tandem-editor 0.16.0 → 0.17.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,271 @@
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-Brg8F0cb.js","assets/CoworkSettings-C0m1IhNy.css","assets/dist-CHppK3gQ.js","assets/prod-Pu_njNLv.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){return e()}function _(e){for(var t=0;t<e.length;t++)e[t]()}function v(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function y(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 b=1024,x=2048,S=4096,C=8192,w=16384,ee=32768,T=1<<25,E=65536,te=1<<19,D=1<<20,ne=1<<25,re=65536,ie=1<<21,ae=1<<22,oe=1<<23,se=Symbol(`$state`),ce=Symbol(`legacy props`),le=Symbol(``),ue=Symbol(`attributes`),de=Symbol(`class`),fe=Symbol(`style`),pe=Symbol(`text`),me=Symbol(`form reset`),he=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},ge=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function _e(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function ve(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function ye(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function be(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function xe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Se(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ce(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function we(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Te(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Ee(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function De(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Oe(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var ke={},Ae=Symbol(),je=`http://www.w3.org/1999/xhtml`,Me=`http://www.w3.org/2000/svg`,Ne=`http://www.w3.org/1998/Math/MathML`;function Pe(){console.warn(`https://svelte.dev/e/derived_inert`)}function Fe(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Ie(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function Le(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var Re=!1;function ze(e){Re=e}var Be;function Ve(e){if(e===null)throw Fe(),ke;return Be=e}function He(){return Ve(bn(Be))}function O(e){if(Re){if(bn(Be)!==null)throw Fe(),ke;Be=e}}function k(e=1){if(Re){for(var t=e,n=Be;t--;)n=bn(n);Be=n}}function Ue(e=!0){for(var t=0,n=Be;;){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=bn(n);e&&n.remove(),n=i}}function We(e){if(!e||e.nodeType!==8)throw Fe(),ke;return e.data}function Ge(e){return e===this.v}function Ke(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function qe(e){return!Ke(e,this.v)}var Je=!1,Ye=!1;function Xe(){Ye=!0}var Ze=null;function Qe(e){Ze=e}function A(e,t=!1,n){Ze={p:Ze,i:!1,c:null,e:null,s:e,x:null,r:lr,l:Ye&&!t?{s:null,u:null,$:[]}:null}}function j(e){var t=Ze,n=t.e;if(n!==null){t.e=null;for(var r of n)In(r)}return e!==void 0&&(t.x=e),t.i=!0,Ze=t.p,e??{}}function $e(){return!Ye||Ze!==null&&Ze.l===null}var et=[];function tt(){var e=et;et=[],_(e)}function nt(e){if(et.length===0&&!bt){var t=et;queueMicrotask(()=>{t===et&&tt()})}et.push(e)}function rt(){for(;et.length>0;)tt()}function it(e){var t=lr;if(t===null)return or.f|=oe,e;if(!(t.f&32768)&&!(t.f&4))throw e;at(e,t)}function at(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 ot=~(x|S|b);function st(e,t){e.f=e.f&ot|t}function ct(e){e.f&512||e.deps===null?st(e,b):st(e,S)}function lt(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=re,lt(t.deps))}function ut(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),lt(e.deps),st(e,b)}var dt=!1,ft=!1;function pt(e){var t=ft;try{return ft=!1,[e(),ft]}finally{ft=t}}var mt=null,ht=null,gt=null,_t=null,vt=null,yt=null,bt=!1,xt=!1,St=null,Ct=null,wt=0,Tt=1,Et=class e{id=Tt++;#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)st(r,x),t(r);for(r of n.m)st(r,S),t(r)}this.#m.add(e)}#_(){if(this.#e=!0,wt++>1e3&&(this.#w(),Ot()),!this.#g()){for(let e of this.#d)this.#f.delete(e),st(e,x),this.schedule(e);for(let e of this.#f)st(e,S),this.schedule(e)}let t=this.#l;this.#l=[],this.apply();var n=St=[],r=[],i=Ct=[];for(let e of t)try{this.#v(e,n,r)}catch(t){throw Ft(e),t}if(gt=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(St=null,Ct=null,this.#g()){this.#x(r),this.#x(n);for(let[e,t]of this.#p)Pt(e,t);i.length>0&&gt.#_();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(),_t=this,At(r),At(n),_t=null,this.#c?.resolve();var s=gt;if(this.linked&&this.#o===0&&this.#w(),Je&&!this.linked&&(this.#S(),gt=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^=b;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^=b:i&4?t.push(r):Je&&i&16777224?n.push(r):Sr(r)&&(i&16&&this.#f.add(r),Dr(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),st(i,x),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#w(),gt=this,this.#_()}#x(e){for(var t=0;t<e.length;t+=1)ut(e[t],this.#d,this.#f)}capture(e,t,n=!1){e.v!==Ae&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),vt?.set(e,t)),this.is_fork||(e.v=t)}activate(){gt=this}deactivate(){gt=null,vt=null}flush(){try{xt=!0,gt=this,this.#_()}finally{wt=0,yt=null,St=null,Ct=null,xt=!1,gt=null,vt=null,en.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=mt;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)jt(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)&&Mt(e,s,a)&&(e.f&4194320?(st(e,x),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,nt(()=>{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??=v()).promise}static ensure(){if(gt===null){let t=gt=new e;t.#C(),!xt&&!bt&&nt(()=>{t.#e||t.flush()})}return gt}apply(){if(!Je||!this.is_fork&&this.#t===null&&this.#n===null){vt=null;return}vt=new Map;for(let[e,[t]]of this.current)vt.set(e,t);for(let t=mt;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)vt.has(e)||vt.set(e,n)}}schedule(e){if(yt=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(St!==null&&t===lr&&(Je||(or===null||!(or.f&2))&&!dt))return;if(n&96){if(!(n&1024))return;t.f^=b}}this.#l.push(t)}#C(){ht===null?mt=ht=this:(ht.#n=this,this.#t=ht),ht=this}#w(){var e=this.#t,t=this.#n;e===null?mt=t:e.#n=t,t===null?ht=e:t.#t=e,this.linked=!1}};function Dt(e){var t=bt;bt=!0;try{var n;for(e&&(gt!==null&&!gt.is_fork&&gt.flush(),n=e());;){if(rt(),gt===null)return n;gt.flush()}}finally{bt=t}}function Ot(){try{Ce()}catch(e){at(e,yt)}}var kt=null;function At(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&Sr(r)&&(kt=new Set,Dr(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&Xn(r),kt?.size>0)){en.clear();for(let e of kt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)kt.has(n)&&(kt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Dr(n)}}kt.clear()}}kt=null}}function jt(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?jt(i,t,n,r):e&4194320&&!(e&2048)&&Mt(i,t,r)&&(st(i,x),Nt(i))}}function Mt(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&&Mt(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function Nt(e){gt.schedule(e)}function Pt(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),st(e,b);for(var n=e.first;n!==null;)Pt(n,t),n=n.next}}function Ft(e){st(e,b);for(var t=e.first;t!==null;)Ft(t),t=t.next}function It(e){let t=0,n=nn(0),r;return()=>{Pn()&&(B(n),Hn(()=>(t===0&&(r=jr(()=>e(()=>cn(n)))),t+=1,()=>{nt(()=>{--t,t===0&&(r?.(),r=void 0,cn(n))})})))}}var Lt=E|te;function Rt(e,t,n,r){new zt(e,t,n,r)}var zt=class{parent;is_pending=!1;transform_error;#e;#t=Re?Be: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=It(()=>(this.#m=nn(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=lr;t.b=this,t.f|=128,n(e)},this.parent=lr.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Un(()=>{if(Re){let e=this.#t;He();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()},Lt),Re&&(this.#e=Be)}#g(){try{this.#a=Wn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=Wn(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=Wn(()=>e(this.#e)),nt(()=>{var e=this.#c=document.createDocumentFragment(),t=vn();e.append(t),this.#a=this.#x(()=>Wn(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,Zn(this.#o,()=>{this.#o=null}),this.#b(gt))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=Wn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();tr(this.#a,e);let t=this.#n.pending;this.#o=Wn(()=>t(this.#e))}else this.#b(gt)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){ut(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=lr,n=or,r=Ze;ur(this.#i),cr(this.#i),Qe(this.#i.ctx);try{return Et.ensure(),e()}catch(e){return it(e),null}finally{ur(t),cr(n),Qe(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&&Zn(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,nt(()=>{this.#d=!1,this.#m&&an(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),B(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;gt?.is_fork?(this.#a&&gt.skip_effect(this.#a),this.#o&&gt.skip_effect(this.#o),this.#s&&gt.skip_effect(this.#s),gt.on_fork_commit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(Jn(this.#a),null),this.#o&&=(Jn(this.#o),null),this.#s&&=(Jn(this.#s),null),Re&&(Ve(this.#t),k(),Ve(Ue()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){Le();return}r=!0,i&&Oe(),this.#s!==null&&Zn(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){at(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return Wn(()=>{var t=lr;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return at(e,this.#i.parent),null}}))};nt(()=>{var t;try{t=this.transform_error(e)}catch(e){at(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>at(e,this.#i&&this.#i.parent)):o(t)})}};function Bt(e,t,n,r){let i=$e()?Wt:qt;var a=e.filter(e=>!e.settled);if(n.length===0&&a.length===0){r(t.map(i));return}var o=lr,s=Vt(),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){at(e,o)}Ht()}}var u=Ut();if(n.length===0){c.then(()=>l(t.map(i))).finally(u);return}function d(){Promise.all(n.map(e=>Kt(e))).then(e=>l([...t.map(i),...e])).catch(e=>at(e,o)).finally(u)}c?c.then(()=>{s(),d(),Ht()}):d()}function Vt(){var e=lr,t=or,n=Ze,r=gt;return function(i=!0){ur(e),cr(t),Qe(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function Ht(e=!0){ur(null),cr(null),Qe(null),e&&gt?.deactivate()}function Ut(){var e=lr,t=e.b,n=gt,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 Wt(e){var t=2|x;return lr!==null&&(lr.f|=te),{ctx:Ze,deps:null,effects:null,equals:Ge,f:t,fn:e,reactions:null,rv:0,v:Ae,wv:0,parent:lr,ac:null}}var Gt=Symbol(`obsolete`);function Kt(e,t,n){let r=lr;r===null&&ve();var i=void 0,a=nn(Ae),o=!or,s=new Set;return Vn(()=>{var t=lr,n=v();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==he&&n.reject(e)}).finally(Ht)}catch(e){n.reject(e),Ht()}var c=gt;if(o){if(t.f&32768)var l=Ut();if(r.b.is_rendered())c.async_deriveds.get(t)?.reject(Gt);else for(let e of s.values())e.reject(Gt);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==Gt&&(c.activate(),t?(a.f|=oe,an(a,t)):(a.f&8388608&&(a.f^=oe),an(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),Fn(()=>{for(let e of s)e.reject(Gt)}),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=Wt(e);return Je||fr(t),t}function qt(e){let t=Wt(e);return t.equals=qe,t}function Jt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)Jn(t[n])}}function Yt(e){var t,n=lr,r=e.parent;if(!ir&&r!==null&&r.f&24576)return Pe(),e.v;ur(r);try{e.f&=~re,Jt(e),t=wr(e)}finally{ur(n)}return t}function Xt(e){var t=Yt(e);if(!e.equals(t)&&(e.wv=xr(),(!gt?.is_fork||e.deps===null)&&(gt===null?e.v=t:(gt.capture(e,t,!0),_t?.capture(e,t,!0)),e.deps===null))){st(e,b);return}ir||(vt===null?ct(e):(Pn()||gt?.is_fork)&&vt.set(e,t))}function Zt(e){if(e.effects!==null)for(let t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(he),t.teardown=m,t.ac=null,Er(t,0),Kn(t))}function Qt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&Dr(t)}var $t=new Set,en=new Map,tn=!1;function nn(e,t){return{f:0,v:e,reactions:null,equals:Ge,rv:0,wv:0}}function N(e,t){let n=nn(e,t);return fr(n),n}function rn(e,t=!1,n=!0){let r=nn(e);return t||(r.equals=qe),Ye&&n&&Ze!==null&&Ze.l!==null&&(Ze.l.s??=[]).push(r),r}function P(e,t,n=!1){return or!==null&&(!sr||or.f&131072)&&$e()&&or.f&4325394&&(dr===null||!i.call(dr,e))&&De(),an(e,n?un(t):t,Ct)}function an(e,t,n=null){if(!e.equals(t)){en.set(e,ir?t:e.v);var r=Et.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&Yt(t),vt===null&&ct(t)}e.wv=xr(),ln(e,x,n),$e()&&lr!==null&&lr.f&1024&&!(lr.f&96)&&(hr===null?gr([e]):hr.push(e)),!r.is_fork&&$t.size>0&&!tn&&on()}return t}function on(){tn=!1;for(let e of $t){e.f&1024&&st(e,S);let t;try{t=Sr(e)}catch{t=!0}t&&Dr(e)}$t.clear()}function sn(e,t=1){var n=B(e),r=t===1?n++:n--;return P(e,n),r}function cn(e){P(e,e.v+1)}function ln(e,t,n){var r=e.reactions;if(r!==null)for(var i=$e(),a=r.length,o=0;o<a;o++){var s=r[o],c=s.f;if(!(!i&&s===lr)){var l=(c&x)===0;if(l&&st(s,t),c&131072)$t.add(s);else if(c&2){var u=s;vt?.delete(u),c&65536||(c&512&&(lr===null||!(lr.f&2097152))&&(s.f|=re),ln(u,S,n))}else if(l){var d=s;c&16&&kt!==null&&kt.add(d),n===null?Nt(d):n.push(d)}}}}function un(e){if(typeof e!=`object`||!e||se 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=yr,f=e=>{if(yr===c)return e();var t=or,n=yr;cr(null),br(c);var r=e();return cr(t),br(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)&&Te();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(Ae,o));r.set(t,e),cn(a)}}else P(n,Ae),cn(a);return!0},get(t,n,i){if(n===se)return e;var a=r.get(n),c=n in t;if(a===void 0&&(!c||s(t,n)?.writable)&&(a=f(()=>N(un(c?t[n]:Ae),o)),r.set(n,a)),a!==void 0){var l=B(a);return l===Ae?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!==Ae)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return n},has(e,t){if(t===se)return!0;var n=r.get(t),i=n!==void 0&&n.v!==Ae||Reflect.has(e,t);return(n!==void 0||lr!==null&&(!i||s(e,t)?.writable))&&(n===void 0&&(n=f(()=>N(i?un(e[t]):Ae,o)),r.set(t,n)),B(n)===Ae)?!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(Ae,o)),r.set(d+``,p)):P(p,Ae)}if(l===void 0)(!u||s(e,t)?.writable)&&(l=f(()=>N(void 0,o)),P(l,un(n)),r.set(t,l));else{u=l.v!==Ae;var m=f(()=>un(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)}cn(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!==Ae});for(var[n,i]of r)i.v!==Ae&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Ee()}})}function dn(e){try{if(typeof e==`object`&&e&&se in e)return e[se]}catch{}return e}function fn(e,t){return Object.is(dn(e),dn(t))}new Set([`copyWithin`,`fill`,`pop`,`push`,`reverse`,`shift`,`sort`,`splice`,`unshift`]);var pn,mn,hn,gn;function _n(){if(pn===void 0){pn=window,mn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;hn=s(t,`firstChild`).get,gn=s(t,`nextSibling`).get,f(e)&&(e[de]=void 0,e[ue]=null,e[fe]=void 0,e.__e=void 0),f(n)&&(n[pe]=void 0)}}function vn(e=``){return document.createTextNode(e)}function yn(e){return hn.call(e)}function bn(e){return gn.call(e)}function F(e,t){if(!Re)return yn(e);var n=yn(Be);if(n===null)n=Be.appendChild(vn());else if(t&&n.nodeType!==3){var r=vn();return n?.before(r),Ve(r),r}return t&&wn(n),Ve(n),n}function I(e,t=!1){if(!Re){var n=yn(e);return n instanceof Comment&&n.data===``?bn(n):n}if(t){if(Be?.nodeType!==3){var r=vn();return Be?.before(r),Ve(r),r}wn(Be)}return Be}function L(e,t=1,n=!1){let r=Re?Be:e;for(var i;t--;)i=r,r=bn(r);if(!Re)return r;if(n){if(r?.nodeType!==3){var a=vn();return r===null?i?.after(a):r.before(a),Ve(a),a}wn(r)}return Ve(r),r}function xn(e){e.textContent=``}function Sn(){return!Je||kt!==null?!1:(lr.f&ee)!==0}function Cn(e,t,n){let r=n?{is:n}:void 0;return document.createElementNS(t??`http://www.w3.org/1999/xhtml`,e,r)}function wn(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 Tn(e,t){if(t){let t=document.body;e.autofocus=!0,nt(()=>{document.activeElement===t&&e.focus()})}}function En(e){Re&&yn(e)!==null&&xn(e)}var Dn=!1;function On(){Dn||(Dn=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[me]?.()})},{capture:!0}))}function kn(e){var t=or,n=lr;cr(null),ur(null);try{return e()}finally{cr(t),ur(n)}}function An(e,t,n,r=n){e.addEventListener(t,()=>kn(n));let i=e[me];i?e[me]=()=>{i(),r(!0)}:e[me]=()=>r(!0),On()}function jn(e){lr===null&&(or===null&&Se(e),xe()),ir&&be(e)}function Mn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Nn(e,t){var n=lr;n!==null&&n.f&8192&&(e|=C);var r={ctx:Ze,deps:null,nodes:null,f:e|x|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};gt?.register_created_effect(r);var i=r;if(e&4)St===null?Et.ensure().schedule(r):St.push(r);else if(t!==null){try{Dr(r)}catch(e){throw Jn(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|=E))}if(i!==null&&(i.parent=n,n!==null&&Mn(i,n),or!==null&&or.f&2&&!(e&64))){var a=or;(a.effects??=[]).push(i)}return r}function Pn(){return or!==null&&!sr}function Fn(e){let t=Nn(8,null);return st(t,b),t.teardown=e,t}function R(e){jn(`$effect`);var t=lr.f;if(!or&&t&32&&!(t&32768)){var n=Ze;(n.e??=[]).push(e)}else return In(e)}function In(e){return Nn(4|D,e)}function Ln(e){return jn(`$effect.pre`),Nn(8|D,e)}function Rn(e){Et.ensure();let t=Nn(64|te,e);return()=>{Jn(t)}}function zn(e){Et.ensure();let t=Nn(64|te,e);return(e={})=>new Promise(n=>{e.outro?Zn(t,()=>{Jn(t),n(void 0)}):(Jn(t),n(void 0))})}function Bn(e){return Nn(4,e)}function Vn(e){return Nn(ae|te,e)}function Hn(e,t=0){return Nn(8|t,e)}function z(e,t=[],n=[],r=[]){Bt(r,t,n,t=>{Nn(8,()=>e(...t.map(B)))})}function Un(e,t=0){return Nn(16|t,e)}function Wn(e){return Nn(32|te,e)}function Gn(e){var t=e.teardown;if(t!==null){let e=ir,n=or;ar(!0),cr(null);try{t.call(null)}finally{ar(e),cr(n)}}}function Kn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&kn(()=>{e.abort(he)});var r=n.next;n.f&64?n.parent=null:Jn(n,t),n=r}}function qn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Jn(t),t=n}}function Jn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Yn(e.nodes.start,e.nodes.end),n=!0),st(e,T),Kn(e,t&&!n),Er(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Gn(e),e.f^=T,e.f|=w;var i=e.parent;i!==null&&i.first!==null&&Xn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Yn(e,t){for(;e!==null;){var n=e===t?null:bn(e);e.remove(),e=n}}function Xn(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 Zn(e,t,n=!0){var r=[];Qn(e,r,!0);var i=()=>{n&&Jn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function Qn(e,t,n){if(!(e.f&8192)){e.f^=C;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;Qn(i,t,o?n:!1)}i=a}}}function $n(e){er(e,!0)}function er(e,t){if(e.f&8192){e.f^=C,e.f&1024||(st(e,x),Et.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;er(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 tr(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:bn(n);t.append(n),n=i}}var nr=null,rr=!1,ir=!1;function ar(e){ir=e}var or=null,sr=!1;function cr(e){or=e}var lr=null;function ur(e){lr=e}var dr=null;function fr(e){or!==null&&(!Je||or.f&2)&&(dr===null?dr=[e]:dr.push(e))}var pr=null,mr=0,hr=null;function gr(e){hr=e}var _r=1,vr=0,yr=vr;function br(e){yr=e}function xr(){return++_r}function Sr(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~re),t&4096){for(var n=e.deps,r=n.length,i=0;i<r;i++){var a=n[i];if(Sr(a)&&Xt(a),a.wv>e.wv)return!0}t&512&&vt===null&&st(e,b)}return!1}function Cr(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!Je&&dr!==null&&i.call(dr,e)))for(var a=0;a<r.length;a++){var o=r[a];o.f&2?Cr(o,t,!1):t===o&&(n?st(o,x):o.f&1024&&st(o,S),Nt(o))}}function wr(e){var t=pr,n=mr,r=hr,i=or,a=dr,o=Ze,s=sr,c=yr,l=e.f;pr=null,mr=0,hr=null,or=l&96?null:e,dr=null,Qe(e.ctx),sr=!1,yr=++vr,e.ac!==null&&(kn(()=>{e.ac.abort(he)}),e.ac=null);try{e.f|=ie;var u=e.fn,d=u();e.f|=ee;var f=e.deps,p=gt?.is_fork;if(pr!==null){var m;if(p||Er(e,mr),f!==null&&mr>0)for(f.length=mr+pr.length,m=0;m<pr.length;m++)f[mr+m]=pr[m];else e.deps=f=pr;if(Pn()&&e.f&512)for(m=mr;m<f.length;m++)(f[m].reactions??=[]).push(e)}else !p&&f!==null&&mr<f.length&&(Er(e,mr),f.length=mr);if($e()&&hr!==null&&!sr&&f!==null&&!(e.f&6146))for(m=0;m<hr.length;m++)Cr(hr[m],e);if(i!==null&&i!==e){if(vr++,i.deps!==null)for(let e=0;e<n;e+=1)i.deps[e].rv=vr;if(t!==null)for(let e of t)e.rv=vr;hr!==null&&(r===null?r=hr:r.push(...hr))}return e.f&8388608&&(e.f^=oe),d}catch(e){return it(e)}finally{e.f^=ie,pr=t,mr=n,hr=r,or=i,dr=a,Qe(o),sr=s,yr=c}}function Tr(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&&(pr===null||!i.call(pr,t))){var s=t;s.f&512&&(s.f^=512,s.f&=~re),s.v!==Ae&&ct(s),Zt(s),Er(s,0)}}function Er(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)Tr(e,n[r])}function Dr(e){var t=e.f;if(!(t&16384)){st(e,b);var n=lr,r=rr;lr=e,rr=!0;try{t&16777232?qn(e):Kn(e),Gn(e);var i=wr(e);e.teardown=typeof i==`function`?i:null,e.wv=_r}finally{rr=r,lr=n}}}async function Or(){if(Je)return new Promise(e=>{requestAnimationFrame(()=>e()),setTimeout(()=>e())});await Promise.resolve(),Dt()}function B(e){var t=(e.f&2)!=0;if(nr?.add(e),or!==null&&!sr&&!(lr!==null&&lr.f&16384)&&(dr===null||!i.call(dr,e))){var n=or.deps;if(or.f&2097152)e.rv<vr&&(e.rv=vr,pr===null&&n!==null&&n[mr]===e?mr++:pr===null?pr=[e]:pr.push(e));else{(or.deps??=[]).push(e);var r=e.reactions;r===null?e.reactions=[or]:i.call(r,or)||r.push(or)}}if(ir&&en.has(e))return en.get(e);if(t){var a=e;if(ir){var o=a.v;return(!(a.f&1024)&&a.reactions!==null||Ar(a))&&(o=Yt(a)),en.set(a,o),o}var s=(a.f&512)==0&&!sr&&or!==null&&(rr||(or.f&512)!=0),c=(a.f&ee)===0;Sr(a)&&(s&&(a.f|=512),Xt(a)),s&&!c&&(Qt(a),kr(a))}if(vt?.has(e))return vt.get(e);if(e.f&8388608)throw e.v;return e.v}function kr(e){if(e.f|=512,e.deps!==null)for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&(Qt(t),kr(t))}function Ar(e){if(e.v===Ae)return!0;if(e.deps===null)return!1;for(let t of e.deps)if(en.has(t)||t.f&2&&Ar(t))return!0;return!1}function jr(e){var t=sr;try{return sr=!0,e()}finally{sr=t}}function Mr(e){if(!(typeof e!=`object`||!e||e instanceof EventTarget)){if(se in e)Nr(e);else if(!Array.isArray(e))for(let t in e){let n=e[t];typeof n==`object`&&n&&se in n&&Nr(n)}}}function Nr(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{Nr(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 Pr=[`touchstart`,`touchmove`];function Fr(e){return Pr.includes(e)}var Ir=Symbol(`events`),Lr=new Set,Rr=new Set;function zr(e,t,n,r={}){function i(e){if(r.capture||Ur.call(t,e),!e.cancelBubble)return kn(()=>n?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?nt(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Br(e,t,n,r,i){var a={capture:r,passive:i},o=zr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&Fn(()=>{t.removeEventListener(e,o,a)})}function V(e,t,n){(t[Ir]??={})[e]=n}function Vr(e){for(var t=0;t<e.length;t++)Lr.add(e[t]);for(var n of Rr)n(e)}var Hr=null;function Ur(e){var t=this,n=t.ownerDocument,r=e.type,i=e.composedPath?.()||[],a=i[0]||e.target;Hr=e;var s=0,c=Hr===e&&e[Ir];if(c){var l=i.indexOf(c);if(l!==-1&&(t===document||t===window)){e[Ir]=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=or,f=lr;cr(null),ur(null);try{for(var p,m=[];a!==null;){var h=a.assignedSlot||a.parentNode||a.host||null;try{var g=a[Ir]?.[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[Ir]=t,delete e.currentTarget,cr(d),ur(f)}}}var Wr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Gr(e){return Wr?.createHTML(e)??e}function Kr(e){var t=Cn(`template`);return t.innerHTML=Gr(e.replaceAll(`<!>`,`<!---->`)),t.content}function qr(e,t){var n=lr;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(Re)return qr(Be,null),Be;i===void 0&&(i=Kr(a?e:`<!>`+e),n||(i=yn(i)));var t=r||mn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=yn(t),s=t.lastChild;qr(o,s)}else qr(t,t);return t}}function Jr(e,t,n=`svg`){var r=!e.startsWith(`<!>`),i=(t&1)!=0,a=`<${n}>${r?e:`<!>`+e}</${n}>`,o;return()=>{if(Re)return qr(Be,null),Be;if(!o){var e=yn(Kr(a));if(i)for(o=document.createDocumentFragment();yn(e);)o.appendChild(yn(e));else o=yn(e)}var t=o.cloneNode(!0);if(i){var n=yn(t),r=t.lastChild;qr(n,r)}else qr(t,t);return t}}function Yr(e,t){return Jr(e,t,`svg`)}function Xr(e=``){if(!Re){var t=vn(e+``);return qr(t,t),t}var n=Be;return n.nodeType===3?wn(n):(n.before(n=vn()),Ve(n)),qr(n,n),n}function Zr(){if(Re)return qr(Be,null),Be;var e=document.createDocumentFragment(),t=document.createComment(``),n=vn();return e.append(t,n),qr(t,n),e}function U(e,t){if(Re){var n=lr;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=Be),He();return}e!==null&&e.before(t)}var Qr=!0;function W(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[pe]??=e.nodeValue)&&(e[pe]=n,e.nodeValue=`${n}`)}function $r(e,t){return ti(e,t)}var ei=new Map;function ti(e,{target:t,anchor:n,props:r={},events:i,context:o,intro:s=!0,transformError:c}){_n();var l=void 0,u=zn(()=>{var u=n??t.appendChild(vn());Rt(u,{pending:()=>{}},t=>{A({});var n=Ze;if(o&&(n.c=o),i&&(r.$$events=i),Re&&qr(t,null),Qr=s,l=e(t,r)||{},Qr=!0,Re&&(lr.nodes.end=Be,Be===null||Be.nodeType!==8||Be.data!==`]`))throw Fe(),ke;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=Fr(r);for(let e of[t,document]){var a=ei.get(e);a===void 0&&(a=new Map,ei.set(e,a));var o=a.get(r);o===void 0?(e.addEventListener(r,Ur,{passive:i}),a.set(r,1)):a.set(r,o+1)}}}};return f(a(Lr)),Rr.add(f),()=>{for(var e of d)for(let n of[t,document]){var r=ei.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Ur),r.delete(e),r.size===0&&ei.delete(n)):r.set(e,i)}Rr.delete(f),u!==n&&u.parentNode?.removeChild(u)}});return ni.set(l,u),l}var ni=new WeakMap,ri=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)$n(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&&(Jn(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();tr(r,t),t.append(vn()),this.#n.set(e,{effect:r,fragment:t})}else Jn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Zn(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)||(Jn(n.effect),this.#n.delete(e))};ensure(e,t){var n=gt,r=Sn();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=vn();i.append(a),this.#n.set(e,{effect:Wn(()=>t(a)),fragment:i})}else this.#t.set(e,Wn(()=>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 Re&&(this.anchor=Be),this.#a(n)}},ii=0,ai=1,oi=2;function si(e,t,n,r,i){Re&&He();var a=$e(),o=Ae,s=a?nn(o):rn(o,!1,!1),c=a?nn(o):rn(o,!1,!1),l=new ri(e);Un(()=>{var a=gt;a.deactivate();var o=t();a.activate();var u=!1;let d=Re&&h(o)===(e.data===`[!`);if(d&&(Ve(Ue()),ze(!1)),h(o)){var f=Vt(),p=!1;let e=e=>{if(!u){p=!0,f(!1),Et.ensure(),Re&&ze(!1);try{e()}finally{Ht(!1),bt||Dt()}}};o.then(t=>{e(()=>{an(s,t),l.ensure(ai,r&&(e=>r(e,s)))})},t=>{e(()=>{if(an(c,t),l.ensure(oi,i&&(e=>i(e,c))),!i)throw c.v})}),Re?l.ensure(ii,n):nt(()=>{p||e(()=>{l.ensure(ii,n)})})}else an(s,o),l.ensure(ai,r&&(e=>r(e,s)));return d&&ze(!0),()=>{u=!0}})}function G(e,t,n=!1){var r;Re&&(r=Be,He());var i=new ri(e),a=n?E:0;function o(e,t){if(Re){var n=We(r);if(e!==parseInt(n.substring(1))){var a=Ue();Ve(a),i.anchor=a,ze(!1),i.ensure(e,t),ze(!0);return}}i.ensure(e,t)}Un(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var ci=Symbol(`NaN`);function li(e,t,n){Re&&He();var r=new ri(e),i=!$e();Un(()=>{var e=t();e!==e&&(e=ci),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function ui(e,t){return t}function di(e,t,n){for(var r=[],i=t.length,o,s=t.length,c=0;c<i;c++){let n=t[c];Zn(n,()=>{if(o){if(o.pending.delete(n),o.done.add(n),o.pending.size===0){var t=e.outrogroups;fi(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;xn(d),d.append(u),e.items.clear()}fi(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function fi(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,tr(a,document.createDocumentFragment())):Jn(t[i],n)}}var pi;function mi(e,t,r,i,o,s=null){var c=e,l=new Map;if(t&4){var u=e;c=Re?Ve(yn(u)):u.appendChild(vn())}Re&&He();var d=null,f=qt(()=>{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,gi(v,p,c,t,i),d!==null&&(p.length===0?d.f&33554432?(d.f^=ne,vi(d,null,c)):$n(d):Zn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Un(()=>{p=B(f);var e=p.length;let n=!1;Re&&We(c)===`[!`!=(e===0)&&(c=Ue(),Ve(c),ze(!1),n=!0);for(var a=new Set,u=gt,v=Sn(),y=0;y<e;y+=1){Re&&Be.nodeType===8&&Be.data===`]`&&(c=Be,n=!0,ze(!1));var b=p[y],x=i(b,y),S=h?null:l.get(x);S?(S.v&&an(S.v,b),S.i&&an(S.i,y),v&&u.unskip_effect(S.e)):(S=_i(l,h?c:pi??=vn(),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=Wn(()=>s(c)):(d=Wn(()=>s(pi??=vn())),d.f|=ne)),e>a.size&&ye(``,``,``),Re&&e>0&&Ve(Ue()),!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&&ze(!0),B(f)}),flags:t,items:l,pending:m,outrogroups:null,fallback:d};h=!1,Re&&(c=Be)}function hi(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function gi(e,t,n,r,i){var o=(r&8)!=0,s=t.length,c=e.items,l=hi(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&&($n(_),o&&(_.nodes?.a?.unfix(),(f??=new Set).delete(_))),_.f&33554432)if(_.f^=ne,_===l)vi(_,null,n);else{var y=d?d.next:l;_===e.effect.last&&(e.effect.last=_.prev),_.prev&&(_.prev.next=_.next),_.next&&(_.next.prev=_.prev),yi(e,d,_),yi(e,_,y),vi(_,y,n),d=_,p=[],m=[],l=hi(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)vi(p[x],b,n);for(x=0;x<m.length;x+=1)u.delete(m[x]);yi(e,S.prev,C.next),yi(e,d,S),yi(e,C,b),l=b,d=C,--v,p=[],m=[]}else u.delete(_),vi(_,l,n),yi(e,_.prev,_.next),yi(e,_,d===null?e.effect.first:d.next),yi(e,d,_),d=_;continue}for(p=[],m=[];l!==null&&l!==_;)(u??=new Set).add(l),m.push(l),l=hi(l.next);if(l===null)continue}_.f&33554432||p.push(_),d=_,l=hi(_.next)}if(e.outrogroups!==null){for(let t of e.outrogroups)t.pending.size===0&&(fi(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=hi(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()}di(e,w,T)}}o&&nt(()=>{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function _i(e,t,n,r,i,a,o,s){var c=o&1?o&16?nn(n):rn(n,!1,!1):null,l=o&2?nn(i):null;return{v:c,i:l,e:Wn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function vi(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=bn(r);if(a.before(r),r===i)return;r=o}}function yi(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function bi(e,t,n=!1,r=!1,i=!1,a=!1){var o=e,s=``;if(n){var c=e;Re&&(o=Ve(yn(c)))}z(()=>{var e=lr;if(s===(s=t()??``)){Re&&He();return}if(n&&!Re){e.nodes=null,c.innerHTML=s,s!==``&&qr(yn(c),c.lastChild);return}if(e.nodes!==null&&(Yn(e.nodes.start,e.nodes.end),e.nodes=null),s!==``){if(Re){for(var a=Be.data,l=He(),u=l;l!==null&&(l.nodeType!==8||l.data!==``);)u=l,l=bn(l);if(l===null)throw Fe(),ke;qr(Be,u),o=Ve(l);return}var d=Cn(r?`svg`:i?`math`:`template`,r?Me:i?Ne:void 0);d.innerHTML=s;var f=r||i?d:d.content;if(qr(yn(f),f.lastChild),r||i)for(;yn(f);)o.before(yn(f));else o.before(f)}})}function xi(e,t,...n){var r=new ri(e);Un(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},E)}function Si(e,t,n){var r;Re&&(r=Be,He());var i=new ri(e);Un(()=>{var e=t()??null;if(Re&&We(r)===`[`!=(e!==null)){var a=Ue();Ve(a),i.anchor=a,ze(!1),i.ensure(e,e&&(t=>n(t,e))),ze(!0);return}i.ensure(e,e&&(t=>n(t,e)))},E)}var Ci=()=>performance.now(),wi={tick:e=>requestAnimationFrame(e),now:()=>Ci(),tasks:new Set};function Ti(){let e=wi.now();wi.tasks.forEach(t=>{t.c(e)||(wi.tasks.delete(t),t.f())}),wi.tasks.size!==0&&wi.tick(Ti)}function Ei(e){let t;return wi.tasks.size===0&&wi.tick(Ti),{promise:new Promise(n=>{wi.tasks.add(t={c:e,f:n})}),abort(){wi.tasks.delete(t)}}}function Di(e,t){kn(()=>{e.dispatchEvent(new CustomEvent(t))})}function Oi(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 ki(e){let t={},n=e.split(`;`);for(let e of n){let[n,r]=e.split(`:`);if(!n||r===void 0)break;let i=Oi(n.trim());t[i]=r.trim()}return t}var Ai=e=>e,ji=null;function Mi(e,t,n){var r=(ji??lr).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=Pi(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 Ni(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 kn(()=>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=Pi(t,m(),p,1,()=>{Di(t,`introstart`)},()=>{Di(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=Pi(t,m(),f,0,()=>{Di(t,`outrostart`)},()=>{Di(t,`outroend`),e?.()})},stop:()=>{f?.abort(),p?.abort()}},g=lr;if((g.nodes.t??=[]).push(h),i&&Qr){var _=s;if(!_){for(var v=g.parent;v&&v.f&65536;)for(;(v=v.parent)&&!(v.f&16););_=!v||(v.f&32768)!=0}_&&Bn(()=>{jr(()=>h.in())})}}function Pi(e,t,n,r,i,a){var o=r===1;if(p(t)){var s,c=!1;return nt(()=>{c||(s=Pi(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=Ai}=t;var h=[];if(o&&n===void 0&&(d&&d(0,1),u)){var g=ki(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=ki(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&&Ei(()=>{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 Fi(e,t,n){Bn(()=>{var r=jr(()=>t(e,n?.())||{});if(n&&r?.update){var i=!1,a={};Hn(()=>{var e=n();Mr(e),i&&Ke(a,e)&&(a=e,r.update(e))}),i=!0}if(r?.destroy)return()=>r.destroy()})}function Ii(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=Ii(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Li(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Ii(e))&&(r&&(r+=` `),r+=t);return r}function Ri(e){return typeof e==`object`?Li(e):e??``}var zi=[...`
3
+ \r\f\xA0\v`];function Bi(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||zi.includes(r[o-1]))&&(s===r.length||zi.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function Vi(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 Hi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function Ui(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(Hi)),i&&c.push(...Object.keys(i).map(Hi));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=Hi(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+=Vi(r)),i&&(n+=Vi(i,!0)),n=n.trim(),n===``?null:n}return e==null?null:String(e)}function Wi(e,t,n,r,i,a){var o=e[de];if(Re||o!==n||o===void 0){var s=Bi(n,r,a);(!Re||s!==e.getAttribute(`class`))&&(s==null?e.removeAttribute(`class`):t?e.className=s:e.setAttribute(`class`,s)),e[de]=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 Gi(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[fe];if(Re||i!==t){var a=Ui(t,r);(!Re||a!==e.getAttribute(`style`))&&(a==null?e.removeAttribute(`style`):e.style.cssText=a),e[fe]=t}else r&&(Array.isArray(r)?(Gi(e,n?.[0],r[0]),Gi(e,n?.[1],r[1],`important`)):Gi(e,n,r));return r}function Ki(e,t,r=!1){if(e.multiple){if(t==null)return;if(!n(t))return Ie();for(var i of e.options)i.selected=t.includes(Yi(i));return}for(i of e.options)if(fn(Yi(i),t)){i.selected=!0;return}(!r||t!==void 0)&&(e.selectedIndex=-1)}function qi(e){var t=new MutationObserver(()=>{Ki(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),Fn(()=>{t.disconnect()})}function Ji(e,t,n=t){var r=new WeakSet,i=!0;An(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),Yi);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&Yi(o)}n(a),e.__value=a,gt!==null&&r.add(gt)}),Bn(()=>{var a=t();if(e===document.activeElement){var o=Je?_t:gt;if(r.has(o))return}if(Ki(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=Yi(s),n(a))}e.__value=a,i=!1}),qi(e)}function Yi(e){return`__value`in e?e.__value:e.value}var Xi=Symbol(`is custom element`),Zi=Symbol(`is html`),Qi=ge?`link`:`LINK`,$i=ge?`progress`:`PROGRESS`;function ea(e){if(Re){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[me]=n,nt(n),On()}}function ta(e,t){var n=ra(e);n.value===(n.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==$i)||(e.value=t??``)}function na(e,t){var n=ra(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function q(e,t,n,r){var i=ra(e);Re&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===Qi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[le]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&aa(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function ra(e){return e[ue]??={[Xi]:e.nodeName.includes(`-`),[Zi]:e.namespaceURI===je}}var ia=new Map;function aa(e){var t=e.getAttribute(`is`)||e.nodeName,n=ia.get(t);if(n)return n;ia.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 oa(e,t,n=t){var r=new WeakSet;An(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=ca(e)?la(a):a,n(a),gt!==null&&r.add(gt),await Or(),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))}}}),(Re&&e.defaultValue!==e.value||jr(t)==null&&e.value)&&(n(ca(e)?la(e.value):e.value),gt!==null&&r.add(gt)),Hn(()=>{var n=t();if(e===document.activeElement){var i=Je?_t:gt;if(r.has(i))return}ca(e)&&n===la(e.value)||e.type===`date`&&!n&&!e.value||n!==e.value&&(e.value=n??``)})}function sa(e,t,n=t){An(e,`change`,t=>{n(t?e.defaultChecked:e.checked)}),(Re&&e.defaultChecked!==e.checked||jr(t)==null)&&n(e.checked),Hn(()=>{e.checked=!!t()})}function ca(e){var t=e.type;return t===`number`||t===`range`}function la(e){return e===``?null:+e}var ua=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 da(e,t,n){var r=ua.observe(e,()=>n(e[t]));Bn(()=>(jr(()=>n(e[t])),r))}function fa(e,t){return e===t||e?.[se]===t}function pa(e={},t,n,r){var i=Ze.r,a=lr;return Bn(()=>{var o,s;return Hn(()=>{o=s,s=r?.()||[],jr(()=>{fa(n(...s),e)||(t(e,...s),o&&fa(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&&fa(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}function ma(e=!1){let t=Ze,n=t.l.u;if(!n)return;let r=()=>Mr(t.s);if(e){let e=0,n={},i=Wt(()=>{let r=!1,i=t.s;for(let e in i)i[e]!==n[e]&&(n[e]=i[e],r=!0);return r&&e++,e});r=()=>B(i)}n.b.length&&Ln(()=>{ha(t,r),_(n.b)}),R(()=>{let e=jr(()=>n.m.map(g));return()=>{for(let t of e)typeof t==`function`&&t()}}),n.a.length&&R(()=>{ha(t,r),_(n.a)})}function ha(e,t){if(e.l.s)for(let t of e.l.s)B(t);t()}var ga={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 _a(e,t,n){return new Proxy({props:e,exclude:t},ga)}var va={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===se||t===ce)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 ya(...e){return new Proxy({props:e},va)}function J(e,t,n,r){var i=!Ye||(n&2)!=0,a=(n&8)!=0,o=(n&16)!=0,c=r,l=!0,u=void 0,d=()=>o&&i?(u??=Wt(r),B(u)):(l&&(l=!1,c=o?jr(r):r),c);let f;if(a){var p=se in e||ce in e;f=s(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;a?[m,h]=pt(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&we(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?Wt:qt)(()=>(v=!1,g()));a&&B(y);var b=lr;return(function(e,t){if(arguments.length>0){let n=t?B(y):i&&a?un(e):e;return P(y,n),v=!0,c!==void 0&&(c=n),e}return ir&&v||b.f&16384?y.v:B(y)})}function ba(e){Ze===null&&_e(`onMount`),Ye&&Ze.l!==null?Sa(Ze).m.push(e):R(()=>{let t=jr(e);if(typeof t==`function`)return t})}function xa(e){Ze===null&&_e(`onDestroy`),ba(()=>()=>jr(e))}function Sa(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`),Xe();var Ca=3478,wa=3479,Ta=`https://github.com/bloknayrb/tandem`,Ea=`${Ta}/issues/new`,Da=new Set([`.md`,`.txt`,`.html`,`.htm`,`.docx`]),Oa=3e3,ka=3e3,Aa=3e4,ja={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)`},Ma={yellow:`var(--tandem-highlight-yellow)`,green:`var(--tandem-highlight-green)`,blue:`var(--tandem-highlight-blue)`,pink:`var(--tandem-highlight-pink)`};function Na(e){return e&&e in ja?e:`yellow`}var Pa=`tandem`,Fa=`tandem:mode`,Ia=`tandem:settings`,La={left:`tandem-left-panel-width`,right:`tandem-panel-width`},Ra=1e3,za=3e3,Ba=`__tandem_ctrl__`,Va=`annotations`,Ha=`awareness`,Ua=`userAwareness`,Wa=`mode`,Ga=`selectionDwellMs`,Ka=`chat`,qa=`documentMeta`,Ja=`annotationReplies`,Ya=`savedAtVersion`,Xa=`authorship`,Za=`selection`,Qa=`activity`,$a=`claude`,eo=`openDocuments`,to=`activeDocumentId`,no=`activeDocumentEpoch`,ro=`storeReadOnly`,io=`fidelityReport`,ao=`tandem:showAuthorship`,oo=`tandem:decorationVisibility`,so=`tandem:recentFiles`,co=`tandem:userName`,lo=`tandem:user-name-changed`,uo={error:8e3,warning:6e3,info:4e3},fo=5*6e4,po=`tandem:tutorialCompleted`,mo=`tutorial-`,ho=`tandem:coworkOnboardingSkipped`,go=3e4,_o=2e3,vo=`tandem:zoomLevel`,yo=.5,bo=`upload://`,xo=`upload://scratchpad/`;function So(e){return e.startsWith(bo)}function Co(e){return e.startsWith(xo)}function wo(e){if(!Co(e))return null;let t=e.slice(20).split(`/`)[0];return t.length>0?t:null}var To=e=>e,Eo=e=>e,Do;(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})(Do||={});var Oo;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Oo||={});var ko=Do.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Ao=e=>{switch(typeof e){case`undefined`:return ko.undefined;case`string`:return ko.string;case`number`:return Number.isNaN(e)?ko.nan:ko.number;case`boolean`:return ko.boolean;case`function`:return ko.function;case`bigint`:return ko.bigint;case`symbol`:return ko.symbol;case`object`:return Array.isArray(e)?ko.array:e===null?ko.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?ko.promise:typeof Map<`u`&&e instanceof Map?ko.map:typeof Set<`u`&&e instanceof Set?ko.set:typeof Date<`u`&&e instanceof Date?ko.date:ko.object;default:return ko.unknown}},Y=Do.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`]),jo=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,Do.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()}};jo.create=e=>new jo(e);var Mo=(e,t)=>{let n;switch(e.code){case Y.invalid_type:n=e.received===ko.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case Y.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Do.jsonStringifyReplacer)}`;break;case Y.unrecognized_keys:n=`Unrecognized key(s) in object: ${Do.joinValues(e.keys,`, `)}`;break;case Y.invalid_union:n=`Invalid input`;break;case Y.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Do.joinValues(e.options)}`;break;case Y.invalid_enum_value:n=`Invalid enum value. Expected ${Do.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}"`:Do.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,Do.assertNever(e)}return{message:n}},No=Mo;function Po(){return No}var Fo=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=Po(),r=Fo({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Mo?void 0:Mo].filter(e=>!!e)});e.common.issues.push(r)}var Io=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 Lo;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 Lo;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}}},Lo=Object.freeze({status:`aborted`}),Ro=e=>({status:`dirty`,value:e}),zo=e=>({status:`valid`,value:e}),Bo=e=>e.status===`aborted`,Vo=e=>e.status===`dirty`,Ho=e=>e.status===`valid`,Uo=e=>typeof Promise<`u`&&e instanceof Promise,Wo;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(Wo||={});var Go=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}},Ko=(e,t)=>{if(Ho(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 jo(e.common.issues);return this._error=t,this._error}}};function qo(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 Jo=class{get description(){return this._def.description}_getType(e){return Ao(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ao(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Io,ctx:{common:e.parent.common,data:e.data,parsedType:Ao(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Uo(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:Ao(e)};return Ko(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:Ao(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Ho(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=>Ho(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:Ao(e)},r=this._parse({data:e,path:n.path,parent:n});return Ko(n,await(Uo(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 Qs({schema:this,typeName:sc.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 $s.create(this,this._def)}nullable(){return ec.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ns.create(this)}promise(){return Zs.create(this,this._def)}or(e){return Is.create([this,e],this._def)}and(e){return Bs.create(this,e,this._def)}transform(e){return new Qs({...qo(this._def),schema:this,typeName:sc.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new tc({...qo(this._def),innerType:this,defaultValue:t,typeName:sc.ZodDefault})}brand(){return new ic({typeName:sc.ZodBranded,type:this,...qo(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new nc({...qo(this._def),innerType:this,catchValue:t,typeName:sc.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ac.create(this,e)}readonly(){return oc.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Yo=/^c[^\s-]{8,}$/i,Xo=/^[0-9a-z]+$/,Zo=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Qo=/^[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,$o=/^[a-z0-9_-]{21}$/i,es=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ts=/^[-+]?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)?)??$/,ns=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,rs=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,is,as=/^(?:(?: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])$/,ss=/^(?:(?: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])$/,cs=/^(([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]))$/,ls=/^(([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])$/,us=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ds=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,fs=`((\\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])))`,ps=RegExp(`^${fs}$`);function ms(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 hs(e){return RegExp(`^${ms(e)}$`)}function gs(e){let t=`${fs}T${ms(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function _s(e,t){return!!((t===`v4`||!t)&&as.test(e)||(t===`v6`||!t)&&cs.test(e))}function vs(e,t){if(!es.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 ys(e,t){return!!((t===`v4`||!t)&&ss.test(e)||(t===`v6`||!t)&&ls.test(e))}var bs=class e extends Jo{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ko.string){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:ko.string,received:t.parsedType}),Lo}let t=new Io,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`)ns.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`)is||=new RegExp(rs,`u`),is.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`)Qo.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`)$o.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`)Yo.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`)Xo.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`)Zo.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`?gs(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`?ps.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?hs(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`?ts.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`duration`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?_s(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`?vs(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`?ys(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`?us.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`base64`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?ds.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`base64url`,code:Y.invalid_string,message:r.message}),t.dirty()):Do.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,...Wo.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...Wo.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...Wo.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...Wo.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...Wo.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...Wo.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...Wo.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...Wo.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...Wo.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...Wo.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...Wo.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...Wo.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...Wo.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...Wo.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,...Wo.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,...Wo.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...Wo.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...Wo.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...Wo.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...Wo.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...Wo.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...Wo.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...Wo.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...Wo.errToObj(t)})}nonempty(e){return this.min(1,Wo.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}};bs.create=e=>new bs({checks:[],typeName:sc.ZodString,coerce:e?.coerce??!1,...qo(e)});function xs(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 Ss=class e extends Jo{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)!==ko.number){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:ko.number,received:t.parsedType}),Lo}let t,n=new Io;for(let r of this._def.checks)r.kind===`int`?Do.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`?xs(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()):Do.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,Wo.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Wo.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Wo.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Wo.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Wo.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:Wo.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:Wo.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:Wo.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:Wo.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:Wo.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Wo.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:Wo.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:Wo.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:Wo.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`&&Do.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)}};Ss.create=e=>new Ss({checks:[],typeName:sc.ZodNumber,coerce:e?.coerce||!1,...qo(e)});var Cs=class e extends Jo{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)!==ko.bigint)return this._getInvalidInput(e);let t,n=new Io;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()):Do.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:ko.bigint,received:t.parsedType}),Lo}gte(e,t){return this.setLimit(`min`,e,!0,Wo.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Wo.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Wo.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Wo.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Wo.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:Wo.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:Wo.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:Wo.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:Wo.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Wo.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}};Cs.create=e=>new Cs({checks:[],typeName:sc.ZodBigInt,coerce:e?.coerce??!1,...qo(e)});var ws=class extends Jo{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ko.boolean){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:ko.boolean,received:t.parsedType}),Lo}return zo(e.data)}};ws.create=e=>new ws({typeName:sc.ZodBoolean,coerce:e?.coerce||!1,...qo(e)});var Ts=class e extends Jo{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ko.date){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:ko.date,received:t.parsedType}),Lo}if(Number.isNaN(e.data.getTime()))return X(this._getOrReturnCtx(e),{code:Y.invalid_date}),Lo;let t=new Io,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()):Do.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:Wo.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:Wo.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)}};Ts.create=e=>new Ts({checks:[],coerce:e?.coerce||!1,typeName:sc.ZodDate,...qo(e)});var Es=class extends Jo{_parse(e){if(this._getType(e)!==ko.symbol){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:ko.symbol,received:t.parsedType}),Lo}return zo(e.data)}};Es.create=e=>new Es({typeName:sc.ZodSymbol,...qo(e)});var Ds=class extends Jo{_parse(e){if(this._getType(e)!==ko.undefined){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:ko.undefined,received:t.parsedType}),Lo}return zo(e.data)}};Ds.create=e=>new Ds({typeName:sc.ZodUndefined,...qo(e)});var Os=class extends Jo{_parse(e){if(this._getType(e)!==ko.null){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:ko.null,received:t.parsedType}),Lo}return zo(e.data)}};Os.create=e=>new Os({typeName:sc.ZodNull,...qo(e)});var ks=class extends Jo{constructor(){super(...arguments),this._any=!0}_parse(e){return zo(e.data)}};ks.create=e=>new ks({typeName:sc.ZodAny,...qo(e)});var As=class extends Jo{constructor(){super(...arguments),this._unknown=!0}_parse(e){return zo(e.data)}};As.create=e=>new As({typeName:sc.ZodUnknown,...qo(e)});var js=class extends Jo{_parse(e){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:ko.never,received:t.parsedType}),Lo}};js.create=e=>new js({typeName:sc.ZodNever,...qo(e)});var Ms=class extends Jo{_parse(e){if(this._getType(e)!==ko.undefined){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:ko.void,received:t.parsedType}),Lo}return zo(e.data)}};Ms.create=e=>new Ms({typeName:sc.ZodVoid,...qo(e)});var Ns=class e extends Jo{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==ko.array)return X(t,{code:Y.invalid_type,expected:ko.array,received:t.parsedType}),Lo;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 Go(t,e,t.path,n)))).then(e=>Io.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new Go(t,e,t.path,n)));return Io.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:Wo.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:Wo.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:Wo.toString(n)}})}nonempty(e){return this.min(1,e)}};Ns.create=(e,t)=>new Ns({type:e,minLength:null,maxLength:null,exactLength:null,typeName:sc.ZodArray,...qo(t)});function Ps(e){if(e instanceof Fs){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=$s.create(Ps(r))}return new Fs({...e._def,shape:()=>t})}else if(e instanceof Ns)return new Ns({...e._def,type:Ps(e.element)});else if(e instanceof $s)return $s.create(Ps(e.unwrap()));else if(e instanceof ec)return ec.create(Ps(e.unwrap()));else if(e instanceof Vs)return Vs.create(e.items.map(e=>Ps(e)));else return e}var Fs=class e extends Jo{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=Do.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==ko.object){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:ko.object,received:t.parsedType}),Lo}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof js&&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 Go(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof js){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 Go(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=>Io.mergeObjectSync(t,e)):Io.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return Wo.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:Wo.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:sc.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 Do.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 Do.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Ps(this)}partial(t){let n={};for(let e of Do.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 Do.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof $s;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Js(Do.objectKeys(this.shape))}};Fs.create=(e,t)=>new Fs({shape:()=>e,unknownKeys:`strip`,catchall:js.create(),typeName:sc.ZodObject,...qo(t)}),Fs.strictCreate=(e,t)=>new Fs({shape:()=>e,unknownKeys:`strict`,catchall:js.create(),typeName:sc.ZodObject,...qo(t)}),Fs.lazycreate=(e,t)=>new Fs({shape:e,unknownKeys:`strip`,catchall:js.create(),typeName:sc.ZodObject,...qo(t)});var Is=class extends Jo{_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 jo(e.ctx.common.issues));return X(t,{code:Y.invalid_union,unionErrors:n}),Lo}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 jo(e));return X(t,{code:Y.invalid_union,unionErrors:i}),Lo}}get options(){return this._def.options}};Is.create=(e,t)=>new Is({options:e,typeName:sc.ZodUnion,...qo(t)});var Ls=e=>e instanceof Ks?Ls(e.schema):e instanceof Qs?Ls(e.innerType()):e instanceof qs?[e.value]:e instanceof Ys?e.options:e instanceof Xs?Do.objectValues(e.enum):e instanceof tc?Ls(e._def.innerType):e instanceof Ds?[void 0]:e instanceof Os?[null]:e instanceof $s?[void 0,...Ls(e.unwrap())]:e instanceof ec?[null,...Ls(e.unwrap())]:e instanceof ic||e instanceof oc?Ls(e.unwrap()):e instanceof nc?Ls(e._def.innerType):[],Rs=class e extends Jo{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==ko.object)return X(t,{code:Y.invalid_type,expected:ko.object,received:t.parsedType}),Lo;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]}),Lo)}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=Ls(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:sc.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...qo(r)})}};function zs(e,t){let n=Ao(e),r=Ao(t);if(e===t)return{valid:!0,data:e};if(n===ko.object&&r===ko.object){let n=Do.objectKeys(t),r=Do.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=zs(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===ko.array&&r===ko.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=zs(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===ko.date&&r===ko.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Bs=class extends Jo{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Bo(e)||Bo(r))return Lo;let i=zs(e.value,r.value);return i.valid?((Vo(e)||Vo(r))&&t.dirty(),{status:t.value,value:i.data}):(X(n,{code:Y.invalid_intersection_types}),Lo)};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}))}};Bs.create=(e,t,n)=>new Bs({left:e,right:t,typeName:sc.ZodIntersection,...qo(n)});var Vs=class e extends Jo{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ko.array)return X(n,{code:Y.invalid_type,expected:ko.array,received:n.parsedType}),Lo;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`}),Lo;!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 Go(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>Io.mergeArray(t,e)):Io.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Vs.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Vs({items:e,typeName:sc.ZodTuple,rest:null,...qo(t)})};var Hs=class e extends Jo{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!==ko.object)return X(n,{code:Y.invalid_type,expected:ko.object,received:n.parsedType}),Lo;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new Go(n,e,n.path,e)),value:a._parse(new Go(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?Io.mergeObjectAsync(t,r):Io.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Jo?new e({keyType:t,valueType:n,typeName:sc.ZodRecord,...qo(r)}):new e({keyType:bs.create(),valueType:t,typeName:sc.ZodRecord,...qo(n)})}},Us=class extends Jo{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!==ko.map)return X(n,{code:Y.invalid_type,expected:ko.map,received:n.parsedType}),Lo;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new Go(n,e,n.path,[a,`key`])),value:i._parse(new Go(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 Lo;(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 Lo;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Us.create=(e,t,n)=>new Us({valueType:t,keyType:e,typeName:sc.ZodMap,...qo(n)});var Ws=class e extends Jo{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ko.set)return X(n,{code:Y.invalid_type,expected:ko.set,received:n.parsedType}),Lo;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 Lo;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 Go(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:Wo.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:Wo.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ws.create=(e,t)=>new Ws({valueType:e,minSize:null,maxSize:null,typeName:sc.ZodSet,...qo(t)});var Gs=class e extends Jo{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==ko.function)return X(t,{code:Y.invalid_type,expected:ko.function,received:t.parsedType}),Lo;function n(e,n){return Fo({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Po(),Mo].filter(e=>!!e),issueData:{code:Y.invalid_arguments,argumentsError:n}})}function r(e,n){return Fo({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Po(),Mo].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 Zs){let e=this;return zo(async function(...t){let o=new jo([]),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 zo(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new jo([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new jo([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:Vs.create(t).rest(As.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||Vs.create([]).rest(As.create()),returns:n||As.create(),typeName:sc.ZodFunction,...qo(r)})}},Ks=class extends Jo{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})}};Ks.create=(e,t)=>new Ks({getter:e,typeName:sc.ZodLazy,...qo(t)});var qs=class extends Jo{_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}),Lo}return{status:`valid`,value:e.data}}get value(){return this._def.value}};qs.create=(e,t)=>new qs({value:e,typeName:sc.ZodLiteral,...qo(t)});function Js(e,t){return new Ys({values:e,typeName:sc.ZodEnum,...qo(t)})}var Ys=class e extends Jo{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return X(t,{expected:Do.joinValues(n),received:t.parsedType,code:Y.invalid_type}),Lo}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}),Lo}return zo(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})}};Ys.create=Js;var Xs=class extends Jo{_parse(e){let t=Do.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ko.string&&n.parsedType!==ko.number){let e=Do.objectValues(t);return X(n,{expected:Do.joinValues(e),received:n.parsedType,code:Y.invalid_type}),Lo}if(this._cache||=new Set(Do.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=Do.objectValues(t);return X(n,{received:n.data,code:Y.invalid_enum_value,options:e}),Lo}return zo(e.data)}get enum(){return this._def.values}};Xs.create=(e,t)=>new Xs({values:e,typeName:sc.ZodNativeEnum,...qo(t)});var Zs=class extends Jo{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==ko.promise&&t.common.async===!1?(X(t,{code:Y.invalid_type,expected:ko.promise,received:t.parsedType}),Lo):zo((t.parsedType===ko.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Zs.create=(e,t)=>new Zs({type:e,typeName:sc.ZodPromise,...qo(t)});var Qs=class extends Jo{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===sc.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 Lo;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?Lo:r.status===`dirty`||t.value===`dirty`?Ro(r.value):r});{if(t.value===`aborted`)return Lo;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?Lo:r.status===`dirty`||t.value===`dirty`?Ro(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`?Lo:(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`?Lo:(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(!Ho(e))return Lo;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=>Ho(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):Lo);Do.assertNever(r)}};Qs.create=(e,t,n)=>new Qs({schema:e,typeName:sc.ZodEffects,effect:t,...qo(n)}),Qs.createWithPreprocess=(e,t,n)=>new Qs({schema:t,effect:{type:`preprocess`,transform:e},typeName:sc.ZodEffects,...qo(n)});var $s=class extends Jo{_parse(e){return this._getType(e)===ko.undefined?zo(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$s.create=(e,t)=>new $s({innerType:e,typeName:sc.ZodOptional,...qo(t)});var ec=class extends Jo{_parse(e){return this._getType(e)===ko.null?zo(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ec.create=(e,t)=>new ec({innerType:e,typeName:sc.ZodNullable,...qo(t)});var tc=class extends Jo{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===ko.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};tc.create=(e,t)=>new tc({innerType:e,typeName:sc.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...qo(t)});var nc=class extends Jo{_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 Uo(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new jo(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new jo(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};nc.create=(e,t)=>new nc({innerType:e,typeName:sc.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...qo(t)});var rc=class extends Jo{_parse(e){if(this._getType(e)!==ko.nan){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:ko.nan,received:t.parsedType}),Lo}return{status:`valid`,value:e.data}}};rc.create=e=>new rc({typeName:sc.ZodNaN,...qo(e)});var ic=class extends Jo{_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}},ac=class e extends Jo{_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`?Lo:e.status===`dirty`?(t.dirty(),Ro(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`?Lo: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:sc.ZodPipeline})}},oc=class extends Jo{_parse(e){let t=this._def.innerType._parse(e),n=e=>(Ho(e)&&(e.value=Object.freeze(e.value)),e);return Uo(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};oc.create=(e,t)=>new oc({innerType:e,typeName:sc.ZodReadonly,...qo(t)}),Fs.lazycreate;var sc;(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`})(sc||={}),bs.create,Ss.create,rc.create,Cs.create,ws.create,Ts.create,Es.create,Ds.create,Os.create,ks.create,As.create,js.create,Ms.create,Ns.create,Fs.create,Fs.strictCreate,Is.create,Rs.create,Bs.create,Vs.create,Hs.create,Us.create,Ws.create,Gs.create,Ks.create,qs.create;var cc=Ys.create;Xs.create,Zs.create,Qs.create,$s.create,ec.create,Qs.createWithPreprocess,ac.create,cc([`highlight`,`note`,`comment`]),cc([`pending`,`accepted`,`dismissed`]),cc([`yellow`,`green`,`blue`,`pink`]),cc([`info`,`warning`,`error`,`success`]);var lc=cc([`solo`,`tandem`]);cc([`user`,`claude`,`import`]),cc([`user`,`claude`,`import`]),cc([`accept`,`dismiss`]),cc([`markdown`,`json`]),cc([`md`,`txt`,`html`,`docx`]),cc([`RANGE_GONE`,`RANGE_MOVED`,`FILE_LOCKED`,`FILE_NOT_FOUND`,`NO_DOCUMENT`,`INVALID_RANGE`,`INVALID_ARGUMENT`,`NOT_FOUND`,`ANNOTATION_RESOLVED`,`FORMAT_ERROR`,`PERMISSION_DENIED`]),cc([`CHANNEL_CONNECT_FAILED`,`MONITOR_CONNECT_FAILED`]);function uc(e){return e.author!==`user`}function dc(e){return e.status===`pending`&&uc(e)}function fc(e){return`${e}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function pc(){return fc(`ann`)}function mc(){return fc(`msg`)}function hc(){return fc(`ntf`)}function gc(e){return fc(e)}var _c=`/api/notify-stream`,vc=`/api/info`,yc=`/api/diagnostics`,bc=`/health`,xc=`/api/open`,Sc=`/api/close`,Cc=`/api/save`,wc=`/api/rename`,Tc=`/api/upload`,Ec=`/api/scratchpad`,Dc=`/api/convert`,Oc=`/api/apply-changes`,kc=`/api/document/raw`,Ac=`/api/document/reload`,jc=`/api/backups`,Mc=`/api/backups/restore`,Nc=`/api/docx-conflict/resolve`,Pc=`/api/annotation-reply`,Fc=`/api/remove-annotation`,Ic=`/api/store/reclaim-lock`,Lc=`/api/chat`,Rc=`/api/sessions`,zc=`/api/sessions/delete`,Bc=`/api/sessions/clear`,Vc=`/api/license/status`,Hc=`/api/license/activate`,Uc=`/api/launcher/status`,Wc=`/api/launcher/nonce`,Gc=`/api/launcher/relaunch`,Kc=`/api/launcher/start-fresh`,qc=`/api/launcher/working-directory`,Jc=[`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`],Yc=new Set(Jc);function Xc(e){return Yc.has(e)}var Zc={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`},Qc={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`}},$c=[{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`}],el={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`},tl=/^(Control|Shift|Alt|Meta|OS)/,nl=new Set([`Tab`,`Escape`,`Enter`,`NumpadEnter`,`NumLock`,`CapsLock`,`ContextMenu`,`Insert`]);function rl(e){return tl.test(e.code)||e.code.startsWith(`Numpad`)||nl.has(e.code)?!1:e.ctrlOrMeta||e.alt}function il(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 rl(t)?t:null}function al(e,t){return e.ctrlOrMeta===(t.ctrlKey||t.metaKey)&&e.alt===t.altKey&&e.shift===t.shiftKey&&e.code===t.code}function ol(e,t){return e.ctrlOrMeta===t.ctrlOrMeta&&e.alt===t.alt&&e.shift===t.shift&&e.code===t.code}function sl(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 cl(){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 ll(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 ul(e){let t=cl(),n=[];return e.ctrlOrMeta&&n.push(t?`⌘`:`Ctrl`),e.alt&&n.push(t?`⌥`:`Alt`),e.shift&&n.push(t?`⇧`:`Shift`),n.push(ll(e.code)),t?n.join(``):n.join(`+`)}function dl(e,t){return t.get(e)??Qc[e]}function fl(e){let t=new Map;for(let n of Jc)t.set(n,ul(dl(n,e)));return t}function pl(e,t){return t?t.has(e):!1}function ml(e,t){if(e.isComposing)return null;if(t&&t.size>0)for(let n of Jc){let r=t.get(n);if(r&&al(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`&&!pl(`settings-modal`,t))return{id:`settings-modal`};if(!e.shiftKey&&e.code===`Comma`&&!pl(`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`&&!pl(`save-as`,t))return{id:`save-as`};if(e.code===`KeyS`&&!pl(`save`,t))return{id:`save`};if(e.shiftKey&&e.code===`KeyP`&&!pl(`toggle-palette`,t))return{id:`toggle-palette`};if(e.code===`KeyN`&&!pl(`new-scratchpad`,t))return{id:`new-scratchpad`};if(e.code===`KeyW`&&!pl(`close-tab`,t))return{id:`close-tab`};if(e.code===`KeyO`&&!pl(`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`&&!pl(`toggle-mode`,t))return{id:`toggle-mode`};if(e.altKey&&e.code===`KeyT`&&!pl(`reopen-closed-tab`,t))return{id:`reopen-closed-tab`};if(!e.altKey&&!e.shiftKey&&e.code===`KeyT`&&!pl(`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`&&!pl(`comment-on-selection`,t))return{id:`comment-on-selection`};if(e.altKey&&e.code===`KeyA`&&!pl(`toggle-authorship`,t))return{id:`toggle-authorship`}}if(e.altKey&&!e.ctrlKey&&!e.metaKey){if(e.shiftKey){if(e.code===`ArrowLeft`&&!pl(`toggle-left-panel`,t))return{id:`toggle-left-panel`};if(e.code===`ArrowRight`&&!pl(`toggle-right-panel`,t))return{id:`toggle-right-panel`}}if(!e.shiftKey){if(e.code===`BracketRight`&&!pl(`annotation-next`,t))return{id:`annotation-next`};if(e.code===`BracketLeft`&&!pl(`annotation-prev`,t))return{id:`annotation-prev`}}if(!e.shiftKey&&e.code===`KeyL`&&!pl(`select-block`,t))return{id:`select-block`}}return null}function hl(e){return e.code===`Slash`?e.shift?`?`:`/`:e.code===`Enter`||e.code===`NumpadEnter`?`Enter`:``}function gl(e){return{key:hl(e),code:e.code,ctrlKey:e.ctrlOrMeta,metaKey:!1,altKey:e.alt,shiftKey:e.shift,isComposing:!1}}function _l(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 vl(e){let t=ml(gl(e));return!t||Xc(t.id)?null:_l(t.id,t.context)||null}function yl(e,t,n){for(let r of Jc)if(r!==n&&ol(dl(r,t),e))return Zc[r];let r=vl(e);if(r)return r;for(let t of $c)if(ol(t.chord,e))return t.label;return null}function bl(e){return $c.some(t=>ol(t.chord,e))}function xl(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))Xc(n)&&sl(r)&&rl(r)&&(bl(r)||vl(r)||(t[n]=r));let n={},r=[];for(let e of Jc){let i=t[e];i&&(r.some(e=>ol(e,i))||(r.push(i),n[e]=i))}return n}function Sl(e){let t=new Map;for(let[n,r]of Object.entries(xl(e)))t.set(n,r);return t}var Cl=[`narrow`,`comfortable`,`wide`,`full`],wl={narrow:`58ch`,comfortable:`68ch`,wide:`82ch`,full:`100%`};function Tl(e){return typeof e==`string`&&Cl.includes(e)}var El=[`anthropic`,`openai`,`gemini`,`local-ollama`,`local-llamacpp`],Dl=50,Ol={s:14,m:16,l:18};function kl(){try{return typeof window>`u`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}catch{return!1}}var Al={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:17,primaryTab:`annotations`,panelOrder:`chat-editor-annotations`,editorMeasure:`comfortable`,selectionDwellMs:Ra,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},jl=64,Ml=512;function Nl(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(t.length>=Dl)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`||!El.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<=jl&&/^[A-Za-z0-9_-]+$/.test(e.apiKeyRef)?r.apiKeyRef=e.apiKeyRef:typeof e.apiKey==`string`&&e.apiKey.length<=Ml&&(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 Pl=[`serif`,`sans`,`mono`];function Fl(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`&&Pl.includes(r)&&(t[n]=r);return t}function Il(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:Tl(e.editorMeasure)?e.editorMeasure:Al.editorMeasure,selectionDwellMs:Math.max(500,Math.min(za,Number(e.selectionDwellMs)||1e3)),showAuthorship:e.showAuthorship===!1?!1:Al.showAuthorship,reduceMotion:typeof e.reduceMotion==`boolean`?e.reduceMotion:kl(),textSize:e.textSize===`s`||e.textSize===`m`||e.textSize===`l`?e.textSize:Al.textSize,theme:e.theme===`light`||e.theme===`dark`||e.theme===`warm`||e.theme===`system`?e.theme:Al.theme,systemLightVariant:e.systemLightVariant===`warm`?`warm`:Al.systemLightVariant,accentHue:typeof e.accentHue==`number`&&e.accentHue>=0&&e.accentHue<=360?e.accentHue:Al.accentHue,editorFont:e.editorFont===`serif`||e.editorFont===`sans`||e.editorFont===`mono`?e.editorFont:Al.editorFont,fontByExtension:Fl(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:Al.density,defaultMode:e.defaultMode===`solo`||e.defaultMode===`tandem`?e.defaultMode:Al.defaultMode,highContrast:e.highContrast===!0,annotationPatterns:e.annotationPatterns===!0,selectionToolbar:e.selectionToolbar===!1?!1:Al.selectionToolbar,formattingBarVisible:e.formattingBarVisible===!1?!1:Al.formattingBarVisible,railHoverReveal:e.railHoverReveal===!1?!1:Al.railHoverReveal,soloRailHidden:e.soloRailHidden===!1?!1:Al.soloRailHidden,degradedBannerDelayMs:typeof e.degradedBannerDelayMs==`number`&&e.degradedBannerDelayMs>=5e3&&e.degradedBannerDelayMs<=12e4?e.degradedBannerDelayMs:Al.degradedBannerDelayMs,sidecarRetryStrategy:e.sidecarRetryStrategy===`exponential`||e.sidecarRetryStrategy===`constant-2s`?e.sidecarRetryStrategy:Al.sidecarRetryStrategy,marginView:e.marginView===!0,showComments:e.showComments===!1?!1:Al.showComments,showHighlights:e.showHighlights===!1?!1:Al.showHighlights,showNotes:e.showNotes===!1?!1:Al.showNotes,showRawMarkdown:e.showRawMarkdown===!1?!1:Al.showRawMarkdown,decorationsMuted:e.decorationsMuted===!0,models:Nl(e.models),defaultModelId:typeof e.defaultModelId==`string`&&e.defaultModelId.length>0?e.defaultModelId:null,customShortcuts:xl(e.customShortcuts),smartTypography:e.smartTypography===!0,spellcheck:e.spellcheck===!1?!1:Al.spellcheck}}function Ll(){let e;try{e=localStorage.getItem(Ia)}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=Il(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 Il(t)}catch(e){console.warn(`[tandem] settings JSON is corrupt, resetting to defaults:`,e)}return{...Al,reduceMotion:kl()}}function Rl(e,t){let n={...e,...t},r=Nl(n.models);return{...n,customShortcuts:xl(n.customShortcuts),fontByExtension:Fl(n.fontByExtension),defaultSaveDirectory:typeof n.defaultSaveDirectory==`string`&&n.defaultSaveDirectory.trim()?n.defaultSaveDirectory.trim():null,selectionDwellMs:Math.max(500,Math.min(za,n.selectionDwellMs)),accentHue:Number.isFinite(n.accentHue)?Math.max(0,Math.min(360,n.accentHue)):Al.accentHue,editorMeasure:Tl(n.editorMeasure)?n.editorMeasure:Al.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 zl(e,t){if(t){let n=e.fontByExtension?.[t];if(n)return n}return e.editorFont}var Bl=`http://127.0.0.1:${wa}`;function Vl(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)}function Hl(e){return e.toLowerCase().endsWith(`.docx`)}async function Ul(e){return Hl(e.name)?Vl(await e.arrayBuffer()):e.text()}var Wl=`modulepreload`,Gl=function(e){return`/`+e},Kl={},ql=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=Gl(t,n),t in Kl)return;Kl[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`:Wl,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 Jl(){try{return Ll().defaultSaveDirectory}catch{return null}}async function Yl(){let e=new AbortController,t=setTimeout(()=>e.abort(),250);try{let t=await fetch(`${Bl}/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 Xl(){try{let{homeDir:e}=await ql(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 Zl(){return Jl()||await Yl()||await Xl()}function Ql(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 $l(e){return e.map(e=>e.path)}function eu(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 tu(){try{let e=localStorage.getItem(so);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 nu(e){try{localStorage.setItem(so,JSON.stringify(e)),su()}catch(e){console.warn(`[tandem] failed to save recent files:`,e)}}function ru(){try{localStorage.removeItem(so),su()}catch(e){console.warn(`[tandem] failed to clear recent files:`,e)}}var iu=3e4,au=null;function ou(){let e=Date.now();if(au&&e-au.ts<iu)return au.files;let t=tu();return au={files:t,ts:e},t}function su(){au=null}var cu=[`editor`,`navigation`,`view`,`document`,`annotations`,`claude`],lu=N(un(new Map));function uu(e,t={}){if(B(lu).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(lu,new Map(B(lu)).set(e.id,e),!0),!0}function du(){return B(lu)}var fu=null;function pu(e){fu=e}function mu(e,t){if(!fu){console.warn(`[actions] "${e}" invoked before App mounted — deps not wired yet`);return}t(fu)}var hu=N(!1),gu=N(!1),_u={get saving(){return B(hu)},get lastSaveOk(){return B(gu)}},vu=!1,yu=!1;function bu(e){return e.connected&&e.tabCount===0&&e.activeTabId===null}async function xu(){if(!yu){yu=!0;try{let e=await fetch(`${Bl}${Ec}`,{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{yu=!1}}}function Su(){try{return typeof window<`u`&&`__TAURI_INTERNALS__`in window}catch{return!1}}var Cu=!1;async function wu(e){let t=await Zl();if(!t)return e;try{let{join:n}=await ql(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 Tu(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 Eu(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 Du(e){if(Cu)return;let{activeDocId:t,notify:n,defaultName:r,sourceFormat:i}=e;if(!t){n(`warning`,`No active document to save.`);return}Cu=!0;try{Su()?await Ou(t,n,r??`Scratchpad.md`):await ku(t,n,i)}finally{Cu=!1}}async function Ou(e,t,n){let r;try{let{save:e}=await ql(async()=>{let{save:e}=await import(`./dist-js-BWAGOggB.js`);return{save:e}},__vite__mapDeps([2,1]));r=await e({defaultPath:await wu(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=Tu(r,i);a!==r&&t(`info`,`Saving as ${i.toUpperCase()} — only .md and .txt are supported.`);try{let n=await fetch(`${Bl}${Cc}`,{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;nu(Ql(tu(),s)),t(`info`,`Saved to ${o}.`)}catch(e){t(`error`,`Save As request failed: ${e instanceof Error?e.message:e}`)}}async function ku(e,t,n){let r=n===`txt`?`txt`:`md`;try{let n=await fetch(`${Bl}${Cc}`,{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}Eu(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 Au(e){if(!e||vu)return;vu=!0,P(hu,!0);let t=!1;try{let n=await fetch(`${Bl}${Cc}`,{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&&fu?.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&&fu?.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),fu?.notify(`error`,`Save failed: ${e}`)}}catch(e){console.warn(`[Tandem] Save request failed:`,e),fu?.notify(`error`,`Save failed — check your connection and try again.`)}finally{vu=!1,P(hu,!1),P(gu,t,!0)}}var ju=!1;async function Mu(){let e;try{e=await fetch(`${Bl}${Uc}`)}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 Nu(){let e;try{e=await fetch(`${Bl}${Wc}`,{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 Pu(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 Fu(e,t,n,r){let i=await Nu();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(`${Bl}${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 Iu(e){if(ju)return!1;let t=await Mu();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 Lu(e){if(!await Iu(e))return;let t=Pu(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.`)){ju=!0;try{await Fu(e,Gc,{cwd:t},{failPrefix:`Relaunch failed`,requestFailPrefix:`Relaunch request failed`,successMessage:`Claude restarting in ${t}.`})}finally{ju=!1}}}function Ru(){mu(`launcher-relaunch-here`,e=>void Lu(e))}async function zu(e){if(await Iu(e)&&confirm(`Drop Claude's saved conversation and restart fresh. This cannot be undone.`)){ju=!0;try{await Fu(e,Kc,{},{failPrefix:`Start fresh failed`,requestFailPrefix:`Start-fresh request failed`,successMessage:`Claude restarting with a fresh conversation.`})}finally{ju=!1}}}var Bu=!1;function Vu(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}async function Hu(e){if(Bu)return;let t=e.getActiveTabId();if(!t){e.notify(`warning`,`No active document.`);return}Bu=!0;try{let n=await fetch(`${Bl}${jc}?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}. ${Vu(e.timestamp)}`).join(`
4
+ `);if(!confirm(`Available backups (newest first):\n${a}\n\nRestore the most recent backup (${Vu(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(`${Bl}${Mc}`,{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 ${Vu(i.timestamp)}.`)}catch(t){e.notify(`error`,`Restore request failed: ${t instanceof Error?t.message:t}`)}finally{Bu=!1}}async function Uu(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 ql(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 Wu=[{id:`save`,label:`Save document`,group:`document`,shortcut:`Ctrl+S`,run(){mu(`save`,e=>void Au(e.getActiveTabId()))}},{id:`settings`,label:`Open settings`,group:`view`,shortcut:`Ctrl+,`,run(){mu(`settings`,e=>e.openSettings())}},{id:`settings-modal`,label:`Open settings (new)`,group:`view`,shortcut:`Ctrl+Shift+,`,run(){mu(`settings-modal`,e=>e.openSettingsModal())}},{id:`toggle-mode`,label:`Toggle Solo / Tandem mode`,group:`document`,shortcut:`Ctrl+Shift+M`,run(){mu(`toggle-mode`,e=>e.toggleSoloMode())}},{id:`new-scratchpad`,label:`New Scratchpad`,group:`document`,shortcut:`Ctrl+N`,run(){xu()}},{id:`save-as`,label:`Save As…`,group:`document`,shortcut:`Ctrl+Shift+S`,run(){mu(`save-as`,e=>void e.saveAs())}},{id:`close-tab`,label:`Close active tab`,group:`document`,shortcut:`Ctrl+W`,run(){mu(`close-tab`,e=>e.closeActiveTab())}},{id:`open-file`,label:`Open file…`,group:`document`,shortcut:`Ctrl+O`,run(){mu(`open-file`,e=>e.openFileDialog())}},{id:`find`,label:`Find / Replace`,group:`navigation`,shortcut:`Ctrl+F`,run(){mu(`find`,e=>e.openFindBar())}},{id:`find-in-tabs`,label:`Find in open tabs`,group:`navigation`,shortcut:`Ctrl+Shift+F`,run(){mu(`find-in-tabs`,e=>e.openFindBarTabs())}},{id:`find-next`,label:`Find next match`,group:`navigation`,shortcut:`Ctrl+G`,run(){mu(`find-next`,e=>e.findNext())}},{id:`find-previous`,label:`Find previous match`,group:`navigation`,shortcut:`Ctrl+Shift+G`,run(){mu(`find-previous`,e=>e.findPrev())}},{id:`toggle-left-panel`,label:`Toggle left panel`,group:`view`,shortcut:`Alt+Shift+Left`,run(){mu(`toggle-left-panel`,e=>e.toggleLeftPanel())}},{id:`toggle-right-panel`,label:`Toggle right panel`,group:`view`,shortcut:`Alt+Shift+Right`,run(){mu(`toggle-right-panel`,e=>e.toggleRightPanel())}},{id:`reopen-closed-tab`,label:`Reopen closed tab (this session)`,group:`document`,shortcut:`Ctrl+Alt+T`,run(){mu(`reopen-closed-tab`,e=>e.reopenClosedTab())}},{id:`annotation-next`,label:`Next annotation`,group:`annotations`,shortcut:`Alt+]`,run(){mu(`annotation-next`,e=>e.annotationNext())}},{id:`annotation-previous`,label:`Previous annotation`,group:`annotations`,shortcut:`Alt+[`,run(){mu(`annotation-previous`,e=>e.annotationPrev())}},{id:`annotation-accept`,label:`Accept focused annotation`,group:`annotations`,shortcut:`Ctrl+Enter`,run(){mu(`annotation-accept`,e=>e.annotationAccept())}},{id:`annotation-dismiss`,label:`Dismiss focused annotation`,group:`annotations`,shortcut:`Ctrl+Shift+Enter`,run(){mu(`annotation-dismiss`,e=>e.annotationDismiss())}},{id:`select-block`,label:`Select containing block`,group:`editor`,shortcut:`Alt+L`,run(){mu(`select-block`,e=>e.selectBlock())}},{id:`toggle-authorship`,label:`Toggle authorship colors`,group:`view`,shortcut:`Ctrl+Alt+A`,run(){mu(`toggle-authorship`,e=>e.toggleAuthorship())}},{id:`toggle-formatting-bar`,label:`Toggle formatting bar`,group:`view`,run(){mu(`toggle-formatting-bar`,e=>e.toggleFormattingBar())}},{id:`toggle-source-view`,label:`Toggle markdown source view`,group:`view`,run(){mu(`toggle-source-view`,e=>e.toggleSourceView())}},{id:`restore-backup`,label:`Restore a backup of this document…`,group:`document`,run(){mu(`restore-backup`,e=>void Hu(e))}},{id:`launcher-relaunch-here`,label:`Relaunch Claude in this folder`,group:`claude`,run(){mu(`launcher-relaunch-here`,e=>void Lu(e))}},{id:`launcher-start-fresh`,label:`Start fresh Claude conversation`,group:`claude`,run(){mu(`launcher-start-fresh`,e=>void zu(e))}},...Su()?[{id:`show-in-file-explorer`,label:`Show in file explorer`,group:`document`,run(){mu(`show-in-file-explorer`,e=>void Uu(e))}}]:[]];for(let e of Wu)uu(e);function Gu(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 Ku(e){return e.type===`save-error`&&e.documentId?{label:`Retry`,documentId:e.documentId}:null}var qu={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 Ju(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 Yu=H(`<button type="button" data-testid="activity-clear-all" class="svelte-bf7dij">Clear all</button>`),Xu=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>`),Zu=Yr(`<path class="svelte-bf7dij"></path>`),Qu=H(`<span class="badge svelte-bf7dij"> </span>`),$u=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>`),ed=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>`),td=H(`<div></div>`),nd=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>`),rd=H(`<span class="svelte-bf7dij">No activity</span>`),id=H(`<span class="svelte-bf7dij">Activity</span> <span class="count svelte-bf7dij"> </span>`,1),ad=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 od(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(un(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}),xa(()=>{clearInterval(a),c&&clearTimeout(c)});var l=ad(),u=F(l);let d;var f=F(u),p=F(f),m=e=>{var r=nd(),a=F(r),s=L(F(a),2),c=F(s,!0);O(s);var l=L(s,4),u=e=>{var n=Yu();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,Xu())},p=e=>{var n=td();let r;mi(n,21,()=>t.items,e=>e.id,(e,n)=>{let r=M(()=>Ku(B(n)));var a=ed(),o=F(a),s=F(o);mi(s,20,()=>qu[B(n).severity],e=>e,(e,t)=>{var n=Zu();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=Qu(),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=$u(),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=>{Wi(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}`)},[()=>Ju(B(n).timestamp,B(i))]),V(`click`,v,()=>t.onDismiss(B(n).id)),U(e,a)}),O(n),z(()=>r=Wi(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,rd())},v=e=>{var t=id(),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=Wi(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()}Vr([`click`]);function sd(e){this.content=e}sd.prototype={constructor:sd,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 sd(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 sd(n)},addToStart:function(e,t){return new sd([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new sd(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 sd(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=sd.from(e),e.size?new sd(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=sd.from(e),e.size?new sd(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=sd.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}},sd.from=function(e){if(e instanceof sd)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new sd(t)};function cd(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=cd(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function ld(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=ld(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 cd(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return ld(this,e,t,n)}findIndex(e){if(e==0)return dd(0,e);if(e==this.size)return dd(this.content.length,e);if(e>this.size||e<0)throw 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?dd(t+1,i):dd(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 ud={index:0,offset:0};function dd(e,t){return ud.index=e,ud.offset=t,ud}function fd(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(!fd(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!fd(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var pd=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&&fd(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw 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}};pd.none=[];var md=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=gd(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(hd(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 hd(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(hd(a.content,t-i-1,n-i-1)))}function gd(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=gd(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function _d(e,t,n){if(n.openStart>e.depth)throw new md(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new md(`Inconsistent open depths`);return vd(e,t,n,0)}function vd(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=vd(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return Cd(a,Td(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return Cd(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=Ed(n,e);return Cd(a,wd(e,i,o,t,r))}}function yd(e,t){if(!t.type.compatibleContent(e.type))throw new md(`Cannot join `+t.type.name+` onto `+e.type.name)}function bd(e,t,n){let r=e.node(n);return yd(r,t.node(n)),r}function xd(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 Sd(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&&(xd(e.nodeAfter,r),a++));for(let e=a;e<o;e++)xd(i.child(e),r);t&&t.depth==n&&t.textOffset&&xd(t.nodeBefore,r)}function Cd(e,t){return e.type.checkContent(t),e.copy(t)}function wd(e,t,n,r,i){let a=e.depth>i&&bd(e,t,i+1),o=r.depth>i&&bd(n,r,i+1),s=[];return Sd(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(yd(a,o),xd(Cd(a,wd(e,t,n,r,i+1)),s)):(a&&xd(Cd(a,Td(e,t,i+1)),s),Sd(t,n,i,s),o&&xd(Cd(o,Td(n,r,i+1)),s)),Sd(r,null,i,s),new Z(s)}function Td(e,t,n){let r=[];return Sd(null,e,n,r),e.depth>n&&xd(Cd(bd(e,t,n+1),Td(e,t,n+1)),r),Sd(t,null,n,r),new Z(r)}function Ed(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 Dd=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 pd.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 jd(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=Ad.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 Ad.set(t,r=new Od);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%kd,i}},Od=class{constructor(){this.elts=[],this.i=0}},kd=12,Ad=new WeakMap,jd=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)}},Md=Object.create(null),Nd=class e{constructor(e,t,n,r=pd.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&&fd(this.attrs,t||e.defaultAttrs||Md)&&pd.sameSet(this.marks,n||pd.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 _d(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 Dd.resolveCached(this,e)}resolveNoCache(e){return Dd.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()+`)`),Fd(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=pd.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(!pd.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}};Nd.prototype.text=void 0;var Pd=class e extends Nd{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):Fd(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 Fd(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var Id=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Ld(t,n);if(r.next==null)return e.empty;let i=Rd(r);r.next&&r.err(`Unexpected trailing text`);let a=Jd(Gd(i));return Yd(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
+ `)}};Id.empty=new Id(!0);var Ld=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 Rd(e){let t=[];do t.push(zd(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function zd(e){let t=[];do t.push(Bd(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function Bd(e){let t=Wd(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=Hd(e,t);else break;return t}function Vd(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function Hd(e,t){let n=Vd(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:Vd(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function Ud(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 Wd(e){if(e.eat(`(`)){let t=Rd(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=Ud(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 Gd(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 Kd(e,t){return t-e}function qd(e,t){let n=[];return r(t),n.sort(Kd);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 Jd(e){let t=Object.create(null);return n(qd(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]);qd(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new Id(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Kd);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Yd(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 Xd(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 Zd(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 Qd(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 $d(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new nf(e,r,t[r]);return n}var ef=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=$d(e,n.attrs),this.defaultAttrs=Xd(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==Id.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:Zd(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new Nd(this,this.computeAttrs(e),Z.from(t),pd.setFrom(n))}createChecked(e=null,t,n){return t=Z.from(t),this.checkContent(t),new Nd(this,this.computeAttrs(e),t,pd.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 Nd(this,e,t.append(i),pd.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){Qd(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:pd.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 tf(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 nf=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?tf(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},rf=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=$d(e,r.attrs),this.excluded=null;let i=Xd(this.attrs);this.instance=i?new pd(this,i):null}create(e=null){return!e&&this.instance?this.instance:new pd(this,Zd(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){Qd(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},af=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=sd.from(e.nodes),t.marks=sd.from(e.marks||{}),this.nodes=ef.compile(this.spec.nodes,this),this.marks=rf.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]=Id.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?of(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==``?[]:of(this,n.split(` `))}this.nodeFromJSON=e=>Nd.fromJSON(this,e),this.markFromJSON=e=>pd.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 ef))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 Pd(n,n.defaultAttrs,e,pd.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 of(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 sf(e){return e.tag!=null}function cf(e){return e.style!=null}var lf=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(sf(e))this.tags.push(e);else if(cf(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 vf(this,t,!1);return n.addAll(e,pd.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new vf(this,t,!0);return n.addAll(e,pd.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(bf(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=xf(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=xf(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)))}},uf={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},df={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ff={ol:!0,ul:!0},pf=1,mf=2,hf=4;function gf(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?pf:0)|(t===`full`?mf:0)}var _f=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=pd.none,this.match=i||(a&hf?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&pf)){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&&!uf.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},vf=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=gf(null,t.preserveWhitespace,0)|(n?hf:0);i=r?new _f(r.type,r.attrs,pd.none,!0,t.topMatch||r.type.contentMatch,a):n?new _f(null,null,pd.none,!0,null,a):new _f(e.schema.topNodeType,null,pd.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&mf?`full`:this.localPreserveWS||(r.options&pf)>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;ff.hasOwnProperty(a)&&this.parser.normalizeLists&&yf(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:df.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(uf.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=pd.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):Sf(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=gf(e,i,a.options);a.options&hf&&a.content.length==0&&(o|=hf);let s=pd.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):Sf(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new _f(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|=pf);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 yf(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&ff.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function bf(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function xf(e){let t={};for(let n in e)t[n]=e[n];return t}function Sf(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 Cf=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=Tf(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}=kf(Tf(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&&kf(Tf(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return kf(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=wf(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return wf(e.marks)}};function wf(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Tf(e){return e.document||window.document}var Ef=new WeakMap;function Df(e){let t=Ef.get(e);return t===void 0&&Ef.set(e,t=Of(e)),t}function Of(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 kf(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=Df(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}=kf(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var Af=65535,jf=2**16;function Mf(e,t){return e+t*jf}function Nf(e){return e&Af}function Pf(e){return(e-(e&Af))/jf}var Ff=1,If=2,Lf=4,Rf=8,zf=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Rf)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&Lf)>0}},Bf=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=Nf(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+Pf(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:Mf(o/3,e-s),f=e==s?If:e==u?Ff:Lf;return(t<0?e!=s:e!=u)&&(f|=Rf),new zf(a,f,d)}r+=l-c}return n?e+r:new zf(e+r,0,null)}touches(e,t){let n=0,r=Nf(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])}};Bf.empty=new Bf([]);var Vf=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 zf(e,r,null)}},Hf=Object.create(null),Uf=class{getMap(){return Bf.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=Hf[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Hf)throw RangeError(`Duplicate use of step JSON ID `+e);return Hf[e]=t,t.prototype.jsonID=e,t}},Wf=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 md)return e.fail(t.message);throw t}}};function Gf(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(Gf(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return Z.fromArray(r)}var Kf=class e extends Uf{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(Gf(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 Wf.fromReplace(e,this.from,this.to,i)}invert(){return new qf(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))}};Uf.jsonID(`addMark`,Kf);var qf=class e extends Uf{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(Gf(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return Wf.fromReplace(e,this.from,this.to,n)}invert(){return new Kf(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))}};Uf.jsonID(`removeMark`,qf);var Jf=class e extends Uf{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Wf.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Wf.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 Yf(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))}};Uf.jsonID(`addNodeMark`,Jf);var Yf=class e extends Uf{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Wf.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Wf.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 Jf(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))}};Uf.jsonID(`removeNodeMark`,Yf);var Xf=class e extends Uf{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Qf(e,this.from,this.to)?Wf.fail(`Structure replace would overwrite content`):Wf.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Bf([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)}};Uf.jsonID(`replace`,Xf);var Zf=class e extends Uf{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&&(Qf(e,this.from,this.gapFrom)||Qf(e,this.gapTo,this.to)))return Wf.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Wf.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?Wf.fromReplace(e,this.from,this.to,n):Wf.fail(`Content does not fit in gap`)}getMap(){return new Bf([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)}};Uf.jsonID(`replaceAround`,Zf);function Qf(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 $f(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 qf(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new Kf(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function ep(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 rf){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 qf(t.from,t.to,t.style)))}function tp(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 Xf(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 qf(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 Xf(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 np(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function rp(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||!np(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function ip(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 Zf(c,l,o,s,new Q(u.append(f),d,p),u.size-d,!0))}function ap(e,t,n=null,r=e){let i=sp(e,t),a=i&&cp(r,t);return a?i.map(op).concat({type:t,attrs:n}).concat(a.map(op)):null}function op(e){return{type:e,attrs:null}}function sp(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 cp(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 lp(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 Zf(i,a,i,a,new Q(r,0,0),n.length,!0))}function up(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)&&pp(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&&fp(e,t,n,a),tp(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 Zf(c,l,c+1,l-1,new Q(Z.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&dp(e,t,n,a),!1}})}function dp(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 fp(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 pp(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function mp(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 Zf(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new Q(Z.from(o),0,0),1,!0))}function hp(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 gp(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 Xf(t,t,new Q(a.append(o),n,n),!0))}function _p(e,t){let n=e.resolve(t),r=n.index();return yp(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function vp(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 yp(e,t){return!!(e&&t&&!e.isLeaf&&vp(e,t))}function bp(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&&yp(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 xp(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);fp(e,r.node(),r.before(),s)}o.inlineContent&&tp(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 Xf(l,c.map(t+n,-1),Q.empty,!0)),r===!0){let t=e.doc.resolve(l);dp(e,t.node(),t.before(),e.steps.length)}return e}function Sp(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 Cp(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 wp(e,t,n=t,r=Q.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return Tp(i,a,r)?new Xf(t,n,r):new Ep(i,a,r).fit()}function Tp(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var Ep=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 Zf(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new Xf(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=kp(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=kp(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=kp(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new Q(Dp(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new Q(Dp(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(Ap(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=Op(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(Dp(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new Q(Dp(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||!jp(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=jp(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=jp(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=Op(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=Op(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=Op(this.placed,this.frontier.length,e))}};function Dp(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Dp(e.firstChild.content,t-1,n)))}function Op(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Op(e.lastChild.content,t-1,n)))}function kp(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Ap(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Ap(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 jp(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&&!Mp(n,a.content,o)?s:null}function Mp(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function Np(e){return e.spec.defining||e.spec.definingForContent}function Pp(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(Tp(i,a,r))return e.step(new Xf(t,n,r));let o=Rp(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=Np(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(Fp(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 Fp(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(Fp(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 Ip(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=Sp(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new Q(Z.from(r),0,0))}function Lp(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),a=Rp(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 Rp(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 zp=class e extends Uf{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 Wf.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 Wf.fromReplace(e,this.pos,this.pos+1,new Q(Z.from(r),0,+!t.isLeaf))}getMap(){return Bf.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)}};Uf.jsonID(`attr`,zp);var Bp=class e extends Uf{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 Wf.ok(n)}getMap(){return Bf.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)}};Uf.jsonID(`docAttr`,Bp);var Vp=class extends Error{};Vp=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},Vp.prototype=Object.create(Error.prototype),Vp.prototype.constructor=Vp,Vp.prototype.name=`TransformError`;var Hp=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Vf}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Vp(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=wp(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 Pp(this,e,t,n),this}replaceRangeWith(e,t,n){return Ip(this,e,t,n),this}deleteRange(e,t){return Lp(this,e,t),this}lift(e,t){return ip(this,e,t),this}join(e,t=1){return xp(this,e,t),this}wrap(e,t){return lp(this,e,t),this}setBlockType(e,t=e,n,r=null){return up(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return mp(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new zp(e,t,n)),this}setDocAttribute(e,t){return this.step(new Bp(e,t)),this}addNodeMark(e,t){return this.step(new Jf(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof pd)t.isInSet(n.marks)&&this.step(new Yf(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new Yf(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 gp(this,e,t,n),this}addMark(e,t,n){return $f(this,e,t,n),this}removeMark(e,t,n){return ep(this,e,t,n),this}clearIncompatible(e,t,n){return tp(this,e,t,n),this}},Up=Object.create(null),Wp=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Gp(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&&tm(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),tm(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new Jp(e):em(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?em(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):em(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 Qp(e.node(0))}static atStart(e){return em(e,e,0,0,1)||new Qp(e)}static atEnd(e){return em(e,e,e.content.size,e.childCount,-1)||new Qp(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=Up[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Up)throw RangeError(`Duplicate use of selection JSON ID `+e);return Up[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Jp.between(this.$anchor,this.$head).getBookmark()}};Wp.prototype.visible=!0;var Gp=class{constructor(e,t){this.$from=e,this.$to=t}},Kp=!1;function qp(e){!Kp&&!e.parent.inlineContent&&(Kp=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var Jp=class e extends Wp{constructor(e,t=e){qp(e),qp(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 Wp.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 Yp(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=Wp.findFrom(n,r,!0)||Wp.findFrom(n,-r,!0);if(e)n=e.$head;else return Wp.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(Wp.findFrom(t,-r,!0)||Wp.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};Wp.jsonID(`text`,Jp);var Yp=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 Jp.between(e.resolve(this.anchor),e.resolve(this.head))}},Xp=class e extends Wp{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?Wp.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 Zp(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}};Xp.prototype.visible=!1,Wp.jsonID(`node`,Xp);var Zp=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new Yp(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Xp.isSelectable(n)?new Xp(t):Wp.near(t)}},Qp=class e extends Wp{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=Wp.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 $p}};Wp.jsonID(`all`,Qp);var $p={map(){return this},resolve(e){return new Qp(e)}};function em(e,t,n,r,i,a=!1){if(t.inlineContent)return Jp.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=em(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&Xp.isSelectable(r))return Xp.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function tm(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof Xf||i instanceof Zf))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(Wp.near(e.doc.resolve(o),n))}var nm=1,rm=2,im=4,am=class extends Hp{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|nm)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&nm)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=rm,this}ensureMarks(e){return pd.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&rm)>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)||pd.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(Wp.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|=im,this}get scrolledIntoView(){return(this.updated&im)>0}};function om(e,t){return!t||!e?e:e.bind(t)}var sm=class{constructor(e,t,n){this.name=e,this.init=om(t.init,n),this.apply=om(t.apply,n)}},cm=[new sm(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new sm(`selection`,{init(e,t){return e.selection||Wp.atStart(t.doc)},apply(e){return e.selection}}),new sm(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new sm(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],lm=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=cm.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 sm(e.key,e.spec.state,e))})}},um=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 am(this)}static create(t){let n=new lm(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 lm(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 lm(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=Nd.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=Wp.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 dm(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=dm(i,t,{})),n[r]=i}return n}var fm=class{constructor(e){this.spec=e,this.props={},e.props&&dm(e.props,this,this.props),this.key=e.key?e.key.key:mm(`plugin`)}getState(e){return e[this.key]}},pm=Object.create(null);function mm(e){return e in pm?e+`$`+ ++pm[e]:(pm[e]=0,e+`$`)}var hm=class{constructor(e=`key`){this.key=mm(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},gm=[{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`}],_m=500,vm=1e4,ym=500,bm=250,xm=16,Sm=8,Cm=12,wm=1,Tm=9e3;function Em(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 Dm(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=vm-Math.min(a,_m-1);a===0?e+=ym:Em(t,a)&&(e+=bm);let n=[];for(let e=0;e<i.length;e++)n.push(a+e);return{score:e,indices:r?n:[]}}let o=t.length>_m?t.slice(0,_m):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+=xm:l-=(n-d-1)*wm),Em(o,n)&&(l+=Sm),e===0&&n===0&&(l+=Cm),c.push(n),d=n,u=n+1}return{score:Math.min(l,Tm),indices:r?c:[]}}function Om(e,t,...n){let r=Dm(e,t),i=[];r&&i.push(r.score);for(let t of n){if(!t)continue;let n=Dm(e,t);n&&i.push(n.score*.75)}return i.length===0?null:{score:Math.max(...i),indices:r?r.indices:[]}}function km(e){return e.sort((e,t)=>t.score-e.score||e.origIndex-t.origIndex),e.map(e=>e.result)}function Am(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 jm(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 Mm=(e,t=m,n=m)=>{var r=Zr(),i=I(r),a=e=>{var r=Zr();mi(I(r),17,()=>Am(t(),n()),ui,(e,t)=>{var n=Zr(),r=I(n),i=e=>{var n=Nm(),r=F(n,!0);O(n),z(()=>W(r,B(t).text)),U(e,n)},a=e=>{var n=Xr();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=Xr();z(()=>W(n,t())),U(e,n)};G(i,e=>{n()?e(a):e(o,-1)}),U(e,r)},Nm=H(`<span class="palette-match svelte-gunx66"> </span>`),Pm=H(`<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);"><!> <!> <!> <!></div>`),Fm=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>`),Im=H(`<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-family: var(--tandem-font-mono);"> </span>`),Lm=H(`<span style="font-size: var(--tandem-text-sm);"><!></span> <!>`,1),Rm=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>`),zm=H(`<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span>`),Bm=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),Vm=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),Hm=H(`<li role="option"><!></li>`),Um=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 Wm(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()),u=M(()=>{if(B(c)!==null&&B(c)!==`>`)return[];let e=du(),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=Om(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 km(n)}),d=M(()=>{if(B(c)!==`#`)return[];let e=n();if(!e||e.isDestroyed)return[];let t=B(l),r=jm(e);if(!t)return r.map((e,t)=>({kind:`heading`,id:`heading-${t}`,...e}));let i=[];return r.forEach((e,n)=>{let r=Om(t,e.text);r&&i.push({result:{kind:`heading`,id:`heading-${n}`,...e,matchIndices:r.indices},score:r.score,origIndex:n})}),km(i)}),f=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=Om(e,r.content,r.textSnapshot);a&&n.push({result:t(r),score:a.score,origIndex:i})}),km(n).slice(0,50)}),p=M(()=>{if(B(c)!==`?`)return[];let e=B(l),t=du(),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<gm.length;e++){let t=gm[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=Om(e,t.description,t.keys);a&&i.push({result:r(t),score:a.score,origIndex:n})}),km(i)}),m=M(()=>[...B(u),...B(d),...B(f),...B(p)]);R(()=>{B(m),P(a,0)}),R(()=>{t.open&&(P(i,``),P(a,0),Promise.resolve().then(()=>B(o)?.focus()))}),ba(()=>{let e=e=>{e.key!==`Escape`||!t.open||(e.preventDefault(),e.stopPropagation(),_())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})});let h={"#":`Search headings…`,"@":`Search annotations…`,"?":`Search shortcuts…`,">":`Search commands…`},g=M(()=>B(c)?h[B(c)]:`Type a command, # headings, @ annotations, ? shortcuts…`);function _(){t.onClose()}function v(e){if(e.kind===`action`)_(),e.action.run();else if(e.kind===`heading`){_();let t=n();if(!t||t.isDestroyed)return;let r=e.pos;try{let e=t.state.doc.resolve(r+1),n=Jp.near(e);t.view.dispatch(t.state.tr.setSelection(n).scrollIntoView()),t.view.focus()}catch{}}else e.kind===`annotation`&&(_(),t.onFocusAnnotation?.(e.id.replace(`annotation-`,``)))}function y(e){let t=B(m).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(m)[B(a)];t&&v(t)}else e.key===`Escape`&&(e.preventDefault(),_())}function b(e){e.target===e.currentTarget&&_()}var x=Zr(),S=I(x),C=e=>{var t=Um(),n=F(t),r=F(n),s=F(r),l=L(F(s),2);ea(l),pa(l,e=>P(o,e),()=>B(o)),k(2),O(s);var u=L(s,2),d=e=>{var t=Pm(),n=F(t),r=e=>{U(e,Xr(`Searching document headings`))};G(n,e=>{B(c)===`#`&&e(r)});var i=L(n,2),a=e=>{U(e,Xr(`Searching annotations`))};G(i,e=>{B(c)===`@`&&e(a)});var o=L(i,2),s=e=>{U(e,Xr(`Showing keyboard shortcuts`))};G(o,e=>{B(c)===`?`&&e(s)});var l=L(o,2),u=e=>{U(e,Xr(`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),h=e=>{var t=Fm(),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)},x=e=>{var t=Zr();mi(I(t),19,()=>B(m),e=>e.id,(e,t,n)=>{let r=M(()=>B(n)===B(a));var i=Hm(),o=F(i),s=e=>{var n=Lm(),r=I(n);Mm(F(r),()=>B(t).action.label,()=>B(t).matchIndices),O(r);var i=L(r,2),a=e=>{var n=Im(),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=Rm(),r=F(n),i=F(r);O(r);var a=L(r,2);Mm(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=Bm(),r=I(n),i=F(r),a=F(i,!0);O(i);var o=L(i,2),s=e=>{var n=zm(),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=Vm(),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,()=>v(B(t))),Br(`mouseenter`,i,()=>P(a,B(n),!0)),U(e,i)}),U(e,t)};G(p,e=>{B(m).length===0?e(h):e(x,-1)}),O(f),Fi(f,(e,t)=>Gu?.(e,t),()=>`y`),k(2),O(n),O(t),z(()=>{q(l,`placeholder`,B(g)),q(l,`aria-activedescendant`,B(m)[B(a)]?`palette-item-${B(m)[B(a)].id}`:void 0)}),V(`click`,t,b),V(`keydown`,t,e=>{e.key===`Escape`&&_()}),V(`keydown`,n,y),oa(l,()=>B(i),e=>P(i,e)),U(e,t)};G(S,e=>{t.open&&e(C)}),U(e,x),j()}Vr([`click`,`keydown`]);var Gm=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 Km(e,t){var n=Gm(),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)}Vr([`click`]);function qm(e){return e?e.osSupported?e.coworkDetected?`normal`:`undetected`:`unsupported`:`loading`}function Jm(e){return e.claudeDesktopDetected??!1?(e.workspacesBlocked??0)>0?`blocked`:`noWorkspacesYet`:`noClaude`}function Ym(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: ${Xm(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 Xm(e){let t=e.trim();return t.length===0?`(no output)`:t.length<=200?t:`${t.slice(0,197)}...`}function Zm(e){try{let t=JSON.parse(e);if(typeof t==`object`&&t&&`kind`in t&&typeof t.kind==`string`)try{return Ym(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 $m(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 eh(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 th(e){let t=e=>e===`ok`||e===`alreadyPresent`;return t(e.installedPlugins)&&t(e.knownMarketplaces)&&t(e.coworkSettings)}function nh(e){if(!e||!e.enabled)return`not-applicable`;let t=e.workspaces??[];return t.some(th)?`reachable`:t.some(e=>$m(eh(e))===`error`)?`unreachable`:`pending`}function rh(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 ih(e,t){return!(!e||t||!e.osSupported||!e.coworkDetected||e.enabled)}function ah(){try{return localStorage.getItem(ho)===`true`}catch{return!1}}function oh(){try{localStorage.setItem(ho,`true`)}catch{}}function sh(){try{return typeof window<`u`&&`__TAURI_INTERNALS__`in window}catch{return!1}}function ch(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 lh=`Tauri runtime not available`;async function uh(){try{return(await ql(()=>import(`./core-SwWLTXZB.js`),[])).invoke}catch(e){return sh()&&console.error(`[cowork] Failed to load @tauri-apps/api/core:`,e),(()=>Promise.reject(Error(lh)))}}function dh(e){return e(`cowork_get_status`)}function fh(e,t){return e(`cowork_toggle_integration`,{enabled:t})}function ph(e){return e(`cowork_rescan`)}function mh(e,t){return e(`cowork_set_lan_ip_override`,{enabled:t})}function hh(e){return e(`cowork_retry_admin_elevation`)}var gh=N(!1),_h=null;function vh(){return B(gh)}function yh(){P(gh,!0)}function bh(e){e!==_h&&(_h=e,e!==null&&P(gh,!1))}function xh(e){let t=N(null),n=N(!1),r=N(null),i=null,a=!1,o=!0,s=null;xa(()=>{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 dh(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 uh().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()},go),()=>{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}}function Sh(e,t={}){return n=>{t.selfOnly&&n.target!==n.currentTarget||n.key!==`Enter`&&n.key!==` `||(n.preventDefault(),e())}}var Ch=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>`),wh=H(`<div class="cad-error svelte-cbdwov" data-testid="cowork-admin-declined-error" role="alert"> </div>`),Th=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>`),Eh=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>`),Dh=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 Oh(e,t){A(t,!0);let n=xh(()=>!0),r=M(()=>n.status?.uacDeclined===!0),i=M(()=>B(r)&&!vh()),a=N(void 0),o=N(!1),s=N(!1),c=N(null);R(()=>{bh(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;yh();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 uh())}catch(e){P(c,`${t}: ${Zm(e instanceof Error?e.message:String(e))}`)}finally{P(s,!1)}}async function u(){await l(async e=>{await hh(e),await n.refetch()},`Retry failed`)}async function d(){await l(async e=>{await fh(e,!1),await n.refetch()},`Failed to disable Cowork`),B(c)||P(o,!1)}var f=Zr(),p=I(f),m=e=>{U(e,Ch())},h=e=>{var t=Dh(),n=M(()=>Sh(()=>{B(s)||yh()},{selfOnly:!0})),r=F(t);q(r,`tabindex`,-1);var i=L(F(r),4),l=L(i,2),f=e=>{var t=wh(),n=F(t,!0);O(t),z(()=>W(n,B(c))),U(e,t)};G(l,e=>{B(c)&&e(f)});var p=L(l,2),m=e=>{var t=Th(),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)},h=e=>{var t=Eh(),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(p,e=>{B(o)?e(m):e(h,-1)}),O(r),pa(r,e=>P(a,e),()=>B(a)),O(t),z(()=>q(i,`href`,`${Ta}#cowork`)),V(`click`,t,e=>{!B(s)&&e.target===e.currentTarget&&yh()}),V(`keydown`,t,function(...e){B(n)?.apply(this,e)}),U(e,t)};G(p,e=>{n.error&&!n.status?e(m):B(i)&&e(h,1)}),U(e,f),j()}Vr([`click`,`keydown`]);var kh=H(`<span style="color: var(--tandem-error-fg-strong); font-size: var(--tandem-text-xs); max-width: 200px;"> </span>`),Ah=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 jh(e,t){A(t,!0);let n=N(null),r=N(null),i=N(null);R(()=>{let e=t.ydoc.getMap(qa),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(`${Bl}${Nc}`,{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=Zr(),c=I(s),l=e=>{var t=Ah(),n=F(t),s=F(n,!0);O(n);var c=L(n,2),l=e=>{var t=kh(),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()}Vr([`click`]);var Mh=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),Nh=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),Ph=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),Fh=H(`<p class="empty-sub empty-sub-secondary svelte-16uow3k">Tandem works alongside Claude (the default integration) or any MCP-capable AI client.</p>`),Ih=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),Lh=H(`<div class="empty-state svelte-16uow3k"><!></div>`);function Rh(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)},ka);return()=>clearTimeout(e)});var i=Lh(),a=F(i),o=e=>{var n=Mh(),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=Ih(),i=L(I(r),6),a=F(i);O(i);var o=L(i,2),s=e=>{var n=Nh(),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=Ph(),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,Fh())};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()}Vr([`click`]);var zh=H(`<li> </li>`),Bh=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>`),Vh=H(`<li> </li>`),Hh=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>`),Uh=H(`<li> </li>`),Wh=H(`<section data-testid="fidelity-report-export-downgrades"><h4 class="svelte-coexzc">Simplified on the last save</h4> <ul class="svelte-coexzc"></ul></section>`),Gh=H(`<div data-testid="fidelity-report-details"><!> <!> <!></div>`),Kh=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 qh(e,t){A(t,!0);let n=N(null),r=N(!1);R(()=>{let e=t.ydoc.getMap(qa),i=()=>{let t=e.get(io);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=Zr(),c=I(s),l=e=>{var o=Kh(),s=I(o),c=F(s),l=F(c),u=e=>{var n=Xr();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=Xr();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=Gh(),r=F(t),o=e=>{var t=Bh(),n=L(F(t),2);mi(n,21,()=>B(i),ui,(e,t)=>{var n=zh(),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=Hh(),r=L(F(t),2);mi(r,21,()=>B(n).importLosses,ui,(e,t)=>{var n=Vh(),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=Wh(),r=L(F(t),2);mi(r,21,()=>B(n).exportDowngrades,ui,(e,t)=>{var n=Uh(),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(()=>Wi(t,1,`fidelity-report-details ${B(a)?`fidelity-report-details--warning`:``}`,`svelte-coexzc`)),U(e,t)};G(m,e=>{B(r)&&e(h)}),z(()=>{Wi(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()}Vr([`click`]);async function Jh(e,t={}){let{readOnly:n=!1,notFoundMessage:r=`File not found.`,failureMessage:i=`Failed to open file.`}=t;try{let t=await fetch(`${Bl}${xc}`,{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 Yh=Array.from(Da).sort().map(e=>e.replace(/^\./,``));async function Xh(){let{open:e}=await ql(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 Zl()??void 0,filters:[{name:`Documents`,extensions:Yh}]});return typeof t==`string`?t:null}async function Zh(e={}){let t;try{t=await Xh()}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 Jh(t);if(!n.ok){e.onError?.(n.error);return}nu(Ql(tu(),t))}async function Qh(e){e.isTauri?await Zh({onError:e.onError}):e.openModal()}async function $h(e,t){try{let n=await fetch(`${Bl}${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 eg(){try{let e=await fetch(`${Bl}${Rc}`),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 tg(e){return $h(zc,{filePath:e})}async function ng(){return $h(Bc,{})}var rg=H(`<input type="file" style="display: none;"/>`),ig=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>`),ag=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>`),og=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>`),sg=H(`<p data-testid="sessions-loading" style="margin: 8px 0 0; font-size: 12px; color: var(--tandem-fg-subtle);">Loading…</p>`),cg=H(`<p data-testid="sessions-empty" style="margin: 8px 0 0; font-size: 12px; color: var(--tandem-fg-subtle);">No saved sessions.</p>`),lg=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>`),ug=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),dg=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>`),fg=H(`<!> <!>`,1),pg=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>`),mg=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 hg(e,t){A(t,!0);let n=N(null),r=N(!1),i=N(void 0),a=N(un($l(tu()))),o=N(un([])),s=N(!1),c=N(!1),l=N(!1),u=N(null);async function d(){P(c,!0),P(u,null);let e=await eg();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 tg(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 ng();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(Da).sort().join(`,`);function _(e){let t=Ql(tu(),e);nu(t),P(a,$l(t),!0)}function v(){ru(),P(a,[],!0)}async function y(e){if(!B(r)){P(n,null),P(r,!0);try{let r=await Jh(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 Xh();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 Ul(e),i=await fetch(`${Bl}${Tc}`,{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(){sh()?b():B(i)?.click()}var w=mg();q(w,`tabindex`,-1);var ee=F(w),T=F(ee),E=L(F(T),2);O(T);var te=L(T,2);Tn(te,!0);var D=F(te,!0);O(te);var ne=L(te,2),re=e=>{var t=rg();pa(t,e=>P(i,e),()=>B(i)),z(()=>q(t,`accept`,g)),V(`change`,t,S),U(e,t)},ie=M(()=>!sh());G(ne,e=>{B(ie)&&e(re)});var ae=L(ne,2),oe=e=>{U(e,ig())},se=M(()=>sh());G(ae,e=>{B(se)&&e(oe)});var ce=L(ae,2),le=e=>{var t=og(),n=F(t),r=L(F(n),2);O(n);var i=L(n,2);mi(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=ag(),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)),Br(`mouseenter`,o,e=>{e.currentTarget.style.background=`var(--tandem-surface-muted)`}),Br(`mouseleave`,o,e=>{e.currentTarget.style.background=`transparent`}),U(e,o)}),O(i),Fi(i,(e,t)=>Gu?.(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=fg(),n=I(t),r=e=>{U(e,sg())},i=e=>{U(e,cg())},a=e=>{var t=ug(),n=I(t),r=F(n);O(n);var i=L(n,2);mi(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=lg(),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),Fi(i,(e,t)=>Gu?.(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=dg(),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=pg(),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(D,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()}Vr([`click`,`keydown`,`change`]);var gg=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),_g=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>`),vg=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),yg=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 bg(e,t){A(t,!0);let n=M(()=>{let e=du(),n=t.effectiveShortcutLabels,r=new Map;for(let t of e.values()){if(!t.shortcut)continue;let e=el[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 cu.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=jr(()=>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=Zr(),o=I(a),s=e=>{var i=yg(),a=F(i),o=F(a),s=L(F(o),2);O(o);var c=L(o,2);mi(c,17,()=>B(n),e=>e.title,(e,t)=>{var n=_g(),r=F(n),i=F(r,!0);O(r);var a=L(r,2);mi(a,21,()=>B(t).rows,e=>e.description,(e,t)=>{var n=gg(),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);mi(u,21,()=>gm,e=>e.description,(e,t)=>{var n=vg(),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),pa(a,e=>P(r,e),()=>B(r)),Fi(a,(e,t)=>Gu?.(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()}Vr([`click`,`keydown`]);var xg=`/api/integrations/existing`,Sg=`/api/integrations`,Cg=`/api/integrations/apply`,wg=`/api/integrations/first-run-needed`;function Tg(e){return`/api/integrations/secrets/${encodeURIComponent(e)}`}function Eg(e){return`/api/models/secrets/${encodeURIComponent(e)}`}var Dg=`/api/integrations/claude-cli-status`,Og=`/api/integrations/install-claude-code`;function kg(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;xa(()=>{c=!1});let l=async e=>{try{let i=await n(`${t}${Dg}`);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}${Og}`,{method:`POST`});if(!c)return null;if(!e.ok){let t=await e.json().catch(()=>null);return c&&P(s,Ag(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 Ag(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 jg=`Tauri runtime not available`;async function Mg(){try{return(await ql(()=>import(`./core-SwWLTXZB.js`),[])).invoke}catch(e){return sh()&&console.error(`[keychain] Failed to load @tauri-apps/api/core:`,e),(()=>Promise.reject(Error(jg)))}}function Ng(e,t,n){return e(`keychain_set`,{account:t,secret:n})}function Pg(e,t){return e(`keychain_delete`,{account:t})}function Fg(e={}){let t=e.fetchFn??((...e)=>globalThis.fetch(...e)),n=e.baseUrl??``,r=e.pathFor??Tg;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 Ig=[`keychain-init`,`Platform secure storage failure`,`Couldn't access platform secure storage`];function Lg(e){return Ig.some(t=>e.includes(t))}function Rg(e={}){let t=()=>e.invoke?Promise.resolve(e.invoke):Mg();return{async set(e,n){try{return await Ng(await t(),e,n),{status:`ok`}}catch(e){let t=e instanceof Error?e.message:String(e);return Lg(t)?{status:`unavailable`}:{status:`error`,message:t}}},async delete(e){try{await Pg(await t(),e)}catch{}}}}function zg(e={}){return e.force===`tauri`||e.force!==`http`&&sh()?Rg({invoke:e.invoke}):Fg({fetchFn:e.fetchFn,baseUrl:e.baseUrl,pathFor:e.pathFor})}function Bg(e){return e.tandemValidation!==void 0&&e.tandemValidation.status!==`valid`}function Vg(e){return(e.status===`ok`||e.status===`missing`)&&!Bg(e)}function Hg(e){return`${e}-${crypto.randomUUID().replace(/-/g,``).slice(0,12)}`}function Ug(e){return`${e}-${crypto.randomUUID().slice(0,8)}`}function Wg(e){if(e.target.kind===`claude-code`){let t=e.tandemEntry?.url??`http://127.0.0.1:3479`,n=Ug(`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=Ug(`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 Gg(e={}){let t=e.fetchFn??globalThis.fetch.bind(globalThis),n=e.baseUrl??``,r=e.keychainBackend??zg({fetchFn:t,baseUrl:n}),i=N(`connect`),a=N(!0),o=N(un([])),s=N(un([])),c=N(null),l=N(un([])),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}${xg}`);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(Vg).map(Wg).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=Hg(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&&Bg(n);return{...e.config,apply:r?`skip`:`create`}})},r=!1;try{let a=await t(`${n}${Sg}`,{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}${Cg}`,{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 Kg=3e3,qg=1500,Jg=2e4;function Yg(e,t,n=``,r=globalThis.fetch.bind(globalThis),i={}){let a=i.verifyTimeoutMs??Kg,o=i.pollIntervalMs??qg,s=i.pollDeadlineMs??Jg,c=N(`idle`),l=N(null),u=N(!1),d=N(un([])),f=!0,p=null,m=0;function h(){p!==null&&(clearInterval(p),p=null)}xa(()=>{f=!1,h(),m++});async function g(e){let t=++m,i;try{i=await r(`${n}${bc}`,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=jr(()=>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 Xg=Yr(`<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>`),Zg=Yr(`<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>`),Qg=Yr(`<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>`),$g=H(`<span class="itc-check-empty svelte-q7klwd"></span>`),e_=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 t_(e,t){A(t,!0);let n=M(()=>Vg(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}:Bg(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=e_();let o;var s=F(a);ea(s);var c=L(s,2),l=F(c),u=e=>{U(e,Xg())},d=e=>{U(e,Zg())};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=Zr(),r=I(n),i=e=>{U(e,Qg())},a=e=>{U(e,$g())};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=Wi(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)??``}`),na(s,t.selected),s.disabled=!B(n),q(s,`data-testid`,`integration-wizard-pick-${B(r)??``}`),W(m,t.install.target.label),Wi(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()}Vr([`change`]);var n_=(e,t=m)=>{var n=o_();z(()=>Wi(n,0,Ri(t()),`svelte-bt94ms`)),U(e,n)},r_=e=>{U(e,s_())},i_=e=>{U(e,c_())},a_=(e,t=m)=>{var n=l_(),r=L(F(n));O(n),z(()=>W(r,` ${t()??``}`)),U(e,n)},o_=Yr(`<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>`),s_=Yr(`<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>`),c_=Yr(`<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>`),l_=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>`),u_=H(`<span><!></span>`),d_=H(`<p class="iw-subtitle svelte-bt94ms">Connect your AI assistant.</p>`),f_=H(`<p class="iw-subtitle svelte-bt94ms">Let a teammate's Claude join from the Cowork VM.</p>`),p_=H(`<div class="iw-whats-next svelte-bt94ms"><!> <span class="svelte-bt94ms">Cowork is enabled. Manage workspaces in Settings&nbsp;→&nbsp;Network.</span></div>`),m_=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>`),h_=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>`),g_=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),__=H(`<div class="iw-banner-warning svelte-bt94ms" role="alert" data-testid="integration-wizard-cowork-error"><!> <span class="svelte-bt94ms"> </span></div>`),v_=H(`<section class="iw-step svelte-bt94ms" data-testid="integration-wizard-cowork-step"><!> <!></section>`),y_=H(`<div class="iw-banner-warning svelte-bt94ms" role="alert" data-testid="integration-wizard-install-error"><!> <span class="svelte-bt94ms"> </span></div>`),b_=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),x_=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>`),S_=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>`),C_=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>`),w_=H(`<span class="iw-secret-stored svelte-bt94ms"><!> Token saved</span>`),T_=H(`<span class="iw-secret-skipped svelte-bt94ms">Skipped (secure storage unavailable)</span>`),E_=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>`),D_=H(`<div class="iw-secret-row svelte-bt94ms"><span class="iw-secret-label svelte-bt94ms"> </span> <!></div>`),O_=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>`),k_=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),A_=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>`),j_=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>`),M_=H(`<div class="iw-verifying svelte-bt94ms" data-testid="integration-wizard-step-verifying"><!></div>`),N_=H(`<span class="iw-result-detail svelte-bt94ms">Connected</span> <!>`,1),P_=H(`<span class="iw-result-detail svelte-bt94ms">Left unchanged (already set up, or couldn't be safely edited)</span>`),F_=H(`<span class="iw-result-detail svelte-bt94ms"> </span>`),I_=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>`),L_=H(`<div class="iw-results svelte-bt94ms"></div>`),R_=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),z_=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),B_=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>`),V_=H(`<p class="iw-hint-text svelte-bt94ms"> </p>`),H_=H(`<details class="iw-tech-details svelte-bt94ms"><summary class="svelte-bt94ms"><!> Technical details</summary> <pre class="iw-tech-text svelte-bt94ms"> </pre></details>`),U_=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>`),W_=H(`<span class="iw-more-badge svelte-bt94ms"><!> Enabled</span>`),G_=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>`),K_=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>`),q_=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>`),J_=H(`<section class="iw-more svelte-bt94ms" data-testid="integration-wizard-more"><div class="iw-more-label svelte-bt94ms">More integrations</div> <!> <!></section>`),Y_=H(`<!> <!>`,1),X_=H(`<button type="button" class="iw-btn iw-btn-primary svelte-bt94ms">Done</button>`),Z_=H(`<button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="cowork-enable-confirm-btn"> </button>`),Q_=H(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" data-testid="integration-wizard-cowork-back">Back</button> <!>`,1),$_=H(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Cancel</button>`),ev=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),tv=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),nv=H(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" disabled="">Connecting…</button>`),rv=H(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" data-testid="integration-wizard-done-retry">Try again</button>`),iv=H(`<!> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-done-close">Done</button>`,1),av=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),ov=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 sv(e,t){A(t,!0);let n=(e,t=m)=>{let n=M(()=>d(t()));var r=Zr(),i=I(r),a=e=>{var r=u_(),i=F(r),a=e=>{U(e,Xr(`Checking Tandem is reachable…`))},o=e=>{var t=Xr();z(()=>W(t,u.claudeConnected?`Claude connected just now`:`Tandem is responding`)),U(e,t)},s=e=>{U(e,Xr(`Config written, but the Tandem MCP server isn't responding — start Tandem, then restart
74
+ Claude.`))},c=e=>{U(e,Xr(`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(()=>{Wi(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=Gg({baseUrl:`http://127.0.0.1:${wa}`}),i=xh(()=>sh()),a=M(()=>qm(i.status)),o=kg(()=>t.open&&r.step===`connect`,`http://127.0.0.1:${wa}`),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=Yg(()=>B(l),()=>t.open&&r.step===`done`,`http://127.0.0.1:${wa}`);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(un({}));R(()=>{if(!t.open)return;let e=jr(()=>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 fh(await uh(),!0),await i.refetch(),P(p,`main`)}catch(e){P(g,Zm(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?Jm(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=Wg(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 D=/HTTP 5\d\d/,ne=/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 D.test(e)?`Tandem's helper isn't responding. Make sure Tandem is running, then try again.`:ne.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=Zr(),ue=I(le),de=e=>{var t=ov(),l=F(t),d=F(l),m=F(d),v=F(m),D=F(v,!0);O(v);var ne=L(v,2),re=e=>{U(e,d_())},le=e=>{U(e,f_())};G(ne,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=v_(),n=F(t),r=e=>{var t=p_();r_(F(t)),k(2),O(t),U(e,t)},a=e=>{var t=g_(),n=I(t);n_(F(n)),k(2),O(n);var r=L(n,2),a=e=>{var t=m_(),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,h_())};G(o,e=>{i.status?.uacDeclined&&e(s)});var c=L(o,2),l=F(c);i_(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=__(),n=F(t);n_(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=Y_(),l=I(t),d=e=>{var t=A_(),n=F(t),i=e=>{a_(e,()=>`Looking for Claude on your computer…`)},a=e=>{var t=S_(),n=L(F(t),2),r=e=>{var t=b_(),n=L(I(t),2),r=F(n,!0);O(n);var i=L(n,2),a=e=>{var t=y_(),n=F(t);n_(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=x_();r_(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=k_(),n=L(I(t),2);mi(n,21,()=>r.existing,e=>e.target.configPath,(e,t)=>{{let n=M(()=>E(B(t)));t_(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=O_(),n=F(t);i_(F(n)),k(),O(n);var i=L(n,2),a=L(F(i),2),o=e=>{var t=C_();n_(F(t)),k(2),O(t),U(e,t)};G(a,e=>{r.keychainUnavailable&&e(o)}),mi(L(a,2),17,()=>r.picked,e=>e.id,(e,t)=>{var n=D_(),r=F(n),i=F(r,!0);O(r);var a=L(r,2),o=e=>{var t=w_();r_(F(t)),k(),O(t),U(e,t)},s=e=>{U(e,T_())},c=e=>{var n=E_(),r=F(n);ea(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??``}`)}),oa(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=j_();a_(F(t),()=>`Connecting Claude…`),k(2),O(t),U(e,t)},_=e=>{var t=B_(),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=M_();a_(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=L_();mi(t,21,()=>r.applyResults,e=>e.id,(e,t)=>{var r=I_(),i=F(r),a=F(i),o=e=>{r_(e)},s=e=>{U(e,Xr(`—`))},c=e=>{n_(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=N_();n(L(I(r),2),()=>B(t).id),U(e,r)},m=e=>{U(e,P_())},h=e=>{var n=F_(),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=>{Wi(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,Xr(`Claude is connected and talking to Tandem. Ask it to open a document.`))},_=e=>{var t=R_();k(2),U(e,t)},v=e=>{U(e,Xr(`Open Claude Desktop to start using Tandem.`))},y=e=>{var t=z_();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=U_(),n=F(t);n_(n,()=>`iw-error-icon`);var i=L(n,4),a=e=>{var t=V_(),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=H_(),n=F(t);i_(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=J_(),n=L(F(t),2),r=e=>{var t=K_(),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=W_();r_(F(t)),k(),O(t),U(e,t)},l=e=>{var t=G_();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(()=>sh());G(n,e=>{B(o)&&e(r)});var s=L(n,2),c=e=>{U(e,q_())};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=Q_(),n=I(t),r=L(n,2),a=e=>{var t=X_();V(`click`,t,()=>P(p,`main`)),U(e,t)},o=e=>{var t=Z_(),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=Zr(),n=I(t),i=e=>{var t=$_();V(`click`,t,S),U(e,t)},a=e=>{var t=ev(),n=I(t),r=L(n,2);V(`click`,n,S),V(`click`,r,C),U(e,t)},o=e=>{var t=tv(),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,nv())},be=e=>{var t=iv(),n=I(t),r=e=>{var t=rv();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=av(),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),pa(l,e=>P(_,e),()=>B(_)),O(t),z(()=>W(D,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()}Vr([`click`,`keydown`]);function cv(e){return e.trial?.daysRemaining??e.daysRemaining??null}function lv(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=cv(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 uv(e){let t=await fetch(`${Bl}${Vc}`,{signal:e});if(!t.ok)throw Error(`${Vc} responded ${t.status} ${t.statusText}`);return await t.json()}async function dv(e){try{let t=await fetch(`${Bl}${Hc}`,{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 fv=6e4;function pv(){let e=N(null),t=M(()=>lv(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 uv();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(),fv))},stop:c,refresh(){return l()},set(t){P(e,t,!0),s(o(t))}}}var mv=pv(),hv=H(`<strong data-testid="license-trial-days" class="svelte-ae26fd"> </strong> `,1),gv=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 _v(e,t){A(t,!0);let n=M(()=>mv.ui);var r=Zr(),i=I(r),a=e=>{var t=gv(),r=F(t),i=F(r),a=e=>{var t=hv(),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,Xr(`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 vv=H(`<div class="license-activate__error svelte-1yvc9ue" data-testid="license-activate-error" role="alert"> </div>`),yv=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 bv(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 dv(e);P(i,!1),a.ok?(mv.set(a.state),P(n,``),t.onActivated?.()):P(r,a.error,!0)}var o=yv(),s=F(o);En(s),q(s,`rows`,4);var c=L(s,2),l=e=>{var t=vv(),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`)}),oa(s,()=>B(n),e=>P(n,e)),V(`click`,u,()=>void a()),U(e,o),j()}Vr([`click`]);var xv=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 Sv(e,t){A(t,!0);let n=M(()=>mv.ui);var r=Zr(),i=I(r),a=e=>{var t=xv(),n=F(t);bv(L(F(n),4),{}),O(n),O(t),U(e,t)};G(i,e=>{B(n).showWall&&e(a)}),U(e,r),j()}var Cv=e=>e;function wv(e,{delay:t=0,duration:n=400,easing:r=Cv}={}){let i=+getComputedStyle(e).opacity;return{delay:t,duration:n,easing:r,css:e=>`opacity: ${e*i}`}}var Tv=null;function Ev(e){let t=e.decorationsMuted;try{localStorage.setItem(ao,String(!t&&e.showAuthorship)),localStorage.setItem(oo,JSON.stringify({comment:!t&&e.showComments,highlight:!t&&e.showHighlights,note:!t&&e.showNotes}))}catch{}}function Dv(){if(Tv)return Tv;let e=Ll(),t=N(un(e));return Ev(e),Tv={get settings(){return B(t)},updateSettings:e=>{if(B(t)._readOnly)return;let n=Rl(B(t),e);try{localStorage.setItem(Ia,JSON.stringify(n))}catch{}Ev(n),P(t,n,!0)}},Tv}function Ov(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 kv=Ov(.2,.8,.2,1),Av=Ov(.4,0,.2,1),jv=260,Mv=260,Nv=280;function Pv(e){return e?!0:typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Fv(e){return{h:e.offsetHeight,mb:Number.parseFloat(getComputedStyle(e).marginBottom)||0}}function Iv(e,{enabled:t,reduceMotion:n}){if(!t||Pv(n))return{duration:0};let{h:r,mb:i}=Fv(e);return{duration:jv,easing:kv,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 Lv(e,{enabled:t,reduceMotion:n,id:r,modes:i}){let a=i?.get(r);if(i?.delete(r),!t||Pv(n))return{duration:0};let{h:o,mb:s}=Fv(e),c=e=>a===`accept`?`translateY(${-8*e}px)`:a===`dismiss`?`translateX(${40*e}px) scale(${1-.04*e})`:`none`;return{duration:Mv,easing:kv,css:(e,t)=>`opacity:${e}; height:${e*o}px; margin-bottom:${e*s}px; transform:${c(t)}; overflow:clip; box-sizing:border-box;`}}function Rv(e,{reduceMotion:t}){if(Pv(t))return{duration:0};let{h:n,mb:r}=Fv(e);return{duration:Nv,easing:kv,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 zv(e,{reduceMotion:t,exitMs:n=200}){if(Pv(t))return{duration:0};let{h:r,mb:i}=Fv(e);return{duration:n,easing:Av,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 Bv=new Map,Vv=480,Hv=1e3;function Uv(e,t){Bv.set(e,t),setTimeout(()=>Bv.delete(e),Hv)}function Wv(e,{id:t,reduceMotion:n}){let r=Bv.get(t);if(Bv.delete(t),!r||Pv(n))return{duration:0};let i=e.getBoundingClientRect(),a=r.left-i.left,o=r.top-i.top;return{duration:Vv,easing:kv,css:(e,t)=>`transform:translate(${a*t}px, ${o*t}px); opacity:${.2+.8*e};`}}var Gv=200;function Kv(e,{reduceMotion:t}){if(Pv(t))return{duration:0};let n=e.offsetWidth;return{duration:Gv,easing:kv,css:e=>`opacity:${e}; width:${e*n}px; min-width:0; overflow:clip; box-sizing:border-box; pointer-events:none;`}}var qv=220;function Jv(e,{reduceMotion:t}){if(Pv(t))return{duration:0};let n=e.offsetWidth;return{duration:qv,easing:kv,css:e=>`opacity:${e}; width:${e*n}px; min-width:0; overflow:clip; box-sizing:border-box;`}}function Yv(e,{reduceMotion:t}){if(Pv(t))return{duration:0};let n=e.offsetWidth,r=e.offsetHeight;return{duration:440,easing:kv,css:e=>`opacity:${e}; width:${e*n}px; height:${e*r}px; overflow:clip; box-sizing:border-box;`}}var Xv=380;function Zv(e,{reduceMotion:t}){if(Pv(t))return{duration:0};let{h:n,mb:r}=Fv(e);return{duration:Xv,easing:kv,css:e=>`opacity:${e}; height:${e*n}px; margin-bottom:${e*r}px; overflow:clip; box-sizing:border-box;`}}var Qv=H(`Detected VM subnet: <code> </code>.`,1),$v=H(`<div class="cos-error svelte-1h0desi" data-testid="cowork-onboarding-error" role="alert"> </div>`),ey=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>`),ty=H(`<button data-testid="cowork-onboarding-learn-more-btn" class="cos-btn cos-btn--ghost svelte-1h0desi" type="button">Learn more</button>`),ny=H(`<a class="cos-learn-more-link svelte-1h0desi" data-testid="cowork-onboarding-learn-more-link" target="_blank" rel="noreferrer">Learn more</a>`),ry=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>`),iy=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 ay(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 uh()),!0}catch(e){return P(i,`${t}: ${Zm(e instanceof Error?e.message:String(e))}`),!1}finally{P(r,!1)}}async function o(){await a(async e=>{await fh(e,!0)},`Failed to enable Cowork`)&&t.onAdvance()}function s(){oh(),t.onAdvance()}var c=iy(),l=L(F(c),2),u=L(F(l)),d=e=>{var n=Qv(),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=$v(),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=ey(),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=ry(),a=F(i),o=L(a,2),c=L(o,2),l=e=>{var n=ty();z(()=>n.disabled=B(r)),V(`click`,n,function(...e){t.onLearnMore?.apply(this,e)}),U(e,n)},u=e=>{var t=ny();z(()=>q(t,`href`,`${Ta}#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()}Vr([`click`]);var oy=H(`<div></div>`),sy=H(`<div style="display: flex; gap: var(--tandem-space-1); margin-bottom: var(--tandem-space-3);" class="svelte-1us4jmd"></div>`),cy=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),ly=H(`<div class="svelte-1us4jmd"><!></div>`),uy=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>`),dy=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 fy(e,t){A(t,!0);let n=Dv(),r=M(()=>Pv(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=sh(),o=ah(),s=M(()=>a&&ih(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=Zr(),m=I(p),h=e=>{var n=dy(),i=F(n),a=e=>{var n=sy();mi(n,20,()=>Array.from({length:B(l)},(e,t)=>t),e=>e,(e,n)=>{var r=oy();let i;z(()=>{i=Wi(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);li(o,()=>B(u).id,e=>{var n=ly(),i=F(n),a=e=>{ay(e,{get status(){return t.coworkStatus},get onAdvance(){return t.onNext}})},o=e=>{var t=cy(),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),Ni(1,n,()=>wv,()=>({duration:B(r)})),U(e,n)});var s=L(o,2),c=e=>{var n=uy(),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()}Vr([`click`]);var py=()=>new Map,my=e=>{let t=py();return e.forEach((e,n)=>{t.set(n,e)}),t},hy=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},gy=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},_y=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},vy=()=>new Set,yy=e=>e[e.length-1],by=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},xy=Array.from,Sy=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Cy=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},wy=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},Ty=Array.isArray,Ey=class{constructor(){this._observers=py()}on(e,t){return hy(this._observers,e,vy).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 xy((this._observers.get(e)||py()).values()).forEach(e=>e(...t))}destroy(){this._observers=py()}},Dy=Math.floor,Oy=Math.abs,ky=(e,t)=>e<t?e:t,Ay=(e,t)=>e>t?e:t;Number.isNaN;var jy=e=>e===0?1/e<0:e<0,My=1<<17,Ny=1<<18,Py=1<<19,Fy=1<<20,Iy=1<<21,Ly=1<<22,Ry=1<<23,zy=1<<24,By=1<<25,Vy=1<<26,Hy=1<<27,Uy=1<<28,Wy=1<<29;My-1,Ny-1,Py-1,Fy-1,Iy-1,Ly-1,Ry-1,zy-1,By-1,Vy-1,Hy-1,Uy-1,Wy-1;var Gy=2**53-1,Ky=-(2**53-1),qy=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&Dy(e)===e);Number.isNaN,Number.parseInt;var Jy=String.fromCharCode;String.fromCodePoint,Jy(65535);var Yy=e=>e.toLowerCase(),Xy=/^\s*/g,Zy=e=>e.replace(Xy,``),Qy=/([A-Z])/g,$y=(e,t)=>Zy(e.replace(Qy,e=>`${t}${Yy(e)}`)),eb=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},tb=typeof TextEncoder<`u`?new TextEncoder:null,nb=tb?e=>tb.encode(e):eb,rb=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});rb&&rb.decode(new Uint8Array).length===1&&(rb=null);var ib=(e,t)=>wy(t,()=>e).join(``),ab=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},ob=()=>new ab,sb=e=>{let t=ob();return e(t),lb(t)},cb=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},lb=e=>{let t=new Uint8Array(cb(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},ub=(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(Ay(n,t)*2),e.cpos=0)},db=(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},fb=db,pb=(e,t)=>{for(;t>127;)db(e,128|127&t),t=Dy(t/128);db(e,127&t)},mb=(e,t)=>{let n=jy(t);for(n&&(t=-t),db(e,(t>63?128:0)|(n?64:0)|63&t),t=Dy(t/64);t>0;)db(e,(t>127?128:0)|127&t),t=Dy(t/128)},hb=new Uint8Array(3e4),gb=hb.length/3,_b=tb&&tb.encodeInto?(e,t)=>{if(t.length<gb){let n=tb.encodeInto(t,hb).written||0;pb(e,n);for(let t=0;t<n;t++)db(e,hb[t])}else yb(e,nb(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;pb(e,r);for(let t=0;t<r;t++)db(e,n.codePointAt(t))},vb=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=ky(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(Ay(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},yb=(e,t)=>{pb(e,t.byteLength),vb(e,t)},bb=(e,t)=>{ub(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},xb=(e,t)=>bb(e,4).setFloat32(0,t,!1),Sb=(e,t)=>bb(e,8).setFloat64(0,t,!1),Cb=(e,t)=>bb(e,8).setBigInt64(0,t,!1),wb=new DataView(new ArrayBuffer(4)),Tb=e=>(wb.setFloat32(0,e),wb.getFloat32(0)===e),Eb=(e,t)=>{switch(typeof t){case`string`:db(e,119),_b(e,t);break;case`number`:qy(t)&&Oy(t)<=2147483647?(db(e,125),mb(e,t)):Tb(t)?(db(e,124),xb(e,t)):(db(e,123),Sb(e,t));break;case`bigint`:db(e,122),Cb(e,t);break;case`object`:if(t===null)db(e,126);else if(Ty(t)){db(e,117),pb(e,t.length);for(let n=0;n<t.length;n++)Eb(e,t[n])}else if(t instanceof Uint8Array)db(e,116),yb(e,t);else{db(e,118);let n=Object.keys(t);pb(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];_b(e,i),Eb(e,t[i])}}break;case`boolean`:db(e,t?120:121);break;default:db(e,127)}},Db=class extends ab{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&pb(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Ob=e=>{e.count>0&&(mb(e.encoder,e.count===1?e.s:-e.s),e.count>1&&pb(e.encoder,e.count-2))},kb=class{constructor(){this.encoder=new ab,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Ob(this),this.count=1,this.s=e)}toUint8Array(){return Ob(this),lb(this.encoder)}},Ab=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);mb(e.encoder,t),e.count>1&&pb(e.encoder,e.count-2)}},jb=class{constructor(){this.encoder=new ab,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Ab(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Ab(this),lb(this.encoder)}},Mb=class{constructor(){this.sarr=[],this.s=``,this.lensE=new kb}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 ab;return this.sarr.push(this.s),this.s=``,_b(e,this.sarr.join(``)),vb(e,this.lensE.toUint8Array()),lb(e)}},Nb=e=>Error(e),Pb=()=>{throw Nb(`Method unimplemented`)},Fb=()=>{throw Nb(`Unexpected case`)},Ib=Nb(`Unexpected end of array`),Lb=Nb(`Integer out of Range`),Rb=class{constructor(e){this.arr=e,this.pos=0}},zb=e=>new Rb(e),Bb=e=>e.pos!==e.arr.length,Vb=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Hb=e=>Vb(e,Wb(e)),Ub=e=>e.arr[e.pos++],Wb=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>Gy)throw Lb}throw Ib},Gb=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>Gy)throw Lb}throw Ib},Kb=rb?e=>rb.decode(Hb(e)):e=>{let t=Wb(e);if(t===0)return``;{let n=String.fromCodePoint(Ub(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Ub(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))}},qb=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Jb=[e=>void 0,e=>null,Gb,e=>qb(e,4).getFloat32(0,!1),e=>qb(e,8).getFloat64(0,!1),e=>qb(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Kb,e=>{let t=Wb(e),n={};for(let r=0;r<t;r++){let t=Kb(e);n[t]=Yb(e)}return n},e=>{let t=Wb(e),n=[];for(let r=0;r<t;r++)n.push(Yb(e));return n},Hb],Yb=e=>Jb[127-Ub(e)](e),Xb=class extends Rb{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Bb(this)?this.count=Wb(this)+1:this.count=-1),this.count--,this.s}},Zb=class extends Rb{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Gb(this);let e=jy(this.s);this.count=1,e&&(this.s=-this.s,this.count=Wb(this)+2)}return this.count--,this.s}},Qb=class extends Rb{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Gb(this),t=e&1;this.diff=Dy(e/2),this.count=1,t&&(this.count=Wb(this)+2)}return this.s+=this.diff,this.count--,this.s}},$b=class{constructor(e){this.decoder=new Zb(e),this.str=Kb(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 ex=crypto.getRandomValues.bind(crypto),tx=Math.random,nx=()=>ex(new Uint32Array(1))[0],rx=e=>e[Dy(tx()*e.length)],ix=`10000000-1000-4000-8000-100000000000`,ax=()=>ix.replace(/[018]/g,e=>(e^nx()&15>>e/4).toString(16)),ox=Date.now,sx=e=>new Promise(e);Promise.all.bind(Promise);var cx=e=>e===void 0?null:e,lx=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&&(lx=localStorage)}catch{}var ux=lx,dx=Symbol(`Equality`),fx=(e,t)=>e===t||!!e?.[dx]?.(t)||!1,px=e=>typeof e==`object`,mx=Object.assign,hx=Object.keys,gx=(e,t)=>{for(let n in e)t(e[n],n)},_x=e=>hx(e).length,vx=e=>{for(let t in e)return!1;return!0},yx=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},bx=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),xx=(e,t)=>e===t||_x(e)===_x(t)&&yx(e,(e,n)=>(e!==void 0||bx(t,n))&&fx(t[n],e)),Sx=Object.freeze,Cx=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&Cx(e[t])}return Sx(e)},wx=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&wx(e,t,n+1)}},Tx=e=>e,Ex=(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[dx]!=null)return e[dx](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)||!Ex(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(_x(e)!==_x(t))return!1;for(let n in e)if(!bx(e,n)||!Ex(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(!Ex(e[n],t[n]))return!1;break;default:return!1}return!0},Dx=(e,t)=>t.includes(e),Ox=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,kx=typeof window<`u`&&typeof document<`u`&&!Ox;typeof navigator<`u`&&/Mac/.test(navigator.platform);var Ax,jx=[],Mx=()=>{if(Ax===void 0)if(Ox){Ax=py();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&Ax.set(t,``),t=r):t===null?jx.push(r):(Ax.set(t,r),t=null)}t!==null&&Ax.set(t,``)}else typeof location==`object`?(Ax=py(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);Ax.set(`--${$y(t,`-`)}`,n),Ax.set(`-${$y(t,`-`)}`,n)}})):Ax=py();return Ax},Nx=e=>Mx().has(e),Px=e=>cx(Ox?{}[e.toUpperCase().replaceAll(`-`,`_`)]:ux.getItem(e)),Fx=e=>Nx(`--`+e)||Px(e)!==null,Ix=Fx(`production`),Lx=Ox&&Dx({}.FORCE_COLOR,[`true`,`1`,`2`])||!Nx(`--no-colors`)&&!Fx(`no-color`)&&(!Ox||process.stdout.isTTY)&&(!Ox||Nx(`--color`)||Px(`COLORTERM`)!==null||(Px(`TERM`)||``).includes(`color`)),Rx=e=>new Uint8Array(e),zx=kx?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Jy(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Bx=e=>{let t=Rx(e.byteLength);return t.set(e),t},Vx=e=>sb(t=>Eb(t,e)),Hx=class{constructor(e,t){this.left=e,this.right=t}},Ux=(e,t)=>new Hx(e,t),Wx=e=>e.next()>=.5,Gx=(e,t,n)=>Dy(e.next()*(n+1-t)+t),Kx=(e,t,n)=>Dy(e.next()*(n+1-t)+t),qx=(e,t,n)=>Kx(e,t,n),Jx=e=>Jy(qx(e,97,122)),Yx=(e,t=0,n=20)=>{let r=qx(e,t,n),i=``;for(let t=0;t<r;t++)i+=Jx(e);return i},Xx=(e,t)=>t[qx(e,0,t.length-1)],Zx=Symbol(`0schema`),Qx=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(ib(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
79
+ `)}},$x=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[dx]?fx(e,t):Ty(e)?Sy(e,e=>Cy(t,t=>$x(e,t))):px(e)?yx(e,(e,n)=>$x(e,t[n])):!1,eS=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),$x(t,n)}equals(e){return this.constructor===e.constructor&&Ex(this.shape,e.shape)}[Zx](){return!0}[dx](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Pb()}get nullable(){return NS(this,JS)}get optional(){return new dS(this)}cast(e){return QS(e,this),e}expect(e){return QS(e,this),e}},tS=class extends eS{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}},nS=(e,t=null)=>new tS(e,t);nS(tS);var rS=class extends eS{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}},iS=e=>new rS(e);nS(rS);var aS=class extends eS{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}},oS=(...e)=>new aS(e),sS=nS(aS),cS=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),lS=e=>{if(US.check(e))return[cS(e)];if(sS.check(e))return e.shape.map(e=>e+``);if(HS.check(e))return[`[+-]?\\d+.?\\d*`];if(WS.check(e))return[`.*`];if(PS.check(e))return e.shape.map(lS).flat(1);Fb()};nS(class extends eS{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(lS).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 uS=Symbol(`optional`),dS=class extends eS{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[uS](){return!0}},fS=nS(dS),pS=class extends eS{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new pS,nS(pS);var mS=class e extends eS{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):yx(this.shape,(n,r)=>{let i=this._isPartial&&!bx(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},hS=e=>new mS(e),gS=nS(mS),_S=iS(e=>e!=null&&(e.constructor===Object||e.constructor==null)),vS=class extends eS{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&yx(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)})}},yS=(e,t)=>new vS(e,t),bS=nS(vS),xS=class extends eS{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&yx(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},SS=(...e)=>new xS(e);nS(xS);var CS=class extends eS{constructor(e){super(),this.shape=e.length===1?e[0]:new MS(e)}check(e,t){let n=Ty(e)&&Sy(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},wS=(...e)=>new CS(e),TS=nS(CS),ES=iS(e=>Ty(e)),DS=class extends eS{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}},OS=(e,t=null)=>new DS(e,t);nS(DS);var kS=OS(eS),AS=nS(class extends eS{constructor(e){super(),this.len=e.length-1,this.args=SS(...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}}),jS=iS(e=>typeof e==`function`);nS(class extends eS{constructor(e){super(),this.shape=e}check(e,t){let n=Sy(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var MS=class extends eS{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=Cy(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},NS=(...e)=>e.findIndex(e=>PS.check(e))>=0?NS(...e.map(e=>ZS(e)).map(e=>PS.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new MS(e),PS=nS(MS),FS=()=>!0,IS=iS(FS),LS=nS(rS,e=>e.shape===FS),RS=iS(e=>typeof e==`bigint`),zS=iS(e=>e===RS),BS=iS(e=>typeof e==`symbol`);iS(e=>e===BS);var VS=iS(e=>typeof e==`number`),HS=iS(e=>e===VS),US=iS(e=>typeof e==`string`),WS=iS(e=>e===US),GS=iS(e=>typeof e==`boolean`),KS=iS(e=>e===GS),qS=oS(void 0);nS(aS,e=>e.shape.length===1&&e.shape[0]===void 0),oS(void 0);var JS=oS(null),YS=nS(aS,e=>e.shape.length===1&&e.shape[0]===null);nS(Uint8Array),nS(tS,e=>e.shape===Uint8Array);var XS=NS(VS,US,JS,qS,RS,GS,BS);(()=>{let e=wS(IS),t=yS(US,IS),n=NS(VS,US,JS,GS,e,t);return e.shape=n,t.shape.values=n,n})();var ZS=e=>{if(kS.check(e))return e;if(_S.check(e)){let t={};for(let n in e)t[n]=ZS(e[n]);return hS(t)}else if(ES.check(e))return NS(...e.map(ZS));else if(XS.check(e))return oS(e);else if(jS.check(e))return nS(e);Fb()},QS=Ix?()=>{}:(e,t)=>{let n=new Qx;if(!t.check(e,n))throw Nb(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},$S=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:ZS(e),h:t}),this}else(e){return this.if(IS,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 Nb(`Unhandled pattern`)}}},eC=(e=>new $S(e))(IS).if(HS,(e,t)=>Gx(t,Ky,Gy)).if(WS,(e,t)=>Yx(t)).if(KS,(e,t)=>Wx(t)).if(zS,(e,t)=>BigInt(Gx(t,Ky,Gy))).if(PS,(e,t)=>tC(t,Xx(t,e.shape))).if(gS,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(fS.check(i)){if(Wx(t))continue;i=i.shape}n[r]=eC(i,t)}return n}).if(TS,(e,t)=>{let n=[],r=Kx(t,0,42);for(let i=0;i<r;i++)n.push(tC(t,e.shape));return n}).if(sS,(e,t)=>Xx(t,e.shape)).if(YS,(e,t)=>null).if(AS,(e,t)=>{let n=tC(t,e.res);return()=>n}).if(LS,(e,t)=>tC(t,Xx(t,[VS,US,JS,qS,RS,GS,wS(VS),yS(NS(`a`,`b`,`c`),VS)]))).if(bS,(e,t)=>{let n={},r=Gx(t,0,3);for(let i=0;i<r;i++){let r=tC(t,e.shape.keys);n[r]=tC(t,e.shape.values)}return n}).done(),tC=(e,t)=>eC(ZS(t),e),nC=typeof document<`u`?document:{};iS(e=>e.nodeType===sC),typeof DOMParser<`u`&&new DOMParser,iS(e=>e.nodeType===iC),iS(e=>e.nodeType===aC);var rC=e=>gy(e,(e,t)=>`${t}:${e};`).join(``),iC=nC.ELEMENT_NODE,aC=nC.TEXT_NODE;nC.CDATA_SECTION_NODE,nC.COMMENT_NODE;var oC=nC.DOCUMENT_NODE;nC.DOCUMENT_TYPE_NODE;var sC=nC.DOCUMENT_FRAGMENT_NODE;iS(e=>e.nodeType===oC);var cC=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),lC=(e,t)=>new cC(setTimeout(t,e)),uC=Symbol,dC=uC(),fC=uC(),pC=uC(),mC=uC(),hC=uC(),gC=uC(),_C=uC(),vC=uC(),yC=uC(),bC=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};ox();var xC={[dC]:Ux(`font-weight`,`bold`),[fC]:Ux(`font-weight`,`normal`),[pC]:Ux(`color`,`blue`),[hC]:Ux(`color`,`green`),[mC]:Ux(`color`,`grey`),[gC]:Ux(`color`,`red`),[_C]:Ux(`color`,`purple`),[vC]:Ux(`color`,`orange`),[yC]:Ux(`color`,`black`)},SC=Lx?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=py(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=xC[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=rC(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}:bC,CC=(...e)=>{console.log(...SC(e)),TC.forEach(t=>t.print(e))},wC=(...e)=>{console.warn(...SC(e)),e.unshift(vC),TC.forEach(t=>t.print(e))},TC=vy(),EC=e=>({[Symbol.iterator](){return this},next:e}),DC=(e,t)=>EC(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),OC=(e,t)=>EC(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),kC=class{constructor(e,t){this.clock=e,this.len=t}},AC=class{constructor(){this.clients=new Map}},jC=(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])Yw(e,i,o.clock,o.len,n)}}),MC=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=Dy((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},NC=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&MC(n,t.clock)!==null},PC=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 kC(r.clock,Ay(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},FC=e=>{let t=new AC;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++)by(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return PC(t),t},IC=(e,t,n,r)=>{hy(e.clients,t,()=>[]).push(new kC(n,r))},LC=()=>new AC,RC=e=>{let t=LC();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 kC(i,a))}}r.length>0&&t.clients.set(n,r)}),t},zC=(e,t)=>{pb(e.restEncoder,t.clients.size),xy(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),pb(e.restEncoder,t);let r=n.length;pb(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},BC=e=>{let t=new AC,n=Wb(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=Wb(e.restDecoder),r=Wb(e.restDecoder);if(r>0){let i=hy(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new kC(e.readDsClock(),e.readDsLen()))}}return t},VC=(e,t,n)=>{let r=new AC,i=Wb(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=Wb(e.restDecoder),a=Wb(e.restDecoder),o=n.clients.get(i)||[],s=Vw(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&IC(r,i,s,a-s);let e=Uw(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,fD(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,fD(t,c,a-c.id.clock)),c.delete(t))}else IC(r,i,n,a-n)}}if(r.clients.size>0){let e=new ZC;return pb(e.restEncoder,0),zC(e,r),e.toUint8Array()}return null},HC=nx,UC=class e extends Ey{constructor({guid:e=ax(),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=HC(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new zw,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=sx(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>sx(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&&rT(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(xy(this.subdocs).map(e=>e.guid))}transact(e,t=null){return rT(this,e,t)}get(e,t=NT){let n=hy(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==NT&&r!==t)if(r===NT){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,eE)}getText(e=``){return this.get(e,xE)}getMap(e=``){return this.get(e,rE)}getXmlElement(e=``){return this.get(e,EE)}getXmlFragment(e=``){return this.get(e,wE)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,xy(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,rT(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()}},WC=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Wb(this.restDecoder)}readDsLen(){return Wb(this.restDecoder)}},GC=class extends WC{readLeftID(){return Sw(Wb(this.restDecoder),Wb(this.restDecoder))}readRightID(){return Sw(Wb(this.restDecoder),Wb(this.restDecoder))}readClient(){return Wb(this.restDecoder)}readInfo(){return Ub(this.restDecoder)}readString(){return Kb(this.restDecoder)}readParentInfo(){return Wb(this.restDecoder)===1}readTypeRef(){return Wb(this.restDecoder)}readLen(){return Wb(this.restDecoder)}readAny(){return Yb(this.restDecoder)}readBuf(){return Bx(Hb(this.restDecoder))}readJSON(){return JSON.parse(Kb(this.restDecoder))}readKey(){return Kb(this.restDecoder)}},KC=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Wb(this.restDecoder),this.dsCurrVal}readDsLen(){let e=Wb(this.restDecoder)+1;return this.dsCurrVal+=e,e}},qC=class extends KC{constructor(e){super(e),this.keys=[],Wb(e),this.keyClockDecoder=new Qb(Hb(e)),this.clientDecoder=new Zb(Hb(e)),this.leftClockDecoder=new Qb(Hb(e)),this.rightClockDecoder=new Qb(Hb(e)),this.infoDecoder=new Xb(Hb(e),Ub),this.stringDecoder=new $b(Hb(e)),this.parentInfoDecoder=new Xb(Hb(e),Ub),this.typeRefDecoder=new Zb(Hb(e)),this.lenDecoder=new Zb(Hb(e))}readLeftID(){return new bw(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new bw(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 Yb(this.restDecoder)}readBuf(){return Hb(this.restDecoder)}readJSON(){return Yb(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}}},JC=class{constructor(){this.restEncoder=ob()}toUint8Array(){return lb(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){pb(this.restEncoder,e)}writeDsLen(e){pb(this.restEncoder,e)}},YC=class extends JC{writeLeftID(e){pb(this.restEncoder,e.client),pb(this.restEncoder,e.clock)}writeRightID(e){pb(this.restEncoder,e.client),pb(this.restEncoder,e.clock)}writeClient(e){pb(this.restEncoder,e)}writeInfo(e){fb(this.restEncoder,e)}writeString(e){_b(this.restEncoder,e)}writeParentInfo(e){pb(this.restEncoder,+!!e)}writeTypeRef(e){pb(this.restEncoder,e)}writeLen(e){pb(this.restEncoder,e)}writeAny(e){Eb(this.restEncoder,e)}writeBuf(e){yb(this.restEncoder,e)}writeJSON(e){_b(this.restEncoder,JSON.stringify(e))}writeKey(e){_b(this.restEncoder,e)}},XC=class{constructor(){this.restEncoder=ob(),this.dsCurrVal=0}toUint8Array(){return lb(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,pb(this.restEncoder,t)}writeDsLen(e){e===0&&Fb(),pb(this.restEncoder,e-1),this.dsCurrVal+=e}},ZC=class extends XC{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new jb,this.clientEncoder=new kb,this.leftClockEncoder=new jb,this.rightClockEncoder=new jb,this.infoEncoder=new Db(fb),this.stringEncoder=new Mb,this.parentInfoEncoder=new Db(fb),this.typeRefEncoder=new kb,this.lenEncoder=new kb}toUint8Array(){let e=ob();return pb(e,0),yb(e,this.keyClockEncoder.toUint8Array()),yb(e,this.clientEncoder.toUint8Array()),yb(e,this.leftClockEncoder.toUint8Array()),yb(e,this.rightClockEncoder.toUint8Array()),yb(e,lb(this.infoEncoder)),yb(e,this.stringEncoder.toUint8Array()),yb(e,lb(this.parentInfoEncoder)),yb(e,this.typeRefEncoder.toUint8Array()),yb(e,this.lenEncoder.toUint8Array()),vb(e,lb(this.restEncoder)),lb(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){Eb(this.restEncoder,e)}writeBuf(e){yb(this.restEncoder,e)}writeJSON(e){Eb(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)}},QC=(e,t,n,r)=>{r=Ay(r,t[0].id.clock);let i=Uw(t,r);pb(e.restEncoder,t.length-i),e.writeClient(n),pb(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)},$C=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{Vw(t,n)>e&&r.set(n,e)}),Bw(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),pb(e.restEncoder,r.size),xy(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{QC(e,t.clients.get(n),n,r)})},ew=(e,t)=>{let n=py(),r=Wb(e.restDecoder);for(let i=0;i<r;i++){let r=Wb(e.restDecoder),i=Array(r),a=e.readClient(),o=Wb(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 FE(Sw(a,o),t),o+=t;break}case 10:{let t=Wb(e.restDecoder);i[n]=new yD(Sw(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new hD(Sw(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,gD(e,r));i[n]=c,o+=c.length}}}}return n},tw=(e,t,n)=>{let r=[],i=xy(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 zw,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!==yD){let i=hy(d,u.id.client,()=>Vw(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,Vw(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 ZC;return $C(e,s,new Map),pb(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},nw=(e,t)=>$C(e,t.doc.store,t.beforeState),rw=(e,t,n,r=new qC(e))=>rT(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=tw(e,i,ew(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<Vw(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=pT([o.update,a.update])}}else i.pendingStructs=a;let s=VC(r,e,i);if(i.pendingDs){let t=new qC(zb(i.pendingDs));Wb(t.restDecoder);let n=VC(t,e,i);s&&n?i.pendingDs=pT([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,iw(e.doc,t)}},n,!1),iw=(e,t,n,r=qC)=>{let i=zb(t);rw(i,e,n,new r(i))},aw=(e,t,n)=>iw(e,t,n,GC),ow=(e,t,n=new Map)=>{$C(e,t.store,n),zC(e,RC(t.store))},sw=(e,t=new Uint8Array([0]),n=new ZC)=>{ow(n,e,uw(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(mT(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===YC)return dT(r.map((e,t)=>t===0?e:yT(e)));if(n.constructor===ZC)return pT(r)}return r[0]},cw=(e,t)=>sw(e,t,new YC),lw=e=>{let t=new Map,n=Wb(e.restDecoder);for(let r=0;r<n;r++){let n=Wb(e.restDecoder),r=Wb(e.restDecoder);t.set(n,r)}return t},uw=e=>lw(new WC(zb(e))),dw=(e,t)=>(pb(e.restEncoder,t.size),xy(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{pb(e.restEncoder,t),pb(e.restEncoder,n)}),e),fw=(e,t)=>dw(e,Bw(t.store)),pw=(e,t=new XC)=>(e instanceof Map?dw(t,e):fw(t,e),t.toUint8Array()),mw=e=>pw(e,new JC),hw=class{constructor(){this.l=[]}},gw=()=>new hw,_w=(e,t)=>e.l.push(t),vw=(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.`)},yw=(e,t,n)=>wx(e.l,[t,n]),bw=class{constructor(e,t){this.client=e,this.clock=t}},xw=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,Sw=(e,t)=>new bw(e,t),Cw=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw Fb()},ww=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},Tw=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},Ew=e=>new Tw(e.type==null?null:Sw(e.type.client,e.type.clock),e.tname??null,e.item==null?null:Sw(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),Dw=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},Ow=(e,t,n=0)=>new Dw(e,t,n),kw=(e,t,n)=>{let r=null,i=null;return e._item===null?i=Cw(e):r=Sw(e._item.id.client,e._item.id.clock),new Tw(r,i,t,n)},Aw=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return kw(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return kw(e,Sw(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return kw(e,r.lastId,n);r=r.right}return kw(e,null,n)},jw=(e,t)=>{let n=Ww(e,t);return{item:n,diff:t.clock-n.id.clock}},Mw=(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(Vw(r,i.client)<=i.clock)return null;let e=n?uD(r,i):jw(r,i),t=e.item;if(!(t instanceof hD))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(Vw(r,a.client)<=a.clock)return null;let{item:e}=n?uD(r,a):{item:Ww(r,a)};if(e instanceof hD&&e.content instanceof cD)c=e.content.type;else return null}else throw Fb();l=s>=0?c._length:0}return Ow(c,l,e.assoc)},Nw=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&xw(e.item,t.item)&&xw(e.type,t.type)&&e.assoc===t.assoc,Pw=class{constructor(e,t){this.ds=e,this.sv=t}},Fw=(e,t)=>new Pw(e,t);Fw(LC(),new Map);var Iw=e=>Fw(RC(e.store),Bw(e.store)),Lw=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!NC(t.ds,e.id),Rw=(e,t)=>{let n=hy(e.meta,Rw,vy),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<Vw(r,n)&&Kw(e,Sw(n,t))}),jC(e,t.ds,e=>{}),n.add(t))},zw=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Bw=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},Vw=(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},Hw=(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 Fb()}n.push(t)},Uw=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=Dy(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=Dy((n+r)/2)}throw Fb()},Ww=(e,t)=>{let n=e.clients.get(t.client);return n[Uw(n,t.clock)]},Gw=(e,t,n)=>{let r=Uw(t,n),i=t[r];return i.id.clock<n&&i instanceof hD?(t.splice(r+1,0,fD(e,i,n-i.id.clock)),r+1):r},Kw=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Gw(e,n,t.clock)]},qw=(e,t,n)=>{let r=t.clients.get(n.client),i=Uw(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==FE&&r.splice(i+1,0,fD(e,a,n.clock-a.id.clock+1)),a},Jw=(e,t,n)=>{let r=e.clients.get(t.id.client);r[Uw(r,t.id.clock)]=n},Yw=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=Gw(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&Gw(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Xw=class{constructor(e,t,n){this.doc=e,this.deleteSet=new AC,this.beforeState=Bw(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}},Zw=(e,t)=>t.deleteSet.clients.size===0&&!_y(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(PC(t.deleteSet),nw(e,t),zC(e,t.deleteSet),!0),Qw=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&hy(e.changed,t,vy).add(n)},$w=(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 hD&&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},eT=(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=Uw(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 hD&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},tT=(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=ky(r.length-1,1+Uw(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+$w(r,e)}})},nT=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{PC(a),n.afterState=Bw(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(()=>{yw(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&vE(n)})}),wx(e,[])}finally{r.gc&&eT(a,i,r.gcFilter),tT(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=Ay(Uw(e,r),1);for(let t=e.length-1;t>=n;)t-=1+$w(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=Uw(r,n);a+1<r.length&&$w(r,a+1)>1||a>0&&$w(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(CC(vC,dC,`[yjs] `,fC,gC,`Changed the client-id because another client seems to be using it.`),r.clientID=HC()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new YC;Zw(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new ZC;Zw(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])):nT(e,t+1)}}},rT=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Xw(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&&nT(i,0)}}return o},iT=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},aT=(e,t,n)=>{jC(e,n.deletions,n=>{n instanceof hD&&t.scope.some(t=>t===e.doc||ww(t,n))&&dD(n,!1)})},oT=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;rT(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;jC(n,o.insertions,e=>{if(e instanceof hD){if(e.redone!==null){let{item:t,diff:i}=uD(r,e.id);i>0&&(t=Kw(n,Sw(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||ww(t,e))&&c.push(e)}}),jC(n,o.deletions,e=>{e instanceof hD&&a.some(t=>t===n.doc||ww(t,e))&&!NC(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=mD(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},sT=class extends Ey{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=Ty(e)?e[0].doc:e instanceof UC?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 AC;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&IC(i,n,r,a)});let a=ox(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=FC([t.deletions,e.deleteSet]),t.insertions=FC([t.insertions,i])}else r.push(new iT(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),jC(e,e.deleteSet,t=>{t instanceof hD&&this.scope.some(n=>n===e.doc||ww(n,t))&&dD(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=Ty(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof NT?e.doc!==this.doc:e!==this.doc)&&wC(`[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=>aT(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>aT(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=oT(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=oT(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*cT(e){let t=Wb(e.restDecoder);for(let n=0;n<t;n++){let t=Wb(e.restDecoder),n=e.readClient(),r=Wb(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=Wb(e.restDecoder);yield new yD(Sw(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new hD(Sw(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,gD(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new FE(Sw(n,r),t),r+=t}}}}var lT=class{constructor(e,t){this.gen=cT(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===yD);return this.curr}},uT=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},dT=e=>pT(e,GC,YC),fT=(e,t)=>{if(e.constructor===FE){let{client:n,clock:r}=e.id;return new FE(Sw(n,r+t),e.length-t)}else if(e.constructor===yD){let{client:n,clock:r}=e.id;return new yD(Sw(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new hD(Sw(r,i+t),null,Sw(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},pT=(e,t=qC,n=ZC)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(zb(e))),i=r.map(e=>new lT(e,!0)),a=null,o=new n,s=new uT(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===yD?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)gT(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===yD)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{gT(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new yD(Sw(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===yD?a.struct.length-=t:n=fT(n,t)),a.struct.mergeWith(n)||(gT(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!==yD;n=e.next())gT(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(gT(s,a.struct,a.offset),a=null),_T(s),zC(o,FC(r.map(e=>BC(e)))),o.toUint8Array()},mT=(e,t,n=qC,r=ZC)=>{let i=uw(t),a=new r,o=new uT(a),s=new n(zb(e)),c=new lT(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===yD){c.next();continue}if(e.id.clock+e.length>n)for(gT(o,e,Ay(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)gT(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 _T(o),zC(a,BC(s)),a.toUint8Array()},hT=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:lb(e.encoder.restEncoder)}),e.encoder.restEncoder=ob(),e.written=0)},gT=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&hT(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),pb(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},_T=e=>{hT(e);let t=e.encoder.restEncoder;pb(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];pb(t,r.written),vb(t,r.restEncoder)}},vT=(e,t,n,r)=>{let i=new n(zb(e)),a=new lT(i,!1),o=new r,s=new uT(o);for(let e=a.curr;e!==null;e=a.next())gT(s,t(e),0);return _T(s),zC(o,BC(i)),o.toUint8Array()},yT=e=>vT(e,Tx,qC,YC),bT=`You must not compute changes after the event-handler fired.`,xT=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||=ST(this.currentTarget,this.target)}deletes(e){return NC(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Nb(bT);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=yy(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=yy(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=yy(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 Nb(bT);let t=this.target,n=vy(),r=vy(),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}},ST=(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},CT=()=>{wC(`Invalid access: Add Yjs type to a document before reading data.`)},wT=80,TT=0,ET=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=TT++}},DT=e=>{e.timestamp=TT++},OT=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=TT++},kT=(e,t,n)=>{if(e.length>=wT){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return OT(r,t,n),r}else{let r=new ET(t,n);return e.push(r),r}},AT=(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)=>Oy(t-e.index)<Oy(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,DT(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&&Oy(n.index-i)<r.parent.length/wT?(OT(n,r,i),n):kT(e._searchMarker,r,i)},jT=(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=Ay(t,i.index+n))}},MT=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;hy(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;yw(r._eH,n,t)},NT=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=gw(),this._dEH=gw(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Pb()}clone(){throw Pb()}_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){_w(this._eH,e)}observeDeep(e){_w(this._dEH,e)}unobserve(e){vw(this._eH,e)}unobserveDeep(e){vw(this._dEH,e)}toJSON(){}},PT=(e,t,n)=>{e.doc??CT(),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},FT=e=>{e.doc??CT();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},IT=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&Lw(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},LT=(e,t)=>{let n=0,r=e._start;for(e.doc??CT();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}},RT=(e,t)=>{let n=[];return LT(e,(r,i)=>{n.push(t(r,i,e))}),n},zT=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}}}},BT=(e,t)=>{e.doc??CT();let n=AT(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}},VT=(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 hD(Sw(o,Vw(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new XE(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 hD(Sw(o,Vw(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new IE(new Uint8Array(n))),i.integrate(e,0);break;case UC:i=new hD(Sw(o,Vw(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new VE(n)),i.integrate(e,0);break;default:if(n instanceof NT)i=new hD(Sw(o,Vw(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new cD(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},HT=()=>Nb(`Length exceeded!`),UT=(e,t,n,r)=>{if(n>t._length)throw HT();if(n===0)return t._searchMarker&&jT(t._searchMarker,n,r.length),VT(e,t,null,r);let i=n,a=AT(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&&Kw(e,Sw(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&jT(t._searchMarker,i,r.length),VT(e,t,o,r)},WT=(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 VT(e,t,r,n)},GT=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=AT(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&&Kw(e,Sw(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&Kw(e,Sw(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw HT();t._searchMarker&&jT(t._searchMarker,i,-a+r)},KT=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},qT=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new XE([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new XE([r]);break;case Uint8Array:s=new IE(r);break;case UC:s=new VE(r);break;default:if(r instanceof NT)s=new cD(r);else throw Error(`Unexpected content type`)}new hD(Sw(o,Vw(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},JT=(e,t)=>{e.doc??CT();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},YT=e=>{let t={};return e.doc??CT(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},XT=(e,t)=>{e.doc??CT();let n=e._map.get(t);return n!==void 0&&!n.deleted},ZT=(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&&Lw(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},QT=e=>(e.doc??CT(),DC(e._map.entries(),e=>!e[1].deleted)),$T=class extends xT{},eE=class e extends NT{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 NT?e.clone():e)),t}get length(){return this.doc??CT(),this._length}_callObserver(e,t){super._callObserver(e,t),MT(this,e,new $T(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):rT(this.doc,n=>{UT(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):rT(this.doc,t=>{WT(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):rT(this.doc,n=>{GT(n,this,e,t)})}get(e){return BT(this,e)}toArray(){return FT(this)}slice(e=0,t=this.length){return PT(this,e,t)}toJSON(){return this.map(e=>e instanceof NT?e.toJSON():e)}map(e){return RT(this,e)}forEach(e){LT(this,e)}[Symbol.iterator](){return zT(this)}_write(e){e.writeTypeRef(tD)}},tE=e=>new eE,nE=class extends xT{constructor(e,t,n){super(e,t),this.keysChanged=n}},rE=class e extends NT{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 NT?e.clone():e)}),t}_callObserver(e,t){MT(this,e,new nE(this,e,t))}toJSON(){this.doc??CT();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof NT?r.toJSON():r}}),e}get size(){return[...QT(this)].length}keys(){return OC(QT(this),e=>e[0])}values(){return OC(QT(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return OC(QT(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??CT(),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):rT(this.doc,t=>{KT(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):rT(this.doc,n=>{qT(n,this,e,t)}),t}get(e){return JT(this,e)}has(e){return XT(this,e)}clear(){this.doc===null?this._prelimContent.clear():rT(this.doc,e=>{this.forEach(function(t,n,r){KT(e,r,n)})})}_write(e){e.writeTypeRef(nD)}},iE=e=>new rE,aE=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&xx(e,t),oE=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&Fb(),this.right.content.constructor){case GE:this.right.deleted||uE(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}},sE=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case GE:t.right.deleted||uE(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&Kw(e,Sw(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},cE=(e,t,n,r)=>{let i=new Map,a=r?AT(t,n):null;return a?sE(e,new oE(a.p.left,a.p,a.index,i),n-a.index):sE(e,new oE(null,t._start,0,i),n)},lE=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===GE&&aE(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 hD(Sw(a,Vw(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new GE(o,r));l.integrate(e,0),n.right=l,n.forward()})},uE=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},dE=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===GE&&aE(t[e.right.content.key]??null,e.right.content.value));)e.forward()},fE=(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(!aE(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new hD(Sw(a,Vw(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new GE(s,c)),n.right.integrate(e,0),n.forward()}}return o},pE=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;dE(n,i);let s=fE(e,t,n,i),c=r.constructor===String?new QE(r):r instanceof NT?new cD(r):new UE(r),{left:l,right:u,index:d}=n;t._searchMarker&&jT(t._searchMarker,n.index,c.getLength()),u=new hD(Sw(o,Vw(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(),lE(e,t,n,s)},mE=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;dE(n,i);let s=fE(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===GE));){if(!n.right.deleted)switch(n.right.content.constructor){case GE:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(aE(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&&Kw(e,Sw(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 hD(Sw(o,Vw(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new QE(i)),n.right.integrate(e,0),n.forward()}lE(e,t,n,s)},hE=(e,t,n,r,i)=>{let a=t,o=py();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===GE){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 GE:{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&&uE(i,n);break}}}t=t.right}return s},gE=(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===GE){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},_E=e=>{let t=0;return rT(e.doc,n=>{let r=e._start,i=e._start,a=py(),o=my(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case GE:uE(o,i.content);break;default:t+=hE(n,r,i,a,o),a=my(o),r=i;break}i=i.right}}),t},vE=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&&Yw(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===GE&&e.constructor!==FE&&t.add(e.parent)})}rT(n,n=>{jC(e,e.deleteSet,e=>{if(e instanceof FE||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===GE?t.add(r):gE(n,e)});for(let e of t)_E(e)})},yE=(e,t,n)=>{let r=n,i=my(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case cD:case UE:case QE:n<t.right.length&&Kw(e,Sw(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&hE(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&jT(o._searchMarker,t.index,-r+n),t},bE=class extends xT{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=[];rT(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},vx(o)||(e.attributes=mx({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case cD:case UE: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 QE: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 GE:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(aE(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),aE(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;aE(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(aE(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),uE(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}},xE=class e extends NT{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??CT(),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 bE(this,e,t);MT(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??CT();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===QE&&(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)):rT(this.doc,n=>{let r=new oE(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)&&pE(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&yE(n,r,a.delete):mE(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??CT();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(Lw(s,e)||t!==void 0&&Lw(s,t))switch(s.content.constructor){case QE:{let r=i.get(`ychange`);e!==void 0&&!Lw(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&&!Lw(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 cD:case UE:{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 GE:Lw(s,e)&&(c(),uE(i,s.content));break}s=s.right}c()};return e||t?rT(a,n=>{e&&Rw(n,e),t&&Rw(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)):rT(r,r=>{let i=cE(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),pE(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):rT(r,r=>{let i=cE(r,this,e,!n);pE(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)):rT(n,n=>{yE(n,cE(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)):rT(r,r=>{let i=cE(r,this,e,!1);i.right!==null&&mE(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):rT(this.doc,t=>{KT(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):rT(this.doc,n=>{qT(n,this,e,t)})}getAttribute(e){return JT(this,e)}getAttributes(){return YT(this)}_write(e){e.writeTypeRef(rD)}},SE=e=>new xE,CE=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??CT()}[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===EE||t.constructor===wE)&&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})}},wE=class e extends NT{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 NT?e.clone():e)),t}get length(){return this.doc??CT(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new CE(this,e)}querySelector(e){e=e.toUpperCase();let t=new CE(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),xy(new CE(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){MT(this,e,new OE(this,t,e))}toString(){return RT(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),LT(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):rT(this.doc,n=>{UT(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)rT(this.doc,n=>{let r=e&&e instanceof NT?e._item:e;VT(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 Nb(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):rT(this.doc,n=>{GT(n,this,e,t)})}toArray(){return FT(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return BT(this,e)}slice(e=0,t=this.length){return PT(this,e,t)}forEach(e){LT(this,e)}_write(e){e.writeTypeRef(aD)}},TE=e=>new wE,EE=class e extends wE{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 gx(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof NT?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):rT(this.doc,t=>{KT(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):rT(this.doc,n=>{qT(n,this,e,t)})}getAttribute(e){return JT(this,e)}hasAttribute(e){return XT(this,e)}getAttributes(e){return e?ZT(this,e):YT(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 LT(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(iD),e.writeKey(this.nodeName)}},DE=e=>new EE(e.readKey()),OE=class extends xT{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)})}},kE=class e extends rE{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(oD),e.writeKey(this.hookName)}},AE=e=>new kE(e.readKey()),jE=class e extends xE{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(sD)}},ME=e=>new jE,NE=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Pb()}mergeWith(e){return!1}write(e,t,n){throw Pb()}integrate(e,t){throw Pb()}},PE=0,FE=class extends NE{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),Hw(e.doc.store,this)}write(e,t){e.writeInfo(PE),e.writeLen(this.length-t)}getMissing(e,t){return null}},IE=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 Pb()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},LE=e=>new IE(e.readBuf()),RE=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){IC(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}},zE=e=>new RE(e.readLen()),BE=(e,t)=>new UC({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),VE=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(BE(this.doc.guid,this.opts))}splice(e){throw Pb()}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}},HE=e=>new VE(BE(e.readString(),e.readAny())),UE=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 Pb()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},WE=e=>new UE(e.readJSON()),GE=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 Pb()}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}},KE=e=>new GE(e.readKey(),e.readJSON()),qE=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}},JE=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 qE(n)},YE=Px(`node_env`)===`development`,XE=class e{constructor(e){this.arr=e,YE&&Cx(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}},ZE=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new XE(n)},QE=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}},$E=e=>new QE(e.readString()),eD=[tE,iE,SE,DE,TE,AE,ME],tD=0,nD=1,rD=2,iD=3,aD=4,oD=5,sD=6,cD=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 Pb()}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}},lD=e=>new cD(eD[e.readTypeRef()](e)),uD=(e,t)=>{let n=t,r=0,i;do r>0&&(n=Sw(n.client,n.clock+r)),i=Ww(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof hD);return{item:i,diff:r}},dD=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},fD=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new hD(Sw(r,i+n),t,Sw(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=Sw(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},pD=(e,t)=>Cy(e,e=>NC(e.deletions,t)),mD=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return Kw(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||mD(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=Kw(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:Kw(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:Kw(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||NC(r,d.right.id)||pD(a.undoStack,d.right.id)||pD(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Kw(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;let m=Sw(c,Vw(s,c)),h=new hD(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,dD(h,!0),h.integrate(e,0),h},hD=class e extends NE{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>=Vw(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Vw(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===bw&&this.id.client!==this.parent.client&&this.parent.clock>=Vw(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=qw(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=Kw(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===FE||this.right&&this.right.constructor===FE)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===bw){let e=Ww(n,this.parent);e.constructor===FE?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=qw(e,e.doc.store,Sw(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),xw(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(xw(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Ww(e.doc.store,n.origin)))r.has(Ww(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),Hw(e.doc.store,this),this.content.integrate(e,this),Qw(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new FE(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:Sw(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&xw(e.origin,this.lastId)&&this.right===e&&xw(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(),IC(e.deleteSet,this.id.client,this.id.clock,this.length),Qw(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw Fb();this.content.gc(e),t?Jw(e,this,new FE(this.id,this.length)):this.content=new RE(this.length)}write(e,t){let n=t>0?Sw(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=Cw(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===bw?(e.writeParentInfo(!1),e.writeLeftID(t)):Fb();i!==null&&e.writeString(i)}this.content.write(e,t)}},gD=(e,t)=>_D[t&31](e),_D=[()=>{Fb()},zE,JE,LE,$E,WE,KE,lD,ZE,HE,()=>{Fb()}],vD=10,yD=class extends NE{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){Fb()}write(e,t){e.writeInfo(vD),pb(e.restEncoder,this.length-t)}getMissing(e,t){return null}},bD=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},xD=`__ $YJS$ __`;bD[xD]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),bD[xD]=!0;var SD={anthropic:`Claude`,openai:`GPT`,gemini:`Gemini`,"local-ollama":`Local model`,"local-llamacpp":`Local model`},CD=`Assistant`;function wD(e){return(e.defaultModelId?e.models.find(t=>t.id===e.defaultModelId):void 0)||(e.models.length===1?e.models[0]:void 0)}function TD(e,t){let n=wD(e);if(!n)return CD;let r=SD[n.provider]||`Assistant`;return t===`family`?r:n.displayName||n.modelId||r}function ED(e){let t=M(()=>TD(e.settings,`family`)),n=M(()=>TD(e.settings,`model`));return{get family(){return B(t)},get specific(){return B(n)}}}function DD(e){return e?e+1:0}function OD(e){let t=0;return e.forEach(e=>{e.isText?t+=e.text.length:e.type.name===`hardBreak`&&(t+=1)}),t}function kD(e){if(e.isTextblock)return OD(e);let t=0;for(let n=0;n<e.childCount;n++)n>0&&(t+=1),t+=kD(e.child(n));return t}function AD(e,t,n){if(e.isTextblock)return Eo(n+Math.min(t,OD(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=kD(a);if(r+s>t)return AD(a,t-r,o);r+=s,i+=a.nodeSize}return Eo(n+e.content.size)}function jD(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`?DD(o.attrs.level||1):0,l=c+kD(o);if(n+l>t){let e=t-n;return AD(o,Math.max(0,e-c),s)}if(n+=l,r+=o.nodeSize,a<i-1&&(n+=1,n>t))return Eo(s+o.content.size)}return Eo(e.content.size)}function MD(e,t,n){if(e.isTextblock)return Math.min(t-n,OD(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+MD(a,t,o);r+=kD(a),i+=a.nodeSize}return r}function ND(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`?DD(o.attrs.level||1):0,l=kD(o);if(t<r+o.nodeSize)return To(t<=s?n+c:n+c+MD(o,t,s));n+=c+l,r+=o.nodeSize,a<i-1&&(n+=1)}return To(n)}function PD(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 jE){if(o===r.type)return Eo(n+Math.min(i+r.index,OD(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 EE){let e=PD(a,o,s,r);if(e!==null)return e}i+=o.nodeSize}return null}function FD(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 EE){let e=PD(i,o,s,n);if(e!==null)return e}r+=o.nodeSize}return null}function ID(e,t,n){let r,i;try{let t=Ew(n.fromRel),a=Ew(n.toRel);r=Mw(t,e),i=Mw(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=FD(t,a,r),s=FD(t,a,i);return o===null||s===null?null:{from:o,to:s}}function LD(e,t,n){if(e.relRange&&n){let r=ID(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:jD(t,e.range.from),to:jD(t,e.range.to),method:`flat`}:null}function RD(e,t){return{from:ND(e,t.from),to:ND(e,t.to)}}function zD(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function BD(e){let t=zD(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 VD=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>`),HD=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>`),UD=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>`),WD=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>`),GD=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>`),KD=H(`<div class="chat-markdown svelte-15oag3v"></div>`),qD=H(`<div style="white-space: pre-wrap; word-break: break-word;"> </div>`),JD=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>`),YD=H(`<span></span>`),XD=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>`),ZD=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>`),QD=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 $D(e,t){A(t,!0);let n=[0,.2,.4],r=ED(Dv()),i=J(t,`inputEl`,15,null),a=M(()=>t.reduceMotion?`auto`:`smooth`),o=N(un([])),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(Ka),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=jr(()=>B(a));if(!e&&u){u=!1;return}u=e,B(c)?.scrollIntoView({behavior:n})}),R(()=>{let e=t.visible,n=jr(()=>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(Ka),n={id:mc(),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=jD(t.editor.state.doc,e.from),r=jD(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:${wa}${Lc}`,{method:`DELETE`})}catch(e){console.warn(`[ChatPanel] Failed to clear chat:`,e)}}var _=QD(),v=F(_),y=L(F(v)),b=F(y),x=e=>{var t=VD(),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=HD();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,UD())};G(ee,e=>{B(o).length===0&&e(T)});var E=L(ee,2);mi(E,17,()=>B(o),e=>e.id,(e,t)=>{var n=JD(),i=F(n),a=F(i),o=F(a,!0);O(a);var s=L(a,2),c=e=>{var n=WD(),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=GD(),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=KD();bi(n,()=>BD(B(t).text),!0),O(n),U(e,n)},_=e=>{var n=qD(),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),D=e=>{var r=XD(),i=F(r);mi(i,20,()=>n,e=>e,(e,t)=>{var n=YD();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(D)}),pa(L(te,2),e=>P(c,e),()=>B(c)),O(w),Fi(w,(e,t)=>Gu?.(e,t),()=>`y`);var ne=L(w,2),re=e=>{var n=ZD(),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(ne,e=>{t.capturedAnchor&&e(re)});var ie=L(ne,2),ae=F(ie);En(ae),q(ae,`rows`,1),pa(ae,e=>P(l,e),()=>B(l));var oe=L(ae,2);O(ie),O(_),z(e=>{ta(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()}Vr([`click`,`input`,`keydown`]);var eO=H(`<button type="button" data-testid="apply-changes-btn"> </button>`);function tO(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(`${Bl}${Oc}`,{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=Zr(),c=I(s),l=e=>{var t=eO();let i;var s=F(t,!0);O(t),z(()=>{i=Wi(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()}Vr([`click`]);function nO(e,t){return e.id<t.id?-1:+(e.id>t.id)}function rO(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?nO(e,t):n<r?-1:1})}function iO(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?nO(e,t):n})}function aO(e,t){return t===`chronological`?iO(e):rO(e)}function oO(e,t){if(!t)return-1;for(let n=0;n<e.length;n++)if(e[n].id===t)return n;return-1}function sO(e,t){if(e.length===0)return null;let n=oO(e,t);return n===-1?e[0].id:e[(n+1)%e.length].id}function cO(e,t){if(e.length===0)return null;let n=oO(e,t);return n===-1?e[e.length-1].id:e[(n-1+e.length)%e.length].id}var lO={background:`var(--tandem-warning-bg)`,border:`var(--tandem-warning-border)`,color:`var(--tandem-warning-fg-strong)`};function uO(e,t=`pointer`){return`cursor: ${e?`not-allowed`:t}; opacity: ${e?.5:1};`}function dO(e,t){return e.type===`highlight`?[]:t??[]}var fO=H(`<button class="aca-btn aca-btn--accept svelte-1u9ox5p">Accept</button>`),pO=H(`<button class="aca-btn aca-btn--reject svelte-1u9ox5p">Reject</button>`),mO=H(`<div class="aca-row svelte-1u9ox5p"><!> <!></div>`),hO=H(`<button class="aca-btn aca-btn--ghost svelte-1u9ox5p">Archive</button>`),gO=H(`<button class="aca-btn aca-btn--send svelte-1u9ox5p"> </button>`),_O=H(`<div class="aca-row svelte-1u9ox5p"><!> <!></div>`),vO=H(`<button class="aca-btn aca-btn--ghost aca-standalone svelte-1u9ox5p">Remove</button>`),yO=H(`<div class="aca-undo-error svelte-1u9ox5p">Can't undo — text has changed.</div>`),bO=H(`<div class="aca-undo-row svelte-1u9ox5p"><button data-testid="undo-btn" class="aca-undo svelte-1u9ox5p">Undo</button> <!></div>`);function xO(e,t){A(t,!0);let n=ED(Dv()),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))}xa(a);var s=Zr(),c=I(s),l=e=>{var n=mO(),r=F(n),i=e=>{var n=fO();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=pO();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=_O(),i=F(r),a=e=>{var n=hO();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=gO(),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=vO();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=bO(),n=F(t),i=L(n,2),a=e=>{U(e,yO())};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()}Vr([`click`]);var SO=`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);`,CO=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),wO=H(`<textarea></textarea>`),TO=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 EO(e,t){A(t,!0);let n=N(null);R(()=>{B(n)?.focus()});var r=TO(),i=F(r),a=e=>{var r=CO(),i=I(r),a=L(i,2);En(a),pa(a,e=>P(n,e),()=>B(n));var o=L(a,2),s=L(o,2);En(s),z(()=>{q(i,`for`,`edit-newtext-${t.annotationId??``}`),q(a,`id`,`edit-newtext-${t.annotationId??``}`),q(a,`data-testid`,`edit-newtext-${t.annotationId??``}`),ta(a,t.editNewText),K(a,SO),q(o,`for`,`edit-reason-${t.annotationId??``}`),q(s,`id`,`edit-reason-${t.annotationId??``}`),q(s,`data-testid`,`edit-reason-${t.annotationId??``}`),ta(s,t.editReason),K(s,SO)}),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=wO();En(r),pa(r,e=>P(n,e),()=>B(n)),z(()=>{q(r,`data-testid`,`edit-text-${t.annotationId??``}`),ta(r,t.editText),K(r,SO)}),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()}Vr([`click`,`keydown`,`input`]);function DO(e,t){return e===`claude`?t??`Assistant`:e===`import`?`Imported`:`You`}function OO(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 kO(e){return e.suggestedText===void 0?e.type:`replacement`}function AO(e,t){return e?e.length>t?e.slice(0,t-3)+`...`:e:``}function jO(e){let t=kO(e),n=AO(e.content,60);return`${e.type===`note`?`private `:``}${t} annotation${n?`: `+n:``}, ${e.status}`}function MO(e){return e.type===`highlight`&&e.color?Ma[Na(e.color)]:`var(--tandem-author-user)`}var NO=H(`<span> </span>`),PO=H(`<button class="ach-edit-btn svelte-d1dbnh" title="Edit this annotation's content">✎ Edit</button>`),FO=H(`<span class="ach-edited svelte-d1dbnh">(edited)</span>`),IO=H(`<span class="ach-dot svelte-d1dbnh" aria-hidden="true"></span>`),LO=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 RO(e,t){A(t,!0);let n=ED(Dv()),r=M(()=>kO(t.annotation)),i=M(()=>DO(t.annotation.author,n.family)),a=M(()=>t.annotation.author===`claude`?`var(--tandem-author-claude)`:`var(--tandem-author-user)`);var o=LO(),s=F(o),c=F(s),l=F(c,!0);O(c);var u=L(c,2),d=e=>{var n=Zr();xi(I(n),()=>t.extraPill),U(e,n)};G(u,e=>{t.extraPill&&e(d)});var f=L(u,2),p=e=>{var n=NO();let r;var i=F(n,!0);O(n),z(()=>{r=Wi(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=PO();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,FO())};G(_,e=>{t.annotation.editedAt&&e(v)});var y=L(_,2),b=e=>{var t=IO();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(),()=>OO(t.annotation.timestamp)]),U(e,o),j()}Vr([`click`]);var zO=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 BO(e,t){A(t,!0);let n=M(()=>t.text?t.text.length>80?t.text.slice(0,77)+`...`:t.text:``);var r=Zr(),i=I(r),a=e=>{var r=zO(),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 VO=H(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>`),HO=H(`<!> <!> <!>`,1);function UO(e,t){A(t,!0);var n=HO(),r=I(n);RO(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);BO(i,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var a=L(i,2),o=e=>{var n=VO(),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 WO=H(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>`),GO=H(`<!> <!> <!>`,1);function KO(e,t){A(t,!0);var n=GO(),r=I(n);RO(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);BO(i,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var a=L(i,2),o=e=>{var n=WO(),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 qO=H(`<input type="checkbox" style="margin-top: 4px; flex-shrink: 0; cursor: pointer;"/>`),JO=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>`),YO=H(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>`),XO=H(`<div style="display: flex; align-items: flex-start; gap: var(--tandem-space-2);"><!> <div style="flex: 1; min-width: 0;"><!> <!> <!> <!></div></div>`);function ZO(e,t){A(t,!0);let n=J(t,`selected`,3,!1);var r=XO(),i=F(r),a=e=>{var r=qO();ea(r),z(()=>{q(r,`data-testid`,`annotation-select-checkbox-${t.annotation.id??``}`),na(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);RO(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=JO(),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);BO(u,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var d=L(u,2),f=e=>{var n=YO(),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()}Vr([`click`,`change`]);var QO=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>`),$O=H(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>`),ek=H(`<!> <!> <!>`,1);function tk(e,t){A(t,!0);var n=ek(),r=I(n);RO(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,QO())},$$slots:{extraPill:!0}});var i=L(r,2);BO(i,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var a=L(i,2),o=e=>{var n=$O(),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 nk=H(`<span class="ct-author-dot ct-author-dot--claude svelte-4l0b78" aria-hidden="true"></span> `,1),rk=H(`<span> </span>`),ik=H(`<span class="ct-author-dot ct-author-dot--user svelte-4l0b78" aria-hidden="true"></span> You`,1),ak=H(`<span class="ct-edited svelte-4l0b78">(edited)</span>`),ok=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>`),sk=H(`<div class="ct-root svelte-4l0b78" data-testid="comment-thread"></div>`);function ck(e,t){A(t,!0);let n=ED(Dv());var r=Zr(),i=I(r),a=e=>{var r=sk();mi(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=ok(),a=F(i),o=F(a);let s;var c=F(o),l=e=>{var t=nk(),r=L(I(t));z(()=>W(r,` ${n.family??``}`)),U(e,t)},u=e=>{var n=rk(),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=ik();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,ak())};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=Wi(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)},[()=>OO(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 lk=H(`<div class="art-replies svelte-155xn9n"><!></div>`),uk=H(`<button type="button"><span class="art-arrow svelte-155xn9n" aria-hidden="true">›</span> </button> <!>`,1),dk=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>`),fk=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>`),pk=H(`<div style="margin-top: 6px;"><!></div>`),mk=H(`<div class="art-root svelte-155xn9n"><!> <!></div>`);function hk(e,t){A(t,!0);let n=J(t,`reduceMotion`,3,!1),r=J(t,`openNonce`,3,0),i=M(()=>dO(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=jr(()=>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=mk(),g=F(h),_=e=>{var t=uk(),r=I(t);let s;var c=L(F(r));O(r);var l=L(r,2),u=e=>{var t=lk();ck(F(t),{get replies(){return B(i)}}),O(t),Ni(3,t,()=>Zv,()=>({reduceMotion:n()})),U(e,t)};G(l,e=>{B(o)&&e(u)}),z(()=>{q(r,`data-testid`,`reply-toggle-${B(a)??``}`),s=Wi(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=pk(),n=F(t),r=e=>{var t=dk(),n=F(t);En(n),pa(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)??``}`),ta(n,B(c)),K(n,SO),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=fk();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()}Vr([`click`,`keydown`,`input`]);function gk(e){return e.split(/(\s+)/).filter(Boolean)}var _k=4e4,vk=6e3;function yk(e,t){if(e.length+t.length>vk)return null;let n=gk(e),r=gk(t);if(n.length*r.length>_k)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 bk=H(`<span> </span>`),xk=H(`<span style="text-decoration: line-through; color: var(--tandem-error); background-color: var(--tandem-error-bg); border-radius: var(--tandem-r-1);"> </span>`),Sk=H(`<span style="color: var(--tandem-success-fg-strong); background-color: var(--tandem-success-bg); border-radius: var(--tandem-r-1);"> </span>`),Ck=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),wk=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),Tk=H(`<p style="margin: 0; font-size: 12px; color: var(--tandem-fg-muted);"> </p>`),Ek=H(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><div><!></div> <!></div>`),Dk=H(`<!> <!> <!>`,1);function Ok(e,t){A(t,!0);let n=M(()=>t.annotation.textSnapshot?yk(t.annotation.textSnapshot,t.annotation.suggestedText):null);var r=Dk(),i=I(r);RO(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);BO(a,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var o=L(a,2),s=e=>{var r=Ek(),i=F(r),a=F(i),o=e=>{var t=Zr();mi(I(t),17,()=>B(n),ui,(e,t)=>{var n=Zr(),r=I(n),i=e=>{var n=bk(),r=F(n,!0);O(n),z(()=>W(r,B(t).text)),U(e,n)},a=e=>{var n=xk(),r=F(n,!0);O(n),z(()=>W(r,B(t).text)),U(e,n)},o=e=>{var n=Sk(),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=wk(),r=I(n),i=e=>{var n=Ck(),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=Tk(),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 kk=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>`),Ak=H(`<div role="listitem"><!> <!> <!> <!> <!></div>`);function jk(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=ED(Dv()),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(()=>jO(t.annotation)),v=M(()=>dO(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, ${MO(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())}var D=Ak();let ne;var re=M(()=>Sh(()=>t.onClick?.(),{selfOnly:!0})),ie=F(D),ae=e=>{var n=kk();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=>{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,get selected(){return i()},get onToggleSelect(){return t.onToggleSelect}})},ce=e=>{KO(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=>{tk(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=>{Ok(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=>{UO(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=>{EO(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);xO(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}}),hk(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(()=>{ne=Wi(D,1,`tandem-annotation-card svelte-3ascys`,null,ne,{"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,function(...e){B(re)?.apply(this,e)}),Ni(1,D,()=>Iv,()=>({enabled:o(),reduceMotion:s()})),Ni(2,D,()=>Lv,()=>({enabled:o(),reduceMotion:s(),id:t.annotation.id,modes:t.exitModes})),U(e,D),j()}Vr([`click`,`keydown`]);var Mk=`browser`;function Nk(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 Pk(e,t){return Nk(e,t,Mk)}function Fk(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 Ik=e=>{console.warn(`[sanitize]`,e)};function Lk(e,t,n){if(!e)return;let r=e.getMap(Va),i=r.get(t);if(!i)return;let a=Fk(i,Ik);Pk(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 Rk(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 zk(e,t){if(!e)return;let n=e.getMap(Va),r=n.get(t);if(!r)return;let i=Fk(r,Ik);i.type===`note`&&Pk(e,()=>{n.set(t,Rk(i))})}function Bk(e,t){if(!e||t.length===0)return 0;let n=e.getMap(Va),r=0;return Pk(e,()=>{for(let e of t){let t=n.get(e);if(!t)continue;let i=Fk(t,Ik);i.type===`note`&&(n.set(e,Rk(i)),r++)}}),r}async function Vk(e,t){try{let n=await fetch(`${Bl}${Fc}`,{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 Hk(e,t,n){try{let r=await fetch(`${Bl}${Pc}`,{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 Uk=new Set([`ctx:annotation:accept`,`ctx:annotation:dismiss`,`ctx:annotation:reply`,`ctx:annotation:edit`,`ctx:annotation:sendToClaude`,`ctx:annotation:copy`,`ctx:annotation:remove`]);function Wk(e){return typeof e==`string`&&Uk.has(e)}var Gk=e=>e.status===`pending`,Kk=e=>e.author!==`user`&&Gk(e),qk=e=>e.author!==`user`&&Gk(e),Jk=e=>(e.type===`note`||e.type===`comment`)&&Gk(e),Yk=e=>e.author===`user`&&Gk(e),Xk=e=>e.author===`user`&&e.type===`note`&&Gk(e),Zk=e=>e.author===`user`&&Gk(e),Qk=e=>!0;function $k(e){return{canAccept:Kk(e),canDismiss:qk(e),canReply:Jk(e),canEdit:Yk(e),canSendToClaude:Xk(e),canCopy:Qk(e),canRemove:Zk(e),isNote:e.type===`note`}}function eA(e){return e.content?.trim()?e.content:e.textSnapshot??``}var tA=null;function nA(e){tA=e}function rA(e,t,n){switch(e){case`ctx:annotation:accept`:Kk(t)&&n.accept?.(t.id);return;case`ctx:annotation:dismiss`:qk(t)&&n.dismiss?.(t.id);return;case`ctx:annotation:sendToClaude`:Xk(t)&&n.sendToClaude?.(t.id);return;case`ctx:annotation:remove`:Zk(t)&&n.remove?.(t.id);return;case`ctx:annotation:edit`:Yk(t)&&n.openEdit?.(t.id);return;case`ctx:annotation:reply`:Jk(t)&&n.openReply?.(t.id);return;case`ctx:annotation:copy`:if(Qk(t)){let e=eA(t);e&&navigator.clipboard.writeText(e).catch(()=>{})}return}}async function iA(e,t){nA({run:t});try{await(await uh())(`show_annotation_context_menu`,{req:$k(e)})}catch{}}var aA=0,oA=null;function sA(){if(!sh())return()=>{};aA++,aA===1&&(oA=ql(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;Wk(t)&&tA?.run(t)})),oA.catch(()=>{}));let e=!1;return()=>{if(!e&&(e=!0,aA--,aA===0)){let e=oA;oA=null,e?.then(e=>e()).catch(()=>{})}}}var cA=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 lA(e,t){A(t,!0);let n=J(t,`reduceMotion`,3,!1),r=ED(Dv());var i=Zr(),a=I(i),o=e=>{var i=cA(),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)}),Ni(1,i,()=>Rv,()=>({reduceMotion:n()})),Ni(2,i,()=>zv,()=>({reduceMotion:n(),exitMs:200})),U(e,i)};G(a,e=>{t.selectedCount>0&&e(o)}),U(e,i),j()}Vr([`click`]);var uA=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),dA=H(`<button data-testid="bulk-accept-btn"> </button> <button data-testid="bulk-dismiss-btn">Reject All</button>`,1),fA=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 pA(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=Zr(),s=I(o),c=e=>{var o=fA(),s=F(o),c=e=>{var r=uA(),o=I(r),s=F(o);O(o);var c=L(o,2);pa(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=dA(),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),Ni(1,o,()=>Rv,()=>({reduceMotion:r()})),Ni(2,o,()=>zv,()=>({reduceMotion:r(),exitMs:180})),U(e,o)};G(s,e=>{t.pendingCount>1&&e(c)}),U(e,o),j()}Vr([`click`]);function mA(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 hA=(e,t=m)=>{var n=Zr(),r=I(n),i=e=>{U(e,gA())},a=e=>{U(e,_A())},o=e=>{U(e,vA())},s=e=>{U(e,yA())},c=e=>{U(e,bA())},l=e=>{U(e,xA())},u=e=>{U(e,SA())};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)},gA=Yr(`<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>`),_A=Yr(`<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>`),vA=Yr(`<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>`),yA=Yr(`<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>`),bA=Yr(`<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>`),xA=Yr(`<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>`),SA=Yr(`<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>`),CA=H(`<span class="chip-text"> </span>`),wA=H(`<span></span>`),TA=H(`<button type="button" role="radio"><!></button>`),EA=H(`<div class="chip-bar svelte-v4eg2o" role="radiogroup" tabindex="-1"><span aria-hidden="true"></span> <!></div>`);function DA(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=mA(()=>n(),jr(()=>r().map(e=>e.value)),e=>i()(e)),c=N(null),l=N(un({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 Or().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=EA(),f=F(d);let p;mi(L(f,2),17,r,e=>e.value,(e,t)=>{let r=M(()=>B(t).value===n());var a=TA();let c;var l=F(a),u=e=>{var n=CA(),r=F(n,!0);O(n),z(()=>W(r,B(t).label)),U(e,n)},d=e=>{var n=wA();z(()=>Wi(n,1,`pip pip-${B(t).pip??``}`,`svelte-v4eg2o`)),U(e,n)},f=e=>{hA(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=Wi(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),pa(d,e=>P(c,e),()=>B(c)),z(()=>{q(d,`aria-label`,a()),q(d,`data-testid`,o()),p=Wi(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()}Vr([`keydown`,`click`]);var OA=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>`),kA=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 AA(e,t){A(t,!0);let n=ED(Dv()),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=Zr(),s=I(o),c=e=>{var n=kA(),o=F(n);DA(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);DA(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);DA(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=OA();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()}Vr([`click`]);var jA=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>`),MA=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>`),NA=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>`),PA=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>`),FA=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>`),IA=H(`<div style="padding: var(--tandem-space-3); flex: 1;" role="list" aria-label="Annotations" class="svelte-l26r3u"><!> <!></div>`),LA=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 RA(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(un(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(un(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(`${Bl}${Ic}`,{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(un(new Map));R(()=>{if(!t.ydoc){P(C,new Map,!0);return}let e=t.ydoc.getMap(Ja);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:aO(e.filter(e=>e.status===`pending`),B(d)),reviewPending:e.filter(dc),resolved:aO(e.filter(e=>e.status!==`pending`),B(d)),allPending:n,reviewAllPending:t.annotations.filter(dc)}}),ee=ED(Dv()),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}jr(()=>{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 D=(e,n)=>Lk(t.ydoc,e,n),ne=e=>zk(t.ydoc,e),re=e=>Vk(e,t.documentId),ie=(e,n)=>Hk(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&&rA(t,n,{accept:oe,dismiss:se,sendToClaude:ne,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(!sh())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 iA(n,fe(t)))}R(()=>{let e=B(ce);if(e)return e.addEventListener(`contextmenu`,pe),()=>e.removeEventListener(`contextmenu`,pe)}),R(()=>sA());function me(e){for(let n of B(w).reviewPending)t.review.resolveAnnotation(n.id,e);P(b,null)}let he=N(un(new Set));R(()=>{let e=new Set(B(w).pending.filter(e=>e.author===`import`&&e.type===`note`).map(e=>e.id));jr(()=>{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));Bk(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=LA(),xe=F(be),Se=e=>{var t=MA(),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=jA(),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: ${lO.background??``}; border: 1px solid ${lO.border??``}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${lO.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 ${lO.border??``}; border-radius: var(--tandem-r-2); background: none; color: ${lO.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: ${lO.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=NA(),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);AA(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);tO(F(Re),{get annotations(){return t.annotations},get activeDocFormat(){return t.activeDocFormat},get documentId(){return t.documentId}}),O(Re);var ze=L(Re,2);lA(ze,{get selectedCount(){return B(he).size},onPromote:_e,onClear:ve,get reduceMotion(){return t.reduceMotion}});var Be=L(ze,2);pA(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=PA(),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=IA(),i=F(n);mi(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(()=>Kk(B(n))?oe:void 0),c=M(()=>qk(B(n))?se:void 0),l=M(()=>Zk(B(n))?re:void 0),u=M(()=>Xk(B(n))?ne:void 0),d=M(()=>Yk(B(n))?D:void 0),f=M(()=>Jk(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);jk(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=FA(),r=F(n),i=F(r);O(r);var a=L(r,2);mi(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));jk(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),pa(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),pa(be,e=>P(x,e),()=>B(x)),Fi(be,(e,t)=>Gu?.(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()}Vr([`click`]);var zA=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>`),BA=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>`),VA=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>`),HA=H(`<ul style="list-style: none; margin: 0; padding: 0;"></ul>`),UA=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 WA(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(un([])),c=N(-1),l=N(un([])),u=N(``),d=N(null),f=N(-1);R(()=>{let e=t.editor;if(!e||e.isDestroyed){P(s,[],!0);return}P(s,jm(e),!0),jr(()=>{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,jm(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(jD(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=Jp.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=UA(),y=L(F(v),2),b=F(y),x=L(F(b),2);ea(x),pa(x,e=>P(d,e),()=>B(d)),O(b),O(y);var S=L(y,2),C=F(S),w=e=>{U(e,zA())},ee=e=>{var t=HA();mi(t,21,()=>B(s),ui,(e,t,n)=>{let r=M(()=>B(f)===n),i=M(()=>B(h)[n]??0);var a=VA(),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=BA(),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),pa(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)),Br(`focus`,o,()=>P(c,n,!0)),Br(`mouseenter`,o,e=>{B(r)||(e.currentTarget.style.background=`var(--tandem-surface-hover, var(--tandem-surface-muted))`)}),Br(`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),Fi(S,(e,t)=>Gu?.(e,t),()=>`y`),O(v),V(`keydown`,v,_),V(`input`,x,p),V(`keydown`,x,m),oa(x,()=>B(u),e=>P(u,e)),U(e,v),j()}Vr([`keydown`,`input`,`click`]);var GA=H(`<div><!></div>`);function KA(e,t){A(t,!0);let n=_a(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=Zr(),a=I(i),o=e=>{var i=GA(),a=F(i),o=e=>{$D(e,ya(()=>n,{get visible(){return t.visible}}))},s=e=>{WA(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=>{RA(e,ya(()=>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=>{$D(e,ya(()=>n))},c=e=>{WA(e,{get editor(){return t.editor},get annotations(){return t.annotations},get focusTrigger(){return t.focusTrigger},get activeFilterType(){return t.activeFilterType}})},l=e=>{RA(e,ya(()=>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 qA=H(`<span style="color: var(--tandem-error-fg-strong); font-size: var(--tandem-text-xs); max-width: 200px;"> </span>`),JA=H(`<button type="button" class="tandem-banner__cta" data-testid="convert-to-markdown-btn"> </button>`),YA=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 XA(e,t){A(t,!0);let n=`tandem:reviewOnlyBannerDismissed`;function r(){try{return localStorage.getItem(n)===`true`}catch{return!1}}let i=N(un(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(`${Bl}${Dc}`,{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=Zr(),u=I(l),d=e=>{var n=YA(),r=L(F(n),2),i=e=>{var t=qA(),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=JA(),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()}Vr([`click`]);var ZA=null;async function QA(e){if(ZA!==null)return ZA;let t=await fetch(`${Bl}${vc}`,{signal:e});if(!t.ok)throw Error(`${vc} responded ${t.status} ${t.statusText}`);let n=await t.json();return ZA=n,n}function $A(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),QA(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 ej=H(`<div data-testid="settings-readonly-banner" role="note">Settings are read-only — they were saved by a newer version of Tandem. Changes are disabled to
109
+ protect them.</div>`);function tj(e,t){A(t,!1),ma();var n=ej();z(()=>K(n,`flex-shrink: 0; padding: var(--tandem-space-2) var(--tandem-space-5); font-size: var(--tandem-text-xs); line-height: 1.4; background: ${lO.background??``}; border-bottom: 1px solid ${lO.border??``}; color: ${lO.color??``};`)),U(e,n),j()}var nj=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"/> <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"/> <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 rj(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=nj(),i=I(r),a=F(i);K(a,n);var o=L(a,2),s=F(o);ea(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);ea(d),k(2),O(u),k(2),O(c),z((e,n)=>{na(s,t.settings.highContrast),s.disabled=t.readOnly,K(s,`accent-color: var(--tandem-accent); ${e??``}`),na(d,t.settings.annotationPatterns),d.disabled=t.readOnly,K(d,`accent-color: var(--tandem-accent); ${n??``}`)},[()=>uO(t.readOnly),()=>uO(t.readOnly)]),V(`change`,s,e=>t.onUpdate({highContrast:e.target.checked})),V(`change`,d,e=>t.onUpdate({annotationPatterns:e.target.checked})),U(e,r),j()}Vr([`change`]);var ij=H(`<button role="radio"> </button>`),aj=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"/> <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
110
+ neutral Light. A dark OS appearance still resolves to Dark.</div>`,1),oj=H(`<button role="radio"> </button>`),sj=H(`<button role="radio"> </button>`),cj=H(`<button role="radio"> </button>`),lj=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>`),uj=H(`<button role="radio"> </button>`),dj=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"/> <span> </span></label>`),fj=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"/></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
111
+ 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"/> <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"/> <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
112
+ 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"/> <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.
113
+ When hidden they stay in the file and always save — only the on-screen markers are
114
+ 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"/> <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
115
+ resizing it; click its edge to pin it open. When off, rails reveal only on click.</div></div>`,1);function pj(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)`};`,uO(t??!1),`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};`,`transition: border-color 0.15s, background 0.15s;`].join(` `)}let d=mA(()=>t.settings.theme,[`light`,`warm`,`dark`,`system`],e=>t.onUpdate({theme:e})),f=mA(()=>t.settings.primaryTab,[`chat`,`annotations`],e=>t.onUpdate({primaryTab:e})),p=mA(()=>t.settings.textSize,[`s`,`m`,`l`],e=>t.onUpdate({textSize:e})),m=mA(()=>t.settings.editorFont,[`sans`,`serif`,`mono`],e=>t.onUpdate({editorFont:e})),h=mA(()=>t.settings.density,[`compact`,`cozy`,`spacious`],e=>t.onUpdate({density:e})),g={};for(let e of n)g[e.format]=mA(()=>i(e.format),[`sans`,`serif`,`mono`],t=>a(e.format,t));var _=fj(),v=I(_),b=F(v);K(b,c);var x=L(b,2);mi(x,20,()=>[`light`,`warm`,`dark`,`system`],e=>e,(e,n)=>{var r=ij(),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),r.disabled=t.readOnly,K(r,a),W(i,n===`light`?`Light`:n===`warm`?`Warm`:n===`dark`?`Dark`:`System`)},[()=>d.tabIndexFor(n),()=>u(t.settings.theme===n,t.readOnly)]),V(`click`,r,()=>t.onUpdate({theme:n})),U(e,r)}),O(x);var S=L(x,2),C=e=>{var n=aj(),r=I(n),i=F(r);ea(i),k(2),O(r),k(2),z(e=>{na(i,t.settings.systemLightVariant===`warm`),i.disabled=t.readOnly,K(i,`accent-color: var(--tandem-accent); ${e??``}`)},[()=>uO(t.readOnly)]),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(v);var w=L(v,2),ee=F(w);K(ee,c);var T=L(ee,2),E=F(T),te=L(E,2);O(T),O(w);var D=L(w,2),ne=F(D);K(ne,c);var re=L(ne,2);mi(re,20,()=>[`s`,`m`,`l`],e=>e,(e,n)=>{var r=oj(),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),r.disabled=t.readOnly,K(r,a),W(i,n===`s`?`Small`:n===`m`?`Medium`:`Large`)},[()=>p.tabIndexFor(n),()=>u(t.settings.textSize===n,t.readOnly)]),V(`click`,r,()=>t.onUpdate({textSize:n})),U(e,r)}),O(re),k(2),O(D);var ie=L(D,2),ae=F(ie);K(ae,c);var oe=L(ae,2),se=L(F(oe),2);ea(se),O(oe),O(ie);var ce=L(ie,2),le=F(ce);K(le,c);var ue=L(le,2);mi(ue,20,()=>[[`sans`,`Sans-serif`],[`serif`,`Serif (Source Serif 4)`],[`mono`,`Monospace`]],([e,t])=>e,(e,n)=>{var r=M(()=>y(n,2));let i=()=>B(r)[0],a=()=>B(r)[1];var o=sj(),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),o.disabled=t.readOnly,K(o,n),W(s,a())},[()=>m.tabIndexFor(i()),()=>u(t.settings.editorFont===i(),t.readOnly)]),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);mi(he,21,()=>n,e=>e.format,(e,n)=>{var o=lj(),s=F(o),c=F(s,!0);O(s);var l=L(s,2);mi(l,21,()=>r,([e,t])=>e,(e,r)=>{var o=M(()=>y(B(r),2));let s=()=>B(o)[0],c=()=>B(o)[1];var l=cj(),d=F(l,!0);O(l),z((e,r,i)=>{q(l,`data-testid`,`font-by-extension-${B(n).format}-${s()}`),q(l,`aria-checked`,e),q(l,`tabindex`,r),l.disabled=t.readOnly,K(l,i),W(d,c())},[()=>i(B(n).format)===s(),()=>g[B(n).format].tabIndexFor(s()),()=>u(i(B(n).format)===s(),t.readOnly)]),V(`click`,l,()=>a(B(n).format,s())),U(e,l)}),O(l),O(o),z(()=>{q(o,`data-testid`,`font-by-extension-row-${B(n).format}`),W(c,B(n).label),q(l,`aria-label`,`Default font for ${B(n).label}`)}),V(`keydown`,l,function(...e){g[B(n).format].handleKeyDown?.apply(this,e)}),U(e,o)}),O(he),k(2),O(de);var ge=L(de,2),_e=F(ge);K(_e,c);var ve=L(_e,2);mi(ve,20,()=>[[`compact`,`Compact`],[`cozy`,`Cozy`],[`spacious`,`Spacious`]],([e,t])=>e,(e,n)=>{var r=M(()=>y(n,2));let i=()=>B(r)[0],a=()=>B(r)[1];var o=uj(),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),o.disabled=t.readOnly,K(o,n),W(s,a())},[()=>h.tabIndexFor(i()),()=>u(t.settings.density===i(),t.readOnly)]),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),mi(L(be,2),17,()=>l,([e,t,n])=>e,(e,n)=>{var r=M(()=>y(B(n),3));let i=()=>B(r)[0],a=()=>B(r)[1],o=()=>B(r)[2];var s=dj(),c=F(s);ea(c);var l=L(c,2),u=F(l,!0);O(l),O(s),z(e=>{q(s,`data-testid`,a()),na(c,t.settings[i()]),c.disabled=t.readOnly,K(c,`accent-color: var(--tandem-accent); ${e??``}`),W(u,o())},[()=>uO(t.readOnly)]),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);ea(Ce),k(2),O(Se),k(2),O(xe);var we=L(xe,2),Te=F(we),Ee=F(Te);ea(Ee),k(2),O(Te),k(2),O(we);var De=L(we,2),Oe=F(De),ke=F(Oe);ea(ke),k(2),O(Oe),k(2),O(De);var Ae=L(De,2),je=F(Ae),Me=F(je);ea(Me),k(2),O(je),k(2),O(Ae),z((e,n,r,i,a,o,c,l,u)=>{q(E,`aria-checked`,t.settings.primaryTab===`chat`),q(E,`tabindex`,e),E.disabled=t.readOnly,K(E,n),q(te,`aria-checked`,t.settings.primaryTab===`annotations`),q(te,`tabindex`,r),te.disabled=t.readOnly,K(te,i),ta(se,t.settings.accentHue),se.disabled=t.readOnly,K(se,`flex: 1; accent-color: var(--tandem-accent); ${a??``}`),me.disabled=t.readOnly||!B(s),K(me,`background: none; border: none; padding: 0; font-size: var(--tandem-text-2xs); color: ${!t.readOnly&&B(s)?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg-subtle)`}; cursor: ${!t.readOnly&&B(s)?`pointer`:`not-allowed`}; text-decoration: ${!t.readOnly&&B(s)?`underline`:`none`};`),na(Ce,t.settings.reduceMotion),Ce.disabled=t.readOnly,K(Ce,`accent-color: var(--tandem-accent); ${o??``}`),na(Ee,t.settings.formattingBarVisible),Ee.disabled=t.readOnly,K(Ee,`accent-color: var(--tandem-accent); ${c??``}`),na(ke,t.settings.showRawMarkdown),ke.disabled=t.readOnly,K(ke,`accent-color: var(--tandem-accent); ${l??``}`),na(Me,t.settings.railHoverReveal),Me.disabled=t.readOnly,K(Me,`accent-color: var(--tandem-accent); ${u??``}`)},[()=>f.tabIndexFor(`chat`),()=>u(t.settings.primaryTab===`chat`,t.readOnly),()=>f.tabIndexFor(`annotations`),()=>u(t.settings.primaryTab===`annotations`,t.readOnly),()=>uO(t.readOnly,`auto`),()=>uO(t.readOnly),()=>uO(t.readOnly),()=>uO(t.readOnly),()=>uO(t.readOnly)]),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()}Vr([`keydown`,`click`,`change`,`input`]);var mj=H(`<button type="button" role="radio"> </button>`),hj=H(`<button type="button" data-testid="settings-default-save-folder-pick">Choose…</button>`),gj=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
116
+ 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.
117
+ Leave empty to fall back to your AI's working directory, then your home
118
+ 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"/> <!> <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"/> <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"/> <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 _j(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=sh();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 ql(()=>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=mA(()=>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=gj(),d=F(u);K(d,n);var f=L(d,4);mi(f,21,()=>s,e=>e.value,(e,n)=>{let r=M(()=>t.settings.editorMeasure===B(n).value);var i=mj(),a=F(i,!0);O(i),z((e,o)=>{q(i,`aria-checked`,B(r)),q(i,`tabindex`,e),q(i,`data-testid`,`editor-measure-${B(n).value}`),i.disabled=t.readOnly,K(i,o),W(a,B(n).label)},[()=>c.tabIndexFor(B(n).value),()=>`flex: 1; padding: 6px 4px; border: none; border-radius: var(--tandem-r-1); ${uO(t.readOnly)} 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)`};`]),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(_);ea(v);var y=L(v,2),b=e=>{var n=hj();z(e=>{n.disabled=t.readOnly,K(n,`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); ${e??``}`)},[()=>uO(t.readOnly)]),V(`click`,n,o),U(e,n)};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);ea(w),k(2),O(C),k(2),O(S);var ee=L(S,2),T=F(ee),E=F(T);ea(E),k(2),O(T),k(2),O(ee),O(u),z((e,n,r,i)=>{W(m,B(l)),ta(v,t.settings.defaultSaveDirectory??``),v.disabled=t.readOnly,K(v,`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); ${e??``}`),x.disabled=t.readOnly||!t.settings.defaultSaveDirectory,K(x,n),na(w,t.settings.smartTypography),w.disabled=t.readOnly,K(w,`accent-color: var(--tandem-accent); ${r??``}`),na(E,t.settings.spellcheck),E.disabled=t.readOnly,K(E,`accent-color: var(--tandem-accent); ${i??``}`)},[()=>uO(t.readOnly,`auto`),()=>`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); ${uO(t.readOnly||!t.settings.defaultSaveDirectory)}`,()=>uO(t.readOnly),()=>uO(t.readOnly)]),V(`keydown`,f,function(...e){c.handleKeyDown?.apply(this,e)}),Br(`submit`,_,a),Br(`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()}Vr([`keydown`,`click`,`change`]);var vj=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 yj(e,t){let n=J(t,`defaultOpen`,3,!1);var r=vj(),i=F(r),a=L(F(i));O(i);var o=L(i,2);xi(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 bj=H(`<span style="color: var(--tandem-fg-subtle);"> </span>`),xj=H(`<button type="button" data-testid="network-restart-sidecar"> </button>`),Sj=H(`<span style="font-size: 10px; color: var(--tandem-fg-subtle);">Run <code>tandem stop &amp;&amp; tandem start</code> to restart</span>`),Cj=H(`<div style="font-size: 10px; color: var(--tandem-error-fg); margin-top: var(--tandem-space-1);"> </div>`),wj=H(`<span><strong>Host:</strong> </span>`),Tj=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>`),Ej=H(`<option> </option>`),Dj=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>`),Oj=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" 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" aria-label="Reconnect retry strategy"></select></div> <!>`,1),kj=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 Aj(e,t){A(t,!0);let n=$A(()=>t.open),r=sh(),i=N(null),a=N(!1);async function o(){if(r){P(a,!0),P(i,null);try{let{invoke:e}=await ql(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=kj(),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=bj(),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=xj(),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,Sj())};G(w,e=>{r?e(ee):e(T,-1)}),O(v);var E=L(v,2),te=e=>{var t=Cj(),n=F(t,!0);O(t),z(()=>W(n,B(i))),U(e,t)};G(E,e=>{B(i)&&e(te)}),O(g);var D=L(g,2),ne=F(D);K(ne,c);var re=L(ne,2),ie=F(re),ae=L(F(ie));O(ie);var oe=L(ie,2),se=e=>{var t=wj(),n=L(F(t));O(t),z(()=>W(n,` ${B(d)??``}`)),U(e,t)};G(oe,e=>{B(d)&&e(se)}),O(re),O(D),yj(L(D,2),{label:`Advanced`,testid:`network-advanced`,children:(e,n)=>{var r=Oj(),i=I(r),a=e=>{var t=Tj(),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);ea(g),k(2),O(o);var _=L(o,2),v=F(_);K(v,c);var y=L(v,2);mi(y,21,()=>s,e=>e.value,(e,t)=>{var n=Ej(),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;qi(y),O(_);var x=L(_,2),S=e=>{var t=Dj(),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((e,n)=>{W(h,`${t.settings.degradedBannerDelayMs/1e3}s`),ta(g,t.settings.degradedBannerDelayMs),g.disabled=t.readOnly,K(g,`width: 100%; accent-color: var(--tandem-accent); ${e??``}`),y.disabled=t.readOnly,K(y,`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); ${n??``}`),b!==(b=t.settings.sidecarRetryStrategy)&&(y.value=(y.__value=t.settings.sidecarRetryStrategy)??``,Ki(y,t.settings.sidecarRetryStrategy))},[()=>uO(t.readOnly,`auto`),()=>uO(t.readOnly)]),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()}Vr([`click`,`input`,`change`]);var jj=`INVALID_BODY`,Mj=`PATH_REJECTED`,Nj=`LAUNCHER_IN_PROGRESS`,Pj=`LAUNCHER_NOT_AVAILABLE`,Fj=`NO_CLAUDE_INTEGRATION`,Ij=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
119
+ 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>`),Lj=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>`),Rj=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>`),zj=H(`<div role="alert" style="font-size: 11px; color: var(--tandem-error-fg);"> </div>`),Bj=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>`),Vj=H(`<div data-testid="settings-modal-cowork-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>`),Hj=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
120
+ Claude Desktop) is the default integration — auto-configured, tested, and the only client whose
121
+ channel-push, cowork, and auto-launch extras are validated today. Other clients can connect
122
+ 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" 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"/> <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"/> <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 Uj(e,t){A(t,!0);function n(e){switch(e){case Mj:return`Working directory must be a folder inside your home directory.`;case jj:return`Working directory path is invalid.`;case Nj:return`Another working-directory update is in progress. Try again.`;case Fj:return`No Claude Code integration is configured.`;case Pj: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;xa(()=>{d=!1});async function f(){try{let e=await fetch(`${Bl}/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(`${Bl}${qc}`,{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 ql(()=>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 _=Hj(),v=I(_),y=e=>{var t=Ij(),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);ea(w),q(w,`step`,100);var ee=L(w,2),T=F(ee),E=F(T);O(T);var te=L(T,2),D=F(te);O(te),O(ee),O(b);var ne=L(b,2),re=F(ne);ea(re),k(2),O(ne);var ie=L(ne,2),ae=F(ie);ea(ae),k(2),O(ie);var oe=L(ie,4),se=e=>{var t=Lj(),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=Bj(),n=L(F(t),4),r=F(n);ea(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=Rj();z(()=>t.disabled=B(a)),V(`click`,t,m),U(e,t)},d=M(()=>sh());G(l,e=>{B(d)&&e(u)});var f=L(l,2);O(c);var p=L(c,2),_=e=>{var t=zj(),n=F(t,!0);O(t),z(()=>W(n,B(o))),U(e,t)};G(p,e=>{B(o)&&e(_)}),O(t),z(()=>{ta(r,B(i)??``),r.disabled=B(a),s.disabled=B(a),f.disabled=B(a)||B(i)===null}),Br(`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=Zr();si(I(t),()=>ql(()=>import(`./CoworkSettings-Brg8F0cb.js`),__vite__mapDeps([4,5])),e=>{U(e,Vj())},(e,t)=>{let n=M(()=>B(t).default);var r=Zr();Si(I(r),()=>B(n),(e,t)=>{t(e,{})}),U(e,r)}),U(e,t)},me=M(()=>sh());G(fe,e=>{B(me)&&e(pe)}),z((e,n,r,i,a,o)=>{W(C,`${e??``}s`),q(w,`min`,500),q(w,`max`,za),ta(w,t.settings.selectionDwellMs),w.disabled=t.readOnly,K(w,`width: 100%; accent-color: var(--tandem-accent); ${n??``}`),W(E,`${r??``}s`),W(D,`${i??``}s`),na(re,t.settings.selectionToolbar),re.disabled=t.readOnly,K(re,`accent-color: var(--tandem-accent); ${a??``}`),na(ae,t.settings.marginView),ae.disabled=t.readOnly,K(ae,`accent-color: var(--tandem-accent); ${o??``}`),W(de,B(u)?`Open integration wizard…`:`Reopen integration wizard…`)},[()=>(t.settings.selectionDwellMs/1e3).toFixed(1),()=>uO(t.readOnly,`auto`),()=>(500/1e3).toFixed(1),()=>(za/1e3).toFixed(1),()=>uO(t.readOnly),()=>uO(t.readOnly)]),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()}Vr([`click`,`input`,`change`]);function Wj(e){let t=e?.trim();return t?t.slice(0,40):`You`}function Gj(){try{return Wj(localStorage.getItem(co))}catch{return`You`}}function Kj(e){let t=Wj(e);try{localStorage.setItem(co,t)}catch{}return typeof window<`u`&&window.dispatchEvent(new Event(lo)),t}function qj(e){let t=()=>e(Gj()),n=t=>{t.key===`tandem:userName`&&e(Wj(t.newValue))};return window.addEventListener(lo,t),window.addEventListener(`storage`,n),()=>{window.removeEventListener(lo,t),window.removeEventListener(`storage`,n)}}function Jj(){let e=N(un(Gj()));return xa(qj(t=>{P(e,t,!0)})),{get userName(){return B(e)},setUserName:t=>{P(e,Kj(t),!0)}}}var Yj=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"/> <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
123
+ restores when you return to Tandem.</div>`,1);function Xj(e,t){A(t,!0);let n=Jj(),r=N(un(n.userName)),i=N(void 0);R(()=>{let e=n.userName;B(r)!==e&&document.activeElement!==B(i)&&P(r,e,!0)});var a=Yj(),o=I(a),s=L(F(o),2);ea(s),pa(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);ea(p),k(2),O(f),k(2),z(e=>{ta(s,B(r)),q(s,`maxlength`,40),q(u,`aria-checked`,t.settings.defaultMode===`tandem`),u.disabled=t.readOnly,q(d,`aria-checked`,t.settings.defaultMode===`solo`),d.disabled=t.readOnly,na(p,t.settings.soloRailHidden),p.disabled=t.readOnly,K(p,`accent-color: var(--tandem-accent); ${e??``}`)},[()=>uO(t.readOnly)]),V(`input`,s,e=>{P(r,e.target.value,!0)}),Br(`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()}Vr([`input`,`keydown`,`click`,`change`]);var Zj=zg({baseUrl:`http://127.0.0.1:${wa}`,pathFor:Eg});function Qj(){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 $j(){return crypto.randomUUID()}function eM(e){if(e.provider!==void 0&&!El.includes(e.provider))throw Error(`Invalid model provider: ${String(e.provider)}`)}async function tM(e,t){let n=await Zj.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 nM(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){eM(t);let r=$j(),i;n&&n.length>0&&(i=Qj(),await tM(i,n));let a={...t,id:r,...i?{apiKeyRef:i}:{}};return e.updateSettings({models:[...e.settings.models,a]}),r},async updateModel(t,n,r){eM(n);let i=e.settings.models.find(e=>e.id===t);if(!i)return;let a;r!==void 0&&r.length>0&&(a=Qj(),await Promise.all([tM(a,r),i.apiKeyRef?Zj.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 Zj.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(()=>Qj()),i=await Promise.allSettled(n.map((e,n)=>tM(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 rM=H(`<option> </option>`),iM=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>`),aM=H(`<input data-testid="model-edit-apikey" class="mem-input mem-input--mono svelte-1pwv6ag" type="password" autocomplete="off"/>`),oM=H(`<label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">API key</span> <!></label>`),sM=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>`),cM=H(`<p class="mem-advanced-help svelte-1pwv6ag">Per-model parameter overrides (temperature, max tokens, etc.) are not editable in
124
+ this preview. The data model accepts a \`params\` map for forward-compat with
125
+ Wave 6 surfaces.</p>`),lM=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 uM(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=jr(()=>t.entry),i=N(un(r?.provider??`anthropic`)),a=N(un(r?.displayName??``)),o=N(un(r?.modelId??``)),s=N(un(r?.endpoint??``)),c=N(un(r?.enabled??!0)),l=N(``),u=r!==void 0&&!!r.apiKeyRef,d=N(un(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=lM();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);mi(T,21,()=>n,e=>e.value,(e,t)=>{var n=rM(),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);ea(te),O(E);var D=L(E,2),ne=L(F(D),2);ea(ne),O(D);var re=L(D,2),ie=e=>{var t=oM(),n=L(F(t),2),i=e=>{var t=iM(),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=aM();ea(t),z(()=>q(t,`placeholder`,f?`Enter new key`:`Paste your API key`)),oa(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=sM(),n=L(F(t),2);ea(n),O(t),oa(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);ea(ce),k(2),O(se);var le=L(se,2);yj(le,{label:`Advanced parameters`,testid:`model-edit-advanced`,children:(e,t)=>{U(e,cM())},$$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()}),Br(`submit`,b,_),V(`click`,w,function(...e){t.onCancel?.apply(this,e)}),Ji(T,()=>B(i),e=>P(i,e)),oa(te,()=>B(a),e=>P(a,e)),oa(ne,()=>B(o),e=>P(o,e)),sa(ce,()=>B(c),e=>P(c,e)),V(`click`,de,function(...e){t.onCancel?.apply(this,e)}),U(e,y),j()}Vr([`click`,`keydown`]);var dM=H(`<span data-testid="models-legacy-migration-status"> </span>`),fM=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
126
+ 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>`),pM=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">Add your first model</button></div>`),mM=H(`<button type="button">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),hM=H(`<button type="button">Delete</button>`),gM=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"/> <span>Default</span></label> <label style="display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--tandem-fg-muted);"><input type="checkbox"/> <span> </span></label> <button type="button">Edit</button> <!></div>`),_M=H(`<div><div class="settings-section-label"> </div> <div style="display: flex; flex-direction: column; gap: 4px;"></div></div>`),vM=H(`<div style="display: flex; flex-direction: column; gap: var(--tandem-space-3);"></div> <button type="button" data-testid="model-add-btn">+ Add model</button>`,1),yM=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>`),bM=H(`<div style="display: flex; flex-direction: column; gap: var(--tandem-space-3);"><!> <!></div> <!> <!>`,1);function xM(e,t){A(t,!0);let n=nM(Dv()),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 _=bM(),v=I(_),y=F(v),b=e=>{var n=fM(),r=L(F(n),2),i=F(r),a=F(i,!0);O(i);var o=L(i,2),s=e=>{var t=dM(),n=F(t,!0);O(t),z(()=>W(n,B(d))),U(e,t)};G(o,e=>{B(d)&&e(s)}),O(r),O(n),z(()=>{i.disabled=t.readOnly||B(u),K(i,`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: ${t.readOnly?`not-allowed`:B(u)?`wait`:`pointer`}; opacity: ${t.readOnly?.5:1};`),W(a,B(u)?`Migrating…`:`Migrate keys`)}),V(`click`,i,g),U(e,n)};G(y,e=>{n.hasLegacyKeys&&e(b)});var x=L(y,2),S=e=>{var n=pM(),r=L(F(n),2);O(n),z(e=>{r.disabled=t.readOnly,K(r,`padding: 6px var(--tandem-space-3); font-size: 13px; font-weight: 500; border: none; border-radius: var(--tandem-r-2); ${e??``} background: var(--tandem-accent); color: var(--tandem-accent-fg);`)},[()=>uO(t.readOnly)]),V(`click`,r,f),U(e,n)},C=e=>{var o=vM(),s=I(o);mi(s,20,()=>i,e=>e,(e,i)=>{let o=M(()=>B(a).get(i)??[]);var s=Zr(),l=I(s),u=e=>{var a=_M(),s=F(a),l=F(s,!0);O(s);var u=L(s,2);mi(u,21,()=>B(o),e=>e.id,(e,r)=>{var i=gM(),a=F(i),o=F(a),s=F(o,!0);O(o);var l=L(o,2),u=F(l,!0);O(l),O(a);var d=L(a,2),f=F(d);ea(f),k(2),O(d);var m=L(d,2),g=F(m);ea(g);var _=L(g,2),v=F(_,!0);O(_),O(m);var y=L(m,2),b=L(y,2),x=e=>{var n=mM(),i=I(n),a=L(i,2);z(e=>{q(i,`data-testid`,`model-delete-confirm-${B(r).id}`),i.disabled=t.readOnly,K(i,`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); ${e??``}`)},[()=>uO(t.readOnly)]),V(`click`,i,()=>h(B(r).id)),V(`click`,a,()=>P(c,null)),U(e,n)},S=e=>{var n=hM();z(e=>{q(n,`data-testid`,`model-delete-btn-${B(r).id}`),n.disabled=t.readOnly,K(n,`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); ${e??``}`)},[()=>uO(t.readOnly)]),V(`click`,n,()=>P(c,B(r).id,!0)),U(e,n)};G(b,e=>{B(c)===B(r).id?e(x):e(S,-1)}),O(i),z((e,a,o)=>{q(i,`data-testid`,`model-row-${B(r).id}`),W(s,B(r).displayName),W(u,B(r).modelId),q(f,`data-testid`,`model-default-${B(r).id}`),na(f,n.defaultModelId===B(r).id),f.disabled=t.readOnly,K(f,`accent-color: var(--tandem-accent); ${e??``}`),q(g,`data-testid`,`model-toggle-${B(r).id}`),na(g,B(r).enabled),g.disabled=t.readOnly,K(g,`accent-color: var(--tandem-accent); ${a??``}`),W(v,B(r).enabled?`On`:`Off`),q(y,`data-testid`,`model-edit-btn-${B(r).id}`),y.disabled=t.readOnly,K(y,`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); ${o??``}`)},[()=>uO(t.readOnly),()=>uO(t.readOnly),()=>uO(t.readOnly)]),V(`change`,f,()=>n.setDefault(B(r).id)),V(`change`,g,()=>n.toggleEnabled(B(r).id)),V(`click`,y,()=>p(B(r))),U(e,i)}),O(u),O(a),z(()=>W(l,r[i])),U(e,a)};G(l,e=>{B(o).length>0&&e(u)}),U(e,s)}),O(s);var l=L(s,2);z(e=>{l.disabled=t.readOnly,K(l,`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); ${e??``} background: var(--tandem-surface); color: var(--tandem-accent);`)},[()=>uO(t.readOnly)]),V(`click`,l,f),U(e,o)};G(x,e=>{n.models.length===0?e(S):e(C,-1)}),O(v);var w=L(v,2),ee=e=>{var t=yM(),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=>{uM(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()}Vr([`click`,`change`]);var SM=H(`<span style="justify-self: start; font-size: 11px; color: var(--tandem-accent-fg-strong); font-style: italic;">Press keys… (Esc to cancel)</span>`),CM=H(`<kbd> </kbd>`),wM=H(`<button type="button">Reset</button>`),TM=H(`<div style="grid-column: 1 / -1; font-size: 11px; color: var(--tandem-error-fg);"> </div>`),EM=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>`),DM=H(`<kbd> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>`,1),OM=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>`),kM=H(`<kbd> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>`,1),AM=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 jM(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(()=>Sl(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=il(a);if(!s)return;let c=yl(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`,`${Zc[e]} set to ${ul(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(()=>Jc.some(e=>B(o).has(e))),d=M(()=>{let e=du(),t=new Map;for(let n of e.values()){if(!n.shortcut||el[n.id])continue;let e=t.get(n.group)??[];e.push({keys:n.shortcut,description:n.label}),t.set(n.group,e)}return cu.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=AM(),m=F(p),h=F(m),g=L(F(h),2);O(h);var _=L(h,2);mi(_,20,()=>Jc,e=>e,(e,t)=>{let n=M(()=>B(r)===t),l=M(()=>B(o).has(t)),u=M(()=>ul(dl(t,B(o))));var d=EM(),p=F(d),m=F(p,!0);O(p);var h=L(p,2),g=e=>{var n=SM();z(()=>q(n,`data-testid`,`shortcut-recording-${t}`)),U(e,n)},_=e=>{var t=CM();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=wM();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=TM(),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,Zc[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(_),O(m);var v=L(m,2);mi(v,17,()=>B(d),e=>e.title,(e,t)=>{var n=OM(),r=F(n),i=F(r);O(r);var a=L(r,2);mi(a,21,()=>B(t).rows,e=>e.keys+e.description,(e,t)=>{var n=DM(),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 y=L(v,2),b=L(F(y),2);mi(b,21,()=>gm,e=>e.keys+e.description,(e,t)=>{var n=kM(),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(b),O(y),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()}Vr([`click`]);var MM=H(`<div data-testid="settings-modal-shortcuts-list"><!></div>`);function NM(e,t){var n=MM();jM(F(n),{get settings(){return t.settings},get onUpdate(){return t.onUpdate},get notify(){return t.notify}}),O(n),U(e,n)}var PM=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
127
+ the command line. A valid license unlocks editing and runs forever.</div></div>`);function FM(e,t){A(t,!0);let n=M(()=>mv.ui),r=M(()=>B(n).statusLabel||`No license required`);function i(){t.notify(`info`,`License activated.`)}var a=PM(),o=L(F(a),2),s=F(o,!0);O(o),bv(L(o,4),{onActivated:i}),k(2),O(a),z(()=>W(s,B(r))),U(e,a),j()}var IM=null;function LM(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function RM(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 zM(e){return e.replace(/(\/Users\/)[^/\\]+/g,`$1[user]`).replace(/(\/home\/)[^/\\]+/g,`$1[user]`).replace(/([A-Za-z]:\\Users\\)[^\\]+/g,`$1[user]`)}function BM(e){return zM(RM(e))}async function VM(){if(LM())try{let{invoke:e}=await ql(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]);if(!await e(`sentry_enabled`).catch(()=>!1))return;let t=await ql(()=>import(`./prod-Pu_njNLv.js`),[]),{defaultOptions:n}=await ql(async()=>{let{defaultOptions:e}=await import(`./dist-CHppK3gQ.js`);return{defaultOptions:e}},__vite__mapDeps([6,7]));t.init({...n,sendDefaultPii:!1,beforeSend:e=>{e.message&&=BM(e.message);for(let t of e.exception?.values??[])t.value&&=BM(t.value);return e.request&&(e.request.data=void 0,e.request.url&&(e.request.url=BM(e.request.url))),e},beforeBreadcrumb:e=>(e.message&&=BM(e.message),(e.category===`fetch`||e.category===`xhr`)&&(e.data=void 0),e)}),IM=t,window.addEventListener(`error`,e=>{UM(e.error??e.message,{source:`window.onerror`})}),window.addEventListener(`unhandledrejection`,e=>{UM(e.reason,{source:`unhandledrejection`})}),console.info(`[sentry] client crash reporting initialised`)}catch(e){console.warn(`[sentry] client init failed (non-fatal):`,e)}}function HM(){return IM!==null}function UM(e,t){if(IM)try{IM.captureException(e,t?{extra:t}:void 0)}catch{}}var WM={pass:`[ok] `,warn:`[warn]`,fail:`[fail]`};function GM(e){return e.replace(/[\x00-\x08\x0b-\x1f\x7f]/g,``)}function KM(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(`${WM[n.status]} ${n.check} — ${GM(n.message)}`),n.status!==`pass`&&n.fix&&t.push(` fix: ${GM(n.fix)}`);return t.push(``,GM(e.report.summary)),t.join(`
128
+ `)}var qM=H(`<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>`),JM=H(`<button type="button" data-testid="settings-modal-open-log-folder-btn">Open Log Folder</button>`),YM=H(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>`),XM=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),ZM=H(`<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 14px; margin: 0; font-size: 11px;"></dl>`),QM=H(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>`),$M=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 eN(e,t){A(t,!0);let n=$A(()=>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(`${Bl}${yc}`)}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=KM(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([ql(()=>import(`./path-49-uTKly.js`),__vite__mapDeps([0,1])),uh()]);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 Jh(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:HM()?`On (TANDEM_SENTRY_DSN set)`:`Off — opt in with TANDEM_SENTRY_DSN`}),t});var u=$M(),d=I(u),f=F(d),p=F(f,!0);O(f);var m=L(f,2),h=e=>{var t=qM(),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=JM();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(()=>sh());G(y,e=>{B(x)&&e(b)}),O(g);var S=L(g,2),C=L(F(S),2),w=e=>{U(e,YM())},ee=e=>{var t=ZM();mi(t,21,()=>B(l),e=>e.label,(e,t)=>{var n=XM(),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,QM())};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()}Vr([`click`]);var tN={appearance:`appearance`,editor:`editor`,network:`network`,accessibility:`accessibility`,collaboration:`collaboration`,claudeCode:`claude-code`,models:`models`,shortcuts:`shortcuts`,license:`license`,about:`about`},nN=H(`<span class="settings-modal-version-chip svelte-bbu5nk" data-testid="settings-modal-sidebar-version"> </span>`),rN=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>`),iN=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>`),aN=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 oN(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:pj},{id:`editor`,label:`Editor`,icon:`M4 4h11M4 9h16M4 14h11M4 19h16`,component:_j},{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:Aj},{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:rj},{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:Xj},{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:Uj},{id:`models`,label:`Models`,icon:`M4 4h16v16H4V4Zm5-3v3M15 1v3M9 20v3M15 20v3M1 9h3M1 15h3M20 9h3M20 15h3M8 8h8v8H8V8Z`,component:xM},{id:`shortcuts`,label:`Shortcuts`,icon:`M3 7h2v2H3V7Zm0 4h2v2H3v-2Zm0 4h2v2H3v-2Zm4-8h2v2H7V7Zm0 4h2v2H7v-2Zm0 4h10v2H7v-2Zm4-8h10v2H11V7Zm0 4h6v2h-6v-2Zm8 0h2v2h-2v-2Z`,component:NM},{id:`license`,label:`License`,icon:`M6 10h12v10H6V10Zm2 0V7a4 4 0 0 1 8 0v3`,component:FM},{id:`about`,label:`About`,icon:`M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm0 4v6m0 4h.01`,component:eN}].filter(e=>e.id!==tN.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=$A(()=>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(un(r[0].id)),b=M(()=>B(v).find(e=>e.id===B(y))??B(v)[0]),x=M(()=>B(b).label),S=M(()=>t.settings._readOnly===!0),C=M(()=>({open:t.open,settings:t.settings,onUpdate:t.onUpdate,connected:o(),reconnectAttempts:s(),readOnly:B(S),notify:u()}));R(()=>{B(b)&&B(b).id!==B(y)&&P(y,B(b).id,!0)}),R(()=>{if(t.open)return jr(()=>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)}}),ba(()=>{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 w(){let e=f.info?.changelogPath;if(!e){P(m,`Changelog file not found.`);return}P(p,!0),P(m,null);let n=await Jh(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 ee={DEFAULT_SETTINGS_TABS:r},T=Zr(),E=I(T),te=e=>{var r=aN(),i=I(r),a=M(()=>Sh(t.onClose)),c=L(i,2);q(c,`aria-labelledby`,n),q(c,`tabindex`,-1);var l=F(c),u=F(l),g=F(u);q(g,`id`,n);var ee=L(g,2),T=e=>{var t=nN(),n=F(t);O(t),z(()=>W(n,`v${f.info.version??``}`)),U(e,t)};G(ee,e=>{f.info&&e(T)}),O(u);var E=L(u,2);mi(E,21,()=>B(v),e=>e.id,(e,t)=>{var n=rN(),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(E);var te=L(E,2),D=F(te),ne=F(D,!0);O(D);var re=L(D,2),ie=e=>{var t=iN(),n=F(t,!0);O(t),z(()=>W(n,B(m))),U(e,t)};G(re,e=>{B(m)&&e(ie)});var ae=L(re,2),oe=L(ae,2),se=F(oe),ce=L(se,2),le=F(ce),ue=e=>{U(e,Xr(`MCP connected`))},de=e=>{U(e,Xr(`Reconnecting…`))},fe=e=>{U(e,Xr(`MCP offline`))};G(le,e=>{o()?e(ue):s()>0?e(de,1):e(fe,-1)}),O(ce),O(oe),O(te),O(l),Fi(l,(e,t)=>Gu?.(e,t),()=>`y`);var pe=L(l,2),me=F(pe),he=F(me),ge=L(he,2),_e=F(ge,!0);O(ge);var ve=L(ge,2);O(me);var ye=L(me,2),be=e=>{tj(e,{})};G(ye,e=>{B(S)&&e(be)});var xe=L(ye,2),Se=F(xe);li(F(Se),()=>B(b).id,e=>{var t=Zr();Si(I(t),()=>B(b).component,(e,t)=>{t(e,ya(()=>B(C)))}),U(e,t)}),O(Se),O(xe),Fi(xe,(e,t)=>Gu?.(e,t),()=>`y`),O(pe),O(c),pa(c,e=>P(d,e),()=>B(d)),z(()=>{q(c,`data-narrow-sidebar-open`,B(h)?`true`:`false`),l.inert=B(_)&&!B(h),D.disabled=B(p)||f.loading,W(ne,B(p)?`Opening…`:`Changelog`),q(ae,`href`,Ea),q(se,`data-state`,o()?`connected`:s()>0?`reconnecting`:`disconnected`),q(he,`aria-label`,B(h)?`Hide sections`:`Show sections`),q(he,`aria-expanded`,B(h)),W(_e,B(x))}),V(`click`,i,function(...e){t.onClose?.apply(this,e)}),V(`keydown`,i,function(...e){B(a)?.apply(this,e)}),V(`click`,D,()=>void w()),V(`click`,he,()=>{P(h,!B(h))}),V(`click`,ve,function(...e){t.onClose?.apply(this,e)}),U(e,r)};return G(E,e=>{t.open&&e(te)}),U(e,T),j(ee)}Vr([`click`,`keydown`]);var sN=H(`<span class="settings-version-chip svelte-fsutp8" data-testid="settings-sidebar-version"> </span>`),cN=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>`),lN=H(`<div role="alert" data-testid="changelog-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>`),uN=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"/> <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
129
+ restores when you return to Tandem.</div>`,1),dN=H(`<div data-testid="cowork-settings-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>`),fN=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" 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"/> <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"/> <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),pN=H(`<div data-testid="settings-shortcuts-list"><!></div>`),mN=H(`<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>`),hN=H(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>`),gN=H(`<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere;"> </dd>`,1),_N=H(`<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 11px;"></dl>`),vN=H(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>`),yN=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),bN=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 xN(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=M(()=>t.settings._readOnly===!0),l=Jj(),u=N(un(l.userName)),d=$A(()=>t.open),f=N(!1),p=N(null),m=N(!1),h=N(null),g=N(`appearance`);R(()=>{B(g),P(p,null),P(h,null)}),R(()=>{let e=l.userName;B(u)!==e&&document.activeElement!==B(s)&&P(u,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 _(e,n,r,i){if(!e){r(i.notFound);return}n(!0),r(null);try{let n=await Jh(e,{readOnly:!0,notFoundMessage:i.notFound,failureMessage:i.failed});if(!n.ok){r(n.error);return}t.onClose()}finally{n(!1)}}function v(){return _(d.info?.workflowsPath,e=>P(m,e,!0),e=>P(h,e,!0),{notFound:`Documentation file not found.`,failed:`Failed to open documentation.`})}function y(){return _(d.info?.changelogPath,e=>P(f,e,!0),e=>P(p,e,!0),{notFound:`Changelog file not found.`,failed:`Failed to open changelog.`})}let b=`font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;`,x=()=>{};function S(e){return r.find(t=>t.id===e)?.label??`Settings`}function C(){let e=d.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 w=Zr(),ee=I(w),T=e=>{var _=bN(),w=I(_),ee=L(w,2);q(ee,`aria-labelledby`,n),q(ee,`tabindex`,-1);var T=F(ee),E=F(T),te=F(E);q(te,`id`,n);var D=L(te,2),ne=e=>{var t=sN(),n=F(t);O(t),z(()=>W(n,`v${d.info.version??``}`)),U(e,t)};G(D,e=>{d.info&&e(ne)}),O(E);var re=L(E,2);mi(re,21,()=>r,e=>e.id,(e,t)=>{var n=cN(),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(g)===B(t).id?`page`:void 0),q(n,`data-active`,B(g)===B(t).id?`true`:`false`),q(i,`d`,B(t).icon),W(o,B(t).label)}),V(`click`,n,()=>P(g,B(t).id,!0)),U(e,n)}),O(re);var ie=L(re,2),ae=F(ie),oe=F(ae,!0);O(ae);var se=L(ae,2),ce=e=>{var t=lN(),n=F(t,!0);O(t),z(()=>W(n,B(p))),U(e,t)};G(se,e=>{B(p)&&e(ce)});var le=L(se,2),ue=L(le,2),de=F(ue),fe=L(de,2),pe=F(fe),me=e=>{U(e,Xr(`MCP connected`))},he=e=>{U(e,Xr(`Reconnecting…`))},ge=e=>{U(e,Xr(`MCP offline`))};G(pe,e=>{i()?e(me):a()>0?e(he,1):e(ge,-1)}),O(fe),O(ue),O(ie),O(T);var _e=L(T,2),ve=F(_e),ye=F(ve),be=F(ye,!0);O(ye);var xe=L(ye,2);O(ve);var Se=L(ve,2),Ce=e=>{tj(e,{})};G(Se,e=>{B(c)&&e(Ce)});var we=L(Se,2),Te=F(we),Ee=F(Te),De=e=>{var n=uN(),r=I(n),i=F(r);K(i,b);var a=L(i,2);ea(a),pa(a,e=>P(s,e),()=>B(s)),O(r);var o=L(r,2),d=F(o);K(d,b);var f=L(d,2),p=F(f),m=L(p,2);O(f),k(2),O(o);var h=L(o,2),g=F(h);ea(g),k(2),O(h),k(2),z((e,n,r)=>{ta(a,B(u)),q(a,`maxlength`,40),q(p,`aria-checked`,t.settings.defaultMode===`tandem`),p.disabled=B(c),K(p,`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}; ${e??``}`),q(m,`aria-checked`,t.settings.defaultMode===`solo`),m.disabled=B(c),K(m,`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}; ${n??``}`),na(g,t.settings.soloRailHidden),g.disabled=B(c),K(g,`accent-color: var(--tandem-accent); ${r??``}`)},[()=>uO(B(c)),()=>uO(B(c)),()=>uO(B(c))]),V(`input`,a,e=>{P(u,e.target.value,!0)}),Br(`blur`,a,()=>l.setUserName(B(u))),V(`keydown`,a,e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(P(u,l.userName,!0),e.currentTarget.blur())}),V(`click`,p,()=>t.onUpdate({defaultMode:`tandem`})),V(`click`,m,()=>t.onUpdate({defaultMode:`solo`})),V(`change`,g,e=>t.onUpdate({soloRailHidden:e.target.checked})),U(e,n)},Oe=e=>{pj(e,{get open(){return t.open},get settings(){return t.settings},get onUpdate(){return t.onUpdate},get connected(){return i()},get reconnectAttempts(){return a()},get readOnly(){return B(c)},notify:x})},ke=e=>{_j(e,{get open(){return t.open},get settings(){return t.settings},get onUpdate(){return t.onUpdate},get connected(){return i()},get reconnectAttempts(){return a()},get readOnly(){return B(c)},notify:x})},Ae=e=>{Aj(e,{get open(){return t.open},get settings(){return t.settings},get onUpdate(){return t.onUpdate},get connected(){return i()},get reconnectAttempts(){return a()},get readOnly(){return B(c)},notify:x})},je=e=>{rj(e,{get open(){return t.open},get settings(){return t.settings},get onUpdate(){return t.onUpdate},get connected(){return i()},get reconnectAttempts(){return a()},get readOnly(){return B(c)},notify:x})},Me=e=>{var n=fN(),r=I(n),i=F(r);K(i,b);var a=L(F(i)),o=F(a);O(a),O(i);var s=L(i,4);ea(s),q(s,`step`,100);var l=L(s,2),u=F(l),d=F(u);O(u);var f=L(u,2),p=F(f);O(f),O(l),O(r);var m=L(r,2),h=F(m);ea(h),k(2),O(m);var g=L(m,2),_=F(g);ea(_),k(2),O(g);var v=L(g,4),y=e=>{var t=Zr();si(I(t),()=>ql(()=>import(`./CoworkSettings-Brg8F0cb.js`),__vite__mapDeps([4,5])),e=>{U(e,dN())},(e,t)=>{let n=M(()=>B(t).default);var r=Zr();Si(I(r),()=>B(n),(e,t)=>{t(e,{})}),U(e,r)}),U(e,t)},x=M(()=>sh());G(v,e=>{B(x)&&e(y)}),z((e,n,r,i,a,l)=>{W(o,`${e??``}s`),q(s,`min`,500),q(s,`max`,za),ta(s,t.settings.selectionDwellMs),s.disabled=B(c),K(s,`width: 100%; accent-color: var(--tandem-accent); ${n??``}`),W(d,`${r??``}s`),W(p,`${i??``}s`),na(h,t.settings.selectionToolbar),h.disabled=B(c),K(h,`accent-color: var(--tandem-accent); ${a??``}`),na(_,t.settings.marginView),_.disabled=B(c),K(_,`accent-color: var(--tandem-accent); ${l??``}`)},[()=>(t.settings.selectionDwellMs/1e3).toFixed(1),()=>uO(B(c),`auto`),()=>(500/1e3).toFixed(1),()=>(za/1e3).toFixed(1),()=>uO(B(c)),()=>uO(B(c))]),V(`input`,s,e=>t.onUpdate({selectionDwellMs:Number(e.target.value)})),V(`change`,h,e=>t.onUpdate({selectionToolbar:e.target.checked})),V(`change`,_,e=>t.onUpdate({marginView:e.target.checked})),U(e,n)},Ne=e=>{var n=pN();jM(F(n),{get settings(){return t.settings},get onUpdate(){return t.onUpdate},notify:x}),O(n),U(e,n)},Pe=e=>{var t=yN(),n=I(t),r=F(n),i=F(r,!0);O(r);var a=L(r,2),o=e=>{var t=mN(),n=F(t,!0);O(t),z(()=>W(n,B(h))),U(e,t)};G(a,e=>{B(h)&&e(o)}),O(n);var s=L(n,2),c=F(s);K(c,b);var l=L(c,2),u=e=>{U(e,hN())},f=e=>{var t=_N();mi(t,21,C,e=>e.label,(e,t)=>{var n=gN(),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)},p=e=>{U(e,vN())};G(l,e=>{d.loading?e(u):d.info?e(f,1):e(p,-1)}),O(s),z(()=>{r.disabled=B(m)||d.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(m)||d.loading?`not-allowed`:`pointer`}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${B(m)||d.loading?.6:1};`),W(i,B(m)?`Opening…`:`View Documentation`)}),V(`click`,r,()=>void v()),U(e,t)};G(Ee,e=>{B(g)===`collaboration`?e(De):B(g)===`appearance`?e(Oe,1):B(g)===`editor`?e(ke,2):B(g)===`network`?e(Ae,3):B(g)===`accessibility`?e(je,4):B(g)===`claude-code`?e(Me,5):B(g)===`shortcuts`?e(Ne,6):e(Pe,-1)}),O(Te),O(we),O(_e),O(ee),pa(ee,e=>P(o,e),()=>B(o)),z(e=>{ae.disabled=B(f)||d.loading,W(oe,B(f)?`Opening…`:`Changelog`),q(le,`href`,Ea),q(de,`data-state`,i()?`connected`:a()>0?`reconnecting`:`disconnected`),W(be,e)},[()=>S(B(g))]),V(`click`,w,function(...e){t.onClose?.apply(this,e)}),V(`click`,ae,()=>void y()),V(`click`,xe,function(...e){t.onClose?.apply(this,e)}),U(e,_)};G(ee,e=>{t.open&&e(T)}),U(e,w),j()}Vr([`click`,`input`,`keydown`,`change`]);var SN=Yr(`<path></path>`),CN=H(`<span class="badge svelte-nsu1aw"> </span>`),wN=H(`<button type="button" class="action svelte-nsu1aw"> </button>`),TN=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>`),EN=H(`<div data-testid="toast-container" class="toast-stack svelte-nsu1aw"></div>`);function DN(e,t){A(t,!0);var n=Zr(),r=I(n),i=e=>{var n=EN();mi(n,21,()=>t.toasts,e=>e.id,(e,n)=>{var r=TN(),i=F(r),a=F(i);mi(a,20,()=>qu[B(n).severity],e=>e,(e,t)=>{var n=SN();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=CN(),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=wN(),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}`),Wi(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()}Vr([`click`]);var ON=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 kN(e,t){let n=M(()=>t.installing?`Installing…`:`Restart to install`);var r=ON(),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)}Vr([`click`]);var AN=Math.floor,jN=(e,t)=>e<t?e:t,MN=(e,t)=>e>t?e:t,NN=128,PN=127,FN=2**53-1,IN=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},LN=typeof TextEncoder<`u`?new TextEncoder:null,RN=LN?e=>LN.encode(e):IN,zN=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});zN&&zN.decode(new Uint8Array).length===1&&(zN=null);var BN=(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},VN=(e,t)=>{for(;t>PN;)BN(e,NN|PN&t),t=AN(t/128);BN(e,PN&t)},HN=new Uint8Array(3e4),UN=HN.length/3,WN=LN&&LN.encodeInto?(e,t)=>{if(t.length<UN){let n=LN.encodeInto(t,HN).written||0;VN(e,n);for(let t=0;t<n;t++)BN(e,HN[t])}else KN(e,RN(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;VN(e,r);for(let t=0;t<r;t++)BN(e,n.codePointAt(t))},GN=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=jN(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(MN(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},KN=(e,t)=>{VN(e,t.byteLength),GN(e,t)},qN=e=>Error(e),JN=qN(`Unexpected end of array`),YN=qN(`Integer out of Range`),XN=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},ZN=e=>XN(e,$N(e)),QN=e=>e.arr[e.pos++],$N=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&PN)*n,n*=128,r<NN)return t;if(t>FN)throw YN}throw JN},eP=zN?e=>zN.decode(ZN(e)):e=>{let t=$N(e);if(t===0)return``;{let n=String.fromCodePoint(QN(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(QN(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))}},tP;(function(e){e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`})(tP||={});var nP=(e,t)=>{VN(e,tP.Token),WN(e,t)},rP=(e,t,n,r)=>{switch($N(e)){case tP.Token:t();break;case tP.PermissionDenied:n(eP(e));break;case tP.Authenticated:r(eP(e));break}},iP=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),aP;(function(e){e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`})(aP||={});function oP(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 sP(e){return new Promise(t=>setTimeout(t,e))}function cP(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 lP(e,t){let n=oP(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||cP;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 sP(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 sP(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await sP(e)}return a()}var uP=Math.floor,dP=(e,t)=>e<t?e:t,fP=(e,t)=>e>t?e:t,pP=64,mP=128,hP=63,gP=127,_P=2**53-1,vP=()=>new Set,yP=Array.from,bP=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},xP=typeof TextEncoder<`u`?new TextEncoder:null,SP=xP?e=>xP.encode(e):bP,CP=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});CP&&CP.decode(new Uint8Array).length===1&&(CP=null);var wP=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},TP=()=>new wP,EP=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},DP=e=>{let t=new Uint8Array(EP(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},OP=(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},kP=(e,t)=>{for(;t>gP;)OP(e,mP|gP&t),t=uP(t/128);OP(e,gP&t)},AP=new Uint8Array(3e4),jP=AP.length/3,MP=xP&&xP.encodeInto?(e,t)=>{if(t.length<jP){let n=xP.encodeInto(t,AP).written||0;kP(e,n);for(let t=0;t<n;t++)OP(e,AP[t])}else PP(e,SP(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;kP(e,r);for(let t=0;t<r;t++)OP(e,n.codePointAt(t))},NP=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=dP(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(fP(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},PP=(e,t)=>{kP(e,t.byteLength),NP(e,t)},FP=e=>Error(e),IP=FP(`Unexpected end of array`),LP=FP(`Integer out of Range`),RP=class{constructor(e){this.arr=e,this.pos=0}},zP=e=>new RP(e),BP=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},VP=e=>BP(e,UP(e)),HP=e=>e.arr[e.pos++],UP=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&gP)*n,n*=128,r<mP)return t;if(t>_P)throw LP}throw IP},WP=e=>{let t=e.arr[e.pos++],n=t&hP,r=64,i=(t&pP)>0?-1:1;if((t&mP)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&gP)*r,r*=128,t<mP)return i*n;if(n>_P)throw LP}throw IP},GP=CP?e=>CP.decode(VP(e)):e=>{let t=UP(e);if(t===0)return``;{let n=String.fromCodePoint(HP(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(HP(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))}},KP=e=>{let t=e.pos,n=GP(e);return e.pos=t,n},qP=Date.now,JP=()=>new Map,YP=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},XP=class{constructor(){this._observers=JP()}on(e,t){YP(this._observers,e,vP).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 yP((this._observers.get(e)||JP()).values()).forEach(e=>e(...t))}destroy(){this._observers=JP()}},ZP=Object.keys,QP=e=>ZP(e).length,$P=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),eF=(e,t)=>e===t,tF=(e,t)=>{if(e==null||t==null)return eF(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)||!tF(e.get(n),t.get(n)))return!1;break;case Object:if(QP(e)!==QP(t))return!1;for(let n in e)if(!$P(e,n)||!tF(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(!tF(e[n],t[n]))return!1;break;default:return!1}return!0},nF=3e4,rF=class extends XP{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=qP();this.getLocalState()!==null&&nF/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&nF<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&iF(this,t,`timeout`)},uP(nF/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:qP()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),tF(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}},iF=(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:qP()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},aF=(e,t,n=e.states)=>{let r=t.length,i=TP();kP(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;kP(i,r),kP(i,s),MP(i,JSON.stringify(o))}return DP(i)},oF=(e,t,n)=>{let r=zP(t),i=qP(),a=[],o=[],s=[],c=[],l=UP(r);for(let t=0;t<l;t++){let t=UP(r),n=UP(r),l=JSON.parse(GP(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&&(tF(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])},sF=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={}}},cF=class{constructor(e){this.data=e,this.encoder=TP(),this.decoder=zP(new Uint8Array(this.data))}peekVarString(){return KP(this.decoder)}readVarUint(){return UP(this.decoder)}readVarString(){return GP(this.decoder)}readVarUint8Array(){return VP(this.decoder)}writeVarUint(e){return kP(this.encoder,e)}writeVarString(e){return MP(this.encoder,e)}writeVarUint8Array(e){return PP(this.encoder,e)}length(){return EP(this.encoder)}},lF;(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`})(lF||={});var uF;(function(e){e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`})(uF||={});var dF=class{constructor(){this.encoder=TP()}get(e){return e.encoder}toUint8Array(){return DP(this.encoder)}},fF=class extends dF{constructor(){super(...arguments),this.type=lF.CLOSE,this.description=`Ask the server to close the connection`}get(e){return MP(this.encoder,e.documentName),kP(this.encoder,this.type),this.encoder}},pF=class extends sF{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=uF.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=uF.Connected,this.emit(`status`,{status:uF.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){this.configuration.providerMap.set(e.configuration.name,e),this.status===uF.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===uF.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){this.configuration.providerMap.has(e.configuration.name)&&(e.send(fF,{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===uF.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:lP(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=uF.Connecting,this.emit(`status`,{status:uF.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){var t;this.resolveConnectionAttempt(),this.lastMessageReceived=qP();let n=new cF(e.data).peekVarString();(t=this.configuration.providerMap.get(n))==null||t.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=uF.Connected,this.emit(`status`,{status:uF.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===uF.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=qP()-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===aP.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=uF.Disconnected,this.emit(`status`,{status:uF.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()}},mF=0,hF=1,gF=2,_F=(e,t)=>{kP(e,mF),PP(e,mw(t))},vF=(e,t,n)=>{kP(e,hF),PP(e,cw(t,n))},yF=(e,t,n)=>vF(t,n,VP(e)),bF=(e,t,n)=>{try{aw(t,VP(e),n)}catch(e){console.error(`Caught error while handling a Yjs update`,e)}},xF=(e,t)=>{kP(e,gF),PP(e,t)},SF=bF,CF=(e,t,n,r)=>{let i=UP(e);switch(i){case mF:yF(e,t,n);break;case hF:bF(e,n,r);break;case gF:SF(e,n,r);break;default:throw Error(`Unknown message type`)}return i},wF=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case lF.Sync:this.applySyncMessage(e,t);break;case lF.Awareness:this.applyAwarenessMessage(e);break;case lF.Auth:this.applyAuthMessage(e);break;case lF.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case lF.Stateless:e.receiveStateless(GP(n.decoder));break;case lF.SyncStatus:this.applySyncStatusMessage(e,WP(n.decoder)===1);break;case lF.CLOSE:let i={code:1e3,reason:GP(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(dF,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(lF.Sync);let r=CF(n.decoder,n.encoder,e.document,e);t&&r===hF&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;oF(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;rP(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(lF.Awareness),t.writeVarUint8Array(aF(e.awareness,Array.from(e.awareness.getStates().keys())))}},TF=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return DP(this.encoder)}send(e){e?.send(this.create())}},EF=class extends dF{constructor(){super(...arguments),this.type=lF.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return MP(this.encoder,e.documentName),kP(this.encoder,this.type),nP(this.encoder,e.token),this.encoder}},DF=class extends dF{constructor(){super(...arguments),this.type=lF.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`);MP(this.encoder,e.documentName),kP(this.encoder,this.type);let t;return t=e.states===void 0?aF(e.awareness,e.clients):aF(e.awareness,e.clients,e.states),PP(this.encoder,t),this.encoder}},OF=class extends dF{constructor(){super(...arguments),this.type=lF.Stateless,this.description=`A stateless message`}get(e){return MP(this.encoder,e.documentName),kP(this.encoder,this.type),MP(this.encoder,e.payload??``),this.encoder}},kF=class extends dF{constructor(){super(...arguments),this.type=lF.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 MP(this.encoder,e.documentName),kP(this.encoder,this.type),_F(this.encoder,e.document),this.encoder}},AF=class extends dF{constructor(){super(...arguments),this.type=lF.Sync,this.description=`A document update`}get(e){return MP(this.encoder,e.documentName),kP(this.encoder,this.type),xF(this.encoder,e.update),this.encoder}},jF=class extends Error{constructor(){super(...arguments),this.code=1001}},MF=class extends sF{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 UC,this.configuration.awareness=e.awareness===void 0?new rF(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:iP(this.awareness.getStates())})}),(n=this.awareness)==null||n.on(`change`,()=>{this.emit(`awarenessChange`,{states:iP(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 pF(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(kF,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&iF(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(OF,{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(EF,{token:e??``,documentName:this.configuration.name})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(AF,{update:e,documentName:this.configuration.name}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(DF,{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(kF,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(DF,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,t){if(!this._isAttached)return;let n=new TF(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new cF(e.data),n=t.readVarString();t.writeVarString(n),this.emit(`message`,{event:e,message:new cF(e.data)}),new wF(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&iF(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&&(iF(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 jF(`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)}},NF=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},PF=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},FF=null,IF=function(e,t,n){let r=FF||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},LF=function(){FF=null},RF=function(e,t,n,r){return n&&(BF(e,t,n,r,-1)||BF(e,t,n,r,1))},zF=/^(img|br|input|textarea|hr)$/i;function BF(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:VF(e))){let n=e.parentNode;if(!n||n.nodeType!=1||GF(e)||zF.test(e.nodeName)||e.contentEditable==`false`)return!1;t=NF(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?VF(e):0}else return!1}}function VF(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function HF(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=VF(e)}else if(e.parentNode&&!GF(e))t=NF(e),e=e.parentNode;else return null}}function UF(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&&!GF(e))t=NF(e)+1,e=e.parentNode;else return null}}function WF(e,t,n){for(let r=t==0,i=t==VF(e);r||i;){if(e==n)return!0;let t=NF(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==VF(e)}}function GF(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 KF=function(e){return e.focusNode&&RF(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function qF(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function JF(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function YF(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(VF(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(VF(r.startContainer),r.startOffset)}}}var XF=typeof navigator<`u`?navigator:null,ZF=typeof document<`u`?document:null,QF=XF&&XF.userAgent||``,$F=/Edge\/(\d+)/.exec(QF),eI=/MSIE \d/.exec(QF),tI=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(QF),nI=!!(eI||tI||$F),rI=eI?document.documentMode:tI?+tI[1]:$F?+$F[1]:0,iI=!nI&&/gecko\/(\d+)/i.test(QF);iI&&+(/Firefox\/(\d+)/.exec(QF)||[0,0])[1];var aI=!nI&&/Chrome\/(\d+)/.exec(QF),oI=!!aI,sI=aI?+aI[1]:0,cI=!nI&&!!XF&&/Apple Computer/.test(XF.vendor),lI=cI&&(/Mobile\/\w+/.test(QF)||!!XF&&XF.maxTouchPoints>2),uI=lI||(XF?/Mac/.test(XF.platform):!1),dI=XF?/Win/.test(XF.platform):!1,fI=/Android \d/.test(QF),pI=!!ZF&&`webkitFontSmoothing`in ZF.documentElement.style,mI=pI?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function hI(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 gI(e,t){return typeof e==`number`?e:e[t]}function _I(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 vI(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=PF(o);continue}let e=o,n=e==a.body,s=n?hI(a):_I(e),c=0,l=0;if(t.top<s.top+gI(r,`top`)?l=-(s.top-t.top+gI(i,`top`)):t.bottom>s.bottom-gI(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+gI(i,`top`)-s.top:t.bottom-s.bottom+gI(i,`bottom`)),t.left<s.left+gI(r,`left`)?c=-(s.left-t.left+gI(i,`left`)):t.right>s.right-gI(r,`right`)&&(c=t.right-s.right+gI(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:PF(o)}}function yI(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:bI(e.dom)}}function bI(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=PF(r));return t}function xI({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;SI(n,r==0?0:r-t)}function SI(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 CI=null;function wI(e){if(e.setActive)return e.setActive();if(CI)return e.focus(CI);let t=bI(e);e.focus(CI==null?{get preventScroll(){return CI={preventScroll:!0},!0}}:void 0),CI||(CI=!1,SI(t,0))}function TI(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=IF(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?EI(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:TI(n,i)}function EI(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=PI(r,1);if(n.top!=n.bottom&&DI(t,n)){i={node:e,offset:a+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function DI(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function OI(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function kI(e,t,n){let{node:r,offset:i}=TI(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 AI(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 jI(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(DI(t,i))return jI(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function MI(e,t){let n=e.dom.ownerDocument,r,i=0,a=YF(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(!DI(t,n)||(o=jI(e.dom,t,n),!o))return null}if(cI)for(let e=o;r&&e;e=PF(e))e.draggable&&(r=void 0);if(o=OI(o,t),r){if(iI&&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;pI&&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=AI(e,r,i,t))}s??=kI(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function NI(e){return e.top<e.bottom||e.left<e.right}function PI(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(NI(e))return e}return Array.prototype.find.call(n,NI)||e.getBoundingClientRect()}var FI=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function II(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=pI||iI;if(r.nodeType==3)if(o&&(FI.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=PI(IF(r,i,i),n);if(iI&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=PI(IF(r,i-1,i-1),-1);if(t.top==e.top){let n=PI(IF(r,i,i+1),-1);if(n.top!=e.top)return LI(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++,LI(PI(IF(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==VF(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return RI(e.getBoundingClientRect(),!1)}if(a==null&&i<VF(r)){let e=r.childNodes[i];if(e.nodeType==1)return RI(e.getBoundingClientRect(),!0)}return RI(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==VF(r))){let e=r.childNodes[i-1],t=e.nodeType==3?IF(e,VF(e)-+!o):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return LI(PI(t,1),!1)}if(a==null&&i<VF(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?e.nodeType==3?IF(e,0,+!o):e.nodeType==1?e:null:null;if(t)return LI(PI(t,-1),!0)}return LI(PI(r.nodeType==3?IF(r):r,-n),n>=0)}function LI(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 RI(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 zI(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 BI(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return zI(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=II(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=IF(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 VI=/[\u0590-\u08ac]/;function HI(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?!VI.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:zI(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 UI=null,WI=null,GI=!1;function KI(e,t,n){return UI==t&&WI==n?GI:(UI=t,WI=n,GI=n==`up`||n==`down`?BI(e,t,n):HI(e,t,n))}var qI=0,JI=1,YI=2,XI=3,ZI=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=qI,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>NF(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 iL){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 QI&&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?NF(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?NF(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=NF(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=NF(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((iI||cI)&&e==t){let{node:e,offset:t}=o;if(e.nodeType==3){if(u=!!(t&&e.nodeValue[t-1]==`
130
+ `),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:NF(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(iI&&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&&cI)&&RF(o.node,o.offset,l.anchorNode,l.anchorOffset)&&RF(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&iI)){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?YI:JI,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=XI:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?YI:XI}n=a}this.dirty=YI}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?YI:JI;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},QI=class extends ZI{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==qI&&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}},$I=class extends ZI{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}},eL=class e extends ZI{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=Cf.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&XI||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=XI&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=qI){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=qI}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=xL(a,n,o,r)),t>0&&(a=xL(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()}},tL=class e extends ZI{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=Cf.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=fL(u,r,n),l?c=new aL(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new rL(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==qI&&e.eq(this.node)&&pL(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 hL(this,a&&a.node,e);vL(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?pd.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==YI)&&(a&&this.protectLocalComposition(e,a),oL(this.contentDOM,this.children,e),lI&&yL(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof Jp)||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=bL(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 $I(this,i,t,r);e.input.compositionNodes.push(a),this.children=xL(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==XI||!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=qI}updateOuterDeco(e){if(pL(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=uL(this.dom,this.nodeDOM,lL(this.outerDeco,this.node,t),lL(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 nL(e,t,n,r,i){fL(r,t,e);let a=new tL(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var rL=class e extends tL{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==XI||this.dirty!=qI&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=qI||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=qI,!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=XI)}get domAtom(){return!1}isText(e){return this.node.text==e}},iL=class extends ZI{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==qI&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},aL=class extends tL{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==XI)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 oL(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=mL(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof eL){let t=r?r.previousSibling:e.lastChild;oL(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=mL(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var sL=function(e){e&&(this.nodeName=e)};sL.prototype=Object.create(null);var cL=[new sL];function lL(e,t,n){if(e.length==0)return cL;let r=n?cL[0]:new sL,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new sL(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new sL(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 uL(e,t,n,r){if(n==cL&&r==cL)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=cL[0],i=t)}dL(i,o||cL[0],a)}return i}function dL(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 fL(e,t,n){return uL(e,e,cL,lL(t,n,e.nodeType!=1))}function pL(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 mL(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var hL=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=gL(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=qI,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=eL.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==XI&&a.dom==a.contentDOM&&(a.dirty=YI),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 tL){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!=XI&&pL(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=YI,u.updateChildren(r,a+1),u.dirty=qI),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)||!pL(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=tL.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=tL.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 QI(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 eL;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof rL)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((cI||oI)&&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 iL(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 gL(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 eL)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 _L(e,t){return e.type.side-t.type.side}function vL(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(_L);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 yL(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 bL(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 xL(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 SL(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(KF(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&Xp.isSelectable(e)&&i.parent&&!(e.isInline&&WF(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new Xp(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=NL(e,u,s,n)}return l}function CL(e){return e.editable?e.hasFocus():FL(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function wL(e,t=!1){let n=e.state.selection;if(jL(e,n),CL(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&oI){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&RF(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)AL(e);else{let{anchor:r,head:i}=n,a,o;TL&&!(n instanceof Jp)&&(n.$from.parent.inlineContent||(a=EL(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=EL(e,n.to))),e.docView.setSelection(r,i,e,t),TL&&(a&&OL(a),o&&OL(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&kL(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var TL=cI||oI&&sI<63;function EL(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(cI&&i&&i.contentEditable==`false`)return DL(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return DL(i);if(a)return DL(a)}}function DL(e){return e.contentEditable=`true`,cI&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function OL(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function kL(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(()=>{(!CL(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function AL(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,NF(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&nI&&rI<=11&&(n.disabled=!0,n.disabled=!1)}function jL(e,t){if(t instanceof Xp){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ML(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ML(e)}function ML(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function NL(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||Jp.between(t,n,r)}function PL(e){return e.editable&&!e.hasFocus()?!1:FL(e)}function FL(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 IL(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return RF(t.node,t.offset,n.anchorNode,n.anchorOffset)}function LL(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&&Wp.findFrom(a,t)}function RL(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function zL(e,t,n){let r=e.state.selection;if(r instanceof Jp){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 RL(e,new Jp(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=LL(e.state,t);return n&&n instanceof Xp?RL(e,n):!1}else if(!(uI&&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?Xp.isSelectable(i)?RL(e,new Xp(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):pI?RL(e,new Jp(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof Xp&&r.node.isInline)return RL(e,new Jp(t>0?r.$to:r.$from));else{let n=LL(e.state,t);return n?RL(e,n):!1}}function BL(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function VL(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function HL(e,t){return t<0?UL(e):WL(e)}function UL(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(iI&&n.nodeType==1&&r<BL(n)&&VL(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(VL(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(GL(n))break;else{let t=n.previousSibling;for(;t&&VL(t,-1);)i=n.parentNode,a=NF(t),t=t.previousSibling;if(t)n=t,r=BL(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?JL(e,n,r):i&&JL(e,i,a)}function WL(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=BL(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(VL(e,1))a=n,o=++r;else break}else if(GL(n))break;else{let t=n.nextSibling;for(;t&&VL(t,1);)a=t.parentNode,o=NF(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=BL(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&JL(e,a,o)}function GL(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function KL(e,t){for(;e&&t==e.childNodes.length&&!GF(e);)t=NF(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 qL(e,t){for(;e&&!t&&!GF(e);)t=NF(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 JL(e,t,n){if(t.nodeType!=3){let e,r;(r=KL(t,n))?(t=r,n=0):(e=qL(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(KF(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&&wL(e)},50)}function YL(e,t){let n=e.state.doc.resolve(t);if(!(oI||dI)&&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 XL(e,t,n){let r=e.state.selection;if(r instanceof Jp&&!r.empty||n.indexOf(`s`)>-1||uI&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=LL(e.state,t);if(n&&n instanceof Xp)return RL(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof Qp?Wp.near(n,t):Wp.findFrom(n,t);return o?RL(e,o):!1}return!1}function ZL(e,t){if(!(e.state.selection instanceof Jp))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 QL(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function $L(e){if(!cI||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;QL(e,n,`true`),setTimeout(()=>QL(e,n,`false`),20)}return!1}function eR(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function tR(e,t){let n=t.keyCode,r=eR(t);if(n==8||uI&&n==72&&r==`c`)return ZL(e,-1)||HL(e,-1);if(n==46&&!t.shiftKey||uI&&n==68&&r==`c`)return ZL(e,1)||HL(e,1);if(n==13||n==27)return!0;if(n==37||uI&&n==66&&r==`c`){let t=n==37?YL(e,e.state.selection.from)==`ltr`?-1:1:-1;return zL(e,t,r)||HL(e,t)}else if(n==39||uI&&n==70&&r==`c`){let t=n==39?YL(e,e.state.selection.from)==`ltr`?1:-1:1;return zL(e,t,r)||HL(e,t)}else if(n==38||uI&&n==80&&r==`c`)return XL(e,-1,r)||HL(e,-1);else if(n==40||uI&&n==78&&r==`c`)return $L(e)||XL(e,1,r)||HL(e,1);else if(r==(uI?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function nR(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`)||Cf.fromSchema(e.state.schema),s=pR(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=dR[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,`
131
+
132
+ `),slice:t}}function rR(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,`
133
+ `))),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=Cf.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=gR(n),pI&&_R(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`)||lf.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!iR.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=vR(uR(s,+u[1],+u[2]),u[4]);else if(s=Q.maxOpen(aR(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=uR(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var iR=/^(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 aR(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&&sR(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=cR(a[a.length-1],i.length));let n=oR(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return Z.from(a)}return e}function oR(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,Z.from(e));return e}function sR(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=sR(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(oR(n,e,i+1))))}}function cR(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,cR(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(Z.empty,!0);return e.copy(n.append(r))}function lR(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=lR(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 uR(e,t,n){return t<e.openStart&&(e=new Q(lR(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Q(lR(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var dR={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},fR=null;function pR(){return fR||=document.implementation.createHTMLDocument(`title`)}var mR=null;function hR(e){let t=window.trustedTypes;return t?(mR||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),mR.createHTML(e)):e}function gR(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=pR().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&dR[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=hR(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function _R(e){let t=e.querySelectorAll(oI?`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 vR(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 yR={},bR={},xR={touchstart:!0,touchmove:!0},SR=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 CR(e){for(let t in yR){let n=yR[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{OR(e,t)&&!DR(e,t)&&(e.editable||!(t.type in bR))&&n(e,t)},xR[t]?{passive:!0}:void 0)}cI&&e.dom.addEventListener(`input`,()=>null),ER(e)}function wR(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function TR(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 ER(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>DR(e,t))})}function DR(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function OR(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 kR(e,t){!DR(e,t)&&yR[t.type]&&(e.editable||!(t.type in bR))&&yR[t.type](e,t)}bR.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!UR(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(fI&&oI&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),lI&&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,qF(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||tR(e,n)?n.preventDefault():wR(e,`key`)},bR.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},bR.keypress=(e,t)=>{let n=t;if(UR(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||uI&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof Jp)||!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 AR(e){return{left:e.clientX,top:e.clientY}}function jR(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function MR(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 NR(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 PR(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&Xp.isSelectable(r)?(NR(e,new Xp(n),`pointer`),!0):!1}function FR(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof Xp&&(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(Xp.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:(NR(e,Xp.create(e.state.doc,i),`pointer`),!0)}function IR(e,t,n,r,i){return MR(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?FR(e,n):PR(e,n))}function LR(e,t,n,r){return MR(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function RR(e,t,n,r){return MR(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||zR(e,n,r)}function zR(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(NR(e,Jp.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)NR(e,Jp.create(r,a+1,a+1+n.content.size),`pointer`);else if(Xp.isSelectable(n))NR(e,Xp.create(r,a),`pointer`);else continue;return!0}}function BR(e){return XR(e)}var VR=uI?`metaKey`:`ctrlKey`;yR.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=BR(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&jR(n,e.input.lastClick)&&!n[VR]&&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(AR(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new HR(e,o,n,!!r)):(a==`doubleClick`?LR:RR)(e,o.pos,o.inside,n)?n.preventDefault():wR(e,`pointer`))};var HR=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[VR],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 Xp&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&iI&&!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)),wR(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(()=>wL(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(AR(e))),this.updateAllowDefault(e),this.allowDefault||!t?wR(this.view,`pointer`):IR(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||cI&&this.mightDrag&&!this.mightDrag.node.isAtom||oI&&!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)?(NR(this.view,Wp.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):wR(this.view,`pointer`)}move(e){this.updateAllowDefault(e),wR(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)}};yR.touchstart=e=>{e.input.lastTouch=Date.now(),BR(e),wR(e,`pointer`)},yR.touchmove=e=>{e.input.lastTouch=Date.now(),wR(e,`pointer`)},yR.contextmenu=e=>BR(e);function UR(e,t){return e.composing?!0:cI&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var WR=fI?5e3:-1;bR.compositionstart=bR.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof Jp&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||oI&&dI&&GR(e)))e.markCursor=e.state.storedMarks||n.marks(),XR(e,!0),e.markCursor=null;else if(XR(e,!t.selection.empty),iI&&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}KR(e,WR)};function GR(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`}bR.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++,KR(e,20))};function KR(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>XR(e),t))}function qR(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=YR());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function JR(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=HF(t.focusNode,t.focusOffset),r=UF(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 YR(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function XR(e,t=!1){if(!(fI&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),qR(e),t||e.docView&&e.docView.dirty){let n=SL(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 ZR(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 QR=nI&&rI<15||lI&&mI<604;yR.copy=bR.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=QR?null:n.clipboardData,{dom:o,text:s}=nR(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):ZR(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function $R(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function ez(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?tz(e,r.value,null,i,t):tz(e,r.textContent,r.innerHTML,i,t)},50)}function tz(e,t,n,r,i){let a=rR(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=$R(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 nz(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,` `):``}bR.paste=(e,t)=>{let n=t;if(e.composing&&!fI)return;let r=QR?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&tz(e,nz(r),r.getData(`text/html`),i,n)?n.preventDefault():ez(e,n)};var rz=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},iz=uI?`altKey`:`ctrlKey`;function az(e,t){return e.someProp(`dragCopies`,e=>!e(t))??!t[iz]}yR.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(AR(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Xp?i.to-1:i.to))){if(r&&r.mightDrag)o=Xp.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=Xp.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=nR(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!oI||sI>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(QR?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,QR||n.dataTransfer.setData(`text/plain`,c),e.dragging=new rz(l,az(e,n),o)},yR.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},bR.dragover=bR.dragenter=(e,t)=>t.preventDefault(),bR.drop=(e,t)=>{try{oz(e,t,e.dragging)}finally{e.dragging=null}};function oz(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(AR(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=rR(e,nz(t.dataTransfer),QR?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&az(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?Cp(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&&Xp.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new Xp(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(NL(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}yR.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())&&wL(e)},20))},yR.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)},yR.beforeinput=(e,t)=>{if(oI&&fI&&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,qF(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 bR)yR[e]=bR[e];function sz(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 cz=class e{constructor(e,t){this.toDOM=e,this.spec=t||pz,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 dz(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&&sz(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},lz=class e{constructor(e,t){this.attrs=e,this.spec=t||pz}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 dz(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&sz(this.attrs,t.attrs)&&sz(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},uz=class e{constructor(e,t){this.attrs=e,this.spec=t||pz}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 dz(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&&sz(this.attrs,t.attrs)&&sz(this.spec,t.spec)}destroy(){}},dz=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 cz(n,r))}static inline(t,n,r,i){return new e(t,n,new lz(r,i))}static node(t,n,r,i){return new e(t,n,new uz(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof lz}get widget(){return this.type instanceof cz}},fz=[],pz={},mz=class e{constructor(e,t){this.local=e.length?e:fz,this.children=t.length?t:fz}static create(e,t){return t.length?Sz(t,e,0,pz):hz}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==hz||e.maps.length==0?this:this.mapInner(e,t,0,0,n||pz)}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?_z(this.children,o||[],t,n,r,i,a):o?new e(o.sort(Cz),fz):hz}add(t,n){return n.length?this==hz?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=bz(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,Sz(s,e,o+1,pz)),a+=3}});let o=vz(a?xz(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(Cz):this.local,i||this.children)}remove(e){return e.length==0||this==hz?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==hz?(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):hz}forChild(t,n){if(this==hz)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 lz){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(Cz),fz);return r?new gz([t,r]):t}return r||hz}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 wz(this.localsInner(e))}localsInner(e){if(this==hz)return fz;if(e.inlineContent||!this.local.some(lz.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof lz||t.push(this.local[e]);return t}forEachSet(e){e(this)}};mz.empty=new mz([],[]),mz.removeOverlap=wz;var hz=mz.empty,gz=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,pz));return e.from(r)}forChild(t,n){if(n.isLeaf)return mz.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=hz&&(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?wz(n?t:t.sort(Cz)):fz}static from(t){switch(t.length){case 0:return hz;case 1:return t[0];default:return new e(t.every(e=>e instanceof mz)?t:t.reduce((e,t)=>e.concat(t instanceof mz?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function _z(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==hz?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=Sz(yz(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 mz(t.sort(Cz),s)}function vz(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 dz(i.from+t,i.to+t,i.type))}return n}function yz(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 bz(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 xz(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function Sz(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=bz(e,t,o+n);if(s){a=!0;let e=Sz(s,t,n+o+1,r);e!=hz&&i.push(o,o+t.nodeSize,e)}});let o=vz(a?xz(e):e,-n).sort(Cz);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 mz(o,i):hz}function Cz(e,t){return e.from-t.from||e.to-t.to}function wz(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),Tz(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),Tz(t,i,r.copy(a.from,r.to)));break}}}return t}function Tz(e,t,n){for(;t<e.length&&Cz(n,e[t])>0;)t++;e.splice(t,0,n)}function Ez(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=hz&&t.push(r)}),e.cursorWrapper&&t.push(mz.create(e.state.doc,[e.cursorWrapper.deco])),gz.from(t)}var Dz={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Oz=nI&&rI<=11,kz=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}},Az=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new kz,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]);nI&&rI<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():cI&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Oz&&(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,Dz)),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(PL(this.view)){if(this.suppressingSelectionUpdates)return wL(this.view);if(nI&&rI<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&RF(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=PF(n))t.add(n);for(let r=e.anchorNode;r;r=PF(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)&&PL(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(iI&&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||Iz(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&&KF(n)&&(c=SL(e))&&c.eq(Wp.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,wL(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),Nz(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Lz(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||wL(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(nI&&rI<=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?NF(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?NF(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}}},jz=new WeakMap,Mz=!1;function Nz(e){if(!jz.has(e)&&(jz.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=iI,Mz)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.`),Mz=!0}}function Pz(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return RF(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Fz(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Pz(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?Pz(e,n):null}function Iz(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 Lz(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 Rz(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}],KF(c)||l.push({node:c.focusNode,offset:c.focusOffset})),oI&&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`)||lf.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:zz,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 zz(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(cI&&/^(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||cI&&/^(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 Bz=/^(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 Vz(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=SL(e,t);if(n&&!e.state.selection.eq(n)){if(oI&&fI&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,qF(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=Rz(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=Kz(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(lI&&e.input.lastIOSEnter>Date.now()-225||fI)&&i.some(e=>e.nodeType==1&&!Bz.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,qF(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof Jp&&!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=Hz(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 Jp&&(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)),nI&&rI<=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((lI&&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,qF(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&Wz(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,qF(8,`Backspace`)))){fI&&oI&&e.domObserver.suppressSelectionUpdates();return}oI&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),fI&&!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,qF(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=Hz(e,n.doc,l.sel);t&&!(oI&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1)||nI&&t.empty&&t.head==y)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},S;if(v)if(h.pos==g.pos){nI&&rI<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>wL(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=Uz(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 Hz(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:NL(e,t.resolve(n.anchor),t.resolve(n.head))}function Uz(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 Wz(e,t,n,r,i){if(n-t<=i.pos-r.pos||Gz(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(Gz(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Gz(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Gz(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 Kz(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&&qz(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&&qz(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function qz(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 Jz=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 SR,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(tB),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=Zz(this),Xz(this),this.nodeViews=$z(this),this.docView=nL(this.state.doc,Yz(this),Ez(this),this.dom,this),this.domObserver=new Az(this,(e,t,n,r)=>Vz(this,e,t,n,r)),this.domObserver.start(),CR(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&&ER(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(tB),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&&(qR(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=$z(this);eB(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&ER(this),this.editable=Zz(this),Xz(this);let o=Ez(this),s=Yz(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&&yI(this);if(i){this.domObserver.stop();let t=l&&(nI||oI)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Qz(n.selection,e.selection);if(l){let n=oI?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=JR(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=nL(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())&&IL(this))?wL(this,t):(jL(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&&xI(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 Xp){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&vI(this,t.getBoundingClientRect(),e)}else vI(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 rz(e.slice,e.move,r<0?void 0:Xp.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(nI){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&&wI(this.dom),wL(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 MI(this,e)}coordsAtPos(e,t=1){return II(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 KI(this,t||this.state,e)}pasteHTML(e,t){return tz(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return tz(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return nR(this,e)}destroy(){this.docView&&(TR(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ez(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,LF())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return kR(this,e)}domSelectionRange(){let e=this.domSelection();return e?cI&&this.root.nodeType===11&&JF(this.dom.ownerDocument)==this.dom&&Fz(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Jz.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Yz(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`,[dz.node(0,e.state.doc.content.size,t)]}function Xz(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:dz.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Zz(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Qz(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 $z(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 eB(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 tB(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 nB={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:`'`},rB={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},iB=typeof navigator<`u`&&/Mac/.test(navigator.platform),aB=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),oB=0;oB<10;oB++)nB[48+oB]=nB[96+oB]=String(oB);for(var oB=1;oB<=24;oB++)nB[oB+111]=`F`+oB;for(var oB=65;oB<=90;oB++)nB[oB]=String.fromCharCode(oB+32),rB[oB]=String.fromCharCode(oB);for(var sB in nB)rB.hasOwnProperty(sB)||(rB[sB]=nB[sB]);function cB(e){var t=!(iB&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||aB&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?rB:nB)[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 lB=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),uB=typeof navigator<`u`&&/Win/.test(navigator.platform);function dB(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))lB?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 fB(e){let t=Object.create(null);for(let n in e)t[dB(n)]=e[n];return t}function pB(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 mB(e){return new fm({props:{handleKeyDown:hB(e)}})}function hB(e){let t=fB(e);return function(e,n){let r=cB(n),i,a=t[pB(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[pB(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(uB&&n.ctrlKey&&n.altKey)&&(i=nB[n.keyCode])&&i!=r){let r=t[pB(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var gB=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function _B(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var vB=(e,t,n)=>{let r=_B(e,n);if(!r)return!1;let i=wB(r);if(!i){let n=r.blockRange(),i=n&&rp(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(HB(e,i,t,-1))return!0;if(r.parent.content.size==0&&(SB(a,`end`)||Xp.isSelectable(a)))for(let n=r.depth;;n--){let o=wp(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(SB(a,`end`)?Wp.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):Xp.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},yB=(e,t,n)=>{let r=_B(e,n);if(!r)return!1;let i=wB(r);return i?xB(e,i,t):!1},bB=(e,t,n)=>{let r=TB(e,n);if(!r)return!1;let i=OB(r);return i?xB(e,i,t):!1};function xB(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=wp(e.doc,i,o,Q.empty);if(!s||s.from!=i||s instanceof Xf&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(Jp.create(t.doc,i)),n(t.scrollIntoView())}return!0}function SB(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 CB=(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=wB(r)}let o=a&&a.nodeBefore;return!o||!Xp.isSelectable(o)?!1:(t&&t(e.tr.setSelection(Xp.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function wB(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 TB(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var EB=(e,t,n)=>{let r=TB(e,n);if(!r)return!1;let i=OB(r);if(!i)return!1;let a=i.nodeAfter;if(HB(e,i,t,1))return!0;if(r.parent.content.size==0&&(SB(a,`start`)||Xp.isSelectable(a))){let n=wp(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(SB(a,`start`)?Wp.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):Xp.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},DB=(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=OB(r)}let o=a&&a.nodeAfter;return!o||!Xp.isSelectable(o)?!1:(t&&t(e.tr.setSelection(Xp.create(e.doc,a.pos)).scrollIntoView()),!0)};function OB(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 kB=(e,t)=>{let n=e.selection,r=n instanceof Xp,i;if(r){if(n.node.isTextblock||!_p(e.doc,n.from))return!1;i=n.from}else if(i=bp(e.doc,n.from,-1),i==null)return!1;if(t){let n=e.tr.join(i);r&&n.setSelection(Xp.create(n.doc,i-e.doc.resolve(i).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},AB=(e,t)=>{let n=e.selection,r;if(n instanceof Xp){if(n.node.isTextblock||!_p(e.doc,n.to))return!1;r=n.to}else if(r=bp(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},jB=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&rp(i);return a==null?!1:(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},MB=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
134
+ `).scrollIntoView()),!0)};function NB(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 PB=(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=NB(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(Wp.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},FB=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof Qp||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=NB(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(Jp.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},IB=(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(hp(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&rp(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function LB(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof Xp&&t.selection.node.isBlock)return!r.parentOffset||!hp(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=NB(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 Jp||t.selection instanceof Qp)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=hp(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,hp(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 RB=LB(),zB=(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(Xp.create(e.doc,i))),!0)},BB=(e,t)=>(t&&t(e.tr.setSelection(new Qp(e.doc))),!0);function VB(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||_p(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function HB(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&VB(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 Zf(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&&_p(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:Wp.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&rp(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&SB(a,`start`,!0)&&SB(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 Zf(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 UB(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(Jp.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var WB=UB(-1),GB=UB(1);function KB(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&ap(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function qB(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 JB(...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 YB=JB(gB,vB,CB),XB=JB(gB,EB,DB),ZB={Enter:JB(MB,FB,IB,RB),"Mod-Enter":PB,Backspace:YB,"Mod-Backspace":YB,"Shift-Backspace":YB,Delete:XB,"Mod-Delete":XB,"Mod-a":BB},QB={"Ctrl-h":ZB.Backspace,"Alt-Backspace":ZB[`Mod-Backspace`],"Ctrl-d":ZB.Delete,"Ctrl-Alt-Backspace":ZB[`Mod-Delete`],"Alt-Delete":ZB[`Mod-Delete`],"Alt-d":ZB[`Mod-Delete`],"Ctrl-a":WB,"Ctrl-e":GB};for(let e in ZB)QB[e]=ZB[e];typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform();function $B(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 eV(s,o,e,t)?(r&&r(s.scrollIntoView()),!0):!1}}function eV(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 jd(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new jd(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let s=ap(a,n,r,t);return s?(e&&tV(e,t,s,i,n),!0):!1}function tV(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 Zf(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&&hp(e.doc,c,s)&&(e.split(c,s),c+=2*s),c+=l.child(n).nodeSize;return e}function nV(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?rV(t,n,e,a):iV(t,n,a):!0:!1}}function rV(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new Zf(a-1,o,a,o,new Q(Z.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new jd(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let s=rp(r);if(s==null)return!1;i.lift(r,s);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return _p(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}function iV(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 Zf(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 aV(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 Zf(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}function oV(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 sV=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:oV({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}},cV=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 lV(e,t,n){return e.config[t]===void 0&&e.parent?lV(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?lV(e.parent,t,n):null}):e.config[t]}function uV(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function dV(e){let t=[],{nodeExtensions:n,markExtensions:r}=uV(e),i=[...n,...r],a={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(e=>{let n=lV(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=lV(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 fV(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 pV(...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 mV(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)=>pV(e,t),{})}function hV(e){return typeof e==`function`}function gV(e,t=void 0,...n){return hV(e)?t?e.bind(t)(...n):e(...n):e}function _V(e={}){return Object.keys(e).length===0&&e.constructor===Object}function vV(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`?!0:e===`false`?!1:e:e}function yV(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):vV(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function bV(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&_V(t)?!1:t!=null))}function xV(e,t){let n=dV(e),{nodeExtensions:r,markExtensions:i}=uV(e);return new af({topNode:r.find(e=>lV(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=bV({...e.reduce((e,t)=>{let n=lV(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:gV(lV(r,`content`,a)),marks:gV(lV(r,`marks`,a)),group:gV(lV(r,`group`,a)),inline:gV(lV(r,`inline`,a)),atom:gV(lV(r,`atom`,a)),selectable:gV(lV(r,`selectable`,a)),draggable:gV(lV(r,`draggable`,a)),code:gV(lV(r,`code`,a)),whitespace:gV(lV(r,`whitespace`,a)),linebreakReplacement:gV(lV(r,`linebreakReplacement`,a)),defining:gV(lV(r,`defining`,a)),isolating:gV(lV(r,`isolating`,a)),attrs:Object.fromEntries(i.map(e=>[e.name,{default:e?.attribute?.default}]))}),s=gV(lV(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>yV(e,i)));let c=lV(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:mV(e,i)}));let l=lV(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=bV({...e.reduce((e,t)=>{let n=lV(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:gV(lV(r,`inclusive`,a)),excludes:gV(lV(r,`excludes`,a)),group:gV(lV(r,`group`,a)),spanning:gV(lV(r,`spanning`,a)),code:gV(lV(r,`code`,a)),attrs:Object.fromEntries(i.map(e=>[e.name,{default:e?.attribute?.default}]))}),s=gV(lV(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>yV(e,i)));let c=lV(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:mV(e,i)})),[r.name,o]}))})}function SV(e,t){return t.nodes[e]||t.marks[e]||null}function CV(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function wV(e,t){let n=Cf.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}var TV=(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 EV(e){return Object.prototype.toString.call(e)===`[object RegExp]`}var DV=class{constructor(e){this.find=e.find,this.handler=e.handler}},OV=(e,t)=>{if(EV(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 kV(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=TV(c)+i;return a.forEach(e=>{if(l)return;let a=OV(u,e.find);if(!a)return;let c=s.state.tr,d=oV({state:s.state,transaction:c}),f={from:n-(a[0].length-i.length),to:r},{commands:p,chain:m,can:h}=new sV({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 AV(e){let{editor:t,rules:n}=e,r=new fm({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:wV(Z.from(e),a.schema);let{from:i}=s;kV({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 kV({editor:t,from:i,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&kV({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?kV({editor:t,from:a.pos,to:a.pos,text:`
135
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function jV(e){return Object.prototype.toString.call(e).slice(8,-1)}function MV(e){return jV(e)===`Object`?e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype:!1}function NV(e,t){let n={...e};return MV(e)&&MV(t)&&Object.keys(t).forEach(r=>{MV(t[r])&&MV(e[r])?n[r]=NV(e[r],t[r]):n[r]=t[r]}),n}var PV=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=gV(lV(this,`addOptions`,{name:this.name}))),this.storage=gV(lV(this,`addStorage`,{name:this.name,options:this.options}))||{}}static create(t={}){return new e(t)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>NV(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=gV(lV(n,`addOptions`,{name:n.name})),n.storage=gV(lV(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 FV(e){return typeof e==`number`}var IV=class{constructor(e){this.find=e.find,this.handler=e.handler}},LV=(e,t,n)=>{if(EV(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 RV(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new sV({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);LV(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 zV=null,BV=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function VV(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(!(!RV({editor:t,state:oV({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 fm({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(zV=t)},i=()=>{zV&&=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=zV;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:wV(Z.from(t),r.schema);let{from:n}=d,i=n+t.length,a=BV(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(!(!FV(p)||!m||p===m.b))return c({rule:e,state:r,from:p,to:m,pasteEvt:o})}}))}function HV(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}var UV=class e{constructor(t,n){this.splittableMarks=[],this.editor=n,this.extensions=e.resolve(t),this.schema=xV(this.extensions,n),this.setupExtensions()}static resolve(t){let n=e.sort(e.flatten(t)),r=HV(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=lV(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=lV(e,`priority`)||100,r=lV(t,`priority`)||100;return n>r?-1:+(n<r)})}get commands(){return this.extensions.reduce((e,t)=>{let n=lV(t,`addCommands`,{name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:SV(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:SV(e.name,this.schema)},a=[],o=lV(e,`addKeyboardShortcuts`,n),s={};if(e.type===`mark`&&lV(e,`exitable`,n)&&(s.ArrowRight=()=>PV.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=mB(s);a.push(c);let l=lV(e,`addInputRules`,n);CV(e,t.options.enableInputRules)&&l&&r.push(...l());let u=lV(e,`addPasteRules`,n);CV(e,t.options.enablePasteRules)&&u&&i.push(...u());let d=lV(e,`addProseMirrorPlugins`,n);if(d){let e=d();a.push(...e)}return a}).flat();return[AV({editor:t,rules:r}),...VV({editor:t,rules:i}),...a]}get attributes(){return dV(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=uV(this.extensions);return Object.fromEntries(t.filter(e=>!!lV(e,`addNodeView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=lV(t,`addNodeView`,{name:t.name,options:t.options,storage:t.storage,editor:e,type:fV(t.name,this.schema)});return r?[t.name,(i,a,o,s,c)=>{let l=mV(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:SV(e.name,this.schema)};e.type===`mark`&&(gV(lV(e,`keepOnSplit`,t))??!0)&&this.splittableMarks.push(e.name);let n=lV(e,`onBeforeCreate`,t),r=lV(e,`onCreate`,t),i=lV(e,`onUpdate`,t),a=lV(e,`onSelectionUpdate`,t),o=lV(e,`onTransaction`,t),s=lV(e,`onFocus`,t),c=lV(e,`onBlur`,t),l=lV(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)})}},WV=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=gV(lV(this,`addOptions`,{name:this.name}))),this.storage=gV(lV(this,`addStorage`,{name:this.name,options:this.options}))||{}}static create(t={}){return new e(t)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>NV(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=gV(lV(n,`addOptions`,{name:n.name})),n.storage=gV(lV(n,`addStorage`,{name:n.name,options:n.options})),n}};function GV(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=`
136
+
137
+ `,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 KV(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}var qV=WV.create({name:`clipboardTextSerializer`,addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new fm({key:new hm(`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=KV(n);return GV(r,{from:o,to:s},{...this.options.blockSeparator===void 0?{}:{blockSeparator:this.options.blockSeparator},textSerializers:c})}}})]}}),JV=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),YV=(e=!1)=>({commands:t})=>t.setContent(``,e),XV=()=>({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=rp(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},ZV=e=>t=>e(t),QV=()=>({state:e,dispatch:t})=>FB(e,t),$V=(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 Jp(r.doc.resolve(Math.max(o-1,0)))),!0},eH=()=>({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},tH=e=>({tr:t,state:n,dispatch:r})=>{let i=fV(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},nH=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},rH=()=>({state:e,dispatch:t})=>gB(e,t),iH=()=>({commands:e})=>e.keyboardShortcut(`Enter`),aH=()=>({state:e,dispatch:t})=>PB(e,t);function oH(e,t,n={strict:!0}){let r=Object.keys(t);return r.length?r.every(r=>n.strict?t[r]===e[r]:EV(t[r])?t[r].test(e[r]):t[r]===e[r]):!0}function sH(e,t,n={}){return e.find(e=>e.type===t&&oH(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function cH(e,t,n={}){return!!sH(e,t,n)}function lH(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,!sH([...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&&cH([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o<e.parent.childCount&&cH([...e.parent.child(o).marks],t,n);)s+=e.parent.child(o).nodeSize,o+=1;return{from:a,to:s}}function uH(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 dH=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=uH(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=lH(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=Jp.create(o,e.from,e.to);n.setSelection(t)}}return!0},fH=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 pH(e){return e instanceof Jp}function mH(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function hH(e,t=null){if(!t)return null;let n=Wp.atStart(e),r=Wp.atEnd(e);if(t===`start`||t===!0)return n;if(t===`end`)return r;let i=n.from,a=r.to;return t===`all`?Jp.create(e,mH(0,i,a),mH(e.content.size,i,a)):Jp.create(e,mH(t,i,a),mH(t,i,a))}function gH(){return navigator.platform===`Android`||/android/i.test(navigator.userAgent)}function _H(){return[`iPad Simulator`,`iPhone Simulator`,`iPod Simulator`,`iPad`,`iPhone`,`iPod`].includes(navigator.platform)||navigator.userAgent.includes(`Mac`)&&`ontouchend`in document}function vH(){return typeof navigator<`u`?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var yH=(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(_H()||gH())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),vH()&&!_H()&&!gH()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&e===null||e===!1)return!0;if(a&&e===null&&!pH(n.state.selection))return o(),!0;let s=hH(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},bH=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),xH=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),SH=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&&SH(r)}return e};function CH(e){let t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return SH(n)}function wH(e,t,n){if(e instanceof Nd||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),wH(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new af({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?lf.fromSchema(a).parseSlice(CH(e),n.parseOptions):lf.fromSchema(a).parse(CH(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=lf.fromSchema(t);return n.slice?r.parseSlice(CH(e),n.parseOptions).content:r.parse(CH(e),n.parseOptions)}return wH(``,t,n)}function TH(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof Xf||i instanceof Zf))return;let a=e.mapping.maps[r],o=0;a.forEach((e,t,n,r)=>{o===0&&(o=r)}),e.setSelection(Wp.near(e.doc.resolve(o),n))}var EH=e=>!(`type`in e),DH=(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{wH(t,a.schema,{parseOptions:s,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=wH(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((EH(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&&TH(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},OH=()=>({state:e,dispatch:t})=>kB(e,t),kH=()=>({state:e,dispatch:t})=>AB(e,t),AH=()=>({state:e,dispatch:t})=>vB(e,t),jH=()=>({state:e,dispatch:t})=>EB(e,t),MH=()=>({state:e,dispatch:t,tr:n})=>{try{let r=bp(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},NH=()=>({state:e,dispatch:t,tr:n})=>{try{let r=bp(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},PH=()=>({state:e,dispatch:t})=>yB(e,t),FH=()=>({state:e,dispatch:t})=>bB(e,t);function IH(){return typeof navigator<`u`?/Mac/.test(navigator.platform):!1}function LH(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))_H()||IH()?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 RH=e=>({editor:t,view:n,tr:r,dispatch:i})=>{let a=LH(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 zH(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?fV(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=>oH(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var BH=(e,t={})=>({state:n,dispatch:r})=>zH(n,fV(e,n.schema),t)?jB(n,r):!1,VH=()=>({state:e,dispatch:t})=>IB(e,t),HH=e=>({state:t,dispatch:n})=>nV(fV(e,t.schema))(t,n),UH=()=>({state:e,dispatch:t})=>MB(e,t);function WH(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function GH(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 KH=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=WH(typeof e==`string`?e:e.name,r.schema);return s?(s===`node`&&(a=fV(e,r.schema)),s===`mark`&&(o=uH(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,GH(e.attrs,t)),o&&e.marks.length&&e.marks.forEach(i=>{o===i.type&&n.addMark(r,r+e.nodeSize,o.create(GH(i.attrs,t)))})})}),!0):!1},qH=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),JH=()=>({tr:e,dispatch:t})=>{if(t){let t=new Qp(e.doc);e.setSelection(t)}return!0},YH=()=>({state:e,dispatch:t})=>CB(e,t),XH=()=>({state:e,dispatch:t})=>DB(e,t),ZH=()=>({state:e,dispatch:t})=>zB(e,t),QH=()=>({state:e,dispatch:t})=>GB(e,t),$H=()=>({state:e,dispatch:t})=>WB(e,t);function eU(e,t,n={},r={}){return wH(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var tU=(e,t=!1,n={},r={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(n.preserveWhitespace!==`full`){let s=eU(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 nU(e,t){let n=uH(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 rU(e,t){let n=new Hp(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function iU(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 aU(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}function oU(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 sU(e){return t=>oU(t.$from,e)}function cU(e,t){return GV(e,{from:0,to:e.content.size},t)}function lU(e,t){let n=fV(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 uU(e,t){let n=WH(typeof t==`string`?t:t.name,e.schema);return n===`node`?lU(e,t):n===`mark`?nU(e,t):{}}function dU(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 fU(e){let t=dU(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 pU(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}})})}),fU(r)}function mU(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=lH(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 hU(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 gU(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?uH(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>a?a.name===e.type.name:!0).find(e=>oH(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=>oH(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 _U(e,t,n={}){if(!t)return zH(e,null,n)||gU(e,null,n);let r=WH(t,e.schema);return r===`node`?zH(e,t,n):r===`mark`?gU(e,t,n):!1}function vU(e,t){let{nodeExtensions:n}=uV(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=gV(lV(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`?i.split(` `).includes(`list`):!1}function yU(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&&(yU(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function bU(e){return e instanceof Xp}function xU(e,t,n){let{selection:r}=t,i=null;if(pH(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 SU=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=uH(e,r.schema);if(i)if(o){let e=nU(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 xU(r,n,c)},CU=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),wU=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=fV(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>qB(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>qB(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},TU=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=mH(e,0,n.content.size),i=Xp.create(n,r);t.setSelection(i)}return!0},EU=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=Jp.atStart(n).from,o=Jp.atEnd(n).to,s=mH(r,a,o),c=mH(i,a,o),l=Jp.create(n,s,c);t.setSelection(l)}return!0},DU=e=>({state:t,dispatch:n})=>aV(fV(e,t.schema))(t,n);function OU(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 kU=({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=hU(l,s.node().type.name,s.node().attrs);if(a instanceof Xp&&a.node.isBlock)return!s.parentOffset||!hp(o,s.pos)?!1:(r&&(e&&OU(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:iU(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=hp(t.doc,t.mapping.map(s.pos),1,p);if(!p&&!m&&hp(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 Jp&&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&&OU(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return m},AU=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=fV(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={...hU(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(Jp.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}let f=c.pos===s.end()?u.contentMatchAt(0).defaultType:null,p={...hU(d,u.type.name,u.attrs),...t},m={...hU(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(!hp(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},jU=(e,t)=>{let n=sU(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&&_p(e.doc,n.pos)&&e.join(n.pos),!0},MU=(e,t)=>{let n=sU(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&&_p(e.doc,r)&&e.join(r),!0},NU=Object.freeze({__proto__:null,blur:JV,clearContent:YV,clearNodes:XV,command:ZV,createParagraphNear:QV,cut:$V,deleteCurrentNode:eH,deleteNode:tH,deleteRange:nH,deleteSelection:rH,enter:iH,exitCode:aH,extendMarkRange:dH,first:fH,focus:yH,forEach:bH,insertContent:xH,insertContentAt:DH,joinBackward:AH,joinDown:kH,joinForward:jH,joinItemBackward:MH,joinItemForward:NH,joinTextblockBackward:PH,joinTextblockForward:FH,joinUp:OH,keyboardShortcut:RH,lift:BH,liftEmptyBlock:VH,liftListItem:HH,newlineInCode:UH,resetAttributes:KH,scrollIntoView:qH,selectAll:JH,selectNodeBackward:YH,selectNodeForward:XH,selectParentNode:ZH,selectTextblockEnd:QH,selectTextblockStart:$H,setContent:tU,setMark:SU,setMeta:CU,setNode:wU,setNodeSelection:TU,setTextSelection:EU,sinkListItem:DU,splitBlock:kU,splitListItem:AU,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=fV(e,o.schema),m=fV(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=sU(e=>vU(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(vU(x.node.type.name,d)&&p.validContent(x.node.content)&&s)return c().command(()=>(a.setNodeMarkup(x.pos,p),!0)).command(()=>jU(a,p)).command(()=>MU(a,p)).run()}return!n||!b||!s?c().command(()=>u().wrapInList(p,r)?!0:l.clearNodes()).wrapInList(p,r).command(()=>jU(a,p)).command(()=>MU(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(()=>jU(a,p)).command(()=>MU(a,p)).run()},toggleMark:(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=uH(e,r.schema);return gU(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},toggleNode:(e,t,n={})=>({state:r,commands:i})=>{let a=fV(e,r.schema),o=fV(t,r.schema),s=zH(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=fV(e,n.schema);return zH(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=uH(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=lH(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=WH(typeof e==`string`?e:e.name,r.schema);return s?(s===`node`&&(a=fV(e,r.schema)),s===`mark`&&(o=uH(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})=>KB(fV(e,n.schema),t)(n,r),wrapInList:(e,t={})=>({state:n,dispatch:r})=>$B(fV(e,n.schema),t)(n,r)}),PU=WV.create({name:`commands`,addCommands(){return{...NU}}}),FU=WV.create({name:`drop`,addProseMirrorPlugins(){return[new fm({key:new hm(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),IU=WV.create({name:`editable`,addProseMirrorPlugins(){return[new fm({key:new hm(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),LU=new hm(`focusEvents`),RU=WV.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new fm({key:LU,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}}}})]}}),zU=WV.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:Wp.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 _H()||IH()?i:r},addProseMirrorPlugins(){return[new fm({key:new hm(`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=Wp.atStart(t.doc).from,l=Wp.atEnd(t.doc).to;if(a||!(o===c&&s===l)||!yU(n.doc))return;let u=n.tr,d=oV({state:n,transaction:u}),{commands:f}=new sV({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),BU=WV.create({name:`paste`,addProseMirrorPlugins(){return[new fm({key:new hm(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),VU=WV.create({name:`tabindex`,addProseMirrorPlugins(){return[new fm({key:new hm(`tabindex`),props:{attributes:()=>this.editor.isEditable?{tabindex:`0`}:{}}})]}}),HU=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)}},UU=`.ProseMirror {
138
+ position: relative;
139
+ }
140
+
141
+ .ProseMirror {
142
+ word-wrap: break-word;
143
+ white-space: pre-wrap;
144
+ white-space: break-spaces;
145
+ -webkit-font-variant-ligatures: none;
146
+ font-variant-ligatures: none;
147
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
148
+ }
149
+
150
+ .ProseMirror [contenteditable="false"] {
151
+ white-space: normal;
152
+ }
153
+
154
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
155
+ white-space: pre-wrap;
156
+ }
157
+
158
+ .ProseMirror pre {
159
+ white-space: pre-wrap;
160
+ }
161
+
162
+ img.ProseMirror-separator {
163
+ display: inline !important;
164
+ border: none !important;
165
+ margin: 0 !important;
166
+ width: 0 !important;
167
+ height: 0 !important;
168
+ }
169
+
170
+ .ProseMirror-gapcursor {
171
+ display: none;
172
+ pointer-events: none;
173
+ position: absolute;
174
+ margin: 0;
175
+ }
176
+
177
+ .ProseMirror-gapcursor:after {
178
+ content: "";
179
+ display: block;
180
+ position: absolute;
181
+ top: -2px;
182
+ width: 20px;
183
+ border-top: 1px solid black;
184
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
185
+ }
186
+
187
+ @keyframes ProseMirror-cursor-blink {
188
+ to {
189
+ visibility: hidden;
190
+ }
191
+ }
192
+
193
+ .ProseMirror-hideselection *::selection {
194
+ background: transparent;
195
+ }
196
+
197
+ .ProseMirror-hideselection *::-moz-selection {
198
+ background: transparent;
199
+ }
200
+
201
+ .ProseMirror-hideselection * {
202
+ caret-color: transparent;
203
+ }
204
+
205
+ .ProseMirror-focused .ProseMirror-gapcursor {
206
+ display: block;
207
+ }
208
+
209
+ .tippy-box[data-animation=fade][data-state=hidden] {
210
+ opacity: 0
211
+ }`;function WU(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 GU=class extends cV{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=WU(UU,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=hV(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?[IU,qV.configure({blockSeparator:this.options.coreExtensionOptions?.clipboardTextSerializer?.blockSeparator}),PU,RU,zU,VU,FU,BU].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 UV(e,this)}createCommandManager(){this.commandManager=new sV({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){let e;try{e=eU(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=eU(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}let t=hH(e,this.options.autofocus);this.view=new Jz(this.options.element,{...this.options.editorProps,attributes:{role:`textbox`,...this.options.editorProps?.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:um.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 uU(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return _U(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return wV(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=`
212
+
213
+ `,textSerializers:n={}}=e||{};return cU(this.state.doc,{blockSeparator:t,textSerializers:{...KV(this.schema),...n}})}get isEmpty(){return yU(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 HU(this.state.doc.resolve(e),this)}get $doc(){return this.$pos(0)}};function KU(e){return new DV({find:e.find,handler:({state:t,range:n,match:r})=>{let i=gV(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(mU(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 qU(e){return new DV({find:e.find,handler:({state:t,range:n,match:r})=>{let i=gV(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 JU(e){return new DV({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=gV(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 YU(e){return new DV({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 XU(e){return new DV({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=gV(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&ap(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&&_p(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)}})}var ZU=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=gV(lV(this,`addOptions`,{name:this.name}))),this.storage=gV(lV(this,`addStorage`,{name:this.name,options:this.options}))||{}}static create(t={}){return new e(t)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>NV(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=gV(lV(n,`addOptions`,{name:n.name})),n.storage=gV(lV(n,`addStorage`,{name:n.name,options:n.options})),n}};function QU(e){return new IV({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=gV(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(mU(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 $U(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof Xp){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 eW=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},tW=/[\uD800-\uDBFF]/,nW=/[\uDC00-\uDFFF]/,rW=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&tW.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&&nW.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},iW=new hm(`y-sync`),aW=new hm(`y-undo`),oW=new hm(`yjs-cursor`),sW=(e,t)=>e>>>t|e<<32-t,cW=e=>sW(e,2)^sW(e,13)^sW(e,22),lW=e=>sW(e,6)^sW(e,11)^sW(e,25),uW=e=>sW(e,7)^sW(e,18)^e>>>3,dW=e=>sW(e,17)^sW(e,19)^e>>>10,fW=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]),pW=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),mW=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(pW),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=dW(t[e-2])+t[e-7]+uW(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+lW(o)+(o&s^~o&c)+fW[e]+t[e]>>>0,d=cW(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/Wy,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}},hW=e=>new mW().digest(e),gW=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},_W=e=>zx(gW(hW(Vx(e)))),vW=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!NC(t.ds,e.id),yW=[{light:`#ecd44433`,dark:`#ecd444`}],bW=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=vy();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,rx(t))}return e.get(n)},xW=(e,{colors:t=yW,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new wW(e,a),c=new fm({props:{editable:e=>{let t=iW.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:iW,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(iW);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)&&lC(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=aW.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)},iW)})}},destroy:()=>{s.destroy()}})});return c},SW=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new Qp(e.doc));else if(t.type===`node`){let r=ZW(n.doc,n.type,t.anchor,n.mapping);e.setSelection(Xp.create(e.doc,r))}else{let r=ZW(n.doc,n.type,t.anchor,n.mapping),i=ZW(n.doc,n.type,t.head,n.mapping);if(r!==null&&i!==null){let t=Jp.between(e.doc.resolve(r),e.doc.resolve(i));e.setSelection(t)}}},CW=(e,t)=>({type:t.selection.jsonID,anchor:YW(t.selection.anchor,e.type,e.mapping),head:YW(t.selection.head,e.type,e.mapping)}),wW=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=eW(),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=CW(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()?(kx&&this._domSelectionInView===null&&(lC(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=nC.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||=Fw(LC(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(iW,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>EW(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(iW,{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=>EW(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=ky(Ay(e.anchor,0),n.doc.content.size),r=ky(Ay(e.head,0),n.doc.content.size);n.setSelection(Jp.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(iW,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=Iw(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&Fb(),r=new UC({gc:!1}),iw(r,t),t=Iw(r),iw(r,e),e=Iw(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[Uw(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{jC(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:bW(n.colorMapping,n.colors,r)}},s=IT(i,new Pw(t.ds,e.sv)).map(n=>!n._item.deleted||vW(n._item,e)||vW(n._item,t)?EW(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(iW,{isChangeOrigin:!0}))},iW)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=iW.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);jC(t,t.deleteSet,e=>{if(e.constructor===hD){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=>TW(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));SW(r,this.beforeTransactionSelection,this),r=r.setMeta(iW,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof sT}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{WW(this.doc,this.type,e,this),this.beforeTransactionSelection=CW(this,this.prosemirrorView.state)},iW)}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))}},TW=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof EE)return EW(e,t,n,r,i,a);throw Pb()}return o},EW=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof EE){let s=TW(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof xE&&!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=DW(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):IT(e,new Pw(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&(vW(e._item,r)?vW(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)},iW),n.mapping.delete(e),null}},DW=(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,HW(n.attributes,t)))}}catch{return e.doc.transact(t=>{e._item.delete(t)},iW),null}return o},OW=(e,t)=>{let n=new jE,r=e.map(e=>({insert:e.text,attributes:UW(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},kW=(e,t)=>{let n=new EE(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,NW(e).map(e=>AW(e,t))),t.mapping.set(n,e),n},AW=(e,t)=>e instanceof Array?OW(e,t):kW(e,t),jW=e=>typeof e==`object`&&!!e,MW=(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||jW(o)&&jW(s)&&MW(o,s)}return r},NW=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},PW=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&hx(e.attributes||{}).length===t[n].marks.length&&yx(e.attributes,(e,r)=>{let i=VW(r),a=t[n].marks;return MW(e,a.find(e=>e.type.name===i)?.attrs)}))},FW=(e,t)=>{if(e instanceof EE&&!(t instanceof Array)&&GW(e,t)){let n=NW(t);return e._length===n.length&&MW(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>FW(e,n[t]))}return e instanceof jE&&t instanceof Array&&PW(e,t)},IW=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),LW=(e,t,n)=>{let r=e.toArray(),i=NW(t),a=i.length,o=r.length,s=ky(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(IW(n.mapping.get(e),t))u=!0;else if(!FW(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(IW(n.mapping.get(e),t))u=!0;else if(!FW(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},RW=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof QE?t+=n.content.str:n.content instanceof GE&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},zW=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=RW(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,UW(e.marks,n))})),{insert:o,remove:s,index:c}=rW(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})))},BW=/(.*)(--[a-zA-Z0-9+/=]{8})$/,VW=e=>BW.exec(e)?.[1]??e,HW=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(VW(r),e[r]));return n},UW=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=hy(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${_W(e.toJSON())}`:e.type.name]=e.attrs}}),n},WW=(e,t,n,r)=>{if(t instanceof EE&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof EE){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=NW(n),a=i.length,o=t.toArray(),s=o.length,c=ky(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!IW(r.mapping.get(e),t))if(FW(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(!IW(r.mapping.get(e),t))if(FW(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 jE&&c instanceof Array)PW(n,c)||zW(n,c,r),l+=1;else{let i=n instanceof EE&&GW(n,c),a=d instanceof EE&&GW(d,f);if(i&&a){let e=LW(n,c,r),t=LW(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(WW(e,n,c,r),l+=1):a?(WW(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[AW(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof jE?(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(AW(i[t],r));t.insert(l,e)}},iW)},GW=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,KW=null,qW=()=>{let e=KW;KW=null,e.forEach((e,t)=>{let n=t.state.tr,r=iW.getState(t.state);r&&r.binding&&!r.binding.isDestroyed&&(e.forEach((e,t)=>{n.setMeta(t,e)}),t.dispatch(n))})},JW=(e,t,n)=>{KW||(KW=new Map,lC(0,qW)),hy(KW,e,py).set(t,n)},YW=(e,t,n)=>{if(e===0)return Aw(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 jE){if(r._length>=e)return Aw(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 Tw(r._item===null?null:r._item.id,r._item===null?Cw(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 Tw(r._item===null?null:r._item.id,r._item===null?Cw(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 Fb();if(e===0&&r.constructor!==jE&&r!==t)return XW(r._item.parent,r._item)}return Aw(t,t._length,t.length===0?-1:0)},XW=(e,t)=>{let n=null,r=null;return e._item===null?r=Cw(e):n=Sw(e._item.id.client,e._item.id.clock),new Tw(n,r,t.id)},ZW=(e,t,n,r)=>{let i=Mw(n,e);if(i===null||i.type!==t&&!ww(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===jE)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 jE?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 jE?o+=e._length:o+=r.get(e).nodeSize),t=t.right}}a=e}return o-1};function QW(e){let t=e.toArray(),n=e=>{let t;if(e instanceof jE)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:VW(t)};return Object.keys(n)&&(r.attrs=n),r})),t});else if(e instanceof EE){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 Fb();return t};return{type:`doc`,content:t.map(n)}}var $W=(e,t,n)=>e!==t,eG=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},tG=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),nG=/^#[0-9a-fA-F]{6}$/,rG=(e,t,n,r,i)=>{let a=iW.getState(e),o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?mz.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`:nG.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`;let l=ZW(o,a.type,Ew(t.cursor.anchor),a.binding.mapping),u=ZW(o,a.type,Ew(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=Ay(e.doc.content.size-1,0);l=ky(l,t),u=ky(u,t),s.push(dz.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=ky(l,u),o=Ay(l,u);s.push(dz.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),mz.create(e.doc,s))},iG=(e,{awarenessStateFilter:t=$W,cursorBuilder:n=eG,selectionBuilder:r=tG,getSelection:i=e=>e.selection}={},a=`cursor`)=>new fm({key:oW,state:{init(i,a){return rG(a,e,t,n,r)},apply(i,a,o,s){let c=iW.getState(s),l=i.getMeta(oW);return c&&c.isChangeOrigin||l&&l.awarenessUpdated?rG(s,e,t,n,r):a.map(i.mapping,i.doc)}},props:{decorations:e=>oW.getState(e)},view:t=>{let n=()=>{t.docView&&JW(t,oW,{awarenessUpdated:!0})},r=()=>{let n=iW.getState(t.state),r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=YW(o.anchor,n.type,n.binding.mapping),c=YW(o.head,n.type,n.binding.mapping);(r.cursor==null||!Nw(Ew(r.cursor.anchor),s)||!Nw(Ew(r.cursor.head),c))&&e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&ZW(n.doc,n.type,Ew(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)}}}}),aG=e=>aW.getState(e)?.undoManager?.undo()!=null,oG=e=>aW.getState(e)?.undoManager?.redo()!=null,sG=new Set([`paragraph`]),cG=(e,t)=>!(e instanceof hD)||!(e.content instanceof cD)||!(e.content.type instanceof xE||e.content.type instanceof EE&&t.has(e.content.type.nodeName))||e.content.type._length===0,lG=({protectedNodes:e=sG,trackedOrigins:t=[],undoManager:n=null}={})=>new fm({key:aW,state:{init:(r,i)=>{let a=iW.getState(i),o=n||new sT(a.type,{trackedOrigins:new Set([iW].concat(t)),deleteFilter:t=>cG(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=iW.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:CW(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=iW.getState(e.state),n=aW.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,aW.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()}}}}),uG=WV.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),aW.getState(t).undoManager.undoStack.length===0?!1:n?aG(t):!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),aW.getState(t).undoManager.redoStack.length===0?!1:n?oG(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=lG(this.options.yUndoOptions),r=n.spec.view;n.spec.view=e=>{let{undoManager:t}=aW.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=xW(t,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender});return this.editor.options.enableContentCheck&&((e=t.doc)==null||e.on(`beforeTransaction`,()=>{try{let e=QW(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 fm({key:new hm(`filterInvalidContent`),filterTransaction:()=>{var e;return this.storage.isDisabled&&((e=t.doc)==null||e.destroy()),!0}})].filter(Boolean)}}),dG=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t.user})),fG=()=>null,pG=WV.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:tG,onUpdate:fG}},onCreate(){if(this.options.onUpdate!==fG&&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[iG((this.options.provider.awareness.setLocalStateField(`user`,this.options.user),this.storage.users=dG(this.options.provider.awareness.states),this.options.provider.awareness.on(`update`,()=>{this.storage.users=dG(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),mG=e=>YU({find:/--$/,replace:e??`—`}),hG=e=>YU({find:/\.\.\.$/,replace:e??`…`}),gG=e=>YU({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:e??`“`}),_G=e=>YU({find:/"$/,replace:e??`”`}),vG=e=>YU({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:e??`‘`}),yG=e=>YU({find:/'$/,replace:e??`’`}),bG=e=>YU({find:/<-$/,replace:e??`←`}),xG=e=>YU({find:/->$/,replace:e??`→`}),SG=e=>YU({find:/\(c\)$/,replace:e??`©`}),CG=e=>YU({find:/\(tm\)$/,replace:e??`™`}),wG=e=>YU({find:/\(sm\)$/,replace:e??`℠`}),TG=e=>YU({find:/\(r\)$/,replace:e??`®`}),EG=e=>YU({find:/(?:^|\s)(1\/2)\s$/,replace:e??`½`}),DG=e=>YU({find:/\+\/-$/,replace:e??`±`}),OG=e=>YU({find:/!=$/,replace:e??`≠`}),kG=e=>YU({find:/<<$/,replace:e??`«`}),AG=e=>YU({find:/>>$/,replace:e??`»`}),jG=e=>YU({find:/\d+\s?([*x])\s?\d+$/,replace:e??`×`}),MG=e=>YU({find:/\^2$/,replace:e??`²`}),NG=e=>YU({find:/\^3$/,replace:e??`³`}),PG=e=>YU({find:/(?:^|\s)(1\/4)\s$/,replace:e??`¼`}),FG=e=>YU({find:/(?:^|\s)(3\/4)\s$/,replace:e??`¾`}),IG=WV.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(mG(this.options.emDash)),this.options.ellipsis!==!1&&e.push(hG(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&e.push(gG(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&e.push(_G(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&e.push(vG(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&e.push(yG(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&e.push(bG(this.options.leftArrow)),this.options.rightArrow!==!1&&e.push(xG(this.options.rightArrow)),this.options.copyright!==!1&&e.push(SG(this.options.copyright)),this.options.trademark!==!1&&e.push(CG(this.options.trademark)),this.options.servicemark!==!1&&e.push(wG(this.options.servicemark)),this.options.registeredTrademark!==!1&&e.push(TG(this.options.registeredTrademark)),this.options.oneHalf!==!1&&e.push(EG(this.options.oneHalf)),this.options.plusMinus!==!1&&e.push(DG(this.options.plusMinus)),this.options.notEqual!==!1&&e.push(OG(this.options.notEqual)),this.options.laquo!==!1&&e.push(kG(this.options.laquo)),this.options.raquo!==!1&&e.push(AG(this.options.raquo)),this.options.multiplication!==!1&&e.push(jG(this.options.multiplication)),this.options.superscriptTwo!==!1&&e.push(MG(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&e.push(NG(this.options.superscriptThree)),this.options.oneQuarter!==!1&&e.push(PG(this.options.oneQuarter)),this.options.threeQuarters!==!1&&e.push(FG(this.options.threeQuarters)),e}});function LG(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 RG(e){let t=e.toLowerCase();return t.includes(`mac`)||t===`darwin`?`macos`:t.includes(`win`)?`windows`:`linux`}function zG(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 BG=[`http://`,`https://`,`mailto:`,`ftp://`,`//`];function VG(e){let t=e.toLowerCase();return BG.some(e=>t.startsWith(e))}function HG(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 UG(e){if(!e)return null;let t=e.trim();return t&&(VG(t)||t.startsWith(`#`)||!HG(t))?t:null}var WG=[`http://`,`https://`,`ftp://`,`//`],GG=/^data:image\/(?:png|jpeg|jpg|gif|webp);base64,/i,KG=7e6;function qG(e){if(!e)return null;let t=e.trim();if(!t)return null;if(GG.test(t))return t.length<=KG?t:null;let n=t.toLowerCase();return WG.some(e=>n.startsWith(e))||t.startsWith(`#`)||!HG(t)?t:null}function JG(e){return e.chain().focus()}async function YG(e,t){let{editor:n}=t;switch(e){case`ctx:undo`:JG(n).undo().run();return;case`ctx:redo`:JG(n).redo().run();return;case`ctx:pastePlain`:{let e=await t.readClipboardText();if(!e)return;let{state:r,view:i}=n,a=zG(e,r.schema,r.selection.$from.marks());i.dispatch(r.tr.replaceSelection(a).scrollIntoView()),i.focus();return}case`ctx:table:insertRowAbove`:JG(n).addRowBefore().run();return;case`ctx:table:insertRowBelow`:JG(n).addRowAfter().run();return;case`ctx:table:insertColLeft`:JG(n).addColumnBefore().run();return;case`ctx:table:insertColRight`:JG(n).addColumnAfter().run();return;case`ctx:table:deleteRow`:JG(n).deleteRow().run();return;case`ctx:table:deleteCol`:JG(n).deleteColumn().run();return;case`ctx:table:mergeCells`:JG(n).mergeCells().run();return;case`ctx:table:splitCell`:JG(n).splitCell().run();return;case`ctx:table:deleteTable`:JG(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=UG(e);n&&await t.writeClipboardText(n);return}case`ctx:link:remove`:JG(n).extendMarkRange(`link`).unsetLink().run();return;default:return}}var XG=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 ZG(e){return typeof e==`string`&&XG.has(e)}async function QG(){try{return await navigator.clipboard.readText()}catch{return null}}async function $G(e){try{await navigator.clipboard.writeText(e)}catch{}}function eK(e,t){if(!sh())return()=>{};let n=e.view.dom,r=t.platform??RG(typeof navigator<`u`?navigator.platform||navigator.userAgent:``),i=null,a=async t=>{let n=t.target;if(!n)return;let a=LG({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 uh())(`show_context_menu`,{req:a})}catch{}};n.addEventListener(`contextmenu`,a);let o=ql(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;ZG(r)&&YG(r,{editor:e,openHref:t.openHref,getLinkHref:()=>i,readClipboardText:QG,writeClipboardText:$G})}));return o.catch(()=>{}),()=>{n.removeEventListener(`contextmenu`,a),o.then(e=>e()).catch(()=>{})}}var tK=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,nK=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,rK=PV.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`,pV(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[KU({find:tK,type:this.type})]},addPasteRules(){return[QU({find:nK,type:this.type})]}}),iK=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,aK=ZU.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`,pV(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[qU({find:iK,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),oK=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,sK=`ελ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`,cK=`numeric`,lK=`ascii`,uK=`alpha`,dK=`asciinumeric`,fK=`alphanumeric`,pK=`domain`,mK=`emoji`,hK=`scheme`,gK=`slashscheme`,_K=`whitespace`;function vK(e,t){return e in t||(t[e]=[]),t[e]}function yK(e,t,n){t[cK]&&(t[dK]=!0,t[fK]=!0),t[lK]&&(t[dK]=!0,t[uK]=!0),t[dK]&&(t[fK]=!0),t[uK]&&(t[fK]=!0),t[fK]&&(t[pK]=!0),t[mK]&&(t[pK]=!0);for(let r in t){let t=vK(r,n);t.indexOf(e)<0&&t.push(e)}}function bK(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function xK(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}xK.groups={},xK.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||=xK.groups;let i;return t&&t.j?i=t:(i=new xK(t),n&&r&&yK(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||=xK.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 xK,Object.assign(o.j,s.j),o.jr.push.apply(o.jr,s.jr),o.jd=s.jd,o.t=s.t):o=new xK,a&&(r&&(o.t&&typeof o.t==`string`?yK(a,Object.assign(bK(o.t,r),n),r):n&&yK(a,n,r)),o.t=a),i.j[e]=o,o}};var SK=(e,t,n,r,i)=>e.ta(t,n,r,i),CK=(e,t,n,r,i)=>e.tr(t,n,r,i),wK=(e,t,n,r,i)=>e.ts(t,n,r,i),$=(e,t,n,r,i)=>e.tt(t,n,r,i),TK=`WORD`,EK=`UWORD`,DK=`ASCIINUMERICAL`,OK=`ALPHANUMERICAL`,kK=`LOCALHOST`,AK=`TLD`,jK=`UTLD`,MK=`SCHEME`,NK=`SLASH_SCHEME`,PK=`NUM`,FK=`WS`,IK=`NL`,LK=`OPENBRACE`,RK=`CLOSEBRACE`,zK=`OPENBRACKET`,BK=`CLOSEBRACKET`,VK=`OPENPAREN`,HK=`CLOSEPAREN`,UK=`OPENANGLEBRACKET`,WK=`CLOSEANGLEBRACKET`,GK=`FULLWIDTHLEFTPAREN`,KK=`FULLWIDTHRIGHTPAREN`,qK=`LEFTCORNERBRACKET`,JK=`RIGHTCORNERBRACKET`,YK=`LEFTWHITECORNERBRACKET`,XK=`RIGHTWHITECORNERBRACKET`,ZK=`FULLWIDTHLESSTHAN`,QK=`FULLWIDTHGREATERTHAN`,$K=`AMPERSAND`,eq=`APOSTROPHE`,tq=`ASTERISK`,nq=`AT`,rq=`BACKSLASH`,iq=`BACKTICK`,aq=`CARET`,oq=`COLON`,sq=`COMMA`,cq=`DOLLAR`,lq=`DOT`,uq=`EQUALS`,dq=`EXCLAMATION`,fq=`HYPHEN`,pq=`PERCENT`,mq=`PIPE`,hq=`PLUS`,gq=`POUND`,_q=`QUERY`,vq=`QUOTE`,yq=`FULLWIDTHMIDDLEDOT`,bq=`SEMI`,xq=`SLASH`,Sq=`TILDE`,Cq=`UNDERSCORE`,wq=`EMOJI`,Tq=`SYM`,Eq=Object.freeze({__proto__:null,ALPHANUMERICAL:OK,AMPERSAND:$K,APOSTROPHE:eq,ASCIINUMERICAL:DK,ASTERISK:tq,AT:nq,BACKSLASH:rq,BACKTICK:iq,CARET:aq,CLOSEANGLEBRACKET:WK,CLOSEBRACE:RK,CLOSEBRACKET:BK,CLOSEPAREN:HK,COLON:oq,COMMA:sq,DOLLAR:cq,DOT:lq,EMOJI:wq,EQUALS:uq,EXCLAMATION:dq,FULLWIDTHGREATERTHAN:QK,FULLWIDTHLEFTPAREN:GK,FULLWIDTHLESSTHAN:ZK,FULLWIDTHMIDDLEDOT:yq,FULLWIDTHRIGHTPAREN:KK,HYPHEN:fq,LEFTCORNERBRACKET:qK,LEFTWHITECORNERBRACKET:YK,LOCALHOST:kK,NL:IK,NUM:PK,OPENANGLEBRACKET:UK,OPENBRACE:LK,OPENBRACKET:zK,OPENPAREN:VK,PERCENT:pq,PIPE:mq,PLUS:hq,POUND:gq,QUERY:_q,QUOTE:vq,RIGHTCORNERBRACKET:JK,RIGHTWHITECORNERBRACKET:XK,SCHEME:MK,SEMI:bq,SLASH:xq,SLASH_SCHEME:NK,SYM:Tq,TILDE:Sq,TLD:AK,UNDERSCORE:Cq,UTLD:jK,UWORD:EK,WORD:TK,WS:FK}),Dq=/[a-z]/,Oq=/\p{L}/u,kq=/\p{Emoji}/u,Aq=/\d/,jq=/\s/,Mq=`\r`,Nq=`
214
+ `,Pq=`️`,Fq=`‍`,Iq=``,Lq=null,Rq=null;function zq(e=[]){let t={};xK.groups=t;let n=new xK;Lq??=Uq(oK),Rq??=Uq(sK),$(n,`'`,eq),$(n,`{`,LK),$(n,`}`,RK),$(n,`[`,zK),$(n,`]`,BK),$(n,`(`,VK),$(n,`)`,HK),$(n,`<`,UK),$(n,`>`,WK),$(n,`(`,GK),$(n,`)`,KK),$(n,`「`,qK),$(n,`」`,JK),$(n,`『`,YK),$(n,`』`,XK),$(n,`<`,ZK),$(n,`>`,QK),$(n,`&`,$K),$(n,`*`,tq),$(n,`@`,nq),$(n,"`",iq),$(n,`^`,aq),$(n,`:`,oq),$(n,`,`,sq),$(n,`$`,cq),$(n,`.`,lq),$(n,`=`,uq),$(n,`!`,dq),$(n,`-`,fq),$(n,`%`,pq),$(n,`|`,mq),$(n,`+`,hq),$(n,`#`,gq),$(n,`?`,_q),$(n,`"`,vq),$(n,`/`,xq),$(n,`;`,bq),$(n,`~`,Sq),$(n,`_`,Cq),$(n,`\\`,rq),$(n,`・`,yq);let r=CK(n,Aq,PK,{[cK]:!0});CK(r,Aq,r);let i=CK(r,Dq,DK,{[dK]:!0}),a=CK(r,Oq,OK,{[fK]:!0}),o=CK(n,Dq,TK,{[lK]:!0});CK(o,Aq,i),CK(o,Dq,o),CK(i,Aq,i),CK(i,Dq,i);let s=CK(n,Oq,EK,{[uK]:!0});CK(s,Dq),CK(s,Aq,a),CK(s,Oq,s),CK(a,Aq,a),CK(a,Dq),CK(a,Oq,a);let c=$(n,Nq,IK,{[_K]:!0}),l=$(n,Mq,FK,{[_K]:!0}),u=CK(n,jq,FK,{[_K]:!0});$(n,Iq,u),$(l,Nq,c),$(l,Iq,u),CK(l,jq,u),$(u,Mq),$(u,Nq),CK(u,jq,u),$(u,Iq,u);let d=CK(n,kq,wq,{[mK]:!0});$(d,`#`),CK(d,kq,d),$(d,Pq,d);let f=$(d,Fq);$(f,`#`),CK(f,kq,d);let p=[[Dq,o],[Aq,i]],m=[[Dq,null],[Oq,s],[Aq,a]];for(let e=0;e<Lq.length;e++)Hq(n,Lq[e],AK,TK,p);for(let e=0;e<Rq.length;e++)Hq(n,Rq[e],jK,EK,m);yK(AK,{tld:!0,ascii:!0},t),yK(jK,{utld:!0,alpha:!0},t),Hq(n,`file`,MK,TK,p),Hq(n,`mailto`,MK,TK,p),Hq(n,`http`,NK,TK,p),Hq(n,`https`,NK,TK,p),Hq(n,`ftp`,NK,TK,p),Hq(n,`ftps`,NK,TK,p),yK(MK,{scheme:!0,ascii:!0},t),yK(NK,{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]?{[hK]:!0}:{[gK]:!0};r.indexOf(`-`)>=0?i[pK]=!0:Dq.test(r)?Aq.test(r)?i[dK]=!0:i[lK]=!0:i[cK]=!0,wK(n,r,r,i)}return wK(n,`localhost`,kK,{ascii:!0}),n.jd=new xK(Tq),{start:n,tokens:Object.assign({groups:t},Eq)}}function Bq(e,t){let n=Vq(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 Vq(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 Hq(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 xK(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new xK(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function Uq(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 Wq={defaultProtocol:`http`,events:null,format:Kq,formatHref:Kq,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Gq(e,t=null){let n=Object.assign({},Wq);e&&(n=Object.assign(n,e instanceof Gq?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}Gq.prototype={o:Wq,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]:Wq[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 Kq(e){return e}function qq(e,t){this.t=`token`,this.v=e,this.tk=t}qq.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=Wq.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 Jq(e,t){class n extends qq{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 Yq=Jq(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),Xq=Jq(`text`),Zq=Jq(`nl`),Qq=Jq(`url`,{isLink:!0,toHref(e=Wq.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==kK&&e[1].t===oq}}),$q=e=>new xK(e);function eJ({groups:e}){let t=e.domain.concat([$K,tq,nq,rq,iq,aq,cq,uq,fq,PK,pq,mq,hq,gq,xq,Tq,Sq,Cq]),n=[eq,oq,sq,lq,dq,pq,_q,vq,bq,UK,WK,LK,RK,BK,zK,VK,HK,GK,KK,qK,JK,YK,XK,ZK,QK],r=[$K,eq,tq,rq,iq,aq,cq,uq,fq,LK,RK,pq,mq,hq,gq,_q,xq,Tq,Sq,Cq],i=$q(),a=$(i,Sq);SK(a,r,a),SK(a,e.domain,a);let o=$q(),s=$q(),c=$q();SK(i,e.domain,o),SK(i,e.scheme,s),SK(i,e.slashscheme,c),SK(o,r,a),SK(o,e.domain,o);let l=$(o,nq);$(a,nq,l),$(s,nq,l),$(c,nq,l);let u=$(a,lq);SK(u,r,a),SK(u,e.domain,a);let d=$q();SK(l,e.domain,d),SK(d,e.domain,d);let f=$(d,lq);SK(f,e.domain,d);let p=$q(Yq);SK(f,e.tld,p),SK(f,e.utld,p),$(l,kK,p);let m=$(d,fq);$(m,fq,m),SK(m,e.domain,d),SK(p,e.domain,d),$(p,lq,f),$(p,fq,m),SK($(p,oq),e.numeric,Yq);let h=$(o,fq),g=$(o,lq);$(h,fq,h),SK(h,e.domain,o),SK(g,r,a),SK(g,e.domain,o);let _=$q(Qq);SK(g,e.tld,_),SK(g,e.utld,_),SK(_,e.domain,o),SK(_,r,a),$(_,lq,g),$(_,fq,h),$(_,nq,l);let v=$(_,oq),y=$q(Qq);SK(v,e.numeric,y);let b=$q(Qq),x=$q();SK(b,t,b),SK(b,n,x),SK(x,t,b),SK(x,n,x),$(_,xq,b),$(y,xq,b);let S=$(s,oq),C=$($($(c,oq),xq),xq);SK(s,e.domain,o),$(s,lq,g),$(s,fq,h),SK(c,e.domain,o),$(c,lq,g),$(c,fq,h),SK(S,e.domain,b),$(S,xq,b),$(S,_q,b),SK(C,e.domain,b),SK(C,t,b),$(C,xq,b);let w=[[LK,RK],[zK,BK],[VK,HK],[UK,WK],[GK,KK],[qK,JK],[YK,XK],[ZK,QK]];for(let e=0;e<w.length;e++){let[r,i]=w[e],a=$(b,r);$(x,r,a),$(a,i,b);let o=$q(Qq);SK(a,t,o);let s=$q();SK(a,n),SK(o,t,o),SK(o,n,s),SK(s,t,o),SK(s,n,s),$(o,i,b),$(s,i,b)}return $(i,kK,_),$(i,IK,Zq),{start:i,tokens:Eq}}function tJ(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(nJ(Xq,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(nJ(e,t,r))}}return o.length>0&&a.push(nJ(Xq,t,o)),a}function nJ(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var rJ=typeof console<`u`&&console&&console.warn||(()=>{}),iJ=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,aJ={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function oJ(){return xK.groups={},aJ.scanner=null,aJ.parser=null,aJ.tokenQueue=[],aJ.pluginQueue=[],aJ.customSchemes=[],aJ.initialized=!1,aJ}function sJ(e,t=!1){if(aJ.initialized&&rJ(`linkifyjs: already initialized - will not register custom scheme "${e}" ${iJ}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
215
+ 1. Must only contain digits, lowercase ASCII letters or "-"
216
+ 2. Cannot start or end with "-"
217
+ 3. "-" cannot repeat`);aJ.customSchemes.push([e,t])}function cJ(){aJ.scanner=zq(aJ.customSchemes);for(let e=0;e<aJ.tokenQueue.length;e++)aJ.tokenQueue[e][1]({scanner:aJ.scanner});aJ.parser=eJ(aJ.scanner.tokens);for(let e=0;e<aJ.pluginQueue.length;e++)aJ.pluginQueue[e][1]({scanner:aJ.scanner,parser:aJ.parser});return aJ.initialized=!0,aJ}function lJ(e){return aJ.initialized||cJ(),tJ(aJ.parser.start,e,Bq(aJ.scanner.start,e))}lJ.scan=Bq;function uJ(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 Gq(n),i=lJ(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 dJ=`[\0- \xA0 ᠎ -\u2029  ]`,fJ=new RegExp(dJ),pJ=RegExp(`${dJ}$`),mJ=new RegExp(dJ,`g`);function hJ(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function gJ(e){return new fm({key:new hm(`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(pU(rU(n.doc,[...t])).forEach(({newRange:t})=>{let n=aU(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(!pJ.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(fJ).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=lJ(n).map(t=>t.toObject(e.defaultProtocol));if(!hJ(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=>{mU(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 _J(e){return new fm({key:new hm(`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=uU(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 vJ(e){return new fm({key:new hm(`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=uJ(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 yJ(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(mJ,``).match(RegExp(`^(?:(?:${n.join(`|`)}):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))`,`i`))}var bJ=PV.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`){sJ(e);return}sJ(e.scheme,e.optionalSlashes)})},onDestroy(){oJ()},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)=>!!yJ(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=>!!yJ(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=>!!yJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,pV(this.options.HTMLAttributes,e),0]:[`a`,pV(this.options.HTMLAttributes,{...e,href:``}),0]},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!yJ(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=>!!yJ(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[QU({find:e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options,i=uJ(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!yJ(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(gJ({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!yJ(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&e.push(_J({type:this.type})),this.options.linkOnPaste&&e.push(vJ({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),e}}),xJ=WV.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new fm({key:new hm(`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&&yU(e);if((n||!this.options.showOnlyCurrent)&&o){let r=[this.options.emptyNodeClass];a&&r.push(this.options.emptyEditorClass);let o=dz.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}),mz.create(e,i)}}})]}}),SJ=PV.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`,pV(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()}}}),CJ=PV.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`,pV(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()}}}),wJ,TJ;if(typeof WeakMap<`u`){let e=new WeakMap;wJ=t=>e.get(t),TJ=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;wJ=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},TJ=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var EJ=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 wJ(e)||TJ(e,DJ(e))}};function DJ(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=OJ(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 EJ(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&&kJ(s,o,e),s}function OJ(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 kJ(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||=AJ(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function AJ(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function jJ(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 MJ=new hm(`selectingCells`);function NJ(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 PJ(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 FJ(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 IJ(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=NJ(t.$head)||LJ(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function LJ(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 RJ(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function zJ(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function BJ(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function VJ(e,t,n){let r=e.node(-1),i=EJ.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 HJ(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 UJ(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 WJ(e,t,n){let r=jJ(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 GJ=class e extends Wp{constructor(e,t=e){let n=e.node(-1),r=EJ.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 Gp(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(RJ(r)&&RJ(i)&&BJ(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 Jp.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=EJ.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=HJ(e,0,l)),u>0&&(e=HJ(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=Wp.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=EJ.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=EJ.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=EJ.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=EJ.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 KJ(this.$anchorCell.pos,this.$headCell.pos)}};GJ.prototype.visible=!1,Wp.jsonID(`cell`,GJ);var KJ=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&&BJ(t,n)?new GJ(t,n):Wp.near(n,1)}};function qJ(e){if(!(e.selection instanceof GJ))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(dz.node(n,n+e.nodeSize,{class:`selectedCell`}))}),mz.create(e.doc,t)}function JJ({$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 YJ({$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 XJ(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof Xp&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=GJ.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=GJ.rowSelection(e,e)}else if(!n){let e=EJ.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=GJ.create(i,t+1,n)}}else r instanceof Jp&&JJ(r)?a=Jp.create(i,r.from):r instanceof Jp&&YJ(r)&&(a=Jp.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var ZJ=new hm(`fix-tables`);function QJ(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)?QJ(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function $J(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=eY(e,t,r,n))};return t?t.doc!=e.doc&&QJ(t.doc,e.doc,0,r):e.doc.descendants(r),n}function eY(e,t,n,r){let i=EJ.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,HJ(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=jJ(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(ZJ,{fixTables:!0})}function tY(e){let t=e.selection,n=IJ(e),r=n.node(-1),i=n.start(-1),a=EJ.get(r);return{...t instanceof GJ?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function nY(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;WJ(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,UJ(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?jJ(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 rY(e,t){if(!FJ(e))return!1;if(t){let n=tY(e);t(nY(e.tr,n,n.left))}return!0}function iY(e,t){if(!FJ(e))return!1;if(t){let n=tY(e);t(nY(e.tr,n,n.right))}return!0}function aY(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,HJ(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 oY(e,t){if(!FJ(e))return!1;if(t){let n=tY(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;aY(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=EJ.get(e)}t(r)}return!0}function sY(e,t,n){let r=jJ(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 cY(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;sY(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?jJ(r.type.schema).cell:r.nodeAt(t.map[c+s*t.width])?.type)?.createAndFill();e&&o.push(e)}return e.insert(a,jJ(r.type.schema).row.create(null,o)),e}function lY(e,t){if(!FJ(e))return!1;if(t){let n=tY(e);t(cY(e.tr,n,n.top))}return!0}function uY(e,t){if(!FJ(e))return!1;if(t){let n=tY(e);t(cY(e.tr,n,n.bottom))}return!0}function dY(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 fY(e,t){if(!FJ(e))return!1;if(t){let n=tY(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;dY(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=EJ.get(n.table)}t(r)}return!0}function pY(e){let t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function mY({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 hY(e,t){let n=e.selection;if(!(n instanceof GJ)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=tY(e),{map:i}=r;if(mY(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{pY(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,{...UJ(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=pY(c)?s+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,o)}n.setSelection(new GJ(n.doc.resolve(s+r.tableStart))),t(n)}return!0}function gY(e,t){let n=jJ(e.schema);return _Y(({node:e})=>n[e.type.spec.tableRole])(e,t)}function _Y(e){return(t,n)=>{let r=t.selection,i,a;if(r instanceof GJ){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{if(i=PJ(r.$from),!i)return!1;a=NJ(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=tY(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 GJ&&u.setSelection(new GJ(u.doc.resolve(r.$anchorCell.pos),d?u.doc.resolve(d):void 0)),n(u)}return!0}}function vY(e,t){return function(n,r){if(!FJ(n))return!1;let i=IJ(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof GJ?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 yY(e){return function(t,n){if(!FJ(t))return!1;if(n){let r=jJ(t.schema),i=tY(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 bY(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 xY(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?yY(e):function(t,n){if(!FJ(t))return!1;if(n){let r=jJ(t.schema),i=tY(t),a=t.tr,o=bY(`row`,i,r),s=bY(`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}}xY(`row`,{useDeprecatedLogic:!0}),xY(`column`,{useDeprecatedLogic:!0});var SY=xY(`cell`,{useDeprecatedLogic:!0});function CY(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 wY(e){return function(t,n){if(!FJ(t))return!1;let r=CY(IJ(t),e);if(r==null)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(Jp.between(e,zJ(e))).scrollIntoView())}return!0}}function TY(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 EY(e,t){let n=e.selection;if(!(n instanceof GJ))return!1;if(t){let r=e.tr,i=jJ(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 DY(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=kY(jJ(o).row,new Q(i,a,c)).content),s.push(i)}else if(a==`cell`||a==`header_cell`)s.push(n||r?kY(jJ(o).row,new Q(t,n,r)).content:t);else return null;return OY(o,s)}function OY(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=jJ(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 kY(e,t){let n=e.createAndFill();return new Hp(n).replace(0,n.content.size,t).doc}function AY({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(HJ(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 jY(e,t,n,r,i,a,o){let s=e.doc.type.schema,c=jJ(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 MY(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 NY(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,HJ(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(HJ(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function PY(e,t,n,r,i){let a=n?e.doc.nodeAt(n-1):e.doc;if(!a)throw Error(`No table found`);let o=EJ.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=EJ.get(a),f=d.mapping.maps.length}jY(d,o,a,n,l,u,f)&&p(),MY(d,o,a,n,c,l,s,f)&&p(),MY(d,o,a,n,c,l,u,f)&&p(),NY(d,o,a,n,s,u,c,f)&&p(),NY(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 GJ(d.doc.resolve(n+o.positionAt(s,c,a)),d.doc.resolve(n+o.positionAt(u-1,l-1,a)))),t(d)}var FY=hB({ArrowLeft:LY(`horiz`,-1),ArrowRight:LY(`horiz`,1),ArrowUp:LY(`vert`,-1),ArrowDown:LY(`vert`,1),"Shift-ArrowLeft":RY(`horiz`,-1),"Shift-ArrowRight":RY(`horiz`,1),"Shift-ArrowUp":RY(`vert`,-1),"Shift-ArrowDown":RY(`vert`,1),Backspace:EY,"Mod-Backspace":EY,Delete:EY,"Mod-Delete":EY});function IY(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function LY(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof GJ)return IY(n,r,Wp.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=HY(i,e,t);if(o==null)return!1;if(e==`horiz`)return IY(n,r,Wp.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=VJ(i,e,t),s;return s=a?Wp.near(a,1):t<0?Wp.near(n.doc.resolve(i.before(-1)),-1):Wp.near(n.doc.resolve(i.after(-1)),1),IY(n,r,s)}}}function RY(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof GJ)o=a;else{let r=HY(i,e,t);if(r==null)return!1;o=new GJ(n.doc.resolve(r))}let s=VJ(o.$headCell,e,t);return s?IY(n,r,new GJ(o.$anchorCell,s)):!1}}function zY(e,t){let n=e.state.doc,r=NJ(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new GJ(r))),!0):!1}function BY(e,t,n){if(!FJ(e.state))return!1;let r=DY(n),i=e.state.selection;if(i instanceof GJ){r||={width:1,height:1,rows:[Z.from(kY(jJ(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=EJ.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=AY(r,o.right-o.left,o.bottom-o.top),PY(e.state,e.dispatch,a,o,r),!0}else if(r){let t=IJ(e.state),n=t.start(-1);return PY(e.state,e.dispatch,n,EJ.get(t.node(-1)).findCell(t.pos-n),r),!0}else return!1}function VY(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=UY(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof GJ)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=NJ(e.state.selection.$anchor))!=null&&WY(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=WY(e,n),i=MJ.getState(e.state)==null;if(!r||!BJ(t,r))if(i)r=t;else return;let a=new GJ(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(MJ,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),MJ.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(MJ,-1))}function o(r){let o=r,s=MJ.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(UY(e,o.target)!=n&&(c=WY(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 HY(e,t,n){if(!(e.state.selection instanceof Jp))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 UY(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function WY(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&&NJ(e.state.doc.resolve(r))||NJ(e.state.doc.resolve(i))}var GY=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`)),KY(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,KY(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 KY(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 qY=new hm(`tableColumnResizing`);function JY({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=GY,lastColumnResizable:i=!0}={}){let a=new fm({key:qY,state:{init(e,t){var i;let o=(i=a.spec)==null||(i=i.props)==null?void 0:i.nodeViews,s=jJ(t.schema).table.name;return r&&o&&(o[s]=(e,t)=>new r(e,n,t)),new YY(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=qY.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{XY(t,n,e,i)},mouseleave:e=>{ZY(e)},mousedown:(e,r)=>{QY(e,r,t,n)}},decorations:e=>{let t=qY.getState(e);if(t&&t.activeHandle>-1)return sX(e,t.activeHandle)},nodeViews:{}}});return a}var YY=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(qY);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 RJ(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function XY(e,t,n,r){if(!e.editable)return;let i=qY.getState(e.state);if(i&&!i.dragging){let a=eX(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=tX(e,t,`left`,n):i-t.clientX<=n&&(o=tX(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=EJ.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}rX(e,o)}}}function ZY(e){if(!e.editable)return;let t=qY.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&rX(e,-1)}function QY(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=qY.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=$Y(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(qY,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=qY.getState(e.state);r?.dragging&&(iX(e,r.activeHandle,nX(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(qY,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=qY.getState(e.state);if(i&&i.dragging){let a=nX(i.dragging,t,n);aX(e,i.activeHandle,a,r)}}return aX(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function $Y(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 eX(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function tX(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=NJ(e.state.doc.resolve(o));if(!s)return-1;if(n==`right`)return s.pos;let c=EJ.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 nX(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function rX(e,t){e.dispatch(e.state.tr.setMeta(qY,{setHandle:t}))}function iX(e,t,n){let r=e.state.doc.resolve(t),i=r.node(-1),a=EJ.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():oX(l.colspan);d[u]=n,c.setNodeMarkup(o+r,null,{...l,colwidth:d})}c.docChanged&&e.dispatch(c)}function aX(e,t,n,r){let i=e.state.doc.resolve(t),a=i.node(-1),o=i.start(-1),s=EJ.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&&KY(a,c.firstChild,c,r,s,n)}function oX(e){return Array(e).fill(0)}function sX(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return mz.empty;let a=EJ.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`,qY.getState(e)?.dragging&&n.push(dz.node(o+t,o+t+i.nodeAt(t).nodeSize,{class:`column-resize-dragging`})),n.push(dz.widget(s,c))}}return mz.create(e.doc,n)}function cX({allowTableNodeSelection:e=!1}={}){return new fm({key:MJ,state:{init(){return null},apply(e,t){let n=e.getMeta(MJ);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:qJ,handleDOMEvents:{mousedown:VY},createSelectionBetween(e){return MJ.getState(e.state)==null?null:e.state.selection},handleTripleClick:zY,handleKeyDown:FY,handlePaste:BY},appendTransaction(t,n,r){return XJ(r,$J(r,n),e)}})}function lX(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function uX(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]=lX(r,o);l.style.setProperty(e,t)}l=l.nextSibling}else{let e=document.createElement(`col`),[n,i]=lX(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 dX=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`)),uX(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,uX(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 fX(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]=lX(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 pX(e,t){return t?e.createChecked(null,t):e.createAndFill()}function mX(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 hX(e,t,n,r,i){let a=mX(e),o=[],s=[];for(let e=0;e<n;e+=1){let e=pX(a.cell,i);if(e&&s.push(e),r){let e=pX(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 gX(e){return e instanceof GJ}var _X=({editor:e})=>{let{selection:t}=e.state;if(!gX(t))return!1;let n=0;return oU(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},vX=ZU.create({name:`table`,addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:dX,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}=fX(e,this.options.cellMinWidth),a=[`table`,pV(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=hX(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(Jp.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>rY(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>iY(e,t),deleteColumn:()=>({state:e,dispatch:t})=>oY(e,t),addRowBefore:()=>({state:e,dispatch:t})=>lY(e,t),addRowAfter:()=>({state:e,dispatch:t})=>uY(e,t),deleteRow:()=>({state:e,dispatch:t})=>fY(e,t),deleteTable:()=>({state:e,dispatch:t})=>TY(e,t),mergeCells:()=>({state:e,dispatch:t})=>hY(e,t),splitCell:()=>({state:e,dispatch:t})=>gY(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>xY(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>xY(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>SY(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>hY(e,t)?!0:gY(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>vY(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>wY(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>wY(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&$J(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=GJ.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:_X,"Mod-Backspace":_X,Delete:_X,"Mod-Delete":_X}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[JY({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],cX({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(e){return{tableRole:gV(lV(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}}),yX=ZU.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`,pV(this.options.HTMLAttributes,e),0]}}),bX=ZU.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`,pV(this.options.HTMLAttributes,e),0]}}),xX=ZU.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,pV(this.options.HTMLAttributes,e),0]}}),SX=PV.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`,pV(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()}}}),CX=/^\s*>\s$/,wX=ZU.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return[`blockquote`,pV(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[XU({find:CX,type:this.type})]}}),TX=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,EX=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,DX=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,OX=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,kX=PV.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`,pV(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[KU({find:TX,type:this.type}),KU({find:DX,type:this.type})]},addPasteRules(){return[QU({find:EX,type:this.type}),QU({find:OX,type:this.type})]}}),AX=`listItem`,jX=`textStyle`,MX=/^\s*([-+*])\s$/,NX=ZU.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`,pV(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(AX,this.editor.getAttributes(jX)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=XU({find:MX,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=XU({find:MX,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(jX),editor:this.editor})),[e]}}),PX=/(^|[^`])`([^`]+)`(?!`)/,FX=/(^|[^`])`([^`]+)`(?!`)/g,IX=PV.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,pV(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[KU({find:PX,type:this.type})]},addPasteRules(){return[QU({find:FX,type:this.type})]}}),LX=/^```([a-z]+)?[\s\n]$/,RX=/^~~~([a-z]+)?[\s\n]$/,zX=ZU.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`,pV(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(`
218
+
219
+ `);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(Wp.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[JU({find:LX,type:this.type,getAttributes:e=>({language:e[1]})}),JU({find:RX,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new fm({key:new hm(`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,`
220
+ `));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(Jp.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),BX=ZU.create({name:`doc`,topNode:!0,content:`block+`});function VX(e={}){return new fm({view(t){return new HX(t,e)}})}var HX=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=Cp(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)}},UX=WV.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[VX(this.options)]}}),WX=class e extends Wp{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):Wp.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 GX(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!qX(e)||!JX(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&&!Xp.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}}};WX.prototype.visible=!1,WX.findFrom=WX.findGapCursorFrom,Wp.jsonID(`gapcursor`,WX);var GX=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 WX.valid(t)?new WX(t):Wp.near(t)}};function KX(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function qX(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||KX(e.type))return!0;if(e.inlineContent)return!1}}return!0}function JX(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||KX(e.type))return!0;if(e.inlineContent)return!1}}return!0}function YX(){return new fm({props:{decorations:eZ,createSelectionBetween(e,t,n){return t.pos==n.pos&&WX.valid(n)?new WX(n):null},handleClick:QX,handleKeyDown:XX,handleDOMEvents:{beforeinput:$X}}})}var XX=hB({ArrowLeft:ZX(`horiz`,-1),ArrowRight:ZX(`horiz`,1),ArrowUp:ZX(`vert`,-1),ArrowDown:ZX(`vert`,1)});function ZX(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 Jp){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=WX.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new WX(c))),!0):!1}}function QX(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!WX.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Xp.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new WX(r))),!0)}function $X(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof WX))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(Jp.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function eZ(e){if(!(e.selection instanceof WX))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,mz.create(e.doc,[dz.widget(e.selection.head,t,{key:`gapcursor`})])}var tZ=WV.create({name:`gapCursor`,addProseMirrorPlugins(){return[YX()]},extendNodeSchema(e){return{allowGapCursor:gV(lV(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),nZ=ZU.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`,pV(this.options.HTMLAttributes,e)]},renderText(){return`
221
+ `},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()}}}),rZ=ZU.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]}`,pV(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=>JU({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),iZ=200,aZ=function(){};aZ.prototype.append=function(e){return e.length?(e=aZ.from(e),!this.length&&e||e.length<iZ&&this.leafAppend(e)||this.length<iZ&&e.leafPrepend(this)||this.appendInner(e)):this},aZ.prototype.prepend=function(e){return e.length?aZ.from(e).append(this):this},aZ.prototype.appendInner=function(e){return new sZ(this,e)},aZ.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?aZ.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},aZ.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},aZ.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)},aZ.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},aZ.from=function(e){return e instanceof aZ?e:e&&e.length?new oZ(e):aZ.empty};var oZ=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<=iZ)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=iZ)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}(aZ);aZ.empty=new oZ([]);var sZ=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}(aZ),cZ=500,lZ=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 dZ(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 dZ(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 dZ(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>pZ&&(s=uZ(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new Vf;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 dZ(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 dZ(i,o,l))}else r.push(new dZ(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new dZ(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>cZ&&(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 dZ(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(aZ.from(i.reverse()),a)}};lZ.empty=new lZ(aZ.empty,0);function uZ(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var dZ=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)}}},fZ=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},pZ=20;function mZ(e,t,n,r){let i=n.getMeta(SZ),a;if(i)return i.historyState;n.getMeta(CZ)&&(e=new fZ(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(SZ))return o.getMeta(SZ).redo?new fZ(e.done.addTransform(n,void 0,r,xZ(t)),e.undone,gZ(n.mapping.maps),e.prevTime,e.prevComposition):new fZ(e.done,e.undone.addTransform(n,void 0,r,xZ(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||!hZ(n,e.prevRanges)),s=o?_Z(e.prevRanges,n.mapping):gZ(n.mapping.maps);return new fZ(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,xZ(t)),lZ.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new fZ(e.done.rebased(n,a),e.undone.rebased(n,a),_Z(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new fZ(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),_Z(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function hZ(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 gZ(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 _Z(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 vZ(e,t,n){let r=xZ(t),i=SZ.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 fZ(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(SZ,{redo:n,historyState:c})}var yZ=!1,bZ=null;function xZ(e){let t=e.plugins;if(bZ!=t){yZ=!1,bZ=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){yZ=!0;break}}return yZ}var SZ=new hm(`history`),CZ=new hm(`closeHistory`);function wZ(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new fm({key:SZ,state:{init(){return new fZ(lZ.empty,lZ.empty,null,0,-1)},apply(t,n,r){return mZ(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?EZ:n==`historyRedo`?DZ:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function TZ(e,t){return(n,r)=>{let i=SZ.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=vZ(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var EZ=TZ(!1,!0),DZ=TZ(!0,!0),OZ=WV.create({name:`history`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>EZ(e,t),redo:()=>({state:e,dispatch:t})=>DZ(e,t)}},addProseMirrorPlugins(){return[wZ(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()}}}),kZ=ZU.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{}}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,pV(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!$U(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}):bU(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(Jp.create(e.doc,t.pos+1)):t.nodeAfter.isBlock?e.setSelection(Xp.create(e.doc,t.pos)):e.setSelection(Jp.create(e.doc,t.pos));else{let r=t.parent.type.contentMatch.defaultType?.create();r&&(e.insert(n,r),e.setSelection(Jp.create(e.doc,n+1)))}e.scrollIntoView()}return!0}).run()}}},addInputRules(){return[qU({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),AZ=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,jZ=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,MZ=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,NZ=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,PZ=PV.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`,pV(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[KU({find:AZ,type:this.type}),KU({find:MZ,type:this.type})]},addPasteRules(){return[QU({find:jZ,type:this.type}),QU({find:NZ,type:this.type})]}}),FZ=ZU.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,pV(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)}}}),IZ=`listItem`,LZ=`textStyle`,RZ=/^(\d+)\.\s$/,zZ=ZU.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`,pV(this.options.HTMLAttributes,n),0]:[`ol`,pV(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(IZ,this.editor.getAttributes(LZ)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=XU({find:RZ,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=XU({find:RZ,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(LZ)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),BZ=ZU.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,pV(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),VZ=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,HZ=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,UZ=PV.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`,pV(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[KU({find:VZ,type:this.type})]},addPasteRules(){return[QU({find:HZ,type:this.type})]}}),WZ=ZU.create({name:`text`,group:`inline`}),GZ=WV.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(kX.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(wX.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(NX.configure(this.options.bulletList)),this.options.code!==!1&&e.push(IX.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(zX.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(BX.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(UX.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(tZ.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(nZ.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(rZ.configure(this.options.heading)),this.options.history!==!1&&e.push(OZ.configure(this.options.history)),this.options.horizontalRule!==!1&&e.push(kZ.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(PZ.configure(this.options.italic)),this.options.listItem!==!1&&e.push(FZ.configure(this.options.listItem)),this.options.orderedList!==!1&&e.push(zZ.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(BZ.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(UZ.configure(this.options.strike)),this.options.text!==!1&&e.push(WZ.configure(this.options.text)),e}}),KZ=PV.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`,pV({class:`tandem-footnote-ref`},e),0]}}),qZ=new hm(`listItemCheckbox`),JZ=/^\[([ xX])\]\s$/,YZ=FZ.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 DV({find:JZ,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 fm({key:qZ,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(dz.widget(r+1,(t,n)=>XZ(t,n,i,e),{side:-1,key:`tandem-checkbox-${r}:${i}`,stopEvent:()=>!0,ignoreSelection:!0}))}),mz.create(t.doc,n)}}})]}});function XZ(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 ZZ=WV.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":``}:{}}}}]}}),QZ=PV.create({name:`rawMarkdown`,parseHTML(){return[]},renderHTML(){return[`span`,{class:`tandem-raw-md`},0]}}),$Z=bJ.extend({renderHTML(e){let t=this.parent?.(e)??[`a`,pV(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 eQ(){return[GZ.configure({history:!1,listItem:!1}),YZ,SX,CJ,SJ,KZ,rK.configure({multicolor:!0}),$Z.configure({openOnClick:!1,HTMLAttributes:{rel:`noopener noreferrer`,target:`_blank`}}),aK.configure({allowBase64:!0}),xJ.configure({placeholder:`Start typing…`}),vX.configure({resizable:!0}),xX,yX,bX,ZZ,QZ]}var tQ={};function nQ(e){let t=tQ[e];if(t)return t;t=tQ[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 rQ(e,t){typeof t!=`string`&&(t=rQ.defaultChars);let n=nQ(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})}rQ.defaultChars=`;/?:@&=+$,#`,rQ.componentChars=``;var iQ={};function aQ(e){let t=iQ[e];if(t)return t;t=iQ[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 oQ(e,t,n){typeof t!=`string`&&(n=t,t=oQ.defaultChars),n===void 0&&(n=!0);let r=aQ(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}oQ.defaultChars=`;/?:@&=+$,-_.!~*'()#`,oQ.componentChars=`-_.!~*'()`;function sQ(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 cQ(){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 lQ=/^([a-z0-9.+-]+:)/i,uQ=/:[0-9]*$/,dQ=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,fQ=[`%`,`/`,`?`,`;`,`#`,`'`,`{`,`}`,`|`,`\\`,`^`,"`",`<`,`>`,`"`,"`",` `,`\r`,`
222
+ `,` `],pQ=[`/`,`?`,`#`],mQ=255,hQ=/^[+a-z0-9A-Z_-]{0,63}$/,gQ=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,_Q={javascript:!0,"javascript:":!0},vQ={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function yQ(e,t){if(e&&e instanceof cQ)return e;let n=new cQ;return n.parse(e,t),n}cQ.prototype.parse=function(e,t){let n,r,i,a=e;if(a=a.trim(),!t&&e.split(`#`).length===1){let e=dQ.exec(a);if(e)return this.pathname=e[1],e[2]&&(this.search=e[2]),this}let o=lQ.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&&_Q[o])&&(a=a.substr(2),this.slashes=!0)),!_Q[o]&&(i||o&&!vQ[o])){let e=-1;for(let t=0;t<pQ.length;t++)r=a.indexOf(pQ[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<fQ.length;t++)r=a.indexOf(fQ[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(hQ)){let r=``;for(let e=0,t=n.length;e<t;e++)n.charCodeAt(e)>127?r+=`x`:r+=n[e];if(!r.match(hQ)){let r=e.slice(0,t),i=e.slice(t+1),o=n.match(gQ);o&&(r.push(o[1]),i.unshift(o[2])),i.length&&(a=i.join(`.`)+a),this.hostname=r.join(`.`);break}}}}this.hostname.length>mQ&&(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),vQ[n]&&this.hostname&&!this.pathname&&(this.pathname=``),this},cQ.prototype.parseHost=function(e){let t=uQ.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 bQ=t({decode:()=>rQ,encode:()=>oQ,format:()=>sQ,parse:()=>yQ}),xQ=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,SQ=/[\0-\x1F\x7F-\x9F]/,CQ=/[\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]/,wQ=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\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]/,TQ=/[\$\+<->\^`\|~\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]/,EQ=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,DQ=t({Any:()=>xQ,Cc:()=>SQ,Cf:()=>CQ,P:()=>wQ,S:()=>TQ,Z:()=>EQ}),OQ=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))),kQ=new Uint16Array(`Ȁaglq \x1Bɭ\0\0p;䀦os;䀧t;䀾t;䀼uot;䀢`.split(``).map(e=>e.charCodeAt(0))),AQ=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]]),jQ=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 MQ(e){return e>=55296&&e<=57343||e>1114111?65533:AQ.get(e)??e}var NQ;(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`})(NQ||={});var PQ=32,FQ;(function(e){e[e.VALUE_LENGTH=49152]=`VALUE_LENGTH`,e[e.BRANCH_LENGTH=16256]=`BRANCH_LENGTH`,e[e.JUMP_TABLE=127]=`JUMP_TABLE`})(FQ||={});function IQ(e){return e>=NQ.ZERO&&e<=NQ.NINE}function LQ(e){return e>=NQ.UPPER_A&&e<=NQ.UPPER_F||e>=NQ.LOWER_A&&e<=NQ.LOWER_F}function RQ(e){return e>=NQ.UPPER_A&&e<=NQ.UPPER_Z||e>=NQ.LOWER_A&&e<=NQ.LOWER_Z||IQ(e)}function zQ(e){return e===NQ.EQUALS||RQ(e)}var BQ;(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`})(BQ||={});var VQ;(function(e){e[e.Legacy=0]=`Legacy`,e[e.Strict=1]=`Strict`,e[e.Attribute=2]=`Attribute`})(VQ||={});var HQ=class{constructor(e,t,n){this.decodeTree=e,this.emitCodePoint=t,this.errors=n,this.state=BQ.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=VQ.Strict}startEntity(e){this.decodeMode=e,this.state=BQ.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,t){switch(this.state){case BQ.EntityStart:return e.charCodeAt(t)===NQ.NUM?(this.state=BQ.NumericStart,this.consumed+=1,this.stateNumericStart(e,t+1)):(this.state=BQ.NamedEntity,this.stateNamedEntity(e,t));case BQ.NumericStart:return this.stateNumericStart(e,t);case BQ.NumericDecimal:return this.stateNumericDecimal(e,t);case BQ.NumericHex:return this.stateNumericHex(e,t);case BQ.NamedEntity:return this.stateNamedEntity(e,t)}}stateNumericStart(e,t){return t>=e.length?-1:(e.charCodeAt(t)|PQ)===NQ.LOWER_X?(this.state=BQ.NumericHex,this.consumed+=1,this.stateNumericHex(e,t+1)):(this.state=BQ.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(IQ(r)||LQ(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(IQ(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===NQ.SEMI)this.consumed+=1;else if(this.decodeMode===VQ.Strict)return 0;return this.emitCodePoint(MQ(this.result),this.consumed),this.errors&&(e!==NQ.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(e,t){let{decodeTree:n}=this,r=n[this.treeIndex],i=(r&FQ.VALUE_LENGTH)>>14;for(;t<e.length;t++,this.excess++){let a=e.charCodeAt(t);if(this.treeIndex=WQ(n,r,this.treeIndex+Math.max(1,i),a),this.treeIndex<0)return this.result===0||this.decodeMode===VQ.Attribute&&(i===0||zQ(a))?0:this.emitNotTerminatedNamedEntity();if(r=n[this.treeIndex],i=(r&FQ.VALUE_LENGTH)>>14,i!==0){if(a===NQ.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==VQ.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]&FQ.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]&~FQ.VALUE_LENGTH:r[e+1],n),t===3&&this.emitCodePoint(r[e+2],n),n}end(){var e;switch(this.state){case BQ.NamedEntity:return this.result!==0&&(this.decodeMode!==VQ.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case BQ.NumericDecimal:return this.emitNumericEntity(0,2);case BQ.NumericHex:return this.emitNumericEntity(0,3);case BQ.NumericStart:return(e=this.errors)==null||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case BQ.EntityStart:return 0}}};function UQ(e){let t=``,n=new HQ(e,e=>t+=jQ(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 WQ(e,t,n,r){let i=(t&FQ.BRANCH_LENGTH)>>7,a=t&FQ.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 GQ=UQ(OQ);UQ(kQ);function KQ(e,t=VQ.Legacy){return GQ(e,t)}function qQ(e){return GQ(e,VQ.Strict)}var JQ=t({arrayReplaceAt:()=>e$,asciiTrim:()=>C$,assign:()=>$Q,escapeHtml:()=>p$,escapeRE:()=>h$,fromCodePoint:()=>n$,has:()=>QQ,isMdAsciiPunct:()=>b$,isPunctChar:()=>v$,isPunctCharCode:()=>y$,isSpace:()=>g$,isString:()=>XQ,isValidEntityCode:()=>t$,isWhiteSpace:()=>_$,lib:()=>w$,normalizeReference:()=>x$,unescapeAll:()=>c$,unescapeMd:()=>s$});function YQ(e){return Object.prototype.toString.call(e)}function XQ(e){return YQ(e)===`[object String]`}var ZQ=Object.prototype.hasOwnProperty;function QQ(e,t){return ZQ.call(e,t)}function $Q(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 e$(e,t,n){return[].concat(e.slice(0,t),n,e.slice(t+1))}function t$(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 n$(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 r$=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,i$=RegExp(r$.source+`|&([a-z#][a-z0-9]{1,31});`,`gi`),a$=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function o$(e,t){if(t.charCodeAt(0)===35&&a$.test(t)){let n=t[1].toLowerCase()===`x`?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return t$(n)?n$(n):e}let n=KQ(e);return n===e?e:n}function s$(e){return e.indexOf(`\\`)<0?e:e.replace(r$,`$1`)}function c$(e){return e.indexOf(`\\`)<0&&e.indexOf(`&`)<0?e:e.replace(i$,function(e,t,n){return t||o$(e,n)})}var l$=/[&<>"]/,u$=/[&<>"]/g,d$={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`};function f$(e){return d$[e]}function p$(e){return l$.test(e)?e.replace(u$,f$):e}var m$=/[.?*+^$[\]\\(){}|-]/g;function h$(e){return e.replace(m$,`\\$&`)}function g$(e){switch(e){case 9:case 32:return!0}return!1}function _$(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 v$(e){return wQ.test(e)||TQ.test(e)}function y$(e){return v$(n$(e))}function b$(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 x$(e){return e=e.trim().replace(/\s+/g,` `),e.toLowerCase().toUpperCase()}function S$(e){return e===32||e===9||e===10||e===13}function C$(e){let t=0;for(;t<e.length&&S$(e.charCodeAt(t));t++);let n=e.length-1;for(;n>=t&&S$(e.charCodeAt(n));n--);return e.slice(t,n+1)}var w$={mdurl:bQ,ucmicro:DQ};function T$(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 E$(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=c$(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=c$(e.slice(t,i)),a.pos=i,a.ok=!0,a)}function D$(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+=c$(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+=c$(e.slice(t,a)),o}var O$=t({parseLinkDestination:()=>E$,parseLinkLabel:()=>T$,parseLinkTitle:()=>D$}),k$={};k$.code_inline=function(e,t,n,r,i){let a=e[t];return`<code`+i.renderAttrs(a)+`>`+p$(a.content)+`</code>`},k$.code_block=function(e,t,n,r,i){let a=e[t];return`<pre`+i.renderAttrs(a)+`><code>`+p$(e[t].content)+`</code></pre>
223
+ `},k$.fence=function(e,t,n,r,i){let a=e[t],o=a.info?c$(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)||p$(a.content),l.indexOf(`<pre`)===0)return l+`
224
+ `;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`},k$.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)},k$.hardbreak=function(e,t,n){return n.xhtmlOut?`<br />
225
+ `:`<br>
226
+ `},k$.softbreak=function(e,t,n){return n.breaks?n.xhtmlOut?`<br />
227
+ `:`<br>
228
+ `:`
229
+ `},k$.text=function(e,t){return p$(e[t].content)},k$.html_block=function(e,t){return e[t].content},k$.html_inline=function(e,t){return e[t].content};function A$(){this.rules=$Q({},k$)}A$.prototype.renderAttrs=function(e){let t,n,r;if(!e.attrs)return``;for(r=``,t=0,n=e.attrs.length;t<n;t++)r+=` `+p$(e.attrs[t][0])+`="`+p$(e.attrs[t][1])+`"`;return r},A$.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+=`
230
+ `),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?`>
231
+ `:`>`,i},A$.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},A$.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+=`
232
+ `;break;default:}return r},A$.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 j$(){this.__rules__=[],this.__cache__=null}j$.prototype.__find__=function(e){for(let t=0;t<this.__rules__.length;t++)if(this.__rules__[t].name===e)return t;return-1},j$.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))})})},j$.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},j$.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},j$.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},j$.prototype.push=function(e,t,n){let r=n||{};this.__rules__.push({name:e,enabled:!0,fn:t,alt:r.alt||[]}),this.__cache__=null},j$.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},j$.prototype.enableOnly=function(e,t){Array.isArray(e)||(e=[e]),this.__rules__.forEach(function(e){e.enabled=!1}),this.enable(e,t)},j$.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},j$.prototype.getRules=function(e){return this.__cache__===null&&this.__compile__(),this.__cache__[e]||[]};function M$(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}M$.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},M$.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]},M$.prototype.attrSet=function(e,t){let n=this.attrIndex(e),r=[e,t];n<0?this.attrPush(r):this.attrs[n]=r},M$.prototype.attrGet=function(e){let t=this.attrIndex(e),n=null;return t>=0&&(n=this.attrs[t][1]),n},M$.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 N$(e,t,n){this.src=e,this.env=n,this.tokens=[],this.inlineMode=!1,this.md=t}N$.prototype.Token=M$;var P$=/\r\n?|\n/g,F$=/\0/g;function I$(e){let t;t=e.src.replace(P$,`
233
+ `),t=t.replace(F$,`�`),e.src=t}function L$(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 R$(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 z$(e){return/^<a[>\s]/i.test(e)}function B$(e){return/^<\/a\s*>/i.test(e)}function V$(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`&&(z$(o.content)&&i>0&&i--,B$(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=e$(r,a,c)}}}}var H$=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,U$=/\((c|tm|r)\)/i,W$=/\((c|tm|r)\)/gi,G$={c:`©`,r:`®`,tm:`™`};function K$(e,t){return G$[t.toLowerCase()]}function q$(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(W$,K$)),r.type===`link_open`&&r.info===`auto`&&t--,r.type===`link_close`&&r.info===`auto`&&t++}}function J$(e){let t=0;for(let n=e.length-1;n>=0;n--){let r=e[n];r.type===`text`&&!t&&H$.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 Y$(e){let t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type===`inline`&&(U$.test(e.tokens[t].content)&&q$(e.tokens[t].children),H$.test(e.tokens[t].content)&&J$(e.tokens[t].children))}var X$=/['"]/,Z$=/['"]/g,Q$=`’`;function $$(e,t,n,r){e[t]||(e[t]=[]),e[t].push({pos:n,ch:r})}function e1(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 t1(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;){Z$.lastIndex=l;let o=Z$.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=b$(m)||y$(m),_=b$(h)||y$(h),v=_$(m),y=_$(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&&$$(i,a,o.index,Q$);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]),$$(i,a,o.index,c),$$(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&&$$(i,a,o.index,Q$)}}Object.keys(i).forEach(function(t){e[t].content=e1(e[t].content,i[t])})}function n1(e){if(e.md.options.typographer)for(let t=e.tokens.length-1;t>=0;t--)e.tokens[t].type!==`inline`||!X$.test(e.tokens[t].content)||t1(e.tokens[t].children,e)}function r1(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 i1=[[`normalize`,I$],[`block`,L$],[`inline`,R$],[`linkify`,V$],[`replacements`,Y$],[`smartquotes`,n1],[`text_join`,r1]];function a1(){this.ruler=new j$;for(let e=0;e<i1.length;e++)this.ruler.push(i1[e][0],i1[e][1])}a1.prototype.process=function(e){let t=this.ruler.getRules(``);for(let n=0,r=t.length;n<r;n++)t[n](e)},a1.prototype.State=N$;function o1(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(g$(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}o1.prototype.push=function(e,t,n){let r=new M$(e,t,n);return r.block=!0,n<0&&this.level--,r.level=this.level,n>0&&this.level++,this.tokens.push(r),r},o1.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]},o1.prototype.skipEmptyLines=function(e){for(let t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e},o1.prototype.skipSpaces=function(e){for(let t=this.src.length;e<t&&g$(this.src.charCodeAt(e));e++);return e},o1.prototype.skipSpacesBack=function(e,t){if(e<=t)return e;for(;e>t;)if(!g$(this.src.charCodeAt(--e)))return e+1;return e},o1.prototype.skipChars=function(e,t){for(let n=this.src.length;e<n&&this.src.charCodeAt(e)===t;e++);return e},o1.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},o1.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(g$(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(``)},o1.prototype.Token=M$;var s1=65536;function c1(e,t){let n=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];return e.src.slice(n,r)}function l1(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 u1(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&&!g$(s)||o===45&&g$(s))return!1;for(;a<e.eMarks[i];){let t=e.src.charCodeAt(a);if(t!==124&&t!==45&&t!==58&&!g$(t))return!1;a++}let c=c1(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=c1(e,t).trim(),c.indexOf(`|`)===-1||e.sCount[t]-e.blkIndent>=4)return!1;l=l1(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=c1(e,i).trim(),!c)||e.sCount[i]-e.blkIndent>=4||(l=l1(c),l.length&&l[0]===``&&l.shift(),l.length&&l[l.length-1]===``&&l.pop(),y+=d-l.length,y>s1))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 d1(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)+`
234
+ `,a.map=[t,e.line],!0}function f1(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 p1(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(g$(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 m1(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&&!g$(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 h1(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&&!g$(e.src.charCodeAt(r))?-1:r}function g1(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),!g$(a))?-1:i}function _1(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 v1(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=g1(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=h1(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=g1(e,c),p<0)break;o=e.bMarks[c]+e.tShift[c]}else if(p=h1(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&&_1(e,h),!0}function y1(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(!g$(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(!g$(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&&g$(c.charCodeAt(i));)i++;if(i<a&&c.charCodeAt(i)!==10&&g)for(g=``,i=f,o=p;i<a&&g$(c.charCodeAt(i));)i++;if(i<a&&c.charCodeAt(i)!==10)return!1;let _=x$(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 b1=`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(`.`),x1=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]*?\\]\\]>)`),S1=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*>)`),C1=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[RegExp(`^</?(`+b1.join(`|`)+`)(?=(\\s|/?>|$))`,`i`),/^$/,!0],[RegExp(S1.source+`\\s*$`),/^$/,!1]];function w1(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<C1.length&&!C1[s][0].test(o);s++);if(s===C1.length)return!1;if(r)return C1[s][2];let c=t+1,l=C1[s][1].test(``);if(!C1[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),C1[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 T1(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&&!g$(o))return!1;if(r)return!0;a=e.skipSpacesBack(a,i);let c=e.skipCharsBack(a,35,i);c>i&&g$(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=C$(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 E1(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=C$(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 D1(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=C$(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 O1=[[`table`,u1,[`paragraph`,`reference`]],[`code`,d1],[`fence`,f1,[`paragraph`,`reference`,`blockquote`,`list`]],[`blockquote`,p1,[`paragraph`,`reference`,`blockquote`,`list`]],[`hr`,m1,[`paragraph`,`reference`,`blockquote`,`list`]],[`list`,v1,[`paragraph`,`reference`,`blockquote`]],[`reference`,y1],[`html_block`,w1,[`paragraph`,`reference`,`blockquote`]],[`heading`,T1,[`paragraph`,`reference`,`blockquote`]],[`lheading`,E1],[`paragraph`,D1]];function k1(){this.ruler=new j$;for(let e=0;e<O1.length;e++)this.ruler.push(O1[e][0],O1[e][1],{alt:(O1[e][2]||[]).slice()})}k1.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)}},k1.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)},k1.prototype.State=o1;function A1(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}A1.prototype.pushPending=function(){let e=new M$(`text`,``,0);return e.content=this.pending,e.level=this.pendingLevel,this.tokens.push(e),this.pending=``,e},A1.prototype.push=function(e,t,n){this.pending&&this.pushPending();let r=new M$(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},A1.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=b$(i)||y$(i),l=b$(s)||y$(s),u=_$(i),d=_$(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}},A1.prototype.Token=M$;function j1(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 M1(e,t){let n=e.pos;for(;n<e.posMax&&!j1(e.src.charCodeAt(n));)n++;return n===e.pos?!1:(t||(e.pending+=e.src.slice(e.pos,n)),e.pos=n,!0)}var N1=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;function P1(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(N1);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 F1(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&&g$(e.src.charCodeAt(n));)n++;return e.pos=n,!0}var I1=[];for(let e=0;e<256;e++)I1.push(0);`\\!"#$%&'()*+,./:;<=>?@[]^_\`{|}~-`.split(``).forEach(function(e){I1[e.charCodeAt(0)]=1});function L1(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),g$(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&&I1[i]!==0?t.content=a:t.content=o,t.markup=o,t.info=`escape`}return e.pos=n+1,!0}function R1(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 z1(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 B1(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 V1(e){let t=e.tokens_meta,n=e.tokens_meta.length;B1(e,e.delimiters);for(let r=0;r<n;r++)t[r]&&t[r].delimiters&&B1(e,t[r].delimiters)}var H1={tokenize:z1,postProcess:V1};function U1(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 W1(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 G1(e){let t=e.tokens_meta,n=e.tokens_meta.length;W1(e,e.delimiters);for(let r=0;r<n;r++)t[r]&&t[r].delimiters&&W1(e,t[r].delimiters)}var K1={tokenize:U1,postProcess:G1};function q1(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),!(!g$(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),!(!g$(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),!(!g$(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[x$(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 J1(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),!(!g$(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),!(!g$(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),!(!g$(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[x$(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 Y1=/^([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])?)*)$/,X1=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function Z1(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(X1.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(Y1.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 Q1(e){return/^<a[>\s]/i.test(e)}function $1(e){return/^<\/a\s*>/i.test(e)}function e0(e){let t=e|32;return t>=97&&t<=122}function t0(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&&!e0(i))return!1;let a=e.src.slice(r).match(x1);if(!a)return!1;if(!t){let t=e.push(`html_inline`,``,0);t.content=a[0],Q1(t.content)&&e.linkLevel++,$1(t.content)&&e.linkLevel--}return e.pos+=a[0].length,!0}var n0=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,r0=/^&([a-z][a-z0-9]{1,31});/i;function i0(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(n0);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=t$(t)?n$(t):n$(65533),n.markup=r[0],n.info=`entity`}return e.pos+=r[0].length,!0}}else{let r=e.src.slice(n).match(r0);if(r){let n=qQ(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 a0(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 o0(e){let t=e.tokens_meta,n=e.tokens_meta.length;a0(e.delimiters);for(let e=0;e<n;e++)t[e]&&t[e].delimiters&&a0(t[e].delimiters)}function s0(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 c0=[[`text`,M1],[`linkify`,P1],[`newline`,F1],[`escape`,L1],[`backticks`,R1],[`strikethrough`,H1.tokenize],[`emphasis`,K1.tokenize],[`link`,q1],[`image`,J1],[`autolink`,Z1],[`html_inline`,t0],[`entity`,i0]],l0=[[`balance_pairs`,o0],[`strikethrough`,H1.postProcess],[`emphasis`,K1.postProcess],[`fragments_join`,s0]];function u0(){this.ruler=new j$;for(let e=0;e<c0.length;e++)this.ruler.push(c0[e][0],c0[e][1]);this.ruler2=new j$;for(let e=0;e<l0.length;e++)this.ruler2.push(l0[e][0],l0[e][1])}u0.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},u0.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()},u0.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)},u0.prototype.State=A1;function d0(e){let t={};return e||={},t.src_Any=xQ.source,t.src_Cc=SQ.source,t.src_Z=EQ.source,t.src_P=wQ.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 f0(e){return Array.prototype.slice.call(arguments,1).forEach(function(t){t&&Object.keys(t).forEach(function(n){e[n]=t[n]})}),e}function p0(e){return Object.prototype.toString.call(e)}function m0(e){return p0(e)===`[object String]`}function h0(e){return p0(e)===`[object Object]`}function g0(e){return p0(e)===`[object RegExp]`}function _0(e){return p0(e)===`[object Function]`}function v0(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,`\\$&`)}var y0={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function b0(e){return Object.keys(e||{}).reduce(function(e,t){return e||y0.hasOwnProperty(t)},!1)}var x0={"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}}},S0=`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]`,C0=`biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф`.split(`|`);function w0(e){return function(t,n){let r=t.slice(n);return e.test(r)?r.match(e)[0].length:0}}function T0(){return function(e,t){t.normalize(e)}}function E0(e){let t=e.re=d0(e.__opts__),n=e.__tlds__.slice();e.onCompile(),e.__tlds_replaced__||n.push(S0),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,h0(n)){g0(n.validate)?r.validate=w0(n.validate):_0(n.validate)?r.validate=n.validate:a(t,n),_0(n.normalize)?r.normalize=n.normalize:n.normalize?a(t,n):r.normalize=T0();return}if(m0(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:T0()};let o=Object.keys(e.__compiled__).filter(function(t){return t.length>0&&e.__compiled__[t]}).map(v0).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 D0(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 O0(e,t){if(!(this instanceof O0))return new O0(e,t);t||b0(e)&&(t=e,e={}),this.__opts__=f0({},y0,t),this.__schemas__=f0({},x0,e),this.__compiled__={},this.__tlds__=C0,this.__tlds_replaced__=!1,this.re={},E0(this)}O0.prototype.add=function(e,t){return this.__schemas__[e]=t,E0(this),this},O0.prototype.set=function(e){return this.__opts__=f0(this.__opts__,e),this},O0.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)},O0.prototype.pretest=function(e){return this.re.pretest.test(e)},O0.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0},O0.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 D0(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},O0.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 D0(e,t[2],t.index+t[1].length,t.index+t[0].length+n);return this.__compiled__[r.schema].normalize(r,this),r},O0.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(),E0(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,E0(this),this)},O0.prototype.normalize=function(e){e.schema||(e.url=`http://`+e.url),e.schema===`mailto:`&&!/^mailto:/i.test(e.url)&&(e.url=`mailto:`+e.url)},O0.prototype.onCompile=function(){};var k0=2147483647,A0=36,j0=1,M0=26,N0=38,P0=700,F0=72,I0=128,L0=`-`,R0=/^xn--/,z0=/[^\0-\x7F]/,B0=/[\x2E\u3002\uFF0E\uFF61]/g,V0={overflow:`Overflow: input needs wider integers to process`,"not-basic":`Illegal input >= 0x80 (not a basic code point)`,"invalid-input":`Invalid input`},H0=A0-j0,U0=Math.floor,W0=String.fromCharCode;function G0(e){throw RangeError(V0[e])}function K0(e,t){let n=[],r=e.length;for(;r--;)n[r]=t(e[r]);return n}function q0(e,t){let n=e.split(`@`),r=``;n.length>1&&(r=n[0]+`@`,e=n[1]),e=e.replace(B0,`.`);let i=K0(e.split(`.`),t).join(`.`);return r+i}function J0(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 Y0=e=>String.fromCodePoint(...e),X0=function(e){return e>=48&&e<58?26+(e-48):e>=65&&e<91?e-65:e>=97&&e<123?e-97:A0},Z0=function(e,t){return e+22+75*(e<26)-((t!=0)<<5)},Q0=function(e,t,n){let r=0;for(e=n?U0(e/P0):e>>1,e+=U0(e/t);e>455;r+=A0)e=U0(e/H0);return U0(r+36*e/(e+N0))},$0=function(e){let t=[],n=e.length,r=0,i=I0,a=F0,o=e.lastIndexOf(L0);o<0&&(o=0);for(let n=0;n<o;++n)e.charCodeAt(n)>=128&&G0(`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=A0;;i+=A0){s>=n&&G0(`invalid-input`);let o=X0(e.charCodeAt(s++));o>=A0&&G0(`invalid-input`),o>U0((k0-r)/t)&&G0(`overflow`),r+=o*t;let c=i<=a?j0:i>=a+M0?M0:i-a;if(o<c)break;let l=A0-c;t>U0(k0/l)&&G0(`overflow`),t*=l}let c=t.length+1;a=Q0(r-o,c,o==0),U0(r/c)>k0-i&&G0(`overflow`),i+=U0(r/c),r%=c,t.splice(r++,0,i)}return String.fromCodePoint(...t)},e2=function(e){let t=[];e=J0(e);let n=e.length,r=I0,i=0,a=F0;for(let n of e)n<128&&t.push(W0(n));let o=t.length,s=o;for(o&&t.push(L0);s<n;){let n=k0;for(let t of e)t>=r&&t<n&&(n=t);let c=s+1;n-r>U0((k0-i)/c)&&G0(`overflow`),i+=(n-r)*c,r=n;for(let n of e)if(n<r&&++i>k0&&G0(`overflow`),n===r){let e=i;for(let n=A0;;n+=A0){let r=n<=a?j0:n>=a+M0?M0:n-a;if(e<r)break;let i=e-r,o=A0-r;t.push(W0(Z0(r+i%o,0))),e=U0(i/o)}t.push(W0(Z0(e,0))),a=Q0(i,c,s===o),i=0,++s}++i,++r}return t.join(``)},t2={version:`2.3.1`,ucs2:{decode:J0,encode:Y0},decode:$0,encode:e2,toASCII:function(e){return q0(e,function(e){return z0.test(e)?`xn--`+e2(e):e})},toUnicode:function(e){return q0(e,function(e){return R0.test(e)?$0(e.slice(4).toLowerCase()):e})}},n2={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`]}}}},r2=/^(vbscript|javascript|file|data):/,i2=/^data:image\/(gif|png|jpeg|webp);/;function a2(e){let t=e.trim().toLowerCase();return r2.test(t)?i2.test(t):!0}var o2=[`http:`,`https:`,`mailto:`];function s2(e){let t=yQ(e,!0);if(t.hostname&&(!t.protocol||o2.indexOf(t.protocol)>=0))try{t.hostname=t2.toASCII(t.hostname)}catch{}return oQ(sQ(t))}function c2(e){let t=yQ(e,!0);if(t.hostname&&(!t.protocol||o2.indexOf(t.protocol)>=0))try{t.hostname=t2.toUnicode(t.hostname)}catch{}return rQ(sQ(t),rQ.defaultChars+`%`)}function l2(e,t){if(!(this instanceof l2))return new l2(e,t);t||XQ(e)||(t=e||{},e=`default`),this.inline=new u0,this.block=new k1,this.core=new a1,this.renderer=new A$,this.linkify=new O0,this.validateLink=a2,this.normalizeLink=s2,this.normalizeLinkText=c2,this.utils=JQ,this.helpers=$Q({},O$),this.options={},this.configure(e),t&&this.set(t)}l2.prototype.set=function(e){return $Q(this.options,e),this},l2.prototype.configure=function(e){let t=this;if(XQ(e)){let t=e;if(e=n2[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},l2.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},l2.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},l2.prototype.use=function(e){let t=[this].concat(Array.prototype.slice.call(arguments,1));return e.apply(e,t),this},l2.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},l2.prototype.render=function(e,t){return t||={},this.renderer.render(this.parse(e,t),this.options,t)},l2.prototype.parseInline=function(e,t){let n=new this.core.State(e,this,t);return n.inlineMode=!0,this.core.process(n),n.tokens},l2.prototype.renderInline=function(e,t){return t||={},this.renderer.render(this.parseInline(e,t),this.options,t)};var u2=new af({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 d2(e,t){if(e.isText&&t.isText&&pd.sameSet(e.marks,t.marks))return e.withText(e.text+t.text)}var f2=class{constructor(e,t){this.schema=e,this.tokenHandlers=t,this.stack=[{type:e.topNodeType,attrs:null,content:[],marks:pd.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=d2(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:pd.none})}closeNode(){let e=this.stack.pop();return this.addNode(e.type,e.attrs,e.content)}};function p2(e,t,n,r){return e.getAttrs?e.getAttrs(t,n,r):e.attrs instanceof Function?e.attrs(t):e.attrs}function m2(e,t){return e.noCloseToken||t==`code_inline`||t==`code_block`||t==`fence`}function h2(e){return e[e.length-1]==`
235
+ `?e.slice(0,e.length-1):e}function g2(){}function _2(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);m2(i,r)?n[r]=(e,n,r,a)=>{e.openNode(t,p2(i,n,r,a)),e.addText(h2(n.content)),e.closeNode()}:(n[r+`_open`]=(e,n,r,a)=>e.openNode(t,p2(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,p2(i,n,r,a))}else if(i.mark){let t=e.marks[i.mark];m2(i,r)?n[r]=(e,n,r,a)=>{e.openMark(t.create(p2(i,n,r,a))),e.addText(h2(n.content)),e.closeMark(t)}:(n[r+`_open`]=(e,n,r,a)=>e.openMark(t.create(p2(i,n,r,a))),n[r+`_close`]=e=>e.closeMark(t))}else if(i.ignore)m2(i,r)?n[r]=g2:(n[r+`_open`]=g2,n[r+`_close`]=g2);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 v2=class{constructor(e,t,n){this.schema=e,this.tokenizer=t,this.tokens=n,this.tokenHandlers=_2(e,n)}parse(e,t={}){let n=new f2(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 y2(e,t){for(;++t<e.length;)if(e[t].type!=`list_item_open`)return e[t].hidden;return!1}new v2(u2,l2(`commonmark`,{html:!1}),{blockquote:{block:`blockquote`},paragraph:{block:`paragraph`},list_item:{block:`list_item`},bullet_list:{block:`bullet_list`,getAttrs:(e,t,n)=>({tight:y2(t,n)})},ordered_list:{block:`ordered_list`,getAttrs:(e,t,n)=>({order:+e.attrGet(`start`)||1,tight:y2(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 b2={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 C2(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||``)+`
236
+ `),e.text(t.textContent,!1),e.write(`
237
+ `),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(`\\
238
+ `);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=S2(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 x2(n.child(r),-1)},close(e,t,n,r){return x2(n.child(r-1),1)},escape:!1}});function x2(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 S2(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 C2=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+=`
239
+ `),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+`
240
+ `}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=b2}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+=`
241
+ `)}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(`
242
+ `);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+=`
243
+ `)}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 w2(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 T2(e){return qG(e.attrGet(`src`))!=null}function E2(e,t){let n=new e.Token(`text`,``,0);return n.content=t.content||t.attrGet(`alt`)||``,n}function D2(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`&&T2(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]=E2(e,a.children[t]));n.push(a)}e.tokens=n}function O2(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:UG(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 k2(e){let t=l2(`commonmark`,{html:!1}).enable([`strikethrough`,`linkify`,`table`]);return t.core.ruler.push(`tandem-wrap-cell-paragraphs`,w2),t.core.ruler.push(`tandem-normalize-images`,D2),new v2(e,t,O2(e))}function A2(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 j2(e){let t=e.trim();if(!t)return!1;let n=A2(t);return n.length===0?!1:n.every(e=>/^:?-+:?$/.test(e.trim()))&&n.some(e=>e.trim().length>0)}function M2(e){let t=e.split(/\r\n|\r|\n/);for(let e=0;e<t.length-1;e++){if(!t[e].includes(`|`)||!j2(t[e+1]))continue;let n=A2(t[e]),r=A2(t[e+1]);if(n.length>0&&n.length===r.length)return!0}return!1}var N2=2e3,P2=RegExp(`(\\*\\*\\S(?:[^*\\n]{0,${N2}}\\S)?\\*\\*|__\\S(?:[^_\\n]{0,${N2}}\\S)?__|\\*\\S(?:[^*\\n]{0,${N2}}\\S)?\\*|\`[^\`\\n]{1,${N2}}\`|~~\\S(?:[^~\\n]{0,${N2}}\\S)?~~|!?\\[[^\\]\\n]{0,${N2}}\\]\\([^)\\n]{1,${N2}}\\))`);function F2(e){return e?!!(/^\s{0,3}(#{1,6}\s|[-*+]\s|\d+[.)]\s|>\s|```|~~~|-{3,}\s*$|\*{3,}\s*$|_{3,}\s*$)/m.test(e)||P2.test(e)||M2(e)):!1}function I2(e,t){if(!F2(e))return null;let n;try{let r=k2(t).parse(e);if(!r)return null;n=r}catch{return null}return n.childCount===0?null:Q.maxOpen(n.content,!1)}function L2(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=I2(e,r.state.schema);if(t)return t}return zG(e,r.state.schema,t.marks())},handlePaste:(e,t)=>{let n=t.clipboardData?.getData(`text/plain`)?.trim();if(!n||/\s/.test(n)||!VG(n))return!1;let{selection:r}=e.state;if(r.empty||!(r instanceof Jp))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 R2=new hm(`tandemAnnotations`),z2={comment:!0,highlight:!0,note:!0};function B2(){try{let e=localStorage.getItem(oo);if(!e)return{...z2};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),{...z2}}}function V2(){return TD(Ll(),`family`)}function H2(e){return e===`highlight`?`highlight`:e===`note`||e===`flag`?`note`:`comment`}function U2(e,t,n,r,i){let a=[],o=e.content.size;return t.forEach(t=>{let s=Fk(t,e=>{console.warn(`[sanitize]`,e)});if(s.status!==`pending`||!r[s.type]||!s.range&&!s.relRange)return;let c=LD(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=Na(s.color),t=Ma[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(dz.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)}}),mz.create(e,a)}var W2=WV.create({name:`tandemAnnotations`,addOptions(){return{ydoc:null}},addProseMirrorPlugins(){let e=this.options.ydoc;if(!e)return[];let t=e.getMap(Va),n=B2(),r=V2();function i(){for(let e of t.values()){let t=e;if(t&&t.status===`pending`&&n[H2(t.type)])return!0}return!1}let a=i(),o=!1;return[new fm({key:R2,state:{init(i,o){return a?U2(o.doc,t,e,n,r):mz.empty},apply(s,c,l,u){let d=s.getMeta(R2);if(d&&typeof d==`object`&&d.type===`toggle-decorations`&&(n=d.visible,a=i(),o=!1),d)return r=V2(),a?U2(u.doc,t,e,n,r):mz.empty;if(!a)return mz.empty;if(s.docChanged){if(!o&&c===mz.empty&&a){let i=U2(u.doc,t,e,n,r);return i!==mz.empty&&(o=!0),i}return c.map(s.mapping,s.doc)}return c}},props:{decorations(e){return R2.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(R2,!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)}}}})]}}),G2=new hm(`tandemAnnotationPing`),K2=700,q2=500,J2=`tandem-annotation-ping`;function Y2(e,t){return!(!t.isLive||t.alreadySeen||!e||e.status!==`pending`||!t.visible[H2(e.type)])}function X2(){try{if(Ll().reduceMotion)return!0}catch{}return typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Z2=WV.create({name:`tandemAnnotationPing`,addOptions(){return{ydoc:null}},addProseMirrorPlugins(){let e=this.options.ydoc;if(!e)return[];let t=e.getMap(Va),n=new Set,r=!1;return[new fm({key:G2,state:{init:()=>mz.empty,apply(e,t){let n=t.map(e.mapping,e.doc),r=e.getMeta(G2);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 G2.getState(e)}},view(i){let a=new Map,o=!1;function s(t,n){if(X2())return;let r=LD(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=dz.node(s,c,{class:J2},{pingId:t});i.dispatch(i.state.tr.setMeta(G2,{type:`add`,deco:l}));let u=setTimeout(()=>{a.delete(t),!o&&i.dispatch(i.state.tr.setMeta(G2,{type:`remove`,id:t}))},K2);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,q2)},d=e=>{r||u();let i=B2();for(let a of e.keysChanged){let e=t.get(a),o=Y2(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)}}}})]}}),Q2=new hm(`tandemAuthorship`),$2=new Set([`paragraph`,`heading`]);function e4(e,t,n){if(e.relRange){let r=ID(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=jD(t,e.range.from),r=jD(t,e.range.to);if(n<r)return{from:n,to:r}}return null}function t4(e,t,n,r){if(!r)return mz.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=e4(r,e,n);if(!s)return;let{from:c,to:l}=s;if(!(c>=l||c<0||l>a)){try{i.push(dz.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(!$2.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(dz.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)}}),mz.create(e,i)}var n4=WV.create({name:`tandemAuthorship`,addOptions(){return{ydoc:null}},addProseMirrorPlugins(){let e=this.options.ydoc;if(!e)return[];let t=e.getMap(Xa),n=!1;try{n=localStorage.getItem(ao)===`true`}catch(e){console.warn(`[authorship] localStorage unavailable`,e)}return[new fm({key:Q2,state:{init(r,i){return{visible:n,decorations:t4(i.doc,t,e,n)}},apply(n,r,i,a){let o=n.getMeta(Q2);if(o?.type===`toggle`){let n=o.visible;return{visible:n,decorations:t4(a.doc,t,e,n)}}return o?.type===`rebuild`?{visible:r.visible,decorations:t4(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 Q2.getState(e)?.decorations??mz.empty}},view(e){let n=()=>{let t=e.state.tr.setMeta(Q2,{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(Q2)||!e.docChanged)return;let n=t.getMap(Xa),r=e.doc;e.steps.forEach(e=>{e.getMap().forEach((e,t,i,a)=>{if(a-i-(t-e)>0)try{let e=ND(r,Eo(i)),t=ND(r,Eo(a));if(t<=e)return;let o=gc(`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)}})})}}),r4=new hm(`tandemAwareness`);function i4(e,t){if(!t)return mz.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(dz.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=jD(e,To(i)),r=a===!1?` tandem-claude-cursor-idle`:``;n.push(dz.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?mz.empty:mz.create(e,n)}var a4=WV.create({name:`tandemAwareness`,addOptions(){return{ydoc:null}},addProseMirrorPlugins(){let e=this.options.ydoc;if(!e)return[];let t=e.getMap(Ha),n=e.getMap(Ua);return[new fm({key:r4,state:{init(e,n){let r=t.get($a);return i4(n.doc,r??null)},apply(e,n,r,i){if(e.getMeta(r4)){let e=t.get($a);return i4(i.doc,e??null)}return e.docChanged?n.map(e.mapping,e.doc):n}},props:{decorations(e){return r4.getState(e)}},view(e){let n=()=>{let t=e.state.tr.setMeta(r4,!0);e.dispatch(t)};return t.observe(n),{destroy(){t.unobserve(n)}}}}),new fm({key:new hm(`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=RD(c.doc,{from:Eo(c.selection.from),to:Eo(c.selection.to)});if(c.selection.from===c.selection.to)r&&=(clearTimeout(r),null),n.set(Za,{...e,timestamp:Date.now()});else{let t=c.doc.textBetween(c.selection.from,c.selection.to,`
244
+ `),i=t.length>200?t.slice(0,197)+`...`:t;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n.set(Za,{...e,selectedText:i,timestamp:Date.now()})},150)}}c.doc!==s.doc&&(a=c.selection.from,i=!0,t||=setTimeout(()=>{t=null,i&&n.set(Qa,{isTyping:!0,cursor:a,lastEdit:Date.now()})},200),e&&clearTimeout(e),e=setTimeout(()=>{i=!1,n.set(Qa,{isTyping:!1,cursor:o.state.selection.from,lastEdit:Date.now()})},Oa))},destroy(){e&&clearTimeout(e),t&&clearTimeout(t),r&&clearTimeout(r)}}}})]}}),o4=new hm(`tandemFindReplace`),s4={query:``,caseSensitive:!1,wholeWord:!1,regexMode:!1,matches:[],activeIndex:-1,decoSet:mz.empty};function c4(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function l4(e){if(!e.query)return null;try{let t=e.regexMode?e.query:c4(e.query),n=e.caseSensitive?`g`:`gi`,r=e.wholeWord?`\\b${t}\\b`:t;return new RegExp(r,n)}catch{return null}}function u4(e,t){let n=l4(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 d4(e,t,n){if(t.length===0)return mz.empty;let r=[];for(let e=0;e<t.length;e++){let{from:i,to:a}=t[e];try{r.push(dz.inline(i,a,{class:e===n?`tandem-find-active`:`tandem-find-match`}))}catch{}}return mz.create(e,r)}function f4(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 p4(e,t,n){if(e.type===`close`)return s4;if(e.type===`find`){let t=e.opts,r=u4(n.doc,t),i=n.selection.from,a=f4(r,i);return{...t,matches:r,activeIndex:a,decoSet:d4(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:d4(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:d4(n.doc,t.matches,e)}}return e}var m4=WV.create({name:`tandemFindReplace`,addProseMirrorPlugins(){return[new fm({key:o4,state:{init:()=>s4,apply(e,t,n,r){let i=e.getMeta(o4);if(i)return p4(i,t,r);if(!t.query)return t;if(e.docChanged){let e=u4(r.doc,t),n=r.selection.from,i=f4(e,n);return{...t,matches:e,activeIndex:i,decoSet:d4(r.doc,e,i)}}let a=r.selection.from,o=f4(t.matches,a);return o===t.activeIndex?t:{...t,activeIndex:o,decoSet:d4(r.doc,t.matches,o)}}},props:{decorations(e){return o4.getState(e)?.decoSet??mz.empty}}})]},addCommands(){return{find:e=>({dispatch:t,tr:n})=>(t&&t(n.setMeta(o4,{type:`find`,opts:e})),!0),findNext:()=>({dispatch:e,tr:t})=>(e&&e(t.setMeta(o4,{type:`next`})),!0),findPrev:()=>({dispatch:e,tr:t})=>(e&&e(t.setMeta(o4,{type:`prev`})),!0),findClose:()=>({dispatch:e,tr:t})=>(e&&e(t.setMeta(o4,{type:`close`})),!0)}},addKeyboardShortcuts(){return{Escape:({editor:e})=>o4.getState(e.state)?.query?(e.commands.findClose(),!0):!1}}});function h4(e){return o4.getState(e)}function g4(e,t){let n=h4(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(o4,{type:`next`});return e.dispatch(a),!0}async function _4(e,t,n){let r=0,i=!1;for(let a=0;a<50;a++){let o=h4(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 v4=new hm(`tandemHeadingCollapse`),y4=`tandem:headingCollapse:`;function b4(e){return!e||e.startsWith(`upload://`)?null:y4+e}function x4(e){let t=b4(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 S4(e,t){let n=b4(e);if(n)try{t.size===0?window.localStorage.removeItem(n):window.localStorage.setItem(n,JSON.stringify(Array.from(t)))}catch{}}function C4(e){return e.trim().toLowerCase().replace(/\s+/g,` `)}function w4(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}::${C4(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 T4(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),S4(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?(S4(r,o),o):n}function E4(e,t,n){return dz.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(v4,{type:`toggle`,hash:t});e.dispatch(r)}),r},{side:-1,ignoreSelection:!0,stopEvent:()=>!0,key:`chevron:${t}:${n?`c`:`e`}`})}function D4(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(dz.node(n,r,{class:`tandem-heading-collapsed-hidden`,style:`display: none;`}))}}),a}function O4(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(E4(a.pos,a.hash,o)),o&&r.push(...D4(e,t,i))}catch{}}return r.length===0?mz.empty:mz.create(e,r)}var k4=WV.create({name:`tandemHeadingCollapse`,addOptions(){return{filePath:null}},addProseMirrorPlugins(){let e=this.options.filePath;return[new fm({key:v4,state:{init(t,n){let r=x4(e),i=w4(n.doc);return{collapsed:r,headings:i,decoSet:O4(n.doc,i,r),hasSeenContent:i.length>0}},apply(t,n,r,i){let a=t.getMeta(v4);if(a?.type===`toggle`){let t=new Set(n.collapsed);return t.has(a.hash)?t.delete(a.hash):t.add(a.hash),S4(e,t),{collapsed:t,headings:n.headings,decoSet:O4(i.doc,n.headings,t),hasSeenContent:n.hasSeenContent}}if(a?.type===`rehydrate`){let t=w4(i.doc),n=x4(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&&S4(e,a),{collapsed:a,headings:t,decoSet:O4(i.doc,t,a),hasSeenContent:!0}}if(!t.docChanged)return n;let o=w4(i.doc),s=n.hasSeenContent||o.length>0,c=n.collapsed;return n.hasSeenContent&&(c=T4(n.headings,o,n.collapsed,e)),{collapsed:c,headings:o,decoSet:O4(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=v4.getState(e.state);if(!r||r.headings.length===0)return;t=!0;let i=e.state.tr.setMeta(v4,{type:`rehydrate`}).setMeta(`addToHistory`,!1);e.dispatch(i)}))}return r(),{update(e){if(t)return;let n=v4.getState(e.state);!n||n.headings.length===0||r()},destroy(){n!==null&&cancelAnimationFrame(n)}}},props:{decorations(e){return v4.getState(e)?.decoSet??mz.empty}}})]}}),A4=new hm(`tandemSelectionDecoration`),j4=WV.create({name:`tandemSelectionDecoration`,addProseMirrorPlugins(){return[new fm({key:A4,props:{decorations(e){let{selection:t}=e;if(!(t instanceof Jp))return mz.empty;let{from:n,to:r}=t;return n===r?mz.empty:mz.create(e.doc,[dz.inline(n,r,{class:`tandem-selection-blurred`})])}}})]}});function M4(e){return e.chain().focus()}var N4={tag:`path`,attrs:{d:`M6 4.5h7M6 8h7M6 11.5h7`}},P4=[{id:`heading-1`,label:`Heading 1`,keywords:[`h1`,`heading`,`title`],hint:`h1`,icon:{kind:`glyph`,glyph:`H¹`},run:e=>M4(e).toggleHeading({level:1}).run()},{id:`heading-2`,label:`Heading 2`,keywords:[`h2`,`heading`,`subtitle`],hint:`h2`,icon:{kind:`glyph`,glyph:`H²`},run:e=>M4(e).toggleHeading({level:2}).run()},{id:`heading-3`,label:`Heading 3`,keywords:[`h3`,`heading`,`subheading`],hint:`h3`,icon:{kind:`glyph`,glyph:`H³`},run:e=>M4(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`}},N4]},run:e=>M4(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`}},N4]},run:e=>M4(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=>M4(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=>M4(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=>M4(e).toggleCodeBlock().run()},{id:`horizontal-rule`,label:`Horizontal rule`,keywords:[`hr`,`divider`,`rule`,`separator`],hint:`hr`,icon:{kind:`glyph`,glyph:`—`},run:e=>M4(e).setHorizontalRule().run()}];function F4(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 I4(e){let t=e.trim().toLowerCase();return t?P4.filter(e=>[e.label,...e.keywords].join(` `).toLowerCase().includes(t)):P4}var L4=[`popup-annotation-input`,`popup-note-submit`,`popup-comment-submit`,`popup-highlight-yellow`,`popup-highlight-green`,`popup-highlight-blue`,`popup-highlight-pink`];function R4(e){let t=document.querySelector(`[data-testid="${e}"]`);return t?document.activeElement===t:!1}function z4(e){for(let t of e)if(document.querySelector(`[data-testid="${t}"]`))return!0;return!1}function B4(){return typeof document>`u`?!1:!!(R4(`find-input`)||document.querySelector(`[data-testid="command-palette"]`)||z4(L4))}var V4=`http://www.w3.org/2000/svg`,H4=new hm(`tandemSlashCommand`);function U4(e){return`${e.from}:${e.to}:${e.query}`}function W4(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 G4(e,t=0){if(B4())return null;let{selection:n}=e;if(!n.empty)return null;let r=n.$from,i=F4(r.parent.textBetween(0,r.parentOffset,`
245
+ `,`
246
+ `));if(!i)return null;let a=r.start()+i.fromOffset,o=r.pos,s=I4(i.query);return s.length===0?null:{from:a,to:o,query:i.query,selectedIndex:Math.min(t,s.length-1)}}function K4(e,t){let n=e.getMeta(H4);return n?n.type===`close`?{active:null,dismissedKey:t.active?U4(t.active):t.dismissedKey}:n.type===`select`&&t.active?{...t,active:{...t.active,selectedIndex:n.selectedIndex??t.active.selectedIndex}}:t:null}function q4(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function J4(){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 Y4(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(V4,`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(V4,t.tag);for(let[n,r]of Object.entries(t.attrs))e.setAttribute(n,r);n.appendChild(e)}return t.appendChild(n),t}function X4(e,t,n,r,i){let a=I4(t.query);q4(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(Y4(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(J4());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 Z4(e,t){let n=I4(t.query)[t.selectedIndex];return n?(e.chain().focus().deleteRange({from:t.from,to:t.to}).run(),n.run(e),!0):!1}var Q4=WV.create({name:`slashCommand`,addOptions(){return{onOpenChange:void 0}},addProseMirrorPlugins(){let e=this.editor,t=this.options.onOpenChange;return[new fm({key:H4,state:{init:()=>({active:null,dismissedKey:null}),apply(e,t,n,r){let i=K4(e,t);if(i)return i;let a=G4(r,t.active?.selectedIndex??0);return a&&!t.active&&!W4(e)||a&&U4(a)===t.dismissedKey?{active:null,dismissedKey:t.dismissedKey}:{active:a,dismissedKey:a?null:t.dismissedKey}}},props:{handleKeyDown(t,n){let r=H4.getState(t.state)?.active;if(!r)return!1;let i=I4(r.query);if(n.key===`ArrowDown`){n.preventDefault();let e=(r.selectedIndex+1)%i.length;return t.dispatch(t.state.tr.setMeta(H4,{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(H4,{type:`select`,selectedIndex:e})),!0}return n.key===`Enter`?(n.preventDefault(),Z4(e,r)):n.key===`Escape`?(n.preventDefault(),t.dispatch(t.state.tr.setMeta(H4,{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`,q4(r),a(!1)},s=()=>{let t=H4.getState(n.state)?.active;if(!t){o();return}X4(r,t,e,e=>{n.dispatch(n.state.tr.setMeta(H4,{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(H4,{type:`close`}))}),a(!0)};return s(),{update:s,destroy(){a(!1),r.remove()}}}})]}}),$4=H(`<div role="presentation" data-testid="editor-root"></div>`);function e3(e,t){A(t,!0);let n=new Set([...Da].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=Dv(),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 GU({element:a,extensions:[...eQ(),uG.configure({document:t.ydoc}),pG.configure({provider:t.provider,user:{name:Gj(),color:`var(--tandem-warning)`}}),W2.configure({ydoc:t.ydoc}),Z2.configure({ydoc:t.ydoc}),k4.configure({filePath:jr(()=>t.currentFilePath??null)}),n4.configure({ydoc:t.ydoc}),a4.configure({ydoc:t.ydoc}),Q4.configure({onOpenChange:t.onSlashCommandMenuChange}),m4,j4,...e?[IG]:[]],editorProps:L2(jr(()=>B(l))),editable:jr(()=>!t.readOnly),autofocus:jr(()=>!t.readOnly)});P(i,n,!0),jr(()=>t.onEditorReady?.(n));let r=eK(n,{openHref:e=>{d(e)}});return()=>{jr(()=>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:L2(B(l))})}),R(()=>{let e=B(i);if(e)return qj(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(VG(e)){window.open(e,`_blank`,`noopener,noreferrer`);return}if(t.currentFilePath){let n=r(e,t.currentFilePath);if(n){let e=await Jh(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=$4();let m;pa(p,e=>a=e,()=>a),z(()=>m=Wi(p,1,``,null,m,{"tandem-paged":B(o)})),V(`click`,p,f),U(e,p),j()}Vr([`click`]);function t3(e,t=queueMicrotask){let n=!1;return()=>{n||(n=!0,t(()=>{n=!1,e()}))}}var n3=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>`),r3=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>`),i3=H(`<div class="fr-msg warning svelte-1q9bff2" role="status"> </div>`),a3=H(`<div class="fr-xdoc-status svelte-1q9bff2">Searching…</div>`),o3=H(`<div class="fr-xdoc-status svelte-1q9bff2">No matches in open tabs</div>`),s3=H(`<div class="fr-xdoc-snip svelte-1q9bff2"> </div>`),c3=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>`),l3=H(`<div data-testid="find-cross-doc-results" class="fr-xdoc svelte-1q9bff2"><!></div>`),u3=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 d3(e,t){A(t,!0);let n=J(t,`tabs`,19,()=>[]),r=N(`doc`),i=N(un([])),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 jE)n.push(e.toString());else{for(let t=0;t<e.length;t++){let n=e.get(t);(n instanceof jE||n instanceof EE)&&r(n)}e instanceof EE&&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;xa(()=>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?h4(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=t3(()=>{e.isDestroyed||sn(b)});return e.on(`transaction`,n),()=>{e.isDestroyed||e.off(`transaction`,n)}});function D(){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 ne(e){P(r,e,!0),e===`tabs`?(t.editor?.commands.findClose(),l(B(u),B(f))):(P(i,[],!0),clearTimeout(c),D())}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 _4(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=Zr(),ce=I(se),le=e=>{var o=u3(),s=F(o);let c;var l=F(s),x=L(F(l),2);ea(x),pa(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);ea(Ce),pa(Ce,e=>P(E,e),()=>B(E));var we=L(Ce,2),Te=L(we,2),Ee=F(Te),De=e=>{var t=Xr();z(()=>W(t,`${B(_).replaced??``}/${B(_).total??``}`)),U(e,t)},Oe=e=>{U(e,Xr(`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=n3(),n=L(F(t),2);let i;var a=L(n,2);let o;O(t),z(()=>{i=Wi(n,1,`fr-scope-pill svelte-1q9bff2`,null,i,{on:B(r)===`doc`}),q(n,`aria-pressed`,B(r)===`doc`),o=Wi(a,1,`fr-scope-pill svelte-1q9bff2`,null,o,{on:B(r)===`tabs`}),q(a,`aria-pressed`,B(r)===`tabs`)}),V(`click`,n,()=>ne(`doc`)),V(`click`,a,()=>ne(`tabs`)),U(e,t)};G(ke,e=>{n().length>1&&e(Ae)});var je=L(ke,2),Me=e=>{var t=r3(),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=i3(),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=l3(),n=F(t),r=e=>{U(e,a3())},o=e=>{U(e,o3())},s=e=>{var t=Zr();mi(I(t),17,()=>B(i),ui,(e,t)=>{var n=c3(),r=F(n),i=F(r),a=L(i),o=F(a);O(a),O(r),mi(L(r,2),17,()=>B(t).snippets,ui,(e,t)=>{var n=s3(),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=Wi(s,1,`fr svelte-1q9bff2`,null,c,{"no-match":B(w)}),te=Wi(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=Wi(pe,1,`fr-toggle svelte-1q9bff2`,null,me,{on:B(f)}),q(pe,`aria-pressed`,B(f)),ge=Wi(he,1,`fr-toggle svelte-1q9bff2`,null,ge,{on:B(p)}),q(he,`aria-pressed`,B(p)),ve=Wi(_e,1,`fr-toggle svelte-1q9bff2`,null,ve,{on:B(m)}),q(_e,`aria-pressed`,B(m)),be=Wi(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,D),oa(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)),D()}),V(`click`,he,()=>{P(p,!B(p)),D()}),V(`click`,_e,()=>{P(m,!B(m)),D()}),V(`click`,ye,re),V(`click`,xe,ae),oa(Ce,()=>B(d),e=>P(d,e)),V(`click`,we,()=>{t.editor&&(g4(t.editor.view,B(d)),sn(b))}),V(`click`,Te,oe),U(e,o)};G(ce,e=>{t.open&&e(le)}),U(e,se),j()}Vr([`keydown`,`input`,`click`]);var f3=H(`<div class="source-view-warning svelte-fwjuih" data-testid="source-view-annotation-warning" role="status"> </div>`),p3=H(`<div class="source-view-error svelte-fwjuih" data-testid="source-view-error" role="alert"> </div>`),m3=H(`<div class="source-view-loading svelte-fwjuih">Loading source…</div>`),h3=H(`<textarea class="source-view-textarea svelte-fwjuih" data-testid="source-view-textarea" spellcheck="false" autocomplete="off" autocapitalize="off" aria-label="Markdown source"></textarea>`),g3=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 _3(e,t){A(t,!0);let n=jr(()=>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(Va),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(`${Bl}${kc}?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(`${Bl}${Ac}`,{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=g3(),g=F(h),_=F(g),v=L(_,4);O(g);var y=L(g,2),b=e=>{var t=f3(),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=p3(),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,m3())},ee=e=>{var t=h3();En(t),V(`input`,t,d),V(`keydown`,t,p),oa(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()}Vr([`click`,`input`,`keydown`]);function v3(e,t){function n(n){e.contains(n.target)||t(n)}return document.addEventListener(`mousedown`,n),{destroy(){document.removeEventListener(`mousedown`,n)}}}var y3=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),b3=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
247
+ marks. Toggle a type to hide its marks in the document; side-panel cards
248
+ 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>`),x3=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 S3(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=x3();let u;var d=F(l);let f;var p=L(d,4);pa(p,e=>P(r,e),()=>B(r));var m=L(p,2),h=e=>{var n=b3(),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=y3();V(`click`,L(I(t),2),c),U(e,t)};G(p,e=>{t.onOpenSettings&&e(m)}),O(n),z(()=>{i=Wi(r,1,`mi svelte-94a7fq`,null,i,{on:t.showAuthorship}),q(r,`aria-checked`,t.showAuthorship),s=Wi(o,1,`mi svelte-94a7fq`,null,s,{on:t.showComments}),q(o,`aria-checked`,t.showComments),u=Wi(l,1,`mi svelte-94a7fq`,null,u,{on:t.showHighlights}),q(l,`aria-checked`,t.showHighlights),f=Wi(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),Fi(l,(e,t)=>v3?.(e,t),()=>()=>P(n,!1)),z(()=>{u=Wi(l,1,`split menu-wrap svelte-94a7fq`,null,u,{open:B(n)}),f=Wi(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()}Vr([`keydown`,`click`]);function C3(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 w3(e){let t=e.closest?.(`[data-tauri-drag-region]`);return!!t&&t.getAttribute(`data-tauri-drag-region`)!==`false`}function T3(e){return t=>{t.preventDefault(),e()}}function E3(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 D3(e,t){let n=t.trim();n?e.chain().focus().setLink({href:n}).run():e.isActive(`link`)&&e.chain().focus().unsetLink().run()}var O3=H(`<button type="button"><!></button>`);function k3(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=O3();let l;var u=F(c),d=e=>{var n=Zr();xi(I(n),()=>t.children),U(e,n)},f=e=>{var n=Xr();z(()=>W(n,t.label)),U(e,n)};G(u,e=>{t.children?e(d):e(f,-1)}),O(c),z(()=>{l=Wi(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)}Vr([`mousedown`,`click`]);var A3=Yr(`<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>`),j3=Yr(`<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>`),M3=H(`<!> <!> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div>`,1),N3=Yr(`<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>`),P3=H(`<div role="dialog" aria-label="Insert link" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
249
+ background: var(--tandem-surface); border: 1px solid var(--tandem-border);
250
+ border-radius: var(--tandem-r-3); padding: 6px;
251
+ display: flex; align-items: center; gap: 4px;
252
+ 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;
253
+ border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
254
+ background: var(--tandem-surface); color: var(--tandem-fg);
255
+ 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;
256
+ border: 1px solid var(--tandem-accent-border); background: transparent;
257
+ color: var(--tandem-accent); border-radius: var(--tandem-r-2); cursor: pointer;
258
+ 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;
259
+ border: 1px solid var(--tandem-border); background: transparent;
260
+ color: var(--tandem-fg-muted); border-radius: var(--tandem-r-2); cursor: pointer;">Cancel</button></div>`),F3=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),I3=H(`<button type="button" role="menuitemradio"> </button>`),L3=H(`<div role="menu" aria-label="Heading level" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
261
+ background: var(--tandem-surface); border: 1px solid var(--tandem-border);
262
+ border-radius: var(--tandem-r-3); padding: 4px; display: flex; flex-direction: column;
263
+ gap: 2px; z-index: var(--tandem-z-dropdown); box-shadow: var(--tandem-shadow-1);"></div>`),R3=Yr(`<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>`),z3=Yr(`<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>`),B3=Yr(`<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>`),V3=Yr(`<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>`),H3=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 U3(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=t3(()=>{e.isDestroyed||sn(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?aW.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`))),D=M(()=>(B(c),t.editor?B(h)||!t.editor.isActive(`link`)&&t.editor.state.selection.from===t.editor.state.selection.to:!0)),ne=M(()=>B(y)?`H${B(y)}`:`H`),re=M(()=>T3(()=>t.editor?.commands.undo())),ie=M(()=>T3(()=>t.editor?.commands.redo())),ae=M(()=>T3(()=>t.editor?.chain().focus().toggleBold().run())),oe=M(()=>T3(()=>t.editor?.chain().focus().toggleItalic().run())),se=M(()=>T3(()=>t.editor?.chain().focus().toggleStrike().run())),ce=M(()=>T3(()=>t.editor?.chain().focus().toggleCode().run())),le=M(()=>T3(()=>t.editor?.chain().focus().toggleBulletList().run())),ue=M(()=>T3(()=>t.editor?.chain().focus().toggleOrderedList().run())),de=M(()=>T3(()=>t.editor?.chain().focus().toggleBlockquote().run())),fe=M(()=>T3(()=>t.editor?.chain().focus().setHorizontalRule().run())),pe=M(()=>T3(()=>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,E3(t.editor),!0),P(u,!0))}function _e(){t.editor&&(D3(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=Zr(),xe=I(be),Se=e=>{var t=H3(),n=F(t),r=e=>{var t=M3(),n=I(t);{let e=e=>{U(e,A3())},t=M(()=>!B(_)),r=M(()=>me(B(re)));k3(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,j3())},t=M(()=>!B(v)),n=M(()=>me(B(ie)));k3(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)));k3(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)));k3(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)));k3(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)));k3(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,N3())},t=M(()=>B(te)||B(u)),n=M(()=>me(ge));k3(xe,{ariaLabel:`Link`,shortcut:`Ctrl+K`,get disabled(){return B(D)},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=P3(),n=F(t);ea(n),pa(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),oa(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),Fi(be,(e,t)=>v3?.(e,t),()=>ve);var we=L(be,4),Te=F(we);{let e=e=>{var t=F3(),n=I(t),r=F(n,!0);O(n),k(2),z(()=>W(r,B(ne))),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))}));k3(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=L3();mi(t,20,()=>o,e=>e,(e,t)=>{let n=M(()=>he(t));var r=I3(),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;
264
+ border-radius: var(--tandem-r-2);
265
+ background: ${B(y)===t?`var(--tandem-accent-bg)`:`transparent`};
266
+ color: ${B(y)===t?`var(--tandem-accent)`:`var(--tandem-fg)`};
267
+ cursor: pointer; text-align: left;
268
+ 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),Fi(we,(e,t)=>v3?.(e,t),()=>()=>P(l,!1));var Oe=L(we,2);{let e=e=>{U(e,R3())},t=M(()=>me(B(le)));k3(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,z3())},t=M(()=>me(B(ue)));k3(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,B3())},t=M(()=>me(B(de)));k3(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)));k3(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,V3())},t=M(()=>me(B(pe)));k3(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()}Vr([`keydown`,`mousedown`,`click`]);function W3(e,t,n){let r=e.getMap(Va),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=pc(),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 Pk(e,()=>r.set(i,a)),`added`}if(a===n)return Pk(e,()=>r.delete(i)),`removed`;let o=pc(),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 Pk(e,()=>{r.delete(i),r.set(o,s)}),`recolored`}function G3(e,t){let n=e.getMap(Va),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`:(Pk(e,()=>{for(let e of r)n.delete(e)}),`removed`)}function K3({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 q3(e,t){return e.on(`selectionUpdate`,t),()=>e.off(`selectionUpdate`,t)}var J3=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),Y3=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),X3=H(`<button type="button"></button>`),Z3=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 Q3(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=ED(Dv()),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,D=0,ne=0,re=null,ie=null,ae=!1;function oe(){re=T?E:D,ie=T?te:ne,!Pv(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=cl(),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(un(window.innerHeight)),he=N(un(window.innerWidth)),ge=Object.keys(ja),_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);D=t.left,ne=t.bottom;let n=K3({anchorX:re??D,anchorY:ie??ne,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=q3(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=C3(()=>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&&(jr(()=>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=ND(t.editor.state.doc,Eo(i)),s=ND(t.editor.state.doc,Eo(a)),c=pc(),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 Pk(t.ydoc,()=>t.ydoc.getMap(Va).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=ND(t.editor.state.doc,Eo(n)),a=ND(t.editor.state.doc,Eo(r));W3(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=ND(t.editor.state.doc,Eo(e)),i=ND(t.editor.state.doc,Eo(n));G3(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&&Uv(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&&Uv(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=Zr(),Ie=I(Fe),Le=e=>{var n=Z3();let r;var i=F(n);let p;var _=F(i),b=F(_),x=F(b),S=F(x);U3(S,{get editor(){return t.editor},variant:`popup`});var C=L(S,2),w=e=>{var n=J3(),r=L(I(n),2);S3(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=Y3(),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),D=F(te),ne=M(()=>ke(()=>{Oe(),t.editor?.chain().focus().run()}));mi(L(D,2),17,()=>ge,ui,(e,n)=>{var r=X3(),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: ${Ma[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);En(le),q(le,`rows`,1),pa(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),pa(n,e=>P(h,e),()=>B(h)),z(()=>{r=Wi(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=Wi(i,1,`morph-block morph-format svelte-1tvmluw`,null,p,{"is-active":!B(y)}),i.inert=B(y),oe=Wi(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`,D,e=>{e.preventDefault(),Oe(),t.editor?.chain().focus().run()}),V(`click`,D,function(...e){B(ne)?.apply(this,e)}),V(`mousedown`,re,e=>{e.preventDefault(),je()}),V(`click`,re,function(...e){B(ie)?.apply(this,e)}),V(`keydown`,le,Pe),oa(le,()=>B(g),e=>P(g,e)),V(`click`,me,Ne),V(`click`,ve,Me),Ni(1,n,()=>Yv,()=>({reduceMotion:d()})),U(e,n)};G(Ie,e=>{B(ve)&&B(m)&&e(Le)}),U(e,Fe),j()}Vr([`mousedown`,`click`,`keydown`]);function $3(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 e6(e){R(()=>$3(e()))}var t6=8e3;function n6(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(`${Bl}${Uc}`)}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(`${Bl}${bc}`)}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(),t6);xa(()=>{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 r6(e,t=document.documentElement){return e?t.setAttribute(`data-annotation-patterns`,`true`):t.removeAttribute(`data-annotation-patterns`),()=>t.removeAttribute(`data-annotation-patterns`)}function i6(e){R(()=>r6(e()))}function a6(e){let t=N(un(new Map));return R(()=>{let n=e.getYdoc();if(!n){B(t).size>0&&P(t,new Map,!0);return}let r=n.getMap(Ja),i=()=>{P(t,o6(r),!0)};return i(),r.observe(i),()=>r.unobserve(i)}),{get byId(){return B(t)}}}function o6(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 s6=25;function c6(e=s6){let t=un([]);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 l6(e,t=()=>Aa){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 u6(e,t=document.documentElement){return t.setAttribute(`data-density`,e),()=>t.removeAttribute(`data-density`)}function d6(e){R(()=>u6(e()))}function f6(e){let t=La[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 p6(e){let{side:t}=e,n=La[t],r=N(un(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 m6={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 h6(e){let t=document.documentElement;return t.style.setProperty(`--tandem-editor-font-family`,m6[e]),()=>t.style.removeProperty(`--tandem-editor-font-family`)}function g6(e){R(()=>h6(e()))}function _6(){let e=N(!1);return{get fileDragOver(){return B(e)},handleEditorDragOver:t=>{sh()||t.dataTransfer?.types.includes(`Files`)&&(t.preventDefault(),P(e,!0))},handleEditorDragLeave:t=>{sh()||(t.currentTarget===t.target||!t.currentTarget.contains(t.relatedTarget))&&P(e,!1)},handleEditorDrop:async t=>{if(sh()||(P(e,!1),!t.dataTransfer?.files.length))return;t.preventDefault();let n=t.dataTransfer.files[0],r=await Ul(n);try{let e=await fetch(`${Bl}${Tc}`,{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 v6(e){return!!e?.query}function y6(){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(`${Bl}${wg}`);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 b6(e,t=document.documentElement){return e?t.setAttribute(`data-high-contrast`,`true`):t.removeAttribute(`data-high-contrast`),()=>t.removeAttribute(`data-high-contrast`)}function x6(e){R(()=>b6(e()))}function S6(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 C6(e){let t=null;return{schedule(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel(){t!==null&&(cancelAnimationFrame(t),t=null)}}}function w6(e){let t=N(un(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}=S6(e.getAnnotations(),e=>LD(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`),!T6(B(t),a)&&P(t,a,!0)}let r=C6(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 T6(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 E6=fo,D6=250;function O6(e,t){return e.severity===`info`&&t-e.timestamp>=E6}function k6(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=>!O6(e,r)).slice(-50)}catch(e){return console.warn(`[useNotifications] failed to load activity history:`,e),[]}}function A6(e={}){let t=e.persist??!0,n=e.storageKey??`tandem:activityHistory`,r=N(un([])),i=N(un(t?k6(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,D6))},u=e=>{let t=a.get(e);t&&(clearTimeout(t),a.delete(e))},d=(e,t)=>{u(e);let n=uo[t]??uo.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,E6-(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:${wa}${_c}`,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?`)},xa(()=>{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 j6(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 M6(e){return`tandem:scratchpad:${e}`}var N6=`tandem:scratchpad:latest`,P6=500;function F6(e){let t=[],n=e=>{if(e instanceof jE)return e.toString();if(e instanceof EE){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 EE||i instanceof jE)&&t.push(n(i))}return t.join(`
269
+ `).replace(/\n+$/,``)}function I6(e){try{return localStorage.getItem(e)}catch{return null}}function L6(e,t){try{localStorage.setItem(e,t)}catch{}}function R6(e){try{localStorage.removeItem(e)}catch{}}function z6(e){let t=new Map,n=un({}),r=()=>Object.values(n).some(Boolean),i=e=>{let t=F6(e.ydoc.getXmlFragment(`default`)),r=M6(e.uuid);if(t.length===0){R6(r),I6(N6)===e.uuid&&R6(N6),n[e.uuid]=!1;return}L6(r,t),L6(N6,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:j6(()=>{},P6)};if(a.persist=j6(()=>i(a),P6),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(F6(r).length>0)return;let i=e.uuid,a=I6(M6(i));if(a===null&&t.size===1){let t=I6(N6);t&&t!==e.uuid&&(a=I6(M6(t)),i=t)}if(a===null||a.length===0)return;let o=a.split(`
270
+ `).map(e=>{let t=new EE(`paragraph`);return e.length>0&&t.insert(0,[new jE(e)]),t});Pk(e.ydoc,()=>{r.length>0&&r.delete(0,r.length),r.insert(0,o)}),L6(M6(e.uuid),a),L6(N6,e.uuid),i!==e.uuid&&R6(M6(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=>{R6(M6(e)),I6(N6)===e&&R6(N6),t.get(e)?.persist.cancel(),n[e]=!1},l=Rn(()=>{R(()=>{let n=e(),r=new Set;for(let e of n){if(!Co(e.filePath))continue;let t=wo(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 B6(e,t,n){return e.length<2?null:e[(e.findIndex(e=>e.id===t)+(n?-1:1)+e.length)%e.length].id}function V6(e,t,n){let r=null;ba(()=>{r=r=>{if(!r.ctrlKey&&!r.metaKey||r.key!==`Tab`)return;let i=B6(e(),t(),r.shiftKey);i&&(r.preventDefault(),n(i))},window.addEventListener(`keydown`,r)}),xa(()=>{r&&window.removeEventListener(`keydown`,r)})}function H6(e,t){return e.length===0||t<1||t>9?null:e[Math.min(t-1,e.length-1)].id}function U6(e){if(e.isComposing)return!0;let t=e.target;return t?t.tagName===`INPUT`||t.tagName===`TEXTAREA`:!1}function W6(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 G6(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 K6(e){let t=N(un([]));R(()=>{let n=e().map(e=>e.id),r=W6(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 W6(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,G6(B(t),n,r,o,i),!0)}}}function q6(e,t){let n=N(un((()=>{try{let e=localStorage.getItem(Fa),t=lc.safeParse(e);return t.success?t.data:Pa}catch(e){return console.warn(`[tandem] localStorage unavailable reading ${Fa}:`,e),Pa}})()));return R(()=>{let e=B(n);try{localStorage.setItem(Fa,e)}catch(e){console.warn(`[tandem] failed to persist ${Fa}:`,e)}}),R(()=>{let t=e(),r=B(n);if(t)try{t.getMap(Ua).set(Wa,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(Ua).set(Ga,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 J6=N(!1),Y6=!1,X6=()=>{},Z6={get fileDragOver(){return B(J6)}};function Q6(e){let t=e.split(/[/\\]/).at(-1)??``,n=t.lastIndexOf(`.`);return n<=0?!1:Da.has(t.slice(n).toLowerCase())}var $6=(()=>{let e=Array.from(Da).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 e8(e,t,n){X6({id:`tauri-drop-${n}-${Date.now()}`,type:`general-error`,severity:t,message:e,dedupKey:n,timestamp:Date.now()})}function t8(e){X6=e,!Y6&&sh()&&(Y6=!0,ql(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(J6,!0);return;case`drop`:P(J6,!1);for(let e of t.paths)if(Q6(e)){(async()=>{let t=await Jh(e);t.ok||e8(`Couldn't open ${e}: ${t.error}`,`error`,`tauri-drop-open-failed`)})();return}e8(`Tandem can only open ${$6} files`,`warning`,`tauri-drop-unsupported`);return;case`leave`:P(J6,!1);return;default:console.warn(`[useTauriFileDrop] unknown payload type:`,t)}}catch(e){console.error(`[useTauriFileDrop] callback threw:`,e),e8(`Drag-and-drop encountered an error — try the Open File dialog`,`error`,`tauri-drop-callback-error`)}})}).catch(e=>{Y6=!1,console.error(`[useTauriFileDrop] Failed to attach onDragDropEvent:`,e),e8(`Drag-and-drop unavailable — use the Open File dialog instead`,`warning`,`tauri-drop-unavailable`)}))}var n8=new class{#e=N(un(sh()?window.__TANDEM_INITIAL_THEME__??null:null));get current(){return B(this.#e)}set current(e){P(this.#e,e,!0)}},r8=!1;function i8(e){n8.current=e,typeof window<`u`&&(window.__TANDEM_INITIAL_THEME__=e)}function a8(){if(r8||!sh())return;r8=!0;let e=null;ql(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]).then(({invoke:t})=>{e=t,t(`get_app_theme`).then(e=>{i8(e===`dark`?`dark`:`light`)}).catch(e=>{console.warn(`[useTauriTheme] get_app_theme failed:`,e)})}).catch(e=>{console.warn(`[useTauriTheme] Tauri API import failed:`,e)}),ql(async()=>{let{getCurrentWindow:e}=await import(`./window-CR0qpD8C.js`);return{getCurrentWindow:e}},__vite__mapDeps([9,1,3])).then(({getCurrentWindow:e})=>{e().onThemeChanged(({payload:e})=>{i8(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`;n8.current!==n&&(i8(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 o8(e=`light`){let t=e===`warm`?`warm`:`light`;try{if(typeof window>`u`)return t;if(sh()){let e=n8.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 s8(e,t=`light`){return e===`system`?o8(t):e}function c8(e){try{let t=document.querySelector(`meta[name="theme-color"]`);t&&(t.content=e===`dark`?`#1c1c24`:e===`warm`?`#f1ead9`:`#fafaf9`)}catch{}}function l8(e,t=`light`){let n=document.documentElement,r=s8(e,t);if(n.setAttribute(`data-theme`,r),c8(r),e!==`system`||sh())return()=>n.removeAttribute(`data-theme`);let i=window.matchMedia(`(prefers-color-scheme: dark)`),a=()=>{let e=o8(t);n.setAttribute(`data-theme`,e),c8(e)};return i.addEventListener(`change`,a),()=>{i.removeEventListener(`change`,a),n.removeAttribute(`data-theme`)}}function u8(e,t=()=>`light`){a8(),R(()=>{let n=e(),r=t();return n8.current,l8(n,r)})}function d8(){try{return localStorage.getItem(po)===`true`}catch{return!1}}function f8(e){return e.author===`user`&&!e.id.startsWith(`tutorial-`)}function p8(){try{localStorage.setItem(po,`true`)}catch{}}function m8(e,t,n){let r=N(un(d8())),i=N(0),a=0,o=ah(),s=M(()=>n()===`welcome.md`),c=M(()=>!B(r)&&B(s)),l=sh(),u=xh(()=>l&&B(c)),d=M(()=>!l||u.status!==null||u.error!==null),f=M(()=>l&&ih(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(mo));t.length!==0&&t.some(e=>e.status!==`pending`)&&(a=Date.now(),P(i,1))}),R(()=>{!B(c)||B(i)!==1||e().some(f8)&&(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(()=>{p8(),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:()=>{p8(),P(r,!0)},nextStep:()=>{a=Date.now(),P(i,Math.min(B(i)+1,B(p)),!0)}}}var h8=`tandem://update-available`,g8=`tandem:updater-dismissed-v`;function _8(e){return`${g8}${e}`}function v8(e){try{return window.localStorage.getItem(_8(e))===`1`}catch{return!1}}function y8(e){try{window.localStorage.setItem(_8(e),`1`)}catch{}}var b8=N(null),x8=N(null),S8=0,C8=null,w8=!1,T8=0;function E8(){return S8}function D8(){return B(b8)}function O8(){return B(x8)}function k8(e){e&&(y8(e),P(x8,e,!0))}function A8(){if(S8+=1,S8===1&&sh()){w8=!1;let e=++T8;(async()=>{try{let{listen:t}=await ql(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1]));if(w8||e!==T8||E8()===0)return;let n=await t(h8,e=>{let t=e.payload?.version??null;t&&(P(b8,t,!0),B(x8)!==t&&P(x8,null))});if(w8||e!==T8||E8()===0){n();return}C8=n}catch(e){console.warn(`[useUpdaterChannel] listen() failed:`,e)}})()}let e=!1;return()=>{if(!e&&(e=!0,S8=Math.max(0,S8-1),S8===0)){w8=!0;let e=C8;if(C8=null,e)try{e()}catch(e){console.warn(`[useUpdaterChannel] unlisten threw:`,e)}}}}function j8(){return R(()=>A8()),{get availableVersion(){return D8()},get showDot(){let e=D8();return!(!e||O8()===e||v8(e))},acknowledge(){k8(D8())}}}var M8=3e4;function N8(){let e=N(!1),t=null;function n(){t!==null&&(clearTimeout(t),t=null)}R(()=>{let e=A8();return()=>{n(),e()}});async function r(){if(!(!D8()||B(e))){P(e,!0),n(),t=setTimeout(()=>{t=null,P(e,!1),console.warn(`[useUpdaterBanner] install_update did not tear down WebView within ${M8}ms; re-arming CTA`)},M8);try{let{invoke:t}=await ql(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 D8()},get installing(){return B(e)},get showBanner(){let e=D8();return!(!e||O8()===e||v8(e))},dismiss(){k8(D8())},install:r}}function P8(){let e=N(un(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 F8(){let e=null;ba(()=>{let t=!1,n;ql(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(vo);if(e!==null){let t=Number(e);Number.isFinite(t)?i=Math.max(yo,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(vo,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(yo,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?.()}}),xa(()=>{e?.()})}var I8=1e3;function L8(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(I8)}}finally{t=!1}}))}}function R8(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 z8(e,t,n){return e.filter(e=>!t.has(e.id)&&!n.has(e.id))}function B8(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 V8(e){let t=t=>({...t,...B8(e?.getRetryStrategy?.()??`exponential`)}),n=N(un([])),r=N(null),i=N(!1),a=N(`connecting`),o=N(0),s=N(null),c=N(un([])),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(Va),r=()=>{let e=[];n.forEach(t=>{e.push(Fk(t,e=>{console.warn(`[sanitize]`,e)}))}),P(c,e,!0)};n.observe(r),r();let i=t.getMap(Ha),a=null,o=!1,s=null,f=e=>e?`${e.tool} ${e.annotationId??``} ${e.token??e.startedAt}`:null,p=()=>{let e=i.get($a),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:${wa}${vc}`,{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)},D=L8({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}),ne=(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=z8(e,s,b),u=[];for(let e of l){b.add(e.id);let n=new UC,r=new MF(t({url:`ws://127.0.0.1:${Ca}`,name:e.id,document:n,token:v}));r.on(`authenticationFailed`,D),x.set(e.id,{ydoc:n,provider:r});let i=n.getMap(qa),a=e=>{if(!e.keysChanged.has(`openDocuments`)&&!e.keysChanged.has(`activeDocumentId`)&&!e.keysChanged.has(`activeDocumentEpoch`))return;let t=i.get(eo),n=i.get(to),r=i.get(no);t&&ne(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,R8({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 UC,r=new MF(t({url:`ws://127.0.0.1:${Ca}`,name:Ba,document:n,token:e}));P(h,n,!0),ie=r,r.on(`authenticationFailed`,D),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(qa),l=e=>{if(e.keysChanged.has(`openDocuments`)||e.keysChanged.has(`activeDocumentId`)||e.keysChanged.has(`activeDocumentEpoch`)){let e=c.get(eo),t=c.get(to),n=c.get(no);e&&ne(e,t??null,n??null)}e.keysChanged.has(`storeReadOnly`)&&P(f,c.get(ro)===!0)};c.observe(l);let u=c.get(eo),d=c.get(to),m=c.get(no);u&&ne(u,d??null,m??null),P(f,c.get(ro)===!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=Rn(()=>{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:${wa}${Sc}`,{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:${wa}${wc}`,{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 H8={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 U8(e){return e.column+e.inset+e.gap}H8.full.column;var W8=U8(H8.full);function G8(e){return 2*W8+e+480}function K8(e){let t=e+480;return{t1:G8(e),t2:2*U8(H8.narrow)+t,t3:2*U8(H8.stub)+t}}var q8={off:0,stub:1,narrow:2,full:3};function J8(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 q8[e]>q8[l]?l:q8[e]<q8[u]?u:e}function Y8(e,t,n){return e?t&&n===`full`?`full`:`off`:t?n:`off`}function X8(e,t,n){return!t&&!n?`off`:e}function Z8(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 Q8(e){let t=M(()=>(e.getLeftRailVisible()?e.leftRailWidthPx:0)+(e.getRightRailVisible()?e.rightRailWidthPx:0)),n=M(()=>K8(B(t))),r=N(`full`);R(()=>{let t=e.getViewportWidth(),i=B(n),a=jr(()=>B(r)),o=J8(a,t,i,32);o!==a&&P(r,o,!0)});let i=M(()=>e.getFormat()===`docx`),a=M(()=>Y8(B(i),e.getMarginView(),B(r))),o=M(()=>X8(B(a),B(i),e.getLeftHasPending())),s=M(()=>X8(B(a),B(i),e.getRightHasPending())),c=M(()=>B(o)!==`off`),l=M(()=>B(s)!==`off`),u=M(()=>B(c)||B(l)),d=M(()=>H8[B(o)]),f=M(()=>H8[B(s)]),p=new Set,m=M(()=>Z8({isDocx:B(i),effectivelyOn:B(u),leftReservePx:U8(B(d)),rightReservePx:U8(B(f)),measure:(()=>{let t=e.getEditorMeasure(),n=wl[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??wl.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 $8(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 e5(e){return e.mode===`stub`?`stub`:e.isEditing||e.isActive?`full`:e.mode===`narrow`?`clamped`:`full`}var t5=6;function n5(e,t={}){let n=t.gap??t5,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 r5(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 i5=.62;function a5(e){let t=e.endX-e.startX,n=e.startX+t*i5,r=e.endX-t*i5;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 o5(e){throw Error(`unhandled annotation author: ${String(e)}`)}function s5(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 o5(e)}}var c5=Yr(`<path stroke-linecap="round" fill="none"></path><circle data-testid="margin-anchor-dot"></circle>`,1),l5=H(`<div class="margin-bubble svelte-lzz9jv"><!></div>`),u5=H(`<svg aria-hidden="true"></svg> <div></div>`,1);function d5(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(un(new Map)),c=M(()=>new Map(B(o).map(e=>[e.id,e5({mode:t.mode,isActive:e.id===t.activeAnnotationId,isEditing:!1})]))),l=M(()=>n5(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));jr(()=>{r5(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&&rA(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(!sh())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 iA(n,h(t)))}R(()=>{let e=B(d);if(e)return e.addEventListener(`contextmenu`,g),()=>e.removeEventListener(`contextmenu`,g)}),R(()=>sA());var _=u5(),v=I(_);mi(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=Zr(),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(()=>s5(B(n).author)),d=M(()=>a5({startX:B(r),startY:B(a),endX:B(i),endY:B(l)}));var f=c5(),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);mi(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(()=>dO(B(r),t.repliesById.get(B(r).id))),o=M(()=>B(c).get(B(r).id)??`full`);var s=l5(),d=F(s);{let e=M(()=>B(r).id===t.activeAnnotationId),i=M(()=>Kk(B(r))?t.onAccept:void 0),s=M(()=>qk(B(r))?t.onDismiss:void 0),c=M(()=>Zk(B(r))?t.onRemove:void 0),l=M(()=>Xk(B(r))?t.onSendToClaude:void 0),u=M(()=>Yk(B(r))?t.onEdit:void 0),p=M(()=>Jk(B(r))?t.onReply:void 0),m=M(()=>B(f)?.id===B(r).id?B(f):null);jk(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;`)}),Ni(1,s,()=>Wv,()=>({id:B(r).id,reduceMotion:n()})),da(s,`clientHeight`,e=>u(B(r).id,e)),U(e,s)}),O(y),pa(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 f5(e){return e.type===`note`}function p5(e){return e.author===`import`||e.type===`comment`}var m5=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),h5=H(`<span></span>`),g5=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 _5(e,t){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`}var a=g5(),o=F(a),s=F(o,!0);O(o);var c=L(o,2),l=F(c),u=e=>{var t=m5();k(8),U(e,t)},d=e=>{var t=Zr();mi(I(t),17,n,e=>e.id,(e,t)=>{var n=h5();z(e=>Wi(n,1,`peek-dot ${e??``}`,`svelte-1mwvi22`),[()=>i(B(t))]),U(e,n)}),U(e,t)};G(l,e=>{t.kind===`outline`?e(u):e(d,-1)}),O(c);var f=L(c,2),p=F(f,!0);O(f),O(a),z(()=>{Wi(a,1,`peek-strip peek-strip-${t.side??``}`,`svelte-1mwvi22`),q(a,`data-testid`,`peek-strip-${t.side}`),q(a,`aria-label`,t.side===`left`?`Show left panel`:`Show right panel`),q(a,`aria-expanded`,!t.collapsed),K(a,t.collapsed?``:`display: none;`),W(s,t.side===`left`?`›`:`‹`),W(p,B(r))}),V(`click`,a,function(...e){t.onActivate?.apply(this,e)}),U(e,a)}Vr([`click`]);var v5=e=>{console.warn(`[sanitize]`,e)};function y5(e,t,n){if(e.suggestedText===void 0)return!1;let r=e.suggestedText,i=LD(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 b5({getYdoc:e,getEditor:t,getAnnotations:n,onActiveAnnotationChange:r,getScrollBehavior:i,getActiveAnnotationId:a,onApplyFailed:o}){let s=N(0),c=N(un(new Set)),l=new Map,u=null;xa(()=>{for(let e of l.values())clearTimeout(e);l.clear()});function d(){return n().filter(dc)}function f(n,r){let i=e();if(!i)return;let a=i.getMap(Va),s=a.get(n);if(!s||s.status!==`pending`)return;let l=Fk(s,v5);if(a.set(n,{...l,status:r}),r===`accepted`&&l.suggestedText!==void 0){let e=t();if(e&&!y5(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(Va),a=i.get(n);if(!a||a.status===`pending`)return m(n),!1;let o=Fk(a,v5),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=LD(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=LD(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 x5=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>`),S5=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>`),C5=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 w5(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 C3(()=>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=C5(),d=F(u);k3(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=S5(),r=F(t);mi(r,17,()=>n,({value:e,label:t})=>e,(e,t)=>{let n=()=>B(t).value,r=()=>B(t).label;var a=x5();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=Wi(a,1,`highlight-picker-swatch svelte-1d240y8`,null,o,{"is-selected":n()===B(i)}),K(s,`background: ${Ma[n()]??``};`)}),V(`click`,a,()=>l(n())),U(e,a)});var s=L(r,2);O(t),pa(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: ${Ma[B(i)]??``};`)}),V(`mousedown`,f,c),U(e,u),j()}Vr([`mousedown`,`click`]);var T5=H(`<div class="fmtbar-divider svelte-1lcxsnm"></div> <!>`,1),E5=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),D5=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 O5(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=t3(()=>{e.isDestroyed||sn(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=ND(n.doc,Eo(r)),o=ND(n.doc,Eo(i));if(a===null||o===null){console.warn(`[FormattingBar] pmPosToFlatOffset returned null — CRDT position may be degraded`,{from:r,to:i});return}W3(t.ydoc,{from:a,to:o},e)}var d=D5(),f=F(d),p=F(f),m=F(p);U3(m,{get editor(){return t.editor}});var h=L(m,4);{let e=M(()=>!B(c));w5(h,{get disabled(){return B(e)},onHighlight:u,onOpenChange:e=>P(l,e,!0)})}O(p);var g=L(p,2),_=e=>{var s=T5();S3(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=E5();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()}Vr([`click`]);var k5=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 A5(e,t){A(t,!0);var n=k5(),r=F(n);let i;var a=L(r,2),o=L(a,2);O(n),z(()=>{i=Wi(r,1,`thumb svelte-14q5edy`,null,i,{tandem:t.tandemMode===`tandem`}),Wi(a,1,Ri(t.tandemMode===`solo`?`on`:``),`svelte-14q5edy`),q(a,`aria-pressed`,t.tandemMode===`solo`),Wi(o,1,Ri(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()}Vr([`click`]);var j5=[{value:`system`,label:`Match system`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`warm`,label:`Warm`}],M5=H(`<span class="titlebar-settings-dot svelte-12l7ydf" data-testid="titlebar-update-available-dot" aria-hidden="true"></span>`),N5=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>`),P5=H(`<div class="brand-menu-divider svelte-12l7ydf" role="separator"></div>`),F5=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),I5=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>`),L5=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>`),R5=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>`),z5=H(`<div class="title-bar-center svelte-12l7ydf" data-tauri-drag-region="false"><!></div>`),B5=H(`<button type="button" data-testid="titlebar-source-toggle" data-tauri-drag-region="false"><span aria-hidden="true">&lt;/&gt;</span></button>`),V5=H(`<span class="status-dot svelte-12l7ydf" data-tauri-drag-region="false" title="AI assistant is connected" aria-label="AI assistant is connected"></span>`),H5=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>`),U5=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>`),W5=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>`),G5=Yr(`<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>`),K5=Yr(`<svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M0 0H10V10H0V0ZM1 2V9H9V2H1Z" fill="currentColor"></path></svg>`),q5=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),J5=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 Y5(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;ba(async()=>{if(sh())try{let[{invoke:e},{getCurrentWindow:t}]=await Promise.all([ql(()=>import(`./core-SwWLTXZB.js`),[]),ql(()=>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)}}),xa(()=>{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 C3(()=>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=J5(),T=F(ee),E=F(T),te=L(F(E),2),D=e=>{U(e,M5())},ne=M(()=>sh()&&a());G(te,e=>{B(ne)&&e(D)}),O(E),pa(E,e=>i(e),()=>i());var re=L(E,2),ie=e=>{var n=R5(),i=F(n),a=e=>{var n=F5(),i=L(I(n),2);mi(i,21,()=>j5,e=>e.value,(e,t)=>{var n=N5();let i;var a=L(F(n),2),o=F(a,!0);O(a),O(n),z(()=>{i=Wi(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,P5())};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=I5();V(`click`,t,C),U(e,t)};G(o,e=>{t.onOpenSettings&&e(s)});var c=L(o,2),l=e=>{var t=L5();V(`click`,t,w),U(e,t)};G(c,e=>{t.onOpenHelp&&e(l)}),O(n),pa(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=z5();xi(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=B5();let n;z(()=>{n=Wi(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=>{A5(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,V5())};G(fe,e=>{n()&&e(pe)});var me=L(fe,2),he=e=>{var n=H5();V(`click`,n,function(...e){t.onConnectAi?.apply(this,e)}),U(e,n)},ge=e=>{var n=U5();V(`click`,n,function(...e){t.onRestartClaude?.apply(this,e)}),U(e,n)},_e=e=>{var n=W5(),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=q5(),n=L(I(t),2),r=F(n),i=L(r,2),a=F(i),o=e=>{U(e,G5())},s=e=>{U(e,K5())};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(()=>sh());G(ve,e=>{B(be)&&e(ye)}),O(ee),z(()=>q(E,`aria-expanded`,B(_))),V(`click`,E,y),U(e,ee),j()}Vr([`click`,`keydown`]);var X5=`tandem-status-count-mode`,Z5=[`words`,`characters`,`sentences`,`paragraphs`,`pages`,`reading`],Q5={words:`words`,characters:`chars`,sentences:`sentences`,paragraphs:`paragraphs`,pages:`pages`,reading:`min read`},$5=250,e7=200;function t7(e){let t=e.trim();return t?t.split(/\s+/).length:0}function n7(e){return Z5[(Z5.indexOf(e)+1)%Z5.length]??`words`}function r7(e){return Q5[e]}function i7(){try{let e=localStorage.getItem(X5);if(e&&Z5.includes(e))return e}catch{}return`words`}function a7(e){try{localStorage.setItem(X5,e)}catch{}}function o7(e,t){if(!e||e.isDestroyed)return 0;let n=e.state.doc.textContent;switch(t){case`characters`:return n.length;case`words`:return t7(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(t7(n)/$5);case`reading`:{let e=t7(n);return e===0?0:Math.max(1,Math.round(e/e7))}}}var s7=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>`),c7=H(`<span data-testid="save-indicator" style="color: var(--tandem-accent);" class="svelte-1esxubl">Saving...</span>`),l7=H(`<span data-testid="saved-indicator" style="color: var(--tandem-success-fg-strong);" class="svelte-1esxubl"> </span>`),u7=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>`),d7=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>`),f7=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 p7(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=ED(Dv()),s=N(!1),c=N(0),l=jr(()=>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=jr(()=>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(un(i7())),_=N(0);R(()=>{let e=t.editor;if(!e||e.isDestroyed)return;let n=t3(()=>{e.isDestroyed||sn(_)});return e.on(`update`,n),e.on(`transaction`,n),()=>{e.off(`update`,n),e.off(`transaction`,n)}});let v=M(()=>(B(_),o7(t.editor??null,B(g))));function y(){let e=n7(B(g));P(g,e,!0),a7(e)}var b=f7(),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=s7(),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: ${r7(n7(B(g)))}`,()=>`${B(v)} ${r7(B(g))} (click to change unit)`,()=>B(v).toLocaleString(),()=>r7(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,c7())},D=e=>{var t=l7(),n=F(t,!0);O(t),z(()=>W(n,B(u))),U(e,t)};G(E,e=>{r()?e(te):B(u)&&e(D,1)}),O(x);var ne=L(x,2),re=e=>{U(e,u7())};G(ne,e=>{t.readOnly&&e(re)});var ie=L(ne,2),ae=F(ie),oe=L(ae,2),se=F(oe,!0);O(oe);var ce=L(oe,2),le=e=>{var t=d7(),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()}Vr([`click`]);function m7(e){let t=e-1;return t*t*t+1}function h7(e,{from:t,to:n},r={}){var{delay:i=0,duration:a=e=>Math.sqrt(e)*120,easing:o=m7}=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=g7(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 g7(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 _7(e){return e.source===`file`&&!e.readOnly}var v7={md:`md`,markdown:`md`,docx:`docx`,doc:`docx`,txt:`txt`,text:`txt`,html:`html`,htm:`html`};function y7(e){let t=e.lastIndexOf(`.`);return t<=0||t===e.length-1?`other`:v7[e.slice(t+1).toLowerCase()]??`other`}function b7(e){let t=e.split(/[/\\]/);return{name:t.at(-1)??e,dir:t.slice(0,-1).join(`/`)}}function x7(e,t=Date.now()){let{dir:n,name:r}=b7(e.path);return{path:e.path,name:r,dir:n,when:eu(e.openedAt,t),pip:y7(r)}}function S7(e,t){let n=t.trim();if(!n)return e.map(e=>({row:e,nameSegments:Am(e.name,[])}));let r=[];for(let t=0;t<e.length;t++){let i=e[t],a=Om(n,i.name,i.dir);a&&r.push({result:{row:i,nameSegments:Am(i.name,a.indices)},score:a.score,origIndex:t})}return km(r)}var C7=Yr(`<path></path>`),w7=Yr(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"></svg>`),T7=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>`),E7=H(`<span class="ntl-count svelte-7c4il0" aria-hidden="true"> </span>`),D7=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>`),O7=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>`),k7=H(`<mark class="svelte-7c4il0"> </mark>`),A7=H(`<span class="ntl-path svelte-7c4il0"> </span>`),j7=H(`<span class="ntl-when svelte-7c4il0"> </span>`),M7=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>`),N7=H(`<div class="ntl-recents svelte-7c4il0"></div>`),P7=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>`),F7=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 I7(e,t){A(t,!0);let n=(e,t=m,n=m,r=m)=>{var i=w7();mi(i,21,()=>u[t()]??[],ui,(e,t)=>{var n=C7();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=>x7(e))),s=M(()=>S7(B(o),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=F7(),g=F(h),_=F(g);n(F(_),()=>`search`,()=>13,()=>1.7),O(_);var v=L(_,2);ea(v),pa(v,e=>P(a,e),()=>B(a));var y=L(v,2),b=e=>{var t=T7();V(`click`,t,()=>P(r,``)),U(e,t)};G(y,e=>{B(l)&&e(b)});var x=L(y,2),S=e=>{var t=E7(),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=D7(),r=F(t);n(F(r),()=>`inbox`,()=>16,()=>1.6),O(r),k(2),O(t),U(e,t)},E=e=>{var t=O7(),n=F(t);k(),O(t),z(e=>W(n,`No matches for “${e??``}”. `),[()=>B(r).trim()]),U(e,t)},te=e=>{var n=N7();mi(n,23,()=>B(s),e=>e.row.path,(e,n,r)=>{var i=M7(),a=F(i),o=L(a,2),s=F(o);mi(s,21,()=>B(n).nameSegments,ui,(e,t)=>{var n=Zr(),r=I(n),i=e=>{var n=k7(),r=F(n,!0);O(n),z(()=>W(r,B(t).text)),U(e,n)},a=e=>{var n=Xr();z(()=>W(n,B(t).text)),U(e,n)};G(r,e=>{B(t).match?e(i):e(a,-1)}),U(e,n)}),O(s);var c=L(s,2),l=e=>{var t=A7(),r=F(t,!0);O(t),z(()=>W(r,B(n).row.dir)),U(e,t)};G(c,e=>{B(n).row.dir&&e(l)}),O(o);var u=L(o,2),d=e=>{var t=j7(),r=F(t,!0);O(t),z(()=>W(r,B(n).row.when)),U(e,t)};G(u,e=>{B(n).row.when&&e(d)}),O(i),z(()=>{q(i,`data-testid`,`new-tab-recent-${B(r)}`),q(i,`title`,B(n).row.path),Wi(a,1,`ntl-pip ntl-pip-${B(n).row.pip??``}`,`svelte-7c4il0`)}),V(`click`,i,()=>t.onOpen(B(n).row.path)),U(e,i)}),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 D=L(w,2),ne=L(F(D),2),re=F(ne);n(F(re),()=>`plus`,()=>14,()=>1.9),O(re),k(4),O(ne);var ie=L(ne,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=P7(),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(D),O(C),k(2),O(h),pa(h,e=>P(i,e),()=>B(i)),V(`keydown`,h,p),oa(v,()=>B(r),e=>P(r,e)),V(`click`,ne,function(...e){t.onNewScratchpad?.apply(this,e)}),V(`click`,ie,function(...e){t.onBrowse?.apply(this,e)}),U(e,h),j()}Vr([`keydown`,`click`]);var L7=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 R7(e,t){A(t,!0);let n=N(un(jr(()=>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=L7();ea(s),Bn(()=>oa(s,()=>B(n),e=>P(n,e))),Fi(s,e=>a?.(e)),z(()=>q(s,`data-testid`,t.testId)),V(`keydown`,s,o),Br(`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()}Vr([`keydown`,`pointerdown`,`click`,`dblclick`]);var z7=H(`<span class="dot svelte-1btt0ja" aria-hidden="true">●</span>`),B7=H(`<span class="saved-check svelte-1btt0ja" aria-hidden="true">✓</span>`),V7=H(`<span class="svelte-1btt0ja"> </span>`),H7=H(`<span class="tab-ro-badge svelte-1btt0ja" aria-label="Read-only">RO</span>`),U7=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 W7(e,t){A(t,!0);let n=J(t,`reduceMotion`,3,!1),r=J(t,`isRenaming`,3,!1),i=M(()=>_7(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(qa),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(Ya);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=U7();q(m,`tabindex`,0);var h=F(m),g=F(h),_=e=>{U(e,z7())},v=e=>{U(e,B7())};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}`);R7(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=V7(),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,H7())};G(S,e=>{t.tab.readOnly&&e(C)});var w=L(S,2);pa(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()),Br(`mouseenter`,w,f),Br(`mouseleave`,w,p),Ni(1,m,()=>Jv,()=>({reduceMotion:n()})),Ni(2,m,()=>Kv,()=>({reduceMotion:n()})),U(e,m),j()}Vr([`click`,`pointerdown`,`keydown`,`dblclick`]);var G7=new Set([`ctx:tab:close`,`ctx:tab:closeOthers`,`ctx:tab:closeRight`,`ctx:tab:copyPath`,`ctx:tab:reveal`]);function K7(e){return typeof e==`string`&&G7.has(e)}function q7(e){return!Co(e)&&!So(e)}function J7(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&&q7(r.filePath)}}function Y7(e,t){return e.some(e=>e.id===t)?e.filter(e=>e.id!==t).map(e=>e.id):[]}function X7(e,t){let n=e.findIndex(e=>e.id===t);return n<0?[]:e.slice(n+1).map(e=>e.id)}var Z7=H(`<div class="tab-flip svelte-urrc8n" role="presentation"><!></div>`),Q7=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 $7(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(un([])),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(!sh())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 uh())(`show_tab_context_menu`,{req:J7(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&&q7(r))try{await navigator.clipboard.writeText(r)}catch{}return;case`ctx:tab:reveal`:if(r&&q7(r))try{await(await uh())(`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,D=0,ne=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}xa(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(!sh())return;let e=ql(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;K7(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,D=e.clientX,ne=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-D,n=e.clientY-ne;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,ou(),!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(!jr(()=>B(h)))return;xe&&clearTimeout(xe);let e=Ce();if(e<=0){P(h,!1);return}xe=setTimeout(()=>{P(h,!1),xe=null},e)}),xa(()=>{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`)||w3(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&&jr(ve)}),R(()=>{i()>0&&jr(()=>{let e=t.tabs.find(e=>e.id===t.activeTabId);e&&_7(e)&&P(o,e.id,!0)})});var De=Q7(),Oe=F(De);mi(Oe,29,()=>t.tabs,e=>e.id,(e,r)=>{var i=Z7(),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);W7(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),Mi(i,()=>h7,()=>({duration:Pv(n())?0:200})),U(e,i)}),O(Oe),pa(Oe,e=>P(C,e),()=>B(C));var ke=L(Oe,2),Ae=F(ke);let je;var Me=F(Ae);pa(Me,e=>P(p,e),()=>B(p));var Ne=L(Me,2),Pe=F(Ne),Fe=F(Pe),Ie=e=>{I7(e,{get recentFiles(){return B(f)},get closedTabTop(){return a()},onOpen:async e=>{ye();let t=await Jh(e);t.ok?nu(Ql(ou(),e)):console.warn(`[tandem] failed to open recent file:`,t.error)},onNewScratchpad:()=>{ye(),xu()},onBrowse:()=>{ye(),t.onRequestOpenDialog?.()},onReopenClosed:()=>{ye(),t.onReopenClosed?.()},onClose:ye})};G(Fe,e=>{B(h)&&e(Ie)}),O(Pe),O(Ne),O(Ae),pa(Ae,e=>P(g,e),()=>B(g)),O(ke),O(De),z(()=>{Wi(Oe,1,Ri([`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=Wi(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()}Vr([`click`]);var e9=(e,t=m,n=m)=>{var r=n9();z(()=>{Wi(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)},t9=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>`),n9=H(`<div role="button" tabindex="-1"></div>`),r9=H(`<!> <!>`,1),i9=H(`<!> <!> <!>`,1),a9=H(`<div class="margin-track svelte-y74n0s" style="grid-column: 2; grid-row: 1;"><!></div>`),o9=H(`<div class="margin-track svelte-y74n0s" style="grid-column: 4; grid-row: 1;"><!></div>`),s9=H(`<div class="editor-content-track svelte-y74n0s" style="grid-column: 3; grid-row: 1;"><!></div> <!> <!>`,1),c9=H(`<div class="editor-end-marker svelte-y74n0s" aria-hidden="true"><span class="editor-end-pill svelte-y74n0s">End of document</span></div>`),l9=H(`<div data-testid="editor-stage"><!></div> <!>`,1),u9=H(`<div class="editor-column-wrap svelte-y74n0s"><div data-testid="editor-scroll-container" role="region" aria-label="Document editor"><!> <!> <!></div> <!></div>`),d9=H(`<div style="display: flex; flex: 1; align-items: center; justify-content: center; color: var(--tandem-fg-subtle);">Connecting...</div>`),f9=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>`),p9=H(`<div class="rail-float-shadow rail-float-shadow-left svelte-y74n0s" aria-hidden="true"></div>`),m9=H(`<div class="rail-float-shadow rail-float-shadow-right svelte-y74n0s" aria-hidden="true"></div>`),h9=H(`<span class="rail-tab-badge svelte-y74n0s"> </span>`),g9=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),_9=H(`<div style="display: flex; flex-direction: column; height: 100vh; background: var(--tandem-bg); color: var(--tandem-fg);"><!> <!></div>`);function v9(e,t){A(t,!0);let n=e=>{$7(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(k)},onTabRename:(e,t)=>a.handleTabRename(e,t,e=>w.push({id:hc(),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=t9();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,()=>{}),Br(`mouseenter`,a,e=>{e.currentTarget.style.background=`var(--tandem-border-strong)`}),Br(`mouseleave`,a,e=>{e.currentTarget.style.background=`transparent`}),U(e,a)},i=e=>{var t=u9(),n=F(t);let r;{let e=e=>{e3(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);d5(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);XA(i,{get visible(){return B(e)},get documentId(){return B(t)}})}var o=L(i,2),s=e=>{var t=r9(),n=I(t);jh(n,{get ydoc(){return B(St).ydoc},get documentId(){return B(St).id},get fileName(){return B(St).fileName}}),qh(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=Zr();li(I(t),()=>B(St).id,e=>{{let t=M(()=>B(Le).get(B(St).id));_3(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=l9(),i=I(r),o=F(i),s=n=>{var r=i9(),i=I(r);li(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=s9(),i=I(r),o=F(i),s=t=>{var n=Zr();li(I(n),()=>B(St).id,t=>{e(t)}),U(t,n)},c=e=>{Rh(e,{get connected(){return a.connected},get aiChip(){return ne.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=a9();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=o9();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),pa(i,e=>P(Me,e),()=>B(Me));var l=L(i,2),u=e=>{U(e,c9())};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),pa(n,e=>P(Ct,e),()=>B(Ct)),Fi(n,(e,t)=>Gu?.(e,t),()=>`y`)}d3(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=Wi(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||Z6.fileDragOver?`2px dashed var(--tandem-accent)`:`2px solid transparent`}; background: ${T.fileDragOver||Z6.fileDragOver?`var(--tandem-accent-bg)`:`var(--tandem-bg)`}; transition: border-color 0.15s, background 0.15s; border-radius: ${T.fileDragOver||Z6.fileDragOver?`var(--tandem-r-5)`:`0`};`)}),Br(`dragover`,n,function(...e){T.handleEditorDragOver?.apply(this,e)}),Br(`dragleave`,n,function(...e){T.handleEditorDragLeave?.apply(this,e)}),Br(`drop`,n,function(...e){T.handleEditorDrop?.apply(this,e)}),U(e,t)},a=V8({getRetryStrategy:()=>h.settings.sidecarRetryStrategy});xa(()=>a.destroy());let o=z6(()=>a.tabs);xa(()=>o.destroy()),mv.start({onTransition:()=>a.rebuildForLicenseChange()}),xa(()=>mv.stop());let s=c6(),c=new Set;function l(e){let t=a.tabs.find(t=>t.id===e);if(t&&Co(t.filePath)){let e=wo(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&&!So(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 Y7(p.orderedTabs,e))l(t)}function d(e){for(let t of X7(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 Jh(e.filePath);t.ok||n(t.error)}finally{c.delete(e.filePath)}}let p=K6(()=>a.tabs);V6(()=>p.orderedTabs,()=>a.activeTabId,e=>a.setActiveTabId(e)),R(()=>{let e=a.tabs;if(e.length!==0)try{let t=tu(),n=t;for(let t of e)So(t.filePath)||(n=Ql(n,t.filePath));(n.length!==t.length||n.some((e,n)=>e!==t[n]))&&nu(n)}catch(e){console.warn(`[tandem] failed to sync recent files:`,e)}});let h=Dv(),g=q6(()=>a.bootstrapYdoc,()=>h.settings.selectionDwellMs),_=$8(h,g),v=M(()=>Sl(h.settings.customShortcuts)),y=M(()=>fl(B(v))),b=M(()=>a.annotations),x=l6(()=>a.disconnectedSince,()=>h.settings.degradedBannerDelayMs),S=N8();F8();let C=M(()=>a.tabs.map(e=>({id:e.id,fileName:e.fileName}))),w=A6(),ee=N(!1),T=_6();if(t8(w.push),sh()){let e=null,t=!1;ql(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)}),xa(()=>{t=!0,e?.()})}if(sh()){let e=null,t=!1;ql(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()})}),xa(()=>{t=!0,e?.()})}if(sh()){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;ql(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)}),ql(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)}),xa(()=>{r=!0,n?.()})}let E=N(!1),te=N(!1),D=y6(),ne=n6({connected:()=>a.connected,firstRunSettled:()=>D.settled,soloMode:()=>g.tandemMode===`solo`}),re=!1;R(()=>{a.connected&&!re&&D.needed!==!0&&D.refetch().then(e=>{e&&(re=!0)})});function ie(){window.dispatchEvent(new CustomEvent(`tandem:open-integration-wizard`))}function ae(){Ru(),setTimeout(()=>ne.refresh(),2e3),setTimeout(()=>ne.refresh(),5e3)}R(()=>{let e=async e=>{let t=e.detail?.via;if(ne.chip===null||await ne.probeSession())return;let n=ne.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(un(le())),ce=N(!1);function le(){try{return localStorage.getItem(oe)}catch{return null}}let ue=M(()=>D.needed===!0&&D.serverVersion!==null&&B(se)!==D.serverVersion),de=M(()=>B(ce)||B(ue));function fe(){if(B(ue)&&D.serverVersion!==null)try{localStorage.setItem(oe,D.serverVersion),P(se,D.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),D.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 Qh({isTauri:sh(),openModal:()=>{P(he,!0)},onError:e=>w.push({id:hc(),type:`general-error`,severity:`error`,message:e,timestamp:Date.now()})})}let _e=j8();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,tN.models,!0),ye()}function Se(){_e.acknowledge(),P(E,!0)}pu({getActiveTabId:()=>a.activeTabId,getActiveDocumentPath:()=>{let e=a.tabs.find(e=>e.id===a.activeTabId);return e&&!So(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?h4(e.state):void 0;e&&v6(t)?e.commands.findNext():(P(Fe,`doc`),P(Pe,!0))},findPrev:()=>{let e=B(je),t=e?h4(e.state):void 0;e&&v6(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=rO(B(b)),t=sO(e,B(Oe));if(t){P(Oe,t,!0);let n=e.find(e=>e.id===t);n&&Mt.scrollToAnnotation(n)}},annotationPrev:()=>{let e=rO(B(b)),t=cO(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||!So(e.filePath)){w.push({id:hc(),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 Du({activeDocId:a.activeTabId,defaultName:n,sourceFormat:e.format,notify:(e,t)=>w.push({id:hc(),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&&jr(()=>{let t=e.state.tr.setMeta(Q2,{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&&jr(()=>{let t=e.state.tr.setMeta(R2,{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`))),u8(()=>h.settings.theme,()=>h.settings.systemLightVariant),e6(()=>h.settings.accentHue),g6(()=>zl(h.settings,B(St)?.format)),d6(()=>h.settings.density),x6(()=>h.settings.highContrast),i6(()=>h.settings.annotationPatterns),R(()=>{let e=Ol[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(un(h.settings.primaryTab===`chat`?`chat`:`annotations`)),De=M(()=>B(Ee)===`annotations`?0:B(b).filter(dc).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(un(new Set)),Le=N(un(new Map)),Re=N(un(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),He=N(0),k=N(0),Ue=N(0),We=f6(`left`),Ge=f6(`right`),Ke=p6({side:`left`,initialWidth:We,getVisible:()=>B(Je)}),qe=p6({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=un({left:!1,right:!1}),tt=un({left:!1,right:!1}),nt=un({left:!1,right:!1}),rt=un({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)||Pv(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=jr(()=>({left:B(Je),right:B(Ye)}));R(()=>{let e=B(Je),t=B(Ye);jr(()=>{_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=P8(),yt=Q8({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`&&f5(e)),getRightHasPending:()=>B(b).some(e=>e.status===`pending`&&p5(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=RD(B(je).state.doc,{from:Eo(e),to:Eo(t)}),r=B(je).state.doc.textBetween(e,t,`
271
+ `);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,jr(()=>!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)&&Au(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||!So(n.filePath)){w.push({id:hc(),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);Du({activeDocId:a.activeTabId,defaultName:i,sourceFormat:n.format,notify:(e,t)=>w.push({id:hc(),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,!jr(()=>B(me)))},"new-scratchpad":e=>{let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`)||(e.preventDefault(),xu())},"close-tab":e=>{if(U6(e))return;e.preventDefault();let t=a.activeTabId;t&&l(t)},"open-file":e=>{U6(e)||(e.preventDefault(),ge())},"pick-tab":(e,t)=>{if(U6(e))return;let n=t?.tabIndex;if(n===void 0)return;let r=H6(a.tabs,n);r&&(e.preventDefault(),a.setActiveTabId(r))},"toggle-mode":e=>{U6(e)||(e.preventDefault(),g.setTandemMode(g.tandemMode===`solo`?`tandem`:`solo`))},"reopen-closed-tab":e=>{U6(e)||(e.preventDefault(),f())},"new-tab-menu":e=>{U6(e)||(e.preventDefault(),P(k,B(k)+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(U6(e))return;e.preventDefault();let n=B(je),r=n?h4(n.state):void 0;n&&v6(r)?t?.shift?n.commands.findPrev():n.commands.findNext():(P(Fe,`doc`),P(Pe,!0))},"annotation-accept-or-dismiss":(e,t)=>{if(U6(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(He,B(He)+1)}},"toggle-authorship":e=>{e.preventDefault(),Ce(!h.settings.showAuthorship)},"toggle-left-panel":e=>{U6(e)||(e.preventDefault(),Ze())},"toggle-right-panel":e=>{U6(e)||(e.preventDefault(),Qe())},"annotation-next":e=>{if(U6(e))return;e.preventDefault();let t=rO(B(b)),n=sO(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(U6(e))return;e.preventDefault();let t=rO(B(b)),n=cO(t,B(Oe));if(n){P(Oe,n,!0);let e=t.find(e=>e.id===n);e&&Mt.scrollToAnnotation(e)}},"select-block":e=>{U6(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(U6(e))return;let t=a.tabs.find(e=>e.id===a.activeTabId);t&&_7(t)&&(e.preventDefault(),P(Ue,B(Ue)+1));return}let t=ml(e,jr(()=>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)||mv.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(!bu({connected:a.connected,tabCount:a.tabs.length,activeTabId:a.activeTabId}))return;let e=setTimeout(()=>{xu()},400);return()=>clearTimeout(e)});let Mt=b5({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(f5):[]),Ft=M(()=>yt.effectivelyOn?B(b).filter(p5):[]),It=w6({getEditor:()=>B(je),getYdoc:()=>B(St)?.ydoc??null,getAnnotations:()=>[...B(Pt),...B(Ft)],getLayerEl:()=>B(Me),getEnabled:()=>yt.effectivelyOn}),Lt=a6({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)=>Lk(e,t,n),onReply:(e,n)=>Hk(e,n,t),onRemove:e=>Vk(e,t),onSendToClaude:t=>zk(e,t)}}),zt=m8(()=>B(b),()=>B(je),()=>B(St)?.fileName);var Bt=_9(),Vt=F(Bt);{let e=M(()=>null),t=M(()=>B(Ot)||B(kt)?At:null);Y5(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 ne.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,d9())},Wt=e=>{var t=g9(),n=I(t),o=e=>{U(e,f9())};G(n,e=>{a.serverRestarted&&e(o)});var s=L(n,2),c=e=>{kN(e,{get version(){return S.availableVersion},get installing(){return S.installing},onInstall:()=>{S.install()},get onDismiss(){return S.dismiss}})},l=M(()=>sh()&&S.showBanner&&S.availableVersion);G(s,e=>{B(l)&&e(c)});var u=L(s,2),d=e=>{Km(e,{get onDismiss(){return x.dismiss},onRetry:()=>{a.reconnect()}})};G(u,e=>{x.showBanner&&e(d)});var f=L(u,2);_v(f,{});var p=L(f,2);{let e=M(()=>B(St)?.ydoc??null),t=M(()=>B(Ne)||B(Pe)||B(me));Q3(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(He)},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);O5(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 D=F(v),ne=e=>{var t=p9();z(()=>K(t,`width: ${Ke.width}px;`)),U(e,t)};G(D,e=>{(tt.left||rt.left)&&e(ne)});var re=L(D,2),ie=F(re);KA(ie,{kind:`outline`,get focusTrigger(){return B(Ve)},get editor(){return B(je)},visible:!0}),e9(L(ie,2),()=>`left`,()=>Ze),O(re);var ae=L(re,2);{let e=M(()=>!B(Je));_5(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=m9();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);e9(Ce,()=>`right`,()=>Qe);var we=L(Ce,2),Te=F(we),Me=F(Te),Fe=L(F(Me)),Ie=e=>{var t=h9(),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`);KA(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`);KA(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));_5(Be,{side:`right`,get collapsed(){return B(e)},kind:`annotations`,get annotations(){return B(b)},onActivate:Qe})}O(ge),O(_);var k=L(_,2);{let e=M(()=>a.claudeWorking?.tool??null);p7(k,{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 _u.saving},get lastSaveOk(){return _u.lastSaveOk},get editor(){return B(je)}})}var Ue=L(k,2);xN(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);oN(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);Sv(Ge,{});var Xe=L(Ge,2);bg(Xe,{get open(){return B(ke)},onClose:()=>P(ke,!1),get effectiveShortcutLabels(){return B(y)}});var A=L(Xe,2),j=e=>{sv(e,{open:!0,onClose:fe})};G(A,e=>{B(de)&&e(j)});var $e=L(A,2),it=e=>{hg(e,{onClose:()=>P(he,!1)})};G($e,e=>{B(he)&&e(it)});var at=L($e,2);Wm(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);DN(ot,{get toasts(){return w.toasts},get onDismiss(){return w.dismiss}});var st=L(ot,2);od(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=Ku(e);t&&(a.tabs.some(e=>e.id===t.documentId)?Au(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=>{Oh(e,{})},dt=M(()=>sh()&&!B(de));G(ct,e=>{B(dt)&&e(lt)});var gt=L(ct,2),_t=e=>{fy(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=Wi(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=Wi(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;`),Wi(Me,1,`rail-tab`+(B(Ee)===`annotations`?` on`:``),`svelte-y74n0s`),Wi(Le,1,`rail-tab`+(B(Ee)===`chat`?` on`:``),`svelte-y74n0s`)}),Br(`scroll`,_,e=>{e.currentTarget.scrollLeft=0}),Br(`mouseenter`,v,()=>ut(`left`)),Br(`mouseleave`,v,()=>ft(`left`)),V(`focusin`,v,()=>pt(`left`)),V(`focusout`,v,e=>mt(`left`,e)),Br(`transitionend`,v,e=>ht(`left`,e)),Br(`mouseenter`,ge,()=>ut(`right`)),Br(`mouseleave`,ge,()=>ft(`right`)),V(`focusin`,ge,()=>pt(`right`)),V(`focusout`,ge,e=>mt(`right`,e)),Br(`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()}Vr([`mousedown`,`keydown`,`keyup`,`click`,`focusin`,`focusout`]);var y9=`error-boundary-recover-btn`,b9=`error-boundary-reload-btn`;function x9(e,t){A(t,!0),R(()=>{t.onSuccess()}),j()}var S9=H(`<button class="btn btn-primary svelte-1bcl6yi">Try to recover</button>`),C9=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>`),w9=H(`<!> <!>`,1);function T9(e,t){A(t,!0);let n=N(0),r=N(0);var i=Zr();Rt(I(i),{onerror:e=>{UM(e,{source:`ErrorBoundary`}),P(r,B(r)+1)},failed:(e,t=m,i=m)=>{var a=Zr();li(I(a),()=>B(r),e=>{var r=C9(),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=S9();z(()=>q(t,`data-testid`,y9)),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`,b9)},[()=>t()instanceof Error?t().message:String(t())]),V(`click`,d,()=>window.location.reload()),U(e,r)}),U(e,a)}},e=>{var r=w9(),i=I(r);xi(i,()=>t.children),x9(L(i,2),{onSuccess:()=>{P(n,0)}}),U(e,r)}),U(e,i),j()}Vr([`click`]);function E9(e){T9(e,{children:(e,t)=>{v9(e,{})},$$slots:{default:!0}})}VM(),$r(E9,{target:document.getElementById(`root`)});export{V as A,A as B,mi 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,Xr as O,I as P,M as R,Wi as S,W as T,t as U,k as V,xa as _,uh as a,na as b,rh as c,ch as d,Jm as f,Ta as g,_o as h,fh as i,B as j,Vr as k,qm as l,Qm as m,ph as n,eh as o,$m as p,mh as r,nh as s,xh as t,Zm as u,ea as v,G as w,K as x,q as y,j as z};