"use strict";var t=require("obsidian");function e(t,e,i,o){return new(i||(i=Promise))(function(n,s){function r(t){try{l(o.next(t))}catch(t){s(t)}}function a(t){try{l(o.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}l((o=o.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const i=["Custom","editingToolbar","editingToolbarSub","editingToolbarAdd","editingToolbarDelete","editingToolbarReload","codeblock-glyph","underline-glyph","superscript-glyph","subscript-glyph","bot-glyph","header-1","header-2","header-3","header-4","header-5","header-6","header-n","obsidian","obsidian-new","accessibility","activity","air-vent","airplay","alarm-check","alarm-clock-off","alarm-clock","alarm-minus","alarm-plus","album","alert-circle","alert-octagon","alert-triangle","align-center-horizontal","align-center-vertical","align-center","align-end-horizontal","align-end-vertical","align-horizontal-distribute-center","align-horizontal-distribute-end","align-horizontal-distribute-start","align-horizontal-justify-center","align-horizontal-justify-end","align-horizontal-justify-start","align-horizontal-space-around","align-horizontal-space-between","align-justify","align-left","align-right","align-start-horizontal","align-start-vertical","align-vertical-distribute-center","align-vertical-distribute-end","align-vertical-distribute-start","align-vertical-justify-center","align-vertical-justify-end","align-vertical-justify-start","align-vertical-space-around","align-vertical-space-between","anchor","angry","annoyed","aperture","apple","archive-restore","archive","armchair","arrow-big-down","arrow-big-left","arrow-big-right","arrow-big-up","arrow-down-circle","arrow-down-left","arrow-down-right","arrow-down","arrow-left-circle","arrow-left-right","arrow-left","arrow-right-circle","arrow-right","arrow-up-circle","arrow-up-left","arrow-up-right","arrow-up","asterisk","at-sign","award","axe","axis-3d","baby","backpack","baggage-claim","banana","banknote","bar-chart-2","bar-chart-3","bar-chart-4","bar-chart-horizontal","bar-chart","baseline","bath","battery-charging","battery-full","battery-low","battery-medium","battery","beaker","bed-double","bed-single","bed","beer","bell-minus","bell-off","bell-plus","bell-ring","bell","bike","binary","bitcoin","bluetooth-connected","bluetooth-off","bluetooth-searching","bluetooth","bold","bomb","bone","book-open","book","bookmark-minus","bookmark-plus","bookmark","bot","box-select","box","boxes","briefcase","brush","bug","building-2","building","bus","cake","calculator","calendar-check-2","calendar-check","calendar-clock","calendar-days","calendar-heart","calendar-minus","calendar-off","calendar-plus","calendar-range","calendar-search","calendar-x2","calendar-x","calendar","camera-off","camera","car","carrot","cast","check-circle-2","check-circle","check-square","check","chef-hat","cherry","chevron-down","chevron-first","chevron-last","chevron-left","chevron-right","chevron-up","chevrons-down-up","chevrons-down","chevrons-left-right","chevrons-left","chevrons-right-left","chevrons-right","chevrons-up-down","chevrons-up","chrome","cigarette-off","cigarette","circle-dot","circle-ellipsis","circle-slashed","circle","citrus","clapperboard","clipboard-check","clipboard-copy","clipboard-edit","clipboard-list","clipboard-signature","clipboard-type","clipboard-x","clipboard","clock-1","clock-10","clock-11","clock-12","clock-2","clock-3","clock-4","clock-5","clock-6","clock-7","clock-8","clock-9","clock","cloud-cog","cloud-drizzle","cloud-fog","cloud-hail","cloud-lightning","cloud-moon-rain","cloud-moon","cloud-off","cloud-rain-wind","cloud-rain","cloud-snow","cloud-sun-rain","cloud-sun","cloud","cloudy","clover","code-2","code","codepen","codesandbox","coffee","cog","coins","columns","command","compass","component","contact","contrast","cookie","copy","copyleft","copyright","corner-down-left","corner-down-right","corner-left-down","corner-left-up","corner-right-down","corner-right-up","corner-up-left","corner-up-right","cpu","credit-card","croissant","crop","cross","crosshair","crown","cup-soda","curly-braces","currency","database","delete","diamond","dice-1","dice-2","dice-3","dice-4","dice-5","dice-6","dices","diff","disc","divide-circle","divide-square","divide","dollar-sign","download-cloud","download","dribbble","droplet","droplets","drumstick","edit-2","edit-3","edit","egg-fried","egg","equal-not","equal","eraser","euro","expand","external-link","eye-off","eye","facebook","factory","fast-forward","feather","figma","file-archive","file-audio-2","file-audio","file-axis-3d","file-badge-2","file-badge","file-bar-chart-2","file-bar-chart","file-box","file-check-2","file-check","file-clock","file-code","file-cog-2","file-cog","file-diff","file-digit","file-down","file-edit","file-heart","file-image","file-input","file-json-2","file-json","file-key-2","file-key","file-line-chart","file-lock-2","file-lock","file-minus-2","file-minus","file-output","file-pie-chart","file-plus-2","file-plus","file-question","file-scan","file-search-2","file-search","file-signature","file-spreadsheet","file-symlink","file-terminal","file-text","file-type-2","file-type","file-up","file-video-2","file-video","file-volume-2","file-volume","file-warning","file-x2","file-x","file","files","film","filter","fingerprint","flag-off","flag-triangle-left","flag-triangle-right","flag","flame","flashlight-off","flashlight","flask-conical","flask-round","flip-horizontal-2","flip-horizontal","flip-vertical-2","flip-vertical","flower-2","flower","focus","folder-archive","folder-check","folder-clock","folder-closed","folder-cog-2","folder-cog","folder-down","folder-edit","folder-heart","folder-input","folder-key","folder-lock","folder-minus","folder-open","folder-output","folder-plus","folder-search-2","folder-search","folder-symlink","folder-tree","folder-up","folder-x","folder","folders","form-input","forward","frame","framer","frown","fuel","function-square","gamepad-2","gamepad","gauge","gavel","gem","ghost","gift","git-branch-plus","git-branch","git-commit","git-compare","git-fork","git-merge","git-pull-request-closed","git-pull-request-draft","git-pull-request","github","gitlab","glass-water","glasses","globe-2","globe","grab","graduation-cap","grape","grid","grip-horizontal","grip-vertical","hammer","hand-metal","hand","hard-drive","hard-hat","hash","haze","headphones","heart-crack","heart-handshake","heart-off","heart-pulse","heart","help-circle","hexagon","highlighter","history","home","hourglass","ice-cream","image-minus","image-off","image-plus","image","import","inbox","indent","indian-rupee","infinity","info","inspect","instagram","italic","japanese-yen","joystick","key","keyboard","lamp-ceiling","lamp-desk","lamp-floor","lamp-wall-down","lamp-wall-up","lamp","landmark","languages","laptop-2","laptop","lasso-select","lasso","laugh","layers","layout-dashboard","layout-grid","layout-list","layout-template","layout","leaf","library","life-buoy","lightbulb-off","lightbulb","line-chart","link-2off","link-2","link","linkedin","list-checks","list-end","list-minus","list-music","list-ordered","list-plus","list-start","list-video","list-x","list","loader-2","loader","locate-fixed","locate-off","locate","lock","log-in","log-out","luggage","magnet","mail-check","mail-minus","mail-open","mail-plus","mail-question","mail-search","mail-warning","mail-x","mail","mails","map-pin-off","map-pin","map","martini","maximize-2","maximize","medal","megaphone-off","megaphone","meh","menu","message-circle","message-square","mic-2","mic-off","mic","microscope","milestone","minimize-2","minimize","minus-circle","minus-square","minus","monitor-off","monitor-speaker","monitor","moon","more-horizontal","more-vertical","mountain-snow","mountain","mouse-pointer-2","mouse-pointer-click","mouse-pointer","mouse","move-3d","move-diagonal-2","move-diagonal","move-horizontal","move-vertical","move","music-2","music-3","music-4","music","navigation-2off","navigation-2","navigation-off","navigation","network","newspaper","octagon","option","outdent","package-2","package-check","package-minus","package-open","package-plus","package-search","package-x","package","paint-bucket","paintbrush-2","paintbrush","palette","palmtree","paperclip","party-popper","pause-circle","pause-octagon","pause","pen-tool","pencil","percent","person-standing","phone-call","phone-forwarded","phone-incoming","phone-missed","phone-off","phone-outgoing","phone","pie-chart","piggy-bank","pin-off","pin","pipette","pizza","plane","play-circle","play","plug-zap","plus-circle","plus-square","plus","pocket","podcast","pointer","pound-sterling","power-off","power","printer","puzzle","qr-code","quote","radio-receiver","radio","recycle","redo-2","redo","refresh-ccw","refresh-cw","regex","repeat-1","repeat","reply-all","reply","rewind","rocket","rocking-chair","rotate-3d","rotate-ccw","rotate-cw","rss","ruler","russian-ruble","save","scale-3d","scale","scaling","scan-face","scan-line","scan","scissors","screen-share-off","screen-share","scroll","search","send","separator-horizontal","separator-vertical","server-cog","server-crash","server-off","server","settings-2","settings","share-2","share","sheet","shield-alert","shield-check","shield-close","shield-off","shield","shirt","shopping-bag","shopping-cart","shovel","shrink","shrub","shuffle","sidebar-close","sidebar-open","sidebar","sigma","signal-high","signal-low","signal-medium","signal-zero","signal","siren","skip-back","skip-forward","skull","slack","slash","slice","sliders-horizontal","sliders","smartphone-charging","smartphone","smile-plus","smile","snowflake","sofa","sort-asc","sort-desc","speaker","sprout","square","star-half","star-off","star","stethoscope","sticker","sticky-note","stop-circle","stretch-horizontal","stretch-vertical","strikethrough","subscript","sun-dim","sun-medium","sun-moon","sun-snow","sun","sunrise","sunset","superscript","swiss-franc","switch-camera","sword","swords","syringe","table-2","table","tablet","tag","tags","target","tent","terminal-square","terminal","text-cursor-input","text-cursor","thermometer-snowflake","thermometer-sun","thermometer","thumbs-down","thumbs-up","ticket","timer-off","timer-reset","timer","toggle-left","toggle-right","tornado","toy-brick","train","trash-2","trash","tree-deciduous","tree-pine","trees","trello","trending-down","trending-up","triangle","trophy","truck","tv-2","tv","twitch","twitter","type","umbrella","underline","undo-2","undo","unlink-2","unlink","unlock","upload-cloud","upload","usb","user-check","user-cog","user-minus","user-plus","user-x","user","users","utensils-crossed","utensils","venetian-mask","verified","vibrate-off","vibrate","video-off","video","view","voicemail","volume-1","volume-2","volume-x","volume","wallet","wand-2","wand","watch","waves","webcam","webhook","wifi-off","wifi","wind","wine","wrap-text","wrench","x-circle","x-octagon","x-square","x","youtube","zap-off","zap","zoom-in","zoom-out","create-new","trash","search","right-triangle","document","folder","pencil","left-arrow","right-arrow","three-horizontal-bars","dot-network","audio-file","image-file","pdf-file","gear","documents","blocks","go-to-file","presentation","cross-in-box","microphone","microphone-filled","two-columns","link","popup-open","checkmark","hashtag","left-arrow-with-tail","right-arrow-with-tail","up-arrow-with-tail","down-arrow-with-tail","lines-of-text","vertical-three-dots","pin","magnifying-glass","info","horizontal-split","vertical-split","calendar-with-checkmark","folder-minus","sheets-in-box","up-and-down-arrows","broken-link","cross","any-key","reset","star","crossed-star","dice","filled-pin","enter","help","vault","open-vault","paper-plane","bullet-list","uppercase-lowercase-a","star-list","expand-vertically","languages","switch","pane-layout","install","sync","check-in-circle","sync-small","check-small","paused","forward-arrow","stacked-levels","bracket-glyph","note-glyph","tag-glyph","price-tag-glyph","heading-glyph","bold-glyph","italic-glyph","strikethrough-glyph","highlight-glyph","code-glyph","quote-glyph","link-glyph","bullet-list-glyph","number-list-glyph","checkbox-glyph","undo-glyph","redo-glyph","up-chevron-glyph","down-chevron-glyph","left-chevron-glyph","right-chevron-glyph","percent-sign-glyph","keyboard-glyph","double-up-arrow-glyph","double-down-arrow-glyph","image-glyph","wrench-screwdriver-glyph","clock","plus-with-circle","minus-with-circle","indent-glyph","unindent-glyph","fullscreen","exit-fullscreen","cloud","run-command","compress-glyph","enlarge-glyph","scissors-glyph","up-curly-arrow-glyph","down-curly-arrow-glyph","plus-minus-glyph","links-going-out","links-coming-in","add-note-glyph","duplicate-glyph","clock-glyph","calendar-glyph","command-glyph","dice-glyph","file-explorer-glyph","graph-glyph","import-glyph","navigate-glyph","open-elsewhere-glyph","presentation-glyph","paper-plane-glyph","question-mark-glyph","restore-file-glyph","search-glyph","star-glyph","play-audio-glyph","stop-audio-glyph","tomorrow-glyph","wand-glyph","workspace-glyph","yesterday-glyph","box-glyph","merge-files-glyph","merge-files","two-blank-pages","scissors","paste","paste-text","split","select-all-text","wand","github-glyph","reading-glasses","user-manual-filled","discord-filled","chat-bubbles-filled","experiment-filled","bracket-glyph","box-glyph","check-small","dice-glyph","dice","discord","right-triangle","heading-glyph","help","keyboard-toggle","broken-link","experiment","left-arrow","link","link-glyph","links-coming-in","links-going-out","open-vault","paused","question-mark-glyph","right-arrow","sidebar-left","sidebar-right","sheets-in-box","star-list","sync-small","tabs","uppercase-lowercase-a","vault","stack-horizontal","stack-vertical","stretch-horizontal","stretch-vertical","distribute-space-horizontal","distribute-space-vertical"],o=1024;let n=0;class s{constructor(t,e){this.from=t,this.to=e}}class r{constructor(t={}){this.id=n++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=c.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}r.closedBy=new r({deserialize:t=>t.split(" ")}),r.openedBy=new r({deserialize:t=>t.split(" ")}),r.group=new r({deserialize:t=>t.split(" ")}),r.isolate=new r({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),r.contextHash=new r({perNode:!0}),r.lookAhead=new r({perNode:!0}),r.mounted=new r({perNode:!0});class a{constructor(t,e,i,o=!1){this.tree=t,this.overlay=e,this.parser=i,this.bracketed=o}static get(t){return t&&t.props&&t.props[r.mounted.id]}}const l=Object.create(null);class c{constructor(t,e,i,o=0){this.name=t,this.props=e,this.id=i,this.flags=o}static define(t){let e=t.props&&t.props.length?Object.create(null):l,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),o=new c(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(o)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return o}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(r.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let o of i.split(" "))e[o]=t[i];return t=>{for(let i=t.prop(r.group),o=-1;o<(i?i.length:0);o++){let n=e[o<0?t.name:i[o]];if(n)return n}}}}c.none=new c("",Object.create(null),0,8);const h=new WeakMap,d=new WeakMap;var u;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"}(u||(u={}));class p{constructor(t,e,i,o,n){if(this.type=t,this.children=e,this.positions=i,this.length=o,this.props=null,n&&n.length){this.props=Object.create(null);for(let[t,e]of n)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=a.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new E(this.topNode,t)}cursorAt(t,e=0,i=0){let o=h.get(this)||this.topNode,n=new E(o);return n.moveTo(t,e),h.set(this,n._tree),n}get topNode(){return new v(this,0,0,null)}resolve(t,e=0){let i=b(h.get(this)||this.topNode,t,e,!1);return h.set(this,i),i}resolveInner(t,e=0){let i=b(d.get(this)||this.topNode,t,e,!0);return d.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let o=t.resolveInner(e,i),n=null;for(let t=o instanceof v?o:o.context.parent;t;t=t.parent)if(t.index<0){let s=t.parent;(n||(n=[o])).push(s.resolve(e,i)),t=s}else{let s=a.get(t.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let r=new v(s.tree,s.overlay[0].from+t.from,-1,t);(n||(n=[o])).push(b(r,e,i,!1))}}return n?S(n):o}(this,t,e)}iterate(t){let{enter:e,leave:i,from:o=0,to:n=this.length}=t,s=t.mode||0,r=(s&u.IncludeAnonymous)>0;for(let t=this.cursor(s|u.IncludeAnonymous);;){let s=!1;if(t.from<=n&&t.to>=o&&(!r&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;s=!0}for(;s&&i&&(r||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;s=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:D(c.none,this.children,this.positions,0,this.children.length,0,this.length,(t,e,i)=>new p(this.type,t,e,i,this.propValues),t.makeTree||((t,e,i)=>new p(c.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:s=o,reused:a=[],minRepeatType:l=n.types.length}=t,c=Array.isArray(i)?new m(i,i.length):i,h=n.types,d=0,u=0;function f(t,e,i,o,r,p){let{id:m,start:k,end:S,size:T}=c,E=u,M=d;if(T<0){if(c.next(),-1==T){let e=a[m];return i.push(e),void o.push(k-t)}if(-3==T)return void(d=m);if(-4==T)return void(u=m);throw new RangeError(`Unrecognized record size: ${T}`)}let A,I,O=h[m],B=k-t;if(S-k<=s&&(I=C(c.pos-e,r))){let e=new Uint16Array(I.size-I.skip),i=c.pos-I.size,o=e.length;for(;c.pos>i;)o=x(I.start,e,o);A=new g(e,S-I.start,n),B=I.start-t}else{let t=c.pos-T;c.next();let e=[],i=[],o=m>=l?m:-1,n=0,r=S;for(;c.pos>t;)o>=0&&c.id==o&&c.size>=0?(c.end<=r-s&&(v(e,i,k,n,c.end,r,o,E,M),n=e.length,r=c.end),c.next()):p>2500?b(k,t,e,i):f(k,t,e,i,o,p+1);if(o>=0&&n>0&&n-1&&n>0){let t=y(O,M);A=D(O,e,i,0,e.length,0,S-k,t,t)}else A=w(O,e,i,S-k,E-S,M)}i.push(A),o.push(B)}function b(t,e,i,o){let r=[],a=0,l=-1;for(;c.pos>e;){let{id:t,start:e,end:i,size:o}=c;if(o>4)c.next();else{if(l>-1&&e=0;t-=3)e[i++]=r[t],e[i++]=r[t+1]-s,e[i++]=r[t+2]-s,e[i++]=i;i.push(new g(e,r[2]-s,n)),o.push(s-t)}}function y(t,e){return(i,o,n)=>{let s,a,l=0,c=i.length-1;if(c>=0&&(s=i[c])instanceof p){if(!c&&s.type==t&&s.length==n)return s;(a=s.prop(r.lookAhead))&&(l=o[c]+s.length+a)}return w(t,i,o,n,l,e)}}function v(t,e,i,o,s,r,a,l,c){let h=[],d=[];for(;t.length>o;)h.push(t.pop()),d.push(e.pop()+i-s);t.push(w(n.types[a],h,d,r-s,l-r,c)),e.push(s-i)}function w(t,e,i,o,n,s,a){if(s){let t=[r.contextHash,s];a=a?[t].concat(a):[t]}if(n>25){let t=[r.lookAhead,n];a=a?[t].concat(a):[t]}return new p(t,e,i,o,a)}function C(t,e){let i=c.fork(),o=0,n=0,r=0,a=i.end-s,h={size:0,start:0,skip:0};t:for(let s=i.pos-t;i.pos>s;){let t=i.size;if(i.id==e&&t>=0){h.size=o,h.start=n,h.skip=r,r+=4,o+=4,i.next();continue}let c=i.pos-t;if(t<0||c=l?4:0,u=i.start;for(i.next();i.pos>c;){if(i.size<0){if(-3!=i.size&&-4!=i.size)break t;d+=4}else i.id>=l&&(d+=4);i.next()}n=u,o+=t,r+=d}return(e<0||o==t)&&(h.size=o,h.start=n,h.skip=r),h.size>4?h:void 0}function x(t,e,i){let{id:o,start:n,end:s,size:r}=c;if(c.next(),r>=0&&o4){let o=c.pos-(r-4);for(;c.pos>o;)i=x(t,e,i)}e[--i]=a,e[--i]=s-t,e[--i]=n-t,e[--i]=o}else-3==r?d=o:-4==r&&(u=o);return i}let k=[],S=[];for(;c.pos>0;)f(t.start||0,t.bufferStart||0,k,S,-1,0);let T=null!==(e=t.length)&&void 0!==e?e:k.length?S[0]+k[0].length:0;return new p(h[t.topID],k.reverse(),S.reverse(),T)}(t)}}p.empty=new p(c.none,[],[],0);class m{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new m(this.buffer,this.index)}}class g{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return c.none}toString(){let t=[];for(let e=0;e0));a=s[a+3]);return r}slice(t,e,i){let o=this.buffer,n=new Uint16Array(e-t),s=0;for(let r=t,a=0;r=e&&ie;case 1:return i<=e&&o>e;case 2:return o>e;case 4:return!0}}function b(t,e,i,o){for(var n;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to0?l.length:-1;t!=h;t+=e){let h=l[t],d=c[t]+r.from;if(n&u.EnterBracketed&&h instanceof p&&null===(null===(s=a.get(h))||void 0===s?void 0:s.overlay)&&(d>=i||d+h.length<=i)||f(o,i,d,d+h.length))if(h instanceof g){if(n&u.ExcludeBuffers)continue;let s=h.findChild(0,h.buffer.length,e,i-d,o);if(s>-1)return new k(new x(r,h,t,d),null,s)}else if(n&u.IncludeAnonymous||!h.type.isAnonymous||M(h)){let s;if(!(n&u.IgnoreMounts)&&(s=a.get(h))&&!s.overlay)return new v(s.tree,d,t,r);let l=new v(h,d,t,r);return n&u.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(e<0?h.children.length-1:0,e,i,o,n)}}if(n&u.IncludeAnonymous||!r.type.isAnonymous)return null;if(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,r=r._parent,!r)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,e,i=0){let o;if(!(i&u.IgnoreOverlays)&&(o=a.get(this._tree))&&o.overlay){let n=t-this.from,s=i&u.EnterBracketed&&o.bracketed;for(let{from:t,to:i}of o.overlay)if((e>0||s?t<=n:t=n:i>n))return new v(o.tree,o.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function w(t,e,i,o){let n=t.cursor(),s=[];if(!n.firstChild())return s;if(null!=i)for(let t=!1;!t;)if(t=n.type.is(i),!n.nextSibling())return s;for(;;){if(null!=o&&n.type.is(o))return s;if(n.type.is(e)&&s.push(n.node),!n.nextSibling())return null==o?s:[]}}function C(t,e,i=e.length-1){for(let o=t;i>=0;o=o.parent){if(!o)return!1;if(!o.type.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}class x{constructor(t,e,i,o){this.parent=t,this.buffer=e,this.index=i,this.start=o}}class k extends y{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:o}=this.context,n=o.findChild(this.index+4,o.buffer[this.index+3],t,e-this.context.start,i);return n<0?null:new k(this.context,this,n)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,e,i=0){if(i&u.ExcludeBuffers)return null;let{buffer:o}=this.context,n=o.findChild(this.index+4,o.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return n<0?null:new k(this.context,this,n)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new k(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new k(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,o=this.index+4,n=i.buffer[this.index+3];if(n>o){let s=i.buffer[this.index+1];t.push(i.slice(o,n,s)),e.push(0)}return new p(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function S(t){if(!t.length)return null;let e=0,i=t[0];for(let o=1;oi.from||n.to0){if(this.index-1)for(let o=e+t,n=t<0?-1:i._tree.children.length;o!=n;o+=t){let t=i._tree.children[o];if(this.mode&u.IncludeAnonymous||t instanceof g||!t.type.isAnonymous||M(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to=0;){for(let s=t;s;s=s._parent)if(s.index==o){if(o==this.index)return s;e=s,i=n+1;break t}o=this.stack[--n]}for(let t=i;t=0;n--){if(n<0)return C(this._tree,t,o);let s=i[e.buffer[this.stack[n]]];if(!s.isAnonymous){if(t[o]&&t[o]!=s.name)return!1;o--}}return!0}}function M(t){return t.children.some(t=>t instanceof g||!t.type.isAnonymous||M(t))}const A=new WeakMap;function I(t,e){if(!t.isAnonymous||e instanceof g||e.type!=t)return 1;let i=A.get(e);if(null==i){i=1;for(let o of e.children){if(o.type!=t||!(o instanceof p)){i=1;break}i+=I(t,o)}A.set(e,i)}return i}function D(t,e,i,o,n,s,r,a,l){let c=0;for(let i=o;i=h)break;m+=e}if(c==n+1){if(m>h){let t=i[n];e(t.children,t.positions,0,t.children.length,o[n]+a);continue}d.push(i[n])}else{let e=o[c-1]+i[c-1].length-p;d.push(D(t,i,o,n,c,p,e,null,l))}u.push(p+a-s)}}(e,i,o,n,0),(a||l)(d,u,r)}class O{constructor(t,e,i,o,n=!1,s=!1){this.from=t,this.to=e,this.tree=i,this.offset=o,this.open=(n?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let o=[new O(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&o.push(i);return o}static applyChanges(t,e,i=128){if(!e.length)return t;let o=[],n=1,s=t.length?t[0]:null;for(let r=0,a=0,l=0;;r++){let c=r=i)for(;s&&s.from=e.from||h<=e.to||l){let t=Math.max(e.from,a)-l,i=Math.min(e.to,h)-l;e=t>=i?null:new O(t,i,e.tree,e.offset+l,r>0,!!c)}if(e&&o.push(e),s.to>h)break;s=nnew s(t.from,t.to)):[new s(0,0)]:[new s(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let o=this.startParse(t,e,i);for(;;){let t=o.advance();if(t)return t}}}class L{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new r({perNode:!0});let N=[],q=[];function R(t){if(t<768)return!1;for(let e=0,i=N.length;;){let o=e+i>>1;if(t=q[o]))return!0;e=o+1}if(e==i)return!1}}function F(t){return t>=127462&&t<=127487}(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let e=0,i=0;e=0&&F(z(t,o));)i++,o-=2;if(i%2==0)break;e+=2}}}return e}function V(t,e,i){for(;e>0;){let o=_(t,e-2,i);if(o=56320&&t<57344}function W(t){return t>=55296&&t<56320}function $(t){return t<65536?1:2}class U{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=tt(this,t,e);let o=[];return this.decompose(0,t,o,2),i.length&&i.decompose(0,i.length,o,3),this.decompose(e,this.length,o,1),Y.from(o,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=tt(this,t,e);let i=[];return this.decompose(t,e,i,0),Y.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),o=new K(this),n=new K(t);for(let t=e,s=e;;){if(o.next(t),n.next(t),t=0,o.lineBreak!=n.lineBreak||o.done!=n.done||o.value!=n.value)return!1;if(s+=o.value.length,o.done||s>=i)return!0}}iter(t=1){return new K(this,t)}iterRange(t,e=this.length){return new J(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let o=this.line(t).from;i=this.iterRange(o,Math.max(o,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new X(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new j(t):Y.from(j.split(t,[])):U.empty}}class j extends U{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,o){for(let n=0;;n++){let s=this.text[n],r=o+s.length;if((e?i:r)>=t)return new Q(o,r,i,s);o=r+1,i++}}decompose(t,e,i,o){let n=t<=0&&e>=this.length?this:new j(Z(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&o){let t=i.pop(),e=G(n.text,t.text.slice(),0,n.length);if(e.length<=32)i.push(new j(e,t.length+n.length));else{let t=e.length>>1;i.push(new j(e.slice(0,t)),new j(e.slice(t)))}}else i.push(n)}replace(t,e,i){if(!(i instanceof j))return super.replace(t,e,i);[t,e]=tt(this,t,e);let o=G(this.text,G(i.text,Z(this.text,0,t)),e),n=this.length+i.length-(e-t);return o.length<=32?new j(o,n):Y.from(j.split(o,[]),n)}sliceString(t,e=this.length,i="\n"){[t,e]=tt(this,t,e);let o="";for(let n=0,s=0;n<=e&&st&&s&&(o+=i),tn&&(o+=r.slice(Math.max(0,t-n),e-n)),n=a+1}return o}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],o=-1;for(let n of t)i.push(n),o+=n.length+1,32==i.length&&(e.push(new j(i,o)),i=[],o=-1);return o>-1&&e.push(new j(i,o)),e}}class Y extends U{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,o){for(let n=0;;n++){let s=this.children[n],r=o+s.length,a=i+s.lines-1;if((e?a:r)>=t)return s.lineInner(t,e,i,o);o=r+1,i=a+1}}decompose(t,e,i,o){for(let n=0,s=0;s<=e&&n=s){let n=o&((s<=t?1:0)|(a>=e?2:0));s>=t&&a<=e&&!n?i.push(r):r.decompose(t-s,e-s,i,n)}s=a+1}}replace(t,e,i){if([t,e]=tt(this,t,e),i.lines=n&&e<=r){let a=s.replace(t-n,e-n,i),l=this.lines-s.lines+a.lines;if(a.lines>4&&a.lines>l>>6){let n=this.children.slice();return n[o]=a,new Y(n,this.length-(e-t)+i.length)}return super.replace(n,r,a)}n=r+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=tt(this,t,e);let o="";for(let n=0,s=0;nt&&n&&(o+=i),ts&&(o+=r.sliceString(t-s,e-s,i)),s=a+1}return o}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof Y))return 0;let i=0,[o,n,s,r]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;o+=e,n+=e){if(o==s||n==r)return i;let a=this.children[o],l=t.children[n];if(a!=l)return i+a.scanIdentical(l,e);i+=a.length+1}}static from(t,e=t.reduce((t,e)=>t+e.length+1,-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new j(i,e)}let o=Math.max(32,i>>5),n=o<<1,s=o>>1,r=[],a=0,l=-1,c=[];function h(t){let e;if(t.lines>n&&t instanceof Y)for(let e of t.children)h(e);else t.lines>s&&(a>s||!a)?(d(),r.push(t)):t instanceof j&&a&&(e=c[c.length-1])instanceof j&&t.lines+e.lines<=32?(a+=t.lines,l+=t.length+1,c[c.length-1]=new j(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>o&&d(),a+=t.lines,l+=t.length+1,c.push(t))}function d(){0!=a&&(r.push(1==c.length?c[0]:Y.from(c,l)),l=-1,a=c.length=0)}for(let e of t)h(e);return d(),1==r.length?r[0]:new Y(r,e)}}function G(t,e,i=0,o=1e9){for(let n=0,s=0,r=!0;s=i&&(l>o&&(a=a.slice(0,o-n)),n0?1:(t instanceof j?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,o=this.nodes[i],n=this.offsets[i],s=n>>1,r=o instanceof j?o.text.length:o.children.length;if(s==(e>0?r:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&n)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(o instanceof j){let n=o.text[s+(e<0?-1:0)];if(this.offsets[i]+=e,n.length>Math.max(0,t))return this.value=0==t?n:e>0?n.slice(t):n.slice(0,n.length-t),this;t-=n.length}else{let n=o.children[s+(e<0?-1:0)];t>n.length?(t-=n.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(n),this.offsets.push(e>0?1:(n instanceof j?n.text.length:n.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class J{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new K(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:o}=this.cursor.next(t);return this.pos+=(o.length+t)*e,this.value=o.length<=i?o:e<0?o.slice(o.length-i):o.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class X{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:o}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=o,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(U.prototype[Symbol.iterator]=function(){return this.iter()},K.prototype[Symbol.iterator]=J.prototype[Symbol.iterator]=X.prototype[Symbol.iterator]=function(){return this});class Q{constructor(t,e,i,o){this.from=t,this.to=e,this.number=i,this.text=o}get length(){return this.to-this.from}}function tt(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}function et(t,e,i=!0,o=!0){return P(t,e,i,o)}const it=/\r\n?|\n/;var ot=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(ot||(ot={}));class nt{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;et)return n+(t-o);n+=r}else{if(i!=ot.Simple&&l>=t&&(i==ot.TrackDel&&ot||i==ot.TrackBefore&&ot))return null;if(l>t||l==t&&e<0&&!r)return t==o||e<0?n:n+a;n+=a}o=l}if(t>o)throw new RangeError(`Position ${t} is out of range for changeset of length ${o}`);return n}touchesRange(t,e=t){for(let i=0,o=0;i=0&&o<=e&&n>=t)return!(oe)||"cover";o=n}return!1}toString(){let t="";for(let e=0;e=0?":"+o:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(t=>"number"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeDesc");return new nt(t)}static create(t){return new nt(t)}}class st extends nt{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return lt(this,(e,i,o,n,s)=>t=t.replace(o,o+(i-e),s),!1),t}mapDesc(t,e=!1){return ct(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let o=0,n=0;o=0){e[o]=r,e[o+1]=s;let a=o>>1;for(;i.length0&&at(i,e,n.text),n.forward(t),r+=t}let l=t[s++];for(;r>1].toJSON()))}return t}static of(t,e,i){let o=[],n=[],s=0,r=null;function a(t=!1){if(!t&&!o.length)return;sr||t<0||r>e)throw new RangeError(`Invalid change range ${t} to ${r} (in doc of length ${e})`);let h=c?"string"==typeof c?U.of(c.split(i||it)):c:U.empty,d=h.length;if(t==r&&0==d)return;ts&&rt(o,t-s,-1),rt(o,r-t,d),at(n,o,h),s=r}}(t),a(!r),r}static empty(t){return new st(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let o=0;oe&&"string"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==n.length)e.push(n[0],0);else{for(;i.length=0&&i<=0&&i==t[n+1]?t[n]+=e:n>=0&&0==e&&0==t[n]?t[n+1]+=i:o?(t[n]+=e,t[n+1]+=i):t.push(e,i)}function at(t,e,i){if(0==i.length)return;let o=e.length-2>>1;if(o>1])),!(i||r==t.sections.length||t.sections[r+1]<0);)a=t.sections[r++],l=t.sections[r++];e(n,c,s,h,d),n=c,s=h}}}function ct(t,e,i,o=!1){let n=[],s=o?[]:null,r=new dt(t),a=new dt(e);for(let t=-1;;){if(r.done&&a.len||a.done&&r.len)throw new Error("Mismatched change set lengths");if(-1==r.ins&&-1==a.ins){let t=Math.min(r.len,a.len);rt(n,t,-1),r.forward(t),a.forward(t)}else if(a.ins>=0&&(r.ins<0||t==r.i||0==r.off&&(a.len=0&&t=0)){if(r.done&&a.done)return s?st.createSet(n,s):nt.create(n);throw new Error("Mismatched change set lengths")}{let e=0,i=r.len;for(;i;)if(-1==a.ins){let t=Math.min(i,a.len);e+=t,i-=t,a.forward(t)}else{if(!(0==a.ins&&a.lene||r.ins>=0&&r.len>e)&&(t||o.length>i),s.forward2(e),r.forward(e)}}else rt(o,0,r.ins,t),n&&at(n,o,r.text),r.next()}}class dt{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i>1;return e>=t.length?U.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?U.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class ut{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let i,o;return this.empty?i=o=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),o=t.mapPos(this.to,-1)),i==this.from&&o==this.to?this:new ut(i,o,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return pt.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return pt.range(this.anchor,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return pt.range(t.anchor,t.head)}static create(t,e,i){return new ut(t,e,i)}}class pt{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:pt.create(this.ranges.map(i=>i.map(t,e)),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;it.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new pt(t.ranges.map(t=>ut.fromJSON(t)),t.main)}static single(t,e=t){return new pt([pt.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,o=0;ot?8:0)|n)}static normalized(t,e=0){let i=t[e];t.sort((t,e)=>t.from-e.from),e=t.indexOf(i);for(let i=1;io.head?pt.range(r,s):pt.range(s,r))}}return new pt(t,e)}}function mt(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let gt=0;class ft{constructor(t,e,i,o,n){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=o,this.id=gt++,this.default=t([]),this.extensions="function"==typeof n?n(this):n}get reader(){return this}static define(t={}){return new ft(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:bt),!!t.static,t.enables)}of(t){return new yt([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new yt(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new yt(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],i=>e(i.field(t)))}}function bt(t,e){return t==e||t.length==e.length&&t.every((t,i)=>t===e[i])}class yt{constructor(t,e,i,o){this.dependencies=t,this.facet=e,this.type=i,this.value=o,this.id=gt++}dynamicSlot(t){var e;let i=this.value,o=this.facet.compareInput,n=this.id,s=t[n]>>1,r=2==this.type,a=!1,l=!1,c=[];for(let i of this.dependencies)"doc"==i?a=!0:"selection"==i?l=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||c.push(t[i.id]);return{create:t=>(t.values[s]=i(t),1),update(t,e){if(a&&e.docChanged||l&&(e.docChanged||e.selection)||wt(t,c)){let e=i(t);if(r?!vt(e,t.values[s],o):!o(e,t.values[s]))return t.values[s]=e,1}return 0},reconfigure:(t,e)=>{let a,l=e.config.address[n];if(null!=l){let n=qt(e,l);if(this.dependencies.every(i=>i instanceof ft?e.facet(i)===t.facet(i):!(i instanceof kt)||e.field(i,!1)==t.field(i,!1))||(r?vt(a=i(t),n,o):o(a=i(t),n)))return t.values[s]=n,0}else a=i(t);return t.values[s]=a,1}}}}function vt(t,e,i){if(t.length!=e.length)return!1;for(let o=0;ot[e.id]),n=i.map(t=>t.type),s=o.filter(t=>!(1&t)),r=t[e.id]>>1;function a(t){let i=[];for(let e=0;et===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(xt).find(t=>t.field==this);return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let o=t.values[e],n=this.updateF(o,i);return this.compareF(o,n)?0:(t.values[e]=n,1)},reconfigure:(t,i)=>{let o,n=t.facet(xt),s=i.facet(xt);return(o=n.find(t=>t.field==this))&&o!=s.find(t=>t.field==this)?(t.values[e]=o.create(t),1):null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}}init(t){return[this,xt.of({field:this,create:t})]}get extension(){return this}}const St=4,Tt=3,Et=2,Mt=1;function At(t){return e=>new Dt(e,t)}const It={highest:At(0),high:At(Mt),default:At(Et),low:At(Tt),lowest:At(St)};class Dt{constructor(t,e){this.inner=t,this.prec=e}}class Ot{of(t){return new Bt(this,t)}reconfigure(t){return Ot.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Bt{constructor(t,e){this.compartment=t,this.inner=e}}class Lt{constructor(t,e,i,o,n,s){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=o,this.staticValues=n,this.facets=s,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(t,e,i){let o=[],n=Object.create(null),s=new Map;for(let i of function(t,e,i){let o=[[],[],[],[],[]],n=new Map;function s(t,r){let a=n.get(t);if(null!=a){if(a<=r)return;let e=o[a].indexOf(t);e>-1&&o[a].splice(e,1),t instanceof Bt&&i.delete(t.compartment)}if(n.set(t,r),Array.isArray(t))for(let e of t)s(e,r);else if(t instanceof Bt){if(i.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let o=e.get(t.compartment)||t.inner;i.set(t.compartment,o),s(o,r)}else if(t instanceof Dt)s(t.inner,t.prec);else if(t instanceof kt)o[r].push(t),t.provides&&s(t.provides,r);else if(t instanceof yt)o[r].push(t),t.facet.extensions&&s(t.facet.extensions,Et);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(e,r)}}return s(t,Et),o.reduce((t,e)=>t.concat(e))}(t,e,s))i instanceof kt?o.push(i):(n[i.facet.id]||(n[i.facet.id]=[])).push(i);let r=Object.create(null),a=[],l=[];for(let t of o)r[t.id]=l.length<<1,l.push(e=>t.slot(e));let c=null==i?void 0:i.config.facets;for(let t in n){let e=n[t],o=e[0].facet,s=c&&c[t]||[];if(e.every(t=>0==t.type))if(r[o.id]=a.length<<1|1,bt(s,e))a.push(i.facet(o));else{let t=o.combine(e.map(t=>t.value));a.push(i&&o.compare(t,i.facet(o))?i.facet(o):t)}else{for(let t of e)0==t.type?(r[t.id]=a.length<<1|1,a.push(t.value)):(r[t.id]=l.length<<1,l.push(e=>t.dynamicSlot(e)));r[o.id]=l.length<<1,l.push(t=>Ct(t,o,e))}}let h=l.map(t=>t(r));return new Lt(t,s,h,r,a,n)}}function Nt(t,e){if(1&e)return 2;let i=e>>1,o=t.status[i];if(4==o)throw new Error("Cyclic dependency between fields and/or facets");if(2&o)return o;t.status[i]=4;let n=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|n}function qt(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const Rt=ft.define(),Ft=ft.define({combine:t=>t.some(t=>t),static:!0}),Pt=ft.define({combine:t=>t.length?t[0]:void 0,static:!0}),_t=ft.define(),Vt=ft.define(),zt=ft.define(),Ht=ft.define({combine:t=>!!t.length&&t[0]});class Wt{constructor(t,e){this.type=t,this.value=e}static define(){return new $t}}class $t{of(t){return new Wt(this,t)}}class Ut{constructor(t){this.map=t}of(t){return new jt(this,t)}}class jt{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new jt(this.type,e)}is(t){return this.type==t}static define(t={}){return new Ut(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let o of t){let t=o.map(e);t&&i.push(t)}return i}}jt.reconfigure=jt.define(),jt.appendConfig=jt.define();class Yt{constructor(t,e,i,o,n,s){this.startState=t,this.changes=e,this.selection=i,this.effects=o,this.annotations=n,this.scrollIntoView=s,this._doc=null,this._state=null,i&&mt(i,e.newLength),n.some(t=>t.type==Yt.time)||(this.annotations=n.concat(Yt.time.of(Date.now())))}static create(t,e,i,o,n,s){return new Yt(t,e,i,o,n,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(Yt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function Gt(t,e){let i=[];for(let o=0,n=0;;){let s,r;if(o=t[o]))s=t[o++],r=t[o++];else{if(!(n=0;n--){let s=i[n](t);s&&Object.keys(s).length&&(o=Zt(o,Kt(e,s,t.changes.newLength),!0))}return o==t?t:Yt.create(e,t.changes,t.selection,o.effects,o.annotations,o.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let o of e.facet(_t)){let e=o(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:Gt(i,e))}if(!0!==i){let o,n;if(!1===i)n=t.changes.invertedDesc,o=st.empty(e.doc.length);else{let e=t.changes.filter(i);o=e.changes,n=e.filtered.mapDesc(e.changes).invertedDesc}t=Yt.create(e,o,t.selection&&t.selection.map(n),jt.mapEffects(t.effects,n),t.annotations,t.scrollIntoView)}let o=e.facet(Vt);for(let i=o.length-1;i>=0;i--){let n=o[i](t);t=n instanceof Yt?n:Array.isArray(n)&&1==n.length&&n[0]instanceof Yt?n[0]:Jt(e,Qt(n),!1)}return t}(n):n)}Yt.time=Wt.define(),Yt.userEvent=Wt.define(),Yt.addToHistory=Wt.define(),Yt.remote=Wt.define();const Xt=[];function Qt(t){return null==t?Xt:Array.isArray(t)?t:[t]}var te=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(te||(te={}));const ee=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ie;try{ie=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function oe(t){return e=>{if(!/\S/.test(e))return te.Space;if(function(t){if(ie)return ie.test(t);for(let e=0;e"€"&&(i.toUpperCase()!=i.toLowerCase()||ee.test(i)))return!0}return!1}(e))return te.Word;for(let i=0;i-1)return te.Word;return te.Other}}class ne{constructor(t,e,i,o,n,s){this.config=t,this.doc=e,this.selection=i,this.values=o,this.status=t.statusTemplate.slice(),this.computeSlot=n,s&&(s._state=this);for(let t=0;tn.set(e,t)),i=null),n.set(e.value.compartment,e.value.extension)):e.is(jt.reconfigure)?(i=null,o=e.value):e.is(jt.appendConfig)&&(i=null,o=Qt(o).concat(e.value));if(i)e=t.startState.values.slice();else{i=Lt.resolve(o,n,this),e=new ne(i,this.doc,this.selection,i.dynamicSlots.map(()=>null),(t,e)=>e.reconfigure(t,this),null).values}let s=t.startState.facet(Ft)?t.newSelection:t.newSelection.asSingle();new ne(i,t.newDoc,s,e,(e,i)=>i.update(e,t),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:pt.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),o=this.changes(i.changes),n=[i.range],s=Qt(i.effects);for(let i=1;in.spec.fromJSON(s,t)))}return ne.create({doc:t.doc,selection:pt.fromJSON(t.selection),extensions:e.extensions?o.concat([e.extensions]):o})}static create(t={}){let e=Lt.resolve(t.extensions||[],new Map),i=t.doc instanceof U?t.doc:U.of((t.doc||"").split(e.staticFacet(ne.lineSeparator)||it)),o=t.selection?t.selection instanceof pt?t.selection:pt.single(t.selection.anchor,t.selection.head):pt.single(0);return mt(o,i.length),e.staticFacet(Ft)||(o=o.asSingle()),new ne(e,i,o,e.dynamicSlots.map(()=>null),(t,e)=>e.create(t),null)}get tabSize(){return this.facet(ne.tabSize)}get lineBreak(){return this.facet(ne.lineSeparator)||"\n"}get readOnly(){return this.facet(Ht)}phrase(t,...e){for(let e of this.facet(ne.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,(t,i)=>{if("$"==i)return"$";let o=+(i||1);return!o||o>e.length?t:e[o-1]})),t}languageDataAt(t,e,i=-1){let o=[];for(let n of this.facet(Rt))for(let s of n(this,e,i))Object.prototype.hasOwnProperty.call(s,t)&&o.push(s[t]);return o}charCategorizer(t){let e=this.languageDataAt("wordChars",t);return oe(e.length?e[0]:"")}wordAt(t){let{text:e,from:i,length:o}=this.doc.lineAt(t),n=this.charCategorizer(t),s=t-i,r=t-i;for(;s>0;){let t=et(e,s,!1);if(n(e.slice(t,s))!=te.Word)break;s=t}for(;rt.length?t[0]:4}),ne.lineSeparator=Pt,ne.readOnly=Ht,ne.phrases=ft.define({compare(t,e){let i=Object.keys(t),o=Object.keys(e);return i.length==o.length&&i.every(i=>t[i]==e[i])}}),ne.languageData=Rt,ne.changeFilter=_t,ne.transactionFilter=Vt,ne.transactionExtender=zt,Ot.reconfigure=jt.define();class se{eq(t){return this==t}range(t,e=t){return ae.create(t,e,this)}}function re(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}se.prototype.startSide=se.prototype.endSide=0,se.prototype.point=!1,se.prototype.mapMode=ot.TrackDel;class ae{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new ae(t,e,i)}}function le(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class ce{constructor(t,e,i,o){this.from=t,this.to=e,this.value=i,this.maxPoint=o}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,o=0){let n=i?this.to:this.from;for(let s=o,r=n.length;;){if(s==r)return s;let o=s+r>>1,a=n[o]-t||(i?this.value[o].endSide:this.value[o].startSide)-e;if(o==s)return a>=0?s:r;a>=0?r=o:s=o+1}}between(t,e,i,o){for(let n=this.findIndex(e,-1e9,!0),s=this.findIndex(i,1e9,!1,n);nc||l==c&&h.startSide>0&&h.endSide<=0)continue;(c-l||h.endSide-h.startSide)<0||(s<0&&(s=l),h.point&&(r=Math.max(r,c-l)),i.push(h),o.push(l-s),n.push(c-s))}return{mapped:i.length?new ce(o,n,i,r):null,pos:s}}}class he{constructor(t,e,i,o){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=o}static create(t,e,i,o){return new he(t,e,i,o)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:o=0,filterTo:n=this.length}=t,s=t.filter;if(0==e.length&&!s)return this;if(i&&(e=e.slice().sort(le)),this.isEmpty)return e.length?he.of(e):this;let r=new pe(this,null,-1).goto(0),a=0,l=[],c=new de;for(;r.value||a=0){let t=e[a++];c.addInner(t.from,t.to,t.value)||l.push(t)}else 1==r.rangeIndex&&r.chunkIndexthis.chunkEnd(r.chunkIndex)||nr.to||n=n&&t<=n+s.length&&!1===s.between(n,t-n,e-n,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return me.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return me.from(t).goto(e)}static compare(t,e,i,o,n=-1){let s=t.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=n),r=e.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=n),a=ue(s,r,i),l=new fe(s,a,n),c=new fe(r,a,n);i.iterGaps((t,e,i)=>be(l,t,c,e,i,o)),i.empty&&0==i.length&&be(l,0,c,0,0,o)}static eq(t,e,i=0,o){null==o&&(o=999999999);let n=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0),s=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0);if(n.length!=s.length)return!1;if(!n.length)return!0;let r=ue(n,s),a=new fe(n,r,0).goto(i),l=new fe(s,r,0).goto(i);for(;;){if(a.to!=l.to||!ye(a.active,l.active)||a.point&&(!l.point||!re(a.point,l.point)))return!1;if(a.to>o)return!0;a.next(),l.next()}}static spans(t,e,i,o,n=-1){let s=new fe(t,null,n).goto(e),r=e,a=s.openStart;for(;;){let t=Math.min(s.to,i);if(s.point){let i=s.activeForPoint(s.to),n=s.pointFromr&&(o.span(r,t,s.active,a),a=s.openEnd(t));if(s.to>i)return a+(s.point&&s.to>i?1:0);r=s.to,s.next()}}static of(t,e=!1){let i=new de;for(let o of t instanceof ae?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i0)return t.slice().sort(le);e=o}return t}(t):t)i.add(o.from,o.to,o.value);return i.finish()}static join(t){if(!t.length)return he.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let o=t[i];o!=he.empty;o=o.nextLayer)e=new he(o.chunkPos,o.chunk,e,Math.max(o.maxPoint,e.maxPoint));return e}}he.empty=new he([],[],null,-1),he.empty.nextLayer=he.empty;class de{finishChunk(t){this.chunks.push(new ce(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,t&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new de)).add(t,e,i)}addInner(t,e,i){let o=t-this.lastTo||i.startSide-this.last.endSide;if(o<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(o<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(he.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=he.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function ue(t,e,i){let o=new Map;for(let e of t)for(let t=0;t=this.minPoint)break}}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&o.push(new pe(s,e,i,n));return 1==o.length?o[0]:new me(o)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)ge(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)ge(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),ge(this.heap,0)}}}function ge(t,e){for(let i=t[e];;){let o=1+(e<<1);if(o>=t.length)break;let n=t[o];if(o+1=0&&(n=t[o+1],o++),i.compare(n)<0)break;t[o]=i,t[e]=n,e=o}}class fe{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=me.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){ve(this.active,t),ve(this.activeTo,t),ve(this.activeRank,t),this.minActive=Ce(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:o,rank:n}=this.cursor;for(;e0;)e++;we(this.active,e,i),we(this.activeTo,e,o),we(this.activeRank,e,n),t&&we(t,e,this.cursor.from),this.minActive=Ce(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let o=this.minActive;if(o>-1&&(this.activeTo[o]-this.cursor.from||this.active[o].endSide-this.cursor.startSide)<0){if(this.activeTo[o]>t){this.to=this.activeTo[o],this.endSide=this.active[o].endSide;break}this.removeActive(o),i&&ve(i,o)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from=0&&i[e]=0&&!(this.activeRank[i]t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function be(t,e,i,o,n,s){t.goto(e),i.goto(o);let r=o+n,a=o,l=o-e,c=!!s.boundChange;for(let e=!1;;){let o=t.to+l-i.to,n=o||t.endSide-i.endSide,h=n<0?t.to+l:i.to,d=Math.min(h,r);if(t.point||i.point?(t.point&&i.point&&re(t.point,i.point)&&ye(t.activeForPoint(t.to),i.activeForPoint(i.to))||s.comparePoint(a,d,t.point,i.point),e=!1):(e&&s.boundChange(a),d>a&&!ye(t.active,i.active)&&s.compareRange(a,d,t.active,i.active),c&&dr)break;a=h,n<=0&&t.next(),n>=0&&i.next()}}function ye(t,e){if(t.length!=e.length)return!1;for(let i=0;i=e;i--)t[i+1]=t[i];t[e]=i}function Ce(t,e){let i=-1,o=1e9;for(let n=0;nt.map(t=>e.replace(/&/,t))).reduce((t,e)=>t.concat(e)),r,s);else if(r&&"object"==typeof r){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");n(o(i),r,a,c)}else null!=r&&a.push(i.replace(/_.*/,"").replace(/[A-Z]/g,t=>"-"+t.toLowerCase())+": "+r+";")}(a.length||c)&&s.push((!i||l||r?t:t.map(i)).join(", ")+" {"+a.join(" ")+"}")}for(let e in t)n(o(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=Se[xe]||1;return Se[xe]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let o=t[ke],n=i&&i.nonce;o?n&&o.setNonce(n):o=new Me(t,n),o.mount(Array.isArray(e)?e:[e],t)}}let Ee=new Map;class Me{constructor(t,e){let i=t.ownerDocument||t,o=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&o.CSSStyleSheet){let e=Ee.get(i);if(e)return t[ke]=e;this.sheet=new o.CSSStyleSheet,Ee.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[ke]=this}mount(t,e){let i=this.sheet,o=0,n=0;for(let e=0;e-1&&(this.modules.splice(r,1),n--,r=-1),-1==r){if(this.modules.splice(n++,0,s),i)for(let t=0;t",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'};"undefined"!=typeof navigator&&/Mac/.test(navigator.platform),"undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var De=0;De<10;De++)Ae[48+De]=Ae[96+De]=String(De);for(De=1;De<=24;De++)Ae[De+111]="F"+De;for(De=65;De<=90;De++)Ae[De]=String.fromCharCode(De+32),Ie[De]=String.fromCharCode(De);for(var Oe in Ae)Ie.hasOwnProperty(Oe)||(Ie[Oe]=Ae[Oe]);let Be="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Le="undefined"!=typeof document?document:{documentElement:{style:{}}};const Ne=/Edge\/(\d+)/.exec(Be.userAgent),qe=/MSIE \d/.test(Be.userAgent),Re=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Be.userAgent),Fe=!!(qe||Re||Ne),Pe=!Fe&&/gecko\/(\d+)/i.test(Be.userAgent),_e=!Fe&&/Chrome\/(\d+)/.exec(Be.userAgent),Ve="webkitFontSmoothing"in Le.documentElement.style,ze=!Fe&&/Apple Computer/.test(Be.vendor),He=ze&&(/Mobile\/\w+/.test(Be.userAgent)||Be.maxTouchPoints>2);var We={mac:He||/Mac/.test(Be.platform),windows:/Win/.test(Be.platform),linux:/Linux|X11/.test(Be.platform),ie:Fe,ie_version:qe?Le.documentMode||6:Re?+Re[1]:Ne?+Ne[1]:0,gecko:Pe,gecko_version:Pe?+(/Firefox\/(\d+)/.exec(Be.userAgent)||[0,0])[1]:0,chrome:!!_e,chrome_version:_e?+_e[1]:0,ios:He,android:/Android\b/.test(Be.userAgent),webkit:Ve,webkit_version:Ve?+(/\bAppleWebKit\/(\d+)/.exec(Be.userAgent)||[0,0])[1]:0,safari:ze,safari_version:ze?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Be.userAgent)||[0,0])[1]:0,tabSize:null!=Le.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function $e(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}const Ue=Object.create(null);function je(t,e,i){if(t==e)return!0;t||(t=Ue),e||(e=Ue);let o=Object.keys(t),n=Object.keys(e);if(o.length-(i&&o.indexOf(i)>-1?1:0)!=n.length-(i&&n.indexOf(i)>-1?1:0))return!1;for(let s of o)if(s!=i&&(-1==n.indexOf(s)||t[s]!==e[s]))return!1;return!0}function Ye(t,e,i){let o=!1;if(e)for(let n in e)i&&n in i||(o=!0,"style"==n?t.style.cssText="":t.removeAttribute(n));if(i)for(let n in i)e&&e[n]==i[n]||(o=!0,"style"==n?t.style.cssText=i[n]:t.setAttribute(n,i[n]));return o}function Ge(t){let e=Object.create(null);for(let i=0;i0?3e8:-4e8:e>0?1e8:-1e8,new ti(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,o=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:n,end:s}=ei(t,o);e=(n?o?-3e8:-1:5e8)-1,i=1+(s?o?2e8:1:-6e8)}return new ti(t,e,i,o,t.widget||null,!0)}static line(t){return new Qe(t)}static set(t,e=!1){return he.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Je.none=he.empty;class Xe extends Je{constructor(t){let{start:e,end:i}=ei(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.attrs=t.class&&t.attributes?$e(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||Ue}eq(t){return this==t||t instanceof Xe&&this.tagName==t.tagName&&je(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}Xe.prototype.point=!1;class Qe extends Je{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof Qe&&this.spec.class==t.spec.class&&je(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}Qe.prototype.mapMode=ot.TrackBefore,Qe.prototype.point=!0;class ti extends Je{constructor(t,e,i,o,n,s){super(e,i,n,t),this.block=o,this.isReplace=s,this.mapMode=o?e<=0?ot.TrackBefore:ot.TrackAfter:ot.TrackDel}get type(){return this.startSide!=this.endSide?Ke.WidgetRange:this.startSide<=0?Ke.WidgetBefore:Ke.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof ti&&(e=this.widget,i=t.widget,e==i||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function ei(t,e=!1){let{inclusiveStart:i,inclusiveEnd:o}=t;return null==i&&(i=t.inclusive),null==o&&(o=t.inclusive),{start:null!=i?i:e,end:null!=o?o:e}}function ii(t,e,i,o=0){let n=i.length-1;n>=0&&i[n]+o>=t?i[n]=Math.max(i[n],e):i.push(t,e)}ti.prototype.point=!0;class oi extends se{constructor(t,e){super(),this.tagName=t,this.attributes=e}eq(t){return t==this||t instanceof oi&&this.tagName==t.tagName&&je(this.attributes,t.attributes)}static create(t){return new oi(t.tagName,t.attributes||Ue)}static set(t,e=!1){return he.of(t,e)}}function ni(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function si(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function ri(t,e){if(!e.anchorNode)return!1;try{return si(t,e.anchorNode)}catch(t){return!1}}function ai(t){return 3==t.nodeType?wi(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function li(t,e,i,o){return!!i&&(di(t,e,i,o,-1)||di(t,e,i,o,1))}function ci(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function hi(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function di(t,e,i,o,n){for(;;){if(t==i&&e==o)return!0;if(e==(n<0?0:ui(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=ci(t)+(n<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(n<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=n<0?ui(t):0}}}function ui(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function pi(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function mi(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function gi(t,e){let i=e.width/t.offsetWidth,o=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(o>.995&&o<1.005||!isFinite(o)||Math.abs(e.height-t.offsetHeight)<1)&&(o=1),{scaleX:i,scaleY:o}}oi.prototype.startSide=oi.prototype.endSide=-1;class fi{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?ui(e):0),i,Math.min(t.focusOffset,i?ui(i):0))}set(t,e,i,o){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=o}}let bi,yi=null;function vi(t){if(t.setActive)return t.setActive();if(yi)return t.focus(yi);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==yi?{get preventScroll(){return yi={preventScroll:!0},!0}}:void 0),!yi){yi=!1;for(let t=0;tMath.max(1,t.scrollHeight-t.clientHeight-4)}function ki(t,e){for(let i=t,o=e;;){if(3==i.nodeType&&o>0)return{node:i,offset:o};if(1==i.nodeType&&o>0){if("false"==i.contentEditable)return null;i=i.childNodes[o-1],o=ui(i)}else{if(!i.parentNode||hi(i))return null;o=ci(i),i=i.parentNode}}}function Si(t,e){for(let i=t,o=e;;){if(3==i.nodeType&&o=26&&(yi=!1);class Ti{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new Ti(t.parentNode,ci(t),e)}static after(t,e){return new Ti(t.parentNode,ci(t)+1,e)}}var Ei=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(Ei||(Ei={}));const Mi=Ei.LTR,Ai=Ei.RTL;function Ii(t){let e=[];for(let i=0;i=e){if(r.level==i)return s;(n<0||(0!=o?o<0?r.frome:t[n].level>r.level))&&(n=s)}}if(n<0)throw new RangeError("Index out of range");return n}}function Fi(t,e){if(t.length!=e.length)return!1;for(let i=0;il&&r.push(new Ri(l,m.from,u)),Vi(t,m.direction==Mi!=!(u%2)?o+1:o,n,m.inner,m.from,m.to,r),l=m.to}p=m.to}else{if(p==i||(e?Pi[p]!=a:Pi[p]==a))break;p++}d?_i(t,l,p,o+1,n,d,r):le;){let i=!0,h=!1;if(!c||l>s[c-1].to){let t=Pi[l-1];t!=a&&(i=!1,h=16==t)}let d=i||1!=a?null:[],u=i?o:o+1,p=l;t:for(;;)if(c&&p==s[c-1].to){if(h)break t;let m=s[--c];if(!i)for(let t=m.from,i=c;;){if(t==e)break t;if(!i||s[i-1].to!=t){if(Pi[t-1]==a)break t;break}t=s[--i].from}if(d)d.push(m);else{m.to=0;t-=3)if(Li[t+1]==-i){let e=Li[t+2],i=2&e?n:4&e?1&e?s:n:0;i&&(Pi[r]=Pi[Li[t]]=i),a=t;break}}else{if(189==Li.length)break;Li[a++]=r,Li[a++]=e,Li[a++]=l}else if(2==(o=Pi[r])||1==o){let t=o==n;l=t?0:1;for(let e=a-3;e>=0;e-=3){let i=Li[e+2];if(2&i)break;if(t)Li[e+2]|=2;else{if(4&i)break;Li[e+2]|=4}}}}}(t,n,s,o,a),function(t,e,i,o){for(let n=0,s=o;n<=i.length;n++){let r=n?i[n-1].to:t,a=nl;)e==s&&(e=i[--o].from,s=o?i[o-1].to:t),Pi[--e]=h;l=r}else s=r,l++}}}(n,s,o,a),_i(t,n,s,e,i,o,r)}function zi(t){return[new Ri(0,t,0)]}let Hi="";function Wi(t,e,i,o,n){var s;let r=o.head-t.from,a=Ri.find(e,r,null!==(s=o.bidiLevel)&&void 0!==s?s:-1,o.assoc),l=e[a],c=l.side(n,i);if(r==c){let t=a+=n?1:-1;if(t<0||t>=e.length)return null;l=e[a=t],r=l.side(!n,i),c=l.side(n,i)}let h=et(t.text,r,l.forward(n,i));(hl.to)&&(h=c),Hi=t.text.slice(Math.min(r,h),Math.max(r,h));let d=a==(n?e.length-1:0)?null:e[a+(n?1:-1)];return d&&h==c&&d.level+(n?0:1)t.some(t=>t)}),eo=ft.define({combine:t=>t.some(t=>t)}),io=ft.define();class oo{constructor(t,e="nearest",i="nearest",o=5,n=5,s=!1){this.range=t,this.y=e,this.x=i,this.yMargin=o,this.xMargin=n,this.isSnapshot=s}map(t){return t.empty?this:new oo(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new oo(pt.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const no=jt.define({map:(t,e)=>t.map(e)}),so=jt.define();function ro(t,e,i){let o=t.facet(Gi);o.length?o[0](e):window.onerror&&window.onerror(String(e),i,void 0,void 0,e)||(i?console.error(i+":",e):console.error(e))}const ao=ft.define({combine:t=>!t.length||t[0]});let lo=0;const co=ft.define({combine:t=>t.filter((e,i)=>{for(let o=0;o{let e=[];return s&&e.push(go.of(e=>{let i=e.plugin(t);return i?s(i):Je.none})),n&&e.push(n(t)),e})}static fromClass(t,e){return ho.define((e,i)=>new t(e,i),e)}}class uo{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(ro(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(e){ro(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){ro(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const po=ft.define(),mo=ft.define(),go=ft.define(),fo=ft.define(),bo=ft.define(),yo=ft.define(),vo=ft.define();function wo(t,e){let i=t.state.facet(vo);if(!i.length)return i;let o=i.map(e=>e instanceof Function?e(t):e),n=[];return he.spans(o,e.from,e.to,{point(){},span(t,i,o,s){let r=t-e.from,a=i-e.from,l=n;for(let t=o.length-1;t>=0;t--,s--){let i,n=o[t].spec.bidiIsolate;if(null==n&&(n=$i(e.text,r,a)),s>0&&l.length&&(i=l[l.length-1]).to==r&&i.direction==n)i.to=a,l=i.inner;else{let t={from:r,to:a,direction:n,inner:[]};l.push(t),l=t.inner}}}}),n}const Co=ft.define();function xo(t){let e=0,i=0,o=0,n=0;for(let s of t.state.facet(Co)){let r=s(t);r&&(null!=r.left&&(e=Math.max(e,r.left)),null!=r.right&&(i=Math.max(i,r.right)),null!=r.top&&(o=Math.max(o,r.top)),null!=r.bottom&&(n=Math.max(n,r.bottom)))}return{left:e,right:i,top:o,bottom:n}}const ko=ft.define();class So{constructor(t,e,i,o){this.fromA=t,this.toA=e,this.fromB=i,this.toB=o}join(t){return new So(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let o=t[e-1];if(!(o.fromA>i.toA)){if(o.toAo.push(new So(t,e,i,n))),this.changedRanges=o}static create(t,e,i){return new To(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}const Eo=[];class Mo{constructor(t,e,i=0){this.dom=t,this.length=e,this.flags=i,this.parent=null,t.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return Eo}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(t){if(this.flags|=2,4&this.flags){this.flags&=-5;let t=this.domAttrs;t&&function(t,e){for(let i=t.attributes.length-1;i>=0;i--){let o=t.attributes[i].name;null==e[o]&&t.removeAttribute(o)}for(let i in e){let o=e[i];"style"==i?t.style.cssText=o:t.getAttribute(i)!=o&&t.setAttribute(i,o)}}(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(t){this.dom=t,t.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t,e=this.posAtStart){let i=e;for(let e of this.children){if(e==t)return i;i+=e.length+e.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}covers(t){return!0}coordsIn(t,e){return null}domPosFor(t,e){let i=ci(this.dom),o=this.length?t>0:e>0;return new Ti(this.parent.dom,i+(o?1:0),0==t||t==this.length)}markDirty(t){this.flags&=-3,t&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let t=this;t;t=t.parent)if(t instanceof Do)return t;return null}static get(t){return t.cmTile}}class Ao extends Mo{constructor(t){super(t,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(t){this.children.push(t),t.parent=this}sync(t){if(2&this.flags)return;super.sync(t);let e,i=this.dom,o=null,n=(null==t?void 0:t.node)==i?t:null,s=0;for(let r of this.children){if(r.sync(t),s+=r.length+r.breakAfter,e=o?o.nextSibling:i.firstChild,n&&e!=r.dom&&(n.written=!0),r.dom.parentNode==i)for(;e&&e!=r.dom;)e=Io(e);else i.insertBefore(r.dom,e);o=r.dom}for(e=o?o.nextSibling:i.firstChild,n&&e&&(n.written=!0);e;)e=Io(e);this.length=s}}function Io(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Do extends Ao{constructor(t,e){super(e),this.view=t}owns(t){for(;t;t=t.parent)if(t==this)return!0;return!1}isBlock(){return!0}nearest(t){for(;;){if(!t)return null;let e=Mo.get(t);if(e&&this.owns(e))return e;t=t.parentNode}}blockTiles(t){for(let e=[],i=this,o=0,n=0;;)if(o==i.children.length){if(!e.length)return;i=i.parent,i.breakAfter&&n++,o=e.pop()}else{let s=i.children[o++];if(s instanceof Oo)e.push(o),i=s,o=0;else{let e=n+s.length,i=t(s,n);if(void 0!==i)return i;n=e+s.breakAfter}}}resolveBlock(t,e){let i,o,n=-1,s=-1;if(this.blockTiles((r,a)=>{let l=a+r.length;if(t>=a&&t<=l){if(r.isWidget()&&e>=-1&&e<=1){if(32&r.flags)return!0;16&r.flags&&(i=void 0)}(at||t==a&&(e>1?r.length:r.covers(-1)))&&(!o||!r.isWidget()&&o.isWidget())&&(o=r,s=t-a)}}),!i&&!o)throw new Error("No tile at position "+t);return i&&e<0||!o?{tile:i,offset:n}:{tile:o,offset:s}}}class Oo extends Ao{constructor(t,e){super(t),this.wrapper=e}isBlock(){return!0}covers(t){return!!this.children.length&&(t<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(t,e){let i=new Oo(e||document.createElement(t.tagName),t);return e||(i.flags|=4),i}}class Bo extends Ao{constructor(t,e){super(t),this.attrs=e}isLine(){return!0}static start(t,e,i){let o=new Bo(e||document.createElement("div"),t);return e&&i||(o.flags|=4),o}get domAttrs(){return this.attrs}resolveInline(t,e,i){let o=null,n=-1,s=null,r=-1;!function t(a,l){for(let c=0,h=0;c=l&&(d.isComposite()?t(d,l-h):(!s||s.isHidden&&(e>0||i&&Lo(s,d)))&&(u>l||32&d.flags)?(s=d,r=l-h):(hi&&(t=i);let o=t,n=t,s=0;0==t&&e<0||t==i&&e>=0?We.chrome||We.gecko||(t?(o--,s=1):n=0)?0:r.length-1];return We.safari&&!s&&0==a.width&&(a=Array.prototype.find.call(r,t=>t.width)||a),s?pi(a,s<0):a||null}static of(t,e){let i=new qo(e||document.createTextNode(t),t);return e||(i.flags|=2),i}}class Ro extends Mo{constructor(t,e,i,o){super(t,e,o),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(t){return!(48&this.flags)&&(this.flags&(t<0?64:128))>0}coordsIn(t,e){return this.coordsInWidget(t,e,!1)}coordsInWidget(t,e,i){let o=this.widget.coordsAt(this.dom,t,e);if(o)return o;if(i)return pi(this.dom.getBoundingClientRect(),this.length?0==t:e<=0);{let e=this.dom.getClientRects(),i=null;if(!e.length)return null;let o=!!(16&this.flags)||!(32&this.flags)&&t>0;for(let n=o?e.length-1:0;i=e[n],!(t>0?0==n:n==e.length-1||i.top0;)if(o.isComposite())if(s){if(!t)break;i&&i.break(),t--,s=!1}else if(n==o.children.length){if(!t&&!r.length)break;i&&i.leave(o),s=!!o.breakAfter,({tile:o,index:n}=r.pop()),n++}else{let a=o.children[n],l=a.breakAfter;!(e>0?a.length<=t:a.length=0;t--){let i=e.marks[t],n=o.lastChild;if(n instanceof No&&n.mark.eq(i.mark))n.dom!=i.dom&&n.setDOM(Yo(i.dom)),o=n;else{if(this.cache.reused.get(i)){let t=Mo.get(i.dom);t&&t.setDOM(Yo(i.dom))}let t=No.of(i.mark,i.dom);o.append(t),o=t}this.cache.reused.set(i,2)}let n=Mo.get(t.text);n&&this.cache.reused.set(n,2);let s=new qo(t.text,t.text.nodeValue);s.flags|=8,o.append(s)}addInlineWidget(t,e,i){let o=this.afterWidget&&48&t.flags&&(48&this.afterWidget.flags)==(48&t.flags);o||this.flushBuffer();let n=this.ensureMarks(e,i);o||16&t.flags||n.append(this.getBuffer(1)),n.append(t),this.pos+=t.length,this.afterWidget=t}addMark(t,e,i){this.flushBuffer(),this.ensureMarks(e,i).append(t),this.pos+=t.length,this.afterWidget=null}addBlockWidget(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}continueWidget(t){(this.afterWidget||this.lastBlock).length+=t,this.pos+=t}addLineStart(t,e){var i;t||(t=jo);let o=Bo.start(t,e||(null===(i=this.cache.find(Bo))||void 0===i?void 0:i.dom),!!e);this.getBlockPos().append(this.lastBlock=this.curLine=o)}addLine(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(t){this.blockPosCovered()||this.addLineStart(t)}ensureLine(t){this.curLine||this.addLineStart(t)}ensureMarks(t,e){var i;let o=this.curLine;for(let n=t.length-1;n>=0;n--){let s,r=t[n];if(e>0&&(s=o.lastChild)&&s instanceof No&&s.mark.eq(r))o=s,e--;else{let t=No.of(r,null===(i=this.cache.find(No,t=>t.mark.eq(r)))||void 0===i?void 0:i.dom);o.append(t),o=t,e=0}}return o}endLine(){if(this.curLine){this.flushBuffer();let t=this.curLine.lastChild;t&&Uo(this.curLine,!1)&&("BR"==t.dom.nodeName||!t.isWidget()||We.ios&&Uo(this.curLine,!0))||this.curLine.append(this.cache.findWidget(Zo,0,32)||new Ro(Zo.toDOM(),0,Zo,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let t=this.wrappers.length-1;t>=0;t--)this.wrappers[t].to=this.pos){let e=new _o(t.from,t.to,t.value,t.rank),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-e.rank||this.wrappers[i-1].to-e.to)<0;)i--;this.wrappers.splice(i,0,e)}this.wrapperPos=this.pos}getBlockPos(){var t;this.updateBlockWrappers();let e=this.root;for(let i of this.wrappers){let o=e.lastChild;if(i.fromt.wrapper.eq(i.wrapper)))||void 0===t?void 0:t.dom);e.append(o),e=o}}return e}blockPosCovered(){let t=this.lastBlock;return null!=t&&!t.breakAfter&&(!t.isWidget()||(160&t.flags)>0)}getBuffer(t){let e=2|(t<0?16:32),i=this.cache.find(Fo,void 0,1);return i&&(i.flags=e),i||new Fo(e)}flushBuffer(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class zo{constructor(t){this.skipCount=0,this.text="",this.textOff=0,this.cursor=t.iter()}skip(t){this.textOff+t<=this.text.length?this.textOff+=t:(this.skipCount+=t-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(t){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=e;let n=this.textOff=Math.min(t,e.length);return i?null:e.slice(0,n)}let e=Math.min(this.text.length,this.textOff+t),i=this.text.slice(this.textOff,e);return this.textOff=e,i}}const Ho=[Ro,Bo,qo,No,Fo,Oo,Do];for(let t=0;t[]),this.index=Ho.map(()=>0),this.reused=new Map}add(t){let e=t.constructor.bucket,i=this.buckets[e];i.length<6?i.push(t):i[this.index[e]=(this.index[e]+1)%6]=t}find(t,e,i=2){let o=t.bucket,n=this.buckets[o],s=this.index[o];for(let t=n.length-1;t>=0;t--){let r=(t+s)%n.length,a=n[r];if((!e||e(a))&&!this.reused.has(a))return n.splice(r,1),r{if(this.cache.add(t),t.isComposite())return!1},enter:t=>this.cache.add(t),leave:()=>{},break:()=>{}}}run(t,e){let i=e&&this.getCompositionContext(e.text);for(let o=0,n=0,s=0;;){let r=so){let t=a-o;this.preserve(t,!s,!r),o=a,n+=t}if(!r)break;this.forward(r.fromA,r.toA),e&&r.fromA<=e.range.fromA&&r.toA>=e.range.toA?(this.emit(n,e.range.fromB),this.builder.addComposition(e,i),this.text.skip(e.range.toB-e.range.fromB),this.emit(e.range.toB,r.toB)):this.emit(n,r.toB),n=r.toB,o=r.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(t,e,i){let o=function(t){let e=[];for(let i=t.parents.length;i>1;i--){let o=i==t.parents.length?t.tile:t.parents[i].tile;o instanceof No&&e.push(o.mark)}return e}(this.old),n=this.openMarks;this.old.advance(t,i?1:-1,{skip:(t,e,i)=>{if(t.isWidget())if(this.openWidget)this.builder.continueWidget(i-e);else{let s=i>0||e{t.isLine()?this.builder.addLineStart(t.attrs,this.cache.maybeReuse(t)):(this.cache.add(t),t instanceof No&&o.unshift(t.mark)),this.openWidget=!1},leave:t=>{t.isLine()?o.length&&(o.length=n=0):t instanceof No&&(o.shift(),n=Math.min(n,o.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(t)}emit(t,e){let i=null,o=this.builder,n=0,s=he.spans(this.decorations,t,e,{point:(t,e,s,r,a,l)=>{if(s instanceof ti){if(this.disallowBlockEffectsFor[l]){if(s.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.view.state.doc.lineAt(t).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(n=r.length,a>r.length)o.continueWidget(e-t);else{let n=s.widget||(s.block?Go.block:Go.inline),l=function(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;t.block&&(e|=256);return e}(s),c=this.cache.findWidget(n,e-t,l)||Ro.of(n,this.view,e-t,l);s.block?(s.startSide>0&&o.addLineStartIfNotCovered(i),o.addBlockWidget(c)):(o.ensureLine(i),o.addInlineWidget(c,r,a))}i=null}else i=function(t,e){let i=e.spec.attributes,o=e.spec.class;if(!i&&!o)return t;t||(t={class:"cm-line"});i&&$e(i,t);o&&(t.class+=" "+o);return t}(i,s);e>t&&this.text.skip(e-t)},span:(t,e,n,s)=>{for(let r=t;rn,this.openMarks=s}forward(t,e){e-t<=10?this.old.advance(e-t,1,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(e-t-10,-1),this.old.advance(5,1,this.reuseWalker))}getCompositionContext(t){let e=[],i=null;for(let o=t.parentNode;;o=o.parentNode){let t=Mo.get(o);if(o==this.view.contentDOM)break;t instanceof No?e.push(t):(null==t?void 0:t.isLine())?i=t:"DIV"!=o.nodeName||i||o==this.view.contentDOM?e.push(No.of(new Xe({tagName:o.nodeName.toLowerCase(),attributes:Ge(o)}),o)):i=new Bo(o,jo)}return{line:i,marks:e}}}function Uo(t,e){let i=t=>{for(let o of t.children)if((e?o.isText():o.length)||i(o))return!0;return!1};return i(t)}const jo={class:"cm-line"};function Yo(t){let e=Mo.get(t);return e&&e.setDOM(t.cloneNode()),t}class Go extends Ze{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Go.inline=new Go("span"),Go.block=new Go("div");const Zo=new class extends Ze{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Ko{constructor(t){this.view=t,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Je.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Do(t,t.contentDOM),this.updateInner([new So(0,0,0,t.state.doc.length)],null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:t,toA:e})=>ethis.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let o=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?o=this.domChanged.newSel.head:function(t,e){let i=!1;e&&t.iterChangedRanges((t,o)=>{te.from&&(i=!0)});return i}(t.changes,this.hasComposition)||t.selectionSet||(o=t.state.selection.main.head));let n=o>-1?function(t,e,i){let o=Xo(t,i);if(!o)return null;let{node:n,from:s,to:r}=o,a=n.nodeValue;if(/[\n\r]/.test(a))return null;if(t.state.doc.sliceString(o.from,o.to)!=a)return null;let l=e.invertedDesc;return{range:new So(l.mapPos(s),l.mapPos(r),s,r),text:n}}(this.view,t.changes,o):null;if(this.domChanged=null,this.hasComposition){let{from:e,to:o}=this.hasComposition;i=new So(e,o,t.changes.mapPos(e,-1),t.changes.mapPos(o,1)).addToSet(i.slice())}this.hasComposition=n?{from:n.range.fromB,to:n.range.toB}:null,(We.ie||We.chrome)&&!n&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let s=this.decorations,r=this.blockWrappers;this.updateDeco();let a=function(t,e,i){let o=new Qo;return he.compare(t,e,i,o),o.changes}(s,this.decorations,t.changes);a.length&&(i=So.extendWithRanges(i,a));let l=function(t,e,i){let o=new tn;return he.compare(t,e,i,o),o.changes}(r,this.blockWrappers,t.changes);return l.length&&(i=So.extendWithRanges(i,l)),n&&!i.some(t=>t.fromA<=n.range.fromA&&t.toA>=n.range.toA)&&(i=n.range.addToSet(i.slice())),!(2&this.tile.flags&&0==i.length)&&(this.updateInner(i,n),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(e||t.length){let i=this.tile,o=new $o(this.view,i,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=o.run(t,e),Jo(i,o.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=We.chrome||We.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),!o||!o.written&&i.selectionRange.focusNode==o.node&&this.tile.dom.contains(o.node)||(this.forceSelection=!0),this.tile.dom.style.height=""});let o=[];if(this.view.viewport.from||this.view.viewport.to-1)&&ri(i,this.view.observer.selectionRange)&&!(o&&i.contains(o));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let a,l,c=this.view.state.selection.main;if(c.empty?l=a=this.inlineDOMNearPos(c.anchor,c.assoc||1):(l=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),a=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),We.gecko&&c.empty&&!this.hasComposition&&(1==(h=a).node.nodeType&&h.node.firstChild&&(0==h.offset||"false"==h.node.childNodes[h.offset-1].contentEditable)&&(h.offset==h.node.childNodes.length||"false"==h.node.childNodes[h.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(t,a.node.childNodes[a.offset]||null)),a=l=new Ti(t,0),r=!0}var h;let d=this.view.observer.selectionRange;!r&&d.focusNode&&(li(a.node,a.offset,d.anchorNode,d.anchorOffset)&&li(l.node,l.offset,d.focusNode,d.focusOffset)||this.suppressWidgetCursorChange(d,c))||(this.view.observer.ignore(()=>{We.android&&We.chrome&&i.contains(d.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(d.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let t=ni(this.view.root);if(t)if(c.empty){if(We.gecko){let t=(e=a.node,n=a.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(nc.head&&([a,l]=[l,a]),e.setEnd(l.node,l.offset),e.setStart(a.node,a.offset),t.removeAllRanges(),t.addRange(e)}else;var e,n;s&&this.view.root.activeElement==i&&(i.blur(),o&&o.focus())}),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new Ti(d.anchorNode,d.anchorOffset),this.impreciseHead=l.precise?null:new Ti(d.focusNode,d.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&li(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=ni(t.root),{anchorNode:o,anchorOffset:n}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let s=this.lineAt(e.head,e.assoc);if(!s)return;let r=s.posAtStart;if(e.head==r||e.head==r+s.length)return;let a=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(e.head+e.assoc,e.assoc);i.collapse(c.node,c.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let h=t.observer.selectionRange;t.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=e.from&&i.collapse(o,n)}posFromDOM(t,e){let i=this.tile.nearest(t);if(!i)return 2&this.tile.dom.compareDocumentPosition(t)?0:this.view.state.doc.length;let o=i.posAtStart;if(!i.isComposite())return i.isText()?t==i.dom?o+e:o+(e?i.length:0):o;{let n;if(t==i.dom)n=i.dom.childNodes[e];else{let o=0==ui(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==i.dom)break;0==o&&e.firstChild!=e.lastChild&&(o=t==e.firstChild?-1:1),t=e}n=o<0?t:t.nextSibling}if(n==i.dom.firstChild)return o;for(;n&&!Mo.get(n);)n=n.nextSibling;if(!n)return o+i.length;for(let t=0,e=o;;t++){let o=i.children[t];if(o.dom==n)return e;e+=o.length+o.breakAfter}}}domAtPos(t,e){let{tile:i,offset:o}=this.tile.resolveBlock(t,e);return i.isWidget()?i.domPosFor(t,e):i.domIn(o,e)}inlineDOMNearPos(t,e){let i,o,n=-1,s=!1,r=-1,a=!1;return this.tile.blockTiles((e,l)=>{if(e.isWidget()){if(32&e.flags&&l>=t)return!0;16&e.flags&&(s=!0)}else{let c=l+e.length;if(l<=t&&(i=e,n=t-l,s=c=t&&!o&&(o=e,r=t-l,a=l>t),l>t&&o)return!0}}),i||o?(s&&o?i=null:a&&i&&(o=null),i&&e<0||!o?i.domIn(n,e):o.domIn(r,e)):this.domAtPos(t,e)}coordsAt(t,e){let{tile:i,offset:o}=this.tile.resolveBlock(t,e);return i.isWidget()?i.widget instanceof en?null:i.coordsInWidget(o,e,!0):i.coordsIn(o,e)}lineAt(t,e){let{tile:i}=this.tile.resolveBlock(t,e);return i.isLine()?i:null}coordsForChar(t){let{tile:e,offset:i}=this.tile.resolveBlock(t,1);if(!e.isLine())return null;return function t(e,i){if(e.isComposite())for(let o of e.children){if(o.length>=i){let e=t(o,i);if(e)return e}if((i-=o.length)<0)break}else if(e.isText()&&iMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,a=this.view.textDirection==Ei.LTR,l=0,c=(t,h,d)=>{for(let u=0;uo);u++){let o=t.children[u],p=h+o.length,m=o.dom.getBoundingClientRect(),{height:g}=m;if(d&&!u&&(l+=m.top-d.top),o instanceof Oo)p>i&&c(o,h,m);else if(h>=i&&(l>0&&e.push(-l),e.push(g+l),l=0,s)){let t=o.dom.lastChild,e=t?ai(t):[];if(e.length){let t=e[e.length-1],i=a?t.right-m.left:m.right-t.left;i>r&&(r=i,this.minWidth=n,this.minWidthFrom=h,this.minWidthTo=p)}}d&&u==t.children.length-1&&(l+=d.bottom-m.bottom),h=p+o.breakAfter}};return c(this.tile,0,null),e}textDirectionAt(t){let{tile:e}=this.tile.resolveBlock(t,1);return"rtl"==getComputedStyle(e.dom).direction?Ei.RTL:Ei.LTR}measureTextSize(){let t=this.tile.blockTiles(t=>{if(t.isLine()&&t.children.length&&t.length<=20){let e,i=0;for(let o of t.children){if(!o.isText()||/[^ -~]/.test(o.text))return;let t=ai(o.dom);if(1!=t.length)return;i+=t[0].width,e=t[0].height}if(i)return{lineHeight:t.dom.getBoundingClientRect().height,charWidth:i/t.length,textHeight:e}}});if(t)return t;let e,i,o,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let t=ai(n.firstChild)[0];e=n.getBoundingClientRect().height,i=t&&t.width?t.width/27:7,o=t&&t.height?t.height:e,n.remove()}),{lineHeight:e,charWidth:i,textHeight:o}}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,o=0;;o++){let n=o==e.viewports.length?null:e.viewports[o],s=n?n.from-1:this.view.state.doc.length;if(s>i){let o=(e.lineBlockAt(s).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(Je.replace({widget:new en(o),block:!0,inclusive:!0,isBlockGap:!0}).range(i,s))}if(!n)break;i=n.to+1}return Je.set(t)}updateDeco(){let t=1,e=this.view.state.facet(go).map(e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e),i=!1,o=this.view.state.facet(bo).map((t,e)=>{let o="function"==typeof t;return o&&(i=!0),o?t(this.view):t});for(o.length&&(this.dynamicDecorationMap[t++]=i,e.push(he.join(o))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t"function"==typeof t?t(this.view):t)}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}for(let e of this.view.state.facet(io))try{if(e(this.view,t.range,t))return!0}catch(t){ro(this.view.state,t,"scroll handler")}let e,{range:i}=t,o=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!o)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(o={left:Math.min(o.left,e.left),top:Math.min(o.top,e.top),right:Math.max(o.right,e.right),bottom:Math.max(o.bottom,e.bottom)});let n=xo(this.view),s={left:o.left-n.left,top:o.top-n.top,right:o.right+n.right,bottom:o.bottom+n.bottom},{offsetWidth:r,offsetHeight:a}=this.view.scrollDOM;!function(t,e,i,o,n,s,r,a){let l=t.ownerDocument,c=l.defaultView||window;for(let h=t,d=!1;h&&!d;)if(1==h.nodeType){let t,u=h==l.body,p=1,m=1;if(u)t=mi(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(d=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let e=h.getBoundingClientRect();({scaleX:p,scaleY:m}=gi(h,e)),t={left:e.left,right:e.left+h.clientWidth*p,top:e.top,bottom:e.top+h.clientHeight*m}}let g=0,f=0;if("nearest"==n)e.top0&&e.bottom>t.bottom+f&&(f=e.bottom-t.bottom+r)):e.bottom>t.bottom&&(f=e.bottom-t.bottom+r,i<0&&e.top-f0&&e.right>t.right+g&&(g=e.right-t.right+s)):e.right>t.right&&(g=e.right-t.right+s,i<0&&e.leftt.bottom||e.leftt.right)&&(e={left:Math.max(e.left,t.left),right:Math.min(e.right,t.right),top:Math.max(e.top,t.top),bottom:Math.min(e.bottom,t.bottom)}),h=h.assignedSlot||h.parentNode}else{if(11!=h.nodeType)break;h=h.host}}(this.view.scrollDOM,s,i.headt.isWidget()||t.children.some(e);return e(this.tile.resolveBlock(t,1).tile)}destroy(){Jo(this.tile)}}function Jo(t,e){let i=null==e?void 0:e.get(t);if(1!=i){null==i&&t.destroy();for(let i of t.children)Jo(i,e)}}function Xo(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let o=ki(i.focusNode,i.focusOffset),n=Si(i.focusNode,i.focusOffset),s=o||n;if(n&&o&&n.node!=o.node){let e=Mo.get(n.node);if(!e||e.isText()&&e.text!=n.node.nodeValue)s=n;else if(t.docView.lastCompositionAfterCursor){let t=Mo.get(o.node);!t||t.isText()&&t.text!=o.node.nodeValue||(s=n)}}if(t.docView.lastCompositionAfterCursor=s!=o,!s)return null;let r=e-s.offset;return{from:r,to:r+s.node.nodeValue.length,node:s.node}}let Qo=class{constructor(){this.changes=[]}compareRange(t,e){ii(t,e,this.changes)}comparePoint(t,e){ii(t,e,this.changes)}boundChange(t){ii(t,t,this.changes)}};class tn{constructor(){this.changes=[]}compareRange(t,e){ii(t,e,this.changes)}comparePoint(){}boundChange(t){ii(t,t,this.changes)}}class en extends Ze{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function on(t,e,i,o,n){let s=Math.round((o-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;s+=Math.floor((n-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let r=t.state.sliceDoc(i.from,i.to);return i.from+function(t,e,i,o){for(let o=0,n=0;;){if(n>=e)return o;if(o==t.length)break;n+=9==t.charCodeAt(o)?i-n%i:1,o=et(t,o)}return!0===o?-1:t.length}(r,s,t.state.tabSize)}function nn(t,e,i,o){let n=function(t,e,i){let o=t.lineBlockAt(e);if(Array.isArray(o.type)){let t;for(let n of o.type){if(n.from>e)break;if(!(n.toe)return n;t&&(n.type!=Ke.Text||t.type==n.type&&!(i<0?n.frome))||(t=n)}}return t||o}return o}(t,e.head,e.assoc||-1),s=o&&n.type==Ke.Text&&(t.lineWrapping||n.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head):null;if(s){let e=t.dom.getBoundingClientRect(),o=t.textDirectionAt(n.from),r=t.posAtCoords({x:i==(o==Ei.LTR)?e.right-1:e.left+1,y:(s.top+s.bottom)/2});if(null!=r)return pt.cursor(r,i?-1:1)}return pt.cursor(i?n.to:n.from,i?-1:1)}function sn(t,e,i,o){let n=t.state.doc.lineAt(e.head),s=t.bidiSpans(n),r=t.textDirectionAt(n.from);for(let a=e,l=null;;){let e=Wi(n,s,r,a,i),c=Hi;if(!e){if(n.number==(i?t.state.doc.lines:1))return a;c="\n",n=t.state.doc.line(n.number+(i?1:-1)),s=t.bidiSpans(n),e=t.visualLineSide(n,!i)}if(l){if(!l(c))return a}else{if(!o)return e;l=o(c)}a=e}}function rn(t,e,i){for(;;){let o=0;for(let n of t)n.between(e-1,e+1,(t,n,s)=>{if(e>t&&ee(t)),i.from,e.head>i.from?-1:1);return o==i.from?i:pt.cursor(o,ot.viewState.docHeight)return new cn(t.state.doc.length,-1);if(n=t.elementAtHeight(c),null==o)break;if(n.type==Ke.Text){let e=t.docView.coordsAt(o<0?n.from:n.to,o);if(e&&(o<0?e.top<=c+r:e.bottom>=c+r))break}let e=t.viewState.heightOracle.textHeight/2;c=o>0?n.bottom+e:n.top-e}if(t.viewport.from>=n.to||t.viewport.to<=n.from){if(i)return null;if(n.type==Ke.Text){let e=on(t,s,n,a,l);return new cn(e,e==n.from?1:-1)}}if(n.type!=Ke.Text)return c<(n.top+n.bottom)/2?new cn(n.from,1):new cn(n.to,-1);let h=t.docView.lineAt(n.from,2);return h&&h.length==n.length||(h=t.docView.lineAt(n.from,-2)),dn(t,h,n.from,a,l)}function dn(t,e,i,o,n){let s=-1,r=null,a=1e9,l=1e9,c=n,h=n,d=(t,e)=>{for(let i=0;io?d.left-o:d.rightn?d.top-n:d.bottom=c&&(c=Math.min(d.top,c),h=Math.max(d.bottom,h),p=0),(s<0||(p-l||u-a)<0)&&(s>=0&&l&&a=c+2?l=0:(s=e,a=u,l=p,r=d))}};if(e.isText()){for(let t=0;t(r.left+r.right)/2==(un(t,s+i)==Ei.LTR)?new cn(i+et(e.text,s),-1):new cn(i+s,1)}{if(!e.length)return new cn(i,1);for(let t=0;t(r.left+r.right)/2==(un(t,s+i)==Ei.LTR)?new cn(h+c.length,-1):new cn(h,1)}}function un(t,e){let i=t.state.doc.lineAt(e);return t.bidiSpans(i)[Ri.find(t.bidiSpans(i),e-i.from,-1,1)].dir}const pn="￿";class mn{constructor(t,e){this.points=t,this.view=e,this.text="",this.lineSeparator=e.state.facet(ne.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=pn}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let o=t;;){this.findPointBefore(i,o);let t=this.text.length;this.readNode(o);let n=Mo.get(o),s=o.nextSibling;if(s==e){(null==n?void 0:n.breakAfter)&&!s&&i!=this.view.contentDOM&&this.lineBreak();break}let r=Mo.get(s);(n&&r?n.breakAfter:(n?n.breakAfter:hi(o))||hi(s)&&("BR"!=o.nodeName||(null==n?void 0:n.isWidget()))&&this.text.length>t)&&!fn(s,e)&&this.lineBreak(),o=s}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,o=this.lineSeparator?null:/\r\n?|\n/g;;){let n,s=-1,r=1;if(this.lineSeparator?(s=e.indexOf(this.lineSeparator,i),r=this.lineSeparator.length):(n=o.exec(e))&&(s=n.index,r=n[0].length),this.append(e.slice(i,s<0?e.length:s)),s<0)break;if(this.lineBreak(),r>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=r-1);i=s+r}}readNode(t){let e=Mo.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(gn(t,i.node,i.offset)?e:0))}}function gn(t,e,i){for(;;){if(!e||i-1;let{impreciseHead:n,impreciseAnchor:s}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=vn(t.docView.tile,e,i,0))){let e=n||s?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:o,focusNode:n,focusOffset:s}=t.observer.selectionRange;i&&(e.push(new bn(i,o)),n==i&&s==o||e.push(new bn(n,s)));return e}(t),i=new mn(e,t);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,o=2==t.length?t[1].pos:i;return i>-1&&o>-1?pt.single(i+e,o+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=n&&n.node==e.focusNode&&n.offset==e.focusOffset||!si(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),o=s&&s.node==e.anchorNode&&s.offset==e.anchorOffset||!si(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),r=t.viewport;if((We.ios||We.chrome)&&t.state.selection.main.empty&&i!=o&&(r.from>0||r.to-1&&t.state.selection.ranges.length>1?this.newSel=t.state.selection.replaceRange(pt.range(o,i)):this.newSel=pt.single(o,i)}}}function vn(t,e,i,o){if(t.isComposite()){let n=-1,s=-1,r=-1,a=-1;for(let l=0,c=o,h=o;li)return vn(o,e,i,c);if(d>=e&&-1==n&&(n=l,s=c),c>i&&o.dom.parentNode==t.dom){r=l,a=h;break}h=d,c=d+o.breakAfter}return{from:s,to:a<0?o+t.length:a,startDOM:(n?t.children[n-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:r=0?t.children[r].dom:null}}return t.isText()?{from:o,to:o+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function wn(t,e){let i,{newSel:o}=e,n=t.state.selection.main,s=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:r}=e.bounds,a=n.from,l=null;(8===s||We.android&&e.text.length=n.from&&i.to<=n.to&&(i.from!=n.from||i.to!=n.to)&&n.to-n.from-(i.to-i.from)<=4?i={from:n.from,to:n.to,insert:t.state.doc.slice(n.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,n.to))}:t.state.doc.lineAt(n.from).toDate.now()-50?i={from:n.from,to:n.to,insert:t.state.toText(t.inputState.insertingText)}:We.chrome&&i&&i.from==i.to&&i.from==n.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(o&&(o=pt.single(o.main.anchor-1,o.main.head-1)),i={from:n.from,to:n.to,insert:U.of([" "])}),i)return Cn(t,i,o,s);if(o&&!o.main.eq(n)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin,"select.pointer"==i&&(o=an(t.state.facet(yo).map(e=>e(t)),o))),t.dispatch({selection:o,scrollIntoView:e,userEvent:i}),!0}return!1}function Cn(t,e,i,o=-1){if(We.ios&&t.inputState.flushIOSKey(e))return!0;let n=t.state.selection.main;if(We.android&&(e.to==n.to&&(e.from==n.from||e.from==n.from-1&&" "==t.state.sliceDoc(e.from,n.from))&&1==e.insert.length&&2==e.insert.lines&&Ci(t.contentDOM,"Enter",13)||(e.from==n.from-1&&e.to==n.to&&0==e.insert.length||8==o&&e.insert.lengthn.head)&&Ci(t.contentDOM,"Backspace",8)||e.from==n.from&&e.to==n.to+1&&0==e.insert.length&&Ci(t.contentDOM,"Delete",46)))return!0;let s,r=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let a=()=>s||(s=function(t,e,i){let o,n=t.state,s=n.selection.main,r=-1;if(e.from==e.to&&e.froms.to){let i=e.frome(t)),o,i);e.from==a&&(r=a)}if(r>-1)o={changes:e,selection:pt.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=s.frome.to?n.sliceDoc(e.to,s.to):"";o=n.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let r=n.changes(e),a=i&&i.main.to<=r.newLength?i.main:void 0;if(n.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let l,c=t.state.sliceDoc(e.from,e.to),h=i&&Xo(t,i.main.head);if(h){let t=e.insert.length-(e.to-e.from);l={from:h.from,to:h.to-t}}else l=t.state.doc.lineAt(s.head);let d=s.to-e.to;o=n.changeByRange(i=>{if(i.from==s.from&&i.to==s.to)return{changes:r,range:a||i.map(r)};let o=i.to-d,h=o-c.length;if(t.state.sliceDoc(h,o)!=c||o>=l.from&&h<=l.to)return{range:i};let u=n.changes({from:h,to:o,insert:e.insert}),p=i.to-s.to;return{changes:u,range:a?pt.range(Math.max(0,a.anchor+p),Math.max(0,a.head+p)):i.map(u)}})}else o={changes:r,selection:a&&n.selection.replaceRange(a)}}let a="input.type";(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,a+=".compose",t.inputState.compositionFirstChange&&(a+=".start",t.inputState.compositionFirstChange=!1));return n.update(o,{userEvent:a,scrollIntoView:!0})}(t,e,i));return t.state.facet(Ki).some(i=>i(t,e.from,e.to,r,a))||t.dispatch(a()),!0}function xn(t,e,i,o){let n=Math.min(t.length,e.length),s=0;for(;s0&&a>0&&t.charCodeAt(r-1)==e.charCodeAt(a-1);)r--,a--;if("end"==o){i-=r+Math.max(0,s-Math.min(r,a))-s}if(r=r?s-i:0,a=s+(a-r),r=s}else if(a=a?s-i:0,r=s+(r-a),a=s}return{from:s,toA:r,toB:a}}class kn{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,We.safari&&t.contentDOM.addEventListener("input",()=>null),We.gecko&&function(t){Yn.has(t)||(Yn.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}(t.contentDOM.ownerDocument)}handleEvent(t){(function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,o=e.target;o!=t.contentDOM;o=o.parentNode)if(!o||11==o.nodeType||(i=Mo.get(o))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0})(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(t)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t)))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=Tn(t),i=this.handlers,o=this.view.contentDOM;for(let t in e)if("scroll"!=t){let n=!e[t].handlers.length,s=i[t];s&&n!=!s.handlers.length&&(o.removeEventListener(t,this.handleEvent),s=null),s||o.addEventListener(t,this.handleEvent,{passive:n})}for(let t in i)"scroll"==t||e[t]||o.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=t.keyCode&&An.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),We.android&&We.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!We.ios||t.synthetic||t.altKey||t.metaKey||!((e=En.find(e=>e.keyCode==t.keyCode))&&!t.ctrlKey||Mn.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(229!=t.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(!("Enter"==e.key&&t&&t.from0||!!(We.safari&&!We.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Sn(t,e){return(i,o)=>{try{return e.call(t,o,i)}catch(t){ro(i.state,t)}}}function Tn(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec,o=t&&t.plugin.domEventHandlers,n=t&&t.plugin.domEventObservers;if(o)for(let t in o){let n=o[t];n&&i(t).handlers.push(Sn(e.value,n))}if(n)for(let t in n){let o=n[t];o&&i(t).observers.push(Sn(e.value,o))}}for(let t in On)i(t).handlers.push(On[t]);for(let t in Bn)i(t).observers.push(Bn[t]);return e}const En=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Mn="dthko",An=[16,17,18,20,91,92,224,225];function In(t){return.7*Math.max(0,t)+8}class Dn{constructor(t,e,i,o){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=o,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=function(t){let e,i,o=t.ownerDocument;for(let n=t.parentNode;n&&!(n==o.body||e&&i);)if(1==n.nodeType)!i&&n.scrollHeight>n.clientHeight&&(i=n),!e&&n.scrollWidth>n.clientWidth&&(e=n),n=n.assignedSlot||n.parentNode;else{if(11!=n.nodeType)break;n=n.host}return{x:e,y:i}}(t.contentDOM),this.atoms=t.state.facet(yo).map(e=>e(t));let n=t.contentDOM.ownerDocument;n.addEventListener("mousemove",this.move=this.move.bind(this)),n.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(ne.allowMultipleSelections)&&function(t,e){let i=t.state.facet(Ui);return i.length?i[0](e):We.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let o=ni(t.root);if(!o||0==o.rangeCount)return!0;let n=o.getRangeAt(0).getClientRects();for(let t=0;t=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=zn(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(e=this.startEvent,i=t,Math.max(Math.abs(e.clientX-i.clientX),Math.abs(e.clientY-i.clientY))<10))return;var e,i;this.select(this.lastEvent=t);let o=0,n=0,s=0,r=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=xo(this.view);t.clientX-c.left<=s+6?o=-In(s-t.clientX):t.clientX+c.right>=a-6&&(o=In(t.clientX-a)),t.clientY-c.top<=r+6?n=-In(r-t.clientY):t.clientY+c.bottom>=l-6&&(n=In(t.clientY-l)),this.setScrollSpeed(o,n)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),!1===this.dragging&&this.select(this.lastEvent)}select(t){let{view:e}=this,i=an(this.atoms,this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}const On=Object.create(null),Bn=Object.create(null),Ln=We.ie&&We.ie_version<15||We.ios&&We.webkit_version<604;function Nn(t,e,i){for(let o of t.facet(e))i=o(i,t);return i}function qn(t,e){e=Nn(t.state,Xi,e);let i,{state:o}=t,n=1,s=o.toText(e),r=s.lines==o.selection.ranges.length;if(null!=Wn&&o.selection.ranges.every(t=>t.empty)&&Wn==s.toString()){let t=-1;i=o.changeByRange(i=>{let a=o.doc.lineAt(i.from);if(a.from==t)return{range:i};t=a.from;let l=o.toText((r?s.line(n++).text:e)+o.lineBreak);return{changes:{from:a.from,insert:l},range:pt.cursor(i.from+l.length)}})}else i=r?o.changeByRange(t=>{let e=s.line(n++);return{changes:{from:t.from,to:t.to,insert:e.text},range:pt.cursor(t.from+e.length)}}):o.replaceSelection(s);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Rn(t,e,i,o){if(1==o)return pt.cursor(e,i);if(2==o)return function(t,e,i=1){let o=t.charCategorizer(e),n=t.doc.lineAt(e),s=e-n.from;if(0==n.length)return pt.cursor(e);0==s?i=1:s==n.length&&(i=-1);let r=s,a=s;i<0?r=et(n.text,s,!1):a=et(n.text,s);let l=o(n.text.slice(r,a));for(;r>0;){let t=et(n.text,r,!1);if(o(n.text.slice(t,r))!=l)break;r=t}for(;a{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},On.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&0!=t.inputState.tabFocusMode&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),Bn.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},Bn.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},On.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let o of t.state.facet(Yi))if(i=o(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),o=zn(e),n=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),n=n.map(t.changes))},get(e,s,r){let a,l=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),c=Rn(t,l.pos,l.assoc,o);if(i.pos!=l.pos&&!s){let e=Rn(t,i.pos,i.assoc,o),n=Math.min(e.from,c.from),s=Math.max(e.to,c.to);c=n1&&(a=function(t,e){for(let i=0;i=e)return pt.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(n,l.pos))?a:r?n.addRange(c):pt.create([c])}}}(t,e)),i){let o=!t.hasFocus;t.inputState.startMouseSelection(new Dn(t,e,i,o)),o&&t.observer.ignore(()=>{vi(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()});let n=t.inputState.mouseSelection;if(n)return n.start(e),!1===n.dragging}else t.inputState.setSelectionOrigin("select.pointer");return!1};const Fn=We.ie&&We.ie_version<=11;let Pn=null,_n=0,Vn=0;function zn(t){if(!Fn)return t.detail;let e=Pn,i=Vn;return Pn=t,Vn=Date.now(),_n=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(_n+1)%3:1}function Hn(t,e,i,o){if(!(i=Nn(t.state,Xi,i)))return;let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,r=o&&s&&function(t,e){let i=t.state.facet(ji);return i.length?i[0](e):We.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:s.from,to:s.to}:null,a={from:n,insert:i},l=t.state.changes(r?[r,a]:a);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(n,-1),head:l.mapPos(n,1)},userEvent:r?"move.drop":"input.drop"}),t.inputState.draggedContent=null}On.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let o=t.docView.tile.nearest(e.target);if(o&&o.isWidget()){let t=o.posAtStart,e=t+o.length;(t>=i.to||e<=i.from)&&(i=pt.range(t,e))}}let{inputState:o}=t;return o.mouseSelection&&(o.mouseSelection.dragging=!0),o.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",Nn(t.state,Qi,t.state.sliceDoc(i.from,i.to))),e.dataTransfer.effectAllowed="copyMove"),!1},On.dragend=t=>(t.inputState.draggedContent=null,!1),On.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let o=Array(i.length),n=0,s=()=>{++n==i.length&&Hn(t,e,o.filter(t=>null!=t).join(t.state.lineBreak),!1)};for(let t=0;t{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(o[t]=e.result),s()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return Hn(t,e,i,!0),!0}return!1},On.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=Ln?null:e.clipboardData;return i?(qn(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{t.focus(),i.remove(),qn(t,i.value)},50)}(t),!1)};let Wn=null;On.copy=On.cut=(t,e)=>{let{text:i,ranges:o,linewise:n}=function(t){let e=[],i=[],o=!1;for(let o of t.selection.ranges)o.empty||(e.push(t.sliceDoc(o.from,o.to)),i.push(o));if(!e.length){let n=-1;for(let{from:o}of t.selection.ranges){let s=t.doc.lineAt(o);s.number>n&&(e.push(s.text),i.push({from:s.from,to:Math.min(t.doc.length,s.to+1)})),n=s.number}o=!0}return{text:Nn(t,Qi,e.join(t.lineBreak)),ranges:i,linewise:o}}(t.state);if(!i&&!n)return!1;Wn=n?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:o,scrollIntoView:!0,userEvent:"delete.cut"});let s=Ln?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",i),!0):(function(t,e){let i=t.dom.parentNode;if(!i)return;let o=i.appendChild(document.createElement("textarea"));o.style.cssText="position: fixed; left: -10000px; top: 10px",o.value=e,o.focus(),o.selectionEnd=e.length,o.selectionStart=0,setTimeout(()=>{o.remove(),t.focus()},50)}(t,i),!1)};const $n=Wt.define();function Un(t,e){let i=[];for(let o of t.facet(Ji)){let n=o(t,e);n&&i.push(n)}return i.length?t.update({effects:i,annotations:$n.of(!0)}):null}function jn(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Un(t.state,e);i?t.dispatch(i):t.update([])}},10)}Bn.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),jn(t)},Bn.blur=t=>{t.observer.clearSelectionRange(),jn(t)},Bn.compositionstart=Bn.compositionupdate=t=>{t.observer.editContext||(null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},Bn.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,We.chrome&&We.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},Bn.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},On.beforeinput=(t,e)=>{var i,o;if("insertText"!=e.inputType&&"insertCompositionText"!=e.inputType||(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),"insertReplacementText"==e.inputType&&t.observer.editContext){let o=null===(i=e.dataTransfer)||void 0===i?void 0:i.getData("text/plain"),n=e.getTargetRanges();if(o&&n.length){let e=n[0],i=t.posAtDOM(e.startContainer,e.startOffset),s=t.posAtDOM(e.endContainer,e.endOffset);return Cn(t,{from:i,to:s,insert:t.state.toText(o)},null),!0}}let n;if(We.chrome&&We.android&&(n=En.find(t=>t.inputType==e.inputType))&&(t.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let e=(null===(o=window.visualViewport)||void 0===o?void 0:o.height)||0;setTimeout(()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return We.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),We.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout(()=>Bn.compositionend(t,e),20),!1};const Yn=new Set;const Gn=["pre-wrap","normal","pre-line","break-spaces"];let Zn=!1;function Kn(){Zn=!1}class Jn{constructor(t){this.lineWrapping=t,this.doc=U.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return Gn.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i-1,a=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=r;if(this.lineWrapping=r,this.lineHeight=e,this.charWidth=i,this.textHeight=o,this.lineLength=n,a){this.heightSamples={};for(let t=0;t0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>es&&(Zn=!0),this.height=t)}replace(t,e,i){return is.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,o){let n=this,s=i.doc;for(let r=o.length-1;r>=0;r--){let{fromA:a,toA:l,fromB:c,toB:h}=o[r],d=n.lineAt(a,ts.ByPosNoHeight,i.setDoc(e),0,0),u=d.to>=l?d:n.lineAt(l,ts.ByPosNoHeight,i,0,0);for(h+=u.to-l,l=u.to;r>0&&d.from<=o[r-1].toA;)a=o[r-1].fromA,c=o[r-1].fromB,r--,a2*n){let n=t[e-1];n.break?t.splice(--e,1,n.left,null,n.right):t.splice(--e,1,n.left,n.right),i+=1+n.break,o-=n.size}else{if(!(n>2*o))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,n-=e.size}}else if(o=n&&s(this.lineAt(0,ts.ByPos,i,o,n))}setMeasuredHeight(t){let e=t.heights[t.index++];e<0?(this.spaceAbove=-e,e=t.heights[t.index++]):this.spaceAbove=0,this.setHeight(e)}updateHeight(t,e=0,i=!1,o){return o&&o.from<=e&&o.more&&this.setMeasuredHeight(o),this.outdated=!1,this}toString(){return`block(${this.length})`}}class rs extends ss{constructor(t,e,i){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(t,e){return new Qn(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,e,i){let o=i[0];return 1==i.length&&(o instanceof rs||o instanceof as&&4&o.flags)&&Math.abs(this.length-o.length)<10?(o instanceof as?o=new rs(o.length,this.height,this.spaceAbove):o.height=this.height,this.outdated||(o.outdated=!1),o):is.of(i)}updateHeight(t,e=0,i=!1,o){return o&&o.from<=e&&o.more?this.setMeasuredHeight(o):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class as extends is{constructor(t){super(t,0)}heightMetrics(t,e){let i,o=t.doc.lineAt(e).number,n=t.doc.lineAt(e+this.length).number,s=n-o+1,r=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*s);i=e/s,this.length>s+1&&(r=(this.height-e)/(this.length-s-1))}else i=this.height/s;return{firstLine:o,lastLine:n,perLine:i,perChar:r}}blockAt(t,e,i,o){let{firstLine:n,lastLine:s,perLine:r,perChar:a}=this.heightMetrics(e,o);if(e.lineWrapping){let n=o+(t0){let t=i[i.length-1];t instanceof as?i[i.length-1]=new as(t.length+o):i.push(null,new as(o-1))}if(t>0){let e=i[0];e instanceof as?i[0]=new as(t+e.length):i.unshift(new as(t-1),null)}return is.of(i)}decomposeLeft(t,e){e.push(new as(t-1),null)}decomposeRight(t,e){e.push(null,new as(this.length-t-1))}updateHeight(t,e=0,i=!1,o){let n=e+this.length;if(o&&o.from<=e+this.length&&o.more){let i=[],s=Math.max(e,o.from),r=-1;for(o.from>e&&i.push(new as(o.from-e-1).updateHeight(t,e));s<=n&&o.more;){let e=t.doc.lineAt(s).length;i.length&&i.push(null);let n=o.heights[o.index++],a=0;n<0&&(a=-n,n=o.heights[o.index++]),-1==r?r=n:Math.abs(n-r)>=es&&(r=-2);let l=new rs(e,n,a);l.outdated=!1,i.push(l),s+=e+1}s<=n&&i.push(null,new as(n-s).updateHeight(t,s));let a=is.of(i);return(r<0||Math.abs(a.height-this.height)>=es||Math.abs(r-this.heightMetrics(t,e).perLine)>=es)&&(Zn=!0),os(this,a)}return(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class ls extends is{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,o){let n=i+this.left.height;return tr))return l;let c=e==ts.ByPosNoHeight?ts.ByPosNoHeight:ts.ByPos;return a?l.join(this.right.lineAt(r,c,i,s,r)):this.left.lineAt(r,c,i,o,n).join(l)}forEachLine(t,e,i,o,n,s){let r=o+this.left.height,a=n+this.left.length+this.break;if(this.break)t=a&&this.right.forEachLine(t,e,i,r,a,s);else{let l=this.lineAt(a,ts.ByPos,i,o,n);t=t&&l.from<=e&&s(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,r,a,s)}}replace(t,e,i){let o=this.left.length+this.break;if(ethis.left.length)return this.balanced(this.left,this.right.replace(t-o,e-o,i));let n=[];t>0&&this.decomposeLeft(t,n);let s=n.length;for(let t of i)n.push(t);if(t>0&&cs(n,s-1),e=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,o=i+this.break;if(t>=o)return this.right.decomposeRight(t-o,e);t2*e.size||e.size>2*t.size?is.of(this.break?[t,null,e]:[t,e]):(this.left=os(this.left,t),this.right=os(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,o){let{left:n,right:s}=this,r=e+n.length+this.break,a=null;return o&&o.from<=e+n.length&&o.more?a=n=n.updateHeight(t,e,i,o):n.updateHeight(t,e,i),o&&o.from<=r+s.length&&o.more?a=s=s.updateHeight(t,r,i,o):s.updateHeight(t,r,i),a?this.balanced(n,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cs(t,e){let i,o;null==t[e]&&(i=t[e-1])instanceof as&&(o=t[e+1])instanceof as&&t.splice(e-1,3,new as(i.length+1+o.length))}class hs{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof rs?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new rs(t-this.pos,-1,0)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t=5)&&this.addLineDeco(o,n,s)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTot&&this.nodes.push(new rs(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,e){let i=new as(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof rs)return t;let e=new rs(0,-1,0);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let o=this.ensureLine();o.length+=i,o.collapsed+=i,o.widgetHeight=Math.max(o.widgetHeight,t),o.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof rs||this.isCovered?(this.writtenToi.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=o.overflow){let o=i.getBoundingClientRect();s=Math.max(s,o.left),r=Math.min(r,o.right),a=Math.max(a,o.top),l=Math.min(e==t.parentNode?n.innerHeight:l,o.bottom)}e="absolute"==o.position||"fixed"==o.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:s-i.left,right:Math.max(s,r)-i.left,top:a-(i.top+e),bottom:Math.max(a,l)-(i.top+e)}}function ps(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class ms{constructor(t,e,i,o){this.from=t,this.to=e,this.size=i,this.displaySize=o}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i"function"!=typeof t&&"cm-lineWrapping"==t.class);this.heightOracle=new Jn(e),this.stateDeco=t.facet(go).filter(t=>"function"!=typeof t),this.heightMap=is.empty().applyChanges(this.stateDeco,U.empty,this.heightOracle.setDoc(t.doc),[new So(0,0,0,t.doc.length)]);for(let t=0;t<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());t++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Je.set(this.lineGaps.map(t=>t.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let o=i?e.head:e.anchor;if(!t.some(({from:t,to:e})=>o>=t&&o<=e)){let{from:e,to:i}=this.lineBlockAt(o);t.push(new bs(e,i))}}return this.viewports=t.sort((t,e)=>t.from-e.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?ws:new Cs(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(xs(t,this.scaler))})}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(go).filter(t=>"function"!=typeof t);let o=t.changedRanges,n=So.extendWithRanges(o,function(t,e,i){let o=new ds;return he.compare(t,e,i,o,0),o.changes}(i,this.stateDeco,t?t.changes:st.empty(this.state.doc.length))),s=this.heightMap.height,r=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Kn(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),n),(this.heightMap.height!=s||Zn)&&(t.flags|=2),r?(this.scrollAnchorPos=t.changes.mapPos(r.from,-1),this.scrollAnchorHeight=r.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=s);let a=n.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,e));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,t.flags|=this.updateForViewport(),(l||!t.changes.empty||2&t.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(eo)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),o=this.heightOracle,n=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?Ei.RTL:Ei.LTR;let s=this.heightOracle.mustRefreshForWrapping(n),r=e.getBoundingClientRect(),a=s||this.mustMeasureContent||this.contentDOMHeight!=r.height;this.contentDOMHeight=r.height,this.mustMeasureContent=!1;let l=0,c=0;if(r.width&&r.height){let{scaleX:t,scaleY:i}=gi(e,r);(t>.005&&Math.abs(this.scaleX-t)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=t,this.scaleY=i,l|=16,s=a=!0)}let h=(parseInt(i.paddingTop)||0)*this.scaleY,d=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==h&&this.paddingBottom==d||(this.paddingTop=h,this.paddingBottom=d,l|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(o.lineWrapping&&(a=!0),this.editorWidth=t.scrollDOM.clientWidth,l|=16);let u=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=u&&(this.scrollAnchorHeight=-1,this.scrollTop=u),this.scrolledToBottom=xi(t.scrollDOM);let p=(this.printing?ps:us)(e,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let f=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(f!=this.inView&&(this.inView=f,f&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(t){let e=t.getBoundingClientRect(),i=t.ownerDocument.defaultView||window;return e.left0&&e.top0}(t.dom))return 0;let b=r.width;if(this.contentDOMWidth==b&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=r.width,this.editorHeight=t.scrollDOM.clientHeight,l|=16),a){let e=t.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(e)&&(s=!0),s||o.lineWrapping&&Math.abs(b-this.contentDOMWidth)>o.charWidth){let{lineHeight:i,charWidth:r,textHeight:a}=t.docView.measureTextSize();s=i>0&&o.refresh(n,i,r,a,Math.max(5,b/r),e),s&&(t.docView.minWidth=0,l|=16)}m>0&&g>0?c=Math.max(m,g):m<0&&g<0&&(c=Math.min(m,g)),Kn();for(let i of this.viewports){let n=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(s?is.empty().applyChanges(this.stateDeco,U.empty,this.heightOracle,[new So(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(o,0,s,new Xn(i.from,n))}Zn&&(l|=2)}let y=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return y&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps,t)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),o=this.heightMap,n=this.heightOracle,{visibleTop:s,visibleBottom:r}=this,a=new bs(o.lineAt(s-1e3*i,ts.ByHeight,n,0,0).from,o.lineAt(r+1e3*(1-i),ts.ByHeight,n,0,0).to);if(e){let{head:t}=e.range;if(ta.to){let i,s=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),r=o.lineAt(t,ts.ByPos,n,0,0);i="center"==e.y?(r.top+r.bottom)/2-s/2:"start"==e.y||"nearest"==e.y&&t=r+Math.max(10,Math.min(i,250)))&&o>s-2e3&&n>1,s=o<<1;if(this.defaultTextDirection!=Ei.LTR&&!i)return[];let r=[],a=(o,s,l,c)=>{if(s-oo&&tt.from>=l.from&&t.to<=l.to&&Math.abs(t.from-o)t.frome));if(!u){if(st.from<=s&&t.to>=s)){let t=e.moveToLineBoundary(pt.cursor(s),!1,!0).head;t>o&&(s=t)}let t=this.gapSize(l,o,s,c);u=new ms(o,s,t,i||t<2e6?t:2e6)}r.push(u)},l=e=>{if(e.lengthn&&(o.push({from:n,to:t}),s+=t-n),n=e}},20),n2e6)for(let i of t)i.from>=e.from&&i.frome.from&&a(e.from,r,e,n),lt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];he.spans(e,this.viewport.from,this.viewport.to,{span(t,e){i.push({from:t,to:e})},point(){}},20);let o=0;if(i.length!=this.visibleRanges.length)o=12;else for(let e=0;e=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||xs(this.heightMap.lineAt(t,ts.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||xs(this.heightMap.lineAt(this.scaler.fromDOM(t),ts.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return xs(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class bs{constructor(t,e){this.from=t,this.to=e}}function ys({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let o=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:n}=e[t],s=n-i;if(o<=s)return i+o;o-=s}}function vs(t,e){let i=0;for(let{from:o,to:n}of t.ranges){if(e<=n){i+=e-o;break}i+=n-o}return i/t.total}const ws={toDOM:t=>t,fromDOM:t=>t,scale:1,eq(t){return t==this}};class Cs{constructor(t,e,i){let o=0,n=0,s=0;this.viewports=i.map(({from:i,to:n})=>{let s=e.lineAt(i,ts.ByPos,t,0,0).top,r=e.lineAt(n,ts.ByPos,t,0,0).bottom;return o+=r-s,{from:i,to:n,top:s,bottom:r,domTop:0,domBottom:0}}),this.scale=(7e6-o)/(e.height-o);for(let t of this.viewports)t.domTop=s+(t.top-n)*this.scale,s=t.domBottom=t.domTop+(t.bottom-t.top),n=t.bottom}toDOM(t){for(let e=0,i=0,o=0;;e++){let n=ee.from==t.viewports[i].from&&e.to==t.viewports[i].to))}}function xs(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),o=e.toDOM(t.bottom);return new Qn(t.from,t.length,i,o-i,Array.isArray(t._content)?t._content.map(t=>xs(t,e)):t._content)}const ks=ft.define({combine:t=>t.join(" ")}),Ss=ft.define({combine:t=>t.indexOf(!0)>-1}),Ts=Te.newName(),Es=Te.newName(),Ms=Te.newName(),As={"&light":"."+Es,"&dark":"."+Ms};function Is(t,e,i){return new Te(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]}):t+" "+e})}const Ds=Is("."+Ts,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},As),Os={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Bs=We.ie&&We.ie_version<=11;class Ls{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new fi,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let t of e)this.queue.push(t);(We.ie&&We.ie_version<=11||We.ios&&t.composing)&&e.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),!window.EditContext||!We.android||!1===t.constructor.EDIT_CONTEXT||We.chrome&&We.chrome_version<126||(this.editContext=new Rs(t),t.state.facet(ao)&&(t.contentDOM.editContext=this.editContext.editContext)),Bs&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){("change"!=t.type&&t.type||t.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,i)=>e!=t[i]))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,o=this.selectionRange;if(i.state.facet(ao)?i.root.activeElement!=this.dom:!ri(this.dom,o))return;let n=o.anchorNode&&i.docView.tile.nearest(o.anchorNode);n&&n.isWidget()&&n.widget.ignoreEvent(t)?e||(this.selectionChanged=!1):(We.ie&&We.ie_version<=11||We.android&&We.chrome)&&!i.state.selection.main.empty&&o.focusNode&&li(o.focusNode,o.focusOffset,o.anchorNode,o.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=ni(t.root);if(!e)return!1;let i=We.safari&&11==t.root.nodeType&&t.root.activeElement==this.dom&&function(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return qs(t,i)}let i=null;function o(t){t.preventDefault(),t.stopImmediatePropagation(),i=t.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",o,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",o,!0),i?qs(t,i):null}(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let o=ri(this.dom,i);return o&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&Ci(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,o=!1;for(let n of t){let t=this.readMutation(n);t&&(t.typeOver&&(o=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:o}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),o=this.selectionChanged&&ri(this.dom,this.selectionRange);if(t<0&&!o)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let n=new yn(this.view,t,e,i);return this.view.docView.domChanged={newSel:n.newSel?n.newSel.main:null},n}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,o=wn(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),o}readMutation(t){let e=this.view.docView.tile.nearest(t.target);if(!e||e.isWidget())return null;if(e.markDirty("attributes"==t.type),"childList"==t.type){let i=Ns(e,t.previousSibling||t.target.previousSibling,-1),o=Ns(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:o?e.posBefore(o):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(ao)!=t.state.facet(ao)&&(t.view.contentDOM.editContext=t.state.facet(ao)?this.editContext.editContext:null))}destroy(){var t,e,i;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Ns(t,e,i){for(;e;){let o=Mo.get(e);if(o&&o.parent==t)return o;let n=e.parentNode;e=n!=t.dom?n:i>0?e.nextSibling:e.previousSibling}return null}function qs(t,e){let i=e.startContainer,o=e.startOffset,n=e.endContainer,s=e.endOffset,r=t.docView.domAtPos(t.state.selection.main.anchor,1);return li(r.node,r.offset,n,s)&&([i,o,n,s]=[n,s,i,o]),{anchorNode:i,anchorOffset:o,focusNode:n,focusOffset:s}}class Rs{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=i=>{let o=t.state.selection.main,{anchor:n,head:s}=o,r=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:r,drifted:!1});let l=a-r>i.text.length;r==this.from&&nthis.to&&(a=n);let c=xn(t.state.sliceDoc(r,a),i.text,(l?o.from:o.to)-r,l?"end":null);if(!c){let e=pt.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));return void(e.main.eq(o)||t.dispatch({selection:e,userEvent:"select"}))}let h={from:c.from+r,to:c.toA+r,insert:U.of(i.text.slice(c.from,c.toB).split("\n"))};if((We.mac||We.android)&&h.from==s-1&&/^\. ?$/.test(i.text)&&"off"==t.contentDOM.getAttribute("autocorrect")&&(h={from:r,to:a,insert:U.of([i.text.replace("."," ")])}),this.pendingContextChange=h,!t.state.readOnly){let e=this.to-this.from+(h.to-h.from+h.insert.length);Cn(t,h,pt.single(this.toEditorPos(i.selectionStart,e),this.toEditorPos(i.selectionEnd,e)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),h.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(e.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(e.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let o=[],n=null;for(let e=this.toEditorPos(i.rangeStart),s=this.toEditorPos(i.rangeEnd);e{let i=[];for(let t of e.getTextFormats()){let e=t.underlineStyle,o=t.underlineThickness;if(!/none/i.test(e)&&!/none/i.test(o)){let n=this.toEditorPos(t.rangeStart),s=this.toEditorPos(t.rangeEnd);if(n{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:e}=this.composing;this.composing=null,e&&this.reset(t.state)}};for(let t in this.handlers)e.addEventListener(t,this.handlers[t]);this.measureReq={read:t=>{this.editContext.updateControlBounds(t.contentDOM.getBoundingClientRect());let e=ni(t.root);e&&e.rangeCount&&this.editContext.updateSelectionBounds(e.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,o=this.pendingContextChange;return t.changes.iterChanges((n,s,r,a,l)=>{if(i)return;let c=l.length-(s-n);if(o&&s>=o.to){if(o.from==n&&o.to==s&&o.insert.eq(l))return o=this.pendingContextChange=null,e+=c,void(this.to+=c);o=null,this.revertPending(t.state)}if(n+=e,(s+=e)<=this.from)this.from+=c,this.to+=c;else if(nthis.to||this.to-this.from+l.length>3e4)return void(i=!0);this.editContext.updateText(this.toContextPos(n),this.toContextPos(s),l.toString()),this.to+=c}e+=c}),o&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(t=>!t.isUserEvent("input.type")&&t.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):this.applyEdits(t)&&this.rangeIsValid(t.state)?(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state):(this.pendingContextChange=null,this.reset(t.state)),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),o=this.toContextPos(e.head);this.editContext.selectionStart==i&&this.editContext.selectionEnd==o||this.editContext.updateSelection(i,o)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to3e4)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class Fs{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var e;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(t=>t.forEach(t=>i(t,this)))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new fs(t.state||ne.create(t)),t.scrollTo&&t.scrollTo.is(no)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(co).map(t=>new uo(t));for(let t of this.plugins)t.update(this);this.observer=new Ls(this),this.inputState=new kn(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Ko(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(e=document.fonts)||void 0===e?void 0:e.ready)&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...t){let e=1==t.length&&t[0]instanceof Yt?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,o=!1,n=this.state;for(let e of t){if(e.startState!=n)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");n=e.state}if(this.destroyed)return void(this.viewState.state=n);let s=this.hasFocus,r=0,a=null;t.some(t=>t.annotation($n))?(this.inputState.notifiedFocused=s,r=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,a=Un(n,s),a||(r=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(n.doc)||!this.state.selection.eq(n.selection))&&(c=null)):this.observer.clear(),n.facet(ne.phrases)!=this.state.facet(ne.phrases))return this.setState(n);e=To.create(this,n,t),e.flags|=r;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(h&&(h=h.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;h=new oo(t.empty?t:pt.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(no)&&(h=t.value.clip(this.state))}this.viewState.update(e,h),this.bidiCache=Vs.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(ko)!=this.styleModules&&this.mountStyles(),o=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some(t=>t.isUserEvent("select.pointer")))}finally{this.updateState=0}if(e.startState.facet(ks)!=e.state.facet(ks)&&(this.viewState.mustMeasureContent=!0),(i||o||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!e.empty)for(let t of this.state.facet(Zi))try{t(e)}catch(t){ro(this.state,t,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!wn(this,c)&&l.force&&Ci(this.contentDOM,l.key,l.keyCode)})}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new fs(t),this.plugins=t.facet(co).map(t=>new uo(t)),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new Ko(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(co),i=t.state.facet(co);if(e!=i){let o=[];for(let n of i){let i=e.indexOf(n);if(i<0)o.push(new uo(n));else{let e=this.plugins[i];e.mustUpdate=t,o.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=o,this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,o=i.scrollTop*this.scaleY,{scrollAnchorPos:n,scrollAnchorHeight:s}=this.viewState;Math.abs(o-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(s<0)if(xi(i))n=-1,s=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(o);n=t.from,s=t.top}this.updateState=1;let r=this.viewState.measure(this);if(!r&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let a=[];4&r||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(t=>{try{return t.read(this)}catch(t){return ro(this.state,t),_s}}),c=To.create(this,this.state,[]),h=!1;c.flags|=r,e?e.flags|=r:e=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),h=this.docView.update(c),h&&this.docViewUpdate());for(let t=0;t1||t<-1){o+=t,i.scrollTop=o/this.scaleY,s=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(Zi))t(e)}get themeClasses(){return Ts+" "+(this.state.facet(Ss)?Ms:Es)+" "+this.state.facet(ks)}updateAttrs(){let t=zs(this,po,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(ao)?"true":"false",class:"cm-content",style:`${We.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),zs(this,mo,e);let i=this.observer.ignore(()=>{let i=Ye(this.contentDOM,this.contentAttrs,e),o=Ye(this.dom,this.editorAttrs,t);return i||o});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(Fs.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(ko);let t=this.state.facet(Fs.cspNonce);Te.mount(this.root,this.styleModules.concat(Ds).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;ee.plugin==t)||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return ln(this,t,sn(this,t,e,i))}moveByGroup(t,e){return ln(this,t,sn(this,t,e,e=>function(t,e,i){let o=t.state.charCategorizer(e),n=o(i);return t=>{let e=o(t);return n==te.Space&&(n=e),n==e}}(this,t.head,e)))}visualLineSide(t,e){let i=this.bidiSpans(t),o=this.textDirectionAt(t.from),n=i[e?i.length-1:0];return pt.cursor(n.side(e,o)+t.from,n.forward(!e,o)?1:-1)}moveToLineBoundary(t,e,i=!0){return nn(this,t,e,i)}moveVertically(t,e,i){return ln(this,t,function(t,e,i,o){let n=e.head,s=i?1:-1;if(n==(i?t.state.doc.length:0))return pt.cursor(n,e.assoc);let r,a=e.goalColumn,l=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(n,e.assoc||-1),h=t.documentTop;if(c)null==a&&(a=c.left-l.left),r=s<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(n);null==a&&(a=Math.min(l.right-l.left,t.defaultCharacterWidth*(n-e.from))),r=(s<0?e.top:e.bottom)+h}let d=l.left+a,u=null!=o?o:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=hn(t,{x:d,y:r+(u+e)*s},!1,s);return pt.cursor(i.pos,i.assoc,void 0,a)}}(this,t,e,i))}domAtPos(t,e=1){return this.docView.domAtPos(t,e)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){this.readMeasured();let i=hn(this,t,e);return i&&i.pos}posAndSideAtCoords(t,e=!0){return this.readMeasured(),hn(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let o=this.state.doc.lineAt(t),n=this.bidiSpans(o);return pi(i,n[Ri.find(n,t-o.from,-1,e)].dir==Ei.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(to)||tthis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Ps)return zi(t.length);let e,i=this.textDirectionAt(t.from);for(let o of this.bidiCache)if(o.from==t.from&&o.dir==i&&(o.fresh||Fi(o.isolates,e=wo(this,t))))return o.order;e||(e=wo(this,t));let o=function(t,e,i){if(!t)return[new Ri(0,0,e==Ai?1:0)];if(e==Mi&&!i.length&&!qi.test(t))return zi(t.length);if(i.length)for(;t.length>Pi.length;)Pi[Pi.length]=256;let o=[],n=e==Mi?0:1;return Vi(t,n,n,i,0,t.length,o),o}(t.text,i,e);return this.bidiCache.push(new Vs(t.from,t.to,i,e,!0,o)),o}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||We.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{vi(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return no.of(new oo("number"==typeof t?pt.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return no.of(new oo(pt.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){null==t?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof t?this.inputState.tabFocusMode=t?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return ho.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return ho.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=Te.newName(),o=[ks.of(i),ko.of(Is(`.${i}`,t))];return e&&e.dark&&o.push(Ss.of(!0)),o}static baseTheme(t){return It.lowest(ko.of(Is("."+Ts,t,As)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),o=i&&Mo.get(i)||Mo.get(t);return(null===(e=null==o?void 0:o.root)||void 0===e?void 0:e.view)||null}}Fs.styleModule=ko,Fs.inputHandler=Ki,Fs.clipboardInputFilter=Xi,Fs.clipboardOutputFilter=Qi,Fs.scrollHandler=io,Fs.focusChangeEffect=Ji,Fs.perLineTextDirection=to,Fs.exceptionSink=Gi,Fs.updateListener=Zi,Fs.editable=ao,Fs.mouseSelectionStyle=Yi,Fs.dragMovesSelection=ji,Fs.clickAddsSelectionRange=Ui,Fs.decorations=go,Fs.blockWrappers=fo,Fs.outerDecorations=bo,Fs.atomicRanges=yo,Fs.bidiIsolatedRanges=vo,Fs.scrollMargins=Co,Fs.darkTheme=Ss,Fs.cspNonce=ft.define({combine:t=>t.length?t[0]:""}),Fs.contentAttributes=mo,Fs.editorAttributes=po,Fs.lineWrapping=Fs.contentAttributes.of({class:"cm-lineWrapping"}),Fs.announce=jt.define();const Ps=4096,_s={};class Vs{constructor(t,e,i,o,n,s){this.from=t,this.to=e,this.dir=i,this.isolates=o,this.fresh=n,this.order=s}static update(t,e){if(e.empty&&!t.some(t=>t.fresh))return t;let i=[],o=t.length?t[t.length-1].dir:Ei.LTR;for(let n=Math.max(0,t.length-10);n=0;n--){let e=o[n],s="function"==typeof e?e(t):e;s&&$e(s,i)}return i}class Hs extends se{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Hs.prototype.elementClass="",Hs.prototype.toDOM=void 0,Hs.prototype.mapMode=ot.TrackBefore,Hs.prototype.startSide=Hs.prototype.endSide=-1,Hs.prototype.point=!0;let Ws=0;class $s{constructor(t,e,i,o){this.name=t,this.set=e,this.base=i,this.modified=o,this.id=Ws++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i="string"==typeof t?t:"?";if(t instanceof $s&&(e=t),null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let o=new $s(i,[],null,[]);if(o.set.push(o),e)for(let t of e.set)o.set.push(t);return o}static defineModifier(t){let e=new js(t);return t=>t.modified.indexOf(e)>-1?t:js.get(t.base||t,t.modified.concat(e).sort((t,e)=>t.id-e.id))}}let Us=0;class js{constructor(t){this.name=t,this.instances=[],this.id=Us++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(i=>{return i.base==t&&(o=e,n=i.modified,o.length==n.length&&o.every((t,e)=>t==n[e]));var o,n});if(i)return i;let o=[],n=new $s(t.name,o,t,e);for(let t of e)t.instances.push(n);let s=function(t){let e=[[]];for(let i=0;ie.length-t.length)}(e);for(let e of t.set)if(!e.modified.length)for(let t of s)o.push(js.get(e,t));return n}}function Ys(t){let e=Object.create(null);for(let i in t){let o=t[i];Array.isArray(o)||(o=[o]);for(let t of i.split(" "))if(t){let i=[],n=2,s=t;for(let e=0;;){if("..."==s&&e>0&&e+3==t.length){n=1;break}let o=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!o)throw new RangeError("Invalid path: "+t);if(i.push("*"==o[0]?"":'"'==o[0][0]?JSON.parse(o[0]):o[0]),e+=o[0].length,e==t.length)break;let r=t[e++];if(e==t.length&&"!"==r){n=0;break}if("/"!=r)throw new RangeError("Invalid path: "+t);s=t.slice(e)}let r=i.length-1,a=i[r];if(!a)throw new RangeError("Invalid path: "+t);let l=new Zs(o,n,r>0?i.slice(0,r):null);e[a]=l.sort(e[a])}}return Gs.add(e)}const Gs=new r({combine(t,e){let i,o,n;for(;t||e;){if(!t||e&&t.depth>=e.depth?(n=e,e=e.next):(n=t,t=t.next),i&&i.mode==n.mode&&!n.context&&!i.context)continue;let s=new Zs(n.tags,n.mode,n.context);i?i.next=s:o=s,i=s}return o}});class Zs{constructor(t,e,i,o){this.tags=t,this.mode=e,this.context=i,this.next=o}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth{let e=n;for(let o of t)for(let t of o.set){let o=i[t.id];if(o){e=e?e+" "+o:o;break}}return e},scope:o}}Zs.empty=new Zs([],2,null);const Js=$s.define,Xs=Js(),Qs=Js(),tr=Js(Qs),er=Js(Qs),ir=Js(),or=Js(ir),nr=Js(ir),sr=Js(),rr=Js(sr),ar=Js(),lr=Js(),cr=Js(),hr=Js(cr),dr=Js(),ur={comment:Xs,lineComment:Js(Xs),blockComment:Js(Xs),docComment:Js(Xs),name:Qs,variableName:Js(Qs),typeName:tr,tagName:Js(tr),propertyName:er,attributeName:Js(er),className:Js(Qs),labelName:Js(Qs),namespace:Js(Qs),macroName:Js(Qs),literal:ir,string:or,docString:Js(or),character:Js(or),attributeValue:Js(or),number:nr,integer:Js(nr),float:Js(nr),bool:Js(ir),regexp:Js(ir),escape:Js(ir),color:Js(ir),url:Js(ir),keyword:ar,self:Js(ar),null:Js(ar),atom:Js(ar),unit:Js(ar),modifier:Js(ar),operatorKeyword:Js(ar),controlKeyword:Js(ar),definitionKeyword:Js(ar),moduleKeyword:Js(ar),operator:lr,derefOperator:Js(lr),arithmeticOperator:Js(lr),logicOperator:Js(lr),bitwiseOperator:Js(lr),compareOperator:Js(lr),updateOperator:Js(lr),definitionOperator:Js(lr),typeOperator:Js(lr),controlOperator:Js(lr),punctuation:cr,separator:Js(cr),bracket:hr,angleBracket:Js(hr),squareBracket:Js(hr),paren:Js(hr),brace:Js(hr),content:sr,heading:rr,heading1:Js(rr),heading2:Js(rr),heading3:Js(rr),heading4:Js(rr),heading5:Js(rr),heading6:Js(rr),contentSeparator:Js(sr),list:Js(sr),quote:Js(sr),emphasis:Js(sr),strong:Js(sr),link:Js(sr),monospace:Js(sr),strikethrough:Js(sr),inserted:Js(),deleted:Js(),changed:Js(),invalid:Js(),meta:dr,documentMeta:Js(dr),annotation:Js(dr),processingInstruction:Js(dr),definition:$s.defineModifier("definition"),constant:$s.defineModifier("constant"),function:$s.defineModifier("function"),standard:$s.defineModifier("standard"),local:$s.defineModifier("local"),special:$s.defineModifier("special")};for(let t in ur){let e=ur[t];e instanceof $s&&(e.name=t)}var pr;Ks([{tag:ur.link,class:"tok-link"},{tag:ur.heading,class:"tok-heading"},{tag:ur.emphasis,class:"tok-emphasis"},{tag:ur.strong,class:"tok-strong"},{tag:ur.keyword,class:"tok-keyword"},{tag:ur.atom,class:"tok-atom"},{tag:ur.bool,class:"tok-bool"},{tag:ur.url,class:"tok-url"},{tag:ur.labelName,class:"tok-labelName"},{tag:ur.inserted,class:"tok-inserted"},{tag:ur.deleted,class:"tok-deleted"},{tag:ur.literal,class:"tok-literal"},{tag:ur.string,class:"tok-string"},{tag:ur.number,class:"tok-number"},{tag:[ur.regexp,ur.escape,ur.special(ur.string)],class:"tok-string2"},{tag:ur.variableName,class:"tok-variableName"},{tag:ur.local(ur.variableName),class:"tok-variableName tok-local"},{tag:ur.definition(ur.variableName),class:"tok-variableName tok-definition"},{tag:ur.special(ur.variableName),class:"tok-variableName2"},{tag:ur.definition(ur.propertyName),class:"tok-propertyName tok-definition"},{tag:ur.typeName,class:"tok-typeName"},{tag:ur.namespace,class:"tok-namespace"},{tag:ur.className,class:"tok-className"},{tag:ur.macroName,class:"tok-macroName"},{tag:ur.propertyName,class:"tok-propertyName"},{tag:ur.operator,class:"tok-operator"},{tag:ur.comment,class:"tok-comment"},{tag:ur.meta,class:"tok-meta"},{tag:ur.invalid,class:"tok-invalid"},{tag:ur.punctuation,class:"tok-punctuation"}]);const mr=new r,gr=new r;class fr{constructor(t,e,i=[],o=""){this.data=t,this.name=o,ne.prototype.hasOwnProperty("tree")||Object.defineProperty(ne.prototype,"tree",{get(){return yr(this)}}),this.parser=e,this.extension=[Mr.of(this),ne.languageData.of((t,e,i)=>{let o=br(t,e,i),n=o.type.prop(mr);if(!n)return[];let s=t.facet(n),r=o.type.prop(gr);if(r){let n=o.resolve(e-o.from,i);for(let e of r)if(e.test(n,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(s)}}return s})].concat(i)}isActiveAt(t,e,i=-1){return br(t,e,i).type.prop(mr)==this.data}findRegions(t){let e=t.facet(Mr);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],o=(t,e)=>{if(t.prop(mr)==this.data)return void i.push({from:e,to:e+t.length});let n=t.prop(r.mounted);if(n){if(n.tree.prop(mr)==this.data){if(n.overlay)for(let t of n.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(n.overlay){let t=i.length;if(o(n.tree,n.overlay[0].from+e),i.length>t)return}}for(let i=0;i=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let wr=null;class Cr{constructor(t,e,i=[],o,n,s,r,a){this.parser=t,this.state=e,this.fragments=i,this.tree=o,this.treeLen=n,this.viewport=s,this.skipped=r,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new Cr(t,e,[],p.empty,0,i,[],null)}startParse(){return this.parser.startParse(new vr(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=p.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(O.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=wr;wr=this;try{return t()}finally{wr=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=xr(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:o,treeLen:n,viewport:s,skipped:r}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,i,o,n)=>e.push({fromA:t,toA:i,fromB:o,toB:n})),i=O.applyChanges(i,e),o=p.empty,n=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){r=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),o=t.mapPos(e.to,-1);it.from&&(this.fragments=xr(this.fragments,i,o),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends B{createParse(e,i,o){let n=o[0].from,s=o[o.length-1].to;return{parsedPos:n,advance(){let e=wr;if(e){for(let t of o)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new p(c.none,[],[],s-n)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return wr}}function xr(t,e,i){return O.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class kr{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new kr(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=Cr.create(t.facet(Mr).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new kr(i)}}fr.state=kt.define({create:kr.init,update(t,e){for(let t of e.effects)if(t.is(fr.setState))return t.value;return e.startState.facet(Mr)!=e.state.facet(Mr)?kr.init(e.state):t.apply(e)}});let Sr=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(Sr=t=>{let e=-1,i=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const Tr="undefined"!=typeof navigator&&(null===(pr=navigator.scheduling)||void 0===pr?void 0:pr.isInputPending)?()=>navigator.scheduling.isInputPending():null,Er=ho.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(fr.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(fr.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=Sr(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEndo+1e3,a=n.context.work(()=>Tr&&Tr()||Date.now()>s,o+(r?0:1e5));this.chunkBudget-=Date.now()-e,(a||this.chunkBudget<=0)&&(n.context.takeTree(),this.view.dispatch({effects:fr.setState.of(new kr(n.context))})),this.chunkBudget>0&&(!a||r)&&this.scheduleWork(),this.checkAsyncSchedule(n.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(t=>ro(this.view.state,t)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Mr=ft.define({combine:t=>t.length?t[0]:null,enables:t=>[fr.state,Er,Fs.contentAttributes.compute([t],e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}})]});ur.meta,ur.link,ur.heading,ur.emphasis,ur.strong,ur.strikethrough,ur.keyword,ur.atom,ur.bool,ur.url,ur.contentSeparator,ur.labelName,ur.literal,ur.inserted,ur.string,ur.deleted,ur.regexp,ur.escape,ur.string,ur.variableName,ur.variableName,ur.typeName,ur.namespace,ur.className,ur.variableName,ur.macroName,ur.propertyName,ur.comment,ur.invalid;const Ar=Object.create(null),Ir=[c.none],Dr=[],Or=Object.create(null),Br=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Br[t]=Nr(Ar,e);function Lr(t,e){Dr.indexOf(t)>-1||(Dr.push(t),console.warn(e))}function Nr(t,e){let i=[];for(let o of e.split(" ")){let e=[];for(let i of o.split(".")){let o=t[i]||ur[i];o?"function"==typeof o?e.length?e=e.map(o):Lr(i,`Modifier ${i} used at start of tag`):e.length?Lr(i,`Tag ${i} used as modifier`):e=Array.isArray(o)?o:[o]:Lr(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let o=e.replace(/ /g,"_"),n=o+" "+i.map(t=>t.id),s=Or[n];if(s)return s.id;let r=Or[n]=c.define({id:Ir.length,name:o,props:[Ys({[o]:i})]});return Ir.push(r),r.id}function qr(t){let e=Date.now().toString(36);return e+=Math.random().toString(36).substr(3,t),e}function Rr(t,e,i,o){let n,s={index:-1,subindex:-1},r=o;return i?r.forEach((t,i)=>{if("SubmenuCommands"in t&&(n=t.SubmenuCommands.findIndex(t=>t.id==e.id),n>=0))return s={index:i,subindex:n},s}):(n=r.findIndex(t=>t.id==e.id),s={index:n,subindex:-1}),s}function Fr(t,e){let i,o=e.getLine(e.getCursor().line),n="";const s=/^(\>*(\[[!\w]+\])?\s*)#+\s/;let r;const a=o.match(s);a&&(r=a[0].trim()),t==r||""==t?i=o.replace(s,"$1"):(i=o.replace(/^\s*(#*|\>|\-|\d+\.)\s*/m,""),i=t+" "+i),n=""!=i?e.getRange(e.getCursor(),{line:e.getCursor().line,ch:o.length}):e.getRange(e.getCursor(),{line:e.getCursor().line,ch:0}),e.setLine(e.getCursor().line,i),e.setCursor({line:e.getCursor().line,ch:Number(i.length-n.length)})}function Pr(t,e){if(!e)return;const i=e.getSelection();if(!i||""===i.trim())return void this.plugin.setLastExecutedCommand("editing-toolbar:change-font-color");const o=/]+["']?>(.*?)<\/font>/gms,n=o.test(i);if(s=i,new RegExp(`^(.+)<\\/font>$`,"ms").test(s.trim()))return;var s;const r=i.replace(o,(e,i)=>i.split("\n").map(e=>e.trim()?`${e}`:e).join("\n")),a=r===i?i.split("\n").map(e=>e.trim()?`${e}`:e).join("\n"):r,l=e.listSelections().map(e=>{const i=n?0:``.length;return e.anchor.line([\s\S]*?)<\/mark>/g.test(i);if(((t,e)=>{const i=e.replace(/([()[{*+.$^\\|?])/g,"\\$1");return new RegExp(`^([sS]+)<\\/mark>$`).test(t.trim())})(i,t))return;let n;n=o?i.replace(/(background:)(?:#[0-9a-fA-F]{3,6}|rgba?\([^)]+\))/gi,`$1${t}`):i.split("\n").map(e=>e.trim()?`${e}`:e).join("\n");const s=e.listSelections().map(e=>{const i=o?0:``.length;return e.anchor.line=0?t.getLine(s).trim():"";if(s<0||!/^\s*\d+\.\s/.test(r)||((null===(i=r.match(/^\s*/))||void 0===i?void 0:i[0].length)||0)0;){const e=t.getLine(i-1);if(!/^\s*\d+\.\s/.test(e.trim()))break;i--}for(;o{"OrderedList"===t.name&&(d=t.to)}}),d>=0){const t=o.offsetToPos(d).line+1;t=0?o.getLine(f).trim():"";if(b&&!/^\s*$/.test(b)&&!b.includes("ㅤ")&&(g.push(""),g.push("ㅤ")),u)g.push(...e);else{let t={},i=-1;for(const o of e){const e=o.trim(),n=/^\d+\.\s/.test(e),s=(null===(r=o.match(/^\s*/))||void 0===r?void 0:r[0])||"";if(n){const o=s.length;t[o]=o!==i?1:(t[o]||1)+1,g.push(`${s}${t[o]}. ${e.replace(/^\d+\.\s/,"")}`),i=o}else g.push(o),i=-1}}o.replaceRange(g.join("\n"),{line:i,ch:0},{line:i+e.length-1,ch:o.getLine(i+e.length-1).length})}function Hr(t,e,i){const o=[];for(let n=e;n<=i;n++)o.push(t.getLine(n));zr(o,e,t)}let Wr;Ei.RTL,Ei.LTR;const $r=e=>{Wr=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;["top","following","fixed"].forEach(t=>{Wr.querySelectorAll(`.editingToolbarModalBar[data-toolbar-style="${t}"]`).forEach(t=>{e?(t.style.display="",t.style.visibility="visible"):t.style.display="none"})});const i=Wr.getElementById("editingToolbarModalBar");i&&(e?(i.style.display="",i.style.visibility="visible"):i.style.display="none")},Ur=e=>{Wr=t.requireApiVersion("0.15.0")?activeWindow.document:window.document,Wr.documentElement.style.setProperty("--toolbar-vertical-offset",`${e.verticalPosition}px`)},jr=e=>{Wr=t.requireApiVersion("0.15.0")?activeWindow.document:window.document,Wr.documentElement.style.setProperty("--toolbar-horizontal-offset",`${e.horizontalPosition}px`)};var Yr={"Editing Toolbar Append Method":"Editing Toolbar Append Method","Choose where Editing Toolbar will append upon regeneration. To see the change, hit the refresh button below, or in the status bar menu.":"Choose where Editing Toolbar will append upon regeneration. To see the change, hit the refresh button below, or in the status bar menu.","Editing Toolbar aesthetic":"Editing Toolbar aesthetic","Choose between a glass morphism, tiny and default style for Editing Toolbar. To see the change, hit the refresh button below, or in the status bar menu.":"Choose between a glass morphism, tiny and default style for Editing Toolbar. To see the change, hit the refresh button below, or in the status bar menu.","Editing Toolbar position":"Editing Toolbar position","Choose between fixed position or cursor following mode.":"Choose between fixed position, cursor following or Top mode.","Editing Toolbar Columns":"Editing Toolbar Columns","Choose the number of columns per row to display on Editing Toolbar.":"Choose the number of columns per row to display on Editing Toolbar.","Editing Toolbar refresh":"Editing Toolbar refresh","Editing Toolbar Commands":"Editing Toolbar Commands","Add a command onto Editing Toolbar from Obsidian's commands library. To reorder the commands, drag and drop the command items. To delete them, use the delete buttom to the right of the command item. Editing Toolbar will not automaticaly refresh after reordering commands. Use the refresh button above.":"Add a command onto Editing Toolbar from Obsidian's commands library. To reorder the commands, drag and drop the command items. To delete them, use the delete buttom to the right of the command item. Editing Toolbar will not automaticaly refresh after reordering commands. Use the refresh button above.","Format Brush Off!":"Format Brush Off!","Hide & Show":"Hide & Show","Editing Toolbar will only refresh automatically after you have either added or deleted a command from it. To see UI changes to editingToolbar (above settings changes) use the refresh button. If you forget to refresh in settings, no worries. There is also a refresh button in the editingToolbar status bar menu.":"Editing Toolbar will only refresh automatically after you have either added or deleted a command from it. To see UI changes to editingToolbar (above settings changes) use the refresh button. If you forget to refresh in settings, no worries. There is also a refresh button in the editingToolbar status bar menu.","Font-Color formatting brush ON!":"Font-Color formatting brush ON!",More:"More","Font Colors":"Font Colors","Format Brush":"Format Brush","Background Color":"Background color",Refresh:"Refresh",Add:"Add",Delete:"Delete","Change Command Name":"Change Command Name","Add Submenu":"Add Submenu","Add Separator":"Add Separator","Enter the icon code, it looks like .... format":"Enter the icon code, it looks like .... format","Please enter a new name: ":"Please enter a new name: ","Drag the slider to move the position":"Drag the slider to move the position","Plugin Settings":"Plugin Settings","Background-color formatting brush ON!":"Background-color formatting brush ON!\nClick the mouse middle or right key to close the formatting-brush","Clear formatting brush ON!":"Clear formatting brush ON!","Clear formatting brush ON!\nClick the mouse middle or right key to close the formatting-brush":"Clear formatting brush ON!\nClick the mouse middle or right key to close the formatting-brush","The toolbar is displayed when the mouse moves over it, otherwise it is automatically hidden":"The toolbar is displayed when the mouse moves over it, otherwise it is automatically hidden","Editing Toolbar Auto-hide":"Editing Toolbar Auto-hide","Editing Toolbar Centred Display":"Editing Toolbar Centred Display","Whether the toolbar is centred or full-width, the default is full-width.":"Whether the toolbar is centred or full-width, the default is full-width.","Custom Backgroud Color":"Custom Backgroud Color","Custom Font Color":"Custom Font Color","🎨 Set Custom Background":"🎨 Set Custom Background","🖌️ Set Custom Font Color":"🖌️ Set Custom Font Color","Click on the picker to adjust the color":"Click on the picker to adjust the color","Mobile Enabled or Not":"Mobile Enabled or Not","Whether to enable the plugin for the mobile client, the default is enabled.":"Whether to enable the plugin for the mobile client, the default is enabled.","Whether to enable on mobile devices with device width less than 768px.":"Whether to enable on mobile devices with device width less than 768px, the default is disable.",Reset:"Reset",Fix:"Fix","Fix Editing Toolbar":"Fix Editing Toolbar",General:"General",Appearance:"Appearance",Commands:"Commands","Choose between fixed position or cursor following mode":"Choose between fixed position, cursor following or Top mode.","Add and manage commands":"Add and manage commands","Choose where Editing Toolbar will append upon regeneration.":"Choose where Editing Toolbar will append upon regeneration.","Whether to enable on mobile devices with device width less than 768px":"Whether to enable on mobile devices with device width less than 768px","Choose between a glass morphism, tiny and default style.":"Choose between a glass morphism, tiny and default style.","Refresh Toolbar":"Refresh Toolbar","Add Command":"Add Command",Settings:"Settings","Position Style":"Position Style",Columns:"Columns","Drag to Adjust Position":"Drag to Adjust Position","Vertical Position":"Vertical Position","Horizontal Position":"Horizontal Position","Toolbar Position":"Toolbar Position","Choose an icon":"Choose an icon","Search for an icon...":"Search for an icon...",All:"All",Obsidian:"Obsidian",Glyph:"Glyph",Custom:"Custom","Choose a command":"Choose a command","The command":"The command","already exists":"already exists","Enter the icon code, format as .... ":"Enter the icon code, format as .... ","No matching icons found":"No matching icons found","Custom Commands":"Custom Commands","Toolbar Commands":"Toolbar Commands",ID:"ID",Prefix:"Prefix",Suffix:"Suffix",Pattern:"Pattern","Custom Format Commands":"Custom Format Commands","Add, edit or delete custom format commands.":"Add, edit or delete custom format commands.",Edit:"Edit","Command ID":"Command ID",'Unique identifier, no spaces, e.g.: "my-custom-format"':'Unique identifier, no spaces, e.g.: "my-custom-format"',"Displayed name in toolbar and menu":"Displayed name in toolbar and menu","Add content before selected text":"Add content before selected text","Add content after selected text":"Add content after selected text","Character offset of cursor after formatting":"Character offset of cursor after formatting","Line offset of cursor after formatting":"Line offset of cursor after formatting","Whether to insert at the beginning of the next line":"Whether to insert at the beginning of the next line","Command icon (click to select)":"Command icon (click to select)","Choose Icon":"Choose Icon",Save:"Save",Cancel:"Cancel","Edit Custom Command":"Edit Custom Command","Add Custom Command":"Add Custom Command","Command ID and command name cannot be empty":"Command ID and command name cannot be empty","Command ID cannot contain spaces":"Command ID cannot contain spaces",'Command ID "${this.commandId}" already exists':'Command ID "${this.commandId}" already exists',"Cursor Position Offset":"Cursor Position Offset","Line Offset":"Line Offset","Line Head Format":"Line Head Format",Icon:"Icon","Command Name":"Command Name","Are you sure you want to restore all settings to default? This will lose all your custom configurations.":"Are you sure you want to restore all settings to default? This will lose all your custom configurations.","Restore default":"Restore default","Restore default settings":"Restore default settings","🔄Restore default settings":"🔄Restore default settings","🔧Data repair":"🔧Data repair","Command IDs have been successfully repaired!":"Command IDs have been successfully repaired!","No command IDs need to be repaired":"No command IDs need to be repaired","Error repairing command IDs, please check the console for details":"Error repairing command IDs, please check the console for details","Error restoring default settings, please check the console for details":"Error restoring default settings, please check the console for details","Successfully restored default settings!":"Successfully restored default settings!",Close:"Close",Tips:"Tips","This update changed the ID of some commands, please click this button to repair the commands to ensure the toolbar works properly":"This update changed the ID of some commands, please click this button to repair the commands to ensure the toolbar works properly","Repair command ID":"Repair command ID","This will reset all your custom configurations":"This will reset all your custom configurations","Notice:":"Notice:","This update rebuilds the entire code, reducing resource consumption":"This update rebuilds the entire code, reducing resource consumption","Optimized mobile usage, added canvas support, and added custom commands":"Optimized mobile usage, added canvas support, and added custom commands","⚠️This update is not compatible with 2.x version command ids, please click [Repair command] to be compatible":"⚠️This update is not compatible with 2.x version command ids, please click [Repair command] to be compatible","⚠️If you want to restore the default settings, please click [Restore default settings]":"⚠️If you want to restore the default settings, please click [Restore default settings]","Please execute a editingToolbar format command first, then enable the format brush":"Please execute a editingToolbar format command first, then enable the format brush","Format brush ON! Select text to apply【":"Format brush ON! Select text to apply【","】format":"】format\nClick the mouse right key to close the formatting-brush","Add to Toolbar":"Add to Toolbar","This command is already in the toolbar.":"This command is already in the toolbar.","Command added to toolbar":"Command added to toolbar","Add this command to the toolbar.":"Add this command to the toolbar.","Callout Type":"Callout Type",Title:"Title","Optional, leave blank for default title":"Optional, leave blank for default title","Input title":"Input title","Collapse State":"Collapse State",Open:"Open",Closed:"Closed",Content:"Content",Insert:"Insert",Default:"Default","Input content":"Input content","Link Text":"Link Text","Link Alias":"Link Alias","Link URL":"Link URL","Embed Content":"Embed Content","Image Size":"Image Size","Insert New Line":"Insert New Line","Paste and Parse":"Paste and Parse","URL Format Error":"URL Format Error","Image Width":"Image Width","Image Height":"Image Height","If it is an image, turn on":"If it is an image, turn on","Insert a link on the next line":"Insert a link on the next line","Link Title(optional)":"Link Title(optional)",Alias:"Alias",Optional:"Optional","Default 0, format will keep the text selected":"Default 0, format will keep the text selected","to insert":"to insert","Latest Changes":"Latest Changes","📋View full changelog":"📋View full changelog","Open changelog":"Open changelog","Loading changelog...":"Loading changelog...","Open the complete changelog in your browser":"Open the complete changelog in your browser","Enable Multiple Configurations":"Enable Multiple Configurations","Enable different command configurations for each position style (following, top, fixed).":"Enable different command configurations for each position style (following, top, fixed).","Currently editing commands for":"Currently editing commands for","position style":"position style","Current Configuration":"Current Configuration","Switch between different command configurations.":"Switch between different command configurations.","Following Style":"Following Style","Top Style":"Top Style","Fixed Style":"Fixed Style","Mobile Style":"Mobile Style",configuration:"configuration","Deploy command to configurations":"Deploy command to configurations","All Configurations":"All Configurations",Deploy:"Deploy","Command deployed to selected configurations":"Command deployed to selected configurations","No configuration selected for deployment":"No configuration selected for deployment","Command already exists in selected configurations":"Command already exists in selected configurations","Command deployed to: ":"Command deployed to: ","Command Deleted":"Command Deleted","Confirm Delete?":"Confirm Delete?",Confirm:"Confirm","Are you sure you want to restore all settings to default? But custom commands will be preserved.":"Are you sure you want to restore all settings to default? But custom commands will be preserved.","Successfully restored default settings! (Custom commands preserved)":"Successfully restored default settings! (Custom commands preserved)","This will reset all your custom configurations, but custom commands will be preserved":"This will reset all your custom configurations, but custom commands will be preserved","Import/Export":"Import/Export","Export Configuration":"Export Configuration","Export your toolbar configuration to share with others.":"Export your toolbar configuration to share with others.",Export:"Export","Import Configuration":"Import Configuration","Import toolbar configuration from JSON.":"Import toolbar configuration from JSON.",Import:"Import","Usage Instructions":"Usage Instructions","Export: Generate a JSON configuration that you can save or share.":"Export: Generate a JSON configuration that you can save or share.","Import: Paste a previously exported JSON configuration.":"Import: Paste a previously exported JSON configuration.","You can choose to export all settings, only toolbar commands, or only custom commands":"You can choose to export all settings, only toolbar commands, or only custom commands","When importing, the plugin will only update the settings included in the import data":"When importing, the plugin will only update the settings included in the import data","Warning: Importing configuration will overwrite your current settings. Consider exporting your current configuration first as a backup.":"Warning: Importing configuration will overwrite your current settings. Consider exporting your current configuration first as a backup.","Export Type":"Export Type","Choose what to export":"Choose what to export","All Settings":"All Settings","Toolbar Commands Only":"Toolbar Commands Only","Custom Commands Only":"Custom Commands Only","Export Content":"Export Content","Copy this content to share with others":"Copy this content to share with others","Loading...":"Loading...","Copy to Clipboard":"Copy to Clipboard","Configuration copied to clipboard":"Configuration copied to clipboard","Failed to copy configuration":"Failed to copy configuration","Paste the configuration JSON here":"Paste the configuration JSON here","Paste configuration here...":"Paste configuration here...","Invalid import data":"Invalid import data","Configuration imported successfully":"Configuration imported successfully","No valid configuration found in import data":"No valid configuration found in import data","Failed to import configuration. Invalid format.":"Failed to import configuration. Invalid format.","Import Mode":"Import Mode","Choose how to import the configuration":"Choose how to import the configuration","Update Mode (Add new items and update existing ones)":"Update Mode (Add new items and update existing ones)","Overwrite Mode (Replace all settings with imported ones)":"Overwrite Mode (Replace all settings with imported ones)","Configuration imported successfully (Overwrite mode)":"Configuration imported successfully (Overwrite mode)","Configuration imported successfully (Update mode)":"Configuration imported successfully (Update mode)","Warning: Overwrite mode will completely replace your current settings with the imported ones. Consider exporting your current configuration first as a backup.":"Warning: Overwrite mode will completely replace your current settings with the imported ones. Consider exporting your current configuration first as a backup.","Warning: Update mode will add new items and update existing ones based on the imported configuration.":"Warning: Update mode will add new items and update existing ones based on the imported configuration.","Add Format Command":"Add Format Command",Regex:"Regex","Prefix/Suffix":"Prefix/Suffix","Insert Special Char":"Insert Special Char","Add Regex Command":"Add Regex Command","Switch Regex Command Window":"Switch Regex Command Window","Please select text first":"Please select text first","Current line is empty, please select text or move to a non-empty line":"Current line is empty, please select text or move to a non-empty line","Use current line for regex commands":"Use current line for regex commands","When no text is selected, regex commands will use the current line instead of clipboard content":"When no text is selected, regex commands will use the current line instead of clipboard content","The selected text does not meet the condition requirements":"The selected text does not meet the condition requirements","Regex command execution error: ":"Regex command execution error: ","Copy code":"Copy code","Copied!":"Copied!","Explain the syntax of JavaScript regular expressions":"Explain the syntax of JavaScript regular expressions","Apply regular expression replacement":"Apply regular expression replacement","Conditional matching":"Conditional matching","Complete regular expression code (copy to AI for explanation)":"Complete regular expression code (copy to AI for explanation)","Error: ":"Error: ","Regex pattern cannot be empty":"Regex pattern cannot be empty","Command already exists":"Command already exists","Choose icon":"Choose icon","URL to Markdown link":"URL to Markdown link","Convert MM/DD/YYYY to YYYY-MM-DD":"Convert MM/DD/YYYY to YYYY-MM-DD","Add bold to keywords":"Add bold to keywords","Format phone number":"Format phone number","Remove extra spaces":"Remove extra spaces","Convert HTML bold tags to Markdown format":"Convert HTML bold tags to Markdown format","Convert quoted text to quote block":"Convert quoted text to quote block","Convert CSV to Markdown table row":"Convert CSV to Markdown table row","Add uniform alias to Markdown links":"Add uniform alias to Markdown links","Delete empty lines (multiline mode)":"Delete empty lines (multiline mode)","Add list symbol to each line (multiline mode)":"Add list symbol to each line (multiline mode)","If the text contains important, set the text highlight (conditional format)":"If the text contains important, set the text highlight (conditional format)","Matching pattern":"Matching pattern","Regex pattern to match":"Regex pattern to match","Replacement pattern (use $1, $2, etc. to reference capture groups)":"Replacement pattern (use $1, $2, etc. to reference capture groups)","Ignore case":"Ignore case","Global replace":"Global replace","Multiline mode":"Multiline mode","Use condition":"Use condition","Condition pattern":"Condition pattern","Only apply custom command when text matches the condition":"Only apply custom command when text matches the condition","Must exist regular expression or text":"Must exist regular expression or text","Replacement pattern":"Replacement pattern","Match case-insensitive":"Match case-insensitive","^ and $ match the start and end of each line":"^ and $ match the start and end of each line","Replace all matches":"Replace all matches",Command:"Command","Input example text to view the formatting effect of the command...":"Input example text to view the formatting effect of the command...",Description:"Description","[Example]":"[Example]","[Requirements]":"[Requirements]","[Output]":"[Output]","AI question template:":"AI question template:","I need to convert the url to a markdown format link":"I need to convert the url to a markdown format link","For example, convert https://example.com to [https://example.com](https://example.com)":"For example, convert https://example.com to [https://example.com](https://example.com)","Use js regular expression to implement, and output the parameters in the following format (the result does not need to be escaped with json)":"Use js regular expression to implement, and output the parameters in the following format (the result does not need to be escaped with json)","[Description]":"[Description]","How to use AI to get regular expressions?":"How to use AI to get regular expressions?","Regular expression examples":"Regular expression examples","Edit regular expression command":"Edit regular expression command","Add regular expression command":"Add regular expression command","Result: ":"Result: ","Example text:":"Example text:",Preview:"Preview",Result:"Result","Please select text or copy text to clipboard first":"Please select text or copy text to clipboard first","Overwrite Import":"Overwrite Import","Update Import":"Update Import","Importing configuration...":"Importing configuration...","Following Style Only":"Following Style Only","Top Style Only":"Top Style Only","Fixed Style Only":"Fixed Style Only","Mobile Style Only":"Mobile Style Only","Unknown import type":"Unknown import type","All Toolbar Commands":"All Toolbar Commands","Initialize Commands":"Initialize Commands","Copy commands from the main menu configuration":"Copy commands from the main menu configuration","Initialize commands to default settings":"Initialize commands to default settings","Reset Commands":"Reset Commands","Commands reset successfully":"Commands reset successfully","Following style commands initialized from current menu commands":"Following style commands initialized from current menu commands","Commands initialized successfully":"Commands initialized successfully","Reset to Menu Commands":"Reset to Menu Commands","Are you sure you want to reset the current configuration?":"Are you sure you want to reset the current configuration?","Following style commands successfully initialized":"Following style commands successfully initialized","Top style commands successfully initialized":"Top style commands successfully initialized","Fixed style commands successfully initialized":"Fixed style commands successfully initialized","Mobile style commands successfully initialized":"Mobile style commands successfully initialized","Reset commands to default settings":"Reset commands to default settings",Clear:"Clear","Remove all commands from this configuration.":"Remove all commands from this configuration.","Are you sure you want to clear all commands under the current style?":"Are you sure you want to clear all commands under the current style?","Current style commands have been cleared":"Current style commands have been cleared","Manage Commands":"Manage Commands","Reset or clear all commands in this configuration":"Reset or clear all commands in this configuration","One-click Clear":"One-click Clear","Import Commands from Other Styles":"Import Commands from Other Styles","Copy commands from another style configuration.":"Copy commands from another style configuration.","Main menu only":"Main menu only","This import will update:":"This import will update:","Custom commands":"Custom commands","Toolbar commands":"Toolbar commands","General settings":"General settings","Please paste configuration data first":"Please paste configuration data first","Invalid import data format":"Invalid import data format","Import From":"Import From","This import will:":"This import will:","Update general settings":"Update general settings","Update Main Menu Commands":"Update Main Menu Commands","Update Custom Commands":"Update Custom Commands","Update Following Style Commands":"Update Following Style Commands","Update Top Style Commands":"Update Top Style Commands","Update Fixed Style Commands":"Update Fixed Style Commands","Update Mobile Style Commands":"Update Mobile Style Commands","Clear all Main Menu Commands":"Clear all Main Menu Commands","Clear all Custom Commands":"Clear all Custom Commands","Clear all Following Style Commands":"Clear all Following Style Commands","Clear all Top Style Commands":"Clear all Top Style Commands","Clear all Fixed Style Commands":"Clear all Fixed Style Commands","Clear all Mobile Style Commands":"Clear all Mobile Style Commands","Overwrite Mode (Replace settings with imported ones)":"Overwrite Mode (Replace settings with imported ones)","Warning: Overwrite mode will replace existing settings with imported ones.":"Warning: Overwrite mode will replace existing settings with imported ones.","Warning: Update mode will add new items and update existing ones.":"Warning: Update mode will add new items and update existing ones.","Enable Multiple Config":"Enable Multiple Config","Set Multiple Config to:":"Set Multiple Config to:",Enable:"Enable",Disable:"Disable","Set Position Style to:":"Set Position Style to:",Following:"Following",Top:"Top",Fixed:"Fixed",Mobile:"Mobile","All commands":"All commands","⚠️ Overwrite mode will replace existing settings with imported ones.":"⚠️ Overwrite mode will replace existing settings with imported ones.","ℹ️ Update mode will merge imported settings with existing ones.":"ℹ️ Update mode will merge imported settings with existing ones.","Do you want to continue?":"Do you want to continue?","Imported settings:":"Imported settings:","Imported commands:":"Imported commands:","Disable toolbar for this view":"Disable toolbar for this view","Enable toolbar for this view":"Enable toolbar for this view","Manage all view types":"Manage all view types","Current View: ":"Current View: ","Appearance Style":"Appearance Style","Position Settings":"Position Settings","All commands have been removed.":"All commands have been removed.","Join the Community":"Join the Community","Share your toolbar settings and styles in our":"Share your toolbar settings and styles in our","Get inspired by what others have created or showcase your own customizations.":"Get inspired by what others have created or showcase your own customizations.","Toolbar Preview (With a hypothetical command configuration.)":"Toolbar Preview (With a hypothetical command configuration.)","Toolbar Theme":"Toolbar Theme","Select a preset toolbar theme, automatically setting the background color, icon color, and size for the selected style.":"Select a preset toolbar theme, automatically setting the background color, icon color, and size for the selected style.","Toolbar Background Color":"Toolbar Background Color","Set the background color of the toolbar.":"Set the background color of the toolbar.","Toolbar Icon Color":"Toolbar Icon Color","Set the color of the toolbar icon.":"Set the color of the toolbar icon.","Toolbar Icon Size":"Toolbar Icon Size","Set the size of the toolbar icon (px); default: 18px":"Set the size of the toolbar icon (px); default: 18px","Custom Theme":"Custom Theme","Fixed Position Offset":"Fixed Position Offset","Choose the offset of the Editing Toolbar in the fixed position.":"Choose the offset of the Editing Toolbar in the fixed position.","Renumber List":"Renumber List","Fetch Remote Title":"Fetch Remote Title","Please enter a URL first":"Please enter a URL first","Failed to fetch title for":"Failed to fetch title for","Link Title (optional)":"Link Title (optional)","Unable to detect editor width":"Unable to detect editor width","Fit Editor Width":"Fit Editor Width","Please execute a format command or select format text first, then enable the format brush":"Please execute a format command or select format text first, then enable the format brush","Use \\n to represent line breaks":"Use \\n to represent line breaks","Use ↵ to represent line breaks":"Use ↵ to represent line breaks","Top Toolbar":"Top Toolbar","Enable the toolbar positioned at the top.":"Enable the toolbar positioned at the top.","Following Toolbar":"Following Toolbar","Enable the toolbar that appears upon text selection.":"Enable the toolbar that appears upon text selection.","Fixed Toolbar":"Fixed Toolbar","Enable the toolbar whose position may be fixed where you please.":"Enable the toolbar whose position may be fixed where you please.","Toolbar Settings":"Toolbar Settings","Choose which toolbar style's appearance you want to edit.":"Choose which toolbar style's appearance you want to edit.","Vertical Split":"Vertical Split"},Gr={"Editing Toolbar Append Method":"工具栏的附加方法。","Choose where Editing Toolbar will append upon regeneration. To see the change, hit the refresh button below, or in the status bar menu.":"工具栏在Obsidian中的追加的位置,只对固定和跟随模式有效。如果你遇到工具栏显示问题,可以选择body试试。请点击下面或者状态栏菜单中的刷新按钮生效。","Editing Toolbar aesthetic":"工具栏样式","Choose between a glass morphism, tiny and default style for Editing Toolbar. To see the change, hit the refresh button below, or in the status bar menu.":"样式有毛玻璃,简约和默认风格选择。请点击下面或者状态栏菜单中的刷新按钮生效。","Editing Toolbar position":"工具栏位置","Choose between fixed position or cursor following mode.":"在固定位置,光标跟随模式或者置顶模式之间进行选择。","Editing Toolbar Columns":"工具栏栏目数","Choose the number of columns per row to display on Editing Toolbar.":"选择在Editing Toolbar上显示的每行的列数。","Editing Toolbar refresh":"刷新工具栏","Editing Toolbar Commands":"在工具栏中添加命令","Add a command onto Editing Toolbar from Obsidian's commands library. To reorder the commands, drag and drop the command items. To delete them, use the delete buttom to the right of the command item. Editing Toolbar will not automaticaly refresh after reordering commands. Use the refresh button above.":"从Obsidian的命令库中添加一个命令到工具栏。要重新排列命令,可以拖放命令项。要删除它们,请使用命令项右边的删除按钮。图标选择Custom可以自定义图标","Format Brush Off!":"关闭格式刷!","Hide & Show":"隐藏 & 显示","Editing Toolbar will only refresh automatically after you have either added or deleted a command from it. To see UI changes to editingToolbar (above settings changes) use the refresh button. If you forget to refresh in settings, no worries. There is also a refresh button in the editingToolbar status bar menu.":"对外观的更改生效需要使用刷新按钮。如果你忘记在设置中刷新,在状态栏菜单中也有一个刷新按钮。","Font-Color formatting brush ON!":"字体颜色格式刷开启\n点击鼠标中键或者右键关闭格式刷",More:"更多","Font Colors":"字体颜色","Format Brush":"格式刷","Background Color":"背景颜色",Refresh:"刷新",Add:"添加",Delete:"删除","Change Command Name":"更改命令名称","Add Submenu":"添加子菜单","Add Separator":"添加分割线","Enter the icon code, it looks like .... format":"输入图标代码,类似.... 格式","Please enter a new name: ":"请输入新名称:","Drag the slider to move the position":"拖动滑块来移动位置","Plugin Settings":"插件设置","Background-color formatting brush ON!":"开启背景色格式刷","Clear formatting brush ON!":"清除格式刷已开启","Clear formatting brush ON!\nClick the mouse middle or right key to close the formatting-brush":"清除格式刷已开启\n点击鼠标中键或者右键关闭格式刷","The toolbar is displayed when the mouse moves over it, otherwise it is automatically hidden":"当鼠标移到工具栏上方时,工具栏显示,否则自动隐藏","Editing Toolbar Auto-hide":"工具栏是否自动隐藏","Editing Toolbar Centred Display":"工具栏是否居中显示","Whether the toolbar is centred or full-width, the default is full-width.":"工具栏居中还是全宽显示,默认全宽显示","Custom Backgroud Color":"设置自定义背景色","Custom Font Color":"设置自定义字体颜色","🎨 Set Custom Background":"🎨 设置自定义背景","🖌️ Set Custom Font Color":"🖌️ 设置自定义字体颜色","Click on the picker to adjust the color":"点击选取器来调整颜色","Mobile Enabled or Not":"是否在移动端启用","Whether to enable on mobile devices with device width less than 768px.":"是否在设备宽度小于768的移动设备启用。默认不启用",Reset:"重置",Fix:"修复","Fix Editing Toolbar":"修复工具栏",General:"常规",Appearance:"外观",Commands:"命令","Choose between fixed position or cursor following mode":"选择固定位置或者光标跟随模式","Add and manage commands":"添加和管理命令","Choose where Editing Toolbar will append upon regeneration.":"选择工具栏在Obsidian中的追加的位置。","Whether to enable on mobile devices with device width less than 768px":"是否在移动设备中启用。默认不启用","Choose between a glass morphism, tiny and default style":"选择毛玻璃,简约和默认风格","Refresh Toolbar":"刷新工具栏","Add Command":"添加命令",Settings:"设置","Adjust Toolbar Position[Fixed mode]":"调整工具栏位置[固定模式]","Position Style":"位置样式",Columns:"列数","Drag to Adjust Position":"拖动调整位置","Vertical Position":"垂直位置","Horizontal Position":"水平位置","Toolbar Position":"工具栏位置","Choose an icon":"选择一个图标","Search for an icon...":"搜索图标...",All:"全部",Obsidian:"Obsidian",Glyph:"Glyph",Custom:"自定义","Choose a command":"选择一个命令","The command":"命令","already exists":"已存在","Enter the icon code, format as .... ":"输入图标代码,格式为 .... ","No matching icons found":"没有找到匹配的图标","Custom Commands":"自定义命令","Toolbar Commands":"工具栏命令",ID:"ID",Prefix:"前缀",Suffix:"后缀","Custom Format Commands":"自定义格式命令","Add, edit or delete custom format commands.":"添加、编辑或删除自定义格式命令",Edit:"编辑","Command ID":"命令ID",'Unique identifier, no spaces, e.g.: "my-custom-format"':'唯一标识符,不包含空格,例如:"my-custom-format"',"Displayed name in toolbar and menu":"在工具栏和菜单中显示的名称","Add content before selected text":"在选中的文本前添加内容","Add content after selected text":"在选中的文本后添加内容","Character offset of cursor after formatting":"格式化后光标的字符偏移量","Line offset of cursor after formatting":"格式化后光标的行偏移量","Whether to insert at the beginning of the next line":"是否在下一行首插入","Command icon (click to select)":"命令图标(点击选择)","Choose Icon":"选择图标",Save:"保存",Cancel:"取消","Edit Custom Command":"编辑自定义命令","Add Custom Command":"添加自定义命令","Command ID and command name cannot be empty":"命令ID和命令名称不能为空","Command ID cannot contain spaces":"命令ID不能包含空格",'Command ID "${this.commandId}" already exists':'命令ID "${this.commandId}" 已存在',"Command Name":"命令名称","Cursor Position Offset":"光标位置偏移量","Line Offset":"行偏移量","Line Head Format":"行首格式",Icon:"图标","Are you sure you want to restore all settings to default? This will lose all your custom configurations.":"确定要恢复所有设置为默认值吗?这将丢失您的所有自定义配置。","Restore default":"恢复默认值","Restore default settings":"恢复默认设置","🔄Restore default settings":"🔄恢复默认设置","🔧Data repair":"🔧数据修复","Command IDs have been successfully repaired!":"命令ID已成功修复!","No command IDs need to be repaired":"没有命令ID需要修复","Error repairing command IDs, please check the console for details":"修复命令ID时出错,请查看控制台了解详情","Error restoring default settings, please check the console for details":"恢复默认设置时出错,请查看控制台了解详情","Successfully restored default settings!":"已成功恢复默认设置!",Close:"关闭",Tips:"提示","This update changed the ID of some commands, please click this button to repair the commands to ensure the toolbar works properly":"此次更新更改了部分命令的ID,请点击此按钮修复命令以确保工具栏正常工作","Repair command ID":"修复命令ID","This will reset all your custom configurations":"这将重置您的所有自定义配置","Notice:":"注意","This update rebuilds the entire code, reducing resource consumption":"此次更新重构了全部代码,降低了资源占用","Optimized mobile usage, added canvas support, and added custom commands":"优化了移动端,增加了对canvas支持,增加了自定义命令","⚠️This update is not compatible with 2.x version command ids, please click [Repair command] to be compatible":"⚠️此次更新不兼容2.x旧版本命令id,请点击【修复命令】进行兼容","⚠️If you want to restore the default settings, please click [Restore default settings]":"⚠️如果想恢复默认设置,请点击【恢复默认设置】","Please execute a editingToolbar format command first, then enable the format brush":"请先执行一个格式命令,然后再启用格式刷","Format brush ON! Select text to apply【":"格式刷已开启\n选中文本应用【","】format":"】格式\n点击鼠标右键关闭格式刷","Add to Toolbar":"添加到工具栏","This command is already in the toolbar.":"该命令已存在于工具栏中","Command added to toolbar":"命令已添加到工具栏","Add this command to the toolbar.":"添加该命令到工具栏","Callout Type":"Callout 类型",Title:"标题","Optional, leave blank for default title":"可选,留空则使用默认标题","Input title":"输入标题","Collapse State":"折叠状态",Open:"展开",Closed:"折叠",Content:"内容",Insert:"插入",Default:"默认","Input content":"输入内容","Link Text":"链接文本","Link Alias":"链接别名","Link URL":"链接地址","Embed Content":"嵌入内容","Image Size":"图片尺寸","Insert New Line":"插入新行","Paste and Parse":"粘贴并解析","URL Format Error":"URL格式错误","Image Width":"图片宽度","Image Height":"图片高度","Insert a link on the next line":"在下一行插入链接","If it is an image, turn on":"如果是图片,请开启","Link Title(optional)":"链接标题(可选)",Alias:"别名",Optional:"可选","Default 0, format will keep the text selected":"默认0,格式化将保持文本选中","to insert":"插入","Latest Changes":"最新更新","📋View full changelog":"📋查看完整更新日志","Open changelog":"打开更新日志","Loading changelog...":"加载更新日志...","Open the complete changelog in your browser":"在浏览器中打开完整更新日志","Enable Multiple Configurations":"启用多配置","Enable different command configurations for each position style (following, top, fixed).":"启用每个位置样式的不同命令配置(following,top,fixed)","Currently editing commands for":"当前编辑的命令配置为:","position style":"样式","Current Configuration":"当前配置","Switch between different command configurations.":"切换不同的命令配置","Following Style":"跟随样式","Top Style":"顶部样式","Fixed Style":"固定样式","Mobile Style":"移动端样式",configuration:"配置","Deploy command to configurations":"部署命令到配置","All Configurations":"所有配置",Deploy:"部署","Command deployed to selected configurations":"命令已部署到选中的配置","No configuration selected for deployment":"没有选中的配置","Command already exists in selected configurations":"命令已存在于选中的配置","Command deployed to: ":"命令已部署到:","Command Deleted":"命令已删除","Confirm Delete?":"确认删除?","Are you sure you want to restore all settings to default? But custom commands will be preserved.":"您确定要将所有设置恢复为默认值吗?但自定义命令将被保留。","Successfully restored default settings! (Custom commands preserved)":"成功恢复默认设置!(自定义命令已保留)","This will reset all your custom configurations, but custom commands will be preserved":"这将重置您的所有自定义配置,但自定义命令将被保留","Import/Export":"导入/导出","Export Configuration":"导出配置","Export your toolbar configuration to share with others.":"导出您的工具栏配置以与他人共享",Export:"导出","Import Configuration":"导入配置","Import toolbar configuration from JSON.":"从JSON导入工具栏配置",Import:"导入","Usage Instructions":"使用说明","Export: Generate a JSON configuration that you can save or share.":"导出:生成可保存或共享的JSON配置","Import: Paste a previously exported JSON configuration.":"导入:粘贴先前导出的JSON配置","You can choose to export all settings, only toolbar commands, or only custom commands":"您可以选择导出所有设置、仅工具栏命令或仅自定义命令","When importing, the plugin will only update the settings included in the import data":"导入时,插件将仅更新导入数据中包含的设置","Warning: Importing configuration will overwrite your current settings. Consider exporting your current configuration first as a backup.":"警告:导入配置将覆盖您当前的设置。建议先导出当前配置作为备份。","Export Type":"导出类型","Choose what to export":"选择要导出的内容","All Settings":"所有设置","Toolbar Commands Only":"仅工具栏命令","Custom Commands Only":"仅自定义命令","Export Content":"导出内容","Copy this content to share with others":"复制此内容以与他人共享","Loading...":"加载中...","Copy to Clipboard":"复制到剪贴板","Configuration copied to clipboard":"配置已复制到剪贴板","Failed to copy configuration":"复制配置失败","Paste the configuration JSON here":"在此处粘贴配置JSON","Paste configuration here...":"在此处粘贴配置...","Invalid import data":"无效的导入数据","Configuration imported successfully":"配置导入成功","No valid configuration found in import data":"导入数据中未找到有效配置","Failed to import configuration. Invalid format.":"导入配置失败。格式无效。","Import Mode":"导入模式","Choose how to import the configuration":"选择如何导入配置","Update Mode (Add new items and update existing ones)":"更新模式(添加新项目并更新现有项目)","Overwrite Mode (Replace all settings with imported ones)":"覆盖模式(用导入的配置替换所有设置)","Configuration imported successfully (Overwrite mode)":"配置导入成功(覆盖模式)","Configuration imported successfully (Update mode)":"配置导入成功(更新模式)","Warning: Overwrite mode will completely replace your current settings with the imported ones. Consider exporting your current configuration first as a backup.":"警告:覆盖模式将完全替换您当前的设置与导入的设置。建议先导出当前配置作为备份。","Warning: Update mode will add new items and update existing ones based on the imported configuration.":"警告:更新模式将根据导入的配置添加新项目并更新现有项目。","Add Format Command":"添加格式命令",Regex:"正则","Prefix/Suffix":"前缀/后缀","Insert Special Char":"增加特殊符号","Add Regex Command":"添加正则表达式命令","Switch Regex Command Window":"切换到正则命令窗口","Please select text first":"请先选中文本","Current line is empty, please select text or move to a non-empty line":"当前行为空,请选中文本或移动到非空行","Use current line for regex commands":"正则命令使用当前行","When no text is selected, regex commands will use the current line instead of clipboard content":"当没有选中文本时,正则命令将使用当前行内容而不是剪贴板内容","The selected text does not meet the condition requirements":"选中的文本不满足条件要求","Regex command execution error: ":"正则表达式命令执行错误:","Copy code":"复制代码","Copied!":"已复制!","Explain the syntax of JavaScript regular expressions":"解释JavaScript正则表达式的语法","Apply regular expression replacement":"应用正则表达式替换","Conditional matching":"条件匹配","Complete regular expression code (copy to AI for explanation)":"完整正则表达式代码(复制到AI解释)","Error: ":"错误:","Regex pattern cannot be empty":"正则表达式不能为空","Command already exists":"命令已存在","Choose icon":"选择图标","URL to Markdown link":"URL转Markdown链接","Convert MM/DD/YYYY to YYYY-MM-DD":"将MM/DD/YYYY日期格式转换为YYYY-MM-DD","Add bold to keywords":"添加粗体到关键词","Format phone number":"格式化电话号码","Remove extra spaces":"删除多余空格","Convert HTML bold tags to Markdown format":"将HTML粗体标签转换为Markdown格式","Convert quoted text to quote block":"将引用的文本转换为引用块","Convert CSV to Markdown table row":"将CSV转换为Markdown表格行","Add uniform alias to Markdown links":"添加统一别名到Markdown链接","Delete empty lines (multiline mode)":"删除空行(多行模式)","Add list symbol to each line (multiline mode)":"添加列表符号到每行(多行模式)","If the text contains important, set the text highlight (conditional format)":"如果文本包含重要内容,设置文本高亮(条件格式)","Matching pattern":"匹配模式","Regex pattern to match":"正则表达式匹配","Replacement pattern (use $1, $2, etc. to reference capture groups)":"替换模式(使用$1, $2等引用捕获组)","Ignore case":"忽略大小写","Global replace":"全局替换","Multiline mode":"多行模式","Use condition":"使用条件","Condition pattern":"条件模式","Only apply custom command when text matches the condition":"仅在文本匹配条件时应用自定义命令","Must exist regular expression or text":"必须存在正则表达式或文本","Replacement pattern":"替换模式","Match case-insensitive":"匹配不区分大小写","^ and $ match the start and end of each line":"^ 和 $ 匹配每行的开始和结束","Replace all matches":"替换所有匹配",Command:"命令","Input example text to view the formatting effect of the command...":"输入示例文本以查看命令的格式化效果...",Description:"描述","[Example]":"[示例]","[Requirements]":"[要求]","[Output]":"[输出]","AI question template:":"AI问题模板:","I need to convert the url to a markdown format link":"我需要将URL转换为Markdown格式链接","For example, convert https://example.com to [https://example.com](https://example.com)":"例如,将https://example.com转换为[https://example.com](https://example.com)","Use js regular expression to implement, and output the parameters in the following format (the result does not need to be escaped with json)":"使用js正则表达式实现,并输出以下格式的参数(结果不需要用json转义)","[Description]":"[描述]","How to use AI to get regular expressions?":"如何使用AI获取正则表达式?","Regular expression examples":"正则表达式示例","Edit regular expression command":"编辑正则表达式命令","Add regular expression command":"添加正则表达式命令","Result:":"结果:","Example text:":"示例文本:",Preview:"预览",Result:"结果","Update Import":"增量导入","Overwrite Import":"覆盖导入","Importing configuration...":"正在导入配置...","Following Style Only":"仅Following样式","Top Style Only":"仅Top样式","Fixed Style Only":"仅Fixed样式","Mobile Style Only":"仅Mobile样式","Unknown import type":"未知导入类型","All Toolbar Commands":"所有工具栏命令","Following style commands successfully initialized":"Following样式初始化成功","Top style commands successfully initialized":"Top样式初始化成功","Fixed style commands successfully initialized":"Fixed样式初始化成功","Mobile style commands successfully initialized":"Mobile样式初始化成功","Commands initialized successfully":"命令初始化成功","Reset Commands":"重置命令","Are you sure you want to reset the current configuration?":"您确定要将当前配置进行重置吗?","Commands reset successfully":"命令重置成功","Initialize Commands":"初始化命令","Initialize commands to default settings":"初始化命令到默认设置","Reset commands to default settings":"重置命令到默认设置",Clear:"清除","Remove all commands from this configuration.":"清除当前样式下的所有命令","Are you sure you want to clear all commands under the current style?":"您确定要清除当前样式下的所有命令吗?","Current style commands have been cleared":"当前样式下的命令已清除","Manage Commands":"管理命令","Reset or clear all commands in this configuration":"重置或清除当前样式下的所有命令","Import Commands from Other Styles":"从其他样式导入命令","Copy commands from another style configuration.":"从另一个样式配置复制命令","Main menu only":"Main menu only","This import will update:":"此次导入将更新:","Custom commands":"自定义命令","Toolbar commands":"工具栏命令","All settings":"所有设置","Following style only":"跟随样式","Top style only":"顶部样式","Fixed style only":"固定样式","Mobile style only":"移动端样式","Main Menu Commands":"主菜单命令","Following Style Commands":"跟随样式命令","Top Style Commands":"顶部样式命令","Fixed Style Commands":"固定样式命令","Mobile Style Commands":"移动端样式命令","General settings":"常规设置","Please paste configuration data first":"请先粘贴配置数据","Invalid import data format":"无效的导入数据格式","Do you want to continue?":"您确定要继续吗?","Warning: Update mode will add new items and update existing ones.":"警告:更新模式将添加新项目并更新现有项目。","Warning: Overwrite mode will completely replace your current settings with the imported ones.":"警告:覆盖模式将完全替换您当前的设置与导入的设置。","Overwrite Mode (Replace settings with imported ones)":"覆盖模式(用导入的配置替换所有设置)","Warning: Overwrite mode will replace existing settings with imported ones.":"警告:覆盖模式将用导入的配置替换所有设置。","Enable Multiple Config":"启用多配置","One-click Clear":"一键清除","This import will:":"此次导入将:","Update general settings":"更新常规设置","Update Main Menu Commands":"更新主菜单命令","Update Custom Commands":"更新自定义命令","Update Following Style Commands":"更新跟随样式命令","Update Top Style Commands":"更新顶部样式命令","Update Fixed Style Commands":"更新固定样式命令","Clear all Main Menu Commands":"清除所有主菜单命令","Clear all Custom Commands":"清除所有自定义命令","Clear all Following Style Commands":"清除所有跟随样式命令","Clear all Top Style Commands":"清除所有顶部样式命令","Clear all Fixed Style Commands":"清除所有固定样式命令","Clear all Mobile Style Commands":"清除所有移动端样式命令","Set Multiple Config to:":"设置多配置为:",Enable:"启用",Disable:"禁用","Set Position Style to:":"设置位置样式为:",Following:"跟随",Top:"顶部",Fixed:"固定",Mobile:"移动端","All commands":"所有命令","⚠️ Overwrite mode will replace existing settings with imported ones.":"⚠️ 覆盖模式将用导入的配置替换所有设置。","ℹ️ Update mode will merge imported settings with existing ones.":"ℹ️ 更新模式将合并导入的设置与现有的设置。","Imported settings:":"导入的设置:","Imported commands:":"导入的命令:","Disable toolbar for this view":"禁用此视图的工具栏","Enable toolbar for this view":"启用此视图的工具栏","Manage all view types":"管理所有视图类型","Current View: ":"当前视图:","Appearance Style":"外观样式","Position Settings":"位置设置","Join the Community":"加入社区","Share your toolbar settings and styles in our":"分享您的工具栏设置和样式:","section!":"社区!","Get inspired by what others have created or showcase your own customizations.":"获取灵感或展示您的自定义设置。","Toolbar Preview (With a hypothetical command configuration.)":"工具栏预览(按钮仅供参考)","Toolbar Theme":"工具栏主题","Select a preset toolbar theme, automatically setting the background color, icon color, and size for the selected style.":"选择预设的工具栏主题,自动设置背景颜色、图标颜色和大小","Toolbar Background Color":"工具栏背景颜色","Set the background color of the toolbar.":"设置工具栏的背景颜色","Toolbar Icon Color":"工具栏图标颜色","Set the color of the toolbar icon.":"设置工具栏图标颜色","Toolbar Icon Size":"工具栏图标大小","Set the size of the toolbar icon (px); default: 18px":"设置工具栏图标大小(px)默认18px","Custom theme":"自定义主题","Fixed Position Offset":"固定位置偏移","Choose the offset of the Editing Toolbar in the fixed position.":"选择固定位置工具栏的偏移量。","Renumber List":"列表重新编号","Insert link":"插入链接","Please enter a URL first":"请先输入一个URL","Failed to fetch title for":"获取标题失败","Link Title (optional)":"链接标题(可选)","Unable to detect editor width":"无法检测编辑器宽度","Fit Editor Width":"自适应宽度","Fetch Remote Title":"获取URL标题","Please execute a format command or select format text first, then enable the format brush":"请先执行一个格式命令或选中带格式的文本,然后启用格式刷",Confirm:"确认","Use \\n to represent line breaks":"使用\\n表示换行符","Use ↵ to represent line breaks":"使用↵表示换行符","All commands have been removed.":"所有命令已被清除。","Top Toolbar":"顶部工具栏","Enable the toolbar positioned at the top.":"启用位于顶部的工具栏。","Following Toolbar":"跟随工具栏","Enable the toolbar that appears upon text selection.":"启用在选中文本时出现的工具栏。","Fixed Toolbar":"固定工具栏","Enable the toolbar whose position may be fixed where you please.":"启用可以固定在任意位置的工具栏。","Toolbar Settings":"工具栏设置","Choose which toolbar style's appearance you want to edit.":"选择要编辑外观的工具栏样式。","Vertical Split":"垂直分割"},Zr=Object.assign({},Gr);const Kr={ar:{},cs:{},da:{},de:{},en:Yr,"en-gb":{"Editing Toolbar Append Method":"Editing Toolbar Append Method","Choose where Editing Toolbar will append upon regeneration. To see the change, hit the refresh button below, or in the status bar menu.":"Choose where Editing Toolbar will append upon regeneration. To see the change, hit the refresh button below, or in the status bar menu.","Editing Toolbar aesthetic":"Editing Toolbar aesthetic","Choose between a glass morphism, tiny and default style for Editing Toolbar. To see the change, hit the refresh button below, or in the status bar menu.":"Choose between a glass morphism, tiny and default style for Editing Toolbar. To see the change, hit the refresh button below, or in the status bar menu.","Editing Toolbar position":"Editing Toolbar position","Choose between fixed position or cursor following mode.":"Choose between fixed position, cursor following or Top mode.","Editing Toolbar Columns":"Editing Toolbar Columns","Choose the number of columns per row to display on Editing Toolbar.":"Choose the number of columns per row to display on Editing Toolbar.","Editing Toolbar refresh":"Editing Toolbar refresh","Editing Toolbar Commands":"Editing Toolbar Commands","Add a command onto Editing Toolbar from Obsidian's commands library. To reorder the commands, drag and drop the command items. To delete them, use the delete buttom to the right of the command item. Editing Toolbar will not automaticaly refresh after reordering commands. Use the refresh button above.":"Add a command onto Editing Toolbar from Obsidian's commands library. To reorder the commands, drag and drop the command items. To delete them, use the delete buttom to the right of the command item. Editing Toolbar will not automaticaly refresh after reordering commands. Use the refresh button above.","Format Brush Off!":"Format Brush Off!","Hide & Show":"Hide & Show","Editing Toolbar will only refresh automatically after you have either added or deleted a command from it. To see UI changes to editingToolbar (above settings changes) use the refresh button. If you forget to refresh in settings, no worries. There is also a refresh button in the editingToolbar status bar menu.":"Editing Toolbar will only refresh automatically after you have either added or deleted a command from it. To see UI changes to editingToolbar (above settings changes) use the refresh button. If you forget to refresh in settings, no worries. There is also a refresh button in the editingToolbar status bar menu.","Font-Color formatting brush ON!":"Font-Colour formatting brush ON!",More:"More","Font Colors":"Font Colours","Format Brush":"Format Brush","Background color":"Background colour",Refresh:"Refresh",Add:"Add",Delete:"Delete","Change Command Name":"Change Command Name","Add Submenu":"Add Submenu","Add Separator":"Add Separator","Enter the icon code, it looks like .... format":"Enter the icon code, it looks like .... format","Please enter a new name: ":"Please enter a new name: ","Drag the slider to move the position":"Drag the slider to move the position","Plugin Settings":"Plugin Settings","Background-color formatting brush ON!":"Background-colour formatting brush ON!\nClick the mouse middle or right key to close the formatting-brush","Clear formatting brush ON!":"Clear formatting brush ON!","Clear formatting brush ON!\nClick the mouse middle or right key to close the formatting-brush":"Clear formatting brush ON!\nClick the mouse middle or right key to close the formatting-brush","The toolbar is displayed when the mouse moves over it, otherwise it is automatically hidden":"The toolbar is displayed when the mouse moves over it, otherwise it is automatically hidden","Editing Toolbar Auto-hide":"Editing Toolbar Auto-hide","Editing Toolbar Centred Display":"Editing Toolbar Centred Display","Whether the toolbar is centred or full-width, the default is full-width.":"Whether the toolbar is centred or full-width, the default is full-width.","Custom Backgroud Color":"Custom Backgroud Colour","Custom Font Color":"Custom Font Colour","🎨 Set Custom Background":"🎨 Set Custom Background","🖌️ Set Custom Font Color":"🖌️ Set Custom Font Colour","Click on the picker to adjust the color":"Click on the picker to adjust the colour","Mobile Enabled or Not":"Mobile Enabled or Not","Whether to enable the plugin for the mobile client, the default is enabled.":"Whether to enable the plugin for the mobile client, the default is enabled.","Whether to enable on mobile devices with device width less than 768px.":"Whether to enable on mobile devices with device width less than 768px, the default is disable.",Reset:"Reset",Fix:"Fix","Fix Editing Toolbar":"Fix Editing Toolbar",General:"General",Appearance:"Appearance",Commands:"Commands","Choose between fixed position or cursor following mode":"Choose between fixed position, cursor following or Top mode.","Add and manage commands":"Add and manage commands","Choose where Editing Toolbar will append upon regeneration.":"Choose where Editing Toolbar will append upon regeneration.","Whether to enable on mobile devices with device width less than 768px":"Whether to enable on mobile devices with device width less than 768px","Choose between a glass morphism, tiny and default style.":"Choose between a glass morphism, tiny and default style.","Refresh Toolbar":"Refresh Toolbar","Add Command":"Add Command",Settings:"Settings","Position Style":"Position Style",Columns:"Columns","Drag to Adjust Position":"Drag to Adjust Position","Vertical Position":"Vertical Position","Horizontal Position":"Horizontal Position","Toolbar Position":"Toolbar Position","Choose an icon":"Choose an icon","Search for an icon...":"Search for an icon...",All:"All",Obsidian:"Obsidian",Glyph:"Glyph",Custom:"Custom","Choose a command":"Choose a command","The command":"The command","already exists":"already exists","Enter the icon code, format as .... ":"Enter the icon code, format as .... ","No matching icons found":"No matching icons found","Custom Commands":"Custom Commands","Toolbar Commands":"Toolbar Commands",ID:"ID",Prefix:"Prefix",Suffix:"Suffix",Pattern:"Pattern","Custom Format Commands":"Custom Format Commands","Add, edit or delete custom format commands.":"Add, edit or delete custom format commands.",Edit:"Edit","Command ID":"Command ID",'Unique identifier, no spaces, e.g.: "my-custom-format"':'Unique identifier, no spaces, e.g.: "my-custom-format"',"Displayed name in toolbar and menu":"Displayed name in toolbar and menu","Add content before selected text":"Add content before selected text","Add content after selected text":"Add content after selected text","Character offset of cursor after formatting":"Character offset of cursor after formatting","Line offset of cursor after formatting":"Line offset of cursor after formatting","Whether to insert at the beginning of the next line":"Whether to insert at the beginning of the next line","Command icon (click to select)":"Command icon (click to select)","Choose Icon":"Choose Icon",Save:"Save",Cancel:"Cancel","Edit Custom Command":"Edit Custom Command","Add Custom Command":"Add Custom Command","Command ID and command name cannot be empty":"Command ID and command name cannot be empty","Command ID cannot contain spaces":"Command ID cannot contain spaces",'Command ID "${this.commandId}" already exists':'Command ID "${this.commandId}" already exists',"Cursor Position Offset":"Cursor Position Offset","Line Offset":"Line Offset","Line Head Format":"Line Head Format",Icon:"Icon","Command Name":"Command Name","Are you sure you want to restore all settings to default? This will lose all your custom configurations.":"Are you sure you want to restore all settings to default? This will lose all your custom configurations.","Restore default":"Restore default","Restore default settings":"Restore default settings","🔄Restore default settings":"🔄Restore default settings","🔧Data repair":"🔧Data repair","Command IDs have been successfully repaired!":"Command IDs have been successfully repaired!","No command IDs need to be repaired":"No command IDs need to be repaired","Error repairing command IDs, please check the console for details":"Error repairing command IDs, please check the console for details","Error restoring default settings, please check the console for details":"Error restoring default settings, please check the console for details","Successfully restored default settings!":"Successfully restored default settings!",Close:"Close",Tips:"Tips","This update changed the ID of some commands, please click this button to repair the commands to ensure the toolbar works properly":"This update changed the ID of some commands, please click this button to repair the commands to ensure the toolbar works properly","Repair command ID":"Repair command ID","This will reset all your custom configurations":"This will reset all your custom configurations","Notice:":"Notice:","This update rebuilds the entire code, reducing resource consumption":"This update rebuilds the entire code, reducing resource consumption","Optimized mobile usage, added canvas support, and added custom commands":"Optimized mobile usage, added canvas support, and added custom commands","⚠️This update is not compatible with 2.x version command ids, please click [Repair command] to be compatible":"⚠️This update is not compatible with 2.x version command ids, please click [Repair command] to be compatible","⚠️If you want to restore the default settings, please click [Restore default settings]":"⚠️If you want to restore the default settings, please click [Restore default settings]","Please execute a editingToolbar format command first, then enable the format brush":"Please execute a editingToolbar format command first, then enable the format brush","Format brush ON! Select text to apply【":"Format brush ON! Select text to apply【","】format":"】format\nClick the mouse middle or right key to close the formatting-brush","Add to Toolbar":"Add to Toolbar","This command is already in the toolbar.":"This command is already in the toolbar.","Command added to toolbar":"Command added to toolbar","Add this command to the toolbar.":"Add this command to the toolbar.","Callout Type":"Callout Type",Title:"Title","Optional, leave blank for default title":"Optional, leave blank for default title","Input title":"Input title","Collapse State":"Collapse State",Open:"Open",Closed:"Closed",Content:"Content",Insert:"Insert",Default:"Default","Input content":"Input content","Link Text":"Link Text","Link Alias":"Link Alias","Link URL":"Link URL","Embed Content":"Embed Content","Image Size":"Image Size","Insert New Line":"Insert New Line","Paste and Parse":"Paste and Parse","URL Format Error":"URL Format Error","Image Width":"Image Width","Image Height":"Image Height","If it is an image, turn on":"If it is an image, turn on","Insert a link on the next line":"Insert a link on the next line","Link Title(optional)":"Link Title(optional)",Alias:"Alias",Optional:"Optional","Default 0, format will keep the text selected":"Default 0, format will keep the text selected","to insert":"to insert","Latest Changes":"Latest Changes","📋View full changelog":"📋View full changelog","Open changelog":"Open changelog","Loading changelog...":"Loading changelog...","Open the complete changelog in your browser":"Open the complete changelog in your browser","Enable Multiple Configurations":"Enable Multiple Configurations","Enable different command configurations for each position style (following, top, fixed).":"Enable different command configurations for each position style (following, top, fixed).","Currently editing commands for":"Currently editing commands for","position style":"position style","Current Configuration":"Current Configuration","Switch between different command configurations.":"Switch between different command configurations.","Following Style":"Following Style","Top Style":"Top Style","Fixed Style":"Fixed Style","Mobile Style":"Mobile Style",configuration:"configuration","Deploy command to configurations":"Deploy command to configurations","All Configurations":"All Configurations",Deploy:"Deploy","Command deployed to selected configurations":"Command deployed to selected configurations","No configuration selected for deployment":"No configuration selected for deployment","Command already exists in selected configurations":"Command already exists in selected configurations","Command deployed to: ":"Command deployed to: ","Command Deleted.":"Command Deleted.","Confirm Delete?":"Confirm Delete?",Confirm:"Confirm","Are you sure you want to restore all settings to default? But custom commands will be preserved.":"Are you sure you want to restore all settings to default? But custom commands will be preserved.","Successfully restored default settings! (Custom commands preserved)":"Successfully restored default settings! (Custom commands preserved)","This will reset all your custom configurations, but custom commands will be preserved":"This will reset all your custom configurations, but custom commands will be preserved","Import/Export":"Import/Export","Export Configuration":"Export Configuration","Export your toolbar configuration to share with others.":"Export your toolbar configuration to share with others.",Export:"Export","Import Configuration":"Import Configuration","Import toolbar configuration from JSON.":"Import toolbar configuration from JSON.",Import:"Import","Usage Instructions":"Usage Instructions","Export: Generate a JSON configuration that you can save or share.":"Export: Generate a JSON configuration that you can save or share.","Import: Paste a previously exported JSON configuration.":"Import: Paste a previously exported JSON configuration.","You can choose to export all settings, only toolbar commands, or only custom commands":"You can choose to export all settings, only toolbar commands, or only custom commands","When importing, the plugin will only update the settings included in the import data":"When importing, the plugin will only update the settings included in the import data","Warning: Importing configuration will overwrite your current settings. Consider exporting your current configuration first as a backup.":"Warning: Importing configuration will overwrite your current settings. Consider exporting your current configuration first as a backup.","Export Type":"Export Type","Choose what to export":"Choose what to export","All Settings":"All Settings","Toolbar Commands Only":"Toolbar Commands Only","Custom Commands Only":"Custom Commands Only","Export Content":"Export Content","Copy this content to share with others":"Copy this content to share with others","Loading...":"Loading...","Copy to Clipboard":"Copy to Clipboard","Configuration copied to clipboard":"Configuration copied to clipboard","Failed to copy configuration":"Failed to copy configuration","Paste the configuration JSON here":"Paste the configuration JSON here","Paste configuration here...":"Paste configuration here...","Invalid import data":"Invalid import data","Configuration imported successfully":"Configuration imported successfully","No valid configuration found in import data":"No valid configuration found in import data","Failed to import configuration. Invalid format.":"Failed to import configuration. Invalid format.","Import Mode":"Import Mode","Choose how to import the configuration":"Choose how to import the configuration","Update Mode (Add new items and update existing ones)":"Update Mode (Add new items and update existing ones)","Overwrite Mode (Replace all settings with imported ones)":"Overwrite Mode (Replace all settings with imported ones)","Configuration imported successfully (Overwrite mode)":"Configuration imported successfully (Overwrite mode)","Configuration imported successfully (Update mode)":"Configuration imported successfully (Update mode)","Warning: Overwrite mode will completely replace your current settings with the imported ones. Consider exporting your current configuration first as a backup.":"Warning: Overwrite mode will completely replace your current settings with the imported ones. Consider exporting your current configuration first as a backup.","Warning: Update mode will add new items and update existing ones based on the imported configuration.":"Warning: Update mode will add new items and update existing ones based on the imported configuration.","Add Format Command":"Add Format Command",Regex:"Regex","Prefix/Suffix":"Prefix/Suffix","Insert Special Char":"Insert Special Char","Add Regex Command":"Add Regex Command","Switch Regex Command Window":"Switch Regex Command Window","Please select text first":"Please select text first","The selected text does not meet the condition requirements":"The selected text does not meet the condition requirements","Regex command execution error: ":"Regex command execution error: ","Copy code":"Copy code","Copied!":"Copied!","Explain the syntax of JavaScript regular expressions":"Explain the syntax of JavaScript regular expressions","Apply regular expression replacement":"Apply regular expression replacement","Conditional matching":"Conditional matching","Complete regular expression code (copy to AI for explanation)":"Complete regular expression code (copy to AI for explanation)","Error: ":"Error: ","Regex pattern cannot be empty":"Regex pattern cannot be empty","Command already exists":"Command already exists","Choose icon":"Choose icon","URL to Markdown link":"URL to Markdown link","Convert MM/DD/YYYY to YYYY-MM-DD":"Convert MM/DD/YYYY to YYYY-MM-DD","Add bold to keywords":"Add bold to keywords","Format phone number":"Format phone number","Remove extra spaces":"Remove extra spaces","Convert HTML bold tags to Markdown format":"Convert HTML bold tags to Markdown format","Convert quoted text to quote block":"Convert quoted text to quote block","Convert CSV to Markdown table row":"Convert CSV to Markdown table row","Add uniform alias to Markdown links":"Add uniform alias to Markdown links","Delete empty lines (multiline mode)":"Delete empty lines (multiline mode)","Add list symbol to each line (multiline mode)":"Add list symbol to each line (multiline mode)","If the text contains important, set the text highlight (conditional format)":"If the text contains important, set the text highlight (conditional format)","Matching pattern":"Matching pattern","Regex pattern to match":"Regex pattern to match","Replacement pattern (use $1, $2, etc. to reference capture groups)":"Replacement pattern (use $1, $2, etc. to reference capture groups)","Ignore case":"Ignore case","Global replace":"Global replace","Multiline mode":"Multiline mode","Use condition":"Use condition","Condition pattern":"Condition pattern","Only apply custom command when text matches the condition":"Only apply custom command when text matches the condition","Must exist regular expression or text":"Must exist regular expression or text","Replacement pattern":"Replacement pattern","Match case-insensitive":"Match case-insensitive","^ and $ match the start and end of each line":"^ and $ match the start and end of each line","Replace all matches":"Replace all matches",Command:"Command","Input example text to view the formatting effect of the command...":"Input example text to view the formatting effect of the command...",Description:"Description","[Example]":"[Example]","[Requirements]":"[Requirements]","[Output]":"[Output]","AI question template:":"AI question template:","I need to convert the url to a markdown format link":"I need to convert the url to a markdown format link","For example, convert https://example.com to [https://example.com](https://example.com)":"For example, convert https://example.com to [https://example.com](https://example.com)","Use js regular expression to implement, and output the parameters in the following format (the result does not need to be escaped with json)":"Use js regular expression to implement, and output the parameters in the following format (the result does not need to be escaped with json)","[Description]":"[Description]","How to use AI to get regular expressions?":"How to use AI to get regular expressions?","Regular expression examples":"Regular expression examples","Edit regular expression command":"Edit regular expression command","Add regular expression command":"Add regular expression command","Result: ":"Result: ","Example text:":"Example text:",Preview:"Preview",Result:"Result","Please select text or copy text to clipboard first":"Please select text or copy text to clipboard first","Overwrite Import":"Overwrite Import","Update Import":"Update Import","Importing configuration...":"Importing configuration...","Following Style Only":"Following Style Only","Top Style Only":"Top Style Only","Fixed Style Only":"Fixed Style Only","Mobile Style Only":"Mobile Style Only","Unknown import type":"Unknown import type","All Toolbar Commands":"All Toolbar Commands","Initialize Commands":"Initialize Commands","Copy commands from the main menu configuration":"Copy commands from the main menu configuration","Initialize commands to default settings":"Initialize commands to default settings","Reset Commands":"Reset Commands","Commands reset successfully":"Commands reset successfully","Following style commands initialized from current menu commands":"Following style commands initialized from current menu commands","Commands initialized successfully":"Commands initialized successfully","Reset to Menu Commands":"Reset to Menu Commands","Are you sure you want to reset the current configuration?":"Are you sure you want to reset the current configuration?","Following style commands successfully initialized":"Following style commands successfully initialized","Top style commands successfully initialized":"Top style commands successfully initialized","Fixed style commands successfully initialized":"Fixed style commands successfully initialized","Mobile style commands successfully initialized":"Mobile style commands successfully initialized","Reset commands to default settings":"Reset commands to default settings",Clear:"Clear","Remove all commands from this configuration.":"Remove all commands from this configuration.","Are you sure you want to clear all commands under the current style?":"Are you sure you want to clear all commands under the current style?","Current style commands have been cleared":"Current style commands have been cleared","Manage Commands":"Manage Commands","Reset or clear all commands in this configuration":"Reset or clear all commands in this configuration","One-click Clear":"One-click Clear","Import Commands from Other Styles":"Import Commands from Other Styles","Copy commands from another style configuration.":"Copy commands from another style configuration.","Main menu only":"Main menu only","This import will update:":"This import will update:","Custom commands":"Custom commands","Toolbar commands":"Toolbar commands","General settings":"General settings","Please paste configuration data first":"Please paste configuration data first","Invalid import data format":"Invalid import data format","Import From":"Import From","This import will:":"This import will:","Update general settings":"Update general settings","Update Main Menu Commands":"Update Main Menu Commands","Update Custom Commands":"Update Custom Commands","Update Following Style Commands":"Update Following Style Commands","Update Top Style Commands":"Update Top Style Commands","Update Fixed Style Commands":"Update Fixed Style Commands","Update Mobile Style Commands":"Update Mobile Style Commands","Clear all Main Menu Commands":"Clear all Main Menu Commands","Clear all Custom Commands":"Clear all Custom Commands","Clear all Following Style Commands":"Clear all Following Style Commands","Clear all Top Style Commands":"Clear all Top Style Commands","Clear all Fixed Style Commands":"Clear all Fixed Style Commands","Clear all Mobile Style Commands":"Clear all Mobile Style Commands","Overwrite Mode (Replace settings with imported ones)":"Overwrite Mode (Replace settings with imported ones)","Warning: Overwrite mode will replace existing settings with imported ones.":"Warning: Overwrite mode will replace existing settings with imported ones.","Warning: Update mode will add new items and update existing ones.":"Warning: Update mode will add new items and update existing ones.","Enable Multiple Config":"Enable Multiple Config","Set Multiple Config to:":"Set Multiple Config to:",Enable:"Enable",Disable:"Disable","Set Position Style to:":"Set Position Style to:",Following:"Following",Top:"Top",Fixed:"Fixed",Mobile:"Mobile","All commands":"All commands","⚠️ Overwrite mode will replace existing settings with imported ones.":"⚠️ Overwrite mode will replace existing settings with imported ones.","ℹ️ Update mode will merge imported settings with existing ones.":"ℹ️ Update mode will merge imported settings with existing ones.","Do you want to continue?":"Do you want to continue?","Imported settings:":"Imported settings:","Imported commands:":"Imported commands:","Disable toolbar for this view":"Disable toolbar for this view","Enable toolbar for this view":"Enable toolbar for this view","Manage all view types":"Manage all view types","Current View: ":"Current View: ","Appearance Style":"Appearance Style","Position Settings":"Position Settings","All commands have been removed.":"All commands have been removed.","Join the Community":"Join the Community","Share your toolbar settings and styles in our":"Share your toolbar settings and styles in our","Get inspired by what others have created or showcase your own customizations.":"Get inspired by what others have created or showcase your own customisations.","Toolbar Preview (With a hypothetical command configuration.)":"Toolbar Preview (With a hypothetical command configuration.)","Toolbar Theme":"Toolbar Theme","Select a preset toolbar theme, automatically setting the background color, icon color, and size for the selected style.":"Select a preset toolbar theme, automatically setting the background colour, icon colour, and size for the selected style.","Toolbar Background Color":"Toolbar Background Colour","Set the background color of the toolbar.":"Set the background colour of the toolbar.","Toolbar Icon Color":"Toolbar Icon Colour","Set the color of the toolbar icon.":"Set the colour of the toolbar icon.","Toolbar Icon Size":"Toolbar Icon Size","Set the size of the toolbar icon (px); default: 18px":"Set the size of the toolbar icon (px); default: 18px","Custom Theme":"Custom Theme","Fixed Position Offset":"Fixed Position Offset","Choose the offset of the Editing Toolbar in the fixed position.":"Choose the offset of the Editing Toolbar in the fixed position.","Renumber List":"Renumber List","Fetch Remote Title":"Fetch Remote Title","Please enter a URL first":"Please enter a URL first","Failed to fetch title for":"Failed to fetch title for","Link Title (optional)":"Link Title (optional)","Unable to detect editor width":"Unable to detect editor width","Fit Editor Width":"Fit Editor Width","Please execute a format command or select format text first, then enable the format brush":"Please execute a format command or select format text first, then enable the format brush","Use \\n to represent line breaks":"Use \\n to represent line breaks","Use ↵ to represent line breaks":"Use ↵ to represent line breaks","Top Toolbar":"Top Toolbar","Enable the toolbar positioned at the top.":"Enable the toolbar positioned at the top.","Following Toolbar":"Following Toolbar","Enable the toolbar that appears upon text selection.":"Enable the toolbar that appears upon text selection.","Fixed Toolbar":"Fixed Toolbar","Enable the toolbar whose position may be fixed where you please.":"Enable the toolbar whose position may be fixed where you please.","Toolbar Settings":"Toolbar Settings","Choose which toolbar style's appearance you want to edit.":"Choose which toolbar style's appearance you want to edit.","Vertical Split":"Vertical Split"},es:{},fr:{},hi:{},id:{},it:{},ja:{},ko:{},nl:{},nn:{},pl:{},pt:{},"pt-br":{},ro:{},ru:{},tr:{},"zh-cn":Gr,"zh-tw":Zr}[t.moment.locale()];function Jr(t){return Kr&&Kr[t]||Yr[t]}class Xr extends t.FuzzySuggestModal{constructor(t,e,i=!1,o,n){super(t.app),this.customCallback=null,this.plugin=t,this.command=e,this.issub=i,this.customCallback=o||null,this.setPlaceholder(Jr("Choose an icon")),this.currentEditingConfig=n||""}capitalJoin(t){return t.split(" ").map(t=>t[0].toUpperCase()+t.substring(1)).join(" ")}getItems(){return i}getItemText(t){return this.capitalJoin(t.replace("feather-","").replace("remix-","").replace("bx-","").replace(/([A-Z])/g," $1").trim().replace(/-/gi," "))}renderSuggestion(e,i){const o=createSpan({cls:"editingToolbarIconPick"});i.appendChild(o),t.setIcon(o,e.item),super.renderSuggestion(e,i)}onChooseItem(t){return e(this,void 0,void 0,function*(){if("Custom"===t)return this.customCallback?void new Qr(this.app,this.plugin,{id:this.command.id,name:this.command.name,icon:""},this.issub,t=>{this.customCallback(t)}).open():void new Qr(this.app,this.plugin,this.command,this.issub,null,this.currentEditingConfig).open();if(this.customCallback)return void this.customCallback(t);const e=this.plugin.getCurrentCommands(this.currentEditingConfig);if(this.command.icon){let i=Rr(this.plugin,this.command,this.issub,e);this.issub?e[i.index].SubmenuCommands[i.subindex].icon=t:e[i.index].icon=t,this.plugin.updateCurrentCommands(e)}else this.command.icon=t,e.push(this.command),this.plugin.updateCurrentCommands(e);yield this.plugin.saveSettings(),setTimeout(()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))},100),console.log(`%c命令 '${this.command.name}' 已添加到编辑工具栏`,"color: Violet")})}}class Qr extends t.Modal{constructor(t,e,i,o,n,s){super(t),this.customCallback=null,this.plugin=e,this.item=i,this.issub=o,this.customCallback=n||null,this.currentEditingConfig=s||"",this.containerEl.addClass("editingToolbar-Modal"),this.containerEl.addClass("customicon")}onOpen(){const{contentEl:t}=this;t.createEl("b",{text:Jr("Enter the icon code, format as .... ")});const i=document.createElement("textarea");i.className="wideInputPromptInputEl",i.placeholder="",i.value=this.item.icon||"",i.style.width="100%",i.style.height="200px",t.appendChild(i),i.addEventListener("input",()=>e(this,void 0,void 0,function*(){const t=i.value;if(this.customCallback)return void(this.item.icon=t);this.item.icon=t;const e=this.plugin.getCurrentCommands(this.currentEditingConfig),o=Rr(this.plugin,this.item,this.issub,e);if(this.issub){let e=o.subindex;-1===e?this.plugin.settings.menuCommands[o.index].SubmenuCommands.push(this.item):this.plugin.settings.menuCommands[o.index].SubmenuCommands[e].icon=t}else{let t=o.index;-1===t?this.plugin.settings.menuCommands.push(this.item):this.plugin.settings.menuCommands[t].icon=this.item.icon}yield this.plugin.saveSettings()})),this.submitEnterCallback&&i.addEventListener("keydown",this.submitEnterCallback)}onClose(){const{contentEl:t}=this;t.empty(),this.customCallback?this.customCallback(this.item.icon||""):setTimeout(()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))},100)}}class ta extends t.FuzzySuggestModal{constructor(t,e){super(t.app),this.plugin=t,this.app,this.setPlaceholder(Jr("Choose a command")),this.currentEditingConfig=e||""}getItems(){return app.commands.listCommands()}getItemText(t){return t.name}onChooseItem(i){return e(this,void 0,void 0,function*(){const e=this.plugin.getCurrentCommands(this.currentEditingConfig);e.findIndex(t=>t.id==i.id)>-1?new t.Notice(Jr("The command")+i.name+Jr("already exists"),3e3):i.icon?(e.push(i),this.plugin.updateCurrentCommands(e),yield this.plugin.saveSettings(),setTimeout(()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))},100),console.log(`%c命令 '${i.name}' 已添加到编辑工具栏`,"color: Violet")):new Xr(this.plugin,i,!1).open()})}}class ea extends t.Modal{constructor(t,e,i,o,n){super(e.app),this.plugin=e,this.item=i,this.issub=o,this.currentEditingConfig=n||"",this.containerEl.addClass("editingToolbar-Modal"),this.containerEl.addClass("changename")}onOpen(){var i;const{contentEl:o}=this;o.createEl("b",{text:Jr("Please enter a new name: ")});const n=new t.TextComponent(o);n.inputEl.classList.add("InputPromptInputEl"),n.setPlaceholder("").setValue(null!==(i=this.item.name)&&void 0!==i?i:"").onChange(t.debounce(t=>e(this,void 0,void 0,function*(){const e=this.plugin.getCurrentCommands(this.currentEditingConfig);let i=Rr(this.plugin,this.item,this.issub,e);if(this.item.name=t,this.issub){let o=i.subindex;-1===o?e[i.index].SubmenuCommands.push(this.item):e[i.index].SubmenuCommands[o].name=t}else{let t=i.index;-1===t?e.push(this.item):e[t].name=this.item.name}this.plugin.updateCurrentCommands(e),yield this.plugin.saveSettings()}),100,!0)).inputEl.addEventListener("keydown",this.submitEnterCallback)}onClose(){const{contentEl:t}=this;t.empty(),setTimeout(()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))},100)}}class ia extends t.Modal{constructor(t,e){super(e.app),this.needSave=!1,this.plugin=e,this.containerEl.addClass("editingToolbar-Modal")}onOpen(){const{contentEl:i}=this;i.createEl("p",{text:Jr("Drag the slider to move the position")});const o=i.createDiv({cls:"slider-container"}),n=o.createDiv({cls:"vertical-slider-container"});n.createEl("p",{text:Jr("Vertical Position")});const s=o.createDiv({cls:"horizontal-slider-container"});s.createEl("p",{text:Jr("Horizontal Position")});const r=o.createDiv({cls:"columns-slider-container"});r.createEl("p",{text:Jr("Editing Toolbar Columns")});const a=document.body.clientHeight,l=document.body.clientWidth,c=Math.floor(a/3),h=-Math.floor(a),d=Math.floor(l/2),u=-Math.floor(l/2),p=new t.SliderComponent(n).setLimits(h,c,5).setValue(this.plugin.settings.verticalPosition||0).onChange(t.debounce(t=>{this.needSave=!0,this.plugin.settings.verticalPosition=t,Ur(this.plugin.settings)},100,!0)).setDynamicTooltip(),m=new t.SliderComponent(s).setLimits(u,d,10).setValue(this.plugin.settings.horizontalPosition||0).onChange(t.debounce(t=>{this.needSave=!0,this.plugin.settings.horizontalPosition=t,jr(this.plugin.settings)},100,!0)).setDynamicTooltip(),g=new t.SliderComponent(r).setLimits(1,32,1).setValue(this.plugin.settings.cMenuNumRows||12).onChange(t.debounce(t=>e(this,void 0,void 0,function*(){this.needSave=!0,this.plugin.settings.cMenuNumRows=t,yield this.plugin.saveSettings(),setTimeout(()=>{dispatchEvent(new Event("editingToolbar-NewCommand"))},100)}),100,!0)).setDynamicTooltip();o.createDiv({cls:"reset-container"}).createEl("button",{text:Jr("Reset"),cls:"reset-button"}).addEventListener("click",()=>{this.needSave=!0,p.setValue(0),m.setValue(0),g.setValue(12),this.plugin.settings.verticalPosition=0,this.plugin.settings.horizontalPosition=0,this.plugin.settings.cMenuNumRows=12,Ur(this.plugin.settings),jr(this.plugin.settings)})}onClose(){return e(this,void 0,void 0,function*(){const{contentEl:t}=this;t.empty(),this.needSave&&(yield this.plugin.saveSettings())})}}const oa=["body","workspace"],na=["default","tiny","glass","custom"],sa=["following","top","fixed"],ra={lastVersion:"0.0.0",aestheticStyle:"default",positionStyle:"top",menuCommands:[{id:"editing-toolbar:editor-undo",name:"Undo Edit",icon:"undo-glyph"},{id:"editing-toolbar:editor-redo",name:"Redo Edit",icon:"redo-glyph"},{id:"editing-toolbar:toggle-format-brush",name:"Format Brush",icon:"paintbrush"},{id:"editing-toolbar:format-eraser",name:"Clear Text Formatting",icon:"eraser"},{id:"editing-toolbar:header2-text",name:"Header 2",icon:"header-2"},{id:"editing-toolbar:header3-text",name:"Header 3",icon:"header-3"},{id:"SubmenuCommands-header",name:"submenu",icon:"header-n",SubmenuCommands:[{id:"editing-toolbar:header1-text",name:"Header 1",icon:"header-1"},{id:"editing-toolbar:header4-text",name:"Header 4",icon:"header-4"},{id:"editing-toolbar:header5-text",name:"Header 5",icon:"header-5"},{id:"editing-toolbar:header6-text",name:"Header 6",icon:"header-6"}]},{id:"editing-toolbar:toggle-bold",name:"Bold",icon:"bold-glyph"},{id:"editing-toolbar:toggle-italics",name:"Italic",icon:"italic-glyph"},{id:"editing-toolbar:toggle-strikethrough",name:"Strikethrough",icon:"strikethrough-glyph"},{id:"editing-toolbar:underline",name:"Underline",icon:"underline-glyph"},{id:"editing-toolbar:toggle-highlight",name:"Highlight",icon:"highlight-glyph"},{id:"SubmenuCommands-lucdf3en5",name:"submenu",icon:"edit",SubmenuCommands:[{id:"editing-toolbar:editor-cut",name:"Cut",icon:"lucide-scissors"},{id:"editing-toolbar:editor-copy",name:"Copy",icon:"lucide-copy"},{id:"editing-toolbar:editor-paste",name:"Paste",icon:"lucide-clipboard-type"},{id:"editing-toolbar:editor:swap-line-down",name:"Swap Line Down",icon:"lucide-corner-right-down"},{id:"editing-toolbar:editor:swap-line-up",name:"Swap Line Up",icon:"lucide-corner-right-up"}]},{id:"editing-toolbar:editor:attach-file",name:"Attach File",icon:"lucide-paperclip"},{id:"editing-toolbar:editor:insert-table",name:"Insert Table",icon:"lucide-table"},{id:"editing-toolbar:editor:cycle-list-checklist",name:"Cycle List and Checklist",icon:"check-circle"},{id:"SubmenuCommands-luc8efull",name:"submenu",icon:"message-square",SubmenuCommands:[{id:"editing-toolbar:editor:toggle-blockquote",name:"Blockquote",icon:"lucide-text-quote"},{id:"editing-toolbar:insert-callout",name:"Callout",icon:"lucide-quote"}]},{id:"SubmenuCommands-mdcmder",name:"submenu",icon:'',SubmenuCommands:[{id:"editing-toolbar:superscript",name:"Superscript",icon:"superscript-glyph"},{id:"editing-toolbar:subscript",name:"Subscript",icon:"subscript-glyph"},{id:"editing-toolbar:editor:toggle-code",name:"Inline Code",icon:"code-glyph"},{id:"editing-toolbar:codeblock",name:"Code Block",icon:"codeblock-glyph"},{id:"editing-toolbar:editor:insert-wikilink",name:"Wikilink",icon:''},{id:"editing-toolbar:editor:insert-embed",name:"Embed",icon:"note-glyph"},{id:"editing-toolbar:insert-link",name:"Link",icon:"link-glyph"},{id:"editing-toolbar:hrline",name:"Horizontal Divider",icon:''},{id:"editing-toolbar:toggle-inline-math",name:"Inline Math",icon:"lucide-sigma"},{id:"editing-toolbar:editor:insert-mathblock",name:"MathBlock",icon:"lucide-sigma-square"}]},{id:"SubmenuCommands-list",name:"submenu-list",icon:"bullet-list-glyph",SubmenuCommands:[{id:"editing-toolbar:editor:toggle-checklist-status",name:"Checklist",icon:"checkbox-glyph"},{id:"editing-toolbar:renumber-ordered-list",name:"Renumber Ordered List",icon:"list-restart"},{id:"editing-toolbar:toggle-numbered-list",name:"Ordered List",icon:''},{id:"editing-toolbar:toggle-bullet-list",name:"Unordered List",icon:''},{id:"editing-toolbar:undent-list",name:"Unindent List",icon:''},{id:"editing-toolbar:indent-list",name:"Indent list",icon:''}]},{id:"SubmenuCommands-aligin",name:"submenu-aligin",icon:'',SubmenuCommands:[{id:"editing-toolbar:justify",name:"Justify Text",icon:''},{id:"editing-toolbar:left",name:"Align Text Left",icon:''},{id:"editing-toolbar:center",name:"Center Text",icon:''},{id:"editing-toolbar:right",name:"Align Text Right",icon:''}]},{id:"editing-toolbar:change-font-color",name:"Change Font Color",icon:''},{id:"editing-toolbar:change-background-color",name:"Change Background Color",icon:''},{id:"editing-toolbar:fullscreen-focus",name:"Fullscreen Focus Mode",icon:"fullscreen"},{id:"editing-toolbar:workplace-fullscreen-focus",name:"Workplace Fullscreen",icon:"exit-fullscreen"}],followingCommands:[],topCommands:[],fixedCommands:[],mobileCommands:[],enableMultipleConfig:!1,enableTopToolbar:!1,enableFollowingToolbar:!1,enableFixedToolbar:!1,appendMethod:"workspace",shouldShowMenuOnSelect:!1,cMenuVisibility:!0,cMenuBottomValue:4.25,cMenuNumRows:12,cMenuWidth:610,cMenuFontColor:"#2DC26B",cMenuBackgroundColor:"#d3f8b6",autohide:!1,Iscentered:!1,custom_bg1:"#FFB78B8C",custom_bg2:"#CDF4698C",custom_bg3:"#A0CCF68C",custom_bg4:"#F0A7D88C",custom_bg5:"#ADEFEF8C",custom_fc1:"#D83931",custom_fc2:"#DE7802",custom_fc3:"#245BDB",custom_fc4:"#6425D0",custom_fc5:"#646A73",isLoadOnMobile:!1,horizontalPosition:0,verticalPosition:0,formatBrushes:{},customCommands:[],viewTypeSettings:{},appearanceByStyle:{top:{toolbarBackgroundColor:"rgba(var(--background-secondary-rgb), 0.7)",toolbarIconColor:"var(--text-normal)",toolbarIconSize:18,aestheticStyle:"default"},following:{toolbarBackgroundColor:"rgba(var(--background-secondary-rgb), 0.7)",toolbarIconColor:"var(--text-normal)",toolbarIconSize:18,aestheticStyle:"default"},fixed:{toolbarBackgroundColor:"rgba(var(--background-secondary-rgb), 0.7)",toolbarIconColor:"var(--text-normal)",toolbarIconSize:18,aestheticStyle:"default"},mobile:{toolbarBackgroundColor:"rgba(var(--background-secondary-rgb), 0.7)",toolbarIconColor:"var(--text-normal)",toolbarIconSize:18,aestheticStyle:"default"}},toolbarBackgroundColor:"rgba(var(--background-secondary-rgb), 0.7)",toolbarIconColor:"var(--text-normal)",toolbarIconSize:18,useCurrentLineForRegex:!1};class aa{static isAllowedViewType(t,e){var i,o,n,s;if(!t)return!1;const r=t.getViewType(),a=null===(n=null===(o=null===(i=window.app)||void 0===i?void 0:i.plugins)||void 0===o?void 0:o.plugins)||void 0===n?void 0:n["editing-toolbar"];if((null===(s=null==a?void 0:a.settings)||void 0===s?void 0:s.viewTypeSettings)&&void 0!==a.settings.viewTypeSettings[r])return a.settings.viewTypeSettings[r];return(e||["markdown","canvas","thino_view","meld-encrypted-view"]).includes(r)}static isSourceMode(t){var e;return!!t&&"source"===(null===(e=t.getMode)||void 0===e?void 0:e.call(t))}}let la;const ca={markdown:".markdown-source-view",thino_view:".markdown-source-view",canvas:".canvas-wrapper",excalidraw:".view-header",image:".image-container",pdf:".view-content",meld_encrypted_view:".markdown-source-view"};function ha(e){la=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;const i=function(){const e=[];e.push(app.workspace.rootSplit);const i=app.workspace.floatingSplit;return null==i||i.children.forEach(i=>{i instanceof t.WorkspaceWindow&&e.push(i)}),e}(),o=t=>{const e=t.querySelectorAll(".editingToolbarModalBar"),i=t.querySelectorAll(".editingToolbarPopoverBar");e.forEach(t=>{t.firstChild&&t.removeChild(t.firstChild),t.remove()}),i.forEach(t=>{t.firstChild&&t.removeChild(t.firstChild),t.remove()})};o(la),i&&i.forEach(t=>{(null==t?void 0:t.containerEl)&&o(t.containerEl)}),e&&e.clearToolbarCache()}function da(e,i,o){var n,s;la=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;const r=o||i.positionStyle||i.settings.positionStyle||"top";if("top"!==r){const t=i.getCachedToolbar(r);if(t)return t}const a=`.editingToolbarModalBar[data-toolbar-style="${r}"]`;let l=null;return l="top"===r?(null===(s=null===(n=e.workspace.activeLeaf)||void 0===n?void 0:n.view.containerEl)||void 0===s?void 0:s.querySelector(a))||null:la.querySelector(a),l&&"top"!==r&&i.setCachedToolbar(r,l),l||null}const ua=(t,e)=>e.reduce((t,e)=>t&&"undefined"!==t[e]?t[e]:void 0,t);function pa(t,e){return t&&void 0!==t[1][0]?e+t.flat(2).join("+").replace("Mod","Ctrl")+e:e+"–"+e}function ma(t,e,i=!0){let o=t.commands.findCommand(e),n=i?"*":"";if(o){let e=o.hotkeys?[[ua(o.hotkeys,[0,"modifiers"])],[ua(o.hotkeys,[0,"key"])]]:void 0,i=t.hotkeyManager.customKeys[o.id];var s=i?[[ua(i,[0,"modifiers"])],[ua(i,[0,"key"])]]:void 0;return s?pa(s,n):pa(e,"")}return"–"}function ga(t){return/<[^>]+>/g.test(t)}function fa(e,i,o){la=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;const n=i.commandsManager.getActiveEditor();let s=da(e,i),r=null==s?void 0:s.querySelector("#"+o);if(r){let t=r.rows,e=t.length;for(let s=1;s{e.style.fill=t})}else if("x-backgroundcolor-picker-table"==o){i.settings.cMenuBackgroundColor=t,_r(t,n),la.querySelectorAll("#change-background-color-icon").forEach(e=>{e.style.fill=t})}i.saveSettings()}}}}}const ba=function(t){let e=t;if(/^(rgb|RGB)/.test(e)){let t=e.replace(/(?:\(|\)|rgb|RGB)*/g,"").split(","),i="#";for(let e=0;e\s*\[\![\w\s]*\]/m)){let t=i.split("\n"),o=[],n=!1,s=0,r=!1;for(let e=0;e+)\s*\[\!([\w\s]*)\]\s*(.*?)$/);if(!a||r)if(n){let t=i.match(/^(>+)\s*/);if(t&&t[1].length>=s){let t=i.replace(new RegExp(`^>{${s}}\\s*`),"");o.push(t)}else n=!1,o.push(i)}else o.push(i);else s=a[1].length,r=!0,a[3].trim()&&o.push(a[3].trim()),n=!0}return void e.replaceSelection(o.join("\n"))}i=i.replace(/(^#+\s|^#(?=\s)|^\>|^\- \[( |x)\]|^\+ |\<[^\<\>]+?\>|^1\. |^\s*\- |^\-+$|^\*+$)/gm,""),i=i.replace(/^[ ]+|[ ]+$/gm,""),i=i.replace(/\!?\[\[([^\[\]\|]*\|)*([^\(\)\[\]]+)\]\]/g,"$2"),i=i.replace(/\!?\[+([^\[\]\(\)]+)\]+\(([^\(\)]+)\)/g,"$1"),i=i.replace(/`([^`]+)`/g,"$1"),i=i.replace(/_([^_]+)_/g,"$1"),i=i.replace(/==([^=]+)==/g,"$1"),i=i.replace(/\*\*\*([^\*]+)\*\*\*/g,"$1"),i=i.replace(/\*\*?([^\*]+)\*\*?/g,"$1"),i=i.replace(/~~([^~]+)~~/g,"$1"),e.replaceSelection(i)}function wa(e,i,o,n,s=!1){let r=da(e,o,"following");const a=e.workspace.getActiveViewOfType(t.ItemView);if(!aa.isAllowedViewType(a))return void(r&&(r.style.visibility="hidden"));if(!(o.settings.enableFollowingToolbar||!o.settings.enableTopToolbar&&!o.settings.enableFixedToolbar&&"following"===o.positionStyle))return;const l="markdown"===(null==a?void 0:a.getViewType());let c=30;if(c="tiny"===o.settings.aestheticStyle?30:i+14,l)if(aa.isSourceMode(a)){if(r){const t=s||n.somethingSelected();r.style.visibility=t?"visible":"hidden","visible"===r.style.visibility&&(r.style.height=c+"px",r.addClass("editingToolbarFlex"),r.removeClass("editingToolbarGrid"),function(t,e){var i,o,n,s;const r=e.containerEl.getBoundingClientRect(),a=t.offsetWidth,l=t.offsetHeight,c=12,h=window.innerWidth,d=e.getCursor("from");e.getCursor("to");const u=e.coordsAtPos(d),p=null!==(o=null===(i=la.getElementsByClassName("mod-left-split")[0])||void 0===i?void 0:i.clientWidth)&&void 0!==o?o:0,m=null!==(s=null===(n=la.getElementsByClassName("side-dock-ribbon mod-left")[0])||void 0===n?void 0:n.clientWidth)&&void 0!==s?s:0,g=p+m;let f=u.left-g-28;f+a>h-g&&(f=h-g-a-c);f=Math.max(0,f);let b=function(t,e,i,o){const n=t.getCursor("from"),s=t.getCursor("to"),r=t.coordsAtPos(s),a=n.line===s.line;let l=e.top-o-10;if(a)l<=i.top&&(l=r.bottom+10);else{if(t.getCursor("head").ch==t.getCursor("from").ch)l=e.top-o-10,l<=i.top&&(l=i.top+2*o);else{const e=(t=>{var e,i,o;let n,s=t.getCursor("head");if(t.getCursor("head").ch!==t.getCursor("from").ch&&(s.ch=Math.max(0,s.ch-1)),t.cursorCoords)n=t.cursorCoords(!0,"window");else{if(!t.coordsAtPos)return;{const r=t.posToOffset(s);n=null!==(o=null===(i=(e=t.cm).coordsAtPos)||void 0===i?void 0:i.call(e,r))&&void 0!==o?o:t.coordsAtPos(r)}}return n})(t);l=e.bottom+10,l>=i.bottom-o&&(l=i.bottom-2*o)}}return l}(e,u,r,l);b=Math.max(0,b),t.style.left=`${f}px`,t.style.top=`${b}px`}(r,n))}}else r&&(r.style.visibility="hidden");else r&&(r.style.visibility="visible",r.style.height=c+"px",r.addClass("editingToolbarFlex"),r.removeClass("editingToolbarGrid"))}function Ca(e,i,o){var n,s,r,a,l,c;const h=i.settings;if(la=t.requireApiVersion("0.15.0")?activeWindow.document:window.document,!o){const t=[];if(h.enableTopToolbar&&t.push("top"),h.enableFollowingToolbar&&t.push("following"),h.enableFixedToolbar&&t.push("fixed"),0===t.length){const e=i.positionStyle||i.settings.positionStyle||"top";t.push(e)}return void t.forEach(t=>{Ca(e,i,t)})}const d=o;if(!h.cMenuVisibility){const t=da(e,i,d);return void(t&&(t.style.display="none"))}const u=(h.appearanceByStyle||{})[d]||{},p=null!==(s=null!==(n=u.toolbarIconSize)&&void 0!==n?n:i.toolbarIconSize)&&void 0!==s?s:18,m=null!==(a=null!==(r=u.aestheticStyle)&&void 0!==r?r:h.aestheticStyle)&&void 0!==a?a:"default",g="custom"===m?null!==(l=u.toolbarBackgroundColor)&&void 0!==l?l:h.toolbarBackgroundColor:void 0,f="custom"===m?null!==(c=u.toolbarIconColor)&&void 0!==c?c:h.toolbarIconColor:void 0,b={default:"editingToolbarDefaultAesthetic",tiny:"editingToolbarTinyAesthetic",glass:"editingToolbarGlassAesthetic",custom:"editingToolbarCustomAesthetic"};!function(){function o(t,e){Object.values(b).forEach(e=>{t.removeClass(e)});const i=b[e]||b.default;t.addClass(i)}const n=()=>{var n,s;let r=0,a=0,l=p+8,c=createEl("div");if(c)if(c.addClass("editingToolbarModalBar"),c.setAttribute("data-toolbar-style",d),"top"===d)c.className+=" top",h.autohide&&(c.className+=" autohide"),h.Iscentered&&(c.className+=" centered");else if("following"===d)c.style.visibility="hidden";else if("fixed"===d){const t=p||18,e=`left: calc(50% - calc(${h.cMenuNumRows*(t+10)}px / 2));\n bottom: 4.25em; \n grid-template-columns: repeat(${h.cMenuNumRows}, ${t+10}px);\n gap: ${(t-18)/4}px`;c.setAttribute("style",e)}c.setAttribute("id","editingToolbarModalBar");let u=createEl("div");if(u.addClass("editingToolbarpopover"),u.addClass("editingToolbarTinyAesthetic"),u.addClass("editingToolbarPopoverBar"),u.setAttribute("data-toolbar-style",d),u.setAttribute("id","editingToolbarPopoverBar"),u.style.visibility="hidden",u.style.height="0",o(c,m),o(u,m),g&&(c.style.setProperty("--editing-toolbar-background-color",g),u.style.setProperty("--editing-toolbar-background-color",g)),f&&(c.style.setProperty("--editing-toolbar-icon-color",f),u.style.setProperty("--editing-toolbar-icon-color",f)),p&&(c.style.setProperty("--toolbar-icon-size",`${p}px`),u.style.setProperty("--toolbar-icon-size",`${p}px`)),"top"===d){let t=e.workspace.activeLeaf.view.containerEl,i=null;const o=e.workspace.activeLeaf.view.getViewType(),n=ca[o];if(n&&(i=null==t?void 0:t.querySelector(n)),!i){const e=null==t?void 0:t.querySelector(".view-content");if(e){const t=e.querySelectorAll(":scope > div");i=t.length>0?t[0]:e}}if(!i)return void console.log("Editing Toolbar: Failed to find target DOM element for toolbar insertion");(null==t?void 0:t.querySelector("#editingToolbarPopoverBar"))||("excalidraw"==o?i.insertAdjacentElement("afterend",u):i.insertAdjacentElement("afterbegin",u)),"excalidraw"==o?i.insertAdjacentElement("afterend",c):i.insertAdjacentElement("afterbegin",c),a=null==i?void 0:i.offsetWidth}else"body"==h.appendMethod?la.body.appendChild(c):"workspace"==h.appendMethod&&(null===(n=la.body)||void 0===n||n.querySelector(".mod-vertical.mod-root").insertAdjacentElement("afterbegin",c));let b=null===(s=e.workspace.activeLeaf.view.containerEl)||void 0===s?void 0:s.querySelector("#editingToolbarPopoverBar");i.getCurrentCommands(d).forEach((o,n)=>{let s;if("SubmenuCommands"in o){let u;r>=a-7*l&&a>100?(i.setIS_MORE_Button(!0),u=new t.ButtonComponent(b)):u=new t.ButtonComponent(c),u.setClass("editingToolbarCommandsubItem"+n),n>=h.cMenuNumRows?u.setClass("editingToolbarSecond"):"top"!==d&&u.buttonEl.setAttribute("aria-label-position","top"),ga(o.icon)?u.buttonEl.innerHTML=o.icon:u.setIcon(o.icon),r+=l+2;let p=function(t){let e=createEl("div");return e.addClass(t),e}("subitem");p&&o.SubmenuCommands.forEach(o=>{let r=ma(e,o.id);s="–"==r?o.name:o.name+"("+r+")";let a=new t.ButtonComponent(p).setTooltip(s).setClass("menu-item").onClick(()=>{e.commands.executeCommandById(o.id);const t=i.commandsManager.getActiveEditor(),n=t&&t.somethingSelected();0==h.cMenuVisibility?c.style.visibility="hidden":"following"===d?n||(c.style.visibility="hidden"):c.style.visibility="visible"});n{e.commands.executeCommandById(o.id);const t=i.commandsManager.getActiveEditor(),n=t&&t.somethingSelected();0==h.cMenuVisibility?c.style.visibility="hidden":"following"===d?n||(c.style.visibility="hidden"):c.style.visibility="visible"}),ga(o.icon)?n.buttonEl.innerHTML=o.icon:n.setIcon(o.icon),r+=l;let s=createEl("div");if(s.addClass("subitem"),s){s.innerHTML=function(t){return`
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Theme Colors
Standard Colors
Custom Font Colors
\n
\n
`}(i),n.buttonEl.insertAdjacentElement("afterbegin",s),fa(e,i,"x-color-picker-table");let o=s.querySelector(".x-color-picker-wrapper");new t.ButtonComponent(o).setIcon("paintbrush").setTooltip(Jr("Format Brush")).onClick(()=>{ya(i),i.setEN_FontColor_Format_Brush(!0),i.Temp_Notice=new t.Notice(Jr("Font-Color formatting brush ON!"),0)}),new t.ButtonComponent(o).setIcon("palette").setTooltip(Jr("Custom Font Color")).onClick(()=>{e.setting.open(),e.setting.openTabById("editing-toolbar"),setTimeout(()=>{const t=e.setting.activeTab.containerEl.querySelector(".editing-toolbar-tabs");if(t){const i=t.children[1];null==i||i.click(),setTimeout(()=>{var t;let i=e.setting.activeTab.containerEl.querySelector(".custom_font");i&&(null===(t=i.addClass)||void 0===t||t.call(i,"toolbar-cta"))},100)}},200)})}}else if("editing-toolbar:change-background-color"==o.id){let n=new t.ButtonComponent(c);n.setClass("editingToolbarCommandsubItem-font-color").setTooltip(Jr("Background Color")).onClick(()=>{e.commands.executeCommandById(o.id);const t=i.commandsManager.getActiveEditor(),n=t&&t.somethingSelected();0==h.cMenuVisibility?c.style.visibility="hidden":"following"===d?n||(c.style.visibility="hidden"):c.style.visibility="visible"}),ga(o.icon)?n.buttonEl.innerHTML=o.icon:n.setIcon(o.icon),r+=l;let s=createEl("div");if(s.addClass("subitem"),s){s.innerHTML=function(t){return`
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Translucent Colors
Highlighter Colors
Custom Colors
\n
\n
`}(i),n.buttonEl.insertAdjacentElement("afterbegin",s),fa(e,i,"x-backgroundcolor-picker-table");let o=s.querySelector(".x-color-picker-wrapper");new t.ButtonComponent(o).setIcon("paintbrush").setTooltip(Jr("Format Brush")).onClick(()=>{ya(i),i.setEN_BG_Format_Brush(!0),i.Temp_Notice=new t.Notice(Jr("Font-Color formatting brush ON!"),0)}),new t.ButtonComponent(o).setIcon("palette").setTooltip(Jr("Custom Backgroud Color")).onClick(()=>{e.setting.open(),e.setting.openTabById("editing-toolbar"),setTimeout(()=>{const t=e.setting.activeTab.containerEl.querySelector(".editing-toolbar-tabs");if(t){const i=t.children[1];null==i||i.click(),setTimeout(()=>{var t;let i=e.setting.activeTab.containerEl.querySelector(".custom_bg");i&&(null===(t=i.addClass)||void 0===t||t.call(i,"toolbar-cta"))},100)}},200)})}}else{let u;r>=a-7*l&&a>100?(i.setIS_MORE_Button(!0),u=new t.ButtonComponent(b)):u=new t.ButtonComponent(c);let p=ma(e,o.id);s="–"==p?o.name:o.name+"("+p+")",u.setTooltip(s).onClick(()=>{e.commands.executeCommandById(o.id);const t=i.commandsManager.getActiveEditor(),n=t&&t.somethingSelected();0==h.cMenuVisibility?c.style.visibility="hidden":"following"===d?n||(c.style.visibility="hidden"):c.style.visibility="visible"}),u.setClass("editingToolbarCommandItem"),n>=h.cMenuNumRows?u.setClass("editingToolbarSecond"):"top"!==d&&u.buttonEl.setAttribute("aria-label-position","top"),"editingToolbar-Divider-Line"==o.id&&u.setClass("editingToolbar-Divider-Line"),ga(o.icon)?u.buttonEl.innerHTML=o.icon:u.setIcon(o.icon),r+=l}}),function(e,i,o){const n=e.workspace.getActiveViewOfType(t.ItemView);if(!aa.isAllowedViewType(n))return;let s=n.containerEl.querySelector("#editingToolbarPopoverBar");if(!i.IS_MORE_Button)return;let r=o.createEl("span");r.addClass("more-menu");let a=new t.ButtonComponent(r);a.setClass("editingToolbarCommandItem").setTooltip(Jr("More")).onClick(()=>{"hidden"==s.style.visibility?(s.style.visibility="visible",s.style.height="32px"):(s.style.visibility="hidden",s.style.height="0")}),a.buttonEl.innerHTML='',i.setIS_MORE_Button(!1)}(e,i,c),Math.abs(i.settings.cMenuWidth-Number(r))>r+4&&(i.settings.cMenuWidth=Number(r),setTimeout(()=>{i.saveSettings()},100))};if(!i.isLoadMobile())return;const s=e.workspace.getActiveViewOfType(t.ItemView);if(aa.isAllowedViewType(s)){const o=da(e,i,d);if(o&&"top"!==d)return h.cMenuVisibility?"following"===d?(o.style.visibility="hidden",o.style.display=""):(o.style.visibility="visible",o.style.display=""):o.style.display="none",g&&o.style.setProperty("--editing-toolbar-background-color",g),f&&o.style.setProperty("--editing-toolbar-icon-color",f),void(p&&o.style.setProperty("--toolbar-icon-size",`${p}px`));if(n(),"top"!==d){const t=da(e,i,d);t&&i.setCachedToolbar(d,t)}jr(i.settings),Ur(i.settings),function(e,i){la=t.requireApiVersion("0.15.0")?activeWindow.document:window.document;const o=la.querySelectorAll("#change-font-color-icon"),n=la.querySelectorAll("#change-background-color-icon");o.length>0&&o.forEach(t=>{t.style.fill=e});n.length>0&&n.forEach(t=>{t.style.fill=i})} /**! * Sortable 1.15.6 * @author RubaXa * @author owenm * @license MIT */(h.cMenuFontColor,h.cMenuBackgroundColor)}}()}function xa(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,o)}return i}function ka(t){for(var e=1;e=0||(n[i]=t[i]);return n}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(o=0;o=0||Object.prototype.propertyIsEnumerable.call(t,i)&&(n[i]=t[i])}return n}function Aa(t){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(t)}var Ia=Aa(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Da=Aa(/Edge/i),Oa=Aa(/firefox/i),Ba=Aa(/safari/i)&&!Aa(/chrome/i)&&!Aa(/android/i),La=Aa(/iP(ad|od|hone)/i),Na=Aa(/chrome/i)&&Aa(/android/i),qa={capture:!1,passive:!1};function Ra(t,e,i){t.addEventListener(e,i,!Ia&&qa)}function Fa(t,e,i){t.removeEventListener(e,i,!Ia&&qa)}function Pa(t,e){if(e){if(">"===e[0]&&(e=e.substring(1)),t)try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return!1}return!1}}function _a(t){return t.host&&t!==document&&t.host.nodeType?t.host:t.parentNode}function Va(t,e,i,o){if(t){i=i||document;do{if(null!=e&&(">"===e[0]?t.parentNode===i&&Pa(t,e):Pa(t,e))||o&&t===i)return t;if(t===i)break}while(t=_a(t))}return null}var za,Ha=/\s+/g;function Wa(t,e,i){if(t&&e)if(t.classList)t.classList[i?"add":"remove"](e);else{var o=(" "+t.className+" ").replace(Ha," ").replace(" "+e+" "," ");t.className=(o+(i?" "+e:"")).replace(Ha," ")}}function $a(t,e,i){var o=t&&t.style;if(o){if(void 0===i)return document.defaultView&&document.defaultView.getComputedStyle?i=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(i=t.currentStyle),void 0===e?i:i[e];e in o||-1!==e.indexOf("webkit")||(e="-webkit-"+e),o[e]=i+("string"==typeof i?"":"px")}}function Ua(t,e){var i="";if("string"==typeof t)i=t;else do{var o=$a(t,"transform");o&&"none"!==o&&(i=o+" "+i)}while(!e&&(t=t.parentNode));var n=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return n&&new n(i)}function ja(t,e,i){if(t){var o=t.getElementsByTagName(e),n=0,s=o.length;if(i)for(;n=s:n<=s))return o;if(o===Ya())break;o=tl(o,!1)}return!1}function Ka(t,e,i,o){for(var n=0,s=0,r=t.children;s2&&void 0!==arguments[2]?arguments[2]:{},o=i.evt,n=Ma(i,dl);hl.pluginEvent.bind(nc)(t,e,ka({dragEl:ml,parentEl:gl,ghostEl:fl,rootEl:bl,nextEl:yl,lastDownEl:vl,cloneEl:wl,cloneHidden:Cl,dragStarted:Nl,putSortable:Ml,activeSortable:nc.active,originalEvent:o,oldIndex:xl,oldDraggableIndex:Sl,newIndex:kl,newDraggableIndex:Tl,hideGhostForTarget:tc,unhideGhostForTarget:ec,cloneNowHidden:function(){Cl=!0},cloneNowShown:function(){Cl=!1},dispatchSortableEvent:function(t){pl({sortable:e,name:t,originalEvent:o})}},n))};function pl(t){!function(t){var e=t.sortable,i=t.rootEl,o=t.name,n=t.targetEl,s=t.cloneEl,r=t.toEl,a=t.fromEl,l=t.oldIndex,c=t.newIndex,h=t.oldDraggableIndex,d=t.newDraggableIndex,u=t.originalEvent,p=t.putSortable,m=t.extraEventProperties;if(e=e||i&&i[rl]){var g,f=e.options,b="on"+o.charAt(0).toUpperCase()+o.substr(1);!window.CustomEvent||Ia||Da?(g=document.createEvent("Event")).initEvent(o,!0,!0):g=new CustomEvent(o,{bubbles:!0,cancelable:!0}),g.to=r||i,g.from=a||i,g.item=n||i,g.clone=s,g.oldIndex=l,g.newIndex=c,g.oldDraggableIndex=h,g.newDraggableIndex=d,g.originalEvent=u,g.pullMode=p?p.lastPutMode:void 0;var y=ka(ka({},m),hl.getEventProperties(o,e));for(var v in y)g[v]=y[v];i&&i.dispatchEvent(g),f[b]&&f[b].call(e,g)}}(ka({putSortable:Ml,cloneEl:wl,targetEl:ml,rootEl:bl,oldIndex:xl,oldDraggableIndex:Sl,newIndex:kl,newDraggableIndex:Tl},t))}var ml,gl,fl,bl,yl,vl,wl,Cl,xl,kl,Sl,Tl,El,Ml,Al,Il,Dl,Ol,Bl,Ll,Nl,ql,Rl,Fl,Pl,_l=!1,Vl=!1,zl=[],Hl=!1,Wl=!1,$l=[],Ul=!1,jl=[],Yl="undefined"!=typeof document,Gl=La,Zl=Da||Ia?"cssFloat":"float",Kl=Yl&&!Na&&!La&&"draggable"in document.createElement("div"),Jl=function(){if(Yl){if(Ia)return!1;var t=document.createElement("x");return t.style.cssText="pointer-events:auto","auto"===t.style.pointerEvents}}(),Xl=function(t,e){var i=$a(t),o=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),n=Ka(t,0,e),s=Ka(t,1,e),r=n&&$a(n),a=s&&$a(s),l=r&&parseInt(r.marginLeft)+parseInt(r.marginRight)+Ga(n).width,c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+Ga(s).width;if("flex"===i.display)return"column"===i.flexDirection||"column-reverse"===i.flexDirection?"vertical":"horizontal";if("grid"===i.display)return i.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(n&&r.float&&"none"!==r.float){var h="left"===r.float?"left":"right";return!s||"both"!==a.clear&&a.clear!==h?"horizontal":"vertical"}return n&&("block"===r.display||"flex"===r.display||"table"===r.display||"grid"===r.display||l>=o&&"none"===i[Zl]||s&&"none"===i[Zl]&&l+c>o)?"vertical":"horizontal"},Ql=function(t){function e(t,i){return function(o,n,s,r){var a=o.options.group.name&&n.options.group.name&&o.options.group.name===n.options.group.name;if(null==t&&(i||a))return!0;if(null==t||!1===t)return!1;if(i&&"clone"===t)return t;if("function"==typeof t)return e(t(o,n,s,r),i)(o,n,s,r);var l=(i?o:n).options.group.name;return!0===t||"string"==typeof t&&t===l||t.join&&t.indexOf(l)>-1}}var i={},o=t.group;o&&"object"==Sa(o)||(o={name:o}),i.name=o.name,i.checkPull=e(o.pull,!0),i.checkPut=e(o.put),i.revertClone=o.revertClone,t.group=i},tc=function(){!Jl&&fl&&$a(fl,"display","none")},ec=function(){!Jl&&fl&&$a(fl,"display","")};Yl&&!Na&&document.addEventListener("click",function(t){if(Vl)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),Vl=!1,!1},!0);var ic=function(t){if(ml){t=t.touches?t.touches[0]:t;var e=(n=t.clientX,s=t.clientY,zl.some(function(t){var e=t[rl].options.emptyInsertThreshold;if(e&&!Ja(t)){var i=Ga(t),o=n>=i.left-e&&n<=i.right+e,a=s>=i.top-e&&s<=i.bottom+e;return o&&a?r=t:void 0}}),r);if(e){var i={};for(var o in t)t.hasOwnProperty(o)&&(i[o]=t[o]);i.target=i.rootEl=e,i.preventDefault=void 0,i.stopPropagation=void 0,e[rl]._onDragOver(i)}}var n,s,r},oc=function(t){ml&&ml.parentNode[rl]._isOutsideThisEl(t.target)};function nc(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));this.el=t,this.options=e=Ea({},e),t[rl]=this;var i={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return Xl(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:!1!==nc.supportPointer&&"PointerEvent"in window&&(!Ba||La),emptyInsertThreshold:5};for(var o in hl.initializePlugins(this,t,i),i)!(o in e)&&(e[o]=i[o]);for(var n in Ql(e),this)"_"===n.charAt(0)&&"function"==typeof this[n]&&(this[n]=this[n].bind(this));this.nativeDraggable=!e.forceFallback&&Kl,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?Ra(t,"pointerdown",this._onTapStart):(Ra(t,"mousedown",this._onTapStart),Ra(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(Ra(t,"dragover",this),Ra(t,"dragenter",this)),zl.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),Ea(this,al())}function sc(t,e,i,o,n,s,r,a){var l,c,h=t[rl],d=h.options.onMove;return!window.CustomEvent||Ia||Da?(l=document.createEvent("Event")).initEvent("move",!0,!0):l=new CustomEvent("move",{bubbles:!0,cancelable:!0}),l.to=e,l.from=t,l.dragged=i,l.draggedRect=o,l.related=n||e,l.relatedRect=s||Ga(e),l.willInsertAfter=a,l.originalEvent=r,t.dispatchEvent(l),d&&(c=d.call(h,l,r)),c}function rc(t){t.draggable=!1}function ac(){Ul=!1}function lc(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,i=e.length,o=0;i--;)o+=e.charCodeAt(i);return o.toString(36)}function cc(t){return setTimeout(t,0)}function hc(t){return clearTimeout(t)}nc.prototype={constructor:nc,_isOutsideThisEl:function(t){this.el.contains(t)||t===this.el||(ql=null)},_getDirection:function(t,e){return"function"==typeof this.options.direction?this.options.direction.call(this,t,e,ml):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,i=this.el,o=this.options,n=o.preventOnFilter,s=t.type,r=t.touches&&t.touches[0]||t.pointerType&&"touch"===t.pointerType&&t,a=(r||t).target,l=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||a,c=o.filter;if(function(t){jl.length=0;var e=t.getElementsByTagName("input"),i=e.length;for(;i--;){var o=e[i];o.checked&&jl.push(o)}}(i),!ml&&!(/mousedown|pointerdown/.test(s)&&0!==t.button||o.disabled)&&!l.isContentEditable&&(this.nativeDraggable||!Ba||!a||"SELECT"!==a.tagName.toUpperCase())&&!((a=Va(a,o.draggable,i,!1))&&a.animated||vl===a)){if(xl=Xa(a),Sl=Xa(a,o.draggable),"function"==typeof c){if(c.call(this,t,a,this))return pl({sortable:e,rootEl:l,name:"filter",targetEl:a,toEl:i,fromEl:i}),ul("filter",e,{evt:t}),void(n&&t.preventDefault())}else if(c&&(c=c.split(",").some(function(o){if(o=Va(l,o.trim(),i,!1))return pl({sortable:e,rootEl:o,name:"filter",targetEl:a,fromEl:i,toEl:i}),ul("filter",e,{evt:t}),!0})))return void(n&&t.preventDefault());o.handle&&!Va(l,o.handle,i,!1)||this._prepareDragStart(t,r,a)}}},_prepareDragStart:function(t,e,i){var o,n=this,s=n.el,r=n.options,a=s.ownerDocument;if(i&&!ml&&i.parentNode===s){var l=Ga(i);if(bl=s,gl=(ml=i).parentNode,yl=ml.nextSibling,vl=i,El=r.group,nc.dragged=ml,Al={target:ml,clientX:(e||t).clientX,clientY:(e||t).clientY},Bl=Al.clientX-l.left,Ll=Al.clientY-l.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,ml.style["will-change"]="all",o=function(){ul("delayEnded",n,{evt:t}),nc.eventCanceled?n._onDrop():(n._disableDelayedDragEvents(),!Oa&&n.nativeDraggable&&(ml.draggable=!0),n._triggerDragStart(t,e),pl({sortable:n,name:"choose",originalEvent:t}),Wa(ml,r.chosenClass,!0))},r.ignore.split(",").forEach(function(t){ja(ml,t.trim(),rc)}),Ra(a,"dragover",ic),Ra(a,"mousemove",ic),Ra(a,"touchmove",ic),r.supportPointer?(Ra(a,"pointerup",n._onDrop),!this.nativeDraggable&&Ra(a,"pointercancel",n._onDrop)):(Ra(a,"mouseup",n._onDrop),Ra(a,"touchend",n._onDrop),Ra(a,"touchcancel",n._onDrop)),Oa&&this.nativeDraggable&&(this.options.touchStartThreshold=4,ml.draggable=!0),ul("delayStart",this,{evt:t}),!r.delay||r.delayOnTouchOnly&&!e||this.nativeDraggable&&(Da||Ia))o();else{if(nc.eventCanceled)return void this._onDrop();r.supportPointer?(Ra(a,"pointerup",n._disableDelayedDrag),Ra(a,"pointercancel",n._disableDelayedDrag)):(Ra(a,"mouseup",n._disableDelayedDrag),Ra(a,"touchend",n._disableDelayedDrag),Ra(a,"touchcancel",n._disableDelayedDrag)),Ra(a,"mousemove",n._delayedDragTouchMoveHandler),Ra(a,"touchmove",n._delayedDragTouchMoveHandler),r.supportPointer&&Ra(a,"pointermove",n._delayedDragTouchMoveHandler),n._dragStartTimer=setTimeout(o,r.delay)}}},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){ml&&rc(ml),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;Fa(t,"mouseup",this._disableDelayedDrag),Fa(t,"touchend",this._disableDelayedDrag),Fa(t,"touchcancel",this._disableDelayedDrag),Fa(t,"pointerup",this._disableDelayedDrag),Fa(t,"pointercancel",this._disableDelayedDrag),Fa(t,"mousemove",this._delayedDragTouchMoveHandler),Fa(t,"touchmove",this._delayedDragTouchMoveHandler),Fa(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||"touch"==t.pointerType&&t,!this.nativeDraggable||e?this.options.supportPointer?Ra(document,"pointermove",this._onTouchMove):Ra(document,e?"touchmove":"mousemove",this._onTouchMove):(Ra(ml,"dragend",this),Ra(bl,"dragstart",this._onDragStart));try{document.selection?cc(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(t,e){if(_l=!1,bl&&ml){ul("dragStarted",this,{evt:e}),this.nativeDraggable&&Ra(document,"dragover",oc);var i=this.options;!t&&Wa(ml,i.dragClass,!1),Wa(ml,i.ghostClass,!0),nc.active=this,t&&this._appendGhost(),pl({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(Il){this._lastX=Il.clientX,this._lastY=Il.clientY,tc();for(var t=document.elementFromPoint(Il.clientX,Il.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(Il.clientX,Il.clientY))!==e;)e=t;if(ml.parentNode[rl]._isOutsideThisEl(t),e)do{if(e[rl]){if(e[rl]._onDragOver({clientX:Il.clientX,clientY:Il.clientY,target:t,rootEl:e})&&!this.options.dragoverBubble)break}t=e}while(e=_a(e));ec()}},_onTouchMove:function(t){if(Al){var e=this.options,i=e.fallbackTolerance,o=e.fallbackOffset,n=t.touches?t.touches[0]:t,s=fl&&Ua(fl,!0),r=fl&&s&&s.a,a=fl&&s&&s.d,l=Gl&&Pl&&Qa(Pl),c=(n.clientX-Al.clientX+o.x)/(r||1)+(l?l[0]-$l[0]:0)/(r||1),h=(n.clientY-Al.clientY+o.y)/(a||1)+(l?l[1]-$l[1]:0)/(a||1);if(!nc.active&&!_l){if(i&&Math.max(Math.abs(n.clientX-this._lastX),Math.abs(n.clientY-this._lastY))n.right+s||t.clientY>o.bottom&&t.clientX>o.left:t.clientY>n.bottom+s||t.clientX>o.right&&t.clientY>o.top}(t,n,this)&&!g.animated){if(g===ml)return O(!1);if(g&&s===t.target&&(r=g),r&&(i=Ga(r)),!1!==sc(bl,s,ml,e,r,i,t,!!r))return D(),g&&g.nextSibling?s.insertBefore(ml,g.nextSibling):s.appendChild(ml),gl=s,B(),O(!0)}else if(g&&function(t,e,i){var o=Ga(Ka(i.el,0,i.options,!0)),n=sl(i.el,i.options,fl),s=10;return e?t.clientXh+c*s/2:ld-Fl)return-Rl}else if(l>h+c*(1-n)/2&&ld-c*s/2))return l>h+c/2?1:-1;return 0}(t,r,i,n,C?1:a.swapThreshold,null==a.invertedSwapThreshold?a.swapThreshold:a.invertedSwapThreshold,Wl,ql===r),0!==b){var T=Xa(ml);do{T-=b,v=gl.children[T]}while(v&&("none"===$a(v,"display")||v===fl))}if(0===b||v===r)return O(!1);ql=r,Rl=b;var E=r.nextElementSibling,M=!1,A=sc(bl,s,ml,e,r,i,t,M=1===b);if(!1!==A)return 1!==A&&-1!==A||(M=1===A),Ul=!0,setTimeout(ac,30),D(),M&&!E?s.appendChild(ml):r.parentNode.insertBefore(ml,M?E:r),k&&ol(k,0,S-k.scrollTop),gl=ml.parentNode,void 0===y||Wl||(Fl=Math.abs(y-Ga(r)[x])),B(),O(!0)}if(s.contains(ml))return O(!1)}return!1}function I(a,l){ul(a,p,ka({evt:t,isOwner:h,axis:n?"vertical":"horizontal",revert:o,dragRect:e,targetRect:i,canSort:d,fromSortable:u,target:r,completed:O,onMove:function(i,o){return sc(bl,s,ml,e,i,Ga(i),t,o)},changed:B},l))}function D(){I("dragOverAnimationCapture"),p.captureAnimationState(),p!==u&&u.captureAnimationState()}function O(e){return I("dragOverCompleted",{insertion:e}),e&&(h?c._hideClone():c._showClone(p),p!==u&&(Wa(ml,Ml?Ml.options.ghostClass:c.options.ghostClass,!1),Wa(ml,a.ghostClass,!0)),Ml!==p&&p!==nc.active?Ml=p:p===nc.active&&Ml&&(Ml=null),u===p&&(p._ignoreWhileAnimating=r),p.animateAll(function(){I("dragOverAnimationComplete"),p._ignoreWhileAnimating=null}),p!==u&&(u.animateAll(),u._ignoreWhileAnimating=null)),(r===ml&&!ml.animated||r===s&&!r.animated)&&(ql=null),a.dragoverBubble||t.rootEl||r===document||(ml.parentNode[rl]._isOutsideThisEl(t.target),!e&&ic(t)),!a.dragoverBubble&&t.stopPropagation&&t.stopPropagation(),m=!0}function B(){kl=Xa(ml),Tl=Xa(ml,a.draggable),pl({sortable:p,name:"change",toEl:s,newIndex:kl,newDraggableIndex:Tl,originalEvent:t})}},_ignoreWhileAnimating:null,_offMoveEvents:function(){Fa(document,"mousemove",this._onTouchMove),Fa(document,"touchmove",this._onTouchMove),Fa(document,"pointermove",this._onTouchMove),Fa(document,"dragover",ic),Fa(document,"mousemove",ic),Fa(document,"touchmove",ic)},_offUpEvents:function(){var t=this.el.ownerDocument;Fa(t,"mouseup",this._onDrop),Fa(t,"touchend",this._onDrop),Fa(t,"pointerup",this._onDrop),Fa(t,"pointercancel",this._onDrop),Fa(t,"touchcancel",this._onDrop),Fa(document,"selectstart",this)},_onDrop:function(t){var e=this.el,i=this.options;kl=Xa(ml),Tl=Xa(ml,i.draggable),ul("drop",this,{evt:t}),gl=ml&&ml.parentNode,kl=Xa(ml),Tl=Xa(ml,i.draggable),nc.eventCanceled||(_l=!1,Wl=!1,Hl=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),hc(this.cloneId),hc(this._dragStartId),this.nativeDraggable&&(Fa(document,"drop",this),Fa(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Ba&&$a(document.body,"user-select",""),$a(ml,"transform",""),t&&(Nl&&(t.cancelable&&t.preventDefault(),!i.dropBubble&&t.stopPropagation()),fl&&fl.parentNode&&fl.parentNode.removeChild(fl),(bl===gl||Ml&&"clone"!==Ml.lastPutMode)&&wl&&wl.parentNode&&wl.parentNode.removeChild(wl),ml&&(this.nativeDraggable&&Fa(ml,"dragend",this),rc(ml),ml.style["will-change"]="",Nl&&!_l&&Wa(ml,Ml?Ml.options.ghostClass:this.options.ghostClass,!1),Wa(ml,this.options.chosenClass,!1),pl({sortable:this,name:"unchoose",toEl:gl,newIndex:null,newDraggableIndex:null,originalEvent:t}),bl!==gl?(kl>=0&&(pl({rootEl:gl,name:"add",toEl:gl,fromEl:bl,originalEvent:t}),pl({sortable:this,name:"remove",toEl:gl,originalEvent:t}),pl({rootEl:gl,name:"sort",toEl:gl,fromEl:bl,originalEvent:t}),pl({sortable:this,name:"sort",toEl:gl,originalEvent:t})),Ml&&Ml.save()):kl!==xl&&kl>=0&&(pl({sortable:this,name:"update",toEl:gl,originalEvent:t}),pl({sortable:this,name:"sort",toEl:gl,originalEvent:t})),nc.active&&(null!=kl&&-1!==kl||(kl=xl,Tl=Sl),pl({sortable:this,name:"end",toEl:gl,originalEvent:t}),this.save())))),this._nulling()},_nulling:function(){ul("nulling",this),bl=ml=gl=fl=yl=wl=vl=Cl=Al=Il=Nl=kl=Tl=xl=Sl=ql=Rl=Ml=El=nc.dragged=nc.ghost=nc.clone=nc.active=null,jl.forEach(function(t){t.checked=!0}),jl.length=Dl=Ol=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":ml&&(this._onDragOver(t),function(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move");t.cancelable&&t.preventDefault()}(t));break;case"selectstart":t.preventDefault()}},toArray:function(){for(var t,e=[],i=this.el.children,o=0,n=i.length,s=this.options;o{i.createEl("p",{text:t})});const o=i.createDiv("confirm-modal-buttons");new t.ButtonComponent(o).setButtonText(this.options.cancelText).onClick(()=>this.close()),new t.ButtonComponent(o).setButtonText(this.options.confirmText).setCta().onClick(()=>e(this,void 0,void 0,function*(){yield this.options.onConfirm(),this.close()}))}onClose(){const{contentEl:t}=this;t.empty()}static show(t,e){new Tc(t,e).open()}}class Ec extends t.Modal{constructor(t,e){super(t),this.changelogContent="",this.changelogLoaded=!1,this.plugin=e}loadChangelog(){return e(this,void 0,void 0,function*(){try{const e=yield t.request({url:"https://raw.githubusercontent.com/PKM-er/obsidian-editing-toolbar/master/CHANGELOG.md",method:"GET"});if(!e)throw new Error("无法获取 Changelog 内容");{const t=e.split("\n");let i="",o=[],n=!1;for(const e of t)if(e.startsWith("## ")&&!i)i=e.substring(3).trim(),n=!0,o.push(e);else{if(e.startsWith("## ")&&n)break;n&&o.push(e)}this.changelogContent=o.join("\n")}}catch(t){console.error("加载 Changelog 时出错:",t),this.changelogContent="### 无法加载更新说明\n\n请[点击此处查看最新更新说明](https://github.com/PKM-er/obsidian-editing-toolbar/blob/master/CHANGELOG.md)"}this.changelogLoaded=!0,this.updateChangelogDisplay()})}updateChangelogDisplay(){this.changelogContainer&&this.changelogContentEl&&this.changelogLoaded&&(this.changelogContentEl.empty(),t.MarkdownRenderer.renderMarkdown(this.changelogContent,this.changelogContentEl,"",this.plugin))}fixCommandIds(){return e(this,void 0,void 0,function*(){try{const e={"editor:toggle-numbered-list":"editing-toolbar:toggle-numbered-list","editor:toggle-bullet-list":"editing-toolbar:toggle-bullet-list","editor:toggle-highlight":"editing-toolbar:toggle-highlight","toggle-highlight":"editing-toolbar:toggle-highlight","editing-toolbar:editor:toggle-bold":"editing-toolbar:toggle-bold","editing-toolbar:editor:toggle-italics":"editing-toolbar:toggle-italics","editing-toolbar:editor:toggle-strikethrough":"editing-toolbar:toggle-strikethrough","editing-toolbar:editor:toggle-inline-math":"editing-toolbar:toggle-inline-math","editing-toolbar:editor:insert-callout":"editing-toolbar:insert-callout","editing-toolbar:editor:insert-link":"editing-toolbar:insert-link","cMenuToolbar-Divider-Line":"editingToolbar-Divider-Line"};let i=!1;const o=this.plugin.settings,n=t=>{t&&Array.isArray(t)&&t.forEach(t=>{t.id&&e[t.id]&&(t.id=e[t.id],i=!0),"editing-toolbar:format-eraser"===t.id&&(t.icon="eraser",i=!0),"editing-toolbar:change-font-color"===t.id&&(t.icon='',i=!0),t.SubmenuCommands&&n(t.SubmenuCommands)})},s=t=>{if(!t||!Array.isArray(t))return!1;for(const e of t){if("editing-toolbar:toggle-format-brush"===e.id)return!0;if(e.SubmenuCommands){if(s(e.SubmenuCommands))return!0}}return!1},r=t=>{if(!t||!Array.isArray(t))return!1;if(!s(t)&&t.length>=2){const e={id:"editing-toolbar:toggle-format-brush",name:"Format Brush",icon:"paintbrush"};return t.splice(2,0,e),!0}return!1};o.menuCommands&&(n(o.menuCommands),r(o.menuCommands)&&(i=!0)),o.enableMultipleConfig&&(o.followingCommands&&(n(o.followingCommands),r(o.followingCommands)&&(i=!0)),o.topCommands&&(n(o.topCommands),r(o.topCommands)&&(i=!0)),o.fixedCommands&&(n(o.fixedCommands),r(o.fixedCommands)&&(i=!0)),o.mobileCommands&&(n(o.mobileCommands),r(o.mobileCommands)&&(i=!0))),i?(yield this.plugin.saveSettings(),new t.Notice(Jr("Command IDs have been successfully repaired!")),dispatchEvent(new Event("editingToolbar-NewCommand"))):new t.Notice(Jr("No command IDs need to be repaired"))}catch(e){console.error("修复命令ID时出错:",e),new t.Notice(Jr("Error repairing command IDs, please check the console for details"))}})}reloadPlugin(t){return e(this,void 0,void 0,function*(){const{plugins:e}=this.app;try{yield e.disablePlugin(t),yield e.enablePlugin(t)}catch(t){console.error(t)}})}restoreDefaultSettings(){return e(this,void 0,void 0,function*(){try{const e=this.plugin.settings.lastVersion,i=this.plugin.settings.customCommands;this.plugin.settings=Object.assign(Object.assign({},ra),{lastVersion:e,customCommands:i}),yield this.plugin.saveSettings(),new t.Notice(Jr("Successfully restored default settings! (Custom commands preserved)")),this.reloadPlugin(this.plugin.manifest.id),this.close()}catch(e){console.error("恢复默认设置时出错:",e),new t.Notice(Jr("Error restoring default settings, please check the console for details"))}})}onOpen(){const{contentEl:i}=this;i.createEl("h2",{text:this.plugin.manifest.version+"⚡Tips"}),i.createEl("p",{text:Jr("Notice:")});const o=i.createEl("ul");o.createEl("li",{text:Jr("⚠️This update is not compatible with 2.x version command ids, please click [Repair command] to be compatible")}),o.createEl("li",{text:Jr("⚠️If you want to restore the default settings, please click [Restore default settings]")}),this.changelogContainer=i.createDiv({cls:"changelog-container"}),this.changelogContainer.createEl("h3",{text:Jr("Latest Changes")}),this.changelogContentEl=this.changelogContainer.createDiv({cls:"changelog-content"}),this.changelogContentEl.setText(Jr("Loading changelog...")),setTimeout(()=>{this.loadChangelog()},100),new t.Setting(i).setName(Jr("🔧Data repair")).setDesc(Jr("This update changed the ID of some commands, please click this button to repair the commands to ensure the toolbar works properly")).addButton(t=>t.setButtonText(Jr("Repair command ID")).onClick(()=>e(this,void 0,void 0,function*(){yield this.fixCommandIds()}))),new t.Setting(i).setName(Jr("🔄Restore default settings")).setDesc(Jr("This will reset all your custom configurations, but custom commands will be preserved")).addButton(t=>t.setButtonText(Jr("Restore default")).onClick(()=>e(this,void 0,void 0,function*(){Tc.show(this.app,{message:Jr("Are you sure you want to restore all settings to default? But custom commands will be preserved."),onConfirm:()=>e(this,void 0,void 0,function*(){yield this.restoreDefaultSettings()})})}))),new t.Setting(i).setName(Jr("📋View full changelog")).setDesc(Jr("Open the complete changelog in your browser")).addButton(t=>t.setButtonText(Jr("Open changelog")).onClick(()=>{window.open("https://github.com/PKM-er/obsidian-editing-toolbar/blob/master/CHANGELOG.md","_blank")})),new t.Setting(i).addButton(t=>t.setButtonText(Jr("Close")).onClick(()=>{this.close()})),i.createEl("style",{text:"\n .changelog-container {\n margin-top: 20px;\n margin-bottom: 20px;\n padding: 10px;\n border: 1px solid var(--background-modifier-border);\n border-radius: 5px;\n max-height: 200px;\n overflow-y: auto;\n }\n .changelog-content {\n padding: 0 10px;\n }\n .changelog-content a {\n text-decoration: underline;\n }\n "})}onClose(){const{contentEl:t}=this;t.empty()}}function Mc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t} /*! Pickr 1.8.4 MIT | https://github.com/Simonwep/pickr */ var Ac=function(t){var e={exports:{}};return t(e,e.exports),e.exports}(function(t,e){self,t.exports=(()=>{var t={d:(e,i)=>{for(var o in i)t.o(i,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:i[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.d(e,{default:()=>O});var i={};function o(t,e,i,o){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};e instanceof HTMLCollection||e instanceof NodeList?e=Array.from(e):Array.isArray(e)||(e=[e]),Array.isArray(i)||(i=[i]);for(const s of e)for(const e of i)s[t](e,o,{capture:!1,...n});return Array.prototype.slice.call(arguments,1)}t.r(i),t.d(i,{adjustableInputNumbers:()=>h,createElementFromString:()=>r,createFromTemplate:()=>a,eventPath:()=>l,off:()=>s,on:()=>n,resolveElement:()=>c});const n=o.bind(null,"addEventListener"),s=o.bind(null,"removeEventListener");function r(t){const e=document.createElement("div");return e.innerHTML=t.trim(),e.firstElementChild}function a(t){const e=(t,e)=>{const i=t.getAttribute(e);return t.removeAttribute(e),i},i=function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=e(t,":obj"),s=e(t,":ref"),r=n?o[n]={}:o;s&&(o[s]=t);for(const o of Array.from(t.children)){const t=e(o,":arr"),n=i(o,t?{}:r);t&&(r[t]||(r[t]=[])).push(Object.keys(n).length?n:o)}return o};return i(r(t))}function l(t){let e=t.path||t.composedPath&&t.composedPath();if(e)return e;let i=t.target.parentElement;for(e=[t.target,i];i=i.parentElement;)e.push(i);return e.push(document,window),e}function c(t){return t instanceof Element?t:"string"==typeof t?t.split(/>>/g).reduce((t,e,i,o)=>(t=t.querySelector(e),i1&&void 0!==arguments[1]?arguments[1]:t=>t;function i(i){const o=[.001,.01,.1][Number(i.shiftKey||2*i.ctrlKey)]*(i.deltaY<0?1:-1);let n=0,s=t.selectionStart;t.value=t.value.replace(/[\d.]+/g,(t,i)=>i<=s&&i+t.length>=s?(s=i,e(Number(t),o,n)):(n++,t)),t.focus(),t.setSelectionRange(s,s),i.preventDefault(),t.dispatchEvent(new Event("input"))}n(t,"focus",()=>n(window,"wheel",i,{passive:!1})),n(t,"blur",()=>s(window,"wheel",i))}const{min:d,max:u,floor:p,round:m}=Math;function g(t,e,i){e/=100,i/=100;const o=p(t=t/360*6),n=t-o,s=i*(1-e),r=i*(1-n*e),a=i*(1-(1-n)*e),l=o%6;return[255*[i,r,s,s,a,i][l],255*[a,i,i,r,s,s][l],255*[s,s,a,i,i,r][l]]}function f(t,e,i){return g(t,e,i).map(t=>m(t).toString(16).padStart(2,"0"))}function b(t,e,i){const o=g(t,e,i),n=o[0]/255,s=o[1]/255,r=o[2]/255,a=d(1-n,1-s,1-r);return[100*(1===a?0:(1-n-a)/(1-a)),100*(1===a?0:(1-s-a)/(1-a)),100*(1===a?0:(1-r-a)/(1-a)),100*a]}function y(t,e,i){const o=(2-(e/=100))*(i/=100)/2;return 0!==o&&(e=1===o?0:o<.5?e*i/(2*o):e*i/(2-2*o)),[t,100*e,100*o]}function v(t,e,i){const o=d(t/=255,e/=255,i/=255),n=u(t,e,i),s=n-o;let r,a;if(0===s)r=a=0;else{a=s/n;const o=((n-t)/6+s/2)/s,l=((n-e)/6+s/2)/s,c=((n-i)/6+s/2)/s;t===n?r=c-l:e===n?r=1/3+o-c:i===n&&(r=2/3+l-o),r<0?r+=1:r>1&&(r-=1)}return[360*r,100*a,100*n]}function w(t,e,i,o){return e/=100,i/=100,[...v(255*(1-d(1,(t/=100)*(1-(o/=100))+o)),255*(1-d(1,e*(1-o)+o)),255*(1-d(1,i*(1-o)+o)))]}function C(t,e,i){e/=100;const o=2*(e*=(i/=100)<.5?i:1-i)/(i+e)*100,n=100*(i+e);return[t,isNaN(o)?0:o,n]}function x(t){return v(...t.match(/.{2}/g).map(t=>parseInt(t,16)))}function k(t){t=t.match(/^[a-zA-Z]+$/)?function(t){if("black"===t.toLowerCase())return"#000";const e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,"#000"===e.fillStyle?null:e.fillStyle}(t):t;const e={cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},i=t=>t.map(t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0);let o;t:for(const n in e){if(!(o=e[n].exec(t)))continue;const s=t=>!!o[2]==("number"==typeof t);switch(n){case"cmyk":{const[,t,e,s,r]=i(o);if(t>100||e>100||s>100||r>100)break t;return{values:w(t,e,s,r),type:n}}case"rgba":{const[,,,t,e,r,a]=i(o);if(t>255||e>255||r>255||a<0||a>1||!s(a))break t;return{values:[...v(t,e,r),a],a:a,type:n}}case"hexa":{let[,t]=o;4!==t.length&&3!==t.length||(t=t.split("").map(t=>t+t).join(""));const e=t.substring(0,6);let i=t.substring(6);return i=i?parseInt(i,16)/255:void 0,{values:[...x(e),i],a:i,type:n}}case"hsla":{const[,,,t,e,r,a]=i(o);if(t>360||e>100||r>100||a<0||a>1||!s(a))break t;return{values:[...C(t,e,r),a],a:a,type:n}}case"hsva":{const[,,,t,e,r,a]=i(o);if(t>360||e>100||r>100||a<0||a>1||!s(a))break t;return{values:[t,e,r,a],a:a,type:n}}}}return{values:null,type:null}}function S(){const t=(t,e)=>function(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;return e(~i?t.map(t=>Number(t.toFixed(i))):t)},e={h:arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,s:arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,v:arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a:arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,toHSVA(){const i=[e.h,e.s,e.v,e.a];return i.toString=t(i,t=>`hsva(${t[0]}, ${t[1]}%, ${t[2]}%, ${e.a})`),i},toHSLA(){const i=[...y(e.h,e.s,e.v),e.a];return i.toString=t(i,t=>`hsla(${t[0]}, ${t[1]}%, ${t[2]}%, ${e.a})`),i},toRGBA(){const i=[...g(e.h,e.s,e.v),e.a];return i.toString=t(i,t=>`rgba(${t[0]}, ${t[1]}, ${t[2]}, ${e.a})`),i},toCMYK(){const i=b(e.h,e.s,e.v);return i.toString=t(i,t=>`cmyk(${t[0]}%, ${t[1]}%, ${t[2]}%, ${t[3]}%)`),i},toHEXA(){const t=f(e.h,e.s,e.v),i=e.a>=1?"":Number((255*e.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return i&&t.push(i),t.toString=()=>`#${t.join("").toUpperCase()}`,t},clone:()=>S(e.h,e.s,e.v,e.a)};return e}const T=t=>Math.max(Math.min(t,1),0);function E(t){const e={options:Object.assign({lock:null,onchange:()=>0,onstop:()=>0},t),_keyboard(t){const{options:i}=e,{type:o,key:n}=t;if(document.activeElement===i.wrapper){const{lock:i}=e.options,s="ArrowUp"===n,r="ArrowRight"===n,a="ArrowDown"===n,l="ArrowLeft"===n;if("keydown"===o&&(s||r||a||l)){let o=0,n=0;"v"===i?o=s||r?1:-1:"h"===i?o=s||r?-1:1:(n=s?-1:a?1:0,o=l?-1:r?1:0),e.update(T(e.cache.x+.01*o),T(e.cache.y+.01*n)),t.preventDefault()}else n.startsWith("Arrow")&&(e.options.onstop(),t.preventDefault())}},_tapstart(t){n(document,["mouseup","touchend","touchcancel"],e._tapstop),n(document,["mousemove","touchmove"],e._tapmove),t.cancelable&&t.preventDefault(),e._tapmove(t)},_tapmove(t){const{options:i,cache:o}=e,{lock:n,element:s,wrapper:r}=i,a=r.getBoundingClientRect();let l=0,c=0;if(t){const e=t&&t.touches&&t.touches[0];l=t?(e||t).clientX:0,c=t?(e||t).clientY:0,la.left+a.width&&(l=a.left+a.width),ca.top+a.height&&(c=a.top+a.height),l-=a.left,c-=a.top}else o&&(l=o.x*a.width,c=o.y*a.height);"h"!==n&&(s.style.left=`calc(${l/a.width*100}% - ${s.offsetWidth/2}px)`),"v"!==n&&(s.style.top=`calc(${c/a.height*100}% - ${s.offsetHeight/2}px)`),e.cache={x:l/a.width,y:c/a.height};const h=T(l/a.width),d=T(c/a.height);switch(n){case"v":return i.onchange(h);case"h":return i.onchange(d);default:return i.onchange(h,d)}},_tapstop(){e.options.onstop(),s(document,["mouseup","touchend","touchcancel"],e._tapstop),s(document,["mousemove","touchmove"],e._tapmove)},trigger(){e._tapmove()},update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const{left:o,top:n,width:s,height:r}=e.options.wrapper.getBoundingClientRect();"h"===e.options.lock&&(i=t),e._tapmove({clientX:o+s*t,clientY:n+r*i})},destroy(){const{options:t,_tapstart:i,_keyboard:o}=e;s(document,["keydown","keyup"],o),s([t.wrapper,t.element],"mousedown",i),s([t.wrapper,t.element],"touchstart",i,{passive:!1})}},{options:i,_tapstart:o,_keyboard:r}=e;return n([i.wrapper,i.element],"mousedown",o),n([i.wrapper,i.element],"touchstart",o,{passive:!1}),n(document,["keydown","keyup"],r),e}function M(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t=Object.assign({onchange:()=>0,className:"",elements:[]},t);const e=n(t.elements,"click",e=>{t.elements.forEach(i=>i.classList[e.target===i?"add":"remove"](t.className)),t.onchange(e),e.stopPropagation()});return{destroy:()=>s(...e)}}const A={variantFlipOrder:{start:"sme",middle:"mse",end:"ems"},positionFlipOrder:{top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},position:"bottom",margin:8},I=(t,e,i)=>{const{container:o,margin:n,position:s,variantFlipOrder:r,positionFlipOrder:a}={container:document.documentElement.getBoundingClientRect(),...A,...i},{left:l,top:c}=e.style;e.style.left="0",e.style.top="0";const h=t.getBoundingClientRect(),d=e.getBoundingClientRect(),u={t:h.top-d.height-n,b:h.bottom+n,r:h.right+n,l:h.left-d.width-n},p={vs:h.left,vm:h.left+h.width/2+-d.width/2,ve:h.left+h.width-d.width,hs:h.top,hm:h.bottom-h.height/2-d.height/2,he:h.bottom-d.height},[m,g="middle"]=s.split("-"),f=a[m],b=r[g],{top:y,left:v,bottom:w,right:C}=o;for(const t of f){const i="t"===t||"b"===t,o=u[t],[n,s]=i?["top","left"]:["left","top"],[r,a]=i?[d.height,d.width]:[d.width,d.height],[l,c]=i?[w,C]:[C,w],[h,m]=i?[y,v]:[v,y];if(!(ol))for(const r of b){const l=p[(i?"v":"h")+r];if(!(lc))return e.style[s]=l-d[s]+"px",e.style[n]=o-d[n]+"px",t+r}}return e.style.left=l,e.style.top=c,null};function D(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class O{constructor(t){D(this,"_initializingActive",!0),D(this,"_recalc",!0),D(this,"_nanopop",null),D(this,"_root",null),D(this,"_color",S()),D(this,"_lastColor",S()),D(this,"_swatchColors",[]),D(this,"_setupAnimationFrame",null),D(this,"_eventListener",{init:[],save:[],hide:[],show:[],clear:[],change:[],changestop:[],cancel:[],swatchselect:[]}),this.options=t=Object.assign({...O.DEFAULT_OPTIONS},t);const{swatches:e,components:i,theme:o,sliders:n,lockOpacity:s,padding:r}=t;["nano","monolith"].includes(o)&&!n&&(t.sliders="h"),i.interaction||(i.interaction={});const{preview:a,opacity:l,hue:c,palette:h}=i;i.opacity=!s&&l,i.palette=h||a||l||c,this._preBuild(),this._buildComponents(),this._bindEvents(),this._finalBuild(),e&&e.length&&e.forEach(t=>this.addSwatch(t));const{button:d,app:u}=this._root;this._nanopop=((t,e,i)=>{const o="object"!=typeof t||t instanceof HTMLElement?{reference:t,popper:e,...i}:t;return{update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o;const{reference:e,popper:i}=Object.assign(o,t);if(!i||!e)throw new Error("Popper- or reference-element missing.");return I(e,i,o)}}})(d,u,{margin:r}),d.setAttribute("role","button"),d.setAttribute("aria-label",this._t("btn:toggle"));const p=this;this._setupAnimationFrame=requestAnimationFrame(function e(){if(!u.offsetWidth)return p._setupAnimationFrame=requestAnimationFrame(e);p.setColor(t.default),p._rePositioningPicker(),t.defaultRepresentation&&(p._representation=t.defaultRepresentation,p.setColorRepresentation(p._representation)),t.showAlways&&p.show(),p._initializingActive=!1,p._emit("init")})}_preBuild(){const{options:t}=this;for(const e of["el","container"])t[e]=c(t[e]);this._root=(t=>{const{components:e,useAsButton:i,inline:o,appClass:n,theme:s,lockOpacity:r}=t.options,l=t=>t?"":'style="display:none" hidden',c=e=>t._t(e),h=a(`\n
\n\n ${i?"":''}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n
\n `),d=h.interaction;return d.options.find(t=>!t.hidden&&!t.classList.add("active")),d.type=()=>d.options.find(t=>t.classList.contains("active")),h})(this),t.useAsButton&&(this._root.button=t.el),t.container.appendChild(this._root.root)}_finalBuild(){const t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){const i=t.el.parentElement;t.el.nextSibling?i.insertBefore(e.app,t.el.nextSibling):i.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}_buildComponents(){const t=this,e=this.options.components,i=(t.options.sliders||"v").repeat(2),[o,n]=i.match(/^[vh]+$/g)?i:[],s=()=>this._color||(this._color=this._lastColor.clone()),r={palette:E({element:t._root.palette.picker,wrapper:t._root.palette.palette,onstop:()=>t._emit("changestop","slider",t),onchange(i,o){if(!e.palette)return;const n=s(),{_root:r,options:a}=t,{lastColor:l,currentColor:c}=r.preview;t._recalc&&(n.s=100*i,n.v=100-100*o,n.v<0&&(n.v=0),t._updateOutput("slider"));const h=n.toRGBA().toString(0);this.element.style.background=h,this.wrapper.style.background=`\n linear-gradient(to top, rgba(0, 0, 0, ${n.a}), transparent),\n linear-gradient(to left, hsla(${n.h}, 100%, 50%, ${n.a}), rgba(255, 255, 255, ${n.a}))\n `,a.comparison?a.useAsButton||t._lastColor||l.style.setProperty("--pcr-color",h):(r.button.style.setProperty("--pcr-color",h),r.button.classList.remove("clear"));const d=n.toHEXA().toString();for(const{el:e,color:i}of t._swatchColors)e.classList[d===i.toHEXA().toString()?"add":"remove"]("pcr-active");c.style.setProperty("--pcr-color",h)}}),hue:E({lock:"v"===n?"h":"v",element:t._root.hue.picker,wrapper:t._root.hue.slider,onstop:()=>t._emit("changestop","slider",t),onchange(i){if(!e.hue||!e.palette)return;const o=s();t._recalc&&(o.h=360*i),this.element.style.backgroundColor=`hsl(${o.h}, 100%, 50%)`,r.palette.trigger()}}),opacity:E({lock:"v"===o?"h":"v",element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onstop:()=>t._emit("changestop","slider",t),onchange(i){if(!e.opacity||!e.palette)return;const o=s();t._recalc&&(o.a=Math.round(100*i)/100),this.element.style.background=`rgba(0, 0, 0, ${o.a})`,r.palette.trigger()}}),selectable:M({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._recalc&&t._updateOutput("swatch")}})};this._components=r}_bindEvents(){const{_root:t,options:e}=this,i=[n(t.interaction.clear,"click",()=>this._clearColor()),n([t.interaction.cancel,t.preview.lastColor],"click",()=>{this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0),this._emit("cancel")}),n(t.interaction.save,"click",()=>{!this.applyColor()&&!e.showAlways&&this.hide()}),n(t.interaction.result,["keyup","input"],t=>{this.setColor(t.target.value,!0)&&!this._initializingActive&&(this._emit("change",this._color,"input",this),this._emit("changestop","input",this)),t.stopImmediatePropagation()}),n(t.interaction.result,["focus","blur"],t=>{this._recalc="blur"===t.type,this._recalc&&this._updateOutput(null)}),n([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],()=>this._recalc=!0,{passive:!0})];if(!e.showAlways){const o=e.closeWithKey;i.push(n(t.button,"click",()=>this.isOpen()?this.hide():this.show()),n(document,"keyup",t=>this.isOpen()&&(t.key===o||t.code===o)&&this.hide()),n(document,["touchstart","mousedown"],e=>{this.isOpen()&&!l(e).some(e=>e===t.app||e===t.button)&&this.hide()},{capture:!0}))}if(e.adjustableNumbers){const e={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};h(t.interaction.result,(t,i,o)=>{const n=e[this.getColorRepresentation().toLowerCase()];if(n){const e=n[o],s=t+(e>=100?1e3*i:i);return s<=0?0:Number((s{o.isOpen()&&(e.closeOnScroll&&o.hide(),null===t?(t=setTimeout(()=>t=null,100),requestAnimationFrame(function e(){o._rePositioningPicker(),null!==t&&requestAnimationFrame(e)})):(clearTimeout(t),t=setTimeout(()=>t=null,100)))},{capture:!0}))}this._eventBindings=i}_rePositioningPicker(){const{options:t}=this;if(!t.inline&&!this._nanopop.update({container:document.body.getBoundingClientRect(),position:t.position})){const t=this._root.app,e=t.getBoundingClientRect();t.style.top=(window.innerHeight-e.height)/2+"px",t.style.left=(window.innerWidth-e.width)/2+"px"}}_updateOutput(t){const{_root:e,_color:i,options:o}=this;if(e.interaction.type()){const t=`to${e.interaction.type().getAttribute("data-type")}`;e.interaction.result.value="function"==typeof i[t]?i[t]().toString(o.outputPrecision):""}!this._initializingActive&&this._recalc&&this._emit("change",i,t,this)}_clearColor(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{_root:e,options:i}=this;i.useAsButton||e.button.style.setProperty("--pcr-color","rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),i.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear"))}_parseLocalColor(t){const{values:e,type:i,a:o}=k(t),{lockOpacity:n}=this.options,s=void 0!==o&&1!==o;return e&&3===e.length&&(e[3]=void 0),{values:!e||n&&s?null:e,type:i}}_t(t){return this.options.i18n[t]||O.I18N_DEFAULTS[t]}_emit(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),o=1;ot(...i,this))}on(t,e){return this._eventListener[t].push(e),this}off(t,e){const i=this._eventListener[t]||[],o=i.indexOf(e);return~o&&i.splice(o,1),this}addSwatch(t){const{values:e}=this._parseLocalColor(t);if(e){const{_swatchColors:t,_root:i}=this,o=S(...e),s=r(`