openchemlib
Version:
Manipulate molecules
16 lines • 1.1 MB
JavaScript
var Cl=class{copyMolecule(Z){let Bt=Z.getIDCodeAndCoordinates();navigator.clipboard.writeText(`${Bt.idCode} ${Bt.coordinates}`)}pasteMolecule(){return null}};var DS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",JU=new Uint8Array(256);for(let w=0;w<DS.length;w++)JU[DS.charCodeAt(w)]=w;function uS(w){let Z=w.length*.75,Bt=w.length,ot,Ft=0,H1,bt,y1,i1;w.at(-1)==="="&&(Z--,w.at(-2)==="="&&Z--);let L1=new ArrayBuffer(Z),u1=new Uint8Array(L1);for(ot=0;ot<Bt;ot+=4)H1=JU[w.charCodeAt(ot)],bt=JU[w.charCodeAt(ot+1)],y1=JU[w.charCodeAt(ot+2)],i1=JU[w.charCodeAt(ot+3)],u1[Ft++]=H1<<2|bt>>4,u1[Ft++]=(bt&15)<<4|y1>>2,u1[Ft++]=(y1&3)<<6|i1&63;return L1}function Ml(w){return w.toString(16).padStart(2,"0")}var hr=globalThis.devicePixelRatio||1;var z2=class{constructor(Z){this.ctx=Z,this.ctx.textAlign="left",this.ctx.textBaseline="top",this.currentFontSize=12,this.currentFont="12px sans-serif",this.ctx.font=this.currentFont,this.currentColor="#000000",this.currentLineWidth=1,this.canvasCache=new Map}clearRect(Z,Bt,ot,Ft){this.ctx.clearRect(Z,Bt,ot,Ft)}getBackgroundRGB(){return 16777215}getForegroundRGB(){return 0}getSelectionBackgroundRGB(){return 12310268}getLineWidth(){return this.currentLineWidth}setRGB(Z){let Bt=Z>>>16&255,ot=Z>>>8&255,Ft=Z>>>0&255;this.currentColor=`#${Ml(Bt)}${Ml(ot)}${Ml(Ft)}`,this.ctx.fillStyle=this.currentColor,this.ctx.strokeStyle=this.currentColor}setFont(Z,Bt,ot){this.currentFontSize=Z,this.currentFont=`${Bt?"bold":""} ${ot?"italic":""} ${Z}px sans-serif`,this.ctx.font=this.currentFont}getFontSize(){return this.currentFontSize}getBounds(Z){let Bt=this.ctx.measureText(Z);return{x:Bt.actualBoundingBoxLeft,y:Bt.actualBoundingBoxAscent,width:Bt.actualBoundingBoxRight,height:Bt.actualBoundingBoxAscent}}drawString(Z,Bt,ot){this.ctx.fillText(ot,Z,Bt)}drawCenteredString(Z,Bt,ot){this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(ot,Z,Bt),this.ctx.textAlign="left",this.ctx.textBaseline="top"}setLineWidth(Z){this.currentLineWidth=Z,this.ctx.lineWidth=Z}fillRectangle(Z,Bt,ot,Ft){this.ctx.fillRect(Z,Bt,ot,Ft)}fillCircle(Z,Bt,ot){let Ft=ot/2;this.ctx.beginPath(),this.ctx.arc(Z+Ft,Bt+Ft,Ft,0,2*Math.PI),this.ctx.fill()}drawLine(Z,Bt,ot,Ft){this.ctx.beginPath(),this.ctx.moveTo(Z,Bt),this.ctx.lineTo(ot,Ft),this.ctx.stroke()}drawPolygon(Z){this.ctx.beginPath(),this.ctx.moveTo(Z.getX(0),Z.getY(0));for(let Bt=1;Bt<Z.getSize();Bt++)this.ctx.lineTo(Z.getX(Bt),Z.getY(Bt));this.ctx.stroke()}drawRectangle(Z,Bt,ot,Ft){this.ctx.strokeRect(Z,Bt,ot,Ft)}fillPolygon(Z){this.ctx.beginPath(),this.ctx.moveTo(Z.getX(0),Z.getY(0));for(let Bt=1;Bt<Z.getSize();Bt++)this.ctx.lineTo(Z.getX(Bt),Z.getY(Bt));this.ctx.fill()}drawImage(Z,Bt,ot,Ft,H1,bt,y1,i1,L1){if(arguments.length!==9)throw new Error(`drawImage call with ${arguments.length} arguments unimplemented`);let u1=this.canvasCache.get(Z);if(!u1){u1=document.createElement("canvas");let n0=Z.imageData;u1.width=n0.width,u1.height=n0.height;let N0=u1.getContext("2d");N0.globalAlpha=0,N0.putImageData(n0,0,0),this.canvasCache.set(Z,u1)}this.ctx.drawImage(u1,Bt,ot,Ft,H1,bt,y1,i1,L1)}isDarkBackground(){return!1}};var Hl=class{constructor(Z,Bt){this.canvasElement=Z,this.changeListener=Bt,this.drawContext=new z2(this.canvasElement.getContext("2d"))}getBackgroundRGB(){return 16777215}getCanvasWidth(){return this.canvasElement.width}getCanvasHeight(){return this.canvasElement.height}getDrawContext(){return this.drawContext}onChange(Z,Bt){this.changeListener?.({what:Z,isUserEvent:Bt})}getClipboardHandler(){return new Cl}};var BPt=`
/* We can customize editor styles here. */
`,Gc;function QS(){if(Gc)return Gc;let w=new CSSStyleSheet;return w.replaceSync(BPt),Gc=w,w}function Jc(w,Z,Bt){let ot=-1;function Ft(bt,y1,i1=0){y1.button>0||Z.fireMouseEvent(bt,y1.button+1,i1,Math.round(y1.offsetX*hr),Math.round(y1.offsetY*hr),y1.shiftKey,y1.ctrlKey,y1.altKey,y1.button===2)}w.addEventListener("pointerdown",bt=>{ot===-1&&(ot=bt.pointerId,Ft(Bt.MOUSE_EVENT_PRESSED,bt))});function H1(bt){ot===bt.pointerId&&(ot=-1,Ft(Bt.MOUSE_EVENT_RELEASED,bt))}return document.addEventListener("pointerup",H1),w.addEventListener("click",bt=>{Ft(Bt.MOUSE_EVENT_CLICKED,bt,bt.detail)}),w.addEventListener("pointerenter",bt=>{Ft(Bt.MOUSE_EVENT_ENTERED,bt)}),w.addEventListener("pointerleave",bt=>{Ft(Bt.MOUSE_EVENT_EXITED,bt)}),w.addEventListener("pointermove",bt=>{ot!==-1?ot===bt.pointerId&&Ft(Bt.MOUSE_EVENT_DRAGGED,bt):Ft(Bt.MOUSE_EVENT_MOVED,bt)}),()=>{document.removeEventListener("pointerup",H1)}}function US(w,Z,Bt,ot,Ft){let H1=typeof navigator<"u"&&navigator.platform==="MacIntel",bt=i1=>H1&&i1.metaKey||!H1&&i1.ctrlKey;function y1(i1,L1){let u1=vPt(L1,ot);u1!==null&&Bt.fireKeyEvent(i1,u1,L1.altKey,L1.ctrlKey,L1.shiftKey,bt(L1))}Z.addEventListener("keydown",i1=>{bt(i1)&&i1.key==="c"||bt(i1)&&i1.key==="v"||y1(ot.KEY_EVENT_PRESSED,i1)}),Z.addEventListener("keyup",i1=>{y1(ot.KEY_EVENT_RELEASED,i1)}),w.addEventListener("paste",i1=>{let L1=i1.clipboardData.getData("text"),u1=Ft.fromText(L1);u1&&u1.getAllAtoms()>0&&Bt.addPastedOrDropped(u1)})}function vPt(w,Z){switch(w.key){case"Control":return Z.KEY_CTRL;case"Alt":return Z.KEY_ALT;case"Shift":return Z.KEY_SHIFT;case"Delete":case"Backspace":return Z.KEY_DELETE;case"F1":return Z.KEY_HELP;case"Escape":return Z.KEY_ESCAPE;case"Enter":return Z.KEY_ENTER;default:return w.key.length===1?w.key.codePointAt(0):null}}var Vl=class{constructor(Z){this.canvasElement=Z,this.drawContext=new z2(this.canvasElement.getContext("2d"))}setDimensions(Z,Bt){this.canvasElement.width=Z,this.canvasElement.style.width=`${Z/hr}px`,this.canvasElement.height=Bt,this.canvasElement.style.height=`${Bt/hr}px`}getDrawContext(){return this.drawContext}getBackgroundRGB(){return 16777215}getForegroundRGB(){return 0}};var oS={"chain.png":"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAQAAABKfvVzAAAB2UlEQVR4XmNgGJmAkYGJgQULZGXAhCygIGICQg4GdjTIARRDh5xAEQwNKYzXeK4xY1Oez3SNfz8TmoYUxq+6m9bfqLjDI4tmfhzLff9VR17FoWhwZXpkOm2v1C+79+cbD4gga8lneuhrfdv6/+ItSBpSGB+bTDos9IfzP9N/k3cX6+7wwByWz/TWR/E1w/+kO+8j4BpSGL9rz9wh+Efs14TF3heY/tu/vlF2hxtkSxzLY2/FVyz/om69jT0G8kM6QyNDM9MT41nbZX9y/J/ct1/4iU7aIYb/9q8uVx0UbmF64mV7i/1/0s0HSVM5dRgYrjB84/8U+bh80iH+34z/17Xc51ZhUGX8qpkK1GL6+krltyClVyz/c+69C57CwQsK1v+Sl9rdvgr8Z/7P9WvKxNs8fsD44ABqeWLkdYHhv9sL8e+s/xJuv4k4yajEAI6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KtMxYnA8X5tvT5cp2eehDLnVxrPPoLgWpx4Hd+8Lp/Zx7boYoe/g40eDtViIF6Se+xPX8qPl96DqECImrRMOY2fg3e1atwd16UX1cR75wEXr4VmGdxL52atbpX2HnxfTenfiJcelKr9CjvQp/IMWJ57AO62ndOKk7890/iSWBU4XaZc0AAAAASUVORK5CYII=)","fist.png":"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAQAAABKfvVzAAABj0lEQVR4Xu2S3yuDYRTHz7IZsfdCUrYLG4VCpJV6d0mS/A1zg79ArRArP4q5s4ulVousFCn/gX/g5WK7wkZMzIXMxjZ793XeMdn7vpM/wDn1PD1P53PO95znIfq3rwmYyU5tZPr7PJYoTjGaZ8xB1t+xZQqyP60iAEeWsThFGKpqbiE9CRECrnCHLnTAj17QbLV4E3mFXALbcOAGSXRiClnMgZLkZR/QYg0UEpDBDuxI4IHzT6OADdRiEK2gE12gBWmWE8Yj7weQIGOT650zaoiqAVtjDx2KeEWR8xZ4lUt+jEWkWJxJBYgkWa7NLy5WXWl5FilzhfoKwEAzzkwYI3DhTQUoVYpYR10FYCTPaDbJ2heQUwGfR0kFELmt6Utu9Jmz6dmFpmmR7v141w1XBiCBNFNacyKmCxT59kgHGBIQ4g7UkpRzESuwaCoQ+YZxqwGUGaUwrvvStqazLeRLj/bTZUTQB5rQfg1jjac9e8qAzFgZKbDMALpj1Kz3Z0WKjiGIfex++x6H98PgK4d/APiDpdwStyBoAAAAAElFTkSuQmCC)","hand.png":"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAQAAABKfvVzAAAB50lEQVR4Xq2TwUsUcRzF3yy52TboHiKVLBCElb1479g5kgKPCkKs4ME6eAiiP0GELileStew6NLJq5Sihw6BG2VlECymB2PVXd10Zl7vN+OuOjNLl35fZhiY+fzee9/vb4D/tAow9fafu90BsqrvnXzNBwSTTBAZ2I3BkSbeYBMzLHNRn9/nEFHCvYZAutDHDfb5wDvanOVnoozBhk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AzbUp92AS1GKqI7odL5F1jM9bzV7KzoyVLvfbDhKAoYZ4wGp/NFKU8Br6scS9VrM7Fw8a56/8A271ovb0pkF9m2UPy2AWGd/k4sYdpal/7+fH4cTxvaPsGo6C3EXysWYWQafIR2cqSnFyV237CM6ADOowyM8Si+xkkCsztB2RIYZCFT2QB1mYVdwSSSza/N85nD1qDl27cyA76EQ1k6bqtESiRagrXFsdyBxQq+ySnfIhtbJ6gHX2bBprQvmAHwKH/GDBmRCDyibP4Od/HLcNZ0KcCSnkmLQsKEd4mmvfgTMhybGCb0zI4RPb1bSbUtnDUvHz4yGJ7BUWx2+5Iu7Rc33AhQAAAABJRU5ErkJggg==)"};var zc=Object.create(null),LS=3/4,El=class{constructor(Z){this.HOTSPOT_32=Z.HOTSPOT_32,this.IMAGE_NAME_32=Z.IMAGE_NAME_32,this.cPointerCursor=Z.cPointerCursor,this.cTextCursor=Z.cTextCursor}getCursor(Z){if(zc[Z])return zc[Z];if(this.IMAGE_NAME_32[Z])return this.buildCursor(Z);switch(Z){case this.cPointerCursor:return"default";case this.cTextCursor:return"text";default:throw new Error(`Unknown cursor: ${Z}`)}}buildCursor(Z){let Bt=this.IMAGE_NAME_32[Z],Ft=`${oS[Bt]} ${this.HOTSPOT_32[Z*2]*LS} ${this.HOTSPOT_32[Z*2+1]*LS}, default`;return zc[Z]=Ft,Ft}};var Sl=class{constructor(Z,Bt){this.title=Z,this.rootElement=Bt,this.elements=[],this.dialogElement=null}setLayout(Z,Bt){this.hLayout=sS(Z),this.vLayout=`${sS(Bt)} auto`}add(Z,Bt,ot,Ft,H1){this.elements.push({component:Z,x:Bt,y:ot,x2:Ft,y2:H1})}createTextField(Z,Bt){return new Kc(Z,Bt)}createLabel(Z){return new Yc(Z)}createComboBox(){return new Xc}createCheckBox(Z){return new Zc(Z)}setEventConsumer(Z){this.consumer=Z}showMessage(Z){window.alert(Z)}showDialog(Z){let Bt=document.createElement("dialog"),ot=this.rootElement.getBoundingClientRect();Object.assign(Bt.style,{position:"absolute",marginBlock:0,left:`${ot.left}px`,right:`${document.body.parentElement.clientWidth-ot.right}px`,top:`${this.rootElement.offsetTop+30}px`}),this.dialogElement=Bt,this.rootElement.getRootNode().append(Bt);let Ft=document.createElement("form");Ft.style.display="grid",Ft.style.gridTemplateColumns=this.hLayout,Ft.style.gridTemplateRows=this.vLayout,Ft.addEventListener("submit",i1=>{i1.preventDefault(),this.consumer.fireOk(),Z()}),Bt.append(Ft);for(let{component:i1,x:L1,y:u1,x2:n0,y2:N0}of this.elements){let H0=document.createElement("div");n0===void 0?(H0.style.gridColumn=`${L1+1} / ${L1+2}`,H0.style.gridRow=`${u1+1} / ${u1+2}`):(H0.style.gridColumn=`${L1+1} / ${n0+2}`,H0.style.gridRow=`${u1+1} / ${N0+2}`),H0.append(i1.getElement()),Ft.append(H0)}let H1=document.createElement("div");Object.assign(H1.style,{display:"flex",flexDirection:"row-reverse",gap:"15px",gridColumn:"1 / -1",gridRow:"-1"}),Ft.append(H1);let bt=document.createElement("button");bt.type="submit",bt.textContent="OK",H1.append(bt);let y1=document.createElement("button");y1.type="button",y1.textContent="Cancel",y1.addEventListener("click",()=>{this.consumer.fireCancel(),Z()}),H1.append(y1),Bt.showModal(),Bt.addEventListener("cancel",()=>{this.consumer.fireCancel(),Z()})}disposeDialog(){this.dialogElement!==null&&(this.dialogElement.remove(),this.dialogElement=null)}},Y2=class{setEventHandler(Z){this.eventHandler=Z}fireEvent(Z,Bt){this.eventHandler(Z,Bt)}},Yc=class extends Y2{constructor(Z){super(),this.element=document.createElement("label"),this.setText(Z)}setText(Z){this.element.textContent=Z}getElement(){return this.element}},Kc=class extends Y2{constructor(){super(),this.element=document.createElement("input"),this.element.type="text"}setText(Z){this.element.value=Z}getText(){return this.element.value}getElement(){return this.element}},Xc=class extends Y2{constructor(){super(),this.element=document.createElement("select"),this.element.addEventListener("change",()=>{this.fireEvent(2,this.element.selectedIndex)})}setEnabled(Z){this.element.disabled=!Z}addItem(Z){let Bt=document.createElement("option");Bt.textContent=Z,this.element.append(Bt)}getSelectedIndex(){return this.element.selectedIndex}setSelectedIndex(Z){this.element.selectedIndex=Z}setSelectedItem(Z){let Bt=this.element.options;for(let ot=0;ot<Bt.length;ot++)Bt[ot].textContent===Z&&(this.element.selectedIndex=ot)}getSelectedItem(){return this.element.options[this.element.selectedIndex].textContent}removeAllItems(){this.element.innerHTML=""}setEditable(){}getElement(){return this.element}},Zc=class extends Y2{constructor(Z){super();let Bt=document.createElement("label"),ot=document.createElement("input");ot.type="checkbox",ot.addEventListener("change",()=>{this.fireEvent(3,ot.checked?1:0)}),Bt.append(ot),Bt.append(Z),this.element=Bt,this.checkBox=ot}setEnabled(Z){this.checkBox.disabled=!Z}isSelected(){return this.checkBox.checked}setSelected(Z){this.checkBox.checked=Z}getElement(){return this.element}};function sS(w){return w.map(Z=>Z>0?`${Z}px`:"auto").join(" ")}var zU=class{constructor(Z){this.imageData=Z,this.dataView=new DataView(Z.data.buffer)}getWidth(){return this.imageData.width}getHeight(){return this.imageData.height}getRGB(Z,Bt){let ot=this.dataView.getInt32((Bt*this.imageData.width+Z)*4,!1);return(ot&255)<<24|ot>>>8}setRGB(Z,Bt,ot){let Ft=ot>>>24&255,H1=ot<<8|Ft;this.dataView.setInt32((Bt*this.imageData.width+Z)*4,H1,!1)}toDataURL(){let Z=document.createElement("canvas"),Bt=Z.getContext("2d");return Z.width=this.imageData.width,Z.height=this.imageData.height,Bt.putImageData(this.imageData,0,0),Z.toDataURL("image/png")}};var ql=class{constructor(Z,Bt,ot){this.canvasElement=Z,this.dialogRoot=Bt,this.JavaEditorArea=ot}register(Z){this.javaUiHelper=Z,this.cursorManager=new El(this.JavaEditorArea,Z)}grabFocus(){this.canvasElement.focus({preventScroll:!0})}setCursor(Z){this.canvasElement.style.cursor=this.cursorManager.getCursor(Z)}showHelpDialog(){}createImage(Z,Bt){let ot=new ImageData(Z,Bt);return new zU(ot)}createImageFromBase64(Z,Bt,ot){ot=ot.replaceAll(/%\d+%/g,y1=>"A".repeat(Number(y1.slice(1,-1))));let Ft=uS(ot),H1=new Uint8ClampedArray(Ft),bt=new ImageData(H1,Z,Bt);return new zU(bt)}createDialog(Z){return new Sl(Z,this.dialogRoot)}runLater(Z){typeof requestAnimationFrame=="function"?requestAnimationFrame(Z):typeof setImmediate=="function"?setImmediate(Z):setTimeout(Z,0)}};function yS(w,Z,Bt,ot,Ft,H1,bt,y1){let{readOnly:i1=!1,initialMode:L1="molecule",initialFragment:u1=!1}=Z,n0=document.createElement("div");n0.dataset.openchemlibCanvasEditor="true",Object.assign(n0.style,{width:"100%",height:"100%",display:"flex",flexDirection:"row",alignItems:"start",backgroundColor:"white",touchAction:"none",userSelect:"none",webkitUserSelect:"none"});let N0=n0.attachShadow({mode:"open"});N0.adoptedStyleSheets=[QS()];let H0=null;i1||(H0=document.createElement("canvas"),N0.append(H0));let Se=document.createElement("div");Object.assign(Se.style,{width:"100%",height:"100%"}),N0.append(Se);let Xe=document.createElement("canvas");Xe.tabIndex=0,Object.assign(Xe.style,{outline:"none"}),Se.append(Xe),w.append(n0);let j8=new H1(new ql(Xe,Se,ot)),GP=new ot(FPt(L1,ot),new Hl(Xe,Bt),j8);if(u1)if(L1==="molecule"){let jA=new bt(0,0);jA.setFragment(!0),GP.setMolecule(jA)}else{let jA=y1.create();jA.setFragment(!0),GP.setReaction(jA)}j8.setEditorArea(GP);let Nn=i1?null:new Ft(GP,new Vl(H0),j8);function K2(jA){Xe.style.width=`${jA.width}px`,Xe.width=Math.floor(jA.width*hr),Xe.style.height=`${jA.height}px`,Xe.height=Math.floor(jA.height*hr),jA.width>0&&jA.height>0&&GP.repaint()}let YU=Se.getBoundingClientRect();K2(YU);let X2=new ResizeObserver(([jA])=>{K2(jA.contentRect)});X2.observe(Se);let Z2=null,W2=null,_2=null;i1||(Z2=Jc(Xe,GP,ot),W2=US(Se,Xe,GP,ot,bt),_2=Jc(H0,Nn,ot));function KU(){n0.remove(),X2.disconnect(),Z2?.(),W2?.(),_2?.()}return{editorArea:GP,toolbar:Nn,uiHelper:j8,destroy:KU}}function FPt(w,Z){switch(w){case"molecule":return 0;case"reaction":return Z.MODE_REACTION|Z.MODE_MULTIPLE_FRAGMENTS;default:throw new Error(`Invalid initial mode: ${w}`)}}function lS(w,Z,Bt,ot,Ft){class H1{#t;#e;#P;#n;#f;#r;constructor(y1,i1={}){let{editorArea:L1,toolbar:u1,uiHelper:n0,destroy:N0}=yS(y1,i1,H0=>this.#i(H0),w,Z,Bt,ot,Ft);this.#t=L1,this.#e=u1,this.#P=n0,this.#n=null,this.#f={[w.EDITOR_EVENT_MOLECULE_CHANGED]:"molecule",[w.EDITOR_EVENT_SELECTION_CHANGED]:"selection",[w.EDITOR_EVENT_HIGHLIGHT_ATOM_CHANGED]:"highlight-atom",[w.EDITOR_EVENT_HIGHLIGHT_BOND_CHANGED]:"highlight-bond"},this.#r=N0}getMode(){return this.#A(),this.#t.getMode()&w.MODE_REACTION!==0?"reaction":"molecule"}setMolecule(y1){this.#A(),this.#t.setMolecule(y1)}getMolecule(){return this.#A(),this.#t.getMolecule()}setReaction(y1){this.#A(),this.#t.setReaction(y1)}getReaction(){return this.#A(),this.#t.getReaction()}setOnChangeListener(y1){this.#A(),this.#n=y1}removeOnChangeListener(){this.#A(),this.#n=null}clearAll(){this.#A(),this.#t.clearAll()}destroy(){this.#A(),this.#r(),this.#t=null,this.#e=null,this.#P=null,this.#n=null,this.#r=null}get isDestroyed(){return!this.#t}moleculeChanged(){this.#A(),this.#t.moleculeChanged()}#A(){if(this.isDestroyed)throw new Error("CanvasEditor has been destroyed")}#i(y1){if(!this.#n)return;let{what:i1,isUserEvent:L1}=y1;this.#n({type:this.#f[i1],isUserEvent:L1})}}return H1}function TS(w,Z,Bt,ot){class Ft extends HTMLElement{static MODE=Object.freeze(Object.create({MOLECULE:"molecule",REACTION:"reaction"}));static observedAttributes=Object.freeze(["idcode","fragment","mode","readonly"]);#t={idcode:"",fragment:!1,mode:Ft.MODE_MOLECULE,readonly:!1};get idcode(){return this.#t.idcode}set idcode(bt){this.#t.idcode=String(bt),this.setAttribute("idcode",this.#t.idcode)}get fragment(){return this.#t.fragment}set fragment(bt){this.#t.fragment=!!bt,this.#t.fragment?this.setAttribute("fragment",""):this.removeAttribute("fragment")}get mode(){return this.#t.mode}set mode(bt){this.#t.mode=String(bt),this.setAttribute("mode",this.#t.mode)}get readonly(){return this.#t.readonly}set readonly(bt){this.#t.readonly=!!bt,this.#t.readonly?this.setAttribute("readonly",""):this.removeAttribute("readonly")}setMolecule(bt){this.fragment=bt.isFragment(),this.idcode=`${bt.getIDCode()} ${bt.getIDCoordinates()}`,this.#e.setMolecule(bt)}getMolecule(){return this.#e.getMolecule()}setReaction(bt){this.fragment=bt.isFragment(),this.idcode=ot.encode(bt,{keepAbsoluteCoordinates:!0,mode:ot.INCLUDE_MAPPING|ot.INCLUDE_COORDS|ot.RETAIN_REACTANT_AND_PRODUCT_ORDER})??"",this.#e.setReaction(bt)}getReaction(){return this.#e.getReaction()}clearAll(){this.#e.clearAll(),this.idcode=""}moleculeChanged(){this.#e.moleculeChanged()}#e;#P(){this.#e||(this.#e=new w(this,{readOnly:this.readonly,initialMode:this.mode}),this.#e.setOnChangeListener(this.#U),requestIdleCallback(()=>this.#n()))}#n(){switch(this.mode){case Ft.MODE.MOLECULE:return this.#r();case Ft.MODE.REACTION:return this.#A();default:throw new Error(`Mode ${this.mode} is not supported`)}}#f(bt){let y1=bt.indexOf(" ");if(y1===-1)return Z.fromIDCode(bt);let i1=bt.slice(0,y1),L1=bt.slice(y1+1);return Z.fromIDCode(i1,L1)}#r(){let bt=this.#f(this.idcode);bt.setFragment(this.fragment),this.#e.setMolecule(bt)}#A(){let bt=ot.decode(this.idcode,{ensureCoordinates:!0})??Bt.create();bt.setFragment(this.fragment),this.#e.setReaction(bt)}#i=!1;#Q(bt){this.#i=!0;try{bt()}finally{this.#i=!1}}#U=bt=>{let y1=this.idcode,i1=this.fragment;this.#Q(()=>{if(bt.type==="molecule")switch(this.mode){case Ft.MODE.MOLECULE:{let u1=this.getMolecule();this.idcode=`${u1.getIDCode()} ${u1.getIDCoordinates()}`,this.fragment=u1.isFragment();break}case Ft.MODE.REACTION:{let u1=this.getReaction();this.idcode=ot.encode(u1,{keepAbsoluteCoordinates:!0,mode:ot.INCLUDE_MAPPING|ot.INCLUDE_COORDS|ot.RETAIN_REACTANT_AND_PRODUCT_ORDER}),this.fragment=u1.isFragment();break}default:throw new Error(`Unsupported mode ${this.mode}`)}});let L1=new CustomEvent("change",{detail:bt,bubbles:!0});if(this.dispatchEvent(L1),bt.mode==="molecule"){if(this.idcode!==y1){let u1=new CustomEvent("idcode-changed",{detail:this.idcode,bubbles:!0});this.dispatchEvent(u1)}if(this.fragment!==i1){let u1=new CustomEvent("fragment-changed",{detail:this.fragment,bubbles:!0});this.dispatchEvent(u1)}}};#D(){this.#e&&(this.#e.destroy(),this.#e=void 0)}#u(){this.#D(),this.#P()}connectedCallback(){this.#t={idcode:this.getAttribute("idcode")||"",fragment:this.hasAttribute("fragment"),mode:this.getAttribute("mode")||Ft.MODE.MOLECULE,readonly:this.hasAttribute("readonly")},this.#P()}disconnectedCallback(){this.#D()}adoptedCallback(){this.connectedCallback()}attributeChangedCallback(bt,y1,i1){if(!this.#e||this.#i)return;(()=>{switch(bt){case"idcode":return this.#t.idcode=String(i1),()=>this.#n();case"fragment":return this.#t.fragment=i1!==null,()=>this.#n();case"mode":return this.#t.mode=String(i1),()=>this.#u();case"readonly":return this.#t.readonly=i1!==null,()=>this.#u();default:throw new Error("unsupported attribute change")}})()()}}return Ft}function Wc(w){let{GenericEditorArea:Z,GenericEditorToolbar:Bt,GenericUIHelper:ot,Molecule:Ft,Reaction:H1,ReactionEncoder:bt}=w,y1=lS(Z,Bt,ot,Ft,H1);function i1(){let L1=customElements.get("openchemlib-editor");if(L1)return L1;let u1=TS(y1,Ft,H1,bt);customElements.define("openchemlib-editor",u1);let n0=document.createElement("style");return n0.id="openchemlib-editor-default-style",n0.innerHTML=`
/* dynamicaly added from openchemlib registerCustomElement with low priority */
openchemlib-editor:defined {
display: block;
height: 400px;
width: 600px;
}
`,document.head.prepend(n0),u1}w.CanvasEditor=y1,w.registerCustomElement=i1,delete w.GenericEditorArea,delete w.GenericEditorToolbar,delete w.GenericUIHelper}function hS(w){w.prototype.changeCustomLabelPosition=function(Bt){switch(Bt){case"superscript":for(let ot=0;ot<this.getAllAtoms();ot++){let Ft=this.getAtomCustomLabel(ot);Ft&&!Ft.startsWith("]")&&this.setAtomCustomLabel(ot,`]${Ft}`)}break;case"normal":for(let ot=0;ot<this.getAllAtoms();ot++){let Ft=this.getAtomCustomLabel(ot);Ft?.startsWith("]")&&this.setAtomCustomLabel(ot,Ft.slice(1))}break;case"auto":for(let ot=0;ot<this.getAllAtoms();ot++){let Ft=this.getAtomCustomLabel(ot);Ft&&(this.getAtomLabel(ot)==="C"?Ft.startsWith("]")&&this.setAtomCustomLabel(ot,Ft.slice(1)):Ft.startsWith("]")||this.setAtomCustomLabel(ot,`]${Ft}`))}break;case void 0:break;default:break}}}function cS(w){w.prototype.getNextCustomAtomLabel=function(Bt){let ot=Bt||"1",Ft=new Set;for(let bt=0;bt<this.getAllAtoms();bt++){let y1=this.getAtomCustomLabel(bt);y1&&Ft.add(y1)}let H1=0;for(;Ft.has(ot)&&H1++<100;)ot=mPt(ot);return ot}}function mPt(w){let Z=w.match(/(\d+)/);if(Z){let ot=Number.parseInt(Z[1],10);return w.replace(/(\d+)/,(ot+1).toString())}let Bt=w.match(/([a-yA-Y])([^a-zA-Z]*)$/);if(Bt){let ot=Bt[1],Ft=String.fromCodePoint(ot.codePointAt(0)+1);return Ft==="Z"||Ft==="z"?"1":w.replace(/([a-yA-Y])([^a-zA-Z]*)$/,`${Ft}$2`)}return"1"}function wS(w){let Z=w.fromMolfile;w.fromMolfile=function(ot,Ft={}){let{customLabelPosition:H1}=Ft,bt=Z.call(this,ot),y1=ot.includes(`\r
`)?`\r
`:`
`,i1=ot.split(y1);if(i1.length<4||!i1[3].includes("V2000"))return bt;let L1=i1.slice(4+bt.getAllAtoms()+bt.getAllBonds());for(let u1=0;u1<L1.length;u1++){let n0=L1[u1];if(n0.startsWith("A ")){let N0=Number(n0.slice(3)),H0=L1[u1+1]?.trim();u1++,!Number.isNaN(N0)&&N0<=bt.getAllAtoms()&&H0&&!bt.getAtomCustomLabel(N0-1)&&bt.setAtomCustomLabel(N0-1,H0)}if(n0.startsWith("V ")){let N0=n0.split(" ").filter(Boolean);if(N0.length>=3){let H0=Number(N0[1]),Se=N0.slice(2).join(" ");!Number.isNaN(H0)&&H0<=bt.getAllAtoms()&&!bt.getAtomCustomLabel(H0-1)&&bt.setAtomCustomLabel(H0-1,Se)}}if(n0.startsWith("M ZZC")){let N0=Number(n0.slice(7,10).trim()),H0=n0.slice(10).trim();N0&&H0&&bt.setAtomCustomLabel(N0-1,H0)}}return bt.changeCustomLabelPosition(H1),bt}}var kPt=["M STY","M SLB","M SAL","M SDT","M SDD","M SED"];function gS(w){let Z=w.prototype.toMolfile;w.prototype.toMolfile=function(ot={}){let Ft=this.getCompactCopy(),{includeCustomAtomLabelsAsALines:H1=!1,includeCustomAtomLabelsAsVLines:bt=!1,customLabelPosition:y1,removeCustomAtomLabels:i1=!1}=ot;Ft.changeCustomLabelPosition(y1);let L1=Z.call(Ft);if(!H1&&!bt&&!i1)return L1;let u1=L1.includes(`\r
`)?`\r
`:`
`,n0=L1.split(u1);if(i1&&(n0=n0.filter(Se=>!kPt.some(Xe=>Se.startsWith(Xe)))),n0.length<4||!n0[3].includes("V2000"))return L1;let N0=[];for(let Se=0;Se<Ft.getAllAtoms();Se++){let Xe=Ft.getAtomCustomLabel(Se);if(Xe){let j8=String(Se+1).padStart(3," ");H1&&N0.push(`A ${j8}`,Xe),bt&&N0.push(`V ${j8} ${Xe}`)}}let H0=n0.findIndex(Se=>Se.startsWith("M END"));return H0===-1?L1:(n0.splice(H0,0,...N0),n0.join(u1))}}function BS(w){let Z=w.prototype.toRxn,Bt=w.prototype.toRxnV3;w.prototype.toRxn=function(Ft={}){return dS(this,Z,Ft)},w.prototype.toRxnV3=function(Ft={}){return dS(this,Bt,Ft)}}function dS(w,Z,Bt){let{programName:ot="",keepIdCode:Ft=!1}=Bt,H1=Z.call(w,ot);return Ft?H1:H1.replace(/^OCL_RXN_V1.0:.*$/m,"")}function vS(w){let Z=w.prototype.toSVG;w.prototype.toSVG=function(ot,Ft,H1,bt){if(typeof ot!="number"||typeof Ft!="number")throw new Error("Molecule#toSVG requires width and height to be specified");bt=bt||{};let y1=bt.factorTextSize||1,i1=bt.autoCrop===!0,L1=bt.autoCropMargin===void 0?5:bt.autoCropMargin,u1=Z.call(this,ot,Ft,y1,i1,L1,H1,bt),n0=/svg id="(.*)" xmlns/.exec(u1)[1];return u1=u1.replace("<style>",`<style> #${n0} text {font-family: sans-serif;}`),u1=u1.replace("line {",`#${n0} line {`),u1=u1.replace("polygon {",`#${n0} polygon {`),bt.fontWeight&&(u1=u1.replaceAll("font-size=",`font-weight="${bt.fontWeight}" font-size=`)),bt.strokeWidth&&(u1=u1.replaceAll(/stroke-width="[^"]+"/g,`stroke-width="${bt.strokeWidth}"`)),u1}}function FS(w){let{ConformerGenerator:Z,ForceFieldMMFF94:Bt,Molecule:ot,Reaction:Ft}=w;Z.prototype.molecules=function*(){let L1;for(;(L1=this.getNextConformerAsMolecule())!==null;)yield L1};let H1={maxIts:4e3,gradTol:1e-4,funcTol:1e-6},bt=Bt.prototype._minimise;delete Bt.prototype._minimise,Bt.prototype.minimise=function(L1){return L1={...H1,...L1},bt.call(this,L1.maxIts,L1.gradTol,L1.funcTol)},hS(ot),cS(ot),wS(ot),gS(ot),BS(Ft,ot),vS(ot);function y1(i1){if(!i1)return null;if(i1.includes("V2000")||i1.includes("V3000"))return ot.fromMolfile(i1);try{return ot.fromSmiles(i1)}catch{}try{return ot.fromIDCode(i1)}catch{}return null}ot.fromText=function(L1){let u1=y1(L1);return u1&&u1.getAllAtoms()>0?u1:null},ot.prototype.getOCL=function(){return w}}function eD(){}function bPt(w){let Z=w.document,Bt={},ot={userAgent:"webkit"},Ft=eD;Ft.__moduleStartupDone=eD;let H1=eD,bt,y1;function i1(){}function L1(){}function u1(){}function n0(){}function N0(){}function H0(){}function Se(){}function Xe(){}function j8(){}function GP(){}function Nn(){}function K2(){}function YU(){}function X2(){}function Z2(){}function W2(){}function _2(){}function KU(){}function jA(){}function _c(){}function Il(){}function xl(){}function AD(){}function $c(){}function c9(){}function nD(){}function ac(){}function tw(){}function CPt(t){}function ew(){}function Aw(){}function Nl(){}function vi(){}function PD(){}function B1(){}function kS(){}function nw(){}function Pw(){}function rw(){}function u0(){}function iw(){}function fw(){}function XU(){}function Dw(){}function uw(){}function Qw(){}function Uw(){}function ow(){}function Lw(){}function sw(){}function Ol(){}function yw(){}function lw(){}function Tw(){}function hw(){}function cw(){}function ww(){}function gw(){}function dw(){}function Bw(){}function vw(){}function Fw(){}function mw(){}function kw(){}function bS(t,e){t.S=e}function Gl(t,e){t.I=e}function RS(t,e){t.T=e}function jS(t,e){t.O=e}function $2(t,e){t.P=e}function pS(t,e){t.G=e}function CS(t,e){t.d=e}function MS(t,e){t.f=e}function HS(t,e){t.i=e}function VS(t,e){t.i=e}function ES(t,e){t.f=e}function SS(t,e){t.n=e}function bw(t,e){t.p=e}function qS(t,e){t.b=e}function IS(t,e){t.e=e}function xS(t,e){t.r=e}function NS(t){t.a=t.b}function ZU(t){this.a=t}function cr(t){this.j=t}function GA(t){this.b=t}function Rw(t){this.e=t}function jw(t){this.e=t}function pw(t){this.a=t}function Cw(t){this.a=t}function Mw(t){this.a=t}function Hw(t){this.a=t}function Vw(t){this.a=t}function Ew(t){this.a=t}function Sw(t){this.a=t}function qw(t){this.a=t}function Iw(t){this.a=t}function a2(t){this.a=t}function WU(t){this.a=t}function rD(t){this.a=t}function xw(t){this.b=t}function tu(){this.i=0}function Nw(){this.i=1}function Ow(){this.a=-1}function Jl(){this.b=-1}function Fi(t){this.a=t}function eu(t){this.a=t}function zl(t){this.a=t}function Yl(t){this.a=t}function Kl(t){this.a=t}function iD(t){this.a=t}function Xl(t){this.a=t}function Zl(t){this.a=t}function fD(t){this.a=t}function DD(t){this.a=t}function Wl(t){this.c=t}function _l(t){this.b=t}function w9(t){this.a=t}function g9(t){this.a=t}function Wt(t){this.c=t}function _U(t){this.b=t}function Gw(t){this.a=t}function Jw(t){this.a=t}function $l(t){this.a=t}function zw(t){this.c=t}function Yw(t){this.c=t}function Kw(t){this.a=t}function Xw(t){this.a=t}function OS(t,e){t.a=e}function GS(t,e){t.a=e}function JS(t,e){t.d=e}function zS(t,e){t.e=e}function $U(t,e){t.n=e}function YS(t,e){t.T&=~e}function Zw(t,e){t.C[e]=-1}function al(t,e){mt(t.a,e)}function KS(t,e){mt(t.S,e)}function XS(t,e){DO(t.a,e)}function ZS(t,e){fO(t.a,e)}function WS(t,e){au(t.a,e)}function t3(t,e){mt(t.a,e)}function JP(t,e){mt(t.a,e)}function aU(t,e){LA(t.d,e)}function _S(t,e){XS(e,t.B)}function $S(t,e){ZS(e,t.v)}function aS(t,e){Wq(e,t.f)}function tq(t,e){t.H[e]=512}function eq(t,e,A){t.k[e]=A}function Au(){fo(this)}function f1(){cu(this)}function LP(){Cu(this)}function Ww(t){XK(this,t)}function to(){f1.call(this)}function _w(){f1.call(this)}function $w(){mr.call(this)}function aw(){e7.call(this)}function e3(){e7.call(this)}function A3(){mr.call(this)}function d9(){mr.call(this)}function Aq(){return++pV}function nq(t){return t>>>0}function Pq(t){return cK(t)}function rq(t){return FK(t)}function iq(t){t.a>0&&--t.a}function sP(t,e){t.u[e]|=Q0}function n3(t,e){t.F[e]|=I0}function fq(t,e){t.q=e,t.T=0}function Dq(t,e){t.r=e,t.T=0}function mi(t,e){t.length=e}function uq(t,e){mt(t.c,e)}function rA(t,e){Si(t.a,e)}function Qq(t){IE=t,pU=!0}function Uq(t){return $r(t)}function oq(){return kf(),sr}function t7(){this.a=new vo}function uD(){this.a=new f1}function e7(){this.a=new f1}function A7(){this.a=new f1}function nu(){this.c=new f1}function n7(){this.b=new k9}function c0(){c0=B1,JD()}function P3(){mr.call(this)}function P7(){mr.call(this)}function dA(){mr.call(this)}function r3(){mr.call(this)}function r7(){mr.call(this)}function i3(){LQ.call(this,0)}function i7(){Y8.call(this,2)}function f7(){A3.call(this)}function f3(){this.a=new TD}function QD(){this.a=new LP}function D3(){this.a=new lP}function D7(){this.a=new lP}function Pu(t){this.a=GJ(t)}function Lq(t){this.a=t,Qi(t)}function sq(t,e){rA(e,t.a.a)}function eo(t,e,A){t.k[e].a=A}function Ao(t,e,A){t.k[e].b=A}function no(t,e,A){t.k[e].c=A}function yq(t){_A(),Y1(),wn=t}function ki(t){SL(t),t.d=null}function u7(){wp(),this.b=It}function wr(t){V1.call(this,t)}function p1(t,e){return t.s[e]}function Q7(t,e){return t.J[e]}function UD(t,e){return t.e[e]}function Mt(t,e){return t.e[e]}function a1(t,e){return t.o[e]}function lq(t,e){return t.o[e]}function Tq(t,e){return t.X[e]}function hq(t,e){return t.Y[e]}function ye(t,e){return t.A[e]}function o0(t,e){return t.B[e]}function K(t,e){return t.C[e]}function ee(t,e){return t.G[e]}function l1(t,e){return t.H[e]}function O(t,e){return t.j[e]}function cq(t,e){return t.d[e]}function u3(t,e){return t.e[e]}function wq(t,e){return t.f[e]}function B9(t,e){return t.a[e]}function ru(t,e){return t.a[e]}function iu(t,e){return t.b[e]}function oD(t,e){return t.e[e]}function J0(t,e){return t.k[e]}function gq(t,e){return t.a[e]}function U7(t,e){return t.b[e]}function o7(t,e){return t.c[e]}function dq(t,e,A){t8(t.a,A,e)}function Bq(t){bJ(t.a,t.c,t.b)}function L7(t){wr.call(this,t)}function s7(t){fa.call(this,t)}function y7(t){No.call(this,t)}function l7(t){No.call(this,t)}function T7(t){No.call(this,t)}function h7(t){No.call(this,t)}function gr(t){wr.call(this,t)}function c7(t){wr.call(this,t)}function w7(t){zL.call(this,t)}function bi(t){t.b=null,t.c=0}function Ri(t){return U1(t),t}function LD(t){return U1(t),t}function vq(t){return nP*t*t}function Fq(t){return is(t,t.i)}function mq(t,e){return oz(t,e)}function kq(t,e){return tJ(t,e)}function bq(t,e){return t.db[e]}function Rq(t){return Ui(t),t.B}function jq(t){return Ui(t),t.H}function ji(){ji=B1,ul=new LP}function g7(){g7=B1,$4=new i1}function Q3(){Q3=B1,a4=new tw}function pq(t,e){t.g=new zr(e)}function sD(t,e){t.T|=248&(8|e)}function yD(t,e,A){bD(t.k[e],A)}function Cq(t){lx(t,t.length)}function Mq(t){ux(t,t.length)}function Hq(t){Qx(t,t.length)}function Vq(t){Tx(t,t.length)}function U3(t){Hu(t,t.length)}function Po(t){U1(t),this.a=t}function o3(t){new f1,this.a=t}function p8(t){wr.call(this,t)}function C8(t){wr.call(this,t)}function ro(t){wr.call(this,t)}function d7(t){wr.call(this,t)}function lD(t){wr.call(this,t)}function L3(t){gr.call(this,t)}function BA(t){EA.call(this,t,0)}function B7(t){return Iu(t,t.jb)}function zP(t){return!!t&&t.b}function v7(t){return t.b==t.c}function vA(t,e){return t.J[e].c}function kt(t,e){return t.J[e].a}function jt(t,e){return t.J[e].b}function d0(t,e){return t.u[e]&3}function qe(t,e){return t.F[e]&3}function Bn(t,e){return t.w[e]<0}function s3(t,e){return t.a[e]}function v9(t,e){return t.k[e].a}function F9(t,e){return t.k[e].b}function m9(t,e){return t.k[e].c}function d(t,e){return RB(t,e)}function F7(t){return 4e3*t*t}function Eq(t){return 8e3*t*t}function Sq(t){return t.c||cQ(t)}function qq(t){return _A(),ar(t)}function Iq(t){return _A(),ei(t)}function JA(){Y1(),$3.call(this)}function m7(t){gr.call(this,t)}function YP(t){C8.call(this,t)}function TD(){eu.call(this,"")}function fu(){eu.call(this,"")}function V0(){eu.call(this,"")}function k9(){eu.call(this,"")}function y3(t){Pu.call(this,t)}function io(t){_U.call(this,t)}function k7(t){Co.call(this,t)}function b7(t){io.call(this,t)}function R7(t){yB.call(this,t)}function l3(t){M8.call(this,t)}function j7(t){hD.call(this,t,0)}function p7(t){Lq.call(this,t.a)}function T3(t){Xw.call(this,t)}function C7(t){C9.call(this,t)}function pi(){M3.call(this,null)}function M7(){this.a=0,this.b=0}function H7(t){this.b=t,this.a=1}function fo(t){t.a=0,t.b=0,t.c=1}function xq(t,e){t.c=e,t.T&=-144}function E0(t,e,A){t.s[e]=A,t.T=0}function w0(t,e,A){t.H[e]=A,t.T=0}function Du(t,e){return t.A[e]==0}function FA(t,e){return t.u[e]&48}function Do(t,e){return t<e?t:t-e}function X1(t,e){return e*t.c+t.b}function Z1(t,e){return e*t.c+t.a}function h3(t,e){return N(t.j,e)}function V7(t,e){return N(t.k,e)}function c3(t,e){return bq(t.d,e)}function Nq(t,e){return lq(t.d,e)}function R0(t,e){return Ho(t.d,e)}function Oq(t,e){return N(t.a,e)}function w3(t,e){return N(t.f,e)}function dr(t,e){return N(t.g,e)}function uu(t,e){return pv(t,e)}function Gq(t,e){return ff(t.d,e)}function Qu(t){return yb(t,N5(t))}function E7(t){return t.l|t.m<<22}function Jq(t,e){cI(t.b,t.a,e)}function S7(t,e){mt(t.f,e),t.d=-1}function q7(t,e){mt(t.g,e),t.d=-1}function zq(t,e){return t.a+=e,t}function g3(t,e){return t.a+=e,t}function Uu(t){return Mo(t),t.n}function On(t){return ut(t,7),t.p}function I7(t){this.a=new s7(t.a)}function uo(t){this.a=new Ji(t)}function M8(t){this.a=(U1(t),t)}function b9(t){this.b=t,this.a=0}function R9(){R9=B1,wU=!1}function d3(){d3=B1,LE=(Wh(),kU)}function Yq(){CU!=0&&(CU=0),MU=-1}function x7(){nl==null&&(nl=[])}function Kq(){throw At(new dA)}function B3(){throw At(new dA)}function hD(t,e){this.k=t,this.j=e}function u(t,e){this.b=t,this.a=e}function Qo(t,e){ha.call(this,t,e)}function cD(t){GK.call(this,t,t.o)}function Uo(){gO.call(this,new c9)}function oo(){oo=B1,H4=SA("X",32)}function N7(t,e,A){Dn(t,A),Ln(t,e)}function Ci(t,e){return X0[t.C[e]]}function ou(t,e){return t.u[e]&448}function Lu(t,e){return t.H[e]&127}function iA(t,e){return t.a[e]&w1}function yP(t,e){return t.c[e]&w1}function Xq(t,e){return t.C[e]==-1}function Ze(t,e,A,n){t.w[e]=n?-A:A}function wD(t,e){su.call(this,t,e)}function Mi(t,e){su.call(this,t,e)}function Lo(t,e){this.b=t,this.a=e}function gD(t,e){this.b=t,this.a=e}function O7(t,e){this.b=t,this.a=e}function KP(t,e){this.a=t,this.b=e}function su(t,e){this.a=t,this.b=e}function G7(t,e){this.a=t,this.b=e}function J7(t,e){this.a=t,this.b=e}function z7(t,e){this.a=t,this.b=e}function Y7(t,e){this.a=t,this.b=e}function We(t,e){this.a=t,this.b=e}function K7(t,e){this.a=t,this.b=e}function X7(t,e){this.a=t,this.b=e}function v3(t,e){this.a=t,this.b=e}function so(t,e){this.k=e,this.j=t}function nn(t){this.b=t,this.a=-2}function Z7(t){pD.call(this,t,0)}function W7(){yB.call(this,null)}function lP(){Ji.call(this,null)}function _7(){C9.call(this,null)}function $7(){d3(),pU||gL(),new Rj}function x1(){x1=B1,gi=new rw}function yo(){yo=B1,vl=new Aw}function Zq(t,e){UL(t.c,new Hw(e))}function Wq(t,e){uG(t.a,t.b,t.c,e)}function _q(t,e){ox(t),t.b._c(e)}function a7(t,e){return mt(t.a,e)}function tg(t,e){return ff(t.a,e)}function F3(t,e){return N(t.a,e).a}function eg(t,e){return N(t.a,e).b}function z(t,e,A){return t.D[e][A]}function _(t,e,A){return t.i[e][A]}function Ot(t,e,A){return t.k[e][A]}function pA(t,e,A){return t.n[e][A]}function $q(t,e){return t.H[e]==512}function dD(t){return t.a.c+t.c.c}function Ag(t){return sn(t,1,t.c)>0}function S1(t,e){return G(t,e)>0}function Hi(t,e){return G(t,e)<0}function yu(t,e){return wg(e,t.a)}function ng(t,e){return wg(e,t.a)}function j9(t,e){su.call(this,t,e)}function Pg(t){sp(),pa.call(this,t)}function Br(t){return t.b=WB(t.a)}function rg(t,e){return t.a.get(e)}function lo(t,e){return So(t.a,e)}function lu(t,e){su.call(this,t,e)}function To(t,e){su.call(this,t,e)}function TP(t,e){this.a=t,this.b=e}function ig(t,e){this.a=t,this.b=e}function fg(t,e){this.a=t,this.b=e}function Dg(t,e){this.b=t,this.a=e}function ug(t,e){this.b=t,this.a=e}function ho(t,e){this.c=t,this.d=e}function Qg(t,e){this.a=t,this.c=e}function co(t,e){V9(t,t.length,e)}function aq(t){return t.B?t.B.u:1}function tI(t){return Array.from(t)}function eI(){return new _P(new P8)}function Tu(t){return typeof t===w2}function Vi(t){return typeof t===nr}function H8(t){return typeof t===bf}function J1(t){return t??null}function m3(t,e){return t==e-1?0:t+1}function AI(t,e){return _A(),Je(t,e)}function nI(t,e){return _A(),SA(t,e)}function P0(t,e){return G(t,e)==0}function hu(t,e){return G(t,e)>=0}function Ug(t,e){return G(t,e)<=0}function gt(t,e){return G(t,e)!=0}function PI(t,e){i6.call(this,t,0,e)}function rI(t){w.clearTimeout(t)}function og(t){this.b=t,this.c=!1}function Lg(){pU||gL(),this.a=new Fm}function sg(){sg=B1,zf=(x1(),$A)}function yg(){yg=B1,B8=(x1(),$A)}function lg(t,e){return J1(t)===J1(e)}function k3(t,e,A){return t.e[e][A]}function b3(t,e,A){return t.f[e][A]}function Ei(t,e){return(t.u[e]&4)!=0}function wo(t,e){return(t.F[e]&4)!=0}function De(t,e){return t.i[e].length}function R3(t,e){return t.e[e]-t.j[e]}function go(t,e){return(t.u[e]&8)!=0}function Tg(t){return parseInt(t)||-1}function cu(t){t.a=h(uP,A0,1,0,5,1)}function Si(t,e){return t.a+=""+e,t}function hg(t,e){return t.a+=""+e,t}function J(t,e){return t.a+=""+e,t}function Ie(t,e,A){t.J[e].b=A,t.T&=7}function Be(t,e,A){t.J[e].a=A,t.T&=7}function hP(t,e,A){t.J[e].c=A,t.T&=7}function iI(t,e,A){t8(t.f,A,e),t.d=-1}function fI(t,e,A){t8(t.g,A,e),t.d=-1}function DI(t,e,A){return M5(t.a,e,A)}function cg(t){return S0(t.l,t.m,t.h)}function XP(t){return t?t.ed():null}function wg(t,e){return t.toFixed(e)}function p9(t){return t.a<t.c.size()}function U0(t){return typeof t===nr}function gg(t,e){return e==0?t.i:t.j}function wu(t,e){Wi(t,0,t.length,e)}function j3(t,e){yx(t.a,t.a.length,e)}function Bo(t,e,A,n){t.a=e,t.b=A,t.c=n}function BD(t,e,A,n){t.D[e][A]=n,t.T=0}function uI(t,e){return t.j[e]-EL(t,e)}function fA(t,e){return(t.F[e]&64)!=0}function gu(t,e){return(t.F[e]&48)>>4}function V8(t){return wP(t,t.q,t.r,wn)}function du(t){a5(),sB.call(this,t,0)}function p3(t){PI.call(this,t,new k9)}function dg(t){WX.call(this,t,new k9)}function C3(t){P8.call(this),this.e=t}function M3(t){this.d=new f1,this.c=t}function Bg(){this.c=new lP,this.b=0}function vg(t,e){this.b=AP(e),this.a=t}function Fg(t,e){this.b=AP(e),this.a=t}function C9(t){this.f=t,this.g=!0}function mg(){Xw.call(this,"UTF-8")}function vo(){kf(),this.g=new Ni,_J()}function ZP(t,e,A){mt(t.a,new We(e,A))}function kg(t,e,A,n){t.e=e,t.c=A,t.d=n}function QI(t,e){return j0(t.a[e][3])}function UI(t,e){return j0(t.a[e][2])}function bg(t,e){return j0(t.a[e][2])}function Rg(t,e){return j0(t.a[e][1])}function oI(t){return t.e==null?"":t.e}function Fo(t){return t!=null?a8(t):0}function jg(t){ke(),QG.call(this,t)}function pg(t){XO.call(this,t,hN())}function Cg(){lu.call(this,"Head",1)}function Mg(){lu.call(this,"Tail",3)}function Hg(t){Wi(t,0,t.length,null)}function H3(t){ut(t,31),t.d&&CY(t.d)}function LI(){return _A(),Y1(),Y1(),wn}function Pn(t,e){return wP(t,t.q,t.r,e)}function Vg(t,e){return(t.u[e]&Q0)!=0}function vr(t,e){return(t.F[e]&Q0)!=0}function V3(t,e){return(t.F[e