finch-markdown-editor 0.1.5 → 0.1.8

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.
@@ -37,7 +37,7 @@
37
37
  </span>`)}function uq({textContent:i,classes:e}){return E(e)?`<span class="${e.join(" ")}">${Ny(i)}</span>`:Ny(i)}var dq=[{type:"table",location:"bottom-right"},{type:"table",location:"right"},{type:"table",location:"bottom"}];function Oq({row:i,col:e},t){let n=[{type:"header",location:"col",index:e},{type:"border",location:"top",index:i}],r=[{type:"border",location:"col",index:e+1},{type:"border",location:"row",index:i+1}],o=[{type:"header",location:"row",index:i},{type:"border",location:"left",index:i}];return[...t.top?n:[],...r,...t.left?o:[]]}function pq({location:i,type:e},t){return e==="header"?{location:i,type:e,index:t[i]}:i==="top"?{location:i,type:e,index:t.row}:i==="left"?{location:i,type:e,index:t.col}:{location:i,type:e,index:t[i]+1}}function dm(i,e){return i?.type!==e?.type||i?.location!==e?.location?!1:i?.type==="table"||e?.type==="table"?!0:i?.index===e?.index}var Vh=class i{state;extraTags;style(e){return cS(this.state,E(this.extraTags)?[...e,...this.extraTags]:e)}static of(e,t){return new i(e,t)}constructor(e,t){this.state=e,this.extraTags=t}};function Xk(i){return af(i).type==="None"}function _k(i){return!Xk(i)}function Fy(i){return _k(i)?af(i).getRangeAt(0).startOffset:void 0}function mq(i){return _k(i)?af(i).getRangeAt(0).startContainer:void 0}function gq(i){af(i).empty()}function af(i){return i.getSelection()}var Om=class i{#e;get table(){return Q(this.#e)}set table(e){I(this.#e,e)}#i;get _selection(){return Q(this.#i)}set _selection(e){I(this.#i,e)}#t;get selectionChanged(){return Q(this.#t)}set selectionChanged(e){I(this.#t,e,!0)}#n;get activeCell(){return Q(this.#n)}set activeCell(e){I(this.#n,e)}#r;get anchorCell(){return Q(this.#r)}set anchorCell(e){I(this.#r,e)}#l;get outlinedSection(){return Q(this.#l)}set outlinedSection(e){I(this.#l,e)}#o;get rootEditor(){return Q(this.#o)}set rootEditor(e){I(this.#o,e)}#s;get extensions(){return Q(this.#s)}set extensions(e){I(this.#s,e)}#a;get markdownConfig(){return Q(this.#a)}set markdownConfig(e){I(this.#a,e)}#h;get globalKeyBindings(){return Q(this.#h)}set globalKeyBindings(e){I(this.#h,e)}#c;get selectionType(){return Q(this.#c)}set selectionType(e){I(this.#c,e)}#u;get lineWrapping(){return Q(this.#u)}set lineWrapping(e){I(this.#u,e)}#d;get wrapperElement(){return Q(this.#d)}set wrapperElement(e){I(this.#d,e)}#O;get tableElement(){return Q(this.#O)}set tableElement(e){I(this.#O,e)}#f;get scrollElement(){return Q(this.#f)}set scrollElement(e){I(this.#f,e)}#b;get menuRootElement(){return Q(this.#b)}set menuRootElement(e){I(this.#b,e)}#S;get headerCellHighlighter(){return Q(this.#S)}set headerCellHighlighter(e){I(this.#S,e)}#v;get dataCellHighlighter(){return Q(this.#v)}set dataCellHighlighter(e){I(this.#v,e)}#m;get onUndo(){return Q(this.#m)}set onUndo(e){I(this.#m,e)}#p;get onRedo(){return Q(this.#p)}set onRedo(e){I(this.#p,e)}#g;get onNavigate(){return Q(this.#g)}set onNavigate(e){I(this.#g,e)}#x;get onDelete(){return Q(this.#x)}set onDelete(e){I(this.#x,e)}#w;get activeTable(){return Q(this.#w)}set activeTable(e){I(this.#w,e)}#y;get hoveredCell(){return Q(this.#y)}set hoveredCell(e){I(this.#y,e)}#Q;get activeHandle(){return Q(this.#Q)}set activeHandle(e){I(this.#Q,e)}#k;get menu(){return Q(this.#k)}set menu(e){I(this.#k,e)}#P;get move(){return Q(this.#P)}set move(e){I(this.#P,e)}#$;get outline(){return Q(this.#$)}set outline(e){I(this.#$,e)}#C;get resize(){return Q(this.#C)}set resize(e){I(this.#C,e)}#T;get interactive(){return Q(this.#T)}set interactive(e){I(this.#T,e)}#R;get pointerDown(){return Q(this.#R)}set pointerDown(e){I(this.#R,e)}static of(e){return new i(e)}focusTable(){this.activeTable=!0,this.tableElement.focus({preventScroll:!0}),this.selectionValue="hidden",gq(this.document)}scrollToCell(e){requestAnimationFrame(()=>{Dh(this.tableElement,e)?.scrollIntoView({inline:"nearest",block:"nearest"})})}scrollToFirstCell(e,t){requestAnimationFrame(()=>{Dh(this.tableElement,{...this.table.firstCellLocation,[e]:t})?.scrollIntoView({inline:"nearest",block:"nearest"})})}get document(){return this.rootEditor.dom.ownerDocument}get window(){return this.document.defaultView??window}get rootScrollElement(){return this.rootEditor.scrollDOM}get scrollOffsetX(){return this.rootScrollElement.scrollLeft+this.scrollElement.scrollLeft}get scrollOffsetY(){return this.rootScrollElement.scrollTop+this.scrollElement.scrollTop}deleteTable(){this.onDelete()}navigate(e){this.onNavigate(e)}undo(){this.onUndo()}redo(){this.onRedo()}get selection(){return this._selection}get selectionValue(){return this._selection.value}set selectionValue(e){sf(this._selection.value,e)||(this._selection.value=e,this.selectionChanged=!0)}highlighter({row:e}){return e===this.table.firstRowIndex?this.headerCellHighlighter:this.dataCellHighlighter}cellHandleState(e,t){return t.type==="border"||this.activeHandle?.state=="active"?dm(this.activeHandle?.handle,t)?this.activeHandle?.state:void 0:dm(this.activeHandle?.handle,t)||e[t.location]===this.activeCell?.[t.location]?"hover":void 0}constructor({table:e,selection:t,scrollElement:n,rootEditor:r,menuRootElement:o,extensions:s,markdownConfig:l,globalKeyBindings:a,selectionType:c,lineWrapping:h,onUndo:f,onRedo:u,onNavigate:d,onDelete:O}){this.#e=N(e),this.#i=N(t),this.#t=ae(!1);let p=this.selection.isCell()?this.selection.cell:void 0;this.#n=ae(p),this.#r=ae(p),this.#l=ae(E(p)?Ne.ofCell(p):void 0),this.#o=N(r),this.#s=N(s),this.#a=N(l),this.#h=N(a),this.#c=N(c),this.#u=N(h),this.#d=ae(void 0),this.#O=ae(void 0),this.#f=N(n),this.#b=N(o),this.#S=N(()=>Vh.of(this.rootEditor.state,[m.heading])),this.#v=N(()=>Vh.of(this.rootEditor.state)),this.#m=N(f),this.#p=N(u),this.#g=N(d),this.#x=N(O),this.#w=ae(!1),this.#y=ae(void 0),this.#Q=ae(void 0),this.#k=ae(void 0),this.#P=ae(void 0),this.#$=ae(void 0),this.#C=ae(void 0),this.#T=N(()=>j(this.move)&&j(this.resize)&&j(this.menu)&&j(this.outline)),this.#R=ae(!1);let g=N(()=>{if(Kh(this.window)){if(E(this.menu))return"default";if(E(this.activeHandle)){let{type:b,location:S}=this.activeHandle.handle;if(b==="table"){if(S==="right")return"col-resize";if(S==="bottom-right")return"nwse-resize";if(S==="bottom")return"row-resize"}else{if(b==="border")return S==="top"?"row-resize":S==="left"?"col-resize":`${S}-resize`;if(b==="header")return this.pointerDown?"grabbing":this.activeHandle.state==="hover"?"pointer":void 0}}else{if(this.outline?.outlined??!1)return"cell";if(E(this.hoveredCell))return"text"}}});Dm([()=>this.selectionValue],()=>{if(this.selectionChanged){this.selectionChanged=!1;return}this.selection.isCell()?(this.activeCell=this.selection.cell,this.anchorCell=this.selection.cell,this.outlinedSection=Ne.ofCell(this.selection.cell)):this.selection.isHidden()?(this.focusTable(),this.activeCell=void 0,this.anchorCell=void 0,this.outlinedSection=void 0):(this.activeTable=!1,this.activeCell=void 0,this.anchorCell=void 0,this.outlinedSection=void 0)}),tf(()=>{this.document.body.style.cursor=Q(g)??""})}};function Ek({tableState:i,event:e}){if(j(i.outlinedSection))return;e?.preventDefault();let t=jy(i.outlinedSection.rowRange,i.table.rowRange),n=jy(i.outlinedSection.colRange,i.table.colRange),r=n&&!t&&ir(i.outlinedSection.rowRange).every(l=>i.table.hasEmptyRowAt(l)),o=t&&!n&&ir(i.outlinedSection.colRange).every(l=>i.table.hasEmptyColAt(l)),s=t&&n&&ir(i.outlinedSection.colRange).every(l=>i.table.hasEmptyColAt(l));if(r){i.table.removeRowsAt({row:i.outlinedSection.startRow,count:i.outlinedSection.rowCount});let l=i.table.hasRowAt(i.outlinedSection.startRow)?i.outlinedSection.startRow:i.table.lastRowIndex,a={row:l,col:i.table.lastColIndex};i.outlinedSection=Ne.of({row:{start:l,endExclusive:l+1},col:i.table.colRange}),i.activeCell=a,i.anchorCell=a}else if(o){i.table.removeColsAt({col:i.outlinedSection.startCol,count:i.outlinedSection.colCount});let l=i.table.hasColAt(i.outlinedSection.startCol)?i.outlinedSection.startCol:i.table.lastColIndex,a={row:i.table.lastRowIndex,col:l};i.outlinedSection=Ne.of({row:i.table.rowRange,col:{start:l,endExclusive:l+1}}),i.activeCell=a,i.anchorCell=a}else s?i.deleteTable():i.table.clearSection(i.outlinedSection)}function Zk(i){Lk(i,"copy")}function zk(i){Lk(i,"cut")}function Vm({event:i,tableState:e}){if(j(e.outlinedSection))return;let t=i.clipboardData.getData("text/plain"),n=Vl.maybeOf(W.of(t.split(/\r\n|\n|\r/)));E(n)?(i.preventDefault(),i.stopPropagation(),Hy(n,e)):e.selection.isCell()||(i.preventDefault(),i.stopPropagation(),Hy(bq(t),e))}function Hy(i,e){let{startRow:t,startCol:n,rowCount:r,colCount:o}=e.outlinedSection,s=yy(r/i.rowCount),l=yy(o/i.colCount);i.tile({rowRepeat:kt(s-1,{min:0}),colRepeat:kt(l-1,{min:0})}),e.table.merge(i,{row:t,col:n}),e.outlinedSection=Ne.of({row:{start:t,endExclusive:t+i.rowCount},col:{start:n,endExclusive:n+i.colCount}}),j(e.anchorCell)&&(e.anchorCell=e.activeCell);let a=e.anchorCell.row<=e.activeCell.row,c=e.anchorCell.col<=e.activeCell.col;e.anchorCell=e.outlinedSection.cornerCellAt(`${a?"top":"bottom"}-${c?"left":"right"}`),e.activeCell=e.outlinedSection.cornerCellAt(`${a?"bottom":"top"}-${c?"right":"left"}`),e.focusTable()}function bq(i){let{text:e}=OQ([[Qt(i)]],["none"]);return Vl.of(e)}function Lk({event:i,tableState:e},t){if(j(e.outlinedSection)||e.selection.isCell())return;i.preventDefault(),i.stopPropagation();let n=e.table.sliceSectionAt(e.outlinedSection);i.clipboardData?.setData("text/plain",n.text.toString()),t==="cut"&&Ek({tableState:e})}function Sq(i){i.pointerDown=!0}function vq(i){i.pointerDown=!1}function xq(i){i.pointerDown=!1}function wq(i,e){e.selection.isCell()||Zk({tableState:e,event:i})}function yq(i,e){e.selection.isCell()||zk({tableState:e,event:i})}function Qq(i,e){e.selection.isCell()||Vm({tableState:e,event:i})}var Im="CellView";function Mk(i){return Sk(i,{component:Im})}function kq(i){return bk(i,{component:Im})}var tr="\0";function qk(i,e,{trim:t}){let n=Tk(i),{from:r,to:o}=Ck(i),s=e.toString(),l=W.of(`${s.slice(0,r)}${tr}${s.slice(r,o)}${tr}${s.slice(o)}`.split(`
38
38
  `)),a=Qm(l,{trim:t}).toString(),c=a.indexOf(tr),h=a.lastIndexOf(tr)-1;return n?{anchor:c,head:h}:{head:c,anchor:h}}function Ky(i,e){let t=Tk(i),{from:n,to:r}=Ck(i),o=e.toString(),s=W.of(`${o.slice(0,n)}${tr}${o.slice(n,r)}${tr}${o.slice(r)}`.split(`
39
39
  `)),l=zh(s).toString(),a=l.indexOf(tr),c=l.lastIndexOf(tr)-1;return t?{anchor:a,head:c}:{head:a,anchor:c}}function Pq(i){if(j(i.tableElement)||Xk(i.document))return;let e=mq(i.document);if(j(e)||!mk(i.tableElement,e))return;let t=Kl(e);if(j(t))return;let n=lf(t);i.selection.isCell()&&ho(i.selection.cell,n)||(i.activeTable=!1,i.selectionValue={cell:n,section:$q(i.document,e)},i.activeCell=n,i.anchorCell=n,i.outlinedSection=Ne.ofCell(n))}function $q(i,e){let t=Mk(e),n=TM({ancestor:t,descendent:e,getText:l=>$M(l)?`
40
- `:l.textContent??""})??"",r=(e.textContent??"").slice(0,Fy(i)),o=Qt(`${n}${r}`),s=n.length+Fy(i);return qk({anchor:s,head:s},o,{trim:!1})}function Cq(i,e){var t=Lm(),n=ze(t);ao(n,()=>e.children),z(i,t)}function Tq(i,e){cr(e,!0),rf(()=>{let t=uk(Cq,{target:e.to,context:ZL(),props:{children:e.children}});return()=>{dk(t)}}),hr()}_L();var Rq=oe('<div class="tbl-blocking-overlay" aria-hidden="true"></div>');function Aq(i){var e=Rq();z(i,e)}function Ih(i,e){let t=e.devicePixelRatio;return Tz(i*t)/t}function Xq({x:i,y:e},t){return{x:Ih(i,t),y:Ih(e,t)}}var _q=oe('<th class="tbl-cell tbl-header-cell"><!></th>'),Eq=oe('<td class="tbl-cell tbl-data-cell"><!></td>');function Zq(i,e){cr(e,!0);let t=N(()=>Gy(E(e.movement)?e.movement.border:{top:e.position.top,right:!0,bottom:!0,left:e.position.left})),n=N(()=>Gy(e.outline)),r=N(()=>{if(j(e.movement?.translate))return;let{x:c,y:h}=e.movement.state==="moving"?Xq(e.movement.translate,e.win):e.movement.translate;return`translate3d(${c}px, ${h}px, 0px)`});var o=Lm(),s=ze(o);{var l=c=>{var h=_q();let f;var u=pi(h);ao(u,()=>e.children),yt(d=>{Pe(h,"align",e.alignment==="none"?void 0:e.alignment),Pe(h,"data-component",Il),Pe(h,"data-row",e.location.row),Pe(h,"data-col",e.location.col),Pe(h,"data-border",Q(t)),Pe(h,"data-outline",Q(n)),Pe(h,"data-selected",d),Pe(h,"data-state",e.movement?.state),f=qh(h,"",f,{transform:Q(r)})},[()=>ro(e.selected)]),z(c,h)},a=c=>{var h=Eq();let f;var u=pi(h);ao(u,()=>e.children),yt(d=>{Pe(h,"align",e.alignment==="none"?void 0:e.alignment),Pe(h,"data-component",Il),Pe(h,"data-row",e.location.row),Pe(h,"data-col",e.location.col),Pe(h,"data-border",Q(t)),Pe(h,"data-outline",Q(n)),Pe(h,"data-selected",d),Pe(h,"data-state",e.movement?.state),f=qh(h,"",f,{transform:Q(r)})},[()=>ro(e.selected)]),z(c,h)};ut(s,c=>{e.position.top?c(l):c(a,!1)})}z(i,o),hr()}function Wk(i){return E(Dl(i.dom).activeElement?.closest(".cm-panels"))}function Jy(i){return i.trim().split(/\s+/)}function zq({doc:i,selection:e,parent:t,extensions:n,markdownConfig:r,selectionType:o,lineWrapping:s,globalKeyBindings:l,rootEditor:a,highlighter:c,onChange:h,eventHandlers:f}){return new $({doc:i,selection:e,parent:t,extensions:[n,vt.lowest([$.editorAttributes.of(u=>{let d=new Set(Jy(a.themeClasses)),O=new Set(Jy(u.themeClasses));return{class:[...d.difference(O)].join(" ")}}),Yt.of([...l.map(u=>({...u,run:E(u.run)?()=>u.run(a):void 0,shift:E(u.shift)?()=>u.shift(a):void 0}))]),o==="codemirror"?Na():[],Ar(c),Dr({extensions:[hQ,r.extensions??[]],addKeymap:!1,completeHTMLTags:r.completeHTMLTags,pasteURLAsLink:r.pasteURLAsLink,htmlTagLanguage:r.htmlTagLanguage}),$.domEventObservers(f),s==="wrap"?$.lineWrapping:[]])],dispatchTransactions:(u,d)=>{d.update(u),u.forEach(h)}})}var Lq=oe('<div class="tbl-cell-editor"></div>');function Mq(i,e){cr(e,!0);let t=sm(e,"text",15),n=sm(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=E(d);if(f||O){if(f){let p=Qm(u,{trim:!0});p.eq(t())||(t(p),l=!0)}if(O){let{head:p,anchor:g}=d.main,b=qk({head:p,anchor:g},u,{trim:!0});$k(b,n())||(n(b),l=!0)}}}Dm([()=>t(),()=>n()],()=>{if(l){l=!1;return}s=!0,o.dispatch({changes:o.state.changes({from:0,to:o.state.doc.length,insert:zh(t())}),selection:Ky(n(),t())}),s=!1},{lazy:!0}),rf(()=>(o=zq({doc:zh(t()),selection:Ky(n(),t()),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}}),Wk(o)||o.focus(),()=>o.destroy()));var c=Lq();Wh(c,h=>r=h,()=>r),z(i,c),hr()}var Yh=class i{event;tableState;position;static navigate(e){new i(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||j(this.tableState.outlinedSection)||j(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),j(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=Pk(this.tableState.activeCell)}}navigateShiftArrowUp(){if(!(!this.position.top||j(this.tableState.outlinedSection)||j(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),j(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=yk(this.tableState.activeCell)}}navigateShiftArrowRight(){if(!(!this.position.right||j(this.tableState.outlinedSection)||j(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),j(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=Qk(this.tableState.activeCell)}}navigateShiftArrowDown(){if(!(!this.position.bottom||j(this.tableState.outlinedSection)||j(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),j(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=kk(this.tableState.activeCell)}}moveLeft({createRow:e,position:t}){if(!j(this.tableState.activeCell)){if(this.event.preventDefault(),ho(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},t)}}moveUp({createRow:e,position:t}){if(!j(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},t)}}moveRight({createRow:e,position:t}){if(!j(this.tableState.activeCell)){if(this.event.preventDefault(),ho(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},t)}}moveDown({createRow:e,position:t}){if(!j(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},t)}}moveTo(e,t){if(this.tableState.activeCell=e,this.tableState.anchorCell=e,this.tableState.outlinedSection=Ne.ofCell(e),this.tableState.selection.isCell()){let n=t==="start"?0:this.tableState.table.cellAt(e).length;this.tableState.selectionValue={cell:e,section:{anchor:n,head:n}}}}constructor({event:e,tableState:t,position:n}){this.event=e,this.tableState=t,this.position=n}},Se={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"},qq=[Se.arrowDown,Se.arrowLeft,Se.arrowRight,Se.arrowUp,Se.enter,Se.tab,`${Se.shift}${Se.arrowDown}`,`${Se.shift}${Se.arrowLeft}`,`${Se.shift}${Se.arrowRight}`,`${Se.shift}${Se.arrowUp}`,`${Se.shift}${Se.tab}`],eQ=new Set(qq);function jk({key:i,shiftKey:e,altKey:t,metaKey:n,ctrlKey:r}){if(!(t||n||r))return e?eQ.has(`${Se.shift}${i}`)?`${Se.shift}${i}`:void 0:eQ.has(i)?i:void 0}function Wq(i,e){i.inputType==="historyUndo"?(e.undo(),i.preventDefault()):i.inputType==="historyRedo"&&(e.redo(),i.preventDefault())}function jq(i){i.preventDefault()}function Dq(i,e,t){let n=jk(i);if(j(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};Yh.navigate({tableState:t,key:n,event:i,position:h})}function Vq(i,e){Vm({tableState:e,event:i})}var Iq=oe('<div class="tbl-cell-view" contenteditable="" tabindex="-1"><!></div>');function Yq(i,e){cr(e,!0);var t=Iq(),n=pi(t);ao(n,()=>e.children),yt(r=>{Pe(t,"data-component",Im),Pe(t,"data-hidden",r)},[()=>ro(e.hidden)]),z(i,t),hr()}var Dk="Handle";function Ym(i){if(!vk(i,{component:Dk}))return;let{type:e,location:t}=Mm(i).dataset;if(e==="table")return{type:e,location:t};{let n=lf(Kl(i));return pq({location:t,type:e},n)}}var Bq=bi('<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>'),Uq=bi('<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>'),Nq=oe('<div class="tbl-handle" role="button" aria-hidden="true"><!></div>');function tQ(i,e){cr(e,!0);let t=sm(e,"toggle",3,!1),n={table:{right:"vertical",bottom:"horizontal"},header:{row:"vertical",col:"horizontal"}},r=N(()=>n[e.of.type]?.[e.of.location]);var o=Nq();qh(o,"",{},{opacity:"var(--tbl-handle-opacity, 0)"});var s=pi(o);{var l=c=>{var h=Bq();z(c,h)},a=c=>{var h=Uq();z(c,h)};ut(s,c=>{Q(r)==="horizontal"?c(l):Q(r)==="vertical"&&c(a,1)})}yt((c,h,f)=>{Pe(o,"data-component",Dk),Pe(o,"data-type",e.of.type),Pe(o,"data-location",e.of.location),Pe(o,"data-active",c),Pe(o,"data-hover",h),Pe(o,"data-toggle",f)},[()=>ro(e.state==="active"),()=>ro(e.state==="hover"),()=>ro(t())]),z(i,o),hr()}var Gq=oe('<div class="tbl-menu"><!></div>');function Fq(i,e){cr(e,!0);let t,n=ae(void 0);rf(()=>{e.translate(t).then(l=>I(n,l,!0))});var r=Gq();let o;var s=pi(r);ao(s,()=>e.children),Wh(r,l=>t=l,()=>t),yt(l=>o=qh(r,"",o,l),[()=>({visibility:E(Q(n))?void 0:"hidden",transform:E(Q(n))?`translate3d(${Q(n).x}px, ${Q(n).y}px, 0px)`:void 0})]),z(i,r),hr()}var Hq=oe('<div class="tbl-menu-item" role="menuitem" tabindex="-1"><!></div>');function Kt(i,e){var t=Hq(),n=pi(t);ao(n,()=>e.children),El("click",t,function(...r){e.onclick?.apply(this,r)}),z(i,t)}fk(["click"]);function Jt(i,e){switch(i.action){case"add":return e.menu.clickAdd(i.direction);case"align":return e.menu.clickAlign(i.alignment);case"clear":return e.menu.clickClear();case"duplicate":return e.menu.clickDuplicate();case"move":return e.menu.clickMove(i.direction);case"remove":return e.menu.clickRemove();case"sort":return e.menu.clickSort(i.direction)}}var Kq=bi('<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>'),Jq=bi('<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>'),e4=bi('<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>'),t4=bi('<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>'),i4=bi('<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>'),n4=bi('<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>'),r4=bi('<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>'),o4=bi('<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>'),s4=bi('<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>'),l4=bi('<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>'),a4=oe('<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 ei(i,e){var t=a4(),n=pi(t),r=pi(n);{var o=S=>{var v=Kq();z(S,v)},s=S=>{var v=Jq();z(S,v)},l=S=>{},a=S=>{var v=e4();z(S,v)},c=S=>{var v=t4();z(S,v)},h=S=>{var v=i4();z(S,v)},f=S=>{var v=n4();z(S,v)},u=S=>{var v=r4();z(S,v)},d=S=>{var v=o4();z(S,v)},O=S=>{var v=s4();z(S,v)},p=S=>{},g=S=>{},b=S=>{var v=l4();z(S,v)};ut(r,S=>{e.name==="sort-ascending"?S(o):e.name==="sort-descending"?S(s,1):e.name==="align-none"?S(l,2):e.name==="align-left"?S(a,3):e.name==="align-center"?S(c,4):e.name==="align-right"?S(h,5):e.name==="move-up"?S(f,6):e.name==="move-right"?S(u,7):e.name==="move-down"?S(d,8):e.name==="move-left"?S(O,9):e.name==="duplicate"?S(p,10):e.name==="clear"?S(g,11):e.name==="remove"&&S(b,12)})}z(i,t)}var c4=oe('<div class="tbl-menu-item-text"><!></div>');function ti(i,e){var t=c4(),n=pi(t);ao(n,()=>e.children),z(i,t)}var h4=oe('<div class="tbl-menu-separator"></div>');function Ph(i){var e=h4();z(i,e)}var f4=oe('<div class="tbl-select-all-overlay" aria-hidden="true"></div>');function u4(i){var e=f4();z(i,e)}var d4=new Set([Se.c,Se.v,Se.x]);function O4(i,e){return d4.has(i.key)&&i[Jz(e)]}var p4=[Se.backspace,Se.delete],m4=new Set(p4);function g4({key:i}){return m4.has(i)?i:void 0}function b4(i){return/^F\d+$/.test(i)}var S4=new Set([Se.alt,Se.escape,Se.enter,Se.shift]);function v4({metaKey:i,ctrlKey:e,key:t}){return!e&&!i&&!S4.has(t)&&!b4(t)}function x4(i,e){e.selection.isCell()||Zk({tableState:e,event:i})}function w4(i,e){e.selection.isCell()||zk({tableState:e,event:i})}function y4(i,e){e.selection.isCell()||Vm({tableState:e,event:i})}function Q4(i,e){if(E(i.target)&&E(Mk(i.target))){i.preventDefault();return}if(!e.interactive||e.selection.isCell())return;let t=jk(i);if(E(t)){Yh.navigate({tableState:e,key:t,event:i,position:{left:!0,top:!0,right:!0,bottom:!0}});return}let n=g4(i);if(E(n)){Ek({tableState:e,event:i});return}if(e.activeTable&&E(e.activeCell)&&v4(i)){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=Ne.ofCell(e.activeCell);return}O4(i,e.window)||Ua(e.rootEditor,i,"editor")&&i.preventDefault()}function Bm(i){return i.buttons===1}function Vk(i,e){return e.setPointerCapture(i.pointerId),()=>e.releasePointerCapture(i.pointerId)}var Bh=class i{offset;maxScroll;boundaryElement;scrollElement;scroll;handle;xAmount;yAmount;updatePosition(e,t){let n=this.boundaryElement.x.getBoundingClientRect();e<n.left+this.offset?this.xAmount=-kt(this.offset+(n.left-e),{max:this.maxScroll}):e>n.right-this.offset?this.xAmount=kt(this.offset-(n.right-e),{max:this.maxScroll}):this.xAmount=0;let r=this.boundaryElement.y.getBoundingClientRect();t<r.top+this.offset?this.yAmount=-kt(this.offset+(r.top-t),{max:this.maxScroll}):t>r.bottom-this.offset?this.yAmount=kt(this.offset-(r.bottom-t),{max:this.maxScroll}):this.yAmount=0,j(this.handle)&&(this.xAmount!==0||this.yAmount!==0)&&this.scroll()}destroy(){E(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 i(e)}constructor({offset:e,maxScroll:t,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=t,this.boundaryElement=n,this.scrollElement=r}},Uh=class i{start;size;get mid(){return this.start+this.size/2}get end(){return this.start+this.size}static of(e){return new i(e)}constructor({start:e,size:t}){this.start=e,this.size=t}},Nh;(i=>{function e(t,n){return pm.of(t,n)}i.of=e})(Nh||(Nh={}));var pm=class i{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,t){return e==="row"?this.rowAt(t):this.colAt(t)}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 Zh(...this.rows.map(e=>e.size))}get minColSize(){return Zh(...this.cols.map(e=>e.size))}moveRowOrColAt(e,{fromIndex:t,toIndex:n}){if(t===n)return;let r=this.rowsOrCols(e),o=r[t];if(t<n){for(let s of ir({start:t,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 ir({start:t,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 t=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:t===-1?0:t,col:n===-1?0:n}}static of(e,t){return new i(e,t)}constructor(e,t){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}=iQ(o,t),c=0;return Uh.of({start:l+c,size:a-c})}),this.cols=n.map((o,s)=>{let{left:l,width:a}=iQ(o,t),c=s===0?1:0;return Uh.of({start:l+c,size:a-c})})}};function iQ(i,e){let{top:t,left:n,width:r,height:o}=i.getBoundingClientRect();return{top:t+e.y,left:n+e.x,width:r,height:o}}var Gh=class i{tableState;tableMeasurement;autoScroller;shouldAutoScroll;removeEventListeners;currentCell;start(){this.tableState.activeCell=this.currentCell,this.tableState.anchorCell=this.currentCell,this.tableState.outlinedSection=Ne.ofCell(this.currentCell),this.tableState.outline={outlined:!1},this.removeEventListeners=co(Le(this.tableState.window,"pointermove",e=>this.drag(e)),Le(this.tableState.window,"pointerup",()=>this.end()),Le(this.tableState.window,"pointerleave",()=>this.end()))}resizeAndContinue(e){e.preventDefault(),j(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.currentCell),this.expandOrContract(this.currentCell),this.tableState.outline={outlined:!0},this.removeEventListeners=co(Le(this.tableState.window,"pointermove",t=>this.drag(t)),Le(this.tableState.window,"pointerup",()=>this.end()),Le(this.tableState.window,"pointerleave",()=>this.end()))}drag(e){if(!Bm(e)){this.end();return}e.preventDefault(),this.shouldAutoScroll()&&this.autoScroller.updatePosition(e.clientX,e.clientY);let t=this.tableMeasurement.lastCellBeforePosition({x:e.clientX+this.tableState.scrollOffsetX,y:e.clientY+this.tableState.scrollOffsetY});ho(t,this.currentCell)||(this.currentCell=t,this.tableState.outline={outlined:!0},this.expandOrContract(t))}end(){this.removeEventListeners?.(),this.autoScroller.destroy(),this.tableState.outline=void 0}expandOrContract(e){this.tableState.focusTable();let[t,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=Ne.of({row:{start:t,endExclusive:n+1},col:{start:r,endExclusive:o+1}}),this.tableState.activeCell=e}static startOutline(e){new i(e).start()}static resizeAndContinueOutline(e){new i(e).resizeAndContinue(e.event)}constructor({tableState:e,cellLocation:t}){this.tableState=e,this.currentCell=t,this.autoScroller=Bh.of({offset:10,maxScroll:32,boundaryElement:{x:e.scrollElement,y:e.rootScrollElement},scrollElement:{x:e.scrollElement,y:e.rootScrollElement}}),this.shouldAutoScroll=_M({delayMillis:500}),this.tableMeasurement=Nh.of(e.tableElement,{x:e.scrollOffsetX,y:e.scrollOffsetY})}};function k4(i,e){Kh(e.window)&&(e.hoveredCell=i)}function P4(i){Kh(i.window)&&(i.hoveredCell=void 0)}function $4(i,e,t){if(!(!t.interactive||!Bm(i)))if(i.shiftKey){if(t.selection.isCell()&&ho(e,t.selection.cell))return;Gh.resizeAndContinueOutline({event:i,tableState:t,cellLocation:e})}else Gh.startOutline({event:i,tableState:t,cellLocation:e})}var C4=new Intl.Collator(navigator.language,{numeric:!0,sensitivity:"base"});function nQ(i,e){return C4.compare(i,e)}function T4({metaKey:i,shiftKey:e,altKey:t,ctrlKey:n,key:r}){return r===Se.escape&&!e&&!t&&!i&&!n}var mm=class i{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=co(Le(e,"pointerdown",s=>{s.preventDefault(),(j(s.target)||!mk(this.tableState.menuRootElement,s.target))&&this.close()}),Le(e,"wheel",s=>s.preventDefault(),{passive:!1}),Le(e,"keydown",s=>{s.preventDefault(),T4(s)&&this.close()})),this.tableState.focusTable(),this.tableState.activeHandle={state:"active",handle:this.handle},this.tableState.outlinedSection=Ne.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 t=this.rowOrCol==="row"?{row:this.index,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:this.index};this.tableState.activeCell=t,this.tableState.anchorCell=t;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 t=await by({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:[my({allowedPlacements:this.rowOrCol==="row"?["right-start","right-end"]:["right-start","right"]}),gy({crossAxis:!0})]}),n=ds(e);return{x:Ih(t.x,n),y:Ih(t.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 t=Bp(this.rowOrCol,this.tableState.activeCell,"forward");this.tableState.activeCell=t,this.tableState.anchorCell=t}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 t=Bp(this.rowOrCol,this.tableState.activeCell,e);this.tableState.activeCell=t,this.tableState.anchorCell=t,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=Bp(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"?(t,n)=>nQ(t.toString(),n.toString()):(t,n)=>nQ(n.toString(),t.toString())),this.close()}static showMenu(e){new i(e).open()}constructor({tableState:e,handle:t,point:n}){this.tableState=e,this.handle=t,this.point=n}},gm=class i{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:t,move:n}=this.calculateDrag();return this.currentIndex=t,this.initialIndex!==this.currentIndex&&(this.dragged=!0),E(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 t=this.isRowOrColExposed(e[this.rowOrCol]),n=this.subject.containsCell(e);return this.rowOrCol==="row"?{top:t,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:t}}cellState(e){return this.subject.containsCell(e)?"moving":"shiftable"}cellTranslate(e){let t=this.rowOrColTranslate(e[this.rowOrCol]);return this.rowOrCol==="row"?{x:0,y:t}:{x:t,y:0}}isRowOrColExposed(e){let t=this.reorderIndex(e),n=t===this.tableMeasurement.firstRowOrColIndex(this.rowOrCol),r=t===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 kt(this.currentPosition-this.initialPosition,{min:this.minBound,max:this.maxBound});let t=this.rowOrColShift;return j(t)?0:er(e,t.range)?t.positionDiff:0}reorderIndex(e){let t=this.rowOrColShift;return j(t)?e:e===this.initialIndex?this.currentIndex:er(e,t.range)?e+t.indexDiff:e}calculateDrag(){let e=this.tableMeasurement.rowsOrCols(this.rowOrCol),t={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=Qz(kz([t,n,r]),(s,l)=>Up(this.currentPosition-s.mid)-Up(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 i(e)}constructor({rowOrCol:e,index:t,position:n,subject:r,tableElement:o,scrollOffsetX:s,scrollOffsetY:l}){this.scrollOffsetX=s,this.scrollOffsetY=l;let a=Nh.of(o,{x:this.scrollOffsetX(),y:this.scrollOffsetY()});this.rowOrCol=e,this.coordinate=e==="row"?"y":"x",this.initialIndex=t,this.initialPosition=n[this.coordinate],this.minBound=a.firstRowOrCol(this.rowOrCol).start-a.rowOrColAt(this.rowOrCol,t).start,this.maxBound=a.lastRowOrCol(this.rowOrCol).end-a.rowOrColAt(this.rowOrCol,t).end,this.size=a.rowOrColAt(this.rowOrCol,t).size,this.subject=r,this.dragged=!1,this.tableMeasurement=a,this.currentIndex=t,this.currentPosition=n[this.coordinate]}},bm=class i{tableState;rowOrCol;index;onClick;moveTracker;subject;autoScroller;removeEventListeners;start(e){e.preventDefault();let t=this.moveTracker.start();this.tableState.outlinedSection=this.subject,this.tableState.move=t,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=Mm(e.target);this.removeEventListeners=co(Vk(e,r),Le(r,"pointermove",o=>this.drag(o)),Le(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=Ne.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 t=this.rowOrCol==="row"?{row:e.toIndex,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:e.toIndex};this.tableState.activeCell=t,this.tableState.anchorCell=t}this.tableState.move=void 0,this.tableState.activeHandle=void 0,!e.moved&&!e.dragged&&this.onClick()}static startMove(e){new i(e).start(e.event)}constructor({event:e,tableState:t,rowOrCol:n,index:r,onClick:o}){this.tableState=t,this.rowOrCol=n,this.index=r,this.subject=Ne.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=Bh.of({offset:16,maxScroll:32,boundaryElement:{x:t.scrollElement,y:t.rootScrollElement},scrollElement:{x:t.scrollElement,y:t.rootScrollElement}}),this.moveTracker=gm.of({subject:this.subject,rowOrCol:n,index:r,position:{x:e.clientX+t.scrollOffsetX,y:e.clientY+t.scrollOffsetY},tableElement:t.tableElement,scrollOffsetX:()=>this.tableState.scrollOffsetX,scrollOffsetY:()=>this.tableState.scrollOffsetY})}};function R4(i){return i==="row"?"y":"x"}var Sm=class i{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"),t=this.calculateClickRowOrCol("col");return{operation:{row:e.operation.row,col:t.operation.col},activeHandle:e.activeHandle,activeCell:E(e.activeCell)&&E(t.activeCell)?{row:e.activeCell.row,col:t.activeCell.col}:void 0,anchorCell:E(e.anchorCell)&&E(t.anchorCell)?{row:e.anchorCell.row,col:t.anchorCell.col}:void 0,outlinedSection:E(e.outlinedSection)&&E(t.outlinedSection)?Ne.of({row:e.outlinedSection.row,col:t.outlinedSection.col}):void 0}}calculateClickRowOrCol(e){let t=this.type==="table"?this.tableState.table.lastRowOrColIndex(e)+1:this.initialHandle.index;return{operation:{[e]:{action:"add",index:t,count:1}},activeHandle:this.type==="table"?void 0:{state:"hover",handle:{type:"border",location:this.handleLocationAt(t),index:t}},...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 t=this.calculateDragRowOrCol("row",e),n=this.calculateDragRowOrCol("col",e);if(j(t)&&j(n))return;let r=t??this.calculateCellMovement("row",this.rowOrColDiff("row")),o=n??this.calculateCellMovement("col",this.rowOrColDiff("col"));return{operation:{row:t?.operation.row,col:n?.operation.col},activeHandle:t?.activeHandle??n?.activeHandle,activeCell:E(r.activeCell)&&E(o.activeCell)?{row:r.activeCell.row,col:o.activeCell.col}:void 0,anchorCell:E(r.anchorCell)&&E(o.anchorCell)?{row:r.anchorCell.row,col:o.anchorCell.col}:void 0,outlinedSection:E(r.outlinedSection)&&E(o.outlinedSection)?Ne.of({row:r.outlinedSection.row,col:o.outlinedSection.col}):void 0}}calculateDragRowOrCol(e,t){let n=R4(e),r=t.position[n]-this.initialPosition[n],o=Rz(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:Zh(-a,c,this.tableState.table.lastRowOrColIndex(e))})}calculateDragRowOrColLess({rowOrCol:e,start:t,length:n}){let r=0;for(let s of ir({start:t-1,endExclusive:t-n-1})){if(!this.tableState.table.hasEmptyRowOrColAt(e,s))break;r++}if(r===0)return;let o=t-(r-1)-1;return{operation:{[e]:{action:"remove",index:t-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:t,length:n}){return{operation:{[e]:{action:"add",index:t,count:n}},activeHandle:{state:"active",handle:this.type==="table"?this.initialHandle:{type:"border",location:this.handleLocationAt(t+n),index:t+n}},...this.calculateCellMovement(e,this.rowOrColDiff(e)+n)}}calculateCellMovement(e,t){let n=this.type==="table"?this.initialRowOrColCount[e]:this.initialHandle.index;if(t>=0)return{outlinedSection:this.initialOutlinedSection?.addForwardsByRowOrCol(e,{start:n,count:t}),activeCell:E(this.initialActiveCell)?By(e,this.initialActiveCell,{start:n,count:t}):void 0,anchorCell:E(this.initialAnchorCell)?By(e,this.initialAnchorCell,{start:n,count:t}):void 0};{let r=-t,o=this.initialOutlinedSection?.subtractBackwardsByRowOrCol(e,{start:n,count:r,min:this.tableState.table.firstRowOrColIndex(e)}),s=E(o)?{min:o.startRowOrCol(e),max:o.endRowOrCol(e)}:void 0,l=E(this.initialActiveCell)?Uy(e,this.initialActiveCell,{start:n,count:r,boundary:s}):void 0,a=E(this.initialAnchorCell)?Uy(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 i(e)}constructor({tableState:e,handle:t,position:n,cellSizePixels:r,dragThresholdPixels:o}){this.tableState=e,this.type=this.handleToType(t),this.initialHandle=t,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 A4(i){let e=Dh(i.tableElement,i.table.firstCellLocation),t=kq(e),{minWidth:n}=getComputedStyle(e),{lineHeight:r,paddingTop:o,paddingBottom:s}=getComputedStyle(t),l=parseFloat(n)+1,a=parseFloat(r)+parseFloat(o)+parseFloat(s)+1;return{width:l,height:a}}var vm=class i{tableState;resizeTracker;removeEventListeners;start(e){e.preventDefault();let t=this.resizeTracker.start();this.tableState.resize={},this.tableState.activeHandle=t.activeHandle,this.tableState.focusTable(),this.removeEventListeners=co(Vk(e,this.tableState.tableElement),Le(this.tableState.tableElement,"pointermove",n=>this.drag(n)),Le(this.tableState.tableElement,"pointerup",()=>this.end()))}drag(e){e.preventDefault();let t=this.resizeTracker.drag({position:{x:e.clientX,y:e.clientY}});E(t)&&(this.resizeTable(t.operation),this.tableState.activeHandle=t.activeHandle,this.tableState.activeCell=t.activeCell,this.tableState.anchorCell=t.anchorCell,this.tableState.outlinedSection=t.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:t}){if(E(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(E(t)){let{action:n,index:r,count:o}=t;n==="add"?this.tableState.table.addEmptyColsAt({col:r,count:o}):this.tableState.table.removeColsAt({col:r,count:o})}}static startResize(e){new i(e).start(e.event)}constructor({event:e,tableState:t,handle:n}){this.tableState=t;let{width:r,height:o}=A4(t);this.resizeTracker=Sm.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 X4(i,e){e.interactive&&(e.activeHandle={state:"hover",handle:i})}function _4(i){i.interactive&&(i.activeHandle=void 0)}function E4(i,e,t){if(t.interactive){if(!Bm(i)){i.preventDefault();return}e.type==="table"||e.type==="border"?vm.startResize({event:i,handle:e,tableState:t}):e.type==="header"&&bm.startMove({event:i,rowOrCol:e.location,index:e.index,tableState:t,onClick:()=>mm.showMenu({handle:e,point:{x:i.clientX,y:i.clientY},tableState:t})})}}function Z4(i,e){let t=i.target;if(j(t))return;let n=Ym(t);if(E(n)){X4(n,e);return}let r=Kl(t);if(E(r)){k4(lf(r),e);return}}function z4(i,e){let t=i.target;if(j(t))return;let n=Ym(t);if(E(n)){_4(e);return}let r=Kl(t);if(E(r)){P4(e);return}}function L4(i,e){let t=i.target;if(j(t))return;let n=Ym(t);if(E(n)){E4(i,n,e);return}let r=Kl(t);if(E(r)){$4(i,lf(r),e);return}i.preventDefault()}function M4(i){i.preventDefault()}var q4=oe("<!> <!> <!>",1),W4=oe('<tr class="tbl-table-row"></tr>'),j4=oe('<tbody class="tbl-table-body"></tbody>'),D4=oe("<!> <!>",1),V4=oe("<!> <!>",1),I4=oe("<!> <!> <!>",1),Y4=oe("<!> <!>",1),B4=oe("<!> <!>",1),U4=oe("<!> <!>",1),N4=oe("<!> <!>",1),G4=oe("<!> <!> <!> <!> <!>",1),F4=oe("<!> <!>",1),H4=oe("<!> <!>",1),K4=oe("<!> <!> <!>",1),J4=oe("<!> <!>",1),e3=oe("<!> <!>",1),t3=oe("<!> <!> <!>",1),i3=oe("<!> <!>",1),n3=oe("<!> <!>",1),r3=oe("<!> <!>",1),o3=oe("<!> <!> <!> <!> <!> <!> <!>",1),s3=oe('<div class="tbl-table-wrapper"><table class="tbl-table" role="grid" tabindex="-1"><thead class="tbl-table-head"><!></thead><!></table> <!> <!> <!> <!></div>');function l3(i,e){cr(e,!0);let t=Om.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});rf(()=>co(Le(t.document,"selectionchange",()=>Pq(t)),Le(t.document.body,"pointerdown",()=>Sq(t),{capture:!0,passive:!0}),Le(t.document.body,"pointerup",()=>vq(t),{capture:!0,passive:!0}),Le(t.document.body,"pointerleave",()=>xq(t),{capture:!0,passive:!0}),Le(t.document.body,"copy",x=>wq(x,t)),Le(t.document.body,"cut",x=>yq(x,t)),Le(t.document.body,"paste",x=>Qq(x,t))));var n=s3(),r=pi(n);{let x=(w,k=yQ)=>{var P=W4();yh(P,20,()=>t.table.colIndices,Z=>Z,(Z,Y)=>{let _=N(()=>({row:k(),col:Y})),V=N(()=>({top:k()===t.table.firstRowIndex,left:Y===t.table.firstColIndex})),M=N(()=>t.selection.isCell()&&ho(Q(_),t.selection.cell));{let ee=N(()=>t.outlinedSection?.containsOnEdge(Q(_))??{top:!1,right:!1,bottom:!1,left:!1}),F=N(()=>t.move?.cellMovement(Q(_)));Zq(Z,{get location(){return Q(_)},get alignment(){return t.table.alignments[Y]},get selected(){return Q(M)},get position(){return Q(V)},get outline(){return Q(ee)},get movement(){return Q(F)},get win(){return t.window},children:(ce,Be)=>{var Ge=q4(),mt=ze(Ge);yh(mt,16,()=>Oq(Q(_),Q(V)),ye=>ye,(ye,Fe)=>{{let gt=N(()=>t.cellHandleState(Q(_),Fe)),_t=N(()=>E(t.resize));tQ(ye,{get of(){return Fe},get state(){return Q(gt)},get toggle(){return Q(_t)}})}});var _e=J(mt,2);Yq(_e,{get hidden(){return Q(M)},children:(ye,Fe)=>{var gt=Lm(),_t=ze(gt);vM(_t,()=>hq(t.table.cellAt(Q(_)),t.highlighter(Q(_)))),z(ye,gt)},$$slots:{default:!0}});var rt=J(_e,2);{var jt=ye=>{var Fe=()=>t.table.cellAt(Q(_)),gt=pe=>t.table.setCellAt(Q(_),pe),_t=()=>t.selection.cellSection,H=pe=>{t.selectionValue={cell:Q(_),section:pe}};{let pe=N(()=>t.highlighter(Q(_)));Mq(ye,{get text(){return Fe()},set text(me){gt(me)},get selection(){return _t()},set selection(me){H(me)},get selectionType(){return t.selectionType},get lineWrapping(){return t.lineWrapping},get extensions(){return t.extensions},get markdownConfig(){return t.markdownConfig},get rootEditor(){return t.rootEditor},get globalKeyBindings(){return t.globalKeyBindings},get highlighter(){return Q(pe)},onbeforeinput:me=>Wq(me,t),ondragstart:me=>jq(me),onkeydown:(me,Ce)=>Dq(me,Ce,t),onpaste:me=>Vq(me,t)})}};ut(rt,ye=>{Q(M)&&ye(jt)})}z(ce,Ge)},$$slots:{default:!0}})}}),z(w,P)};var o=pi(r),s=pi(o);x(s,()=>t.table.headerRowIndex);var l=J(o);{var a=w=>{var k=j4();yh(k,20,()=>t.table.dataRowIndices,P=>P,(P,Z)=>{x(P,()=>Z)}),z(w,k)},c=N(()=>t.table.hasDataRows());ut(l,w=>{Q(c)&&w(a)})}Wh(r,w=>t.tableElement=w,()=>t?.tableElement)}var h=J(r,2);{var f=x=>{let w=N(()=>t.menu.type==="row"?"row":"column");Tq(x,{get to(){return t.menuRootElement},children:(k,P)=>{Fq(k,{translate:Z=>t.menu.computeTranslation(Z),children:(Z,Y)=>{let _=N(()=>{let{addable:H,alignable:pe,clearable:me,duplicatable:Ce,moveable:Ve,removable:Ie,sortable:Pt}=t.menu.capabilities;return{addable:H,alignable:pe,clearable:me,duplicatable:Ce,moveable:Ve,removable:Ie,sortable:Pt}});var V=o3(),M=ze(V);{var ee=H=>{var pe=I4(),me=ze(pe);Kt(me,{onclick:()=>Jt({action:"sort",direction:"ascending"},t),children:(Ie,Pt)=>{var he=D4(),ge=ze(he);ei(ge,{name:"sort-ascending"});var Me=J(ge,2);ti(Me,{children:(Qe,ot)=>{var Te=Ht();yt(()=>vn(Te,`Sort by ${Q(w)??""} (A-Z)`)),z(Qe,Te)}}),z(Ie,he)}});var Ce=J(me,2);Kt(Ce,{onclick:()=>Jt({action:"sort",direction:"descending"},t),children:(Ie,Pt)=>{var he=V4(),ge=ze(he);ei(ge,{name:"sort-descending"});var Me=J(ge,2);ti(Me,{children:(Qe,ot)=>{var Te=Ht();yt(()=>vn(Te,`Sort by ${Q(w)??""} (Z-A)`)),z(Qe,Te)}}),z(Ie,he)}});var Ve=J(Ce,2);Ph(Ve),z(H,pe)};ut(M,H=>{Q(_).sortable&&H(ee)})}var F=J(M,2);{var ce=H=>{var pe=G4(),me=ze(pe);Kt(me,{onclick:()=>Jt({action:"align",alignment:"none"},t),children:(he,ge)=>{var Me=Y4(),Qe=ze(Me);ei(Qe,{name:"align-none"});var ot=J(Qe,2);ti(ot,{children:(Te,Si)=>{var Hi=Ht("Align none");z(Te,Hi)}}),z(he,Me)}});var Ce=J(me,2);Kt(Ce,{onclick:()=>Jt({action:"align",alignment:"left"},t),children:(he,ge)=>{var Me=B4(),Qe=ze(Me);ei(Qe,{name:"align-left"});var ot=J(Qe,2);ti(ot,{children:(Te,Si)=>{var Hi=Ht("Align left");z(Te,Hi)}}),z(he,Me)}});var Ve=J(Ce,2);Kt(Ve,{onclick:()=>Jt({action:"align",alignment:"center"},t),children:(he,ge)=>{var Me=U4(),Qe=ze(Me);ei(Qe,{name:"align-center"});var ot=J(Qe,2);ti(ot,{children:(Te,Si)=>{var Hi=Ht("Align center");z(Te,Hi)}}),z(he,Me)}});var Ie=J(Ve,2);Kt(Ie,{onclick:()=>Jt({action:"align",alignment:"right"},t),children:(he,ge)=>{var Me=N4(),Qe=ze(Me);ei(Qe,{name:"align-right"});var ot=J(Qe,2);ti(ot,{children:(Te,Si)=>{var Hi=Ht("Align right");z(Te,Hi)}}),z(he,Me)}});var Pt=J(Ie,2);Ph(Pt),z(H,pe)};ut(F,H=>{Q(_).alignable&&H(ce)})}var Be=J(F,2);{var Ge=H=>{var pe=K4(),me=ze(pe);Kt(me,{onclick:()=>Jt({action:"add",direction:"before"},t),children:(Ie,Pt)=>{var he=F4(),ge=ze(he);ei(ge,{name:"add-before"});var Me=J(ge,2);ti(Me,{children:(Qe,ot)=>{var Te=Ht();yt(()=>vn(Te,`Add ${Q(w)??""} ${Q(w)==="row"?"above":"before"}`)),z(Qe,Te)}}),z(Ie,he)}});var Ce=J(me,2);Kt(Ce,{onclick:()=>Jt({action:"add",direction:"after"},t),children:(Ie,Pt)=>{var he=H4(),ge=ze(he);ei(ge,{name:"add-after"});var Me=J(ge,2);ti(Me,{children:(Qe,ot)=>{var Te=Ht();yt(()=>vn(Te,`Add ${Q(w)??""} ${Q(w)==="row"?"below":"after"}`)),z(Qe,Te)}}),z(Ie,he)}});var Ve=J(Ce,2);Ph(Ve),z(H,pe)};ut(Be,H=>{Q(_).addable&&H(Ge)})}var mt=J(Be,2);{var _e=H=>{var pe=t3(),me=ze(pe);{var Ce=he=>{Kt(he,{onclick:()=>Jt({action:"move",direction:"backward"},t),children:(ge,Me)=>{var Qe=J4(),ot=ze(Qe);{let Si=N(()=>`move-${Q(w)==="row"?"up":"left"}`);ei(ot,{get name(){return Q(Si)}})}var Te=J(ot,2);ti(Te,{children:(Si,Hi)=>{var ps=Ht();yt(()=>vn(ps,`Move ${Q(w)??""} ${Q(w)==="row"?"up":"left"}`)),z(Si,ps)}}),z(ge,Qe)}})};ut(me,he=>{(Q(_).moveable==="backward"||Q(_).moveable===!0)&&he(Ce)})}var Ve=J(me,2);{var Ie=he=>{Kt(he,{onclick:()=>Jt({action:"move",direction:"forward"},t),children:(ge,Me)=>{var Qe=e3(),ot=ze(Qe);{let Si=N(()=>`move-${Q(w)==="row"?"down":"right"}`);ei(ot,{get name(){return Q(Si)}})}var Te=J(ot,2);ti(Te,{children:(Si,Hi)=>{var ps=Ht();yt(()=>vn(ps,`Move ${Q(w)??""} ${Q(w)==="row"?"down":"right"}`)),z(Si,ps)}}),z(ge,Qe)}})};ut(Ve,he=>{(Q(_).moveable==="forward"||Q(_).moveable===!0)&&he(Ie)})}var Pt=J(Ve,2);Ph(Pt),z(H,pe)};ut(mt,H=>{Q(_).moveable!==!1&&H(_e)})}var rt=J(mt,2);{var jt=H=>{Kt(H,{onclick:()=>Jt({action:"duplicate"},t),children:(pe,me)=>{var Ce=i3(),Ve=ze(Ce);ei(Ve,{name:"duplicate"});var Ie=J(Ve,2);ti(Ie,{children:(Pt,he)=>{var ge=Ht();yt(()=>vn(ge,`Duplicate ${Q(w)??""}`)),z(Pt,ge)}}),z(pe,Ce)}})};ut(rt,H=>{Q(_).duplicatable&&H(jt)})}var ye=J(rt,2);{var Fe=H=>{Kt(H,{onclick:()=>Jt({action:"clear"},t),children:(pe,me)=>{var Ce=n3(),Ve=ze(Ce);ei(Ve,{name:"clear"});var Ie=J(Ve,2);ti(Ie,{children:(Pt,he)=>{var ge=Ht();yt(()=>vn(ge,`Clear ${Q(w)??""}`)),z(Pt,ge)}}),z(pe,Ce)}})};ut(ye,H=>{Q(_).clearable&&H(Fe)})}var gt=J(ye,2);{var _t=H=>{Kt(H,{onclick:()=>Jt({action:"remove"},t),children:(pe,me)=>{var Ce=r3(),Ve=ze(Ce);ei(Ve,{name:"remove"});var Ie=J(Ve,2);ti(Ie,{children:(Pt,he)=>{var ge=Ht();yt(()=>vn(ge,`Delete ${Q(w)??""}`)),z(Pt,ge)}}),z(pe,Ce)}})};ut(gt,H=>{Q(_).removable&&H(_t)})}z(Z,V)},$$slots:{default:!0}})},$$slots:{default:!0}})},u=N(()=>E(t.menu));ut(h,x=>{Q(u)&&x(f)})}var d=J(h,2);yh(d,16,()=>dq,x=>x,(x,w)=>{{let k=N(()=>dm(t.activeHandle?.handle,w)?t.activeHandle.state:void 0);tQ(x,{get of(){return w},get state(){return Q(k)}})}});var O=J(d,2);{var p=x=>{Aq(x)},g=N(()=>!t.interactive&&j(t.outline));ut(O,x=>{Q(g)&&x(p)})}var b=J(O,2);{var S=x=>{u4(x)},v=N(()=>t.selection.isAll());ut(b,x=>{Q(v)&&x(S)})}Wh(n,x=>t.wrapperElement=x,()=>t?.wrapperElement),yt(x=>Pe(n,"data-select-all",x),[()=>ro(t.selection.isAll())]),El("mouseover",n,x=>Z4(x,t)),El("mouseout",n,x=>z4(x,t)),El("pointerdown",n,x=>L4(x,t)),xh("dragover",n,x=>M4(x)),El("keydown",r,x=>Q4(x,t)),xh("copy",r,x=>x4(x,t)),xh("cut",r,x=>w4(x,t)),xh("paste",r,x=>y4(x,t)),z(i,n),hr()}fk(["mouseover","mouseout","pointerdown","keydown"]);var xm=class i extends Ze{tableDescription;widgetElement;height;destroyWidgetElement;get estimatedHeight(){return this.height}coordsAt(e,t,n){let r=this.tableDescription.table.closestCellAtPosition(t),o=Dh(e,r);if(j(o))return null;let s=o.getBoundingClientRect();return{top:s.top,right:s.right,bottom:s.bottom,left:s.left}}toDOM(e){if(E(this.widgetElement))return this.widgetElement;let{widgetElement:t,destroyWidgetElement:n}=this.create(e);return this.widgetElement=t,this.destroyWidgetElement=n,e.requestMeasure({read:()=>{this.height=t.getBoundingClientRect().height}}),t}destroy(e){this.destroyWidgetElement?.(),this.destroyWidgetElement=void 0,this.widgetElement=void 0,this.height=qy}create(e){let t=Dl(e.dom).createElement("div");t.className="tbl-table-widget",t.tabIndex=-1,t.addEventListener("pointerdown",d=>{d?.target===t&&d.preventDefault()});let n=this.tableDescription,r=nM(()=>{tf(()=>{let d=!n.table.text.eq(n.editorTableText),O=!sf(n.selection.value,n.editorSelectionValue);if(!d&&!O)return;let p;if(n.selection.isCell()){let{from:b}=n.table.cellSpan(n.selection.cell);p={anchor:n.from+b+n.selection.cellSection.anchor,head:n.from+b+n.selection.cellSection.head}}else n.selection.isAll()?p={anchor:n.from,head:n.to}:n.selection.isHidden()&&(p={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:or("table.edit"),changes:g,selection:p})})}),{extensions:o,markdownConfig:s,globalKeyBindings:l,selectionType:a,lineWrapping:c}=Bk(e.state),h=uk(l3,{target:t,props:{table:n.table,selection:n.selection,scrollElement:t,rootEditor:e,extensions:o,markdownConfig:s,globalKeyBindings:l,selectionType:a,lineWrapping:c,menuRootElement:qs(e,Rk).dom,onUndo:()=>mc(e),onRedo:()=>Fs(e),onNavigate:d=>{e.dispatch({annotations:or("table.navigate"),selection:{anchor:d==="before"?n.from-1:n.to+1}}),e.focus()},onDelete:()=>{e.dispatch({annotations:or("table.delete"),changes:{from:n.from,to:n.to},selection:e.state.selection}),e.focus()}}}),f=()=>{dk(h)},u=AM(t,({height:d})=>{this.height=d});return{widgetElement:t,destroyWidgetElement:co(r,f,u)}}static of(e,t){return new i(e,t)}constructor(e,t){super(),this.tableDescription=e;let n=S3(t);if(E(n)){let{widgetElement:r,destroyWidgetElement:o}=this.create(n);this.widgetElement=r,this.destroyWidgetElement=o,this.height=RM(n,r)}else this.widgetElement=void 0,this.destroyWidgetElement=void 0,this.height=qy}};function a3(i,e){return{widget:xm.of(i,e),block:!0,inclusive:!0}}function c3(i,e){return X.replace(a3(i,e))}function h3(i,e){let t=new Ke;for(let n of i)t.add(n.from,n.to,c3(n,e));return t.finish()}function f3(i){return Ik(i)}function u3(i,e){return Ik(i,e)}function Ik(i,e=[]){let t=[];gz(B(i),o=>{fQ(o)&&t.push({from:i.doc.lineAt(o.from).from,to:i.doc.lineAt(o.to).to})});let n=[],r=[];for(let o of t){if($z(e,o,SQ)){n.push(o);continue}let s=d3(o,i);Hh(s)?n.push(o):r.push(...s)}return{spans:n,formatting:r,complete:Nb(i)}}function d3(i,e){return[...O3(i,e),...p3(i,e)]}function O3(i,{doc:e,lineBreak:t}){return Yl({doc:e,lineBreak:t,span:i}).changes}function p3({from:i,to:e},{doc:t}){let n=t.slice(i,e),{text:r}=Np(n);return n.eq(r)?[]:[{from:i,to:e,insert:r}]}var m3={create(i){return $h(i)},update(i,e){if(IM(e))return $h(e.state);if(!e.docChanged&&j(e.selection)&&i.complete)return i;let{tables:t,formatting:n,decorations:r}=i;if(!e.docChanged&&i.complete)return{tables:rQ(t,e),formatting:n,decorations:r.map(e.changes),complete:!0};if(VM(e)||g3(e,t))return $h(e.state);let o=rQ(t,e).map(c=>c.span),{complete:s,spans:l,formatting:a}=u3(e.state,o);return Kn(o,l,SQ)?{complete:s,tables:t,formatting:a,decorations:r.map(e.changes)}:$h(e.state)},provide(i){return $.decorations.from(i,e=>e.decorations)}},Yk=de.define(m3);function $h(i){let{spans:e,formatting:t,complete:n}=f3(i),{doc:r,selection:o}=i,s=e.map(l=>hm.of({span:l,doc:r,selection:o}));return{complete:n,tables:s,formatting:t,decorations:h3(s,i)}}function g3(i,e){return!jm(i)&&e.some(t=>i.changes.touchesRange(t.from,t.to)!==!1)}function rQ(i,e){return xz(i,t=>t.applyTransaction(e))}var b3={create(){return{view:void 0}},update(i){return i}},Um=de.define(b3);function Bk(i){return i.facet(Gp)}function lr(i){return i.field(Yk)}function S3(i){return i.field(Um).view}function v3(i){let{handlePosition:e,selectionType:t,lineWrapping:n}=Bk(i);return{...Kh(window)?{"data-tbl-hoverable":""}:{},"data-tbl-theme-mode":i.facet($.darkTheme)?"dark":"light","data-tbl-handle-position":e,"data-tbl-selection-type":t,"data-tbl-line-wrapping":n}}var x3=["undo","redo","select.undo","select.redo"];function w3(i){return x3.some(e=>i.isUserEvent(e))}function y3(i){return Uk(i,"select.search")}function Q3(i){return Uk(i,"select")}function k3(i){return i.isUserEvent("delete.forward")}function P3(i){return i.isUserEvent("delete.backward")}function Uk(i,e){return i.annotation(Ee.userEvent)===e}var $3=({state:i,view:e,transactions:t})=>{e.hasFocus||lr(i).tables.some(n=>n.containsSelection())||t.some(n=>w3(n)||y3(n)&&!Wk(e))&&e.focus()},Nk=D.define(),C3=new Map(xk.map(i=>[i,Nk.of(i)]));function Gk(i){return C3.get(i)}var T3=(i,e)=>!e||!lr(i).tables.some(t=>t.containsSelection())?null:Gk("table.focus"),R3=i=>{let{selection:e,startState:t,docChanged:n}=i;if(j(e)||n||!Q3(i)||!Ah(e)||!Ah(t.selection))return i;let r=t.selection.main,o=e.main;for(let s of lr(t).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),E(f))return[i,{annotation:or("table.navigate"),selection:ez({pos:s.from+f})}]}return i},A3=i=>{let{selection:e,startState:t}=i;if(j(e)||!Ah(e))return i;let n=t.selection.main;if(k3(i)){for(let r of lr(t).tables)if(n.head===r.from-1){let o=r.table.firstCellSpan.from;return[{selection:{anchor:r.from+o,head:r.from+o}}]}return i}else if(P3(i)){for(let r of lr(t).tables)if(n.head===r.to+1){let o=r.table.lastCellSpan.to;return[{selection:{anchor:r.from+o,head:r.from+o}}]}return i}else return i};function X3(i){return AS(i)>0||XS(i)>0}var _3=({state:i,docChanged:e,selectionSet:t,transactions:n,view:r})=>{if(!e&&!t&&X3(i)||n.some(a=>jm(a)))return;let{formatting:o}=lr(i);if(Hh(o))return;let s=He.of(o,i.doc.length,i.lineBreak),l=i.selection.map(s);r.dispatch({annotations:or("table.format"),changes:s,selection:l})},E3=i=>{if(!i.docChanged||jm(i))return i;let e=i.changes,{tables:t}=lr(i.startState),n=[];for(let s of t)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(Yl({doc:i.newDoc,lineBreak:i.startState.lineBreak,span:l}).changes)}if(Hh(n))return i;let r=He.of(n,i.changes.newLength,i.startState.lineBreak),o=i.newSelection.map(r);return[i,{annotation:or("table.correct"),changes:r,selection:o,sequential:!0}]};function Z3(i,{anchor:e,head:t,goalColumn:n,bidiLevel:r}={}){return y.range(e??i.anchor,t??i.head,n??i.goalColumn,r??i.bidiLevel??void 0)}var z3=i=>{let{selection:e,startState:t,docChanged:n}=i;if(j(e)||n||Ah(e))return i;let r=e.ranges.map(o=>{if(o.empty)return o;let s=lr(t).tables,l=oQ(o.anchor,s),a=oQ(o.head,s);return E(l)||E(a)?Z3(o,{anchor:l,head:a}):o});return Kn(e.ranges,r,(o,s)=>o===s)?i:[i,{annotations:or("table.select"),selection:y.create(r,e.mainIndex)}]};function oQ(i,e){for(let t of e){let n=t.from,r=t.to,o=t.from+1,s=t.to-1;if(i===n||i===o)return n-1;if(i===r||i===s)return r+1}}var L3={"& .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"}},M3={'&[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"}},q3={".cm-tooltip.tbl-menu-tooltip":{border:"none","user-select":"none","&, &::before, &::after, & *, & *::before, & *::after":{"box-sizing":"border-box"}}},W3={".tbl-blocking-overlay":{position:"absolute",top:0,left:0,"z-index":900,"background-color":"transparent",width:"100%",height:"100%"}},j3={"& .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)"}},D3={".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)"}},V3={'&[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"}},I3={".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}},Y3={".tbl-menu-item-icon":{"z-index":200,width:"1em",height:"1em","pointer-events":"none","font-size":"var(--tbl-style-menu-font-size)"}},B3={".tbl-menu-item-text":{"z-index":200,"pointer-events":"none","user-select":"none","font-size":"var(--tbl-style-menu-font-size)"}},U3={".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)"}}},N3={".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)"}},G3={".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)"}},F3={".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"}},H3={"& .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)"}},K3={...L3,...q3,...M3,...H3,...W3,...D3,...j3,...V3,...I3,...G3,...U3,...Y3,...B3,...N3,...F3},J3=i=>{let e=i.effects.find(t=>t.is(Nk))?.value;return E(e)?{annotations:or(e)}:null},eW=i=>{let e=i.annotation(Wm);return E(e)?[Gk(qM(e))]:[]},wm=class i{static of(e){return e.state.field(Um).view=e,new i}constructor(){}};function tW(i){return[Gp.of(i),Yk,Um,Oe.define(e=>wm.of(e)),$.editorAttributes.compute([Gp,$.darkTheme],v3),$.baseTheme(K3),$.theme("light"in i.theme?{':where(:root:has(&[data-tbl-theme-mode="light"]))':i.theme.light.props,':where(:root:has(&[data-tbl-theme-mode="dark"]))':i.theme.dark.props}:{":where(:root:has(&))":i.theme.props}),$.theme({":where(:root:has(&))":i.style.props}),Td.of(eW),yr.of(Rk),G.transactionExtender.of(J3),G.transactionFilter.of(E3),G.transactionFilter.of(A3),G.transactionFilter.of(R3),G.transactionFilter.of(z3),$.updateListener.of(_3),$.updateListener.of($3),$.clipboardInputFilter.of(Hz),$.focusChangeEffect.of(T3)]}function Fk(i){return tW(aQ(i))}function iW(i,e){if(!j(i))for(let t of i)e(t)}function nW(i,e){j(i)||e(i)}function Hk(i,e,t){if(!Number.isInteger(i)||i<=0)throw new Error(t);if(!Number.isInteger(e)||e<=0)throw new Error(t)}function rW({pos:i,doc:e,lineBreak:t,rows:n,cols:r}){let[o,...s]=Jn(`${"| ".repeat(r)}|`,{count:n}),l=`${"| - ".repeat(r)}|`,{before:a,after:c}=Yl({doc:e,lineBreak:t,span:{from:i-1,to:i}}),h=`${a?.insert??""}${[o,l,...s].join(t)}${c?.insert??""}`;return{label:`${n}\xD7${r} table`,type:"table",apply:(f,u)=>{f.dispatch({annotations:rl.of(u),changes:{from:i-1,to:i,insert:h},selection:{anchor:i+1+(a?.count??0)}})}}}var oW=[{rows:2,cols:2},{rows:3,cols:3},{rows:4,cols:4}];function sW(i){let e=i?.options??oW;return({state:t,pos:n})=>{let r=t.doc.lineAt(n);if(n!==r.from+1||r.length!==1||r.text.slice(0,1)!=="|")return null;let{doc:o,lineBreak:s}=t;return{from:n,options:e.map(({rows:l,cols:a})=>rW({pos:n,doc:o,lineBreak:s,rows:l,cols:a}))}}}function Kk(i){return iW(i?.options,({rows:e,cols:t})=>{Hk(e,t,"options[].{ rows, cols } must be positive integers")}),sW(i)}var lW={rows:2,cols:2};function aW(i){let{rows:e,cols:t}=i?.size??lW;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}=Yl({doc:n.doc,lineBreak:n.lineBreak,span:{from:l,to:a}}),[f,...u]=Jn(`${"| ".repeat(t)}|`,{count:e}),d=`${"| - ".repeat(t)}|`,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 Jk(i){return nW(i?.size,({rows:e,cols:t})=>{Hk(e,t,"size.{rows, cols} must be positive integers")}),aW(i)}var eP=16,tP="50rem",iP="88%",cW=$.theme({"&":{height:"100%",color:"var(--text)",backgroundColor:"var(--card)",fontSize:`${eP}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:"20px 0",caretColor:"var(--text)",minHeight:"100%",minWidth:"0"},".cm-line:not(.tbl-table-widget .cm-line)":{boxSizing:"border-box",width:tP,maxWidth:iP,marginInline:"auto",paddingTop:"var(--md-line-pad-y, 2px)",paddingBottom:"var(--md-line-pad-y, 2px)",lineHeight:"var(--md-line-height, 1.7rem)"},".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:`min(${tP}, ${iP}) !important`,marginInline:"auto !important",padding:"0 16px 16px 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-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)"},".cm-line.cm-md-h1":{fontSize:"1.4em",fontWeight:"700",lineHeight:"normal !important"},".cm-line.cm-md-h2":{fontSize:"1.2em",fontWeight:"700",lineHeight:"normal !important"},".cm-line.cm-md-h3":{fontSize:"1.15em",fontWeight:"700",lineHeight:"normal !important"},".cm-line.cm-md-h4":{fontSize:"1.1em",fontWeight:"700",lineHeight:"normal !important"},".cm-line.cm-md-h5":{fontSize:"1.04em",fontWeight:"700",lineHeight:"normal !important"},".cm-line.cm-md-h6":{fontSize:"1em",fontWeight:"700",lineHeight:"normal !important"},".cm-md-bullet":{display:"inline-block",color:"var(--accent)",fontWeight:"700",textAlign:"center",fontFamily:"monospace"},".\u037Cx":{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-line > .cm-widget:has(.cm-md-image-block)":{display:"inline-block",width:"100%",maxWidth:"100%"},".cm-md-image-block":{display:"inline-block",maxWidth:"100%",margin:"8px 0",lineHeight:"1.4",verticalAlign:"top"},".cm-md-image-block img":{display:"block",maxHeight:"80vh",maxWidth:"100%",width:"auto",borderRadius:"8px",cursor:"zoom-in"},".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-list-line":{paddingLeft:"2ch"},".cm-line.cm-md-code-line":{color:"var(--text)",backgroundColor:"color-mix(in srgb, var(--text) 8%, transparent)",lineHeight:"1.3rem !important",fontFamily:"var(--finch-font-mono)",paddingTop:"0 !important",paddingBottom:"0 !important",paddingLeft:"24px",paddingRight:"24px",fontSize:"13px !important"},".cm-line.cm-md-code-line span":{fontSize:"12px !important"},".cm-line.cm-md-code-open":{fontSize:"12px",borderRadius:"8px 8px 0 0",height:"22px",paddingTop:"2px",paddingLeft:"12px",paddingRight:"12px",lineHeight:"1.5rem !important"},".cm-line.cm-md-code-close":{fontSize:"12px",borderRadius:"0 0 8px 8px",height:"22px",paddingLeft:"12px",paddingRight:"12px"},".cm-md-code-fence-empty":{opacity:"0"},".cm-md-code-copy":{float:"right",height:"20px",margin:"4px -7px",padding:"0 7px",border:"0px",borderRadius:"6px",color:"var(--muted)",backgroundColor:"color-mix(in srgb, var(--card) 88%, transparent)",font:"11px 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-selectionMatch":{backgroundColor:"transparent !important"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--text)"},".cm-gutters":{color:"var(--muted)",backgroundColor:"var(--card)",borderRight:"0px",fontSize:`${12/eP}em`},".cm-gutterElement":{padding:"0px 8px 0 10px"},".cm-lineNumbers .cm-gutterElement":{padding:"0 5px 0 8px",lineHeight:"var(--md-gutter-line-height, 32px)",color:"color-mix(in srgb, var(--muted) 35%, transparent)",fontFamily:"var(--finch-font-mono)",fontSize:"12px"},".cm-lineNumbers .cm-gutterElement.cm-gutter-code-line":{lineHeight:"22px"},".cm-activeLine":{backgroundColor:"color-mix(in srgb, var(--text) 7%, transparent)",boxShadow:["-25vw 0 color-mix(in srgb, var(--text) 7%, transparent)","25vw 0 color-mix(in srgb, var(--text) 7%, transparent)"].join(", ")},".cm-activeLineGutter":{color:"var(--text) !important",backgroundColor:"color-mix(in srgb, var(--text) 7%, 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-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:"color-mix(in srgb, var(--accent) 34%, transparent)"},".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-autocomplete > ul > li[aria-selected]":{color:"var(--text)",backgroundColor:"color-mix(in srgb, var(--accent) 20%, transparent)"}}),hW=[ft.of({name:"JavaScript",alias:["js","mjs","cjs"],extensions:["js","mjs","cjs"],support:qr()}),ft.of({name:"JSX",alias:["jsx"],extensions:["jsx"],support:qr({jsx:!0})}),ft.of({name:"TypeScript",alias:["ts"],extensions:["ts"],support:qr({typescript:!0})}),ft.of({name:"TSX",alias:["tsx"],extensions:["tsx"],support:qr({jsx:!0,typescript:!0})}),ft.of({name:"JSON",alias:["json","json5"],extensions:["json"],support:Vx()}),ft.of({name:"CSS",alias:["css"],extensions:["css"],support:th()}),ft.of({name:"HTML",alias:["html","htm","xml","svg"],extensions:["html"],support:nh()}),ft.of({name:"Python",alias:["python","py"],extensions:["py"],support:aw()}),ft.of({name:"SQL",alias:["sql"],extensions:["sql"],support:Qw()}),ft.of({name:"YAML",alias:["yaml","yml"],extensions:["yaml","yml"],support:qw()}),ft.of({name:"Shell",alias:["bash","sh","shell","zsh","console"],extensions:["sh"],support:new je(ac.define(Iw))})],nP=_o.define([{tag:m.heading,color:"var(--accent)",fontWeight:"700"},{tag:m.strong,color:"var(--text)",fontWeight:"700"},{tag:m.emphasis,fontStyle:"italic"},{tag:m.strikethrough,color:"var(--muted)",textDecoration:"line-through"},{tag:m.monospace,color:"var(--muted)"},{tag:m.link,color:"var(--accent)"},{tag:m.url,color:"var(--muted)",textDecoration:"underline"},{tag:m.quote,color:"var(--muted)"},{tag:m.meta,color:"var(--muted)"},{tag:m.keyword,color:"#c678dd"},{tag:[m.name,m.deleted,m.character,m.propertyName,m.macroName],color:"#e06c75"},{tag:[m.function(m.variableName),m.labelName],color:"#61afef"},{tag:[m.color,m.constant(m.name),m.standard(m.name),m.bool],color:"#d19a66"},{tag:[m.definition(m.name),m.separator],color:"var(--text)"},{tag:[m.typeName,m.className,m.number,m.changed,m.annotation,m.modifier,m.self,m.namespace],color:"#e5c07b"},{tag:[m.operator,m.operatorKeyword,m.escape,m.regexp,m.special(m.string)],color:"#56b6c2"},{tag:m.string,color:"#98c379"},{tag:m.comment,color:"var(--muted)",fontStyle:"italic"},{tag:m.invalid,color:"#fff",backgroundColor:"#e06c75"}]),rP=/^(#{1,6})(?:\s|$)/;function oP(i){let e=new Ke,t=i.state.doc;for(let n=1;n<=t.lines;n++){let r=t.line(n),o=r.text,s=rP.exec(o),l=o.trim().length===0,a;if(s)a=`cm-md-h${s[1].length}`;else if(l&&n<t.lines){let c=t.line(n+1).text;c.trim().length>0&&(a=rP.test(c)?"cm-md-gap-heading":"cm-md-gap")}a&&e.add(r.from,r.from,X.line({class:a}))}return e.finish()}var fW=Oe.fromClass(class{decorations;constructor(i){this.decorations=oP(i)}update(i){(i.docChanged||i.viewportChanged)&&(this.decorations=oP(i.view))}},{decorations:i=>i.decorations}),sP=/`([^`\n]+)`/g,Os=/^\s*```+\s*([^\s`]*)?\s*$/,pP=/^\s{0,3}(?:(?:-\s*){3,}|(?:\*\s*){3,}|(?:_\s*){3,})$/,uW=/^(\s*)([-+*])(?=\s+)/,dW=/^(\s*>\s?)/,Mi=X.replace({}),OW=X.mark({class:"cm-md-inline-code"});function Nm(i){let e=i.trim();return/^https?:\/\//i.test(e)?e:null}function Gm(i){return X.mark({class:"cm-md-link",attributes:{"data-md-href":i,role:"link",title:i}})}var Fm=class extends Ze{constructor(t,n){super();this.src=t;this.alt=n}src;alt;captionEl=null;eq(t){return t.src===this.src&&t.alt===this.alt}ignoreEvent(t){return!!(this.captionEl&&t.target instanceof Node&&this.captionEl.contains(t.target))}toDOM(t){let n=document.createElement("span");n.className="cm-md-image-block";let r=document.createElement("img");r.src=this.src,r.alt=this.alt,r.dataset.mdImageSrc=this.src,r.title=this.alt||this.src,n.appendChild(r);let o=document.createElement("div");return o.className="cm-md-image-caption",o.contentEditable="plaintext-only",o.contentEditable!=="plaintext-only"&&(o.contentEditable="true"),o.spellcheck=!1,o.dataset.placeholder="\u6DFB\u52A0\u56FE\u7247\u8BF4\u660E\u2026",o.textContent=this.alt,o.addEventListener("paste",s=>{s.preventDefault();let l=s.clipboardData?.getData("text/plain")??"";document.execCommand("insertText",!1,l.replace(/[\r\n]+/g," "))}),o.addEventListener("keydown",s=>{s.key==="Enter"?(s.preventDefault(),o.blur()):s.key==="Escape"&&(s.preventDefault(),o.textContent=this.alt,o.blur())}),o.addEventListener("input",()=>{o.textContent||o.replaceChildren()}),o.addEventListener("blur",()=>pW(t,n,this.alt,o.textContent??"")),n.appendChild(o),this.captionEl=o,n}};function pW(i,e,t,n){if(n===t)return;let r;try{r=i.posAtDOM(e)}catch{return}let o=i.state.doc.lineAt(Math.min(r,i.state.doc.length)),s=[];B(i.state).iterate({from:o.from,to:o.to,enter:h=>{if(h.name==="Image"&&h.from<=r&&r<=h.to)return s.push({from:h.from,to:h.to}),!1}});let l=s[0];if(!l)return;let a=i.state.sliceDoc(l.from,l.to),c=/^!\[[^\]]*\](\([^)]*\))/.exec(a);c&&i.dispatch({changes:{from:l.from,to:l.to,insert:`![${n}]${c[1]}`}})}function lP(i){let e=[];return B(i).iterate({enter:t=>{if(t.name!=="Image")return;if(i.doc.lineAt(t.from).text.trim()!==i.sliceDoc(t.from,t.to))return!1;let r=t.node.getChild("URL");if(!r)return!1;let o=i.sliceDoc(t.from,t.to),s=/^!\[([^\]]*)\]/.exec(o)?.[1]??"",l=i.sliceDoc(r.from,r.to).trim();return l&&e.push(X.replace({widget:new Fm(l,s),inclusive:!1}).range(t.from,t.to)),!1}}),X.set(e,!0)}var mP=de.define({create:lP,update(i,e){return e.docChanged?lP(e.state):i.map(e.changes)},provide:i=>$.decorations.from(i)}),mW=$.atomicRanges.of(i=>i.state.field(mP));function gW(i){let e=[],t=[],n=B(i.state);return n.iterate({enter:r=>{r.name==="URL"&&t.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||Jl(i,r.from,r.to))return!1;let l=Nm(i.state.sliceDoc(o.from,o.to)),a=s[0],c=s[1];return!l||a.to>=c.from||(e.push(Mi.range(a.from,a.to)),e.push(Gm(l).range(a.to,c.from)),e.push(Mi.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||Jl(i,r.from,r.to))return!1;let l=Nm(i.state.sliceDoc(o.from,o.to));return l&&(e.push(Mi.range(s[0].from,s[0].to)),e.push(Gm(l).range(o.from,o.to)),e.push(Mi.range(s[s.length-1].from,s[s.length-1].to))),!1}if(r.name==="URL"){if(Jl(i,r.from,r.to))return;let o=Nm(i.state.sliceDoc(r.from,r.to));o&&e.push(Gm(o).range(r.from,r.to))}}}),{decorations:e,urlRanges:t}}function bW(i){let e=[];return B(i.state).iterate({enter:t=>{if(t.name==="Table"||t.name==="Image")return!1;let n=t.name==="Strikethrough"?"StrikethroughMark":t.name==="Emphasis"||t.name==="StrongEmphasis"?"EmphasisMark":void 0;if(n){if(Jl(i,t.from,t.to))return!1;for(let r of t.node.getChildren(n))e.push(Mi.range(r.from,r.to))}}}),e}function SW(i,e,t){return t.some(n=>i<n.to&&e>n.from)}function gP(i){return i.button!==0||!(i.target instanceof Element)?null:i.target.closest(".cm-md-link[data-md-href]")}function vW(i){return gP(i)?(i.preventDefault(),i.stopPropagation(),!0):!1}function xW(i,e){let t=gP(i)?.dataset.mdHref;return t?(i.preventDefault(),i.stopPropagation(),e?.(t),!0):!1}function bP(i){return i.button!==0||!(i.target instanceof Element)?null:i.target.closest(".cm-md-image-block img[data-md-image-src]")}function wW(i){return bP(i)?(i.preventDefault(),i.stopPropagation(),!0):!1}function yW(i,e){let t=bP(i)?.dataset.mdImageSrc;return t?(i.preventDefault(),i.stopPropagation(),e?.(t),!0):!1}var Hm=class extends Rt{elementClass="cm-gutter-code-line"},QW=new Hm;function aP(i){let e=new Ke,t=!1;for(let n=1;n<=i.lines;n++){let r=i.line(n),o=Os.test(r.text);(o||t)&&e.add(r.from,r.from,QW),o&&(t=!t)}return e.finish()}var cP=de.define({create:i=>aP(i.doc),update:(i,e)=>e.docChanged?aP(e.state.doc):i}),kW=[cP,ko.from(cP)],Km=class extends Ze{toDOM(){let e=document.createElement("span");return e.className="cm-md-bullet",e.textContent="\u2022",e.setAttribute("aria-hidden","true"),e}},Jm=class extends Ze{constructor(t){super();this.position=t}position;eq(t){return t.position===this.position}toDOM(t){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",()=>{t.dispatch({selection:{anchor:this.position}}),t.focus()}),n}},eg=class extends Ze{constructor(t,n){super();this.language=t;this.code=n}language;code;eq(t){return t.language===this.language&&t.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 t=document.createElement("button");return t.type="button",t.className="cm-md-code-copy",t.textContent=this.language.toUpperCase(),t.title="\u590D\u5236\u4EE3\u7801\u5757",t.addEventListener("mousedown",n=>n.preventDefault()),t.addEventListener("click",async n=>{n.preventDefault(),n.stopPropagation();let r=t.textContent||this.language.toUpperCase();try{await navigator.clipboard.writeText(this.code),t.textContent="\u5DF2\u590D\u5236"}catch{t.textContent="\u590D\u5236\u5931\u8D25"}window.setTimeout(()=>{t.textContent=r},1200)}),t}};function hP(i,e,t){return i.state.selection.ranges.some(n=>n.empty?n.head>=e&&n.head<=t:n.from<=t&&n.to>=e)}function Jl(i,e,t){let n=i.state.doc.lineAt(e);return i.state.selection.ranges.some(r=>r.empty?r.head>=n.from&&r.head<=n.to&&r.head>=e-1&&r.head<=t+1:r.from<=n.to&&r.to>=n.from&&r.from<=t+1&&r.to>=e-1)}function PW(i){let e=i.state.doc,t=new Map,n=0,r="";for(let o=1;o<=e.lines;o++){let s=e.line(o),l=Os.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(`
40
+ `:l.textContent??""})??"",r=(e.textContent??"").slice(0,Fy(i)),o=Qt(`${n}${r}`),s=n.length+Fy(i);return qk({anchor:s,head:s},o,{trim:!1})}function Cq(i,e){var t=Lm(),n=ze(t);ao(n,()=>e.children),z(i,t)}function Tq(i,e){cr(e,!0),rf(()=>{let t=uk(Cq,{target:e.to,context:ZL(),props:{children:e.children}});return()=>{dk(t)}}),hr()}_L();var Rq=oe('<div class="tbl-blocking-overlay" aria-hidden="true"></div>');function Aq(i){var e=Rq();z(i,e)}function Ih(i,e){let t=e.devicePixelRatio;return Tz(i*t)/t}function Xq({x:i,y:e},t){return{x:Ih(i,t),y:Ih(e,t)}}var _q=oe('<th class="tbl-cell tbl-header-cell"><!></th>'),Eq=oe('<td class="tbl-cell tbl-data-cell"><!></td>');function Zq(i,e){cr(e,!0);let t=N(()=>Gy(E(e.movement)?e.movement.border:{top:e.position.top,right:!0,bottom:!0,left:e.position.left})),n=N(()=>Gy(e.outline)),r=N(()=>{if(j(e.movement?.translate))return;let{x:c,y:h}=e.movement.state==="moving"?Xq(e.movement.translate,e.win):e.movement.translate;return`translate3d(${c}px, ${h}px, 0px)`});var o=Lm(),s=ze(o);{var l=c=>{var h=_q();let f;var u=pi(h);ao(u,()=>e.children),yt(d=>{Pe(h,"align",e.alignment==="none"?void 0:e.alignment),Pe(h,"data-component",Il),Pe(h,"data-row",e.location.row),Pe(h,"data-col",e.location.col),Pe(h,"data-border",Q(t)),Pe(h,"data-outline",Q(n)),Pe(h,"data-selected",d),Pe(h,"data-state",e.movement?.state),f=qh(h,"",f,{transform:Q(r)})},[()=>ro(e.selected)]),z(c,h)},a=c=>{var h=Eq();let f;var u=pi(h);ao(u,()=>e.children),yt(d=>{Pe(h,"align",e.alignment==="none"?void 0:e.alignment),Pe(h,"data-component",Il),Pe(h,"data-row",e.location.row),Pe(h,"data-col",e.location.col),Pe(h,"data-border",Q(t)),Pe(h,"data-outline",Q(n)),Pe(h,"data-selected",d),Pe(h,"data-state",e.movement?.state),f=qh(h,"",f,{transform:Q(r)})},[()=>ro(e.selected)]),z(c,h)};ut(s,c=>{e.position.top?c(l):c(a,!1)})}z(i,o),hr()}function Wk(i){return E(Dl(i.dom).activeElement?.closest(".cm-panels"))}function Jy(i){return i.trim().split(/\s+/)}function zq({doc:i,selection:e,parent:t,extensions:n,markdownConfig:r,selectionType:o,lineWrapping:s,globalKeyBindings:l,rootEditor:a,highlighter:c,onChange:h,eventHandlers:f}){return new $({doc:i,selection:e,parent:t,extensions:[n,vt.lowest([$.editorAttributes.of(u=>{let d=new Set(Jy(a.themeClasses)),O=new Set(Jy(u.themeClasses));return{class:[...d.difference(O)].join(" ")}}),Yt.of([...l.map(u=>({...u,run:E(u.run)?()=>u.run(a):void 0,shift:E(u.shift)?()=>u.shift(a):void 0}))]),o==="codemirror"?Na():[],Ar(c),Dr({extensions:[hQ,r.extensions??[]],addKeymap:!1,completeHTMLTags:r.completeHTMLTags,pasteURLAsLink:r.pasteURLAsLink,htmlTagLanguage:r.htmlTagLanguage}),$.domEventObservers(f),s==="wrap"?$.lineWrapping:[]])],dispatchTransactions:(u,d)=>{d.update(u),u.forEach(h)}})}var Lq=oe('<div class="tbl-cell-editor"></div>');function Mq(i,e){cr(e,!0);let t=sm(e,"text",15),n=sm(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=E(d);if(f||O){if(f){let p=Qm(u,{trim:!0});p.eq(t())||(t(p),l=!0)}if(O){let{head:p,anchor:g}=d.main,b=qk({head:p,anchor:g},u,{trim:!0});$k(b,n())||(n(b),l=!0)}}}Dm([()=>t(),()=>n()],()=>{if(l){l=!1;return}s=!0,o.dispatch({changes:o.state.changes({from:0,to:o.state.doc.length,insert:zh(t())}),selection:Ky(n(),t())}),s=!1},{lazy:!0}),rf(()=>(o=zq({doc:zh(t()),selection:Ky(n(),t()),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}}),Wk(o)||o.focus(),()=>o.destroy()));var c=Lq();Wh(c,h=>r=h,()=>r),z(i,c),hr()}var Yh=class i{event;tableState;position;static navigate(e){new i(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||j(this.tableState.outlinedSection)||j(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),j(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=Pk(this.tableState.activeCell)}}navigateShiftArrowUp(){if(!(!this.position.top||j(this.tableState.outlinedSection)||j(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),j(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=yk(this.tableState.activeCell)}}navigateShiftArrowRight(){if(!(!this.position.right||j(this.tableState.outlinedSection)||j(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),j(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=Qk(this.tableState.activeCell)}}navigateShiftArrowDown(){if(!(!this.position.bottom||j(this.tableState.outlinedSection)||j(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),j(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=kk(this.tableState.activeCell)}}moveLeft({createRow:e,position:t}){if(!j(this.tableState.activeCell)){if(this.event.preventDefault(),ho(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},t)}}moveUp({createRow:e,position:t}){if(!j(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},t)}}moveRight({createRow:e,position:t}){if(!j(this.tableState.activeCell)){if(this.event.preventDefault(),ho(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},t)}}moveDown({createRow:e,position:t}){if(!j(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},t)}}moveTo(e,t){if(this.tableState.activeCell=e,this.tableState.anchorCell=e,this.tableState.outlinedSection=Ne.ofCell(e),this.tableState.selection.isCell()){let n=t==="start"?0:this.tableState.table.cellAt(e).length;this.tableState.selectionValue={cell:e,section:{anchor:n,head:n}}}}constructor({event:e,tableState:t,position:n}){this.event=e,this.tableState=t,this.position=n}},Se={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"},qq=[Se.arrowDown,Se.arrowLeft,Se.arrowRight,Se.arrowUp,Se.enter,Se.tab,`${Se.shift}${Se.arrowDown}`,`${Se.shift}${Se.arrowLeft}`,`${Se.shift}${Se.arrowRight}`,`${Se.shift}${Se.arrowUp}`,`${Se.shift}${Se.tab}`],eQ=new Set(qq);function jk({key:i,shiftKey:e,altKey:t,metaKey:n,ctrlKey:r}){if(!(t||n||r))return e?eQ.has(`${Se.shift}${i}`)?`${Se.shift}${i}`:void 0:eQ.has(i)?i:void 0}function Wq(i,e){i.inputType==="historyUndo"?(e.undo(),i.preventDefault()):i.inputType==="historyRedo"&&(e.redo(),i.preventDefault())}function jq(i){i.preventDefault()}function Dq(i,e,t){let n=jk(i);if(j(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};Yh.navigate({tableState:t,key:n,event:i,position:h})}function Vq(i,e){Vm({tableState:e,event:i})}var Iq=oe('<div class="tbl-cell-view" contenteditable="" tabindex="-1"><!></div>');function Yq(i,e){cr(e,!0);var t=Iq(),n=pi(t);ao(n,()=>e.children),yt(r=>{Pe(t,"data-component",Im),Pe(t,"data-hidden",r)},[()=>ro(e.hidden)]),z(i,t),hr()}var Dk="Handle";function Ym(i){if(!vk(i,{component:Dk}))return;let{type:e,location:t}=Mm(i).dataset;if(e==="table")return{type:e,location:t};{let n=lf(Kl(i));return pq({location:t,type:e},n)}}var Bq=bi('<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>'),Uq=bi('<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>'),Nq=oe('<div class="tbl-handle" role="button" aria-hidden="true"><!></div>');function tQ(i,e){cr(e,!0);let t=sm(e,"toggle",3,!1),n={table:{right:"vertical",bottom:"horizontal"},header:{row:"vertical",col:"horizontal"}},r=N(()=>n[e.of.type]?.[e.of.location]);var o=Nq();qh(o,"",{},{opacity:"var(--tbl-handle-opacity, 0)"});var s=pi(o);{var l=c=>{var h=Bq();z(c,h)},a=c=>{var h=Uq();z(c,h)};ut(s,c=>{Q(r)==="horizontal"?c(l):Q(r)==="vertical"&&c(a,1)})}yt((c,h,f)=>{Pe(o,"data-component",Dk),Pe(o,"data-type",e.of.type),Pe(o,"data-location",e.of.location),Pe(o,"data-active",c),Pe(o,"data-hover",h),Pe(o,"data-toggle",f)},[()=>ro(e.state==="active"),()=>ro(e.state==="hover"),()=>ro(t())]),z(i,o),hr()}var Gq=oe('<div class="tbl-menu"><!></div>');function Fq(i,e){cr(e,!0);let t,n=ae(void 0);rf(()=>{e.translate(t).then(l=>I(n,l,!0))});var r=Gq();let o;var s=pi(r);ao(s,()=>e.children),Wh(r,l=>t=l,()=>t),yt(l=>o=qh(r,"",o,l),[()=>({visibility:E(Q(n))?void 0:"hidden",transform:E(Q(n))?`translate3d(${Q(n).x}px, ${Q(n).y}px, 0px)`:void 0})]),z(i,r),hr()}var Hq=oe('<div class="tbl-menu-item" role="menuitem" tabindex="-1"><!></div>');function Kt(i,e){var t=Hq(),n=pi(t);ao(n,()=>e.children),El("click",t,function(...r){e.onclick?.apply(this,r)}),z(i,t)}fk(["click"]);function Jt(i,e){switch(i.action){case"add":return e.menu.clickAdd(i.direction);case"align":return e.menu.clickAlign(i.alignment);case"clear":return e.menu.clickClear();case"duplicate":return e.menu.clickDuplicate();case"move":return e.menu.clickMove(i.direction);case"remove":return e.menu.clickRemove();case"sort":return e.menu.clickSort(i.direction)}}var Kq=bi('<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>'),Jq=bi('<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>'),e4=bi('<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>'),t4=bi('<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>'),i4=bi('<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>'),n4=bi('<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>'),r4=bi('<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>'),o4=bi('<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>'),s4=bi('<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>'),l4=bi('<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>'),a4=oe('<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 ei(i,e){var t=a4(),n=pi(t),r=pi(n);{var o=S=>{var v=Kq();z(S,v)},s=S=>{var v=Jq();z(S,v)},l=S=>{},a=S=>{var v=e4();z(S,v)},c=S=>{var v=t4();z(S,v)},h=S=>{var v=i4();z(S,v)},f=S=>{var v=n4();z(S,v)},u=S=>{var v=r4();z(S,v)},d=S=>{var v=o4();z(S,v)},O=S=>{var v=s4();z(S,v)},p=S=>{},g=S=>{},b=S=>{var v=l4();z(S,v)};ut(r,S=>{e.name==="sort-ascending"?S(o):e.name==="sort-descending"?S(s,1):e.name==="align-none"?S(l,2):e.name==="align-left"?S(a,3):e.name==="align-center"?S(c,4):e.name==="align-right"?S(h,5):e.name==="move-up"?S(f,6):e.name==="move-right"?S(u,7):e.name==="move-down"?S(d,8):e.name==="move-left"?S(O,9):e.name==="duplicate"?S(p,10):e.name==="clear"?S(g,11):e.name==="remove"&&S(b,12)})}z(i,t)}var c4=oe('<div class="tbl-menu-item-text"><!></div>');function ti(i,e){var t=c4(),n=pi(t);ao(n,()=>e.children),z(i,t)}var h4=oe('<div class="tbl-menu-separator"></div>');function Ph(i){var e=h4();z(i,e)}var f4=oe('<div class="tbl-select-all-overlay" aria-hidden="true"></div>');function u4(i){var e=f4();z(i,e)}var d4=new Set([Se.c,Se.v,Se.x]);function O4(i,e){return d4.has(i.key)&&i[Jz(e)]}var p4=[Se.backspace,Se.delete],m4=new Set(p4);function g4({key:i}){return m4.has(i)?i:void 0}function b4(i){return/^F\d+$/.test(i)}var S4=new Set([Se.alt,Se.escape,Se.enter,Se.shift]);function v4({metaKey:i,ctrlKey:e,key:t}){return!e&&!i&&!S4.has(t)&&!b4(t)}function x4(i,e){e.selection.isCell()||Zk({tableState:e,event:i})}function w4(i,e){e.selection.isCell()||zk({tableState:e,event:i})}function y4(i,e){e.selection.isCell()||Vm({tableState:e,event:i})}function Q4(i,e){if(E(i.target)&&E(Mk(i.target))){i.preventDefault();return}if(!e.interactive||e.selection.isCell())return;let t=jk(i);if(E(t)){Yh.navigate({tableState:e,key:t,event:i,position:{left:!0,top:!0,right:!0,bottom:!0}});return}let n=g4(i);if(E(n)){Ek({tableState:e,event:i});return}if(e.activeTable&&E(e.activeCell)&&v4(i)){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=Ne.ofCell(e.activeCell);return}O4(i,e.window)||Ua(e.rootEditor,i,"editor")&&i.preventDefault()}function Bm(i){return i.buttons===1}function Vk(i,e){return e.setPointerCapture(i.pointerId),()=>e.releasePointerCapture(i.pointerId)}var Bh=class i{offset;maxScroll;boundaryElement;scrollElement;scroll;handle;xAmount;yAmount;updatePosition(e,t){let n=this.boundaryElement.x.getBoundingClientRect();e<n.left+this.offset?this.xAmount=-kt(this.offset+(n.left-e),{max:this.maxScroll}):e>n.right-this.offset?this.xAmount=kt(this.offset-(n.right-e),{max:this.maxScroll}):this.xAmount=0;let r=this.boundaryElement.y.getBoundingClientRect();t<r.top+this.offset?this.yAmount=-kt(this.offset+(r.top-t),{max:this.maxScroll}):t>r.bottom-this.offset?this.yAmount=kt(this.offset-(r.bottom-t),{max:this.maxScroll}):this.yAmount=0,j(this.handle)&&(this.xAmount!==0||this.yAmount!==0)&&this.scroll()}destroy(){E(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 i(e)}constructor({offset:e,maxScroll:t,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=t,this.boundaryElement=n,this.scrollElement=r}},Uh=class i{start;size;get mid(){return this.start+this.size/2}get end(){return this.start+this.size}static of(e){return new i(e)}constructor({start:e,size:t}){this.start=e,this.size=t}},Nh;(i=>{function e(t,n){return pm.of(t,n)}i.of=e})(Nh||(Nh={}));var pm=class i{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,t){return e==="row"?this.rowAt(t):this.colAt(t)}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 Zh(...this.rows.map(e=>e.size))}get minColSize(){return Zh(...this.cols.map(e=>e.size))}moveRowOrColAt(e,{fromIndex:t,toIndex:n}){if(t===n)return;let r=this.rowsOrCols(e),o=r[t];if(t<n){for(let s of ir({start:t,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 ir({start:t,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 t=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:t===-1?0:t,col:n===-1?0:n}}static of(e,t){return new i(e,t)}constructor(e,t){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}=iQ(o,t),c=0;return Uh.of({start:l+c,size:a-c})}),this.cols=n.map((o,s)=>{let{left:l,width:a}=iQ(o,t),c=s===0?1:0;return Uh.of({start:l+c,size:a-c})})}};function iQ(i,e){let{top:t,left:n,width:r,height:o}=i.getBoundingClientRect();return{top:t+e.y,left:n+e.x,width:r,height:o}}var Gh=class i{tableState;tableMeasurement;autoScroller;shouldAutoScroll;removeEventListeners;currentCell;start(){this.tableState.activeCell=this.currentCell,this.tableState.anchorCell=this.currentCell,this.tableState.outlinedSection=Ne.ofCell(this.currentCell),this.tableState.outline={outlined:!1},this.removeEventListeners=co(Le(this.tableState.window,"pointermove",e=>this.drag(e)),Le(this.tableState.window,"pointerup",()=>this.end()),Le(this.tableState.window,"pointerleave",()=>this.end()))}resizeAndContinue(e){e.preventDefault(),j(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.currentCell),this.expandOrContract(this.currentCell),this.tableState.outline={outlined:!0},this.removeEventListeners=co(Le(this.tableState.window,"pointermove",t=>this.drag(t)),Le(this.tableState.window,"pointerup",()=>this.end()),Le(this.tableState.window,"pointerleave",()=>this.end()))}drag(e){if(!Bm(e)){this.end();return}e.preventDefault(),this.shouldAutoScroll()&&this.autoScroller.updatePosition(e.clientX,e.clientY);let t=this.tableMeasurement.lastCellBeforePosition({x:e.clientX+this.tableState.scrollOffsetX,y:e.clientY+this.tableState.scrollOffsetY});ho(t,this.currentCell)||(this.currentCell=t,this.tableState.outline={outlined:!0},this.expandOrContract(t))}end(){this.removeEventListeners?.(),this.autoScroller.destroy(),this.tableState.outline=void 0}expandOrContract(e){this.tableState.focusTable();let[t,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=Ne.of({row:{start:t,endExclusive:n+1},col:{start:r,endExclusive:o+1}}),this.tableState.activeCell=e}static startOutline(e){new i(e).start()}static resizeAndContinueOutline(e){new i(e).resizeAndContinue(e.event)}constructor({tableState:e,cellLocation:t}){this.tableState=e,this.currentCell=t,this.autoScroller=Bh.of({offset:10,maxScroll:32,boundaryElement:{x:e.scrollElement,y:e.rootScrollElement},scrollElement:{x:e.scrollElement,y:e.rootScrollElement}}),this.shouldAutoScroll=_M({delayMillis:500}),this.tableMeasurement=Nh.of(e.tableElement,{x:e.scrollOffsetX,y:e.scrollOffsetY})}};function k4(i,e){Kh(e.window)&&(e.hoveredCell=i)}function P4(i){Kh(i.window)&&(i.hoveredCell=void 0)}function $4(i,e,t){if(!(!t.interactive||!Bm(i)))if(i.shiftKey){if(t.selection.isCell()&&ho(e,t.selection.cell))return;Gh.resizeAndContinueOutline({event:i,tableState:t,cellLocation:e})}else Gh.startOutline({event:i,tableState:t,cellLocation:e})}var C4=new Intl.Collator(navigator.language,{numeric:!0,sensitivity:"base"});function nQ(i,e){return C4.compare(i,e)}function T4({metaKey:i,shiftKey:e,altKey:t,ctrlKey:n,key:r}){return r===Se.escape&&!e&&!t&&!i&&!n}var mm=class i{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=co(Le(e,"pointerdown",s=>{s.preventDefault(),(j(s.target)||!mk(this.tableState.menuRootElement,s.target))&&this.close()}),Le(e,"wheel",s=>s.preventDefault(),{passive:!1}),Le(e,"keydown",s=>{s.preventDefault(),T4(s)&&this.close()})),this.tableState.focusTable(),this.tableState.activeHandle={state:"active",handle:this.handle},this.tableState.outlinedSection=Ne.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 t=this.rowOrCol==="row"?{row:this.index,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:this.index};this.tableState.activeCell=t,this.tableState.anchorCell=t;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 t=await by({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:[my({allowedPlacements:this.rowOrCol==="row"?["right-start","right-end"]:["right-start","right"]}),gy({crossAxis:!0})]}),n=ds(e);return{x:Ih(t.x,n),y:Ih(t.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 t=Bp(this.rowOrCol,this.tableState.activeCell,"forward");this.tableState.activeCell=t,this.tableState.anchorCell=t}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 t=Bp(this.rowOrCol,this.tableState.activeCell,e);this.tableState.activeCell=t,this.tableState.anchorCell=t,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=Bp(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"?(t,n)=>nQ(t.toString(),n.toString()):(t,n)=>nQ(n.toString(),t.toString())),this.close()}static showMenu(e){new i(e).open()}constructor({tableState:e,handle:t,point:n}){this.tableState=e,this.handle=t,this.point=n}},gm=class i{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:t,move:n}=this.calculateDrag();return this.currentIndex=t,this.initialIndex!==this.currentIndex&&(this.dragged=!0),E(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 t=this.isRowOrColExposed(e[this.rowOrCol]),n=this.subject.containsCell(e);return this.rowOrCol==="row"?{top:t,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:t}}cellState(e){return this.subject.containsCell(e)?"moving":"shiftable"}cellTranslate(e){let t=this.rowOrColTranslate(e[this.rowOrCol]);return this.rowOrCol==="row"?{x:0,y:t}:{x:t,y:0}}isRowOrColExposed(e){let t=this.reorderIndex(e),n=t===this.tableMeasurement.firstRowOrColIndex(this.rowOrCol),r=t===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 kt(this.currentPosition-this.initialPosition,{min:this.minBound,max:this.maxBound});let t=this.rowOrColShift;return j(t)?0:er(e,t.range)?t.positionDiff:0}reorderIndex(e){let t=this.rowOrColShift;return j(t)?e:e===this.initialIndex?this.currentIndex:er(e,t.range)?e+t.indexDiff:e}calculateDrag(){let e=this.tableMeasurement.rowsOrCols(this.rowOrCol),t={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=Qz(kz([t,n,r]),(s,l)=>Up(this.currentPosition-s.mid)-Up(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 i(e)}constructor({rowOrCol:e,index:t,position:n,subject:r,tableElement:o,scrollOffsetX:s,scrollOffsetY:l}){this.scrollOffsetX=s,this.scrollOffsetY=l;let a=Nh.of(o,{x:this.scrollOffsetX(),y:this.scrollOffsetY()});this.rowOrCol=e,this.coordinate=e==="row"?"y":"x",this.initialIndex=t,this.initialPosition=n[this.coordinate],this.minBound=a.firstRowOrCol(this.rowOrCol).start-a.rowOrColAt(this.rowOrCol,t).start,this.maxBound=a.lastRowOrCol(this.rowOrCol).end-a.rowOrColAt(this.rowOrCol,t).end,this.size=a.rowOrColAt(this.rowOrCol,t).size,this.subject=r,this.dragged=!1,this.tableMeasurement=a,this.currentIndex=t,this.currentPosition=n[this.coordinate]}},bm=class i{tableState;rowOrCol;index;onClick;moveTracker;subject;autoScroller;removeEventListeners;start(e){e.preventDefault();let t=this.moveTracker.start();this.tableState.outlinedSection=this.subject,this.tableState.move=t,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=Mm(e.target);this.removeEventListeners=co(Vk(e,r),Le(r,"pointermove",o=>this.drag(o)),Le(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=Ne.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 t=this.rowOrCol==="row"?{row:e.toIndex,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:e.toIndex};this.tableState.activeCell=t,this.tableState.anchorCell=t}this.tableState.move=void 0,this.tableState.activeHandle=void 0,!e.moved&&!e.dragged&&this.onClick()}static startMove(e){new i(e).start(e.event)}constructor({event:e,tableState:t,rowOrCol:n,index:r,onClick:o}){this.tableState=t,this.rowOrCol=n,this.index=r,this.subject=Ne.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=Bh.of({offset:16,maxScroll:32,boundaryElement:{x:t.scrollElement,y:t.rootScrollElement},scrollElement:{x:t.scrollElement,y:t.rootScrollElement}}),this.moveTracker=gm.of({subject:this.subject,rowOrCol:n,index:r,position:{x:e.clientX+t.scrollOffsetX,y:e.clientY+t.scrollOffsetY},tableElement:t.tableElement,scrollOffsetX:()=>this.tableState.scrollOffsetX,scrollOffsetY:()=>this.tableState.scrollOffsetY})}};function R4(i){return i==="row"?"y":"x"}var Sm=class i{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"),t=this.calculateClickRowOrCol("col");return{operation:{row:e.operation.row,col:t.operation.col},activeHandle:e.activeHandle,activeCell:E(e.activeCell)&&E(t.activeCell)?{row:e.activeCell.row,col:t.activeCell.col}:void 0,anchorCell:E(e.anchorCell)&&E(t.anchorCell)?{row:e.anchorCell.row,col:t.anchorCell.col}:void 0,outlinedSection:E(e.outlinedSection)&&E(t.outlinedSection)?Ne.of({row:e.outlinedSection.row,col:t.outlinedSection.col}):void 0}}calculateClickRowOrCol(e){let t=this.type==="table"?this.tableState.table.lastRowOrColIndex(e)+1:this.initialHandle.index;return{operation:{[e]:{action:"add",index:t,count:1}},activeHandle:this.type==="table"?void 0:{state:"hover",handle:{type:"border",location:this.handleLocationAt(t),index:t}},...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 t=this.calculateDragRowOrCol("row",e),n=this.calculateDragRowOrCol("col",e);if(j(t)&&j(n))return;let r=t??this.calculateCellMovement("row",this.rowOrColDiff("row")),o=n??this.calculateCellMovement("col",this.rowOrColDiff("col"));return{operation:{row:t?.operation.row,col:n?.operation.col},activeHandle:t?.activeHandle??n?.activeHandle,activeCell:E(r.activeCell)&&E(o.activeCell)?{row:r.activeCell.row,col:o.activeCell.col}:void 0,anchorCell:E(r.anchorCell)&&E(o.anchorCell)?{row:r.anchorCell.row,col:o.anchorCell.col}:void 0,outlinedSection:E(r.outlinedSection)&&E(o.outlinedSection)?Ne.of({row:r.outlinedSection.row,col:o.outlinedSection.col}):void 0}}calculateDragRowOrCol(e,t){let n=R4(e),r=t.position[n]-this.initialPosition[n],o=Rz(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:Zh(-a,c,this.tableState.table.lastRowOrColIndex(e))})}calculateDragRowOrColLess({rowOrCol:e,start:t,length:n}){let r=0;for(let s of ir({start:t-1,endExclusive:t-n-1})){if(!this.tableState.table.hasEmptyRowOrColAt(e,s))break;r++}if(r===0)return;let o=t-(r-1)-1;return{operation:{[e]:{action:"remove",index:t-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:t,length:n}){return{operation:{[e]:{action:"add",index:t,count:n}},activeHandle:{state:"active",handle:this.type==="table"?this.initialHandle:{type:"border",location:this.handleLocationAt(t+n),index:t+n}},...this.calculateCellMovement(e,this.rowOrColDiff(e)+n)}}calculateCellMovement(e,t){let n=this.type==="table"?this.initialRowOrColCount[e]:this.initialHandle.index;if(t>=0)return{outlinedSection:this.initialOutlinedSection?.addForwardsByRowOrCol(e,{start:n,count:t}),activeCell:E(this.initialActiveCell)?By(e,this.initialActiveCell,{start:n,count:t}):void 0,anchorCell:E(this.initialAnchorCell)?By(e,this.initialAnchorCell,{start:n,count:t}):void 0};{let r=-t,o=this.initialOutlinedSection?.subtractBackwardsByRowOrCol(e,{start:n,count:r,min:this.tableState.table.firstRowOrColIndex(e)}),s=E(o)?{min:o.startRowOrCol(e),max:o.endRowOrCol(e)}:void 0,l=E(this.initialActiveCell)?Uy(e,this.initialActiveCell,{start:n,count:r,boundary:s}):void 0,a=E(this.initialAnchorCell)?Uy(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 i(e)}constructor({tableState:e,handle:t,position:n,cellSizePixels:r,dragThresholdPixels:o}){this.tableState=e,this.type=this.handleToType(t),this.initialHandle=t,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 A4(i){let e=Dh(i.tableElement,i.table.firstCellLocation),t=kq(e),{minWidth:n}=getComputedStyle(e),{lineHeight:r,paddingTop:o,paddingBottom:s}=getComputedStyle(t),l=parseFloat(n)+1,a=parseFloat(r)+parseFloat(o)+parseFloat(s)+1;return{width:l,height:a}}var vm=class i{tableState;resizeTracker;removeEventListeners;start(e){e.preventDefault();let t=this.resizeTracker.start();this.tableState.resize={},this.tableState.activeHandle=t.activeHandle,this.tableState.focusTable(),this.removeEventListeners=co(Vk(e,this.tableState.tableElement),Le(this.tableState.tableElement,"pointermove",n=>this.drag(n)),Le(this.tableState.tableElement,"pointerup",()=>this.end()))}drag(e){e.preventDefault();let t=this.resizeTracker.drag({position:{x:e.clientX,y:e.clientY}});E(t)&&(this.resizeTable(t.operation),this.tableState.activeHandle=t.activeHandle,this.tableState.activeCell=t.activeCell,this.tableState.anchorCell=t.anchorCell,this.tableState.outlinedSection=t.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:t}){if(E(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(E(t)){let{action:n,index:r,count:o}=t;n==="add"?this.tableState.table.addEmptyColsAt({col:r,count:o}):this.tableState.table.removeColsAt({col:r,count:o})}}static startResize(e){new i(e).start(e.event)}constructor({event:e,tableState:t,handle:n}){this.tableState=t;let{width:r,height:o}=A4(t);this.resizeTracker=Sm.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 X4(i,e){e.interactive&&(e.activeHandle={state:"hover",handle:i})}function _4(i){i.interactive&&(i.activeHandle=void 0)}function E4(i,e,t){if(t.interactive){if(!Bm(i)){i.preventDefault();return}e.type==="table"||e.type==="border"?vm.startResize({event:i,handle:e,tableState:t}):e.type==="header"&&bm.startMove({event:i,rowOrCol:e.location,index:e.index,tableState:t,onClick:()=>mm.showMenu({handle:e,point:{x:i.clientX,y:i.clientY},tableState:t})})}}function Z4(i,e){let t=i.target;if(j(t))return;let n=Ym(t);if(E(n)){X4(n,e);return}let r=Kl(t);if(E(r)){k4(lf(r),e);return}}function z4(i,e){let t=i.target;if(j(t))return;let n=Ym(t);if(E(n)){_4(e);return}let r=Kl(t);if(E(r)){P4(e);return}}function L4(i,e){let t=i.target;if(j(t))return;let n=Ym(t);if(E(n)){E4(i,n,e);return}let r=Kl(t);if(E(r)){$4(i,lf(r),e);return}i.preventDefault()}function M4(i){i.preventDefault()}var q4=oe("<!> <!> <!>",1),W4=oe('<tr class="tbl-table-row"></tr>'),j4=oe('<tbody class="tbl-table-body"></tbody>'),D4=oe("<!> <!>",1),V4=oe("<!> <!>",1),I4=oe("<!> <!> <!>",1),Y4=oe("<!> <!>",1),B4=oe("<!> <!>",1),U4=oe("<!> <!>",1),N4=oe("<!> <!>",1),G4=oe("<!> <!> <!> <!> <!>",1),F4=oe("<!> <!>",1),H4=oe("<!> <!>",1),K4=oe("<!> <!> <!>",1),J4=oe("<!> <!>",1),e3=oe("<!> <!>",1),t3=oe("<!> <!> <!>",1),i3=oe("<!> <!>",1),n3=oe("<!> <!>",1),r3=oe("<!> <!>",1),o3=oe("<!> <!> <!> <!> <!> <!> <!>",1),s3=oe('<div class="tbl-table-wrapper"><table class="tbl-table" role="grid" tabindex="-1"><thead class="tbl-table-head"><!></thead><!></table> <!> <!> <!> <!></div>');function l3(i,e){cr(e,!0);let t=Om.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});rf(()=>co(Le(t.document,"selectionchange",()=>Pq(t)),Le(t.document.body,"pointerdown",()=>Sq(t),{capture:!0,passive:!0}),Le(t.document.body,"pointerup",()=>vq(t),{capture:!0,passive:!0}),Le(t.document.body,"pointerleave",()=>xq(t),{capture:!0,passive:!0}),Le(t.document.body,"copy",x=>wq(x,t)),Le(t.document.body,"cut",x=>yq(x,t)),Le(t.document.body,"paste",x=>Qq(x,t))));var n=s3(),r=pi(n);{let x=(w,k=yQ)=>{var P=W4();yh(P,20,()=>t.table.colIndices,Z=>Z,(Z,Y)=>{let _=N(()=>({row:k(),col:Y})),V=N(()=>({top:k()===t.table.firstRowIndex,left:Y===t.table.firstColIndex})),M=N(()=>t.selection.isCell()&&ho(Q(_),t.selection.cell));{let ee=N(()=>t.outlinedSection?.containsOnEdge(Q(_))??{top:!1,right:!1,bottom:!1,left:!1}),F=N(()=>t.move?.cellMovement(Q(_)));Zq(Z,{get location(){return Q(_)},get alignment(){return t.table.alignments[Y]},get selected(){return Q(M)},get position(){return Q(V)},get outline(){return Q(ee)},get movement(){return Q(F)},get win(){return t.window},children:(ce,Be)=>{var Ge=q4(),mt=ze(Ge);yh(mt,16,()=>Oq(Q(_),Q(V)),ye=>ye,(ye,Fe)=>{{let gt=N(()=>t.cellHandleState(Q(_),Fe)),_t=N(()=>E(t.resize));tQ(ye,{get of(){return Fe},get state(){return Q(gt)},get toggle(){return Q(_t)}})}});var _e=J(mt,2);Yq(_e,{get hidden(){return Q(M)},children:(ye,Fe)=>{var gt=Lm(),_t=ze(gt);vM(_t,()=>hq(t.table.cellAt(Q(_)),t.highlighter(Q(_)))),z(ye,gt)},$$slots:{default:!0}});var rt=J(_e,2);{var jt=ye=>{var Fe=()=>t.table.cellAt(Q(_)),gt=pe=>t.table.setCellAt(Q(_),pe),_t=()=>t.selection.cellSection,H=pe=>{t.selectionValue={cell:Q(_),section:pe}};{let pe=N(()=>t.highlighter(Q(_)));Mq(ye,{get text(){return Fe()},set text(me){gt(me)},get selection(){return _t()},set selection(me){H(me)},get selectionType(){return t.selectionType},get lineWrapping(){return t.lineWrapping},get extensions(){return t.extensions},get markdownConfig(){return t.markdownConfig},get rootEditor(){return t.rootEditor},get globalKeyBindings(){return t.globalKeyBindings},get highlighter(){return Q(pe)},onbeforeinput:me=>Wq(me,t),ondragstart:me=>jq(me),onkeydown:(me,Ce)=>Dq(me,Ce,t),onpaste:me=>Vq(me,t)})}};ut(rt,ye=>{Q(M)&&ye(jt)})}z(ce,Ge)},$$slots:{default:!0}})}}),z(w,P)};var o=pi(r),s=pi(o);x(s,()=>t.table.headerRowIndex);var l=J(o);{var a=w=>{var k=j4();yh(k,20,()=>t.table.dataRowIndices,P=>P,(P,Z)=>{x(P,()=>Z)}),z(w,k)},c=N(()=>t.table.hasDataRows());ut(l,w=>{Q(c)&&w(a)})}Wh(r,w=>t.tableElement=w,()=>t?.tableElement)}var h=J(r,2);{var f=x=>{let w=N(()=>t.menu.type==="row"?"row":"column");Tq(x,{get to(){return t.menuRootElement},children:(k,P)=>{Fq(k,{translate:Z=>t.menu.computeTranslation(Z),children:(Z,Y)=>{let _=N(()=>{let{addable:H,alignable:pe,clearable:me,duplicatable:Ce,moveable:Ve,removable:Ie,sortable:Pt}=t.menu.capabilities;return{addable:H,alignable:pe,clearable:me,duplicatable:Ce,moveable:Ve,removable:Ie,sortable:Pt}});var V=o3(),M=ze(V);{var ee=H=>{var pe=I4(),me=ze(pe);Kt(me,{onclick:()=>Jt({action:"sort",direction:"ascending"},t),children:(Ie,Pt)=>{var he=D4(),ge=ze(he);ei(ge,{name:"sort-ascending"});var Me=J(ge,2);ti(Me,{children:(Qe,ot)=>{var Te=Ht();yt(()=>vn(Te,`Sort by ${Q(w)??""} (A-Z)`)),z(Qe,Te)}}),z(Ie,he)}});var Ce=J(me,2);Kt(Ce,{onclick:()=>Jt({action:"sort",direction:"descending"},t),children:(Ie,Pt)=>{var he=V4(),ge=ze(he);ei(ge,{name:"sort-descending"});var Me=J(ge,2);ti(Me,{children:(Qe,ot)=>{var Te=Ht();yt(()=>vn(Te,`Sort by ${Q(w)??""} (Z-A)`)),z(Qe,Te)}}),z(Ie,he)}});var Ve=J(Ce,2);Ph(Ve),z(H,pe)};ut(M,H=>{Q(_).sortable&&H(ee)})}var F=J(M,2);{var ce=H=>{var pe=G4(),me=ze(pe);Kt(me,{onclick:()=>Jt({action:"align",alignment:"none"},t),children:(he,ge)=>{var Me=Y4(),Qe=ze(Me);ei(Qe,{name:"align-none"});var ot=J(Qe,2);ti(ot,{children:(Te,Si)=>{var Hi=Ht("Align none");z(Te,Hi)}}),z(he,Me)}});var Ce=J(me,2);Kt(Ce,{onclick:()=>Jt({action:"align",alignment:"left"},t),children:(he,ge)=>{var Me=B4(),Qe=ze(Me);ei(Qe,{name:"align-left"});var ot=J(Qe,2);ti(ot,{children:(Te,Si)=>{var Hi=Ht("Align left");z(Te,Hi)}}),z(he,Me)}});var Ve=J(Ce,2);Kt(Ve,{onclick:()=>Jt({action:"align",alignment:"center"},t),children:(he,ge)=>{var Me=U4(),Qe=ze(Me);ei(Qe,{name:"align-center"});var ot=J(Qe,2);ti(ot,{children:(Te,Si)=>{var Hi=Ht("Align center");z(Te,Hi)}}),z(he,Me)}});var Ie=J(Ve,2);Kt(Ie,{onclick:()=>Jt({action:"align",alignment:"right"},t),children:(he,ge)=>{var Me=N4(),Qe=ze(Me);ei(Qe,{name:"align-right"});var ot=J(Qe,2);ti(ot,{children:(Te,Si)=>{var Hi=Ht("Align right");z(Te,Hi)}}),z(he,Me)}});var Pt=J(Ie,2);Ph(Pt),z(H,pe)};ut(F,H=>{Q(_).alignable&&H(ce)})}var Be=J(F,2);{var Ge=H=>{var pe=K4(),me=ze(pe);Kt(me,{onclick:()=>Jt({action:"add",direction:"before"},t),children:(Ie,Pt)=>{var he=F4(),ge=ze(he);ei(ge,{name:"add-before"});var Me=J(ge,2);ti(Me,{children:(Qe,ot)=>{var Te=Ht();yt(()=>vn(Te,`Add ${Q(w)??""} ${Q(w)==="row"?"above":"before"}`)),z(Qe,Te)}}),z(Ie,he)}});var Ce=J(me,2);Kt(Ce,{onclick:()=>Jt({action:"add",direction:"after"},t),children:(Ie,Pt)=>{var he=H4(),ge=ze(he);ei(ge,{name:"add-after"});var Me=J(ge,2);ti(Me,{children:(Qe,ot)=>{var Te=Ht();yt(()=>vn(Te,`Add ${Q(w)??""} ${Q(w)==="row"?"below":"after"}`)),z(Qe,Te)}}),z(Ie,he)}});var Ve=J(Ce,2);Ph(Ve),z(H,pe)};ut(Be,H=>{Q(_).addable&&H(Ge)})}var mt=J(Be,2);{var _e=H=>{var pe=t3(),me=ze(pe);{var Ce=he=>{Kt(he,{onclick:()=>Jt({action:"move",direction:"backward"},t),children:(ge,Me)=>{var Qe=J4(),ot=ze(Qe);{let Si=N(()=>`move-${Q(w)==="row"?"up":"left"}`);ei(ot,{get name(){return Q(Si)}})}var Te=J(ot,2);ti(Te,{children:(Si,Hi)=>{var ps=Ht();yt(()=>vn(ps,`Move ${Q(w)??""} ${Q(w)==="row"?"up":"left"}`)),z(Si,ps)}}),z(ge,Qe)}})};ut(me,he=>{(Q(_).moveable==="backward"||Q(_).moveable===!0)&&he(Ce)})}var Ve=J(me,2);{var Ie=he=>{Kt(he,{onclick:()=>Jt({action:"move",direction:"forward"},t),children:(ge,Me)=>{var Qe=e3(),ot=ze(Qe);{let Si=N(()=>`move-${Q(w)==="row"?"down":"right"}`);ei(ot,{get name(){return Q(Si)}})}var Te=J(ot,2);ti(Te,{children:(Si,Hi)=>{var ps=Ht();yt(()=>vn(ps,`Move ${Q(w)??""} ${Q(w)==="row"?"down":"right"}`)),z(Si,ps)}}),z(ge,Qe)}})};ut(Ve,he=>{(Q(_).moveable==="forward"||Q(_).moveable===!0)&&he(Ie)})}var Pt=J(Ve,2);Ph(Pt),z(H,pe)};ut(mt,H=>{Q(_).moveable!==!1&&H(_e)})}var rt=J(mt,2);{var jt=H=>{Kt(H,{onclick:()=>Jt({action:"duplicate"},t),children:(pe,me)=>{var Ce=i3(),Ve=ze(Ce);ei(Ve,{name:"duplicate"});var Ie=J(Ve,2);ti(Ie,{children:(Pt,he)=>{var ge=Ht();yt(()=>vn(ge,`Duplicate ${Q(w)??""}`)),z(Pt,ge)}}),z(pe,Ce)}})};ut(rt,H=>{Q(_).duplicatable&&H(jt)})}var ye=J(rt,2);{var Fe=H=>{Kt(H,{onclick:()=>Jt({action:"clear"},t),children:(pe,me)=>{var Ce=n3(),Ve=ze(Ce);ei(Ve,{name:"clear"});var Ie=J(Ve,2);ti(Ie,{children:(Pt,he)=>{var ge=Ht();yt(()=>vn(ge,`Clear ${Q(w)??""}`)),z(Pt,ge)}}),z(pe,Ce)}})};ut(ye,H=>{Q(_).clearable&&H(Fe)})}var gt=J(ye,2);{var _t=H=>{Kt(H,{onclick:()=>Jt({action:"remove"},t),children:(pe,me)=>{var Ce=r3(),Ve=ze(Ce);ei(Ve,{name:"remove"});var Ie=J(Ve,2);ti(Ie,{children:(Pt,he)=>{var ge=Ht();yt(()=>vn(ge,`Delete ${Q(w)??""}`)),z(Pt,ge)}}),z(pe,Ce)}})};ut(gt,H=>{Q(_).removable&&H(_t)})}z(Z,V)},$$slots:{default:!0}})},$$slots:{default:!0}})},u=N(()=>E(t.menu));ut(h,x=>{Q(u)&&x(f)})}var d=J(h,2);yh(d,16,()=>dq,x=>x,(x,w)=>{{let k=N(()=>dm(t.activeHandle?.handle,w)?t.activeHandle.state:void 0);tQ(x,{get of(){return w},get state(){return Q(k)}})}});var O=J(d,2);{var p=x=>{Aq(x)},g=N(()=>!t.interactive&&j(t.outline));ut(O,x=>{Q(g)&&x(p)})}var b=J(O,2);{var S=x=>{u4(x)},v=N(()=>t.selection.isAll());ut(b,x=>{Q(v)&&x(S)})}Wh(n,x=>t.wrapperElement=x,()=>t?.wrapperElement),yt(x=>Pe(n,"data-select-all",x),[()=>ro(t.selection.isAll())]),El("mouseover",n,x=>Z4(x,t)),El("mouseout",n,x=>z4(x,t)),El("pointerdown",n,x=>L4(x,t)),xh("dragover",n,x=>M4(x)),El("keydown",r,x=>Q4(x,t)),xh("copy",r,x=>x4(x,t)),xh("cut",r,x=>w4(x,t)),xh("paste",r,x=>y4(x,t)),z(i,n),hr()}fk(["mouseover","mouseout","pointerdown","keydown"]);var xm=class i extends Ze{tableDescription;widgetElement;height;destroyWidgetElement;get estimatedHeight(){return this.height}coordsAt(e,t,n){let r=this.tableDescription.table.closestCellAtPosition(t),o=Dh(e,r);if(j(o))return null;let s=o.getBoundingClientRect();return{top:s.top,right:s.right,bottom:s.bottom,left:s.left}}toDOM(e){if(E(this.widgetElement))return this.widgetElement;let{widgetElement:t,destroyWidgetElement:n}=this.create(e);return this.widgetElement=t,this.destroyWidgetElement=n,e.requestMeasure({read:()=>{this.height=t.getBoundingClientRect().height}}),t}destroy(e){this.destroyWidgetElement?.(),this.destroyWidgetElement=void 0,this.widgetElement=void 0,this.height=qy}create(e){let t=Dl(e.dom).createElement("div");t.className="tbl-table-widget",t.tabIndex=-1,t.addEventListener("pointerdown",d=>{d?.target===t&&d.preventDefault()});let n=this.tableDescription,r=nM(()=>{tf(()=>{let d=!n.table.text.eq(n.editorTableText),O=!sf(n.selection.value,n.editorSelectionValue);if(!d&&!O)return;let p;if(n.selection.isCell()){let{from:b}=n.table.cellSpan(n.selection.cell);p={anchor:n.from+b+n.selection.cellSection.anchor,head:n.from+b+n.selection.cellSection.head}}else n.selection.isAll()?p={anchor:n.from,head:n.to}:n.selection.isHidden()&&(p={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:or("table.edit"),changes:g,selection:p})})}),{extensions:o,markdownConfig:s,globalKeyBindings:l,selectionType:a,lineWrapping:c}=Bk(e.state),h=uk(l3,{target:t,props:{table:n.table,selection:n.selection,scrollElement:t,rootEditor:e,extensions:o,markdownConfig:s,globalKeyBindings:l,selectionType:a,lineWrapping:c,menuRootElement:qs(e,Rk).dom,onUndo:()=>mc(e),onRedo:()=>Fs(e),onNavigate:d=>{e.dispatch({annotations:or("table.navigate"),selection:{anchor:d==="before"?n.from-1:n.to+1}}),e.focus()},onDelete:()=>{e.dispatch({annotations:or("table.delete"),changes:{from:n.from,to:n.to},selection:e.state.selection}),e.focus()}}}),f=()=>{dk(h)},u=AM(t,({height:d})=>{this.height=d});return{widgetElement:t,destroyWidgetElement:co(r,f,u)}}static of(e,t){return new i(e,t)}constructor(e,t){super(),this.tableDescription=e;let n=S3(t);if(E(n)){let{widgetElement:r,destroyWidgetElement:o}=this.create(n);this.widgetElement=r,this.destroyWidgetElement=o,this.height=RM(n,r)}else this.widgetElement=void 0,this.destroyWidgetElement=void 0,this.height=qy}};function a3(i,e){return{widget:xm.of(i,e),block:!0,inclusive:!0}}function c3(i,e){return X.replace(a3(i,e))}function h3(i,e){let t=new Ke;for(let n of i)t.add(n.from,n.to,c3(n,e));return t.finish()}function f3(i){return Ik(i)}function u3(i,e){return Ik(i,e)}function Ik(i,e=[]){let t=[];gz(B(i),o=>{fQ(o)&&t.push({from:i.doc.lineAt(o.from).from,to:i.doc.lineAt(o.to).to})});let n=[],r=[];for(let o of t){if($z(e,o,SQ)){n.push(o);continue}let s=d3(o,i);Hh(s)?n.push(o):r.push(...s)}return{spans:n,formatting:r,complete:Nb(i)}}function d3(i,e){return[...O3(i,e),...p3(i,e)]}function O3(i,{doc:e,lineBreak:t}){return Yl({doc:e,lineBreak:t,span:i}).changes}function p3({from:i,to:e},{doc:t}){let n=t.slice(i,e),{text:r}=Np(n);return n.eq(r)?[]:[{from:i,to:e,insert:r}]}var m3={create(i){return $h(i)},update(i,e){if(IM(e))return $h(e.state);if(!e.docChanged&&j(e.selection)&&i.complete)return i;let{tables:t,formatting:n,decorations:r}=i;if(!e.docChanged&&i.complete)return{tables:rQ(t,e),formatting:n,decorations:r.map(e.changes),complete:!0};if(VM(e)||g3(e,t))return $h(e.state);let o=rQ(t,e).map(c=>c.span),{complete:s,spans:l,formatting:a}=u3(e.state,o);return Kn(o,l,SQ)?{complete:s,tables:t,formatting:a,decorations:r.map(e.changes)}:$h(e.state)},provide(i){return $.decorations.from(i,e=>e.decorations)}},Yk=de.define(m3);function $h(i){let{spans:e,formatting:t,complete:n}=f3(i),{doc:r,selection:o}=i,s=e.map(l=>hm.of({span:l,doc:r,selection:o}));return{complete:n,tables:s,formatting:t,decorations:h3(s,i)}}function g3(i,e){return!jm(i)&&e.some(t=>i.changes.touchesRange(t.from,t.to)!==!1)}function rQ(i,e){return xz(i,t=>t.applyTransaction(e))}var b3={create(){return{view:void 0}},update(i){return i}},Um=de.define(b3);function Bk(i){return i.facet(Gp)}function lr(i){return i.field(Yk)}function S3(i){return i.field(Um).view}function v3(i){let{handlePosition:e,selectionType:t,lineWrapping:n}=Bk(i);return{...Kh(window)?{"data-tbl-hoverable":""}:{},"data-tbl-theme-mode":i.facet($.darkTheme)?"dark":"light","data-tbl-handle-position":e,"data-tbl-selection-type":t,"data-tbl-line-wrapping":n}}var x3=["undo","redo","select.undo","select.redo"];function w3(i){return x3.some(e=>i.isUserEvent(e))}function y3(i){return Uk(i,"select.search")}function Q3(i){return Uk(i,"select")}function k3(i){return i.isUserEvent("delete.forward")}function P3(i){return i.isUserEvent("delete.backward")}function Uk(i,e){return i.annotation(Ee.userEvent)===e}var $3=({state:i,view:e,transactions:t})=>{e.hasFocus||lr(i).tables.some(n=>n.containsSelection())||t.some(n=>w3(n)||y3(n)&&!Wk(e))&&e.focus()},Nk=D.define(),C3=new Map(xk.map(i=>[i,Nk.of(i)]));function Gk(i){return C3.get(i)}var T3=(i,e)=>!e||!lr(i).tables.some(t=>t.containsSelection())?null:Gk("table.focus"),R3=i=>{let{selection:e,startState:t,docChanged:n}=i;if(j(e)||n||!Q3(i)||!Ah(e)||!Ah(t.selection))return i;let r=t.selection.main,o=e.main;for(let s of lr(t).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),E(f))return[i,{annotation:or("table.navigate"),selection:ez({pos:s.from+f})}]}return i},A3=i=>{let{selection:e,startState:t}=i;if(j(e)||!Ah(e))return i;let n=t.selection.main;if(k3(i)){for(let r of lr(t).tables)if(n.head===r.from-1){let o=r.table.firstCellSpan.from;return[{selection:{anchor:r.from+o,head:r.from+o}}]}return i}else if(P3(i)){for(let r of lr(t).tables)if(n.head===r.to+1){let o=r.table.lastCellSpan.to;return[{selection:{anchor:r.from+o,head:r.from+o}}]}return i}else return i};function X3(i){return AS(i)>0||XS(i)>0}var _3=({state:i,docChanged:e,selectionSet:t,transactions:n,view:r})=>{if(!e&&!t&&X3(i)||n.some(a=>jm(a)))return;let{formatting:o}=lr(i);if(Hh(o))return;let s=He.of(o,i.doc.length,i.lineBreak),l=i.selection.map(s);r.dispatch({annotations:or("table.format"),changes:s,selection:l})},E3=i=>{if(!i.docChanged||jm(i))return i;let e=i.changes,{tables:t}=lr(i.startState),n=[];for(let s of t)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(Yl({doc:i.newDoc,lineBreak:i.startState.lineBreak,span:l}).changes)}if(Hh(n))return i;let r=He.of(n,i.changes.newLength,i.startState.lineBreak),o=i.newSelection.map(r);return[i,{annotation:or("table.correct"),changes:r,selection:o,sequential:!0}]};function Z3(i,{anchor:e,head:t,goalColumn:n,bidiLevel:r}={}){return y.range(e??i.anchor,t??i.head,n??i.goalColumn,r??i.bidiLevel??void 0)}var z3=i=>{let{selection:e,startState:t,docChanged:n}=i;if(j(e)||n||Ah(e))return i;let r=e.ranges.map(o=>{if(o.empty)return o;let s=lr(t).tables,l=oQ(o.anchor,s),a=oQ(o.head,s);return E(l)||E(a)?Z3(o,{anchor:l,head:a}):o});return Kn(e.ranges,r,(o,s)=>o===s)?i:[i,{annotations:or("table.select"),selection:y.create(r,e.mainIndex)}]};function oQ(i,e){for(let t of e){let n=t.from,r=t.to,o=t.from+1,s=t.to-1;if(i===n||i===o)return n-1;if(i===r||i===s)return r+1}}var L3={"& .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"}},M3={'&[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"}},q3={".cm-tooltip.tbl-menu-tooltip":{border:"none","user-select":"none","&, &::before, &::after, & *, & *::before, & *::after":{"box-sizing":"border-box"}}},W3={".tbl-blocking-overlay":{position:"absolute",top:0,left:0,"z-index":900,"background-color":"transparent",width:"100%",height:"100%"}},j3={"& .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)"}},D3={".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)"}},V3={'&[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"}},I3={".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}},Y3={".tbl-menu-item-icon":{"z-index":200,width:"1em",height:"1em","pointer-events":"none","font-size":"var(--tbl-style-menu-font-size)"}},B3={".tbl-menu-item-text":{"z-index":200,"pointer-events":"none","user-select":"none","font-size":"var(--tbl-style-menu-font-size)"}},U3={".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)"}}},N3={".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)"}},G3={".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)"}},F3={".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"}},H3={"& .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)"}},K3={...L3,...q3,...M3,...H3,...W3,...D3,...j3,...V3,...I3,...G3,...U3,...Y3,...B3,...N3,...F3},J3=i=>{let e=i.effects.find(t=>t.is(Nk))?.value;return E(e)?{annotations:or(e)}:null},eW=i=>{let e=i.annotation(Wm);return E(e)?[Gk(qM(e))]:[]},wm=class i{static of(e){return e.state.field(Um).view=e,new i}constructor(){}};function tW(i){return[Gp.of(i),Yk,Um,Oe.define(e=>wm.of(e)),$.editorAttributes.compute([Gp,$.darkTheme],v3),$.baseTheme(K3),$.theme("light"in i.theme?{':where(:root:has(&[data-tbl-theme-mode="light"]))':i.theme.light.props,':where(:root:has(&[data-tbl-theme-mode="dark"]))':i.theme.dark.props}:{":where(:root:has(&))":i.theme.props}),$.theme({":where(:root:has(&))":i.style.props}),Td.of(eW),yr.of(Rk),G.transactionExtender.of(J3),G.transactionFilter.of(E3),G.transactionFilter.of(A3),G.transactionFilter.of(R3),G.transactionFilter.of(z3),$.updateListener.of(_3),$.updateListener.of($3),$.clipboardInputFilter.of(Hz),$.focusChangeEffect.of(T3)]}function Fk(i){return tW(aQ(i))}function iW(i,e){if(!j(i))for(let t of i)e(t)}function nW(i,e){j(i)||e(i)}function Hk(i,e,t){if(!Number.isInteger(i)||i<=0)throw new Error(t);if(!Number.isInteger(e)||e<=0)throw new Error(t)}function rW({pos:i,doc:e,lineBreak:t,rows:n,cols:r}){let[o,...s]=Jn(`${"| ".repeat(r)}|`,{count:n}),l=`${"| - ".repeat(r)}|`,{before:a,after:c}=Yl({doc:e,lineBreak:t,span:{from:i-1,to:i}}),h=`${a?.insert??""}${[o,l,...s].join(t)}${c?.insert??""}`;return{label:`${n}\xD7${r} table`,type:"table",apply:(f,u)=>{f.dispatch({annotations:rl.of(u),changes:{from:i-1,to:i,insert:h},selection:{anchor:i+1+(a?.count??0)}})}}}var oW=[{rows:2,cols:2},{rows:3,cols:3},{rows:4,cols:4}];function sW(i){let e=i?.options??oW;return({state:t,pos:n})=>{let r=t.doc.lineAt(n);if(n!==r.from+1||r.length!==1||r.text.slice(0,1)!=="|")return null;let{doc:o,lineBreak:s}=t;return{from:n,options:e.map(({rows:l,cols:a})=>rW({pos:n,doc:o,lineBreak:s,rows:l,cols:a}))}}}function Kk(i){return iW(i?.options,({rows:e,cols:t})=>{Hk(e,t,"options[].{ rows, cols } must be positive integers")}),sW(i)}var lW={rows:2,cols:2};function aW(i){let{rows:e,cols:t}=i?.size??lW;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}=Yl({doc:n.doc,lineBreak:n.lineBreak,span:{from:l,to:a}}),[f,...u]=Jn(`${"| ".repeat(t)}|`,{count:e}),d=`${"| - ".repeat(t)}|`,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 Jk(i){return nW(i?.size,({rows:e,cols:t})=>{Hk(e,t,"size.{rows, cols} must be positive integers")}),aW(i)}var eP=16,tP="50rem",iP="88%",cW=$.theme({"&":{height:"100%",color:"var(--text)",backgroundColor:"var(--card)",fontSize:`${eP}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:"20px 0",caretColor:"var(--text)",minHeight:"100%",minWidth:"0"},".cm-line:not(.tbl-table-widget .cm-line)":{boxSizing:"border-box",width:tP,maxWidth:iP,marginInline:"auto",paddingTop:"var(--md-line-pad-y, 2px)",paddingBottom:"var(--md-line-pad-y, 2px)",lineHeight:"var(--md-line-height, 1.7rem)"},".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:`min(${tP}, ${iP}) !important`,marginInline:"auto !important",padding:"0 16px 16px 6px !important"},".tbl-table-widget .tbl-table-wrapper":{maxWidth:"100%",paddingTop:"12px"},".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-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)"},".cm-line.cm-md-h1":{fontSize:"1.4em",fontWeight:"700",lineHeight:"normal !important"},".cm-line.cm-md-h2":{fontSize:"1.2em",fontWeight:"700",lineHeight:"normal !important"},".cm-line.cm-md-h3":{fontSize:"1.15em",fontWeight:"700",lineHeight:"normal !important"},".cm-line.cm-md-h4":{fontSize:"1.1em",fontWeight:"700",lineHeight:"normal !important"},".cm-line.cm-md-h5":{fontSize:"1.04em",fontWeight:"700",lineHeight:"normal !important"},".cm-line.cm-md-h6":{fontSize:"1em",fontWeight:"700",lineHeight:"normal !important"},".cm-md-bullet":{display:"inline-block",color:"var(--accent)",fontWeight:"700",textAlign:"center",fontFamily:"monospace"},".\u037Cx":{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-line > .cm-widget:has(.cm-md-image-block)":{display:"inline-block",width:"100%",maxWidth:"100%"},".cm-md-image-block":{display:"inline-block",maxWidth:"100%",margin:"8px 0",lineHeight:"1.4",verticalAlign:"top"},".cm-md-image-block img":{display:"block",maxHeight:"80vh",maxWidth:"100%",width:"auto",borderRadius:"8px",cursor:"zoom-in"},".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-list-line":{paddingLeft:"2ch"},".cm-line.cm-md-code-line":{color:"var(--text)",backgroundColor:"color-mix(in srgb, var(--text) 8%, transparent)",lineHeight:"1.3rem !important",fontFamily:"var(--finch-font-mono)",paddingTop:"0 !important",paddingBottom:"0 !important",width:"calc(50rem - 30px) !important",paddingInline:"24px",fontSize:"13px !important"},".cm-line.cm-md-code-line span":{fontSize:"12px !important"},".cm-line.cm-md-code-open":{fontSize:"12px",borderRadius:"8px 8px 0 0",height:"22px",paddingTop:"2px",paddingInline:"12px",lineHeight:"1.5rem !important"},".cm-line.cm-md-code-close":{fontSize:"12px",borderRadius:"0 0 8px 8px",height:"22px",paddingInline:"12px"},".cm-md-code-fence-empty":{opacity:"0"},".cm-md-code-copy":{float:"right",height:"20px",margin:"4px -7px",padding:"0 7px",border:"0px",borderRadius:"6px",color:"var(--muted)",backgroundColor:"color-mix(in srgb, var(--card) 88%, transparent)",font:"11px 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-selectionMatch":{backgroundColor:"transparent !important"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--text)"},".cm-gutters":{color:"var(--muted)",backgroundColor:"var(--card)",borderRight:"0px",fontSize:`${12/eP}em`},".cm-gutterElement":{padding:"0px 8px 0 10px"},".cm-lineNumbers .cm-gutterElement":{padding:"0 5px 0 8px",lineHeight:"var(--md-gutter-line-height, 32px)",color:"color-mix(in srgb, var(--muted) 35%, transparent)",fontFamily:"var(--finch-font-mono)",fontSize:"12px"},".cm-lineNumbers .cm-gutterElement.cm-gutter-code-line":{lineHeight:"22px"},".cm-activeLine":{backgroundColor:"color-mix(in srgb, var(--text) 7%, transparent)",boxShadow:["-25vw 0 color-mix(in srgb, var(--text) 7%, transparent)","25vw 0 color-mix(in srgb, var(--text) 7%, transparent)"].join(", ")},".cm-activeLineGutter":{color:"var(--text) !important",backgroundColor:"color-mix(in srgb, var(--text) 7%, 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-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:"color-mix(in srgb, var(--accent) 34%, transparent)"},".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-autocomplete > ul > li[aria-selected]":{color:"var(--text)",backgroundColor:"color-mix(in srgb, var(--accent) 20%, transparent)"}}),hW=[ft.of({name:"JavaScript",alias:["js","mjs","cjs"],extensions:["js","mjs","cjs"],support:qr()}),ft.of({name:"JSX",alias:["jsx"],extensions:["jsx"],support:qr({jsx:!0})}),ft.of({name:"TypeScript",alias:["ts"],extensions:["ts"],support:qr({typescript:!0})}),ft.of({name:"TSX",alias:["tsx"],extensions:["tsx"],support:qr({jsx:!0,typescript:!0})}),ft.of({name:"JSON",alias:["json","json5"],extensions:["json"],support:Vx()}),ft.of({name:"CSS",alias:["css"],extensions:["css"],support:th()}),ft.of({name:"HTML",alias:["html","htm","xml","svg"],extensions:["html"],support:nh()}),ft.of({name:"Python",alias:["python","py"],extensions:["py"],support:aw()}),ft.of({name:"SQL",alias:["sql"],extensions:["sql"],support:Qw()}),ft.of({name:"YAML",alias:["yaml","yml"],extensions:["yaml","yml"],support:qw()}),ft.of({name:"Shell",alias:["bash","sh","shell","zsh","console"],extensions:["sh"],support:new je(ac.define(Iw))})],nP=_o.define([{tag:m.heading,color:"var(--accent)",fontWeight:"700"},{tag:m.strong,color:"var(--text)",fontWeight:"700"},{tag:m.emphasis,fontStyle:"italic"},{tag:m.strikethrough,color:"var(--muted)",textDecoration:"line-through"},{tag:m.monospace,color:"var(--muted)"},{tag:m.link,color:"var(--accent)"},{tag:m.url,color:"var(--muted)",textDecoration:"underline"},{tag:m.quote,color:"var(--muted)"},{tag:m.meta,color:"var(--muted)"},{tag:m.keyword,color:"#c678dd"},{tag:[m.name,m.deleted,m.character,m.propertyName,m.macroName],color:"#e06c75"},{tag:[m.function(m.variableName),m.labelName],color:"#61afef"},{tag:[m.color,m.constant(m.name),m.standard(m.name),m.bool],color:"#d19a66"},{tag:[m.definition(m.name),m.separator],color:"var(--text)"},{tag:[m.typeName,m.className,m.number,m.changed,m.annotation,m.modifier,m.self,m.namespace],color:"#e5c07b"},{tag:[m.operator,m.operatorKeyword,m.escape,m.regexp,m.special(m.string)],color:"#56b6c2"},{tag:m.string,color:"#98c379"},{tag:m.comment,color:"var(--muted)",fontStyle:"italic"},{tag:m.invalid,color:"#fff",backgroundColor:"#e06c75"}]),rP=/^(#{1,6})(?:\s|$)/;function oP(i){let e=new Ke,t=i.state.doc;for(let n=1;n<=t.lines;n++){let r=t.line(n),o=r.text,s=rP.exec(o),l=o.trim().length===0,a;if(s)a=`cm-md-h${s[1].length}`;else if(l&&n<t.lines){let c=t.line(n+1).text;c.trim().length>0&&(a=rP.test(c)?"cm-md-gap-heading":"cm-md-gap")}a&&e.add(r.from,r.from,X.line({class:a}))}return e.finish()}var fW=Oe.fromClass(class{decorations;constructor(i){this.decorations=oP(i)}update(i){(i.docChanged||i.viewportChanged)&&(this.decorations=oP(i.view))}},{decorations:i=>i.decorations}),sP=/`([^`\n]+)`/g,Os=/^\s*```+\s*([^\s`]*)?\s*$/,pP=/^\s{0,3}(?:(?:-\s*){3,}|(?:\*\s*){3,}|(?:_\s*){3,})$/,uW=/^(\s*)([-+*])(?=\s+)/,dW=/^(\s*>\s?)/,Mi=X.replace({}),OW=X.mark({class:"cm-md-inline-code"});function Nm(i){let e=i.trim();return/^https?:\/\//i.test(e)?e:null}function Gm(i){return X.mark({class:"cm-md-link",attributes:{"data-md-href":i,role:"link",title:i}})}var Fm=class extends Ze{constructor(t,n){super();this.src=t;this.alt=n}src;alt;captionEl=null;eq(t){return t.src===this.src&&t.alt===this.alt}ignoreEvent(t){return!!(this.captionEl&&t.target instanceof Node&&this.captionEl.contains(t.target))}toDOM(t){let n=document.createElement("span");n.className="cm-md-image-block";let r=document.createElement("img");r.src=this.src,r.alt=this.alt,r.dataset.mdImageSrc=this.src,r.title=this.alt||this.src,n.appendChild(r);let o=document.createElement("div");return o.className="cm-md-image-caption",o.contentEditable="plaintext-only",o.contentEditable!=="plaintext-only"&&(o.contentEditable="true"),o.spellcheck=!1,o.dataset.placeholder="\u6DFB\u52A0\u56FE\u7247\u8BF4\u660E\u2026",o.textContent=this.alt,o.addEventListener("paste",s=>{s.preventDefault();let l=s.clipboardData?.getData("text/plain")??"";document.execCommand("insertText",!1,l.replace(/[\r\n]+/g," "))}),o.addEventListener("keydown",s=>{s.key==="Enter"?(s.preventDefault(),o.blur()):s.key==="Escape"&&(s.preventDefault(),o.textContent=this.alt,o.blur())}),o.addEventListener("input",()=>{o.textContent||o.replaceChildren()}),o.addEventListener("blur",()=>pW(t,n,this.alt,o.textContent??"")),n.appendChild(o),this.captionEl=o,n}};function pW(i,e,t,n){if(n===t)return;let r;try{r=i.posAtDOM(e)}catch{return}let o=i.state.doc.lineAt(Math.min(r,i.state.doc.length)),s=[];B(i.state).iterate({from:o.from,to:o.to,enter:h=>{if(h.name==="Image"&&h.from<=r&&r<=h.to)return s.push({from:h.from,to:h.to}),!1}});let l=s[0];if(!l)return;let a=i.state.sliceDoc(l.from,l.to),c=/^!\[[^\]]*\](\([^)]*\))/.exec(a);c&&i.dispatch({changes:{from:l.from,to:l.to,insert:`![${n}]${c[1]}`}})}function lP(i){let e=[];return B(i).iterate({enter:t=>{if(t.name!=="Image")return;if(i.doc.lineAt(t.from).text.trim()!==i.sliceDoc(t.from,t.to))return!1;let r=t.node.getChild("URL");if(!r)return!1;let o=i.sliceDoc(t.from,t.to),s=/^!\[([^\]]*)\]/.exec(o)?.[1]??"",l=i.sliceDoc(r.from,r.to).trim();return l&&e.push(X.replace({widget:new Fm(l,s),inclusive:!1}).range(t.from,t.to)),!1}}),X.set(e,!0)}var mP=de.define({create:lP,update(i,e){return e.docChanged?lP(e.state):i.map(e.changes)},provide:i=>$.decorations.from(i)}),mW=$.atomicRanges.of(i=>i.state.field(mP));function gW(i){let e=[],t=[],n=B(i.state);return n.iterate({enter:r=>{r.name==="URL"&&t.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||Jl(i,r.from,r.to))return!1;let l=Nm(i.state.sliceDoc(o.from,o.to)),a=s[0],c=s[1];return!l||a.to>=c.from||(e.push(Mi.range(a.from,a.to)),e.push(Gm(l).range(a.to,c.from)),e.push(Mi.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||Jl(i,r.from,r.to))return!1;let l=Nm(i.state.sliceDoc(o.from,o.to));return l&&(e.push(Mi.range(s[0].from,s[0].to)),e.push(Gm(l).range(o.from,o.to)),e.push(Mi.range(s[s.length-1].from,s[s.length-1].to))),!1}if(r.name==="URL"){if(Jl(i,r.from,r.to))return;let o=Nm(i.state.sliceDoc(r.from,r.to));o&&e.push(Gm(o).range(r.from,r.to))}}}),{decorations:e,urlRanges:t}}function bW(i){let e=[];return B(i.state).iterate({enter:t=>{if(t.name==="Table"||t.name==="Image")return!1;let n=t.name==="Strikethrough"?"StrikethroughMark":t.name==="Emphasis"||t.name==="StrongEmphasis"?"EmphasisMark":void 0;if(n){if(Jl(i,t.from,t.to))return!1;for(let r of t.node.getChildren(n))e.push(Mi.range(r.from,r.to))}}}),e}function SW(i,e,t){return t.some(n=>i<n.to&&e>n.from)}function gP(i){return i.button!==0||!(i.target instanceof Element)?null:i.target.closest(".cm-md-link[data-md-href]")}function vW(i){return gP(i)?(i.preventDefault(),i.stopPropagation(),!0):!1}function xW(i,e){let t=gP(i)?.dataset.mdHref;return t?(i.preventDefault(),i.stopPropagation(),e?.(t),!0):!1}function bP(i){return i.button!==0||!(i.target instanceof Element)?null:i.target.closest(".cm-md-image-block img[data-md-image-src]")}function wW(i){return bP(i)?(i.preventDefault(),i.stopPropagation(),!0):!1}function yW(i,e){let t=bP(i)?.dataset.mdImageSrc;return t?(i.preventDefault(),i.stopPropagation(),e?.(t),!0):!1}var Hm=class extends Rt{elementClass="cm-gutter-code-line"},QW=new Hm;function aP(i){let e=new Ke,t=!1;for(let n=1;n<=i.lines;n++){let r=i.line(n),o=Os.test(r.text);(o||t)&&e.add(r.from,r.from,QW),o&&(t=!t)}return e.finish()}var cP=de.define({create:i=>aP(i.doc),update:(i,e)=>e.docChanged?aP(e.state.doc):i}),kW=[cP,ko.from(cP)],Km=class extends Ze{toDOM(){let e=document.createElement("span");return e.className="cm-md-bullet",e.textContent="\u2022",e.setAttribute("aria-hidden","true"),e}},Jm=class extends Ze{constructor(t){super();this.position=t}position;eq(t){return t.position===this.position}toDOM(t){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",()=>{t.dispatch({selection:{anchor:this.position}}),t.focus()}),n}},eg=class extends Ze{constructor(t,n){super();this.language=t;this.code=n}language;code;eq(t){return t.language===this.language&&t.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 t=document.createElement("button");return t.type="button",t.className="cm-md-code-copy",t.textContent=this.language.toUpperCase(),t.title="\u590D\u5236\u4EE3\u7801\u5757",t.addEventListener("mousedown",n=>n.preventDefault()),t.addEventListener("click",async n=>{n.preventDefault(),n.stopPropagation();let r=t.textContent||this.language.toUpperCase();try{await navigator.clipboard.writeText(this.code),t.textContent="\u5DF2\u590D\u5236"}catch{t.textContent="\u590D\u5236\u5931\u8D25"}window.setTimeout(()=>{t.textContent=r},1200)}),t}};function hP(i,e,t){return i.state.selection.ranges.some(n=>n.empty?n.head>=e&&n.head<=t:n.from<=t&&n.to>=e)}function Jl(i,e,t){let n=i.state.doc.lineAt(e);return i.state.selection.ranges.some(r=>r.empty?r.head>=n.from&&r.head<=n.to&&r.head>=e-1&&r.head<=t+1:r.from<=n.to&&r.to>=n.from&&r.from<=t+1&&r.to>=e-1)}function PW(i){let e=i.state.doc,t=new Map,n=0,r="";for(let o=1;o<=e.lines;o++){let s=e.line(o),l=Os.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;t.set(n,{role:"open",language:r,code:a,blockFrom:c,blockTo:h});for(let f=n+1;f<o;f++)t.set(f,{role:"body",language:r,code:a,blockFrom:c,blockTo:h});t.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
42
  `),s=e.line(n).from,l=e.length;t.set(n,{role:"open",language:r,code:o,blockFrom:s,blockTo:l});for(let a=n+1;a<=e.lines;a++)t.set(a,{role:"body",language:r,code:o,blockFrom:s,blockTo:l})}return t}function $W(i){let e=new Set;return B(i.state).iterate({enter:t=>{if(t.name==="Table"){let n=i.state.doc.lineAt(t.from).number,r=i.state.doc.lineAt(t.to).number;for(let o=n;o<=r;o++)e.add(o);return!1}}}),e}function fP(i,e=!0){let t=[],n=i.state.doc,r=PW(i),o=$W(i),s=e?gW(i):{decorations:[],urlRanges:[]};t.push(...s.decorations,...bW(i));for(let l=1;l<=n.lines;l++){let a=n.line(l);if(o.has(l))continue;let c=hP(i,a.from,a.to),h=r.get(l);if(h){let d=hP(i,h.blockFrom,h.blockTo),O=h.role==="open"?" cm-md-code-open":h.role==="close"?" cm-md-code-close":"";if(t.push(X.line({class:`cm-md-code-line${O}`}).range(a.from)),!d&&h.role!=="body"){let p=new eg(h.role==="open"?h.language:"",h.code);t.push(Mi.range(a.from,a.to)),t.push(X.widget({widget:p,side:-1}).range(a.from))}continue}let f=dW.exec(a.text);if(f&&(t.push(X.line({class:"cm-md-quote"}).range(a.from)),c||t.push(Mi.range(a.from,a.from+f[0].length))),!c&&pP.test(a.text)){t.push(Mi.range(a.from,a.to)),t.push(X.widget({widget:new Jm(a.from),side:-1}).range(a.from));continue}if(vP.test(a.text)&&t.push(X.line({class:"cm-md-list-line"}).range(a.from)),!c){let d=uW.exec(a.text);if(d){let p=a.from+d[1].length;t.push(X.replace({widget:new Km}).range(p,p+1))}let O=/^(#{1,6}\s+)/.exec(a.text);O&&t.push(Mi.range(a.from,a.from+O[0].length))}sP.lastIndex=0;let u;for(;u=sP.exec(a.text);){let d=a.from+u.index,O=d+u[0].length;SW(d,O,s.urlRanges)||(t.push(OW.range(d+1,O-1)),Jl(i,d,O)||(t.push(Mi.range(d,d+1)),t.push(Mi.range(O-1,O))))}}return X.set(t,!0)}function CW(i){return Oe.fromClass(class{decorations;constructor(e){this.decorations=fP(e,i)}update(e){(e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=fP(e.view,i))}},{decorations:e=>e.decorations})}var TW=CW(!0);function SP(i,e,t,n){let r=n??i.state.selection.main;if(!t){let l=new FileReader;l.onload=()=>{let a=typeof l.result=="string"?l.result:"";if(!a)return;let c=`![Pasted image](${a})`;i.dispatch({changes:{from:r.from,to:r.to,insert:c},selection:{anchor:r.from+c.length}}),i.focus()},l.readAsDataURL(e);return}let o=`![Uploading image\u2026](pasting:${Math.random().toString(36).slice(2)})`;i.dispatch({changes:{from:r.from,to:r.to,insert:o},selection:{anchor:r.from+o.length}}),i.focus();let s=l=>{let c=i.state.doc.toString().indexOf(o);c<0||i.dispatch({changes:{from:c,to:c+o.length,insert:l}})};t(e).then(l=>s(`![Pasted image](${l})`),()=>s(""))}function RW(i,e,t){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(),SP(i,s,t),!0}}return!1}function AW(i,e,t){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=i.posAtCoords({x:e.clientX,y:e.clientY})??i.state.selection.main.from;return SP(i,r[0],t,{from:s,to:s}),!0}var vP=/^\s*(?:[-+*]|\d+[.)])\s+/;function uP(i){let e=i.state.doc.lineAt(i.state.selection.main.head);return vP.test(e.text)}var XW=/^\s*(?:#{1,6}|>|[-+*]|\d+[.)]|`{1,}|\*\*|__|~~|_)\s*$/;function _W(i){return Os.test(i)||pP.test(i)||XW.test(i)}function cf(i,e){let t=i.state.selection.main;if(!t.empty)return!1;let n=i.coordsAtPos(t.head),r=i.moveVertically(t,e>0),o=i.coordsAtPos(r.head);if(!n||!o||r.head===t.head)return!1;let l=Array.from(i.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];EW(c,e<0)}),!0):!1}function EW(i,e){let t=i.ownerDocument,n=t.createTreeWalker(i,NodeFilter.SHOW_TEXT),r=[];for(;n.nextNode();)r.push(n.currentNode);let o=e?r[r.length-1]:r[0],s=t.createRange();o?s.setStart(o,e?o.textContent?.length??0:0):s.selectNodeContents(i),s.collapse(!0);let l=t.getSelection();l?.removeAllRanges(),l?.addRange(s);let a=c=>{let h=i.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 dP(i,e){let t=i.state.selection.main;if(!t.empty)return!1;let n=i.state.doc,r=n.lineAt(t.head),o=r.number+e;if(o<1||o>n.lines)return!1;let s=n.line(o);if(!_W(s.text))return!1;let l=i.moveVertically(t,e>0),a=n.lineAt(l.head).number;if(a===o)return!1;let c=e>0?a>o:a<o,h=l.head===t.head;if(!c&&!h)return!1;let f=t.head-r.from;return i.dispatch({selection:{anchor:s.from+Math.min(f,s.length)},scrollIntoView:!0}),!0}function ZW(i){let e=i.state.selection.main;if(!e.empty)return!1;let t=i.state.doc.lineAt(e.head),n=t.text.slice(0,e.head-t.from),r=t.text.slice(e.head-t.from);if(!/^\s*``$/.test(n)||r.trim()!=="")return!1;let o=0;for(let a=1;a<t.number;a++)Os.test(i.state.doc.line(a).text)&&o++;if(o%2!==0)return!1;let l=`${/^\s*/.exec(n)?.[0]??""}\`\`\``;return i.dispatch({changes:{from:e.head,insert:`\`
43
43