CoreFiles by mySites.guru
codemirror-autocomplete.min.js1 lines, 35,331 bytes, from Joomla_5.0.2-Stable-Full_Package.zip
Raw History Compare with 5.0.1
md5
d24752fc18662065ac3b0833c69fa731
sha1
fe003160bbc41634ec50d22315c35b038b93646f
sha256
3f42b233edeb6ac5cf1fed50e781d0eaa4c33432b496b5fdbc705c5bc76f6dfc
import{Annotation as Ye,EditorSelection as x,Text as Ge,StateEffect as S,Facet as le,Prec as re,RangeValue as Je,codePointSize as I,codePointAt as v,CharCategory as H,combineConfig as Ze,StateField as K,MapMode as Q,RangeSet as ae,fromCodePoint as ce}from"@codemirror/state";import{getTooltip as fe,keymap as he,EditorView as M,Direction as _e,showTooltip as et,ViewPlugin as tt,logException as X,Decoration as N,WidgetType as it}from"@codemirror/view";import{syntaxTree as B,indentUnit as nt}from"@codemirror/language";class Y{constructor(e,t,n){this.state=e,this.pos=t,this.explicit=n,this.abortListeners=[]}tokenBefore(e){let t=B(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),o=t.text.slice(n-t.from,this.pos-t.from),s=o.search(me(e,!1));return s<0?null:{from:n+s,to:this.pos,text:o.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t){e=="abort"&&this.abortListeners&&this.abortListeners.push(t)}}function ue(i){let e=Object.keys(i).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function ot(i){let e=Object.create(null),t=Object.create(null);for(let{label:o}of i){e[o[0]]=!0;for(let s=1;s<o.length;s++)t[o[s]]=!0}let n=ue(e)+ue(t)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function pe(i){let e=i.map(o=>typeof o=="string"?{label:o}:o),[t,n]=e.every(o=>/^\w+$/.test(o.label))?[/\w*$/,/\w+$/]:ot(e);return o=>{let s=o.matchBefore(n);return s||o.explicit?{from:s?s.from:o.pos,options:e,validFor:t}:null}}function st(i,e){return t=>{for(let n=B(t.state).resolveInner(t.pos,-1);n;n=n.parent){if(i.indexOf(n.name)>-1)return e(t);if(n.type.isTop)break}return null}}function lt(i,e){return t=>{for(let n=B(t.state).resolveInner(t.pos,-1);n;n=n.parent){if(i.indexOf(n.name)>-1)return null;if(n.type.isTop)break}return e(t)}}class de{constructor(e,t,n,o){this.completion=e,this.source=t,this.match=n,this.score=o}}function O(i){return i.selection.main.from}function me(i,e){var t;let{source:n}=i,o=e&&n[0]!="^",s=n[n.length-1]!="$";return!o&&!s?i:new RegExp(`${o?"^":""}(?:${n})${s?"$":""}`,(t=i.flags)!==null&&t!==void 0?t:i.ignoreCase?"i":"")}const G=Ye.define();function ge(i,e,t,n){let{main:o}=i.selection,s=t-o.from,l=n-o.from;return Object.assign(Object.assign({},i.changeByRange(a=>a!=o&&t!=n&&i.sliceDoc(a.from+s,a.from+l)!=i.sliceDoc(t,n)?{range:a}:{changes:{from:a.from+s,to:n==o.from?a.to:a.from+l,insert:e},range:x.cursor(a.from+s+e.length)})),{userEvent:"input.complete"})}const be=new WeakMap;function rt(i){if(!Array.isArray(i))return i;let e=be.get(i);return e||be.set(i,e=pe(i)),e}const J=S.define(),k=S.define();class at{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=v(e,t),o=I(n);this.chars.push(n);let s=e.slice(t,t+o),l=s.toUpperCase();this.folded.push(v(l==s?s.toLowerCase():l,0)),t+=o}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,!0}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return!1;let{chars:t,folded:n,any:o,precise:s,byWord:l}=this;if(t.length==1){let d=v(e,0),A=I(d),C=A==e.length?0:-100;if(d!=t[0])if(d==n[0])C+=-200;else return!1;return this.ret(C,[0,A])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let r=t.length,c=0;if(a<0){for(let d=0,A=Math.min(e.length,200);d<A&&c<r;){let C=v(e,d);(C==t[c]||C==n[c])&&(o[c++]=d),d+=I(C)}if(c<r)return!1}let f=0,h=0,u=!1,p=0,w=-1,E=-1,Xe=/[a-z]/.test(e),z=!0;for(let d=0,A=Math.min(e.length,200),C=0;d<A&&h<r;){let g=v(e,d);a<0&&(f<r&&g==t[f]&&(s[f++]=d),p<r&&(g==t[p]||g==n[p]?(p==0&&(w=d),E=d+1,p++):p=0));let W,V=g<255?g>=48&&g<=57||g>=97&&g<=122?2:g>=65&&g<=90?1:0:(W=ce(g))!=W.toLowerCase()?1:W!=W.toUpperCase()?2:0;(!d||V==1&&Xe||C==0&&V!=0)&&(t[h]==g||n[h]==g&&(u=!0)?l[h++]=d:l.length&&(z=!1)),C=V,d+=I(g)}return h==r&&l[0]==0&&z?this.result(-100+(u?-200:0),l,e):p==r&&w==0?this.ret(-200-e.length+(E==e.length?0:-100),[0,E]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):p==r?this.ret(-200+-700-e.length,[w,E]):h==r?this.result(-100+(u?-200:0)+-700+(z?0:-1100),l,e):t.length==2?!1:this.result((o[0]?-700:0)+-200+-1100,o,e)}result(e,t,n){let o=[],s=0;for(let l of t){let a=l+(this.astral?I(v(n,l)):1);s&&o[s-1]==l?o[s-1]=a:(o[s++]=l,o[s++]=a)}return this.ret(e-n.length,o)}}const b=le.define({combine(i){return Ze(i,{activateOnTyping:!0,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:ct,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>ye(e(n),t(n)),optionClass:(e,t)=>n=>ye(e(n),t(n)),addToOptions:(e,t)=>e.concat(t)})}});function ye(i,e){return i?e?i+" "+e:i:e}function ct(i,e,t,n,o){let s=i.textDirection==_e.RTL,l=s,a=!1,r="top",c,f,h=e.left-o.left,u=o.right-e.right,p=n.right-n.left,w=n.bottom-n.top;if(l&&h<Math.min(p,u)?l=!1:!l&&u<Math.min(p,h)&&(l=!0),p<=(l?h:u))c=Math.max(o.top,Math.min(t.top,o.bottom-w))-e.top,f=Math.min(400,l?h:u);else{a=!0,f=Math.min(400,(s?e.right:o.right-e.left)-30);let E=o.bottom-e.bottom;E>=w||E>e.top?c=t.bottom-e.top:(r="bottom",c=e.bottom-t.top)}return{style:`${r}: ${c}px; max-width: ${f}px`,class:"cm-completionInfo-"+(a?s?"left-narrow":"right-narrow":l?"left":"right")}}function ft(i){let e=i.addToOptions.slice();return i.icons&&e.push({render(t){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),t.type&&n.classList.add(...t.type.split(/\s+/g).map(o=>"cm-completionIcon-"+o)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(t,n,o){let s=document.createElement("span");s.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let r=0;r<o.length;){let c=o[r++],f=o[r++];c>a&&s.appendChild(document.createTextNode(l.slice(a,c)));let h=s.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(l.slice(c,f))),h.className="cm-completionMatchedText",a=f}return a<l.length&&s.appendChild(document.createTextNode(l.slice(a))),s},position:50},{render(t){if(!t.detail)return null;let n=document.createElement("span");return n.className="cm-completionDetail",n.textContent=t.detail,n},position:80}),e.sort((t,n)=>t.position-n.position).map(t=>t.render)}function xe(i,e,t){if(i<=t)return{from:0,to:i};if(e<0&&(e=0),e<=i>>1){let o=Math.floor(e/t);return{from:o*t,to:(o+1)*t}}let n=Math.floor((i-e)/t);return{from:i-(n+1)*t,to:i-n*t}}class ht{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:r=>this.placeInfo(r),key:this},this.space=null,this.currentClass="";let o=e.state.field(t),{options:s,selected:l}=o.open,a=e.state.facet(b);this.optionContent=ft(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=xe(s.length,l,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",r=>{for(let c=r.target,f;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(f=/-(\d+)$/.exec(c.id))&&+f[1]<s.length){this.applyCompletion(e,s[+f[1]]),r.preventDefault();return}}),this.dom.addEventListener("focusout",r=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(b).closeOnBlur&&r.relatedTarget!=e.contentDOM&&e.dispatch({effects:k.of(null)})}),this.list=this.dom.appendChild(this.createListBox(s,o.id,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}mount(){this.updateSel()}update(e){var t,n,o;let s=e.state.field(this.stateField),l=e.startState.field(this.stateField);this.updateTooltipClass(e.state),s!=l&&(this.updateSel(),((t=s.open)===null||t===void 0?void 0:t.disabled)!=((n=l.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!(!((o=s.open)===null||o===void 0)&&o.disabled)))}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of t.split(" "))n&&this.dom.classList.add(n);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=xe(t.options.length,t.selected,this.view.state.facet(b).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t.options,e.id,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:o}=n;if(!o)return;let s=typeof o=="string"?document.createTextNode(o):o(n);if(!s)return;"then"in s?s.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,n)}).catch(l=>X(this.view.state,l,"completion info")):this.addInfoPane(s,n)}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:o,destroy:s}=e;n.appendChild(o),this.infoDestroy=s||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,o=this.range.from;n;n=n.nextSibling,o++)n.nodeName!="LI"||!n.id?o--:o==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected");return t&&pt(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),o=e.getBoundingClientRect(),s=this.space;if(!s){let l=this.dom.ownerDocument.defaultView||window;s={left:0,top:0,right:l.innerWidth,bottom:l.innerHeight}}return o.top>Math.min(s.bottom,t.bottom)-10||o.bottom<Math.max(s.top,t.top)+10?null:this.view.state.facet(b).positionInfo(this.view,t,o,n,s)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const o=document.createElement("ul");o.id=t,o.setAttribute("role","listbox"),o.setAttribute("aria-expanded","true"),o.setAttribute("aria-label",this.view.state.phrase("Completions"));let s=null;for(let l=n.from;l<n.to;l++){let{completion:a,match:r}=e[l],{section:c}=a;if(c){let u=typeof c=="string"?c:c.name;if(u!=s&&(l>n.from||n.from==0))if(s=u,typeof c!="string"&&c.header)o.appendChild(c.header(c));else{let p=o.appendChild(document.createElement("completion-section"));p.textContent=u}}const f=o.appendChild(document.createElement("li"));f.id=t+"-"+l,f.setAttribute("role","option");let h=this.optionClass(a);h&&(f.className=h);for(let u of this.optionContent){let p=u(a,this.view.state,r);p&&f.appendChild(p)}}return n.from&&o.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&o.classList.add("cm-completionListIncompleteBottom"),o}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function ut(i,e){return t=>new ht(t,i,e)}function pt(i,e){let t=i.getBoundingClientRect(),n=e.getBoundingClientRect();n.top<t.top?i.scrollTop-=t.top-n.top:n.bottom>t.bottom&&(i.scrollTop+=n.bottom-t.bottom)}function ve(i){return(i.boost||0)*100+(i.apply?10:0)+(i.info?5:0)+(i.type?1:0)}function dt(i,e){let t=[],n=null,o=r=>{t.push(r);let{section:c}=r.completion;if(c){n||(n=[]);let f=typeof c=="string"?c:c.name;n.some(h=>h.name==f)||n.push(typeof c=="string"?{name:f}:c)}};for(let r of i)if(r.hasResult()){let c=r.result.getMatch;if(r.result.filter===!1)for(let f of r.result.options)o(new de(f,r.source,c?c(f):[],1e9-t.length));else{let f=new at(e.sliceDoc(r.from,r.to));for(let h of r.result.options)if(f.match(h.label)){let u=h.displayLabel?c?c(h,f.matched):[]:f.matched;o(new de(h,r.source,u,f.score+(h.boost||0)))}}}if(n){let r=Object.create(null),c=0,f=(h,u)=>{var p,w;return((p=h.rank)!==null&&p!==void 0?p:1e9)-((w=u.rank)!==null&&w!==void 0?w:1e9)||(h.name<u.name?-1:1)};for(let h of n.sort(f))c-=1e5,r[h.name]=c;for(let h of t){let{section:u}=h.completion;u&&(h.score+=r[typeof u=="string"?u:u.name])}}let s=[],l=null,a=e.facet(b).compareCompletions;for(let r of t.sort((c,f)=>f.score-c.score||a(c.completion,f.completion))){let c=r.completion;!l||l.label!=c.label||l.detail!=c.detail||l.type!=null&&c.type!=null&&l.type!=c.type||l.apply!=c.apply||l.boost!=c.boost?s.push(r):ve(r.completion)>ve(l)&&(s[s.length-1]=r),l=r.completion}return s}class R{constructor(e,t,n,o,s,l){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=o,this.selected=s,this.disabled=l}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new R(this.options,we(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,o,s){let l=dt(e,t);if(!l.length)return o&&e.some(r=>r.state==1)?new R(o.options,o.attrs,o.tooltip,o.timestamp,o.selected,!0):null;let a=t.facet(b).selectOnOpen?0:-1;if(o&&o.selected!=a&&o.selected!=-1){let r=o.options[o.selected].completion;for(let c=0;c<l.length;c++)if(l[c].completion==r){a=c;break}}return new R(l,we(n,a),{pos:e.reduce((r,c)=>c.hasResult()?Math.min(r,c.from):r,1e8),create:ut(m,Se),above:s.aboveCursor},o?o.timestamp:Date.now(),a,!1)}map(e){return new R(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class q{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new q(bt,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(b),s=(n.override||t.languageDataAt("autocomplete",O(t)).map(rt)).map(a=>(this.active.find(c=>c.source==a)||new y(a,this.active.some(c=>c.state!=0)?1:0)).update(e,n));s.length==this.active.length&&s.every((a,r)=>a==this.active[r])&&(s=this.active);let l=this.open;l&&e.docChanged&&(l=l.map(e.changes)),e.selection||s.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!mt(s,this.active)?l=R.build(s,t,this.id,l,n):l&&l.disabled&&!s.some(a=>a.state==1)&&(l=null),!l&&s.every(a=>a.state!=1)&&s.some(a=>a.hasResult())&&(s=s.map(a=>a.hasResult()?new y(a.source,0):a));for(let a of e.effects)a.is(_)&&(l=l&&l.setSelected(a.value,this.id));return s==this.active&&l==this.open?this:new q(s,this.id,l)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:gt}}function mt(i,e){if(i==e)return!0;for(let t=0,n=0;;){for(;t<i.length&&!i[t].hasResult;)t++;for(;n<e.length&&!e[n].hasResult;)n++;let o=t==i.length,s=n==e.length;if(o||s)return o==s;if(i[t++].result!=e[n++].result)return!1}}const gt={"aria-autocomplete":"list"};function we(i,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":i};return e>-1&&(t["aria-activedescendant"]=i+"-"+e),t}const bt=[];function Z(i){return i.isUserEvent("input.type")?"input":i.isUserEvent("delete.backward")?"delete":null}class y{constructor(e,t,n=-1){this.source=e,this.state=t,this.explicitPos=n}hasResult(){return!1}update(e,t){let n=Z(e),o=this;n?o=o.handleUserEvent(e,n,t):e.docChanged?o=o.handleChange(e):e.selection&&o.state!=0&&(o=new y(o.source,0));for(let s of e.effects)if(s.is(J))o=new y(o.source,1,s.value?O(e.state):-1);else if(s.is(k))o=new y(o.source,0);else if(s.is(Ce))for(let l of s.value)l.source==o.source&&(o=l);return o}handleUserEvent(e,t,n){return t=="delete"||!n.activateOnTyping?this.map(e.changes):new y(this.source,1)}handleChange(e){return e.changes.touchesRange(O(e.startState))?new y(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new y(this.source,this.state,e.mapPos(this.explicitPos))}}class D extends y{constructor(e,t,n,o,s){super(e,2,t),this.result=n,this.from=o,this.to=s}hasResult(){return!0}handleUserEvent(e,t,n){var o;let s=e.changes.mapPos(this.from),l=e.changes.mapPos(this.to,1),a=O(e.state);if((this.explicitPos<0?a<=s:a<this.from)||a>l||t=="delete"&&O(e.startState)==this.from)return new y(this.source,t=="input"&&n.activateOnTyping?1:0);let r=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos),c;return yt(this.result.validFor,e.state,s,l)?new D(this.source,r,this.result,s,l):this.result.update&&(c=this.result.update(this.result,s,l,new Y(e.state,a,r>=0)))?new D(this.source,r,c,c.from,(o=c.to)!==null&&o!==void 0?o:O(e.state)):new y(this.source,1,r)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new y(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new D(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}}function yt(i,e,t,n){if(!i)return!1;let o=e.sliceDoc(t,n);return typeof i=="function"?i(o,t,n,e):me(i,!0).test(o)}const Ce=S.define({map(i,e){return i.map(t=>t.map(e))}}),_=S.define(),m=K.define({create(){return q.start()},update(i,e){return i.update(e)},provide:i=>[et.from(i,e=>e.tooltip),M.contentAttributes.from(i,e=>e.attrs)]});function Se(i,e){const t=e.completion.apply||e.completion.label;let n=i.state.field(m).active.find(o=>o.source==e.source);return n instanceof D?(typeof t=="string"?i.dispatch(Object.assign(Object.assign({},ge(i.state,t,n.from,n.to)),{annotations:G.of(e.completion)})):t(i,e.completion,n.from,n.to),!0):!1}function F(i,e="option"){return t=>{let n=t.state.field(m,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<t.state.facet(b).interactionDelay)return!1;let o=1,s;e=="page"&&(s=fe(t,n.open.tooltip))&&(o=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:l}=n.open.options,a=n.open.selected>-1?n.open.selected+o*(i?1:-1):i?0:l-1;return a<0?a=e=="page"?0:l-1:a>=l&&(a=e=="page"?l-1:0),t.dispatch({effects:_.of(a)}),!0}}const Ie=i=>{let e=i.state.field(m,!1);return i.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<i.state.facet(b).interactionDelay?!1:Se(i,e.open.options[e.open.selected])},Oe=i=>i.state.field(m,!1)?(i.dispatch({effects:J.of(!0)}),!0):!1,Ee=i=>{let e=i.state.field(m,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(i.dispatch({effects:k.of(null)}),!0)};class xt{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Te=50,vt=50,wt=1e3,Ct=tt.fromClass(class{constructor(i){this.view=i,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let e of i.state.field(m).active)e.state==1&&this.startQuery(e)}update(i){let e=i.state.field(m);if(!i.selectionSet&&!i.docChanged&&i.startState.field(m)==e)return;let t=i.transactions.some(n=>(n.selection||n.docChanged)&&!Z(n));for(let n=0;n<this.running.length;n++){let o=this.running[n];if(t||o.updates.length+i.transactions.length>vt&&Date.now()-o.time>wt){for(let s of o.context.abortListeners)try{s()}catch(l){X(this.view.state,l)}o.context.abortListeners=null,this.running.splice(n--,1)}else o.updates.push(...i.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=e.active.some(n=>n.state==1&&!this.running.some(o=>o.active.source==n.source))?setTimeout(()=>this.startUpdate(),Te):-1,this.composing!=0)for(let n of i.transactions)Z(n)=="input"?this.composing=2:this.composing==2&&n.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:i}=this.view,e=i.field(m);for(let t of e.active)t.state==1&&!this.running.some(n=>n.active.source==t.source)&&this.startQuery(t)}startQuery(i){let{state:e}=this.view,t=O(e),n=new Y(e,t,i.explicitPos==t),o=new xt(i,n);this.running.push(o),Promise.resolve(i.source(n)).then(s=>{o.context.aborted||(o.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:k.of(null)}),X(this.view.state,s)})}scheduleAccept(){this.running.every(i=>i.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),Te))}accept(){var i;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(b);for(let n=0;n<this.running.length;n++){let o=this.running[n];if(o.done===void 0)continue;if(this.running.splice(n--,1),o.done){let l=new D(o.active.source,o.active.explicitPos,o.done,o.done.from,(i=o.done.to)!==null&&i!==void 0?i:O(o.updates.length?o.updates[0].startState:this.view.state));for(let a of o.updates)l=l.update(a,t);if(l.hasResult()){e.push(l);continue}}let s=this.view.state.field(m).active.find(l=>l.source==o.active.source);if(s&&s.state==1)if(o.done==null){let l=new y(o.active.source,0);for(let a of o.updates)l=l.update(a,t);l.state!=1&&e.push(l)}else this.startQuery(s)}e.length&&this.view.dispatch({effects:Ce.of(e)})}},{eventHandlers:{blur(i){let e=this.view.state.field(m,!1);if(e&&e.tooltip&&this.view.state.facet(b).closeOnBlur){let t=e.open&&fe(this.view,e.open.tooltip);(!t||!t.dom.contains(i.relatedTarget))&&this.view.dispatch({effects:k.of(null)})}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:J.of(!1)}),20),this.composing=0}}}),Pe=M.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",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",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",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class St{constructor(e,t,n,o){this.field=e,this.line=t,this.from=n,this.to=o}}class oe{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(e){let t=e.mapPos(this.from,-1,Q.TrackDel),n=e.mapPos(this.to,1,Q.TrackDel);return t==null||n==null?null:new oe(this.field,t,n)}}class se{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],o=[t],s=e.doc.lineAt(t),l=/^\s*/.exec(s.text)[0];for(let r of this.lines){if(n.length){let c=l,f=/^\t*/.exec(r)[0].length;for(let h=0;h<f;h++)c+=e.facet(nt);o.push(t+c.length-f),r=c+r.slice(f)}n.push(r),t+=r.length+1}let a=this.fieldPositions.map(r=>new oe(r.field,o[r.line]+r.from,o[r.line]+r.to));return{text:n,ranges:a}}static parse(e){let t=[],n=[],o=[],s;for(let l of e.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(l);){let a=s[1]?+s[1]:null,r=s[2]||s[3]||"",c=-1;for(let f=0;f<t.length;f++)(a!=null?t[f].seq==a:r&&t[f].name==r)&&(c=f);if(c<0){let f=0;for(;f<t.length&&(a==null||t[f].seq!=null&&t[f].seq<a);)f++;t.splice(f,0,{seq:a,name:r}),c=f;for(let h of o)h.field>=c&&h.field++}o.push(new St(c,n.length,s.index,s.index+r.length)),l=l.slice(0,s.index)+r+l.slice(s.index+s[0].length)}for(let a;a=/\\([{}])/.exec(l);){l=l.slice(0,a.index)+a[1]+l.slice(a.index+a[0].length);for(let r of o)r.line==n.length&&r.from>a.index&&(r.from--,r.to--)}n.push(l)}return new se(n,o)}}let It=N.widget({widget:new class extends it{toDOM(){let i=document.createElement("span");return i.className="cm-snippetFieldPosition",i}ignoreEvent(){return!1}}}),Ot=N.mark({class:"cm-snippetField"});class L{constructor(e,t){this.ranges=e,this.active=t,this.deco=N.set(e.map(n=>(n.from==n.to?It:Ot).range(n.from,n.to)))}map(e){let t=[];for(let n of this.ranges){let o=n.map(e);if(!o)return null;t.push(o)}return new L(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(n=>n.field==this.active&&n.from<=t.from&&n.to>=t.to))}}const $=S.define({map(i,e){return i&&i.map(e)}}),Et=S.define(),T=K.define({create(){return null},update(i,e){for(let t of e.effects){if(t.is($))return t.value;if(t.is(Et)&&i)return new L(i.ranges,t.value)}return i&&e.docChanged&&(i=i.map(e.changes)),i&&e.selection&&!i.selectionInsideField(e.selection)&&(i=null),i},provide:i=>M.decorations.from(i,e=>e?e.deco:N.none)});function ee(i,e){return x.create(i.filter(t=>t.field==e).map(t=>x.range(t.from,t.to)))}function Ae(i){let e=se.parse(i);return(t,n,o,s)=>{let{text:l,ranges:a}=e.instantiate(t.state,o),r={changes:{from:o,to:s,insert:Ge.of(l)},scrollIntoView:!0,annotations:n?G.of(n):void 0};if(a.length&&(r.selection=ee(a,0)),a.length>1){let c=new L(a,0),f=r.effects=[$.of(c)];t.state.field(T,!1)===void 0&&f.push(S.appendConfig.of([T,Rt,Dt,Pe]))}t.dispatch(t.state.update(r))}}function Re(i){return({state:e,dispatch:t})=>{let n=e.field(T,!1);if(!n||i<0&&n.active==0)return!1;let o=n.active+i,s=i>0&&!n.ranges.some(l=>l.field==o+i);return t(e.update({selection:ee(n.ranges,o),effects:$.of(s?null:new L(n.ranges,o))})),!0}}const Le=({state:i,dispatch:e})=>i.field(T,!1)?(e(i.update({effects:$.of(null)})),!0):!1,De=Re(1),Me=Re(-1);function Tt(i){let e=i.field(T,!1);return!!(e&&e.ranges.some(t=>t.field==e.active+1))}function Pt(i){let e=i.field(T,!1);return!!(e&&e.active>0)}const At=[{key:"Tab",run:De,shift:Me},{key:"Escape",run:Le}],te=le.define({combine(i){return i.length?i[0]:At}}),Rt=re.highest(he.compute([te],i=>i.facet(te)));function Lt(i,e){return Object.assign(Object.assign({},e),{apply:Ae(i)})}const Dt=M.domEventHandlers({mousedown(i,e){let t=e.state.field(T,!1),n;if(!t||(n=e.posAtCoords({x:i.clientX,y:i.clientY}))==null)return!1;let o=t.ranges.find(s=>s.from<=n&&s.to>=n);return!o||o.field==t.active?!1:(e.dispatch({selection:ee(t.ranges,o.field),effects:$.of(t.ranges.some(s=>s.field>o.field)?new L(t.ranges,o.field):null)}),!0)}});function Mt(i){let e=i.replace(/[\\[.+*?(){|^$]/g,"\\$&");try{return new RegExp(`[\\p{Alphabetic}\\p{Number}_${e}]+`,"ug")}catch{return new RegExp(`[w${e}]`,"g")}}function Be(i,e){return new RegExp(e(i.source),i.unicode?"u":"")}const ke=Object.create(null);function Bt(i){return ke[i]||(ke[i]=new WeakMap)}function Fe(i,e,t,n,o){for(let s=i.iterLines(),l=0;!s.next().done;){let{value:a}=s,r;for(e.lastIndex=0;r=e.exec(a);)if(!n[r[0]]&&l+r.index!=o&&(t.push({type:"text",label:r[0]}),n[r[0]]=!0,t.length>=2e3))return;l+=a.length+1}}function $e(i,e,t,n,o){let s=i.length>=1e3,l=s&&e.get(i);if(l)return l;let a=[],r=Object.create(null);if(i.children){let c=0;for(let f of i.children){if(f.length>=1e3)for(let h of $e(f,e,t,n-c,o-c))r[h.label]||(r[h.label]=!0,a.push(h));else Fe(f,t,a,r,o-c);c+=f.length+1}}else Fe(i,t,a,r,o);return s&&a.length<2e3&&e.set(i,a),a}const kt=i=>{let e=i.state.languageDataAt("wordChars",i.pos).join(""),t=Mt(e),n=i.matchBefore(Be(t,l=>l+"$"));if(!n&&!i.explicit)return null;let o=n?n.from:i.pos,s=$e(i.state.doc,Bt(e),t,5e4,o);return{from:o,options:s,validFor:Be(t,l=>"^"+l)}},j={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},P=S.define({map(i,e){let t=e.mapPos(i,-1,Q.TrackAfter);return t??void 0}}),ie=new class extends Je{};ie.startSide=1,ie.endSide=-1;const je=K.define({create(){return ae.empty},update(i,e){if(e.selection){let t=e.state.doc.lineAt(e.selection.main.head).from,n=e.startState.doc.lineAt(e.startState.selection.main.head).from;t!=e.changes.mapPos(n,-1)&&(i=ae.empty)}i=i.map(e.changes);for(let t of e.effects)t.is(P)&&(i=i.update({add:[ie.range(t.value,t.value+1)]}));return i}});function Ft(){return[jt,je]}const ne="()[]{}<>";function We(i){for(let e=0;e<ne.length;e+=2)if(ne.charCodeAt(e)==i)return ne.charAt(e+1);return ce(i<128?i:i+1)}function Ne(i,e){return i.languageDataAt("closeBrackets",e)[0]||j}const $t=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),jt=M.inputHandler.of((i,e,t,n)=>{if(($t?i.composing:i.compositionStarted)||i.state.readOnly)return!1;let o=i.state.selection.main;if(n.length>2||n.length==2&&I(v(n,0))==1||e!=o.from||t!=o.to)return!1;let s=qe(i.state,n);return s?(i.dispatch(s),!0):!1}),Ue=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let n=Ne(i,i.selection.main.head).brackets||j.brackets,o=null,s=i.changeByRange(l=>{if(l.empty){let a=Nt(i.doc,l.head);for(let r of n)if(r==a&&U(i.doc,l.head)==We(v(r,0)))return{changes:{from:l.head-r.length,to:l.head+r.length},range:x.cursor(l.head-r.length)}}return{range:o=l}});return o||e(i.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!o},Wt=[{key:"Backspace",run:Ue}];function qe(i,e){let t=Ne(i,i.selection.main.head),n=t.brackets||j.brackets;for(let o of n){let s=We(v(o,0));if(e==o)return s==o?zt(i,o,n.indexOf(o+o+o)>-1,t):Ut(i,o,s,t.before||j.before);if(e==s&&ze(i,i.selection.main.from))return qt(i,o,s)}return null}function ze(i,e){let t=!1;return i.field(je).between(0,i.doc.length,n=>{n==e&&(t=!0)}),t}function U(i,e){let t=i.sliceString(e,e+2);return t.slice(0,I(v(t,0)))}function Nt(i,e){let t=i.sliceString(e-2,e);return I(v(t,0))==t.length?t:t.slice(1)}function Ut(i,e,t,n){let o=null,s=i.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:t,from:l.to}],effects:P.of(l.to+e.length),range:x.range(l.anchor+e.length,l.head+e.length)};let a=U(i.doc,l.head);return!a||/\s/.test(a)||n.indexOf(a)>-1?{changes:{insert:e+t,from:l.head},effects:P.of(l.head+e.length),range:x.cursor(l.head+e.length)}:{range:o=l}});return o?null:i.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function qt(i,e,t){let n=null,o=i.changeByRange(s=>s.empty&&U(i.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:x.cursor(s.head+t.length)}:n={range:s});return n?null:i.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function zt(i,e,t,n){let o=n.stringPrefixes||j.stringPrefixes,s=null,l=i.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:P.of(a.to+e.length),range:x.range(a.anchor+e.length,a.head+e.length)};let r=a.head,c=U(i.doc,r),f;if(c==e){if(Ve(i,r))return{changes:{insert:e+e,from:r},effects:P.of(r+e.length),range:x.cursor(r+e.length)};if(ze(i,r)){let u=t&&i.sliceDoc(r,r+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:r,to:r+u.length,insert:u},range:x.cursor(r+u.length)}}}else{if(t&&i.sliceDoc(r-2*e.length,r)==e+e&&(f=He(i,r-2*e.length,o))>-1&&Ve(i,f))return{changes:{insert:e+e+e+e,from:r},effects:P.of(r+e.length),range:x.cursor(r+e.length)};if(i.charCategorizer(r)(c)!=H.Word&&He(i,r,o)>-1&&!Vt(i,r,e,o))return{changes:{insert:e+e,from:r},effects:P.of(r+e.length),range:x.cursor(r+e.length)}}return{range:s=a}});return s?null:i.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function Ve(i,e){let t=B(i).resolveInner(e+1);return t.parent&&t.from==e}function Vt(i,e,t,n){let o=B(i).resolveInner(e,-1),s=n.reduce((l,a)=>Math.max(l,a.length),0);for(let l=0;l<5;l++){let a=i.sliceDoc(o.from,Math.min(o.to,o.from+t.length+s)),r=a.indexOf(t);if(!r||r>-1&&n.indexOf(a.slice(0,r))>-1){let f=o.firstChild;for(;f&&f.from==o.from&&f.to-f.from>t.length+r;){if(i.sliceDoc(f.to-t.length,f.to)==t)return!1;f=f.firstChild}return!0}let c=o.to==e&&o.parent;if(!c)break;o=c}return!1}function He(i,e,t){let n=i.charCategorizer(e);if(n(i.sliceDoc(e-1,e))!=H.Word)return e;for(let o of t){let s=e-o.length;if(i.sliceDoc(s,e)==o&&n(i.sliceDoc(s-1,s))!=H.Word)return s}return-1}function Ht(i={}){return[m,b.of(i),Ct,Kt,Pe]}const Ke=[{key:"Ctrl-Space",run:Oe},{key:"Escape",run:Ee},{key:"ArrowDown",run:F(!0)},{key:"ArrowUp",run:F(!1)},{key:"PageDown",run:F(!0,"page")},{key:"PageUp",run:F(!1,"page")},{key:"Enter",run:Ie}],Kt=re.highest(he.computeN([b],i=>i.facet(b).defaultKeymap?[Ke]:[]));function Qt(i){let e=i.field(m,!1);return e&&e.active.some(t=>t.state==1)?"pending":e&&e.active.some(t=>t.state!=0)?"active":null}const Qe=new WeakMap;function Xt(i){var e;let t=(e=i.field(m,!1))===null||e===void 0?void 0:e.open;if(!t||t.disabled)return[];let n=Qe.get(t.options);return n||Qe.set(t.options,n=t.options.map(o=>o.completion)),n}function Yt(i){var e;let t=(e=i.field(m,!1))===null||e===void 0?void 0:e.open;return t&&!t.disabled&&t.selected>=0?t.options[t.selected].completion:null}function Gt(i){var e;let t=(e=i.field(m,!1))===null||e===void 0?void 0:e.open;return t&&!t.disabled&&t.selected>=0?t.selected:null}function Jt(i){return _.of(i)}export{Y as CompletionContext,Ie as acceptCompletion,Ht as autocompletion,Le as clearSnippet,Ft as closeBrackets,Wt as closeBracketsKeymap,Ee as closeCompletion,kt as completeAnyWord,pe as completeFromList,Ke as completionKeymap,Qt as completionStatus,Xt as currentCompletions,Ue as deleteBracketPair,Tt as hasNextSnippetField,Pt as hasPrevSnippetField,st as ifIn,lt as ifNotIn,qe as insertBracket,ge as insertCompletionText,F as moveCompletionSelection,De as nextSnippetField,G as pickedCompletion,Me as prevSnippetField,Yt as selectedCompletion,Gt as selectedCompletionIndex,Jt as setSelectedCompletion,Ae as snippet,Lt as snippetCompletion,te as snippetKeymap,Oe as startCompletion};

The same content is in 12 releases, Joomla 5.0.1-rc1 to 5.1.0-alpha4. See them all, or every version of this file.