finch-markdown-editor 0.2.23 → 0.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/codemirror.js +1 -1
- package/package.json +1 -1
package/dist/codemirror.js
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
`)),l=ef(s).toString(),a=l.indexOf(sr),c=l.lastIndexOf(sr)-1;return i?{anchor:a,head:c}:{head:a,anchor:c}}function gW(t){if(N(t.tableElement)||Uv(t.document))return;let e=lW(t.document);if(N(e)||!_v(t.tableElement,e))return;let i=ma(e);if(N(i))return;let n=Qf(i);t.selection.isCell()&&wo(t.selection.cell,n)||(t.activeTable=!1,t.selectionValue={cell:n,section:$W(t.document,e)},t.activeCell=n,t.anchorCell=n,t.outlinedSection=nt.ofCell(n))}function $W(t,e){let i=tQ(e),n=bq({ancestor:i,descendent:e,getText:l=>$q(l)?`
|
|
40
40
|
`:l.textContent??""})??"",r=(e.textContent??"").slice(0,d2(t)),o=kt(`${n}${r}`),s=n.length+d2(t);return iQ({anchor:s,head:s},o,{trim:!1})}function wW(t,e){var i=$g(),n=Ne(i);go(n,()=>e.children),W(t,i)}function bW(t,e){Or(e,!0),Sf(()=>{let i=Cv(wW,{target:e.to,context:k7(),props:{children:e.children}});return()=>{Rv(i)}}),pr()}v7();var yW=ae('<div class="tbl-blocking-overlay" aria-hidden="true"></div>');function SW(t){var e=yW();W(t,e)}function cf(t,e){let i=e.devicePixelRatio;return bD(t*i)/i}function xW({x:t,y:e},i){return{x:cf(t,i),y:cf(e,i)}}var vW=ae('<th class="tbl-cell tbl-header-cell"><!></th>'),QW=ae('<td class="tbl-cell tbl-data-cell"><!></td>');function kW(t,e){Or(e,!0);let i=ee(()=>u2(Y(e.movement)?e.movement.border:{top:e.position.top,right:!0,bottom:!0,left:e.position.left})),n=ee(()=>u2(e.outline)),r=ee(()=>{if(N(e.movement?.translate))return;let{x:c,y:h}=e.movement.state==="moving"?xW(e.movement.translate,e.win):e.movement.translate;return`translate3d(${c}px, ${h}px, 0px)`});var o=$g(),s=Ne(o);{var l=c=>{var h=vW();let f;var u=$i(h);go(u,()=>e.children),Qt(d=>{Ze(h,"align",e.alignment==="none"?void 0:e.alignment),Ze(h,"data-component",aa),Ze(h,"data-row",e.location.row),Ze(h,"data-col",e.location.col),Ze(h,"data-border",k(i)),Ze(h,"data-outline",k(n)),Ze(h,"data-selected",d),Ze(h,"data-state",e.movement?.state),f=rf(h,"",f,{transform:k(r)})},[()=>uo(e.selected)]),W(c,h)},a=c=>{var h=QW();let f;var u=$i(h);go(u,()=>e.children),Qt(d=>{Ze(h,"align",e.alignment==="none"?void 0:e.alignment),Ze(h,"data-component",aa),Ze(h,"data-row",e.location.row),Ze(h,"data-col",e.location.col),Ze(h,"data-border",k(i)),Ze(h,"data-outline",k(n)),Ze(h,"data-selected",d),Ze(h,"data-state",e.movement?.state),f=rf(h,"",f,{transform:k(r)})},[()=>uo(e.selected)]),W(c,h)};pt(s,c=>{e.position.top?c(l):c(a,!1)})}W(t,o),pr()}function nQ(t){return Y(sa(t.dom).activeElement?.closest(".cm-panels"))}function m2(t){return t.trim().split(/\s+/)}function PW({doc:t,selection:e,parent:i,extensions:n,markdownConfig:r,selectionType:o,lineWrapping:s,globalKeyBindings:l,rootEditor:a,highlighter:c,onChange:h,eventHandlers:f}){return new T({doc:t,selection:e,parent:i,extensions:[n,xt.lowest([T.editorAttributes.of(u=>{let d=new Set(m2(a.themeClasses)),O=new Set(m2(u.themeClasses));return{class:[...d.difference(O)].join(" ")}}),Ht.of([...l.map(u=>({...u,run:Y(u.run)?()=>u.run(a):void 0,shift:Y(u.shift)?()=>u.shift(a):void 0}))]),o==="codemirror"?o0():[],Uo(c),Ir({extensions:[P2,r.extensions??[]],addKeymap:!1,completeHTMLTags:r.completeHTMLTags,pasteURLAsLink:r.pasteURLAsLink,htmlTagLanguage:r.htmlTagLanguage}),T.domEventObservers(f),s==="wrap"?T.lineWrapping:[]])],dispatchTransactions:(u,d)=>{d.update(u),u.forEach(h)}})}var TW=ae('<div class="tbl-cell-editor"></div>');function CW(t,e){Or(e,!0);let i=Am(e,"text",15),n=Am(e,"selection",15),r,o,s=!1,l=!1;function a(h){let{docChanged:f,newDoc:u,selection:d}=h;if(s)return;let O=Y(d);if(f||O){if(f){let m=og(u,{trim:!0});m.eq(i())||(i(m),l=!0)}if(O){let{head:m,anchor:g}=d.main,$=iQ({head:m,anchor:g},u,{trim:!0});Mv($,n())||(n($),l=!0)}}}xg([()=>i(),()=>n()],()=>{if(l){l=!1;return}s=!0,o.dispatch({changes:o.state.changes({from:0,to:o.state.doc.length,insert:ef(i())}),selection:p2(n(),i())}),s=!1},{lazy:!0}),Sf(()=>(o=PW({doc:ef(i()),selection:p2(n(),i()),parent:r,selectionType:e.selectionType,lineWrapping:e.lineWrapping,extensions:e.extensions,markdownConfig:e.markdownConfig,globalKeyBindings:e.globalKeyBindings,rootEditor:e.rootEditor,highlighter:e.highlighter,onChange:a,eventHandlers:{beforeinput:e.onbeforeinput,dragstart:e.ondragstart,keydown:(h,{state:f})=>e.onkeydown(h,f),paste:e.onpaste}}),nQ(o)||o.focus(),()=>o.destroy()));var c=TW();of(c,h=>r=h,()=>r),W(t,c),pr()}var hf=class t{event;tableState;position;static navigate(e){new t(e)[`navigate${e.key}`]()}navigateTab(){this.moveRight({createRow:!0,position:"end"})}navigateShiftTab(){this.moveLeft({createRow:!0,position:"end"})}navigateEnter(){this.moveDown({createRow:!0,position:"end"})}navigateArrowLeft(){this.position.left&&this.moveLeft({createRow:!1,position:"end"})}navigateArrowUp(){this.position.top&&this.moveUp({createRow:!1,position:"end"})}navigateArrowRight(){this.position.right&&this.moveRight({createRow:!1,position:"start"})}navigateArrowDown(){this.position.bottom&&this.moveDown({createRow:!1,position:"end"})}navigateShiftArrowLeft(){if(!(!this.position.left||N(this.tableState.outlinedSection)||N(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),N(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.endCol===this.tableState.anchorCell.col){if(this.tableState.outlinedSection.startCol===this.tableState.table.firstColIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandLeft()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractLeft();this.tableState.activeCell=Gv(this.tableState.activeCell)}}navigateShiftArrowUp(){if(!(!this.position.top||N(this.tableState.outlinedSection)||N(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),N(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.endRow===this.tableState.anchorCell.row){if(this.tableState.outlinedSection.startRow===this.tableState.table.firstRowIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandUp()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractUp();this.tableState.activeCell=Xv(this.tableState.activeCell)}}navigateShiftArrowRight(){if(!(!this.position.right||N(this.tableState.outlinedSection)||N(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),N(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.startCol===this.tableState.anchorCell.col){if(this.tableState.outlinedSection.endCol===this.tableState.table.lastColIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandRight()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractRight();this.tableState.activeCell=Av(this.tableState.activeCell)}}navigateShiftArrowDown(){if(!(!this.position.bottom||N(this.tableState.outlinedSection)||N(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),N(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.startRow===this.tableState.anchorCell.row){if(this.tableState.outlinedSection.endRow===this.tableState.table.lastRowIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandDown()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractDown();this.tableState.activeCell=Lv(this.tableState.activeCell)}}moveLeft({createRow:e,position:i}){if(!N(this.tableState.activeCell)){if(this.event.preventDefault(),wo(this.tableState.activeCell,this.tableState.table.firstCellLocation)){if(!e){this.tableState.navigate("before");return}this.tableState.table.prependEmptyRows(1),this.tableState.activeCell={row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col}}this.moveTo(this.tableState.activeCell.col===this.tableState.table.firstColIndex?{row:this.tableState.activeCell.row-1,col:this.tableState.table.lastColIndex}:{row:this.tableState.activeCell.row,col:this.tableState.activeCell.col-1},i)}}moveUp({createRow:e,position:i}){if(!N(this.tableState.activeCell)){if(this.event.preventDefault(),this.tableState.activeCell.row===this.tableState.table.firstRowIndex){if(!e){this.tableState.navigate("before");return}this.tableState.table.prependEmptyRows(1),this.tableState.activeCell={row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col}}this.moveTo({row:this.tableState.activeCell.row-1,col:this.tableState.activeCell.col},i)}}moveRight({createRow:e,position:i}){if(!N(this.tableState.activeCell)){if(this.event.preventDefault(),wo(this.tableState.activeCell,this.tableState.table.lastCellLocation)){if(!e){this.tableState.navigate("after");return}this.tableState.table.appendEmptyRows(1)}this.moveTo(this.tableState.activeCell.col===this.tableState.table.lastColIndex?{row:this.tableState.activeCell.row+1,col:this.tableState.table.firstColIndex}:{row:this.tableState.activeCell.row,col:this.tableState.activeCell.col+1},i)}}moveDown({createRow:e,position:i}){if(!N(this.tableState.activeCell)){if(this.event.preventDefault(),this.tableState.activeCell.row===this.tableState.table.lastRowIndex){if(!e){this.tableState.navigate("after");return}this.tableState.table.appendEmptyRows(1)}this.moveTo({row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col},i)}}moveTo(e,i){if(this.tableState.activeCell=e,this.tableState.anchorCell=e,this.tableState.outlinedSection=nt.ofCell(e),this.tableState.selection.isCell()){let n=i==="start"?0:this.tableState.table.cellAt(e).length;this.tableState.selectionValue={cell:e,section:{anchor:n,head:n}}}}constructor({event:e,tableState:i,position:n}){this.event=e,this.tableState=i,this.position=n}},Qe={alt:"Alt",arrowDown:"ArrowDown",arrowLeft:"ArrowLeft",arrowRight:"ArrowRight",arrowUp:"ArrowUp",backspace:"Backspace",c:"c",delete:"Delete",enter:"Enter",escape:"Escape",shift:"Shift",tab:"Tab",v:"v",x:"x"},RW=[Qe.arrowDown,Qe.arrowLeft,Qe.arrowRight,Qe.arrowUp,Qe.enter,Qe.tab,`${Qe.shift}${Qe.arrowDown}`,`${Qe.shift}${Qe.arrowLeft}`,`${Qe.shift}${Qe.arrowRight}`,`${Qe.shift}${Qe.arrowUp}`,`${Qe.shift}${Qe.tab}`],g2=new Set(RW);function rQ({key:t,shiftKey:e,altKey:i,metaKey:n,ctrlKey:r}){if(!(i||n||r))return e?g2.has(`${Qe.shift}${t}`)?`${Qe.shift}${t}`:void 0:g2.has(t)?t:void 0}function EW(t,e){t.inputType==="historyUndo"?(e.undo(),t.preventDefault()):t.inputType==="historyRedo"&&(e.redo(),t.preventDefault())}function zW(t){t.preventDefault()}function _W(t,e,i){let n=rQ(t);if(N(n))return;let r=e.selection.main.head,o=e.doc.lineAt(r).number,s=0,l=e.doc.length,a=1,c=e.doc.lines,h={top:o===a,right:r===l,bottom:o===c,left:r===s};hf.navigate({tableState:i,key:n,event:t,position:h})}function jW(t,e){vg({tableState:e,event:t})}var ZW=ae('<div class="tbl-cell-view" contenteditable="" tabindex="-1"><!></div>');function YW(t,e){Or(e,!0);var i=ZW(),n=$i(i);go(n,()=>e.children),Qt(r=>{Ze(i,"data-component",Qg),Ze(i,"data-hidden",r)},[()=>uo(e.hidden)]),W(t,i),pr()}var oQ="Handle";function kg(t){if(!Dv(t,{component:oQ}))return;let{type:e,location:i}=wg(t).dataset;if(e==="table")return{type:e,location:i};{let n=Qf(ma(t));return sW({location:i,type:e},n)}}var DW=yi('<svg class="tbl-handle-grip" width="15" height="3" fill="currentColor" viewBox="0 0 15 3" xmlns="http://www.w3.org/2000/svg"><circle cx="1.5" cy="1.5" r="1.5"></circle><circle cx="7.5" cy="1.5" r="1.5"></circle><circle cx="13.5" cy="1.5" r="1.5"></circle></svg>'),qW=yi('<svg class="tbl-handle-grip" width="3" height="15" fill="currentColor" viewBox="0 0 3 15" xmlns="http://www.w3.org/2000/svg"><circle cy="1.5" cx="1.5" r="1.5"></circle><circle cy="7.5" cx="1.5" r="1.5"></circle><circle cy="13.5" cx="1.5" r="1.5"></circle></svg>'),WW=ae('<div class="tbl-handle" role="button" aria-hidden="true"><!></div>');function $2(t,e){Or(e,!0);let i=Am(e,"toggle",3,!1),n={table:{right:"vertical",bottom:"horizontal"},header:{row:"vertical",col:"horizontal"}},r=ee(()=>n[e.of.type]?.[e.of.location]);var o=WW();rf(o,"",{},{opacity:"var(--tbl-handle-opacity, 0)"});var s=$i(o);{var l=c=>{var h=DW();W(c,h)},a=c=>{var h=qW();W(c,h)};pt(s,c=>{k(r)==="horizontal"?c(l):k(r)==="vertical"&&c(a,1)})}Qt((c,h,f)=>{Ze(o,"data-component",oQ),Ze(o,"data-type",e.of.type),Ze(o,"data-location",e.of.location),Ze(o,"data-active",c),Ze(o,"data-hover",h),Ze(o,"data-toggle",f)},[()=>uo(e.state==="active"),()=>uo(e.state==="hover"),()=>uo(i())]),W(t,o),pr()}var XW=ae('<div class="tbl-menu"><!></div>');function AW(t,e){Or(e,!0);let i,n=Oe(void 0);Sf(()=>{e.translate(i).then(l=>I(n,l,!0))});var r=XW();let o;var s=$i(r);go(s,()=>e.children),of(r,l=>i=l,()=>i),Qt(l=>o=rf(r,"",o,l),[()=>({visibility:Y(k(n))?void 0:"hidden",transform:Y(k(n))?`translate3d(${k(n).x}px, ${k(n).y}px, 0px)`:void 0})]),W(t,r),pr()}var LW=ae('<div class="tbl-menu-item" role="menuitem" tabindex="-1"><!></div>');function Jt(t,e){var i=LW(),n=$i(i);go(n,()=>e.children),Kl("click",i,function(...r){e.onclick?.apply(this,r)}),W(t,i)}Tv(["click"]);function ei(t,e){switch(t.action){case"add":return e.menu.clickAdd(t.direction);case"align":return e.menu.clickAlign(t.alignment);case"clear":return e.menu.clickClear();case"duplicate":return e.menu.clickDuplicate();case"move":return e.menu.clickMove(t.direction);case"remove":return e.menu.clickRemove();case"sort":return e.menu.clickSort(t.direction)}}var GW=yi('<path d="M294.6 454.6L214.6 534.6C202.1 547.1 181.8 547.1 169.3 534.6L89.3 454.6C76.8 442.1 76.8 421.8 89.3 409.3C101.8 396.8 122.1 396.8 134.6 409.3L160 434.7L160 128C160 110.3 174.3 96 192 96C209.7 96 224 110.3 224 128L224 434.7L249.4 409.3C261.9 396.8 282.2 396.8 294.7 409.3C307.2 421.8 307.2 442.1 294.7 454.6zM476.6 113.7C527.3 215 553.9 268.4 556.6 273.7C564.5 289.5 558.1 308.7 542.3 316.6C526.5 324.5 507.3 318.1 499.4 302.3L492.2 288L403.8 288L396.6 302.3C388.7 318.1 369.5 324.5 353.7 316.6C337.9 308.7 331.5 289.5 339.4 273.7C342.1 268.4 368.7 215 419.4 113.7C424.8 102.9 435.9 96 448 96C460.1 96 471.2 102.8 476.6 113.7zM448 199.6L427.8 240L468.2 240L448 199.6zM352 384C352 366.3 366.3 352 384 352L512 352C524.9 352 536.6 359.8 541.6 371.8C546.6 383.8 543.8 397.5 534.7 406.7L461.3 480L512 480C529.7 480 544 494.3 544 512C544 529.7 529.7 544 512 544L384 544C371.1 544 359.4 536.2 354.4 524.2C349.4 512.2 352.2 498.5 361.3 489.3L434.7 415.9L384 415.9C366.3 415.9 352 401.6 352 383.9z"></path>'),MW=yi('<path d="M294.6 454.6L214.6 534.6C202.1 547.1 181.8 547.1 169.3 534.6L89.3 454.6C76.8 442.1 76.8 421.8 89.3 409.3C101.8 396.8 122.1 396.8 134.6 409.3L160 434.7L160 128C160 110.3 174.3 96 192 96C209.7 96 224 110.3 224 128L224 434.7L249.4 409.3C261.9 396.8 282.2 396.8 294.7 409.3C307.2 421.8 307.2 442.1 294.7 454.6zM352 128C352 110.3 366.3 96 384 96L512 96C524.9 96 536.6 103.8 541.6 115.8C546.6 127.8 543.8 141.5 534.7 150.7L461.3 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L384 288C371.1 288 359.4 280.2 354.4 268.2C349.4 256.2 352.2 242.5 361.3 233.3L434.8 160L384 160C366.3 160 352 145.7 352 128zM476.6 337.7L556.6 497.7C564.5 513.5 558.1 532.7 542.3 540.6C526.5 548.5 507.3 542.1 499.4 526.3L492.2 512L403.8 512L396.6 526.3C388.7 542.1 369.5 548.5 353.7 540.6C337.9 532.7 331.5 513.5 339.4 497.7L419.4 337.7C424.8 326.9 435.9 320 448 320C460.1 320 471.2 326.8 476.6 337.7zM448 423.6L427.8 464L468.2 464L448 423.6z"></path>'),NW=yi('<path d="M384 128C384 145.7 369.7 160 352 160L128 160C110.3 160 96 145.7 96 128C96 110.3 110.3 96 128 96L352 96C369.7 96 384 110.3 384 128zM384 384C384 401.7 369.7 416 352 416L128 416C110.3 416 96 401.7 96 384C96 366.3 110.3 352 128 352L352 352C369.7 352 384 366.3 384 384zM96 256C96 238.3 110.3 224 128 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L128 288C110.3 288 96 273.7 96 256zM544 512C544 529.7 529.7 544 512 544L128 544C110.3 544 96 529.7 96 512C96 494.3 110.3 480 128 480L512 480C529.7 480 544 494.3 544 512z"></path>'),HW=yi('<path d="M448 128C448 110.3 433.7 96 416 96L224 96C206.3 96 192 110.3 192 128C192 145.7 206.3 160 224 160L416 160C433.7 160 448 145.7 448 128zM544 256C544 238.3 529.7 224 512 224L128 224C110.3 224 96 238.3 96 256C96 273.7 110.3 288 128 288L512 288C529.7 288 544 273.7 544 256zM96 512C96 529.7 110.3 544 128 544L512 544C529.7 544 544 529.7 544 512C544 494.3 529.7 480 512 480L128 480C110.3 480 96 494.3 96 512zM448 384C448 366.3 433.7 352 416 352L224 352C206.3 352 192 366.3 192 384C192 401.7 206.3 416 224 416L416 416C433.7 416 448 401.7 448 384z"></path>'),BW=yi('<path d="M544 128C544 145.7 529.7 160 512 160L288 160C270.3 160 256 145.7 256 128C256 110.3 270.3 96 288 96L512 96C529.7 96 544 110.3 544 128zM544 384C544 401.7 529.7 416 512 416L288 416C270.3 416 256 401.7 256 384C256 366.3 270.3 352 288 352L512 352C529.7 352 544 366.3 544 384zM96 256C96 238.3 110.3 224 128 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L128 288C110.3 288 96 273.7 96 256zM544 512C544 529.7 529.7 544 512 544L128 544C110.3 544 96 529.7 96 512C96 494.3 110.3 480 128 480L512 480C529.7 480 544 494.3 544 512z"></path>'),IW=yi('<path d="M342.6 81.4C330.1 68.9 309.8 68.9 297.3 81.4L137.3 241.4C124.8 253.9 124.8 274.2 137.3 286.7C149.8 299.2 170.1 299.2 182.6 286.7L288 181.3L288 552C288 569.7 302.3 584 320 584C337.7 584 352 569.7 352 552L352 181.3L457.4 286.7C469.9 299.2 490.2 299.2 502.7 286.7C515.2 274.2 515.2 253.9 502.7 241.4L342.7 81.4z"></path>'),UW=yi('<path d="M566.6 342.6C579.1 330.1 579.1 309.8 566.6 297.3L406.6 137.3C394.1 124.8 373.8 124.8 361.3 137.3C348.8 149.8 348.8 170.1 361.3 182.6L466.7 288L96 288C78.3 288 64 302.3 64 320C64 337.7 78.3 352 96 352L466.7 352L361.3 457.4C348.8 469.9 348.8 490.2 361.3 502.7C373.8 515.2 394.1 515.2 406.6 502.7L566.6 342.7z"></path>'),VW=yi('<path d="M297.4 566.6C309.9 579.1 330.2 579.1 342.7 566.6L502.7 406.6C515.2 394.1 515.2 373.8 502.7 361.3C490.2 348.8 469.9 348.8 457.4 361.3L352 466.7L352 96C352 78.3 337.7 64 320 64C302.3 64 288 78.3 288 96L288 466.7L182.6 361.3C170.1 348.8 149.8 348.8 137.3 361.3C124.8 373.8 124.8 394.1 137.3 406.6L297.3 566.6z"></path>'),FW=yi('<path d="M73.4 297.4C60.9 309.9 60.9 330.2 73.4 342.7L233.4 502.7C245.9 515.2 266.2 515.2 278.7 502.7C291.2 490.2 291.2 469.9 278.7 457.4L173.3 352L544 352C561.7 352 576 337.7 576 320C576 302.3 561.7 288 544 288L173.3 288L278.7 182.6C291.2 170.1 291.2 149.8 278.7 137.3C266.2 124.8 245.9 124.8 233.4 137.3L73.4 297.3z"></path>'),KW=yi('<path d="M262.2 48C248.9 48 236.9 56.3 232.2 68.8L216 112L120 112C106.7 112 96 122.7 96 136C96 149.3 106.7 160 120 160L520 160C533.3 160 544 149.3 544 136C544 122.7 533.3 112 520 112L424 112L407.8 68.8C403.1 56.3 391.2 48 377.8 48L262.2 48zM128 208L128 512C128 547.3 156.7 576 192 576L448 576C483.3 576 512 547.3 512 512L512 208L464 208L464 512C464 520.8 456.8 528 448 528L192 528C183.2 528 176 520.8 176 512L176 208L128 208zM288 280C288 266.7 277.3 256 264 256C250.7 256 240 266.7 240 280L240 456C240 469.3 250.7 480 264 480C277.3 480 288 469.3 288 456L288 280zM400 280C400 266.7 389.3 256 376 256C362.7 256 352 266.7 352 280L352 456C352 469.3 362.7 480 376 480C389.3 480 400 469.3 400 456L400 280z"></path>'),JW=ae('<div class="tbl-menu-item-icon"><svg xmlns="http://www.w3.org/2000/svg" height="14" width="14" viewBox="0 0 640 640" fill="currentColor"><!></svg></div>');function ti(t,e){var i=JW(),n=$i(i),r=$i(n);{var o=w=>{var b=GW();W(w,b)},s=w=>{var b=MW();W(w,b)},l=w=>{},a=w=>{var b=NW();W(w,b)},c=w=>{var b=HW();W(w,b)},h=w=>{var b=BW();W(w,b)},f=w=>{var b=IW();W(w,b)},u=w=>{var b=UW();W(w,b)},d=w=>{var b=VW();W(w,b)},O=w=>{var b=FW();W(w,b)},m=w=>{},g=w=>{},$=w=>{var b=KW();W(w,b)};pt(r,w=>{e.name==="sort-ascending"?w(o):e.name==="sort-descending"?w(s,1):e.name==="align-none"?w(l,2):e.name==="align-left"?w(a,3):e.name==="align-center"?w(c,4):e.name==="align-right"?w(h,5):e.name==="move-up"?w(f,6):e.name==="move-right"?w(u,7):e.name==="move-down"?w(d,8):e.name==="move-left"?w(O,9):e.name==="duplicate"?w(m,10):e.name==="clear"?w(g,11):e.name==="remove"&&w($,12)})}W(t,i)}var eX=ae('<div class="tbl-menu-item-text"><!></div>');function ii(t,e){var i=eX(),n=$i(i);go(n,()=>e.children),W(t,i)}var tX=ae('<div class="tbl-menu-separator"></div>');function Mh(t){var e=tX();W(t,e)}var iX=ae('<div class="tbl-select-all-overlay" aria-hidden="true"></div>');function nX(t){var e=iX();W(t,e)}var rX=new Set([Qe.c,Qe.v,Qe.x]);function oX(t,e){return rX.has(t.key)&&t[MD(e)]}var sX=[Qe.backspace,Qe.delete],lX=new Set(sX);function aX({key:t}){return lX.has(t)?t:void 0}function cX(t){return/^F\d+$/.test(t)}var hX=new Set([Qe.alt,Qe.escape,Qe.enter,Qe.shift]);function fX({metaKey:t,ctrlKey:e,key:i}){return!e&&!t&&!hX.has(i)&&!cX(i)}function uX(t,e){e.selection.isCell()||Kv({tableState:e,event:t})}function dX(t,e){e.selection.isCell()||Jv({tableState:e,event:t})}function OX(t,e){e.selection.isCell()||vg({tableState:e,event:t})}function pX(t,e){if(Y(t.target)&&Y(tQ(t.target))){t.preventDefault();return}if(!e.interactive||e.selection.isCell())return;let i=rQ(t);if(Y(i)){hf.navigate({tableState:e,key:i,event:t,position:{left:!0,top:!0,right:!0,bottom:!0}});return}let n=aX(t);if(Y(n)){Fv({tableState:e,event:t});return}if(e.activeTable&&Y(e.activeCell)&&fX(t)){e.activeTable=!1,e.anchorCell=e.activeCell;let r=e.table.cellAt(e.activeCell).length;e.selectionValue={cell:e.activeCell,section:{head:r,anchor:r}},e.outlinedSection=nt.ofCell(e.activeCell);return}oX(t,e.window)||uc(e.rootEditor,t,"editor")&&t.preventDefault()}function Pg(t){return t.buttons===1}function sQ(t,e){return e.setPointerCapture(t.pointerId),()=>e.releasePointerCapture(t.pointerId)}var ff=class t{offset;maxScroll;boundaryElement;scrollElement;scroll;handle;xAmount;yAmount;updatePosition(e,i){let n=this.boundaryElement.x.getBoundingClientRect();e<n.left+this.offset?this.xAmount=-Pt(this.offset+(n.left-e),{max:this.maxScroll}):e>n.right-this.offset?this.xAmount=Pt(this.offset-(n.right-e),{max:this.maxScroll}):this.xAmount=0;let r=this.boundaryElement.y.getBoundingClientRect();i<r.top+this.offset?this.yAmount=-Pt(this.offset+(r.top-i),{max:this.maxScroll}):i>r.bottom-this.offset?this.yAmount=Pt(this.offset-(r.bottom-i),{max:this.maxScroll}):this.yAmount=0,N(this.handle)&&(this.xAmount!==0||this.yAmount!==0)&&this.scroll()}destroy(){Y(this.handle)&&cancelAnimationFrame(this.handle)}scrollInternal(){if(this.xAmount===0&&this.yAmount===0){this.scroll();return}this.scrollElement.x.scrollBy({left:this.xAmount}),this.scrollElement.y.scrollBy({top:this.yAmount}),this.scroll()}static of(e){return new t(e)}constructor({offset:e,maxScroll:i,boundaryElement:n,scrollElement:r}){let o=this.scrollInternal.bind(this);this.scroll=()=>{this.handle=requestAnimationFrame(o)},this.xAmount=0,this.yAmount=0,this.offset=e??0,this.maxScroll=i,this.boundaryElement=n,this.scrollElement=r}},uf=class t{start;size;get mid(){return this.start+this.size/2}get end(){return this.start+this.size}static of(e){return new t(e)}constructor({start:e,size:i}){this.start=e,this.size=i}},df;(t=>{function e(i,n){return Vm.of(i,n)}t.of=e})(df||(df={}));var Vm=class t{rows;cols;rowsOrCols(e){return e==="row"?this.rows:this.cols}rowAt(e){return this.rows[e]}colAt(e){return this.cols[e]}rowOrColAt(e,i){return e==="row"?this.rowAt(i):this.colAt(i)}get firstRow(){return this.rows[this.firstRowIndex]}get firstCol(){return this.cols[this.firstColIndex]}firstRowOrCol(e){return e==="row"?this.firstRow:this.firstCol}get lastRow(){return this.rows[this.lastRowIndex]}get lastCol(){return this.cols[this.lastColIndex]}lastRowOrCol(e){return e==="row"?this.lastRow:this.lastCol}firstRowIndex=0;firstColIndex=0;firstRowOrColIndex(e){return 0}get lastRowIndex(){return this.rowCount-1}get lastColIndex(){return this.colCount-1}lastRowOrColIndex(e){return e==="row"?this.lastRowIndex:this.lastColIndex}get rowCount(){return this.rows.length}get colCount(){return this.cols.length}get minRowSize(){return Jh(...this.rows.map(e=>e.size))}get minColSize(){return Jh(...this.cols.map(e=>e.size))}moveRowOrColAt(e,{fromIndex:i,toIndex:n}){if(i===n)return;let r=this.rowsOrCols(e),o=r[i];if(i<n){for(let s of lr({start:i,endExclusive:n}))r[s]=r[s+1],r[s].start-=o.size;o.start=r[n].start+r[n].size}else{for(let s of lr({start:i,endExclusive:n}))r[s]=r[s-1],r[s].start+=o.size;o.start=r[n].start-o.size}r[n]=o}lastCellBeforePosition(e){let i=this.rows.map(r=>r.start).findLastIndex(r=>r<e.y),n=this.cols.map(r=>r.start).findLastIndex(r=>r<e.x);return{row:i===-1?0:i,col:n===-1?0:n}}static of(e,i){return new t(e,i)}constructor(e,i){let n=[...e.querySelectorAll("tr:first-child > th")],r=[...e.querySelectorAll("tr > th:first-child,tr > td:first-child")];this.rows=r.map((o,s)=>{let{top:l,height:a}=w2(o,i),c=0;return uf.of({start:l+c,size:a-c})}),this.cols=n.map((o,s)=>{let{left:l,width:a}=w2(o,i),c=s===0?1:0;return uf.of({start:l+c,size:a-c})})}};function w2(t,e){let{top:i,left:n,width:r,height:o}=t.getBoundingClientRect();return{top:i+e.y,left:n+e.x,width:r,height:o}}var Of=class t{tableState;tableMeasurement;autoScroller;shouldAutoScroll;removeEventListeners;currentCell;start(){this.tableState.activeCell=this.currentCell,this.tableState.anchorCell=this.currentCell,this.tableState.outlinedSection=nt.ofCell(this.currentCell),this.tableState.outline={outlined:!1},this.removeEventListeners=$o(He(this.tableState.window,"pointermove",e=>this.drag(e)),He(this.tableState.window,"pointerup",()=>this.end()),He(this.tableState.window,"pointerleave",()=>this.end()))}resizeAndContinue(e){e.preventDefault(),N(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.currentCell),this.expandOrContract(this.currentCell),this.tableState.outline={outlined:!0},this.removeEventListeners=$o(He(this.tableState.window,"pointermove",i=>this.drag(i)),He(this.tableState.window,"pointerup",()=>this.end()),He(this.tableState.window,"pointerleave",()=>this.end()))}drag(e){if(!Pg(e)){this.end();return}e.preventDefault(),this.shouldAutoScroll()&&this.autoScroller.updatePosition(e.clientX,e.clientY);let i=this.tableMeasurement.lastCellBeforePosition({x:e.clientX+this.tableState.scrollOffsetX,y:e.clientY+this.tableState.scrollOffsetY});wo(i,this.currentCell)||(this.currentCell=i,this.tableState.outline={outlined:!0},this.expandOrContract(i))}end(){this.removeEventListeners?.(),this.autoScroller.destroy(),this.tableState.outline=void 0}expandOrContract(e){this.tableState.focusTable();let[i,n]=e.row<=this.tableState.anchorCell.row?[e.row,this.tableState.anchorCell.row]:[this.tableState.anchorCell.row,e.row],[r,o]=e.col<=this.tableState.anchorCell.col?[e.col,this.tableState.anchorCell.col]:[this.tableState.anchorCell.col,e.col];this.tableState.outlinedSection=nt.of({row:{start:i,endExclusive:n+1},col:{start:r,endExclusive:o+1}}),this.tableState.activeCell=e}static startOutline(e){new t(e).start()}static resizeAndContinueOutline(e){new t(e).resizeAndContinue(e.event)}constructor({tableState:e,cellLocation:i}){this.tableState=e,this.currentCell=i,this.autoScroller=ff.of({offset:10,maxScroll:32,boundaryElement:{x:e.scrollElement,y:e.rootScrollElement},scrollElement:{x:e.scrollElement,y:e.rootScrollElement}}),this.shouldAutoScroll=vq({delayMillis:500}),this.tableMeasurement=df.of(e.tableElement,{x:e.scrollOffsetX,y:e.scrollOffsetY})}};function mX(t,e){gf(e.window)&&(e.hoveredCell=t)}function gX(t){gf(t.window)&&(t.hoveredCell=void 0)}function $X(t,e,i){if(!(!i.interactive||!Pg(t)))if(t.shiftKey){if(i.selection.isCell()&&wo(e,i.selection.cell))return;Of.resizeAndContinueOutline({event:t,tableState:i,cellLocation:e})}else Of.startOutline({event:t,tableState:i,cellLocation:e})}var wX=new Intl.Collator(navigator.language,{numeric:!0,sensitivity:"base"});function b2(t,e){return wX.compare(t,e)}function bX({metaKey:t,shiftKey:e,altKey:i,ctrlKey:n,key:r}){return r===Qe.escape&&!e&&!i&&!t&&!n}var Fm=class t{tableState;handle;point;removeEventListeners;get rowOrCol(){return this.handle.location}get index(){return this.handle.index}open(){let e=this.tableState.document.body;this.removeEventListeners=$o(He(e,"pointerdown",s=>{s.preventDefault(),(N(s.target)||!_v(this.tableState.menuRootElement,s.target))&&this.close()}),He(e,"wheel",s=>s.preventDefault(),{passive:!1}),He(e,"keydown",s=>{s.preventDefault(),bX(s)&&this.close()})),this.tableState.focusTable(),this.tableState.activeHandle={state:"active",handle:this.handle},this.tableState.outlinedSection=nt.of(this.rowOrCol==="row"?{row:{start:this.index,endExclusive:this.index+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:this.index,endExclusive:this.index+1}});let i=this.rowOrCol==="row"?{row:this.index,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:this.index};this.tableState.activeCell=i,this.tableState.anchorCell=i;let n=this.index!==this.tableState.table.firstRowOrColIndex(this.rowOrCol),r=this.index!==this.tableState.table.lastRowOrColIndex(this.rowOrCol),o=!1;n?o=r?!0:"backward":r&&(o="forward"),this.tableState.menu={type:this.rowOrCol,capabilities:{addable:!0,alignable:this.rowOrCol==="col",clearable:!0,duplicatable:!0,moveable:o,removable:!this.tableState.table.hasSingleRowOrCol(this.rowOrCol),sortable:this.rowOrCol==="col"},clickAdd:s=>this.clickAdd(s),clickAlign:s=>this.clickAlign(s),clickClear:()=>this.clickClear(),clickDuplicate:()=>this.clickDuplicate(),clickMove:s=>this.clickMove(s),clickRemove:()=>this.clickRemove(),clickSort:s=>this.clickSort(s),computeTranslation:s=>this.computeTranslation(s)}}close(){this.removeEventListeners?.(),this.tableState.menu=void 0,this.tableState.activeHandle=void 0}async computeTranslation(e){let i=await Zx({getBoundingClientRect:()=>({x:this.point.x,y:this.point.y,top:this.point.y,right:this.point.x,bottom:this.point.y,left:this.point.x,width:0,height:0})},e,{middleware:[_x({allowedPlacements:this.rowOrCol==="row"?["right-start","right-end"]:["right-start","right"]}),jx({crossAxis:!0})]}),n=Cs(e);return{x:cf(i.x,n),y:cf(i.y,n)}}clickAdd(e){if(this.tableState.table.addEmptyRowsOrColsAt(this.rowOrCol,{index:e==="before"?this.index:this.index+1,count:1}),e==="after"){this.tableState.outlinedSection=this.tableState.outlinedSection?.shift(this.rowOrCol,"forward");let i=Pm(this.rowOrCol,this.tableState.activeCell,"forward");this.tableState.activeCell=i,this.tableState.anchorCell=i}this.close()}clickAlign(e){this.tableState.table.setAlignmentAt(this.index,e),this.close()}clickClear(){this.tableState.table.clearRowOrCol(this.rowOrCol,this.index),this.close()}clickDuplicate(){this.tableState.table.duplicateRowOrColAt(this.rowOrCol,this.index),this.close()}clickMove(e){this.tableState.table.moveRowOrColAt(this.rowOrCol,{fromIndex:this.index,toIndex:e==="backward"?this.index-1:this.index+1}),this.tableState.outlinedSection=this.tableState.outlinedSection?.shift(this.rowOrCol,e);let i=Pm(this.rowOrCol,this.tableState.activeCell,e);this.tableState.activeCell=i,this.tableState.anchorCell=i,this.close()}clickRemove(){if(this.tableState.table.removeRowsOrColsAt(this.rowOrCol,{index:this.index,count:1}),!this.tableState.table.hasRowOrColAt(this.rowOrCol,this.index)){this.tableState.outlinedSection=this.tableState.outlinedSection?.shift(this.rowOrCol,"backward");let e=Pm(this.rowOrCol,this.tableState.activeCell,"backward");this.tableState.activeCell=e,this.tableState.anchorCell=e}this.close()}clickSort(e){this.tableState.table.sortByColAt(this.index,e==="ascending"?(i,n)=>b2(i.toString(),n.toString()):(i,n)=>b2(n.toString(),i.toString())),this.close()}static showMenu(e){new t(e).open()}constructor({tableState:e,handle:i,point:n}){this.tableState=e,this.handle=i,this.point=n}},Km=class t{coordinate;initialIndex;size;initialPosition;minBound;maxBound;scrollOffsetX;scrollOffsetY;subject;rowOrCol;tableMeasurement;currentIndex;currentPosition;dragged;start(){return{cellMovement:e=>this.cellMovement(e)}}drag(e){this.currentPosition=e[this.coordinate];let{currentIndex:i,move:n}=this.calculateDrag();return this.currentIndex=i,this.initialIndex!==this.currentIndex&&(this.dragged=!0),Y(n)&&this.tableMeasurement.moveRowOrColAt(this.rowOrCol,n),{cellMovement:r=>this.cellMovement(r)}}end(){return this.initialIndex===this.currentIndex?{moved:!1,dragged:this.dragged}:{moved:!0,toIndex:this.currentIndex}}cellMovement(e){return{border:this.cellBorder(e),state:this.cellState(e),translate:this.cellTranslate(e)}}cellBorder(e){let i=this.isRowOrColExposed(e[this.rowOrCol]),n=this.subject.containsCell(e);return this.rowOrCol==="row"?{top:i,right:!0,bottom:!n||e.row===this.tableMeasurement.lastRowIndex,left:this.tableMeasurement.firstColIndex===e.col}:{top:this.tableMeasurement.firstRowIndex===e.row,right:!n||e.col===this.tableMeasurement.lastColIndex,bottom:!0,left:i}}cellState(e){return this.subject.containsCell(e)?"moving":"shiftable"}cellTranslate(e){let i=this.rowOrColTranslate(e[this.rowOrCol]);return this.rowOrCol==="row"?{x:0,y:i}:{x:i,y:0}}isRowOrColExposed(e){let i=this.reorderIndex(e),n=i===this.tableMeasurement.firstRowOrColIndex(this.rowOrCol),r=i===this.currentIndex+1;return n||r}get rowOrColShift(){if(this.currentIndex!==this.initialIndex)return this.currentIndex<this.initialIndex?{direction:"forwards",range:{start:this.currentIndex,endExclusive:this.initialIndex},indexDiff:1,positionDiff:this.size-1}:{direction:"backwards",range:{start:this.initialIndex+1,endExclusive:this.currentIndex+1},indexDiff:-1,positionDiff:1-this.size}}rowOrColTranslate(e){if(e===this.initialIndex)return Pt(this.currentPosition-this.initialPosition,{min:this.minBound,max:this.maxBound});let i=this.rowOrColShift;return N(i)?0:or(e,i.range)?i.positionDiff:0}reorderIndex(e){let i=this.rowOrColShift;return N(i)?e:e===this.initialIndex?this.currentIndex:or(e,i.range)?e+i.indexDiff:e}calculateDrag(){let e=this.tableMeasurement.rowsOrCols(this.rowOrCol),i={name:"current",index:this.currentIndex,mid:e[this.currentIndex].mid},n=this.currentIndex!==this.tableMeasurement.firstRowOrColIndex(this.rowOrCol)?{name:"left",index:this.currentIndex-1,mid:e[this.currentIndex-1].start+e[this.currentIndex].size/2}:void 0,r=this.currentIndex!==this.tableMeasurement.lastRowOrColIndex(this.rowOrCol)?{name:"right",index:this.currentIndex+1,mid:e[this.currentIndex].start+e[this.currentIndex+1].size+e[this.currentIndex].size/2}:void 0,o=pD(mD([i,n,r]),(s,l)=>Tm(this.currentPosition-s.mid)-Tm(this.currentPosition-l.mid));return o.name==="current"?{currentIndex:this.currentIndex,move:void 0}:{currentIndex:o.index,move:{fromIndex:this.currentIndex,toIndex:o.index}}}static of(e){return new t(e)}constructor({rowOrCol:e,index:i,position:n,subject:r,tableElement:o,scrollOffsetX:s,scrollOffsetY:l}){this.scrollOffsetX=s,this.scrollOffsetY=l;let a=df.of(o,{x:this.scrollOffsetX(),y:this.scrollOffsetY()});this.rowOrCol=e,this.coordinate=e==="row"?"y":"x",this.initialIndex=i,this.initialPosition=n[this.coordinate],this.minBound=a.firstRowOrCol(this.rowOrCol).start-a.rowOrColAt(this.rowOrCol,i).start,this.maxBound=a.lastRowOrCol(this.rowOrCol).end-a.rowOrColAt(this.rowOrCol,i).end,this.size=a.rowOrColAt(this.rowOrCol,i).size,this.subject=r,this.dragged=!1,this.tableMeasurement=a,this.currentIndex=i,this.currentPosition=n[this.coordinate]}},Jm=class t{tableState;rowOrCol;index;onClick;moveTracker;subject;autoScroller;removeEventListeners;start(e){e.preventDefault();let i=this.moveTracker.start();this.tableState.outlinedSection=this.subject,this.tableState.move=i,this.tableState.activeHandle={state:"active",handle:{type:"header",index:this.index,location:this.rowOrCol}};let n=this.rowOrCol==="row"?{row:this.index,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:this.index};this.tableState.activeCell=n,this.tableState.anchorCell=n,this.tableState.focusTable();let r=wg(e.target);this.removeEventListeners=$o(sQ(e,r),He(r,"pointermove",o=>this.drag(o)),He(r,"pointerup",()=>this.end()))}drag(e){e.preventDefault(),this.autoScroller.updatePosition(e.clientX,e.clientY),this.tableState.move=this.moveTracker.drag({x:e.clientX+this.tableState.scrollOffsetX,y:e.clientY+this.tableState.scrollOffsetY})}end(){this.removeEventListeners?.(),this.autoScroller.destroy();let e=this.moveTracker.end();if(e.moved){this.tableState.table.moveRowOrColAt(this.rowOrCol,{fromIndex:this.index,toIndex:e.toIndex}),this.tableState.outlinedSection=nt.of(this.rowOrCol==="row"?{row:{start:e.toIndex,endExclusive:e.toIndex+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:e.toIndex,endExclusive:e.toIndex+1}});let i=this.rowOrCol==="row"?{row:e.toIndex,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:e.toIndex};this.tableState.activeCell=i,this.tableState.anchorCell=i}this.tableState.move=void 0,this.tableState.activeHandle=void 0,!e.moved&&!e.dragged&&this.onClick()}static startMove(e){new t(e).start(e.event)}constructor({event:e,tableState:i,rowOrCol:n,index:r,onClick:o}){this.tableState=i,this.rowOrCol=n,this.index=r,this.subject=nt.of(n==="row"?{row:{start:r,endExclusive:r+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:r,endExclusive:r+1}}),this.onClick=o,this.autoScroller=ff.of({offset:16,maxScroll:32,boundaryElement:{x:i.scrollElement,y:i.rootScrollElement},scrollElement:{x:i.scrollElement,y:i.rootScrollElement}}),this.moveTracker=Km.of({subject:this.subject,rowOrCol:n,index:r,position:{x:e.clientX+i.scrollOffsetX,y:e.clientY+i.scrollOffsetY},tableElement:i.tableElement,scrollOffsetX:()=>this.tableState.scrollOffsetX,scrollOffsetY:()=>this.tableState.scrollOffsetY})}};function yX(t){return t==="row"?"y":"x"}var eg=class t{tableState;type;initialHandle;initialRowOrColCount;initialPosition;initialOutlinedSection;initialActiveCell;initialAnchorCell;cellSizePixels;dragThresholdPixels;dragged;start(){return{activeHandle:{state:"active",handle:this.initialHandle}}}drag(e){return this.dragged=!0,this.calculateDrag(e)}end(){return this.dragged?{activeHandle:void 0}:this.calculateClick()}calculateClick(){if(this.type!=="table")return this.calculateClickRowOrCol(this.type);if(this.initialHandle.location==="right")return this.calculateClickRowOrCol("col");if(this.initialHandle.location==="bottom")return this.calculateClickRowOrCol("row");let e=this.calculateClickRowOrCol("row"),i=this.calculateClickRowOrCol("col");return{operation:{row:e.operation.row,col:i.operation.col},activeHandle:e.activeHandle,activeCell:Y(e.activeCell)&&Y(i.activeCell)?{row:e.activeCell.row,col:i.activeCell.col}:void 0,anchorCell:Y(e.anchorCell)&&Y(i.anchorCell)?{row:e.anchorCell.row,col:i.anchorCell.col}:void 0,outlinedSection:Y(e.outlinedSection)&&Y(i.outlinedSection)?nt.of({row:e.outlinedSection.row,col:i.outlinedSection.col}):void 0}}calculateClickRowOrCol(e){let i=this.type==="table"?this.tableState.table.lastRowOrColIndex(e)+1:this.initialHandle.index;return{operation:{[e]:{action:"add",index:i,count:1}},activeHandle:this.type==="table"?void 0:{state:"hover",handle:{type:"border",location:this.handleLocationAt(i),index:i}},...this.calculateCellMovement(e,1)}}calculateDrag(e){if(this.type!=="table")return this.calculateDragRowOrCol(this.type,e);if(this.initialHandle.location==="right")return this.calculateDragRowOrCol("col",e);if(this.initialHandle.location==="bottom")return this.calculateDragRowOrCol("row",e);let i=this.calculateDragRowOrCol("row",e),n=this.calculateDragRowOrCol("col",e);if(N(i)&&N(n))return;let r=i??this.calculateCellMovement("row",this.rowOrColDiff("row")),o=n??this.calculateCellMovement("col",this.rowOrColDiff("col"));return{operation:{row:i?.operation.row,col:n?.operation.col},activeHandle:i?.activeHandle??n?.activeHandle,activeCell:Y(r.activeCell)&&Y(o.activeCell)?{row:r.activeCell.row,col:o.activeCell.col}:void 0,anchorCell:Y(r.anchorCell)&&Y(o.anchorCell)?{row:r.anchorCell.row,col:o.anchorCell.col}:void 0,outlinedSection:Y(r.outlinedSection)&&Y(o.outlinedSection)?nt.of({row:r.outlinedSection.row,col:o.outlinedSection.col}):void 0}}calculateDragRowOrCol(e,i){let n=yX(e),r=i.position[n]-this.initialPosition[n],o=yD(r/this.cellSizePixels[e]),s=r%this.cellSizePixels[e]>=this.dragThresholdPixels[e]?1:0,l=this.tableState.table.rowOrColCount(e)-this.initialRowOrColCount[e],a=o+s-l,c=this.type==="table"?this.tableState.table.lastRowOrColIndex(e)+1:this.initialHandle.index+l;if(a!==0)return a>0?this.calculateDragRowOrColMore({rowOrCol:e,start:c,length:a}):this.calculateDragRowOrColLess({rowOrCol:e,start:c,length:Jh(-a,c,this.tableState.table.lastRowOrColIndex(e))})}calculateDragRowOrColLess({rowOrCol:e,start:i,length:n}){let r=0;for(let s of lr({start:i-1,endExclusive:i-n-1})){if(!this.tableState.table.hasEmptyRowOrColAt(e,s))break;r++}if(r===0)return;let o=i-(r-1)-1;return{operation:{[e]:{action:"remove",index:i-r,count:r}},activeHandle:this.type==="table"?{state:"active",handle:this.initialHandle}:{state:"active",handle:{type:"border",location:this.handleLocationAt(o),index:o}},...this.calculateCellMovement(e,this.rowOrColDiff(e)-r)}}calculateDragRowOrColMore({rowOrCol:e,start:i,length:n}){return{operation:{[e]:{action:"add",index:i,count:n}},activeHandle:{state:"active",handle:this.type==="table"?this.initialHandle:{type:"border",location:this.handleLocationAt(i+n),index:i+n}},...this.calculateCellMovement(e,this.rowOrColDiff(e)+n)}}calculateCellMovement(e,i){let n=this.type==="table"?this.initialRowOrColCount[e]:this.initialHandle.index;if(i>=0)return{outlinedSection:this.initialOutlinedSection?.addForwardsByRowOrCol(e,{start:n,count:i}),activeCell:Y(this.initialActiveCell)?c2(e,this.initialActiveCell,{start:n,count:i}):void 0,anchorCell:Y(this.initialAnchorCell)?c2(e,this.initialAnchorCell,{start:n,count:i}):void 0};{let r=-i,o=this.initialOutlinedSection?.subtractBackwardsByRowOrCol(e,{start:n,count:r,min:this.tableState.table.firstRowOrColIndex(e)}),s=Y(o)?{min:o.startRowOrCol(e),max:o.endRowOrCol(e)}:void 0,l=Y(this.initialActiveCell)?h2(e,this.initialActiveCell,{start:n,count:r,boundary:s}):void 0,a=Y(this.initialAnchorCell)?h2(e,this.initialAnchorCell,{start:n,count:r,boundary:s}):void 0;return{outlinedSection:o,activeCell:l,anchorCell:a}}}rowOrColDiff(e){return this.tableState.table.rowOrColCount(e)-this.initialRowOrColCount[e]}handleLocationAt(e){if(this.type!=="table")return this.type==="row"&&e===this.tableState.table.firstRowIndex?"top":this.type==="col"&&e===this.tableState.table.firstColIndex?"left":this.type}handleToType(e){return e.type==="table"?"table":e.location==="top"?"row":e.location==="left"?"col":e.location}static of(e){return new t(e)}constructor({tableState:e,handle:i,position:n,cellSizePixels:r,dragThresholdPixels:o}){this.tableState=e,this.type=this.handleToType(i),this.initialHandle=i,this.initialPosition=n,this.initialRowOrColCount={row:e.table.rowCount,col:e.table.colCount},this.initialActiveCell=e.activeCell,this.initialAnchorCell=e.anchorCell,this.initialOutlinedSection=e.outlinedSection,this.cellSizePixels=r,this.dragThresholdPixels=o,this.dragged=!1}};function SX(t){let e=lf(t.tableElement,t.table.firstCellLocation),i=mW(e),{minWidth:n}=getComputedStyle(e),{lineHeight:r,paddingTop:o,paddingBottom:s}=getComputedStyle(i),l=parseFloat(n)+1,a=parseFloat(r)+parseFloat(o)+parseFloat(s)+1;return{width:l,height:a}}var tg=class t{tableState;resizeTracker;removeEventListeners;start(e){e.preventDefault();let i=this.resizeTracker.start();this.tableState.resize={},this.tableState.activeHandle=i.activeHandle,this.tableState.focusTable(),this.removeEventListeners=$o(sQ(e,this.tableState.tableElement),He(this.tableState.tableElement,"pointermove",n=>this.drag(n)),He(this.tableState.tableElement,"pointerup",()=>this.end()))}drag(e){e.preventDefault();let i=this.resizeTracker.drag({position:{x:e.clientX,y:e.clientY}});Y(i)&&(this.resizeTable(i.operation),this.tableState.activeHandle=i.activeHandle,this.tableState.activeCell=i.activeCell,this.tableState.anchorCell=i.anchorCell,this.tableState.outlinedSection=i.outlinedSection)}end(){this.removeEventListeners?.();let e=this.resizeTracker.end();"operation"in e&&(this.resizeTable(e.operation),this.tableState.activeCell=e.activeCell,this.tableState.anchorCell=e.anchorCell,this.tableState.outlinedSection=e.outlinedSection),this.tableState.activeHandle=e.activeHandle,this.tableState.resize=void 0}resizeTable({row:e,col:i}){if(Y(e)){let{action:n,index:r,count:o}=e;n==="add"?this.tableState.table.addEmptyRowsAt({row:r,count:o}):this.tableState.table.removeRowsAt({row:r,count:o})}if(Y(i)){let{action:n,index:r,count:o}=i;n==="add"?this.tableState.table.addEmptyColsAt({col:r,count:o}):this.tableState.table.removeColsAt({col:r,count:o})}}static startResize(e){new t(e).start(e.event)}constructor({event:e,tableState:i,handle:n}){this.tableState=i;let{width:r,height:o}=SX(i);this.resizeTracker=eg.of({tableState:this.tableState,handle:n,position:{x:e.clientX,y:e.clientY},cellSizePixels:{row:o,col:r},dragThresholdPixels:{row:o/2,col:r/2}})}};function xX(t,e){e.interactive&&(e.activeHandle={state:"hover",handle:t})}function vX(t){t.interactive&&(t.activeHandle=void 0)}function QX(t,e,i){if(i.interactive){if(!Pg(t)){t.preventDefault();return}e.type==="table"||e.type==="border"?tg.startResize({event:t,handle:e,tableState:i}):e.type==="header"&&Jm.startMove({event:t,rowOrCol:e.location,index:e.index,tableState:i,onClick:()=>Fm.showMenu({handle:e,point:{x:t.clientX,y:t.clientY},tableState:i})})}}function kX(t,e){let i=t.target;if(N(i))return;let n=kg(i);if(Y(n)){xX(n,e);return}let r=ma(i);if(Y(r)){mX(Qf(r),e);return}}function PX(t,e){let i=t.target;if(N(i))return;let n=kg(i);if(Y(n)){vX(e);return}let r=ma(i);if(Y(r)){gX(e);return}}function TX(t,e){let i=t.target;if(N(i))return;let n=kg(i);if(Y(n)){QX(t,n,e);return}let r=ma(i);if(Y(r)){$X(t,Qf(r),e);return}t.preventDefault()}function CX(t){t.preventDefault()}var RX=ae("<!> <!> <!>",1),EX=ae('<tr class="tbl-table-row"></tr>'),zX=ae('<tbody class="tbl-table-body"></tbody>'),_X=ae("<!> <!>",1),jX=ae("<!> <!>",1),ZX=ae("<!> <!> <!>",1),YX=ae("<!> <!>",1),DX=ae("<!> <!>",1),qX=ae("<!> <!>",1),WX=ae("<!> <!>",1),XX=ae("<!> <!> <!> <!> <!>",1),AX=ae("<!> <!>",1),LX=ae("<!> <!>",1),GX=ae("<!> <!> <!>",1),MX=ae("<!> <!>",1),NX=ae("<!> <!>",1),HX=ae("<!> <!> <!>",1),BX=ae("<!> <!>",1),IX=ae("<!> <!>",1),UX=ae("<!> <!>",1),VX=ae("<!> <!> <!> <!> <!> <!> <!>",1),FX=ae('<div class="tbl-table-wrapper"><table class="tbl-table" role="grid" tabindex="-1"><thead class="tbl-table-head"><!></thead><!></table> <!> <!> <!> <!></div>');function KX(t,e){Or(e,!0);let i=Um.of({table:()=>e.table,selection:()=>e.selection,scrollElement:()=>e.scrollElement,rootEditor:()=>e.rootEditor,menuRootElement:()=>e.menuRootElement,extensions:()=>e.extensions,markdownConfig:()=>e.markdownConfig,globalKeyBindings:()=>e.globalKeyBindings,selectionType:()=>e.selectionType,lineWrapping:()=>e.lineWrapping,onUndo:()=>e.onUndo,onRedo:()=>e.onRedo,onNavigate:()=>e.onNavigate,onDelete:()=>e.onDelete});Sf(()=>$o(He(i.document,"selectionchange",()=>gW(i)),He(i.document.body,"pointerdown",()=>hW(i),{capture:!0,passive:!0}),He(i.document.body,"pointerup",()=>fW(i),{capture:!0,passive:!0}),He(i.document.body,"pointerleave",()=>uW(i),{capture:!0,passive:!0}),He(i.document.body,"copy",S=>dW(S,i)),He(i.document.body,"cut",S=>OW(S,i)),He(i.document.body,"paste",S=>pW(S,i))));var n=FX(),r=$i(n);{let S=(y,Q=X2)=>{var P=EX();Ah(P,20,()=>i.table.colIndices,D=>D,(D,B)=>{let Z=ee(()=>({row:Q(),col:B})),H=ee(()=>({top:Q()===i.table.firstRowIndex,left:B===i.table.firstColIndex})),v=ee(()=>i.selection.isCell()&&wo(k(Z),i.selection.cell));{let _=ee(()=>i.outlinedSection?.containsOnEdge(k(Z))??{top:!1,right:!1,bottom:!1,left:!1}),G=ee(()=>i.move?.cellMovement(k(Z)));kW(D,{get location(){return k(Z)},get alignment(){return i.table.alignments[B]},get selected(){return k(v)},get position(){return k(H)},get outline(){return k(_)},get movement(){return k(G)},get win(){return i.window},children:(F,pe)=>{var we=RX(),rt=Ne(we);Ah(rt,16,()=>oW(k(Z),k(H)),be=>be,(be,ke)=>{{let bt=ee(()=>i.cellHandleState(k(Z),ke)),Zt=ee(()=>Y(i.resize));$2(be,{get of(){return ke},get state(){return k(bt)},get toggle(){return k(Zt)}})}});var Ye=re(rt,2);YW(Ye,{get hidden(){return k(v)},children:(be,ke)=>{var bt=$g(),Zt=Ne(bt);fq(Zt,()=>tW(i.table.cellAt(k(Z)),i.highlighter(k(Z)))),W(be,bt)},$$slots:{default:!0}});var Fe=re(Ye,2);{var wt=be=>{var ke=()=>i.table.cellAt(k(Z)),bt=ye=>i.table.setCellAt(k(Z),ye),Zt=()=>i.selection.cellSection,te=ye=>{i.selectionValue={cell:k(Z),section:ye}};{let ye=ee(()=>i.highlighter(k(Z)));CW(be,{get text(){return ke()},set text(Se){bt(Se)},get selection(){return Zt()},set selection(Se){te(Se)},get selectionType(){return i.selectionType},get lineWrapping(){return i.lineWrapping},get extensions(){return i.extensions},get markdownConfig(){return i.markdownConfig},get rootEditor(){return i.rootEditor},get globalKeyBindings(){return i.globalKeyBindings},get highlighter(){return k(ye)},onbeforeinput:Se=>EW(Se,i),ondragstart:Se=>zW(Se),onkeydown:(Se,We)=>_W(Se,We,i),onpaste:Se=>jW(Se,i)})}};pt(Fe,be=>{k(v)&&be(wt)})}W(F,we)},$$slots:{default:!0}})}}),W(y,P)};var o=$i(r),s=$i(o);S(s,()=>i.table.headerRowIndex);var l=re(o);{var a=y=>{var Q=zX();Ah(Q,20,()=>i.table.dataRowIndices,P=>P,(P,D)=>{S(P,()=>D)}),W(y,Q)},c=ee(()=>i.table.hasDataRows());pt(l,y=>{k(c)&&y(a)})}of(r,y=>i.tableElement=y,()=>i?.tableElement)}var h=re(r,2);{var f=S=>{let y=ee(()=>i.menu.type==="row"?"row":"column");bW(S,{get to(){return i.menuRootElement},children:(Q,P)=>{AW(Q,{translate:D=>i.menu.computeTranslation(D),children:(D,B)=>{let Z=ee(()=>{let{addable:te,alignable:ye,clearable:Se,duplicatable:We,moveable:Ke,removable:Je,sortable:Tt}=i.menu.capabilities;return{addable:te,alignable:ye,clearable:Se,duplicatable:We,moveable:Ke,removable:Je,sortable:Tt}});var H=VX(),v=Ne(H);{var _=te=>{var ye=ZX(),Se=Ne(ye);Jt(Se,{onclick:()=>ei({action:"sort",direction:"ascending"},i),children:(Je,Tt)=>{var me=_X(),xe=Ne(me);ti(xe,{name:"sort-ascending"});var Be=re(xe,2);ii(Be,{children:(ze,ht)=>{var Xe=Kt();Qt(()=>Qn(Xe,`Sort by ${k(y)??""} (A-Z)`)),W(ze,Xe)}}),W(Je,me)}});var We=re(Se,2);Jt(We,{onclick:()=>ei({action:"sort",direction:"descending"},i),children:(Je,Tt)=>{var me=jX(),xe=Ne(me);ti(xe,{name:"sort-descending"});var Be=re(xe,2);ii(Be,{children:(ze,ht)=>{var Xe=Kt();Qt(()=>Qn(Xe,`Sort by ${k(y)??""} (Z-A)`)),W(ze,Xe)}}),W(Je,me)}});var Ke=re(We,2);Mh(Ke),W(te,ye)};pt(v,te=>{k(Z).sortable&&te(_)})}var G=re(v,2);{var F=te=>{var ye=XX(),Se=Ne(ye);Jt(Se,{onclick:()=>ei({action:"align",alignment:"none"},i),children:(me,xe)=>{var Be=YX(),ze=Ne(Be);ti(ze,{name:"align-none"});var ht=re(ze,2);ii(ht,{children:(Xe,Si)=>{var en=Kt("Align none");W(Xe,en)}}),W(me,Be)}});var We=re(Se,2);Jt(We,{onclick:()=>ei({action:"align",alignment:"left"},i),children:(me,xe)=>{var Be=DX(),ze=Ne(Be);ti(ze,{name:"align-left"});var ht=re(ze,2);ii(ht,{children:(Xe,Si)=>{var en=Kt("Align left");W(Xe,en)}}),W(me,Be)}});var Ke=re(We,2);Jt(Ke,{onclick:()=>ei({action:"align",alignment:"center"},i),children:(me,xe)=>{var Be=qX(),ze=Ne(Be);ti(ze,{name:"align-center"});var ht=re(ze,2);ii(ht,{children:(Xe,Si)=>{var en=Kt("Align center");W(Xe,en)}}),W(me,Be)}});var Je=re(Ke,2);Jt(Je,{onclick:()=>ei({action:"align",alignment:"right"},i),children:(me,xe)=>{var Be=WX(),ze=Ne(Be);ti(ze,{name:"align-right"});var ht=re(ze,2);ii(ht,{children:(Xe,Si)=>{var en=Kt("Align right");W(Xe,en)}}),W(me,Be)}});var Tt=re(Je,2);Mh(Tt),W(te,ye)};pt(G,te=>{k(Z).alignable&&te(F)})}var pe=re(G,2);{var we=te=>{var ye=GX(),Se=Ne(ye);Jt(Se,{onclick:()=>ei({action:"add",direction:"before"},i),children:(Je,Tt)=>{var me=AX(),xe=Ne(me);ti(xe,{name:"add-before"});var Be=re(xe,2);ii(Be,{children:(ze,ht)=>{var Xe=Kt();Qt(()=>Qn(Xe,`Add ${k(y)??""} ${k(y)==="row"?"above":"before"}`)),W(ze,Xe)}}),W(Je,me)}});var We=re(Se,2);Jt(We,{onclick:()=>ei({action:"add",direction:"after"},i),children:(Je,Tt)=>{var me=LX(),xe=Ne(me);ti(xe,{name:"add-after"});var Be=re(xe,2);ii(Be,{children:(ze,ht)=>{var Xe=Kt();Qt(()=>Qn(Xe,`Add ${k(y)??""} ${k(y)==="row"?"below":"after"}`)),W(ze,Xe)}}),W(Je,me)}});var Ke=re(We,2);Mh(Ke),W(te,ye)};pt(pe,te=>{k(Z).addable&&te(we)})}var rt=re(pe,2);{var Ye=te=>{var ye=HX(),Se=Ne(ye);{var We=me=>{Jt(me,{onclick:()=>ei({action:"move",direction:"backward"},i),children:(xe,Be)=>{var ze=MX(),ht=Ne(ze);{let Si=ee(()=>`move-${k(y)==="row"?"up":"left"}`);ti(ht,{get name(){return k(Si)}})}var Xe=re(ht,2);ii(Xe,{children:(Si,en)=>{var zs=Kt();Qt(()=>Qn(zs,`Move ${k(y)??""} ${k(y)==="row"?"up":"left"}`)),W(Si,zs)}}),W(xe,ze)}})};pt(Se,me=>{(k(Z).moveable==="backward"||k(Z).moveable===!0)&&me(We)})}var Ke=re(Se,2);{var Je=me=>{Jt(me,{onclick:()=>ei({action:"move",direction:"forward"},i),children:(xe,Be)=>{var ze=NX(),ht=Ne(ze);{let Si=ee(()=>`move-${k(y)==="row"?"down":"right"}`);ti(ht,{get name(){return k(Si)}})}var Xe=re(ht,2);ii(Xe,{children:(Si,en)=>{var zs=Kt();Qt(()=>Qn(zs,`Move ${k(y)??""} ${k(y)==="row"?"down":"right"}`)),W(Si,zs)}}),W(xe,ze)}})};pt(Ke,me=>{(k(Z).moveable==="forward"||k(Z).moveable===!0)&&me(Je)})}var Tt=re(Ke,2);Mh(Tt),W(te,ye)};pt(rt,te=>{k(Z).moveable!==!1&&te(Ye)})}var Fe=re(rt,2);{var wt=te=>{Jt(te,{onclick:()=>ei({action:"duplicate"},i),children:(ye,Se)=>{var We=BX(),Ke=Ne(We);ti(Ke,{name:"duplicate"});var Je=re(Ke,2);ii(Je,{children:(Tt,me)=>{var xe=Kt();Qt(()=>Qn(xe,`Duplicate ${k(y)??""}`)),W(Tt,xe)}}),W(ye,We)}})};pt(Fe,te=>{k(Z).duplicatable&&te(wt)})}var be=re(Fe,2);{var ke=te=>{Jt(te,{onclick:()=>ei({action:"clear"},i),children:(ye,Se)=>{var We=IX(),Ke=Ne(We);ti(Ke,{name:"clear"});var Je=re(Ke,2);ii(Je,{children:(Tt,me)=>{var xe=Kt();Qt(()=>Qn(xe,`Clear ${k(y)??""}`)),W(Tt,xe)}}),W(ye,We)}})};pt(be,te=>{k(Z).clearable&&te(ke)})}var bt=re(be,2);{var Zt=te=>{Jt(te,{onclick:()=>ei({action:"remove"},i),children:(ye,Se)=>{var We=UX(),Ke=Ne(We);ti(Ke,{name:"remove"});var Je=re(Ke,2);ii(Je,{children:(Tt,me)=>{var xe=Kt();Qt(()=>Qn(xe,`Delete ${k(y)??""}`)),W(Tt,xe)}}),W(ye,We)}})};pt(bt,te=>{k(Z).removable&&te(Zt)})}W(D,H)},$$slots:{default:!0}})},$$slots:{default:!0}})},u=ee(()=>Y(i.menu));pt(h,S=>{k(u)&&S(f)})}var d=re(h,2);Ah(d,16,()=>rW,S=>S,(S,y)=>{{let Q=ee(()=>Im(i.activeHandle?.handle,y)?i.activeHandle.state:void 0);$2(S,{get of(){return y},get state(){return k(Q)}})}});var O=re(d,2);{var m=S=>{SW(S)},g=ee(()=>!i.interactive&&N(i.outline));pt(O,S=>{k(g)&&S(m)})}var $=re(O,2);{var w=S=>{nX(S)},b=ee(()=>i.selection.isAll());pt($,S=>{k(b)&&S(w)})}of(n,S=>i.wrapperElement=S,()=>i?.wrapperElement),Qt(S=>Ze(n,"data-select-all",S),[()=>uo(i.selection.isAll())]),Kl("mouseover",n,S=>kX(S,i)),Kl("mouseout",n,S=>PX(S,i)),Kl("pointerdown",n,S=>TX(S,i)),Wh("dragover",n,S=>CX(S)),Kl("keydown",r,S=>pX(S,i)),Wh("copy",r,S=>uX(S,i)),Wh("cut",r,S=>dX(S,i)),Wh("paste",r,S=>OX(S,i)),W(t,n),pr()}Tv(["mouseover","mouseout","pointerdown","keydown"]);var ig=class t extends Me{tableDescription;widgetElement;height;destroyWidgetElement;get estimatedHeight(){return this.height}coordsAt(e,i,n){let r=this.tableDescription.table.closestCellAtPosition(i),o=lf(e,r);if(N(o))return null;let s=o.getBoundingClientRect();return{top:s.top,right:s.right,bottom:s.bottom,left:s.left}}toDOM(e){if(Y(this.widgetElement))return this.widgetElement;let{widgetElement:i,destroyWidgetElement:n}=this.create(e);return this.widgetElement=i,this.destroyWidgetElement=n,e.requestMeasure({read:()=>{this.height=i.getBoundingClientRect().height}}),i}destroy(e){this.destroyWidgetElement?.(),this.destroyWidgetElement=void 0,this.widgetElement=void 0,this.height=i2}create(e){let i=sa(e.dom).createElement("div");i.className="tbl-table-widget",i.tabIndex=-1,i.addEventListener("pointerdown",d=>{d?.target===i&&d.preventDefault()});let n=this.tableDescription,r=I7(()=>{bf(()=>{let d=!n.table.text.eq(n.editorTableText),O=!vf(n.selection.value,n.editorSelectionValue);if(!d&&!O)return;let m;if(n.selection.isCell()){let{from:$}=n.table.cellSpan(n.selection.cell);m={anchor:n.from+$+n.selection.cellSection.anchor,head:n.from+$+n.selection.cellSection.head}}else n.selection.isAll()?m={anchor:n.from,head:n.to}:n.selection.isHidden()&&(m={anchor:n.from+1,head:n.from+1});let g=d?{from:n.from,to:n.to,insert:n.table.text}:void 0;n.markSynchronized(),e.dispatch({annotations:hr("table.edit"),changes:g,selection:m})})}),{extensions:o,markdownConfig:s,globalKeyBindings:l,selectionType:a,lineWrapping:c}=cQ(e.state),h=Cv(KX,{target:i,props:{table:n.table,selection:n.selection,scrollElement:i,rootEditor:e,extensions:o,markdownConfig:s,globalKeyBindings:l,selectionType:a,lineWrapping:c,menuRootElement:il(e,Bv).dom,onUndo:()=>jc(e),onRedo:()=>dl(e),onNavigate:d=>{e.dispatch({annotations:hr("table.navigate"),selection:{anchor:d==="before"?n.from-1:n.to+1}}),e.focus()},onDelete:()=>{e.dispatch({annotations:hr("table.delete"),changes:{from:n.from,to:n.to},selection:e.state.selection}),e.focus()}}}),f=()=>{Rv(h)},u=Sq(i,({height:d})=>{this.height=d});return{widgetElement:i,destroyWidgetElement:$o(r,f,u)}}static of(e,i){return new t(e,i)}constructor(e,i){super(),this.tableDescription=e;let n=hA(i);if(Y(n)){let{widgetElement:r,destroyWidgetElement:o}=this.create(n);this.widgetElement=r,this.destroyWidgetElement=o,this.height=yq(n,r)}else this.widgetElement=void 0,this.destroyWidgetElement=void 0,this.height=i2}};function JX(t,e){return{widget:ig.of(t,e),block:!0,inclusive:!0}}function eA(t,e){return E.replace(JX(t,e))}function tA(t,e){let i=new Ue;for(let n of t)i.add(n.from,n.to,eA(n,e));return i.finish()}function iA(t){return lQ(t)}function nA(t,e){return lQ(t,e)}function lQ(t,e=[]){let i=[];aD(V(t),o=>{T2(o)&&i.push({from:t.doc.lineAt(o.from).from,to:t.doc.lineAt(o.to).to})});let n=[],r=[];for(let o of i){if($D(e,o,Y2)){n.push(o);continue}let s=rA(o,t);mf(s)?n.push(o):r.push(...s)}return{spans:n,formatting:r,complete:N0(t)}}function rA(t,e){return[...oA(t,e),...sA(t,e)]}function oA(t,{doc:e,lineBreak:i}){return ca({doc:e,lineBreak:i,span:t}).changes}function sA({from:t,to:e},{doc:i}){let n=i.slice(t,e),{text:r}=Cm(n);return n.eq(r)?[]:[{from:t,to:e,insert:r}]}var lA={create(t){return Nh(t)},update(t,e){if(Zq(e))return Nh(e.state);if(!e.docChanged&&N(e.selection)&&t.complete)return t;let{tables:i,formatting:n,decorations:r}=t;if(!e.docChanged&&t.complete)return{tables:y2(i,e),formatting:n,decorations:r.map(e.changes),complete:!0};if(jq(e)||aA(e,i))return Nh(e.state);let o=y2(i,e).map(c=>c.span),{complete:s,spans:l,formatting:a}=nA(e.state,o);return nr(o,l,Y2)?{complete:s,tables:i,formatting:a,decorations:r.map(e.changes)}:Nh(e.state)},provide(t){return T.decorations.from(t,e=>e.decorations)}},aQ=ce.define(lA);function Nh(t){let{spans:e,formatting:i,complete:n}=iA(t),{doc:r,selection:o}=t,s=e.map(l=>Nm.of({span:l,doc:r,selection:o}));return{complete:n,tables:s,formatting:i,decorations:tA(s,t)}}function aA(t,e){return!Sg(t)&&e.some(i=>t.changes.touchesRange(i.from,i.to)!==!1)}function y2(t,e){return uD(t,i=>i.applyTransaction(e))}var cA={create(){return{view:void 0}},update(t){return t}},Tg=ce.define(cA);function cQ(t){return t.facet(Rm)}function ur(t){return t.field(aQ)}function hA(t){return t.field(Tg).view}function fA(t){let{handlePosition:e,selectionType:i,lineWrapping:n}=cQ(t);return{...gf(window)?{"data-tbl-hoverable":""}:{},"data-tbl-theme-mode":t.facet(T.darkTheme)?"dark":"light","data-tbl-handle-position":e,"data-tbl-selection-type":i,"data-tbl-line-wrapping":n}}var uA=["undo","redo","select.undo","select.redo"];function dA(t){return uA.some(e=>t.isUserEvent(e))}function OA(t){return hQ(t,"select.search")}function pA(t){return hQ(t,"select")}function mA(t){return t.isUserEvent("delete.forward")}function gA(t){return t.isUserEvent("delete.backward")}function hQ(t,e){return t.annotation(_e.userEvent)===e}var $A=({state:t,view:e,transactions:i})=>{e.hasFocus||ur(t).tables.some(n=>n.containsSelection())||i.some(n=>dA(n)||OA(n)&&!nQ(e))&&e.focus()},fQ=A.define(),wA=new Map(qv.map(t=>[t,fQ.of(t)]));function uQ(t){return wA.get(t)}var bA=(t,e)=>!e||!ur(t).tables.some(i=>i.containsSelection())?null:uQ("table.focus"),yA=t=>{let{selection:e,startState:i,docChanged:n}=t;if(N(e)||n||!pA(t)||!Uh(e)||!Uh(i.selection))return t;let r=i.selection.main,o=e.main;for(let s of ur(i).tables){let l=s.from===o.head,a=s.to===o.head,c=s.from===r.head+1&&s.to===o.head-1,h=s.from===o.head+1&&s.to===r.head-1,f;if(l?f=s.table.firstCellSpan.from:c?f=s.table.firstCellSpan.to:(a||h)&&(f=s.table.lastCellSpan.to),Y(f))return[t,{annotation:hr("table.navigate"),selection:NY({pos:s.from+f})}]}return t},SA=t=>{let{selection:e,startState:i}=t;if(N(e)||!Uh(e))return t;let n=i.selection.main;if(mA(t)){for(let r of ur(i).tables)if(n.head===r.from-1){let o=r.table.firstCellSpan.from;return[{selection:{anchor:r.from+o,head:r.from+o}}]}return t}else if(gA(t)){for(let r of ur(i).tables)if(n.head===r.to+1){let o=r.table.lastCellSpan.to;return[{selection:{anchor:r.from+o,head:r.from+o}}]}return t}else return t};function xA(t){return T5(t)>0||C5(t)>0}var vA=({state:t,docChanged:e,selectionSet:i,transactions:n,view:r})=>{if(!e&&!i&&xA(t)||n.some(a=>Sg(a)))return;let{formatting:o}=ur(t);if(mf(o))return;let s=ot.of(o,t.doc.length,t.lineBreak),l=t.selection.map(s);r.dispatch({annotations:hr("table.format"),changes:s,selection:l})},QA=t=>{if(!t.docChanged||Sg(t))return t;let e=t.changes,{tables:i}=ur(t.startState),n=[];for(let s of i)if(e.touchesRange(s.from-1,s.from)!==!1||e.touchesRange(s.to,s.to+1)!==!1){let l={from:e.mapPos(s.from,1),to:e.mapPos(s.to)};if(l.from>=l.to)continue;n.push(ca({doc:t.newDoc,lineBreak:t.startState.lineBreak,span:l}).changes)}if(mf(n))return t;let r=ot.of(n,t.changes.newLength,t.startState.lineBreak),o=t.newSelection.map(r);return[t,{annotation:hr("table.correct"),changes:r,selection:o,sequential:!0}]};function kA(t,{anchor:e,head:i,goalColumn:n,bidiLevel:r}={}){return x.range(e??t.anchor,i??t.head,n??t.goalColumn,r??t.bidiLevel??void 0)}var PA=t=>{let{selection:e,startState:i,docChanged:n}=t;if(N(e)||n||Uh(e))return t;let r=e.ranges.map(o=>{if(o.empty)return o;let s=ur(i).tables,l=S2(o.anchor,s),a=S2(o.head,s);return Y(l)||Y(a)?kA(o,{anchor:l,head:a}):o});return nr(e.ranges,r,(o,s)=>o===s)?t:[t,{annotations:hr("table.select"),selection:x.create(r,e.mainIndex)}]};function S2(t,e){for(let i of e){let n=i.from,r=i.to,o=i.from+1,s=i.to-1;if(t===n||t===o)return n-1;if(t===r||t===s)return r+1}}var TA={"& .cm-tooltip.cm-tooltip-autocomplete:has(.cm-completionIcon-table)":{border:"1px solid var(--tbl-theme-menu-border-color)","box-shadow":"2px 2px 0 0 rgb(0 0 0 / 10%)","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)"},"& .cm-tooltip.cm-tooltip-autocomplete > ul:has(.cm-completionIcon-table)":{"min-width":"auto",display:"flex","flex-direction":"column","justify-content":"center",padding:"0.25em 0","line-height":1,"font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)",background:"var(--tbl-theme-menu-background)"},"& .cm-tooltip.cm-tooltip-autocomplete ul li[aria-selected]:has(.cm-completionIcon-table)":{color:"var(--tbl-theme-menu-hover-text-color)","&::before":{background:"var(--tbl-theme-menu-hover-background)"}},"& .cm-tooltip.cm-tooltip-autocomplete ul li:not([aria-selected]):has(.cm-completionIcon-table)":{color:"var(--tbl-theme-menu-text-color)"},"& .cm-tooltip.cm-tooltip-autocomplete ul li:not([aria-selected]):has(.cm-completionIcon-table), & .cm-tooltip.cm-tooltip-autocomplete ul li[aria-selected]:has(.cm-completionIcon-table)":{position:"relative",padding:"0.5em 0.75em",background:"var(--tbl-theme-menu-background)",display:"flex",gap:"0.75em","align-items":"center","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)","line-height":1,"&::before":{position:"absolute",height:"100%",width:"calc(100% - 0.5em)",left:"0.25em",top:0,content:'""',"pointer-events":"none"}},"& .cm-completionIcon.cm-completionIcon-table":{opacity:1,"mask-image":`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='14' width='12.25' viewBox='0 0 448 512'%3E%3C!--!Font Awesome Free v7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2026 Fonticons, Inc.--%3E%3Cpath d='M384 96l-128 0 0 128 128 0 0-128zm64 128l0 192c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96C0 60.7 28.7 32 64 32l320 0c35.3 0 64 28.7 64 64l0 128zM64 288l0 128 128 0 0-128-128 0zm128-64l0-128-128 0 0 128 128 0zm64 64l0 128 128 0 0-128-128 0z'/%3E%3C/svg%3E")`,"mask-position":"center","mask-repeat":"no-repeat",padding:0,background:"currentColor",position:"relative",width:"1em",height:"1em","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)","line-height":1},"& :has(.cm-completionIcon.cm-completionIcon-table) .cm-completionLabel":{position:"relative"}},CA={'&[data-tbl-handle-position="inside"] .tbl-table-widget':{"padding-left":"6px","margin-left":0},".tbl-table-widget":{contain:"paint","padding-top":"16px","padding-right":"16px","padding-bottom":"16px","padding-left":"16px","margin-left":"-10px","overflow-x":"auto","overflow-y":"hidden","&, &::before, &::after, & *, & *::before, & *::after":{"box-sizing":"border-box"}},"&.cm-editor .cm-content div.tbl-table-widget::selection, & .cm-content div.tbl-table-widget ::selection, & .cm-content div.tbl-table-widget:focus::selection, & .cm-content div.tbl-table-widget :focus::selection":{"background-color":"transparent !important","caret-color":"transparent !important"}},RA={".cm-tooltip.tbl-menu-tooltip":{border:"none","user-select":"none","&, &::before, &::after, & *, & *::before, & *::after":{"box-sizing":"border-box"}}},EA={".tbl-blocking-overlay":{position:"absolute",top:0,left:0,"z-index":900,"background-color":"transparent",width:"100%",height:"100%"}},zA={"& .cm-content div.tbl-table-widget .tbl-cell-editor ::selection, & .cm-content div.tbl-table-widget .tbl-cell-editor :focus::selection":{"background-color":"Highlight !important","caret-color":"initial !important"},"&[data-tbl-selection-type='codemirror'] .tbl-cell-editor .cm-editor .cm-content":{"caret-color":"transparent !important"},"&[data-tbl-selection-type='codemirror'] .tbl-cell-editor .cm-editor .cm-content ::selection, &[data-tbl-selection-type='codemirror'] .tbl-cell-editor .cm-editor .cm-content :focus::selection":{"background-color":"transparent !important","caret-color":"transparent !important"},"&[data-tbl-line-wrapping='wrap'] .tbl-cell-editor .cm-editor .cm-content":{"word-break":"normal","overflow-wrap":"break-word"},".tbl-cell-editor":{height:"100%"},".tbl-cell-editor .cm-editor":{margin:0,padding:0,outline:"none",height:"100%",background:"unset",color:"var(--tbl-theme-text-color)"},".tbl-cell-editor .cm-editor .cm-scroller":{margin:0,padding:0,overflow:"hidden","line-height":1.5,"font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)"},".tbl-cell-editor .cm-editor .cm-content":{margin:0,padding:"7px 9px","line-height":1.5,"font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)"},".tbl-cell-editor .cm-editor .cm-line":{margin:0,padding:"0 1px","line-height":1.5,"touch-action":"none","font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)"}},_A={".tbl-cell":{"box-sizing":"content-box",position:"relative","vertical-align":"top","background-color":"var(--tbl-row-background)",padding:0,"font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)","min-width":"calc(4ch + 20px)",height:"inherit","user-select":"none",border:"none","scroll-margin-right":"1px","scroll-margin-left":"1px","&:first-child":{"scroll-margin-left":"16px"},"&:last-child":{"scroll-margin-right":"16px"},'&[align="left"]':{"text-align":"left"},'&[align="center"]':{"text-align":"center"},'&[align="right"]':{"text-align":"right"},'&[data-border~="top"]':{"border-top":"1px solid var(--tbl-theme-border-color)"},'&[data-border~="right"]':{"border-right":"1px solid var(--tbl-theme-border-color)"},'&[data-border~="bottom"]':{"border-bottom":"1px solid var(--tbl-theme-border-color)"},'&[data-border~="left"]':{"border-left":"1px solid var(--tbl-theme-border-color)"},'&[data-state="moving"]':{"z-index":200,"background-color":"color-mix(in srgb, var(--tbl-row-background), transparent 15%)"},'&[data-state="shiftable"]':{transform:"translate3d(0, 0, 0)",transition:"transform 150ms ease"},"&[data-outline]":{"&::after":{display:"block",position:"absolute",top:"-1px",left:"-1px",border:"none",width:"calc(100% + 2px)",height:"calc(100% + 2px)","pointer-events":"none",content:'""'},'&[data-outline~="top"]::after':{"border-top":"2px solid var(--tbl-theme-outline-color)"},'&[data-outline~="right"]::after':{"border-right":"2px solid var(--tbl-theme-outline-color)"},'&[data-outline~="bottom"]::after':{"border-bottom":"2px solid var(--tbl-theme-outline-color)"},'&[data-outline~="left"]::after':{"border-left":"2px solid var(--tbl-theme-outline-color)"}}},".tbl-header-cell:not([align])":{"text-align":"var(--tbl-style-default-header-alignment)"}},jA={'&[data-tbl-line-wrapping="wrap"] .tbl-cell-view':{"word-break":"normal","overflow-wrap":"break-word"},'&[data-tbl-line-wrapping="nowrap"] .tbl-cell-view':{"white-space":"pre"},".tbl-cell-view":{margin:0,outline:"none",padding:"7px 10px",height:"100%","line-height":1.5,"white-space-collapse":"break-spaces","font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)","&[data-hidden]":{display:"none"}},".tbl-cell-view [data-br]":{"white-space":"pre"}},ZA={".tbl-handle":{display:"flex",position:"absolute","justify-content":"center","align-items":"center","z-index":200,transition:"opacity 150ms ease 50ms","touch-action":"none"},".tbl-handle[data-hover], .tbl-handle[data-active]":{"--tbl-handle-opacity":1},'&:not([data-tbl-hoverable]) .tbl-handle[data-type="border"], &:not([data-tbl-hoverable]) .tbl-handle[data-type="table"]':{display:"none"},'.tbl-handle[data-type="border"]':{"background-color":"var(--tbl-theme-border-hover-color)"},'.tbl-handle[data-type="border"][data-active]':{"background-color":"var(--tbl-theme-border-active-color)"},'.tbl-handle[data-type="border"][data-toggle]':{transition:"none"},'.tbl-handle[data-type="border"][data-location="top"]':{top:"-1px",left:"-1px",width:"calc(100% + 2px)",height:"2px"},'.tbl-handle[data-type="border"][data-location="left"]':{top:"-1px",left:"-1px",width:"2px",height:"calc(100% + 2px)"},'.tbl-handle[data-type="border"][data-location="col"]':{top:"-1px",right:"-2px",width:"3px",height:"calc(100% + 2px)"},'.tbl-handle[data-type="border"][data-location="row"]':{bottom:"-2px",left:"-1px",width:"calc(100% + 2px)",height:"3px"},'.tbl-handle[data-type="table"]':{"box-sizing":"content-box",color:"var(--tbl-theme-border-hover-color)","background-color":"color-mix(in srgb, var(--tbl-theme-border-color), var(--tbl-theme-header-row-background) 80%)"},'.tbl-handle[data-type="table"][data-location="right"]':{top:0,left:"100%",width:"15px",height:"calc(100% - 2px)",border:"1px solid var(--tbl-theme-border-color)","border-left":"none","&::before":{position:"absolute",top:"-1px",left:"-2px",width:"2px",height:"calc(100% + 2px)",content:'""'},"&::after":{position:"absolute","z-index":366,top:"-1px",left:0,content:'""',width:"calc(100% + 1px)",height:"calc(100% + 2px)","background-color":"var(--tbl-overlay)"}},'.tbl-handle[data-type="table"][data-location="bottom-right"]':{left:"calc(100% - 1px)",top:"calc(100% - 1px)","z-index":250,width:"15px",height:"15px",border:"1px solid var(--tbl-theme-border-color)","border-top-style":"dashed","border-left-style":"dashed","&::after":{position:"absolute","z-index":366,top:"-1px",left:"-1px",content:'""',width:"calc(100% + 2px)",height:"calc(100% + 2px)","background-color":"var(--tbl-overlay)"}},'.tbl-handle[data-type="table"][data-location="bottom"]':{top:"100%",left:"0",width:"calc(100% - 2px)",height:"15px",border:"1px solid var(--tbl-theme-border-color)","border-top":"none","&::before":{position:"absolute",top:"-2px",left:"-1px",width:"calc(100% + 2px)",height:"2px",content:'""'},"&::after":{position:"absolute","z-index":366,top:0,left:"-1px",content:'""',width:"calc(100% + 2px)",height:"calc(100% + 1px)","background-color":"var(--tbl-overlay)"}},'.tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="bottom"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="bottom"]':{"--tbl-handle-opacity":1},'.tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="right"]':{"border-bottom":"none"},'.tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="bottom"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="bottom"]':{"border-right":"none"},'.tbl-handle[data-type="table"][data-active], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="bottom"]':{"background-color":"color-mix(in srgb, var(--tbl-theme-border-color), var(--tbl-theme-header-row-background) 80%)",color:"var(--tbl-theme-border-active-color)"},'&[data-tbl-handle-position="outside"] .tbl-handle[data-type="header"]':{"box-sizing":"content-box",transition:"none","z-index":300,color:"var(--tbl-theme-border-hover-color)",border:"1px solid transparent","&:hover":{"border-color":"var(--tbl-theme-border-color)","background-color":"color-mix(in srgb, var(--tbl-theme-border-color), var(--tbl-theme-header-row-background) 80%)"},"&[data-active]":{"background-color":"var(--tbl-theme-outline-color)","border-color":"var(--tbl-theme-outline-color)",color:"#ffffff"}},'&[data-tbl-handle-position="outside"] .tbl-handle[data-type="header"][data-location="row"]':{top:"-1px",left:"-17px",width:"15px",height:"100%","border-right":"none"},'&[data-tbl-handle-position="outside"] .tbl-handle[data-type="header"][data-location="col"]':{top:"-17px",left:"-1px",width:"100%",height:"15px","border-bottom":"none","&:hover::after":{position:"absolute","z-index":366,top:"-1px",left:"-1px",content:'""',width:"calc(100% + 2px)",height:"calc(100% + 1px)","background-color":"var(--tbl-overlay)"}},'&[data-tbl-handle-position="inside"] .tbl-handle[data-type="header"]':{transition:"none","z-index":300,color:"var(--tbl-theme-border-hover-color)","&:hover":{color:"var(--tbl-theme-border-active-color)"},"&[data-active]":{color:"var(--tbl-theme-outline-color)"}},'&[data-tbl-handle-position="inside"] .tbl-handle[data-type="header"][data-location="row"]':{top:"calc(50% - 13px)",left:"-1px",width:"3px",height:"26px","border-top":"4px solid var(--tbl-row-background)","border-bottom":"4px solid var(--tbl-row-background)","background-color":"var(--tbl-row-background)","&:hover::after, &[data-active]::after":{position:"absolute",top:"-6px",left:0,"box-sizing":"content-box","border-top":"2px solid transparent","border-bottom":"2px solid transparent",width:"calc(100% + 6px)",height:"calc(100% + 8px)",content:'""'}},'&[data-tbl-handle-position="inside"] .tbl-handle[data-type="header"][data-location="col"]':{top:"-1px",left:"calc(50% - 11.5px)",width:"23px",height:"3px","border-right":"4px solid var(--tbl-row-background)","border-left":"4px solid var(--tbl-row-background)","background-color":"var(--tbl-row-background)","&:hover::after, &[data-active]::after":{position:"absolute",top:0,left:"-6px","box-sizing":"content-box","border-right":"2px solid transparent","border-left":"2px solid transparent",width:"calc(100% + 8px)",height:"calc(100% + 6px)",content:'""'}},".tbl-handle-grip":{"pointer-events":"none","z-index":333}},YA={".tbl-menu-item-icon":{"z-index":200,width:"1em",height:"1em","pointer-events":"none","font-size":"var(--tbl-style-menu-font-size)"}},DA={".tbl-menu-item-text":{"z-index":200,"pointer-events":"none","user-select":"none","font-size":"var(--tbl-style-menu-font-size)"}},qA={".tbl-menu-item":{display:"flex",position:"relative","align-items":"center",gap:"0.75em",padding:"0.5em 0.75em",color:"var(--tbl-theme-menu-text-color)","user-select":"none","line-height":1,"font-size":"var(--tbl-style-menu-font-size)","&:active":{cursor:"pointer",color:"var(--tbl-theme-menu-hover-text-color)","&::after":{"background-color":"var(--tbl-theme-menu-hover-background)"}},"&::after":{position:"absolute",left:"0.25em",width:"calc(100% - 0.5em)",height:"100%",content:'""'}},"&[data-tbl-hoverable] .tbl-menu-item:hover":{cursor:"pointer",color:"var(--tbl-theme-menu-hover-text-color)","&::after":{"background-color":"var(--tbl-theme-menu-hover-background)"}}},WA={".tbl-menu-separator":{margin:"0.25em 0.5em","background-color":"var(--tbl-theme-menu-border-color)",height:"1px","font-size":"var(--tbl-style-menu-font-size)"}},XA={".tbl-menu":{position:"absolute",top:0,left:0,"z-index":900,"box-shadow":"2px 2px 0 0 rgb(0 0 0 / 10%)",border:"1px solid var(--tbl-theme-menu-border-color)","background-color":"var(--tbl-theme-menu-background)",padding:"0.25em 0",width:"max-content","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)"}},AA={".tbl-select-all-overlay":{position:"absolute",top:0,left:0,"z-index":900,"background-color":"var(--tbl-overlay)",width:"100%",height:"100%","pointer-events":"none"}},LA={"& .tbl-table-wrapper[data-select-all]":{"--tbl-select-all-overlay":"var(--tbl-theme-select-all-blur-overlay)"},"&.cm-focused .tbl-table-wrapper[data-select-all]":{"--tbl-select-all-overlay":"var(--tbl-theme-select-all-focus-overlay)"},".tbl-table-wrapper":{"--tbl-overlay":"var(--tbl-select-all-overlay, transparent)",position:"relative",width:"fit-content","white-space-collapse":"collapse","touch-action":"none"},".tbl-table":{"border-collapse":"separate","border-spacing":0,overflow:"visible","touch-action":"none","&:focus-visible":{outline:"none"}},".tbl-table-head, .tbl-table-body":{height:"100%"},".tbl-table-row":{height:0},"@supports (-moz-appearance: none) /* TableTheme */":{".tbl-table-row":{height:"fit-content"}},".tbl-table-head .tbl-table-row":{"--tbl-row-background":"var(--tbl-theme-header-row-background)"},".tbl-table-body .tbl-table-row:nth-child(2n + 1)":{"--tbl-row-background":"var(--tbl-theme-even-row-background)"},".tbl-table-body .tbl-table-row:nth-child(2n)":{"--tbl-row-background":"var(--tbl-theme-odd-row-background)"}},GA={...TA,...RA,...CA,...LA,...EA,..._A,...zA,...jA,...ZA,...XA,...qA,...YA,...DA,...WA,...AA},MA=t=>{let e=t.effects.find(i=>i.is(fQ))?.value;return Y(e)?{annotations:hr(e)}:null},NA=t=>{let e=t.annotation(yg);return Y(e)?[uQ(Rq(e))]:[]},ng=class t{static of(e){return e.state.field(Tg).view=e,new t}constructor(){}};function HA(t){return[Rm.of(t),aQ,Tg,fe.define(e=>ng.of(e)),T.editorAttributes.compute([Rm,T.darkTheme],fA),T.baseTheme(GA),T.theme("light"in t.theme?{':where(:root:has(&[data-tbl-theme-mode="light"]))':t.theme.light.props,':where(:root:has(&[data-tbl-theme-mode="dark"]))':t.theme.dark.props}:{":where(:root:has(&))":t.theme.props}),T.theme({":where(:root:has(&))":t.style.props}),iO.of(NA),Tr.of(Bv),ie.transactionExtender.of(MA),ie.transactionFilter.of(QA),ie.transactionFilter.of(SA),ie.transactionFilter.of(yA),ie.transactionFilter.of(PA),T.updateListener.of(vA),T.updateListener.of($A),T.clipboardInputFilter.of(LD),T.focusChangeEffect.of(bA)]}function dQ(t){return HA(Q2(t))}function BA(t,e){if(!N(t))for(let i of t)e(i)}function IA(t,e){N(t)||e(t)}function OQ(t,e,i){if(!Number.isInteger(t)||t<=0)throw new Error(i);if(!Number.isInteger(e)||e<=0)throw new Error(i)}function UA({pos:t,doc:e,lineBreak:i,rows:n,cols:r}){let[o,...s]=rr(`${"| ".repeat(r)}|`,{count:n}),l=`${"| - ".repeat(r)}|`,{before:a,after:c}=ca({doc:e,lineBreak:i,span:{from:t-1,to:t}}),h=`${a?.insert??""}${[o,l,...s].join(i)}${c?.insert??""}`;return{label:`${n}\xD7${r} table`,type:"table",apply:(f,u)=>{f.dispatch({annotations:yl.of(u),changes:{from:t-1,to:t,insert:h},selection:{anchor:t+1+(a?.count??0)}})}}}var VA=[{rows:2,cols:2},{rows:3,cols:3},{rows:4,cols:4}];function FA(t){let e=t?.options??VA;return({state:i,pos:n})=>{let r=i.doc.lineAt(n);if(n!==r.from+1||r.length!==1||r.text.slice(0,1)!=="|")return null;let{doc:o,lineBreak:s}=i;return{from:n,options:e.map(({rows:l,cols:a})=>UA({pos:n,doc:o,lineBreak:s,rows:l,cols:a}))}}}function pQ(t){return BA(t?.options,({rows:e,cols:i})=>{OQ(e,i,"options[].{ rows, cols } must be positive integers")}),FA(t)}var KA={rows:2,cols:2};function JA(t){let{rows:e,cols:i}=t?.size??KA;return({state:n,dispatch:r})=>{let{anchor:o,head:s}=n.selection.main,{from:l,to:a}=o<=s?{from:o,to:s}:{from:s,to:o},{before:c,after:h}=ca({doc:n.doc,lineBreak:n.lineBreak,span:{from:l,to:a}}),[f,...u]=rr(`${"| ".repeat(i)}|`,{count:e}),d=`${"| - ".repeat(i)}|`,O=`${c?.insert??""}${[f,d,...u].join(n.lineBreak)}${h?.insert??""}`;return r(n.update({changes:{from:l,to:a,insert:O},selection:{anchor:l+2+(c?.count??0)}})),!0}}function mQ(t){return IA(t?.size,({rows:e,cols:i})=>{OQ(e,i,"size.{rows, cols} must be positive integers")}),JA(t)}var So=16,e8="50rem",t8="88%",Cg="0px",i8=[y0(),S0(),c0(),k5(),r5(),a0(),ie.allowMultipleSelections.of(!0),V0(),Uo(l5,{fallback:!0}),f5(),vb(),jO(),f0(),u0(),h0(),Ht.of([...Pb,...sO,...pO,...rO,...t5,...ZO,..._b])],Bg=[1.4,1.2,1.15,1.1,1.04,1],DQ=1.6,qQ=12/So,Pf=1.3,Tf=1.5,WQ=13/So,OH=12/So,gQ=22/So;function Cf(t){return`${t/WQ}em`}var zf={compact:1.7,writing:2},$Q=new To;function wQ(t){let e=t?zf.writing:zf.compact;return T.theme({"&":{"--md-line-ratio":String(e),"--md-line-pad-y":t?"4px":"2px"}})}function yo(t){return`${t/qQ}em`}function bQ(t){let e=Bg[t-1]??1;return yo(e*DQ)}var jg="\u037Cx";function n8(){let t={};return Bg.forEach((e,i)=>{t[`.cm-line.cm-md-h${i+1}`]={fontSize:`${e}em`,fontWeight:"700",lineHeight:`${DQ} !important`},t[`.cm-line.cm-md-h${i+1} .${jg}`]={fontFamily:"inherit"},t[`.cm-lineNumbers .cm-gutterElement.cm-gutter-h${i+1}`]={lineHeight:`calc(${bQ(i+1)} + 2 * var(--md-line-pad-y, 2px))`},t[`.cm-ai-gutter .cm-gutterElement.cm-gutter-h${i+1}`]={"--md-gutter-line-height":bQ(i+1)}}),t}var r8=T.theme({"&":{height:"100%",color:"var(--text)",backgroundColor:"var(--bg)",fontSize:`${So}px`},".cm-foldGutter":{display:"none !important"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"var(--md-editor-font-family, var(--finch-font-mono))",overflowX:"hidden",overflowY:"auto"},".cm-content":{padding:"var(--md-focus-pad-y, 48px) 0",caretColor:"var(--text)",minHeight:"100%",minWidth:"0",position:"relative"},".cm-content:not(.tbl-table-widget .cm-content)":{boxSizing:"border-box",paddingInline:Cg,width:`calc(${e8} + 2 * ${Cg})`,maxWidth:`calc(${t8} + 2 * ${Cg})`,marginInline:"auto",flexGrow:"0",flexShrink:"1"},".cm-content:not(.tbl-table-widget .cm-content)::before":{content:'""',position:"absolute",top:"0",bottom:"0",left:"-100%",right:"-100%"},".cm-line:not(.tbl-table-widget .cm-line)":{boxSizing:"border-box",position:"relative",width:"100%",paddingTop:"var(--md-line-pad-y, 2px)",paddingBottom:"var(--md-line-pad-y, 2px)",lineHeight:`calc(var(--md-line-ratio, ${zf.compact}) * 1em)`},".cm-content > .cm-line:has(+ .tbl-table-widget)":{height:"0 !important",minHeight:"0 !important",paddingTop:"0 !important",paddingBottom:"0 !important",lineHeight:"0 !important",overflow:"hidden"},".cm-content > .tbl-table-widget":{boxSizing:"border-box",width:"auto !important",maxWidth:"100% !important",marginInline:"auto !important",padding:"12px 16px 12px 6px !important"},".tbl-table-widget .tbl-table-wrapper":{maxWidth:"100%"},".tbl-table-widget .tbl-table":{width:"auto !important",maxWidth:"100%"},".tbl-cell-editor .cm-editor .cm-line":{fontSize:"0.9rem",fontFamily:"var(--md-editor-font-family, var(--finch-font-mono))"},".tbl-cell-view":{fontSize:"0.9rem",fontFamily:"var(--md-editor-font-family, var(--finch-font-mono))"},".tbl-cell:has(> .tbl-cell-view[data-md-preview]) > .tbl-cell-view:not([data-md-preview])":{display:"none"},".tbl-cell:has(.tbl-cell-editor) > .tbl-cell-view[data-md-preview]":{display:"none"},".tbl-table-widget .tbl-cell[data-selected]":{backgroundColor:"color-mix(in srgb, var(--accent) 15%, var(--tbl-row-background))"},".tbl-table-widget .tbl-cell[data-outline]::after":{backgroundColor:"color-mix(in srgb, var(--accent) 7%, transparent)"},...n8(),".cm-md-bullet":{display:"inline-block",color:"var(--accent)",fontWeight:"700",textAlign:"center",fontFamily:"monospace"},[`.${jg}`]:{fontFamily:"monospace"},".tbl-cell-view .cm-md-delimiter":{display:"none"},".tbl-cell-view .cm-md-strong":{fontWeight:"700"},".tbl-cell-view .cm-md-emphasis":{fontStyle:"italic"},".tbl-table-widget .tbl-table-head .tbl-cell-view, .tbl-table-widget .tbl-table-head .tbl-cell-editor .cm-content":{color:"var(--accent)"},".cm-md-inline-code":{padding:"0.08em 0.32em",borderRadius:"5px",color:"var(--text)",backgroundColor:"color-mix(in srgb, var(--text) 9%, transparent)",fontFamily:"var(--finch-font-mono)",fontSize:"0.8em",position:"relative",top:"-0.1em"},".cm-md-mark":{backgroundColor:"color-mix(in srgb, #ffd60a 40%, transparent)",borderRadius:"3px",padding:"0 0.12em",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone"},".cm-md-image-wrapper":{boxSizing:"border-box",display:"inline-flex",flexDirection:"column",maxWidth:"100%",margin:"4px 2px",lineHeight:"1.4",verticalAlign:"bottom",outline:"none"},".cm-editor:has(.cm-md-image-selected) .cm-cursor":{display:"none !important"},".cm-md-image-wrapper.cm-md-image-selected img":{outline:"2px solid var(--accent)",outlineOffset:"2px",borderRadius:"10px"},".cm-md-image-frame":{position:"relative",display:"inline-block",width:"fit-content",maxWidth:"100%",alignSelf:"flex-start",lineHeight:"0"},".cm-md-image-wrapper img":{display:"block",maxHeight:"80vh",maxWidth:"100%",width:"auto",height:"auto",borderRadius:"8px",cursor:"zoom-in"},".cm-md-image-resize-handle":{position:"absolute",right:"6px",bottom:"6px",width:"12px",height:"12px",boxSizing:"border-box",borderRight:"1.75px solid var(--accent)",borderBottom:"1.75px solid var(--accent)",borderRadius:"0 0 4px 0",cursor:"nwse-resize",touchAction:"none",opacity:"0",pointerEvents:"none",transition:"opacity 120ms ease"},".cm-md-image-selected .cm-md-image-resize-handle, .cm-md-image-resizing .cm-md-image-resize-handle":{opacity:"1",pointerEvents:"auto"},".cm-md-image-resizing":{userSelect:"none"},".cm-md-image-caption":{display:"block",marginTop:"6px",fontSize:"0.82em",lineHeight:"1.4",color:"color-mix(in srgb, var(--muted) 80%, transparent)",outline:"none",cursor:"text",whiteSpace:"pre-wrap",wordBreak:"break-word"},".cm-md-image-caption:empty::before":{content:"attr(data-placeholder)",color:"color-mix(in srgb, var(--muted) 80%, transparent)"},".cm-md-image-caption:not(:empty)":{color:"var(--text)"},".cm-md-link":{color:"var(--accent) !important",textDecoration:"underline",textDecorationColor:"color-mix(in srgb, var(--accent) 55%, transparent)",textUnderlineOffset:"0.16em",cursor:"pointer"},".cm-md-link:hover":{textDecorationColor:"var(--accent)"},".cm-line.cm-md-quote":{borderLeft:"2px solid var(--border)",paddingLeft:"8px"},[`.cm-line.cm-md-quote .${jg}`]:{fontFamily:"inherit"},".cm-line.cm-md-list-line":{paddingLeft:"2ch"},".cm-line.cm-md-code-line":{color:"var(--text)",backgroundColor:"color-mix(in srgb, var(--text) 4%, transparent)",lineHeight:Cf(Pf)+" !important",fontFamily:"var(--finch-font-mono)",paddingTop:"0 !important",paddingBottom:"0 !important",width:"99% !important",paddingInline:"24px","--cm-ai-hint-inline-offset":"26px",fontSize:`${WQ}em !important`,marginInline:"auto"},".cm-line.cm-md-code-open":{borderRadius:"8px 8px 0 0",height:Cf(gQ),paddingTop:"2px",paddingInline:"12px",lineHeight:Cf(Tf)+" !important"},".cm-line.cm-md-code-close":{borderRadius:"0 0 8px 8px",height:Cf(gQ),paddingInline:"12px"},".cm-md-code-fence-empty":{opacity:"0"},".cm-md-code-copy":{float:"right",height:"16px",margin:"3px -9px",padding:"0 4px",border:"0px",borderRadius:"6px",color:"var(--muted)",backgroundColor:"color-mix(in srgb, var(--card) 88%, transparent)",font:"10px var(--finch-font-mono)",cursor:"pointer"},".cm-md-code-copy:hover":{color:"var(--text)",backgroundColor:"var(--card)"},".cm-md-hr":{display:"inline-block",width:"100%",height:"1px",verticalAlign:"middle",backgroundColor:"var(--border)",cursor:"text"},".cm-line.cm-md-gap":{},".cm-line.cm-md-gap-heading":{},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--text)"},".cm-gutters":{color:"var(--muted)",backgroundColor:"var(--bg)",borderRight:"0px",fontSize:`${12/So}em`,"--md-gutter-line-height":`calc(var(--md-line-ratio, ${zf.compact}) * 1em / ${qQ})`},".cm-content .cm-widgetBuffer":{verticalAlign:"top"},".cm-gutterElement":{padding:"0px 8px 0 10px"},".cm-lineNumbers .cm-gutterElement":{padding:"0 5px 0 8px",lineHeight:"calc(var(--md-gutter-line-height, 32px) + 2 * var(--md-line-pad-y, 2px))",color:"color-mix(in srgb, var(--muted) 35%, transparent)",fontFamily:"var(--finch-font-mono)",fontSize:"inherit"},".cm-lineNumbers .cm-gutterElement.cm-gutter-code-line":{lineHeight:yo(Pf)},".cm-lineNumbers .cm-gutterElement.cm-gutter-code-open":{lineHeight:yo(Tf)},".cm-gutters .cm-ai-gutter":{width:"22px"},".cm-ai-gutter .cm-gutterElement":{position:"relative",padding:"0","--md-ai-row-height":"calc(var(--md-gutter-line-height, 32px) + 2 * var(--md-line-pad-y, 2px))",color:"var(--accent)"},".cm-ai-gutter .cm-gutterElement.cm-gutter-code-line":{"--md-gutter-line-height":yo(Pf),"--md-ai-row-height":yo(Pf)},".cm-ai-gutter .cm-gutterElement.cm-gutter-code-open":{"--md-gutter-line-height":yo(Tf),"--md-ai-row-height":yo(Tf)},".cm-ai-working-mark":{position:"absolute",inset:"0"},".cm-ai-working-spinner":{position:"absolute",top:"0",left:"0",right:"0",height:"var(--md-ai-row-height, 32px)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},".cm-ai-working-spinner:hover svg":{animation:"none"},".cm-ai-working-spinner:focus-visible":{outline:"1px solid var(--accent)",outlineOffset:"-1px",borderRadius:"3px"},".cm-ai-gutter svg":{width:"13px",height:"13px",animation:"cm-ai-spin 1s linear infinite"},".cm-ai-added-line":{position:"absolute",top:"0",left:"0",right:"0",height:"var(--md-ai-row-height, 32px)",display:"flex",justifyContent:"center"},".cm-ai-added-dot":{width:"6px",height:"6px",marginTop:"calc((var(--md-ai-row-height, 32px) - 6px) / 2 - 1px)",borderRadius:"50%",backgroundColor:"#35a854",boxShadow:"0 0 0 2px color-mix(in srgb, #35a854 16%, transparent)"},".cm-ai-working-rail":{position:"absolute",top:"0",bottom:"0",left:"50%",width:"1.5px",marginLeft:"-0.75px",borderRadius:"1px",backgroundColor:"var(--accent)",opacity:"0.45"},".cm-ai-working-rail.cm-ai-working-rail-below":{top:"calc(var(--md-ai-row-height, 32px) / 2 + 6.5px)"},".cm-ai-working-corner":{position:"absolute",top:"0",left:"50%",width:"6px",height:"calc(var(--md-ai-row-height, 32px) / 2)",marginLeft:"-0.75px",borderLeft:"1.5px solid var(--accent)",borderBottom:"1.5px solid var(--accent)",borderBottomLeftRadius:"5px",opacity:"0.45"},".cm-ai-hint-line::after":{content:'var(--cm-ai-hint, "")',color:"var(--muted)",opacity:"0.5",pointerEvents:"none",userSelect:"none",position:"absolute",top:"0",bottom:"0",left:"var(--cm-ai-hint-inline-offset, 10px)",display:"flex",alignItems:"center",whiteSpace:"nowrap",wordBreak:"keep-all",overflowWrap:"normal"},".cm-ai-hint-code-line::after":{content:'var(--cm-ai-hint-code, "")'},".cm-activeLine":{backgroundColor:"color-mix(in srgb, var(--text) 4%, transparent)",boxShadow:["-25vw 0 color-mix(in srgb, var(--text) 4%, transparent)","25vw 0 color-mix(in srgb, var(--text) 4%, transparent)"].join(", ")},".cm-activeLineGutter":{color:"var(--text) !important",backgroundColor:"color-mix(in srgb, var(--text) 4%, transparent)"},".cm-line:not(.cm-activeLine)":{opacity:"var(--md-focus-opacity, 1)"},".tbl-table-widget .tbl-cell":{opacity:"var(--md-focus-opacity, 1)"},".tbl-table-widget .tbl-cell[data-selected], .tbl-table-widget .tbl-cell[data-selected] .cm-line":{opacity:"1"},"& .cm-content ::selection, & .cm-content::selection":{backgroundColor:"transparent"},"& .cm-content ::-moz-selection, & .cm-content::-moz-selection":{backgroundColor:"transparent"},"& .cm-content .cm-md-selection":{backgroundColor:"color-mix(in srgb, var(--accent) 24%, transparent)",borderRadius:"4px",whiteSpace:"pre-wrap"},".cm-panels":{color:"var(--text)",backgroundColor:"var(--card)",borderTop:"none"},".cm-panel.cm-search":{padding:"6px 30px 7px 8px",fontSize:"12px",color:"var(--text)",backgroundColor:"var(--card)",borderBottom:"1px solid var(--border)",boxShadow:"0 2px 10px rgba(0,0,0,.14)"},".cm-panel.cm-search .cm-textfield":{width:"140px",marginRight:"6px",padding:"3px 7px",border:"1px solid var(--border)",borderRadius:"6px",backgroundColor:"var(--bg)",color:"var(--text)",fontFamily:"var(--finch-font-mono, monospace)",fontSize:"12px",outline:"none",transition:"border-color .12s ease, box-shadow .12s ease"},".cm-panel.cm-search .cm-textfield:focus":{borderColor:"var(--accent)",boxShadow:"0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent)"},".cm-panel.cm-search .cm-textfield::placeholder":{color:"color-mix(in srgb, var(--muted) 65%, transparent)"},".cm-panel.cm-search .cm-button":{marginRight:"4px",padding:"3px 9px",border:"1px solid var(--border)",borderRadius:"6px",backgroundImage:"none",backgroundColor:"color-mix(in srgb, var(--text) 4%, transparent)",color:"var(--text)",fontSize:"12px",fontWeight:"500",cursor:"pointer",transition:"background-color .12s ease, border-color .12s ease"},".cm-panel.cm-search .cm-button:hover":{backgroundImage:"none",backgroundColor:"color-mix(in srgb, var(--text) 9%, transparent)",borderColor:"color-mix(in srgb, var(--text) 22%, transparent)"},".cm-panel.cm-search .cm-button:active":{backgroundImage:"none",backgroundColor:"color-mix(in srgb, var(--accent) 18%, transparent)",borderColor:"var(--accent)"},".cm-panel.cm-search label":{display:"inline-flex",alignItems:"center",gap:"4px",marginRight:"10px",color:"var(--muted)",fontSize:"11.5px",whiteSpace:"nowrap",cursor:"pointer"},".cm-panel.cm-search input[type=checkbox]":{width:"13px",height:"13px",margin:"0",accentColor:"var(--accent)",cursor:"pointer"},".cm-panel.cm-search [name=close]":{position:"absolute",top:"5px",right:"6px",width:"20px",height:"20px",lineHeight:"1",padding:"0",border:"1px solid transparent",borderRadius:"5px",backgroundColor:"transparent",color:"var(--muted)",fontSize:"15px",cursor:"pointer"},".cm-panel.cm-search [name=close]:hover":{color:"var(--text)",backgroundColor:"color-mix(in srgb, var(--text) 8%, transparent)",borderColor:"var(--border)"},".cm-editor .cm-content .cm-searchMatch":{backgroundColor:"color-mix(in srgb, var(--accent) 26%, transparent)",outline:"1px solid color-mix(in srgb, var(--accent) 38%, transparent)",borderRadius:"2px"},".cm-editor .cm-content .cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"color-mix(in srgb, var(--accent) 48%, transparent)",outline:"1px solid var(--accent)"},".cm-tooltip":{color:"var(--text)",backgroundColor:"var(--card)",border:"1px solid var(--border)"},".cm-tooltip.cm-tooltip-autocomplete":{borderRadius:"10px",padding:"5px",boxShadow:"0 2px 8px rgba(0,0,0,.12)",overflow:"hidden"},".cm-tooltip.cm-tooltip-autocomplete > ul":{minWidth:"188px",fontFamily:"var(--finch-font-body, system-ui)",fontSize:"13px"},".cm-tooltip.cm-tooltip-autocomplete > ul > li":{display:"flex",alignItems:"center",gap:"0",padding:"4px 7px",borderRadius:"6px"},".cm-tooltip-autocomplete > ul > li[aria-selected]":{color:"var(--text)",backgroundColor:"var(--finch-bg-active, color-mix(in srgb, var(--text) 10%, transparent))"},".cm-tooltip-autocomplete .cm-completionLabel":{flex:"1"},".cm-tooltip-autocomplete .cm-completionDetail":{marginLeft:"auto",color:"var(--muted)",fontStyle:"normal",fontSize:"0.86em"},".cm-tooltip-autocomplete .cm-md-completion-icon":{flex:"none",width:"16px",height:"16px",paddingRight:"8px",boxSizing:"content-box",color:"var(--muted)",opacity:"0.82"}}),o8=[ve.of({name:"JavaScript",alias:["js","mjs","cjs"],extensions:["js","mjs","cjs"],support:Nr()}),ve.of({name:"JSX",alias:["jsx"],extensions:["jsx"],support:Nr({jsx:!0})}),ve.of({name:"TypeScript",alias:["ts"],extensions:["ts"],support:Nr({typescript:!0})}),ve.of({name:"TSX",alias:["tsx"],extensions:["tsx"],support:Nr({jsx:!0,typescript:!0})}),ve.of({name:"JSON",alias:["json","json5"],extensions:["json","json5"],support:ZS()}),ve.of({name:"Mermaid",alias:["mermaid","mmd"],extensions:["mermaid","mmd"],support:cm()}),ve.of({name:"Infographic",alias:["infographic"],extensions:["infographic"],support:new de(ix)}),ve.of({name:"CSS",alias:["css"],extensions:["css"],support:mh()}),ve.of({name:"HTML",alias:["html","htm","xml","svg"],extensions:["html"],support:$h()}),ve.of({name:"Python",alias:["python","py"],extensions:["py"],support:e1()}),ve.of({name:"SQL",alias:["sql"],extensions:["sql"],support:m1()}),ve.of({name:"YAML",alias:["yaml","yml"],extensions:["yaml","yml"],support:E1()}),ve.of({name:"Shell",alias:["bash","sh","shell","zsh","console"],extensions:["sh"],support:new de(Ho.define(lx))})],yQ=No.define([{tag:p.heading,color:"var(--accent)",fontWeight:"700"},{tag:p.strong,color:"var(--text)",fontWeight:"700"},{tag:p.emphasis,fontStyle:"italic"},{tag:p.strikethrough,color:"var(--muted)",textDecoration:"line-through"},{tag:p.monospace,color:"var(--muted)"},{tag:p.link,color:"var(--accent)"},{tag:p.url,color:"var(--muted)",textDecoration:"underline"},{tag:p.quote,color:"var(--muted)"},{tag:p.meta,color:"var(--muted)"},{tag:p.keyword,color:"#c678dd"},{tag:[p.name,p.deleted,p.character,p.propertyName,p.macroName],color:"#e06c75"},{tag:[p.function(p.variableName),p.labelName],color:"#61afef"},{tag:[p.color,p.constant(p.name),p.standard(p.name),p.bool],color:"#d19a66"},{tag:[p.definition(p.name),p.separator],color:"var(--text)"},{tag:[p.typeName,p.className,p.number,p.changed,p.annotation,p.modifier,p.self,p.namespace],color:"#d3b070"},{tag:[p.operator,p.operatorKeyword,p.escape,p.regexp,p.special(p.string),p.contentSeparator],color:"#56b6c2"},{tag:p.string,color:"#88b06a"},{tag:p.variableName,color:"#61afef"},{tag:p.controlKeyword,color:"#c678dd"},{tag:p.comment,color:"var(--muted)",fontStyle:"italic"},{tag:p.invalid,color:"#fff",backgroundColor:"#e06c75"}]),Zg=/^(#{1,6})(?:\s|$)/;function SQ(t){let e=new Ue,i=t.state.doc;for(let n=1;n<=i.lines;n++){let r=i.line(n),o=r.text,s=Zg.exec(o),l=o.trim().length===0,a;if(s)a=`cm-md-h${s[1].length}`;else if(l&&n<i.lines){let c=i.line(n+1).text;c.trim().length>0&&(a=Zg.test(c)?"cm-md-gap-heading":"cm-md-gap")}a&&e.add(r.from,r.from,E.line({class:a}))}return e.finish()}var s8=fe.fromClass(class{decorations;constructor(t){this.decorations=SQ(t)}update(t){(t.docChanged||t.viewportChanged)&&(this.decorations=SQ(t.view))}},{decorations:t=>t.decorations}),xQ=/`([^`\n]+)`/g,vQ=/==(?=\S)(.+?)(?<=\S)==/g,xo=/^\s*```+\s*([^\s`]*)?\s*$/;function XQ(t,e){let i=!1;for(let n=1;n<e;n++)xo.test(t.line(n).text)&&(i=!i);return i}var AQ=/^\s{0,3}(?:(?:-\s*){3,}|(?:\*\s*){3,}|(?:_\s*){3,})$/,l8=/^(\s*)([-+*])(?=\s+)/,a8=/^(\s*>\s?)/,oi=E.replace({}),c8=E.mark({class:"cm-md-inline-code"}),h8=E.mark({class:"cm-md-mark"});function Rg(t){let e=t.trim();return/^https?:\/\//i.test(e)?e:null}function Eg(t){return E.mark({class:"cm-md-link",attributes:{"data-md-href":t,role:"link",title:t}})}var Rf=48;function Ig(t){let e=/^(.*)\|(\d+)(?:x\d+)?$/.exec(t);if(!e)return{caption:t,width:null};let i=Number(e[2]);return{caption:e[1],width:Number.isFinite(i)&&i>0?Math.round(i):null}}function $a(t,e){t.style.width=e?`${e}px`:"auto",t.style.height="auto"}function f8(t,e){if(typeof ResizeObserver>"u")return;let i=0,n=0,r=new ResizeObserver(o=>{let s=o[0]?.contentRect;if(s&&!(Math.abs(s.width-i)<2&&Math.abs(s.height-n)<2)){i=s.width,n=s.height;try{t.requestMeasure()}catch{}}});r.observe(e),e.__finchImageResizeObserver=r}function u8(t,e,i,n){let r;try{r=t.contentDOM.querySelectorAll("img[data-md-image-src]")}catch{return null}for(let o of r){if(o.dataset.mdImageSrc!==e)continue;let s=o.closest(".cm-md-image-wrapper");if(!(s&&(s.dataset.mdAlt!==i||(s.dataset.mdWidth??"")!==(n==null?"":String(n))))&&!(!o.complete||o.naturalWidth===0)&&!o.__finchImageClaimed)return o.__finchImageClaimed=!0,queueMicrotask(()=>{delete o.__finchImageClaimed}),o.remove(),o}return null}var Yg=class extends Me{constructor(i,n,r){super();this.src=i;this.alt=n;this.width=r}src;alt;width;captionEl=null;eq(i){return i.src===this.src&&i.alt===this.alt&&i.width===this.width}ignoreEvent(i){return!!(this.captionEl&&i.target instanceof Node&&this.captionEl.contains(i.target))}toDOM(i){let n=document.createElement("span");n.className="cm-md-image-wrapper",n.tabIndex=-1,n.setAttribute("aria-selected","false"),n.addEventListener("keydown",c=>{if(c.key==="Backspace"||c.key==="Delete"){c.preventDefault(),c.stopPropagation(),Dg(i);return}c.key!=="ArrowLeft"&&c.key!=="ArrowRight"||(c.preventDefault(),c.stopPropagation(),p8(i,n,c.key==="ArrowLeft"?-1:1))}),n.dataset.mdSrc=this.src,n.dataset.mdAlt=this.alt,this.width!=null&&(n.dataset.mdWidth=String(this.width));let r=document.createElement("span");r.className="cm-md-image-frame";let o=u8(i,this.src,this.alt,this.width)??document.createElement("img");o.dataset.mdImageSrc||(o.src=this.src,o.dataset.mdImageSrc=this.src),o.alt=this.alt,o.title=this.alt||this.src,$a(o,this.width),r.appendChild(o);let s=document.createElement("span");s.className="cm-md-image-resize-handle",s.setAttribute("role","separator"),s.setAttribute("aria-label","Resize image width"),s.title="\u62D6\u52A8\u8C03\u6574\u56FE\u7247\u5BBD\u5EA6",s.addEventListener("pointerdown",c=>{d8(i,n,o,s,c,this.width)}),r.appendChild(s),n.appendChild(r);let l=document.createElement("span");l.className="cm-md-image-caption",l.contentEditable="plaintext-only",l.contentEditable!=="plaintext-only"&&(l.contentEditable="true"),l.spellcheck=!1,l.dataset.placeholder="\u6DFB\u52A0\u56FE\u7247\u8BF4\u660E\u2026",l.textContent=this.alt,l.addEventListener("paste",c=>{c.preventDefault();let h=c.clipboardData?.getData("text/plain")??"";document.execCommand("insertText",!1,h.replace(/[\r\n]+/g," "))});let a=0;return l.addEventListener("compositionend",()=>{a=Date.now()}),l.addEventListener("keydown",c=>{if(c.stopPropagation(),c.key==="Enter"){if(c.isComposing||c.keyCode===229||Date.now()-a<100)return;c.preventDefault(),l.blur()}else c.key==="Escape"&&(c.preventDefault(),l.textContent=this.alt,l.blur())}),l.addEventListener("input",()=>{l.textContent||l.replaceChildren()}),l.addEventListener("blur",()=>m8(i,n,this.alt,l.textContent??"")),n.appendChild(l),this.captionEl=l,f8(i,n),n}destroy(i){let n=i.__finchImageResizeObserver;n&&(n.disconnect(),delete i.__finchImageResizeObserver)}updateDOM(i,n,r){if(r.src!==this.src||r.alt!==this.alt)return!1;let o=i.querySelector("img[data-md-image-src]");if(!o)return!1;if($a(o,this.width),r.width!==this.width)try{n.requestMeasure()}catch{}return this.captionEl=i.querySelector(".cm-md-image-caption"),!0}};function ga(t,e){let i=null;return V(t).iterate({enter:n=>{if(n.name==="Image")return!i&&e(n.from,n.to)&&(i={from:n.from,to:n.to}),!1}}),i}function Df(t){return Math.min(t.from+1,t.to)}function _f(t){let e=t.selection.main;return e.empty?ga(t,(i,n)=>i<e.head&&e.head<n):null}function qf(t,e){let i=t.selection.main;return i.empty&&i.head===Df(e)}function Es(t,e){let i=e.parentNode;if(!i)return null;let n=Array.prototype.indexOf.call(i.childNodes,e);if(n<0)return null;try{let r=t.posAtDOM(i,n),o=t.posAtDOM(i,n+1),s=Math.min(r,o),l=Math.max(r,o);return ga(t.state,(a,c)=>a===s&&c===l)??ga(t.state,a=>a===r)??ga(t.state,(a,c)=>c===o)??_f(t.state)}catch{return _f(t.state)}}function d8(t,e,i,n,r,o){if(r.button!==0)return;r.preventDefault(),r.stopPropagation();let s=Es(t,e);s&&!qf(t.state,s)&&t.dispatch({selection:{anchor:Df(s)}});let l=r.clientX,a=i.getBoundingClientRect().width,c=e.closest(".cm-line")?.getBoundingClientRect().width??a,h=Math.max(Rf,Math.floor(c)),f=Math.max(Rf,Math.round(a));e.classList.add("cm-md-image-resizing"),n.setPointerCapture(r.pointerId);let u=()=>{e.classList.remove("cm-md-image-resizing"),n.removeEventListener("pointermove",d),n.removeEventListener("pointerup",O),n.removeEventListener("pointercancel",m),n.hasPointerCapture(r.pointerId)&&n.releasePointerCapture(r.pointerId)},d=g=>{if(g.pointerId!==r.pointerId)return;g.preventDefault();let $=Math.round(a+g.clientX-l);f=Math.max(Rf,Math.min(h,$)),$a(i,f),n.setAttribute("aria-valuenow",String(f))},O=g=>{g.pointerId===r.pointerId&&(g.preventDefault(),u(),g8(t,e,f))},m=g=>{g.pointerId===r.pointerId&&(u(),$a(i,o))};n.addEventListener("pointermove",d),n.addEventListener("pointerup",O),n.addEventListener("pointercancel",m)}function O8(t){!t.isConnected||!t.classList.contains("cm-md-image-selected")||t.focus({preventScroll:!0})}function p8(t,e,i){let n=Es(t,e);n&&(t.dispatch({selection:{anchor:i<0?n.from:n.to},scrollIntoView:!0}),t.focus())}function jf(t,e){let i=t.state.selection.main;if(!i.empty)return!1;let n=ga(t.state,e>0?r=>r===i.head:(r,o)=>o===i.head);return n?(t.dispatch({selection:{anchor:Df(n)},scrollIntoView:!0}),!0):!1}function m8(t,e,i,n){if(n===i)return;let r=Es(t,e);if(!r)return;let o=t.state.sliceDoc(r.from,r.to),s=/^!\[([^\]]*)\](\([^)]*\))/.exec(o);if(!s)return;let l=Ig(s[1]),a=l.width?`|${l.width}`:"";t.dispatch({changes:{from:r.from,to:r.to,insert:`![${n}${a}]${s[2]}`}})}function g8(t,e,i){let n=Es(t,e);if(!n)return;let r=t.state.sliceDoc(n.from,n.to),o=/^!\[([^\]]*)\](\([^)]*\))/.exec(r);if(!o)return;let s=Ig(o[1]),l=Math.max(Rf,Math.round(i));s.width!==l&&t.dispatch({changes:{from:n.from,to:n.to,insert:`![${s.caption}|${l}]${o[2]}`}})}function QQ(t){let e=[];return V(t).iterate({enter:i=>{if(i.name!=="Image")return;let n=i.node.getChild("URL");if(!n)return!1;let r=t.sliceDoc(i.from,i.to),o=/^!\[([^\]]*)\]/.exec(r)?.[1]??"",s=Ig(o),l=t.sliceDoc(n.from,n.to).trim();if(!l)return!1;let a={from:i.from,to:i.to};return e.push(E.replace({widget:new Yg(l,s.caption,s.width)}).range(a.from,a.to)),!1}}),E.set(e,!0)}var Ug=ce.define({create:QQ,update(t,e){return e.docChanged?QQ(e.state):t},provide:t=>T.decorations.from(t)}),$8=E.mark({class:"cm-md-selection"}),kQ=fe.fromClass(class{decorations;constructor(t){this.decorations=this.compute(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.compute(t.view))}compute(t){let{state:e}=t,i=e.selection.ranges,n=null;for(let r of i)r.from>=r.to||(n||(n=new Ue),n.add(r.from,r.to,$8));return n?n.finish():E.none}},{decorations:t=>t.decorations}),w8=fe.fromClass(class{constructor(t){this.sync(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&this.sync(t.view)}docViewUpdate(t){this.sync(t)}heal(t){for(let e of t.contentDOM.querySelectorAll(".cm-md-image-wrapper")){let i=e.querySelector(".cm-md-image-frame");if(!i||i.querySelector("img[data-md-image-src]"))continue;let n=e.dataset.mdSrc;if(!n)continue;let r=document.createElement("img");r.src=n,r.dataset.mdImageSrc=n,r.alt=e.dataset.mdAlt??"",r.title=r.alt||n;let o=e.dataset.mdWidth;$a(r,o?Number(o):null),i.insertBefore(r,i.firstChild)}}sync(t){this.heal(t);let e=_f(t.state),i=e&&qf(t.state,e)?e:null;for(let n of t.contentDOM.querySelectorAll(".cm-md-image-wrapper")){let r=i?Es(t,n):null,o=!!i&&!!r&&r.from===i.from&&r.to===i.to;n.classList.contains("cm-md-image-selected")!==o&&(n.classList.toggle("cm-md-image-selected",o),n.setAttribute("aria-selected",o?"true":"false"),o&&O8(n))}}}),b8=T.atomicRanges.of(t=>t.state.field(Ug));function y8(t){let e=[],i=[],n=V(t.state);return n.iterate({enter:r=>{r.name==="URL"&&i.push({from:r.from,to:r.to})}}),n.iterate({enter:r=>{if(r.name==="Table"||r.name==="Image")return!1;if(r.name==="Link"){let o=r.node.getChild("URL"),s=r.node.getChildren("LinkMark");if(!o||s.length<4||Rs(t,r.from,r.to))return!1;let l=Rg(t.state.sliceDoc(o.from,o.to)),a=s[0],c=s[1];return!l||a.to>=c.from||(e.push(oi.range(a.from,a.to)),e.push(Eg(l).range(a.to,c.from)),e.push(oi.range(c.from,r.to))),!1}if(r.name==="Autolink"){let o=r.node.getChild("URL"),s=r.node.getChildren("LinkMark");if(!o||s.length<2||Rs(t,r.from,r.to))return!1;let l=Rg(t.state.sliceDoc(o.from,o.to));return l&&(e.push(oi.range(s[0].from,s[0].to)),e.push(Eg(l).range(o.from,o.to)),e.push(oi.range(s[s.length-1].from,s[s.length-1].to))),!1}if(r.name==="URL"){if(Rs(t,r.from,r.to))return;let o=Rg(t.state.sliceDoc(r.from,r.to));o&&e.push(Eg(o).range(r.from,r.to))}}}),{decorations:e,urlRanges:i}}function S8(t){let e=[];return V(t.state).iterate({enter:i=>{if(i.name==="Table"||i.name==="Image")return!1;let n=i.name==="Strikethrough"?"StrikethroughMark":i.name==="Emphasis"||i.name==="StrongEmphasis"?"EmphasisMark":void 0;if(n){if(Rs(t,i.from,i.to))return!1;for(let r of i.node.getChildren(n))e.push(oi.range(r.from,r.to))}}}),e}function zg(t,e,i){return i.some(n=>t<n.to&&e>n.from)}function LQ(t){return t.button!==0||!(t.target instanceof Element)?null:t.target.closest(".cm-md-link[data-md-href]")}function x8(t){return LQ(t)?(t.preventDefault(),t.stopPropagation(),!0):!1}function v8(t,e){let i=LQ(t)?.dataset.mdHref;return i?(t.preventDefault(),t.stopPropagation(),e?.(i),!0):!1}function GQ(t){return t.button!==0||!(t.target instanceof Element)?null:t.target.closest(".cm-md-image-wrapper img[data-md-image-src]")}function Q8(t){return GQ(t)?(t.preventDefault(),t.stopPropagation(),!0):!1}function k8(t,e){let i=e.closest(".cm-md-image-wrapper");return i?Es(t,i):null}function P8(t,e,i){let n=GQ(e),r=n?.dataset.mdImageSrc;if(!n||!r)return!1;e.preventDefault(),e.stopPropagation();let o=k8(t,n);return o&&qf(t.state,o)?(i?.(r),!0):(o&&t.dispatch({selection:{anchor:Df(o)},scrollIntoView:!0}),!0)}function Dg(t){if(!t.state.selection.main.empty)return!1;let i=_f(t.state);return!i||!qf(t.state,i)?!1:(t.dispatch({changes:{from:i.from,to:i.to},selection:{anchor:i.from}}),t.focus(),!0)}var wa=class extends it{constructor(i){super();this.elementClass=i}elementClass},T8=new wa("cm-gutter-code-line"),C8=new wa("cm-gutter-code-line cm-gutter-code-open"),R8=Bg.map((t,e)=>new wa(`cm-gutter-h${e+1}`));function PQ(t){let e=new Ue,i=!1;for(let n=1;n<=t.lines;n++){let r=t.line(n),o=xo.test(r.text);if(o||i){let s=o&&!i;e.add(r.from,r.from,s?C8:T8)}else{let s=Zg.exec(r.text);s&&e.add(r.from,r.from,R8[s[1].length-1])}o&&(i=!i)}return e.finish()}var TQ=ce.define({create:t=>PQ(t.doc),update:(t,e)=>e.docChanged?PQ(e.state.doc):t}),E8=[TQ,Do.from(TQ)];function Vg(){let t=document.createElement("span");return t.className="cm-ai-working-mark",t}function MQ(t){let e=document.createElement("span");return e.className=t?`cm-ai-working-rail ${t}`:"cm-ai-working-rail",e}var Zf=class extends it{constructor(i){super();this.hasMore=i}hasMore;elementClass="cm-ai-working cm-ai-working-start";toDOM(){let i=Vg(),n=document.createElement("span");n.className="cm-ai-working-spinner",n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.setAttribute("aria-label","Stop rewrite"),n.title="Stop rewrite";let r=s=>{n.innerHTML=s?'<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10" stroke-opacity="0.25"/><path d="M12 2a10 10 0 0 1 10 10"/></svg>'};r(!1),n.addEventListener("mouseenter",()=>r(!0)),n.addEventListener("mouseleave",()=>r(!1));let o=s=>{s.preventDefault(),s.stopPropagation(),n.dispatchEvent(new CustomEvent("finch:aiWorkingCancel",{bubbles:!0}))};return n.addEventListener("click",o),n.addEventListener("keydown",s=>{(s.key==="Enter"||s.key===" ")&&o(s)}),i.appendChild(n),this.hasMore&&i.appendChild(MQ("cm-ai-working-rail-below")),i}},qg=class extends it{elementClass="cm-ai-working cm-ai-working-line";toDOM(){let e=Vg();return e.appendChild(MQ()),e}},Wg=class extends it{elementClass="cm-ai-working cm-ai-working-end";toDOM(){let e=Vg(),i=document.createElement("span");return i.className="cm-ai-working-corner",e.appendChild(i),e}},NQ=new Zf(!1),z8=new Zf(!0),_8=new qg,j8=new Wg,Xg=A.define();function Z8(t,e){if(!e)return J.empty;let i=new Ue,n=Math.max(1,Math.min(e.fromLine,t.lines)),r=Math.max(n,Math.min(e.toLine,t.lines));for(let o=n;o<=r;o++){let s=o===n?r>n?z8:NQ:o===r?j8:_8;i.add(t.line(o).from,t.line(o).from,s)}return i.finish()}var HQ=ce.define({create:()=>J.empty,update:(t,e)=>{let i=t.map(e.changes);for(let n of e.effects)n.is(Xg)&&(i=Z8(e.state.doc,n.value));return i}}),Ag=class extends it{elementClass="cm-ai-added-line";toDOM(){let e=document.createElement("span");return e.className="cm-ai-added-dot",e}},Y8=new Ag,BQ=A.define(),IQ=ce.define({create:()=>J.empty,update:(t,e)=>{let i=t.map(e.changes);for(let n of e.effects){if(!n.is(BQ))continue;let r=new Ue;for(let o of n.value)o>=1&&o<=e.state.doc.lines&&r.add(e.state.doc.line(o).from,e.state.doc.line(o).from,Y8);i=r.finish()}if(e.selection){let n=e.state.doc.lineAt(e.selection.main.head).from;i=i.update({filter:r=>r!==n})}return i}}),D8=rl({class:"cm-ai-gutter",markers:t=>J.join([t.state.field(HQ),t.state.field(IQ)]),initialSpacer:()=>NQ}),q8=E.line({class:"cm-ai-hint-line"}),W8=E.line({class:"cm-ai-hint-line cm-ai-hint-code-line"});function UQ(t){let e=t.selection.main;if(!e.empty)return null;let i=t.doc.lineAt(e.head);return i.text.trim()?null:i.number}var X8=fe.fromClass(class{decorations;constructor(t){this.decorations=this.build(t)}update(t){(t.docChanged||t.selectionSet||t.focusChanged||t.viewportChanged)&&(this.decorations=this.build(t.view))}build(t){if(!t.hasFocus)return E.none;let e=UQ(t.state);if(e==null)return E.none;let i=t.state.doc.line(e),n=XQ(t.state.doc,e)?W8:q8;return E.set([n.range(i.from)])}},{decorations:t=>t.decorations}),Lg=class extends Me{eq(){return!0}toDOM(){let e=document.createElement("span");return e.className="cm-md-bullet",e.textContent="\u2022",e.setAttribute("aria-hidden","true"),e}},Gg=class extends Me{constructor(i){super();this.position=i}position;eq(i){return i.position===this.position}toDOM(i){let n=document.createElement("span");return n.className="cm-md-hr",n.title="\u70B9\u51FB\u7F16\u8F91\u5206\u9694\u7EBF",n.addEventListener("mousedown",r=>r.preventDefault()),n.addEventListener("click",()=>{i.dispatch({selection:{anchor:this.position}}),i.focus()}),n}},Mg=class extends Me{constructor(i,n){super();this.language=i;this.code=n}language;code;eq(i){return i.language===this.language&&i.code===this.code}toDOM(){if(!this.language){let n=document.createElement("span");return n.className="cm-md-code-fence-empty",n.textContent="\u200B",n}let i=document.createElement("button");return i.type="button",i.className="cm-md-code-copy",i.textContent=this.language.toUpperCase(),i.title="\u590D\u5236\u4EE3\u7801\u5757",i.addEventListener("mousedown",n=>n.preventDefault()),i.addEventListener("click",async n=>{n.preventDefault(),n.stopPropagation();let r=i.textContent||this.language.toUpperCase();try{await navigator.clipboard.writeText(this.code),i.textContent="\u5DF2\u590D\u5236"}catch{i.textContent="\u590D\u5236\u5931\u8D25"}window.setTimeout(()=>{i.textContent=r},1200)}),i}};function CQ(t,e,i){return t.state.selection.ranges.some(n=>n.empty?n.head>=e&&n.head<=i:n.from<=i&&n.to>=e)}function Rs(t,e,i){let n=t.state.doc.lineAt(e);return t.state.selection.ranges.some(r=>r.empty?r.head>=n.from&&r.head<=n.to&&r.head>=e-1&&r.head<=i+1:r.from<=n.to&&r.to>=n.from&&r.from<=i+1&&r.to>=e-1)}function A8(t){let e=t.state.doc,i=new Map,n=0,r="";for(let o=1;o<=e.lines;o++){let s=e.line(o),l=xo.exec(s.text);if(!n){if(!l)continue;n=o,r=l[1]||"";continue}if(l){let a=Array.from({length:o-n-1},(f,u)=>e.line(n+u+1).text).join(`
|
|
41
41
|
`),c=e.line(n).from,h=s.to;i.set(n,{role:"open",language:r,code:a,blockFrom:c,blockTo:h});for(let f=n+1;f<o;f++)i.set(f,{role:"body",language:r,code:a,blockFrom:c,blockTo:h});i.set(o,{role:"close",language:r,code:a,blockFrom:c,blockTo:h}),n=0,r=""}}if(n){let o=Array.from({length:e.lines-n},(a,c)=>e.line(n+c+1).text).join(`
|
|
42
|
-
`),s=e.line(n).from,l=e.length;i.set(n,{role:"open",language:r,code:o,blockFrom:s,blockTo:l});for(let a=n+1;a<=e.lines;a++)i.set(a,{role:"body",language:r,code:o,blockFrom:s,blockTo:l})}return i}function L8(t){let e=new Set;return V(t.state).iterate({enter:i=>{if(i.name==="Table"){let n=t.state.doc.lineAt(i.from).number,r=t.state.doc.lineAt(i.to).number;for(let o=n;o<=r;o++)e.add(o);return!1}}}),e}function G8(t){let e=null,i=o=>{e||!o?.between||o.between(0,t.state.doc.length,(s,l,a)=>{if(a?.widget?.tableDescription)return e=a.widget,!1})};for(let o of t.state.facet(T.decorations))if(i(typeof o=="function"?o(t):o),e)break;if(!e)return!1;let n=Object.getPrototypeOf(e);if(!n||n.__finchTableHardened)return!0;n.__finchTableHardened=!0;let r=n.destroy;return n.destroy=function(o){o?.isConnected||r?.call(this,o)}
|
|
42
|
+
`),s=e.line(n).from,l=e.length;i.set(n,{role:"open",language:r,code:o,blockFrom:s,blockTo:l});for(let a=n+1;a<=e.lines;a++)i.set(a,{role:"body",language:r,code:o,blockFrom:s,blockTo:l})}return i}function L8(t){let e=new Set;return V(t.state).iterate({enter:i=>{if(i.name==="Table"){let n=t.state.doc.lineAt(i.from).number,r=t.state.doc.lineAt(i.to).number;for(let o=n;o<=r;o++)e.add(o);return!1}}}),e}function G8(t){let e=null,i=o=>{e||!o?.between||o.between(0,t.state.doc.length,(s,l,a)=>{if(a?.widget?.tableDescription)return e=a.widget,!1})};for(let o of t.state.facet(T.decorations))if(i(typeof o=="function"?o(t):o),e)break;if(!e)return!1;let n=Object.getPrototypeOf(e);if(!n||n.__finchTableHardened)return!0;n.__finchTableHardened=!0;let r=n.destroy;return n.destroy=function(o){o?.isConnected||r?.call(this,o)},!0}var M8=fe.fromClass(class{done=!1;constructor(t){this.attempt(t)}update(t){!this.done&&(t.docChanged||t.viewportChanged)&&this.attempt(t.view)}attempt(t){try{this.done=G8(t)}catch{}}});function N8(t){let e=[];return V(t.state).iterate({enter:i=>{if(i.name==="Table")return e.push({from:i.from,to:i.to}),!1}}),e}var Ef="data-md-table-placeholder";function H8(t){let e=t.dom.querySelector(".cm-content");if(!e)return()=>{};let i=[],n=()=>{let s=Array.from(t.dom.querySelectorAll(".tbl-table-widget"));s.forEach((l,a)=>{let c=l.querySelector(".tbl-table-wrapper:not(["+Ef+"] *)"),h=l.querySelector(`[${Ef}]`);if(c){h&&h.remove(),i[a]=c.outerHTML;return}if(h)return;let f=i[a];if(!f)return;let u=document.createElement("div");u.setAttribute(Ef,"true"),u.setAttribute("aria-hidden","true"),u.style.pointerEvents="none",u.innerHTML=f,l.appendChild(u)}),s.length<i.length&&(i=i.slice(0,s.length))},r=0,o=new MutationObserver(()=>{r||(r=window.requestAnimationFrame(()=>{r=0,n()}))});return o.observe(e,{childList:!0,subtree:!0}),n(),()=>{o.disconnect(),r&&window.cancelAnimationFrame(r)}}var RQ=0;function EQ(t){if(!Array.from(t.dom.querySelectorAll(".tbl-table-widget")).some(o=>!o.querySelector(`.tbl-table-wrapper:not([${Ef}] *)`)))return;let n=Date.now();if(n-RQ<1e3)return;RQ=n;let r=N8(t);r.length&&t.dispatch({changes:r.map(({from:o,to:s})=>({from:o,to:s,insert:t.state.doc.sliceString(o,s)})),selection:t.state.selection,scrollIntoView:!1,annotations:[_e.addToHistory.of(!1)]})}function zQ(t,e=!0){let i=[],n=t.state.doc,r=A8(t),o=L8(t),s=e?y8(t):{decorations:[],urlRanges:[]};i.push(...s.decorations,...S8(t));for(let l=1;l<=n.lines;l++){let a=n.line(l);if(o.has(l))continue;let c=CQ(t,a.from,a.to),h=r.get(l);if(h){let m=CQ(t,h.blockFrom,h.blockTo),g=h.role==="open"?" cm-md-code-open":h.role==="close"?" cm-md-code-close":"";if(i.push(E.line({class:`cm-md-code-line${g}`}).range(a.from)),!m&&h.role!=="body"){let $=new Mg(h.role==="open"?h.language:"",h.code);i.push(oi.range(a.from,a.to)),i.push(E.widget({widget:$,side:-1}).range(a.from))}continue}let f=a8.exec(a.text);if(f&&(i.push(E.line({class:"cm-md-quote"}).range(a.from)),c||i.push(oi.range(a.from,a.from+f[0].length))),!c&&AQ.test(a.text)){i.push(oi.range(a.from,a.to)),i.push(E.widget({widget:new Gg(a.from),side:-1}).range(a.from));continue}if(FQ.test(a.text)&&i.push(E.line({class:"cm-md-list-line"}).range(a.from)),!c){let m=l8.exec(a.text);if(m){let $=a.from+m[1].length;i.push(E.replace({widget:new Lg}).range($,$+1))}let g=/^(#{1,6}\s+)/.exec(a.text);g&&i.push(oi.range(a.from,a.from+g[0].length))}xQ.lastIndex=0;let u=[],d;for(;d=xQ.exec(a.text);){let m=a.from+d.index,g=m+d[0].length;zg(m,g,s.urlRanges)||(u.push({from:m,to:g}),i.push(c8.range(m+1,g-1)),Rs(t,m,g)||(i.push(oi.range(m,m+1)),i.push(oi.range(g-1,g))))}vQ.lastIndex=0;let O;for(;O=vQ.exec(a.text);){let m=a.from+O.index,g=m+O[0].length;zg(m,g,u)||zg(m,g,s.urlRanges)||(i.push(h8.range(m+2,g-2)),Rs(t,m,g)||(i.push(oi.range(m,m+2)),i.push(oi.range(g-2,g))))}}return E.set(B8(t,i),!0)}function B8(t,e){let i=[],n=t.state.field(Ug,!1);return!n||(n.between(0,t.state.doc.length,(r,o)=>{i.push({from:r,to:o})}),!i.length)?e:e.filter(r=>!i.some(o=>r.from>=o.from&&r.to<=o.to))}function I8(t){return fe.fromClass(class{decorations;constructor(e){this.decorations=zQ(e,t)}update(e){(e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=zQ(e.view,t))}},{decorations:e=>e.decorations})}var U8=I8(!0);function VQ(t,e,i,n){let r=n??t.state.selection.main;if(!i){let l=new FileReader;l.onload=()=>{let a=typeof l.result=="string"?l.result:"";if(!a)return;let c=``;t.dispatch({changes:{from:r.from,to:r.to,insert:c},selection:{anchor:r.from+c.length}}),t.focus()},l.readAsDataURL(e);return}let o=`.toString(36).slice(2)})`;t.dispatch({changes:{from:r.from,to:r.to,insert:o},selection:{anchor:r.from+o.length}}),t.focus();let s=l=>{let c=t.state.doc.toString().indexOf(o);c<0||t.dispatch({changes:{from:c,to:c+o.length,insert:l}})};i(e).then(l=>s(``),()=>s(""))}function V8(t,e,i){let n=e.clipboardData?.items;if(!n)return!1;for(let r=0;r<n.length;r++){let o=n[r];if(o.kind==="file"&&o.type.indexOf("image/")===0){let s=o.getAsFile();if(s)return e.preventDefault(),VQ(t,s,i),!0}}return!1}function F8(t,e,i){let n=e.dataTransfer?.files;if(!n)return!1;let r=Array.from(n).filter(l=>l.type.indexOf("image/")===0);if(!r.length)return!1;e.preventDefault();let s=t.posAtCoords({x:e.clientX,y:e.clientY})??t.state.selection.main.from;return VQ(t,r[0],i,{from:s,to:s}),!0}var FQ=/^\s*(?:[-+*]|\d+[.)])\s+/;function _Q(t){let e=t.state.doc.lineAt(t.state.selection.main.head);return FQ.test(e.text)}var K8=/^\s*(?:#{1,6}|>|[-+*]|\d+[.)]|`{1,}|\*\*|__|~~|_)\s*$/;function J8(t){return xo.test(t)||AQ.test(t)||K8.test(t)}function Yf(t,e){let i=t.state.selection.main;if(!i.empty)return!1;let n=t.coordsAtPos(i.head),r=t.moveVertically(i,e>0),o=t.coordsAtPos(r.head);if(!n||!o||r.head===i.head)return!1;let l=Array.from(t.dom.querySelectorAll(".tbl-table-widget")).map(a=>({widget:a,rect:a.getBoundingClientRect()})).filter(({rect:a})=>e>0?a.top>=n.bottom-1&&a.top<=o.top+1:a.bottom<=n.top+1&&a.bottom>=o.bottom-1).sort((a,c)=>e>0?a.rect.top-c.rect.top:c.rect.bottom-a.rect.bottom)[0]?.widget;return l?(window.requestAnimationFrame(()=>{let a=l.querySelectorAll(".tbl-cell");if(!a.length)return;let c=a[e>0?0:a.length-1];eL(c,e<0)}),!0):!1}function eL(t,e){let i=t.ownerDocument,n=i.createTreeWalker(t,NodeFilter.SHOW_TEXT),r=[];for(;n.nextNode();)r.push(n.currentNode);let o=e?r[r.length-1]:r[0],s=i.createRange();o?s.setStart(o,e?o.textContent?.length??0:0):s.selectNodeContents(t),s.collapse(!0);let l=i.getSelection();l?.removeAllRanges(),l?.addRange(s);let a=c=>{let h=t.querySelector(".tbl-cell-editor .cm-content");if(h){h.focus({preventScroll:!0});return}c>0&&window.requestAnimationFrame(()=>a(c-1))};window.requestAnimationFrame(()=>a(8))}function jQ(t,e){let i=t.state.selection.main;if(!i.empty)return!1;let n=t.state.doc,r=n.lineAt(i.head),o=r.number+e;if(o<1||o>n.lines)return!1;let s=n.line(o);if(!J8(s.text))return!1;let l=t.moveVertically(i,e>0),a=n.lineAt(l.head).number;if(a===o)return!1;let c=e>0?a>o:a<o,h=l.head===i.head;if(!c&&!h)return!1;let f=i.head-r.from;return t.dispatch({selection:{anchor:s.from+Math.min(f,s.length)},scrollIntoView:!0}),!0}function tL(t){let e=t.state.selection.main;if(!e.empty)return!1;let i=t.state.doc.lineAt(e.head),n=i.text.slice(0,e.head-i.from),r=i.text.slice(e.head-i.from);if(!/^\s*``$/.test(n)||r.trim()!=="")return!1;let o=0;for(let a=1;a<i.number;a++)xo.test(t.state.doc.line(a).text)&&o++;if(o%2!==0)return!1;let l=`${/^\s*/.exec(n)?.[0]??""}\`\`\``;return t.dispatch({changes:{from:e.head,insert:`\`
|
|
43
43
|
|
|
44
44
|
${l}`},selection:{anchor:e.head+1},scrollIntoView:!0}),!0}function iL(t){let e=t.state.selection.main;if(!e.empty)return!1;let i=t.state.doc.lineAt(e.head);if(e.head!==i.to||!xo.test(i.text))return!1;let n=0,r=0;for(let l=1;l<=t.state.doc.lines;l++)xo.test(t.state.doc.line(l).text)&&(r++,l===i.number&&(n=r));if(n%2!==1||n!==r)return!1;let o=/^(\s*)(`{3,})/.exec(i.text);if(!o)return!1;let s=`${o[1]}${o[2]}`;return t.dispatch({changes:{from:e.head,insert:`
|
|
45
45
|
|
package/package.json
CHANGED