pocketbase/ui/dist/assets/CodeEditor.07a02f98.js

14 lines
141 KiB
JavaScript
Raw Normal View History

import{S as Ze,i as Te,s as be,e as ke,f as Xe,T as gO,g as ye,y as ZO,o as xe,K as _e,M as we,N as Re}from"./index.786ddc4b.js";import{P as qe,N as ve,u as We,D as Ye,v as oO,T as j,I as KO,w as QO,x as l,y as Ve,L as cO,z as hO,A as U,B as dO,F as HO,G as uO,H as V,J as Ce,K as ze,E as y,M as Y,O as Ge,Q as je,R as P,U as Ue,a as q,h as Ae,b as Ie,c as De,d as Be,e as Ee,s as Ne,f as Me,g as Le,i as Je,r as Fe,j as Ke,k as He,l as Ot,m as et,n as tt,o as at,p as it,q as rt,t as TO,C}from"./index.30b22912.js";class B{constructor(O,t,a,i,r,s,n,Q,c,h=0,o){this.p=O,this.stack=t,this.state=a,this.reducePos=i,this.pos=r,this.score=s,this.buffer=n,this.bufferBase=Q,this.curContext=c,this.lookAhead=h,this.parent=o}toString(){return`[${this.stack.filter((O,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(O,t,a=0){let i=O.parser.context;return new B(O,[],t,a,a,0,[],0,i?new bO(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(O,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=O}reduce(O){let t=O>>19,a=O&65535,{parser:i}=this.p,r=i.dynamicPrecedence(a);if(r&&(this.score+=r),t==0){this.pushState(i.getGoto(this.state,a,!0),this.reducePos),a<i.minRepeatTerm&&this.storeNode(a,this.reducePos,this.reducePos,4,!0),this.reduceContext(a,this.reducePos);return}let s=this.stack.length-(t-1)*3-(O&262144?6:0),n=this.stack[s-2],Q=this.stack[s-1],c=this.bufferBase+this.buffer.length-Q;if(a<i.minRepeatTerm||O&131072){let h=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(a,n,h,c+4,!0)}if(O&262144)this.state=this.stack[s];else{let h=this.stack[s-3];this.state=i.getGoto(h,a,!0)}for(;this.stack.length>s;)this.stack.pop();this.reduceContext(a,n)}storeNode(O,t,a,i=4,r=!1){if(O==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this,n=this.buffer.length;if(n==0&&s.parent&&(n=s.bufferBase-s.parent.bufferBase,s=s.parent),n>0&&s.buffer[n-4]==0&&s.buffer[n-1]>-1){if(t==a)return;if(s.buffer[n-2]>=t){s.buffer[n-2]=a;return}}}if(!r||this.pos==a)this.buffer.push(O,t,a,i);else{let s=this.buffer.length;if(s>0&&this.buffer[s-4]!=0)for(;s>0&&this.buffer[s-2]>a;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,i>4&&(i-=4);this.buffer[s]=O,this.buffer[s+1]=t,this.buffer[s+2]=a,this.buffer[s+3]=i}}shift(O,t,a){let i=this.pos;if(O&131072)this.pushState(O&65535,this.pos);else if((O&262144)==0){let r=O,{parser:s}=this.p;(a>this.pos||t<=s.maxNode)&&(this.pos=a,s.stateFlag(r,1)||(this.reducePos=a)),this.pushState(r,i),this.shiftContext(t,i),t<=s.maxNode&&this.buffer.push(t,i,a,4)}else this.pos=a,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,a,4)}apply(O,t,a){O&65536?this.reduce(O):this.shift(O,t,a)}useNode(O,t){let a=this.p.reused.length-1;(a<0||this.p.reused[a]!=O)&&(this.p.reused.push(O),a++);let i=this.pos;this.reducePos=this.pos=i+O.length,this.pushState(t,i),this.buffer.push(a,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,O,this,this.p.stream.reset(this.pos-O.length)))}split(){let O=this,t=O.buffer.length;for(;t>0&&O.buffer[t-2]>O.reducePos;)t-=4;let a=O.buffer.slice(t),i=O.bufferBase+t;for(;O&&i==O.bufferBase;)O=O.parent;return new B(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,a,i,this.curContext,this.lookAhead,O)}recoverByDelete(O,t){let a=O<=this.p.parser.maxNode;a&&this.storeNode(O,this.pos,t,4),this.storeNode(0,this.pos,t,a?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(O){for(let t=new st(this);;){let a=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,O);if(a==0)return!1;if((a&65536)==0)return!0;t.reduce(a)}}recoverByInsert(O){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>4<<1||this.stack.length>=120){let i=[];for(let r=0,s;r<t.length;r+=2)(s=t[r+1])!=this.state&&this.p.parser.hasAction(s,O)&&i.push(t[r]
\${}
} catch (\${error}) {
\${}
}`,{label:"try",detail:"/ catch block",type:"keyword"}),P("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),P(`if (\${}) {
\${}
} else {
\${}
}`,{label:"if",detail:"/ else block",type:"keyword"}),P(`class \${name} {
constructor(\${params}) {
\${}
}
}`,{label:"class",detail:"definition",type:"keyword"}),P('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),P('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],NO=new Ue,he=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function v(e){return(O,t)=>{let a=O.node.getChild("VariableDefinition");return a&&t(a,e),!0}}const Da=["FunctionDeclaration"],Ba={FunctionDeclaration:v("function"),ClassDeclaration:v("class"),ClassExpression:()=>!0,EnumDeclaration:v("constant"),TypeAliasDeclaration:v("type"),NamespaceDeclaration:v("namespace"),VariableDefinition(e,O){e.matchContext(Da)||O(e,"variable")},TypeDefinition(e,O){O(e,"type")},__proto__:null};function de(e,O){let t=NO.get(O);if(t)return t;let a=[],i=!0;function r(s,n){let Q=e.sliceString(s.from,s.to);a.push({label:Q,type:n})}return O.cursor(KO.IncludeAnonymous).iterate(s=>{if(i)i=!1;else if(s.name){let n=Ba[s.name];if(n&&n(s,r)||he.has(s.name))return!1}else if(s.to-s.from>8192){for(let n of de(e,s.node))a.push(n);return!1}}),NO.set(O,a),a}const MO=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,ue=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName"];function Ea(e){let O=V(e.state).resolveInner(e.pos,-1);if(ue.indexOf(O.name)>-1)return null;let t=O.name=="VariableName"||O.to-O.from<20&&MO.test(e.state.sliceDoc(O.from,O.to));if(!t&&!e.explicit)return null;let a=[];for(let i=O;i;i=i.parent)he.has(i.name)&&(a=a.concat(de(e.state.doc,i)));return{options:a,from:t?O.from:e.pos,validFor:MO}}const X=cO.define({name:"javascript",parser:Aa.configure({props:[hO.add({IfStatement:U({except:/^\s*({|else\b)/}),TryStatement:U({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Ge,SwitchBody:e=>{let O=e.textAfter,t=/^\s*\}/.test(O),a=/^\s*(case|default)\b/.test(O);return e.baseIndent+(t?0:a?1:2)*e.unit},Block:je({closing:"}"}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":U({except:/^{/}),JSXElement(e){let O=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(O?0:e.unit)},JSXEscape(e){let O=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(O?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),dO.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression":HO,BlockComment(e){return{from:e.from+2,to:e.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),fe=X.configure({dialect:"ts"},"typescript"),pe=X.configure({dialect:"jsx"}),$e=X.configure({dialect:"jsx ts"},"typescript"),Na="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(e=>({label:e,type:"keyword"}));function Se(e={}){let O=e.jsx?e.typescript?$e:pe:e.typescript?fe:X;return new uO(O,[X.data.of({autocomplete:Ce(ue,ze(Ia.concat(Na)))}),X.data.of({autocomplete:Ea}),e.jsx?La:[]])}function LO(e,O,t=e.length){if(!O)return"";let a=O.getChild("JSXIdentifier");return a?e.sliceString(a.from,Math.min(a.to,t)):""}const Ma=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),La=y.inputHandler.of((e,O,t,a)=>{if((Ma?e.composing:e.compositionStarted)||e.state.readOnly||O!=t||a!=">"&&a!="/"||!X.isActiveAt(e.state,O,-1))return!1;let{state:i}=e,r=i.changeByRange(s=>{var n,Q,c;let{head:h}=s,o=V(i).resolveInner(h,-1),u;if(o.name=="JSXStartTag"&&(o=o.parent),a==">"&&o.name=="JSXFragmentTag")return{range:Y.cursor(h+1),changes:{from:h,insert:"><>"}};if(a==">"&&o.name=="JSXIdentifier"){if(((Q=(n=o.parent)===null||n===void 0?void 0:n.lastChild)===null||Q===void 0?void 0:Q.name)!="JSXEndTag"&&(u=LO(i.doc,o.parent,h)))return{range:Y.cursor(h+1),changes:{from:h,insert:`></${u}>`}}}else if(a=="/