hyperbook 0.84.2 → 0.84.4

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.
@@ -1,22 +1,22 @@
1
- var Tt=Object.defineProperty;var Lt=(a,e,t)=>e in a?Tt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var h=(a,e,t)=>Lt(a,typeof e!="symbol"?e+"":e,t);import{l as C,e as x,U as Pt,R as it,K as Ve,a as Ge,M as ee,W as Mt,b as jt,c as $t,d as It,f as Bt}from"./assets/monaco-editor-DtkeIt2Q.js";/* empty css */import{j as c}from"./assets/jquery-CauBH1CL.js";import{p as H}from"./assets/pako-DwGzBETv.js";import{i as Ot,w as At}from"./assets/sql.js-Ck07Zxpa.js";import{Z as Qe,H as Ft,B as Nt,T as Wt}from"./assets/zip.js-DcZ2UyDZ.js";import{M as Ze}from"./assets/markdown-it-C44Roubk.js";import"./sql-ide-embedded.js";import"./assets/mdurl-k9Sl0PQj.js";import"./assets/uc.micro-kMc2yuuw.js";import"./assets/entities-C20TfXL6.js";import"./assets/linkify-it-DmNjr4Kv.js";import"./assets/punycode.js-Dj65hjkv.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))i(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(n){if(n.ep)return;n.ep=!0;const r=t(n);fetch(n.href,r)}})();var s=(a=>(a[a.identifier=0]="identifier",a[a.integerConstant=1]="integerConstant",a[a.floatingPointConstant=2]="floatingPointConstant",a[a.booleanConstant=3]="booleanConstant",a[a.stringConstant=4]="stringConstant",a[a.charConstant=5]="charConstant",a[a.true=6]="true",a[a.false=7]="false",a[a.keywordRename=8]="keywordRename",a[a.keywordDistinct=9]="keywordDistinct",a[a.keywordTo=10]="keywordTo",a[a.keywordAlter=11]="keywordAlter",a[a.keywordCommit=12]="keywordCommit",a[a.keywordAdd=13]="keywordAdd",a[a.keywordDelete=14]="keywordDelete",a[a.keywordSelect=15]="keywordSelect",a[a.keywordInsert=16]="keywordInsert",a[a.keywordInto=17]="keywordInto",a[a.keywordValues=18]="keywordValues",a[a.keywordUpdate=19]="keywordUpdate",a[a.keywordSet=20]="keywordSet",a[a.keywordNo=21]="keywordNo",a[a.keywordUse=22]="keywordUse",a[a.keywordCreate=23]="keywordCreate",a[a.keywordReferences=24]="keywordReferences",a[a.keywordPrimary=25]="keywordPrimary",a[a.keywordForeign=26]="keywordForeign",a[a.keywordTable=27]="keywordTable",a[a.keywordSchema=28]="keywordSchema",a[a.keywordTables=29]="keywordTables",a[a.keywordColumn=30]="keywordColumn",a[a.keywordDrop=31]="keywordDrop",a[a.keywordUnique=32]="keywordUnique",a[a.keywordKey=33]="keywordKey",a[a.keywordIndex=34]="keywordIndex",a[a.keywordConstraint=35]="keywordConstraint",a[a.keywordModify=36]="keywordModify",a[a.keywordCascade=37]="keywordCascade",a[a.keywordRestrict=38]="keywordRestrict",a[a.keywordAction=39]="keywordAction",a[a.keywordAutoincrement=40]="keywordAutoincrement",a[a.keywordFrom=41]="keywordFrom",a[a.keywordWhere=42]="keywordWhere",a[a.keywordGroup=43]="keywordGroup",a[a.keywordBy=44]="keywordBy",a[a.keywordHaving=45]="keywordHaving",a[a.keywordOrder=46]="keywordOrder",a[a.keywordAscending=47]="keywordAscending",a[a.keywordDescending=48]="keywordDescending",a[a.keywordNulls=49]="keywordNulls",a[a.keywordFirst=50]="keywordFirst",a[a.keywordLast=51]="keywordLast",a[a.keywordIs=52]="keywordIs",a[a.keywordNull=53]="keywordNull",a[a.keywordDatabase=54]="keywordDatabase",a[a.keywordUnion=55]="keywordUnion",a[a.keywordView=56]="keywordView",a[a.keywordEnum=57]="keywordEnum",a[a.keywordBetween=58]="keywordBetween",a[a.keywordOr=59]="keywordOr",a[a.keywordAnd=60]="keywordAnd",a[a.keywordNot=61]="keywordNot",a[a.keywordJoin=62]="keywordJoin",a[a.keywordNatural=63]="keywordNatural",a[a.keywordLeft=64]="keywordLeft",a[a.keywordCross=65]="keywordCross",a[a.keywordInner=66]="keywordInner",a[a.keywordOuter=67]="keywordOuter",a[a.keywordOn=68]="keywordOn",a[a.keywordAs=69]="keywordAs",a[a.keywordLimit=70]="keywordLimit",a[a.keywordOffset=71]="keywordOffset",a[a.keywordIn=72]="keywordIn",a[a.keywordNotIn=73]="keywordNotIn",a[a.keywordLike=74]="keywordLike",a[a.keywordCollate=75]="keywordCollate",a[a.keywordDefault=76]="keywordDefault",a[a.keywordComment=77]="keywordComment",a[a.keywordEngine=78]="keywordEngine",a[a.keywordCharset=79]="keywordCharset",a[a.keywordCharacter=80]="keywordCharacter",a[a.keywordStart=81]="keywordStart",a[a.keywordTransaction=82]="keywordTransaction",a[a.keywordIf=83]="keywordIf",a[a.keywordExists=84]="keywordExists",a[a.keywordLock=85]="keywordLock",a[a.keywordUnlock=86]="keywordUnlock",a[a.keywordWrite=87]="keywordWrite",a[a.keywordRead=88]="keywordRead",a[a.leftBracket=89]="leftBracket",a[a.rightBracket=90]="rightBracket",a[a.leftSquareBracket=91]="leftSquareBracket",a[a.rightSquareBracket=92]="rightSquareBracket",a[a.leftCurlyBracket=93]="leftCurlyBracket",a[a.rightCurlyBracket=94]="rightCurlyBracket",a[a.leftRightSquareBracket=95]="leftRightSquareBracket",a[a.dot=96]="dot",a[a.modulo=97]="modulo",a[a.minus=98]="minus",a[a.plus=99]="plus",a[a.multiplication=100]="multiplication",a[a.division=101]="division",a[a.singleQuote=102]="singleQuote",a[a.doubleQuote=103]="doubleQuote",a[a.identifierQuote=104]="identifierQuote",a[a.lower=105]="lower",a[a.greater=106]="greater",a[a.lowerOrEqual=107]="lowerOrEqual",a[a.greaterOrEqual=108]="greaterOrEqual",a[a.concatenation=109]="concatenation",a[a.equal=110]="equal",a[a.notEqual=111]="notEqual",a[a.semicolon=112]="semicolon",a[a.colon=113]="colon",a[a.comma=114]="comma",a[a.backslash=115]="backslash",a[a.pipe=116]="pipe",a[a.at=117]="at",a[a.hash=118]="hash",a[a.space=119]="space",a[a.tab=120]="tab",a[a.newline=121]="newline",a[a.linefeed=122]="linefeed",a[a.identifierChar=123]="identifierChar",a[a.comment=124]="comment",a[a.endofSourcecode=125]="endofSourcecode",a[a.constantNode=126]="constantNode",a[a.callMethod=127]="callMethod",a[a.unaryOp=128]="unaryOp",a[a.binaryOp=129]="binaryOp",a[a.table=130]="table",a[a.subquery=131]="subquery",a[a.list=132]="list",a[a.column=133]="column",a[a.columnDef=134]="columnDef",a[a.allColumns=135]="allColumns",a[a.isNull=136]="isNull",a[a.isNot=137]="isNot",a[a.isNotNull=138]="isNotNull",a[a.omittedeStatement=139]="omittedeStatement",a))(s||{}),D={0:"ein Bezeichner",1:"eine Integer-Konstante",2:"eine Fließkomma-Konstante",3:"eine boolesche Konstante",4:"eine Zeichenketten-Konstante",5:"eine char-Konstante",6:"true",7:"false",8:"rename",9:"distinct",10:"to",11:"alter",12:"commit",13:"add",14:"delete",15:"select",16:"insert",17:"into",18:"values",19:"update",20:"set",21:"no",22:"use",23:"create",24:"references",25:"primary",26:"foreign",27:"table",28:"schema",29:"tables",30:"column",31:"drop",32:"unique",33:"key",34:"index",35:"constraint",36:"modify",37:"cascade",38:"restrict",39:"action",40:"autoincrement",41:"from",42:"where",43:"group",44:"by",45:"having",46:"order",47:"ascending",48:"descending",49:"nulls",50:"first",51:"last",52:"is",53:"null",54:"database",55:"union",56:"view",57:"enum",58:"between",60:"and",59:"or",61:"not",62:"join",63:"natural",64:"left",65:"cross",66:"inner",67:"outer",68:"on",69:"as",70:"limit",71:"offset",72:"in",73:"not in",74:"like",75:"collate",76:"default",77:"comment",78:"engine",79:"charset",80:"character",81:"start",82:"transaction",83:"if",84:"exists",85:"lock",86:"unlock",87:"write",88:"read",89:"(",90:")",91:"[",92:"]",93:"{",94:"}",95:"[]",96:".",98:"-",97:"%",99:"+",100:"*",101:"/",102:"'",103:'"',104:"`",105:"<",106:">",110:"=",107:"<=",108:">=",109:"||",112:";",113:":",114:",",115:"\\",117:"@",118:"#",116:"|",119:"ein Leerzeichen",120:"ein Tabulatorzeichen",121:"ein Zeilenumbruch",123:"eines der Zeichen a..z, A..Z, _",124:"ein Kommentar",125:"das Ende des Programmes"},Me={"(":89,")":90,"[":91,"]":92,"{":93,"}":94,".":96,",":114,"-":98,"%":97,"+":99,"*":100,"/":101,"\\":115,"@":117,"#":118,"|":116,"'":102,'"':103,"`":104,"<":105,">":106,"=":110,"<>":111,";":112,":":113," ":119," ":120,"\n":121,"\r":122},Rt={rename:8,distinct:9,to:10,alter:11,commit:12,add:13,delete:14,select:15,insert:16,into:17,values:18,update:19,set:20,no:21,use:22,create:23,references:24,primary:25,foreign:26,table:27,tables:29,column:30,drop:31,unique:32,key:33,index:34,constraint:35,modify:36,cascade:37,restrict:38,action:39,autoincrement:40,auto_increment:40,from:41,where:42,true:6,false:7,group:43,by:44,having:45,order:46,asc:47,desc:48,nulls:49,first:50,last:51,is:52,null:53,database:54,union:55,view:56,enum:57,between:58,or:59,and:60,not:61,join:62,natural:63,left:64,cross:65,inner:66,outer:67,on:68,as:69,limit:70,offset:71,in:72,"not in":73,like:74,collate:75,default:76,comment:77,engine:78,charset:79,character:80,start:81,transaction:82,if:83,exists:84,lock:85,unlock:86,write:87,read:88},Je={n:`
2
- `,r:"\r",t:" ",'"':'"',"'":"'","\\":"\\"},I="►";class Re{constructor(){h(this,"tokenList");h(this,"nonSpaceLastTokenType");h(this,"nonSpaceLastToken");h(this,"errorList");h(this,"pos");h(this,"line");h(this,"column");h(this,"currentChar");h(this,"nextChar");h(this,"input");h(this,"spaceTokens",[s.space,s.tab,s.newline]);h(this,"bracketStack");h(this,"bracketError");h(this,"correspondingBracket",{});h(this,"tokenTypesToMerge",[{first:s.keywordNotIn,second:s.keywordIn,merged:s.keywordNotIn},{first:s.keywordIs,second:s.keywordNot,merged:s.isNot},{first:s.isNot,second:s.keywordNull,merged:s.isNotNull},{first:s.keywordIs,second:s.keywordNull,merged:s.isNull}]);this.correspondingBracket[s.leftBracket]=s.rightBracket,this.correspondingBracket[s.leftCurlyBracket]=s.rightCurlyBracket,this.correspondingBracket[s.leftSquareBracket]=s.rightSquareBracket,this.correspondingBracket[s.rightBracket]=s.leftBracket,this.correspondingBracket[s.rightCurlyBracket]=s.leftCurlyBracket,this.correspondingBracket[s.rightSquareBracket]=s.leftSquareBracket}lex(e){if(this.input=e.replace(" "," "),this.tokenList=[],this.errorList=[],this.bracketError=null,this.bracketStack=[],this.pos=0,this.line=1,this.column=1,this.nonSpaceLastTokenType=null,this.nonSpaceLastToken=null,e.length==0)return{tokens:this.tokenList,errors:this.errorList,bracketError:null};for(this.currentChar=e.charAt(0),this.nextChar=e.length>1?e.charAt(1):I;this.currentChar!=I;)this.mainState();if(this.bracketStack.length>0){let t=this.bracketStack.pop(),i=this.correspondingBracket[t];this.setBracketError(D[t]+" "+D[i])}return{tokens:this.tokenList,errors:this.errorList,bracketError:this.bracketError}}checkClosingBracket(e){if(this.bracketStack.length==0){let n=this.correspondingBracket[e];this.setBracketError(D[n]+" "+D[e]);return}let t=this.bracketStack.pop(),i=this.correspondingBracket[t];e!=i&&this.setBracketError(D[t]+" "+D[i])}setBracketError(e){this.bracketError==null&&(this.bracketError=e)}next(){this.pos++,this.currentChar=this.nextChar,this.pos+1<this.input.length?this.nextChar=this.input.charAt(this.pos+1):this.nextChar=I,this.column++}mainState(){let e=this.currentChar,t=Me[e];if(t!=null){switch(t){case s.leftSquareBracket:if(this.nextChar=="]"){this.pushToken(s.leftRightSquareBracket,"[]"),this.next(),this.next();return}else{this.pushToken(s.leftSquareBracket,"["),this.bracketStack.push(t),this.next();return}case s.division:if(this.nextChar=="*"){this.lexMultilineComment();return}this.pushToken(s.division,"/"),this.next();return;case s.pipe:if(this.nextChar=="|"){this.pushToken(s.concatenation,"||"),this.next(),this.next();return}else{this.pushToken(s.pipe,"|"),this.next();return}case s.lower:if(this.nextChar==">"){this.pushToken(s.notEqual,"<>"),this.next(),this.next();return}else if(this.nextChar=="="){this.pushToken(s.lowerOrEqual,"<="),this.next(),this.next();return}else{this.pushToken(s.lower,"<"),this.next();return}case s.greater:if(this.nextChar=="="){this.pushToken(s.greaterOrEqual,">="),this.next(),this.next();return}else{this.pushToken(s.greater,">"),this.next();return}case s.rightSquareBracket:this.checkClosingBracket(t);break;case s.leftBracket:this.bracketStack.push(t);break;case s.rightBracket:this.checkClosingBracket(t);break;case s.leftCurlyBracket:this.bracketStack.push(t);break;case s.rightCurlyBracket:this.checkClosingBracket(t);break;case s.minus:if(this.isDigit(this.nextChar,10)&&!([s.identifier,s.integerConstant,s.floatingPointConstant,s.rightBracket].indexOf(this.nonSpaceLastTokenType)>=0)){this.lexNumber();return}else if(this.nextChar=="-"){this.lexEndofLineComment("--");return}else{this.pushToken(s.minus,"-"),this.next();return}case s.hash:if(this.nonSpaceLastToken==null||this.nonSpaceLastToken.position.line<this.line){this.lexEndofLineComment("#");return}else this.pushToken(s.hash,"#"),this.next();break;case s.singleQuote:this.lexStringConstant("'");return;case s.doubleQuote:this.lexStringConstant('"');return;case s.newline:this.pushToken(s.newline,`
3
- `),this.line++,this.column=0,this.next();return;case s.space:case s.tab:this.lexSpace();return;case s.linefeed:this.next();return;case s.at:this.lexAnnotation();return;case s.identifierQuote:this.lexQuotedIdentifier();return}this.pushToken(t,e),this.next();return}if(this.isDigit(e,10)){this.lexNumber();return}this.lexIdentifierOrKeyword()}lexQuotedIdentifier(){let e=this.line,t=this.column,i="";for(this.next();this.currentChar!="`"&&this.currentChar!=I;)i+=this.currentChar,this.next();this.currentChar==I?this.pushError("Innerhalb eines in `` eingeschlossenen Bezeichners wurde das Ende der Datei erreicht.",i.length+1,"error",e,t):(this.next(),this.pushToken(s.identifier,i,e,t))}pushToken(e,t,i=this.line,n=this.column,r=(""+t).length){let o={tt:e,value:t,position:{column:n,line:i,length:r}};for(let l of this.tokenTypesToMerge)if(e==l.second&&this.nonSpaceLastTokenType==l.first){let d=n-this.nonSpaceLastToken.position.column+r;this.nonSpaceLastToken.tt=l.merged,this.nonSpaceLastToken.position={column:this.nonSpaceLastToken.position.column,line:i,length:d},this.nonSpaceLastToken.value=this.nonSpaceLastToken.value+" "+t,this.nonSpaceLastTokenType=l.merged;return}this.spaceTokens.indexOf(e)>=0||(this.nonSpaceLastTokenType=e,this.nonSpaceLastToken=o),this.tokenList.push(o)}pushError(e,t,i="error",n=this.line,r=this.column){this.errorList.push({text:e,position:{line:n,column:r,length:t},level:i})}isDigit(e,t){var i=e.charCodeAt(0);if(t==10)return i>=48&&i<=57;if(t==2)return i>=48&&i<=49;if(t==8)return i>=48&&i<=55;if(t==16)return i>=48&&i<=57||i>=97&&i<=102||i>=65&&i<=70}lexSpace(){let e=this.column,t=this.line,i=this.pos;for(;this.currentChar==" "||this.currentChar==" ";)this.next();let n=this.pos;this.pushToken(s.space,this.input.substring(i,n),t,e)}lexCharacterConstant(){let e=this.column,t=this.line;this.next();let i=this.currentChar;if(i=="\\"){let n=Je[this.nextChar];n==null?(this.pushError("Die Escape-Sequenz \\"+this.nextChar+" gibt es nicht.",2),this.nextChar!="'"&&(i=this.nextChar,this.next())):(i=n,this.next())}this.next(),this.currentChar!="'"?this.pushError("Das Ende der char-Konstante wird erwartet (').",1):this.next(),this.pushToken(s.charConstant,i,t,e)}lexStringConstant(e){let t=this.line,i=this.column,n="";for(this.next();;){let r=this.currentChar;if(r=="\\"){let o=Je[this.nextChar];if(o==null)if(this.nextChar=="u"){let l="";for(this.next(),this.next();"abcdef0123456789".indexOf(this.currentChar)>=0&&l.length<4;)l+=this.currentChar,l.length<4&&this.next();l.length<4?this.pushError("Unbekanntes Unicode-Zeichen: u"+l,1+l.length):r=String.fromCodePoint(parseInt(l,16))}else this.pushError("Die Escape-Sequenz \\"+this.nextChar+" gibt es nicht.",2);else r=o,this.next()}else if(r==e){if(this.next(),this.currentChar!=e)break;n+=e}else if(r==`
4
- `||r==I){this.pushError("Innerhalb einer String-Konstante wurde das Zeilenende erreicht.",n.length+1,"error",t,i);break}n+=r,this.next()}e=="'"?this.pushToken(s.stringConstant,n,t,i,n.length+2):(this.pushToken(s.identifier,n,t,i,n.length+2),this.tokenList[this.tokenList.length-1].isDoubleQuotedIdentifier=!0)}lexMultilineComment(){let e=this.line,t=this.column,i=!1,n="/*";for(this.next(),this.next();;){let r=this.currentChar;if(r=="*"&&this.nextChar=="/"){this.next(),this.next(),n+="*/";break}if(r==I){this.pushError("Innerhalb eines Mehrzeilenkommentars (/*... */) wurde das Dateiende erreicht.",1);break}r==`
1
+ var Pt=Object.defineProperty;var Mt=(a,e,t)=>e in a?Pt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var h=(a,e,t)=>Mt(a,typeof e!="symbol"?e+"":e,t);import{l as C,e as x,U as jt,R as rt,K as Qe,a as Ze,M as te,W as $t,b as It,c as Bt,d as Ot,f as At}from"./assets/monaco-editor-DtkeIt2Q.js";/* empty css */import{j as c}from"./assets/jquery-CauBH1CL.js";import{p as H}from"./assets/pako-DwGzBETv.js";import{i as Ft,w as Nt}from"./assets/sql.js-Ck07Zxpa.js";import{Z as Je,H as Wt,B as Rt,T as qt}from"./assets/zip.js-DcZ2UyDZ.js";import{M as Ye}from"./assets/markdown-it-C44Roubk.js";import"./sql-ide-embedded.js";import"./assets/mdurl-k9Sl0PQj.js";import"./assets/uc.micro-kMc2yuuw.js";import"./assets/entities-C20TfXL6.js";import"./assets/linkify-it-DmNjr4Kv.js";import"./assets/punycode.js-Dj65hjkv.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))i(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(n){if(n.ep)return;n.ep=!0;const r=t(n);fetch(n.href,r)}})();var s=(a=>(a[a.identifier=0]="identifier",a[a.integerConstant=1]="integerConstant",a[a.floatingPointConstant=2]="floatingPointConstant",a[a.booleanConstant=3]="booleanConstant",a[a.stringConstant=4]="stringConstant",a[a.charConstant=5]="charConstant",a[a.true=6]="true",a[a.false=7]="false",a[a.keywordRename=8]="keywordRename",a[a.keywordDistinct=9]="keywordDistinct",a[a.keywordTo=10]="keywordTo",a[a.keywordAlter=11]="keywordAlter",a[a.keywordCommit=12]="keywordCommit",a[a.keywordAdd=13]="keywordAdd",a[a.keywordDelete=14]="keywordDelete",a[a.keywordSelect=15]="keywordSelect",a[a.keywordInsert=16]="keywordInsert",a[a.keywordInto=17]="keywordInto",a[a.keywordValues=18]="keywordValues",a[a.keywordUpdate=19]="keywordUpdate",a[a.keywordSet=20]="keywordSet",a[a.keywordNo=21]="keywordNo",a[a.keywordUse=22]="keywordUse",a[a.keywordCreate=23]="keywordCreate",a[a.keywordReferences=24]="keywordReferences",a[a.keywordPrimary=25]="keywordPrimary",a[a.keywordForeign=26]="keywordForeign",a[a.keywordTable=27]="keywordTable",a[a.keywordSchema=28]="keywordSchema",a[a.keywordTables=29]="keywordTables",a[a.keywordColumn=30]="keywordColumn",a[a.keywordDrop=31]="keywordDrop",a[a.keywordUnique=32]="keywordUnique",a[a.keywordKey=33]="keywordKey",a[a.keywordIndex=34]="keywordIndex",a[a.keywordConstraint=35]="keywordConstraint",a[a.keywordModify=36]="keywordModify",a[a.keywordCascade=37]="keywordCascade",a[a.keywordRestrict=38]="keywordRestrict",a[a.keywordAction=39]="keywordAction",a[a.keywordAutoincrement=40]="keywordAutoincrement",a[a.keywordFrom=41]="keywordFrom",a[a.keywordWhere=42]="keywordWhere",a[a.keywordGroup=43]="keywordGroup",a[a.keywordBy=44]="keywordBy",a[a.keywordHaving=45]="keywordHaving",a[a.keywordOrder=46]="keywordOrder",a[a.keywordAscending=47]="keywordAscending",a[a.keywordDescending=48]="keywordDescending",a[a.keywordNulls=49]="keywordNulls",a[a.keywordFirst=50]="keywordFirst",a[a.keywordLast=51]="keywordLast",a[a.keywordIs=52]="keywordIs",a[a.keywordNull=53]="keywordNull",a[a.keywordDatabase=54]="keywordDatabase",a[a.keywordUnion=55]="keywordUnion",a[a.keywordView=56]="keywordView",a[a.keywordEnum=57]="keywordEnum",a[a.keywordBetween=58]="keywordBetween",a[a.keywordNotBetween=59]="keywordNotBetween",a[a.keywordNotLike=60]="keywordNotLike",a[a.keywordOr=61]="keywordOr",a[a.keywordAnd=62]="keywordAnd",a[a.keywordNot=63]="keywordNot",a[a.keywordJoin=64]="keywordJoin",a[a.keywordNatural=65]="keywordNatural",a[a.keywordLeft=66]="keywordLeft",a[a.keywordCross=67]="keywordCross",a[a.keywordInner=68]="keywordInner",a[a.keywordOuter=69]="keywordOuter",a[a.keywordOn=70]="keywordOn",a[a.keywordAs=71]="keywordAs",a[a.keywordLimit=72]="keywordLimit",a[a.keywordOffset=73]="keywordOffset",a[a.keywordIn=74]="keywordIn",a[a.keywordNotIn=75]="keywordNotIn",a[a.keywordLike=76]="keywordLike",a[a.keywordCollate=77]="keywordCollate",a[a.keywordDefault=78]="keywordDefault",a[a.keywordComment=79]="keywordComment",a[a.keywordEngine=80]="keywordEngine",a[a.keywordCharset=81]="keywordCharset",a[a.keywordCharacter=82]="keywordCharacter",a[a.keywordStart=83]="keywordStart",a[a.keywordTransaction=84]="keywordTransaction",a[a.keywordIf=85]="keywordIf",a[a.keywordExists=86]="keywordExists",a[a.keywordLock=87]="keywordLock",a[a.keywordUnlock=88]="keywordUnlock",a[a.keywordWrite=89]="keywordWrite",a[a.keywordRead=90]="keywordRead",a[a.leftBracket=91]="leftBracket",a[a.rightBracket=92]="rightBracket",a[a.leftSquareBracket=93]="leftSquareBracket",a[a.rightSquareBracket=94]="rightSquareBracket",a[a.leftCurlyBracket=95]="leftCurlyBracket",a[a.rightCurlyBracket=96]="rightCurlyBracket",a[a.leftRightSquareBracket=97]="leftRightSquareBracket",a[a.dot=98]="dot",a[a.modulo=99]="modulo",a[a.minus=100]="minus",a[a.plus=101]="plus",a[a.multiplication=102]="multiplication",a[a.division=103]="division",a[a.singleQuote=104]="singleQuote",a[a.doubleQuote=105]="doubleQuote",a[a.identifierQuote=106]="identifierQuote",a[a.lower=107]="lower",a[a.greater=108]="greater",a[a.lowerOrEqual=109]="lowerOrEqual",a[a.greaterOrEqual=110]="greaterOrEqual",a[a.concatenation=111]="concatenation",a[a.equal=112]="equal",a[a.notEqual=113]="notEqual",a[a.semicolon=114]="semicolon",a[a.colon=115]="colon",a[a.comma=116]="comma",a[a.backslash=117]="backslash",a[a.pipe=118]="pipe",a[a.at=119]="at",a[a.hash=120]="hash",a[a.space=121]="space",a[a.tab=122]="tab",a[a.newline=123]="newline",a[a.linefeed=124]="linefeed",a[a.identifierChar=125]="identifierChar",a[a.comment=126]="comment",a[a.exclamationMark=127]="exclamationMark",a[a.endofSourcecode=128]="endofSourcecode",a[a.constantNode=129]="constantNode",a[a.callMethod=130]="callMethod",a[a.unaryOp=131]="unaryOp",a[a.binaryOp=132]="binaryOp",a[a.table=133]="table",a[a.subquery=134]="subquery",a[a.list=135]="list",a[a.column=136]="column",a[a.columnDef=137]="columnDef",a[a.allColumns=138]="allColumns",a[a.isNull=139]="isNull",a[a.isNot=140]="isNot",a[a.isNotNull=141]="isNotNull",a[a.omittedeStatement=142]="omittedeStatement",a))(s||{}),_={0:"ein Bezeichner",1:"eine Integer-Konstante",2:"eine Fließkomma-Konstante",3:"eine boolesche Konstante",4:"eine Zeichenketten-Konstante",5:"eine char-Konstante",6:"true",7:"false",8:"rename",9:"distinct",10:"to",11:"alter",12:"commit",13:"add",14:"delete",15:"select",16:"insert",17:"into",18:"values",19:"update",20:"set",21:"no",22:"use",23:"create",24:"references",25:"primary",26:"foreign",27:"table",28:"schema",29:"tables",30:"column",31:"drop",32:"unique",33:"key",34:"index",35:"constraint",36:"modify",37:"cascade",38:"restrict",39:"action",40:"autoincrement",41:"from",42:"where",43:"group",44:"by",45:"having",46:"order",47:"ascending",48:"descending",49:"nulls",50:"first",51:"last",52:"is",53:"null",54:"database",55:"union",56:"view",57:"enum",58:"between",59:"not between",60:"not like",62:"and",61:"or",63:"not",64:"join",65:"natural",66:"left",67:"cross",68:"inner",69:"outer",70:"on",71:"as",72:"limit",73:"offset",74:"in",75:"not in",76:"like",77:"collate",78:"default",79:"comment",80:"engine",81:"charset",82:"character",83:"start",84:"transaction",85:"if",86:"exists",87:"lock",88:"unlock",89:"write",90:"read",91:"(",92:")",93:"[",94:"]",95:"{",96:"}",97:"[]",98:".",100:"-",99:"%",101:"+",102:"*",103:"/",104:"'",105:'"',106:"`",107:"<",108:">",112:"=",109:"<=",110:">=",111:"||",114:";",115:":",116:",",117:"\\",119:"@",120:"#",118:"|",121:"ein Leerzeichen",122:"ein Tabulatorzeichen",123:"ein Zeilenumbruch",125:"eines der Zeichen a..z, A..Z, _",126:"ein Kommentar",128:"das Ende des Programmes"},je={"(":91,")":92,"[":93,"]":94,"{":95,"}":96,"!":127,".":98,",":116,"-":100,"%":99,"+":101,"*":102,"/":103,"\\":117,"@":119,"#":120,"|":118,"'":104,'"':105,"`":106,"<":107,">":108,"=":112,"<>":113,";":114,":":115," ":121," ":122,"\n":123,"\r":124},zt={rename:8,distinct:9,to:10,alter:11,commit:12,add:13,delete:14,select:15,insert:16,into:17,values:18,update:19,set:20,no:21,use:22,create:23,references:24,primary:25,foreign:26,table:27,tables:29,column:30,drop:31,unique:32,key:33,index:34,constraint:35,modify:36,cascade:37,restrict:38,action:39,autoincrement:40,auto_increment:40,from:41,where:42,true:6,false:7,group:43,by:44,having:45,order:46,asc:47,desc:48,nulls:49,first:50,last:51,is:52,null:53,database:54,union:55,view:56,enum:57,between:58,or:61,and:62,not:63,join:64,natural:65,left:66,cross:67,inner:68,outer:69,on:70,as:71,limit:72,offset:73,in:74,"not in":75,"not between":59,like:76,collate:77,default:78,comment:79,engine:80,charset:81,character:82,start:83,transaction:84,if:85,exists:86,lock:87,unlock:88,write:89,read:90},Xe={n:`
2
+ `,r:"\r",t:" ",'"':'"',"'":"'","\\":"\\"},B="►";class Re{constructor(){h(this,"tokenList");h(this,"nonSpaceLastTokenType");h(this,"nonSpaceLastToken");h(this,"errorList");h(this,"pos");h(this,"line");h(this,"column");h(this,"currentChar");h(this,"nextChar");h(this,"input");h(this,"spaceTokens",[s.space,s.tab,s.newline]);h(this,"bracketStack");h(this,"bracketError");h(this,"correspondingBracket",{});h(this,"tokenTypesToMerge",[{first:s.keywordNotIn,second:s.keywordIn,merged:s.keywordNotIn},{first:s.keywordNot,second:s.keywordBetween,merged:s.keywordNotBetween},{first:s.keywordNot,second:s.keywordLike,merged:s.keywordNotLike},{first:s.keywordIs,second:s.keywordNot,merged:s.isNot},{first:s.isNot,second:s.keywordNull,merged:s.isNotNull},{first:s.keywordIs,second:s.keywordNull,merged:s.isNull}]);this.correspondingBracket[s.leftBracket]=s.rightBracket,this.correspondingBracket[s.leftCurlyBracket]=s.rightCurlyBracket,this.correspondingBracket[s.leftSquareBracket]=s.rightSquareBracket,this.correspondingBracket[s.rightBracket]=s.leftBracket,this.correspondingBracket[s.rightCurlyBracket]=s.leftCurlyBracket,this.correspondingBracket[s.rightSquareBracket]=s.leftSquareBracket}lex(e){if(this.input=e.replace(" "," "),this.tokenList=[],this.errorList=[],this.bracketError=null,this.bracketStack=[],this.pos=0,this.line=1,this.column=1,this.nonSpaceLastTokenType=null,this.nonSpaceLastToken=null,e.length==0)return{tokens:this.tokenList,errors:this.errorList,bracketError:null};for(this.currentChar=e.charAt(0),this.nextChar=e.length>1?e.charAt(1):B;this.currentChar!=B;)this.mainState();if(this.bracketStack.length>0){let t=this.bracketStack.pop(),i=this.correspondingBracket[t];this.setBracketError(_[t]+" "+_[i])}return{tokens:this.tokenList,errors:this.errorList,bracketError:this.bracketError}}checkClosingBracket(e){if(this.bracketStack.length==0){let n=this.correspondingBracket[e];this.setBracketError(_[n]+" "+_[e]);return}let t=this.bracketStack.pop(),i=this.correspondingBracket[t];e!=i&&this.setBracketError(_[t]+" "+_[i])}setBracketError(e){this.bracketError==null&&(this.bracketError=e)}next(){this.pos++,this.currentChar=this.nextChar,this.pos+1<this.input.length?this.nextChar=this.input.charAt(this.pos+1):this.nextChar=B,this.column++}mainState(){let e=this.currentChar,t=je[e];if(t!=null){switch(t){case s.exclamationMark:if(this.nextChar=="="){this.pushToken(s.notEqual,"!="),this.next(),this.next();return}else{this.pushToken(s.exclamationMark,"!"),this.next();return}case s.leftSquareBracket:if(this.nextChar=="]"){this.pushToken(s.leftRightSquareBracket,"[]"),this.next(),this.next();return}else{this.pushToken(s.leftSquareBracket,"["),this.bracketStack.push(t),this.next();return}case s.division:if(this.nextChar=="*"){this.lexMultilineComment();return}this.pushToken(s.division,"/"),this.next();return;case s.pipe:if(this.nextChar=="|"){this.pushToken(s.concatenation,"||"),this.next(),this.next();return}else{this.pushToken(s.pipe,"|"),this.next();return}case s.lower:if(this.nextChar==">"){this.pushToken(s.notEqual,"<>"),this.next(),this.next();return}else if(this.nextChar=="="){this.pushToken(s.lowerOrEqual,"<="),this.next(),this.next();return}else{this.pushToken(s.lower,"<"),this.next();return}case s.greater:if(this.nextChar=="="){this.pushToken(s.greaterOrEqual,">="),this.next(),this.next();return}else{this.pushToken(s.greater,">"),this.next();return}case s.rightSquareBracket:this.checkClosingBracket(t);break;case s.leftBracket:this.bracketStack.push(t);break;case s.rightBracket:this.checkClosingBracket(t);break;case s.leftCurlyBracket:this.bracketStack.push(t);break;case s.rightCurlyBracket:this.checkClosingBracket(t);break;case s.minus:if(this.isDigit(this.nextChar,10)&&!([s.identifier,s.integerConstant,s.floatingPointConstant,s.rightBracket].indexOf(this.nonSpaceLastTokenType)>=0)){this.lexNumber();return}else if(this.nextChar=="-"){this.lexEndofLineComment("--");return}else{this.pushToken(s.minus,"-"),this.next();return}case s.hash:if(this.nonSpaceLastToken==null||this.nonSpaceLastToken.position.line<this.line){this.lexEndofLineComment("#");return}else this.pushToken(s.hash,"#"),this.next();break;case s.singleQuote:this.lexStringConstant("'");return;case s.doubleQuote:this.lexStringConstant('"');return;case s.newline:this.pushToken(s.newline,`
3
+ `),this.line++,this.column=0,this.next();return;case s.space:case s.tab:this.lexSpace();return;case s.linefeed:this.next();return;case s.at:this.lexAnnotation();return;case s.identifierQuote:this.lexQuotedIdentifier();return}this.pushToken(t,e),this.next();return}if(this.isDigit(e,10)){this.lexNumber();return}this.lexIdentifierOrKeyword()}lexQuotedIdentifier(){let e=this.line,t=this.column,i="";for(this.next();this.currentChar!="`"&&this.currentChar!=B;)i+=this.currentChar,this.next();this.currentChar==B?this.pushError("Innerhalb eines in `` eingeschlossenen Bezeichners wurde das Ende der Datei erreicht.",i.length+1,"error",e,t):(this.next(),this.pushToken(s.identifier,i,e,t))}pushToken(e,t,i=this.line,n=this.column,r=(""+t).length){let o={tt:e,value:t,position:{column:n,line:i,length:r}};for(let l of this.tokenTypesToMerge)if(e==l.second&&this.nonSpaceLastTokenType==l.first){let d=n-this.nonSpaceLastToken.position.column+r;this.nonSpaceLastToken.tt=l.merged,this.nonSpaceLastToken.position={column:this.nonSpaceLastToken.position.column,line:i,length:d},this.nonSpaceLastToken.value=this.nonSpaceLastToken.value+" "+t,this.nonSpaceLastTokenType=l.merged;return}this.spaceTokens.indexOf(e)>=0||(this.nonSpaceLastTokenType=e,this.nonSpaceLastToken=o),this.tokenList.push(o)}pushError(e,t,i="error",n=this.line,r=this.column){this.errorList.push({text:e,position:{line:n,column:r,length:t},level:i})}isDigit(e,t){var i=e.charCodeAt(0);if(t==10)return i>=48&&i<=57;if(t==2)return i>=48&&i<=49;if(t==8)return i>=48&&i<=55;if(t==16)return i>=48&&i<=57||i>=97&&i<=102||i>=65&&i<=70}lexSpace(){let e=this.column,t=this.line,i=this.pos;for(;this.currentChar==" "||this.currentChar==" ";)this.next();let n=this.pos;this.pushToken(s.space,this.input.substring(i,n),t,e)}lexCharacterConstant(){let e=this.column,t=this.line;this.next();let i=this.currentChar;if(i=="\\"){let n=Xe[this.nextChar];n==null?(this.pushError("Die Escape-Sequenz \\"+this.nextChar+" gibt es nicht.",2),this.nextChar!="'"&&(i=this.nextChar,this.next())):(i=n,this.next())}this.next(),this.currentChar!="'"?this.pushError("Das Ende der char-Konstante wird erwartet (').",1):this.next(),this.pushToken(s.charConstant,i,t,e)}lexStringConstant(e){let t=this.line,i=this.column,n="";for(this.next();;){let r=this.currentChar;if(r=="\\"){let o=Xe[this.nextChar];if(o==null)if(this.nextChar=="u"){let l="";for(this.next(),this.next();"abcdef0123456789".indexOf(this.currentChar)>=0&&l.length<4;)l+=this.currentChar,l.length<4&&this.next();l.length<4?this.pushError("Unbekanntes Unicode-Zeichen: u"+l,1+l.length):r=String.fromCodePoint(parseInt(l,16))}else this.pushError("Die Escape-Sequenz \\"+this.nextChar+" gibt es nicht.",2);else r=o,this.next()}else if(r==e){if(this.next(),this.currentChar!=e)break;n+=e}else if(r==`
4
+ `||r==B){this.pushError("Innerhalb einer String-Konstante wurde das Zeilenende erreicht.",n.length+1,"error",t,i);break}n+=r,this.next()}e=="'"?this.pushToken(s.stringConstant,n,t,i,n.length+2):(this.pushToken(s.identifier,n,t,i,n.length+2),this.tokenList[this.tokenList.length-1].isDoubleQuotedIdentifier=!0)}lexMultilineComment(){let e=this.line,t=this.column,i=!1,n="/*";for(this.next(),this.next();;){let r=this.currentChar;if(r=="*"&&this.nextChar=="/"){this.next(),this.next(),n+="*/";break}if(r==B){this.pushError("Innerhalb eines Mehrzeilenkommentars (/*... */) wurde das Dateiende erreicht.",1);break}r==`
5
5
  `?(this.line++,this.column=0,i=!0,n+=r):i&&r==" "||(n+=r,i=!1),this.next()}this.pushToken(s.comment,n,e,t)}lexEndofLineComment(e){let t=this.line,i=this.column,n=e;for(let r=0;r<e.length;r++)this.next();for(;;){let r=this.currentChar;if(r==`
6
- `||r==I)break;n+=r,this.next()}this.pushToken(s.comment,n,t,i)}lexNumber(){let e=this.line,t=this.column,i=1;this.currentChar=="-"&&(i=-1,this.next());let n=this.pos,r=this.currentChar;this.next();let o=10;for(r=="0"&&["b","x","0","1","2","3","4","5","6","7"].indexOf(this.currentChar)>=0&&(this.currentChar=="x"?(o=16,this.next()):this.currentChar=="b"?(o=2,this.next()):o=8,n=this.pos);this.isDigit(this.currentChar,o);)this.next();let l=s.integerConstant;if(this.currentChar=="."){for(l=s.floatingPointConstant,this.next();this.isDigit(this.currentChar,10);)this.next();o!=10&&this.pushError("Eine float/double-Konstante darf nicht mit 0, 0b oder 0x beginnen.",this.pos-n,"error",this.line,this.column-(this.pos-n))}let d=this.input.substring(n,this.pos);n=this.pos;let u=0;if(this.currentChar=="e"){this.next();let f=this.pos;for(this.currentChar=="-"&&this.next();this.isDigit(this.currentChar,10);)this.next();o!=10&&this.pushError("Eine float/double-Konstante darf nicht mit 0, 0b oder 0x beginnen.",this.pos-n,"error",this.line,this.column-(this.pos-n));let p=this.input.substring(f,this.pos);u=Number.parseInt(p)}(this.currentChar=="d"||this.currentChar=="f")&&(l==s.floatingPointConstant,this.next(),o!=10&&this.pushError("Eine float/double-Konstante darf nicht mit 0, 0b oder 0x beginnen.",this.pos-n,"error",this.line,this.column-(this.pos-n)));let m=l==s.integerConstant?Number.parseInt(d,o):Number.parseFloat(d);m*=i,u!=0&&(m*=Math.pow(10,u)),this.pushToken(l,m,e,t)}lexAnnotation(){let e=this.line,t=this.column-1,i=this.pos,n=this.currentChar;for(this.next();Me[n]==null&&!this.isSpace(n)&&n!=I;)this.next(),n=this.currentChar;let r=this.pos,o=this.input.substring(i,r);this.pushToken(s.at,o,e,t,o.length+1)}lexIdentifierOrKeyword(){let e=this.line,t=this.column,i=this.pos,n=this.currentChar;for(;Me[n]==null&&!this.isSpace(n)&&n!=I;)this.next(),n=this.currentChar;let r=this.pos,o=this.input.substring(i,r),l=Rt[o.toLowerCase()];if(l!=null&&typeof l=="number"){switch(l){case s.true:this.pushToken(s.booleanConstant,!0,e,t);break;case s.false:this.pushToken(s.booleanConstant,!1,e,t);break;default:this.pushToken(l,o,e,t);break}return}this.pushToken(s.identifier,o,e,t)}isSpace(e){return e==" "||e==`
7
- `}}const qt="modulepreload",zt=function(a,e){return new URL(a,e).href},Ye={},gn=function(e,t,i){let n=Promise.resolve();if(t&&t.length>0){const o=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),d=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));n=Promise.allSettled(t.map(u=>{if(u=zt(u,i),u in Ye)return;Ye[u]=!0;const m=u.endsWith(".css"),f=m?'[rel="stylesheet"]':"";if(!!i)for(let k=o.length-1;k>=0;k--){const g=o[k];if(g.href===u&&(!m||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${f}`))return;const b=document.createElement("link");if(b.rel=m?"stylesheet":qt,m||(b.as="script"),b.crossOrigin="",b.href=u,d&&b.setAttribute("nonce",d),document.head.appendChild(b),m)return new Promise((k,g)=>{b.addEventListener("load",k),b.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${u}`)))})}))}function r(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return n.then(o=>{for(const l of o||[])l.status==="rejected"&&r(l.reason);return e().catch(r)})};class nt{constructor(){h(this,"autoFormatTriggerCharacters",[`
6
+ `||r==B)break;n+=r,this.next()}this.pushToken(s.comment,n,t,i)}lexNumber(){let e=this.line,t=this.column,i=1;this.currentChar=="-"&&(i=-1,this.next());let n=this.pos,r=this.currentChar;this.next();let o=10;for(r=="0"&&["b","x","0","1","2","3","4","5","6","7"].indexOf(this.currentChar)>=0&&(this.currentChar=="x"?(o=16,this.next()):this.currentChar=="b"?(o=2,this.next()):o=8,n=this.pos);this.isDigit(this.currentChar,o);)this.next();let l=s.integerConstant;if(this.currentChar=="."){for(l=s.floatingPointConstant,this.next();this.isDigit(this.currentChar,10);)this.next();o!=10&&this.pushError("Eine float/double-Konstante darf nicht mit 0, 0b oder 0x beginnen.",this.pos-n,"error",this.line,this.column-(this.pos-n))}let d=this.input.substring(n,this.pos);n=this.pos;let u=0;if(this.currentChar=="e"){this.next();let f=this.pos;for(this.currentChar=="-"&&this.next();this.isDigit(this.currentChar,10);)this.next();o!=10&&this.pushError("Eine float/double-Konstante darf nicht mit 0, 0b oder 0x beginnen.",this.pos-n,"error",this.line,this.column-(this.pos-n));let p=this.input.substring(f,this.pos);u=Number.parseInt(p)}(this.currentChar=="d"||this.currentChar=="f")&&(l==s.floatingPointConstant,this.next(),o!=10&&this.pushError("Eine float/double-Konstante darf nicht mit 0, 0b oder 0x beginnen.",this.pos-n,"error",this.line,this.column-(this.pos-n)));let m=l==s.integerConstant?Number.parseInt(d,o):Number.parseFloat(d);m*=i,u!=0&&(m*=Math.pow(10,u)),this.pushToken(l,m,e,t)}lexAnnotation(){let e=this.line,t=this.column-1,i=this.pos,n=this.currentChar;for(this.next();je[n]==null&&!this.isSpace(n)&&n!=B;)this.next(),n=this.currentChar;let r=this.pos,o=this.input.substring(i,r);this.pushToken(s.at,o,e,t,o.length+1)}lexIdentifierOrKeyword(){let e=this.line,t=this.column,i=this.pos,n=this.currentChar;for(;je[n]==null&&!this.isSpace(n)&&n!=B;)this.next(),n=this.currentChar;let r=this.pos,o=this.input.substring(i,r),l=zt[o.toLowerCase()];if(l!=null&&typeof l=="number"){switch(l){case s.true:this.pushToken(s.booleanConstant,!0,e,t);break;case s.false:this.pushToken(s.booleanConstant,!1,e,t);break;default:this.pushToken(l,o,e,t);break}return}this.pushToken(s.identifier,o,e,t)}isSpace(e){return e==" "||e==`
7
+ `}}const Ut="modulepreload",Ht=function(a,e){return new URL(a,e).href},et={},gn=function(e,t,i){let n=Promise.resolve();if(t&&t.length>0){const o=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),d=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));n=Promise.allSettled(t.map(u=>{if(u=Ht(u,i),u in et)return;et[u]=!0;const m=u.endsWith(".css"),f=m?'[rel="stylesheet"]':"";if(!!i)for(let k=o.length-1;k>=0;k--){const g=o[k];if(g.href===u&&(!m||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${f}`))return;const b=document.createElement("link");if(b.rel=m?"stylesheet":Ut,m||(b.as="script"),b.crossOrigin="",b.href=u,d&&b.setAttribute("nonce",d),document.head.appendChild(b),m)return new Promise((k,g)=>{b.addEventListener("load",k),b.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${u}`)))})}))}function r(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return n.then(o=>{for(const l of o||[])l.status==="rejected"&&r(l.reason);return e().catch(r)})};class st{constructor(){h(this,"autoFormatTriggerCharacters",[`
8
8
  `]);h(this,"displayName","Java-Autoformat")}init(){C.registerDocumentFormattingEditProvider("myJava",this),C.registerOnTypeFormattingEditProvider("myJava",this)}provideOnTypeFormattingEdits(e,t,i,n,r){let o=this.format(e);return Promise.resolve(o)}deleteOverlappingRanges(e){for(let t=0;t<e.length-1;t++){let i=e[t],n=e[t+1];if(!(i.range.endLineNumber<n.range.startLineNumber)&&i.range.endLineNumber==n.range.startLineNumber){if(i.range.endColumn>=n.range.startColumn)e.splice(t+1,1);else if(i.range.endColumn==0&&i.text.length>0&&n.range.startColumn==1&&n.range.endColumn>n.range.startColumn&&n.text==""){let r=i.text.length-(n.range.endColumn-n.range.startColumn);r>0?(i.text=i.text.substr(0,r),e.splice(t+1,1)):r<0?(n.range.endColumn=n.range.startColumn-r,e.splice(t,1),t--):(e.splice(t,2),t--)}}}}provideDocumentFormattingEdits(e,t,i){let n=this.format(e);return Promise.resolve(n)}format(e){let t=[],i=e.getValue(x.EndOfLinePreference.LF),n=new Re().lex(i).tokens;if(n==null)return[];let r=null,o=0,l=3,d=[],u=[],m=0,f=0;for(let p=0;p<n.length;p++){let b=n[p];switch(m--,b.tt){case s.leftCurlyBracket:if(o++,d.push(b.position.line),r!=null){let g=r.tt;(g==s.rightBracket||g==s.identifier||g==s.leftRightSquareBracket)&&this.replaceBetween(r,b,t," ")}if(p<n.length-1){let g=n[p+1];g.tt!=s.newline&&g.tt!=s.space&&this.insertSpaces(t,g.position.line,g.position.column,1)}break;case s.rightCurlyBracket:u[u.length-1]==o&&(u.pop(),o--,this.deleteSpaces(t,b.position.line,1,3)),o--;let k=d.pop();if(k!=null&&k!=b.position.line)r!=null&&r.position.line==b.position.line&&this.replace(t,b.position,b.position,`
9
- `+" ".repeat(o*l));else if(p>0){let g=n[p-1];g.tt!=s.space&&g.tt!=s.newline&&this.insertSpaces(t,b.position.line,b.position.column,1)}break;case s.leftBracket:if(f++,p<n.length-2){let g=n[p+1],w=n[p+2];g.tt==s.space&&w.tt!=s.newline&&(this.deleteSpaces(t,g.position.line,g.position.column,g.position.length),p++,w.tt==s.rightBracket&&(p++,f--))}if(p>1){let g=n[p-1],w=n[p-2];g.tt==s.space&&w.tt!=s.newline&&!this.isBinaryOperator(w.tt)&&g.position.length==1&&this.deleteSpaces(t,g.position.line,g.position.column,1)}break;case s.rightBracket:if(f--,p>1){let g=n[p-1],w=n[p-2];g.tt==s.space&&w.tt!=s.newline&&this.deleteSpaces(t,g.position.line,g.position.column,g.position.length)}break;case s.newline:if(m=2,p<n.length-2){let g=this.isBinaryOperator(r==null?void 0:r.tt),w=this.isBinaryOperator(this.getNextNonSpaceToken(p,n).tt),y=n[p+1],J=n[p+2],q=0;if(y.tt==s.newline)break;let V=0;if(y.tt==s.space){if(J.tt==s.newline)break;q=y.position.length,p++,J.tt==s.rightCurlyBracket&&(V=-1)}y.tt==s.rightCurlyBracket&&(V=-1),(w||g)&&(V=1);let G=o+V;f>0&&G++,G<0&&(G=0);let O=G*l;O>q?this.insertSpaces(t,b.position.line+1,0,O-q):O<q&&this.deleteSpaces(t,b.position.line+1,0,q-O)}break;case s.space:p<n.length-1&&n[p+1].tt!=s.comment&&p>0&&n[p-1].tt!=s.newline&&b.position.length>1&&this.deleteSpaces(t,b.position.line,b.position.column,b.position.length-1);break;case s.comma:case s.semicolon:if(p>1){let g=n[p-1],w=n[p-2];g.tt!=s.newline&&w.tt!=s.newline&&!this.isBinaryOperator(w.tt)&&g.tt==s.space&&g.position.length==1&&this.deleteSpaces(t,g.position.line,g.position.column,1)}if(p<n.length-1){let g=n[p+1];g.tt!=s.comment&&g.tt!=s.space&&g.tt!=s.newline&&this.insertSpaces(t,g.position.line,g.position.column,1)}break;case s.rightSquareBracket:r!=null&&r.tt==s.leftSquareBracket&&this.replaceBetween(r,b,t,"");break}if(this.isBinaryOperator(b.tt)){let k=b.tt==s.lower&&this.lowerBelongsToGenericExpression(p,n),g=b.tt==s.greater&&this.greaterBelongsToGenericExpression(p,n);if(m<=0&&r!=null&&[s.leftBracket,s.comma].indexOf(r.tt)<0){if(p>0){let w=n[p-1],y=k||g?0:1;w.tt==s.space?w.position.length!=y&&this.insertSpaces(t,w.position.line,w.position.column,y-w.position.length):y==1&&this.insertSpaces(t,b.position.line,b.position.column,1)}if(p<n.length-1){let w=n[p+1],y=k?0:1;w.tt==s.space?(g&&p<n.length-2&&n[p+2].tt==s.leftBracket&&(y=0),w.position.length!=y&&this.insertSpaces(t,w.position.line,w.position.column,y-w.position.length)):(g&&w.tt==s.leftBracket&&(y=0),y==1&&this.insertSpaces(t,w.position.line,w.position.column,1))}}}b.tt!=s.space&&b.tt!=s.newline&&(r=b)}return this.deleteOverlappingRanges(t),t}getNextNonSpaceToken(e,t){if(e==t.length-1)return t[e];let i=e+1;for(;i<t.length-1&&t[i].tt==s.space;)i++;return t[i]}lowerBelongsToGenericExpression(e,t){let i=e+1;for(;i<t.length;){let n=t[i].tt;if(n==s.greater)return!0;if([s.space,s.comma,s.identifier].indexOf(n)<0)return!1;i++}return!1}greaterBelongsToGenericExpression(e,t){let i=e-1;for(;i>=0;){let n=t[i].tt;if(n==s.lower)return!0;if([s.space,s.comma,s.identifier].indexOf(n)<0)return!1;i--}return!1}isBinaryOperator(e){return e!=null&&e>=s.modulo&&e<=s.equal}replaceBetween(e,t,i,n){let r={line:e.position.line,column:e.position.column+e.position.length},o={line:t.position.line,column:t.position.column};(r.line!=o.line||o.column-r.column!=n.length)&&this.replace(i,r,o,n)}deleteSpaces(e,t,i,n){e.push({range:{startColumn:i,startLineNumber:t,endColumn:i+n+(i==0?1:0),endLineNumber:t},text:""})}insertSpaces(e,t,i,n){if(n<0){this.deleteSpaces(e,t,i,-n);return}e.push({range:{startColumn:i,startLineNumber:t,endColumn:i,endLineNumber:t},text:" ".repeat(n)})}replace(e,t,i,n){e.push({range:{startColumn:t.column,startLineNumber:t.line,endColumn:i.column,endLineNumber:i.line},text:n})}}class rt{constructor(){h(this,"themes",[]);this.initThemes()}switchTheme(e){for(let t of this.themes)if(t.name==e){this.internalSwitchTheme(t);break}}internalSwitchTheme(e){x.setTheme(e.monacoTheme);let t=document.documentElement;for(const i of Object.keys(e.cssColors)){const n=e.cssColors[i];t.style.setProperty(i,n)}}initThemes(){this.themes.push({name:"dark",monacoTheme:"myCustomThemeDark",cssColors:{"--backgroundDark":"#1e1e1e","--backgroundLight":"#252526","--backgroundHeading":"#37373d","--backgroundSelected":"#2a2d2e","--fontColorNormal":"#c2cccc","--fontColorLight":"#e7e7e7","--slider":"#414141","--loginButtonBackgrond":"#59a15d","--loginButtonFontColor":"#000000","--loginMessageColor":"rgb(122, 48, 48)","--loginButtonHover":"#63a867","--loginButtonActive":"#94ffd1","--scrollbar":"#1e1e1e","--scrollbar-thumb":"#3e3e3e","--scrollbar-thumb-hover":"#5e5e5e","--scrollbar-thumb-active":"#7e7e7e","--submenu-hover":"#094771","--submenu-color":"#ffffff","--menuitemsdivider":"#616162","--file-hover":"hsla(0, 0%, 38%, 0.125)","--file-active":"#094771","--file-active-hover":"rgba(9, 71, 113, 0.827)","--file-errorcount":"red","--inplace-editor":"blue","--contextmenu-background":"#3c3c3c","--contextmenu-color":"rgb(212,212,212)","--contextmenu-hover-background":"#094771","--contextmenu-hover-color":"#ffffff","--error-filename":"#2a709e","--error-line-ative":"#094771","--error-line-hover":"rgba(96, 96, 96, 0.125)","--error-position":"#c0802d","--linecolumn":"#14c714","--reveal-error":"rgba(253, 101, 101, 0.745)","--reveal-method":"#2b2b7d2f","--reveal-errorline-background":"red","--reveal-error-whole-line":"rgba(255, 0, 0, 0.555)","--reveal-programpointer":"rgba(111, 214, 27, 0.337)","--reveal-syntaxelement":"rgb(85,85,85)","--margin-breakpoint":"rgba(255, 0, 0, 0.623)","--speedcontrol-bar":"#9d9d9d","--speedcontrol-grip":"#588555","--speedcontrol-grip-hover":"#89d185","--speedcontrol-display-background":"#383838","--speedcontrol-display-border":"#9d9d9d","--editorTooltip-background":"#252526","--editorTooltip-border":"#454545","--renameInput-color":"#ffffff","--bottomdiv-tabheading-hover":"white","--bottomdiv-tabheading-active":"rgb(97,97,255)","--noErrorMessage":"rgb(37, 211, 37)","--console-top-borderbottom":"#c4c4c4","--console-top-background":"#1e1e1e","--consoleEntry-withBorder":"#303030","--consoleEntryValue":"white","--consoleEntryIdentifier":"rgb(156, 156, 235)","--consoleEntryNoValue":"gray","--consoleEntryCaption":"white","--error-Caption":"rgb(166, 165, 176)","--console-error":"rgb(155, 51, 51)","--deIdentifier":"rgb(156, 156, 235)","--deValue":"white","--helper-background-color":"#383838","--helper-border-color":"#d4d4d4","--arrowBoxButtonOuter-background":"#59a15d","--arrowBoxButtonOuter-border":"#3d3d3d","--arrowBoxButtonOuter-color":"black","--arrowBoxButtonOuter-button-hover":"#63a867","--arrowBox-after":"rgba(136, 183, 213, 0)","--arrowBox-before":"rgba(194, 225, 245, 0)","--defaultOutputColor":"#ffffff","--runInputColor":"#ffffff","--runBackgroundColor":"rgba(255, 255, 255, 0.2)","--table-even":"#222","--table-heading":"#202060","--highlightStatementGreen-color":"#015a0165"}});let e="#8080ff";this.themes.push({name:"light",monacoTheme:"myCustomThemeLight",cssColors:{"--backgroundDark":"white","--backgroundLight":"#f3f3f3","--backgroundHeading":"#dcdcdc","--backgroundSelected":"#e8e8e8","--fontColorNormal":"#000","--fontColorLight":"#303030","--slider":"#b0b0b0","--loginButtonBackgrond":"#59a15d","--loginButtonFontColor":"#000000","--loginMessageColor":"rgb(122, 48, 48)","--loginButtonHover":"#63a867","--loginButtonActive":"#94ffd1","--scrollbar":"#e3e3e3","--scrollbar-thumb":"#bababa","--scrollbar-thumb-hover":"#8e8e8e","--scrollbar-thumb-active":"#616161","--submenu-hover":e,"--submenu-color":"#ffffff","--menuitemsdivider":"#cfcfcf","--file-hover":"#e8e8e8","--file-active":e,"--file-active-hover":"#a0a0ff","--file-errorcount":"red","--inplace-editor":"white","--contextmenu-background":"white","--contextmenu-color":"#756161","--contextmenu-hover-background":e,"--contextmenu-hover-color":"#a0a0ff","--error-filename":"#ff0000","--error-line-ative":"#ffa0a0","--error-line-hover":"#ffc0c0","--error-position":"#804040","--linecolumn":"#14c714","--reveal-error":"rgba(253, 101, 101, 0.745)","--reveal-method":"#babaec80","--reveal-errorline-background":"red","--reveal-error-whole-line":"rgba(255, 0, 0, 0.555)","--reveal-programpointer":"rgba(111, 214, 27, 0.337)","--reveal-syntaxelement":"#c0c0c0","--margin-breakpoint":"rgba(255, 0, 0, 0.623)","--speedcontrol-bar":"#9d9d9d","--speedcontrol-grip":"#588555","--speedcontrol-grip-hover":"#89d185","--speedcontrol-display-background":"#e0e0e0","--speedcontrol-display-border":"#9d9d9d","--editorTooltip-background":"#e0e0e0","--editorTooltip-border":"#9d9d9d","--renameInput-color":"#000000","--bottomdiv-tabheading-hover":"#424242","--bottomdiv-tabheading-active":"#424242","--noErrorMessage":"rgb(17, 180, 17)","--console-top-borderbottom":"#c4c4c4","--console-top-background":"white","--consoleEntry-withBorder":"#303030","--consoleEntryValue":"#0000a0","--consoleEntryIdentifier":"black","--consoleEntryNoValue":"gray","--consoleEntryCaption":"#756161","--error-Caption":"rgb(166, 165, 176)","--console-error":"rgb(155, 21, 21)","--deIdentifier":"black","--deValue":"#0000a0","--helper-background-color":"#f3f3f3","--helper-border-color":"#606060","--arrowBoxButtonOuter-background":"#59a15d","--arrowBoxButtonOuter-border":"#3d3d3d","--arrowBoxButtonOuter-color":"black","--arrowBoxButtonOuter-button-hover":"#63a867","--arrowBox-after":"rgba(136, 183, 213, 0)","--arrowBox-before":"rgba(194, 225, 245, 0)","--defaultOutputColor":"#303030","--runInputColor":"#000000","--runBackgroundColor":"rgba(0, 0, 0, 0.2)","--table-even":"#d1d2e4","--table-heading":"#c3f2b9","--highlightStatementGreen-color":"#015a0120"}})}}class st{}const L=class L extends st{constructor(t,i,n,r,o){super();h(this,"binaryResultTypes",new Map);h(this,"unaryOperators",[]);h(this,"canCastToList");this.name=t,this.parameterDescriptions=i,this.checkFunction=n,this.outputFunction=r,this.canCastToList=o.slice(0);let l=this.canCastToList.indexOf(t);l>=0&&this.canCastToList.splice(l,1)}static fromConstantType(t){switch(t){case s.stringConstant:return this.baseTypeMap.get("text");case s.integerConstant:return this.baseTypeMap.get("integer");case s.floatingPointConstant:return this.baseTypeMap.get("float");case s.charConstant:return this.baseTypeMap.get("text");case s.booleanConstant:return this.baseTypeMap.get("boolean");case s.keywordNull:return this.baseTypeMap.get("null")}}getBaseTypeName(){return this.name}toString(){return this.name}getSQLiteType(){return this.toString()}static getBaseType(t){return t!=null&&t.toLocaleLowerCase()=="char"&&(t="varchar"),this.baseTypeMap.get(t.toLocaleLowerCase())}static addBaseTypes(t){L.baseTypes=L.baseTypes.concat(t),t.forEach(i=>L.baseTypeMap.set(i.name,i))}addBinaryOperation(t,i,n,r=!0){Array.isArray(t)||(t=[t]),t.forEach(o=>{let l=this.binaryResultTypes.get(o);l==null&&(l=new Map,this.binaryResultTypes.set(o,l)),l.set(i,n),r&&i!=this&&i.addBinaryOperation(o,this,n,!1)})}canCastTo(t){let i=t instanceof L?t:t.baseType;return i instanceof ce&&(i=L.getBaseType("text")),i instanceof he&&(i=L.getBaseType("double")),this.canCastToList.indexOf(i.name)>=0||this.name==i.name}getBinaryResultType(t,i){let n=this.binaryResultTypes.get(t);if(n==null)return null;let r=i instanceof L?i:i.baseType;return r instanceof ce&&(r=L.getBaseType("text")),r instanceof he&&(r=L.getBaseType("double")),n.get(r)}getUnaryResultType(t){if([s.isNull,s.isNotNull].indexOf(t)>=0)return E;if(this.unaryOperators.indexOf(t)>=0)return this}getBinaryResult(t,i,n){switch(t){case s.concatenation:return i!=null&&n!=null?i+n:i??n;case s.plus:return i!=null&&n!=null?i+n:i??n;case s.minus:return i!=null&&n!=null?i-n:i??n;case s.multiplication:return i!=null&&n!=null?i*n:i??n;case s.division:return i!=null&&n!=null?i*n:i??n;case s.keywordAnd:return i!=null&&n!=null?i*n:i??n;case s.keywordOr:return i!=null&&n!=null?Math.max(i,n):i??n;case s.lower:return i!=null&&n!=null?i<n:i==null;case s.greater:return i!=null&&n!=null?i>=n:i==null;case s.lowerOrEqual:return i!=null&&n!=null?i<=n:i==null;case s.greaterOrEqual:return i!=null&&n!=null?i>=n:i==null;case s.equal:return i==n;case s.notEqual:return i!=n;case s.modulo:return i%n}}};h(L,"baseTypes",[]),h(L,"baseTypeMap",new Map);let v=L;class he extends v{constructor(t){super("NumberEnum",[],(i,n)=>`check(${i} in (${t.join(", ")}))`,(i,n)=>i,["decimal","integer","double","float"]);h(this,"isInteger",!0);h(this,"numericBinaryOperators",[s.plus,s.minus,s.multiplication,s.division,s.modulo]);h(this,"comparisonOperators",[s.lower,s.lowerOrEqual,s.greater,s.greaterOrEqual,s.equal,s.notEqual]);this.values=t;for(let i of t)Math.abs(Math.round(i)-i)>1e-8&&(this.isInteger=!1);this.name=this.isInteger?"integerEnum":"floatEnum"}getBinaryResultType(t,i){return this.numericBinaryOperators.indexOf(t)>=0?this.isInteger?v.getBaseType("integer"):v.getBaseType("double"):v.getBaseType("boolean")}getUnaryResultType(t){return null}getBinaryResult(t,i,n){return i+n}toString(){return"enum ("+this.values.join(", ")+")"}getBaseTypeName(){return"enum"}getSQLiteType(){return this.isInteger?"integerEnum":"realEnum"}}class ce extends v{constructor(e){super("textEnum",[],(t,i)=>`check(${t} in (${e.map(n=>"'"+n+"'").join(", ")}))`,(t,i)=>t,["text","varchar","char"]),this.values=e}getBinaryResultType(e,t){return e==s.concatenation?v.getBaseType("text"):null}getUnaryResultType(e){return null}getBinaryResult(e,t,i){return t+i}toString(){return"enum ("+this.values.join(", ")+")"}getBaseTypeName(){return"enum"}getSQLiteType(){return"textEnum"}}let Be=[1,10,100,1e3,1e5,1e5,1e6,1e7,1e8,1e9];class le extends st{constructor(t,i){super();h(this,"name");this.baseType=t,this.parameterValues=i;let n=i.join(", ");this.name=t.name+"("+n+")"}toString(){return this.name}getBaseTypeName(){return this.baseType.name}getSQLiteType(){return this.baseType.getSQLiteType()}canCastTo(t){let i=t instanceof v?t:t.baseType;return this.baseType.canCastToList.indexOf(i.name)>=0||this.baseType.name==i.name}getBinaryResultType(t,i){let n=this.baseType.binaryResultTypes.get(t);if(n==null)return null;let r=i instanceof v?i:i.baseType,o=n.get(r);if(this.baseType==r&&this.baseType==o&&i instanceof le){if(this.baseType.name=="varchar"||t==s.concatenation)return new le(this.baseType,[this.parameterValues[0]+i.parameterValues[0]]);if(this.baseType.name=="decimal")return new le(this.baseType,[Math.max(this.parameterValues[0],i.parameterValues[0]),Math.max(this.parameterValues[1],i.parameterValues[1])])}return n.get(r)}getUnaryResultType(t){return this.baseType.getUnaryResultType(t)}getBinaryResult(t,i,n){let r=this.baseType.getBinaryResult(t,i,n);return(this.name="varchar")?r==null?null:(""+r).substr(0,this.parameterValues[0]):this.name=="decimal"?r==null?null:Math.round(r*Be[this.parameterValues[1]])/Be[this.parameterValues[1]]:r}}let ne=["varchar","char","text","tinytext","mediumtext","longtext"];var j=new v("varchar",["Maximale Länge"],(a,e)=>`check(length(${a}) <= ${Math.max(e[0],1)})`,(a,e)=>a.substring(0,Math.max(e[0],1)),ne),$=new v("char",["Maximale Länge"],(a,e)=>`check(length(${a}) <= ${Math.max(e[0],1)})`,(a,e)=>a.substring(0,Math.max(e[0],1)),ne),_=new v("text",["Maximale Länge"],(a,e)=>"",(a,e)=>a,ne.concat(["time","date","datetime","timestamp"])),Ut=new v("tinyText",[],(a,e)=>"",(a,e)=>a,ne),Ht=new v("mediumText",[],(a,e)=>"",(a,e)=>a,ne),Kt=new v("longText",[],(a,e)=>"",(a,e)=>a,ne);let re=["decimal","numeric","double","real","float","floatEnum"];var we=new v("decimal",["Gesamtzahl der Stellen","Nachkommastellen"],(a,e)=>"",(a,e)=>{let t=Math.trunc(a),i=a-t;return""+t+(e[1]>0?"."+Math.round(i*Be[e[1]]):"")},re),Vt=new v("numeric",["Gesamtzahl der Stellen","Nachkommastellen"],(a,e)=>"",(a,e)=>""+a,re),Gt=new v("double",["Gesamtzahl der Stellen","Nachkommastellen"],(a,e)=>"",(a,e)=>""+a,re),Qt=new v("real",[],(a,e)=>"",(a,e)=>""+a,re),Zt=new v("float",[],(a,e)=>"",(a,e)=>""+a,re);let Jt=["int","integer","tinyint","smallint","mediumint","bigint","integerEnum"],se=Jt.concat(re);var Yt=new v("int",["Maximale Anzahl der Stellen"],(a,e)=>`check(round(${a}) = ${a})`,(a,e)=>""+Math.round(a),se),Xt=new v("integer",["Maximale Anzahl der Stellen"],(a,e)=>`check(round(${a}) = ${a})`,(a,e)=>""+Math.round(a),se),ei=new v("tinyint",["Maximale Anzahl der Stellen"],(a,e)=>`check(round(${a}) = ${a})`,(a,e)=>""+Math.round(a),se),ti=new v("smallint",["Maximale Anzahl der Stellen"],(a,e)=>`check(round(${a}) = ${a})`,(a,e)=>""+Math.round(a),se),ii=new v("mediumint",["Maximale Anzahl der Stellen"],(a,e)=>`check(round(${a}) = ${a})`,(a,e)=>""+Math.round(a),se),ni=new v("bigint",["Maximale Anzahl der Stellen"],(a,e)=>`check(round(${a}) = ${a})`,(a,e)=>""+Math.round(a),se),ot=new v("time",[],(a,e)=>`check(isTime(${a}))`,(a,e)=>a,[]),at=new v("date",[],(a,e)=>`check(isDate(${a}))`,(a,e)=>a,[]),lt=new v("datetime",[],(a,e)=>`check(isDateTime(${a}))`,(a,e)=>a,["timestamp"]),dt=new v("timestamp",[],(a,e)=>`check(isDateTime(${a}))`,(a,e)=>a,["datetime"]),E=new v("boolean",[],(a,e)=>`check(${a} == 0 or ${a} == 1)`,(a,e)=>a==1?"true":"false",["varchar","text","decimal","numeric"]),ri=new v("null",[],(a,e)=>"",(a,e)=>a,[]);let A=[we,Vt,Gt,Qt,Zt,Yt,Xt,ei,ti,ii,ni],ut=[j,$,_,Ut,Ht,Kt,ot,at,lt,dt,E,ri].concat(A),oe=[ot,at,lt,dt];v.addBaseTypes(ut);j.addBinaryOperation(s.concatenation,j,j);j.addBinaryOperation(s.concatenation,$,j);j.addBinaryOperation(s.concatenation,_,_);_.addBinaryOperation(s.concatenation,_,_);j.addBinaryOperation(s.keywordLike,j,E);j.addBinaryOperation(s.keywordLike,_,E);_.addBinaryOperation(s.keywordLike,_,E);$.addBinaryOperation(s.concatenation,$,$);$.addBinaryOperation(s.concatenation,j,$);$.addBinaryOperation(s.concatenation,_,_);_.addBinaryOperation(s.concatenation,_,_);$.addBinaryOperation(s.keywordLike,$,E);$.addBinaryOperation(s.keywordLike,_,E);_.addBinaryOperation(s.keywordLike,_,E);E.addBinaryOperation(s.equal,E,E);let ht=[s.plus,s.minus,s.multiplication,s.division,s.modulo],de=[s.lower,s.lowerOrEqual,s.greater,s.greaterOrEqual,s.equal,s.notEqual];for(let a=0;a<A.length;a++){for(let e=a;e<A.length;e++)A[a].addBinaryOperation(ht,A[e],A[e]),A[a].addBinaryOperation(de,A[e],E);A[a].unaryOperators=[s.minus]}we.addBinaryOperation(ht,we,we);let B=[j,_];for(let a=0;a<B.length;a++)for(let e=a;e<B.length;e++)B[a].addBinaryOperation(s.concatenation,B[e],B[e]),B[a].addBinaryOperation(de,B[e],E);for(let a=0;a<oe.length;a++){oe[a].addBinaryOperation(de,oe[a],E);for(let e=0;e<B.length;e++)oe[a].addBinaryOperation(de,B[e],E),B[e].addBinaryOperation(de,oe[a],E)}let si=[s.keywordAnd,s.keywordOr];E.addBinaryOperation(si,E,E);E.unaryOperators=[s.keywordNot];ut.forEach(a=>a.unaryOperators=a.unaryOperators.concat([s.isNull,s.isNotNull]));const Q=class Q{constructor(){h(this,"module");h(this,"pos");h(this,"tokenList");h(this,"errorList");h(this,"lookahead",4);h(this,"ct");h(this,"lastToken");h(this,"cct");h(this,"tt");h(this,"position");h(this,"lastComment");h(this,"endToken",{position:{line:0,column:0,length:1},tt:s.endofSourcecode,value:"das Ende des Programms"});h(this,"beginStatementKeywords",["select","insert into","update","create table","create view","delete from","alter table","drop table","drop view"]);h(this,"identifierMap",{year:"int",binary:"varchar",varbinary:"varchar"})}parse(e){if(this.module=e,this.tokenList=e.tokenList,this.errorList=[],e.completionHints=new Map,this.tokenList.length==0){this.module.sqlStatements=[],this.module.errors[1]=this.errorList,this.module.addCompletionHint({line:0,column:0,length:0},{line:2e4,column:100,length:0},!1,!1,this.beginStatementKeywords);return}this.pos=0,this.initializeLookahead();let t=this.tokenList[this.tokenList.length-1];this.endToken.position={line:t.position.line,column:t.position.column+t.position.length,length:1},this.module.sqlStatements=this.parseMain(),this.module.errors[1]=this.errorList}initializeLookahead(){this.ct=[];for(let e=0;e<this.lookahead;e++){let t=this.endToken;for(;!(this.pos>=this.tokenList.length);){let i=this.tokenList[this.pos];if(i.tt==s.comment&&(this.lastComment=i),i.tt!=s.newline&&i.tt!=s.space&&i.tt!=s.comment){t=i,this.lastComment!=null&&(t.commentBefore=this.lastComment,this.lastComment=null);break}this.pos++}this.ct.push(t),e<this.lookahead-1&&this.pos++}this.cct=this.ct[0],this.tt=this.cct.tt,this.position=this.cct.position}nextToken(){let e;for(this.lastToken=this.cct;;){if(this.pos++,this.pos>=this.tokenList.length){e=this.endToken;break}if(e=this.tokenList[this.pos],e.tt==s.comment&&(this.lastComment=e),e.tt!=s.newline&&e.tt!=s.space&&e.tt!=s.comment){e.commentBefore=this.lastComment,this.lastComment=null;break}}for(let t=0;t<this.lookahead-1;t++)this.ct[t]=this.ct[t+1];this.ct[this.lookahead-1]=e,this.cct=this.ct[0],this.tt=this.cct.tt,this.position=this.cct.position}pushError(e,t="error",i){i==null&&(i=Object.assign({},this.position)),this.errorList.push({text:e,position:i,level:t})}skip(e){Array.isArray(e)||(e=[e]),e.indexOf(this.tt)>=0&&this.nextToken()}expect(e,t=!0,i=!1){if(this.tt!=e&&!(Array.isArray(e)&&e.indexOf(this.tt)>=0)){if(e==s.semicolon&&this.tt==s.endofSourcecode)return!0;let n=this.cct.position;e==s.semicolon&&this.lastToken!=null&&this.lastToken.position.line<n.line&&(n={line:this.lastToken.position.line,column:this.lastToken.position.column+this.lastToken.position.length,length:1}),e==s.semicolon&&this.lastToken.position.line<this.cct.position.line&&!this.isOperatorOrDot(this.lastToken.tt)&&i&&this.module.main.getSemicolonAngel().register(n,this.module);let r;if(Array.isArray(e)){r=e.map(l=>D[l]);let o=r.join(", ");this.pushError("Erwartet wird eines der folgenden: "+o+" - Gefunden wurde: "+D[this.tt],"error",n)}else r=[D[e]],this.pushError("Erwartet wird: "+D[e]+" - Gefunden wurde: "+D[this.tt],"error",n);return!1}return t&&this.nextToken(),!0}getEndOfPosition(e){return{line:e.line,column:e.column+e.length,length:0}}isOperatorOrDot(e){if(e==s.dot)return!0;for(let t of Q.operatorPrecedence)for(let i of t)if(e==i)return!0}isEnd(){return this.cct==this.endToken}comesToken(e,t=!1){if(!Array.isArray(e)){let n=this.tt==e;return n&&t&&this.nextToken(),n}let i=e.indexOf(this.tt)>=0;return i&&t&&this.nextToken,i}getCurrentPosition(){return Object.assign({},this.position)}getCurrentPositionPlus(e){if(this.tt==s.endofSourcecode)return{line:this.endToken.position.line,column:100,length:1};let t=0,i=e,n=0;for(;t<this.lookahead-1&&(n=this.ct[t].position.length)<i;)i-=n,t++;let r=this.ct[t].position;return r==null&&(r=this.getCurrentPosition()),{line:r.line,column:r.column+i,length:1}}getEndOfCurrentToken(){let e=this.getCurrentPosition();return e.column=e.column+this.position.length,e.length=0,e}parseMain(){let e=[],t={column:0,line:0,length:0},i=!0;for(this.module.addCompletionHint(t,this.getCurrentPositionPlus(8),!1,!1,this.beginStatementKeywords);!this.isEnd();){let n=this.pos,r=this.errorList.length;for(;[s.space,s.newline,s.comment,s.semicolon].indexOf(this.cct.tt)>=0;)this.nextToken();let o=this.getCurrentPosition(),l=this.parseStatement();for(t={line:this.lastToken.position.line+1,column:0,length:0},i=this.tt==s.semicolon;this.tt==s.semicolon;)this.nextToken();let d=!1;for(let u=r;u<this.errorList.length;u++)this.errorList[u].level=="error"&&(d=!0);if(l!=null&&e.push({ast:l,from:o,to:this.getEndOfPosition(this.lastToken.position),hasErrors:d,acceptedBySQLite:!1,resultTypes:[]}),this.getCurrentPosition(),this.pos==n){let u=[s.keywordSelect,s.keywordUpdate,s.keywordCreate,s.keywordInsert,s.keywordDelete,s.keywordDrop,s.keywordAlter],m=!0;for(;!this.isEnd()&&u.indexOf(this.tt)<0;)[s.space,s.newline].indexOf(this.tt)<0&&m&&(this.pushError("Erwartet wird eines dieser Schlüsselwörter: "+u.map(f=>D[f]).join(", ")+"; Gefunden wurde: "+this.cct.value),m=!0),this.nextToken()}(i||this.cct.position.line-t.line>0)&&this.module.addCompletionHint(t,this.getCurrentPositionPlus(8),!1,!1,this.beginStatementKeywords)}return this.module.addCompletionHint(t,{line:this.endToken.position.line+1,column:0,length:0},!1,!1,this.beginStatementKeywords),e}parseStatement(e=!0){let t=null;switch(this.tt){case s.keywordSelect:return this.parseSelect();case s.keywordInsert:return this.parseInsert();case s.keywordCreate:return this.parseCreateTableOrDatabaseOrView();case s.keywordUpdate:return this.parseUpdate();case s.keywordDelete:return this.parseDelete();case s.keywordDrop:return this.parseDropTableOrView();case s.keywordAlter:return this.parseAlterTable();case s.keywordCommit:return this.pushError("Die Aweisung commit ist unnötig, da jede Anweisung automatisch commited wird.","info"),this.nextToken(),null;case s.keywordSet:return this.parseSet();case s.keywordUse:return this.parseUse();case s.keywordStart:return this.pushError("Die Aweisung 'start transaction' ist unnötig, da jede Anweisung automatisch commited wird.","info"),this.nextToken(),this.expect(s.keywordTransaction,!0),null;case s.keywordLock:case s.keywordUnlock:return this.parseLockUnlock(),null;default:let i=D[this.tt];i==null&&(i=""),i!=this.cct.value&&(i+="("+this.cct.value+")"),i+=" wird hier nicht erwartet.",this.pushError(i),this.nextToken();break}return t}parseLockUnlock(){this.nextToken(),this.expect(s.keywordTables,!0),this.skip(s.identifier),this.skip([s.keywordWrite,s.keywordRead]),this.skip(s.semicolon)}parseSet(){this.pushError("Das SET-Statement wird von SQLite nicht unterstützt. Diese Anweisung wird daher einfach überlesen.","info");let e={type:s.omittedeStatement,position:this.getCurrentPosition(),endPosition:null,symbolTable:null};return this.nextToken(),this.comesToken(s.keywordDatabase)&&this.nextToken(),this.expect(s.identifier,!0),this.comesToken(s.equal,!0),this.expect([s.identifier,s.stringConstant,s.integerConstant,s.charConstant,s.booleanConstant,s.floatingPointConstant],!0),e.endPosition=this.getCurrentPosition(),e}parseUse(){this.pushError("Das USE-Statement wird von SQLite nicht unterstützt. Diese Anweisung wird daher einfach überlesen. Sie können eine andere Datenbank auswählen indem Sie in der Datenbankliste links darauf klicken.","info");let e={type:s.omittedeStatement,position:this.getCurrentPosition(),endPosition:null,symbolTable:null};return this.nextToken(),this.expect(s.identifier,!0),e.endPosition=this.getCurrentPosition(),e}parseAlterTable(){let e=this.getCurrentPosition();this.nextToken();let t={type:s.keywordAlter,kind:null,position:e,endPosition:this.getEndOfPosition(this.getCurrentPosition()),symbolTable:null,tableIdentifier:null,tableIdentifierPosition:null};if(this.expect(s.keywordTable,!0)||this.addCompletionHintHere(!1,!1,["table"],1),this.addCompletionHintHere(!1,!0,[],1),!this.expect(s.identifier,!1))return t;switch(t.tableIdentifier=this.cct.value,t.tableIdentifierPosition=this.getCurrentPosition(),this.nextToken(),t.endPosition=this.getCurrentPosition(),this.addCompletionHintHere(!1,!1,["rename to","rename column","add column","drop column"],1),this.tt){case s.keywordRename:this.parseRenameTableOrColumn(t);break;case s.keywordAdd:this.parseAlterTableAdd(t);break;case s.keywordDrop:this.parseDropColumn(t);break;default:this.pushError("Erwartet wird rename to, rename column, add column oder drop column")}return t}parseRenameTableOrColumn(e){switch(this.nextToken(),this.comesToken(s.keywordTo)||this.addCompletionHintHere(e.tableIdentifier,!1,["column","to"],3),e.endPosition=this.getEndOfCurrentToken(),this.tt){case s.keywordTo:this.nextToken(),e.endPosition=this.getEndOfCurrentToken(),e.kind="renameTable",this.comesToken(s.identifier)?(e.newTableName=this.cct.value,this.nextToken(),e.endPosition=this.getEndOfCurrentToken()):this.pushError("Erwartet wird der neue Tabellenname.");return;case s.keywordColumn:if(this.nextToken(),e.endPosition=this.getEndOfCurrentToken(),this.addCompletionHintHere(e.tableIdentifier,!1,[],3),!this.comesToken(s.identifier)){this.pushError("Erwartet wird der Name einer Spalte der Tabelle "+e.tableIdentifier+".");return}if(e.kind="renameColumn",e.oldColumnName=this.cct.value,e.oldColumnPosition=this.getCurrentPosition(),this.nextToken(),this.addCompletionHintHere(!1,!1,["to"],3),e.endPosition=this.getEndOfCurrentToken(),!this.expect(s.keywordTo,!0))return;e.endPosition=this.getEndOfCurrentToken(),this.comesToken(s.identifier)?(e.newColumnName=this.cct.value,this.nextToken(),e.endPosition=this.getEndOfCurrentToken()):this.pushError("Erwartet wird der neue Spaltenname.");return;default:this.pushError("Erwartet wird das Schlüsselwort 'to' (zum Umbenennen der Tabelle) oder das Schlüsselwor 'column' (zum Umbenennen einer Spalte).");return}}parseDropColumn(e){this.nextToken(),this.comesToken(s.keywordColumn,!0),e.oldColumnPosition=this.getCurrentPosition(),this.addCompletionHintHere(e.tableIdentifier,!1,[],3),e.kind="dropColumn",e.endPosition=this.getEndOfCurrentToken(),this.comesToken(s.identifier)?(e.oldColumnName=this.cct.value,this.nextToken()):this.pushError("Erwartet wird der Bezeichner der Spalte, die gelöscht werden soll.")}parseAlterTableAdd(e){do{this.nextToken(),this.comesToken(s.keywordAdd,!0);let t=!1;switch(this.tt){case s.keywordColumn:this.parseAddColumn(e);break;case s.keywordPrimary:this.parseAddPrimaryKey(e);break;case s.keywordUnique:this.nextToken(),t=!0,this.expect([s.keywordIndex,s.keywordKey],!1);case s.keywordKey:case s.keywordIndex:this.parseAddIndex(e,t);break;case s.keywordModify:this.parseModifyColumn(e);break;case s.keywordConstraint:this.parseAddConstraint(e);break;default:this.parseAddColumn(e);break}}while(this.tt==s.comma)}parseAddConstraint(e){if(this.nextToken(),!!this.expect(s.identifier)&&this.comesToken(s.keywordForeign)){let t=this.parseForeignKeyDefinition();t!=null&&(e.foreignKeys==null&&(e.foreignKeys=[]),e.foreignKeys.push(t),e.kind="omittedKind")}}parseForeignKeyDefinition(){let e={column:"",referencesTable:"",referencesColumn:"",referencesPosition:this.getCurrentPosition()};if(this.expect(s.keywordForeign)&&this.expect(s.keywordKey)&&this.expect(s.leftBracket)){if(!this.comesToken(s.identifier)){this.pushError("Der Bezeichner der Fremdschlüsselspalte wird erwartet.");return}if(e.column=this.cct.value,this.nextToken(),!!this.expect(s.rightBracket))return this.parseReferences(e),e}}parseReferences(e){if(!this.expect(s.keywordReferences))return;if(this.addCompletionHintHere(!1,!0,[]),!this.comesToken(s.identifier)){this.pushError("Der Bezeichner der referenzierten Tabelle wird erwartet.");return}e.referencesTable=this.cct.value,this.nextToken();let t=this.lastToken.position,i=this.getCurrentPosition();if(this.module.addCompletionHint(this.getEndOfPosition(t),i,e.referencesTable,!1,[]),!!this.expect(s.leftBracket)){if(!this.comesToken(s.identifier)){this.pushError("Der Bezeichner der referenzierten Spalte wird erwartet.");return}if(e.referencesColumn=this.cct.value,this.nextToken(),!!this.expect(s.rightBracket))for(;this.tt==s.keywordOn;){this.nextToken();let n="";switch(this.tt){case s.keywordDelete:n="onDelete";break;case s.keywordUpdate:n="onUpdate";break}switch(n==""?(this.pushError("Nach 'on' wird 'delete' oder 'update' erwartet."),this.comesToken([s.keywordCascade,s.keywordRestrict,s.keywordSet,s.keywordNo])||(this.nextToken(),n="onDelete")):this.nextToken(),this.tt){case s.keywordCascade:e[n]=this.cct.value,this.nextToken();break;case s.keywordRestrict:e[n]=this.cct.value,this.nextToken();break;case s.keywordSet:e[n]="set ",this.nextToken(),[s.keywordNull,s.keywordDefault].indexOf(this.tt)>=0?(e[n]+=this.cct.value,this.nextToken()):this.pushError("Nach 'on delete/update set' wird 'null' oder 'default' erwartet.");break;case s.keywordNo:this.nextToken(),this.expect(s.keywordAction),e[n]="no action";break;default:this.pushError("Nach 'on delete/update' wird 'cascade', 'set null', 'set default' oder 'no action' erwartet.");break}}}}parseModifyColumn(e){this.nextToken();let t=this.parseColumnDefinition(!1);t!=null&&(e.modifyColumnInfo==null&&(e.modifyColumnInfo=[]),e.modifyColumnInfo.push(t))}parseAddPrimaryKey(e){if(this.nextToken(),e.primaryKeys=[],this.expect(s.keywordKey,!0)&&this.expect(s.leftBracket,!1))do this.nextToken(),this.tt==s.identifier&&(e.primaryKeys.push(this.cct.value),this.nextToken());while(this.tt==s.comma);return this.expect(s.rightBracket,!0)?(e.kind="omittedKind",e):null}parseAddIndex(e,t){this.nextToken();let i={index_name:"",column:"",unique:t};if(this.tt==s.identifier)i.index_name=this.cct.value+"_idx",this.nextToken();else return this.pushError("Erwartet wird der Bezeichner des Index."),null;if(!this.expect(s.leftBracket,!0))return null;if(this.tt==s.identifier)i.column=this.cct.value,this.nextToken(),e.indices==null&&(e.indices=[]),e.indices.push(i);else return this.pushError("Erwartet wird der Bezeichner der Spalte, für die ein Index erstellt werden soll."),null;return e.kind="omittedKind",this.expect(s.rightBracket,!0),null}parseAddColumn(e){e.kind="addColumn",this.comesToken(s.keywordColumn,!0),e.columnDefBegin=this.getCurrentPosition(),e.columnDef=this.parseColumnDefinition(!1)}parseDropTableOrView(){let e=this.getCurrentPosition();this.nextToken();let t={type:s.keywordDrop,position:e,endPosition:this.getEndOfPosition(this.getCurrentPosition()),symbolTable:null,tableIdentifier:null,tableIdentifierPosition:null,ifExists:!1};return this.expect([s.keywordTable,s.keywordView],!0)||this.addCompletionHintHere(!1,!1,["table","view"],1),this.comesToken(s.keywordIf,!0)&&(t.ifExists=!0,this.expect(s.keywordExists,!0)),this.addCompletionHintHere(!1,!0,[],1,"",";"),this.expect(s.identifier,!1)&&(t.tableIdentifier=this.cct.value,t.tableIdentifierPosition=this.getCurrentPosition(),this.nextToken(),t.endPosition=this.getCurrentPosition()),t}parseDelete(){let e=this.getCurrentPosition();this.nextToken();let t={type:s.keywordDelete,position:e,endPosition:this.getEndOfPosition(this.getCurrentPosition()),symbolTable:null,tableIdentifier:null,tableIdentifierPosition:null,whereNode:null,whereNodeBegin:null,whereNodeEnd:null};return this.expect(s.keywordFrom,!0)||this.addCompletionHintHere(!1,!1,["from"],1),this.addCompletionHintHere(!1,!0,[],1,"",` where
9
+ `+" ".repeat(o*l));else if(p>0){let g=n[p-1];g.tt!=s.space&&g.tt!=s.newline&&this.insertSpaces(t,b.position.line,b.position.column,1)}break;case s.leftBracket:if(f++,p<n.length-2){let g=n[p+1],w=n[p+2];g.tt==s.space&&w.tt!=s.newline&&(this.deleteSpaces(t,g.position.line,g.position.column,g.position.length),p++,w.tt==s.rightBracket&&(p++,f--))}if(p>1){let g=n[p-1],w=n[p-2];g.tt==s.space&&w.tt!=s.newline&&!this.isBinaryOperator(w.tt)&&g.position.length==1&&this.deleteSpaces(t,g.position.line,g.position.column,1)}break;case s.rightBracket:if(f--,p>1){let g=n[p-1],w=n[p-2];g.tt==s.space&&w.tt!=s.newline&&this.deleteSpaces(t,g.position.line,g.position.column,g.position.length)}break;case s.newline:if(m=2,p<n.length-2){let g=this.isBinaryOperator(r==null?void 0:r.tt),w=this.isBinaryOperator(this.getNextNonSpaceToken(p,n).tt),y=n[p+1],J=n[p+2],q=0;if(y.tt==s.newline)break;let V=0;if(y.tt==s.space){if(J.tt==s.newline)break;q=y.position.length,p++,J.tt==s.rightCurlyBracket&&(V=-1)}y.tt==s.rightCurlyBracket&&(V=-1),(w||g)&&(V=1);let G=o+V;f>0&&G++,G<0&&(G=0);let A=G*l;A>q?this.insertSpaces(t,b.position.line+1,0,A-q):A<q&&this.deleteSpaces(t,b.position.line+1,0,q-A)}break;case s.space:p<n.length-1&&n[p+1].tt!=s.comment&&p>0&&n[p-1].tt!=s.newline&&b.position.length>1&&this.deleteSpaces(t,b.position.line,b.position.column,b.position.length-1);break;case s.comma:case s.semicolon:if(p>1){let g=n[p-1],w=n[p-2];g.tt!=s.newline&&w.tt!=s.newline&&!this.isBinaryOperator(w.tt)&&g.tt==s.space&&g.position.length==1&&this.deleteSpaces(t,g.position.line,g.position.column,1)}if(p<n.length-1){let g=n[p+1];g.tt!=s.comment&&g.tt!=s.space&&g.tt!=s.newline&&this.insertSpaces(t,g.position.line,g.position.column,1)}break;case s.rightSquareBracket:r!=null&&r.tt==s.leftSquareBracket&&this.replaceBetween(r,b,t,"");break}if(this.isBinaryOperator(b.tt)){let k=b.tt==s.lower&&this.lowerBelongsToGenericExpression(p,n),g=b.tt==s.greater&&this.greaterBelongsToGenericExpression(p,n);if(m<=0&&r!=null&&[s.leftBracket,s.comma].indexOf(r.tt)<0){if(p>0){let w=n[p-1],y=k||g?0:1;w.tt==s.space?w.position.length!=y&&this.insertSpaces(t,w.position.line,w.position.column,y-w.position.length):y==1&&this.insertSpaces(t,b.position.line,b.position.column,1)}if(p<n.length-1){let w=n[p+1],y=k?0:1;w.tt==s.space?(g&&p<n.length-2&&n[p+2].tt==s.leftBracket&&(y=0),w.position.length!=y&&this.insertSpaces(t,w.position.line,w.position.column,y-w.position.length)):(g&&w.tt==s.leftBracket&&(y=0),y==1&&this.insertSpaces(t,w.position.line,w.position.column,1))}}}b.tt!=s.space&&b.tt!=s.newline&&(r=b)}return this.deleteOverlappingRanges(t),t}getNextNonSpaceToken(e,t){if(e==t.length-1)return t[e];let i=e+1;for(;i<t.length-1&&t[i].tt==s.space;)i++;return t[i]}lowerBelongsToGenericExpression(e,t){let i=e+1;for(;i<t.length;){let n=t[i].tt;if(n==s.greater)return!0;if([s.space,s.comma,s.identifier].indexOf(n)<0)return!1;i++}return!1}greaterBelongsToGenericExpression(e,t){let i=e-1;for(;i>=0;){let n=t[i].tt;if(n==s.lower)return!0;if([s.space,s.comma,s.identifier].indexOf(n)<0)return!1;i--}return!1}isBinaryOperator(e){return e!=null&&e>=s.modulo&&e<=s.equal}replaceBetween(e,t,i,n){let r={line:e.position.line,column:e.position.column+e.position.length},o={line:t.position.line,column:t.position.column};(r.line!=o.line||o.column-r.column!=n.length)&&this.replace(i,r,o,n)}deleteSpaces(e,t,i,n){e.push({range:{startColumn:i,startLineNumber:t,endColumn:i+n+(i==0?1:0),endLineNumber:t},text:""})}insertSpaces(e,t,i,n){if(n<0){this.deleteSpaces(e,t,i,-n);return}e.push({range:{startColumn:i,startLineNumber:t,endColumn:i,endLineNumber:t},text:" ".repeat(n)})}replace(e,t,i,n){e.push({range:{startColumn:t.column,startLineNumber:t.line,endColumn:i.column,endLineNumber:i.line},text:n})}}class ot{constructor(){h(this,"themes",[]);this.initThemes()}switchTheme(e){for(let t of this.themes)if(t.name==e){this.internalSwitchTheme(t);break}}internalSwitchTheme(e){x.setTheme(e.monacoTheme);let t=document.documentElement;for(const i of Object.keys(e.cssColors)){const n=e.cssColors[i];t.style.setProperty(i,n)}}initThemes(){this.themes.push({name:"dark",monacoTheme:"myCustomThemeDark",cssColors:{"--backgroundDark":"#1e1e1e","--backgroundLight":"#252526","--backgroundHeading":"#37373d","--backgroundSelected":"#2a2d2e","--fontColorNormal":"#c2cccc","--fontColorLight":"#e7e7e7","--slider":"#414141","--loginButtonBackgrond":"#59a15d","--loginButtonFontColor":"#000000","--loginMessageColor":"rgb(122, 48, 48)","--loginButtonHover":"#63a867","--loginButtonActive":"#94ffd1","--scrollbar":"#1e1e1e","--scrollbar-thumb":"#3e3e3e","--scrollbar-thumb-hover":"#5e5e5e","--scrollbar-thumb-active":"#7e7e7e","--submenu-hover":"#094771","--submenu-color":"#ffffff","--menuitemsdivider":"#616162","--file-hover":"hsla(0, 0%, 38%, 0.125)","--file-active":"#094771","--file-active-hover":"rgba(9, 71, 113, 0.827)","--file-errorcount":"red","--inplace-editor":"blue","--contextmenu-background":"#3c3c3c","--contextmenu-color":"rgb(212,212,212)","--contextmenu-hover-background":"#094771","--contextmenu-hover-color":"#ffffff","--error-filename":"#2a709e","--error-line-ative":"#094771","--error-line-hover":"rgba(96, 96, 96, 0.125)","--error-position":"#c0802d","--linecolumn":"#14c714","--reveal-error":"rgba(253, 101, 101, 0.745)","--reveal-method":"#2b2b7d2f","--reveal-errorline-background":"red","--reveal-error-whole-line":"rgba(255, 0, 0, 0.555)","--reveal-programpointer":"rgba(111, 214, 27, 0.337)","--reveal-syntaxelement":"rgb(85,85,85)","--margin-breakpoint":"rgba(255, 0, 0, 0.623)","--speedcontrol-bar":"#9d9d9d","--speedcontrol-grip":"#588555","--speedcontrol-grip-hover":"#89d185","--speedcontrol-display-background":"#383838","--speedcontrol-display-border":"#9d9d9d","--editorTooltip-background":"#252526","--editorTooltip-border":"#454545","--renameInput-color":"#ffffff","--bottomdiv-tabheading-hover":"white","--bottomdiv-tabheading-active":"rgb(97,97,255)","--noErrorMessage":"rgb(37, 211, 37)","--console-top-borderbottom":"#c4c4c4","--console-top-background":"#1e1e1e","--consoleEntry-withBorder":"#303030","--consoleEntryValue":"white","--consoleEntryIdentifier":"rgb(156, 156, 235)","--consoleEntryNoValue":"gray","--consoleEntryCaption":"white","--error-Caption":"rgb(166, 165, 176)","--console-error":"rgb(155, 51, 51)","--deIdentifier":"rgb(156, 156, 235)","--deValue":"white","--helper-background-color":"#383838","--helper-border-color":"#d4d4d4","--arrowBoxButtonOuter-background":"#59a15d","--arrowBoxButtonOuter-border":"#3d3d3d","--arrowBoxButtonOuter-color":"black","--arrowBoxButtonOuter-button-hover":"#63a867","--arrowBox-after":"rgba(136, 183, 213, 0)","--arrowBox-before":"rgba(194, 225, 245, 0)","--defaultOutputColor":"#ffffff","--runInputColor":"#ffffff","--runBackgroundColor":"rgba(255, 255, 255, 0.2)","--table-even":"#222","--table-heading":"#202060","--highlightStatementGreen-color":"#015a0165"}});let e="#8080ff";this.themes.push({name:"light",monacoTheme:"myCustomThemeLight",cssColors:{"--backgroundDark":"white","--backgroundLight":"#f3f3f3","--backgroundHeading":"#dcdcdc","--backgroundSelected":"#e8e8e8","--fontColorNormal":"#000","--fontColorLight":"#303030","--slider":"#b0b0b0","--loginButtonBackgrond":"#59a15d","--loginButtonFontColor":"#000000","--loginMessageColor":"rgb(122, 48, 48)","--loginButtonHover":"#63a867","--loginButtonActive":"#94ffd1","--scrollbar":"#e3e3e3","--scrollbar-thumb":"#bababa","--scrollbar-thumb-hover":"#8e8e8e","--scrollbar-thumb-active":"#616161","--submenu-hover":e,"--submenu-color":"#ffffff","--menuitemsdivider":"#cfcfcf","--file-hover":"#e8e8e8","--file-active":e,"--file-active-hover":"#a0a0ff","--file-errorcount":"red","--inplace-editor":"white","--contextmenu-background":"white","--contextmenu-color":"#756161","--contextmenu-hover-background":e,"--contextmenu-hover-color":"#a0a0ff","--error-filename":"#ff0000","--error-line-ative":"#ffa0a0","--error-line-hover":"#ffc0c0","--error-position":"#804040","--linecolumn":"#14c714","--reveal-error":"rgba(253, 101, 101, 0.745)","--reveal-method":"#babaec80","--reveal-errorline-background":"red","--reveal-error-whole-line":"rgba(255, 0, 0, 0.555)","--reveal-programpointer":"rgba(111, 214, 27, 0.337)","--reveal-syntaxelement":"#c0c0c0","--margin-breakpoint":"rgba(255, 0, 0, 0.623)","--speedcontrol-bar":"#9d9d9d","--speedcontrol-grip":"#588555","--speedcontrol-grip-hover":"#89d185","--speedcontrol-display-background":"#e0e0e0","--speedcontrol-display-border":"#9d9d9d","--editorTooltip-background":"#e0e0e0","--editorTooltip-border":"#9d9d9d","--renameInput-color":"#000000","--bottomdiv-tabheading-hover":"#424242","--bottomdiv-tabheading-active":"#424242","--noErrorMessage":"rgb(17, 180, 17)","--console-top-borderbottom":"#c4c4c4","--console-top-background":"white","--consoleEntry-withBorder":"#303030","--consoleEntryValue":"#0000a0","--consoleEntryIdentifier":"black","--consoleEntryNoValue":"gray","--consoleEntryCaption":"#756161","--error-Caption":"rgb(166, 165, 176)","--console-error":"rgb(155, 21, 21)","--deIdentifier":"black","--deValue":"#0000a0","--helper-background-color":"#f3f3f3","--helper-border-color":"#606060","--arrowBoxButtonOuter-background":"#59a15d","--arrowBoxButtonOuter-border":"#3d3d3d","--arrowBoxButtonOuter-color":"black","--arrowBoxButtonOuter-button-hover":"#63a867","--arrowBox-after":"rgba(136, 183, 213, 0)","--arrowBox-before":"rgba(194, 225, 245, 0)","--defaultOutputColor":"#303030","--runInputColor":"#000000","--runBackgroundColor":"rgba(0, 0, 0, 0.2)","--table-even":"#d1d2e4","--table-heading":"#c3f2b9","--highlightStatementGreen-color":"#015a0120"}})}}class at{}const M=class M extends at{constructor(t,i,n,r,o){super();h(this,"binaryResultTypes",new Map);h(this,"unaryOperators",[]);h(this,"canCastToList");this.name=t,this.parameterDescriptions=i,this.checkFunction=n,this.outputFunction=r,this.canCastToList=o.slice(0);let l=this.canCastToList.indexOf(t);l>=0&&this.canCastToList.splice(l,1)}static fromConstantType(t){switch(t){case s.stringConstant:return this.baseTypeMap.get("text");case s.integerConstant:return this.baseTypeMap.get("integer");case s.floatingPointConstant:return this.baseTypeMap.get("float");case s.charConstant:return this.baseTypeMap.get("text");case s.booleanConstant:return this.baseTypeMap.get("boolean");case s.keywordNull:return this.baseTypeMap.get("null")}}getBaseTypeName(){return this.name}toString(){return this.name}getSQLiteType(){return this.toString()}static getBaseType(t){return t!=null&&t.toLocaleLowerCase()=="char"&&(t="varchar"),this.baseTypeMap.get(t.toLocaleLowerCase())}static addBaseTypes(t){M.baseTypes=M.baseTypes.concat(t),t.forEach(i=>M.baseTypeMap.set(i.name,i))}addBinaryOperation(t,i,n,r=!0){Array.isArray(t)||(t=[t]),t.forEach(o=>{let l=this.binaryResultTypes.get(o);l==null&&(l=new Map,this.binaryResultTypes.set(o,l)),l.set(i,n),r&&i!=this&&i.addBinaryOperation(o,this,n,!1)})}canCastTo(t){let i=t instanceof M?t:t.baseType;return i instanceof me&&(i=M.getBaseType("text")),i instanceof ce&&(i=M.getBaseType("double")),this.canCastToList.indexOf(i.name)>=0||this.name==i.name}getBinaryResultType(t,i){let n=this.binaryResultTypes.get(t);if(n==null)return null;let r=i instanceof M?i:i.baseType;return r instanceof me&&(r=M.getBaseType("text")),r instanceof ce&&(r=M.getBaseType("double")),n.get(r)}getUnaryResultType(t){if([s.isNull,s.isNotNull].indexOf(t)>=0)return E;if(this.unaryOperators.indexOf(t)>=0)return this}getBinaryResult(t,i,n){switch(t){case s.concatenation:return i!=null&&n!=null?i+(n+""):i??n;case s.plus:return i!=null&&n!=null?i+n:i??n;case s.minus:return i!=null&&n!=null?i-n:i??n;case s.multiplication:return i!=null&&n!=null?i*n:i??n;case s.division:return i!=null&&n!=null?i*n:i??n;case s.keywordAnd:return i!=null&&n!=null?i*n:i??n;case s.keywordOr:return i!=null&&n!=null?Math.max(i,n):i??n;case s.lower:return i!=null&&n!=null?i<n:i==null;case s.greater:return i!=null&&n!=null?i>=n:i==null;case s.lowerOrEqual:return i!=null&&n!=null?i<=n:i==null;case s.greaterOrEqual:return i!=null&&n!=null?i>=n:i==null;case s.equal:return i==n;case s.notEqual:return i!=n;case s.modulo:return i%n}}};h(M,"baseTypes",[]),h(M,"baseTypeMap",new Map);let v=M;class ce extends v{constructor(t){super("NumberEnum",[],(i,n)=>`check(${i} in (${t.join(", ")}))`,(i,n)=>i,["decimal","integer","double","float"]);h(this,"isInteger",!0);h(this,"numericBinaryOperators",[s.plus,s.minus,s.multiplication,s.division,s.modulo]);h(this,"comparisonOperators",[s.lower,s.lowerOrEqual,s.greater,s.greaterOrEqual,s.equal,s.notEqual]);this.values=t;for(let i of t)Math.abs(Math.round(i)-i)>1e-8&&(this.isInteger=!1);this.name=this.isInteger?"integerEnum":"floatEnum"}getBinaryResultType(t,i){return this.numericBinaryOperators.indexOf(t)>=0?this.isInteger?v.getBaseType("integer"):v.getBaseType("double"):v.getBaseType("boolean")}getUnaryResultType(t){return null}getBinaryResult(t,i,n){return i+n}toString(){return"enum ("+this.values.join(", ")+")"}getBaseTypeName(){return"enum"}getSQLiteType(){return this.isInteger?"integerEnum":"realEnum"}}class me extends v{constructor(e){super("textEnum",[],(t,i)=>`check(${t} in (${e.map(n=>"'"+n+"'").join(", ")}))`,(t,i)=>t,["text","varchar","char"]),this.values=e}getBinaryResultType(e,t){return e==s.concatenation?v.getBaseType("text"):null}getUnaryResultType(e){return null}getBinaryResult(e,t,i){return t+i}toString(){return"enum ("+this.values.join(", ")+")"}getBaseTypeName(){return"enum"}getSQLiteType(){return"textEnum"}}let Be=[1,10,100,1e3,1e5,1e5,1e6,1e7,1e8,1e9];class de extends at{constructor(t,i){super();h(this,"name");this.baseType=t,this.parameterValues=i;let n=i.join(", ");this.name=t.name+"("+n+")"}toString(){return this.name}getBaseTypeName(){return this.baseType.name}getSQLiteType(){return this.baseType.getSQLiteType()}canCastTo(t){let i=t instanceof v?t:t.baseType;return this.baseType.canCastToList.indexOf(i.name)>=0||this.baseType.name==i.name}getBinaryResultType(t,i){let n=this.baseType.binaryResultTypes.get(t);if(n==null)return null;let r=i instanceof v?i:i.baseType,o=n.get(r);if(this.baseType==r&&this.baseType==o&&i instanceof de){if(this.baseType.name=="varchar"||t==s.concatenation)return new de(this.baseType,[this.parameterValues[0]+i.parameterValues[0]]);if(this.baseType.name=="decimal")return new de(this.baseType,[Math.max(this.parameterValues[0],i.parameterValues[0]),Math.max(this.parameterValues[1],i.parameterValues[1])])}return n.get(r)}getUnaryResultType(t){return this.baseType.getUnaryResultType(t)}getBinaryResult(t,i,n){let r=this.baseType.getBinaryResult(t,i,n);return(this.name="varchar")?r==null?null:(""+r).substr(0,this.parameterValues[0]):this.name=="decimal"?r==null?null:Math.round(r*Be[this.parameterValues[1]])/Be[this.parameterValues[1]]:r}}let re=["varchar","char","text","tinytext","mediumtext","longtext"];var T=new v("varchar",["Maximale Länge"],(a,e)=>`check(length(${a}) <= ${Math.max(e[0],1)})`,(a,e)=>a.substring(0,Math.max(e[0],1)),re),P=new v("char",["Maximale Länge"],(a,e)=>`check(length(${a}) <= ${Math.max(e[0],1)})`,(a,e)=>a.substring(0,Math.max(e[0],1)),re),S=new v("text",["Maximale Länge"],(a,e)=>"",(a,e)=>a,re.concat(["time","date","datetime","timestamp"])),Kt=new v("tinyText",[],(a,e)=>"",(a,e)=>a,re),Vt=new v("mediumText",[],(a,e)=>"",(a,e)=>a,re),Gt=new v("longText",[],(a,e)=>"",(a,e)=>a,re);let se=["decimal","numeric","double","real","float","floatEnum"];var ke=new v("decimal",["Gesamtzahl der Stellen","Nachkommastellen"],(a,e)=>"",(a,e)=>{let t=Math.trunc(a),i=a-t;return""+t+(e[1]>0?"."+Math.round(i*Be[e[1]]):"")},se),Qt=new v("numeric",["Gesamtzahl der Stellen","Nachkommastellen"],(a,e)=>"",(a,e)=>""+a,se),Zt=new v("double",["Gesamtzahl der Stellen","Nachkommastellen"],(a,e)=>"",(a,e)=>""+a,se),Jt=new v("real",[],(a,e)=>"",(a,e)=>""+a,se),qe=new v("float",[],(a,e)=>"",(a,e)=>""+a,se);let Yt=["int","integer","tinyint","smallint","mediumint","bigint","integerEnum"],oe=Yt.concat(se);var ze=new v("int",["Maximale Anzahl der Stellen"],(a,e)=>`check(round(${a}) = ${a})`,(a,e)=>""+Math.round(a),oe),Xt=new v("integer",["Maximale Anzahl der Stellen"],(a,e)=>`check(round(${a}) = ${a})`,(a,e)=>""+Math.round(a),oe),ei=new v("tinyint",["Maximale Anzahl der Stellen"],(a,e)=>`check(round(${a}) = ${a})`,(a,e)=>""+Math.round(a),oe),ti=new v("smallint",["Maximale Anzahl der Stellen"],(a,e)=>`check(round(${a}) = ${a})`,(a,e)=>""+Math.round(a),oe),ii=new v("mediumint",["Maximale Anzahl der Stellen"],(a,e)=>`check(round(${a}) = ${a})`,(a,e)=>""+Math.round(a),oe),ni=new v("bigint",["Maximale Anzahl der Stellen"],(a,e)=>`check(round(${a}) = ${a})`,(a,e)=>""+Math.round(a),oe),lt=new v("time",[],(a,e)=>`check(isTime(${a}))`,(a,e)=>a,[]),dt=new v("date",[],(a,e)=>`check(isDate(${a}))`,(a,e)=>a,[]),ut=new v("datetime",[],(a,e)=>`check(isDateTime(${a}))`,(a,e)=>a,["timestamp"]),ht=new v("timestamp",[],(a,e)=>`check(isDateTime(${a}))`,(a,e)=>a,["datetime"]),E=new v("boolean",[],(a,e)=>`check(${a} == 0 or ${a} == 1)`,(a,e)=>a==1?"true":"false",["varchar","text","decimal","numeric"]),ri=new v("null",[],(a,e)=>"",(a,e)=>a,[]);let I=[ke,Qt,Zt,Jt,qe,ze,Xt,ei,ti,ii,ni],ct=[T,P,S,Kt,Vt,Gt,lt,dt,ut,ht,E,ri].concat(I),ae=[lt,dt,ut,ht];v.addBaseTypes(ct);T.addBinaryOperation(s.concatenation,T,T);T.addBinaryOperation(s.concatenation,P,T);T.addBinaryOperation(s.concatenation,S,S);T.addBinaryOperation(s.concatenation,qe,S);T.addBinaryOperation(s.concatenation,ze,S);S.addBinaryOperation(s.concatenation,S,S);S.addBinaryOperation(s.concatenation,qe,S);S.addBinaryOperation(s.concatenation,ze,S);T.addBinaryOperation(s.keywordLike,T,E);T.addBinaryOperation(s.keywordLike,S,E);S.addBinaryOperation(s.keywordLike,S,E);T.addBinaryOperation(s.keywordNotLike,T,E);T.addBinaryOperation(s.keywordNotLike,S,E);S.addBinaryOperation(s.keywordNotLike,S,E);P.addBinaryOperation(s.concatenation,P,P);P.addBinaryOperation(s.concatenation,T,P);P.addBinaryOperation(s.concatenation,S,S);S.addBinaryOperation(s.concatenation,S,S);P.addBinaryOperation(s.keywordLike,P,E);P.addBinaryOperation(s.keywordLike,S,E);S.addBinaryOperation(s.keywordLike,S,E);P.addBinaryOperation(s.keywordNotLike,P,E);P.addBinaryOperation(s.keywordNotLike,S,E);S.addBinaryOperation(s.keywordNotLike,S,E);E.addBinaryOperation(s.equal,E,E);let mt=[s.plus,s.minus,s.multiplication,s.division,s.modulo],ue=[s.lower,s.lowerOrEqual,s.greater,s.greaterOrEqual,s.equal,s.notEqual];for(let a=0;a<I.length;a++){for(let e=a;e<I.length;e++)I[a].addBinaryOperation(mt,I[e],I[e]),I[a].addBinaryOperation(ue,I[e],E);I[a].addBinaryOperation(s.concatenation,T,S),I[a].addBinaryOperation(s.concatenation,S,S),I[a].unaryOperators=[s.minus]}ke.addBinaryOperation(mt,ke,ke);let O=[T,S];for(let a=0;a<O.length;a++)for(let e=a;e<O.length;e++)O[a].addBinaryOperation(s.concatenation,O[e],O[e]),O[a].addBinaryOperation(ue,O[e],E);for(let a=0;a<ae.length;a++){ae[a].addBinaryOperation(ue,ae[a],E);for(let e=0;e<O.length;e++)ae[a].addBinaryOperation(ue,O[e],E),O[e].addBinaryOperation(ue,ae[a],E)}let si=[s.keywordAnd,s.keywordOr];E.addBinaryOperation(si,E,E);E.unaryOperators=[s.keywordNot];ct.forEach(a=>a.unaryOperators=a.unaryOperators.concat([s.isNull,s.isNotNull]));const Q=class Q{constructor(){h(this,"module");h(this,"pos");h(this,"tokenList");h(this,"errorList");h(this,"lookahead",4);h(this,"ct");h(this,"lastToken");h(this,"cct");h(this,"tt");h(this,"position");h(this,"lastComment");h(this,"endToken",{position:{line:0,column:0,length:1},tt:s.endofSourcecode,value:"das Ende des Programms"});h(this,"beginStatementKeywords",["select","insert into","update","create table","create view","delete from","alter table","drop table","drop view"]);h(this,"identifierMap",{year:"int",binary:"varchar",varbinary:"varchar"})}parse(e){if(this.module=e,this.tokenList=e.tokenList,this.errorList=[],e.completionHints=new Map,this.tokenList.length==0){this.module.sqlStatements=[],this.module.errors[1]=this.errorList,this.module.addCompletionHint({line:0,column:0,length:0},{line:2e4,column:100,length:0},!1,!1,this.beginStatementKeywords);return}this.pos=0,this.initializeLookahead();let t=this.tokenList[this.tokenList.length-1];this.endToken.position={line:t.position.line,column:t.position.column+t.position.length,length:1},this.module.sqlStatements=this.parseMain(),this.module.errors[1]=this.errorList}initializeLookahead(){this.ct=[];for(let e=0;e<this.lookahead;e++){let t=this.endToken;for(;!(this.pos>=this.tokenList.length);){let i=this.tokenList[this.pos];if(i.tt==s.comment&&(this.lastComment=i),i.tt!=s.newline&&i.tt!=s.space&&i.tt!=s.comment){t=i,this.lastComment!=null&&(t.commentBefore=this.lastComment,this.lastComment=null);break}this.pos++}this.ct.push(t),e<this.lookahead-1&&this.pos++}this.cct=this.ct[0],this.tt=this.cct.tt,this.position=this.cct.position}nextToken(){let e;for(this.lastToken=this.cct;;){if(this.pos++,this.pos>=this.tokenList.length){e=this.endToken;break}if(e=this.tokenList[this.pos],e.tt==s.comment&&(this.lastComment=e),e.tt!=s.newline&&e.tt!=s.space&&e.tt!=s.comment){e.commentBefore=this.lastComment,this.lastComment=null;break}}for(let t=0;t<this.lookahead-1;t++)this.ct[t]=this.ct[t+1];this.ct[this.lookahead-1]=e,this.cct=this.ct[0],this.tt=this.cct.tt,this.position=this.cct.position}pushError(e,t="error",i){i==null&&(i=Object.assign({},this.position)),this.errorList.push({text:e,position:i,level:t})}skip(e){Array.isArray(e)||(e=[e]),e.indexOf(this.tt)>=0&&this.nextToken()}expect(e,t=!0,i=!1){if(this.tt!=e&&!(Array.isArray(e)&&e.indexOf(this.tt)>=0)){if(e==s.semicolon&&this.tt==s.endofSourcecode)return!0;let n=this.cct.position;e==s.semicolon&&this.lastToken!=null&&this.lastToken.position.line<n.line&&(n={line:this.lastToken.position.line,column:this.lastToken.position.column+this.lastToken.position.length,length:1}),e==s.semicolon&&this.lastToken.position.line<this.cct.position.line&&!this.isOperatorOrDot(this.lastToken.tt)&&i&&this.module.main.getSemicolonAngel().register(n,this.module);let r;if(Array.isArray(e)){r=e.map(l=>_[l]);let o=r.join(", ");this.pushError("Erwartet wird eines der folgenden: "+o+" - Gefunden wurde: "+_[this.tt],"error",n)}else r=[_[e]],this.pushError("Erwartet wird: "+_[e]+" - Gefunden wurde: "+_[this.tt],"error",n);return!1}return t&&this.nextToken(),!0}getEndOfPosition(e){return{line:e.line,column:e.column+e.length,length:0}}isOperatorOrDot(e){if(e==s.dot)return!0;for(let t of Q.operatorPrecedence)for(let i of t)if(e==i)return!0}isEnd(){return this.cct==this.endToken}comesToken(e,t=!1){if(!Array.isArray(e)){let n=this.tt==e;return n&&t&&this.nextToken(),n}let i=e.indexOf(this.tt)>=0;return i&&t&&this.nextToken,i}getCurrentPosition(){return Object.assign({},this.position)}getCurrentPositionPlus(e){if(this.tt==s.endofSourcecode)return{line:this.endToken.position.line,column:100,length:1};let t=0,i=e,n=0;for(;t<this.lookahead-1&&(n=this.ct[t].position.length)<i;)i-=n,t++;let r=this.ct[t].position;return r==null&&(r=this.getCurrentPosition()),{line:r.line,column:r.column+i,length:1}}getEndOfCurrentToken(){let e=this.getCurrentPosition();return e.column=e.column+this.position.length,e.length=0,e}parseMain(){let e=[],t={column:0,line:0,length:0},i=!0;for(this.module.addCompletionHint(t,this.getCurrentPositionPlus(8),!1,!1,this.beginStatementKeywords);!this.isEnd();){let n=this.pos,r=this.errorList.length;for(;[s.space,s.newline,s.comment,s.semicolon].indexOf(this.cct.tt)>=0;)this.nextToken();let o=this.getCurrentPosition(),l=this.parseStatement();for(t={line:this.lastToken.position.line+1,column:0,length:0},i=this.tt==s.semicolon;this.tt==s.semicolon;)this.nextToken();let d=!1;for(let u=r;u<this.errorList.length;u++)this.errorList[u].level=="error"&&(d=!0);if(l!=null&&e.push({ast:l,from:o,to:this.getEndOfPosition(this.lastToken.position),hasErrors:d,acceptedBySQLite:!1,resultTypes:[]}),this.getCurrentPosition(),this.pos==n){let u=[s.keywordSelect,s.keywordUpdate,s.keywordCreate,s.keywordInsert,s.keywordDelete,s.keywordDrop,s.keywordAlter],m=!0;for(;!this.isEnd()&&u.indexOf(this.tt)<0;)[s.space,s.newline].indexOf(this.tt)<0&&m&&(this.pushError("Erwartet wird eines dieser Schlüsselwörter: "+u.map(f=>_[f]).join(", ")+"; Gefunden wurde: "+this.cct.value),m=!0),this.nextToken()}(i||this.cct.position.line-t.line>0)&&this.module.addCompletionHint(t,this.getCurrentPositionPlus(8),!1,!1,this.beginStatementKeywords)}return this.module.addCompletionHint(t,{line:this.endToken.position.line+1,column:0,length:0},!1,!1,this.beginStatementKeywords),e}parseStatement(e=!0){let t=null;switch(this.tt){case s.keywordSelect:return this.parseSelect();case s.keywordInsert:return this.parseInsert();case s.keywordCreate:return this.parseCreateTableOrDatabaseOrView();case s.keywordUpdate:return this.parseUpdate();case s.keywordDelete:return this.parseDelete();case s.keywordDrop:return this.parseDropTableOrView();case s.keywordAlter:return this.parseAlterTable();case s.keywordCommit:return this.pushError("Die Aweisung commit ist unnötig, da jede Anweisung automatisch commited wird.","info"),this.nextToken(),null;case s.keywordSet:return this.parseSet();case s.keywordUse:return this.parseUse();case s.keywordStart:return this.pushError("Die Aweisung 'start transaction' ist unnötig, da jede Anweisung automatisch commited wird.","info"),this.nextToken(),this.expect(s.keywordTransaction,!0),null;case s.keywordLock:case s.keywordUnlock:return this.parseLockUnlock(),null;default:let i=_[this.tt];i==null&&(i=""),i!=this.cct.value&&(i+="("+this.cct.value+")"),i+=" wird hier nicht erwartet.",this.pushError(i),this.nextToken();break}return t}parseLockUnlock(){this.nextToken(),this.expect(s.keywordTables,!0),this.skip(s.identifier),this.skip([s.keywordWrite,s.keywordRead]),this.skip(s.semicolon)}parseSet(){this.pushError("Das SET-Statement wird von SQLite nicht unterstützt. Diese Anweisung wird daher einfach überlesen.","info");let e={type:s.omittedeStatement,position:this.getCurrentPosition(),endPosition:null,symbolTable:null};return this.nextToken(),this.comesToken(s.keywordDatabase)&&this.nextToken(),this.expect(s.identifier,!0),this.comesToken(s.equal,!0),this.expect([s.identifier,s.stringConstant,s.integerConstant,s.charConstant,s.booleanConstant,s.floatingPointConstant],!0),e.endPosition=this.getCurrentPosition(),e}parseUse(){this.pushError("Das USE-Statement wird von SQLite nicht unterstützt. Diese Anweisung wird daher einfach überlesen. Sie können eine andere Datenbank auswählen indem Sie in der Datenbankliste links darauf klicken.","info");let e={type:s.omittedeStatement,position:this.getCurrentPosition(),endPosition:null,symbolTable:null};return this.nextToken(),this.expect(s.identifier,!0),e.endPosition=this.getCurrentPosition(),e}parseAlterTable(){let e=this.getCurrentPosition();this.nextToken();let t={type:s.keywordAlter,kind:null,position:e,endPosition:this.getEndOfPosition(this.getCurrentPosition()),symbolTable:null,tableIdentifier:null,tableIdentifierPosition:null};if(this.expect(s.keywordTable,!0)||this.addCompletionHintHere(!1,!1,["table"],1),this.addCompletionHintHere(!1,!0,[],1),!this.expect(s.identifier,!1))return t;switch(t.tableIdentifier=this.cct.value,t.tableIdentifierPosition=this.getCurrentPosition(),this.nextToken(),t.endPosition=this.getCurrentPosition(),this.addCompletionHintHere(!1,!1,["rename to","rename column","add column","drop column"],1),this.tt){case s.keywordRename:this.parseRenameTableOrColumn(t);break;case s.keywordAdd:this.parseAlterTableAdd(t);break;case s.keywordDrop:this.parseDropColumn(t);break;default:this.pushError("Erwartet wird rename to, rename column, add column oder drop column")}return t}parseRenameTableOrColumn(e){switch(this.nextToken(),this.comesToken(s.keywordTo)||this.addCompletionHintHere(e.tableIdentifier,!1,["column","to"],3),e.endPosition=this.getEndOfCurrentToken(),this.tt){case s.keywordTo:this.nextToken(),e.endPosition=this.getEndOfCurrentToken(),e.kind="renameTable",this.comesToken(s.identifier)?(e.newTableName=this.cct.value,this.nextToken(),e.endPosition=this.getEndOfCurrentToken()):this.pushError("Erwartet wird der neue Tabellenname.");return;case s.keywordColumn:if(this.nextToken(),e.endPosition=this.getEndOfCurrentToken(),this.addCompletionHintHere(e.tableIdentifier,!1,[],3),!this.comesToken(s.identifier)){this.pushError("Erwartet wird der Name einer Spalte der Tabelle "+e.tableIdentifier+".");return}if(e.kind="renameColumn",e.oldColumnName=this.cct.value,e.oldColumnPosition=this.getCurrentPosition(),this.nextToken(),this.addCompletionHintHere(!1,!1,["to"],3),e.endPosition=this.getEndOfCurrentToken(),!this.expect(s.keywordTo,!0))return;e.endPosition=this.getEndOfCurrentToken(),this.comesToken(s.identifier)?(e.newColumnName=this.cct.value,this.nextToken(),e.endPosition=this.getEndOfCurrentToken()):this.pushError("Erwartet wird der neue Spaltenname.");return;default:this.pushError("Erwartet wird das Schlüsselwort 'to' (zum Umbenennen der Tabelle) oder das Schlüsselwor 'column' (zum Umbenennen einer Spalte).");return}}parseDropColumn(e){this.nextToken(),this.comesToken(s.keywordColumn,!0),e.oldColumnPosition=this.getCurrentPosition(),this.addCompletionHintHere(e.tableIdentifier,!1,[],3),e.kind="dropColumn",e.endPosition=this.getEndOfCurrentToken(),this.comesToken(s.identifier)?(e.oldColumnName=this.cct.value,this.nextToken()):this.pushError("Erwartet wird der Bezeichner der Spalte, die gelöscht werden soll.")}parseAlterTableAdd(e){do{this.nextToken(),this.comesToken(s.keywordAdd,!0);let t=!1;switch(this.tt){case s.keywordColumn:this.parseAddColumn(e);break;case s.keywordPrimary:this.parseAddPrimaryKey(e);break;case s.keywordUnique:this.nextToken(),t=!0,this.expect([s.keywordIndex,s.keywordKey],!1);case s.keywordKey:case s.keywordIndex:this.parseAddIndex(e,t);break;case s.keywordModify:this.parseModifyColumn(e);break;case s.keywordConstraint:this.parseAddConstraint(e);break;default:this.parseAddColumn(e);break}}while(this.tt==s.comma)}parseAddConstraint(e){if(this.nextToken(),!!this.expect(s.identifier)&&this.comesToken(s.keywordForeign)){let t=this.parseForeignKeyDefinition();t!=null&&(e.foreignKeys==null&&(e.foreignKeys=[]),e.foreignKeys.push(t),e.kind="omittedKind")}}parseForeignKeyDefinition(){let e={column:"",referencesTable:"",referencesColumn:"",referencesPosition:this.getCurrentPosition()};if(this.expect(s.keywordForeign)&&this.expect(s.keywordKey)&&this.expect(s.leftBracket)){if(!this.comesToken(s.identifier)){this.pushError("Der Bezeichner der Fremdschlüsselspalte wird erwartet.");return}if(e.column=this.cct.value,this.nextToken(),!!this.expect(s.rightBracket))return this.parseReferences(e),e}}parseReferences(e){if(!this.expect(s.keywordReferences))return;if(this.addCompletionHintHere(!1,!0,[]),!this.comesToken(s.identifier)){this.pushError("Der Bezeichner der referenzierten Tabelle wird erwartet.");return}e.referencesTable=this.cct.value,this.nextToken();let t=this.lastToken.position,i=this.getCurrentPosition();if(this.module.addCompletionHint(this.getEndOfPosition(t),i,e.referencesTable,!1,[]),!!this.expect(s.leftBracket)){if(!this.comesToken(s.identifier)){this.pushError("Der Bezeichner der referenzierten Spalte wird erwartet.");return}if(e.referencesColumn=this.cct.value,this.nextToken(),!!this.expect(s.rightBracket))for(;this.tt==s.keywordOn;){this.nextToken();let n="";switch(this.tt){case s.keywordDelete:n="onDelete";break;case s.keywordUpdate:n="onUpdate";break}switch(n==""?(this.pushError("Nach 'on' wird 'delete' oder 'update' erwartet."),this.comesToken([s.keywordCascade,s.keywordRestrict,s.keywordSet,s.keywordNo])||(this.nextToken(),n="onDelete")):this.nextToken(),this.tt){case s.keywordCascade:e[n]=this.cct.value,this.nextToken();break;case s.keywordRestrict:e[n]=this.cct.value,this.nextToken();break;case s.keywordSet:e[n]="set ",this.nextToken(),[s.keywordNull,s.keywordDefault].indexOf(this.tt)>=0?(e[n]+=this.cct.value,this.nextToken()):this.pushError("Nach 'on delete/update set' wird 'null' oder 'default' erwartet.");break;case s.keywordNo:this.nextToken(),this.expect(s.keywordAction),e[n]="no action";break;default:this.pushError("Nach 'on delete/update' wird 'cascade', 'set null', 'set default' oder 'no action' erwartet.");break}}}}parseModifyColumn(e){this.nextToken();let t=this.parseColumnDefinition(!1);t!=null&&(e.modifyColumnInfo==null&&(e.modifyColumnInfo=[]),e.modifyColumnInfo.push(t))}parseAddPrimaryKey(e){if(this.nextToken(),e.primaryKeys=[],this.expect(s.keywordKey,!0)&&this.expect(s.leftBracket,!1))do this.nextToken(),this.tt==s.identifier&&(e.primaryKeys.push(this.cct.value),this.nextToken());while(this.tt==s.comma);return this.expect(s.rightBracket,!0)?(e.kind="omittedKind",e):null}parseAddIndex(e,t){this.nextToken();let i={index_name:"",column:"",unique:t};if(this.tt==s.identifier)i.index_name=this.cct.value+"_idx",this.nextToken();else return this.pushError("Erwartet wird der Bezeichner des Index."),null;if(!this.expect(s.leftBracket,!0))return null;if(this.tt==s.identifier)i.column=this.cct.value,this.nextToken(),e.indices==null&&(e.indices=[]),e.indices.push(i);else return this.pushError("Erwartet wird der Bezeichner der Spalte, für die ein Index erstellt werden soll."),null;return e.kind="omittedKind",this.expect(s.rightBracket,!0),null}parseAddColumn(e){e.kind="addColumn",this.comesToken(s.keywordColumn,!0),e.columnDefBegin=this.getCurrentPosition(),e.columnDef=this.parseColumnDefinition(!1)}parseDropTableOrView(){let e=this.getCurrentPosition();this.nextToken();let t={type:s.keywordDrop,position:e,endPosition:this.getEndOfPosition(this.getCurrentPosition()),symbolTable:null,tableIdentifier:null,tableIdentifierPosition:null,ifExists:!1};return this.expect([s.keywordTable,s.keywordView],!0)||this.addCompletionHintHere(!1,!1,["table","view"],1),this.comesToken(s.keywordIf,!0)&&(t.ifExists=!0,this.expect(s.keywordExists,!0)),this.addCompletionHintHere(!1,!0,[],1,"",";"),this.expect(s.identifier,!1)&&(t.tableIdentifier=this.cct.value,t.tableIdentifierPosition=this.getCurrentPosition(),this.nextToken(),t.endPosition=this.getCurrentPosition()),t}parseDelete(){let e=this.getCurrentPosition();this.nextToken();let t={type:s.keywordDelete,position:e,endPosition:this.getEndOfPosition(this.getCurrentPosition()),symbolTable:null,tableIdentifier:null,tableIdentifierPosition:null,whereNode:null,whereNodeBegin:null,whereNodeEnd:null};return this.expect(s.keywordFrom,!0)||this.addCompletionHintHere(!1,!1,["from"],1),this.addCompletionHintHere(!1,!0,[],1,"",` where
10
10
  `),!this.expect(s.identifier,!1)||(t.tableIdentifier=this.cct.value,t.tableIdentifierPosition=this.getCurrentPosition(),this.nextToken(),t.endPosition=this.getCurrentPosition(),this.addCompletionHintHere(!1,!1,[`where
11
11
  `],1),this.tt!=s.keywordWhere)||(this.nextToken(),t.endPosition=this.getCurrentPosition(),t.whereNodeBegin=this.getEndOfPosition(this.lastToken.position),t.whereNode=this.parseTerm(),t.whereNodeEnd=this.getCurrentPosition(),this.module.addCompletionHint(t.whereNodeBegin,this.getCurrentPositionPlus(3),t.tableIdentifier,!1,[]),t.endPosition=this.getCurrentPosition()),t}parseUpdate(){let e=this.getCurrentPosition();this.nextToken();let t={type:s.keywordUpdate,position:e,endPosition:this.getEndOfPosition(this.getCurrentPosition()),symbolTable:null,tableIdentifier:null,tableIdentifierPosition:null,columnIdentifiers:[],columnIdentifierPositions:[],values:[],valuePosBegin:[],valuePosEnd:[],whereNode:null,whereNodeBegin:null,whereNodeEnd:null};if(this.addCompletionHintHere(!1,!0,[],1,"",` set
12
12
  `),!this.expect(s.identifier,!1)||(t.tableIdentifier=this.cct.value,t.tableIdentifierPosition=this.getCurrentPosition(),this.nextToken(),t.endPosition=this.getCurrentPosition(),this.addCompletionHintHere(!1,!1,[`set
13
- `],1),!this.expect(s.keywordSet)))return t;let i=!0;do{if(this.addCompletionHintHere(t.tableIdentifier,!1,i?[]:["where"],1,null," = "),i=!1,this.tt!=s.identifier){this.pushError("Hier wird der Bezeichner derjenigen Spalte der Tabelle "+t.tableIdentifier+" erwaretet, deren Wert verändert werden soll.","error");break}t.columnIdentifiers.push(this.cct.value),t.columnIdentifierPositions.push(this.getCurrentPosition()),this.nextToken(),this.expect(s.equal,!0),t.valuePosBegin.push(this.getCurrentPosition()),t.values.push(this.parseTerm()),t.valuePosEnd.push(this.getCurrentPosition())}while(this.comesToken(s.comma,!0));if(t.endPosition=this.getCurrentPosition(),this.lastToken.tt!=s.comma||this.comesToken(s.keywordWhere)){if(!this.expect(s.keywordWhere,!0))return t;t.whereNodeBegin=this.getEndOfPosition(this.lastToken.position),t.whereNode=this.parseTerm(),t.whereNodeEnd=this.getCurrentPosition(),this.module.addCompletionHint(t.whereNodeBegin,t.whereNodeEnd,t.tableIdentifier,!1,[]),t.endPosition=this.getCurrentPosition()}else this.comesToken(s.keywordWhere,!0);return t}parseCreateTableOrDatabaseOrView(){switch(this.ct[1].tt){case s.keywordDatabase:return this.parseCreateDatabase();case s.keywordTable:return this.parseCreateTable();case s.keywordView:return this.parseCreateView();case s.keywordSchema:default:return this.nextToken(),this.pushError("Nach 'create' wird 'table' erwartet."),this.nextToken(),null}}parseCreateDatabase(){let e={type:s.omittedeStatement,position:this.getCurrentPosition(),endPosition:null,symbolTable:null};for(this.nextToken(),this.pushError("Die CREATE-DATABASE-Anweisung wird von der SQLite-Engine nicht unterstützt. Sie können eine neue Datenbank anlegen, indem Sie auf den entsprechenden Button oberhalb der Liste der Datenbanken (linke Seite des Fensters) klicken. Diese Anweisung wird überlesen.","info");this.tt!=s.semicolon&&this.tt!=s.endofSourcecode;)e.endPosition=this.getEndOfCurrentToken(),this.nextToken();return e}parseCreateView(){let e=this.getCurrentPosition();this.nextToken(),this.nextToken();let t=!1;this.comesToken(s.keywordIf)&&(this.nextToken(),this.expect(s.keywordNot,!0),this.expect(s.keywordExists,!0),t=!0);let i="";if(!this.expect(s.identifier,!1))return null;i=this.cct.value,this.nextToken();let n=[];if(this.comesToken(s.leftBracket,!0)){do this.expect(s.identifier,!1)&&n.push(this.cct.value),this.nextToken();while(this.comesToken(s.comma,!0));this.expect(s.rightBracket,!0)}if(!this.expect(s.keywordAs,!0))return this.module.addCompletionHint(this.getCurrentPosition(),this.getCurrentPositionPlus(2),!1,!1,["as"]),null;if(!this.expect(s.keywordSelect,!1))return this.module.addCompletionHint(this.getCurrentPosition(),this.getCurrentPositionPlus(2),!1,!1,["select"]),null;let r=this.parseSelect();return{type:s.keywordView,identifier:i,position:e,endPosition:this.getCurrentPosition(),symbolTable:null,ifNotExists:t,columnIdentifierList:n,selectStatement:r}}parseCreateTable(){let e=this.getCurrentPosition();this.nextToken(),this.expect(s.keywordTable,!0)||this.module.addCompletionHint(e,this.getCurrentPositionPlus(3),!1,!1,["table"]);let t=!1;this.comesToken(s.keywordIf)&&(this.nextToken(),this.expect(s.keywordNot,!0),this.expect(s.keywordExists,!0),t=!0);let i="";if(this.expect(s.identifier,!1)){i=this.cct.value;let l=this.getCurrentPosition(),d=this.getCurrentPositionPlus(i.length+3);this.nextToken(),this.comesToken(s.leftBracket)||this.module.addCompletionHint(l,d,!1,!1,["("])}let n={type:s.keywordCreate,identifier:i,position:e,endPosition:null,columnList:[],symbolTable:null,combinedPrimaryKeyColumns:[],foreignKeyInfoList:[],ifNotExists:t,uniqueConstraints:[]};if(!this.expect(s.leftBracket,!0))return n;let r=!1,o=!0;for(;this.tt!=s.rightBracket;){switch(o||this.expect(s.comma,!0),o=!1,this.comesToken(s.keywordConstraint,!0)&&(this.expect(s.identifier,!0),this.expect([s.keywordForeign,s.keywordPrimary,s.keywordUnique],!1)),this.tt){case s.keywordPrimary:r&&this.pushError("Je Tabelle darf nur ein einziger Primärschlüssel definiert werden.","error",this.getCurrentPosition()),this.parsePrimaryKeyTerm(r,n),r=!0;break;case s.keywordKey:this.nextToken(),this.comesToken(s.identifier,!0),this.comesToken(s.leftBracket,!0),this.comesToken(s.identifier,!0),this.comesToken(s.rightBracket,!0);break;case s.keywordUnique:this.parseUniqueTerm(n);break;case s.keywordForeign:let l=this.parseForeignKeyDefinition();l!=null&&n.foreignKeyInfoList.push(l);break;case s.identifier:let d=this.parseColumnDefinition(r);n.columnList.push(d),r=r||d.isPrimary;break;default:this.pushError(D[this.tt]+" wird hier nicht erwartet.","error");break}if(!this.comesToken(s.comma))break}for(this.expect(s.rightBracket,!0);[s.keywordAutoincrement,s.keywordEngine,s.keywordDefault,s.keywordCollate].indexOf(this.tt)>=0;)switch(this.tt){case s.keywordCollate:this.nextToken(),this.skip(s.equal),this.expect(s.identifier,!0);break;case s.keywordEngine:this.nextToken(),this.skip(s.equal),this.expect(s.identifier,!0);break;case s.keywordDefault:this.nextToken(),this.expect([s.keywordCharset,s.keywordCharacter],!0),this.skip(s.keywordSet),this.skip(s.equal),this.expect(s.identifier,!0);break;case s.keywordAutoincrement:this.nextToken(),this.expect(s.equal,!0),this.expect(s.integerConstant,!0);break}for(let l of n.columnList)l.isAutoIncrement&&!(l.isPrimary||n.combinedPrimaryKeyColumns.indexOf(l.identifier)>=0)&&this.pushError("autoincrement gibt es nur bei Primärschlüsseln, d.h. es fehlt wahrscheinlich 'primary key'.","warning",n.position);return n.endPosition=this.getCurrentPosition(),n}parsePrimaryKeyTerm(e,t){e&&this.pushError("Die Tabelle kann nur einen einzigen Primärschlüssel haben."),this.nextToken(),this.expect(s.keywordKey,!0);let i=t.columnList.map(n=>n.identifier);if(this.addCompletionHintHere(!1,!1,i),this.comesToken(s.leftBracket)){for(this.addCompletionHintHere(!1,!1,i),this.nextToken();;)if(this.comesToken(s.identifier))if(t.combinedPrimaryKeyColumns.push(this.cct.value),this.nextToken(),this.addCompletionHintHere(!1,!1,i,1),this.comesToken(s.comma))this.nextToken(),this.addCompletionHintHere(!1,!1,i);else break;else{this.pushError("Der Bezeichner einer Spalte wird erwartet. Gefunden wurde: "+this.cct.value);break}this.expect(s.rightBracket,!0)}else this.pushError("( erwartet.")}parseUniqueTerm(e){this.nextToken();let t=e.columnList.map(n=>n.identifier),i=[];if(e.uniqueConstraints.push(i),this.addCompletionHintHere(!1,!1,t),this.comesToken(s.leftBracket)){for(this.addCompletionHintHere(!1,!1,t),this.nextToken();;)if(this.comesToken(s.identifier))if(i.push(this.cct.value),this.nextToken(),this.addCompletionHintHere(!1,!1,t,1),this.comesToken(s.comma))this.nextToken(),this.addCompletionHintHere(!1,!1,t);else break;else{this.pushError("Der Bezeichner einer Spalte wird erwartet. Gefunden wurde: "+this.cct.value);break}this.expect(s.rightBracket,!0)}else this.pushError("( erwartet.")}parseColumnDefinition(e){let t=this.getCurrentPosition(),i=this.cct.value;this.nextToken();let n={type:s.columnDef,identifier:i,isPrimary:!1,isAutoIncrement:!1,position:t,baseType:null,notNull:!1};return this.parseType(n,e),n}addCompletionHintHere(e,t,i,n=0,r="",o=""){let l=this.lastToken.position,d=this.getCurrentPosition();d.column+=1+n,this.module.addCompletionHint(this.getEndOfPosition(l),d,e,t,i,null,r,o)}parseType(e,t){let i=v.baseTypes.map(o=>o.toString());if(this.addCompletionHintHere(!1,!1,i),!this.expect([s.identifier,s.keywordEnum],!1)){this.pushError("Erwartet wird ein Datentyp. Gefunden wurde: "+this.cct.value);return}let n;if(this.cct.tt==s.keywordEnum){if(this.nextToken(),this.expect(s.leftBracket,!0)){let o=[];for(;!this.comesToken(s.rightBracket,!0)&&!this.isEnd();){let l=this.parseConstant();l!=null&&o.push(l),this.comesToken(s.comma)&&this.nextToken()}if(o.length>0)switch(o[0].constantType){case s.integerConstant:case s.floatingPointConstant:n=new he(o.map(l=>l.constant));break;default:n=new ce(o.map(l=>""+l.constant));break}else n=new ce([]);e.baseType=n}}else{let o=this.cct.value,l=this.getCurrentPosition(),d=this.identifierMap[o.toLocaleLowerCase()];if(d!=null&&(o=d),n=v.getBaseType(o),n==null&&this.pushError("Erwartet wird ein Datentyp. Gefunden wurde: "+o),e.baseType=n,this.nextToken(),this.tt==s.leftBracket){for(this.nextToken(),e.parameters=[];this.tt==s.integerConstant&&(e.parameters.push(this.cct.value),this.nextToken(),this.tt==s.comma);)if(this.nextToken(),this.tt!=s.integerConstant){this.pushError("Erwartet wird eine ganze Zahl, gefunden wurde: "+this.cct.value);break}n!=null&&e.parameters.length>n.parameterDescriptions.length&&this.pushError("Der Datentyp "+n.toString()+" hat höchstens "+n.parameterDescriptions.length+" Parameter."),this.expect(s.rightBracket,!0)}if(o!=null&&e.parameters==null)switch(o.toLocaleLowerCase()){case"char":e.parameters=[1];break;case"varchar":e.parameters=[1],this.pushError("Hinter dem Datentyp varchar wird zwingend eine Längenangabe in Klammern erwaretet, also z.B. varchar(30)","error",l);break}}this.tt!=s.comma&&this.addCompletionHintHere(!1,!1,["primary key","references","not null"]);let r=[];for(;[s.keywordOn,s.keywordCharacter,s.keywordComment,s.keywordAutoincrement,s.keywordKey,s.keywordPrimary,s.keywordNot,s.keywordReferences,s.keywordCollate,s.keywordDefault].indexOf(this.tt)>=0;)switch(r.indexOf(this.tt)>=0&&this.pushError("Das Schlüsselwort "+D[this.tt]+" darf bei der Definition einer Spalte nicht öfters als ein Mal vorkommen."),r.push(this.tt),this.tt){case s.keywordAutoincrement:this.nextToken(),e.isAutoIncrement=!0,this.tt==s.equal?(this.nextToken(),this.expect(s.integerConstant)):this.tt==s.comma&&this.ct[1].tt==s.keywordAutoincrement&&this.nextToken();break;case s.keywordPrimary:t&&this.pushError("In einer Tabelle darf es nur einen einzigen primary key geben."),this.nextToken(),this.expect(s.keywordKey,!0)?this.comesToken(s.comma)||this.addCompletionHintHere(!1,!1,[`autoincrement,
14
- `]):this.addCompletionHintHere(!1,!1,["key"]),e.isPrimary=!0;break;case s.keywordReferences:let o={column:e.identifier,referencesColumn:"",referencesTable:"",referencesPosition:this.getCurrentPosition()};e.foreignKeyInfo=o,this.parseReferences(o);break;case s.keywordNot:this.nextToken(),this.expect(s.keywordNull,!0)?this.addCompletionHintHere(!1,!1,["references"]):this.addCompletionHintHere(!1,!1,["null"]),e.notNull=!0;break;case s.keywordCollate:this.nextToken(),e.collate=this.cct.value,this.expect(s.identifier,!0);break;case s.keywordCharacter:this.nextToken(),this.expect(s.keywordSet,!0),this.expect(s.identifier,!0);break;case s.keywordDefault:if(this.nextToken(),this.ct[1].tt==s.leftBracket&&this.ct[2].tt==s.rightBracket){this.nextToken(),this.nextToken(),this.nextToken();break}if(e.defaultValue=this.cct.value,typeof this.cct.value=="string"&&e.defaultValue.toLowerCase()!="null"&&(e.defaultValue="'"+e.defaultValue+"'"),this.tt==s.keywordNull){this.nextToken();break}else[s.identifier,s.integerConstant,s.floatingPointConstant,s.stringConstant].indexOf(this.tt)>=0&&(v.fromConstantType(this.tt).canCastTo(n)||this.pushError("Die Konstante hinter 'default' passt nicht zum Datentyp der Spalte."),this.nextToken());break;case s.keywordComment:this.nextToken(),this.expect(s.stringConstant,!0);break;case s.keywordOn:for(this.nextToken(),this.expect([s.keywordUpdate],!0);!this.comesToken([s.comma,s.endofSourcecode,s.rightBracket]);)this.nextToken();this.lastToken.tt==s.leftBracket&&this.tt==s.rightBracket&&this.nextToken();break}}parseInsert(){let e=this.getCurrentPosition(),t=e;this.nextToken(),this.expect(s.keywordInto,!0);let i={type:s.keywordInsert,position:e,endPosition:this.getCurrentPosition(),valuesPosition:null,columnsPosition:null,symbolTable:null,columnList:[],values:[],table:null};if(this.tt==s.identifier?(i.table={type:s.table,identifier:this.cct.value,alias:null,position:this.getCurrentPosition()},i.columnsPosition={line:i.table.position.line,column:i.table.position.column+i.table.position.length,length:0},this.nextToken()):this.pushError("Hier wird der Bezeichner einer Tabelle erwartet. Gefunden wurde: "+this.cct.value,"error"),this.tt==s.leftBracket){this.nextToken();let n=!0;for(;n||this.tt==s.comma;)n||this.nextToken(),n=!1,this.tt==s.identifier?i.columnList.push({type:s.identifier,identifier:this.cct.value+"",position:this.getCurrentPosition()}):this.pushError("Erwartet wird der Bezeichner einer Spalte. Gefunden wurde: "+this.cct.value,"error"),this.nextToken();t=this.getCurrentPosition(),this.expect(s.rightBracket,!0)}switch(i.valuesPosition=this.getCurrentPosition(),this.tt){case s.keywordValues:this.nextToken(),this.parseValueLists(i.values);break;case s.keywordSelect:case s.leftBracket:if(this.getCurrentPosition().line<=t.line+1){let n=this.parseSelect();i.select=n}break}return i.endPosition=this.getCurrentPosition(),i}parseValueLists(e){let t=[s.keywordNull,s.charConstant,s.stringConstant,s.booleanConstant,s.floatingPointConstant,s.integerConstant],i=!0;for(;i||this.tt==s.comma;){i||this.nextToken(),i=!1;let n=this.getCurrentPosition();if(!this.expect(s.leftBracket,!0))break;let r=[],o=!0;for(;o||this.tt==s.comma;){if(o||this.nextToken(),o=!1,this.tt==s.identifier)if(this.cct.isDoubleQuotedIdentifier)this.tt=s.stringConstant;else{let l=(this.cct.value+"").toLocaleLowerCase();["date","_binary"].indexOf(l)>=0&&this.nextToken()}t.indexOf(this.tt)<0?(this.pushError("Erwartet wird eine Konstante oder null. Gefunden wurde: "+this.cct.value,"error"),this.nextToken()):(r.push({constantType:this.tt,position:this.getCurrentPosition(),constant:this.cct.value,type:s.constantNode}),this.nextToken())}this.expect(s.rightBracket,!0),r.length==0?this.pushError("Eine Zeile kann nur dann in die Tabelle eingefügt werden, wenn sie mindestens einen Spaltenwert besitzt.","error",n):e.push(r)}}parseConstant(){let e={constantType:this.tt,position:this.getCurrentPosition(),constant:this.cct.value,type:s.constantNode};return this.nextToken(),e}parseSelect(){let e=this.getCurrentPosition();this.nextToken();let t={line:e.line,column:e.column+6,length:1},i={type:s.keywordSelect,position:e,endPosition:this.getCurrentPosition(),symbolTableEndPosition:this.getCurrentPosition(),symbolTable:null,columnList:[],fromNode:null,whereNode:null,parentStatement:null};i.columnList=this.parseColumnList([s.keywordFrom,s.semicolon,s.endofSourcecode],!0);let n=["distinct","as","*","from"];i.columnList.findIndex(l=>l.type==s.allColumns)>=0&&(n=["from"]),this.module.addCompletionHint(t,this.getCurrentPositionPlus(2),!0,!0,n);let r=this.comesToken(s.keywordFrom,!0),o=["where","join","left","right","inner","outer","natural","on","as",", "];if(!r)n.unshift("from");else{i.fromStartPosition={line:this.lastToken.position.line,column:this.lastToken.position.column+this.lastToken.position.length,length:0};let l=[];i.fromNode=this.parseTableOrSubQuery(l),o.splice(o.indexOf(this.lastToken.value+""),1);let d=this.getCurrentPositionPlus(2);this.comesToken(s.semicolon)&&(d=this.getCurrentPosition()),i.fromEndPosition=this.getCurrentPosition();let u=["like","union"];if(this.tt==s.keywordWhere){this.getCurrentPosition();let f=this.getCurrentPosition();this.nextToken(),i.whereNode=this.parseTerm(),this.module.addCompletionHint(f,this.getCurrentPositionPlus(4),!0,!0,u)}else o.push("where");let m=[];if(this.tt==s.keywordGroup){let f=this.getCurrentPosition();i.groupByNode=this.parseGroupBy(),this.module.addCompletionHint(f,this.getCurrentPosition(),!0,!0,m)}else u.push("group by");if(this.tt==s.keywordOrder){let f=this.getCurrentPosition();i.orderByNode=this.parseOrderBy(),this.module.addCompletionHint(f,this.getCurrentPosition(),!0,!0,["asc","desc"])}else u.push("order by"),m.push("order by");this.tt==s.keywordLimit&&(i.limitNode=this.parseLimit()),i.symbolTableEndPosition=this.getCurrentPosition(),this.comesToken(s.keywordUnion,!0)?this.expect(s.keywordSelect,!1)&&(i.union=this.parseSelect()):r&&i.fromNode!=null&&o.push("union"),this.module.addCompletionHint(i.fromStartPosition,d,!1,!0,o,l)}return i.endPosition=this.getCurrentPosition(),i.endPosition.column+=3,i}parseLimit(){let e=this.getCurrentPosition();this.nextToken();let t=this.parseTerm(),i={type:s.keywordLimit,position:e,numberOfRows:t};return this.tt==s.keywordOffset&&(this.nextToken(),i.offset=this.parseTerm()),i}parseGroupBy(){let e=this.getCurrentPosition();this.expect(s.keywordGroup,!0),this.expect(s.keywordBy,!0);let t={type:s.keywordGroup,columnList:[],position:e},i=[s.keywordHaving,s.keywordSelect,s.keywordOrder,s.keywordLimit,s.rightBracket,s.semicolon];return t.columnList=this.parseColumnList(i,!1).map(n=>n.term),this.tt==s.keywordHaving&&(this.nextToken(),t.having=this.parseTerm()),t}parseOrderBy(){this.expect(s.keywordOrder,!0),this.expect(s.keywordBy,!0);let e=[],t=!0;do{t?t=!1:this.expect(s.comma,!0);let i=this.parseTerm(),n={type:s.keywordOrder,position:this.getCurrentPosition(),column:i};[s.keywordAscending,s.keywordDescending].indexOf(this.tt)>=0&&this.nextToken(),this.tt==s.keywordNulls&&(this.nextToken(),this.expect([s.keywordFirst,s.keywordLast],!0)),e.push(n)}while(this.tt==s.comma);return e}parseTableOrSubQuery(e){let t=this.parseAtomicTableOrSubQuery(e),i=this.getCurrentPosition();for(;this.parseJoinOperator();){let n=this.parseAtomicTableOrSubQuery(e);t={type:s.keywordJoin,firstOperand:t,secondOperand:n,position:i},this.tt==s.keywordOn&&(this.nextToken(),t.on=this.parseTerm())}return t}parseJoinOperator(){if(this.tt==s.comma)return this.nextToken(),!0;switch(this.tt==s.keywordNatural&&this.nextToken(),this.tt){case s.keywordLeft:return this.nextToken(),this.tt==s.keywordOuter&&this.nextToken(),this.expect(s.keywordJoin,!0);case s.keywordInner:case s.keywordCross:return this.nextToken(),this.expect(s.keywordJoin,!0);case s.keywordJoin:return this.nextToken(),!0;default:return!1}}parseAtomicTableOrSubQuery(e){if(!this.expect([s.identifier,s.leftBracket],!1))return null;if(this.tt==s.leftBracket){this.nextToken();let t;if(this.tt==s.keywordSelect){let i=this.getCurrentPosition(),n=this.parseSelect();t={type:s.subquery,alias:null,position:i,query:n}}else t=this.parseTableOrSubQuery(e);return this.expect(s.rightBracket,!0),this.tt==s.keywordAs&&t.type==s.subquery&&(this.nextToken(),this.expect(s.identifier,!1)&&(t.alias=this.cct.value,this.nextToken(),e.push(t.alias))),t}if(this.tt==s.identifier){let t={type:s.table,identifier:this.cct.value,alias:null,position:this.getCurrentPosition()};e.push(t.identifier),this.nextToken();let i=this.tt==s.keywordAs;return(i||this.tt==s.identifier)&&(i&&this.nextToken(),this.expect(s.identifier,!1)&&(t.alias=this.cct.value,this.nextToken(),e.push(t.alias))),t}}parseColumnList(e,t){let i=[];for(;[s.stringConstant,s.integerConstant,s.floatingPointConstant,s.booleanConstant,s.identifier,s.multiplication,s.leftBracket,s.keywordDistinct].indexOf(this.tt)>=0;){if(this.tt==s.multiplication)i.push({term:null,alias:null,distinct:!1,position:this.getCurrentPosition(),type:s.allColumns}),this.nextToken();else{let n=this.comesToken(s.keywordDistinct,!0),r=this.parseTerm();if(r!=null){let o={type:s.column,term:r,distinct:n,position:r.position};i.push(o),(this.comesToken(s.keywordAs)||this.comesToken(s.identifier))&&(this.skip(s.keywordAs),this.expect(s.identifier,!1)&&(o.alias=""+this.cct.value),this.nextToken())}}if(e.indexOf(this.tt)>=0||this.isEnd())break;this.expect(s.comma,!0)}return i.length==0&&this.pushError("Es fehlt die kommaseparierte Liste der gewünschten Spalten.","error"),i}parseTerm(){return this.parseTermBinary(0)}parseTermBinary(e){let t;e<Q.operatorPrecedence.length-1?t=this.parseTermBinary(e+1):t=this.parseUnary();let i=Q.operatorPrecedence[e];if(t==null||i.indexOf(this.tt)<0)return t;let n=!0;if(this.tt==s.keywordBetween)return this.parseBetween(t);for(;n||i.indexOf(this.tt)>=0;){let r=this.tt;n=!1;let o=this.getCurrentPosition();this.nextToken();let l;e<Q.operatorPrecedence.length-1?l=this.parseTermBinary(e+1):l=this.parseUnary(),t={type:s.binaryOp,position:o,operator:r,firstOperand:t,secondOperand:l}}return t}parseBetween(e){let t=this.getCurrentPosition();this.nextToken();let i=this.parseTermBinary(2);if(this.expect(s.keywordAnd,!0)){let n=this.parseTermBinary(2);return{type:s.keywordBetween,position:t,firstOperand:e,secondOperand:i,thirdOperand:n}}return null}parseUnary(){let e,t=this.getCurrentPosition();switch(this.tt){case s.leftBracket:return this.parseBracket();case s.keywordNot:return t=t,this.nextToken(),e=this.parseTermBinary(2),{type:s.unaryOp,position:t,operand:e,operator:s.keywordNot};case s.minus:t=this.position;let i=this.tt;return this.nextToken(),e=this.parseUnary(),{type:s.unaryOp,position:t,operand:e,operator:i};case s.integerConstant:case s.charConstant:case s.floatingPointConstant:case s.stringConstant:case s.booleanConstant:e={type:s.constantNode,position:this.getCurrentPosition(),constantType:this.tt,constant:this.cct.value};let n=this.tt==s.stringConstant;return this.nextToken(),n?this.parseDotChains(e):e;case s.identifier:let r=this.cct.value,o=this.getCurrentPosition();if(this.nextToken(),this.tt==s.leftBracket){let l=this.parseMethodCallParameters(),d=l.rightBracketPosition;e={type:s.callMethod,position:o,rightBracketPosition:d,operands:l.nodes,identifier:r,commaPositions:l.commaPositions,distinctBeforeParameters:l.distinctBeforeParameters}}else if(e={type:s.identifier,identifier:r,position:t},this.tt==s.dot){let l=this.getCurrentPosition();this.nextToken(),this.expect(s.identifier,!1);let d={type:s.identifier,identifier:this.cct.value,position:this.getCurrentPosition()};this.nextToken(),e={type:s.dot,identifierLeft:e,identifierRight:d,position:l}}else[s.isNull,s.isNotNull].indexOf(this.tt)>=0&&(e={type:s.unaryOp,operand:e,operator:this.tt,position:t},this.nextToken());return e;default:return this.pushError("Erwartet wird eine Variable, ein Methodenaufruf oder eine Konstante. Gefunden wurde: "+this.cct.value),null}}parseList(){let e={type:s.list,position:this.getCurrentPosition(),elements:[]},t=[s.charConstant,s.stringConstant,s.booleanConstant,s.floatingPointConstant,s.integerConstant];for(;t.indexOf(this.tt)>=0&&(e.elements.push({type:s.constantNode,constant:this.cct.value,constantType:this.tt,position:this.cct.position}),this.nextToken(),this.tt==s.comma);)this.nextToken();return e}parseBracket(){this.getCurrentPosition();let e=this.lastToken;if(this.nextToken(),this.tt==s.keywordSelect){let t=this.parseSelect();return this.expect(s.rightBracket,!0),t}else if([s.comma,s.rightBracket].indexOf(this.ct[1].tt)>=0&&[s.keywordIn,s.keywordNotIn].indexOf(e.tt)>=0){let t=this.parseList();return this.expect(s.rightBracket,!0),t}else{let t=this.parseTerm(),i=this.getCurrentPosition();return this.expect(s.rightBracket,!0),{position:i,type:s.rightBracket,termInsideBrackets:t}}}parseMethodCallParameters(){this.nextToken();let e=this.comesToken(s.keywordDistinct,!0);if(this.tt==s.rightBracket){let o=this.getCurrentPosition();return this.nextToken(),{rightBracketPosition:o,nodes:[],commaPositions:[],distinctBeforeParameters:e}}let t=[],i=[];for(;;){let o=this.pos;if(this.tt==s.multiplication)this.nextToken(),t.push({type:s.allColumns,position:this.getCurrentPosition()});else{let l=this.parseTerm();l!=null&&t.push(l)}if(this.tt!=s.comma)break;i.push(this.getCurrentPosition()),this.nextToken(),this.pos==o&&this.nextToken()}let n=this.getCurrentPosition();return{rightBracketPosition:this.expect(s.rightBracket,!0)?n:null,nodes:t,commaPositions:i,distinctBeforeParameters:e}}parseDotChains(e){if(e==null)return null;for(;this.comesToken([s.dot]);)if(this.tt==s.dot){if(this.nextToken(),this.tt!=s.identifier)return this.pushError("Erwartet wird der Bezeichner eines Attributs oder einer Methode, gefunden wurde: "+this.cct.value),e;let t=this.cct.value,i=this.getCurrentPosition();if(this.nextToken(),this.tt==s.leftBracket){let n=this.parseMethodCallParameters();e={type:s.callMethod,position:i,rightBracketPosition:n.rightBracketPosition,operands:n.nodes,identifier:t,commaPositions:n.commaPositions,distinctBeforeParameters:n.distinctBeforeParameters}}}return e}};h(Q,"operatorPrecedence",[[s.keywordOr],[s.keywordAnd],[s.keywordBetween],[s.lower,s.lowerOrEqual,s.greater,s.greaterOrEqual,s.equal,s.notEqual,s.keywordLike],[s.concatenation,s.plus,s.minus],[s.multiplication,s.division,s.modulo],[s.keywordIn,s.keywordNotIn]]);let ye=Q;function Oe(a){return a.replace(/['"]+/g,"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function oi(a){return`${Xe(a.getDate())}.${Xe(a.getMonth())}.${a.getFullYear()}`}function Xe(a){return a<10?"0"+a:""+a}function ai(a){let e=a.match(/^(\d{2})\.(\d{2})\.(\d{4}), (\d{2}):(\d{2})$/);return new Date(Number.parseInt(e[3]),Number.parseInt(e[2]),Number.parseInt(e[1]),Number.parseInt(e[4]),Number.parseInt(e[5]))}function li(a){if(a==null||typeof a!="string")return!1;var e=/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/;if(a.match(e)){var t=a.split("/"),i=a.split("-"),n=t.length,r=i.length;if(n>1)var o=a.split("/");else if(r>1)var o=a.split("-");if(o.length!=3)return!1;var l=parseInt(o[2]),d=parseInt(o[1]),u=parseInt(o[0]),m=[31,28,31,30,31,30,31,31,30,31,30,31];if((d==1||d>2)&&l>m[d-1])return!1;if(d==2){var f=!1;return(!(u%4)&&u%100||!(u%400))&&(f=!0),!(f==!1&&l>=29||f==!0&&l>29)}return!0}else return!1}function di(a){if(a==null||typeof a!="string")return!1;var e=/^\d{4}[\-](0[1-9]|1[012])[\-](0[1-9]|[12][0-9]|3[01]) ([01][0-9]|2[0123]):([0-5][0-9]):([0-5][0-9])$/;if(a.match(e)){var t=a.split(" "),i=t[0];if(i.length!=10)return!1;var n=parseInt(i.substring(8,10)),r=parseInt(i.substring(5,7)),o=parseInt(i.substring(0,4)),l=[31,28,31,30,31,30,31,31,30,31,30,31];if((r==1||r>2)&&n>l[r-1])return!1;if(r==2){var d=!1;return(!(o%4)&&o%100||!(o%400))&&(d=!0),!(d==!1&&n>=29||d==!0&&n>29)}return!0}else return!1}function ui(a){if(a==null||typeof a!="string")return!1;var e=/^([01][0-9]|2[0123]):([0-5][0-9]):([0-5][0-9])$/;return a.match(e)!=null}class pe{constructor(e,t){h(this,"type");this.identifier=e,this.type=v.getBaseType(t)}}class je{constructor(e,t,i,n){h(this,"acceptsStarParameter",!1);h(this,"returnType");this.identifier=e,this.isAggregating=t,this.parameters=n,this.returnType=v.getBaseType(i)}}const De=class De{constructor(){h(this,"methods",[]);this.pushOneParameterMethod("abs","float","float"),this.pushOneParameterMethod("sin","float","float"),this.pushOneParameterMethod("cos","float","float"),this.pushOneParameterMethod("tan","float","float"),this.pushOneParameterMethod("max","integer","integer"),this.pushOneParameterMethod("max","float","float"),this.pushOneParameterMethod("max","date","date"),this.pushOneParameterMethod("max","time","time"),this.pushOneParameterMethod("max","datetime","datetime"),this.pushOneParameterMethod("max","timestamp","timestamp"),this.pushOneParameterMethod("min","integer","integer"),this.pushOneParameterMethod("min","float","float"),this.pushOneParameterMethod("min","date","date"),this.pushOneParameterMethod("min","time","time"),this.pushOneParameterMethod("min","datetime","datetime"),this.pushOneParameterMethod("min","timestamp","timestamp"),this.pushOneParameterMethod("avg","integer","integer"),this.pushOneParameterMethod("avg","float","float"),this.pushOneParameterMethod("sum","float","float"),this.pushOneParameterMethod("sum","integer","integer"),this.pushOneParameterMethod("concat","text","text"),this.pushOneParameterMethod("upper","text","text"),this.pushOneParameterMethod("lower","text","text"),this.pushOneParameterMethod("length","integer","text"),this.pushOneParameterMethod("month","integer","date"),this.pushOneParameterMethod("day","integer","date"),this.pushOneParameterMethod("year","integer","date");let e=new je("count",!0,"integer",[new pe("spalte","text")]);e.acceptsStarParameter=!0,this.methods.push(e);let t=new je("strftime",!1,"text",[new pe("formatstring","text"),new pe("date","date")]);t.acceptsStarParameter=!0,this.methods.push(t)}static getInstance(){return this.instance==null&&(this.instance=new De),this.instance}getMethods(e){return this.methods.filter(t=>t.identifier==e.toLowerCase())}pushOneParameterMethod(e,t,i){this.methods.push(new je(e,!0,t,[new pe("spalte",i)]))}};h(De,"instance");let Ae=De;class me{constructor(e,t,i,n,r,o,l){h(this,"references");h(this,"fromColumnStructure");h(this,"notNull");this.identifier=e,this.type=t,this.table=i,this.isPrimaryKey=n,this.isNullable=r,this.defaultValue=o,this.isAutoIncrement=l}static fromColumnStructure(e,t){let i=/^(\w*) *(?:\((.*)\))?.*$/,n=e.completeTypeSQL.match(i),r=n[1],o=n[2],l=[];o!=null&&(l=o.split(",").map(m=>parseInt(m.trim())));let d;if(r.indexOf("Enum")>=0)switch(r){case"textEnum":d=new ce(e.enumValues);break;case"realEnum":d=new he(e.enumValues.map(m=>Number.parseFloat(m)));break;case"integerEnum":d=new he(e.enumValues.map(m=>Number.parseInt(m)));break}else d=v.getBaseType(r);l.length>0&&d!=null&&(d=new le(d,l));let u=new me(e.name,d,t,e.isPrimaryKey,!e.isPrimaryKey,e.defaultValue,e.isAutoIncrement);return u.notNull=e.notNull,u.fromColumnStructure=e,u}}class Z{constructor(e){h(this,"columns",[]);h(this,"size");h(this,"type");this.identifier=e}static fromTableStructure(e){let t=new Z(e.name);return t.columns=e.columns.map(i=>me.fromColumnStructure(i,t)),t.size=e.size,t.type=e.type,t}static fromTableStructureList(e){e==null&&(e=[]);let t=e.map(n=>Z.fromTableStructure(n)),i=new Map;for(let n of t)for(let r of n.columns)i.set(r.fromColumnStructure,r);for(let n of t)for(let r of n.columns){let o=r.fromColumnStructure.references;if(o!=null){let l=i.get(o);r.references=l}}return t}}class ke{constructor(e,t,i){h(this,"parent");h(this,"positionFrom");h(this,"positionTo");h(this,"childSymbolTables",[]);h(this,"symbols",new Map);h(this,"symbolList",[]);this.parent=e,this.positionFrom=t,this.positionTo=i,this.parent!=null&&this.parent.childSymbolTables.push(this)}extractDatabaseStructure(e){for(let t of Z.fromTableStructureList(e==null?void 0:e.tables))this.storeTableSymbols(t)}storeTableSymbols(e){this.storeSymbol({identifier:e.identifier,posOfDefinition:null,referencedOnPositions:[],table:e});for(let t of e.columns)this.storeSymbol({identifier:t.identifier,posOfDefinition:null,referencedOnPositions:[],column:t})}storeSymbol(e){let t=this.symbols.get(e.identifier.toLowerCase());t==null?(t=[e],this.symbols.set(e.identifier.toLowerCase(),t)):t.push(e),this.symbolList.push(e)}findTableAtPosition(e,t){if(!this.containsPosition(e,t))return null;let i=null,n=1e7;for(let r of this.childSymbolTables)if(r.containsPosition(e,t)){let o=r.findTableAtPosition(e,t);o.positionTo.line-o.positionFrom.line<n&&(i=o,n=o.positionTo.line-o.positionFrom.line)}return i??this}containsPosition(e,t){return!(e<this.positionFrom.line||e>this.positionTo.line||e==this.positionFrom.line&&t<this.positionFrom.column||e==this.positionTo.line&&t>this.positionTo.column+1)}findTable(e){let t=this.findTables(e);return t.length==0?null:t[0].table}findTables(e){let t=this;for(;t!=null;){let i=t.symbols.get(e.toLowerCase());if(i!=null&&(i=i.filter(n=>n.table!=null),i.length>0))return i;t=t.parent}return[]}findColumn(e){let t=this;for(;t!=null;){let i=t.symbols.get(e.toLowerCase());if(i!=null&&(i=i.filter(n=>n.column!=null),i.length>0))return i;t=t.parent}return[]}}class hi{constructor(e){h(this,"symbolTableStack",[]);h(this,"errorList");h(this,"module");h(this,"databaseTool");h(this,"tables");var t;this.databaseTool=e,this.tables=Z.fromTableStructureList((t=e.databaseStructure)==null?void 0:t.tables)}start(e){this.module=e,this.symbolTableStack=[],this.errorList=[],e.mainSymbolTable=new ke(null,{column:0,line:0,length:0},{column:0,line:1e5,length:0}),this.symbolTableStack.push(e.mainSymbolTable);for(let t of this.module.sqlStatements){let i=this.errorList.length,n=t.ast;if(n!=null){switch(n.type){case s.keywordSelect:this.resolveSelect(n,t.resultTypes),this.symbolTableStack.pop();break;case s.keywordInsert:this.resolveInsert(n),this.symbolTableStack.pop();break;case s.keywordCreate:this.resolveCreateTable(n),this.symbolTableStack.pop();break;case s.keywordUpdate:this.resolveUpdate(n),this.symbolTableStack.pop();break;case s.keywordDelete:this.resolveDelete(n),this.symbolTableStack.pop();break;case s.keywordDrop:this.resolveDropTable(n),this.symbolTableStack.pop();break;case s.keywordAlter:this.resolveAlterTable(n),this.symbolTableStack.pop();break;case s.keywordView:this.resolveCreateView(n),this.symbolTableStack.pop()}t.hasErrors=t.hasErrors||this.errorList.length>i}}e.errors[2]=this.errorList}pushError(e,t="error",i){this.errorList.push({text:e,position:i,level:t})}getCurrentSymbolTable(){return this.symbolTableStack[this.symbolTableStack.length-1]}pushNewSymbolTable(e,t){t==null&&(t={line:1e5,column:1,length:1});let i=new ke(this.getCurrentSymbolTable(),e,t);return this.symbolTableStack.push(i),i}resolveSelect(e,t){let i=new Z(null);e.symbolTable=this.pushNewSymbolTable(e.position,e.symbolTableEndPosition);let n=[];this.resolveTableOrSubQuery(e.fromNode,n),e.fromStartPosition!=null&&new ke(this.getCurrentSymbolTable(),e.fromStartPosition,e.fromEndPosition).extractDatabaseStructure(this.databaseTool.databaseStructure);for(let r of e.columnList)if(r.type==s.allColumns)for(let o of n)for(let l of o.columns){let d=new me(l.identifier,l.type,i,!1,!0,l.defaultValue,l.isAutoIncrement);i.columns.push(d),t.push(l.type)}else{this.resolveTerm(r.term);let o=new me(r.alias,r.term.sqlType,i,!1,!0,null,!1);i.columns.push(o),t.push(r.term.sqlType),o.identifier!=null&&e.symbolTable.storeSymbol({identifier:o.identifier,posOfDefinition:r.term.position,referencedOnPositions:[],column:o})}if(e.whereNode!=null){let r=this.resolveTerm(e.whereNode);r!=null&&r.getBaseTypeName()!="boolean"&&this.pushError("Das Ergebnis des where-Teils einer select-Anweisung muss vom Typ boolean sein.","error",e.whereNode.position)}return e.union!=null&&(this.symbolTableStack.pop(),this.resolveSelect(e.union,[]).columns.length!=i.columns.length&&this.pushError("Die select-Anweisungen links und rechts vom Schlüsselwort 'union' müssen dieselbe Anzahl von Spalten besitzen.","error",e.symbolTableEndPosition)),i}resolveDropTable(e){e.symbolTable=this.pushNewSymbolTable(e.position,e.endPosition),e.symbolTable.extractDatabaseStructure(this.databaseTool.databaseStructure),e.tableIdentifier!=null&&(e.ifExists||e.symbolTable.findTable(e.tableIdentifier)==null&&this.pushError("Die Tabelle "+e.tableIdentifier+" ist nicht bekannt.","error",e.tableIdentifierPosition))}resolveDelete(e){if(e.symbolTable=this.pushNewSymbolTable(e.position,e.endPosition),e.symbolTable.extractDatabaseStructure(this.databaseTool.databaseStructure),e.tableIdentifier==null)return;let t=e.symbolTable.findTable(e.tableIdentifier);if(t==null&&this.pushError("Die Tabelle "+e.tableIdentifier+" ist nicht bekannt.","error",e.tableIdentifierPosition),e.whereNode!=null){let i=this.pushNewSymbolTable(e.whereNodeBegin,e.whereNodeEnd);t!=null&&i.storeTableSymbols(t),this.resolveTerm(e.whereNode),this.symbolTableStack.pop()}}resolveAlterTable(e){if(e.symbolTable=this.pushNewSymbolTable(e.position,e.endPosition),e.symbolTable.extractDatabaseStructure(this.databaseTool.databaseStructure),e.tableIdentifier==null)return;let t=e.symbolTable.findTable(e.tableIdentifier);t==null&&this.pushError("Die Tabelle "+e.tableIdentifier+" ist nicht bekannt.","error",e.tableIdentifierPosition);let i=null;switch(e.oldColumnName!=null&&(i=t.columns.find(n=>n.identifier.toLocaleLowerCase()==e.oldColumnName.toLocaleLowerCase()),i==null&&this.pushError("Die Tabelle "+e.tableIdentifier+" hat keine Spalte mit dem Bezeichner "+e.oldColumnName,"error",e.oldColumnPosition)),e.kind){case"dropColumn":break;case"addColumn":let n=e.columnDef;if(n==null)break;if(n.foreignKeyInfo!=null&&n.baseType!=null){let r=n.foreignKeyInfo,o=this.getCurrentSymbolTable().findTables(r.referencesTable);if(o.length==1){let l=o[0].table,d=l.columns.find(u=>u.identifier==r.referencesColumn);d!=null&&d.type!=null&&(d.isPrimaryKey||this.pushError("Die referenzierte Spalte "+r.referencesTable+"."+r.referencesColumn+" ist kein Primärschlüssel.","warning",n.referencesPosition),d.type.canCastTo(n.baseType)||this.pushError("Der Datentyp "+n.baseType.toString()+" der Spalte "+n.identifier+" kann nich in den Datentyp "+d.type.toString()+" der referenzierten Spalte "+l.identifier+"."+d.identifier+" umgewandelt werden.","error",n.referencesPosition))}}break}}resolveUpdate(e){if(e.symbolTable=this.pushNewSymbolTable(e.position,e.endPosition),e.symbolTable.extractDatabaseStructure(this.databaseTool.databaseStructure),e.tableIdentifier==null)return;let t=e.symbolTable.findTable(e.tableIdentifier);if(t==null)this.pushError("Die Tabelle "+e.tableIdentifier+" ist nicht bekannt.","error",e.tableIdentifierPosition);else{for(let i=0;i<e.columnIdentifiers.length;i++){let n=e.columnIdentifiers[i],r=e.columnIdentifierPositions[i],o=e.values[i];if(n==null||(t.columns.find(u=>u.identifier==n)==null&&this.pushError(n+" ist kein Bezeichner einer Spalte der Tabelle "+e.tableIdentifier+".","error",r),o==null))continue;this.pushNewSymbolTable(e.valuePosBegin[i],e.valuePosEnd[i]).storeTableSymbols(t),this.resolveTerm(o),this.symbolTableStack.pop()}e.whereNodeBegin!=null&&this.pushNewSymbolTable(e.whereNodeBegin,e.whereNodeEnd).storeTableSymbols(t),e.whereNode!=null&&this.resolveTerm(e.whereNode)}this.symbolTableStack.pop()}resolveCreateTable(e){e.symbolTable=this.pushNewSymbolTable(e.position,e.endPosition),e.symbolTable.extractDatabaseStructure(this.databaseTool.databaseStructure);let t={identifier:e.identifier,columns:null,size:0,type:"table"};t.columns=e.columnList.map(i=>({identifier:i.identifier,isNullable:!1,isPrimaryKey:i.isPrimary,isAutoIncrement:i.isAutoIncrement,notNull:!1,references:null,table:t,type:i.baseType,defaultValue:i.defaultValue})),e.symbolTable.storeTableSymbols(t);for(let i of e.columnList)if(e.columnList.filter(n=>n.identifier.toLocaleLowerCase()==i.identifier.toLocaleLowerCase()).length>1&&this.pushError("Der Spaltenbezeichner "+i.identifier+" darf in einer Tabelle nur ein einziges Mal verwendet werden","error",i.position),i.foreignKeyInfo!=null&&i.baseType!=null){let n=i.foreignKeyInfo,r=this.getCurrentSymbolTable().findTables(n.referencesTable);if(r.length==1){let o=r[0].table,l=o.columns.find(d=>d.identifier==n.referencesColumn);l!=null&&l.type!=null&&(l.isPrimaryKey||this.pushError("Die referenzierte Spalte "+n.referencesTable+"."+n.referencesColumn+" ist kein Primärschlüssel.","warning",i.referencesPosition),l.type.canCastTo(i.baseType)||this.pushError("Der Datentyp "+i.baseType.toString()+" der Spalte "+i.identifier+" kann nich in den Datentyp "+l.type.toString()+" der referenzierten Spalte "+o.identifier+"."+l.identifier+" umgewandelt werden.","error",i.referencesPosition))}}for(let i of e.foreignKeyInfoList){let n=e.columnList.find(o=>o.identifier==i.column);if(n==null)continue;let r=this.getCurrentSymbolTable().findTables(i.referencesTable);if(r.length==1){let o=r[0].table,l=o.columns.find(d=>d.identifier==i.referencesColumn);l!=null&&l.type!=null&&(l.isPrimaryKey||this.pushError("Die referenzierte Spalte "+i.referencesTable+"."+i.referencesColumn+" ist kein Primärschlüssel.","warning",i.referencesPosition),l.type.canCastTo(n.baseType)||this.pushError("Der Datentyp "+n.baseType.toString()+" der Spalte "+n.identifier+" kann nich in den Datentyp "+l.type.toString()+" der referenzierten Spalte "+o.identifier+"."+l.identifier+" umgewandelt werden.","error",i.referencesPosition))}}}resolveTableOrSubQuery(e,t){if(e!=null)switch(e.type){case s.table:let i=this.tables.filter(n=>n.identifier.toLowerCase()==e.identifier.toLowerCase());if(i.length==0)this.pushError(e.identifier+" ist nicht der Name einer Tabelle.","error",e.position);else if(i.length>1)this.pushError("Der Bezeichner "+e.identifier+" ist hier nicht eindeutig.","error",e.position);else{let n=i[0];t.push(n),this.storeTableIntoSymbolTable(n,e.position,e.alias)}break;case s.keywordJoin:this.resolveTableOrSubQuery(e.firstOperand,t),this.resolveTableOrSubQuery(e.secondOperand,t);break;case s.subquery:e.table=this.resolveSelect(e.query,[]),t.push(e.table),e.alias!=null&&(e.table.identifier=e.alias,this.storeTableIntoSymbolTable(e.table,e.position));break}}storeTableIntoSymbolTable(e,t,i){let n=this.getCurrentSymbolTable();n.storeSymbol({identifier:i==null?e.identifier.toLowerCase():i.toLowerCase(),posOfDefinition:t,table:e,referencedOnPositions:[]});for(let r of e.columns)n.storeSymbol({identifier:r.identifier.toLowerCase(),posOfDefinition:null,column:r,tableAlias:i,referencedOnPositions:[]})}resolveTerm(e){if(e==null)return null;switch(e.type){case s.keywordBetween:let t=this.resolveTerm(e.firstOperand),i=this.resolveTerm(e.secondOperand),n=this.resolveTerm(e.thirdOperand);return t==null||i==null||n==null?null:t.canCastTo(v.getBaseType("double"))?i.canCastTo(v.getBaseType("double"))?(n.canCastTo(v.getBaseType("double"))||this.pushError("Hier wird eine Zahl erwartet.","error",e.thirdOperand.position),v.getBaseType("boolean")):(this.pushError("Hier wird eine Zahl erwartet.","error",e.secondOperand.position),null):(this.pushError("Hier wird eine Zahl erwartet.","error",e.firstOperand.position),null);case s.binaryOp:if([s.keywordIn,s.keywordNotIn].indexOf(e.operator)>=0)return this.resolveNotIn(e);let r=this.resolveTerm(e.firstOperand),o=this.resolveTerm(e.secondOperand);if(r!=null&&o!=null){let u=r.getBinaryResultType(e.operator,o);return u==null&&this.pushError("Der Operator "+D[e.operator]+" ist für die Datentypen "+r.toString()+" und "+o.toString()+" nicht definiert.","error",e.position),e.sqlType=u,u}else return null;case s.unaryOp:let l=this.resolveTerm(e.operand);if(l!=null){let u=l.getUnaryResultType(e.operator);return u==null&&this.pushError("Der Operator "+D[e.operator]+" ist für einen Operanden des Datentyps "+l.toString()+" nicht definiert.","error",e.position),e.sqlType=u,u}else return null;case s.callMethod:return this.resolveMethodCall(e);case s.constantNode:return e.sqlType=v.fromConstantType(e.constantType),e.sqlType;case s.identifier:return this.resolveIdentifier(e);case s.dot:return this.resolveDot(e);case s.keywordSelect:let d=this.resolveSelect(e,[]);return d.columns.length!=1?(this.pushError("Die Ergebnistabelle einer Unterabfrage an dieser Stelle muss genau eine Spalte besitzen.","error",e.position),null):d.columns[0].type;case s.rightBracket:return e.sqlType=this.resolveTerm(e.termInsideBrackets),e.sqlType;case s.allColumns:this.pushError("Das Zeichen * kann hier nicht verwendet werden.","error",e.position);break;case s.list:this.pushError("Eine Liste wird hier nicht erwartet.","error",e.position);break}}resolveDot(e){let t=this.getCurrentSymbolTable().findTables(e.identifierLeft.identifier);if(t.length==0)return this.pushError("Die Tabelle "+e.identifierLeft.identifier+" kann nicht gefunden werden.","error",e.identifierLeft.position),null;if(t.length>1)return this.pushError("Der Tabellenbezeichner "+e.identifierLeft.identifier+" ist nicht eindeutig.","error",e.identifierLeft.position),null;let n=t[0].table.columns.filter(o=>o.identifier.toLowerCase()==e.identifierRight.identifier.toLowerCase());if(n.length==0){this.pushError("Die Tabelle "+e.identifierLeft.identifier+" hat keine Spalte mit dem Bezeichner "+e.identifierRight.identifier+".","error",e.identifierRight.position);return}if(n.length>1){this.pushError("Die Tabelle "+e.identifierLeft.identifier+" hat mehrere Spalten mit dem Bezeichner "+e.identifierRight.identifier+".","error",e.identifierRight.position);return}let r=n[0];return e.sqlType=r.type,r.type}resolveIdentifier(e){let t=this.getCurrentSymbolTable().findColumn(e.identifier);if(t.length==0)return this.pushError("Der Bezeichner "+e.identifier+" ist an dieser Stelle nicht bekannt.","error",e.position),null;if(t.length>1)return this.pushError("Der Bezeichner "+e.identifier+" ist nicht eindeutig.","error",e.position),null;let i=t[0];return e.sqlType=i.column.type,i.column.type}resolveMethodCall(e){let i=Ae.getInstance().getMethods(e.identifier);if(e.identifier.toLocaleLowerCase()=="concat"){if(e.operands.length==0)return this.pushError("Die Methode concat benötigt mindestens einen Parameter.","error",e.position),null;let n=i[0];return e.sqlType=n.returnType,e.sqlType}else{let n=e.identifier.toLocaleLowerCase()=="count";if(n||(i=i.filter(r=>r.parameters.length==e.operands.length)),e.operands.length==1&&e.operands[0].type==s.allColumns)return i=i.filter(r=>r.acceptsStarParameter),e.sqlType=i[0].returnType,e.sqlType;if(i.length==0)return this.pushError("Es gibt keine passende Methode mit dem Bezeichner '"+e.identifier+"'.","error",e.position),null;for(let r of e.operands)if(this.resolveTerm(r)==null)return e.sqlType=i[0].returnType,e.sqlType;for(let r of i){let o=!0;for(let l=0;l<r.parameters.length;l++){let d=r.parameters[l],u=e.operands[l];if(u!=null&&!u.sqlType.canCastTo(d.type)){o=!1;break}}if(o||n)return e.sqlType=r.returnType,e.sqlType}return this.pushError("Es gibt keine passende Methode mit dem Bezeichner '"+e.identifier+"'.","error",e.position),null}}resolveNotIn(e){if(e.firstOperand==null||e.secondOperand==null)return null;let t=D[e.operator];this.resolveTerm(e.firstOperand);let i=e.firstOperand.sqlType;if(i!=null)if(e.secondOperand.type==s.keywordSelect){let n=e.secondOperand;n.columnList.length!=1&&this.pushError("Wenn rechts vom Operator '"+t+"' eine Unterabfrage steht, muss die Ergebnistabelle dieser Unterabfrage genau eine Spalte haben.","error",n.position),this.resolveSelect(n,[]);let r=n.columnList[0].term.sqlType;r.canCastTo(i)||this.pushError("Der Datentyp der Ergebnisspalte der Unterabfrage ist "+r.toString()+". Dieser kann nicht in den Datentyp "+i.toString()+" umgewandelt werden.","error",n.position)}else if(e.secondOperand.type==s.list){let n=e.secondOperand;for(let r of n.elements){let o=v.fromConstantType(r.constantType);r.sqlType=o,o.canCastTo(i)||this.pushError("Der Datentyp des Listenelements "+r.constant+" ist "+o.toString()+". Er kann nicht in den Datentype "+i.toString()+" des Operanden auf der linken Seite des Operators '"+t+"' umgewandelt werden.","error",r.position)}}else this.pushError("Der rechte Operand der Operatoren 'in' und 'not in' muss eine Unterabfrage oder eine Liste sein.","error",e.secondOperand.position);return v.getBaseType("boolean")}resolveCreateView(e){let t=this.pushNewSymbolTable(e.position,e.endPosition);this.resolveSelect(e.selectStatement,[]),t.childSymbolTables.push(this.symbolTableStack.pop())}resolveInsert(e){let t=null,i=this.pushNewSymbolTable(e.position,e.endPosition);e.table!=null&&(e.table.table=this.tables.find(l=>l.identifier.toLowerCase()==e.table.identifier.toLocaleLowerCase()),e.table.table==null?this.pushError("Die Tabelle "+e.table.identifier+" gibt es nicht.","error",e.table.position):(t=e.table.table,i.storeTableSymbols(t)));let n=e.endPosition;e.valuesPosition!=null&&(n=e.valuesPosition),e.columnsPosition!=null&&(n=e.columnsPosition),this.module.addCompletionHint(e.position,n,!1,!0,["into","values"]),t!=null&&this.module.addCompletionHint(n,e.valuesPosition==null?e.endPosition:e.valuesPosition,!0,!1,["values"]),this.pushNewSymbolTable(e.position,n).extractDatabaseStructure(this.databaseTool.databaseStructure);let o=[];if(e.columnList.length==0)t!=null&&(o=t.columns);else if(t!=null)for(let l of e.columnList){let d=t.columns.find(u=>u.identifier.toLowerCase()==l.identifier.toLowerCase());d==null?this.pushError("Die Tabelle "+t.identifier+" besitzt keine Spalte mit dem Bezeichner "+l.identifier+".","error",l.position):o.push(d)}if(o.length>0)if(e.select!=null){let l=this.resolveSelect(e.select,[]);if((l==null?void 0:l.columns)!=null)if(o.length!=l.columns.length)this.pushError("Die insert-Anweisung erwartet "+o.length+" Werte je Datensatz, die select-Anweisung liefert aber "+l.columns.length+".","error",e.position);else for(let d=0;d<o.length;d++){let u=o[d],m=l.columns[d];u.type!=null&&m.type!=null&&(m.type.canCastTo(u.type)||this.pushError("Der Datentyp "+m.type.toString()+" der "+(d+1)+"-ten Spalte des select-Terms kann nicht in den Datentyp "+u.type.toString()+" der entsprechenden Spalte der insert-Anweisung umgewandelt werden.","error",e.position))}}else for(let l of e.values)if(l.length!=o.length&&l.length>0)this.pushError("Erwartet werden "+o.length+" Elemente, hier stehen aber "+l.length+" Elemente in der Liste.","error",l[0].position);else for(let d=0;d<l.length;d++){let u=l[d],m=o[d];u.sqlType=v.fromConstantType(u.constantType);let f=m.type.toString().toLocaleLowerCase();if(u.constantType==s.keywordNull)(!m.isNullable||m.notNull)&&this.pushError("Die Spalte "+m.identifier+" ist nicht nullable, daher kann null hier nicht eingefügt werden.","error",u.position);else if(u.sqlType.canCastTo(m.type)){if(f=="date"){if(!li(u.constant)){let p=`'${u.constant}' ist kein date-Wert.<br><b>Tipp: </b>Datumswerte haben die Form 'yyyy-mm-dd', also z.B. '2022-06-15'.`;this.pushError(p,"error",u.position)}}else if(f=="datetime"||f=="timestamp"){if(!di(u.constant)){let p=`'${u.constant}' ist kein ${f}-Wert.<br><b>Tipp: </b>Timestamps haben die Form 'yyyy-mm-dd hh:min:ss', also z.B. '2022-06-15 07:56:22'.`;this.pushError(p,"error",u.position)}}else if(f=="time"&&!ui(u.constant)){let p=`'${u.constant}' ist kein ${f}-Wert.<br><b>Tipp: </b>Time-Werte haben die Form 'hh:min:ss', also z.B. '07:56:22'.`;this.pushError(p,"error",u.position)}}else{let p="Der Wert "+u.constant+" vom Datentyp "+u.sqlType.toString()+" kann nicht in den Datentyp "+m.type.toString()+" der Spalte "+m.identifier+" umgewandelt werden.";f=="date"&&(p+="<br><b>Tipp: </b>Datumswerte haben die Form 'yyyy-mm-dd', also z.B. '2022-06-15'."),(f=="datetime"||f=="timestamp")&&(p+="<br><b>Tipp: </b>Timestamps haben die Form 'yyyy-mm-dd hh:min:ss', also z.B. '2022-06-15 07:56:22'."),this.pushError(p,"error",u.position)}}this.symbolTableStack.pop()}}var fe=(a=>(a[a.compiling=0]="compiling",a[a.error=1]="error",a[a.compiledButNothingToRun=2]="compiledButNothingToRun",a[a.readyToRun=3]="readyToRun",a))(fe||{});class ct{constructor(e){h(this,"compilerStatus",2);h(this,"atLeastOneModuleIsStartable");this.main=e}compile(e){this.compilerStatus=0;let t=performance.now(),i=new Re;for(let u of e.getModules(!1)){u.file.dirty=!1,u.clear();let m=i.lex(u.getProgramTextFromMonacoModel());u.errors[0]=m.errors,u.tokenList=m.tokens,u.bracketError=m.bracketError}this.main.getSemicolonAngel().startRegistering();let n=new ye;for(let u of e.getModules(!1))n.parse(u);let r=this.main.getDatabaseTool(),o=new hi(r);for(let u of e.getModules(!1))o.start(u);let l=performance.now()-t;l=Math.round(l*100)/100;let d="Compiled in "+l+" ms.";return this.main.getCurrentWorkspace().compilerMessage=d,this.main.getSemicolonAngel().healSemicolons(),this.compilerStatus=3,null}}const z=class z{constructor(e,t){h(this,"file");h(this,"uri");h(this,"model");h(this,"oldErrorDecorations",[]);h(this,"lastSavedVersionId");h(this,"editorState");h(this,"errors",[[],[],[],[]]);h(this,"tokenList");h(this,"sqlStatements");h(this,"mainSymbolTable");h(this,"identifierPositions",{});h(this,"methodCallPositions",{});h(this,"bracketError");h(this,"completionHints",new Map);if(this.main=t,e==null||this.main==null)return;this.file=e;let i=e.name,n=z.uriMap[i];n==null?n=0:n++,z.uriMap[i]=n,n>0&&(i+=" ("+n+")"),this.uri=Pt.from({path:i,scheme:"inmemory"}),this.model=x.createModel(e.text,"vscSQL",this.uri),this.model.updateOptions({tabSize:3}),this.lastSavedVersionId=this.model.getAlternativeVersionId();let r=this;this.model.onDidChangeContent(()=>{let o=r.model.getAlternativeVersionId();if(o!=r.lastSavedVersionId&&(r.file.dirty=!0,r.file.saved=!1,r.lastSavedVersionId=o),!r.main.isEmbedded()){let l=t;l.workspacesOwnerId!=l.user.id?(r.file.text_before_revision==null||r.file.student_edited_after_revision)&&(r.file.student_edited_after_revision=!1,r.file.text_before_revision=r.file.text,r.file.saved=!1,l.networkManager.sendUpdates(null,!1),l.bottomDiv.homeworkManager.showHomeWorkRevisionButton(),l.projectExplorer.renderHomeworkButton(r.file)):r.file.student_edited_after_revision=!0}})}addCompletionHint(e,t,i,n,r,o,l="",d=""){let u={fromColumn:e.column,fromLine:e.line,toColumn:t.column,toLine:t.line,hintColumns:typeof i=="boolean"?i:!0,hintColumnsOfTable:typeof i=="string"?i:null,hintTables:n,hintKeywords:r==null?null:r.map(m=>m.toUpperCase()),dontHint:o,praefix:l,suffix:d};for(let m=u.fromLine;m<=u.toLine;m++){let f=this.completionHints.get(m);f==null&&(f=[],this.completionHints.set(m,f)),f.push(u)}}getSQLSTatementsAtSelection(e){let t={line:e.startLineNumber,column:e.startColumn},i={line:e.endLineNumber,column:e.endColumn};return this.sqlStatements==null?[]:this.sqlStatements.filter(n=>!(this.compare(n.to,t)<0||this.compare(n.from,i)>0))}compare(e,t){return e.line>t.line?1:e.line<t.line?-1:e.column>t.column?1:e.column<t.column?-1:0}getSQLStatementAtPosition(e){return this.sqlStatements.find(t=>!(t.from.line>e.lineNumber||t.from.line==e.lineNumber&&t.from.column>e.column||t.to.line<e.lineNumber||t.to.line==e.lineNumber&&t.to.column<e.column))}getCompletionHint(e,t){let i=this.completionHints.get(e);if(i==null||i.length==0)return null;let n=e*1e3+t;if(i=i.filter(l=>n>=l.fromLine*1e3+l.fromColumn&&n<=l.toLine*1e3+l.toColumn),i.length==0)return;let r=i[0],o=(r.toLine-r.fromLine)*1e3+(r.toColumn-r.fromColumn);for(let l=1;l<i.length;l++){let d=i[l],u=(d.toLine-d.fromLine)*1e3+(d.toColumn-d.fromColumn);u<o&&(r=d,o=u)}return r}static restoreFromData(e,t){let i={name:e.name,text:e.text,text_before_revision:e.text_before_revision,submitted_date:e.submitted_date,student_edited_after_revision:!1,dirty:!0,saved:!0,version:e.version,id:e.id};return new z(i,t)}getFileData(e){let t=this.file;return{id:t.id,name:t.name,text:t.text,text_before_revision:t.text_before_revision,submitted_date:t.submitted_date,student_edited_after_revision:t.student_edited_after_revision,version:t.version,workspace_id:e.id,forceUpdate:!1,file_type:11}}findSymbolTableAtPosition(e,t){return this.mainSymbolTable==null?null:((e>this.mainSymbolTable.positionTo.line||e==this.mainSymbolTable.positionTo.line&&t>this.mainSymbolTable.positionTo.column)&&(e=this.mainSymbolTable.positionTo.line,t=this.mainSymbolTable.positionTo.column-1),this.mainSymbolTable.findTableAtPosition(e,t))}getErrorCount(){let e=0;for(let t of this.errors)t.forEach(i=>e+=i.level=="error"?1:0);return e}getProgramTextFromMonacoModel(){return this.model.getValue(x.EndOfLinePreference.LF,!1)}addIdentifierPosition(e,t){let i=this.identifierPositions[e.line];i==null&&(i=[],this.identifierPositions[e.line]=i),i.push({position:e,element:t})}getElementAtPosition(e,t){let i=this.identifierPositions[e];if(i==null)return null;let n=null;for(let r of i)t>=r.position.column&&t<r.position.column+r.position.length&&r.position.length>0&&n==null&&(n=r);return n==null?null:n.element}copy(){let e=new z(this.file,this.main);return e.model=this.model,e.mainSymbolTable=this.mainSymbolTable,this.mainSymbolTable=null,this.file.dirty=!0,e}clear(){this.identifierPositions={},this.file!=null&&this.file.dirty&&(this.tokenList=null,this.errors[0]=[],this.errors[1]=[]),this.errors[2]=[],this.errors[3]=[],this.mainSymbolTable=new ke(null,{line:1,column:1,length:1},{line:1e5,column:1,length:0}),this.methodCallPositions={}}hasErrors(){for(let e of this.errors)if(e.find(t=>t.level=="error"))return!0;return!1}getSortedAndFilteredErrors(){let e=[];for(let t of this.errors)e=e.concat(t);e.sort((t,i)=>t.position.line>i.position.line?1:i.position.line>t.position.line?-1:t.position.column>=i.position.column?1:-1);for(let t=0;t<e.length-1;t++){let i=e[t],n=e[t+1];i.position.line==n.position.line&&i.position.column+10>n.position.column&&(this.errorLevelCompare(i.level,n.level)==1?e.splice(t+1,1):e.splice(t,1),t--)}return e}errorLevelCompare(e,t){return e=="error"?1:t=="error"?2:e=="warning"?1:t=="warning"?2:1}};h(z,"maxUriNumber",0),h(z,"uriMap",{});let U=z;class qe{constructor(e){h(this,"modules",[]);h(this,"moduleMap",new Map);h(this,"dirty",!1);this.main=e}findModuleById(e){for(let t of this.modules)if(t.file.id==e)return t;return null}copy(){let e=new qe(this.main);for(let t of this.modules)e.putModule(t.copy());return e}findModuleByFile(e){for(let t of this.modules)if(t.file==e)return t;return null}hasErrors(){for(let e of this.modules)if(e.hasErrors())return!0;return!1}getFirstModule(){if(this.modules.length>0)for(let e of this.modules)return e;return null}isDirty(){if(this.dirty)return this.dirty=!1,!0;let e=!1;for(let t of this.modules)if(t.file.dirty){e=!0;break}return e}getModules(e,t){let i=[];for(let n of this.modules)n.file.name!=t&&i.push(n);return i}putModule(e){this.modules.push(e),this.moduleMap[e.file.name]=e}removeModuleWithFile(e){for(let t of this.modules)if(t.file==e){this.removeModule(t);break}}removeModule(e){this.modules.indexOf(e)<0||(this.modules.splice(this.modules.indexOf(e),1),this.moduleMap[e.file.name]=void 0,this.dirty=!0)}getModule(e){return this.moduleMap[e]}}class mt{constructor(e){h(this,"semicolonPositions",[]);h(this,"time");this.main=e}startRegistering(){this.semicolonPositions.forEach(e=>e.isThereAgain=!1),this.time=new Date().getTime()}register(e,t){let i=this.semicolonPositions.find(n=>n.position.line==e.line&&n.position.column==e.column);i?i.isThereAgain=!0:this.semicolonPositions.push({position:e,firstSeenMs:this.time,isThereAgain:!0,module:t})}healSemicolons(){let e=new Date().getTime();this.semicolonPositions=this.semicolonPositions.filter(n=>n.isThereAgain);let t=this.main.getCurrentlyEditedModule(),i=this.main.getMonacoEditor().getPosition().lineNumber;this.semicolonPositions.filter(n=>e-n.firstSeenMs>2e3).forEach(n=>{let r=n.module.file.id!=null&&n.module.file.id==t.file.id,o=[{range:new it(n.position.line,n.position.column,n.position.line,n.position.column),text:";",forceMoveMarkers:!0}];if(r&&Math.abs(i-n.position.line)>1){let l=this.main.getMonacoEditor();const d=l.getSelection();l.executeEdits("Semicolon-Angel",o),l.setSelection(d),this.semicolonPositions.splice(this.semicolonPositions.indexOf(n),1)}})}}var bn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function wn(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}function ci(a){if(a.__esModule)return a;var e=a.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(a).forEach(function(i){var n=Object.getOwnPropertyDescriptor(a,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return a[i]}})}),t}class ft{constructor(e,t){h(this,"actions",{});h(this,"keyEntries",{});h(this,"buttons",{});this.$mainElement=e,this.main=t}init(){let e=this.$mainElement;e==null&&(e=c(document));let t=this;e.on("keydown",function(i){i!=null&&t.executeKeyDownEvent(i)})}trigger(e){let t=this.actions[e];t!=null&&t.action(e,null,"")}registerAction(e,t,i,n="",r){let o={action:i,identifier:e,keys:t,text:n,active:!0};this.actions[e]=o;for(let l of t)this.keyEntries[l.toLowerCase()]==null&&(this.keyEntries[l.toLowerCase()]=[]),this.keyEntries[l.toLowerCase()].push(o);if(r!=null){this.buttons[e]==null&&(this.buttons[e]=[]),this.buttons[e].push(r);let l=n;t.length>0&&(l+=" ["+t.join(", ")+"]"),r.attr("title",l),r.on("mousedown",()=>{o.active&&i(e,null,"mousedown")})}}isActive(e){let t=this.actions[e];return t==null?!1:t.active}setActive(e,t){let i=this.actions[e];i!=null&&(i.active=t);let n=this.buttons[e];if(n!=null)for(let r of n)t?r.addClass("jo_active"):r.removeClass("jo_active")}executeKeyDownEvent(e){if(document.activeElement.tagName.toLowerCase()=="input"||e.keyCode<=18&&e.keyCode>=16)return;let t="";e.ctrlKey&&(t+="ctrl+"),e.shiftKey&&(t+="shift+"),e.altKey&&(t+="alt+"),e.key!=null&&(t+=e.key.toLowerCase());let i=this.keyEntries[t];if(i!=null){for(let n of i)if(n.active){e.stopPropagation(),e.preventDefault(),n.action(n.identifier,null,t);break}}}}function pt(a,e,t,i=null){let n=window.PointerEvent?"pointer":"mouse";e==null&&(e=a);let r=c('<input type="text" class="jo_inplaceeditor" spellcheck="false">');r.css({width:e.css("width"),height:e.css("height"),color:e.css("color"),position:e.css("position"),"background-color":e.css("background-color"),"font-size":e.css("font-size"),"font-weight":e.css("font-weight"),"box-sizing":"border-box"}),r.val(a.text()),r.on(n+"down",o=>{o.stopPropagation()}),i!=null&&r[0].setSelectionRange(i.start,i.end),e.after(r),e.hide(),setTimeout(()=>{r.focus()},300),r.on("keydown.me",o=>{if(o.key=="Enter"||o.key=="Escape"){r.off("keydown.me"),r.off("focusout.me"),r.remove(),e.show();let l=Oe(r.val());t(l);return}}),r.on("focusout.me",o=>{r.off("keydown.me"),r.off("focusout.me"),r.remove(),e.show();let l=Oe(r.val());t(l)})}function R(a,e,t){let i=window.PointerEvent?"pointer":"mouse",n=c('<div class="jo_contextmenu"></div>'),r=null,o=null;for(let p of a){let b=p.caption;p.link!=null&&(b=`<a href="${p.link}" target="_blank" class="jo_menulink">${p.caption}</a>`);let k=c("<div>"+b+(p.subMenu!=null?'<span style="float: right"> &nbsp; &nbsp; &gt;</span>':"")+"</div>");if(p.color!=null&&k.css("color",p.color),p.link==null)k.on(i+"up.contextmenu",g=>{g.stopPropagation(),c(".jo_contextmenu").remove(),c(document).off(i+"up.contextmenu"),c(document).off(i+"down.contextmenu"),c(document).off("keydown.contextmenu"),p.callback()}),k.on(i+"down.contextmenu",g=>{g.stopPropagation()});else{let g=k.find("a");g.on(i+"up",w=>{w.stopPropagation(),setTimeout(()=>{k.hide()},500)}),g.on(i+"down",w=>{w.stopPropagation()})}k.on(i+"move.contextmenu",()=>{p!=o&&r!=null&&(r.remove(),o=null,r=null),p.subMenu!=null&&(r=R(p.subMenu,k.offset().left+k.width(),k.offset().top))}),n.append(k)}c(document).on(i+"down.contextmenu",p=>{c(document).off(i+"down.contextmenu"),c(document).off("keydown.contextmenu"),c(".jo_contextmenu").remove()}),c(document).on("keydown.contextmenu",p=>{p.key=="Escape"&&(c(document).off(i+"up.contextmenu"),c(document).off("keydown.contextmenu"),c(".jo_contextmenu").remove())});let l=e>window.innerWidth*.8?"right":"left",d=e>window.innerWidth*.8?window.innerWidth-e:e,u=t>window.innerHeight*.8?"bottom":"top",m=t>window.innerHeight*.8?window.innerHeight-t:t,f={};return f[l]=d+"px",f[u]=m+"px",n.css(f),c("body").append(n),n.show(),n}function Te(a){let e=a.find(".jo_tabheadings>div").not(".jo_noHeading"),t=a.find(".jo_tabs>div"),i=window.PointerEvent?"pointer":"mouse";e.on(i+"down",n=>{let r=c(n.target);e.removeClass("jo_active"),r.addClass("jo_active");let o=a.find("."+r.data("target"));t.removeClass("jo_active"),t.trigger("myhide"),o.addClass("jo_active"),o.trigger("myshow")})}function Y(a,e="",t="",i){let n="";e!=null&&e!=""&&(n+=` class="${e}"`);let r=c(`<div${n}></div>`);return t!=null&&t!=""&&r.text(t),r}var ve=!1;function mi(){matchMedia("(pointer:fine)").matches&&(ve=!0)}function et(a,e,t,i){let n="rgba("+t[0]+", "+t[1]+", "+t[2]+", ",r=1,o=r/(i/20),l=()=>{a.css(e,n+r+")"),r-=o,r<0?a.css(e,""):setTimeout(l,20)};l()}function ze(a,e,t=!1){var i=t?a:new Blob([typeof a=="string"?a:JSON.stringify(a)],{type:"text/plain"});if(window.navigator&&window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(i,e);else{var n=document.createEvent("MouseEvents"),r=document.createElement("a");r.download=e,r.href=window.URL.createObjectURL(i),r.dataset.downloadurl=["text/plain",r.download,r.href].join(":"),n.initEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),r.dispatchEvent(n),r.remove()}}function fi(a){var e=document.createElement("textarea");e.value=a,e.style.top="0",e.style.left="0",e.style.position="fixed",document.body.appendChild(e),e.focus(),e.select();try{var t=document.execCommand("copy")}catch(i){console.error("Fallback: Oops, unable to copy",i)}document.body.removeChild(e)}function gt(a){if(!navigator.clipboard){fi(a);return}navigator.clipboard.writeText(a).then(function(){},function(e){console.error("Async: Could not copy text: ",e)})}function pi(a){const e=new RegExp(`(^| )${a}=([^;]+)`),t=document.cookie.match(e);if(t)return t[2]}const P=class P{static registerPerformanceEntry(e,t){let i=P.performanceData.find(r=>r.url==e);i==null&&(i={count:0,sumTime:0,url:e},P.performanceData.push(i)),i.count++;let n=Math.round(performance.now()-t);i.sumTime+=n,P.performanceDataCount++}static sendDataToServer(){if(performance.now()-P.lastTimeSent>3*60*1e3){let e={data:P.performanceData};P.performanceData=[],P.performanceDataCount=0,P.lastTimeSent=performance.now(),S("collectPerformanceData",e,()=>{})}}};h(P,"performanceData",[]),h(P,"performanceDataCount",0),h(P,"lastTimeSent",performance.now());let Fe=P;var M="";function S(a,e,t,i){a.startsWith("http")||(a="servlet/"+a),$e(!0);let n=performance.now(),r={};M!=null&&(r={"x-token-pm":M}),c.ajax({type:"POST",async:!0,data:JSON.stringify(e),contentType:"application/json",headers:r,url:a,success:function(o){if(Fe.registerPerformanceEntry(a,n),o.csrfToken!=null&&(M=o.csrfToken),$e(!1),o.success!=null&&o.success==!1||typeof o=="string"&&o==""){let l="Fehler bei der Bearbeitung der Anfrage";o.message!=null&&(l=o.message),i&&i(l)}else t(o)},error:function(o,l){if($e(!1),i){let d="Server nicht erreichbar.";o.status!=0&&(d=""+o.status),i(l+": "+d);return}}})}function $e(a){a?c(".jo_network-busy").css("visibility","visible"):c(".jo_network-busy").css("visibility","hidden")}async function ge(a,e){let t=[["content-type","text/json"]];M!=null&&t.push(["x-token-pm",M]);try{let n=await(await fetch(a,{method:"POST",headers:t,body:JSON.stringify(e)})).json();return n.token!=null&&(M=n.token),n==null?alert("Fehler beim Übertragen der Daten."):n.success!=!0&&alert(`Fehler beim Übertragen der Daten:
15
- `+n.message),n}catch(i){return{status:"Error",message:"Es ist ein Fehler aufgetreten: "+i}}}class Ue{constructor(){h(this,"id");h(this,"name");h(this,"templateDump");h(this,"based_on_template_id");h(this,"templateName");h(this,"statements");h(this,"published_to");h(this,"version");h(this,"description");h(this,"owner_id")}static fromDatabaseData(e,t){let i=new Ue;return i.id=e.id,i.name=e.name,i.statements=e.statements,i.published_to=e.published_to,i.version=t,i.description=e.description,i.templateDump=null,i.based_on_template_id=e.based_on_template_id,i.owner_id=e.owner_id,i}}class gi{fetchTemplateFromCache(e,t){if(e==null){t(null);return}let i=this;this.cacheAvailable()||t(null),this.getCache(n=>{n.match(i.databaseIdToCacheIdentifier(e)).then(r=>{r.arrayBuffer().then(o=>t(new Uint8Array(o)))}).catch(()=>t(null))})}saveTemplateToCache(e,t){if(!this.cacheAvailable())return;let i=this;this.getCache(n=>{n.put(i.databaseIdToCacheIdentifier(e),new Response(t)).catch(r=>{console.warn("Konnte Template nicht im Cache speichern, Grund: "+r)})})}cacheAvailable(){return"caches"in self}getCache(e){caches.open("my-cache").then(e)}databaseIdToCacheIdentifier(e){return"/onlineIdeTemplateDb"+e}}class Le{uploadCurrentDatabase(e,t,i,n,r=()=>{}){t.waitOverlay.show("Bitte warten, lade Vorlage auf den Server hoch ..."),e>=0?t.getDatabaseTool().export(l=>{l=H.deflate(l),this.uploadIntern(l,e,n,t,r)},l=>{alert("Fehler beim Exportieren der Datenbank: "+l),t.waitOverlay.hide()}):this.uploadIntern(i,-1,n,t,r)}uploadIntern(e,t,i,n,r){let o={"x-workspaceid":""+t,"x-reason":i};return M!=null&&(o["x-token-pm"]=M),c.ajax({type:"POST",async:!0,contentType:"application/octet-stream",data:e,processData:!1,headers:o,url:"servlet/uploadTemplate",success:function(l){n.waitOverlay.hide(),r(l)},error:function(l,d){alert("message"),n.waitOverlay.hide()}}),e}}const X=class X{static isZipfile(e){return X.checkSignature(e,this.zipSignature)}static isSqLiteFile(e){return X.checkSignature(e,this.sqLiteSignature)}static checkSignature(e,t){if(e==null||e.byteLength<t.length)return!1;for(let i=0;i<t.length;i++)if(e[i]!=t[i])return!1;return!0}};h(X,"zipSignature",[120,156]),h(X,"sqLiteSignature",[83,81,76,105,116,101,32,102,111,114,109,97,116,32,51,0]);let Ce=X;class bt{constructor(e,t){h(this,"nextStrategy");this.name=e,this.manager=t}}class bi extends bt{constructor(t){super("long-polling strategy",t);h(this,"isClosed");h(this,"csrfToken");h(this,"shortestTimeoutMs",6e4);h(this,"timeOpened",null);h(this,"abortController");this.isClosed=!1}open(){this.isClosed=!1,this.abortController=new AbortController,this.timeOpened=performance.now();let t=[["content-type","text/json"]];t.push(["x-token-pm",M]),this.csrfToken=M,t.push(["x-timeout",this.shortestTimeoutMs+""]);try{fetch("/servlet/registerLongpollingListener",{signal:this.abortController.signal,method:"POST",headers:t,body:JSON.stringify({})}).then(i=>{if(i.status!=200){console.log(`Long-polling listener got http-status: ${i.status} (${i.statusText})`);let n=Math.round(performance.now()-this.timeOpened)-4e3;n<this.shortestTimeoutMs&&(this.shortestTimeoutMs=n)}switch(i.status){case 200:i.json().then(n=>{this.manager.onMessage(n)}),this.reopen();break;case 502:case 504:this.reopen(1e3,!1);break;default:this.reopen(1e4,!1);break}}).catch(i=>{console.log(`Long-polling listener failed due to reason: ${i}`),this.reopen(1e4,!1)}).finally(()=>{this.abortController=null})}catch{this.reopen(1e4,!1)}}reopen(t=500,i=!0){this.isClosed||(t>500&&console.log(`Reopen long-polling listener in ${t/1e3} seconds...`),setTimeout(()=>{this.isClosed||this.open()},t))}async close(){var i;this.isClosed=!0,(i=this.abortController)==null||i.abort();let t=[["content-type","text/json"]];t.push(["x-token-pm",this.csrfToken]),await fetch("/servlet/unregisterLongpollingListener",{method:"POST",headers:t,body:JSON.stringify({})})}}class wi extends bt{constructor(t){super("websocket strategy",t);h(this,"csrfToken");h(this,"websocket");h(this,"isClosed");h(this,"openedTimestamp");h(this,"currentTimer")}open(){this.isClosed=!1;try{let t=(window.location.protocol.startsWith("https")?"wss://":"ws://")+window.location.host+"/servlet/pushWebsocket?csrfToken="+M;this.websocket=new WebSocket(t),this.websocket.onopen=i=>{this.openedTimestamp=performance.now()},this.websocket.onclose=i=>{console.log("Websocket has been closed, code: "+i.code+", reason: "+i.reason),this.isClosed=!0,i.code==1001&&performance.now()-this.openedTimestamp>1e4?(console.log("Reason was timeout, dt > 10s => Reopen!"),this.open()):(this.manager.onStrategyFailed(this),this.isClosed=!0)},this.websocket.onerror=i=>{console.log("Error on websocket, type: "+i.type),this.websocket.close(),this.manager.onStrategyFailed(this),this.isClosed=!0},this.websocket.onmessage=i=>{if(i.data=="pong")return;const n=JSON.parse(i.data);this.manager.onMessage(n)},this.currentTimer!=null&&clearTimeout(this.currentTimer),this.doPing()}catch{this.manager.onStrategyFailed(this),this.isClosed=!0}}doPing(){this.currentTimer=setTimeout(()=>{this.isClosed?this.currentTimer=null:(this.websocket.send("ping"),this.doPing())},25e3)}async close(){this.isClosed=!0,this.websocket.close()}}class ki{constructor(e){h(this,"strategies",[]);h(this,"currentStrategy");h(this,"eventTypeToSubscriberInfoMap",new Map);this.baseURL=e,this.strategies=[new wi(this),new bi(this)];for(let t=this.strategies.length-2;t>=0;t--)this.strategies[t].nextStrategy=this.strategies[t+1]}subscribe(e,t){this.eventTypeToSubscriberInfoMap.set(e,{eventType:e,handler:t})}unsubscribe(e){this.eventTypeToSubscriberInfoMap.delete(e)}open(){this.currentStrategy==null&&(this.currentStrategy=this.strategies[0],console.log(`Opening ${this.currentStrategy.name}`),this.currentStrategy.open())}onMessage(e){var t;for(let i of e){if(i.eventType=="keepAlive")return;(t=this.eventTypeToSubscriberInfoMap.get(i.eventType))==null||t.handler(i.data)}}onStrategyFailed(e){if(e!=this.currentStrategy)return;let t=this.currentStrategy;this.currentStrategy=this.currentStrategy.nextStrategy;let i=`${t.name} failed. `;this.currentStrategy!=null?(i+=`=> Trying ${this.currentStrategy.name} in 3 seconds...`,setTimeout(()=>{console.log(`Opening ${this.currentStrategy.name}`),this.currentStrategy.open()},3e3)):i+="It was the last resort, unfortunately this client has no means to receive push-messages from server.",console.log(i)}close(){this.currentStrategy!=null&&(this.currentStrategy.close(),this.currentStrategy=null)}}const F=class F extends ki{static subscribe(e,t){F.getInstance().subscribe(e,t)}static unsubscribe(e){F.getInstance().unsubscribe(e)}static getInstance(){return F.instance==null&&(F.instance=new F("")),F.instance}};h(F,"instance");let N=F;class vi{constructor(e,t){h(this,"timerhandle");h(this,"ownUpdateFrequencyInSeconds",20);h(this,"teacherUpdateFrequencyInSeconds",5);h(this,"updateFrequencyInSeconds",20);h(this,"forcedUpdateEvery",4);h(this,"counterTillForcedUpdate",2);h(this,"secondsTillNextUpdate",this.updateFrequencyInSeconds);h(this,"errorHappened",!1);h(this,"interval");this.main=e,this.$updateTimerDiv=t}initializeTimer(){let e=this;this.$updateTimerDiv.find("svg").attr("width",e.updateFrequencyInSeconds),this.interval!=null&&clearInterval(this.interval),this.interval=setInterval(()=>{if(e.main.user==null)return;if(e.secondsTillNextUpdate--,e.secondsTillNextUpdate<0){e.secondsTillNextUpdate=e.updateFrequencyInSeconds,this.counterTillForcedUpdate--;let i=this.counterTillForcedUpdate==0;i&&(this.counterTillForcedUpdate=this.forcedUpdateEvery),e.sendUpdates(()=>{},i)}let t=this.$updateTimerDiv.find(".jo_updateTimerRect");t.attr("width",e.secondsTillNextUpdate+"px"),e.errorHappened?(t.css("fill","#c00000"),this.$updateTimerDiv.attr("title","Fehler beim letzten Speichervorgang -> Werd's wieder versuchen")):(t.css("fill","#008000"),this.$updateTimerDiv.attr("title",e.secondsTillNextUpdate+" Sekunden bis zum nächsten Speichern"))},1e3)}sendUpdates(e,t=!1){var l;if(this.main.user==null)return;this.main.projectExplorer.writeEditorTextToFile(),this.main.userDataDirty&&(this.main.userDataDirty=!1,this.sendUpdateUserSettings(()=>{}));let i=[],n=[];for(let d of this.main.workspaceList){d.saved||(i.push(d.getWorkspaceData(!1)),d.saved=!0);for(let u of d.moduleStore.getModules(!1))u.file.saved||(u.file.text=u.getProgramTextFromMonacoModel(),n.push(u.getFileData(d)),u.file.saved=!0)}let r={workspacesWithoutFiles:i,files:n,owner_id:this.main.workspacesOwnerId,userId:this.main.user.id,language:1,currentWorkspaceId:(l=this.main.getCurrentWorkspace())==null?void 0:l.id,getModifiedWorkspaces:!1},o=this;if(i.length>0||n.length>0||t)S("sendUpdates",r,d=>{if(o.errorHappened=!d.success,!o.errorHappened&&(o.updateWorkspaces(r,d),e!=null)){e();return}},()=>{o.errorHappened=!0});else if(e!=null){e();return}}initializeSSE(){N.subscribe("doFileUpdate",e=>{let t=this.main.workspaceList.slice();this.sendUpdates(()=>{let i=this.main.workspaceList.filter(n=>t.indexOf(n)<0).map(n=>n.name).join(", ");alert(`Deine Lehrkraft hat Dir folgende Datenbank übermittelt: ${i}`)},!0)})}sendCreateWorkspace(e,t,i){if(this.main.user.is_testuser){e.id=Math.round(Math.random()*1e7),i(null);return}let n={type:"create",entity:"workspace",data:e,owner_id:t,userId:this.main.user.id};S("createOrDeleteFileOrWorkspace",n,r=>{e.id=r.id,i(null)},i)}getDatabaseSettings(e,t){S("getDatabaseSettings",{workspaceId:e},n=>{t(n)},n=>{alert(n)})}setNewSecret(e,t,i){S("setNewSecret",{workspaceId:e,secretKind:t},r=>{i(r.secret)},r=>{alert(r)})}setNameAndPublishedTo(e,t,i,n,r){S("setPublishedTo",{workspaceId:e,databaseName:t,publishedTo:i,description:n},l=>{r()},l=>{alert(l)})}sendCreateFile(e,t,i,n){let o={type:"create",entity:"file",data:e.getFileData(t),owner_id:i,userId:this.main.user.id};S("createOrDeleteFileOrWorkspace",o,l=>{e.file.id=l.id,n(null)},n)}sendDuplicateWorkspace(e,t){let i={workspace_id:e.id,language:1};S("duplicateWorkspace",i,n=>{t(n.message,n.workspace)},t)}sendDistributeWorkspace(e,t,i,n){let r=()=>{new Le().uploadCurrentDatabase(e.id,this.main,null,"distributeWorkspace",o=>{this.sendUpdates(()=>{let l={workspace_id:e.id,database_as_template_id:o.newTemplateId,class_id:t==null?void 0:t.id,student_ids:i};S("distributeWorkspace",l,d=>{n(d.message)},n)},!1)})};this.main.projectExplorer.setWorkspaceActive(e,r)}sendDeleteWorkspaceOrFile(e,t,i){let n={type:"delete",entity:e,id:t,userId:this.main.user.id};S("createOrDeleteFileOrWorkspace",n,r=>{r.success?i(null):i("Netzwerkfehler!")},i)}sendUpdateUserSettings(e){var i;let t={settings:this.main.user.settings,userId:this.main.user.id,current_workspace_id:(i=this.main.getCurrentWorkspace())==null?void 0:i.id};S("updateUserSettings",t,n=>{n.success?e(null):e("Netzwerkfehler!")},e)}getNewStatements(e,t){let i={workspaceId:e.id,version_before:e.database.version};S("getNewStatements",i,n=>{n.success&&t(n.newStatements,n.firstNewStatementIndex)})}AddDatabaseStatements(e,t,i){let n={workspaceId:e.id,version_before:e.database.version,statements:t};S("addDatabaseStatements",n,r=>{r.success&&i(r.statements_before,r.new_version)})}fetchDatabase(e,t){let i=new gi,n={workspaceId:e.id};S("getDatabase",n,r=>{if(r.success){if(e.database=Ue.fromDatabaseData(r.database,r.version),e.databaseId=e.database.id,e.database.based_on_template_id==null){t(null);return}i.fetchTemplateFromCache(e.database.based_on_template_id,o=>{if(Ce.isZipfile(o))try{e.database.templateDump=H.inflate(o)}catch(l){console.log(l),console.log("Dump seems not to be compressed..."),e.database.templateDump=o}else e.database.templateDump=o;if(Ce.isSqLiteFile(e.database.templateDump)){t(null);return}else this.fetchTemplate(e.id,(l,d)=>{if(l!=null){i.saveTemplateToCache(e.database.based_on_template_id,l),e.database.templateDump=H.inflate(l),t(null);return}else{e.database.templateDump=null,t(d);return}})})}else t("Netzwerkfehler!")},r=>{t("Netzwerkfehler: "+r)})}fetchTemplate(e,t){let i={workspaceId:e},n={};M!=null&&(n={"x-token-pm":M}),c.ajax({type:"POST",async:!0,data:JSON.stringify(i),contentType:"application/json",url:"servlet/getTemplate",headers:n,xhrFields:{responseType:"arraybuffer"},success:function(r){t(new Uint8Array(r))},error:function(r,o){t(null,"Konnte das Template nicht laden.")}})}fetchTemplateList(e){let t={user_id:this.main.user.id};S("getTemplateList",t,i=>{i.success?e(i.templateList):e([])},i=>{alert(i),e([])})}updateWorkspaces(e,t){let i=new Map,n=[];e.files.forEach(o=>n.push(o.id)),t.workspaces.workspaces.forEach(o=>i.set(o.id,o));let r=[];for(let o of t.workspaces.workspaces)this.main.workspaceList.filter(d=>d.id==o.id).length==0&&(r.push(o.name),this.createNewWorkspaceFromWorkspaceData(o));for(let o of this.main.workspaceList){let l=i.get(o.id);if(l!=null){let d=new Map;l.files.forEach(m=>d.set(m.id,m));let u=new Map;for(let m of o.moduleStore.getModules(!1)){let f=m.file.id;u.set(f,m);let p=d.get(f);p==null?(this.main.projectExplorer.fileListPanel.removeElement(m),this.main.currentWorkspace.moduleStore.removeModule(m)):p.version>m.file.version&&((n.indexOf(f)<0||p.forceUpdate)&&(m.file.text=p.text,m.model.setValue(p.text),m.file.saved=!0,m.lastSavedVersionId=m.model.getAlternativeVersionId()),m.file.version=p.version)}for(let m of l.files)u.get(m.id)==null&&this.createFile(o,m)}}this.main.projectExplorer.workspaceListPanel.sortElements(),this.main.projectExplorer.fileListPanel.sortElements()}createNewWorkspaceFromWorkspaceData(e,t=!1){let i=this.main.createNewWorkspace(e.name,e.owner_id);i.id=e.id,i.sql_history="",i.path=e.path,i.isFolder=e.isFolder,this.main.workspaceList.push(i);let n=e.path.split("/");n.length==1&&n[0]==""&&(n=[]);let r={name:e.name,externalElement:i,iconClass:"workspace",isFolder:e.isFolder,path:n};this.main.projectExplorer.workspaceListPanel.addElement(r,!0),i.panelElement=r;for(let o of e.files)this.createFile(i,o);t&&(this.main.projectExplorer.workspaceListPanel.sortElements(),this.main.projectExplorer.fileListPanel.sortElements())}createFile(e,t){let i=null;e==this.main.currentWorkspace&&(i={name:t.name,externalElement:null},this.main.projectExplorer.fileListPanel.addElement(i,!0));let n={id:t.id,name:t.name,dirty:!1,saved:!0,text:t.text,version:t.version,identical_to_repository_version:!0,workspace_id:e.id,panelElement:i},r=this.main.projectExplorer.getNewModule(n);i!=null&&(i.externalElement=r),e.moduleStore.putModule(r)}rollback(e){let t=this.main.currentWorkspace,i={workspaceId:t.id,version:t.database.version};S("rollback",i,n=>{n.success?e(null,t.database.version>n.new_version):(alert(n.message),e(n.message,!1))},n=>{alert(n),e(n,!1)})}}const yi=""+new URL("assets/sqljsWorker-CGIvyKli.js",import.meta.url).href;function be(a,e){const t=new a.Database(e);return t.create_function("isDate",function(i){if(i==null)return!0;if(typeof i!="string")return!1;var n=/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/;if(i.match(n)){var r=i.split("/"),o=i.split("-"),l=r.length,d=o.length;if(l>1)var u=i.split("/");else if(d>1)var u=i.split("-");if(u.length!=3)return!1;var m=parseInt(u[2]),f=parseInt(u[1]),p=parseInt(u[0]),b=[31,28,31,30,31,30,31,31,30,31,30,31];if((f==1||f>2)&&m>b[f-1])return!1;if(f==2){var k=!1;return(!(p%4)&&p%100||!(p%400))&&(k=!0),!(k==!1&&m>=29||k==!0&&m>29)}return!0}else return!1}),t.create_function("isDateTime",function(i){if(i==null)return!0;if(typeof i!="string")return!1;var n=/^\d{4}[\-](0[1-9]|1[012])[\-](0[1-9]|[12][0-9]|3[01]) ([01][1-9]|2[0123]):([0-5][0-9]):([0-5][0-9])$/;if(i.match(n)){var r=i.split(" "),o=r[0];if(o.length!=10)return!1;var l=parseInt(o.substring(8,10)),d=parseInt(o.substring(5,7)),u=parseInt(o.substring(0,4)),m=[31,28,31,30,31,30,31,31,30,31,30,31];if((d==1||d>2)&&l>m[d-1])return!1;if(d==2){var f=!1;return(!(u%4)&&u%100||!(u%400))&&(f=!0),!(f==!1&&l>=29||f==!0&&l>29)}return!0}else return!1}),t.create_function("month",function(i){var n=/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/;let r=i.match(n);return r?Number(r[1]):-1}),t.create_function("day",function(i){var n=/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/;let r=i.match(n);return r?Number(r[2]):-1}),t.create_function("year",function(i){var n=/^(\d{4})[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/;let r=i.match(n);return r?Number(r[1]):-1}),t.create_function("isTime",function(i){if(i==null)return!0;if(typeof i!="string")return!1;var n=/^([01][0-9]|2[0123]):([0-5][0-9]):([0-5][0-9])$/;return i.match(n)!=null}),t.create_function("concat",function(i){if(arguments==null)return"";let n="";for(let r=0;r<arguments.length;r++)n+=""+arguments[r];return n}),t}const Ci={},xi=Object.freeze(Object.defineProperty({__proto__:null,default:Ci},Symbol.toStringTag,{value:"Module"})),kn=ci(xi);class Si{constructor(){h(this,"initsql",Ot({locateFile:(e,t)=>At}));h(this,"db");h(this,"SQL");h(this,"onmessage");h(this,"onError")}postMessageToClient(e){this.onmessage({data:e})}postMessage(e){let t=this;t.db==null?t.initsql.then(i=>{t.SQL=i,t.db=be(i,void 0),t.worker(e)}).catch(i=>(console.log(i),t.postMessageToClient({id:this.data.id,error:i.message}))):t.worker(e)}terminate(){}worker(e){var t,i,n=e.config?e.config:{};try{switch(e&&e.action){case"open":return t=e.buffer,this.db=be(this.SQL,t&&new Uint8Array(t)),this.postMessageToClient({id:e.id,ready:!0});case"exec":if(this.db===null&&(this.db=be(this.SQL,void 0)),!e.sql)throw"exec: Missing query string";return this.postMessageToClient({id:e.id,results:this.db.exec(e.sql,e.params,n)});case"each":this.db===null&&(this.db=be(this.SQL,void 0));var r=function(d){return this.postMessage({id:e.id,row:d,finished:!1})},o=function(){return this.postMessage({id:e.id,finished:!0})};return this.db.each(e.sql,e.params,r,o,n);case"export":t=this.db.export(),i={id:e.id,results:[{buffer:t}]};try{return this.postMessageToClient(i)}catch{return this.postMessageToClient(i)}case"close":return this.db&&this.db.close(),this.postMessageToClient({id:e.id});default:throw new Error("Invalid action : "+(e&&e.action))}}catch(l){return this.postMessageToClient({id:e.id,error:l.message})}}}class W{constructor(e){h(this,"databaseDirectoryEntries",null);h(this,"worker");h(this,"queryId",0);h(this,"querySuccessCallbacksMap",new Map);h(this,"queryErrorCallbackMap",new Map);h(this,"databaseStructure");this.main=e}initializeWorker(e,t,i,n){this.main.getWaitOverlay().show("Bitte warten, die Datenbank wird initialisiert..."),this.worker!=null&&this.worker.terminate(),performance.now(),window.jo_doc?this.worker=new Si:(this.worker=new Worker(new URL(""+new URL("assets/sqljsWorker-CGIvyKli.js",import.meta.url).href,import.meta.url),{type:"module"}),this.worker=new Worker(yi,{type:"module"}));let r=this,o=[];this.worker.onmessage=()=>{r.worker.onmessage=u=>{let m=u.data.id;if(u.data.error==null){let f=r.querySuccessCallbacksMap.get(m);f!=null&&f(u.data.results)}else{let f=r.queryErrorCallbackMap.get(m);f!=null&&f(u.data.error)}this.queryErrorCallbackMap.delete(m),this.querySuccessCallbacksMap.delete(m)},t==null&&(t=[]),t=t.slice(),t.unshift("PRAGMA foreign_keys = OFF;"),t.push("PRAGMA foreign_keys = ON;");let l=t.length,d=()=>{if(t.length>0){this.main.getWaitOverlay().setProgress(`${Math.round((1-t.length/l)*100)+" %"}`);let u=t.shift();r.executeQuery(u,m=>{d()},m=>{o.push("Error while setting up database: "+m+", query: "+u),console.log({error:"Error while setting up database: "+m,query:u}),console.log(),d()})}else i!=null&&i(o),r.retrieveDatabaseStructure(()=>{n&&n(),this.main.getWaitOverlay().hide()})};d()},this.worker.onerror=l=>{o.push("Worker error: "+l.error),console.log("Worker error: "+l.error)},this.worker.postMessage({id:r.queryId++,action:"open",buffer:e})}executeQuery(e,t,i){let n=this.queryId++;this.querySuccessCallbacksMap.set(n,t),this.queryErrorCallbackMap.set(n,i),this.worker.postMessage({id:n,action:"exec",sql:e,params:{}})}export(e,t){let i=this.queryId++;this.querySuccessCallbacksMap.set(i,n=>{e(n[0].buffer)}),this.queryErrorCallbackMap.set(i,t),this.worker.postMessage({id:i,action:"export",params:{}})}getDirectoryEntries(e){this.databaseDirectoryEntries!=null?e(this.databaseDirectoryEntries):c.getJSON("assets/databases/directory.json",function(t){e(t)})}retrieveDatabaseStructure(e){let t="SELECT name, sql, type FROM sqlite_master WHERE type='table' or type='view';",i=this;this.executeQuery(t,n=>{var d;let r="",o=(d=n[0])==null?void 0:d.values,l=o==null?void 0:o.map(u=>u[2]);o==null||o.forEach(u=>r+=`PRAGMA table_info("${u[0]}");
13
+ `],1),!this.expect(s.keywordSet)))return t;let i=!0;do{if(this.addCompletionHintHere(t.tableIdentifier,!1,i?[]:["where"],1,null," = "),i=!1,this.tt!=s.identifier){this.pushError("Hier wird der Bezeichner derjenigen Spalte der Tabelle "+t.tableIdentifier+" erwaretet, deren Wert verändert werden soll.","error");break}t.columnIdentifiers.push(this.cct.value),t.columnIdentifierPositions.push(this.getCurrentPosition()),this.nextToken(),this.expect(s.equal,!0),t.valuePosBegin.push(this.getCurrentPosition()),t.values.push(this.parseTerm()),t.valuePosEnd.push(this.getCurrentPosition())}while(this.comesToken(s.comma,!0));if(t.endPosition=this.getCurrentPosition(),this.lastToken.tt!=s.comma||this.comesToken(s.keywordWhere)){if(!this.expect(s.keywordWhere,!0))return t;t.whereNodeBegin=this.getEndOfPosition(this.lastToken.position),t.whereNode=this.parseTerm(),t.whereNodeEnd=this.getCurrentPosition(),this.module.addCompletionHint(t.whereNodeBegin,t.whereNodeEnd,t.tableIdentifier,!1,[]),t.endPosition=this.getCurrentPosition()}else this.comesToken(s.keywordWhere,!0);return t}parseCreateTableOrDatabaseOrView(){switch(this.ct[1].tt){case s.keywordDatabase:return this.parseCreateDatabase();case s.keywordTable:return this.parseCreateTable();case s.keywordView:return this.parseCreateView();case s.keywordSchema:default:return this.nextToken(),this.pushError("Nach 'create' wird 'table' erwartet."),this.nextToken(),null}}parseCreateDatabase(){let e={type:s.omittedeStatement,position:this.getCurrentPosition(),endPosition:null,symbolTable:null};for(this.nextToken(),this.pushError("Die CREATE-DATABASE-Anweisung wird von der SQLite-Engine nicht unterstützt. Sie können eine neue Datenbank anlegen, indem Sie auf den entsprechenden Button oberhalb der Liste der Datenbanken (linke Seite des Fensters) klicken. Diese Anweisung wird überlesen.","info");this.tt!=s.semicolon&&this.tt!=s.endofSourcecode;)e.endPosition=this.getEndOfCurrentToken(),this.nextToken();return e}parseCreateView(){let e=this.getCurrentPosition();this.nextToken(),this.nextToken();let t=!1;this.comesToken(s.keywordIf)&&(this.nextToken(),this.expect(s.keywordNot,!0),this.expect(s.keywordExists,!0),t=!0);let i="";if(!this.expect(s.identifier,!1))return null;i=this.cct.value,this.nextToken();let n=[];if(this.comesToken(s.leftBracket,!0)){do this.expect(s.identifier,!1)&&n.push(this.cct.value),this.nextToken();while(this.comesToken(s.comma,!0));this.expect(s.rightBracket,!0)}if(!this.expect(s.keywordAs,!0))return this.module.addCompletionHint(this.getCurrentPosition(),this.getCurrentPositionPlus(2),!1,!1,["as"]),null;if(!this.expect(s.keywordSelect,!1))return this.module.addCompletionHint(this.getCurrentPosition(),this.getCurrentPositionPlus(2),!1,!1,["select"]),null;let r=this.parseSelect();return{type:s.keywordView,identifier:i,position:e,endPosition:this.getCurrentPosition(),symbolTable:null,ifNotExists:t,columnIdentifierList:n,selectStatement:r}}parseCreateTable(){let e=this.getCurrentPosition();this.nextToken(),this.expect(s.keywordTable,!0)||this.module.addCompletionHint(e,this.getCurrentPositionPlus(3),!1,!1,["table"]);let t=!1;this.comesToken(s.keywordIf)&&(this.nextToken(),this.expect(s.keywordNot,!0),this.expect(s.keywordExists,!0),t=!0);let i="";if(this.expect(s.identifier,!1)){i=this.cct.value;let l=this.getCurrentPosition(),d=this.getCurrentPositionPlus(i.length+3);this.nextToken(),this.comesToken(s.leftBracket)||this.module.addCompletionHint(l,d,!1,!1,["("])}let n={type:s.keywordCreate,identifier:i,position:e,endPosition:null,columnList:[],symbolTable:null,combinedPrimaryKeyColumns:[],foreignKeyInfoList:[],ifNotExists:t,uniqueConstraints:[]};if(!this.expect(s.leftBracket,!0))return n;let r=!1,o=!0;for(;this.tt!=s.rightBracket;){switch(o||this.expect(s.comma,!0),o=!1,this.comesToken(s.keywordConstraint,!0)&&(this.expect(s.identifier,!0),this.expect([s.keywordForeign,s.keywordPrimary,s.keywordUnique],!1)),this.tt){case s.keywordPrimary:r&&this.pushError("Je Tabelle darf nur ein einziger Primärschlüssel definiert werden.","error",this.getCurrentPosition()),this.parsePrimaryKeyTerm(r,n),r=!0;break;case s.keywordKey:this.nextToken(),this.comesToken(s.identifier,!0),this.comesToken(s.leftBracket,!0),this.comesToken(s.identifier,!0),this.comesToken(s.rightBracket,!0);break;case s.keywordUnique:this.parseUniqueTerm(n);break;case s.keywordForeign:let l=this.parseForeignKeyDefinition();l!=null&&n.foreignKeyInfoList.push(l);break;case s.identifier:let d=this.parseColumnDefinition(r);n.columnList.push(d),r=r||d.isPrimary;break;default:this.pushError(_[this.tt]+" wird hier nicht erwartet.","error");break}if(!this.comesToken(s.comma))break}for(this.expect(s.rightBracket,!0);[s.keywordAutoincrement,s.keywordEngine,s.keywordDefault,s.keywordCollate].indexOf(this.tt)>=0;)switch(this.tt){case s.keywordCollate:this.nextToken(),this.skip(s.equal),this.expect(s.identifier,!0);break;case s.keywordEngine:this.nextToken(),this.skip(s.equal),this.expect(s.identifier,!0);break;case s.keywordDefault:this.nextToken(),this.expect([s.keywordCharset,s.keywordCharacter],!0),this.skip(s.keywordSet),this.skip(s.equal),this.expect(s.identifier,!0);break;case s.keywordAutoincrement:this.nextToken(),this.expect(s.equal,!0),this.expect(s.integerConstant,!0);break}for(let l of n.columnList)l.isAutoIncrement&&!(l.isPrimary||n.combinedPrimaryKeyColumns.indexOf(l.identifier)>=0)&&this.pushError("autoincrement gibt es nur bei Primärschlüsseln, d.h. es fehlt wahrscheinlich 'primary key'.","warning",n.position);return n.endPosition=this.getCurrentPosition(),n}parsePrimaryKeyTerm(e,t){e&&this.pushError("Die Tabelle kann nur einen einzigen Primärschlüssel haben."),this.nextToken(),this.expect(s.keywordKey,!0);let i=t.columnList.map(n=>n.identifier);if(this.addCompletionHintHere(!1,!1,i),this.comesToken(s.leftBracket)){for(this.addCompletionHintHere(!1,!1,i),this.nextToken();;)if(this.comesToken(s.identifier))if(t.combinedPrimaryKeyColumns.push(this.cct.value),this.nextToken(),this.addCompletionHintHere(!1,!1,i,1),this.comesToken(s.comma))this.nextToken(),this.addCompletionHintHere(!1,!1,i);else break;else{this.pushError("Der Bezeichner einer Spalte wird erwartet. Gefunden wurde: "+this.cct.value);break}this.expect(s.rightBracket,!0)}else this.pushError("( erwartet.")}parseUniqueTerm(e){this.nextToken();let t=e.columnList.map(n=>n.identifier),i=[];if(e.uniqueConstraints.push(i),this.addCompletionHintHere(!1,!1,t),this.comesToken(s.leftBracket)){for(this.addCompletionHintHere(!1,!1,t),this.nextToken();;)if(this.comesToken(s.identifier))if(i.push(this.cct.value),this.nextToken(),this.addCompletionHintHere(!1,!1,t,1),this.comesToken(s.comma))this.nextToken(),this.addCompletionHintHere(!1,!1,t);else break;else{this.pushError("Der Bezeichner einer Spalte wird erwartet. Gefunden wurde: "+this.cct.value);break}this.expect(s.rightBracket,!0)}else this.pushError("( erwartet.")}parseColumnDefinition(e){let t=this.getCurrentPosition(),i=this.cct.value;this.nextToken();let n={type:s.columnDef,identifier:i,isPrimary:!1,isAutoIncrement:!1,position:t,baseType:null,notNull:!1};return this.parseType(n,e),n}addCompletionHintHere(e,t,i,n=0,r="",o=""){let l=this.lastToken.position,d=this.getCurrentPosition();d.column+=1+n,this.module.addCompletionHint(this.getEndOfPosition(l),d,e,t,i,null,r,o)}parseType(e,t){let i=v.baseTypes.map(o=>o.toString());if(this.addCompletionHintHere(!1,!1,i),!this.expect([s.identifier,s.keywordEnum],!1)){this.pushError("Erwartet wird ein Datentyp. Gefunden wurde: "+this.cct.value);return}let n;if(this.cct.tt==s.keywordEnum){if(this.nextToken(),this.expect(s.leftBracket,!0)){let o=[];for(;!this.comesToken(s.rightBracket,!0)&&!this.isEnd();){let l=this.parseConstant();l!=null&&o.push(l),this.comesToken(s.comma)&&this.nextToken()}if(o.length>0)switch(o[0].constantType){case s.integerConstant:case s.floatingPointConstant:n=new ce(o.map(l=>l.constant));break;default:n=new me(o.map(l=>""+l.constant));break}else n=new me([]);e.baseType=n}}else{let o=this.cct.value,l=this.getCurrentPosition(),d=this.identifierMap[o.toLocaleLowerCase()];if(d!=null&&(o=d),n=v.getBaseType(o),n==null&&this.pushError("Erwartet wird ein Datentyp. Gefunden wurde: "+o),e.baseType=n,this.nextToken(),this.tt==s.leftBracket){for(this.nextToken(),e.parameters=[];this.tt==s.integerConstant&&(e.parameters.push(this.cct.value),this.nextToken(),this.tt==s.comma);)if(this.nextToken(),this.tt!=s.integerConstant){this.pushError("Erwartet wird eine ganze Zahl, gefunden wurde: "+this.cct.value);break}n!=null&&e.parameters.length>n.parameterDescriptions.length&&this.pushError("Der Datentyp "+n.toString()+" hat höchstens "+n.parameterDescriptions.length+" Parameter."),this.expect(s.rightBracket,!0)}if(o!=null&&e.parameters==null)switch(o.toLocaleLowerCase()){case"char":e.parameters=[1];break;case"varchar":e.parameters=[1],this.pushError("Hinter dem Datentyp varchar wird zwingend eine Längenangabe in Klammern erwaretet, also z.B. varchar(30)","error",l);break}}this.tt!=s.comma&&this.addCompletionHintHere(!1,!1,["primary key","references","not null"]);let r=[];for(;[s.keywordOn,s.keywordCharacter,s.keywordComment,s.keywordAutoincrement,s.keywordKey,s.keywordPrimary,s.keywordNot,s.keywordReferences,s.keywordCollate,s.keywordDefault].indexOf(this.tt)>=0;)switch(r.indexOf(this.tt)>=0&&this.pushError("Das Schlüsselwort "+_[this.tt]+" darf bei der Definition einer Spalte nicht öfters als ein Mal vorkommen."),r.push(this.tt),this.tt){case s.keywordAutoincrement:this.nextToken(),e.isAutoIncrement=!0,this.tt==s.equal?(this.nextToken(),this.expect(s.integerConstant)):this.tt==s.comma&&this.ct[1].tt==s.keywordAutoincrement&&this.nextToken();break;case s.keywordPrimary:t&&this.pushError("In einer Tabelle darf es nur einen einzigen primary key geben."),this.nextToken(),this.expect(s.keywordKey,!0)?this.comesToken(s.comma)||this.addCompletionHintHere(!1,!1,[`autoincrement,
14
+ `]):this.addCompletionHintHere(!1,!1,["key"]),e.isPrimary=!0;break;case s.keywordReferences:let o={column:e.identifier,referencesColumn:"",referencesTable:"",referencesPosition:this.getCurrentPosition()};e.foreignKeyInfo=o,this.parseReferences(o);break;case s.keywordNot:this.nextToken(),this.expect(s.keywordNull,!0)?this.addCompletionHintHere(!1,!1,["references"]):this.addCompletionHintHere(!1,!1,["null"]),e.notNull=!0;break;case s.keywordCollate:this.nextToken(),e.collate=this.cct.value,this.expect(s.identifier,!0);break;case s.keywordCharacter:this.nextToken(),this.expect(s.keywordSet,!0),this.expect(s.identifier,!0);break;case s.keywordDefault:if(this.nextToken(),this.ct[1].tt==s.leftBracket&&this.ct[2].tt==s.rightBracket){this.nextToken(),this.nextToken(),this.nextToken();break}if(e.defaultValue=this.cct.value,typeof this.cct.value=="string"&&e.defaultValue.toLowerCase()!="null"&&(e.defaultValue="'"+e.defaultValue+"'"),this.tt==s.keywordNull){this.nextToken();break}else[s.identifier,s.integerConstant,s.floatingPointConstant,s.stringConstant].indexOf(this.tt)>=0&&(v.fromConstantType(this.tt).canCastTo(n)||this.pushError("Die Konstante hinter 'default' passt nicht zum Datentyp der Spalte."),this.nextToken());break;case s.keywordComment:this.nextToken(),this.expect(s.stringConstant,!0);break;case s.keywordOn:for(this.nextToken(),this.expect([s.keywordUpdate],!0);!this.comesToken([s.comma,s.endofSourcecode,s.rightBracket]);)this.nextToken();this.lastToken.tt==s.leftBracket&&this.tt==s.rightBracket&&this.nextToken();break}}parseInsert(){let e=this.getCurrentPosition(),t=e;this.nextToken(),this.expect(s.keywordInto,!0);let i={type:s.keywordInsert,position:e,endPosition:this.getCurrentPosition(),valuesPosition:null,columnsPosition:null,symbolTable:null,columnList:[],values:[],table:null};if(this.tt==s.identifier?(i.table={type:s.table,identifier:this.cct.value,alias:null,position:this.getCurrentPosition()},i.columnsPosition={line:i.table.position.line,column:i.table.position.column+i.table.position.length,length:0},this.nextToken()):this.pushError("Hier wird der Bezeichner einer Tabelle erwartet. Gefunden wurde: "+this.cct.value,"error"),this.tt==s.leftBracket){this.nextToken();let n=!0;for(;n||this.tt==s.comma;)n||this.nextToken(),n=!1,this.tt==s.identifier?i.columnList.push({type:s.identifier,identifier:this.cct.value+"",position:this.getCurrentPosition()}):this.pushError("Erwartet wird der Bezeichner einer Spalte. Gefunden wurde: "+this.cct.value,"error"),this.nextToken();t=this.getCurrentPosition(),this.expect(s.rightBracket,!0)}switch(i.valuesPosition=this.getCurrentPosition(),this.tt){case s.keywordValues:this.nextToken(),this.parseValueLists(i.values);break;case s.keywordSelect:case s.leftBracket:if(this.getCurrentPosition().line<=t.line+1){let n=this.parseSelect();i.select=n}break}return i.endPosition=this.getCurrentPosition(),i}parseValueLists(e){let t=[s.keywordNull,s.charConstant,s.stringConstant,s.booleanConstant,s.floatingPointConstant,s.integerConstant],i=!0;for(;i||this.tt==s.comma;){i||this.nextToken(),i=!1;let n=this.getCurrentPosition();if(!this.expect(s.leftBracket,!0))break;let r=[],o=!0;for(;o||this.tt==s.comma;){if(o||this.nextToken(),o=!1,this.tt==s.identifier)if(this.cct.isDoubleQuotedIdentifier)this.tt=s.stringConstant;else{let l=(this.cct.value+"").toLocaleLowerCase();["date","_binary"].indexOf(l)>=0&&this.nextToken()}t.indexOf(this.tt)<0?(this.pushError("Erwartet wird eine Konstante oder null. Gefunden wurde: "+this.cct.value,"error"),this.nextToken()):(r.push({constantType:this.tt,position:this.getCurrentPosition(),constant:this.cct.value,type:s.constantNode}),this.nextToken())}this.expect(s.rightBracket,!0),r.length==0?this.pushError("Eine Zeile kann nur dann in die Tabelle eingefügt werden, wenn sie mindestens einen Spaltenwert besitzt.","error",n):e.push(r)}}parseConstant(){let e={constantType:this.tt,position:this.getCurrentPosition(),constant:this.cct.value,type:s.constantNode};return this.nextToken(),e}parseSelect(){let e=this.getCurrentPosition();this.nextToken();let t={line:e.line,column:e.column+6,length:1},i={type:s.keywordSelect,position:e,endPosition:this.getCurrentPosition(),symbolTableEndPosition:this.getCurrentPosition(),symbolTable:null,columnList:[],fromNode:null,whereNode:null,parentStatement:null};i.columnList=this.parseColumnList([s.keywordFrom,s.semicolon,s.endofSourcecode],!0);let n=["distinct","as","*","from"];i.columnList.findIndex(l=>l.type==s.allColumns)>=0&&(n=["from"]),this.module.addCompletionHint(t,this.getCurrentPositionPlus(2),!0,!0,n);let r=this.comesToken(s.keywordFrom,!0),o=["where","join","left","right","inner","outer","natural","on","as",", "];if(!r)n.unshift("from");else{i.fromStartPosition={line:this.lastToken.position.line,column:this.lastToken.position.column+this.lastToken.position.length,length:0};let l=[];i.fromNode=this.parseTableOrSubQuery(l),o.splice(o.indexOf(this.lastToken.value+""),1);let d=this.getCurrentPositionPlus(2);this.comesToken(s.semicolon)&&(d=this.getCurrentPosition()),i.fromEndPosition=this.getCurrentPosition();let u=["like","union"];if(this.tt==s.keywordWhere){this.getCurrentPosition();let f=this.getCurrentPosition();this.nextToken(),i.whereNode=this.parseTerm(),this.module.addCompletionHint(f,this.getCurrentPositionPlus(4),!0,!0,u)}else o.push("where");let m=[];if(this.tt==s.keywordGroup){let f=this.getCurrentPosition();i.groupByNode=this.parseGroupBy(),this.module.addCompletionHint(f,this.getCurrentPosition(),!0,!0,m)}else u.push("group by");if(this.tt==s.keywordOrder){let f=this.getCurrentPosition();i.orderByNode=this.parseOrderBy(),this.module.addCompletionHint(f,this.getCurrentPosition(),!0,!0,["asc","desc"])}else u.push("order by"),m.push("order by");this.tt==s.keywordLimit&&(i.limitNode=this.parseLimit()),i.symbolTableEndPosition=this.getCurrentPosition(),this.comesToken(s.keywordUnion,!0)?this.expect(s.keywordSelect,!1)&&(i.union=this.parseSelect()):r&&i.fromNode!=null&&o.push("union"),this.module.addCompletionHint(i.fromStartPosition,d,!1,!0,o,l)}return i.endPosition=this.getCurrentPosition(),i.endPosition.column+=3,i}parseLimit(){let e=this.getCurrentPosition();this.nextToken();let t=this.parseTerm(),i={type:s.keywordLimit,position:e,numberOfRows:t};return this.tt==s.keywordOffset&&(this.nextToken(),i.offset=this.parseTerm()),i}parseGroupBy(){let e=this.getCurrentPosition();this.expect(s.keywordGroup,!0),this.expect(s.keywordBy,!0);let t={type:s.keywordGroup,columnList:[],position:e},i=[s.keywordHaving,s.keywordSelect,s.keywordOrder,s.keywordLimit,s.rightBracket,s.semicolon];return t.columnList=this.parseColumnList(i,!1).map(n=>n.term),this.tt==s.keywordHaving&&(this.nextToken(),t.having=this.parseTerm()),t}parseOrderBy(){this.expect(s.keywordOrder,!0),this.expect(s.keywordBy,!0);let e=[],t=!0;do{t?t=!1:this.expect(s.comma,!0);let i=this.parseTerm(),n={type:s.keywordOrder,position:this.getCurrentPosition(),column:i};[s.keywordAscending,s.keywordDescending].indexOf(this.tt)>=0&&this.nextToken(),this.tt==s.keywordNulls&&(this.nextToken(),this.expect([s.keywordFirst,s.keywordLast],!0)),e.push(n)}while(this.tt==s.comma);return e}parseTableOrSubQuery(e){let t=this.parseAtomicTableOrSubQuery(e),i=this.getCurrentPosition();for(;this.parseJoinOperator();){let n=this.parseAtomicTableOrSubQuery(e);t={type:s.keywordJoin,firstOperand:t,secondOperand:n,position:i},this.tt==s.keywordOn&&(this.nextToken(),t.on=this.parseTerm())}return t}parseJoinOperator(){if(this.tt==s.comma)return this.nextToken(),!0;switch(this.tt==s.keywordNatural&&this.nextToken(),this.tt){case s.keywordLeft:return this.nextToken(),this.tt==s.keywordOuter&&this.nextToken(),this.expect(s.keywordJoin,!0);case s.keywordInner:case s.keywordCross:return this.nextToken(),this.expect(s.keywordJoin,!0);case s.keywordJoin:return this.nextToken(),!0;default:return!1}}parseAtomicTableOrSubQuery(e){if(!this.expect([s.identifier,s.leftBracket],!1))return null;if(this.tt==s.leftBracket){this.nextToken();let t;if(this.tt==s.keywordSelect){let i=this.getCurrentPosition(),n=this.parseSelect();t={type:s.subquery,alias:null,position:i,query:n}}else t=this.parseTableOrSubQuery(e);return this.expect(s.rightBracket,!0),this.tt==s.keywordAs&&t.type==s.subquery&&(this.nextToken(),this.expect(s.identifier,!1)&&(t.alias=this.cct.value,this.nextToken(),e.push(t.alias))),t}if(this.tt==s.identifier){let t={type:s.table,identifier:this.cct.value,alias:null,position:this.getCurrentPosition()};e.push(t.identifier),this.nextToken();let i=this.tt==s.keywordAs;return(i||this.tt==s.identifier)&&(i&&this.nextToken(),this.expect(s.identifier,!1)&&(t.alias=this.cct.value,this.nextToken(),e.push(t.alias))),t}}parseColumnList(e,t){let i=[];for(;[s.stringConstant,s.integerConstant,s.floatingPointConstant,s.booleanConstant,s.identifier,s.multiplication,s.leftBracket,s.keywordDistinct].indexOf(this.tt)>=0;){if(this.tt==s.multiplication)i.push({term:null,alias:null,distinct:!1,position:this.getCurrentPosition(),type:s.allColumns}),this.nextToken();else{let n=this.comesToken(s.keywordDistinct,!0),r=this.parseTerm();if(r!=null){let o={type:s.column,term:r,distinct:n,position:r.position};i.push(o),(this.comesToken(s.keywordAs)||this.comesToken(s.identifier))&&(this.skip(s.keywordAs),this.expect(s.identifier,!1)&&(o.alias=""+this.cct.value),this.nextToken())}}if(e.indexOf(this.tt)>=0||this.isEnd())break;this.expect(s.comma,!0)}return i.length==0&&this.pushError("Es fehlt die kommaseparierte Liste der gewünschten Spalten.","error"),i}parseTerm(){return this.parseTermBinary(0)}parseTermBinary(e){let t;e<Q.operatorPrecedence.length-1?t=this.parseTermBinary(e+1):t=this.parseUnary();let i=Q.operatorPrecedence[e];if(t==null||i.indexOf(this.tt)<0)return t;let n=!0;if(this.tt==s.keywordBetween||this.tt==s.keywordNotBetween)return this.parseBetween(t,this.tt);for(;n||i.indexOf(this.tt)>=0;){let r=this.tt;n=!1;let o=this.getCurrentPosition();this.nextToken();let l;e<Q.operatorPrecedence.length-1?l=this.parseTermBinary(e+1):l=this.parseUnary(),t={type:s.binaryOp,position:o,operator:r,firstOperand:t,secondOperand:l}}return t}parseBetween(e,t){let i=this.getCurrentPosition();this.nextToken();let n=this.parseTermBinary(2);if(this.expect(s.keywordAnd,!0)){let r=this.parseTermBinary(2);return{type:s.keywordBetween,position:i,firstOperand:e,secondOperand:n,thirdOperand:r}}return null}parseUnary(){let e,t=this.getCurrentPosition();switch(this.tt){case s.leftBracket:return this.parseBracket();case s.keywordNot:return t=t,this.nextToken(),e=this.parseTermBinary(2),{type:s.unaryOp,position:t,operand:e,operator:s.keywordNot};case s.minus:t=this.position;let i=this.tt;return this.nextToken(),e=this.parseUnary(),{type:s.unaryOp,position:t,operand:e,operator:i};case s.integerConstant:case s.charConstant:case s.floatingPointConstant:case s.stringConstant:case s.booleanConstant:e={type:s.constantNode,position:this.getCurrentPosition(),constantType:this.tt,constant:this.cct.value};let n=this.tt==s.stringConstant;return this.nextToken(),n?this.parseDotChains(e):e;case s.identifier:let r=this.cct.value,o=this.getCurrentPosition();if(this.nextToken(),this.tt==s.leftBracket){let l=this.parseMethodCallParameters(),d=l.rightBracketPosition;e={type:s.callMethod,position:o,rightBracketPosition:d,operands:l.nodes,identifier:r,commaPositions:l.commaPositions,distinctBeforeParameters:l.distinctBeforeParameters}}else if(e={type:s.identifier,identifier:r,position:t},this.tt==s.dot){let l=this.getCurrentPosition();this.nextToken(),this.expect(s.identifier,!1);let d={type:s.identifier,identifier:this.cct.value,position:this.getCurrentPosition()};this.nextToken(),e={type:s.dot,identifierLeft:e,identifierRight:d,position:l}}else[s.isNull,s.isNotNull].indexOf(this.tt)>=0&&(e={type:s.unaryOp,operand:e,operator:this.tt,position:t},this.nextToken());return e;default:return this.pushError("Erwartet wird eine Variable, ein Methodenaufruf oder eine Konstante. Gefunden wurde: "+this.cct.value),null}}parseList(){let e={type:s.list,position:this.getCurrentPosition(),elements:[]},t=[s.charConstant,s.stringConstant,s.booleanConstant,s.floatingPointConstant,s.integerConstant];for(;t.indexOf(this.tt)>=0&&(e.elements.push({type:s.constantNode,constant:this.cct.value,constantType:this.tt,position:this.cct.position}),this.nextToken(),this.tt==s.comma);)this.nextToken();return e}parseBracket(){this.getCurrentPosition();let e=this.lastToken;if(this.nextToken(),this.tt==s.keywordSelect){let t=this.parseSelect();return this.expect(s.rightBracket,!0),t}else if([s.comma,s.rightBracket].indexOf(this.ct[1].tt)>=0&&[s.keywordIn,s.keywordNotIn].indexOf(e.tt)>=0){let t=this.parseList();return this.expect(s.rightBracket,!0),t}else{let t=this.parseTerm(),i=this.getCurrentPosition();return this.expect(s.rightBracket,!0),{position:i,type:s.rightBracket,termInsideBrackets:t}}}parseMethodCallParameters(){this.nextToken();let e=this.comesToken(s.keywordDistinct,!0);if(this.tt==s.rightBracket){let o=this.getCurrentPosition();return this.nextToken(),{rightBracketPosition:o,nodes:[],commaPositions:[],distinctBeforeParameters:e}}let t=[],i=[];for(;;){let o=this.pos;if(this.tt==s.multiplication)this.nextToken(),t.push({type:s.allColumns,position:this.getCurrentPosition()});else{let l=this.parseTerm();l!=null&&t.push(l)}if(this.tt!=s.comma)break;i.push(this.getCurrentPosition()),this.nextToken(),this.pos==o&&this.nextToken()}let n=this.getCurrentPosition();return{rightBracketPosition:this.expect(s.rightBracket,!0)?n:null,nodes:t,commaPositions:i,distinctBeforeParameters:e}}parseDotChains(e){if(e==null)return null;for(;this.comesToken([s.dot]);)if(this.tt==s.dot){if(this.nextToken(),this.tt!=s.identifier)return this.pushError("Erwartet wird der Bezeichner eines Attributs oder einer Methode, gefunden wurde: "+this.cct.value),e;let t=this.cct.value,i=this.getCurrentPosition();if(this.nextToken(),this.tt==s.leftBracket){let n=this.parseMethodCallParameters();e={type:s.callMethod,position:i,rightBracketPosition:n.rightBracketPosition,operands:n.nodes,identifier:t,commaPositions:n.commaPositions,distinctBeforeParameters:n.distinctBeforeParameters}}}return e}};h(Q,"operatorPrecedence",[[s.keywordOr],[s.keywordAnd],[s.keywordBetween,s.keywordNotBetween],[s.lower,s.lowerOrEqual,s.greater,s.greaterOrEqual,s.equal,s.notEqual,s.keywordLike,s.keywordNotLike],[s.concatenation,s.plus,s.minus],[s.multiplication,s.division,s.modulo],[s.keywordIn,s.keywordNotIn]]);let Ce=Q;function Oe(a){return a.replace(/['"]+/g,"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function oi(a){return`${tt(a.getDate())}.${tt(a.getMonth())}.${a.getFullYear()}`}function tt(a){return a<10?"0"+a:""+a}function ai(a){let e=a.match(/^(\d{2})\.(\d{2})\.(\d{4}), (\d{2}):(\d{2})$/);return new Date(Number.parseInt(e[3]),Number.parseInt(e[2]),Number.parseInt(e[1]),Number.parseInt(e[4]),Number.parseInt(e[5]))}function li(a){if(a==null||typeof a!="string")return!1;var e=/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/;if(a.match(e)){var t=a.split("/"),i=a.split("-"),n=t.length,r=i.length;if(n>1)var o=a.split("/");else if(r>1)var o=a.split("-");if(o.length!=3)return!1;var l=parseInt(o[2]),d=parseInt(o[1]),u=parseInt(o[0]),m=[31,28,31,30,31,30,31,31,30,31,30,31];if((d==1||d>2)&&l>m[d-1])return!1;if(d==2){var f=!1;return(!(u%4)&&u%100||!(u%400))&&(f=!0),!(f==!1&&l>=29||f==!0&&l>29)}return!0}else return!1}function di(a){if(a==null||typeof a!="string")return!1;var e=/^\d{4}[\-](0[1-9]|1[012])[\-](0[1-9]|[12][0-9]|3[01]) ([01][0-9]|2[0123]):([0-5][0-9]):([0-5][0-9])$/;if(a.match(e)){var t=a.split(" "),i=t[0];if(i.length!=10)return!1;var n=parseInt(i.substring(8,10)),r=parseInt(i.substring(5,7)),o=parseInt(i.substring(0,4)),l=[31,28,31,30,31,30,31,31,30,31,30,31];if((r==1||r>2)&&n>l[r-1])return!1;if(r==2){var d=!1;return(!(o%4)&&o%100||!(o%400))&&(d=!0),!(d==!1&&n>=29||d==!0&&n>29)}return!0}else return!1}function ui(a){if(a==null||typeof a!="string")return!1;var e=/^([01][0-9]|2[0123]):([0-5][0-9]):([0-5][0-9])$/;return a.match(e)!=null}class Y{constructor(e,t){h(this,"type");this.identifier=e,this.type=v.getBaseType(t)}}class ge{constructor(e,t,i,n){h(this,"acceptsStarParameter",!1);h(this,"returnType");this.identifier=e,this.isAggregating=t,this.parameters=n,this.returnType=v.getBaseType(i)}}const _e=class _e{constructor(){h(this,"methods",[]);this.pushOneParameterMethod("abs","float","float"),this.pushOneParameterMethod("sin","float","float"),this.pushOneParameterMethod("cos","float","float"),this.pushOneParameterMethod("tan","float","float"),this.pushOneParameterMethod("max","integer","integer"),this.pushOneParameterMethod("max","float","float"),this.pushOneParameterMethod("max","date","date"),this.pushOneParameterMethod("max","time","time"),this.pushOneParameterMethod("max","datetime","datetime"),this.pushOneParameterMethod("max","timestamp","timestamp"),this.pushOneParameterMethod("min","integer","integer"),this.pushOneParameterMethod("min","float","float"),this.pushOneParameterMethod("min","date","date"),this.pushOneParameterMethod("min","time","time"),this.pushOneParameterMethod("min","datetime","datetime"),this.pushOneParameterMethod("min","timestamp","timestamp"),this.pushOneParameterMethod("avg","integer","integer"),this.pushOneParameterMethod("avg","float","float"),this.pushOneParameterMethod("sum","float","float"),this.pushOneParameterMethod("sum","integer","integer"),this.pushOneParameterMethod("concat","text","text"),this.pushOneParameterMethod("upper","text","text"),this.pushOneParameterMethod("lower","text","text"),this.pushOneParameterMethod("length","integer","text"),this.pushOneParameterMethod("month","integer","date"),this.pushOneParameterMethod("day","integer","date"),this.pushOneParameterMethod("year","integer","date"),this.pushOneParameterMethod("round","integer","float");let e=new ge("count",!0,"integer",[new Y("spalte","text")]);e.acceptsStarParameter=!0,this.methods.push(e);let t=new ge("strftime",!1,"text",[new Y("formatstring","text"),new Y("date","date")]);t.acceptsStarParameter=!0,this.methods.push(t);let i=new ge("round",!1,"float",[new Y("number","float"),new Y("digits","integer")]);i.acceptsStarParameter=!1,this.methods.push(i)}static getInstance(){return this.instance==null&&(this.instance=new _e),this.instance}getMethods(e){return this.methods.filter(t=>t.identifier==e.toLowerCase())}pushOneParameterMethod(e,t,i){this.methods.push(new ge(e,!0,t,[new Y("spalte",i)]))}};h(_e,"instance");let Ae=_e;class fe{constructor(e,t,i,n,r,o,l){h(this,"references");h(this,"fromColumnStructure");h(this,"notNull");this.identifier=e,this.type=t,this.table=i,this.isPrimaryKey=n,this.isNullable=r,this.defaultValue=o,this.isAutoIncrement=l}static fromColumnStructure(e,t){let i=/^(\w*) *(?:\((.*)\))?.*$/,n=e.completeTypeSQL.match(i),r=n[1],o=n[2],l=[];o!=null&&(l=o.split(",").map(m=>parseInt(m.trim())));let d;if(r.indexOf("Enum")>=0)switch(r){case"textEnum":d=new me(e.enumValues);break;case"realEnum":d=new ce(e.enumValues.map(m=>Number.parseFloat(m)));break;case"integerEnum":d=new ce(e.enumValues.map(m=>Number.parseInt(m)));break}else d=v.getBaseType(r);l.length>0&&d!=null&&(d=new de(d,l));let u=new fe(e.name,d,t,e.isPrimaryKey,!e.isPrimaryKey,e.defaultValue,e.isAutoIncrement);return u.notNull=e.notNull,u.fromColumnStructure=e,u}}class Z{constructor(e){h(this,"columns",[]);h(this,"size");h(this,"type");this.identifier=e}static fromTableStructure(e){let t=new Z(e.name);return t.columns=e.columns.map(i=>fe.fromColumnStructure(i,t)),t.size=e.size,t.type=e.type,t}static fromTableStructureList(e){e==null&&(e=[]);let t=e.map(n=>Z.fromTableStructure(n)),i=new Map;for(let n of t)for(let r of n.columns)i.set(r.fromColumnStructure,r);for(let n of t)for(let r of n.columns){let o=r.fromColumnStructure.references;if(o!=null){let l=i.get(o);r.references=l}}return t}}class ve{constructor(e,t,i){h(this,"parent");h(this,"positionFrom");h(this,"positionTo");h(this,"childSymbolTables",[]);h(this,"symbols",new Map);h(this,"symbolList",[]);this.parent=e,this.positionFrom=t,this.positionTo=i,this.parent!=null&&this.parent.childSymbolTables.push(this)}extractDatabaseStructure(e){for(let t of Z.fromTableStructureList(e==null?void 0:e.tables))this.storeTableSymbols(t)}storeTableSymbols(e){this.storeSymbol({identifier:e.identifier,posOfDefinition:null,referencedOnPositions:[],table:e});for(let t of e.columns)this.storeSymbol({identifier:t.identifier,posOfDefinition:null,referencedOnPositions:[],column:t})}storeSymbol(e){let t=this.symbols.get(e.identifier.toLowerCase());t==null?(t=[e],this.symbols.set(e.identifier.toLowerCase(),t)):t.push(e),this.symbolList.push(e)}findTableAtPosition(e,t){if(!this.containsPosition(e,t))return null;let i=null,n=1e7;for(let r of this.childSymbolTables)if(r.containsPosition(e,t)){let o=r.findTableAtPosition(e,t);o.positionTo.line-o.positionFrom.line<n&&(i=o,n=o.positionTo.line-o.positionFrom.line)}return i??this}containsPosition(e,t){return!(e<this.positionFrom.line||e>this.positionTo.line||e==this.positionFrom.line&&t<this.positionFrom.column||e==this.positionTo.line&&t>this.positionTo.column+1)}findTable(e){let t=this.findTables(e);return t.length==0?null:t[0].table}findTables(e){let t=this;for(;t!=null;){let i=t.symbols.get(e.toLowerCase());if(i!=null&&(i=i.filter(n=>n.table!=null),i.length>0))return i;t=t.parent}return[]}findColumn(e){let t=this;for(;t!=null;){let i=t.symbols.get(e.toLowerCase());if(i!=null&&(i=i.filter(n=>n.column!=null),i.length>0))return i;t=t.parent}return[]}}class hi{constructor(e){h(this,"symbolTableStack",[]);h(this,"errorList");h(this,"module");h(this,"databaseTool");h(this,"tables");var t;this.databaseTool=e,this.tables=Z.fromTableStructureList((t=e.databaseStructure)==null?void 0:t.tables)}start(e){this.module=e,this.symbolTableStack=[],this.errorList=[],e.mainSymbolTable=new ve(null,{column:0,line:0,length:0},{column:0,line:1e5,length:0}),this.symbolTableStack.push(e.mainSymbolTable);for(let t of this.module.sqlStatements){let i=this.errorList.length,n=t.ast;if(n!=null){switch(n.type){case s.keywordSelect:this.resolveSelect(n,t.resultTypes),this.symbolTableStack.pop();break;case s.keywordInsert:this.resolveInsert(n),this.symbolTableStack.pop();break;case s.keywordCreate:this.resolveCreateTable(n),this.symbolTableStack.pop();break;case s.keywordUpdate:this.resolveUpdate(n),this.symbolTableStack.pop();break;case s.keywordDelete:this.resolveDelete(n),this.symbolTableStack.pop();break;case s.keywordDrop:this.resolveDropTable(n),this.symbolTableStack.pop();break;case s.keywordAlter:this.resolveAlterTable(n),this.symbolTableStack.pop();break;case s.keywordView:this.resolveCreateView(n),this.symbolTableStack.pop()}t.hasErrors=t.hasErrors||this.errorList.length>i}}e.errors[2]=this.errorList}pushError(e,t="error",i){this.errorList.push({text:e,position:i,level:t})}getCurrentSymbolTable(){return this.symbolTableStack[this.symbolTableStack.length-1]}pushNewSymbolTable(e,t){t==null&&(t={line:1e5,column:1,length:1});let i=new ve(this.getCurrentSymbolTable(),e,t);return this.symbolTableStack.push(i),i}resolveSelect(e,t){let i=new Z(null);e.symbolTable=this.pushNewSymbolTable(e.position,e.symbolTableEndPosition);let n=[];this.resolveTableOrSubQuery(e.fromNode,n),e.fromStartPosition!=null&&new ve(this.getCurrentSymbolTable(),e.fromStartPosition,e.fromEndPosition).extractDatabaseStructure(this.databaseTool.databaseStructure);for(let r of e.columnList)if(r.type==s.allColumns)for(let o of n)for(let l of o.columns){let d=new fe(l.identifier,l.type,i,!1,!0,l.defaultValue,l.isAutoIncrement);i.columns.push(d),t.push(l.type)}else{this.resolveTerm(r.term);let o=new fe(r.alias,r.term.sqlType,i,!1,!0,null,!1);i.columns.push(o),t.push(r.term.sqlType),o.identifier!=null&&e.symbolTable.storeSymbol({identifier:o.identifier,posOfDefinition:r.term.position,referencedOnPositions:[],column:o})}if(e.whereNode!=null){let r=this.resolveTerm(e.whereNode);r!=null&&r.getBaseTypeName()!="boolean"&&this.pushError("Das Ergebnis des where-Teils einer select-Anweisung muss vom Typ boolean sein.","error",e.whereNode.position)}return e.union!=null&&(this.symbolTableStack.pop(),this.resolveSelect(e.union,[]).columns.length!=i.columns.length&&this.pushError("Die select-Anweisungen links und rechts vom Schlüsselwort 'union' müssen dieselbe Anzahl von Spalten besitzen.","error",e.symbolTableEndPosition)),i}resolveDropTable(e){e.symbolTable=this.pushNewSymbolTable(e.position,e.endPosition),e.symbolTable.extractDatabaseStructure(this.databaseTool.databaseStructure),e.tableIdentifier!=null&&(e.ifExists||e.symbolTable.findTable(e.tableIdentifier)==null&&this.pushError("Die Tabelle "+e.tableIdentifier+" ist nicht bekannt.","error",e.tableIdentifierPosition))}resolveDelete(e){if(e.symbolTable=this.pushNewSymbolTable(e.position,e.endPosition),e.symbolTable.extractDatabaseStructure(this.databaseTool.databaseStructure),e.tableIdentifier==null)return;let t=e.symbolTable.findTable(e.tableIdentifier);if(t==null&&this.pushError("Die Tabelle "+e.tableIdentifier+" ist nicht bekannt.","error",e.tableIdentifierPosition),e.whereNode!=null){let i=this.pushNewSymbolTable(e.whereNodeBegin,e.whereNodeEnd);t!=null&&i.storeTableSymbols(t),this.resolveTerm(e.whereNode),this.symbolTableStack.pop()}}resolveAlterTable(e){if(e.symbolTable=this.pushNewSymbolTable(e.position,e.endPosition),e.symbolTable.extractDatabaseStructure(this.databaseTool.databaseStructure),e.tableIdentifier==null)return;let t=e.symbolTable.findTable(e.tableIdentifier);t==null&&this.pushError("Die Tabelle "+e.tableIdentifier+" ist nicht bekannt.","error",e.tableIdentifierPosition);let i=null;switch(e.oldColumnName!=null&&(i=t.columns.find(n=>n.identifier.toLocaleLowerCase()==e.oldColumnName.toLocaleLowerCase()),i==null&&this.pushError("Die Tabelle "+e.tableIdentifier+" hat keine Spalte mit dem Bezeichner "+e.oldColumnName,"error",e.oldColumnPosition)),e.kind){case"dropColumn":break;case"addColumn":let n=e.columnDef;if(n==null)break;if(n.foreignKeyInfo!=null&&n.baseType!=null){let r=n.foreignKeyInfo,o=this.getCurrentSymbolTable().findTables(r.referencesTable);if(o.length==1){let l=o[0].table,d=l.columns.find(u=>u.identifier==r.referencesColumn);d!=null&&d.type!=null&&(d.isPrimaryKey||this.pushError("Die referenzierte Spalte "+r.referencesTable+"."+r.referencesColumn+" ist kein Primärschlüssel.","warning",n.referencesPosition),d.type.canCastTo(n.baseType)||this.pushError("Der Datentyp "+n.baseType.toString()+" der Spalte "+n.identifier+" kann nich in den Datentyp "+d.type.toString()+" der referenzierten Spalte "+l.identifier+"."+d.identifier+" umgewandelt werden.","error",n.referencesPosition))}}break}}resolveUpdate(e){if(e.symbolTable=this.pushNewSymbolTable(e.position,e.endPosition),e.symbolTable.extractDatabaseStructure(this.databaseTool.databaseStructure),e.tableIdentifier==null)return;let t=e.symbolTable.findTable(e.tableIdentifier);if(t==null)this.pushError("Die Tabelle "+e.tableIdentifier+" ist nicht bekannt.","error",e.tableIdentifierPosition);else{for(let i=0;i<e.columnIdentifiers.length;i++){let n=e.columnIdentifiers[i],r=e.columnIdentifierPositions[i],o=e.values[i];if(n==null||(t.columns.find(u=>u.identifier==n)==null&&this.pushError(n+" ist kein Bezeichner einer Spalte der Tabelle "+e.tableIdentifier+".","error",r),o==null))continue;this.pushNewSymbolTable(e.valuePosBegin[i],e.valuePosEnd[i]).storeTableSymbols(t),this.resolveTerm(o),this.symbolTableStack.pop()}e.whereNodeBegin!=null&&this.pushNewSymbolTable(e.whereNodeBegin,e.whereNodeEnd).storeTableSymbols(t),e.whereNode!=null&&this.resolveTerm(e.whereNode)}this.symbolTableStack.pop()}resolveCreateTable(e){e.symbolTable=this.pushNewSymbolTable(e.position,e.endPosition),e.symbolTable.extractDatabaseStructure(this.databaseTool.databaseStructure);let t={identifier:e.identifier,columns:null,size:0,type:"table"};t.columns=e.columnList.map(i=>({identifier:i.identifier,isNullable:!1,isPrimaryKey:i.isPrimary,isAutoIncrement:i.isAutoIncrement,notNull:!1,references:null,table:t,type:i.baseType,defaultValue:i.defaultValue})),e.symbolTable.storeTableSymbols(t);for(let i of e.columnList)if(e.columnList.filter(n=>n.identifier.toLocaleLowerCase()==i.identifier.toLocaleLowerCase()).length>1&&this.pushError("Der Spaltenbezeichner "+i.identifier+" darf in einer Tabelle nur ein einziges Mal verwendet werden","error",i.position),i.foreignKeyInfo!=null&&i.baseType!=null){let n=i.foreignKeyInfo,r=this.getCurrentSymbolTable().findTables(n.referencesTable);if(r.length==1){let o=r[0].table,l=o.columns.find(d=>d.identifier==n.referencesColumn);l!=null&&l.type!=null&&(l.isPrimaryKey||this.pushError("Die referenzierte Spalte "+n.referencesTable+"."+n.referencesColumn+" ist kein Primärschlüssel.","warning",i.referencesPosition),l.type.canCastTo(i.baseType)||this.pushError("Der Datentyp "+i.baseType.toString()+" der Spalte "+i.identifier+" kann nich in den Datentyp "+l.type.toString()+" der referenzierten Spalte "+o.identifier+"."+l.identifier+" umgewandelt werden.","error",i.referencesPosition))}}for(let i of e.foreignKeyInfoList){let n=e.columnList.find(o=>o.identifier==i.column);if(n==null)continue;let r=this.getCurrentSymbolTable().findTables(i.referencesTable);if(r.length==1){let o=r[0].table,l=o.columns.find(d=>d.identifier==i.referencesColumn);l!=null&&l.type!=null&&(l.isPrimaryKey||this.pushError("Die referenzierte Spalte "+i.referencesTable+"."+i.referencesColumn+" ist kein Primärschlüssel.","warning",i.referencesPosition),l.type.canCastTo(n.baseType)||this.pushError("Der Datentyp "+n.baseType.toString()+" der Spalte "+n.identifier+" kann nich in den Datentyp "+l.type.toString()+" der referenzierten Spalte "+o.identifier+"."+l.identifier+" umgewandelt werden.","error",i.referencesPosition))}}}resolveTableOrSubQuery(e,t){if(e!=null)switch(e.type){case s.table:let i=this.tables.filter(n=>n.identifier.toLowerCase()==e.identifier.toLowerCase());if(i.length==0)this.pushError(e.identifier+" ist nicht der Name einer Tabelle.","error",e.position);else if(i.length>1)this.pushError("Der Bezeichner "+e.identifier+" ist hier nicht eindeutig.","error",e.position);else{let n=i[0];t.push(n),this.storeTableIntoSymbolTable(n,e.position,e.alias)}break;case s.keywordJoin:this.resolveTableOrSubQuery(e.firstOperand,t),this.resolveTableOrSubQuery(e.secondOperand,t);break;case s.subquery:e.table=this.resolveSelect(e.query,[]),t.push(e.table),e.alias!=null&&(e.table.identifier=e.alias,this.storeTableIntoSymbolTable(e.table,e.position));break}}storeTableIntoSymbolTable(e,t,i){let n=this.getCurrentSymbolTable();n.storeSymbol({identifier:i==null?e.identifier.toLowerCase():i.toLowerCase(),posOfDefinition:t,table:e,referencedOnPositions:[]});for(let r of e.columns)n.storeSymbol({identifier:r.identifier.toLowerCase(),posOfDefinition:null,column:r,tableAlias:i,referencedOnPositions:[]})}resolveTerm(e){if(e==null)return null;switch(e.type){case s.keywordBetween:let t=this.resolveTerm(e.firstOperand),i=this.resolveTerm(e.secondOperand),n=this.resolveTerm(e.thirdOperand);return t==null||i==null||n==null?null:t.canCastTo(v.getBaseType("double"))?i.canCastTo(v.getBaseType("double"))?(n.canCastTo(v.getBaseType("double"))||this.pushError("Hier wird eine Zahl erwartet.","error",e.thirdOperand.position),v.getBaseType("boolean")):(this.pushError("Hier wird eine Zahl erwartet.","error",e.secondOperand.position),null):(this.pushError("Hier wird eine Zahl erwartet.","error",e.firstOperand.position),null);case s.binaryOp:if([s.keywordIn,s.keywordNotIn].indexOf(e.operator)>=0)return this.resolveNotIn(e);let r=this.resolveTerm(e.firstOperand),o=this.resolveTerm(e.secondOperand);if(r!=null&&o!=null){let u=r.getBinaryResultType(e.operator,o);return u==null&&this.pushError("Der Operator "+_[e.operator]+" ist für die Datentypen "+r.toString()+" und "+o.toString()+" nicht definiert.","error",e.position),e.sqlType=u,u}else return null;case s.unaryOp:let l=this.resolveTerm(e.operand);if(l!=null){let u=l.getUnaryResultType(e.operator);return u==null&&this.pushError("Der Operator "+_[e.operator]+" ist für einen Operanden des Datentyps "+l.toString()+" nicht definiert.","error",e.position),e.sqlType=u,u}else return null;case s.callMethod:return this.resolveMethodCall(e);case s.constantNode:return e.sqlType=v.fromConstantType(e.constantType),e.sqlType;case s.identifier:return this.resolveIdentifier(e);case s.dot:return this.resolveDot(e);case s.keywordSelect:let d=this.resolveSelect(e,[]);return d.columns.length!=1?(this.pushError("Die Ergebnistabelle einer Unterabfrage an dieser Stelle muss genau eine Spalte besitzen.","error",e.position),null):d.columns[0].type;case s.rightBracket:return e.sqlType=this.resolveTerm(e.termInsideBrackets),e.sqlType;case s.allColumns:this.pushError("Das Zeichen * kann hier nicht verwendet werden.","error",e.position);break;case s.list:this.pushError("Eine Liste wird hier nicht erwartet.","error",e.position);break}}resolveDot(e){let t=this.getCurrentSymbolTable().findTables(e.identifierLeft.identifier);if(t.length==0)return this.pushError("Die Tabelle "+e.identifierLeft.identifier+" kann nicht gefunden werden.","error",e.identifierLeft.position),null;if(t.length>1)return this.pushError("Der Tabellenbezeichner "+e.identifierLeft.identifier+" ist nicht eindeutig.","error",e.identifierLeft.position),null;let n=t[0].table.columns.filter(o=>o.identifier.toLowerCase()==e.identifierRight.identifier.toLowerCase());if(n.length==0){this.pushError("Die Tabelle "+e.identifierLeft.identifier+" hat keine Spalte mit dem Bezeichner "+e.identifierRight.identifier+".","error",e.identifierRight.position);return}if(n.length>1){this.pushError("Die Tabelle "+e.identifierLeft.identifier+" hat mehrere Spalten mit dem Bezeichner "+e.identifierRight.identifier+".","error",e.identifierRight.position);return}let r=n[0];return e.sqlType=r.type,r.type}resolveIdentifier(e){let t=this.getCurrentSymbolTable().findColumn(e.identifier);if(t.length==0)return this.pushError("Der Bezeichner "+e.identifier+" ist an dieser Stelle nicht bekannt.","error",e.position),null;if(t.length>1)return this.pushError("Der Bezeichner "+e.identifier+" ist nicht eindeutig.","error",e.position),null;let i=t[0];return e.sqlType=i.column.type,i.column.type}resolveMethodCall(e){let i=Ae.getInstance().getMethods(e.identifier);if(e.identifier.toLocaleLowerCase()=="concat"){if(e.operands.length==0)return this.pushError("Die Methode concat benötigt mindestens einen Parameter.","error",e.position),null;let n=i[0];return e.sqlType=n.returnType,e.sqlType}else{let n=e.identifier.toLocaleLowerCase()=="count";if(n||(i=i.filter(r=>r.parameters.length==e.operands.length)),e.operands.length==1&&e.operands[0].type==s.allColumns)return i=i.filter(r=>r.acceptsStarParameter),e.sqlType=i[0].returnType,e.sqlType;if(i.length==0)return this.pushError("Es gibt keine passende Methode mit dem Bezeichner '"+e.identifier+"'.","error",e.position),null;for(let r of e.operands)if(this.resolveTerm(r)==null)return e.sqlType=i[0].returnType,e.sqlType;for(let r of i){let o=!0;for(let l=0;l<r.parameters.length;l++){let d=r.parameters[l],u=e.operands[l];if(u!=null&&!u.sqlType.canCastTo(d.type)){o=!1;break}}if(o||n)return e.sqlType=r.returnType,e.sqlType}return this.pushError("Es gibt keine passende Methode mit dem Bezeichner '"+e.identifier+"'.","error",e.position),null}}resolveNotIn(e){if(e.firstOperand==null||e.secondOperand==null)return null;let t=_[e.operator];this.resolveTerm(e.firstOperand);let i=e.firstOperand.sqlType;if(i!=null)if(e.secondOperand.type==s.keywordSelect){let n=e.secondOperand;n.columnList.length!=1&&this.pushError("Wenn rechts vom Operator '"+t+"' eine Unterabfrage steht, muss die Ergebnistabelle dieser Unterabfrage genau eine Spalte haben.","error",n.position),this.resolveSelect(n,[]);let r=n.columnList[0].term.sqlType;r.canCastTo(i)||this.pushError("Der Datentyp der Ergebnisspalte der Unterabfrage ist "+r.toString()+". Dieser kann nicht in den Datentyp "+i.toString()+" umgewandelt werden.","error",n.position)}else if(e.secondOperand.type==s.list){let n=e.secondOperand;for(let r of n.elements){let o=v.fromConstantType(r.constantType);r.sqlType=o,o.canCastTo(i)||this.pushError("Der Datentyp des Listenelements "+r.constant+" ist "+o.toString()+". Er kann nicht in den Datentype "+i.toString()+" des Operanden auf der linken Seite des Operators '"+t+"' umgewandelt werden.","error",r.position)}}else this.pushError("Der rechte Operand der Operatoren 'in' und 'not in' muss eine Unterabfrage oder eine Liste sein.","error",e.secondOperand.position);return v.getBaseType("boolean")}resolveCreateView(e){let t=this.pushNewSymbolTable(e.position,e.endPosition);this.resolveSelect(e.selectStatement,[]),t.childSymbolTables.push(this.symbolTableStack.pop())}resolveInsert(e){let t=null,i=this.pushNewSymbolTable(e.position,e.endPosition);e.table!=null&&(e.table.table=this.tables.find(l=>l.identifier.toLowerCase()==e.table.identifier.toLocaleLowerCase()),e.table.table==null?this.pushError("Die Tabelle "+e.table.identifier+" gibt es nicht.","error",e.table.position):(t=e.table.table,i.storeTableSymbols(t)));let n=e.endPosition;e.valuesPosition!=null&&(n=e.valuesPosition),e.columnsPosition!=null&&(n=e.columnsPosition),this.module.addCompletionHint(e.position,n,!1,!0,["into","values"]),t!=null&&this.module.addCompletionHint(n,e.valuesPosition==null?e.endPosition:e.valuesPosition,!0,!1,["values"]),this.pushNewSymbolTable(e.position,n).extractDatabaseStructure(this.databaseTool.databaseStructure);let o=[];if(e.columnList.length==0)t!=null&&(o=t.columns);else if(t!=null)for(let l of e.columnList){let d=t.columns.find(u=>u.identifier.toLowerCase()==l.identifier.toLowerCase());d==null?this.pushError("Die Tabelle "+t.identifier+" besitzt keine Spalte mit dem Bezeichner "+l.identifier+".","error",l.position):o.push(d)}if(o.length>0)if(e.select!=null){let l=this.resolveSelect(e.select,[]);if((l==null?void 0:l.columns)!=null)if(o.length!=l.columns.length)this.pushError("Die insert-Anweisung erwartet "+o.length+" Werte je Datensatz, die select-Anweisung liefert aber "+l.columns.length+".","error",e.position);else for(let d=0;d<o.length;d++){let u=o[d],m=l.columns[d];u.type!=null&&m.type!=null&&(m.type.canCastTo(u.type)||this.pushError("Der Datentyp "+m.type.toString()+" der "+(d+1)+"-ten Spalte des select-Terms kann nicht in den Datentyp "+u.type.toString()+" der entsprechenden Spalte der insert-Anweisung umgewandelt werden.","error",e.position))}}else for(let l of e.values)if(l.length!=o.length&&l.length>0)this.pushError("Erwartet werden "+o.length+" Elemente, hier stehen aber "+l.length+" Elemente in der Liste.","error",l[0].position);else for(let d=0;d<l.length;d++){let u=l[d],m=o[d];u.sqlType=v.fromConstantType(u.constantType);let f=m.type.toString().toLocaleLowerCase();if(u.constantType==s.keywordNull)(!m.isNullable||m.notNull)&&this.pushError("Die Spalte "+m.identifier+" ist nicht nullable, daher kann null hier nicht eingefügt werden.","error",u.position);else if(u.sqlType.canCastTo(m.type)){if(f=="date"){if(!li(u.constant)){let p=`'${u.constant}' ist kein date-Wert.<br><b>Tipp: </b>Datumswerte haben die Form 'yyyy-mm-dd', also z.B. '2022-06-15'.`;this.pushError(p,"error",u.position)}}else if(f=="datetime"||f=="timestamp"){if(!di(u.constant)){let p=`'${u.constant}' ist kein ${f}-Wert.<br><b>Tipp: </b>Timestamps haben die Form 'yyyy-mm-dd hh:min:ss', also z.B. '2022-06-15 07:56:22'.`;this.pushError(p,"error",u.position)}}else if(f=="time"&&!ui(u.constant)){let p=`'${u.constant}' ist kein ${f}-Wert.<br><b>Tipp: </b>Time-Werte haben die Form 'hh:min:ss', also z.B. '07:56:22'.`;this.pushError(p,"error",u.position)}}else{let p="Der Wert "+u.constant+" vom Datentyp "+u.sqlType.toString()+" kann nicht in den Datentyp "+m.type.toString()+" der Spalte "+m.identifier+" umgewandelt werden.";f=="date"&&(p+="<br><b>Tipp: </b>Datumswerte haben die Form 'yyyy-mm-dd', also z.B. '2022-06-15'."),(f=="datetime"||f=="timestamp")&&(p+="<br><b>Tipp: </b>Timestamps haben die Form 'yyyy-mm-dd hh:min:ss', also z.B. '2022-06-15 07:56:22'."),this.pushError(p,"error",u.position)}}this.symbolTableStack.pop()}}var pe=(a=>(a[a.compiling=0]="compiling",a[a.error=1]="error",a[a.compiledButNothingToRun=2]="compiledButNothingToRun",a[a.readyToRun=3]="readyToRun",a))(pe||{});class ft{constructor(e){h(this,"compilerStatus",2);h(this,"atLeastOneModuleIsStartable");this.main=e}compile(e){this.compilerStatus=0;let t=performance.now(),i=new Re;for(let u of e.getModules(!1)){u.file.dirty=!1,u.clear();let m=i.lex(u.getProgramTextFromMonacoModel());u.errors[0]=m.errors,u.tokenList=m.tokens,u.bracketError=m.bracketError}this.main.getSemicolonAngel().startRegistering();let n=new Ce;for(let u of e.getModules(!1))n.parse(u);let r=this.main.getDatabaseTool(),o=new hi(r);for(let u of e.getModules(!1))o.start(u);let l=performance.now()-t;l=Math.round(l*100)/100;let d="Compiled in "+l+" ms.";return this.main.getCurrentWorkspace().compilerMessage=d,this.main.getSemicolonAngel().healSemicolons(),this.compilerStatus=3,null}}const z=class z{constructor(e,t){h(this,"file");h(this,"uri");h(this,"model");h(this,"oldErrorDecorations",[]);h(this,"lastSavedVersionId");h(this,"editorState");h(this,"errors",[[],[],[],[]]);h(this,"tokenList");h(this,"sqlStatements");h(this,"mainSymbolTable");h(this,"identifierPositions",{});h(this,"methodCallPositions",{});h(this,"bracketError");h(this,"completionHints",new Map);if(this.main=t,e==null||this.main==null)return;this.file=e;let i=e.name,n=z.uriMap[i];n==null?n=0:n++,z.uriMap[i]=n,n>0&&(i+=" ("+n+")"),this.uri=jt.from({path:i,scheme:"inmemory"}),this.model=x.createModel(e.text,"vscSQL",this.uri),this.model.updateOptions({tabSize:3}),this.lastSavedVersionId=this.model.getAlternativeVersionId();let r=this;this.model.onDidChangeContent(()=>{let o=r.model.getAlternativeVersionId();if(o!=r.lastSavedVersionId&&(r.file.dirty=!0,r.file.saved=!1,r.lastSavedVersionId=o),!r.main.isEmbedded()){let l=t;l.workspacesOwnerId!=l.user.id?(r.file.text_before_revision==null||r.file.student_edited_after_revision)&&(r.file.student_edited_after_revision=!1,r.file.text_before_revision=r.file.text,r.file.saved=!1,l.networkManager.sendUpdates(null,!1),l.bottomDiv.homeworkManager.showHomeWorkRevisionButton(),l.projectExplorer.renderHomeworkButton(r.file)):r.file.student_edited_after_revision=!0}})}addCompletionHint(e,t,i,n,r,o,l="",d=""){let u={fromColumn:e.column,fromLine:e.line,toColumn:t.column,toLine:t.line,hintColumns:typeof i=="boolean"?i:!0,hintColumnsOfTable:typeof i=="string"?i:null,hintTables:n,hintKeywords:r==null?null:r.map(m=>m.toUpperCase()),dontHint:o,praefix:l,suffix:d};for(let m=u.fromLine;m<=u.toLine;m++){let f=this.completionHints.get(m);f==null&&(f=[],this.completionHints.set(m,f)),f.push(u)}}getSQLSTatementsAtSelection(e){let t={line:e.startLineNumber,column:e.startColumn},i={line:e.endLineNumber,column:e.endColumn};return this.sqlStatements==null?[]:this.sqlStatements.filter(n=>!(this.compare(n.to,t)<0||this.compare(n.from,i)>0))}compare(e,t){return e.line>t.line?1:e.line<t.line?-1:e.column>t.column?1:e.column<t.column?-1:0}getSQLStatementAtPosition(e){return this.sqlStatements.find(t=>!(t.from.line>e.lineNumber||t.from.line==e.lineNumber&&t.from.column>e.column||t.to.line<e.lineNumber||t.to.line==e.lineNumber&&t.to.column<e.column))}getCompletionHint(e,t){let i=this.completionHints.get(e);if(i==null||i.length==0)return null;let n=e*1e3+t;if(i=i.filter(l=>n>=l.fromLine*1e3+l.fromColumn&&n<=l.toLine*1e3+l.toColumn),i.length==0)return;let r=i[0],o=(r.toLine-r.fromLine)*1e3+(r.toColumn-r.fromColumn);for(let l=1;l<i.length;l++){let d=i[l],u=(d.toLine-d.fromLine)*1e3+(d.toColumn-d.fromColumn);u<o&&(r=d,o=u)}return r}static restoreFromData(e,t){let i={name:e.name,text:e.text,text_before_revision:e.text_before_revision,submitted_date:e.submitted_date,student_edited_after_revision:!1,dirty:!0,saved:!0,version:e.version,id:e.id};return new z(i,t)}getFileData(e){let t=this.file;return{id:t.id,name:t.name,text:t.text,text_before_revision:t.text_before_revision,submitted_date:t.submitted_date,student_edited_after_revision:t.student_edited_after_revision,version:t.version,workspace_id:e.id,forceUpdate:!1,file_type:11}}findSymbolTableAtPosition(e,t){return this.mainSymbolTable==null?null:((e>this.mainSymbolTable.positionTo.line||e==this.mainSymbolTable.positionTo.line&&t>this.mainSymbolTable.positionTo.column)&&(e=this.mainSymbolTable.positionTo.line,t=this.mainSymbolTable.positionTo.column-1),this.mainSymbolTable.findTableAtPosition(e,t))}getErrorCount(){let e=0;for(let t of this.errors)t.forEach(i=>e+=i.level=="error"?1:0);return e}getProgramTextFromMonacoModel(){return this.model.getValue(x.EndOfLinePreference.LF,!1)}addIdentifierPosition(e,t){let i=this.identifierPositions[e.line];i==null&&(i=[],this.identifierPositions[e.line]=i),i.push({position:e,element:t})}getElementAtPosition(e,t){let i=this.identifierPositions[e];if(i==null)return null;let n=null;for(let r of i)t>=r.position.column&&t<r.position.column+r.position.length&&r.position.length>0&&n==null&&(n=r);return n==null?null:n.element}copy(){let e=new z(this.file,this.main);return e.model=this.model,e.mainSymbolTable=this.mainSymbolTable,this.mainSymbolTable=null,this.file.dirty=!0,e}clear(){this.identifierPositions={},this.file!=null&&this.file.dirty&&(this.tokenList=null,this.errors[0]=[],this.errors[1]=[]),this.errors[2]=[],this.errors[3]=[],this.mainSymbolTable=new ve(null,{line:1,column:1,length:1},{line:1e5,column:1,length:0}),this.methodCallPositions={}}hasErrors(){for(let e of this.errors)if(e.find(t=>t.level=="error"))return!0;return!1}getSortedAndFilteredErrors(){let e=[];for(let t of this.errors)e=e.concat(t);e.sort((t,i)=>t.position.line>i.position.line?1:i.position.line>t.position.line?-1:t.position.column>=i.position.column?1:-1);for(let t=0;t<e.length-1;t++){let i=e[t],n=e[t+1];i.position.line==n.position.line&&i.position.column+10>n.position.column&&(this.errorLevelCompare(i.level,n.level)==1?e.splice(t+1,1):e.splice(t,1),t--)}return e}errorLevelCompare(e,t){return e=="error"?1:t=="error"?2:e=="warning"?1:t=="warning"?2:1}};h(z,"maxUriNumber",0),h(z,"uriMap",{});let U=z;class Ue{constructor(e){h(this,"modules",[]);h(this,"moduleMap",new Map);h(this,"dirty",!1);this.main=e}findModuleById(e){for(let t of this.modules)if(t.file.id==e)return t;return null}copy(){let e=new Ue(this.main);for(let t of this.modules)e.putModule(t.copy());return e}findModuleByFile(e){for(let t of this.modules)if(t.file==e)return t;return null}hasErrors(){for(let e of this.modules)if(e.hasErrors())return!0;return!1}getFirstModule(){if(this.modules.length>0)for(let e of this.modules)return e;return null}isDirty(){if(this.dirty)return this.dirty=!1,!0;let e=!1;for(let t of this.modules)if(t.file.dirty){e=!0;break}return e}getModules(e,t){let i=[];for(let n of this.modules)n.file.name!=t&&i.push(n);return i}putModule(e){this.modules.push(e),this.moduleMap[e.file.name]=e}removeModuleWithFile(e){for(let t of this.modules)if(t.file==e){this.removeModule(t);break}}removeModule(e){this.modules.indexOf(e)<0||(this.modules.splice(this.modules.indexOf(e),1),this.moduleMap[e.file.name]=void 0,this.dirty=!0)}getModule(e){return this.moduleMap[e]}}class pt{constructor(e){h(this,"semicolonPositions",[]);h(this,"time");this.main=e}startRegistering(){this.semicolonPositions.forEach(e=>e.isThereAgain=!1),this.time=new Date().getTime()}register(e,t){let i=this.semicolonPositions.find(n=>n.position.line==e.line&&n.position.column==e.column);i?i.isThereAgain=!0:this.semicolonPositions.push({position:e,firstSeenMs:this.time,isThereAgain:!0,module:t})}healSemicolons(){let e=new Date().getTime();this.semicolonPositions=this.semicolonPositions.filter(n=>n.isThereAgain);let t=this.main.getCurrentlyEditedModule(),i=this.main.getMonacoEditor().getPosition().lineNumber;this.semicolonPositions.filter(n=>e-n.firstSeenMs>2e3).forEach(n=>{let r=n.module.file.id!=null&&n.module.file.id==t.file.id,o=[{range:new rt(n.position.line,n.position.column,n.position.line,n.position.column),text:";",forceMoveMarkers:!0}];if(r&&Math.abs(i-n.position.line)>1){let l=this.main.getMonacoEditor();const d=l.getSelection();l.executeEdits("Semicolon-Angel",o),l.setSelection(d),this.semicolonPositions.splice(this.semicolonPositions.indexOf(n),1)}})}}var bn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function wn(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}function ci(a){if(a.__esModule)return a;var e=a.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(a).forEach(function(i){var n=Object.getOwnPropertyDescriptor(a,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return a[i]}})}),t}class gt{constructor(e,t){h(this,"actions",{});h(this,"keyEntries",{});h(this,"buttons",{});this.$mainElement=e,this.main=t}init(){let e=this.$mainElement;e==null&&(e=c(document));let t=this;e.on("keydown",function(i){i!=null&&t.executeKeyDownEvent(i)})}trigger(e){let t=this.actions[e];t!=null&&t.action(e,null,"")}registerAction(e,t,i,n="",r){let o={action:i,identifier:e,keys:t,text:n,active:!0};this.actions[e]=o;for(let l of t)this.keyEntries[l.toLowerCase()]==null&&(this.keyEntries[l.toLowerCase()]=[]),this.keyEntries[l.toLowerCase()].push(o);if(r!=null){this.buttons[e]==null&&(this.buttons[e]=[]),this.buttons[e].push(r);let l=n;t.length>0&&(l+=" ["+t.join(", ")+"]"),r.attr("title",l),r.on("mousedown",()=>{o.active&&i(e,null,"mousedown")})}}isActive(e){let t=this.actions[e];return t==null?!1:t.active}setActive(e,t){let i=this.actions[e];i!=null&&(i.active=t);let n=this.buttons[e];if(n!=null)for(let r of n)t?r.addClass("jo_active"):r.removeClass("jo_active")}executeKeyDownEvent(e){if(document.activeElement.tagName.toLowerCase()=="input"||e.keyCode<=18&&e.keyCode>=16)return;let t="";e.ctrlKey&&(t+="ctrl+"),e.shiftKey&&(t+="shift+"),e.altKey&&(t+="alt+"),e.key!=null&&(t+=e.key.toLowerCase());let i=this.keyEntries[t];if(i!=null){for(let n of i)if(n.active){e.stopPropagation(),e.preventDefault(),n.action(n.identifier,null,t);break}}}}function bt(a,e,t,i=null){let n=window.PointerEvent?"pointer":"mouse";e==null&&(e=a);let r=c('<input type="text" class="jo_inplaceeditor" spellcheck="false">');r.css({width:e.css("width"),height:e.css("height"),color:e.css("color"),position:e.css("position"),"background-color":e.css("background-color"),"font-size":e.css("font-size"),"font-weight":e.css("font-weight"),"box-sizing":"border-box"}),r.val(a.text()),r.on(n+"down",o=>{o.stopPropagation()}),i!=null&&r[0].setSelectionRange(i.start,i.end),e.after(r),e.hide(),setTimeout(()=>{r.focus()},300),r.on("keydown.me",o=>{if(o.key=="Enter"||o.key=="Escape"){r.off("keydown.me"),r.off("focusout.me"),r.remove(),e.show();let l=Oe(r.val());t(l);return}}),r.on("focusout.me",o=>{r.off("keydown.me"),r.off("focusout.me"),r.remove(),e.show();let l=Oe(r.val());t(l)})}function R(a,e,t){let i=window.PointerEvent?"pointer":"mouse",n=c('<div class="jo_contextmenu"></div>'),r=null,o=null;for(let p of a){let b=p.caption;p.link!=null&&(b=`<a href="${p.link}" target="_blank" class="jo_menulink">${p.caption}</a>`);let k=c("<div>"+b+(p.subMenu!=null?'<span style="float: right"> &nbsp; &nbsp; &gt;</span>':"")+"</div>");if(p.color!=null&&k.css("color",p.color),p.link==null)k.on(i+"up.contextmenu",g=>{g.stopPropagation(),c(".jo_contextmenu").remove(),c(document).off(i+"up.contextmenu"),c(document).off(i+"down.contextmenu"),c(document).off("keydown.contextmenu"),p.callback()}),k.on(i+"down.contextmenu",g=>{g.stopPropagation()});else{let g=k.find("a");g.on(i+"up",w=>{w.stopPropagation(),setTimeout(()=>{k.hide()},500)}),g.on(i+"down",w=>{w.stopPropagation()})}k.on(i+"move.contextmenu",()=>{p!=o&&r!=null&&(r.remove(),o=null,r=null),p.subMenu!=null&&(r=R(p.subMenu,k.offset().left+k.width(),k.offset().top))}),n.append(k)}c(document).on(i+"down.contextmenu",p=>{c(document).off(i+"down.contextmenu"),c(document).off("keydown.contextmenu"),c(".jo_contextmenu").remove()}),c(document).on("keydown.contextmenu",p=>{p.key=="Escape"&&(c(document).off(i+"up.contextmenu"),c(document).off("keydown.contextmenu"),c(".jo_contextmenu").remove())});let l=e>window.innerWidth*.8?"right":"left",d=e>window.innerWidth*.8?window.innerWidth-e:e,u=t>window.innerHeight*.8?"bottom":"top",m=t>window.innerHeight*.8?window.innerHeight-t:t,f={};return f[l]=d+"px",f[u]=m+"px",n.css(f),c("body").append(n),n.show(),n}function Le(a){let e=a.find(".jo_tabheadings>div").not(".jo_noHeading"),t=a.find(".jo_tabs>div"),i=window.PointerEvent?"pointer":"mouse";e.on(i+"down",n=>{let r=c(n.target);e.removeClass("jo_active"),r.addClass("jo_active");let o=a.find("."+r.data("target"));t.removeClass("jo_active"),t.trigger("myhide"),o.addClass("jo_active"),o.trigger("myshow")})}function X(a,e="",t="",i){let n="";e!=null&&e!=""&&(n+=` class="${e}"`);let r=c(`<div${n}></div>`);return t!=null&&t!=""&&r.text(t),r}var ye=!1;function mi(){matchMedia("(pointer:fine)").matches&&(ye=!0)}function it(a,e,t,i){let n="rgba("+t[0]+", "+t[1]+", "+t[2]+", ",r=1,o=r/(i/20),l=()=>{a.css(e,n+r+")"),r-=o,r<0?a.css(e,""):setTimeout(l,20)};l()}function He(a,e,t=!1){var i=t?a:new Blob([typeof a=="string"?a:JSON.stringify(a)],{type:"text/plain"});if(window.navigator&&window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(i,e);else{var n=document.createEvent("MouseEvents"),r=document.createElement("a");r.download=e,r.href=window.URL.createObjectURL(i),r.dataset.downloadurl=["text/plain",r.download,r.href].join(":"),n.initEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),r.dispatchEvent(n),r.remove()}}function fi(a){var e=document.createElement("textarea");e.value=a,e.style.top="0",e.style.left="0",e.style.position="fixed",document.body.appendChild(e),e.focus(),e.select();try{var t=document.execCommand("copy")}catch(i){console.error("Fallback: Oops, unable to copy",i)}document.body.removeChild(e)}function wt(a){if(!navigator.clipboard){fi(a);return}navigator.clipboard.writeText(a).then(function(){},function(e){console.error("Async: Could not copy text: ",e)})}function pi(a){const e=new RegExp(`(^| )${a}=([^;]+)`),t=document.cookie.match(e);if(t)return t[2]}const j=class j{static registerPerformanceEntry(e,t){let i=j.performanceData.find(r=>r.url==e);i==null&&(i={count:0,sumTime:0,url:e},j.performanceData.push(i)),i.count++;let n=Math.round(performance.now()-t);i.sumTime+=n,j.performanceDataCount++}static sendDataToServer(){if(performance.now()-j.lastTimeSent>3*60*1e3){let e={data:j.performanceData};j.performanceData=[],j.performanceDataCount=0,j.lastTimeSent=performance.now(),D("collectPerformanceData",e,()=>{})}}};h(j,"performanceData",[]),h(j,"performanceDataCount",0),h(j,"lastTimeSent",performance.now());let Fe=j;var $="";function D(a,e,t,i){a.startsWith("http")||(a="servlet/"+a),$e(!0);let n=performance.now(),r={};$!=null&&(r={"x-token-pm":$}),c.ajax({type:"POST",async:!0,data:JSON.stringify(e),contentType:"application/json",headers:r,url:a,success:function(o){if(Fe.registerPerformanceEntry(a,n),o.csrfToken!=null&&($=o.csrfToken),$e(!1),o.success!=null&&o.success==!1||typeof o=="string"&&o==""){let l="Fehler bei der Bearbeitung der Anfrage";o.message!=null&&(l=o.message),i&&i(l)}else t(o)},error:function(o,l){if($e(!1),i){let d="Server nicht erreichbar.";o.status!=0&&(d=""+o.status),i(l+": "+d);return}}})}function $e(a){a?c(".jo_network-busy").css("visibility","visible"):c(".jo_network-busy").css("visibility","hidden")}async function be(a,e){let t=[["content-type","text/json"]];$!=null&&t.push(["x-token-pm",$]);try{let n=await(await fetch(a,{method:"POST",headers:t,body:JSON.stringify(e)})).json();return n.token!=null&&($=n.token),n==null?alert("Fehler beim Übertragen der Daten."):n.success!=!0&&alert(`Fehler beim Übertragen der Daten:
15
+ `+n.message),n}catch(i){return{status:"Error",message:"Es ist ein Fehler aufgetreten: "+i}}}class Ke{constructor(){h(this,"id");h(this,"name");h(this,"templateDump");h(this,"based_on_template_id");h(this,"templateName");h(this,"statements");h(this,"published_to");h(this,"version");h(this,"description");h(this,"owner_id")}static fromDatabaseData(e,t){let i=new Ke;return i.id=e.id,i.name=e.name,i.statements=e.statements,i.published_to=e.published_to,i.version=t,i.description=e.description,i.templateDump=null,i.based_on_template_id=e.based_on_template_id,i.owner_id=e.owner_id,i}}class gi{fetchTemplateFromCache(e,t){if(e==null){t(null);return}let i=this;this.cacheAvailable()||t(null),this.getCache(n=>{n.match(i.databaseIdToCacheIdentifier(e)).then(r=>{r.arrayBuffer().then(o=>t(new Uint8Array(o)))}).catch(()=>t(null))})}saveTemplateToCache(e,t){if(!this.cacheAvailable())return;let i=this;this.getCache(n=>{n.put(i.databaseIdToCacheIdentifier(e),new Response(t)).catch(r=>{console.warn("Konnte Template nicht im Cache speichern, Grund: "+r)})})}cacheAvailable(){return"caches"in self}getCache(e){caches.open("my-cache").then(e)}databaseIdToCacheIdentifier(e){return"/onlineIdeTemplateDb"+e}}class Pe{uploadCurrentDatabase(e,t,i,n,r=()=>{}){t.waitOverlay.show("Bitte warten, lade Vorlage auf den Server hoch ..."),e>=0?t.getDatabaseTool().export(l=>{l=H.deflate(l),this.uploadIntern(l,e,n,t,r)},l=>{alert("Fehler beim Exportieren der Datenbank: "+l),t.waitOverlay.hide()}):this.uploadIntern(i,-1,n,t,r)}uploadIntern(e,t,i,n,r){let o={"x-workspaceid":""+t,"x-reason":i};return $!=null&&(o["x-token-pm"]=$),c.ajax({type:"POST",async:!0,contentType:"application/octet-stream",data:e,processData:!1,headers:o,url:"servlet/uploadTemplate",success:function(l){n.waitOverlay.hide(),r(l)},error:function(l,d){alert("Fehler beim Hochladen der Datenbank: "+d),n.waitOverlay.hide()}}),e}}const ee=class ee{static isZipfile(e){return ee.checkSignature(e,this.zipSignature)}static isSqLiteFile(e){return ee.checkSignature(e,this.sqLiteSignature)}static checkSignature(e,t){if(e==null||e.byteLength<t.length)return!1;for(let i=0;i<t.length;i++)if(e[i]!=t[i])return!1;return!0}};h(ee,"zipSignature",[120,156]),h(ee,"sqLiteSignature",[83,81,76,105,116,101,32,102,111,114,109,97,116,32,51,0]);let xe=ee;class kt{constructor(e,t){h(this,"nextStrategy");this.name=e,this.manager=t}}class bi extends kt{constructor(t){super("long-polling strategy",t);h(this,"isClosed");h(this,"csrfToken");h(this,"shortestTimeoutMs",6e4);h(this,"timeOpened",null);h(this,"abortController");this.isClosed=!1}open(){this.isClosed=!1,this.abortController=new AbortController,this.timeOpened=performance.now();let t=[["content-type","text/json"]];t.push(["x-token-pm",$]),this.csrfToken=$,t.push(["x-timeout",this.shortestTimeoutMs+""]);try{fetch("/servlet/registerLongpollingListener",{signal:this.abortController.signal,method:"POST",headers:t,body:JSON.stringify({})}).then(i=>{if(i.status!=200){console.log(`Long-polling listener got http-status: ${i.status} (${i.statusText})`);let n=Math.round(performance.now()-this.timeOpened)-4e3;n<this.shortestTimeoutMs&&(this.shortestTimeoutMs=n)}switch(i.status){case 200:i.json().then(n=>{this.manager.onMessage(n)}),this.reopen();break;case 502:case 504:this.reopen(1e3,!1);break;default:this.reopen(1e4,!1);break}}).catch(i=>{console.log(`Long-polling listener failed due to reason: ${i}`),this.reopen(1e4,!1)}).finally(()=>{this.abortController=null})}catch{this.reopen(1e4,!1)}}reopen(t=500,i=!0){this.isClosed||(t>500&&console.log(`Reopen long-polling listener in ${t/1e3} seconds...`),setTimeout(()=>{this.isClosed||this.open()},t))}async close(){var i;this.isClosed=!0,(i=this.abortController)==null||i.abort();let t=[["content-type","text/json"]];t.push(["x-token-pm",this.csrfToken]),await fetch("/servlet/unregisterLongpollingListener",{method:"POST",headers:t,body:JSON.stringify({})})}}class wi extends kt{constructor(t){super("websocket strategy",t);h(this,"csrfToken");h(this,"websocket");h(this,"isClosed");h(this,"openedTimestamp");h(this,"currentTimer")}open(){this.isClosed=!1;try{let t=(window.location.protocol.startsWith("https")?"wss://":"ws://")+window.location.host+"/servlet/pushWebsocket?csrfToken="+$;this.websocket=new WebSocket(t),this.websocket.onopen=i=>{this.openedTimestamp=performance.now()},this.websocket.onclose=i=>{console.log("Websocket has been closed, code: "+i.code+", reason: "+i.reason),this.isClosed=!0,i.code==1001&&performance.now()-this.openedTimestamp>1e4?(console.log("Reason was timeout, dt > 10s => Reopen!"),this.open()):(this.manager.onStrategyFailed(this),this.isClosed=!0)},this.websocket.onerror=i=>{console.log("Error on websocket, type: "+i.type),this.websocket.close(),this.manager.onStrategyFailed(this),this.isClosed=!0},this.websocket.onmessage=i=>{if(i.data=="pong")return;const n=JSON.parse(i.data);this.manager.onMessage(n)},this.currentTimer!=null&&clearTimeout(this.currentTimer),this.doPing()}catch{this.manager.onStrategyFailed(this),this.isClosed=!0}}doPing(){this.currentTimer=setTimeout(()=>{this.isClosed?this.currentTimer=null:(this.websocket.send("ping"),this.doPing())},25e3)}async close(){this.isClosed=!0,this.websocket.close()}}class ki{constructor(e){h(this,"strategies",[]);h(this,"currentStrategy");h(this,"eventTypeToSubscriberInfoMap",new Map);this.baseURL=e,this.strategies=[new wi(this),new bi(this)];for(let t=this.strategies.length-2;t>=0;t--)this.strategies[t].nextStrategy=this.strategies[t+1]}subscribe(e,t){this.eventTypeToSubscriberInfoMap.set(e,{eventType:e,handler:t})}unsubscribe(e){this.eventTypeToSubscriberInfoMap.delete(e)}open(){this.currentStrategy==null&&(this.currentStrategy=this.strategies[0],console.log(`Opening ${this.currentStrategy.name}`),this.currentStrategy.open())}onMessage(e){var t;for(let i of e){if(i.eventType=="keepAlive")return;(t=this.eventTypeToSubscriberInfoMap.get(i.eventType))==null||t.handler(i.data)}}onStrategyFailed(e){if(e!=this.currentStrategy)return;let t=this.currentStrategy;this.currentStrategy=this.currentStrategy.nextStrategy;let i=`${t.name} failed. `;this.currentStrategy!=null?(i+=`=> Trying ${this.currentStrategy.name} in 3 seconds...`,setTimeout(()=>{console.log(`Opening ${this.currentStrategy.name}`),this.currentStrategy.open()},3e3)):i+="It was the last resort, unfortunately this client has no means to receive push-messages from server.",console.log(i)}close(){this.currentStrategy!=null&&(this.currentStrategy.close(),this.currentStrategy=null)}}const F=class F extends ki{static subscribe(e,t){F.getInstance().subscribe(e,t)}static unsubscribe(e){F.getInstance().unsubscribe(e)}static getInstance(){return F.instance==null&&(F.instance=new F("")),F.instance}};h(F,"instance");let N=F;class vi{constructor(e,t){h(this,"timerhandle");h(this,"ownUpdateFrequencyInSeconds",20);h(this,"teacherUpdateFrequencyInSeconds",5);h(this,"updateFrequencyInSeconds",20);h(this,"forcedUpdateEvery",4);h(this,"counterTillForcedUpdate",2);h(this,"secondsTillNextUpdate",this.updateFrequencyInSeconds);h(this,"errorHappened",!1);h(this,"interval");this.main=e,this.$updateTimerDiv=t}initializeTimer(){let e=this;this.$updateTimerDiv.find("svg").attr("width",e.updateFrequencyInSeconds),this.interval!=null&&clearInterval(this.interval),this.interval=setInterval(()=>{if(e.main.user==null)return;if(e.secondsTillNextUpdate--,e.secondsTillNextUpdate<0){e.secondsTillNextUpdate=e.updateFrequencyInSeconds,this.counterTillForcedUpdate--;let i=this.counterTillForcedUpdate==0;i&&(this.counterTillForcedUpdate=this.forcedUpdateEvery),e.sendUpdates(()=>{},i)}let t=this.$updateTimerDiv.find(".jo_updateTimerRect");t.attr("width",e.secondsTillNextUpdate+"px"),e.errorHappened?(t.css("fill","#c00000"),this.$updateTimerDiv.attr("title","Fehler beim letzten Speichervorgang -> Werd's wieder versuchen")):(t.css("fill","#008000"),this.$updateTimerDiv.attr("title",e.secondsTillNextUpdate+" Sekunden bis zum nächsten Speichern"))},1e3)}sendUpdates(e,t=!1){var l;if(this.main.user==null)return;this.main.projectExplorer.writeEditorTextToFile(),this.main.userDataDirty&&(this.main.userDataDirty=!1,this.sendUpdateUserSettings(()=>{}));let i=[],n=[];for(let d of this.main.workspaceList){d.saved||(i.push(d.getWorkspaceData(!1)),d.saved=!0);for(let u of d.moduleStore.getModules(!1))u.file.saved||(u.file.text=u.getProgramTextFromMonacoModel(),n.push(u.getFileData(d)),u.file.saved=!0)}let r={workspacesWithoutFiles:i,files:n,owner_id:this.main.workspacesOwnerId,userId:this.main.user.id,language:1,currentWorkspaceId:(l=this.main.getCurrentWorkspace())==null?void 0:l.id,getModifiedWorkspaces:!1},o=this;if(i.length>0||n.length>0||t)D("sendUpdates",r,d=>{if(o.errorHappened=!d.success,!o.errorHappened&&(o.updateWorkspaces(r,d),e!=null)){e();return}},()=>{o.errorHappened=!0});else if(e!=null){e();return}}initializeSSE(){N.subscribe("doFileUpdate",e=>{let t=this.main.workspaceList.slice();this.sendUpdates(()=>{let i=this.main.workspaceList.filter(n=>t.indexOf(n)<0).map(n=>n.name).join(", ");alert(`Deine Lehrkraft hat Dir folgende Datenbank übermittelt: ${i}`)},!0)})}sendCreateWorkspace(e,t,i){if(this.main.user.is_testuser){e.id=Math.round(Math.random()*1e7),i(null);return}let n={type:"create",entity:"workspace",data:e,owner_id:t,userId:this.main.user.id};D("createOrDeleteFileOrWorkspace",n,r=>{e.id=r.id,i(null)},i)}getDatabaseSettings(e,t){D("getDatabaseSettings",{workspaceId:e},n=>{t(n)},n=>{alert(n)})}setNewSecret(e,t,i){D("setNewSecret",{workspaceId:e,secretKind:t},r=>{i(r.secret)},r=>{alert(r)})}setNameAndPublishedTo(e,t,i,n,r){D("setPublishedTo",{workspaceId:e,databaseName:t,publishedTo:i,description:n},l=>{r()},l=>{alert(l)})}sendCreateFile(e,t,i,n){let o={type:"create",entity:"file",data:e.getFileData(t),owner_id:i,userId:this.main.user.id};D("createOrDeleteFileOrWorkspace",o,l=>{e.file.id=l.id,n(null)},n)}sendDuplicateWorkspace(e,t){let i={workspace_id:e.id,language:1};D("duplicateWorkspace",i,n=>{t(n.message,n.workspace)},t)}sendDistributeWorkspace(e,t,i,n){let r=()=>{new Pe().uploadCurrentDatabase(e.id,this.main,null,"distributeWorkspace",o=>{this.sendUpdates(()=>{let l={workspace_id:e.id,database_as_template_id:o.newTemplateId,class_id:t==null?void 0:t.id,student_ids:i};D("distributeWorkspace",l,d=>{n(d.message)},n)},!1)})};this.main.projectExplorer.setWorkspaceActive(e,r)}sendDeleteWorkspaceOrFile(e,t,i){let n={type:"delete",entity:e,id:t,userId:this.main.user.id};D("createOrDeleteFileOrWorkspace",n,r=>{r.success?i(null):i("Netzwerkfehler!")},i)}sendUpdateUserSettings(e){var i;let t={settings:this.main.user.settings,userId:this.main.user.id,current_workspace_id:(i=this.main.getCurrentWorkspace())==null?void 0:i.id};D("updateUserSettings",t,n=>{n.success?e(null):e("Netzwerkfehler!")},e)}getNewStatements(e,t){let i={workspaceId:e.id,version_before:e.database.version};D("getNewStatements",i,n=>{n.success&&t(n.newStatements,n.firstNewStatementIndex)})}AddDatabaseStatements(e,t,i){let n={workspaceId:e.id,version_before:e.database.version,statements:t};D("addDatabaseStatements",n,r=>{r.success&&i(r.statements_before,r.new_version)})}fetchDatabase(e,t){let i=new gi,n={workspaceId:e.id};D("getDatabase",n,r=>{if(r.success){if(e.database=Ke.fromDatabaseData(r.database,r.version),e.databaseId=e.database.id,e.database.based_on_template_id==null){t(null);return}i.fetchTemplateFromCache(e.database.based_on_template_id,o=>{if(xe.isZipfile(o))try{e.database.templateDump=H.inflate(o)}catch(l){console.log(l),console.log("Dump seems not to be compressed..."),e.database.templateDump=o}else e.database.templateDump=o;if(xe.isSqLiteFile(e.database.templateDump)){t(null);return}else this.fetchTemplate(e.id,(l,d)=>{if(l!=null){i.saveTemplateToCache(e.database.based_on_template_id,l),e.database.templateDump=H.inflate(l),t(null);return}else{e.database.templateDump=null,t(d);return}})})}else t("Netzwerkfehler!")},r=>{t("Netzwerkfehler: "+r)})}fetchTemplate(e,t){let i={workspaceId:e},n={};$!=null&&(n={"x-token-pm":$}),c.ajax({type:"POST",async:!0,data:JSON.stringify(i),contentType:"application/json",url:"servlet/getTemplate",headers:n,xhrFields:{responseType:"arraybuffer"},success:function(r){t(new Uint8Array(r))},error:function(r,o){t(null,"Konnte das Template nicht laden.")}})}fetchTemplateList(e){let t={user_id:this.main.user.id};D("getTemplateList",t,i=>{i.success?e(i.templateList):e([])},i=>{alert(i),e([])})}updateWorkspaces(e,t){let i=new Map,n=[];e.files.forEach(o=>n.push(o.id)),t.workspaces.workspaces.forEach(o=>i.set(o.id,o));let r=[];for(let o of t.workspaces.workspaces)this.main.workspaceList.filter(d=>d.id==o.id).length==0&&(r.push(o.name),this.createNewWorkspaceFromWorkspaceData(o));for(let o of this.main.workspaceList){let l=i.get(o.id);if(l!=null){let d=new Map;l.files.forEach(m=>d.set(m.id,m));let u=new Map;for(let m of o.moduleStore.getModules(!1)){let f=m.file.id;u.set(f,m);let p=d.get(f);p==null?(this.main.projectExplorer.fileListPanel.removeElement(m),this.main.currentWorkspace.moduleStore.removeModule(m)):p.version>m.file.version&&((n.indexOf(f)<0||p.forceUpdate)&&(m.file.text=p.text,m.model.setValue(p.text),m.file.saved=!0,m.lastSavedVersionId=m.model.getAlternativeVersionId()),m.file.version=p.version)}for(let m of l.files)u.get(m.id)==null&&this.createFile(o,m)}}this.main.projectExplorer.workspaceListPanel.sortElements(),this.main.projectExplorer.fileListPanel.sortElements()}createNewWorkspaceFromWorkspaceData(e,t=!1){let i=this.main.createNewWorkspace(e.name,e.owner_id);i.id=e.id,i.sql_history="",i.path=e.path,i.isFolder=e.isFolder,this.main.workspaceList.push(i);let n=e.path.split("/");n.length==1&&n[0]==""&&(n=[]);let r={name:e.name,externalElement:i,iconClass:"workspace",isFolder:e.isFolder,path:n};this.main.projectExplorer.workspaceListPanel.addElement(r,!0),i.panelElement=r;for(let o of e.files)this.createFile(i,o);t&&(this.main.projectExplorer.workspaceListPanel.sortElements(),this.main.projectExplorer.fileListPanel.sortElements())}createFile(e,t){let i=null;e==this.main.currentWorkspace&&(i={name:t.name,externalElement:null},this.main.projectExplorer.fileListPanel.addElement(i,!0));let n={id:t.id,name:t.name,dirty:!1,saved:!0,text:t.text,version:t.version,identical_to_repository_version:!0,workspace_id:e.id,panelElement:i},r=this.main.projectExplorer.getNewModule(n);i!=null&&(i.externalElement=r),e.moduleStore.putModule(r)}rollback(e){let t=this.main.currentWorkspace,i={workspaceId:t.id,version:t.database.version};D("rollback",i,n=>{n.success?e(null,t.database.version>n.new_version):(alert(n.message),e(n.message,!1))},n=>{alert(n),e(n,!1)})}}const yi=""+new URL("assets/sqljsWorker-CGIvyKli.js",import.meta.url).href;function we(a,e){const t=new a.Database(e);return t.create_function("isDate",function(i){if(i==null)return!0;if(typeof i!="string")return!1;var n=/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/;if(i.match(n)){var r=i.split("/"),o=i.split("-"),l=r.length,d=o.length;if(l>1)var u=i.split("/");else if(d>1)var u=i.split("-");if(u.length!=3)return!1;var m=parseInt(u[2]),f=parseInt(u[1]),p=parseInt(u[0]),b=[31,28,31,30,31,30,31,31,30,31,30,31];if((f==1||f>2)&&m>b[f-1])return!1;if(f==2){var k=!1;return(!(p%4)&&p%100||!(p%400))&&(k=!0),!(k==!1&&m>=29||k==!0&&m>29)}return!0}else return!1}),t.create_function("isDateTime",function(i){if(i==null)return!0;if(typeof i!="string")return!1;var n=/^\d{4}[\-](0[1-9]|1[012])[\-](0[1-9]|[12][0-9]|3[01]) ([01][1-9]|2[0123]):([0-5][0-9]):([0-5][0-9])$/;if(i.match(n)){var r=i.split(" "),o=r[0];if(o.length!=10)return!1;var l=parseInt(o.substring(8,10)),d=parseInt(o.substring(5,7)),u=parseInt(o.substring(0,4)),m=[31,28,31,30,31,30,31,31,30,31,30,31];if((d==1||d>2)&&l>m[d-1])return!1;if(d==2){var f=!1;return(!(u%4)&&u%100||!(u%400))&&(f=!0),!(f==!1&&l>=29||f==!0&&l>29)}return!0}else return!1}),t.create_function("month",function(i){var n=/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/;let r=i.match(n);return r?Number(r[1]):-1}),t.create_function("day",function(i){var n=/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/;let r=i.match(n);return r?Number(r[2]):-1}),t.create_function("year",function(i){var n=/^(\d{4})[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/;let r=i.match(n);return r?Number(r[1]):-1}),t.create_function("isTime",function(i){if(i==null)return!0;if(typeof i!="string")return!1;var n=/^([01][0-9]|2[0123]):([0-5][0-9]):([0-5][0-9])$/;return i.match(n)!=null}),t.create_function("concat",function(i){if(arguments==null)return"";let n="";for(let r=0;r<arguments.length;r++)n+=""+arguments[r];return n}),t}const Ci={},xi=Object.freeze(Object.defineProperty({__proto__:null,default:Ci},Symbol.toStringTag,{value:"Module"})),kn=ci(xi);class Si{constructor(){h(this,"initsql",Ft({locateFile:(e,t)=>Nt}));h(this,"db");h(this,"SQL");h(this,"onmessage");h(this,"onError")}postMessageToClient(e){this.onmessage({data:e})}postMessage(e){let t=this;t.db==null?t.initsql.then(i=>{t.SQL=i,t.db=we(i,void 0),t.worker(e)}).catch(i=>(console.log(i),t.postMessageToClient({id:this.data.id,error:i.message}))):t.worker(e)}terminate(){}worker(e){var t,i,n=e.config?e.config:{};try{switch(e&&e.action){case"open":return t=e.buffer,this.db=we(this.SQL,t&&new Uint8Array(t)),this.postMessageToClient({id:e.id,ready:!0});case"exec":if(this.db===null&&(this.db=we(this.SQL,void 0)),!e.sql)throw"exec: Missing query string";return this.postMessageToClient({id:e.id,results:this.db.exec(e.sql,e.params,n)});case"each":this.db===null&&(this.db=we(this.SQL,void 0));var r=function(d){return this.postMessage({id:e.id,row:d,finished:!1})},o=function(){return this.postMessage({id:e.id,finished:!0})};return this.db.each(e.sql,e.params,r,o,n);case"export":t=this.db.export(),i={id:e.id,results:[{buffer:t}]};try{return this.postMessageToClient(i)}catch{return this.postMessageToClient(i)}case"close":return this.db&&this.db.close(),this.postMessageToClient({id:e.id});default:throw new Error("Invalid action : "+(e&&e.action))}}catch(l){return this.postMessageToClient({id:e.id,error:l.message})}}}class W{constructor(e){h(this,"databaseDirectoryEntries",null);h(this,"worker");h(this,"queryId",0);h(this,"querySuccessCallbacksMap",new Map);h(this,"queryErrorCallbackMap",new Map);h(this,"databaseStructure");this.main=e}initializeWorker(e,t,i,n){this.main.getWaitOverlay().show("Bitte warten, die Datenbank wird initialisiert..."),this.worker!=null&&this.worker.terminate(),performance.now(),window.jo_doc?this.worker=new Si:(this.worker=new Worker(new URL(""+new URL("assets/sqljsWorker-CGIvyKli.js",import.meta.url).href,import.meta.url),{type:"module"}),this.worker=new Worker(yi,{type:"module"}));let r=this,o=[];this.worker.onmessage=()=>{r.worker.onmessage=u=>{let m=u.data.id;if(u.data.error==null){let f=r.querySuccessCallbacksMap.get(m);f!=null&&f(u.data.results)}else{let f=r.queryErrorCallbackMap.get(m);f!=null&&f(u.data.error)}this.queryErrorCallbackMap.delete(m),this.querySuccessCallbacksMap.delete(m)},t==null&&(t=[]),t=t.slice(),t.unshift("PRAGMA foreign_keys = OFF;"),t.push("PRAGMA foreign_keys = ON;");let l=t.length,d=()=>{if(t.length>0){this.main.getWaitOverlay().setProgress(`${Math.round((1-t.length/l)*100)+" %"}`);let u=t.shift();r.executeQuery(u,m=>{d()},m=>{o.push("Error while setting up database: "+m+", query: "+u),console.log({error:"Error while setting up database: "+m,query:u}),console.log(),d()})}else i!=null&&i(o),r.retrieveDatabaseStructure(()=>{n&&n(),this.main.getWaitOverlay().hide()})};d()},this.worker.onerror=l=>{o.push("Worker error: "+l.error),console.log("Worker error: "+l.error)},this.worker.postMessage({id:r.queryId++,action:"open",buffer:e})}executeQuery(e,t,i){let n=this.queryId++;this.querySuccessCallbacksMap.set(n,t),this.queryErrorCallbackMap.set(n,i),this.worker.postMessage({id:n,action:"exec",sql:e,params:{}})}export(e,t){let i=this.queryId++;this.querySuccessCallbacksMap.set(i,n=>{e(n[0].buffer)}),this.queryErrorCallbackMap.set(i,t),this.worker.postMessage({id:i,action:"export",params:{}})}getDirectoryEntries(e){this.databaseDirectoryEntries!=null?e(this.databaseDirectoryEntries):c.getJSON("assets/databases/directory.json",function(t){e(t)})}retrieveDatabaseStructure(e){let t="SELECT name, sql, type FROM sqlite_master WHERE type='table' or type='view';",i=this;this.executeQuery(t,n=>{var d;let r="",o=(d=n[0])==null?void 0:d.values,l=o==null?void 0:o.map(u=>u[2]);o==null||o.forEach(u=>r+=`PRAGMA table_info("${u[0]}");
16
16
  PRAGMA foreign_key_list("${u[0]}");
17
17
  select count(*) from "${u[0]}";
18
18
 
19
- `),r!=""?this.executeQuery(r,u=>{i.databaseStructure=i.parseDatabaseStructure(n,u,l),e(i.databaseStructure)},u=>{console.log(u),i.databaseStructure={tables:[]},e(i.databaseStructure)}):(i.databaseStructure={tables:[]},e(i.databaseStructure))},n=>{console.log(n)})}parseDatabaseStructure(e,t,i){var o;this.databaseStructure={tables:[]};let n=new Map,r=0;for(let l=0;l<e[0].values.length;l++){let d=e[0].values[l][0],u=e[0].values[l][1],m={name:d,size:0,completeSQL:u,columns:[],type:i[l]};n.set(d.toLocaleLowerCase(),m),this.databaseStructure.tables.push(m);let f=t[r].values,p=null;t.length>r+1&&t[r+1].columns[0]=="id"&&(p=t[r+1].values,r++),r++;let b=t[r].values[0][0];r++,m.size=b,f.forEach(k=>{k[0];let g=k[1],w=k[2],y=k[3]==1,J=k[4],q=k[5]!=0,V=[];if(w.indexOf("Enum")>=0){let O=`"${g}" ${w} .* check\\("${g}" in \\((.*)\\)\\)`,Pe=new RegExp(O),Ke=u.match(Pe);Ke!=null&&(V=Ke[1].split(", "))}let G={name:g,isPrimaryKey:q,isAutoIncrement:q&&u.toLowerCase().indexOf("autoincrement")>=0,completeTypeSQL:w,enumValues:V,table:m,typeLengths:[],defaultValue:J,notNull:y};if(p!=null){let O=p.find(Pe=>Pe[3].toLocaleLowerCase()==g.toLocaleLowerCase());O!=null&&(G.referencesRawData=O)}m.columns.push(G)})}for(let l of this.databaseStructure.tables)for(let d of l.columns)if(d.referencesRawData!=null){let u=n.get((o=d.referencesRawData[2])==null?void 0:o.toLocaleLowerCase());if(u==null)continue;let m=u.columns.find(f=>f.name.toLocaleLowerCase()==d.referencesRawData[4].toLocaleLowerCase());d.references=m}return this.databaseStructure}static getDumpType(e){let t=[83,81,76,105,116,101],i=120,n=!0;for(let r=0;r<t.length;r++)if(t[r]!=e[r]){n=!1;break}return n?"binaryUncompressed":e[0]==i?"binaryCompressed":"other"}}class wt{constructor(e,t){h(this,"$dialog");this.main=e,this.workspace=t,this.init()}init(){this.$dialog=c("#dialog"),c("#main").css("visibility","hidden"),this.$dialog.append(c(`<div class="jo_ds_heading">Datenbank-Einstellungen</div>
19
+ `),r!=""?this.executeQuery(r,u=>{i.databaseStructure=i.parseDatabaseStructure(n,u,l),e(i.databaseStructure)},u=>{console.log(u),i.databaseStructure={tables:[]},e(i.databaseStructure)}):(i.databaseStructure={tables:[]},e(i.databaseStructure))},n=>{console.log(n),alert("Error retrieving database structure: "+n),i.databaseStructure={tables:[]},e(i.databaseStructure)})}parseDatabaseStructure(e,t,i){var o;this.databaseStructure={tables:[]};let n=new Map,r=0;for(let l=0;l<e[0].values.length;l++){let d=e[0].values[l][0],u=e[0].values[l][1],m={name:d,size:0,completeSQL:u,columns:[],type:i[l]};n.set(d.toLocaleLowerCase(),m),this.databaseStructure.tables.push(m);let f=t[r].values,p=null;t.length>r+1&&t[r+1].columns[0]=="id"&&(p=t[r+1].values,r++),r++;let b=t[r].values[0][0];r++,m.size=b,f.forEach(k=>{k[0];let g=k[1],w=k[2],y=k[3]==1,J=k[4],q=k[5]!=0,V=[];if(w.indexOf("Enum")>=0){let A=`"${g}" ${w} .* check\\("${g}" in \\((.*)\\)\\)`,Me=new RegExp(A),Ge=u.match(Me);Ge!=null&&(V=Ge[1].split(", "))}let G={name:g,isPrimaryKey:q,isAutoIncrement:q&&u.toLowerCase().indexOf("autoincrement")>=0,completeTypeSQL:w,enumValues:V,table:m,typeLengths:[],defaultValue:J,notNull:y};if(p!=null){let A=p.find(Me=>Me[3].toLocaleLowerCase()==g.toLocaleLowerCase());A!=null&&(G.referencesRawData=A)}m.columns.push(G)})}for(let l of this.databaseStructure.tables)for(let d of l.columns)if(d.referencesRawData!=null){let u=n.get((o=d.referencesRawData[2])==null?void 0:o.toLocaleLowerCase());if(u==null)continue;let m=u.columns.find(f=>f.name.toLocaleLowerCase()==d.referencesRawData[4].toLocaleLowerCase());d.references=m}return this.databaseStructure}static getDumpType(e){let t=[83,81,76,105,116,101],i=120,n=!0;for(let r=0;r<t.length;r++)if(t[r]!=e[r]){n=!1;break}return n?"binaryUncompressed":e[0]==i?"binaryCompressed":"other"}}class vt{constructor(e,t){h(this,"$dialog");this.main=e,this.workspace=t,this.init()}init(){this.$dialog=c("#dialog"),c("#main").css("visibility","hidden"),this.$dialog.append(c(`<div class="jo_ds_heading">Datenbank-Einstellungen</div>
20
20
  <div style="width: 100%; padding-left: 10px; box-sizing: border-box">
21
21
  <div class="jo_ds_settings" style="margin-left: 0px">
22
22
  <div class="jo_ds_settings_caption">Name der Datenbank:</div><div><input class="dialog-input jo_databasename" value="Neue Datenbank"></input></div>
@@ -76,7 +76,7 @@ select count(*) from "${u[0]}";
76
76
  <button id="jo_ds_cancel_button">Abbrechen</button>
77
77
  <button id="jo_ds_save_button">Speichern</button>
78
78
  </div>
79
- `));let e=this;this.$dialog.css("visibility","visible"),this.main.user.is_teacher||(c("#b2").next().remove(),c("#b2").remove()),this.main.user.is_admin||this.main.user.username=="DB-Vorlagen"||(c("#b3").next().remove(),c("#b3").remove()),c("#jo_ds_cancel_button").on("click",()=>{this.showMainWindow()}),c("#jo_ds_save_button").on("click",()=>{this.saveNameAndPublishedTo()}),this.setValues(),["read","write","ddl"].forEach(t=>{c(".jo_button_code_"+t).on("pointerdown",()=>{e.main.networkManager.setNewSecret(e.workspace.id,t,n=>{c(".jo_ds_secret_"+t).text(n)})});let i=c('<button class="jo_small_button jo_copy_secret_button jo_active">Kopieren</button>');c("#copySecretTd"+t).append(i),i.on("pointerdown",()=>{gt(c(".jo_ds_secret_"+t).text())})})}saveNameAndPublishedTo(){let e=0;c("#jo_ds_publishedTo").find("input").each((r,o)=>{let l=c(o);o.checked&&(e=Number.parseInt(l.attr("value")))});let t=c(".jo_databasename").val(),i=c(".jo_ds_settings_description").val();this.workspace.name=t,this.workspace.panelElement.$htmlFirstLine.find(".jo_filename").text(t),this.workspace.saved=!1;let n=this.workspace.database;this.main.networkManager.setNameAndPublishedTo(this.workspace.id,t,e,i,()=>{this.workspace.name=t,n.published_to==0&&e>0&&new Le().uploadCurrentDatabase(this.workspace.id,this.main,null,"publishDatabaseAsTemplate"),n.published_to=e,n.description=i,this.showMainWindow()})}setValues(){c(".jo_databasename").val(this.workspace.database.name),this.main.networkManager.getDatabaseSettings(this.workspace.id,e=>{let t=e.owner;!e.userIsOwner&&e.secrets!=null&&(t+=" (hat aber keinen mit der Datenbank verbundenen Workspace)"),c(".jo_ds_settings_owner").text(t),["read","write","ddl"].forEach(i=>{let n="---";e.secrets!=null&&(n=e.secrets[i]),c(".jo_ds_secret_"+i).text(n)}),(this.main.user.is_admin||this.main.user.username=="DB-Vorlagen")&&(c("#b3").css("visibility","visible"),c("#lb3").css("visibility","visible")),this.main.user.is_schooladmin&&(c("#b2").css("visibility","visible"),c("#lb2").css("visibility","visible")),c("#b"+e.publishedTo).prop("checked",!0),c("#jo_upload_db").prop("checked",e.publishedTo!=0),c(".jo_ds_settings_description").val(this.workspace.database.description),e.secrets==null?(this.$dialog.find("input, textarea").attr("readonly","").css("background-color","#888"),this.$dialog.find("#jo_ds_ownerSettings").hide(),this.$dialog.find("#jo_ds_save_button").hide()):(this.$dialog.find("input, textarea").removeAttr("readonly").css("background-color","#fff"),this.$dialog.find("#jo_ds_ownerSettings").show(),this.$dialog.find("#jo_ds_save_button").show())})}showMainWindow(){c("#main").css("visibility","visible"),this.$dialog.css("visibility","hidden"),this.$dialog.empty()}}class te{constructor(e,t,i){h(this,"name");h(this,"path","");h(this,"isFolder");h(this,"id");h(this,"owner_id");h(this,"version");h(this,"moduleStore");h(this,"panelElement");h(this,"currentlyOpenModule");h(this,"saved",!0);h(this,"compilerMessage");h(this,"databaseId");h(this,"database");h(this,"sql_history");h(this,"permissions");this.main=t,this.name=e,this.owner_id=i,this.moduleStore=new qe(t),this.sql_history=""}getWorkspaceData(e){let t={name:this.name,id:this.id,owner_id:this.owner_id,currentFileId:this.currentlyOpenModule==null?null:this.currentlyOpenModule.file.id,files:[],sql_history:this.sql_history,path:this.path,isFolder:!1,permissions:this.permissions,database_id:this.databaseId};if(e)for(let i of this.moduleStore.getModules(!1))t.files.push(i.getFileData(this));return t}renderSettingsButton(e){var r;let t=(r=e==null?void 0:e.$htmlFirstLine)==null?void 0:r.find(".jo_additionalButtonSettings");if(t==null)return;let i=c('<div class="jo_settingsButton img_settings jo_button jo_active" title="Datenbank-Einstellungen..."></div>');t.append(i);let n=this;i.on("pointerdown",o=>o.stopPropagation()),i.on("pointerup",o=>{o.stopPropagation(),new wt(n.main,n)}),i[0].addEventListener("contextmenu",o=>{o.preventDefault(),o.stopPropagation()},!1)}static restoreFromData(e,t){let i=new te(e.name,t,e.owner_id);i.id=e.id,i.path=e.path,i.isFolder=e.isFolder,i.owner_id=e.owner_id,i.sql_history=e.sql_history,i.permissions=e.permissions,i.databaseId=e.database_id;for(let n of e.files){let r=U.restoreFromData(n,t);i.moduleStore.putModule(r),n.id==e.currentFileId&&(i.currentlyOpenModule=r)}return i}hasErrors(){return this.moduleStore.hasErrors()}getModuleByMonacoModel(e){for(let t of this.moduleStore.getModules(!1))if(t.model==e)return t;return null}}class kt{constructor(e,t){h(this,"collapsedTables",new Map);this.main=e,this.$mainDiv=t}refresh(){this.main.getDatabaseTool().retrieveDatabaseStructure(t=>{this.refreshAfterRetrievingDBStructure()})}clear(){this.$mainDiv.empty()}refreshAfterRetrievingDBStructure(){let e=this.main.getDatabaseTool(),t=this.main.getCurrentWorkspace();if(t!=null)for(let n of t.moduleStore.getModules(!1))n.file.dirty=!0;let i=Z.fromTableStructureList(e.databaseStructure.tables);this.$mainDiv.empty();for(let n of i)if(n.identifier!="sqlite_sequence"){let r=this.renderTable(n);this.$mainDiv.append(r)}}renderTable(e){let t=this.collapsedTables.get(e.identifier)!=null,i=c(`<div class="jo_table">
79
+ `));let e=this;this.$dialog.css("visibility","visible"),this.main.user.is_teacher||(c("#b2").next().remove(),c("#b2").remove()),this.main.user.is_admin||this.main.user.username=="DB-Vorlagen"||(c("#b3").next().remove(),c("#b3").remove()),c("#jo_ds_cancel_button").on("click",()=>{this.showMainWindow()}),c("#jo_ds_save_button").on("click",()=>{this.saveNameAndPublishedTo()}),this.setValues(),["read","write","ddl"].forEach(t=>{c(".jo_button_code_"+t).on("pointerdown",()=>{e.main.networkManager.setNewSecret(e.workspace.id,t,n=>{c(".jo_ds_secret_"+t).text(n)})});let i=c('<button class="jo_small_button jo_copy_secret_button jo_active">Kopieren</button>');c("#copySecretTd"+t).append(i),i.on("pointerdown",()=>{wt(c(".jo_ds_secret_"+t).text())})})}saveNameAndPublishedTo(){let e=0;c("#jo_ds_publishedTo").find("input").each((r,o)=>{let l=c(o);o.checked&&(e=Number.parseInt(l.attr("value")))});let t=c(".jo_databasename").val(),i=c(".jo_ds_settings_description").val();this.workspace.name=t,this.workspace.panelElement.$htmlFirstLine.find(".jo_filename").text(t),this.workspace.saved=!1;let n=this.workspace.database;this.main.networkManager.setNameAndPublishedTo(this.workspace.id,t,e,i,()=>{this.workspace.name=t,n.published_to==0&&e>0&&new Pe().uploadCurrentDatabase(this.workspace.id,this.main,null,"publishDatabaseAsTemplate"),n.published_to=e,n.description=i,this.showMainWindow()})}setValues(){c(".jo_databasename").val(this.workspace.database.name),this.main.networkManager.getDatabaseSettings(this.workspace.id,e=>{let t=e.owner;!e.userIsOwner&&e.secrets!=null&&(t+=" (hat aber keinen mit der Datenbank verbundenen Workspace)"),c(".jo_ds_settings_owner").text(t),["read","write","ddl"].forEach(i=>{let n="---";e.secrets!=null&&(n=e.secrets[i]),c(".jo_ds_secret_"+i).text(n)}),(this.main.user.is_admin||this.main.user.username=="DB-Vorlagen")&&(c("#b3").css("visibility","visible"),c("#lb3").css("visibility","visible")),this.main.user.is_schooladmin&&(c("#b2").css("visibility","visible"),c("#lb2").css("visibility","visible")),c("#b"+e.publishedTo).prop("checked",!0),c("#jo_upload_db").prop("checked",e.publishedTo!=0),c(".jo_ds_settings_description").val(this.workspace.database.description),e.secrets==null?(this.$dialog.find("input, textarea").attr("readonly","").css("background-color","#888"),this.$dialog.find("#jo_ds_ownerSettings").hide(),this.$dialog.find("#jo_ds_save_button").hide()):(this.$dialog.find("input, textarea").removeAttr("readonly").css("background-color","#fff"),this.$dialog.find("#jo_ds_ownerSettings").show(),this.$dialog.find("#jo_ds_save_button").show())})}showMainWindow(){c("#main").css("visibility","visible"),this.$dialog.css("visibility","hidden"),this.$dialog.empty()}}class ie{constructor(e,t,i){h(this,"name");h(this,"path","");h(this,"isFolder");h(this,"id");h(this,"owner_id");h(this,"version");h(this,"moduleStore");h(this,"panelElement");h(this,"currentlyOpenModule");h(this,"saved",!0);h(this,"compilerMessage");h(this,"databaseId");h(this,"database");h(this,"sql_history");h(this,"permissions");this.main=t,this.name=e,this.owner_id=i,this.moduleStore=new Ue(t),this.sql_history=""}getWorkspaceData(e){let t={name:this.name,id:this.id,owner_id:this.owner_id,currentFileId:this.currentlyOpenModule==null?null:this.currentlyOpenModule.file.id,files:[],sql_history:this.sql_history,path:this.path,isFolder:!1,permissions:this.permissions,database_id:this.databaseId};if(e)for(let i of this.moduleStore.getModules(!1))t.files.push(i.getFileData(this));return t}renderSettingsButton(e){var r;let t=(r=e==null?void 0:e.$htmlFirstLine)==null?void 0:r.find(".jo_additionalButtonSettings");if(t==null)return;let i=c('<div class="jo_settingsButton img_settings jo_button jo_active" title="Datenbank-Einstellungen..."></div>');t.append(i);let n=this;i.on("pointerdown",o=>o.stopPropagation()),i.on("pointerup",o=>{o.stopPropagation(),new vt(n.main,n)}),i[0].addEventListener("contextmenu",o=>{o.preventDefault(),o.stopPropagation()},!1)}static restoreFromData(e,t){let i=new ie(e.name,t,e.owner_id);i.id=e.id,i.path=e.path,i.isFolder=e.isFolder,i.owner_id=e.owner_id,i.sql_history=e.sql_history,i.permissions=e.permissions,i.databaseId=e.database_id;for(let n of e.files){let r=U.restoreFromData(n,t);i.moduleStore.putModule(r),n.id==e.currentFileId&&(i.currentlyOpenModule=r)}return i}hasErrors(){return this.moduleStore.hasErrors()}getModuleByMonacoModel(e){for(let t of this.moduleStore.getModules(!1))if(t.model==e)return t;return null}}class yt{constructor(e,t){h(this,"collapsedTables",new Map);this.main=e,this.$mainDiv=t}refresh(){this.main.getDatabaseTool().retrieveDatabaseStructure(t=>{this.refreshAfterRetrievingDBStructure()})}clear(){this.$mainDiv.empty()}refreshAfterRetrievingDBStructure(){let e=this.main.getDatabaseTool(),t=this.main.getCurrentWorkspace();if(t!=null)for(let n of t.moduleStore.getModules(!1))n.file.dirty=!0;let i=Z.fromTableStructureList(e.databaseStructure.tables);this.$mainDiv.empty();for(let n of i)if(n.identifier!="sqlite_sequence"){let r=this.renderTable(n);this.$mainDiv.append(r)}}renderTable(e){let t=this.collapsedTables.get(e.identifier)!=null,i=c(`<div class="jo_table">
80
80
  <div class="jo_tableheader">
81
81
  <div class="${t?"img_tree-collapsed-dark":"img_tree-expanded-dark"} jo_treeswitch jo_button jo_active"></div>
82
82
  <div class="jo_tableheaderlink">
@@ -96,13 +96,13 @@ select count(*) from "${u[0]}";
96
96
  </div>
97
97
  `);r.append(g)}i.append(r);let o=i.find(".jo_treeswitch"),l=this;return o.on("pointerup",d=>{d.stopPropagation();let u=o.parents(".jo_table").find(".jo_columnlist");o.hasClass("img_tree-collapsed-dark")?(o.removeClass("img_tree-collapsed-dark"),o.addClass("img_tree-expanded-dark"),u.slideDown(300),l.collapsedTables.delete(e.identifier)):(o.removeClass("img_tree-expanded-dark"),o.addClass("img_tree-collapsed-dark"),u.slideUp(300),l.collapsedTables.set(e.identifier,!0))}),i}csvExport(e){let t="select * from "+e.identifier+";";this.main.getDatabaseTool().executeQuery(t,i=>{let n="";const r=i.pop();r&&(n+=r.columns.map(o=>`"${o}"`).join(",")+`
98
98
  `,n+=r.values.map(o=>o.map(l=>`"${l}"`).join(",")).join(`
99
- `)),ze("\uFEFF"+n,e.identifier+".csv",!1)},i=>{})}}class Ei{constructor(e){h(this,"isConsole");h(this,"triggerCharacters",[".","abcdefghijklmnopqrstuvwxyzäöüß_ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜ"," ",",","("]);h(this,"keywordCompletionItems",new Map);h(this,"first",!0);h(this,"keywordToSnippetMap",{"(":`(
99
+ `)),He("\uFEFF"+n,e.identifier+".csv",!1)},i=>{})}}class Ei{constructor(e){h(this,"isConsole");h(this,"triggerCharacters",[".","abcdefghijklmnopqrstuvwxyzäöüß_ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜ"," ",",","("]);h(this,"keywordCompletionItems",new Map);h(this,"first",!0);h(this,"keywordToSnippetMap",{"(":`(
100
100
  $0
101
101
  )`,varchar:"varchar($1) $0",decimal:"decimal($1, $2) $0"});this.main=e,this.setupKeywordCompletionItems()}provideCompletionItems(e,t,i,n){let r=this.main.getCurrentWorkspace().getModuleByMonacoModel(e);return r==null||r.mainSymbolTable==null?null:new Promise((o,l)=>{let d=this,u=function(){r.file.dirty?setTimeout(()=>{u()},100):o(d.provideCompletionItemsIntern(e,t,i,n))};u()})}provideCompletionItemsIntern(e,t,i,n){let r=this.main.getCurrentWorkspace().getModuleByMonacoModel(e);if(r==null||r.mainSymbolTable==null||this.isStringLiteral(r,t))return null;let o=e.getValueInRange({startLineNumber:1,startColumn:1,endLineNumber:t.lineNumber,endColumn:t.column}),l=e.getValueInRange({startLineNumber:t.lineNumber,startColumn:t.column,endLineNumber:t.lineNumber+5,endColumn:1}),d=r.mainSymbolTable.findTableAtPosition(t.lineNumber,t.column),u=r.getCompletionHint(t.lineNumber,t.column);u==null&&(u={fromColumn:0,toColumn:0,fromLine:0,toLine:0,hintColumns:!1,hintTables:!1,hintKeywords:[]});let m=[];this.addKeywordCompletionItems(u,m);let f=o.match(/.*\s([\wöäüÖÄÜß]*)(\.)([\wöäüÖÄÜß]*)$/),p=l.match(/^([\wöäüÖÄÜß]*)/),b="";p!=null&&p.length>0&&(b=p[0]),f==null?this.addIdentifierCompletionItems(u,d,m):this.addDotCompletionItems(t,f,b,d,m);let k=e.getWordUntilPosition(t),g={startColumn:k.startColumn,startLineNumber:t.lineNumber,endColumn:k.endColumn,endLineNumber:t.lineNumber},w={startColumn:t.column,startLineNumber:t.lineNumber,endColumn:t.column,endLineNumber:t.lineNumber};for(let y of m)y.range==null&&(y.insertText.startsWith(",")?y.range=w:y.range=g);return u.dontHint!=null&&(m=m.filter(y=>u.dontHint.indexOf(y.insertText)<0)),{suggestions:m}}addDotCompletionItems(e,t,i,n,r){let o=t[3],l=t[1];e.column-o.length-1;let d={startLineNumber:e.lineNumber,startColumn:e.column-o.length,endLineNumber:e.lineNumber,endColumn:e.column+i.length};for(let u of n.symbolList)if(u.table!=null){let m=u.table.identifier;if(u.tableAlias!=null&&(m=u.tableAlias),m.toLowerCase()==l)for(let f of u.table.columns)r.push({label:f.identifier,detail:"Spalte "+f.identifier+" der Tabelle "+u.table.identifier,filterText:f.identifier,insertText:f.identifier,insertTextRules:C.CompletionItemInsertTextRule.KeepWhitespace,kind:C.CompletionItemKind.Field,range:d})}}addIdentifierCompletionItems(e,t,i){var m,f;let n=e.praefix==null?"":e.praefix,r=e.suffix==null?"":e.suffix;if(!(e.hintTables||e.hintColumns))return;let o={},l=t,d={},u=[];for(;l!=null;){for(let p of l.symbolList)if(p.column!=null){let b=p.column.identifier;d[b]==null?(d[b]=[p],u.push(b)):d[b].push(p)}else if(p.table!=null&&e.hintTables&&!o[p.identifier]){let b=n+p.identifier+r;i.push({label:p.identifier,detail:"Tabelle "+p.table.identifier,filterText:p.identifier,insertText:b,insertTextRules:b.indexOf("$")>=0?C.CompletionItemInsertTextRule.InsertAsSnippet:C.CompletionItemInsertTextRule.KeepWhitespace,kind:b.indexOf("$")>=0?C.CompletionItemKind.Snippet:C.CompletionItemKind.Class,range:void 0,sortText:"aa"+p.identifier}),o[p.identifier]=!0}l=l.parent}if(e.hintColumns)for(let p of u){let b=d[p],k=b.length>1&&e.hintColumnsOfTable==null;for(let g of b){let w=g.identifier;if(k&&g.identifier==g.column.identifier.toLowerCase()&&(w=(g.tableAlias==null?g.column.table.identifier:g.tableAlias)+"."+w),e.hintColumnsOfTable==null||((f=(m=g.column)==null?void 0:m.table)==null?void 0:f.identifier)==e.hintColumnsOfTable){let y=n+w+r;i.push({label:w,detail:"Die Spalte "+g.column.identifier+" der Tabelle "+g.column.table.identifier,filterText:w,insertText:y,insertTextRules:y.indexOf("$")>=0?C.CompletionItemInsertTextRule.InsertAsSnippet:C.CompletionItemInsertTextRule.KeepWhitespace,kind:y.indexOf("$")>=0?C.CompletionItemKind.Snippet:C.CompletionItemKind.Field,range:void 0})}}}}addKeywordCompletionItems(e,t){let i=e.praefix==null?"":e.praefix,n=e.suffix==null?"":e.suffix;for(let r of e.hintKeywords){let o=i+r+n,l=this.keywordToSnippetMap[r],d=this.keywordCompletionItems.get(r);if(d!=null)t.push(d);else if(l!=null){let u=l.replace("$0","").replace("$1","").replace("$2","").replace(/ /g,"").replace(/\n/g,"").replace(/\t/g,"");t.push({label:u,detail:"",filterText:r,insertText:l,insertTextRules:C.CompletionItemInsertTextRule.InsertAsSnippet,kind:C.CompletionItemKind.Snippet,range:void 0})}else t.push({label:r,detail:"",filterText:r,insertText:r,insertTextRules:o.indexOf("$")>=0?C.CompletionItemInsertTextRule.InsertAsSnippet:C.CompletionItemInsertTextRule.KeepWhitespace,kind:o.indexOf("$")>=0?C.CompletionItemKind.Snippet:C.CompletionItemKind.Keyword,range:void 0,sortText:r=="from"?"*":void 0})}}isStringLiteral(e,t){let i=e.tokenList;if(i==null||i.length==0)return!1;let n=0,r=i.length-1,o,l=1e3;for(;;){let d=o;if(o=Math.round((r+n)/2),d==o||(l--,l==0))return!1;let u=i[o],m=u.position;if(m.line<t.lineNumber||m.line==t.lineNumber&&m.column+m.length<t.column){n=o;continue}if(m.line>t.lineNumber||m.line==t.lineNumber&&m.column>t.column){r=o;continue}return u.tt==s.stringConstant}}setupKeywordCompletionItems(){this.keywordCompletionItems.set("delete from",{label:"delete from <Tabelle> where <Bedingung>",detail:"Anweisung zum Löschen von Datensätzen",filterText:"delete from",insertText:"delete from ",command:{id:"editor.action.triggerSuggest",title:"123",arguments:[]},insertTextRules:C.CompletionItemInsertTextRule.InsertAsSnippet,kind:C.CompletionItemKind.Snippet,range:void 0}),this.keywordCompletionItems.set("drop table",{label:"drop table <Tabelle>",detail:"Anweisung zum Löschen einer Tabelle",filterText:"drop table",insertText:"drop table ",command:{id:"editor.action.triggerSuggest",title:"123",arguments:[]},kind:C.CompletionItemKind.Snippet,range:void 0}),this.keywordCompletionItems.set("alter",{label:"alter table <Tabelle> <rename to, rename column, add column, drop column>",detail:"Anweisung zum Ändern des Schemas (alter table <Tabelle> <rename to, rename column, add column, drop column>)",filterText:"alter",insertText:"alter table ",command:{id:"editor.action.triggerSuggest",title:"123",arguments:[]},kind:C.CompletionItemKind.Snippet,range:void 0}),this.keywordCompletionItems.set("select",{label:"select <Spalten> from <Tabellen> where <Bedingung>",detail:"Select-Anweisung",filterText:"select",insertText:`select * from $1
102
102
  where $0
103
103
  `,command:{id:"editor.action.triggerSuggest",title:"123",arguments:[]},insertTextRules:C.CompletionItemInsertTextRule.InsertAsSnippet,kind:C.CompletionItemKind.Snippet,range:void 0}),this.keywordCompletionItems.set("create table",{label:"create table <Tabellenbezeichner> (<Spaltendefinitionen>)",detail:"Create table-Anweisung (Erstellt eine neue Tabelle)",filterText:"create",insertText:`create table $1 (
104
104
  $0
105
- );`,command:{id:"editor.action.triggerSuggest",title:"123",arguments:[]},insertTextRules:C.CompletionItemInsertTextRule.InsertAsSnippet,kind:C.CompletionItemKind.Snippet,range:void 0})}}class Di{constructor(e){h(this,"signatureHelpTriggerCharacters",["(",",",";","<",">","="]);h(this,"signatureHelpRetriggerCharacters",[]);this.main=e}provideSignatureHelp(e,t,i,n){let r=this;return new Promise((o,l)=>{setTimeout(()=>{this.main.compileIfDirty(),o(r.provideSignatureHelpLater(e,t,i,n))},300)})}provideSignatureHelpLater(e,t,i,n){e!=this.main.getMonacoEditor().getModel();let r=this.main.getCurrentWorkspace().getModuleByMonacoModel(e);if(r==null)return null;let o=r.methodCallPositions[t.lineNumber];if(o==null)return null;let l=null,d=-1;for(let u=o.length-1;u>=0;u--){let m=o[u];m.identifierPosition.column+m.identifierPosition.length<t.column&&m.identifierPosition.column>d&&(m.rightBracketPosition==null||t.lineNumber<=m.rightBracketPosition.line&&t.column<=m.rightBracketPosition.column||t.lineNumber<m.rightBracketPosition.line)&&(l=m,d=m.identifierPosition.column)}return l==null?null:this.getSignatureHelp(l,t)}getSignatureHelp(e,t){let i=0;for(let r of e.commaPositions)(r.line<t.lineNumber||r.line==t.lineNumber&&r.column<t.column)&&i++;let n=[];return Promise.resolve({value:{activeParameter:i,activeSignature:0,signatures:n},dispose:()=>{}})}}const _e=class _e{constructor(e){this.editor=e}provideHover(e,t,i){var l;let n=this.editor.editor.getSelection();if(n!=null&&(n.startLineNumber!=n.endLineNumber||n.startColumn!=n.endColumn)&&(n.startLineNumber<t.lineNumber||n.startLineNumber==t.lineNumber&&n.startColumn<=t.column)&&(n.endLineNumber>t.lineNumber||n.endLineNumber==t.lineNumber&&n.endColumn>=t.column))return;let r=(l=this.editor.main.getCurrentWorkspace())==null?void 0:l.getModuleByMonacoModel(e);if(r==null)return null;for(let d of r.errors)for(let u of d)if(u.position.line==t.lineNumber&&u.position.column<=t.column&&u.position.column+u.position.length>=t.column)return null;if(r.getElementAtPosition(t.lineNumber,t.column)==null){let d=this.getWordUnderCursor(e,t),u=_e.keywordDescriptions[d];if(u!=null)return{range:null,contents:[{value:u}]}}}getWordUnderCursor(e,t){let i=e.getValueLengthInRange({startColumn:0,startLineNumber:0,endLineNumber:t.lineNumber,endColumn:t.column}),n=e.getValue(),r="",o=i;for(;o<n.length&&this.isInsideIdentifierOrArrayDescriptor(n.charAt(o));)o++;let l=i;for(;l>0&&this.isInsideIdentifierOrArrayDescriptor(n.charAt(l-1));)l--;if(o-l>1)r=n.substring(l,o);else{for(o=i;o<n.length&&this.isInsideOperator(n.charAt(o));)o++;for(l=i;l>0&&this.isInsideOperator(n.charAt(l-1));)l--;o-l>0&&(r=n.substring(l,o))}return r}widenDeclaration(e,t,i){let n=e.getValueLengthInRange({startColumn:0,startLineNumber:0,endLineNumber:t.lineNumber,endColumn:t.column}),r=e.getValue(),o=n;for(;o<r.length&&this.isInsideIdentifierOrArrayDescriptor(r.charAt(o));)o++;let l=n;for(;l>0&&this.isInsideIdentifierChain(r.charAt(l-1));)l--;return(i==null?void 0:i.length)==null||i.length,o-l>length?r.substring(l,o):i}isInsideIdentifierChain(e){return e.toLocaleLowerCase().match(/[a-z0-9äöüß_\[\]\.]/i)}isInsideOperator(e){return e.toLocaleLowerCase().match(/[!%<>=\+\-\*\/]/i)}isInsideIdentifierOrArrayDescriptor(e){return e.toLocaleLowerCase().match(/[a-z0-9äöüß\[\]]/i)}};h(_e,"keywordDescriptions",{select:"```\nselect spalte1, spalte2, ..., spalteN from tabelle where <Bedingung>\n``` \nsucht alle Zeilen der Tabelle, die der Bedingung genügen (**Selektion**) und gibt davon die angegebenen Spalten aus (**Projektion**). Das Ergebnis der ```select```-Anweisung ist wieder eine Tabelle. \n ",from:"```\nselect spalte1, spalte2, ..., spalteN from tabelle where <Bedingung>\n``` \nsucht alle Zeilen der Tabelle, die der Bedingung genügen (**Selektion**) und gibt davon die angegebenen Spalten aus (**Projektion**). Das Ergebnis der ```select```-Anweisung ist wieder eine Tabelle. \n ",where:"```\n... where <Bedingung>\n``` \nHinter ```where``` steht immer eine Bedingung, d.h. ein Term mit booleschem Wert (```true``` oder ```false```). Die Anweisung wird für alle Zeilen ausgeführt, die der Bedingung genügen, d.h. für die der Term den Wert ```true``` ergibt. \n ",delete:"```\ndelete from tabelle where <Bedingung>\n``` \nlöscht alle Zeilen der Tabelle, die der Bedingung genügen. \n ",insert:"```\ninsert (spalte1, spalte2, ..., spalteN) into tabelle values (Wert1, ..., WertN), (Wert1, ..., WertN), ... \n``` \nFügt Datensätze in eine Tabelle ein. Die Werte ```wert1, ..., wertN``` müssen den angegebenen Spalten ```Spalte1, ..., SpalteN``` entsprechen.\n ",values:"```\ninsert (spalte1, spalte2, ..., spalteN) into tabelle values (Wert1, ..., WertN), (Wert1, ..., WertN), ... \n``` \nFügt Datensätze in eine Tabelle ein. Die Werte ```wert1, ..., wertN``` müssen den angegebenen Spalten ```Spalte1, ..., SpalteN``` entsprechen.\n ",update:"```\nupdate tabelle set Spalte1 = Wert1, Spalte2 = Wert2, ..., SpalteN = WertN where <Bedingung> \n``` \nÄndert in allen Datensätze der Tabelle, die der Bedingung genügen, die Werte in den angegebenen Spalten ```Spalte1, ..., SpalteN```.\n ","%":"```\na % b\n``` \n (sprich: 'a modulo b') berechnet den **Rest** der ganzzahligen Division a/b.","=":"```\na = b\n``` \nergibt genau dann ```true```, wenn ```a``` und ```b``` gleich sind. \n```=``` nennt man **Vergleichsoperator**. \n\n**Tipp:** In SQL gibt es auch einen **Ungleich-Operator**: ```<>```","<=":"```\na <= b\n``` \nergibt genau dann ```true```, wenn der Wert von ```a``` kleiner oder gleich dem Wert von ```b``` ist.",">=":"```\na <= b\n``` \nergibt genau dann ```true```, wenn der Wert von ```a``` größer oder gleich dem Wert von ```b``` ist.","<>":"```\na <> b\n``` \nergibt genau dann ```true```, wenn ```a``` und ```b``` **un**gleich sind. \n```<>``` nennt man **Ungleich-Operator**."});let Ne=_e;class _i{constructor(e){this.main=e}provideCodeActions(e,t,i,n){return{actions:[],dispose:()=>{}}}}class Ti{constructor(e){this.main=e}provideReferences(e,t,i,n){let r=this.main.getCurrentWorkspace().getModuleByMonacoModel(e);if(r==null)return null;let o=r.getElementAtPosition(t.lineNumber,t.column);if(o==null)return;let l=o.usagePositions,d=[];return l.forEach((u,m)=>{if(u!=null)for(let f of u)d.push({uri:m.uri,range:{startColumn:f.column,startLineNumber:f.line,endLineNumber:f.line,endColumn:f.column+f.length}})}),d}}function Li(){C.register({id:"vscSQL",extensions:[".sql"]});let a={onEnterRules:[{beforeText:/^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,afterText:/^\s*\*\/$/,action:{indentAction:C.IndentAction.IndentOutdent,appendText:" * "}},{beforeText:/^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,action:{indentAction:C.IndentAction.None,appendText:" * "}},{beforeText:/^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/,action:{indentAction:C.IndentAction.None,appendText:"* "}},{beforeText:/^(\t|(\ \ ))*\ \*\/\s*$/,action:{indentAction:C.IndentAction.None,removeText:1}},{beforeText:/^(\t|(\ \ ))*\ \*[^/]*\*\/\s*$/,action:{indentAction:C.IndentAction.None,removeText:1}}],comments:{lineComment:"--",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}]},e={defaultToken:"",tokenPostfix:".sql",ignoreCase:!0,brackets:[{open:"[",close:"]",token:"delimiter.square"},{open:"(",close:")",token:"delimiter.parenthesis"}],escapes:/\\(?:[abfnrtv\\"'])/,keywords:["ABORT","ACTION","ADD","AFTER","ALL","ALTER","ANALYZE","AND","AS","ASC","ATTACH","AUTOINCREMENT","BEFORE","BEGIN","BETWEEN","BY","CASCADE","CASE","CAST","CHECK","COLLATE","COLUMN","COMMIT","CONFLICT","CONSTRAINT","CREATE","CROSS","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","DATABASE","DEFAULT","DEFERRABLE","DEFERRED","DELETE","DESC","DETACH","DISTINCT","DROP","EACH","ELSE","END","ESCAPE","EXCEPT","EXCLUSIVE","EXISTS","EXPLAIN","FAIL","FOR","FOREIGN","FROM","FULL","GLOB","GROUP","HAVING","IF","IGNORE","IMMEDIATE","IN","INDEX","INDEXED","INITIALLY","INNER","INSERT","INSTEAD","INTERSECT","INTO","IS","ISNULL","JOIN","KEY","LEFT","LIKE","LIMIT","MATCH","NATURAL","NO","NOT","NOTNULL","NULL","OF","OFFSET","ON","OR","ORDER","OUTER","PLAN","PRAGMA","PRIMARY","QUERY","RAISE","RECURSIVE","REFERENCES","REGEXP","REINDEX","RELEASE","RENAME","REPLACE","RESTRICT","RIGHT","ROLLBACK","ROW","SAVEPOINT","SELECT","SET","TABLE","TEMP","TEMPORARY","THEN","TO","TRANSACTION","TRIGGER","UNION","UNIQUE","UPDATE","USING","VACUUM","VALUES","VIEW","VIRTUAL","WHEN","WHERE","WITH","WITHOUT","ENGINE","CHARSET"],operators:["AND","BETWEEN","IN","LIKE","NOT","OR","IS","NULL","INTERSECT","UNION","INNER","JOIN","LEFT","OUTER","RIGHT"],builtinFunctions:["abs","changes","char","coalesce","count","glob","hex","ifnull","iif","instr","last_insert_rowid","length","like","likelihood","likely","lower","ltrim","max","min","nullif","quote","random","randomblob","replace","round","rtrim","sign","soundex","sqlite_version","substr","substring","total_changes","trim","typeof","unicode","unlikely","upper","zeroblob"],builtinVariables:[],pseudoColumns:[],tokenizer:{root:[{include:"@comments"},{include:"@whitespace"},{include:"@pseudoColumns"},{include:"@numbers"},{include:"@strings"},{include:"@complexIdentifiers"},{include:"@scopes"},[/[;,.]/,"delimiter"],[/[()]/,"@brackets"],[/[a-z_$äöü][\w$äöüßÄÖÜ]*(?=\()/,{cases:{"@builtinFunctions":"functions","@keywords":"keyword","@default":"identifier"}}],[/[\w@#$]+/,{cases:{"@keywords":"keyword","@operators":"operator","@builtinVariables":"predefined","@default":"identifier"}}],[/[<>=!%&+\-*/|~^]/,"operator"]],whitespace:[[/\s+/,"white"]],comments:[[/--+.*/,"comment"],[/\/\*/,{token:"comment.quote",next:"@comment"}]],comment:[[/[^*/]+/,"comment"],[/\*\//,{token:"comment.quote",next:"@pop"}],[/./,"comment"]],pseudoColumns:[[/[$][A-Za-z_][\w@#$]*/,{cases:{"@pseudoColumns":"predefined","@default":"identifier"}}]],numbers:[[/0[xX][0-9a-fA-F]*/,"number"],[/[$][+-]*\d*(\.\d*)?/,"number"],[/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/,"number"]],strings:[[/'/,{token:"string",next:"@string"}]],string:[[/[^\\']+/,"string"],[/\\./,"string.escape.invalid"],[/''/,"string"],[/'/,{token:"string",next:"@pop"}]],complexIdentifiers:[[/"/,{token:"identifier.quote",next:"@quotedIdentifier"}]],quotedIdentifier:[[/[^"]+/,"identifier"],[/""/,"identifier"],[/"/,{token:"identifier.quote",next:"@pop"}]],scopes:[]}};C.setLanguageConfiguration("vscSQL",a),C.setMonarchTokensProvider("vscSQL",e)}class K{static openHelper(e,t,i){let n=c(".jo_arrow_box");n.removeClass(["jo_arrow_box_left","jo_arrow_box_right","jo_arrow_box_top","jo_arrow_box_bottom"]),n.addClass("jo_arrow_box_"+i),n.css({left:"",right:"",top:"",bottom:""});let r=t.offset(),o=c("body"),l=34;switch(i){case"bottom":n.css({left:r.left+t.width()/2-l,bottom:o.height()-r.top+l});break;case"top":n.css({left:r.left+t.width()/2-l,top:r.top+t.height()+26});break;case"left":n.css({left:r.left+t.width()+l,top:r.top+t.height()/2-l});break;case"right":n.css({right:o.width()-r.left,top:r.top+t.height()/2-l});break}n.find("span").html(e);let d=n.find(".jo_button");d.on("click",u=>{u.stopPropagation(),d.off("click"),K.close()}),n.fadeIn(800)}static close(){c(".jo_arrow_box").fadeOut(800)}static showHelper(e,t,i){let n;if(t instanceof Se)n=t;else return;let r=n.user;if(r==null)return;let o=r.settings.helperHistory,l=e+"Done";if(o!=null&&(o[l]==null||!o[l])){o[l]=!0,n.networkManager.sendUpdateUserSettings(()=>{});let d="",u="left";switch(e){case"newDatabaseHelper":d=`Es gibt noch keine Datenbank. <br> Nutzen Sie den Button
105
+ );`,command:{id:"editor.action.triggerSuggest",title:"123",arguments:[]},insertTextRules:C.CompletionItemInsertTextRule.InsertAsSnippet,kind:C.CompletionItemKind.Snippet,range:void 0})}}class Di{constructor(e){h(this,"signatureHelpTriggerCharacters",["(",",",";","<",">","="]);h(this,"signatureHelpRetriggerCharacters",[]);this.main=e}provideSignatureHelp(e,t,i,n){let r=this;return new Promise((o,l)=>{setTimeout(()=>{this.main.compileIfDirty(),o(r.provideSignatureHelpLater(e,t,i,n))},300)})}provideSignatureHelpLater(e,t,i,n){e!=this.main.getMonacoEditor().getModel();let r=this.main.getCurrentWorkspace().getModuleByMonacoModel(e);if(r==null)return null;let o=r.methodCallPositions[t.lineNumber];if(o==null)return null;let l=null,d=-1;for(let u=o.length-1;u>=0;u--){let m=o[u];m.identifierPosition.column+m.identifierPosition.length<t.column&&m.identifierPosition.column>d&&(m.rightBracketPosition==null||t.lineNumber<=m.rightBracketPosition.line&&t.column<=m.rightBracketPosition.column||t.lineNumber<m.rightBracketPosition.line)&&(l=m,d=m.identifierPosition.column)}return l==null?null:this.getSignatureHelp(l,t)}getSignatureHelp(e,t){let i=0;for(let r of e.commaPositions)(r.line<t.lineNumber||r.line==t.lineNumber&&r.column<t.column)&&i++;let n=[];return Promise.resolve({value:{activeParameter:i,activeSignature:0,signatures:n},dispose:()=>{}})}}const Te=class Te{constructor(e){this.editor=e}provideHover(e,t,i){var l;let n=this.editor.editor.getSelection();if(n!=null&&(n.startLineNumber!=n.endLineNumber||n.startColumn!=n.endColumn)&&(n.startLineNumber<t.lineNumber||n.startLineNumber==t.lineNumber&&n.startColumn<=t.column)&&(n.endLineNumber>t.lineNumber||n.endLineNumber==t.lineNumber&&n.endColumn>=t.column))return;let r=(l=this.editor.main.getCurrentWorkspace())==null?void 0:l.getModuleByMonacoModel(e);if(r==null)return null;for(let d of r.errors)for(let u of d)if(u.position.line==t.lineNumber&&u.position.column<=t.column&&u.position.column+u.position.length>=t.column)return null;if(r.getElementAtPosition(t.lineNumber,t.column)==null){let d=this.getWordUnderCursor(e,t),u=Te.keywordDescriptions[d];if(u!=null)return{range:null,contents:[{value:u}]}}}getWordUnderCursor(e,t){let i=e.getValueLengthInRange({startColumn:0,startLineNumber:0,endLineNumber:t.lineNumber,endColumn:t.column}),n=e.getValue(),r="",o=i;for(;o<n.length&&this.isInsideIdentifierOrArrayDescriptor(n.charAt(o));)o++;let l=i;for(;l>0&&this.isInsideIdentifierOrArrayDescriptor(n.charAt(l-1));)l--;if(o-l>1)r=n.substring(l,o);else{for(o=i;o<n.length&&this.isInsideOperator(n.charAt(o));)o++;for(l=i;l>0&&this.isInsideOperator(n.charAt(l-1));)l--;o-l>0&&(r=n.substring(l,o))}return r}widenDeclaration(e,t,i){let n=e.getValueLengthInRange({startColumn:0,startLineNumber:0,endLineNumber:t.lineNumber,endColumn:t.column}),r=e.getValue(),o=n;for(;o<r.length&&this.isInsideIdentifierOrArrayDescriptor(r.charAt(o));)o++;let l=n;for(;l>0&&this.isInsideIdentifierChain(r.charAt(l-1));)l--;return(i==null?void 0:i.length)==null||i.length,o-l>length?r.substring(l,o):i}isInsideIdentifierChain(e){return e.toLocaleLowerCase().match(/[a-z0-9äöüß_\[\]\.]/i)}isInsideOperator(e){return e.toLocaleLowerCase().match(/[!%<>=\+\-\*\/]/i)}isInsideIdentifierOrArrayDescriptor(e){return e.toLocaleLowerCase().match(/[a-z0-9äöüß\[\]]/i)}};h(Te,"keywordDescriptions",{select:"```\nselect spalte1, spalte2, ..., spalteN from tabelle where <Bedingung>\n``` \nsucht alle Zeilen der Tabelle, die der Bedingung genügen (**Selektion**) und gibt davon die angegebenen Spalten aus (**Projektion**). Das Ergebnis der ```select```-Anweisung ist wieder eine Tabelle. \n ",from:"```\nselect spalte1, spalte2, ..., spalteN from tabelle where <Bedingung>\n``` \nsucht alle Zeilen der Tabelle, die der Bedingung genügen (**Selektion**) und gibt davon die angegebenen Spalten aus (**Projektion**). Das Ergebnis der ```select```-Anweisung ist wieder eine Tabelle. \n ",where:"```\n... where <Bedingung>\n``` \nHinter ```where``` steht immer eine Bedingung, d.h. ein Term mit booleschem Wert (```true``` oder ```false```). Die Anweisung wird für alle Zeilen ausgeführt, die der Bedingung genügen, d.h. für die der Term den Wert ```true``` ergibt. \n ",delete:"```\ndelete from tabelle where <Bedingung>\n``` \nlöscht alle Zeilen der Tabelle, die der Bedingung genügen. \n ",insert:"```\ninsert (spalte1, spalte2, ..., spalteN) into tabelle values (Wert1, ..., WertN), (Wert1, ..., WertN), ... \n``` \nFügt Datensätze in eine Tabelle ein. Die Werte ```wert1, ..., wertN``` müssen den angegebenen Spalten ```Spalte1, ..., SpalteN``` entsprechen.\n ",values:"```\ninsert (spalte1, spalte2, ..., spalteN) into tabelle values (Wert1, ..., WertN), (Wert1, ..., WertN), ... \n``` \nFügt Datensätze in eine Tabelle ein. Die Werte ```wert1, ..., wertN``` müssen den angegebenen Spalten ```Spalte1, ..., SpalteN``` entsprechen.\n ",update:"```\nupdate tabelle set Spalte1 = Wert1, Spalte2 = Wert2, ..., SpalteN = WertN where <Bedingung> \n``` \nÄndert in allen Datensätze der Tabelle, die der Bedingung genügen, die Werte in den angegebenen Spalten ```Spalte1, ..., SpalteN```.\n ","%":"```\na % b\n``` \n (sprich: 'a modulo b') berechnet den **Rest** der ganzzahligen Division a/b.","=":"```\na = b\n``` \nergibt genau dann ```true```, wenn ```a``` und ```b``` gleich sind. \n```=``` nennt man **Vergleichsoperator**. \n\n**Tipp:** In SQL gibt es auch einen **Ungleich-Operator**: ```<>```","<=":"```\na <= b\n``` \nergibt genau dann ```true```, wenn der Wert von ```a``` kleiner oder gleich dem Wert von ```b``` ist.",">=":"```\na <= b\n``` \nergibt genau dann ```true```, wenn der Wert von ```a``` größer oder gleich dem Wert von ```b``` ist.","<>":"```\na <> b\n``` \nergibt genau dann ```true```, wenn ```a``` und ```b``` **un**gleich sind. \n```<>``` nennt man **Ungleich-Operator**."});let Ne=Te;class _i{constructor(e){this.main=e}provideCodeActions(e,t,i,n){return{actions:[],dispose:()=>{}}}}class Ti{constructor(e){this.main=e}provideReferences(e,t,i,n){let r=this.main.getCurrentWorkspace().getModuleByMonacoModel(e);if(r==null)return null;let o=r.getElementAtPosition(t.lineNumber,t.column);if(o==null)return;let l=o.usagePositions,d=[];return l.forEach((u,m)=>{if(u!=null)for(let f of u)d.push({uri:m.uri,range:{startColumn:f.column,startLineNumber:f.line,endLineNumber:f.line,endColumn:f.column+f.length}})}),d}}function Li(){C.register({id:"vscSQL",extensions:[".sql"]});let a={onEnterRules:[{beforeText:/^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,afterText:/^\s*\*\/$/,action:{indentAction:C.IndentAction.IndentOutdent,appendText:" * "}},{beforeText:/^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,action:{indentAction:C.IndentAction.None,appendText:" * "}},{beforeText:/^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/,action:{indentAction:C.IndentAction.None,appendText:"* "}},{beforeText:/^(\t|(\ \ ))*\ \*\/\s*$/,action:{indentAction:C.IndentAction.None,removeText:1}},{beforeText:/^(\t|(\ \ ))*\ \*[^/]*\*\/\s*$/,action:{indentAction:C.IndentAction.None,removeText:1}}],comments:{lineComment:"--",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}]},e={defaultToken:"",tokenPostfix:".sql",ignoreCase:!0,brackets:[{open:"[",close:"]",token:"delimiter.square"},{open:"(",close:")",token:"delimiter.parenthesis"}],escapes:/\\(?:[abfnrtv\\"'])/,keywords:["ABORT","ACTION","ADD","AFTER","ALL","ALTER","ANALYZE","AND","AS","ASC","ATTACH","AUTOINCREMENT","BEFORE","BEGIN","BETWEEN","BY","CASCADE","CASE","CAST","CHECK","COLLATE","COLUMN","COMMIT","CONFLICT","CONSTRAINT","CREATE","CROSS","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","DATABASE","DEFAULT","DEFERRABLE","DEFERRED","DELETE","DESC","DETACH","DISTINCT","DROP","EACH","ELSE","END","ESCAPE","EXCEPT","EXCLUSIVE","EXISTS","EXPLAIN","FAIL","FOR","FOREIGN","FROM","FULL","GLOB","GROUP","HAVING","IF","IGNORE","IMMEDIATE","IN","INDEX","INDEXED","INITIALLY","INNER","INSERT","INSTEAD","INTERSECT","INTO","IS","ISNULL","JOIN","KEY","LEFT","LIKE","LIMIT","MATCH","NATURAL","NO","NOT","NOTNULL","NULL","OF","OFFSET","ON","OR","ORDER","OUTER","PLAN","PRAGMA","PRIMARY","QUERY","RAISE","RECURSIVE","REFERENCES","REGEXP","REINDEX","RELEASE","RENAME","REPLACE","RESTRICT","RIGHT","ROLLBACK","ROW","SAVEPOINT","SELECT","SET","TABLE","TEMP","TEMPORARY","THEN","TO","TRANSACTION","TRIGGER","UNION","UNIQUE","UPDATE","USING","VACUUM","VALUES","VIEW","VIRTUAL","WHEN","WHERE","WITH","WITHOUT","ENGINE","CHARSET"],operators:["AND","BETWEEN","IN","LIKE","NOT","OR","IS","NULL","INTERSECT","UNION","INNER","JOIN","LEFT","OUTER","RIGHT"],builtinFunctions:["abs","changes","char","coalesce","count","glob","hex","ifnull","iif","instr","last_insert_rowid","length","like","likelihood","likely","lower","ltrim","max","min","nullif","quote","random","randomblob","replace","round","rtrim","sign","soundex","sqlite_version","substr","substring","total_changes","trim","typeof","unicode","unlikely","upper","zeroblob"],builtinVariables:[],pseudoColumns:[],tokenizer:{root:[{include:"@comments"},{include:"@whitespace"},{include:"@pseudoColumns"},{include:"@numbers"},{include:"@strings"},{include:"@complexIdentifiers"},{include:"@scopes"},[/[;,.]/,"delimiter"],[/[()]/,"@brackets"],[/[a-z_$äöü][\w$äöüßÄÖÜ]*(?=\()/,{cases:{"@builtinFunctions":"functions","@keywords":"keyword","@default":"identifier"}}],[/[\w@#$]+/,{cases:{"@keywords":"keyword","@operators":"operator","@builtinVariables":"predefined","@default":"identifier"}}],[/[<>=!%&+\-*/|~^]/,"operator"]],whitespace:[[/\s+/,"white"]],comments:[[/--+.*/,"comment"],[/\/\*/,{token:"comment.quote",next:"@comment"}]],comment:[[/[^*/]+/,"comment"],[/\*\//,{token:"comment.quote",next:"@pop"}],[/./,"comment"]],pseudoColumns:[[/[$][A-Za-z_][\w@#$]*/,{cases:{"@pseudoColumns":"predefined","@default":"identifier"}}]],numbers:[[/0[xX][0-9a-fA-F]*/,"number"],[/[$][+-]*\d*(\.\d*)?/,"number"],[/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/,"number"]],strings:[[/'/,{token:"string",next:"@string"}]],string:[[/[^\\']+/,"string"],[/\\./,"string.escape.invalid"],[/''/,"string"],[/'/,{token:"string",next:"@pop"}]],complexIdentifiers:[[/"/,{token:"identifier.quote",next:"@quotedIdentifier"}]],quotedIdentifier:[[/[^"]+/,"identifier"],[/""/,"identifier"],[/"/,{token:"identifier.quote",next:"@pop"}]],scopes:[]}};C.setLanguageConfiguration("vscSQL",a),C.setMonarchTokensProvider("vscSQL",e)}class K{static openHelper(e,t,i){let n=c(".jo_arrow_box");n.removeClass(["jo_arrow_box_left","jo_arrow_box_right","jo_arrow_box_top","jo_arrow_box_bottom"]),n.addClass("jo_arrow_box_"+i),n.css({left:"",right:"",top:"",bottom:""});let r=t.offset(),o=c("body"),l=34;switch(i){case"bottom":n.css({left:r.left+t.width()/2-l,bottom:o.height()-r.top+l});break;case"top":n.css({left:r.left+t.width()/2-l,top:r.top+t.height()+26});break;case"left":n.css({left:r.left+t.width()+l,top:r.top+t.height()/2-l});break;case"right":n.css({right:o.width()-r.left,top:r.top+t.height()/2-l});break}n.find("span").html(e);let d=n.find(".jo_button");d.on("click",u=>{u.stopPropagation(),d.off("click"),K.close()}),n.fadeIn(800)}static close(){c(".jo_arrow_box").fadeOut(800)}static showHelper(e,t,i){let n;if(t instanceof Ee)n=t;else return;let r=n.user;if(r==null)return;let o=r.settings.helperHistory,l=e+"Done";if(o!=null&&(o[l]==null||!o[l])){o[l]=!0,n.networkManager.sendUpdateUserSettings(()=>{});let d="",u="left";switch(e){case"newDatabaseHelper":d=`Es gibt noch keine Datenbank. <br> Nutzen Sie den Button
106
106
  <span class='img_add-database-dark jo_inline-image'></span> um eine Datenbank anzulegen.
107
107
  `,u="left";break;case"newSQLFileHelper":d=`Es gibt noch keine Datei mit SQL-Anweisungen. <br> Nutzen Sie den Button
108
108
  <span class='img_add-file-dark jo_inline-image'></span> um eine neue Datei anzulegen.
@@ -115,10 +115,10 @@ where $0
115
115
  oder drücken Sie &lt;Strg&gt;&nbsp;+&nbsp&lt;Enter&gt;. `,u="top";break;case"consoleHelper":d=`
116
116
  Hier können Sie Anweisungen oder Terme eingeben, die nach Bestätigung mit der Enter-Taste ausgeführt/ausgewertet werden. Das Ergebnis sehen Sie im Bereich über der Eingabezeile. <br>
117
117
  Falls das Programm gerade pausiert (z.B. bei Ausführung in Einzelschritten) können Sie auch auf die Variablen des aktuellen Sichtbarkeitsbereiches zugreifen.
118
- `,u="bottom"}d!=""&&i!=null&&i.length>0&&K.openHelper(d,i,u)}}}class vt{constructor(e,t,i){h(this,"editor");h(this,"cw",null);h(this,"dontPushNextCursorMove",0);h(this,"lastTime",0);h(this,"elementDecoration",[]);this.main=e,this.showMinimap=t,this.isEmbedded=i}initGUI(e){Li(),x.defineTheme("myCustomThemeDark",{base:"vs-dark",inherit:!0,rules:[{token:"functions",foreground:"dcdcaa",fontStyle:"italic"},{token:"string.sql",foreground:"3DC9B0"},{token:"number",foreground:"7bef3f"},{token:"type",foreground:"499cd6"},{token:"identifier",foreground:"effefe"},{token:"statement",foreground:"9cdcfe",fontStyle:"bold"},{token:"keyword",foreground:"619ceb",fontStyle:"bold"},{token:"table",foreground:"ff0000",fontStyle:"bold"},{token:"delimiter",foreground:"e8eb38"}],colors:{"editor.background":"#1e1e1e",jo_highlightStatementGreen:"#004000",jo_highlightStatementYellow:"#404000",jo_highlightStatementRed:"#402020"}}),x.defineTheme("myCustomThemeLight",{base:"vs",inherit:!0,rules:[{token:"functions",foreground:"694E16",fontStyle:"italic bold"},{token:"string.sql",foreground:"a03030"},{token:"number",foreground:"404040"},{token:"type",foreground:"0000ff",fontStyle:"bold"},{token:"identifier",foreground:"8000e0"},{token:"statement",foreground:"001080",fontStyle:"bold"},{token:"keyword",foreground:"00a000",fontStyle:"bold"},{token:"comment",foreground:"808080",fontStyle:"italic"}],colors:{"editor.background":"#FFFFFF","editor.foreground":"#000000","editor.inactiveSelectionBackground":"#E5EBF1","editorIndentGuide.background":"#D3D3D3","editorIndentGuide.activeBackground":"#939393","editor.selectionHighlightBackground":"#ADD6FF80","editorSuggestWidget.background":"#F3F3F3","activityBarBadge.background":"#007ACC","sideBarTitle.foreground":"#6F6F6F","list.hoverBackground":"#E8E8E8","input.placeholderForeground":"#767676","searchEditor.textInputBorder":"#CECECE","settings.textInputBorder":"#CECECE","settings.numberInputBorder":"#CECECE","statusBarItem.remoteForeground":"#FFF","statusBarItem.remoteBackground":"#16825D",jo_highlightStatementGreen:"#004000",jo_highlightStatementYellow:"#404000",jo_highlightStatementRed:"#400000"}}),this.editor=x.create(e[0],{language:"vscSQL",lightbulb:{enabled:x.ShowLightbulbIconMode.On},lineDecorationsWidth:0,peekWidgetDefaultFocus:"tree",fixedOverflowWidgets:!0,quickSuggestions:!0,quickSuggestionsDelay:10,fontSize:14,fontFamily:"Consolas, Roboto Mono",fontWeight:"500",roundedSelection:!0,selectOnLineNumbers:!1,automaticLayout:!0,scrollBeyondLastLine:!1,occurrencesHighlight:"off",autoIndent:"full",dragAndDrop:!0,formatOnType:!0,formatOnPaste:!0,suggestFontSize:16,suggestLineHeight:22,suggest:{localityBonus:!0,insertMode:"replace"},parameterHints:{enabled:!0,cycle:!0},mouseWheelZoom:this.isEmbedded,minimap:{enabled:this.showMinimap},scrollbar:{vertical:"auto",horizontal:"auto"},theme:"myCustomThemeDark"});let t=this,i=n=>{n.ctrlKey===!0&&(t.changeEditorFontSize(Math.sign(n.deltaY),!0),n.preventDefault())};return this.editor.onDidChangeConfiguration(n=>{n.hasChanged(x.EditorOption.fontInfo)&&this.isEmbedded&&this.main.getBottomDiv().errorManager.registerLightbulbOnClickFunctions()}),this.editor.onDidChangeCursorPosition(n=>{t.onDidChangeCursorPosition(n.position)}),this.editor.onDidChangeModel(n=>{let r=e.find(".monaco-editor")[0];if(r!=null&&(r.removeEventListener("wheel",i),r.addEventListener("wheel",i,{passive:!1})),this.main.getCurrentWorkspace()==null)return;let o=this.main.getCurrentWorkspace().getModuleByMonacoModel(this.editor.getModel());this.main instanceof Se&&o!=null&&this.main.projectExplorer.setActiveAfterExternalModelSet(o)}),C.registerHoverProvider("vscSQL",new Ne(this)),C.registerCompletionItemProvider("vscSQL",new Ei(this.main)),C.registerCodeActionProvider("vscSQL",new _i(this.main)),C.registerReferenceProvider("vscSQL",new Ti(this.main)),C.registerSignatureHelpProvider("vscSQL",new Di(this.main)),this.editor.onMouseDown(n=>{n.target.type!==x.MouseTargetType.GUTTER_GLYPH_MARGIN&&n.target.type!==x.MouseTargetType.GUTTER_LINE_NUMBERS||t.onMarginMouseDown(n.target.position.lineNumber)}),setTimeout(()=>{x.remeasureFonts()},2e3),this.addActions(),this.editor.onDidType(n=>{t.onDidType(n)}),this.editor}onDidType(e){const t=(i,n,r,o)=>{const l=new it(i.lineNumber,i.column,i.lineNumber,i.column);this.editor.executeEdits("new-bullets",[{range:l,text:n}]),this.editor.setPosition({lineNumber:r,column:o})};if(e===`
118
+ `,u="bottom"}d!=""&&i!=null&&i.length>0&&K.openHelper(d,i,u)}}}class Ct{constructor(e,t,i){h(this,"editor");h(this,"cw",null);h(this,"dontPushNextCursorMove",0);h(this,"lastTime",0);h(this,"elementDecoration",[]);this.main=e,this.showMinimap=t,this.isEmbedded=i}initGUI(e){Li(),x.defineTheme("myCustomThemeDark",{base:"vs-dark",inherit:!0,rules:[{token:"functions",foreground:"dcdcaa",fontStyle:"italic"},{token:"string.sql",foreground:"3DC9B0"},{token:"number",foreground:"7bef3f"},{token:"type",foreground:"499cd6"},{token:"identifier",foreground:"effefe"},{token:"statement",foreground:"9cdcfe",fontStyle:"bold"},{token:"keyword",foreground:"619ceb",fontStyle:"bold"},{token:"table",foreground:"ff0000",fontStyle:"bold"},{token:"delimiter",foreground:"e8eb38"}],colors:{"editor.background":"#1e1e1e",jo_highlightStatementGreen:"#004000",jo_highlightStatementYellow:"#404000",jo_highlightStatementRed:"#402020"}}),x.defineTheme("myCustomThemeLight",{base:"vs",inherit:!0,rules:[{token:"functions",foreground:"694E16",fontStyle:"italic bold"},{token:"string.sql",foreground:"a03030"},{token:"number",foreground:"404040"},{token:"type",foreground:"0000ff",fontStyle:"bold"},{token:"identifier",foreground:"8000e0"},{token:"statement",foreground:"001080",fontStyle:"bold"},{token:"keyword",foreground:"00a000",fontStyle:"bold"},{token:"comment",foreground:"808080",fontStyle:"italic"}],colors:{"editor.background":"#FFFFFF","editor.foreground":"#000000","editor.inactiveSelectionBackground":"#E5EBF1","editorIndentGuide.background":"#D3D3D3","editorIndentGuide.activeBackground":"#939393","editor.selectionHighlightBackground":"#ADD6FF80","editorSuggestWidget.background":"#F3F3F3","activityBarBadge.background":"#007ACC","sideBarTitle.foreground":"#6F6F6F","list.hoverBackground":"#E8E8E8","input.placeholderForeground":"#767676","searchEditor.textInputBorder":"#CECECE","settings.textInputBorder":"#CECECE","settings.numberInputBorder":"#CECECE","statusBarItem.remoteForeground":"#FFF","statusBarItem.remoteBackground":"#16825D",jo_highlightStatementGreen:"#004000",jo_highlightStatementYellow:"#404000",jo_highlightStatementRed:"#400000"}}),this.editor=x.create(e[0],{language:"vscSQL",lightbulb:{enabled:x.ShowLightbulbIconMode.On},lineDecorationsWidth:0,peekWidgetDefaultFocus:"tree",fixedOverflowWidgets:!0,quickSuggestions:!0,quickSuggestionsDelay:10,fontSize:14,fontFamily:"Consolas, Roboto Mono",fontWeight:"500",roundedSelection:!0,selectOnLineNumbers:!1,automaticLayout:!0,scrollBeyondLastLine:!1,occurrencesHighlight:"off",autoIndent:"full",dragAndDrop:!0,formatOnType:!0,formatOnPaste:!0,suggestFontSize:16,suggestLineHeight:22,suggest:{localityBonus:!0,insertMode:"replace"},parameterHints:{enabled:!0,cycle:!0},mouseWheelZoom:this.isEmbedded,minimap:{enabled:this.showMinimap},scrollbar:{vertical:"auto",horizontal:"auto"},theme:"myCustomThemeDark"});let t=this,i=n=>{n.ctrlKey===!0&&(t.changeEditorFontSize(Math.sign(n.deltaY),!0),n.preventDefault())};return this.editor.onDidChangeConfiguration(n=>{n.hasChanged(x.EditorOption.fontInfo)&&this.isEmbedded&&this.main.getBottomDiv().errorManager.registerLightbulbOnClickFunctions()}),this.editor.onDidChangeCursorPosition(n=>{t.onDidChangeCursorPosition(n.position)}),this.editor.onDidChangeModel(n=>{let r=e.find(".monaco-editor")[0];if(r!=null&&(r.removeEventListener("wheel",i),r.addEventListener("wheel",i,{passive:!1})),this.main.getCurrentWorkspace()==null)return;let o=this.main.getCurrentWorkspace().getModuleByMonacoModel(this.editor.getModel());this.main instanceof Ee&&o!=null&&this.main.projectExplorer.setActiveAfterExternalModelSet(o)}),C.registerHoverProvider("vscSQL",new Ne(this)),C.registerCompletionItemProvider("vscSQL",new Ei(this.main)),C.registerCodeActionProvider("vscSQL",new _i(this.main)),C.registerReferenceProvider("vscSQL",new Ti(this.main)),C.registerSignatureHelpProvider("vscSQL",new Di(this.main)),this.editor.onMouseDown(n=>{n.target.type!==x.MouseTargetType.GUTTER_GLYPH_MARGIN&&n.target.type!==x.MouseTargetType.GUTTER_LINE_NUMBERS||t.onMarginMouseDown(n.target.position.lineNumber)}),setTimeout(()=>{x.remeasureFonts()},2e3),this.addActions(),this.editor.onDidType(n=>{t.onDidType(n)}),this.editor}onDidType(e){const t=(i,n,r,o)=>{const l=new rt(i.lineNumber,i.column,i.lineNumber,i.column);this.editor.executeEdits("new-bullets",[{range:l,text:n}]),this.editor.setPosition({lineNumber:r,column:o})};if(e===`
119
119
  `){const i=this.editor.getModel(),n=this.editor.getPosition(),r=i.getLineContent(n.lineNumber-1);if(r.trim().indexOf("/*")===0&&!r.trimRight().endsWith("*/")&&!(n.lineNumber<i.getLineCount()?i.getLineContent(n.lineNumber+1):"").trim().startsWith("*")){let l=r.substr(0,r.length-r.trimLeft().length);r.trim().indexOf("/**")===0?t(n,`
120
120
  `+l+" */",n.lineNumber,n.column+3+l.length):t(n,` *
121
- `+l+" */",n.lineNumber,n.column+3+l.length)}}}setFontSize(e){let t=new Date().getTime();if(t-this.lastTime<150)return;this.lastTime=t;let i=this.editor.getOptions().get(x.EditorOption.fontSize);if(this.main instanceof Se&&this.main.viewModeController.saveFontSize(e),e!=i){this.editor.updateOptions({fontSize:e});let r=this.editor.getOptions().get(x.EditorOption.fontSize)/e;this.editor.updateOptions({fontSize:e/r})}c(".jo_editorFontSize").css("font-size",e+"px"),c(".jo_editorFontSize").css("line-height",e+2+"px"),document.documentElement.style.setProperty("--breakpoint-size",e+"px"),document.documentElement.style.setProperty("--breakpoint-radius",e/2+"px"),this.main.getBottomDiv().errorManager.registerLightbulbOnClickFunctions()}changeEditorFontSize(e,t=!0){let i=this.editor.getOptions().get(x.EditorOption.fontSize);t&&(i<10?e*=1:i<20?e*=2:e*=4);let n=i+e;n>=6&&n<=80&&this.setFontSize(n)}addActions(){let e=this;this.editor.addAction({id:"Find bracket",label:"Finde korrespondierende Klammer",keybindings:[Ve.CtrlCmd|Ge.KeyK],precondition:null,keybindingContext:null,contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:function(t){return t.getAction("editor.action.jumpToBracket").run(),null}}),this.editor.addAction({id:"Execute statement",label:"SQL-Anweisung ausführen",keybindings:[Ve.CtrlCmd|Ge.Enter],precondition:null,keybindingContext:null,contextMenuGroupId:"navigation",contextMenuOrder:1,run:function(t){return e.main.getActionManager().trigger("execute"),null}})}onMarginMouseDown(e){}onDidChangeCursorPosition(e){e==null&&(e=this.editor.getPosition());let t=this.getCurrentlyEditedModule();if(t==null){this.elementDecoration=this.editor.deltaDecorations(this.elementDecoration,[]);return}let i=t.getElementAtPosition(e.lineNumber,e.column),n=[];if(i!=null){let l=i.usagePositions.get(t);if(l!=null)for(let d of l)n.push({range:{startColumn:d.column,startLineNumber:d.line,endColumn:d.column+d.length,endLineNumber:d.line},options:{className:"jo_revealSyntaxElement",isWholeLine:!1,overviewRuler:{color:{id:"editorIndentGuide.background"},darkColor:{id:"editorIndentGuide.activeBackground"},position:x.OverviewRulerLane.Left}}})}let r=!1;for(let o of t.getSQLSTatementsAtSelection(this.editor.getSelection())){let l="jo_highlightStatementGreen";o!=null&&(o.hasErrors?(l="jo_highlightStatementRed",o.acceptedBySQLite&&(l="jo_highlightStatementYellow",r=!0)):r=!0,n.push({range:{startColumn:o.from.column,startLineNumber:o.from.line,endColumn:o.to.column,endLineNumber:o.to.line},options:{className:l,isWholeLine:!1,overviewRuler:{color:{id:l},darkColor:{id:l},position:x.OverviewRulerLane.Left},minimap:{color:{id:l},position:x.MinimapPosition.Inline},zIndex:-100}}))}this.main.getActionManager().setActive("execute",r),r&&!this.main.isEmbedded()&&K.showHelper("playButtonHelper",this.main,c("div.img_start-dark")),this.elementDecoration=this.editor.deltaDecorations(this.elementDecoration,n)}getCurrentlyEditedModule(){return this.main.getCurrentlyEditedModule()}}class yt{constructor(e,t){h(this,"panelEntries",[]);this.main=e,this.$historyPanel=t}clear(){this.$historyPanel.empty(),this.main.getActionManager().setActive("rollback",!1),this.panelEntries=[]}clearAndShowStatements(e){this.clear(),this.appendStatements(e),this.main.getActionManager().setActive("rollback",e.length>0)}appendStatements(e){e.forEach(t=>{let i=this.makePanelEntry(t,this.panelEntries.length+1);this.$historyPanel.prepend(i.$div),this.panelEntries.unshift(i)}),e.length>0&&this.main.getActionManager().setActive("rollback",!0),this.makeLastButtonActive()}makeLastButtonActive(){this.panelEntries.forEach(e=>e.$rollbackButton.removeClass("jo_active")),this.panelEntries.length>0&&this.panelEntries[0].$rollbackButton.addClass("jo_active")}makePanelEntry(e,t){let i=c('<div class="jo_panelEntry"></div>'),n=c(`<div class="jo_panelEntryIndex">${t}.</div>`),r=c('<div class="jo_panelEntryText"></div>'),o=e.substring(0,Math.min(400,e.length));e.length>400&&(o+="..."),r.text(o);let l=c('<div class="img_copy jo_panelEntryCopyButton jo_active jo_button" title="In die Zwischenablage kopieren"></div>'),d=c('<div class="img_undo jo_panelEntryRollbackButton jo_button" title="Rollback"></div>');l.on("click",()=>{gt(e)});let u=window.PointerEvent?"pointer":"mouse";return d.on(u+"up",m=>{m.preventDefault(),R([{caption:"Abbrechen",callback:()=>{}},{caption:"Ich bin mir sicher: rollback!",color:"#ff6060",callback:()=>{this.rollback()}}],m.pageX+2,m.pageY+2),m.stopPropagation()}),i.append(n,r,l,d),{$div:i,statement:e,$rollbackButton:d}}rollback(){this.panelEntries.length!=0&&(this.main.isEmbedded()?(this.rollbackEmbedded(),this.main.getActionManager().setActive("rollback",this.panelEntries.length>0)):this.main.networkManager.rollback((t,i)=>{t==null&&i&&this.rollbackLocal()}))}rollbackLocal(e){let t=this.main.getCurrentWorkspace().database;for(e==null&&(e=t.version-1);t.version>e;)t.statements.pop(),t.version--;this.main.getDatabaseTool().initializeWorker(t.templateDump,t.statements,()=>{},()=>{this.main.getDatabaseExplorer().refreshAfterRetrievingDBStructure(),this.panelEntries.shift().$div.remove(),this.makeLastButtonActive(),this.main.getActionManager().setActive("rollback",this.panelEntries.length>0)})}rollbackEmbedded(){let e=this.main;e.writeQueryManager.rollback(),this.main.getDatabaseTool().initializeWorker(e.initialTemplateDump,e.initialStatements.concat(e.writeQueryManager.writtenStatements),()=>{},()=>{this.main.getDatabaseExplorer().refreshAfterRetrievingDBStructure(),this.panelEntries.shift().$div.remove(),this.makeLastButtonActive()})}}class Ct{constructor(){h(this,"MaxRowsPerInsert",300)}clean(e){switch(e.ast.type){case s.keywordCreate:return e.sqlCleaned=this.cleanCreateTableStatement(e.ast),e.sqlCleaned;case s.keywordInsert:return e.ast.select!=null?e.sql:(e.sqlCleaned=this.cleanInsertStatement(e.ast),e.sqlCleaned);default:return e.sql}}cleanInsertStatement(e){let t=`insert into ${e.table.identifier}`;e.columnList!=null&&e.columnList.length>0&&(t+=`(${e.columnList.map(r=>this.escapeIdentifier(r.identifier)).join(", ")})`),t+=`
121
+ `+l+" */",n.lineNumber,n.column+3+l.length)}}}setFontSize(e){let t=new Date().getTime();if(t-this.lastTime<150)return;this.lastTime=t;let i=this.editor.getOptions().get(x.EditorOption.fontSize);if(this.main instanceof Ee&&this.main.viewModeController.saveFontSize(e),e!=i){this.editor.updateOptions({fontSize:e});let r=this.editor.getOptions().get(x.EditorOption.fontSize)/e;this.editor.updateOptions({fontSize:e/r})}c(".jo_editorFontSize").css("font-size",e+"px"),c(".jo_editorFontSize").css("line-height",e+2+"px"),document.documentElement.style.setProperty("--breakpoint-size",e+"px"),document.documentElement.style.setProperty("--breakpoint-radius",e/2+"px"),this.main.getBottomDiv().errorManager.registerLightbulbOnClickFunctions()}changeEditorFontSize(e,t=!0){let i=this.editor.getOptions().get(x.EditorOption.fontSize);t&&(i<10?e*=1:i<20?e*=2:e*=4);let n=i+e;n>=6&&n<=80&&this.setFontSize(n)}addActions(){let e=this;this.editor.addAction({id:"Find bracket",label:"Finde korrespondierende Klammer",keybindings:[Qe.CtrlCmd|Ze.KeyK],precondition:null,keybindingContext:null,contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:function(t){return t.getAction("editor.action.jumpToBracket").run(),null}}),this.editor.addAction({id:"Execute statement",label:"SQL-Anweisung ausführen",keybindings:[Qe.CtrlCmd|Ze.Enter],precondition:null,keybindingContext:null,contextMenuGroupId:"navigation",contextMenuOrder:1,run:function(t){return e.main.getActionManager().trigger("execute"),null}})}onMarginMouseDown(e){}onDidChangeCursorPosition(e){e==null&&(e=this.editor.getPosition());let t=this.getCurrentlyEditedModule();if(t==null){this.elementDecoration=this.editor.deltaDecorations(this.elementDecoration,[]);return}let i=t.getElementAtPosition(e.lineNumber,e.column),n=[];if(i!=null){let l=i.usagePositions.get(t);if(l!=null)for(let d of l)n.push({range:{startColumn:d.column,startLineNumber:d.line,endColumn:d.column+d.length,endLineNumber:d.line},options:{className:"jo_revealSyntaxElement",isWholeLine:!1,overviewRuler:{color:{id:"editorIndentGuide.background"},darkColor:{id:"editorIndentGuide.activeBackground"},position:x.OverviewRulerLane.Left}}})}let r=!1;for(let o of t.getSQLSTatementsAtSelection(this.editor.getSelection())){let l="jo_highlightStatementGreen";o!=null&&(o.hasErrors?(l="jo_highlightStatementRed",o.acceptedBySQLite&&(l="jo_highlightStatementYellow",r=!0)):r=!0,n.push({range:{startColumn:o.from.column,startLineNumber:o.from.line,endColumn:o.to.column,endLineNumber:o.to.line},options:{className:l,isWholeLine:!1,overviewRuler:{color:{id:l},darkColor:{id:l},position:x.OverviewRulerLane.Left},minimap:{color:{id:l},position:x.MinimapPosition.Inline},zIndex:-100}}))}this.main.getActionManager().setActive("execute",r),r&&!this.main.isEmbedded()&&K.showHelper("playButtonHelper",this.main,c("div.img_start-dark")),this.elementDecoration=this.editor.deltaDecorations(this.elementDecoration,n)}getCurrentlyEditedModule(){return this.main.getCurrentlyEditedModule()}}class xt{constructor(e,t){h(this,"panelEntries",[]);this.main=e,this.$historyPanel=t}clear(){this.$historyPanel.empty(),this.main.getActionManager().setActive("rollback",!1),this.panelEntries=[]}clearAndShowStatements(e){this.clear(),this.appendStatements(e),this.main.getActionManager().setActive("rollback",e.length>0)}appendStatements(e){e.forEach(t=>{let i=this.makePanelEntry(t,this.panelEntries.length+1);this.$historyPanel.prepend(i.$div),this.panelEntries.unshift(i)}),e.length>0&&this.main.getActionManager().setActive("rollback",!0),this.makeLastButtonActive()}makeLastButtonActive(){this.panelEntries.forEach(e=>e.$rollbackButton.removeClass("jo_active")),this.panelEntries.length>0&&this.panelEntries[0].$rollbackButton.addClass("jo_active")}makePanelEntry(e,t){let i=c('<div class="jo_panelEntry"></div>'),n=c(`<div class="jo_panelEntryIndex">${t}.</div>`),r=c('<div class="jo_panelEntryText"></div>'),o=e.substring(0,Math.min(400,e.length));e.length>400&&(o+="..."),r.text(o);let l=c('<div class="img_copy jo_panelEntryCopyButton jo_active jo_button" title="In die Zwischenablage kopieren"></div>'),d=c('<div class="img_undo jo_panelEntryRollbackButton jo_button" title="Rollback"></div>');l.on("click",()=>{wt(e)});let u=window.PointerEvent?"pointer":"mouse";return d.on(u+"up",m=>{m.preventDefault(),R([{caption:"Abbrechen",callback:()=>{}},{caption:"Ich bin mir sicher: rollback!",color:"#ff6060",callback:()=>{this.rollback()}}],m.pageX+2,m.pageY+2),m.stopPropagation()}),i.append(n,r,l,d),{$div:i,statement:e,$rollbackButton:d}}rollback(){this.panelEntries.length!=0&&(this.main.isEmbedded()?(this.rollbackEmbedded(),this.main.getActionManager().setActive("rollback",this.panelEntries.length>0)):this.main.networkManager.rollback((t,i)=>{t==null&&i&&this.rollbackLocal()}))}rollbackLocal(e){let t=this.main.getCurrentWorkspace().database;for(e==null&&(e=t.version-1);t.version>e;)t.statements.pop(),t.version--;this.main.getDatabaseTool().initializeWorker(t.templateDump,t.statements,()=>{},()=>{this.main.getDatabaseExplorer().refreshAfterRetrievingDBStructure(),this.panelEntries.shift().$div.remove(),this.makeLastButtonActive(),this.main.getActionManager().setActive("rollback",this.panelEntries.length>0)})}rollbackEmbedded(){let e=this.main;e.writeQueryManager.rollback(),this.main.getDatabaseTool().initializeWorker(e.initialTemplateDump,e.initialStatements.concat(e.writeQueryManager.writtenStatements),()=>{},()=>{this.main.getDatabaseExplorer().refreshAfterRetrievingDBStructure(),this.panelEntries.shift().$div.remove(),this.makeLastButtonActive()})}}class St{constructor(){h(this,"MaxRowsPerInsert",300)}clean(e){switch(e.ast.type){case s.keywordCreate:return e.sqlCleaned=this.cleanCreateTableStatement(e.ast),e.sqlCleaned;case s.keywordInsert:return e.ast.select!=null?e.sql:(e.sqlCleaned=this.cleanInsertStatement(e.ast),e.sqlCleaned);default:return e.sql}}cleanInsertStatement(e){let t=`insert into ${e.table.identifier}`;e.columnList!=null&&e.columnList.length>0&&(t+=`(${e.columnList.map(r=>this.escapeIdentifier(r.identifier)).join(", ")})`),t+=`
122
122
  values`;let i="",n=[];if(e.values!=null&&e.values.length>0)for(let r of e.values)n.push(`
123
123
  (${r.map(o=>this.cleanValue(o)).join(", ")})`);for(;n.length>0;)i+=t,i+=n.splice(0,Math.max(this.MaxRowsPerInsert,n.length)).join(`,
124
124
  `),i+=`;
@@ -130,7 +130,7 @@ values`;let i="",n=[];if(e.values!=null&&e.values.length>0)for(let r of e.values
130
130
  primary key(${this.escapeIdentifiers(i).join(", ")})`),e.uniqueConstraints.length>0&&(t+=`,
131
131
  `+e.uniqueConstraints.map(n=>"unique("+this.escapeIdentifiers(n).join(", ")+")").join(`,
132
132
  `)),t+=`
133
- );`,t}cleanForeignKeyInfo(e){let t=`foreign key (${this.escapeIdentifier(e.column)}) references ${this.escapeIdentifier(e.referencesTable)}(${this.escapeIdentifier(e.referencesColumn)})`;return e.onDelete&&(t+=" on delete "+e.onDelete),e.onUpdate&&(t+=" on update "+e.onUpdate),t}cleanColumnDef(e){let t=e.baseType.getSQLiteType();t=="int"&&e.isAutoIncrement&&(t="integer");let i=`${this.escapeIdentifier(e.identifier)} ${t}`;if(e.parameters!=null&&e.parameters.length>0&&!e.isAutoIncrement&&(i+=`(${e.parameters.join(", ")})`),e.notNull&&(i+=" not null"),e.defaultValue!=null&&(i+=" default "+e.defaultValue),(e.isPrimary||e.isAutoIncrement)&&(i+=" primary key"),e.isAutoIncrement&&(i+=" autoincrement"),e.foreignKeyInfo!=null){let o=e.foreignKeyInfo,l=o.referencesColumn;o.referencesTable&&(l=this.escapeIdentifier(o.referencesTable)+"("+this.escapeIdentifier(l)+")"),i+=" references "+l,o.onDelete&&(i+=" on delete "+o.onDelete),o.onUpdate&&(i+=" on update "+o.onUpdate)}if(e.collate!=null){let o=e.collate.toLocaleLowerCase();["binary","nocase","rtrim"].indexOf(o)>=0&&(i+=" collate "+o)}let n=e.parameters?e.parameters:[0,0],r=e.baseType.checkFunction(this.escapeIdentifier(e.identifier),n);return r!=""&&(i+=" "+r),i}escapeIdentifier(e){return'"'+e+'"'}escapeIdentifiers(e){return e.map(this.escapeIdentifier)}}class xt{constructor(e){h(this,"createTableNodes");h(this,"insertNodes");h(this,"tableModifyingNodes");this.main=e}async loadFromUrl(e){if(e==null)return;let t=null;return e.endsWith(".zip")?t=await this.unzipURL(e):t=await(await fetch(e)).text(),this.importFromText(t)}async loadFromFile(e){if(e!=null)if(e.name.endsWith(".zip")){let t=await this.unzipFile(e);return this.importFromText(t)}else return new Promise((t,i)=>{var n=new FileReader;n.onload=r=>{let o=r.target.result;t(this.importFromText(o))},n.readAsText(e)})}async unzipURL(e){const t=new Qe(new Ft(e));return this.unzipIntern(t)}async unzipFile(e){const t=new Qe(new Nt(e));return this.unzipIntern(t)}async unzipIntern(e){let t=await e.getEntries();t=t.filter(n=>n.filename.endsWith(".sql"));let i="";if(t.length)for(let n of t)i+=await n.getData(new Wt,{onprogress:(r,o)=>{}});return await e.close(),i}async importFromText(e){if(e==null)return null;let i=new Re().lex(e),n=new ye,r=new U({dirty:!1,name:"",saved:!0,student_edited_after_revision:!1,submitted_date:null,text:e,text_before_revision:null,version:0},this.main);r.tokenList=i.tokens,n.parse(r),this.createTableNodes=r.sqlStatements.filter(o=>o.ast.type==s.keywordCreate).map(o=>o.ast),this.insertNodes=r.sqlStatements.filter(o=>o.ast.type==s.keywordInsert).map(o=>o.ast),this.tableModifyingNodes=r.sqlStatements.filter(o=>o.ast.type==s.keywordAlter&&o.ast.kind=="omittedKind").map(o=>o.ast);for(let o of this.tableModifyingNodes){let l=this.findCreateTableNode(o.tableIdentifier);if(l!=null){if(o.primaryKeys!=null&&(l.combinedPrimaryKeyColumns=o.primaryKeys,l.columnList.forEach(d=>d.isPrimary=!1)),o.autoIncrementColumn!=null){let d=this.findCreateTableColumnNode(l,o.autoIncrementColumn);d!=null&&(d.isPrimary=!0)}if(o.modifyColumnInfo!=null)for(let d of o.modifyColumnInfo){let u=this.findCreateTableColumnNode(l,d.identifier),m=l.columnList.indexOf(u);l.columnList.splice(m,1,d)}if(o.foreignKeys!=null)for(let d of o.foreignKeys)l.foreignKeyInfoList.push(d);if(o.indices!=null)for(let d of o.indices)r.sqlStatements.push({acceptedBySQLite:!0,from:null,to:null,hasErrors:!1,ast:{type:s.keywordIndex,columnIdentifier:d.column,indexIdentifier:d.index_name,tableIdentifier:o.tableIdentifier,unique:d.unique,position:null,endPosition:null,symbolTable:null},sql:`create ${d.unique?"unique ":""}index ${d.index_name} on ${o.tableIdentifier}(${d.column});`,resultTypes:[]})}}return this.makeDatabase(r.sqlStatements)}findCreateTableNode(e){return e=e.toLocaleLowerCase(),this.createTableNodes.find(t=>t.identifier.toLocaleLowerCase()==e)}findCreateTableColumnNode(e,t){return t=t.toLocaleLowerCase(),e.columnList.find(i=>i.identifier.toLocaleLowerCase()==t)}async makeDatabase(e){let t=new Ct,i=e.filter(o=>o.ast.type!=s.omittedeStatement).map(o=>t.clean(o));i.unshift("PRAGMA foreign_keys = OFF;"),i.push("PRAGMA foreign_keys = ON;");let n=new W(this.main);return new Promise((o,l)=>{n.initializeWorker(null,i,()=>{n.export(d=>{o({binDump:d})},d=>{l(d)})})})}}class xe{async loadFromFile(e,t){if(e!=null)if(t.getWaitOverlay().show("Lese Datei ein..."),e.name.endsWith(".sql")||e.name.endsWith(".zip")){let n=await new xt(t).loadFromFile(e);return t.getWaitOverlay().hide(),n}else{var i=new FileReader;return new Promise((n,r)=>{i.onload=o=>{let l=o.target.result,d=new Uint8Array(l);W.getDumpType(d)=="binaryCompressed"&&(d=H.inflate(d)),t.getWaitOverlay().hide(),n({binDump:d})},i.readAsArrayBuffer(e)})}}saveToFile(e){e.export(t=>{let i=prompt("Bitte geben Sie den Dateinamen ein","datenbank.sqLite");if(i==null){alert("Der Dateiname ist leer, daher wird nichts gespeichert.");return}i.endsWith(".sqLite")||(i=i+".sqLite"),ze(new Blob([t.buffer]),i,!0)},()=>{})}}class We{constructor(e,t,i){h(this,"$dialog");h(this,"database");this.main=e,this.owner_id=t,this.path=i,this.init()}init(){this.$dialog=c("#dialog"),c("#main").css("visibility","hidden"),this.$dialog.append(c(`<div class="jo_ds_heading">Neue Datenbank anlegen</div>
133
+ );`,t}cleanForeignKeyInfo(e){let t=`foreign key (${this.escapeIdentifier(e.column)}) references ${this.escapeIdentifier(e.referencesTable)}(${this.escapeIdentifier(e.referencesColumn)})`;return e.onDelete&&(t+=" on delete "+e.onDelete),e.onUpdate&&(t+=" on update "+e.onUpdate),t}cleanColumnDef(e){let t=e.baseType.getSQLiteType();t=="int"&&e.isAutoIncrement&&(t="integer");let i=`${this.escapeIdentifier(e.identifier)} ${t}`;if(e.parameters!=null&&e.parameters.length>0&&!e.isAutoIncrement&&(i+=`(${e.parameters.join(", ")})`),e.notNull&&(i+=" not null"),e.defaultValue!=null&&(i+=" default "+e.defaultValue),(e.isPrimary||e.isAutoIncrement)&&(i+=" primary key"),e.isAutoIncrement&&(i+=" autoincrement"),e.foreignKeyInfo!=null){let o=e.foreignKeyInfo,l=o.referencesColumn;o.referencesTable&&(l=this.escapeIdentifier(o.referencesTable)+"("+this.escapeIdentifier(l)+")"),i+=" references "+l,o.onDelete&&(i+=" on delete "+o.onDelete),o.onUpdate&&(i+=" on update "+o.onUpdate)}if(e.collate!=null){let o=e.collate.toLocaleLowerCase();["binary","nocase","rtrim"].indexOf(o)>=0&&(i+=" collate "+o)}let n=e.parameters?e.parameters:[0,0],r=e.baseType.checkFunction(this.escapeIdentifier(e.identifier),n);return r!=""&&(i+=" "+r),i}escapeIdentifier(e){return'"'+e+'"'}escapeIdentifiers(e){return e.map(this.escapeIdentifier)}}class Et{constructor(e){h(this,"createTableNodes");h(this,"insertNodes");h(this,"tableModifyingNodes");this.main=e}async loadFromUrl(e){if(e==null)return;let t=null;return e.endsWith(".zip")?t=await this.unzipURL(e):t=await(await fetch(e)).text(),this.importFromText(t)}async loadFromFile(e){if(e!=null)if(e.name.endsWith(".zip")){let t=await this.unzipFile(e);return this.importFromText(t)}else return new Promise((t,i)=>{var n=new FileReader;n.onload=r=>{let o=r.target.result;t(this.importFromText(o))},n.readAsText(e)})}async unzipURL(e){const t=new Je(new Wt(e));return this.unzipIntern(t)}async unzipFile(e){const t=new Je(new Rt(e));return this.unzipIntern(t)}async unzipIntern(e){let t=await e.getEntries();t=t.filter(n=>n.filename.endsWith(".sql"));let i="";if(t.length)for(let n of t)i+=await n.getData(new qt,{onprogress:(r,o)=>{}});return await e.close(),i}async importFromText(e){if(e==null)return null;let i=new Re().lex(e),n=new Ce,r=new U({dirty:!1,name:"",saved:!0,student_edited_after_revision:!1,submitted_date:null,text:e,text_before_revision:null,version:0},this.main);r.tokenList=i.tokens,n.parse(r),this.createTableNodes=r.sqlStatements.filter(o=>o.ast.type==s.keywordCreate).map(o=>o.ast),this.insertNodes=r.sqlStatements.filter(o=>o.ast.type==s.keywordInsert).map(o=>o.ast),this.tableModifyingNodes=r.sqlStatements.filter(o=>o.ast.type==s.keywordAlter&&o.ast.kind=="omittedKind").map(o=>o.ast);for(let o of this.tableModifyingNodes){let l=this.findCreateTableNode(o.tableIdentifier);if(l!=null){if(o.primaryKeys!=null&&(l.combinedPrimaryKeyColumns=o.primaryKeys,l.columnList.forEach(d=>d.isPrimary=!1)),o.autoIncrementColumn!=null){let d=this.findCreateTableColumnNode(l,o.autoIncrementColumn);d!=null&&(d.isPrimary=!0)}if(o.modifyColumnInfo!=null)for(let d of o.modifyColumnInfo){let u=this.findCreateTableColumnNode(l,d.identifier),m=l.columnList.indexOf(u);l.columnList.splice(m,1,d)}if(o.foreignKeys!=null)for(let d of o.foreignKeys)l.foreignKeyInfoList.push(d);if(o.indices!=null)for(let d of o.indices)r.sqlStatements.push({acceptedBySQLite:!0,from:null,to:null,hasErrors:!1,ast:{type:s.keywordIndex,columnIdentifier:d.column,indexIdentifier:d.index_name,tableIdentifier:o.tableIdentifier,unique:d.unique,position:null,endPosition:null,symbolTable:null},sql:`create ${d.unique?"unique ":""}index ${d.index_name} on ${o.tableIdentifier}(${d.column});`,resultTypes:[]})}}return this.makeDatabase(r.sqlStatements)}findCreateTableNode(e){return e=e.toLocaleLowerCase(),this.createTableNodes.find(t=>t.identifier.toLocaleLowerCase()==e)}findCreateTableColumnNode(e,t){return t=t.toLocaleLowerCase(),e.columnList.find(i=>i.identifier.toLocaleLowerCase()==t)}async makeDatabase(e){let t=new St,i=e.filter(o=>o.ast.type!=s.omittedeStatement).map(o=>t.clean(o));i.unshift("PRAGMA foreign_keys = OFF;"),i.push("PRAGMA foreign_keys = ON;");let n=new W(this.main);return new Promise((o,l)=>{n.initializeWorker(null,i,()=>{n.export(d=>{o({binDump:d})},d=>{l(d)})})})}}class Se{async loadFromFile(e,t){if(e!=null)if(t.getWaitOverlay().show("Lese Datei ein..."),e.name.endsWith(".sql")||e.name.endsWith(".zip")){let n=await new Et(t).loadFromFile(e);return t.getWaitOverlay().hide(),n}else{var i=new FileReader;return new Promise((n,r)=>{i.onload=o=>{let l=o.target.result,d=new Uint8Array(l);W.getDumpType(d)=="binaryCompressed"&&(d=H.inflate(d)),t.getWaitOverlay().hide(),n({binDump:d})},i.readAsArrayBuffer(e)})}}saveToFile(e){e.export(t=>{let i=prompt("Bitte geben Sie den Dateinamen ein","datenbank.sqLite");if(i==null){alert("Der Dateiname ist leer, daher wird nichts gespeichert.");return}i.endsWith(".sqLite")||(i=i+".sqLite"),He(new Blob([t.buffer]),i,!0)},()=>{})}}class We{constructor(e,t,i){h(this,"$dialog");h(this,"database");this.main=e,this.owner_id=t,this.path=i,this.init()}init(){this.$dialog=c("#dialog"),c("#main").css("visibility","hidden"),this.$dialog.append(c(`<div class="jo_ds_heading">Neue Datenbank anlegen</div>
134
134
 
135
135
  <div class="jo_ds_settings">
136
136
  <div class="jo_ds_settings_caption">Name der Datenbank:</div><div><input class="dialog-input jo_databasename" value="Neue Datenbank"></input></div>
@@ -182,17 +182,17 @@ values`;let i="",n=[];if(e.values!=null&&e.values.length>0)for(let r of e.values
182
182
  <button id="jo_ds_cancel_button">Abbrechen</button>
183
183
  <button id="jo_ds_create_database_button">Datenbank anlegen</button>
184
184
  </div>
185
- `)),Te(this.$dialog);let e=c(".jo_templatelist_others"),t=c(".jo_templatelist_mine"),i=this.main.user.id;this.main.networkManager.fetchTemplateList(o=>{o.sort((d,u)=>d.name.localeCompare(u.name)),o.forEach(d=>{let u=c('<div class="jo_templateListEntry"></div>');u.append(c(`<div class="jo_tle_firstline">${d.name} <span class="jo_tle_ownername"> (von ${d.ownerName})</span></div>`)),u.append(c(`<div class="jo_tle_secondline">${d.description}</div>`)),u.data("templateId",d.id),u.data("name",d.name),d.ownerId==i?t.append(u):e.append(u),d.$tle=u,u.on("pointerdown",()=>{e.find(".jo_templateListEntry").removeClass("jo_active"),t.find(".jo_templateListEntry").removeClass("jo_active"),u.addClass("jo_active")})});let l=c(".jo_templatename");l.on("input",()=>{let d=l.val();e.find(".jo_templateListEntry").hide(),t.find(".jo_templateListEntry").hide(),o.forEach(u=>{(u.name+u.ownerName+(u.description?u.description:"")).indexOf(d)>=0&&u.$tle.show()})})});let n=c(".jo_databaseimport_dropzone");n.on("dragover",o=>{o.stopPropagation(),o.preventDefault(),o.originalEvent.dataTransfer.dropEffect="copy"}),n.on("drop",o=>{o.stopPropagation(),o.preventDefault();var l=o.originalEvent.dataTransfer.files;this.importFile(l)});let r=c(".jo_dumpfile");r.on("change",o=>{var l=o.originalEvent.target.files;this.importFile(l).then(()=>{r.val(null)})}),this.$dialog.css("visibility","visible"),c("#jo_ds_cancel_button").on("click",()=>{this.showMainWindow()}),c("#jo_ds_create_database_button").on("click",()=>{let o="emptyDatabase";c(".jo_createDatabaseFromTemplateTab").hasClass("jo_active")&&(o="fromTemplate"),c(".jo_createDatabaseUseExistingTab").hasClass("jo_active")&&(o="useExistingDatabase"),c(".jo_createDatabaseUseDumpFile").hasClass("jo_active")&&(o="useDumpFile");let l={id:null,isFolder:!1,name:c(".dialog-input.jo_databasename").val(),path:this.path.join("/")};switch(o){case"emptyDatabase":this.createWorkspace(l);break;case"fromTemplate":let d=c(".jo_templateListEntry.jo_active");if(d.length!=1){alert("Bitte wählen Sie genau eine Vorlage aus.");return}else l.template_database_id=d.data("templateId"),l.name=="Neue Datenbank"&&(l.name=d.data("name")),this.createWorkspace(l);break;case"useExistingDatabase":let u=c(".jo_databasecodeinput").val(),m=u.indexOf("T");if(m==-1){alert("Der Zugriffscode muss das Zeichen T enthalten.");return}l.otherDatabaseId=Number.parseInt(u.substring(0,m)),l.secret=u.substring(m+1),this.createWorkspace(l);break;case"useDumpFile":if(this.database!=null)new Le().uploadCurrentDatabase(-1,this.main,this.database.binDump,"uploadBaseTemplateForWorkspace",f=>{l.template_id=f.newTemplateId,this.createWorkspace(l)});else{alert("Bitte laden Sie zuerst den Binärdump einer Datenbank hoch.");return}break}})}createWorkspace(e){this.main.networkManager.sendCreateWorkspace(e,this.owner_id,t=>{if(t!=null){alert(t);return}let i=this.main.createNewWorkspace(e.name,this.owner_id);i.path=e.path,i.id=e.id,i.sql_history="";let n=this.main.projectExplorer;this.main.workspaceList.push(i);let r={name:e.name,externalElement:i,iconClass:"workspace",isFolder:!1,path:this.path};n.workspaceListPanel.addElement(r,!0),i.panelElement=r,i.renderSettingsButton(r),n.workspaceListPanel.sortElements(),n.fileListPanel.sortElements(),n.setWorkspaceActive(i),this.showMainWindow()})}async importFile(e){let t=this,n=await new xe().loadFromFile(e[0],this.main),r=!1;if(W.getDumpType(n.binDump)=="binaryCompressed"){let l=H.inflate(n.binDump);W.getDumpType(l)=="binaryUncompressed"&&(r=!0)}else W.getDumpType(n.binDump)=="binaryUncompressed"&&(n.binDump=H.deflate(n.binDump),r=!0);r?(t.database=n,c(".jo_databaseimport_ok").html("Die Datenbankdatei wurde erfolgreich von Datei eingelesen. Sie können die Datenbank jetzt durch Klick auf den Button unten erstellen.")):alert("In der Datei befindet sich kein Binärdump einer Datenbank.")}showMainWindow(){c("#main").css("visibility","visible"),this.$dialog.css("visibility","hidden"),this.$dialog.empty()}}class Pi{constructor(e){h(this,"currentSubmenu",{});h(this,"openSubmenusOnMousemove",!1);this.main=e}initGUI(e){let t=this,i=this.main.getMonacoEditor(),n={items:[{identifier:"Datei",subMenu:{items:[{identifier:"Speichern und Beenden",action:()=>{c("#buttonLogout").trigger("click")}}]}},{identifier:"Bearbeiten",subMenu:{items:[{identifier:"Rückgängig (Strg + z)",action:()=>{i.trigger(".","undo",{})}},{identifier:"Wiederholen (Strg + y)",action:()=>{i.trigger(".","redo",{})}},{identifier:"-"},{identifier:"Kopieren (Strg + c)",action:()=>{i.getAction("editor.action.clipboardCopyAction").run()}},{identifier:"Ausschneiden (Strg + x)",action:()=>{i.getAction("editor.action.clipboardCutAction").run()}},{identifier:"Nach oben kopieren (Alt + Shift + Pfeil rauf)",action:()=>{i.getAction("editor.action.copyLinesUpAction").run()}},{identifier:"Nach unten kopieren (Alt + Shift + Pfeil runter)",action:()=>{i.getAction("editor.action.copyLinesDownAction").run()}},{identifier:"Nach oben verschieben (Alt + Pfeil rauf)",action:()=>{i.getAction("editor.action.moveLinesUpAction").run()}},{identifier:"Nach unten verschieben (Alt + Pfeil runter)",action:()=>{i.getAction("editor.action.moveLinesDownAction").run()}},{identifier:"-"},{identifier:"Suchen... (Strg + f)",action:()=>{i.getAction("actions.find").run()}},{identifier:"Ersetzen... (Strg + h)",action:()=>{i.getAction("editor.action.startFindReplaceAction").run()}},{identifier:"-"},{identifier:"Aus-/Einkommentieren (Strg + #)",action:()=>{i.getAction("editor.action.commentLine").run()}},{identifier:"Dokument formatieren (Alt + Shift + f)",action:()=>{i.getAction("editor.action.formatDocument").run()}},{identifier:"-"},{identifier:"Finde zugehörige Klammer (Strg + k)",action:()=>{i.getAction("editor.action.jumpToBracket").run()}},{identifier:"-"},{identifier:"Alles zusammenfalten",action:()=>{i.getAction("editor.foldAll").run()}},{identifier:"Alles auffalten",action:()=>{i.getAction("editor.unfoldAll").run()}},{identifier:"-"},{identifier:"Vorschlag auslösen (Strg + Leertaste)",action:()=>{i.focus(),setTimeout(()=>{i.getAction("editor.action.triggerSuggest").run()},200)}},{identifier:"Parameterhilfe (Strg + Shift + Leertaste)",action:()=>{i.getAction("editor.action.triggerParameterHints").run()}},{identifier:"Gehe zur Definition (Strg + Click)",action:()=>{i.focus(),setTimeout(()=>{i.getAction("editor.action.revealDefinition").run()},200)}}]}},{identifier:"Ansicht",subMenu:{items:[{identifier:"Theme",subMenu:{items:[{identifier:"Dark",action:()=>{t.switchTheme("dark")}},{identifier:"Light",action:()=>{t.switchTheme("light")}}]}},{identifier:"-"},{identifier:"Hoher Kontrast im Editor ein/aus",action:()=>{i.getAction("editor.action.toggleHighContrast").run()}},{identifier:"-"},{identifier:"Zoom out (Strg + Mausrad)",action:()=>{this.main.editor.changeEditorFontSize(-4)}},{identifier:"Zoom normal",action:()=>{this.main.editor.setFontSize(14)}},{identifier:"Zoom in (Strg + Mausrad)",action:()=>{this.main.editor.changeEditorFontSize(4)}}]}},{identifier:"Datenbank",subMenu:{items:[{identifier:"Neue Datenbank anlegen...",action:()=>{let r=t.main.user.id;t.main.workspacesOwnerId!=null&&(r=t.main.workspacesOwnerId),new We(t.main,r,[])}},{identifier:"Einstellungen...",action:()=>{new wt(this.main,this.main.currentWorkspace)}},{identifier:"Export als Binärdump (.sqLite-File)...",action:()=>{new xe().saveToFile(this.main.getDatabaseTool())}},{identifier:"Aktuellen Zustand als Vorlage hochladen...",action:()=>{let r=this.main.currentWorkspace;if(r==null){alert("Es ist kein Workspace ausgewählt.");return}if(r.database.owner_id!=this.main.user.id){alert("Die Datenbank gehört einer anderen Benutzerin/einem anderen Benutzer. Sie kann daher nicht als Vorlage hochgeladen werden.");return}if(r.database.published_to==0){alert(`Die Datenbank ist noch nicht für andere Benutzer/innen veröffentlicht, daher kann sie nicht als Vorlage hochgeladen werden.
186
- Die Möglichkeit zum Veröffentlichen finden Sie unter Datenbank->Einstellungen.`);return}new Le().uploadCurrentDatabase(r.id,this.main,null,"publishDatabaseAsTemplate",()=>{alert("Der aktuelle Zustand der Datebank wurde erfolgreich als Vorlage hochgeladen.")})}}]}},{identifier:"Hilfe",subMenu:{items:[{identifier:"Über die Online-IDE...",link:"https://www.learnj.de/doku.php?id=javaonline:ueber"},{identifier:"Impressum...",link:"https://www.learnj.de/doku.php?id=ide:impressum"},{identifier:"Datenschutzerklärung...",link:"https://www.learnj.de/doku.php?id=ide:datenschutzerklaerung"},{identifier:"<div class='jo_menu_version'>Version 2.0 (8.2.2026, 16:26 Uhr)</div>",noHoverAnimation:!0}]}}]};e!=null&&e.is_admin&&n.items[0].subMenu.items.push({identifier:"Shutdown server...",action:()=>{confirm("Server wirklich herunterfahren?")&&S("shutdown",{},()=>{alert("Server erfolgreich heruntergefahren.")},r=>{alert(r)})}}),c("#mainmenu").empty(),this.initMenu(n,0)}switchTheme(e){this.main.viewModeController.setTheme(e)}initMenu(e,t){e.level=t,t==0?e.$element=c("#mainmenu"):(e.$element=c('<div class="jo_submenu"></div>'),c("body").append(e.$element)),e.$element.data("model",e);for(let n of e.items){if(n.identifier=="-")n.$element=c('<div class="jo_menuitemdivider"></div>');else{let r=n.noHoverAnimation?' class="jo_menuitem_nohover"':"";if(n.$element=c(`<div${r}>${n.identifier}</div>`),n.link!=null){let o=c('<a href="'+n.link+'" target="_blank" class="jo_menulink"></a>');o.on("pointerdown",l=>{l.stopPropagation()}),o.on("pointerup",l=>{l.stopPropagation(),setTimeout(()=>{e.$element.hide()},500)}),o.append(n.$element),n.$element=o}n.subMenu!=null&&this.initMenu(n.subMenu,t+1),this.initMenuitemCallbacks(e,n),t==0&&n.$element.addClass("jo_mainmenuitem")}e.$element.append(n.$element),n.$element.data("model",n)}let i=this;c(document).on("pointerdown",()=>{for(let n=0;n<5;n++)i.currentSubmenu[n]!=null&&(i.currentSubmenu[n].hide(),i.currentSubmenu[n]=null);i.openSubmenusOnMousemove=!1})}initMenuitemCallbacks(e,t){let i=this;t.action!=null&&(t.$element.on("pointerdown",n=>{n.stopPropagation()}),t.$element.on("pointerup",n=>{n.stopPropagation(),t.action(t.identifier);for(let r=0;r<5;r++)i.currentSubmenu[r]!=null&&(i.currentSubmenu[r].hide(),i.currentSubmenu[r]=null);i.openSubmenusOnMousemove=!1})),t.subMenu!=null?(t.$element.on("mousedown",n=>{i.opensubmenu(t),i.openSubmenusOnMousemove=!0,n.stopPropagation()}),t.$element.on("mousemove.mainmenu",()=>{i.openSubmenusOnMousemove?i.opensubmenu(t):i.currentSubmenu[e.level+1]!=null&&(i.currentSubmenu[e.level+1].hide(),i.currentSubmenu[e.level+1]=null)})):t.$element.on("mousemove.mainmenu",()=>{i.currentSubmenu[e.level+1]!=null&&(i.currentSubmenu[e.level+1].hide(),i.currentSubmenu[e.level+1]=null)})}opensubmenu(e){let t=e.subMenu,i,n;t.level==1?(i=e.$element.position().left,n=30):(i=e.$element.offset().left+e.$element.width(),n=e.$element.offset().top),t.$element.css({top:""+n+"px",left:""+i+"px"}),this.currentSubmenu[t.level]!=null&&this.currentSubmenu[t.level].hide(),t.$element.show(),this.currentSubmenu[t.level]=t.$element}}class St{constructor(e,t){h(this,"$buttonStart");h(this,"$buttonRollback");this.main=e,this.$buttonsContainer=t,this.$buttonStart=c('<div title="Start" class="img_start-dark jo_button"></div>'),this.$buttonRollback=c('<div title="Rollback" class="img_undo jo_button"></div>');let i=this.main.getActionManager();i.registerAction("execute",["Strg + Enter"],()=>{i.isActive("execute")&&this.main.getResultsetPresenter().executeSelectedStatements()},"SQL-Statement ausführen",this.$buttonStart),i.setActive("execute",!1),i.registerAction("rollback",["Strg + LeftArrow"],()=>{i.isActive("rollback")&&this.main.getHistoryViewer().rollback()},"Letztes schreibendes SQL-Statement rückgängig machen",this.$buttonRollback),i.setActive("rollback",!1),t.append(this.$buttonStart,this.$buttonRollback)}}const T=class T{constructor(e,t,i,n,r,o,l,d,u,m,f){h(this,"elements",[]);h(this,"$captionElement");h(this,"$buttonNew");h(this,"$listElement");h(this,"fixed");h(this,"dontSortElements",!1);h(this,"newFilesElementCallback");h(this,"newDatabaseElementCallback");h(this,"newFolderCallback");h(this,"renameCallback");h(this,"deleteCallback");h(this,"selectCallback");h(this,"addElementActionCallback");h(this,"contextMenuProvider");h(this,"moveCallback");h(this,"dropElementCallback");h(this,"$newFolderAction");this.accordion=e,this.caption=t,this.flexWeight=i,this.newButtonClass=n,this.buttonNewTitle=r,this.defaultIconClass=o,this.withDeleteButton=l,this.withFolders=d,this.kind=u,this.enableDrag=m,this.acceptDropKinds=f,e.addPanel(this);let p=window.PointerEvent?"pointer":"mouse";if(d){let b=this;this.$newFolderAction=c('<div class="img_add-folder-dark jo_button jo_active" style="margin-right: 4px" title="Neuen Ordner auf oberster Ebene anlegen">'),this.$newFolderAction.on(p+"down",g=>{g.stopPropagation(),g.preventDefault();let w=[];this.addFolder("Neuer Ordner",w,y=>{this.newFolderCallback(y,()=>{this.sortElements(),y.$htmlFirstLine[0].scrollIntoView(),et(y.$htmlFirstLine.find(".jo_filename"),"background-color",[0,255,0],2e3)})})}),this.addAction(this.$newFolderAction);let k=c('<div class="img_collapse-all-dark jo_button jo_active" style="margin-right: 4px" title="Alle Ordner zusammenfalten">');k.on(p+"down",g=>{g.stopPropagation(),g.preventDefault(),b.collapseAll()}),this.addAction(k)}}collapseAll(){for(let e of this.elements)e.isFolder&&e.$htmlFirstLine.hasClass("jo_expanded")&&(e.$htmlFirstLine.removeClass("jo_expanded"),e.$htmlFirstLine.addClass("jo_collapsed")),e.path.length>0&&e.$htmlFirstLine.slideUp(200)}remove(){this.$captionElement.remove(),this.$listElement.remove()}setFixed(e){this.fixed=e,this.fixed?(this.grow(),this.$captionElement.addClass("jo_fixed")):this.$captionElement.removeClass("jo_fixed")}enableNewButton(e){this.$buttonNew!=null&&(e?this.$buttonNew.show():this.$buttonNew.hide())}getCurrentlySelectedPath(){let e=[],t=this.getSelectedElement();return t!=null&&(e=t.path.slice(0),t.isFolder&&e.push(t.name)),e}compareWithPath(e,t,i,n,r,o){t=t.slice(),t.push(e),e="",r=r.slice(),r.push(n),n="";let l=0;for(;l<t.length&&l<r.length;){let d=t[l].localeCompare(r[l]);if(d!=0)return d;l++}return t.length<r.length?-1:t.length>r.length?1:e.localeCompare(n)}getElementIndex(e,t,i){for(let n=0;n<this.elements.length;n++){let r=this.elements[n];if(this.compareWithPath(e,t,i,r.name,r.path,r.isFolder)<0)return n}return this.elements.length}insertElement(e){let t=this.getElementIndex(e.name,e.path,e.isFolder);this.elements.splice(t,0,e);let i=this.$listElement.find(".jo_file");if(t==0)this.$listElement.prepend(e.$htmlFirstLine);else if(t==i.length)this.$listElement.append(e.$htmlFirstLine);else{let n=i.get(t);c(n).before(e.$htmlFirstLine)}}addFolder(e,t,i){let n={name:e,isFolder:!0,path:t},r=this.renderElement(n,!0);this.insertElement(n),r[0].scrollIntoView(),this.renameElement(n,()=>{i(n)})}renderOuterHtmlElements(e){let t=this;if(this.$captionElement=c(`<div class="jo_leftpanelcaption jo_expanded">
187
- <div class="jo_captiontext">`+this.caption+'</div><div class="jo_actions"></div></div>'),this.newButtonClass!=null){this.$buttonNew=c('<div class="jo_button jo_active '+this.newButtonClass+'" title="'+this.buttonNewTitle+'">'),this.$captionElement.find(".jo_actions").append(this.$buttonNew);let l=window.PointerEvent?"pointer":"mouse";this.$buttonNew.on(l+"down",d=>{K.close(),d.stopPropagation();let u=t.getCurrentlySelectedPath(),m={name:"Neu",isFolder:!1,path:u},f=this.getElementIndex("",u,!1);this.elements.splice(f,0,m);let p=this.renderElement(m,!0);if(f==0)this.$listElement.prepend(p);else{let b=this.$listElement.find(".jo_file").get(f-1);c(b).after(p)}p[0].scrollIntoView(),t.renameElement(m,()=>{t.newFilesElementCallback(m,b=>{m.externalElement=b,m.$htmlSecondLine!=null&&m.$htmlSecondLine.insertAfter(p),t.selectCallback!=null&&t.select(m.externalElement)})})})}let i=c('<div id="filelistouter" class="jo_projectexplorerdiv jo_scrollable" data-grow="'+this.flexWeight+'" style="flex-grow: '+this.flexWeight+'"></div>');this.$listElement=c('<div class="jo_filelist"></div>'),i.append(this.$listElement),e.append(this.$captionElement),e.append(i);let n=this.$captionElement,r=this.$listElement.parent(),o=window.PointerEvent?"pointer":"mouse";n.on(o+"down",l=>{if(l.button==0&&!this.fixed){let d=r.data("grow");n.hasClass("jo_expanded")?t.accordion.parts.length>1&&r.animate({"flex-grow":.001},1e3,()=>{n.toggleClass("jo_expanded")}):(n.toggleClass("jo_expanded"),r.animate({"flex-grow":d},1e3))}}),n.on("dragover",l=>{T.currentlyDraggedElementKind==t.kind&&(n.addClass("jo_file_dragover"),l.preventDefault())}),n.on("dragleave",l=>{n.removeClass("jo_file_dragover")}),n.on("drop",l=>{if(T.currentlyDraggedElementKind==t.kind){l.preventDefault(),n.removeClass("jo_file_dragover");let d=T.currentlyDraggedElement;d!=null&&t.moveElement(d,null)}})}grow(){let e=this.$listElement.parent(),t=e.data("grow");e.css("flex-grow",t),this.$captionElement.addClass("jo_expanded")}addElement(e,t){e.$htmlFirstLine=this.renderElement(e,t),this.insertElement(e)}sortElements(){this.dontSortElements||(this.elements.sort((e,t)=>{let i=e.sortName?e.sortName:e.name,n=t.sortName?t.sortName:t.name;return this.compareWithPath(i,e.path,e.isFolder,n,t.path,t.isFolder)}),this.elements.forEach(e=>{this.$listElement.append(e.$htmlFirstLine)}))}setTextAfterFilename(e,t,i){if(e==null)return;let n=e.$htmlFirstLine.find(".jo_textAfterName");n.addClass(i),n.html(t)}addAction(e){this.$captionElement.find(".jo_actions").prepend(e)}renderElement(e,t){let i=window.PointerEvent?"pointer":"mouse",n=this,r="";e.iconClass==null&&(e.iconClass=this.defaultIconClass),e.isFolder&&(e.iconClass="folder",r=t?" jo_expanded":" jo_collapsed");let o="";e.path==null&&(e.path=[]);for(let u=0;u<e.path.length;u++)o+='<div class="jo_folderline"></div>';if(e.$htmlFirstLine=c(`<div class="jo_file jo_${e.iconClass} ${r}">
185
+ `)),Le(this.$dialog);let e=c(".jo_templatelist_others"),t=c(".jo_templatelist_mine"),i=this.main.user.id;this.main.networkManager.fetchTemplateList(o=>{o.sort((d,u)=>d.name.localeCompare(u.name)),o.forEach(d=>{let u=c('<div class="jo_templateListEntry"></div>');u.append(c(`<div class="jo_tle_firstline">${d.name} <span class="jo_tle_ownername"> (von ${d.ownerName})</span></div>`)),u.append(c(`<div class="jo_tle_secondline">${d.description}</div>`)),u.data("templateId",d.id),u.data("name",d.name),d.ownerId==i?t.append(u):e.append(u),d.$tle=u,u.on("pointerdown",()=>{e.find(".jo_templateListEntry").removeClass("jo_active"),t.find(".jo_templateListEntry").removeClass("jo_active"),u.addClass("jo_active")})});let l=c(".jo_templatename");l.on("input",()=>{let d=l.val();e.find(".jo_templateListEntry").hide(),t.find(".jo_templateListEntry").hide(),o.forEach(u=>{(u.name+u.ownerName+(u.description?u.description:"")).indexOf(d)>=0&&u.$tle.show()})})});let n=c(".jo_databaseimport_dropzone");n.on("dragover",o=>{o.stopPropagation(),o.preventDefault(),o.originalEvent.dataTransfer.dropEffect="copy"}),n.on("drop",o=>{o.stopPropagation(),o.preventDefault();var l=o.originalEvent.dataTransfer.files;this.importFile(l)});let r=c(".jo_dumpfile");r.on("change",o=>{var l=o.originalEvent.target.files;this.importFile(l).then(()=>{r.val(null)})}),this.$dialog.css("visibility","visible"),c("#jo_ds_cancel_button").on("click",()=>{this.showMainWindow()}),c("#jo_ds_create_database_button").on("click",()=>{let o="emptyDatabase";c(".jo_createDatabaseFromTemplateTab").hasClass("jo_active")&&(o="fromTemplate"),c(".jo_createDatabaseUseExistingTab").hasClass("jo_active")&&(o="useExistingDatabase"),c(".jo_createDatabaseUseDumpFile").hasClass("jo_active")&&(o="useDumpFile");let l={id:null,isFolder:!1,name:c(".dialog-input.jo_databasename").val(),path:this.path.join("/")};switch(o){case"emptyDatabase":this.createWorkspace(l);break;case"fromTemplate":let d=c(".jo_templateListEntry.jo_active");if(d.length!=1){alert("Bitte wählen Sie genau eine Vorlage aus.");return}else l.template_database_id=d.data("templateId"),l.name=="Neue Datenbank"&&(l.name=d.data("name")),this.createWorkspace(l);break;case"useExistingDatabase":let u=c(".jo_databasecodeinput").val(),m=u.indexOf("T");if(m==-1){alert("Der Zugriffscode muss das Zeichen T enthalten.");return}l.otherDatabaseId=Number.parseInt(u.substring(0,m)),l.secret=u.substring(m+1),this.createWorkspace(l);break;case"useDumpFile":if(this.database!=null)new Pe().uploadCurrentDatabase(-1,this.main,this.database.binDump,"uploadBaseTemplateForWorkspace",f=>{l.template_id=f.newTemplateId,this.createWorkspace(l)});else{alert("Bitte laden Sie zuerst den Binärdump einer Datenbank hoch.");return}break}})}createWorkspace(e){this.main.networkManager.sendCreateWorkspace(e,this.owner_id,t=>{if(t!=null){alert(t);return}let i=this.main.createNewWorkspace(e.name,this.owner_id);i.path=e.path,i.id=e.id,i.sql_history="";let n=this.main.projectExplorer;this.main.workspaceList.push(i);let r={name:e.name,externalElement:i,iconClass:"workspace",isFolder:!1,path:this.path};n.workspaceListPanel.addElement(r,!0),i.panelElement=r,i.renderSettingsButton(r),n.workspaceListPanel.sortElements(),n.fileListPanel.sortElements(),n.setWorkspaceActive(i),this.showMainWindow()})}async importFile(e){let t=this,n=await new Se().loadFromFile(e[0],this.main),r=!1;if(W.getDumpType(n.binDump)=="binaryCompressed"){let l=H.inflate(n.binDump);W.getDumpType(l)=="binaryUncompressed"&&(r=!0)}else W.getDumpType(n.binDump)=="binaryUncompressed"&&(n.binDump=H.deflate(n.binDump),r=!0);r?(t.database=n,c(".jo_databaseimport_ok").html("Die Datenbankdatei wurde erfolgreich von Datei eingelesen. Sie können die Datenbank jetzt durch Klick auf den Button unten erstellen.")):alert("In der Datei befindet sich kein Binärdump einer Datenbank.")}showMainWindow(){c("#main").css("visibility","visible"),this.$dialog.css("visibility","hidden"),this.$dialog.empty()}}class Pi{constructor(e){h(this,"currentSubmenu",{});h(this,"openSubmenusOnMousemove",!1);this.main=e}initGUI(e){let t=this,i=this.main.getMonacoEditor(),n={items:[{identifier:"Datei",subMenu:{items:[{identifier:"Speichern und Beenden",action:()=>{c("#buttonLogout").trigger("click")}}]}},{identifier:"Bearbeiten",subMenu:{items:[{identifier:"Rückgängig (Strg + z)",action:()=>{i.trigger(".","undo",{})}},{identifier:"Wiederholen (Strg + y)",action:()=>{i.trigger(".","redo",{})}},{identifier:"-"},{identifier:"Kopieren (Strg + c)",action:()=>{i.getAction("editor.action.clipboardCopyAction").run()}},{identifier:"Ausschneiden (Strg + x)",action:()=>{i.getAction("editor.action.clipboardCutAction").run()}},{identifier:"Nach oben kopieren (Alt + Shift + Pfeil rauf)",action:()=>{i.getAction("editor.action.copyLinesUpAction").run()}},{identifier:"Nach unten kopieren (Alt + Shift + Pfeil runter)",action:()=>{i.getAction("editor.action.copyLinesDownAction").run()}},{identifier:"Nach oben verschieben (Alt + Pfeil rauf)",action:()=>{i.getAction("editor.action.moveLinesUpAction").run()}},{identifier:"Nach unten verschieben (Alt + Pfeil runter)",action:()=>{i.getAction("editor.action.moveLinesDownAction").run()}},{identifier:"-"},{identifier:"Suchen... (Strg + f)",action:()=>{i.getAction("actions.find").run()}},{identifier:"Ersetzen... (Strg + h)",action:()=>{i.getAction("editor.action.startFindReplaceAction").run()}},{identifier:"-"},{identifier:"Aus-/Einkommentieren (Strg + #)",action:()=>{i.getAction("editor.action.commentLine").run()}},{identifier:"Dokument formatieren (Alt + Shift + f)",action:()=>{i.getAction("editor.action.formatDocument").run()}},{identifier:"-"},{identifier:"Finde zugehörige Klammer (Strg + k)",action:()=>{i.getAction("editor.action.jumpToBracket").run()}},{identifier:"-"},{identifier:"Alles zusammenfalten",action:()=>{i.getAction("editor.foldAll").run()}},{identifier:"Alles auffalten",action:()=>{i.getAction("editor.unfoldAll").run()}},{identifier:"-"},{identifier:"Vorschlag auslösen (Strg + Leertaste)",action:()=>{i.focus(),setTimeout(()=>{i.getAction("editor.action.triggerSuggest").run()},200)}},{identifier:"Parameterhilfe (Strg + Shift + Leertaste)",action:()=>{i.getAction("editor.action.triggerParameterHints").run()}},{identifier:"Gehe zur Definition (Strg + Click)",action:()=>{i.focus(),setTimeout(()=>{i.getAction("editor.action.revealDefinition").run()},200)}}]}},{identifier:"Ansicht",subMenu:{items:[{identifier:"Theme",subMenu:{items:[{identifier:"Dark",action:()=>{t.switchTheme("dark")}},{identifier:"Light",action:()=>{t.switchTheme("light")}}]}},{identifier:"-"},{identifier:"Hoher Kontrast im Editor ein/aus",action:()=>{i.getAction("editor.action.toggleHighContrast").run()}},{identifier:"-"},{identifier:"Zoom out (Strg + Mausrad)",action:()=>{this.main.editor.changeEditorFontSize(-4)}},{identifier:"Zoom normal",action:()=>{this.main.editor.setFontSize(14)}},{identifier:"Zoom in (Strg + Mausrad)",action:()=>{this.main.editor.changeEditorFontSize(4)}}]}},{identifier:"Datenbank",subMenu:{items:[{identifier:"Neue Datenbank anlegen...",action:()=>{let r=t.main.user.id;t.main.workspacesOwnerId!=null&&(r=t.main.workspacesOwnerId),new We(t.main,r,[])}},{identifier:"Einstellungen...",action:()=>{new vt(this.main,this.main.currentWorkspace)}},{identifier:"Export als Binärdump (.sqLite-File)...",action:()=>{new Se().saveToFile(this.main.getDatabaseTool())}},{identifier:"Aktuellen Zustand als Vorlage hochladen...",action:()=>{let r=this.main.currentWorkspace;if(r==null){alert("Es ist kein Workspace ausgewählt.");return}if(r.database.owner_id!=this.main.user.id){alert("Die Datenbank gehört einer anderen Benutzerin/einem anderen Benutzer. Sie kann daher nicht als Vorlage hochgeladen werden.");return}if(r.database.published_to==0){alert(`Die Datenbank ist noch nicht für andere Benutzer/innen veröffentlicht, daher kann sie nicht als Vorlage hochgeladen werden.
186
+ Die Möglichkeit zum Veröffentlichen finden Sie unter Datenbank->Einstellungen.`);return}new Pe().uploadCurrentDatabase(r.id,this.main,null,"publishDatabaseAsTemplate",()=>{alert("Der aktuelle Zustand der Datebank wurde erfolgreich als Vorlage hochgeladen.")})}}]}},{identifier:"Hilfe",subMenu:{items:[{identifier:"Über die Online-IDE...",link:"https://www.learnj.de/doku.php?id=javaonline:ueber"},{identifier:"Impressum...",link:"https://www.learnj.de/doku.php?id=ide:impressum"},{identifier:"Datenschutzerklärung...",link:"https://www.learnj.de/doku.php?id=ide:datenschutzerklaerung"},{identifier:"<div class='jo_menu_version'>Version 2.0 (13.2.2026, 09:46 Uhr)</div>",noHoverAnimation:!0}]}}]};e!=null&&e.is_admin&&n.items[0].subMenu.items.push({identifier:"Shutdown server...",action:()=>{confirm("Server wirklich herunterfahren?")&&D("shutdown",{},()=>{alert("Server erfolgreich heruntergefahren.")},r=>{alert(r)})}}),c("#mainmenu").empty(),this.initMenu(n,0)}switchTheme(e){this.main.viewModeController.setTheme(e)}initMenu(e,t){e.level=t,t==0?e.$element=c("#mainmenu"):(e.$element=c('<div class="jo_submenu"></div>'),c("body").append(e.$element)),e.$element.data("model",e);for(let n of e.items){if(n.identifier=="-")n.$element=c('<div class="jo_menuitemdivider"></div>');else{let r=n.noHoverAnimation?' class="jo_menuitem_nohover"':"";if(n.$element=c(`<div${r}>${n.identifier}</div>`),n.link!=null){let o=c('<a href="'+n.link+'" target="_blank" class="jo_menulink"></a>');o.on("pointerdown",l=>{l.stopPropagation()}),o.on("pointerup",l=>{l.stopPropagation(),setTimeout(()=>{e.$element.hide()},500)}),o.append(n.$element),n.$element=o}n.subMenu!=null&&this.initMenu(n.subMenu,t+1),this.initMenuitemCallbacks(e,n),t==0&&n.$element.addClass("jo_mainmenuitem")}e.$element.append(n.$element),n.$element.data("model",n)}let i=this;c(document).on("pointerdown",()=>{for(let n=0;n<5;n++)i.currentSubmenu[n]!=null&&(i.currentSubmenu[n].hide(),i.currentSubmenu[n]=null);i.openSubmenusOnMousemove=!1})}initMenuitemCallbacks(e,t){let i=this;t.action!=null&&(t.$element.on("pointerdown",n=>{n.stopPropagation()}),t.$element.on("pointerup",n=>{n.stopPropagation(),t.action(t.identifier);for(let r=0;r<5;r++)i.currentSubmenu[r]!=null&&(i.currentSubmenu[r].hide(),i.currentSubmenu[r]=null);i.openSubmenusOnMousemove=!1})),t.subMenu!=null?(t.$element.on("mousedown",n=>{i.opensubmenu(t),i.openSubmenusOnMousemove=!0,n.stopPropagation()}),t.$element.on("mousemove.mainmenu",()=>{i.openSubmenusOnMousemove?i.opensubmenu(t):i.currentSubmenu[e.level+1]!=null&&(i.currentSubmenu[e.level+1].hide(),i.currentSubmenu[e.level+1]=null)})):t.$element.on("mousemove.mainmenu",()=>{i.currentSubmenu[e.level+1]!=null&&(i.currentSubmenu[e.level+1].hide(),i.currentSubmenu[e.level+1]=null)})}opensubmenu(e){let t=e.subMenu,i,n;t.level==1?(i=e.$element.position().left,n=30):(i=e.$element.offset().left+e.$element.width(),n=e.$element.offset().top),t.$element.css({top:""+n+"px",left:""+i+"px"}),this.currentSubmenu[t.level]!=null&&this.currentSubmenu[t.level].hide(),t.$element.show(),this.currentSubmenu[t.level]=t.$element}}class Dt{constructor(e,t){h(this,"$buttonStart");h(this,"$buttonRollback");this.main=e,this.$buttonsContainer=t,this.$buttonStart=c('<div title="Start" class="img_start-dark jo_button"></div>'),this.$buttonRollback=c('<div title="Rollback" class="img_undo jo_button"></div>');let i=this.main.getActionManager();i.registerAction("execute",["Strg + Enter"],()=>{i.isActive("execute")&&this.main.getResultsetPresenter().executeSelectedStatements()},"SQL-Statement ausführen",this.$buttonStart),i.setActive("execute",!1),i.registerAction("rollback",["Strg + LeftArrow"],()=>{i.isActive("rollback")&&this.main.getHistoryViewer().rollback()},"Letztes schreibendes SQL-Statement rückgängig machen",this.$buttonRollback),i.setActive("rollback",!1),t.append(this.$buttonStart,this.$buttonRollback)}}const L=class L{constructor(e,t,i,n,r,o,l,d,u,m,f){h(this,"elements",[]);h(this,"$captionElement");h(this,"$buttonNew");h(this,"$listElement");h(this,"fixed");h(this,"dontSortElements",!1);h(this,"newFilesElementCallback");h(this,"newDatabaseElementCallback");h(this,"newFolderCallback");h(this,"renameCallback");h(this,"deleteCallback");h(this,"selectCallback");h(this,"addElementActionCallback");h(this,"contextMenuProvider");h(this,"moveCallback");h(this,"dropElementCallback");h(this,"$newFolderAction");this.accordion=e,this.caption=t,this.flexWeight=i,this.newButtonClass=n,this.buttonNewTitle=r,this.defaultIconClass=o,this.withDeleteButton=l,this.withFolders=d,this.kind=u,this.enableDrag=m,this.acceptDropKinds=f,e.addPanel(this);let p=window.PointerEvent?"pointer":"mouse";if(d){let b=this;this.$newFolderAction=c('<div class="img_add-folder-dark jo_button jo_active" style="margin-right: 4px" title="Neuen Ordner auf oberster Ebene anlegen">'),this.$newFolderAction.on(p+"down",g=>{g.stopPropagation(),g.preventDefault();let w=[];this.addFolder("Neuer Ordner",w,y=>{this.newFolderCallback(y,()=>{this.sortElements(),y.$htmlFirstLine[0].scrollIntoView(),it(y.$htmlFirstLine.find(".jo_filename"),"background-color",[0,255,0],2e3)})})}),this.addAction(this.$newFolderAction);let k=c('<div class="img_collapse-all-dark jo_button jo_active" style="margin-right: 4px" title="Alle Ordner zusammenfalten">');k.on(p+"down",g=>{g.stopPropagation(),g.preventDefault(),b.collapseAll()}),this.addAction(k)}}collapseAll(){for(let e of this.elements)e.isFolder&&e.$htmlFirstLine.hasClass("jo_expanded")&&(e.$htmlFirstLine.removeClass("jo_expanded"),e.$htmlFirstLine.addClass("jo_collapsed")),e.path.length>0&&e.$htmlFirstLine.slideUp(200)}remove(){this.$captionElement.remove(),this.$listElement.remove()}setFixed(e){this.fixed=e,this.fixed?(this.grow(),this.$captionElement.addClass("jo_fixed")):this.$captionElement.removeClass("jo_fixed")}enableNewButton(e){this.$buttonNew!=null&&(e?this.$buttonNew.show():this.$buttonNew.hide())}getCurrentlySelectedPath(){let e=[],t=this.getSelectedElement();return t!=null&&(e=t.path.slice(0),t.isFolder&&e.push(t.name)),e}compareWithPath(e,t,i,n,r,o){t=t.slice(),t.push(e),e="",r=r.slice(),r.push(n),n="";let l=0;for(;l<t.length&&l<r.length;){let d=t[l].localeCompare(r[l]);if(d!=0)return d;l++}return t.length<r.length?-1:t.length>r.length?1:e.localeCompare(n)}getElementIndex(e,t,i){for(let n=0;n<this.elements.length;n++){let r=this.elements[n];if(this.compareWithPath(e,t,i,r.name,r.path,r.isFolder)<0)return n}return this.elements.length}insertElement(e){let t=this.getElementIndex(e.name,e.path,e.isFolder);this.elements.splice(t,0,e);let i=this.$listElement.find(".jo_file");if(t==0)this.$listElement.prepend(e.$htmlFirstLine);else if(t==i.length)this.$listElement.append(e.$htmlFirstLine);else{let n=i.get(t);c(n).before(e.$htmlFirstLine)}}addFolder(e,t,i){let n={name:e,isFolder:!0,path:t},r=this.renderElement(n,!0);this.insertElement(n),r[0].scrollIntoView(),this.renameElement(n,()=>{i(n)})}renderOuterHtmlElements(e){let t=this;if(this.$captionElement=c(`<div class="jo_leftpanelcaption jo_expanded">
187
+ <div class="jo_captiontext">`+this.caption+'</div><div class="jo_actions"></div></div>'),this.newButtonClass!=null){this.$buttonNew=c('<div class="jo_button jo_active '+this.newButtonClass+'" title="'+this.buttonNewTitle+'">'),this.$captionElement.find(".jo_actions").append(this.$buttonNew);let l=window.PointerEvent?"pointer":"mouse";this.$buttonNew.on(l+"down",d=>{K.close(),d.stopPropagation();let u=t.getCurrentlySelectedPath(),m={name:"Neu",isFolder:!1,path:u},f=this.getElementIndex("",u,!1);this.elements.splice(f,0,m);let p=this.renderElement(m,!0);if(f==0)this.$listElement.prepend(p);else{let b=this.$listElement.find(".jo_file").get(f-1);c(b).after(p)}p[0].scrollIntoView(),t.renameElement(m,()=>{t.newFilesElementCallback(m,b=>{m.externalElement=b,m.$htmlSecondLine!=null&&m.$htmlSecondLine.insertAfter(p),t.selectCallback!=null&&t.select(m.externalElement)})})})}let i=c('<div id="filelistouter" class="jo_projectexplorerdiv jo_scrollable" data-grow="'+this.flexWeight+'" style="flex-grow: '+this.flexWeight+'"></div>');this.$listElement=c('<div class="jo_filelist"></div>'),i.append(this.$listElement),e.append(this.$captionElement),e.append(i);let n=this.$captionElement,r=this.$listElement.parent(),o=window.PointerEvent?"pointer":"mouse";n.on(o+"down",l=>{if(l.button==0&&!this.fixed){let d=r.data("grow");n.hasClass("jo_expanded")?t.accordion.parts.length>1&&r.animate({"flex-grow":.001},1e3,()=>{n.toggleClass("jo_expanded")}):(n.toggleClass("jo_expanded"),r.animate({"flex-grow":d},1e3))}}),n.on("dragover",l=>{L.currentlyDraggedElementKind==t.kind&&(n.addClass("jo_file_dragover"),l.preventDefault())}),n.on("dragleave",l=>{n.removeClass("jo_file_dragover")}),n.on("drop",l=>{if(L.currentlyDraggedElementKind==t.kind){l.preventDefault(),n.removeClass("jo_file_dragover");let d=L.currentlyDraggedElement;d!=null&&t.moveElement(d,null)}})}grow(){let e=this.$listElement.parent(),t=e.data("grow");e.css("flex-grow",t),this.$captionElement.addClass("jo_expanded")}addElement(e,t){e.$htmlFirstLine=this.renderElement(e,t),this.insertElement(e)}sortElements(){this.dontSortElements||(this.elements.sort((e,t)=>{let i=e.sortName?e.sortName:e.name,n=t.sortName?t.sortName:t.name;return this.compareWithPath(i,e.path,e.isFolder,n,t.path,t.isFolder)}),this.elements.forEach(e=>{this.$listElement.append(e.$htmlFirstLine)}))}setTextAfterFilename(e,t,i){if(e==null)return;let n=e.$htmlFirstLine.find(".jo_textAfterName");n.addClass(i),n.html(t)}addAction(e){this.$captionElement.find(".jo_actions").prepend(e)}renderElement(e,t){let i=window.PointerEvent?"pointer":"mouse",n=this,r="";e.iconClass==null&&(e.iconClass=this.defaultIconClass),e.isFolder&&(e.iconClass="folder",r=t?" jo_expanded":" jo_collapsed");let o="";e.path==null&&(e.path=[]);for(let u=0;u<e.path.length;u++)o+='<div class="jo_folderline"></div>';if(e.$htmlFirstLine=c(`<div class="jo_file jo_${e.iconClass} ${r}">
188
188
  <div class="jo_folderlines">${o}</div>
189
189
  <div class="jo_fileimage"></div>
190
190
  <div class="jo_filename">${Oe(e.name)}</div>
191
191
  <div class="jo_textAfterName"></div>
192
192
  <div class="jo_additionalButtonSettings"></div>
193
193
  ${this.withDeleteButton?'<div class="jo_delete img_delete jo_button jo_active"></div>':""}
194
- ${ve?"":'<div class="jo_settings_button img_ellipsis-dark jo_button jo_active"></div>'}
195
- </div>`),!t&&e.path.length>0&&e.$htmlFirstLine.hide(),this.addElementActionCallback!=null){let u=this.addElementActionCallback(e);e.$htmlFirstLine.append(u)}if(this.withFolders&&e.isFolder&&(e.$htmlFirstLine.on("dragover",u=>{T.currentlyDraggedElementKind==n.kind&&(e.$htmlFirstLine.addClass("jo_file_dragover"),u.preventDefault())}),e.$htmlFirstLine.on("dragleave",u=>{e.$htmlFirstLine.removeClass("jo_file_dragover")}),e.$htmlFirstLine.on("drop",u=>{if(T.currentlyDraggedElementKind==n.kind){u.preventDefault(),e.$htmlFirstLine.removeClass("jo_file_dragover");let m=T.currentlyDraggedElement;T.currentlyDraggedElement=null,m!=null&&n.moveElement(m,e)}})),this.withFolders||this.enableDrag){let u=e.$htmlFirstLine.find(".jo_filename");u.attr("draggable","true"),u.on("dragstart",m=>{T.currentlyDraggedElement=e,T.currentlyDraggedElementKind=n.kind,m.originalEvent.dataTransfer.effectAllowed=e.isFolder?"move":"copyMove"})}this.acceptDropKinds!=null&&this.acceptDropKinds.length>0&&(e.isFolder||(e.$htmlFirstLine.on("dragover",u=>{this.acceptDropKinds.indexOf(T.currentlyDraggedElementKind)>=0&&(e.$htmlFirstLine.addClass("jo_file_dragover"),u.ctrlKey?u.originalEvent.dataTransfer.dropEffect="copy":u.originalEvent.dataTransfer.dropEffect="move",u.preventDefault())}),e.$htmlFirstLine.on("dragleave",u=>{e.$htmlFirstLine.removeClass("jo_file_dragover")}),e.$htmlFirstLine.on("drop",u=>{if(this.acceptDropKinds.indexOf(T.currentlyDraggedElementKind)>=0){u.preventDefault(),e.$htmlFirstLine.removeClass("jo_file_dragover");let m=T.currentlyDraggedElement;T.currentlyDraggedElement=null,m!=null&&n.dropElementCallback!=null&&n.dropElementCallback(e,m,u.ctrlKey?"copy":"move")}}))),e.$htmlFirstLine.on(i+"up",u=>{if(u.button==0&&n.selectCallback!=null){n.selectCallback(e.externalElement);for(let m of n.elements)m!=e&&m.$htmlFirstLine.hasClass("jo_active")&&m.$htmlFirstLine.removeClass("jo_active");if(e.$htmlFirstLine.addClass("jo_active"),e.isFolder){e.$htmlFirstLine.hasClass("jo_expanded")?(e.$htmlFirstLine.removeClass("jo_expanded"),e.$htmlFirstLine.addClass("jo_collapsed")):(e.$htmlFirstLine.addClass("jo_expanded"),e.$htmlFirstLine.removeClass("jo_collapsed"));let m={};for(let f of this.elements)if(f.isFolder){let p=f.path.join("/");p!=""&&(p+="/"),p+=f.name,m[p]=f.$htmlFirstLine.hasClass("jo_collapsed"),m[f.path.join("/")]&&(m[p]=!0)}m[""]=!1;for(let f of this.elements)m[f.path.join("/")]?f.$htmlFirstLine.slideUp(200):f.$htmlFirstLine.slideDown(200)}}});let l=function(u){let m=[];if(n.renameCallback!=null&&m.push({caption:"Umbenennen",callback:()=>{n.renameElement(e)}}),e.isFolder&&(m=m.concat([{caption:"Neuen Unterordner anlegen (unterhalb '"+e.name+"')...",callback:()=>{n.select(e.externalElement);let f=n.getCurrentlySelectedPath();n.addFolder("Neuer Ordner",f,p=>{n.newFolderCallback(p,()=>{n.sortElements(),p.$htmlFirstLine[0].scrollIntoView(),et(p.$htmlFirstLine.find(".jo_filename"),"background-color",[0,255,0],2e3)})})}},{caption:"Neue Datenbank...",callback:()=>{n.select(e.externalElement),n.newDatabaseElementCallback(e.path.concat(e.name))}}])),n.contextMenuProvider!=null&&!e.isFolder)for(let f of n.contextMenuProvider(e))m.push({caption:f.caption,callback:()=>{f.callback(e)},color:f.color,subMenu:f.subMenu==null?null:f.subMenu.map(p=>({caption:p.caption,callback:()=>{p.callback(e)},color:p.color}))});m.length>0&&(u.preventDefault(),u.stopPropagation(),R(m,u.pageX,u.pageY))};e.$htmlFirstLine[0].addEventListener("contextmenu",l,!1);let d;return ve||e.$htmlFirstLine.on("pointerup",()=>(clearTimeout(d),!1)).on("pointerdown",u=>(d=window.setTimeout(()=>{l(u)},500),!1)),ve||(e.$htmlFirstLine.find(".jo_settings_button").on("pointerdown",u=>{l(u)}),e.$htmlFirstLine.find(".jo_settings_button").on("mousedown click",u=>{u.preventDefault(),u.stopPropagation()})),n.withDeleteButton&&(e.$htmlFirstLine.find(".jo_delete")[0].addEventListener("contextmenu",u=>{u.preventDefault(),u.stopPropagation()},!1),e.$htmlFirstLine.find(".jo_delete").on(i+"up",u=>{u.preventDefault(),R([{caption:"Abbrechen",callback:()=>{}},{caption:"Ich bin mir sicher: löschen!",color:"#ff6060",callback:()=>{if(e.isFolder&&n.getChildElements(e).length>0){alert("Dieser Ordner kann nicht gelöscht werden, da er nicht leer ist.");return}n.deleteCallback(e.externalElement,()=>{e.$htmlFirstLine.remove(),e.$htmlSecondLine!=null&&e.$htmlSecondLine.remove(),n.elements.splice(n.elements.indexOf(e),1),n.selectCallback!=null&&(n.elements.length>0?n.select(n.elements[0].externalElement):n.select(null))})}}],u.pageX+2,u.pageY+2),u.stopPropagation()})),e.$htmlFirstLine}moveElement(e,t){let i=t==null?[]:t.path.slice(0).concat([t.name]);if(e.isFolder){let n=[e],r=e.path.concat([e.name]).join("/");if(i.join("/").indexOf(r)==0)return;let o=e.path.length;e.path=i.slice(0);for(let l of this.elements)l.path.join("/").startsWith(r)&&(l.path.splice(0,o),l.path=i.concat(l.path),n.push(l));for(let l of n)l.$htmlFirstLine.remove(),this.elements.splice(this.elements.indexOf(l),1);for(let l of n)this.renderElement(l,!0),this.insertElement(l);this.moveCallback(n)}else e.path=i,e.$htmlFirstLine.remove(),this.elements.splice(this.elements.indexOf(e),1),this.renderElement(e,!0),this.insertElement(e),this.select(e.externalElement),e.$htmlFirstLine[0].scrollIntoView(),this.moveCallback(e)}getChildElements(e){let t=e.path.slice(0).concat(e.name).join("/");return this.elements.filter(i=>i.path.join("/").startsWith(t))}pathStartsWith(e,t){if(e.length<t.length)return!1;for(let i=0;i<t.length;i++)if(e[i]!=t[i])return!1;return!0}renameElement(e,t){let i=this,n=e.$htmlFirstLine.find(".jo_filename"),r=e.name.indexOf("."),o=r==null?null:{start:0,end:r};this.dontSortElements=!0,pt(n,n,l=>{e.externalElement!=null&&(l=i.renameCallback(e.externalElement,l));let d=e.name;if(e.name=l,n.html(e.name),e.isFolder){let u=e.path.slice().concat([d]),m=[];for(let f of this.elements)this.pathStartsWith(f.path,u)&&(f.path[u.length-1]=e.name,m.push(f));m.length>0&&this.moveCallback(m)}t!=null&&t(),i.sortElements(),n[0].scrollIntoView(),this.dontSortElements=!1},o)}select(e,t=!0,i=!1){if(e==null)for(let n of this.elements)n.$htmlFirstLine.hasClass("jo_active")&&n.$htmlFirstLine.removeClass("jo_active");else{let n=this.findElement(e);if(n!=null){for(let r of this.elements)r.$htmlFirstLine.hasClass("jo_active")&&r.$htmlFirstLine.removeClass("jo_active");if(n.$htmlFirstLine.addClass("jo_active"),i){let r=n.path.join("/");for(let o of this.elements){let l=o.path.slice(0);r.startsWith(l.join("/"))&&(o.isFolder&&(l.push(o.name),r.startsWith(l.join("/"))&&(o.$htmlFirstLine.removeClass("jo_collapsed"),o.$htmlFirstLine.addClass("jo_expanded"))),o.$htmlFirstLine.show())}n.$htmlFirstLine[0].scrollIntoView()}}}t&&this.selectCallback!=null&&this.selectCallback(e)}getPathString(e){let t=e.path.join("/");return e.isFolder&&(t!=""&&(t+="/"),t+=e.name),t}setElementClass(e,t){var i;e!=null&&((i=e.$htmlFirstLine)==null||i.removeClass("jo_"+e.iconClass).addClass("jo_"+t),e.iconClass=t)}findElement(e){for(let t of this.elements)if(t.externalElement==e)return t;return null}removeElement(e){for(let t of this.elements)if(t.externalElement==e){t.$htmlFirstLine.remove(),t.$htmlSecondLine!=null&&t.$htmlSecondLine.remove(),this.elements.splice(this.elements.indexOf(t),1),this.selectCallback!=null&&(this.elements.length>0?this.select(this.elements[0].externalElement):this.select(null));return}}clear(){this.$listElement.empty(),this.elements=[]}setCaption(e){this.$captionElement.find(".jo_captiontext").html(e)}getSelectedElement(){for(let e of this.elements)if(e.$htmlFirstLine.hasClass("jo_active"))return e;return null}};h(T,"currentlyDraggedElement"),h(T,"currentlyDraggedElementKind");let ie=T;class Mi{constructor(e,t){h(this,"parts",[]);h(this,"$html");this.main=e,this.$html=t,t.addClass("jo_leftpanelinner")}addPanel(e){e.renderOuterHtmlElements(this.$html),this.parts.push(e)}}class ji{constructor(e,t,i){h(this,"$dialog");h(this,"$dialogMain");h(this,"studentCount",0);this.classes=e,this.workspace=t,this.main=i,this.init()}init(){this.$dialog=c("#dialog"),c("#main").css("visibility","hidden"),this.$dialog.append(c(`<div class="jo_ds_heading">Austeilen eines Workspace an einzelne Schüler/innen</div>
194
+ ${ye?"":'<div class="jo_settings_button img_ellipsis-dark jo_button jo_active"></div>'}
195
+ </div>`),!t&&e.path.length>0&&e.$htmlFirstLine.hide(),this.addElementActionCallback!=null){let u=this.addElementActionCallback(e);e.$htmlFirstLine.append(u)}if(this.withFolders&&e.isFolder&&(e.$htmlFirstLine.on("dragover",u=>{L.currentlyDraggedElementKind==n.kind&&(e.$htmlFirstLine.addClass("jo_file_dragover"),u.preventDefault())}),e.$htmlFirstLine.on("dragleave",u=>{e.$htmlFirstLine.removeClass("jo_file_dragover")}),e.$htmlFirstLine.on("drop",u=>{if(L.currentlyDraggedElementKind==n.kind){u.preventDefault(),e.$htmlFirstLine.removeClass("jo_file_dragover");let m=L.currentlyDraggedElement;L.currentlyDraggedElement=null,m!=null&&n.moveElement(m,e)}})),this.withFolders||this.enableDrag){let u=e.$htmlFirstLine.find(".jo_filename");u.attr("draggable","true"),u.on("dragstart",m=>{L.currentlyDraggedElement=e,L.currentlyDraggedElementKind=n.kind,m.originalEvent.dataTransfer.effectAllowed=e.isFolder?"move":"copyMove"})}this.acceptDropKinds!=null&&this.acceptDropKinds.length>0&&(e.isFolder||(e.$htmlFirstLine.on("dragover",u=>{this.acceptDropKinds.indexOf(L.currentlyDraggedElementKind)>=0&&(e.$htmlFirstLine.addClass("jo_file_dragover"),u.ctrlKey?u.originalEvent.dataTransfer.dropEffect="copy":u.originalEvent.dataTransfer.dropEffect="move",u.preventDefault())}),e.$htmlFirstLine.on("dragleave",u=>{e.$htmlFirstLine.removeClass("jo_file_dragover")}),e.$htmlFirstLine.on("drop",u=>{if(this.acceptDropKinds.indexOf(L.currentlyDraggedElementKind)>=0){u.preventDefault(),e.$htmlFirstLine.removeClass("jo_file_dragover");let m=L.currentlyDraggedElement;L.currentlyDraggedElement=null,m!=null&&n.dropElementCallback!=null&&n.dropElementCallback(e,m,u.ctrlKey?"copy":"move")}}))),e.$htmlFirstLine.on(i+"up",u=>{if(u.button==0&&n.selectCallback!=null){n.selectCallback(e.externalElement);for(let m of n.elements)m!=e&&m.$htmlFirstLine.hasClass("jo_active")&&m.$htmlFirstLine.removeClass("jo_active");if(e.$htmlFirstLine.addClass("jo_active"),e.isFolder){e.$htmlFirstLine.hasClass("jo_expanded")?(e.$htmlFirstLine.removeClass("jo_expanded"),e.$htmlFirstLine.addClass("jo_collapsed")):(e.$htmlFirstLine.addClass("jo_expanded"),e.$htmlFirstLine.removeClass("jo_collapsed"));let m={};for(let f of this.elements)if(f.isFolder){let p=f.path.join("/");p!=""&&(p+="/"),p+=f.name,m[p]=f.$htmlFirstLine.hasClass("jo_collapsed"),m[f.path.join("/")]&&(m[p]=!0)}m[""]=!1;for(let f of this.elements)m[f.path.join("/")]?f.$htmlFirstLine.slideUp(200):f.$htmlFirstLine.slideDown(200)}}});let l=function(u){let m=[];if(n.renameCallback!=null&&m.push({caption:"Umbenennen",callback:()=>{n.renameElement(e)}}),e.isFolder&&(m=m.concat([{caption:"Neuen Unterordner anlegen (unterhalb '"+e.name+"')...",callback:()=>{n.select(e.externalElement);let f=n.getCurrentlySelectedPath();n.addFolder("Neuer Ordner",f,p=>{n.newFolderCallback(p,()=>{n.sortElements(),p.$htmlFirstLine[0].scrollIntoView(),it(p.$htmlFirstLine.find(".jo_filename"),"background-color",[0,255,0],2e3)})})}},{caption:"Neue Datenbank...",callback:()=>{n.select(e.externalElement),n.newDatabaseElementCallback(e.path.concat(e.name))}}])),n.contextMenuProvider!=null&&!e.isFolder)for(let f of n.contextMenuProvider(e))m.push({caption:f.caption,callback:()=>{f.callback(e)},color:f.color,subMenu:f.subMenu==null?null:f.subMenu.map(p=>({caption:p.caption,callback:()=>{p.callback(e)},color:p.color}))});m.length>0&&(u.preventDefault(),u.stopPropagation(),R(m,u.pageX,u.pageY))};e.$htmlFirstLine[0].addEventListener("contextmenu",l,!1);let d;return ye||e.$htmlFirstLine.on("pointerup",()=>(clearTimeout(d),!1)).on("pointerdown",u=>(d=window.setTimeout(()=>{l(u)},500),!1)),ye||(e.$htmlFirstLine.find(".jo_settings_button").on("pointerdown",u=>{l(u)}),e.$htmlFirstLine.find(".jo_settings_button").on("mousedown click",u=>{u.preventDefault(),u.stopPropagation()})),n.withDeleteButton&&(e.$htmlFirstLine.find(".jo_delete")[0].addEventListener("contextmenu",u=>{u.preventDefault(),u.stopPropagation()},!1),e.$htmlFirstLine.find(".jo_delete").on(i+"up",u=>{u.preventDefault(),R([{caption:"Abbrechen",callback:()=>{}},{caption:"Ich bin mir sicher: löschen!",color:"#ff6060",callback:()=>{if(e.isFolder&&n.getChildElements(e).length>0){alert("Dieser Ordner kann nicht gelöscht werden, da er nicht leer ist.");return}n.deleteCallback(e.externalElement,()=>{e.$htmlFirstLine.remove(),e.$htmlSecondLine!=null&&e.$htmlSecondLine.remove(),n.elements.splice(n.elements.indexOf(e),1),n.selectCallback!=null&&(n.elements.length>0?n.select(n.elements[0].externalElement):n.select(null))})}}],u.pageX+2,u.pageY+2),u.stopPropagation()})),e.$htmlFirstLine}moveElement(e,t){let i=t==null?[]:t.path.slice(0).concat([t.name]);if(e.isFolder){let n=[e],r=e.path.concat([e.name]).join("/");if(i.join("/").indexOf(r)==0)return;let o=e.path.length;e.path=i.slice(0);for(let l of this.elements)l.path.join("/").startsWith(r)&&(l.path.splice(0,o),l.path=i.concat(l.path),n.push(l));for(let l of n)l.$htmlFirstLine.remove(),this.elements.splice(this.elements.indexOf(l),1);for(let l of n)this.renderElement(l,!0),this.insertElement(l);this.moveCallback(n)}else e.path=i,e.$htmlFirstLine.remove(),this.elements.splice(this.elements.indexOf(e),1),this.renderElement(e,!0),this.insertElement(e),this.select(e.externalElement),e.$htmlFirstLine[0].scrollIntoView(),this.moveCallback(e)}getChildElements(e){let t=e.path.slice(0).concat(e.name).join("/");return this.elements.filter(i=>(i.path.join("/")+"/").startsWith(t+"/"))}pathStartsWith(e,t){if(e.length<t.length)return!1;for(let i=0;i<t.length;i++)if(e[i]!=t[i])return!1;return!0}renameElement(e,t){let i=this,n=e.$htmlFirstLine.find(".jo_filename"),r=e.name.indexOf("."),o=r==null?null:{start:0,end:r};this.dontSortElements=!0,bt(n,n,l=>{e.externalElement!=null&&(l=i.renameCallback(e.externalElement,l));let d=e.name;if(e.name=l,n.html(e.name),e.isFolder){let u=e.path.slice().concat([d]),m=[];for(let f of this.elements)this.pathStartsWith(f.path,u)&&(f.path[u.length-1]=e.name,m.push(f));m.length>0&&this.moveCallback(m)}t!=null&&t(),i.sortElements(),n[0].scrollIntoView(),this.dontSortElements=!1},o)}select(e,t=!0,i=!1){if(e==null)for(let n of this.elements)n.$htmlFirstLine.hasClass("jo_active")&&n.$htmlFirstLine.removeClass("jo_active");else{let n=this.findElement(e);if(n!=null){for(let r of this.elements)r.$htmlFirstLine.hasClass("jo_active")&&r.$htmlFirstLine.removeClass("jo_active");if(n.$htmlFirstLine.addClass("jo_active"),i){let r=n.path.join("/");for(let o of this.elements){let l=o.path.slice(0);r.startsWith(l.join("/"))&&(o.isFolder&&(l.push(o.name),r.startsWith(l.join("/"))&&(o.$htmlFirstLine.removeClass("jo_collapsed"),o.$htmlFirstLine.addClass("jo_expanded"))),o.$htmlFirstLine.show())}n.$htmlFirstLine[0].scrollIntoView()}}}t&&this.selectCallback!=null&&this.selectCallback(e)}getPathString(e){let t=e.path.join("/");return e.isFolder&&(t!=""&&(t+="/"),t+=e.name),t}setElementClass(e,t){var i;e!=null&&((i=e.$htmlFirstLine)==null||i.removeClass("jo_"+e.iconClass).addClass("jo_"+t),e.iconClass=t)}findElement(e){for(let t of this.elements)if(t.externalElement==e)return t;return null}removeElement(e){for(let t of this.elements)if(t.externalElement==e){t.$htmlFirstLine.remove(),t.$htmlSecondLine!=null&&t.$htmlSecondLine.remove(),this.elements.splice(this.elements.indexOf(t),1),this.selectCallback!=null&&(this.elements.length>0?this.select(this.elements[0].externalElement):this.select(null));return}}clear(){this.$listElement.empty(),this.elements=[]}setCaption(e){this.$captionElement.find(".jo_captiontext").html(e)}getSelectedElement(){for(let e of this.elements)if(e.$htmlFirstLine.hasClass("jo_active"))return e;return null}};h(L,"currentlyDraggedElement"),h(L,"currentlyDraggedElementKind");let ne=L;class Mi{constructor(e,t){h(this,"parts",[]);h(this,"$html");this.main=e,this.$html=t,t.addClass("jo_leftpanelinner")}addPanel(e){e.renderOuterHtmlElements(this.$html),this.parts.push(e)}}class ji{constructor(e,t,i){h(this,"$dialog");h(this,"$dialogMain");h(this,"studentCount",0);this.classes=e,this.workspace=t,this.main=i,this.init()}init(){this.$dialog=c("#dialog"),c("#main").css("visibility","hidden"),this.$dialog.append(c(`<div class="jo_ds_heading">Austeilen eines Workspace an einzelne Schüler/innen</div>
196
196
  <div class="jo_ds_settings">
197
197
  <div class="jo_ds_settings_caption">Workspace:</div><div class="jo_ds_workspacename">${this.workspace.name}</div>
198
198
  <div class="jo_ds_settings_caption">Liste filtern:</div><div class="jo_ds_filterdiv"><input class="dialog-input"></input></div>
@@ -204,21 +204,21 @@ Die Möglichkeit zum Veröffentlichen finden Sie unter Datenbank->Einstellungen.
204
204
  <button id="jo_ds_cancel_button">Abbrechen</button>
205
205
  <button id="jo_ds_distribute_button">Austeilen</button>
206
206
  </div>
207
- `));let e=c(".jo_ds_student_list"),t=this;for(let i of this.classes)for(let n of i.students){let r=c('<div class="jo_ds_student_line">'),o=c(`<div class="jo_ds_student_class">${i.name}</div>`),l=c(`<div class="jo_ds_student_name">${n.rufname} ${n.familienname}</div>`);r.append(o,l),e.append(r),r.on("mousedown",()=>{r.toggleClass("jo_active"),t.studentCount+=r.hasClass("jo_active")?1:-1,c(".jo_ds_selected_message").text(`${t.studentCount} Schüler/inn/en selektiert`)}),r.data("student",n),r.data("klass",i)}c(".jo_ds_filterdiv>input").on("input",()=>{let i=c(".jo_ds_filterdiv>input").val();i==null||i==""?c(".jo_ds_student_line").show():c(".jo_ds_student_line").each((n,r)=>{let o=i.toLocaleLowerCase(),l=c(r),d=l.data("klass"),u=l.data("student");(d.name+" "+u.rufname+" "+u.familienname).toLocaleLowerCase().indexOf(o)>=0?l.show():l.hide()})}),this.$dialogMain=this.$dialog.find(".dialog-main"),this.$dialog.css("visibility","visible"),c("#jo_ds_cancel_button").on("click",()=>{t.close()}),c("#jo_ds_distribute_button").on("click",()=>{t.distributeDatabase()}),c(".jo_ds_filterdiv>input")[0].focus()}distributeDatabase(){let e=[];c(".jo_ds_student_line").each((t,i)=>{let n=c(i);if(n.hasClass("jo_active")){let r=n.data("student");e.push(r.id)}}),this.close(),this.main.networkManager.sendDistributeWorkspace(this.workspace,null,e,t=>{if(t==null){let i=this.main.networkManager,n=i.updateFrequencyInSeconds*i.forcedUpdateEvery;alert(`Der Workspace ${this.workspace.name} wurde an ${e.length} Schüler/innen ausgeteilt. Er wird in maximal ${n} s bei jedem Schüler ankommen.`)}else alert(t)})}close(){this.$dialog.css("visibility","hidden"),this.$dialog.empty(),c("#main").css("visibility","visible")}}class $i{constructor(e,t){h(this,"programPointerModule",null);h(this,"programPointerPosition");h(this,"programPointerDecoration",[]);h(this,"accordion");h(this,"fileListPanel");h(this,"workspaceListPanel");h(this,"$homeAction");h(this,"lastOpenModule",null);this.main=e,this.$projectexplorerDiv=t}initGUI(){this.accordion=new Mi(this.main,this.$projectexplorerDiv),this.initFilelistPanel(),this.initWorkspacelistPanel()}initFilelistPanel(){let e=this;this.fileListPanel=new ie(this.accordion,"Kein Workspace gewählt","1","img_add-file-dark","Neue Datei...","java",!0,!1,"file",!0,[]),this.fileListPanel.newFilesElementCallback=(t,i)=>{if(e.main.currentWorkspace==null)return alert("Bitte wählen Sie zuerst einen Workspace aus."),null;let n={name:t.name,dirty:!1,saved:!0,text:"",text_before_revision:null,submitted_date:null,student_edited_after_revision:!1,version:1,panelElement:t},r=new U(n,e.main);e.main.currentWorkspace.moduleStore.putModule(r),e.setModuleActive(r),e.main.networkManager.sendCreateFile(r,e.main.currentWorkspace,e.main.workspacesOwnerId,l=>{l==null?i(r):alert("Der Server ist nicht erreichbar!")})},this.fileListPanel.renameCallback=(t,i)=>{i=i.substr(0,80);let n=t.file;return n.name=i,n.saved=!1,e.main.networkManager.sendUpdates(),i},this.fileListPanel.deleteCallback=(t,i)=>{var n;t&&t.file&&((n=e==null?void 0:e.main)!=null&&n.networkManager)&&e.main.networkManager.sendDeleteWorkspaceOrFile("file",t.file.id,r=>{r==null?(e.main.currentWorkspace.moduleStore.removeModule(t),i()):alert("Der Server ist nicht erreichbar!")})},this.fileListPanel.contextMenuProvider=t=>{let i=[];return e.main.user.is_teacher||e.main.user.is_admin||e.main.user.is_schooladmin||t.externalElement.file,i},this.fileListPanel.selectCallback=t=>{e.setModuleActive(t)}}renderHomeworkButton(e){var r,o;let t=(o=(r=e==null?void 0:e.panelElement)==null?void 0:r.$htmlFirstLine)==null?void 0:o.find(".jo_additionalButtonHomework");if(t==null)return;t.find(".jo_homeworkButton").remove();let i=null,n="";if(e.submitted_date!=null&&(i="img_homework",n="Wurde als Hausaufgabe abgegeben: "+e.submitted_date,e.text_before_revision&&(i="img_homework-corrected",n="Korrektur liegt vor.")),i!=null){let l=c(`<div class="jo_homeworkButton ${i}" title="${n}"></div>`);t.prepend(l),i.indexOf("jo_active")>=0&&(l.on("mousedown",d=>d.stopPropagation()),l.on("click",d=>{d.stopPropagation()}))}}initWorkspacelistPanel(){let e=this;this.workspaceListPanel=new ie(this.accordion,"Datenbanken","3",null,"Neue Datenbank...","workspace",!0,!0,"workspace",!1,["file"]);let t=c('<div class="img_add-database-dark jo_button jo_active" style="margin-right: 4px" title="Neue Datenbank auf oberster Ordnerebene anlegen">'),i=window.PointerEvent?"pointer":"mouse";t.on(i+"down",n=>{n.stopPropagation();let r=e.main.user.id;e.main.workspacesOwnerId!=null&&(r=e.main.workspacesOwnerId),new We(e.main,r,this.workspaceListPanel.getCurrentlySelectedPath())}),this.workspaceListPanel.addAction(t),this.workspaceListPanel.$buttonNew!=null&&this.workspaceListPanel.$buttonNew.hide(),this.workspaceListPanel.newDatabaseElementCallback=n=>{let r=e.main.user.id;e.main.workspacesOwnerId!=null&&(r=e.main.workspacesOwnerId),new We(e.main,r,n)},this.workspaceListPanel.renameCallback=(n,r)=>(r=r.substring(0,80),n.name=r,n.saved=!1,e.main.networkManager.sendUpdates(),n.database.owner_id==n.owner_id&&(n.database.name=r,e.main.networkManager.setNameAndPublishedTo(n.id,r,n.database.published_to,n.database.description,()=>{})),r),this.workspaceListPanel.deleteCallback=(n,r)=>{e.main.networkManager.sendDeleteWorkspaceOrFile("workspace",n.id,o=>{o==null?(e.main.removeWorkspace(n),n.isFolder||(e.fileListPanel.clear(),e.main.databaseExplorer.clear(),e.main.getResultsetPresenter().clear(),e.fileListPanel.enableNewButton(!1),e.main.getMonacoEditor().setModel(null)),r()):alert("Fehler: "+o)})},this.workspaceListPanel.selectCallback=n=>{n!=null&&n.isFolder||n!=this.main.currentWorkspace&&e.main.networkManager.sendUpdates(()=>{e.setWorkspaceActive(n)})},this.workspaceListPanel.newFolderCallback=(n,r)=>{let o=e.main.user.id;e.main.workspacesOwnerId!=null&&(o=e.main.workspacesOwnerId);let l=new te(n.name,e.main,o);l.isFolder=!0,l.path=n.path.join("/"),l.panelElement=n,n.externalElement=l,e.main.workspaceList.push(l);let d={id:-1,isFolder:!0,name:l.name,path:l.path};e.main.networkManager.sendCreateWorkspace(d,e.main.workspacesOwnerId,u=>{u==null?(l.id=d.id,r(l)):(alert("Fehler: "+u),e.workspaceListPanel.removeElement(n))})},this.workspaceListPanel.moveCallback=n=>{Array.isArray(n)||(n=[n]);for(let r of n){let o=r.externalElement;o.path=r.path.join("/"),o.saved=!1}this.main.networkManager.sendUpdates()},this.workspaceListPanel.dropElementCallback=(n,r,o)=>{let l=n.externalElement,d=r.externalElement;if(l.moduleStore.getModules(!1).indexOf(d)>=0)return;let u={name:d.file.name,dirty:!0,saved:!1,text:d.file.text,text_before_revision:null,submitted_date:null,student_edited_after_revision:!1,version:d.file.version,panelElement:null};o=="move"&&(e.main.currentWorkspace.moduleStore.removeModule(d),e.fileListPanel.removeElement(d),e.main.networkManager.sendDeleteWorkspaceOrFile("file",d.file.id,()=>{}));let m=new U(u,e.main);l.moduleStore.putModule(m),e.main.networkManager.sendCreateFile(m,l,e.main.workspacesOwnerId,p=>{p==null||alert("Der Server ist nicht erreichbar!")})},this.$homeAction=c('<div class="img_home-dark jo_button jo_active" style="margin-right: 4px" title="Meine eigenen Workspaces anzeigen">'),this.$homeAction.on(i+"down",n=>{n.stopPropagation(),e.main.networkManager.sendUpdates(()=>{e.onHomeButtonClicked()}),e.main.bottomDiv.hideHomeworkTab()}),this.workspaceListPanel.addAction(this.$homeAction),this.$homeAction.hide(),this.workspaceListPanel.contextMenuProvider=n=>{let r=[];return this.main.user.is_teacher&&this.main.teacherExplorer.classPanel.elements.length>0&&r.push({caption:"An Klasse austeilen...",callback:o=>{},subMenu:this.main.teacherExplorer.classPanel.elements.map(o=>({caption:o.name,callback:l=>{let d=o.externalElement,u=l.externalElement;this.main.networkManager.sendDistributeWorkspace(u,d,null,m=>{if(m==null){let f=this.main.networkManager,p=f.updateFrequencyInSeconds*f.forcedUpdateEvery;alert("Der Workspace "+u.name+" wurde an die Klasse "+d.name+" ausgeteilt. Er wird in maximal "+p+" s bei jedem Schüler ankommen.")}else alert(m)})}}))},{caption:"An einzelne Schüler/innen austeilen...",callback:o=>{let l=this.main.teacherExplorer.classPanel.elements.map(u=>u.externalElement),d=o.externalElement;new ji(l,d,this.main)}}),r}}onHomeButtonClicked(){this.main.teacherExplorer.restoreOwnWorkspaces(),this.main.networkManager.updateFrequencyInSeconds=this.main.networkManager.ownUpdateFrequencyInSeconds,this.$homeAction.hide(),this.fileListPanel.enableNewButton(this.main.workspaceList.length>0)}renderFiles(e){let t=e==null?"Kein Workspace vorhanden":e.name;if(this.fileListPanel.setCaption(t),this.fileListPanel.clear(),this.main.getCurrentWorkspace()!=null)for(let i of this.main.getCurrentWorkspace().moduleStore.getModules(!1))i.file.panelElement=null;if(e!=null){let i=[];for(let n of e.moduleStore.getModules(!1))i.push(n);i.sort((n,r)=>n.file.name>r.file.name?1:n.file.name<r.file.name?-1:0);for(let n of i)n.file.panelElement={name:n.file.name,externalElement:n,isFolder:!1,path:[]},this.fileListPanel.addElement(n.file.panelElement,!0),this.renderHomeworkButton(n.file);this.fileListPanel.sortElements()}}renderWorkspaces(e){this.fileListPanel.clear(),this.workspaceListPanel.clear();for(let t of e){let i=t.path.split("/");i.length==1&&i[0]==""&&(i=[]),t.panelElement={name:t.name,externalElement:t,iconClass:"workspace",isFolder:t.isFolder,path:i},this.workspaceListPanel.addElement(t.panelElement,!1),t.renderSettingsButton(t.panelElement)}this.workspaceListPanel.sortElements(),this.fileListPanel.enableNewButton(e.length>0)}renderErrorCount(e,t){if(t!=null)for(let i of e.moduleStore.getModules(!1)){let n=t.get(i),r=n==null||n==0?"":"("+n+")";this.fileListPanel.setTextAfterFilename(i.file.panelElement,r,"jo_errorcount")}}setWorkspaceActive(e,t,i=!1){if(t==null&&(t=()=>{}),e==this.main.getCurrentWorkspace()){t!=null&&t();return}if(e!=null)if(e.isFolder){this.main.currentWorkspace=null,this.main.databaseTool.initializeWorker(null,[],null,()=>{this.main.databaseExplorer.refreshAfterRetrievingDBStructure()}),this.setModuleActive(null);return}else this.fileListPanel.$buttonNew.show();this.workspaceListPanel.select(e,!1,i);let n=r=>{r!=null?(alert(r),this.main.waitOverlay.hide(),t!=null&&t()):(this.main.waitOverlay.show("Bitte warten, initialisiere Datenbank ..."),this.initializeDatabaseTool(e,t))};e!=null&&(e.database==null?(this.main.waitOverlay.show("Bitte warten, hole Datenbank vom Server ..."),this.main.networkManager.fetchDatabase(e,n)):n(null))}initializeDatabaseTool(e,t){if(!e.database){t&&t();return}let i=this.main.getDatabaseTool(),n=e.database.statements;n==null&&(n=[]),i.initializeWorker(e.database.templateDump,n,()=>{var r;if(this.main.currentWorkspace=e,((r=this.main.user)==null?void 0:r.id)==e.owner_id&&(this.main.user.currentWorkspace_id=e.id),this.renderFiles(e),e!=null){let o=e.moduleStore.getModules(!1);e.currentlyOpenModule!=null?this.setModuleActive(e.currentlyOpenModule):o.length>0?this.setModuleActive(o[0]):this.setModuleActive(null);for(let l of o)l.file.dirty=!0;o.length==0&&K.showHelper("newSQLFileHelper",this.main,this.fileListPanel.$captionElement)}else this.setModuleActive(null);this.main.notifier.connect(e)},()=>{this.main.databaseExplorer.refreshAfterRetrievingDBStructure(),this.main.getHistoryViewer().clearAndShowStatements(e.database.statements),t!=null&&t()})}writeEditorTextToFile(){let e=this.getCurrentlyEditedModule();e!=null&&(e.file.text=e.getProgramTextFromMonacoModel())}setModuleActive(e){this.main.bottomDiv.homeworkManager.hideRevision(),this.lastOpenModule!=null&&(this.lastOpenModule.file.text=this.lastOpenModule.getProgramTextFromMonacoModel(),this.lastOpenModule.editorState=this.main.getMonacoEditor().saveViewState()),e==null?(this.main.getMonacoEditor().setModel(x.createModel("Keine Datei vorhanden.","text")),this.main.getMonacoEditor().updateOptions({readOnly:!0})):(this.main.getMonacoEditor().updateOptions({readOnly:!1}),this.main.getMonacoEditor().setModel(e.model),e.file.text_before_revision!=null?this.main.bottomDiv.homeworkManager.showHomeWorkRevisionButton():this.main.bottomDiv.homeworkManager.hideHomeworkRevisionButton())}setActiveAfterExternalModelSet(e){this.fileListPanel.select(e,!1),this.lastOpenModule=e,e.editorState!=null&&(this.main.editor.dontPushNextCursorMove++,this.main.getMonacoEditor().restoreViewState(e.editorState),this.main.editor.dontPushNextCursorMove--),this.setCurrentlyEditedModule(e),this.showProgramPointer(),setTimeout(()=>{this.main.getMonacoEditor().getOptions().get(x.EditorOption.readOnly)||this.main.getMonacoEditor().focus()},300)}showProgramPointer(){if(this.programPointerModule==this.getCurrentlyEditedModule()&&this.getCurrentlyEditedModule()!=null){let e=this.programPointerPosition,t={startColumn:e.column,startLineNumber:e.line,endColumn:e.column+e.length,endLineNumber:e.line};this.main.getMonacoEditor().revealRangeInCenterIfOutsideViewport(t),this.programPointerDecoration=this.main.getMonacoEditor().deltaDecorations(this.programPointerDecoration,[{range:t,options:{className:"jo_revealProgramPointer",isWholeLine:!0,overviewRuler:{color:"#6fd61b",position:x.OverviewRulerLane.Center},minimap:{color:"#6fd61b",position:x.MinimapPosition.Inline}}},{range:t,options:{beforeContentClassName:"jo_revealProgramPointerBefore"}}])}}showProgramPointerPosition(e,t){if(e==null)return;let i=this.main.currentWorkspace.moduleStore.findModuleByFile(e);i!=null&&(this.programPointerModule=i,this.programPointerPosition=t,i!=this.getCurrentlyEditedModule()?this.setModuleActive(i):this.showProgramPointer())}hideProgramPointerPosition(){this.getCurrentlyEditedModule()==this.programPointerModule&&this.main.getMonacoEditor().deltaDecorations(this.programPointerDecoration,[]),this.programPointerModule=null,this.programPointerDecoration=[]}getCurrentlyEditedModule(){let e=this.main.currentWorkspace;return e==null?null:e.currentlyOpenModule}setCurrentlyEditedModule(e){if(e==null)return;let t=this.main.currentWorkspace;t.currentlyOpenModule!=e&&(t.currentlyOpenModule=e,t.saved=!1,e.file.dirty=!0)}setExplorerColor(e){let t;e==null?(e="transparent",t="Meine Datenbanken"):t="Schüler-DB",this.fileListPanel.$listElement.parent().css("background-color",e),this.workspaceListPanel.$listElement.parent().css("background-color",e),this.workspaceListPanel.setCaption(t)}getNewModule(e){return new U(e,this.main)}}class He{constructor(e,t){h(this,"$paginationDiv");h(this,"$infoDiv");h(this,"$arrowLeft");h(this,"$arrowRight");h(this,"paginationFrom");h(this,"paginationAll");h(this,"paginationSize",1e3);h(this,"result");h(this,"resultColumnTypes");h(this,"writeQueryListeners",[]);h(this,"oldErrorDecorations",[]);h(this,"showResultsBusy",!1);h(this,"showResultPending",!1);this.main=e,this.$bottomDiv=t,this.$paginationDiv=t.find(".jo_pagination");const i=c('<div class="jo_button jo_active img_export-csv-dark"></div>');this.$arrowLeft=c('<div class="jo_button img_arrow-left-dark jo_active"></div>'),this.$infoDiv=c('<div class="jo_pagination_info"><span class="jo_pagination_fromto"></span>/<span class="jo_pagination_all"></span></div>'),this.$arrowRight=c('<div class="jo_button img_arrow-right-dark jo_active"></div>'),this.$paginationDiv.empty(),this.$paginationDiv.append(i,this.$arrowLeft,this.$infoDiv,this.$arrowRight),this.$paginationDiv.hide();const n=t.find(".jo_resultTab");n.on("myshow",l=>{this.$paginationDiv.show()}),n.on("myhide",l=>{this.$paginationDiv.hide()});let r=(window.PointerEvent?"pointer":"mouse")+"up",o=this;this.$arrowLeft.on(r,l=>{o.paginationFrom>1&&(o.paginationFrom=Math.max(o.paginationFrom-o.paginationSize,1),o.paginationFrom%1e3!=1&&(o.paginationFrom=(Math.floor(o.paginationFrom/o.paginationSize)+1)*o.paginationSize+1),o.showResults(),o.activateButtons())}),this.$arrowRight.on(r,l=>{o.paginationFrom<this.paginationAll-o.paginationSize+1&&(o.paginationFrom=Math.min(o.paginationFrom+o.paginationSize,o.paginationAll-o.paginationSize+1),o.showResults(),o.activateButtons())}),i.on("click",()=>{this.exportCSV()})}addWriteQueryListener(e){this.writeQueryListeners.push(e)}activateButtons(){this.$arrowLeft.toggleClass("jo_active",this.paginationFrom>1),this.$arrowRight.toggleClass("jo_active",this.paginationFrom<this.paginationAll-this.paginationSize+1)}exportCSV(){let e="";this.result&&(e+=this.result.columns.map(t=>`"${t}"`).join(",")+`
207
+ `));let e=c(".jo_ds_student_list"),t=this;for(let i of this.classes)for(let n of i.students){let r=c('<div class="jo_ds_student_line">'),o=c(`<div class="jo_ds_student_class">${i.name}</div>`),l=c(`<div class="jo_ds_student_name">${n.rufname} ${n.familienname}</div>`);r.append(o,l),e.append(r),r.on("mousedown",()=>{r.toggleClass("jo_active"),t.studentCount+=r.hasClass("jo_active")?1:-1,c(".jo_ds_selected_message").text(`${t.studentCount} Schüler/inn/en selektiert`)}),r.data("student",n),r.data("klass",i)}c(".jo_ds_filterdiv>input").on("input",()=>{let i=c(".jo_ds_filterdiv>input").val();i==null||i==""?c(".jo_ds_student_line").show():c(".jo_ds_student_line").each((n,r)=>{let o=i.toLocaleLowerCase(),l=c(r),d=l.data("klass"),u=l.data("student");(d.name+" "+u.rufname+" "+u.familienname).toLocaleLowerCase().indexOf(o)>=0?l.show():l.hide()})}),this.$dialogMain=this.$dialog.find(".dialog-main"),this.$dialog.css("visibility","visible"),c("#jo_ds_cancel_button").on("click",()=>{t.close()}),c("#jo_ds_distribute_button").on("click",()=>{t.distributeDatabase()}),c(".jo_ds_filterdiv>input")[0].focus()}distributeDatabase(){let e=[];c(".jo_ds_student_line").each((t,i)=>{let n=c(i);if(n.hasClass("jo_active")){let r=n.data("student");e.push(r.id)}}),this.close(),this.main.networkManager.sendDistributeWorkspace(this.workspace,null,e,t=>{if(t==null){let i=this.main.networkManager,n=i.updateFrequencyInSeconds*i.forcedUpdateEvery;alert(`Der Workspace ${this.workspace.name} wurde an ${e.length} Schüler/innen ausgeteilt. Er wird in maximal ${n} s bei jedem Schüler ankommen.`)}else alert(t)})}close(){this.$dialog.css("visibility","hidden"),this.$dialog.empty(),c("#main").css("visibility","visible")}}class $i{constructor(e,t){h(this,"programPointerModule",null);h(this,"programPointerPosition");h(this,"programPointerDecoration",[]);h(this,"accordion");h(this,"fileListPanel");h(this,"workspaceListPanel");h(this,"$homeAction");h(this,"lastOpenModule",null);this.main=e,this.$projectexplorerDiv=t}initGUI(){this.accordion=new Mi(this.main,this.$projectexplorerDiv),this.initFilelistPanel(),this.initWorkspacelistPanel()}initFilelistPanel(){let e=this;this.fileListPanel=new ne(this.accordion,"Kein Workspace gewählt","1","img_add-file-dark","Neue Datei...","java",!0,!1,"file",!0,[]),this.fileListPanel.newFilesElementCallback=(t,i)=>{if(e.main.currentWorkspace==null)return alert("Bitte wählen Sie zuerst einen Workspace aus."),null;let n={name:t.name,dirty:!1,saved:!0,text:"",text_before_revision:null,submitted_date:null,student_edited_after_revision:!1,version:1,panelElement:t},r=new U(n,e.main);e.main.currentWorkspace.moduleStore.putModule(r),e.setModuleActive(r),e.main.networkManager.sendCreateFile(r,e.main.currentWorkspace,e.main.workspacesOwnerId,l=>{l==null?i(r):alert("Der Server ist nicht erreichbar!")})},this.fileListPanel.renameCallback=(t,i)=>{i=i.substr(0,80);let n=t.file;return n.name=i,n.saved=!1,e.main.networkManager.sendUpdates(),i},this.fileListPanel.deleteCallback=(t,i)=>{var n;t&&t.file&&((n=e==null?void 0:e.main)!=null&&n.networkManager)&&e.main.networkManager.sendDeleteWorkspaceOrFile("file",t.file.id,r=>{r==null?(e.main.currentWorkspace.moduleStore.removeModule(t),i()):alert("Der Server ist nicht erreichbar!")})},this.fileListPanel.contextMenuProvider=t=>{let i=[];return e.main.user.is_teacher||e.main.user.is_admin||e.main.user.is_schooladmin||t.externalElement.file,i},this.fileListPanel.selectCallback=t=>{e.setModuleActive(t)}}renderHomeworkButton(e){var r,o;let t=(o=(r=e==null?void 0:e.panelElement)==null?void 0:r.$htmlFirstLine)==null?void 0:o.find(".jo_additionalButtonHomework");if(t==null)return;t.find(".jo_homeworkButton").remove();let i=null,n="";if(e.submitted_date!=null&&(i="img_homework",n="Wurde als Hausaufgabe abgegeben: "+e.submitted_date,e.text_before_revision&&(i="img_homework-corrected",n="Korrektur liegt vor.")),i!=null){let l=c(`<div class="jo_homeworkButton ${i}" title="${n}"></div>`);t.prepend(l),i.indexOf("jo_active")>=0&&(l.on("mousedown",d=>d.stopPropagation()),l.on("click",d=>{d.stopPropagation()}))}}initWorkspacelistPanel(){let e=this;this.workspaceListPanel=new ne(this.accordion,"Datenbanken","3",null,"Neue Datenbank...","workspace",!0,!0,"workspace",!1,["file"]);let t=c('<div class="img_add-database-dark jo_button jo_active" style="margin-right: 4px" title="Neue Datenbank auf oberster Ordnerebene anlegen">'),i=window.PointerEvent?"pointer":"mouse";t.on(i+"down",n=>{n.stopPropagation();let r=e.main.user.id;e.main.workspacesOwnerId!=null&&(r=e.main.workspacesOwnerId),new We(e.main,r,this.workspaceListPanel.getCurrentlySelectedPath())}),this.workspaceListPanel.addAction(t),this.workspaceListPanel.$buttonNew!=null&&this.workspaceListPanel.$buttonNew.hide(),this.workspaceListPanel.newDatabaseElementCallback=n=>{let r=e.main.user.id;e.main.workspacesOwnerId!=null&&(r=e.main.workspacesOwnerId),new We(e.main,r,n)},this.workspaceListPanel.renameCallback=(n,r)=>{var o;return r=r.substring(0,80),n.name=r,n.saved=!1,e.main.networkManager.sendUpdates(),((o=n.database)==null?void 0:o.owner_id)==n.owner_id&&(n.database.name=r,e.main.networkManager.setNameAndPublishedTo(n.id,r,n.database.published_to,n.database.description,()=>{})),r},this.workspaceListPanel.deleteCallback=(n,r)=>{e.main.networkManager.sendDeleteWorkspaceOrFile("workspace",n.id,o=>{o==null?(e.main.removeWorkspace(n),n.isFolder||(e.fileListPanel.clear(),e.main.databaseExplorer.clear(),e.main.getResultsetPresenter().clear(),e.fileListPanel.enableNewButton(!1),e.main.getMonacoEditor().setModel(null)),r()):alert("Fehler: "+o)})},this.workspaceListPanel.selectCallback=n=>{n!=null&&n.isFolder||n!=this.main.currentWorkspace&&e.main.networkManager.sendUpdates(()=>{e.setWorkspaceActive(n)})},this.workspaceListPanel.newFolderCallback=(n,r)=>{let o=e.main.user.id;e.main.workspacesOwnerId!=null&&(o=e.main.workspacesOwnerId);let l=new ie(n.name,e.main,o);l.isFolder=!0,l.path=n.path.join("/"),l.panelElement=n,n.externalElement=l,e.main.workspaceList.push(l);let d={id:-1,isFolder:!0,name:l.name,path:l.path};e.main.networkManager.sendCreateWorkspace(d,e.main.workspacesOwnerId,u=>{u==null?(l.id=d.id,r(l)):(alert("Fehler: "+u),e.workspaceListPanel.removeElement(n))})},this.workspaceListPanel.moveCallback=n=>{Array.isArray(n)||(n=[n]);for(let r of n){let o=r.externalElement;o.path=r.path.join("/"),o.saved=!1}this.main.networkManager.sendUpdates()},this.workspaceListPanel.dropElementCallback=(n,r,o)=>{let l=n.externalElement,d=r.externalElement;if(l.moduleStore.getModules(!1).indexOf(d)>=0)return;let u={name:d.file.name,dirty:!0,saved:!1,text:d.file.text,text_before_revision:null,submitted_date:null,student_edited_after_revision:!1,version:d.file.version,panelElement:null};o=="move"&&(e.main.currentWorkspace.moduleStore.removeModule(d),e.fileListPanel.removeElement(d),e.main.networkManager.sendDeleteWorkspaceOrFile("file",d.file.id,()=>{}));let m=new U(u,e.main);l.moduleStore.putModule(m),e.main.networkManager.sendCreateFile(m,l,e.main.workspacesOwnerId,p=>{p==null||alert("Der Server ist nicht erreichbar!")})},this.$homeAction=c('<div class="img_home-dark jo_button jo_active" style="margin-right: 4px" title="Meine eigenen Workspaces anzeigen">'),this.$homeAction.on(i+"down",n=>{n.stopPropagation(),e.main.networkManager.sendUpdates(()=>{e.onHomeButtonClicked()}),e.main.bottomDiv.hideHomeworkTab()}),this.workspaceListPanel.addAction(this.$homeAction),this.$homeAction.hide(),this.workspaceListPanel.contextMenuProvider=n=>{let r=[];return this.main.user.is_teacher&&this.main.teacherExplorer.classPanel.elements.length>0&&r.push({caption:"An Klasse austeilen...",callback:o=>{},subMenu:this.main.teacherExplorer.classPanel.elements.map(o=>({caption:o.name,callback:l=>{let d=o.externalElement,u=l.externalElement;this.main.networkManager.sendDistributeWorkspace(u,d,null,m=>{if(m==null){let f=this.main.networkManager,p=f.updateFrequencyInSeconds*f.forcedUpdateEvery;alert("Der Workspace "+u.name+" wurde an die Klasse "+d.name+" ausgeteilt. Er wird in maximal "+p+" s bei jedem Schüler ankommen.")}else alert(m)})}}))},{caption:"An einzelne Schüler/innen austeilen...",callback:o=>{let l=this.main.teacherExplorer.classPanel.elements.map(u=>u.externalElement),d=o.externalElement;new ji(l,d,this.main)}}),r}}onHomeButtonClicked(){this.main.teacherExplorer.restoreOwnWorkspaces(),this.main.networkManager.updateFrequencyInSeconds=this.main.networkManager.ownUpdateFrequencyInSeconds,this.$homeAction.hide(),this.fileListPanel.enableNewButton(this.main.workspaceList.length>0)}renderFiles(e){let t=e==null?"Kein Workspace vorhanden":e.name;if(this.fileListPanel.setCaption(t),this.fileListPanel.clear(),this.main.getCurrentWorkspace()!=null)for(let i of this.main.getCurrentWorkspace().moduleStore.getModules(!1))i.file.panelElement=null;if(e!=null){let i=[];for(let n of e.moduleStore.getModules(!1))i.push(n);i.sort((n,r)=>n.file.name>r.file.name?1:n.file.name<r.file.name?-1:0);for(let n of i)n.file.panelElement={name:n.file.name,externalElement:n,isFolder:!1,path:[]},this.fileListPanel.addElement(n.file.panelElement,!0),this.renderHomeworkButton(n.file);this.fileListPanel.sortElements()}}renderWorkspaces(e){this.fileListPanel.clear(),this.workspaceListPanel.clear();for(let t of e){let i=t.path.split("/");i.length==1&&i[0]==""&&(i=[]),t.panelElement={name:t.name,externalElement:t,iconClass:"workspace",isFolder:t.isFolder,path:i},this.workspaceListPanel.addElement(t.panelElement,!1),t.renderSettingsButton(t.panelElement)}this.workspaceListPanel.sortElements(),this.fileListPanel.enableNewButton(e.length>0)}renderErrorCount(e,t){if(t!=null)for(let i of e.moduleStore.getModules(!1)){let n=t.get(i),r=n==null||n==0?"":"("+n+")";this.fileListPanel.setTextAfterFilename(i.file.panelElement,r,"jo_errorcount")}}setWorkspaceActive(e,t,i=!1){if(t==null&&(t=()=>{}),e==this.main.getCurrentWorkspace()){t!=null&&t();return}if(e!=null)if(e.isFolder){this.main.currentWorkspace=null,this.main.databaseTool.initializeWorker(null,[],null,()=>{this.main.databaseExplorer.refreshAfterRetrievingDBStructure()}),this.setModuleActive(null);return}else this.fileListPanel.$buttonNew.show();this.workspaceListPanel.select(e,!1,i);let n=r=>{r!=null?(alert(r),this.main.waitOverlay.hide(),t!=null&&t()):(this.main.waitOverlay.show("Bitte warten, initialisiere Datenbank ..."),this.initializeDatabaseTool(e,t))};e!=null&&(e.database==null?(this.main.waitOverlay.show("Bitte warten, hole Datenbank vom Server ..."),this.main.networkManager.fetchDatabase(e,n)):n(null))}initializeDatabaseTool(e,t){if(!e.database){t&&t();return}let i=this.main.getDatabaseTool(),n=e.database.statements;n==null&&(n=[]),i.initializeWorker(e.database.templateDump,n,()=>{var r;if(this.main.currentWorkspace=e,((r=this.main.user)==null?void 0:r.id)==e.owner_id&&(this.main.user.currentWorkspace_id=e.id),this.renderFiles(e),e!=null){let o=e.moduleStore.getModules(!1);e.currentlyOpenModule!=null?this.setModuleActive(e.currentlyOpenModule):o.length>0?this.setModuleActive(o[0]):this.setModuleActive(null);for(let l of o)l.file.dirty=!0;o.length==0&&K.showHelper("newSQLFileHelper",this.main,this.fileListPanel.$captionElement)}else this.setModuleActive(null);this.main.notifier.connect(e)},()=>{this.main.databaseExplorer.refreshAfterRetrievingDBStructure(),this.main.getHistoryViewer().clearAndShowStatements(e.database.statements),t!=null&&t()})}writeEditorTextToFile(){let e=this.getCurrentlyEditedModule();e!=null&&(e.file.text=e.getProgramTextFromMonacoModel())}setModuleActive(e){this.main.bottomDiv.homeworkManager.hideRevision(),this.lastOpenModule!=null&&(this.lastOpenModule.file.text=this.lastOpenModule.getProgramTextFromMonacoModel(),this.lastOpenModule.editorState=this.main.getMonacoEditor().saveViewState()),e==null?(this.main.getMonacoEditor().setModel(x.createModel("Keine Datei vorhanden.","text")),this.main.getMonacoEditor().updateOptions({readOnly:!0})):(this.main.getMonacoEditor().updateOptions({readOnly:!1}),this.main.getMonacoEditor().setModel(e.model),e.file.text_before_revision!=null?this.main.bottomDiv.homeworkManager.showHomeWorkRevisionButton():this.main.bottomDiv.homeworkManager.hideHomeworkRevisionButton())}setActiveAfterExternalModelSet(e){this.fileListPanel.select(e,!1),this.lastOpenModule=e,e.editorState!=null&&(this.main.editor.dontPushNextCursorMove++,this.main.getMonacoEditor().restoreViewState(e.editorState),this.main.editor.dontPushNextCursorMove--),this.setCurrentlyEditedModule(e),this.showProgramPointer(),setTimeout(()=>{this.main.getMonacoEditor().getOptions().get(x.EditorOption.readOnly)||this.main.getMonacoEditor().focus()},300)}showProgramPointer(){if(this.programPointerModule==this.getCurrentlyEditedModule()&&this.getCurrentlyEditedModule()!=null){let e=this.programPointerPosition,t={startColumn:e.column,startLineNumber:e.line,endColumn:e.column+e.length,endLineNumber:e.line};this.main.getMonacoEditor().revealRangeInCenterIfOutsideViewport(t),this.programPointerDecoration=this.main.getMonacoEditor().deltaDecorations(this.programPointerDecoration,[{range:t,options:{className:"jo_revealProgramPointer",isWholeLine:!0,overviewRuler:{color:"#6fd61b",position:x.OverviewRulerLane.Center},minimap:{color:"#6fd61b",position:x.MinimapPosition.Inline}}},{range:t,options:{beforeContentClassName:"jo_revealProgramPointerBefore"}}])}}showProgramPointerPosition(e,t){if(e==null)return;let i=this.main.currentWorkspace.moduleStore.findModuleByFile(e);i!=null&&(this.programPointerModule=i,this.programPointerPosition=t,i!=this.getCurrentlyEditedModule()?this.setModuleActive(i):this.showProgramPointer())}hideProgramPointerPosition(){this.getCurrentlyEditedModule()==this.programPointerModule&&this.main.getMonacoEditor().deltaDecorations(this.programPointerDecoration,[]),this.programPointerModule=null,this.programPointerDecoration=[]}getCurrentlyEditedModule(){let e=this.main.currentWorkspace;return e==null?null:e.currentlyOpenModule}setCurrentlyEditedModule(e){if(e==null)return;let t=this.main.currentWorkspace;t.currentlyOpenModule!=e&&(t.currentlyOpenModule=e,t.saved=!1,e.file.dirty=!0)}setExplorerColor(e){let t;e==null?(e="transparent",t="Meine Datenbanken"):t="Schüler-DB",this.fileListPanel.$listElement.parent().css("background-color",e),this.workspaceListPanel.$listElement.parent().css("background-color",e),this.workspaceListPanel.setCaption(t)}getNewModule(e){return new U(e,this.main)}}class Ve{constructor(e,t){h(this,"$paginationDiv");h(this,"$infoDiv");h(this,"$arrowLeft");h(this,"$arrowRight");h(this,"paginationFrom");h(this,"paginationAll");h(this,"paginationSize",1e3);h(this,"result");h(this,"resultColumnTypes");h(this,"writeQueryListeners",[]);h(this,"oldErrorDecorations",[]);h(this,"showResultsBusy",!1);h(this,"showResultPending",!1);this.main=e,this.$bottomDiv=t,this.$paginationDiv=t.find(".jo_pagination");const i=c('<div class="jo_button jo_active img_export-csv-dark"></div>');this.$arrowLeft=c('<div class="jo_button img_arrow-left-dark jo_active"></div>'),this.$infoDiv=c('<div class="jo_pagination_info"><span class="jo_pagination_fromto"></span>/<span class="jo_pagination_all"></span></div>'),this.$arrowRight=c('<div class="jo_button img_arrow-right-dark jo_active"></div>'),this.$paginationDiv.empty(),this.$paginationDiv.append(i,this.$arrowLeft,this.$infoDiv,this.$arrowRight),this.$paginationDiv.hide();const n=t.find(".jo_resultTab");n.on("myshow",l=>{this.$paginationDiv.show()}),n.on("myhide",l=>{this.$paginationDiv.hide()});let r=(window.PointerEvent?"pointer":"mouse")+"up",o=this;this.$arrowLeft.on(r,l=>{o.paginationFrom>1&&(o.paginationFrom=Math.max(o.paginationFrom-o.paginationSize,1),o.paginationFrom%1e3!=1&&(o.paginationFrom=(Math.floor(o.paginationFrom/o.paginationSize)+1)*o.paginationSize+1),o.showResults(),o.activateButtons())}),this.$arrowRight.on(r,l=>{o.paginationFrom<this.paginationAll-o.paginationSize+1&&(o.paginationFrom=Math.min(o.paginationFrom+o.paginationSize,o.paginationAll-o.paginationSize+1),o.showResults(),o.activateButtons())}),i.on("click",()=>{this.exportCSV()})}addWriteQueryListener(e){this.writeQueryListeners.push(e)}activateButtons(){this.$arrowLeft.toggleClass("jo_active",this.paginationFrom>1),this.$arrowRight.toggleClass("jo_active",this.paginationFrom<this.paginationAll-this.paginationSize+1)}exportCSV(){let e="";this.result&&(e+=this.result.columns.map(t=>`"${t}"`).join(",")+`
208
208
  `,e+=this.result.values.map(t=>t.map(i=>`"${i}"`).join(",")).join(`
209
- `)),ze("\uFEFF"+e,"results.csv",!1)}executeSelectedStatements(){let e=this.fetchSelectedStatements().filter(o=>o.ast.type!=s.omittedeStatement);if(e.length==0)return;let t=e.some(o=>this.isDDLStatement(o)),i=e.some(o=>this.isWriteStatement(o)),n=this.main.getCurrentWorkspace(),r=n.database;if(t&&n.permissions<=1){alert("Der Benutzer hat keine Berechtigung zum Ändern der Tabellenstruktur.");return}if(i&&n.permissions==0){alert("Der Benutzer hat keine Berechtigung zum Einfügen/Löschen/Ändern von Datensätzen.");return}t||i?this.main.isEmbedded()?this.executeDDLWriteStatementsEmbedded(n,e,r):this.executeDDLWriteStatementsInOnlineIDE(n,e,r):this.executeStatements(e,0,[],()=>{})}executeDDLWriteStatementsEmbedded(e,t,i){let n=[];this.executeStatements(t,0,n,()=>{n.length!=0&&(this.main.getDatabaseExplorer().refresh(),this.writeQueryListeners.forEach(r=>r.notify(n)))})}executeDDLWriteStatementsInOnlineIDE(e,t,i){let n=this.main;n.networkManager.getNewStatements(e,(r,o)=>{n.notifier.executeNewStatements(r,o,()=>{},()=>{let l=[];this.executeStatements(t,0,l,()=>{if(l.length==0)return;let d=l.map(u=>u.sqlCleaned==null?u.sql:u.sqlCleaned);i.statements=i.statements.concat(d),this.main.getHistoryViewer().appendStatements(d),i.version+=d.length,n.networkManager.AddDatabaseStatements(e,l.map(u=>u.sqlCleaned==null?u.sql:u.sqlCleaned),(u,m)=>{u.length>0?(e.database.version=0,e.database.statements=[],n.networkManager.getNewStatements(e,()=>{this.resetDatabase(i)})):n.getDatabaseExplorer().refresh()})})},!1)})}resetDatabase(e){this.main.getDatabaseTool().initializeWorker(e.templateDump,e.statements,()=>{this.main.getDatabaseExplorer().refresh()})}executeStatementsString(e,t,i){if(e.length==0){i();return}t<e.length?this.main.getDatabaseTool().executeQuery(e[t],n=>{this.executeStatementsString(e,t+1,i)},n=>{console.log("Error when executing statement "+e[t]+`
209
+ `)),He("\uFEFF"+e,"results.csv",!1)}executeSelectedStatements(){let e=this.fetchSelectedStatements().filter(o=>o.ast.type!=s.omittedeStatement);if(e.length==0)return;let t=e.some(o=>this.isDDLStatement(o)),i=e.some(o=>this.isWriteStatement(o)),n=this.main.getCurrentWorkspace(),r=n.database;if(t&&n.permissions<=1){alert("Der Benutzer hat keine Berechtigung zum Ändern der Tabellenstruktur.");return}if(i&&n.permissions==0){alert("Der Benutzer hat keine Berechtigung zum Einfügen/Löschen/Ändern von Datensätzen.");return}t||i?this.main.isEmbedded()?this.executeDDLWriteStatementsEmbedded(n,e,r):this.executeDDLWriteStatementsInOnlineIDE(n,e,r):this.executeStatements(e,0,[],()=>{})}executeDDLWriteStatementsEmbedded(e,t,i){let n=[];this.executeStatements(t,0,n,()=>{n.length!=0&&(this.main.getDatabaseExplorer().refresh(),this.writeQueryListeners.forEach(r=>r.notify(n)))})}executeDDLWriteStatementsInOnlineIDE(e,t,i){let n=this.main;n.networkManager.getNewStatements(e,(r,o)=>{n.notifier.executeNewStatements(r,o,()=>{},()=>{let l=[];this.executeStatements(t,0,l,()=>{if(l.length==0)return;let d=l.map(u=>u.sqlCleaned==null?u.sql:u.sqlCleaned);i.statements=i.statements.concat(d),this.main.getHistoryViewer().appendStatements(d),i.version+=d.length,n.networkManager.AddDatabaseStatements(e,l.map(u=>u.sqlCleaned==null?u.sql:u.sqlCleaned),(u,m)=>{u.length>0?(e.database.version=0,e.database.statements=[],n.networkManager.getNewStatements(e,()=>{this.resetDatabase(i)})):n.getDatabaseExplorer().refresh()})})},!1)})}resetDatabase(e){this.main.getDatabaseTool().initializeWorker(e.templateDump,e.statements,()=>{this.main.getDatabaseExplorer().refresh()})}executeStatementsString(e,t,i){if(e.length==0){i();return}t<e.length?this.main.getDatabaseTool().executeQuery(e[t],n=>{this.executeStatementsString(e,t+1,i)},n=>{console.log("Error when executing statement "+e[t]+`
210
210
  Error : `+n),this.executeStatementsString(e,t+1,i)}):i()}executeStatements(e,t,i,n,r=[]){if(t>=e.length){this.showErrors(r),n();return}let o=e[t],l=()=>{this.executeStatements(e,t+1,i,n,r)};if(o.ast==null){l();return}if(o.ast.type==s.keywordSelect){let d=!1;for(let u=t+1;u<e.length;u++)d=d||this.isSelectStatement(e[u]);if(d)l();else{if(o.ast.limitNode==null){for(o.sql.trimRight();o.sql.endsWith(";")||o.sql.endsWith(`
211
- `)||o.sql.endsWith("\r");)o.sql=o.sql.substring(0,o.sql.length-1),o.sql.trimRight();o.sql+=" limit 100000"}this.main.getDatabaseTool().executeQuery(o.sql,u=>{this.presentResultsIntern(o.sql,u,o.resultTypes),l()},u=>{r.push({statement:o,message:u}),l()})}}else{let d=new Ct().clean(o);console.log(d),this.main.getDatabaseTool().executeQuery(d,u=>{i.push(o),l()},u=>{r.push({statement:o,message:u}),l()})}}showErrorDecorations(e){let t={error:"#bc1616",warning:"#cca700",info:"#75beff"};this.main.getMonacoEditor();let i=[],n=[];for(let o of e){let l="error",d,u=t[l];switch(l){case"error":d="jo_revealErrorLine";break;case"warning":d="jo_revealWarningLine";break;case"info":d="jo_revealInfoLine";break}let m;switch(l){case"error":m=ee.Error;break;case"warning":m=ee.Warning;break;case"info":m=ee.Info;break}i.push({startLineNumber:o.statement.from.line,startColumn:o.statement.from.column,endLineNumber:o.statement.to.line,endColumn:o.statement.to.column,message:o.message,severity:m}),n.push({range:{startLineNumber:o.statement.from.line,startColumn:o.statement.from.column,endLineNumber:o.statement.to.line,endColumn:o.statement.to.column},options:{linesDecorationsClassName:d,minimap:{position:x.MinimapPosition.Inline,color:u}}})}let r=this.main.getCurrentlyEditedModule().model;x.setModelMarkers(r,"test",i),this.oldErrorDecorations=r.deltaDecorations(this.oldErrorDecorations,n)}showTable(e){let t="select * from "+e.identifier+";";this.main.getDatabaseTool().executeQuery(t,i=>{this.presentResultsIntern(t,i,e.columns.map(n=>n.type))},i=>{})}showErrors(e){let t=this.$bottomDiv.find(".jo_errorsTab"),i=this.$bottomDiv.find(".jo_errorsTabheading");if(t.empty(),this.showErrorDecorations(e),e.length==0)return;let n=window.PointerEvent?"pointer":"mouse";i.trigger(n+"down");let r=c('<div class="jo_errorlist"></div>');t.append(r);for(let o of e){let l=o.statement.sql;l=l.replace(/\n/g," "),l=l.replace(/\s\s+/g," ");let d=c('<div class="jo_error-line" style="flex-direction:column; width: fit-content"></div>');r.append(d),d.on(n+"down",()=>{let f={startColumn:o.statement.from.column,startLineNumber:o.statement.from.line,endColumn:o.statement.to.column,endLineNumber:o.statement.to.line};this.main.getMonacoEditor().revealRangeInCenter(f),r.find(".jo_error-line").removeClass("jo_active"),d.addClass("jo_active")});let u=c('<div class="jo_sqlErrorStatement"></div>');d.append(u),x.colorize(l,"vscSQL",{}).then(f=>{u.html(f)});let m=c('<div class="jo_sqlErrorMessage">'+o.message+"</div>");d.append(m)}this.$bottomDiv.find(".jo_tabheading").removeClass("jo_active"),i.addClass("jo_active"),t.addClass("jo_active")}isSelectStatement(e){return e.ast!=null&&e.ast.type==s.keywordSelect}isDDLStatement(e){return e.ast!=null&&[s.keywordCreate,s.keywordDrop,s.keywordAlter,s.keywordView].indexOf(e.ast.type)>=0}isWriteStatement(e){return e.ast!=null&&[s.keywordInsert,s.keywordDelete,s.keywordUpdate].indexOf(e.ast.type)>=0}presentResultsIntern(e,t,i){let n=this.$bottomDiv.find(".jo_resultTabheading"),r=this.$bottomDiv.find(".jo_result-header"),o=window.PointerEvent?"pointer":"mouse";n.trigger(o+"down"),this.result=t.pop(),this.resultColumnTypes=i;let l=r;e=e.replace(/\n/g," "),e=e.replace(/\s\s+/g," "),e=e.replace(/limit 100000/g,""),x.colorize(e,"vscSQL",{}).then(d=>{l.html(d)}),this.paginationAll=this.result?this.result.values.length:0,this.$infoDiv.find(".jo_pagination_all").html(`${this.paginationAll}`),this.paginationFrom=1,this.$paginationDiv.show(),this.activateButtons(),this.showResults()}clear(){this.$bottomDiv.find(".jo_result-body").empty(),this.$paginationDiv.hide()}showResults(){let e=this.$bottomDiv.find(".jo_result-body");if(this.result==null){this.$infoDiv.find(".jo_pagination_fromto").html("---"),e.html("Die Datenbank lieferte eine leere Ergebnistabelle.");return}let t=this,i=this.paginationAll==0?0:this.paginationFrom,n=this.paginationAll==0?0:Math.min(this.paginationFrom+this.paginationSize-1,this.paginationAll);if(this.$infoDiv.find(".jo_pagination_fromto").html(`${i}-${n}`),this.showResultsBusy){if(this.showResultPending)return;this.showResultPending=!0;let f=()=>{t.showResultsBusy?setTimeout(()=>{f()},200):(t.showResultPending=!1,t.showResults())};setTimeout(f,200);return}this.showResultsBusy=!0;let r=c("<table></table>"),o=c("<tr></tr>");r.append(o),this.result.columns.forEach(f=>{o.append(c(`<th><div>${f}</div></th>`))});let l=this.result.values.slice(this.paginationFrom-1,this.paginationFrom+this.paginationSize-1),d=0,u=this.resultColumnTypes.map(f=>["boolean","tinyint(1)"].indexOf(f.toString())>=0),m=()=>{if(d<l.length){for(let f=d;f<Math.min(d+200,l.length);f++){let p=l[f],b=c("<tr></tr>");r.append(b),p.forEach((k,g)=>{let w=k;u[g]&&(w=k==1?"true":"false"),b.append(c(`<td>${w}</td>`))})}d=Math.min(d+200,l.length),d<l.length?setTimeout(m,30):(e.empty().append(r),this.showResultsBusy=!1)}};m()}fetchSelectedStatements(){let e=this.main.getCurrentlyEditedModule();if(e==null)return null;let t=this.main.getMonacoEditor(),i=e.getSQLSTatementsAtSelection(t.getSelection());for(let n of i)n.sql=t.getModel().getValueInRange({startColumn:n.from.column,startLineNumber:n.from.line,endColumn:n.to.column,endLineNumber:n.to.line});return i}}h(He,"StatementDelimiter",`;
211
+ `)||o.sql.endsWith("\r");)o.sql=o.sql.substring(0,o.sql.length-1),o.sql.trimRight();o.sql+=" limit 100000"}this.main.getDatabaseTool().executeQuery(o.sql,u=>{this.presentResultsIntern(o.sql,u,o.resultTypes),l()},u=>{r.push({statement:o,message:u}),l()})}}else{let d=new St().clean(o);console.log(d),this.main.getDatabaseTool().executeQuery(d,u=>{i.push(o),l()},u=>{r.push({statement:o,message:u}),l()})}}showErrorDecorations(e){let t={error:"#bc1616",warning:"#cca700",info:"#75beff"};this.main.getMonacoEditor();let i=[],n=[];for(let o of e){let l="error",d,u=t[l];switch(l){case"error":d="jo_revealErrorLine";break;case"warning":d="jo_revealWarningLine";break;case"info":d="jo_revealInfoLine";break}let m;switch(l){case"error":m=te.Error;break;case"warning":m=te.Warning;break;case"info":m=te.Info;break}i.push({startLineNumber:o.statement.from.line,startColumn:o.statement.from.column,endLineNumber:o.statement.to.line,endColumn:o.statement.to.column,message:o.message,severity:m}),n.push({range:{startLineNumber:o.statement.from.line,startColumn:o.statement.from.column,endLineNumber:o.statement.to.line,endColumn:o.statement.to.column},options:{linesDecorationsClassName:d,minimap:{position:x.MinimapPosition.Inline,color:u}}})}let r=this.main.getCurrentlyEditedModule().model;x.setModelMarkers(r,"test",i),this.oldErrorDecorations=r.deltaDecorations(this.oldErrorDecorations,n)}showTable(e){let t="select * from "+e.identifier+";";this.main.getDatabaseTool().executeQuery(t,i=>{this.presentResultsIntern(t,i,e.columns.map(n=>n.type))},i=>{})}showErrors(e){let t=this.$bottomDiv.find(".jo_errorsTab"),i=this.$bottomDiv.find(".jo_errorsTabheading");if(t.empty(),this.showErrorDecorations(e),e.length==0)return;let n=window.PointerEvent?"pointer":"mouse";i.trigger(n+"down");let r=c('<div class="jo_errorlist"></div>');t.append(r);for(let o of e){let l=o.statement.sql;l=l.replace(/\n/g," "),l=l.replace(/\s\s+/g," ");let d=c('<div class="jo_error-line" style="flex-direction:column; width: fit-content"></div>');r.append(d),d.on(n+"down",()=>{let f={startColumn:o.statement.from.column,startLineNumber:o.statement.from.line,endColumn:o.statement.to.column,endLineNumber:o.statement.to.line};this.main.getMonacoEditor().revealRangeInCenter(f),r.find(".jo_error-line").removeClass("jo_active"),d.addClass("jo_active")});let u=c('<div class="jo_sqlErrorStatement"></div>');d.append(u),x.colorize(l,"vscSQL",{}).then(f=>{u.html(f)});let m=c('<div class="jo_sqlErrorMessage">'+o.message+"</div>");d.append(m)}this.$bottomDiv.find(".jo_tabheading").removeClass("jo_active"),i.addClass("jo_active"),t.addClass("jo_active")}isSelectStatement(e){return e.ast!=null&&e.ast.type==s.keywordSelect}isDDLStatement(e){return e.ast!=null&&[s.keywordCreate,s.keywordDrop,s.keywordAlter,s.keywordView].indexOf(e.ast.type)>=0}isWriteStatement(e){return e.ast!=null&&[s.keywordInsert,s.keywordDelete,s.keywordUpdate].indexOf(e.ast.type)>=0}presentResultsIntern(e,t,i){let n=this.$bottomDiv.find(".jo_resultTabheading"),r=this.$bottomDiv.find(".jo_result-header"),o=window.PointerEvent?"pointer":"mouse";n.trigger(o+"down"),this.result=t.pop(),this.resultColumnTypes=i;let l=r;e=e.replace(/\n/g," "),e=e.replace(/\s\s+/g," "),e=e.replace(/limit 100000/g,""),x.colorize(e,"vscSQL",{}).then(d=>{l.html(d)}),this.paginationAll=this.result?this.result.values.length:0,this.$infoDiv.find(".jo_pagination_all").html(`${this.paginationAll}`),this.paginationFrom=1,this.$paginationDiv.show(),this.activateButtons(),this.showResults()}clear(){this.$bottomDiv.find(".jo_result-body").empty(),this.$paginationDiv.hide()}showResults(){let e=this.$bottomDiv.find(".jo_result-body");if(this.result==null){this.$infoDiv.find(".jo_pagination_fromto").html("---"),e.html("Die Datenbank lieferte eine leere Ergebnistabelle.");return}let t=this,i=this.paginationAll==0?0:this.paginationFrom,n=this.paginationAll==0?0:Math.min(this.paginationFrom+this.paginationSize-1,this.paginationAll);if(this.$infoDiv.find(".jo_pagination_fromto").html(`${i}-${n}`),this.showResultsBusy){if(this.showResultPending)return;this.showResultPending=!0;let f=()=>{t.showResultsBusy?setTimeout(()=>{f()},200):(t.showResultPending=!1,t.showResults())};setTimeout(f,200);return}this.showResultsBusy=!0;let r=c("<table></table>"),o=c("<tr></tr>");r.append(o),this.result.columns.forEach(f=>{o.append(c(`<th><div>${f}</div></th>`))});let l=this.result.values.slice(this.paginationFrom-1,this.paginationFrom+this.paginationSize-1),d=0,u=this.resultColumnTypes.map(f=>["boolean","tinyint(1)"].indexOf(f.toString())>=0),m=()=>{if(d<l.length){for(let f=d;f<Math.min(d+200,l.length);f++){let p=l[f],b=c("<tr></tr>");r.append(b),p.forEach((k,g)=>{let w=k;u[g]&&(w=k==1?"true":"false"),b.append(c(`<td>${w}</td>`))})}d=Math.min(d+200,l.length),d<l.length?setTimeout(m,30):(e.empty().append(r),this.showResultsBusy=!1)}};m()}fetchSelectedStatements(){let e=this.main.getCurrentlyEditedModule();if(e==null)return null;let t=this.main.getMonacoEditor(),i=e.getSQLSTatementsAtSelection(t.getSelection());for(let n of i)n.sql=t.getModel().getValueInRange({startColumn:n.from.column,startLineNumber:n.from.line,endColumn:n.to.column,endLineNumber:n.to.line});return i}}h(Ve,"StatementDelimiter",`;
212
212
 
213
- `);class Et{constructor(e,t){h(this,"isWholePage",!1);h(this,"$tabs");h(this,"$headings");this.main=e,this.$rightDiv=t,this.$tabs=t.find(".jo_tabs"),this.$headings=t.find(".jo_tabheadings"),this.$headings.find(".jo_classDiagramTabHeading").length>0,this.$headings.find(".jo_objectDiagramTabHeading").length>0;let i=this,n="100%";t.find(".jo_whole-window").on("click",()=>{i.isWholePage=!i.isWholePage;let r=c(".jo_whole-window");i.isWholePage?(c("#code").css("display","none"),n=c("#rightdiv").css("width"),c("#rightdiv").css("width","100%"),r.removeClass("img_whole-window"),r.addClass("img_whole-window-back"),c(".jo_control-container").append(c("#controls")),r.attr("title","Auf normale Größe zurückführen"),c(".jo_graphics").trigger("sizeChanged")):(c("#code").css("display","flex"),c("#rightdiv").css("width",n),r.removeClass("img_whole-window-back"),r.addClass("img_whole-window"),c("#controls").insertAfter(c("#view-mode")),r.attr("title","Auf Fenstergröße vergrößern"),c(".jo_graphics").trigger("sizeChanged"))})}initGUI(){Te(this.$rightDiv)}}class Ii{constructor(e){h(this,"main");this.main=e}initSliders(){let e=this,t=window.PointerEvent?"pointer":"mouse";c("#slider1").on(t+"down",r=>{let o=r.clientX;c(document).on(t+"move.slider1",l=>{let d=l.clientX-o;e.moveLeftPanel(d),o=l.clientX}),c(document).on(t+"up.slider1",()=>{c(document).off(t+"move.slider1"),c(document).off(t+"up.slider1")})}),c("#slider2").on(t+"down",r=>{let o=r.clientY;c(document).on(t+"move.slider2",l=>{let d=l.clientY-o;e.moveBottomDiv(d),o=l.clientY}),c(document).on(t+"up.slider2",()=>{c(document).off(t+"move.slider2"),c(document).off(t+"up.slider2")})}),c("#slider3").on(t+"down",r=>{let o=r.clientX;c(document).on(t+"move.slider3",l=>{let d=l.clientX-o;e.moveRightDiv(d),o=l.clientX,l.stopPropagation()}),c(document).on(t+"up.slider3",()=>{c(document).off(t+"move.slider3"),c(document).off(t+"up.slider3")})});let i=c('<div class="jo_sliderknob img_knob jo_button jo_active" style="left: -8px" draggable="false"></div>');c("#slider2").append(i),i.on(t+"down",r=>{let o=r.clientY,l=r.clientX;r.stopImmediatePropagation(),c(document).on(t+"move.knobleft",d=>{let u=d.clientY-o,m=d.clientX-l;d.stopImmediatePropagation(),e.moveLeftPanel(m),e.moveBottomDiv(u),l+=m,o+=u}),c(document).on(t+"up.knobleft",()=>{c(document).off(t+"move.knobleft"),c(document).off(t+"up.knobleft")})});let n=c('<div class="jo_sliderknob img_knob jo_button jo_active" style="right: -8px" draggable="false"></div>');c("#slider2").append(n),n.on(t+"down",r=>{let o=r.clientY,l=r.clientX;r.stopImmediatePropagation(),c(document).on(t+"move.knobright",d=>{let u=d.clientY-o,m=d.clientX-l;d.stopImmediatePropagation(),e.moveRightDiv(m),e.moveBottomDiv(u),l+=m,o+=u}),c(document).on(t+"up.knobright",()=>{c(document).off(t+"move.knobright"),c(document).off(t+"up.knobright")})})}moveRightDiv(e){let t=c("#editor>.monaco-editor"),i=c("#rightdiv"),n=Number.parseInt(i.css("width").replace("px",""));i.css("width",n-e+"px");let r=Number.parseInt(t.css("width").replace("px",""));t.css("width",r+e+"px"),this.main.getMonacoEditor().layout(),this.main.bottomDiv.homeworkManager.diffEditor!=null&&this.main.bottomDiv.homeworkManager.diffEditor.layout(),c(".jo_graphics").trigger("sizeChanged"),n+=e}moveBottomDiv(e){let t=c("#editor>.monaco-editor"),i=c("#bottomdiv-outer"),n=Number.parseInt(i.css("height").replace("px",""));i.css("height",n-e+"px");let r=Number.parseInt(t.css("height").replace("px",""));t.css("height",r+e+"px"),this.main.getMonacoEditor().layout(),this.main.bottomDiv.homeworkManager.diffEditor!=null&&this.main.bottomDiv.homeworkManager.diffEditor.layout()}moveLeftPanel(e){let t=c("#leftpanel"),i=c("#editor>.monaco-editor"),n=Number.parseInt(t.css("width").replace("px",""));t.css("width",n+e+"px");let r=Number.parseInt(i.css("width").replace("px",""));i.css("width",r-e+"px"),this.main.getMonacoEditor().layout(),this.main.bottomDiv.homeworkManager.diffEditor!=null&&this.main.bottomDiv.homeworkManager.diffEditor.layout()}}function ae(a,e=!1){var t,i;return a.vidis_akronym?a.username&&a.username.length>0?a.username:a.vidis_akronym:((t=a.familienname)==null?void 0:t.length)>0&&((i=a.rufname)==null?void 0:i.length)>0?e?a.familienname+", "+a.rufname:a.rufname+" "+a.familienname:a.username}class Bi{constructor(e,t){h(this,"studentPanel");h(this,"classPanel");h(this,"ownWorkspaces");h(this,"currentOwnWorkspace");this.main=e,this.classData=t}removePanels(){this.classPanel.remove(),this.studentPanel.remove()}initGUI(){this.initStudentPanel(),this.initClassPanel(),this.renderClasses(this.classData)}initStudentPanel(){let e=this;this.studentPanel=new ie(this.main.projectExplorer.accordion,"Schüler/innen","2",null,"","student",!1,!1,"student",!1,[]),this.studentPanel.selectCallback=t=>{e.main.networkManager.sendUpdates(()=>{let i={ws_userId:t.id,userId:this.main.user.id,language:1};S("getWorkspaces",i,n=>{n.success==!0&&(e.main.workspacesOwnerId==e.main.user.id&&(e.ownWorkspaces=e.main.workspaceList.slice(),e.currentOwnWorkspace=e.main.currentWorkspace),e.main.restoreWorkspaces(n.workspaces),e.main.workspacesOwnerId=t.id,e.main.projectExplorer.setExplorerColor("rgba(255, 0, 0, 0.2"),e.main.projectExplorer.$homeAction.show(),K.showHelper("homeButtonHelper",this.main),e.main.bottomDiv.showHomeworkTab(),e.main.bottomDiv.homeworkManager.attachToWorkspaces(e.main.workspaceList)),this.main.networkManager.updateFrequencyInSeconds=this.main.networkManager.teacherUpdateFrequencyInSeconds,this.main.networkManager.secondsTillNextUpdate=this.main.networkManager.teacherUpdateFrequencyInSeconds})})}}restoreOwnWorkspaces(){let e=this.main;e.getMonacoEditor().updateOptions({readOnly:!0}),e.workspaceList=this.ownWorkspaces,e.workspacesOwnerId=e.user.id,e.projectExplorer.setExplorerColor(null),e.projectExplorer.renderWorkspaces(e.workspaceList),e.currentWorkspace==null&&e.workspaceList.length>0&&(e.currentWorkspace=e.workspaceList[0]),this.currentOwnWorkspace!=null&&e.projectExplorer.setWorkspaceActive(this.currentOwnWorkspace),e.currentWorkspace=this.currentOwnWorkspace,this.studentPanel.select(null,!1)}initClassPanel(){let e=this;this.classPanel=new ie(this.main.projectExplorer.accordion,"Klassen","1",null,"","class",!1,!1,"class",!1,[]),this.classPanel.selectCallback=t=>{e.main.networkManager.sendUpdates(()=>{let i=t;i!=null&&this.renderStudents(i.students)})}}renderStudents(e){this.studentPanel.clear(),e.sort((t,i)=>t.vidis_akronym&&i.vidis_akronym?ae(t)>ae(i)?1:-1:t.familienname>i.familienname?1:i.familienname>t.familienname?-1:t.rufname>i.rufname?1:i.rufname>t.rufname?-1:0);for(let t of e){let i={name:ae(t,!0),sortName:t.vidis_akronym?ae(t):t.familienname+" "+t.rufname,externalElement:t,isFolder:!1,path:[]};this.studentPanel.addElement(i,!0)}}renderClasses(e){this.studentPanel.clear(),e.sort((t,i)=>t.name>i.name?1:i.name>t.name?-1:0);for(let t of e){let i={name:t.name,externalElement:t,isFolder:!1,path:[]};this.classPanel.addElement(i,!0)}}}class Oi{constructor(e,t){h(this,"$buttonEditorFullscreen");h(this,"$buttonPresentationMode");h(this,"$buttonMonitorMode");h(this,"$buttonMap",{});h(this,"highContrast",!1);h(this,"editorHasFullWidth",!1);this.$buttonsContainer=e,this.main=t,this.$buttonEditorFullscreen=c('<div title="Editor in voller Breite" class="img_whole-window jo_button jo_active" style="padding: 1px; margin-right: 20px"></div>'),this.$buttonPresentationMode=c('<div title="Präsentation (Beamer)" class="img_presentation-mode jo_button jo_active" syle="padding: 1px"></div>'),this.$buttonMonitorMode=c('<div title="Monitor" class="img_monitor-mode jo_button jo_active" style="margin-left: 5px; padding: 1px"></div>'),e.append(this.$buttonEditorFullscreen,this.$buttonPresentationMode,this.$buttonMonitorMode),this.$buttonMap={presentation:this.$buttonPresentationMode,monitor:this.$buttonMonitorMode};let i=this.main.actionManager;i.registerAction("editor.fullwidth",[],()=>{this.toggleEditorFullwidth()},"Editor auf die volle Breite erweitern",this.$buttonEditorFullscreen),i.registerAction("viewmode.presentation",[],()=>{this.setMode("presentation")},"Präsentationsansicht",this.$buttonPresentationMode),i.registerAction("viewmode.monitor",[],()=>{this.setMode("monitor")},"Monitoransicht",this.$buttonMonitorMode)}toggleEditorFullwidth(){this.editorHasFullWidth?(this.$buttonEditorFullscreen.removeClass("img_whole-window-back"),this.$buttonEditorFullscreen.addClass("img_whole-window"),this.$buttonEditorFullscreen.attr("title","Editor in voller Breite"),c("#rightdiv").show(600),c("#leftpanel").show(600),c("#controls").show()):(this.$buttonEditorFullscreen.removeClass("img_whole-window"),this.$buttonEditorFullscreen.addClass("img_whole-window-back"),this.$buttonEditorFullscreen.attr("title","Editor in normaler Breite"),c("#rightdiv").hide(600),c("#leftpanel").hide(600),c("#controls").hide()),setTimeout(()=>{this.main.getMonacoEditor().layout()},800),this.editorHasFullWidth=!this.editorHasFullWidth}setMode(e,t=!0){let i=e=="presentation"?"monitor":"presentation";this.$buttonMap[e].addClass("jo_pressed"),this.$buttonMap[i].removeClass("jo_pressed");let r=this.main.user.settings.viewModes,o=r[e];r.viewModeChosen=e,this.main.themeManager.switchTheme(o.theme),this.main.editor.setFontSize(o.fontSize),this.highContrast!=o.highContrast&&(this.main.getMonacoEditor().getAction("editor.action.toggleHighContrast").run(),this.highContrast=!this.highContrast),t&&this.saveSettings()}saveFontSize(e){let t=this.getChosenViewMode();t.fontSize=e,this.saveSettings()}setTheme(e){let t=this.getChosenViewMode();t.theme=e,this.main.themeManager.switchTheme(t.theme),this.saveSettings()}toggleHighContrast(){let e=this.getChosenViewMode();e.highContrast=!e.highContrast,this.main.getMonacoEditor().getAction("editor.action.toggleHighContrast").run(),this.saveSettings()}getChosenViewMode(){let e=this.main.user.settings.viewModes;return e[e.viewModeChosen]}saveSettings(){this.main.userDataDirty=!0}initViewMode(){let e=this.main.user.settings;e.viewModes==null&&(e.viewModes={monitor:null,presentation:null,viewModeChosen:"monitor"}),e.viewModes.monitor==null&&(e.viewModes.monitor={fontSize:14,highContrast:!1,theme:"dark"},e.viewModes.presentation={fontSize:18,highContrast:!1,theme:"light"},this.saveSettings()),this.setMode(e.viewModes.viewModeChosen,!1)}}class Dt{constructor(e){h(this,"visible",!1);h(this,"fadeOutPending",!1);h(this,"$bitteWartenText");h(this,"$bitteWartenProgress");this.$waitDiv=e,e.css("display","none"),this.$bitteWartenText=e.find(".bitteWartenText"),this.$bitteWartenProgress=e.find(".bitteWartenProgress")}show(e){this.fadeOutPending=!1,this.$bitteWartenText.html(e),this.$bitteWartenProgress.html(""),this.visible||(this.visible=!0,this.$waitDiv.css("display","flex"),this.$waitDiv.hide(),this.$waitDiv.fadeIn(400))}setProgress(e){this.$bitteWartenProgress.html(e)}hide(){this.visible&&(this.fadeOutPending=!0,setTimeout(()=>{this.fadeOutPending&&(this.fadeOutPending=!1,this.$waitDiv.fadeOut(200,()=>{this.$waitDiv.css("display","none")}),this.visible=!1)},50))}}class Ai{constructor(e){h(this,"logoutAfterMinutes",20);h(this,"counterInMinutes",this.logoutAfterMinutes);let t=this;setInterval(()=>{t.counterInMinutes--,t.counterInMinutes==0&&(e?e.logout():t.logout())},60*1e3),document.body.addEventListener("keydown",()=>{t.reset()}),document.body.addEventListener("mousedown",()=>{t.reset()})}reset(){this.counterInMinutes=this.logoutAfterMinutes}logout(){S("logout",{currentWorkspaceId:null},()=>{window.location.href="index.html"})}}class Fi{constructor(){h(this,"$dialog");h(this,"$dialogMain")}init(){this.$dialog=c("#dialog"),c("#main").css("visibility","hidden"),this.$dialog.append(c('<div style="flex: 1"></div><div class="dialog-main"></div><div style="flex: 4"></div>')),this.$dialogMain=this.$dialog.find(".dialog-main"),this.$dialog.css("visibility","visible")}heading(e){let t=c('<div class="dialog-heading">'+e+"</div>");return this.$dialogMain.append(t),t}description(e,t){let i=t==null?"":`style="color: ${t}"`,n=c(`<div class="dialog-description" ${i}>${e}</div>`);return this.$dialogMain.append(n),n}input(e,t){let i=c(`<input class="dialog-input" type="${e}" placeholder="${t}"></input>`);return this.$dialogMain.append(i),i}buttons(e){let t=c('<div class="dialog-buttonRow"></div>');this.$dialogMain.append(t);for(let i of e){let n=c(`<button style="background-color: ${i.color};margin-left: 20px">${i.caption}</button>`);n.on("click",()=>{i.callback()}),t.append(n)}}waitMessage(e){let t=c(`<div class="dialog-wait">${e}<img src="assets/graphics/ball-triangle.svg"></div>`);return this.$dialogMain.append(t),i=>{let n=i?"visible":"hidden";t.css("visibility",n)}}close(){this.$dialog.css("visibility","hidden"),this.$dialog.empty(),c("#main").css("visibility","visible")}}class Ni{constructor(e){this.main=e}init(){let e=c("#buttonUserSettings"),t=this;e.on("click",i=>{R([{caption:"Passwort ändern...",callback:()=>{new Wi(t.main).show()}}],e.offset().left,e.offset().top+e.height())})}}class Wi{constructor(e){h(this,"dialog");this.main=e,this.dialog=new Fi}show(){this.dialog.init(),this.dialog.heading("Passwort ändern"),this.dialog.description("Bitte geben Sie Ihr bisheriges Passwort und darunter zweimal Ihr neues Passwort ein. <br>Das Passwort muss mindestens 8 Zeichen lang sein und sowohl Buchstaben als auch Zahlen oder Sonderzeichen enthalten.");let e=this.dialog.input("password","Altes Passwort"),t=this.dialog.input("password","Neues Passwort"),i=this.dialog.input("password","Neues Passwort wiederholen"),n=this.dialog.description("","red"),r=this.dialog.waitMessage("Bitte warten...");this.dialog.buttons([{caption:"Abbrechen",color:"#a00000",callback:()=>{this.dialog.close()}},{caption:"OK",color:"green",callback:()=>{t.val()!=i.val()?n.text("Die zwei eingegebenen neuen Passwörter stimmen nicht überein."):(r(!0),S("changePassword",{oldPassword:e.val(),newPassword:t.val()},()=>{r(!1),alert("Das Passwort wurde erfolgreich geändert."),this.dialog.close()},o=>{r(!1),n.text(o)}))}}])}}class Ri{constructor(e){h(this,"loggedInWithVidis",!1);this.main=e,new Ai(this)}loginWithVidis(e){this.loggedInWithVidis=!0,c("#login").hide(),c("#main").css("visibility","visible"),c("#bitteWartenText").html("Bitte warten ..."),c("#bitteWarten").css("display","flex"),this.sendLoginRequest(e)}initGUI(){let e=c("#login-spinner>img");c("#login-username").focus(),c("#login-username").on("keydown",i=>{i.key=="Enter"&&c("#login-password").focus()}),c("#login-password").on("keydown",i=>{i.key=="Enter"&&c("#login-button").trigger("click")}),c("#login-password").on("keydown",i=>{i.key=="Tab"&&(i.preventDefault(),c("#login-button").focus(),c("#login-button").addClass("jo_active")),i.key=="Enter"&&c("#login-button").trigger("click")}),c("#login-button").on("keydown",i=>{i.key=="Tab"?(i.preventDefault(),c("#login-username").focus(),c("#login-button").removeClass("jo_active")):c("#login-button").trigger("click")});let t=!1;c("#login-button").on("click",()=>{e.show(),!t&&(t=!0,setTimeout(()=>{t=!1},1e3),this.sendLoginRequest())}),c("#buttonLogout").on("click",()=>{this.logout()})}logout(){this.main.waitOverlay.show("Bitte warten, der letzte Bearbeitungsstand wird noch gespeichert ..."),this.main.workspacesOwnerId!=this.main.user.id&&this.main.projectExplorer.onHomeButtonClicked(),N.getInstance().close(),this.main.networkManager.sendUpdates(()=>{var t;this.main.notifier.connect(null);let e={currentWorkspaceId:(t=this.main.currentWorkspace)==null?void 0:t.id};this.main.networkManager.sendUpdateUserSettings(()=>{S("logout",e,()=>{this.loggedInWithVidis?window.location.assign("https://aai.vidis.schule/auth/realms/vidis/protocol/openid-connect/logout?ID_TOKEN_HINT="+this.main.user.vidis_sub+"&post_logout_redirect_uri=https%3A%2F%2Fwww.sql-ide.de"):(c("#login").show(),this.main.waitOverlay.hide(),c("#login-message").empty(),this.main.getMonacoEditor().setModel(x.createModel("","myJava")),this.main.projectExplorer.fileListPanel.clear(),this.main.projectExplorer.workspaceListPanel.clear(),this.main.databaseExplorer.clear(),this.main.resultsetPresenter.clear(),this.main.user.is_teacher&&(this.main.teacherExplorer.removePanels(),this.main.teacherExplorer=null),this.main.currentWorkspace=null,this.main.user=null)})})},!0)}sendLoginRequest(e){let t=this,i=c("#login-spinner>img");i.show();let n={username:c("#login-username").val(),password:c("#login-password").val(),language:1};S("login"+(e?"?singleUseToken="+e:""),n,r=>{if(!r.success)c("#login-message").html("Fehler: Benutzername und/oder Passwort ist falsch.");else{N.getInstance().open(),c("#login").hide(),this.main.waitOverlay.show("Bitte warten...");let o=r.user;(o.settings==null||o.settings.helperHistory==null)&&(o.settings={helperHistory:{},viewModes:null,classDiagram:null}),this.main.waitForGUICallback=()=>{let l=r.user;t.main.mainMenu.initGUI(l),t.main.waitOverlay.hide(),i.hide(),c("#menupanel-username").html(ae(l)),new Ni(t.main).init(),l.is_teacher&&t.main.initTeacherExplorer(r.classdata),t.main.user=l,t.main.restoreWorkspaces(r.workspaces),t.main.workspacesOwnerId=l.id,t.main.networkManager.initializeTimer(),t.main.projectExplorer.fileListPanel.setFixed(!l.is_teacher),t.main.projectExplorer.workspaceListPanel.setFixed(!l.is_teacher),t.main.viewModeController.initViewMode(),t.main.bottomDiv.hideHomeworkTab(),t.main.networkManager.initializeSSE()},this.main.startupComplete==0&&(this.main.waitForGUICallback(),this.main.waitForGUICallback=null)}},r=>{c("#login-message").html("Login gescheitert: "+r),c("#login-spinner>img").hide()})}}class qi{constructor(e){h(this,"workspace");h(this,"database");this.main=e}async connect(e){if(this.workspace!=null){let i={workspaceId:this.workspace.id,registerOrUnregister:"unregister"};await ge("servlet/registerPushClientForDatabase",i)}if(this.workspace=e,e==null){N.unsubscribe("onOpen");return}this.database=e.database;let t={workspaceId:e.id,registerOrUnregister:"register"};ge("servlet/registerPushClientForDatabase",t),N.subscribe("broadcastDatabaseChange",i=>{i.databaseId==this.workspace.databaseId?i.rollbackToVersion!=null?this.main.getHistoryViewer().rollbackLocal(i.rollbackToVersion):this.executeNewStatements(i.newStatements,i.firstNewStatementIndex,()=>{this.getNewStatementsHttp()}):(t.registerOrUnregister="unregister",ge("servlet/registerPushClientForDatabase",t),N.unsubscribe("onOpen"))}),N.subscribe("onOpen",()=>{t.registerOrUnregister="register",ge("servlet/registerPushClientForDatabase",t)})}executeNewStatements(e,t,i,n=()=>{},r=!0){if(this.database==null)return;let o=this,l=t-(this.database.version+1);if(l>0){i(),n();return}else{l<0&&(e.splice(0,-l),t-=l);let d=e;d.length>0?this.main.resultsetPresenter.executeStatementsString(d,0,()=>{o.main.getHistoryViewer().appendStatements(d),o.database.statements=o.database.statements.concat(d),o.database.version=t+e.length-1,r&&o.main.databaseExplorer.refresh(),n()}):n()}}getNewStatementsHttp(){let e=this;if(this.workspace==null||this.database==null)return;let t={workspaceId:this.workspace.id,version_before:this.workspace.database.version};S("getNewStatements",t,i=>{i.rollbackToVersion!=null?e.main.getHistoryViewer().rollbackLocal(i.rollbackToVersion):e.executeNewStatements(i.newStatements,i.firstNewStatementIndex,()=>{e.getNewStatementsHttp()})})}}function tt(a,e,t){var i="";if(t){var n=new Date;n.setTime(n.getTime()+t*1e3),i="; expires="+n.toUTCString()}document.cookie=a+"="+(e||"")+i+"; path=/"}class Se{constructor(){h(this,"workspaceList",[]);h(this,"workspacesOwnerId");h(this,"editor");h(this,"currentWorkspace");h(this,"projectExplorer");h(this,"teacherExplorer");h(this,"networkManager");h(this,"actionManager");h(this,"mainMenu");h(this,"login");h(this,"compiler");h(this,"semicolonAngel");h(this,"bottomDiv");h(this,"startupComplete",2);h(this,"waitForGUICallback");h(this,"version",0);h(this,"timerHandle");h(this,"user");h(this,"userDataDirty",!1);h(this,"themeManager");h(this,"rightDiv");h(this,"viewModeController");h(this,"databaseTool");h(this,"databaseExplorer");h(this,"resultsetPresenter");h(this,"notifier");h(this,"waitOverlay",new Dt(c(".bitteWarten")));h(this,"historyViewer",new yt(this,c(".jo_historyTab")))}isEmbedded(){return!1}getCurrentWorkspace(){return this.currentWorkspace}getMonacoEditor(){return this.editor.editor}getRightDiv(){return this.rightDiv}getBottomDiv(){return this.bottomDiv}getCurrentlyEditedModule(){return this.projectExplorer.getCurrentlyEditedModule()}getActionManager(){return this.actionManager}getCompiler(){return this.compiler}setModuleActive(e){this.projectExplorer.setModuleActive(e)}getSemicolonAngel(){return this.semicolonAngel}getDatabaseTool(){return this.databaseTool}getDatabaseExplorer(){return this.databaseExplorer}getResultsetPresenter(){return this.resultsetPresenter}getWaitOverlay(){return this.waitOverlay}getHistoryViewer(){return this.historyViewer}initGUI(){mi(),this.login=new Ri(this);let e=location.search.split("singleUseToken=")[1];e&&tt("singleUseToken",e,3);let t=pi("singleUseToken");t?(tt("singleUseToken","",0),this.login.initGUI(),this.login.loginWithVidis(t)):this.login.initGUI(),this.databaseTool=new W(this),this.databaseExplorer=new kt(this,c(".jo_db_tree")),this.actionManager=new ft(null,this),this.actionManager.init(),this.networkManager=new vi(this,c("#bottomdiv-outer .jo_updateTimerDiv")),new Ii(this).initSliders(),this.mainMenu=new Pi(this),this.projectExplorer=new $i(this,c("#leftpanel>.jo_projectexplorer")),this.projectExplorer.initGUI(),this.bottomDiv=new _t(this,c("#bottomdiv-outer>.jo_bottomdiv-inner"),c("body")),this.rightDiv=new Et(this,c("#rightdiv-inner")),this.rightDiv.initGUI(),this.checkStartupComplete(),this.themeManager=new rt,this.viewModeController=new Oi(c("#view-mode"),this),this.semicolonAngel=new mt(this),new St(this,c("#controls")),this.resultsetPresenter=new He(this,c(".jo_bottomdiv-inner")),this.notifier=new qi(this)}initEditor(){this.editor=new vt(this,!0,!1),new nt().init(),this.editor.initGUI(c("#editor"));let e=this;c(window).on("resize",t=>{c("#bottomdiv-outer").css("height","450px"),c("#editor").css("height",window.innerHeight-450-30-2+"px"),e.editor.editor.layout(),c("#editor").css("height","")}),c(window).trigger("resize"),this.checkStartupComplete()}initTeacherExplorer(e){this.teacherExplorer=new Bi(this,e),this.teacherExplorer.initGUI()}checkStartupComplete(){this.startupComplete--,this.startupComplete==0&&this.start()}start(){this.waitForGUICallback!=null&&this.waitForGUICallback();let e=this;setTimeout(()=>{e.getMonacoEditor().layout()},200),this.compiler=new ct(this),this.startTimer(),c(window).on("unload",function(){navigator.sendBeacon&&e.user!=null&&(e.networkManager.sendUpdates(null,!1),e.networkManager.sendUpdateUserSettings(()=>{}))})}startTimer(){this.timerHandle!=null&&clearInterval(this.timerHandle);let e=this;this.timerHandle=setInterval(()=>{e.compileIfDirty()},500)}compileIfDirty(){var e,t;if(this.currentWorkspace!=null&&this.currentWorkspace.moduleStore.isDirty()&&this.compiler.compilerStatus!=fe.compiling)try{this.compiler.compile(this.currentWorkspace.moduleStore);let i=(t=(e=this.bottomDiv)==null?void 0:e.errorManager)==null?void 0:t.showErrors(this.currentWorkspace);this.projectExplorer.renderErrorCount(this.currentWorkspace,i),this.editor.onDidChangeCursorPosition(null),this.projectExplorer&&this.version++}catch(i){console.error(i),this.compiler.compilerStatus=fe.error}}removeWorkspace(e){this.workspaceList.splice(this.workspaceList.indexOf(e),1)}restoreWorkspaces(e){this.workspaceList=[],this.currentWorkspace=null,this.getMonacoEditor().updateOptions({readOnly:!0});let t=null;for(let i of e.workspaces){let n=te.restoreFromData(i,this);this.workspaceList.push(n),i.id==this.user.currentWorkspace_id&&!i.isFolder&&(t=n)}if(this.projectExplorer.renderWorkspaces(this.workspaceList),t==null&&this.workspaceList.length>0){for(let i of this.workspaceList)if(!i.isFolder){t=this.workspaceList[0];break}}t!=null&&this.projectExplorer.setWorkspaceActive(t,null,!0),this.workspaceList.length==0&&K.showHelper("newDatabaseHelper",this,this.projectExplorer.workspaceListPanel.$captionElement)}createNewWorkspace(e,t){return new te(e,this,t)}}class zi{constructor(e,t,i){h(this,"oldDecorations",[]);h(this,"oldErrorDecorations",[]);h(this,"$errorDiv");h(this,"minimapColor",{});h(this,"lightBulbOnClickFunctionList",[]);this.main=e,this.$bottomDiv=t,this.$mainDiv=i,this.minimapColor.error="#bc1616",this.minimapColor.warning="#cca700",this.minimapColor.info="#75beff";let n=this;i.find(".jo_pw_undo").on("click",()=>{n.main.getMonacoEditor().trigger(".","undo",{})}).attr("title","Undo")}showErrors(e){this.main.getResultsetPresenter().showErrorDecorations([]),this.lightBulbOnClickFunctionList=[];let t=new Map;this.$errorDiv=this.$bottomDiv.find(".jo_tabs>.jo_errorsTab"),this.$errorDiv.empty();let i=!1,n=e.moduleStore;this.main.getMonacoEditor();for(let r of n.getModules(!1)){let o=[],l=[],d=[],u=r.getSortedAndFilteredErrors();t.set(r,r.getErrorCount());for(let m of u){let f,p=this.minimapColor[m.level];switch(m.level){case"error":f="jo_revealErrorLine";break;case"warning":f="jo_revealWarningLine";break;case"info":f="jo_revealInfoLine";break}this.processError(m,r,d);let b;switch(m.level){case"error":b=ee.Error;break;case"warning":b=ee.Warning;break;case"info":b=ee.Info;break}o.push({startLineNumber:m.position.line,startColumn:m.position.column,endLineNumber:m.position.line,endColumn:m.position.column+m.position.length,message:m.text,severity:b,relatedInformation:m.quickFix}),l.push({range:{startLineNumber:m.position.line,startColumn:m.position.column,endLineNumber:m.position.line,endColumn:m.position.column+m.position.length},options:{linesDecorationsClassName:f,minimap:{position:x.MinimapPosition.Inline,color:p}}})}if(x.setModelMarkers(r.model,"test",o),r.oldErrorDecorations=r.model.deltaDecorations(r.oldErrorDecorations,l),this.oldDecorations=this.main.getMonacoEditor().deltaDecorations(this.oldDecorations,[]),d.length>0&&this.$errorDiv.length>0){i=!0;let m=c('<div class="jo_error-filename">'+r.file.name+"&nbsp;</div>");this.$errorDiv.append(m);for(let f of d)this.$errorDiv.append(f)}}return!i&&this.$errorDiv.length>0&&this.$errorDiv.append(c('<div class="jo_noErrorMessage">Keine Fehler gefunden :-)</div>')),this.registerLightbulbOnClickFunctions(),t}registerLightbulbOnClickFunctions(){let e=this;setTimeout(()=>{for(let t of e.lightBulbOnClickFunctionList)c(t.class).off("click",t.onClickFunction),c(t.class).on("click",t.onClickFunction).attr("title",t.title)},500)}processError(e,t,i){let n=c('<div class="jo_error-line"></div>'),r=c('<span class="jo_error-position">[Z&nbsp;<span class="jo_linecolumn">'+e.position.line+'</span> Sp&nbsp;<span class="jo_linecolumn">'+e.position.column+"</span>]</span>:&nbsp;"),o="";switch(e.level){case"error":break;case"warning":o='<span class="jo_warning_category">Warnung: </span>';break;case"info":o='<span class="jo_info_category">Info: </span>';break}let l=c('<div class="jo_error-text">'+o+e.text+"</div>");n.append(r).append(l);let d=this;n.on("mousedown",u=>{this.$errorDiv.find(".jo_error-line").removeClass("jo_active"),n.addClass("jo_active"),d.showError(t,e)}),i.push(n)}showError(e,t){this.main instanceof Se&&e!=this.main.projectExplorer.getCurrentlyEditedModule()&&this.main.projectExplorer.setModuleActive(e);let i=t.position,n={startColumn:i.column,startLineNumber:i.line,endColumn:i.column+i.length,endLineNumber:i.line};this.main.getMonacoEditor().revealRangeInCenter(n);let r="";switch(t.level){case"error":r="jo_revealError";break;case"warning":r="jo_revealWarning";break;case"info":r="jo_revealInfo";break}this.oldDecorations=this.main.getMonacoEditor().deltaDecorations(this.oldDecorations,[{range:n,options:{className:r}}])}}class Ui{constructor(e,t){h(this,"$homeworkTab");h(this,"$homeworkTabLeft");h(this,"$homeworkTabRight");h(this,"$showRevisionButton");h(this,"showRevisionActive",!1);h(this,"diffEditor");this.main=e,this.$bottomDiv=t,this.$homeworkTab=t.find(".jo_tabs>.jo_homeworkTab")}initGUI(){let e=this;this.$homeworkTab.append(this.$homeworkTabLeft=Y("","jo_homeworkTabLeft jo_scrollable")),this.$homeworkTab.append(this.$homeworkTabRight=Y("","jo_homeworkTabRight jo_scrollable")),c("#view-mode").prepend(this.$showRevisionButton=Y("","jo_button jo_active jo_homeworkRevisionButton","")),this.$showRevisionButton.on("click",()=>{this.showRevisionActive?this.hideRevision():this.showRevision(e.main.getCurrentlyEditedModule())}),this.$showRevisionButton.hide(),c("#diffEditor").hide()}showHomeWorkRevisionButton(){this.$showRevisionButton.text(this.showRevisionActive?"Normalansicht":"Korrekturen zeigen"),this.$showRevisionButton.show()}hideHomeworkRevisionButton(){this.$showRevisionButton.hide()}showRevision(e){e.file.text=e.getProgramTextFromMonacoModel();let t=e.file;c("#editor").hide(),c("#diffEditor").show();var i=x.createModel(t.text_before_revision,"myJava"),n=x.createModel(t.text,"myJava");this.diffEditor=x.createDiffEditor(document.getElementById("diffEditor"),{enableSplitViewResizing:!0,originalEditable:!1,readOnly:!0,renderSideBySide:!0}),this.diffEditor.setModel({original:i,modified:n}),this.showRevisionActive=!0,this.showHomeWorkRevisionButton()}hideRevision(){this.showRevisionActive&&(c("#diffEditor").hide(),this.diffEditor.dispose(),this.diffEditor=null,c("#editor").show(),this.showRevisionActive=!1,this.showHomeWorkRevisionButton())}attachToWorkspaces(e){let t=[],i={};e.forEach(o=>{o.moduleStore.getModules(!1).forEach(l=>{let d=l.file.submitted_date;if(d!=null){let u=ai(d),m=oi(u),f=i[m];f==null&&(f={date:u,day:m,modules:[]},i[m]=f,t.push(f)),f.modules.push({module:l,workspace:o})}})}),this.$homeworkTabLeft.empty(),this.$homeworkTabRight.empty();let n=this;this.$homeworkTabLeft.append(Y("","jo_homeworkHeading","Abgabetage:")),t.sort((o,l)=>o.date.getFullYear()!=l.date.getFullYear()?-Math.sign(o.date.getFullYear()-l.date.getFullYear()):o.date.getMonth()!=l.date.getMonth()?-Math.sign(o.date.getMonth()-l.date.getMonth()):o.date.getDate()!=l.date.getDate()?-Math.sign(o.date.getDate()-l.date.getDate()):0);let r=!0;t.forEach(o=>{o.modules.sort((d,u)=>d.module.file.name.localeCompare(u.module.file.name));let l=Y("","jo_homeworkDate",o.day);this.$homeworkTabLeft.append(l),l.on("click",d=>{this.$homeworkTabLeft.find(".jo_homeworkDate").removeClass("active"),l.addClass("jo_active"),n.select(o)}),r&&(r=!1,l.addClass("jo_active"),n.select(o))})}select(e){this.$homeworkTabRight.empty(),this.$homeworkTabRight.append(Y("","jo_homeworkHeading","Abgegebene Dateien:"));let t=this;e.modules.forEach(i=>{let n=c(`<div class="jo_homeworkEntry">Workspace <span class="jo_homework-workspace">
213
+ `);class _t{constructor(e,t){h(this,"isWholePage",!1);h(this,"$tabs");h(this,"$headings");this.main=e,this.$rightDiv=t,this.$tabs=t.find(".jo_tabs"),this.$headings=t.find(".jo_tabheadings"),this.$headings.find(".jo_classDiagramTabHeading").length>0,this.$headings.find(".jo_objectDiagramTabHeading").length>0;let i=this,n="100%";t.find(".jo_whole-window").on("click",()=>{i.isWholePage=!i.isWholePage;let r=c(".jo_whole-window");i.isWholePage?(c("#code").css("display","none"),n=c("#rightdiv").css("width"),c("#rightdiv").css("width","100%"),r.removeClass("img_whole-window"),r.addClass("img_whole-window-back"),c(".jo_control-container").append(c("#controls")),r.attr("title","Auf normale Größe zurückführen"),c(".jo_graphics").trigger("sizeChanged")):(c("#code").css("display","flex"),c("#rightdiv").css("width",n),r.removeClass("img_whole-window-back"),r.addClass("img_whole-window"),c("#controls").insertAfter(c("#view-mode")),r.attr("title","Auf Fenstergröße vergrößern"),c(".jo_graphics").trigger("sizeChanged"))})}initGUI(){Le(this.$rightDiv)}}class Ii{constructor(e){h(this,"main");this.main=e}initSliders(){let e=this,t=window.PointerEvent?"pointer":"mouse";c("#slider1").on(t+"down",r=>{let o=r.clientX;c(document).on(t+"move.slider1",l=>{let d=l.clientX-o;e.moveLeftPanel(d),o=l.clientX}),c(document).on(t+"up.slider1",()=>{c(document).off(t+"move.slider1"),c(document).off(t+"up.slider1")})}),c("#slider2").on(t+"down",r=>{let o=r.clientY;c(document).on(t+"move.slider2",l=>{let d=l.clientY-o;e.moveBottomDiv(d),o=l.clientY}),c(document).on(t+"up.slider2",()=>{c(document).off(t+"move.slider2"),c(document).off(t+"up.slider2")})}),c("#slider3").on(t+"down",r=>{let o=r.clientX;c(document).on(t+"move.slider3",l=>{let d=l.clientX-o;e.moveRightDiv(d),o=l.clientX,l.stopPropagation()}),c(document).on(t+"up.slider3",()=>{c(document).off(t+"move.slider3"),c(document).off(t+"up.slider3")})});let i=c('<div class="jo_sliderknob img_knob jo_button jo_active" style="left: -8px" draggable="false"></div>');c("#slider2").append(i),i.on(t+"down",r=>{let o=r.clientY,l=r.clientX;r.stopImmediatePropagation(),c(document).on(t+"move.knobleft",d=>{let u=d.clientY-o,m=d.clientX-l;d.stopImmediatePropagation(),e.moveLeftPanel(m),e.moveBottomDiv(u),l+=m,o+=u}),c(document).on(t+"up.knobleft",()=>{c(document).off(t+"move.knobleft"),c(document).off(t+"up.knobleft")})});let n=c('<div class="jo_sliderknob img_knob jo_button jo_active" style="right: -8px" draggable="false"></div>');c("#slider2").append(n),n.on(t+"down",r=>{let o=r.clientY,l=r.clientX;r.stopImmediatePropagation(),c(document).on(t+"move.knobright",d=>{let u=d.clientY-o,m=d.clientX-l;d.stopImmediatePropagation(),e.moveRightDiv(m),e.moveBottomDiv(u),l+=m,o+=u}),c(document).on(t+"up.knobright",()=>{c(document).off(t+"move.knobright"),c(document).off(t+"up.knobright")})})}moveRightDiv(e){let t=c("#editor>.monaco-editor"),i=c("#rightdiv"),n=Number.parseInt(i.css("width").replace("px",""));i.css("width",n-e+"px");let r=Number.parseInt(t.css("width").replace("px",""));t.css("width",r+e+"px"),this.main.getMonacoEditor().layout(),this.main.bottomDiv.homeworkManager.diffEditor!=null&&this.main.bottomDiv.homeworkManager.diffEditor.layout(),c(".jo_graphics").trigger("sizeChanged"),n+=e}moveBottomDiv(e){let t=c("#editor>.monaco-editor"),i=c("#bottomdiv-outer"),n=Number.parseInt(i.css("height").replace("px",""));i.css("height",n-e+"px");let r=Number.parseInt(t.css("height").replace("px",""));t.css("height",r+e+"px"),this.main.getMonacoEditor().layout(),this.main.bottomDiv.homeworkManager.diffEditor!=null&&this.main.bottomDiv.homeworkManager.diffEditor.layout()}moveLeftPanel(e){let t=c("#leftpanel"),i=c("#editor>.monaco-editor"),n=Number.parseInt(t.css("width").replace("px",""));t.css("width",n+e+"px");let r=Number.parseInt(i.css("width").replace("px",""));i.css("width",r-e+"px"),this.main.getMonacoEditor().layout(),this.main.bottomDiv.homeworkManager.diffEditor!=null&&this.main.bottomDiv.homeworkManager.diffEditor.layout()}}function le(a,e=!1){var t,i;return a.vidis_akronym?a.username&&a.username.length>0?a.username:a.vidis_akronym:((t=a.familienname)==null?void 0:t.length)>0&&((i=a.rufname)==null?void 0:i.length)>0?e?a.familienname+", "+a.rufname:a.rufname+" "+a.familienname:a.username}class Bi{constructor(e,t){h(this,"studentPanel");h(this,"classPanel");h(this,"ownWorkspaces");h(this,"currentOwnWorkspace");this.main=e,this.classData=t}removePanels(){this.classPanel.remove(),this.studentPanel.remove()}initGUI(){this.initStudentPanel(),this.initClassPanel(),this.renderClasses(this.classData)}initStudentPanel(){let e=this;this.studentPanel=new ne(this.main.projectExplorer.accordion,"Schüler/innen","2",null,"","student",!1,!1,"student",!1,[]),this.studentPanel.selectCallback=t=>{e.main.networkManager.sendUpdates(()=>{let i={ws_userId:t.id,userId:this.main.user.id,language:1};D("getWorkspaces",i,n=>{n.success==!0&&(e.main.workspacesOwnerId==e.main.user.id&&(e.ownWorkspaces=e.main.workspaceList.slice(),e.currentOwnWorkspace=e.main.currentWorkspace),e.main.restoreWorkspaces(n.workspaces),e.main.workspacesOwnerId=t.id,e.main.projectExplorer.setExplorerColor("rgba(255, 0, 0, 0.2"),e.main.projectExplorer.$homeAction.show(),K.showHelper("homeButtonHelper",this.main),e.main.bottomDiv.showHomeworkTab(),e.main.bottomDiv.homeworkManager.attachToWorkspaces(e.main.workspaceList)),this.main.networkManager.updateFrequencyInSeconds=this.main.networkManager.teacherUpdateFrequencyInSeconds,this.main.networkManager.secondsTillNextUpdate=this.main.networkManager.teacherUpdateFrequencyInSeconds})})}}restoreOwnWorkspaces(){let e=this.main;e.getMonacoEditor().updateOptions({readOnly:!0}),e.workspaceList=this.ownWorkspaces,e.workspacesOwnerId=e.user.id,e.projectExplorer.setExplorerColor(null),e.projectExplorer.renderWorkspaces(e.workspaceList),e.currentWorkspace==null&&e.workspaceList.length>0&&(e.currentWorkspace=e.workspaceList[0]),this.currentOwnWorkspace!=null&&e.projectExplorer.setWorkspaceActive(this.currentOwnWorkspace),e.currentWorkspace=this.currentOwnWorkspace,this.studentPanel.select(null,!1)}initClassPanel(){let e=this;this.classPanel=new ne(this.main.projectExplorer.accordion,"Klassen","1",null,"","class",!1,!1,"class",!1,[]),this.classPanel.selectCallback=t=>{e.main.networkManager.sendUpdates(()=>{let i=t;i!=null&&this.renderStudents(i.students)})}}renderStudents(e){this.studentPanel.clear(),e.sort((t,i)=>t.vidis_akronym&&i.vidis_akronym?le(t)>le(i)?1:-1:t.familienname>i.familienname?1:i.familienname>t.familienname?-1:t.rufname>i.rufname?1:i.rufname>t.rufname?-1:0);for(let t of e){let i={name:le(t,!0),sortName:t.vidis_akronym?le(t):t.familienname+" "+t.rufname,externalElement:t,isFolder:!1,path:[]};this.studentPanel.addElement(i,!0)}}renderClasses(e){this.studentPanel.clear(),e.sort((t,i)=>t.name>i.name?1:i.name>t.name?-1:0);for(let t of e){let i={name:t.name,externalElement:t,isFolder:!1,path:[]};this.classPanel.addElement(i,!0)}}}class Oi{constructor(e,t){h(this,"$buttonEditorFullscreen");h(this,"$buttonPresentationMode");h(this,"$buttonMonitorMode");h(this,"$buttonMap",{});h(this,"highContrast",!1);h(this,"editorHasFullWidth",!1);this.$buttonsContainer=e,this.main=t,this.$buttonEditorFullscreen=c('<div title="Editor in voller Breite" class="img_whole-window jo_button jo_active" style="padding: 1px; margin-right: 20px"></div>'),this.$buttonPresentationMode=c('<div title="Präsentation (Beamer)" class="img_presentation-mode jo_button jo_active" syle="padding: 1px"></div>'),this.$buttonMonitorMode=c('<div title="Monitor" class="img_monitor-mode jo_button jo_active" style="margin-left: 5px; padding: 1px"></div>'),e.append(this.$buttonEditorFullscreen,this.$buttonPresentationMode,this.$buttonMonitorMode),this.$buttonMap={presentation:this.$buttonPresentationMode,monitor:this.$buttonMonitorMode};let i=this.main.actionManager;i.registerAction("editor.fullwidth",[],()=>{this.toggleEditorFullwidth()},"Editor auf die volle Breite erweitern",this.$buttonEditorFullscreen),i.registerAction("viewmode.presentation",[],()=>{this.setMode("presentation")},"Präsentationsansicht",this.$buttonPresentationMode),i.registerAction("viewmode.monitor",[],()=>{this.setMode("monitor")},"Monitoransicht",this.$buttonMonitorMode)}toggleEditorFullwidth(){this.editorHasFullWidth?(this.$buttonEditorFullscreen.removeClass("img_whole-window-back"),this.$buttonEditorFullscreen.addClass("img_whole-window"),this.$buttonEditorFullscreen.attr("title","Editor in voller Breite"),c("#rightdiv").show(600),c("#leftpanel").show(600),c("#controls").show()):(this.$buttonEditorFullscreen.removeClass("img_whole-window"),this.$buttonEditorFullscreen.addClass("img_whole-window-back"),this.$buttonEditorFullscreen.attr("title","Editor in normaler Breite"),c("#rightdiv").hide(600),c("#leftpanel").hide(600),c("#controls").hide()),setTimeout(()=>{this.main.getMonacoEditor().layout()},800),this.editorHasFullWidth=!this.editorHasFullWidth}setMode(e,t=!0){let i=e=="presentation"?"monitor":"presentation";this.$buttonMap[e].addClass("jo_pressed"),this.$buttonMap[i].removeClass("jo_pressed");let r=this.main.user.settings.viewModes,o=r[e];r.viewModeChosen=e,this.main.themeManager.switchTheme(o.theme),this.main.editor.setFontSize(o.fontSize),this.highContrast!=o.highContrast&&(this.main.getMonacoEditor().getAction("editor.action.toggleHighContrast").run(),this.highContrast=!this.highContrast),t&&this.saveSettings()}saveFontSize(e){let t=this.getChosenViewMode();t.fontSize=e,this.saveSettings()}setTheme(e){let t=this.getChosenViewMode();t.theme=e,this.main.themeManager.switchTheme(t.theme),this.saveSettings()}toggleHighContrast(){let e=this.getChosenViewMode();e.highContrast=!e.highContrast,this.main.getMonacoEditor().getAction("editor.action.toggleHighContrast").run(),this.saveSettings()}getChosenViewMode(){let e=this.main.user.settings.viewModes;return e[e.viewModeChosen]}saveSettings(){this.main.userDataDirty=!0}initViewMode(){let e=this.main.user.settings;e.viewModes==null&&(e.viewModes={monitor:null,presentation:null,viewModeChosen:"monitor"}),e.viewModes.monitor==null&&(e.viewModes.monitor={fontSize:14,highContrast:!1,theme:"dark"},e.viewModes.presentation={fontSize:18,highContrast:!1,theme:"light"},this.saveSettings()),this.setMode(e.viewModes.viewModeChosen,!1)}}class Tt{constructor(e){h(this,"visible",!1);h(this,"fadeOutPending",!1);h(this,"$bitteWartenText");h(this,"$bitteWartenProgress");this.$waitDiv=e,e.css("display","none"),this.$bitteWartenText=e.find(".bitteWartenText"),this.$bitteWartenProgress=e.find(".bitteWartenProgress")}show(e){this.fadeOutPending=!1,this.$bitteWartenText.html(e),this.$bitteWartenProgress.html(""),this.visible||(this.visible=!0,this.$waitDiv.css("display","flex"),this.$waitDiv.hide(),this.$waitDiv.fadeIn(400))}setProgress(e){this.$bitteWartenProgress.html(e)}hide(){this.visible&&(this.fadeOutPending=!0,setTimeout(()=>{this.fadeOutPending&&(this.fadeOutPending=!1,this.$waitDiv.fadeOut(200,()=>{this.$waitDiv.css("display","none")}),this.visible=!1)},50))}}class Ai{constructor(e){h(this,"logoutAfterMinutes",20);h(this,"counterInMinutes",this.logoutAfterMinutes);let t=this;setInterval(()=>{t.counterInMinutes--,t.counterInMinutes==0&&(e?e.logout():t.logout())},60*1e3),document.body.addEventListener("keydown",()=>{t.reset()}),document.body.addEventListener("mousedown",()=>{t.reset()})}reset(){this.counterInMinutes=this.logoutAfterMinutes}logout(){D("logout",{currentWorkspaceId:null},()=>{window.location.href="index.html"})}}class Fi{constructor(){h(this,"$dialog");h(this,"$dialogMain")}init(){this.$dialog=c("#dialog"),c("#main").css("visibility","hidden"),this.$dialog.append(c('<div style="flex: 1"></div><div class="dialog-main"></div><div style="flex: 4"></div>')),this.$dialogMain=this.$dialog.find(".dialog-main"),this.$dialog.css("visibility","visible")}heading(e){let t=c('<div class="dialog-heading">'+e+"</div>");return this.$dialogMain.append(t),t}description(e,t){let i=t==null?"":`style="color: ${t}"`,n=c(`<div class="dialog-description" ${i}>${e}</div>`);return this.$dialogMain.append(n),n}input(e,t){let i=c(`<input class="dialog-input" type="${e}" placeholder="${t}"></input>`);return this.$dialogMain.append(i),i}buttons(e){let t=c('<div class="dialog-buttonRow"></div>');this.$dialogMain.append(t);for(let i of e){let n=c(`<button style="background-color: ${i.color};margin-left: 20px">${i.caption}</button>`);n.on("click",()=>{i.callback()}),t.append(n)}}waitMessage(e){let t=c(`<div class="dialog-wait">${e}<img src="assets/graphics/ball-triangle.svg"></div>`);return this.$dialogMain.append(t),i=>{let n=i?"visible":"hidden";t.css("visibility",n)}}close(){this.$dialog.css("visibility","hidden"),this.$dialog.empty(),c("#main").css("visibility","visible")}}class Ni{constructor(e){this.main=e}init(){let e=c("#buttonUserSettings"),t=this;e.on("click",i=>{R([{caption:"Passwort ändern...",callback:()=>{new Wi(t.main).show()}}],e.offset().left,e.offset().top+e.height())})}}class Wi{constructor(e){h(this,"dialog");this.main=e,this.dialog=new Fi}show(){this.dialog.init(),this.dialog.heading("Passwort ändern"),this.dialog.description("Bitte geben Sie Ihr bisheriges Passwort und darunter zweimal Ihr neues Passwort ein. <br>Das Passwort muss mindestens 8 Zeichen lang sein und sowohl Buchstaben als auch Zahlen oder Sonderzeichen enthalten.");let e=this.dialog.input("password","Altes Passwort"),t=this.dialog.input("password","Neues Passwort"),i=this.dialog.input("password","Neues Passwort wiederholen"),n=this.dialog.description("","red"),r=this.dialog.waitMessage("Bitte warten...");this.dialog.buttons([{caption:"Abbrechen",color:"#a00000",callback:()=>{this.dialog.close()}},{caption:"OK",color:"green",callback:()=>{t.val()!=i.val()?n.text("Die zwei eingegebenen neuen Passwörter stimmen nicht überein."):(r(!0),D("changePassword",{oldPassword:e.val(),newPassword:t.val()},()=>{r(!1),alert("Das Passwort wurde erfolgreich geändert."),this.dialog.close()},o=>{r(!1),n.text(o)}))}}])}}class Ri{constructor(e){h(this,"loggedInWithVidis",!1);this.main=e,new Ai(this)}loginWithVidis(e){this.loggedInWithVidis=!0,c("#login").hide(),c("#main").css("visibility","visible"),c("#bitteWartenText").html("Bitte warten ..."),c("#bitteWarten").css("display","flex"),this.sendLoginRequest(e)}initGUI(){let e=c("#login-spinner>img");c("#login-username").focus(),c("#login-username").on("keydown",i=>{i.key=="Enter"&&c("#login-password").focus()}),c("#login-password").on("keydown",i=>{i.key=="Enter"&&c("#login-button").trigger("click")}),c("#login-password").on("keydown",i=>{i.key=="Tab"&&(i.preventDefault(),c("#login-button").focus(),c("#login-button").addClass("jo_active")),i.key=="Enter"&&c("#login-button").trigger("click")}),c("#login-button").on("keydown",i=>{i.key=="Tab"?(i.preventDefault(),c("#login-username").focus(),c("#login-button").removeClass("jo_active")):c("#login-button").trigger("click")});let t=!1;c("#login-button").on("click",()=>{e.show(),!t&&(t=!0,setTimeout(()=>{t=!1},1e3),this.sendLoginRequest())}),c("#buttonLogout").on("click",()=>{this.logout()})}logout(){this.main.waitOverlay.show("Bitte warten, der letzte Bearbeitungsstand wird noch gespeichert ..."),this.main.workspacesOwnerId!=this.main.user.id&&this.main.projectExplorer.onHomeButtonClicked(),N.getInstance().close(),this.main.networkManager.sendUpdates(()=>{var t;this.main.notifier.connect(null);let e={currentWorkspaceId:(t=this.main.currentWorkspace)==null?void 0:t.id};this.main.networkManager.sendUpdateUserSettings(()=>{D("logout",e,()=>{this.loggedInWithVidis?window.location.assign("https://aai.vidis.schule/auth/realms/vidis/protocol/openid-connect/logout?ID_TOKEN_HINT="+this.main.user.vidis_sub+"&post_logout_redirect_uri=https%3A%2F%2Fwww.sql-ide.de"):(c("#login").show(),this.main.waitOverlay.hide(),c("#login-message").empty(),this.main.getMonacoEditor().setModel(x.createModel("","myJava")),this.main.projectExplorer.fileListPanel.clear(),this.main.projectExplorer.workspaceListPanel.clear(),this.main.databaseExplorer.clear(),this.main.resultsetPresenter.clear(),this.main.user.is_teacher&&(this.main.teacherExplorer.removePanels(),this.main.teacherExplorer=null),this.main.currentWorkspace=null,this.main.user=null)})})},!0)}sendLoginRequest(e){let t=this,i=c("#login-spinner>img");i.show();let n={username:c("#login-username").val(),password:c("#login-password").val(),language:1};D("login"+(e?"?singleUseToken="+e:""),n,r=>{if(!r.success)c("#login-message").html("Fehler: Benutzername und/oder Passwort ist falsch.");else{N.getInstance().open(),c("#login").hide(),this.main.waitOverlay.show("Bitte warten...");let o=r.user;(o.settings==null||o.settings.helperHistory==null)&&(o.settings={helperHistory:{},viewModes:null,classDiagram:null}),this.main.waitForGUICallback=()=>{let l=r.user;t.main.mainMenu.initGUI(l),t.main.waitOverlay.hide(),i.hide(),c("#menupanel-username").html(le(l)),new Ni(t.main).init(),l.is_teacher&&t.main.initTeacherExplorer(r.classdata),t.main.user=l,t.main.restoreWorkspaces(r.workspaces),t.main.workspacesOwnerId=l.id,t.main.networkManager.initializeTimer(),t.main.projectExplorer.fileListPanel.setFixed(!l.is_teacher),t.main.projectExplorer.workspaceListPanel.setFixed(!l.is_teacher),t.main.viewModeController.initViewMode(),t.main.bottomDiv.hideHomeworkTab(),t.main.networkManager.initializeSSE()},this.main.startupComplete==0&&(this.main.waitForGUICallback(),this.main.waitForGUICallback=null)}},r=>{c("#login-message").html("Login gescheitert: "+r),c("#login-spinner>img").hide()})}}class qi{constructor(e){h(this,"workspace");h(this,"database");this.main=e}async connect(e){if(this.workspace!=null){let i={workspaceId:this.workspace.id,registerOrUnregister:"unregister"};await be("servlet/registerPushClientForDatabase",i)}if(this.workspace=e,e==null){N.unsubscribe("onOpen");return}this.database=e.database;let t={workspaceId:e.id,registerOrUnregister:"register"};be("servlet/registerPushClientForDatabase",t),N.subscribe("broadcastDatabaseChange",i=>{i.databaseId==this.workspace.databaseId?i.rollbackToVersion!=null?this.main.getHistoryViewer().rollbackLocal(i.rollbackToVersion):this.executeNewStatements(i.newStatements,i.firstNewStatementIndex,()=>{this.getNewStatementsHttp()}):(t.registerOrUnregister="unregister",be("servlet/registerPushClientForDatabase",t),N.unsubscribe("onOpen"))}),N.subscribe("onOpen",()=>{t.registerOrUnregister="register",be("servlet/registerPushClientForDatabase",t)})}executeNewStatements(e,t,i,n=()=>{},r=!0){if(this.database==null)return;let o=this,l=t-(this.database.version+1);if(l>0){i(),n();return}else{l<0&&(e.splice(0,-l),t-=l);let d=e;d.length>0?this.main.resultsetPresenter.executeStatementsString(d,0,()=>{o.main.getHistoryViewer().appendStatements(d),o.database.statements=o.database.statements.concat(d),o.database.version=t+e.length-1,r&&o.main.databaseExplorer.refresh(),n()}):n()}}getNewStatementsHttp(){let e=this;if(this.workspace==null||this.database==null)return;let t={workspaceId:this.workspace.id,version_before:this.workspace.database.version};D("getNewStatements",t,i=>{i.rollbackToVersion!=null?e.main.getHistoryViewer().rollbackLocal(i.rollbackToVersion):e.executeNewStatements(i.newStatements,i.firstNewStatementIndex,()=>{e.getNewStatementsHttp()})})}}function nt(a,e,t){var i="";if(t){var n=new Date;n.setTime(n.getTime()+t*1e3),i="; expires="+n.toUTCString()}document.cookie=a+"="+(e||"")+i+"; path=/"}class Ee{constructor(){h(this,"workspaceList",[]);h(this,"workspacesOwnerId");h(this,"editor");h(this,"currentWorkspace");h(this,"projectExplorer");h(this,"teacherExplorer");h(this,"networkManager");h(this,"actionManager");h(this,"mainMenu");h(this,"login");h(this,"compiler");h(this,"semicolonAngel");h(this,"bottomDiv");h(this,"startupComplete",2);h(this,"waitForGUICallback");h(this,"version",0);h(this,"timerHandle");h(this,"user");h(this,"userDataDirty",!1);h(this,"themeManager");h(this,"rightDiv");h(this,"viewModeController");h(this,"databaseTool");h(this,"databaseExplorer");h(this,"resultsetPresenter");h(this,"notifier");h(this,"waitOverlay",new Tt(c(".bitteWarten")));h(this,"historyViewer",new xt(this,c(".jo_historyTab")))}isEmbedded(){return!1}getCurrentWorkspace(){return this.currentWorkspace}getMonacoEditor(){return this.editor.editor}getRightDiv(){return this.rightDiv}getBottomDiv(){return this.bottomDiv}getCurrentlyEditedModule(){return this.projectExplorer.getCurrentlyEditedModule()}getActionManager(){return this.actionManager}getCompiler(){return this.compiler}setModuleActive(e){this.projectExplorer.setModuleActive(e)}getSemicolonAngel(){return this.semicolonAngel}getDatabaseTool(){return this.databaseTool}getDatabaseExplorer(){return this.databaseExplorer}getResultsetPresenter(){return this.resultsetPresenter}getWaitOverlay(){return this.waitOverlay}getHistoryViewer(){return this.historyViewer}initGUI(){mi(),this.login=new Ri(this);let e=location.search.split("singleUseToken=")[1];e&&nt("singleUseToken",e,3);let t=pi("singleUseToken");t?(nt("singleUseToken","",0),this.login.initGUI(),this.login.loginWithVidis(t)):this.login.initGUI(),this.databaseTool=new W(this),this.databaseExplorer=new yt(this,c(".jo_db_tree")),this.actionManager=new gt(null,this),this.actionManager.init(),this.networkManager=new vi(this,c("#bottomdiv-outer .jo_updateTimerDiv")),new Ii(this).initSliders(),this.mainMenu=new Pi(this),this.projectExplorer=new $i(this,c("#leftpanel>.jo_projectexplorer")),this.projectExplorer.initGUI(),this.bottomDiv=new Lt(this,c("#bottomdiv-outer>.jo_bottomdiv-inner"),c("body")),this.rightDiv=new _t(this,c("#rightdiv-inner")),this.rightDiv.initGUI(),this.checkStartupComplete(),this.themeManager=new ot,this.viewModeController=new Oi(c("#view-mode"),this),this.semicolonAngel=new pt(this),new Dt(this,c("#controls")),this.resultsetPresenter=new Ve(this,c(".jo_bottomdiv-inner")),this.notifier=new qi(this)}initEditor(){this.editor=new Ct(this,!0,!1),new st().init(),this.editor.initGUI(c("#editor"));let e=this;c(window).on("resize",t=>{c("#bottomdiv-outer").css("height","450px"),c("#editor").css("height",window.innerHeight-450-30-2+"px"),e.editor.editor.layout(),c("#editor").css("height","")}),c(window).trigger("resize"),this.checkStartupComplete()}initTeacherExplorer(e){this.teacherExplorer=new Bi(this,e),this.teacherExplorer.initGUI()}checkStartupComplete(){this.startupComplete--,this.startupComplete==0&&this.start()}start(){this.waitForGUICallback!=null&&this.waitForGUICallback();let e=this;setTimeout(()=>{e.getMonacoEditor().layout()},200),this.compiler=new ft(this),this.startTimer(),c(window).on("unload",function(){navigator.sendBeacon&&e.user!=null&&(e.networkManager.sendUpdates(null,!1),e.networkManager.sendUpdateUserSettings(()=>{}))})}startTimer(){this.timerHandle!=null&&clearInterval(this.timerHandle);let e=this;this.timerHandle=setInterval(()=>{e.compileIfDirty()},500)}compileIfDirty(){var e,t;if(this.currentWorkspace!=null&&this.currentWorkspace.moduleStore.isDirty()&&this.compiler.compilerStatus!=pe.compiling)try{this.compiler.compile(this.currentWorkspace.moduleStore);let i=(t=(e=this.bottomDiv)==null?void 0:e.errorManager)==null?void 0:t.showErrors(this.currentWorkspace);this.projectExplorer.renderErrorCount(this.currentWorkspace,i),this.editor.onDidChangeCursorPosition(null),this.projectExplorer&&this.version++}catch(i){console.error(i),this.compiler.compilerStatus=pe.error}}removeWorkspace(e){this.workspaceList.splice(this.workspaceList.indexOf(e),1)}restoreWorkspaces(e){this.workspaceList=[],this.currentWorkspace=null,this.getMonacoEditor().updateOptions({readOnly:!0});let t=null;for(let i of e.workspaces){let n=ie.restoreFromData(i,this);this.workspaceList.push(n),i.id==this.user.currentWorkspace_id&&!i.isFolder&&(t=n)}if(this.projectExplorer.renderWorkspaces(this.workspaceList),t==null&&this.workspaceList.length>0){for(let i of this.workspaceList)if(!i.isFolder){t=this.workspaceList[0];break}}t!=null&&this.projectExplorer.setWorkspaceActive(t,null,!0),this.workspaceList.length==0&&K.showHelper("newDatabaseHelper",this,this.projectExplorer.workspaceListPanel.$captionElement)}createNewWorkspace(e,t){return new ie(e,this,t)}}class zi{constructor(e,t,i){h(this,"oldDecorations",[]);h(this,"oldErrorDecorations",[]);h(this,"$errorDiv");h(this,"minimapColor",{});h(this,"lightBulbOnClickFunctionList",[]);this.main=e,this.$bottomDiv=t,this.$mainDiv=i,this.minimapColor.error="#bc1616",this.minimapColor.warning="#cca700",this.minimapColor.info="#75beff";let n=this;i.find(".jo_pw_undo").on("click",()=>{n.main.getMonacoEditor().trigger(".","undo",{})}).attr("title","Undo")}showErrors(e){this.main.getResultsetPresenter().showErrorDecorations([]),this.lightBulbOnClickFunctionList=[];let t=new Map;this.$errorDiv=this.$bottomDiv.find(".jo_tabs>.jo_errorsTab"),this.$errorDiv.empty();let i=!1,n=e.moduleStore;this.main.getMonacoEditor();for(let r of n.getModules(!1)){let o=[],l=[],d=[],u=r.getSortedAndFilteredErrors();t.set(r,r.getErrorCount());for(let m of u){let f,p=this.minimapColor[m.level];switch(m.level){case"error":f="jo_revealErrorLine";break;case"warning":f="jo_revealWarningLine";break;case"info":f="jo_revealInfoLine";break}this.processError(m,r,d);let b;switch(m.level){case"error":b=te.Error;break;case"warning":b=te.Warning;break;case"info":b=te.Info;break}o.push({startLineNumber:m.position.line,startColumn:m.position.column,endLineNumber:m.position.line,endColumn:m.position.column+m.position.length,message:m.text,severity:b,relatedInformation:m.quickFix}),l.push({range:{startLineNumber:m.position.line,startColumn:m.position.column,endLineNumber:m.position.line,endColumn:m.position.column+m.position.length},options:{linesDecorationsClassName:f,minimap:{position:x.MinimapPosition.Inline,color:p}}})}if(x.setModelMarkers(r.model,"test",o),r.oldErrorDecorations=r.model.deltaDecorations(r.oldErrorDecorations,l),this.oldDecorations=this.main.getMonacoEditor().deltaDecorations(this.oldDecorations,[]),d.length>0&&this.$errorDiv.length>0){i=!0;let m=c('<div class="jo_error-filename">'+r.file.name+"&nbsp;</div>");this.$errorDiv.append(m);for(let f of d)this.$errorDiv.append(f)}}return!i&&this.$errorDiv.length>0&&this.$errorDiv.append(c('<div class="jo_noErrorMessage">Keine Fehler gefunden :-)</div>')),this.registerLightbulbOnClickFunctions(),t}registerLightbulbOnClickFunctions(){let e=this;setTimeout(()=>{for(let t of e.lightBulbOnClickFunctionList)c(t.class).off("click",t.onClickFunction),c(t.class).on("click",t.onClickFunction).attr("title",t.title)},500)}processError(e,t,i){let n=c('<div class="jo_error-line"></div>'),r=c('<span class="jo_error-position">[Z&nbsp;<span class="jo_linecolumn">'+e.position.line+'</span> Sp&nbsp;<span class="jo_linecolumn">'+e.position.column+"</span>]</span>:&nbsp;"),o="";switch(e.level){case"error":break;case"warning":o='<span class="jo_warning_category">Warnung: </span>';break;case"info":o='<span class="jo_info_category">Info: </span>';break}let l=c('<div class="jo_error-text">'+o+e.text+"</div>");n.append(r).append(l);let d=this;n.on("mousedown",u=>{this.$errorDiv.find(".jo_error-line").removeClass("jo_active"),n.addClass("jo_active"),d.showError(t,e)}),i.push(n)}showError(e,t){this.main instanceof Ee&&e!=this.main.projectExplorer.getCurrentlyEditedModule()&&this.main.projectExplorer.setModuleActive(e);let i=t.position,n={startColumn:i.column,startLineNumber:i.line,endColumn:i.column+i.length,endLineNumber:i.line};this.main.getMonacoEditor().revealRangeInCenter(n);let r="";switch(t.level){case"error":r="jo_revealError";break;case"warning":r="jo_revealWarning";break;case"info":r="jo_revealInfo";break}this.oldDecorations=this.main.getMonacoEditor().deltaDecorations(this.oldDecorations,[{range:n,options:{className:r}}])}}class Ui{constructor(e,t){h(this,"$homeworkTab");h(this,"$homeworkTabLeft");h(this,"$homeworkTabRight");h(this,"$showRevisionButton");h(this,"showRevisionActive",!1);h(this,"diffEditor");this.main=e,this.$bottomDiv=t,this.$homeworkTab=t.find(".jo_tabs>.jo_homeworkTab")}initGUI(){let e=this;this.$homeworkTab.append(this.$homeworkTabLeft=X("","jo_homeworkTabLeft jo_scrollable")),this.$homeworkTab.append(this.$homeworkTabRight=X("","jo_homeworkTabRight jo_scrollable")),c("#view-mode").prepend(this.$showRevisionButton=X("","jo_button jo_active jo_homeworkRevisionButton","")),this.$showRevisionButton.on("click",()=>{this.showRevisionActive?this.hideRevision():this.showRevision(e.main.getCurrentlyEditedModule())}),this.$showRevisionButton.hide(),c("#diffEditor").hide()}showHomeWorkRevisionButton(){this.$showRevisionButton.text(this.showRevisionActive?"Normalansicht":"Korrekturen zeigen"),this.$showRevisionButton.show()}hideHomeworkRevisionButton(){this.$showRevisionButton.hide()}showRevision(e){e.file.text=e.getProgramTextFromMonacoModel();let t=e.file;c("#editor").hide(),c("#diffEditor").show();var i=x.createModel(t.text_before_revision,"myJava"),n=x.createModel(t.text,"myJava");this.diffEditor=x.createDiffEditor(document.getElementById("diffEditor"),{enableSplitViewResizing:!0,originalEditable:!1,readOnly:!0,renderSideBySide:!0}),this.diffEditor.setModel({original:i,modified:n}),this.showRevisionActive=!0,this.showHomeWorkRevisionButton()}hideRevision(){this.showRevisionActive&&(c("#diffEditor").hide(),this.diffEditor.dispose(),this.diffEditor=null,c("#editor").show(),this.showRevisionActive=!1,this.showHomeWorkRevisionButton())}attachToWorkspaces(e){let t=[],i={};e.forEach(o=>{o.moduleStore.getModules(!1).forEach(l=>{let d=l.file.submitted_date;if(d!=null){let u=ai(d),m=oi(u),f=i[m];f==null&&(f={date:u,day:m,modules:[]},i[m]=f,t.push(f)),f.modules.push({module:l,workspace:o})}})}),this.$homeworkTabLeft.empty(),this.$homeworkTabRight.empty();let n=this;this.$homeworkTabLeft.append(X("","jo_homeworkHeading","Abgabetage:")),t.sort((o,l)=>o.date.getFullYear()!=l.date.getFullYear()?-Math.sign(o.date.getFullYear()-l.date.getFullYear()):o.date.getMonth()!=l.date.getMonth()?-Math.sign(o.date.getMonth()-l.date.getMonth()):o.date.getDate()!=l.date.getDate()?-Math.sign(o.date.getDate()-l.date.getDate()):0);let r=!0;t.forEach(o=>{o.modules.sort((d,u)=>d.module.file.name.localeCompare(u.module.file.name));let l=X("","jo_homeworkDate",o.day);this.$homeworkTabLeft.append(l),l.on("click",d=>{this.$homeworkTabLeft.find(".jo_homeworkDate").removeClass("active"),l.addClass("jo_active"),n.select(o)}),r&&(r=!1,l.addClass("jo_active"),n.select(o))})}select(e){this.$homeworkTabRight.empty(),this.$homeworkTabRight.append(X("","jo_homeworkHeading","Abgegebene Dateien:"));let t=this;e.modules.forEach(i=>{let n=c(`<div class="jo_homeworkEntry">Workspace <span class="jo_homework-workspace">
214
214
  ${i.workspace.name}</span>, Datei <span class="jo_homework-file">
215
- ${i.module.file.name}</span> (Abgabe: ${i.module.file.submitted_date} )</div>`);t.$homeworkTabRight.append(n),n.on("click",()=>{t.main.projectExplorer.setWorkspaceActive(i.workspace),t.main.projectExplorer.setModuleActive(i.module),t.main.projectExplorer.fileListPanel.select(i.module,!1)})})}}class _t{constructor(e,t,i){h(this,"errorManager");h(this,"homeworkManager");this.main=e,this.$bottomDiv=t,this.$mainDiv=i,this.$bottomDiv.find(".jo_tabheadings>.jo_homeworkTabheading").length>0&&(this.homeworkManager=new Ui(e,t)),this.errorManager=new zi(e,t,i)}initGUI(){Te(this.$bottomDiv),this.homeworkManager!=null&&this.homeworkManager.initGUI(),this.$bottomDiv.find(".jo_tabs").children().first().trigger("click")}showHomeworkTab(){c(".jo_homeworkTabheading").css("visibility","visible"),c(".jo_homeworkTabheading").trigger("mousedown")}hideHomeworkTab(){c(".jo_homeworkTabheading").css("visibility","hidden"),c(".jo_tabheadings").children().first().trigger("mousedown")}}class Hi{constructor(e){this.main=e}async load(e,t){let i=e.replace("https://","").replace("http://","").toLocaleLowerCase(),n=i.toLocaleLowerCase(),r=await this.fetchTemplateFromCache(i);if(r!=null)return W.getDumpType(r)=="binaryCompressed"&&(t.show("Datenbank aus Cache wird entpackt..."),r=H.inflate(r),t.hide()),{binDump:r};let o;return n.endsWith(".sqlite")||n.endsWith(".zz")?o=await this.loadSqLiteDump(e,t):(n.endsWith(".zip")||n.endsWith(".sql"))&&(o=await this.loadMySql(e,i)),this.saveDatabaseToCache(i,o.binDump),o}loadMySql(e,t){return new xt(this.main).loadFromUrl(e)}async loadSqLiteDump(e,t){return t.show("Datenbank wird geladen..."),new Promise((i,n)=>{c.ajax({type:"GET",async:!0,url:e,xhrFields:{responseType:"arraybuffer"},success:function(r){let o=new Uint8Array(r);W.getDumpType(o)=="binaryCompressed"&&(t.show("Datenbank wird entpackt..."),o=H.inflate(o)),t.hide(),i({binDump:o})},error:function(r,o){t.hide(),n(o)}})})}cutSqlToStatements(e){e=e.replace(/\r\n/g,`
215
+ ${i.module.file.name}</span> (Abgabe: ${i.module.file.submitted_date} )</div>`);t.$homeworkTabRight.append(n),n.on("click",()=>{t.main.projectExplorer.setWorkspaceActive(i.workspace),t.main.projectExplorer.setModuleActive(i.module),t.main.projectExplorer.fileListPanel.select(i.module,!1)})})}}class Lt{constructor(e,t,i){h(this,"errorManager");h(this,"homeworkManager");this.main=e,this.$bottomDiv=t,this.$mainDiv=i,this.$bottomDiv.find(".jo_tabheadings>.jo_homeworkTabheading").length>0&&(this.homeworkManager=new Ui(e,t)),this.errorManager=new zi(e,t,i)}initGUI(){Le(this.$bottomDiv),this.homeworkManager!=null&&this.homeworkManager.initGUI(),this.$bottomDiv.find(".jo_tabs").children().first().trigger("click")}showHomeworkTab(){c(".jo_homeworkTabheading").css("visibility","visible"),c(".jo_homeworkTabheading").trigger("mousedown")}hideHomeworkTab(){c(".jo_homeworkTabheading").css("visibility","hidden"),c(".jo_tabheadings").children().first().trigger("mousedown")}}class Hi{constructor(e){this.main=e}async load(e,t){let i=e.replace("https://","").replace("http://","").toLocaleLowerCase(),n=i.toLocaleLowerCase(),r=await this.fetchTemplateFromCache(i);if(r!=null)return W.getDumpType(r)=="binaryCompressed"&&(t.show("Datenbank aus Cache wird entpackt..."),r=H.inflate(r),t.hide()),{binDump:r};let o;return n.endsWith(".sqlite")||n.endsWith(".zz")?o=await this.loadSqLiteDump(e,t):(n.endsWith(".zip")||n.endsWith(".sql"))&&(o=await this.loadMySql(e,i)),this.saveDatabaseToCache(i,o.binDump),o}loadMySql(e,t){return new Et(this.main).loadFromUrl(e)}async loadSqLiteDump(e,t){return t.show("Datenbank wird geladen..."),new Promise((i,n)=>{c.ajax({type:"GET",async:!0,url:e,xhrFields:{responseType:"arraybuffer"},success:function(r){let o=new Uint8Array(r);W.getDumpType(o)=="binaryCompressed"&&(t.show("Datenbank wird entpackt..."),o=H.inflate(o)),t.hide(),i({binDump:o})},error:function(r,o){t.hide(),n(o)}})})}cutSqlToStatements(e){e=e.replace(/\r\n/g,`
216
216
  `);let t=[];return e.indexOf("~@~")>=0?t=e.split("~@~"):t=e.split(`;
217
217
  `),t}async fetchTemplateFromCache(e){if(e==null||!this.cacheAvailable())return null;let i=await(await caches.open("my-cache")).match(e);if(i==null)return null;let n=await i.arrayBuffer();return new Uint8Array(n)}async saveDatabaseToCache(e,t){if(!this.cacheAvailable())return;(await caches.open("my-cache")).put(e,new Response(t))}cacheAvailable(){return"caches"in self}}class Ki{constructor(e,t,i){h(this,"currentFile");h(this,"files",[]);this.moduleStore=e,this.$fileListDiv=t,this.main=i;let n=this;for(let l of e.getModules(!1))this.addModule(l);let r=t.parent(),o=c('<div class="joe_addFileButton jo_button img_add-dark jo_active" title="Datei hinzufügen"></div>');r.append(o),o.on("click",()=>{let l=this.main.addModule({text:"",title:"Neue Datei.java",type:"sql"}),d=this.addModule(l);this.renameElement(d,()=>{n.currentFile!=d&&n.selectFile(d)})})}removeAllFiles(){this.files.forEach(e=>this.removeFile(e))}addHint(e){let t=this,i=c('<div class="jo_file jo_hint" ><div class="jo_fileimage"></div><div class="jo_filename" style="line-height: 22px">'+e.title+'</div><div class="jo_additionalButtons"></div></div></div>');this.$fileListDiv.append(i);let n={module:null,$fileDiv:i,type:"hint",hint:e.text};this.files.push(n),i.on("click",r=>{t.selectFile(n)})}addModule(e){let t=this,i=c(`<div class="jo_file jo_java" >
218
218
  <div class="jo_fileimage"></div>
219
219
  <div class="jo_filename" style="line-height: 22px">${e.file.name}</div>
220
220
  <div class="jo_additionalButtonStart"></div>
221
- <div class="jo_delete img_delete jo_button jo_active" title="Datei löschen"></div></div></div>`);this.$fileListDiv.append(i);let n={module:e,$fileDiv:i,type:"sql"};return this.files.push(n),e.file.panelElement={name:e.file.name,$htmlFirstLine:i,isFolder:!1,path:[]},i.find(".jo_delete").on("mousedown",r=>{t.onDelete(n,r)}),i.find(".jo_delete").on("click",r=>{r.preventDefault(),r.stopPropagation()}),i.on("click",r=>{t.selectFile(n)}),i[0].addEventListener("contextmenu",function(r){r.preventDefault(),R([{caption:"Umbenennen",callback:()=>{t.renameElement(n,()=>{})}}],r.pageX,r.pageY)},!1),n}onDelete(e,t){t.preventDefault(),t.stopPropagation();let i=this;R([{caption:"Abbrechen",callback:()=>{}},{caption:"Ich bin mir sicher: löschen!",color:"#ff6060",callback:()=>{i.removeFile(e)}}],t.pageX+2,t.pageY+2)}removeFile(e){e.$fileDiv.remove(),this.main.removeModule(e.module),this.files=this.files.filter(t=>t!=e),this.currentFile==e&&(this.files.length>0?this.selectFile(this.files[0]):(this.main.getMonacoEditor().setValue("Keine Datei vorhanden."),this.main.getMonacoEditor().updateOptions({readOnly:!0}))),this.files.forEach(t=>{t.module!=null&&(t.module.file.saved=!1)})}removeModule(e){for(let t of this.files)t.module==e&&this.removeFile(t)}renameElement(e,t){let i=e.$fileDiv.find(".jo_filename"),n=e.module.file.name.indexOf("."),r=n==null?null:{start:0,end:n};pt(i,i,o=>{e.module.file.name=o,i.html(o),t!=null&&t()},r)}setFirstFileActive(){this.files.length>0&&this.selectFile(this.files[0])}selectFile(e){if(e!=null)switch(e.type){case"sql":this.main.$hintDiv.hide(),this.main.$monacoDiv.show(),this.main.setModuleActive(e.module),this.main.getMonacoEditor().focus();break;case"hint":this.main.$monacoDiv.hide(),this.main.$hintDiv.show();let t={},i=[],n=Ze({highlight:function(r,o){return i.push(r),""}});n.renderer.rules.code_inline=function(r,o,l,d,u){var m=r[o];return i.push(m.content),""},n.render(e.hint),this.colorize(i,t,()=>{let r=Ze({highlight:function(l,d){return t[l]}});r.renderer.rules.code_inline=function(l,d,u,m,f){var p=l[d];return t[p.content].replace("<br/>","")};let o=r.render(e.hint);this.main.$hintDiv.html(o)}),this.$fileListDiv.find(".jo_file").removeClass("jo_active"),e.$fileDiv.addClass("jo_active");break}}colorize(e,t,i){let n=this;if(e.length>0){let r=e.pop();x.colorize(r,"myJava",{tabSize:3}).then(o=>{t[r]=o,n.colorize(e,t,i)})}else i()}markFile(e){this.$fileListDiv.find(".jo_file").removeClass("jo_active"),this.currentFile=this.files.find(t=>t.module==e),this.currentFile!=null&&this.currentFile.$fileDiv.addClass("jo_active")}}class Vi{constructor(e){h(this,"db");this.databaseIdentifier=e}open(e){if(window.indexedDB){let t=window.indexedDB.open(this.databaseIdentifier,1),i=this;t.onerror=function(n){console.log("Couldn't open IndexedDB: "+n.type)},t.onsuccess=function(n){i.db=t.result,i.db.onerror=function(r){console.log("Datenbankfehler: "+r.target.error.message)},e()},t.onupgradeneeded=function(n){i.db=n.target.result;let r=i.db.createObjectStore("scripts",{keyPath:"scriptId",autoIncrement:!1});r.transaction.oncomplete=function(o){},i.db.createObjectStore("databases",{keyPath:"databaseId",autoIncrement:!1}),r.transaction.oncomplete=function(o){}}}else console.log("IndexedDB not available.")}writeScript(e,t){this.db.transaction("scripts","readwrite").objectStore("scripts").put({scriptId:e,script:t})}removeScript(e){this.db.transaction("scripts","readwrite").objectStore("scripts").delete(e)}getScript(e,t){let n=this.db.transaction("scripts","readwrite").objectStore("scripts").get(e);n.onerror=r=>{t(null)},n.onsuccess=r=>{n.result==null?t(null):t(n.result.script)}}writeDatabase(e,t){this.db.transaction("databases","readwrite").objectStore("databases").put({databaseId:e,database:t})}removeDatabase(e){this.db.transaction("databases","readwrite").objectStore("databases").delete(e)}getDatabase(e,t){let n=this.db.transaction("databases","readwrite").objectStore("databases").get(e);n.onerror=r=>{t(null)},n.onsuccess=r=>{n.result==null?t(null):t(n.result.database)}}}class Gi{constructor(e){this.module=e}getName(){return this.module.file.name}getText(){return this.module.getProgramTextFromMonacoModel()}}class Qi{constructor(e){this.ide=e}getFiles(){return this.ide.getCurrentWorkspace().moduleStore.getModules(!1).map(e=>new Gi(e))}}const ue=class ue{static registerIDE(e){ue.ideMap.set(e.config.id,new Qi(e))}getIDE(e){return ue.ideMap.get(e)}};h(ue,"ideMap",new Map);let Ee=ue;class Ie{constructor(e,t,i,n,r){h(this,"$sliderDiv");this.$container=e,this.firstLast=t,this.horVert=i,this.callback=n,this.$otherDiv=r,this.initSlider()}initSlider(){let e=this;this.$otherDiv==null&&this.$container.parent().children().each((t,i)=>{i!=this.$container[0]&&(e.$otherDiv=c(i))}),this.$sliderDiv=c('<div class="joe_slider"></div>'),this.$sliderDiv.css({width:this.horVert?"100%":"4px",height:this.horVert?"4px":"100%",cursor:this.horVert?"row-resize":"col-resize"}),this.firstLast?this.$sliderDiv.css({top:"0px",left:"0px"}):this.horVert?this.$sliderDiv.css({bottom:"0px",left:"0px"}):this.$sliderDiv.css({top:"0px",right:"0px"}),this.$container.append(this.$sliderDiv),this.$sliderDiv.on("mousedown",t=>{let i=t.clientX,n=t.clientY;c(document).on("mousemove.slider",r=>{let o=r.clientX-i,l=r.clientY-n;e.slide(o,l),i=r.clientX,n=r.clientY}),c(document).on("mouseup.slider",()=>{c(document).off("mousemove.slider"),c(document).off("mouseup.slider")})}),setTimeout(()=>{e.slide(1,1)},600)}setColor(e){this.$sliderDiv.css("background-color",e)}slide(e,t){if(this.horVert){let i=Number.parseInt(this.$container.css("height").replace("px","")),n=Number.parseInt(this.$otherDiv.css("height").replace("px","")),r=this.firstLast?i-=t:i+=t,o=this.firstLast?n+=t:n-=t;this.$container.css("height",r+"px"),this.$otherDiv.css("height",o+"px"),this.callback(r)}else{let i=Number.parseInt(this.$container.css("width").replace("px","")),n=Number.parseInt(this.$otherDiv.css("width").replace("px","")),r=this.firstLast?i-=e:i+=e,o=this.firstLast?n+=e:n-=e;this.$container.css("width",r+"px"),this.$otherDiv.css("width",o+"px"),this.callback(r)}this.$container.css("flex","0 1 auto")}}class Zi{constructor(e,t){h(this,"indexedDB");h(this,"databaseTool");h(this,"statementsToExecute",[]);h(this,"writtenStatements",[]);h(this,"statementsToWrite",[]);h(this,"atLeastOneExecuted",!1);h(this,"count");this.main=e,this.databaseIdentifier=t}indexedDBReady(e){this.indexedDB=e,this.indexedDB.getDatabase(this.databaseIdentifier,t=>{t!=null&&(this.writtenStatements=JSON.parse(t),this.statementsToExecute=this.writtenStatements.slice(),this.main.historyViewer.clear(),this.main.historyViewer.appendStatements(this.statementsToExecute),this.executeStatements(),this.writeStatementsIfNecessary())})}reset(){this.statementsToWrite=[],this.writtenStatements=[],this.statementsToExecute=[],this.main.historyViewer.clear(),this.forceWriteStatements()}writeStatementsIfNecessary(){this.indexedDB!=null&&this.statementsToWrite.length>0&&this.forceWriteStatements()}forceWriteStatements(){this.writtenStatements=this.writtenStatements.concat(this.statementsToWrite),this.statementsToWrite=[],this.indexedDB.writeDatabase(this.databaseIdentifier,JSON.stringify(this.writtenStatements))}executeStatements(){if(this.databaseTool!=null&&this.statementsToExecute.length>0){this.atLeastOneExecuted||(this.main.$databaseResetButton.fadeIn(200),this.count=this.statementsToExecute.length,this.main.waitOverlay.show("Schreibe lokale Datenbankänderungen ...")),this.main.waitOverlay.setProgress(Math.round(100*(1-this.statementsToExecute.length/this.count))+" %");let e=this.statementsToExecute.shift();this.atLeastOneExecuted=!0,this.databaseTool.executeQuery(e,()=>{this.executeStatements()},()=>{this.executeStatements()})}else this.atLeastOneExecuted&&(this.main.databaseExplorer.refresh(),this.atLeastOneExecuted=!1,this.main.waitOverlay.hide())}notify(e){this.main.$databaseResetButton.fadeIn(200);let t=e.map(i=>i.sqlCleaned==null?i.sql:i.sqlCleaned);this.statementsToWrite=this.statementsToWrite.concat(t),this.main.historyViewer.appendStatements(t),this.writeStatementsIfNecessary()}databaseReady(e){this.databaseTool=e,this.executeStatements()}rollback(){this.writeStatementsIfNecessary(),this.writtenStatements.pop(),this.forceWriteStatements()}}const Ji="data:image/svg+xml,%3csvg%20width='105'%20height='105'%20viewBox='0%200%20105%20105'%20xmlns='http://www.w3.org/2000/svg'%20fill='%23fff'%3e%3ccircle%20cx='12.5'%20cy='12.5'%20r='12.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='0s'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3ccircle%20cx='12.5'%20cy='52.5'%20r='12.5'%20fill-opacity='.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='100ms'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3ccircle%20cx='52.5'%20cy='12.5'%20r='12.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='300ms'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3ccircle%20cx='52.5'%20cy='52.5'%20r='12.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='600ms'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3ccircle%20cx='92.5'%20cy='12.5'%20r='12.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='800ms'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3ccircle%20cx='92.5'%20cy='52.5'%20r='12.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='400ms'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3ccircle%20cx='12.5'%20cy='92.5'%20r='12.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='700ms'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3ccircle%20cx='52.5'%20cy='92.5'%20r='12.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='500ms'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3ccircle%20cx='92.5'%20cy='92.5'%20r='12.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='200ms'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3c/svg%3e";class Yi{constructor(e,t){h(this,"config");h(this,"editor");h(this,"programPointerDecoration",[]);h(this,"programPointerModule");h(this,"currentWorkspace");h(this,"actionManager");h(this,"compiler");h(this,"$dbTreeDiv");h(this,"$debuggerDiv");h(this,"bottomDiv");h(this,"$filesListDiv");h(this,"$hintDiv");h(this,"$monacoDiv");h(this,"$codeResetButton");h(this,"$databaseResetButton");h(this,"programIsExecutable",!1);h(this,"version",0);h(this,"timerHandle");h(this,"rightDiv");h(this,"$rightDivInner");h(this,"fileExplorer");h(this,"debounceDiagramDrawing");h(this,"indexedDB");h(this,"compileRunsAfterCodeReset",0);h(this,"semicolonAngel");h(this,"databaseTool");h(this,"databaseExplorer");h(this,"waitOverlay");h(this,"resultsetPresenter");h(this,"writeQueryManager");h(this,"historyViewer");h(this,"initialTemplateDump");h(this,"initialStatements");this.scriptList=t,this.readConfig(e),this.writeQueryManager=new Zi(this,(this.config.databaseURL==null?"Empty database":this.config.databaseURL)+this.config.id),this.initGUI(e),this.databaseExplorer=new kt(this,this.$dbTreeDiv),this.databaseTool=new W(this),this.config.databaseURL!=null?new Hi(this).load(this.config.databaseURL,this.getWaitOverlay()).then(i=>{this.initialTemplateDump=i.binDump,this.initialStatements=i.statements==null?[]:i.statements,this.initDatabase()}).catch(i=>{alert("Fehler beim Laden der Datenbank: "+i)}):this.initDatabase(),this.semicolonAngel=new mt(this),this.config.enableFileAccess&&(window.sql_ide_access=new Ee,Ee.registerIDE(this))}isEmbedded(){return!0}getCompiler(){return this.compiler}getCurrentWorkspace(){return this.currentWorkspace}getMonacoEditor(){return this.editor.editor}getRightDiv(){return this.rightDiv}getBottomDiv(){return this.bottomDiv}getActionManager(){return this.actionManager}getCurrentlyEditedModule(){var e;return this.config.withFileList?(e=this.fileExplorer.currentFile)==null?void 0:e.module:this.currentWorkspace.moduleStore.getFirstModule()}getDatabaseTool(){return this.databaseTool}getDatabaseExplorer(){return this.databaseExplorer}getResultsetPresenter(){return this.resultsetPresenter}getWaitOverlay(){return this.waitOverlay}getHistoryViewer(){return this.historyViewer}initDatabase(){this.resetDatabase(()=>{this.initScripts(),this.indexedDB=new Vi("SQL-IDE"),this.indexedDB.open(()=>{this.config.id!=null&&(this.writeQueryManager.indexedDBReady(this.indexedDB),this.readScripts())})})}resetDatabase(e){this.databaseTool.initializeWorker(this.initialTemplateDump,this.initialStatements,()=>{},()=>{this.writeQueryManager.databaseReady(this.databaseTool),this.databaseExplorer.refreshAfterRetrievingDBStructure(),e()})}initScripts(){var e;(e=this.fileExplorer)==null||e.removeAllFiles(),this.initWorkspace(this.scriptList),this.config.withFileList?(this.fileExplorer=new Ki(this.currentWorkspace.moduleStore,this.$filesListDiv,this),this.fileExplorer.setFirstFileActive(),this.scriptList.filter(t=>t.type=="hint").forEach(t=>this.fileExplorer.addHint(t))):this.setModuleActive(this.currentWorkspace.moduleStore.getFirstModule())}readConfig(e){let t=e.data("sql-online");t!=null&&typeof t=="string"?this.config=JSON.parse(t.split("'").join('"')):this.config={},this.config.withFileList==null&&(this.config.withFileList=!1),this.config.withOutput==null&&(this.config.withOutput=!0),this.config.withErrorList==null&&(this.config.withErrorList=!0),this.config.withBottomPanel==null&&(this.config.withBottomPanel=!0),this.config.withOutput||this.config.withFileList||this.config.withErrorList||(this.config.withBottomPanel=!1),this.config.withBottomPanel||(this.config.withFileList=!1,this.config.withOutput=!1,this.config.withErrorList=!1),this.config.databaseURL!=null&&["http:","https:"].forEach(i=>{this.config.databaseURL.startsWith(i)&&!this.config.databaseURL.startsWith(i+"://")&&(this.config.databaseURL=this.config.databaseURL.replace(i,i+"//"))})}setModuleActive(e){this.config.withFileList&&this.fileExplorer.currentFile!=null&&(this.fileExplorer.currentFile.module.editorState=this.getMonacoEditor().saveViewState()),this.config.withFileList&&this.fileExplorer.markFile(e),this.getMonacoEditor().updateOptions({readOnly:!1,lineNumbersMinChars:4}),this.editor.editor.setModel(e.model),e.editorState!=null&&this.getMonacoEditor().restoreViewState(e.editorState)}readScripts(){let e=this.currentWorkspace.moduleStore.getModules(!1),t=this;this.indexedDB.getScript(this.config.id,i=>{var n;if(i==null)setInterval(()=>{t.saveScripts()},1e3);else{let r=JSON.parse(i),o=r.length;for(let l of e)(n=t.fileExplorer)==null||n.removeModule(l),t.removeModule(l);for(let l of r){let d=this.config.id+l;this.indexedDB.getScript(d,u=>{var m,f;if(u!=null){let p=t.addModule({title:l,text:u,type:"sql"});(m=t.fileExplorer)==null||m.addModule(p),t.$codeResetButton.fadeIn(1e3)}if(o--,o==0&&(setInterval(()=>{t.saveScripts()},1e3),(f=t.fileExplorer)==null||f.setFirstFileActive(),t.fileExplorer==null)){let p=t.currentWorkspace.moduleStore.getModules(!1);p.length>0&&t.setModuleActive(p[0])}})}}})}saveScripts(){let e=this.currentWorkspace.moduleStore.getModules(!1),t=[],i=!1;if(e.forEach(n=>i=i||!n.file.saved),i){for(let n of e){t.push(n.file.name);let r=this.config.id+n.file.name;this.indexedDB.writeScript(r,n.getProgramTextFromMonacoModel()),n.file.saved=!0}this.indexedDB.writeScript(this.config.id,JSON.stringify(t))}}deleteScriptsInDB(){this.indexedDB.getScript(this.config.id,e=>{if(e!=null){let t=JSON.parse(e);for(let i of t){let n=this.config.id+i;this.indexedDB.removeScript(n)}this.indexedDB.removeScript(this.config.id)}})}initWorkspace(e){this.currentWorkspace=new te("Embedded-Workspace",this,0);for(let t of e)t.type=="sql"&&this.addModule(t)}addModule(e){let t=U.restoreFromData({id:this.currentWorkspace.moduleStore.getModules(!0).length,name:e.title,text:e.text,text_before_revision:null,submitted_date:null,student_edited_after_revision:!1,version:1,workspace_id:0,forceUpdate:!1,file_type:11},this);this.currentWorkspace.moduleStore.putModule(t);let i=this;return t.model.onDidChangeContent(()=>{i.considerShowingCodeResetButton()}),t}removeModule(e){this.currentWorkspace.moduleStore.removeModule(e)}initGUI(e){e.css({"background-image":"none","background-size":"100%"});let t=c('<div class="joe_centerDiv"></div>');e.append(t);let i=this.makeWaitDiv();e.append(i),this.waitOverlay=new Dt(i);let n=this.makeCodeResetModalWindow(e),r=this.makeDatabaseResetModalWindow(e),o=this.makeRightDiv(),l=c('<div class="joe_editorDiv"></div>');this.$monacoDiv=c('<div class="joe_monacoDiv"></div>'),this.$hintDiv=c('<div class="joe_hintDiv jo_scrollable"></div>'),this.$codeResetButton=c('<div class="joe_codeResetButton jo_button jo_active" title="Code auf Ausgangszustand zurücksetzen">Code Reset</div>'),this.$databaseResetButton=c('<div class="joe_databaseResetButton jo_button jo_active" title="Datenbank auf Ausgangszustand zurücksetzen">Datenbank Reset</div>'),l.append(this.$monacoDiv,this.$hintDiv,this.$databaseResetButton),this.$monacoDiv.append(this.$codeResetButton),this.$codeResetButton.hide(),this.$codeResetButton.on("click",()=>{n.show()}),this.$databaseResetButton.hide(),this.$databaseResetButton.on("click",()=>{r.show()}),this.$hintDiv.hide();let d=c('<div class="joe_controlsDiv"></div>'),u=c('<div class="joe_bottomDivInner"></div>'),m=c('<div class="joe_bottomDiv"></div>');if(this.makeBottomDiv(u,d),m.append(u),this.config.withFileList){let y=this.makeFilesDiv();m.prepend(y),new Ie(y,!1,!1,()=>{})}e.append(m),e.addClass("joe_javaOnlineDiv"),this.editor=new vt(this,!1,!0),this.editor.initGUI(this.$monacoDiv),this.$monacoDiv.find(".monaco-editor").css("z-index","10"),e.attr("tabindex")==null&&e.attr("tabindex","0"),this.actionManager=new ft(e,this),this.actionManager.init(),this.bottomDiv=new _t(this,u,e),this.bottomDiv.initGUI(),this.rightDiv=new Et(this,this.$rightDivInner),this.rightDiv.initGUI(),t.append(l,m),e.append(o);let f=c('<div class="jo_rightdiv-rightside-container"></div>'),p=c('<div class="jo_button jo_active img_ellipsis-dark" style="margin-right: 10px"></div>');d.append(p),this.$rightDivInner.append(f),new Ie(o,!0,!1,()=>{this.editor.editor.layout()},t),new Ie(m,!0,!0,()=>{this.editor.editor.layout()}),p.on("mouseup",y=>{y.preventDefault(),y.stopPropagation(),R([{caption:"Über die Online-IDE ...",link:"https://learnj.de",callback:()=>{}}],y.pageX+2,y.pageY+2)});let b=c('<label type="file" class="img_open-file jo_button jo_active"style="margin-right: 8px;" title="Datenbank-Dump aus Datei laden"><input type="file" style="display:none"></label>'),k=this,g=b.find("input");g.on("change",y=>{var J=y.originalEvent.target.files;k.loadDatabaseFromFile(J[0]).then(()=>{g.val(null)})});let w=c('<div class="img_save-dark jo_button jo_active"style="margin-right: 8px;" title="Datenbank-Dump in Datei speichern"></div>');w.on("click",()=>{k.saveDatabaseToFile()}),d.append(b,w),this.resultsetPresenter=new He(this,u),this.resultsetPresenter.addWriteQueryListener(this.writeQueryManager),new St(this,d),this.historyViewer=new yt(this,e.find(".jo_historyTab")),setTimeout(()=>{this.editor.editor.layout(),this.compiler=new ct(this),this.startTimer()},200)}saveDatabaseToFile(){new xe().saveToFile(this.databaseTool)}async loadDatabaseFromFile(e){let i=await new xe().loadFromFile(e,this);if(i==null){alert("Es ist ein Fehler beim Import aufgetreten.");return}else this.databaseTool.initializeWorker(i.binDump,[],n=>{n.length>0&&(alert("Es sind Fehler beim Import aufgetreten. Ausführliche Fehlermeldungen sehen Sie in der Konsole (F12)."),console.log(n))},()=>{this.databaseExplorer.refreshAfterRetrievingDBStructure()})}makeWaitDiv(){let e=`
221
+ <div class="jo_delete img_delete jo_button jo_active" title="Datei löschen"></div></div></div>`);this.$fileListDiv.append(i);let n={module:e,$fileDiv:i,type:"sql"};return this.files.push(n),e.file.panelElement={name:e.file.name,$htmlFirstLine:i,isFolder:!1,path:[]},i.find(".jo_delete").on("mousedown",r=>{t.onDelete(n,r)}),i.find(".jo_delete").on("click",r=>{r.preventDefault(),r.stopPropagation()}),i.on("click",r=>{t.selectFile(n)}),i[0].addEventListener("contextmenu",function(r){r.preventDefault(),R([{caption:"Umbenennen",callback:()=>{t.renameElement(n,()=>{})}}],r.pageX,r.pageY)},!1),n}onDelete(e,t){t.preventDefault(),t.stopPropagation();let i=this;R([{caption:"Abbrechen",callback:()=>{}},{caption:"Ich bin mir sicher: löschen!",color:"#ff6060",callback:()=>{i.removeFile(e)}}],t.pageX+2,t.pageY+2)}removeFile(e){e.$fileDiv.remove(),this.main.removeModule(e.module),this.files=this.files.filter(t=>t!=e),this.currentFile==e&&(this.files.length>0?this.selectFile(this.files[0]):(this.main.getMonacoEditor().setValue("Keine Datei vorhanden."),this.main.getMonacoEditor().updateOptions({readOnly:!0}))),this.files.forEach(t=>{t.module!=null&&(t.module.file.saved=!1)})}removeModule(e){for(let t of this.files)t.module==e&&this.removeFile(t)}renameElement(e,t){let i=e.$fileDiv.find(".jo_filename"),n=e.module.file.name.indexOf("."),r=n==null?null:{start:0,end:n};bt(i,i,o=>{e.module.file.name=o,i.html(o),t!=null&&t()},r)}setFirstFileActive(){this.files.length>0&&this.selectFile(this.files[0])}selectFile(e){if(e!=null)switch(e.type){case"sql":this.main.$hintDiv.hide(),this.main.$monacoDiv.show(),this.main.setModuleActive(e.module),this.main.getMonacoEditor().focus();break;case"hint":this.main.$monacoDiv.hide(),this.main.$hintDiv.show();let t={},i=[],n=Ye({highlight:function(r,o){return i.push(r),""}});n.renderer.rules.code_inline=function(r,o,l,d,u){var m=r[o];return i.push(m.content),""},n.render(e.hint),this.colorize(i,t,()=>{let r=Ye({highlight:function(l,d){return t[l]}});r.renderer.rules.code_inline=function(l,d,u,m,f){var p=l[d];return t[p.content].replace("<br/>","")};let o=r.render(e.hint);this.main.$hintDiv.html(o)}),this.$fileListDiv.find(".jo_file").removeClass("jo_active"),e.$fileDiv.addClass("jo_active");break}}colorize(e,t,i){let n=this;if(e.length>0){let r=e.pop();x.colorize(r,"myJava",{tabSize:3}).then(o=>{t[r]=o,n.colorize(e,t,i)})}else i()}markFile(e){this.$fileListDiv.find(".jo_file").removeClass("jo_active"),this.currentFile=this.files.find(t=>t.module==e),this.currentFile!=null&&this.currentFile.$fileDiv.addClass("jo_active")}}class Vi{constructor(e){h(this,"scriptsTable");h(this,"databasesTable");this.databaseIdentifier=e}open(e){try{this.scriptsTable=window.store.sqlideScripts,this.databasesTable=window.store.sqlideDatabases,this.scriptsTable&&this.databasesTable?e():console.log("Dexie tables not available at window.store")}catch(t){console.log("Couldn't access Dexie tables: "+t)}}writeScript(e,t){this.scriptsTable.put({scriptId:e,script:t}).catch(i=>{console.error("Error writing script: ",i)})}removeScript(e){this.scriptsTable.delete(e).catch(t=>{console.error("Error removing script: ",t)})}getScript(e,t){this.scriptsTable.get(e).then(i=>{i==null?t(null):t(i.script)}).catch(i=>{console.error("Error getting script: ",i),t(null)})}writeDatabase(e,t){this.databasesTable.put({databaseId:e,database:t}).catch(i=>{console.error("Error writing database: ",i)})}removeDatabase(e){this.databasesTable.delete(e).catch(t=>{console.error("Error removing database: ",t)})}getDatabase(e,t){this.databasesTable.get(e).then(i=>{i==null?t(null):t(i.database)}).catch(i=>{console.error("Error getting database: ",i),t(null)})}}class Gi{constructor(e){this.module=e}getName(){return this.module.file.name}getText(){return this.module.getProgramTextFromMonacoModel()}}class Qi{constructor(e){this.ide=e}getFiles(){return this.ide.getCurrentWorkspace().moduleStore.getModules(!1).map(e=>new Gi(e))}}const he=class he{static registerIDE(e){he.ideMap.set(e.config.id,new Qi(e))}getIDE(e){return he.ideMap.get(e)}};h(he,"ideMap",new Map);let De=he;class Ie{constructor(e,t,i,n,r){h(this,"$sliderDiv");this.$container=e,this.firstLast=t,this.horVert=i,this.callback=n,this.$otherDiv=r,this.initSlider()}initSlider(){let e=this;this.$otherDiv==null&&this.$container.parent().children().each((t,i)=>{i!=this.$container[0]&&(e.$otherDiv=c(i))}),this.$sliderDiv=c('<div class="joe_slider"></div>'),this.$sliderDiv.css({width:this.horVert?"100%":"4px",height:this.horVert?"4px":"100%",cursor:this.horVert?"row-resize":"col-resize"}),this.firstLast?this.$sliderDiv.css({top:"0px",left:"0px"}):this.horVert?this.$sliderDiv.css({bottom:"0px",left:"0px"}):this.$sliderDiv.css({top:"0px",right:"0px"}),this.$container.append(this.$sliderDiv),this.$sliderDiv.on("mousedown",t=>{let i=t.clientX,n=t.clientY;c(document).on("mousemove.slider",r=>{let o=r.clientX-i,l=r.clientY-n;e.slide(o,l),i=r.clientX,n=r.clientY}),c(document).on("mouseup.slider",()=>{c(document).off("mousemove.slider"),c(document).off("mouseup.slider")})}),setTimeout(()=>{e.slide(1,1)},600)}setColor(e){this.$sliderDiv.css("background-color",e)}slide(e,t){if(this.horVert){let i=Number.parseInt(this.$container.css("height").replace("px","")),n=Number.parseInt(this.$otherDiv.css("height").replace("px","")),r=this.firstLast?i-=t:i+=t,o=this.firstLast?n+=t:n-=t;this.$container.css("height",r+"px"),this.$otherDiv.css("height",o+"px"),this.callback(r)}else{let i=Number.parseInt(this.$container.css("width").replace("px","")),n=Number.parseInt(this.$otherDiv.css("width").replace("px","")),r=this.firstLast?i-=e:i+=e,o=this.firstLast?n+=e:n-=e;this.$container.css("width",r+"px"),this.$otherDiv.css("width",o+"px"),this.callback(r)}this.$container.css("flex","0 1 auto")}}class Zi{constructor(e,t){h(this,"indexedDB");h(this,"databaseTool");h(this,"statementsToExecute",[]);h(this,"writtenStatements",[]);h(this,"statementsToWrite",[]);h(this,"atLeastOneExecuted",!1);h(this,"count");this.main=e,this.databaseIdentifier=t}indexedDBReady(e){this.indexedDB=e,this.indexedDB.getDatabase(this.databaseIdentifier,t=>{t!=null&&(this.writtenStatements=JSON.parse(t),this.statementsToExecute=this.writtenStatements.slice(),this.main.historyViewer.clear(),this.main.historyViewer.appendStatements(this.statementsToExecute),this.executeStatements(),this.writeStatementsIfNecessary())})}reset(){this.statementsToWrite=[],this.writtenStatements=[],this.statementsToExecute=[],this.main.historyViewer.clear(),this.forceWriteStatements()}writeStatementsIfNecessary(){this.indexedDB!=null&&this.statementsToWrite.length>0&&this.forceWriteStatements()}forceWriteStatements(){this.writtenStatements=this.writtenStatements.concat(this.statementsToWrite),this.statementsToWrite=[],this.indexedDB.writeDatabase(this.databaseIdentifier,JSON.stringify(this.writtenStatements))}executeStatements(){if(this.databaseTool!=null&&this.statementsToExecute.length>0){this.atLeastOneExecuted||(this.main.$databaseResetButton.fadeIn(200),this.count=this.statementsToExecute.length,this.main.waitOverlay.show("Schreibe lokale Datenbankänderungen ...")),this.main.waitOverlay.setProgress(Math.round(100*(1-this.statementsToExecute.length/this.count))+" %");let e=this.statementsToExecute.shift();this.atLeastOneExecuted=!0,this.databaseTool.executeQuery(e,()=>{this.executeStatements()},()=>{this.executeStatements()})}else this.atLeastOneExecuted&&(this.main.databaseExplorer.refresh(),this.atLeastOneExecuted=!1,this.main.waitOverlay.hide())}notify(e){this.main.$databaseResetButton.fadeIn(200);let t=e.map(i=>i.sqlCleaned==null?i.sql:i.sqlCleaned);this.statementsToWrite=this.statementsToWrite.concat(t),this.main.historyViewer.appendStatements(t),this.writeStatementsIfNecessary()}databaseReady(e){this.databaseTool=e,this.executeStatements()}rollback(){this.writeStatementsIfNecessary(),this.writtenStatements.pop(),this.forceWriteStatements()}}const Ji="data:image/svg+xml,%3csvg%20width='105'%20height='105'%20viewBox='0%200%20105%20105'%20xmlns='http://www.w3.org/2000/svg'%20fill='%23fff'%3e%3ccircle%20cx='12.5'%20cy='12.5'%20r='12.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='0s'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3ccircle%20cx='12.5'%20cy='52.5'%20r='12.5'%20fill-opacity='.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='100ms'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3ccircle%20cx='52.5'%20cy='12.5'%20r='12.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='300ms'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3ccircle%20cx='52.5'%20cy='52.5'%20r='12.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='600ms'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3ccircle%20cx='92.5'%20cy='12.5'%20r='12.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='800ms'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3ccircle%20cx='92.5'%20cy='52.5'%20r='12.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='400ms'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3ccircle%20cx='12.5'%20cy='92.5'%20r='12.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='700ms'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3ccircle%20cx='52.5'%20cy='92.5'%20r='12.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='500ms'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3ccircle%20cx='92.5'%20cy='92.5'%20r='12.5'%3e%3canimate%20attributeName='fill-opacity'%20begin='200ms'%20dur='1s'%20values='1;.2;1'%20calcMode='linear'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3c/svg%3e";class Yi{constructor(e,t){h(this,"config");h(this,"editor");h(this,"programPointerDecoration",[]);h(this,"programPointerModule");h(this,"currentWorkspace");h(this,"actionManager");h(this,"compiler");h(this,"$dbTreeDiv");h(this,"$debuggerDiv");h(this,"bottomDiv");h(this,"$filesListDiv");h(this,"$hintDiv");h(this,"$monacoDiv");h(this,"$codeResetButton");h(this,"$databaseResetButton");h(this,"programIsExecutable",!1);h(this,"version",0);h(this,"timerHandle");h(this,"rightDiv");h(this,"$rightDivInner");h(this,"fileExplorer");h(this,"debounceDiagramDrawing");h(this,"indexedDB");h(this,"compileRunsAfterCodeReset",0);h(this,"semicolonAngel");h(this,"databaseTool");h(this,"databaseExplorer");h(this,"waitOverlay");h(this,"resultsetPresenter");h(this,"writeQueryManager");h(this,"historyViewer");h(this,"initialTemplateDump");h(this,"initialStatements");this.scriptList=t,this.readConfig(e),this.writeQueryManager=new Zi(this,(this.config.databaseURL==null?"Empty database":this.config.databaseURL)+this.config.id),this.initGUI(e),this.databaseExplorer=new yt(this,this.$dbTreeDiv),this.databaseTool=new W(this),this.config.databaseURL!=null?new Hi(this).load(this.config.databaseURL,this.getWaitOverlay()).then(i=>{this.initialTemplateDump=i.binDump,this.initialStatements=i.statements==null?[]:i.statements,this.initDatabase()}).catch(i=>{alert("Fehler beim Laden der Datenbank: "+i)}):this.initDatabase(),this.semicolonAngel=new pt(this),this.config.enableFileAccess&&(window.sql_ide_access=new De,De.registerIDE(this))}isEmbedded(){return!0}getCompiler(){return this.compiler}getCurrentWorkspace(){return this.currentWorkspace}getMonacoEditor(){return this.editor.editor}getRightDiv(){return this.rightDiv}getBottomDiv(){return this.bottomDiv}getActionManager(){return this.actionManager}getCurrentlyEditedModule(){var e;return this.config.withFileList?(e=this.fileExplorer.currentFile)==null?void 0:e.module:this.currentWorkspace.moduleStore.getFirstModule()}getDatabaseTool(){return this.databaseTool}getDatabaseExplorer(){return this.databaseExplorer}getResultsetPresenter(){return this.resultsetPresenter}getWaitOverlay(){return this.waitOverlay}getHistoryViewer(){return this.historyViewer}initDatabase(){this.resetDatabase(()=>{this.initScripts(),this.indexedDB=new Vi("SQL-IDE"),this.indexedDB.open(()=>{this.config.id!=null&&(this.writeQueryManager.indexedDBReady(this.indexedDB),this.readScripts())})})}resetDatabase(e){this.databaseTool.initializeWorker(this.initialTemplateDump,this.initialStatements,()=>{},()=>{this.writeQueryManager.databaseReady(this.databaseTool),this.databaseExplorer.refreshAfterRetrievingDBStructure(),e()})}initScripts(){var e;(e=this.fileExplorer)==null||e.removeAllFiles(),this.initWorkspace(this.scriptList),this.config.withFileList?(this.fileExplorer=new Ki(this.currentWorkspace.moduleStore,this.$filesListDiv,this),this.fileExplorer.setFirstFileActive(),this.scriptList.filter(t=>t.type=="hint").forEach(t=>this.fileExplorer.addHint(t))):this.setModuleActive(this.currentWorkspace.moduleStore.getFirstModule())}readConfig(e){let t=e.data("sql-online");t!=null&&typeof t=="string"?this.config=JSON.parse(t.split("'").join('"')):this.config={},this.config.withFileList==null&&(this.config.withFileList=!1),this.config.withOutput==null&&(this.config.withOutput=!0),this.config.withErrorList==null&&(this.config.withErrorList=!0),this.config.withBottomPanel==null&&(this.config.withBottomPanel=!0),this.config.withOutput||this.config.withFileList||this.config.withErrorList||(this.config.withBottomPanel=!1),this.config.withBottomPanel||(this.config.withFileList=!1,this.config.withOutput=!1,this.config.withErrorList=!1),this.config.databaseURL!=null&&["http:","https:"].forEach(i=>{this.config.databaseURL.startsWith(i)&&!this.config.databaseURL.startsWith(i+"://")&&(this.config.databaseURL=this.config.databaseURL.replace(i,i+"//"))})}setModuleActive(e){this.config.withFileList&&this.fileExplorer.currentFile!=null&&(this.fileExplorer.currentFile.module.editorState=this.getMonacoEditor().saveViewState()),this.config.withFileList&&this.fileExplorer.markFile(e),this.getMonacoEditor().updateOptions({readOnly:!1,lineNumbersMinChars:4}),this.editor.editor.setModel(e.model),e.editorState!=null&&this.getMonacoEditor().restoreViewState(e.editorState)}readScripts(){let e=this.currentWorkspace.moduleStore.getModules(!1),t=this;this.indexedDB.getScript(this.config.id,i=>{var n;if(i==null)setInterval(()=>{t.saveScripts()},1e3);else{let r=JSON.parse(i),o=r.length;for(let l of e)(n=t.fileExplorer)==null||n.removeModule(l),t.removeModule(l);for(let l of r){let d=this.config.id+l;this.indexedDB.getScript(d,u=>{var m,f;if(u!=null){let p=t.addModule({title:l,text:u,type:"sql"});(m=t.fileExplorer)==null||m.addModule(p),t.$codeResetButton.fadeIn(1e3)}if(o--,o==0&&(setInterval(()=>{t.saveScripts()},1e3),(f=t.fileExplorer)==null||f.setFirstFileActive(),t.fileExplorer==null)){let p=t.currentWorkspace.moduleStore.getModules(!1);p.length>0&&t.setModuleActive(p[0])}})}}})}saveScripts(){let e=this.currentWorkspace.moduleStore.getModules(!1),t=[],i=!1;if(e.forEach(n=>i=i||!n.file.saved),i){for(let n of e){t.push(n.file.name);let r=this.config.id+n.file.name;this.indexedDB.writeScript(r,n.getProgramTextFromMonacoModel()),n.file.saved=!0}this.indexedDB.writeScript(this.config.id,JSON.stringify(t))}}deleteScriptsInDB(){this.indexedDB.getScript(this.config.id,e=>{if(e!=null){let t=JSON.parse(e);for(let i of t){let n=this.config.id+i;this.indexedDB.removeScript(n)}this.indexedDB.removeScript(this.config.id)}})}initWorkspace(e){this.currentWorkspace=new ie("Embedded-Workspace",this,0);for(let t of e)t.type=="sql"&&this.addModule(t)}addModule(e){let t=U.restoreFromData({id:this.currentWorkspace.moduleStore.getModules(!0).length,name:e.title,text:e.text,text_before_revision:null,submitted_date:null,student_edited_after_revision:!1,version:1,workspace_id:0,forceUpdate:!1,file_type:11},this);this.currentWorkspace.moduleStore.putModule(t);let i=this;return t.model.onDidChangeContent(()=>{i.considerShowingCodeResetButton()}),t}removeModule(e){this.currentWorkspace.moduleStore.removeModule(e)}initGUI(e){e.css({"background-image":"none","background-size":"100%"});let t=c('<div class="joe_centerDiv"></div>');e.append(t);let i=this.makeWaitDiv();e.append(i),this.waitOverlay=new Tt(i);let n=this.makeCodeResetModalWindow(e),r=this.makeDatabaseResetModalWindow(e),o=this.makeRightDiv(),l=c('<div class="joe_editorDiv"></div>');this.$monacoDiv=c('<div class="joe_monacoDiv"></div>'),this.$hintDiv=c('<div class="joe_hintDiv jo_scrollable"></div>'),this.$codeResetButton=c('<div class="joe_codeResetButton jo_button jo_active" title="Code auf Ausgangszustand zurücksetzen">Code Reset</div>'),this.$databaseResetButton=c('<div class="joe_databaseResetButton jo_button jo_active" title="Datenbank auf Ausgangszustand zurücksetzen">Datenbank Reset</div>'),l.append(this.$monacoDiv,this.$hintDiv,this.$databaseResetButton),this.$monacoDiv.append(this.$codeResetButton),this.$codeResetButton.hide(),this.$codeResetButton.on("click",()=>{n.show()}),this.$databaseResetButton.hide(),this.$databaseResetButton.on("click",()=>{r.show()}),this.$hintDiv.hide();let d=c('<div class="joe_controlsDiv"></div>'),u=c('<div class="joe_bottomDivInner"></div>'),m=c('<div class="joe_bottomDiv"></div>');if(this.makeBottomDiv(u,d),m.append(u),this.config.withFileList){let y=this.makeFilesDiv();m.prepend(y),new Ie(y,!1,!1,()=>{})}e.append(m),e.addClass("joe_javaOnlineDiv"),this.editor=new Ct(this,!1,!0),this.editor.initGUI(this.$monacoDiv),this.$monacoDiv.find(".monaco-editor").css("z-index","10"),e.attr("tabindex")==null&&e.attr("tabindex","0"),this.actionManager=new gt(e,this),this.actionManager.init(),this.bottomDiv=new Lt(this,u,e),this.bottomDiv.initGUI(),this.rightDiv=new _t(this,this.$rightDivInner),this.rightDiv.initGUI(),t.append(l,m),e.append(o);let f=c('<div class="jo_rightdiv-rightside-container"></div>'),p=c('<div class="jo_button jo_active img_ellipsis-dark" style="margin-right: 10px"></div>');d.append(p),this.$rightDivInner.append(f),new Ie(o,!0,!1,()=>{this.editor.editor.layout()},t),new Ie(m,!0,!0,()=>{this.editor.editor.layout()}),p.on("mouseup",y=>{y.preventDefault(),y.stopPropagation(),R([{caption:"Über die Online-IDE ...",link:"https://learnj.de",callback:()=>{}}],y.pageX+2,y.pageY+2)});let b=c('<label type="file" class="img_open-file jo_button jo_active"style="margin-right: 8px;" title="Datenbank-Dump aus Datei laden"><input type="file" style="display:none"></label>'),k=this,g=b.find("input");g.on("change",y=>{var J=y.originalEvent.target.files;k.loadDatabaseFromFile(J[0]).then(()=>{g.val(null)})});let w=c('<div class="img_save-dark jo_button jo_active"style="margin-right: 8px;" title="Datenbank-Dump in Datei speichern"></div>');w.on("click",()=>{k.saveDatabaseToFile()}),d.append(b,w),this.resultsetPresenter=new Ve(this,u),this.resultsetPresenter.addWriteQueryListener(this.writeQueryManager),new Dt(this,d),this.historyViewer=new xt(this,e.find(".jo_historyTab")),setTimeout(()=>{this.editor.editor.layout(),this.compiler=new ft(this),this.startTimer()},200)}saveDatabaseToFile(){new Se().saveToFile(this.databaseTool)}async loadDatabaseFromFile(e){let i=await new Se().loadFromFile(e,this);if(i==null){alert("Es ist ein Fehler beim Import aufgetreten.");return}else this.databaseTool.initializeWorker(i.binDump,[],n=>{n.length>0&&(alert("Es sind Fehler beim Import aufgetreten. Ausführliche Fehlermeldungen sehen Sie in der Konsole (F12)."),console.log(n))},()=>{this.databaseExplorer.refreshAfterRetrievingDBStructure()})}makeWaitDiv(){let e=`
222
222
  <div class="bitteWarten">
223
223
  <div style="margin-bottom: 30px">
224
224
  <div class="bitteWartenText" style="font-size: 20px"></div>
@@ -264,11 +264,11 @@ Error : `+n),this.executeStatementsString(e,t+1,i)}):i()}executeStatements(e,t,i
264
264
  </div>
265
265
  <div style="flex: 2"></div>
266
266
  </div>
267
- `);return t.hide(),e.append(t),e.find(".joe_databaseResetModalCancel").on("click",()=>{t.hide()}),e.find(".joe_databaseResetModalOK").on("click",()=>{t.hide(),this.resetDatabase(()=>{this.writeQueryManager.reset()}),this.$databaseResetButton.hide(),this.compileRunsAfterCodeReset=1}),t}makeFilesDiv(){let e=c('<div class="joe_bottomDivFiles jo_scrollable"></div>'),t=c('<div class="joe_filesHeader jo_tabheading jo_active" style="line-height: 24px">Dateien</div>');return this.$filesListDiv=c('<div class="joe_filesList jo_scrollable"></div>'),e.append(t,this.$filesListDiv),e}startTimer(){this.timerHandle!=null&&clearInterval(this.timerHandle);let e=this;this.timerHandle=setInterval(()=>{e.compileIfDirty()},500)}compileIfDirty(){var e,t;if(this.currentWorkspace!=null&&this.currentWorkspace.moduleStore.isDirty()&&this.compiler.compilerStatus!=fe.compiling&&this.getDatabaseTool().databaseStructure!=null)try{this.compiler.compile(this.currentWorkspace.moduleStore);let i=(t=(e=this.bottomDiv)==null?void 0:e.errorManager)==null?void 0:t.showErrors(this.currentWorkspace);this.editor.onDidChangeCursorPosition(null),this.version++}catch(i){console.error(i),this.compiler.compilerStatus=fe.error}}considerShowingCodeResetButton(){this.compileRunsAfterCodeReset++,this.compileRunsAfterCodeReset==3&&this.$codeResetButton.fadeIn(1e3)}makeBottomDiv(e,t){let i=c('<div class="jo_tabheadings"></div>');i.css("position","relative");let n=c('<div class="joe_tabheading-right jo_noHeading joe_controlsTabheading"></div>');if(n.append(t),i.append(n),this.config.withErrorList){let u=c('<div class="jo_tabheading jo_active" data-target="jo_errorsTab" style="line-height: 24px">Fehler</div>');i.append(u)}if(this.config.withOutput){let u=c('<div class="jo_tabheading jo_resultTabheading" data-target="jo_resultTab" style="line-height: 24px">Ausgabe</div>');i.append(u)}let r=c('<div class="jo_tabheading jo_historyTabheading" data-target="jo_historyTab" style="line-height: 24px">History</div>');i.append(r);let o=c('<div class="joe_tabheading-right jo_noHeading joe_paginationHeading"><div class="jo_pagination"></div></div>');i.append(o),e.append(i);let l=c('<div class="jo_tabs jo_scrollable"></div>');if(this.config.withErrorList){let u=c('<div class="jo_active jo_scrollable jo_errorsTab"></div>');l.append(u)}if(this.config.withOutput){let u=c(`<div class="jo_editorFontSize jo_resultTab">
267
+ `);return t.hide(),e.append(t),e.find(".joe_databaseResetModalCancel").on("click",()=>{t.hide()}),e.find(".joe_databaseResetModalOK").on("click",()=>{t.hide(),this.resetDatabase(()=>{this.writeQueryManager.reset()}),this.$databaseResetButton.hide(),this.compileRunsAfterCodeReset=1}),t}makeFilesDiv(){let e=c('<div class="joe_bottomDivFiles jo_scrollable"></div>'),t=c('<div class="joe_filesHeader jo_tabheading jo_active" style="line-height: 24px">Dateien</div>');return this.$filesListDiv=c('<div class="joe_filesList jo_scrollable"></div>'),e.append(t,this.$filesListDiv),e}startTimer(){this.timerHandle!=null&&clearInterval(this.timerHandle);let e=this;this.timerHandle=setInterval(()=>{e.compileIfDirty()},500)}compileIfDirty(){var e,t;if(this.currentWorkspace!=null&&this.currentWorkspace.moduleStore.isDirty()&&this.compiler.compilerStatus!=pe.compiling&&this.getDatabaseTool().databaseStructure!=null)try{this.compiler.compile(this.currentWorkspace.moduleStore);let i=(t=(e=this.bottomDiv)==null?void 0:e.errorManager)==null?void 0:t.showErrors(this.currentWorkspace);this.editor.onDidChangeCursorPosition(null),this.version++}catch(i){console.error(i),this.compiler.compilerStatus=pe.error}}considerShowingCodeResetButton(){this.compileRunsAfterCodeReset++,this.compileRunsAfterCodeReset==3&&this.$codeResetButton.fadeIn(1e3)}makeBottomDiv(e,t){let i=c('<div class="jo_tabheadings"></div>');i.css("position","relative");let n=c('<div class="joe_tabheading-right jo_noHeading joe_controlsTabheading"></div>');if(n.append(t),i.append(n),this.config.withErrorList){let u=c('<div class="jo_tabheading jo_active" data-target="jo_errorsTab" style="line-height: 24px">Fehler</div>');i.append(u)}if(this.config.withOutput){let u=c('<div class="jo_tabheading jo_resultTabheading" data-target="jo_resultTab" style="line-height: 24px">Ausgabe</div>');i.append(u)}let r=c('<div class="jo_tabheading jo_historyTabheading" data-target="jo_historyTab" style="line-height: 24px">History</div>');i.append(r);let o=c('<div class="joe_tabheading-right jo_noHeading joe_paginationHeading"><div class="jo_pagination"></div></div>');i.append(o),e.append(i);let l=c('<div class="jo_tabs jo_scrollable"></div>');if(this.config.withErrorList){let u=c('<div class="jo_active jo_scrollable jo_errorsTab"></div>');l.append(u)}if(this.config.withOutput){let u=c(`<div class="jo_editorFontSize jo_resultTab">
268
268
  <div class="jo_result-inner">
269
269
  <div class="jo_result-header"></div>
270
270
  <div class="jo_scrollable jo_result-body"></div>
271
271
  </div>
272
272
  </div>
273
- `);l.append(u)}let d=c('<div class="jo_scrollable jo_historyTab"></div>');l.append(d),e.append(l)}makeRightDiv(){let e=c('<div class="joe_rightDiv"></div>');this.$rightDivInner=c('<div class="joe_rightDivInner"></div>'),e.append(this.$rightDivInner);let t=c('<div class="jo_tabheadings"></div>');t.css("position","relative");let i=c('<div class="jo_tabheading jo_active" data-target="jo_db_tree" style="line-height: 24px">DB (Baum)</div>');t.append(i),this.$rightDivInner.append(t);let n=c('<div class="jo_tabs jo_scrollable"></div>');return this.$dbTreeDiv=c('<div class="jo_tab jo_scrollable jo_editorFontSize jo_active jo_db_tree">DB-Baum</div>'),n.append(this.$dbTreeDiv),this.$rightDivInner.append(n),Te(e),e}getSemicolonAngel(){return this.semicolonAngel}}function Xi(){self.MonacoEnvironment={getWorker:(a,e)=>{switch(e){case"json":return new Bt;case"css":case"scss":case"less":return new It;case"html":case"handlebars":case"razor":return new $t;case"typescript":case"javascript":return new jt;default:return new Mt}}}}class en{constructor(){h(this,"startupComplete",2);h(this,"themeManager");h(this,"mainEmbeddedList",[])}initGUI(){this.checkStartupComplete(),this.themeManager=new rt}initEditor(){new nt().init(),this.checkStartupComplete()}checkStartupComplete(){this.startupComplete--,this.startupComplete==0&&this.start()}start(){this.initJavaOnlineDivs()}initJavaOnlineDivs(){c(".sql-online").each((e,t)=>{let i=c(t),n=[];i.find("script").each((r,o)=>{let l=c(o),d="sql";l.data("type")!=null&&(d=l.data("type"));let u={type:d,title:l.attr("title"),text:l.text().trim()};n.push(u)}),this.initDiv(i,n)})}initDiv(e,t){new Yi(e,t)}}c(function(){let a=new en;Xi(),a.initEditor(),a.initGUI(),console.log("SQL-IDE embedded Version 2.0 vom 8.2.2026, 16:26 Uhr")});export{gn as _,bn as c,wn as g,kn as r};
273
+ `);l.append(u)}let d=c('<div class="jo_scrollable jo_historyTab"></div>');l.append(d),e.append(l)}makeRightDiv(){let e=c('<div class="joe_rightDiv"></div>');this.$rightDivInner=c('<div class="joe_rightDivInner"></div>'),e.append(this.$rightDivInner);let t=c('<div class="jo_tabheadings"></div>');t.css("position","relative");let i=c('<div class="jo_tabheading jo_active" data-target="jo_db_tree" style="line-height: 24px">DB (Baum)</div>');t.append(i),this.$rightDivInner.append(t);let n=c('<div class="jo_tabs jo_scrollable"></div>');return this.$dbTreeDiv=c('<div class="jo_tab jo_scrollable jo_editorFontSize jo_active jo_db_tree">DB-Baum</div>'),n.append(this.$dbTreeDiv),this.$rightDivInner.append(n),Le(e),e}getSemicolonAngel(){return this.semicolonAngel}}function Xi(){self.MonacoEnvironment={getWorker:(a,e)=>{switch(e){case"json":return new At;case"css":case"scss":case"less":return new Ot;case"html":case"handlebars":case"razor":return new Bt;case"typescript":case"javascript":return new It;default:return new $t}}}}class en{constructor(){h(this,"startupComplete",2);h(this,"themeManager");h(this,"mainEmbeddedList",[])}initGUI(){this.checkStartupComplete(),this.themeManager=new ot}initEditor(){new st().init(),this.checkStartupComplete()}checkStartupComplete(){this.startupComplete--,this.startupComplete==0&&this.start()}start(){this.initJavaOnlineDivs()}initJavaOnlineDivs(){c(".sql-online").each((e,t)=>{let i=c(t),n=[];i.find("script").each((r,o)=>{let l=c(o),d="sql";l.data("type")!=null&&(d=l.data("type"));let u={type:d,title:l.attr("title"),text:l.text().trim()};n.push(u)}),this.initDiv(i,n)})}initDiv(e,t){new Yi(e,t)}}c(function(){let a=new en;Xi(),a.initEditor(),a.initGUI(),console.log("SQL-IDE embedded Version 2.0 vom 13.2.2026, 09:46 Uhr")});export{gn as _,bn as c,wn as g,kn as r};
274
274
  //# sourceMappingURL=sql-ide-embedded.js.map