@bpmn-io/properties-panel 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ All notable changes to [`@bpmn-io/properties-panel`](https://github.com/bpmn-io/
6
6
 
7
7
  ___Note:__ Yet to be released changes appear here._
8
8
 
9
+ ## 0.18.0
10
+
11
+ * `FEAT`: pass variables to FEEL editor ([#171](https://github.com/bpmn-io/properties-panel/pull/171))
12
+ * `FIX`: add error class to text area with error ([#165](https://github.com/bpmn-io/properties-panel/issues/165))
13
+ * `CHORE`: revert sticky headers ([#172](https://github.com/bpmn-io/properties-panel/pull/172))
14
+
9
15
  ## 0.17.0
10
16
 
11
17
  * `FEAT`: add `FeelEntry` component ([#158](https://github.com/bpmn-io/properties-panel/pull/158))
@@ -120,8 +120,11 @@
120
120
  overflow: hidden;
121
121
  }
122
122
 
123
- .bio-properties-panel * {
123
+ .bio-properties-panel {
124
124
  color: var(--text-base-color);
125
+ }
126
+
127
+ .bio-properties-panel * {
125
128
  font-size: var(--text-size-base);
126
129
  line-height: var(--text-line-height);
127
130
  font-weight: 400;
@@ -243,8 +246,14 @@
243
246
  justify-content: space-between;
244
247
  margin-bottom: -1px; /* avoid double borders */
245
248
  position: relative; /* browsers not supporting sticky */
246
- position: -webkit-sticky; /* for safari */
247
- position: sticky;
249
+
250
+ /**
251
+ * @pinussilvestrus Note: we exclude the sticky header feature until we
252
+ * find a proper fix for https://github.com/bpmn-io/bpmn-js-properties-panel/issues/726
253
+ */
254
+
255
+ /* position: -webkit-sticky; /* for safari */
256
+ /* position: sticky; */
248
257
  top: 0;
249
258
  z-index: 1;
250
259
  }
@@ -988,7 +997,7 @@ textarea.bio-properties-panel-input {
988
997
  background-color: var(--feel-indicator-background-color);
989
998
  border-right: 0px;
990
999
  border-radius: 2px 0 0 2px;
991
- z-index: 100;
1000
+ z-index: 1;
992
1001
  height: 100%;
993
1002
  width: 2em;
994
1003
  text-align: center;
package/dist/index.esm.js CHANGED
@@ -460,36 +460,10 @@ function useShowEntryEvent(id) {
460
460
 
461
461
  function useStickyIntersectionObserver(ref, scrollContainerSelector, setSticky) {
462
462
  useEffect(() => {
463
- // return early if IntersectionObserver is not available
464
- if (!IntersectionObserver) {
463
+
464
+ {
465
465
  return;
466
466
  }
467
-
468
- let observer;
469
-
470
- if (ref.current) {
471
- const scrollContainer = query(scrollContainerSelector);
472
- observer = new IntersectionObserver(entries => {
473
- if (entries[0].intersectionRatio < 1) {
474
- setSticky(true);
475
- } else if (entries[0].intersectionRatio === 1) {
476
- setSticky(false);
477
- }
478
- }, {
479
- root: scrollContainer,
480
- rootMargin: '0px 0px 999999% 0px',
481
- // Use bottom margin to avoid stickyness when scrolling out to bottom
482
- threshold: [1]
483
- });
484
- observer.observe(ref.current);
485
- } // Unobserve if unmounted
486
-
487
-
488
- return () => {
489
- if (ref.current && observer) {
490
- observer.unobserve(ref.current);
491
- }
492
- };
493
467
  }, [ref]);
494
468
  }
495
469
 
@@ -549,7 +523,7 @@ function Group(props) {
549
523
  setEdited(hasOneEditedEntry);
550
524
  }, [entries]); // set css class when group is sticky to top
551
525
 
552
- useStickyIntersectionObserver(groupRef, 'div.bio-properties-panel-scroll-container', setSticky);
526
+ useStickyIntersectionObserver(groupRef);
553
527
  const propertiesPanelContext = { ...useContext(LayoutContext),
554
528
  onShow
555
529
  };
@@ -1126,7 +1100,7 @@ function ListGroup(props) {
1126
1100
  }
1127
1101
  }, [items, shouldHandleEffects]); // set css class when group is sticky to top
1128
1102
 
1129
- useStickyIntersectionObserver(groupRef, 'div.bio-properties-panel-scroll-container', setSticky);
1103
+ useStickyIntersectionObserver(groupRef);
1130
1104
 
1131
1105
  const toggleOpen = () => setOpen(!open);
1132
1106
 
@@ -1409,6 +1383,10 @@ Find the code point at the given position in a string (like the
1409
1383
  [`codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
1410
1384
  string method).
1411
1385
  */function codePointAt(str,pos){let code0=str.charCodeAt(pos);if(!surrogateHigh(code0)||pos+1==str.length)return code0;let code1=str.charCodeAt(pos+1);if(!surrogateLow(code1))return code0;return (code0-0xd800<<10)+(code1-0xdc00)+0x10000;}/**
1386
+ Given a Unicode codepoint, return the JavaScript string that
1387
+ respresents it (like
1388
+ [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)).
1389
+ */function fromCodePoint(code){if(code<=0xffff)return String.fromCharCode(code);code-=0x10000;return String.fromCharCode((code>>10)+0xd800,(code&1023)+0xdc00);}/**
1412
1390
  The amount of positions a character takes up a JavaScript string.
1413
1391
  */function codePointSize(code){return code<0x10000?1:2;}const DefaultSplit=/\r\n?|\n/;/**
1414
1392
  Distinguishes different ways in which positions can be mapped.
@@ -1880,7 +1858,7 @@ collaborative editing.
1880
1858
  */Transaction.remote=/*@__PURE__*/Annotation.define();function joinRanges(a,b){let result=[];for(let iA=0,iB=0;;){let from,to;if(iA<a.length&&(iB==b.length||b[iB]>=a[iA])){from=a[iA++];to=a[iA++];}else if(iB<b.length){from=b[iB++];to=b[iB++];}else return result;if(!result.length||result[result.length-1]<from)result.push(from,to);else if(result[result.length-1]<to)result[result.length-1]=to;}}function mergeTransaction(a,b,sequential){var _a;let mapForA,mapForB,changes;if(sequential){mapForA=b.changes;mapForB=ChangeSet.empty(b.changes.length);changes=a.changes.compose(b.changes);}else {mapForA=b.changes.map(a.changes);mapForB=a.changes.mapDesc(b.changes,true);changes=a.changes.compose(mapForA);}return {changes,selection:b.selection?b.selection.map(mapForB):(_a=a.selection)===null||_a===void 0?void 0:_a.map(mapForA),effects:StateEffect.mapEffects(a.effects,mapForA).concat(StateEffect.mapEffects(b.effects,mapForB)),annotations:a.annotations.length?a.annotations.concat(b.annotations):b.annotations,scrollIntoView:a.scrollIntoView||b.scrollIntoView};}function resolveTransactionInner(state,spec,docSize){let sel=spec.selection,annotations=asArray(spec.annotations);if(spec.userEvent)annotations=annotations.concat(Transaction.userEvent.of(spec.userEvent));return {changes:spec.changes instanceof ChangeSet?spec.changes:ChangeSet.of(spec.changes||[],docSize,state.facet(lineSeparator)),selection:sel&&(sel instanceof EditorSelection?sel:EditorSelection.single(sel.anchor,sel.head)),effects:asArray(spec.effects),annotations,scrollIntoView:!!spec.scrollIntoView};}function resolveTransaction(state,specs,filter){let s=resolveTransactionInner(state,specs.length?specs[0]:{},state.doc.length);if(specs.length&&specs[0].filter===false)filter=false;for(let i=1;i<specs.length;i++){if(specs[i].filter===false)filter=false;let seq=!!specs[i].sequential;s=mergeTransaction(s,resolveTransactionInner(state,specs[i],seq?s.changes.newLength:state.doc.length),seq);}let tr=Transaction.create(state,s.changes,s.selection,s.effects,s.annotations,s.scrollIntoView);return extendTransaction(filter?filterTransaction(tr):tr);}// Finish a transaction by applying filters if necessary.
1881
1859
  function filterTransaction(tr){let state=tr.startState;// Change filters
1882
1860
  let result=true;for(let filter of state.facet(changeFilter)){let value=filter(tr);if(value===false){result=false;break;}if(Array.isArray(value))result=result===true?value:joinRanges(result,value);}if(result!==true){let changes,back;if(result===false){back=tr.changes.invertedDesc;changes=ChangeSet.empty(state.doc.length);}else {let filtered=tr.changes.filter(result);changes=filtered.changes;back=filtered.filtered.invertedDesc;}tr=Transaction.create(state,changes,tr.selection&&tr.selection.map(back),StateEffect.mapEffects(tr.effects,back),tr.annotations,tr.scrollIntoView);}// Transaction filters
1883
- let filters=state.facet(transactionFilter);for(let i=filters.length-1;i>=0;i--){let filtered=filters[i](tr);if(filtered instanceof Transaction)tr=filtered;else if(Array.isArray(filtered)&&filtered.length==1&&filtered[0]instanceof Transaction)tr=filtered[0];else tr=resolveTransaction(state,asArray(filtered),false);}return tr;}function extendTransaction(tr){let state=tr.startState,extenders=state.facet(transactionExtender),spec=tr;for(let i=extenders.length-1;i>=0;i--){let extension=extenders[i](tr);if(extension&&Object.keys(extension).length)spec=mergeTransaction(tr,resolveTransactionInner(state,extension,tr.changes.newLength),true);}return spec==tr?tr:Transaction.create(state,tr.changes,tr.selection,spec.effects,spec.annotations,spec.scrollIntoView);}const none=[];function asArray(value){return value==null?none:Array.isArray(value)?value:[value];}/**
1861
+ let filters=state.facet(transactionFilter);for(let i=filters.length-1;i>=0;i--){let filtered=filters[i](tr);if(filtered instanceof Transaction)tr=filtered;else if(Array.isArray(filtered)&&filtered.length==1&&filtered[0]instanceof Transaction)tr=filtered[0];else tr=resolveTransaction(state,asArray(filtered),false);}return tr;}function extendTransaction(tr){let state=tr.startState,extenders=state.facet(transactionExtender),spec=tr;for(let i=extenders.length-1;i>=0;i--){let extension=extenders[i](tr);if(extension&&Object.keys(extension).length)spec=mergeTransaction(tr,resolveTransactionInner(state,extension,tr.changes.newLength),true);}return spec==tr?tr:Transaction.create(state,tr.changes,tr.selection,spec.effects,spec.annotations,spec.scrollIntoView);}const none$1=[];function asArray(value){return value==null?none$1:Array.isArray(value)?value:[value];}/**
1884
1862
  The categories produced by a [character
1885
1863
  categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used
1886
1864
  do things like selecting by word.
@@ -2434,7 +2412,7 @@ merge(from,to,source,hasStart,openStart,openEnd){if(source){if(!(source instance
2434
2412
  addLineDeco(deco){let attrs=deco.spec.attributes,cls=deco.spec.class;if(attrs)this.attrs=combineAttrs(attrs,this.attrs||{});if(cls)this.attrs=combineAttrs({class:cls},this.attrs||{});}domAtPos(pos){return inlineDOMAtPos(this.dom,this.children,pos);}reuseDOM(node){if(node.nodeName=="DIV"){this.setDOM(node);this.dirty|=4/* Attrs */|2/* Node */;}}sync(track){var _a;if(!this.dom){this.setDOM(document.createElement("div"));this.dom.className="cm-line";this.prevAttrs=this.attrs?null:undefined;}else if(this.dirty&4/* Attrs */){clearAttributes(this.dom);this.dom.className="cm-line";this.prevAttrs=this.attrs?null:undefined;}if(this.prevAttrs!==undefined){updateAttrs(this.dom,this.prevAttrs,this.attrs);this.dom.classList.add("cm-line");this.prevAttrs=undefined;}super.sync(track);let last=this.dom.lastChild;while(last&&ContentView.get(last)instanceof MarkView)last=last.lastChild;if(!last||!this.length||last.nodeName!="BR"&&((_a=ContentView.get(last))===null||_a===void 0?void 0:_a.isEditable)==false&&(!browser.ios||!this.children.some(ch=>ch instanceof TextView))){let hack=document.createElement("BR");hack.cmIgnore=true;this.dom.appendChild(hack);}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let totalWidth=0;for(let child of this.children){if(!(child instanceof TextView))return null;let rects=clientRectsFor(child.dom);if(rects.length!=1)return null;totalWidth+=rects[0].width;}return {lineHeight:this.dom.getBoundingClientRect().height,charWidth:totalWidth/this.length};}coordsAt(pos,side){return coordsInChildren(this,pos,side);}become(_other){return false;}get type(){return BlockType.Text;}static find(docView,pos){for(let i=0,off=0;i<docView.children.length;i++){let block=docView.children[i],end=off+block.length;if(end>=pos){if(block instanceof LineView)return block;if(end>pos)break;}off=end+block.breakAfter;}return null;}}class BlockWidgetView extends ContentView{constructor(widget,length,type){super();this.widget=widget;this.length=length;this.type=type;this.breakAfter=0;this.prevWidget=null;}merge(from,to,source,_takeDeco,openStart,openEnd){if(source&&(!(source instanceof BlockWidgetView)||!this.widget.compare(source.widget)||from>0&&openStart<=0||to<this.length&&openEnd<=0))return false;this.length=from+(source?source.length:0)+(this.length-to);return true;}domAtPos(pos){return pos==0?DOMPos.before(this.dom):DOMPos.after(this.dom,pos==this.length);}split(at){let len=this.length-at;this.length=at;let end=new BlockWidgetView(this.widget,len,this.type);end.breakAfter=this.breakAfter;return end;}get children(){return noChildren;}sync(){if(!this.dom||!this.widget.updateDOM(this.dom)){if(this.dom&&this.prevWidget)this.prevWidget.destroy(this.dom);this.prevWidget=null;this.setDOM(this.widget.toDOM(this.editorView));this.dom.contentEditable="false";}}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Text.empty;}domBoundsAround(){return null;}become(other){if(other instanceof BlockWidgetView&&other.type==this.type&&other.widget.constructor==this.widget.constructor){if(!other.widget.eq(this.widget))this.markDirty(true);if(this.dom&&!this.prevWidget)this.prevWidget=this.widget;this.widget=other.widget;this.length=other.length;this.breakAfter=other.breakAfter;return true;}return false;}ignoreMutation(){return true;}ignoreEvent(event){return this.widget.ignoreEvent(event);}destroy(){super.destroy();if(this.dom)this.widget.destroy(this.dom);}}class ContentBuilder{constructor(doc,pos,end,disallowBlockEffectsFor){this.doc=doc;this.pos=pos;this.end=end;this.disallowBlockEffectsFor=disallowBlockEffectsFor;this.content=[];this.curLine=null;this.breakAtStart=0;this.pendingBuffer=0/* No */;// Set to false directly after a widget that covers the position after it
2435
2413
  this.atCursorPos=true;this.openStart=-1;this.openEnd=-1;this.text="";this.textOff=0;this.cursor=doc.iter();this.skip=pos;}posCovered(){if(this.content.length==0)return !this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let last=this.content[this.content.length-1];return !last.breakAfter&&!(last instanceof BlockWidgetView&&last.type==BlockType.WidgetBefore);}getLine(){if(!this.curLine){this.content.push(this.curLine=new LineView());this.atCursorPos=true;}return this.curLine;}flushBuffer(active){if(this.pendingBuffer){this.curLine.append(wrapMarks(new WidgetBufferView(-1),active),active.length);this.pendingBuffer=0/* No */;}}addBlockWidget(view){this.flushBuffer([]);this.curLine=null;this.content.push(view);}finish(openEnd){if(!openEnd)this.flushBuffer([]);else this.pendingBuffer=0/* No */;if(!this.posCovered())this.getLine();}buildText(length,active,openStart){while(length>0){if(this.textOff==this.text.length){let{value,lineBreak,done}=this.cursor.next(this.skip);this.skip=0;if(done)throw new Error("Ran out of text content when drawing inline views");if(lineBreak){if(!this.posCovered())this.getLine();if(this.content.length)this.content[this.content.length-1].breakAfter=1;else this.breakAtStart=1;this.flushBuffer([]);this.curLine=null;length--;continue;}else {this.text=value;this.textOff=0;}}let take=Math.min(this.text.length-this.textOff,length,512/* Chunk */);this.flushBuffer(active.slice(0,openStart));this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff,this.textOff+take)),active),openStart);this.atCursorPos=true;this.textOff+=take;length-=take;openStart=0;}}span(from,to,active,openStart){this.buildText(to-from,active,openStart);this.pos=to;if(this.openStart<0)this.openStart=openStart;}point(from,to,deco,active,openStart,index){if(this.disallowBlockEffectsFor[index]&&deco instanceof PointDecoration){if(deco.block)throw new RangeError("Block decorations may not be specified via plugins");if(to>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins");}let len=to-from;if(deco instanceof PointDecoration){if(deco.block){let{type}=deco;if(type==BlockType.WidgetAfter&&!this.posCovered())this.getLine();this.addBlockWidget(new BlockWidgetView(deco.widget||new NullWidget("div"),len,type));}else {let view=WidgetView.create(deco.widget||new NullWidget("span"),len,deco.startSide);let cursorBefore=this.atCursorPos&&!view.isEditable&&openStart<=active.length&&(from<to||deco.startSide>0);let cursorAfter=!view.isEditable&&(from<to||deco.startSide<=0);let line=this.getLine();if(this.pendingBuffer==2/* IfCursor */&&!cursorBefore)this.pendingBuffer=0/* No */;this.flushBuffer(active);if(cursorBefore){line.append(wrapMarks(new WidgetBufferView(1),active),openStart);openStart=active.length+Math.max(0,openStart-active.length);}line.append(wrapMarks(view,active),openStart);this.atCursorPos=cursorAfter;this.pendingBuffer=!cursorAfter?0/* No */:from<to?1/* Yes */:2/* IfCursor */;}}else if(this.doc.lineAt(this.pos).from==this.pos){// Line decoration
2436
2414
  this.getLine().addLineDeco(deco);}if(len){// Advance the iterator past the replaced content
2437
- if(this.textOff+len<=this.text.length){this.textOff+=len;}else {this.skip+=len-(this.text.length-this.textOff);this.text="";this.textOff=0;}this.pos=to;}if(this.openStart<0)this.openStart=openStart;}static build(text,from,to,decorations,dynamicDecorationMap){let builder=new ContentBuilder(text,from,to,dynamicDecorationMap);builder.openEnd=RangeSet.spans(decorations,from,to,builder);if(builder.openStart<0)builder.openStart=builder.openEnd;builder.finish(builder.openEnd);return builder;}}function wrapMarks(view,active){for(let mark of active)view=new MarkView(mark,[view],view.length);return view;}class NullWidget extends WidgetType{constructor(tag){super();this.tag=tag;}eq(other){return other.tag==this.tag;}toDOM(){return document.createElement(this.tag);}updateDOM(elt){return elt.nodeName.toLowerCase()==this.tag;}}const clickAddsSelectionRange=/*@__PURE__*/Facet.define();const dragMovesSelection$1=/*@__PURE__*/Facet.define();const mouseSelectionStyle=/*@__PURE__*/Facet.define();const exceptionSink=/*@__PURE__*/Facet.define();const updateListener=/*@__PURE__*/Facet.define();const inputHandler=/*@__PURE__*/Facet.define();const perLineTextDirection=/*@__PURE__*/Facet.define({combine:values=>values.some(x=>x)});class ScrollTarget{constructor(range,y="nearest",x="nearest",yMargin=5,xMargin=5){this.range=range;this.y=y;this.x=x;this.yMargin=yMargin;this.xMargin=xMargin;}map(changes){return changes.empty?this:new ScrollTarget(this.range.map(changes),this.y,this.x,this.yMargin,this.xMargin);}}const scrollIntoView=/*@__PURE__*/StateEffect.define({map:(t,ch)=>t.map(ch)});/**
2415
+ if(this.textOff+len<=this.text.length){this.textOff+=len;}else {this.skip+=len-(this.text.length-this.textOff);this.text="";this.textOff=0;}this.pos=to;}if(this.openStart<0)this.openStart=openStart;}static build(text,from,to,decorations,dynamicDecorationMap){let builder=new ContentBuilder(text,from,to,dynamicDecorationMap);builder.openEnd=RangeSet.spans(decorations,from,to,builder);if(builder.openStart<0)builder.openStart=builder.openEnd;builder.finish(builder.openEnd);return builder;}}function wrapMarks(view,active){for(let mark of active)view=new MarkView(mark,[view],view.length);return view;}class NullWidget extends WidgetType{constructor(tag){super();this.tag=tag;}eq(other){return other.tag==this.tag;}toDOM(){return document.createElement(this.tag);}updateDOM(elt){return elt.nodeName.toLowerCase()==this.tag;}}const clickAddsSelectionRange=/*@__PURE__*/Facet.define();const dragMovesSelection$1=/*@__PURE__*/Facet.define();const mouseSelectionStyle=/*@__PURE__*/Facet.define();const exceptionSink=/*@__PURE__*/Facet.define();const updateListener=/*@__PURE__*/Facet.define();const inputHandler=/*@__PURE__*/Facet.define();const perLineTextDirection=/*@__PURE__*/Facet.define({combine:values=>values.some(x=>x)});class ScrollTarget{constructor(range,y="nearest",x="nearest",yMargin=5,xMargin=5){this.range=range;this.y=y;this.x=x;this.yMargin=yMargin;this.xMargin=xMargin;}map(changes){return changes.empty?this:new ScrollTarget(this.range.map(changes),this.y,this.x,this.yMargin,this.xMargin);}}const scrollIntoView$1=/*@__PURE__*/StateEffect.define({map:(t,ch)=>t.map(ch)});/**
2438
2416
  Log or report an unhandled exception in client code. Should
2439
2417
  probably only be used by extension code that allows client code to
2440
2418
  provide functions, and calls those functions in a context where an
@@ -2952,7 +2930,7 @@ transactions for editing actions.
2952
2930
  [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
2953
2931
  as a primitive.
2954
2932
  */update(transactions){if(this.updateState!=0/* Idle */)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let redrawn=false,attrsChanged=false,update;let state=this.state;for(let tr of transactions){if(tr.startState!=state)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");state=tr.state;}if(this.destroyed){this.viewState.state=state;return;}this.observer.clear();// When the phrases change, redraw the editor
2955
- if(state.facet(EditorState.phrases)!=this.state.facet(EditorState.phrases))return this.setState(state);update=ViewUpdate.create(this,state,transactions);let scrollTarget=this.viewState.scrollTarget;try{this.updateState=2/* Updating */;for(let tr of transactions){if(scrollTarget)scrollTarget=scrollTarget.map(tr.changes);if(tr.scrollIntoView){let{main}=tr.state.selection;scrollTarget=new ScrollTarget(main.empty?main:EditorSelection.cursor(main.head,main.head>main.anchor?-1:1));}for(let e of tr.effects)if(e.is(scrollIntoView))scrollTarget=e.value;}this.viewState.update(update,scrollTarget);this.bidiCache=CachedOrder.update(this.bidiCache,update.changes);if(!update.empty){this.updatePlugins(update);this.inputState.update(update);}redrawn=this.docView.update(update);if(this.state.facet(styleModule)!=this.styleModules)this.mountStyles();attrsChanged=this.updateAttrs();this.showAnnouncements(transactions);this.docView.updateSelection(redrawn,transactions.some(tr=>tr.isUserEvent("select.pointer")));}finally{this.updateState=0/* Idle */;}if(update.startState.facet(theme$1)!=update.state.facet(theme$1))this.viewState.mustMeasureContent=true;if(redrawn||attrsChanged||scrollTarget||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)this.requestMeasure();if(!update.empty)for(let listener of this.state.facet(updateListener))listener(update);}/**
2933
+ if(state.facet(EditorState.phrases)!=this.state.facet(EditorState.phrases))return this.setState(state);update=ViewUpdate.create(this,state,transactions);let scrollTarget=this.viewState.scrollTarget;try{this.updateState=2/* Updating */;for(let tr of transactions){if(scrollTarget)scrollTarget=scrollTarget.map(tr.changes);if(tr.scrollIntoView){let{main}=tr.state.selection;scrollTarget=new ScrollTarget(main.empty?main:EditorSelection.cursor(main.head,main.head>main.anchor?-1:1));}for(let e of tr.effects)if(e.is(scrollIntoView$1))scrollTarget=e.value;}this.viewState.update(update,scrollTarget);this.bidiCache=CachedOrder.update(this.bidiCache,update.changes);if(!update.empty){this.updatePlugins(update);this.inputState.update(update);}redrawn=this.docView.update(update);if(this.state.facet(styleModule)!=this.styleModules)this.mountStyles();attrsChanged=this.updateAttrs();this.showAnnouncements(transactions);this.docView.updateSelection(redrawn,transactions.some(tr=>tr.isUserEvent("select.pointer")));}finally{this.updateState=0/* Idle */;}if(update.startState.facet(theme$1)!=update.state.facet(theme$1))this.viewState.mustMeasureContent=true;if(redrawn||attrsChanged||scrollTarget||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)this.requestMeasure();if(!update.empty)for(let listener of this.state.facet(updateListener))listener(update);}/**
2956
2934
  Reset the view to the given state. (This will cause the entire
2957
2935
  document to be redrawn and all view plugins to be reinitialized,
2958
2936
  so you should probably only use it when the new state isn't
@@ -3108,7 +3086,7 @@ return (document.hasFocus()||browser.safari&&((_a=this.inputState)===null||_a===
3108
3086
  Returns an effect that can be
3109
3087
  [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to
3110
3088
  cause it to scroll the given position or range into view.
3111
- */static scrollIntoView(pos,options={}){return scrollIntoView.of(new ScrollTarget(typeof pos=="number"?EditorSelection.cursor(pos):pos,options.y,options.x,options.yMargin,options.xMargin));}/**
3089
+ */static scrollIntoView(pos,options={}){return scrollIntoView$1.of(new ScrollTarget(typeof pos=="number"?EditorSelection.cursor(pos):pos,options.y,options.x,options.yMargin,options.xMargin));}/**
3112
3090
  Returns an extension that can be used to add DOM event handlers.
3113
3091
  The value should be an object mapping event names to handler
3114
3092
  functions. For any given event, such functions are ordered by
@@ -3251,9 +3229,9 @@ for a given key, no further handlers are called.
3251
3229
  */const keymap=/*@__PURE__*/Facet.define({enables:handleKeyEvents});const Keymaps=/*@__PURE__*/new WeakMap();// This is hidden behind an indirection, rather than directly computed
3252
3230
  // by the facet, to keep internal types out of the facet's type.
3253
3231
  function getKeymap(state){let bindings=state.facet(keymap);let map=Keymaps.get(bindings);if(!map)Keymaps.set(bindings,map=buildKeymap(bindings.reduce((a,b)=>a.concat(b),[])));return map;}let storedPrefix=null;const PrefixTimeout=4000;function buildKeymap(bindings,platform=currentPlatform){let bound=Object.create(null);let isPrefix=Object.create(null);let checkPrefix=(name,is)=>{let current=isPrefix[name];if(current==null)isPrefix[name]=is;else if(current!=is)throw new Error("Key binding "+name+" is used both as a regular binding and as a multi-stroke prefix");};let add=(scope,key,command,preventDefault)=>{let scopeObj=bound[scope]||(bound[scope]=Object.create(null));let parts=key.split(/ (?!$)/).map(k=>normalizeKeyName(k,platform));for(let i=1;i<parts.length;i++){let prefix=parts.slice(0,i).join(" ");checkPrefix(prefix,true);if(!scopeObj[prefix])scopeObj[prefix]={preventDefault:true,commands:[view=>{let ourObj=storedPrefix={view,prefix,scope};setTimeout(()=>{if(storedPrefix==ourObj)storedPrefix=null;},PrefixTimeout);return true;}]};}let full=parts.join(" ");checkPrefix(full,false);let binding=scopeObj[full]||(scopeObj[full]={preventDefault:false,commands:[]});binding.commands.push(command);if(preventDefault)binding.preventDefault=true;};for(let b of bindings){let name=b[platform]||b.key;if(!name)continue;for(let scope of b.scope?b.scope.split(" "):["editor"]){add(scope,name,b.run,b.preventDefault);if(b.shift)add(scope,"Shift-"+name,b.shift,b.preventDefault);}}return bound;}function runHandlers(map,event,view,scope){let name=keyName(event),isChar=name.length==1&&name!=" ";let prefix="",fallthrough=false;if(storedPrefix&&storedPrefix.view==view&&storedPrefix.scope==scope){prefix=storedPrefix.prefix+" ";if(fallthrough=modifierCodes.indexOf(event.keyCode)<0)storedPrefix=null;}let runFor=binding=>{if(binding){for(let cmd of binding.commands)if(cmd(view))return true;if(binding.preventDefault)fallthrough=true;}return false;};let scopeObj=map[scope],baseName;if(scopeObj){if(runFor(scopeObj[prefix+modifiers(name,event,!isChar)]))return true;if(isChar&&(event.shiftKey||event.altKey||event.metaKey)&&(baseName=base[event.keyCode])&&baseName!=name){if(runFor(scopeObj[prefix+modifiers(baseName,event,true)]))return true;}else if(isChar&&event.shiftKey){if(runFor(scopeObj[prefix+modifiers(name,event,true)]))return true;}}return fallthrough;}const Outside="-10000px";class TooltipViewManager{constructor(view,facet,createTooltipView){this.facet=facet;this.createTooltipView=createTooltipView;this.input=view.state.facet(facet);this.tooltips=this.input.filter(t=>t);this.tooltipViews=this.tooltips.map(createTooltipView);}update(update){let input=update.state.facet(this.facet);let tooltips=input.filter(x=>x);if(input===this.input){for(let t of this.tooltipViews)if(t.update)t.update(update);return false;}let tooltipViews=[];for(let i=0;i<tooltips.length;i++){let tip=tooltips[i],known=-1;if(!tip)continue;for(let i=0;i<this.tooltips.length;i++){let other=this.tooltips[i];if(other&&other.create==tip.create)known=i;}if(known<0){tooltipViews[i]=this.createTooltipView(tip);}else {let tooltipView=tooltipViews[i]=this.tooltipViews[known];if(tooltipView.update)tooltipView.update(update);}}for(let t of this.tooltipViews)if(tooltipViews.indexOf(t)<0)t.dom.remove();this.input=input;this.tooltips=tooltips;this.tooltipViews=tooltipViews;return true;}}function windowSpace(){return {top:0,left:0,bottom:innerHeight,right:innerWidth};}const tooltipConfig=/*@__PURE__*/Facet.define({combine:values=>{var _a,_b,_c;return {position:browser.ios?"absolute":((_a=values.find(conf=>conf.position))===null||_a===void 0?void 0:_a.position)||"fixed",parent:((_b=values.find(conf=>conf.parent))===null||_b===void 0?void 0:_b.parent)||null,tooltipSpace:((_c=values.find(conf=>conf.tooltipSpace))===null||_c===void 0?void 0:_c.tooltipSpace)||windowSpace};}});const tooltipPlugin=/*@__PURE__*/ViewPlugin.fromClass(class{constructor(view){var _a;this.view=view;this.inView=true;this.lastTransaction=0;this.measureTimeout=-1;let config=view.state.facet(tooltipConfig);this.position=config.position;this.parent=config.parent;this.classes=view.themeClasses;this.createContainer();this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this};this.manager=new TooltipViewManager(view,showTooltip,t=>this.createTooltip(t));this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(entries=>{if(Date.now()>this.lastTransaction-50&&entries.length>0&&entries[entries.length-1].intersectionRatio<1)this.measureSoon();},{threshold:[1]}):null;this.observeIntersection();(_a=view.dom.ownerDocument.defaultView)===null||_a===void 0?void 0:_a.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this));this.maybeMeasure();}createContainer(){if(this.parent){this.container=document.createElement("div");this.container.style.position="relative";this.container.className=this.view.themeClasses;this.parent.appendChild(this.container);}else {this.container=this.view.dom;}}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let tooltip of this.manager.tooltipViews)this.intersectionObserver.observe(tooltip.dom);}}measureSoon(){if(this.measureTimeout<0)this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1;this.maybeMeasure();},50);}update(update){if(update.transactions.length)this.lastTransaction=Date.now();let updated=this.manager.update(update);if(updated)this.observeIntersection();let shouldMeasure=updated||update.geometryChanged;let newConfig=update.state.facet(tooltipConfig);if(newConfig.position!=this.position){this.position=newConfig.position;for(let t of this.manager.tooltipViews)t.dom.style.position=this.position;shouldMeasure=true;}if(newConfig.parent!=this.parent){if(this.parent)this.container.remove();this.parent=newConfig.parent;this.createContainer();for(let t of this.manager.tooltipViews)this.container.appendChild(t.dom);shouldMeasure=true;}else if(this.parent&&this.view.themeClasses!=this.classes){this.classes=this.container.className=this.view.themeClasses;}if(shouldMeasure)this.maybeMeasure();}createTooltip(tooltip){let tooltipView=tooltip.create(this.view);tooltipView.dom.classList.add("cm-tooltip");if(tooltip.arrow&&!tooltipView.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let arrow=document.createElement("div");arrow.className="cm-tooltip-arrow";tooltipView.dom.appendChild(arrow);}tooltipView.dom.style.position=this.position;tooltipView.dom.style.top=Outside;this.container.appendChild(tooltipView.dom);if(tooltipView.mount)tooltipView.mount(this.view);return tooltipView;}destroy(){var _a,_b;(_a=this.view.dom.ownerDocument.defaultView)===null||_a===void 0?void 0:_a.removeEventListener("resize",this.measureSoon);for(let{dom}of this.manager.tooltipViews)dom.remove();(_b=this.intersectionObserver)===null||_b===void 0?void 0:_b.disconnect();clearTimeout(this.measureTimeout);}readMeasure(){let editor=this.view.dom.getBoundingClientRect();return {editor,parent:this.parent?this.container.getBoundingClientRect():editor,pos:this.manager.tooltips.map((t,i)=>{let tv=this.manager.tooltipViews[i];return tv.getCoords?tv.getCoords(t.pos):this.view.coordsAtPos(t.pos);}),size:this.manager.tooltipViews.map(({dom})=>dom.getBoundingClientRect()),space:this.view.state.facet(tooltipConfig).tooltipSpace(this.view)};}writeMeasure(measured){let{editor,space}=measured;let others=[];for(let i=0;i<this.manager.tooltips.length;i++){let tooltip=this.manager.tooltips[i],tView=this.manager.tooltipViews[i],{dom}=tView;let pos=measured.pos[i],size=measured.size[i];// Hide tooltips that are outside of the editor.
3254
- if(!pos||pos.bottom<=Math.max(editor.top,space.top)||pos.top>=Math.min(editor.bottom,space.bottom)||pos.right<Math.max(editor.left,space.left)-.1||pos.left>Math.min(editor.right,space.right)+.1){dom.style.top=Outside;continue;}let arrow=tooltip.arrow?tView.dom.querySelector(".cm-tooltip-arrow"):null;let arrowHeight=arrow?7/* Size */:0;let width=size.right-size.left,height=size.bottom-size.top;let offset=tView.offset||noOffset,ltr=this.view.textDirection==Direction.LTR;let left=size.width>space.right-space.left?ltr?space.left:space.right-size.width:ltr?Math.min(pos.left-(arrow?14/* Offset */:0)+offset.x,space.right-width):Math.max(space.left,pos.left-width+(arrow?14/* Offset */:0)-offset.x);let above=!!tooltip.above;if(!tooltip.strictSide&&(above?pos.top-(size.bottom-size.top)-offset.y<space.top:pos.bottom+(size.bottom-size.top)+offset.y>space.bottom)&&above==space.bottom-pos.bottom>pos.top-space.top)above=!above;let top=above?pos.top-height-arrowHeight-offset.y:pos.bottom+arrowHeight+offset.y;let right=left+width;if(tView.overlap!==true)for(let r of others)if(r.left<right&&r.right>left&&r.top<top+height&&r.bottom>top)top=above?r.top-height-2-arrowHeight:r.bottom+arrowHeight+2;if(this.position=="absolute"){dom.style.top=top-measured.parent.top+"px";dom.style.left=left-measured.parent.left+"px";}else {dom.style.top=top+"px";dom.style.left=left+"px";}if(arrow)arrow.style.left=`${pos.left+(ltr?offset.x:-offset.x)-(left+14/* Offset */-7/* Size */)}px`;if(tView.overlap!==true)others.push({left,top,right,bottom:top+height});dom.classList.toggle("cm-tooltip-above",above);dom.classList.toggle("cm-tooltip-below",!above);if(tView.positioned)tView.positioned();}}maybeMeasure(){if(this.manager.tooltips.length){if(this.view.inView)this.view.requestMeasure(this.measureReq);if(this.inView!=this.view.inView){this.inView=this.view.inView;if(!this.inView)for(let tv of this.manager.tooltipViews)tv.dom.style.top=Outside;}}}},{eventHandlers:{scroll(){this.maybeMeasure();}}});const baseTheme$2=/*@__PURE__*/EditorView.baseTheme({".cm-tooltip":{zIndex:100},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:`${7/* Size */}px`,width:`${7/* Size */*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:`${7/* Size */}px solid transparent`,borderRight:`${7/* Size */}px solid transparent`},".cm-tooltip-above &":{bottom:`-${7/* Size */}px`,"&:before":{borderTop:`${7/* Size */}px solid #bbb`},"&:after":{borderTop:`${7/* Size */}px solid #f5f5f5`,bottom:"1px"}},".cm-tooltip-below &":{top:`-${7/* Size */}px`,"&:before":{borderBottom:`${7/* Size */}px solid #bbb`},"&:after":{borderBottom:`${7/* Size */}px solid #f5f5f5`,top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}});const noOffset={x:0,y:0};/**
3232
+ if(!pos||pos.bottom<=Math.max(editor.top,space.top)||pos.top>=Math.min(editor.bottom,space.bottom)||pos.right<Math.max(editor.left,space.left)-.1||pos.left>Math.min(editor.right,space.right)+.1){dom.style.top=Outside;continue;}let arrow=tooltip.arrow?tView.dom.querySelector(".cm-tooltip-arrow"):null;let arrowHeight=arrow?7/* Size */:0;let width=size.right-size.left,height=size.bottom-size.top;let offset=tView.offset||noOffset,ltr=this.view.textDirection==Direction.LTR;let left=size.width>space.right-space.left?ltr?space.left:space.right-size.width:ltr?Math.min(pos.left-(arrow?14/* Offset */:0)+offset.x,space.right-width):Math.max(space.left,pos.left-width+(arrow?14/* Offset */:0)-offset.x);let above=!!tooltip.above;if(!tooltip.strictSide&&(above?pos.top-(size.bottom-size.top)-offset.y<space.top:pos.bottom+(size.bottom-size.top)+offset.y>space.bottom)&&above==space.bottom-pos.bottom>pos.top-space.top)above=!above;let top=above?pos.top-height-arrowHeight-offset.y:pos.bottom+arrowHeight+offset.y;let right=left+width;if(tView.overlap!==true)for(let r of others)if(r.left<right&&r.right>left&&r.top<top+height&&r.bottom>top)top=above?r.top-height-2-arrowHeight:r.bottom+arrowHeight+2;if(this.position=="absolute"){dom.style.top=top-measured.parent.top+"px";dom.style.left=left-measured.parent.left+"px";}else {dom.style.top=top+"px";dom.style.left=left+"px";}if(arrow)arrow.style.left=`${pos.left+(ltr?offset.x:-offset.x)-(left+14/* Offset */-7/* Size */)}px`;if(tView.overlap!==true)others.push({left,top,right,bottom:top+height});dom.classList.toggle("cm-tooltip-above",above);dom.classList.toggle("cm-tooltip-below",!above);if(tView.positioned)tView.positioned();}}maybeMeasure(){if(this.manager.tooltips.length){if(this.view.inView)this.view.requestMeasure(this.measureReq);if(this.inView!=this.view.inView){this.inView=this.view.inView;if(!this.inView)for(let tv of this.manager.tooltipViews)tv.dom.style.top=Outside;}}}},{eventHandlers:{scroll(){this.maybeMeasure();}}});const baseTheme$3=/*@__PURE__*/EditorView.baseTheme({".cm-tooltip":{zIndex:100},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:`${7/* Size */}px`,width:`${7/* Size */*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:`${7/* Size */}px solid transparent`,borderRight:`${7/* Size */}px solid transparent`},".cm-tooltip-above &":{bottom:`-${7/* Size */}px`,"&:before":{borderTop:`${7/* Size */}px solid #bbb`},"&:after":{borderTop:`${7/* Size */}px solid #f5f5f5`,bottom:"1px"}},".cm-tooltip-below &":{top:`-${7/* Size */}px`,"&:before":{borderBottom:`${7/* Size */}px solid #bbb`},"&:after":{borderBottom:`${7/* Size */}px solid #f5f5f5`,top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}});const noOffset={x:0,y:0};/**
3255
3233
  Facet to which an extension can add a value to show a tooltip.
3256
- */const showTooltip=/*@__PURE__*/Facet.define({enables:[tooltipPlugin,baseTheme$2]});const showHoverTooltip=/*@__PURE__*/Facet.define();class HoverTooltipHost{constructor(view){this.view=view;this.mounted=false;this.dom=document.createElement("div");this.dom.classList.add("cm-tooltip-hover");this.manager=new TooltipViewManager(view,showHoverTooltip,t=>this.createHostedView(t));}// Needs to be static so that host tooltip instances always match
3234
+ */const showTooltip=/*@__PURE__*/Facet.define({enables:[tooltipPlugin,baseTheme$3]});const showHoverTooltip=/*@__PURE__*/Facet.define();class HoverTooltipHost{constructor(view){this.view=view;this.mounted=false;this.dom=document.createElement("div");this.dom.classList.add("cm-tooltip-hover");this.manager=new TooltipViewManager(view,showHoverTooltip,t=>this.createHostedView(t));}// Needs to be static so that host tooltip instances always match
3257
3235
  static create(view){return new HoverTooltipHost(view);}createHostedView(tooltip){let hostedView=tooltip.create(this.view);hostedView.dom.classList.add("cm-tooltip-section");this.dom.appendChild(hostedView.dom);if(this.mounted&&hostedView.mount)hostedView.mount(this.view);return hostedView;}mount(view){for(let hostedView of this.manager.tooltipViews){if(hostedView.mount)hostedView.mount(view);}this.mounted=true;}positioned(){for(let hostedView of this.manager.tooltipViews){if(hostedView.positioned)hostedView.positioned();}}update(update){this.manager.update(update);}}const showHoverTooltipHost=/*@__PURE__*/showTooltip.compute([showHoverTooltip],state=>{let tooltips=state.facet(showHoverTooltip).filter(t=>t);if(tooltips.length===0)return null;return {pos:Math.min(...tooltips.map(t=>t.pos)),end:Math.max(...tooltips.filter(t=>t.end!=null).map(t=>t.end)),create:HoverTooltipHost.create,above:tooltips[0].above,arrow:tooltips.some(t=>t.arrow)};});class HoverPlugin{constructor(view,source,field,setHover,hoverTime){this.view=view;this.source=source;this.field=field;this.setHover=setHover;this.hoverTime=hoverTime;this.hoverTimeout=-1;this.restartTimeout=-1;this.pending=null;this.lastMove={x:0,y:0,target:view.dom,time:0};this.checkHover=this.checkHover.bind(this);view.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this));view.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this));}update(){if(this.pending){this.pending=null;clearTimeout(this.restartTimeout);this.restartTimeout=setTimeout(()=>this.startHover(),20);}}get active(){return this.view.state.field(this.field);}checkHover(){this.hoverTimeout=-1;if(this.active)return;let hovered=Date.now()-this.lastMove.time;if(hovered<this.hoverTime)this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-hovered);else this.startHover();}startHover(){clearTimeout(this.restartTimeout);let{lastMove}=this;let pos=this.view.contentDOM.contains(lastMove.target)?this.view.posAtCoords(lastMove):null;if(pos==null)return;let posCoords=this.view.coordsAtPos(pos);if(posCoords==null||lastMove.y<posCoords.top||lastMove.y>posCoords.bottom||lastMove.x<posCoords.left-this.view.defaultCharacterWidth||lastMove.x>posCoords.right+this.view.defaultCharacterWidth)return;let bidi=this.view.bidiSpans(this.view.state.doc.lineAt(pos)).find(s=>s.from<=pos&&s.to>=pos);let rtl=bidi&&bidi.dir==Direction.RTL?-1:1;let open=this.source(this.view,pos,lastMove.x<posCoords.left?-rtl:rtl);if(open===null||open===void 0?void 0:open.then){let pending=this.pending={pos};open.then(result=>{if(this.pending==pending){this.pending=null;if(result)this.view.dispatch({effects:this.setHover.of(result)});}},e=>logException(this.view.state,e,"hover tooltip"));}else if(open){this.view.dispatch({effects:this.setHover.of(open)});}}mousemove(event){var _a;this.lastMove={x:event.clientX,y:event.clientY,target:event.target,time:Date.now()};if(this.hoverTimeout<0)this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime);let tooltip=this.active;if(tooltip&&!isInTooltip(this.lastMove.target)||this.pending){let{pos}=tooltip||this.pending,end=(_a=tooltip===null||tooltip===void 0?void 0:tooltip.end)!==null&&_a!==void 0?_a:pos;if(pos==end?this.view.posAtCoords(this.lastMove)!=pos:!isOverRange(this.view,pos,end,event.clientX,event.clientY,6/* MaxDist */)){this.view.dispatch({effects:this.setHover.of(null)});this.pending=null;}}}mouseleave(){clearTimeout(this.hoverTimeout);this.hoverTimeout=-1;if(this.active)this.view.dispatch({effects:this.setHover.of(null)});}destroy(){clearTimeout(this.hoverTimeout);this.view.dom.removeEventListener("mouseleave",this.mouseleave);this.view.dom.removeEventListener("mousemove",this.mousemove);}}function isInTooltip(elt){for(let cur=elt;cur;cur=cur.parentNode)if(cur.nodeType==1&&cur.classList.contains("cm-tooltip"))return true;return false;}function isOverRange(view,from,to,x,y,margin){let range=document.createRange();let fromDOM=view.domAtPos(from),toDOM=view.domAtPos(to);range.setEnd(toDOM.node,toDOM.offset);range.setStart(fromDOM.node,fromDOM.offset);let rects=range.getClientRects();range.detach();for(let i=0;i<rects.length;i++){let rect=rects[i];let dist=Math.max(rect.top-y,y-rect.bottom,rect.left-x,x-rect.right);if(dist<=margin)return true;}return false;}/**
3258
3236
  Set up a hover tooltip, which shows up when the pointer hovers
3259
3237
  over ranges of text. The callback is called when the mouse hovers
@@ -3266,7 +3244,9 @@ pointer is before the position, 1 if after the position.
3266
3244
  Note that all hover tooltips are hosted within a single tooltip
3267
3245
  container element. This allows multiple tooltips over the same
3268
3246
  range to be "merged" together without overlapping.
3269
- */function hoverTooltip(source,options={}){let setHover=StateEffect.define();let hoverState=StateField.define({create(){return null;},update(value,tr){if(value&&(options.hideOnChange&&(tr.docChanged||tr.selection)||options.hideOn&&options.hideOn(tr,value)))return null;if(value&&tr.docChanged){let newPos=tr.changes.mapPos(value.pos,-1,MapMode.TrackDel);if(newPos==null)return null;let copy=Object.assign(Object.create(null),value);copy.pos=newPos;if(value.end!=null)copy.end=tr.changes.mapPos(value.end);value=copy;}for(let effect of tr.effects){if(effect.is(setHover))value=effect.value;if(effect.is(closeHoverTooltipEffect))value=null;}return value;},provide:f=>showHoverTooltip.from(f)});return [hoverState,ViewPlugin.define(view=>new HoverPlugin(view,source,hoverState,setHover,options.hoverTime||300/* Time */)),showHoverTooltipHost];}const closeHoverTooltipEffect=/*@__PURE__*/StateEffect.define();const panelConfig=/*@__PURE__*/Facet.define({combine(configs){let topContainer,bottomContainer;for(let c of configs){topContainer=topContainer||c.topContainer;bottomContainer=bottomContainer||c.bottomContainer;}return {topContainer,bottomContainer};}});const panelPlugin=/*@__PURE__*/ViewPlugin.fromClass(class{constructor(view){this.input=view.state.facet(showPanel);this.specs=this.input.filter(s=>s);this.panels=this.specs.map(spec=>spec(view));let conf=view.state.facet(panelConfig);this.top=new PanelGroup(view,true,conf.topContainer);this.bottom=new PanelGroup(view,false,conf.bottomContainer);this.top.sync(this.panels.filter(p=>p.top));this.bottom.sync(this.panels.filter(p=>!p.top));for(let p of this.panels){p.dom.classList.add("cm-panel");if(p.mount)p.mount();}}update(update){let conf=update.state.facet(panelConfig);if(this.top.container!=conf.topContainer){this.top.sync([]);this.top=new PanelGroup(update.view,true,conf.topContainer);}if(this.bottom.container!=conf.bottomContainer){this.bottom.sync([]);this.bottom=new PanelGroup(update.view,false,conf.bottomContainer);}this.top.syncClasses();this.bottom.syncClasses();let input=update.state.facet(showPanel);if(input!=this.input){let specs=input.filter(x=>x);let panels=[],top=[],bottom=[],mount=[];for(let spec of specs){let known=this.specs.indexOf(spec),panel;if(known<0){panel=spec(update.view);mount.push(panel);}else {panel=this.panels[known];if(panel.update)panel.update(update);}panels.push(panel);(panel.top?top:bottom).push(panel);}this.specs=specs;this.panels=panels;this.top.sync(top);this.bottom.sync(bottom);for(let p of mount){p.dom.classList.add("cm-panel");if(p.mount)p.mount();}}else {for(let p of this.panels)if(p.update)p.update(update);}}destroy(){this.top.sync([]);this.bottom.sync([]);}},{provide:plugin=>EditorView.scrollMargins.of(view=>{let value=view.plugin(plugin);return value&&{top:value.top.scrollMargin(),bottom:value.bottom.scrollMargin()};})});class PanelGroup{constructor(view,top,container){this.view=view;this.top=top;this.container=container;this.dom=undefined;this.classes="";this.panels=[];this.syncClasses();}sync(panels){for(let p of this.panels)if(p.destroy&&panels.indexOf(p)<0)p.destroy();this.panels=panels;this.syncDOM();}syncDOM(){if(this.panels.length==0){if(this.dom){this.dom.remove();this.dom=undefined;}return;}if(!this.dom){this.dom=document.createElement("div");this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";this.dom.style[this.top?"top":"bottom"]="0";let parent=this.container||this.view.dom;parent.insertBefore(this.dom,this.top?parent.firstChild:null);}let curDOM=this.dom.firstChild;for(let panel of this.panels){if(panel.dom.parentNode==this.dom){while(curDOM!=panel.dom)curDOM=rm(curDOM);curDOM=curDOM.nextSibling;}else {this.dom.insertBefore(panel.dom,curDOM);}}while(curDOM)curDOM=rm(curDOM);}scrollMargin(){return !this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top);}syncClasses(){if(!this.container||this.classes==this.view.themeClasses)return;for(let cls of this.classes.split(" "))if(cls)this.container.classList.remove(cls);for(let cls of (this.classes=this.view.themeClasses).split(" "))if(cls)this.container.classList.add(cls);}}function rm(node){let next=node.nextSibling;node.remove();return next;}/**
3247
+ */function hoverTooltip(source,options={}){let setHover=StateEffect.define();let hoverState=StateField.define({create(){return null;},update(value,tr){if(value&&(options.hideOnChange&&(tr.docChanged||tr.selection)||options.hideOn&&options.hideOn(tr,value)))return null;if(value&&tr.docChanged){let newPos=tr.changes.mapPos(value.pos,-1,MapMode.TrackDel);if(newPos==null)return null;let copy=Object.assign(Object.create(null),value);copy.pos=newPos;if(value.end!=null)copy.end=tr.changes.mapPos(value.end);value=copy;}for(let effect of tr.effects){if(effect.is(setHover))value=effect.value;if(effect.is(closeHoverTooltipEffect))value=null;}return value;},provide:f=>showHoverTooltip.from(f)});return [hoverState,ViewPlugin.define(view=>new HoverPlugin(view,source,hoverState,setHover,options.hoverTime||300/* Time */)),showHoverTooltipHost];}/**
3248
+ Get the active tooltip view for a given tooltip, if available.
3249
+ */function getTooltip(view,tooltip){let plugin=view.plugin(tooltipPlugin);if(!plugin)return null;let found=plugin.manager.tooltips.indexOf(tooltip);return found<0?null:plugin.manager.tooltipViews[found];}const closeHoverTooltipEffect=/*@__PURE__*/StateEffect.define();const panelConfig=/*@__PURE__*/Facet.define({combine(configs){let topContainer,bottomContainer;for(let c of configs){topContainer=topContainer||c.topContainer;bottomContainer=bottomContainer||c.bottomContainer;}return {topContainer,bottomContainer};}});const panelPlugin=/*@__PURE__*/ViewPlugin.fromClass(class{constructor(view){this.input=view.state.facet(showPanel);this.specs=this.input.filter(s=>s);this.panels=this.specs.map(spec=>spec(view));let conf=view.state.facet(panelConfig);this.top=new PanelGroup(view,true,conf.topContainer);this.bottom=new PanelGroup(view,false,conf.bottomContainer);this.top.sync(this.panels.filter(p=>p.top));this.bottom.sync(this.panels.filter(p=>!p.top));for(let p of this.panels){p.dom.classList.add("cm-panel");if(p.mount)p.mount();}}update(update){let conf=update.state.facet(panelConfig);if(this.top.container!=conf.topContainer){this.top.sync([]);this.top=new PanelGroup(update.view,true,conf.topContainer);}if(this.bottom.container!=conf.bottomContainer){this.bottom.sync([]);this.bottom=new PanelGroup(update.view,false,conf.bottomContainer);}this.top.syncClasses();this.bottom.syncClasses();let input=update.state.facet(showPanel);if(input!=this.input){let specs=input.filter(x=>x);let panels=[],top=[],bottom=[],mount=[];for(let spec of specs){let known=this.specs.indexOf(spec),panel;if(known<0){panel=spec(update.view);mount.push(panel);}else {panel=this.panels[known];if(panel.update)panel.update(update);}panels.push(panel);(panel.top?top:bottom).push(panel);}this.specs=specs;this.panels=panels;this.top.sync(top);this.bottom.sync(bottom);for(let p of mount){p.dom.classList.add("cm-panel");if(p.mount)p.mount();}}else {for(let p of this.panels)if(p.update)p.update(update);}}destroy(){this.top.sync([]);this.bottom.sync([]);}},{provide:plugin=>EditorView.scrollMargins.of(view=>{let value=view.plugin(plugin);return value&&{top:value.top.scrollMargin(),bottom:value.bottom.scrollMargin()};})});class PanelGroup{constructor(view,top,container){this.view=view;this.top=top;this.container=container;this.dom=undefined;this.classes="";this.panels=[];this.syncClasses();}sync(panels){for(let p of this.panels)if(p.destroy&&panels.indexOf(p)<0)p.destroy();this.panels=panels;this.syncDOM();}syncDOM(){if(this.panels.length==0){if(this.dom){this.dom.remove();this.dom=undefined;}return;}if(!this.dom){this.dom=document.createElement("div");this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";this.dom.style[this.top?"top":"bottom"]="0";let parent=this.container||this.view.dom;parent.insertBefore(this.dom,this.top?parent.firstChild:null);}let curDOM=this.dom.firstChild;for(let panel of this.panels){if(panel.dom.parentNode==this.dom){while(curDOM!=panel.dom)curDOM=rm(curDOM);curDOM=curDOM.nextSibling;}else {this.dom.insertBefore(panel.dom,curDOM);}}while(curDOM)curDOM=rm(curDOM);}scrollMargin(){return !this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top);}syncClasses(){if(!this.container||this.classes==this.view.themeClasses)return;for(let cls of this.classes.split(" "))if(cls)this.container.classList.remove(cls);for(let cls of (this.classes=this.view.themeClasses).split(" "))if(cls)this.container.classList.add(cls);}}function rm(node){let next=node.nextSibling;node.remove();return next;}/**
3270
3250
  Opening a panel is done by providing a constructor function for
3271
3251
  the panel through this facet. (The panel is closed again when its
3272
3252
  constructor is no longer provided.) Values of `null` are ignored.
@@ -4780,7 +4760,7 @@ The default keymap. Includes all bindings from
4780
4760
  - Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment).
4781
4761
  */const defaultKeymap=/*@__PURE__*/[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:cursorSyntaxLeft,shift:selectSyntaxLeft},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:cursorSyntaxRight,shift:selectSyntaxRight},{key:"Alt-ArrowUp",run:moveLineUp},{key:"Shift-Alt-ArrowUp",run:copyLineUp},{key:"Alt-ArrowDown",run:moveLineDown},{key:"Shift-Alt-ArrowDown",run:copyLineDown},{key:"Escape",run:simplifySelection},{key:"Mod-Enter",run:insertBlankLine},{key:"Alt-l",mac:"Ctrl-l",run:selectLine},{key:"Mod-i",run:selectParentSyntax,preventDefault:true},{key:"Mod-[",run:indentLess},{key:"Mod-]",run:indentMore},{key:"Mod-Alt-\\",run:indentSelection},{key:"Shift-Mod-k",run:deleteLine},{key:"Shift-Mod-\\",run:cursorMatchingBracket},{key:"Mod-/",run:toggleComment},{key:"Alt-A",run:toggleBlockComment}].concat(standardKeymap);function crelt(){var elt=arguments[0];if(typeof elt=="string")elt=document.createElement(elt);var i=1,next=arguments[1];if(next&&typeof next=="object"&&next.nodeType==null&&!Array.isArray(next)){for(var name in next)if(Object.prototype.hasOwnProperty.call(next,name)){var value=next[name];if(typeof value=="string")elt.setAttribute(name,value);else if(value!=null)elt[name]=value;}i++;}for(;i<arguments.length;i++)add(elt,arguments[i]);return elt;}function add(elt,child){if(typeof child=="string"){elt.appendChild(document.createTextNode(child));}else if(child==null);else if(child.nodeType!=null){elt.appendChild(child);}else if(Array.isArray(child)){for(var i=0;i<child.length;i++)add(elt,child[i]);}else {throw new RangeError("Unsupported child node: "+child);}}class SelectedDiagnostic{constructor(from,to,diagnostic){this.from=from;this.to=to;this.diagnostic=diagnostic;}}class LintState{constructor(diagnostics,panel,selected){this.diagnostics=diagnostics;this.panel=panel;this.selected=selected;}static init(diagnostics,panel,state){// Filter the list of diagnostics for which to create markers
4782
4762
  let markedDiagnostics=diagnostics;let diagnosticFilter=state.facet(lintConfig).markerFilter;if(diagnosticFilter)markedDiagnostics=diagnosticFilter(markedDiagnostics);let ranges=Decoration.set(markedDiagnostics.map(d=>{// For zero-length ranges or ranges covering only a line break, create a widget
4783
- return d.from==d.to||d.from==d.to-1&&state.doc.lineAt(d.from).to==d.from?Decoration.widget({widget:new DiagnosticWidget(d),diagnostic:d}).range(d.from):Decoration.mark({attributes:{class:"cm-lintRange cm-lintRange-"+d.severity},diagnostic:d}).range(d.from,d.to);}),true);return new LintState(ranges,panel,findDiagnostic(ranges));}}function findDiagnostic(diagnostics,diagnostic=null,after=0){let found=null;diagnostics.between(after,1e9,(from,to,{spec})=>{if(diagnostic&&spec.diagnostic!=diagnostic)return;found=new SelectedDiagnostic(from,to,spec.diagnostic);return false;});return found;}function hideTooltip(tr,tooltip){return !!(tr.effects.some(e=>e.is(setDiagnosticsEffect))||tr.changes.touchesRange(tooltip.pos));}function maybeEnableLint(state,effects){return state.field(lintState,false)?effects:effects.concat(StateEffect.appendConfig.of([lintState,EditorView.decorations.compute([lintState],state=>{let{selected,panel}=state.field(lintState);return !selected||!panel||selected.from==selected.to?Decoration.none:Decoration.set([activeMark.range(selected.from,selected.to)]);}),hoverTooltip(lintTooltip,{hideOn:hideTooltip}),baseTheme$1]));}/**
4763
+ return d.from==d.to||d.from==d.to-1&&state.doc.lineAt(d.from).to==d.from?Decoration.widget({widget:new DiagnosticWidget(d),diagnostic:d}).range(d.from):Decoration.mark({attributes:{class:"cm-lintRange cm-lintRange-"+d.severity},diagnostic:d}).range(d.from,d.to);}),true);return new LintState(ranges,panel,findDiagnostic(ranges));}}function findDiagnostic(diagnostics,diagnostic=null,after=0){let found=null;diagnostics.between(after,1e9,(from,to,{spec})=>{if(diagnostic&&spec.diagnostic!=diagnostic)return;found=new SelectedDiagnostic(from,to,spec.diagnostic);return false;});return found;}function hideTooltip(tr,tooltip){return !!(tr.effects.some(e=>e.is(setDiagnosticsEffect))||tr.changes.touchesRange(tooltip.pos));}function maybeEnableLint(state,effects){return state.field(lintState,false)?effects:effects.concat(StateEffect.appendConfig.of([lintState,EditorView.decorations.compute([lintState],state=>{let{selected,panel}=state.field(lintState);return !selected||!panel||selected.from==selected.to?Decoration.none:Decoration.set([activeMark.range(selected.from,selected.to)]);}),hoverTooltip(lintTooltip,{hideOn:hideTooltip}),baseTheme$2]));}/**
4784
4764
  Returns a transaction spec which updates the current set of
4785
4765
  diagnostics, and enables the lint extension if if wasn't already
4786
4766
  active.
@@ -4800,8 +4780,112 @@ this.moveSelection((this.selectedIndex+1)%this.items.length);}else if(event.keyC
4800
4780
  this.moveSelection(0);}else if(event.keyCode==35){// End
4801
4781
  this.moveSelection(this.items.length-1);}else if(event.keyCode==13){// Enter
4802
4782
  this.view.focus();}else if(event.keyCode>=65&&event.keyCode<=90&&this.selectedIndex>=0){// A-Z
4803
- let{diagnostic}=this.items[this.selectedIndex],keys=assignKeys(diagnostic.actions);for(let i=0;i<keys.length;i++)if(keys[i].toUpperCase().charCodeAt(0)==event.keyCode){let found=findDiagnostic(this.view.state.field(lintState).diagnostics,diagnostic);if(found)diagnostic.actions[i].apply(view,found.from,found.to);}}else {return;}event.preventDefault();};let onclick=event=>{for(let i=0;i<this.items.length;i++){if(this.items[i].dom.contains(event.target))this.moveSelection(i);}};this.list=crelt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown,onclick});this.dom=crelt("div",{class:"cm-panel-lint"},this.list,crelt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>closeLintPanel(this.view)},"×"));this.update();}get selectedIndex(){let selected=this.view.state.field(lintState).selected;if(!selected)return -1;for(let i=0;i<this.items.length;i++)if(this.items[i].diagnostic==selected.diagnostic)return i;return -1;}update(){let{diagnostics,selected}=this.view.state.field(lintState);let i=0,needsSync=false,newSelectedItem=null;diagnostics.between(0,this.view.state.doc.length,(_start,_end,{spec})=>{let found=-1,item;for(let j=i;j<this.items.length;j++)if(this.items[j].diagnostic==spec.diagnostic){found=j;break;}if(found<0){item=new PanelItem(this.view,spec.diagnostic);this.items.splice(i,0,item);needsSync=true;}else {item=this.items[found];if(found>i){this.items.splice(i,found-i);needsSync=true;}}if(selected&&item.diagnostic==selected.diagnostic){if(!item.dom.hasAttribute("aria-selected")){item.dom.setAttribute("aria-selected","true");newSelectedItem=item;}}else if(item.dom.hasAttribute("aria-selected")){item.dom.removeAttribute("aria-selected");}i++;});while(i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0)){needsSync=true;this.items.pop();}if(this.items.length==0){this.items.push(new PanelItem(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")}));needsSync=true;}if(newSelectedItem){this.list.setAttribute("aria-activedescendant",newSelectedItem.id);this.view.requestMeasure({key:this,read:()=>({sel:newSelectedItem.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel,panel})=>{if(sel.top<panel.top)this.list.scrollTop-=panel.top-sel.top;else if(sel.bottom>panel.bottom)this.list.scrollTop+=sel.bottom-panel.bottom;}});}else if(this.selectedIndex<0){this.list.removeAttribute("aria-activedescendant");}if(needsSync)this.sync();}sync(){let domPos=this.list.firstChild;function rm(){let prev=domPos;domPos=prev.nextSibling;prev.remove();}for(let item of this.items){if(item.dom.parentNode==this.list){while(domPos!=item.dom)rm();domPos=item.dom.nextSibling;}else {this.list.insertBefore(item.dom,domPos);}}while(domPos)rm();}moveSelection(selectedIndex){if(this.selectedIndex<0)return;let field=this.view.state.field(lintState);let selection=findDiagnostic(field.diagnostics,this.items[selectedIndex].diagnostic);if(!selection)return;this.view.dispatch({selection:{anchor:selection.from,head:selection.to},scrollIntoView:true,effects:movePanelSelection.of(selection)});}static open(view){return new LintPanel(view);}}function svg(content,attrs=`viewBox="0 0 40 40"`){return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`;}function underline(color){return svg(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${color}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`);}const baseTheme$1=/*@__PURE__*/EditorView.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:/*@__PURE__*/underline("#d11")},".cm-lintRange-warning":{backgroundImage:/*@__PURE__*/underline("orange")},".cm-lintRange-info":{backgroundImage:/*@__PURE__*/underline("#999")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});const FeelLinter=function(editorView){const messages=[];// don't lint if the Editor is empty
4804
- if(editorView.state.doc.length===0){return messages;}const tree=syntaxTree(editorView.state);tree.iterate({enter:node=>{if(node.type.isError){const error=node.toString();/* The error has the pattern [⚠ || ⚠(NodeType)]. The regex extracts the node type from inside the brackets */const match=/\((.*?)\)/.exec(error);const nodeType=match&&match[1];let message;if(nodeType){message='unexpected '+nodeType;}else {message='expression expected';}messages.push({from:node.from,to:node.to,severity:'error',message:message,source:'syntaxError'});}}});return messages;};var syntaxLinter=linter$1(FeelLinter);var linter=[syntaxLinter];const baseTheme=EditorView.theme({'& .cm-content':{padding:'0px'},'& .cm-line':{padding:'0px'},'&.cm-editor.cm-focused':{outline:'none'}});const highlightTheme=EditorView.baseTheme({'& .variableName':{color:'#10f'},'& .number':{color:'#164'},'& .string':{color:'#a11'},'& .function':{color:'#aa3731',fontWeight:'bold'},'& .atom':{color:'#708'}});const syntaxClasses=syntaxHighlighting(HighlightStyle.define([{tag:tags.variableName,class:'variableName'},{tag:tags.name,class:'variableName'},{tag:tags.number,class:'number'},{tag:tags.string,class:'string'},{tag:tags.function(tags.variableName),class:'function'},{tag:tags.atom,class:'atom'}]));var theme=[baseTheme,highlightTheme,syntaxClasses];/**
4783
+ let{diagnostic}=this.items[this.selectedIndex],keys=assignKeys(diagnostic.actions);for(let i=0;i<keys.length;i++)if(keys[i].toUpperCase().charCodeAt(0)==event.keyCode){let found=findDiagnostic(this.view.state.field(lintState).diagnostics,diagnostic);if(found)diagnostic.actions[i].apply(view,found.from,found.to);}}else {return;}event.preventDefault();};let onclick=event=>{for(let i=0;i<this.items.length;i++){if(this.items[i].dom.contains(event.target))this.moveSelection(i);}};this.list=crelt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown,onclick});this.dom=crelt("div",{class:"cm-panel-lint"},this.list,crelt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>closeLintPanel(this.view)},"×"));this.update();}get selectedIndex(){let selected=this.view.state.field(lintState).selected;if(!selected)return -1;for(let i=0;i<this.items.length;i++)if(this.items[i].diagnostic==selected.diagnostic)return i;return -1;}update(){let{diagnostics,selected}=this.view.state.field(lintState);let i=0,needsSync=false,newSelectedItem=null;diagnostics.between(0,this.view.state.doc.length,(_start,_end,{spec})=>{let found=-1,item;for(let j=i;j<this.items.length;j++)if(this.items[j].diagnostic==spec.diagnostic){found=j;break;}if(found<0){item=new PanelItem(this.view,spec.diagnostic);this.items.splice(i,0,item);needsSync=true;}else {item=this.items[found];if(found>i){this.items.splice(i,found-i);needsSync=true;}}if(selected&&item.diagnostic==selected.diagnostic){if(!item.dom.hasAttribute("aria-selected")){item.dom.setAttribute("aria-selected","true");newSelectedItem=item;}}else if(item.dom.hasAttribute("aria-selected")){item.dom.removeAttribute("aria-selected");}i++;});while(i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0)){needsSync=true;this.items.pop();}if(this.items.length==0){this.items.push(new PanelItem(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")}));needsSync=true;}if(newSelectedItem){this.list.setAttribute("aria-activedescendant",newSelectedItem.id);this.view.requestMeasure({key:this,read:()=>({sel:newSelectedItem.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel,panel})=>{if(sel.top<panel.top)this.list.scrollTop-=panel.top-sel.top;else if(sel.bottom>panel.bottom)this.list.scrollTop+=sel.bottom-panel.bottom;}});}else if(this.selectedIndex<0){this.list.removeAttribute("aria-activedescendant");}if(needsSync)this.sync();}sync(){let domPos=this.list.firstChild;function rm(){let prev=domPos;domPos=prev.nextSibling;prev.remove();}for(let item of this.items){if(item.dom.parentNode==this.list){while(domPos!=item.dom)rm();domPos=item.dom.nextSibling;}else {this.list.insertBefore(item.dom,domPos);}}while(domPos)rm();}moveSelection(selectedIndex){if(this.selectedIndex<0)return;let field=this.view.state.field(lintState);let selection=findDiagnostic(field.diagnostics,this.items[selectedIndex].diagnostic);if(!selection)return;this.view.dispatch({selection:{anchor:selection.from,head:selection.to},scrollIntoView:true,effects:movePanelSelection.of(selection)});}static open(view){return new LintPanel(view);}}function svg(content,attrs=`viewBox="0 0 40 40"`){return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`;}function underline(color){return svg(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${color}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`);}const baseTheme$2=/*@__PURE__*/EditorView.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:/*@__PURE__*/underline("#d11")},".cm-lintRange-warning":{backgroundImage:/*@__PURE__*/underline("orange")},".cm-lintRange-info":{backgroundImage:/*@__PURE__*/underline("#999")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});const FeelLinter=function(editorView){const messages=[];// don't lint if the Editor is empty
4784
+ if(editorView.state.doc.length===0){return messages;}const tree=syntaxTree(editorView.state);tree.iterate({enter:node=>{if(node.type.isError){const error=node.toString();/* The error has the pattern [⚠ || ⚠(NodeType)]. The regex extracts the node type from inside the brackets */const match=/\((.*?)\)/.exec(error);const nodeType=match&&match[1];let message;if(nodeType){message='unexpected '+nodeType;}else {message='expression expected';}messages.push({from:node.from,to:node.to,severity:'error',message:message,source:'syntaxError'});}}});return messages;};var syntaxLinter=linter$1(FeelLinter);var linter=[syntaxLinter];const baseTheme$1=EditorView.theme({'& .cm-content':{padding:'0px'},'& .cm-line':{padding:'0px'},'&.cm-editor.cm-focused':{outline:'none'}});const highlightTheme=EditorView.baseTheme({'& .variableName':{color:'#10f'},'& .number':{color:'#164'},'& .string':{color:'#a11'},'& .function':{color:'#aa3731',fontWeight:'bold'},'& .atom':{color:'#708'}});const syntaxClasses=syntaxHighlighting(HighlightStyle.define([{tag:tags.variableName,class:'variableName'},{tag:tags.name,class:'variableName'},{tag:tags.number,class:'number'},{tag:tags.string,class:'string'},{tag:tags.function(tags.variableName),class:'function'},{tag:tags.atom,class:'atom'}]));var theme=[baseTheme$1,highlightTheme,syntaxClasses];/**
4785
+ An instance of this is passed to completion source functions.
4786
+ */class CompletionContext{/**
4787
+ Create a new completion context. (Mostly useful for testing
4788
+ completion sources—in the editor, the extension will create
4789
+ these for you.)
4790
+ */constructor(/**
4791
+ The editor state that the completion happens in.
4792
+ */state,/**
4793
+ The position at which the completion is happening.
4794
+ */pos,/**
4795
+ Indicates whether completion was activated explicitly, or
4796
+ implicitly by typing. The usual way to respond to this is to
4797
+ only return completions when either there is part of a
4798
+ completable entity before the cursor, or `explicit` is true.
4799
+ */explicit){this.state=state;this.pos=pos;this.explicit=explicit;/**
4800
+ @internal
4801
+ */this.abortListeners=[];}/**
4802
+ Get the extent, content, and (if there is a token) type of the
4803
+ token before `this.pos`.
4804
+ */tokenBefore(types){let token=syntaxTree(this.state).resolveInner(this.pos,-1);while(token&&types.indexOf(token.name)<0)token=token.parent;return token?{from:token.from,to:this.pos,text:this.state.sliceDoc(token.from,this.pos),type:token.type}:null;}/**
4805
+ Get the match of the given expression directly before the
4806
+ cursor.
4807
+ */matchBefore(expr){let line=this.state.doc.lineAt(this.pos);let start=Math.max(line.from,this.pos-250);let str=line.text.slice(start-line.from,this.pos-line.from);let found=str.search(ensureAnchor(expr,false));return found<0?null:{from:start+found,to:this.pos,text:str.slice(found)};}/**
4808
+ Yields true when the query has been aborted. Can be useful in
4809
+ asynchronous queries to avoid doing work that will be ignored.
4810
+ */get aborted(){return this.abortListeners==null;}/**
4811
+ Allows you to register abort handlers, which will be called when
4812
+ the query is
4813
+ [aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
4814
+ */addEventListener(type,listener){if(type=="abort"&&this.abortListeners)this.abortListeners.push(listener);}}function toSet(chars){let flat=Object.keys(chars).join("");let words=/\w/.test(flat);if(words)flat=flat.replace(/\w/g,"");return `[${words?"\\w":""}${flat.replace(/[^\w\s]/g,"\\$&")}]`;}function prefixMatch(options){let first=Object.create(null),rest=Object.create(null);for(let{label}of options){first[label[0]]=true;for(let i=1;i<label.length;i++)rest[label[i]]=true;}let source=toSet(first)+toSet(rest)+"*$";return [new RegExp("^"+source),new RegExp(source)];}/**
4815
+ Given a a fixed array of options, return an autocompleter that
4816
+ completes them.
4817
+ */function completeFromList(list){let options=list.map(o=>typeof o=="string"?{label:o}:o);let[validFor,match]=options.every(o=>/^\w+$/.test(o.label))?[/\w*$/,/\w+$/]:prefixMatch(options);return context=>{let token=context.matchBefore(match);return token||context.explicit?{from:token?token.from:context.pos,options,validFor}:null;};}class Option{constructor(completion,source,match){this.completion=completion;this.source=source;this.match=match;}}function cur(state){return state.selection.main.head;}// Make sure the given regexp has a $ at its end and, if `start` is
4818
+ // true, a ^ at its start.
4819
+ function ensureAnchor(expr,start){var _a;let{source}=expr;let addStart=start&&source[0]!="^",addEnd=source[source.length-1]!="$";if(!addStart&&!addEnd)return expr;return new RegExp(`${addStart?"^":""}(?:${source})${addEnd?"$":""}`,(_a=expr.flags)!==null&&_a!==void 0?_a:expr.ignoreCase?"i":"");}/**
4820
+ Helper function that returns a transaction spec which inserts a
4821
+ completion's text in the main selection range, and any other
4822
+ selection range that has the same text in front of it.
4823
+ */function insertCompletionText(state,text,from,to){return Object.assign(Object.assign({},state.changeByRange(range=>{if(range==state.selection.main)return {changes:{from:from,to:to,insert:text},range:EditorSelection.cursor(from+text.length)};let len=to-from;if(!range.empty||len&&state.sliceDoc(range.from-len,range.from)!=state.sliceDoc(from,to))return {range};return {changes:{from:range.from-len,to:range.from,insert:text},range:EditorSelection.cursor(range.from-len+text.length)};})),{userEvent:"input.complete"});}function applyCompletion(view,option){const apply=option.completion.apply||option.completion.label;let result=option.source;if(typeof apply=="string")view.dispatch(insertCompletionText(view.state,apply,result.from,result.to));else apply(view,option.completion,result.from,result.to);}const SourceCache=/*@__PURE__*/new WeakMap();function asSource(source){if(!Array.isArray(source))return source;let known=SourceCache.get(source);if(!known)SourceCache.set(source,known=completeFromList(source));return known;}// A pattern matcher for fuzzy completion matching. Create an instance
4824
+ // once for a pattern, and then use that to match any number of
4825
+ // completions.
4826
+ class FuzzyMatcher{constructor(pattern){this.pattern=pattern;this.chars=[];this.folded=[];// Buffers reused by calls to `match` to track matched character
4827
+ // positions.
4828
+ this.any=[];this.precise=[];this.byWord=[];for(let p=0;p<pattern.length;){let char=codePointAt(pattern,p),size=codePointSize(char);this.chars.push(char);let part=pattern.slice(p,p+size),upper=part.toUpperCase();this.folded.push(codePointAt(upper==part?part.toLowerCase():upper,0));p+=size;}this.astral=pattern.length!=this.chars.length;}// Matches a given word (completion) against the pattern (input).
4829
+ // Will return null for no match, and otherwise an array that starts
4830
+ // with the match score, followed by any number of `from, to` pairs
4831
+ // indicating the matched parts of `word`.
4832
+ //
4833
+ // The score is a number that is more negative the worse the match
4834
+ // is. See `Penalty` above.
4835
+ match(word){if(this.pattern.length==0)return [0];if(word.length<this.pattern.length)return null;let{chars,folded,any,precise,byWord}=this;// For single-character queries, only match when they occur right
4836
+ // at the start
4837
+ if(chars.length==1){let first=codePointAt(word,0);return first==chars[0]?[0,0,codePointSize(first)]:first==folded[0]?[-200/* CaseFold */,0,codePointSize(first)]:null;}let direct=word.indexOf(this.pattern);if(direct==0)return [0,0,this.pattern.length];let len=chars.length,anyTo=0;if(direct<0){for(let i=0,e=Math.min(word.length,200);i<e&&anyTo<len;){let next=codePointAt(word,i);if(next==chars[anyTo]||next==folded[anyTo])any[anyTo++]=i;i+=codePointSize(next);}// No match, exit immediately
4838
+ if(anyTo<len)return null;}// This tracks the extent of the precise (non-folded, not
4839
+ // necessarily adjacent) match
4840
+ let preciseTo=0;// Tracks whether there is a match that hits only characters that
4841
+ // appear to be starting words. `byWordFolded` is set to true when
4842
+ // a case folded character is encountered in such a match
4843
+ let byWordTo=0,byWordFolded=false;// If we've found a partial adjacent match, these track its state
4844
+ let adjacentTo=0,adjacentStart=-1,adjacentEnd=-1;let hasLower=/[a-z]/.test(word),wordAdjacent=true;// Go over the option's text, scanning for the various kinds of matches
4845
+ for(let i=0,e=Math.min(word.length,200),prevType=0/* NonWord */;i<e&&byWordTo<len;){let next=codePointAt(word,i);if(direct<0){if(preciseTo<len&&next==chars[preciseTo])precise[preciseTo++]=i;if(adjacentTo<len){if(next==chars[adjacentTo]||next==folded[adjacentTo]){if(adjacentTo==0)adjacentStart=i;adjacentEnd=i+1;adjacentTo++;}else {adjacentTo=0;}}}let ch,type=next<0xff?next>=48&&next<=57||next>=97&&next<=122?2/* Lower */:next>=65&&next<=90?1/* Upper */:0/* NonWord */:(ch=fromCodePoint(next))!=ch.toLowerCase()?1/* Upper */:ch!=ch.toUpperCase()?2/* Lower */:0/* NonWord */;if(!i||type==1/* Upper */&&hasLower||prevType==0/* NonWord */&&type!=0/* NonWord */){if(chars[byWordTo]==next||folded[byWordTo]==next&&(byWordFolded=true))byWord[byWordTo++]=i;else if(byWord.length)wordAdjacent=false;}prevType=type;i+=codePointSize(next);}if(byWordTo==len&&byWord[0]==0&&wordAdjacent)return this.result(-100/* ByWord */+(byWordFolded?-200/* CaseFold */:0),byWord,word);if(adjacentTo==len&&adjacentStart==0)return [-200/* CaseFold */-word.length,0,adjacentEnd];if(direct>-1)return [-700/* NotStart */-word.length,direct,direct+this.pattern.length];if(adjacentTo==len)return [-200/* CaseFold */+-700/* NotStart */-word.length,adjacentStart,adjacentEnd];if(byWordTo==len)return this.result(-100/* ByWord */+(byWordFolded?-200/* CaseFold */:0)+-700/* NotStart */+(wordAdjacent?0:-1100/* Gap */),byWord,word);return chars.length==2?null:this.result((any[0]?-700/* NotStart */:0)+-200/* CaseFold */+-1100/* Gap */,any,word);}result(score,positions,word){let result=[score-word.length],i=1;for(let pos of positions){let to=pos+(this.astral?codePointSize(codePointAt(word,pos)):1);if(i>1&&result[i-1]==pos)result[i-1]=to;else {result[i++]=pos;result[i++]=to;}}return result;}}const completionConfig=/*@__PURE__*/Facet.define({combine(configs){return combineConfig(configs,{activateOnTyping:true,override:null,closeOnBlur:true,maxRenderedOptions:100,defaultKeymap:true,optionClass:()=>"",aboveCursor:false,icons:true,addToOptions:[]},{defaultKeymap:(a,b)=>a&&b,closeOnBlur:(a,b)=>a&&b,icons:(a,b)=>a&&b,optionClass:(a,b)=>c=>joinClass(a(c),b(c)),addToOptions:(a,b)=>a.concat(b)});}});function joinClass(a,b){return a?b?a+" "+b:a:b;}function optionContent(config){let content=config.addToOptions.slice();if(config.icons)content.push({render(completion){let icon=document.createElement("div");icon.classList.add("cm-completionIcon");if(completion.type)icon.classList.add(...completion.type.split(/\s+/g).map(cls=>"cm-completionIcon-"+cls));icon.setAttribute("aria-hidden","true");return icon;},position:20});content.push({render(completion,_s,match){let labelElt=document.createElement("span");labelElt.className="cm-completionLabel";let{label}=completion,off=0;for(let j=1;j<match.length;){let from=match[j++],to=match[j++];if(from>off)labelElt.appendChild(document.createTextNode(label.slice(off,from)));let span=labelElt.appendChild(document.createElement("span"));span.appendChild(document.createTextNode(label.slice(from,to)));span.className="cm-completionMatchedText";off=to;}if(off<label.length)labelElt.appendChild(document.createTextNode(label.slice(off)));return labelElt;},position:50},{render(completion){if(!completion.detail)return null;let detailElt=document.createElement("span");detailElt.className="cm-completionDetail";detailElt.textContent=completion.detail;return detailElt;},position:80});return content.sort((a,b)=>a.position-b.position).map(a=>a.render);}function rangeAroundSelected(total,selected,max){if(total<=max)return {from:0,to:total};if(selected<=total>>1){let off=Math.floor(selected/max);return {from:off*max,to:(off+1)*max};}let off=Math.floor((total-selected)/max);return {from:total-(off+1)*max,to:total-off*max};}class CompletionTooltip{constructor(view,stateField){this.view=view;this.stateField=stateField;this.info=null;this.placeInfo={read:()=>this.measureInfo(),write:pos=>this.positionInfo(pos),key:this};let cState=view.state.field(stateField);let{options,selected}=cState.open;let config=view.state.facet(completionConfig);this.optionContent=optionContent(config);this.optionClass=config.optionClass;this.range=rangeAroundSelected(options.length,selected,config.maxRenderedOptions);this.dom=document.createElement("div");this.dom.className="cm-tooltip-autocomplete";this.dom.addEventListener("mousedown",e=>{for(let dom=e.target,match;dom&&dom!=this.dom;dom=dom.parentNode){if(dom.nodeName=="LI"&&(match=/-(\d+)$/.exec(dom.id))&&+match[1]<options.length){applyCompletion(view,options[+match[1]]);e.preventDefault();return;}}});this.list=this.dom.appendChild(this.createListBox(options,cState.id,this.range));this.list.addEventListener("scroll",()=>{if(this.info)this.view.requestMeasure(this.placeInfo);});}mount(){this.updateSel();}update(update){if(update.state.field(this.stateField)!=update.startState.field(this.stateField))this.updateSel();}positioned(){if(this.info)this.view.requestMeasure(this.placeInfo);}updateSel(){let cState=this.view.state.field(this.stateField),open=cState.open;if(open.selected<this.range.from||open.selected>=this.range.to){this.range=rangeAroundSelected(open.options.length,open.selected,this.view.state.facet(completionConfig).maxRenderedOptions);this.list.remove();this.list=this.dom.appendChild(this.createListBox(open.options,cState.id,this.range));this.list.addEventListener("scroll",()=>{if(this.info)this.view.requestMeasure(this.placeInfo);});}if(this.updateSelectedOption(open.selected)){if(this.info){this.info.remove();this.info=null;}let{completion}=open.options[open.selected];let{info}=completion;if(!info)return;let infoResult=typeof info==='string'?document.createTextNode(info):info(completion);if(!infoResult)return;if('then'in infoResult){infoResult.then(node=>{if(node&&this.view.state.field(this.stateField,false)==cState)this.addInfoPane(node);}).catch(e=>logException(this.view.state,e,"completion info"));}else {this.addInfoPane(infoResult);}}}addInfoPane(content){let dom=this.info=document.createElement("div");dom.className="cm-tooltip cm-completionInfo";dom.appendChild(content);this.dom.appendChild(dom);this.view.requestMeasure(this.placeInfo);}updateSelectedOption(selected){let set=null;for(let opt=this.list.firstChild,i=this.range.from;opt;opt=opt.nextSibling,i++){if(i==selected){if(!opt.hasAttribute("aria-selected")){opt.setAttribute("aria-selected","true");set=opt;}}else {if(opt.hasAttribute("aria-selected"))opt.removeAttribute("aria-selected");}}if(set)scrollIntoView(this.list,set);return set;}measureInfo(){let sel=this.dom.querySelector("[aria-selected]");if(!sel||!this.info)return null;let listRect=this.dom.getBoundingClientRect();let infoRect=this.info.getBoundingClientRect();let selRect=sel.getBoundingClientRect();if(selRect.top>Math.min(innerHeight,listRect.bottom)-10||selRect.bottom<Math.max(0,listRect.top)+10)return null;let top=Math.max(0,Math.min(selRect.top,innerHeight-infoRect.height))-listRect.top;let left=this.view.textDirection==Direction.RTL;let spaceLeft=listRect.left,spaceRight=innerWidth-listRect.right;if(left&&spaceLeft<Math.min(infoRect.width,spaceRight))left=false;else if(!left&&spaceRight<Math.min(infoRect.width,spaceLeft))left=true;return {top,left};}positionInfo(pos){if(this.info){this.info.style.top=(pos?pos.top:-1e6)+"px";if(pos){this.info.classList.toggle("cm-completionInfo-left",pos.left);this.info.classList.toggle("cm-completionInfo-right",!pos.left);}}}createListBox(options,id,range){const ul=document.createElement("ul");ul.id=id;ul.setAttribute("role","listbox");ul.setAttribute("aria-expanded","true");ul.setAttribute("aria-label",this.view.state.phrase("Completions"));for(let i=range.from;i<range.to;i++){let{completion,match}=options[i];const li=ul.appendChild(document.createElement("li"));li.id=id+"-"+i;li.setAttribute("role","option");let cls=this.optionClass(completion);if(cls)li.className=cls;for(let source of this.optionContent){let node=source(completion,this.view.state,match);if(node)li.appendChild(node);}}if(range.from)ul.classList.add("cm-completionListIncompleteTop");if(range.to<options.length)ul.classList.add("cm-completionListIncompleteBottom");return ul;}}// We allocate a new function instance every time the completion
4846
+ // changes to force redrawing/repositioning of the tooltip
4847
+ function completionTooltip(stateField){return view=>new CompletionTooltip(view,stateField);}function scrollIntoView(container,element){let parent=container.getBoundingClientRect();let self=element.getBoundingClientRect();if(self.top<parent.top)container.scrollTop-=parent.top-self.top;else if(self.bottom>parent.bottom)container.scrollTop+=self.bottom-parent.bottom;}// Used to pick a preferred option when two options with the same
4848
+ // label occur in the result.
4849
+ function score(option){return (option.boost||0)*100+(option.apply?10:0)+(option.info?5:0)+(option.type?1:0);}function sortOptions(active,state){let options=[],i=0;for(let a of active)if(a.hasResult()){if(a.result.filter===false){let getMatch=a.result.getMatch;for(let option of a.result.options){let match=[1e9-i++];if(getMatch)for(let n of getMatch(option))match.push(n);options.push(new Option(option,a,match));}}else {let matcher=new FuzzyMatcher(state.sliceDoc(a.from,a.to)),match;for(let option of a.result.options)if(match=matcher.match(option.label)){if(option.boost!=null)match[0]+=option.boost;options.push(new Option(option,a,match));}}}let result=[],prev=null;for(let opt of options.sort(cmpOption)){if(!prev||prev.label!=opt.completion.label||prev.detail!=opt.completion.detail||prev.type!=null&&opt.completion.type!=null&&prev.type!=opt.completion.type||prev.apply!=opt.completion.apply)result.push(opt);else if(score(opt.completion)>score(prev))result[result.length-1]=opt;prev=opt.completion;}return result;}class CompletionDialog{constructor(options,attrs,tooltip,timestamp,selected){this.options=options;this.attrs=attrs;this.tooltip=tooltip;this.timestamp=timestamp;this.selected=selected;}setSelected(selected,id){return selected==this.selected||selected>=this.options.length?this:new CompletionDialog(this.options,makeAttrs(id,selected),this.tooltip,this.timestamp,selected);}static build(active,state,id,prev,conf){let options=sortOptions(active,state);if(!options.length)return null;let selected=0;if(prev&&prev.selected){let selectedValue=prev.options[prev.selected].completion;for(let i=0;i<options.length;i++)if(options[i].completion==selectedValue){selected=i;break;}}return new CompletionDialog(options,makeAttrs(id,selected),{pos:active.reduce((a,b)=>b.hasResult()?Math.min(a,b.from):a,1e8),create:completionTooltip(completionState),above:conf.aboveCursor},prev?prev.timestamp:Date.now(),selected);}map(changes){return new CompletionDialog(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:changes.mapPos(this.tooltip.pos)}),this.timestamp,this.selected);}}class CompletionState{constructor(active,id,open){this.active=active;this.id=id;this.open=open;}static start(){return new CompletionState(none,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null);}update(tr){let{state}=tr,conf=state.facet(completionConfig);let sources=conf.override||state.languageDataAt("autocomplete",cur(state)).map(asSource);let active=sources.map(source=>{let value=this.active.find(s=>s.source==source)||new ActiveSource(source,this.active.some(a=>a.state!=0/* Inactive */)?1/* Pending */:0/* Inactive */);return value.update(tr,conf);});if(active.length==this.active.length&&active.every((a,i)=>a==this.active[i]))active=this.active;let open=tr.selection||active.some(a=>a.hasResult()&&tr.changes.touchesRange(a.from,a.to))||!sameResults(active,this.active)?CompletionDialog.build(active,state,this.id,this.open,conf):this.open&&tr.docChanged?this.open.map(tr.changes):this.open;if(!open&&active.every(a=>a.state!=1/* Pending */)&&active.some(a=>a.hasResult()))active=active.map(a=>a.hasResult()?new ActiveSource(a.source,0/* Inactive */):a);for(let effect of tr.effects)if(effect.is(setSelectedEffect))open=open&&open.setSelected(effect.value,this.id);return active==this.active&&open==this.open?this:new CompletionState(active,this.id,open);}get tooltip(){return this.open?this.open.tooltip:null;}get attrs(){return this.open?this.open.attrs:baseAttrs;}}function sameResults(a,b){if(a==b)return true;for(let iA=0,iB=0;;){while(iA<a.length&&!a[iA].hasResult)iA++;while(iB<b.length&&!b[iB].hasResult)iB++;let endA=iA==a.length,endB=iB==b.length;if(endA||endB)return endA==endB;if(a[iA++].result!=b[iB++].result)return false;}}const baseAttrs={"aria-autocomplete":"list"};function makeAttrs(id,selected){return {"aria-autocomplete":"list","aria-haspopup":"listbox","aria-activedescendant":id+"-"+selected,"aria-controls":id};}const none=[];function cmpOption(a,b){let dScore=b.match[0]-a.match[0];if(dScore)return dScore;return a.completion.label.localeCompare(b.completion.label);}function getUserEvent(tr){return tr.isUserEvent("input.type")?"input":tr.isUserEvent("delete.backward")?"delete":null;}class ActiveSource{constructor(source,state,explicitPos=-1){this.source=source;this.state=state;this.explicitPos=explicitPos;}hasResult(){return false;}update(tr,conf){let event=getUserEvent(tr),value=this;if(event)value=value.handleUserEvent(tr,event,conf);else if(tr.docChanged)value=value.handleChange(tr);else if(tr.selection&&value.state!=0/* Inactive */)value=new ActiveSource(value.source,0/* Inactive */);for(let effect of tr.effects){if(effect.is(startCompletionEffect))value=new ActiveSource(value.source,1/* Pending */,effect.value?cur(tr.state):-1);else if(effect.is(closeCompletionEffect))value=new ActiveSource(value.source,0/* Inactive */);else if(effect.is(setActiveEffect))for(let active of effect.value)if(active.source==value.source)value=active;}return value;}handleUserEvent(tr,type,conf){return type=="delete"||!conf.activateOnTyping?this.map(tr.changes):new ActiveSource(this.source,1/* Pending */);}handleChange(tr){return tr.changes.touchesRange(cur(tr.startState))?new ActiveSource(this.source,0/* Inactive */):this.map(tr.changes);}map(changes){return changes.empty||this.explicitPos<0?this:new ActiveSource(this.source,this.state,changes.mapPos(this.explicitPos));}}class ActiveResult extends ActiveSource{constructor(source,explicitPos,result,from,to){super(source,2/* Result */,explicitPos);this.result=result;this.from=from;this.to=to;}hasResult(){return true;}handleUserEvent(tr,type,conf){var _a;let from=tr.changes.mapPos(this.from),to=tr.changes.mapPos(this.to,1);let pos=cur(tr.state);if((this.explicitPos<0?pos<=from:pos<this.from)||pos>to||type=="delete"&&cur(tr.startState)==this.from)return new ActiveSource(this.source,type=="input"&&conf.activateOnTyping?1/* Pending */:0/* Inactive */);let explicitPos=this.explicitPos<0?-1:tr.changes.mapPos(this.explicitPos),updated;if(checkValid(this.result.validFor,tr.state,from,to))return new ActiveResult(this.source,explicitPos,this.result,from,to);if(this.result.update&&(updated=this.result.update(this.result,from,to,new CompletionContext(tr.state,pos,explicitPos>=0))))return new ActiveResult(this.source,explicitPos,updated,updated.from,(_a=updated.to)!==null&&_a!==void 0?_a:cur(tr.state));return new ActiveSource(this.source,1/* Pending */,explicitPos);}handleChange(tr){return tr.changes.touchesRange(this.from,this.to)?new ActiveSource(this.source,0/* Inactive */):this.map(tr.changes);}map(mapping){return mapping.empty?this:new ActiveResult(this.source,this.explicitPos<0?-1:mapping.mapPos(this.explicitPos),this.result,mapping.mapPos(this.from),mapping.mapPos(this.to,1));}}function checkValid(validFor,state,from,to){if(!validFor)return false;let text=state.sliceDoc(from,to);return typeof validFor=="function"?validFor(text,from,to,state):ensureAnchor(validFor,true).test(text);}const startCompletionEffect=/*@__PURE__*/StateEffect.define();const closeCompletionEffect=/*@__PURE__*/StateEffect.define();const setActiveEffect=/*@__PURE__*/StateEffect.define({map(sources,mapping){return sources.map(s=>s.map(mapping));}});const setSelectedEffect=/*@__PURE__*/StateEffect.define();const completionState=/*@__PURE__*/StateField.define({create(){return CompletionState.start();},update(value,tr){return value.update(tr);},provide:f=>[showTooltip.from(f,val=>val.tooltip),EditorView.contentAttributes.from(f,state=>state.attrs)]});const CompletionInteractMargin=75;/**
4850
+ Returns a command that moves the completion selection forward or
4851
+ backward by the given amount.
4852
+ */function moveCompletionSelection(forward,by="option"){return view=>{let cState=view.state.field(completionState,false);if(!cState||!cState.open||Date.now()-cState.open.timestamp<CompletionInteractMargin)return false;let step=1,tooltip;if(by=="page"&&(tooltip=getTooltip(view,cState.open.tooltip)))step=Math.max(2,Math.floor(tooltip.dom.offsetHeight/tooltip.dom.querySelector("li").offsetHeight)-1);let selected=cState.open.selected+step*(forward?1:-1),{length}=cState.open.options;if(selected<0)selected=by=="page"?0:length-1;else if(selected>=length)selected=by=="page"?length-1:0;view.dispatch({effects:setSelectedEffect.of(selected)});return true;};}/**
4853
+ Accept the current completion.
4854
+ */const acceptCompletion=view=>{let cState=view.state.field(completionState,false);if(view.state.readOnly||!cState||!cState.open||Date.now()-cState.open.timestamp<CompletionInteractMargin)return false;applyCompletion(view,cState.open.options[cState.open.selected]);return true;};/**
4855
+ Explicitly start autocompletion.
4856
+ */const startCompletion=view=>{let cState=view.state.field(completionState,false);if(!cState)return false;view.dispatch({effects:startCompletionEffect.of(true)});return true;};/**
4857
+ Close the currently active completion.
4858
+ */const closeCompletion=view=>{let cState=view.state.field(completionState,false);if(!cState||!cState.active.some(a=>a.state!=0/* Inactive */))return false;view.dispatch({effects:closeCompletionEffect.of(null)});return true;};class RunningQuery{constructor(active,context){this.active=active;this.context=context;this.time=Date.now();this.updates=[];// Note that 'undefined' means 'not done yet', whereas 'null' means
4859
+ // 'query returned null'.
4860
+ this.done=undefined;}}const DebounceTime=50,MaxUpdateCount=50,MinAbortTime=1000;const completionPlugin=/*@__PURE__*/ViewPlugin.fromClass(class{constructor(view){this.view=view;this.debounceUpdate=-1;this.running=[];this.debounceAccept=-1;this.composing=0/* None */;for(let active of view.state.field(completionState).active)if(active.state==1/* Pending */)this.startQuery(active);}update(update){let cState=update.state.field(completionState);if(!update.selectionSet&&!update.docChanged&&update.startState.field(completionState)==cState)return;let doesReset=update.transactions.some(tr=>{return (tr.selection||tr.docChanged)&&!getUserEvent(tr);});for(let i=0;i<this.running.length;i++){let query=this.running[i];if(doesReset||query.updates.length+update.transactions.length>MaxUpdateCount&&Date.now()-query.time>MinAbortTime){for(let handler of query.context.abortListeners){try{handler();}catch(e){logException(this.view.state,e);}}query.context.abortListeners=null;this.running.splice(i--,1);}else {query.updates.push(...update.transactions);}}if(this.debounceUpdate>-1)clearTimeout(this.debounceUpdate);this.debounceUpdate=cState.active.some(a=>a.state==1/* Pending */&&!this.running.some(q=>q.active.source==a.source))?setTimeout(()=>this.startUpdate(),DebounceTime):-1;if(this.composing!=0/* None */)for(let tr of update.transactions){if(getUserEvent(tr)=="input")this.composing=2/* Changed */;else if(this.composing==2/* Changed */&&tr.selection)this.composing=3/* ChangedAndMoved */;}}startUpdate(){this.debounceUpdate=-1;let{state}=this.view,cState=state.field(completionState);for(let active of cState.active){if(active.state==1/* Pending */&&!this.running.some(r=>r.active.source==active.source))this.startQuery(active);}}startQuery(active){let{state}=this.view,pos=cur(state);let context=new CompletionContext(state,pos,active.explicitPos==pos);let pending=new RunningQuery(active,context);this.running.push(pending);Promise.resolve(active.source(context)).then(result=>{if(!pending.context.aborted){pending.done=result||null;this.scheduleAccept();}},err=>{this.view.dispatch({effects:closeCompletionEffect.of(null)});logException(this.view.state,err);});}scheduleAccept(){if(this.running.every(q=>q.done!==undefined))this.accept();else if(this.debounceAccept<0)this.debounceAccept=setTimeout(()=>this.accept(),DebounceTime);}// For each finished query in this.running, try to create a result
4861
+ // or, if appropriate, restart the query.
4862
+ accept(){var _a;if(this.debounceAccept>-1)clearTimeout(this.debounceAccept);this.debounceAccept=-1;let updated=[];let conf=this.view.state.facet(completionConfig);for(let i=0;i<this.running.length;i++){let query=this.running[i];if(query.done===undefined)continue;this.running.splice(i--,1);if(query.done){let active=new ActiveResult(query.active.source,query.active.explicitPos,query.done,query.done.from,(_a=query.done.to)!==null&&_a!==void 0?_a:cur(query.updates.length?query.updates[0].startState:this.view.state));// Replay the transactions that happened since the start of
4863
+ // the request and see if that preserves the result
4864
+ for(let tr of query.updates)active=active.update(tr,conf);if(active.hasResult()){updated.push(active);continue;}}let current=this.view.state.field(completionState).active.find(a=>a.source==query.active.source);if(current&&current.state==1/* Pending */){if(query.done==null){// Explicitly failed. Should clear the pending status if it
4865
+ // hasn't been re-set in the meantime.
4866
+ let active=new ActiveSource(query.active.source,0/* Inactive */);for(let tr of query.updates)active=active.update(tr,conf);if(active.state!=1/* Pending */)updated.push(active);}else {// Cleared by subsequent transactions. Restart.
4867
+ this.startQuery(current);}}}if(updated.length)this.view.dispatch({effects:setActiveEffect.of(updated)});}},{eventHandlers:{blur(){let state=this.view.state.field(completionState,false);if(state&&state.tooltip&&this.view.state.facet(completionConfig).closeOnBlur)this.view.dispatch({effects:closeCompletionEffect.of(null)});},compositionstart(){this.composing=1/* Started */;},compositionend(){if(this.composing==3/* ChangedAndMoved */){// Safari fires compositionend events synchronously, possibly
4868
+ // from inside an update, so dispatch asynchronously to avoid reentrancy
4869
+ setTimeout(()=>this.view.dispatch({effects:startCompletionEffect.of(false)}),20);}this.composing=0/* None */;}}});const baseTheme=/*@__PURE__*/EditorView.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",listStyle:"none",margin:0,padding:0,"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer",padding:"1px 3px",lineHeight:1.2}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:0.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"300px"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑\uFE0E'"}// Disable emoji rendering
4870
+ },".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});const closedBracket=/*@__PURE__*/new class extends RangeValue{}();closedBracket.startSide=1;closedBracket.endSide=-1;/**
4871
+ Returns an extension that enables autocompletion.
4872
+ */function autocompletion$1(config={}){return [completionState,completionConfig.of(config),completionPlugin,completionKeymapExt,baseTheme];}/**
4873
+ Basic keybindings for autocompletion.
4874
+
4875
+ - Ctrl-Space: [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion)
4876
+ - Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion)
4877
+ - ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)`
4878
+ - ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)`
4879
+ - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
4880
+ - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
4881
+ - Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion)
4882
+ */const completionKeymap=[{key:"Ctrl-Space",run:startCompletion},{key:"Escape",run:closeCompletion},{key:"ArrowDown",run:/*@__PURE__*/moveCompletionSelection(true)},{key:"ArrowUp",run:/*@__PURE__*/moveCompletionSelection(false)},{key:"PageDown",run:/*@__PURE__*/moveCompletionSelection(true,"page")},{key:"PageUp",run:/*@__PURE__*/moveCompletionSelection(false,"page")},{key:"Enter",run:acceptCompletion}];const completionKeymapExt=/*@__PURE__*/Prec.highest(/*@__PURE__*/keymap.computeN([completionConfig],state=>state.facet(completionConfig).defaultKeymap?[completionKeymap]:[]));var variables=variables=>context=>{const options=variables.map(v=>({label:v.name,type:'variable',info:v.info,detail:v.detail}));// In most cases, use what is typed before the cursor
4883
+ let nodeBefore=syntaxTree(context.state).resolve(context.pos,-1);// For the special case of empty nodes, we need to check the current node
4884
+ // as well. The previous node could be part of another token, e.g.
4885
+ // when typing functions "abs(".
4886
+ let nextNode=nodeBefore.nextSibling;const isInEmptyNode=isNodeEmpty(nodeBefore)||nextNode&&nextNode.from===context.pos&&isNodeEmpty(nextNode);if(context.explicit&&isInEmptyNode){return {from:context.pos,options:options};}const result={from:nodeBefore.from,options:options};// Only auto-complete variables
4887
+ if(nodeBefore.name!=='VariableName'){return null;}return result;};// helpers ///////////////////////////////
4888
+ function isNodeEmpty(node){return node.from===node.to;}function autocompletion(context){return [autocompletion$1({override:[variables(context)]})];}/**
4805
4889
  * Creates a FEEL editor in the supplied container
4806
4890
  *
4807
4891
  * @param {Object} config
@@ -4811,7 +4895,7 @@ if(editorView.state.doc.length===0){return messages;}const tree=syntaxTree(edito
4811
4895
  * @param {String} [config.value]
4812
4896
  *
4813
4897
  * @returns {Object} editor
4814
- */function FeelEditor({container,onChange=()=>{},onKeyDown=()=>{},value='',readOnly=false}){const changeHandler=EditorView.updateListener.of(update=>{if(update.docChanged){onChange(update.state.doc.toString());}});const keyHandler=EditorView.domEventHandlers({keydown:onKeyDown});const extensions=[keymap.of([...defaultKeymap]),changeHandler,keyHandler,language(),theme,linter];if(readOnly){extensions.push(EditorView.editable.of(false));}this._cmEditor=new EditorView({state:EditorState.create({doc:value,extensions:extensions}),parent:container});return this;}/**
4898
+ */function FeelEditor({container,variables=[],onChange=()=>{},onKeyDown=()=>{},value='',readOnly=false}){const changeHandler=EditorView.updateListener.of(update=>{if(update.docChanged){onChange(update.state.doc.toString());}});const keyHandler=EditorView.domEventHandlers({keydown:onKeyDown});const extensions=[keymap.of([...defaultKeymap]),changeHandler,keyHandler,language(),autocompletion(variables),theme,linter];if(readOnly){extensions.push(EditorView.editable.of(false));}this._cmEditor=new EditorView({state:EditorState.create({doc:value,extensions:extensions}),parent:container});return this;}/**
4815
4899
  * Replaces the content of the Editor
4816
4900
  *
4817
4901
  * @param {String} value
@@ -4849,7 +4933,8 @@ const CodeEditor = forwardRef((props, ref) => {
4849
4933
  value,
4850
4934
  onInput,
4851
4935
  onFeelToggle,
4852
- disabled
4936
+ disabled,
4937
+ variables
4853
4938
  } = props;
4854
4939
  const inputRef = useRef();
4855
4940
  const [editor, setEditor] = useState();
@@ -4884,10 +4969,15 @@ const CodeEditor = forwardRef((props, ref) => {
4884
4969
  container: inputRef.current,
4885
4970
  onChange: handleInput,
4886
4971
  onKeyDown: onKeyDown,
4887
- value: localValue
4972
+ value: localValue,
4973
+ variables: variables
4888
4974
  });
4889
4975
  setEditor(editor);
4890
- }, []);
4976
+ return () => {
4977
+ inputRef.current.innerHTML = '';
4978
+ setEditor(null);
4979
+ };
4980
+ }, [variables]);
4891
4981
  useEffect(() => {
4892
4982
  if (!editor) {
4893
4983
  return;
@@ -5070,6 +5160,7 @@ function FeelTextfield(props) {
5070
5160
  setFocus(true);
5071
5161
  },
5072
5162
  value: feelOnlyValue,
5163
+ variables: props.variables,
5073
5164
  ref: ref
5074
5165
  }) : jsx(OptionalComponent, { ...props,
5075
5166
  onInput: handleLocalInput,
@@ -5229,6 +5320,7 @@ function FeelEntry(props) {
5229
5320
  example: props.example,
5230
5321
  show: show,
5231
5322
  value: value,
5323
+ variables: props.variables,
5232
5324
  OptionalComponent: props.OptionalComponent
5233
5325
  }), error && jsx("div", {
5234
5326
  class: "bio-properties-panel-error",
@@ -5824,7 +5916,7 @@ function TextAreaEntry(props) {
5824
5916
  const value = getValue(element);
5825
5917
  const error = useError(id);
5826
5918
  return jsxs("div", {
5827
- class: "bio-properties-panel-entry",
5919
+ class: classnames('bio-properties-panel-entry', error ? 'has-error' : ''),
5828
5920
  "data-entry-id": id,
5829
5921
  children: [jsx(TextArea, {
5830
5922
  id: id,