@powerhousedao/connect 5.2.0-staging.5 → 5.2.0-staging.6

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.
Files changed (32) hide show
  1. package/dist/assets/{AddDriveModal-DPsXCsKY.js → AddDriveModal-BPfg2aVp.js} +1 -1
  2. package/dist/assets/{ClearStorageModal-0a-FvVft.js → ClearStorageModal-DkzEs3J3.js} +1 -1
  3. package/dist/assets/{CookiesPolicyModal-LlyeXnT3.js → CookiesPolicyModal-9HTOqDGi.js} +1 -1
  4. package/dist/assets/{CreateDocumentModal-DhqPyZgR.js → CreateDocumentModal-BVrngAVh.js} +1 -1
  5. package/dist/assets/{DebugSettingsModal-NDgrmANh.js → DebugSettingsModal-C3F03ZDt.js} +1 -1
  6. package/dist/assets/{DeleteDriveModal-DUJdD0gh.js → DeleteDriveModal-BwBYVng9.js} +1 -1
  7. package/dist/assets/{DeleteItemModal-V2LIIT_4.js → DeleteItemModal-DQwVlqv-.js} +1 -1
  8. package/dist/assets/{DisclaimerModal-DKm61lr_.js → DisclaimerModal-BY7I1-64.js} +1 -1
  9. package/dist/assets/{DriveSettingsModal-BKD3uIaj.js → DriveSettingsModal-BcUGdfi5.js} +1 -1
  10. package/dist/assets/{ExportDocumentWithErrorsModal-BEGpnYjK.js → ExportDocumentWithErrorsModal-D18AVOle.js} +1 -1
  11. package/dist/assets/{SettingsModal-H99Ry2GZ.js → SettingsModal-BbOGnZB2.js} +1 -1
  12. package/dist/assets/{UpgradeDriveModal-DrNkfaAz.js → UpgradeDriveModal-DqMxQCoF.js} +1 -1
  13. package/dist/assets/{design_system-QOruZ9IE.js → design_system-CivzDHIq.js} +1 -1
  14. package/dist/assets/{design_system_connect-WFutsSdX.js → design_system_connect-BRZJ3Vw4.js} +1 -1
  15. package/dist/assets/{design_system_ui-eg6dgZXY.js → design_system_ui-D74NrKvC.js} +1 -1
  16. package/dist/assets/{document_engineering-BYqfH4n8.js → document_engineering-CorBRLgC.js} +1 -1
  17. package/dist/assets/{document_model_editor-Cbv49XRh.js → document_model_editor-BkDmLrc0.js} +4 -4
  18. package/dist/assets/{drive_explorer-COqcUUEO.js → drive_explorer-CRZ83OvJ.js} +2 -2
  19. package/dist/assets/{graphql-editor-jn3J7F9p.js → graphql-editor-bK8aKD9d.js} +1 -1
  20. package/dist/assets/{hooks-DuGZmrxp.js → hooks-C4xwrn3a.js} +1 -1
  21. package/dist/assets/{index-Zw4YIbMe.js → index-BaXh7H_G.js} +3 -3
  22. package/dist/assets/{index-DP1215d5.js → index-mtUXtVai.js} +2 -2
  23. package/dist/assets/{json-editor-DOPxjhQb.js → json-editor-Ek6O-GGf.js} +1 -1
  24. package/dist/assets/{nodefs-DmjA5Too.js → nodefs-DwD3CLeV.js} +1 -1
  25. package/dist/assets/{opfs-ahp-C3aLiPPU.js → opfs-ahp-CXiEKQWP.js} +1 -1
  26. package/dist/assets/{reactor_browser-DCsuyS4N.js → reactor_browser-BhmwuJ3V.js} +3 -3
  27. package/dist/assets/{state-schemas-INif6n1R.js → state-schemas-CCZ_uel9.js} +2 -2
  28. package/dist/index.html +7 -7
  29. package/lib/package.copy.json +1 -1
  30. package/lib/tsconfig.tsbuildinfo +1 -1
  31. package/package.copy.json +1 -1
  32. package/package.json +10 -10
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/nodefs-DmjA5Too.js","assets/document_model-DB4SzBSe.js","assets/zod-BpTyxkjy.js","assets/react-DQSxOgtG.js","assets/document_drive-BuVpBb4l.js","assets/graphql-BS4Brs_E.js","assets/config-CU-aFfVJ.js","assets/drive_explorer-COqcUUEO.js","assets/sentry_react-cODD7zWc.js","assets/sentry_browser-B4YoBIIG.js","assets/document_model_editor-Cbv49XRh.js","assets/react/jsx-runtime-DldvXD6N.js","assets/design_system-QOruZ9IE.js","assets/tailwind_merge-Dr4f9Rms.js","assets/react-dom-D6zQJsh6.js","assets/design_system_connect-WFutsSdX.js","assets/design_system_ui-eg6dgZXY.js","assets/react-dom/client-BVPiT_FE.js","assets/opfs-ahp-C3aLiPPU.js"])))=>i.map(i=>d[i]);
2
- import{Y as capitalCase,Z as buildSignedAction,_ as documentModelDocumentType,d as baseSaveToFileHandle,$ as createZip,g as generateId,k as createPresignedHeader,w as replayDocument,e as baseLoadFromInput,a0 as actions,h as defaultBaseState,a1 as validateInitialState,a2 as validateStateSchemaName,a3 as validateModules,j as createState}from"./document_model-DB4SzBSe.js";import{l as logger,d as deleteNode$1,a as addFile$1,i as isFileNode,b as addFolder$1,c as isFolderNode,g as generateNodesCopy,h as handleTargetNameCollisions,e as copyNode$1,m as moveNode$1,u as updateNode,A as AbortError,M as MemoryStorage,R as ReactorBuilder$1,s as setSharingType,f as setAvailableOffline,j as setDriveName,r as removeTrigger$1,P as PullResponderTransmitter,k as addTrigger$1,S as SynchronizationUnitNotFoundError,D as DocumentNotFoundError,n as DocumentModelNotFoundError}from"./document_drive-BuVpBb4l.js";import{_ as __vitePreload}from"./drive_explorer-COqcUUEO.js";import{p as process$1,g as getDefaultExportFromCjs,a as getAugmentedNamespace}from"./react-DQSxOgtG.js";import"./document_model_editor-Cbv49XRh.js";import{r as reactExports}from"./sentry_react-cODD7zWc.js";function makePHEventFunctions(t){const e=`ph:set${capitalCase(t)}`,I=`ph:${t}Updated`;function B(hr){const fr=new CustomEvent(e,{detail:{[t]:hr}});window.dispatchEvent(fr)}function tr(){const hr=new CustomEvent(I);window.dispatchEvent(hr)}function rr(hr){const fr=hr.detail[t];if(!window.ph)throw new Error("ph global store is not defined");window.ph[t]=fr,tr()}function ir(){window.addEventListener(e,rr)}function lr(hr){return window.addEventListener(I,hr),()=>{window.removeEventListener(I,hr)}}function dr(){if(!window.ph)throw new Error("ph global store is not defined");return window.ph[t]}function mr(){return reactExports.useSyncExternalStore(lr,dr)}return{useValue:mr,setValue:B,addEventHandler:ir}}const featuresEventFunctions=makePHEventFunctions("features"),useFeatures=featuresEventFunctions.useValue,setFeatures=featuresEventFunctions.setValue,addFeaturesEventHandler=featuresEventFunctions.addEventHandler;function isLegacyReadEnabledSync(){return window.ph?.features?.get("FEATURE_LEGACY_READ_ENABLED")??!0}function isLegacyWriteEnabledSync(){return window.ph?.features?.get("FEATURE_LEGACY_WRITE_ENABLED")??!0}function isChannelSyncEnabledSync(){return window.ph?.features?.get("FEATURE_CHANNEL_SYNC_ENABLED")??!1}function useInspectorEnabled(){return useFeatures()?.get("FEATURE_INSPECTOR_ENABLED")??!1}async function queueActions(t,e){if(!t)throw new Error("No document provided");if(!e)throw new Error("No actions provided");const I=Array.isArray(e)?e:[e];if(I.length===0)throw new Error("No actions provided");if(isLegacyWriteEnabledSync()){const tr=window.ph?.legacyReactor;if(!tr)throw new Error("Legacy reactor not initialized");const rr=await tr.queueActions(t.header.id,I);return rr.status!=="SUCCESS"&&logger.error(rr.error),rr.document}else{const tr=window.ph?.reactorClient;if(!tr)throw new Error("ReactorClient not initialized");return await tr.execute(t.header.id,"main",I)}}async function queueOperations(t,e){if(!t)throw new Error("No documentId provided");if(!e)throw new Error("No operations provided");const I=Array.isArray(e)?e:[e];if(I.length===0)throw new Error("No operations provided");if(isLegacyWriteEnabledSync()){const tr=window.ph?.legacyReactor;if(!tr)throw new Error("Legacy reactor not initialized");const rr=await tr.queueOperations(t,I);return rr.status!=="SUCCESS"&&logger.error(rr.error),rr.document}else{const tr=window.ph?.reactorClient;if(!tr)throw new Error("ReactorClient not initialized");const rr=I.map(ir=>ir.action);return await tr.execute(t,"main",rr)}}async function uploadOperations(t,e,I,B){const tr=B?.operationsLimit||50,rr=B?.onProgress;logger.verbose(`uploadDocumentOperations(documentId:${t}, ops: ${Object.keys(e).join(",")}, limit:${tr})`);const ir=Object.values(e).filter(mr=>mr!==void 0),lr=ir.reduce((mr,hr)=>mr+hr.length,0);let dr=0;for(const mr of ir)for(let hr=0;hr<mr.length;hr+=tr){logger.verbose(`uploadDocumentOperations:for(i:${hr}, ops:${mr.length}, limit:${tr}): START`);const fr=mr.slice(hr,hr+tr),_r=fr.at(-1);if(!_r)break;const wr=_r.action.scope;if(await I(t,fr),dr+=fr.length,rr){const gr=Math.round(dr/lr*100);rr({stage:"uploading",progress:gr,totalOperations:lr,uploadedOperations:dr})}logger.verbose(`uploadDocumentOperations:for:waitForUpdate(${t}:${wr} rev ${_r.index}): NEXT`)}logger.verbose(`uploadDocumentOperations:for:waitForUpdate(${t}): END`)}async function signAction$1(t,e){const I=window.ph?.legacyReactor;if(!I)return t;const tr=I.getDocumentModelModules().find(hr=>hr.documentModel.global.id===e.header.documentType);if(!tr)return logger.error(`Document model '${e.header.documentType}' not found`),t;const rr=tr.reducer,ir=window.ph?.user,lr=window.ph?.connectCrypto;if(!ir||!lr||!t.context?.signer)return t;const dr=t.context.signer;return await buildSignedAction(t,rr,e,dr,lr.sign)}function addActionContext(t){const e=window.ph?.user,I=window.ph?.did;return e?{context:{signer:{app:{name:"Connect",key:I||""},user:{address:e.address,networkId:e.networkId,chainId:e.chainId},signatures:[]}},...t}:t}async function makeSignedActionWithContext(t,e){if(!t){logger.error("No action found");return}if(!e){logger.error("No document found");return}const I=await signAction$1(t,e);return addActionContext(I)}async function makeSignedActionsWithContext(t,e){if(!t){logger.error("No actions found");return}const I=Array.isArray(t)?t:[t];return(await Promise.all(I.map(tr=>makeSignedActionWithContext(tr,e)))).filter(tr=>tr!==void 0)}async function getDocument(t){try{return await window.ph?.legacyReactor?.getDocument(t)}catch(e){logger.debug(`Failed to get document with id ${t}:`,e);return}}function getActionErrors(t,e){return e.reduce((I,B)=>{const tr=t.operations[B.scope].findLast(rr=>rr.action.id===B.id);return tr?.error&&I.push(new Error(tr.error)),I},new Array)}async function dispatchActions(t,e,I){const B=typeof e=="string"?await getDocument(e):e;if(!B){logger.error(`Document with id ${JSON.stringify(e)} not found`);return}const tr=await makeSignedActionsWithContext(t,B);if(!tr){logger.error("No signed actions with context found");return}const rr=await queueActions(B,tr);if(I&&rr){const ir=getActionErrors(rr,tr);ir.length&&I(ir)}return rr}class UnsupportedDocumentTypeError extends Error{constructor(e){super(`Document type ${e} is not supported`),this.name="UnsupportedDocumentTypeError"}}class DocumentTypeMismatchError extends Error{constructor(e,I,B){super(`Document ${e} is not of type ${I}. Actual type: ${B}`)}}class NoSelectedDocumentError extends Error{constructor(){super("There is no selected document. Call 'setSelectedNode' to select a document.")}}function isDocumentTypeSupported(t,e){return e?.length?e.some(I=>{if(I.endsWith("/*")){const B=I.slice(0,-2);return t.startsWith(B+"/")}if(I.endsWith("*")&&!I.endsWith("/*")){const B=I.slice(0,-1);return t.startsWith(B)}return I===t}):!0}function getUserPermissions(){const t=window.ph?.user,e=window.ph?.allowList;return e?{isAllowedToCreateDocuments:e.includes(t?.address??""),isAllowedToEditDocuments:e.includes(t?.address??"")}:{isAllowedToCreateDocuments:!0,isAllowedToEditDocuments:!0}}async function isDocumentInLocation(t,e,I){const B=isLegacyReadEnabledSync();try{if(B){const tr=window.ph?.legacyReactor;if(!tr)throw new Error("Legacy reactor not initialized");const rr=await tr.getDrive(e),ir=rr.state.global.nodes.find(dr=>dr.id===t.header.id);if(ir&&ir.parentFolder===(I??null))return{isDuplicate:!0,duplicateType:"id",nodeId:ir.id};const lr=rr.state.global.nodes.find(dr=>isFileNode(dr)&&dr.name===t.header.name&&dr.documentType===t.header.documentType&&dr.parentFolder===(I??null));return lr?{isDuplicate:!0,duplicateType:"name",nodeId:lr.id}:{isDuplicate:!1}}else{const tr=window.ph?.reactorClient;if(!tr)throw new Error("ReactorClient not initialized");const{document:rr}=await tr.get(e),ir=rr.state.global.nodes.find(dr=>dr.id===t.header.id);if(ir&&ir.parentFolder===(I??null))return{isDuplicate:!0,duplicateType:"id",nodeId:ir.id};const lr=rr.state.global.nodes.find(dr=>isFileNode(dr)&&dr.name===t.header.name&&dr.documentType===t.header.documentType&&dr.parentFolder===(I??null));return lr?{isDuplicate:!0,duplicateType:"name",nodeId:lr.id}:{isDuplicate:!1}}}catch{return{isDuplicate:!1}}}function getDocumentTypeIcon(t){switch(t.header.documentType){case"powerhouse/document-model":return"document-model";case"powerhouse/app":return"app";case"powerhouse/document-editor":return"editor";case"powerhouse/subgraph":return"subgraph";case"powerhouse/package":return"package";case"powerhouse/processor":{const B=t.state.global?.type;return B==="analytics"?"analytics-processor":B==="relational"?"relational-processor":B==="codegen"?"codegen-processor":void 0}default:return}}function downloadFile(t,e){createZip(t).generateAsync({type:"blob"}).then(B=>{const tr=window.document.createElement("a");tr.style.display="none",tr.href=URL.createObjectURL(B),tr.download=e,window.document.body.appendChild(tr),tr.click(),window.document.body.removeChild(tr)}).catch(logger.error)}async function exportFile(t,e){if(isLegacyReadEnabledSync()){if(!window.ph?.legacyReactor)throw new Error("Legacy reactor not initialized")}else if(!window.ph?.reactorClient)throw new Error("ReactorClient not initialized");let B="";if(t.header.documentType===documentModelDocumentType){const ir=t.state.global.extension.replace(/^\.+|\.+$/g,"");B=ir!==""?`.${ir}`:""}const tr=`${t.header.name||"Untitled"}${B}.phd`;if(!window.showSaveFilePicker)return downloadFile(t,tr);try{const rr=await window.showSaveFilePicker({suggestedName:tr});return await baseSaveToFileHandle(t,rr),rr}catch(rr){if(!(rr instanceof DOMException&&rr.name==="AbortError"))throw rr}}async function loadFile(t){const e=isLegacyReadEnabledSync(),I=await baseLoadFromInput(t,B=>B,{checkHashes:!0});if(e){const B=window.ph?.legacyReactor;if(!B)throw new Error("Legacy reactor not initialized");const rr=B.getDocumentModelModules().find(ir=>ir.documentModel.global.id===I.header.documentType);if(!rr)throw new Error(`Document "${I.header.documentType}" is not supported`);return rr.utils.loadFromInput(t)}else{const B=window.ph?.reactorClient;if(!B)throw new Error("ReactorClient not initialized");const{results:tr}=await B.getDocumentModels(),rr=tr.find(ir=>ir.documentModel.global.id===I.header.documentType);if(!rr)throw new Error(`Document "${I.header.documentType}" is not supported`);return rr.utils.loadFromInput(t)}}async function addDocument(t,e,I,B,tr,rr,ir){const{isAllowedToCreateDocuments:lr}=getUserPermissions();if(!lr)throw new Error("User is not allowed to create documents");if(isLegacyWriteEnabledSync()){const mr=window.ph?.legacyReactor;if(!mr)throw new Error("Legacy reactor not initialized");const hr=await mr.getDrive(t),fr=rr??generateId(),wr=mr.getDocumentModelModules().find(br=>br.documentModel.global.id===I);if(!wr)throw new Error(`Document model module for type ${I} not found`);const gr=wr.utils.createDocument({...tr?.state});gr.header=createPresignedHeader(fr,I),gr.header.name=e;const xr=ir?{preferredEditor:ir}:void 0;await mr.addDocument(gr,xr);const Mr=addFile$1({id:fr,name:e,documentType:I,parentFolder:B??null}),yr=(await queueActions(hr,Mr)).state.global.nodes.find(br=>br.id===fr);if(!yr||!isFileNode(yr))throw new Error("There was an error adding document");return yr}else{const mr=window.ph?.reactorClient;if(!mr)throw new Error("ReactorClient not initialized");const hr=await mr.createEmpty(I,t);return e&&await mr.rename(hr.header.id,e),B&&await mr.moveChildren(t,B,[hr.header.id]),{id:hr.header.id,name:e||hr.header.name,documentType:I,parentFolder:B??null,kind:"file"}}}async function addFile(t,e,I,B){logger.verbose(`addFile(drive: ${e}, name: ${I}, folder: ${B})`);const{isAllowedToCreateDocuments:tr}=getUserPermissions();if(!tr)throw new Error("User is not allowed to create files");const rr=isLegacyWriteEnabledSync(),ir=await loadFile(t);if(!ir)throw new Error("No document loaded");let lr=!1;if(rr){const _r=window.ph?.legacyReactor;if(!_r)throw new Error("Legacy reactor not initialized");if(!_r.getDocumentModelModules().find(gr=>gr.documentModel.global.id===ir.header.documentType))throw new Error(`Document model module for type ${ir.header.documentType} not found`);try{await _r.getDocument(ir.header.id),lr=!0}catch{}}else{const _r=window.ph?.reactorClient;if(!_r)throw new Error("ReactorClient not initialized");const{results:wr}=await _r.getDocumentModels();if(!wr.find(xr=>xr.documentModel.global.id===ir.header.documentType))throw new Error(`Document model module for type ${ir.header.documentType} not found`);try{await _r.get(ir.header.id),lr=!0}catch{}}const dr=lr?generateId():ir.header.id,mr=createPresignedHeader(dr,ir.header.documentType);mr.lastModifiedAtUtcIso=ir.header.createdAtUtcIso,mr.meta=ir.header.meta,mr.name=I||ir.header.name;const hr={...ir,state:ir.initialState,operations:Object.keys(ir.operations).reduce((_r,wr)=>(_r[wr]=[],_r),{})};if(!await addDocument(e,I||ir.header.name,ir.header.documentType,B,hr,dr,ir.header.meta?.preferredEditor))throw new Error("There was an error adding file");uploadOperations(dr,ir.operations,queueOperations).catch(_r=>{throw _r})}async function addFileWithProgress(t,e,I,B,tr,rr,ir){logger.verbose(`addFileWithProgress(drive: ${e}, name: ${I}, folder: ${B})`);const lr=window.ph?.legacyReactor;if(!lr)return;const{isAllowedToCreateDocuments:dr}=getUserPermissions();if(!dr)throw new Error("User is not allowed to create files");try{tr?.({stage:"loading",progress:0});const mr=await loadFile(t);if(!mr)throw new Error("No document loaded");const hr=await isDocumentInLocation(mr,e,B);if(hr.isDuplicate&&!ir){tr?.({stage:"conflict",progress:0,duplicateType:hr.duplicateType});return}hr.isDuplicate&&ir==="replace"&&hr.nodeId&&await deleteNode(e,hr.nodeId);const fr=getDocumentTypeIcon(mr);if(tr?.(fr?{stage:"loading",progress:10,documentType:fr}:{stage:"loading",progress:10}),!isDocumentTypeSupported(mr.header.documentType,rr))throw tr?.({stage:"unsupported-document-type",progress:100,error:`Document type ${mr.header.documentType} is not supported`}),new UnsupportedDocumentTypeError(mr.header.documentType);if(!lr.getDocumentModelModules().find(yr=>yr.documentModel.global.id===mr.header.documentType))throw new Error(`Document model module for type ${mr.header.documentType} not found`);tr?.({stage:"initializing",progress:10});let wr=!1;try{await lr.getDocument(mr.header.id),wr=!0}catch{}const gr=wr?generateId():mr.header.id,xr=createPresignedHeader(gr,mr.header.documentType);xr.lastModifiedAtUtcIso=mr.header.createdAtUtcIso,xr.meta=mr.header.meta,xr.name=I||mr.header.name;const Mr={...mr,header:xr,state:mr.initialState,operations:Object.keys(mr.operations).reduce((yr,br)=>(yr[br]=[],yr),{})},Sr=await addDocument(e,I||mr.header.name,mr.header.documentType,B,Mr,gr,mr.header.meta?.preferredEditor);if(!Sr)throw new Error("There was an error adding file");return tr?.({stage:"initializing",progress:20}),await uploadOperations(gr,mr.operations,queueOperations,{onProgress:yr=>{if(yr.totalOperations&&yr.uploadedOperations!==void 0){const br=yr.totalOperations>0?yr.uploadedOperations/yr.totalOperations:0,vr=20+Math.round(br*80);tr?.({stage:"uploading",progress:vr,totalOperations:yr.totalOperations,uploadedOperations:yr.uploadedOperations})}}}),tr?.({stage:"complete",progress:100}),Sr}catch(mr){if(!(mr instanceof UnsupportedDocumentTypeError)){const hr=mr instanceof Error?mr.message:"Unknown error occurred";tr?.({stage:"failed",progress:100,error:hr})}throw mr}}async function addFolder(t,e,I){const{isAllowedToCreateDocuments:B}=getUserPermissions();if(!B)throw new Error("User is not allowed to create folders");if(isLegacyWriteEnabledSync()){const rr=window.ph?.legacyReactor;if(!rr)throw new Error("Legacy reactor not initialized");const ir=generateId(),lr=await rr.getDrive(t),mr=(await queueActions(lr,addFolder$1({id:ir,name:e,parentFolder:I}))).state.global.nodes.find(hr=>hr.id===ir);if(!mr||!isFolderNode(mr))throw new Error("There was an error adding folder");return mr}else{const rr=window.ph?.reactorClient;if(!rr)throw new Error("ReactorClient not initialized");const{document:ir}=await rr.get(t),lr=generateId(),mr=(await rr.execute(t,"main",[addFolder$1({id:lr,name:e,parentFolder:I})])).state.global.nodes.find(hr=>hr.id===lr);if(!mr||!isFolderNode(mr))throw new Error("There was an error adding folder");return mr}}async function deleteNode(t,e){const{isAllowedToCreateDocuments:I}=getUserPermissions();if(!I)throw new Error("User is not allowed to delete documents");if(isLegacyWriteEnabledSync()){const tr=window.ph?.legacyReactor;if(!tr)throw new Error("Legacy reactor not initialized");const rr=await tr.getDrive(t);await queueActions(rr,deleteNode$1({id:e}))}else{const tr=window.ph?.reactorClient;if(!tr)throw new Error("ReactorClient not initialized");await tr.deleteDocument(e)}}async function renameNode(t,e,I){const{isAllowedToCreateDocuments:B}=getUserPermissions();if(!B)throw new Error("User is not allowed to rename documents");if(isLegacyWriteEnabledSync()){const rr=window.ph?.legacyReactor;if(!rr)throw new Error("Legacy reactor not initialized");const ir=await rr.getDrive(t),dr=(await queueActions(ir,updateNode({id:e,name:I}))).state.global.nodes.find(mr=>mr.id===e);if(!dr)throw new Error("There was an error renaming node");return dr}else{const rr=window.ph?.reactorClient;if(!rr)throw new Error("ReactorClient not initialized");await rr.rename(e,I);const{document:ir}=await rr.get(t),lr=ir.state.global.nodes.find(dr=>dr.id===e);if(!lr)throw new Error("There was an error renaming node");return lr}}async function moveNode(t,e,I){const{isAllowedToCreateDocuments:B}=getUserPermissions();if(!B)throw new Error("User is not allowed to move documents");if(isLegacyWriteEnabledSync()){const rr=window.ph?.legacyReactor;if(!rr)throw new Error("Legacy reactor not initialized");const ir=await rr.getDrive(t);return await queueActions(ir,moveNode$1({srcFolder:e.id,targetParentFolder:I?.id}))}else{const rr=window.ph?.reactorClient;if(!rr)throw new Error("ReactorClient not initialized");const ir=e.parentFolder??t,lr=I?.id??t;return await rr.moveChildren(ir,lr,[e.id])}}function _duplicateDocument(t,e,I=generateId()){const B=t.getDocumentModelModules().find(tr=>tr.documentModel.global.id===e.header.documentType);if(!B)throw new Error(`Document model module for type ${e.header.documentType} not found`);return replayDocument(e.initialState,e.operations,B.reducer,void 0,createPresignedHeader(I,e.header.documentType))}async function copyNode(t,e,I){const B=window.ph?.legacyReactor;if(!B)return;const{isAllowedToCreateDocuments:tr}=getUserPermissions();if(!tr)throw new Error("User is not allowed to copy documents");const rr=await B.getDrive(t),ir=generateNodesCopy({srcId:e.id,targetParentFolder:I?.id,targetName:e.name},()=>generateId(),rr.state.global.nodes),lr=new Map;for(const hr of ir){const fr=rr.state.global.nodes.find(_r=>_r.id===hr.srcId);if(fr){const _r=handleTargetNameCollisions({nodes:rr.state.global.nodes,srcName:hr.targetName||fr.name,targetParentFolder:hr.targetParentFolder||null});lr.set(hr.targetId,_r)}}const dr=ir.filter(hr=>{const fr=rr.state.global.nodes.find(_r=>_r.id===hr.srcId);return fr!==void 0&&isFileNode(fr)});for(const hr of dr)try{const fr=await B.getDocument(hr.srcId),_r=_duplicateDocument(B,fr,hr.targetId),wr=lr.get(hr.targetId);wr&&(_r.header.name=wr),await B.addDocument(_r)}catch(fr){logger.error(`Error copying document ${hr.srcId}: ${String(fr)}`)}const mr=ir.map(hr=>copyNode$1(hr));return await queueActions(rr,mr)}function validateBatchRequest(t){const e=new Set;for(const rr of t){if(e.has(rr.key))throw new Error(`Duplicate plan key: ${rr.key}`);e.add(rr.key)}for(const rr of t)for(const ir of rr.dependsOn)if(!e.has(ir))throw new Error(`Job '${rr.key}' depends on non-existent key: ${ir}`);const I=new Set,B=new Set,tr=rr=>{I.add(rr),B.add(rr);const ir=t.find(lr=>lr.key===rr);if(ir){for(const lr of ir.dependsOn)if(I.has(lr)){if(B.has(lr))return!0}else if(tr(lr))return!0}return B.delete(rr),!1};for(const rr of t)if(!I.has(rr.key)&&tr(rr.key))throw new Error(`Dependency cycle detected involving key: ${rr.key}`);for(const rr of t)if(rr.actions.length===0)throw new Error(`Job '${rr.key}' has empty actions array`)}function validateActionScopes(t){for(const e of t.actions){const I=e.scope||"global";if(I!==t.scope)throw new Error(`Job '${t.key}' declares scope '${t.scope}' but action has scope '${I}'`)}}function topologicalSort(t){const e=[],I=new Set,B=tr=>{if(I.has(tr))return;I.add(tr);const rr=t.find(ir=>ir.key===tr);if(rr)for(const ir of rr.dependsOn)B(ir);e.push(tr)};for(const tr of t)B(tr.key);return e}function toErrorInfo(t){return t instanceof Error?{message:t.message,stack:t.stack||new Error().stack||""}:{message:t,stack:new Error().stack||""}}function filterByType(t,e){return{results:t.results.filter(B=>B.header.documentType===e),options:t.options,nextCursor:t.nextCursor,next:t.next?async()=>{const B=await t.next();return filterByType(B,e)}:void 0}}function getSharedScope(t){if(t.length===0)throw new Error("No operations provided");const e=t[0].action.scope;for(const[I,B]of t.entries()){const tr=B.action.scope;if(tr!==e)throw new Error(`All operations in load must share the same scope. Expected '${e}', received '${tr}' at position ${I}`)}return e}const signAction=async(t,e,I)=>{const B=await e.sign(t,I);return{...t,context:{...t.context,signer:{user:{address:B[0],networkId:"",chainId:0},app:{name:"",key:B[1]},signatures:[B]}}}},signActions=async(t,e,I)=>Promise.all(t.map(B=>signAction(B,e,I)));class EventBusAggregateError extends Error{errors;constructor(e){const I=`EventBus emit failed with ${e.length} error(s): ${e.map(B=>B&&typeof B=="object"&&"message"in B?B.message:String(B)).join("; ")}`;super(I),this.name="EventBusAggregateError",this.errors=e}}const OperationEventTypes={OPERATION_WRITTEN:10001,OPERATIONS_READY:10002,JOB_FAILED:10003};var PropagationMode;(function(t){t.None="none",t.Cascade="cascade"})(PropagationMode||(PropagationMode={}));var RelationshipChangeType;(function(t){t.Added="added",t.Removed="removed"})(RelationshipChangeType||(RelationshipChangeType={}));var JobStatus;(function(t){t.PENDING="PENDING",t.RUNNING="RUNNING",t.WRITE_COMPLETED="WRITE_COMPLETED",t.READ_MODELS_READY="READ_MODELS_READY",t.FAILED="FAILED"})(JobStatus||(JobStatus={}));function isTerminalStatus(t){return t===JobStatus.READ_MODELS_READY||t===JobStatus.FAILED}class JobAwaiter{eventBus;getJobStatus;pendingJobs=new Map;unsubscribers=[];constructor(e,I){this.eventBus=e,this.getJobStatus=I,this.subscribeToEvents()}subscribeToEvents(){this.unsubscribers.push(this.eventBus.subscribe(OperationEventTypes.OPERATION_WRITTEN,async(e,I)=>{await this.handleOperationWritten(I)})),this.unsubscribers.push(this.eventBus.subscribe(OperationEventTypes.OPERATIONS_READY,async(e,I)=>{await this.handleOperationsReady(I)})),this.unsubscribers.push(this.eventBus.subscribe(OperationEventTypes.JOB_FAILED,async(e,I)=>{await this.handleJobFailed(I)}))}shutdown(){for(const e of this.unsubscribers)e();this.unsubscribers=[];for(const[,e]of this.pendingJobs)for(const I of e)I.reject(new Error("JobAwaiter destroyed"));this.pendingJobs.clear()}async waitForJob(e,I){if(I?.aborted)throw new Error("Operation aborted");const B=await this.getJobStatus(e,I);return isTerminalStatus(B.status)?B:new Promise((rr,ir)=>{const lr={resolve:rr,reject:ir,signal:I},dr=this.pendingJobs.get(e)||[];if(dr.push(lr),this.pendingJobs.set(e,dr),I){const mr=()=>{const hr=this.pendingJobs.get(e);if(hr){const fr=hr.indexOf(lr);fr!==-1&&(hr.splice(fr,1),hr.length===0&&this.pendingJobs.delete(e),lr.reject(new Error("Operation aborted")))}};I.addEventListener("abort",mr,{once:!0})}})}async handleOperationWritten(e){const I=e.jobId;await this.checkAndResolveWaiters(I)}async handleOperationsReady(e){const I=e.jobId;await this.checkAndResolveWaiters(I)}async handleJobFailed(e){await this.checkAndResolveWaiters(e.jobId)}async checkAndResolveWaiters(e){const I=this.pendingJobs.get(e);if(!(!I||I.length===0))try{const B=I.filter(rr=>!rr.signal?.aborted);if(B.length===0){this.pendingJobs.delete(e);return}const tr=await this.getJobStatus(e,B[0].signal);if(isTerminalStatus(tr.status)){this.pendingJobs.delete(e);for(const rr of B)rr.resolve(tr);for(const rr of I)rr.signal?.aborted&&rr.reject(new Error("Operation aborted"))}}catch(B){this.pendingJobs.delete(e);for(const tr of I)tr.reject(B instanceof Error?B:new Error(String(B)))}}}var DocumentChangeType;(function(t){t.Created="created",t.Deleted="deleted",t.Updated="updated",t.ParentAdded="parent_added",t.ParentRemoved="parent_removed",t.ChildAdded="child_added",t.ChildRemoved="child_removed"})(DocumentChangeType||(DocumentChangeType={}));class ReactorClient{reactor;signer;subscriptionManager;jobAwaiter;documentIndexer;constructor(e,I,B,tr,rr){this.reactor=e,this.signer=I,this.subscriptionManager=B,this.jobAwaiter=tr,this.documentIndexer=rr}async getDocumentModels(e,I,B){return this.reactor.getDocumentModels(e,I,B)}async get(e,I,B){return await this.reactor.getByIdOrSlug(e,I,void 0,B)}async getChildren(e,I,B,tr){const ir=(await this.reactor.getByIdOrSlug(e,I,void 0,tr)).document.header.id,dr=(await this.documentIndexer.getOutgoing(ir,void 0,void 0,tr)).map(mr=>mr.targetId);return dr.length===0?{results:[],options:B||{cursor:"0",limit:0}}:this.reactor.find({ids:dr},I,B,void 0,tr)}async getParents(e,I,B,tr){const ir=(await this.reactor.getByIdOrSlug(e,I,void 0,tr)).document.header.id,dr=(await this.documentIndexer.getIncoming(ir,void 0,void 0,tr)).map(mr=>mr.sourceId);return dr.length===0?{results:[],options:B||{cursor:"0",limit:0}}:this.reactor.find({ids:dr},I,B,void 0,tr)}async find(e,I,B,tr){return this.reactor.find(e,I,B,void 0,tr)}async create(e,I,B){const tr=await this.reactor.create(e,this.signer,B),rr=await this.waitForJob(tr,B);if(rr.status===JobStatus.FAILED)throw new Error(rr.error?.message);const ir=e.header.id,lr=await this.reactor.get(ir,void 0,rr.consistencyToken,B);return I&&await this.addChildren(I,[ir],void 0,B),lr.document}async createEmpty(e,I,B){const rr=(await this.reactor.getDocumentModels(void 0,void 0,B)).results.find(lr=>lr.documentModel.global.id===e);if(!rr)throw new Error(`Document model not found for type: ${e}`);const ir=rr.utils.createDocument();return this.create(ir,I,B)}async execute(e,I,B,tr){const rr=await signActions(B,this.signer,tr),ir=await this.reactor.execute(e,I,rr,tr),lr=await this.waitForJob(ir,tr);if(lr.status===JobStatus.FAILED)throw new Error(lr.error?.message);const dr={branch:I};return(await this.reactor.getByIdOrSlug(e,dr,lr.consistencyToken,tr)).document}async executeAsync(e,I,B,tr){const rr=await signActions(B,this.signer,tr);return this.reactor.execute(e,I,rr,tr)}async rename(e,I,B="main",tr){return this.execute(e,B,[actions.setName(I)],tr)}async addChildren(e,I,B="main",tr){const rr=await this.reactor.addChildren(e,I,B,this.signer,tr),ir=await this.waitForJob(rr,tr);if(ir.status===JobStatus.FAILED)throw new Error(ir.error?.message);return(await this.reactor.getByIdOrSlug(e,{branch:B},ir.consistencyToken,tr)).document}async removeChildren(e,I,B="main",tr){const rr=await this.reactor.removeChildren(e,I,B,this.signer,tr),ir=await this.waitForJob(rr,tr);if(ir.status===JobStatus.FAILED)throw new Error(ir.error?.message);return(await this.reactor.getByIdOrSlug(e,{branch:B},ir.consistencyToken,tr)).document}async moveChildren(e,I,B,tr="main",rr){const ir=await this.reactor.removeChildren(e,B,tr,this.signer,rr),lr=await this.waitForJob(ir,rr);if(lr.status===JobStatus.FAILED)throw new Error(lr.error?.message);const dr=await this.reactor.addChildren(I,B,tr,this.signer,rr),mr=await this.waitForJob(dr,rr);if(mr.status===JobStatus.FAILED)throw new Error(mr.error?.message);const hr=await this.reactor.getByIdOrSlug(e,{branch:tr},lr.consistencyToken,rr),fr=await this.reactor.getByIdOrSlug(I,{branch:tr},mr.consistencyToken,rr);return{source:hr.document,target:fr.document}}async deleteDocument(e,I,B){const tr=[];if(I===PropagationMode.Cascade){const lr=[],dr=[e],mr=new Set;for(;dr.length>0;){const hr=dr.shift();if(mr.has(hr))continue;if(mr.add(hr),B?.aborted)throw new Error("Operation aborted");const fr=await this.documentIndexer.getOutgoing(hr,["child"],void 0,B);for(const _r of fr)mr.has(_r.targetId)||(lr.push(_r.targetId),dr.push(_r.targetId))}for(const hr of lr){const fr=await this.reactor.deleteDocument(hr,this.signer,B);tr.push(fr)}}const rr=await this.reactor.deleteDocument(e,this.signer,B);tr.push(rr);const ir=await Promise.all(tr.map(lr=>this.waitForJob(lr,B)));for(const lr of ir)if(lr.status===JobStatus.FAILED)throw new Error(lr.error?.message)}async deleteDocuments(e,I,B){const tr=e.map(rr=>this.deleteDocument(rr,I,B));await Promise.all(tr)}async getJobStatus(e,I){return this.reactor.getJobStatus(e,I)}async waitForJob(e,I){const B=typeof e=="string"?e:e.id;return this.jobAwaiter.waitForJob(B,I)}subscribe(e,I,B){const tr=this.subscriptionManager.onDocumentCreated(dr=>{(async()=>{try{const mr=await Promise.all(dr.results.map(hr=>this.reactor.get(hr,B,void 0,void 0).then(fr=>fr.document)));I({type:DocumentChangeType.Created,documents:mr})}catch{}})()},e),rr=this.subscriptionManager.onDocumentDeleted(dr=>{I({type:DocumentChangeType.Deleted,documents:[],context:{childId:dr[0]}})},e),ir=this.subscriptionManager.onDocumentStateUpdated(dr=>{I({type:DocumentChangeType.Updated,documents:dr.results})},e,B),lr=this.subscriptionManager.onRelationshipChanged((dr,mr,hr)=>{I({type:hr===RelationshipChangeType.Added?DocumentChangeType.ChildAdded:DocumentChangeType.ChildRemoved,documents:[],context:{parentId:dr,childId:mr}})},e);return()=>{tr(),rr(),ir(),lr()}}}function createDocumentFromAction(t){const e=t.input,I=createPresignedHeader();I.id=e.documentId,I.documentType=e.model,e.signing&&(I.createdAtUtcIso=e.signing.createdAtUtcIso,I.lastModifiedAtUtcIso=e.signing.createdAtUtcIso,I.sig={publicKey:e.signing.publicKey,nonce:e.signing.nonce}),e.slug!==void 0&&(I.slug=e.slug),I.slug||(I.slug=e.documentId),e.name!==void 0&&(I.name=e.name),e.branch!==void 0&&(I.branch=e.branch),e.meta!==void 0&&(I.meta=e.meta);const B=defaultBaseState();return{header:I,operations:{},state:B,initialState:B,clipboard:[]}}function applyUpgradeDocumentAction(t,e){const I=e.input,B=I.initialState||I.state;return B&&(t.state={...t.state,...B},t.initialState=t.state),t}function applyDeleteDocumentAction(t,e){const I=e.timestampUtcMs||new Date().toISOString();return t.state={...t.state,document:{...t.state.document,isDeleted:!0,deletedAtUtcIso:I}},t}const getNextIndexForScope=(t,e)=>t.header.revision[e]||0;function createEmptyConsistencyToken(){return{version:1,createdAtUtcIso:new Date().toISOString(),coordinates:[]}}function createConsistencyToken(t){if(t.length===0)return createEmptyConsistencyToken();const e=[];for(let I=0;I<t.length;I++){const B=t[I];e.push({documentId:B.context.documentId,scope:B.context.scope,branch:B.context.branch,operationIndex:B.operation.index})}return{version:1,createdAtUtcIso:new Date().toISOString(),coordinates:e}}class LRUNode{key;prev;next;constructor(e){this.key=e,this.prev=void 0,this.next=void 0}}class LRUTracker{map;head;tail;constructor(){this.map=new Map,this.head=void 0,this.tail=void 0}get size(){return this.map.size}touch(e){const I=this.map.get(e);I?this.moveToFront(I):this.addToFront(e)}evict(){if(!this.tail)return;const e=this.tail.key;return this.remove(e),e}remove(e){const I=this.map.get(e);I&&(this.removeNode(I),this.map.delete(e))}clear(){this.map.clear(),this.head=void 0,this.tail=void 0}addToFront(e){const I=new LRUNode(e);this.map.set(e,I),this.head?(I.next=this.head,this.head.prev=I,this.head=I):(this.head=I,this.tail=I)}moveToFront(e){e!==this.head&&(this.removeNode(e),e.prev=void 0,e.next=this.head,this.head&&(this.head.prev=e),this.head=e,this.tail||(this.tail=e))}removeNode(e){e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev}}class DocumentMetaCache{cache;lruTracker;operationStore;config;constructor(e,I){this.operationStore=e,this.config={maxDocuments:I.maxDocuments},this.cache=new Map,this.lruTracker=new LRUTracker}async startup(){return Promise.resolve()}async shutdown(){return Promise.resolve()}async getDocumentMeta(e,I,B){if(B?.aborted)throw new Error("Operation aborted");const tr=this.makeKey(e,I),rr=this.cache.get(tr);if(rr)return this.lruTracker.touch(tr),rr;const ir=await this.rebuildLatest(e,I,B);return this.putDocumentMeta(e,I,ir),ir}async rebuildAtRevision(e,I,B,tr){if(tr?.aborted)throw new Error("Operation aborted");return this.rebuildFromOperations(e,I,B,tr)}putDocumentMeta(e,I,B){const tr=this.makeKey(e,I);if(!this.cache.has(tr)&&this.cache.size>=this.config.maxDocuments){const rr=this.lruTracker.evict();rr&&this.cache.delete(rr)}this.cache.set(tr,structuredClone(B)),this.lruTracker.touch(tr)}invalidate(e,I){let B=0;if(I===void 0)for(const tr of this.cache.keys())tr.startsWith(`${e}:`)&&(this.cache.delete(tr),this.lruTracker.remove(tr),B++);else{const tr=this.makeKey(e,I);this.cache.has(tr)&&(this.cache.delete(tr),this.lruTracker.remove(tr),B=1)}return B}clear(){this.cache.clear(),this.lruTracker.clear()}makeKey(e,I){return`${e}:${I}`}async rebuildLatest(e,I,B){return this.rebuildFromOperations(e,I,void 0,B)}async rebuildFromOperations(e,I,B,tr){const rr=await this.operationStore.getSince(e,"document",I,-1,void 0,tr);if(rr.items.length===0)throw new Error(`Document ${e} not found`);const ir=rr.items[0];if(ir.action.type!=="CREATE_DOCUMENT")throw new Error(`Invalid document: first operation must be CREATE_DOCUMENT, found ${ir.action.type}`);const lr=ir.action,dr=lr.input.model;let mr=createDocumentFromAction(lr),hr=0;for(const fr of rr.items){if(B!==void 0&&fr.index>B)break;hr=fr.index,fr.action.type==="UPGRADE_DOCUMENT"?mr=applyUpgradeDocumentAction(mr,fr.action):fr.action.type==="DELETE_DOCUMENT"&&(mr=applyDeleteDocumentAction(mr,fr.action))}return{state:mr.state.document,documentType:dr,documentScopeRevision:hr+1}}}function isUndefined(t){return typeof t>"u"||t===void 0}function isString(t){return typeof t=="string"}function isNumber(t){return typeof t=="number"}function isBoolean(t){return typeof t=="boolean"}function isNull(t){return t===null}function isDate(t){return t instanceof Date}function isBigInt(t){return typeof t=="bigint"}function isFunction(t){return typeof t=="function"}function isObject(t){return typeof t=="object"&&t!==null}function getLast(t){return t[t.length-1]}function freeze(t){return Object.freeze(t)}function asArray$1(t){return isReadonlyArray(t)?t:[t]}function isReadonlyArray(t){return Array.isArray(t)}function noop(t){return t}const AlterTableNode=freeze({is(t){return t.kind==="AlterTableNode"},create(t){return freeze({kind:"AlterTableNode",table:t})},cloneWithTableProps(t,e){return freeze({...t,...e})},cloneWithColumnAlteration(t,e){return freeze({...t,columnAlterations:t.columnAlterations?[...t.columnAlterations,e]:[e]})}}),IdentifierNode=freeze({is(t){return t.kind==="IdentifierNode"},create(t){return freeze({kind:"IdentifierNode",name:t})}}),CreateIndexNode=freeze({is(t){return t.kind==="CreateIndexNode"},create(t){return freeze({kind:"CreateIndexNode",name:IdentifierNode.create(t)})},cloneWith(t,e){return freeze({...t,...e})},cloneWithColumns(t,e){return freeze({...t,columns:[...t.columns||[],...e]})}}),CreateSchemaNode=freeze({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return freeze({kind:"CreateSchemaNode",schema:IdentifierNode.create(t),...e})},cloneWith(t,e){return freeze({...t,...e})}}),ON_COMMIT_ACTIONS=["preserve rows","delete rows","drop"],CreateTableNode=freeze({is(t){return t.kind==="CreateTableNode"},create(t){return freeze({kind:"CreateTableNode",table:t,columns:freeze([])})},cloneWithColumn(t,e){return freeze({...t,columns:freeze([...t.columns,e])})},cloneWithConstraint(t,e){return freeze({...t,constraints:t.constraints?freeze([...t.constraints,e]):freeze([e])})},cloneWithFrontModifier(t,e){return freeze({...t,frontModifiers:t.frontModifiers?freeze([...t.frontModifiers,e]):freeze([e])})},cloneWithEndModifier(t,e){return freeze({...t,endModifiers:t.endModifiers?freeze([...t.endModifiers,e]):freeze([e])})},cloneWith(t,e){return freeze({...t,...e})}}),SchemableIdentifierNode=freeze({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return freeze({kind:"SchemableIdentifierNode",identifier:IdentifierNode.create(t)})},createWithSchema(t,e){return freeze({kind:"SchemableIdentifierNode",schema:IdentifierNode.create(t),identifier:IdentifierNode.create(e)})}}),DropIndexNode=freeze({is(t){return t.kind==="DropIndexNode"},create(t,e){return freeze({kind:"DropIndexNode",name:SchemableIdentifierNode.create(t),...e})},cloneWith(t,e){return freeze({...t,...e})}}),DropSchemaNode=freeze({is(t){return t.kind==="DropSchemaNode"},create(t,e){return freeze({kind:"DropSchemaNode",schema:IdentifierNode.create(t),...e})},cloneWith(t,e){return freeze({...t,...e})}}),DropTableNode=freeze({is(t){return t.kind==="DropTableNode"},create(t,e){return freeze({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return freeze({...t,...e})}}),AliasNode=freeze({is(t){return t.kind==="AliasNode"},create(t,e){return freeze({kind:"AliasNode",node:t,alias:e})}}),TableNode=freeze({is(t){return t.kind==="TableNode"},create(t){return freeze({kind:"TableNode",table:SchemableIdentifierNode.create(t)})},createWithSchema(t,e){return freeze({kind:"TableNode",table:SchemableIdentifierNode.createWithSchema(t,e)})}});function isOperationNodeSource(t){return isObject(t)&&isFunction(t.toOperationNode)}function isExpression(t){return isObject(t)&&"expressionType"in t&&isOperationNodeSource(t)}function isAliasedExpression(t){return isObject(t)&&"expression"in t&&isString(t.alias)&&isOperationNodeSource(t)}const SelectModifierNode=freeze({is(t){return t.kind==="SelectModifierNode"},create(t,e){return freeze({kind:"SelectModifierNode",modifier:t,of:e})},createWithExpression(t){return freeze({kind:"SelectModifierNode",rawModifier:t})}}),AndNode=freeze({is(t){return t.kind==="AndNode"},create(t,e){return freeze({kind:"AndNode",left:t,right:e})}}),OrNode=freeze({is(t){return t.kind==="OrNode"},create(t,e){return freeze({kind:"OrNode",left:t,right:e})}}),OnNode=freeze({is(t){return t.kind==="OnNode"},create(t){return freeze({kind:"OnNode",on:t})},cloneWithOperation(t,e,I){return freeze({...t,on:e==="And"?AndNode.create(t.on,I):OrNode.create(t.on,I)})}}),JoinNode=freeze({is(t){return t.kind==="JoinNode"},create(t,e){return freeze({kind:"JoinNode",joinType:t,table:e,on:void 0})},createWithOn(t,e,I){return freeze({kind:"JoinNode",joinType:t,table:e,on:OnNode.create(I)})},cloneWithOn(t,e){return freeze({...t,on:t.on?OnNode.cloneWithOperation(t.on,"And",e):OnNode.create(e)})}}),BinaryOperationNode=freeze({is(t){return t.kind==="BinaryOperationNode"},create(t,e,I){return freeze({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:I})}}),COMPARISON_OPERATORS=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","^@","&&","?","?&","?|","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp","is distinct from","is not distinct from"],ARITHMETIC_OPERATORS=["+","-","*","/","%","^","&","|","#","<<",">>"],JSON_OPERATORS=["->","->>"],BINARY_OPERATORS=[...COMPARISON_OPERATORS,...ARITHMETIC_OPERATORS,"&&","||"],UNARY_FILTER_OPERATORS=["exists","not exists"],UNARY_OPERATORS=["not","-",...UNARY_FILTER_OPERATORS],OPERATORS=[...BINARY_OPERATORS,...JSON_OPERATORS,...UNARY_OPERATORS,"between","between symmetric"],OperatorNode=freeze({is(t){return t.kind==="OperatorNode"},create(t){return freeze({kind:"OperatorNode",operator:t})}});function isJSONOperator(t){return isString(t)&&JSON_OPERATORS.includes(t)}const ColumnNode=freeze({is(t){return t.kind==="ColumnNode"},create(t){return freeze({kind:"ColumnNode",column:IdentifierNode.create(t)})}}),SelectAllNode=freeze({is(t){return t.kind==="SelectAllNode"},create(){return freeze({kind:"SelectAllNode"})}}),ReferenceNode=freeze({is(t){return t.kind==="ReferenceNode"},create(t,e){return freeze({kind:"ReferenceNode",table:e,column:t})},createSelectAll(t){return freeze({kind:"ReferenceNode",table:t,column:SelectAllNode.create()})}});class DynamicReferenceBuilder{#e;get dynamicReference(){return this.#e}get refType(){}constructor(e){this.#e=e}toOperationNode(){return parseSimpleReferenceExpression(this.#e)}}function isDynamicReferenceBuilder(t){return isObject(t)&&isOperationNodeSource(t)&&isString(t.dynamicReference)}const OrderByItemNode=freeze({is(t){return t.kind==="OrderByItemNode"},create(t,e){return freeze({kind:"OrderByItemNode",orderBy:t,direction:e})},cloneWith(t,e){return freeze({...t,...e})}}),RawNode=freeze({is(t){return t.kind==="RawNode"},create(t,e){return freeze({kind:"RawNode",sqlFragments:freeze(t),parameters:freeze(e)})},createWithSql(t){return RawNode.create([t],[])},createWithChild(t){return RawNode.create(["",""],[t])},createWithChildren(t){return RawNode.create(new Array(t.length+1).fill(""),t)}}),CollateNode={is(t){return t.kind==="CollateNode"},create(t){return freeze({kind:"CollateNode",collation:IdentifierNode.create(t)})}};class OrderByItemBuilder{#e;constructor(e){this.#e=freeze(e)}desc(){return new OrderByItemBuilder({node:OrderByItemNode.cloneWith(this.#e.node,{direction:RawNode.createWithSql("desc")})})}asc(){return new OrderByItemBuilder({node:OrderByItemNode.cloneWith(this.#e.node,{direction:RawNode.createWithSql("asc")})})}nullsLast(){return new OrderByItemBuilder({node:OrderByItemNode.cloneWith(this.#e.node,{nulls:"last"})})}nullsFirst(){return new OrderByItemBuilder({node:OrderByItemNode.cloneWith(this.#e.node,{nulls:"first"})})}collate(e){return new OrderByItemBuilder({node:OrderByItemNode.cloneWith(this.#e.node,{collation:CollateNode.create(e)})})}toOperationNode(){return this.#e.node}}const LOGGED_MESSAGES=new Set;function logOnce(t){LOGGED_MESSAGES.has(t)||(LOGGED_MESSAGES.add(t),console.log(t))}function isOrderByDirection(t){return t==="asc"||t==="desc"}function parseOrderBy(t){if(t.length===2)return[parseOrderByItem(t[0],t[1])];if(t.length===1){const[e]=t;return Array.isArray(e)?(logOnce("orderBy(array) is deprecated, use multiple orderBy calls instead."),e.map(I=>parseOrderByItem(I))):[parseOrderByItem(e)]}throw new Error(`Invalid number of arguments at order by! expected 1-2, received ${t.length}`)}function parseOrderByItem(t,e){const I=parseOrderByExpression(t);if(OrderByItemNode.is(I)){if(e)throw new Error("Cannot specify direction twice!");return I}return parseOrderByWithModifiers(I,e)}function parseOrderByExpression(t){if(isExpressionOrFactory(t))return parseExpression(t);if(isDynamicReferenceBuilder(t))return t.toOperationNode();const[e,I]=t.split(" ");return I?(logOnce("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),parseOrderByWithModifiers(parseStringReference(e),I)):parseStringReference(t)}function parseOrderByWithModifiers(t,e){if(typeof e=="string"){if(!isOrderByDirection(e))throw new Error(`Invalid order by direction: ${e}`);return OrderByItemNode.create(t,RawNode.createWithSql(e))}if(isExpression(e))return logOnce("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),OrderByItemNode.create(t,e.toOperationNode());const I=OrderByItemNode.create(t);return e?e(new OrderByItemBuilder({node:I})).toOperationNode():I}const JSONReferenceNode=freeze({is(t){return t.kind==="JSONReferenceNode"},create(t,e){return freeze({kind:"JSONReferenceNode",reference:t,traversal:e})},cloneWithTraversal(t,e){return freeze({...t,traversal:e})}}),JSONOperatorChainNode=freeze({is(t){return t.kind==="JSONOperatorChainNode"},create(t){return freeze({kind:"JSONOperatorChainNode",operator:t,values:freeze([])})},cloneWithValue(t,e){return freeze({...t,values:freeze([...t.values,e])})}}),JSONPathNode=freeze({is(t){return t.kind==="JSONPathNode"},create(t){return freeze({kind:"JSONPathNode",inOperator:t,pathLegs:freeze([])})},cloneWithLeg(t,e){return freeze({...t,pathLegs:freeze([...t.pathLegs,e])})}});function parseSimpleReferenceExpression(t){return isString(t)?parseStringReference(t):t.toOperationNode()}function parseReferenceExpressionOrList(t){return isReadonlyArray(t)?t.map(e=>parseReferenceExpression(e)):[parseReferenceExpression(t)]}function parseReferenceExpression(t){return isExpressionOrFactory(t)?parseExpression(t):parseSimpleReferenceExpression(t)}function parseJSONReference(t,e){const I=parseStringReference(t);if(isJSONOperator(e))return JSONReferenceNode.create(I,JSONOperatorChainNode.create(OperatorNode.create(e)));const B=e.slice(0,-1);if(isJSONOperator(B))return JSONReferenceNode.create(I,JSONPathNode.create(OperatorNode.create(B)));throw new Error(`Invalid JSON operator: ${e}`)}function parseStringReference(t){if(!t.includes("."))return ReferenceNode.create(ColumnNode.create(t));const I=t.split(".").map(trim$2);if(I.length===3)return parseStringReferenceWithTableAndSchema(I);if(I.length===2)return parseStringReferenceWithTable(I);throw new Error(`invalid column reference ${t}`)}function parseAliasedStringReference(t){const e=" as ";if(t.includes(e)){const[I,B]=t.split(e).map(trim$2);return AliasNode.create(parseStringReference(I),IdentifierNode.create(B))}else return parseStringReference(t)}function parseColumnName(t){return ColumnNode.create(t)}function parseOrderedColumnName(t){if(t.includes(" ")){const[I,B]=t.split(" ").map(trim$2);if(!isOrderByDirection(B))throw new Error(`invalid order direction "${B}" next to "${I}"`);return parseOrderBy([I,B])[0]}else return parseColumnName(t)}function parseStringReferenceWithTableAndSchema(t){const[e,I,B]=t;return ReferenceNode.create(ColumnNode.create(B),TableNode.createWithSchema(e,I))}function parseStringReferenceWithTable(t){const[e,I]=t;return ReferenceNode.create(ColumnNode.create(I),TableNode.create(e))}function trim$2(t){return t.trim()}const PrimitiveValueListNode=freeze({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return freeze({kind:"PrimitiveValueListNode",values:freeze([...t])})}}),ValueListNode=freeze({is(t){return t.kind==="ValueListNode"},create(t){return freeze({kind:"ValueListNode",values:freeze(t)})}}),ValueNode=freeze({is(t){return t.kind==="ValueNode"},create(t){return freeze({kind:"ValueNode",value:t})},createImmediate(t){return freeze({kind:"ValueNode",value:t,immediate:!0})}});function parseValueExpressionOrList(t){return isReadonlyArray(t)?parseValueExpressionList(t):parseValueExpression(t)}function parseValueExpression(t){return isExpressionOrFactory(t)?parseExpression(t):ValueNode.create(t)}function isSafeImmediateValue(t){return isNumber(t)||isBoolean(t)||isNull(t)}function parseSafeImmediateValue(t){if(!isSafeImmediateValue(t))throw new Error(`unsafe immediate value ${JSON.stringify(t)}`);return ValueNode.createImmediate(t)}function parseValueExpressionList(t){return t.some(isExpressionOrFactory)?ValueListNode.create(t.map(e=>parseValueExpression(e))):PrimitiveValueListNode.create(t)}const ParensNode=freeze({is(t){return t.kind==="ParensNode"},create(t){return freeze({kind:"ParensNode",node:t})}});function parseValueBinaryOperationOrExpression(t){if(t.length===3)return parseValueBinaryOperation(t[0],t[1],t[2]);if(t.length===1)return parseValueExpression(t[0]);throw new Error(`invalid arguments: ${JSON.stringify(t)}`)}function parseValueBinaryOperation(t,e,I){return isIsOperator(e)&&needsIsOperator(I)?BinaryOperationNode.create(parseReferenceExpression(t),parseOperator(e),ValueNode.createImmediate(I)):BinaryOperationNode.create(parseReferenceExpression(t),parseOperator(e),parseValueExpressionOrList(I))}function parseReferentialBinaryOperation(t,e,I){return BinaryOperationNode.create(parseReferenceExpression(t),parseOperator(e),parseReferenceExpression(I))}function parseFilterObject(t,e){return parseFilterList(Object.entries(t).filter(([,I])=>!isUndefined(I)).map(([I,B])=>parseValueBinaryOperation(I,needsIsOperator(B)?"is":"=",B)),e)}function parseFilterList(t,e,I=!0){const B=e==="and"?AndNode.create:OrNode.create;if(t.length===0)return BinaryOperationNode.create(ValueNode.createImmediate(1),OperatorNode.create("="),ValueNode.createImmediate(e==="and"?1:0));let tr=toOperationNode(t[0]);for(let rr=1;rr<t.length;++rr)tr=B(tr,toOperationNode(t[rr]));return t.length>1&&I?ParensNode.create(tr):tr}function isIsOperator(t){return t==="is"||t==="is not"}function needsIsOperator(t){return isNull(t)||isBoolean(t)}function parseOperator(t){if(isString(t)&&OPERATORS.includes(t))return OperatorNode.create(t);if(isOperationNodeSource(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function toOperationNode(t){return isOperationNodeSource(t)?t.toOperationNode():t}const OrderByNode=freeze({is(t){return t.kind==="OrderByNode"},create(t){return freeze({kind:"OrderByNode",items:freeze([...t])})},cloneWithItems(t,e){return freeze({...t,items:freeze([...t.items,...e])})}}),PartitionByNode=freeze({is(t){return t.kind==="PartitionByNode"},create(t){return freeze({kind:"PartitionByNode",items:freeze(t)})},cloneWithItems(t,e){return freeze({...t,items:freeze([...t.items,...e])})}}),OverNode=freeze({is(t){return t.kind==="OverNode"},create(){return freeze({kind:"OverNode"})},cloneWithOrderByItems(t,e){return freeze({...t,orderBy:t.orderBy?OrderByNode.cloneWithItems(t.orderBy,e):OrderByNode.create(e)})},cloneWithPartitionByItems(t,e){return freeze({...t,partitionBy:t.partitionBy?PartitionByNode.cloneWithItems(t.partitionBy,e):PartitionByNode.create(e)})}}),FromNode=freeze({is(t){return t.kind==="FromNode"},create(t){return freeze({kind:"FromNode",froms:freeze(t)})},cloneWithFroms(t,e){return freeze({...t,froms:freeze([...t.froms,...e])})}}),GroupByNode=freeze({is(t){return t.kind==="GroupByNode"},create(t){return freeze({kind:"GroupByNode",items:freeze(t)})},cloneWithItems(t,e){return freeze({...t,items:freeze([...t.items,...e])})}}),HavingNode=freeze({is(t){return t.kind==="HavingNode"},create(t){return freeze({kind:"HavingNode",having:t})},cloneWithOperation(t,e,I){return freeze({...t,having:e==="And"?AndNode.create(t.having,I):OrNode.create(t.having,I)})}}),InsertQueryNode=freeze({is(t){return t.kind==="InsertQueryNode"},create(t,e,I){return freeze({kind:"InsertQueryNode",into:t,...e&&{with:e},replace:I})},createWithoutInto(){return freeze({kind:"InsertQueryNode"})},cloneWith(t,e){return freeze({...t,...e})}}),ListNode=freeze({is(t){return t.kind==="ListNode"},create(t){return freeze({kind:"ListNode",items:freeze(t)})}}),UpdateQueryNode=freeze({is(t){return t.kind==="UpdateQueryNode"},create(t,e){return freeze({kind:"UpdateQueryNode",table:t.length===1?t[0]:ListNode.create(t),...e&&{with:e}})},createWithoutTable(){return freeze({kind:"UpdateQueryNode"})},cloneWithFromItems(t,e){return freeze({...t,from:t.from?FromNode.cloneWithFroms(t.from,e):FromNode.create(e)})},cloneWithUpdates(t,e){return freeze({...t,updates:t.updates?freeze([...t.updates,...e]):e})},cloneWithLimit(t,e){return freeze({...t,limit:e})}}),UsingNode=freeze({is(t){return t.kind==="UsingNode"},create(t){return freeze({kind:"UsingNode",tables:freeze(t)})},cloneWithTables(t,e){return freeze({...t,tables:freeze([...t.tables,...e])})}}),DeleteQueryNode=freeze({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return freeze({kind:"DeleteQueryNode",from:FromNode.create(t),...e&&{with:e}})},cloneWithOrderByItems:(t,e)=>QueryNode.cloneWithOrderByItems(t,e),cloneWithoutOrderBy:t=>QueryNode.cloneWithoutOrderBy(t),cloneWithLimit(t,e){return freeze({...t,limit:e})},cloneWithoutLimit(t){return freeze({...t,limit:void 0})},cloneWithUsing(t,e){return freeze({...t,using:t.using!==void 0?UsingNode.cloneWithTables(t.using,e):UsingNode.create(e)})}}),WhereNode=freeze({is(t){return t.kind==="WhereNode"},create(t){return freeze({kind:"WhereNode",where:t})},cloneWithOperation(t,e,I){return freeze({...t,where:e==="And"?AndNode.create(t.where,I):OrNode.create(t.where,I)})}}),ReturningNode=freeze({is(t){return t.kind==="ReturningNode"},create(t){return freeze({kind:"ReturningNode",selections:freeze(t)})},cloneWithSelections(t,e){return freeze({...t,selections:t.selections?freeze([...t.selections,...e]):freeze(e)})}}),ExplainNode=freeze({is(t){return t.kind==="ExplainNode"},create(t,e){return freeze({kind:"ExplainNode",format:t,options:e})}}),WhenNode=freeze({is(t){return t.kind==="WhenNode"},create(t){return freeze({kind:"WhenNode",condition:t})},cloneWithResult(t,e){return freeze({...t,result:e})}}),MergeQueryNode=freeze({is(t){return t.kind==="MergeQueryNode"},create(t,e){return freeze({kind:"MergeQueryNode",into:t,...e&&{with:e}})},cloneWithUsing(t,e){return freeze({...t,using:e})},cloneWithWhen(t,e){return freeze({...t,whens:t.whens?freeze([...t.whens,e]):freeze([e])})},cloneWithThen(t,e){return freeze({...t,whens:t.whens?freeze([...t.whens.slice(0,-1),WhenNode.cloneWithResult(t.whens[t.whens.length-1],e)]):void 0})}}),OutputNode=freeze({is(t){return t.kind==="OutputNode"},create(t){return freeze({kind:"OutputNode",selections:freeze(t)})},cloneWithSelections(t,e){return freeze({...t,selections:t.selections?freeze([...t.selections,...e]):freeze(e)})}}),QueryNode=freeze({is(t){return SelectQueryNode.is(t)||InsertQueryNode.is(t)||UpdateQueryNode.is(t)||DeleteQueryNode.is(t)||MergeQueryNode.is(t)},cloneWithEndModifier(t,e){return freeze({...t,endModifiers:t.endModifiers?freeze([...t.endModifiers,e]):freeze([e])})},cloneWithWhere(t,e){return freeze({...t,where:t.where?WhereNode.cloneWithOperation(t.where,"And",e):WhereNode.create(e)})},cloneWithJoin(t,e){return freeze({...t,joins:t.joins?freeze([...t.joins,e]):freeze([e])})},cloneWithReturning(t,e){return freeze({...t,returning:t.returning?ReturningNode.cloneWithSelections(t.returning,e):ReturningNode.create(e)})},cloneWithoutReturning(t){return freeze({...t,returning:void 0})},cloneWithoutWhere(t){return freeze({...t,where:void 0})},cloneWithExplain(t,e,I){return freeze({...t,explain:ExplainNode.create(e,I?.toOperationNode())})},cloneWithTop(t,e){return freeze({...t,top:e})},cloneWithOutput(t,e){return freeze({...t,output:t.output?OutputNode.cloneWithSelections(t.output,e):OutputNode.create(e)})},cloneWithOrderByItems(t,e){return freeze({...t,orderBy:t.orderBy?OrderByNode.cloneWithItems(t.orderBy,e):OrderByNode.create(e)})},cloneWithoutOrderBy(t){return freeze({...t,orderBy:void 0})}}),SelectQueryNode=freeze({is(t){return t.kind==="SelectQueryNode"},create(t){return freeze({kind:"SelectQueryNode",...t&&{with:t}})},createFrom(t,e){return freeze({kind:"SelectQueryNode",from:FromNode.create(t),...e&&{with:e}})},cloneWithSelections(t,e){return freeze({...t,selections:t.selections?freeze([...t.selections,...e]):freeze(e)})},cloneWithDistinctOn(t,e){return freeze({...t,distinctOn:t.distinctOn?freeze([...t.distinctOn,...e]):freeze(e)})},cloneWithFrontModifier(t,e){return freeze({...t,frontModifiers:t.frontModifiers?freeze([...t.frontModifiers,e]):freeze([e])})},cloneWithOrderByItems:(t,e)=>QueryNode.cloneWithOrderByItems(t,e),cloneWithGroupByItems(t,e){return freeze({...t,groupBy:t.groupBy?GroupByNode.cloneWithItems(t.groupBy,e):GroupByNode.create(e)})},cloneWithLimit(t,e){return freeze({...t,limit:e})},cloneWithOffset(t,e){return freeze({...t,offset:e})},cloneWithFetch(t,e){return freeze({...t,fetch:e})},cloneWithHaving(t,e){return freeze({...t,having:t.having?HavingNode.cloneWithOperation(t.having,"And",e):HavingNode.create(e)})},cloneWithSetOperations(t,e){return freeze({...t,setOperations:t.setOperations?freeze([...t.setOperations,...e]):freeze([...e])})},cloneWithoutSelections(t){return freeze({...t,selections:[]})},cloneWithoutLimit(t){return freeze({...t,limit:void 0})},cloneWithoutOffset(t){return freeze({...t,offset:void 0})},cloneWithoutOrderBy:t=>QueryNode.cloneWithoutOrderBy(t),cloneWithoutGroupBy(t){return freeze({...t,groupBy:void 0})}});class JoinBuilder{#e;constructor(e){this.#e=freeze(e)}on(...e){return new JoinBuilder({...this.#e,joinNode:JoinNode.cloneWithOn(this.#e.joinNode,parseValueBinaryOperationOrExpression(e))})}onRef(e,I,B){return new JoinBuilder({...this.#e,joinNode:JoinNode.cloneWithOn(this.#e.joinNode,parseReferentialBinaryOperation(e,I,B))})}onTrue(){return new JoinBuilder({...this.#e,joinNode:JoinNode.cloneWithOn(this.#e.joinNode,RawNode.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return this.#e.joinNode}}const PartitionByItemNode=freeze({is(t){return t.kind==="PartitionByItemNode"},create(t){return freeze({kind:"PartitionByItemNode",partitionBy:t})}});function parsePartitionBy(t){return parseReferenceExpressionOrList(t).map(PartitionByItemNode.create)}class OverBuilder{#e;constructor(e){this.#e=freeze(e)}orderBy(...e){return new OverBuilder({overNode:OverNode.cloneWithOrderByItems(this.#e.overNode,parseOrderBy(e))})}clearOrderBy(){return new OverBuilder({overNode:QueryNode.cloneWithoutOrderBy(this.#e.overNode)})}partitionBy(e){return new OverBuilder({overNode:OverNode.cloneWithPartitionByItems(this.#e.overNode,parsePartitionBy(e))})}$call(e){return e(this)}toOperationNode(){return this.#e.overNode}}const SelectionNode=freeze({is(t){return t.kind==="SelectionNode"},create(t){return freeze({kind:"SelectionNode",selection:t})},createSelectAll(){return freeze({kind:"SelectionNode",selection:SelectAllNode.create()})},createSelectAllFromTable(t){return freeze({kind:"SelectionNode",selection:ReferenceNode.createSelectAll(t)})}});function parseSelectArg(t){return isFunction(t)?parseSelectArg(t(expressionBuilder())):isReadonlyArray(t)?t.map(e=>parseSelectExpression(e)):[parseSelectExpression(t)]}function parseSelectExpression(t){return isString(t)?SelectionNode.create(parseAliasedStringReference(t)):isDynamicReferenceBuilder(t)?SelectionNode.create(t.toOperationNode()):SelectionNode.create(parseAliasedExpression(t))}function parseSelectAll(t){return t?Array.isArray(t)?t.map(parseSelectAllArg):[parseSelectAllArg(t)]:[SelectionNode.createSelectAll()]}function parseSelectAllArg(t){if(isString(t))return SelectionNode.createSelectAllFromTable(parseTable(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const ValuesNode=freeze({is(t){return t.kind==="ValuesNode"},create(t){return freeze({kind:"ValuesNode",values:freeze(t)})}}),DefaultInsertValueNode=freeze({is(t){return t.kind==="DefaultInsertValueNode"},create(){return freeze({kind:"DefaultInsertValueNode"})}});function parseInsertExpression(t){const e=isFunction(t)?t(expressionBuilder()):t,I=isReadonlyArray(e)?e:freeze([e]);return parseInsertColumnsAndValues(I)}function parseInsertColumnsAndValues(t){const e=parseColumnNamesAndIndexes(t);return[freeze([...e.keys()].map(ColumnNode.create)),ValuesNode.create(t.map(I=>parseRowValues(I,e)))]}function parseColumnNamesAndIndexes(t){const e=new Map;for(const I of t){const B=Object.keys(I);for(const tr of B)!e.has(tr)&&I[tr]!==void 0&&e.set(tr,e.size)}return e}function parseRowValues(t,e){const I=Object.keys(t),B=Array.from({length:e.size});let tr=!1,rr=I.length;for(const lr of I){const dr=e.get(lr);if(isUndefined(dr)){rr--;continue}const mr=t[lr];(isUndefined(mr)||isExpressionOrFactory(mr))&&(tr=!0),B[dr]=mr}if(rr<e.size||tr){const lr=DefaultInsertValueNode.create();return ValueListNode.create(B.map(dr=>isUndefined(dr)?lr:parseValueExpression(dr)))}return PrimitiveValueListNode.create(B)}const ColumnUpdateNode=freeze({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return freeze({kind:"ColumnUpdateNode",column:t,value:e})}});function parseUpdate(...t){return t.length===2?[ColumnUpdateNode.create(parseReferenceExpression(t[0]),parseValueExpression(t[1]))]:parseUpdateObjectExpression(t[0])}function parseUpdateObjectExpression(t){const e=isFunction(t)?t(expressionBuilder()):t;return Object.entries(e).filter(([I,B])=>B!==void 0).map(([I,B])=>ColumnUpdateNode.create(ColumnNode.create(I),parseValueExpression(B)))}const OnDuplicateKeyNode=freeze({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return freeze({kind:"OnDuplicateKeyNode",updates:t})}});class InsertResult{insertId;numInsertedOrUpdatedRows;constructor(e,I){this.insertId=e,this.numInsertedOrUpdatedRows=I}}class NoResultError extends Error{node;constructor(e){super("no result"),this.node=e}}function isNoResultErrorConstructor(t){return Object.prototype.hasOwnProperty.call(t,"prototype")}const OnConflictNode=freeze({is(t){return t.kind==="OnConflictNode"},create(){return freeze({kind:"OnConflictNode"})},cloneWith(t,e){return freeze({...t,...e})},cloneWithIndexWhere(t,e){return freeze({...t,indexWhere:t.indexWhere?WhereNode.cloneWithOperation(t.indexWhere,"And",e):WhereNode.create(e)})},cloneWithIndexOrWhere(t,e){return freeze({...t,indexWhere:t.indexWhere?WhereNode.cloneWithOperation(t.indexWhere,"Or",e):WhereNode.create(e)})},cloneWithUpdateWhere(t,e){return freeze({...t,updateWhere:t.updateWhere?WhereNode.cloneWithOperation(t.updateWhere,"And",e):WhereNode.create(e)})},cloneWithUpdateOrWhere(t,e){return freeze({...t,updateWhere:t.updateWhere?WhereNode.cloneWithOperation(t.updateWhere,"Or",e):WhereNode.create(e)})},cloneWithoutIndexWhere(t){return freeze({...t,indexWhere:void 0})},cloneWithoutUpdateWhere(t){return freeze({...t,updateWhere:void 0})}});class OnConflictBuilder{#e;constructor(e){this.#e=freeze(e)}column(e){const I=ColumnNode.create(e);return new OnConflictBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?freeze([...this.#e.onConflictNode.columns,I]):freeze([I])})})}columns(e){const I=e.map(ColumnNode.create);return new OnConflictBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?freeze([...this.#e.onConflictNode.columns,...I]):freeze(I)})})}constraint(e){return new OnConflictBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWith(this.#e.onConflictNode,{constraint:IdentifierNode.create(e)})})}expression(e){return new OnConflictBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWith(this.#e.onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new OnConflictBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWithIndexWhere(this.#e.onConflictNode,parseValueBinaryOperationOrExpression(e))})}whereRef(e,I,B){return new OnConflictBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWithIndexWhere(this.#e.onConflictNode,parseReferentialBinaryOperation(e,I,B))})}clearWhere(){return new OnConflictBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWithoutIndexWhere(this.#e.onConflictNode)})}doNothing(){return new OnConflictDoNothingBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWith(this.#e.onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new OnConflictUpdateBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWith(this.#e.onConflictNode,{updates:parseUpdateObjectExpression(e)})})}$call(e){return e(this)}}class OnConflictDoNothingBuilder{#e;constructor(e){this.#e=freeze(e)}toOperationNode(){return this.#e.onConflictNode}}class OnConflictUpdateBuilder{#e;constructor(e){this.#e=freeze(e)}where(...e){return new OnConflictUpdateBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWithUpdateWhere(this.#e.onConflictNode,parseValueBinaryOperationOrExpression(e))})}whereRef(e,I,B){return new OnConflictUpdateBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWithUpdateWhere(this.#e.onConflictNode,parseReferentialBinaryOperation(e,I,B))})}clearWhere(){return new OnConflictUpdateBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWithoutUpdateWhere(this.#e.onConflictNode)})}$call(e){return e(this)}toOperationNode(){return this.#e.onConflictNode}}const TopNode=freeze({is(t){return t.kind==="TopNode"},create(t,e){return freeze({kind:"TopNode",expression:t,modifiers:e})}});function parseTop(t,e){if(!isNumber(t)&&!isBigInt(t))throw new Error(`Invalid top expression: ${t}`);if(!isUndefined(e)&&!isTopModifiers(e))throw new Error(`Invalid top modifiers: ${e}`);return TopNode.create(t,e)}function isTopModifiers(t){return t==="percent"||t==="with ties"||t==="percent with ties"}const OrActionNode=freeze({is(t){return t.kind==="OrActionNode"},create(t){return freeze({kind:"OrActionNode",action:t})}});class InsertQueryBuilder{#e;constructor(e){this.#e=freeze(e)}values(e){const[I,B]=parseInsertExpression(e);return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{columns:I,values:B})})}columns(e){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{columns:freeze(e.map(ColumnNode.create))})})}expression(e){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{values:parseExpression(e)})})}defaultValues(){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{defaultValues:!0})})}modifyEnd(e){return new InsertQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}ignore(){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{orAction:OrActionNode.create("ignore")})})}orIgnore(){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{orAction:OrActionNode.create("ignore")})})}orAbort(){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{orAction:OrActionNode.create("abort")})})}orFail(){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{orAction:OrActionNode.create("fail")})})}orReplace(){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{orAction:OrActionNode.create("replace")})})}orRollback(){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{orAction:OrActionNode.create("rollback")})})}top(e,I){return new InsertQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithTop(this.#e.queryNode,parseTop(e,I))})}onConflict(e){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{onConflict:e(new OnConflictBuilder({onConflictNode:OnConflictNode.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{onDuplicateKey:OnDuplicateKeyNode.create(parseUpdateObjectExpression(e))})})}returning(e){return new InsertQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectArg(e))})}returningAll(){return new InsertQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectAll())})}output(e){return new InsertQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectArg(e))})}outputAll(e){return new InsertQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectAll(e))})}clearReturning(){return new InsertQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,I){return e?I(this):new InsertQueryBuilder({...this.#e})}$castTo(){return new InsertQueryBuilder(this.#e)}$narrowType(){return new InsertQueryBuilder(this.#e)}$assertType(){return new InsertQueryBuilder(this.#e)}withPlugin(e){return new InsertQueryBuilder({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){const e=this.compile(),I=await this.#e.executor.executeQuery(e),{adapter:B}=this.#e.executor,tr=e.query;return tr.returning&&B.supportsReturning||tr.output&&B.supportsOutput?I.rows:[new InsertResult(I.insertId,I.numAffectedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=NoResultError){const I=await this.executeTakeFirst();if(I===void 0)throw isNoResultErrorConstructor(e)?new e(this.toOperationNode()):e(this.toOperationNode());return I}async*stream(e=100){const I=this.compile(),B=this.#e.executor.stream(I,e);for await(const tr of B)yield*tr.rows}async explain(e,I){return await new InsertQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithExplain(this.#e.queryNode,e,I)}).execute()}}class DeleteResult{numDeletedRows;constructor(e){this.numDeletedRows=e}}const LimitNode=freeze({is(t){return t.kind==="LimitNode"},create(t){return freeze({kind:"LimitNode",limit:t})}});class DeleteQueryBuilder{#e;constructor(e){this.#e=freeze(e)}where(...e){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithWhere(this.#e.queryNode,parseValueBinaryOperationOrExpression(e))})}whereRef(e,I,B){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithWhere(this.#e.queryNode,parseReferentialBinaryOperation(e,I,B))})}clearWhere(){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithoutWhere(this.#e.queryNode)})}top(e,I){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithTop(this.#e.queryNode,parseTop(e,I))})}using(e){return new DeleteQueryBuilder({...this.#e,queryNode:DeleteQueryNode.cloneWithUsing(this.#e.queryNode,parseTableExpressionOrList(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}#t(e,I){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithJoin(this.#e.queryNode,parseJoin(e,I))})}returning(e){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectArg(e))})}returningAll(e){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectAll(e))})}output(e){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectArg(e))})}outputAll(e){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectAll(e))})}clearReturning(){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithoutReturning(this.#e.queryNode)})}clearLimit(){return new DeleteQueryBuilder({...this.#e,queryNode:DeleteQueryNode.cloneWithoutLimit(this.#e.queryNode)})}orderBy(...e){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOrderByItems(this.#e.queryNode,parseOrderBy(e))})}clearOrderBy(){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new DeleteQueryBuilder({...this.#e,queryNode:DeleteQueryNode.cloneWithLimit(this.#e.queryNode,LimitNode.create(parseValueExpression(e)))})}modifyEnd(e){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}$call(e){return e(this)}$if(e,I){return e?I(this):new DeleteQueryBuilder({...this.#e})}$castTo(){return new DeleteQueryBuilder(this.#e)}$narrowType(){return new DeleteQueryBuilder(this.#e)}$assertType(){return new DeleteQueryBuilder(this.#e)}withPlugin(e){return new DeleteQueryBuilder({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){const e=this.compile(),I=await this.#e.executor.executeQuery(e),{adapter:B}=this.#e.executor,tr=e.query;return tr.returning&&B.supportsReturning||tr.output&&B.supportsOutput?I.rows:[new DeleteResult(I.numAffectedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=NoResultError){const I=await this.executeTakeFirst();if(I===void 0)throw isNoResultErrorConstructor(e)?new e(this.toOperationNode()):e(this.toOperationNode());return I}async*stream(e=100){const I=this.compile(),B=this.#e.executor.stream(I,e);for await(const tr of B)yield*tr.rows}async explain(e,I){return await new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithExplain(this.#e.queryNode,e,I)}).execute()}}class UpdateResult{numUpdatedRows;numChangedRows;constructor(e,I){this.numUpdatedRows=e,this.numChangedRows=I}}class UpdateQueryBuilder{#e;constructor(e){this.#e=freeze(e)}where(...e){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithWhere(this.#e.queryNode,parseValueBinaryOperationOrExpression(e))})}whereRef(e,I,B){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithWhere(this.#e.queryNode,parseReferentialBinaryOperation(e,I,B))})}clearWhere(){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithoutWhere(this.#e.queryNode)})}top(e,I){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithTop(this.#e.queryNode,parseTop(e,I))})}from(e){return new UpdateQueryBuilder({...this.#e,queryNode:UpdateQueryNode.cloneWithFromItems(this.#e.queryNode,parseTableExpressionOrList(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}#t(e,I){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithJoin(this.#e.queryNode,parseJoin(e,I))})}orderBy(...e){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOrderByItems(this.#e.queryNode,parseOrderBy(e))})}clearOrderBy(){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new UpdateQueryBuilder({...this.#e,queryNode:UpdateQueryNode.cloneWithLimit(this.#e.queryNode,LimitNode.create(parseValueExpression(e)))})}set(...e){return new UpdateQueryBuilder({...this.#e,queryNode:UpdateQueryNode.cloneWithUpdates(this.#e.queryNode,parseUpdate(...e))})}returning(e){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectArg(e))})}returningAll(e){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectAll(e))})}output(e){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectArg(e))})}outputAll(e){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectAll(e))})}modifyEnd(e){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}clearReturning(){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,I){return e?I(this):new UpdateQueryBuilder({...this.#e})}$castTo(){return new UpdateQueryBuilder(this.#e)}$narrowType(){return new UpdateQueryBuilder(this.#e)}$assertType(){return new UpdateQueryBuilder(this.#e)}withPlugin(e){return new UpdateQueryBuilder({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){const e=this.compile(),I=await this.#e.executor.executeQuery(e),{adapter:B}=this.#e.executor,tr=e.query;return tr.returning&&B.supportsReturning||tr.output&&B.supportsOutput?I.rows:[new UpdateResult(I.numAffectedRows??BigInt(0),I.numChangedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=NoResultError){const I=await this.executeTakeFirst();if(I===void 0)throw isNoResultErrorConstructor(e)?new e(this.toOperationNode()):e(this.toOperationNode());return I}async*stream(e=100){const I=this.compile(),B=this.#e.executor.stream(I,e);for await(const tr of B)yield*tr.rows}async explain(e,I){return await new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithExplain(this.#e.queryNode,e,I)}).execute()}}const CommonTableExpressionNameNode=freeze({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return freeze({kind:"CommonTableExpressionNameNode",table:TableNode.create(t),columns:e?freeze(e.map(ColumnNode.create)):void 0})}}),CommonTableExpressionNode=freeze({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return freeze({kind:"CommonTableExpressionNode",name:t,expression:e})},cloneWith(t,e){return freeze({...t,...e})}});class CTEBuilder{#e;constructor(e){this.#e=freeze(e)}materialized(){return new CTEBuilder({...this.#e,node:CommonTableExpressionNode.cloneWith(this.#e.node,{materialized:!0})})}notMaterialized(){return new CTEBuilder({...this.#e,node:CommonTableExpressionNode.cloneWith(this.#e.node,{materialized:!1})})}toOperationNode(){return this.#e.node}}function parseCommonTableExpression(t,e){const I=e(createQueryCreator()).toOperationNode();return isFunction(t)?t(cteBuilderFactory(I)).toOperationNode():CommonTableExpressionNode.create(parseCommonTableExpressionName(t),I)}function cteBuilderFactory(t){return e=>new CTEBuilder({node:CommonTableExpressionNode.create(parseCommonTableExpressionName(e),t)})}function parseCommonTableExpressionName(t){if(t.includes("(")){const e=t.split(/[\(\)]/),I=e[0],B=e[1].split(",").map(tr=>tr.trim());return CommonTableExpressionNameNode.create(I,B)}else return CommonTableExpressionNameNode.create(t)}const WithNode=freeze({is(t){return t.kind==="WithNode"},create(t,e){return freeze({kind:"WithNode",expressions:freeze([t]),...e})},cloneWithExpression(t,e){return freeze({...t,expressions:freeze([...t.expressions,e])})}}),CHARS=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function randomString(t){let e="";for(let I=0;I<t;++I)e+=randomChar();return e}function randomChar(){return CHARS[~~(Math.random()*CHARS.length)]}function createQueryId(){return new LazyQueryId}class LazyQueryId{#e;get queryId(){return this.#e===void 0&&(this.#e=randomString(8)),this.#e}}function requireAllProps(t){return t}class OperationNodeTransformer{nodeStack=[];#e=freeze({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),RenameConstraintNode:this.transformRenameConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),RefreshMaterializedViewNode:this.transformRefreshMaterializedView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this),OrActionNode:this.transformOrAction.bind(this),CollateNode:this.transformCollate.bind(this)});transformNode(e,I){if(!e)return e;this.nodeStack.push(e);const B=this.transformNodeImpl(e,I);return this.nodeStack.pop(),freeze(B)}transformNodeImpl(e,I){return this.#e[e.kind](e,I)}transformNodeList(e,I){return e&&freeze(e.map(B=>this.transformNode(B,I)))}transformSelectQuery(e,I){return{kind:"SelectQueryNode",from:this.transformNode(e.from,I),selections:this.transformNodeList(e.selections,I),distinctOn:this.transformNodeList(e.distinctOn,I),joins:this.transformNodeList(e.joins,I),groupBy:this.transformNode(e.groupBy,I),orderBy:this.transformNode(e.orderBy,I),where:this.transformNode(e.where,I),frontModifiers:this.transformNodeList(e.frontModifiers,I),endModifiers:this.transformNodeList(e.endModifiers,I),limit:this.transformNode(e.limit,I),offset:this.transformNode(e.offset,I),with:this.transformNode(e.with,I),having:this.transformNode(e.having,I),explain:this.transformNode(e.explain,I),setOperations:this.transformNodeList(e.setOperations,I),fetch:this.transformNode(e.fetch,I),top:this.transformNode(e.top,I)}}transformSelection(e,I){return{kind:"SelectionNode",selection:this.transformNode(e.selection,I)}}transformColumn(e,I){return{kind:"ColumnNode",column:this.transformNode(e.column,I)}}transformAlias(e,I){return{kind:"AliasNode",node:this.transformNode(e.node,I),alias:this.transformNode(e.alias,I)}}transformTable(e,I){return{kind:"TableNode",table:this.transformNode(e.table,I)}}transformFrom(e,I){return{kind:"FromNode",froms:this.transformNodeList(e.froms,I)}}transformReference(e,I){return{kind:"ReferenceNode",column:this.transformNode(e.column,I),table:this.transformNode(e.table,I)}}transformAnd(e,I){return{kind:"AndNode",left:this.transformNode(e.left,I),right:this.transformNode(e.right,I)}}transformOr(e,I){return{kind:"OrNode",left:this.transformNode(e.left,I),right:this.transformNode(e.right,I)}}transformValueList(e,I){return{kind:"ValueListNode",values:this.transformNodeList(e.values,I)}}transformParens(e,I){return{kind:"ParensNode",node:this.transformNode(e.node,I)}}transformJoin(e,I){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table,I),on:this.transformNode(e.on,I)}}transformRaw(e,I){return{kind:"RawNode",sqlFragments:freeze([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters,I)}}transformWhere(e,I){return{kind:"WhereNode",where:this.transformNode(e.where,I)}}transformInsertQuery(e,I){return{kind:"InsertQueryNode",into:this.transformNode(e.into,I),columns:this.transformNodeList(e.columns,I),values:this.transformNode(e.values,I),returning:this.transformNode(e.returning,I),onConflict:this.transformNode(e.onConflict,I),onDuplicateKey:this.transformNode(e.onDuplicateKey,I),endModifiers:this.transformNodeList(e.endModifiers,I),with:this.transformNode(e.with,I),ignore:e.ignore,orAction:this.transformNode(e.orAction,I),replace:e.replace,explain:this.transformNode(e.explain,I),defaultValues:e.defaultValues,top:this.transformNode(e.top,I),output:this.transformNode(e.output,I)}}transformValues(e,I){return{kind:"ValuesNode",values:this.transformNodeList(e.values,I)}}transformDeleteQuery(e,I){return{kind:"DeleteQueryNode",from:this.transformNode(e.from,I),using:this.transformNode(e.using,I),joins:this.transformNodeList(e.joins,I),where:this.transformNode(e.where,I),returning:this.transformNode(e.returning,I),endModifiers:this.transformNodeList(e.endModifiers,I),with:this.transformNode(e.with,I),orderBy:this.transformNode(e.orderBy,I),limit:this.transformNode(e.limit,I),explain:this.transformNode(e.explain,I),top:this.transformNode(e.top,I),output:this.transformNode(e.output,I)}}transformReturning(e,I){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections,I)}}transformCreateTable(e,I){return{kind:"CreateTableNode",table:this.transformNode(e.table,I),columns:this.transformNodeList(e.columns,I),constraints:this.transformNodeList(e.constraints,I),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers,I),endModifiers:this.transformNodeList(e.endModifiers,I),selectQuery:this.transformNode(e.selectQuery,I)}}transformColumnDefinition(e,I){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column,I),dataType:this.transformNode(e.dataType,I),references:this.transformNode(e.references,I),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo,I),check:this.transformNode(e.check,I),generated:this.transformNode(e.generated,I),frontModifiers:this.transformNodeList(e.frontModifiers,I),endModifiers:this.transformNodeList(e.endModifiers,I),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists}}transformAddColumn(e,I){return{kind:"AddColumnNode",column:this.transformNode(e.column,I)}}transformDropTable(e,I){return{kind:"DropTableNode",table:this.transformNode(e.table,I),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e,I){return{kind:"OrderByNode",items:this.transformNodeList(e.items,I)}}transformOrderByItem(e,I){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy,I),direction:this.transformNode(e.direction,I),collation:this.transformNode(e.collation,I),nulls:e.nulls}}transformGroupBy(e,I){return{kind:"GroupByNode",items:this.transformNodeList(e.items,I)}}transformGroupByItem(e,I){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy,I)}}transformUpdateQuery(e,I){return{kind:"UpdateQueryNode",table:this.transformNode(e.table,I),from:this.transformNode(e.from,I),joins:this.transformNodeList(e.joins,I),where:this.transformNode(e.where,I),updates:this.transformNodeList(e.updates,I),returning:this.transformNode(e.returning,I),endModifiers:this.transformNodeList(e.endModifiers,I),with:this.transformNode(e.with,I),explain:this.transformNode(e.explain,I),limit:this.transformNode(e.limit,I),top:this.transformNode(e.top,I),output:this.transformNode(e.output,I),orderBy:this.transformNode(e.orderBy,I)}}transformColumnUpdate(e,I){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column,I),value:this.transformNode(e.value,I)}}transformLimit(e,I){return{kind:"LimitNode",limit:this.transformNode(e.limit,I)}}transformOffset(e,I){return{kind:"OffsetNode",offset:this.transformNode(e.offset,I)}}transformOnConflict(e,I){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns,I),constraint:this.transformNode(e.constraint,I),indexExpression:this.transformNode(e.indexExpression,I),indexWhere:this.transformNode(e.indexWhere,I),updates:this.transformNodeList(e.updates,I),updateWhere:this.transformNode(e.updateWhere,I),doNothing:e.doNothing}}transformOnDuplicateKey(e,I){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates,I)}}transformCreateIndex(e,I){return{kind:"CreateIndexNode",name:this.transformNode(e.name,I),table:this.transformNode(e.table,I),columns:this.transformNodeList(e.columns,I),unique:e.unique,using:this.transformNode(e.using,I),ifNotExists:e.ifNotExists,where:this.transformNode(e.where,I),nullsNotDistinct:e.nullsNotDistinct}}transformList(e,I){return{kind:"ListNode",items:this.transformNodeList(e.items,I)}}transformDropIndex(e,I){return{kind:"DropIndexNode",name:this.transformNode(e.name,I),table:this.transformNode(e.table,I),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e,I){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns,I),name:this.transformNode(e.name,I),deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformUniqueConstraint(e,I){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns,I),name:this.transformNode(e.name,I),nullsNotDistinct:e.nullsNotDistinct,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformForeignKeyConstraint(e,I){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns,I),references:this.transformNode(e.references,I),name:this.transformNode(e.name,I),onDelete:e.onDelete,onUpdate:e.onUpdate,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformSetOperation(e,I){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression,I),all:e.all}}transformReferences(e,I){return{kind:"ReferencesNode",table:this.transformNode(e.table,I),columns:this.transformNodeList(e.columns,I),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e,I){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression,I),name:this.transformNode(e.name,I)}}transformWith(e,I){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions,I),recursive:e.recursive}}transformCommonTableExpression(e,I){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name,I),materialized:e.materialized,expression:this.transformNode(e.expression,I)}}transformCommonTableExpressionName(e,I){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table,I),columns:this.transformNodeList(e.columns,I)}}transformHaving(e,I){return{kind:"HavingNode",having:this.transformNode(e.having,I)}}transformCreateSchema(e,I){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema,I),ifNotExists:e.ifNotExists}}transformDropSchema(e,I){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema,I),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e,I){return{kind:"AlterTableNode",table:this.transformNode(e.table,I),renameTo:this.transformNode(e.renameTo,I),setSchema:this.transformNode(e.setSchema,I),columnAlterations:this.transformNodeList(e.columnAlterations,I),addConstraint:this.transformNode(e.addConstraint,I),dropConstraint:this.transformNode(e.dropConstraint,I),renameConstraint:this.transformNode(e.renameConstraint,I),addIndex:this.transformNode(e.addIndex,I),dropIndex:this.transformNode(e.dropIndex,I)}}transformDropColumn(e,I){return{kind:"DropColumnNode",column:this.transformNode(e.column,I)}}transformRenameColumn(e,I){return{kind:"RenameColumnNode",column:this.transformNode(e.column,I),renameTo:this.transformNode(e.renameTo,I)}}transformAlterColumn(e,I){return{kind:"AlterColumnNode",column:this.transformNode(e.column,I),dataType:this.transformNode(e.dataType,I),dataTypeExpression:this.transformNode(e.dataTypeExpression,I),setDefault:this.transformNode(e.setDefault,I),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e,I){return{kind:"ModifyColumnNode",column:this.transformNode(e.column,I)}}transformAddConstraint(e,I){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint,I)}}transformDropConstraint(e,I){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName,I),ifExists:e.ifExists,modifier:e.modifier}}transformRenameConstraint(e,I){return{kind:"RenameConstraintNode",oldName:this.transformNode(e.oldName,I),newName:this.transformNode(e.newName,I)}}transformCreateView(e,I){return{kind:"CreateViewNode",name:this.transformNode(e.name,I),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns,I),as:this.transformNode(e.as,I)}}transformRefreshMaterializedView(e,I){return{kind:"RefreshMaterializedViewNode",name:this.transformNode(e.name,I),concurrently:e.concurrently,withNoData:e.withNoData}}transformDropView(e,I){return{kind:"DropViewNode",name:this.transformNode(e.name,I),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e,I){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression,I)}}transformDefaultValue(e,I){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue,I)}}transformOn(e,I){return{kind:"OnNode",on:this.transformNode(e.on,I)}}transformSelectModifier(e,I){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier,I),of:this.transformNodeList(e.of,I)}}transformCreateType(e,I){return{kind:"CreateTypeNode",name:this.transformNode(e.name,I),enum:this.transformNode(e.enum,I)}}transformDropType(e,I){return{kind:"DropTypeNode",name:this.transformNode(e.name,I),ifExists:e.ifExists}}transformExplain(e,I){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options,I)}}transformSchemableIdentifier(e,I){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema,I),identifier:this.transformNode(e.identifier,I)}}transformAggregateFunction(e,I){return{kind:"AggregateFunctionNode",func:e.func,aggregated:this.transformNodeList(e.aggregated,I),distinct:e.distinct,orderBy:this.transformNode(e.orderBy,I),withinGroup:this.transformNode(e.withinGroup,I),filter:this.transformNode(e.filter,I),over:this.transformNode(e.over,I)}}transformOver(e,I){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy,I),partitionBy:this.transformNode(e.partitionBy,I)}}transformPartitionBy(e,I){return{kind:"PartitionByNode",items:this.transformNodeList(e.items,I)}}transformPartitionByItem(e,I){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy,I)}}transformBinaryOperation(e,I){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand,I),operator:this.transformNode(e.operator,I),rightOperand:this.transformNode(e.rightOperand,I)}}transformUnaryOperation(e,I){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator,I),operand:this.transformNode(e.operand,I)}}transformUsing(e,I){return{kind:"UsingNode",tables:this.transformNodeList(e.tables,I)}}transformFunction(e,I){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments,I)}}transformCase(e,I){return{kind:"CaseNode",value:this.transformNode(e.value,I),when:this.transformNodeList(e.when,I),else:this.transformNode(e.else,I),isStatement:e.isStatement}}transformWhen(e,I){return{kind:"WhenNode",condition:this.transformNode(e.condition,I),result:this.transformNode(e.result,I)}}transformJSONReference(e,I){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference,I),traversal:this.transformNode(e.traversal,I)}}transformJSONPath(e,I){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator,I),pathLegs:this.transformNodeList(e.pathLegs,I)}}transformJSONPathLeg(e,I){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e,I){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator,I),values:this.transformNodeList(e.values,I)}}transformTuple(e,I){return{kind:"TupleNode",values:this.transformNodeList(e.values,I)}}transformMergeQuery(e,I){return{kind:"MergeQueryNode",into:this.transformNode(e.into,I),using:this.transformNode(e.using,I),whens:this.transformNodeList(e.whens,I),with:this.transformNode(e.with,I),top:this.transformNode(e.top,I),endModifiers:this.transformNodeList(e.endModifiers,I),output:this.transformNode(e.output,I),returning:this.transformNode(e.returning,I)}}transformMatched(e,I){return{kind:"MatchedNode",not:e.not,bySource:e.bySource}}transformAddIndex(e,I){return{kind:"AddIndexNode",name:this.transformNode(e.name,I),columns:this.transformNodeList(e.columns,I),unique:e.unique,using:this.transformNode(e.using,I),ifNotExists:e.ifNotExists}}transformCast(e,I){return{kind:"CastNode",expression:this.transformNode(e.expression,I),dataType:this.transformNode(e.dataType,I)}}transformFetch(e,I){return{kind:"FetchNode",rowCount:this.transformNode(e.rowCount,I),modifier:e.modifier}}transformTop(e,I){return{kind:"TopNode",expression:e.expression,modifiers:e.modifiers}}transformOutput(e,I){return{kind:"OutputNode",selections:this.transformNodeList(e.selections,I)}}transformDataType(e,I){return e}transformSelectAll(e,I){return e}transformIdentifier(e,I){return e}transformValue(e,I){return e}transformPrimitiveValueList(e,I){return e}transformOperator(e,I){return e}transformDefaultInsertValue(e,I){return e}transformOrAction(e,I){return e}transformCollate(e,I){return e}}const ROOT_OPERATION_NODES=freeze({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,RefreshMaterializedViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0}),SCHEMALESS_FUNCTIONS={json_agg:!0,to_json:!0};class WithSchemaTransformer extends OperationNodeTransformer{#e;#t=new Set;#r=new Set;constructor(e){super(),this.#e=e}transformNodeImpl(e,I){if(!this.#o(e))return super.transformNodeImpl(e,I);const B=this.#s(e);for(const ir of B)this.#r.add(ir);const tr=this.#l(e);for(const ir of tr)this.#t.add(ir);const rr=super.transformNodeImpl(e,I);for(const ir of tr)this.#t.delete(ir);for(const ir of B)this.#r.delete(ir);return rr}transformSchemableIdentifier(e,I){const B=super.transformSchemableIdentifier(e,I);return B.schema||!this.#t.has(e.identifier.name)?B:{...B,schema:IdentifierNode.create(this.#e)}}transformReferences(e,I){const B=super.transformReferences(e,I);return B.table.table.schema?B:{...B,table:TableNode.createWithSchema(this.#e,B.table.table.identifier.name)}}transformAggregateFunction(e,I){return{...super.transformAggregateFunction({...e,aggregated:[]},I),aggregated:this.#n(e,I,"aggregated")}}transformFunction(e,I){return{...super.transformFunction({...e,arguments:[]},I),arguments:this.#n(e,I,"arguments")}}#n(e,I,B){return SCHEMALESS_FUNCTIONS[e.func]?e[B].map(tr=>!TableNode.is(tr)||tr.table.schema?this.transformNode(tr,I):{...tr,table:this.transformIdentifier(tr.table.identifier,I)}):this.transformNodeList(e[B],I)}#o(e){return e.kind in ROOT_OPERATION_NODES}#l(e){const I=new Set;if("name"in e&&e.name&&SchemableIdentifierNode.is(e.name)&&this.#a(e.name,I),"from"in e&&e.from)for(const B of e.from.froms)this.#i(B,I);if("into"in e&&e.into&&this.#i(e.into,I),"table"in e&&e.table&&this.#i(e.table,I),"joins"in e&&e.joins)for(const B of e.joins)this.#i(B.table,I);return"using"in e&&e.using&&(JoinNode.is(e.using)?this.#i(e.using.table,I):this.#i(e.using,I)),I}#s(e){const I=new Set;return"with"in e&&e.with&&this.#d(e.with,I),I}#i(e,I){if(TableNode.is(e))this.#a(e.table,I);else if(AliasNode.is(e)&&TableNode.is(e.node))this.#a(e.node.table,I);else if(ListNode.is(e))for(const B of e.items)this.#i(B,I)}#a(e,I){const B=e.identifier.name;!this.#t.has(B)&&!this.#r.has(B)&&I.add(B)}#d(e,I){for(const B of e.expressions){const tr=B.name.table.table.identifier.name;this.#r.has(tr)||I.add(tr)}}}class WithSchemaPlugin{#e;constructor(e){this.#e=new WithSchemaTransformer(e)}transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}async transformResult(e){return e.result}}const MatchedNode=freeze({is(t){return t.kind==="MatchedNode"},create(t,e=!1){return freeze({kind:"MatchedNode",not:t,bySource:e})}});function parseMergeWhen(t,e,I){return WhenNode.create(parseFilterList([MatchedNode.create(!t.isMatched,t.bySource),...e&&e.length>0?[e.length===3&&I?parseReferentialBinaryOperation(e[0],e[1],e[2]):parseValueBinaryOperationOrExpression(e)]:[]],"and",!1))}function parseMergeThen(t){return isString(t)?RawNode.create([t],[]):isOperationNodeSource(t)?t.toOperationNode():t}class Deferred{#e;#t;#r;constructor(){this.#e=new Promise((e,I)=>{this.#r=I,this.#t=e})}get promise(){return this.#e}resolve=e=>{this.#t&&this.#t(e)};reject=e=>{this.#r&&this.#r(e)}}async function provideControlledConnection(t){const e=new Deferred,I=new Deferred;return t.provideConnection(async B=>(e.resolve(B),await I.promise)).catch(B=>e.reject(B)),freeze({connection:await e.promise,release:I.resolve})}const NO_PLUGINS=freeze([]);class QueryExecutorBase{#e;constructor(e=NO_PLUGINS){this.#e=e}get plugins(){return this.#e}transformQuery(e,I){for(const B of this.#e){const tr=B.transformQuery({node:e,queryId:I});if(tr.kind===e.kind)e=tr;else throw new Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${e.kind}`,`but it returned a ${tr.kind}`].join(" "))}return e}async executeQuery(e){return await this.provideConnection(async I=>{const B=await I.executeQuery(e);return"numUpdatedOrDeletedRows"in B&&logOnce("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`."),await this.#t(B,e.queryId)})}async*stream(e,I){const{connection:B,release:tr}=await provideControlledConnection(this);try{for await(const rr of B.streamQuery(e,I))yield await this.#t(rr,e.queryId)}finally{tr()}}async#t(e,I){for(const B of this.#e)e=await B.transformResult({result:e,queryId:I});return e}}class NoopQueryExecutor extends QueryExecutorBase{get adapter(){throw new Error("this query cannot be compiled to SQL")}compileQuery(){throw new Error("this query cannot be compiled to SQL")}provideConnection(){throw new Error("this query cannot be executed")}withConnectionProvider(){throw new Error("this query cannot have a connection provider")}withPlugin(e){return new NoopQueryExecutor([...this.plugins,e])}withPlugins(e){return new NoopQueryExecutor([...this.plugins,...e])}withPluginAtFront(e){return new NoopQueryExecutor([e,...this.plugins])}withoutPlugins(){return new NoopQueryExecutor([])}}const NOOP_QUERY_EXECUTOR=new NoopQueryExecutor;class MergeResult{numChangedRows;constructor(e){this.numChangedRows=e}}class MergeQueryBuilder{#e;constructor(e){this.#e=freeze(e)}modifyEnd(e){return new MergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,I){return new MergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithTop(this.#e.queryNode,parseTop(e,I))})}using(...e){return new WheneableMergeQueryBuilder({...this.#e,queryNode:MergeQueryNode.cloneWithUsing(this.#e.queryNode,parseJoin("Using",e))})}returning(e){return new MergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectArg(e))})}returningAll(e){return new MergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectAll(e))})}output(e){return new MergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectArg(e))})}outputAll(e){return new MergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectAll(e))})}}class WheneableMergeQueryBuilder{#e;constructor(e){this.#e=freeze(e)}modifyEnd(e){return new WheneableMergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,I){return new WheneableMergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithTop(this.#e.queryNode,parseTop(e,I))})}whenMatched(){return this.#t([])}whenMatchedAnd(...e){return this.#t(e)}whenMatchedAndRef(e,I,B){return this.#t([e,I,B],!0)}#t(e,I){return new MatchedThenableMergeQueryBuilder({...this.#e,queryNode:MergeQueryNode.cloneWithWhen(this.#e.queryNode,parseMergeWhen({isMatched:!0},e,I))})}whenNotMatched(){return this.#r([])}whenNotMatchedAnd(...e){return this.#r(e)}whenNotMatchedAndRef(e,I,B){return this.#r([e,I,B],!0)}whenNotMatchedBySource(){return this.#r([],!1,!0)}whenNotMatchedBySourceAnd(...e){return this.#r(e,!1,!0)}whenNotMatchedBySourceAndRef(e,I,B){return this.#r([e,I,B],!0,!0)}returning(e){return new WheneableMergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectArg(e))})}returningAll(e){return new WheneableMergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectAll(e))})}output(e){return new WheneableMergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectArg(e))})}outputAll(e){return new WheneableMergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectAll(e))})}#r(e,I=!1,B=!1){const tr={...this.#e,queryNode:MergeQueryNode.cloneWithWhen(this.#e.queryNode,parseMergeWhen({isMatched:!1,bySource:B},e,I))},rr=B?MatchedThenableMergeQueryBuilder:NotMatchedThenableMergeQueryBuilder;return new rr(tr)}$call(e){return e(this)}$if(e,I){return e?I(this):new WheneableMergeQueryBuilder({...this.#e})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){const e=this.compile(),I=await this.#e.executor.executeQuery(e),{adapter:B}=this.#e.executor,tr=e.query;return tr.returning&&B.supportsReturning||tr.output&&B.supportsOutput?I.rows:[new MergeResult(I.numAffectedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=NoResultError){const I=await this.executeTakeFirst();if(I===void 0)throw isNoResultErrorConstructor(e)?new e(this.toOperationNode()):e(this.toOperationNode());return I}}class MatchedThenableMergeQueryBuilder{#e;constructor(e){this.#e=freeze(e)}thenDelete(){return new WheneableMergeQueryBuilder({...this.#e,queryNode:MergeQueryNode.cloneWithThen(this.#e.queryNode,parseMergeThen("delete"))})}thenDoNothing(){return new WheneableMergeQueryBuilder({...this.#e,queryNode:MergeQueryNode.cloneWithThen(this.#e.queryNode,parseMergeThen("do nothing"))})}thenUpdate(e){return new WheneableMergeQueryBuilder({...this.#e,queryNode:MergeQueryNode.cloneWithThen(this.#e.queryNode,parseMergeThen(e(new UpdateQueryBuilder({queryId:this.#e.queryId,executor:NOOP_QUERY_EXECUTOR,queryNode:UpdateQueryNode.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate(I=>I.set(...e))}}class NotMatchedThenableMergeQueryBuilder{#e;constructor(e){this.#e=freeze(e)}thenDoNothing(){return new WheneableMergeQueryBuilder({...this.#e,queryNode:MergeQueryNode.cloneWithThen(this.#e.queryNode,parseMergeThen("do nothing"))})}thenInsertValues(e){const[I,B]=parseInsertExpression(e);return new WheneableMergeQueryBuilder({...this.#e,queryNode:MergeQueryNode.cloneWithThen(this.#e.queryNode,parseMergeThen(InsertQueryNode.cloneWith(InsertQueryNode.createWithoutInto(),{columns:I,values:B})))})}}class QueryCreator{#e;constructor(e){this.#e=freeze(e)}selectFrom(e){return createSelectQueryBuilder({queryId:createQueryId(),executor:this.#e.executor,queryNode:SelectQueryNode.createFrom(parseTableExpressionOrList(e),this.#e.withNode)})}selectNoFrom(e){return createSelectQueryBuilder({queryId:createQueryId(),executor:this.#e.executor,queryNode:SelectQueryNode.cloneWithSelections(SelectQueryNode.create(this.#e.withNode),parseSelectArg(e))})}insertInto(e){return new InsertQueryBuilder({queryId:createQueryId(),executor:this.#e.executor,queryNode:InsertQueryNode.create(parseTable(e),this.#e.withNode)})}replaceInto(e){return new InsertQueryBuilder({queryId:createQueryId(),executor:this.#e.executor,queryNode:InsertQueryNode.create(parseTable(e),this.#e.withNode,!0)})}deleteFrom(e){return new DeleteQueryBuilder({queryId:createQueryId(),executor:this.#e.executor,queryNode:DeleteQueryNode.create(parseTableExpressionOrList(e),this.#e.withNode)})}updateTable(e){return new UpdateQueryBuilder({queryId:createQueryId(),executor:this.#e.executor,queryNode:UpdateQueryNode.create(parseTableExpressionOrList(e),this.#e.withNode)})}mergeInto(e){return new MergeQueryBuilder({queryId:createQueryId(),executor:this.#e.executor,queryNode:MergeQueryNode.create(parseAliasedTable(e),this.#e.withNode)})}with(e,I){const B=parseCommonTableExpression(e,I);return new QueryCreator({...this.#e,withNode:this.#e.withNode?WithNode.cloneWithExpression(this.#e.withNode,B):WithNode.create(B)})}withRecursive(e,I){const B=parseCommonTableExpression(e,I);return new QueryCreator({...this.#e,withNode:this.#e.withNode?WithNode.cloneWithExpression(this.#e.withNode,B):WithNode.create(B,{recursive:!0})})}withPlugin(e){return new QueryCreator({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new QueryCreator({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new QueryCreator({...this.#e,executor:this.#e.executor.withPluginAtFront(new WithSchemaPlugin(e))})}}function createQueryCreator(){return new QueryCreator({executor:NOOP_QUERY_EXECUTOR})}function createJoinBuilder(t,e){return new JoinBuilder({joinNode:JoinNode.create(t,parseTableExpression(e))})}function createOverBuilder(){return new OverBuilder({overNode:OverNode.create()})}function parseJoin(t,e){if(e.length===3)return parseSingleOnJoin(t,e[0],e[1],e[2]);if(e.length===2)return parseCallbackJoin(t,e[0],e[1]);if(e.length===1)return parseOnlessJoin(t,e[0]);throw new Error("not implemented")}function parseCallbackJoin(t,e,I){return I(createJoinBuilder(t,e)).toOperationNode()}function parseSingleOnJoin(t,e,I,B){return JoinNode.createWithOn(t,parseTableExpression(e),parseReferentialBinaryOperation(I,"=",B))}function parseOnlessJoin(t,e){return JoinNode.create(t,parseTableExpression(e))}const OffsetNode=freeze({is(t){return t.kind==="OffsetNode"},create(t){return freeze({kind:"OffsetNode",offset:t})}}),GroupByItemNode=freeze({is(t){return t.kind==="GroupByItemNode"},create(t){return freeze({kind:"GroupByItemNode",groupBy:t})}});function parseGroupBy(t){return t=isFunction(t)?t(expressionBuilder()):t,parseReferenceExpressionOrList(t).map(GroupByItemNode.create)}const SetOperationNode=freeze({is(t){return t.kind==="SetOperationNode"},create(t,e,I){return freeze({kind:"SetOperationNode",operator:t,expression:e,all:I})}});function parseSetOperations(t,e,I){return isFunction(e)&&(e=e(createExpressionBuilder())),isReadonlyArray(e)||(e=[e]),e.map(B=>SetOperationNode.create(t,parseExpression(B),I))}class ExpressionWrapper{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new AliasedExpressionWrapper(this,e)}or(...e){return new OrWrapper(OrNode.create(this.#e,parseValueBinaryOperationOrExpression(e)))}and(...e){return new AndWrapper(AndNode.create(this.#e,parseValueBinaryOperationOrExpression(e)))}$castTo(){return new ExpressionWrapper(this.#e)}$notNull(){return new ExpressionWrapper(this.#e)}toOperationNode(){return this.#e}}class AliasedExpressionWrapper{#e;#t;constructor(e,I){this.#e=e,this.#t=I}get expression(){return this.#e}get alias(){return this.#t}toOperationNode(){return AliasNode.create(this.#e.toOperationNode(),isOperationNodeSource(this.#t)?this.#t.toOperationNode():IdentifierNode.create(this.#t))}}class OrWrapper{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new AliasedExpressionWrapper(this,e)}or(...e){return new OrWrapper(OrNode.create(this.#e,parseValueBinaryOperationOrExpression(e)))}$castTo(){return new OrWrapper(this.#e)}toOperationNode(){return ParensNode.create(this.#e)}}class AndWrapper{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new AliasedExpressionWrapper(this,e)}and(...e){return new AndWrapper(AndNode.create(this.#e,parseValueBinaryOperationOrExpression(e)))}$castTo(){return new AndWrapper(this.#e)}toOperationNode(){return ParensNode.create(this.#e)}}const FetchNode={is(t){return t.kind==="FetchNode"},create(t,e){return{kind:"FetchNode",rowCount:ValueNode.create(t),modifier:e}}};function parseFetch(t,e){if(!isNumber(t)&&!isBigInt(t))throw new Error(`Invalid fetch row count: ${t}`);if(!isFetchModifier(e))throw new Error(`Invalid fetch modifier: ${e}`);return FetchNode.create(t,e)}function isFetchModifier(t){return t==="only"||t==="with ties"}class SelectQueryBuilderImpl{#e;constructor(e){this.#e=freeze(e)}get expressionType(){}get isSelectQueryBuilder(){return!0}where(...e){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithWhere(this.#e.queryNode,parseValueBinaryOperationOrExpression(e))})}whereRef(e,I,B){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithWhere(this.#e.queryNode,parseReferentialBinaryOperation(e,I,B))})}having(...e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithHaving(this.#e.queryNode,parseValueBinaryOperationOrExpression(e))})}havingRef(e,I,B){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithHaving(this.#e.queryNode,parseReferentialBinaryOperation(e,I,B))})}select(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithSelections(this.#e.queryNode,parseSelectArg(e))})}distinctOn(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithDistinctOn(this.#e.queryNode,parseReferenceExpressionOrList(e))})}modifyFront(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithFrontModifier(this.#e.queryNode,SelectModifierNode.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,SelectModifierNode.createWithExpression(e.toOperationNode()))})}distinct(){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithFrontModifier(this.#e.queryNode,SelectModifierNode.create("Distinct"))})}forUpdate(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,SelectModifierNode.create("ForUpdate",e?asArray$1(e).map(parseTable):void 0))})}forShare(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,SelectModifierNode.create("ForShare",e?asArray$1(e).map(parseTable):void 0))})}forKeyShare(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,SelectModifierNode.create("ForKeyShare",e?asArray$1(e).map(parseTable):void 0))})}forNoKeyUpdate(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,SelectModifierNode.create("ForNoKeyUpdate",e?asArray$1(e).map(parseTable):void 0))})}skipLocked(){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,SelectModifierNode.create("SkipLocked"))})}noWait(){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,SelectModifierNode.create("NoWait"))})}selectAll(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithSelections(this.#e.queryNode,parseSelectAll(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}crossJoin(...e){return this.#t("CrossJoin",e)}innerJoinLateral(...e){return this.#t("LateralInnerJoin",e)}leftJoinLateral(...e){return this.#t("LateralLeftJoin",e)}crossJoinLateral(...e){return this.#t("LateralCrossJoin",e)}crossApply(...e){return this.#t("CrossApply",e)}outerApply(...e){return this.#t("OuterApply",e)}#t(e,I){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithJoin(this.#e.queryNode,parseJoin(e,I))})}orderBy(...e){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithOrderByItems(this.#e.queryNode,parseOrderBy(e))})}groupBy(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithGroupByItems(this.#e.queryNode,parseGroupBy(e))})}limit(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithLimit(this.#e.queryNode,LimitNode.create(parseValueExpression(e)))})}offset(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithOffset(this.#e.queryNode,OffsetNode.create(parseValueExpression(e)))})}fetch(e,I="only"){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithFetch(this.#e.queryNode,parseFetch(e,I))})}top(e,I){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithTop(this.#e.queryNode,parseTop(e,I))})}union(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithSetOperations(this.#e.queryNode,parseSetOperations("union",e,!1))})}unionAll(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithSetOperations(this.#e.queryNode,parseSetOperations("union",e,!0))})}intersect(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithSetOperations(this.#e.queryNode,parseSetOperations("intersect",e,!1))})}intersectAll(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithSetOperations(this.#e.queryNode,parseSetOperations("intersect",e,!0))})}except(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithSetOperations(this.#e.queryNode,parseSetOperations("except",e,!1))})}exceptAll(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithSetOperations(this.#e.queryNode,parseSetOperations("except",e,!0))})}as(e){return new AliasedSelectQueryBuilderImpl(this,e)}clearSelect(){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithoutSelections(this.#e.queryNode)})}clearWhere(){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithoutWhere(this.#e.queryNode)})}clearLimit(){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithoutLimit(this.#e.queryNode)})}clearOffset(){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithoutOffset(this.#e.queryNode)})}clearOrderBy(){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithoutOrderBy(this.#e.queryNode)})}clearGroupBy(){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithoutGroupBy(this.#e.queryNode)})}$call(e){return e(this)}$if(e,I){return e?I(this):new SelectQueryBuilderImpl({...this.#e})}$castTo(){return new SelectQueryBuilderImpl(this.#e)}$narrowType(){return new SelectQueryBuilderImpl(this.#e)}$assertType(){return new SelectQueryBuilderImpl(this.#e)}$asTuple(){return new ExpressionWrapper(this.toOperationNode())}$asScalar(){return new ExpressionWrapper(this.toOperationNode())}withPlugin(e){return new SelectQueryBuilderImpl({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){const e=this.compile();return(await this.#e.executor.executeQuery(e)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=NoResultError){const I=await this.executeTakeFirst();if(I===void 0)throw isNoResultErrorConstructor(e)?new e(this.toOperationNode()):e(this.toOperationNode());return I}async*stream(e=100){const I=this.compile(),B=this.#e.executor.stream(I,e);for await(const tr of B)yield*tr.rows}async explain(e,I){return await new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithExplain(this.#e.queryNode,e,I)}).execute()}}function createSelectQueryBuilder(t){return new SelectQueryBuilderImpl(t)}class AliasedSelectQueryBuilderImpl{#e;#t;constructor(e,I){this.#e=e,this.#t=I}get expression(){return this.#e}get alias(){return this.#t}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return AliasNode.create(this.#e.toOperationNode(),IdentifierNode.create(this.#t))}}const AggregateFunctionNode=freeze({is(t){return t.kind==="AggregateFunctionNode"},create(t,e=[]){return freeze({kind:"AggregateFunctionNode",func:t,aggregated:e})},cloneWithDistinct(t){return freeze({...t,distinct:!0})},cloneWithOrderBy(t,e,I=!1){const B=I?"withinGroup":"orderBy";return freeze({...t,[B]:t[B]?OrderByNode.cloneWithItems(t[B],e):OrderByNode.create(e)})},cloneWithFilter(t,e){return freeze({...t,filter:t.filter?WhereNode.cloneWithOperation(t.filter,"And",e):WhereNode.create(e)})},cloneWithOrFilter(t,e){return freeze({...t,filter:t.filter?WhereNode.cloneWithOperation(t.filter,"Or",e):WhereNode.create(e)})},cloneWithOver(t,e){return freeze({...t,over:e})}}),FunctionNode=freeze({is(t){return t.kind==="FunctionNode"},create(t,e){return freeze({kind:"FunctionNode",func:t,arguments:e})}});class AggregateFunctionBuilder{#e;constructor(e){this.#e=freeze(e)}get expressionType(){}as(e){return new AliasedAggregateFunctionBuilder(this,e)}distinct(){return new AggregateFunctionBuilder({...this.#e,aggregateFunctionNode:AggregateFunctionNode.cloneWithDistinct(this.#e.aggregateFunctionNode)})}orderBy(...e){return new AggregateFunctionBuilder({...this.#e,aggregateFunctionNode:QueryNode.cloneWithOrderByItems(this.#e.aggregateFunctionNode,parseOrderBy(e))})}clearOrderBy(){return new AggregateFunctionBuilder({...this.#e,aggregateFunctionNode:QueryNode.cloneWithoutOrderBy(this.#e.aggregateFunctionNode)})}withinGroupOrderBy(...e){return new AggregateFunctionBuilder({...this.#e,aggregateFunctionNode:AggregateFunctionNode.cloneWithOrderBy(this.#e.aggregateFunctionNode,parseOrderBy(e),!0)})}filterWhere(...e){return new AggregateFunctionBuilder({...this.#e,aggregateFunctionNode:AggregateFunctionNode.cloneWithFilter(this.#e.aggregateFunctionNode,parseValueBinaryOperationOrExpression(e))})}filterWhereRef(e,I,B){return new AggregateFunctionBuilder({...this.#e,aggregateFunctionNode:AggregateFunctionNode.cloneWithFilter(this.#e.aggregateFunctionNode,parseReferentialBinaryOperation(e,I,B))})}over(e){const I=createOverBuilder();return new AggregateFunctionBuilder({...this.#e,aggregateFunctionNode:AggregateFunctionNode.cloneWithOver(this.#e.aggregateFunctionNode,(e?e(I):I).toOperationNode())})}$call(e){return e(this)}$castTo(){return new AggregateFunctionBuilder(this.#e)}$notNull(){return new AggregateFunctionBuilder(this.#e)}toOperationNode(){return this.#e.aggregateFunctionNode}}class AliasedAggregateFunctionBuilder{#e;#t;constructor(e,I){this.#e=e,this.#t=I}get expression(){return this.#e}get alias(){return this.#t}toOperationNode(){return AliasNode.create(this.#e.toOperationNode(),IdentifierNode.create(this.#t))}}function createFunctionModule(){const t=(I,B)=>new ExpressionWrapper(FunctionNode.create(I,parseReferenceExpressionOrList(B??[]))),e=(I,B)=>new AggregateFunctionBuilder({aggregateFunctionNode:AggregateFunctionNode.create(I,B?parseReferenceExpressionOrList(B):void 0)});return Object.assign(t,{agg:e,avg(I){return e("avg",[I])},coalesce(...I){return t("coalesce",I)},count(I){return e("count",[I])},countAll(I){return new AggregateFunctionBuilder({aggregateFunctionNode:AggregateFunctionNode.create("count",parseSelectAll(I))})},max(I){return e("max",[I])},min(I){return e("min",[I])},sum(I){return e("sum",[I])},any(I){return t("any",[I])},jsonAgg(I){return new AggregateFunctionBuilder({aggregateFunctionNode:AggregateFunctionNode.create("json_agg",[isString(I)?parseTable(I):I.toOperationNode()])})},toJson(I){return new ExpressionWrapper(FunctionNode.create("to_json",[isString(I)?parseTable(I):I.toOperationNode()]))}})}const UnaryOperationNode=freeze({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return freeze({kind:"UnaryOperationNode",operator:t,operand:e})}});function parseUnaryOperation(t,e){return UnaryOperationNode.create(OperatorNode.create(t),parseReferenceExpression(e))}const CaseNode=freeze({is(t){return t.kind==="CaseNode"},create(t){return freeze({kind:"CaseNode",value:t})},cloneWithWhen(t,e){return freeze({...t,when:freeze(t.when?[...t.when,e]:[e])})},cloneWithThen(t,e){return freeze({...t,when:t.when?freeze([...t.when.slice(0,-1),WhenNode.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return freeze({...t,...e})}});class CaseBuilder{#e;constructor(e){this.#e=freeze(e)}when(...e){return new CaseThenBuilder({...this.#e,node:CaseNode.cloneWithWhen(this.#e.node,WhenNode.create(parseValueBinaryOperationOrExpression(e)))})}}class CaseThenBuilder{#e;constructor(e){this.#e=freeze(e)}then(e){return new CaseWhenBuilder({...this.#e,node:CaseNode.cloneWithThen(this.#e.node,isSafeImmediateValue(e)?parseSafeImmediateValue(e):parseValueExpression(e))})}}class CaseWhenBuilder{#e;constructor(e){this.#e=freeze(e)}when(...e){return new CaseThenBuilder({...this.#e,node:CaseNode.cloneWithWhen(this.#e.node,WhenNode.create(parseValueBinaryOperationOrExpression(e)))})}else(e){return new CaseEndBuilder({...this.#e,node:CaseNode.cloneWith(this.#e.node,{else:isSafeImmediateValue(e)?parseSafeImmediateValue(e):parseValueExpression(e)})})}end(){return new ExpressionWrapper(CaseNode.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new ExpressionWrapper(CaseNode.cloneWith(this.#e.node,{isStatement:!0}))}}class CaseEndBuilder{#e;constructor(e){this.#e=freeze(e)}end(){return new ExpressionWrapper(CaseNode.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new ExpressionWrapper(CaseNode.cloneWith(this.#e.node,{isStatement:!0}))}}const JSONPathLegNode=freeze({is(t){return t.kind==="JSONPathLegNode"},create(t,e){return freeze({kind:"JSONPathLegNode",type:t,value:e})}});class JSONPathBuilder{#e;constructor(e){this.#e=e}at(e){return this.#t("ArrayLocation",e)}key(e){return this.#t("Member",e)}#t(e,I){return JSONReferenceNode.is(this.#e)?new TraversedJSONPathBuilder(JSONReferenceNode.cloneWithTraversal(this.#e,JSONPathNode.is(this.#e.traversal)?JSONPathNode.cloneWithLeg(this.#e.traversal,JSONPathLegNode.create(e,I)):JSONOperatorChainNode.cloneWithValue(this.#e.traversal,ValueNode.createImmediate(I)))):new TraversedJSONPathBuilder(JSONPathNode.cloneWithLeg(this.#e,JSONPathLegNode.create(e,I)))}}class TraversedJSONPathBuilder extends JSONPathBuilder{#e;constructor(e){super(e),this.#e=e}get expressionType(){}as(e){return new AliasedJSONPathBuilder(this,e)}$castTo(){return new TraversedJSONPathBuilder(this.#e)}$notNull(){return new TraversedJSONPathBuilder(this.#e)}toOperationNode(){return this.#e}}class AliasedJSONPathBuilder{#e;#t;constructor(e,I){this.#e=e,this.#t=I}get expression(){return this.#e}get alias(){return this.#t}toOperationNode(){return AliasNode.create(this.#e.toOperationNode(),isOperationNodeSource(this.#t)?this.#t.toOperationNode():IdentifierNode.create(this.#t))}}const TupleNode=freeze({is(t){return t.kind==="TupleNode"},create(t){return freeze({kind:"TupleNode",values:freeze(t)})}}),SIMPLE_COLUMN_DATA_TYPES=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],COLUMN_DATA_TYPE_REGEX=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],DataTypeNode=freeze({is(t){return t.kind==="DataTypeNode"},create(t){return freeze({kind:"DataTypeNode",dataType:t})}});function isColumnDataType(t){return!!(SIMPLE_COLUMN_DATA_TYPES.includes(t)||COLUMN_DATA_TYPE_REGEX.some(e=>e.test(t)))}function parseDataTypeExpression(t){if(isOperationNodeSource(t))return t.toOperationNode();if(isColumnDataType(t))return DataTypeNode.create(t);throw new Error(`invalid column data type ${JSON.stringify(t)}`)}const CastNode=freeze({is(t){return t.kind==="CastNode"},create(t,e){return freeze({kind:"CastNode",expression:t,dataType:e})}});function createExpressionBuilder(t=NOOP_QUERY_EXECUTOR){function e(tr,rr,ir){return new ExpressionWrapper(parseValueBinaryOperation(tr,rr,ir))}function I(tr,rr){return new ExpressionWrapper(parseUnaryOperation(tr,rr))}const B=Object.assign(e,{fn:void 0,eb:void 0,selectFrom(tr){return createSelectQueryBuilder({queryId:createQueryId(),executor:t,queryNode:SelectQueryNode.createFrom(parseTableExpressionOrList(tr))})},case(tr){return new CaseBuilder({node:CaseNode.create(isUndefined(tr)?void 0:parseReferenceExpression(tr))})},ref(tr,rr){return isUndefined(rr)?new ExpressionWrapper(parseStringReference(tr)):new JSONPathBuilder(parseJSONReference(tr,rr))},jsonPath(){return new JSONPathBuilder(JSONPathNode.create())},table(tr){return new ExpressionWrapper(parseTable(tr))},val(tr){return new ExpressionWrapper(parseValueExpression(tr))},refTuple(...tr){return new ExpressionWrapper(TupleNode.create(tr.map(parseReferenceExpression)))},tuple(...tr){return new ExpressionWrapper(TupleNode.create(tr.map(parseValueExpression)))},lit(tr){return new ExpressionWrapper(parseSafeImmediateValue(tr))},unary:I,not(tr){return I("not",tr)},exists(tr){return I("exists",tr)},neg(tr){return I("-",tr)},between(tr,rr,ir){return new ExpressionWrapper(BinaryOperationNode.create(parseReferenceExpression(tr),OperatorNode.create("between"),AndNode.create(parseValueExpression(rr),parseValueExpression(ir))))},betweenSymmetric(tr,rr,ir){return new ExpressionWrapper(BinaryOperationNode.create(parseReferenceExpression(tr),OperatorNode.create("between symmetric"),AndNode.create(parseValueExpression(rr),parseValueExpression(ir))))},and(tr){return isReadonlyArray(tr)?new ExpressionWrapper(parseFilterList(tr,"and")):new ExpressionWrapper(parseFilterObject(tr,"and"))},or(tr){return isReadonlyArray(tr)?new ExpressionWrapper(parseFilterList(tr,"or")):new ExpressionWrapper(parseFilterObject(tr,"or"))},parens(...tr){const rr=parseValueBinaryOperationOrExpression(tr);return ParensNode.is(rr)?new ExpressionWrapper(rr):new ExpressionWrapper(ParensNode.create(rr))},cast(tr,rr){return new ExpressionWrapper(CastNode.create(parseReferenceExpression(tr),parseDataTypeExpression(rr)))},withSchema(tr){return createExpressionBuilder(t.withPluginAtFront(new WithSchemaPlugin(tr)))}});return B.fn=createFunctionModule(),B.eb=B,B}function expressionBuilder(t){return createExpressionBuilder()}function parseExpression(t){if(isOperationNodeSource(t))return t.toOperationNode();if(isFunction(t))return t(expressionBuilder()).toOperationNode();throw new Error(`invalid expression: ${JSON.stringify(t)}`)}function parseAliasedExpression(t){if(isOperationNodeSource(t))return t.toOperationNode();if(isFunction(t))return t(expressionBuilder()).toOperationNode();throw new Error(`invalid aliased expression: ${JSON.stringify(t)}`)}function isExpressionOrFactory(t){return isExpression(t)||isAliasedExpression(t)||isFunction(t)}class DynamicTableBuilder{#e;get table(){return this.#e}constructor(e){this.#e=e}as(e){return new AliasedDynamicTableBuilder(this.#e,e)}}class AliasedDynamicTableBuilder{#e;#t;get table(){return this.#e}get alias(){return this.#t}constructor(e,I){this.#e=e,this.#t=I}toOperationNode(){return AliasNode.create(parseTable(this.#e),IdentifierNode.create(this.#t))}}function isAliasedDynamicTableBuilder(t){return isObject(t)&&isOperationNodeSource(t)&&isString(t.table)&&isString(t.alias)}function parseTableExpressionOrList(t){return isReadonlyArray(t)?t.map(e=>parseTableExpression(e)):[parseTableExpression(t)]}function parseTableExpression(t){return isString(t)?parseAliasedTable(t):isAliasedDynamicTableBuilder(t)?t.toOperationNode():parseAliasedExpression(t)}function parseAliasedTable(t){const e=" as ";if(t.includes(e)){const[I,B]=t.split(e).map(trim$1);return AliasNode.create(parseTable(I),IdentifierNode.create(B))}else return parseTable(t)}function parseTable(t){if(t.includes(".")){const[I,B]=t.split(".").map(trim$1);return TableNode.createWithSchema(I,B)}else return TableNode.create(t)}function trim$1(t){return t.trim()}const AddColumnNode=freeze({is(t){return t.kind==="AddColumnNode"},create(t){return freeze({kind:"AddColumnNode",column:t})}}),ColumnDefinitionNode=freeze({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return freeze({kind:"ColumnDefinitionNode",column:ColumnNode.create(t),dataType:e})},cloneWithFrontModifier(t,e){return freeze({...t,frontModifiers:t.frontModifiers?freeze([...t.frontModifiers,e]):[e]})},cloneWithEndModifier(t,e){return freeze({...t,endModifiers:t.endModifiers?freeze([...t.endModifiers,e]):[e]})},cloneWith(t,e){return freeze({...t,...e})}}),DropColumnNode=freeze({is(t){return t.kind==="DropColumnNode"},create(t){return freeze({kind:"DropColumnNode",column:ColumnNode.create(t)})}}),RenameColumnNode=freeze({is(t){return t.kind==="RenameColumnNode"},create(t,e){return freeze({kind:"RenameColumnNode",column:ColumnNode.create(t),renameTo:ColumnNode.create(e)})}}),CheckConstraintNode=freeze({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return freeze({kind:"CheckConstraintNode",expression:t,name:e?IdentifierNode.create(e):void 0})}}),ON_MODIFY_FOREIGN_ACTIONS=["no action","restrict","cascade","set null","set default"],ReferencesNode=freeze({is(t){return t.kind==="ReferencesNode"},create(t,e){return freeze({kind:"ReferencesNode",table:t,columns:freeze([...e])})},cloneWithOnDelete(t,e){return freeze({...t,onDelete:e})},cloneWithOnUpdate(t,e){return freeze({...t,onUpdate:e})}});function parseDefaultValueExpression(t){return isOperationNodeSource(t)?t.toOperationNode():ValueNode.createImmediate(t)}const GeneratedNode=freeze({is(t){return t.kind==="GeneratedNode"},create(t){return freeze({kind:"GeneratedNode",...t})},createWithExpression(t){return freeze({kind:"GeneratedNode",always:!0,expression:t})},cloneWith(t,e){return freeze({...t,...e})}}),DefaultValueNode=freeze({is(t){return t.kind==="DefaultValueNode"},create(t){return freeze({kind:"DefaultValueNode",defaultValue:t})}});function parseOnModifyForeignAction(t){if(ON_MODIFY_FOREIGN_ACTIONS.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}class ColumnDefinitionBuilder{#e;constructor(e){this.#e=e}autoIncrement(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{autoIncrement:!0}))}identity(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{identity:!0}))}primaryKey(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{primaryKey:!0}))}references(e){const I=parseStringReference(e);if(!I.table||SelectAllNode.is(I.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{references:ReferencesNode.create(I.table,[I.column])}))}onDelete(e){if(!this.#e.references)throw new Error("on delete constraint can only be added for foreign keys");return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{references:ReferencesNode.cloneWithOnDelete(this.#e.references,parseOnModifyForeignAction(e))}))}onUpdate(e){if(!this.#e.references)throw new Error("on update constraint can only be added for foreign keys");return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{references:ReferencesNode.cloneWithOnUpdate(this.#e.references,parseOnModifyForeignAction(e))}))}unique(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{unique:!0}))}notNull(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{notNull:!0}))}unsigned(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{unsigned:!0}))}defaultTo(e){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{defaultTo:DefaultValueNode.create(parseDefaultValueExpression(e))}))}check(e){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{check:CheckConstraintNode.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{generated:GeneratedNode.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{generated:GeneratedNode.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{generated:GeneratedNode.create({identity:!0,byDefault:!0})}))}stored(){if(!this.#e.generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{generated:GeneratedNode.cloneWith(this.#e.generated,{stored:!0})}))}modifyFront(e){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWithFrontModifier(this.#e,e.toOperationNode()))}nullsNotDistinct(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{nullsNotDistinct:!0}))}ifNotExists(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{ifNotExists:!0}))}modifyEnd(e){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWithEndModifier(this.#e,e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return this.#e}}const ModifyColumnNode=freeze({is(t){return t.kind==="ModifyColumnNode"},create(t){return freeze({kind:"ModifyColumnNode",column:t})}}),ForeignKeyConstraintNode=freeze({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,I,B){return freeze({kind:"ForeignKeyConstraintNode",columns:t,references:ReferencesNode.create(e,I),name:B?IdentifierNode.create(B):void 0})},cloneWith(t,e){return freeze({...t,...e})}});class ForeignKeyConstraintBuilder{#e;constructor(e){this.#e=e}onDelete(e){return new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.cloneWith(this.#e,{onDelete:parseOnModifyForeignAction(e)}))}onUpdate(e){return new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.cloneWith(this.#e,{onUpdate:parseOnModifyForeignAction(e)}))}deferrable(){return new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}}const AddConstraintNode=freeze({is(t){return t.kind==="AddConstraintNode"},create(t){return freeze({kind:"AddConstraintNode",constraint:t})}}),UniqueConstraintNode=freeze({is(t){return t.kind==="UniqueConstraintNode"},create(t,e,I){return freeze({kind:"UniqueConstraintNode",columns:freeze(t.map(ColumnNode.create)),name:e?IdentifierNode.create(e):void 0,nullsNotDistinct:I})},cloneWith(t,e){return freeze({...t,...e})}}),DropConstraintNode=freeze({is(t){return t.kind==="DropConstraintNode"},create(t){return freeze({kind:"DropConstraintNode",constraintName:IdentifierNode.create(t)})},cloneWith(t,e){return freeze({...t,...e})}}),AlterColumnNode=freeze({is(t){return t.kind==="AlterColumnNode"},create(t,e,I){return freeze({kind:"AlterColumnNode",column:ColumnNode.create(t),[e]:I})}});class AlterColumnBuilder{#e;constructor(e){this.#e=e}setDataType(e){return new AlteredColumnBuilder(AlterColumnNode.create(this.#e,"dataType",parseDataTypeExpression(e)))}setDefault(e){return new AlteredColumnBuilder(AlterColumnNode.create(this.#e,"setDefault",parseDefaultValueExpression(e)))}dropDefault(){return new AlteredColumnBuilder(AlterColumnNode.create(this.#e,"dropDefault",!0))}setNotNull(){return new AlteredColumnBuilder(AlterColumnNode.create(this.#e,"setNotNull",!0))}dropNotNull(){return new AlteredColumnBuilder(AlterColumnNode.create(this.#e,"dropNotNull",!0))}$call(e){return e(this)}}class AlteredColumnBuilder{#e;constructor(e){this.#e=e}toOperationNode(){return this.#e}}class AlterTableExecutor{#e;constructor(e){this.#e=freeze(e)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class AlterTableAddForeignKeyConstraintBuilder{#e;constructor(e){this.#e=freeze(e)}onDelete(e){return new AlterTableAddForeignKeyConstraintBuilder({...this.#e,constraintBuilder:this.#e.constraintBuilder.onDelete(e)})}onUpdate(e){return new AlterTableAddForeignKeyConstraintBuilder({...this.#e,constraintBuilder:this.#e.constraintBuilder.onUpdate(e)})}deferrable(){return new AlterTableAddForeignKeyConstraintBuilder({...this.#e,constraintBuilder:this.#e.constraintBuilder.deferrable()})}notDeferrable(){return new AlterTableAddForeignKeyConstraintBuilder({...this.#e,constraintBuilder:this.#e.constraintBuilder.notDeferrable()})}initiallyDeferred(){return new AlterTableAddForeignKeyConstraintBuilder({...this.#e,constraintBuilder:this.#e.constraintBuilder.initiallyDeferred()})}initiallyImmediate(){return new AlterTableAddForeignKeyConstraintBuilder({...this.#e,constraintBuilder:this.#e.constraintBuilder.initiallyImmediate()})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(AlterTableNode.cloneWithTableProps(this.#e.node,{addConstraint:AddConstraintNode.create(this.#e.constraintBuilder.toOperationNode())}),this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class AlterTableDropConstraintBuilder{#e;constructor(e){this.#e=freeze(e)}ifExists(){return new AlterTableDropConstraintBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{dropConstraint:DropConstraintNode.cloneWith(this.#e.node.dropConstraint,{ifExists:!0})})})}cascade(){return new AlterTableDropConstraintBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{dropConstraint:DropConstraintNode.cloneWith(this.#e.node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new AlterTableDropConstraintBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{dropConstraint:DropConstraintNode.cloneWith(this.#e.node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}const PrimaryKeyConstraintNode=freeze({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return freeze({kind:"PrimaryKeyConstraintNode",columns:freeze(t.map(ColumnNode.create)),name:e?IdentifierNode.create(e):void 0})},cloneWith(t,e){return freeze({...t,...e})}}),AddIndexNode=freeze({is(t){return t.kind==="AddIndexNode"},create(t){return freeze({kind:"AddIndexNode",name:IdentifierNode.create(t)})},cloneWith(t,e){return freeze({...t,...e})},cloneWithColumns(t,e){return freeze({...t,columns:[...t.columns||[],...e]})}});class AlterTableAddIndexBuilder{#e;constructor(e){this.#e=freeze(e)}unique(){return new AlterTableAddIndexBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addIndex:AddIndexNode.cloneWith(this.#e.node.addIndex,{unique:!0})})})}column(e){return new AlterTableAddIndexBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addIndex:AddIndexNode.cloneWithColumns(this.#e.node.addIndex,[parseOrderedColumnName(e)])})})}columns(e){return new AlterTableAddIndexBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addIndex:AddIndexNode.cloneWithColumns(this.#e.node.addIndex,e.map(parseOrderedColumnName))})})}expression(e){return new AlterTableAddIndexBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addIndex:AddIndexNode.cloneWithColumns(this.#e.node.addIndex,[e.toOperationNode()])})})}using(e){return new AlterTableAddIndexBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addIndex:AddIndexNode.cloneWith(this.#e.node.addIndex,{using:RawNode.createWithSql(e)})})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class UniqueConstraintNodeBuilder{#e;constructor(e){this.#e=e}nullsNotDistinct(){return new UniqueConstraintNodeBuilder(UniqueConstraintNode.cloneWith(this.#e,{nullsNotDistinct:!0}))}deferrable(){return new UniqueConstraintNodeBuilder(UniqueConstraintNode.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new UniqueConstraintNodeBuilder(UniqueConstraintNode.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new UniqueConstraintNodeBuilder(UniqueConstraintNode.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new UniqueConstraintNodeBuilder(UniqueConstraintNode.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}}class PrimaryKeyConstraintBuilder{#e;constructor(e){this.#e=e}deferrable(){return new PrimaryKeyConstraintBuilder(PrimaryKeyConstraintNode.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new PrimaryKeyConstraintBuilder(PrimaryKeyConstraintNode.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new PrimaryKeyConstraintBuilder(PrimaryKeyConstraintNode.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new PrimaryKeyConstraintBuilder(PrimaryKeyConstraintNode.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}}class CheckConstraintBuilder{#e;constructor(e){this.#e=e}$call(e){return e(this)}toOperationNode(){return this.#e}}const RenameConstraintNode=freeze({is(t){return t.kind==="RenameConstraintNode"},create(t,e){return freeze({kind:"RenameConstraintNode",oldName:IdentifierNode.create(t),newName:IdentifierNode.create(e)})}});class AlterTableBuilder{#e;constructor(e){this.#e=freeze(e)}renameTo(e){return new AlterTableExecutor({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{renameTo:parseTable(e)})})}setSchema(e){return new AlterTableExecutor({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{setSchema:IdentifierNode.create(e)})})}alterColumn(e,I){const B=I(new AlterColumnBuilder(e));return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,B.toOperationNode())})}dropColumn(e){return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,DropColumnNode.create(e))})}renameColumn(e,I){return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,RenameColumnNode.create(e,I))})}addColumn(e,I,B=noop){const tr=B(new ColumnDefinitionBuilder(ColumnDefinitionNode.create(e,parseDataTypeExpression(I))));return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,AddColumnNode.create(tr.toOperationNode()))})}modifyColumn(e,I,B=noop){const tr=B(new ColumnDefinitionBuilder(ColumnDefinitionNode.create(e,parseDataTypeExpression(I))));return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,ModifyColumnNode.create(tr.toOperationNode()))})}addUniqueConstraint(e,I,B=noop){const tr=B(new UniqueConstraintNodeBuilder(UniqueConstraintNode.create(I,e)));return new AlterTableExecutor({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addConstraint:AddConstraintNode.create(tr.toOperationNode())})})}addCheckConstraint(e,I,B=noop){const tr=B(new CheckConstraintBuilder(CheckConstraintNode.create(I.toOperationNode(),e)));return new AlterTableExecutor({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addConstraint:AddConstraintNode.create(tr.toOperationNode())})})}addForeignKeyConstraint(e,I,B,tr,rr=noop){const ir=rr(new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.create(I.map(ColumnNode.create),parseTable(B),tr.map(ColumnNode.create),e)));return new AlterTableAddForeignKeyConstraintBuilder({...this.#e,constraintBuilder:ir})}addPrimaryKeyConstraint(e,I,B=noop){const tr=B(new PrimaryKeyConstraintBuilder(PrimaryKeyConstraintNode.create(I,e)));return new AlterTableExecutor({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addConstraint:AddConstraintNode.create(tr.toOperationNode())})})}dropConstraint(e){return new AlterTableDropConstraintBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{dropConstraint:DropConstraintNode.create(e)})})}renameConstraint(e,I){return new AlterTableDropConstraintBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{renameConstraint:RenameConstraintNode.create(e,I)})})}addIndex(e){return new AlterTableAddIndexBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addIndex:AddIndexNode.create(e)})})}dropIndex(e){return new AlterTableExecutor({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{dropIndex:DropIndexNode.create(e)})})}$call(e){return e(this)}}class AlterTableColumnAlteringBuilder{#e;constructor(e){this.#e=freeze(e)}alterColumn(e,I){const B=I(new AlterColumnBuilder(e));return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,B.toOperationNode())})}dropColumn(e){return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,DropColumnNode.create(e))})}renameColumn(e,I){return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,RenameColumnNode.create(e,I))})}addColumn(e,I,B=noop){const tr=B(new ColumnDefinitionBuilder(ColumnDefinitionNode.create(e,parseDataTypeExpression(I))));return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,AddColumnNode.create(tr.toOperationNode()))})}modifyColumn(e,I,B=noop){const tr=B(new ColumnDefinitionBuilder(ColumnDefinitionNode.create(e,parseDataTypeExpression(I))));return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,ModifyColumnNode.create(tr.toOperationNode()))})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class ImmediateValueTransformer extends OperationNodeTransformer{transformPrimitiveValueList(e){return ValueListNode.create(e.values.map(ValueNode.createImmediate))}transformValue(e){return ValueNode.createImmediate(e.value)}}class CreateIndexBuilder{#e;constructor(e){this.#e=freeze(e)}ifNotExists(){return new CreateIndexBuilder({...this.#e,node:CreateIndexNode.cloneWith(this.#e.node,{ifNotExists:!0})})}unique(){return new CreateIndexBuilder({...this.#e,node:CreateIndexNode.cloneWith(this.#e.node,{unique:!0})})}nullsNotDistinct(){return new CreateIndexBuilder({...this.#e,node:CreateIndexNode.cloneWith(this.#e.node,{nullsNotDistinct:!0})})}on(e){return new CreateIndexBuilder({...this.#e,node:CreateIndexNode.cloneWith(this.#e.node,{table:parseTable(e)})})}column(e){return new CreateIndexBuilder({...this.#e,node:CreateIndexNode.cloneWithColumns(this.#e.node,[parseOrderedColumnName(e)])})}columns(e){return new CreateIndexBuilder({...this.#e,node:CreateIndexNode.cloneWithColumns(this.#e.node,e.map(parseOrderedColumnName))})}expression(e){return new CreateIndexBuilder({...this.#e,node:CreateIndexNode.cloneWithColumns(this.#e.node,[e.toOperationNode()])})}using(e){return new CreateIndexBuilder({...this.#e,node:CreateIndexNode.cloneWith(this.#e.node,{using:RawNode.createWithSql(e)})})}where(...e){const I=new ImmediateValueTransformer;return new CreateIndexBuilder({...this.#e,node:QueryNode.cloneWithWhere(this.#e.node,I.transformNode(parseValueBinaryOperationOrExpression(e),this.#e.queryId))})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class CreateSchemaBuilder{#e;constructor(e){this.#e=freeze(e)}ifNotExists(){return new CreateSchemaBuilder({...this.#e,node:CreateSchemaNode.cloneWith(this.#e.node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}function parseOnCommitAction(t){if(ON_COMMIT_ACTIONS.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}class CreateTableBuilder{#e;constructor(e){this.#e=freeze(e)}temporary(){return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWith(this.#e.node,{temporary:!0})})}onCommit(e){return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWith(this.#e.node,{onCommit:parseOnCommitAction(e)})})}ifNotExists(){return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWith(this.#e.node,{ifNotExists:!0})})}addColumn(e,I,B=noop){const tr=B(new ColumnDefinitionBuilder(ColumnDefinitionNode.create(e,parseDataTypeExpression(I))));return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWithColumn(this.#e.node,tr.toOperationNode())})}addPrimaryKeyConstraint(e,I,B=noop){const tr=B(new PrimaryKeyConstraintBuilder(PrimaryKeyConstraintNode.create(I,e)));return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWithConstraint(this.#e.node,tr.toOperationNode())})}addUniqueConstraint(e,I,B=noop){const tr=B(new UniqueConstraintNodeBuilder(UniqueConstraintNode.create(I,e)));return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWithConstraint(this.#e.node,tr.toOperationNode())})}addCheckConstraint(e,I,B=noop){const tr=B(new CheckConstraintBuilder(CheckConstraintNode.create(I.toOperationNode(),e)));return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWithConstraint(this.#e.node,tr.toOperationNode())})}addForeignKeyConstraint(e,I,B,tr,rr=noop){const ir=rr(new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.create(I.map(ColumnNode.create),parseTable(B),tr.map(ColumnNode.create),e)));return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWithConstraint(this.#e.node,ir.toOperationNode())})}modifyFront(e){return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWithFrontModifier(this.#e.node,e.toOperationNode())})}modifyEnd(e){return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWithEndModifier(this.#e.node,e.toOperationNode())})}as(e){return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWith(this.#e.node,{selectQuery:parseExpression(e)})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class DropIndexBuilder{#e;constructor(e){this.#e=freeze(e)}on(e){return new DropIndexBuilder({...this.#e,node:DropIndexNode.cloneWith(this.#e.node,{table:parseTable(e)})})}ifExists(){return new DropIndexBuilder({...this.#e,node:DropIndexNode.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new DropIndexBuilder({...this.#e,node:DropIndexNode.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class DropSchemaBuilder{#e;constructor(e){this.#e=freeze(e)}ifExists(){return new DropSchemaBuilder({...this.#e,node:DropSchemaNode.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new DropSchemaBuilder({...this.#e,node:DropSchemaNode.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class DropTableBuilder{#e;constructor(e){this.#e=freeze(e)}ifExists(){return new DropTableBuilder({...this.#e,node:DropTableNode.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new DropTableBuilder({...this.#e,node:DropTableNode.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}const CreateViewNode=freeze({is(t){return t.kind==="CreateViewNode"},create(t){return freeze({kind:"CreateViewNode",name:SchemableIdentifierNode.create(t)})},cloneWith(t,e){return freeze({...t,...e})}});class ImmediateValuePlugin{#e=new ImmediateValueTransformer;transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}transformResult(e){return Promise.resolve(e.result)}}class CreateViewBuilder{#e;constructor(e){this.#e=freeze(e)}temporary(){return new CreateViewBuilder({...this.#e,node:CreateViewNode.cloneWith(this.#e.node,{temporary:!0})})}materialized(){return new CreateViewBuilder({...this.#e,node:CreateViewNode.cloneWith(this.#e.node,{materialized:!0})})}ifNotExists(){return new CreateViewBuilder({...this.#e,node:CreateViewNode.cloneWith(this.#e.node,{ifNotExists:!0})})}orReplace(){return new CreateViewBuilder({...this.#e,node:CreateViewNode.cloneWith(this.#e.node,{orReplace:!0})})}columns(e){return new CreateViewBuilder({...this.#e,node:CreateViewNode.cloneWith(this.#e.node,{columns:e.map(parseColumnName)})})}as(e){const I=e.withPlugin(new ImmediateValuePlugin).toOperationNode();return new CreateViewBuilder({...this.#e,node:CreateViewNode.cloneWith(this.#e.node,{as:I})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}const DropViewNode=freeze({is(t){return t.kind==="DropViewNode"},create(t){return freeze({kind:"DropViewNode",name:SchemableIdentifierNode.create(t)})},cloneWith(t,e){return freeze({...t,...e})}});class DropViewBuilder{#e;constructor(e){this.#e=freeze(e)}materialized(){return new DropViewBuilder({...this.#e,node:DropViewNode.cloneWith(this.#e.node,{materialized:!0})})}ifExists(){return new DropViewBuilder({...this.#e,node:DropViewNode.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new DropViewBuilder({...this.#e,node:DropViewNode.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}const CreateTypeNode=freeze({is(t){return t.kind==="CreateTypeNode"},create(t){return freeze({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return freeze({...t,enum:ValueListNode.create(e.map(ValueNode.createImmediate))})}});class CreateTypeBuilder{#e;constructor(e){this.#e=freeze(e)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}asEnum(e){return new CreateTypeBuilder({...this.#e,node:CreateTypeNode.cloneWithEnum(this.#e.node,e)})}$call(e){return e(this)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}const DropTypeNode=freeze({is(t){return t.kind==="DropTypeNode"},create(t){return freeze({kind:"DropTypeNode",name:t})},cloneWith(t,e){return freeze({...t,...e})}});class DropTypeBuilder{#e;constructor(e){this.#e=freeze(e)}ifExists(){return new DropTypeBuilder({...this.#e,node:DropTypeNode.cloneWith(this.#e.node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}function parseSchemableIdentifier(t){if(t.includes(".")){const I=t.split(".").map(trim);if(I.length===2)return SchemableIdentifierNode.createWithSchema(I[0],I[1]);throw new Error(`invalid schemable identifier ${t}`)}else return SchemableIdentifierNode.create(t)}function trim(t){return t.trim()}const RefreshMaterializedViewNode=freeze({is(t){return t.kind==="RefreshMaterializedViewNode"},create(t){return freeze({kind:"RefreshMaterializedViewNode",name:SchemableIdentifierNode.create(t)})},cloneWith(t,e){return freeze({...t,...e})}});class RefreshMaterializedViewBuilder{#e;constructor(e){this.#e=freeze(e)}concurrently(){return new RefreshMaterializedViewBuilder({...this.#e,node:RefreshMaterializedViewNode.cloneWith(this.#e.node,{concurrently:!0,withNoData:!1})})}withData(){return new RefreshMaterializedViewBuilder({...this.#e,node:RefreshMaterializedViewNode.cloneWith(this.#e.node,{withNoData:!1})})}withNoData(){return new RefreshMaterializedViewBuilder({...this.#e,node:RefreshMaterializedViewNode.cloneWith(this.#e.node,{withNoData:!0,concurrently:!1})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class SchemaModule{#e;constructor(e){this.#e=e}createTable(e){return new CreateTableBuilder({queryId:createQueryId(),executor:this.#e,node:CreateTableNode.create(parseTable(e))})}dropTable(e){return new DropTableBuilder({queryId:createQueryId(),executor:this.#e,node:DropTableNode.create(parseTable(e))})}createIndex(e){return new CreateIndexBuilder({queryId:createQueryId(),executor:this.#e,node:CreateIndexNode.create(e)})}dropIndex(e){return new DropIndexBuilder({queryId:createQueryId(),executor:this.#e,node:DropIndexNode.create(e)})}createSchema(e){return new CreateSchemaBuilder({queryId:createQueryId(),executor:this.#e,node:CreateSchemaNode.create(e)})}dropSchema(e){return new DropSchemaBuilder({queryId:createQueryId(),executor:this.#e,node:DropSchemaNode.create(e)})}alterTable(e){return new AlterTableBuilder({queryId:createQueryId(),executor:this.#e,node:AlterTableNode.create(parseTable(e))})}createView(e){return new CreateViewBuilder({queryId:createQueryId(),executor:this.#e,node:CreateViewNode.create(e)})}refreshMaterializedView(e){return new RefreshMaterializedViewBuilder({queryId:createQueryId(),executor:this.#e,node:RefreshMaterializedViewNode.create(e)})}dropView(e){return new DropViewBuilder({queryId:createQueryId(),executor:this.#e,node:DropViewNode.create(e)})}createType(e){return new CreateTypeBuilder({queryId:createQueryId(),executor:this.#e,node:CreateTypeNode.create(parseSchemableIdentifier(e))})}dropType(e){return new DropTypeBuilder({queryId:createQueryId(),executor:this.#e,node:DropTypeNode.create(parseSchemableIdentifier(e))})}withPlugin(e){return new SchemaModule(this.#e.withPlugin(e))}withoutPlugins(){return new SchemaModule(this.#e.withoutPlugins())}withSchema(e){return new SchemaModule(this.#e.withPluginAtFront(new WithSchemaPlugin(e)))}}class DynamicModule{ref(e){return new DynamicReferenceBuilder(e)}table(e){return new DynamicTableBuilder(e)}}class DefaultConnectionProvider{#e;constructor(e){this.#e=e}async provideConnection(e){const I=await this.#e.acquireConnection();try{return await e(I)}finally{await this.#e.releaseConnection(I)}}}class DefaultQueryExecutor extends QueryExecutorBase{#e;#t;#r;constructor(e,I,B,tr=[]){super(tr),this.#e=e,this.#t=I,this.#r=B}get adapter(){return this.#t}compileQuery(e,I){return this.#e.compileQuery(e,I)}provideConnection(e){return this.#r.provideConnection(e)}withPlugins(e){return new DefaultQueryExecutor(this.#e,this.#t,this.#r,[...this.plugins,...e])}withPlugin(e){return new DefaultQueryExecutor(this.#e,this.#t,this.#r,[...this.plugins,e])}withPluginAtFront(e){return new DefaultQueryExecutor(this.#e,this.#t,this.#r,[e,...this.plugins])}withConnectionProvider(e){return new DefaultQueryExecutor(this.#e,this.#t,e,[...this.plugins])}withoutPlugins(){return new DefaultQueryExecutor(this.#e,this.#t,this.#r,[])}}function performanceNow(){return typeof performance<"u"&&isFunction(performance.now)?performance.now():Date.now()}class RuntimeDriver{#e;#t;#r;#n;#o;#l=new WeakSet;constructor(e,I){this.#n=!1,this.#e=e,this.#t=I}async init(){if(this.#o)throw new Error("driver has already been destroyed");this.#r||(this.#r=this.#e.init().then(()=>{this.#n=!0}).catch(e=>(this.#r=void 0,Promise.reject(e)))),await this.#r}async acquireConnection(){if(this.#o)throw new Error("driver has already been destroyed");this.#n||await this.init();const e=await this.#e.acquireConnection();return this.#l.has(e)||(this.#s()&&this.#i(e),this.#l.add(e)),e}async releaseConnection(e){await this.#e.releaseConnection(e)}beginTransaction(e,I){return this.#e.beginTransaction(e,I)}commitTransaction(e){return this.#e.commitTransaction(e)}rollbackTransaction(e){return this.#e.rollbackTransaction(e)}savepoint(e,I,B){if(this.#e.savepoint)return this.#e.savepoint(e,I,B);throw new Error("The `savepoint` method is not supported by this driver")}rollbackToSavepoint(e,I,B){if(this.#e.rollbackToSavepoint)return this.#e.rollbackToSavepoint(e,I,B);throw new Error("The `rollbackToSavepoint` method is not supported by this driver")}releaseSavepoint(e,I,B){if(this.#e.releaseSavepoint)return this.#e.releaseSavepoint(e,I,B);throw new Error("The `releaseSavepoint` method is not supported by this driver")}async destroy(){this.#r&&(await this.#r,this.#o||(this.#o=this.#e.destroy().catch(e=>(this.#o=void 0,Promise.reject(e)))),await this.#o)}#s(){return this.#t.isLevelEnabled("query")||this.#t.isLevelEnabled("error")}#i(e){const I=e.executeQuery,B=e.streamQuery,tr=this;e.executeQuery=async rr=>{let ir;const lr=performanceNow();try{return await I.call(e,rr)}catch(dr){throw ir=dr,await tr.#a(dr,rr,lr),dr}finally{ir||await tr.#d(rr,lr)}},e.streamQuery=async function*(rr,ir){let lr;const dr=performanceNow();try{for await(const mr of B.call(e,rr,ir))yield mr}catch(mr){throw lr=mr,await tr.#a(mr,rr,dr),mr}finally{lr||await tr.#d(rr,dr,!0)}}}async#a(e,I,B){await this.#t.error(()=>({level:"error",error:e,query:I,queryDurationMillis:this.#c(B)}))}async#d(e,I,B=!1){await this.#t.query(()=>({level:"query",isStream:B,query:e,queryDurationMillis:this.#c(I)}))}#c(e){return performanceNow()-e}}const ignoreError=()=>{};class SingleConnectionProvider{#e;#t;constructor(e){this.#e=e}async provideConnection(e){for(;this.#t;)await this.#t.catch(ignoreError);return this.#t=this.#r(e).finally(()=>{this.#t=void 0}),this.#t}async#r(e){return await e(this.#e)}}const TRANSACTION_ACCESS_MODES=["read only","read write"],TRANSACTION_ISOLATION_LEVELS=["read uncommitted","read committed","repeatable read","serializable","snapshot"];function validateTransactionSettings(t){if(t.accessMode&&!TRANSACTION_ACCESS_MODES.includes(t.accessMode))throw new Error(`invalid transaction access mode ${t.accessMode}`);if(t.isolationLevel&&!TRANSACTION_ISOLATION_LEVELS.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}freeze(["query","error"]);class Log{#e;#t;constructor(e){isFunction(e)?(this.#t=e,this.#e=freeze({query:!0,error:!0})):(this.#t=defaultLogger,this.#e=freeze({query:e.includes("query"),error:e.includes("error")}))}isLevelEnabled(e){return this.#e[e]}async query(e){this.#e.query&&await this.#t(e())}async error(e){this.#e.error&&await this.#t(e())}}function defaultLogger(t){if(t.level==="query"){const e=`kysely:query:${t.isStream?"stream:":""}`;console.log(`${e} ${t.query.sql}`),console.log(`${e} duration: ${t.queryDurationMillis.toFixed(1)}ms`)}else t.level==="error"&&(t.error instanceof Error?console.error(`kysely:error: ${t.error.stack??t.error.message}`):console.error(`kysely:error: ${JSON.stringify({error:t.error,query:t.query.sql,queryDurationMillis:t.queryDurationMillis})}`))}function isCompilable(t){return isObject(t)&&isFunction(t.compile)}Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");class Kysely extends QueryCreator{#e;constructor(e){let I,B;if(isKyselyProps(e))I={executor:e.executor},B={...e};else{const tr=e.dialect,rr=tr.createDriver(),ir=tr.createQueryCompiler(),lr=tr.createAdapter(),dr=new Log(e.log??[]),mr=new RuntimeDriver(rr,dr),hr=new DefaultConnectionProvider(mr),fr=new DefaultQueryExecutor(ir,lr,hr,e.plugins??[]);I={executor:fr},B={config:e,executor:fr,dialect:tr,driver:mr}}super(I),this.#e=freeze(B)}get schema(){return new SchemaModule(this.#e.executor)}get dynamic(){return new DynamicModule}get introspection(){return this.#e.dialect.createIntrospector(this.withoutPlugins())}case(e){return new CaseBuilder({node:CaseNode.create(isUndefined(e)?void 0:parseExpression(e))})}get fn(){return createFunctionModule()}transaction(){return new TransactionBuilder({...this.#e})}startTransaction(){return new ControlledTransactionBuilder({...this.#e})}connection(){return new ConnectionBuilder({...this.#e})}withPlugin(e){return new Kysely({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new Kysely({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new Kysely({...this.#e,executor:this.#e.executor.withPluginAtFront(new WithSchemaPlugin(e))})}withTables(){return new Kysely({...this.#e})}async destroy(){await this.#e.driver.destroy()}get isTransaction(){return!1}getExecutor(){return this.#e.executor}executeQuery(e,I){I!==void 0&&logOnce("Passing `queryId` in `db.executeQuery` is deprecated and will result in a compile-time error in the future.");const B=isCompilable(e)?e.compile():e;return this.getExecutor().executeQuery(B)}async[Symbol.asyncDispose](){await this.destroy()}}class Transaction extends Kysely{#e;constructor(e){super(e),this.#e=e}get isTransaction(){return!0}transaction(){throw new Error("calling the transaction method for a Transaction is not supported")}connection(){throw new Error("calling the connection method for a Transaction is not supported")}async destroy(){throw new Error("calling the destroy method for a Transaction is not supported")}withPlugin(e){return new Transaction({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new Transaction({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new Transaction({...this.#e,executor:this.#e.executor.withPluginAtFront(new WithSchemaPlugin(e))})}withTables(){return new Transaction({...this.#e})}}function isKyselyProps(t){return isObject(t)&&isObject(t.config)&&isObject(t.driver)&&isObject(t.executor)&&isObject(t.dialect)}class ConnectionBuilder{#e;constructor(e){this.#e=freeze(e)}async execute(e){return this.#e.executor.provideConnection(async I=>{const B=this.#e.executor.withConnectionProvider(new SingleConnectionProvider(I)),tr=new Kysely({...this.#e,executor:B});return await e(tr)})}}class TransactionBuilder{#e;constructor(e){this.#e=freeze(e)}setAccessMode(e){return new TransactionBuilder({...this.#e,accessMode:e})}setIsolationLevel(e){return new TransactionBuilder({...this.#e,isolationLevel:e})}async execute(e){const{isolationLevel:I,accessMode:B,...tr}=this.#e,rr={isolationLevel:I,accessMode:B};return validateTransactionSettings(rr),this.#e.executor.provideConnection(async ir=>{const lr=this.#e.executor.withConnectionProvider(new SingleConnectionProvider(ir)),dr=new Transaction({...tr,executor:lr});let mr=!1;try{await this.#e.driver.beginTransaction(ir,rr),mr=!0;const hr=await e(dr);return await this.#e.driver.commitTransaction(ir),hr}catch(hr){throw mr&&await this.#e.driver.rollbackTransaction(ir),hr}})}}class ControlledTransactionBuilder{#e;constructor(e){this.#e=freeze(e)}setAccessMode(e){return new ControlledTransactionBuilder({...this.#e,accessMode:e})}setIsolationLevel(e){return new ControlledTransactionBuilder({...this.#e,isolationLevel:e})}async execute(){const{isolationLevel:e,accessMode:I,...B}=this.#e,tr={isolationLevel:e,accessMode:I};validateTransactionSettings(tr);const rr=await provideControlledConnection(this.#e.executor);return await this.#e.driver.beginTransaction(rr.connection,tr),new ControlledTransaction({...B,connection:rr,executor:this.#e.executor.withConnectionProvider(new SingleConnectionProvider(rr.connection))})}}class ControlledTransaction extends Transaction{#e;#t;#r;constructor(e){const I={isCommitted:!1,isRolledBack:!1};e={...e,executor:new NotCommittedOrRolledBackAssertingExecutor(e.executor,I)};const{connection:B,...tr}=e;super(tr),this.#e=freeze(e),this.#r=I;const rr=createQueryId();this.#t=ir=>e.executor.compileQuery(ir,rr)}get isCommitted(){return this.#r.isCommitted}get isRolledBack(){return this.#r.isRolledBack}commit(){return assertNotCommittedOrRolledBack(this.#r),new Command(async()=>{await this.#e.driver.commitTransaction(this.#e.connection.connection),this.#r.isCommitted=!0,this.#e.connection.release()})}rollback(){return assertNotCommittedOrRolledBack(this.#r),new Command(async()=>{await this.#e.driver.rollbackTransaction(this.#e.connection.connection),this.#r.isRolledBack=!0,this.#e.connection.release()})}savepoint(e){return assertNotCommittedOrRolledBack(this.#r),new Command(async()=>(await this.#e.driver.savepoint?.(this.#e.connection.connection,e,this.#t),new ControlledTransaction({...this.#e})))}rollbackToSavepoint(e){return assertNotCommittedOrRolledBack(this.#r),new Command(async()=>(await this.#e.driver.rollbackToSavepoint?.(this.#e.connection.connection,e,this.#t),new ControlledTransaction({...this.#e})))}releaseSavepoint(e){return assertNotCommittedOrRolledBack(this.#r),new Command(async()=>(await this.#e.driver.releaseSavepoint?.(this.#e.connection.connection,e,this.#t),new ControlledTransaction({...this.#e})))}withPlugin(e){return new ControlledTransaction({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new ControlledTransaction({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new ControlledTransaction({...this.#e,executor:this.#e.executor.withPluginAtFront(new WithSchemaPlugin(e))})}withTables(){return new ControlledTransaction({...this.#e})}}class Command{#e;constructor(e){this.#e=e}async execute(){return await this.#e()}}function assertNotCommittedOrRolledBack(t){if(t.isCommitted)throw new Error("Transaction is already committed");if(t.isRolledBack)throw new Error("Transaction is already rolled back")}class NotCommittedOrRolledBackAssertingExecutor{#e;#t;constructor(e,I){e instanceof NotCommittedOrRolledBackAssertingExecutor?this.#e=e.#e:this.#e=e,this.#t=I}get adapter(){return this.#e.adapter}get plugins(){return this.#e.plugins}transformQuery(e,I){return this.#e.transformQuery(e,I)}compileQuery(e,I){return this.#e.compileQuery(e,I)}provideConnection(e){return this.#e.provideConnection(e)}executeQuery(e){return assertNotCommittedOrRolledBack(this.#t),this.#e.executeQuery(e)}stream(e,I){return assertNotCommittedOrRolledBack(this.#t),this.#e.stream(e,I)}withConnectionProvider(e){return new NotCommittedOrRolledBackAssertingExecutor(this.#e.withConnectionProvider(e),this.#t)}withPlugin(e){return new NotCommittedOrRolledBackAssertingExecutor(this.#e.withPlugin(e),this.#t)}withPlugins(e){return new NotCommittedOrRolledBackAssertingExecutor(this.#e.withPlugins(e),this.#t)}withPluginAtFront(e){return new NotCommittedOrRolledBackAssertingExecutor(this.#e.withPluginAtFront(e),this.#t)}withoutPlugins(){return new NotCommittedOrRolledBackAssertingExecutor(this.#e.withoutPlugins(),this.#t)}}class RawBuilderImpl{#e;constructor(e){this.#e=freeze(e)}get expressionType(){}get isRawBuilder(){return!0}as(e){return new AliasedRawBuilderImpl(this,e)}$castTo(){return new RawBuilderImpl({...this.#e})}$notNull(){return new RawBuilderImpl(this.#e)}withPlugin(e){return new RawBuilderImpl({...this.#e,plugins:this.#e.plugins!==void 0?freeze([...this.#e.plugins,e]):freeze([e])})}toOperationNode(){return this.#r(this.#t())}compile(e){return this.#n(this.#t(e))}async execute(e){const I=this.#t(e);return I.executeQuery(this.#n(I))}#t(e){const I=e!==void 0?e.getExecutor():NOOP_QUERY_EXECUTOR;return this.#e.plugins!==void 0?I.withPlugins(this.#e.plugins):I}#r(e){return e.transformQuery(this.#e.rawNode,this.#e.queryId)}#n(e){return e.compileQuery(this.#r(e),this.#e.queryId)}}function createRawBuilder(t){return new RawBuilderImpl(t)}class AliasedRawBuilderImpl{#e;#t;constructor(e,I){this.#e=e,this.#t=I}get expression(){return this.#e}get alias(){return this.#t}get rawBuilder(){return this.#e}toOperationNode(){return AliasNode.create(this.#e.toOperationNode(),isOperationNodeSource(this.#t)?this.#t.toOperationNode():IdentifierNode.create(this.#t))}}const sql=Object.assign((t,...e)=>createRawBuilder({queryId:createQueryId(),rawNode:RawNode.create(t,e?.map(parseParameter)??[])}),{ref(t){return createRawBuilder({queryId:createQueryId(),rawNode:RawNode.createWithChild(parseStringReference(t))})},val(t){return createRawBuilder({queryId:createQueryId(),rawNode:RawNode.createWithChild(parseValueExpression(t))})},value(t){return this.val(t)},table(t){return createRawBuilder({queryId:createQueryId(),rawNode:RawNode.createWithChild(parseTable(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",createRawBuilder({queryId:createQueryId(),rawNode:RawNode.create(e,t.map(IdentifierNode.create))})},lit(t){return createRawBuilder({queryId:createQueryId(),rawNode:RawNode.createWithChild(ValueNode.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return createRawBuilder({queryId:createQueryId(),rawNode:RawNode.createWithSql(t)})},join(t,e=sql`, `){const I=new Array(Math.max(2*t.length-1,0)),B=e.toOperationNode();for(let tr=0;tr<t.length;++tr)I[2*tr]=parseParameter(t[tr]),tr!==t.length-1&&(I[2*tr+1]=B);return createRawBuilder({queryId:createQueryId(),rawNode:RawNode.createWithChildren(I)})}});function parseParameter(t){return isOperationNodeSource(t)?t.toOperationNode():parseValueExpression(t)}class OperationNodeVisitor{nodeStack=[];get parentNode(){return this.nodeStack[this.nodeStack.length-2]}#e=freeze({AliasNode:this.visitAlias.bind(this),ColumnNode:this.visitColumn.bind(this),IdentifierNode:this.visitIdentifier.bind(this),SchemableIdentifierNode:this.visitSchemableIdentifier.bind(this),RawNode:this.visitRaw.bind(this),ReferenceNode:this.visitReference.bind(this),SelectQueryNode:this.visitSelectQuery.bind(this),SelectionNode:this.visitSelection.bind(this),TableNode:this.visitTable.bind(this),FromNode:this.visitFrom.bind(this),SelectAllNode:this.visitSelectAll.bind(this),AndNode:this.visitAnd.bind(this),OrNode:this.visitOr.bind(this),ValueNode:this.visitValue.bind(this),ValueListNode:this.visitValueList.bind(this),PrimitiveValueListNode:this.visitPrimitiveValueList.bind(this),ParensNode:this.visitParens.bind(this),JoinNode:this.visitJoin.bind(this),OperatorNode:this.visitOperator.bind(this),WhereNode:this.visitWhere.bind(this),InsertQueryNode:this.visitInsertQuery.bind(this),DeleteQueryNode:this.visitDeleteQuery.bind(this),ReturningNode:this.visitReturning.bind(this),CreateTableNode:this.visitCreateTable.bind(this),AddColumnNode:this.visitAddColumn.bind(this),ColumnDefinitionNode:this.visitColumnDefinition.bind(this),DropTableNode:this.visitDropTable.bind(this),DataTypeNode:this.visitDataType.bind(this),OrderByNode:this.visitOrderBy.bind(this),OrderByItemNode:this.visitOrderByItem.bind(this),GroupByNode:this.visitGroupBy.bind(this),GroupByItemNode:this.visitGroupByItem.bind(this),UpdateQueryNode:this.visitUpdateQuery.bind(this),ColumnUpdateNode:this.visitColumnUpdate.bind(this),LimitNode:this.visitLimit.bind(this),OffsetNode:this.visitOffset.bind(this),OnConflictNode:this.visitOnConflict.bind(this),OnDuplicateKeyNode:this.visitOnDuplicateKey.bind(this),CreateIndexNode:this.visitCreateIndex.bind(this),DropIndexNode:this.visitDropIndex.bind(this),ListNode:this.visitList.bind(this),PrimaryKeyConstraintNode:this.visitPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.visitUniqueConstraint.bind(this),ReferencesNode:this.visitReferences.bind(this),CheckConstraintNode:this.visitCheckConstraint.bind(this),WithNode:this.visitWith.bind(this),CommonTableExpressionNode:this.visitCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.visitCommonTableExpressionName.bind(this),HavingNode:this.visitHaving.bind(this),CreateSchemaNode:this.visitCreateSchema.bind(this),DropSchemaNode:this.visitDropSchema.bind(this),AlterTableNode:this.visitAlterTable.bind(this),DropColumnNode:this.visitDropColumn.bind(this),RenameColumnNode:this.visitRenameColumn.bind(this),AlterColumnNode:this.visitAlterColumn.bind(this),ModifyColumnNode:this.visitModifyColumn.bind(this),AddConstraintNode:this.visitAddConstraint.bind(this),DropConstraintNode:this.visitDropConstraint.bind(this),RenameConstraintNode:this.visitRenameConstraint.bind(this),ForeignKeyConstraintNode:this.visitForeignKeyConstraint.bind(this),CreateViewNode:this.visitCreateView.bind(this),RefreshMaterializedViewNode:this.visitRefreshMaterializedView.bind(this),DropViewNode:this.visitDropView.bind(this),GeneratedNode:this.visitGenerated.bind(this),DefaultValueNode:this.visitDefaultValue.bind(this),OnNode:this.visitOn.bind(this),ValuesNode:this.visitValues.bind(this),SelectModifierNode:this.visitSelectModifier.bind(this),CreateTypeNode:this.visitCreateType.bind(this),DropTypeNode:this.visitDropType.bind(this),ExplainNode:this.visitExplain.bind(this),DefaultInsertValueNode:this.visitDefaultInsertValue.bind(this),AggregateFunctionNode:this.visitAggregateFunction.bind(this),OverNode:this.visitOver.bind(this),PartitionByNode:this.visitPartitionBy.bind(this),PartitionByItemNode:this.visitPartitionByItem.bind(this),SetOperationNode:this.visitSetOperation.bind(this),BinaryOperationNode:this.visitBinaryOperation.bind(this),UnaryOperationNode:this.visitUnaryOperation.bind(this),UsingNode:this.visitUsing.bind(this),FunctionNode:this.visitFunction.bind(this),CaseNode:this.visitCase.bind(this),WhenNode:this.visitWhen.bind(this),JSONReferenceNode:this.visitJSONReference.bind(this),JSONPathNode:this.visitJSONPath.bind(this),JSONPathLegNode:this.visitJSONPathLeg.bind(this),JSONOperatorChainNode:this.visitJSONOperatorChain.bind(this),TupleNode:this.visitTuple.bind(this),MergeQueryNode:this.visitMergeQuery.bind(this),MatchedNode:this.visitMatched.bind(this),AddIndexNode:this.visitAddIndex.bind(this),CastNode:this.visitCast.bind(this),FetchNode:this.visitFetch.bind(this),TopNode:this.visitTop.bind(this),OutputNode:this.visitOutput.bind(this),OrActionNode:this.visitOrAction.bind(this),CollateNode:this.visitCollate.bind(this)});visitNode=e=>{this.nodeStack.push(e),this.#e[e.kind](e),this.nodeStack.pop()}}const LIT_WRAP_REGEX=/'/g;class DefaultQueryCompiler extends OperationNodeVisitor{#e="";#t=[];get numParameters(){return this.#t.length}compileQuery(e,I){return this.#e="",this.#t=[],this.nodeStack.splice(0,this.nodeStack.length),this.visitNode(e),freeze({query:e,queryId:I,sql:this.getSql(),parameters:[...this.#t]})}getSql(){return this.#e}visitSelectQuery(e){const I=this.parentNode!==void 0&&!ParensNode.is(this.parentNode)&&!InsertQueryNode.is(this.parentNode)&&!CreateTableNode.is(this.parentNode)&&!CreateViewNode.is(this.parentNode)&&!SetOperationNode.is(this.parentNode);this.parentNode===void 0&&e.explain&&(this.visitNode(e.explain),this.append(" ")),I&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("select"),e.distinctOn&&(this.append(" "),this.compileDistinctOn(e.distinctOn)),e.frontModifiers?.length&&(this.append(" "),this.compileList(e.frontModifiers," ")),e.top&&(this.append(" "),this.visitNode(e.top)),e.selections&&(this.append(" "),this.compileList(e.selections)),e.from&&(this.append(" "),this.visitNode(e.from)),e.joins&&(this.append(" "),this.compileList(e.joins," ")),e.where&&(this.append(" "),this.visitNode(e.where)),e.groupBy&&(this.append(" "),this.visitNode(e.groupBy)),e.having&&(this.append(" "),this.visitNode(e.having)),e.setOperations&&(this.append(" "),this.compileList(e.setOperations," ")),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.offset&&(this.append(" "),this.visitNode(e.offset)),e.fetch&&(this.append(" "),this.visitNode(e.fetch)),e.endModifiers?.length&&(this.append(" "),this.compileList(this.sortSelectModifiers([...e.endModifiers])," ")),I&&this.append(")")}visitFrom(e){this.append("from "),this.compileList(e.froms)}visitSelection(e){this.visitNode(e.selection)}visitColumn(e){this.visitNode(e.column)}compileDistinctOn(e){this.append("distinct on ("),this.compileList(e),this.append(")")}compileList(e,I=", "){const B=e.length-1;for(let tr=0;tr<=B;tr++)this.visitNode(e[tr]),tr<B&&this.append(I)}visitWhere(e){this.append("where "),this.visitNode(e.where)}visitHaving(e){this.append("having "),this.visitNode(e.having)}visitInsertQuery(e){const I=this.parentNode!==void 0&&!ParensNode.is(this.parentNode)&&!RawNode.is(this.parentNode)&&!WhenNode.is(this.parentNode);this.parentNode===void 0&&e.explain&&(this.visitNode(e.explain),this.append(" ")),I&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append(e.replace?"replace":"insert"),e.ignore&&(logOnce("`InsertQueryNode.ignore` is deprecated. Use `InsertQueryNode.orAction` instead."),this.append(" ignore")),e.orAction&&(this.append(" "),this.visitNode(e.orAction)),e.top&&(this.append(" "),this.visitNode(e.top)),e.into&&(this.append(" into "),this.visitNode(e.into)),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.output&&(this.append(" "),this.visitNode(e.output)),e.values&&(this.append(" "),this.visitNode(e.values)),e.defaultValues&&(this.append(" "),this.append("default values")),e.onConflict&&(this.append(" "),this.visitNode(e.onConflict)),e.onDuplicateKey&&(this.append(" "),this.visitNode(e.onDuplicateKey)),e.returning&&(this.append(" "),this.visitNode(e.returning)),I&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitValues(e){this.append("values "),this.compileList(e.values)}visitDeleteQuery(e){const I=this.parentNode!==void 0&&!ParensNode.is(this.parentNode)&&!RawNode.is(this.parentNode);this.parentNode===void 0&&e.explain&&(this.visitNode(e.explain),this.append(" ")),I&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("delete "),e.top&&(this.visitNode(e.top),this.append(" ")),this.visitNode(e.from),e.output&&(this.append(" "),this.visitNode(e.output)),e.using&&(this.append(" "),this.visitNode(e.using)),e.joins&&(this.append(" "),this.compileList(e.joins," ")),e.where&&(this.append(" "),this.visitNode(e.where)),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.returning&&(this.append(" "),this.visitNode(e.returning)),I&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitReturning(e){this.append("returning "),this.compileList(e.selections)}visitAlias(e){this.visitNode(e.node),this.append(" as "),this.visitNode(e.alias)}visitReference(e){e.table&&(this.visitNode(e.table),this.append(".")),this.visitNode(e.column)}visitSelectAll(e){this.append("*")}visitIdentifier(e){this.append(this.getLeftIdentifierWrapper()),this.compileUnwrappedIdentifier(e),this.append(this.getRightIdentifierWrapper())}compileUnwrappedIdentifier(e){if(!isString(e.name))throw new Error("a non-string identifier was passed to compileUnwrappedIdentifier.");this.append(this.sanitizeIdentifier(e.name))}visitAnd(e){this.visitNode(e.left),this.append(" and "),this.visitNode(e.right)}visitOr(e){this.visitNode(e.left),this.append(" or "),this.visitNode(e.right)}visitValue(e){e.immediate?this.appendImmediateValue(e.value):this.appendValue(e.value)}visitValueList(e){this.append("("),this.compileList(e.values),this.append(")")}visitTuple(e){this.append("("),this.compileList(e.values),this.append(")")}visitPrimitiveValueList(e){this.append("(");const{values:I}=e;for(let B=0;B<I.length;++B)this.appendValue(I[B]),B!==I.length-1&&this.append(", ");this.append(")")}visitParens(e){this.append("("),this.visitNode(e.node),this.append(")")}visitJoin(e){this.append(JOIN_TYPE_SQL[e.joinType]),this.append(" "),this.visitNode(e.table),e.on&&(this.append(" "),this.visitNode(e.on))}visitOn(e){this.append("on "),this.visitNode(e.on)}visitRaw(e){const{sqlFragments:I,parameters:B}=e;for(let tr=0;tr<I.length;++tr)this.append(I[tr]),B.length>tr&&this.visitNode(B[tr])}visitOperator(e){this.append(e.operator)}visitTable(e){this.visitNode(e.table)}visitSchemableIdentifier(e){e.schema&&(this.visitNode(e.schema),this.append(".")),this.visitNode(e.identifier)}visitCreateTable(e){this.append("create "),e.frontModifiers&&e.frontModifiers.length>0&&(this.compileList(e.frontModifiers," "),this.append(" ")),e.temporary&&this.append("temporary "),this.append("table "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.table),e.selectQuery?(this.append(" as "),this.visitNode(e.selectQuery)):(this.append(" ("),this.compileList([...e.columns,...e.constraints??[]]),this.append(")"),e.onCommit&&(this.append(" on commit "),this.append(e.onCommit)),e.endModifiers&&e.endModifiers.length>0&&(this.append(" "),this.compileList(e.endModifiers," ")))}visitColumnDefinition(e){e.ifNotExists&&this.append("if not exists "),this.visitNode(e.column),this.append(" "),this.visitNode(e.dataType),e.unsigned&&this.append(" unsigned"),e.frontModifiers&&e.frontModifiers.length>0&&(this.append(" "),this.compileList(e.frontModifiers," ")),e.generated&&(this.append(" "),this.visitNode(e.generated)),e.identity&&this.append(" identity"),e.defaultTo&&(this.append(" "),this.visitNode(e.defaultTo)),e.notNull&&this.append(" not null"),e.unique&&this.append(" unique"),e.nullsNotDistinct&&this.append(" nulls not distinct"),e.primaryKey&&this.append(" primary key"),e.autoIncrement&&(this.append(" "),this.append(this.getAutoIncrement())),e.references&&(this.append(" "),this.visitNode(e.references)),e.check&&(this.append(" "),this.visitNode(e.check)),e.endModifiers&&e.endModifiers.length>0&&(this.append(" "),this.compileList(e.endModifiers," "))}getAutoIncrement(){return"auto_increment"}visitReferences(e){this.append("references "),this.visitNode(e.table),this.append(" ("),this.compileList(e.columns),this.append(")"),e.onDelete&&(this.append(" on delete "),this.append(e.onDelete)),e.onUpdate&&(this.append(" on update "),this.append(e.onUpdate))}visitDropTable(e){this.append("drop table "),e.ifExists&&this.append("if exists "),this.visitNode(e.table),e.cascade&&this.append(" cascade")}visitDataType(e){this.append(e.dataType)}visitOrderBy(e){this.append("order by "),this.compileList(e.items)}visitOrderByItem(e){this.visitNode(e.orderBy),e.collation&&(this.append(" "),this.visitNode(e.collation)),e.direction&&(this.append(" "),this.visitNode(e.direction)),e.nulls&&(this.append(" nulls "),this.append(e.nulls))}visitGroupBy(e){this.append("group by "),this.compileList(e.items)}visitGroupByItem(e){this.visitNode(e.groupBy)}visitUpdateQuery(e){const I=this.parentNode!==void 0&&!ParensNode.is(this.parentNode)&&!RawNode.is(this.parentNode)&&!WhenNode.is(this.parentNode);if(this.parentNode===void 0&&e.explain&&(this.visitNode(e.explain),this.append(" ")),I&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("update "),e.top&&(this.visitNode(e.top),this.append(" ")),e.table&&(this.visitNode(e.table),this.append(" ")),this.append("set "),e.updates&&this.compileList(e.updates),e.output&&(this.append(" "),this.visitNode(e.output)),e.from&&(this.append(" "),this.visitNode(e.from)),e.joins){if(!e.from)throw new Error("Joins in an update query are only supported as a part of a PostgreSQL 'update set from join' query. If you want to create a MySQL 'update join set' query, see https://kysely.dev/docs/examples/update/my-sql-joins");this.append(" "),this.compileList(e.joins," ")}e.where&&(this.append(" "),this.visitNode(e.where)),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.returning&&(this.append(" "),this.visitNode(e.returning)),I&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitColumnUpdate(e){this.visitNode(e.column),this.append(" = "),this.visitNode(e.value)}visitLimit(e){this.append("limit "),this.visitNode(e.limit)}visitOffset(e){this.append("offset "),this.visitNode(e.offset)}visitOnConflict(e){this.append("on conflict"),e.columns?(this.append(" ("),this.compileList(e.columns),this.append(")")):e.constraint?(this.append(" on constraint "),this.visitNode(e.constraint)):e.indexExpression&&(this.append(" ("),this.visitNode(e.indexExpression),this.append(")")),e.indexWhere&&(this.append(" "),this.visitNode(e.indexWhere)),e.doNothing===!0?this.append(" do nothing"):e.updates&&(this.append(" do update set "),this.compileList(e.updates),e.updateWhere&&(this.append(" "),this.visitNode(e.updateWhere)))}visitOnDuplicateKey(e){this.append("on duplicate key update "),this.compileList(e.updates)}visitCreateIndex(e){this.append("create "),e.unique&&this.append("unique "),this.append("index "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.name),e.table&&(this.append(" on "),this.visitNode(e.table)),e.using&&(this.append(" using "),this.visitNode(e.using)),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.nullsNotDistinct&&this.append(" nulls not distinct"),e.where&&(this.append(" "),this.visitNode(e.where))}visitDropIndex(e){this.append("drop index "),e.ifExists&&this.append("if exists "),this.visitNode(e.name),e.table&&(this.append(" on "),this.visitNode(e.table)),e.cascade&&this.append(" cascade")}visitCreateSchema(e){this.append("create schema "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.schema)}visitDropSchema(e){this.append("drop schema "),e.ifExists&&this.append("if exists "),this.visitNode(e.schema),e.cascade&&this.append(" cascade")}visitPrimaryKeyConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("primary key ("),this.compileList(e.columns),this.append(")"),this.buildDeferrable(e)}buildDeferrable(e){e.deferrable!==void 0&&(e.deferrable?this.append(" deferrable"):this.append(" not deferrable")),e.initiallyDeferred!==void 0&&(e.initiallyDeferred?this.append(" initially deferred"):this.append(" initially immediate"))}visitUniqueConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("unique"),e.nullsNotDistinct&&this.append(" nulls not distinct"),this.append(" ("),this.compileList(e.columns),this.append(")"),this.buildDeferrable(e)}visitCheckConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("check ("),this.visitNode(e.expression),this.append(")")}visitForeignKeyConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("foreign key ("),this.compileList(e.columns),this.append(") "),this.visitNode(e.references),e.onDelete&&(this.append(" on delete "),this.append(e.onDelete)),e.onUpdate&&(this.append(" on update "),this.append(e.onUpdate)),this.buildDeferrable(e)}visitList(e){this.compileList(e.items)}visitWith(e){this.append("with "),e.recursive&&this.append("recursive "),this.compileList(e.expressions)}visitCommonTableExpression(e){this.visitNode(e.name),this.append(" as "),isBoolean(e.materialized)&&(e.materialized||this.append("not "),this.append("materialized ")),this.visitNode(e.expression)}visitCommonTableExpressionName(e){this.visitNode(e.table),e.columns&&(this.append("("),this.compileList(e.columns),this.append(")"))}visitAlterTable(e){this.append("alter table "),this.visitNode(e.table),this.append(" "),e.renameTo&&(this.append("rename to "),this.visitNode(e.renameTo)),e.setSchema&&(this.append("set schema "),this.visitNode(e.setSchema)),e.addConstraint&&this.visitNode(e.addConstraint),e.dropConstraint&&this.visitNode(e.dropConstraint),e.renameConstraint&&this.visitNode(e.renameConstraint),e.columnAlterations&&this.compileColumnAlterations(e.columnAlterations),e.addIndex&&this.visitNode(e.addIndex),e.dropIndex&&this.visitNode(e.dropIndex)}visitAddColumn(e){this.append("add column "),this.visitNode(e.column)}visitRenameColumn(e){this.append("rename column "),this.visitNode(e.column),this.append(" to "),this.visitNode(e.renameTo)}visitDropColumn(e){this.append("drop column "),this.visitNode(e.column)}visitAlterColumn(e){this.append("alter column "),this.visitNode(e.column),this.append(" "),e.dataType&&(this.announcesNewColumnDataType()&&this.append("type "),this.visitNode(e.dataType),e.dataTypeExpression&&(this.append("using "),this.visitNode(e.dataTypeExpression))),e.setDefault&&(this.append("set default "),this.visitNode(e.setDefault)),e.dropDefault&&this.append("drop default"),e.setNotNull&&this.append("set not null"),e.dropNotNull&&this.append("drop not null")}visitModifyColumn(e){this.append("modify column "),this.visitNode(e.column)}visitAddConstraint(e){this.append("add "),this.visitNode(e.constraint)}visitDropConstraint(e){this.append("drop constraint "),e.ifExists&&this.append("if exists "),this.visitNode(e.constraintName),e.modifier==="cascade"?this.append(" cascade"):e.modifier==="restrict"&&this.append(" restrict")}visitRenameConstraint(e){this.append("rename constraint "),this.visitNode(e.oldName),this.append(" to "),this.visitNode(e.newName)}visitSetOperation(e){this.append(e.operator),this.append(" "),e.all&&this.append("all "),this.visitNode(e.expression)}visitCreateView(e){this.append("create "),e.orReplace&&this.append("or replace "),e.materialized&&this.append("materialized "),e.temporary&&this.append("temporary "),this.append("view "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.name),this.append(" "),e.columns&&(this.append("("),this.compileList(e.columns),this.append(") ")),e.as&&(this.append("as "),this.visitNode(e.as))}visitRefreshMaterializedView(e){this.append("refresh materialized view "),e.concurrently&&this.append("concurrently "),this.visitNode(e.name),e.withNoData?this.append(" with no data"):this.append(" with data")}visitDropView(e){this.append("drop "),e.materialized&&this.append("materialized "),this.append("view "),e.ifExists&&this.append("if exists "),this.visitNode(e.name),e.cascade&&this.append(" cascade")}visitGenerated(e){this.append("generated "),e.always&&this.append("always "),e.byDefault&&this.append("by default "),this.append("as "),e.identity&&this.append("identity"),e.expression&&(this.append("("),this.visitNode(e.expression),this.append(")")),e.stored&&this.append(" stored")}visitDefaultValue(e){this.append("default "),this.visitNode(e.defaultValue)}visitSelectModifier(e){e.rawModifier?this.visitNode(e.rawModifier):this.append(SELECT_MODIFIER_SQL[e.modifier]),e.of&&(this.append(" of "),this.compileList(e.of,", "))}visitCreateType(e){this.append("create type "),this.visitNode(e.name),e.enum&&(this.append(" as enum "),this.visitNode(e.enum))}visitDropType(e){this.append("drop type "),e.ifExists&&this.append("if exists "),this.visitNode(e.name)}visitExplain(e){this.append("explain"),(e.options||e.format)&&(this.append(" "),this.append(this.getLeftExplainOptionsWrapper()),e.options&&(this.visitNode(e.options),e.format&&this.append(this.getExplainOptionsDelimiter())),e.format&&(this.append("format"),this.append(this.getExplainOptionAssignment()),this.append(e.format)),this.append(this.getRightExplainOptionsWrapper()))}visitDefaultInsertValue(e){this.append("default")}visitAggregateFunction(e){this.append(e.func),this.append("("),e.distinct&&this.append("distinct "),this.compileList(e.aggregated),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),this.append(")"),e.withinGroup&&(this.append(" within group ("),this.visitNode(e.withinGroup),this.append(")")),e.filter&&(this.append(" filter("),this.visitNode(e.filter),this.append(")")),e.over&&(this.append(" "),this.visitNode(e.over))}visitOver(e){this.append("over("),e.partitionBy&&(this.visitNode(e.partitionBy),e.orderBy&&this.append(" ")),e.orderBy&&this.visitNode(e.orderBy),this.append(")")}visitPartitionBy(e){this.append("partition by "),this.compileList(e.items)}visitPartitionByItem(e){this.visitNode(e.partitionBy)}visitBinaryOperation(e){this.visitNode(e.leftOperand),this.append(" "),this.visitNode(e.operator),this.append(" "),this.visitNode(e.rightOperand)}visitUnaryOperation(e){this.visitNode(e.operator),this.isMinusOperator(e.operator)||this.append(" "),this.visitNode(e.operand)}isMinusOperator(e){return OperatorNode.is(e)&&e.operator==="-"}visitUsing(e){this.append("using "),this.compileList(e.tables)}visitFunction(e){this.append(e.func),this.append("("),this.compileList(e.arguments),this.append(")")}visitCase(e){this.append("case"),e.value&&(this.append(" "),this.visitNode(e.value)),e.when&&(this.append(" "),this.compileList(e.when," ")),e.else&&(this.append(" else "),this.visitNode(e.else)),this.append(" end"),e.isStatement&&this.append(" case")}visitWhen(e){this.append("when "),this.visitNode(e.condition),e.result&&(this.append(" then "),this.visitNode(e.result))}visitJSONReference(e){this.visitNode(e.reference),this.visitNode(e.traversal)}visitJSONPath(e){e.inOperator&&this.visitNode(e.inOperator),this.append("'$");for(const I of e.pathLegs)this.visitNode(I);this.append("'")}visitJSONPathLeg(e){const I=e.type==="ArrayLocation";this.append(I?"[":"."),this.append(String(e.value)),I&&this.append("]")}visitJSONOperatorChain(e){for(let I=0,B=e.values.length;I<B;I++)I===B-1?this.visitNode(e.operator):this.append("->"),this.visitNode(e.values[I])}visitMergeQuery(e){e.with&&(this.visitNode(e.with),this.append(" ")),this.append("merge "),e.top&&(this.visitNode(e.top),this.append(" ")),this.append("into "),this.visitNode(e.into),e.using&&(this.append(" "),this.visitNode(e.using)),e.whens&&(this.append(" "),this.compileList(e.whens," ")),e.returning&&(this.append(" "),this.visitNode(e.returning)),e.output&&(this.append(" "),this.visitNode(e.output)),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitMatched(e){e.not&&this.append("not "),this.append("matched"),e.bySource&&this.append(" by source")}visitAddIndex(e){this.append("add "),e.unique&&this.append("unique "),this.append("index "),this.visitNode(e.name),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.using&&(this.append(" using "),this.visitNode(e.using))}visitCast(e){this.append("cast("),this.visitNode(e.expression),this.append(" as "),this.visitNode(e.dataType),this.append(")")}visitFetch(e){this.append("fetch next "),this.visitNode(e.rowCount),this.append(` rows ${e.modifier}`)}visitOutput(e){this.append("output "),this.compileList(e.selections)}visitTop(e){this.append(`top(${e.expression})`),e.modifiers&&this.append(` ${e.modifiers}`)}visitOrAction(e){this.append(e.action)}visitCollate(e){this.append("collate "),this.visitNode(e.collation)}append(e){this.#e+=e}appendValue(e){this.addParameter(e),this.append(this.getCurrentParameterPlaceholder())}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getCurrentParameterPlaceholder(){return"$"+this.numParameters}getLeftExplainOptionsWrapper(){return"("}getExplainOptionAssignment(){return" "}getExplainOptionsDelimiter(){return", "}getRightExplainOptionsWrapper(){return")"}sanitizeIdentifier(e){const I=this.getLeftIdentifierWrapper(),B=this.getRightIdentifierWrapper();let tr="";for(const rr of e)tr+=rr,rr===I?tr+=I:rr===B&&(tr+=B);return tr}sanitizeStringLiteral(e){return e.replace(LIT_WRAP_REGEX,"''")}addParameter(e){this.#t.push(e)}appendImmediateValue(e){if(isString(e))this.appendStringLiteral(e);else if(isNumber(e)||isBoolean(e)||isBigInt(e))this.append(e.toString());else if(isNull(e))this.append("null");else if(isDate(e))this.appendImmediateValue(e.toISOString());else throw new Error(`invalid immediate value ${e}`)}appendStringLiteral(e){this.append("'"),this.append(this.sanitizeStringLiteral(e)),this.append("'")}sortSelectModifiers(e){return e.sort((I,B)=>I.modifier&&B.modifier?SELECT_MODIFIER_PRIORITY[I.modifier]-SELECT_MODIFIER_PRIORITY[B.modifier]:1),freeze(e)}compileColumnAlterations(e){this.compileList(e)}announcesNewColumnDataType(){return!0}}const SELECT_MODIFIER_SQL=freeze({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),SELECT_MODIFIER_PRIORITY=freeze({ForKeyShare:1,ForNoKeyUpdate:1,ForUpdate:1,ForShare:1,NoWait:2,SkipLocked:2,Distinct:0}),JOIN_TYPE_SQL=freeze({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",CrossJoin:"cross join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral",LateralCrossJoin:"cross join lateral",OuterApply:"outer apply",CrossApply:"cross apply",Using:"using"}),CompiledQuery=freeze({raw(t,e=[]){return freeze({sql:t,query:RawNode.createWithSql(t),parameters:freeze(e),queryId:createQueryId()})}});class DialectAdapterBase{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!1}get supportsOutput(){return!1}}class NoopPlugin{transformQuery(e){return e.node}async transformResult(e){return e.result}}const DEFAULT_MIGRATION_TABLE="kysely_migration",DEFAULT_MIGRATION_LOCK_TABLE="kysely_migration_lock",DEFAULT_ALLOW_UNORDERED_MIGRATIONS=!1,MIGRATION_LOCK_ID="migration_lock";freeze({__noMigrations__:!0});class Migrator{#e;constructor(e){this.#e=freeze(e)}async getMigrations(){const e=await this.#u(this.#n)?await this.#e.db.withPlugin(this.#s).selectFrom(this.#n).select(["name","timestamp"]).$narrowType().execute():[];return(await this.#_()).map(({name:B,...tr})=>{const rr=e.find(ir=>ir.name===B);return{name:B,migration:tr,executedAt:rr?new Date(rr.timestamp):void 0}})}async migrateToLatest(){return this.#t(()=>({direction:"Up",step:1/0}))}async migrateTo(e){return this.#t(({migrations:I,executedMigrations:B,pendingMigrations:tr})=>{if(isObject(e)&&e.__noMigrations__===!0)return{direction:"Down",step:1/0};if(!I.find(lr=>lr.name===e))throw new Error(`migration "${e}" doesn't exist`);const rr=B.indexOf(e),ir=tr.findIndex(lr=>lr.name===e);if(rr!==-1)return{direction:"Down",step:B.length-rr-1};if(ir!==-1)return{direction:"Up",step:ir+1};throw new Error(`migration "${e}" isn't executed or pending`)})}async migrateUp(){return this.#t(()=>({direction:"Up",step:1}))}async migrateDown(){return this.#t(()=>({direction:"Down",step:1}))}async#t(e){try{return await this.#i(),await this.#g(e)}catch(I){return I instanceof MigrationResultSetError?I.resultSet:{error:I}}}get#r(){return this.#e.migrationTableSchema}get#n(){return this.#e.migrationTableName??DEFAULT_MIGRATION_TABLE}get#o(){return this.#e.migrationLockTableName??DEFAULT_MIGRATION_LOCK_TABLE}get#l(){return this.#e.allowUnorderedMigrations??DEFAULT_ALLOW_UNORDERED_MIGRATIONS}get#s(){return this.#r?new WithSchemaPlugin(this.#r):new NoopPlugin}async#i(){await this.#a(),await this.#d(),await this.#c(),await this.#h()}async#a(){if(this.#r&&!await this.#p())try{await this.#m(this.#e.db.schema.createSchema(this.#r))}catch(e){if(!await this.#p())throw e}}async#d(){if(!await this.#u(this.#n))try{this.#r&&await this.#m(this.#e.db.schema.createSchema(this.#r)),await this.#m(this.#e.db.schema.withPlugin(this.#s).createTable(this.#n).addColumn("name","varchar(255)",e=>e.notNull().primaryKey()).addColumn("timestamp","varchar(255)",e=>e.notNull()))}catch(e){if(!await this.#u(this.#n))throw e}}async#c(){if(!await this.#u(this.#o))try{await this.#m(this.#e.db.schema.withPlugin(this.#s).createTable(this.#o).addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("is_locked","integer",e=>e.notNull().defaultTo(0)))}catch(e){if(!await this.#u(this.#o))throw e}}async#h(){if(!await this.#f())try{await this.#e.db.withPlugin(this.#s).insertInto(this.#o).values({id:MIGRATION_LOCK_ID,is_locked:0}).execute()}catch(e){if(!await this.#f())throw e}}async#p(){return(await this.#e.db.introspection.getSchemas()).some(I=>I.name===this.#r)}async#u(e){const I=this.#r;return(await this.#e.db.introspection.getTables({withInternalKyselyTables:!0})).some(tr=>tr.name===e&&(!I||tr.schema===I))}async#f(){return!!await this.#e.db.withPlugin(this.#s).selectFrom(this.#o).where("id","=",MIGRATION_LOCK_ID).select("id").executeTakeFirst()}async#g(e){const I=this.#e.db.getExecutor().adapter,B=freeze({lockTable:this.#e.migrationLockTableName??DEFAULT_MIGRATION_LOCK_TABLE,lockRowId:MIGRATION_LOCK_ID,lockTableSchema:this.#e.migrationTableSchema}),tr=async rr=>{try{await I.acquireMigrationLock(rr,B);const ir=await this.#w(rr);if(ir.migrations.length===0)return{results:[]};const{direction:lr,step:dr}=e(ir);return dr<=0?{results:[]}:lr==="Down"?await this.#S(rr,ir,dr):lr==="Up"?await this.#M(rr,ir,dr):{results:[]}}finally{await I.releaseMigrationLock(rr,B)}};return I.supportsTransactionalDdl&&!this.#e.disableTransactions?this.#e.db.transaction().execute(tr):this.#e.db.connection().execute(tr)}async#w(e){const I=await this.#_(),B=await this.#E(e);this.#b(I,B),this.#l||this.#x(I,B);const tr=this.#y(I,B);return freeze({migrations:I,executedMigrations:B,lastMigration:getLast(B),pendingMigrations:tr})}#y(e,I){return e.filter(B=>!I.includes(B.name))}async#_(){const e=await this.#e.provider.getMigrations();return Object.keys(e).sort().map(I=>({...e[I],name:I}))}async#E(e){const I=await e.withPlugin(this.#s).selectFrom(this.#n).select(["name","timestamp"]).$narrowType().execute(),B=this.#e.nameComparator||((tr,rr)=>tr.localeCompare(rr));return I.sort((tr,rr)=>tr.timestamp===rr.timestamp?B(tr.name,rr.name):new Date(tr.timestamp).getTime()-new Date(rr.timestamp).getTime()).map(tr=>tr.name)}#b(e,I){for(const B of I)if(!e.some(tr=>tr.name===B))throw new Error(`corrupted migrations: previously executed migration ${B} is missing`)}#x(e,I){for(let B=0;B<I.length;++B)if(e[B].name!==I[B])throw new Error(`corrupted migrations: expected previously executed migration ${I[B]} to be at index ${B} but ${e[B].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`)}async#S(e,I,B){const tr=I.executedMigrations.slice().reverse().slice(0,B).map(ir=>I.migrations.find(lr=>lr.name===ir)),rr=tr.map(ir=>({migrationName:ir.name,direction:"Down",status:"NotExecuted"}));for(let ir=0;ir<rr.length;++ir){const lr=tr[ir];try{lr.down&&(await lr.down(e),await e.withPlugin(this.#s).deleteFrom(this.#n).where("name","=",lr.name).execute(),rr[ir]={migrationName:lr.name,direction:"Down",status:"Success"})}catch(dr){throw rr[ir]={migrationName:lr.name,direction:"Down",status:"Error"},new MigrationResultSetError({error:dr,results:rr})}}return{results:rr}}async#M(e,I,B){const rr=I.pendingMigrations.slice(0,B).map(ir=>({migrationName:ir.name,direction:"Up",status:"NotExecuted"}));for(let ir=0;ir<rr.length;ir++){const lr=I.pendingMigrations[ir];try{await lr.up(e),await e.withPlugin(this.#s).insertInto(this.#n).values({name:lr.name,timestamp:new Date().toISOString()}).execute(),rr[ir]={migrationName:lr.name,direction:"Up",status:"Success"}}catch(dr){throw rr[ir]={migrationName:lr.name,direction:"Up",status:"Error"},new MigrationResultSetError({error:dr,results:rr})}}return{results:rr}}async#m(e){this.#e.db.getExecutor().adapter.supportsCreateIfNotExists&&(e=e.ifNotExists()),await e.execute()}}class MigrationResultSetError extends Error{#e;constructor(e){super(),this.#e=e}get resultSet(){return this.#e}}const ID_WRAP_REGEX=/"/g;class PostgresQueryCompiler extends DefaultQueryCompiler{sanitizeIdentifier(e){return e.replace(ID_WRAP_REGEX,'""')}}class PostgresIntrospector{#e;constructor(e){this.#e=e}async getSchemas(){return(await this.#e.selectFrom("pg_catalog.pg_namespace").select("nspname").$castTo().execute()).map(I=>({name:I.nspname}))}async getTables(e={withInternalKyselyTables:!1}){let I=this.#e.selectFrom("pg_catalog.pg_attribute as a").innerJoin("pg_catalog.pg_class as c","a.attrelid","c.oid").innerJoin("pg_catalog.pg_namespace as ns","c.relnamespace","ns.oid").innerJoin("pg_catalog.pg_type as typ","a.atttypid","typ.oid").innerJoin("pg_catalog.pg_namespace as dtns","typ.typnamespace","dtns.oid").select(["a.attname as column","a.attnotnull as not_null","a.atthasdef as has_default","c.relname as table","c.relkind as table_type","ns.nspname as schema","typ.typname as type","dtns.nspname as type_schema",sql`col_description(a.attrelid, a.attnum)`.as("column_description"),sql`pg_get_serial_sequence(quote_ident(ns.nspname) || '.' || quote_ident(c.relname), a.attname)`.as("auto_incrementing")]).where("c.relkind","in",["r","v","p"]).where("ns.nspname","!~","^pg_").where("ns.nspname","!=","information_schema").where("ns.nspname","!=","crdb_internal").where(sql`has_schema_privilege(ns.nspname, 'USAGE')`).where("a.attnum",">=",0).where("a.attisdropped","!=",!0).orderBy("ns.nspname").orderBy("c.relname").orderBy("a.attnum").$castTo();e.withInternalKyselyTables||(I=I.where("c.relname","!=",DEFAULT_MIGRATION_TABLE).where("c.relname","!=",DEFAULT_MIGRATION_LOCK_TABLE));const B=await I.execute();return this.#t(B)}async getMetadata(e){return{tables:await this.getTables(e)}}#t(e){return e.reduce((I,B)=>{let tr=I.find(rr=>rr.name===B.table&&rr.schema===B.schema);return tr||(tr=freeze({name:B.table,isView:B.table_type==="v",schema:B.schema,columns:[]}),I.push(tr)),tr.columns.push(freeze({name:B.column,dataType:B.type,dataTypeSchema:B.type_schema,isNullable:!B.not_null,isAutoIncrementing:B.auto_incrementing!==null,hasDefaultValue:B.has_default,comment:B.column_description??void 0})),I},[])}}const LOCK_ID=BigInt("3853314791062309107");class PostgresAdapter extends DialectAdapterBase{get supportsTransactionalDdl(){return!0}get supportsReturning(){return!0}async acquireMigrationLock(e,I){await sql`select pg_advisory_xact_lock(${sql.lit(LOCK_ID)})`.execute(e)}async releaseMigrationLock(e,I){}}class KyselyOperationIndexTxn{collections=[];collectionMemberships=[];collectionRemovals=[];operations=[];createCollection(e){this.collections.push(e)}addToCollection(e,I){const B=this.operations.length-1;if(B<0)throw new Error("addToCollection must be called after write() - no operations in transaction");this.collectionMemberships.push({collectionId:e,documentId:I,operationIndex:B})}removeFromCollection(e,I){const B=this.operations.length-1;if(B<0)throw new Error("removeFromCollection must be called after write() - no operations in transaction");this.collectionRemovals.push({collectionId:e,documentId:I,operationIndex:B})}write(e){this.operations.push(...e)}getCollections(){return this.collections}getCollectionMemberships(){return this.collectionMemberships}getCollectionRemovals(){return this.collectionRemovals}getOperations(){return this.operations}}class KyselyOperationIndex{db;constructor(e){this.db=e}start(){return new KyselyOperationIndexTxn}async commit(e,I){if(I?.aborted)throw new Error("Operation aborted");const B=e,tr=B.getCollections(),rr=B.getCollectionMemberships(),ir=B.getCollectionRemovals(),lr=B.getOperations();let dr=[];return await this.db.transaction().execute(async mr=>{if(tr.length>0){const fr=tr.map(_r=>({documentId:_r,collectionId:_r,joinedOrdinal:BigInt(0),leftOrdinal:null}));await mr.insertInto("document_collections").values(fr).onConflict(_r=>_r.doNothing()).execute()}let hr=[];if(lr.length>0){const fr=lr.map(wr=>{const gr=wr.timestampUtcMs;let xr;return/^\d+$/.test(gr)?xr=Number(gr):xr=new Date(gr).getTime(),{opId:wr.id||"",documentId:wr.documentId,documentType:wr.documentType,scope:wr.scope,branch:wr.branch,timestampUtcMs:BigInt(xr||0),index:wr.index,skip:wr.skip,hash:wr.hash,action:wr.action}});hr=(await mr.insertInto("operation_index_operations").values(fr).returning("ordinal").execute()).map(wr=>wr.ordinal),dr=hr}if(rr.length>0)for(const fr of rr){const _r=hr[fr.operationIndex];await mr.insertInto("document_collections").values({documentId:fr.documentId,collectionId:fr.collectionId,joinedOrdinal:BigInt(_r),leftOrdinal:null}).onConflict(wr=>wr.columns(["documentId","collectionId"]).doUpdateSet({joinedOrdinal:BigInt(_r),leftOrdinal:null})).execute()}if(ir.length>0)for(const fr of ir){const _r=hr[fr.operationIndex];await mr.updateTable("document_collections").set({leftOrdinal:BigInt(_r)}).where("collectionId","=",fr.collectionId).where("documentId","=",fr.documentId).where("leftOrdinal","is",null).execute()}}),dr}async find(e,I,B,tr,rr){if(rr?.aborted)throw new Error("Operation aborted");let ir=this.db.selectFrom("operation_index_operations as oi").innerJoin("document_collections as dc","oi.documentId","dc.documentId").selectAll("oi").select(["dc.documentId","dc.collectionId"]).where("dc.collectionId","=",e).whereRef("oi.ordinal",">=","dc.joinedOrdinal").where(sql`dc."leftOrdinal" IS NULL OR oi.ordinal < dc."leftOrdinal"`).orderBy("oi.ordinal","asc");if(I!==void 0&&(ir=ir.where("oi.ordinal",">",I)),B?.branch&&(ir=ir.where("oi.branch","=",B.branch)),B?.scopes&&B.scopes.length>0&&(ir=ir.where("oi.scope","in",B.scopes)),tr?.cursor){const fr=Number.parseInt(tr.cursor,10);ir=ir.where("oi.ordinal",">",fr)}tr?.limit&&(ir=ir.limit(tr.limit+1));const lr=await ir.execute();let dr=!1,mr=lr;tr?.limit&&lr.length>tr.limit&&(dr=!0,mr=lr.slice(0,tr.limit));const hr=dr&&mr.length>0?mr[mr.length-1].ordinal.toString():void 0;return{items:mr.map(fr=>this.rowToOperationIndexEntry(fr)),nextCursor:hr,hasMore:dr}}async getSinceOrdinal(e,I,B){if(B?.aborted)throw new Error("Operation aborted");let tr=this.db.selectFrom("operation_index_operations").selectAll().where("ordinal",">",e).orderBy("ordinal","asc");if(I?.cursor){const mr=Number.parseInt(I.cursor,10);tr=tr.where("ordinal",">",mr)}I?.limit&&(tr=tr.limit(I.limit+1));const rr=await tr.execute();let ir=!1,lr=rr;I?.limit&&rr.length>I.limit&&(ir=!0,lr=rr.slice(0,I.limit));const dr=ir&&lr.length>0?lr[lr.length-1].ordinal.toString():void 0;return{items:lr.map(mr=>this.rowToOperationWithContext(mr)),nextCursor:dr,hasMore:ir}}rowToOperationWithContext(e){return{operation:{index:e.index,timestampUtcMs:e.timestampUtcMs.toString(),hash:e.hash,skip:e.skip,action:e.action,id:e.opId},context:{documentId:e.documentId,documentType:e.documentType,scope:e.scope,branch:e.branch,ordinal:e.ordinal}}}rowToOperationIndexEntry(e){return{ordinal:e.ordinal,documentId:e.documentId,documentType:e.documentType,branch:e.branch,scope:e.scope,index:e.index,timestampUtcMs:e.timestampUtcMs.toString(),hash:e.hash,skip:e.skip,action:e.action,id:e.opId}}}class RingBuffer{buffer;head=0;size=0;capacity;constructor(e){if(e<=0)throw new Error("Ring buffer capacity must be greater than 0");this.capacity=e,this.buffer=new Array(e)}push(e){const I=(this.head+this.size)%this.capacity;this.size<this.capacity?(this.buffer[I]=e,this.size++):(this.buffer[this.head]=e,this.head=(this.head+1)%this.capacity)}getAll(){if(this.size===0)return[];const e=[];for(let I=0;I<this.size;I++){const B=(this.head+I)%this.capacity;e.push(this.buffer[B])}return e}clear(){this.buffer=new Array(this.capacity),this.head=0,this.size=0}get length(){return this.size}}class KyselyWriteCache{streams;lruTracker;keyframeStore;operationStore;registry;config;constructor(e,I,B,tr){this.keyframeStore=e,this.operationStore=I,this.registry=B,this.config={maxDocuments:tr.maxDocuments,ringBufferSize:tr.ringBufferSize,keyframeInterval:tr.keyframeInterval},this.streams=new Map,this.lruTracker=new LRUTracker}async startup(){return Promise.resolve()}async shutdown(){return Promise.resolve()}async getState(e,I,B,tr,rr){if(rr?.aborted)throw new Error("Operation aborted");const ir=this.makeStreamKey(e,I,B),lr=this.streams.get(ir);if(lr){const hr=lr.ringBuffer.getAll();if(tr===void 0){if(hr.length>0){const fr=hr[hr.length-1];return this.lruTracker.touch(ir),fr.document}}else{const fr=hr.find(wr=>wr.revision===tr);if(fr)return this.lruTracker.touch(ir),fr.document;const _r=this.findNearestOlderSnapshot(hr,tr);if(_r){const wr=await this.warmMissRebuild(_r.document,_r.revision,e,I,B,tr,rr);return this.putState(e,I,B,tr,wr),this.lruTracker.touch(ir),wr}}}const dr=await this.coldMissRebuild(e,I,B,tr,rr);let mr=tr;return mr===void 0&&(mr=dr.header.revision[I]||0),this.putState(e,I,B,mr,dr),dr}putState(e,I,B,tr,rr){const ir=this.makeStreamKey(e,I,B),lr=this.getOrCreateStream(ir),dr={revision:tr,document:rr};lr.ringBuffer.push(dr),this.isKeyframeRevision(tr)&&this.keyframeStore.putKeyframe(e,I,B,tr,rr).catch(mr=>{console.error(`Failed to persist keyframe ${e}@${tr}:`,mr)})}invalidate(e,I,B){let tr=0;if(I===void 0&&B===void 0)for(const[rr]of this.streams.entries())rr.startsWith(`${e}:`)&&(this.streams.delete(rr),this.lruTracker.remove(rr),tr++);else if(I!==void 0&&B===void 0)for(const[rr]of this.streams.entries())rr.startsWith(`${e}:${I}:`)&&(this.streams.delete(rr),this.lruTracker.remove(rr),tr++);else if(I!==void 0&&B!==void 0){const rr=this.makeStreamKey(e,I,B);this.streams.has(rr)&&(this.streams.delete(rr),this.lruTracker.remove(rr),tr=1)}return tr}clear(){this.streams.clear(),this.lruTracker.clear()}getStream(e,I,B){const tr=this.makeStreamKey(e,I,B);return this.streams.get(tr)}async findNearestKeyframe(e,I,B,tr,rr){if(!(tr===Number.MAX_SAFE_INTEGER||tr<=0))return this.keyframeStore.findNearestKeyframe(e,I,B,tr,rr)}async coldMissRebuild(e,I,B,tr,rr){const ir=tr||Number.MAX_SAFE_INTEGER,lr=await this.findNearestKeyframe(e,I,B,ir,rr);let dr,mr,hr;if(lr)dr=lr.document,mr=lr.revision,hr=lr.document.header.documentType;else{dr=void 0,mr=0;const Mr=await this.operationStore.getSince(e,"document",B,-1,{limit:1},rr);if(Mr.items.length===0)throw new Error(`Failed to rebuild document ${e}: no CREATE_DOCUMENT operation found in document scope`);const Sr=Mr.items[0];if(Sr.action.type!=="CREATE_DOCUMENT")throw new Error(`Failed to rebuild document ${e}: first operation in document scope must be CREATE_DOCUMENT, found ${Sr.action.type}`);const yr=Sr.action;if(hr=yr.input.model,!hr)throw new Error(`Failed to rebuild document ${e}: CREATE_DOCUMENT action missing model in input`);dr=createDocumentFromAction(yr);const br=this.registry.getModule(hr),vr=await this.operationStore.getSince(e,"document",B,0,void 0,rr);for(const Cr of vr.items)Cr.index!==0&&(Cr.action.type==="UPGRADE_DOCUMENT"?applyUpgradeDocumentAction(dr,Cr.action):Cr.action.type==="DELETE_DOCUMENT"?applyDeleteDocumentAction(dr,Cr.action):dr=br.reducer(dr,Cr.action))}const fr=this.registry.getModule(hr);let _r;const wr=100;let gr;do{if(rr?.aborted)throw new Error("Operation aborted");const Mr=_r?{cursor:_r,pageSize:wr}:{pageSize:wr};try{const Sr=await this.operationStore.getSince(e,I,B,mr,Mr,rr);for(const br of Sr.items){if(tr!==void 0&&br.index>tr)break;dr=fr.reducer(dr,br.action)}const yr=tr!==void 0&&Sr.items.some(br=>br.index>=tr);gr=!!Sr.nextCursor&&!yr,gr&&(_r=Sr.nextCursor)}catch(Sr){throw new Error(`Failed to rebuild document ${e}: ${Sr instanceof Error?Sr.message:String(Sr)}`)}}while(gr);const xr=await this.operationStore.getRevisions(e,B,rr);return dr.header.revision=xr.revision,dr.header.lastModifiedAtUtcIso=xr.latestTimestamp,dr}async warmMissRebuild(e,I,B,tr,rr,ir,lr){const dr=e.header.documentType,mr=this.registry.getModule(dr);let hr=e;try{const _r=await this.operationStore.getSince(B,tr,rr,I,void 0,lr);for(const wr of _r.items){if(lr?.aborted)throw new Error("Operation aborted");if(ir!==void 0&&wr.index>ir||(hr=mr.reducer(hr,wr.action),ir!==void 0&&wr.index===ir))break}}catch(_r){throw new Error(`Failed to rebuild document ${B}: ${_r instanceof Error?_r.message:String(_r)}`)}const fr=await this.operationStore.getRevisions(B,rr,lr);return hr.header.revision=fr.revision,hr.header.lastModifiedAtUtcIso=fr.latestTimestamp,hr}findNearestOlderSnapshot(e,I){let B;for(const tr of e)tr.revision<I&&(!B||tr.revision>B.revision)&&(B=tr);return B}makeStreamKey(e,I,B){return`${e}:${I}:${B}`}getOrCreateStream(e){let I=this.streams.get(e);if(!I){if(this.streams.size>=this.config.maxDocuments){const B=this.lruTracker.evict();B&&this.streams.delete(B)}I={key:e,ringBuffer:new RingBuffer(this.config.ringBufferSize)},this.streams.set(e,I)}return this.lruTracker.touch(e),I}isKeyframeRevision(e){return e>0&&e%this.config.keyframeInterval===0}}class EventBus{eventTypeToSubscribers=new Map;subscribe(e,I){let B=this.eventTypeToSubscribers.get(e);B||(B=[],this.eventTypeToSubscribers.set(e,B)),B.push(I);let tr=!1;return()=>{if(tr)return;tr=!0;const rr=this.eventTypeToSubscribers.get(e);if(!rr)return;const ir=rr.indexOf(I);ir!==-1&&rr.splice(ir,1),rr.length===0&&this.eventTypeToSubscribers.delete(e)}}async emit(e,I){const B=this.eventTypeToSubscribers.get(e);if(!B||B.length===0)return;const tr=B.slice(),rr=[];for(const ir of tr)try{await Promise.resolve(ir(e,I))}catch(lr){rr.push(lr)}if(rr.length>0)throw new EventBusAggregateError(rr)}}var JobQueueState;(function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.PREPROCESSING=0]="PREPROCESSING",t[t.PENDING=1]="PENDING",t[t.READY=2]="READY",t[t.RUNNING=3]="RUNNING",t[t.RESOLVED=4]="RESOLVED"})(JobQueueState||(JobQueueState={}));const QueueEventTypes={JOB_AVAILABLE:1e4};class SimpleJobExecutorManager{executorFactory;eventBus;queue;jobTracker;executors=[];isRunning=!1;activeJobs=0;totalJobsProcessed=0;unsubscribe;constructor(e,I,B,tr){this.executorFactory=e,this.eventBus=I,this.queue=B,this.jobTracker=tr}async start(e){if(this.isRunning)throw new Error("JobExecutorManager is already running");if(e<1)throw new Error("Number of executors must be at least 1");this.executors=[];for(let I=0;I<e;I++)this.executors.push(this.executorFactory());this.unsubscribe=this.eventBus.subscribe(QueueEventTypes.JOB_AVAILABLE,async()=>{this.activeJobs<this.executors.length&&await this.processNextJob()}),this.isRunning=!0,await this.processExistingJobs()}async stop(e=!0){if(this.isRunning){if(this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0),e)for(;this.activeJobs>0;)await new Promise(I=>setTimeout(I,100));this.executors=[],this.isRunning=!1}}getExecutors(){return[...this.executors]}getStatus(){return{isRunning:this.isRunning,numExecutors:this.executors.length,activeJobs:this.activeJobs,totalJobsProcessed:this.totalJobsProcessed}}async processNextJob(){let e;try{e=await this.queue.dequeueNext()}catch(rr){console.error("Error dequeueing job:",rr);return}if(!e)return;e.start(),this.activeJobs++,this.jobTracker.markRunning(e.job.id);const I=this.totalJobsProcessed%this.executors.length,B=this.executors[I];let tr;try{tr=await B.executeJob(e.job)}catch(rr){const ir=this.toErrorInfo(rr instanceof Error?rr:String(rr));console.error(`Error executing job ${e.job.id}:`,ir.message),e.fail(ir),this.activeJobs--,this.jobTracker.markFailed(e.job.id,ir),this.eventBus.emit(OperationEventTypes.JOB_FAILED,{jobId:e.job.id,error:new Error(ir.message)}).catch(()=>{}),await this.checkForMoreJobs();return}if(tr.success)e.complete(),this.totalJobsProcessed++;else{const rr=e.job.retryCount||0,ir=e.job.maxRetries||0;if(rr<ir){const lr=tr.error?this.toErrorInfo(tr.error):this.toErrorInfo("Unknown error");try{await this.queue.retryJob(e.job.id,lr)}catch(dr){const mr=this.toErrorInfo(dr instanceof Error?dr:"Failed to retry job");console.error(`Failed to retry job ${e.job.id}:`,mr.message),this.jobTracker.markFailed(e.job.id,mr),this.eventBus.emit(OperationEventTypes.JOB_FAILED,{jobId:e.job.id,error:new Error(mr.message)}).catch(()=>{}),e.fail(mr)}}else{const lr=tr.error?this.toErrorInfo(tr.error):this.toErrorInfo("Unknown error"),dr=this.formatErrorHistory(e.job.errorHistory,lr,rr+1);console.error(`Job ${e.job.id} failed after ${rr+1} attempts:`,dr.message),this.jobTracker.markFailed(e.job.id,dr),this.eventBus.emit(OperationEventTypes.JOB_FAILED,{jobId:e.job.id,error:new Error(dr.message)}).catch(()=>{}),e.fail(dr)}}this.activeJobs--,await this.checkForMoreJobs()}async checkForMoreJobs(){if(!this.isRunning)return;let e;try{e=await this.queue.hasJobs()}catch(I){console.error("Error checking for more jobs:",I);return}e&&await this.processNextJob()}async processExistingJobs(){let e;try{e=await this.queue.hasJobs()}catch(I){console.error("Error checking for existing jobs:",I);return}if(e){const I=[];for(let B=0;B<Math.min(this.executors.length,5);B++)I.push(this.processNextJob());try{await Promise.all(I)}catch(B){console.error("Error processing existing jobs:",B)}}}toErrorInfo(e){return e instanceof Error?{message:e.message,stack:e.stack||new Error().stack||""}:{message:e,stack:new Error().stack||""}}formatErrorHistory(e,I,B){const tr=[...e,I];if(tr.length===1)return I;const rr=[`Job failed after ${B} attempts:`],ir=[];return tr.forEach((lr,dr)=>{rr.push(`[Attempt ${dr+1}] ${lr.message}`),ir.push(`[Attempt ${dr+1}] Stack trace:
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/nodefs-DwD3CLeV.js","assets/document_model-DB4SzBSe.js","assets/zod-BpTyxkjy.js","assets/react-DQSxOgtG.js","assets/document_drive-BuVpBb4l.js","assets/graphql-BS4Brs_E.js","assets/config-CU-aFfVJ.js","assets/drive_explorer-CRZ83OvJ.js","assets/sentry_react-cODD7zWc.js","assets/sentry_browser-B4YoBIIG.js","assets/document_model_editor-BkDmLrc0.js","assets/react/jsx-runtime-DldvXD6N.js","assets/design_system-CivzDHIq.js","assets/tailwind_merge-Dr4f9Rms.js","assets/react-dom-D6zQJsh6.js","assets/design_system_connect-BRZJ3Vw4.js","assets/design_system_ui-D74NrKvC.js","assets/react-dom/client-BVPiT_FE.js","assets/opfs-ahp-CXiEKQWP.js"])))=>i.map(i=>d[i]);
2
+ import{Y as capitalCase,Z as buildSignedAction,_ as documentModelDocumentType,d as baseSaveToFileHandle,$ as createZip,g as generateId,k as createPresignedHeader,w as replayDocument,e as baseLoadFromInput,a0 as actions,h as defaultBaseState,a1 as validateInitialState,a2 as validateStateSchemaName,a3 as validateModules,j as createState}from"./document_model-DB4SzBSe.js";import{l as logger,d as deleteNode$1,a as addFile$1,i as isFileNode,b as addFolder$1,c as isFolderNode,g as generateNodesCopy,h as handleTargetNameCollisions,e as copyNode$1,m as moveNode$1,u as updateNode,A as AbortError,M as MemoryStorage,R as ReactorBuilder$1,s as setSharingType,f as setAvailableOffline,j as setDriveName,r as removeTrigger$1,P as PullResponderTransmitter,k as addTrigger$1,S as SynchronizationUnitNotFoundError,D as DocumentNotFoundError,n as DocumentModelNotFoundError}from"./document_drive-BuVpBb4l.js";import{_ as __vitePreload}from"./drive_explorer-CRZ83OvJ.js";import{p as process$1,g as getDefaultExportFromCjs,a as getAugmentedNamespace}from"./react-DQSxOgtG.js";import"./document_model_editor-BkDmLrc0.js";import{r as reactExports}from"./sentry_react-cODD7zWc.js";function makePHEventFunctions(t){const e=`ph:set${capitalCase(t)}`,I=`ph:${t}Updated`;function B(hr){const fr=new CustomEvent(e,{detail:{[t]:hr}});window.dispatchEvent(fr)}function tr(){const hr=new CustomEvent(I);window.dispatchEvent(hr)}function rr(hr){const fr=hr.detail[t];if(!window.ph)throw new Error("ph global store is not defined");window.ph[t]=fr,tr()}function ir(){window.addEventListener(e,rr)}function lr(hr){return window.addEventListener(I,hr),()=>{window.removeEventListener(I,hr)}}function dr(){if(!window.ph)throw new Error("ph global store is not defined");return window.ph[t]}function mr(){return reactExports.useSyncExternalStore(lr,dr)}return{useValue:mr,setValue:B,addEventHandler:ir}}const featuresEventFunctions=makePHEventFunctions("features"),useFeatures=featuresEventFunctions.useValue,setFeatures=featuresEventFunctions.setValue,addFeaturesEventHandler=featuresEventFunctions.addEventHandler;function isLegacyReadEnabledSync(){return window.ph?.features?.get("FEATURE_LEGACY_READ_ENABLED")??!0}function isLegacyWriteEnabledSync(){return window.ph?.features?.get("FEATURE_LEGACY_WRITE_ENABLED")??!0}function isChannelSyncEnabledSync(){return window.ph?.features?.get("FEATURE_CHANNEL_SYNC_ENABLED")??!1}function useInspectorEnabled(){return useFeatures()?.get("FEATURE_INSPECTOR_ENABLED")??!1}async function queueActions(t,e){if(!t)throw new Error("No document provided");if(!e)throw new Error("No actions provided");const I=Array.isArray(e)?e:[e];if(I.length===0)throw new Error("No actions provided");if(isLegacyWriteEnabledSync()){const tr=window.ph?.legacyReactor;if(!tr)throw new Error("Legacy reactor not initialized");const rr=await tr.queueActions(t.header.id,I);return rr.status!=="SUCCESS"&&logger.error(rr.error),rr.document}else{const tr=window.ph?.reactorClient;if(!tr)throw new Error("ReactorClient not initialized");return await tr.execute(t.header.id,"main",I)}}async function queueOperations(t,e){if(!t)throw new Error("No documentId provided");if(!e)throw new Error("No operations provided");const I=Array.isArray(e)?e:[e];if(I.length===0)throw new Error("No operations provided");if(isLegacyWriteEnabledSync()){const tr=window.ph?.legacyReactor;if(!tr)throw new Error("Legacy reactor not initialized");const rr=await tr.queueOperations(t,I);return rr.status!=="SUCCESS"&&logger.error(rr.error),rr.document}else{const tr=window.ph?.reactorClient;if(!tr)throw new Error("ReactorClient not initialized");const rr=I.map(ir=>ir.action);return await tr.execute(t,"main",rr)}}async function uploadOperations(t,e,I,B){const tr=B?.operationsLimit||50,rr=B?.onProgress;logger.verbose(`uploadDocumentOperations(documentId:${t}, ops: ${Object.keys(e).join(",")}, limit:${tr})`);const ir=Object.values(e).filter(mr=>mr!==void 0),lr=ir.reduce((mr,hr)=>mr+hr.length,0);let dr=0;for(const mr of ir)for(let hr=0;hr<mr.length;hr+=tr){logger.verbose(`uploadDocumentOperations:for(i:${hr}, ops:${mr.length}, limit:${tr}): START`);const fr=mr.slice(hr,hr+tr),_r=fr.at(-1);if(!_r)break;const wr=_r.action.scope;if(await I(t,fr),dr+=fr.length,rr){const gr=Math.round(dr/lr*100);rr({stage:"uploading",progress:gr,totalOperations:lr,uploadedOperations:dr})}logger.verbose(`uploadDocumentOperations:for:waitForUpdate(${t}:${wr} rev ${_r.index}): NEXT`)}logger.verbose(`uploadDocumentOperations:for:waitForUpdate(${t}): END`)}async function signAction$1(t,e){const I=window.ph?.legacyReactor;if(!I)return t;const tr=I.getDocumentModelModules().find(hr=>hr.documentModel.global.id===e.header.documentType);if(!tr)return logger.error(`Document model '${e.header.documentType}' not found`),t;const rr=tr.reducer,ir=window.ph?.user,lr=window.ph?.connectCrypto;if(!ir||!lr||!t.context?.signer)return t;const dr=t.context.signer;return await buildSignedAction(t,rr,e,dr,lr.sign)}function addActionContext(t){const e=window.ph?.user,I=window.ph?.did;return e?{context:{signer:{app:{name:"Connect",key:I||""},user:{address:e.address,networkId:e.networkId,chainId:e.chainId},signatures:[]}},...t}:t}async function makeSignedActionWithContext(t,e){if(!t){logger.error("No action found");return}if(!e){logger.error("No document found");return}const I=await signAction$1(t,e);return addActionContext(I)}async function makeSignedActionsWithContext(t,e){if(!t){logger.error("No actions found");return}const I=Array.isArray(t)?t:[t];return(await Promise.all(I.map(tr=>makeSignedActionWithContext(tr,e)))).filter(tr=>tr!==void 0)}async function getDocument(t){try{return await window.ph?.legacyReactor?.getDocument(t)}catch(e){logger.debug(`Failed to get document with id ${t}:`,e);return}}function getActionErrors(t,e){return e.reduce((I,B)=>{const tr=t.operations[B.scope].findLast(rr=>rr.action.id===B.id);return tr?.error&&I.push(new Error(tr.error)),I},new Array)}async function dispatchActions(t,e,I){const B=typeof e=="string"?await getDocument(e):e;if(!B){logger.error(`Document with id ${JSON.stringify(e)} not found`);return}const tr=await makeSignedActionsWithContext(t,B);if(!tr){logger.error("No signed actions with context found");return}const rr=await queueActions(B,tr);if(I&&rr){const ir=getActionErrors(rr,tr);ir.length&&I(ir)}return rr}class UnsupportedDocumentTypeError extends Error{constructor(e){super(`Document type ${e} is not supported`),this.name="UnsupportedDocumentTypeError"}}class DocumentTypeMismatchError extends Error{constructor(e,I,B){super(`Document ${e} is not of type ${I}. Actual type: ${B}`)}}class NoSelectedDocumentError extends Error{constructor(){super("There is no selected document. Call 'setSelectedNode' to select a document.")}}function isDocumentTypeSupported(t,e){return e?.length?e.some(I=>{if(I.endsWith("/*")){const B=I.slice(0,-2);return t.startsWith(B+"/")}if(I.endsWith("*")&&!I.endsWith("/*")){const B=I.slice(0,-1);return t.startsWith(B)}return I===t}):!0}function getUserPermissions(){const t=window.ph?.user,e=window.ph?.allowList;return e?{isAllowedToCreateDocuments:e.includes(t?.address??""),isAllowedToEditDocuments:e.includes(t?.address??"")}:{isAllowedToCreateDocuments:!0,isAllowedToEditDocuments:!0}}async function isDocumentInLocation(t,e,I){const B=isLegacyReadEnabledSync();try{if(B){const tr=window.ph?.legacyReactor;if(!tr)throw new Error("Legacy reactor not initialized");const rr=await tr.getDrive(e),ir=rr.state.global.nodes.find(dr=>dr.id===t.header.id);if(ir&&ir.parentFolder===(I??null))return{isDuplicate:!0,duplicateType:"id",nodeId:ir.id};const lr=rr.state.global.nodes.find(dr=>isFileNode(dr)&&dr.name===t.header.name&&dr.documentType===t.header.documentType&&dr.parentFolder===(I??null));return lr?{isDuplicate:!0,duplicateType:"name",nodeId:lr.id}:{isDuplicate:!1}}else{const tr=window.ph?.reactorClient;if(!tr)throw new Error("ReactorClient not initialized");const{document:rr}=await tr.get(e),ir=rr.state.global.nodes.find(dr=>dr.id===t.header.id);if(ir&&ir.parentFolder===(I??null))return{isDuplicate:!0,duplicateType:"id",nodeId:ir.id};const lr=rr.state.global.nodes.find(dr=>isFileNode(dr)&&dr.name===t.header.name&&dr.documentType===t.header.documentType&&dr.parentFolder===(I??null));return lr?{isDuplicate:!0,duplicateType:"name",nodeId:lr.id}:{isDuplicate:!1}}}catch{return{isDuplicate:!1}}}function getDocumentTypeIcon(t){switch(t.header.documentType){case"powerhouse/document-model":return"document-model";case"powerhouse/app":return"app";case"powerhouse/document-editor":return"editor";case"powerhouse/subgraph":return"subgraph";case"powerhouse/package":return"package";case"powerhouse/processor":{const B=t.state.global?.type;return B==="analytics"?"analytics-processor":B==="relational"?"relational-processor":B==="codegen"?"codegen-processor":void 0}default:return}}function downloadFile(t,e){createZip(t).generateAsync({type:"blob"}).then(B=>{const tr=window.document.createElement("a");tr.style.display="none",tr.href=URL.createObjectURL(B),tr.download=e,window.document.body.appendChild(tr),tr.click(),window.document.body.removeChild(tr)}).catch(logger.error)}async function exportFile(t,e){if(isLegacyReadEnabledSync()){if(!window.ph?.legacyReactor)throw new Error("Legacy reactor not initialized")}else if(!window.ph?.reactorClient)throw new Error("ReactorClient not initialized");let B="";if(t.header.documentType===documentModelDocumentType){const ir=t.state.global.extension.replace(/^\.+|\.+$/g,"");B=ir!==""?`.${ir}`:""}const tr=`${t.header.name||"Untitled"}${B}.phd`;if(!window.showSaveFilePicker)return downloadFile(t,tr);try{const rr=await window.showSaveFilePicker({suggestedName:tr});return await baseSaveToFileHandle(t,rr),rr}catch(rr){if(!(rr instanceof DOMException&&rr.name==="AbortError"))throw rr}}async function loadFile(t){const e=isLegacyReadEnabledSync(),I=await baseLoadFromInput(t,B=>B,{checkHashes:!0});if(e){const B=window.ph?.legacyReactor;if(!B)throw new Error("Legacy reactor not initialized");const rr=B.getDocumentModelModules().find(ir=>ir.documentModel.global.id===I.header.documentType);if(!rr)throw new Error(`Document "${I.header.documentType}" is not supported`);return rr.utils.loadFromInput(t)}else{const B=window.ph?.reactorClient;if(!B)throw new Error("ReactorClient not initialized");const{results:tr}=await B.getDocumentModels(),rr=tr.find(ir=>ir.documentModel.global.id===I.header.documentType);if(!rr)throw new Error(`Document "${I.header.documentType}" is not supported`);return rr.utils.loadFromInput(t)}}async function addDocument(t,e,I,B,tr,rr,ir){const{isAllowedToCreateDocuments:lr}=getUserPermissions();if(!lr)throw new Error("User is not allowed to create documents");if(isLegacyWriteEnabledSync()){const mr=window.ph?.legacyReactor;if(!mr)throw new Error("Legacy reactor not initialized");const hr=await mr.getDrive(t),fr=rr??generateId(),wr=mr.getDocumentModelModules().find(br=>br.documentModel.global.id===I);if(!wr)throw new Error(`Document model module for type ${I} not found`);const gr=wr.utils.createDocument({...tr?.state});gr.header=createPresignedHeader(fr,I),gr.header.name=e;const xr=ir?{preferredEditor:ir}:void 0;await mr.addDocument(gr,xr);const Mr=addFile$1({id:fr,name:e,documentType:I,parentFolder:B??null}),yr=(await queueActions(hr,Mr)).state.global.nodes.find(br=>br.id===fr);if(!yr||!isFileNode(yr))throw new Error("There was an error adding document");return yr}else{const mr=window.ph?.reactorClient;if(!mr)throw new Error("ReactorClient not initialized");const hr=await mr.createEmpty(I,t);return e&&await mr.rename(hr.header.id,e),B&&await mr.moveChildren(t,B,[hr.header.id]),{id:hr.header.id,name:e||hr.header.name,documentType:I,parentFolder:B??null,kind:"file"}}}async function addFile(t,e,I,B){logger.verbose(`addFile(drive: ${e}, name: ${I}, folder: ${B})`);const{isAllowedToCreateDocuments:tr}=getUserPermissions();if(!tr)throw new Error("User is not allowed to create files");const rr=isLegacyWriteEnabledSync(),ir=await loadFile(t);if(!ir)throw new Error("No document loaded");let lr=!1;if(rr){const _r=window.ph?.legacyReactor;if(!_r)throw new Error("Legacy reactor not initialized");if(!_r.getDocumentModelModules().find(gr=>gr.documentModel.global.id===ir.header.documentType))throw new Error(`Document model module for type ${ir.header.documentType} not found`);try{await _r.getDocument(ir.header.id),lr=!0}catch{}}else{const _r=window.ph?.reactorClient;if(!_r)throw new Error("ReactorClient not initialized");const{results:wr}=await _r.getDocumentModels();if(!wr.find(xr=>xr.documentModel.global.id===ir.header.documentType))throw new Error(`Document model module for type ${ir.header.documentType} not found`);try{await _r.get(ir.header.id),lr=!0}catch{}}const dr=lr?generateId():ir.header.id,mr=createPresignedHeader(dr,ir.header.documentType);mr.lastModifiedAtUtcIso=ir.header.createdAtUtcIso,mr.meta=ir.header.meta,mr.name=I||ir.header.name;const hr={...ir,state:ir.initialState,operations:Object.keys(ir.operations).reduce((_r,wr)=>(_r[wr]=[],_r),{})};if(!await addDocument(e,I||ir.header.name,ir.header.documentType,B,hr,dr,ir.header.meta?.preferredEditor))throw new Error("There was an error adding file");uploadOperations(dr,ir.operations,queueOperations).catch(_r=>{throw _r})}async function addFileWithProgress(t,e,I,B,tr,rr,ir){logger.verbose(`addFileWithProgress(drive: ${e}, name: ${I}, folder: ${B})`);const lr=window.ph?.legacyReactor;if(!lr)return;const{isAllowedToCreateDocuments:dr}=getUserPermissions();if(!dr)throw new Error("User is not allowed to create files");try{tr?.({stage:"loading",progress:0});const mr=await loadFile(t);if(!mr)throw new Error("No document loaded");const hr=await isDocumentInLocation(mr,e,B);if(hr.isDuplicate&&!ir){tr?.({stage:"conflict",progress:0,duplicateType:hr.duplicateType});return}hr.isDuplicate&&ir==="replace"&&hr.nodeId&&await deleteNode(e,hr.nodeId);const fr=getDocumentTypeIcon(mr);if(tr?.(fr?{stage:"loading",progress:10,documentType:fr}:{stage:"loading",progress:10}),!isDocumentTypeSupported(mr.header.documentType,rr))throw tr?.({stage:"unsupported-document-type",progress:100,error:`Document type ${mr.header.documentType} is not supported`}),new UnsupportedDocumentTypeError(mr.header.documentType);if(!lr.getDocumentModelModules().find(yr=>yr.documentModel.global.id===mr.header.documentType))throw new Error(`Document model module for type ${mr.header.documentType} not found`);tr?.({stage:"initializing",progress:10});let wr=!1;try{await lr.getDocument(mr.header.id),wr=!0}catch{}const gr=wr?generateId():mr.header.id,xr=createPresignedHeader(gr,mr.header.documentType);xr.lastModifiedAtUtcIso=mr.header.createdAtUtcIso,xr.meta=mr.header.meta,xr.name=I||mr.header.name;const Mr={...mr,header:xr,state:mr.initialState,operations:Object.keys(mr.operations).reduce((yr,br)=>(yr[br]=[],yr),{})},Sr=await addDocument(e,I||mr.header.name,mr.header.documentType,B,Mr,gr,mr.header.meta?.preferredEditor);if(!Sr)throw new Error("There was an error adding file");return tr?.({stage:"initializing",progress:20}),await uploadOperations(gr,mr.operations,queueOperations,{onProgress:yr=>{if(yr.totalOperations&&yr.uploadedOperations!==void 0){const br=yr.totalOperations>0?yr.uploadedOperations/yr.totalOperations:0,vr=20+Math.round(br*80);tr?.({stage:"uploading",progress:vr,totalOperations:yr.totalOperations,uploadedOperations:yr.uploadedOperations})}}}),tr?.({stage:"complete",progress:100}),Sr}catch(mr){if(!(mr instanceof UnsupportedDocumentTypeError)){const hr=mr instanceof Error?mr.message:"Unknown error occurred";tr?.({stage:"failed",progress:100,error:hr})}throw mr}}async function addFolder(t,e,I){const{isAllowedToCreateDocuments:B}=getUserPermissions();if(!B)throw new Error("User is not allowed to create folders");if(isLegacyWriteEnabledSync()){const rr=window.ph?.legacyReactor;if(!rr)throw new Error("Legacy reactor not initialized");const ir=generateId(),lr=await rr.getDrive(t),mr=(await queueActions(lr,addFolder$1({id:ir,name:e,parentFolder:I}))).state.global.nodes.find(hr=>hr.id===ir);if(!mr||!isFolderNode(mr))throw new Error("There was an error adding folder");return mr}else{const rr=window.ph?.reactorClient;if(!rr)throw new Error("ReactorClient not initialized");const{document:ir}=await rr.get(t),lr=generateId(),mr=(await rr.execute(t,"main",[addFolder$1({id:lr,name:e,parentFolder:I})])).state.global.nodes.find(hr=>hr.id===lr);if(!mr||!isFolderNode(mr))throw new Error("There was an error adding folder");return mr}}async function deleteNode(t,e){const{isAllowedToCreateDocuments:I}=getUserPermissions();if(!I)throw new Error("User is not allowed to delete documents");if(isLegacyWriteEnabledSync()){const tr=window.ph?.legacyReactor;if(!tr)throw new Error("Legacy reactor not initialized");const rr=await tr.getDrive(t);await queueActions(rr,deleteNode$1({id:e}))}else{const tr=window.ph?.reactorClient;if(!tr)throw new Error("ReactorClient not initialized");await tr.deleteDocument(e)}}async function renameNode(t,e,I){const{isAllowedToCreateDocuments:B}=getUserPermissions();if(!B)throw new Error("User is not allowed to rename documents");if(isLegacyWriteEnabledSync()){const rr=window.ph?.legacyReactor;if(!rr)throw new Error("Legacy reactor not initialized");const ir=await rr.getDrive(t),dr=(await queueActions(ir,updateNode({id:e,name:I}))).state.global.nodes.find(mr=>mr.id===e);if(!dr)throw new Error("There was an error renaming node");return dr}else{const rr=window.ph?.reactorClient;if(!rr)throw new Error("ReactorClient not initialized");await rr.rename(e,I);const{document:ir}=await rr.get(t),lr=ir.state.global.nodes.find(dr=>dr.id===e);if(!lr)throw new Error("There was an error renaming node");return lr}}async function moveNode(t,e,I){const{isAllowedToCreateDocuments:B}=getUserPermissions();if(!B)throw new Error("User is not allowed to move documents");if(isLegacyWriteEnabledSync()){const rr=window.ph?.legacyReactor;if(!rr)throw new Error("Legacy reactor not initialized");const ir=await rr.getDrive(t);return await queueActions(ir,moveNode$1({srcFolder:e.id,targetParentFolder:I?.id}))}else{const rr=window.ph?.reactorClient;if(!rr)throw new Error("ReactorClient not initialized");const ir=e.parentFolder??t,lr=I?.id??t;return await rr.moveChildren(ir,lr,[e.id])}}function _duplicateDocument(t,e,I=generateId()){const B=t.getDocumentModelModules().find(tr=>tr.documentModel.global.id===e.header.documentType);if(!B)throw new Error(`Document model module for type ${e.header.documentType} not found`);return replayDocument(e.initialState,e.operations,B.reducer,void 0,createPresignedHeader(I,e.header.documentType))}async function copyNode(t,e,I){const B=window.ph?.legacyReactor;if(!B)return;const{isAllowedToCreateDocuments:tr}=getUserPermissions();if(!tr)throw new Error("User is not allowed to copy documents");const rr=await B.getDrive(t),ir=generateNodesCopy({srcId:e.id,targetParentFolder:I?.id,targetName:e.name},()=>generateId(),rr.state.global.nodes),lr=new Map;for(const hr of ir){const fr=rr.state.global.nodes.find(_r=>_r.id===hr.srcId);if(fr){const _r=handleTargetNameCollisions({nodes:rr.state.global.nodes,srcName:hr.targetName||fr.name,targetParentFolder:hr.targetParentFolder||null});lr.set(hr.targetId,_r)}}const dr=ir.filter(hr=>{const fr=rr.state.global.nodes.find(_r=>_r.id===hr.srcId);return fr!==void 0&&isFileNode(fr)});for(const hr of dr)try{const fr=await B.getDocument(hr.srcId),_r=_duplicateDocument(B,fr,hr.targetId),wr=lr.get(hr.targetId);wr&&(_r.header.name=wr),await B.addDocument(_r)}catch(fr){logger.error(`Error copying document ${hr.srcId}: ${String(fr)}`)}const mr=ir.map(hr=>copyNode$1(hr));return await queueActions(rr,mr)}function validateBatchRequest(t){const e=new Set;for(const rr of t){if(e.has(rr.key))throw new Error(`Duplicate plan key: ${rr.key}`);e.add(rr.key)}for(const rr of t)for(const ir of rr.dependsOn)if(!e.has(ir))throw new Error(`Job '${rr.key}' depends on non-existent key: ${ir}`);const I=new Set,B=new Set,tr=rr=>{I.add(rr),B.add(rr);const ir=t.find(lr=>lr.key===rr);if(ir){for(const lr of ir.dependsOn)if(I.has(lr)){if(B.has(lr))return!0}else if(tr(lr))return!0}return B.delete(rr),!1};for(const rr of t)if(!I.has(rr.key)&&tr(rr.key))throw new Error(`Dependency cycle detected involving key: ${rr.key}`);for(const rr of t)if(rr.actions.length===0)throw new Error(`Job '${rr.key}' has empty actions array`)}function validateActionScopes(t){for(const e of t.actions){const I=e.scope||"global";if(I!==t.scope)throw new Error(`Job '${t.key}' declares scope '${t.scope}' but action has scope '${I}'`)}}function topologicalSort(t){const e=[],I=new Set,B=tr=>{if(I.has(tr))return;I.add(tr);const rr=t.find(ir=>ir.key===tr);if(rr)for(const ir of rr.dependsOn)B(ir);e.push(tr)};for(const tr of t)B(tr.key);return e}function toErrorInfo(t){return t instanceof Error?{message:t.message,stack:t.stack||new Error().stack||""}:{message:t,stack:new Error().stack||""}}function filterByType(t,e){return{results:t.results.filter(B=>B.header.documentType===e),options:t.options,nextCursor:t.nextCursor,next:t.next?async()=>{const B=await t.next();return filterByType(B,e)}:void 0}}function getSharedScope(t){if(t.length===0)throw new Error("No operations provided");const e=t[0].action.scope;for(const[I,B]of t.entries()){const tr=B.action.scope;if(tr!==e)throw new Error(`All operations in load must share the same scope. Expected '${e}', received '${tr}' at position ${I}`)}return e}const signAction=async(t,e,I)=>{const B=await e.sign(t,I);return{...t,context:{...t.context,signer:{user:{address:B[0],networkId:"",chainId:0},app:{name:"",key:B[1]},signatures:[B]}}}},signActions=async(t,e,I)=>Promise.all(t.map(B=>signAction(B,e,I)));class EventBusAggregateError extends Error{errors;constructor(e){const I=`EventBus emit failed with ${e.length} error(s): ${e.map(B=>B&&typeof B=="object"&&"message"in B?B.message:String(B)).join("; ")}`;super(I),this.name="EventBusAggregateError",this.errors=e}}const OperationEventTypes={OPERATION_WRITTEN:10001,OPERATIONS_READY:10002,JOB_FAILED:10003};var PropagationMode;(function(t){t.None="none",t.Cascade="cascade"})(PropagationMode||(PropagationMode={}));var RelationshipChangeType;(function(t){t.Added="added",t.Removed="removed"})(RelationshipChangeType||(RelationshipChangeType={}));var JobStatus;(function(t){t.PENDING="PENDING",t.RUNNING="RUNNING",t.WRITE_COMPLETED="WRITE_COMPLETED",t.READ_MODELS_READY="READ_MODELS_READY",t.FAILED="FAILED"})(JobStatus||(JobStatus={}));function isTerminalStatus(t){return t===JobStatus.READ_MODELS_READY||t===JobStatus.FAILED}class JobAwaiter{eventBus;getJobStatus;pendingJobs=new Map;unsubscribers=[];constructor(e,I){this.eventBus=e,this.getJobStatus=I,this.subscribeToEvents()}subscribeToEvents(){this.unsubscribers.push(this.eventBus.subscribe(OperationEventTypes.OPERATION_WRITTEN,async(e,I)=>{await this.handleOperationWritten(I)})),this.unsubscribers.push(this.eventBus.subscribe(OperationEventTypes.OPERATIONS_READY,async(e,I)=>{await this.handleOperationsReady(I)})),this.unsubscribers.push(this.eventBus.subscribe(OperationEventTypes.JOB_FAILED,async(e,I)=>{await this.handleJobFailed(I)}))}shutdown(){for(const e of this.unsubscribers)e();this.unsubscribers=[];for(const[,e]of this.pendingJobs)for(const I of e)I.reject(new Error("JobAwaiter destroyed"));this.pendingJobs.clear()}async waitForJob(e,I){if(I?.aborted)throw new Error("Operation aborted");const B=await this.getJobStatus(e,I);return isTerminalStatus(B.status)?B:new Promise((rr,ir)=>{const lr={resolve:rr,reject:ir,signal:I},dr=this.pendingJobs.get(e)||[];if(dr.push(lr),this.pendingJobs.set(e,dr),I){const mr=()=>{const hr=this.pendingJobs.get(e);if(hr){const fr=hr.indexOf(lr);fr!==-1&&(hr.splice(fr,1),hr.length===0&&this.pendingJobs.delete(e),lr.reject(new Error("Operation aborted")))}};I.addEventListener("abort",mr,{once:!0})}})}async handleOperationWritten(e){const I=e.jobId;await this.checkAndResolveWaiters(I)}async handleOperationsReady(e){const I=e.jobId;await this.checkAndResolveWaiters(I)}async handleJobFailed(e){await this.checkAndResolveWaiters(e.jobId)}async checkAndResolveWaiters(e){const I=this.pendingJobs.get(e);if(!(!I||I.length===0))try{const B=I.filter(rr=>!rr.signal?.aborted);if(B.length===0){this.pendingJobs.delete(e);return}const tr=await this.getJobStatus(e,B[0].signal);if(isTerminalStatus(tr.status)){this.pendingJobs.delete(e);for(const rr of B)rr.resolve(tr);for(const rr of I)rr.signal?.aborted&&rr.reject(new Error("Operation aborted"))}}catch(B){this.pendingJobs.delete(e);for(const tr of I)tr.reject(B instanceof Error?B:new Error(String(B)))}}}var DocumentChangeType;(function(t){t.Created="created",t.Deleted="deleted",t.Updated="updated",t.ParentAdded="parent_added",t.ParentRemoved="parent_removed",t.ChildAdded="child_added",t.ChildRemoved="child_removed"})(DocumentChangeType||(DocumentChangeType={}));class ReactorClient{reactor;signer;subscriptionManager;jobAwaiter;documentIndexer;constructor(e,I,B,tr,rr){this.reactor=e,this.signer=I,this.subscriptionManager=B,this.jobAwaiter=tr,this.documentIndexer=rr}async getDocumentModels(e,I,B){return this.reactor.getDocumentModels(e,I,B)}async get(e,I,B){return await this.reactor.getByIdOrSlug(e,I,void 0,B)}async getChildren(e,I,B,tr){const ir=(await this.reactor.getByIdOrSlug(e,I,void 0,tr)).document.header.id,dr=(await this.documentIndexer.getOutgoing(ir,void 0,void 0,tr)).map(mr=>mr.targetId);return dr.length===0?{results:[],options:B||{cursor:"0",limit:0}}:this.reactor.find({ids:dr},I,B,void 0,tr)}async getParents(e,I,B,tr){const ir=(await this.reactor.getByIdOrSlug(e,I,void 0,tr)).document.header.id,dr=(await this.documentIndexer.getIncoming(ir,void 0,void 0,tr)).map(mr=>mr.sourceId);return dr.length===0?{results:[],options:B||{cursor:"0",limit:0}}:this.reactor.find({ids:dr},I,B,void 0,tr)}async find(e,I,B,tr){return this.reactor.find(e,I,B,void 0,tr)}async create(e,I,B){const tr=await this.reactor.create(e,this.signer,B),rr=await this.waitForJob(tr,B);if(rr.status===JobStatus.FAILED)throw new Error(rr.error?.message);const ir=e.header.id,lr=await this.reactor.get(ir,void 0,rr.consistencyToken,B);return I&&await this.addChildren(I,[ir],void 0,B),lr.document}async createEmpty(e,I,B){const rr=(await this.reactor.getDocumentModels(void 0,void 0,B)).results.find(lr=>lr.documentModel.global.id===e);if(!rr)throw new Error(`Document model not found for type: ${e}`);const ir=rr.utils.createDocument();return this.create(ir,I,B)}async execute(e,I,B,tr){const rr=await signActions(B,this.signer,tr),ir=await this.reactor.execute(e,I,rr,tr),lr=await this.waitForJob(ir,tr);if(lr.status===JobStatus.FAILED)throw new Error(lr.error?.message);const dr={branch:I};return(await this.reactor.getByIdOrSlug(e,dr,lr.consistencyToken,tr)).document}async executeAsync(e,I,B,tr){const rr=await signActions(B,this.signer,tr);return this.reactor.execute(e,I,rr,tr)}async rename(e,I,B="main",tr){return this.execute(e,B,[actions.setName(I)],tr)}async addChildren(e,I,B="main",tr){const rr=await this.reactor.addChildren(e,I,B,this.signer,tr),ir=await this.waitForJob(rr,tr);if(ir.status===JobStatus.FAILED)throw new Error(ir.error?.message);return(await this.reactor.getByIdOrSlug(e,{branch:B},ir.consistencyToken,tr)).document}async removeChildren(e,I,B="main",tr){const rr=await this.reactor.removeChildren(e,I,B,this.signer,tr),ir=await this.waitForJob(rr,tr);if(ir.status===JobStatus.FAILED)throw new Error(ir.error?.message);return(await this.reactor.getByIdOrSlug(e,{branch:B},ir.consistencyToken,tr)).document}async moveChildren(e,I,B,tr="main",rr){const ir=await this.reactor.removeChildren(e,B,tr,this.signer,rr),lr=await this.waitForJob(ir,rr);if(lr.status===JobStatus.FAILED)throw new Error(lr.error?.message);const dr=await this.reactor.addChildren(I,B,tr,this.signer,rr),mr=await this.waitForJob(dr,rr);if(mr.status===JobStatus.FAILED)throw new Error(mr.error?.message);const hr=await this.reactor.getByIdOrSlug(e,{branch:tr},lr.consistencyToken,rr),fr=await this.reactor.getByIdOrSlug(I,{branch:tr},mr.consistencyToken,rr);return{source:hr.document,target:fr.document}}async deleteDocument(e,I,B){const tr=[];if(I===PropagationMode.Cascade){const lr=[],dr=[e],mr=new Set;for(;dr.length>0;){const hr=dr.shift();if(mr.has(hr))continue;if(mr.add(hr),B?.aborted)throw new Error("Operation aborted");const fr=await this.documentIndexer.getOutgoing(hr,["child"],void 0,B);for(const _r of fr)mr.has(_r.targetId)||(lr.push(_r.targetId),dr.push(_r.targetId))}for(const hr of lr){const fr=await this.reactor.deleteDocument(hr,this.signer,B);tr.push(fr)}}const rr=await this.reactor.deleteDocument(e,this.signer,B);tr.push(rr);const ir=await Promise.all(tr.map(lr=>this.waitForJob(lr,B)));for(const lr of ir)if(lr.status===JobStatus.FAILED)throw new Error(lr.error?.message)}async deleteDocuments(e,I,B){const tr=e.map(rr=>this.deleteDocument(rr,I,B));await Promise.all(tr)}async getJobStatus(e,I){return this.reactor.getJobStatus(e,I)}async waitForJob(e,I){const B=typeof e=="string"?e:e.id;return this.jobAwaiter.waitForJob(B,I)}subscribe(e,I,B){const tr=this.subscriptionManager.onDocumentCreated(dr=>{(async()=>{try{const mr=await Promise.all(dr.results.map(hr=>this.reactor.get(hr,B,void 0,void 0).then(fr=>fr.document)));I({type:DocumentChangeType.Created,documents:mr})}catch{}})()},e),rr=this.subscriptionManager.onDocumentDeleted(dr=>{I({type:DocumentChangeType.Deleted,documents:[],context:{childId:dr[0]}})},e),ir=this.subscriptionManager.onDocumentStateUpdated(dr=>{I({type:DocumentChangeType.Updated,documents:dr.results})},e,B),lr=this.subscriptionManager.onRelationshipChanged((dr,mr,hr)=>{I({type:hr===RelationshipChangeType.Added?DocumentChangeType.ChildAdded:DocumentChangeType.ChildRemoved,documents:[],context:{parentId:dr,childId:mr}})},e);return()=>{tr(),rr(),ir(),lr()}}}function createDocumentFromAction(t){const e=t.input,I=createPresignedHeader();I.id=e.documentId,I.documentType=e.model,e.signing&&(I.createdAtUtcIso=e.signing.createdAtUtcIso,I.lastModifiedAtUtcIso=e.signing.createdAtUtcIso,I.sig={publicKey:e.signing.publicKey,nonce:e.signing.nonce}),e.slug!==void 0&&(I.slug=e.slug),I.slug||(I.slug=e.documentId),e.name!==void 0&&(I.name=e.name),e.branch!==void 0&&(I.branch=e.branch),e.meta!==void 0&&(I.meta=e.meta);const B=defaultBaseState();return{header:I,operations:{},state:B,initialState:B,clipboard:[]}}function applyUpgradeDocumentAction(t,e){const I=e.input,B=I.initialState||I.state;return B&&(t.state={...t.state,...B},t.initialState=t.state),t}function applyDeleteDocumentAction(t,e){const I=e.timestampUtcMs||new Date().toISOString();return t.state={...t.state,document:{...t.state.document,isDeleted:!0,deletedAtUtcIso:I}},t}const getNextIndexForScope=(t,e)=>t.header.revision[e]||0;function createEmptyConsistencyToken(){return{version:1,createdAtUtcIso:new Date().toISOString(),coordinates:[]}}function createConsistencyToken(t){if(t.length===0)return createEmptyConsistencyToken();const e=[];for(let I=0;I<t.length;I++){const B=t[I];e.push({documentId:B.context.documentId,scope:B.context.scope,branch:B.context.branch,operationIndex:B.operation.index})}return{version:1,createdAtUtcIso:new Date().toISOString(),coordinates:e}}class LRUNode{key;prev;next;constructor(e){this.key=e,this.prev=void 0,this.next=void 0}}class LRUTracker{map;head;tail;constructor(){this.map=new Map,this.head=void 0,this.tail=void 0}get size(){return this.map.size}touch(e){const I=this.map.get(e);I?this.moveToFront(I):this.addToFront(e)}evict(){if(!this.tail)return;const e=this.tail.key;return this.remove(e),e}remove(e){const I=this.map.get(e);I&&(this.removeNode(I),this.map.delete(e))}clear(){this.map.clear(),this.head=void 0,this.tail=void 0}addToFront(e){const I=new LRUNode(e);this.map.set(e,I),this.head?(I.next=this.head,this.head.prev=I,this.head=I):(this.head=I,this.tail=I)}moveToFront(e){e!==this.head&&(this.removeNode(e),e.prev=void 0,e.next=this.head,this.head&&(this.head.prev=e),this.head=e,this.tail||(this.tail=e))}removeNode(e){e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev}}class DocumentMetaCache{cache;lruTracker;operationStore;config;constructor(e,I){this.operationStore=e,this.config={maxDocuments:I.maxDocuments},this.cache=new Map,this.lruTracker=new LRUTracker}async startup(){return Promise.resolve()}async shutdown(){return Promise.resolve()}async getDocumentMeta(e,I,B){if(B?.aborted)throw new Error("Operation aborted");const tr=this.makeKey(e,I),rr=this.cache.get(tr);if(rr)return this.lruTracker.touch(tr),rr;const ir=await this.rebuildLatest(e,I,B);return this.putDocumentMeta(e,I,ir),ir}async rebuildAtRevision(e,I,B,tr){if(tr?.aborted)throw new Error("Operation aborted");return this.rebuildFromOperations(e,I,B,tr)}putDocumentMeta(e,I,B){const tr=this.makeKey(e,I);if(!this.cache.has(tr)&&this.cache.size>=this.config.maxDocuments){const rr=this.lruTracker.evict();rr&&this.cache.delete(rr)}this.cache.set(tr,structuredClone(B)),this.lruTracker.touch(tr)}invalidate(e,I){let B=0;if(I===void 0)for(const tr of this.cache.keys())tr.startsWith(`${e}:`)&&(this.cache.delete(tr),this.lruTracker.remove(tr),B++);else{const tr=this.makeKey(e,I);this.cache.has(tr)&&(this.cache.delete(tr),this.lruTracker.remove(tr),B=1)}return B}clear(){this.cache.clear(),this.lruTracker.clear()}makeKey(e,I){return`${e}:${I}`}async rebuildLatest(e,I,B){return this.rebuildFromOperations(e,I,void 0,B)}async rebuildFromOperations(e,I,B,tr){const rr=await this.operationStore.getSince(e,"document",I,-1,void 0,tr);if(rr.items.length===0)throw new Error(`Document ${e} not found`);const ir=rr.items[0];if(ir.action.type!=="CREATE_DOCUMENT")throw new Error(`Invalid document: first operation must be CREATE_DOCUMENT, found ${ir.action.type}`);const lr=ir.action,dr=lr.input.model;let mr=createDocumentFromAction(lr),hr=0;for(const fr of rr.items){if(B!==void 0&&fr.index>B)break;hr=fr.index,fr.action.type==="UPGRADE_DOCUMENT"?mr=applyUpgradeDocumentAction(mr,fr.action):fr.action.type==="DELETE_DOCUMENT"&&(mr=applyDeleteDocumentAction(mr,fr.action))}return{state:mr.state.document,documentType:dr,documentScopeRevision:hr+1}}}function isUndefined(t){return typeof t>"u"||t===void 0}function isString(t){return typeof t=="string"}function isNumber(t){return typeof t=="number"}function isBoolean(t){return typeof t=="boolean"}function isNull(t){return t===null}function isDate(t){return t instanceof Date}function isBigInt(t){return typeof t=="bigint"}function isFunction(t){return typeof t=="function"}function isObject(t){return typeof t=="object"&&t!==null}function getLast(t){return t[t.length-1]}function freeze(t){return Object.freeze(t)}function asArray$1(t){return isReadonlyArray(t)?t:[t]}function isReadonlyArray(t){return Array.isArray(t)}function noop(t){return t}const AlterTableNode=freeze({is(t){return t.kind==="AlterTableNode"},create(t){return freeze({kind:"AlterTableNode",table:t})},cloneWithTableProps(t,e){return freeze({...t,...e})},cloneWithColumnAlteration(t,e){return freeze({...t,columnAlterations:t.columnAlterations?[...t.columnAlterations,e]:[e]})}}),IdentifierNode=freeze({is(t){return t.kind==="IdentifierNode"},create(t){return freeze({kind:"IdentifierNode",name:t})}}),CreateIndexNode=freeze({is(t){return t.kind==="CreateIndexNode"},create(t){return freeze({kind:"CreateIndexNode",name:IdentifierNode.create(t)})},cloneWith(t,e){return freeze({...t,...e})},cloneWithColumns(t,e){return freeze({...t,columns:[...t.columns||[],...e]})}}),CreateSchemaNode=freeze({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return freeze({kind:"CreateSchemaNode",schema:IdentifierNode.create(t),...e})},cloneWith(t,e){return freeze({...t,...e})}}),ON_COMMIT_ACTIONS=["preserve rows","delete rows","drop"],CreateTableNode=freeze({is(t){return t.kind==="CreateTableNode"},create(t){return freeze({kind:"CreateTableNode",table:t,columns:freeze([])})},cloneWithColumn(t,e){return freeze({...t,columns:freeze([...t.columns,e])})},cloneWithConstraint(t,e){return freeze({...t,constraints:t.constraints?freeze([...t.constraints,e]):freeze([e])})},cloneWithFrontModifier(t,e){return freeze({...t,frontModifiers:t.frontModifiers?freeze([...t.frontModifiers,e]):freeze([e])})},cloneWithEndModifier(t,e){return freeze({...t,endModifiers:t.endModifiers?freeze([...t.endModifiers,e]):freeze([e])})},cloneWith(t,e){return freeze({...t,...e})}}),SchemableIdentifierNode=freeze({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return freeze({kind:"SchemableIdentifierNode",identifier:IdentifierNode.create(t)})},createWithSchema(t,e){return freeze({kind:"SchemableIdentifierNode",schema:IdentifierNode.create(t),identifier:IdentifierNode.create(e)})}}),DropIndexNode=freeze({is(t){return t.kind==="DropIndexNode"},create(t,e){return freeze({kind:"DropIndexNode",name:SchemableIdentifierNode.create(t),...e})},cloneWith(t,e){return freeze({...t,...e})}}),DropSchemaNode=freeze({is(t){return t.kind==="DropSchemaNode"},create(t,e){return freeze({kind:"DropSchemaNode",schema:IdentifierNode.create(t),...e})},cloneWith(t,e){return freeze({...t,...e})}}),DropTableNode=freeze({is(t){return t.kind==="DropTableNode"},create(t,e){return freeze({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return freeze({...t,...e})}}),AliasNode=freeze({is(t){return t.kind==="AliasNode"},create(t,e){return freeze({kind:"AliasNode",node:t,alias:e})}}),TableNode=freeze({is(t){return t.kind==="TableNode"},create(t){return freeze({kind:"TableNode",table:SchemableIdentifierNode.create(t)})},createWithSchema(t,e){return freeze({kind:"TableNode",table:SchemableIdentifierNode.createWithSchema(t,e)})}});function isOperationNodeSource(t){return isObject(t)&&isFunction(t.toOperationNode)}function isExpression(t){return isObject(t)&&"expressionType"in t&&isOperationNodeSource(t)}function isAliasedExpression(t){return isObject(t)&&"expression"in t&&isString(t.alias)&&isOperationNodeSource(t)}const SelectModifierNode=freeze({is(t){return t.kind==="SelectModifierNode"},create(t,e){return freeze({kind:"SelectModifierNode",modifier:t,of:e})},createWithExpression(t){return freeze({kind:"SelectModifierNode",rawModifier:t})}}),AndNode=freeze({is(t){return t.kind==="AndNode"},create(t,e){return freeze({kind:"AndNode",left:t,right:e})}}),OrNode=freeze({is(t){return t.kind==="OrNode"},create(t,e){return freeze({kind:"OrNode",left:t,right:e})}}),OnNode=freeze({is(t){return t.kind==="OnNode"},create(t){return freeze({kind:"OnNode",on:t})},cloneWithOperation(t,e,I){return freeze({...t,on:e==="And"?AndNode.create(t.on,I):OrNode.create(t.on,I)})}}),JoinNode=freeze({is(t){return t.kind==="JoinNode"},create(t,e){return freeze({kind:"JoinNode",joinType:t,table:e,on:void 0})},createWithOn(t,e,I){return freeze({kind:"JoinNode",joinType:t,table:e,on:OnNode.create(I)})},cloneWithOn(t,e){return freeze({...t,on:t.on?OnNode.cloneWithOperation(t.on,"And",e):OnNode.create(e)})}}),BinaryOperationNode=freeze({is(t){return t.kind==="BinaryOperationNode"},create(t,e,I){return freeze({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:I})}}),COMPARISON_OPERATORS=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","^@","&&","?","?&","?|","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp","is distinct from","is not distinct from"],ARITHMETIC_OPERATORS=["+","-","*","/","%","^","&","|","#","<<",">>"],JSON_OPERATORS=["->","->>"],BINARY_OPERATORS=[...COMPARISON_OPERATORS,...ARITHMETIC_OPERATORS,"&&","||"],UNARY_FILTER_OPERATORS=["exists","not exists"],UNARY_OPERATORS=["not","-",...UNARY_FILTER_OPERATORS],OPERATORS=[...BINARY_OPERATORS,...JSON_OPERATORS,...UNARY_OPERATORS,"between","between symmetric"],OperatorNode=freeze({is(t){return t.kind==="OperatorNode"},create(t){return freeze({kind:"OperatorNode",operator:t})}});function isJSONOperator(t){return isString(t)&&JSON_OPERATORS.includes(t)}const ColumnNode=freeze({is(t){return t.kind==="ColumnNode"},create(t){return freeze({kind:"ColumnNode",column:IdentifierNode.create(t)})}}),SelectAllNode=freeze({is(t){return t.kind==="SelectAllNode"},create(){return freeze({kind:"SelectAllNode"})}}),ReferenceNode=freeze({is(t){return t.kind==="ReferenceNode"},create(t,e){return freeze({kind:"ReferenceNode",table:e,column:t})},createSelectAll(t){return freeze({kind:"ReferenceNode",table:t,column:SelectAllNode.create()})}});class DynamicReferenceBuilder{#e;get dynamicReference(){return this.#e}get refType(){}constructor(e){this.#e=e}toOperationNode(){return parseSimpleReferenceExpression(this.#e)}}function isDynamicReferenceBuilder(t){return isObject(t)&&isOperationNodeSource(t)&&isString(t.dynamicReference)}const OrderByItemNode=freeze({is(t){return t.kind==="OrderByItemNode"},create(t,e){return freeze({kind:"OrderByItemNode",orderBy:t,direction:e})},cloneWith(t,e){return freeze({...t,...e})}}),RawNode=freeze({is(t){return t.kind==="RawNode"},create(t,e){return freeze({kind:"RawNode",sqlFragments:freeze(t),parameters:freeze(e)})},createWithSql(t){return RawNode.create([t],[])},createWithChild(t){return RawNode.create(["",""],[t])},createWithChildren(t){return RawNode.create(new Array(t.length+1).fill(""),t)}}),CollateNode={is(t){return t.kind==="CollateNode"},create(t){return freeze({kind:"CollateNode",collation:IdentifierNode.create(t)})}};class OrderByItemBuilder{#e;constructor(e){this.#e=freeze(e)}desc(){return new OrderByItemBuilder({node:OrderByItemNode.cloneWith(this.#e.node,{direction:RawNode.createWithSql("desc")})})}asc(){return new OrderByItemBuilder({node:OrderByItemNode.cloneWith(this.#e.node,{direction:RawNode.createWithSql("asc")})})}nullsLast(){return new OrderByItemBuilder({node:OrderByItemNode.cloneWith(this.#e.node,{nulls:"last"})})}nullsFirst(){return new OrderByItemBuilder({node:OrderByItemNode.cloneWith(this.#e.node,{nulls:"first"})})}collate(e){return new OrderByItemBuilder({node:OrderByItemNode.cloneWith(this.#e.node,{collation:CollateNode.create(e)})})}toOperationNode(){return this.#e.node}}const LOGGED_MESSAGES=new Set;function logOnce(t){LOGGED_MESSAGES.has(t)||(LOGGED_MESSAGES.add(t),console.log(t))}function isOrderByDirection(t){return t==="asc"||t==="desc"}function parseOrderBy(t){if(t.length===2)return[parseOrderByItem(t[0],t[1])];if(t.length===1){const[e]=t;return Array.isArray(e)?(logOnce("orderBy(array) is deprecated, use multiple orderBy calls instead."),e.map(I=>parseOrderByItem(I))):[parseOrderByItem(e)]}throw new Error(`Invalid number of arguments at order by! expected 1-2, received ${t.length}`)}function parseOrderByItem(t,e){const I=parseOrderByExpression(t);if(OrderByItemNode.is(I)){if(e)throw new Error("Cannot specify direction twice!");return I}return parseOrderByWithModifiers(I,e)}function parseOrderByExpression(t){if(isExpressionOrFactory(t))return parseExpression(t);if(isDynamicReferenceBuilder(t))return t.toOperationNode();const[e,I]=t.split(" ");return I?(logOnce("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),parseOrderByWithModifiers(parseStringReference(e),I)):parseStringReference(t)}function parseOrderByWithModifiers(t,e){if(typeof e=="string"){if(!isOrderByDirection(e))throw new Error(`Invalid order by direction: ${e}`);return OrderByItemNode.create(t,RawNode.createWithSql(e))}if(isExpression(e))return logOnce("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),OrderByItemNode.create(t,e.toOperationNode());const I=OrderByItemNode.create(t);return e?e(new OrderByItemBuilder({node:I})).toOperationNode():I}const JSONReferenceNode=freeze({is(t){return t.kind==="JSONReferenceNode"},create(t,e){return freeze({kind:"JSONReferenceNode",reference:t,traversal:e})},cloneWithTraversal(t,e){return freeze({...t,traversal:e})}}),JSONOperatorChainNode=freeze({is(t){return t.kind==="JSONOperatorChainNode"},create(t){return freeze({kind:"JSONOperatorChainNode",operator:t,values:freeze([])})},cloneWithValue(t,e){return freeze({...t,values:freeze([...t.values,e])})}}),JSONPathNode=freeze({is(t){return t.kind==="JSONPathNode"},create(t){return freeze({kind:"JSONPathNode",inOperator:t,pathLegs:freeze([])})},cloneWithLeg(t,e){return freeze({...t,pathLegs:freeze([...t.pathLegs,e])})}});function parseSimpleReferenceExpression(t){return isString(t)?parseStringReference(t):t.toOperationNode()}function parseReferenceExpressionOrList(t){return isReadonlyArray(t)?t.map(e=>parseReferenceExpression(e)):[parseReferenceExpression(t)]}function parseReferenceExpression(t){return isExpressionOrFactory(t)?parseExpression(t):parseSimpleReferenceExpression(t)}function parseJSONReference(t,e){const I=parseStringReference(t);if(isJSONOperator(e))return JSONReferenceNode.create(I,JSONOperatorChainNode.create(OperatorNode.create(e)));const B=e.slice(0,-1);if(isJSONOperator(B))return JSONReferenceNode.create(I,JSONPathNode.create(OperatorNode.create(B)));throw new Error(`Invalid JSON operator: ${e}`)}function parseStringReference(t){if(!t.includes("."))return ReferenceNode.create(ColumnNode.create(t));const I=t.split(".").map(trim$2);if(I.length===3)return parseStringReferenceWithTableAndSchema(I);if(I.length===2)return parseStringReferenceWithTable(I);throw new Error(`invalid column reference ${t}`)}function parseAliasedStringReference(t){const e=" as ";if(t.includes(e)){const[I,B]=t.split(e).map(trim$2);return AliasNode.create(parseStringReference(I),IdentifierNode.create(B))}else return parseStringReference(t)}function parseColumnName(t){return ColumnNode.create(t)}function parseOrderedColumnName(t){if(t.includes(" ")){const[I,B]=t.split(" ").map(trim$2);if(!isOrderByDirection(B))throw new Error(`invalid order direction "${B}" next to "${I}"`);return parseOrderBy([I,B])[0]}else return parseColumnName(t)}function parseStringReferenceWithTableAndSchema(t){const[e,I,B]=t;return ReferenceNode.create(ColumnNode.create(B),TableNode.createWithSchema(e,I))}function parseStringReferenceWithTable(t){const[e,I]=t;return ReferenceNode.create(ColumnNode.create(I),TableNode.create(e))}function trim$2(t){return t.trim()}const PrimitiveValueListNode=freeze({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return freeze({kind:"PrimitiveValueListNode",values:freeze([...t])})}}),ValueListNode=freeze({is(t){return t.kind==="ValueListNode"},create(t){return freeze({kind:"ValueListNode",values:freeze(t)})}}),ValueNode=freeze({is(t){return t.kind==="ValueNode"},create(t){return freeze({kind:"ValueNode",value:t})},createImmediate(t){return freeze({kind:"ValueNode",value:t,immediate:!0})}});function parseValueExpressionOrList(t){return isReadonlyArray(t)?parseValueExpressionList(t):parseValueExpression(t)}function parseValueExpression(t){return isExpressionOrFactory(t)?parseExpression(t):ValueNode.create(t)}function isSafeImmediateValue(t){return isNumber(t)||isBoolean(t)||isNull(t)}function parseSafeImmediateValue(t){if(!isSafeImmediateValue(t))throw new Error(`unsafe immediate value ${JSON.stringify(t)}`);return ValueNode.createImmediate(t)}function parseValueExpressionList(t){return t.some(isExpressionOrFactory)?ValueListNode.create(t.map(e=>parseValueExpression(e))):PrimitiveValueListNode.create(t)}const ParensNode=freeze({is(t){return t.kind==="ParensNode"},create(t){return freeze({kind:"ParensNode",node:t})}});function parseValueBinaryOperationOrExpression(t){if(t.length===3)return parseValueBinaryOperation(t[0],t[1],t[2]);if(t.length===1)return parseValueExpression(t[0]);throw new Error(`invalid arguments: ${JSON.stringify(t)}`)}function parseValueBinaryOperation(t,e,I){return isIsOperator(e)&&needsIsOperator(I)?BinaryOperationNode.create(parseReferenceExpression(t),parseOperator(e),ValueNode.createImmediate(I)):BinaryOperationNode.create(parseReferenceExpression(t),parseOperator(e),parseValueExpressionOrList(I))}function parseReferentialBinaryOperation(t,e,I){return BinaryOperationNode.create(parseReferenceExpression(t),parseOperator(e),parseReferenceExpression(I))}function parseFilterObject(t,e){return parseFilterList(Object.entries(t).filter(([,I])=>!isUndefined(I)).map(([I,B])=>parseValueBinaryOperation(I,needsIsOperator(B)?"is":"=",B)),e)}function parseFilterList(t,e,I=!0){const B=e==="and"?AndNode.create:OrNode.create;if(t.length===0)return BinaryOperationNode.create(ValueNode.createImmediate(1),OperatorNode.create("="),ValueNode.createImmediate(e==="and"?1:0));let tr=toOperationNode(t[0]);for(let rr=1;rr<t.length;++rr)tr=B(tr,toOperationNode(t[rr]));return t.length>1&&I?ParensNode.create(tr):tr}function isIsOperator(t){return t==="is"||t==="is not"}function needsIsOperator(t){return isNull(t)||isBoolean(t)}function parseOperator(t){if(isString(t)&&OPERATORS.includes(t))return OperatorNode.create(t);if(isOperationNodeSource(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function toOperationNode(t){return isOperationNodeSource(t)?t.toOperationNode():t}const OrderByNode=freeze({is(t){return t.kind==="OrderByNode"},create(t){return freeze({kind:"OrderByNode",items:freeze([...t])})},cloneWithItems(t,e){return freeze({...t,items:freeze([...t.items,...e])})}}),PartitionByNode=freeze({is(t){return t.kind==="PartitionByNode"},create(t){return freeze({kind:"PartitionByNode",items:freeze(t)})},cloneWithItems(t,e){return freeze({...t,items:freeze([...t.items,...e])})}}),OverNode=freeze({is(t){return t.kind==="OverNode"},create(){return freeze({kind:"OverNode"})},cloneWithOrderByItems(t,e){return freeze({...t,orderBy:t.orderBy?OrderByNode.cloneWithItems(t.orderBy,e):OrderByNode.create(e)})},cloneWithPartitionByItems(t,e){return freeze({...t,partitionBy:t.partitionBy?PartitionByNode.cloneWithItems(t.partitionBy,e):PartitionByNode.create(e)})}}),FromNode=freeze({is(t){return t.kind==="FromNode"},create(t){return freeze({kind:"FromNode",froms:freeze(t)})},cloneWithFroms(t,e){return freeze({...t,froms:freeze([...t.froms,...e])})}}),GroupByNode=freeze({is(t){return t.kind==="GroupByNode"},create(t){return freeze({kind:"GroupByNode",items:freeze(t)})},cloneWithItems(t,e){return freeze({...t,items:freeze([...t.items,...e])})}}),HavingNode=freeze({is(t){return t.kind==="HavingNode"},create(t){return freeze({kind:"HavingNode",having:t})},cloneWithOperation(t,e,I){return freeze({...t,having:e==="And"?AndNode.create(t.having,I):OrNode.create(t.having,I)})}}),InsertQueryNode=freeze({is(t){return t.kind==="InsertQueryNode"},create(t,e,I){return freeze({kind:"InsertQueryNode",into:t,...e&&{with:e},replace:I})},createWithoutInto(){return freeze({kind:"InsertQueryNode"})},cloneWith(t,e){return freeze({...t,...e})}}),ListNode=freeze({is(t){return t.kind==="ListNode"},create(t){return freeze({kind:"ListNode",items:freeze(t)})}}),UpdateQueryNode=freeze({is(t){return t.kind==="UpdateQueryNode"},create(t,e){return freeze({kind:"UpdateQueryNode",table:t.length===1?t[0]:ListNode.create(t),...e&&{with:e}})},createWithoutTable(){return freeze({kind:"UpdateQueryNode"})},cloneWithFromItems(t,e){return freeze({...t,from:t.from?FromNode.cloneWithFroms(t.from,e):FromNode.create(e)})},cloneWithUpdates(t,e){return freeze({...t,updates:t.updates?freeze([...t.updates,...e]):e})},cloneWithLimit(t,e){return freeze({...t,limit:e})}}),UsingNode=freeze({is(t){return t.kind==="UsingNode"},create(t){return freeze({kind:"UsingNode",tables:freeze(t)})},cloneWithTables(t,e){return freeze({...t,tables:freeze([...t.tables,...e])})}}),DeleteQueryNode=freeze({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return freeze({kind:"DeleteQueryNode",from:FromNode.create(t),...e&&{with:e}})},cloneWithOrderByItems:(t,e)=>QueryNode.cloneWithOrderByItems(t,e),cloneWithoutOrderBy:t=>QueryNode.cloneWithoutOrderBy(t),cloneWithLimit(t,e){return freeze({...t,limit:e})},cloneWithoutLimit(t){return freeze({...t,limit:void 0})},cloneWithUsing(t,e){return freeze({...t,using:t.using!==void 0?UsingNode.cloneWithTables(t.using,e):UsingNode.create(e)})}}),WhereNode=freeze({is(t){return t.kind==="WhereNode"},create(t){return freeze({kind:"WhereNode",where:t})},cloneWithOperation(t,e,I){return freeze({...t,where:e==="And"?AndNode.create(t.where,I):OrNode.create(t.where,I)})}}),ReturningNode=freeze({is(t){return t.kind==="ReturningNode"},create(t){return freeze({kind:"ReturningNode",selections:freeze(t)})},cloneWithSelections(t,e){return freeze({...t,selections:t.selections?freeze([...t.selections,...e]):freeze(e)})}}),ExplainNode=freeze({is(t){return t.kind==="ExplainNode"},create(t,e){return freeze({kind:"ExplainNode",format:t,options:e})}}),WhenNode=freeze({is(t){return t.kind==="WhenNode"},create(t){return freeze({kind:"WhenNode",condition:t})},cloneWithResult(t,e){return freeze({...t,result:e})}}),MergeQueryNode=freeze({is(t){return t.kind==="MergeQueryNode"},create(t,e){return freeze({kind:"MergeQueryNode",into:t,...e&&{with:e}})},cloneWithUsing(t,e){return freeze({...t,using:e})},cloneWithWhen(t,e){return freeze({...t,whens:t.whens?freeze([...t.whens,e]):freeze([e])})},cloneWithThen(t,e){return freeze({...t,whens:t.whens?freeze([...t.whens.slice(0,-1),WhenNode.cloneWithResult(t.whens[t.whens.length-1],e)]):void 0})}}),OutputNode=freeze({is(t){return t.kind==="OutputNode"},create(t){return freeze({kind:"OutputNode",selections:freeze(t)})},cloneWithSelections(t,e){return freeze({...t,selections:t.selections?freeze([...t.selections,...e]):freeze(e)})}}),QueryNode=freeze({is(t){return SelectQueryNode.is(t)||InsertQueryNode.is(t)||UpdateQueryNode.is(t)||DeleteQueryNode.is(t)||MergeQueryNode.is(t)},cloneWithEndModifier(t,e){return freeze({...t,endModifiers:t.endModifiers?freeze([...t.endModifiers,e]):freeze([e])})},cloneWithWhere(t,e){return freeze({...t,where:t.where?WhereNode.cloneWithOperation(t.where,"And",e):WhereNode.create(e)})},cloneWithJoin(t,e){return freeze({...t,joins:t.joins?freeze([...t.joins,e]):freeze([e])})},cloneWithReturning(t,e){return freeze({...t,returning:t.returning?ReturningNode.cloneWithSelections(t.returning,e):ReturningNode.create(e)})},cloneWithoutReturning(t){return freeze({...t,returning:void 0})},cloneWithoutWhere(t){return freeze({...t,where:void 0})},cloneWithExplain(t,e,I){return freeze({...t,explain:ExplainNode.create(e,I?.toOperationNode())})},cloneWithTop(t,e){return freeze({...t,top:e})},cloneWithOutput(t,e){return freeze({...t,output:t.output?OutputNode.cloneWithSelections(t.output,e):OutputNode.create(e)})},cloneWithOrderByItems(t,e){return freeze({...t,orderBy:t.orderBy?OrderByNode.cloneWithItems(t.orderBy,e):OrderByNode.create(e)})},cloneWithoutOrderBy(t){return freeze({...t,orderBy:void 0})}}),SelectQueryNode=freeze({is(t){return t.kind==="SelectQueryNode"},create(t){return freeze({kind:"SelectQueryNode",...t&&{with:t}})},createFrom(t,e){return freeze({kind:"SelectQueryNode",from:FromNode.create(t),...e&&{with:e}})},cloneWithSelections(t,e){return freeze({...t,selections:t.selections?freeze([...t.selections,...e]):freeze(e)})},cloneWithDistinctOn(t,e){return freeze({...t,distinctOn:t.distinctOn?freeze([...t.distinctOn,...e]):freeze(e)})},cloneWithFrontModifier(t,e){return freeze({...t,frontModifiers:t.frontModifiers?freeze([...t.frontModifiers,e]):freeze([e])})},cloneWithOrderByItems:(t,e)=>QueryNode.cloneWithOrderByItems(t,e),cloneWithGroupByItems(t,e){return freeze({...t,groupBy:t.groupBy?GroupByNode.cloneWithItems(t.groupBy,e):GroupByNode.create(e)})},cloneWithLimit(t,e){return freeze({...t,limit:e})},cloneWithOffset(t,e){return freeze({...t,offset:e})},cloneWithFetch(t,e){return freeze({...t,fetch:e})},cloneWithHaving(t,e){return freeze({...t,having:t.having?HavingNode.cloneWithOperation(t.having,"And",e):HavingNode.create(e)})},cloneWithSetOperations(t,e){return freeze({...t,setOperations:t.setOperations?freeze([...t.setOperations,...e]):freeze([...e])})},cloneWithoutSelections(t){return freeze({...t,selections:[]})},cloneWithoutLimit(t){return freeze({...t,limit:void 0})},cloneWithoutOffset(t){return freeze({...t,offset:void 0})},cloneWithoutOrderBy:t=>QueryNode.cloneWithoutOrderBy(t),cloneWithoutGroupBy(t){return freeze({...t,groupBy:void 0})}});class JoinBuilder{#e;constructor(e){this.#e=freeze(e)}on(...e){return new JoinBuilder({...this.#e,joinNode:JoinNode.cloneWithOn(this.#e.joinNode,parseValueBinaryOperationOrExpression(e))})}onRef(e,I,B){return new JoinBuilder({...this.#e,joinNode:JoinNode.cloneWithOn(this.#e.joinNode,parseReferentialBinaryOperation(e,I,B))})}onTrue(){return new JoinBuilder({...this.#e,joinNode:JoinNode.cloneWithOn(this.#e.joinNode,RawNode.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return this.#e.joinNode}}const PartitionByItemNode=freeze({is(t){return t.kind==="PartitionByItemNode"},create(t){return freeze({kind:"PartitionByItemNode",partitionBy:t})}});function parsePartitionBy(t){return parseReferenceExpressionOrList(t).map(PartitionByItemNode.create)}class OverBuilder{#e;constructor(e){this.#e=freeze(e)}orderBy(...e){return new OverBuilder({overNode:OverNode.cloneWithOrderByItems(this.#e.overNode,parseOrderBy(e))})}clearOrderBy(){return new OverBuilder({overNode:QueryNode.cloneWithoutOrderBy(this.#e.overNode)})}partitionBy(e){return new OverBuilder({overNode:OverNode.cloneWithPartitionByItems(this.#e.overNode,parsePartitionBy(e))})}$call(e){return e(this)}toOperationNode(){return this.#e.overNode}}const SelectionNode=freeze({is(t){return t.kind==="SelectionNode"},create(t){return freeze({kind:"SelectionNode",selection:t})},createSelectAll(){return freeze({kind:"SelectionNode",selection:SelectAllNode.create()})},createSelectAllFromTable(t){return freeze({kind:"SelectionNode",selection:ReferenceNode.createSelectAll(t)})}});function parseSelectArg(t){return isFunction(t)?parseSelectArg(t(expressionBuilder())):isReadonlyArray(t)?t.map(e=>parseSelectExpression(e)):[parseSelectExpression(t)]}function parseSelectExpression(t){return isString(t)?SelectionNode.create(parseAliasedStringReference(t)):isDynamicReferenceBuilder(t)?SelectionNode.create(t.toOperationNode()):SelectionNode.create(parseAliasedExpression(t))}function parseSelectAll(t){return t?Array.isArray(t)?t.map(parseSelectAllArg):[parseSelectAllArg(t)]:[SelectionNode.createSelectAll()]}function parseSelectAllArg(t){if(isString(t))return SelectionNode.createSelectAllFromTable(parseTable(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const ValuesNode=freeze({is(t){return t.kind==="ValuesNode"},create(t){return freeze({kind:"ValuesNode",values:freeze(t)})}}),DefaultInsertValueNode=freeze({is(t){return t.kind==="DefaultInsertValueNode"},create(){return freeze({kind:"DefaultInsertValueNode"})}});function parseInsertExpression(t){const e=isFunction(t)?t(expressionBuilder()):t,I=isReadonlyArray(e)?e:freeze([e]);return parseInsertColumnsAndValues(I)}function parseInsertColumnsAndValues(t){const e=parseColumnNamesAndIndexes(t);return[freeze([...e.keys()].map(ColumnNode.create)),ValuesNode.create(t.map(I=>parseRowValues(I,e)))]}function parseColumnNamesAndIndexes(t){const e=new Map;for(const I of t){const B=Object.keys(I);for(const tr of B)!e.has(tr)&&I[tr]!==void 0&&e.set(tr,e.size)}return e}function parseRowValues(t,e){const I=Object.keys(t),B=Array.from({length:e.size});let tr=!1,rr=I.length;for(const lr of I){const dr=e.get(lr);if(isUndefined(dr)){rr--;continue}const mr=t[lr];(isUndefined(mr)||isExpressionOrFactory(mr))&&(tr=!0),B[dr]=mr}if(rr<e.size||tr){const lr=DefaultInsertValueNode.create();return ValueListNode.create(B.map(dr=>isUndefined(dr)?lr:parseValueExpression(dr)))}return PrimitiveValueListNode.create(B)}const ColumnUpdateNode=freeze({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return freeze({kind:"ColumnUpdateNode",column:t,value:e})}});function parseUpdate(...t){return t.length===2?[ColumnUpdateNode.create(parseReferenceExpression(t[0]),parseValueExpression(t[1]))]:parseUpdateObjectExpression(t[0])}function parseUpdateObjectExpression(t){const e=isFunction(t)?t(expressionBuilder()):t;return Object.entries(e).filter(([I,B])=>B!==void 0).map(([I,B])=>ColumnUpdateNode.create(ColumnNode.create(I),parseValueExpression(B)))}const OnDuplicateKeyNode=freeze({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return freeze({kind:"OnDuplicateKeyNode",updates:t})}});class InsertResult{insertId;numInsertedOrUpdatedRows;constructor(e,I){this.insertId=e,this.numInsertedOrUpdatedRows=I}}class NoResultError extends Error{node;constructor(e){super("no result"),this.node=e}}function isNoResultErrorConstructor(t){return Object.prototype.hasOwnProperty.call(t,"prototype")}const OnConflictNode=freeze({is(t){return t.kind==="OnConflictNode"},create(){return freeze({kind:"OnConflictNode"})},cloneWith(t,e){return freeze({...t,...e})},cloneWithIndexWhere(t,e){return freeze({...t,indexWhere:t.indexWhere?WhereNode.cloneWithOperation(t.indexWhere,"And",e):WhereNode.create(e)})},cloneWithIndexOrWhere(t,e){return freeze({...t,indexWhere:t.indexWhere?WhereNode.cloneWithOperation(t.indexWhere,"Or",e):WhereNode.create(e)})},cloneWithUpdateWhere(t,e){return freeze({...t,updateWhere:t.updateWhere?WhereNode.cloneWithOperation(t.updateWhere,"And",e):WhereNode.create(e)})},cloneWithUpdateOrWhere(t,e){return freeze({...t,updateWhere:t.updateWhere?WhereNode.cloneWithOperation(t.updateWhere,"Or",e):WhereNode.create(e)})},cloneWithoutIndexWhere(t){return freeze({...t,indexWhere:void 0})},cloneWithoutUpdateWhere(t){return freeze({...t,updateWhere:void 0})}});class OnConflictBuilder{#e;constructor(e){this.#e=freeze(e)}column(e){const I=ColumnNode.create(e);return new OnConflictBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?freeze([...this.#e.onConflictNode.columns,I]):freeze([I])})})}columns(e){const I=e.map(ColumnNode.create);return new OnConflictBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?freeze([...this.#e.onConflictNode.columns,...I]):freeze(I)})})}constraint(e){return new OnConflictBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWith(this.#e.onConflictNode,{constraint:IdentifierNode.create(e)})})}expression(e){return new OnConflictBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWith(this.#e.onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new OnConflictBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWithIndexWhere(this.#e.onConflictNode,parseValueBinaryOperationOrExpression(e))})}whereRef(e,I,B){return new OnConflictBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWithIndexWhere(this.#e.onConflictNode,parseReferentialBinaryOperation(e,I,B))})}clearWhere(){return new OnConflictBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWithoutIndexWhere(this.#e.onConflictNode)})}doNothing(){return new OnConflictDoNothingBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWith(this.#e.onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new OnConflictUpdateBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWith(this.#e.onConflictNode,{updates:parseUpdateObjectExpression(e)})})}$call(e){return e(this)}}class OnConflictDoNothingBuilder{#e;constructor(e){this.#e=freeze(e)}toOperationNode(){return this.#e.onConflictNode}}class OnConflictUpdateBuilder{#e;constructor(e){this.#e=freeze(e)}where(...e){return new OnConflictUpdateBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWithUpdateWhere(this.#e.onConflictNode,parseValueBinaryOperationOrExpression(e))})}whereRef(e,I,B){return new OnConflictUpdateBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWithUpdateWhere(this.#e.onConflictNode,parseReferentialBinaryOperation(e,I,B))})}clearWhere(){return new OnConflictUpdateBuilder({...this.#e,onConflictNode:OnConflictNode.cloneWithoutUpdateWhere(this.#e.onConflictNode)})}$call(e){return e(this)}toOperationNode(){return this.#e.onConflictNode}}const TopNode=freeze({is(t){return t.kind==="TopNode"},create(t,e){return freeze({kind:"TopNode",expression:t,modifiers:e})}});function parseTop(t,e){if(!isNumber(t)&&!isBigInt(t))throw new Error(`Invalid top expression: ${t}`);if(!isUndefined(e)&&!isTopModifiers(e))throw new Error(`Invalid top modifiers: ${e}`);return TopNode.create(t,e)}function isTopModifiers(t){return t==="percent"||t==="with ties"||t==="percent with ties"}const OrActionNode=freeze({is(t){return t.kind==="OrActionNode"},create(t){return freeze({kind:"OrActionNode",action:t})}});class InsertQueryBuilder{#e;constructor(e){this.#e=freeze(e)}values(e){const[I,B]=parseInsertExpression(e);return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{columns:I,values:B})})}columns(e){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{columns:freeze(e.map(ColumnNode.create))})})}expression(e){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{values:parseExpression(e)})})}defaultValues(){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{defaultValues:!0})})}modifyEnd(e){return new InsertQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}ignore(){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{orAction:OrActionNode.create("ignore")})})}orIgnore(){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{orAction:OrActionNode.create("ignore")})})}orAbort(){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{orAction:OrActionNode.create("abort")})})}orFail(){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{orAction:OrActionNode.create("fail")})})}orReplace(){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{orAction:OrActionNode.create("replace")})})}orRollback(){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{orAction:OrActionNode.create("rollback")})})}top(e,I){return new InsertQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithTop(this.#e.queryNode,parseTop(e,I))})}onConflict(e){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{onConflict:e(new OnConflictBuilder({onConflictNode:OnConflictNode.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new InsertQueryBuilder({...this.#e,queryNode:InsertQueryNode.cloneWith(this.#e.queryNode,{onDuplicateKey:OnDuplicateKeyNode.create(parseUpdateObjectExpression(e))})})}returning(e){return new InsertQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectArg(e))})}returningAll(){return new InsertQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectAll())})}output(e){return new InsertQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectArg(e))})}outputAll(e){return new InsertQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectAll(e))})}clearReturning(){return new InsertQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,I){return e?I(this):new InsertQueryBuilder({...this.#e})}$castTo(){return new InsertQueryBuilder(this.#e)}$narrowType(){return new InsertQueryBuilder(this.#e)}$assertType(){return new InsertQueryBuilder(this.#e)}withPlugin(e){return new InsertQueryBuilder({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){const e=this.compile(),I=await this.#e.executor.executeQuery(e),{adapter:B}=this.#e.executor,tr=e.query;return tr.returning&&B.supportsReturning||tr.output&&B.supportsOutput?I.rows:[new InsertResult(I.insertId,I.numAffectedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=NoResultError){const I=await this.executeTakeFirst();if(I===void 0)throw isNoResultErrorConstructor(e)?new e(this.toOperationNode()):e(this.toOperationNode());return I}async*stream(e=100){const I=this.compile(),B=this.#e.executor.stream(I,e);for await(const tr of B)yield*tr.rows}async explain(e,I){return await new InsertQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithExplain(this.#e.queryNode,e,I)}).execute()}}class DeleteResult{numDeletedRows;constructor(e){this.numDeletedRows=e}}const LimitNode=freeze({is(t){return t.kind==="LimitNode"},create(t){return freeze({kind:"LimitNode",limit:t})}});class DeleteQueryBuilder{#e;constructor(e){this.#e=freeze(e)}where(...e){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithWhere(this.#e.queryNode,parseValueBinaryOperationOrExpression(e))})}whereRef(e,I,B){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithWhere(this.#e.queryNode,parseReferentialBinaryOperation(e,I,B))})}clearWhere(){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithoutWhere(this.#e.queryNode)})}top(e,I){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithTop(this.#e.queryNode,parseTop(e,I))})}using(e){return new DeleteQueryBuilder({...this.#e,queryNode:DeleteQueryNode.cloneWithUsing(this.#e.queryNode,parseTableExpressionOrList(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}#t(e,I){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithJoin(this.#e.queryNode,parseJoin(e,I))})}returning(e){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectArg(e))})}returningAll(e){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectAll(e))})}output(e){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectArg(e))})}outputAll(e){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectAll(e))})}clearReturning(){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithoutReturning(this.#e.queryNode)})}clearLimit(){return new DeleteQueryBuilder({...this.#e,queryNode:DeleteQueryNode.cloneWithoutLimit(this.#e.queryNode)})}orderBy(...e){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOrderByItems(this.#e.queryNode,parseOrderBy(e))})}clearOrderBy(){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new DeleteQueryBuilder({...this.#e,queryNode:DeleteQueryNode.cloneWithLimit(this.#e.queryNode,LimitNode.create(parseValueExpression(e)))})}modifyEnd(e){return new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}$call(e){return e(this)}$if(e,I){return e?I(this):new DeleteQueryBuilder({...this.#e})}$castTo(){return new DeleteQueryBuilder(this.#e)}$narrowType(){return new DeleteQueryBuilder(this.#e)}$assertType(){return new DeleteQueryBuilder(this.#e)}withPlugin(e){return new DeleteQueryBuilder({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){const e=this.compile(),I=await this.#e.executor.executeQuery(e),{adapter:B}=this.#e.executor,tr=e.query;return tr.returning&&B.supportsReturning||tr.output&&B.supportsOutput?I.rows:[new DeleteResult(I.numAffectedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=NoResultError){const I=await this.executeTakeFirst();if(I===void 0)throw isNoResultErrorConstructor(e)?new e(this.toOperationNode()):e(this.toOperationNode());return I}async*stream(e=100){const I=this.compile(),B=this.#e.executor.stream(I,e);for await(const tr of B)yield*tr.rows}async explain(e,I){return await new DeleteQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithExplain(this.#e.queryNode,e,I)}).execute()}}class UpdateResult{numUpdatedRows;numChangedRows;constructor(e,I){this.numUpdatedRows=e,this.numChangedRows=I}}class UpdateQueryBuilder{#e;constructor(e){this.#e=freeze(e)}where(...e){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithWhere(this.#e.queryNode,parseValueBinaryOperationOrExpression(e))})}whereRef(e,I,B){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithWhere(this.#e.queryNode,parseReferentialBinaryOperation(e,I,B))})}clearWhere(){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithoutWhere(this.#e.queryNode)})}top(e,I){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithTop(this.#e.queryNode,parseTop(e,I))})}from(e){return new UpdateQueryBuilder({...this.#e,queryNode:UpdateQueryNode.cloneWithFromItems(this.#e.queryNode,parseTableExpressionOrList(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}#t(e,I){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithJoin(this.#e.queryNode,parseJoin(e,I))})}orderBy(...e){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOrderByItems(this.#e.queryNode,parseOrderBy(e))})}clearOrderBy(){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new UpdateQueryBuilder({...this.#e,queryNode:UpdateQueryNode.cloneWithLimit(this.#e.queryNode,LimitNode.create(parseValueExpression(e)))})}set(...e){return new UpdateQueryBuilder({...this.#e,queryNode:UpdateQueryNode.cloneWithUpdates(this.#e.queryNode,parseUpdate(...e))})}returning(e){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectArg(e))})}returningAll(e){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectAll(e))})}output(e){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectArg(e))})}outputAll(e){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectAll(e))})}modifyEnd(e){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}clearReturning(){return new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,I){return e?I(this):new UpdateQueryBuilder({...this.#e})}$castTo(){return new UpdateQueryBuilder(this.#e)}$narrowType(){return new UpdateQueryBuilder(this.#e)}$assertType(){return new UpdateQueryBuilder(this.#e)}withPlugin(e){return new UpdateQueryBuilder({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){const e=this.compile(),I=await this.#e.executor.executeQuery(e),{adapter:B}=this.#e.executor,tr=e.query;return tr.returning&&B.supportsReturning||tr.output&&B.supportsOutput?I.rows:[new UpdateResult(I.numAffectedRows??BigInt(0),I.numChangedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=NoResultError){const I=await this.executeTakeFirst();if(I===void 0)throw isNoResultErrorConstructor(e)?new e(this.toOperationNode()):e(this.toOperationNode());return I}async*stream(e=100){const I=this.compile(),B=this.#e.executor.stream(I,e);for await(const tr of B)yield*tr.rows}async explain(e,I){return await new UpdateQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithExplain(this.#e.queryNode,e,I)}).execute()}}const CommonTableExpressionNameNode=freeze({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return freeze({kind:"CommonTableExpressionNameNode",table:TableNode.create(t),columns:e?freeze(e.map(ColumnNode.create)):void 0})}}),CommonTableExpressionNode=freeze({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return freeze({kind:"CommonTableExpressionNode",name:t,expression:e})},cloneWith(t,e){return freeze({...t,...e})}});class CTEBuilder{#e;constructor(e){this.#e=freeze(e)}materialized(){return new CTEBuilder({...this.#e,node:CommonTableExpressionNode.cloneWith(this.#e.node,{materialized:!0})})}notMaterialized(){return new CTEBuilder({...this.#e,node:CommonTableExpressionNode.cloneWith(this.#e.node,{materialized:!1})})}toOperationNode(){return this.#e.node}}function parseCommonTableExpression(t,e){const I=e(createQueryCreator()).toOperationNode();return isFunction(t)?t(cteBuilderFactory(I)).toOperationNode():CommonTableExpressionNode.create(parseCommonTableExpressionName(t),I)}function cteBuilderFactory(t){return e=>new CTEBuilder({node:CommonTableExpressionNode.create(parseCommonTableExpressionName(e),t)})}function parseCommonTableExpressionName(t){if(t.includes("(")){const e=t.split(/[\(\)]/),I=e[0],B=e[1].split(",").map(tr=>tr.trim());return CommonTableExpressionNameNode.create(I,B)}else return CommonTableExpressionNameNode.create(t)}const WithNode=freeze({is(t){return t.kind==="WithNode"},create(t,e){return freeze({kind:"WithNode",expressions:freeze([t]),...e})},cloneWithExpression(t,e){return freeze({...t,expressions:freeze([...t.expressions,e])})}}),CHARS=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function randomString(t){let e="";for(let I=0;I<t;++I)e+=randomChar();return e}function randomChar(){return CHARS[~~(Math.random()*CHARS.length)]}function createQueryId(){return new LazyQueryId}class LazyQueryId{#e;get queryId(){return this.#e===void 0&&(this.#e=randomString(8)),this.#e}}function requireAllProps(t){return t}class OperationNodeTransformer{nodeStack=[];#e=freeze({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),RenameConstraintNode:this.transformRenameConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),RefreshMaterializedViewNode:this.transformRefreshMaterializedView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this),OrActionNode:this.transformOrAction.bind(this),CollateNode:this.transformCollate.bind(this)});transformNode(e,I){if(!e)return e;this.nodeStack.push(e);const B=this.transformNodeImpl(e,I);return this.nodeStack.pop(),freeze(B)}transformNodeImpl(e,I){return this.#e[e.kind](e,I)}transformNodeList(e,I){return e&&freeze(e.map(B=>this.transformNode(B,I)))}transformSelectQuery(e,I){return{kind:"SelectQueryNode",from:this.transformNode(e.from,I),selections:this.transformNodeList(e.selections,I),distinctOn:this.transformNodeList(e.distinctOn,I),joins:this.transformNodeList(e.joins,I),groupBy:this.transformNode(e.groupBy,I),orderBy:this.transformNode(e.orderBy,I),where:this.transformNode(e.where,I),frontModifiers:this.transformNodeList(e.frontModifiers,I),endModifiers:this.transformNodeList(e.endModifiers,I),limit:this.transformNode(e.limit,I),offset:this.transformNode(e.offset,I),with:this.transformNode(e.with,I),having:this.transformNode(e.having,I),explain:this.transformNode(e.explain,I),setOperations:this.transformNodeList(e.setOperations,I),fetch:this.transformNode(e.fetch,I),top:this.transformNode(e.top,I)}}transformSelection(e,I){return{kind:"SelectionNode",selection:this.transformNode(e.selection,I)}}transformColumn(e,I){return{kind:"ColumnNode",column:this.transformNode(e.column,I)}}transformAlias(e,I){return{kind:"AliasNode",node:this.transformNode(e.node,I),alias:this.transformNode(e.alias,I)}}transformTable(e,I){return{kind:"TableNode",table:this.transformNode(e.table,I)}}transformFrom(e,I){return{kind:"FromNode",froms:this.transformNodeList(e.froms,I)}}transformReference(e,I){return{kind:"ReferenceNode",column:this.transformNode(e.column,I),table:this.transformNode(e.table,I)}}transformAnd(e,I){return{kind:"AndNode",left:this.transformNode(e.left,I),right:this.transformNode(e.right,I)}}transformOr(e,I){return{kind:"OrNode",left:this.transformNode(e.left,I),right:this.transformNode(e.right,I)}}transformValueList(e,I){return{kind:"ValueListNode",values:this.transformNodeList(e.values,I)}}transformParens(e,I){return{kind:"ParensNode",node:this.transformNode(e.node,I)}}transformJoin(e,I){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table,I),on:this.transformNode(e.on,I)}}transformRaw(e,I){return{kind:"RawNode",sqlFragments:freeze([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters,I)}}transformWhere(e,I){return{kind:"WhereNode",where:this.transformNode(e.where,I)}}transformInsertQuery(e,I){return{kind:"InsertQueryNode",into:this.transformNode(e.into,I),columns:this.transformNodeList(e.columns,I),values:this.transformNode(e.values,I),returning:this.transformNode(e.returning,I),onConflict:this.transformNode(e.onConflict,I),onDuplicateKey:this.transformNode(e.onDuplicateKey,I),endModifiers:this.transformNodeList(e.endModifiers,I),with:this.transformNode(e.with,I),ignore:e.ignore,orAction:this.transformNode(e.orAction,I),replace:e.replace,explain:this.transformNode(e.explain,I),defaultValues:e.defaultValues,top:this.transformNode(e.top,I),output:this.transformNode(e.output,I)}}transformValues(e,I){return{kind:"ValuesNode",values:this.transformNodeList(e.values,I)}}transformDeleteQuery(e,I){return{kind:"DeleteQueryNode",from:this.transformNode(e.from,I),using:this.transformNode(e.using,I),joins:this.transformNodeList(e.joins,I),where:this.transformNode(e.where,I),returning:this.transformNode(e.returning,I),endModifiers:this.transformNodeList(e.endModifiers,I),with:this.transformNode(e.with,I),orderBy:this.transformNode(e.orderBy,I),limit:this.transformNode(e.limit,I),explain:this.transformNode(e.explain,I),top:this.transformNode(e.top,I),output:this.transformNode(e.output,I)}}transformReturning(e,I){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections,I)}}transformCreateTable(e,I){return{kind:"CreateTableNode",table:this.transformNode(e.table,I),columns:this.transformNodeList(e.columns,I),constraints:this.transformNodeList(e.constraints,I),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers,I),endModifiers:this.transformNodeList(e.endModifiers,I),selectQuery:this.transformNode(e.selectQuery,I)}}transformColumnDefinition(e,I){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column,I),dataType:this.transformNode(e.dataType,I),references:this.transformNode(e.references,I),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo,I),check:this.transformNode(e.check,I),generated:this.transformNode(e.generated,I),frontModifiers:this.transformNodeList(e.frontModifiers,I),endModifiers:this.transformNodeList(e.endModifiers,I),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists}}transformAddColumn(e,I){return{kind:"AddColumnNode",column:this.transformNode(e.column,I)}}transformDropTable(e,I){return{kind:"DropTableNode",table:this.transformNode(e.table,I),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e,I){return{kind:"OrderByNode",items:this.transformNodeList(e.items,I)}}transformOrderByItem(e,I){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy,I),direction:this.transformNode(e.direction,I),collation:this.transformNode(e.collation,I),nulls:e.nulls}}transformGroupBy(e,I){return{kind:"GroupByNode",items:this.transformNodeList(e.items,I)}}transformGroupByItem(e,I){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy,I)}}transformUpdateQuery(e,I){return{kind:"UpdateQueryNode",table:this.transformNode(e.table,I),from:this.transformNode(e.from,I),joins:this.transformNodeList(e.joins,I),where:this.transformNode(e.where,I),updates:this.transformNodeList(e.updates,I),returning:this.transformNode(e.returning,I),endModifiers:this.transformNodeList(e.endModifiers,I),with:this.transformNode(e.with,I),explain:this.transformNode(e.explain,I),limit:this.transformNode(e.limit,I),top:this.transformNode(e.top,I),output:this.transformNode(e.output,I),orderBy:this.transformNode(e.orderBy,I)}}transformColumnUpdate(e,I){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column,I),value:this.transformNode(e.value,I)}}transformLimit(e,I){return{kind:"LimitNode",limit:this.transformNode(e.limit,I)}}transformOffset(e,I){return{kind:"OffsetNode",offset:this.transformNode(e.offset,I)}}transformOnConflict(e,I){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns,I),constraint:this.transformNode(e.constraint,I),indexExpression:this.transformNode(e.indexExpression,I),indexWhere:this.transformNode(e.indexWhere,I),updates:this.transformNodeList(e.updates,I),updateWhere:this.transformNode(e.updateWhere,I),doNothing:e.doNothing}}transformOnDuplicateKey(e,I){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates,I)}}transformCreateIndex(e,I){return{kind:"CreateIndexNode",name:this.transformNode(e.name,I),table:this.transformNode(e.table,I),columns:this.transformNodeList(e.columns,I),unique:e.unique,using:this.transformNode(e.using,I),ifNotExists:e.ifNotExists,where:this.transformNode(e.where,I),nullsNotDistinct:e.nullsNotDistinct}}transformList(e,I){return{kind:"ListNode",items:this.transformNodeList(e.items,I)}}transformDropIndex(e,I){return{kind:"DropIndexNode",name:this.transformNode(e.name,I),table:this.transformNode(e.table,I),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e,I){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns,I),name:this.transformNode(e.name,I),deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformUniqueConstraint(e,I){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns,I),name:this.transformNode(e.name,I),nullsNotDistinct:e.nullsNotDistinct,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformForeignKeyConstraint(e,I){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns,I),references:this.transformNode(e.references,I),name:this.transformNode(e.name,I),onDelete:e.onDelete,onUpdate:e.onUpdate,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformSetOperation(e,I){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression,I),all:e.all}}transformReferences(e,I){return{kind:"ReferencesNode",table:this.transformNode(e.table,I),columns:this.transformNodeList(e.columns,I),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e,I){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression,I),name:this.transformNode(e.name,I)}}transformWith(e,I){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions,I),recursive:e.recursive}}transformCommonTableExpression(e,I){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name,I),materialized:e.materialized,expression:this.transformNode(e.expression,I)}}transformCommonTableExpressionName(e,I){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table,I),columns:this.transformNodeList(e.columns,I)}}transformHaving(e,I){return{kind:"HavingNode",having:this.transformNode(e.having,I)}}transformCreateSchema(e,I){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema,I),ifNotExists:e.ifNotExists}}transformDropSchema(e,I){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema,I),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e,I){return{kind:"AlterTableNode",table:this.transformNode(e.table,I),renameTo:this.transformNode(e.renameTo,I),setSchema:this.transformNode(e.setSchema,I),columnAlterations:this.transformNodeList(e.columnAlterations,I),addConstraint:this.transformNode(e.addConstraint,I),dropConstraint:this.transformNode(e.dropConstraint,I),renameConstraint:this.transformNode(e.renameConstraint,I),addIndex:this.transformNode(e.addIndex,I),dropIndex:this.transformNode(e.dropIndex,I)}}transformDropColumn(e,I){return{kind:"DropColumnNode",column:this.transformNode(e.column,I)}}transformRenameColumn(e,I){return{kind:"RenameColumnNode",column:this.transformNode(e.column,I),renameTo:this.transformNode(e.renameTo,I)}}transformAlterColumn(e,I){return{kind:"AlterColumnNode",column:this.transformNode(e.column,I),dataType:this.transformNode(e.dataType,I),dataTypeExpression:this.transformNode(e.dataTypeExpression,I),setDefault:this.transformNode(e.setDefault,I),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e,I){return{kind:"ModifyColumnNode",column:this.transformNode(e.column,I)}}transformAddConstraint(e,I){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint,I)}}transformDropConstraint(e,I){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName,I),ifExists:e.ifExists,modifier:e.modifier}}transformRenameConstraint(e,I){return{kind:"RenameConstraintNode",oldName:this.transformNode(e.oldName,I),newName:this.transformNode(e.newName,I)}}transformCreateView(e,I){return{kind:"CreateViewNode",name:this.transformNode(e.name,I),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns,I),as:this.transformNode(e.as,I)}}transformRefreshMaterializedView(e,I){return{kind:"RefreshMaterializedViewNode",name:this.transformNode(e.name,I),concurrently:e.concurrently,withNoData:e.withNoData}}transformDropView(e,I){return{kind:"DropViewNode",name:this.transformNode(e.name,I),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e,I){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression,I)}}transformDefaultValue(e,I){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue,I)}}transformOn(e,I){return{kind:"OnNode",on:this.transformNode(e.on,I)}}transformSelectModifier(e,I){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier,I),of:this.transformNodeList(e.of,I)}}transformCreateType(e,I){return{kind:"CreateTypeNode",name:this.transformNode(e.name,I),enum:this.transformNode(e.enum,I)}}transformDropType(e,I){return{kind:"DropTypeNode",name:this.transformNode(e.name,I),ifExists:e.ifExists}}transformExplain(e,I){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options,I)}}transformSchemableIdentifier(e,I){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema,I),identifier:this.transformNode(e.identifier,I)}}transformAggregateFunction(e,I){return{kind:"AggregateFunctionNode",func:e.func,aggregated:this.transformNodeList(e.aggregated,I),distinct:e.distinct,orderBy:this.transformNode(e.orderBy,I),withinGroup:this.transformNode(e.withinGroup,I),filter:this.transformNode(e.filter,I),over:this.transformNode(e.over,I)}}transformOver(e,I){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy,I),partitionBy:this.transformNode(e.partitionBy,I)}}transformPartitionBy(e,I){return{kind:"PartitionByNode",items:this.transformNodeList(e.items,I)}}transformPartitionByItem(e,I){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy,I)}}transformBinaryOperation(e,I){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand,I),operator:this.transformNode(e.operator,I),rightOperand:this.transformNode(e.rightOperand,I)}}transformUnaryOperation(e,I){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator,I),operand:this.transformNode(e.operand,I)}}transformUsing(e,I){return{kind:"UsingNode",tables:this.transformNodeList(e.tables,I)}}transformFunction(e,I){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments,I)}}transformCase(e,I){return{kind:"CaseNode",value:this.transformNode(e.value,I),when:this.transformNodeList(e.when,I),else:this.transformNode(e.else,I),isStatement:e.isStatement}}transformWhen(e,I){return{kind:"WhenNode",condition:this.transformNode(e.condition,I),result:this.transformNode(e.result,I)}}transformJSONReference(e,I){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference,I),traversal:this.transformNode(e.traversal,I)}}transformJSONPath(e,I){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator,I),pathLegs:this.transformNodeList(e.pathLegs,I)}}transformJSONPathLeg(e,I){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e,I){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator,I),values:this.transformNodeList(e.values,I)}}transformTuple(e,I){return{kind:"TupleNode",values:this.transformNodeList(e.values,I)}}transformMergeQuery(e,I){return{kind:"MergeQueryNode",into:this.transformNode(e.into,I),using:this.transformNode(e.using,I),whens:this.transformNodeList(e.whens,I),with:this.transformNode(e.with,I),top:this.transformNode(e.top,I),endModifiers:this.transformNodeList(e.endModifiers,I),output:this.transformNode(e.output,I),returning:this.transformNode(e.returning,I)}}transformMatched(e,I){return{kind:"MatchedNode",not:e.not,bySource:e.bySource}}transformAddIndex(e,I){return{kind:"AddIndexNode",name:this.transformNode(e.name,I),columns:this.transformNodeList(e.columns,I),unique:e.unique,using:this.transformNode(e.using,I),ifNotExists:e.ifNotExists}}transformCast(e,I){return{kind:"CastNode",expression:this.transformNode(e.expression,I),dataType:this.transformNode(e.dataType,I)}}transformFetch(e,I){return{kind:"FetchNode",rowCount:this.transformNode(e.rowCount,I),modifier:e.modifier}}transformTop(e,I){return{kind:"TopNode",expression:e.expression,modifiers:e.modifiers}}transformOutput(e,I){return{kind:"OutputNode",selections:this.transformNodeList(e.selections,I)}}transformDataType(e,I){return e}transformSelectAll(e,I){return e}transformIdentifier(e,I){return e}transformValue(e,I){return e}transformPrimitiveValueList(e,I){return e}transformOperator(e,I){return e}transformDefaultInsertValue(e,I){return e}transformOrAction(e,I){return e}transformCollate(e,I){return e}}const ROOT_OPERATION_NODES=freeze({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,RefreshMaterializedViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0}),SCHEMALESS_FUNCTIONS={json_agg:!0,to_json:!0};class WithSchemaTransformer extends OperationNodeTransformer{#e;#t=new Set;#r=new Set;constructor(e){super(),this.#e=e}transformNodeImpl(e,I){if(!this.#o(e))return super.transformNodeImpl(e,I);const B=this.#s(e);for(const ir of B)this.#r.add(ir);const tr=this.#l(e);for(const ir of tr)this.#t.add(ir);const rr=super.transformNodeImpl(e,I);for(const ir of tr)this.#t.delete(ir);for(const ir of B)this.#r.delete(ir);return rr}transformSchemableIdentifier(e,I){const B=super.transformSchemableIdentifier(e,I);return B.schema||!this.#t.has(e.identifier.name)?B:{...B,schema:IdentifierNode.create(this.#e)}}transformReferences(e,I){const B=super.transformReferences(e,I);return B.table.table.schema?B:{...B,table:TableNode.createWithSchema(this.#e,B.table.table.identifier.name)}}transformAggregateFunction(e,I){return{...super.transformAggregateFunction({...e,aggregated:[]},I),aggregated:this.#n(e,I,"aggregated")}}transformFunction(e,I){return{...super.transformFunction({...e,arguments:[]},I),arguments:this.#n(e,I,"arguments")}}#n(e,I,B){return SCHEMALESS_FUNCTIONS[e.func]?e[B].map(tr=>!TableNode.is(tr)||tr.table.schema?this.transformNode(tr,I):{...tr,table:this.transformIdentifier(tr.table.identifier,I)}):this.transformNodeList(e[B],I)}#o(e){return e.kind in ROOT_OPERATION_NODES}#l(e){const I=new Set;if("name"in e&&e.name&&SchemableIdentifierNode.is(e.name)&&this.#a(e.name,I),"from"in e&&e.from)for(const B of e.from.froms)this.#i(B,I);if("into"in e&&e.into&&this.#i(e.into,I),"table"in e&&e.table&&this.#i(e.table,I),"joins"in e&&e.joins)for(const B of e.joins)this.#i(B.table,I);return"using"in e&&e.using&&(JoinNode.is(e.using)?this.#i(e.using.table,I):this.#i(e.using,I)),I}#s(e){const I=new Set;return"with"in e&&e.with&&this.#d(e.with,I),I}#i(e,I){if(TableNode.is(e))this.#a(e.table,I);else if(AliasNode.is(e)&&TableNode.is(e.node))this.#a(e.node.table,I);else if(ListNode.is(e))for(const B of e.items)this.#i(B,I)}#a(e,I){const B=e.identifier.name;!this.#t.has(B)&&!this.#r.has(B)&&I.add(B)}#d(e,I){for(const B of e.expressions){const tr=B.name.table.table.identifier.name;this.#r.has(tr)||I.add(tr)}}}class WithSchemaPlugin{#e;constructor(e){this.#e=new WithSchemaTransformer(e)}transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}async transformResult(e){return e.result}}const MatchedNode=freeze({is(t){return t.kind==="MatchedNode"},create(t,e=!1){return freeze({kind:"MatchedNode",not:t,bySource:e})}});function parseMergeWhen(t,e,I){return WhenNode.create(parseFilterList([MatchedNode.create(!t.isMatched,t.bySource),...e&&e.length>0?[e.length===3&&I?parseReferentialBinaryOperation(e[0],e[1],e[2]):parseValueBinaryOperationOrExpression(e)]:[]],"and",!1))}function parseMergeThen(t){return isString(t)?RawNode.create([t],[]):isOperationNodeSource(t)?t.toOperationNode():t}class Deferred{#e;#t;#r;constructor(){this.#e=new Promise((e,I)=>{this.#r=I,this.#t=e})}get promise(){return this.#e}resolve=e=>{this.#t&&this.#t(e)};reject=e=>{this.#r&&this.#r(e)}}async function provideControlledConnection(t){const e=new Deferred,I=new Deferred;return t.provideConnection(async B=>(e.resolve(B),await I.promise)).catch(B=>e.reject(B)),freeze({connection:await e.promise,release:I.resolve})}const NO_PLUGINS=freeze([]);class QueryExecutorBase{#e;constructor(e=NO_PLUGINS){this.#e=e}get plugins(){return this.#e}transformQuery(e,I){for(const B of this.#e){const tr=B.transformQuery({node:e,queryId:I});if(tr.kind===e.kind)e=tr;else throw new Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${e.kind}`,`but it returned a ${tr.kind}`].join(" "))}return e}async executeQuery(e){return await this.provideConnection(async I=>{const B=await I.executeQuery(e);return"numUpdatedOrDeletedRows"in B&&logOnce("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`."),await this.#t(B,e.queryId)})}async*stream(e,I){const{connection:B,release:tr}=await provideControlledConnection(this);try{for await(const rr of B.streamQuery(e,I))yield await this.#t(rr,e.queryId)}finally{tr()}}async#t(e,I){for(const B of this.#e)e=await B.transformResult({result:e,queryId:I});return e}}class NoopQueryExecutor extends QueryExecutorBase{get adapter(){throw new Error("this query cannot be compiled to SQL")}compileQuery(){throw new Error("this query cannot be compiled to SQL")}provideConnection(){throw new Error("this query cannot be executed")}withConnectionProvider(){throw new Error("this query cannot have a connection provider")}withPlugin(e){return new NoopQueryExecutor([...this.plugins,e])}withPlugins(e){return new NoopQueryExecutor([...this.plugins,...e])}withPluginAtFront(e){return new NoopQueryExecutor([e,...this.plugins])}withoutPlugins(){return new NoopQueryExecutor([])}}const NOOP_QUERY_EXECUTOR=new NoopQueryExecutor;class MergeResult{numChangedRows;constructor(e){this.numChangedRows=e}}class MergeQueryBuilder{#e;constructor(e){this.#e=freeze(e)}modifyEnd(e){return new MergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,I){return new MergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithTop(this.#e.queryNode,parseTop(e,I))})}using(...e){return new WheneableMergeQueryBuilder({...this.#e,queryNode:MergeQueryNode.cloneWithUsing(this.#e.queryNode,parseJoin("Using",e))})}returning(e){return new MergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectArg(e))})}returningAll(e){return new MergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectAll(e))})}output(e){return new MergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectArg(e))})}outputAll(e){return new MergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectAll(e))})}}class WheneableMergeQueryBuilder{#e;constructor(e){this.#e=freeze(e)}modifyEnd(e){return new WheneableMergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,I){return new WheneableMergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithTop(this.#e.queryNode,parseTop(e,I))})}whenMatched(){return this.#t([])}whenMatchedAnd(...e){return this.#t(e)}whenMatchedAndRef(e,I,B){return this.#t([e,I,B],!0)}#t(e,I){return new MatchedThenableMergeQueryBuilder({...this.#e,queryNode:MergeQueryNode.cloneWithWhen(this.#e.queryNode,parseMergeWhen({isMatched:!0},e,I))})}whenNotMatched(){return this.#r([])}whenNotMatchedAnd(...e){return this.#r(e)}whenNotMatchedAndRef(e,I,B){return this.#r([e,I,B],!0)}whenNotMatchedBySource(){return this.#r([],!1,!0)}whenNotMatchedBySourceAnd(...e){return this.#r(e,!1,!0)}whenNotMatchedBySourceAndRef(e,I,B){return this.#r([e,I,B],!0,!0)}returning(e){return new WheneableMergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectArg(e))})}returningAll(e){return new WheneableMergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithReturning(this.#e.queryNode,parseSelectAll(e))})}output(e){return new WheneableMergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectArg(e))})}outputAll(e){return new WheneableMergeQueryBuilder({...this.#e,queryNode:QueryNode.cloneWithOutput(this.#e.queryNode,parseSelectAll(e))})}#r(e,I=!1,B=!1){const tr={...this.#e,queryNode:MergeQueryNode.cloneWithWhen(this.#e.queryNode,parseMergeWhen({isMatched:!1,bySource:B},e,I))},rr=B?MatchedThenableMergeQueryBuilder:NotMatchedThenableMergeQueryBuilder;return new rr(tr)}$call(e){return e(this)}$if(e,I){return e?I(this):new WheneableMergeQueryBuilder({...this.#e})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){const e=this.compile(),I=await this.#e.executor.executeQuery(e),{adapter:B}=this.#e.executor,tr=e.query;return tr.returning&&B.supportsReturning||tr.output&&B.supportsOutput?I.rows:[new MergeResult(I.numAffectedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=NoResultError){const I=await this.executeTakeFirst();if(I===void 0)throw isNoResultErrorConstructor(e)?new e(this.toOperationNode()):e(this.toOperationNode());return I}}class MatchedThenableMergeQueryBuilder{#e;constructor(e){this.#e=freeze(e)}thenDelete(){return new WheneableMergeQueryBuilder({...this.#e,queryNode:MergeQueryNode.cloneWithThen(this.#e.queryNode,parseMergeThen("delete"))})}thenDoNothing(){return new WheneableMergeQueryBuilder({...this.#e,queryNode:MergeQueryNode.cloneWithThen(this.#e.queryNode,parseMergeThen("do nothing"))})}thenUpdate(e){return new WheneableMergeQueryBuilder({...this.#e,queryNode:MergeQueryNode.cloneWithThen(this.#e.queryNode,parseMergeThen(e(new UpdateQueryBuilder({queryId:this.#e.queryId,executor:NOOP_QUERY_EXECUTOR,queryNode:UpdateQueryNode.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate(I=>I.set(...e))}}class NotMatchedThenableMergeQueryBuilder{#e;constructor(e){this.#e=freeze(e)}thenDoNothing(){return new WheneableMergeQueryBuilder({...this.#e,queryNode:MergeQueryNode.cloneWithThen(this.#e.queryNode,parseMergeThen("do nothing"))})}thenInsertValues(e){const[I,B]=parseInsertExpression(e);return new WheneableMergeQueryBuilder({...this.#e,queryNode:MergeQueryNode.cloneWithThen(this.#e.queryNode,parseMergeThen(InsertQueryNode.cloneWith(InsertQueryNode.createWithoutInto(),{columns:I,values:B})))})}}class QueryCreator{#e;constructor(e){this.#e=freeze(e)}selectFrom(e){return createSelectQueryBuilder({queryId:createQueryId(),executor:this.#e.executor,queryNode:SelectQueryNode.createFrom(parseTableExpressionOrList(e),this.#e.withNode)})}selectNoFrom(e){return createSelectQueryBuilder({queryId:createQueryId(),executor:this.#e.executor,queryNode:SelectQueryNode.cloneWithSelections(SelectQueryNode.create(this.#e.withNode),parseSelectArg(e))})}insertInto(e){return new InsertQueryBuilder({queryId:createQueryId(),executor:this.#e.executor,queryNode:InsertQueryNode.create(parseTable(e),this.#e.withNode)})}replaceInto(e){return new InsertQueryBuilder({queryId:createQueryId(),executor:this.#e.executor,queryNode:InsertQueryNode.create(parseTable(e),this.#e.withNode,!0)})}deleteFrom(e){return new DeleteQueryBuilder({queryId:createQueryId(),executor:this.#e.executor,queryNode:DeleteQueryNode.create(parseTableExpressionOrList(e),this.#e.withNode)})}updateTable(e){return new UpdateQueryBuilder({queryId:createQueryId(),executor:this.#e.executor,queryNode:UpdateQueryNode.create(parseTableExpressionOrList(e),this.#e.withNode)})}mergeInto(e){return new MergeQueryBuilder({queryId:createQueryId(),executor:this.#e.executor,queryNode:MergeQueryNode.create(parseAliasedTable(e),this.#e.withNode)})}with(e,I){const B=parseCommonTableExpression(e,I);return new QueryCreator({...this.#e,withNode:this.#e.withNode?WithNode.cloneWithExpression(this.#e.withNode,B):WithNode.create(B)})}withRecursive(e,I){const B=parseCommonTableExpression(e,I);return new QueryCreator({...this.#e,withNode:this.#e.withNode?WithNode.cloneWithExpression(this.#e.withNode,B):WithNode.create(B,{recursive:!0})})}withPlugin(e){return new QueryCreator({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new QueryCreator({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new QueryCreator({...this.#e,executor:this.#e.executor.withPluginAtFront(new WithSchemaPlugin(e))})}}function createQueryCreator(){return new QueryCreator({executor:NOOP_QUERY_EXECUTOR})}function createJoinBuilder(t,e){return new JoinBuilder({joinNode:JoinNode.create(t,parseTableExpression(e))})}function createOverBuilder(){return new OverBuilder({overNode:OverNode.create()})}function parseJoin(t,e){if(e.length===3)return parseSingleOnJoin(t,e[0],e[1],e[2]);if(e.length===2)return parseCallbackJoin(t,e[0],e[1]);if(e.length===1)return parseOnlessJoin(t,e[0]);throw new Error("not implemented")}function parseCallbackJoin(t,e,I){return I(createJoinBuilder(t,e)).toOperationNode()}function parseSingleOnJoin(t,e,I,B){return JoinNode.createWithOn(t,parseTableExpression(e),parseReferentialBinaryOperation(I,"=",B))}function parseOnlessJoin(t,e){return JoinNode.create(t,parseTableExpression(e))}const OffsetNode=freeze({is(t){return t.kind==="OffsetNode"},create(t){return freeze({kind:"OffsetNode",offset:t})}}),GroupByItemNode=freeze({is(t){return t.kind==="GroupByItemNode"},create(t){return freeze({kind:"GroupByItemNode",groupBy:t})}});function parseGroupBy(t){return t=isFunction(t)?t(expressionBuilder()):t,parseReferenceExpressionOrList(t).map(GroupByItemNode.create)}const SetOperationNode=freeze({is(t){return t.kind==="SetOperationNode"},create(t,e,I){return freeze({kind:"SetOperationNode",operator:t,expression:e,all:I})}});function parseSetOperations(t,e,I){return isFunction(e)&&(e=e(createExpressionBuilder())),isReadonlyArray(e)||(e=[e]),e.map(B=>SetOperationNode.create(t,parseExpression(B),I))}class ExpressionWrapper{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new AliasedExpressionWrapper(this,e)}or(...e){return new OrWrapper(OrNode.create(this.#e,parseValueBinaryOperationOrExpression(e)))}and(...e){return new AndWrapper(AndNode.create(this.#e,parseValueBinaryOperationOrExpression(e)))}$castTo(){return new ExpressionWrapper(this.#e)}$notNull(){return new ExpressionWrapper(this.#e)}toOperationNode(){return this.#e}}class AliasedExpressionWrapper{#e;#t;constructor(e,I){this.#e=e,this.#t=I}get expression(){return this.#e}get alias(){return this.#t}toOperationNode(){return AliasNode.create(this.#e.toOperationNode(),isOperationNodeSource(this.#t)?this.#t.toOperationNode():IdentifierNode.create(this.#t))}}class OrWrapper{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new AliasedExpressionWrapper(this,e)}or(...e){return new OrWrapper(OrNode.create(this.#e,parseValueBinaryOperationOrExpression(e)))}$castTo(){return new OrWrapper(this.#e)}toOperationNode(){return ParensNode.create(this.#e)}}class AndWrapper{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new AliasedExpressionWrapper(this,e)}and(...e){return new AndWrapper(AndNode.create(this.#e,parseValueBinaryOperationOrExpression(e)))}$castTo(){return new AndWrapper(this.#e)}toOperationNode(){return ParensNode.create(this.#e)}}const FetchNode={is(t){return t.kind==="FetchNode"},create(t,e){return{kind:"FetchNode",rowCount:ValueNode.create(t),modifier:e}}};function parseFetch(t,e){if(!isNumber(t)&&!isBigInt(t))throw new Error(`Invalid fetch row count: ${t}`);if(!isFetchModifier(e))throw new Error(`Invalid fetch modifier: ${e}`);return FetchNode.create(t,e)}function isFetchModifier(t){return t==="only"||t==="with ties"}class SelectQueryBuilderImpl{#e;constructor(e){this.#e=freeze(e)}get expressionType(){}get isSelectQueryBuilder(){return!0}where(...e){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithWhere(this.#e.queryNode,parseValueBinaryOperationOrExpression(e))})}whereRef(e,I,B){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithWhere(this.#e.queryNode,parseReferentialBinaryOperation(e,I,B))})}having(...e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithHaving(this.#e.queryNode,parseValueBinaryOperationOrExpression(e))})}havingRef(e,I,B){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithHaving(this.#e.queryNode,parseReferentialBinaryOperation(e,I,B))})}select(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithSelections(this.#e.queryNode,parseSelectArg(e))})}distinctOn(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithDistinctOn(this.#e.queryNode,parseReferenceExpressionOrList(e))})}modifyFront(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithFrontModifier(this.#e.queryNode,SelectModifierNode.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,SelectModifierNode.createWithExpression(e.toOperationNode()))})}distinct(){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithFrontModifier(this.#e.queryNode,SelectModifierNode.create("Distinct"))})}forUpdate(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,SelectModifierNode.create("ForUpdate",e?asArray$1(e).map(parseTable):void 0))})}forShare(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,SelectModifierNode.create("ForShare",e?asArray$1(e).map(parseTable):void 0))})}forKeyShare(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,SelectModifierNode.create("ForKeyShare",e?asArray$1(e).map(parseTable):void 0))})}forNoKeyUpdate(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,SelectModifierNode.create("ForNoKeyUpdate",e?asArray$1(e).map(parseTable):void 0))})}skipLocked(){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,SelectModifierNode.create("SkipLocked"))})}noWait(){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithEndModifier(this.#e.queryNode,SelectModifierNode.create("NoWait"))})}selectAll(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithSelections(this.#e.queryNode,parseSelectAll(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}crossJoin(...e){return this.#t("CrossJoin",e)}innerJoinLateral(...e){return this.#t("LateralInnerJoin",e)}leftJoinLateral(...e){return this.#t("LateralLeftJoin",e)}crossJoinLateral(...e){return this.#t("LateralCrossJoin",e)}crossApply(...e){return this.#t("CrossApply",e)}outerApply(...e){return this.#t("OuterApply",e)}#t(e,I){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithJoin(this.#e.queryNode,parseJoin(e,I))})}orderBy(...e){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithOrderByItems(this.#e.queryNode,parseOrderBy(e))})}groupBy(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithGroupByItems(this.#e.queryNode,parseGroupBy(e))})}limit(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithLimit(this.#e.queryNode,LimitNode.create(parseValueExpression(e)))})}offset(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithOffset(this.#e.queryNode,OffsetNode.create(parseValueExpression(e)))})}fetch(e,I="only"){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithFetch(this.#e.queryNode,parseFetch(e,I))})}top(e,I){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithTop(this.#e.queryNode,parseTop(e,I))})}union(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithSetOperations(this.#e.queryNode,parseSetOperations("union",e,!1))})}unionAll(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithSetOperations(this.#e.queryNode,parseSetOperations("union",e,!0))})}intersect(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithSetOperations(this.#e.queryNode,parseSetOperations("intersect",e,!1))})}intersectAll(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithSetOperations(this.#e.queryNode,parseSetOperations("intersect",e,!0))})}except(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithSetOperations(this.#e.queryNode,parseSetOperations("except",e,!1))})}exceptAll(e){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithSetOperations(this.#e.queryNode,parseSetOperations("except",e,!0))})}as(e){return new AliasedSelectQueryBuilderImpl(this,e)}clearSelect(){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithoutSelections(this.#e.queryNode)})}clearWhere(){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithoutWhere(this.#e.queryNode)})}clearLimit(){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithoutLimit(this.#e.queryNode)})}clearOffset(){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithoutOffset(this.#e.queryNode)})}clearOrderBy(){return new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithoutOrderBy(this.#e.queryNode)})}clearGroupBy(){return new SelectQueryBuilderImpl({...this.#e,queryNode:SelectQueryNode.cloneWithoutGroupBy(this.#e.queryNode)})}$call(e){return e(this)}$if(e,I){return e?I(this):new SelectQueryBuilderImpl({...this.#e})}$castTo(){return new SelectQueryBuilderImpl(this.#e)}$narrowType(){return new SelectQueryBuilderImpl(this.#e)}$assertType(){return new SelectQueryBuilderImpl(this.#e)}$asTuple(){return new ExpressionWrapper(this.toOperationNode())}$asScalar(){return new ExpressionWrapper(this.toOperationNode())}withPlugin(e){return new SelectQueryBuilderImpl({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){const e=this.compile();return(await this.#e.executor.executeQuery(e)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=NoResultError){const I=await this.executeTakeFirst();if(I===void 0)throw isNoResultErrorConstructor(e)?new e(this.toOperationNode()):e(this.toOperationNode());return I}async*stream(e=100){const I=this.compile(),B=this.#e.executor.stream(I,e);for await(const tr of B)yield*tr.rows}async explain(e,I){return await new SelectQueryBuilderImpl({...this.#e,queryNode:QueryNode.cloneWithExplain(this.#e.queryNode,e,I)}).execute()}}function createSelectQueryBuilder(t){return new SelectQueryBuilderImpl(t)}class AliasedSelectQueryBuilderImpl{#e;#t;constructor(e,I){this.#e=e,this.#t=I}get expression(){return this.#e}get alias(){return this.#t}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return AliasNode.create(this.#e.toOperationNode(),IdentifierNode.create(this.#t))}}const AggregateFunctionNode=freeze({is(t){return t.kind==="AggregateFunctionNode"},create(t,e=[]){return freeze({kind:"AggregateFunctionNode",func:t,aggregated:e})},cloneWithDistinct(t){return freeze({...t,distinct:!0})},cloneWithOrderBy(t,e,I=!1){const B=I?"withinGroup":"orderBy";return freeze({...t,[B]:t[B]?OrderByNode.cloneWithItems(t[B],e):OrderByNode.create(e)})},cloneWithFilter(t,e){return freeze({...t,filter:t.filter?WhereNode.cloneWithOperation(t.filter,"And",e):WhereNode.create(e)})},cloneWithOrFilter(t,e){return freeze({...t,filter:t.filter?WhereNode.cloneWithOperation(t.filter,"Or",e):WhereNode.create(e)})},cloneWithOver(t,e){return freeze({...t,over:e})}}),FunctionNode=freeze({is(t){return t.kind==="FunctionNode"},create(t,e){return freeze({kind:"FunctionNode",func:t,arguments:e})}});class AggregateFunctionBuilder{#e;constructor(e){this.#e=freeze(e)}get expressionType(){}as(e){return new AliasedAggregateFunctionBuilder(this,e)}distinct(){return new AggregateFunctionBuilder({...this.#e,aggregateFunctionNode:AggregateFunctionNode.cloneWithDistinct(this.#e.aggregateFunctionNode)})}orderBy(...e){return new AggregateFunctionBuilder({...this.#e,aggregateFunctionNode:QueryNode.cloneWithOrderByItems(this.#e.aggregateFunctionNode,parseOrderBy(e))})}clearOrderBy(){return new AggregateFunctionBuilder({...this.#e,aggregateFunctionNode:QueryNode.cloneWithoutOrderBy(this.#e.aggregateFunctionNode)})}withinGroupOrderBy(...e){return new AggregateFunctionBuilder({...this.#e,aggregateFunctionNode:AggregateFunctionNode.cloneWithOrderBy(this.#e.aggregateFunctionNode,parseOrderBy(e),!0)})}filterWhere(...e){return new AggregateFunctionBuilder({...this.#e,aggregateFunctionNode:AggregateFunctionNode.cloneWithFilter(this.#e.aggregateFunctionNode,parseValueBinaryOperationOrExpression(e))})}filterWhereRef(e,I,B){return new AggregateFunctionBuilder({...this.#e,aggregateFunctionNode:AggregateFunctionNode.cloneWithFilter(this.#e.aggregateFunctionNode,parseReferentialBinaryOperation(e,I,B))})}over(e){const I=createOverBuilder();return new AggregateFunctionBuilder({...this.#e,aggregateFunctionNode:AggregateFunctionNode.cloneWithOver(this.#e.aggregateFunctionNode,(e?e(I):I).toOperationNode())})}$call(e){return e(this)}$castTo(){return new AggregateFunctionBuilder(this.#e)}$notNull(){return new AggregateFunctionBuilder(this.#e)}toOperationNode(){return this.#e.aggregateFunctionNode}}class AliasedAggregateFunctionBuilder{#e;#t;constructor(e,I){this.#e=e,this.#t=I}get expression(){return this.#e}get alias(){return this.#t}toOperationNode(){return AliasNode.create(this.#e.toOperationNode(),IdentifierNode.create(this.#t))}}function createFunctionModule(){const t=(I,B)=>new ExpressionWrapper(FunctionNode.create(I,parseReferenceExpressionOrList(B??[]))),e=(I,B)=>new AggregateFunctionBuilder({aggregateFunctionNode:AggregateFunctionNode.create(I,B?parseReferenceExpressionOrList(B):void 0)});return Object.assign(t,{agg:e,avg(I){return e("avg",[I])},coalesce(...I){return t("coalesce",I)},count(I){return e("count",[I])},countAll(I){return new AggregateFunctionBuilder({aggregateFunctionNode:AggregateFunctionNode.create("count",parseSelectAll(I))})},max(I){return e("max",[I])},min(I){return e("min",[I])},sum(I){return e("sum",[I])},any(I){return t("any",[I])},jsonAgg(I){return new AggregateFunctionBuilder({aggregateFunctionNode:AggregateFunctionNode.create("json_agg",[isString(I)?parseTable(I):I.toOperationNode()])})},toJson(I){return new ExpressionWrapper(FunctionNode.create("to_json",[isString(I)?parseTable(I):I.toOperationNode()]))}})}const UnaryOperationNode=freeze({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return freeze({kind:"UnaryOperationNode",operator:t,operand:e})}});function parseUnaryOperation(t,e){return UnaryOperationNode.create(OperatorNode.create(t),parseReferenceExpression(e))}const CaseNode=freeze({is(t){return t.kind==="CaseNode"},create(t){return freeze({kind:"CaseNode",value:t})},cloneWithWhen(t,e){return freeze({...t,when:freeze(t.when?[...t.when,e]:[e])})},cloneWithThen(t,e){return freeze({...t,when:t.when?freeze([...t.when.slice(0,-1),WhenNode.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return freeze({...t,...e})}});class CaseBuilder{#e;constructor(e){this.#e=freeze(e)}when(...e){return new CaseThenBuilder({...this.#e,node:CaseNode.cloneWithWhen(this.#e.node,WhenNode.create(parseValueBinaryOperationOrExpression(e)))})}}class CaseThenBuilder{#e;constructor(e){this.#e=freeze(e)}then(e){return new CaseWhenBuilder({...this.#e,node:CaseNode.cloneWithThen(this.#e.node,isSafeImmediateValue(e)?parseSafeImmediateValue(e):parseValueExpression(e))})}}class CaseWhenBuilder{#e;constructor(e){this.#e=freeze(e)}when(...e){return new CaseThenBuilder({...this.#e,node:CaseNode.cloneWithWhen(this.#e.node,WhenNode.create(parseValueBinaryOperationOrExpression(e)))})}else(e){return new CaseEndBuilder({...this.#e,node:CaseNode.cloneWith(this.#e.node,{else:isSafeImmediateValue(e)?parseSafeImmediateValue(e):parseValueExpression(e)})})}end(){return new ExpressionWrapper(CaseNode.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new ExpressionWrapper(CaseNode.cloneWith(this.#e.node,{isStatement:!0}))}}class CaseEndBuilder{#e;constructor(e){this.#e=freeze(e)}end(){return new ExpressionWrapper(CaseNode.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new ExpressionWrapper(CaseNode.cloneWith(this.#e.node,{isStatement:!0}))}}const JSONPathLegNode=freeze({is(t){return t.kind==="JSONPathLegNode"},create(t,e){return freeze({kind:"JSONPathLegNode",type:t,value:e})}});class JSONPathBuilder{#e;constructor(e){this.#e=e}at(e){return this.#t("ArrayLocation",e)}key(e){return this.#t("Member",e)}#t(e,I){return JSONReferenceNode.is(this.#e)?new TraversedJSONPathBuilder(JSONReferenceNode.cloneWithTraversal(this.#e,JSONPathNode.is(this.#e.traversal)?JSONPathNode.cloneWithLeg(this.#e.traversal,JSONPathLegNode.create(e,I)):JSONOperatorChainNode.cloneWithValue(this.#e.traversal,ValueNode.createImmediate(I)))):new TraversedJSONPathBuilder(JSONPathNode.cloneWithLeg(this.#e,JSONPathLegNode.create(e,I)))}}class TraversedJSONPathBuilder extends JSONPathBuilder{#e;constructor(e){super(e),this.#e=e}get expressionType(){}as(e){return new AliasedJSONPathBuilder(this,e)}$castTo(){return new TraversedJSONPathBuilder(this.#e)}$notNull(){return new TraversedJSONPathBuilder(this.#e)}toOperationNode(){return this.#e}}class AliasedJSONPathBuilder{#e;#t;constructor(e,I){this.#e=e,this.#t=I}get expression(){return this.#e}get alias(){return this.#t}toOperationNode(){return AliasNode.create(this.#e.toOperationNode(),isOperationNodeSource(this.#t)?this.#t.toOperationNode():IdentifierNode.create(this.#t))}}const TupleNode=freeze({is(t){return t.kind==="TupleNode"},create(t){return freeze({kind:"TupleNode",values:freeze(t)})}}),SIMPLE_COLUMN_DATA_TYPES=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],COLUMN_DATA_TYPE_REGEX=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],DataTypeNode=freeze({is(t){return t.kind==="DataTypeNode"},create(t){return freeze({kind:"DataTypeNode",dataType:t})}});function isColumnDataType(t){return!!(SIMPLE_COLUMN_DATA_TYPES.includes(t)||COLUMN_DATA_TYPE_REGEX.some(e=>e.test(t)))}function parseDataTypeExpression(t){if(isOperationNodeSource(t))return t.toOperationNode();if(isColumnDataType(t))return DataTypeNode.create(t);throw new Error(`invalid column data type ${JSON.stringify(t)}`)}const CastNode=freeze({is(t){return t.kind==="CastNode"},create(t,e){return freeze({kind:"CastNode",expression:t,dataType:e})}});function createExpressionBuilder(t=NOOP_QUERY_EXECUTOR){function e(tr,rr,ir){return new ExpressionWrapper(parseValueBinaryOperation(tr,rr,ir))}function I(tr,rr){return new ExpressionWrapper(parseUnaryOperation(tr,rr))}const B=Object.assign(e,{fn:void 0,eb:void 0,selectFrom(tr){return createSelectQueryBuilder({queryId:createQueryId(),executor:t,queryNode:SelectQueryNode.createFrom(parseTableExpressionOrList(tr))})},case(tr){return new CaseBuilder({node:CaseNode.create(isUndefined(tr)?void 0:parseReferenceExpression(tr))})},ref(tr,rr){return isUndefined(rr)?new ExpressionWrapper(parseStringReference(tr)):new JSONPathBuilder(parseJSONReference(tr,rr))},jsonPath(){return new JSONPathBuilder(JSONPathNode.create())},table(tr){return new ExpressionWrapper(parseTable(tr))},val(tr){return new ExpressionWrapper(parseValueExpression(tr))},refTuple(...tr){return new ExpressionWrapper(TupleNode.create(tr.map(parseReferenceExpression)))},tuple(...tr){return new ExpressionWrapper(TupleNode.create(tr.map(parseValueExpression)))},lit(tr){return new ExpressionWrapper(parseSafeImmediateValue(tr))},unary:I,not(tr){return I("not",tr)},exists(tr){return I("exists",tr)},neg(tr){return I("-",tr)},between(tr,rr,ir){return new ExpressionWrapper(BinaryOperationNode.create(parseReferenceExpression(tr),OperatorNode.create("between"),AndNode.create(parseValueExpression(rr),parseValueExpression(ir))))},betweenSymmetric(tr,rr,ir){return new ExpressionWrapper(BinaryOperationNode.create(parseReferenceExpression(tr),OperatorNode.create("between symmetric"),AndNode.create(parseValueExpression(rr),parseValueExpression(ir))))},and(tr){return isReadonlyArray(tr)?new ExpressionWrapper(parseFilterList(tr,"and")):new ExpressionWrapper(parseFilterObject(tr,"and"))},or(tr){return isReadonlyArray(tr)?new ExpressionWrapper(parseFilterList(tr,"or")):new ExpressionWrapper(parseFilterObject(tr,"or"))},parens(...tr){const rr=parseValueBinaryOperationOrExpression(tr);return ParensNode.is(rr)?new ExpressionWrapper(rr):new ExpressionWrapper(ParensNode.create(rr))},cast(tr,rr){return new ExpressionWrapper(CastNode.create(parseReferenceExpression(tr),parseDataTypeExpression(rr)))},withSchema(tr){return createExpressionBuilder(t.withPluginAtFront(new WithSchemaPlugin(tr)))}});return B.fn=createFunctionModule(),B.eb=B,B}function expressionBuilder(t){return createExpressionBuilder()}function parseExpression(t){if(isOperationNodeSource(t))return t.toOperationNode();if(isFunction(t))return t(expressionBuilder()).toOperationNode();throw new Error(`invalid expression: ${JSON.stringify(t)}`)}function parseAliasedExpression(t){if(isOperationNodeSource(t))return t.toOperationNode();if(isFunction(t))return t(expressionBuilder()).toOperationNode();throw new Error(`invalid aliased expression: ${JSON.stringify(t)}`)}function isExpressionOrFactory(t){return isExpression(t)||isAliasedExpression(t)||isFunction(t)}class DynamicTableBuilder{#e;get table(){return this.#e}constructor(e){this.#e=e}as(e){return new AliasedDynamicTableBuilder(this.#e,e)}}class AliasedDynamicTableBuilder{#e;#t;get table(){return this.#e}get alias(){return this.#t}constructor(e,I){this.#e=e,this.#t=I}toOperationNode(){return AliasNode.create(parseTable(this.#e),IdentifierNode.create(this.#t))}}function isAliasedDynamicTableBuilder(t){return isObject(t)&&isOperationNodeSource(t)&&isString(t.table)&&isString(t.alias)}function parseTableExpressionOrList(t){return isReadonlyArray(t)?t.map(e=>parseTableExpression(e)):[parseTableExpression(t)]}function parseTableExpression(t){return isString(t)?parseAliasedTable(t):isAliasedDynamicTableBuilder(t)?t.toOperationNode():parseAliasedExpression(t)}function parseAliasedTable(t){const e=" as ";if(t.includes(e)){const[I,B]=t.split(e).map(trim$1);return AliasNode.create(parseTable(I),IdentifierNode.create(B))}else return parseTable(t)}function parseTable(t){if(t.includes(".")){const[I,B]=t.split(".").map(trim$1);return TableNode.createWithSchema(I,B)}else return TableNode.create(t)}function trim$1(t){return t.trim()}const AddColumnNode=freeze({is(t){return t.kind==="AddColumnNode"},create(t){return freeze({kind:"AddColumnNode",column:t})}}),ColumnDefinitionNode=freeze({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return freeze({kind:"ColumnDefinitionNode",column:ColumnNode.create(t),dataType:e})},cloneWithFrontModifier(t,e){return freeze({...t,frontModifiers:t.frontModifiers?freeze([...t.frontModifiers,e]):[e]})},cloneWithEndModifier(t,e){return freeze({...t,endModifiers:t.endModifiers?freeze([...t.endModifiers,e]):[e]})},cloneWith(t,e){return freeze({...t,...e})}}),DropColumnNode=freeze({is(t){return t.kind==="DropColumnNode"},create(t){return freeze({kind:"DropColumnNode",column:ColumnNode.create(t)})}}),RenameColumnNode=freeze({is(t){return t.kind==="RenameColumnNode"},create(t,e){return freeze({kind:"RenameColumnNode",column:ColumnNode.create(t),renameTo:ColumnNode.create(e)})}}),CheckConstraintNode=freeze({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return freeze({kind:"CheckConstraintNode",expression:t,name:e?IdentifierNode.create(e):void 0})}}),ON_MODIFY_FOREIGN_ACTIONS=["no action","restrict","cascade","set null","set default"],ReferencesNode=freeze({is(t){return t.kind==="ReferencesNode"},create(t,e){return freeze({kind:"ReferencesNode",table:t,columns:freeze([...e])})},cloneWithOnDelete(t,e){return freeze({...t,onDelete:e})},cloneWithOnUpdate(t,e){return freeze({...t,onUpdate:e})}});function parseDefaultValueExpression(t){return isOperationNodeSource(t)?t.toOperationNode():ValueNode.createImmediate(t)}const GeneratedNode=freeze({is(t){return t.kind==="GeneratedNode"},create(t){return freeze({kind:"GeneratedNode",...t})},createWithExpression(t){return freeze({kind:"GeneratedNode",always:!0,expression:t})},cloneWith(t,e){return freeze({...t,...e})}}),DefaultValueNode=freeze({is(t){return t.kind==="DefaultValueNode"},create(t){return freeze({kind:"DefaultValueNode",defaultValue:t})}});function parseOnModifyForeignAction(t){if(ON_MODIFY_FOREIGN_ACTIONS.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}class ColumnDefinitionBuilder{#e;constructor(e){this.#e=e}autoIncrement(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{autoIncrement:!0}))}identity(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{identity:!0}))}primaryKey(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{primaryKey:!0}))}references(e){const I=parseStringReference(e);if(!I.table||SelectAllNode.is(I.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{references:ReferencesNode.create(I.table,[I.column])}))}onDelete(e){if(!this.#e.references)throw new Error("on delete constraint can only be added for foreign keys");return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{references:ReferencesNode.cloneWithOnDelete(this.#e.references,parseOnModifyForeignAction(e))}))}onUpdate(e){if(!this.#e.references)throw new Error("on update constraint can only be added for foreign keys");return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{references:ReferencesNode.cloneWithOnUpdate(this.#e.references,parseOnModifyForeignAction(e))}))}unique(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{unique:!0}))}notNull(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{notNull:!0}))}unsigned(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{unsigned:!0}))}defaultTo(e){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{defaultTo:DefaultValueNode.create(parseDefaultValueExpression(e))}))}check(e){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{check:CheckConstraintNode.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{generated:GeneratedNode.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{generated:GeneratedNode.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{generated:GeneratedNode.create({identity:!0,byDefault:!0})}))}stored(){if(!this.#e.generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{generated:GeneratedNode.cloneWith(this.#e.generated,{stored:!0})}))}modifyFront(e){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWithFrontModifier(this.#e,e.toOperationNode()))}nullsNotDistinct(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{nullsNotDistinct:!0}))}ifNotExists(){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#e,{ifNotExists:!0}))}modifyEnd(e){return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWithEndModifier(this.#e,e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return this.#e}}const ModifyColumnNode=freeze({is(t){return t.kind==="ModifyColumnNode"},create(t){return freeze({kind:"ModifyColumnNode",column:t})}}),ForeignKeyConstraintNode=freeze({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,I,B){return freeze({kind:"ForeignKeyConstraintNode",columns:t,references:ReferencesNode.create(e,I),name:B?IdentifierNode.create(B):void 0})},cloneWith(t,e){return freeze({...t,...e})}});class ForeignKeyConstraintBuilder{#e;constructor(e){this.#e=e}onDelete(e){return new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.cloneWith(this.#e,{onDelete:parseOnModifyForeignAction(e)}))}onUpdate(e){return new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.cloneWith(this.#e,{onUpdate:parseOnModifyForeignAction(e)}))}deferrable(){return new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}}const AddConstraintNode=freeze({is(t){return t.kind==="AddConstraintNode"},create(t){return freeze({kind:"AddConstraintNode",constraint:t})}}),UniqueConstraintNode=freeze({is(t){return t.kind==="UniqueConstraintNode"},create(t,e,I){return freeze({kind:"UniqueConstraintNode",columns:freeze(t.map(ColumnNode.create)),name:e?IdentifierNode.create(e):void 0,nullsNotDistinct:I})},cloneWith(t,e){return freeze({...t,...e})}}),DropConstraintNode=freeze({is(t){return t.kind==="DropConstraintNode"},create(t){return freeze({kind:"DropConstraintNode",constraintName:IdentifierNode.create(t)})},cloneWith(t,e){return freeze({...t,...e})}}),AlterColumnNode=freeze({is(t){return t.kind==="AlterColumnNode"},create(t,e,I){return freeze({kind:"AlterColumnNode",column:ColumnNode.create(t),[e]:I})}});class AlterColumnBuilder{#e;constructor(e){this.#e=e}setDataType(e){return new AlteredColumnBuilder(AlterColumnNode.create(this.#e,"dataType",parseDataTypeExpression(e)))}setDefault(e){return new AlteredColumnBuilder(AlterColumnNode.create(this.#e,"setDefault",parseDefaultValueExpression(e)))}dropDefault(){return new AlteredColumnBuilder(AlterColumnNode.create(this.#e,"dropDefault",!0))}setNotNull(){return new AlteredColumnBuilder(AlterColumnNode.create(this.#e,"setNotNull",!0))}dropNotNull(){return new AlteredColumnBuilder(AlterColumnNode.create(this.#e,"dropNotNull",!0))}$call(e){return e(this)}}class AlteredColumnBuilder{#e;constructor(e){this.#e=e}toOperationNode(){return this.#e}}class AlterTableExecutor{#e;constructor(e){this.#e=freeze(e)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class AlterTableAddForeignKeyConstraintBuilder{#e;constructor(e){this.#e=freeze(e)}onDelete(e){return new AlterTableAddForeignKeyConstraintBuilder({...this.#e,constraintBuilder:this.#e.constraintBuilder.onDelete(e)})}onUpdate(e){return new AlterTableAddForeignKeyConstraintBuilder({...this.#e,constraintBuilder:this.#e.constraintBuilder.onUpdate(e)})}deferrable(){return new AlterTableAddForeignKeyConstraintBuilder({...this.#e,constraintBuilder:this.#e.constraintBuilder.deferrable()})}notDeferrable(){return new AlterTableAddForeignKeyConstraintBuilder({...this.#e,constraintBuilder:this.#e.constraintBuilder.notDeferrable()})}initiallyDeferred(){return new AlterTableAddForeignKeyConstraintBuilder({...this.#e,constraintBuilder:this.#e.constraintBuilder.initiallyDeferred()})}initiallyImmediate(){return new AlterTableAddForeignKeyConstraintBuilder({...this.#e,constraintBuilder:this.#e.constraintBuilder.initiallyImmediate()})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(AlterTableNode.cloneWithTableProps(this.#e.node,{addConstraint:AddConstraintNode.create(this.#e.constraintBuilder.toOperationNode())}),this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class AlterTableDropConstraintBuilder{#e;constructor(e){this.#e=freeze(e)}ifExists(){return new AlterTableDropConstraintBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{dropConstraint:DropConstraintNode.cloneWith(this.#e.node.dropConstraint,{ifExists:!0})})})}cascade(){return new AlterTableDropConstraintBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{dropConstraint:DropConstraintNode.cloneWith(this.#e.node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new AlterTableDropConstraintBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{dropConstraint:DropConstraintNode.cloneWith(this.#e.node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}const PrimaryKeyConstraintNode=freeze({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return freeze({kind:"PrimaryKeyConstraintNode",columns:freeze(t.map(ColumnNode.create)),name:e?IdentifierNode.create(e):void 0})},cloneWith(t,e){return freeze({...t,...e})}}),AddIndexNode=freeze({is(t){return t.kind==="AddIndexNode"},create(t){return freeze({kind:"AddIndexNode",name:IdentifierNode.create(t)})},cloneWith(t,e){return freeze({...t,...e})},cloneWithColumns(t,e){return freeze({...t,columns:[...t.columns||[],...e]})}});class AlterTableAddIndexBuilder{#e;constructor(e){this.#e=freeze(e)}unique(){return new AlterTableAddIndexBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addIndex:AddIndexNode.cloneWith(this.#e.node.addIndex,{unique:!0})})})}column(e){return new AlterTableAddIndexBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addIndex:AddIndexNode.cloneWithColumns(this.#e.node.addIndex,[parseOrderedColumnName(e)])})})}columns(e){return new AlterTableAddIndexBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addIndex:AddIndexNode.cloneWithColumns(this.#e.node.addIndex,e.map(parseOrderedColumnName))})})}expression(e){return new AlterTableAddIndexBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addIndex:AddIndexNode.cloneWithColumns(this.#e.node.addIndex,[e.toOperationNode()])})})}using(e){return new AlterTableAddIndexBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addIndex:AddIndexNode.cloneWith(this.#e.node.addIndex,{using:RawNode.createWithSql(e)})})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class UniqueConstraintNodeBuilder{#e;constructor(e){this.#e=e}nullsNotDistinct(){return new UniqueConstraintNodeBuilder(UniqueConstraintNode.cloneWith(this.#e,{nullsNotDistinct:!0}))}deferrable(){return new UniqueConstraintNodeBuilder(UniqueConstraintNode.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new UniqueConstraintNodeBuilder(UniqueConstraintNode.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new UniqueConstraintNodeBuilder(UniqueConstraintNode.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new UniqueConstraintNodeBuilder(UniqueConstraintNode.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}}class PrimaryKeyConstraintBuilder{#e;constructor(e){this.#e=e}deferrable(){return new PrimaryKeyConstraintBuilder(PrimaryKeyConstraintNode.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new PrimaryKeyConstraintBuilder(PrimaryKeyConstraintNode.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new PrimaryKeyConstraintBuilder(PrimaryKeyConstraintNode.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new PrimaryKeyConstraintBuilder(PrimaryKeyConstraintNode.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}}class CheckConstraintBuilder{#e;constructor(e){this.#e=e}$call(e){return e(this)}toOperationNode(){return this.#e}}const RenameConstraintNode=freeze({is(t){return t.kind==="RenameConstraintNode"},create(t,e){return freeze({kind:"RenameConstraintNode",oldName:IdentifierNode.create(t),newName:IdentifierNode.create(e)})}});class AlterTableBuilder{#e;constructor(e){this.#e=freeze(e)}renameTo(e){return new AlterTableExecutor({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{renameTo:parseTable(e)})})}setSchema(e){return new AlterTableExecutor({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{setSchema:IdentifierNode.create(e)})})}alterColumn(e,I){const B=I(new AlterColumnBuilder(e));return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,B.toOperationNode())})}dropColumn(e){return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,DropColumnNode.create(e))})}renameColumn(e,I){return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,RenameColumnNode.create(e,I))})}addColumn(e,I,B=noop){const tr=B(new ColumnDefinitionBuilder(ColumnDefinitionNode.create(e,parseDataTypeExpression(I))));return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,AddColumnNode.create(tr.toOperationNode()))})}modifyColumn(e,I,B=noop){const tr=B(new ColumnDefinitionBuilder(ColumnDefinitionNode.create(e,parseDataTypeExpression(I))));return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,ModifyColumnNode.create(tr.toOperationNode()))})}addUniqueConstraint(e,I,B=noop){const tr=B(new UniqueConstraintNodeBuilder(UniqueConstraintNode.create(I,e)));return new AlterTableExecutor({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addConstraint:AddConstraintNode.create(tr.toOperationNode())})})}addCheckConstraint(e,I,B=noop){const tr=B(new CheckConstraintBuilder(CheckConstraintNode.create(I.toOperationNode(),e)));return new AlterTableExecutor({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addConstraint:AddConstraintNode.create(tr.toOperationNode())})})}addForeignKeyConstraint(e,I,B,tr,rr=noop){const ir=rr(new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.create(I.map(ColumnNode.create),parseTable(B),tr.map(ColumnNode.create),e)));return new AlterTableAddForeignKeyConstraintBuilder({...this.#e,constraintBuilder:ir})}addPrimaryKeyConstraint(e,I,B=noop){const tr=B(new PrimaryKeyConstraintBuilder(PrimaryKeyConstraintNode.create(I,e)));return new AlterTableExecutor({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addConstraint:AddConstraintNode.create(tr.toOperationNode())})})}dropConstraint(e){return new AlterTableDropConstraintBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{dropConstraint:DropConstraintNode.create(e)})})}renameConstraint(e,I){return new AlterTableDropConstraintBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{renameConstraint:RenameConstraintNode.create(e,I)})})}addIndex(e){return new AlterTableAddIndexBuilder({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{addIndex:AddIndexNode.create(e)})})}dropIndex(e){return new AlterTableExecutor({...this.#e,node:AlterTableNode.cloneWithTableProps(this.#e.node,{dropIndex:DropIndexNode.create(e)})})}$call(e){return e(this)}}class AlterTableColumnAlteringBuilder{#e;constructor(e){this.#e=freeze(e)}alterColumn(e,I){const B=I(new AlterColumnBuilder(e));return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,B.toOperationNode())})}dropColumn(e){return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,DropColumnNode.create(e))})}renameColumn(e,I){return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,RenameColumnNode.create(e,I))})}addColumn(e,I,B=noop){const tr=B(new ColumnDefinitionBuilder(ColumnDefinitionNode.create(e,parseDataTypeExpression(I))));return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,AddColumnNode.create(tr.toOperationNode()))})}modifyColumn(e,I,B=noop){const tr=B(new ColumnDefinitionBuilder(ColumnDefinitionNode.create(e,parseDataTypeExpression(I))));return new AlterTableColumnAlteringBuilder({...this.#e,node:AlterTableNode.cloneWithColumnAlteration(this.#e.node,ModifyColumnNode.create(tr.toOperationNode()))})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class ImmediateValueTransformer extends OperationNodeTransformer{transformPrimitiveValueList(e){return ValueListNode.create(e.values.map(ValueNode.createImmediate))}transformValue(e){return ValueNode.createImmediate(e.value)}}class CreateIndexBuilder{#e;constructor(e){this.#e=freeze(e)}ifNotExists(){return new CreateIndexBuilder({...this.#e,node:CreateIndexNode.cloneWith(this.#e.node,{ifNotExists:!0})})}unique(){return new CreateIndexBuilder({...this.#e,node:CreateIndexNode.cloneWith(this.#e.node,{unique:!0})})}nullsNotDistinct(){return new CreateIndexBuilder({...this.#e,node:CreateIndexNode.cloneWith(this.#e.node,{nullsNotDistinct:!0})})}on(e){return new CreateIndexBuilder({...this.#e,node:CreateIndexNode.cloneWith(this.#e.node,{table:parseTable(e)})})}column(e){return new CreateIndexBuilder({...this.#e,node:CreateIndexNode.cloneWithColumns(this.#e.node,[parseOrderedColumnName(e)])})}columns(e){return new CreateIndexBuilder({...this.#e,node:CreateIndexNode.cloneWithColumns(this.#e.node,e.map(parseOrderedColumnName))})}expression(e){return new CreateIndexBuilder({...this.#e,node:CreateIndexNode.cloneWithColumns(this.#e.node,[e.toOperationNode()])})}using(e){return new CreateIndexBuilder({...this.#e,node:CreateIndexNode.cloneWith(this.#e.node,{using:RawNode.createWithSql(e)})})}where(...e){const I=new ImmediateValueTransformer;return new CreateIndexBuilder({...this.#e,node:QueryNode.cloneWithWhere(this.#e.node,I.transformNode(parseValueBinaryOperationOrExpression(e),this.#e.queryId))})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class CreateSchemaBuilder{#e;constructor(e){this.#e=freeze(e)}ifNotExists(){return new CreateSchemaBuilder({...this.#e,node:CreateSchemaNode.cloneWith(this.#e.node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}function parseOnCommitAction(t){if(ON_COMMIT_ACTIONS.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}class CreateTableBuilder{#e;constructor(e){this.#e=freeze(e)}temporary(){return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWith(this.#e.node,{temporary:!0})})}onCommit(e){return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWith(this.#e.node,{onCommit:parseOnCommitAction(e)})})}ifNotExists(){return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWith(this.#e.node,{ifNotExists:!0})})}addColumn(e,I,B=noop){const tr=B(new ColumnDefinitionBuilder(ColumnDefinitionNode.create(e,parseDataTypeExpression(I))));return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWithColumn(this.#e.node,tr.toOperationNode())})}addPrimaryKeyConstraint(e,I,B=noop){const tr=B(new PrimaryKeyConstraintBuilder(PrimaryKeyConstraintNode.create(I,e)));return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWithConstraint(this.#e.node,tr.toOperationNode())})}addUniqueConstraint(e,I,B=noop){const tr=B(new UniqueConstraintNodeBuilder(UniqueConstraintNode.create(I,e)));return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWithConstraint(this.#e.node,tr.toOperationNode())})}addCheckConstraint(e,I,B=noop){const tr=B(new CheckConstraintBuilder(CheckConstraintNode.create(I.toOperationNode(),e)));return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWithConstraint(this.#e.node,tr.toOperationNode())})}addForeignKeyConstraint(e,I,B,tr,rr=noop){const ir=rr(new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.create(I.map(ColumnNode.create),parseTable(B),tr.map(ColumnNode.create),e)));return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWithConstraint(this.#e.node,ir.toOperationNode())})}modifyFront(e){return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWithFrontModifier(this.#e.node,e.toOperationNode())})}modifyEnd(e){return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWithEndModifier(this.#e.node,e.toOperationNode())})}as(e){return new CreateTableBuilder({...this.#e,node:CreateTableNode.cloneWith(this.#e.node,{selectQuery:parseExpression(e)})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class DropIndexBuilder{#e;constructor(e){this.#e=freeze(e)}on(e){return new DropIndexBuilder({...this.#e,node:DropIndexNode.cloneWith(this.#e.node,{table:parseTable(e)})})}ifExists(){return new DropIndexBuilder({...this.#e,node:DropIndexNode.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new DropIndexBuilder({...this.#e,node:DropIndexNode.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class DropSchemaBuilder{#e;constructor(e){this.#e=freeze(e)}ifExists(){return new DropSchemaBuilder({...this.#e,node:DropSchemaNode.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new DropSchemaBuilder({...this.#e,node:DropSchemaNode.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class DropTableBuilder{#e;constructor(e){this.#e=freeze(e)}ifExists(){return new DropTableBuilder({...this.#e,node:DropTableNode.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new DropTableBuilder({...this.#e,node:DropTableNode.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}const CreateViewNode=freeze({is(t){return t.kind==="CreateViewNode"},create(t){return freeze({kind:"CreateViewNode",name:SchemableIdentifierNode.create(t)})},cloneWith(t,e){return freeze({...t,...e})}});class ImmediateValuePlugin{#e=new ImmediateValueTransformer;transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}transformResult(e){return Promise.resolve(e.result)}}class CreateViewBuilder{#e;constructor(e){this.#e=freeze(e)}temporary(){return new CreateViewBuilder({...this.#e,node:CreateViewNode.cloneWith(this.#e.node,{temporary:!0})})}materialized(){return new CreateViewBuilder({...this.#e,node:CreateViewNode.cloneWith(this.#e.node,{materialized:!0})})}ifNotExists(){return new CreateViewBuilder({...this.#e,node:CreateViewNode.cloneWith(this.#e.node,{ifNotExists:!0})})}orReplace(){return new CreateViewBuilder({...this.#e,node:CreateViewNode.cloneWith(this.#e.node,{orReplace:!0})})}columns(e){return new CreateViewBuilder({...this.#e,node:CreateViewNode.cloneWith(this.#e.node,{columns:e.map(parseColumnName)})})}as(e){const I=e.withPlugin(new ImmediateValuePlugin).toOperationNode();return new CreateViewBuilder({...this.#e,node:CreateViewNode.cloneWith(this.#e.node,{as:I})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}const DropViewNode=freeze({is(t){return t.kind==="DropViewNode"},create(t){return freeze({kind:"DropViewNode",name:SchemableIdentifierNode.create(t)})},cloneWith(t,e){return freeze({...t,...e})}});class DropViewBuilder{#e;constructor(e){this.#e=freeze(e)}materialized(){return new DropViewBuilder({...this.#e,node:DropViewNode.cloneWith(this.#e.node,{materialized:!0})})}ifExists(){return new DropViewBuilder({...this.#e,node:DropViewNode.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new DropViewBuilder({...this.#e,node:DropViewNode.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}const CreateTypeNode=freeze({is(t){return t.kind==="CreateTypeNode"},create(t){return freeze({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return freeze({...t,enum:ValueListNode.create(e.map(ValueNode.createImmediate))})}});class CreateTypeBuilder{#e;constructor(e){this.#e=freeze(e)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}asEnum(e){return new CreateTypeBuilder({...this.#e,node:CreateTypeNode.cloneWithEnum(this.#e.node,e)})}$call(e){return e(this)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}const DropTypeNode=freeze({is(t){return t.kind==="DropTypeNode"},create(t){return freeze({kind:"DropTypeNode",name:t})},cloneWith(t,e){return freeze({...t,...e})}});class DropTypeBuilder{#e;constructor(e){this.#e=freeze(e)}ifExists(){return new DropTypeBuilder({...this.#e,node:DropTypeNode.cloneWith(this.#e.node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}function parseSchemableIdentifier(t){if(t.includes(".")){const I=t.split(".").map(trim);if(I.length===2)return SchemableIdentifierNode.createWithSchema(I[0],I[1]);throw new Error(`invalid schemable identifier ${t}`)}else return SchemableIdentifierNode.create(t)}function trim(t){return t.trim()}const RefreshMaterializedViewNode=freeze({is(t){return t.kind==="RefreshMaterializedViewNode"},create(t){return freeze({kind:"RefreshMaterializedViewNode",name:SchemableIdentifierNode.create(t)})},cloneWith(t,e){return freeze({...t,...e})}});class RefreshMaterializedViewBuilder{#e;constructor(e){this.#e=freeze(e)}concurrently(){return new RefreshMaterializedViewBuilder({...this.#e,node:RefreshMaterializedViewNode.cloneWith(this.#e.node,{concurrently:!0,withNoData:!1})})}withData(){return new RefreshMaterializedViewBuilder({...this.#e,node:RefreshMaterializedViewNode.cloneWith(this.#e.node,{withNoData:!1})})}withNoData(){return new RefreshMaterializedViewBuilder({...this.#e,node:RefreshMaterializedViewNode.cloneWith(this.#e.node,{withNoData:!0,concurrently:!1})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}}class SchemaModule{#e;constructor(e){this.#e=e}createTable(e){return new CreateTableBuilder({queryId:createQueryId(),executor:this.#e,node:CreateTableNode.create(parseTable(e))})}dropTable(e){return new DropTableBuilder({queryId:createQueryId(),executor:this.#e,node:DropTableNode.create(parseTable(e))})}createIndex(e){return new CreateIndexBuilder({queryId:createQueryId(),executor:this.#e,node:CreateIndexNode.create(e)})}dropIndex(e){return new DropIndexBuilder({queryId:createQueryId(),executor:this.#e,node:DropIndexNode.create(e)})}createSchema(e){return new CreateSchemaBuilder({queryId:createQueryId(),executor:this.#e,node:CreateSchemaNode.create(e)})}dropSchema(e){return new DropSchemaBuilder({queryId:createQueryId(),executor:this.#e,node:DropSchemaNode.create(e)})}alterTable(e){return new AlterTableBuilder({queryId:createQueryId(),executor:this.#e,node:AlterTableNode.create(parseTable(e))})}createView(e){return new CreateViewBuilder({queryId:createQueryId(),executor:this.#e,node:CreateViewNode.create(e)})}refreshMaterializedView(e){return new RefreshMaterializedViewBuilder({queryId:createQueryId(),executor:this.#e,node:RefreshMaterializedViewNode.create(e)})}dropView(e){return new DropViewBuilder({queryId:createQueryId(),executor:this.#e,node:DropViewNode.create(e)})}createType(e){return new CreateTypeBuilder({queryId:createQueryId(),executor:this.#e,node:CreateTypeNode.create(parseSchemableIdentifier(e))})}dropType(e){return new DropTypeBuilder({queryId:createQueryId(),executor:this.#e,node:DropTypeNode.create(parseSchemableIdentifier(e))})}withPlugin(e){return new SchemaModule(this.#e.withPlugin(e))}withoutPlugins(){return new SchemaModule(this.#e.withoutPlugins())}withSchema(e){return new SchemaModule(this.#e.withPluginAtFront(new WithSchemaPlugin(e)))}}class DynamicModule{ref(e){return new DynamicReferenceBuilder(e)}table(e){return new DynamicTableBuilder(e)}}class DefaultConnectionProvider{#e;constructor(e){this.#e=e}async provideConnection(e){const I=await this.#e.acquireConnection();try{return await e(I)}finally{await this.#e.releaseConnection(I)}}}class DefaultQueryExecutor extends QueryExecutorBase{#e;#t;#r;constructor(e,I,B,tr=[]){super(tr),this.#e=e,this.#t=I,this.#r=B}get adapter(){return this.#t}compileQuery(e,I){return this.#e.compileQuery(e,I)}provideConnection(e){return this.#r.provideConnection(e)}withPlugins(e){return new DefaultQueryExecutor(this.#e,this.#t,this.#r,[...this.plugins,...e])}withPlugin(e){return new DefaultQueryExecutor(this.#e,this.#t,this.#r,[...this.plugins,e])}withPluginAtFront(e){return new DefaultQueryExecutor(this.#e,this.#t,this.#r,[e,...this.plugins])}withConnectionProvider(e){return new DefaultQueryExecutor(this.#e,this.#t,e,[...this.plugins])}withoutPlugins(){return new DefaultQueryExecutor(this.#e,this.#t,this.#r,[])}}function performanceNow(){return typeof performance<"u"&&isFunction(performance.now)?performance.now():Date.now()}class RuntimeDriver{#e;#t;#r;#n;#o;#l=new WeakSet;constructor(e,I){this.#n=!1,this.#e=e,this.#t=I}async init(){if(this.#o)throw new Error("driver has already been destroyed");this.#r||(this.#r=this.#e.init().then(()=>{this.#n=!0}).catch(e=>(this.#r=void 0,Promise.reject(e)))),await this.#r}async acquireConnection(){if(this.#o)throw new Error("driver has already been destroyed");this.#n||await this.init();const e=await this.#e.acquireConnection();return this.#l.has(e)||(this.#s()&&this.#i(e),this.#l.add(e)),e}async releaseConnection(e){await this.#e.releaseConnection(e)}beginTransaction(e,I){return this.#e.beginTransaction(e,I)}commitTransaction(e){return this.#e.commitTransaction(e)}rollbackTransaction(e){return this.#e.rollbackTransaction(e)}savepoint(e,I,B){if(this.#e.savepoint)return this.#e.savepoint(e,I,B);throw new Error("The `savepoint` method is not supported by this driver")}rollbackToSavepoint(e,I,B){if(this.#e.rollbackToSavepoint)return this.#e.rollbackToSavepoint(e,I,B);throw new Error("The `rollbackToSavepoint` method is not supported by this driver")}releaseSavepoint(e,I,B){if(this.#e.releaseSavepoint)return this.#e.releaseSavepoint(e,I,B);throw new Error("The `releaseSavepoint` method is not supported by this driver")}async destroy(){this.#r&&(await this.#r,this.#o||(this.#o=this.#e.destroy().catch(e=>(this.#o=void 0,Promise.reject(e)))),await this.#o)}#s(){return this.#t.isLevelEnabled("query")||this.#t.isLevelEnabled("error")}#i(e){const I=e.executeQuery,B=e.streamQuery,tr=this;e.executeQuery=async rr=>{let ir;const lr=performanceNow();try{return await I.call(e,rr)}catch(dr){throw ir=dr,await tr.#a(dr,rr,lr),dr}finally{ir||await tr.#d(rr,lr)}},e.streamQuery=async function*(rr,ir){let lr;const dr=performanceNow();try{for await(const mr of B.call(e,rr,ir))yield mr}catch(mr){throw lr=mr,await tr.#a(mr,rr,dr),mr}finally{lr||await tr.#d(rr,dr,!0)}}}async#a(e,I,B){await this.#t.error(()=>({level:"error",error:e,query:I,queryDurationMillis:this.#c(B)}))}async#d(e,I,B=!1){await this.#t.query(()=>({level:"query",isStream:B,query:e,queryDurationMillis:this.#c(I)}))}#c(e){return performanceNow()-e}}const ignoreError=()=>{};class SingleConnectionProvider{#e;#t;constructor(e){this.#e=e}async provideConnection(e){for(;this.#t;)await this.#t.catch(ignoreError);return this.#t=this.#r(e).finally(()=>{this.#t=void 0}),this.#t}async#r(e){return await e(this.#e)}}const TRANSACTION_ACCESS_MODES=["read only","read write"],TRANSACTION_ISOLATION_LEVELS=["read uncommitted","read committed","repeatable read","serializable","snapshot"];function validateTransactionSettings(t){if(t.accessMode&&!TRANSACTION_ACCESS_MODES.includes(t.accessMode))throw new Error(`invalid transaction access mode ${t.accessMode}`);if(t.isolationLevel&&!TRANSACTION_ISOLATION_LEVELS.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}freeze(["query","error"]);class Log{#e;#t;constructor(e){isFunction(e)?(this.#t=e,this.#e=freeze({query:!0,error:!0})):(this.#t=defaultLogger,this.#e=freeze({query:e.includes("query"),error:e.includes("error")}))}isLevelEnabled(e){return this.#e[e]}async query(e){this.#e.query&&await this.#t(e())}async error(e){this.#e.error&&await this.#t(e())}}function defaultLogger(t){if(t.level==="query"){const e=`kysely:query:${t.isStream?"stream:":""}`;console.log(`${e} ${t.query.sql}`),console.log(`${e} duration: ${t.queryDurationMillis.toFixed(1)}ms`)}else t.level==="error"&&(t.error instanceof Error?console.error(`kysely:error: ${t.error.stack??t.error.message}`):console.error(`kysely:error: ${JSON.stringify({error:t.error,query:t.query.sql,queryDurationMillis:t.queryDurationMillis})}`))}function isCompilable(t){return isObject(t)&&isFunction(t.compile)}Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");class Kysely extends QueryCreator{#e;constructor(e){let I,B;if(isKyselyProps(e))I={executor:e.executor},B={...e};else{const tr=e.dialect,rr=tr.createDriver(),ir=tr.createQueryCompiler(),lr=tr.createAdapter(),dr=new Log(e.log??[]),mr=new RuntimeDriver(rr,dr),hr=new DefaultConnectionProvider(mr),fr=new DefaultQueryExecutor(ir,lr,hr,e.plugins??[]);I={executor:fr},B={config:e,executor:fr,dialect:tr,driver:mr}}super(I),this.#e=freeze(B)}get schema(){return new SchemaModule(this.#e.executor)}get dynamic(){return new DynamicModule}get introspection(){return this.#e.dialect.createIntrospector(this.withoutPlugins())}case(e){return new CaseBuilder({node:CaseNode.create(isUndefined(e)?void 0:parseExpression(e))})}get fn(){return createFunctionModule()}transaction(){return new TransactionBuilder({...this.#e})}startTransaction(){return new ControlledTransactionBuilder({...this.#e})}connection(){return new ConnectionBuilder({...this.#e})}withPlugin(e){return new Kysely({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new Kysely({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new Kysely({...this.#e,executor:this.#e.executor.withPluginAtFront(new WithSchemaPlugin(e))})}withTables(){return new Kysely({...this.#e})}async destroy(){await this.#e.driver.destroy()}get isTransaction(){return!1}getExecutor(){return this.#e.executor}executeQuery(e,I){I!==void 0&&logOnce("Passing `queryId` in `db.executeQuery` is deprecated and will result in a compile-time error in the future.");const B=isCompilable(e)?e.compile():e;return this.getExecutor().executeQuery(B)}async[Symbol.asyncDispose](){await this.destroy()}}class Transaction extends Kysely{#e;constructor(e){super(e),this.#e=e}get isTransaction(){return!0}transaction(){throw new Error("calling the transaction method for a Transaction is not supported")}connection(){throw new Error("calling the connection method for a Transaction is not supported")}async destroy(){throw new Error("calling the destroy method for a Transaction is not supported")}withPlugin(e){return new Transaction({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new Transaction({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new Transaction({...this.#e,executor:this.#e.executor.withPluginAtFront(new WithSchemaPlugin(e))})}withTables(){return new Transaction({...this.#e})}}function isKyselyProps(t){return isObject(t)&&isObject(t.config)&&isObject(t.driver)&&isObject(t.executor)&&isObject(t.dialect)}class ConnectionBuilder{#e;constructor(e){this.#e=freeze(e)}async execute(e){return this.#e.executor.provideConnection(async I=>{const B=this.#e.executor.withConnectionProvider(new SingleConnectionProvider(I)),tr=new Kysely({...this.#e,executor:B});return await e(tr)})}}class TransactionBuilder{#e;constructor(e){this.#e=freeze(e)}setAccessMode(e){return new TransactionBuilder({...this.#e,accessMode:e})}setIsolationLevel(e){return new TransactionBuilder({...this.#e,isolationLevel:e})}async execute(e){const{isolationLevel:I,accessMode:B,...tr}=this.#e,rr={isolationLevel:I,accessMode:B};return validateTransactionSettings(rr),this.#e.executor.provideConnection(async ir=>{const lr=this.#e.executor.withConnectionProvider(new SingleConnectionProvider(ir)),dr=new Transaction({...tr,executor:lr});let mr=!1;try{await this.#e.driver.beginTransaction(ir,rr),mr=!0;const hr=await e(dr);return await this.#e.driver.commitTransaction(ir),hr}catch(hr){throw mr&&await this.#e.driver.rollbackTransaction(ir),hr}})}}class ControlledTransactionBuilder{#e;constructor(e){this.#e=freeze(e)}setAccessMode(e){return new ControlledTransactionBuilder({...this.#e,accessMode:e})}setIsolationLevel(e){return new ControlledTransactionBuilder({...this.#e,isolationLevel:e})}async execute(){const{isolationLevel:e,accessMode:I,...B}=this.#e,tr={isolationLevel:e,accessMode:I};validateTransactionSettings(tr);const rr=await provideControlledConnection(this.#e.executor);return await this.#e.driver.beginTransaction(rr.connection,tr),new ControlledTransaction({...B,connection:rr,executor:this.#e.executor.withConnectionProvider(new SingleConnectionProvider(rr.connection))})}}class ControlledTransaction extends Transaction{#e;#t;#r;constructor(e){const I={isCommitted:!1,isRolledBack:!1};e={...e,executor:new NotCommittedOrRolledBackAssertingExecutor(e.executor,I)};const{connection:B,...tr}=e;super(tr),this.#e=freeze(e),this.#r=I;const rr=createQueryId();this.#t=ir=>e.executor.compileQuery(ir,rr)}get isCommitted(){return this.#r.isCommitted}get isRolledBack(){return this.#r.isRolledBack}commit(){return assertNotCommittedOrRolledBack(this.#r),new Command(async()=>{await this.#e.driver.commitTransaction(this.#e.connection.connection),this.#r.isCommitted=!0,this.#e.connection.release()})}rollback(){return assertNotCommittedOrRolledBack(this.#r),new Command(async()=>{await this.#e.driver.rollbackTransaction(this.#e.connection.connection),this.#r.isRolledBack=!0,this.#e.connection.release()})}savepoint(e){return assertNotCommittedOrRolledBack(this.#r),new Command(async()=>(await this.#e.driver.savepoint?.(this.#e.connection.connection,e,this.#t),new ControlledTransaction({...this.#e})))}rollbackToSavepoint(e){return assertNotCommittedOrRolledBack(this.#r),new Command(async()=>(await this.#e.driver.rollbackToSavepoint?.(this.#e.connection.connection,e,this.#t),new ControlledTransaction({...this.#e})))}releaseSavepoint(e){return assertNotCommittedOrRolledBack(this.#r),new Command(async()=>(await this.#e.driver.releaseSavepoint?.(this.#e.connection.connection,e,this.#t),new ControlledTransaction({...this.#e})))}withPlugin(e){return new ControlledTransaction({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new ControlledTransaction({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new ControlledTransaction({...this.#e,executor:this.#e.executor.withPluginAtFront(new WithSchemaPlugin(e))})}withTables(){return new ControlledTransaction({...this.#e})}}class Command{#e;constructor(e){this.#e=e}async execute(){return await this.#e()}}function assertNotCommittedOrRolledBack(t){if(t.isCommitted)throw new Error("Transaction is already committed");if(t.isRolledBack)throw new Error("Transaction is already rolled back")}class NotCommittedOrRolledBackAssertingExecutor{#e;#t;constructor(e,I){e instanceof NotCommittedOrRolledBackAssertingExecutor?this.#e=e.#e:this.#e=e,this.#t=I}get adapter(){return this.#e.adapter}get plugins(){return this.#e.plugins}transformQuery(e,I){return this.#e.transformQuery(e,I)}compileQuery(e,I){return this.#e.compileQuery(e,I)}provideConnection(e){return this.#e.provideConnection(e)}executeQuery(e){return assertNotCommittedOrRolledBack(this.#t),this.#e.executeQuery(e)}stream(e,I){return assertNotCommittedOrRolledBack(this.#t),this.#e.stream(e,I)}withConnectionProvider(e){return new NotCommittedOrRolledBackAssertingExecutor(this.#e.withConnectionProvider(e),this.#t)}withPlugin(e){return new NotCommittedOrRolledBackAssertingExecutor(this.#e.withPlugin(e),this.#t)}withPlugins(e){return new NotCommittedOrRolledBackAssertingExecutor(this.#e.withPlugins(e),this.#t)}withPluginAtFront(e){return new NotCommittedOrRolledBackAssertingExecutor(this.#e.withPluginAtFront(e),this.#t)}withoutPlugins(){return new NotCommittedOrRolledBackAssertingExecutor(this.#e.withoutPlugins(),this.#t)}}class RawBuilderImpl{#e;constructor(e){this.#e=freeze(e)}get expressionType(){}get isRawBuilder(){return!0}as(e){return new AliasedRawBuilderImpl(this,e)}$castTo(){return new RawBuilderImpl({...this.#e})}$notNull(){return new RawBuilderImpl(this.#e)}withPlugin(e){return new RawBuilderImpl({...this.#e,plugins:this.#e.plugins!==void 0?freeze([...this.#e.plugins,e]):freeze([e])})}toOperationNode(){return this.#r(this.#t())}compile(e){return this.#n(this.#t(e))}async execute(e){const I=this.#t(e);return I.executeQuery(this.#n(I))}#t(e){const I=e!==void 0?e.getExecutor():NOOP_QUERY_EXECUTOR;return this.#e.plugins!==void 0?I.withPlugins(this.#e.plugins):I}#r(e){return e.transformQuery(this.#e.rawNode,this.#e.queryId)}#n(e){return e.compileQuery(this.#r(e),this.#e.queryId)}}function createRawBuilder(t){return new RawBuilderImpl(t)}class AliasedRawBuilderImpl{#e;#t;constructor(e,I){this.#e=e,this.#t=I}get expression(){return this.#e}get alias(){return this.#t}get rawBuilder(){return this.#e}toOperationNode(){return AliasNode.create(this.#e.toOperationNode(),isOperationNodeSource(this.#t)?this.#t.toOperationNode():IdentifierNode.create(this.#t))}}const sql=Object.assign((t,...e)=>createRawBuilder({queryId:createQueryId(),rawNode:RawNode.create(t,e?.map(parseParameter)??[])}),{ref(t){return createRawBuilder({queryId:createQueryId(),rawNode:RawNode.createWithChild(parseStringReference(t))})},val(t){return createRawBuilder({queryId:createQueryId(),rawNode:RawNode.createWithChild(parseValueExpression(t))})},value(t){return this.val(t)},table(t){return createRawBuilder({queryId:createQueryId(),rawNode:RawNode.createWithChild(parseTable(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",createRawBuilder({queryId:createQueryId(),rawNode:RawNode.create(e,t.map(IdentifierNode.create))})},lit(t){return createRawBuilder({queryId:createQueryId(),rawNode:RawNode.createWithChild(ValueNode.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return createRawBuilder({queryId:createQueryId(),rawNode:RawNode.createWithSql(t)})},join(t,e=sql`, `){const I=new Array(Math.max(2*t.length-1,0)),B=e.toOperationNode();for(let tr=0;tr<t.length;++tr)I[2*tr]=parseParameter(t[tr]),tr!==t.length-1&&(I[2*tr+1]=B);return createRawBuilder({queryId:createQueryId(),rawNode:RawNode.createWithChildren(I)})}});function parseParameter(t){return isOperationNodeSource(t)?t.toOperationNode():parseValueExpression(t)}class OperationNodeVisitor{nodeStack=[];get parentNode(){return this.nodeStack[this.nodeStack.length-2]}#e=freeze({AliasNode:this.visitAlias.bind(this),ColumnNode:this.visitColumn.bind(this),IdentifierNode:this.visitIdentifier.bind(this),SchemableIdentifierNode:this.visitSchemableIdentifier.bind(this),RawNode:this.visitRaw.bind(this),ReferenceNode:this.visitReference.bind(this),SelectQueryNode:this.visitSelectQuery.bind(this),SelectionNode:this.visitSelection.bind(this),TableNode:this.visitTable.bind(this),FromNode:this.visitFrom.bind(this),SelectAllNode:this.visitSelectAll.bind(this),AndNode:this.visitAnd.bind(this),OrNode:this.visitOr.bind(this),ValueNode:this.visitValue.bind(this),ValueListNode:this.visitValueList.bind(this),PrimitiveValueListNode:this.visitPrimitiveValueList.bind(this),ParensNode:this.visitParens.bind(this),JoinNode:this.visitJoin.bind(this),OperatorNode:this.visitOperator.bind(this),WhereNode:this.visitWhere.bind(this),InsertQueryNode:this.visitInsertQuery.bind(this),DeleteQueryNode:this.visitDeleteQuery.bind(this),ReturningNode:this.visitReturning.bind(this),CreateTableNode:this.visitCreateTable.bind(this),AddColumnNode:this.visitAddColumn.bind(this),ColumnDefinitionNode:this.visitColumnDefinition.bind(this),DropTableNode:this.visitDropTable.bind(this),DataTypeNode:this.visitDataType.bind(this),OrderByNode:this.visitOrderBy.bind(this),OrderByItemNode:this.visitOrderByItem.bind(this),GroupByNode:this.visitGroupBy.bind(this),GroupByItemNode:this.visitGroupByItem.bind(this),UpdateQueryNode:this.visitUpdateQuery.bind(this),ColumnUpdateNode:this.visitColumnUpdate.bind(this),LimitNode:this.visitLimit.bind(this),OffsetNode:this.visitOffset.bind(this),OnConflictNode:this.visitOnConflict.bind(this),OnDuplicateKeyNode:this.visitOnDuplicateKey.bind(this),CreateIndexNode:this.visitCreateIndex.bind(this),DropIndexNode:this.visitDropIndex.bind(this),ListNode:this.visitList.bind(this),PrimaryKeyConstraintNode:this.visitPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.visitUniqueConstraint.bind(this),ReferencesNode:this.visitReferences.bind(this),CheckConstraintNode:this.visitCheckConstraint.bind(this),WithNode:this.visitWith.bind(this),CommonTableExpressionNode:this.visitCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.visitCommonTableExpressionName.bind(this),HavingNode:this.visitHaving.bind(this),CreateSchemaNode:this.visitCreateSchema.bind(this),DropSchemaNode:this.visitDropSchema.bind(this),AlterTableNode:this.visitAlterTable.bind(this),DropColumnNode:this.visitDropColumn.bind(this),RenameColumnNode:this.visitRenameColumn.bind(this),AlterColumnNode:this.visitAlterColumn.bind(this),ModifyColumnNode:this.visitModifyColumn.bind(this),AddConstraintNode:this.visitAddConstraint.bind(this),DropConstraintNode:this.visitDropConstraint.bind(this),RenameConstraintNode:this.visitRenameConstraint.bind(this),ForeignKeyConstraintNode:this.visitForeignKeyConstraint.bind(this),CreateViewNode:this.visitCreateView.bind(this),RefreshMaterializedViewNode:this.visitRefreshMaterializedView.bind(this),DropViewNode:this.visitDropView.bind(this),GeneratedNode:this.visitGenerated.bind(this),DefaultValueNode:this.visitDefaultValue.bind(this),OnNode:this.visitOn.bind(this),ValuesNode:this.visitValues.bind(this),SelectModifierNode:this.visitSelectModifier.bind(this),CreateTypeNode:this.visitCreateType.bind(this),DropTypeNode:this.visitDropType.bind(this),ExplainNode:this.visitExplain.bind(this),DefaultInsertValueNode:this.visitDefaultInsertValue.bind(this),AggregateFunctionNode:this.visitAggregateFunction.bind(this),OverNode:this.visitOver.bind(this),PartitionByNode:this.visitPartitionBy.bind(this),PartitionByItemNode:this.visitPartitionByItem.bind(this),SetOperationNode:this.visitSetOperation.bind(this),BinaryOperationNode:this.visitBinaryOperation.bind(this),UnaryOperationNode:this.visitUnaryOperation.bind(this),UsingNode:this.visitUsing.bind(this),FunctionNode:this.visitFunction.bind(this),CaseNode:this.visitCase.bind(this),WhenNode:this.visitWhen.bind(this),JSONReferenceNode:this.visitJSONReference.bind(this),JSONPathNode:this.visitJSONPath.bind(this),JSONPathLegNode:this.visitJSONPathLeg.bind(this),JSONOperatorChainNode:this.visitJSONOperatorChain.bind(this),TupleNode:this.visitTuple.bind(this),MergeQueryNode:this.visitMergeQuery.bind(this),MatchedNode:this.visitMatched.bind(this),AddIndexNode:this.visitAddIndex.bind(this),CastNode:this.visitCast.bind(this),FetchNode:this.visitFetch.bind(this),TopNode:this.visitTop.bind(this),OutputNode:this.visitOutput.bind(this),OrActionNode:this.visitOrAction.bind(this),CollateNode:this.visitCollate.bind(this)});visitNode=e=>{this.nodeStack.push(e),this.#e[e.kind](e),this.nodeStack.pop()}}const LIT_WRAP_REGEX=/'/g;class DefaultQueryCompiler extends OperationNodeVisitor{#e="";#t=[];get numParameters(){return this.#t.length}compileQuery(e,I){return this.#e="",this.#t=[],this.nodeStack.splice(0,this.nodeStack.length),this.visitNode(e),freeze({query:e,queryId:I,sql:this.getSql(),parameters:[...this.#t]})}getSql(){return this.#e}visitSelectQuery(e){const I=this.parentNode!==void 0&&!ParensNode.is(this.parentNode)&&!InsertQueryNode.is(this.parentNode)&&!CreateTableNode.is(this.parentNode)&&!CreateViewNode.is(this.parentNode)&&!SetOperationNode.is(this.parentNode);this.parentNode===void 0&&e.explain&&(this.visitNode(e.explain),this.append(" ")),I&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("select"),e.distinctOn&&(this.append(" "),this.compileDistinctOn(e.distinctOn)),e.frontModifiers?.length&&(this.append(" "),this.compileList(e.frontModifiers," ")),e.top&&(this.append(" "),this.visitNode(e.top)),e.selections&&(this.append(" "),this.compileList(e.selections)),e.from&&(this.append(" "),this.visitNode(e.from)),e.joins&&(this.append(" "),this.compileList(e.joins," ")),e.where&&(this.append(" "),this.visitNode(e.where)),e.groupBy&&(this.append(" "),this.visitNode(e.groupBy)),e.having&&(this.append(" "),this.visitNode(e.having)),e.setOperations&&(this.append(" "),this.compileList(e.setOperations," ")),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.offset&&(this.append(" "),this.visitNode(e.offset)),e.fetch&&(this.append(" "),this.visitNode(e.fetch)),e.endModifiers?.length&&(this.append(" "),this.compileList(this.sortSelectModifiers([...e.endModifiers])," ")),I&&this.append(")")}visitFrom(e){this.append("from "),this.compileList(e.froms)}visitSelection(e){this.visitNode(e.selection)}visitColumn(e){this.visitNode(e.column)}compileDistinctOn(e){this.append("distinct on ("),this.compileList(e),this.append(")")}compileList(e,I=", "){const B=e.length-1;for(let tr=0;tr<=B;tr++)this.visitNode(e[tr]),tr<B&&this.append(I)}visitWhere(e){this.append("where "),this.visitNode(e.where)}visitHaving(e){this.append("having "),this.visitNode(e.having)}visitInsertQuery(e){const I=this.parentNode!==void 0&&!ParensNode.is(this.parentNode)&&!RawNode.is(this.parentNode)&&!WhenNode.is(this.parentNode);this.parentNode===void 0&&e.explain&&(this.visitNode(e.explain),this.append(" ")),I&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append(e.replace?"replace":"insert"),e.ignore&&(logOnce("`InsertQueryNode.ignore` is deprecated. Use `InsertQueryNode.orAction` instead."),this.append(" ignore")),e.orAction&&(this.append(" "),this.visitNode(e.orAction)),e.top&&(this.append(" "),this.visitNode(e.top)),e.into&&(this.append(" into "),this.visitNode(e.into)),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.output&&(this.append(" "),this.visitNode(e.output)),e.values&&(this.append(" "),this.visitNode(e.values)),e.defaultValues&&(this.append(" "),this.append("default values")),e.onConflict&&(this.append(" "),this.visitNode(e.onConflict)),e.onDuplicateKey&&(this.append(" "),this.visitNode(e.onDuplicateKey)),e.returning&&(this.append(" "),this.visitNode(e.returning)),I&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitValues(e){this.append("values "),this.compileList(e.values)}visitDeleteQuery(e){const I=this.parentNode!==void 0&&!ParensNode.is(this.parentNode)&&!RawNode.is(this.parentNode);this.parentNode===void 0&&e.explain&&(this.visitNode(e.explain),this.append(" ")),I&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("delete "),e.top&&(this.visitNode(e.top),this.append(" ")),this.visitNode(e.from),e.output&&(this.append(" "),this.visitNode(e.output)),e.using&&(this.append(" "),this.visitNode(e.using)),e.joins&&(this.append(" "),this.compileList(e.joins," ")),e.where&&(this.append(" "),this.visitNode(e.where)),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.returning&&(this.append(" "),this.visitNode(e.returning)),I&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitReturning(e){this.append("returning "),this.compileList(e.selections)}visitAlias(e){this.visitNode(e.node),this.append(" as "),this.visitNode(e.alias)}visitReference(e){e.table&&(this.visitNode(e.table),this.append(".")),this.visitNode(e.column)}visitSelectAll(e){this.append("*")}visitIdentifier(e){this.append(this.getLeftIdentifierWrapper()),this.compileUnwrappedIdentifier(e),this.append(this.getRightIdentifierWrapper())}compileUnwrappedIdentifier(e){if(!isString(e.name))throw new Error("a non-string identifier was passed to compileUnwrappedIdentifier.");this.append(this.sanitizeIdentifier(e.name))}visitAnd(e){this.visitNode(e.left),this.append(" and "),this.visitNode(e.right)}visitOr(e){this.visitNode(e.left),this.append(" or "),this.visitNode(e.right)}visitValue(e){e.immediate?this.appendImmediateValue(e.value):this.appendValue(e.value)}visitValueList(e){this.append("("),this.compileList(e.values),this.append(")")}visitTuple(e){this.append("("),this.compileList(e.values),this.append(")")}visitPrimitiveValueList(e){this.append("(");const{values:I}=e;for(let B=0;B<I.length;++B)this.appendValue(I[B]),B!==I.length-1&&this.append(", ");this.append(")")}visitParens(e){this.append("("),this.visitNode(e.node),this.append(")")}visitJoin(e){this.append(JOIN_TYPE_SQL[e.joinType]),this.append(" "),this.visitNode(e.table),e.on&&(this.append(" "),this.visitNode(e.on))}visitOn(e){this.append("on "),this.visitNode(e.on)}visitRaw(e){const{sqlFragments:I,parameters:B}=e;for(let tr=0;tr<I.length;++tr)this.append(I[tr]),B.length>tr&&this.visitNode(B[tr])}visitOperator(e){this.append(e.operator)}visitTable(e){this.visitNode(e.table)}visitSchemableIdentifier(e){e.schema&&(this.visitNode(e.schema),this.append(".")),this.visitNode(e.identifier)}visitCreateTable(e){this.append("create "),e.frontModifiers&&e.frontModifiers.length>0&&(this.compileList(e.frontModifiers," "),this.append(" ")),e.temporary&&this.append("temporary "),this.append("table "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.table),e.selectQuery?(this.append(" as "),this.visitNode(e.selectQuery)):(this.append(" ("),this.compileList([...e.columns,...e.constraints??[]]),this.append(")"),e.onCommit&&(this.append(" on commit "),this.append(e.onCommit)),e.endModifiers&&e.endModifiers.length>0&&(this.append(" "),this.compileList(e.endModifiers," ")))}visitColumnDefinition(e){e.ifNotExists&&this.append("if not exists "),this.visitNode(e.column),this.append(" "),this.visitNode(e.dataType),e.unsigned&&this.append(" unsigned"),e.frontModifiers&&e.frontModifiers.length>0&&(this.append(" "),this.compileList(e.frontModifiers," ")),e.generated&&(this.append(" "),this.visitNode(e.generated)),e.identity&&this.append(" identity"),e.defaultTo&&(this.append(" "),this.visitNode(e.defaultTo)),e.notNull&&this.append(" not null"),e.unique&&this.append(" unique"),e.nullsNotDistinct&&this.append(" nulls not distinct"),e.primaryKey&&this.append(" primary key"),e.autoIncrement&&(this.append(" "),this.append(this.getAutoIncrement())),e.references&&(this.append(" "),this.visitNode(e.references)),e.check&&(this.append(" "),this.visitNode(e.check)),e.endModifiers&&e.endModifiers.length>0&&(this.append(" "),this.compileList(e.endModifiers," "))}getAutoIncrement(){return"auto_increment"}visitReferences(e){this.append("references "),this.visitNode(e.table),this.append(" ("),this.compileList(e.columns),this.append(")"),e.onDelete&&(this.append(" on delete "),this.append(e.onDelete)),e.onUpdate&&(this.append(" on update "),this.append(e.onUpdate))}visitDropTable(e){this.append("drop table "),e.ifExists&&this.append("if exists "),this.visitNode(e.table),e.cascade&&this.append(" cascade")}visitDataType(e){this.append(e.dataType)}visitOrderBy(e){this.append("order by "),this.compileList(e.items)}visitOrderByItem(e){this.visitNode(e.orderBy),e.collation&&(this.append(" "),this.visitNode(e.collation)),e.direction&&(this.append(" "),this.visitNode(e.direction)),e.nulls&&(this.append(" nulls "),this.append(e.nulls))}visitGroupBy(e){this.append("group by "),this.compileList(e.items)}visitGroupByItem(e){this.visitNode(e.groupBy)}visitUpdateQuery(e){const I=this.parentNode!==void 0&&!ParensNode.is(this.parentNode)&&!RawNode.is(this.parentNode)&&!WhenNode.is(this.parentNode);if(this.parentNode===void 0&&e.explain&&(this.visitNode(e.explain),this.append(" ")),I&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("update "),e.top&&(this.visitNode(e.top),this.append(" ")),e.table&&(this.visitNode(e.table),this.append(" ")),this.append("set "),e.updates&&this.compileList(e.updates),e.output&&(this.append(" "),this.visitNode(e.output)),e.from&&(this.append(" "),this.visitNode(e.from)),e.joins){if(!e.from)throw new Error("Joins in an update query are only supported as a part of a PostgreSQL 'update set from join' query. If you want to create a MySQL 'update join set' query, see https://kysely.dev/docs/examples/update/my-sql-joins");this.append(" "),this.compileList(e.joins," ")}e.where&&(this.append(" "),this.visitNode(e.where)),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.returning&&(this.append(" "),this.visitNode(e.returning)),I&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitColumnUpdate(e){this.visitNode(e.column),this.append(" = "),this.visitNode(e.value)}visitLimit(e){this.append("limit "),this.visitNode(e.limit)}visitOffset(e){this.append("offset "),this.visitNode(e.offset)}visitOnConflict(e){this.append("on conflict"),e.columns?(this.append(" ("),this.compileList(e.columns),this.append(")")):e.constraint?(this.append(" on constraint "),this.visitNode(e.constraint)):e.indexExpression&&(this.append(" ("),this.visitNode(e.indexExpression),this.append(")")),e.indexWhere&&(this.append(" "),this.visitNode(e.indexWhere)),e.doNothing===!0?this.append(" do nothing"):e.updates&&(this.append(" do update set "),this.compileList(e.updates),e.updateWhere&&(this.append(" "),this.visitNode(e.updateWhere)))}visitOnDuplicateKey(e){this.append("on duplicate key update "),this.compileList(e.updates)}visitCreateIndex(e){this.append("create "),e.unique&&this.append("unique "),this.append("index "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.name),e.table&&(this.append(" on "),this.visitNode(e.table)),e.using&&(this.append(" using "),this.visitNode(e.using)),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.nullsNotDistinct&&this.append(" nulls not distinct"),e.where&&(this.append(" "),this.visitNode(e.where))}visitDropIndex(e){this.append("drop index "),e.ifExists&&this.append("if exists "),this.visitNode(e.name),e.table&&(this.append(" on "),this.visitNode(e.table)),e.cascade&&this.append(" cascade")}visitCreateSchema(e){this.append("create schema "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.schema)}visitDropSchema(e){this.append("drop schema "),e.ifExists&&this.append("if exists "),this.visitNode(e.schema),e.cascade&&this.append(" cascade")}visitPrimaryKeyConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("primary key ("),this.compileList(e.columns),this.append(")"),this.buildDeferrable(e)}buildDeferrable(e){e.deferrable!==void 0&&(e.deferrable?this.append(" deferrable"):this.append(" not deferrable")),e.initiallyDeferred!==void 0&&(e.initiallyDeferred?this.append(" initially deferred"):this.append(" initially immediate"))}visitUniqueConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("unique"),e.nullsNotDistinct&&this.append(" nulls not distinct"),this.append(" ("),this.compileList(e.columns),this.append(")"),this.buildDeferrable(e)}visitCheckConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("check ("),this.visitNode(e.expression),this.append(")")}visitForeignKeyConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("foreign key ("),this.compileList(e.columns),this.append(") "),this.visitNode(e.references),e.onDelete&&(this.append(" on delete "),this.append(e.onDelete)),e.onUpdate&&(this.append(" on update "),this.append(e.onUpdate)),this.buildDeferrable(e)}visitList(e){this.compileList(e.items)}visitWith(e){this.append("with "),e.recursive&&this.append("recursive "),this.compileList(e.expressions)}visitCommonTableExpression(e){this.visitNode(e.name),this.append(" as "),isBoolean(e.materialized)&&(e.materialized||this.append("not "),this.append("materialized ")),this.visitNode(e.expression)}visitCommonTableExpressionName(e){this.visitNode(e.table),e.columns&&(this.append("("),this.compileList(e.columns),this.append(")"))}visitAlterTable(e){this.append("alter table "),this.visitNode(e.table),this.append(" "),e.renameTo&&(this.append("rename to "),this.visitNode(e.renameTo)),e.setSchema&&(this.append("set schema "),this.visitNode(e.setSchema)),e.addConstraint&&this.visitNode(e.addConstraint),e.dropConstraint&&this.visitNode(e.dropConstraint),e.renameConstraint&&this.visitNode(e.renameConstraint),e.columnAlterations&&this.compileColumnAlterations(e.columnAlterations),e.addIndex&&this.visitNode(e.addIndex),e.dropIndex&&this.visitNode(e.dropIndex)}visitAddColumn(e){this.append("add column "),this.visitNode(e.column)}visitRenameColumn(e){this.append("rename column "),this.visitNode(e.column),this.append(" to "),this.visitNode(e.renameTo)}visitDropColumn(e){this.append("drop column "),this.visitNode(e.column)}visitAlterColumn(e){this.append("alter column "),this.visitNode(e.column),this.append(" "),e.dataType&&(this.announcesNewColumnDataType()&&this.append("type "),this.visitNode(e.dataType),e.dataTypeExpression&&(this.append("using "),this.visitNode(e.dataTypeExpression))),e.setDefault&&(this.append("set default "),this.visitNode(e.setDefault)),e.dropDefault&&this.append("drop default"),e.setNotNull&&this.append("set not null"),e.dropNotNull&&this.append("drop not null")}visitModifyColumn(e){this.append("modify column "),this.visitNode(e.column)}visitAddConstraint(e){this.append("add "),this.visitNode(e.constraint)}visitDropConstraint(e){this.append("drop constraint "),e.ifExists&&this.append("if exists "),this.visitNode(e.constraintName),e.modifier==="cascade"?this.append(" cascade"):e.modifier==="restrict"&&this.append(" restrict")}visitRenameConstraint(e){this.append("rename constraint "),this.visitNode(e.oldName),this.append(" to "),this.visitNode(e.newName)}visitSetOperation(e){this.append(e.operator),this.append(" "),e.all&&this.append("all "),this.visitNode(e.expression)}visitCreateView(e){this.append("create "),e.orReplace&&this.append("or replace "),e.materialized&&this.append("materialized "),e.temporary&&this.append("temporary "),this.append("view "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.name),this.append(" "),e.columns&&(this.append("("),this.compileList(e.columns),this.append(") ")),e.as&&(this.append("as "),this.visitNode(e.as))}visitRefreshMaterializedView(e){this.append("refresh materialized view "),e.concurrently&&this.append("concurrently "),this.visitNode(e.name),e.withNoData?this.append(" with no data"):this.append(" with data")}visitDropView(e){this.append("drop "),e.materialized&&this.append("materialized "),this.append("view "),e.ifExists&&this.append("if exists "),this.visitNode(e.name),e.cascade&&this.append(" cascade")}visitGenerated(e){this.append("generated "),e.always&&this.append("always "),e.byDefault&&this.append("by default "),this.append("as "),e.identity&&this.append("identity"),e.expression&&(this.append("("),this.visitNode(e.expression),this.append(")")),e.stored&&this.append(" stored")}visitDefaultValue(e){this.append("default "),this.visitNode(e.defaultValue)}visitSelectModifier(e){e.rawModifier?this.visitNode(e.rawModifier):this.append(SELECT_MODIFIER_SQL[e.modifier]),e.of&&(this.append(" of "),this.compileList(e.of,", "))}visitCreateType(e){this.append("create type "),this.visitNode(e.name),e.enum&&(this.append(" as enum "),this.visitNode(e.enum))}visitDropType(e){this.append("drop type "),e.ifExists&&this.append("if exists "),this.visitNode(e.name)}visitExplain(e){this.append("explain"),(e.options||e.format)&&(this.append(" "),this.append(this.getLeftExplainOptionsWrapper()),e.options&&(this.visitNode(e.options),e.format&&this.append(this.getExplainOptionsDelimiter())),e.format&&(this.append("format"),this.append(this.getExplainOptionAssignment()),this.append(e.format)),this.append(this.getRightExplainOptionsWrapper()))}visitDefaultInsertValue(e){this.append("default")}visitAggregateFunction(e){this.append(e.func),this.append("("),e.distinct&&this.append("distinct "),this.compileList(e.aggregated),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),this.append(")"),e.withinGroup&&(this.append(" within group ("),this.visitNode(e.withinGroup),this.append(")")),e.filter&&(this.append(" filter("),this.visitNode(e.filter),this.append(")")),e.over&&(this.append(" "),this.visitNode(e.over))}visitOver(e){this.append("over("),e.partitionBy&&(this.visitNode(e.partitionBy),e.orderBy&&this.append(" ")),e.orderBy&&this.visitNode(e.orderBy),this.append(")")}visitPartitionBy(e){this.append("partition by "),this.compileList(e.items)}visitPartitionByItem(e){this.visitNode(e.partitionBy)}visitBinaryOperation(e){this.visitNode(e.leftOperand),this.append(" "),this.visitNode(e.operator),this.append(" "),this.visitNode(e.rightOperand)}visitUnaryOperation(e){this.visitNode(e.operator),this.isMinusOperator(e.operator)||this.append(" "),this.visitNode(e.operand)}isMinusOperator(e){return OperatorNode.is(e)&&e.operator==="-"}visitUsing(e){this.append("using "),this.compileList(e.tables)}visitFunction(e){this.append(e.func),this.append("("),this.compileList(e.arguments),this.append(")")}visitCase(e){this.append("case"),e.value&&(this.append(" "),this.visitNode(e.value)),e.when&&(this.append(" "),this.compileList(e.when," ")),e.else&&(this.append(" else "),this.visitNode(e.else)),this.append(" end"),e.isStatement&&this.append(" case")}visitWhen(e){this.append("when "),this.visitNode(e.condition),e.result&&(this.append(" then "),this.visitNode(e.result))}visitJSONReference(e){this.visitNode(e.reference),this.visitNode(e.traversal)}visitJSONPath(e){e.inOperator&&this.visitNode(e.inOperator),this.append("'$");for(const I of e.pathLegs)this.visitNode(I);this.append("'")}visitJSONPathLeg(e){const I=e.type==="ArrayLocation";this.append(I?"[":"."),this.append(String(e.value)),I&&this.append("]")}visitJSONOperatorChain(e){for(let I=0,B=e.values.length;I<B;I++)I===B-1?this.visitNode(e.operator):this.append("->"),this.visitNode(e.values[I])}visitMergeQuery(e){e.with&&(this.visitNode(e.with),this.append(" ")),this.append("merge "),e.top&&(this.visitNode(e.top),this.append(" ")),this.append("into "),this.visitNode(e.into),e.using&&(this.append(" "),this.visitNode(e.using)),e.whens&&(this.append(" "),this.compileList(e.whens," ")),e.returning&&(this.append(" "),this.visitNode(e.returning)),e.output&&(this.append(" "),this.visitNode(e.output)),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitMatched(e){e.not&&this.append("not "),this.append("matched"),e.bySource&&this.append(" by source")}visitAddIndex(e){this.append("add "),e.unique&&this.append("unique "),this.append("index "),this.visitNode(e.name),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.using&&(this.append(" using "),this.visitNode(e.using))}visitCast(e){this.append("cast("),this.visitNode(e.expression),this.append(" as "),this.visitNode(e.dataType),this.append(")")}visitFetch(e){this.append("fetch next "),this.visitNode(e.rowCount),this.append(` rows ${e.modifier}`)}visitOutput(e){this.append("output "),this.compileList(e.selections)}visitTop(e){this.append(`top(${e.expression})`),e.modifiers&&this.append(` ${e.modifiers}`)}visitOrAction(e){this.append(e.action)}visitCollate(e){this.append("collate "),this.visitNode(e.collation)}append(e){this.#e+=e}appendValue(e){this.addParameter(e),this.append(this.getCurrentParameterPlaceholder())}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getCurrentParameterPlaceholder(){return"$"+this.numParameters}getLeftExplainOptionsWrapper(){return"("}getExplainOptionAssignment(){return" "}getExplainOptionsDelimiter(){return", "}getRightExplainOptionsWrapper(){return")"}sanitizeIdentifier(e){const I=this.getLeftIdentifierWrapper(),B=this.getRightIdentifierWrapper();let tr="";for(const rr of e)tr+=rr,rr===I?tr+=I:rr===B&&(tr+=B);return tr}sanitizeStringLiteral(e){return e.replace(LIT_WRAP_REGEX,"''")}addParameter(e){this.#t.push(e)}appendImmediateValue(e){if(isString(e))this.appendStringLiteral(e);else if(isNumber(e)||isBoolean(e)||isBigInt(e))this.append(e.toString());else if(isNull(e))this.append("null");else if(isDate(e))this.appendImmediateValue(e.toISOString());else throw new Error(`invalid immediate value ${e}`)}appendStringLiteral(e){this.append("'"),this.append(this.sanitizeStringLiteral(e)),this.append("'")}sortSelectModifiers(e){return e.sort((I,B)=>I.modifier&&B.modifier?SELECT_MODIFIER_PRIORITY[I.modifier]-SELECT_MODIFIER_PRIORITY[B.modifier]:1),freeze(e)}compileColumnAlterations(e){this.compileList(e)}announcesNewColumnDataType(){return!0}}const SELECT_MODIFIER_SQL=freeze({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),SELECT_MODIFIER_PRIORITY=freeze({ForKeyShare:1,ForNoKeyUpdate:1,ForUpdate:1,ForShare:1,NoWait:2,SkipLocked:2,Distinct:0}),JOIN_TYPE_SQL=freeze({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",CrossJoin:"cross join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral",LateralCrossJoin:"cross join lateral",OuterApply:"outer apply",CrossApply:"cross apply",Using:"using"}),CompiledQuery=freeze({raw(t,e=[]){return freeze({sql:t,query:RawNode.createWithSql(t),parameters:freeze(e),queryId:createQueryId()})}});class DialectAdapterBase{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!1}get supportsOutput(){return!1}}class NoopPlugin{transformQuery(e){return e.node}async transformResult(e){return e.result}}const DEFAULT_MIGRATION_TABLE="kysely_migration",DEFAULT_MIGRATION_LOCK_TABLE="kysely_migration_lock",DEFAULT_ALLOW_UNORDERED_MIGRATIONS=!1,MIGRATION_LOCK_ID="migration_lock";freeze({__noMigrations__:!0});class Migrator{#e;constructor(e){this.#e=freeze(e)}async getMigrations(){const e=await this.#u(this.#n)?await this.#e.db.withPlugin(this.#s).selectFrom(this.#n).select(["name","timestamp"]).$narrowType().execute():[];return(await this.#_()).map(({name:B,...tr})=>{const rr=e.find(ir=>ir.name===B);return{name:B,migration:tr,executedAt:rr?new Date(rr.timestamp):void 0}})}async migrateToLatest(){return this.#t(()=>({direction:"Up",step:1/0}))}async migrateTo(e){return this.#t(({migrations:I,executedMigrations:B,pendingMigrations:tr})=>{if(isObject(e)&&e.__noMigrations__===!0)return{direction:"Down",step:1/0};if(!I.find(lr=>lr.name===e))throw new Error(`migration "${e}" doesn't exist`);const rr=B.indexOf(e),ir=tr.findIndex(lr=>lr.name===e);if(rr!==-1)return{direction:"Down",step:B.length-rr-1};if(ir!==-1)return{direction:"Up",step:ir+1};throw new Error(`migration "${e}" isn't executed or pending`)})}async migrateUp(){return this.#t(()=>({direction:"Up",step:1}))}async migrateDown(){return this.#t(()=>({direction:"Down",step:1}))}async#t(e){try{return await this.#i(),await this.#g(e)}catch(I){return I instanceof MigrationResultSetError?I.resultSet:{error:I}}}get#r(){return this.#e.migrationTableSchema}get#n(){return this.#e.migrationTableName??DEFAULT_MIGRATION_TABLE}get#o(){return this.#e.migrationLockTableName??DEFAULT_MIGRATION_LOCK_TABLE}get#l(){return this.#e.allowUnorderedMigrations??DEFAULT_ALLOW_UNORDERED_MIGRATIONS}get#s(){return this.#r?new WithSchemaPlugin(this.#r):new NoopPlugin}async#i(){await this.#a(),await this.#d(),await this.#c(),await this.#h()}async#a(){if(this.#r&&!await this.#p())try{await this.#m(this.#e.db.schema.createSchema(this.#r))}catch(e){if(!await this.#p())throw e}}async#d(){if(!await this.#u(this.#n))try{this.#r&&await this.#m(this.#e.db.schema.createSchema(this.#r)),await this.#m(this.#e.db.schema.withPlugin(this.#s).createTable(this.#n).addColumn("name","varchar(255)",e=>e.notNull().primaryKey()).addColumn("timestamp","varchar(255)",e=>e.notNull()))}catch(e){if(!await this.#u(this.#n))throw e}}async#c(){if(!await this.#u(this.#o))try{await this.#m(this.#e.db.schema.withPlugin(this.#s).createTable(this.#o).addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("is_locked","integer",e=>e.notNull().defaultTo(0)))}catch(e){if(!await this.#u(this.#o))throw e}}async#h(){if(!await this.#f())try{await this.#e.db.withPlugin(this.#s).insertInto(this.#o).values({id:MIGRATION_LOCK_ID,is_locked:0}).execute()}catch(e){if(!await this.#f())throw e}}async#p(){return(await this.#e.db.introspection.getSchemas()).some(I=>I.name===this.#r)}async#u(e){const I=this.#r;return(await this.#e.db.introspection.getTables({withInternalKyselyTables:!0})).some(tr=>tr.name===e&&(!I||tr.schema===I))}async#f(){return!!await this.#e.db.withPlugin(this.#s).selectFrom(this.#o).where("id","=",MIGRATION_LOCK_ID).select("id").executeTakeFirst()}async#g(e){const I=this.#e.db.getExecutor().adapter,B=freeze({lockTable:this.#e.migrationLockTableName??DEFAULT_MIGRATION_LOCK_TABLE,lockRowId:MIGRATION_LOCK_ID,lockTableSchema:this.#e.migrationTableSchema}),tr=async rr=>{try{await I.acquireMigrationLock(rr,B);const ir=await this.#w(rr);if(ir.migrations.length===0)return{results:[]};const{direction:lr,step:dr}=e(ir);return dr<=0?{results:[]}:lr==="Down"?await this.#S(rr,ir,dr):lr==="Up"?await this.#M(rr,ir,dr):{results:[]}}finally{await I.releaseMigrationLock(rr,B)}};return I.supportsTransactionalDdl&&!this.#e.disableTransactions?this.#e.db.transaction().execute(tr):this.#e.db.connection().execute(tr)}async#w(e){const I=await this.#_(),B=await this.#E(e);this.#b(I,B),this.#l||this.#x(I,B);const tr=this.#y(I,B);return freeze({migrations:I,executedMigrations:B,lastMigration:getLast(B),pendingMigrations:tr})}#y(e,I){return e.filter(B=>!I.includes(B.name))}async#_(){const e=await this.#e.provider.getMigrations();return Object.keys(e).sort().map(I=>({...e[I],name:I}))}async#E(e){const I=await e.withPlugin(this.#s).selectFrom(this.#n).select(["name","timestamp"]).$narrowType().execute(),B=this.#e.nameComparator||((tr,rr)=>tr.localeCompare(rr));return I.sort((tr,rr)=>tr.timestamp===rr.timestamp?B(tr.name,rr.name):new Date(tr.timestamp).getTime()-new Date(rr.timestamp).getTime()).map(tr=>tr.name)}#b(e,I){for(const B of I)if(!e.some(tr=>tr.name===B))throw new Error(`corrupted migrations: previously executed migration ${B} is missing`)}#x(e,I){for(let B=0;B<I.length;++B)if(e[B].name!==I[B])throw new Error(`corrupted migrations: expected previously executed migration ${I[B]} to be at index ${B} but ${e[B].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`)}async#S(e,I,B){const tr=I.executedMigrations.slice().reverse().slice(0,B).map(ir=>I.migrations.find(lr=>lr.name===ir)),rr=tr.map(ir=>({migrationName:ir.name,direction:"Down",status:"NotExecuted"}));for(let ir=0;ir<rr.length;++ir){const lr=tr[ir];try{lr.down&&(await lr.down(e),await e.withPlugin(this.#s).deleteFrom(this.#n).where("name","=",lr.name).execute(),rr[ir]={migrationName:lr.name,direction:"Down",status:"Success"})}catch(dr){throw rr[ir]={migrationName:lr.name,direction:"Down",status:"Error"},new MigrationResultSetError({error:dr,results:rr})}}return{results:rr}}async#M(e,I,B){const rr=I.pendingMigrations.slice(0,B).map(ir=>({migrationName:ir.name,direction:"Up",status:"NotExecuted"}));for(let ir=0;ir<rr.length;ir++){const lr=I.pendingMigrations[ir];try{await lr.up(e),await e.withPlugin(this.#s).insertInto(this.#n).values({name:lr.name,timestamp:new Date().toISOString()}).execute(),rr[ir]={migrationName:lr.name,direction:"Up",status:"Success"}}catch(dr){throw rr[ir]={migrationName:lr.name,direction:"Up",status:"Error"},new MigrationResultSetError({error:dr,results:rr})}}return{results:rr}}async#m(e){this.#e.db.getExecutor().adapter.supportsCreateIfNotExists&&(e=e.ifNotExists()),await e.execute()}}class MigrationResultSetError extends Error{#e;constructor(e){super(),this.#e=e}get resultSet(){return this.#e}}const ID_WRAP_REGEX=/"/g;class PostgresQueryCompiler extends DefaultQueryCompiler{sanitizeIdentifier(e){return e.replace(ID_WRAP_REGEX,'""')}}class PostgresIntrospector{#e;constructor(e){this.#e=e}async getSchemas(){return(await this.#e.selectFrom("pg_catalog.pg_namespace").select("nspname").$castTo().execute()).map(I=>({name:I.nspname}))}async getTables(e={withInternalKyselyTables:!1}){let I=this.#e.selectFrom("pg_catalog.pg_attribute as a").innerJoin("pg_catalog.pg_class as c","a.attrelid","c.oid").innerJoin("pg_catalog.pg_namespace as ns","c.relnamespace","ns.oid").innerJoin("pg_catalog.pg_type as typ","a.atttypid","typ.oid").innerJoin("pg_catalog.pg_namespace as dtns","typ.typnamespace","dtns.oid").select(["a.attname as column","a.attnotnull as not_null","a.atthasdef as has_default","c.relname as table","c.relkind as table_type","ns.nspname as schema","typ.typname as type","dtns.nspname as type_schema",sql`col_description(a.attrelid, a.attnum)`.as("column_description"),sql`pg_get_serial_sequence(quote_ident(ns.nspname) || '.' || quote_ident(c.relname), a.attname)`.as("auto_incrementing")]).where("c.relkind","in",["r","v","p"]).where("ns.nspname","!~","^pg_").where("ns.nspname","!=","information_schema").where("ns.nspname","!=","crdb_internal").where(sql`has_schema_privilege(ns.nspname, 'USAGE')`).where("a.attnum",">=",0).where("a.attisdropped","!=",!0).orderBy("ns.nspname").orderBy("c.relname").orderBy("a.attnum").$castTo();e.withInternalKyselyTables||(I=I.where("c.relname","!=",DEFAULT_MIGRATION_TABLE).where("c.relname","!=",DEFAULT_MIGRATION_LOCK_TABLE));const B=await I.execute();return this.#t(B)}async getMetadata(e){return{tables:await this.getTables(e)}}#t(e){return e.reduce((I,B)=>{let tr=I.find(rr=>rr.name===B.table&&rr.schema===B.schema);return tr||(tr=freeze({name:B.table,isView:B.table_type==="v",schema:B.schema,columns:[]}),I.push(tr)),tr.columns.push(freeze({name:B.column,dataType:B.type,dataTypeSchema:B.type_schema,isNullable:!B.not_null,isAutoIncrementing:B.auto_incrementing!==null,hasDefaultValue:B.has_default,comment:B.column_description??void 0})),I},[])}}const LOCK_ID=BigInt("3853314791062309107");class PostgresAdapter extends DialectAdapterBase{get supportsTransactionalDdl(){return!0}get supportsReturning(){return!0}async acquireMigrationLock(e,I){await sql`select pg_advisory_xact_lock(${sql.lit(LOCK_ID)})`.execute(e)}async releaseMigrationLock(e,I){}}class KyselyOperationIndexTxn{collections=[];collectionMemberships=[];collectionRemovals=[];operations=[];createCollection(e){this.collections.push(e)}addToCollection(e,I){const B=this.operations.length-1;if(B<0)throw new Error("addToCollection must be called after write() - no operations in transaction");this.collectionMemberships.push({collectionId:e,documentId:I,operationIndex:B})}removeFromCollection(e,I){const B=this.operations.length-1;if(B<0)throw new Error("removeFromCollection must be called after write() - no operations in transaction");this.collectionRemovals.push({collectionId:e,documentId:I,operationIndex:B})}write(e){this.operations.push(...e)}getCollections(){return this.collections}getCollectionMemberships(){return this.collectionMemberships}getCollectionRemovals(){return this.collectionRemovals}getOperations(){return this.operations}}class KyselyOperationIndex{db;constructor(e){this.db=e}start(){return new KyselyOperationIndexTxn}async commit(e,I){if(I?.aborted)throw new Error("Operation aborted");const B=e,tr=B.getCollections(),rr=B.getCollectionMemberships(),ir=B.getCollectionRemovals(),lr=B.getOperations();let dr=[];return await this.db.transaction().execute(async mr=>{if(tr.length>0){const fr=tr.map(_r=>({documentId:_r,collectionId:_r,joinedOrdinal:BigInt(0),leftOrdinal:null}));await mr.insertInto("document_collections").values(fr).onConflict(_r=>_r.doNothing()).execute()}let hr=[];if(lr.length>0){const fr=lr.map(wr=>{const gr=wr.timestampUtcMs;let xr;return/^\d+$/.test(gr)?xr=Number(gr):xr=new Date(gr).getTime(),{opId:wr.id||"",documentId:wr.documentId,documentType:wr.documentType,scope:wr.scope,branch:wr.branch,timestampUtcMs:BigInt(xr||0),index:wr.index,skip:wr.skip,hash:wr.hash,action:wr.action}});hr=(await mr.insertInto("operation_index_operations").values(fr).returning("ordinal").execute()).map(wr=>wr.ordinal),dr=hr}if(rr.length>0)for(const fr of rr){const _r=hr[fr.operationIndex];await mr.insertInto("document_collections").values({documentId:fr.documentId,collectionId:fr.collectionId,joinedOrdinal:BigInt(_r),leftOrdinal:null}).onConflict(wr=>wr.columns(["documentId","collectionId"]).doUpdateSet({joinedOrdinal:BigInt(_r),leftOrdinal:null})).execute()}if(ir.length>0)for(const fr of ir){const _r=hr[fr.operationIndex];await mr.updateTable("document_collections").set({leftOrdinal:BigInt(_r)}).where("collectionId","=",fr.collectionId).where("documentId","=",fr.documentId).where("leftOrdinal","is",null).execute()}}),dr}async find(e,I,B,tr,rr){if(rr?.aborted)throw new Error("Operation aborted");let ir=this.db.selectFrom("operation_index_operations as oi").innerJoin("document_collections as dc","oi.documentId","dc.documentId").selectAll("oi").select(["dc.documentId","dc.collectionId"]).where("dc.collectionId","=",e).whereRef("oi.ordinal",">=","dc.joinedOrdinal").where(sql`dc."leftOrdinal" IS NULL OR oi.ordinal < dc."leftOrdinal"`).orderBy("oi.ordinal","asc");if(I!==void 0&&(ir=ir.where("oi.ordinal",">",I)),B?.branch&&(ir=ir.where("oi.branch","=",B.branch)),B?.scopes&&B.scopes.length>0&&(ir=ir.where("oi.scope","in",B.scopes)),tr?.cursor){const fr=Number.parseInt(tr.cursor,10);ir=ir.where("oi.ordinal",">",fr)}tr?.limit&&(ir=ir.limit(tr.limit+1));const lr=await ir.execute();let dr=!1,mr=lr;tr?.limit&&lr.length>tr.limit&&(dr=!0,mr=lr.slice(0,tr.limit));const hr=dr&&mr.length>0?mr[mr.length-1].ordinal.toString():void 0;return{items:mr.map(fr=>this.rowToOperationIndexEntry(fr)),nextCursor:hr,hasMore:dr}}async getSinceOrdinal(e,I,B){if(B?.aborted)throw new Error("Operation aborted");let tr=this.db.selectFrom("operation_index_operations").selectAll().where("ordinal",">",e).orderBy("ordinal","asc");if(I?.cursor){const mr=Number.parseInt(I.cursor,10);tr=tr.where("ordinal",">",mr)}I?.limit&&(tr=tr.limit(I.limit+1));const rr=await tr.execute();let ir=!1,lr=rr;I?.limit&&rr.length>I.limit&&(ir=!0,lr=rr.slice(0,I.limit));const dr=ir&&lr.length>0?lr[lr.length-1].ordinal.toString():void 0;return{items:lr.map(mr=>this.rowToOperationWithContext(mr)),nextCursor:dr,hasMore:ir}}rowToOperationWithContext(e){return{operation:{index:e.index,timestampUtcMs:e.timestampUtcMs.toString(),hash:e.hash,skip:e.skip,action:e.action,id:e.opId},context:{documentId:e.documentId,documentType:e.documentType,scope:e.scope,branch:e.branch,ordinal:e.ordinal}}}rowToOperationIndexEntry(e){return{ordinal:e.ordinal,documentId:e.documentId,documentType:e.documentType,branch:e.branch,scope:e.scope,index:e.index,timestampUtcMs:e.timestampUtcMs.toString(),hash:e.hash,skip:e.skip,action:e.action,id:e.opId}}}class RingBuffer{buffer;head=0;size=0;capacity;constructor(e){if(e<=0)throw new Error("Ring buffer capacity must be greater than 0");this.capacity=e,this.buffer=new Array(e)}push(e){const I=(this.head+this.size)%this.capacity;this.size<this.capacity?(this.buffer[I]=e,this.size++):(this.buffer[this.head]=e,this.head=(this.head+1)%this.capacity)}getAll(){if(this.size===0)return[];const e=[];for(let I=0;I<this.size;I++){const B=(this.head+I)%this.capacity;e.push(this.buffer[B])}return e}clear(){this.buffer=new Array(this.capacity),this.head=0,this.size=0}get length(){return this.size}}class KyselyWriteCache{streams;lruTracker;keyframeStore;operationStore;registry;config;constructor(e,I,B,tr){this.keyframeStore=e,this.operationStore=I,this.registry=B,this.config={maxDocuments:tr.maxDocuments,ringBufferSize:tr.ringBufferSize,keyframeInterval:tr.keyframeInterval},this.streams=new Map,this.lruTracker=new LRUTracker}async startup(){return Promise.resolve()}async shutdown(){return Promise.resolve()}async getState(e,I,B,tr,rr){if(rr?.aborted)throw new Error("Operation aborted");const ir=this.makeStreamKey(e,I,B),lr=this.streams.get(ir);if(lr){const hr=lr.ringBuffer.getAll();if(tr===void 0){if(hr.length>0){const fr=hr[hr.length-1];return this.lruTracker.touch(ir),fr.document}}else{const fr=hr.find(wr=>wr.revision===tr);if(fr)return this.lruTracker.touch(ir),fr.document;const _r=this.findNearestOlderSnapshot(hr,tr);if(_r){const wr=await this.warmMissRebuild(_r.document,_r.revision,e,I,B,tr,rr);return this.putState(e,I,B,tr,wr),this.lruTracker.touch(ir),wr}}}const dr=await this.coldMissRebuild(e,I,B,tr,rr);let mr=tr;return mr===void 0&&(mr=dr.header.revision[I]||0),this.putState(e,I,B,mr,dr),dr}putState(e,I,B,tr,rr){const ir=this.makeStreamKey(e,I,B),lr=this.getOrCreateStream(ir),dr={revision:tr,document:rr};lr.ringBuffer.push(dr),this.isKeyframeRevision(tr)&&this.keyframeStore.putKeyframe(e,I,B,tr,rr).catch(mr=>{console.error(`Failed to persist keyframe ${e}@${tr}:`,mr)})}invalidate(e,I,B){let tr=0;if(I===void 0&&B===void 0)for(const[rr]of this.streams.entries())rr.startsWith(`${e}:`)&&(this.streams.delete(rr),this.lruTracker.remove(rr),tr++);else if(I!==void 0&&B===void 0)for(const[rr]of this.streams.entries())rr.startsWith(`${e}:${I}:`)&&(this.streams.delete(rr),this.lruTracker.remove(rr),tr++);else if(I!==void 0&&B!==void 0){const rr=this.makeStreamKey(e,I,B);this.streams.has(rr)&&(this.streams.delete(rr),this.lruTracker.remove(rr),tr=1)}return tr}clear(){this.streams.clear(),this.lruTracker.clear()}getStream(e,I,B){const tr=this.makeStreamKey(e,I,B);return this.streams.get(tr)}async findNearestKeyframe(e,I,B,tr,rr){if(!(tr===Number.MAX_SAFE_INTEGER||tr<=0))return this.keyframeStore.findNearestKeyframe(e,I,B,tr,rr)}async coldMissRebuild(e,I,B,tr,rr){const ir=tr||Number.MAX_SAFE_INTEGER,lr=await this.findNearestKeyframe(e,I,B,ir,rr);let dr,mr,hr;if(lr)dr=lr.document,mr=lr.revision,hr=lr.document.header.documentType;else{dr=void 0,mr=0;const Mr=await this.operationStore.getSince(e,"document",B,-1,{limit:1},rr);if(Mr.items.length===0)throw new Error(`Failed to rebuild document ${e}: no CREATE_DOCUMENT operation found in document scope`);const Sr=Mr.items[0];if(Sr.action.type!=="CREATE_DOCUMENT")throw new Error(`Failed to rebuild document ${e}: first operation in document scope must be CREATE_DOCUMENT, found ${Sr.action.type}`);const yr=Sr.action;if(hr=yr.input.model,!hr)throw new Error(`Failed to rebuild document ${e}: CREATE_DOCUMENT action missing model in input`);dr=createDocumentFromAction(yr);const br=this.registry.getModule(hr),vr=await this.operationStore.getSince(e,"document",B,0,void 0,rr);for(const Cr of vr.items)Cr.index!==0&&(Cr.action.type==="UPGRADE_DOCUMENT"?applyUpgradeDocumentAction(dr,Cr.action):Cr.action.type==="DELETE_DOCUMENT"?applyDeleteDocumentAction(dr,Cr.action):dr=br.reducer(dr,Cr.action))}const fr=this.registry.getModule(hr);let _r;const wr=100;let gr;do{if(rr?.aborted)throw new Error("Operation aborted");const Mr=_r?{cursor:_r,pageSize:wr}:{pageSize:wr};try{const Sr=await this.operationStore.getSince(e,I,B,mr,Mr,rr);for(const br of Sr.items){if(tr!==void 0&&br.index>tr)break;dr=fr.reducer(dr,br.action)}const yr=tr!==void 0&&Sr.items.some(br=>br.index>=tr);gr=!!Sr.nextCursor&&!yr,gr&&(_r=Sr.nextCursor)}catch(Sr){throw new Error(`Failed to rebuild document ${e}: ${Sr instanceof Error?Sr.message:String(Sr)}`)}}while(gr);const xr=await this.operationStore.getRevisions(e,B,rr);return dr.header.revision=xr.revision,dr.header.lastModifiedAtUtcIso=xr.latestTimestamp,dr}async warmMissRebuild(e,I,B,tr,rr,ir,lr){const dr=e.header.documentType,mr=this.registry.getModule(dr);let hr=e;try{const _r=await this.operationStore.getSince(B,tr,rr,I,void 0,lr);for(const wr of _r.items){if(lr?.aborted)throw new Error("Operation aborted");if(ir!==void 0&&wr.index>ir||(hr=mr.reducer(hr,wr.action),ir!==void 0&&wr.index===ir))break}}catch(_r){throw new Error(`Failed to rebuild document ${B}: ${_r instanceof Error?_r.message:String(_r)}`)}const fr=await this.operationStore.getRevisions(B,rr,lr);return hr.header.revision=fr.revision,hr.header.lastModifiedAtUtcIso=fr.latestTimestamp,hr}findNearestOlderSnapshot(e,I){let B;for(const tr of e)tr.revision<I&&(!B||tr.revision>B.revision)&&(B=tr);return B}makeStreamKey(e,I,B){return`${e}:${I}:${B}`}getOrCreateStream(e){let I=this.streams.get(e);if(!I){if(this.streams.size>=this.config.maxDocuments){const B=this.lruTracker.evict();B&&this.streams.delete(B)}I={key:e,ringBuffer:new RingBuffer(this.config.ringBufferSize)},this.streams.set(e,I)}return this.lruTracker.touch(e),I}isKeyframeRevision(e){return e>0&&e%this.config.keyframeInterval===0}}class EventBus{eventTypeToSubscribers=new Map;subscribe(e,I){let B=this.eventTypeToSubscribers.get(e);B||(B=[],this.eventTypeToSubscribers.set(e,B)),B.push(I);let tr=!1;return()=>{if(tr)return;tr=!0;const rr=this.eventTypeToSubscribers.get(e);if(!rr)return;const ir=rr.indexOf(I);ir!==-1&&rr.splice(ir,1),rr.length===0&&this.eventTypeToSubscribers.delete(e)}}async emit(e,I){const B=this.eventTypeToSubscribers.get(e);if(!B||B.length===0)return;const tr=B.slice(),rr=[];for(const ir of tr)try{await Promise.resolve(ir(e,I))}catch(lr){rr.push(lr)}if(rr.length>0)throw new EventBusAggregateError(rr)}}var JobQueueState;(function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.PREPROCESSING=0]="PREPROCESSING",t[t.PENDING=1]="PENDING",t[t.READY=2]="READY",t[t.RUNNING=3]="RUNNING",t[t.RESOLVED=4]="RESOLVED"})(JobQueueState||(JobQueueState={}));const QueueEventTypes={JOB_AVAILABLE:1e4};class SimpleJobExecutorManager{executorFactory;eventBus;queue;jobTracker;executors=[];isRunning=!1;activeJobs=0;totalJobsProcessed=0;unsubscribe;constructor(e,I,B,tr){this.executorFactory=e,this.eventBus=I,this.queue=B,this.jobTracker=tr}async start(e){if(this.isRunning)throw new Error("JobExecutorManager is already running");if(e<1)throw new Error("Number of executors must be at least 1");this.executors=[];for(let I=0;I<e;I++)this.executors.push(this.executorFactory());this.unsubscribe=this.eventBus.subscribe(QueueEventTypes.JOB_AVAILABLE,async()=>{this.activeJobs<this.executors.length&&await this.processNextJob()}),this.isRunning=!0,await this.processExistingJobs()}async stop(e=!0){if(this.isRunning){if(this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0),e)for(;this.activeJobs>0;)await new Promise(I=>setTimeout(I,100));this.executors=[],this.isRunning=!1}}getExecutors(){return[...this.executors]}getStatus(){return{isRunning:this.isRunning,numExecutors:this.executors.length,activeJobs:this.activeJobs,totalJobsProcessed:this.totalJobsProcessed}}async processNextJob(){let e;try{e=await this.queue.dequeueNext()}catch(rr){console.error("Error dequeueing job:",rr);return}if(!e)return;e.start(),this.activeJobs++,this.jobTracker.markRunning(e.job.id);const I=this.totalJobsProcessed%this.executors.length,B=this.executors[I];let tr;try{tr=await B.executeJob(e.job)}catch(rr){const ir=this.toErrorInfo(rr instanceof Error?rr:String(rr));console.error(`Error executing job ${e.job.id}:`,ir.message),e.fail(ir),this.activeJobs--,this.jobTracker.markFailed(e.job.id,ir),this.eventBus.emit(OperationEventTypes.JOB_FAILED,{jobId:e.job.id,error:new Error(ir.message)}).catch(()=>{}),await this.checkForMoreJobs();return}if(tr.success)e.complete(),this.totalJobsProcessed++;else{const rr=e.job.retryCount||0,ir=e.job.maxRetries||0;if(rr<ir){const lr=tr.error?this.toErrorInfo(tr.error):this.toErrorInfo("Unknown error");try{await this.queue.retryJob(e.job.id,lr)}catch(dr){const mr=this.toErrorInfo(dr instanceof Error?dr:"Failed to retry job");console.error(`Failed to retry job ${e.job.id}:`,mr.message),this.jobTracker.markFailed(e.job.id,mr),this.eventBus.emit(OperationEventTypes.JOB_FAILED,{jobId:e.job.id,error:new Error(mr.message)}).catch(()=>{}),e.fail(mr)}}else{const lr=tr.error?this.toErrorInfo(tr.error):this.toErrorInfo("Unknown error"),dr=this.formatErrorHistory(e.job.errorHistory,lr,rr+1);console.error(`Job ${e.job.id} failed after ${rr+1} attempts:`,dr.message),this.jobTracker.markFailed(e.job.id,dr),this.eventBus.emit(OperationEventTypes.JOB_FAILED,{jobId:e.job.id,error:new Error(dr.message)}).catch(()=>{}),e.fail(dr)}}this.activeJobs--,await this.checkForMoreJobs()}async checkForMoreJobs(){if(!this.isRunning)return;let e;try{e=await this.queue.hasJobs()}catch(I){console.error("Error checking for more jobs:",I);return}e&&await this.processNextJob()}async processExistingJobs(){let e;try{e=await this.queue.hasJobs()}catch(I){console.error("Error checking for existing jobs:",I);return}if(e){const I=[];for(let B=0;B<Math.min(this.executors.length,5);B++)I.push(this.processNextJob());try{await Promise.all(I)}catch(B){console.error("Error processing existing jobs:",B)}}}toErrorInfo(e){return e instanceof Error?{message:e.message,stack:e.stack||new Error().stack||""}:{message:e,stack:new Error().stack||""}}formatErrorHistory(e,I,B){const tr=[...e,I];if(tr.length===1)return I;const rr=[`Job failed after ${B} attempts:`],ir=[];return tr.forEach((lr,dr)=>{rr.push(`[Attempt ${dr+1}] ${lr.message}`),ir.push(`[Attempt ${dr+1}] Stack trace:
3
3
  ${lr.stack}`)}),{message:rr.join(`
4
4
  `),stack:ir.join(`
5
5
 
@@ -18,7 +18,7 @@ ${yr.stack}`),{success:!1,generatedOperations:ir,operationsWithContext:lr,error:
18
18
  WHERE a.typcategory = 'A'
19
19
  GROUP BY b.oid, b.typarray
20
20
  ORDER BY b.oid
21
- `);for(let I of e.rows)this.serializers[I.typarray]=B=>Ke$1(B,this.serializers[I.oid],I.typarray),this.parsers[I.typarray]=B=>yn(B,this.parsers[I.oid],I.typarray)}async refreshArrayTypes(){await this._initArrayTypes({force:!0})}async query(t,e,I){return await this._checkReady(),await this._runExclusiveTransaction(async()=>await T(this,r,g$1).call(this,t,e,I))}async sql(t,...e){let{query:I,params:B}=g$2(t,...e);return await this.query(I,B)}async exec(t,e){return await this._checkReady(),await this._runExclusiveTransaction(async()=>await T(this,r,h).call(this,t,e))}async describeQuery(t,e){try{await T(this,r,l).call(this,O$1.parse({text:t,types:e?.paramTypes}),e);let I=await T(this,r,l).call(this,O$1.describe({type:"S"}),e),B=I.messages.find(lr=>lr.name==="parameterDescription"),tr=I.messages.find(lr=>lr.name==="rowDescription"),rr=B?.dataTypeIDs.map(lr=>({dataTypeID:lr,serializer:this.serializers[lr]}))??[],ir=tr?.fields.map(lr=>({name:lr.name,dataTypeID:lr.dataTypeID,parser:this.parsers[lr.dataTypeID]}))??[];return{queryParams:rr,resultFields:ir}}finally{await T(this,r,l).call(this,O$1.sync(),e)}}async transaction(t){return await this._checkReady(),await this._runExclusiveTransaction(async()=>{await T(this,r,h).call(this,"BEGIN"),x$2(this,u,!0);let e=!1,I=()=>{if(e)throw new Error("Transaction is closed")},B={query:async(tr,rr,ir)=>(I(),await T(this,r,g$1).call(this,tr,rr,ir)),sql:async(tr,...rr)=>{let{query:ir,params:lr}=g$2(tr,...rr);return await T(this,r,g$1).call(this,ir,lr)},exec:async(tr,rr)=>(I(),await T(this,r,h).call(this,tr,rr)),rollback:async()=>{I(),await T(this,r,h).call(this,"ROLLBACK"),e=!0},get closed(){return e}};try{let tr=await t(B);return e||(e=!0,await T(this,r,h).call(this,"COMMIT")),x$2(this,u,!1),tr}catch(tr){throw e||await T(this,r,h).call(this,"ROLLBACK"),x$2(this,u,!1),tr}})}async runExclusive(t){return await this._runExclusiveQuery(t)}};b=new WeakMap,u=new WeakMap,r=new WeakSet,l=async function(t,e={}){return await this.execProtocol(t,{...e,syncToFs:!1})},g$1=async function(t,e=[],I){return await this._runExclusiveQuery(async()=>{T(this,r,R).call(this,"runQuery",t,e,I),await this._handleBlob(I?.blob);let B;try{let{messages:rr}=await T(this,r,l).call(this,O$1.parse({text:t,types:I?.paramTypes}),I),ir=De((await T(this,r,l).call(this,O$1.describe({type:"S"}),I)).messages),lr=e.map((dr,mr)=>{let hr=ir[mr];if(dr==null)return null;let fr=I?.serializers?.[hr]??this.serializers[hr];return fr?fr(dr):dr.toString()});B=[...rr,...(await T(this,r,l).call(this,O$1.bind({values:lr}),I)).messages,...(await T(this,r,l).call(this,O$1.describe({type:"P"}),I)).messages,...(await T(this,r,l).call(this,O$1.execute({}),I)).messages]}finally{await T(this,r,l).call(this,O$1.sync(),I)}await this._cleanupBlob(),h$1(this,u)||await this.syncToFs();let tr=await this._getWrittenBlob();return bn(B,this.parsers,I,tr)[0]})},h=async function(t,e){return await this._runExclusiveQuery(async()=>{T(this,r,R).call(this,"runExec",t,e),await this._handleBlob(e?.blob);let I;try{I=(await T(this,r,l).call(this,O$1.query(t),e)).messages}finally{await T(this,r,l).call(this,O$1.sync(),e)}this._cleanupBlob(),h$1(this,u)||await this.syncToFs();let B=await this._getWrittenBlob();return bn(I,this.parsers,e,B)})},R=function(...t){this.debug>0&&console.log(...t)};var w=D$1((t,e)=>{u$1();var I=9007199254740991,B=(function(Sr){return Sr})();function tr(Sr){return Sr===B}function rr(Sr){return typeof Sr=="string"||Object.prototype.toString.call(Sr)=="[object String]"}function ir(Sr){return Object.prototype.toString.call(Sr)=="[object Date]"}function lr(Sr){return Sr!==null&&typeof Sr=="object"}function dr(Sr){return typeof Sr=="function"}function mr(Sr){return typeof Sr=="number"&&Sr>-1&&Sr%1==0&&Sr<=I}function hr(Sr){return Object.prototype.toString.call(Sr)=="[object Array]"}function fr(Sr){return lr(Sr)&&!dr(Sr)&&mr(Sr.length)}function _r(Sr){return Object.prototype.toString.call(Sr)=="[object ArrayBuffer]"}function wr(Sr,yr){return Array.prototype.map.call(Sr,yr)}function gr(Sr,yr){var br=B;return dr(yr)&&Array.prototype.every.call(Sr,function(vr,Cr,Ar){var Ir=yr(vr,Cr,Ar);return Ir&&(br=vr),!Ir}),br}function xr(Sr){return Object.assign.apply(null,arguments)}function Mr(Sr){var yr,br,vr;if(rr(Sr)){for(br=Sr.length,vr=new Uint8Array(br),yr=0;yr<br;yr++)vr[yr]=Sr.charCodeAt(yr)&255;return vr}return _r(Sr)?new Uint8Array(Sr):lr(Sr)&&_r(Sr.buffer)?new Uint8Array(Sr.buffer):fr(Sr)?new Uint8Array(Sr):lr(Sr)&&dr(Sr.toString)?Mr(Sr.toString()):new Uint8Array}e.exports.MAX_SAFE_INTEGER=I,e.exports.isUndefined=tr,e.exports.isString=rr,e.exports.isObject=lr,e.exports.isDateTime=ir,e.exports.isFunction=dr,e.exports.isArray=hr,e.exports.isArrayLike=fr,e.exports.isArrayBuffer=_r,e.exports.map=wr,e.exports.find=gr,e.exports.extend=xr,e.exports.toUint8Array=Mr}),x=D$1((t,e)=>{u$1();var I="\0";e.exports={NULL_CHAR:I,TMAGIC:"ustar"+I+"00",OLDGNU_MAGIC:"ustar "+I,REGTYPE:0,LNKTYPE:1,SYMTYPE:2,CHRTYPE:3,BLKTYPE:4,DIRTYPE:5,FIFOTYPE:6,CONTTYPE:7,TSUID:parseInt("4000",8),TSGID:parseInt("2000",8),TSVTX:parseInt("1000",8),TUREAD:parseInt("0400",8),TUWRITE:parseInt("0200",8),TUEXEC:parseInt("0100",8),TGREAD:parseInt("0040",8),TGWRITE:parseInt("0020",8),TGEXEC:parseInt("0010",8),TOREAD:parseInt("0004",8),TOWRITE:parseInt("0002",8),TOEXEC:parseInt("0001",8),TPERMALL:parseInt("0777",8),TPERMMASK:parseInt("0777",8)}}),L=D$1((t,e)=>{u$1();var I=w(),B=x(),tr=512,rr=B.TPERMALL,ir=0,lr=0,dr=[["name",100,0,function(yr,br){return fr(yr[br[0]],br[1])},function(yr,br,vr){return gr(yr.slice(br,br+vr[1]))}],["mode",8,100,function(yr,br){var vr=yr[br[0]]||rr;return vr=vr&B.TPERMMASK,_r(vr,br[1],rr)},function(yr,br,vr){var Cr=xr(yr.slice(br,br+vr[1]));return Cr&=B.TPERMMASK,Cr}],["uid",8,108,function(yr,br){return _r(yr[br[0]],br[1],ir)},function(yr,br,vr){return xr(yr.slice(br,br+vr[1]))}],["gid",8,116,function(yr,br){return _r(yr[br[0]],br[1],lr)},function(yr,br,vr){return xr(yr.slice(br,br+vr[1]))}],["size",12,124,function(yr,br){return _r(yr.data.length,br[1])},function(yr,br,vr){return xr(yr.slice(br,br+vr[1]))}],["modifyTime",12,136,function(yr,br){return wr(yr[br[0]],br[1])},function(yr,br,vr){return Mr(yr.slice(br,br+vr[1]))}],["checksum",8,148,function(yr,br){return" "},function(yr,br,vr){return xr(yr.slice(br,br+vr[1]))}],["type",1,156,function(yr,br){return""+(parseInt(yr[br[0]],10)||0)%8},function(yr,br,vr){return(parseInt(String.fromCharCode(yr[br]),10)||0)%8}],["linkName",100,157,function(yr,br){return""},function(yr,br,vr){return gr(yr.slice(br,br+vr[1]))}],["ustar",8,257,function(yr,br){return B.TMAGIC},function(yr,br,vr){return hr(gr(yr.slice(br,br+vr[1]),!0))},function(yr,br){return yr[br[0]]==B.TMAGIC||yr[br[0]]==B.OLDGNU_MAGIC}],["owner",32,265,function(yr,br){return fr(yr[br[0]],br[1])},function(yr,br,vr){return gr(yr.slice(br,br+vr[1]))}],["group",32,297,function(yr,br){return fr(yr[br[0]],br[1])},function(yr,br,vr){return gr(yr.slice(br,br+vr[1]))}],["majorNumber",8,329,function(yr,br){return""},function(yr,br,vr){return xr(yr.slice(br,br+vr[1]))}],["minorNumber",8,337,function(yr,br){return""},function(yr,br,vr){return xr(yr.slice(br,br+vr[1]))}],["prefix",131,345,function(yr,br){return fr(yr[br[0]],br[1])},function(yr,br,vr){return gr(yr.slice(br,br+vr[1]))}],["accessTime",12,476,function(yr,br){return wr(yr[br[0]],br[1])},function(yr,br,vr){return Mr(yr.slice(br,br+vr[1]))}],["createTime",12,488,function(yr,br){return wr(yr[br[0]],br[1])},function(yr,br,vr){return Mr(yr.slice(br,br+vr[1]))}]],mr=(function(yr){var br=yr[yr.length-1];return br[2]+br[1]})(dr);function hr(yr){if(yr.length==8){var br=yr.split("");if(br[5]==B.NULL_CHAR)return(br[6]==" "||br[6]==B.NULL_CHAR)&&(br[6]="0"),(br[7]==" "||br[7]==B.NULL_CHAR)&&(br[7]="0"),br=br.join(""),br==B.TMAGIC?br:yr;if(br[7]==B.NULL_CHAR)return br[5]==B.NULL_CHAR&&(br[5]=" "),br[6]==B.NULL_CHAR&&(br[6]=" "),br==B.OLDGNU_MAGIC?br:yr}return yr}function fr(yr,br){return br-=1,I.isUndefined(yr)&&(yr=""),yr=(""+yr).substr(0,br),yr+B.NULL_CHAR}function _r(yr,br,vr){for(vr=parseInt(vr)||0,br-=1,yr=(parseInt(yr)||vr).toString(8).substr(-br,br);yr.length<br;)yr="0"+yr;return yr+B.NULL_CHAR}function wr(yr,br){if(I.isDateTime(yr))yr=Math.floor(1*yr/1e3);else if(yr=parseInt(yr,10),isFinite(yr)){if(yr<=0)return""}else yr=Math.floor(1*new Date/1e3);return _r(yr,br,0)}function gr(yr,br){var vr=String.fromCharCode.apply(null,yr);if(br)return vr;var Cr=vr.indexOf(B.NULL_CHAR);return Cr>=0?vr.substr(0,Cr):vr}function xr(yr){var br=String.fromCharCode.apply(null,yr);return parseInt(br.replace(/^0+$/g,""),8)||0}function Mr(yr){return yr.length==0||yr[0]==0?null:new Date(1e3*xr(yr))}function Sr(yr,br,vr){var Cr=parseInt(br,10)||0,Ar=Math.min(Cr+mr,yr.length),Ir=0,Dr=0,Fr=0;vr&&dr.every(function(Pr){return Pr[0]=="checksum"?(Dr=Cr+Pr[2],Fr=Dr+Pr[1],!1):!0});for(var zr=32,Gr=Cr;Gr<Ar;Gr++){var Ur=Gr>=Dr&&Gr<Fr?zr:yr[Gr];Ir=(Ir+Ur)%262144}return Ir}e.exports.recordSize=tr,e.exports.defaultFileMode=rr,e.exports.defaultUid=ir,e.exports.defaultGid=lr,e.exports.posixHeader=dr,e.exports.effectiveHeaderSize=mr,e.exports.calculateChecksum=Sr,e.exports.formatTarString=fr,e.exports.formatTarNumber=_r,e.exports.formatTarDateTime=wr,e.exports.parseTarString=gr,e.exports.parseTarNumber=xr,e.exports.parseTarDateTime=Mr}),er=D$1((t,e)=>{u$1();var I=x(),B=w(),tr=L();function rr(fr){return tr.recordSize}function ir(fr){return Math.ceil(fr.data.length/tr.recordSize)*tr.recordSize}function lr(fr){var _r=0;return fr.forEach(function(wr){_r+=rr()+ir(wr)}),_r+=tr.recordSize*2,new Uint8Array(_r)}function dr(fr,_r,wr){wr=parseInt(wr)||0;var gr=wr;tr.posixHeader.forEach(function(br){for(var vr=br[3](_r,br),Cr=vr.length,Ar=0;Ar<Cr;Ar+=1)fr[gr+Ar]=vr.charCodeAt(Ar)&255;gr+=br[1]});var xr=B.find(tr.posixHeader,function(br){return br[0]=="checksum"});if(xr){var Mr=tr.calculateChecksum(fr,wr,!0),Sr=tr.formatTarNumber(Mr,xr[1]-2)+I.NULL_CHAR+" ";gr=wr+xr[2];for(var yr=0;yr<Sr.length;yr+=1)fr[gr]=Sr.charCodeAt(yr)&255,gr++}return wr+rr()}function mr(fr,_r,wr){return wr=parseInt(wr,10)||0,fr.set(_r.data,wr),wr+ir(_r)}function hr(fr){fr=B.map(fr,function(gr){return B.extend({},gr,{data:B.toUint8Array(gr.data)})});var _r=lr(fr),wr=0;return fr.forEach(function(gr){wr=dr(_r,gr,wr),wr=mr(_r,gr,wr)}),_r}e.exports.tar=hr}),nr=D$1((t,e)=>{u$1();var I=x(),B=w(),tr=L(),rr={extractData:!0,checkHeader:!0,checkChecksum:!0,checkFileSize:!0},ir={size:!0,checksum:!0,ustar:!0},lr={unexpectedEndOfFile:"Unexpected end of file.",fileCorrupted:"File is corrupted.",checksumCheckFailed:"Checksum check failed."};function dr(xr){return tr.recordSize}function mr(xr){return Math.ceil(xr/tr.recordSize)*tr.recordSize}function hr(xr,Mr){for(var Sr=Mr,yr=Math.min(xr.length,Mr+tr.recordSize*2),br=Sr;br<yr;br++)if(xr[br]!=0)return!1;return!0}function fr(xr,Mr,Sr){if(xr.length-Mr<tr.recordSize){if(Sr.checkFileSize)throw new Error(lr.unexpectedEndOfFile);return null}Mr=parseInt(Mr)||0;var yr={},br=Mr;if(tr.posixHeader.forEach(function(Ar){yr[Ar[0]]=Ar[4](xr,br,Ar),br+=Ar[1]}),yr.type!=0&&(yr.size=0),Sr.checkHeader&&tr.posixHeader.forEach(function(Ar){if(B.isFunction(Ar[5])&&!Ar[5](yr,Ar)){var Ir=new Error(lr.fileCorrupted);throw Ir.data={offset:Mr+Ar[2],field:Ar[0]},Ir}}),Sr.checkChecksum){var vr=tr.calculateChecksum(xr,Mr,!0);if(vr!=yr.checksum){var Cr=new Error(lr.checksumCheckFailed);throw Cr.data={offset:Mr,header:yr,checksum:vr},Cr}}return yr}function _r(xr,Mr,Sr,yr){return yr.extractData?Sr.size<=0?new Uint8Array:xr.slice(Mr,Mr+Sr.size):null}function wr(xr,Mr){var Sr={};return tr.posixHeader.forEach(function(yr){var br=yr[0];ir[br]||(Sr[br]=xr[br])}),Sr.isOldGNUFormat=xr.ustar==I.OLDGNU_MAGIC,Mr&&(Sr.data=Mr),Sr}function gr(xr,Mr){Mr=B.extend({},rr,Mr);for(var Sr=[],yr=0,br=xr.length;br-yr>=tr.recordSize;){xr=B.toUint8Array(xr);var vr=fr(xr,yr,Mr);if(!vr)break;yr+=dr();var Cr=_r(xr,yr,vr,Mr);if(Sr.push(wr(vr,Cr)),yr+=mr(vr.size),hr(xr,yr))break}return Sr}e.exports.untar=gr}),or$2=D$1((t,e)=>{u$1();var I=w(),B=x(),tr=er(),rr=nr();I.extend(e.exports,tr,rr,B)});u$1();u$1();var g=L$2(or$2());async function H$1(t,e,I="pgdata",B="auto"){let tr=Br(t,e),[rr,ir]=await qr(tr,B),lr=I+(ir?".tar.gz":".tar"),dr=ir?"application/x-gzip":"application/x-tar";return typeof File<"u"?new File([rr],lr,{type:dr}):new Blob([rr],{type:dr})}var Hr=["application/x-gtar","application/x-tar+gzip","application/x-gzip","application/gzip"];async function ce$1(t,e,I){let B=new Uint8Array(await e.arrayBuffer()),tr=typeof File<"u"&&e instanceof File?e.name:void 0;(Hr.includes(e.type)||tr?.endsWith(".tgz")||tr?.endsWith(".tar.gz"))&&(B=await ar(B));let rr;try{rr=(0,g.untar)(B)}catch(ir){if(ir instanceof Error&&ir.message.includes("File is corrupted"))B=await ar(B),rr=(0,g.untar)(B);else throw ir}for(let ir of rr){let lr=I+ir.name,dr=lr.split("/").slice(0,-1);for(let mr=1;mr<=dr.length;mr++){let hr=dr.slice(0,mr).join("/");t.analyzePath(hr).exists||t.mkdir(hr)}ir.type===g.REGTYPE?(t.writeFile(lr,ir.data),t.utime(lr,sr(ir.modifyTime),sr(ir.modifyTime))):ir.type===g.DIRTYPE&&t.mkdir(lr)}}function jr(t,e){let I=[],B=tr=>{t.readdir(tr).forEach(rr=>{if(rr==="."||rr==="..")return;let ir=tr+"/"+rr,lr=t.stat(ir),dr=t.isFile(lr.mode)?t.readFile(ir,{encoding:"binary"}):new Uint8Array(0);I.push({name:ir.substring(e.length),mode:lr.mode,size:lr.size,type:t.isFile(lr.mode)?g.REGTYPE:g.DIRTYPE,modifyTime:lr.mtime,data:dr}),t.isDir(lr.mode)&&B(ir)})};return B(e),I}function Br(t,e){let I=jr(t,e);return(0,g.tar)(I)}async function qr(t,e="auto"){if(e==="none")return[t,!1];if(typeof CompressionStream<"u")return[await Yr(t),!0];if(typeof process$1<"u"&&process$1.versions&&process$1.versions.node)return[await Wr(t),!0];if(e==="auto")return[t,!1];throw new Error("Compression not supported in this environment")}async function Yr(t){let e=new CompressionStream("gzip"),I=e.writable.getWriter(),B=e.readable.getReader();I.write(t),I.close();let tr=[];for(;;){let{value:lr,done:dr}=await B.read();if(dr)break;lr&&tr.push(lr)}let rr=new Uint8Array(tr.reduce((lr,dr)=>lr+dr.length,0)),ir=0;return tr.forEach(lr=>{rr.set(lr,ir),ir+=lr.length}),rr}async function Wr(t){let{promisify:e}=await __vitePreload(()=>Promise.resolve().then(()=>__viteBrowserExternal$1),void 0),{gzip:I}=await __vitePreload(async()=>{const{gzip:B}=await Promise.resolve().then(()=>__viteBrowserExternal$1);return{gzip:B}},void 0);return await e(I)(t)}async function ar(t){if(typeof CompressionStream<"u")return await Xr(t);if(typeof process$1<"u"&&process$1.versions&&process$1.versions.node)return await Kr(t);throw new Error("Unsupported environment for decompression")}async function Xr(t){let e=new DecompressionStream("gzip"),I=e.writable.getWriter(),B=e.readable.getReader();I.write(t),I.close();let tr=[];for(;;){let{value:lr,done:dr}=await B.read();if(dr)break;lr&&tr.push(lr)}let rr=new Uint8Array(tr.reduce((lr,dr)=>lr+dr.length,0)),ir=0;return tr.forEach(lr=>{rr.set(lr,ir),ir+=lr.length}),rr}async function Kr(t){let{promisify:e}=await __vitePreload(()=>Promise.resolve().then(()=>__viteBrowserExternal$1),void 0),{gunzip:I}=await __vitePreload(async()=>{const{gunzip:B}=await Promise.resolve().then(()=>__viteBrowserExternal$1);return{gunzip:B}},void 0);return await e(I)(t)}function sr(t){return t?typeof t=="number"?t:Math.floor(t.getTime()/1e3):Math.floor(Date.now()/1e3)}var Vr="/tmp/pglite",C=Vr+"/base",ur=class{constructor(t){this.dataDir=t}async init(t,e){return this.pg=t,{emscriptenOpts:e}}async syncToFs(t){}async initialSyncFs(){}async closeFs(){}async dumpTar(t,e){return H$1(this.pg.Module.FS,C,t,e)}},cr=class{constructor(t,{debug:e=!1}={}){this.dataDir=t,this.debug=e}async syncToFs(t){}async initialSyncFs(){}async closeFs(){}async dumpTar(t,e){return H$1(this.pg.Module.FS,C,t,e)}async init(t,e){return this.pg=t,{emscriptenOpts:{...e,preRun:[...e.preRun||[],I=>{let B=Zr(I,this);I.FS.mkdir(C),I.FS.mount(B,{},C)}]}}}},pr={EBADF:8,EBADFD:127,EEXIST:20,EINVAL:28,EISDIR:31,ENODEV:43,ENOENT:44,ENOTDIR:54,ENOTEMPTY:55},Zr=(t,e)=>{let I=t.FS,B=e.debug?console.log:null,tr={tryFSOperation(rr){try{return rr()}catch(ir){throw ir.code?ir.code==="UNKNOWN"?new I.ErrnoError(pr.EINVAL):new I.ErrnoError(ir.code):ir}},mount(rr){return tr.createNode(null,"/",16895,0)},syncfs(rr,ir,lr){},createNode(rr,ir,lr,dr){if(!I.isDir(lr)&&!I.isFile(lr))throw new I.ErrnoError(28);let mr=I.createNode(rr,ir,lr);return mr.node_ops=tr.node_ops,mr.stream_ops=tr.stream_ops,mr},getMode:function(rr){return B?.("getMode",rr),tr.tryFSOperation(()=>e.lstat(rr).mode)},realPath:function(rr){let ir=[];for(;rr.parent!==rr;)ir.push(rr.name),rr=rr.parent;return ir.push(rr.mount.opts.root),ir.reverse(),ir.join("/")},node_ops:{getattr(rr){B?.("getattr",tr.realPath(rr));let ir=tr.realPath(rr);return tr.tryFSOperation(()=>{let lr=e.lstat(ir);return{...lr,dev:0,ino:rr.id,nlink:1,rdev:rr.rdev,atime:new Date(lr.atime),mtime:new Date(lr.mtime),ctime:new Date(lr.ctime)}})},setattr(rr,ir){B?.("setattr",tr.realPath(rr),ir);let lr=tr.realPath(rr);tr.tryFSOperation(()=>{ir.mode!==void 0&&e.chmod(lr,ir.mode),ir.size!==void 0&&e.truncate(lr,ir.size),ir.timestamp!==void 0&&e.utimes(lr,ir.timestamp,ir.timestamp),ir.size!==void 0&&e.truncate(lr,ir.size)})},lookup(rr,ir){B?.("lookup",tr.realPath(rr),ir);let lr=[tr.realPath(rr),ir].join("/"),dr=tr.getMode(lr);return tr.createNode(rr,ir,dr)},mknod(rr,ir,lr,dr){B?.("mknod",tr.realPath(rr),ir,lr,dr);let mr=tr.createNode(rr,ir,lr,dr),hr=tr.realPath(mr);return tr.tryFSOperation(()=>(I.isDir(mr.mode)?e.mkdir(hr,{mode:lr}):e.writeFile(hr,"",{mode:lr}),mr))},rename(rr,ir,lr){B?.("rename",tr.realPath(rr),tr.realPath(ir),lr);let dr=tr.realPath(rr),mr=[tr.realPath(ir),lr].join("/");tr.tryFSOperation(()=>{e.rename(dr,mr)}),rr.name=lr},unlink(rr,ir){B?.("unlink",tr.realPath(rr),ir);let lr=[tr.realPath(rr),ir].join("/");try{e.unlink(lr)}catch{}},rmdir(rr,ir){B?.("rmdir",tr.realPath(rr),ir);let lr=[tr.realPath(rr),ir].join("/");return tr.tryFSOperation(()=>{e.rmdir(lr)})},readdir(rr){B?.("readdir",tr.realPath(rr));let ir=tr.realPath(rr);return tr.tryFSOperation(()=>e.readdir(ir))},symlink(rr,ir,lr){throw B?.("symlink",tr.realPath(rr),ir,lr),new I.ErrnoError(63)},readlink(rr){throw B?.("readlink",tr.realPath(rr)),new I.ErrnoError(63)}},stream_ops:{open(rr){B?.("open stream",tr.realPath(rr.node));let ir=tr.realPath(rr.node);return tr.tryFSOperation(()=>{I.isFile(rr.node.mode)&&(rr.shared.refcount=1,rr.nfd=e.open(ir))})},close(rr){return B?.("close stream",tr.realPath(rr.node)),tr.tryFSOperation(()=>{I.isFile(rr.node.mode)&&rr.nfd&&--rr.shared.refcount===0&&e.close(rr.nfd)})},dup(rr){B?.("dup stream",tr.realPath(rr.node)),rr.shared.refcount++},read(rr,ir,lr,dr,mr){return B?.("read stream",tr.realPath(rr.node),lr,dr,mr),dr===0?0:tr.tryFSOperation(()=>e.read(rr.nfd,ir,lr,dr,mr))},write(rr,ir,lr,dr,mr){return B?.("write stream",tr.realPath(rr.node),lr,dr,mr),tr.tryFSOperation(()=>e.write(rr.nfd,ir.buffer,lr,dr,mr))},llseek(rr,ir,lr){B?.("llseek stream",tr.realPath(rr.node),ir,lr);let dr=ir;if(lr===1?dr+=rr.position:lr===2&&I.isFile(rr.node.mode)&&tr.tryFSOperation(()=>{let mr=e.fstat(rr.nfd);dr+=mr.size}),dr<0)throw new I.ErrnoError(28);return dr},mmap(rr,ir,lr,dr,mr){if(B?.("mmap stream",tr.realPath(rr.node),ir,lr,dr,mr),!I.isFile(rr.node.mode))throw new I.ErrnoError(pr.ENODEV);let hr=t.mmapAlloc(ir);return tr.stream_ops.read(rr,t.HEAP8,hr,ir,lr),{ptr:hr,allocated:!0}},msync(rr,ir,lr,dr,mr){return B?.("msync stream",tr.realPath(rr.node),lr,dr,mr),tr.stream_ops.write(rr,ir,0,dr,lr),0}}};return tr};u$1();u$1();u$1();var He=new Error("request for lock canceled"),We=function(t,e,I,B){function tr(rr){return rr instanceof I?rr:new I(function(ir){ir(rr)})}return new(I||(I=Promise))(function(rr,ir){function lr(hr){try{mr(B.next(hr))}catch(fr){ir(fr)}}function dr(hr){try{mr(B.throw(hr))}catch(fr){ir(fr)}}function mr(hr){hr.done?rr(hr.value):tr(hr.value).then(lr,dr)}mr((B=B.apply(t,[])).next())})},ce=class{constructor(t,e=He){this._value=t,this._cancelError=e,this._weightedQueues=[],this._weightedWaiters=[]}acquire(t=1){if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);return new Promise((e,I)=>{this._weightedQueues[t-1]||(this._weightedQueues[t-1]=[]),this._weightedQueues[t-1].push({resolve:e,reject:I}),this._dispatch()})}runExclusive(t,e=1){return We(this,void 0,void 0,function*(){let[I,B]=yield this.acquire(e);try{return yield t(I)}finally{B()}})}waitForUnlock(t=1){if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);return new Promise(e=>{this._weightedWaiters[t-1]||(this._weightedWaiters[t-1]=[]),this._weightedWaiters[t-1].push(e),this._dispatch()})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(t){this._value=t,this._dispatch()}release(t=1){if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);this._value+=t,this._dispatch()}cancel(){this._weightedQueues.forEach(t=>t.forEach(e=>e.reject(this._cancelError))),this._weightedQueues=[]}_dispatch(){var t;for(let e=this._value;e>0;e--){let I=(t=this._weightedQueues[e-1])===null||t===void 0?void 0:t.shift();if(!I)continue;let B=this._value,tr=e;this._value-=e,e=this._value+1,I.resolve([B,this._newReleaser(tr)])}this._drainUnlockWaiters()}_newReleaser(t){let e=!1;return()=>{e||(e=!0,this.release(t))}}_drainUnlockWaiters(){for(let t=this._value;t>0;t--)this._weightedWaiters[t-1]&&(this._weightedWaiters[t-1].forEach(e=>e()),this._weightedWaiters[t-1]=[])}},je=function(t,e,I,B){function tr(rr){return rr instanceof I?rr:new I(function(ir){ir(rr)})}return new(I||(I=Promise))(function(rr,ir){function lr(hr){try{mr(B.next(hr))}catch(fr){ir(fr)}}function dr(hr){try{mr(B.throw(hr))}catch(fr){ir(fr)}}function mr(hr){hr.done?rr(hr.value):tr(hr.value).then(lr,dr)}mr((B=B.apply(t,[])).next())})},H=class{constructor(t){this._semaphore=new ce(1,t)}acquire(){return je(this,void 0,void 0,function*(){let[,t]=yield this._semaphore.acquire();return t})}runExclusive(t){return this._semaphore.runExclusive(()=>t())}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}};u$1();var Ie=L$2(or$2());async function ge(t){if(Fe$1){let e=await __vitePreload(()=>Promise.resolve().then(()=>__viteBrowserExternal$1),void 0),I=await __vitePreload(()=>Promise.resolve().then(()=>__viteBrowserExternal$1),void 0),{Writable:B}=await __vitePreload(async()=>{const{Writable:lr}=await Promise.resolve().then(()=>__viteBrowserExternal$1);return{Writable:lr}},void 0),{pipeline:tr}=await __vitePreload(async()=>{const{pipeline:lr}=await Promise.resolve().then(()=>__viteBrowserExternal$1);return{pipeline:lr}},void 0);if(!e.existsSync(t))throw new Error(`Extension bundle not found: ${t}`);let rr=I.createGunzip(),ir=[];return await tr(e.createReadStream(t),rr,new B({write(lr,dr,mr){ir.push(lr),mr()}})),new Blob(ir)}else{let e=await fetch(t.toString());if(!e.ok||!e.body)return null;if(e.headers.get("Content-Encoding")==="gzip")return e.blob();{let I=new DecompressionStream("gzip");return new Response(e.body.pipeThrough(I)).blob()}}}async function Pe(t,e){for(let I in t.pg_extensions){let B;try{B=await t.pg_extensions[I]}catch(tr){console.error("Failed to fetch extension:",I,tr);continue}if(B){let tr=new Uint8Array(await B.arrayBuffer());Ve(t,I,tr,e)}else console.error("Could not get binary data for extension:",I)}}function Ve(t,e,I,B){Ie.default.untar(I).forEach(tr=>{if(!tr.name.startsWith(".")){let rr=t.WASM_PREFIX+"/"+tr.name;if(tr.name.endsWith(".so")){let ir=(...dr)=>{B("pgfs:ext OK",rr,dr)},lr=(...dr)=>{B("pgfs:ext FAIL",rr,dr)};t.FS.createPreloadedFile(Ke(rr),tr.name.split("/").pop().slice(0,-3),tr.data,!0,!0,ir,lr,!1)}else t.FS.writeFile(rr,tr.data)}})}function Ke(t){let e=t.lastIndexOf("/");return e>0?t.slice(0,e):t}u$1();u$1();var ee=class extends ur{async init(t,e){return this.pg=t,{emscriptenOpts:{...e,preRun:[...e.preRun||[],I=>{let B=I.FS.filesystems.IDBFS;I.FS.mkdir("/pglite"),I.FS.mkdir(`/pglite/${this.dataDir}`),I.FS.mount(B,{},`/pglite/${this.dataDir}`),I.FS.symlink(`/pglite/${this.dataDir}`,C)}]}}}initialSyncFs(){return new Promise((t,e)=>{this.pg.Module.FS.syncfs(!0,I=>{I?e(I):t()})})}syncToFs(t){return new Promise((e,I)=>{this.pg.Module.FS.syncfs(!1,B=>{B?I(B):e()})})}async closeFs(){let t=this.pg.Module.FS.filesystems.IDBFS.dbs[this.dataDir];t&&t.close(),this.pg.Module.FS.quit()}};u$1();var te=class extends ur{async closeFs(){this.pg.Module.FS.quit()}};function Fe(t){let e;if(t?.startsWith("file://")){if(t=t.slice(7),!t)throw new Error("Invalid dataDir, must be a valid path");e="nodefs"}else t?.startsWith("idb://")?(t=t.slice(6),e="idbfs"):t?.startsWith("opfs-ahp://")?(t=t.slice(11),e="opfs-ahp"):!t||t?.startsWith("memory://")?e="memoryfs":e="nodefs";return{dataDir:t,fsType:e}}async function Ae(t,e){let I;if(t&&e==="nodefs"){let{NodeFS:B}=await __vitePreload(()=>import("./nodefs-DmjA5Too.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]));I=new B(t)}else if(t&&e==="idbfs")I=new ee(t);else if(t&&e==="opfs-ahp"){let{OpfsAhpFS:B}=await __vitePreload(()=>import("./opfs-ahp-C3aLiPPU.js"),__vite__mapDeps([18,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]));I=new B(t)}else I=new te;return I}u$1();u$1();var Qe=(()=>{var _scriptName=import.meta.url;return async function(moduleArg={}){var moduleRtn,Module=moduleArg,readyPromiseResolve,readyPromiseReject,readyPromise=new Promise((t,e)=>{readyPromiseResolve=t,readyPromiseReject=e}),ENVIRONMENT_IS_WEB=typeof window=="object",ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope<"u",ENVIRONMENT_IS_NODE=typeof process$1=="object"&&typeof process$1.versions=="object"&&typeof process$1.versions.node=="string"&&process$1.type!="renderer";if(ENVIRONMENT_IS_NODE){let{createRequire:t}=await __vitePreload(()=>Promise.resolve().then(()=>__viteBrowserExternal$1),void 0),e=import.meta.url;e.startsWith("data:")&&(e="/");var require=t(e)}Module.expectedDataFileDownloads??(Module.expectedDataFileDownloads=0),Module.expectedDataFileDownloads++,(()=>{var t=typeof ENVIRONMENT_IS_PTHREAD<"u"&&ENVIRONMENT_IS_PTHREAD,e=typeof ENVIRONMENT_IS_WASM_WORKER<"u"&&ENVIRONMENT_IS_WASM_WORKER;if(t||e)return;var I=typeof process$1=="object"&&typeof process$1.versions=="object"&&typeof process$1.versions.node=="string";function B(tr){typeof window=="object"?window.encodeURIComponent(window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/"):typeof process$1>"u"&&typeof location<"u"&&encodeURIComponent(location.pathname.substring(0,location.pathname.lastIndexOf("/"))+"/");var rr="postgres.data",ir="postgres.data",lr=Module.locateFile?Module.locateFile(ir,""):ir,dr=tr.remote_package_size;function mr(gr,xr,Mr,Sr){if(I){require("fs").readFile(gr,(yr,br)=>{yr?Sr(yr):Mr(br.buffer)});return}Module.dataFileDownloads??(Module.dataFileDownloads={}),fetch(gr).catch(yr=>Promise.reject(new Error(`Network Error: ${gr}`,{cause:yr}))).then(yr=>{if(!yr.ok)return Promise.reject(new Error(`${yr.status}: ${yr.url}`));if(!yr.body&&yr.arrayBuffer)return yr.arrayBuffer().then(Mr);let br=yr.body.getReader(),vr=()=>br.read().then(Fr).catch(zr=>Promise.reject(new Error(`Unexpected error while handling : ${yr.url} ${zr}`,{cause:zr}))),Cr=[],Ar=yr.headers,Ir=Number(Ar.get("Content-Length")??xr),Dr=0,Fr=({done:zr,value:Gr})=>{if(zr){let Ur=new Uint8Array(Cr.map(kr=>kr.length).reduce((kr,Or)=>kr+Or,0)),Pr=0;for(let kr of Cr)Ur.set(kr,Pr),Pr+=kr.length;Mr(Ur.buffer)}else{Cr.push(Gr),Dr+=Gr.length,Module.dataFileDownloads[gr]={loaded:Dr,total:Ir};let Ur=0,Pr=0;for(let kr of Object.values(Module.dataFileDownloads))Ur+=kr.loaded,Pr+=kr.total;return Module.setStatus?.(`Downloading data... (${Ur}/${Pr})`),vr()}};return Module.setStatus?.("Downloading data..."),vr()})}function hr(gr){console.error("package error:",gr)}var fr=null,_r=Module.getPreloadedPackage?Module.getPreloadedPackage(lr,dr):null;_r||mr(lr,dr,gr=>{fr?(fr(gr),fr=null):_r=gr},hr);function wr(gr){function xr(vr,Cr){if(!vr)throw Cr+new Error().stack}gr.FS_createPath("/","home",!0,!0),gr.FS_createPath("/home","web_user",!0,!0),gr.FS_createPath("/","tmp",!0,!0),gr.FS_createPath("/tmp","pglite",!0,!0),gr.FS_createPath("/tmp/pglite","bin",!0,!0),gr.FS_createPath("/tmp/pglite","lib",!0,!0),gr.FS_createPath("/tmp/pglite/lib","postgresql",!0,!0),gr.FS_createPath("/tmp/pglite/lib/postgresql","pgxs",!0,!0),gr.FS_createPath("/tmp/pglite/lib/postgresql/pgxs","config",!0,!0),gr.FS_createPath("/tmp/pglite/lib/postgresql/pgxs","src",!0,!0),gr.FS_createPath("/tmp/pglite/lib/postgresql/pgxs/src","makefiles",!0,!0),gr.FS_createPath("/tmp/pglite/lib/postgresql/pgxs/src","test",!0,!0),gr.FS_createPath("/tmp/pglite/lib/postgresql/pgxs/src/test","isolation",!0,!0),gr.FS_createPath("/tmp/pglite/lib/postgresql/pgxs/src/test","regress",!0,!0),gr.FS_createPath("/tmp/pglite","share",!0,!0),gr.FS_createPath("/tmp/pglite/share","postgresql",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql","extension",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql","timezone",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Africa",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","America",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone/America","Argentina",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone/America","Indiana",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone/America","Kentucky",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone/America","North_Dakota",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Antarctica",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Arctic",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Asia",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Atlantic",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Australia",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Brazil",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Canada",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Chile",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Etc",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Europe",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Indian",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Mexico",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Pacific",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","US",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql","timezonesets",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql","tsearch_data",!0,!0);function Mr(vr,Cr,Ar){this.start=vr,this.end=Cr,this.audio=Ar}Mr.prototype={requests:{},open:function(vr,Cr){this.name=Cr,this.requests[Cr]=this,gr.addRunDependency(`fp ${this.name}`)},send:function(){},onload:function(){var vr=this.byteArray.subarray(this.start,this.end);this.finish(vr)},finish:function(vr){var Cr=this;gr.FS_createDataFile(this.name,null,vr,!0,!0,!0),gr.removeRunDependency(`fp ${Cr.name}`),this.requests[this.name]=null}};for(var Sr=tr.files,yr=0;yr<Sr.length;++yr)new Mr(Sr[yr].start,Sr[yr].end,Sr[yr].audio||0).open("GET",Sr[yr].filename);function br(vr){xr(vr,"Loading data file failed."),xr(vr.constructor.name===ArrayBuffer.name,"bad input to processPackageData");var Cr=new Uint8Array(vr);Mr.prototype.byteArray=Cr;for(var Ar=tr.files,Ir=0;Ir<Ar.length;++Ir)Mr.prototype.requests[Ar[Ir].filename].onload();gr.removeRunDependency("datafile_postgres.data")}gr.addRunDependency("datafile_postgres.data"),gr.preloadResults??(gr.preloadResults={}),gr.preloadResults[rr]={fromCache:!1},_r?(br(_r),_r=null):fr=br}Module.calledRun?wr(Module):(Module.preRun??(Module.preRun=[])).push(wr)}B({files:[{filename:"/home/web_user/.pgpass",start:0,end:204},{filename:"/tmp/pglite/bin/initdb",start:204,end:216},{filename:"/tmp/pglite/bin/postgres",start:216,end:228},{filename:"/tmp/pglite/lib/postgresql/cyrillic_and_mic.so",start:228,end:20397},{filename:"/tmp/pglite/lib/postgresql/dict_snowball.so",start:20397,end:1581299},{filename:"/tmp/pglite/lib/postgresql/euc2004_sjis2004.so",start:1581299,end:1592382},{filename:"/tmp/pglite/lib/postgresql/euc_cn_and_mic.so",start:1592382,end:1599256},{filename:"/tmp/pglite/lib/postgresql/euc_jp_and_sjis.so",start:1599256,end:1622931},{filename:"/tmp/pglite/lib/postgresql/euc_kr_and_mic.so",start:1622931,end:1630057},{filename:"/tmp/pglite/lib/postgresql/euc_tw_and_big5.so",start:1630057,end:1651566},{filename:"/tmp/pglite/lib/postgresql/latin2_and_win1250.so",start:1651566,end:1660345},{filename:"/tmp/pglite/lib/postgresql/latin_and_mic.so",start:1660345,end:1668272},{filename:"/tmp/pglite/lib/postgresql/libpqwalreceiver.so",start:1668272,end:2186522},{filename:"/tmp/pglite/lib/postgresql/pgoutput.so",start:2186522,end:2303364},{filename:"/tmp/pglite/lib/postgresql/pgxs/config/install-sh",start:2303364,end:2317361},{filename:"/tmp/pglite/lib/postgresql/pgxs/config/missing",start:2317361,end:2318709},{filename:"/tmp/pglite/lib/postgresql/pgxs/src/Makefile.global",start:2318709,end:2354956},{filename:"/tmp/pglite/lib/postgresql/pgxs/src/Makefile.port",start:2354956,end:2355232},{filename:"/tmp/pglite/lib/postgresql/pgxs/src/Makefile.shlib",start:2355232,end:2371270},{filename:"/tmp/pglite/lib/postgresql/pgxs/src/makefiles/pgxs.mk",start:2371270,end:2386198},{filename:"/tmp/pglite/lib/postgresql/pgxs/src/nls-global.mk",start:2386198,end:2393083},{filename:"/tmp/pglite/lib/postgresql/pgxs/src/test/isolation/isolationtester.cjs",start:2393083,end:2589770},{filename:"/tmp/pglite/lib/postgresql/pgxs/src/test/isolation/pg_isolation_regress.cjs",start:2589770,end:2742128},{filename:"/tmp/pglite/lib/postgresql/pgxs/src/test/regress/pg_regress.cjs",start:2742128,end:2894476},{filename:"/tmp/pglite/lib/postgresql/plpgsql.so",start:2894476,end:3653241},{filename:"/tmp/pglite/password",start:3653241,end:3653250},{filename:"/tmp/pglite/share/postgresql/errcodes.txt",start:3653250,end:3686708},{filename:"/tmp/pglite/share/postgresql/extension/plpgsql--1.0.sql",start:3686708,end:3687366},{filename:"/tmp/pglite/share/postgresql/extension/plpgsql.control",start:3687366,end:3687559},{filename:"/tmp/pglite/share/postgresql/fix-CVE-2024-4317.sql",start:3687559,end:3693324},{filename:"/tmp/pglite/share/postgresql/information_schema.sql",start:3693324,end:3808299},{filename:"/tmp/pglite/share/postgresql/pg_hba.conf.sample",start:3808299,end:3813924},{filename:"/tmp/pglite/share/postgresql/pg_ident.conf.sample",start:3813924,end:3816564},{filename:"/tmp/pglite/share/postgresql/pg_service.conf.sample",start:3816564,end:3817168},{filename:"/tmp/pglite/share/postgresql/postgres.bki",start:3817168,end:4761272},{filename:"/tmp/pglite/share/postgresql/postgresql.conf.sample",start:4761272,end:4790919},{filename:"/tmp/pglite/share/postgresql/psqlrc.sample",start:4790919,end:4791197},{filename:"/tmp/pglite/share/postgresql/snowball_create.sql",start:4791197,end:4835373},{filename:"/tmp/pglite/share/postgresql/sql_features.txt",start:4835373,end:4871054},{filename:"/tmp/pglite/share/postgresql/system_constraints.sql",start:4871054,end:4879949},{filename:"/tmp/pglite/share/postgresql/system_functions.sql",start:4879949,end:4903264},{filename:"/tmp/pglite/share/postgresql/system_views.sql",start:4903264,end:4953537},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Abidjan",start:4953537,end:4953667},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Accra",start:4953667,end:4953797},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Addis_Ababa",start:4953797,end:4953988},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Algiers",start:4953988,end:4954458},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Asmara",start:4954458,end:4954649},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Asmera",start:4954649,end:4954840},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Bamako",start:4954840,end:4954970},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Bangui",start:4954970,end:4955150},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Banjul",start:4955150,end:4955280},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Bissau",start:4955280,end:4955429},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Blantyre",start:4955429,end:4955560},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Brazzaville",start:4955560,end:4955740},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Bujumbura",start:4955740,end:4955871},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Cairo",start:4955871,end:4957180},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Casablanca",start:4957180,end:4959099},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Ceuta",start:4959099,end:4959661},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Conakry",start:4959661,end:4959791},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Dakar",start:4959791,end:4959921},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Dar_es_Salaam",start:4959921,end:4960112},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Djibouti",start:4960112,end:4960303},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Douala",start:4960303,end:4960483},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/El_Aaiun",start:4960483,end:4962313},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Freetown",start:4962313,end:4962443},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Gaborone",start:4962443,end:4962574},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Harare",start:4962574,end:4962705},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Johannesburg",start:4962705,end:4962895},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Juba",start:4962895,end:4963353},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Kampala",start:4963353,end:4963544},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Khartoum",start:4963544,end:4964002},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Kigali",start:4964002,end:4964133},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Kinshasa",start:4964133,end:4964313},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Lagos",start:4964313,end:4964493},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Libreville",start:4964493,end:4964673},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Lome",start:4964673,end:4964803},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Luanda",start:4964803,end:4964983},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Lubumbashi",start:4964983,end:4965114},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Lusaka",start:4965114,end:4965245},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Malabo",start:4965245,end:4965425},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Maputo",start:4965425,end:4965556},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Maseru",start:4965556,end:4965746},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Mbabane",start:4965746,end:4965936},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Mogadishu",start:4965936,end:4966127},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Monrovia",start:4966127,end:4966291},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Nairobi",start:4966291,end:4966482},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Ndjamena",start:4966482,end:4966642},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Niamey",start:4966642,end:4966822},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Nouakchott",start:4966822,end:4966952},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Ouagadougou",start:4966952,end:4967082},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Porto-Novo",start:4967082,end:4967262},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Sao_Tome",start:4967262,end:4967435},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Timbuktu",start:4967435,end:4967565},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Tripoli",start:4967565,end:4967996},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Tunis",start:4967996,end:4968445},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Windhoek",start:4968445,end:4969083},{filename:"/tmp/pglite/share/postgresql/timezone/America/Adak",start:4969083,end:4970052},{filename:"/tmp/pglite/share/postgresql/timezone/America/Anchorage",start:4970052,end:4971029},{filename:"/tmp/pglite/share/postgresql/timezone/America/Anguilla",start:4971029,end:4971206},{filename:"/tmp/pglite/share/postgresql/timezone/America/Antigua",start:4971206,end:4971383},{filename:"/tmp/pglite/share/postgresql/timezone/America/Araguaina",start:4971383,end:4971975},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Buenos_Aires",start:4971975,end:4972683},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Catamarca",start:4972683,end:4973391},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/ComodRivadavia",start:4973391,end:4974099},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Cordoba",start:4974099,end:4974807},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Jujuy",start:4974807,end:4975497},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/La_Rioja",start:4975497,end:4976214},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Mendoza",start:4976214,end:4976922},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Rio_Gallegos",start:4976922,end:4977630},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Salta",start:4977630,end:4978320},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/San_Juan",start:4978320,end:4979037},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/San_Luis",start:4979037,end:4979754},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Tucuman",start:4979754,end:4980480},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Ushuaia",start:4980480,end:4981188},{filename:"/tmp/pglite/share/postgresql/timezone/America/Aruba",start:4981188,end:4981365},{filename:"/tmp/pglite/share/postgresql/timezone/America/Asuncion",start:4981365,end:4982249},{filename:"/tmp/pglite/share/postgresql/timezone/America/Atikokan",start:4982249,end:4982398},{filename:"/tmp/pglite/share/postgresql/timezone/America/Atka",start:4982398,end:4983367},{filename:"/tmp/pglite/share/postgresql/timezone/America/Bahia",start:4983367,end:4984049},{filename:"/tmp/pglite/share/postgresql/timezone/America/Bahia_Banderas",start:4984049,end:4984777},{filename:"/tmp/pglite/share/postgresql/timezone/America/Barbados",start:4984777,end:4985055},{filename:"/tmp/pglite/share/postgresql/timezone/America/Belem",start:4985055,end:4985449},{filename:"/tmp/pglite/share/postgresql/timezone/America/Belize",start:4985449,end:4986494},{filename:"/tmp/pglite/share/postgresql/timezone/America/Blanc-Sablon",start:4986494,end:4986671},{filename:"/tmp/pglite/share/postgresql/timezone/America/Boa_Vista",start:4986671,end:4987101},{filename:"/tmp/pglite/share/postgresql/timezone/America/Bogota",start:4987101,end:4987280},{filename:"/tmp/pglite/share/postgresql/timezone/America/Boise",start:4987280,end:4988279},{filename:"/tmp/pglite/share/postgresql/timezone/America/Buenos_Aires",start:4988279,end:4988987},{filename:"/tmp/pglite/share/postgresql/timezone/America/Cambridge_Bay",start:4988987,end:4989870},{filename:"/tmp/pglite/share/postgresql/timezone/America/Campo_Grande",start:4989870,end:4990822},{filename:"/tmp/pglite/share/postgresql/timezone/America/Cancun",start:4990822,end:4991351},{filename:"/tmp/pglite/share/postgresql/timezone/America/Caracas",start:4991351,end:4991541},{filename:"/tmp/pglite/share/postgresql/timezone/America/Catamarca",start:4991541,end:4992249},{filename:"/tmp/pglite/share/postgresql/timezone/America/Cayenne",start:4992249,end:4992400},{filename:"/tmp/pglite/share/postgresql/timezone/America/Cayman",start:4992400,end:4992549},{filename:"/tmp/pglite/share/postgresql/timezone/America/Chicago",start:4992549,end:4994303},{filename:"/tmp/pglite/share/postgresql/timezone/America/Chihuahua",start:4994303,end:4994994},{filename:"/tmp/pglite/share/postgresql/timezone/America/Ciudad_Juarez",start:4994994,end:4995712},{filename:"/tmp/pglite/share/postgresql/timezone/America/Coral_Harbour",start:4995712,end:4995861},{filename:"/tmp/pglite/share/postgresql/timezone/America/Cordoba",start:4995861,end:4996569},{filename:"/tmp/pglite/share/postgresql/timezone/America/Costa_Rica",start:4996569,end:4996801},{filename:"/tmp/pglite/share/postgresql/timezone/America/Creston",start:4996801,end:4997041},{filename:"/tmp/pglite/share/postgresql/timezone/America/Cuiaba",start:4997041,end:4997975},{filename:"/tmp/pglite/share/postgresql/timezone/America/Curacao",start:4997975,end:4998152},{filename:"/tmp/pglite/share/postgresql/timezone/America/Danmarkshavn",start:4998152,end:4998599},{filename:"/tmp/pglite/share/postgresql/timezone/America/Dawson",start:4998599,end:4999628},{filename:"/tmp/pglite/share/postgresql/timezone/America/Dawson_Creek",start:4999628,end:5000311},{filename:"/tmp/pglite/share/postgresql/timezone/America/Denver",start:5000311,end:5001353},{filename:"/tmp/pglite/share/postgresql/timezone/America/Detroit",start:5001353,end:5002252},{filename:"/tmp/pglite/share/postgresql/timezone/America/Dominica",start:5002252,end:5002429},{filename:"/tmp/pglite/share/postgresql/timezone/America/Edmonton",start:5002429,end:5003399},{filename:"/tmp/pglite/share/postgresql/timezone/America/Eirunepe",start:5003399,end:5003835},{filename:"/tmp/pglite/share/postgresql/timezone/America/El_Salvador",start:5003835,end:5004011},{filename:"/tmp/pglite/share/postgresql/timezone/America/Ensenada",start:5004011,end:5005036},{filename:"/tmp/pglite/share/postgresql/timezone/America/Fort_Nelson",start:5005036,end:5006484},{filename:"/tmp/pglite/share/postgresql/timezone/America/Fort_Wayne",start:5006484,end:5007015},{filename:"/tmp/pglite/share/postgresql/timezone/America/Fortaleza",start:5007015,end:5007499},{filename:"/tmp/pglite/share/postgresql/timezone/America/Glace_Bay",start:5007499,end:5008379},{filename:"/tmp/pglite/share/postgresql/timezone/America/Godthab",start:5008379,end:5009344},{filename:"/tmp/pglite/share/postgresql/timezone/America/Goose_Bay",start:5009344,end:5010924},{filename:"/tmp/pglite/share/postgresql/timezone/America/Grand_Turk",start:5010924,end:5011777},{filename:"/tmp/pglite/share/postgresql/timezone/America/Grenada",start:5011777,end:5011954},{filename:"/tmp/pglite/share/postgresql/timezone/America/Guadeloupe",start:5011954,end:5012131},{filename:"/tmp/pglite/share/postgresql/timezone/America/Guatemala",start:5012131,end:5012343},{filename:"/tmp/pglite/share/postgresql/timezone/America/Guayaquil",start:5012343,end:5012522},{filename:"/tmp/pglite/share/postgresql/timezone/America/Guyana",start:5012522,end:5012703},{filename:"/tmp/pglite/share/postgresql/timezone/America/Halifax",start:5012703,end:5014375},{filename:"/tmp/pglite/share/postgresql/timezone/America/Havana",start:5014375,end:5015492},{filename:"/tmp/pglite/share/postgresql/timezone/America/Hermosillo",start:5015492,end:5015778},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indiana/Indianapolis",start:5015778,end:5016309},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indiana/Knox",start:5016309,end:5017325},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indiana/Marengo",start:5017325,end:5017892},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indiana/Petersburg",start:5017892,end:5018575},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indiana/Tell_City",start:5018575,end:5019097},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indiana/Vevay",start:5019097,end:5019466},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indiana/Vincennes",start:5019466,end:5020024},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indiana/Winamac",start:5020024,end:5020636},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indianapolis",start:5020636,end:5021167},{filename:"/tmp/pglite/share/postgresql/timezone/America/Inuvik",start:5021167,end:5021984},{filename:"/tmp/pglite/share/postgresql/timezone/America/Iqaluit",start:5021984,end:5022839},{filename:"/tmp/pglite/share/postgresql/timezone/America/Jamaica",start:5022839,end:5023178},{filename:"/tmp/pglite/share/postgresql/timezone/America/Jujuy",start:5023178,end:5023868},{filename:"/tmp/pglite/share/postgresql/timezone/America/Juneau",start:5023868,end:5024834},{filename:"/tmp/pglite/share/postgresql/timezone/America/Kentucky/Louisville",start:5024834,end:5026076},{filename:"/tmp/pglite/share/postgresql/timezone/America/Kentucky/Monticello",start:5026076,end:5027048},{filename:"/tmp/pglite/share/postgresql/timezone/America/Knox_IN",start:5027048,end:5028064},{filename:"/tmp/pglite/share/postgresql/timezone/America/Kralendijk",start:5028064,end:5028241},{filename:"/tmp/pglite/share/postgresql/timezone/America/La_Paz",start:5028241,end:5028411},{filename:"/tmp/pglite/share/postgresql/timezone/America/Lima",start:5028411,end:5028694},{filename:"/tmp/pglite/share/postgresql/timezone/America/Los_Angeles",start:5028694,end:5029988},{filename:"/tmp/pglite/share/postgresql/timezone/America/Louisville",start:5029988,end:5031230},{filename:"/tmp/pglite/share/postgresql/timezone/America/Lower_Princes",start:5031230,end:5031407},{filename:"/tmp/pglite/share/postgresql/timezone/America/Maceio",start:5031407,end:5031909},{filename:"/tmp/pglite/share/postgresql/timezone/America/Managua",start:5031909,end:5032204},{filename:"/tmp/pglite/share/postgresql/timezone/America/Manaus",start:5032204,end:5032616},{filename:"/tmp/pglite/share/postgresql/timezone/America/Marigot",start:5032616,end:5032793},{filename:"/tmp/pglite/share/postgresql/timezone/America/Martinique",start:5032793,end:5032971},{filename:"/tmp/pglite/share/postgresql/timezone/America/Matamoros",start:5032971,end:5033408},{filename:"/tmp/pglite/share/postgresql/timezone/America/Mazatlan",start:5033408,end:5034126},{filename:"/tmp/pglite/share/postgresql/timezone/America/Mendoza",start:5034126,end:5034834},{filename:"/tmp/pglite/share/postgresql/timezone/America/Menominee",start:5034834,end:5035751},{filename:"/tmp/pglite/share/postgresql/timezone/America/Merida",start:5035751,end:5036405},{filename:"/tmp/pglite/share/postgresql/timezone/America/Metlakatla",start:5036405,end:5037e3},{filename:"/tmp/pglite/share/postgresql/timezone/America/Mexico_City",start:5037e3,end:5037773},{filename:"/tmp/pglite/share/postgresql/timezone/America/Miquelon",start:5037773,end:5038323},{filename:"/tmp/pglite/share/postgresql/timezone/America/Moncton",start:5038323,end:5039816},{filename:"/tmp/pglite/share/postgresql/timezone/America/Monterrey",start:5039816,end:5040460},{filename:"/tmp/pglite/share/postgresql/timezone/America/Montevideo",start:5040460,end:5041429},{filename:"/tmp/pglite/share/postgresql/timezone/America/Montreal",start:5041429,end:5043146},{filename:"/tmp/pglite/share/postgresql/timezone/America/Montserrat",start:5043146,end:5043323},{filename:"/tmp/pglite/share/postgresql/timezone/America/Nassau",start:5043323,end:5045040},{filename:"/tmp/pglite/share/postgresql/timezone/America/New_York",start:5045040,end:5046784},{filename:"/tmp/pglite/share/postgresql/timezone/America/Nipigon",start:5046784,end:5048501},{filename:"/tmp/pglite/share/postgresql/timezone/America/Nome",start:5048501,end:5049476},{filename:"/tmp/pglite/share/postgresql/timezone/America/Noronha",start:5049476,end:5049960},{filename:"/tmp/pglite/share/postgresql/timezone/America/North_Dakota/Beulah",start:5049960,end:5051003},{filename:"/tmp/pglite/share/postgresql/timezone/America/North_Dakota/Center",start:5051003,end:5051993},{filename:"/tmp/pglite/share/postgresql/timezone/America/North_Dakota/New_Salem",start:5051993,end:5052983},{filename:"/tmp/pglite/share/postgresql/timezone/America/Nuuk",start:5052983,end:5053948},{filename:"/tmp/pglite/share/postgresql/timezone/America/Ojinaga",start:5053948,end:5054657},{filename:"/tmp/pglite/share/postgresql/timezone/America/Panama",start:5054657,end:5054806},{filename:"/tmp/pglite/share/postgresql/timezone/America/Pangnirtung",start:5054806,end:5055661},{filename:"/tmp/pglite/share/postgresql/timezone/America/Paramaribo",start:5055661,end:5055848},{filename:"/tmp/pglite/share/postgresql/timezone/America/Phoenix",start:5055848,end:5056088},{filename:"/tmp/pglite/share/postgresql/timezone/America/Port-au-Prince",start:5056088,end:5056653},{filename:"/tmp/pglite/share/postgresql/timezone/America/Port_of_Spain",start:5056653,end:5056830},{filename:"/tmp/pglite/share/postgresql/timezone/America/Porto_Acre",start:5056830,end:5057248},{filename:"/tmp/pglite/share/postgresql/timezone/America/Porto_Velho",start:5057248,end:5057642},{filename:"/tmp/pglite/share/postgresql/timezone/America/Puerto_Rico",start:5057642,end:5057819},{filename:"/tmp/pglite/share/postgresql/timezone/America/Punta_Arenas",start:5057819,end:5059037},{filename:"/tmp/pglite/share/postgresql/timezone/America/Rainy_River",start:5059037,end:5060331},{filename:"/tmp/pglite/share/postgresql/timezone/America/Rankin_Inlet",start:5060331,end:5061138},{filename:"/tmp/pglite/share/postgresql/timezone/America/Recife",start:5061138,end:5061622},{filename:"/tmp/pglite/share/postgresql/timezone/America/Regina",start:5061622,end:5062260},{filename:"/tmp/pglite/share/postgresql/timezone/America/Resolute",start:5062260,end:5063067},{filename:"/tmp/pglite/share/postgresql/timezone/America/Rio_Branco",start:5063067,end:5063485},{filename:"/tmp/pglite/share/postgresql/timezone/America/Rosario",start:5063485,end:5064193},{filename:"/tmp/pglite/share/postgresql/timezone/America/Santa_Isabel",start:5064193,end:5065218},{filename:"/tmp/pglite/share/postgresql/timezone/America/Santarem",start:5065218,end:5065627},{filename:"/tmp/pglite/share/postgresql/timezone/America/Santiago",start:5065627,end:5066981},{filename:"/tmp/pglite/share/postgresql/timezone/America/Santo_Domingo",start:5066981,end:5067298},{filename:"/tmp/pglite/share/postgresql/timezone/America/Sao_Paulo",start:5067298,end:5068250},{filename:"/tmp/pglite/share/postgresql/timezone/America/Scoresbysund",start:5068250,end:5069234},{filename:"/tmp/pglite/share/postgresql/timezone/America/Shiprock",start:5069234,end:5070276},{filename:"/tmp/pglite/share/postgresql/timezone/America/Sitka",start:5070276,end:5071232},{filename:"/tmp/pglite/share/postgresql/timezone/America/St_Barthelemy",start:5071232,end:5071409},{filename:"/tmp/pglite/share/postgresql/timezone/America/St_Johns",start:5071409,end:5073287},{filename:"/tmp/pglite/share/postgresql/timezone/America/St_Kitts",start:5073287,end:5073464},{filename:"/tmp/pglite/share/postgresql/timezone/America/St_Lucia",start:5073464,end:5073641},{filename:"/tmp/pglite/share/postgresql/timezone/America/St_Thomas",start:5073641,end:5073818},{filename:"/tmp/pglite/share/postgresql/timezone/America/St_Vincent",start:5073818,end:5073995},{filename:"/tmp/pglite/share/postgresql/timezone/America/Swift_Current",start:5073995,end:5074363},{filename:"/tmp/pglite/share/postgresql/timezone/America/Tegucigalpa",start:5074363,end:5074557},{filename:"/tmp/pglite/share/postgresql/timezone/America/Thule",start:5074557,end:5075012},{filename:"/tmp/pglite/share/postgresql/timezone/America/Thunder_Bay",start:5075012,end:5076729},{filename:"/tmp/pglite/share/postgresql/timezone/America/Tijuana",start:5076729,end:5077754},{filename:"/tmp/pglite/share/postgresql/timezone/America/Toronto",start:5077754,end:5079471},{filename:"/tmp/pglite/share/postgresql/timezone/America/Tortola",start:5079471,end:5079648},{filename:"/tmp/pglite/share/postgresql/timezone/America/Vancouver",start:5079648,end:5080978},{filename:"/tmp/pglite/share/postgresql/timezone/America/Virgin",start:5080978,end:5081155},{filename:"/tmp/pglite/share/postgresql/timezone/America/Whitehorse",start:5081155,end:5082184},{filename:"/tmp/pglite/share/postgresql/timezone/America/Winnipeg",start:5082184,end:5083478},{filename:"/tmp/pglite/share/postgresql/timezone/America/Yakutat",start:5083478,end:5084424},{filename:"/tmp/pglite/share/postgresql/timezone/America/Yellowknife",start:5084424,end:5085394},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Casey",start:5085394,end:5085681},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Davis",start:5085681,end:5085878},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/DumontDUrville",start:5085878,end:5086032},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Macquarie",start:5086032,end:5087008},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Mawson",start:5087008,end:5087160},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/McMurdo",start:5087160,end:5088203},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Palmer",start:5088203,end:5089090},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Rothera",start:5089090,end:5089222},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/South_Pole",start:5089222,end:5090265},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Syowa",start:5090265,end:5090398},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Troll",start:5090398,end:5090575},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Vostok",start:5090575,end:5090745},{filename:"/tmp/pglite/share/postgresql/timezone/Arctic/Longyearbyen",start:5090745,end:5091450},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Aden",start:5091450,end:5091583},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Almaty",start:5091583,end:5092201},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Amman",start:5092201,end:5093129},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Anadyr",start:5093129,end:5093872},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Aqtau",start:5093872,end:5094478},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Aqtobe",start:5094478,end:5095093},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Ashgabat",start:5095093,end:5095468},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Ashkhabad",start:5095468,end:5095843},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Atyrau",start:5095843,end:5096459},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Baghdad",start:5096459,end:5097089},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Bahrain",start:5097089,end:5097241},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Baku",start:5097241,end:5097985},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Bangkok",start:5097985,end:5098137},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Barnaul",start:5098137,end:5098890},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Beirut",start:5098890,end:5099622},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Bishkek",start:5099622,end:5100240},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Brunei",start:5100240,end:5100560},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Calcutta",start:5100560,end:5100780},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Chita",start:5100780,end:5101530},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Choibalsan",start:5101530,end:5102149},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Chongqing",start:5102149,end:5102542},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Chungking",start:5102542,end:5102935},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Colombo",start:5102935,end:5103182},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Dacca",start:5103182,end:5103413},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Damascus",start:5103413,end:5104647},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Dhaka",start:5104647,end:5104878},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Dili",start:5104878,end:5105048},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Dubai",start:5105048,end:5105181},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Dushanbe",start:5105181,end:5105547},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Famagusta",start:5105547,end:5106487},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Gaza",start:5106487,end:5108933},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Harbin",start:5108933,end:5109326},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Hebron",start:5109326,end:5111790},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Ho_Chi_Minh",start:5111790,end:5112026},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Hong_Kong",start:5112026,end:5112801},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Hovd",start:5112801,end:5113395},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Irkutsk",start:5113395,end:5114155},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Istanbul",start:5114155,end:5115355},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Jakarta",start:5115355,end:5115603},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Jayapura",start:5115603,end:5115774},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Jerusalem",start:5115774,end:5116848},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Kabul",start:5116848,end:5117007},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Kamchatka",start:5117007,end:5117734},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Karachi",start:5117734,end:5118e3},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Kashgar",start:5118e3,end:5118133},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Kathmandu",start:5118133,end:5118294},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Katmandu",start:5118294,end:5118455},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Khandyga",start:5118455,end:5119230},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Kolkata",start:5119230,end:5119450},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Krasnoyarsk",start:5119450,end:5120191},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Kuala_Lumpur",start:5120191,end:5120447},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Kuching",start:5120447,end:5120767},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Kuwait",start:5120767,end:5120900},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Macao",start:5120900,end:5121691},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Macau",start:5121691,end:5122482},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Magadan",start:5122482,end:5123233},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Makassar",start:5123233,end:5123423},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Manila",start:5123423,end:5123661},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Muscat",start:5123661,end:5123794},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Nicosia",start:5123794,end:5124391},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Novokuznetsk",start:5124391,end:5125117},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Novosibirsk",start:5125117,end:5125870},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Omsk",start:5125870,end:5126611},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Oral",start:5126611,end:5127236},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Phnom_Penh",start:5127236,end:5127388},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Pontianak",start:5127388,end:5127635},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Pyongyang",start:5127635,end:5127818},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Qatar",start:5127818,end:5127970},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Qostanay",start:5127970,end:5128594},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Qyzylorda",start:5128594,end:5129218},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Rangoon",start:5129218,end:5129405},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Riyadh",start:5129405,end:5129538},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Saigon",start:5129538,end:5129774},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Sakhalin",start:5129774,end:5130529},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Samarkand",start:5130529,end:5130895},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Seoul",start:5130895,end:5131310},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Shanghai",start:5131310,end:5131703},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Singapore",start:5131703,end:5131959},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Srednekolymsk",start:5131959,end:5132701},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Taipei",start:5132701,end:5133212},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Tashkent",start:5133212,end:5133578},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Tbilisi",start:5133578,end:5134207},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Tehran",start:5134207,end:5135019},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Tel_Aviv",start:5135019,end:5136093},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Thimbu",start:5136093,end:5136247},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Thimphu",start:5136247,end:5136401},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Tokyo",start:5136401,end:5136614},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Tomsk",start:5136614,end:5137367},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Ujung_Pandang",start:5137367,end:5137557},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Ulaanbaatar",start:5137557,end:5138151},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Ulan_Bator",start:5138151,end:5138745},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Urumqi",start:5138745,end:5138878},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Ust-Nera",start:5138878,end:5139649},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Vientiane",start:5139649,end:5139801},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Vladivostok",start:5139801,end:5140543},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Yakutsk",start:5140543,end:5141284},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Yangon",start:5141284,end:5141471},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Yekaterinburg",start:5141471,end:5142231},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Yerevan",start:5142231,end:5142939},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Azores",start:5142939,end:5144392},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Bermuda",start:5144392,end:5145416},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Canary",start:5145416,end:5145894},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Cape_Verde",start:5145894,end:5146069},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Faeroe",start:5146069,end:5146510},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Faroe",start:5146510,end:5146951},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Jan_Mayen",start:5146951,end:5147656},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Madeira",start:5147656,end:5149109},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Reykjavik",start:5149109,end:5149239},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/South_Georgia",start:5149239,end:5149371},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/St_Helena",start:5149371,end:5149501},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Stanley",start:5149501,end:5150290},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/ACT",start:5150290,end:5151194},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Adelaide",start:5151194,end:5152115},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Brisbane",start:5152115,end:5152404},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Broken_Hill",start:5152404,end:5153345},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Canberra",start:5153345,end:5154249},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Currie",start:5154249,end:5155252},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Darwin",start:5155252,end:5155486},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Eucla",start:5155486,end:5155800},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Hobart",start:5155800,end:5156803},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/LHI",start:5156803,end:5157495},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Lindeman",start:5157495,end:5157820},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Lord_Howe",start:5157820,end:5158512},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Melbourne",start:5158512,end:5159416},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/NSW",start:5159416,end:5160320},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/North",start:5160320,end:5160554},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Perth",start:5160554,end:5160860},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Queensland",start:5160860,end:5161149},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/South",start:5161149,end:5162070},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Sydney",start:5162070,end:5162974},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Tasmania",start:5162974,end:5163977},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Victoria",start:5163977,end:5164881},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/West",start:5164881,end:5165187},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Yancowinna",start:5165187,end:5166128},{filename:"/tmp/pglite/share/postgresql/timezone/Brazil/Acre",start:5166128,end:5166546},{filename:"/tmp/pglite/share/postgresql/timezone/Brazil/DeNoronha",start:5166546,end:5167030},{filename:"/tmp/pglite/share/postgresql/timezone/Brazil/East",start:5167030,end:5167982},{filename:"/tmp/pglite/share/postgresql/timezone/Brazil/West",start:5167982,end:5168394},{filename:"/tmp/pglite/share/postgresql/timezone/CET",start:5168394,end:5169015},{filename:"/tmp/pglite/share/postgresql/timezone/CST6CDT",start:5169015,end:5169966},{filename:"/tmp/pglite/share/postgresql/timezone/Canada/Atlantic",start:5169966,end:5171638},{filename:"/tmp/pglite/share/postgresql/timezone/Canada/Central",start:5171638,end:5172932},{filename:"/tmp/pglite/share/postgresql/timezone/Canada/Eastern",start:5172932,end:5174649},{filename:"/tmp/pglite/share/postgresql/timezone/Canada/Mountain",start:5174649,end:5175619},{filename:"/tmp/pglite/share/postgresql/timezone/Canada/Newfoundland",start:5175619,end:5177497},{filename:"/tmp/pglite/share/postgresql/timezone/Canada/Pacific",start:5177497,end:5178827},{filename:"/tmp/pglite/share/postgresql/timezone/Canada/Saskatchewan",start:5178827,end:5179465},{filename:"/tmp/pglite/share/postgresql/timezone/Canada/Yukon",start:5179465,end:5180494},{filename:"/tmp/pglite/share/postgresql/timezone/Chile/Continental",start:5180494,end:5181848},{filename:"/tmp/pglite/share/postgresql/timezone/Chile/EasterIsland",start:5181848,end:5183022},{filename:"/tmp/pglite/share/postgresql/timezone/Cuba",start:5183022,end:5184139},{filename:"/tmp/pglite/share/postgresql/timezone/EET",start:5184139,end:5184636},{filename:"/tmp/pglite/share/postgresql/timezone/EST",start:5184636,end:5184747},{filename:"/tmp/pglite/share/postgresql/timezone/EST5EDT",start:5184747,end:5185698},{filename:"/tmp/pglite/share/postgresql/timezone/Egypt",start:5185698,end:5187007},{filename:"/tmp/pglite/share/postgresql/timezone/Eire",start:5187007,end:5188503},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT",start:5188503,end:5188614},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+0",start:5188614,end:5188725},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+1",start:5188725,end:5188838},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+10",start:5188838,end:5188952},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+11",start:5188952,end:5189066},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+12",start:5189066,end:5189180},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+2",start:5189180,end:5189293},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+3",start:5189293,end:5189406},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+4",start:5189406,end:5189519},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+5",start:5189519,end:5189632},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+6",start:5189632,end:5189745},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+7",start:5189745,end:5189858},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+8",start:5189858,end:5189971},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+9",start:5189971,end:5190084},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-0",start:5190084,end:5190195},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-1",start:5190195,end:5190309},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-10",start:5190309,end:5190424},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-11",start:5190424,end:5190539},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-12",start:5190539,end:5190654},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-13",start:5190654,end:5190769},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-14",start:5190769,end:5190884},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-2",start:5190884,end:5190998},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-3",start:5190998,end:5191112},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-4",start:5191112,end:5191226},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-5",start:5191226,end:5191340},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-6",start:5191340,end:5191454},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-7",start:5191454,end:5191568},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-8",start:5191568,end:5191682},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-9",start:5191682,end:5191796},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT0",start:5191796,end:5191907},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/Greenwich",start:5191907,end:5192018},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/UCT",start:5192018,end:5192129},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/UTC",start:5192129,end:5192240},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/Universal",start:5192240,end:5192351},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/Zulu",start:5192351,end:5192462},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Amsterdam",start:5192462,end:5193565},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Andorra",start:5193565,end:5193954},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Astrakhan",start:5193954,end:5194680},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Athens",start:5194680,end:5195362},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Belfast",start:5195362,end:5196961},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Belgrade",start:5196961,end:5197439},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Berlin",start:5197439,end:5198144},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Bratislava",start:5198144,end:5198867},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Brussels",start:5198867,end:5199970},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Bucharest",start:5199970,end:5200631},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Budapest",start:5200631,end:5201397},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Busingen",start:5201397,end:5201894},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Chisinau",start:5201894,end:5202649},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Copenhagen",start:5202649,end:5203354},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Dublin",start:5203354,end:5204850},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Gibraltar",start:5204850,end:5206070},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Guernsey",start:5206070,end:5207669},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Helsinki",start:5207669,end:5208150},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Isle_of_Man",start:5208150,end:5209749},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Istanbul",start:5209749,end:5210949},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Jersey",start:5210949,end:5212548},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Kaliningrad",start:5212548,end:5213452},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Kiev",start:5213452,end:5214010},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Kirov",start:5214010,end:5214745},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Kyiv",start:5214745,end:5215303},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Lisbon",start:5215303,end:5216757},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Ljubljana",start:5216757,end:5217235},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/London",start:5217235,end:5218834},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Luxembourg",start:5218834,end:5219937},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Madrid",start:5219937,end:5220834},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Malta",start:5220834,end:5221762},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Mariehamn",start:5221762,end:5222243},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Minsk",start:5222243,end:5223051},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Monaco",start:5223051,end:5224156},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Moscow",start:5224156,end:5225064},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Nicosia",start:5225064,end:5225661},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Oslo",start:5225661,end:5226366},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Paris",start:5226366,end:5227471},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Podgorica",start:5227471,end:5227949},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Prague",start:5227949,end:5228672},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Riga",start:5228672,end:5229366},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Rome",start:5229366,end:5230313},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Samara",start:5230313,end:5231045},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/San_Marino",start:5231045,end:5231992},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Sarajevo",start:5231992,end:5232470},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Saratov",start:5232470,end:5233196},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Simferopol",start:5233196,end:5234061},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Skopje",start:5234061,end:5234539},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Sofia",start:5234539,end:5235131},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Stockholm",start:5235131,end:5235836},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Tallinn",start:5235836,end:5236511},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Tirane",start:5236511,end:5237115},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Tiraspol",start:5237115,end:5237870},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Ulyanovsk",start:5237870,end:5238630},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Uzhgorod",start:5238630,end:5239188},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Vaduz",start:5239188,end:5239685},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Vatican",start:5239685,end:5240632},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Vienna",start:5240632,end:5241290},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Vilnius",start:5241290,end:5241966},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Volgograd",start:5241966,end:5242719},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Warsaw",start:5242719,end:5243642},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Zagreb",start:5243642,end:5244120},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Zaporozhye",start:5244120,end:5244678},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Zurich",start:5244678,end:5245175},{filename:"/tmp/pglite/share/postgresql/timezone/Factory",start:5245175,end:5245288},{filename:"/tmp/pglite/share/postgresql/timezone/GB",start:5245288,end:5246887},{filename:"/tmp/pglite/share/postgresql/timezone/GB-Eire",start:5246887,end:5248486},{filename:"/tmp/pglite/share/postgresql/timezone/GMT",start:5248486,end:5248597},{filename:"/tmp/pglite/share/postgresql/timezone/GMT+0",start:5248597,end:5248708},{filename:"/tmp/pglite/share/postgresql/timezone/GMT-0",start:5248708,end:5248819},{filename:"/tmp/pglite/share/postgresql/timezone/GMT0",start:5248819,end:5248930},{filename:"/tmp/pglite/share/postgresql/timezone/Greenwich",start:5248930,end:5249041},{filename:"/tmp/pglite/share/postgresql/timezone/HST",start:5249041,end:5249153},{filename:"/tmp/pglite/share/postgresql/timezone/Hongkong",start:5249153,end:5249928},{filename:"/tmp/pglite/share/postgresql/timezone/Iceland",start:5249928,end:5250058},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Antananarivo",start:5250058,end:5250249},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Chagos",start:5250249,end:5250401},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Christmas",start:5250401,end:5250553},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Cocos",start:5250553,end:5250740},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Comoro",start:5250740,end:5250931},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Kerguelen",start:5250931,end:5251083},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Mahe",start:5251083,end:5251216},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Maldives",start:5251216,end:5251368},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Mauritius",start:5251368,end:5251547},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Mayotte",start:5251547,end:5251738},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Reunion",start:5251738,end:5251871},{filename:"/tmp/pglite/share/postgresql/timezone/Iran",start:5251871,end:5252683},{filename:"/tmp/pglite/share/postgresql/timezone/Israel",start:5252683,end:5253757},{filename:"/tmp/pglite/share/postgresql/timezone/Jamaica",start:5253757,end:5254096},{filename:"/tmp/pglite/share/postgresql/timezone/Japan",start:5254096,end:5254309},{filename:"/tmp/pglite/share/postgresql/timezone/Kwajalein",start:5254309,end:5254528},{filename:"/tmp/pglite/share/postgresql/timezone/Libya",start:5254528,end:5254959},{filename:"/tmp/pglite/share/postgresql/timezone/MET",start:5254959,end:5255580},{filename:"/tmp/pglite/share/postgresql/timezone/MST",start:5255580,end:5255691},{filename:"/tmp/pglite/share/postgresql/timezone/MST7MDT",start:5255691,end:5256642},{filename:"/tmp/pglite/share/postgresql/timezone/Mexico/BajaNorte",start:5256642,end:5257667},{filename:"/tmp/pglite/share/postgresql/timezone/Mexico/BajaSur",start:5257667,end:5258385},{filename:"/tmp/pglite/share/postgresql/timezone/Mexico/General",start:5258385,end:5259158},{filename:"/tmp/pglite/share/postgresql/timezone/NZ",start:5259158,end:5260201},{filename:"/tmp/pglite/share/postgresql/timezone/NZ-CHAT",start:5260201,end:5261009},{filename:"/tmp/pglite/share/postgresql/timezone/Navajo",start:5261009,end:5262051},{filename:"/tmp/pglite/share/postgresql/timezone/PRC",start:5262051,end:5262444},{filename:"/tmp/pglite/share/postgresql/timezone/PST8PDT",start:5262444,end:5263395},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Apia",start:5263395,end:5263802},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Auckland",start:5263802,end:5264845},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Bougainville",start:5264845,end:5265046},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Chatham",start:5265046,end:5265854},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Chuuk",start:5265854,end:5266008},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Easter",start:5266008,end:5267182},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Efate",start:5267182,end:5267524},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Enderbury",start:5267524,end:5267696},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Fakaofo",start:5267696,end:5267849},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Fiji",start:5267849,end:5268245},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Funafuti",start:5268245,end:5268379},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Galapagos",start:5268379,end:5268554},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Gambier",start:5268554,end:5268686},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Guadalcanal",start:5268686,end:5268820},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Guam",start:5268820,end:5269170},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Honolulu",start:5269170,end:5269391},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Johnston",start:5269391,end:5269612},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Kanton",start:5269612,end:5269784},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Kiritimati",start:5269784,end:5269958},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Kosrae",start:5269958,end:5270200},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Kwajalein",start:5270200,end:5270419},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Majuro",start:5270419,end:5270553},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Marquesas",start:5270553,end:5270692},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Midway",start:5270692,end:5270838},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Nauru",start:5270838,end:5271021},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Niue",start:5271021,end:5271175},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Norfolk",start:5271175,end:5271422},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Noumea",start:5271422,end:5271620},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Pago_Pago",start:5271620,end:5271766},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Palau",start:5271766,end:5271914},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Pitcairn",start:5271914,end:5272067},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Pohnpei",start:5272067,end:5272201},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Ponape",start:5272201,end:5272335},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Port_Moresby",start:5272335,end:5272489},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Rarotonga",start:5272489,end:5272895},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Saipan",start:5272895,end:5273245},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Samoa",start:5273245,end:5273391},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Tahiti",start:5273391,end:5273524},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Tarawa",start:5273524,end:5273658},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Tongatapu",start:5273658,end:5273895},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Truk",start:5273895,end:5274049},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Wake",start:5274049,end:5274183},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Wallis",start:5274183,end:5274317},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Yap",start:5274317,end:5274471},{filename:"/tmp/pglite/share/postgresql/timezone/Poland",start:5274471,end:5275394},{filename:"/tmp/pglite/share/postgresql/timezone/Portugal",start:5275394,end:5276848},{filename:"/tmp/pglite/share/postgresql/timezone/ROC",start:5276848,end:5277359},{filename:"/tmp/pglite/share/postgresql/timezone/ROK",start:5277359,end:5277774},{filename:"/tmp/pglite/share/postgresql/timezone/Singapore",start:5277774,end:5278030},{filename:"/tmp/pglite/share/postgresql/timezone/Turkey",start:5278030,end:5279230},{filename:"/tmp/pglite/share/postgresql/timezone/UCT",start:5279230,end:5279341},{filename:"/tmp/pglite/share/postgresql/timezone/US/Alaska",start:5279341,end:5280318},{filename:"/tmp/pglite/share/postgresql/timezone/US/Aleutian",start:5280318,end:5281287},{filename:"/tmp/pglite/share/postgresql/timezone/US/Arizona",start:5281287,end:5281527},{filename:"/tmp/pglite/share/postgresql/timezone/US/Central",start:5281527,end:5283281},{filename:"/tmp/pglite/share/postgresql/timezone/US/East-Indiana",start:5283281,end:5283812},{filename:"/tmp/pglite/share/postgresql/timezone/US/Eastern",start:5283812,end:5285556},{filename:"/tmp/pglite/share/postgresql/timezone/US/Hawaii",start:5285556,end:5285777},{filename:"/tmp/pglite/share/postgresql/timezone/US/Indiana-Starke",start:5285777,end:5286793},{filename:"/tmp/pglite/share/postgresql/timezone/US/Michigan",start:5286793,end:5287692},{filename:"/tmp/pglite/share/postgresql/timezone/US/Mountain",start:5287692,end:5288734},{filename:"/tmp/pglite/share/postgresql/timezone/US/Pacific",start:5288734,end:5290028},{filename:"/tmp/pglite/share/postgresql/timezone/US/Samoa",start:5290028,end:5290174},{filename:"/tmp/pglite/share/postgresql/timezone/UTC",start:5290174,end:5290285},{filename:"/tmp/pglite/share/postgresql/timezone/Universal",start:5290285,end:5290396},{filename:"/tmp/pglite/share/postgresql/timezone/W-SU",start:5290396,end:5291304},{filename:"/tmp/pglite/share/postgresql/timezone/WET",start:5291304,end:5291798},{filename:"/tmp/pglite/share/postgresql/timezone/Zulu",start:5291798,end:5291909},{filename:"/tmp/pglite/share/postgresql/timezonesets/Africa.txt",start:5291909,end:5298882},{filename:"/tmp/pglite/share/postgresql/timezonesets/America.txt",start:5298882,end:5309889},{filename:"/tmp/pglite/share/postgresql/timezonesets/Antarctica.txt",start:5309889,end:5311023},{filename:"/tmp/pglite/share/postgresql/timezonesets/Asia.txt",start:5311023,end:5319334},{filename:"/tmp/pglite/share/postgresql/timezonesets/Atlantic.txt",start:5319334,end:5322867},{filename:"/tmp/pglite/share/postgresql/timezonesets/Australia",start:5322867,end:5324002},{filename:"/tmp/pglite/share/postgresql/timezonesets/Australia.txt",start:5324002,end:5327386},{filename:"/tmp/pglite/share/postgresql/timezonesets/Default",start:5327386,end:5354636},{filename:"/tmp/pglite/share/postgresql/timezonesets/Etc.txt",start:5354636,end:5355886},{filename:"/tmp/pglite/share/postgresql/timezonesets/Europe.txt",start:5355886,end:5364668},{filename:"/tmp/pglite/share/postgresql/timezonesets/India",start:5364668,end:5365261},{filename:"/tmp/pglite/share/postgresql/timezonesets/Indian.txt",start:5365261,end:5366522},{filename:"/tmp/pglite/share/postgresql/timezonesets/Pacific.txt",start:5366522,end:5370290},{filename:"/tmp/pglite/share/postgresql/tsearch_data/danish.stop",start:5370290,end:5370714},{filename:"/tmp/pglite/share/postgresql/tsearch_data/dutch.stop",start:5370714,end:5371167},{filename:"/tmp/pglite/share/postgresql/tsearch_data/english.stop",start:5371167,end:5371789},{filename:"/tmp/pglite/share/postgresql/tsearch_data/finnish.stop",start:5371789,end:5373368},{filename:"/tmp/pglite/share/postgresql/tsearch_data/french.stop",start:5373368,end:5374173},{filename:"/tmp/pglite/share/postgresql/tsearch_data/german.stop",start:5374173,end:5375522},{filename:"/tmp/pglite/share/postgresql/tsearch_data/hungarian.stop",start:5375522,end:5376749},{filename:"/tmp/pglite/share/postgresql/tsearch_data/hunspell_sample.affix",start:5376749,end:5376992},{filename:"/tmp/pglite/share/postgresql/tsearch_data/hunspell_sample_long.affix",start:5376992,end:5377625},{filename:"/tmp/pglite/share/postgresql/tsearch_data/hunspell_sample_long.dict",start:5377625,end:5377723},{filename:"/tmp/pglite/share/postgresql/tsearch_data/hunspell_sample_num.affix",start:5377723,end:5378185},{filename:"/tmp/pglite/share/postgresql/tsearch_data/hunspell_sample_num.dict",start:5378185,end:5378314},{filename:"/tmp/pglite/share/postgresql/tsearch_data/ispell_sample.affix",start:5378314,end:5378779},{filename:"/tmp/pglite/share/postgresql/tsearch_data/ispell_sample.dict",start:5378779,end:5378860},{filename:"/tmp/pglite/share/postgresql/tsearch_data/italian.stop",start:5378860,end:5380514},{filename:"/tmp/pglite/share/postgresql/tsearch_data/nepali.stop",start:5380514,end:5384775},{filename:"/tmp/pglite/share/postgresql/tsearch_data/norwegian.stop",start:5384775,end:5385626},{filename:"/tmp/pglite/share/postgresql/tsearch_data/portuguese.stop",start:5385626,end:5386893},{filename:"/tmp/pglite/share/postgresql/tsearch_data/russian.stop",start:5386893,end:5388128},{filename:"/tmp/pglite/share/postgresql/tsearch_data/spanish.stop",start:5388128,end:5390306},{filename:"/tmp/pglite/share/postgresql/tsearch_data/swedish.stop",start:5390306,end:5390865},{filename:"/tmp/pglite/share/postgresql/tsearch_data/synonym_sample.syn",start:5390865,end:5390938},{filename:"/tmp/pglite/share/postgresql/tsearch_data/thesaurus_sample.ths",start:5390938,end:5391411},{filename:"/tmp/pglite/share/postgresql/tsearch_data/turkish.stop",start:5391411,end:5391671},{filename:"/tmp/pglite/share/postgresql/tsearch_data/unaccent.rules",start:5391671,end:5401610},{filename:"/tmp/pglite/share/postgresql/tsearch_data/xsyn_sample.rules",start:5401610,end:5401749}],remote_package_size:5401749})})();var moduleOverrides=Object.assign({},Module),arguments_=[],thisProgram="./this.program",quit_=(t,e)=>{throw e},scriptDirectory="";function locateFile(t){return Module.locateFile?Module.locateFile(t,scriptDirectory):scriptDirectory+t}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs"),nodePath=require("path");import.meta.url.startsWith("data:")||(scriptDirectory=nodePath.dirname(require("url").fileURLToPath(import.meta.url))+"/"),readBinary=t=>{t=isFileURI(t)?new URL(t):t;var e=fs.readFileSync(t);return e},readAsync=async(t,e=!0)=>{t=isFileURI(t)?new URL(t):t;var I=fs.readFileSync(t,e?void 0:"utf8");return I},!Module.thisProgram&&process$1.argv.length>1&&(thisProgram=process$1.argv[1].replace(/\\/g,"/")),arguments_=process$1.argv.slice(2),quit_=(t,e)=>{throw process$1.exitCode=t,e}}else(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&(ENVIRONMENT_IS_WORKER?scriptDirectory=self.location.href:typeof document<"u"&&document.currentScript&&(scriptDirectory=document.currentScript.src),_scriptName&&(scriptDirectory=_scriptName),scriptDirectory.startsWith("blob:")?scriptDirectory="":scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1),readAsync=async t=>{var e=await fetch(t,{credentials:"same-origin"});if(e.ok)return e.arrayBuffer();throw new Error(e.status+" : "+e.url)});var out=Module.print||console.log.bind(console),err=Module.printErr||console.error.bind(console);Object.assign(Module,moduleOverrides),moduleOverrides=null,Module.arguments&&(arguments_=Module.arguments),Module.thisProgram&&(thisProgram=Module.thisProgram);var dynamicLibraries=Module.dynamicLibraries||[],wasmBinary=Module.wasmBinary,wasmMemory,ABORT=!1,EXITSTATUS;function assert(t,e){t||abort(e)}var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAP64,HEAPF64;function updateMemoryViews(){var t=wasmMemory.buffer;Module.HEAP8=HEAP8=new Int8Array(t),Module.HEAP16=HEAP16=new Int16Array(t),Module.HEAPU8=HEAPU8=new Uint8Array(t),Module.HEAPU16=HEAPU16=new Uint16Array(t),Module.HEAP32=HEAP32=new Int32Array(t),Module.HEAPU32=HEAPU32=new Uint32Array(t),Module.HEAPF32=HEAPF32=new Float32Array(t),Module.HEAPF64=HEAPF64=new Float64Array(t),Module.HEAP64=HEAP64=new BigInt64Array(t),Module.HEAPU64=new BigUint64Array(t)}if(Module.wasmMemory)wasmMemory=Module.wasmMemory;else{var INITIAL_MEMORY=Module.INITIAL_MEMORY||134217728;wasmMemory=new WebAssembly.Memory({initial:INITIAL_MEMORY/65536,maximum:32768})}updateMemoryViews();var __ATPRERUN__=[],__ATINIT__=[],__ATMAIN__=[],__ATPOSTRUN__=[],__RELOC_FUNCS__=[],runtimeInitialized=!1;function preRun(){if(Module.preRun)for(typeof Module.preRun=="function"&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=!0,callRuntimeCallbacks(__RELOC_FUNCS__),!Module.noFSInit&&!FS.initialized&&FS.init(),FS.ignorePermissions=!1,SOCKFS.root=FS.mount(SOCKFS,{},null),PIPEFS.root=FS.mount(PIPEFS,{},null),callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function postRun(){if(Module.postRun)for(typeof Module.postRun=="function"&&(Module.postRun=[Module.postRun]);Module.postRun.length;)addOnPostRun(Module.postRun.shift());callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(t){__ATPRERUN__.unshift(t)}function addOnInit(t){__ATINIT__.unshift(t)}function addOnPostRun(t){__ATPOSTRUN__.unshift(t)}var runDependencies=0,dependenciesFulfilled=null;function addRunDependency(t){runDependencies++,Module.monitorRunDependencies?.(runDependencies)}function removeRunDependency(t){if(runDependencies--,Module.monitorRunDependencies?.(runDependencies),runDependencies==0&&dependenciesFulfilled){var e=dependenciesFulfilled;dependenciesFulfilled=null,e()}}function abort(t){Module.onAbort?.(t),t="Aborted("+t+")",err(t),ABORT=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw readyPromiseReject(e),e}var dataURIPrefix="data:application/octet-stream;base64,",isDataURI=t=>t.startsWith(dataURIPrefix),isFileURI=t=>t.startsWith("file://");function findWasmBinary(){if(Module.locateFile){var t="postgres.wasm";return isDataURI(t)?t:locateFile(t)}return new URL("/assets/postgres-CyuUVpXN.wasm",import.meta.url).href}var wasmBinaryFile;function getBinarySync(t){if(t==wasmBinaryFile&&wasmBinary)return new Uint8Array(wasmBinary);if(readBinary)return readBinary(t);throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(t){if(!wasmBinary)try{var e=await readAsync(t);return new Uint8Array(e)}catch{}return getBinarySync(t)}async function instantiateArrayBuffer(t,e){try{var I=await getWasmBinary(t),B=await WebAssembly.instantiate(I,e);return B}catch(tr){err(`failed to asynchronously prepare wasm: ${tr}`),abort(tr)}}async function instantiateAsync(t,e,I){if(!t&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(e)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function")try{var B=fetch(e,{credentials:"same-origin"}),tr=await WebAssembly.instantiateStreaming(B,I);return tr}catch(rr){err(`wasm streaming compile failed: ${rr}`),err("falling back to ArrayBuffer instantiation")}return instantiateArrayBuffer(e,I)}function getWasmImports(){return{env:wasmImports,wasi_snapshot_preview1:wasmImports,"GOT.mem":new Proxy(wasmImports,GOTHandler),"GOT.func":new Proxy(wasmImports,GOTHandler)}}async function createWasm(){function t(tr,rr){wasmExports=tr.exports,wasmExports=relocateExports(wasmExports,16777216);var ir=getDylinkMetadata(rr);return ir.neededDynlibs&&(dynamicLibraries=ir.neededDynlibs.concat(dynamicLibraries)),mergeLibSymbols(wasmExports),LDSO.init(),loadDylibs(),addOnInit(wasmExports.__wasm_call_ctors),__RELOC_FUNCS__.push(wasmExports.__wasm_apply_data_relocs),removeRunDependency(),wasmExports}addRunDependency();function e(tr){t(tr.instance,tr.module)}var I=getWasmImports();if(Module.instantiateWasm)try{return Module.instantiateWasm(I,t)}catch(tr){err(`Module.instantiateWasm callback failed with error: ${tr}`),readyPromiseReject(tr)}wasmBinaryFile??(wasmBinaryFile=findWasmBinary());try{var B=await instantiateAsync(wasmBinary,wasmBinaryFile,I);return e(B),B}catch(tr){readyPromiseReject(tr);return}}var ASM_CONSTS={18792944:t=>{Module.is_worker=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,Module.FD_BUFFER_MAX=t,Module.emscripten_copy_to=console.warn},18793117:()=>{Module.postMessage=function(t){console.log("# 1252: onCustomMessage:",__FILE__,t)}},18793242:()=>{if(Module.is_worker){let t=function(e){console.log("onCustomMessage:",e)};Module.onCustomMessage=t}else Module.postMessage=function(t){switch(t.type){case"raw":{stringToUTF8(t.data,shm_rawinput,Module.FD_BUFFER_MAX);break}case"stdin":{stringToUTF8(t.data,1,Module.FD_BUFFER_MAX);break}case"rcon":{stringToUTF8(t.data,shm_rcon,Module.FD_BUFFER_MAX);break}default:console.warn("custom_postMessage?",t)}}}};function is_web_env(){try{if(window)return 1}catch{return 0}}is_web_env.sig="i";class ExitStatus{constructor(e){P$1(this,"name","ExitStatus"),this.message=`Program terminated with exit(${e})`,this.status=e}}var GOT={},currentModuleWeakSymbols=new Set([]),GOTHandler={get(t,e){var I=GOT[e];return I||(I=GOT[e]=new WebAssembly.Global({value:"i32",mutable:!0})),currentModuleWeakSymbols.has(e)||(I.required=!0),I}},callRuntimeCallbacks=t=>{for(;t.length>0;)t.shift()(Module)},UTF8Decoder=typeof TextDecoder<"u"?new TextDecoder:void 0,UTF8ArrayToString=(t,e=0,I=NaN)=>{for(var B=e+I,tr=e;t[tr]&&!(tr>=B);)++tr;if(tr-e>16&&t.buffer&&UTF8Decoder)return UTF8Decoder.decode(t.subarray(e,tr));for(var rr="";e<tr;){var ir=t[e++];if(!(ir&128)){rr+=String.fromCharCode(ir);continue}var lr=t[e++]&63;if((ir&224)==192){rr+=String.fromCharCode((ir&31)<<6|lr);continue}var dr=t[e++]&63;if((ir&240)==224?ir=(ir&15)<<12|lr<<6|dr:ir=(ir&7)<<18|lr<<12|dr<<6|t[e++]&63,ir<65536)rr+=String.fromCharCode(ir);else{var mr=ir-65536;rr+=String.fromCharCode(55296|mr>>10,56320|mr&1023)}}return rr},getDylinkMetadata=t=>{var e=0,I=0;function B(){return t[e++]}function tr(){for(var Ur=0,Pr=1;;){var kr=t[e++];if(Ur+=(kr&127)*Pr,Pr*=128,!(kr&128))break}return Ur}function rr(){var Ur=tr();return e+=Ur,UTF8ArrayToString(t,e-Ur,Ur)}function ir(Ur,Pr){if(Ur)throw new Error(Pr)}var lr="dylink.0";if(t instanceof WebAssembly.Module){var dr=WebAssembly.Module.customSections(t,lr);dr.length===0&&(lr="dylink",dr=WebAssembly.Module.customSections(t,lr)),ir(dr.length===0,"need dylink section"),t=new Uint8Array(dr[0]),I=t.length}else{var mr=new Uint32Array(new Uint8Array(t.subarray(0,24)).buffer),hr=mr[0]==1836278016;ir(!hr,"need to see wasm magic number"),ir(t[8]!==0,"need the dylink section to be first"),e=9;var fr=tr();I=e+fr,lr=rr()}var _r={neededDynlibs:[],tlsExports:new Set,weakImports:new Set};if(lr=="dylink"){_r.memorySize=tr(),_r.memoryAlign=tr(),_r.tableSize=tr(),_r.tableAlign=tr();for(var wr=tr(),gr=0;gr<wr;++gr){var xr=rr();_r.neededDynlibs.push(xr)}}else{ir(lr!=="dylink.0");for(var Mr=1,Sr=2,yr=3,br=4,vr=256,Cr=3,Ar=1;e<I;){var Ir=B(),Dr=tr();if(Ir===Mr)_r.memorySize=tr(),_r.memoryAlign=tr(),_r.tableSize=tr(),_r.tableAlign=tr();else if(Ir===Sr)for(var wr=tr(),gr=0;gr<wr;++gr)xr=rr(),_r.neededDynlibs.push(xr);else if(Ir===yr)for(var Fr=tr();Fr--;){var zr=rr(),Gr=tr();Gr&vr&&_r.tlsExports.add(zr)}else if(Ir===br)for(var Fr=tr();Fr--;){rr();var zr=rr(),Gr=tr();(Gr&Cr)==Ar&&_r.weakImports.add(zr)}else e+=Dr}}return _r};function getValue(t,e="i8"){switch(e.endsWith("*")&&(e="*"),e){case"i1":return HEAP8[t];case"i8":return HEAP8[t];case"i16":return HEAP16[t>>1];case"i32":return HEAP32[t>>2];case"i64":return HEAP64[t>>3];case"float":return HEAPF32[t>>2];case"double":return HEAPF64[t>>3];case"*":return HEAPU32[t>>2];default:abort(`invalid type for getValue: ${e}`)}}var newDSO=(t,e,I)=>{var B={refcount:1/0,name:t,exports:I,global:!0};return LDSO.loadedLibsByName[t]=B,e!=null&&(LDSO.loadedLibsByHandle[e]=B),B},LDSO={loadedLibsByName:{},loadedLibsByHandle:{},init(){newDSO("__main__",0,wasmImports)}},___heap_base=23144432,alignMemory=(t,e)=>Math.ceil(t/e)*e,getMemory=t=>{if(runtimeInitialized)return _calloc(t,1);var e=___heap_base,I=e+alignMemory(t,16);return ___heap_base=I,GOT.__heap_base.value=I,e},isInternalSym=t=>["__cpp_exception","__c_longjmp","__wasm_apply_data_relocs","__dso_handle","__tls_size","__tls_align","__set_stack_limits","_emscripten_tls_init","__wasm_init_tls","__wasm_call_ctors","__start_em_asm","__stop_em_asm","__start_em_js","__stop_em_js"].includes(t)||t.startsWith("__em_js__"),uleb128Encode=(t,e)=>{t<128?e.push(t):e.push(t%128|128,t>>7)},sigToWasmTypes=t=>{for(var e={i:"i32",j:"i64",f:"f32",d:"f64",e:"externref",p:"i32"},I={parameters:[],results:t[0]=="v"?[]:[e[t[0]]]},B=1;B<t.length;++B)I.parameters.push(e[t[B]]);return I},generateFuncType=(t,e)=>{var I=t.slice(0,1),B=t.slice(1),tr={i:127,p:127,j:126,f:125,d:124,e:111};e.push(96),uleb128Encode(B.length,e);for(var rr=0;rr<B.length;++rr)e.push(tr[B[rr]]);I=="v"?e.push(0):e.push(1,tr[I])},convertJsFunctionToWasm=(t,e)=>{if(typeof WebAssembly.Function=="function")return new WebAssembly.Function(sigToWasmTypes(e),t);var I=[1];generateFuncType(e,I);var B=[0,97,115,109,1,0,0,0,1];uleb128Encode(I.length,B),B.push(...I),B.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var tr=new WebAssembly.Module(new Uint8Array(B)),rr=new WebAssembly.Instance(tr,{e:{f:t}}),ir=rr.exports.f;return ir},wasmTableMirror=[],wasmTable=new WebAssembly.Table({initial:5360,element:"anyfunc"}),getWasmTableEntry=t=>{var e=wasmTableMirror[t];return e||(t>=wasmTableMirror.length&&(wasmTableMirror.length=t+1),wasmTableMirror[t]=e=wasmTable.get(t)),e},updateTableMap=(t,e)=>{if(functionsInTableMap)for(var I=t;I<t+e;I++){var B=getWasmTableEntry(I);B&&functionsInTableMap.set(B,I)}},functionsInTableMap,getFunctionAddress=t=>(functionsInTableMap||(functionsInTableMap=new WeakMap,updateTableMap(0,wasmTable.length)),functionsInTableMap.get(t)||0),freeTableIndexes=[],getEmptyTableSlot=()=>{if(freeTableIndexes.length)return freeTableIndexes.pop();try{wasmTable.grow(1)}catch(t){throw t instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":t}return wasmTable.length-1},setWasmTableEntry=(t,e)=>{wasmTable.set(t,e),wasmTableMirror[t]=wasmTable.get(t)},addFunction=(t,e)=>{var I=getFunctionAddress(t);if(I)return I;var B=getEmptyTableSlot();try{setWasmTableEntry(B,t)}catch(rr){if(!(rr instanceof TypeError))throw rr;var tr=convertJsFunctionToWasm(t,e);setWasmTableEntry(B,tr)}return functionsInTableMap.set(t,B),B},updateGOT=(t,e)=>{for(var I in t)if(!isInternalSym(I)){var B=t[I];GOT[I]||(GOT[I]=new WebAssembly.Global({value:"i32",mutable:!0})),GOT[I].value==0&&(typeof B=="function"?GOT[I].value=addFunction(B):typeof B=="number"?GOT[I].value=B:err(`unhandled export type for '${I}': ${typeof B}`))}},relocateExports=(t,e,I)=>{var B={};for(var tr in t){var rr=t[tr];typeof rr=="object"&&(rr=rr.value),typeof rr=="number"&&(rr+=e),B[tr]=rr}return updateGOT(B),B},isSymbolDefined=t=>{var e=wasmImports[t];return!(!e||e.stub)},dynCall=(t,e,I=[])=>{var B=getWasmTableEntry(e)(...I);return B},stackSave=()=>_emscripten_stack_get_current(),stackRestore=t=>__emscripten_stack_restore(t),createInvokeFunction=t=>(e,...I)=>{var B=stackSave();try{return dynCall(t,e,I)}catch(tr){if(stackRestore(B),tr!==tr+0)throw tr;if(_setThrew(1,0),t[0]=="j")return 0n}},resolveGlobalSymbol=(t,e=!1)=>{var I;return isSymbolDefined(t)?I=wasmImports[t]:t.startsWith("invoke_")&&(I=wasmImports[t]=createInvokeFunction(t.split("_")[1])),{sym:I,name:t}},UTF8ToString=(t,e)=>t?UTF8ArrayToString(HEAPU8,t,e):"",loadWebAssemblyModule=(binary,flags,libName,localScope,handle)=>{var metadata=getDylinkMetadata(binary);currentModuleWeakSymbols=metadata.weakImports;function loadModule(){var firstLoad=!handle||!HEAP8[handle+8];if(firstLoad){var memAlign=Math.pow(2,metadata.memoryAlign),memoryBase=metadata.memorySize?alignMemory(getMemory(metadata.memorySize+memAlign),memAlign):0,tableBase=metadata.tableSize?wasmTable.length:0;handle&&(HEAP8[handle+8]=1,HEAPU32[handle+12>>2]=memoryBase,HEAP32[handle+16>>2]=metadata.memorySize,HEAPU32[handle+20>>2]=tableBase,HEAP32[handle+24>>2]=metadata.tableSize)}else memoryBase=HEAPU32[handle+12>>2],tableBase=HEAPU32[handle+20>>2];var tableGrowthNeeded=tableBase+metadata.tableSize-wasmTable.length;tableGrowthNeeded>0&&wasmTable.grow(tableGrowthNeeded);var moduleExports;function resolveSymbol(t){var e=resolveGlobalSymbol(t).sym;return!e&&localScope&&(e=localScope[t]),e||(e=moduleExports[t]),e}var proxyHandler={get(t,e){switch(e){case"__memory_base":return memoryBase;case"__table_base":return tableBase}if(e in wasmImports&&!wasmImports[e].stub)return wasmImports[e];if(!(e in t)){var I;t[e]=(...B)=>(I||(I=resolveSymbol(e)),I(...B))}return t[e]}},proxy=new Proxy({},proxyHandler),info={"GOT.mem":new Proxy({},GOTHandler),"GOT.func":new Proxy({},GOTHandler),env:proxy,wasi_snapshot_preview1:proxy};function postInstantiation(module,instance){updateTableMap(tableBase,metadata.tableSize),moduleExports=relocateExports(instance.exports,memoryBase),flags.allowUndefined||reportUndefinedSymbols();function addEmAsm(addr,body){for(var args=[],arity=0;arity<16&&body.indexOf("$"+arity)!=-1;arity++)args.push("$"+arity);args=args.join(",");var func=`(${args}) => { ${body} };`;ASM_CONSTS[start]=eval(func)}if("__start_em_asm"in moduleExports)for(var start=moduleExports.__start_em_asm,stop=moduleExports.__stop_em_asm;start<stop;){var jsString=UTF8ToString(start);addEmAsm(start,jsString),start=HEAPU8.indexOf(0,start)+1}function addEmJs(name,cSig,body){var jsArgs=[];if(cSig=cSig.slice(1,-1),cSig!="void"){cSig=cSig.split(",");for(var i in cSig){var jsArg=cSig[i].split(" ").pop();jsArgs.push(jsArg.replaceAll("*",""))}}var func=`(${jsArgs}) => ${body};`;moduleExports[name]=eval(func)}for(var name in moduleExports)if(name.startsWith("__em_js__")){var start=moduleExports[name],jsString=UTF8ToString(start),parts=jsString.split("<::>");addEmJs(name.replace("__em_js__",""),parts[0],parts[1]),delete moduleExports[name]}var applyRelocs=moduleExports.__wasm_apply_data_relocs;applyRelocs&&(runtimeInitialized?applyRelocs():__RELOC_FUNCS__.push(applyRelocs));var init=moduleExports.__wasm_call_ctors;return init&&(runtimeInitialized?init():__ATINIT__.push(init)),moduleExports}if(flags.loadAsync){if(binary instanceof WebAssembly.Module){var instance=new WebAssembly.Instance(binary,info);return Promise.resolve(postInstantiation(binary,instance))}return WebAssembly.instantiate(binary,info).then(t=>postInstantiation(t.module,t.instance))}var module=binary instanceof WebAssembly.Module?binary:new WebAssembly.Module(binary),instance=new WebAssembly.Instance(module,info);return postInstantiation(module,instance)}return flags.loadAsync?metadata.neededDynlibs.reduce((t,e)=>t.then(()=>loadDynamicLibrary(e,flags,localScope)),Promise.resolve()).then(loadModule):(metadata.neededDynlibs.forEach(t=>loadDynamicLibrary(t,flags,localScope)),loadModule())},mergeLibSymbols=(t,e)=>{for(var[I,B]of Object.entries(t)){let tr=ir=>{isSymbolDefined(ir)||(wasmImports[ir]=B)};tr(I);let rr="__main_argc_argv";I=="main"&&tr(rr),I==rr&&tr("main")}},asyncLoad=async t=>{var e=await readAsync(t);return new Uint8Array(e)},preloadPlugins=Module.preloadPlugins||[],registerWasmPlugin=()=>{var t={promiseChainEnd:Promise.resolve(),canHandle:e=>!Module.noWasmDecoding&&e.endsWith(".so"),handle:(e,I,B,tr)=>{t.promiseChainEnd=t.promiseChainEnd.then(()=>loadWebAssemblyModule(e,{loadAsync:!0,nodelete:!0},I,{})).then(rr=>{preloadedWasm[I]=rr,B(e)},rr=>{err(`failed to instantiate wasm: ${I}: ${rr}`),tr()})}};preloadPlugins.push(t)},preloadedWasm={};function loadDynamicLibrary(t,e={global:!0,nodelete:!0},I,B){var tr=LDSO.loadedLibsByName[t];if(tr)return e.global?tr.global||(tr.global=!0,mergeLibSymbols(tr.exports)):I&&Object.assign(I,tr.exports),e.nodelete&&tr.refcount!==1/0&&(tr.refcount=1/0),tr.refcount++,B&&(LDSO.loadedLibsByHandle[B]=tr),e.loadAsync?Promise.resolve(!0):!0;tr=newDSO(t,B,"loading"),tr.refcount=e.nodelete?1/0:1,tr.global=e.global;function rr(){if(B){var dr=HEAPU32[B+28>>2],mr=HEAPU32[B+32>>2];if(dr&&mr){var hr=HEAP8.slice(dr,dr+mr);return e.loadAsync?Promise.resolve(hr):hr}}var fr=locateFile(t);if(e.loadAsync)return asyncLoad(fr);if(!readBinary)throw new Error(`${fr}: file not found, and synchronous loading of external files is not available`);return readBinary(fr)}function ir(){var dr=preloadedWasm[t];return dr?e.loadAsync?Promise.resolve(dr):dr:e.loadAsync?rr().then(mr=>loadWebAssemblyModule(mr,e,t,I,B)):loadWebAssemblyModule(rr(),e,t,I,B)}function lr(dr){tr.global?mergeLibSymbols(dr):I&&Object.assign(I,dr),tr.exports=dr}return e.loadAsync?ir().then(dr=>(lr(dr),!0)):(lr(ir()),!0)}var reportUndefinedSymbols=()=>{for(var[t,e]of Object.entries(GOT))if(e.value==0){var I=resolveGlobalSymbol(t,!0).sym;if(!I&&!e.required)continue;if(typeof I=="function")e.value=addFunction(I,I.sig);else if(typeof I=="number")e.value=I;else throw new Error(`bad export type for '${t}': ${typeof I}`)}},loadDylibs=()=>{if(!dynamicLibraries.length){reportUndefinedSymbols();return}addRunDependency(),dynamicLibraries.reduce((t,e)=>t.then(()=>loadDynamicLibrary(e,{loadAsync:!0,global:!0,nodelete:!0,allowUndefined:!0})),Promise.resolve()).then(()=>{reportUndefinedSymbols(),removeRunDependency()})},noExitRuntime=Module.noExitRuntime||!0;function setValue(t,e,I="i8"){switch(I.endsWith("*")&&(I="*"),I){case"i1":HEAP8[t]=e;break;case"i8":HEAP8[t]=e;break;case"i16":HEAP16[t>>1]=e;break;case"i32":HEAP32[t>>2]=e;break;case"i64":HEAP64[t>>3]=BigInt(e);break;case"float":HEAPF32[t>>2]=e;break;case"double":HEAPF64[t>>3]=e;break;case"*":HEAPU32[t>>2]=e;break;default:abort(`invalid type for setValue: ${I}`)}}var ___assert_fail=(t,e,I,B)=>abort(`Assertion failed: ${UTF8ToString(t)}, at: `+[e?UTF8ToString(e):"unknown filename",I,B?UTF8ToString(B):"unknown function"]);___assert_fail.sig="vppip";var ___call_sighandler=(t,e)=>getWasmTableEntry(t)(e);___call_sighandler.sig="vpi";var ___memory_base=new WebAssembly.Global({value:"i32",mutable:!1},16777216),___stack_pointer=new WebAssembly.Global({value:"i32",mutable:!0},23144432),PATH={isAbs:t=>t.charAt(0)==="/",splitPath:t=>{var e=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return e.exec(t).slice(1)},normalizeArray:(t,e)=>{for(var I=0,B=t.length-1;B>=0;B--){var tr=t[B];tr==="."?t.splice(B,1):tr===".."?(t.splice(B,1),I++):I&&(t.splice(B,1),I--)}if(e)for(;I;I--)t.unshift("..");return t},normalize:t=>{var e=PATH.isAbs(t),I=t.substr(-1)==="/";return t=PATH.normalizeArray(t.split("/").filter(B=>!!B),!e).join("/"),!t&&!e&&(t="."),t&&I&&(t+="/"),(e?"/":"")+t},dirname:t=>{var e=PATH.splitPath(t),I=e[0],B=e[1];return!I&&!B?".":(B&&(B=B.substr(0,B.length-1)),I+B)},basename:t=>{if(t==="/")return"/";t=PATH.normalize(t),t=t.replace(/\/$/,"");var e=t.lastIndexOf("/");return e===-1?t:t.substr(e+1)},join:(...t)=>PATH.normalize(t.join("/")),join2:(t,e)=>PATH.normalize(t+"/"+e)},initRandomFill=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return B=>crypto.getRandomValues(B);if(ENVIRONMENT_IS_NODE)try{var t=require("crypto"),e=t.randomFillSync;if(e)return B=>t.randomFillSync(B);var I=t.randomBytes;return B=>(B.set(I(B.byteLength)),B)}catch{}abort("initRandomDevice")},randomFill=t=>(randomFill=initRandomFill())(t),PATH_FS={resolve:(...t)=>{for(var e="",I=!1,B=t.length-1;B>=-1&&!I;B--){var tr=B>=0?t[B]:FS.cwd();if(typeof tr!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!tr)return"";e=tr+"/"+e,I=PATH.isAbs(tr)}return e=PATH.normalizeArray(e.split("/").filter(rr=>!!rr),!I).join("/"),(I?"/":"")+e||"."},relative:(t,e)=>{t=PATH_FS.resolve(t).substr(1),e=PATH_FS.resolve(e).substr(1);function I(mr){for(var hr=0;hr<mr.length&&mr[hr]==="";hr++);for(var fr=mr.length-1;fr>=0&&mr[fr]==="";fr--);return hr>fr?[]:mr.slice(hr,fr-hr+1)}for(var B=I(t.split("/")),tr=I(e.split("/")),rr=Math.min(B.length,tr.length),ir=rr,lr=0;lr<rr;lr++)if(B[lr]!==tr[lr]){ir=lr;break}for(var dr=[],lr=ir;lr<B.length;lr++)dr.push("..");return dr=dr.concat(tr.slice(ir)),dr.join("/")}},FS_stdin_getChar_buffer=[],lengthBytesUTF8=t=>{for(var e=0,I=0;I<t.length;++I){var B=t.charCodeAt(I);B<=127?e++:B<=2047?e+=2:B>=55296&&B<=57343?(e+=4,++I):e+=3}return e},stringToUTF8Array=(t,e,I,B)=>{if(!(B>0))return 0;for(var tr=I,rr=I+B-1,ir=0;ir<t.length;++ir){var lr=t.charCodeAt(ir);if(lr>=55296&&lr<=57343){var dr=t.charCodeAt(++ir);lr=65536+((lr&1023)<<10)|dr&1023}if(lr<=127){if(I>=rr)break;e[I++]=lr}else if(lr<=2047){if(I+1>=rr)break;e[I++]=192|lr>>6,e[I++]=128|lr&63}else if(lr<=65535){if(I+2>=rr)break;e[I++]=224|lr>>12,e[I++]=128|lr>>6&63,e[I++]=128|lr&63}else{if(I+3>=rr)break;e[I++]=240|lr>>18,e[I++]=128|lr>>12&63,e[I++]=128|lr>>6&63,e[I++]=128|lr&63}}return e[I]=0,I-tr};function intArrayFromString(t,e,I){var B=lengthBytesUTF8(t)+1,tr=new Array(B),rr=stringToUTF8Array(t,tr,0,tr.length);return tr.length=rr,tr}var FS_stdin_getChar=()=>{if(!FS_stdin_getChar_buffer.length){var t=null;if(ENVIRONMENT_IS_NODE){var e=256,I=Buffer.alloc(e),B=0,tr=process$1.stdin.fd;try{B=fs.readSync(tr,I,0,e)}catch(rr){if(rr.toString().includes("EOF"))B=0;else throw rr}B>0&&(t=I.slice(0,B).toString("utf-8"))}else typeof window<"u"&&typeof window.prompt=="function"&&(t=window.prompt("Input: "),t!==null&&(t+=`
21
+ `);for(let I of e.rows)this.serializers[I.typarray]=B=>Ke$1(B,this.serializers[I.oid],I.typarray),this.parsers[I.typarray]=B=>yn(B,this.parsers[I.oid],I.typarray)}async refreshArrayTypes(){await this._initArrayTypes({force:!0})}async query(t,e,I){return await this._checkReady(),await this._runExclusiveTransaction(async()=>await T(this,r,g$1).call(this,t,e,I))}async sql(t,...e){let{query:I,params:B}=g$2(t,...e);return await this.query(I,B)}async exec(t,e){return await this._checkReady(),await this._runExclusiveTransaction(async()=>await T(this,r,h).call(this,t,e))}async describeQuery(t,e){try{await T(this,r,l).call(this,O$1.parse({text:t,types:e?.paramTypes}),e);let I=await T(this,r,l).call(this,O$1.describe({type:"S"}),e),B=I.messages.find(lr=>lr.name==="parameterDescription"),tr=I.messages.find(lr=>lr.name==="rowDescription"),rr=B?.dataTypeIDs.map(lr=>({dataTypeID:lr,serializer:this.serializers[lr]}))??[],ir=tr?.fields.map(lr=>({name:lr.name,dataTypeID:lr.dataTypeID,parser:this.parsers[lr.dataTypeID]}))??[];return{queryParams:rr,resultFields:ir}}finally{await T(this,r,l).call(this,O$1.sync(),e)}}async transaction(t){return await this._checkReady(),await this._runExclusiveTransaction(async()=>{await T(this,r,h).call(this,"BEGIN"),x$2(this,u,!0);let e=!1,I=()=>{if(e)throw new Error("Transaction is closed")},B={query:async(tr,rr,ir)=>(I(),await T(this,r,g$1).call(this,tr,rr,ir)),sql:async(tr,...rr)=>{let{query:ir,params:lr}=g$2(tr,...rr);return await T(this,r,g$1).call(this,ir,lr)},exec:async(tr,rr)=>(I(),await T(this,r,h).call(this,tr,rr)),rollback:async()=>{I(),await T(this,r,h).call(this,"ROLLBACK"),e=!0},get closed(){return e}};try{let tr=await t(B);return e||(e=!0,await T(this,r,h).call(this,"COMMIT")),x$2(this,u,!1),tr}catch(tr){throw e||await T(this,r,h).call(this,"ROLLBACK"),x$2(this,u,!1),tr}})}async runExclusive(t){return await this._runExclusiveQuery(t)}};b=new WeakMap,u=new WeakMap,r=new WeakSet,l=async function(t,e={}){return await this.execProtocol(t,{...e,syncToFs:!1})},g$1=async function(t,e=[],I){return await this._runExclusiveQuery(async()=>{T(this,r,R).call(this,"runQuery",t,e,I),await this._handleBlob(I?.blob);let B;try{let{messages:rr}=await T(this,r,l).call(this,O$1.parse({text:t,types:I?.paramTypes}),I),ir=De((await T(this,r,l).call(this,O$1.describe({type:"S"}),I)).messages),lr=e.map((dr,mr)=>{let hr=ir[mr];if(dr==null)return null;let fr=I?.serializers?.[hr]??this.serializers[hr];return fr?fr(dr):dr.toString()});B=[...rr,...(await T(this,r,l).call(this,O$1.bind({values:lr}),I)).messages,...(await T(this,r,l).call(this,O$1.describe({type:"P"}),I)).messages,...(await T(this,r,l).call(this,O$1.execute({}),I)).messages]}finally{await T(this,r,l).call(this,O$1.sync(),I)}await this._cleanupBlob(),h$1(this,u)||await this.syncToFs();let tr=await this._getWrittenBlob();return bn(B,this.parsers,I,tr)[0]})},h=async function(t,e){return await this._runExclusiveQuery(async()=>{T(this,r,R).call(this,"runExec",t,e),await this._handleBlob(e?.blob);let I;try{I=(await T(this,r,l).call(this,O$1.query(t),e)).messages}finally{await T(this,r,l).call(this,O$1.sync(),e)}this._cleanupBlob(),h$1(this,u)||await this.syncToFs();let B=await this._getWrittenBlob();return bn(I,this.parsers,e,B)})},R=function(...t){this.debug>0&&console.log(...t)};var w=D$1((t,e)=>{u$1();var I=9007199254740991,B=(function(Sr){return Sr})();function tr(Sr){return Sr===B}function rr(Sr){return typeof Sr=="string"||Object.prototype.toString.call(Sr)=="[object String]"}function ir(Sr){return Object.prototype.toString.call(Sr)=="[object Date]"}function lr(Sr){return Sr!==null&&typeof Sr=="object"}function dr(Sr){return typeof Sr=="function"}function mr(Sr){return typeof Sr=="number"&&Sr>-1&&Sr%1==0&&Sr<=I}function hr(Sr){return Object.prototype.toString.call(Sr)=="[object Array]"}function fr(Sr){return lr(Sr)&&!dr(Sr)&&mr(Sr.length)}function _r(Sr){return Object.prototype.toString.call(Sr)=="[object ArrayBuffer]"}function wr(Sr,yr){return Array.prototype.map.call(Sr,yr)}function gr(Sr,yr){var br=B;return dr(yr)&&Array.prototype.every.call(Sr,function(vr,Cr,Ar){var Ir=yr(vr,Cr,Ar);return Ir&&(br=vr),!Ir}),br}function xr(Sr){return Object.assign.apply(null,arguments)}function Mr(Sr){var yr,br,vr;if(rr(Sr)){for(br=Sr.length,vr=new Uint8Array(br),yr=0;yr<br;yr++)vr[yr]=Sr.charCodeAt(yr)&255;return vr}return _r(Sr)?new Uint8Array(Sr):lr(Sr)&&_r(Sr.buffer)?new Uint8Array(Sr.buffer):fr(Sr)?new Uint8Array(Sr):lr(Sr)&&dr(Sr.toString)?Mr(Sr.toString()):new Uint8Array}e.exports.MAX_SAFE_INTEGER=I,e.exports.isUndefined=tr,e.exports.isString=rr,e.exports.isObject=lr,e.exports.isDateTime=ir,e.exports.isFunction=dr,e.exports.isArray=hr,e.exports.isArrayLike=fr,e.exports.isArrayBuffer=_r,e.exports.map=wr,e.exports.find=gr,e.exports.extend=xr,e.exports.toUint8Array=Mr}),x=D$1((t,e)=>{u$1();var I="\0";e.exports={NULL_CHAR:I,TMAGIC:"ustar"+I+"00",OLDGNU_MAGIC:"ustar "+I,REGTYPE:0,LNKTYPE:1,SYMTYPE:2,CHRTYPE:3,BLKTYPE:4,DIRTYPE:5,FIFOTYPE:6,CONTTYPE:7,TSUID:parseInt("4000",8),TSGID:parseInt("2000",8),TSVTX:parseInt("1000",8),TUREAD:parseInt("0400",8),TUWRITE:parseInt("0200",8),TUEXEC:parseInt("0100",8),TGREAD:parseInt("0040",8),TGWRITE:parseInt("0020",8),TGEXEC:parseInt("0010",8),TOREAD:parseInt("0004",8),TOWRITE:parseInt("0002",8),TOEXEC:parseInt("0001",8),TPERMALL:parseInt("0777",8),TPERMMASK:parseInt("0777",8)}}),L=D$1((t,e)=>{u$1();var I=w(),B=x(),tr=512,rr=B.TPERMALL,ir=0,lr=0,dr=[["name",100,0,function(yr,br){return fr(yr[br[0]],br[1])},function(yr,br,vr){return gr(yr.slice(br,br+vr[1]))}],["mode",8,100,function(yr,br){var vr=yr[br[0]]||rr;return vr=vr&B.TPERMMASK,_r(vr,br[1],rr)},function(yr,br,vr){var Cr=xr(yr.slice(br,br+vr[1]));return Cr&=B.TPERMMASK,Cr}],["uid",8,108,function(yr,br){return _r(yr[br[0]],br[1],ir)},function(yr,br,vr){return xr(yr.slice(br,br+vr[1]))}],["gid",8,116,function(yr,br){return _r(yr[br[0]],br[1],lr)},function(yr,br,vr){return xr(yr.slice(br,br+vr[1]))}],["size",12,124,function(yr,br){return _r(yr.data.length,br[1])},function(yr,br,vr){return xr(yr.slice(br,br+vr[1]))}],["modifyTime",12,136,function(yr,br){return wr(yr[br[0]],br[1])},function(yr,br,vr){return Mr(yr.slice(br,br+vr[1]))}],["checksum",8,148,function(yr,br){return" "},function(yr,br,vr){return xr(yr.slice(br,br+vr[1]))}],["type",1,156,function(yr,br){return""+(parseInt(yr[br[0]],10)||0)%8},function(yr,br,vr){return(parseInt(String.fromCharCode(yr[br]),10)||0)%8}],["linkName",100,157,function(yr,br){return""},function(yr,br,vr){return gr(yr.slice(br,br+vr[1]))}],["ustar",8,257,function(yr,br){return B.TMAGIC},function(yr,br,vr){return hr(gr(yr.slice(br,br+vr[1]),!0))},function(yr,br){return yr[br[0]]==B.TMAGIC||yr[br[0]]==B.OLDGNU_MAGIC}],["owner",32,265,function(yr,br){return fr(yr[br[0]],br[1])},function(yr,br,vr){return gr(yr.slice(br,br+vr[1]))}],["group",32,297,function(yr,br){return fr(yr[br[0]],br[1])},function(yr,br,vr){return gr(yr.slice(br,br+vr[1]))}],["majorNumber",8,329,function(yr,br){return""},function(yr,br,vr){return xr(yr.slice(br,br+vr[1]))}],["minorNumber",8,337,function(yr,br){return""},function(yr,br,vr){return xr(yr.slice(br,br+vr[1]))}],["prefix",131,345,function(yr,br){return fr(yr[br[0]],br[1])},function(yr,br,vr){return gr(yr.slice(br,br+vr[1]))}],["accessTime",12,476,function(yr,br){return wr(yr[br[0]],br[1])},function(yr,br,vr){return Mr(yr.slice(br,br+vr[1]))}],["createTime",12,488,function(yr,br){return wr(yr[br[0]],br[1])},function(yr,br,vr){return Mr(yr.slice(br,br+vr[1]))}]],mr=(function(yr){var br=yr[yr.length-1];return br[2]+br[1]})(dr);function hr(yr){if(yr.length==8){var br=yr.split("");if(br[5]==B.NULL_CHAR)return(br[6]==" "||br[6]==B.NULL_CHAR)&&(br[6]="0"),(br[7]==" "||br[7]==B.NULL_CHAR)&&(br[7]="0"),br=br.join(""),br==B.TMAGIC?br:yr;if(br[7]==B.NULL_CHAR)return br[5]==B.NULL_CHAR&&(br[5]=" "),br[6]==B.NULL_CHAR&&(br[6]=" "),br==B.OLDGNU_MAGIC?br:yr}return yr}function fr(yr,br){return br-=1,I.isUndefined(yr)&&(yr=""),yr=(""+yr).substr(0,br),yr+B.NULL_CHAR}function _r(yr,br,vr){for(vr=parseInt(vr)||0,br-=1,yr=(parseInt(yr)||vr).toString(8).substr(-br,br);yr.length<br;)yr="0"+yr;return yr+B.NULL_CHAR}function wr(yr,br){if(I.isDateTime(yr))yr=Math.floor(1*yr/1e3);else if(yr=parseInt(yr,10),isFinite(yr)){if(yr<=0)return""}else yr=Math.floor(1*new Date/1e3);return _r(yr,br,0)}function gr(yr,br){var vr=String.fromCharCode.apply(null,yr);if(br)return vr;var Cr=vr.indexOf(B.NULL_CHAR);return Cr>=0?vr.substr(0,Cr):vr}function xr(yr){var br=String.fromCharCode.apply(null,yr);return parseInt(br.replace(/^0+$/g,""),8)||0}function Mr(yr){return yr.length==0||yr[0]==0?null:new Date(1e3*xr(yr))}function Sr(yr,br,vr){var Cr=parseInt(br,10)||0,Ar=Math.min(Cr+mr,yr.length),Ir=0,Dr=0,Fr=0;vr&&dr.every(function(Pr){return Pr[0]=="checksum"?(Dr=Cr+Pr[2],Fr=Dr+Pr[1],!1):!0});for(var zr=32,Gr=Cr;Gr<Ar;Gr++){var Ur=Gr>=Dr&&Gr<Fr?zr:yr[Gr];Ir=(Ir+Ur)%262144}return Ir}e.exports.recordSize=tr,e.exports.defaultFileMode=rr,e.exports.defaultUid=ir,e.exports.defaultGid=lr,e.exports.posixHeader=dr,e.exports.effectiveHeaderSize=mr,e.exports.calculateChecksum=Sr,e.exports.formatTarString=fr,e.exports.formatTarNumber=_r,e.exports.formatTarDateTime=wr,e.exports.parseTarString=gr,e.exports.parseTarNumber=xr,e.exports.parseTarDateTime=Mr}),er=D$1((t,e)=>{u$1();var I=x(),B=w(),tr=L();function rr(fr){return tr.recordSize}function ir(fr){return Math.ceil(fr.data.length/tr.recordSize)*tr.recordSize}function lr(fr){var _r=0;return fr.forEach(function(wr){_r+=rr()+ir(wr)}),_r+=tr.recordSize*2,new Uint8Array(_r)}function dr(fr,_r,wr){wr=parseInt(wr)||0;var gr=wr;tr.posixHeader.forEach(function(br){for(var vr=br[3](_r,br),Cr=vr.length,Ar=0;Ar<Cr;Ar+=1)fr[gr+Ar]=vr.charCodeAt(Ar)&255;gr+=br[1]});var xr=B.find(tr.posixHeader,function(br){return br[0]=="checksum"});if(xr){var Mr=tr.calculateChecksum(fr,wr,!0),Sr=tr.formatTarNumber(Mr,xr[1]-2)+I.NULL_CHAR+" ";gr=wr+xr[2];for(var yr=0;yr<Sr.length;yr+=1)fr[gr]=Sr.charCodeAt(yr)&255,gr++}return wr+rr()}function mr(fr,_r,wr){return wr=parseInt(wr,10)||0,fr.set(_r.data,wr),wr+ir(_r)}function hr(fr){fr=B.map(fr,function(gr){return B.extend({},gr,{data:B.toUint8Array(gr.data)})});var _r=lr(fr),wr=0;return fr.forEach(function(gr){wr=dr(_r,gr,wr),wr=mr(_r,gr,wr)}),_r}e.exports.tar=hr}),nr=D$1((t,e)=>{u$1();var I=x(),B=w(),tr=L(),rr={extractData:!0,checkHeader:!0,checkChecksum:!0,checkFileSize:!0},ir={size:!0,checksum:!0,ustar:!0},lr={unexpectedEndOfFile:"Unexpected end of file.",fileCorrupted:"File is corrupted.",checksumCheckFailed:"Checksum check failed."};function dr(xr){return tr.recordSize}function mr(xr){return Math.ceil(xr/tr.recordSize)*tr.recordSize}function hr(xr,Mr){for(var Sr=Mr,yr=Math.min(xr.length,Mr+tr.recordSize*2),br=Sr;br<yr;br++)if(xr[br]!=0)return!1;return!0}function fr(xr,Mr,Sr){if(xr.length-Mr<tr.recordSize){if(Sr.checkFileSize)throw new Error(lr.unexpectedEndOfFile);return null}Mr=parseInt(Mr)||0;var yr={},br=Mr;if(tr.posixHeader.forEach(function(Ar){yr[Ar[0]]=Ar[4](xr,br,Ar),br+=Ar[1]}),yr.type!=0&&(yr.size=0),Sr.checkHeader&&tr.posixHeader.forEach(function(Ar){if(B.isFunction(Ar[5])&&!Ar[5](yr,Ar)){var Ir=new Error(lr.fileCorrupted);throw Ir.data={offset:Mr+Ar[2],field:Ar[0]},Ir}}),Sr.checkChecksum){var vr=tr.calculateChecksum(xr,Mr,!0);if(vr!=yr.checksum){var Cr=new Error(lr.checksumCheckFailed);throw Cr.data={offset:Mr,header:yr,checksum:vr},Cr}}return yr}function _r(xr,Mr,Sr,yr){return yr.extractData?Sr.size<=0?new Uint8Array:xr.slice(Mr,Mr+Sr.size):null}function wr(xr,Mr){var Sr={};return tr.posixHeader.forEach(function(yr){var br=yr[0];ir[br]||(Sr[br]=xr[br])}),Sr.isOldGNUFormat=xr.ustar==I.OLDGNU_MAGIC,Mr&&(Sr.data=Mr),Sr}function gr(xr,Mr){Mr=B.extend({},rr,Mr);for(var Sr=[],yr=0,br=xr.length;br-yr>=tr.recordSize;){xr=B.toUint8Array(xr);var vr=fr(xr,yr,Mr);if(!vr)break;yr+=dr();var Cr=_r(xr,yr,vr,Mr);if(Sr.push(wr(vr,Cr)),yr+=mr(vr.size),hr(xr,yr))break}return Sr}e.exports.untar=gr}),or$2=D$1((t,e)=>{u$1();var I=w(),B=x(),tr=er(),rr=nr();I.extend(e.exports,tr,rr,B)});u$1();u$1();var g=L$2(or$2());async function H$1(t,e,I="pgdata",B="auto"){let tr=Br(t,e),[rr,ir]=await qr(tr,B),lr=I+(ir?".tar.gz":".tar"),dr=ir?"application/x-gzip":"application/x-tar";return typeof File<"u"?new File([rr],lr,{type:dr}):new Blob([rr],{type:dr})}var Hr=["application/x-gtar","application/x-tar+gzip","application/x-gzip","application/gzip"];async function ce$1(t,e,I){let B=new Uint8Array(await e.arrayBuffer()),tr=typeof File<"u"&&e instanceof File?e.name:void 0;(Hr.includes(e.type)||tr?.endsWith(".tgz")||tr?.endsWith(".tar.gz"))&&(B=await ar(B));let rr;try{rr=(0,g.untar)(B)}catch(ir){if(ir instanceof Error&&ir.message.includes("File is corrupted"))B=await ar(B),rr=(0,g.untar)(B);else throw ir}for(let ir of rr){let lr=I+ir.name,dr=lr.split("/").slice(0,-1);for(let mr=1;mr<=dr.length;mr++){let hr=dr.slice(0,mr).join("/");t.analyzePath(hr).exists||t.mkdir(hr)}ir.type===g.REGTYPE?(t.writeFile(lr,ir.data),t.utime(lr,sr(ir.modifyTime),sr(ir.modifyTime))):ir.type===g.DIRTYPE&&t.mkdir(lr)}}function jr(t,e){let I=[],B=tr=>{t.readdir(tr).forEach(rr=>{if(rr==="."||rr==="..")return;let ir=tr+"/"+rr,lr=t.stat(ir),dr=t.isFile(lr.mode)?t.readFile(ir,{encoding:"binary"}):new Uint8Array(0);I.push({name:ir.substring(e.length),mode:lr.mode,size:lr.size,type:t.isFile(lr.mode)?g.REGTYPE:g.DIRTYPE,modifyTime:lr.mtime,data:dr}),t.isDir(lr.mode)&&B(ir)})};return B(e),I}function Br(t,e){let I=jr(t,e);return(0,g.tar)(I)}async function qr(t,e="auto"){if(e==="none")return[t,!1];if(typeof CompressionStream<"u")return[await Yr(t),!0];if(typeof process$1<"u"&&process$1.versions&&process$1.versions.node)return[await Wr(t),!0];if(e==="auto")return[t,!1];throw new Error("Compression not supported in this environment")}async function Yr(t){let e=new CompressionStream("gzip"),I=e.writable.getWriter(),B=e.readable.getReader();I.write(t),I.close();let tr=[];for(;;){let{value:lr,done:dr}=await B.read();if(dr)break;lr&&tr.push(lr)}let rr=new Uint8Array(tr.reduce((lr,dr)=>lr+dr.length,0)),ir=0;return tr.forEach(lr=>{rr.set(lr,ir),ir+=lr.length}),rr}async function Wr(t){let{promisify:e}=await __vitePreload(()=>Promise.resolve().then(()=>__viteBrowserExternal$1),void 0),{gzip:I}=await __vitePreload(async()=>{const{gzip:B}=await Promise.resolve().then(()=>__viteBrowserExternal$1);return{gzip:B}},void 0);return await e(I)(t)}async function ar(t){if(typeof CompressionStream<"u")return await Xr(t);if(typeof process$1<"u"&&process$1.versions&&process$1.versions.node)return await Kr(t);throw new Error("Unsupported environment for decompression")}async function Xr(t){let e=new DecompressionStream("gzip"),I=e.writable.getWriter(),B=e.readable.getReader();I.write(t),I.close();let tr=[];for(;;){let{value:lr,done:dr}=await B.read();if(dr)break;lr&&tr.push(lr)}let rr=new Uint8Array(tr.reduce((lr,dr)=>lr+dr.length,0)),ir=0;return tr.forEach(lr=>{rr.set(lr,ir),ir+=lr.length}),rr}async function Kr(t){let{promisify:e}=await __vitePreload(()=>Promise.resolve().then(()=>__viteBrowserExternal$1),void 0),{gunzip:I}=await __vitePreload(async()=>{const{gunzip:B}=await Promise.resolve().then(()=>__viteBrowserExternal$1);return{gunzip:B}},void 0);return await e(I)(t)}function sr(t){return t?typeof t=="number"?t:Math.floor(t.getTime()/1e3):Math.floor(Date.now()/1e3)}var Vr="/tmp/pglite",C=Vr+"/base",ur=class{constructor(t){this.dataDir=t}async init(t,e){return this.pg=t,{emscriptenOpts:e}}async syncToFs(t){}async initialSyncFs(){}async closeFs(){}async dumpTar(t,e){return H$1(this.pg.Module.FS,C,t,e)}},cr=class{constructor(t,{debug:e=!1}={}){this.dataDir=t,this.debug=e}async syncToFs(t){}async initialSyncFs(){}async closeFs(){}async dumpTar(t,e){return H$1(this.pg.Module.FS,C,t,e)}async init(t,e){return this.pg=t,{emscriptenOpts:{...e,preRun:[...e.preRun||[],I=>{let B=Zr(I,this);I.FS.mkdir(C),I.FS.mount(B,{},C)}]}}}},pr={EBADF:8,EBADFD:127,EEXIST:20,EINVAL:28,EISDIR:31,ENODEV:43,ENOENT:44,ENOTDIR:54,ENOTEMPTY:55},Zr=(t,e)=>{let I=t.FS,B=e.debug?console.log:null,tr={tryFSOperation(rr){try{return rr()}catch(ir){throw ir.code?ir.code==="UNKNOWN"?new I.ErrnoError(pr.EINVAL):new I.ErrnoError(ir.code):ir}},mount(rr){return tr.createNode(null,"/",16895,0)},syncfs(rr,ir,lr){},createNode(rr,ir,lr,dr){if(!I.isDir(lr)&&!I.isFile(lr))throw new I.ErrnoError(28);let mr=I.createNode(rr,ir,lr);return mr.node_ops=tr.node_ops,mr.stream_ops=tr.stream_ops,mr},getMode:function(rr){return B?.("getMode",rr),tr.tryFSOperation(()=>e.lstat(rr).mode)},realPath:function(rr){let ir=[];for(;rr.parent!==rr;)ir.push(rr.name),rr=rr.parent;return ir.push(rr.mount.opts.root),ir.reverse(),ir.join("/")},node_ops:{getattr(rr){B?.("getattr",tr.realPath(rr));let ir=tr.realPath(rr);return tr.tryFSOperation(()=>{let lr=e.lstat(ir);return{...lr,dev:0,ino:rr.id,nlink:1,rdev:rr.rdev,atime:new Date(lr.atime),mtime:new Date(lr.mtime),ctime:new Date(lr.ctime)}})},setattr(rr,ir){B?.("setattr",tr.realPath(rr),ir);let lr=tr.realPath(rr);tr.tryFSOperation(()=>{ir.mode!==void 0&&e.chmod(lr,ir.mode),ir.size!==void 0&&e.truncate(lr,ir.size),ir.timestamp!==void 0&&e.utimes(lr,ir.timestamp,ir.timestamp),ir.size!==void 0&&e.truncate(lr,ir.size)})},lookup(rr,ir){B?.("lookup",tr.realPath(rr),ir);let lr=[tr.realPath(rr),ir].join("/"),dr=tr.getMode(lr);return tr.createNode(rr,ir,dr)},mknod(rr,ir,lr,dr){B?.("mknod",tr.realPath(rr),ir,lr,dr);let mr=tr.createNode(rr,ir,lr,dr),hr=tr.realPath(mr);return tr.tryFSOperation(()=>(I.isDir(mr.mode)?e.mkdir(hr,{mode:lr}):e.writeFile(hr,"",{mode:lr}),mr))},rename(rr,ir,lr){B?.("rename",tr.realPath(rr),tr.realPath(ir),lr);let dr=tr.realPath(rr),mr=[tr.realPath(ir),lr].join("/");tr.tryFSOperation(()=>{e.rename(dr,mr)}),rr.name=lr},unlink(rr,ir){B?.("unlink",tr.realPath(rr),ir);let lr=[tr.realPath(rr),ir].join("/");try{e.unlink(lr)}catch{}},rmdir(rr,ir){B?.("rmdir",tr.realPath(rr),ir);let lr=[tr.realPath(rr),ir].join("/");return tr.tryFSOperation(()=>{e.rmdir(lr)})},readdir(rr){B?.("readdir",tr.realPath(rr));let ir=tr.realPath(rr);return tr.tryFSOperation(()=>e.readdir(ir))},symlink(rr,ir,lr){throw B?.("symlink",tr.realPath(rr),ir,lr),new I.ErrnoError(63)},readlink(rr){throw B?.("readlink",tr.realPath(rr)),new I.ErrnoError(63)}},stream_ops:{open(rr){B?.("open stream",tr.realPath(rr.node));let ir=tr.realPath(rr.node);return tr.tryFSOperation(()=>{I.isFile(rr.node.mode)&&(rr.shared.refcount=1,rr.nfd=e.open(ir))})},close(rr){return B?.("close stream",tr.realPath(rr.node)),tr.tryFSOperation(()=>{I.isFile(rr.node.mode)&&rr.nfd&&--rr.shared.refcount===0&&e.close(rr.nfd)})},dup(rr){B?.("dup stream",tr.realPath(rr.node)),rr.shared.refcount++},read(rr,ir,lr,dr,mr){return B?.("read stream",tr.realPath(rr.node),lr,dr,mr),dr===0?0:tr.tryFSOperation(()=>e.read(rr.nfd,ir,lr,dr,mr))},write(rr,ir,lr,dr,mr){return B?.("write stream",tr.realPath(rr.node),lr,dr,mr),tr.tryFSOperation(()=>e.write(rr.nfd,ir.buffer,lr,dr,mr))},llseek(rr,ir,lr){B?.("llseek stream",tr.realPath(rr.node),ir,lr);let dr=ir;if(lr===1?dr+=rr.position:lr===2&&I.isFile(rr.node.mode)&&tr.tryFSOperation(()=>{let mr=e.fstat(rr.nfd);dr+=mr.size}),dr<0)throw new I.ErrnoError(28);return dr},mmap(rr,ir,lr,dr,mr){if(B?.("mmap stream",tr.realPath(rr.node),ir,lr,dr,mr),!I.isFile(rr.node.mode))throw new I.ErrnoError(pr.ENODEV);let hr=t.mmapAlloc(ir);return tr.stream_ops.read(rr,t.HEAP8,hr,ir,lr),{ptr:hr,allocated:!0}},msync(rr,ir,lr,dr,mr){return B?.("msync stream",tr.realPath(rr.node),lr,dr,mr),tr.stream_ops.write(rr,ir,0,dr,lr),0}}};return tr};u$1();u$1();u$1();var He=new Error("request for lock canceled"),We=function(t,e,I,B){function tr(rr){return rr instanceof I?rr:new I(function(ir){ir(rr)})}return new(I||(I=Promise))(function(rr,ir){function lr(hr){try{mr(B.next(hr))}catch(fr){ir(fr)}}function dr(hr){try{mr(B.throw(hr))}catch(fr){ir(fr)}}function mr(hr){hr.done?rr(hr.value):tr(hr.value).then(lr,dr)}mr((B=B.apply(t,[])).next())})},ce=class{constructor(t,e=He){this._value=t,this._cancelError=e,this._weightedQueues=[],this._weightedWaiters=[]}acquire(t=1){if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);return new Promise((e,I)=>{this._weightedQueues[t-1]||(this._weightedQueues[t-1]=[]),this._weightedQueues[t-1].push({resolve:e,reject:I}),this._dispatch()})}runExclusive(t,e=1){return We(this,void 0,void 0,function*(){let[I,B]=yield this.acquire(e);try{return yield t(I)}finally{B()}})}waitForUnlock(t=1){if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);return new Promise(e=>{this._weightedWaiters[t-1]||(this._weightedWaiters[t-1]=[]),this._weightedWaiters[t-1].push(e),this._dispatch()})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(t){this._value=t,this._dispatch()}release(t=1){if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);this._value+=t,this._dispatch()}cancel(){this._weightedQueues.forEach(t=>t.forEach(e=>e.reject(this._cancelError))),this._weightedQueues=[]}_dispatch(){var t;for(let e=this._value;e>0;e--){let I=(t=this._weightedQueues[e-1])===null||t===void 0?void 0:t.shift();if(!I)continue;let B=this._value,tr=e;this._value-=e,e=this._value+1,I.resolve([B,this._newReleaser(tr)])}this._drainUnlockWaiters()}_newReleaser(t){let e=!1;return()=>{e||(e=!0,this.release(t))}}_drainUnlockWaiters(){for(let t=this._value;t>0;t--)this._weightedWaiters[t-1]&&(this._weightedWaiters[t-1].forEach(e=>e()),this._weightedWaiters[t-1]=[])}},je=function(t,e,I,B){function tr(rr){return rr instanceof I?rr:new I(function(ir){ir(rr)})}return new(I||(I=Promise))(function(rr,ir){function lr(hr){try{mr(B.next(hr))}catch(fr){ir(fr)}}function dr(hr){try{mr(B.throw(hr))}catch(fr){ir(fr)}}function mr(hr){hr.done?rr(hr.value):tr(hr.value).then(lr,dr)}mr((B=B.apply(t,[])).next())})},H=class{constructor(t){this._semaphore=new ce(1,t)}acquire(){return je(this,void 0,void 0,function*(){let[,t]=yield this._semaphore.acquire();return t})}runExclusive(t){return this._semaphore.runExclusive(()=>t())}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}};u$1();var Ie=L$2(or$2());async function ge(t){if(Fe$1){let e=await __vitePreload(()=>Promise.resolve().then(()=>__viteBrowserExternal$1),void 0),I=await __vitePreload(()=>Promise.resolve().then(()=>__viteBrowserExternal$1),void 0),{Writable:B}=await __vitePreload(async()=>{const{Writable:lr}=await Promise.resolve().then(()=>__viteBrowserExternal$1);return{Writable:lr}},void 0),{pipeline:tr}=await __vitePreload(async()=>{const{pipeline:lr}=await Promise.resolve().then(()=>__viteBrowserExternal$1);return{pipeline:lr}},void 0);if(!e.existsSync(t))throw new Error(`Extension bundle not found: ${t}`);let rr=I.createGunzip(),ir=[];return await tr(e.createReadStream(t),rr,new B({write(lr,dr,mr){ir.push(lr),mr()}})),new Blob(ir)}else{let e=await fetch(t.toString());if(!e.ok||!e.body)return null;if(e.headers.get("Content-Encoding")==="gzip")return e.blob();{let I=new DecompressionStream("gzip");return new Response(e.body.pipeThrough(I)).blob()}}}async function Pe(t,e){for(let I in t.pg_extensions){let B;try{B=await t.pg_extensions[I]}catch(tr){console.error("Failed to fetch extension:",I,tr);continue}if(B){let tr=new Uint8Array(await B.arrayBuffer());Ve(t,I,tr,e)}else console.error("Could not get binary data for extension:",I)}}function Ve(t,e,I,B){Ie.default.untar(I).forEach(tr=>{if(!tr.name.startsWith(".")){let rr=t.WASM_PREFIX+"/"+tr.name;if(tr.name.endsWith(".so")){let ir=(...dr)=>{B("pgfs:ext OK",rr,dr)},lr=(...dr)=>{B("pgfs:ext FAIL",rr,dr)};t.FS.createPreloadedFile(Ke(rr),tr.name.split("/").pop().slice(0,-3),tr.data,!0,!0,ir,lr,!1)}else t.FS.writeFile(rr,tr.data)}})}function Ke(t){let e=t.lastIndexOf("/");return e>0?t.slice(0,e):t}u$1();u$1();var ee=class extends ur{async init(t,e){return this.pg=t,{emscriptenOpts:{...e,preRun:[...e.preRun||[],I=>{let B=I.FS.filesystems.IDBFS;I.FS.mkdir("/pglite"),I.FS.mkdir(`/pglite/${this.dataDir}`),I.FS.mount(B,{},`/pglite/${this.dataDir}`),I.FS.symlink(`/pglite/${this.dataDir}`,C)}]}}}initialSyncFs(){return new Promise((t,e)=>{this.pg.Module.FS.syncfs(!0,I=>{I?e(I):t()})})}syncToFs(t){return new Promise((e,I)=>{this.pg.Module.FS.syncfs(!1,B=>{B?I(B):e()})})}async closeFs(){let t=this.pg.Module.FS.filesystems.IDBFS.dbs[this.dataDir];t&&t.close(),this.pg.Module.FS.quit()}};u$1();var te=class extends ur{async closeFs(){this.pg.Module.FS.quit()}};function Fe(t){let e;if(t?.startsWith("file://")){if(t=t.slice(7),!t)throw new Error("Invalid dataDir, must be a valid path");e="nodefs"}else t?.startsWith("idb://")?(t=t.slice(6),e="idbfs"):t?.startsWith("opfs-ahp://")?(t=t.slice(11),e="opfs-ahp"):!t||t?.startsWith("memory://")?e="memoryfs":e="nodefs";return{dataDir:t,fsType:e}}async function Ae(t,e){let I;if(t&&e==="nodefs"){let{NodeFS:B}=await __vitePreload(()=>import("./nodefs-DwD3CLeV.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]));I=new B(t)}else if(t&&e==="idbfs")I=new ee(t);else if(t&&e==="opfs-ahp"){let{OpfsAhpFS:B}=await __vitePreload(()=>import("./opfs-ahp-CXiEKQWP.js"),__vite__mapDeps([18,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]));I=new B(t)}else I=new te;return I}u$1();u$1();var Qe=(()=>{var _scriptName=import.meta.url;return async function(moduleArg={}){var moduleRtn,Module=moduleArg,readyPromiseResolve,readyPromiseReject,readyPromise=new Promise((t,e)=>{readyPromiseResolve=t,readyPromiseReject=e}),ENVIRONMENT_IS_WEB=typeof window=="object",ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope<"u",ENVIRONMENT_IS_NODE=typeof process$1=="object"&&typeof process$1.versions=="object"&&typeof process$1.versions.node=="string"&&process$1.type!="renderer";if(ENVIRONMENT_IS_NODE){let{createRequire:t}=await __vitePreload(()=>Promise.resolve().then(()=>__viteBrowserExternal$1),void 0),e=import.meta.url;e.startsWith("data:")&&(e="/");var require=t(e)}Module.expectedDataFileDownloads??(Module.expectedDataFileDownloads=0),Module.expectedDataFileDownloads++,(()=>{var t=typeof ENVIRONMENT_IS_PTHREAD<"u"&&ENVIRONMENT_IS_PTHREAD,e=typeof ENVIRONMENT_IS_WASM_WORKER<"u"&&ENVIRONMENT_IS_WASM_WORKER;if(t||e)return;var I=typeof process$1=="object"&&typeof process$1.versions=="object"&&typeof process$1.versions.node=="string";function B(tr){typeof window=="object"?window.encodeURIComponent(window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/"):typeof process$1>"u"&&typeof location<"u"&&encodeURIComponent(location.pathname.substring(0,location.pathname.lastIndexOf("/"))+"/");var rr="postgres.data",ir="postgres.data",lr=Module.locateFile?Module.locateFile(ir,""):ir,dr=tr.remote_package_size;function mr(gr,xr,Mr,Sr){if(I){require("fs").readFile(gr,(yr,br)=>{yr?Sr(yr):Mr(br.buffer)});return}Module.dataFileDownloads??(Module.dataFileDownloads={}),fetch(gr).catch(yr=>Promise.reject(new Error(`Network Error: ${gr}`,{cause:yr}))).then(yr=>{if(!yr.ok)return Promise.reject(new Error(`${yr.status}: ${yr.url}`));if(!yr.body&&yr.arrayBuffer)return yr.arrayBuffer().then(Mr);let br=yr.body.getReader(),vr=()=>br.read().then(Fr).catch(zr=>Promise.reject(new Error(`Unexpected error while handling : ${yr.url} ${zr}`,{cause:zr}))),Cr=[],Ar=yr.headers,Ir=Number(Ar.get("Content-Length")??xr),Dr=0,Fr=({done:zr,value:Gr})=>{if(zr){let Ur=new Uint8Array(Cr.map(kr=>kr.length).reduce((kr,Or)=>kr+Or,0)),Pr=0;for(let kr of Cr)Ur.set(kr,Pr),Pr+=kr.length;Mr(Ur.buffer)}else{Cr.push(Gr),Dr+=Gr.length,Module.dataFileDownloads[gr]={loaded:Dr,total:Ir};let Ur=0,Pr=0;for(let kr of Object.values(Module.dataFileDownloads))Ur+=kr.loaded,Pr+=kr.total;return Module.setStatus?.(`Downloading data... (${Ur}/${Pr})`),vr()}};return Module.setStatus?.("Downloading data..."),vr()})}function hr(gr){console.error("package error:",gr)}var fr=null,_r=Module.getPreloadedPackage?Module.getPreloadedPackage(lr,dr):null;_r||mr(lr,dr,gr=>{fr?(fr(gr),fr=null):_r=gr},hr);function wr(gr){function xr(vr,Cr){if(!vr)throw Cr+new Error().stack}gr.FS_createPath("/","home",!0,!0),gr.FS_createPath("/home","web_user",!0,!0),gr.FS_createPath("/","tmp",!0,!0),gr.FS_createPath("/tmp","pglite",!0,!0),gr.FS_createPath("/tmp/pglite","bin",!0,!0),gr.FS_createPath("/tmp/pglite","lib",!0,!0),gr.FS_createPath("/tmp/pglite/lib","postgresql",!0,!0),gr.FS_createPath("/tmp/pglite/lib/postgresql","pgxs",!0,!0),gr.FS_createPath("/tmp/pglite/lib/postgresql/pgxs","config",!0,!0),gr.FS_createPath("/tmp/pglite/lib/postgresql/pgxs","src",!0,!0),gr.FS_createPath("/tmp/pglite/lib/postgresql/pgxs/src","makefiles",!0,!0),gr.FS_createPath("/tmp/pglite/lib/postgresql/pgxs/src","test",!0,!0),gr.FS_createPath("/tmp/pglite/lib/postgresql/pgxs/src/test","isolation",!0,!0),gr.FS_createPath("/tmp/pglite/lib/postgresql/pgxs/src/test","regress",!0,!0),gr.FS_createPath("/tmp/pglite","share",!0,!0),gr.FS_createPath("/tmp/pglite/share","postgresql",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql","extension",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql","timezone",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Africa",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","America",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone/America","Argentina",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone/America","Indiana",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone/America","Kentucky",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone/America","North_Dakota",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Antarctica",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Arctic",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Asia",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Atlantic",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Australia",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Brazil",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Canada",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Chile",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Etc",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Europe",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Indian",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Mexico",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","Pacific",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql/timezone","US",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql","timezonesets",!0,!0),gr.FS_createPath("/tmp/pglite/share/postgresql","tsearch_data",!0,!0);function Mr(vr,Cr,Ar){this.start=vr,this.end=Cr,this.audio=Ar}Mr.prototype={requests:{},open:function(vr,Cr){this.name=Cr,this.requests[Cr]=this,gr.addRunDependency(`fp ${this.name}`)},send:function(){},onload:function(){var vr=this.byteArray.subarray(this.start,this.end);this.finish(vr)},finish:function(vr){var Cr=this;gr.FS_createDataFile(this.name,null,vr,!0,!0,!0),gr.removeRunDependency(`fp ${Cr.name}`),this.requests[this.name]=null}};for(var Sr=tr.files,yr=0;yr<Sr.length;++yr)new Mr(Sr[yr].start,Sr[yr].end,Sr[yr].audio||0).open("GET",Sr[yr].filename);function br(vr){xr(vr,"Loading data file failed."),xr(vr.constructor.name===ArrayBuffer.name,"bad input to processPackageData");var Cr=new Uint8Array(vr);Mr.prototype.byteArray=Cr;for(var Ar=tr.files,Ir=0;Ir<Ar.length;++Ir)Mr.prototype.requests[Ar[Ir].filename].onload();gr.removeRunDependency("datafile_postgres.data")}gr.addRunDependency("datafile_postgres.data"),gr.preloadResults??(gr.preloadResults={}),gr.preloadResults[rr]={fromCache:!1},_r?(br(_r),_r=null):fr=br}Module.calledRun?wr(Module):(Module.preRun??(Module.preRun=[])).push(wr)}B({files:[{filename:"/home/web_user/.pgpass",start:0,end:204},{filename:"/tmp/pglite/bin/initdb",start:204,end:216},{filename:"/tmp/pglite/bin/postgres",start:216,end:228},{filename:"/tmp/pglite/lib/postgresql/cyrillic_and_mic.so",start:228,end:20397},{filename:"/tmp/pglite/lib/postgresql/dict_snowball.so",start:20397,end:1581299},{filename:"/tmp/pglite/lib/postgresql/euc2004_sjis2004.so",start:1581299,end:1592382},{filename:"/tmp/pglite/lib/postgresql/euc_cn_and_mic.so",start:1592382,end:1599256},{filename:"/tmp/pglite/lib/postgresql/euc_jp_and_sjis.so",start:1599256,end:1622931},{filename:"/tmp/pglite/lib/postgresql/euc_kr_and_mic.so",start:1622931,end:1630057},{filename:"/tmp/pglite/lib/postgresql/euc_tw_and_big5.so",start:1630057,end:1651566},{filename:"/tmp/pglite/lib/postgresql/latin2_and_win1250.so",start:1651566,end:1660345},{filename:"/tmp/pglite/lib/postgresql/latin_and_mic.so",start:1660345,end:1668272},{filename:"/tmp/pglite/lib/postgresql/libpqwalreceiver.so",start:1668272,end:2186522},{filename:"/tmp/pglite/lib/postgresql/pgoutput.so",start:2186522,end:2303364},{filename:"/tmp/pglite/lib/postgresql/pgxs/config/install-sh",start:2303364,end:2317361},{filename:"/tmp/pglite/lib/postgresql/pgxs/config/missing",start:2317361,end:2318709},{filename:"/tmp/pglite/lib/postgresql/pgxs/src/Makefile.global",start:2318709,end:2354956},{filename:"/tmp/pglite/lib/postgresql/pgxs/src/Makefile.port",start:2354956,end:2355232},{filename:"/tmp/pglite/lib/postgresql/pgxs/src/Makefile.shlib",start:2355232,end:2371270},{filename:"/tmp/pglite/lib/postgresql/pgxs/src/makefiles/pgxs.mk",start:2371270,end:2386198},{filename:"/tmp/pglite/lib/postgresql/pgxs/src/nls-global.mk",start:2386198,end:2393083},{filename:"/tmp/pglite/lib/postgresql/pgxs/src/test/isolation/isolationtester.cjs",start:2393083,end:2589770},{filename:"/tmp/pglite/lib/postgresql/pgxs/src/test/isolation/pg_isolation_regress.cjs",start:2589770,end:2742128},{filename:"/tmp/pglite/lib/postgresql/pgxs/src/test/regress/pg_regress.cjs",start:2742128,end:2894476},{filename:"/tmp/pglite/lib/postgresql/plpgsql.so",start:2894476,end:3653241},{filename:"/tmp/pglite/password",start:3653241,end:3653250},{filename:"/tmp/pglite/share/postgresql/errcodes.txt",start:3653250,end:3686708},{filename:"/tmp/pglite/share/postgresql/extension/plpgsql--1.0.sql",start:3686708,end:3687366},{filename:"/tmp/pglite/share/postgresql/extension/plpgsql.control",start:3687366,end:3687559},{filename:"/tmp/pglite/share/postgresql/fix-CVE-2024-4317.sql",start:3687559,end:3693324},{filename:"/tmp/pglite/share/postgresql/information_schema.sql",start:3693324,end:3808299},{filename:"/tmp/pglite/share/postgresql/pg_hba.conf.sample",start:3808299,end:3813924},{filename:"/tmp/pglite/share/postgresql/pg_ident.conf.sample",start:3813924,end:3816564},{filename:"/tmp/pglite/share/postgresql/pg_service.conf.sample",start:3816564,end:3817168},{filename:"/tmp/pglite/share/postgresql/postgres.bki",start:3817168,end:4761272},{filename:"/tmp/pglite/share/postgresql/postgresql.conf.sample",start:4761272,end:4790919},{filename:"/tmp/pglite/share/postgresql/psqlrc.sample",start:4790919,end:4791197},{filename:"/tmp/pglite/share/postgresql/snowball_create.sql",start:4791197,end:4835373},{filename:"/tmp/pglite/share/postgresql/sql_features.txt",start:4835373,end:4871054},{filename:"/tmp/pglite/share/postgresql/system_constraints.sql",start:4871054,end:4879949},{filename:"/tmp/pglite/share/postgresql/system_functions.sql",start:4879949,end:4903264},{filename:"/tmp/pglite/share/postgresql/system_views.sql",start:4903264,end:4953537},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Abidjan",start:4953537,end:4953667},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Accra",start:4953667,end:4953797},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Addis_Ababa",start:4953797,end:4953988},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Algiers",start:4953988,end:4954458},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Asmara",start:4954458,end:4954649},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Asmera",start:4954649,end:4954840},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Bamako",start:4954840,end:4954970},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Bangui",start:4954970,end:4955150},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Banjul",start:4955150,end:4955280},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Bissau",start:4955280,end:4955429},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Blantyre",start:4955429,end:4955560},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Brazzaville",start:4955560,end:4955740},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Bujumbura",start:4955740,end:4955871},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Cairo",start:4955871,end:4957180},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Casablanca",start:4957180,end:4959099},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Ceuta",start:4959099,end:4959661},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Conakry",start:4959661,end:4959791},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Dakar",start:4959791,end:4959921},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Dar_es_Salaam",start:4959921,end:4960112},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Djibouti",start:4960112,end:4960303},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Douala",start:4960303,end:4960483},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/El_Aaiun",start:4960483,end:4962313},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Freetown",start:4962313,end:4962443},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Gaborone",start:4962443,end:4962574},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Harare",start:4962574,end:4962705},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Johannesburg",start:4962705,end:4962895},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Juba",start:4962895,end:4963353},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Kampala",start:4963353,end:4963544},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Khartoum",start:4963544,end:4964002},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Kigali",start:4964002,end:4964133},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Kinshasa",start:4964133,end:4964313},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Lagos",start:4964313,end:4964493},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Libreville",start:4964493,end:4964673},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Lome",start:4964673,end:4964803},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Luanda",start:4964803,end:4964983},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Lubumbashi",start:4964983,end:4965114},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Lusaka",start:4965114,end:4965245},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Malabo",start:4965245,end:4965425},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Maputo",start:4965425,end:4965556},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Maseru",start:4965556,end:4965746},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Mbabane",start:4965746,end:4965936},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Mogadishu",start:4965936,end:4966127},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Monrovia",start:4966127,end:4966291},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Nairobi",start:4966291,end:4966482},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Ndjamena",start:4966482,end:4966642},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Niamey",start:4966642,end:4966822},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Nouakchott",start:4966822,end:4966952},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Ouagadougou",start:4966952,end:4967082},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Porto-Novo",start:4967082,end:4967262},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Sao_Tome",start:4967262,end:4967435},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Timbuktu",start:4967435,end:4967565},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Tripoli",start:4967565,end:4967996},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Tunis",start:4967996,end:4968445},{filename:"/tmp/pglite/share/postgresql/timezone/Africa/Windhoek",start:4968445,end:4969083},{filename:"/tmp/pglite/share/postgresql/timezone/America/Adak",start:4969083,end:4970052},{filename:"/tmp/pglite/share/postgresql/timezone/America/Anchorage",start:4970052,end:4971029},{filename:"/tmp/pglite/share/postgresql/timezone/America/Anguilla",start:4971029,end:4971206},{filename:"/tmp/pglite/share/postgresql/timezone/America/Antigua",start:4971206,end:4971383},{filename:"/tmp/pglite/share/postgresql/timezone/America/Araguaina",start:4971383,end:4971975},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Buenos_Aires",start:4971975,end:4972683},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Catamarca",start:4972683,end:4973391},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/ComodRivadavia",start:4973391,end:4974099},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Cordoba",start:4974099,end:4974807},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Jujuy",start:4974807,end:4975497},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/La_Rioja",start:4975497,end:4976214},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Mendoza",start:4976214,end:4976922},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Rio_Gallegos",start:4976922,end:4977630},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Salta",start:4977630,end:4978320},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/San_Juan",start:4978320,end:4979037},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/San_Luis",start:4979037,end:4979754},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Tucuman",start:4979754,end:4980480},{filename:"/tmp/pglite/share/postgresql/timezone/America/Argentina/Ushuaia",start:4980480,end:4981188},{filename:"/tmp/pglite/share/postgresql/timezone/America/Aruba",start:4981188,end:4981365},{filename:"/tmp/pglite/share/postgresql/timezone/America/Asuncion",start:4981365,end:4982249},{filename:"/tmp/pglite/share/postgresql/timezone/America/Atikokan",start:4982249,end:4982398},{filename:"/tmp/pglite/share/postgresql/timezone/America/Atka",start:4982398,end:4983367},{filename:"/tmp/pglite/share/postgresql/timezone/America/Bahia",start:4983367,end:4984049},{filename:"/tmp/pglite/share/postgresql/timezone/America/Bahia_Banderas",start:4984049,end:4984777},{filename:"/tmp/pglite/share/postgresql/timezone/America/Barbados",start:4984777,end:4985055},{filename:"/tmp/pglite/share/postgresql/timezone/America/Belem",start:4985055,end:4985449},{filename:"/tmp/pglite/share/postgresql/timezone/America/Belize",start:4985449,end:4986494},{filename:"/tmp/pglite/share/postgresql/timezone/America/Blanc-Sablon",start:4986494,end:4986671},{filename:"/tmp/pglite/share/postgresql/timezone/America/Boa_Vista",start:4986671,end:4987101},{filename:"/tmp/pglite/share/postgresql/timezone/America/Bogota",start:4987101,end:4987280},{filename:"/tmp/pglite/share/postgresql/timezone/America/Boise",start:4987280,end:4988279},{filename:"/tmp/pglite/share/postgresql/timezone/America/Buenos_Aires",start:4988279,end:4988987},{filename:"/tmp/pglite/share/postgresql/timezone/America/Cambridge_Bay",start:4988987,end:4989870},{filename:"/tmp/pglite/share/postgresql/timezone/America/Campo_Grande",start:4989870,end:4990822},{filename:"/tmp/pglite/share/postgresql/timezone/America/Cancun",start:4990822,end:4991351},{filename:"/tmp/pglite/share/postgresql/timezone/America/Caracas",start:4991351,end:4991541},{filename:"/tmp/pglite/share/postgresql/timezone/America/Catamarca",start:4991541,end:4992249},{filename:"/tmp/pglite/share/postgresql/timezone/America/Cayenne",start:4992249,end:4992400},{filename:"/tmp/pglite/share/postgresql/timezone/America/Cayman",start:4992400,end:4992549},{filename:"/tmp/pglite/share/postgresql/timezone/America/Chicago",start:4992549,end:4994303},{filename:"/tmp/pglite/share/postgresql/timezone/America/Chihuahua",start:4994303,end:4994994},{filename:"/tmp/pglite/share/postgresql/timezone/America/Ciudad_Juarez",start:4994994,end:4995712},{filename:"/tmp/pglite/share/postgresql/timezone/America/Coral_Harbour",start:4995712,end:4995861},{filename:"/tmp/pglite/share/postgresql/timezone/America/Cordoba",start:4995861,end:4996569},{filename:"/tmp/pglite/share/postgresql/timezone/America/Costa_Rica",start:4996569,end:4996801},{filename:"/tmp/pglite/share/postgresql/timezone/America/Creston",start:4996801,end:4997041},{filename:"/tmp/pglite/share/postgresql/timezone/America/Cuiaba",start:4997041,end:4997975},{filename:"/tmp/pglite/share/postgresql/timezone/America/Curacao",start:4997975,end:4998152},{filename:"/tmp/pglite/share/postgresql/timezone/America/Danmarkshavn",start:4998152,end:4998599},{filename:"/tmp/pglite/share/postgresql/timezone/America/Dawson",start:4998599,end:4999628},{filename:"/tmp/pglite/share/postgresql/timezone/America/Dawson_Creek",start:4999628,end:5000311},{filename:"/tmp/pglite/share/postgresql/timezone/America/Denver",start:5000311,end:5001353},{filename:"/tmp/pglite/share/postgresql/timezone/America/Detroit",start:5001353,end:5002252},{filename:"/tmp/pglite/share/postgresql/timezone/America/Dominica",start:5002252,end:5002429},{filename:"/tmp/pglite/share/postgresql/timezone/America/Edmonton",start:5002429,end:5003399},{filename:"/tmp/pglite/share/postgresql/timezone/America/Eirunepe",start:5003399,end:5003835},{filename:"/tmp/pglite/share/postgresql/timezone/America/El_Salvador",start:5003835,end:5004011},{filename:"/tmp/pglite/share/postgresql/timezone/America/Ensenada",start:5004011,end:5005036},{filename:"/tmp/pglite/share/postgresql/timezone/America/Fort_Nelson",start:5005036,end:5006484},{filename:"/tmp/pglite/share/postgresql/timezone/America/Fort_Wayne",start:5006484,end:5007015},{filename:"/tmp/pglite/share/postgresql/timezone/America/Fortaleza",start:5007015,end:5007499},{filename:"/tmp/pglite/share/postgresql/timezone/America/Glace_Bay",start:5007499,end:5008379},{filename:"/tmp/pglite/share/postgresql/timezone/America/Godthab",start:5008379,end:5009344},{filename:"/tmp/pglite/share/postgresql/timezone/America/Goose_Bay",start:5009344,end:5010924},{filename:"/tmp/pglite/share/postgresql/timezone/America/Grand_Turk",start:5010924,end:5011777},{filename:"/tmp/pglite/share/postgresql/timezone/America/Grenada",start:5011777,end:5011954},{filename:"/tmp/pglite/share/postgresql/timezone/America/Guadeloupe",start:5011954,end:5012131},{filename:"/tmp/pglite/share/postgresql/timezone/America/Guatemala",start:5012131,end:5012343},{filename:"/tmp/pglite/share/postgresql/timezone/America/Guayaquil",start:5012343,end:5012522},{filename:"/tmp/pglite/share/postgresql/timezone/America/Guyana",start:5012522,end:5012703},{filename:"/tmp/pglite/share/postgresql/timezone/America/Halifax",start:5012703,end:5014375},{filename:"/tmp/pglite/share/postgresql/timezone/America/Havana",start:5014375,end:5015492},{filename:"/tmp/pglite/share/postgresql/timezone/America/Hermosillo",start:5015492,end:5015778},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indiana/Indianapolis",start:5015778,end:5016309},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indiana/Knox",start:5016309,end:5017325},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indiana/Marengo",start:5017325,end:5017892},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indiana/Petersburg",start:5017892,end:5018575},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indiana/Tell_City",start:5018575,end:5019097},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indiana/Vevay",start:5019097,end:5019466},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indiana/Vincennes",start:5019466,end:5020024},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indiana/Winamac",start:5020024,end:5020636},{filename:"/tmp/pglite/share/postgresql/timezone/America/Indianapolis",start:5020636,end:5021167},{filename:"/tmp/pglite/share/postgresql/timezone/America/Inuvik",start:5021167,end:5021984},{filename:"/tmp/pglite/share/postgresql/timezone/America/Iqaluit",start:5021984,end:5022839},{filename:"/tmp/pglite/share/postgresql/timezone/America/Jamaica",start:5022839,end:5023178},{filename:"/tmp/pglite/share/postgresql/timezone/America/Jujuy",start:5023178,end:5023868},{filename:"/tmp/pglite/share/postgresql/timezone/America/Juneau",start:5023868,end:5024834},{filename:"/tmp/pglite/share/postgresql/timezone/America/Kentucky/Louisville",start:5024834,end:5026076},{filename:"/tmp/pglite/share/postgresql/timezone/America/Kentucky/Monticello",start:5026076,end:5027048},{filename:"/tmp/pglite/share/postgresql/timezone/America/Knox_IN",start:5027048,end:5028064},{filename:"/tmp/pglite/share/postgresql/timezone/America/Kralendijk",start:5028064,end:5028241},{filename:"/tmp/pglite/share/postgresql/timezone/America/La_Paz",start:5028241,end:5028411},{filename:"/tmp/pglite/share/postgresql/timezone/America/Lima",start:5028411,end:5028694},{filename:"/tmp/pglite/share/postgresql/timezone/America/Los_Angeles",start:5028694,end:5029988},{filename:"/tmp/pglite/share/postgresql/timezone/America/Louisville",start:5029988,end:5031230},{filename:"/tmp/pglite/share/postgresql/timezone/America/Lower_Princes",start:5031230,end:5031407},{filename:"/tmp/pglite/share/postgresql/timezone/America/Maceio",start:5031407,end:5031909},{filename:"/tmp/pglite/share/postgresql/timezone/America/Managua",start:5031909,end:5032204},{filename:"/tmp/pglite/share/postgresql/timezone/America/Manaus",start:5032204,end:5032616},{filename:"/tmp/pglite/share/postgresql/timezone/America/Marigot",start:5032616,end:5032793},{filename:"/tmp/pglite/share/postgresql/timezone/America/Martinique",start:5032793,end:5032971},{filename:"/tmp/pglite/share/postgresql/timezone/America/Matamoros",start:5032971,end:5033408},{filename:"/tmp/pglite/share/postgresql/timezone/America/Mazatlan",start:5033408,end:5034126},{filename:"/tmp/pglite/share/postgresql/timezone/America/Mendoza",start:5034126,end:5034834},{filename:"/tmp/pglite/share/postgresql/timezone/America/Menominee",start:5034834,end:5035751},{filename:"/tmp/pglite/share/postgresql/timezone/America/Merida",start:5035751,end:5036405},{filename:"/tmp/pglite/share/postgresql/timezone/America/Metlakatla",start:5036405,end:5037e3},{filename:"/tmp/pglite/share/postgresql/timezone/America/Mexico_City",start:5037e3,end:5037773},{filename:"/tmp/pglite/share/postgresql/timezone/America/Miquelon",start:5037773,end:5038323},{filename:"/tmp/pglite/share/postgresql/timezone/America/Moncton",start:5038323,end:5039816},{filename:"/tmp/pglite/share/postgresql/timezone/America/Monterrey",start:5039816,end:5040460},{filename:"/tmp/pglite/share/postgresql/timezone/America/Montevideo",start:5040460,end:5041429},{filename:"/tmp/pglite/share/postgresql/timezone/America/Montreal",start:5041429,end:5043146},{filename:"/tmp/pglite/share/postgresql/timezone/America/Montserrat",start:5043146,end:5043323},{filename:"/tmp/pglite/share/postgresql/timezone/America/Nassau",start:5043323,end:5045040},{filename:"/tmp/pglite/share/postgresql/timezone/America/New_York",start:5045040,end:5046784},{filename:"/tmp/pglite/share/postgresql/timezone/America/Nipigon",start:5046784,end:5048501},{filename:"/tmp/pglite/share/postgresql/timezone/America/Nome",start:5048501,end:5049476},{filename:"/tmp/pglite/share/postgresql/timezone/America/Noronha",start:5049476,end:5049960},{filename:"/tmp/pglite/share/postgresql/timezone/America/North_Dakota/Beulah",start:5049960,end:5051003},{filename:"/tmp/pglite/share/postgresql/timezone/America/North_Dakota/Center",start:5051003,end:5051993},{filename:"/tmp/pglite/share/postgresql/timezone/America/North_Dakota/New_Salem",start:5051993,end:5052983},{filename:"/tmp/pglite/share/postgresql/timezone/America/Nuuk",start:5052983,end:5053948},{filename:"/tmp/pglite/share/postgresql/timezone/America/Ojinaga",start:5053948,end:5054657},{filename:"/tmp/pglite/share/postgresql/timezone/America/Panama",start:5054657,end:5054806},{filename:"/tmp/pglite/share/postgresql/timezone/America/Pangnirtung",start:5054806,end:5055661},{filename:"/tmp/pglite/share/postgresql/timezone/America/Paramaribo",start:5055661,end:5055848},{filename:"/tmp/pglite/share/postgresql/timezone/America/Phoenix",start:5055848,end:5056088},{filename:"/tmp/pglite/share/postgresql/timezone/America/Port-au-Prince",start:5056088,end:5056653},{filename:"/tmp/pglite/share/postgresql/timezone/America/Port_of_Spain",start:5056653,end:5056830},{filename:"/tmp/pglite/share/postgresql/timezone/America/Porto_Acre",start:5056830,end:5057248},{filename:"/tmp/pglite/share/postgresql/timezone/America/Porto_Velho",start:5057248,end:5057642},{filename:"/tmp/pglite/share/postgresql/timezone/America/Puerto_Rico",start:5057642,end:5057819},{filename:"/tmp/pglite/share/postgresql/timezone/America/Punta_Arenas",start:5057819,end:5059037},{filename:"/tmp/pglite/share/postgresql/timezone/America/Rainy_River",start:5059037,end:5060331},{filename:"/tmp/pglite/share/postgresql/timezone/America/Rankin_Inlet",start:5060331,end:5061138},{filename:"/tmp/pglite/share/postgresql/timezone/America/Recife",start:5061138,end:5061622},{filename:"/tmp/pglite/share/postgresql/timezone/America/Regina",start:5061622,end:5062260},{filename:"/tmp/pglite/share/postgresql/timezone/America/Resolute",start:5062260,end:5063067},{filename:"/tmp/pglite/share/postgresql/timezone/America/Rio_Branco",start:5063067,end:5063485},{filename:"/tmp/pglite/share/postgresql/timezone/America/Rosario",start:5063485,end:5064193},{filename:"/tmp/pglite/share/postgresql/timezone/America/Santa_Isabel",start:5064193,end:5065218},{filename:"/tmp/pglite/share/postgresql/timezone/America/Santarem",start:5065218,end:5065627},{filename:"/tmp/pglite/share/postgresql/timezone/America/Santiago",start:5065627,end:5066981},{filename:"/tmp/pglite/share/postgresql/timezone/America/Santo_Domingo",start:5066981,end:5067298},{filename:"/tmp/pglite/share/postgresql/timezone/America/Sao_Paulo",start:5067298,end:5068250},{filename:"/tmp/pglite/share/postgresql/timezone/America/Scoresbysund",start:5068250,end:5069234},{filename:"/tmp/pglite/share/postgresql/timezone/America/Shiprock",start:5069234,end:5070276},{filename:"/tmp/pglite/share/postgresql/timezone/America/Sitka",start:5070276,end:5071232},{filename:"/tmp/pglite/share/postgresql/timezone/America/St_Barthelemy",start:5071232,end:5071409},{filename:"/tmp/pglite/share/postgresql/timezone/America/St_Johns",start:5071409,end:5073287},{filename:"/tmp/pglite/share/postgresql/timezone/America/St_Kitts",start:5073287,end:5073464},{filename:"/tmp/pglite/share/postgresql/timezone/America/St_Lucia",start:5073464,end:5073641},{filename:"/tmp/pglite/share/postgresql/timezone/America/St_Thomas",start:5073641,end:5073818},{filename:"/tmp/pglite/share/postgresql/timezone/America/St_Vincent",start:5073818,end:5073995},{filename:"/tmp/pglite/share/postgresql/timezone/America/Swift_Current",start:5073995,end:5074363},{filename:"/tmp/pglite/share/postgresql/timezone/America/Tegucigalpa",start:5074363,end:5074557},{filename:"/tmp/pglite/share/postgresql/timezone/America/Thule",start:5074557,end:5075012},{filename:"/tmp/pglite/share/postgresql/timezone/America/Thunder_Bay",start:5075012,end:5076729},{filename:"/tmp/pglite/share/postgresql/timezone/America/Tijuana",start:5076729,end:5077754},{filename:"/tmp/pglite/share/postgresql/timezone/America/Toronto",start:5077754,end:5079471},{filename:"/tmp/pglite/share/postgresql/timezone/America/Tortola",start:5079471,end:5079648},{filename:"/tmp/pglite/share/postgresql/timezone/America/Vancouver",start:5079648,end:5080978},{filename:"/tmp/pglite/share/postgresql/timezone/America/Virgin",start:5080978,end:5081155},{filename:"/tmp/pglite/share/postgresql/timezone/America/Whitehorse",start:5081155,end:5082184},{filename:"/tmp/pglite/share/postgresql/timezone/America/Winnipeg",start:5082184,end:5083478},{filename:"/tmp/pglite/share/postgresql/timezone/America/Yakutat",start:5083478,end:5084424},{filename:"/tmp/pglite/share/postgresql/timezone/America/Yellowknife",start:5084424,end:5085394},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Casey",start:5085394,end:5085681},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Davis",start:5085681,end:5085878},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/DumontDUrville",start:5085878,end:5086032},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Macquarie",start:5086032,end:5087008},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Mawson",start:5087008,end:5087160},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/McMurdo",start:5087160,end:5088203},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Palmer",start:5088203,end:5089090},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Rothera",start:5089090,end:5089222},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/South_Pole",start:5089222,end:5090265},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Syowa",start:5090265,end:5090398},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Troll",start:5090398,end:5090575},{filename:"/tmp/pglite/share/postgresql/timezone/Antarctica/Vostok",start:5090575,end:5090745},{filename:"/tmp/pglite/share/postgresql/timezone/Arctic/Longyearbyen",start:5090745,end:5091450},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Aden",start:5091450,end:5091583},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Almaty",start:5091583,end:5092201},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Amman",start:5092201,end:5093129},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Anadyr",start:5093129,end:5093872},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Aqtau",start:5093872,end:5094478},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Aqtobe",start:5094478,end:5095093},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Ashgabat",start:5095093,end:5095468},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Ashkhabad",start:5095468,end:5095843},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Atyrau",start:5095843,end:5096459},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Baghdad",start:5096459,end:5097089},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Bahrain",start:5097089,end:5097241},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Baku",start:5097241,end:5097985},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Bangkok",start:5097985,end:5098137},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Barnaul",start:5098137,end:5098890},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Beirut",start:5098890,end:5099622},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Bishkek",start:5099622,end:5100240},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Brunei",start:5100240,end:5100560},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Calcutta",start:5100560,end:5100780},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Chita",start:5100780,end:5101530},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Choibalsan",start:5101530,end:5102149},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Chongqing",start:5102149,end:5102542},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Chungking",start:5102542,end:5102935},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Colombo",start:5102935,end:5103182},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Dacca",start:5103182,end:5103413},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Damascus",start:5103413,end:5104647},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Dhaka",start:5104647,end:5104878},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Dili",start:5104878,end:5105048},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Dubai",start:5105048,end:5105181},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Dushanbe",start:5105181,end:5105547},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Famagusta",start:5105547,end:5106487},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Gaza",start:5106487,end:5108933},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Harbin",start:5108933,end:5109326},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Hebron",start:5109326,end:5111790},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Ho_Chi_Minh",start:5111790,end:5112026},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Hong_Kong",start:5112026,end:5112801},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Hovd",start:5112801,end:5113395},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Irkutsk",start:5113395,end:5114155},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Istanbul",start:5114155,end:5115355},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Jakarta",start:5115355,end:5115603},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Jayapura",start:5115603,end:5115774},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Jerusalem",start:5115774,end:5116848},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Kabul",start:5116848,end:5117007},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Kamchatka",start:5117007,end:5117734},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Karachi",start:5117734,end:5118e3},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Kashgar",start:5118e3,end:5118133},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Kathmandu",start:5118133,end:5118294},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Katmandu",start:5118294,end:5118455},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Khandyga",start:5118455,end:5119230},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Kolkata",start:5119230,end:5119450},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Krasnoyarsk",start:5119450,end:5120191},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Kuala_Lumpur",start:5120191,end:5120447},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Kuching",start:5120447,end:5120767},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Kuwait",start:5120767,end:5120900},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Macao",start:5120900,end:5121691},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Macau",start:5121691,end:5122482},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Magadan",start:5122482,end:5123233},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Makassar",start:5123233,end:5123423},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Manila",start:5123423,end:5123661},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Muscat",start:5123661,end:5123794},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Nicosia",start:5123794,end:5124391},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Novokuznetsk",start:5124391,end:5125117},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Novosibirsk",start:5125117,end:5125870},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Omsk",start:5125870,end:5126611},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Oral",start:5126611,end:5127236},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Phnom_Penh",start:5127236,end:5127388},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Pontianak",start:5127388,end:5127635},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Pyongyang",start:5127635,end:5127818},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Qatar",start:5127818,end:5127970},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Qostanay",start:5127970,end:5128594},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Qyzylorda",start:5128594,end:5129218},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Rangoon",start:5129218,end:5129405},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Riyadh",start:5129405,end:5129538},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Saigon",start:5129538,end:5129774},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Sakhalin",start:5129774,end:5130529},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Samarkand",start:5130529,end:5130895},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Seoul",start:5130895,end:5131310},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Shanghai",start:5131310,end:5131703},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Singapore",start:5131703,end:5131959},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Srednekolymsk",start:5131959,end:5132701},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Taipei",start:5132701,end:5133212},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Tashkent",start:5133212,end:5133578},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Tbilisi",start:5133578,end:5134207},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Tehran",start:5134207,end:5135019},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Tel_Aviv",start:5135019,end:5136093},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Thimbu",start:5136093,end:5136247},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Thimphu",start:5136247,end:5136401},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Tokyo",start:5136401,end:5136614},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Tomsk",start:5136614,end:5137367},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Ujung_Pandang",start:5137367,end:5137557},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Ulaanbaatar",start:5137557,end:5138151},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Ulan_Bator",start:5138151,end:5138745},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Urumqi",start:5138745,end:5138878},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Ust-Nera",start:5138878,end:5139649},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Vientiane",start:5139649,end:5139801},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Vladivostok",start:5139801,end:5140543},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Yakutsk",start:5140543,end:5141284},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Yangon",start:5141284,end:5141471},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Yekaterinburg",start:5141471,end:5142231},{filename:"/tmp/pglite/share/postgresql/timezone/Asia/Yerevan",start:5142231,end:5142939},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Azores",start:5142939,end:5144392},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Bermuda",start:5144392,end:5145416},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Canary",start:5145416,end:5145894},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Cape_Verde",start:5145894,end:5146069},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Faeroe",start:5146069,end:5146510},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Faroe",start:5146510,end:5146951},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Jan_Mayen",start:5146951,end:5147656},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Madeira",start:5147656,end:5149109},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Reykjavik",start:5149109,end:5149239},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/South_Georgia",start:5149239,end:5149371},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/St_Helena",start:5149371,end:5149501},{filename:"/tmp/pglite/share/postgresql/timezone/Atlantic/Stanley",start:5149501,end:5150290},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/ACT",start:5150290,end:5151194},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Adelaide",start:5151194,end:5152115},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Brisbane",start:5152115,end:5152404},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Broken_Hill",start:5152404,end:5153345},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Canberra",start:5153345,end:5154249},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Currie",start:5154249,end:5155252},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Darwin",start:5155252,end:5155486},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Eucla",start:5155486,end:5155800},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Hobart",start:5155800,end:5156803},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/LHI",start:5156803,end:5157495},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Lindeman",start:5157495,end:5157820},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Lord_Howe",start:5157820,end:5158512},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Melbourne",start:5158512,end:5159416},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/NSW",start:5159416,end:5160320},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/North",start:5160320,end:5160554},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Perth",start:5160554,end:5160860},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Queensland",start:5160860,end:5161149},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/South",start:5161149,end:5162070},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Sydney",start:5162070,end:5162974},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Tasmania",start:5162974,end:5163977},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Victoria",start:5163977,end:5164881},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/West",start:5164881,end:5165187},{filename:"/tmp/pglite/share/postgresql/timezone/Australia/Yancowinna",start:5165187,end:5166128},{filename:"/tmp/pglite/share/postgresql/timezone/Brazil/Acre",start:5166128,end:5166546},{filename:"/tmp/pglite/share/postgresql/timezone/Brazil/DeNoronha",start:5166546,end:5167030},{filename:"/tmp/pglite/share/postgresql/timezone/Brazil/East",start:5167030,end:5167982},{filename:"/tmp/pglite/share/postgresql/timezone/Brazil/West",start:5167982,end:5168394},{filename:"/tmp/pglite/share/postgresql/timezone/CET",start:5168394,end:5169015},{filename:"/tmp/pglite/share/postgresql/timezone/CST6CDT",start:5169015,end:5169966},{filename:"/tmp/pglite/share/postgresql/timezone/Canada/Atlantic",start:5169966,end:5171638},{filename:"/tmp/pglite/share/postgresql/timezone/Canada/Central",start:5171638,end:5172932},{filename:"/tmp/pglite/share/postgresql/timezone/Canada/Eastern",start:5172932,end:5174649},{filename:"/tmp/pglite/share/postgresql/timezone/Canada/Mountain",start:5174649,end:5175619},{filename:"/tmp/pglite/share/postgresql/timezone/Canada/Newfoundland",start:5175619,end:5177497},{filename:"/tmp/pglite/share/postgresql/timezone/Canada/Pacific",start:5177497,end:5178827},{filename:"/tmp/pglite/share/postgresql/timezone/Canada/Saskatchewan",start:5178827,end:5179465},{filename:"/tmp/pglite/share/postgresql/timezone/Canada/Yukon",start:5179465,end:5180494},{filename:"/tmp/pglite/share/postgresql/timezone/Chile/Continental",start:5180494,end:5181848},{filename:"/tmp/pglite/share/postgresql/timezone/Chile/EasterIsland",start:5181848,end:5183022},{filename:"/tmp/pglite/share/postgresql/timezone/Cuba",start:5183022,end:5184139},{filename:"/tmp/pglite/share/postgresql/timezone/EET",start:5184139,end:5184636},{filename:"/tmp/pglite/share/postgresql/timezone/EST",start:5184636,end:5184747},{filename:"/tmp/pglite/share/postgresql/timezone/EST5EDT",start:5184747,end:5185698},{filename:"/tmp/pglite/share/postgresql/timezone/Egypt",start:5185698,end:5187007},{filename:"/tmp/pglite/share/postgresql/timezone/Eire",start:5187007,end:5188503},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT",start:5188503,end:5188614},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+0",start:5188614,end:5188725},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+1",start:5188725,end:5188838},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+10",start:5188838,end:5188952},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+11",start:5188952,end:5189066},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+12",start:5189066,end:5189180},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+2",start:5189180,end:5189293},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+3",start:5189293,end:5189406},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+4",start:5189406,end:5189519},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+5",start:5189519,end:5189632},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+6",start:5189632,end:5189745},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+7",start:5189745,end:5189858},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+8",start:5189858,end:5189971},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT+9",start:5189971,end:5190084},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-0",start:5190084,end:5190195},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-1",start:5190195,end:5190309},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-10",start:5190309,end:5190424},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-11",start:5190424,end:5190539},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-12",start:5190539,end:5190654},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-13",start:5190654,end:5190769},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-14",start:5190769,end:5190884},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-2",start:5190884,end:5190998},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-3",start:5190998,end:5191112},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-4",start:5191112,end:5191226},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-5",start:5191226,end:5191340},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-6",start:5191340,end:5191454},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-7",start:5191454,end:5191568},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-8",start:5191568,end:5191682},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT-9",start:5191682,end:5191796},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/GMT0",start:5191796,end:5191907},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/Greenwich",start:5191907,end:5192018},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/UCT",start:5192018,end:5192129},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/UTC",start:5192129,end:5192240},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/Universal",start:5192240,end:5192351},{filename:"/tmp/pglite/share/postgresql/timezone/Etc/Zulu",start:5192351,end:5192462},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Amsterdam",start:5192462,end:5193565},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Andorra",start:5193565,end:5193954},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Astrakhan",start:5193954,end:5194680},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Athens",start:5194680,end:5195362},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Belfast",start:5195362,end:5196961},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Belgrade",start:5196961,end:5197439},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Berlin",start:5197439,end:5198144},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Bratislava",start:5198144,end:5198867},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Brussels",start:5198867,end:5199970},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Bucharest",start:5199970,end:5200631},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Budapest",start:5200631,end:5201397},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Busingen",start:5201397,end:5201894},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Chisinau",start:5201894,end:5202649},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Copenhagen",start:5202649,end:5203354},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Dublin",start:5203354,end:5204850},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Gibraltar",start:5204850,end:5206070},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Guernsey",start:5206070,end:5207669},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Helsinki",start:5207669,end:5208150},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Isle_of_Man",start:5208150,end:5209749},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Istanbul",start:5209749,end:5210949},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Jersey",start:5210949,end:5212548},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Kaliningrad",start:5212548,end:5213452},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Kiev",start:5213452,end:5214010},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Kirov",start:5214010,end:5214745},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Kyiv",start:5214745,end:5215303},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Lisbon",start:5215303,end:5216757},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Ljubljana",start:5216757,end:5217235},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/London",start:5217235,end:5218834},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Luxembourg",start:5218834,end:5219937},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Madrid",start:5219937,end:5220834},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Malta",start:5220834,end:5221762},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Mariehamn",start:5221762,end:5222243},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Minsk",start:5222243,end:5223051},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Monaco",start:5223051,end:5224156},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Moscow",start:5224156,end:5225064},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Nicosia",start:5225064,end:5225661},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Oslo",start:5225661,end:5226366},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Paris",start:5226366,end:5227471},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Podgorica",start:5227471,end:5227949},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Prague",start:5227949,end:5228672},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Riga",start:5228672,end:5229366},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Rome",start:5229366,end:5230313},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Samara",start:5230313,end:5231045},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/San_Marino",start:5231045,end:5231992},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Sarajevo",start:5231992,end:5232470},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Saratov",start:5232470,end:5233196},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Simferopol",start:5233196,end:5234061},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Skopje",start:5234061,end:5234539},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Sofia",start:5234539,end:5235131},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Stockholm",start:5235131,end:5235836},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Tallinn",start:5235836,end:5236511},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Tirane",start:5236511,end:5237115},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Tiraspol",start:5237115,end:5237870},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Ulyanovsk",start:5237870,end:5238630},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Uzhgorod",start:5238630,end:5239188},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Vaduz",start:5239188,end:5239685},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Vatican",start:5239685,end:5240632},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Vienna",start:5240632,end:5241290},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Vilnius",start:5241290,end:5241966},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Volgograd",start:5241966,end:5242719},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Warsaw",start:5242719,end:5243642},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Zagreb",start:5243642,end:5244120},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Zaporozhye",start:5244120,end:5244678},{filename:"/tmp/pglite/share/postgresql/timezone/Europe/Zurich",start:5244678,end:5245175},{filename:"/tmp/pglite/share/postgresql/timezone/Factory",start:5245175,end:5245288},{filename:"/tmp/pglite/share/postgresql/timezone/GB",start:5245288,end:5246887},{filename:"/tmp/pglite/share/postgresql/timezone/GB-Eire",start:5246887,end:5248486},{filename:"/tmp/pglite/share/postgresql/timezone/GMT",start:5248486,end:5248597},{filename:"/tmp/pglite/share/postgresql/timezone/GMT+0",start:5248597,end:5248708},{filename:"/tmp/pglite/share/postgresql/timezone/GMT-0",start:5248708,end:5248819},{filename:"/tmp/pglite/share/postgresql/timezone/GMT0",start:5248819,end:5248930},{filename:"/tmp/pglite/share/postgresql/timezone/Greenwich",start:5248930,end:5249041},{filename:"/tmp/pglite/share/postgresql/timezone/HST",start:5249041,end:5249153},{filename:"/tmp/pglite/share/postgresql/timezone/Hongkong",start:5249153,end:5249928},{filename:"/tmp/pglite/share/postgresql/timezone/Iceland",start:5249928,end:5250058},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Antananarivo",start:5250058,end:5250249},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Chagos",start:5250249,end:5250401},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Christmas",start:5250401,end:5250553},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Cocos",start:5250553,end:5250740},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Comoro",start:5250740,end:5250931},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Kerguelen",start:5250931,end:5251083},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Mahe",start:5251083,end:5251216},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Maldives",start:5251216,end:5251368},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Mauritius",start:5251368,end:5251547},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Mayotte",start:5251547,end:5251738},{filename:"/tmp/pglite/share/postgresql/timezone/Indian/Reunion",start:5251738,end:5251871},{filename:"/tmp/pglite/share/postgresql/timezone/Iran",start:5251871,end:5252683},{filename:"/tmp/pglite/share/postgresql/timezone/Israel",start:5252683,end:5253757},{filename:"/tmp/pglite/share/postgresql/timezone/Jamaica",start:5253757,end:5254096},{filename:"/tmp/pglite/share/postgresql/timezone/Japan",start:5254096,end:5254309},{filename:"/tmp/pglite/share/postgresql/timezone/Kwajalein",start:5254309,end:5254528},{filename:"/tmp/pglite/share/postgresql/timezone/Libya",start:5254528,end:5254959},{filename:"/tmp/pglite/share/postgresql/timezone/MET",start:5254959,end:5255580},{filename:"/tmp/pglite/share/postgresql/timezone/MST",start:5255580,end:5255691},{filename:"/tmp/pglite/share/postgresql/timezone/MST7MDT",start:5255691,end:5256642},{filename:"/tmp/pglite/share/postgresql/timezone/Mexico/BajaNorte",start:5256642,end:5257667},{filename:"/tmp/pglite/share/postgresql/timezone/Mexico/BajaSur",start:5257667,end:5258385},{filename:"/tmp/pglite/share/postgresql/timezone/Mexico/General",start:5258385,end:5259158},{filename:"/tmp/pglite/share/postgresql/timezone/NZ",start:5259158,end:5260201},{filename:"/tmp/pglite/share/postgresql/timezone/NZ-CHAT",start:5260201,end:5261009},{filename:"/tmp/pglite/share/postgresql/timezone/Navajo",start:5261009,end:5262051},{filename:"/tmp/pglite/share/postgresql/timezone/PRC",start:5262051,end:5262444},{filename:"/tmp/pglite/share/postgresql/timezone/PST8PDT",start:5262444,end:5263395},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Apia",start:5263395,end:5263802},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Auckland",start:5263802,end:5264845},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Bougainville",start:5264845,end:5265046},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Chatham",start:5265046,end:5265854},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Chuuk",start:5265854,end:5266008},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Easter",start:5266008,end:5267182},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Efate",start:5267182,end:5267524},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Enderbury",start:5267524,end:5267696},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Fakaofo",start:5267696,end:5267849},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Fiji",start:5267849,end:5268245},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Funafuti",start:5268245,end:5268379},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Galapagos",start:5268379,end:5268554},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Gambier",start:5268554,end:5268686},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Guadalcanal",start:5268686,end:5268820},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Guam",start:5268820,end:5269170},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Honolulu",start:5269170,end:5269391},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Johnston",start:5269391,end:5269612},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Kanton",start:5269612,end:5269784},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Kiritimati",start:5269784,end:5269958},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Kosrae",start:5269958,end:5270200},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Kwajalein",start:5270200,end:5270419},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Majuro",start:5270419,end:5270553},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Marquesas",start:5270553,end:5270692},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Midway",start:5270692,end:5270838},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Nauru",start:5270838,end:5271021},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Niue",start:5271021,end:5271175},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Norfolk",start:5271175,end:5271422},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Noumea",start:5271422,end:5271620},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Pago_Pago",start:5271620,end:5271766},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Palau",start:5271766,end:5271914},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Pitcairn",start:5271914,end:5272067},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Pohnpei",start:5272067,end:5272201},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Ponape",start:5272201,end:5272335},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Port_Moresby",start:5272335,end:5272489},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Rarotonga",start:5272489,end:5272895},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Saipan",start:5272895,end:5273245},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Samoa",start:5273245,end:5273391},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Tahiti",start:5273391,end:5273524},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Tarawa",start:5273524,end:5273658},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Tongatapu",start:5273658,end:5273895},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Truk",start:5273895,end:5274049},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Wake",start:5274049,end:5274183},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Wallis",start:5274183,end:5274317},{filename:"/tmp/pglite/share/postgresql/timezone/Pacific/Yap",start:5274317,end:5274471},{filename:"/tmp/pglite/share/postgresql/timezone/Poland",start:5274471,end:5275394},{filename:"/tmp/pglite/share/postgresql/timezone/Portugal",start:5275394,end:5276848},{filename:"/tmp/pglite/share/postgresql/timezone/ROC",start:5276848,end:5277359},{filename:"/tmp/pglite/share/postgresql/timezone/ROK",start:5277359,end:5277774},{filename:"/tmp/pglite/share/postgresql/timezone/Singapore",start:5277774,end:5278030},{filename:"/tmp/pglite/share/postgresql/timezone/Turkey",start:5278030,end:5279230},{filename:"/tmp/pglite/share/postgresql/timezone/UCT",start:5279230,end:5279341},{filename:"/tmp/pglite/share/postgresql/timezone/US/Alaska",start:5279341,end:5280318},{filename:"/tmp/pglite/share/postgresql/timezone/US/Aleutian",start:5280318,end:5281287},{filename:"/tmp/pglite/share/postgresql/timezone/US/Arizona",start:5281287,end:5281527},{filename:"/tmp/pglite/share/postgresql/timezone/US/Central",start:5281527,end:5283281},{filename:"/tmp/pglite/share/postgresql/timezone/US/East-Indiana",start:5283281,end:5283812},{filename:"/tmp/pglite/share/postgresql/timezone/US/Eastern",start:5283812,end:5285556},{filename:"/tmp/pglite/share/postgresql/timezone/US/Hawaii",start:5285556,end:5285777},{filename:"/tmp/pglite/share/postgresql/timezone/US/Indiana-Starke",start:5285777,end:5286793},{filename:"/tmp/pglite/share/postgresql/timezone/US/Michigan",start:5286793,end:5287692},{filename:"/tmp/pglite/share/postgresql/timezone/US/Mountain",start:5287692,end:5288734},{filename:"/tmp/pglite/share/postgresql/timezone/US/Pacific",start:5288734,end:5290028},{filename:"/tmp/pglite/share/postgresql/timezone/US/Samoa",start:5290028,end:5290174},{filename:"/tmp/pglite/share/postgresql/timezone/UTC",start:5290174,end:5290285},{filename:"/tmp/pglite/share/postgresql/timezone/Universal",start:5290285,end:5290396},{filename:"/tmp/pglite/share/postgresql/timezone/W-SU",start:5290396,end:5291304},{filename:"/tmp/pglite/share/postgresql/timezone/WET",start:5291304,end:5291798},{filename:"/tmp/pglite/share/postgresql/timezone/Zulu",start:5291798,end:5291909},{filename:"/tmp/pglite/share/postgresql/timezonesets/Africa.txt",start:5291909,end:5298882},{filename:"/tmp/pglite/share/postgresql/timezonesets/America.txt",start:5298882,end:5309889},{filename:"/tmp/pglite/share/postgresql/timezonesets/Antarctica.txt",start:5309889,end:5311023},{filename:"/tmp/pglite/share/postgresql/timezonesets/Asia.txt",start:5311023,end:5319334},{filename:"/tmp/pglite/share/postgresql/timezonesets/Atlantic.txt",start:5319334,end:5322867},{filename:"/tmp/pglite/share/postgresql/timezonesets/Australia",start:5322867,end:5324002},{filename:"/tmp/pglite/share/postgresql/timezonesets/Australia.txt",start:5324002,end:5327386},{filename:"/tmp/pglite/share/postgresql/timezonesets/Default",start:5327386,end:5354636},{filename:"/tmp/pglite/share/postgresql/timezonesets/Etc.txt",start:5354636,end:5355886},{filename:"/tmp/pglite/share/postgresql/timezonesets/Europe.txt",start:5355886,end:5364668},{filename:"/tmp/pglite/share/postgresql/timezonesets/India",start:5364668,end:5365261},{filename:"/tmp/pglite/share/postgresql/timezonesets/Indian.txt",start:5365261,end:5366522},{filename:"/tmp/pglite/share/postgresql/timezonesets/Pacific.txt",start:5366522,end:5370290},{filename:"/tmp/pglite/share/postgresql/tsearch_data/danish.stop",start:5370290,end:5370714},{filename:"/tmp/pglite/share/postgresql/tsearch_data/dutch.stop",start:5370714,end:5371167},{filename:"/tmp/pglite/share/postgresql/tsearch_data/english.stop",start:5371167,end:5371789},{filename:"/tmp/pglite/share/postgresql/tsearch_data/finnish.stop",start:5371789,end:5373368},{filename:"/tmp/pglite/share/postgresql/tsearch_data/french.stop",start:5373368,end:5374173},{filename:"/tmp/pglite/share/postgresql/tsearch_data/german.stop",start:5374173,end:5375522},{filename:"/tmp/pglite/share/postgresql/tsearch_data/hungarian.stop",start:5375522,end:5376749},{filename:"/tmp/pglite/share/postgresql/tsearch_data/hunspell_sample.affix",start:5376749,end:5376992},{filename:"/tmp/pglite/share/postgresql/tsearch_data/hunspell_sample_long.affix",start:5376992,end:5377625},{filename:"/tmp/pglite/share/postgresql/tsearch_data/hunspell_sample_long.dict",start:5377625,end:5377723},{filename:"/tmp/pglite/share/postgresql/tsearch_data/hunspell_sample_num.affix",start:5377723,end:5378185},{filename:"/tmp/pglite/share/postgresql/tsearch_data/hunspell_sample_num.dict",start:5378185,end:5378314},{filename:"/tmp/pglite/share/postgresql/tsearch_data/ispell_sample.affix",start:5378314,end:5378779},{filename:"/tmp/pglite/share/postgresql/tsearch_data/ispell_sample.dict",start:5378779,end:5378860},{filename:"/tmp/pglite/share/postgresql/tsearch_data/italian.stop",start:5378860,end:5380514},{filename:"/tmp/pglite/share/postgresql/tsearch_data/nepali.stop",start:5380514,end:5384775},{filename:"/tmp/pglite/share/postgresql/tsearch_data/norwegian.stop",start:5384775,end:5385626},{filename:"/tmp/pglite/share/postgresql/tsearch_data/portuguese.stop",start:5385626,end:5386893},{filename:"/tmp/pglite/share/postgresql/tsearch_data/russian.stop",start:5386893,end:5388128},{filename:"/tmp/pglite/share/postgresql/tsearch_data/spanish.stop",start:5388128,end:5390306},{filename:"/tmp/pglite/share/postgresql/tsearch_data/swedish.stop",start:5390306,end:5390865},{filename:"/tmp/pglite/share/postgresql/tsearch_data/synonym_sample.syn",start:5390865,end:5390938},{filename:"/tmp/pglite/share/postgresql/tsearch_data/thesaurus_sample.ths",start:5390938,end:5391411},{filename:"/tmp/pglite/share/postgresql/tsearch_data/turkish.stop",start:5391411,end:5391671},{filename:"/tmp/pglite/share/postgresql/tsearch_data/unaccent.rules",start:5391671,end:5401610},{filename:"/tmp/pglite/share/postgresql/tsearch_data/xsyn_sample.rules",start:5401610,end:5401749}],remote_package_size:5401749})})();var moduleOverrides=Object.assign({},Module),arguments_=[],thisProgram="./this.program",quit_=(t,e)=>{throw e},scriptDirectory="";function locateFile(t){return Module.locateFile?Module.locateFile(t,scriptDirectory):scriptDirectory+t}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs"),nodePath=require("path");import.meta.url.startsWith("data:")||(scriptDirectory=nodePath.dirname(require("url").fileURLToPath(import.meta.url))+"/"),readBinary=t=>{t=isFileURI(t)?new URL(t):t;var e=fs.readFileSync(t);return e},readAsync=async(t,e=!0)=>{t=isFileURI(t)?new URL(t):t;var I=fs.readFileSync(t,e?void 0:"utf8");return I},!Module.thisProgram&&process$1.argv.length>1&&(thisProgram=process$1.argv[1].replace(/\\/g,"/")),arguments_=process$1.argv.slice(2),quit_=(t,e)=>{throw process$1.exitCode=t,e}}else(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&(ENVIRONMENT_IS_WORKER?scriptDirectory=self.location.href:typeof document<"u"&&document.currentScript&&(scriptDirectory=document.currentScript.src),_scriptName&&(scriptDirectory=_scriptName),scriptDirectory.startsWith("blob:")?scriptDirectory="":scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1),readAsync=async t=>{var e=await fetch(t,{credentials:"same-origin"});if(e.ok)return e.arrayBuffer();throw new Error(e.status+" : "+e.url)});var out=Module.print||console.log.bind(console),err=Module.printErr||console.error.bind(console);Object.assign(Module,moduleOverrides),moduleOverrides=null,Module.arguments&&(arguments_=Module.arguments),Module.thisProgram&&(thisProgram=Module.thisProgram);var dynamicLibraries=Module.dynamicLibraries||[],wasmBinary=Module.wasmBinary,wasmMemory,ABORT=!1,EXITSTATUS;function assert(t,e){t||abort(e)}var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAP64,HEAPF64;function updateMemoryViews(){var t=wasmMemory.buffer;Module.HEAP8=HEAP8=new Int8Array(t),Module.HEAP16=HEAP16=new Int16Array(t),Module.HEAPU8=HEAPU8=new Uint8Array(t),Module.HEAPU16=HEAPU16=new Uint16Array(t),Module.HEAP32=HEAP32=new Int32Array(t),Module.HEAPU32=HEAPU32=new Uint32Array(t),Module.HEAPF32=HEAPF32=new Float32Array(t),Module.HEAPF64=HEAPF64=new Float64Array(t),Module.HEAP64=HEAP64=new BigInt64Array(t),Module.HEAPU64=new BigUint64Array(t)}if(Module.wasmMemory)wasmMemory=Module.wasmMemory;else{var INITIAL_MEMORY=Module.INITIAL_MEMORY||134217728;wasmMemory=new WebAssembly.Memory({initial:INITIAL_MEMORY/65536,maximum:32768})}updateMemoryViews();var __ATPRERUN__=[],__ATINIT__=[],__ATMAIN__=[],__ATPOSTRUN__=[],__RELOC_FUNCS__=[],runtimeInitialized=!1;function preRun(){if(Module.preRun)for(typeof Module.preRun=="function"&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=!0,callRuntimeCallbacks(__RELOC_FUNCS__),!Module.noFSInit&&!FS.initialized&&FS.init(),FS.ignorePermissions=!1,SOCKFS.root=FS.mount(SOCKFS,{},null),PIPEFS.root=FS.mount(PIPEFS,{},null),callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function postRun(){if(Module.postRun)for(typeof Module.postRun=="function"&&(Module.postRun=[Module.postRun]);Module.postRun.length;)addOnPostRun(Module.postRun.shift());callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(t){__ATPRERUN__.unshift(t)}function addOnInit(t){__ATINIT__.unshift(t)}function addOnPostRun(t){__ATPOSTRUN__.unshift(t)}var runDependencies=0,dependenciesFulfilled=null;function addRunDependency(t){runDependencies++,Module.monitorRunDependencies?.(runDependencies)}function removeRunDependency(t){if(runDependencies--,Module.monitorRunDependencies?.(runDependencies),runDependencies==0&&dependenciesFulfilled){var e=dependenciesFulfilled;dependenciesFulfilled=null,e()}}function abort(t){Module.onAbort?.(t),t="Aborted("+t+")",err(t),ABORT=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw readyPromiseReject(e),e}var dataURIPrefix="data:application/octet-stream;base64,",isDataURI=t=>t.startsWith(dataURIPrefix),isFileURI=t=>t.startsWith("file://");function findWasmBinary(){if(Module.locateFile){var t="postgres.wasm";return isDataURI(t)?t:locateFile(t)}return new URL("/assets/postgres-CyuUVpXN.wasm",import.meta.url).href}var wasmBinaryFile;function getBinarySync(t){if(t==wasmBinaryFile&&wasmBinary)return new Uint8Array(wasmBinary);if(readBinary)return readBinary(t);throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(t){if(!wasmBinary)try{var e=await readAsync(t);return new Uint8Array(e)}catch{}return getBinarySync(t)}async function instantiateArrayBuffer(t,e){try{var I=await getWasmBinary(t),B=await WebAssembly.instantiate(I,e);return B}catch(tr){err(`failed to asynchronously prepare wasm: ${tr}`),abort(tr)}}async function instantiateAsync(t,e,I){if(!t&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(e)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function")try{var B=fetch(e,{credentials:"same-origin"}),tr=await WebAssembly.instantiateStreaming(B,I);return tr}catch(rr){err(`wasm streaming compile failed: ${rr}`),err("falling back to ArrayBuffer instantiation")}return instantiateArrayBuffer(e,I)}function getWasmImports(){return{env:wasmImports,wasi_snapshot_preview1:wasmImports,"GOT.mem":new Proxy(wasmImports,GOTHandler),"GOT.func":new Proxy(wasmImports,GOTHandler)}}async function createWasm(){function t(tr,rr){wasmExports=tr.exports,wasmExports=relocateExports(wasmExports,16777216);var ir=getDylinkMetadata(rr);return ir.neededDynlibs&&(dynamicLibraries=ir.neededDynlibs.concat(dynamicLibraries)),mergeLibSymbols(wasmExports),LDSO.init(),loadDylibs(),addOnInit(wasmExports.__wasm_call_ctors),__RELOC_FUNCS__.push(wasmExports.__wasm_apply_data_relocs),removeRunDependency(),wasmExports}addRunDependency();function e(tr){t(tr.instance,tr.module)}var I=getWasmImports();if(Module.instantiateWasm)try{return Module.instantiateWasm(I,t)}catch(tr){err(`Module.instantiateWasm callback failed with error: ${tr}`),readyPromiseReject(tr)}wasmBinaryFile??(wasmBinaryFile=findWasmBinary());try{var B=await instantiateAsync(wasmBinary,wasmBinaryFile,I);return e(B),B}catch(tr){readyPromiseReject(tr);return}}var ASM_CONSTS={18792944:t=>{Module.is_worker=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,Module.FD_BUFFER_MAX=t,Module.emscripten_copy_to=console.warn},18793117:()=>{Module.postMessage=function(t){console.log("# 1252: onCustomMessage:",__FILE__,t)}},18793242:()=>{if(Module.is_worker){let t=function(e){console.log("onCustomMessage:",e)};Module.onCustomMessage=t}else Module.postMessage=function(t){switch(t.type){case"raw":{stringToUTF8(t.data,shm_rawinput,Module.FD_BUFFER_MAX);break}case"stdin":{stringToUTF8(t.data,1,Module.FD_BUFFER_MAX);break}case"rcon":{stringToUTF8(t.data,shm_rcon,Module.FD_BUFFER_MAX);break}default:console.warn("custom_postMessage?",t)}}}};function is_web_env(){try{if(window)return 1}catch{return 0}}is_web_env.sig="i";class ExitStatus{constructor(e){P$1(this,"name","ExitStatus"),this.message=`Program terminated with exit(${e})`,this.status=e}}var GOT={},currentModuleWeakSymbols=new Set([]),GOTHandler={get(t,e){var I=GOT[e];return I||(I=GOT[e]=new WebAssembly.Global({value:"i32",mutable:!0})),currentModuleWeakSymbols.has(e)||(I.required=!0),I}},callRuntimeCallbacks=t=>{for(;t.length>0;)t.shift()(Module)},UTF8Decoder=typeof TextDecoder<"u"?new TextDecoder:void 0,UTF8ArrayToString=(t,e=0,I=NaN)=>{for(var B=e+I,tr=e;t[tr]&&!(tr>=B);)++tr;if(tr-e>16&&t.buffer&&UTF8Decoder)return UTF8Decoder.decode(t.subarray(e,tr));for(var rr="";e<tr;){var ir=t[e++];if(!(ir&128)){rr+=String.fromCharCode(ir);continue}var lr=t[e++]&63;if((ir&224)==192){rr+=String.fromCharCode((ir&31)<<6|lr);continue}var dr=t[e++]&63;if((ir&240)==224?ir=(ir&15)<<12|lr<<6|dr:ir=(ir&7)<<18|lr<<12|dr<<6|t[e++]&63,ir<65536)rr+=String.fromCharCode(ir);else{var mr=ir-65536;rr+=String.fromCharCode(55296|mr>>10,56320|mr&1023)}}return rr},getDylinkMetadata=t=>{var e=0,I=0;function B(){return t[e++]}function tr(){for(var Ur=0,Pr=1;;){var kr=t[e++];if(Ur+=(kr&127)*Pr,Pr*=128,!(kr&128))break}return Ur}function rr(){var Ur=tr();return e+=Ur,UTF8ArrayToString(t,e-Ur,Ur)}function ir(Ur,Pr){if(Ur)throw new Error(Pr)}var lr="dylink.0";if(t instanceof WebAssembly.Module){var dr=WebAssembly.Module.customSections(t,lr);dr.length===0&&(lr="dylink",dr=WebAssembly.Module.customSections(t,lr)),ir(dr.length===0,"need dylink section"),t=new Uint8Array(dr[0]),I=t.length}else{var mr=new Uint32Array(new Uint8Array(t.subarray(0,24)).buffer),hr=mr[0]==1836278016;ir(!hr,"need to see wasm magic number"),ir(t[8]!==0,"need the dylink section to be first"),e=9;var fr=tr();I=e+fr,lr=rr()}var _r={neededDynlibs:[],tlsExports:new Set,weakImports:new Set};if(lr=="dylink"){_r.memorySize=tr(),_r.memoryAlign=tr(),_r.tableSize=tr(),_r.tableAlign=tr();for(var wr=tr(),gr=0;gr<wr;++gr){var xr=rr();_r.neededDynlibs.push(xr)}}else{ir(lr!=="dylink.0");for(var Mr=1,Sr=2,yr=3,br=4,vr=256,Cr=3,Ar=1;e<I;){var Ir=B(),Dr=tr();if(Ir===Mr)_r.memorySize=tr(),_r.memoryAlign=tr(),_r.tableSize=tr(),_r.tableAlign=tr();else if(Ir===Sr)for(var wr=tr(),gr=0;gr<wr;++gr)xr=rr(),_r.neededDynlibs.push(xr);else if(Ir===yr)for(var Fr=tr();Fr--;){var zr=rr(),Gr=tr();Gr&vr&&_r.tlsExports.add(zr)}else if(Ir===br)for(var Fr=tr();Fr--;){rr();var zr=rr(),Gr=tr();(Gr&Cr)==Ar&&_r.weakImports.add(zr)}else e+=Dr}}return _r};function getValue(t,e="i8"){switch(e.endsWith("*")&&(e="*"),e){case"i1":return HEAP8[t];case"i8":return HEAP8[t];case"i16":return HEAP16[t>>1];case"i32":return HEAP32[t>>2];case"i64":return HEAP64[t>>3];case"float":return HEAPF32[t>>2];case"double":return HEAPF64[t>>3];case"*":return HEAPU32[t>>2];default:abort(`invalid type for getValue: ${e}`)}}var newDSO=(t,e,I)=>{var B={refcount:1/0,name:t,exports:I,global:!0};return LDSO.loadedLibsByName[t]=B,e!=null&&(LDSO.loadedLibsByHandle[e]=B),B},LDSO={loadedLibsByName:{},loadedLibsByHandle:{},init(){newDSO("__main__",0,wasmImports)}},___heap_base=23144432,alignMemory=(t,e)=>Math.ceil(t/e)*e,getMemory=t=>{if(runtimeInitialized)return _calloc(t,1);var e=___heap_base,I=e+alignMemory(t,16);return ___heap_base=I,GOT.__heap_base.value=I,e},isInternalSym=t=>["__cpp_exception","__c_longjmp","__wasm_apply_data_relocs","__dso_handle","__tls_size","__tls_align","__set_stack_limits","_emscripten_tls_init","__wasm_init_tls","__wasm_call_ctors","__start_em_asm","__stop_em_asm","__start_em_js","__stop_em_js"].includes(t)||t.startsWith("__em_js__"),uleb128Encode=(t,e)=>{t<128?e.push(t):e.push(t%128|128,t>>7)},sigToWasmTypes=t=>{for(var e={i:"i32",j:"i64",f:"f32",d:"f64",e:"externref",p:"i32"},I={parameters:[],results:t[0]=="v"?[]:[e[t[0]]]},B=1;B<t.length;++B)I.parameters.push(e[t[B]]);return I},generateFuncType=(t,e)=>{var I=t.slice(0,1),B=t.slice(1),tr={i:127,p:127,j:126,f:125,d:124,e:111};e.push(96),uleb128Encode(B.length,e);for(var rr=0;rr<B.length;++rr)e.push(tr[B[rr]]);I=="v"?e.push(0):e.push(1,tr[I])},convertJsFunctionToWasm=(t,e)=>{if(typeof WebAssembly.Function=="function")return new WebAssembly.Function(sigToWasmTypes(e),t);var I=[1];generateFuncType(e,I);var B=[0,97,115,109,1,0,0,0,1];uleb128Encode(I.length,B),B.push(...I),B.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var tr=new WebAssembly.Module(new Uint8Array(B)),rr=new WebAssembly.Instance(tr,{e:{f:t}}),ir=rr.exports.f;return ir},wasmTableMirror=[],wasmTable=new WebAssembly.Table({initial:5360,element:"anyfunc"}),getWasmTableEntry=t=>{var e=wasmTableMirror[t];return e||(t>=wasmTableMirror.length&&(wasmTableMirror.length=t+1),wasmTableMirror[t]=e=wasmTable.get(t)),e},updateTableMap=(t,e)=>{if(functionsInTableMap)for(var I=t;I<t+e;I++){var B=getWasmTableEntry(I);B&&functionsInTableMap.set(B,I)}},functionsInTableMap,getFunctionAddress=t=>(functionsInTableMap||(functionsInTableMap=new WeakMap,updateTableMap(0,wasmTable.length)),functionsInTableMap.get(t)||0),freeTableIndexes=[],getEmptyTableSlot=()=>{if(freeTableIndexes.length)return freeTableIndexes.pop();try{wasmTable.grow(1)}catch(t){throw t instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":t}return wasmTable.length-1},setWasmTableEntry=(t,e)=>{wasmTable.set(t,e),wasmTableMirror[t]=wasmTable.get(t)},addFunction=(t,e)=>{var I=getFunctionAddress(t);if(I)return I;var B=getEmptyTableSlot();try{setWasmTableEntry(B,t)}catch(rr){if(!(rr instanceof TypeError))throw rr;var tr=convertJsFunctionToWasm(t,e);setWasmTableEntry(B,tr)}return functionsInTableMap.set(t,B),B},updateGOT=(t,e)=>{for(var I in t)if(!isInternalSym(I)){var B=t[I];GOT[I]||(GOT[I]=new WebAssembly.Global({value:"i32",mutable:!0})),GOT[I].value==0&&(typeof B=="function"?GOT[I].value=addFunction(B):typeof B=="number"?GOT[I].value=B:err(`unhandled export type for '${I}': ${typeof B}`))}},relocateExports=(t,e,I)=>{var B={};for(var tr in t){var rr=t[tr];typeof rr=="object"&&(rr=rr.value),typeof rr=="number"&&(rr+=e),B[tr]=rr}return updateGOT(B),B},isSymbolDefined=t=>{var e=wasmImports[t];return!(!e||e.stub)},dynCall=(t,e,I=[])=>{var B=getWasmTableEntry(e)(...I);return B},stackSave=()=>_emscripten_stack_get_current(),stackRestore=t=>__emscripten_stack_restore(t),createInvokeFunction=t=>(e,...I)=>{var B=stackSave();try{return dynCall(t,e,I)}catch(tr){if(stackRestore(B),tr!==tr+0)throw tr;if(_setThrew(1,0),t[0]=="j")return 0n}},resolveGlobalSymbol=(t,e=!1)=>{var I;return isSymbolDefined(t)?I=wasmImports[t]:t.startsWith("invoke_")&&(I=wasmImports[t]=createInvokeFunction(t.split("_")[1])),{sym:I,name:t}},UTF8ToString=(t,e)=>t?UTF8ArrayToString(HEAPU8,t,e):"",loadWebAssemblyModule=(binary,flags,libName,localScope,handle)=>{var metadata=getDylinkMetadata(binary);currentModuleWeakSymbols=metadata.weakImports;function loadModule(){var firstLoad=!handle||!HEAP8[handle+8];if(firstLoad){var memAlign=Math.pow(2,metadata.memoryAlign),memoryBase=metadata.memorySize?alignMemory(getMemory(metadata.memorySize+memAlign),memAlign):0,tableBase=metadata.tableSize?wasmTable.length:0;handle&&(HEAP8[handle+8]=1,HEAPU32[handle+12>>2]=memoryBase,HEAP32[handle+16>>2]=metadata.memorySize,HEAPU32[handle+20>>2]=tableBase,HEAP32[handle+24>>2]=metadata.tableSize)}else memoryBase=HEAPU32[handle+12>>2],tableBase=HEAPU32[handle+20>>2];var tableGrowthNeeded=tableBase+metadata.tableSize-wasmTable.length;tableGrowthNeeded>0&&wasmTable.grow(tableGrowthNeeded);var moduleExports;function resolveSymbol(t){var e=resolveGlobalSymbol(t).sym;return!e&&localScope&&(e=localScope[t]),e||(e=moduleExports[t]),e}var proxyHandler={get(t,e){switch(e){case"__memory_base":return memoryBase;case"__table_base":return tableBase}if(e in wasmImports&&!wasmImports[e].stub)return wasmImports[e];if(!(e in t)){var I;t[e]=(...B)=>(I||(I=resolveSymbol(e)),I(...B))}return t[e]}},proxy=new Proxy({},proxyHandler),info={"GOT.mem":new Proxy({},GOTHandler),"GOT.func":new Proxy({},GOTHandler),env:proxy,wasi_snapshot_preview1:proxy};function postInstantiation(module,instance){updateTableMap(tableBase,metadata.tableSize),moduleExports=relocateExports(instance.exports,memoryBase),flags.allowUndefined||reportUndefinedSymbols();function addEmAsm(addr,body){for(var args=[],arity=0;arity<16&&body.indexOf("$"+arity)!=-1;arity++)args.push("$"+arity);args=args.join(",");var func=`(${args}) => { ${body} };`;ASM_CONSTS[start]=eval(func)}if("__start_em_asm"in moduleExports)for(var start=moduleExports.__start_em_asm,stop=moduleExports.__stop_em_asm;start<stop;){var jsString=UTF8ToString(start);addEmAsm(start,jsString),start=HEAPU8.indexOf(0,start)+1}function addEmJs(name,cSig,body){var jsArgs=[];if(cSig=cSig.slice(1,-1),cSig!="void"){cSig=cSig.split(",");for(var i in cSig){var jsArg=cSig[i].split(" ").pop();jsArgs.push(jsArg.replaceAll("*",""))}}var func=`(${jsArgs}) => ${body};`;moduleExports[name]=eval(func)}for(var name in moduleExports)if(name.startsWith("__em_js__")){var start=moduleExports[name],jsString=UTF8ToString(start),parts=jsString.split("<::>");addEmJs(name.replace("__em_js__",""),parts[0],parts[1]),delete moduleExports[name]}var applyRelocs=moduleExports.__wasm_apply_data_relocs;applyRelocs&&(runtimeInitialized?applyRelocs():__RELOC_FUNCS__.push(applyRelocs));var init=moduleExports.__wasm_call_ctors;return init&&(runtimeInitialized?init():__ATINIT__.push(init)),moduleExports}if(flags.loadAsync){if(binary instanceof WebAssembly.Module){var instance=new WebAssembly.Instance(binary,info);return Promise.resolve(postInstantiation(binary,instance))}return WebAssembly.instantiate(binary,info).then(t=>postInstantiation(t.module,t.instance))}var module=binary instanceof WebAssembly.Module?binary:new WebAssembly.Module(binary),instance=new WebAssembly.Instance(module,info);return postInstantiation(module,instance)}return flags.loadAsync?metadata.neededDynlibs.reduce((t,e)=>t.then(()=>loadDynamicLibrary(e,flags,localScope)),Promise.resolve()).then(loadModule):(metadata.neededDynlibs.forEach(t=>loadDynamicLibrary(t,flags,localScope)),loadModule())},mergeLibSymbols=(t,e)=>{for(var[I,B]of Object.entries(t)){let tr=ir=>{isSymbolDefined(ir)||(wasmImports[ir]=B)};tr(I);let rr="__main_argc_argv";I=="main"&&tr(rr),I==rr&&tr("main")}},asyncLoad=async t=>{var e=await readAsync(t);return new Uint8Array(e)},preloadPlugins=Module.preloadPlugins||[],registerWasmPlugin=()=>{var t={promiseChainEnd:Promise.resolve(),canHandle:e=>!Module.noWasmDecoding&&e.endsWith(".so"),handle:(e,I,B,tr)=>{t.promiseChainEnd=t.promiseChainEnd.then(()=>loadWebAssemblyModule(e,{loadAsync:!0,nodelete:!0},I,{})).then(rr=>{preloadedWasm[I]=rr,B(e)},rr=>{err(`failed to instantiate wasm: ${I}: ${rr}`),tr()})}};preloadPlugins.push(t)},preloadedWasm={};function loadDynamicLibrary(t,e={global:!0,nodelete:!0},I,B){var tr=LDSO.loadedLibsByName[t];if(tr)return e.global?tr.global||(tr.global=!0,mergeLibSymbols(tr.exports)):I&&Object.assign(I,tr.exports),e.nodelete&&tr.refcount!==1/0&&(tr.refcount=1/0),tr.refcount++,B&&(LDSO.loadedLibsByHandle[B]=tr),e.loadAsync?Promise.resolve(!0):!0;tr=newDSO(t,B,"loading"),tr.refcount=e.nodelete?1/0:1,tr.global=e.global;function rr(){if(B){var dr=HEAPU32[B+28>>2],mr=HEAPU32[B+32>>2];if(dr&&mr){var hr=HEAP8.slice(dr,dr+mr);return e.loadAsync?Promise.resolve(hr):hr}}var fr=locateFile(t);if(e.loadAsync)return asyncLoad(fr);if(!readBinary)throw new Error(`${fr}: file not found, and synchronous loading of external files is not available`);return readBinary(fr)}function ir(){var dr=preloadedWasm[t];return dr?e.loadAsync?Promise.resolve(dr):dr:e.loadAsync?rr().then(mr=>loadWebAssemblyModule(mr,e,t,I,B)):loadWebAssemblyModule(rr(),e,t,I,B)}function lr(dr){tr.global?mergeLibSymbols(dr):I&&Object.assign(I,dr),tr.exports=dr}return e.loadAsync?ir().then(dr=>(lr(dr),!0)):(lr(ir()),!0)}var reportUndefinedSymbols=()=>{for(var[t,e]of Object.entries(GOT))if(e.value==0){var I=resolveGlobalSymbol(t,!0).sym;if(!I&&!e.required)continue;if(typeof I=="function")e.value=addFunction(I,I.sig);else if(typeof I=="number")e.value=I;else throw new Error(`bad export type for '${t}': ${typeof I}`)}},loadDylibs=()=>{if(!dynamicLibraries.length){reportUndefinedSymbols();return}addRunDependency(),dynamicLibraries.reduce((t,e)=>t.then(()=>loadDynamicLibrary(e,{loadAsync:!0,global:!0,nodelete:!0,allowUndefined:!0})),Promise.resolve()).then(()=>{reportUndefinedSymbols(),removeRunDependency()})},noExitRuntime=Module.noExitRuntime||!0;function setValue(t,e,I="i8"){switch(I.endsWith("*")&&(I="*"),I){case"i1":HEAP8[t]=e;break;case"i8":HEAP8[t]=e;break;case"i16":HEAP16[t>>1]=e;break;case"i32":HEAP32[t>>2]=e;break;case"i64":HEAP64[t>>3]=BigInt(e);break;case"float":HEAPF32[t>>2]=e;break;case"double":HEAPF64[t>>3]=e;break;case"*":HEAPU32[t>>2]=e;break;default:abort(`invalid type for setValue: ${I}`)}}var ___assert_fail=(t,e,I,B)=>abort(`Assertion failed: ${UTF8ToString(t)}, at: `+[e?UTF8ToString(e):"unknown filename",I,B?UTF8ToString(B):"unknown function"]);___assert_fail.sig="vppip";var ___call_sighandler=(t,e)=>getWasmTableEntry(t)(e);___call_sighandler.sig="vpi";var ___memory_base=new WebAssembly.Global({value:"i32",mutable:!1},16777216),___stack_pointer=new WebAssembly.Global({value:"i32",mutable:!0},23144432),PATH={isAbs:t=>t.charAt(0)==="/",splitPath:t=>{var e=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return e.exec(t).slice(1)},normalizeArray:(t,e)=>{for(var I=0,B=t.length-1;B>=0;B--){var tr=t[B];tr==="."?t.splice(B,1):tr===".."?(t.splice(B,1),I++):I&&(t.splice(B,1),I--)}if(e)for(;I;I--)t.unshift("..");return t},normalize:t=>{var e=PATH.isAbs(t),I=t.substr(-1)==="/";return t=PATH.normalizeArray(t.split("/").filter(B=>!!B),!e).join("/"),!t&&!e&&(t="."),t&&I&&(t+="/"),(e?"/":"")+t},dirname:t=>{var e=PATH.splitPath(t),I=e[0],B=e[1];return!I&&!B?".":(B&&(B=B.substr(0,B.length-1)),I+B)},basename:t=>{if(t==="/")return"/";t=PATH.normalize(t),t=t.replace(/\/$/,"");var e=t.lastIndexOf("/");return e===-1?t:t.substr(e+1)},join:(...t)=>PATH.normalize(t.join("/")),join2:(t,e)=>PATH.normalize(t+"/"+e)},initRandomFill=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return B=>crypto.getRandomValues(B);if(ENVIRONMENT_IS_NODE)try{var t=require("crypto"),e=t.randomFillSync;if(e)return B=>t.randomFillSync(B);var I=t.randomBytes;return B=>(B.set(I(B.byteLength)),B)}catch{}abort("initRandomDevice")},randomFill=t=>(randomFill=initRandomFill())(t),PATH_FS={resolve:(...t)=>{for(var e="",I=!1,B=t.length-1;B>=-1&&!I;B--){var tr=B>=0?t[B]:FS.cwd();if(typeof tr!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!tr)return"";e=tr+"/"+e,I=PATH.isAbs(tr)}return e=PATH.normalizeArray(e.split("/").filter(rr=>!!rr),!I).join("/"),(I?"/":"")+e||"."},relative:(t,e)=>{t=PATH_FS.resolve(t).substr(1),e=PATH_FS.resolve(e).substr(1);function I(mr){for(var hr=0;hr<mr.length&&mr[hr]==="";hr++);for(var fr=mr.length-1;fr>=0&&mr[fr]==="";fr--);return hr>fr?[]:mr.slice(hr,fr-hr+1)}for(var B=I(t.split("/")),tr=I(e.split("/")),rr=Math.min(B.length,tr.length),ir=rr,lr=0;lr<rr;lr++)if(B[lr]!==tr[lr]){ir=lr;break}for(var dr=[],lr=ir;lr<B.length;lr++)dr.push("..");return dr=dr.concat(tr.slice(ir)),dr.join("/")}},FS_stdin_getChar_buffer=[],lengthBytesUTF8=t=>{for(var e=0,I=0;I<t.length;++I){var B=t.charCodeAt(I);B<=127?e++:B<=2047?e+=2:B>=55296&&B<=57343?(e+=4,++I):e+=3}return e},stringToUTF8Array=(t,e,I,B)=>{if(!(B>0))return 0;for(var tr=I,rr=I+B-1,ir=0;ir<t.length;++ir){var lr=t.charCodeAt(ir);if(lr>=55296&&lr<=57343){var dr=t.charCodeAt(++ir);lr=65536+((lr&1023)<<10)|dr&1023}if(lr<=127){if(I>=rr)break;e[I++]=lr}else if(lr<=2047){if(I+1>=rr)break;e[I++]=192|lr>>6,e[I++]=128|lr&63}else if(lr<=65535){if(I+2>=rr)break;e[I++]=224|lr>>12,e[I++]=128|lr>>6&63,e[I++]=128|lr&63}else{if(I+3>=rr)break;e[I++]=240|lr>>18,e[I++]=128|lr>>12&63,e[I++]=128|lr>>6&63,e[I++]=128|lr&63}}return e[I]=0,I-tr};function intArrayFromString(t,e,I){var B=lengthBytesUTF8(t)+1,tr=new Array(B),rr=stringToUTF8Array(t,tr,0,tr.length);return tr.length=rr,tr}var FS_stdin_getChar=()=>{if(!FS_stdin_getChar_buffer.length){var t=null;if(ENVIRONMENT_IS_NODE){var e=256,I=Buffer.alloc(e),B=0,tr=process$1.stdin.fd;try{B=fs.readSync(tr,I,0,e)}catch(rr){if(rr.toString().includes("EOF"))B=0;else throw rr}B>0&&(t=I.slice(0,B).toString("utf-8"))}else typeof window<"u"&&typeof window.prompt=="function"&&(t=window.prompt("Input: "),t!==null&&(t+=`
22
22
  `));if(!t)return null;FS_stdin_getChar_buffer=intArrayFromString(t)}return FS_stdin_getChar_buffer.shift()},TTY={ttys:[],init(){},shutdown(){},register(t,e){TTY.ttys[t]={input:[],output:[],ops:e},FS.registerDevice(t,TTY.stream_ops)},stream_ops:{open(t){var e=TTY.ttys[t.node.rdev];if(!e)throw new FS.ErrnoError(43);t.tty=e,t.seekable=!1},close(t){t.tty.ops.fsync(t.tty)},fsync(t){t.tty.ops.fsync(t.tty)},read(t,e,I,B,tr){if(!t.tty||!t.tty.ops.get_char)throw new FS.ErrnoError(60);for(var rr=0,ir=0;ir<B;ir++){var lr;try{lr=t.tty.ops.get_char(t.tty)}catch{throw new FS.ErrnoError(29)}if(lr===void 0&&rr===0)throw new FS.ErrnoError(6);if(lr==null)break;rr++,e[I+ir]=lr}return rr&&(t.node.atime=Date.now()),rr},write(t,e,I,B,tr){if(!t.tty||!t.tty.ops.put_char)throw new FS.ErrnoError(60);try{for(var rr=0;rr<B;rr++)t.tty.ops.put_char(t.tty,e[I+rr])}catch{throw new FS.ErrnoError(29)}return B&&(t.node.mtime=t.node.ctime=Date.now()),rr}},default_tty_ops:{get_char(t){return FS_stdin_getChar()},put_char(t,e){e===null||e===10?(out(UTF8ArrayToString(t.output)),t.output=[]):e!=0&&t.output.push(e)},fsync(t){t.output&&t.output.length>0&&(out(UTF8ArrayToString(t.output)),t.output=[])},ioctl_tcgets(t){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(t,e,I){return 0},ioctl_tiocgwinsz(t){return[24,80]}},default_tty1_ops:{put_char(t,e){e===null||e===10?(err(UTF8ArrayToString(t.output)),t.output=[]):e!=0&&t.output.push(e)},fsync(t){t.output&&t.output.length>0&&(err(UTF8ArrayToString(t.output)),t.output=[])}}},zeroMemory=(t,e)=>{HEAPU8.fill(0,t,t+e)},mmapAlloc=t=>{t=alignMemory(t,65536);var e=_emscripten_builtin_memalign(65536,t);return e&&zeroMemory(e,t),e},MEMFS={ops_table:null,mount(t){return MEMFS.createNode(null,"/",16895,0)},createNode(t,e,I,B){if(FS.isBlkdev(I)||FS.isFIFO(I))throw new FS.ErrnoError(63);MEMFS.ops_table||(MEMFS.ops_table={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}});var tr=FS.createNode(t,e,I,B);return FS.isDir(tr.mode)?(tr.node_ops=MEMFS.ops_table.dir.node,tr.stream_ops=MEMFS.ops_table.dir.stream,tr.contents={}):FS.isFile(tr.mode)?(tr.node_ops=MEMFS.ops_table.file.node,tr.stream_ops=MEMFS.ops_table.file.stream,tr.usedBytes=0,tr.contents=null):FS.isLink(tr.mode)?(tr.node_ops=MEMFS.ops_table.link.node,tr.stream_ops=MEMFS.ops_table.link.stream):FS.isChrdev(tr.mode)&&(tr.node_ops=MEMFS.ops_table.chrdev.node,tr.stream_ops=MEMFS.ops_table.chrdev.stream),tr.atime=tr.mtime=tr.ctime=Date.now(),t&&(t.contents[e]=tr,t.atime=t.mtime=t.ctime=tr.atime),tr},getFileDataAsTypedArray(t){return t.contents?t.contents.subarray?t.contents.subarray(0,t.usedBytes):new Uint8Array(t.contents):new Uint8Array(0)},expandFileStorage(t,e){var I=t.contents?t.contents.length:0;if(!(I>=e)){var B=1048576;e=Math.max(e,I*(I<B?2:1.125)>>>0),I!=0&&(e=Math.max(e,256));var tr=t.contents;t.contents=new Uint8Array(e),t.usedBytes>0&&t.contents.set(tr.subarray(0,t.usedBytes),0)}},resizeFileStorage(t,e){if(t.usedBytes!=e)if(e==0)t.contents=null,t.usedBytes=0;else{var I=t.contents;t.contents=new Uint8Array(e),I&&t.contents.set(I.subarray(0,Math.min(e,t.usedBytes))),t.usedBytes=e}},node_ops:{getattr(t){var e={};return e.dev=FS.isChrdev(t.mode)?t.id:1,e.ino=t.id,e.mode=t.mode,e.nlink=1,e.uid=0,e.gid=0,e.rdev=t.rdev,FS.isDir(t.mode)?e.size=4096:FS.isFile(t.mode)?e.size=t.usedBytes:FS.isLink(t.mode)?e.size=t.link.length:e.size=0,e.atime=new Date(t.atime),e.mtime=new Date(t.mtime),e.ctime=new Date(t.ctime),e.blksize=4096,e.blocks=Math.ceil(e.size/e.blksize),e},setattr(t,e){for(let I of["mode","atime","mtime","ctime"])e[I]&&(t[I]=e[I]);e.size!==void 0&&MEMFS.resizeFileStorage(t,e.size)},lookup(t,e){throw MEMFS.doesNotExistError},mknod(t,e,I,B){return MEMFS.createNode(t,e,I,B)},rename(t,e,I){var B;try{B=FS.lookupNode(e,I)}catch{}if(B){if(FS.isDir(t.mode))for(var tr in B.contents)throw new FS.ErrnoError(55);FS.hashRemoveNode(B)}delete t.parent.contents[t.name],e.contents[I]=t,t.name=I,e.ctime=e.mtime=t.parent.ctime=t.parent.mtime=Date.now()},unlink(t,e){delete t.contents[e],t.ctime=t.mtime=Date.now()},rmdir(t,e){var I=FS.lookupNode(t,e);for(var B in I.contents)throw new FS.ErrnoError(55);delete t.contents[e],t.ctime=t.mtime=Date.now()},readdir(t){return[".","..",...Object.keys(t.contents)]},symlink(t,e,I){var B=MEMFS.createNode(t,e,41471,0);return B.link=I,B},readlink(t){if(!FS.isLink(t.mode))throw new FS.ErrnoError(28);return t.link}},stream_ops:{read(t,e,I,B,tr){var rr=t.node.contents;if(tr>=t.node.usedBytes)return 0;var ir=Math.min(t.node.usedBytes-tr,B);if(ir>8&&rr.subarray)e.set(rr.subarray(tr,tr+ir),I);else for(var lr=0;lr<ir;lr++)e[I+lr]=rr[tr+lr];return ir},write(t,e,I,B,tr,rr){if(e.buffer===HEAP8.buffer&&(rr=!1),!B)return 0;var ir=t.node;if(ir.mtime=ir.ctime=Date.now(),e.subarray&&(!ir.contents||ir.contents.subarray)){if(rr)return ir.contents=e.subarray(I,I+B),ir.usedBytes=B,B;if(ir.usedBytes===0&&tr===0)return ir.contents=e.slice(I,I+B),ir.usedBytes=B,B;if(tr+B<=ir.usedBytes)return ir.contents.set(e.subarray(I,I+B),tr),B}if(MEMFS.expandFileStorage(ir,tr+B),ir.contents.subarray&&e.subarray)ir.contents.set(e.subarray(I,I+B),tr);else for(var lr=0;lr<B;lr++)ir.contents[tr+lr]=e[I+lr];return ir.usedBytes=Math.max(ir.usedBytes,tr+B),B},llseek(t,e,I){var B=e;if(I===1?B+=t.position:I===2&&FS.isFile(t.node.mode)&&(B+=t.node.usedBytes),B<0)throw new FS.ErrnoError(28);return B},allocate(t,e,I){MEMFS.expandFileStorage(t.node,e+I),t.node.usedBytes=Math.max(t.node.usedBytes,e+I)},mmap(t,e,I,B,tr){if(!FS.isFile(t.node.mode))throw new FS.ErrnoError(43);var rr,ir,lr=t.node.contents;if(!(tr&2)&&lr&&lr.buffer===HEAP8.buffer)ir=!1,rr=lr.byteOffset;else{if(ir=!0,rr=mmapAlloc(e),!rr)throw new FS.ErrnoError(48);lr&&((I>0||I+e<lr.length)&&(lr.subarray?lr=lr.subarray(I,I+e):lr=Array.prototype.slice.call(lr,I,I+e)),HEAP8.set(lr,rr))}return{ptr:rr,allocated:ir}},msync(t,e,I,B,tr){return MEMFS.stream_ops.write(t,e,0,B,I,!1),0}}},FS_createDataFile=(t,e,I,B,tr,rr)=>{FS.createDataFile(t,e,I,B,tr,rr)},FS_handledByPreloadPlugin=(t,e,I,B)=>{typeof Browser<"u"&&Browser.init();var tr=!1;return preloadPlugins.forEach(rr=>{tr||rr.canHandle(e)&&(rr.handle(t,e,I,B),tr=!0)}),tr},FS_createPreloadedFile=(t,e,I,B,tr,rr,ir,lr,dr,mr)=>{var hr=e?PATH_FS.resolve(PATH.join2(t,e)):t;function fr(_r){function wr(gr){mr?.(),lr||FS_createDataFile(t,e,gr,B,tr,dr),rr?.(),removeRunDependency()}FS_handledByPreloadPlugin(_r,hr,wr,()=>{ir?.(),removeRunDependency()})||wr(_r)}addRunDependency(),typeof I=="string"?asyncLoad(I).then(fr,ir):fr(I)},FS_modeStringToFlags=t=>{var e={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},I=e[t];if(typeof I>"u")throw new Error(`Unknown file open mode: ${t}`);return I},FS_getMode=(t,e)=>{var I=0;return t&&(I|=365),e&&(I|=146),I},IDBFS={dbs:{},indexedDB:()=>{if(typeof indexedDB<"u")return indexedDB;var t=null;return typeof window=="object"&&(t=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),t},DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",queuePersist:t=>{function e(){t.idbPersistState==="again"?I():t.idbPersistState=0}function I(){t.idbPersistState="idb",IDBFS.syncfs(t,!1,e)}t.idbPersistState?t.idbPersistState==="idb"&&(t.idbPersistState="again"):t.idbPersistState=setTimeout(I,0)},mount:t=>{var e=MEMFS.mount(t);if(t?.opts?.autoPersist){e.idbPersistState=0;var I=e.node_ops;e.node_ops=Object.assign({},e.node_ops),e.node_ops.mknod=(B,tr,rr,ir)=>{var lr=I.mknod(B,tr,rr,ir);return lr.node_ops=e.node_ops,lr.idbfs_mount=e.mount,lr.memfs_stream_ops=lr.stream_ops,lr.stream_ops=Object.assign({},lr.stream_ops),lr.stream_ops.write=(dr,mr,hr,fr,_r,wr)=>(dr.node.isModified=!0,lr.memfs_stream_ops.write(dr,mr,hr,fr,_r,wr)),lr.stream_ops.close=dr=>{var mr=dr.node;if(mr.isModified&&(IDBFS.queuePersist(mr.idbfs_mount),mr.isModified=!1),mr.memfs_stream_ops.close)return mr.memfs_stream_ops.close(dr)},lr},e.node_ops.mkdir=(...B)=>(IDBFS.queuePersist(e.mount),I.mkdir(...B)),e.node_ops.rmdir=(...B)=>(IDBFS.queuePersist(e.mount),I.rmdir(...B)),e.node_ops.symlink=(...B)=>(IDBFS.queuePersist(e.mount),I.symlink(...B)),e.node_ops.unlink=(...B)=>(IDBFS.queuePersist(e.mount),I.unlink(...B)),e.node_ops.rename=(...B)=>(IDBFS.queuePersist(e.mount),I.rename(...B))}return e},syncfs:(t,e,I)=>{IDBFS.getLocalSet(t,(B,tr)=>{if(B)return I(B);IDBFS.getRemoteSet(t,(rr,ir)=>{if(rr)return I(rr);var lr=e?ir:tr,dr=e?tr:ir;IDBFS.reconcile(lr,dr,I)})})},quit:()=>{Object.values(IDBFS.dbs).forEach(t=>t.close()),IDBFS.dbs={}},getDB:(t,e)=>{var I=IDBFS.dbs[t];if(I)return e(null,I);var B;try{B=IDBFS.indexedDB().open(t,IDBFS.DB_VERSION)}catch(tr){return e(tr)}if(!B)return e("Unable to connect to IndexedDB");B.onupgradeneeded=tr=>{var rr=tr.target.result,ir=tr.target.transaction,lr;rr.objectStoreNames.contains(IDBFS.DB_STORE_NAME)?lr=ir.objectStore(IDBFS.DB_STORE_NAME):lr=rr.createObjectStore(IDBFS.DB_STORE_NAME),lr.indexNames.contains("timestamp")||lr.createIndex("timestamp","timestamp",{unique:!1})},B.onsuccess=()=>{I=B.result,IDBFS.dbs[t]=I,e(null,I)},B.onerror=tr=>{e(tr.target.error),tr.preventDefault()}},getLocalSet:(t,e)=>{var I={};function B(dr){return dr!=="."&&dr!==".."}function tr(dr){return mr=>PATH.join2(dr,mr)}for(var rr=FS.readdir(t.mountpoint).filter(B).map(tr(t.mountpoint));rr.length;){var ir=rr.pop(),lr;try{lr=FS.stat(ir)}catch(dr){return e(dr)}FS.isDir(lr.mode)&&rr.push(...FS.readdir(ir).filter(B).map(tr(ir))),I[ir]={timestamp:lr.mtime}}return e(null,{type:"local",entries:I})},getRemoteSet:(t,e)=>{var I={};IDBFS.getDB(t.mountpoint,(B,tr)=>{if(B)return e(B);try{var rr=tr.transaction([IDBFS.DB_STORE_NAME],"readonly");rr.onerror=dr=>{e(dr.target.error),dr.preventDefault()};var ir=rr.objectStore(IDBFS.DB_STORE_NAME),lr=ir.index("timestamp");lr.openKeyCursor().onsuccess=dr=>{var mr=dr.target.result;if(!mr)return e(null,{type:"remote",db:tr,entries:I});I[mr.primaryKey]={timestamp:mr.key},mr.continue()}}catch(dr){return e(dr)}})},loadLocalEntry:(t,e)=>{var I,B;try{var tr=FS.lookupPath(t);B=tr.node,I=FS.stat(t)}catch(rr){return e(rr)}return FS.isDir(I.mode)?e(null,{timestamp:I.mtime,mode:I.mode}):FS.isFile(I.mode)?(B.contents=MEMFS.getFileDataAsTypedArray(B),e(null,{timestamp:I.mtime,mode:I.mode,contents:B.contents})):e(new Error("node type not supported"))},storeLocalEntry:(t,e,I)=>{try{if(FS.isDir(e.mode))FS.mkdirTree(t,e.mode);else if(FS.isFile(e.mode))FS.writeFile(t,e.contents,{canOwn:!0});else return I(new Error("node type not supported"));FS.chmod(t,e.mode),FS.utime(t,e.timestamp,e.timestamp)}catch(B){return I(B)}I(null)},removeLocalEntry:(t,e)=>{try{var I=FS.stat(t);FS.isDir(I.mode)?FS.rmdir(t):FS.isFile(I.mode)&&FS.unlink(t)}catch(B){return e(B)}e(null)},loadRemoteEntry:(t,e,I)=>{var B=t.get(e);B.onsuccess=tr=>I(null,tr.target.result),B.onerror=tr=>{I(tr.target.error),tr.preventDefault()}},storeRemoteEntry:(t,e,I,B)=>{try{var tr=t.put(I,e)}catch(rr){B(rr);return}tr.onsuccess=rr=>B(),tr.onerror=rr=>{B(rr.target.error),rr.preventDefault()}},removeRemoteEntry:(t,e,I)=>{var B=t.delete(e);B.onsuccess=tr=>I(),B.onerror=tr=>{I(tr.target.error),tr.preventDefault()}},reconcile:(t,e,I)=>{var B=0,tr=[];Object.keys(t.entries).forEach(fr=>{var _r=t.entries[fr],wr=e.entries[fr];(!wr||_r.timestamp.getTime()!=wr.timestamp.getTime())&&(tr.push(fr),B++)});var rr=[];if(Object.keys(e.entries).forEach(fr=>{t.entries[fr]||(rr.push(fr),B++)}),!B)return I(null);var ir=!1,lr=t.type==="remote"?t.db:e.db,dr=lr.transaction([IDBFS.DB_STORE_NAME],"readwrite"),mr=dr.objectStore(IDBFS.DB_STORE_NAME);function hr(fr){if(fr&&!ir)return ir=!0,I(fr)}dr.onerror=dr.onabort=fr=>{hr(fr.target.error),fr.preventDefault()},dr.oncomplete=fr=>{ir||I(null)},tr.sort().forEach(fr=>{e.type==="local"?IDBFS.loadRemoteEntry(mr,fr,(_r,wr)=>{if(_r)return hr(_r);IDBFS.storeLocalEntry(fr,wr,hr)}):IDBFS.loadLocalEntry(fr,(_r,wr)=>{if(_r)return hr(_r);IDBFS.storeRemoteEntry(mr,fr,wr,hr)})}),rr.sort().reverse().forEach(fr=>{e.type==="local"?IDBFS.removeLocalEntry(fr,hr):IDBFS.removeRemoteEntry(mr,fr,hr)})}},ERRNO_CODES={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115,ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14,EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135},NODEFS={isWindows:!1,staticInit(){NODEFS.isWindows=!!process$1.platform.match(/^win/);var t=process$1.binding("constants");t.fs&&(t=t.fs),NODEFS.flagsForNodeMap={1024:t.O_APPEND,64:t.O_CREAT,128:t.O_EXCL,256:t.O_NOCTTY,0:t.O_RDONLY,2:t.O_RDWR,4096:t.O_SYNC,512:t.O_TRUNC,1:t.O_WRONLY,131072:t.O_NOFOLLOW}},convertNodeCode(t){var e=t.code;return ERRNO_CODES[e]},tryFSOperation(t){try{return t()}catch(e){throw e.code?e.code==="UNKNOWN"?new FS.ErrnoError(28):new FS.ErrnoError(NODEFS.convertNodeCode(e)):e}},mount(t){return NODEFS.createNode(null,"/",NODEFS.getMode(t.opts.root),0)},createNode(t,e,I,B){if(!FS.isDir(I)&&!FS.isFile(I)&&!FS.isLink(I))throw new FS.ErrnoError(28);var tr=FS.createNode(t,e,I);return tr.node_ops=NODEFS.node_ops,tr.stream_ops=NODEFS.stream_ops,tr},getMode(t){return NODEFS.tryFSOperation(()=>{var e=fs.lstatSync(t).mode;return NODEFS.isWindows&&(e|=(e&292)>>2),e})},realPath(t){for(var e=[];t.parent!==t;)e.push(t.name),t=t.parent;return e.push(t.mount.opts.root),e.reverse(),PATH.join(...e)},flagsForNode(t){t&=-2097153,t&=-2049,t&=-32769,t&=-524289,t&=-65537;var e=0;for(var I in NODEFS.flagsForNodeMap)t&I&&(e|=NODEFS.flagsForNodeMap[I],t^=I);if(t)throw new FS.ErrnoError(28);return e},node_ops:{getattr(t){var e=NODEFS.realPath(t),I;return NODEFS.tryFSOperation(()=>I=fs.lstatSync(e)),NODEFS.isWindows&&(I.blksize||(I.blksize=4096),I.blocks||(I.blocks=(I.size+I.blksize-1)/I.blksize|0),I.mode|=(I.mode&292)>>2),{dev:I.dev,ino:I.ino,mode:I.mode,nlink:I.nlink,uid:I.uid,gid:I.gid,rdev:I.rdev,size:I.size,atime:I.atime,mtime:I.mtime,ctime:I.ctime,blksize:I.blksize,blocks:I.blocks}},setattr(t,e){var I=NODEFS.realPath(t);NODEFS.tryFSOperation(()=>{if(e.mode!==void 0){var B=e.mode;NODEFS.isWindows&&(B&=384),fs.chmodSync(I,B),t.mode=e.mode}if(e.atime||e.mtime){var tr=e.atime&&new Date(e.atime),rr=e.mtime&&new Date(e.mtime);fs.utimesSync(I,tr,rr)}e.size!==void 0&&fs.truncateSync(I,e.size)})},lookup(t,e){var I=PATH.join2(NODEFS.realPath(t),e),B=NODEFS.getMode(I);return NODEFS.createNode(t,e,B)},mknod(t,e,I,B){var tr=NODEFS.createNode(t,e,I,B),rr=NODEFS.realPath(tr);return NODEFS.tryFSOperation(()=>{FS.isDir(tr.mode)?fs.mkdirSync(rr,tr.mode):fs.writeFileSync(rr,"",{mode:tr.mode})}),tr},rename(t,e,I){var B=NODEFS.realPath(t),tr=PATH.join2(NODEFS.realPath(e),I);try{FS.unlink(tr)}catch{}NODEFS.tryFSOperation(()=>fs.renameSync(B,tr)),t.name=I},unlink(t,e){var I=PATH.join2(NODEFS.realPath(t),e);NODEFS.tryFSOperation(()=>fs.unlinkSync(I))},rmdir(t,e){var I=PATH.join2(NODEFS.realPath(t),e);NODEFS.tryFSOperation(()=>fs.rmdirSync(I))},readdir(t){var e=NODEFS.realPath(t);return NODEFS.tryFSOperation(()=>fs.readdirSync(e))},symlink(t,e,I){var B=PATH.join2(NODEFS.realPath(t),e);NODEFS.tryFSOperation(()=>fs.symlinkSync(I,B))},readlink(t){var e=NODEFS.realPath(t);return NODEFS.tryFSOperation(()=>fs.readlinkSync(e))},statfs(t){var e=NODEFS.tryFSOperation(()=>fs.statfsSync(t));return e.frsize=e.bsize,e}},stream_ops:{open(t){var e=NODEFS.realPath(t.node);NODEFS.tryFSOperation(()=>{FS.isFile(t.node.mode)&&(t.shared.refcount=1,t.nfd=fs.openSync(e,NODEFS.flagsForNode(t.flags)))})},close(t){NODEFS.tryFSOperation(()=>{FS.isFile(t.node.mode)&&t.nfd&&--t.shared.refcount===0&&fs.closeSync(t.nfd)})},dup(t){t.shared.refcount++},read(t,e,I,B,tr){return B===0?0:NODEFS.tryFSOperation(()=>fs.readSync(t.nfd,new Int8Array(e.buffer,I,B),0,B,tr))},write(t,e,I,B,tr){return NODEFS.tryFSOperation(()=>fs.writeSync(t.nfd,new Int8Array(e.buffer,I,B),0,B,tr))},llseek(t,e,I){var B=e;if(I===1?B+=t.position:I===2&&FS.isFile(t.node.mode)&&NODEFS.tryFSOperation(()=>{var tr=fs.fstatSync(t.nfd);B+=tr.size}),B<0)throw new FS.ErrnoError(28);return B},mmap(t,e,I,B,tr){if(!FS.isFile(t.node.mode))throw new FS.ErrnoError(43);var rr=mmapAlloc(e);return NODEFS.stream_ops.read(t,HEAP8,rr,e,I),{ptr:rr,allocated:!0}},msync(t,e,I,B,tr){return NODEFS.stream_ops.write(t,e,0,B,I,!1),0}}},FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:class{constructor(t){P$1(this,"name","ErrnoError"),this.errno=t}},filesystems:null,syncFSRequests:0,readFiles:{},FSStream:class{constructor(){P$1(this,"shared",{})}get object(){return this.node}set object(t){this.node=t}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(t){this.shared.flags=t}get position(){return this.shared.position}set position(t){this.shared.position=t}},FSNode:class{constructor(t,e,I,B){P$1(this,"node_ops",{}),P$1(this,"stream_ops",{}),P$1(this,"readMode",365),P$1(this,"writeMode",146),P$1(this,"mounted",null),t||(t=this),this.parent=t,this.mount=t.mount,this.id=FS.nextInode++,this.name=e,this.mode=I,this.rdev=B,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(t){t?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(t){t?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return FS.isDir(this.mode)}get isDevice(){return FS.isChrdev(this.mode)}},lookupPath(t,e={}){if(!t)return{path:"",node:null};e.follow_mount??(e.follow_mount=!0),PATH.isAbs(t)||(t=FS.cwd()+"/"+t);e:for(var I=0;I<40;I++){for(var B=t.split("/").filter(mr=>!!mr&&mr!=="."),tr=FS.root,rr="/",ir=0;ir<B.length;ir++){var lr=ir===B.length-1;if(lr&&e.parent)break;if(B[ir]===".."){rr=PATH.dirname(rr),tr=tr.parent;continue}rr=PATH.join2(rr,B[ir]);try{tr=FS.lookupNode(tr,B[ir])}catch(mr){if(mr?.errno===44&&lr&&e.noent_okay)return{path:rr};throw mr}if(FS.isMountpoint(tr)&&(!lr||e.follow_mount)&&(tr=tr.mounted.root),FS.isLink(tr.mode)&&(!lr||e.follow)){if(!tr.node_ops.readlink)throw new FS.ErrnoError(52);var dr=tr.node_ops.readlink(tr);PATH.isAbs(dr)||(dr=PATH.dirname(rr)+"/"+dr),t=dr+"/"+B.slice(ir+1).join("/");continue e}}return{path:rr,node:tr}}throw new FS.ErrnoError(32)},getPath(t){for(var e;;){if(FS.isRoot(t)){var I=t.mount.mountpoint;return e?I[I.length-1]!=="/"?`${I}/${e}`:I+e:I}e=e?`${t.name}/${e}`:t.name,t=t.parent}},hashName(t,e){for(var I=0,B=0;B<e.length;B++)I=(I<<5)-I+e.charCodeAt(B)|0;return(t+I>>>0)%FS.nameTable.length},hashAddNode(t){var e=FS.hashName(t.parent.id,t.name);t.name_next=FS.nameTable[e],FS.nameTable[e]=t},hashRemoveNode(t){var e=FS.hashName(t.parent.id,t.name);if(FS.nameTable[e]===t)FS.nameTable[e]=t.name_next;else for(var I=FS.nameTable[e];I;){if(I.name_next===t){I.name_next=t.name_next;break}I=I.name_next}},lookupNode(t,e){var I=FS.mayLookup(t);if(I)throw new FS.ErrnoError(I);for(var B=FS.hashName(t.id,e),tr=FS.nameTable[B];tr;tr=tr.name_next){var rr=tr.name;if(tr.parent.id===t.id&&rr===e)return tr}return FS.lookup(t,e)},createNode(t,e,I,B){var tr=new FS.FSNode(t,e,I,B);return FS.hashAddNode(tr),tr},destroyNode(t){FS.hashRemoveNode(t)},isRoot(t){return t===t.parent},isMountpoint(t){return!!t.mounted},isFile(t){return(t&61440)===32768},isDir(t){return(t&61440)===16384},isLink(t){return(t&61440)===40960},isChrdev(t){return(t&61440)===8192},isBlkdev(t){return(t&61440)===24576},isFIFO(t){return(t&61440)===4096},isSocket(t){return(t&49152)===49152},flagsToPermissionString(t){var e=["r","w","rw"][t&3];return t&512&&(e+="w"),e},nodePermissions(t,e){return FS.ignorePermissions?0:e.includes("r")&&!(t.mode&292)||e.includes("w")&&!(t.mode&146)||e.includes("x")&&!(t.mode&73)?2:0},mayLookup(t){if(!FS.isDir(t.mode))return 54;var e=FS.nodePermissions(t,"x");return e||(t.node_ops.lookup?0:2)},mayCreate(t,e){if(!FS.isDir(t.mode))return 54;try{var I=FS.lookupNode(t,e);return 20}catch{}return FS.nodePermissions(t,"wx")},mayDelete(t,e,I){var B;try{B=FS.lookupNode(t,e)}catch(rr){return rr.errno}var tr=FS.nodePermissions(t,"wx");if(tr)return tr;if(I){if(!FS.isDir(B.mode))return 54;if(FS.isRoot(B)||FS.getPath(B)===FS.cwd())return 10}else if(FS.isDir(B.mode))return 31;return 0},mayOpen(t,e){return t?FS.isLink(t.mode)?32:FS.isDir(t.mode)&&(FS.flagsToPermissionString(e)!=="r"||e&512)?31:FS.nodePermissions(t,FS.flagsToPermissionString(e)):44},MAX_OPEN_FDS:4096,nextfd(){for(var t=0;t<=FS.MAX_OPEN_FDS;t++)if(!FS.streams[t])return t;throw new FS.ErrnoError(33)},getStreamChecked(t){var e=FS.getStream(t);if(!e)throw new FS.ErrnoError(8);return e},getStream:t=>FS.streams[t],createStream(t,e=-1){return t=Object.assign(new FS.FSStream,t),e==-1&&(e=FS.nextfd()),t.fd=e,FS.streams[e]=t,t},closeStream(t){FS.streams[t]=null},dupStream(t,e=-1){var I=FS.createStream(t,e);return I.stream_ops?.dup?.(I),I},chrdev_stream_ops:{open(t){var e=FS.getDevice(t.node.rdev);t.stream_ops=e.stream_ops,t.stream_ops.open?.(t)},llseek(){throw new FS.ErrnoError(70)}},major:t=>t>>8,minor:t=>t&255,makedev:(t,e)=>t<<8|e,registerDevice(t,e){FS.devices[t]={stream_ops:e}},getDevice:t=>FS.devices[t],getMounts(t){for(var e=[],I=[t];I.length;){var B=I.pop();e.push(B),I.push(...B.mounts)}return e},syncfs(t,e){typeof t=="function"&&(e=t,t=!1),FS.syncFSRequests++,FS.syncFSRequests>1&&err(`warning: ${FS.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var I=FS.getMounts(FS.root.mount),B=0;function tr(ir){return FS.syncFSRequests--,e(ir)}function rr(ir){if(ir)return rr.errored?void 0:(rr.errored=!0,tr(ir));++B>=I.length&&tr(null)}I.forEach(ir=>{if(!ir.type.syncfs)return rr(null);ir.type.syncfs(ir,t,rr)})},mount(t,e,I){var B=I==="/",tr=!I,rr;if(B&&FS.root)throw new FS.ErrnoError(10);if(!B&&!tr){var ir=FS.lookupPath(I,{follow_mount:!1});if(I=ir.path,rr=ir.node,FS.isMountpoint(rr))throw new FS.ErrnoError(10);if(!FS.isDir(rr.mode))throw new FS.ErrnoError(54)}var lr={type:t,opts:e,mountpoint:I,mounts:[]},dr=t.mount(lr);return dr.mount=lr,lr.root=dr,B?FS.root=dr:rr&&(rr.mounted=lr,rr.mount&&rr.mount.mounts.push(lr)),dr},unmount(t){var e=FS.lookupPath(t,{follow_mount:!1});if(!FS.isMountpoint(e.node))throw new FS.ErrnoError(28);var I=e.node,B=I.mounted,tr=FS.getMounts(B);Object.keys(FS.nameTable).forEach(ir=>{for(var lr=FS.nameTable[ir];lr;){var dr=lr.name_next;tr.includes(lr.mount)&&FS.destroyNode(lr),lr=dr}}),I.mounted=null;var rr=I.mount.mounts.indexOf(B);I.mount.mounts.splice(rr,1)},lookup(t,e){return t.node_ops.lookup(t,e)},mknod(t,e,I){var B=FS.lookupPath(t,{parent:!0}),tr=B.node,rr=PATH.basename(t);if(!rr||rr==="."||rr==="..")throw new FS.ErrnoError(28);var ir=FS.mayCreate(tr,rr);if(ir)throw new FS.ErrnoError(ir);if(!tr.node_ops.mknod)throw new FS.ErrnoError(63);return tr.node_ops.mknod(tr,rr,e,I)},statfs(t){var e={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:FS.nextInode,ffree:FS.nextInode-1,fsid:42,flags:2,namelen:255},I=FS.lookupPath(t,{follow:!0}).node;return I?.node_ops.statfs&&Object.assign(e,I.node_ops.statfs(I.mount.opts.root)),e},create(t,e=438){return e&=4095,e|=32768,FS.mknod(t,e,0)},mkdir(t,e=511){return e&=1023,e|=16384,FS.mknod(t,e,0)},mkdirTree(t,e){for(var I=t.split("/"),B="",tr=0;tr<I.length;++tr)if(I[tr]){B+="/"+I[tr];try{FS.mkdir(B,e)}catch(rr){if(rr.errno!=20)throw rr}}},mkdev(t,e,I){return typeof I>"u"&&(I=e,e=438),e|=8192,FS.mknod(t,e,I)},symlink(t,e){if(!PATH_FS.resolve(t))throw new FS.ErrnoError(44);var I=FS.lookupPath(e,{parent:!0}),B=I.node;if(!B)throw new FS.ErrnoError(44);var tr=PATH.basename(e),rr=FS.mayCreate(B,tr);if(rr)throw new FS.ErrnoError(rr);if(!B.node_ops.symlink)throw new FS.ErrnoError(63);return B.node_ops.symlink(B,tr,t)},rename(t,e){var I=PATH.dirname(t),B=PATH.dirname(e),tr=PATH.basename(t),rr=PATH.basename(e),ir,lr,dr;if(ir=FS.lookupPath(t,{parent:!0}),lr=ir.node,ir=FS.lookupPath(e,{parent:!0}),dr=ir.node,!lr||!dr)throw new FS.ErrnoError(44);if(lr.mount!==dr.mount)throw new FS.ErrnoError(75);var mr=FS.lookupNode(lr,tr),hr=PATH_FS.relative(t,B);if(hr.charAt(0)!==".")throw new FS.ErrnoError(28);if(hr=PATH_FS.relative(e,I),hr.charAt(0)!==".")throw new FS.ErrnoError(55);var fr;try{fr=FS.lookupNode(dr,rr)}catch{}if(mr!==fr){var _r=FS.isDir(mr.mode),wr=FS.mayDelete(lr,tr,_r);if(wr)throw new FS.ErrnoError(wr);if(wr=fr?FS.mayDelete(dr,rr,_r):FS.mayCreate(dr,rr),wr)throw new FS.ErrnoError(wr);if(!lr.node_ops.rename)throw new FS.ErrnoError(63);if(FS.isMountpoint(mr)||fr&&FS.isMountpoint(fr))throw new FS.ErrnoError(10);if(dr!==lr&&(wr=FS.nodePermissions(lr,"w"),wr))throw new FS.ErrnoError(wr);FS.hashRemoveNode(mr);try{lr.node_ops.rename(mr,dr,rr),mr.parent=dr}catch(gr){throw gr}finally{FS.hashAddNode(mr)}}},rmdir(t){var e=FS.lookupPath(t,{parent:!0}),I=e.node,B=PATH.basename(t),tr=FS.lookupNode(I,B),rr=FS.mayDelete(I,B,!0);if(rr)throw new FS.ErrnoError(rr);if(!I.node_ops.rmdir)throw new FS.ErrnoError(63);if(FS.isMountpoint(tr))throw new FS.ErrnoError(10);I.node_ops.rmdir(I,B),FS.destroyNode(tr)},readdir(t){var e=FS.lookupPath(t,{follow:!0}),I=e.node;if(!I.node_ops.readdir)throw new FS.ErrnoError(54);return I.node_ops.readdir(I)},unlink(t){var e=FS.lookupPath(t,{parent:!0}),I=e.node;if(!I)throw new FS.ErrnoError(44);var B=PATH.basename(t),tr=FS.lookupNode(I,B),rr=FS.mayDelete(I,B,!1);if(rr)throw new FS.ErrnoError(rr);if(!I.node_ops.unlink)throw new FS.ErrnoError(63);if(FS.isMountpoint(tr))throw new FS.ErrnoError(10);I.node_ops.unlink(I,B),FS.destroyNode(tr)},readlink(t){var e=FS.lookupPath(t),I=e.node;if(!I)throw new FS.ErrnoError(44);if(!I.node_ops.readlink)throw new FS.ErrnoError(28);return I.node_ops.readlink(I)},stat(t,e){var I=FS.lookupPath(t,{follow:!e}),B=I.node;if(!B)throw new FS.ErrnoError(44);if(!B.node_ops.getattr)throw new FS.ErrnoError(63);return B.node_ops.getattr(B)},lstat(t){return FS.stat(t,!0)},chmod(t,e,I){var B;if(typeof t=="string"){var tr=FS.lookupPath(t,{follow:!I});B=tr.node}else B=t;if(!B.node_ops.setattr)throw new FS.ErrnoError(63);B.node_ops.setattr(B,{mode:e&4095|B.mode&-4096,ctime:Date.now()})},lchmod(t,e){FS.chmod(t,e,!0)},fchmod(t,e){var I=FS.getStreamChecked(t);FS.chmod(I.node,e)},chown(t,e,I,B){var tr;if(typeof t=="string"){var rr=FS.lookupPath(t,{follow:!B});tr=rr.node}else tr=t;if(!tr.node_ops.setattr)throw new FS.ErrnoError(63);tr.node_ops.setattr(tr,{timestamp:Date.now()})},lchown(t,e,I){FS.chown(t,e,I,!0)},fchown(t,e,I){var B=FS.getStreamChecked(t);FS.chown(B.node,e,I)},truncate(t,e){if(e<0)throw new FS.ErrnoError(28);var I;if(typeof t=="string"){var B=FS.lookupPath(t,{follow:!0});I=B.node}else I=t;if(!I.node_ops.setattr)throw new FS.ErrnoError(63);if(FS.isDir(I.mode))throw new FS.ErrnoError(31);if(!FS.isFile(I.mode))throw new FS.ErrnoError(28);var tr=FS.nodePermissions(I,"w");if(tr)throw new FS.ErrnoError(tr);I.node_ops.setattr(I,{size:e,timestamp:Date.now()})},ftruncate(t,e){var I=FS.getStreamChecked(t);if(!(I.flags&2097155))throw new FS.ErrnoError(28);FS.truncate(I.node,e)},utime(t,e,I){var B=FS.lookupPath(t,{follow:!0}),tr=B.node;tr.node_ops.setattr(tr,{atime:e,mtime:I})},open(t,e,I=438){if(t==="")throw new FS.ErrnoError(44);e=typeof e=="string"?FS_modeStringToFlags(e):e,e&64?I=I&4095|32768:I=0;var B;if(typeof t=="object")B=t;else{var tr=FS.lookupPath(t,{follow:!(e&131072),noent_okay:!0});B=tr.node,t=tr.path}var rr=!1;if(e&64)if(B){if(e&128)throw new FS.ErrnoError(20)}else B=FS.mknod(t,I,0),rr=!0;if(!B)throw new FS.ErrnoError(44);if(FS.isChrdev(B.mode)&&(e&=-513),e&65536&&!FS.isDir(B.mode))throw new FS.ErrnoError(54);if(!rr){var ir=FS.mayOpen(B,e);if(ir)throw new FS.ErrnoError(ir)}e&512&&!rr&&FS.truncate(B,0),e&=-131713;var lr=FS.createStream({node:B,path:FS.getPath(B),flags:e,seekable:!0,position:0,stream_ops:B.stream_ops,ungotten:[],error:!1});return lr.stream_ops.open&&lr.stream_ops.open(lr),Module.logReadFiles&&!(e&1)&&(t in FS.readFiles||(FS.readFiles[t]=1)),lr},close(t){if(FS.isClosed(t))throw new FS.ErrnoError(8);t.getdents&&(t.getdents=null);try{t.stream_ops.close&&t.stream_ops.close(t)}catch(e){throw e}finally{FS.closeStream(t.fd)}t.fd=null},isClosed(t){return t.fd===null},llseek(t,e,I){if(FS.isClosed(t))throw new FS.ErrnoError(8);if(!t.seekable||!t.stream_ops.llseek)throw new FS.ErrnoError(70);if(I!=0&&I!=1&&I!=2)throw new FS.ErrnoError(28);return t.position=t.stream_ops.llseek(t,e,I),t.ungotten=[],t.position},read(t,e,I,B,tr){if(B<0||tr<0)throw new FS.ErrnoError(28);if(FS.isClosed(t))throw new FS.ErrnoError(8);if((t.flags&2097155)===1)throw new FS.ErrnoError(8);if(FS.isDir(t.node.mode))throw new FS.ErrnoError(31);if(!t.stream_ops.read)throw new FS.ErrnoError(28);var rr=typeof tr<"u";if(!rr)tr=t.position;else if(!t.seekable)throw new FS.ErrnoError(70);var ir=t.stream_ops.read(t,e,I,B,tr);return rr||(t.position+=ir),ir},write(t,e,I,B,tr,rr){if(B<0||tr<0)throw new FS.ErrnoError(28);if(FS.isClosed(t))throw new FS.ErrnoError(8);if(!(t.flags&2097155))throw new FS.ErrnoError(8);if(FS.isDir(t.node.mode))throw new FS.ErrnoError(31);if(!t.stream_ops.write)throw new FS.ErrnoError(28);t.seekable&&t.flags&1024&&FS.llseek(t,0,2);var ir=typeof tr<"u";if(!ir)tr=t.position;else if(!t.seekable)throw new FS.ErrnoError(70);var lr=t.stream_ops.write(t,e,I,B,tr,rr);return ir||(t.position+=lr),lr},allocate(t,e,I){if(FS.isClosed(t))throw new FS.ErrnoError(8);if(e<0||I<=0)throw new FS.ErrnoError(28);if(!(t.flags&2097155))throw new FS.ErrnoError(8);if(!FS.isFile(t.node.mode)&&!FS.isDir(t.node.mode))throw new FS.ErrnoError(43);if(!t.stream_ops.allocate)throw new FS.ErrnoError(138);t.stream_ops.allocate(t,e,I)},mmap(t,e,I,B,tr){if(B&2&&!(tr&2)&&(t.flags&2097155)!==2)throw new FS.ErrnoError(2);if((t.flags&2097155)===1)throw new FS.ErrnoError(2);if(!t.stream_ops.mmap)throw new FS.ErrnoError(43);if(!e)throw new FS.ErrnoError(28);return t.stream_ops.mmap(t,e,I,B,tr)},msync(t,e,I,B,tr){return t.stream_ops.msync?t.stream_ops.msync(t,e,I,B,tr):0},ioctl(t,e,I){if(!t.stream_ops.ioctl)throw new FS.ErrnoError(59);return t.stream_ops.ioctl(t,e,I)},readFile(t,e={}){if(e.flags=e.flags||0,e.encoding=e.encoding||"binary",e.encoding!=="utf8"&&e.encoding!=="binary")throw new Error(`Invalid encoding type "${e.encoding}"`);var I,B=FS.open(t,e.flags),tr=FS.stat(t),rr=tr.size,ir=new Uint8Array(rr);return FS.read(B,ir,0,rr,0),e.encoding==="utf8"?I=UTF8ArrayToString(ir):e.encoding==="binary"&&(I=ir),FS.close(B),I},writeFile(t,e,I={}){I.flags=I.flags||577;var B=FS.open(t,I.flags,I.mode);if(typeof e=="string"){var tr=new Uint8Array(lengthBytesUTF8(e)+1),rr=stringToUTF8Array(e,tr,0,tr.length);FS.write(B,tr,0,rr,void 0,I.canOwn)}else if(ArrayBuffer.isView(e))FS.write(B,e,0,e.byteLength,void 0,I.canOwn);else throw new Error("Unsupported data type");FS.close(B)},cwd:()=>FS.currentPath,chdir(t){var e=FS.lookupPath(t,{follow:!0});if(e.node===null)throw new FS.ErrnoError(44);if(!FS.isDir(e.node.mode))throw new FS.ErrnoError(54);var I=FS.nodePermissions(e.node,"x");if(I)throw new FS.ErrnoError(I);FS.currentPath=e.path},createDefaultDirectories(){FS.mkdir("/tmp"),FS.mkdir("/home"),FS.mkdir("/home/web_user")},createDefaultDevices(){FS.mkdir("/dev"),FS.registerDevice(FS.makedev(1,3),{read:()=>0,write:(B,tr,rr,ir,lr)=>ir,llseek:()=>0}),FS.mkdev("/dev/null",FS.makedev(1,3)),TTY.register(FS.makedev(5,0),TTY.default_tty_ops),TTY.register(FS.makedev(6,0),TTY.default_tty1_ops),FS.mkdev("/dev/tty",FS.makedev(5,0)),FS.mkdev("/dev/tty1",FS.makedev(6,0));var t=new Uint8Array(1024),e=0,I=()=>(e===0&&(e=randomFill(t).byteLength),t[--e]);FS.createDevice("/dev","random",I),FS.createDevice("/dev","urandom",I),FS.mkdir("/dev/shm"),FS.mkdir("/dev/shm/tmp")},createSpecialDirectories(){FS.mkdir("/proc");var t=FS.mkdir("/proc/self");FS.mkdir("/proc/self/fd"),FS.mount({mount(){var e=FS.createNode(t,"fd",16895,73);return e.stream_ops={llseek:MEMFS.stream_ops.llseek},e.node_ops={lookup(I,B){var tr=+B,rr=FS.getStreamChecked(tr),ir={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>rr.path},id:tr+1};return ir.parent=ir,ir},readdir(){return Array.from(FS.streams.entries()).filter(([I,B])=>B).map(([I,B])=>I.toString())}},e}},{},"/proc/self/fd")},createStandardStreams(t,e,I){t?FS.createDevice("/dev","stdin",t):FS.symlink("/dev/tty","/dev/stdin"),e?FS.createDevice("/dev","stdout",null,e):FS.symlink("/dev/tty","/dev/stdout"),I?FS.createDevice("/dev","stderr",null,I):FS.symlink("/dev/tty1","/dev/stderr"),FS.open("/dev/stdin",0),FS.open("/dev/stdout",1),FS.open("/dev/stderr",1)},staticInit(){FS.nameTable=new Array(4096),FS.mount(MEMFS,{},"/"),FS.createDefaultDirectories(),FS.createDefaultDevices(),FS.createSpecialDirectories(),FS.filesystems={MEMFS,IDBFS,NODEFS}},init(t,e,I){FS.initialized=!0,t??(t=Module.stdin),e??(e=Module.stdout),I??(I=Module.stderr),FS.createStandardStreams(t,e,I)},quit(){FS.initialized=!1,_fflush(0);for(var t=0;t<FS.streams.length;t++){var e=FS.streams[t];e&&FS.close(e)}},findObject(t,e){var I=FS.analyzePath(t,e);return I.exists?I.object:null},analyzePath(t,e){try{var I=FS.lookupPath(t,{follow:!e});t=I.path}catch{}var B={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var I=FS.lookupPath(t,{parent:!0});B.parentExists=!0,B.parentPath=I.path,B.parentObject=I.node,B.name=PATH.basename(t),I=FS.lookupPath(t,{follow:!e}),B.exists=!0,B.path=I.path,B.object=I.node,B.name=I.node.name,B.isRoot=I.path==="/"}catch(tr){B.error=tr.errno}return B},createPath(t,e,I,B){t=typeof t=="string"?t:FS.getPath(t);for(var tr=e.split("/").reverse();tr.length;){var rr=tr.pop();if(rr){var ir=PATH.join2(t,rr);try{FS.mkdir(ir)}catch{}t=ir}}return ir},createFile(t,e,I,B,tr){var rr=PATH.join2(typeof t=="string"?t:FS.getPath(t),e),ir=FS_getMode(B,tr);return FS.create(rr,ir)},createDataFile(t,e,I,B,tr,rr){var ir=e;t&&(t=typeof t=="string"?t:FS.getPath(t),ir=e?PATH.join2(t,e):t);var lr=FS_getMode(B,tr),dr=FS.create(ir,lr);if(I){if(typeof I=="string"){for(var mr=new Array(I.length),hr=0,fr=I.length;hr<fr;++hr)mr[hr]=I.charCodeAt(hr);I=mr}FS.chmod(dr,lr|146);var _r=FS.open(dr,577);FS.write(_r,I,0,I.length,0,rr),FS.close(_r),FS.chmod(dr,lr)}},createDevice(t,e,I,B){var tr,rr=PATH.join2(typeof t=="string"?t:FS.getPath(t),e),ir=FS_getMode(!!I,!!B);(tr=FS.createDevice).major??(tr.major=64);var lr=FS.makedev(FS.createDevice.major++,0);return FS.registerDevice(lr,{open(dr){dr.seekable=!1},close(dr){B?.buffer?.length&&B(10)},read(dr,mr,hr,fr,_r){for(var wr=0,gr=0;gr<fr;gr++){var xr;try{xr=I()}catch{throw new FS.ErrnoError(29)}if(xr===void 0&&wr===0)throw new FS.ErrnoError(6);if(xr==null)break;wr++,mr[hr+gr]=xr}return wr&&(dr.node.atime=Date.now()),wr},write(dr,mr,hr,fr,_r){for(var wr=0;wr<fr;wr++)try{B(mr[hr+wr])}catch{throw new FS.ErrnoError(29)}return fr&&(dr.node.mtime=dr.node.ctime=Date.now()),wr}}),FS.mkdev(rr,ir,lr)},forceLoadFile(t){if(t.isDevice||t.isFolder||t.link||t.contents)return!0;if(typeof XMLHttpRequest<"u")throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");try{t.contents=readBinary(t.url),t.usedBytes=t.contents.length}catch{throw new FS.ErrnoError(29)}},createLazyFile(t,e,I,B,tr){class rr{constructor(){P$1(this,"lengthKnown",!1),P$1(this,"chunks",[])}get(wr){if(!(wr>this.length-1||wr<0)){var gr=wr%this.chunkSize,xr=wr/this.chunkSize|0;return this.getter(xr)[gr]}}setDataGetter(wr){this.getter=wr}cacheLength(){var wr=new XMLHttpRequest;if(wr.open("HEAD",I,!1),wr.send(null),!(wr.status>=200&&wr.status<300||wr.status===304))throw new Error("Couldn't load "+I+". Status: "+wr.status);var gr=Number(wr.getResponseHeader("Content-length")),xr,Mr=(xr=wr.getResponseHeader("Accept-Ranges"))&&xr==="bytes",Sr=(xr=wr.getResponseHeader("Content-Encoding"))&&xr==="gzip",yr=1024*1024;Mr||(yr=gr);var br=(Cr,Ar)=>{if(Cr>Ar)throw new Error("invalid range ("+Cr+", "+Ar+") or no bytes requested!");if(Ar>gr-1)throw new Error("only "+gr+" bytes available! programmer error!");var Ir=new XMLHttpRequest;if(Ir.open("GET",I,!1),gr!==yr&&Ir.setRequestHeader("Range","bytes="+Cr+"-"+Ar),Ir.responseType="arraybuffer",Ir.overrideMimeType&&Ir.overrideMimeType("text/plain; charset=x-user-defined"),Ir.send(null),!(Ir.status>=200&&Ir.status<300||Ir.status===304))throw new Error("Couldn't load "+I+". Status: "+Ir.status);return Ir.response!==void 0?new Uint8Array(Ir.response||[]):intArrayFromString(Ir.responseText||"")},vr=this;vr.setDataGetter(Cr=>{var Ar=Cr*yr,Ir=(Cr+1)*yr-1;if(Ir=Math.min(Ir,gr-1),typeof vr.chunks[Cr]>"u"&&(vr.chunks[Cr]=br(Ar,Ir)),typeof vr.chunks[Cr]>"u")throw new Error("doXHR failed!");return vr.chunks[Cr]}),(Sr||!gr)&&(yr=gr=1,gr=this.getter(0).length,yr=gr,out("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=gr,this._chunkSize=yr,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(typeof XMLHttpRequest<"u"){if(!ENVIRONMENT_IS_WORKER)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var ir=new rr,lr={isDevice:!1,contents:ir}}else var lr={isDevice:!1,url:I};var dr=FS.createFile(t,e,lr,B,tr);lr.contents?dr.contents=lr.contents:lr.url&&(dr.contents=null,dr.url=lr.url),Object.defineProperties(dr,{usedBytes:{get:function(){return this.contents.length}}});var mr={},hr=Object.keys(dr.stream_ops);hr.forEach(_r=>{var wr=dr.stream_ops[_r];mr[_r]=(...gr)=>(FS.forceLoadFile(dr),wr(...gr))});function fr(_r,wr,gr,xr,Mr){var Sr=_r.node.contents;if(Mr>=Sr.length)return 0;var yr=Math.min(Sr.length-Mr,xr);if(Sr.slice)for(var br=0;br<yr;br++)wr[gr+br]=Sr[Mr+br];else for(var br=0;br<yr;br++)wr[gr+br]=Sr.get(Mr+br);return yr}return mr.read=(_r,wr,gr,xr,Mr)=>(FS.forceLoadFile(dr),fr(_r,wr,gr,xr,Mr)),mr.mmap=(_r,wr,gr,xr,Mr)=>{FS.forceLoadFile(dr);var Sr=mmapAlloc(wr);if(!Sr)throw new FS.ErrnoError(48);return fr(_r,HEAP8,Sr,wr,gr),{ptr:Sr,allocated:!0}},dr.stream_ops=mr,dr}},SYSCALLS={DEFAULT_POLLMASK:5,calculateAt(t,e,I){if(PATH.isAbs(e))return e;var B;if(t===-100)B=FS.cwd();else{var tr=SYSCALLS.getStreamFromFD(t);B=tr.path}if(e.length==0){if(!I)throw new FS.ErrnoError(44);return B}return B+"/"+e},doStat(t,e,I){var B=t(e);HEAP32[I>>2]=B.dev,HEAP32[I+4>>2]=B.mode,HEAPU32[I+8>>2]=B.nlink,HEAP32[I+12>>2]=B.uid,HEAP32[I+16>>2]=B.gid,HEAP32[I+20>>2]=B.rdev,HEAP64[I+24>>3]=BigInt(B.size),HEAP32[I+32>>2]=4096,HEAP32[I+36>>2]=B.blocks;var tr=B.atime.getTime(),rr=B.mtime.getTime(),ir=B.ctime.getTime();return HEAP64[I+40>>3]=BigInt(Math.floor(tr/1e3)),HEAPU32[I+48>>2]=tr%1e3*1e3*1e3,HEAP64[I+56>>3]=BigInt(Math.floor(rr/1e3)),HEAPU32[I+64>>2]=rr%1e3*1e3*1e3,HEAP64[I+72>>3]=BigInt(Math.floor(ir/1e3)),HEAPU32[I+80>>2]=ir%1e3*1e3*1e3,HEAP64[I+88>>3]=BigInt(B.ino),0},doMsync(t,e,I,B,tr){if(!FS.isFile(e.node.mode))throw new FS.ErrnoError(43);if(B&2)return 0;var rr=HEAPU8.slice(t,t+I);FS.msync(e,rr,tr,I,B)},getStreamFromFD(t){var e=FS.getStreamChecked(t);return e},varargs:void 0,getStr(t){var e=UTF8ToString(t);return e}},___syscall__newselect=function(t,e,I,B,tr){try{for(var rr=0,ir=e?HEAP32[e>>2]:0,lr=e?HEAP32[e+4>>2]:0,dr=I?HEAP32[I>>2]:0,mr=I?HEAP32[I+4>>2]:0,hr=B?HEAP32[B>>2]:0,fr=B?HEAP32[B+4>>2]:0,_r=0,wr=0,gr=0,xr=0,Mr=0,Sr=0,yr=(e?HEAP32[e>>2]:0)|(I?HEAP32[I>>2]:0)|(B?HEAP32[B>>2]:0),br=(e?HEAP32[e+4>>2]:0)|(I?HEAP32[I+4>>2]:0)|(B?HEAP32[B+4>>2]:0),vr=(Ur,Pr,kr,Or)=>Ur<32?Pr&Or:kr&Or,Cr=0;Cr<t;Cr++){var Ar=1<<Cr%32;if(vr(Cr,yr,br,Ar)){var Ir=SYSCALLS.getStreamFromFD(Cr),Dr=SYSCALLS.DEFAULT_POLLMASK;if(Ir.stream_ops.poll){var Fr=-1;if(tr){var zr=e?HEAP32[tr>>2]:0,Gr=e?HEAP32[tr+4>>2]:0;Fr=(zr+Gr/1e6)*1e3}Dr=Ir.stream_ops.poll(Ir,Fr)}Dr&1&&vr(Cr,ir,lr,Ar)&&(Cr<32?_r=_r|Ar:wr=wr|Ar,rr++),Dr&4&&vr(Cr,dr,mr,Ar)&&(Cr<32?gr=gr|Ar:xr=xr|Ar,rr++),Dr&2&&vr(Cr,hr,fr,Ar)&&(Cr<32?Mr=Mr|Ar:Sr=Sr|Ar,rr++)}}return e&&(HEAP32[e>>2]=_r,HEAP32[e+4>>2]=wr),I&&(HEAP32[I>>2]=gr,HEAP32[I+4>>2]=xr),B&&(HEAP32[B>>2]=Mr,HEAP32[B+4>>2]=Sr),rr}catch(Ur){if(typeof FS>"u"||Ur.name!=="ErrnoError")throw Ur;return-Ur.errno}};___syscall__newselect.sig="iipppp";var SOCKFS={websocketArgs:{},callbacks:{},on(t,e){SOCKFS.callbacks[t]=e},emit(t,e){SOCKFS.callbacks[t]?.(e)},mount(t){return SOCKFS.websocketArgs=Module.websocket||{},(Module.websocket??(Module.websocket={})).on=SOCKFS.on,FS.createNode(null,"/",16895,0)},createSocket(t,e,I){e&=-526337;var B=e==1;if(B&&I&&I!=6)throw new FS.ErrnoError(66);var tr={family:t,type:e,protocol:I,server:null,error:null,peers:{},pending:[],recv_queue:[],sock_ops:SOCKFS.websocket_sock_ops},rr=SOCKFS.nextname(),ir=FS.createNode(SOCKFS.root,rr,49152,0);ir.sock=tr;var lr=FS.createStream({path:rr,node:ir,flags:2,seekable:!1,stream_ops:SOCKFS.stream_ops});return tr.stream=lr,tr},getSocket(t){var e=FS.getStream(t);return!e||!FS.isSocket(e.node.mode)?null:e.node.sock},stream_ops:{poll(t){var e=t.node.sock;return e.sock_ops.poll(e)},ioctl(t,e,I){var B=t.node.sock;return B.sock_ops.ioctl(B,e,I)},read(t,e,I,B,tr){var rr=t.node.sock,ir=rr.sock_ops.recvmsg(rr,B);return ir?(e.set(ir.buffer,I),ir.buffer.length):0},write(t,e,I,B,tr){var rr=t.node.sock;return rr.sock_ops.sendmsg(rr,e,I,B)},close(t){var e=t.node.sock;e.sock_ops.close(e)}},nextname(){return SOCKFS.nextname.current||(SOCKFS.nextname.current=0),`socket[${SOCKFS.nextname.current++}]`},websocket_sock_ops:{createPeer(t,e,I){var B;if(typeof e=="object"&&(B=e,e=null,I=null),B)if(B._socket)e=B._socket.remoteAddress,I=B._socket.remotePort;else{var tr=/ws[s]?:\/\/([^:]+):(\d+)/.exec(B.url);if(!tr)throw new Error("WebSocket URL must be in the format ws(s)://address:port");e=tr[1],I=parseInt(tr[2],10)}else try{var rr="ws:#".replace("#","//"),ir="binary",lr=void 0;if(SOCKFS.websocketArgs.url&&(rr=SOCKFS.websocketArgs.url),SOCKFS.websocketArgs.subprotocol?ir=SOCKFS.websocketArgs.subprotocol:SOCKFS.websocketArgs.subprotocol===null&&(ir="null"),rr==="ws://"||rr==="wss://"){var dr=e.split("/");rr=rr+dr[0]+":"+I+"/"+dr.slice(1).join("/")}ir!=="null"&&(ir=ir.replace(/^ +| +$/g,"").split(/ *, */),lr=ir);var mr;ENVIRONMENT_IS_NODE?mr=require("ws"):mr=WebSocket,B=new mr(rr,lr),B.binaryType="arraybuffer"}catch{throw new FS.ErrnoError(23)}var hr={addr:e,port:I,socket:B,msg_send_queue:[]};return SOCKFS.websocket_sock_ops.addPeer(t,hr),SOCKFS.websocket_sock_ops.handlePeerEvents(t,hr),t.type===2&&typeof t.sport<"u"&&hr.msg_send_queue.push(new Uint8Array([255,255,255,255,112,111,114,116,(t.sport&65280)>>8,t.sport&255])),hr},getPeer(t,e,I){return t.peers[e+":"+I]},addPeer(t,e){t.peers[e.addr+":"+e.port]=e},removePeer(t,e){delete t.peers[e.addr+":"+e.port]},handlePeerEvents(t,e){var I=!0,B=function(){t.connecting=!1,SOCKFS.emit("open",t.stream.fd);try{for(var rr=e.msg_send_queue.shift();rr;)e.socket.send(rr),rr=e.msg_send_queue.shift()}catch{e.socket.close()}};function tr(rr){if(typeof rr=="string"){var ir=new TextEncoder;rr=ir.encode(rr)}else{if(assert(rr.byteLength!==void 0),rr.byteLength==0)return;rr=new Uint8Array(rr)}var lr=I;if(I=!1,lr&&rr.length===10&&rr[0]===255&&rr[1]===255&&rr[2]===255&&rr[3]===255&&rr[4]===112&&rr[5]===111&&rr[6]===114&&rr[7]===116){var dr=rr[8]<<8|rr[9];SOCKFS.websocket_sock_ops.removePeer(t,e),e.port=dr,SOCKFS.websocket_sock_ops.addPeer(t,e);return}t.recv_queue.push({addr:e.addr,port:e.port,data:rr}),SOCKFS.emit("message",t.stream.fd)}ENVIRONMENT_IS_NODE?(e.socket.on("open",B),e.socket.on("message",function(rr,ir){ir&&tr(new Uint8Array(rr).buffer)}),e.socket.on("close",function(){SOCKFS.emit("close",t.stream.fd)}),e.socket.on("error",function(rr){t.error=14,SOCKFS.emit("error",[t.stream.fd,t.error,"ECONNREFUSED: Connection refused"])})):(e.socket.onopen=B,e.socket.onclose=function(){SOCKFS.emit("close",t.stream.fd)},e.socket.onmessage=function(rr){tr(rr.data)},e.socket.onerror=function(rr){t.error=14,SOCKFS.emit("error",[t.stream.fd,t.error,"ECONNREFUSED: Connection refused"])})},poll(t){if(t.type===1&&t.server)return t.pending.length?65:0;var e=0,I=t.type===1?SOCKFS.websocket_sock_ops.getPeer(t,t.daddr,t.dport):null;return(t.recv_queue.length||!I||I&&I.socket.readyState===I.socket.CLOSING||I&&I.socket.readyState===I.socket.CLOSED)&&(e|=65),(!I||I&&I.socket.readyState===I.socket.OPEN)&&(e|=4),(I&&I.socket.readyState===I.socket.CLOSING||I&&I.socket.readyState===I.socket.CLOSED)&&(t.connecting?e|=4:e|=16),e},ioctl(t,e,I){switch(e){case 21531:var B=0;return t.recv_queue.length&&(B=t.recv_queue[0].data.length),HEAP32[I>>2]=B,0;default:return 28}},close(t){if(t.server){try{t.server.close()}catch{}t.server=null}for(var e=Object.keys(t.peers),I=0;I<e.length;I++){var B=t.peers[e[I]];try{B.socket.close()}catch{}SOCKFS.websocket_sock_ops.removePeer(t,B)}return 0},bind(t,e,I){if(typeof t.saddr<"u"||typeof t.sport<"u")throw new FS.ErrnoError(28);if(t.saddr=e,t.sport=I,t.type===2){t.server&&(t.server.close(),t.server=null);try{t.sock_ops.listen(t,0)}catch(B){if(B.name!=="ErrnoError"||B.errno!==138)throw B}}},connect(t,e,I){if(t.server)throw new FS.ErrnoError(138);if(typeof t.daddr<"u"&&typeof t.dport<"u"){var B=SOCKFS.websocket_sock_ops.getPeer(t,t.daddr,t.dport);if(B)throw B.socket.readyState===B.socket.CONNECTING?new FS.ErrnoError(7):new FS.ErrnoError(30)}var tr=SOCKFS.websocket_sock_ops.createPeer(t,e,I);t.daddr=tr.addr,t.dport=tr.port,t.connecting=!0},listen(t,e){if(!ENVIRONMENT_IS_NODE)throw new FS.ErrnoError(138);if(t.server)throw new FS.ErrnoError(28);var I=require("ws").Server,B=t.saddr;t.server=new I({host:B,port:t.sport}),SOCKFS.emit("listen",t.stream.fd),t.server.on("connection",function(tr){if(t.type===1){var rr=SOCKFS.createSocket(t.family,t.type,t.protocol),ir=SOCKFS.websocket_sock_ops.createPeer(rr,tr);rr.daddr=ir.addr,rr.dport=ir.port,t.pending.push(rr),SOCKFS.emit("connection",rr.stream.fd)}else SOCKFS.websocket_sock_ops.createPeer(t,tr),SOCKFS.emit("connection",t.stream.fd)}),t.server.on("close",function(){SOCKFS.emit("close",t.stream.fd),t.server=null}),t.server.on("error",function(tr){t.error=23,SOCKFS.emit("error",[t.stream.fd,t.error,"EHOSTUNREACH: Host is unreachable"])})},accept(t){if(!t.server||!t.pending.length)throw new FS.ErrnoError(28);var e=t.pending.shift();return e.stream.flags=t.stream.flags,e},getname(t,e){var I,B;if(e){if(t.daddr===void 0||t.dport===void 0)throw new FS.ErrnoError(53);I=t.daddr,B=t.dport}else I=t.saddr||0,B=t.sport||0;return{addr:I,port:B}},sendmsg(t,e,I,B,tr,rr){if(t.type===2){if((tr===void 0||rr===void 0)&&(tr=t.daddr,rr=t.dport),tr===void 0||rr===void 0)throw new FS.ErrnoError(17)}else tr=t.daddr,rr=t.dport;var ir=SOCKFS.websocket_sock_ops.getPeer(t,tr,rr);if(t.type===1&&(!ir||ir.socket.readyState===ir.socket.CLOSING||ir.socket.readyState===ir.socket.CLOSED))throw new FS.ErrnoError(53);ArrayBuffer.isView(e)&&(I+=e.byteOffset,e=e.buffer);var lr=e.slice(I,I+B);if(!ir||ir.socket.readyState!==ir.socket.OPEN)return t.type===2&&(!ir||ir.socket.readyState===ir.socket.CLOSING||ir.socket.readyState===ir.socket.CLOSED)&&(ir=SOCKFS.websocket_sock_ops.createPeer(t,tr,rr)),ir.msg_send_queue.push(lr),B;try{return ir.socket.send(lr),B}catch{throw new FS.ErrnoError(28)}},recvmsg(t,e){if(t.type===1&&t.server)throw new FS.ErrnoError(53);var I=t.recv_queue.shift();if(!I){if(t.type===1){var B=SOCKFS.websocket_sock_ops.getPeer(t,t.daddr,t.dport);if(!B)throw new FS.ErrnoError(53);if(B.socket.readyState===B.socket.CLOSING||B.socket.readyState===B.socket.CLOSED)return null;throw new FS.ErrnoError(6)}throw new FS.ErrnoError(6)}var tr=I.data.byteLength||I.data.length,rr=I.data.byteOffset||0,ir=I.data.buffer||I.data,lr=Math.min(e,tr),dr={buffer:new Uint8Array(ir,rr,lr),addr:I.addr,port:I.port};if(t.type===1&&lr<tr){var mr=tr-lr;I.data=new Uint8Array(ir,rr+lr,mr),t.recv_queue.unshift(I)}return dr}}},getSocketFromFD=t=>{var e=SOCKFS.getSocket(t);if(!e)throw new FS.ErrnoError(8);return e},inetNtop4=t=>(t&255)+"."+(t>>8&255)+"."+(t>>16&255)+"."+(t>>24&255),inetNtop6=t=>{var e="",I=0,B=0,tr=0,rr=0,ir=0,lr=0,dr=[t[0]&65535,t[0]>>16,t[1]&65535,t[1]>>16,t[2]&65535,t[2]>>16,t[3]&65535,t[3]>>16],mr=!0,hr="";for(lr=0;lr<5;lr++)if(dr[lr]!==0){mr=!1;break}if(mr){if(hr=inetNtop4(dr[6]|dr[7]<<16),dr[5]===-1)return e="::ffff:",e+=hr,e;if(dr[5]===0)return e="::",hr==="0.0.0.0"&&(hr=""),hr==="0.0.0.1"&&(hr="1"),e+=hr,e}for(I=0;I<8;I++)dr[I]===0&&(I-tr>1&&(ir=0),tr=I,ir++),ir>B&&(B=ir,rr=I-B+1);for(I=0;I<8;I++){if(B>1&&dr[I]===0&&I>=rr&&I<rr+B){I===rr&&(e+=":",rr===0&&(e+=":"));continue}e+=Number(_ntohs(dr[I]&65535)).toString(16),e+=I<7?":":""}return e},readSockaddr=(t,e)=>{var I=HEAP16[t>>1],B=_ntohs(HEAPU16[t+2>>1]),tr;switch(I){case 2:if(e!==16)return{errno:28};tr=HEAP32[t+4>>2],tr=inetNtop4(tr);break;case 10:if(e!==28)return{errno:28};tr=[HEAP32[t+8>>2],HEAP32[t+12>>2],HEAP32[t+16>>2],HEAP32[t+20>>2]],tr=inetNtop6(tr);break;default:return{errno:5}}return{family:I,addr:tr,port:B}},inetPton4=t=>{for(var e=t.split("."),I=0;I<4;I++){var B=Number(e[I]);if(isNaN(B))return null;e[I]=B}return(e[0]|e[1]<<8|e[2]<<16|e[3]<<24)>>>0},jstoi_q=t=>parseInt(t),inetPton6=t=>{var e,I,B,tr,rr=/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i,ir=[];if(!rr.test(t))return null;if(t==="::")return[0,0,0,0,0,0,0,0];for(t.startsWith("::")?t=t.replace("::","Z:"):t=t.replace("::",":Z:"),t.indexOf(".")>0?(t=t.replace(new RegExp("[.]","g"),":"),e=t.split(":"),e[e.length-4]=jstoi_q(e[e.length-4])+jstoi_q(e[e.length-3])*256,e[e.length-3]=jstoi_q(e[e.length-2])+jstoi_q(e[e.length-1])*256,e=e.slice(0,e.length-2)):e=t.split(":"),B=0,tr=0,I=0;I<e.length;I++)if(typeof e[I]=="string")if(e[I]==="Z"){for(tr=0;tr<8-e.length+1;tr++)ir[I+tr]=0;B=tr-1}else ir[I+B]=_htons(parseInt(e[I],16));else ir[I+B]=e[I];return[ir[1]<<16|ir[0],ir[3]<<16|ir[2],ir[5]<<16|ir[4],ir[7]<<16|ir[6]]},DNS={address_map:{id:1,addrs:{},names:{}},lookup_name(t){var e=inetPton4(t);if(e!==null||(e=inetPton6(t),e!==null))return t;var I;if(DNS.address_map.addrs[t])I=DNS.address_map.addrs[t];else{var B=DNS.address_map.id++;assert(B<65535,"exceeded max address mappings of 65535"),I="172.29."+(B&255)+"."+(B&65280),DNS.address_map.names[I]=t,DNS.address_map.addrs[t]=I}return I},lookup_addr(t){return DNS.address_map.names[t]?DNS.address_map.names[t]:null}},getSocketAddress=(t,e)=>{var I=readSockaddr(t,e);if(I.errno)throw new FS.ErrnoError(I.errno);return I.addr=DNS.lookup_addr(I.addr)||I.addr,I};function ___syscall_bind(t,e,I,B,tr,rr){try{var ir=getSocketFromFD(t),lr=getSocketAddress(e,I);return ir.sock_ops.bind(ir,lr.addr,lr.port),0}catch(dr){if(typeof FS>"u"||dr.name!=="ErrnoError")throw dr;return-dr.errno}}___syscall_bind.sig="iippiii";function ___syscall_chdir(t){try{return t=SYSCALLS.getStr(t),FS.chdir(t),0}catch(e){if(typeof FS>"u"||e.name!=="ErrnoError")throw e;return-e.errno}}___syscall_chdir.sig="ip";function ___syscall_chmod(t,e){try{return t=SYSCALLS.getStr(t),FS.chmod(t,e),0}catch(I){if(typeof FS>"u"||I.name!=="ErrnoError")throw I;return-I.errno}}___syscall_chmod.sig="ipi";function ___syscall_connect(t,e,I,B,tr,rr){try{var ir=getSocketFromFD(t),lr=getSocketAddress(e,I);return ir.sock_ops.connect(ir,lr.addr,lr.port),0}catch(dr){if(typeof FS>"u"||dr.name!=="ErrnoError")throw dr;return-dr.errno}}___syscall_connect.sig="iippiii";function ___syscall_dup(t){try{var e=SYSCALLS.getStreamFromFD(t);return FS.dupStream(e).fd}catch(I){if(typeof FS>"u"||I.name!=="ErrnoError")throw I;return-I.errno}}___syscall_dup.sig="ii";function ___syscall_dup3(t,e,I){try{var B=SYSCALLS.getStreamFromFD(t);if(B.fd===e)return-28;if(e<0||e>=FS.MAX_OPEN_FDS)return-8;var tr=FS.getStream(e);return tr&&FS.close(tr),FS.dupStream(B,e).fd}catch(rr){if(typeof FS>"u"||rr.name!=="ErrnoError")throw rr;return-rr.errno}}___syscall_dup3.sig="iiii";function ___syscall_faccessat(t,e,I,B){try{if(e=SYSCALLS.getStr(e),e=SYSCALLS.calculateAt(t,e),I&-8)return-28;var tr=FS.lookupPath(e,{follow:!0}),rr=tr.node;if(!rr)return-44;var ir="";return I&4&&(ir+="r"),I&2&&(ir+="w"),I&1&&(ir+="x"),ir&&FS.nodePermissions(rr,ir)?-2:0}catch(lr){if(typeof FS>"u"||lr.name!=="ErrnoError")throw lr;return-lr.errno}}___syscall_faccessat.sig="iipii";var ___syscall_fadvise64=(t,e,I,B)=>0;___syscall_fadvise64.sig="iijji";var INT53_MAX=9007199254740992,INT53_MIN=-9007199254740992,bigintToI53Checked=t=>t<INT53_MIN||t>INT53_MAX?NaN:Number(t);function ___syscall_fallocate(t,e,I,B){I=bigintToI53Checked(I),B=bigintToI53Checked(B);try{if(isNaN(I))return 61;var tr=SYSCALLS.getStreamFromFD(t);return FS.allocate(tr,I,B),0}catch(rr){if(typeof FS>"u"||rr.name!=="ErrnoError")throw rr;return-rr.errno}}___syscall_fallocate.sig="iiijj";var syscallGetVarargI=()=>{var t=HEAP32[+SYSCALLS.varargs>>2];return SYSCALLS.varargs+=4,t},syscallGetVarargP=syscallGetVarargI;function ___syscall_fcntl64(t,e,I){SYSCALLS.varargs=I;try{var B=SYSCALLS.getStreamFromFD(t);switch(e){case 0:{var tr=syscallGetVarargI();if(tr<0)return-28;for(;FS.streams[tr];)tr++;var rr;return rr=FS.dupStream(B,tr),rr.fd}case 1:case 2:return 0;case 3:return B.flags;case 4:{var tr=syscallGetVarargI();return B.flags|=tr,0}case 12:{var tr=syscallGetVarargP(),ir=0;return HEAP16[tr+ir>>1]=2,0}case 13:case 14:return 0}return-28}catch(lr){if(typeof FS>"u"||lr.name!=="ErrnoError")throw lr;return-lr.errno}}___syscall_fcntl64.sig="iiip";function ___syscall_fdatasync(t){try{var e=SYSCALLS.getStreamFromFD(t);return 0}catch(I){if(typeof FS>"u"||I.name!=="ErrnoError")throw I;return-I.errno}}___syscall_fdatasync.sig="ii";function ___syscall_fstat64(t,e){try{var I=SYSCALLS.getStreamFromFD(t);return SYSCALLS.doStat(FS.stat,I.path,e)}catch(B){if(typeof FS>"u"||B.name!=="ErrnoError")throw B;return-B.errno}}___syscall_fstat64.sig="iip";function ___syscall_ftruncate64(t,e){e=bigintToI53Checked(e);try{return isNaN(e)?61:(FS.ftruncate(t,e),0)}catch(I){if(typeof FS>"u"||I.name!=="ErrnoError")throw I;return-I.errno}}___syscall_ftruncate64.sig="iij";var stringToUTF8=(t,e,I)=>stringToUTF8Array(t,HEAPU8,e,I);function ___syscall_getcwd(t,e){try{if(e===0)return-28;var I=FS.cwd(),B=lengthBytesUTF8(I)+1;return e<B?-68:(stringToUTF8(I,t,e),B)}catch(tr){if(typeof FS>"u"||tr.name!=="ErrnoError")throw tr;return-tr.errno}}___syscall_getcwd.sig="ipp";function ___syscall_getdents64(t,e,I){try{var B=SYSCALLS.getStreamFromFD(t);B.getdents||(B.getdents=FS.readdir(B.path));for(var tr=280,rr=0,ir=FS.llseek(B,0,1),lr=Math.floor(ir/tr),dr=Math.min(B.getdents.length,lr+Math.floor(I/tr)),mr=lr;mr<dr;mr++){var hr,fr,_r=B.getdents[mr];if(_r===".")hr=B.node.id,fr=4;else if(_r===".."){var wr=FS.lookupPath(B.path,{parent:!0});hr=wr.node.id,fr=4}else{var gr;try{gr=FS.lookupNode(B.node,_r)}catch(xr){if(xr?.errno===28)continue;throw xr}hr=gr.id,fr=FS.isChrdev(gr.mode)?2:FS.isDir(gr.mode)?4:FS.isLink(gr.mode)?10:8}HEAP64[e+rr>>3]=BigInt(hr),HEAP64[e+rr+8>>3]=BigInt((mr+1)*tr),HEAP16[e+rr+16>>1]=280,HEAP8[e+rr+18]=fr,stringToUTF8(_r,e+rr+19,256),rr+=tr}return FS.llseek(B,mr*tr,0),rr}catch(xr){if(typeof FS>"u"||xr.name!=="ErrnoError")throw xr;return-xr.errno}}___syscall_getdents64.sig="iipp";var writeSockaddr=(t,e,I,B,tr)=>{switch(e){case 2:I=inetPton4(I),zeroMemory(t,16),tr&&(HEAP32[tr>>2]=16),HEAP16[t>>1]=e,HEAP32[t+4>>2]=I,HEAP16[t+2>>1]=_htons(B);break;case 10:I=inetPton6(I),zeroMemory(t,28),tr&&(HEAP32[tr>>2]=28),HEAP32[t>>2]=e,HEAP32[t+8>>2]=I[0],HEAP32[t+12>>2]=I[1],HEAP32[t+16>>2]=I[2],HEAP32[t+20>>2]=I[3],HEAP16[t+2>>1]=_htons(B);break;default:return 5}return 0};function ___syscall_getsockname(t,e,I,B,tr,rr){try{var ir=getSocketFromFD(t),lr=writeSockaddr(e,ir.family,DNS.lookup_name(ir.saddr||"0.0.0.0"),ir.sport,I);return 0}catch(dr){if(typeof FS>"u"||dr.name!=="ErrnoError")throw dr;return-dr.errno}}___syscall_getsockname.sig="iippiii";function ___syscall_getsockopt(t,e,I,B,tr,rr){try{var ir=getSocketFromFD(t);return e===1&&I===4?(HEAP32[B>>2]=ir.error,HEAP32[tr>>2]=4,ir.error=null,0):-50}catch(lr){if(typeof FS>"u"||lr.name!=="ErrnoError")throw lr;return-lr.errno}}___syscall_getsockopt.sig="iiiippi";function ___syscall_ioctl(t,e,I){SYSCALLS.varargs=I;try{var B=SYSCALLS.getStreamFromFD(t);switch(e){case 21509:return B.tty?0:-59;case 21505:{if(!B.tty)return-59;if(B.tty.ops.ioctl_tcgets){var tr=B.tty.ops.ioctl_tcgets(B),rr=syscallGetVarargP();HEAP32[rr>>2]=tr.c_iflag||0,HEAP32[rr+4>>2]=tr.c_oflag||0,HEAP32[rr+8>>2]=tr.c_cflag||0,HEAP32[rr+12>>2]=tr.c_lflag||0;for(var ir=0;ir<32;ir++)HEAP8[rr+ir+17]=tr.c_cc[ir]||0;return 0}return 0}case 21510:case 21511:case 21512:return B.tty?0:-59;case 21506:case 21507:case 21508:{if(!B.tty)return-59;if(B.tty.ops.ioctl_tcsets){for(var rr=syscallGetVarargP(),lr=HEAP32[rr>>2],dr=HEAP32[rr+4>>2],mr=HEAP32[rr+8>>2],hr=HEAP32[rr+12>>2],fr=[],ir=0;ir<32;ir++)fr.push(HEAP8[rr+ir+17]);return B.tty.ops.ioctl_tcsets(B.tty,e,{c_iflag:lr,c_oflag:dr,c_cflag:mr,c_lflag:hr,c_cc:fr})}return 0}case 21519:{if(!B.tty)return-59;var rr=syscallGetVarargP();return HEAP32[rr>>2]=0,0}case 21520:return B.tty?-28:-59;case 21531:{var rr=syscallGetVarargP();return FS.ioctl(B,e,rr)}case 21523:{if(!B.tty)return-59;if(B.tty.ops.ioctl_tiocgwinsz){var _r=B.tty.ops.ioctl_tiocgwinsz(B.tty),rr=syscallGetVarargP();HEAP16[rr>>1]=_r[0],HEAP16[rr+2>>1]=_r[1]}return 0}case 21524:return B.tty?0:-59;case 21515:return B.tty?0:-59;default:return-28}}catch(wr){if(typeof FS>"u"||wr.name!=="ErrnoError")throw wr;return-wr.errno}}___syscall_ioctl.sig="iiip";function ___syscall_lstat64(t,e){try{return t=SYSCALLS.getStr(t),SYSCALLS.doStat(FS.lstat,t,e)}catch(I){if(typeof FS>"u"||I.name!=="ErrnoError")throw I;return-I.errno}}___syscall_lstat64.sig="ipp";function ___syscall_mkdirat(t,e,I){try{return e=SYSCALLS.getStr(e),e=SYSCALLS.calculateAt(t,e),FS.mkdir(e,I,0),0}catch(B){if(typeof FS>"u"||B.name!=="ErrnoError")throw B;return-B.errno}}___syscall_mkdirat.sig="iipi";function ___syscall_newfstatat(t,e,I,B){try{e=SYSCALLS.getStr(e);var tr=B&256,rr=B&4096;return B=B&-6401,e=SYSCALLS.calculateAt(t,e,rr),SYSCALLS.doStat(tr?FS.lstat:FS.stat,e,I)}catch(ir){if(typeof FS>"u"||ir.name!=="ErrnoError")throw ir;return-ir.errno}}___syscall_newfstatat.sig="iippi";function ___syscall_openat(t,e,I,B){SYSCALLS.varargs=B;try{e=SYSCALLS.getStr(e),e=SYSCALLS.calculateAt(t,e);var tr=B?syscallGetVarargI():0;return FS.open(e,I,tr).fd}catch(rr){if(typeof FS>"u"||rr.name!=="ErrnoError")throw rr;return-rr.errno}}___syscall_openat.sig="iipip";var PIPEFS={BUCKET_BUFFER_SIZE:8192,mount(t){return FS.createNode(null,"/",16895,0)},createPipe(){var t={buckets:[],refcnt:2};t.buckets.push({buffer:new Uint8Array(PIPEFS.BUCKET_BUFFER_SIZE),offset:0,roffset:0});var e=PIPEFS.nextname(),I=PIPEFS.nextname(),B=FS.createNode(PIPEFS.root,e,4096,0),tr=FS.createNode(PIPEFS.root,I,4096,0);B.pipe=t,tr.pipe=t;var rr=FS.createStream({path:e,node:B,flags:0,seekable:!1,stream_ops:PIPEFS.stream_ops});B.stream=rr;var ir=FS.createStream({path:I,node:tr,flags:1,seekable:!1,stream_ops:PIPEFS.stream_ops});return tr.stream=ir,{readable_fd:rr.fd,writable_fd:ir.fd}},stream_ops:{poll(t){var e=t.node.pipe;if((t.flags&2097155)===1)return 260;if(e.buckets.length>0)for(var I=0;I<e.buckets.length;I++){var B=e.buckets[I];if(B.offset-B.roffset>0)return 65}return 0},ioctl(t,e,I){return 28},fsync(t){return 28},read(t,e,I,B,tr){for(var rr=t.node.pipe,ir=0,lr=0;lr<rr.buckets.length;lr++){var dr=rr.buckets[lr];ir+=dr.offset-dr.roffset}var mr=e.subarray(I,I+B);if(B<=0)return 0;if(ir==0)throw new FS.ErrnoError(6);for(var hr=Math.min(ir,B),fr=hr,_r=0,lr=0;lr<rr.buckets.length;lr++){var wr=rr.buckets[lr],gr=wr.offset-wr.roffset;if(hr<=gr){var xr=wr.buffer.subarray(wr.roffset,wr.offset);hr<gr?(xr=xr.subarray(0,hr),wr.roffset+=hr):_r++,mr.set(xr);break}else{var xr=wr.buffer.subarray(wr.roffset,wr.offset);mr.set(xr),mr=mr.subarray(xr.byteLength),hr-=xr.byteLength,_r++}}return _r&&_r==rr.buckets.length&&(_r--,rr.buckets[_r].offset=0,rr.buckets[_r].roffset=0),rr.buckets.splice(0,_r),fr},write(t,e,I,B,tr){var rr=t.node.pipe,ir=e.subarray(I,I+B),lr=ir.byteLength;if(lr<=0)return 0;var dr=null;rr.buckets.length==0?(dr={buffer:new Uint8Array(PIPEFS.BUCKET_BUFFER_SIZE),offset:0,roffset:0},rr.buckets.push(dr)):dr=rr.buckets[rr.buckets.length-1],assert(dr.offset<=PIPEFS.BUCKET_BUFFER_SIZE);var mr=PIPEFS.BUCKET_BUFFER_SIZE-dr.offset;if(mr>=lr)return dr.buffer.set(ir,dr.offset),dr.offset+=lr,lr;mr>0&&(dr.buffer.set(ir.subarray(0,mr),dr.offset),dr.offset+=mr,ir=ir.subarray(mr,ir.byteLength));for(var hr=ir.byteLength/PIPEFS.BUCKET_BUFFER_SIZE|0,fr=ir.byteLength%PIPEFS.BUCKET_BUFFER_SIZE,_r=0;_r<hr;_r++){var wr={buffer:new Uint8Array(PIPEFS.BUCKET_BUFFER_SIZE),offset:PIPEFS.BUCKET_BUFFER_SIZE,roffset:0};rr.buckets.push(wr),wr.buffer.set(ir.subarray(0,PIPEFS.BUCKET_BUFFER_SIZE)),ir=ir.subarray(PIPEFS.BUCKET_BUFFER_SIZE,ir.byteLength)}if(fr>0){var wr={buffer:new Uint8Array(PIPEFS.BUCKET_BUFFER_SIZE),offset:ir.byteLength,roffset:0};rr.buckets.push(wr),wr.buffer.set(ir)}return lr},close(t){var e=t.node.pipe;e.refcnt--,e.refcnt===0&&(e.buckets=null)}},nextname(){return PIPEFS.nextname.current||(PIPEFS.nextname.current=0),"pipe["+PIPEFS.nextname.current+++"]"}};function ___syscall_pipe(t){try{if(t==0)throw new FS.ErrnoError(21);var e=PIPEFS.createPipe();return HEAP32[t>>2]=e.readable_fd,HEAP32[t+4>>2]=e.writable_fd,0}catch(I){if(typeof FS>"u"||I.name!=="ErrnoError")throw I;return-I.errno}}___syscall_pipe.sig="ip";function ___syscall_poll(t,e,I){try{for(var B=0,tr=0;tr<e;tr++){var rr=t+8*tr,ir=HEAP32[rr>>2],lr=HEAP16[rr+4>>1],dr=32,mr=FS.getStream(ir);mr&&(dr=SYSCALLS.DEFAULT_POLLMASK,mr.stream_ops.poll&&(dr=mr.stream_ops.poll(mr,-1))),dr&=lr|8|16,dr&&B++,HEAP16[rr+6>>1]=dr}return B}catch(hr){if(typeof FS>"u"||hr.name!=="ErrnoError")throw hr;return-hr.errno}}___syscall_poll.sig="ipii";function ___syscall_readlinkat(t,e,I,B){try{if(e=SYSCALLS.getStr(e),e=SYSCALLS.calculateAt(t,e),B<=0)return-28;var tr=FS.readlink(e),rr=Math.min(B,lengthBytesUTF8(tr)),ir=HEAP8[I+rr];return stringToUTF8(tr,I,B+1),HEAP8[I+rr]=ir,rr}catch(lr){if(typeof FS>"u"||lr.name!=="ErrnoError")throw lr;return-lr.errno}}___syscall_readlinkat.sig="iippp";function ___syscall_recvfrom(t,e,I,B,tr,rr){try{var ir=getSocketFromFD(t),lr=ir.sock_ops.recvmsg(ir,I);if(!lr)return 0;if(tr)var dr=writeSockaddr(tr,ir.family,DNS.lookup_name(lr.addr),lr.port,rr);return HEAPU8.set(lr.buffer,e),lr.buffer.byteLength}catch(mr){if(typeof FS>"u"||mr.name!=="ErrnoError")throw mr;return-mr.errno}}___syscall_recvfrom.sig="iippipp";function ___syscall_renameat(t,e,I,B){try{return e=SYSCALLS.getStr(e),B=SYSCALLS.getStr(B),e=SYSCALLS.calculateAt(t,e),B=SYSCALLS.calculateAt(I,B),FS.rename(e,B),0}catch(tr){if(typeof FS>"u"||tr.name!=="ErrnoError")throw tr;return-tr.errno}}___syscall_renameat.sig="iipip";function ___syscall_rmdir(t){try{return t=SYSCALLS.getStr(t),FS.rmdir(t),0}catch(e){if(typeof FS>"u"||e.name!=="ErrnoError")throw e;return-e.errno}}___syscall_rmdir.sig="ip";function ___syscall_sendto(t,e,I,B,tr,rr){try{var ir=getSocketFromFD(t);if(!tr)return FS.write(ir.stream,HEAP8,e,I);var lr=getSocketAddress(tr,rr);return ir.sock_ops.sendmsg(ir,HEAP8,e,I,lr.addr,lr.port)}catch(dr){if(typeof FS>"u"||dr.name!=="ErrnoError")throw dr;return-dr.errno}}___syscall_sendto.sig="iippipp";function ___syscall_socket(t,e,I){try{var B=SOCKFS.createSocket(t,e,I);return B.stream.fd}catch(tr){if(typeof FS>"u"||tr.name!=="ErrnoError")throw tr;return-tr.errno}}___syscall_socket.sig="iiiiiii";function ___syscall_stat64(t,e){try{return t=SYSCALLS.getStr(t),SYSCALLS.doStat(FS.stat,t,e)}catch(I){if(typeof FS>"u"||I.name!=="ErrnoError")throw I;return-I.errno}}___syscall_stat64.sig="ipp";function ___syscall_symlinkat(t,e,I){try{return t=SYSCALLS.getStr(t),I=SYSCALLS.getStr(I),I=SYSCALLS.calculateAt(e,I),FS.symlink(t,I),0}catch(B){if(typeof FS>"u"||B.name!=="ErrnoError")throw B;return-B.errno}}___syscall_symlinkat.sig="ipip";function ___syscall_truncate64(t,e){e=bigintToI53Checked(e);try{return isNaN(e)?61:(t=SYSCALLS.getStr(t),FS.truncate(t,e),0)}catch(I){if(typeof FS>"u"||I.name!=="ErrnoError")throw I;return-I.errno}}___syscall_truncate64.sig="ipj";function ___syscall_unlinkat(t,e,I){try{return e=SYSCALLS.getStr(e),e=SYSCALLS.calculateAt(t,e),I===0?FS.unlink(e):I===512?FS.rmdir(e):abort("Invalid flags passed to unlinkat"),0}catch(B){if(typeof FS>"u"||B.name!=="ErrnoError")throw B;return-B.errno}}___syscall_unlinkat.sig="iipi";var ___table_base=new WebAssembly.Global({value:"i32",mutable:!1},1),__abort_js=()=>abort("");__abort_js.sig="v";var ENV={},stackAlloc=t=>__emscripten_stack_alloc(t),stringToUTF8OnStack=t=>{var e=lengthBytesUTF8(t)+1,I=stackAlloc(e);return stringToUTF8(t,I,e),I},dlSetError=t=>{var e=stackSave(),I=stringToUTF8OnStack(t);___dl_seterr(I,0),stackRestore(e)},dlopenInternal=(t,e)=>{var I=UTF8ToString(t+36),B=HEAP32[t+4>>2];I=PATH.normalize(I);var tr=!!(B&256),rr=tr?null:{},ir={global:tr,nodelete:!!(B&4096),loadAsync:e.loadAsync};try{return loadDynamicLibrary(I,ir,rr,t)}catch(lr){return dlSetError(`Could not load dynamic lib: ${I}
23
23
  ${lr}`),0}},__dlopen_js=t=>dlopenInternal(t,{loadAsync:!1});__dlopen_js.sig="pp";var __dlsym_js=(t,e,I)=>{e=UTF8ToString(e);var B,tr,rr=LDSO.loadedLibsByHandle[t];if(!rr.exports.hasOwnProperty(e)||rr.exports[e].stub)return dlSetError(`Tried to lookup unknown symbol "${e}" in dynamic lib: ${rr.name}`),0;if(tr=Object.keys(rr.exports).indexOf(e),B=rr.exports[e],typeof B=="function"){var ir=getFunctionAddress(B);ir?B=ir:(B=addFunction(B,B.sig),HEAPU32[I>>2]=tr)}return B};__dlsym_js.sig="pppp";var __emscripten_memcpy_js=(t,e,I)=>HEAPU8.copyWithin(t,e,e+I);__emscripten_memcpy_js.sig="vppp";var runtimeKeepaliveCounter=0,__emscripten_runtime_keepalive_clear=()=>{noExitRuntime=!1,runtimeKeepaliveCounter=0};__emscripten_runtime_keepalive_clear.sig="v";var __emscripten_system=t=>{if(ENVIRONMENT_IS_NODE){if(!t)return 1;var e=UTF8ToString(t);if(!e.length)return 0;var I=require("child_process"),B=I.spawnSync(e,[],{shell:!0,stdio:"inherit"}),tr=(ir,lr)=>ir<<8|lr;if(B.status===null){var rr=ir=>{switch(ir){case"SIGHUP":return 1;case"SIGQUIT":return 3;case"SIGFPE":return 8;case"SIGKILL":return 9;case"SIGALRM":return 14;case"SIGTERM":return 15;default:return 2}};return tr(0,rr(B.signal))}return tr(B.status,0)}return t?-52:0};__emscripten_system.sig="ip";var __emscripten_throw_longjmp=()=>{throw 1/0};__emscripten_throw_longjmp.sig="v";function __gmtime_js(t,e){t=bigintToI53Checked(t);var I=new Date(t*1e3);HEAP32[e>>2]=I.getUTCSeconds(),HEAP32[e+4>>2]=I.getUTCMinutes(),HEAP32[e+8>>2]=I.getUTCHours(),HEAP32[e+12>>2]=I.getUTCDate(),HEAP32[e+16>>2]=I.getUTCMonth(),HEAP32[e+20>>2]=I.getUTCFullYear()-1900,HEAP32[e+24>>2]=I.getUTCDay();var B=Date.UTC(I.getUTCFullYear(),0,1,0,0,0,0),tr=(I.getTime()-B)/(1e3*60*60*24)|0;HEAP32[e+28>>2]=tr}__gmtime_js.sig="vjp";var isLeapYear=t=>t%4===0&&(t%100!==0||t%400===0),MONTH_DAYS_LEAP_CUMULATIVE=[0,31,60,91,121,152,182,213,244,274,305,335],MONTH_DAYS_REGULAR_CUMULATIVE=[0,31,59,90,120,151,181,212,243,273,304,334],ydayFromDate=t=>{var e=isLeapYear(t.getFullYear()),I=e?MONTH_DAYS_LEAP_CUMULATIVE:MONTH_DAYS_REGULAR_CUMULATIVE,B=I[t.getMonth()]+t.getDate()-1;return B};function __localtime_js(t,e){t=bigintToI53Checked(t);var I=new Date(t*1e3);HEAP32[e>>2]=I.getSeconds(),HEAP32[e+4>>2]=I.getMinutes(),HEAP32[e+8>>2]=I.getHours(),HEAP32[e+12>>2]=I.getDate(),HEAP32[e+16>>2]=I.getMonth(),HEAP32[e+20>>2]=I.getFullYear()-1900,HEAP32[e+24>>2]=I.getDay();var B=ydayFromDate(I)|0;HEAP32[e+28>>2]=B,HEAP32[e+36>>2]=-(I.getTimezoneOffset()*60);var tr=new Date(I.getFullYear(),0,1),rr=new Date(I.getFullYear(),6,1).getTimezoneOffset(),ir=tr.getTimezoneOffset(),lr=(rr!=ir&&I.getTimezoneOffset()==Math.min(ir,rr))|0;HEAP32[e+32>>2]=lr}__localtime_js.sig="vjp";function __mmap_js(t,e,I,B,tr,rr,ir){tr=bigintToI53Checked(tr);try{if(isNaN(tr))return 61;var lr=SYSCALLS.getStreamFromFD(B),dr=FS.mmap(lr,t,tr,e,I),mr=dr.ptr;return HEAP32[rr>>2]=dr.allocated,HEAPU32[ir>>2]=mr,0}catch(hr){if(typeof FS>"u"||hr.name!=="ErrnoError")throw hr;return-hr.errno}}__mmap_js.sig="ipiiijpp";function __munmap_js(t,e,I,B,tr,rr){rr=bigintToI53Checked(rr);try{var ir=SYSCALLS.getStreamFromFD(tr);I&2&&SYSCALLS.doMsync(t,ir,e,B,rr)}catch(lr){if(typeof FS>"u"||lr.name!=="ErrnoError")throw lr;return-lr.errno}}__munmap_js.sig="ippiiij";var timers={},handleException=t=>{if(t instanceof ExitStatus||t=="unwind")return EXITSTATUS;quit_(1,t)},keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0,_proc_exit=t=>{EXITSTATUS=t,keepRuntimeAlive()||(Module.onExit?.(t),ABORT=!0),quit_(t,new ExitStatus(t))};_proc_exit.sig="vi";var exitJS=(t,e)=>{EXITSTATUS=t,_proc_exit(t)},_exit=exitJS;_exit.sig="vi";var maybeExit=()=>{if(!keepRuntimeAlive())try{_exit(EXITSTATUS)}catch(t){handleException(t)}},callUserCallback=t=>{if(!ABORT)try{t(),maybeExit()}catch(e){handleException(e)}},_emscripten_get_now=()=>performance.now();_emscripten_get_now.sig="d";var __setitimer_js=(t,e)=>{if(timers[t]&&(clearTimeout(timers[t].id),delete timers[t]),!e)return 0;var I=setTimeout(()=>{delete timers[t],callUserCallback(()=>__emscripten_timeout(t,_emscripten_get_now()))},e);return timers[t]={id:I,timeout_ms:e},0};__setitimer_js.sig="iid";var __tzset_js=(t,e,I,B)=>{var tr=new Date().getFullYear(),rr=new Date(tr,0,1),ir=new Date(tr,6,1),lr=rr.getTimezoneOffset(),dr=ir.getTimezoneOffset(),mr=Math.max(lr,dr);HEAPU32[t>>2]=mr*60,HEAP32[e>>2]=+(lr!=dr);var hr=wr=>{var gr=wr>=0?"-":"+",xr=Math.abs(wr),Mr=String(Math.floor(xr/60)).padStart(2,"0"),Sr=String(xr%60).padStart(2,"0");return`UTC${gr}${Mr}${Sr}`},fr=hr(lr),_r=hr(dr);dr<lr?(stringToUTF8(fr,I,17),stringToUTF8(_r,B,17)):(stringToUTF8(fr,B,17),stringToUTF8(_r,I,17))};__tzset_js.sig="vpppp";var _emscripten_date_now=()=>Date.now();_emscripten_date_now.sig="d";var checkWasiClock=t=>t>=0&&t<=3;function _clock_time_get(t,e,I){if(!checkWasiClock(t))return 28;var B;t===0?B=_emscripten_date_now():B=_emscripten_get_now();var tr=Math.round(B*1e3*1e3);return HEAP64[I>>3]=BigInt(tr),0}_clock_time_get.sig="iijp";var readEmAsmArgsArray=[],readEmAsmArgs=(t,e)=>{readEmAsmArgsArray.length=0;for(var I;I=HEAPU8[t++];){var B=I!=105;B&=I!=112,e+=B&&e%8?4:0,readEmAsmArgsArray.push(I==112?HEAPU32[e>>2]:I==106?HEAP64[e>>3]:I==105?HEAP32[e>>2]:HEAPF64[e>>3]),e+=B?8:4}return readEmAsmArgsArray},runEmAsmFunction=(t,e,I)=>{var B=readEmAsmArgs(e,I);return ASM_CONSTS[t](...B)},_emscripten_asm_const_int=(t,e,I)=>runEmAsmFunction(t,e,I);_emscripten_asm_const_int.sig="ippp";var _emscripten_force_exit=t=>{__emscripten_runtime_keepalive_clear(),_exit(t)};_emscripten_force_exit.sig="vi";var getHeapMax=()=>2147483648,growMemory=t=>{var e=wasmMemory.buffer,I=(t-e.byteLength+65535)/65536|0;try{return wasmMemory.grow(I),updateMemoryViews(),1}catch{}},_emscripten_resize_heap=t=>{var e=HEAPU8.length;t>>>=0;var I=getHeapMax();if(t>I)return!1;for(var B=1;B<=4;B*=2){var tr=e*(1+.2/B);tr=Math.min(tr,t+100663296);var rr=Math.min(I,alignMemory(Math.max(t,tr),65536)),ir=growMemory(rr);if(ir)return!0}return!1};_emscripten_resize_heap.sig="ip";var _emscripten_set_main_loop_timing=(t,e)=>{if(MainLoop.timingMode=t,MainLoop.timingValue=e,!MainLoop.func)return 1;if(MainLoop.running||(MainLoop.running=!0),t==0)MainLoop.scheduler=function(){var rr=Math.max(0,MainLoop.tickStartTime+e-_emscripten_get_now())|0;setTimeout(MainLoop.runner,rr)},MainLoop.method="timeout";else if(t==1)MainLoop.scheduler=function(){MainLoop.requestAnimationFrame(MainLoop.runner)},MainLoop.method="rAF";else if(t==2){if(typeof MainLoop.setImmediate>"u")if(typeof setImmediate>"u"){var I=[],B="setimmediate",tr=rr=>{(rr.data===B||rr.data.target===B)&&(rr.stopPropagation(),I.shift()())};addEventListener("message",tr,!0),MainLoop.setImmediate=rr=>{I.push(rr),ENVIRONMENT_IS_WORKER?(Module.setImmediates??(Module.setImmediates=[]),Module.setImmediates.push(rr),postMessage({target:B})):postMessage(B,"*")}}else MainLoop.setImmediate=setImmediate;MainLoop.scheduler=function(){MainLoop.setImmediate(MainLoop.runner)},MainLoop.method="immediate"}return 0};_emscripten_set_main_loop_timing.sig="iii";var MainLoop={running:!1,scheduler:null,method:"",currentlyRunningMainloop:0,func:null,arg:0,timingMode:0,timingValue:0,currentFrameNumber:0,queue:[],preMainLoop:[],postMainLoop:[],pause(){MainLoop.scheduler=null,MainLoop.currentlyRunningMainloop++},resume(){MainLoop.currentlyRunningMainloop++;var t=MainLoop.timingMode,e=MainLoop.timingValue,I=MainLoop.func;MainLoop.func=null,setMainLoop(I,0,!1,MainLoop.arg,!0),_emscripten_set_main_loop_timing(t,e),MainLoop.scheduler()},updateStatus(){if(Module.setStatus){var t=Module.statusMessage||"Please wait...",e=MainLoop.remainingBlockers??0,I=MainLoop.expectedBlockers??0;e?e<I?Module.setStatus("{message} ({expected - remaining}/{expected})"):Module.setStatus(t):Module.setStatus("")}},init(){Module.preMainLoop&&MainLoop.preMainLoop.push(Module.preMainLoop),Module.postMainLoop&&MainLoop.postMainLoop.push(Module.postMainLoop)},runIter(t){if(!ABORT){for(var e of MainLoop.preMainLoop)if(e()===!1)return;callUserCallback(t);for(var I of MainLoop.postMainLoop)I()}},nextRAF:0,fakeRequestAnimationFrame(t){var e=Date.now();if(MainLoop.nextRAF===0)MainLoop.nextRAF=e+1e3/60;else for(;e+2>=MainLoop.nextRAF;)MainLoop.nextRAF+=1e3/60;var I=Math.max(MainLoop.nextRAF-e,0);setTimeout(t,I)},requestAnimationFrame(t){if(typeof requestAnimationFrame=="function"){requestAnimationFrame(t);return}var e=MainLoop.fakeRequestAnimationFrame;e(t)}},setMainLoop=(t,e,I,B,tr)=>{MainLoop.func=t,MainLoop.arg=B;var rr=MainLoop.currentlyRunningMainloop;function ir(){return rr<MainLoop.currentlyRunningMainloop?(maybeExit(),!1):!0}if(MainLoop.running=!1,MainLoop.runner=function(){if(!ABORT){if(MainLoop.queue.length>0){var lr=MainLoop.queue.shift();if(lr.func(lr.arg),MainLoop.remainingBlockers){var dr=MainLoop.remainingBlockers,mr=dr%1==0?dr-1:Math.floor(dr);lr.counted?MainLoop.remainingBlockers=mr:(mr=mr+.5,MainLoop.remainingBlockers=(8*dr+mr)/9)}if(MainLoop.updateStatus(),!ir())return;setTimeout(MainLoop.runner,0);return}if(ir()){if(MainLoop.currentFrameNumber=MainLoop.currentFrameNumber+1|0,MainLoop.timingMode==1&&MainLoop.timingValue>1&&MainLoop.currentFrameNumber%MainLoop.timingValue!=0){MainLoop.scheduler();return}else MainLoop.timingMode==0&&(MainLoop.tickStartTime=_emscripten_get_now());MainLoop.runIter(t),ir()&&MainLoop.scheduler()}}},tr||(e&&e>0?_emscripten_set_main_loop_timing(0,1e3/e):_emscripten_set_main_loop_timing(1,1),MainLoop.scheduler()),I)throw"unwind"},_emscripten_set_main_loop=(t,e,I)=>{var B=getWasmTableEntry(t);setMainLoop(B,e,I)};_emscripten_set_main_loop.sig="vpii";var getExecutableName=()=>thisProgram||"./this.program",getEnvStrings=()=>{if(!getEnvStrings.strings){var t=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:t,_:getExecutableName()};for(var I in ENV)ENV[I]===void 0?delete e[I]:e[I]=ENV[I];var B=[];for(var I in e)B.push(`${I}=${e[I]}`);getEnvStrings.strings=B}return getEnvStrings.strings},stringToAscii=(t,e)=>{for(var I=0;I<t.length;++I)HEAP8[e++]=t.charCodeAt(I);HEAP8[e]=0},_environ_get=(t,e)=>{var I=0;return getEnvStrings().forEach((B,tr)=>{var rr=e+I;HEAPU32[t+tr*4>>2]=rr,stringToAscii(B,rr),I+=B.length+1}),0};_environ_get.sig="ipp";var _environ_sizes_get=(t,e)=>{var I=getEnvStrings();HEAPU32[t>>2]=I.length;var B=0;return I.forEach(tr=>B+=tr.length+1),HEAPU32[e>>2]=B,0};_environ_sizes_get.sig="ipp";function _fd_close(t){try{var e=SYSCALLS.getStreamFromFD(t);return FS.close(e),0}catch(I){if(typeof FS>"u"||I.name!=="ErrnoError")throw I;return I.errno}}_fd_close.sig="ii";function _fd_fdstat_get(t,e){try{var I=0,B=0,tr=0,rr=SYSCALLS.getStreamFromFD(t),ir=rr.tty?2:FS.isDir(rr.mode)?3:FS.isLink(rr.mode)?7:4;return HEAP8[e]=ir,HEAP16[e+2>>1]=tr,HEAP64[e+8>>3]=BigInt(I),HEAP64[e+16>>3]=BigInt(B),0}catch(lr){if(typeof FS>"u"||lr.name!=="ErrnoError")throw lr;return lr.errno}}_fd_fdstat_get.sig="iip";var doReadv=(t,e,I,B)=>{for(var tr=0,rr=0;rr<I;rr++){var ir=HEAPU32[e>>2],lr=HEAPU32[e+4>>2];e+=8;var dr=FS.read(t,HEAP8,ir,lr,B);if(dr<0)return-1;if(tr+=dr,dr<lr)break;typeof B<"u"&&(B+=dr)}return tr};function _fd_pread(t,e,I,B,tr){B=bigintToI53Checked(B);try{if(isNaN(B))return 61;var rr=SYSCALLS.getStreamFromFD(t),ir=doReadv(rr,e,I,B);return HEAPU32[tr>>2]=ir,0}catch(lr){if(typeof FS>"u"||lr.name!=="ErrnoError")throw lr;return lr.errno}}_fd_pread.sig="iippjp";var doWritev=(t,e,I,B)=>{for(var tr=0,rr=0;rr<I;rr++){var ir=HEAPU32[e>>2],lr=HEAPU32[e+4>>2];e+=8;var dr=FS.write(t,HEAP8,ir,lr,B);if(dr<0)return-1;if(tr+=dr,dr<lr)break;typeof B<"u"&&(B+=dr)}return tr};function _fd_pwrite(t,e,I,B,tr){B=bigintToI53Checked(B);try{if(isNaN(B))return 61;var rr=SYSCALLS.getStreamFromFD(t),ir=doWritev(rr,e,I,B);return HEAPU32[tr>>2]=ir,0}catch(lr){if(typeof FS>"u"||lr.name!=="ErrnoError")throw lr;return lr.errno}}_fd_pwrite.sig="iippjp";function _fd_read(t,e,I,B){try{var tr=SYSCALLS.getStreamFromFD(t),rr=doReadv(tr,e,I);return HEAPU32[B>>2]=rr,0}catch(ir){if(typeof FS>"u"||ir.name!=="ErrnoError")throw ir;return ir.errno}}_fd_read.sig="iippp";function _fd_seek(t,e,I,B){e=bigintToI53Checked(e);try{if(isNaN(e))return 61;var tr=SYSCALLS.getStreamFromFD(t);return FS.llseek(tr,e,I),HEAP64[B>>3]=BigInt(tr.position),tr.getdents&&e===0&&I===0&&(tr.getdents=null),0}catch(rr){if(typeof FS>"u"||rr.name!=="ErrnoError")throw rr;return rr.errno}}_fd_seek.sig="iijip";function _fd_sync(t){try{var e=SYSCALLS.getStreamFromFD(t);return e.stream_ops?.fsync?e.stream_ops.fsync(e):0}catch(I){if(typeof FS>"u"||I.name!=="ErrnoError")throw I;return I.errno}}_fd_sync.sig="ii";function _fd_write(t,e,I,B){try{var tr=SYSCALLS.getStreamFromFD(t),rr=doWritev(tr,e,I);return HEAPU32[B>>2]=rr,0}catch(ir){if(typeof FS>"u"||ir.name!=="ErrnoError")throw ir;return ir.errno}}_fd_write.sig="iippp";var _getaddrinfo=(t,e,I,B)=>{var tr=0,rr=0,ir=0,lr=0,dr=0,mr=0,hr;function fr(_r,wr,gr,xr,Mr,Sr){var yr,br,vr,Cr;return br=_r===10?28:16,Mr=_r===10?inetNtop6(Mr):inetNtop4(Mr),yr=_malloc(br),Cr=writeSockaddr(yr,_r,Mr,Sr),assert(!Cr),vr=_malloc(32),HEAP32[vr+4>>2]=_r,HEAP32[vr+8>>2]=wr,HEAP32[vr+12>>2]=gr,HEAPU32[vr+24>>2]=xr,HEAPU32[vr+20>>2]=yr,_r===10?HEAP32[vr+16>>2]=28:HEAP32[vr+16>>2]=16,HEAP32[vr+28>>2]=0,vr}if(I&&(ir=HEAP32[I>>2],lr=HEAP32[I+4>>2],dr=HEAP32[I+8>>2],mr=HEAP32[I+12>>2]),dr&&!mr&&(mr=dr===2?17:6),!dr&&mr&&(dr=mr===17?2:1),mr===0&&(mr=6),dr===0&&(dr=1),!t&&!e)return-2;if(ir&-1088||I!==0&&HEAP32[I>>2]&2&&!t)return-1;if(ir&32)return-2;if(dr!==0&&dr!==1&&dr!==2)return-7;if(lr!==0&&lr!==2&&lr!==10)return-6;if(e&&(e=UTF8ToString(e),rr=parseInt(e,10),isNaN(rr)))return ir&1024?-2:-8;if(!t)return lr===0&&(lr=2),ir&1||(lr===2?tr=_htonl(2130706433):tr=[0,0,0,_htonl(1)]),hr=fr(lr,dr,mr,null,tr,rr),HEAPU32[B>>2]=hr,0;if(t=UTF8ToString(t),tr=inetPton4(t),tr!==null)if(lr===0||lr===2)lr=2;else if(lr===10&&ir&8)tr=[0,0,_htonl(65535),tr],lr=10;else return-2;else if(tr=inetPton6(t),tr!==null)if(lr===0||lr===10)lr=10;else return-2;return tr!=null?(hr=fr(lr,dr,mr,t,tr,rr),HEAPU32[B>>2]=hr,0):ir&4?-2:(t=DNS.lookup_name(t),tr=inetPton4(t),lr===0?lr=2:lr===10&&(tr=[0,0,_htonl(65535),tr]),hr=fr(lr,dr,mr,null,tr,rr),HEAPU32[B>>2]=hr,0)};_getaddrinfo.sig="ipppp";var _getnameinfo=(t,e,I,B,tr,rr,ir)=>{var lr=readSockaddr(t,e);if(lr.errno)return-6;var dr=lr.port,mr=lr.addr,hr=!1;if(I&&B){var fr;if(ir&1||!(fr=DNS.lookup_addr(mr))){if(ir&8)return-2}else mr=fr;var _r=stringToUTF8(mr,I,B);_r+1>=B&&(hr=!0)}if(tr&&rr){dr=""+dr;var _r=stringToUTF8(dr,tr,rr);_r+1>=rr&&(hr=!0)}return hr?-12:0};_getnameinfo.sig="ipipipii";var stringToNewUTF8=t=>{var e=lengthBytesUTF8(t)+1,I=_malloc(e);return I&&stringToUTF8(t,I,e),I},getCFunc=t=>{var e=Module["_"+t];return e},writeArrayToMemory=(t,e)=>{HEAP8.set(t,e)},ccall=(t,e,I,B,tr)=>{var rr={string:gr=>{var xr=0;return gr!=null&&gr!==0&&(xr=stringToUTF8OnStack(gr)),xr},array:gr=>{var xr=stackAlloc(gr.length);return writeArrayToMemory(gr,xr),xr}};function ir(gr){return e==="string"?UTF8ToString(gr):e==="boolean"?!!gr:gr}var lr=getCFunc(t),dr=[],mr=0;if(B)for(var hr=0;hr<B.length;hr++){var fr=rr[I[hr]];fr?(mr===0&&(mr=stackSave()),dr[hr]=fr(B[hr])):dr[hr]=B[hr]}var _r=lr(...dr);function wr(gr){return mr!==0&&stackRestore(mr),ir(gr)}return _r=wr(_r),_r},cwrap=(t,e,I,B)=>{var tr=!I||I.every(ir=>ir==="number"||ir==="boolean"),rr=e!=="string";return rr&&tr&&!B?getCFunc(t):(...ir)=>ccall(t,e,I,ir)},FS_createPath=FS.createPath,FS_unlink=t=>FS.unlink(t),FS_createLazyFile=FS.createLazyFile,FS_createDevice=FS.createDevice,setTempRet0=t=>__emscripten_tempret_set(t),_setTempRet0=setTempRet0;Module._setTempRet0=_setTempRet0;var getTempRet0=t=>__emscripten_tempret_get(),_getTempRet0=getTempRet0;Module._getTempRet0=_getTempRet0,registerWasmPlugin(),FS.createPreloadedFile=FS_createPreloadedFile,FS.staticInit(),Module.FS_createPath=FS.createPath,Module.FS_createDataFile=FS.createDataFile,Module.FS_createPreloadedFile=FS.createPreloadedFile,Module.FS_unlink=FS.unlink,Module.FS_createLazyFile=FS.createLazyFile,Module.FS_createDevice=FS.createDevice,MEMFS.doesNotExistError=new FS.ErrnoError(44),MEMFS.doesNotExistError.stack="<generic error, no stack>",ENVIRONMENT_IS_NODE&&NODEFS.staticInit(),Module.requestAnimationFrame=MainLoop.requestAnimationFrame,Module.pauseMainLoop=MainLoop.pause,Module.resumeMainLoop=MainLoop.resume,MainLoop.init();var wasmImports={__assert_fail:___assert_fail,__call_sighandler:___call_sighandler,__heap_base:___heap_base,__indirect_function_table:wasmTable,__memory_base:___memory_base,__stack_pointer:___stack_pointer,__syscall__newselect:___syscall__newselect,__syscall_bind:___syscall_bind,__syscall_chdir:___syscall_chdir,__syscall_chmod:___syscall_chmod,__syscall_connect:___syscall_connect,__syscall_dup:___syscall_dup,__syscall_dup3:___syscall_dup3,__syscall_faccessat:___syscall_faccessat,__syscall_fadvise64:___syscall_fadvise64,__syscall_fallocate:___syscall_fallocate,__syscall_fcntl64:___syscall_fcntl64,__syscall_fdatasync:___syscall_fdatasync,__syscall_fstat64:___syscall_fstat64,__syscall_ftruncate64:___syscall_ftruncate64,__syscall_getcwd:___syscall_getcwd,__syscall_getdents64:___syscall_getdents64,__syscall_getsockname:___syscall_getsockname,__syscall_getsockopt:___syscall_getsockopt,__syscall_ioctl:___syscall_ioctl,__syscall_lstat64:___syscall_lstat64,__syscall_mkdirat:___syscall_mkdirat,__syscall_newfstatat:___syscall_newfstatat,__syscall_openat:___syscall_openat,__syscall_pipe:___syscall_pipe,__syscall_poll:___syscall_poll,__syscall_readlinkat:___syscall_readlinkat,__syscall_recvfrom:___syscall_recvfrom,__syscall_renameat:___syscall_renameat,__syscall_rmdir:___syscall_rmdir,__syscall_sendto:___syscall_sendto,__syscall_socket:___syscall_socket,__syscall_stat64:___syscall_stat64,__syscall_symlinkat:___syscall_symlinkat,__syscall_truncate64:___syscall_truncate64,__syscall_unlinkat:___syscall_unlinkat,__table_base:___table_base,_abort_js:__abort_js,_dlopen_js:__dlopen_js,_dlsym_js:__dlsym_js,_emscripten_memcpy_js:__emscripten_memcpy_js,_emscripten_runtime_keepalive_clear:__emscripten_runtime_keepalive_clear,_emscripten_system:__emscripten_system,_emscripten_throw_longjmp:__emscripten_throw_longjmp,_gmtime_js:__gmtime_js,_localtime_js:__localtime_js,_mmap_js:__mmap_js,_munmap_js:__munmap_js,_setitimer_js:__setitimer_js,_tzset_js:__tzset_js,clock_time_get:_clock_time_get,emscripten_asm_const_int:_emscripten_asm_const_int,emscripten_date_now:_emscripten_date_now,emscripten_force_exit:_emscripten_force_exit,emscripten_get_now:_emscripten_get_now,emscripten_resize_heap:_emscripten_resize_heap,emscripten_set_main_loop:_emscripten_set_main_loop,environ_get:_environ_get,environ_sizes_get:_environ_sizes_get,exit:_exit,fd_close:_fd_close,fd_fdstat_get:_fd_fdstat_get,fd_pread:_fd_pread,fd_pwrite:_fd_pwrite,fd_read:_fd_read,fd_seek:_fd_seek,fd_sync:_fd_sync,fd_write:_fd_write,getTempRet0:_getTempRet0,getaddrinfo:_getaddrinfo,getnameinfo:_getnameinfo,invoke_di,invoke_i,invoke_id,invoke_ii,invoke_iii,invoke_iiii,invoke_iiiii,invoke_iiiiii,invoke_iiiiiii,invoke_iiiiiiii,invoke_iiiiiiiii,invoke_iiiiiiiiii,invoke_iiiiiiiiiiiiiiiii,invoke_iiiiiji,invoke_iiiij,invoke_iiiijii,invoke_iiij,invoke_iiji,invoke_ij,invoke_ijiiiii,invoke_ijiiiiii,invoke_ji,invoke_jii,invoke_jiiii,invoke_jiiiii,invoke_jiiiiiiii,invoke_v,invoke_vi,invoke_vid,invoke_vii,invoke_viii,invoke_viiii,invoke_viiiii,invoke_viiiiii,invoke_viiiiiii,invoke_viiiiiiii,invoke_viiiiiiiii,invoke_viiiiiiiiiiii,invoke_viiij,invoke_viij,invoke_viiji,invoke_viijii,invoke_viijiiii,invoke_vij,invoke_viji,invoke_vijiji,invoke_vj,invoke_vji,is_web_env,memory:wasmMemory,proc_exit:_proc_exit,setTempRet0:_setTempRet0},wasmExports;createWasm(),Module._ScanKeywordLookup=(t,e)=>(Module._ScanKeywordLookup=wasmExports.ScanKeywordLookup)(t,e),Module._pg_snprintf=(t,e,I,B)=>(Module._pg_snprintf=wasmExports.pg_snprintf)(t,e,I,B),Module._strlen=t=>(Module._strlen=wasmExports.strlen)(t),Module._memset=(t,e,I)=>(Module._memset=wasmExports.memset)(t,e,I),Module._strchr=(t,e)=>(Module._strchr=wasmExports.strchr)(t,e),Module._PQserverVersion=t=>(Module._PQserverVersion=wasmExports.PQserverVersion)(t),Module._strstr=(t,e)=>(Module._strstr=wasmExports.strstr)(t,e),Module._pg_fprintf=(t,e,I)=>(Module._pg_fprintf=wasmExports.pg_fprintf)(t,e,I),Module._strspn=(t,e)=>(Module._strspn=wasmExports.strspn)(t,e);var _malloc=Module._malloc=t=>(_malloc=Module._malloc=wasmExports.malloc)(t);Module._pg_strcasecmp=(t,e)=>(Module._pg_strcasecmp=wasmExports.pg_strcasecmp)(t,e),Module._strcmp=(t,e)=>(Module._strcmp=wasmExports.strcmp)(t,e),Module._free=t=>(Module._free=wasmExports.free)(t),Module._pg_tolower=t=>(Module._pg_tolower=wasmExports.pg_tolower)(t),Module._memchr=(t,e,I)=>(Module._memchr=wasmExports.memchr)(t,e,I),Module._getenv=t=>(Module._getenv=wasmExports.getenv)(t),Module._fileno=t=>(Module._fileno=wasmExports.fileno)(t),Module._isatty=t=>(Module._isatty=wasmExports.isatty)(t),Module._strdup=t=>(Module._strdup=wasmExports.strdup)(t),Module.___errno_location=()=>(Module.___errno_location=wasmExports.__errno_location)();var _fflush=Module._fflush=t=>(_fflush=Module._fflush=wasmExports.fflush)(t);Module._pg_vsnprintf=(t,e,I,B)=>(Module._pg_vsnprintf=wasmExports.pg_vsnprintf)(t,e,I,B),Module._pg_malloc_extended=(t,e)=>(Module._pg_malloc_extended=wasmExports.pg_malloc_extended)(t,e),Module._PageInit=(t,e,I)=>(Module._PageInit=wasmExports.PageInit)(t,e,I),Module._pg_checksum_page=(t,e)=>(Module._pg_checksum_page=wasmExports.pg_checksum_page)(t,e),Module._errstart=(t,e)=>(Module._errstart=wasmExports.errstart)(t,e),Module._errcode=t=>(Module._errcode=wasmExports.errcode)(t),Module._errmsg=(t,e)=>(Module._errmsg=wasmExports.errmsg)(t,e),Module._errfinish=(t,e,I)=>(Module._errfinish=wasmExports.errfinish)(t,e,I),Module._PageAddItemExtended=(t,e,I,B,tr)=>(Module._PageAddItemExtended=wasmExports.PageAddItemExtended)(t,e,I,B,tr),Module._errstart_cold=(t,e)=>(Module._errstart_cold=wasmExports.errstart_cold)(t,e),Module._puts=t=>(Module._puts=wasmExports.puts)(t),Module._errmsg_internal=(t,e)=>(Module._errmsg_internal=wasmExports.errmsg_internal)(t,e),Module._memmove=(t,e,I)=>(Module._memmove=wasmExports.memmove)(t,e,I),Module._memcpy=(t,e,I)=>(Module._memcpy=wasmExports.memcpy)(t,e,I),Module._palloc=t=>(Module._palloc=wasmExports.palloc)(t),Module._pfree=t=>(Module._pfree=wasmExports.pfree)(t),Module._PageGetFreeSpace=t=>(Module._PageGetFreeSpace=wasmExports.PageGetFreeSpace)(t),Module._PageGetExactFreeSpace=t=>(Module._PageGetExactFreeSpace=wasmExports.PageGetExactFreeSpace)(t),Module._PageGetHeapFreeSpace=t=>(Module._PageGetHeapFreeSpace=wasmExports.PageGetHeapFreeSpace)(t),Module._PageIndexMultiDelete=(t,e,I)=>(Module._PageIndexMultiDelete=wasmExports.PageIndexMultiDelete)(t,e,I),Module._PageIndexTupleOverwrite=(t,e,I,B)=>(Module._PageIndexTupleOverwrite=wasmExports.PageIndexTupleOverwrite)(t,e,I,B),Module._ItemPointerEquals=(t,e)=>(Module._ItemPointerEquals=wasmExports.ItemPointerEquals)(t,e),Module._ItemPointerCompare=(t,e)=>(Module._ItemPointerCompare=wasmExports.ItemPointerCompare)(t,e),Module._add_size=(t,e)=>(Module._add_size=wasmExports.add_size)(t,e),Module._ShmemInitStruct=(t,e,I)=>(Module._ShmemInitStruct=wasmExports.ShmemInitStruct)(t,e,I),Module._s_init_lock_sema=(t,e)=>(Module._s_init_lock_sema=wasmExports.s_init_lock_sema)(t,e),Module._LWLockAcquire=(t,e)=>(Module._LWLockAcquire=wasmExports.LWLockAcquire)(t,e),Module._LWLockRelease=t=>(Module._LWLockRelease=wasmExports.LWLockRelease)(t),Module._on_shmem_exit=(t,e)=>(Module._on_shmem_exit=wasmExports.on_shmem_exit)(t,e),Module._tas_sema=t=>(Module._tas_sema=wasmExports.tas_sema)(t),Module._s_lock=(t,e,I,B)=>(Module._s_lock=wasmExports.s_lock)(t,e,I,B),Module._s_unlock_sema=t=>(Module._s_unlock_sema=wasmExports.s_unlock_sema)(t),Module._StartTransactionCommand=()=>(Module._StartTransactionCommand=wasmExports.StartTransactionCommand)(),Module._CommitTransactionCommand=()=>(Module._CommitTransactionCommand=wasmExports.CommitTransactionCommand)(),Module._WaitLatch=(t,e,I,B)=>(Module._WaitLatch=wasmExports.WaitLatch)(t,e,I,B),Module._ResetLatch=t=>(Module._ResetLatch=wasmExports.ResetLatch)(t),Module._ProcessInterrupts=()=>(Module._ProcessInterrupts=wasmExports.ProcessInterrupts)(),Module._MemoryContextAlloc=(t,e)=>(Module._MemoryContextAlloc=wasmExports.MemoryContextAlloc)(t,e),Module._AllocateDir=t=>(Module._AllocateDir=wasmExports.AllocateDir)(t),Module._ReadDir=(t,e)=>(Module._ReadDir=wasmExports.ReadDir)(t,e),Module._strncmp=(t,e,I)=>(Module._strncmp=wasmExports.strncmp)(t,e,I),Module._unlink=t=>(Module._unlink=wasmExports.unlink)(t),Module._errcode_for_file_access=()=>(Module._errcode_for_file_access=wasmExports.errcode_for_file_access)(),Module._FreeDir=t=>(Module._FreeDir=wasmExports.FreeDir)(t),Module._pg_prng_uint32=t=>(Module._pg_prng_uint32=wasmExports.pg_prng_uint32)(t),Module._dsm_create=(t,e)=>(Module._dsm_create=wasmExports.dsm_create)(t,e),Module._dsm_attach=t=>(Module._dsm_attach=wasmExports.dsm_attach)(t),Module._dsm_detach=t=>(Module._dsm_detach=wasmExports.dsm_detach)(t),Module._dsm_segment_address=t=>(Module._dsm_segment_address=wasmExports.dsm_segment_address)(t),Module._dsm_segment_handle=t=>(Module._dsm_segment_handle=wasmExports.dsm_segment_handle)(t),Module._MemoryContextAllocZero=(t,e)=>(Module._MemoryContextAllocZero=wasmExports.MemoryContextAllocZero)(t,e),Module._read=(t,e,I)=>(Module._read=wasmExports.read)(t,e,I),Module._hash_create=(t,e,I,B)=>(Module._hash_create=wasmExports.hash_create)(t,e,I,B),Module._hash_destroy=t=>(Module._hash_destroy=wasmExports.hash_destroy)(t),Module._hash_seq_init=(t,e)=>(Module._hash_seq_init=wasmExports.hash_seq_init)(t,e),Module._hash_seq_search=t=>(Module._hash_seq_search=wasmExports.hash_seq_search)(t),Module._hash_search=(t,e,I,B)=>(Module._hash_search=wasmExports.hash_search)(t,e,I,B),Module._initStringInfo=t=>(Module._initStringInfo=wasmExports.initStringInfo)(t),Module._appendStringInfo=(t,e,I)=>(Module._appendStringInfo=wasmExports.appendStringInfo)(t,e,I),Module._GetCurrentTimestamp=()=>(Module._GetCurrentTimestamp=wasmExports.GetCurrentTimestamp)(),Module._pg_usleep=t=>(Module._pg_usleep=wasmExports.pg_usleep)(t),Module._errdetail=(t,e)=>(Module._errdetail=wasmExports.errdetail)(t,e),Module._TransactionIdDidCommit=t=>(Module._TransactionIdDidCommit=wasmExports.TransactionIdDidCommit)(t),Module._TransactionIdPrecedes=(t,e)=>(Module._TransactionIdPrecedes=wasmExports.TransactionIdPrecedes)(t,e),Module._XLogBeginInsert=()=>(Module._XLogBeginInsert=wasmExports.XLogBeginInsert)(),Module._XLogRegisterData=(t,e)=>(Module._XLogRegisterData=wasmExports.XLogRegisterData)(t,e),Module._XLogInsert=(t,e)=>(Module._XLogInsert=wasmExports.XLogInsert)(t,e),Module._ConditionVariableInit=t=>(Module._ConditionVariableInit=wasmExports.ConditionVariableInit)(t),Module._ConditionVariableCancelSleep=()=>(Module._ConditionVariableCancelSleep=wasmExports.ConditionVariableCancelSleep)(),Module._ConditionVariableSleep=(t,e)=>(Module._ConditionVariableSleep=wasmExports.ConditionVariableSleep)(t,e),Module.___wasm_setjmp=(t,e,I)=>(Module.___wasm_setjmp=wasmExports.__wasm_setjmp)(t,e,I),Module.___wasm_setjmp_test=(t,e)=>(Module.___wasm_setjmp_test=wasmExports.__wasm_setjmp_test)(t,e),Module._pg_re_throw=()=>(Module._pg_re_throw=wasmExports.pg_re_throw)(),Module._emscripten_longjmp=(t,e)=>(Module._emscripten_longjmp=wasmExports.emscripten_longjmp)(t,e),Module._procsignal_sigusr1_handler=t=>(Module._procsignal_sigusr1_handler=wasmExports.procsignal_sigusr1_handler)(t),Module._close=t=>(Module._close=wasmExports.close)(t),Module._ReleaseExternalFD=()=>(Module._ReleaseExternalFD=wasmExports.ReleaseExternalFD)(),Module._fcntl=(t,e,I)=>(Module._fcntl=wasmExports.fcntl)(t,e,I),Module._pqsignal=(t,e)=>(Module._pqsignal=wasmExports.pqsignal)(t,e),Module._write=(t,e,I)=>(Module._write=wasmExports.write)(t,e,I),Module._AddWaitEventToSet=(t,e,I,B,tr)=>(Module._AddWaitEventToSet=wasmExports.AddWaitEventToSet)(t,e,I,B,tr),Module._clock_gettime=(t,e)=>(Module._clock_gettime=wasmExports.clock_gettime)(t,e),Module._poll=(t,e,I)=>(Module._poll=wasmExports.poll)(t,e,I),Module._WaitLatchOrSocket=(t,e,I,B,tr)=>(Module._WaitLatchOrSocket=wasmExports.WaitLatchOrSocket)(t,e,I,B,tr),Module._GetNumRegisteredWaitEvents=t=>(Module._GetNumRegisteredWaitEvents=wasmExports.GetNumRegisteredWaitEvents)(t),Module._ShmemInitHash=(t,e,I,B,tr)=>(Module._ShmemInitHash=wasmExports.ShmemInitHash)(t,e,I,B,tr),Module._InitMaterializedSRF=(t,e)=>(Module._InitMaterializedSRF=wasmExports.InitMaterializedSRF)(t,e),Module._cstring_to_text=t=>(Module._cstring_to_text=wasmExports.cstring_to_text)(t),Module._Int64GetDatum=t=>(Module._Int64GetDatum=wasmExports.Int64GetDatum)(t),Module._tuplestore_putvalues=(t,e,I,B)=>(Module._tuplestore_putvalues=wasmExports.tuplestore_putvalues)(t,e,I,B),Module._shm_toc_allocate=(t,e)=>(Module._shm_toc_allocate=wasmExports.shm_toc_allocate)(t,e),Module._shm_toc_insert=(t,e,I)=>(Module._shm_toc_insert=wasmExports.shm_toc_insert)(t,e,I),Module._shm_toc_lookup=(t,e,I)=>(Module._shm_toc_lookup=wasmExports.shm_toc_lookup)(t,e,I),Module._superuser_arg=t=>(Module._superuser_arg=wasmExports.superuser_arg)(t),Module._superuser=()=>(Module._superuser=wasmExports.superuser)(),Module._GetUserId=()=>(Module._GetUserId=wasmExports.GetUserId)(),Module._has_privs_of_role=(t,e)=>(Module._has_privs_of_role=wasmExports.has_privs_of_role)(t,e),Module._errmsg_plural=(t,e,I,B)=>(Module._errmsg_plural=wasmExports.errmsg_plural)(t,e,I,B),Module._errhint=(t,e)=>(Module._errhint=wasmExports.errhint)(t,e),Module._fstat=(t,e)=>(Module._fstat=wasmExports.fstat)(t,e),Module._ftruncate=(t,e)=>(Module._ftruncate=wasmExports.ftruncate)(t,e),Module._RequestAddinShmemSpace=t=>(Module._RequestAddinShmemSpace=wasmExports.RequestAddinShmemSpace)(t),Module._hash_estimate_size=(t,e)=>(Module._hash_estimate_size=wasmExports.hash_estimate_size)(t,e),Module._pg_sprintf=(t,e,I)=>(Module._pg_sprintf=wasmExports.pg_sprintf)(t,e,I),Module._SetConfigOption=(t,e,I,B)=>(Module._SetConfigOption=wasmExports.SetConfigOption)(t,e,I,B),Module._pg_printf=(t,e)=>(Module._pg_printf=wasmExports.pg_printf)(t,e),Module._before_shmem_exit=(t,e)=>(Module._before_shmem_exit=wasmExports.before_shmem_exit)(t,e),Module._cancel_before_shmem_exit=(t,e)=>(Module._cancel_before_shmem_exit=wasmExports.cancel_before_shmem_exit)(t,e),Module._pg_qsort=(t,e,I,B)=>(Module._pg_qsort=wasmExports.pg_qsort)(t,e,I,B),Module._TransactionIdIsInProgress=t=>(Module._TransactionIdIsInProgress=wasmExports.TransactionIdIsInProgress)(t),Module._TransactionIdIsCurrentTransactionId=t=>(Module._TransactionIdIsCurrentTransactionId=wasmExports.TransactionIdIsCurrentTransactionId)(t),Module._RecoveryInProgress=()=>(Module._RecoveryInProgress=wasmExports.RecoveryInProgress)(),Module._GetOldestNonRemovableTransactionId=t=>(Module._GetOldestNonRemovableTransactionId=wasmExports.GetOldestNonRemovableTransactionId)(t),Module._GetCurrentCommandId=t=>(Module._GetCurrentCommandId=wasmExports.GetCurrentCommandId)(t),Module._BackendXidGetPid=t=>(Module._BackendXidGetPid=wasmExports.BackendXidGetPid)(t),Module._lappend_int=(t,e)=>(Module._lappend_int=wasmExports.lappend_int)(t,e),Module._index_close=(t,e)=>(Module._index_close=wasmExports.index_close)(t,e),Module._table_close=(t,e)=>(Module._table_close=wasmExports.table_close)(t,e),Module._CommandCounterIncrement=()=>(Module._CommandCounterIncrement=wasmExports.CommandCounterIncrement)(),Module._GetActiveSnapshot=()=>(Module._GetActiveSnapshot=wasmExports.GetActiveSnapshot)(),Module._ScanKeyInit=(t,e,I,B,tr)=>(Module._ScanKeyInit=wasmExports.ScanKeyInit)(t,e,I,B,tr),Module._table_open=(t,e)=>(Module._table_open=wasmExports.table_open)(t,e),Module._systable_beginscan=(t,e,I,B,tr,rr)=>(Module._systable_beginscan=wasmExports.systable_beginscan)(t,e,I,B,tr,rr),Module._systable_getnext=t=>(Module._systable_getnext=wasmExports.systable_getnext)(t),Module._systable_endscan=t=>(Module._systable_endscan=wasmExports.systable_endscan)(t),Module._index_open=(t,e)=>(Module._index_open=wasmExports.index_open)(t,e),Module._systable_beginscan_ordered=(t,e,I,B,tr)=>(Module._systable_beginscan_ordered=wasmExports.systable_beginscan_ordered)(t,e,I,B,tr),Module._systable_getnext_ordered=(t,e)=>(Module._systable_getnext_ordered=wasmExports.systable_getnext_ordered)(t,e),Module._systable_endscan_ordered=t=>(Module._systable_endscan_ordered=wasmExports.systable_endscan_ordered)(t),Module._heap_form_tuple=(t,e,I)=>(Module._heap_form_tuple=wasmExports.heap_form_tuple)(t,e,I),Module._heap_freetuple=t=>(Module._heap_freetuple=wasmExports.heap_freetuple)(t),Module._AllocSetContextCreateInternal=(t,e,I,B,tr)=>(Module._AllocSetContextCreateInternal=wasmExports.AllocSetContextCreateInternal)(t,e,I,B,tr),Module._list_free_deep=t=>(Module._list_free_deep=wasmExports.list_free_deep)(t),Module._lappend=(t,e)=>(Module._lappend=wasmExports.lappend)(t,e),Module._LockBuffer=(t,e)=>(Module._LockBuffer=wasmExports.LockBuffer)(t,e),Module._GetFreeIndexPage=t=>(Module._GetFreeIndexPage=wasmExports.GetFreeIndexPage)(t),Module._RecordFreeIndexPage=(t,e)=>(Module._RecordFreeIndexPage=wasmExports.RecordFreeIndexPage)(t,e),Module._IndexFreeSpaceMapVacuum=t=>(Module._IndexFreeSpaceMapVacuum=wasmExports.IndexFreeSpaceMapVacuum)(t),Module._UnlockReleaseBuffer=t=>(Module._UnlockReleaseBuffer=wasmExports.UnlockReleaseBuffer)(t),Module._smgropen=(t,e)=>(Module._smgropen=wasmExports.smgropen)(t,e),Module._smgrsetowner=(t,e)=>(Module._smgrsetowner=wasmExports.smgrsetowner)(t,e),Module._RelationGetNumberOfBlocksInFork=(t,e)=>(Module._RelationGetNumberOfBlocksInFork=wasmExports.RelationGetNumberOfBlocksInFork)(t,e),Module._ReleaseBuffer=t=>(Module._ReleaseBuffer=wasmExports.ReleaseBuffer)(t),Module._GetRecordedFreeSpace=(t,e)=>(Module._GetRecordedFreeSpace=wasmExports.GetRecordedFreeSpace)(t,e),Module._smgrexists=(t,e)=>(Module._smgrexists=wasmExports.smgrexists)(t,e),Module._ReadBufferExtended=(t,e,I,B,tr)=>(Module._ReadBufferExtended=wasmExports.ReadBufferExtended)(t,e,I,B,tr),Module._MarkBufferDirty=t=>(Module._MarkBufferDirty=wasmExports.MarkBufferDirty)(t),Module._log_newpage_buffer=(t,e)=>(Module._log_newpage_buffer=wasmExports.log_newpage_buffer)(t,e),Module._copy_file=(t,e)=>(Module._copy_file=wasmExports.copy_file)(t,e),Module._fd_fsync_fname=(t,e)=>(Module._fd_fsync_fname=wasmExports.fd_fsync_fname)(t,e),Module._OpenTransientFile=(t,e)=>(Module._OpenTransientFile=wasmExports.OpenTransientFile)(t,e),Module._CloseTransientFile=t=>(Module._CloseTransientFile=wasmExports.CloseTransientFile)(t),Module._hash_bytes=(t,e)=>(Module._hash_bytes=wasmExports.hash_bytes)(t,e),Module._pstrdup=t=>(Module._pstrdup=wasmExports.pstrdup)(t),Module._repalloc=(t,e)=>(Module._repalloc=wasmExports.repalloc)(t,e),Module._wasm_OpenPipeStream=(t,e)=>(Module._wasm_OpenPipeStream=wasmExports.wasm_OpenPipeStream)(t,e),Module._access=(t,e)=>(Module._access=wasmExports.access)(t,e),Module._fopen=(t,e)=>(Module._fopen=wasmExports.fopen)(t,e),Module._fiprintf=(t,e,I)=>(Module._fiprintf=wasmExports.fiprintf)(t,e,I),Module._fclose=t=>(Module._fclose=wasmExports.fclose)(t),Module._fsync_fname_ext=(t,e,I,B)=>(Module._fsync_fname_ext=wasmExports.fsync_fname_ext)(t,e,I,B),Module._fd_durable_rename=(t,e,I)=>(Module._fd_durable_rename=wasmExports.fd_durable_rename)(t,e,I),Module._rename=(t,e)=>(Module._rename=wasmExports.rename)(t,e),Module._strlcpy=(t,e,I)=>(Module._strlcpy=wasmExports.strlcpy)(t,e,I),Module._dup=t=>(Module._dup=wasmExports.dup)(t),Module._open=(t,e,I)=>(Module._open=wasmExports.open)(t,e,I),Module._AcquireExternalFD=()=>(Module._AcquireExternalFD=wasmExports.AcquireExternalFD)(),Module._realloc=(t,e)=>(Module._realloc=wasmExports.realloc)(t,e),Module._stat=(t,e)=>(Module._stat=wasmExports.stat)(t,e),Module._pwrite=(t,e,I,B)=>(Module._pwrite=wasmExports.pwrite)(t,e,I,B),Module._lseek=(t,e,I)=>(Module._lseek=wasmExports.lseek)(t,e,I),Module._AllocateFile=(t,e)=>(Module._AllocateFile=wasmExports.AllocateFile)(t,e),Module._GetCurrentSubTransactionId=()=>(Module._GetCurrentSubTransactionId=wasmExports.GetCurrentSubTransactionId)(),Module._FreeFile=t=>(Module._FreeFile=wasmExports.FreeFile)(t),Module._pclose=t=>(Module._pclose=wasmExports.pclose)(t),Module._ClosePipeStream=t=>(Module._ClosePipeStream=wasmExports.ClosePipeStream)(t),Module._pg_prng_uint64_range=(t,e,I)=>(Module._pg_prng_uint64_range=wasmExports.pg_prng_uint64_range)(t,e,I),Module._AtEOSubXact_Files=(t,e,I)=>(Module._AtEOSubXact_Files=wasmExports.AtEOSubXact_Files)(t,e,I),Module._pre_format_elog_string=(t,e)=>(Module._pre_format_elog_string=wasmExports.pre_format_elog_string)(t,e),Module._format_elog_string=(t,e)=>(Module._format_elog_string=wasmExports.format_elog_string)(t,e),Module._list_free=t=>(Module._list_free=wasmExports.list_free)(t),Module._guc_malloc=(t,e)=>(Module._guc_malloc=wasmExports.guc_malloc)(t,e),Module._MemoryContextDelete=t=>(Module._MemoryContextDelete=wasmExports.MemoryContextDelete)(t),Module._strtoul=(t,e,I)=>(Module._strtoul=wasmExports.strtoul)(t,e,I),Module._hash_get_num_entries=t=>(Module._hash_get_num_entries=wasmExports.hash_get_num_entries)(t),Module._LWLockInitialize=(t,e)=>(Module._LWLockInitialize=wasmExports.LWLockInitialize)(t,e),Module._PrefetchBuffer=(t,e,I,B)=>(Module._PrefetchBuffer=wasmExports.PrefetchBuffer)(t,e,I,B),Module._LockBufHdr=t=>(Module._LockBufHdr=wasmExports.LockBufHdr)(t),Module._ReadBuffer=(t,e)=>(Module._ReadBuffer=wasmExports.ReadBuffer)(t,e),Module._pgstat_assoc_relation=t=>(Module._pgstat_assoc_relation=wasmExports.pgstat_assoc_relation)(t),Module._ExtendBufferedRel=(t,e,I,B)=>(Module._ExtendBufferedRel=wasmExports.ExtendBufferedRel)(t,e,I,B),Module._LockBufferForCleanup=t=>(Module._LockBufferForCleanup=wasmExports.LockBufferForCleanup)(t),Module._smgrread=(t,e,I,B)=>(Module._smgrread=wasmExports.smgrread)(t,e,I,B),Module._LockRelationForExtension=(t,e)=>(Module._LockRelationForExtension=wasmExports.LockRelationForExtension)(t,e),Module._UnlockRelationForExtension=(t,e)=>(Module._UnlockRelationForExtension=wasmExports.UnlockRelationForExtension)(t,e),Module._BufferGetBlockNumber=t=>(Module._BufferGetBlockNumber=wasmExports.BufferGetBlockNumber)(t),Module._bsearch=(t,e,I,B,tr)=>(Module._bsearch=wasmExports.bsearch)(t,e,I,B,tr),Module._set_errcontext_domain=t=>(Module._set_errcontext_domain=wasmExports.set_errcontext_domain)(t),Module._errcontext_msg=(t,e)=>(Module._errcontext_msg=wasmExports.errcontext_msg)(t,e),Module._GetAccessStrategy=t=>(Module._GetAccessStrategy=wasmExports.GetAccessStrategy)(t),Module._FreeAccessStrategy=t=>(Module._FreeAccessStrategy=wasmExports.FreeAccessStrategy)(t),Module._ConditionalLockBuffer=t=>(Module._ConditionalLockBuffer=wasmExports.ConditionalLockBuffer)(t),Module._TestForOldSnapshot_impl=(t,e)=>(Module._TestForOldSnapshot_impl=wasmExports.TestForOldSnapshot_impl)(t,e);var _calloc=Module._calloc=(t,e)=>(_calloc=Module._calloc=wasmExports.calloc)(t,e);Module._have_free_buffer=()=>(Module._have_free_buffer=wasmExports.have_free_buffer)(),Module._palloc0=t=>(Module._palloc0=wasmExports.palloc0)(t),Module._resetStringInfo=t=>(Module._resetStringInfo=wasmExports.resetStringInfo)(t),Module._appendStringInfoChar=(t,e)=>(Module._appendStringInfoChar=wasmExports.appendStringInfoChar)(t,e),Module._appendBinaryStringInfo=(t,e,I)=>(Module._appendBinaryStringInfo=wasmExports.appendBinaryStringInfo)(t,e,I),Module._errdetail_internal=(t,e)=>(Module._errdetail_internal=wasmExports.errdetail_internal)(t,e),Module._strcpy=(t,e)=>(Module._strcpy=wasmExports.strcpy)(t,e),Module._LWLockRegisterTranche=(t,e)=>(Module._LWLockRegisterTranche=wasmExports.LWLockRegisterTranche)(t,e),Module._GetNamedLWLockTranche=t=>(Module._GetNamedLWLockTranche=wasmExports.GetNamedLWLockTranche)(t),Module._LWLockNewTrancheId=()=>(Module._LWLockNewTrancheId=wasmExports.LWLockNewTrancheId)(),Module._RequestNamedLWLockTranche=(t,e)=>(Module._RequestNamedLWLockTranche=wasmExports.RequestNamedLWLockTranche)(t,e),Module._pg_prng_double=t=>(Module._pg_prng_double=wasmExports.pg_prng_double)(t),Module._getpid=()=>(Module._getpid=wasmExports.getpid)(),Module._GetTransactionSnapshot=()=>(Module._GetTransactionSnapshot=wasmExports.GetTransactionSnapshot)(),Module._ConditionVariableSignal=t=>(Module._ConditionVariableSignal=wasmExports.ConditionVariableSignal)(t),Module._LockPage=(t,e,I)=>(Module._LockPage=wasmExports.LockPage)(t,e,I),Module._UnlockPage=(t,e,I)=>(Module._UnlockPage=wasmExports.UnlockPage)(t,e,I),Module._pgstat_progress_update_param=(t,e)=>(Module._pgstat_progress_update_param=wasmExports.pgstat_progress_update_param)(t,e),Module._list_make1_impl=(t,e)=>(Module._list_make1_impl=wasmExports.list_make1_impl)(t,e),Module._psprintf=(t,e)=>(Module._psprintf=wasmExports.psprintf)(t,e),Module._smgrtruncate=(t,e,I,B)=>(Module._smgrtruncate=wasmExports.smgrtruncate)(t,e,I,B),Module._log=t=>(Module._log=wasmExports.log)(t),Module._pairingheap_allocate=(t,e)=>(Module._pairingheap_allocate=wasmExports.pairingheap_allocate)(t,e),Module._pairingheap_add=(t,e)=>(Module._pairingheap_add=wasmExports.pairingheap_add)(t,e),Module._pairingheap_first=t=>(Module._pairingheap_first=wasmExports.pairingheap_first)(t),Module._pairingheap_remove_first=t=>(Module._pairingheap_remove_first=wasmExports.pairingheap_remove_first)(t),Module._bloom_create=(t,e,I)=>(Module._bloom_create=wasmExports.bloom_create)(t,e,I),Module._bloom_free=t=>(Module._bloom_free=wasmExports.bloom_free)(t),Module._bloom_add_element=(t,e,I)=>(Module._bloom_add_element=wasmExports.bloom_add_element)(t,e,I),Module._hash_bytes_extended=(t,e,I)=>(Module._hash_bytes_extended=wasmExports.hash_bytes_extended)(t,e,I),Module._bloom_lacks_element=(t,e,I)=>(Module._bloom_lacks_element=wasmExports.bloom_lacks_element)(t,e,I),Module._bloom_prop_bits_set=t=>(Module._bloom_prop_bits_set=wasmExports.bloom_prop_bits_set)(t),Module._pg_popcount=(t,e)=>(Module._pg_popcount=wasmExports.pg_popcount)(t,e),Module._memcmp=(t,e,I)=>(Module._memcmp=wasmExports.memcmp)(t,e,I),Module._bms_make_singleton=t=>(Module._bms_make_singleton=wasmExports.bms_make_singleton)(t),Module._bms_add_members=(t,e)=>(Module._bms_add_members=wasmExports.bms_add_members)(t,e),Module._bms_add_member=(t,e)=>(Module._bms_add_member=wasmExports.bms_add_member)(t,e),Module._bms_del_member=(t,e)=>(Module._bms_del_member=wasmExports.bms_del_member)(t,e),Module._check_stack_depth=()=>(Module._check_stack_depth=wasmExports.check_stack_depth)(),Module._parser_errposition=(t,e)=>(Module._parser_errposition=wasmExports.parser_errposition)(t,e),Module._makeVar=(t,e,I,B,tr,rr)=>(Module._makeVar=wasmExports.makeVar)(t,e,I,B,tr,rr),Module._bms_union=(t,e)=>(Module._bms_union=wasmExports.bms_union)(t,e),Module._varstr_levenshtein_less_equal=(t,e,I,B,tr,rr,ir,lr,dr)=>(Module._varstr_levenshtein_less_equal=wasmExports.varstr_levenshtein_less_equal)(t,e,I,B,tr,rr,ir,lr,dr),Module._SearchSysCacheExists=(t,e,I,B,tr)=>(Module._SearchSysCacheExists=wasmExports.SearchSysCacheExists)(t,e,I,B,tr),Module._MemoryContextAllocZeroAligned=(t,e)=>(Module._MemoryContextAllocZeroAligned=wasmExports.MemoryContextAllocZeroAligned)(t,e),Module._makeString=t=>(Module._makeString=wasmExports.makeString)(t),Module._addRTEPermissionInfo=(t,e)=>(Module._addRTEPermissionInfo=wasmExports.addRTEPermissionInfo)(t,e),Module._copyObjectImpl=t=>(Module._copyObjectImpl=wasmExports.copyObjectImpl)(t),Module._exprType=t=>(Module._exprType=wasmExports.exprType)(t),Module._lappend_oid=(t,e)=>(Module._lappend_oid=wasmExports.lappend_oid)(t,e),Module._exprTypmod=t=>(Module._exprTypmod=wasmExports.exprTypmod)(t),Module._exprLocation=t=>(Module._exprLocation=wasmExports.exprLocation)(t),Module._CreateTemplateTupleDesc=t=>(Module._CreateTemplateTupleDesc=wasmExports.CreateTemplateTupleDesc)(t),Module._TupleDescInitEntry=(t,e,I,B,tr,rr)=>(Module._TupleDescInitEntry=wasmExports.TupleDescInitEntry)(t,e,I,B,tr,rr),Module._TupleDescInitEntryCollation=(t,e,I)=>(Module._TupleDescInitEntryCollation=wasmExports.TupleDescInitEntryCollation)(t,e,I),Module._typenameTypeIdAndMod=(t,e,I,B)=>(Module._typenameTypeIdAndMod=wasmExports.typenameTypeIdAndMod)(t,e,I,B),Module._format_type_be=t=>(Module._format_type_be=wasmExports.format_type_be)(t),Module._list_concat=(t,e)=>(Module._list_concat=wasmExports.list_concat)(t,e),Module._list_copy=t=>(Module._list_copy=wasmExports.list_copy)(t),Module._relation_open=(t,e)=>(Module._relation_open=wasmExports.relation_open)(t,e),Module._relation_close=(t,e)=>(Module._relation_close=wasmExports.relation_close)(t,e),Module._makeTargetEntry=(t,e,I,B)=>(Module._makeTargetEntry=wasmExports.makeTargetEntry)(t,e,I,B),Module._get_attname=(t,e,I)=>(Module._get_attname=wasmExports.get_attname)(t,e,I),Module._SearchSysCache2=(t,e,I)=>(Module._SearchSysCache2=wasmExports.SearchSysCache2)(t,e,I),Module._ReleaseSysCache=t=>(Module._ReleaseSysCache=wasmExports.ReleaseSysCache)(t),Module._RangeVarGetRelidExtended=(t,e,I,B,tr)=>(Module._RangeVarGetRelidExtended=wasmExports.RangeVarGetRelidExtended)(t,e,I,B,tr),Module._pg_mbstrlen_with_len=(t,e)=>(Module._pg_mbstrlen_with_len=wasmExports.pg_mbstrlen_with_len)(t,e),Module._errposition=t=>(Module._errposition=wasmExports.errposition)(t),Module._numeric_in=t=>(Module._numeric_in=wasmExports.numeric_in)(t),Module._DirectFunctionCall3Coll=(t,e,I,B,tr)=>(Module._DirectFunctionCall3Coll=wasmExports.DirectFunctionCall3Coll)(t,e,I,B,tr),Module._bit_in=t=>(Module._bit_in=wasmExports.bit_in)(t),Module._NameListToString=t=>(Module._NameListToString=wasmExports.NameListToString)(t),Module._appendStringInfoString=(t,e)=>(Module._appendStringInfoString=wasmExports.appendStringInfoString)(t,e),Module._lookup_type_cache=(t,e)=>(Module._lookup_type_cache=wasmExports.lookup_type_cache)(t,e),Module._CacheRegisterSyscacheCallback=(t,e,I)=>(Module._CacheRegisterSyscacheCallback=wasmExports.CacheRegisterSyscacheCallback)(t,e,I),Module._SearchSysCache1=(t,e)=>(Module._SearchSysCache1=wasmExports.SearchSysCache1)(t,e),Module._list_make2_impl=(t,e,I)=>(Module._list_make2_impl=wasmExports.list_make2_impl)(t,e,I),Module._get_base_element_type=t=>(Module._get_base_element_type=wasmExports.get_base_element_type)(t),Module._downcase_truncate_identifier=(t,e,I)=>(Module._downcase_truncate_identifier=wasmExports.downcase_truncate_identifier)(t,e,I),Module._pg_database_encoding_max_length=()=>(Module._pg_database_encoding_max_length=wasmExports.pg_database_encoding_max_length)(),Module._truncate_identifier=(t,e,I)=>(Module._truncate_identifier=wasmExports.truncate_identifier)(t,e,I),Module._scanner_isspace=t=>(Module._scanner_isspace=wasmExports.scanner_isspace)(t),Module._get_typcollation=t=>(Module._get_typcollation=wasmExports.get_typcollation)(t),Module._list_delete_cell=(t,e)=>(Module._list_delete_cell=wasmExports.list_delete_cell)(t,e),Module._makeTypeNameFromNameList=t=>(Module._makeTypeNameFromNameList=wasmExports.makeTypeNameFromNameList)(t),Module._SysCacheGetAttrNotNull=(t,e,I)=>(Module._SysCacheGetAttrNotNull=wasmExports.SysCacheGetAttrNotNull)(t,e,I),Module._text_to_cstring=t=>(Module._text_to_cstring=wasmExports.text_to_cstring)(t),Module._stringToNode=t=>(Module._stringToNode=wasmExports.stringToNode)(t),Module._bms_is_member=(t,e)=>(Module._bms_is_member=wasmExports.bms_is_member)(t,e),Module._bms_free=t=>(Module._bms_free=wasmExports.bms_free)(t),Module._core_yylex=(t,e,I)=>(Module._core_yylex=wasmExports.core_yylex)(t,e,I),Module._getc=t=>(Module._getc=wasmExports.getc)(t),Module._ferror=t=>(Module._ferror=wasmExports.ferror)(t),Module._fread=(t,e,I,B)=>(Module._fread=wasmExports.fread)(t,e,I,B),Module._clearerr=t=>(Module._clearerr=wasmExports.clearerr)(t),Module._scanner_init=(t,e,I,B)=>(Module._scanner_init=wasmExports.scanner_init)(t,e,I,B),Module._scanner_finish=t=>(Module._scanner_finish=wasmExports.scanner_finish)(t),Module._get_namespace_name=t=>(Module._get_namespace_name=wasmExports.get_namespace_name)(t),Module._lookup_rowtype_tupdesc=(t,e)=>(Module._lookup_rowtype_tupdesc=wasmExports.lookup_rowtype_tupdesc)(t,e),Module._DecrTupleDescRefCount=t=>(Module._DecrTupleDescRefCount=wasmExports.DecrTupleDescRefCount)(t),Module._relation_openrv=(t,e)=>(Module._relation_openrv=wasmExports.relation_openrv)(t,e),Module._errdetail_relkind_not_supported=t=>(Module._errdetail_relkind_not_supported=wasmExports.errdetail_relkind_not_supported)(t),Module._object_aclcheck=(t,e,I,B)=>(Module._object_aclcheck=wasmExports.object_aclcheck)(t,e,I,B),Module._aclcheck_error=(t,e,I)=>(Module._aclcheck_error=wasmExports.aclcheck_error)(t,e,I),Module._pg_class_aclcheck=(t,e,I)=>(Module._pg_class_aclcheck=wasmExports.pg_class_aclcheck)(t,e,I),Module._get_relkind_objtype=t=>(Module._get_relkind_objtype=wasmExports.get_relkind_objtype)(t),Module._list_make3_impl=(t,e,I,B)=>(Module._list_make3_impl=wasmExports.list_make3_impl)(t,e,I,B),Module._quote_qualified_identifier=(t,e)=>(Module._quote_qualified_identifier=wasmExports.quote_qualified_identifier)(t,e),Module._table_openrv=(t,e)=>(Module._table_openrv=wasmExports.table_openrv)(t,e),Module._equal=(t,e)=>(Module._equal=wasmExports.equal)(t,e),Module._RelationGetIndexList=t=>(Module._RelationGetIndexList=wasmExports.RelationGetIndexList)(t),Module._pg_detoast_datum=t=>(Module._pg_detoast_datum=wasmExports.pg_detoast_datum)(t),Module._SysCacheGetAttr=(t,e,I,B)=>(Module._SysCacheGetAttr=wasmExports.SysCacheGetAttr)(t,e,I,B),Module._deconstruct_array_builtin=(t,e,I,B,tr)=>(Module._deconstruct_array_builtin=wasmExports.deconstruct_array_builtin)(t,e,I,B,tr),Module._untransformRelOptions=t=>(Module._untransformRelOptions=wasmExports.untransformRelOptions)(t),Module._transformExpr=(t,e,I)=>(Module._transformExpr=wasmExports.transformExpr)(t,e,I),Module._get_rel_namespace=t=>(Module._get_rel_namespace=wasmExports.get_rel_namespace)(t),Module._get_rel_name=t=>(Module._get_rel_name=wasmExports.get_rel_name)(t),Module._makeRangeVar=(t,e,I)=>(Module._makeRangeVar=wasmExports.makeRangeVar)(t,e,I),Module._makeDefElem=(t,e,I)=>(Module._makeDefElem=wasmExports.makeDefElem)(t,e,I),Module._makeRangeVarFromNameList=t=>(Module._makeRangeVarFromNameList=wasmExports.makeRangeVarFromNameList)(t),Module._coerce_to_target_type=(t,e,I,B,tr,rr,ir,lr)=>(Module._coerce_to_target_type=wasmExports.coerce_to_target_type)(t,e,I,B,tr,rr,ir,lr),Module._LookupTypeName=(t,e,I,B)=>(Module._LookupTypeName=wasmExports.LookupTypeName)(t,e,I,B),Module._GetSysCacheOid=(t,e,I,B,tr,rr)=>(Module._GetSysCacheOid=wasmExports.GetSysCacheOid)(t,e,I,B,tr,rr),Module._construct_array_builtin=(t,e,I)=>(Module._construct_array_builtin=wasmExports.construct_array_builtin)(t,e,I),Module._get_collation_oid=(t,e)=>(Module._get_collation_oid=wasmExports.get_collation_oid)(t,e),Module._typeStringToTypeName=(t,e)=>(Module._typeStringToTypeName=wasmExports.typeStringToTypeName)(t,e),Module._raw_parser=(t,e)=>(Module._raw_parser=wasmExports.raw_parser)(t,e),Module._errsave_start=(t,e)=>(Module._errsave_start=wasmExports.errsave_start)(t,e),Module._errsave_finish=(t,e,I,B)=>(Module._errsave_finish=wasmExports.errsave_finish)(t,e,I,B),Module._defGetBoolean=t=>(Module._defGetBoolean=wasmExports.defGetBoolean)(t),Module._list_delete_last=t=>(Module._list_delete_last=wasmExports.list_delete_last)(t),Module._format_type_with_typemod=(t,e)=>(Module._format_type_with_typemod=wasmExports.format_type_with_typemod)(t,e),Module._list_member=(t,e)=>(Module._list_member=wasmExports.list_member)(t,e),Module._list_member_int=(t,e)=>(Module._list_member_int=wasmExports.list_member_int)(t,e),Module._list_sort=(t,e)=>(Module._list_sort=wasmExports.list_sort)(t,e),Module._get_element_type=t=>(Module._get_element_type=wasmExports.get_element_type)(t),Module._makeBoolean=t=>(Module._makeBoolean=wasmExports.makeBoolean)(t),Module._makeInteger=t=>(Module._makeInteger=wasmExports.makeInteger)(t),Module._makeTypeName=t=>(Module._makeTypeName=wasmExports.makeTypeName)(t),Module._list_make4_impl=(t,e,I,B,tr)=>(Module._list_make4_impl=wasmExports.list_make4_impl)(t,e,I,B,tr),Module._isxdigit=t=>(Module._isxdigit=wasmExports.isxdigit)(t),Module._strip_implicit_coercions=t=>(Module._strip_implicit_coercions=wasmExports.strip_implicit_coercions)(t),Module._SearchSysCacheList=(t,e,I,B,tr)=>(Module._SearchSysCacheList=wasmExports.SearchSysCacheList)(t,e,I,B,tr),Module._ReleaseCatCacheList=t=>(Module._ReleaseCatCacheList=wasmExports.ReleaseCatCacheList)(t),Module._get_sortgroupref_tle=(t,e)=>(Module._get_sortgroupref_tle=wasmExports.get_sortgroupref_tle)(t,e),Module._type_is_rowtype=t=>(Module._type_is_rowtype=wasmExports.type_is_rowtype)(t),Module._bms_next_member=(t,e)=>(Module._bms_next_member=wasmExports.bms_next_member)(t,e),Module._MemoryContextReset=t=>(Module._MemoryContextReset=wasmExports.MemoryContextReset)(t),Module._abort=()=>(Module._abort=wasmExports.abort)(),Module._heap_getnext=(t,e)=>(Module._heap_getnext=wasmExports.heap_getnext)(t,e),Module._OidOutputFunctionCall=(t,e)=>(Module._OidOutputFunctionCall=wasmExports.OidOutputFunctionCall)(t,e),Module._atoi=t=>(Module._atoi=wasmExports.atoi)(t),Module._GetConfigOption=(t,e,I)=>(Module._GetConfigOption=wasmExports.GetConfigOption)(t,e,I),Module._pg_strong_random=(t,e)=>(Module._pg_strong_random=wasmExports.pg_strong_random)(t,e),Module._pg_prng_seed_check=t=>(Module._pg_prng_seed_check=wasmExports.pg_prng_seed_check)(t),Module._pg_prng_seed=(t,e)=>(Module._pg_prng_seed=wasmExports.pg_prng_seed)(t,e),Module._fputc=(t,e)=>(Module._fputc=wasmExports.fputc)(t,e),Module._time=t=>(Module._time=wasmExports.time)(t),Module._TimestampDifferenceMilliseconds=(t,e)=>(Module._TimestampDifferenceMilliseconds=wasmExports.TimestampDifferenceMilliseconds)(t,e),Module._ProcessConfigFile=t=>(Module._ProcessConfigFile=wasmExports.ProcessConfigFile)(t),Module._send=(t,e,I,B)=>(Module._send=wasmExports.send)(t,e,I,B),Module._parse_bool=(t,e)=>(Module._parse_bool=wasmExports.parse_bool)(t,e),Module._enlargeStringInfo=(t,e)=>(Module._enlargeStringInfo=wasmExports.enlargeStringInfo)(t,e),Module._BackgroundWorkerInitializeConnectionByOid=(t,e,I)=>(Module._BackgroundWorkerInitializeConnectionByOid=wasmExports.BackgroundWorkerInitializeConnectionByOid)(t,e,I),Module._BackgroundWorkerUnblockSignals=()=>(Module._BackgroundWorkerUnblockSignals=wasmExports.BackgroundWorkerUnblockSignals)(),Module._pg_getnameinfo_all=(t,e,I,B,tr,rr,ir)=>(Module._pg_getnameinfo_all=wasmExports.pg_getnameinfo_all)(t,e,I,B,tr,rr,ir),Module._gai_strerror=t=>(Module._gai_strerror=wasmExports.gai_strerror)(t),Module._SignalHandlerForConfigReload=t=>(Module._SignalHandlerForConfigReload=wasmExports.SignalHandlerForConfigReload)(t),Module._fwrite=(t,e,I,B)=>(Module._fwrite=wasmExports.fwrite)(t,e,I,B),Module._SignalHandlerForShutdownRequest=t=>(Module._SignalHandlerForShutdownRequest=wasmExports.SignalHandlerForShutdownRequest)(t),Module._EmitErrorReport=()=>(Module._EmitErrorReport=wasmExports.EmitErrorReport)(),Module._FlushErrorState=()=>(Module._FlushErrorState=wasmExports.FlushErrorState)(),Module._die=t=>(Module._die=wasmExports.die)(t),Module._MultiXactIdPrecedes=(t,e)=>(Module._MultiXactIdPrecedes=wasmExports.MultiXactIdPrecedes)(t,e),Module._CreateTupleDescCopy=t=>(Module._CreateTupleDescCopy=wasmExports.CreateTupleDescCopy)(t),Module._pgstat_report_activity=(t,e)=>(Module._pgstat_report_activity=wasmExports.pgstat_report_activity)(t,e),Module._DirectFunctionCall2Coll=(t,e,I,B)=>(Module._DirectFunctionCall2Coll=wasmExports.DirectFunctionCall2Coll)(t,e,I,B),Module._RegisterBackgroundWorker=t=>(Module._RegisterBackgroundWorker=wasmExports.RegisterBackgroundWorker)(t),Module._RegisterDynamicBackgroundWorker=(t,e)=>(Module._RegisterDynamicBackgroundWorker=wasmExports.RegisterDynamicBackgroundWorker)(t,e),Module._WaitForBackgroundWorkerStartup=(t,e)=>(Module._WaitForBackgroundWorkerStartup=wasmExports.WaitForBackgroundWorkerStartup)(t,e),Module._WaitForBackgroundWorkerShutdown=t=>(Module._WaitForBackgroundWorkerShutdown=wasmExports.WaitForBackgroundWorkerShutdown)(t),Module._GetXLogReplayRecPtr=t=>(Module._GetXLogReplayRecPtr=wasmExports.GetXLogReplayRecPtr)(t),Module._gettimeofday=(t,e)=>(Module._gettimeofday=wasmExports.gettimeofday)(t,e),Module._sscanf=(t,e,I)=>(Module._sscanf=wasmExports.sscanf)(t,e,I),Module._get_call_result_type=(t,e,I)=>(Module._get_call_result_type=wasmExports.get_call_result_type)(t,e,I),Module._HeapTupleHeaderGetDatum=t=>(Module._HeapTupleHeaderGetDatum=wasmExports.HeapTupleHeaderGetDatum)(t),Module._wal_segment_close=t=>(Module._wal_segment_close=wasmExports.wal_segment_close)(t),Module._wal_segment_open=(t,e,I)=>(Module._wal_segment_open=wasmExports.wal_segment_open)(t,e,I),Module._GetFlushRecPtr=t=>(Module._GetFlushRecPtr=wasmExports.GetFlushRecPtr)(t),Module._XLogReadRecord=(t,e)=>(Module._XLogReadRecord=wasmExports.XLogReadRecord)(t,e),Module._RmgrNotFound=t=>(Module._RmgrNotFound=wasmExports.RmgrNotFound)(t),Module._CacheRegisterRelcacheCallback=(t,e)=>(Module._CacheRegisterRelcacheCallback=wasmExports.CacheRegisterRelcacheCallback)(t,e),Module._free_attrmap=t=>(Module._free_attrmap=wasmExports.free_attrmap)(t),Module._BuildIndexInfo=t=>(Module._BuildIndexInfo=wasmExports.BuildIndexInfo)(t),Module._hash_seq_term=t=>(Module._hash_seq_term=wasmExports.hash_seq_term)(t),Module._PushActiveSnapshot=t=>(Module._PushActiveSnapshot=wasmExports.PushActiveSnapshot)(t),Module._PopActiveSnapshot=()=>(Module._PopActiveSnapshot=wasmExports.PopActiveSnapshot)(),Module._MakePerTupleExprContext=t=>(Module._MakePerTupleExprContext=wasmExports.MakePerTupleExprContext)(t),Module._ExecInitExpr=(t,e)=>(Module._ExecInitExpr=wasmExports.ExecInitExpr)(t,e),Module._FreeExecutorState=t=>(Module._FreeExecutorState=wasmExports.FreeExecutorState)(t),Module._list_member_oid=(t,e)=>(Module._list_member_oid=wasmExports.list_member_oid)(t,e),Module._MemoryContextStrdup=(t,e)=>(Module._MemoryContextStrdup=wasmExports.MemoryContextStrdup)(t,e),Module._pq_getmsgint=(t,e)=>(Module._pq_getmsgint=wasmExports.pq_getmsgint)(t,e),Module._CreateExecutorState=()=>(Module._CreateExecutorState=wasmExports.CreateExecutorState)(),Module._ExecInitRangeTable=(t,e,I)=>(Module._ExecInitRangeTable=wasmExports.ExecInitRangeTable)(t,e,I),Module._getTypeInputInfo=(t,e,I)=>(Module._getTypeInputInfo=wasmExports.getTypeInputInfo)(t,e,I),Module._ExecStoreVirtualTuple=t=>(Module._ExecStoreVirtualTuple=wasmExports.ExecStoreVirtualTuple)(t),Module._execute_attr_map_slot=(t,e,I)=>(Module._execute_attr_map_slot=wasmExports.execute_attr_map_slot)(t,e,I),Module._slot_getsomeattrs_int=(t,e)=>(Module._slot_getsomeattrs_int=wasmExports.slot_getsomeattrs_int)(t,e),Module._GetUserNameFromId=(t,e)=>(Module._GetUserNameFromId=wasmExports.GetUserNameFromId)(t,e),Module._makeStringInfo=()=>(Module._makeStringInfo=wasmExports.makeStringInfo)(),Module._list_member_xid=(t,e)=>(Module._list_member_xid=wasmExports.list_member_xid)(t,e),Module._lappend_xid=(t,e)=>(Module._lappend_xid=wasmExports.lappend_xid)(t,e),Module._tuplestore_end=t=>(Module._tuplestore_end=wasmExports.tuplestore_end)(t),Module._quote_literal_cstr=t=>(Module._quote_literal_cstr=wasmExports.quote_literal_cstr)(t),Module._MakeSingleTupleTableSlot=(t,e)=>(Module._MakeSingleTupleTableSlot=wasmExports.MakeSingleTupleTableSlot)(t,e),Module._ExecDropSingleTupleTableSlot=t=>(Module._ExecDropSingleTupleTableSlot=wasmExports.ExecDropSingleTupleTableSlot)(t),Module._tuplestore_tuple_count=t=>(Module._tuplestore_tuple_count=wasmExports.tuplestore_tuple_count)(t),Module._quote_identifier=t=>(Module._quote_identifier=wasmExports.quote_identifier)(t),Module._BeginCopyFrom=(t,e,I,B,tr,rr,ir,lr)=>(Module._BeginCopyFrom=wasmExports.BeginCopyFrom)(t,e,I,B,tr,rr,ir,lr),Module._array_contains_nulls=t=>(Module._array_contains_nulls=wasmExports.array_contains_nulls)(t),Module._format_procedure=t=>(Module._format_procedure=wasmExports.format_procedure)(t),Module._pg_detoast_datum_packed=t=>(Module._pg_detoast_datum_packed=wasmExports.pg_detoast_datum_packed)(t),Module._cstring_to_text_with_len=(t,e)=>(Module._cstring_to_text_with_len=wasmExports.cstring_to_text_with_len)(t,e),Module._GenerationContextCreate=(t,e,I,B,tr)=>(Module._GenerationContextCreate=wasmExports.GenerationContextCreate)(t,e,I,B,tr),Module._BeginInternalSubTransaction=t=>(Module._BeginInternalSubTransaction=wasmExports.BeginInternalSubTransaction)(t),Module._RollbackAndReleaseCurrentSubTransaction=()=>(Module._RollbackAndReleaseCurrentSubTransaction=wasmExports.RollbackAndReleaseCurrentSubTransaction)(),Module._CopyErrorData=()=>(Module._CopyErrorData=wasmExports.CopyErrorData)(),Module._FreeErrorData=t=>(Module._FreeErrorData=wasmExports.FreeErrorData)(t),Module._RelidByRelfilenumber=(t,e)=>(Module._RelidByRelfilenumber=wasmExports.RelidByRelfilenumber)(t,e),Module._RelationIdGetRelation=t=>(Module._RelationIdGetRelation=wasmExports.RelationIdGetRelation)(t),Module._heap_deform_tuple=(t,e,I,B)=>(Module._heap_deform_tuple=wasmExports.heap_deform_tuple)(t,e,I,B),Module._RelationClose=t=>(Module._RelationClose=wasmExports.RelationClose)(t),Module._nocachegetattr=(t,e,I)=>(Module._nocachegetattr=wasmExports.nocachegetattr)(t,e,I),Module._XLogReaderAllocate=(t,e,I,B)=>(Module._XLogReaderAllocate=wasmExports.XLogReaderAllocate)(t,e,I,B),Module._XLogReaderFree=t=>(Module._XLogReaderFree=wasmExports.XLogReaderFree)(t),Module._OutputPluginPrepareWrite=(t,e)=>(Module._OutputPluginPrepareWrite=wasmExports.OutputPluginPrepareWrite)(t,e),Module._OutputPluginWrite=(t,e)=>(Module._OutputPluginWrite=wasmExports.OutputPluginWrite)(t,e),Module._OutputPluginUpdateProgress=(t,e)=>(Module._OutputPluginUpdateProgress=wasmExports.OutputPluginUpdateProgress)(t,e),Module._replorigin_by_oid=(t,e,I)=>(Module._replorigin_by_oid=wasmExports.replorigin_by_oid)(t,e,I),Module._logicalrep_write_begin=(t,e)=>(Module._logicalrep_write_begin=wasmExports.logicalrep_write_begin)(t,e),Module._logicalrep_write_commit=(t,e,I)=>(Module._logicalrep_write_commit=wasmExports.logicalrep_write_commit)(t,e,I),Module._logicalrep_write_begin_prepare=(t,e)=>(Module._logicalrep_write_begin_prepare=wasmExports.logicalrep_write_begin_prepare)(t,e),Module._logicalrep_write_prepare=(t,e,I)=>(Module._logicalrep_write_prepare=wasmExports.logicalrep_write_prepare)(t,e,I),Module._logicalrep_write_commit_prepared=(t,e,I)=>(Module._logicalrep_write_commit_prepared=wasmExports.logicalrep_write_commit_prepared)(t,e,I),Module._logicalrep_write_rollback_prepared=(t,e,I,B)=>(Module._logicalrep_write_rollback_prepared=wasmExports.logicalrep_write_rollback_prepared)(t,e,I,B),Module._logicalrep_write_stream_prepare=(t,e,I)=>(Module._logicalrep_write_stream_prepare=wasmExports.logicalrep_write_stream_prepare)(t,e,I),Module._logicalrep_write_origin=(t,e,I)=>(Module._logicalrep_write_origin=wasmExports.logicalrep_write_origin)(t,e,I),Module._logicalrep_write_insert=(t,e,I,B,tr,rr)=>(Module._logicalrep_write_insert=wasmExports.logicalrep_write_insert)(t,e,I,B,tr,rr),Module._logicalrep_write_update=(t,e,I,B,tr,rr,ir)=>(Module._logicalrep_write_update=wasmExports.logicalrep_write_update)(t,e,I,B,tr,rr,ir),Module._logicalrep_write_delete=(t,e,I,B,tr,rr)=>(Module._logicalrep_write_delete=wasmExports.logicalrep_write_delete)(t,e,I,B,tr,rr),Module._logicalrep_write_truncate=(t,e,I,B,tr,rr)=>(Module._logicalrep_write_truncate=wasmExports.logicalrep_write_truncate)(t,e,I,B,tr,rr),Module._logicalrep_write_message=(t,e,I,B,tr,rr,ir)=>(Module._logicalrep_write_message=wasmExports.logicalrep_write_message)(t,e,I,B,tr,rr,ir),Module._logicalrep_write_rel=(t,e,I,B)=>(Module._logicalrep_write_rel=wasmExports.logicalrep_write_rel)(t,e,I,B),Module._logicalrep_write_typ=(t,e,I)=>(Module._logicalrep_write_typ=wasmExports.logicalrep_write_typ)(t,e,I),Module._logicalrep_write_stream_start=(t,e,I)=>(Module._logicalrep_write_stream_start=wasmExports.logicalrep_write_stream_start)(t,e,I),Module._logicalrep_write_stream_stop=t=>(Module._logicalrep_write_stream_stop=wasmExports.logicalrep_write_stream_stop)(t),Module._logicalrep_write_stream_commit=(t,e,I)=>(Module._logicalrep_write_stream_commit=wasmExports.logicalrep_write_stream_commit)(t,e,I),Module._logicalrep_write_stream_abort=(t,e,I,B,tr,rr)=>(Module._logicalrep_write_stream_abort=wasmExports.logicalrep_write_stream_abort)(t,e,I,B,tr,rr),Module._ProcessWalRcvInterrupts=()=>(Module._ProcessWalRcvInterrupts=wasmExports.ProcessWalRcvInterrupts)(),Module._timestamptz_to_str=t=>(Module._timestamptz_to_str=wasmExports.timestamptz_to_str)(t),Module._GetDatabaseEncodingName=()=>(Module._GetDatabaseEncodingName=wasmExports.GetDatabaseEncodingName)(),Module._PQconnectStartParams=(t,e,I)=>(Module._PQconnectStartParams=wasmExports.PQconnectStartParams)(t,e,I),Module._PQstatus=t=>(Module._PQstatus=wasmExports.PQstatus)(t),Module._PQsocket=t=>(Module._PQsocket=wasmExports.PQsocket)(t),Module._PQconnectPoll=t=>(Module._PQconnectPoll=wasmExports.PQconnectPoll)(t),Module._PQconnectionUsedPassword=t=>(Module._PQconnectionUsedPassword=wasmExports.PQconnectionUsedPassword)(t),Module._PQfinish=t=>(Module._PQfinish=wasmExports.PQfinish)(t),Module._PQresultStatus=t=>(Module._PQresultStatus=wasmExports.PQresultStatus)(t),Module._PQclear=t=>(Module._PQclear=wasmExports.PQclear)(t),Module._PQerrorMessage=t=>(Module._PQerrorMessage=wasmExports.PQerrorMessage)(t),Module._pchomp=t=>(Module._pchomp=wasmExports.pchomp)(t),Module._PQnfields=t=>(Module._PQnfields=wasmExports.PQnfields)(t),Module._PQntuples=t=>(Module._PQntuples=wasmExports.PQntuples)(t),Module._PQgetvalue=(t,e,I)=>(Module._PQgetvalue=wasmExports.PQgetvalue)(t,e,I),Module._pg_strtoint32=t=>(Module._pg_strtoint32=wasmExports.pg_strtoint32)(t),Module._PQconsumeInput=t=>(Module._PQconsumeInput=wasmExports.PQconsumeInput)(t),Module._pg_lsn_in=t=>(Module._pg_lsn_in=wasmExports.pg_lsn_in)(t),Module._DirectFunctionCall1Coll=(t,e,I)=>(Module._DirectFunctionCall1Coll=wasmExports.DirectFunctionCall1Coll)(t,e,I),Module._PQgetisnull=(t,e,I)=>(Module._PQgetisnull=wasmExports.PQgetisnull)(t,e,I),Module._tuplestore_begin_heap=(t,e,I)=>(Module._tuplestore_begin_heap=wasmExports.tuplestore_begin_heap)(t,e,I),Module._TupleDescGetAttInMetadata=t=>(Module._TupleDescGetAttInMetadata=wasmExports.TupleDescGetAttInMetadata)(t),Module._BuildTupleFromCStrings=(t,e)=>(Module._BuildTupleFromCStrings=wasmExports.BuildTupleFromCStrings)(t,e),Module._tuplestore_puttuple=(t,e)=>(Module._tuplestore_puttuple=wasmExports.tuplestore_puttuple)(t,e),Module._PQresultErrorField=(t,e)=>(Module._PQresultErrorField=wasmExports.PQresultErrorField)(t,e),Module._PQsendQuery=(t,e)=>(Module._PQsendQuery=wasmExports.PQsendQuery)(t,e),Module._PQisBusy=t=>(Module._PQisBusy=wasmExports.PQisBusy)(t),Module._PQgetResult=t=>(Module._PQgetResult=wasmExports.PQgetResult)(t),Module._ResourceOwnerDelete=t=>(Module._ResourceOwnerDelete=wasmExports.ResourceOwnerDelete)(t),Module._CreateDestReceiver=t=>(Module._CreateDestReceiver=wasmExports.CreateDestReceiver)(t),Module._defGetString=t=>(Module._defGetString=wasmExports.defGetString)(t),Module._pg_md5_encrypt=(t,e,I,B,tr)=>(Module._pg_md5_encrypt=wasmExports.pg_md5_encrypt)(t,e,I,B,tr),Module._plain_crypt_verify=(t,e,I,B)=>(Module._plain_crypt_verify=wasmExports.plain_crypt_verify)(t,e,I,B),Module._pg_b64_enc_len=t=>(Module._pg_b64_enc_len=wasmExports.pg_b64_enc_len)(t),Module._pg_b64_encode=(t,e,I,B)=>(Module._pg_b64_encode=wasmExports.pg_b64_encode)(t,e,I,B),Module._pg_b64_dec_len=t=>(Module._pg_b64_dec_len=wasmExports.pg_b64_dec_len)(t),Module._pg_b64_decode=(t,e,I,B)=>(Module._pg_b64_decode=wasmExports.pg_b64_decode)(t,e,I,B),Module._pg_hmac_create=t=>(Module._pg_hmac_create=wasmExports.pg_hmac_create)(t),Module._pg_hmac_init=(t,e,I)=>(Module._pg_hmac_init=wasmExports.pg_hmac_init)(t,e,I),Module._pg_hmac_update=(t,e,I)=>(Module._pg_hmac_update=wasmExports.pg_hmac_update)(t,e,I),Module._pg_hmac_final=(t,e,I)=>(Module._pg_hmac_final=wasmExports.pg_hmac_final)(t,e,I),Module._pg_hmac_error=t=>(Module._pg_hmac_error=wasmExports.pg_hmac_error)(t),Module._pg_hmac_free=t=>(Module._pg_hmac_free=wasmExports.pg_hmac_free)(t),Module._scram_H=(t,e,I,B,tr)=>(Module._scram_H=wasmExports.scram_H)(t,e,I,B,tr),Module._pg_saslprep=(t,e)=>(Module._pg_saslprep=wasmExports.pg_saslprep)(t,e),Module._scram_build_secret=(t,e,I,B,tr,rr,ir)=>(Module._scram_build_secret=wasmExports.scram_build_secret)(t,e,I,B,tr,rr,ir),Module._scram_SaltedPassword=(t,e,I,B,tr,rr,ir,lr)=>(Module._scram_SaltedPassword=wasmExports.scram_SaltedPassword)(t,e,I,B,tr,rr,ir,lr),Module._scram_ServerKey=(t,e,I,B,tr)=>(Module._scram_ServerKey=wasmExports.scram_ServerKey)(t,e,I,B,tr),Module._strtol=(t,e,I)=>(Module._strtol=wasmExports.strtol)(t,e,I),Module._replace_percent_placeholders=(t,e,I,B)=>(Module._replace_percent_placeholders=wasmExports.replace_percent_placeholders)(t,e,I,B),Module._fgets=(t,e,I)=>(Module._fgets=wasmExports.fgets)(t,e,I),Module._explicit_bzero=(t,e)=>(Module._explicit_bzero=wasmExports.explicit_bzero)(t,e),Module._wait_result_to_str=t=>(Module._wait_result_to_str=wasmExports.wait_result_to_str)(t),Module._pg_strip_crlf=t=>(Module._pg_strip_crlf=wasmExports.pg_strip_crlf)(t),Module._geteuid=()=>(Module._geteuid=wasmExports.geteuid)(),Module._getpeereid=(t,e,I)=>(Module._getpeereid=wasmExports.getpeereid)(t,e,I),Module._pg_getaddrinfo_all=(t,e,I,B)=>(Module._pg_getaddrinfo_all=wasmExports.pg_getaddrinfo_all)(t,e,I,B),Module._socket=(t,e,I)=>(Module._socket=wasmExports.socket)(t,e,I),Module._connect=(t,e,I)=>(Module._connect=wasmExports.connect)(t,e,I),Module._recv=(t,e,I,B)=>(Module._recv=wasmExports.recv)(t,e,I,B),Module._pg_freeaddrinfo_all=(t,e)=>(Module._pg_freeaddrinfo_all=wasmExports.pg_freeaddrinfo_all)(t,e),Module._pq_sendtext=(t,e,I)=>(Module._pq_sendtext=wasmExports.pq_sendtext)(t,e,I),Module._pq_sendfloat4=(t,e)=>(Module._pq_sendfloat4=wasmExports.pq_sendfloat4)(t,e),Module._pq_sendfloat8=(t,e)=>(Module._pq_sendfloat8=wasmExports.pq_sendfloat8)(t,e),Module._pq_begintypsend=t=>(Module._pq_begintypsend=wasmExports.pq_begintypsend)(t),Module._pq_endtypsend=t=>(Module._pq_endtypsend=wasmExports.pq_endtypsend)(t),Module._pq_getmsgfloat4=t=>(Module._pq_getmsgfloat4=wasmExports.pq_getmsgfloat4)(t),Module._pq_getmsgfloat8=t=>(Module._pq_getmsgfloat8=wasmExports.pq_getmsgfloat8)(t),Module._pq_getmsgtext=(t,e,I)=>(Module._pq_getmsgtext=wasmExports.pq_getmsgtext)(t,e,I),Module._feof=t=>(Module._feof=wasmExports.feof)(t),Module._pg_mb2wchar_with_len=(t,e,I)=>(Module._pg_mb2wchar_with_len=wasmExports.pg_mb2wchar_with_len)(t,e,I),Module._pg_regcomp=(t,e,I,B,tr)=>(Module._pg_regcomp=wasmExports.pg_regcomp)(t,e,I,B,tr),Module._pg_regerror=(t,e,I,B)=>(Module._pg_regerror=wasmExports.pg_regerror)(t,e,I,B),Module._get_role_oid=(t,e)=>(Module._get_role_oid=wasmExports.get_role_oid)(t,e),Module._strcat=(t,e)=>(Module._strcat=wasmExports.strcat)(t,e),Module._sigemptyset=t=>(Module._sigemptyset=wasmExports.sigemptyset)(t),Module._be_lo_unlink=t=>(Module._be_lo_unlink=wasmExports.be_lo_unlink)(t),Module._object_ownercheck=(t,e,I)=>(Module._object_ownercheck=wasmExports.object_ownercheck)(t,e,I),Module._text_to_cstring_buffer=(t,e,I)=>(Module._text_to_cstring_buffer=wasmExports.text_to_cstring_buffer)(t,e,I),Module._setsockopt=(t,e,I,B,tr)=>(Module._setsockopt=wasmExports.setsockopt)(t,e,I,B,tr),Module._getsockname=(t,e,I)=>(Module._getsockname=wasmExports.getsockname)(t,e,I),Module._pq_recvbuf_fill=(t,e)=>(Module._pq_recvbuf_fill=wasmExports.pq_recvbuf_fill)(t,e),Module._getsockopt=(t,e,I,B,tr)=>(Module._getsockopt=wasmExports.getsockopt)(t,e,I,B,tr),Module._getmissingattr=(t,e,I)=>(Module._getmissingattr=wasmExports.getmissingattr)(t,e,I),Module._get_rel_relkind=t=>(Module._get_rel_relkind=wasmExports.get_rel_relkind)(t),Module._MemoryContextSetIdentifier=(t,e)=>(Module._MemoryContextSetIdentifier=wasmExports.MemoryContextSetIdentifier)(t,e),Module._MemoryContextSetParent=(t,e)=>(Module._MemoryContextSetParent=wasmExports.MemoryContextSetParent)(t,e),Module._find_base_rel=(t,e)=>(Module._find_base_rel=wasmExports.find_base_rel)(t,e),Module._bms_equal=(t,e)=>(Module._bms_equal=wasmExports.bms_equal)(t,e),Module._bms_num_members=t=>(Module._bms_num_members=wasmExports.bms_num_members)(t),Module._fmgr_info_copy=(t,e,I)=>(Module._fmgr_info_copy=wasmExports.fmgr_info_copy)(t,e,I),Module._fmgr_info_cxt=(t,e,I)=>(Module._fmgr_info_cxt=wasmExports.fmgr_info_cxt)(t,e,I),Module._get_typlenbyvalalign=(t,e,I,B)=>(Module._get_typlenbyvalalign=wasmExports.get_typlenbyvalalign)(t,e,I,B),Module._deconstruct_array=(t,e,I,B,tr,rr,ir,lr)=>(Module._deconstruct_array=wasmExports.deconstruct_array)(t,e,I,B,tr,rr,ir,lr),Module._datumCopy=(t,e,I)=>(Module._datumCopy=wasmExports.datumCopy)(t,e,I),Module._qsort_arg=(t,e,I,B,tr)=>(Module._qsort_arg=wasmExports.qsort_arg)(t,e,I,B,tr),Module._FunctionCall2Coll=(t,e,I,B)=>(Module._FunctionCall2Coll=wasmExports.FunctionCall2Coll)(t,e,I,B),Module._datumIsEqual=(t,e,I,B)=>(Module._datumIsEqual=wasmExports.datumIsEqual)(t,e,I,B),Module._bms_overlap=(t,e)=>(Module._bms_overlap=wasmExports.bms_overlap)(t,e),Module._ExecPrepareExpr=(t,e)=>(Module._ExecPrepareExpr=wasmExports.ExecPrepareExpr)(t,e),Module._RegisterSnapshot=t=>(Module._RegisterSnapshot=wasmExports.RegisterSnapshot)(t),Module._UnregisterSnapshot=t=>(Module._UnregisterSnapshot=wasmExports.UnregisterSnapshot)(t),Module._get_fn_expr_argtype=(t,e)=>(Module._get_fn_expr_argtype=wasmExports.get_fn_expr_argtype)(t,e),Module._get_opfamily_member=(t,e,I,B)=>(Module._get_opfamily_member=wasmExports.get_opfamily_member)(t,e,I,B),Module._init_MultiFuncCall=t=>(Module._init_MultiFuncCall=wasmExports.init_MultiFuncCall)(t),Module._per_MultiFuncCall=t=>(Module._per_MultiFuncCall=wasmExports.per_MultiFuncCall)(t),Module._end_MultiFuncCall=(t,e)=>(Module._end_MultiFuncCall=wasmExports.end_MultiFuncCall)(t,e),Module._textToQualifiedNameList=t=>(Module._textToQualifiedNameList=wasmExports.textToQualifiedNameList)(t),Module._FunctionCall1Coll=(t,e,I)=>(Module._FunctionCall1Coll=wasmExports.FunctionCall1Coll)(t,e,I),Module._DirectFunctionCall4Coll=(t,e,I,B,tr,rr)=>(Module._DirectFunctionCall4Coll=wasmExports.DirectFunctionCall4Coll)(t,e,I,B,tr,rr),Module._pg_mblen=t=>(Module._pg_mblen=wasmExports.pg_mblen)(t),Module._tsearch_readline_begin=(t,e)=>(Module._tsearch_readline_begin=wasmExports.tsearch_readline_begin)(t,e),Module._tsearch_readline=t=>(Module._tsearch_readline=wasmExports.tsearch_readline)(t),Module._t_isspace=t=>(Module._t_isspace=wasmExports.t_isspace)(t),Module._lowerstr=t=>(Module._lowerstr=wasmExports.lowerstr)(t),Module._tsearch_readline_end=t=>(Module._tsearch_readline_end=wasmExports.tsearch_readline_end)(t),Module._t_isdigit=t=>(Module._t_isdigit=wasmExports.t_isdigit)(t),Module._pnstrdup=(t,e)=>(Module._pnstrdup=wasmExports.pnstrdup)(t,e),Module._get_tsearch_config_filename=(t,e)=>(Module._get_tsearch_config_filename=wasmExports.get_tsearch_config_filename)(t,e),Module._lookup_ts_dictionary_cache=t=>(Module._lookup_ts_dictionary_cache=wasmExports.lookup_ts_dictionary_cache)(t),Module._FunctionCall4Coll=(t,e,I,B,tr,rr)=>(Module._FunctionCall4Coll=wasmExports.FunctionCall4Coll)(t,e,I,B,tr,rr),Module._t_isalnum=t=>(Module._t_isalnum=wasmExports.t_isalnum)(t),Module._isalnum=t=>(Module._isalnum=wasmExports.isalnum)(t),Module._pg_any_to_server=(t,e,I)=>(Module._pg_any_to_server=wasmExports.pg_any_to_server)(t,e,I),Module._lowerstr_with_len=(t,e)=>(Module._lowerstr_with_len=wasmExports.lowerstr_with_len)(t,e),Module._tolower=t=>(Module._tolower=wasmExports.tolower)(t),Module._readstoplist=(t,e,I)=>(Module._readstoplist=wasmExports.readstoplist)(t,e,I),Module._searchstoplist=(t,e)=>(Module._searchstoplist=wasmExports.searchstoplist)(t,e),Module._GetDatabaseEncoding=()=>(Module._GetDatabaseEncoding=wasmExports.GetDatabaseEncoding)(),Module._vacuum_delay_point=()=>(Module._vacuum_delay_point=wasmExports.vacuum_delay_point)(),Module._get_restriction_variable=(t,e,I,B,tr,rr)=>(Module._get_restriction_variable=wasmExports.get_restriction_variable)(t,e,I,B,tr,rr),Module._get_attstatsslot=(t,e,I,B,tr)=>(Module._get_attstatsslot=wasmExports.get_attstatsslot)(t,e,I,B,tr),Module._free_attstatsslot=t=>(Module._free_attstatsslot=wasmExports.free_attstatsslot)(t),Module._Float8GetDatum=t=>(Module._Float8GetDatum=wasmExports.Float8GetDatum)(t),Module._ExecReScan=t=>(Module._ExecReScan=wasmExports.ExecReScan)(t),Module._ExecAsyncResponse=t=>(Module._ExecAsyncResponse=wasmExports.ExecAsyncResponse)(t),Module._ExecAsyncRequestDone=(t,e)=>(Module._ExecAsyncRequestDone=wasmExports.ExecAsyncRequestDone)(t,e),Module._ExecAsyncRequestPending=t=>(Module._ExecAsyncRequestPending=wasmExports.ExecAsyncRequestPending)(t),Module._tuplesort_end=t=>(Module._tuplesort_end=wasmExports.tuplesort_end)(t),Module._ExecInitExprList=(t,e)=>(Module._ExecInitExprList=wasmExports.ExecInitExprList)(t,e),Module._fmgr_info=(t,e)=>(Module._fmgr_info=wasmExports.fmgr_info)(t,e),Module._get_typlenbyval=(t,e,I)=>(Module._get_typlenbyval=wasmExports.get_typlenbyval)(t,e,I),Module._ExecForceStoreHeapTuple=(t,e,I)=>(Module._ExecForceStoreHeapTuple=wasmExports.ExecForceStoreHeapTuple)(t,e,I),Module._tuplesort_performsort=t=>(Module._tuplesort_performsort=wasmExports.tuplesort_performsort)(t),Module._tuplesort_begin_heap=(t,e,I,B,tr,rr,ir,lr,dr)=>(Module._tuplesort_begin_heap=wasmExports.tuplesort_begin_heap)(t,e,I,B,tr,rr,ir,lr,dr),Module._MemoryContextMemAllocated=(t,e)=>(Module._MemoryContextMemAllocated=wasmExports.MemoryContextMemAllocated)(t,e),Module._tuplesort_gettupleslot=(t,e,I,B,tr)=>(Module._tuplesort_gettupleslot=wasmExports.tuplesort_gettupleslot)(t,e,I,B,tr),Module._tuplesort_puttupleslot=(t,e)=>(Module._tuplesort_puttupleslot=wasmExports.tuplesort_puttupleslot)(t,e),Module._ExecStoreAllNullTuple=t=>(Module._ExecStoreAllNullTuple=wasmExports.ExecStoreAllNullTuple)(t),Module._MakeExpandedObjectReadOnlyInternal=t=>(Module._MakeExpandedObjectReadOnlyInternal=wasmExports.MakeExpandedObjectReadOnlyInternal)(t),Module._BlessTupleDesc=t=>(Module._BlessTupleDesc=wasmExports.BlessTupleDesc)(t),Module._pg_detoast_datum_copy=t=>(Module._pg_detoast_datum_copy=wasmExports.pg_detoast_datum_copy)(t),Module._construct_md_array=(t,e,I,B,tr,rr,ir,lr,dr)=>(Module._construct_md_array=wasmExports.construct_md_array)(t,e,I,B,tr,rr,ir,lr,dr),Module._ArrayGetNItems=(t,e)=>(Module._ArrayGetNItems=wasmExports.ArrayGetNItems)(t,e),Module._construct_empty_array=t=>(Module._construct_empty_array=wasmExports.construct_empty_array)(t),Module._DatumGetEOHP=t=>(Module._DatumGetEOHP=wasmExports.DatumGetEOHP)(t),Module._expanded_record_fetch_tupdesc=t=>(Module._expanded_record_fetch_tupdesc=wasmExports.expanded_record_fetch_tupdesc)(t),Module._expanded_record_fetch_field=(t,e,I)=>(Module._expanded_record_fetch_field=wasmExports.expanded_record_fetch_field)(t,e,I),Module._execute_attr_map_tuple=(t,e)=>(Module._execute_attr_map_tuple=wasmExports.execute_attr_map_tuple)(t,e),Module._MemoryContextAllocExtended=(t,e,I)=>(Module._MemoryContextAllocExtended=wasmExports.MemoryContextAllocExtended)(t,e,I),Module._lookup_rowtype_tupdesc_domain=(t,e,I)=>(Module._lookup_rowtype_tupdesc_domain=wasmExports.lookup_rowtype_tupdesc_domain)(t,e,I),Module._MemoryContextGetParent=t=>(Module._MemoryContextGetParent=wasmExports.MemoryContextGetParent)(t),Module._DeleteExpandedObject=t=>(Module._DeleteExpandedObject=wasmExports.DeleteExpandedObject)(t),Module._InstrAlloc=(t,e,I)=>(Module._InstrAlloc=wasmExports.InstrAlloc)(t,e,I),Module._ExprEvalPushStep=(t,e)=>(Module._ExprEvalPushStep=wasmExports.ExprEvalPushStep)(t,e),Module._getTypeOutputInfo=(t,e,I)=>(Module._getTypeOutputInfo=wasmExports.getTypeOutputInfo)(t,e,I),Module._ExecInitExprWithParams=(t,e)=>(Module._ExecInitExprWithParams=wasmExports.ExecInitExprWithParams)(t,e),Module._ExecOpenScanRelation=(t,e,I)=>(Module._ExecOpenScanRelation=wasmExports.ExecOpenScanRelation)(t,e,I),Module._FreeExprContext=(t,e)=>(Module._FreeExprContext=wasmExports.FreeExprContext)(t,e),Module._CreateExprContext=t=>(Module._CreateExprContext=wasmExports.CreateExprContext)(t),Module._ExecGetReturningSlot=(t,e)=>(Module._ExecGetReturningSlot=wasmExports.ExecGetReturningSlot)(t,e),Module._build_attrmap_by_name_if_req=(t,e,I)=>(Module._build_attrmap_by_name_if_req=wasmExports.build_attrmap_by_name_if_req)(t,e,I),Module._ExecGetResultRelCheckAsUser=(t,e)=>(Module._ExecGetResultRelCheckAsUser=wasmExports.ExecGetResultRelCheckAsUser)(t,e),Module._InstrEndLoop=t=>(Module._InstrEndLoop=wasmExports.InstrEndLoop)(t),Module._ExecStoreHeapTuple=(t,e,I)=>(Module._ExecStoreHeapTuple=wasmExports.ExecStoreHeapTuple)(t,e,I),Module._get_partition_ancestors=t=>(Module._get_partition_ancestors=wasmExports.get_partition_ancestors)(t),Module._pull_varattnos=(t,e,I)=>(Module._pull_varattnos=wasmExports.pull_varattnos)(t,e,I),Module._ExecFindJunkAttributeInTlist=(t,e)=>(Module._ExecFindJunkAttributeInTlist=wasmExports.ExecFindJunkAttributeInTlist)(t,e),Module._visibilitymap_get_status=(t,e,I)=>(Module._visibilitymap_get_status=wasmExports.visibilitymap_get_status)(t,e,I),Module._index_deform_tuple=(t,e,I,B)=>(Module._index_deform_tuple=wasmExports.index_deform_tuple)(t,e,I,B),Module._LaunchParallelWorkers=t=>(Module._LaunchParallelWorkers=wasmExports.LaunchParallelWorkers)(t),Module._standard_ExecutorStart=(t,e)=>(Module._standard_ExecutorStart=wasmExports.standard_ExecutorStart)(t,e),Module._GetCommandTagName=t=>(Module._GetCommandTagName=wasmExports.GetCommandTagName)(t),Module._standard_ExecutorRun=(t,e,I,B)=>(Module._standard_ExecutorRun=wasmExports.standard_ExecutorRun)(t,e,I,B),Module._EnterParallelMode=()=>(Module._EnterParallelMode=wasmExports.EnterParallelMode)(),Module._ExitParallelMode=()=>(Module._ExitParallelMode=wasmExports.ExitParallelMode)(),Module._standard_ExecutorFinish=t=>(Module._standard_ExecutorFinish=wasmExports.standard_ExecutorFinish)(t),Module._standard_ExecutorEnd=t=>(Module._standard_ExecutorEnd=wasmExports.standard_ExecutorEnd)(t),Module._MakeTupleTableSlot=(t,e)=>(Module._MakeTupleTableSlot=wasmExports.MakeTupleTableSlot)(t,e),Module._CreateParallelContext=(t,e,I)=>(Module._CreateParallelContext=wasmExports.CreateParallelContext)(t,e,I),Module._InitializeParallelDSM=t=>(Module._InitializeParallelDSM=wasmExports.InitializeParallelDSM)(t),Module._WaitForParallelWorkersToFinish=t=>(Module._WaitForParallelWorkersToFinish=wasmExports.WaitForParallelWorkersToFinish)(t),Module._DestroyParallelContext=t=>(Module._DestroyParallelContext=wasmExports.DestroyParallelContext)(t),Module._SPI_connect=()=>(Module._SPI_connect=wasmExports.SPI_connect)(),Module._SPI_connect_ext=t=>(Module._SPI_connect_ext=wasmExports.SPI_connect_ext)(t),Module._SPI_finish=()=>(Module._SPI_finish=wasmExports.SPI_finish)(),Module._SPI_commit=()=>(Module._SPI_commit=wasmExports.SPI_commit)(),Module._ReThrowError=t=>(Module._ReThrowError=wasmExports.ReThrowError)(t),Module._SPI_commit_and_chain=()=>(Module._SPI_commit_and_chain=wasmExports.SPI_commit_and_chain)(),Module._SPI_rollback=()=>(Module._SPI_rollback=wasmExports.SPI_rollback)(),Module._SPI_rollback_and_chain=()=>(Module._SPI_rollback_and_chain=wasmExports.SPI_rollback_and_chain)(),Module._SPI_execute=(t,e,I)=>(Module._SPI_execute=wasmExports.SPI_execute)(t,e,I),Module._EnsurePortalSnapshotExists=()=>(Module._EnsurePortalSnapshotExists=wasmExports.EnsurePortalSnapshotExists)(),Module._SPI_freetuptable=t=>(Module._SPI_freetuptable=wasmExports.SPI_freetuptable)(t),Module._ReleaseCachedPlan=(t,e)=>(Module._ReleaseCachedPlan=wasmExports.ReleaseCachedPlan)(t,e),Module._SPI_exec=(t,e)=>(Module._SPI_exec=wasmExports.SPI_exec)(t,e),Module._SPI_execute_extended=(t,e)=>(Module._SPI_execute_extended=wasmExports.SPI_execute_extended)(t,e),Module._makeParamList=t=>(Module._makeParamList=wasmExports.makeParamList)(t),Module._SPI_execp=(t,e,I,B)=>(Module._SPI_execp=wasmExports.SPI_execp)(t,e,I,B),Module._SPI_execute_plan_extended=(t,e)=>(Module._SPI_execute_plan_extended=wasmExports.SPI_execute_plan_extended)(t,e),Module._SPI_execute_plan_with_paramlist=(t,e,I,B)=>(Module._SPI_execute_plan_with_paramlist=wasmExports.SPI_execute_plan_with_paramlist)(t,e,I,B),Module._SPI_prepare=(t,e,I)=>(Module._SPI_prepare=wasmExports.SPI_prepare)(t,e,I),Module._SPI_prepare_extended=(t,e)=>(Module._SPI_prepare_extended=wasmExports.SPI_prepare_extended)(t,e),Module._SPI_keepplan=t=>(Module._SPI_keepplan=wasmExports.SPI_keepplan)(t),Module._SPI_freeplan=t=>(Module._SPI_freeplan=wasmExports.SPI_freeplan)(t),Module._SPI_copytuple=t=>(Module._SPI_copytuple=wasmExports.SPI_copytuple)(t),Module._SPI_returntuple=(t,e)=>(Module._SPI_returntuple=wasmExports.SPI_returntuple)(t,e),Module._SPI_fnumber=(t,e)=>(Module._SPI_fnumber=wasmExports.SPI_fnumber)(t,e),Module._SPI_fname=(t,e)=>(Module._SPI_fname=wasmExports.SPI_fname)(t,e),Module._SPI_getvalue=(t,e,I)=>(Module._SPI_getvalue=wasmExports.SPI_getvalue)(t,e,I),Module._SPI_getbinval=(t,e,I,B)=>(Module._SPI_getbinval=wasmExports.SPI_getbinval)(t,e,I,B),Module._SPI_gettype=(t,e)=>(Module._SPI_gettype=wasmExports.SPI_gettype)(t,e),Module._SPI_gettypeid=(t,e)=>(Module._SPI_gettypeid=wasmExports.SPI_gettypeid)(t,e),Module._SPI_getrelname=t=>(Module._SPI_getrelname=wasmExports.SPI_getrelname)(t),Module._SPI_palloc=t=>(Module._SPI_palloc=wasmExports.SPI_palloc)(t),Module._SPI_datumTransfer=(t,e,I)=>(Module._SPI_datumTransfer=wasmExports.SPI_datumTransfer)(t,e,I),Module._datumTransfer=(t,e,I)=>(Module._datumTransfer=wasmExports.datumTransfer)(t,e,I),Module._SPI_cursor_open_with_paramlist=(t,e,I,B)=>(Module._SPI_cursor_open_with_paramlist=wasmExports.SPI_cursor_open_with_paramlist)(t,e,I,B),Module._SPI_cursor_parse_open=(t,e,I)=>(Module._SPI_cursor_parse_open=wasmExports.SPI_cursor_parse_open)(t,e,I),Module._SPI_cursor_find=t=>(Module._SPI_cursor_find=wasmExports.SPI_cursor_find)(t),Module._SPI_cursor_fetch=(t,e,I)=>(Module._SPI_cursor_fetch=wasmExports.SPI_cursor_fetch)(t,e,I),Module._SPI_scroll_cursor_fetch=(t,e,I)=>(Module._SPI_scroll_cursor_fetch=wasmExports.SPI_scroll_cursor_fetch)(t,e,I),Module._SPI_scroll_cursor_move=(t,e,I)=>(Module._SPI_scroll_cursor_move=wasmExports.SPI_scroll_cursor_move)(t,e,I),Module._SPI_cursor_close=t=>(Module._SPI_cursor_close=wasmExports.SPI_cursor_close)(t),Module._SPI_result_code_string=t=>(Module._SPI_result_code_string=wasmExports.SPI_result_code_string)(t),Module._SPI_plan_get_plan_sources=t=>(Module._SPI_plan_get_plan_sources=wasmExports.SPI_plan_get_plan_sources)(t),Module._SPI_plan_get_cached_plan=t=>(Module._SPI_plan_get_cached_plan=wasmExports.SPI_plan_get_cached_plan)(t),Module._geterrposition=()=>(Module._geterrposition=wasmExports.geterrposition)(),Module._internalerrposition=t=>(Module._internalerrposition=wasmExports.internalerrposition)(t),Module._internalerrquery=t=>(Module._internalerrquery=wasmExports.internalerrquery)(t),Module._SPI_register_trigger_data=t=>(Module._SPI_register_trigger_data=wasmExports.SPI_register_trigger_data)(t),Module._EOH_get_flat_size=t=>(Module._EOH_get_flat_size=wasmExports.EOH_get_flat_size)(t),Module._EOH_flatten_into=(t,e,I)=>(Module._EOH_flatten_into=wasmExports.EOH_flatten_into)(t,e,I),Module._ExecFetchSlotHeapTuple=(t,e,I)=>(Module._ExecFetchSlotHeapTuple=wasmExports.ExecFetchSlotHeapTuple)(t,e,I),Module._InputFunctionCall=(t,e,I,B)=>(Module._InputFunctionCall=wasmExports.InputFunctionCall)(t,e,I,B),Module._convert_tuples_by_position=(t,e,I)=>(Module._convert_tuples_by_position=wasmExports.convert_tuples_by_position)(t,e,I),Module._SetTuplestoreDestReceiverParams=(t,e,I,B,tr,rr)=>(Module._SetTuplestoreDestReceiverParams=wasmExports.SetTuplestoreDestReceiverParams)(t,e,I,B,tr,rr),Module._detoast_external_attr=t=>(Module._detoast_external_attr=wasmExports.detoast_external_attr)(t),Module._bms_nonempty_difference=(t,e)=>(Module._bms_nonempty_difference=wasmExports.bms_nonempty_difference)(t,e),Module._table_parallelscan_estimate=(t,e)=>(Module._table_parallelscan_estimate=wasmExports.table_parallelscan_estimate)(t,e),Module._table_parallelscan_initialize=(t,e,I)=>(Module._table_parallelscan_initialize=wasmExports.table_parallelscan_initialize)(t,e,I),Module._table_beginscan_parallel=(t,e)=>(Module._table_beginscan_parallel=wasmExports.table_beginscan_parallel)(t,e),Module._BufferUsageAccumDiff=(t,e,I)=>(Module._BufferUsageAccumDiff=wasmExports.BufferUsageAccumDiff)(t,e,I),Module._WalUsageAccumDiff=(t,e,I)=>(Module._WalUsageAccumDiff=wasmExports.WalUsageAccumDiff)(t,e,I),Module._InstrUpdateTupleCount=(t,e)=>(Module._InstrUpdateTupleCount=wasmExports.InstrUpdateTupleCount)(t,e),Module._tuplesort_reset=t=>(Module._tuplesort_reset=wasmExports.tuplesort_reset)(t),Module._get_call_expr_argtype=(t,e)=>(Module._get_call_expr_argtype=wasmExports.get_call_expr_argtype)(t,e),Module._get_typtype=t=>(Module._get_typtype=wasmExports.get_typtype)(t),Module._pull_var_clause=(t,e)=>(Module._pull_var_clause=wasmExports.pull_var_clause)(t,e),Module._bms_is_subset=(t,e)=>(Module._bms_is_subset=wasmExports.bms_is_subset)(t,e),Module._bms_membership=t=>(Module._bms_membership=wasmExports.bms_membership)(t),Module._make_restrictinfo=(t,e,I,B,tr,rr,ir,lr,dr,mr)=>(Module._make_restrictinfo=wasmExports.make_restrictinfo)(t,e,I,B,tr,rr,ir,lr,dr,mr),Module._GetSysCacheHashValue=(t,e,I,B,tr)=>(Module._GetSysCacheHashValue=wasmExports.GetSysCacheHashValue)(t,e,I,B,tr),Module._tlist_member=(t,e)=>(Module._tlist_member=wasmExports.tlist_member)(t,e),Module._add_path=(t,e)=>(Module._add_path=wasmExports.add_path)(t,e),Module._contain_mutable_functions=t=>(Module._contain_mutable_functions=wasmExports.contain_mutable_functions)(t),Module._make_orclause=t=>(Module._make_orclause=wasmExports.make_orclause)(t),Module._extract_actual_clauses=(t,e)=>(Module._extract_actual_clauses=wasmExports.extract_actual_clauses)(t,e),Module._cost_sort=(t,e,I,B,tr,rr,ir,lr,dr)=>(Module._cost_sort=wasmExports.cost_sort)(t,e,I,B,tr,rr,ir,lr,dr),Module._pathkeys_contained_in=(t,e)=>(Module._pathkeys_contained_in=wasmExports.pathkeys_contained_in)(t,e),Module._change_plan_targetlist=(t,e,I)=>(Module._change_plan_targetlist=wasmExports.change_plan_targetlist)(t,e,I),Module._make_foreignscan=(t,e,I,B,tr,rr,ir,lr)=>(Module._make_foreignscan=wasmExports.make_foreignscan)(t,e,I,B,tr,rr,ir,lr),Module._list_member_ptr=(t,e)=>(Module._list_member_ptr=wasmExports.list_member_ptr)(t,e),Module._clamp_row_est=t=>(Module._clamp_row_est=wasmExports.clamp_row_est)(t),Module._standard_planner=(t,e,I,B)=>(Module._standard_planner=wasmExports.standard_planner)(t,e,I,B),Module._estimate_expression_value=(t,e)=>(Module._estimate_expression_value=wasmExports.estimate_expression_value)(t,e),Module._add_new_columns_to_pathtarget=(t,e)=>(Module._add_new_columns_to_pathtarget=wasmExports.add_new_columns_to_pathtarget)(t,e),Module._get_sortgroupref_clause_noerr=(t,e)=>(Module._get_sortgroupref_clause_noerr=wasmExports.get_sortgroupref_clause_noerr)(t,e),Module._get_agg_clause_costs=(t,e,I)=>(Module._get_agg_clause_costs=wasmExports.get_agg_clause_costs)(t,e,I),Module._grouping_is_sortable=t=>(Module._grouping_is_sortable=wasmExports.grouping_is_sortable)(t),Module._create_sort_path=(t,e,I,B,tr)=>(Module._create_sort_path=wasmExports.create_sort_path)(t,e,I,B,tr),Module._copy_pathtarget=t=>(Module._copy_pathtarget=wasmExports.copy_pathtarget)(t),Module._get_sortgrouplist_exprs=(t,e)=>(Module._get_sortgrouplist_exprs=wasmExports.get_sortgrouplist_exprs)(t,e),Module._estimate_num_groups=(t,e,I,B,tr)=>(Module._estimate_num_groups=wasmExports.estimate_num_groups)(t,e,I,B,tr),Module._cost_qual_eval=(t,e,I)=>(Module._cost_qual_eval=wasmExports.cost_qual_eval)(t,e,I),Module._plan_create_index_workers=(t,e)=>(Module._plan_create_index_workers=wasmExports.plan_create_index_workers)(t,e),Module._create_projection_path=(t,e,I,B)=>(Module._create_projection_path=wasmExports.create_projection_path)(t,e,I,B),Module._get_plan_rowmark=(t,e)=>(Module._get_plan_rowmark=wasmExports.get_plan_rowmark)(t,e),Module._find_join_rel=(t,e)=>(Module._find_join_rel=wasmExports.find_join_rel)(t,e),Module._make_canonical_pathkey=(t,e,I,B,tr)=>(Module._make_canonical_pathkey=wasmExports.make_canonical_pathkey)(t,e,I,B,tr),Module._eclass_useful_for_merging=(t,e,I)=>(Module._eclass_useful_for_merging=wasmExports.eclass_useful_for_merging)(t,e,I),Module._update_mergeclause_eclasses=(t,e)=>(Module._update_mergeclause_eclasses=wasmExports.update_mergeclause_eclasses)(t,e),Module._clauselist_selectivity=(t,e,I,B,tr)=>(Module._clauselist_selectivity=wasmExports.clauselist_selectivity)(t,e,I,B,tr),Module._join_clause_is_movable_to=(t,e)=>(Module._join_clause_is_movable_to=wasmExports.join_clause_is_movable_to)(t,e),Module._generate_implied_equalities_for_column=(t,e,I,B,tr)=>(Module._generate_implied_equalities_for_column=wasmExports.generate_implied_equalities_for_column)(t,e,I,B,tr),Module._get_tablespace_page_costs=(t,e,I)=>(Module._get_tablespace_page_costs=wasmExports.get_tablespace_page_costs)(t,e,I),Module._set_baserel_size_estimates=(t,e)=>(Module._set_baserel_size_estimates=wasmExports.set_baserel_size_estimates)(t,e),Module._add_to_flat_tlist=(t,e)=>(Module._add_to_flat_tlist=wasmExports.add_to_flat_tlist)(t,e),Module._get_baserel_parampathinfo=(t,e,I)=>(Module._get_baserel_parampathinfo=wasmExports.get_baserel_parampathinfo)(t,e,I),Module._create_foreignscan_path=(t,e,I,B,tr,rr,ir,lr,dr,mr)=>(Module._create_foreignscan_path=wasmExports.create_foreignscan_path)(t,e,I,B,tr,rr,ir,lr,dr,mr),Module._create_foreign_join_path=(t,e,I,B,tr,rr,ir,lr,dr,mr)=>(Module._create_foreign_join_path=wasmExports.create_foreign_join_path)(t,e,I,B,tr,rr,ir,lr,dr,mr),Module._create_foreign_upper_path=(t,e,I,B,tr,rr,ir,lr,dr)=>(Module._create_foreign_upper_path=wasmExports.create_foreign_upper_path)(t,e,I,B,tr,rr,ir,lr,dr),Module._adjust_limit_rows_costs=(t,e,I,B,tr)=>(Module._adjust_limit_rows_costs=wasmExports.adjust_limit_rows_costs)(t,e,I,B,tr),Module._SearchSysCacheAttName=(t,e)=>(Module._SearchSysCacheAttName=wasmExports.SearchSysCacheAttName)(t,e),Module._get_translated_update_targetlist=(t,e,I,B)=>(Module._get_translated_update_targetlist=wasmExports.get_translated_update_targetlist)(t,e,I,B),Module._add_row_identity_var=(t,e,I,B)=>(Module._add_row_identity_var=wasmExports.add_row_identity_var)(t,e,I,B),Module._get_rel_all_updated_cols=(t,e)=>(Module._get_rel_all_updated_cols=wasmExports.get_rel_all_updated_cols)(t,e),Module._list_append_unique_ptr=(t,e)=>(Module._list_append_unique_ptr=wasmExports.list_append_unique_ptr)(t,e),Module._palloc_extended=(t,e)=>(Module._palloc_extended=wasmExports.palloc_extended)(t,e),Module._pg_reg_getinitialstate=t=>(Module._pg_reg_getinitialstate=wasmExports.pg_reg_getinitialstate)(t),Module._pg_reg_getfinalstate=t=>(Module._pg_reg_getfinalstate=wasmExports.pg_reg_getfinalstate)(t),Module._pg_reg_getnumoutarcs=(t,e)=>(Module._pg_reg_getnumoutarcs=wasmExports.pg_reg_getnumoutarcs)(t,e),Module._pg_reg_getoutarcs=(t,e,I,B)=>(Module._pg_reg_getoutarcs=wasmExports.pg_reg_getoutarcs)(t,e,I,B),Module._pg_reg_getnumcolors=t=>(Module._pg_reg_getnumcolors=wasmExports.pg_reg_getnumcolors)(t),Module._pg_reg_colorisbegin=(t,e)=>(Module._pg_reg_colorisbegin=wasmExports.pg_reg_colorisbegin)(t,e),Module._pg_reg_colorisend=(t,e)=>(Module._pg_reg_colorisend=wasmExports.pg_reg_colorisend)(t,e),Module._pg_reg_getnumcharacters=(t,e)=>(Module._pg_reg_getnumcharacters=wasmExports.pg_reg_getnumcharacters)(t,e),Module._pg_reg_getcharacters=(t,e,I,B)=>(Module._pg_reg_getcharacters=wasmExports.pg_reg_getcharacters)(t,e,I,B),Module._toupper=t=>(Module._toupper=wasmExports.toupper)(t),Module._pg_initdb=()=>(Module._pg_initdb=wasmExports.pg_initdb)(),Module._pg_initdb_main=()=>(Module._pg_initdb_main=wasmExports.pg_initdb_main)(),Module.___cxa_throw=(t,e,I)=>(Module.___cxa_throw=wasmExports.__cxa_throw)(t,e,I),Module._main_repl=()=>(Module._main_repl=wasmExports.main_repl)(),Module._main=(t,e)=>(Module._main=wasmExports.__main_argc_argv)(t,e),Module._setenv=(t,e,I)=>(Module._setenv=wasmExports.setenv)(t,e,I),Module._pg_repl_raf=()=>(Module._pg_repl_raf=wasmExports.pg_repl_raf)(),Module._GetForeignDataWrapper=t=>(Module._GetForeignDataWrapper=wasmExports.GetForeignDataWrapper)(t),Module._GetForeignServer=t=>(Module._GetForeignServer=wasmExports.GetForeignServer)(t),Module._GetForeignServerExtended=(t,e)=>(Module._GetForeignServerExtended=wasmExports.GetForeignServerExtended)(t,e),Module._GetForeignServerByName=(t,e)=>(Module._GetForeignServerByName=wasmExports.GetForeignServerByName)(t,e),Module._GetUserMapping=(t,e)=>(Module._GetUserMapping=wasmExports.GetUserMapping)(t,e),Module._GetForeignTable=t=>(Module._GetForeignTable=wasmExports.GetForeignTable)(t),Module._GetForeignColumnOptions=(t,e)=>(Module._GetForeignColumnOptions=wasmExports.GetForeignColumnOptions)(t,e),Module._initClosestMatch=(t,e,I)=>(Module._initClosestMatch=wasmExports.initClosestMatch)(t,e,I),Module._updateClosestMatch=(t,e)=>(Module._updateClosestMatch=wasmExports.updateClosestMatch)(t,e),Module._getClosestMatch=t=>(Module._getClosestMatch=wasmExports.getClosestMatch)(t),Module._GetExistingLocalJoinPath=t=>(Module._GetExistingLocalJoinPath=wasmExports.GetExistingLocalJoinPath)(t),Module._BaseBackupAddTarget=(t,e,I)=>(Module._BaseBackupAddTarget=wasmExports.BaseBackupAddTarget)(t,e,I),Module._bbsink_forward_begin_backup=t=>(Module._bbsink_forward_begin_backup=wasmExports.bbsink_forward_begin_backup)(t),Module._bbsink_forward_archive_contents=(t,e)=>(Module._bbsink_forward_archive_contents=wasmExports.bbsink_forward_archive_contents)(t,e),Module._bbsink_forward_end_archive=t=>(Module._bbsink_forward_end_archive=wasmExports.bbsink_forward_end_archive)(t),Module._bbsink_forward_begin_archive=(t,e)=>(Module._bbsink_forward_begin_archive=wasmExports.bbsink_forward_begin_archive)(t,e),Module._bbsink_forward_begin_manifest=t=>(Module._bbsink_forward_begin_manifest=wasmExports.bbsink_forward_begin_manifest)(t),Module._bbsink_forward_manifest_contents=(t,e)=>(Module._bbsink_forward_manifest_contents=wasmExports.bbsink_forward_manifest_contents)(t,e),Module._bbsink_forward_end_manifest=t=>(Module._bbsink_forward_end_manifest=wasmExports.bbsink_forward_end_manifest)(t),Module._bbsink_forward_end_backup=(t,e,I)=>(Module._bbsink_forward_end_backup=wasmExports.bbsink_forward_end_backup)(t,e,I),Module._bbsink_forward_cleanup=t=>(Module._bbsink_forward_cleanup=wasmExports.bbsink_forward_cleanup)(t),Module._ResourceOwnerCreate=(t,e)=>(Module._ResourceOwnerCreate=wasmExports.ResourceOwnerCreate)(t,e),Module._escape_json=(t,e)=>(Module._escape_json=wasmExports.escape_json)(t,e),Module._exprIsLengthCoercion=(t,e)=>(Module._exprIsLengthCoercion=wasmExports.exprIsLengthCoercion)(t,e),Module._tbm_add_tuples=(t,e,I,B)=>(Module._tbm_add_tuples=wasmExports.tbm_add_tuples)(t,e,I,B),Module._appendStringInfoStringQuoted=(t,e,I)=>(Module._appendStringInfoStringQuoted=wasmExports.appendStringInfoStringQuoted)(t,e,I),Module._list_make5_impl=(t,e,I,B,tr,rr)=>(Module._list_make5_impl=wasmExports.list_make5_impl)(t,e,I,B,tr,rr),Module._list_delete=(t,e)=>(Module._list_delete=wasmExports.list_delete)(t,e),Module._CleanQuerytext=(t,e,I)=>(Module._CleanQuerytext=wasmExports.CleanQuerytext)(t,e,I),Module._EnableQueryId=()=>(Module._EnableQueryId=wasmExports.EnableQueryId)(),Module._get_rel_type_id=t=>(Module._get_rel_type_id=wasmExports.get_rel_type_id)(t),Module._set_config_option=(t,e,I,B,tr,rr,ir,lr)=>(Module._set_config_option=wasmExports.set_config_option)(t,e,I,B,tr,rr,ir,lr),Module._NewGUCNestLevel=()=>(Module._NewGUCNestLevel=wasmExports.NewGUCNestLevel)(),Module._AtEOXact_GUC=(t,e)=>(Module._AtEOXact_GUC=wasmExports.AtEOXact_GUC)(t,e),Module._parse_int=(t,e,I,B)=>(Module._parse_int=wasmExports.parse_int)(t,e,I,B),Module._strtod=(t,e)=>(Module._strtod=wasmExports.strtod)(t,e),Module._parse_real=(t,e,I,B)=>(Module._parse_real=wasmExports.parse_real)(t,e,I,B),Module._DefineCustomBoolVariable=(t,e,I,B,tr,rr,ir,lr,dr,mr)=>(Module._DefineCustomBoolVariable=wasmExports.DefineCustomBoolVariable)(t,e,I,B,tr,rr,ir,lr,dr,mr),Module._DefineCustomIntVariable=(t,e,I,B,tr,rr,ir,lr,dr,mr,hr,fr)=>(Module._DefineCustomIntVariable=wasmExports.DefineCustomIntVariable)(t,e,I,B,tr,rr,ir,lr,dr,mr,hr,fr),Module._DefineCustomRealVariable=(t,e,I,B,tr,rr,ir,lr,dr,mr,hr,fr)=>(Module._DefineCustomRealVariable=wasmExports.DefineCustomRealVariable)(t,e,I,B,tr,rr,ir,lr,dr,mr,hr,fr),Module._DefineCustomStringVariable=(t,e,I,B,tr,rr,ir,lr,dr,mr)=>(Module._DefineCustomStringVariable=wasmExports.DefineCustomStringVariable)(t,e,I,B,tr,rr,ir,lr,dr,mr),Module._DefineCustomEnumVariable=(t,e,I,B,tr,rr,ir,lr,dr,mr,hr)=>(Module._DefineCustomEnumVariable=wasmExports.DefineCustomEnumVariable)(t,e,I,B,tr,rr,ir,lr,dr,mr,hr),Module._MarkGUCPrefixReserved=t=>(Module._MarkGUCPrefixReserved=wasmExports.MarkGUCPrefixReserved)(t),Module._strcspn=(t,e)=>(Module._strcspn=wasmExports.strcspn)(t,e),Module._BlockSampler_Init=(t,e,I,B)=>(Module._BlockSampler_Init=wasmExports.BlockSampler_Init)(t,e,I,B),Module._sampler_random_init_state=(t,e)=>(Module._sampler_random_init_state=wasmExports.sampler_random_init_state)(t,e),Module._BlockSampler_HasMore=t=>(Module._BlockSampler_HasMore=wasmExports.BlockSampler_HasMore)(t),Module._BlockSampler_Next=t=>(Module._BlockSampler_Next=wasmExports.BlockSampler_Next)(t),Module._sampler_random_fract=t=>(Module._sampler_random_fract=wasmExports.sampler_random_fract)(t),Module._reservoir_init_selection_state=(t,e)=>(Module._reservoir_init_selection_state=wasmExports.reservoir_init_selection_state)(t,e),Module._reservoir_get_next_S=(t,e,I)=>(Module._reservoir_get_next_S=wasmExports.reservoir_get_next_S)(t,e,I),Module._canonicalize_path=t=>(Module._canonicalize_path=wasmExports.canonicalize_path)(t),Module.__bt_mkscankey=(t,e)=>(Module.__bt_mkscankey=wasmExports._bt_mkscankey)(t,e),Module._nocache_index_getattr=(t,e,I)=>(Module._nocache_index_getattr=wasmExports.nocache_index_getattr)(t,e,I),Module._tuplesort_estimate_shared=t=>(Module._tuplesort_estimate_shared=wasmExports.tuplesort_estimate_shared)(t),Module._tuplesort_initialize_shared=(t,e,I)=>(Module._tuplesort_initialize_shared=wasmExports.tuplesort_initialize_shared)(t,e,I),Module._tuplesort_attach_shared=(t,e)=>(Module._tuplesort_attach_shared=wasmExports.tuplesort_attach_shared)(t,e),Module._GetCurrentTransactionNestLevel=()=>(Module._GetCurrentTransactionNestLevel=wasmExports.GetCurrentTransactionNestLevel)(),Module._in_error_recursion_trouble=()=>(Module._in_error_recursion_trouble=wasmExports.in_error_recursion_trouble)(),Module._strrchr=(t,e)=>(Module._strrchr=wasmExports.strrchr)(t,e),Module._errhidestmt=t=>(Module._errhidestmt=wasmExports.errhidestmt)(t),Module._err_generic_string=(t,e)=>(Module._err_generic_string=wasmExports.err_generic_string)(t,e),Module._getinternalerrposition=()=>(Module._getinternalerrposition=wasmExports.getinternalerrposition)(),Module._GetErrorContextStack=()=>(Module._GetErrorContextStack=wasmExports.GetErrorContextStack)(),Module._SplitIdentifierString=(t,e,I)=>(Module._SplitIdentifierString=wasmExports.SplitIdentifierString)(t,e,I),Module._appendStringInfoSpaces=(t,e)=>(Module._appendStringInfoSpaces=wasmExports.appendStringInfoSpaces)(t,e),Module._unpack_sql_state=t=>(Module._unpack_sql_state=wasmExports.unpack_sql_state)(t),Module._CreateTupleDescCopyConstr=t=>(Module._CreateTupleDescCopyConstr=wasmExports.CreateTupleDescCopyConstr)(t),Module._CachedPlanAllowsSimpleValidityCheck=(t,e,I)=>(Module._CachedPlanAllowsSimpleValidityCheck=wasmExports.CachedPlanAllowsSimpleValidityCheck)(t,e,I),Module._CachedPlanIsSimplyValid=(t,e,I)=>(Module._CachedPlanIsSimplyValid=wasmExports.CachedPlanIsSimplyValid)(t,e,I),Module._GetCachedExpression=t=>(Module._GetCachedExpression=wasmExports.GetCachedExpression)(t),Module._FreeCachedExpression=t=>(Module._FreeCachedExpression=wasmExports.FreeCachedExpression)(t),Module._MemoryContextDeleteChildren=t=>(Module._MemoryContextDeleteChildren=wasmExports.MemoryContextDeleteChildren)(t),Module._is_publishable_relation=t=>(Module._is_publishable_relation=wasmExports.is_publishable_relation)(t),Module._GetRelationPublications=t=>(Module._GetRelationPublications=wasmExports.GetRelationPublications)(t),Module._GetSchemaPublications=t=>(Module._GetSchemaPublications=wasmExports.GetSchemaPublications)(t),Module._index_getprocid=(t,e,I)=>(Module._index_getprocid=wasmExports.index_getprocid)(t,e,I),Module._get_rel_relispartition=t=>(Module._get_rel_relispartition=wasmExports.get_rel_relispartition)(t),Module._get_func_namespace=t=>(Module._get_func_namespace=wasmExports.get_func_namespace)(t),Module._get_typsubscript=(t,e)=>(Module._get_typsubscript=wasmExports.get_typsubscript)(t,e),Module._get_namespace_name_or_temp=t=>(Module._get_namespace_name_or_temp=wasmExports.get_namespace_name_or_temp)(t),Module._texteq=t=>(Module._texteq=wasmExports.texteq)(t),Module._GetUserIdAndSecContext=(t,e)=>(Module._GetUserIdAndSecContext=wasmExports.GetUserIdAndSecContext)(t,e),Module._SetUserIdAndSecContext=(t,e)=>(Module._SetUserIdAndSecContext=wasmExports.SetUserIdAndSecContext)(t,e),Module._DirectFunctionCall5Coll=(t,e,I,B,tr,rr,ir)=>(Module._DirectFunctionCall5Coll=wasmExports.DirectFunctionCall5Coll)(t,e,I,B,tr,rr,ir),Module._CallerFInfoFunctionCall2=(t,e,I,B,tr)=>(Module._CallerFInfoFunctionCall2=wasmExports.CallerFInfoFunctionCall2)(t,e,I,B,tr),Module._FunctionCall0Coll=(t,e)=>(Module._FunctionCall0Coll=wasmExports.FunctionCall0Coll)(t,e),Module._OutputFunctionCall=(t,e)=>(Module._OutputFunctionCall=wasmExports.OutputFunctionCall)(t,e),Module._get_fn_expr_rettype=t=>(Module._get_fn_expr_rettype=wasmExports.get_fn_expr_rettype)(t),Module._has_fn_opclass_options=t=>(Module._has_fn_opclass_options=wasmExports.has_fn_opclass_options)(t),Module._get_fn_opclass_options=t=>(Module._get_fn_opclass_options=wasmExports.get_fn_opclass_options)(t),Module._CheckFunctionValidatorAccess=(t,e)=>(Module._CheckFunctionValidatorAccess=wasmExports.CheckFunctionValidatorAccess)(t,e),Module._resolve_polymorphic_argtypes=(t,e,I,B)=>(Module._resolve_polymorphic_argtypes=wasmExports.resolve_polymorphic_argtypes)(t,e,I,B),Module._get_func_arg_info=(t,e,I,B)=>(Module._get_func_arg_info=wasmExports.get_func_arg_info)(t,e,I,B),Module._dlsym=(t,e)=>(Module._dlsym=wasmExports.dlsym)(t,e),Module._dlopen=(t,e)=>(Module._dlopen=wasmExports.dlopen)(t,e),Module._dlerror=()=>(Module._dlerror=wasmExports.dlerror)(),Module._dlclose=t=>(Module._dlclose=wasmExports.dlclose)(t),Module._find_rendezvous_variable=t=>(Module._find_rendezvous_variable=wasmExports.find_rendezvous_variable)(t),Module._fscanf=(t,e,I)=>(Module._fscanf=wasmExports.fscanf)(t,e,I),Module._strlcat=(t,e,I)=>(Module._strlcat=wasmExports.strlcat)(t,e,I),Module._pg_bindtextdomain=t=>(Module._pg_bindtextdomain=wasmExports.pg_bindtextdomain)(t),Module._pg_do_encoding_conversion=(t,e,I,B)=>(Module._pg_do_encoding_conversion=wasmExports.pg_do_encoding_conversion)(t,e,I,B),Module._report_invalid_encoding=(t,e,I)=>(Module._report_invalid_encoding=wasmExports.report_invalid_encoding)(t,e,I),Module._pg_encoding_to_char_private=t=>(Module._pg_encoding_to_char_private=wasmExports.pg_encoding_to_char_private)(t),Module._MemoryContextAllocHuge=(t,e)=>(Module._MemoryContextAllocHuge=wasmExports.MemoryContextAllocHuge)(t,e),Module._namein=t=>(Module._namein=wasmExports.namein)(t),Module._pg_char_to_encoding_private=t=>(Module._pg_char_to_encoding_private=wasmExports.pg_char_to_encoding_private)(t),Module._pg_encoding_max_length=t=>(Module._pg_encoding_max_length=wasmExports.pg_encoding_max_length)(t),Module._pg_server_to_any=(t,e,I)=>(Module._pg_server_to_any=wasmExports.pg_server_to_any)(t,e,I),Module._pg_utf_mblen=t=>(Module._pg_utf_mblen=wasmExports.pg_utf_mblen)(t),Module._pg_wchar2mb_with_len=(t,e,I)=>(Module._pg_wchar2mb_with_len=wasmExports.pg_wchar2mb_with_len)(t,e,I),Module._pg_encoding_mblen=(t,e)=>(Module._pg_encoding_mblen=wasmExports.pg_encoding_mblen)(t,e),Module._check_encoding_conversion_args=(t,e,I,B,tr)=>(Module._check_encoding_conversion_args=wasmExports.check_encoding_conversion_args)(t,e,I,B,tr),Module._report_untranslatable_char=(t,e,I,B)=>(Module._report_untranslatable_char=wasmExports.report_untranslatable_char)(t,e,I,B),Module._local2local=(t,e,I,B,tr,rr,ir)=>(Module._local2local=wasmExports.local2local)(t,e,I,B,tr,rr,ir),Module._latin2mic=(t,e,I,B,tr,rr)=>(Module._latin2mic=wasmExports.latin2mic)(t,e,I,B,tr,rr),Module._mic2latin=(t,e,I,B,tr,rr)=>(Module._mic2latin=wasmExports.mic2latin)(t,e,I,B,tr,rr),Module._latin2mic_with_table=(t,e,I,B,tr,rr,ir)=>(Module._latin2mic_with_table=wasmExports.latin2mic_with_table)(t,e,I,B,tr,rr,ir),Module._mic2latin_with_table=(t,e,I,B,tr,rr,ir)=>(Module._mic2latin_with_table=wasmExports.mic2latin_with_table)(t,e,I,B,tr,rr,ir),Module._pg_encoding_verifymbchar=(t,e,I)=>(Module._pg_encoding_verifymbchar=wasmExports.pg_encoding_verifymbchar)(t,e,I),Module._float_overflow_error=()=>(Module._float_overflow_error=wasmExports.float_overflow_error)(),Module._float_underflow_error=()=>(Module._float_underflow_error=wasmExports.float_underflow_error)(),Module._float4in_internal=(t,e,I,B,tr)=>(Module._float4in_internal=wasmExports.float4in_internal)(t,e,I,B,tr),Module._strtof=(t,e)=>(Module._strtof=wasmExports.strtof)(t,e),Module._float_to_shortest_decimal_buf=(t,e)=>(Module._float_to_shortest_decimal_buf=wasmExports.float_to_shortest_decimal_buf)(t,e),Module._float8in_internal=(t,e,I,B,tr)=>(Module._float8in_internal=wasmExports.float8in_internal)(t,e,I,B,tr),Module._float8out_internal=t=>(Module._float8out_internal=wasmExports.float8out_internal)(t),Module._btfloat4cmp=t=>(Module._btfloat4cmp=wasmExports.btfloat4cmp)(t),Module._btfloat8cmp=t=>(Module._btfloat8cmp=wasmExports.btfloat8cmp)(t),Module._pow=(t,e)=>(Module._pow=wasmExports.pow)(t,e),Module._log10=t=>(Module._log10=wasmExports.log10)(t),Module._acos=t=>(Module._acos=wasmExports.acos)(t),Module._asin=t=>(Module._asin=wasmExports.asin)(t),Module._cos=t=>(Module._cos=wasmExports.cos)(t),Module._sin=t=>(Module._sin=wasmExports.sin)(t),Module._fmod=(t,e)=>(Module._fmod=wasmExports.fmod)(t,e),Module._construct_array=(t,e,I,B,tr,rr)=>(Module._construct_array=wasmExports.construct_array)(t,e,I,B,tr,rr),Module._try_relation_open=(t,e)=>(Module._try_relation_open=wasmExports.try_relation_open)(t,e),Module._forkname_to_number=t=>(Module._forkname_to_number=wasmExports.forkname_to_number)(t),Module._numeric_lt=t=>(Module._numeric_lt=wasmExports.numeric_lt)(t),Module._int64_to_numeric=t=>(Module._int64_to_numeric=wasmExports.int64_to_numeric)(t),Module._numeric_sub=t=>(Module._numeric_sub=wasmExports.numeric_sub)(t),Module._numeric_ge=t=>(Module._numeric_ge=wasmExports.numeric_ge)(t),Module._inet_in=t=>(Module._inet_in=wasmExports.inet_in)(t),Module._format_operator=t=>(Module._format_operator=wasmExports.format_operator)(t),Module._RelationIsVisible=t=>(Module._RelationIsVisible=wasmExports.RelationIsVisible)(t),Module._pg_get_indexdef_columns_extended=(t,e)=>(Module._pg_get_indexdef_columns_extended=wasmExports.pg_get_indexdef_columns_extended)(t,e),Module._accumArrayResult=(t,e,I,B,tr)=>(Module._accumArrayResult=wasmExports.accumArrayResult)(t,e,I,B,tr),Module._makeArrayResult=(t,e)=>(Module._makeArrayResult=wasmExports.makeArrayResult)(t,e),Module._init_local_reloptions=(t,e)=>(Module._init_local_reloptions=wasmExports.init_local_reloptions)(t,e),Module._add_local_int_reloption=(t,e,I,B,tr,rr,ir)=>(Module._add_local_int_reloption=wasmExports.add_local_int_reloption)(t,e,I,B,tr,rr,ir),Module._pg_inet_net_ntop=(t,e,I,B,tr)=>(Module._pg_inet_net_ntop=wasmExports.pg_inet_net_ntop)(t,e,I,B,tr),Module._network_cmp=t=>(Module._network_cmp=wasmExports.network_cmp)(t),Module._convert_network_to_scalar=(t,e,I)=>(Module._convert_network_to_scalar=wasmExports.convert_network_to_scalar)(t,e,I),Module._JsonbValueToJsonb=t=>(Module._JsonbValueToJsonb=wasmExports.JsonbValueToJsonb)(t),Module._pushJsonbValue=(t,e,I)=>(Module._pushJsonbValue=wasmExports.pushJsonbValue)(t,e,I),Module._numeric_cmp=t=>(Module._numeric_cmp=wasmExports.numeric_cmp)(t),Module._timetz_cmp=t=>(Module._timetz_cmp=wasmExports.timetz_cmp)(t),Module._date_cmp=t=>(Module._date_cmp=wasmExports.date_cmp)(t),Module._time_cmp=t=>(Module._time_cmp=wasmExports.time_cmp)(t),Module._timestamp_cmp=t=>(Module._timestamp_cmp=wasmExports.timestamp_cmp)(t),Module._domain_check=(t,e,I,B,tr)=>(Module._domain_check=wasmExports.domain_check)(t,e,I,B,tr),Module._initArrayResult=(t,e,I)=>(Module._initArrayResult=wasmExports.initArrayResult)(t,e,I),Module._path_is_prefix_of_path=(t,e)=>(Module._path_is_prefix_of_path=wasmExports.path_is_prefix_of_path)(t,e),Module._path_is_relative_and_below_cwd=t=>(Module._path_is_relative_and_below_cwd=wasmExports.path_is_relative_and_below_cwd)(t),Module._ArrayGetIntegerTypmods=(t,e)=>(Module._ArrayGetIntegerTypmods=wasmExports.ArrayGetIntegerTypmods)(t,e),Module._bpchareq=t=>(Module._bpchareq=wasmExports.bpchareq)(t),Module._varstr_cmp=(t,e,I,B,tr)=>(Module._varstr_cmp=wasmExports.varstr_cmp)(t,e,I,B,tr),Module._bpcharlt=t=>(Module._bpcharlt=wasmExports.bpcharlt)(t),Module._bpcharle=t=>(Module._bpcharle=wasmExports.bpcharle)(t),Module._bpchargt=t=>(Module._bpchargt=wasmExports.bpchargt)(t),Module._bpcharge=t=>(Module._bpcharge=wasmExports.bpcharge)(t),Module._bpcharcmp=t=>(Module._bpcharcmp=wasmExports.bpcharcmp)(t),Module._current_query=t=>(Module._current_query=wasmExports.current_query)(t),Module._str_tolower=(t,e,I)=>(Module._str_tolower=wasmExports.str_tolower)(t,e,I),Module._TransferExpandedObject=(t,e)=>(Module._TransferExpandedObject=wasmExports.TransferExpandedObject)(t,e),Module._macaddr_cmp=t=>(Module._macaddr_cmp=wasmExports.macaddr_cmp)(t),Module._macaddr_lt=t=>(Module._macaddr_lt=wasmExports.macaddr_lt)(t),Module._macaddr_le=t=>(Module._macaddr_le=wasmExports.macaddr_le)(t),Module._macaddr_eq=t=>(Module._macaddr_eq=wasmExports.macaddr_eq)(t),Module._macaddr_ge=t=>(Module._macaddr_ge=wasmExports.macaddr_ge)(t),Module._macaddr_gt=t=>(Module._macaddr_gt=wasmExports.macaddr_gt)(t),Module._quote_ident=t=>(Module._quote_ident=wasmExports.quote_ident)(t),Module._timestamp_in=t=>(Module._timestamp_in=wasmExports.timestamp_in)(t),Module._ParseDateTime=(t,e,I,B,tr,rr,ir)=>(Module._ParseDateTime=wasmExports.ParseDateTime)(t,e,I,B,tr,rr,ir),Module._DecodeDateTime=(t,e,I,B,tr,rr,ir,lr)=>(Module._DecodeDateTime=wasmExports.DecodeDateTime)(t,e,I,B,tr,rr,ir,lr),Module.___multi3=(t,e,I,B,tr)=>(Module.___multi3=wasmExports.__multi3)(t,e,I,B,tr),Module._timestamptz_in=t=>(Module._timestamptz_in=wasmExports.timestamptz_in)(t),Module._timestamp_eq=t=>(Module._timestamp_eq=wasmExports.timestamp_eq)(t),Module._timestamp_lt=t=>(Module._timestamp_lt=wasmExports.timestamp_lt)(t),Module._timestamp_gt=t=>(Module._timestamp_gt=wasmExports.timestamp_gt)(t),Module._timestamp_le=t=>(Module._timestamp_le=wasmExports.timestamp_le)(t),Module._timestamp_ge=t=>(Module._timestamp_ge=wasmExports.timestamp_ge)(t),Module._interval_eq=t=>(Module._interval_eq=wasmExports.interval_eq)(t),Module._interval_lt=t=>(Module._interval_lt=wasmExports.interval_lt)(t),Module._interval_gt=t=>(Module._interval_gt=wasmExports.interval_gt)(t),Module._interval_le=t=>(Module._interval_le=wasmExports.interval_le)(t),Module._interval_ge=t=>(Module._interval_ge=wasmExports.interval_ge)(t),Module._interval_cmp=t=>(Module._interval_cmp=wasmExports.interval_cmp)(t),Module._timestamp_mi=t=>(Module._timestamp_mi=wasmExports.timestamp_mi)(t),Module._interval_um=t=>(Module._interval_um=wasmExports.interval_um)(t),Module._interval_mi=t=>(Module._interval_mi=wasmExports.interval_mi)(t),Module._IsValidJsonNumber=(t,e)=>(Module._IsValidJsonNumber=wasmExports.IsValidJsonNumber)(t,e),Module._btnamecmp=t=>(Module._btnamecmp=wasmExports.btnamecmp)(t),Module._strncpy=(t,e,I)=>(Module._strncpy=wasmExports.strncpy)(t,e,I),Module._expand_array=(t,e,I)=>(Module._expand_array=wasmExports.expand_array)(t,e,I),Module._pg_get_encoding_from_locale=(t,e)=>(Module._pg_get_encoding_from_locale=wasmExports.pg_get_encoding_from_locale)(t,e),Module._localtime=t=>(Module._localtime=wasmExports.localtime)(t),Module._strftime=(t,e,I,B)=>(Module._strftime=wasmExports.strftime)(t,e,I,B),Module._numeric_is_nan=t=>(Module._numeric_is_nan=wasmExports.numeric_is_nan)(t),Module._numeric_eq=t=>(Module._numeric_eq=wasmExports.numeric_eq)(t),Module._numeric_gt=t=>(Module._numeric_gt=wasmExports.numeric_gt)(t),Module._numeric_le=t=>(Module._numeric_le=wasmExports.numeric_le)(t),Module._numeric_div=t=>(Module._numeric_div=wasmExports.numeric_div)(t),Module._numeric_float8_no_overflow=t=>(Module._numeric_float8_no_overflow=wasmExports.numeric_float8_no_overflow)(t),Module._numeric_float4=t=>(Module._numeric_float4=wasmExports.numeric_float4)(t),Module._date_eq=t=>(Module._date_eq=wasmExports.date_eq)(t),Module._date_lt=t=>(Module._date_lt=wasmExports.date_lt)(t),Module._date_le=t=>(Module._date_le=wasmExports.date_le)(t),Module._date_gt=t=>(Module._date_gt=wasmExports.date_gt)(t),Module._date_ge=t=>(Module._date_ge=wasmExports.date_ge)(t),Module._date_mi=t=>(Module._date_mi=wasmExports.date_mi)(t),Module._time_eq=t=>(Module._time_eq=wasmExports.time_eq)(t),Module._time_lt=t=>(Module._time_lt=wasmExports.time_lt)(t),Module._time_le=t=>(Module._time_le=wasmExports.time_le)(t),Module._time_gt=t=>(Module._time_gt=wasmExports.time_gt)(t),Module._time_ge=t=>(Module._time_ge=wasmExports.time_ge)(t),Module._time_mi_time=t=>(Module._time_mi_time=wasmExports.time_mi_time)(t),Module._get_extension_oid=(t,e)=>(Module._get_extension_oid=wasmExports.get_extension_oid)(t,e),Module._pg_ltoa=(t,e)=>(Module._pg_ltoa=wasmExports.pg_ltoa)(t,e),Module._varbit_in=t=>(Module._varbit_in=wasmExports.varbit_in)(t),Module._biteq=t=>(Module._biteq=wasmExports.biteq)(t),Module._bitlt=t=>(Module._bitlt=wasmExports.bitlt)(t),Module._bitle=t=>(Module._bitle=wasmExports.bitle)(t),Module._bitgt=t=>(Module._bitgt=wasmExports.bitgt)(t),Module._bitge=t=>(Module._bitge=wasmExports.bitge)(t),Module._bitcmp=t=>(Module._bitcmp=wasmExports.bitcmp)(t),Module._tidin=t=>(Module._tidin=wasmExports.tidin)(t),Module._tidout=t=>(Module._tidout=wasmExports.tidout)(t),Module._cash_cmp=t=>(Module._cash_cmp=wasmExports.cash_cmp)(t),Module._arraycontsel=t=>(Module._arraycontsel=wasmExports.arraycontsel)(t),Module._arraycontjoinsel=t=>(Module._arraycontjoinsel=wasmExports.arraycontjoinsel)(t),Module._text_lt=t=>(Module._text_lt=wasmExports.text_lt)(t),Module._text_le=t=>(Module._text_le=wasmExports.text_le)(t),Module._text_gt=t=>(Module._text_gt=wasmExports.text_gt)(t),Module._text_ge=t=>(Module._text_ge=wasmExports.text_ge)(t),Module._bttextcmp=t=>(Module._bttextcmp=wasmExports.bttextcmp)(t),Module._byteaeq=t=>(Module._byteaeq=wasmExports.byteaeq)(t),Module._bytealt=t=>(Module._bytealt=wasmExports.bytealt)(t),Module._byteale=t=>(Module._byteale=wasmExports.byteale)(t),Module._byteagt=t=>(Module._byteagt=wasmExports.byteagt)(t),Module._byteage=t=>(Module._byteage=wasmExports.byteage)(t),Module._byteacmp=t=>(Module._byteacmp=wasmExports.byteacmp)(t),Module._to_hex32=t=>(Module._to_hex32=wasmExports.to_hex32)(t),Module._varstr_levenshtein=(t,e,I,B,tr,rr,ir,lr)=>(Module._varstr_levenshtein=wasmExports.varstr_levenshtein)(t,e,I,B,tr,rr,ir,lr),Module._utf8_to_unicode=t=>(Module._utf8_to_unicode=wasmExports.utf8_to_unicode)(t),Module._format_type_extended=(t,e,I)=>(Module._format_type_extended=wasmExports.format_type_extended)(t,e,I),Module._array_create_iterator=(t,e,I)=>(Module._array_create_iterator=wasmExports.array_create_iterator)(t,e,I),Module._array_iterate=(t,e,I)=>(Module._array_iterate=wasmExports.array_iterate)(t,e,I),Module._make_expanded_record_from_typeid=(t,e,I)=>(Module._make_expanded_record_from_typeid=wasmExports.make_expanded_record_from_typeid)(t,e,I),Module._make_expanded_record_from_tupdesc=(t,e)=>(Module._make_expanded_record_from_tupdesc=wasmExports.make_expanded_record_from_tupdesc)(t,e),Module._make_expanded_record_from_exprecord=(t,e)=>(Module._make_expanded_record_from_exprecord=wasmExports.make_expanded_record_from_exprecord)(t,e),Module._expanded_record_set_tuple=(t,e,I,B)=>(Module._expanded_record_set_tuple=wasmExports.expanded_record_set_tuple)(t,e,I,B),Module._expanded_record_get_tuple=t=>(Module._expanded_record_get_tuple=wasmExports.expanded_record_get_tuple)(t),Module._deconstruct_expanded_record=t=>(Module._deconstruct_expanded_record=wasmExports.deconstruct_expanded_record)(t),Module._expanded_record_lookup_field=(t,e,I)=>(Module._expanded_record_lookup_field=wasmExports.expanded_record_lookup_field)(t,e,I),Module._expanded_record_set_field_internal=(t,e,I,B,tr,rr)=>(Module._expanded_record_set_field_internal=wasmExports.expanded_record_set_field_internal)(t,e,I,B,tr,rr),Module._expanded_record_set_fields=(t,e,I,B)=>(Module._expanded_record_set_fields=wasmExports.expanded_record_set_fields)(t,e,I,B),Module._macaddr8_cmp=t=>(Module._macaddr8_cmp=wasmExports.macaddr8_cmp)(t),Module._macaddr8_lt=t=>(Module._macaddr8_lt=wasmExports.macaddr8_lt)(t),Module._macaddr8_le=t=>(Module._macaddr8_le=wasmExports.macaddr8_le)(t),Module._macaddr8_eq=t=>(Module._macaddr8_eq=wasmExports.macaddr8_eq)(t),Module._macaddr8_ge=t=>(Module._macaddr8_ge=wasmExports.macaddr8_ge)(t),Module._macaddr8_gt=t=>(Module._macaddr8_gt=wasmExports.macaddr8_gt)(t),Module._enum_lt=t=>(Module._enum_lt=wasmExports.enum_lt)(t),Module._enum_le=t=>(Module._enum_le=wasmExports.enum_le)(t),Module._enum_ge=t=>(Module._enum_ge=wasmExports.enum_ge)(t),Module._enum_gt=t=>(Module._enum_gt=wasmExports.enum_gt)(t),Module._enum_cmp=t=>(Module._enum_cmp=wasmExports.enum_cmp)(t),Module._uuid_in=t=>(Module._uuid_in=wasmExports.uuid_in)(t),Module._uuid_out=t=>(Module._uuid_out=wasmExports.uuid_out)(t),Module._uuid_cmp=t=>(Module._uuid_cmp=wasmExports.uuid_cmp)(t),Module._gen_random_uuid=t=>(Module._gen_random_uuid=wasmExports.gen_random_uuid)(t),Module._generic_restriction_selectivity=(t,e,I,B,tr,rr)=>(Module._generic_restriction_selectivity=wasmExports.generic_restriction_selectivity)(t,e,I,B,tr,rr),Module._genericcostestimate=(t,e,I,B)=>(Module._genericcostestimate=wasmExports.genericcostestimate)(t,e,I,B),Module._pg_xml_init=t=>(Module._pg_xml_init=wasmExports.pg_xml_init)(t),Module._xmlInitParser=()=>(Module._xmlInitParser=wasmExports.xmlInitParser)(),Module._xml_ereport=(t,e,I,B)=>(Module._xml_ereport=wasmExports.xml_ereport)(t,e,I,B),Module._pg_xml_done=(t,e)=>(Module._pg_xml_done=wasmExports.pg_xml_done)(t,e),Module._xmlXPathNewContext=t=>(Module._xmlXPathNewContext=wasmExports.xmlXPathNewContext)(t),Module._xmlXPathFreeContext=t=>(Module._xmlXPathFreeContext=wasmExports.xmlXPathFreeContext)(t),Module._xmlFreeDoc=t=>(Module._xmlFreeDoc=wasmExports.xmlFreeDoc)(t),Module._xmlXPathCompile=t=>(Module._xmlXPathCompile=wasmExports.xmlXPathCompile)(t),Module._xmlXPathCompiledEval=(t,e)=>(Module._xmlXPathCompiledEval=wasmExports.xmlXPathCompiledEval)(t,e),Module._xmlXPathFreeCompExpr=t=>(Module._xmlXPathFreeCompExpr=wasmExports.xmlXPathFreeCompExpr)(t),Module._xmlStrdup=t=>(Module._xmlStrdup=wasmExports.xmlStrdup)(t),Module._strnlen=(t,e)=>(Module._strnlen=wasmExports.strnlen)(t,e),Module._xmlXPathCastNodeToString=t=>(Module._xmlXPathCastNodeToString=wasmExports.xmlXPathCastNodeToString)(t),Module._heap_modify_tuple_by_cols=(t,e,I,B,tr,rr)=>(Module._heap_modify_tuple_by_cols=wasmExports.heap_modify_tuple_by_cols)(t,e,I,B,tr,rr),Module._ResourceOwnerReleaseAllPlanCacheRefs=t=>(Module._ResourceOwnerReleaseAllPlanCacheRefs=wasmExports.ResourceOwnerReleaseAllPlanCacheRefs)(t),Module._RegisterResourceReleaseCallback=(t,e)=>(Module._RegisterResourceReleaseCallback=wasmExports.RegisterResourceReleaseCallback)(t,e),Module._PinPortal=t=>(Module._PinPortal=wasmExports.PinPortal)(t),Module._UnpinPortal=t=>(Module._UnpinPortal=wasmExports.UnpinPortal)(t),Module._btint2cmp=t=>(Module._btint2cmp=wasmExports.btint2cmp)(t),Module._btint4cmp=t=>(Module._btint4cmp=wasmExports.btint4cmp)(t),Module._btoidcmp=t=>(Module._btoidcmp=wasmExports.btoidcmp)(t),Module._btcharcmp=t=>(Module._btcharcmp=wasmExports.btcharcmp)(t),Module._btint8cmp=t=>(Module._btint8cmp=wasmExports.btint8cmp)(t),Module._btboolcmp=t=>(Module._btboolcmp=wasmExports.btboolcmp)(t),Module._GetPublicationByName=(t,e)=>(Module._GetPublicationByName=wasmExports.GetPublicationByName)(t,e),Module._GetTopMostAncestorInPublication=(t,e,I)=>(Module._GetTopMostAncestorInPublication=wasmExports.GetTopMostAncestorInPublication)(t,e,I),Module._pub_collist_to_bitmapset=(t,e,I)=>(Module._pub_collist_to_bitmapset=wasmExports.pub_collist_to_bitmapset)(t,e,I),Module._getExtensionOfObject=(t,e)=>(Module._getExtensionOfObject=wasmExports.getExtensionOfObject)(t,e),Module._visibilitymap_prepare_truncate=(t,e)=>(Module._visibilitymap_prepare_truncate=wasmExports.visibilitymap_prepare_truncate)(t,e),Module._log_newpage_range=(t,e,I,B,tr)=>(Module._log_newpage_range=wasmExports.log_newpage_range)(t,e,I,B,tr),Module._function_parse_error_transpose=t=>(Module._function_parse_error_transpose=wasmExports.function_parse_error_transpose)(t),Module._IndexGetRelation=(t,e)=>(Module._IndexGetRelation=wasmExports.IndexGetRelation)(t,e),Module._RelnameGetRelid=t=>(Module._RelnameGetRelid=wasmExports.RelnameGetRelid)(t),Module._standard_ProcessUtility=(t,e,I,B,tr,rr,ir,lr)=>(Module._standard_ProcessUtility=wasmExports.standard_ProcessUtility)(t,e,I,B,tr,rr,ir,lr),Module._Async_Notify=(t,e)=>(Module._Async_Notify=wasmExports.Async_Notify)(t,e),Module._sigaddset=(t,e)=>(Module._sigaddset=wasmExports.sigaddset)(t,e),Module._fsync_pgdata=(t,e)=>(Module._fsync_pgdata=wasmExports.fsync_pgdata)(t,e),Module._get_restricted_token=()=>(Module._get_restricted_token=wasmExports.get_restricted_token)(),Module._pg_malloc=t=>(Module._pg_malloc=wasmExports.pg_malloc)(t),Module._pg_realloc=(t,e)=>(Module._pg_realloc=wasmExports.pg_realloc)(t,e),Module._pg_strdup=t=>(Module._pg_strdup=wasmExports.pg_strdup)(t),Module._simple_prompt=(t,e)=>(Module._simple_prompt=wasmExports.simple_prompt)(t,e),Module._interactive_file=()=>(Module._interactive_file=wasmExports.interactive_file)(),Module._interactive_one=()=>(Module._interactive_one=wasmExports.interactive_one)(),Module._pg_shutdown=()=>(Module._pg_shutdown=wasmExports.pg_shutdown)(),Module._interactive_write=t=>(Module._interactive_write=wasmExports.interactive_write)(t),Module._interactive_read=()=>(Module._interactive_read=wasmExports.interactive_read)(),Module._visibilitymap_pin=(t,e,I)=>(Module._visibilitymap_pin=wasmExports.visibilitymap_pin)(t,e,I),Module._HeapTupleSatisfiesVacuum=(t,e,I)=>(Module._HeapTupleSatisfiesVacuum=wasmExports.HeapTupleSatisfiesVacuum)(t,e,I),Module._visibilitymap_clear=(t,e,I,B)=>(Module._visibilitymap_clear=wasmExports.visibilitymap_clear)(t,e,I,B),Module._vac_estimate_reltuples=(t,e,I,B)=>(Module._vac_estimate_reltuples=wasmExports.vac_estimate_reltuples)(t,e,I,B),Module._heap_tuple_needs_eventual_freeze=t=>(Module._heap_tuple_needs_eventual_freeze=wasmExports.heap_tuple_needs_eventual_freeze)(t),Module._HeapTupleSatisfiesUpdate=(t,e,I)=>(Module._HeapTupleSatisfiesUpdate=wasmExports.HeapTupleSatisfiesUpdate)(t,e,I),Module._HeapTupleGetUpdateXid=t=>(Module._HeapTupleGetUpdateXid=wasmExports.HeapTupleGetUpdateXid)(t),Module._HeapTupleSatisfiesVisibility=(t,e,I)=>(Module._HeapTupleSatisfiesVisibility=wasmExports.HeapTupleSatisfiesVisibility)(t,e,I),Module._GetMultiXactIdMembers=(t,e,I,B)=>(Module._GetMultiXactIdMembers=wasmExports.GetMultiXactIdMembers)(t,e,I,B),Module._XLogRecGetBlockTagExtended=(t,e,I,B,tr,rr)=>(Module._XLogRecGetBlockTagExtended=wasmExports.XLogRecGetBlockTagExtended)(t,e,I,B,tr,rr),Module._toast_open_indexes=(t,e,I,B)=>(Module._toast_open_indexes=wasmExports.toast_open_indexes)(t,e,I,B),Module._init_toast_snapshot=t=>(Module._init_toast_snapshot=wasmExports.init_toast_snapshot)(t),Module._toast_close_indexes=(t,e,I)=>(Module._toast_close_indexes=wasmExports.toast_close_indexes)(t,e,I),Module._index_getprocinfo=(t,e,I)=>(Module._index_getprocinfo=wasmExports.index_getprocinfo)(t,e,I),Module._identify_opfamily_groups=(t,e)=>(Module._identify_opfamily_groups=wasmExports.identify_opfamily_groups)(t,e),Module._check_amproc_signature=(t,e,I,B,tr,rr)=>(Module._check_amproc_signature=wasmExports.check_amproc_signature)(t,e,I,B,tr,rr),Module._check_amoptsproc_signature=t=>(Module._check_amoptsproc_signature=wasmExports.check_amoptsproc_signature)(t),Module._check_amop_signature=(t,e,I,B)=>(Module._check_amop_signature=wasmExports.check_amop_signature)(t,e,I,B),Module._RelationGetIndexScan=(t,e,I)=>(Module._RelationGetIndexScan=wasmExports.RelationGetIndexScan)(t,e,I),Module.__hash_get_indextuple_hashkey=t=>(Module.__hash_get_indextuple_hashkey=wasmExports._hash_get_indextuple_hashkey)(t),Module.__hash_getbuf=(t,e,I,B)=>(Module.__hash_getbuf=wasmExports._hash_getbuf)(t,e,I,B),Module.__hash_relbuf=(t,e)=>(Module.__hash_relbuf=wasmExports._hash_relbuf)(t,e),Module.__hash_getbuf_with_strategy=(t,e,I,B,tr)=>(Module.__hash_getbuf_with_strategy=wasmExports._hash_getbuf_with_strategy)(t,e,I,B,tr),Module._build_reloptions=(t,e,I,B,tr,rr)=>(Module._build_reloptions=wasmExports.build_reloptions)(t,e,I,B,tr,rr),Module._index_form_tuple=(t,e,I)=>(Module._index_form_tuple=wasmExports.index_form_tuple)(t,e,I),Module.__hash_ovflblkno_to_bitno=(t,e)=>(Module.__hash_ovflblkno_to_bitno=wasmExports._hash_ovflblkno_to_bitno)(t,e),Module._brin_build_desc=t=>(Module._brin_build_desc=wasmExports.brin_build_desc)(t),Module._brin_deform_tuple=(t,e,I)=>(Module._brin_deform_tuple=wasmExports.brin_deform_tuple)(t,e,I),Module._brin_free_desc=t=>(Module._brin_free_desc=wasmExports.brin_free_desc)(t),Module._XLogRecGetBlockRefInfo=(t,e,I,B,tr)=>(Module._XLogRecGetBlockRefInfo=wasmExports.XLogRecGetBlockRefInfo)(t,e,I,B,tr),Module._ginPostingListDecode=(t,e)=>(Module._ginPostingListDecode=wasmExports.ginPostingListDecode)(t,e),Module._add_reloption_kind=()=>(Module._add_reloption_kind=wasmExports.add_reloption_kind)(),Module._register_reloptions_validator=(t,e)=>(Module._register_reloptions_validator=wasmExports.register_reloptions_validator)(t,e),Module._add_int_reloption=(t,e,I,B,tr,rr,ir)=>(Module._add_int_reloption=wasmExports.add_int_reloption)(t,e,I,B,tr,rr,ir),Module._XLogFindNextRecord=(t,e)=>(Module._XLogFindNextRecord=wasmExports.XLogFindNextRecord)(t,e),Module._RestoreBlockImage=(t,e,I)=>(Module._RestoreBlockImage=wasmExports.RestoreBlockImage)(t,e,I),Module._GenericXLogStart=t=>(Module._GenericXLogStart=wasmExports.GenericXLogStart)(t),Module._GenericXLogRegisterBuffer=(t,e,I)=>(Module._GenericXLogRegisterBuffer=wasmExports.GenericXLogRegisterBuffer)(t,e,I),Module._GenericXLogFinish=t=>(Module._GenericXLogFinish=wasmExports.GenericXLogFinish)(t),Module._GenericXLogAbort=t=>(Module._GenericXLogAbort=wasmExports.GenericXLogAbort)(t),Module._read_local_xlog_page_no_wait=(t,e,I,B,tr)=>(Module._read_local_xlog_page_no_wait=wasmExports.read_local_xlog_page_no_wait)(t,e,I,B,tr),Module._XLogRecStoreStats=(t,e)=>(Module._XLogRecStoreStats=wasmExports.XLogRecStoreStats)(t,e),Module._ReadMultiXactIdRange=(t,e)=>(Module._ReadMultiXactIdRange=wasmExports.ReadMultiXactIdRange)(t,e),Module._MultiXactIdPrecedesOrEquals=(t,e)=>(Module._MultiXactIdPrecedesOrEquals=wasmExports.MultiXactIdPrecedesOrEquals)(t,e),Module._RegisterXactCallback=(t,e)=>(Module._RegisterXactCallback=wasmExports.RegisterXactCallback)(t,e),Module._RegisterSubXactCallback=(t,e)=>(Module._RegisterSubXactCallback=wasmExports.RegisterSubXactCallback)(t,e),Module._ReleaseCurrentSubTransaction=()=>(Module._ReleaseCurrentSubTransaction=wasmExports.ReleaseCurrentSubTransaction)(),Module._WaitForParallelWorkersToAttach=t=>(Module._WaitForParallelWorkersToAttach=wasmExports.WaitForParallelWorkersToAttach)(t),Module.__bt_allequalimage=(t,e)=>(Module.__bt_allequalimage=wasmExports._bt_allequalimage)(t,e),Module.__bt_checkpage=(t,e)=>(Module.__bt_checkpage=wasmExports._bt_checkpage)(t,e),Module.__bt_relbuf=(t,e)=>(Module.__bt_relbuf=wasmExports._bt_relbuf)(t,e),Module.__bt_metaversion=(t,e,I)=>(Module.__bt_metaversion=wasmExports._bt_metaversion)(t,e,I),Module.__bt_search=(t,e,I,B,tr,rr)=>(Module.__bt_search=wasmExports._bt_search)(t,e,I,B,tr,rr),Module.__bt_compare=(t,e,I,B)=>(Module.__bt_compare=wasmExports._bt_compare)(t,e,I,B),Module.__bt_binsrch_insert=(t,e)=>(Module.__bt_binsrch_insert=wasmExports._bt_binsrch_insert)(t,e),Module.__bt_freestack=t=>(Module.__bt_freestack=wasmExports._bt_freestack)(t),Module.__bt_form_posting=(t,e,I)=>(Module.__bt_form_posting=wasmExports._bt_form_posting)(t,e,I),Module.__bt_check_natts=(t,e,I,B)=>(Module.__bt_check_natts=wasmExports._bt_check_natts)(t,e,I,B),Module._gistcheckpage=(t,e)=>(Module._gistcheckpage=wasmExports.gistcheckpage)(t,e),Module._EndCopyFrom=t=>(Module._EndCopyFrom=wasmExports.EndCopyFrom)(t),Module._ProcessCopyOptions=(t,e,I,B)=>(Module._ProcessCopyOptions=wasmExports.ProcessCopyOptions)(t,e,I,B),Module._CopyFromErrorCallback=t=>(Module._CopyFromErrorCallback=wasmExports.CopyFromErrorCallback)(t),Module._NextCopyFrom=(t,e,I,B)=>(Module._NextCopyFrom=wasmExports.NextCopyFrom)(t,e,I,B),Module._nextval=t=>(Module._nextval=wasmExports.nextval)(t),Module._defGetStreamingMode=t=>(Module._defGetStreamingMode=wasmExports.defGetStreamingMode)(t),Module._ExplainBeginOutput=t=>(Module._ExplainBeginOutput=wasmExports.ExplainBeginOutput)(t),Module._NewExplainState=()=>(Module._NewExplainState=wasmExports.NewExplainState)(),Module._ExplainEndOutput=t=>(Module._ExplainEndOutput=wasmExports.ExplainEndOutput)(t),Module._ExplainPrintPlan=(t,e)=>(Module._ExplainPrintPlan=wasmExports.ExplainPrintPlan)(t,e),Module._ExplainPrintTriggers=(t,e)=>(Module._ExplainPrintTriggers=wasmExports.ExplainPrintTriggers)(t,e),Module._ExplainPrintJITSummary=(t,e)=>(Module._ExplainPrintJITSummary=wasmExports.ExplainPrintJITSummary)(t,e),Module._ExplainPropertyInteger=(t,e,I,B)=>(Module._ExplainPropertyInteger=wasmExports.ExplainPropertyInteger)(t,e,I,B),Module._ExplainQueryText=(t,e)=>(Module._ExplainQueryText=wasmExports.ExplainQueryText)(t,e),Module._ExplainPropertyText=(t,e,I)=>(Module._ExplainPropertyText=wasmExports.ExplainPropertyText)(t,e,I),Module._ExplainQueryParameters=(t,e,I)=>(Module._ExplainQueryParameters=wasmExports.ExplainQueryParameters)(t,e,I),Module._pg_is_ascii=t=>(Module._pg_is_ascii=wasmExports.pg_is_ascii)(t),Module._fputs=(t,e)=>(Module._fputs=wasmExports.fputs)(t,e),Module._popen=(t,e)=>(Module._popen=wasmExports.popen)(t,e),Module._float_to_shortest_decimal_bufn=(t,e)=>(Module._float_to_shortest_decimal_bufn=wasmExports.float_to_shortest_decimal_bufn)(t,e),Module._pg_prng_uint64=t=>(Module._pg_prng_uint64=wasmExports.pg_prng_uint64)(t),Module._scram_ClientKey=(t,e,I,B,tr)=>(Module._scram_ClientKey=wasmExports.scram_ClientKey)(t,e,I,B,tr),Module._pg_encoding_dsplen=(t,e)=>(Module._pg_encoding_dsplen=wasmExports.pg_encoding_dsplen)(t,e),Module._getcwd=(t,e)=>(Module._getcwd=wasmExports.getcwd)(t,e),Module._pg_get_user_home_dir=(t,e,I)=>(Module._pg_get_user_home_dir=wasmExports.pg_get_user_home_dir)(t,e,I),Module._nanosleep=(t,e)=>(Module._nanosleep=wasmExports.nanosleep)(t,e),Module._snprintf=(t,e,I,B)=>(Module._snprintf=wasmExports.snprintf)(t,e,I,B),Module._pg_strerror_r=(t,e,I)=>(Module._pg_strerror_r=wasmExports.pg_strerror_r)(t,e,I),Module._pthread_mutex_lock=t=>(Module._pthread_mutex_lock=wasmExports.pthread_mutex_lock)(t),Module._pthread_mutex_unlock=t=>(Module._pthread_mutex_unlock=wasmExports.pthread_mutex_unlock)(t),Module._strncat=(t,e,I)=>(Module._strncat=wasmExports.strncat)(t,e,I),Module._PQexec=(t,e)=>(Module._PQexec=wasmExports.PQexec)(t,e),Module._PQsetSingleRowMode=t=>(Module._PQsetSingleRowMode=wasmExports.PQsetSingleRowMode)(t),Module._PQcmdStatus=t=>(Module._PQcmdStatus=wasmExports.PQcmdStatus)(t),Module._pthread_sigmask=(t,e,I)=>(Module._pthread_sigmask=wasmExports.pthread_sigmask)(t,e,I),Module._sigismember=(t,e)=>(Module._sigismember=wasmExports.sigismember)(t,e),Module._sigpending=t=>(Module._sigpending=wasmExports.sigpending)(t),Module._sigwait=(t,e)=>(Module._sigwait=wasmExports.sigwait)(t,e),Module._isolat1ToUTF8=(t,e,I,B)=>(Module._isolat1ToUTF8=wasmExports.isolat1ToUTF8)(t,e,I,B),Module._UTF8Toisolat1=(t,e,I,B)=>(Module._UTF8Toisolat1=wasmExports.UTF8Toisolat1)(t,e,I,B),Module._vfprintf=(t,e,I)=>(Module._vfprintf=wasmExports.vfprintf)(t,e,I),Module._vsnprintf=(t,e,I,B)=>(Module._vsnprintf=wasmExports.vsnprintf)(t,e,I,B),Module._xmlParserValidityWarning=(t,e,I)=>(Module._xmlParserValidityWarning=wasmExports.xmlParserValidityWarning)(t,e,I),Module._xmlParserValidityError=(t,e,I)=>(Module._xmlParserValidityError=wasmExports.xmlParserValidityError)(t,e,I),Module._xmlParserError=(t,e,I)=>(Module._xmlParserError=wasmExports.xmlParserError)(t,e,I),Module._xmlParserWarning=(t,e,I)=>(Module._xmlParserWarning=wasmExports.xmlParserWarning)(t,e,I),Module._fprintf=(t,e,I)=>(Module._fprintf=wasmExports.fprintf)(t,e,I),Module.___xmlParserInputBufferCreateFilename=(t,e)=>(Module.___xmlParserInputBufferCreateFilename=wasmExports.__xmlParserInputBufferCreateFilename)(t,e),Module.___xmlOutputBufferCreateFilename=(t,e,I)=>(Module.___xmlOutputBufferCreateFilename=wasmExports.__xmlOutputBufferCreateFilename)(t,e,I),Module._xmlSAX2InternalSubset=(t,e,I,B)=>(Module._xmlSAX2InternalSubset=wasmExports.xmlSAX2InternalSubset)(t,e,I,B),Module._xmlSAX2IsStandalone=t=>(Module._xmlSAX2IsStandalone=wasmExports.xmlSAX2IsStandalone)(t),Module._xmlSAX2HasInternalSubset=t=>(Module._xmlSAX2HasInternalSubset=wasmExports.xmlSAX2HasInternalSubset)(t),Module._xmlSAX2HasExternalSubset=t=>(Module._xmlSAX2HasExternalSubset=wasmExports.xmlSAX2HasExternalSubset)(t),Module._xmlSAX2ResolveEntity=(t,e,I)=>(Module._xmlSAX2ResolveEntity=wasmExports.xmlSAX2ResolveEntity)(t,e,I),Module._xmlSAX2GetEntity=(t,e)=>(Module._xmlSAX2GetEntity=wasmExports.xmlSAX2GetEntity)(t,e),Module._xmlSAX2EntityDecl=(t,e,I,B,tr,rr)=>(Module._xmlSAX2EntityDecl=wasmExports.xmlSAX2EntityDecl)(t,e,I,B,tr,rr),Module._xmlSAX2NotationDecl=(t,e,I,B)=>(Module._xmlSAX2NotationDecl=wasmExports.xmlSAX2NotationDecl)(t,e,I,B),Module._xmlSAX2AttributeDecl=(t,e,I,B,tr,rr,ir)=>(Module._xmlSAX2AttributeDecl=wasmExports.xmlSAX2AttributeDecl)(t,e,I,B,tr,rr,ir),Module._xmlSAX2ElementDecl=(t,e,I,B)=>(Module._xmlSAX2ElementDecl=wasmExports.xmlSAX2ElementDecl)(t,e,I,B),Module._xmlSAX2UnparsedEntityDecl=(t,e,I,B,tr)=>(Module._xmlSAX2UnparsedEntityDecl=wasmExports.xmlSAX2UnparsedEntityDecl)(t,e,I,B,tr),Module._xmlSAX2SetDocumentLocator=(t,e)=>(Module._xmlSAX2SetDocumentLocator=wasmExports.xmlSAX2SetDocumentLocator)(t,e),Module._xmlSAX2StartDocument=t=>(Module._xmlSAX2StartDocument=wasmExports.xmlSAX2StartDocument)(t),Module._xmlSAX2EndDocument=t=>(Module._xmlSAX2EndDocument=wasmExports.xmlSAX2EndDocument)(t),Module._xmlSAX2StartElement=(t,e,I)=>(Module._xmlSAX2StartElement=wasmExports.xmlSAX2StartElement)(t,e,I),Module._xmlSAX2EndElement=(t,e)=>(Module._xmlSAX2EndElement=wasmExports.xmlSAX2EndElement)(t,e),Module._xmlSAX2Reference=(t,e)=>(Module._xmlSAX2Reference=wasmExports.xmlSAX2Reference)(t,e),Module._xmlSAX2Characters=(t,e,I)=>(Module._xmlSAX2Characters=wasmExports.xmlSAX2Characters)(t,e,I),Module._xmlSAX2ProcessingInstruction=(t,e,I)=>(Module._xmlSAX2ProcessingInstruction=wasmExports.xmlSAX2ProcessingInstruction)(t,e,I),Module._xmlSAX2Comment=(t,e)=>(Module._xmlSAX2Comment=wasmExports.xmlSAX2Comment)(t,e),Module._xmlSAX2GetParameterEntity=(t,e)=>(Module._xmlSAX2GetParameterEntity=wasmExports.xmlSAX2GetParameterEntity)(t,e),Module._xmlSAX2CDataBlock=(t,e,I)=>(Module._xmlSAX2CDataBlock=wasmExports.xmlSAX2CDataBlock)(t,e,I),Module._xmlSAX2ExternalSubset=(t,e,I,B)=>(Module._xmlSAX2ExternalSubset=wasmExports.xmlSAX2ExternalSubset)(t,e,I,B),Module._xmlSAX2GetPublicId=t=>(Module._xmlSAX2GetPublicId=wasmExports.xmlSAX2GetPublicId)(t),Module._xmlSAX2GetSystemId=t=>(Module._xmlSAX2GetSystemId=wasmExports.xmlSAX2GetSystemId)(t),Module._xmlSAX2GetLineNumber=t=>(Module._xmlSAX2GetLineNumber=wasmExports.xmlSAX2GetLineNumber)(t),Module._xmlSAX2GetColumnNumber=t=>(Module._xmlSAX2GetColumnNumber=wasmExports.xmlSAX2GetColumnNumber)(t),Module._xmlSAX2IgnorableWhitespace=(t,e,I)=>(Module._xmlSAX2IgnorableWhitespace=wasmExports.xmlSAX2IgnorableWhitespace)(t,e,I),Module._xmlHashDefaultDeallocator=(t,e)=>(Module._xmlHashDefaultDeallocator=wasmExports.xmlHashDefaultDeallocator)(t,e),Module._iconv_open=(t,e)=>(Module._iconv_open=wasmExports.iconv_open)(t,e),Module._iconv_close=t=>(Module._iconv_close=wasmExports.iconv_close)(t),Module._iconv=(t,e,I,B,tr)=>(Module._iconv=wasmExports.iconv)(t,e,I,B,tr),Module._UTF8ToHtml=(t,e,I,B)=>(Module._UTF8ToHtml=wasmExports.UTF8ToHtml)(t,e,I,B),Module._xmlReadMemory=(t,e,I,B,tr)=>(Module._xmlReadMemory=wasmExports.xmlReadMemory)(t,e,I,B,tr),Module._xmlSAX2StartElementNs=(t,e,I,B,tr,rr,ir,lr,dr)=>(Module._xmlSAX2StartElementNs=wasmExports.xmlSAX2StartElementNs)(t,e,I,B,tr,rr,ir,lr,dr),Module._xmlSAX2EndElementNs=(t,e,I,B)=>(Module._xmlSAX2EndElementNs=wasmExports.xmlSAX2EndElementNs)(t,e,I,B),Module.___cxa_atexit=(t,e,I)=>(Module.___cxa_atexit=wasmExports.__cxa_atexit)(t,e,I),Module._xmlDocGetRootElement=t=>(Module._xmlDocGetRootElement=wasmExports.xmlDocGetRootElement)(t),Module._xmlFileMatch=t=>(Module._xmlFileMatch=wasmExports.xmlFileMatch)(t),Module._xmlFileOpen=t=>(Module._xmlFileOpen=wasmExports.xmlFileOpen)(t),Module._xmlFileRead=(t,e,I)=>(Module._xmlFileRead=wasmExports.xmlFileRead)(t,e,I),Module._xmlFileClose=t=>(Module._xmlFileClose=wasmExports.xmlFileClose)(t),Module._gzread=(t,e,I)=>(Module._gzread=wasmExports.gzread)(t,e,I),Module._gzclose=t=>(Module._gzclose=wasmExports.gzclose)(t),Module._gzdirect=t=>(Module._gzdirect=wasmExports.gzdirect)(t),Module._gzdopen=(t,e)=>(Module._gzdopen=wasmExports.gzdopen)(t,e),Module._gzopen=(t,e)=>(Module._gzopen=wasmExports.gzopen)(t,e),Module._gzwrite=(t,e,I)=>(Module._gzwrite=wasmExports.gzwrite)(t,e,I),Module._xmlUCSIsCatNd=t=>(Module._xmlUCSIsCatNd=wasmExports.xmlUCSIsCatNd)(t),Module._xmlUCSIsCatP=t=>(Module._xmlUCSIsCatP=wasmExports.xmlUCSIsCatP)(t),Module._xmlUCSIsCatZ=t=>(Module._xmlUCSIsCatZ=wasmExports.xmlUCSIsCatZ)(t),Module._xmlUCSIsCatC=t=>(Module._xmlUCSIsCatC=wasmExports.xmlUCSIsCatC)(t),Module._xmlUCSIsCatL=t=>(Module._xmlUCSIsCatL=wasmExports.xmlUCSIsCatL)(t),Module._xmlUCSIsCatLu=t=>(Module._xmlUCSIsCatLu=wasmExports.xmlUCSIsCatLu)(t),Module._xmlUCSIsCatLl=t=>(Module._xmlUCSIsCatLl=wasmExports.xmlUCSIsCatLl)(t),Module._xmlUCSIsCatLt=t=>(Module._xmlUCSIsCatLt=wasmExports.xmlUCSIsCatLt)(t),Module._xmlUCSIsCatLm=t=>(Module._xmlUCSIsCatLm=wasmExports.xmlUCSIsCatLm)(t),Module._xmlUCSIsCatLo=t=>(Module._xmlUCSIsCatLo=wasmExports.xmlUCSIsCatLo)(t),Module._xmlUCSIsCatM=t=>(Module._xmlUCSIsCatM=wasmExports.xmlUCSIsCatM)(t),Module._xmlUCSIsCatMn=t=>(Module._xmlUCSIsCatMn=wasmExports.xmlUCSIsCatMn)(t),Module._xmlUCSIsCatMc=t=>(Module._xmlUCSIsCatMc=wasmExports.xmlUCSIsCatMc)(t),Module._xmlUCSIsCatMe=t=>(Module._xmlUCSIsCatMe=wasmExports.xmlUCSIsCatMe)(t),Module._xmlUCSIsCatN=t=>(Module._xmlUCSIsCatN=wasmExports.xmlUCSIsCatN)(t),Module._xmlUCSIsCatNl=t=>(Module._xmlUCSIsCatNl=wasmExports.xmlUCSIsCatNl)(t),Module._xmlUCSIsCatNo=t=>(Module._xmlUCSIsCatNo=wasmExports.xmlUCSIsCatNo)(t),Module._xmlUCSIsCatPc=t=>(Module._xmlUCSIsCatPc=wasmExports.xmlUCSIsCatPc)(t),Module._xmlUCSIsCatPd=t=>(Module._xmlUCSIsCatPd=wasmExports.xmlUCSIsCatPd)(t),Module._xmlUCSIsCatPs=t=>(Module._xmlUCSIsCatPs=wasmExports.xmlUCSIsCatPs)(t),Module._xmlUCSIsCatPe=t=>(Module._xmlUCSIsCatPe=wasmExports.xmlUCSIsCatPe)(t),Module._xmlUCSIsCatPi=t=>(Module._xmlUCSIsCatPi=wasmExports.xmlUCSIsCatPi)(t),Module._xmlUCSIsCatPf=t=>(Module._xmlUCSIsCatPf=wasmExports.xmlUCSIsCatPf)(t),Module._xmlUCSIsCatPo=t=>(Module._xmlUCSIsCatPo=wasmExports.xmlUCSIsCatPo)(t),Module._xmlUCSIsCatZs=t=>(Module._xmlUCSIsCatZs=wasmExports.xmlUCSIsCatZs)(t),Module._xmlUCSIsCatZl=t=>(Module._xmlUCSIsCatZl=wasmExports.xmlUCSIsCatZl)(t),Module._xmlUCSIsCatZp=t=>(Module._xmlUCSIsCatZp=wasmExports.xmlUCSIsCatZp)(t),Module._xmlUCSIsCatS=t=>(Module._xmlUCSIsCatS=wasmExports.xmlUCSIsCatS)(t),Module._xmlUCSIsCatSm=t=>(Module._xmlUCSIsCatSm=wasmExports.xmlUCSIsCatSm)(t),Module._xmlUCSIsCatSc=t=>(Module._xmlUCSIsCatSc=wasmExports.xmlUCSIsCatSc)(t),Module._xmlUCSIsCatSk=t=>(Module._xmlUCSIsCatSk=wasmExports.xmlUCSIsCatSk)(t),Module._xmlUCSIsCatSo=t=>(Module._xmlUCSIsCatSo=wasmExports.xmlUCSIsCatSo)(t),Module._xmlUCSIsCatCc=t=>(Module._xmlUCSIsCatCc=wasmExports.xmlUCSIsCatCc)(t),Module._xmlUCSIsCatCf=t=>(Module._xmlUCSIsCatCf=wasmExports.xmlUCSIsCatCf)(t),Module._xmlUCSIsCatCo=t=>(Module._xmlUCSIsCatCo=wasmExports.xmlUCSIsCatCo)(t),Module._xmlUCSIsAegeanNumbers=t=>(Module._xmlUCSIsAegeanNumbers=wasmExports.xmlUCSIsAegeanNumbers)(t),Module._xmlUCSIsAlphabeticPresentationForms=t=>(Module._xmlUCSIsAlphabeticPresentationForms=wasmExports.xmlUCSIsAlphabeticPresentationForms)(t),Module._xmlUCSIsArabic=t=>(Module._xmlUCSIsArabic=wasmExports.xmlUCSIsArabic)(t),Module._xmlUCSIsArabicPresentationFormsA=t=>(Module._xmlUCSIsArabicPresentationFormsA=wasmExports.xmlUCSIsArabicPresentationFormsA)(t),Module._xmlUCSIsArabicPresentationFormsB=t=>(Module._xmlUCSIsArabicPresentationFormsB=wasmExports.xmlUCSIsArabicPresentationFormsB)(t),Module._xmlUCSIsArmenian=t=>(Module._xmlUCSIsArmenian=wasmExports.xmlUCSIsArmenian)(t),Module._xmlUCSIsArrows=t=>(Module._xmlUCSIsArrows=wasmExports.xmlUCSIsArrows)(t),Module._xmlUCSIsBasicLatin=t=>(Module._xmlUCSIsBasicLatin=wasmExports.xmlUCSIsBasicLatin)(t),Module._xmlUCSIsBengali=t=>(Module._xmlUCSIsBengali=wasmExports.xmlUCSIsBengali)(t),Module._xmlUCSIsBlockElements=t=>(Module._xmlUCSIsBlockElements=wasmExports.xmlUCSIsBlockElements)(t),Module._xmlUCSIsBopomofo=t=>(Module._xmlUCSIsBopomofo=wasmExports.xmlUCSIsBopomofo)(t),Module._xmlUCSIsBopomofoExtended=t=>(Module._xmlUCSIsBopomofoExtended=wasmExports.xmlUCSIsBopomofoExtended)(t),Module._xmlUCSIsBoxDrawing=t=>(Module._xmlUCSIsBoxDrawing=wasmExports.xmlUCSIsBoxDrawing)(t),Module._xmlUCSIsBraillePatterns=t=>(Module._xmlUCSIsBraillePatterns=wasmExports.xmlUCSIsBraillePatterns)(t),Module._xmlUCSIsBuhid=t=>(Module._xmlUCSIsBuhid=wasmExports.xmlUCSIsBuhid)(t),Module._xmlUCSIsByzantineMusicalSymbols=t=>(Module._xmlUCSIsByzantineMusicalSymbols=wasmExports.xmlUCSIsByzantineMusicalSymbols)(t),Module._xmlUCSIsCJKCompatibility=t=>(Module._xmlUCSIsCJKCompatibility=wasmExports.xmlUCSIsCJKCompatibility)(t),Module._xmlUCSIsCJKCompatibilityForms=t=>(Module._xmlUCSIsCJKCompatibilityForms=wasmExports.xmlUCSIsCJKCompatibilityForms)(t),Module._xmlUCSIsCJKCompatibilityIdeographs=t=>(Module._xmlUCSIsCJKCompatibilityIdeographs=wasmExports.xmlUCSIsCJKCompatibilityIdeographs)(t),Module._xmlUCSIsCJKCompatibilityIdeographsSupplement=t=>(Module._xmlUCSIsCJKCompatibilityIdeographsSupplement=wasmExports.xmlUCSIsCJKCompatibilityIdeographsSupplement)(t),Module._xmlUCSIsCJKRadicalsSupplement=t=>(Module._xmlUCSIsCJKRadicalsSupplement=wasmExports.xmlUCSIsCJKRadicalsSupplement)(t),Module._xmlUCSIsCJKSymbolsandPunctuation=t=>(Module._xmlUCSIsCJKSymbolsandPunctuation=wasmExports.xmlUCSIsCJKSymbolsandPunctuation)(t),Module._xmlUCSIsCJKUnifiedIdeographs=t=>(Module._xmlUCSIsCJKUnifiedIdeographs=wasmExports.xmlUCSIsCJKUnifiedIdeographs)(t),Module._xmlUCSIsCJKUnifiedIdeographsExtensionA=t=>(Module._xmlUCSIsCJKUnifiedIdeographsExtensionA=wasmExports.xmlUCSIsCJKUnifiedIdeographsExtensionA)(t),Module._xmlUCSIsCJKUnifiedIdeographsExtensionB=t=>(Module._xmlUCSIsCJKUnifiedIdeographsExtensionB=wasmExports.xmlUCSIsCJKUnifiedIdeographsExtensionB)(t),Module._xmlUCSIsCherokee=t=>(Module._xmlUCSIsCherokee=wasmExports.xmlUCSIsCherokee)(t),Module._xmlUCSIsCombiningDiacriticalMarks=t=>(Module._xmlUCSIsCombiningDiacriticalMarks=wasmExports.xmlUCSIsCombiningDiacriticalMarks)(t),Module._xmlUCSIsCombiningDiacriticalMarksforSymbols=t=>(Module._xmlUCSIsCombiningDiacriticalMarksforSymbols=wasmExports.xmlUCSIsCombiningDiacriticalMarksforSymbols)(t),Module._xmlUCSIsCombiningHalfMarks=t=>(Module._xmlUCSIsCombiningHalfMarks=wasmExports.xmlUCSIsCombiningHalfMarks)(t),Module._xmlUCSIsCombiningMarksforSymbols=t=>(Module._xmlUCSIsCombiningMarksforSymbols=wasmExports.xmlUCSIsCombiningMarksforSymbols)(t),Module._xmlUCSIsControlPictures=t=>(Module._xmlUCSIsControlPictures=wasmExports.xmlUCSIsControlPictures)(t),Module._xmlUCSIsCurrencySymbols=t=>(Module._xmlUCSIsCurrencySymbols=wasmExports.xmlUCSIsCurrencySymbols)(t),Module._xmlUCSIsCypriotSyllabary=t=>(Module._xmlUCSIsCypriotSyllabary=wasmExports.xmlUCSIsCypriotSyllabary)(t),Module._xmlUCSIsCyrillic=t=>(Module._xmlUCSIsCyrillic=wasmExports.xmlUCSIsCyrillic)(t),Module._xmlUCSIsCyrillicSupplement=t=>(Module._xmlUCSIsCyrillicSupplement=wasmExports.xmlUCSIsCyrillicSupplement)(t),Module._xmlUCSIsDeseret=t=>(Module._xmlUCSIsDeseret=wasmExports.xmlUCSIsDeseret)(t),Module._xmlUCSIsDevanagari=t=>(Module._xmlUCSIsDevanagari=wasmExports.xmlUCSIsDevanagari)(t),Module._xmlUCSIsDingbats=t=>(Module._xmlUCSIsDingbats=wasmExports.xmlUCSIsDingbats)(t),Module._xmlUCSIsEnclosedAlphanumerics=t=>(Module._xmlUCSIsEnclosedAlphanumerics=wasmExports.xmlUCSIsEnclosedAlphanumerics)(t),Module._xmlUCSIsEnclosedCJKLettersandMonths=t=>(Module._xmlUCSIsEnclosedCJKLettersandMonths=wasmExports.xmlUCSIsEnclosedCJKLettersandMonths)(t),Module._xmlUCSIsEthiopic=t=>(Module._xmlUCSIsEthiopic=wasmExports.xmlUCSIsEthiopic)(t),Module._xmlUCSIsGeneralPunctuation=t=>(Module._xmlUCSIsGeneralPunctuation=wasmExports.xmlUCSIsGeneralPunctuation)(t),Module._xmlUCSIsGeometricShapes=t=>(Module._xmlUCSIsGeometricShapes=wasmExports.xmlUCSIsGeometricShapes)(t),Module._xmlUCSIsGeorgian=t=>(Module._xmlUCSIsGeorgian=wasmExports.xmlUCSIsGeorgian)(t),Module._xmlUCSIsGothic=t=>(Module._xmlUCSIsGothic=wasmExports.xmlUCSIsGothic)(t),Module._xmlUCSIsGreek=t=>(Module._xmlUCSIsGreek=wasmExports.xmlUCSIsGreek)(t),Module._xmlUCSIsGreekExtended=t=>(Module._xmlUCSIsGreekExtended=wasmExports.xmlUCSIsGreekExtended)(t),Module._xmlUCSIsGreekandCoptic=t=>(Module._xmlUCSIsGreekandCoptic=wasmExports.xmlUCSIsGreekandCoptic)(t),Module._xmlUCSIsGujarati=t=>(Module._xmlUCSIsGujarati=wasmExports.xmlUCSIsGujarati)(t),Module._xmlUCSIsGurmukhi=t=>(Module._xmlUCSIsGurmukhi=wasmExports.xmlUCSIsGurmukhi)(t),Module._xmlUCSIsHalfwidthandFullwidthForms=t=>(Module._xmlUCSIsHalfwidthandFullwidthForms=wasmExports.xmlUCSIsHalfwidthandFullwidthForms)(t),Module._xmlUCSIsHangulCompatibilityJamo=t=>(Module._xmlUCSIsHangulCompatibilityJamo=wasmExports.xmlUCSIsHangulCompatibilityJamo)(t),Module._xmlUCSIsHangulJamo=t=>(Module._xmlUCSIsHangulJamo=wasmExports.xmlUCSIsHangulJamo)(t),Module._xmlUCSIsHangulSyllables=t=>(Module._xmlUCSIsHangulSyllables=wasmExports.xmlUCSIsHangulSyllables)(t),Module._xmlUCSIsHanunoo=t=>(Module._xmlUCSIsHanunoo=wasmExports.xmlUCSIsHanunoo)(t),Module._xmlUCSIsHebrew=t=>(Module._xmlUCSIsHebrew=wasmExports.xmlUCSIsHebrew)(t),Module._xmlUCSIsHighPrivateUseSurrogates=t=>(Module._xmlUCSIsHighPrivateUseSurrogates=wasmExports.xmlUCSIsHighPrivateUseSurrogates)(t),Module._xmlUCSIsHighSurrogates=t=>(Module._xmlUCSIsHighSurrogates=wasmExports.xmlUCSIsHighSurrogates)(t),Module._xmlUCSIsHiragana=t=>(Module._xmlUCSIsHiragana=wasmExports.xmlUCSIsHiragana)(t),Module._xmlUCSIsIPAExtensions=t=>(Module._xmlUCSIsIPAExtensions=wasmExports.xmlUCSIsIPAExtensions)(t),Module._xmlUCSIsIdeographicDescriptionCharacters=t=>(Module._xmlUCSIsIdeographicDescriptionCharacters=wasmExports.xmlUCSIsIdeographicDescriptionCharacters)(t),Module._xmlUCSIsKanbun=t=>(Module._xmlUCSIsKanbun=wasmExports.xmlUCSIsKanbun)(t),Module._xmlUCSIsKangxiRadicals=t=>(Module._xmlUCSIsKangxiRadicals=wasmExports.xmlUCSIsKangxiRadicals)(t),Module._xmlUCSIsKannada=t=>(Module._xmlUCSIsKannada=wasmExports.xmlUCSIsKannada)(t),Module._xmlUCSIsKatakana=t=>(Module._xmlUCSIsKatakana=wasmExports.xmlUCSIsKatakana)(t),Module._xmlUCSIsKatakanaPhoneticExtensions=t=>(Module._xmlUCSIsKatakanaPhoneticExtensions=wasmExports.xmlUCSIsKatakanaPhoneticExtensions)(t),Module._xmlUCSIsKhmer=t=>(Module._xmlUCSIsKhmer=wasmExports.xmlUCSIsKhmer)(t),Module._xmlUCSIsKhmerSymbols=t=>(Module._xmlUCSIsKhmerSymbols=wasmExports.xmlUCSIsKhmerSymbols)(t),Module._xmlUCSIsLao=t=>(Module._xmlUCSIsLao=wasmExports.xmlUCSIsLao)(t),Module._xmlUCSIsLatin1Supplement=t=>(Module._xmlUCSIsLatin1Supplement=wasmExports.xmlUCSIsLatin1Supplement)(t),Module._xmlUCSIsLatinExtendedA=t=>(Module._xmlUCSIsLatinExtendedA=wasmExports.xmlUCSIsLatinExtendedA)(t),Module._xmlUCSIsLatinExtendedB=t=>(Module._xmlUCSIsLatinExtendedB=wasmExports.xmlUCSIsLatinExtendedB)(t),Module._xmlUCSIsLatinExtendedAdditional=t=>(Module._xmlUCSIsLatinExtendedAdditional=wasmExports.xmlUCSIsLatinExtendedAdditional)(t),Module._xmlUCSIsLetterlikeSymbols=t=>(Module._xmlUCSIsLetterlikeSymbols=wasmExports.xmlUCSIsLetterlikeSymbols)(t),Module._xmlUCSIsLimbu=t=>(Module._xmlUCSIsLimbu=wasmExports.xmlUCSIsLimbu)(t),Module._xmlUCSIsLinearBIdeograms=t=>(Module._xmlUCSIsLinearBIdeograms=wasmExports.xmlUCSIsLinearBIdeograms)(t),Module._xmlUCSIsLinearBSyllabary=t=>(Module._xmlUCSIsLinearBSyllabary=wasmExports.xmlUCSIsLinearBSyllabary)(t),Module._xmlUCSIsLowSurrogates=t=>(Module._xmlUCSIsLowSurrogates=wasmExports.xmlUCSIsLowSurrogates)(t),Module._xmlUCSIsMalayalam=t=>(Module._xmlUCSIsMalayalam=wasmExports.xmlUCSIsMalayalam)(t),Module._xmlUCSIsMathematicalAlphanumericSymbols=t=>(Module._xmlUCSIsMathematicalAlphanumericSymbols=wasmExports.xmlUCSIsMathematicalAlphanumericSymbols)(t),Module._xmlUCSIsMathematicalOperators=t=>(Module._xmlUCSIsMathematicalOperators=wasmExports.xmlUCSIsMathematicalOperators)(t),Module._xmlUCSIsMiscellaneousMathematicalSymbolsA=t=>(Module._xmlUCSIsMiscellaneousMathematicalSymbolsA=wasmExports.xmlUCSIsMiscellaneousMathematicalSymbolsA)(t),Module._xmlUCSIsMiscellaneousMathematicalSymbolsB=t=>(Module._xmlUCSIsMiscellaneousMathematicalSymbolsB=wasmExports.xmlUCSIsMiscellaneousMathematicalSymbolsB)(t),Module._xmlUCSIsMiscellaneousSymbols=t=>(Module._xmlUCSIsMiscellaneousSymbols=wasmExports.xmlUCSIsMiscellaneousSymbols)(t),Module._xmlUCSIsMiscellaneousSymbolsandArrows=t=>(Module._xmlUCSIsMiscellaneousSymbolsandArrows=wasmExports.xmlUCSIsMiscellaneousSymbolsandArrows)(t),Module._xmlUCSIsMiscellaneousTechnical=t=>(Module._xmlUCSIsMiscellaneousTechnical=wasmExports.xmlUCSIsMiscellaneousTechnical)(t),Module._xmlUCSIsMongolian=t=>(Module._xmlUCSIsMongolian=wasmExports.xmlUCSIsMongolian)(t),Module._xmlUCSIsMusicalSymbols=t=>(Module._xmlUCSIsMusicalSymbols=wasmExports.xmlUCSIsMusicalSymbols)(t),Module._xmlUCSIsMyanmar=t=>(Module._xmlUCSIsMyanmar=wasmExports.xmlUCSIsMyanmar)(t),Module._xmlUCSIsNumberForms=t=>(Module._xmlUCSIsNumberForms=wasmExports.xmlUCSIsNumberForms)(t),Module._xmlUCSIsOgham=t=>(Module._xmlUCSIsOgham=wasmExports.xmlUCSIsOgham)(t),Module._xmlUCSIsOldItalic=t=>(Module._xmlUCSIsOldItalic=wasmExports.xmlUCSIsOldItalic)(t),Module._xmlUCSIsOpticalCharacterRecognition=t=>(Module._xmlUCSIsOpticalCharacterRecognition=wasmExports.xmlUCSIsOpticalCharacterRecognition)(t),Module._xmlUCSIsOriya=t=>(Module._xmlUCSIsOriya=wasmExports.xmlUCSIsOriya)(t),Module._xmlUCSIsOsmanya=t=>(Module._xmlUCSIsOsmanya=wasmExports.xmlUCSIsOsmanya)(t),Module._xmlUCSIsPhoneticExtensions=t=>(Module._xmlUCSIsPhoneticExtensions=wasmExports.xmlUCSIsPhoneticExtensions)(t),Module._xmlUCSIsPrivateUse=t=>(Module._xmlUCSIsPrivateUse=wasmExports.xmlUCSIsPrivateUse)(t),Module._xmlUCSIsPrivateUseArea=t=>(Module._xmlUCSIsPrivateUseArea=wasmExports.xmlUCSIsPrivateUseArea)(t),Module._xmlUCSIsRunic=t=>(Module._xmlUCSIsRunic=wasmExports.xmlUCSIsRunic)(t),Module._xmlUCSIsShavian=t=>(Module._xmlUCSIsShavian=wasmExports.xmlUCSIsShavian)(t),Module._xmlUCSIsSinhala=t=>(Module._xmlUCSIsSinhala=wasmExports.xmlUCSIsSinhala)(t),Module._xmlUCSIsSmallFormVariants=t=>(Module._xmlUCSIsSmallFormVariants=wasmExports.xmlUCSIsSmallFormVariants)(t),Module._xmlUCSIsSpacingModifierLetters=t=>(Module._xmlUCSIsSpacingModifierLetters=wasmExports.xmlUCSIsSpacingModifierLetters)(t),Module._xmlUCSIsSpecials=t=>(Module._xmlUCSIsSpecials=wasmExports.xmlUCSIsSpecials)(t),Module._xmlUCSIsSuperscriptsandSubscripts=t=>(Module._xmlUCSIsSuperscriptsandSubscripts=wasmExports.xmlUCSIsSuperscriptsandSubscripts)(t),Module._xmlUCSIsSupplementalArrowsA=t=>(Module._xmlUCSIsSupplementalArrowsA=wasmExports.xmlUCSIsSupplementalArrowsA)(t),Module._xmlUCSIsSupplementalArrowsB=t=>(Module._xmlUCSIsSupplementalArrowsB=wasmExports.xmlUCSIsSupplementalArrowsB)(t),Module._xmlUCSIsSupplementalMathematicalOperators=t=>(Module._xmlUCSIsSupplementalMathematicalOperators=wasmExports.xmlUCSIsSupplementalMathematicalOperators)(t),Module._xmlUCSIsSupplementaryPrivateUseAreaA=t=>(Module._xmlUCSIsSupplementaryPrivateUseAreaA=wasmExports.xmlUCSIsSupplementaryPrivateUseAreaA)(t),Module._xmlUCSIsSupplementaryPrivateUseAreaB=t=>(Module._xmlUCSIsSupplementaryPrivateUseAreaB=wasmExports.xmlUCSIsSupplementaryPrivateUseAreaB)(t),Module._xmlUCSIsSyriac=t=>(Module._xmlUCSIsSyriac=wasmExports.xmlUCSIsSyriac)(t),Module._xmlUCSIsTagalog=t=>(Module._xmlUCSIsTagalog=wasmExports.xmlUCSIsTagalog)(t),Module._xmlUCSIsTagbanwa=t=>(Module._xmlUCSIsTagbanwa=wasmExports.xmlUCSIsTagbanwa)(t),Module._xmlUCSIsTags=t=>(Module._xmlUCSIsTags=wasmExports.xmlUCSIsTags)(t),Module._xmlUCSIsTaiLe=t=>(Module._xmlUCSIsTaiLe=wasmExports.xmlUCSIsTaiLe)(t),Module._xmlUCSIsTaiXuanJingSymbols=t=>(Module._xmlUCSIsTaiXuanJingSymbols=wasmExports.xmlUCSIsTaiXuanJingSymbols)(t),Module._xmlUCSIsTamil=t=>(Module._xmlUCSIsTamil=wasmExports.xmlUCSIsTamil)(t),Module._xmlUCSIsTelugu=t=>(Module._xmlUCSIsTelugu=wasmExports.xmlUCSIsTelugu)(t),Module._xmlUCSIsThaana=t=>(Module._xmlUCSIsThaana=wasmExports.xmlUCSIsThaana)(t),Module._xmlUCSIsThai=t=>(Module._xmlUCSIsThai=wasmExports.xmlUCSIsThai)(t),Module._xmlUCSIsTibetan=t=>(Module._xmlUCSIsTibetan=wasmExports.xmlUCSIsTibetan)(t),Module._xmlUCSIsUgaritic=t=>(Module._xmlUCSIsUgaritic=wasmExports.xmlUCSIsUgaritic)(t),Module._xmlUCSIsUnifiedCanadianAboriginalSyllabics=t=>(Module._xmlUCSIsUnifiedCanadianAboriginalSyllabics=wasmExports.xmlUCSIsUnifiedCanadianAboriginalSyllabics)(t),Module._xmlUCSIsVariationSelectors=t=>(Module._xmlUCSIsVariationSelectors=wasmExports.xmlUCSIsVariationSelectors)(t),Module._xmlUCSIsVariationSelectorsSupplement=t=>(Module._xmlUCSIsVariationSelectorsSupplement=wasmExports.xmlUCSIsVariationSelectorsSupplement)(t),Module._xmlUCSIsYiRadicals=t=>(Module._xmlUCSIsYiRadicals=wasmExports.xmlUCSIsYiRadicals)(t),Module._xmlUCSIsYiSyllables=t=>(Module._xmlUCSIsYiSyllables=wasmExports.xmlUCSIsYiSyllables)(t),Module._xmlUCSIsYijingHexagramSymbols=t=>(Module._xmlUCSIsYijingHexagramSymbols=wasmExports.xmlUCSIsYijingHexagramSymbols)(t),Module._xmlUCSIsCatCs=t=>(Module._xmlUCSIsCatCs=wasmExports.xmlUCSIsCatCs)(t),Module.___small_fprintf=(t,e,I)=>(Module.___small_fprintf=wasmExports.__small_fprintf)(t,e,I),Module._xmlXPathBooleanFunction=(t,e)=>(Module._xmlXPathBooleanFunction=wasmExports.xmlXPathBooleanFunction)(t,e),Module._xmlXPathCeilingFunction=(t,e)=>(Module._xmlXPathCeilingFunction=wasmExports.xmlXPathCeilingFunction)(t,e),Module._xmlXPathCountFunction=(t,e)=>(Module._xmlXPathCountFunction=wasmExports.xmlXPathCountFunction)(t,e),Module._xmlXPathConcatFunction=(t,e)=>(Module._xmlXPathConcatFunction=wasmExports.xmlXPathConcatFunction)(t,e),Module._xmlXPathContainsFunction=(t,e)=>(Module._xmlXPathContainsFunction=wasmExports.xmlXPathContainsFunction)(t,e),Module._xmlXPathIdFunction=(t,e)=>(Module._xmlXPathIdFunction=wasmExports.xmlXPathIdFunction)(t,e),Module._xmlXPathFalseFunction=(t,e)=>(Module._xmlXPathFalseFunction=wasmExports.xmlXPathFalseFunction)(t,e),Module._xmlXPathFloorFunction=(t,e)=>(Module._xmlXPathFloorFunction=wasmExports.xmlXPathFloorFunction)(t,e),Module._xmlXPathLastFunction=(t,e)=>(Module._xmlXPathLastFunction=wasmExports.xmlXPathLastFunction)(t,e),Module._xmlXPathLangFunction=(t,e)=>(Module._xmlXPathLangFunction=wasmExports.xmlXPathLangFunction)(t,e),Module._xmlXPathLocalNameFunction=(t,e)=>(Module._xmlXPathLocalNameFunction=wasmExports.xmlXPathLocalNameFunction)(t,e),Module._xmlXPathNotFunction=(t,e)=>(Module._xmlXPathNotFunction=wasmExports.xmlXPathNotFunction)(t,e),Module._xmlXPathNamespaceURIFunction=(t,e)=>(Module._xmlXPathNamespaceURIFunction=wasmExports.xmlXPathNamespaceURIFunction)(t,e),Module._xmlXPathNormalizeFunction=(t,e)=>(Module._xmlXPathNormalizeFunction=wasmExports.xmlXPathNormalizeFunction)(t,e),Module._xmlXPathNumberFunction=(t,e)=>(Module._xmlXPathNumberFunction=wasmExports.xmlXPathNumberFunction)(t,e),Module._xmlXPathPositionFunction=(t,e)=>(Module._xmlXPathPositionFunction=wasmExports.xmlXPathPositionFunction)(t,e),Module._xmlXPathRoundFunction=(t,e)=>(Module._xmlXPathRoundFunction=wasmExports.xmlXPathRoundFunction)(t,e),Module._xmlXPathStringFunction=(t,e)=>(Module._xmlXPathStringFunction=wasmExports.xmlXPathStringFunction)(t,e),Module._xmlXPathStringLengthFunction=(t,e)=>(Module._xmlXPathStringLengthFunction=wasmExports.xmlXPathStringLengthFunction)(t,e),Module._xmlXPathStartsWithFunction=(t,e)=>(Module._xmlXPathStartsWithFunction=wasmExports.xmlXPathStartsWithFunction)(t,e),Module._xmlXPathSubstringFunction=(t,e)=>(Module._xmlXPathSubstringFunction=wasmExports.xmlXPathSubstringFunction)(t,e),Module._xmlXPathSubstringBeforeFunction=(t,e)=>(Module._xmlXPathSubstringBeforeFunction=wasmExports.xmlXPathSubstringBeforeFunction)(t,e),Module._xmlXPathSubstringAfterFunction=(t,e)=>(Module._xmlXPathSubstringAfterFunction=wasmExports.xmlXPathSubstringAfterFunction)(t,e),Module._xmlXPathSumFunction=(t,e)=>(Module._xmlXPathSumFunction=wasmExports.xmlXPathSumFunction)(t,e),Module._xmlXPathTrueFunction=(t,e)=>(Module._xmlXPathTrueFunction=wasmExports.xmlXPathTrueFunction)(t,e),Module._xmlXPathTranslateFunction=(t,e)=>(Module._xmlXPathTranslateFunction=wasmExports.xmlXPathTranslateFunction)(t,e),Module._xmlXPathNextSelf=(t,e)=>(Module._xmlXPathNextSelf=wasmExports.xmlXPathNextSelf)(t,e),Module._xmlXPathNextChild=(t,e)=>(Module._xmlXPathNextChild=wasmExports.xmlXPathNextChild)(t,e),Module._xmlXPathNextDescendant=(t,e)=>(Module._xmlXPathNextDescendant=wasmExports.xmlXPathNextDescendant)(t,e),Module._xmlXPathNextDescendantOrSelf=(t,e)=>(Module._xmlXPathNextDescendantOrSelf=wasmExports.xmlXPathNextDescendantOrSelf)(t,e),Module._xmlXPathNextParent=(t,e)=>(Module._xmlXPathNextParent=wasmExports.xmlXPathNextParent)(t,e),Module._xmlXPathNextAncestor=(t,e)=>(Module._xmlXPathNextAncestor=wasmExports.xmlXPathNextAncestor)(t,e),Module._xmlXPathNextAncestorOrSelf=(t,e)=>(Module._xmlXPathNextAncestorOrSelf=wasmExports.xmlXPathNextAncestorOrSelf)(t,e),Module._xmlXPathNextFollowingSibling=(t,e)=>(Module._xmlXPathNextFollowingSibling=wasmExports.xmlXPathNextFollowingSibling)(t,e),Module._xmlXPathNextPrecedingSibling=(t,e)=>(Module._xmlXPathNextPrecedingSibling=wasmExports.xmlXPathNextPrecedingSibling)(t,e),Module._xmlXPathNextFollowing=(t,e)=>(Module._xmlXPathNextFollowing=wasmExports.xmlXPathNextFollowing)(t,e),Module._xmlXPathNextNamespace=(t,e)=>(Module._xmlXPathNextNamespace=wasmExports.xmlXPathNextNamespace)(t,e),Module._xmlXPathNextAttribute=(t,e)=>(Module._xmlXPathNextAttribute=wasmExports.xmlXPathNextAttribute)(t,e),Module._zcalloc=(t,e,I)=>(Module._zcalloc=wasmExports.zcalloc)(t,e,I),Module._zcfree=(t,e)=>(Module._zcfree=wasmExports.zcfree)(t,e),Module._strerror=t=>(Module._strerror=wasmExports.strerror)(t);var ___dl_seterr=(t,e)=>(___dl_seterr=wasmExports.__dl_seterr)(t,e);Module._putc=(t,e)=>(Module._putc=wasmExports.putc)(t,e),Module._gmtime=t=>(Module._gmtime=wasmExports.gmtime)(t);var _htonl=t=>(_htonl=wasmExports.htonl)(t),_htons=t=>(_htons=wasmExports.htons)(t);Module._ioctl=(t,e,I)=>(Module._ioctl=wasmExports.ioctl)(t,e,I);var _emscripten_builtin_memalign=(t,e)=>(_emscripten_builtin_memalign=wasmExports.emscripten_builtin_memalign)(t,e),_ntohs=t=>(_ntohs=wasmExports.ntohs)(t);Module._srand=t=>(Module._srand=wasmExports.srand)(t),Module._rand=()=>(Module._rand=wasmExports.rand)();var __emscripten_timeout=(t,e)=>(__emscripten_timeout=wasmExports._emscripten_timeout)(t,e);Module.___floatsitf=(t,e)=>(Module.___floatsitf=wasmExports.__floatsitf)(t,e),Module.___multf3=(t,e,I,B,tr)=>(Module.___multf3=wasmExports.__multf3)(t,e,I,B,tr),Module.___extenddftf2=(t,e)=>(Module.___extenddftf2=wasmExports.__extenddftf2)(t,e),Module.___getf2=(t,e,I,B)=>(Module.___getf2=wasmExports.__getf2)(t,e,I,B),Module.___subtf3=(t,e,I,B,tr)=>(Module.___subtf3=wasmExports.__subtf3)(t,e,I,B,tr),Module.___letf2=(t,e,I,B)=>(Module.___letf2=wasmExports.__letf2)(t,e,I,B),Module.___lttf2=(t,e,I,B)=>(Module.___lttf2=wasmExports.__lttf2)(t,e,I,B);var _setThrew=(t,e)=>(_setThrew=wasmExports.setThrew)(t,e),__emscripten_tempret_set=t=>(__emscripten_tempret_set=wasmExports._emscripten_tempret_set)(t),__emscripten_tempret_get=()=>(__emscripten_tempret_get=wasmExports._emscripten_tempret_get)();Module.___fixtfsi=(t,e)=>(Module.___fixtfsi=wasmExports.__fixtfsi)(t,e);var __emscripten_stack_restore=t=>(__emscripten_stack_restore=wasmExports._emscripten_stack_restore)(t),__emscripten_stack_alloc=t=>(__emscripten_stack_alloc=wasmExports._emscripten_stack_alloc)(t),_emscripten_stack_get_current=()=>(_emscripten_stack_get_current=wasmExports.emscripten_stack_get_current)();Module._ScanKeywords=18770052,Module._stderr=18792480,Module._stdout=18792784,Module._TopMemoryContext=18830716,Module._MainLWLockArray=18800668,Module._MyProc=18802328,Module._MyProcPid=18824228,Module._MyLatch=18824260,Module._CurrentMemoryContext=18830712,Module._InterruptPending=18824092,Module._pg_global_prng_state=18936304,Module._CurrentResourceOwner=18830692,Module._InterruptHoldoffCount=18824132,Module._IsUnderPostmaster=18824165,Module._wal_level=18758340,Module._MyDatabaseId=18824148,Module._error_context_stack=18816816,Module._PG_exception_stack=18816820,Module.___THREW__=18950052,Module.___threwValue=18950056,Module._ShmemVariableCache=18849760,Module._shmem_startup_hook=18794508,Module._debug_query_string=18848300,Module._CritSectionCount=18824140,Module._old_snapshot_threshold=18823756,Module._TopTransactionResourceOwner=18830700,Module._LocalBufferBlockPointers=18800556,Module._BufferBlocks=18795304,Module._pgBufferUsage=18813728,Module._GUC_check_errdetail_string=18814680,Module._NBuffers=18690456,Module._BufferDescriptors=18795300,Module._ParallelWorkerNumber=18767008,Module._stdin=18792632,Module._ScanKeywordTokens=17487664,Module._post_parse_analyze_hook=18802584,Module._progname=18848060,Module._DataDir=18824144,Module._MyStartTime=18824232,Module._MyProcPort=18824248,Module._Log_directory=18803120,Module._Log_filename=18803124,Module._ConfigReloadPending=18803272,Module._ShutdownRequestPending=18803276,Module._process_shared_preload_libraries_in_progress=18824080,Module._wal_segment_size=18758360,Module._application_name=18815988,Module._XactIsoLevel=18758700,Module._RmgrTable=18758816,Module._CacheMemoryContext=18830728,Module._TopTransactionContext=18830736,Module._TTSOpsVirtual=18638668,Module._WalReceiverFunctions=18803712,Module._TTSOpsMinimalTuple=18638764,Module._cluster_name=18640444,Module._work_mem=18690432,Module._ClientAuthentication_hook=18804032,Module._cma_rsize=18848108,Module._SOCKET_DATA=18854312,Module._SOCKET_FILE=18854308,Module._TTSOpsHeapTuple=18638716,Module._SnapshotAnyData=18690240,Module._ExecutorStart_hook=18813600,Module._ExecutorRun_hook=18813604,Module._ExecutorFinish_hook=18813608,Module._ExecutorEnd_hook=18813612,Module._SPI_processed=18813624,Module._SPI_tuptable=18813632,Module._SPI_result=18813636,Module._pgWalUsage=18813840,Module._cpu_operator_cost=18638912,Module._planner_hook=18813876,Module._maintenance_work_mem=18690448,Module._max_parallel_maintenance_workers=18690452,Module._cpu_tuple_cost=18638896,Module._seq_page_cost=18638880,Module._check_function_bodies=18640389,Module._quote_all_identifiers=18848065,Module._extra_float_digits=18692128,Module._IntervalStyle=18824172,Module._pg_crc32_table=18115504,Module._oldSnapshotControl=18823760,Module._shmem_request_hook=18824084,Module._DateStyle=18690420,Module._pg_number_of_ones=18433360,Module._xmlStructuredError=18936668,Module._xmlStructuredErrorContext=18936676,Module._xmlGenericErrorContext=18936672,Module._xmlGenericError=18774356,Module._xmlIsBaseCharGroup=18774120,Module._xmlIsDigitGroup=18774152,Module._xmlIsCombiningGroup=18774136,Module._xmlIsExtenderGroup=18774168,Module._xmlFree=18774320,Module._ProcessUtility_hook=18848012,Module._single_mode_feed=18848076,Module._cma_wsize=18848116,Module._check_password_hook=18850784,Module._IDB_STAGE=18854320,Module._IDB_PIPE_FP=18854316,Module._pg_scram_mech=18774064,Module._pg_g_threadlock=18772168,Module._pgresStatus=18773856,Module._xmlIsPubidChar_tab=18433648,Module._xmlGetWarningsDefaultValue=18774348,Module._xmlMalloc=18774324,Module._xmlRealloc=18774332,Module._xmlLastError=18936688,Module._xmlMallocAtomic=18774328,Module._xmlMemStrdup=18774336,Module._xmlBufferAllocScheme=18774340,Module._xmlDefaultBufferSize=18774344,Module._xmlParserDebugEntities=18936628,Module._xmlDoValidityCheckingDefaultValue=18936632,Module._xmlLoadExtDtdDefaultValue=18936636,Module._xmlPedanticParserDefaultValue=18936640,Module._xmlLineNumbersDefaultValue=18936644,Module._xmlKeepBlanksDefaultValue=18774352,Module._xmlSubstituteEntitiesDefaultValue=18936648,Module._xmlRegisterNodeDefaultValue=18936652,Module._xmlDeregisterNodeDefaultValue=18936656,Module._xmlParserInputBufferCreateFilenameValue=18936660,Module._xmlOutputBufferCreateFilenameValue=18936664,Module._xmlIndentTreeOutput=18774360,Module._xmlTreeIndentString=18774364,Module._xmlSaveNoEmptyTags=18936680,Module._xmlDefaultSAXHandler=18774368,Module._xmlDefaultSAXLocator=18774480,Module._xmlParserMaxDepth=18775140,Module._xmlStringText=18435456,Module._xmlStringComment=18435471,Module._xmlStringTextNoenc=18435461,Module._xmlXPathNAN=18937352,Module._xmlXPathNINF=18937368,Module._xmlXPathPINF=18937360,Module._z_errmsg=18791696,Module.__length_code=18455120,Module.__dist_code=18454608;function invoke_i(t){var e=stackSave();try{return getWasmTableEntry(t)()}catch(I){if(stackRestore(e),I!==I+0)throw I;_setThrew(1,0)}}function invoke_v(t){var e=stackSave();try{getWasmTableEntry(t)()}catch(I){if(stackRestore(e),I!==I+0)throw I;_setThrew(1,0)}}function invoke_vi(t,e){var I=stackSave();try{getWasmTableEntry(t)(e)}catch(B){if(stackRestore(I),B!==B+0)throw B;_setThrew(1,0)}}function invoke_iii(t,e,I){var B=stackSave();try{return getWasmTableEntry(t)(e,I)}catch(tr){if(stackRestore(B),tr!==tr+0)throw tr;_setThrew(1,0)}}function invoke_iiiiii(t,e,I,B,tr,rr){var ir=stackSave();try{return getWasmTableEntry(t)(e,I,B,tr,rr)}catch(lr){if(stackRestore(ir),lr!==lr+0)throw lr;_setThrew(1,0)}}function invoke_viii(t,e,I,B){var tr=stackSave();try{getWasmTableEntry(t)(e,I,B)}catch(rr){if(stackRestore(tr),rr!==rr+0)throw rr;_setThrew(1,0)}}function invoke_viiiiiii(t,e,I,B,tr,rr,ir,lr){var dr=stackSave();try{getWasmTableEntry(t)(e,I,B,tr,rr,ir,lr)}catch(mr){if(stackRestore(dr),mr!==mr+0)throw mr;_setThrew(1,0)}}function invoke_iiii(t,e,I,B){var tr=stackSave();try{return getWasmTableEntry(t)(e,I,B)}catch(rr){if(stackRestore(tr),rr!==rr+0)throw rr;_setThrew(1,0)}}function invoke_viiii(t,e,I,B,tr){var rr=stackSave();try{getWasmTableEntry(t)(e,I,B,tr)}catch(ir){if(stackRestore(rr),ir!==ir+0)throw ir;_setThrew(1,0)}}function invoke_iiiii(t,e,I,B,tr){var rr=stackSave();try{return getWasmTableEntry(t)(e,I,B,tr)}catch(ir){if(stackRestore(rr),ir!==ir+0)throw ir;_setThrew(1,0)}}function invoke_vii(t,e,I){var B=stackSave();try{getWasmTableEntry(t)(e,I)}catch(tr){if(stackRestore(B),tr!==tr+0)throw tr;_setThrew(1,0)}}function invoke_ii(t,e){var I=stackSave();try{return getWasmTableEntry(t)(e)}catch(B){if(stackRestore(I),B!==B+0)throw B;_setThrew(1,0)}}function invoke_viiiiiiii(t,e,I,B,tr,rr,ir,lr,dr){var mr=stackSave();try{getWasmTableEntry(t)(e,I,B,tr,rr,ir,lr,dr)}catch(hr){if(stackRestore(mr),hr!==hr+0)throw hr;_setThrew(1,0)}}function invoke_viiiii(t,e,I,B,tr,rr){var ir=stackSave();try{getWasmTableEntry(t)(e,I,B,tr,rr)}catch(lr){if(stackRestore(ir),lr!==lr+0)throw lr;_setThrew(1,0)}}function invoke_ij(t,e){var I=stackSave();try{return getWasmTableEntry(t)(e)}catch(B){if(stackRestore(I),B!==B+0)throw B;_setThrew(1,0)}}function invoke_ji(t,e){var I=stackSave();try{return getWasmTableEntry(t)(e)}catch(B){if(stackRestore(I),B!==B+0)throw B;return _setThrew(1,0),0n}}function invoke_ijiiiiii(t,e,I,B,tr,rr,ir,lr){var dr=stackSave();try{return getWasmTableEntry(t)(e,I,B,tr,rr,ir,lr)}catch(mr){if(stackRestore(dr),mr!==mr+0)throw mr;_setThrew(1,0)}}function invoke_vij(t,e,I){var B=stackSave();try{getWasmTableEntry(t)(e,I)}catch(tr){if(stackRestore(B),tr!==tr+0)throw tr;_setThrew(1,0)}}function invoke_vj(t,e){var I=stackSave();try{getWasmTableEntry(t)(e)}catch(B){if(stackRestore(I),B!==B+0)throw B;_setThrew(1,0)}}function invoke_viijii(t,e,I,B,tr,rr){var ir=stackSave();try{getWasmTableEntry(t)(e,I,B,tr,rr)}catch(lr){if(stackRestore(ir),lr!==lr+0)throw lr;_setThrew(1,0)}}function invoke_iiiiiji(t,e,I,B,tr,rr,ir){var lr=stackSave();try{return getWasmTableEntry(t)(e,I,B,tr,rr,ir)}catch(dr){if(stackRestore(lr),dr!==dr+0)throw dr;_setThrew(1,0)}}function invoke_viijiiii(t,e,I,B,tr,rr,ir,lr){var dr=stackSave();try{getWasmTableEntry(t)(e,I,B,tr,rr,ir,lr)}catch(mr){if(stackRestore(dr),mr!==mr+0)throw mr;_setThrew(1,0)}}function invoke_viij(t,e,I,B){var tr=stackSave();try{getWasmTableEntry(t)(e,I,B)}catch(rr){if(stackRestore(tr),rr!==rr+0)throw rr;_setThrew(1,0)}}function invoke_jiiiiiiii(t,e,I,B,tr,rr,ir,lr,dr){var mr=stackSave();try{return getWasmTableEntry(t)(e,I,B,tr,rr,ir,lr,dr)}catch(hr){if(stackRestore(mr),hr!==hr+0)throw hr;return _setThrew(1,0),0n}}function invoke_jiiiii(t,e,I,B,tr,rr){var ir=stackSave();try{return getWasmTableEntry(t)(e,I,B,tr,rr)}catch(lr){if(stackRestore(ir),lr!==lr+0)throw lr;return _setThrew(1,0),0n}}function invoke_iiiiiiiii(t,e,I,B,tr,rr,ir,lr,dr){var mr=stackSave();try{return getWasmTableEntry(t)(e,I,B,tr,rr,ir,lr,dr)}catch(hr){if(stackRestore(mr),hr!==hr+0)throw hr;_setThrew(1,0)}}function invoke_vji(t,e,I){var B=stackSave();try{getWasmTableEntry(t)(e,I)}catch(tr){if(stackRestore(B),tr!==tr+0)throw tr;_setThrew(1,0)}}function invoke_iiiijii(t,e,I,B,tr,rr,ir){var lr=stackSave();try{return getWasmTableEntry(t)(e,I,B,tr,rr,ir)}catch(dr){if(stackRestore(lr),dr!==dr+0)throw dr;_setThrew(1,0)}}function invoke_vijiji(t,e,I,B,tr,rr){var ir=stackSave();try{getWasmTableEntry(t)(e,I,B,tr,rr)}catch(lr){if(stackRestore(ir),lr!==lr+0)throw lr;_setThrew(1,0)}}function invoke_viji(t,e,I,B){var tr=stackSave();try{getWasmTableEntry(t)(e,I,B)}catch(rr){if(stackRestore(tr),rr!==rr+0)throw rr;_setThrew(1,0)}}function invoke_iiij(t,e,I,B){var tr=stackSave();try{return getWasmTableEntry(t)(e,I,B)}catch(rr){if(stackRestore(tr),rr!==rr+0)throw rr;_setThrew(1,0)}}function invoke_iiiiiiii(t,e,I,B,tr,rr,ir,lr){var dr=stackSave();try{return getWasmTableEntry(t)(e,I,B,tr,rr,ir,lr)}catch(mr){if(stackRestore(dr),mr!==mr+0)throw mr;_setThrew(1,0)}}function invoke_iiiiiii(t,e,I,B,tr,rr,ir){var lr=stackSave();try{return getWasmTableEntry(t)(e,I,B,tr,rr,ir)}catch(dr){if(stackRestore(lr),dr!==dr+0)throw dr;_setThrew(1,0)}}function invoke_di(t,e){var I=stackSave();try{return getWasmTableEntry(t)(e)}catch(B){if(stackRestore(I),B!==B+0)throw B;_setThrew(1,0)}}function invoke_id(t,e){var I=stackSave();try{return getWasmTableEntry(t)(e)}catch(B){if(stackRestore(I),B!==B+0)throw B;_setThrew(1,0)}}function invoke_ijiiiii(t,e,I,B,tr,rr,ir){var lr=stackSave();try{return getWasmTableEntry(t)(e,I,B,tr,rr,ir)}catch(dr){if(stackRestore(lr),dr!==dr+0)throw dr;_setThrew(1,0)}}function invoke_jiiii(t,e,I,B,tr){var rr=stackSave();try{return getWasmTableEntry(t)(e,I,B,tr)}catch(ir){if(stackRestore(rr),ir!==ir+0)throw ir;return _setThrew(1,0),0n}}function invoke_viiiiii(t,e,I,B,tr,rr,ir){var lr=stackSave();try{getWasmTableEntry(t)(e,I,B,tr,rr,ir)}catch(dr){if(stackRestore(lr),dr!==dr+0)throw dr;_setThrew(1,0)}}function invoke_viiiiiiiiiiii(t,e,I,B,tr,rr,ir,lr,dr,mr,hr,fr,_r){var wr=stackSave();try{getWasmTableEntry(t)(e,I,B,tr,rr,ir,lr,dr,mr,hr,fr,_r)}catch(gr){if(stackRestore(wr),gr!==gr+0)throw gr;_setThrew(1,0)}}function invoke_jii(t,e,I){var B=stackSave();try{return getWasmTableEntry(t)(e,I)}catch(tr){if(stackRestore(B),tr!==tr+0)throw tr;return _setThrew(1,0),0n}}function invoke_iiiij(t,e,I,B,tr){var rr=stackSave();try{return getWasmTableEntry(t)(e,I,B,tr)}catch(ir){if(stackRestore(rr),ir!==ir+0)throw ir;_setThrew(1,0)}}function invoke_iiiiiiiiii(t,e,I,B,tr,rr,ir,lr,dr,mr){var hr=stackSave();try{return getWasmTableEntry(t)(e,I,B,tr,rr,ir,lr,dr,mr)}catch(fr){if(stackRestore(hr),fr!==fr+0)throw fr;_setThrew(1,0)}}function invoke_viiji(t,e,I,B,tr){var rr=stackSave();try{getWasmTableEntry(t)(e,I,B,tr)}catch(ir){if(stackRestore(rr),ir!==ir+0)throw ir;_setThrew(1,0)}}function invoke_iiji(t,e,I,B){var tr=stackSave();try{return getWasmTableEntry(t)(e,I,B)}catch(rr){if(stackRestore(tr),rr!==rr+0)throw rr;_setThrew(1,0)}}function invoke_vid(t,e,I){var B=stackSave();try{getWasmTableEntry(t)(e,I)}catch(tr){if(stackRestore(B),tr!==tr+0)throw tr;_setThrew(1,0)}}function invoke_viiiiiiiii(t,e,I,B,tr,rr,ir,lr,dr,mr){var hr=stackSave();try{getWasmTableEntry(t)(e,I,B,tr,rr,ir,lr,dr,mr)}catch(fr){if(stackRestore(hr),fr!==fr+0)throw fr;_setThrew(1,0)}}function invoke_viiij(t,e,I,B,tr){var rr=stackSave();try{getWasmTableEntry(t)(e,I,B,tr)}catch(ir){if(stackRestore(rr),ir!==ir+0)throw ir;_setThrew(1,0)}}function invoke_iiiiiiiiiiiiiiiii(t,e,I,B,tr,rr,ir,lr,dr,mr,hr,fr,_r,wr,gr,xr,Mr){var Sr=stackSave();try{return getWasmTableEntry(t)(e,I,B,tr,rr,ir,lr,dr,mr,hr,fr,_r,wr,gr,xr,Mr)}catch(yr){if(stackRestore(Sr),yr!==yr+0)throw yr;_setThrew(1,0)}}Module.addRunDependency=addRunDependency,Module.removeRunDependency=removeRunDependency,Module.callMain=callMain,Module.ccall=ccall,Module.cwrap=cwrap,Module.setValue=setValue,Module.getValue=getValue,Module.UTF8ToString=UTF8ToString,Module.stringToNewUTF8=stringToNewUTF8,Module.stringToUTF8OnStack=stringToUTF8OnStack,Module.FS_createPreloadedFile=FS_createPreloadedFile,Module.FS_unlink=FS_unlink,Module.FS_createPath=FS_createPath,Module.FS_createDevice=FS_createDevice,Module.FS=FS,Module.FS_createDataFile=FS_createDataFile,Module.FS_createLazyFile=FS_createLazyFile;var calledRun;dependenciesFulfilled=function t(){calledRun||run(),calledRun||(dependenciesFulfilled=t)};function callMain(t=[]){var e=resolveGlobalSymbol("main").sym;if(e){t.unshift(thisProgram);var I=t.length,B=stackAlloc((I+1)*4),tr=B;t.forEach(ir=>{HEAPU32[tr>>2]=stringToUTF8OnStack(ir),tr+=4}),HEAPU32[tr>>2]=0;try{var rr=e(I,B);return exitJS(rr,!0),rr}catch(ir){return handleException(ir)}}}function run(t=arguments_){if(runDependencies>0||(preRun(),runDependencies>0))return;function e(){calledRun||(calledRun=!0,Module.calledRun=!0,!ABORT&&(initRuntime(),preMain(),readyPromiseResolve(Module),Module.onRuntimeInitialized?.(),shouldRunNow&&callMain(t),postRun()))}Module.setStatus?(Module.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>Module.setStatus(""),1),e()},1)):e()}if(Module.preInit)for(typeof Module.preInit=="function"&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.pop()();var shouldRunNow=!0;return Module.noInitialRun&&(shouldRunNow=!1),run(),moduleRtn=readyPromise,moduleRtn}})(),ke=Qe,Te=ke,Y,W,j,J,$,_e,ie,me,Z,ae,oe,se,V,G,k,K,O,qe,re,pe=class oo extends z{constructor(e={},I={}){super(),R$2(this,O),R$2(this,Y,!1),R$2(this,W,!1),R$2(this,j,!1),R$2(this,J,!1),R$2(this,$,!1),R$2(this,_e,new H),R$2(this,ie,new H),R$2(this,me,new H),R$2(this,Z,!1),this.debug=0,R$2(this,ae),R$2(this,oe,[]),R$2(this,se,new ye),R$2(this,V),R$2(this,G),R$2(this,k,new Map),R$2(this,K,new Set),typeof e=="string"?I={dataDir:e,...I}:I=e,this.dataDir=I.dataDir,I.parsers!==void 0&&(this.parsers={...this.parsers,...I.parsers}),I.serializers!==void 0&&(this.serializers={...this.serializers,...I.serializers}),I?.debug!==void 0&&(this.debug=I.debug),I?.relaxedDurability!==void 0&&x$2(this,$,I.relaxedDurability),x$2(this,ae,I.extensions??{}),this.waitReady=T(this,O,qe).call(this,I??{})}static async create(e,I){let B=typeof e=="string"?{dataDir:e,...I??{}}:e??{},tr=new oo(B);return await tr.waitReady,tr}get Module(){return this.mod}get ready(){return h$1(this,Y)&&!h$1(this,W)&&!h$1(this,j)}get closed(){return h$1(this,j)}async close(){await this._checkReady(),x$2(this,W,!0);for(let e of h$1(this,oe))await e();try{await this.execProtocol(O$1.end()),this.mod._pg_shutdown()}catch(e){let I=e;if(!(I.name==="ExitStatus"&&I.status===0))throw e}await this.fs.closeFs(),x$2(this,j,!0),x$2(this,W,!1)}async[Symbol.asyncDispose](){await this.close()}async _handleBlob(e){x$2(this,V,e?await e.arrayBuffer():void 0)}async _cleanupBlob(){x$2(this,V,void 0)}async _getWrittenBlob(){if(!h$1(this,G))return;let e=new Blob(h$1(this,G));return x$2(this,G,void 0),e}async _checkReady(){if(h$1(this,W))throw new Error("PGlite is closing");if(h$1(this,j))throw new Error("PGlite is closed");h$1(this,Y)||await this.waitReady}execProtocolRawSync(e){let I=e.length,B=this.mod;B._interactive_write(I),B.HEAPU8.set(e,1),B._interactive_one();let tr=I+2,rr=tr+B._interactive_read();return B.HEAPU8.subarray(tr,rr)}async execProtocolRaw(e,{syncToFs:I=!0}={}){let B=e.length,tr=this.mod;tr._interactive_write(B),tr.HEAPU8.set(e,1),tr._interactive_one();let rr=B+2,ir=rr+tr._interactive_read(),lr=tr.HEAPU8.subarray(rr,ir);return I&&await this.syncToFs(),lr}async execProtocol(e,{syncToFs:I=!0,throwOnError:B=!0,onNotice:tr}={}){let rr=await this.execProtocolRaw(e,{syncToFs:I}),ir=[];return h$1(this,se).parse(rr,lr=>{if(lr instanceof E){if(x$2(this,se,new ye),B)throw lr}else if(lr instanceof ne)this.debug>0&&console.warn(lr),tr&&tr(lr);else if(lr instanceof ee$1)switch(lr.text){case"BEGIN":x$2(this,J,!0);break;case"COMMIT":case"ROLLBACK":x$2(this,J,!1);break}else if(lr instanceof X){let dr=h$1(this,k).get(lr.channel);dr&&dr.forEach(mr=>{queueMicrotask(()=>mr(lr.payload))}),h$1(this,K).forEach(mr=>{queueMicrotask(()=>mr(lr.channel,lr.payload))})}ir.push(lr)}),{messages:ir,data:rr}}isInTransaction(){return h$1(this,J)}async syncToFs(){if(h$1(this,Z))return;x$2(this,Z,!0);let e=async()=>{await h$1(this,me).runExclusive(async()=>{x$2(this,Z,!1),await this.fs.syncToFs(h$1(this,$))})};h$1(this,$)?e():await e()}async listen(e,I){let B=Nr(e);h$1(this,k).has(B)||h$1(this,k).set(B,new Set),h$1(this,k).get(B).add(I);try{await this.exec(`LISTEN ${e}`)}catch(tr){throw h$1(this,k).get(B).delete(I),h$1(this,k).get(B)?.size===0&&h$1(this,k).delete(B),tr}return async()=>{await this.unlisten(B,I)}}async unlisten(e,I){let B=Nr(e);I?(h$1(this,k).get(B)?.delete(I),h$1(this,k).get(B)?.size===0&&(await this.exec(`UNLISTEN ${e}`),h$1(this,k).delete(B))):(await this.exec(`UNLISTEN ${e}`),h$1(this,k).delete(B))}onNotification(e){return h$1(this,K).add(e),()=>{h$1(this,K).delete(e)}}offNotification(e){h$1(this,K).delete(e)}async dumpDataDir(e){let I=this.dataDir?.split("/").pop()??"pgdata";return this.fs.dumpTar(I,e)}_runExclusiveQuery(e){return h$1(this,_e).runExclusive(e)}_runExclusiveTransaction(e){return h$1(this,ie).runExclusive(e)}async clone(){let e=await this.dumpDataDir("none");return new oo({loadDataDir:e})}};Y=new WeakMap,W=new WeakMap,j=new WeakMap,J=new WeakMap,$=new WeakMap,_e=new WeakMap,ie=new WeakMap,me=new WeakMap,Z=new WeakMap,ae=new WeakMap,oe=new WeakMap,se=new WeakMap,V=new WeakMap,G=new WeakMap,k=new WeakMap,K=new WeakMap,O=new WeakSet,qe=async function(t){if(t.fs)this.fs=t.fs;else{let{dataDir:mr,fsType:hr}=Fe(t.dataDir);this.fs=await Ae(mr,hr)}let e={},I=[],B=[`PGDATA=${C}`,`PREFIX=${Vr}`,`PGUSER=${t.username??"postgres"}`,`PGDATABASE=${t.database??"template1"}`,"MODE=REACT","REPL=N",...this.debug?["-d",this.debug.toString()]:[]];t.wasmModule||Rr();let tr=t.fsBundle?t.fsBundle.arrayBuffer():Er(),rr;tr.then(mr=>{rr=mr});let ir={WASM_PREFIX:Vr,arguments:B,INITIAL_MEMORY:t.initialMemory,noExitRuntime:!0,...this.debug>0?{print:console.info,printErr:console.error}:{print:()=>{},printErr:()=>{}},instantiateWasm:(mr,hr)=>(Tr(mr,t.wasmModule).then(({instance:fr,module:_r})=>{hr(fr,_r)}),{}),getPreloadedPackage:(mr,hr)=>{if(mr==="postgres.data"){if(rr.byteLength!==hr)throw new Error(`Invalid FS bundle size: ${rr.byteLength} !== ${hr}`);return rr}throw new Error(`Unknown package: ${mr}`)},preRun:[mr=>{let hr=mr.FS.makedev(64,0),fr={open:_r=>{},close:_r=>{},read:(_r,wr,gr,xr,Mr)=>{let Sr=h$1(this,V);if(!Sr)throw new Error("No /dev/blob File or Blob provided to read from");let yr=new Uint8Array(Sr);if(Mr>=yr.length)return 0;let br=Math.min(yr.length-Mr,xr);for(let vr=0;vr<br;vr++)wr[gr+vr]=yr[Mr+vr];return br},write:(_r,wr,gr,xr,Mr)=>(h$1(this,G)??x$2(this,G,[]),h$1(this,G).push(wr.slice(gr,gr+xr)),xr),llseek:(_r,wr,gr)=>{let xr=h$1(this,V);if(!xr)throw new Error("No /dev/blob File or Blob provided to llseek");let Mr=wr;if(gr===1?Mr+=_r.position:gr===2&&(Mr=new Uint8Array(xr).length),Mr<0)throw new mr.FS.ErrnoError(28);return Mr}};mr.FS.registerDevice(hr,fr),mr.FS.mkdev("/dev/blob",hr)}]},{emscriptenOpts:lr}=await this.fs.init(this,ir);ir=lr;for(let[mr,hr]of Object.entries(h$1(this,ae)))if(hr instanceof URL)e[mr]=ge(hr);else{let fr=await hr.setup(this,ir);if(fr.emscriptenOpts&&(ir=fr.emscriptenOpts),fr.namespaceObj){let _r=this;_r[mr]=fr.namespaceObj}fr.bundlePath&&(e[mr]=ge(fr.bundlePath)),fr.init&&I.push(fr.init),fr.close&&h$1(this,oe).push(fr.close)}if(ir.pg_extensions=e,await tr,this.mod=await Te(ir),await this.fs.initialSyncFs(),t.loadDataDir){if(this.mod.FS.analyzePath(C+"/PG_VERSION").exists)throw new Error("Database already exists, cannot load from tarball");T(this,O,re).call(this,"pglite: loading data from tarball"),await ce$1(this.mod.FS,t.loadDataDir,C)}this.mod.FS.analyzePath(C+"/PG_VERSION").exists?T(this,O,re).call(this,"pglite: found DB, resuming"):T(this,O,re).call(this,"pglite: no db"),await Pe(this.mod,(...mr)=>T(this,O,re).call(this,...mr));let dr=this.mod._pg_initdb();if(!dr)throw new Error("INITDB failed to return value");if(dr&1)throw new Error("INITDB failed");if(dr&2){let mr=t.username??"postgres",hr=t.database??"template1";if(dr&4){if(!(dr&12))throw new Error("Invalid db/user combination")}else if(hr!=="template1"&&mr!=="postgres")throw new Error("INITDB created a new datadir, but an alternative db/user was requested")}await this.syncToFs(),x$2(this,Y,!0),await this.exec("SET search_path TO public;"),await this._initArrayTypes();for(let mr of I)await mr()},re=function(...t){this.debug>0&&console.log(...t)};var Ue=pe;u$1();var PGliteConnection=class{client;constructor(t){this.client=t}async executeQuery(t){const e=await this.client.query(t.sql,[...t.parameters]);return e.affectedRows?{numAffectedRows:BigInt(e.affectedRows),rows:e.rows}:{rows:e.rows}}async*streamQuery(t,e){if(!Number.isInteger(e)||e<=0)throw new Error("chunkSize must be a positive integer");const I=await this.client.query(t.sql,[...t.parameters]);for(let B=0;B<I.rows.length;B=B+e)yield{rows:I.rows.slice(B,B+e)}}},PGliteDialect=class{constructor(t){this.pgLite=t}createAdapter(){return new PostgresAdapter}createDriver(){return new PGliteDriver(this.pgLite)}createQueryCompiler(){return new PostgresQueryCompiler}createIntrospector(t){return new PostgresIntrospector(t)}},PGliteDriver=class{client;connection;queue=[];constructor(t){this.client=t}async init(){}async acquireConnection(){if(this.client===void 0)throw new Error("PGLite not initialized");return this.connection!==void 0?new Promise(t=>{this.queue.push(t)}):(this.connection=new PGliteConnection(this.client),this.connection)}async releaseConnection(t){if(t!==this.connection)throw new Error("Invalid connection");const I=this.queue.splice(0,1)[0];if(I===void 0){this.connection=void 0;return}I(this.connection)}async beginTransaction(t,e){e.isolationLevel?await t.executeQuery(CompiledQuery.raw(`start transaction isolation level ${e.isolationLevel}`)):await t.executeQuery(CompiledQuery.raw("begin"))}async commitTransaction(t){await t.executeQuery(CompiledQuery.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(CompiledQuery.raw("rollback"))}async destroy(){this.client=void 0}};class ConsistencyAwareLegacyStorage{inner;consistencyTracker;constructor(e,I,B){this.inner=e,this.consistencyTracker=I,B.subscribe(OperationEventTypes.OPERATION_WRITTEN,(tr,rr)=>{const ir=rr.operations.map(lr=>({documentId:lr.context.documentId,scope:lr.context.scope,branch:lr.context.branch,operationIndex:lr.operation.index}));this.consistencyTracker.update(ir)})}async waitForConsistency(e,I){e&&e.coordinates.length>0&&await this.consistencyTracker.waitFor(e.coordinates,void 0,I)}async get(e,I,B){return await this.waitForConsistency(I,B),this.inner.get(e)}async getBySlug(e,I,B){return await this.waitForConsistency(I,B),this.inner.getBySlug(e)}async exists(e,I,B){return await this.waitForConsistency(I,B),this.inner.exists(e)}async findByType(e,I,B,tr,rr){return await this.waitForConsistency(tr,rr),this.inner.findByType(e,I,B)}async getChildren(e,I,B){return await this.waitForConsistency(I,B),this.inner.getChildren(e)}async resolveIds(e,I,B){return await this.waitForConsistency(I,B),this.inner.resolveIds(e,B)}async resolveSlugs(e,I,B){return await this.waitForConsistency(I,B),this.inner.resolveSlugs(e,B)}async getParents(e,I,B){return await this.waitForConsistency(I,B),this.inner.getParents(e)}}async function up$9(t){await t.schema.createTable("Operation").addColumn("id","serial",e=>e.primaryKey()).addColumn("jobId","text",e=>e.notNull()).addColumn("opId","text",e=>e.notNull().unique()).addColumn("prevOpId","text",e=>e.notNull()).addColumn("writeTimestampUtcMs","timestamptz",e=>e.notNull().defaultTo(sql`NOW()`)).addColumn("documentId","text",e=>e.notNull()).addColumn("documentType","text",e=>e.notNull()).addColumn("scope","text",e=>e.notNull()).addColumn("branch","text",e=>e.notNull()).addColumn("timestampUtcMs","timestamptz",e=>e.notNull()).addColumn("index","integer",e=>e.notNull()).addColumn("action","jsonb",e=>e.notNull()).addColumn("skip","integer",e=>e.notNull()).addColumn("error","text").addColumn("hash","text",e=>e.notNull()).addUniqueConstraint("unique_revision",["documentId","scope","branch","index"]).execute(),await t.schema.createIndex("streamOperations").on("Operation").columns(["documentId","scope","branch","id"]).execute(),await t.schema.createIndex("branchlessStreamOperations").on("Operation").columns(["documentId","scope","id"]).execute()}const migration001=Object.freeze(Object.defineProperty({__proto__:null,up:up$9},Symbol.toStringTag,{value:"Module"}));async function up$8(t){await t.schema.createTable("Keyframe").addColumn("id","serial",e=>e.primaryKey()).addColumn("documentId","text",e=>e.notNull()).addColumn("documentType","text",e=>e.notNull()).addColumn("scope","text",e=>e.notNull()).addColumn("branch","text",e=>e.notNull()).addColumn("revision","integer",e=>e.notNull()).addColumn("document","jsonb",e=>e.notNull()).addColumn("createdAt","timestamptz",e=>e.notNull().defaultTo(sql`NOW()`)).addUniqueConstraint("unique_keyframe",["documentId","scope","branch","revision"]).execute(),await t.schema.createIndex("keyframe_lookup").on("Keyframe").columns(["documentId","scope","branch","revision"]).execute()}const migration002=Object.freeze(Object.defineProperty({__proto__:null,up:up$8},Symbol.toStringTag,{value:"Module"}));async function up$7(t){await t.schema.createTable("Document").addColumn("id","text",e=>e.primaryKey()).addColumn("createdAt","timestamptz",e=>e.notNull().defaultTo(sql`NOW()`)).addColumn("updatedAt","timestamptz",e=>e.notNull().defaultTo(sql`NOW()`)).execute()}const migration003=Object.freeze(Object.defineProperty({__proto__:null,up:up$7},Symbol.toStringTag,{value:"Module"}));async function up$6(t){await t.schema.createTable("DocumentRelationship").addColumn("id","text",e=>e.primaryKey()).addColumn("sourceId","text",e=>e.notNull().references("Document.id").onDelete("cascade")).addColumn("targetId","text",e=>e.notNull().references("Document.id").onDelete("cascade")).addColumn("relationshipType","text",e=>e.notNull()).addColumn("metadata","jsonb").addColumn("createdAt","timestamptz",e=>e.notNull().defaultTo(sql`NOW()`)).addColumn("updatedAt","timestamptz",e=>e.notNull().defaultTo(sql`NOW()`)).addUniqueConstraint("unique_source_target_type",["sourceId","targetId","relationshipType"]).execute(),await t.schema.createIndex("idx_relationship_source").on("DocumentRelationship").column("sourceId").execute(),await t.schema.createIndex("idx_relationship_target").on("DocumentRelationship").column("targetId").execute(),await t.schema.createIndex("idx_relationship_type").on("DocumentRelationship").column("relationshipType").execute()}const migration004=Object.freeze(Object.defineProperty({__proto__:null,up:up$6},Symbol.toStringTag,{value:"Module"}));async function up$5(t){await t.schema.createTable("IndexerState").addColumn("id","integer",e=>e.primaryKey().generatedAlwaysAsIdentity()).addColumn("lastOperationId","integer",e=>e.notNull()).addColumn("lastOperationTimestamp","timestamptz",e=>e.notNull().defaultTo(sql`NOW()`)).execute()}const migration005=Object.freeze(Object.defineProperty({__proto__:null,up:up$5},Symbol.toStringTag,{value:"Module"}));async function up$4(t){await t.schema.createTable("DocumentSnapshot").addColumn("id","text",e=>e.primaryKey()).addColumn("documentId","text",e=>e.notNull()).addColumn("slug","text").addColumn("name","text").addColumn("scope","text",e=>e.notNull()).addColumn("branch","text",e=>e.notNull()).addColumn("content","jsonb",e=>e.notNull()).addColumn("documentType","text",e=>e.notNull()).addColumn("lastOperationIndex","integer",e=>e.notNull()).addColumn("lastOperationHash","text",e=>e.notNull()).addColumn("lastUpdatedAt","timestamptz",e=>e.notNull().defaultTo(sql`NOW()`)).addColumn("snapshotVersion","integer",e=>e.notNull().defaultTo(1)).addColumn("identifiers","jsonb").addColumn("metadata","jsonb").addColumn("isDeleted","boolean",e=>e.notNull().defaultTo(!1)).addColumn("deletedAt","timestamptz").addUniqueConstraint("unique_doc_scope_branch",["documentId","scope","branch"]).execute(),await t.schema.createIndex("idx_slug_scope_branch").on("DocumentSnapshot").columns(["slug","scope","branch"]).execute(),await t.schema.createIndex("idx_doctype_scope_branch").on("DocumentSnapshot").columns(["documentType","scope","branch"]).execute(),await t.schema.createIndex("idx_last_updated").on("DocumentSnapshot").column("lastUpdatedAt").execute(),await t.schema.createIndex("idx_is_deleted").on("DocumentSnapshot").column("isDeleted").execute()}const migration006=Object.freeze(Object.defineProperty({__proto__:null,up:up$4},Symbol.toStringTag,{value:"Module"}));async function up$3(t){await t.schema.createTable("SlugMapping").addColumn("slug","text",e=>e.primaryKey()).addColumn("documentId","text",e=>e.notNull()).addColumn("scope","text",e=>e.notNull()).addColumn("branch","text",e=>e.notNull()).addColumn("createdAt","timestamptz",e=>e.notNull().defaultTo(sql`NOW()`)).addColumn("updatedAt","timestamptz",e=>e.notNull().defaultTo(sql`NOW()`)).addUniqueConstraint("unique_docid_scope_branch",["documentId","scope","branch"]).execute(),await t.schema.createIndex("idx_slug_documentid").on("SlugMapping").column("documentId").execute()}const migration007=Object.freeze(Object.defineProperty({__proto__:null,up:up$3},Symbol.toStringTag,{value:"Module"}));async function up$2(t){await t.schema.createTable("ViewState").addColumn("readModelId","text",e=>e.primaryKey()).addColumn("lastOrdinal","integer",e=>e.notNull().defaultTo(0)).addColumn("lastOperationTimestamp","timestamptz",e=>e.notNull().defaultTo(sql`NOW()`)).execute()}const migration008=Object.freeze(Object.defineProperty({__proto__:null,up:up$2},Symbol.toStringTag,{value:"Module"}));async function up$1(t){await t.schema.createTable("document_collections").addColumn("documentId","text",e=>e.notNull()).addColumn("collectionId","text",e=>e.notNull()).addColumn("joinedOrdinal","bigint",e=>e.notNull().defaultTo(0)).addColumn("leftOrdinal","bigint").addPrimaryKeyConstraint("document_collections_pkey",["documentId","collectionId"]).execute(),await t.schema.createIndex("idx_document_collections_collectionId").on("document_collections").column("collectionId").execute(),await t.schema.createIndex("idx_doc_collections_collection_range").on("document_collections").columns(["collectionId","joinedOrdinal"]).execute(),await t.schema.createTable("operation_index_operations").addColumn("ordinal","serial",e=>e.primaryKey()).addColumn("opId","text",e=>e.notNull()).addColumn("documentId","text",e=>e.notNull()).addColumn("documentType","text",e=>e.notNull()).addColumn("scope","text",e=>e.notNull()).addColumn("branch","text",e=>e.notNull()).addColumn("timestampUtcMs","bigint",e=>e.notNull()).addColumn("writeTimestampUtcMs","timestamptz",e=>e.notNull().defaultTo(sql`NOW()`)).addColumn("index","integer",e=>e.notNull()).addColumn("skip","integer",e=>e.notNull()).addColumn("hash","text",e=>e.notNull()).addColumn("action","jsonb",e=>e.notNull()).execute(),await t.schema.createIndex("idx_operation_index_operations_document").on("operation_index_operations").columns(["documentId","branch","scope"]).execute(),await t.schema.createIndex("idx_operation_index_operations_ordinal").on("operation_index_operations").column("ordinal").execute()}const migration009=Object.freeze(Object.defineProperty({__proto__:null,up:up$1},Symbol.toStringTag,{value:"Module"}));async function up(t){await t.schema.createTable("sync_remotes").addColumn("name","text",e=>e.primaryKey()).addColumn("collection_id","text",e=>e.notNull()).addColumn("channel_type","text",e=>e.notNull()).addColumn("channel_id","text",e=>e.notNull().defaultTo("")).addColumn("remote_name","text",e=>e.notNull().defaultTo("")).addColumn("channel_parameters","jsonb",e=>e.notNull().defaultTo(sql`'{}'::jsonb`)).addColumn("filter_document_ids","jsonb").addColumn("filter_scopes","jsonb").addColumn("filter_branch","text",e=>e.notNull().defaultTo("main")).addColumn("push_state","text",e=>e.notNull().defaultTo("idle")).addColumn("push_last_success_utc_ms","bigint").addColumn("push_last_failure_utc_ms","bigint").addColumn("push_failure_count","integer",e=>e.notNull().defaultTo(0)).addColumn("pull_state","text",e=>e.notNull().defaultTo("idle")).addColumn("pull_last_success_utc_ms","bigint").addColumn("pull_last_failure_utc_ms","bigint").addColumn("pull_failure_count","integer",e=>e.notNull().defaultTo(0)).addColumn("created_at","timestamptz",e=>e.notNull().defaultTo(sql`NOW()`)).addColumn("updated_at","timestamptz",e=>e.notNull().defaultTo(sql`NOW()`)).execute(),await t.schema.createIndex("idx_sync_remotes_collection").on("sync_remotes").column("collection_id").execute(),await t.schema.createTable("sync_cursors").addColumn("remote_name","text",e=>e.primaryKey().references("sync_remotes.name").onDelete("cascade")).addColumn("cursor_ordinal","bigint",e=>e.notNull().defaultTo(0)).addColumn("last_synced_at_utc_ms","bigint").addColumn("updated_at","timestamptz",e=>e.notNull().defaultTo(sql`NOW()`)).execute(),await t.schema.createIndex("idx_sync_cursors_ordinal").on("sync_cursors").column("cursor_ordinal").execute()}const migration010=Object.freeze(Object.defineProperty({__proto__:null,up},Symbol.toStringTag,{value:"Module"})),migrations={"001_create_operation_table":migration001,"002_create_keyframe_table":migration002,"003_create_document_table":migration003,"004_create_document_relationship_table":migration004,"005_create_indexer_state_table":migration005,"006_create_document_snapshot_table":migration006,"007_create_slug_mapping_table":migration007,"008_create_view_state_table":migration008,"009_create_operation_index_tables":migration009,"010_create_sync_tables":migration010};class ProgrammaticMigrationProvider{getMigrations(){return Promise.resolve(migrations)}}async function runMigrations(t){const e=new Migrator({db:t,provider:new ProgrammaticMigrationProvider}),{error:I,results:B}=await e.migrateToLatest(),tr=B?.map(rr=>rr.migrationName)??[];return I?{success:!1,migrationsExecuted:tr,error:I instanceof Error?I:new Error("Unknown migration error")}:{success:!0,migrationsExecuted:tr}}class ReactorBuilder{documentModels=[];storage;features={legacyStorageEnabled:!0};readModels=[];executorManager;executorConfig={count:1};writeCacheConfig;readModelCoordinatorFactory;migrationStrategy="auto";syncBuilder;eventBus;documentIndexer;signatureVerifier;kyselyInstance;withDocumentModels(e){return this.documentModels=e,this}withLegacyStorage(e){return this.storage=e,this}withFeatures(e){return this.features={...this.features,...e},this}withReadModel(e){return this.readModels.push(e),this}withReadModelCoordinatorFactory(e){return this.readModelCoordinatorFactory=e,this}withExecutor(e){return this.executorManager=e,this}withExecutorConfig(e){return this.executorConfig={...this.executorConfig,...e},this}withWriteCacheConfig(e){return this.writeCacheConfig=e,this}withMigrationStrategy(e){return this.migrationStrategy=e,this}withSync(e){return this.syncBuilder=e,this}withEventBus(e){return this.eventBus=e,this}withSignatureVerifier(e){return this.signatureVerifier=e,this}withKysely(e){return this.kyselyInstance=e,this}async build(){return(await this.buildModule()).reactor}async buildModule(){const e=this.storage||new MemoryStorage,I=new DocumentModelRegistry;this.documentModels.length>0&&I.registerModules(...this.documentModels);const tr=new ReactorBuilder$1(this.documentModels).withStorage(e).build();await tr.initialize();const rr=this.kyselyInstance??new Kysely({dialect:new PGliteDialect(new Ue)});if(this.migrationStrategy==="auto"){const zr=await runMigrations(rr);if(!zr.success&&zr.error)throw new Error(`Database migration failed: ${zr.error.message}`)}const ir=new KyselyOperationStore(rr),lr=new KyselyKeyframeStore(rr),dr=this.eventBus||new EventBus,mr=new InMemoryQueue(dr),hr=new InMemoryJobTracker(dr),fr=new ConsistencyTracker,_r=new ConsistencyAwareLegacyStorage(e,fr,dr),wr={maxDocuments:this.writeCacheConfig?.maxDocuments??100,ringBufferSize:this.writeCacheConfig?.ringBufferSize??10,keyframeInterval:this.writeCacheConfig?.keyframeInterval??10},gr=new KyselyWriteCache(lr,ir,I,wr);await gr.startup();const xr=new KyselyOperationIndex(rr),Mr=new DocumentMetaCache(ir,{maxDocuments:1e3});await Mr.startup();let Sr=this.executorManager;Sr||(Sr=new SimpleJobExecutorManager(()=>new SimpleJobExecutor(I,e,e,ir,dr,gr,xr,Mr,{legacyStorageEnabled:this.features.legacyStorageEnabled},this.signatureVerifier),dr,mr,hr)),await Sr.start(this.executorConfig.count);const yr=Array.from(new Set([...this.readModels])),br=new ConsistencyTracker,vr=new KyselyDocumentView(rr,ir,xr,gr,br);try{await vr.init()}catch(zr){console.error("Error initializing document view",zr)}yr.push(vr);const Cr=new ConsistencyTracker,Ar=new KyselyDocumentIndexer(rr,ir,Cr);try{await Ar.init()}catch(zr){console.error("Error initializing document indexer",zr)}yr.push(Ar),this.documentIndexer=Ar;const Ir=this.readModelCoordinatorFactory?this.readModelCoordinatorFactory(dr,yr):new ReadModelCoordinator(dr,yr),Dr=new Reactor(tr,_r,mr,hr,Ir,this.features,vr,Ar,ir);let Fr;return this.syncBuilder&&(Fr=this.syncBuilder.buildModule(Dr,xr,dr,rr),await Fr.syncManager.startup()),{driveServer:tr,storage:e,eventBus:dr,documentModelRegistry:I,queue:mr,jobTracker:hr,executorManager:Sr,database:rr,operationStore:ir,keyframeStore:lr,writeCache:gr,operationIndex:xr,documentView:vr,documentViewConsistencyTracker:br,documentIndexer:Ar,documentIndexerConsistencyTracker:Cr,readModelCoordinator:Ir,syncModule:Fr,reactor:Dr}}}class PassthroughSigner{sign(){return Promise.resolve(["","","","",""])}}class DefaultSubscriptionErrorHandler{handleError(e,I){const B=`Subscription error in ${I.eventType} (${I.subscriptionId})`;if(e instanceof Error){const tr=new Error(`${B}: ${e.message}`);throw tr.cause=e,tr.stack=e.stack,tr}else throw new Error(`${B}: ${String(e)}`)}}class ReactorSubscriptionManager{createdSubscriptions=new Map;deletedSubscriptions=new Map;updatedSubscriptions=new Map;relationshipSubscriptions=new Map;subscriptionCounter=0;errorHandler;constructor(e){this.errorHandler=e}onDocumentCreated(e,I){const B=`created-${++this.subscriptionCounter}`;return this.createdSubscriptions.set(B,{id:B,callback:e,search:I}),()=>{this.createdSubscriptions.delete(B)}}onDocumentDeleted(e,I){const B=`deleted-${++this.subscriptionCounter}`;return this.deletedSubscriptions.set(B,{id:B,callback:e,search:I}),()=>{this.deletedSubscriptions.delete(B)}}onDocumentStateUpdated(e,I,B){const tr=`updated-${++this.subscriptionCounter}`;return this.updatedSubscriptions.set(tr,{id:tr,callback:e,search:I,view:B}),()=>{this.updatedSubscriptions.delete(tr)}}onRelationshipChanged(e,I){const B=`relationship-${++this.subscriptionCounter}`;return this.relationshipSubscriptions.set(B,{id:B,callback:e,search:I}),()=>{this.relationshipSubscriptions.delete(B)}}notifyDocumentsCreated(e,I,B){const tr={results:e,options:{cursor:"",limit:e.length}};for(const rr of this.createdSubscriptions.values()){const ir=this.filterDocumentIds(e,rr.search,I,B);if(ir.length>0)try{rr.callback({...tr,results:ir})}catch(lr){this.errorHandler.handleError(lr,{eventType:"created",subscriptionId:rr.id,eventData:ir})}}}notifyDocumentsDeleted(e,I,B){for(const tr of this.deletedSubscriptions.values()){const rr=this.filterDocumentIds(e,tr.search,I,B);if(rr.length>0)try{tr.callback(rr)}catch(ir){this.errorHandler.handleError(ir,{eventType:"deleted",subscriptionId:tr.id,eventData:rr})}}}notifyDocumentsUpdated(e){const I={results:e,options:{cursor:"",limit:e.length}};for(const B of this.updatedSubscriptions.values()){const tr=this.filterDocuments(e,B.search);if(tr.length>0)try{B.callback({...I,results:tr})}catch(rr){this.errorHandler.handleError(rr,{eventType:"updated",subscriptionId:B.id,eventData:tr})}}}notifyRelationshipChanged(e,I,B,tr){for(const rr of this.relationshipSubscriptions.values())if(this.matchesRelationshipFilter(e,I,tr,rr.search))try{rr.callback(e,I,B)}catch(ir){this.errorHandler.handleError(ir,{eventType:"relationshipChanged",subscriptionId:rr.id,eventData:{parentId:e,childId:I,changeType:B}})}}clearAll(){this.createdSubscriptions.clear(),this.deletedSubscriptions.clear(),this.updatedSubscriptions.clear(),this.relationshipSubscriptions.clear()}filterDocumentIds(e,I,B,tr){return I?e.filter(rr=>!(I.ids&&!I.ids.includes(rr)||I.type&&B&&B.get(rr)!==I.type||I.parentId&&tr&&tr.get(rr)!==I.parentId)):e}filterDocuments(e,I){return I?e.filter(B=>!(I.ids&&!I.ids.includes(B.header.id)||I.type&&B.header.documentType!==I.type||I.slugs&&!I.slugs.includes(B.header.slug))):e}matchesRelationshipFilter(e,I,B,tr){return tr?!(tr.parentId&&e!==tr.parentId||tr.ids&&!tr.ids.includes(I)||tr.type&&B&&B!==tr.type):!0}}class ReactorClientBuilder{reactorBuilder;reactor;eventBus;documentIndexer;signer;signatureVerifier;subscriptionManager;jobAwaiter;withReactorBuilder(e){if(this.reactor)throw new Error("Reactor is already set");return this.reactorBuilder=e,this}withReactor(e,I,B){if(this.reactorBuilder)throw new Error("ReactorBuilder is already set");return this.reactor=e,this.eventBus=I,this.documentIndexer=B,this}withSigner(e){return"signer"in e?(this.signer=e.signer,this.signatureVerifier=e.verifier):this.signer=e,this}withSubscriptionManager(e){return this.subscriptionManager=e,this}withJobAwaiter(e){return this.jobAwaiter=e,this}async build(){return(await this.buildModule()).client}async buildModule(){let e,I,B,tr;if(this.reactorBuilder)this.signatureVerifier&&this.reactorBuilder.withSignatureVerifier(this.signatureVerifier),tr=await this.reactorBuilder.buildModule(),e=tr.reactor,I=tr.eventBus,B=tr.documentIndexer;else if(this.reactor&&this.eventBus&&this.documentIndexer)e=this.reactor,I=this.eventBus,B=this.documentIndexer,tr=void 0;else throw new Error("Either ReactorBuilder or (Reactor + EventBus + DocumentIndexer) is required");const rr=this.signer??new PassthroughSigner,ir=this.subscriptionManager??new ReactorSubscriptionManager(new DefaultSubscriptionErrorHandler),lr=this.jobAwaiter??new JobAwaiter(I,(mr,hr)=>e.getJobStatus(mr,hr));return{client:new ReactorClient(e,rr,ir,lr,B),reactor:e,eventBus:I,documentIndexer:B,signer:rr,subscriptionManager:ir,jobAwaiter:lr,reactorModule:tr}}}function rowToRemoteCursor(t){return{remoteName:t.remote_name,cursorOrdinal:Number(t.cursor_ordinal),lastSyncedAtUtcMs:t.last_synced_at_utc_ms?Number(t.last_synced_at_utc_ms):void 0}}function remoteCursorToRow(t){return{remote_name:t.remoteName,cursor_ordinal:BigInt(t.cursorOrdinal),last_synced_at_utc_ms:t.lastSyncedAtUtcMs?BigInt(t.lastSyncedAtUtcMs):null}}class KyselySyncCursorStorage{db;constructor(e){this.db=e}async list(e,I){if(I?.aborted)throw new Error("Operation aborted");const B=await this.db.selectFrom("sync_cursors").selectAll().where("remote_name","=",e).execute();if(I?.aborted)throw new Error("Operation aborted");return B.map(rowToRemoteCursor)}async get(e,I){if(I?.aborted)throw new Error("Operation aborted");const B=await this.db.selectFrom("sync_cursors").selectAll().where("remote_name","=",e).executeTakeFirst();if(I?.aborted)throw new Error("Operation aborted");return B?rowToRemoteCursor(B):{remoteName:e,cursorOrdinal:0}}async upsert(e,I){if(I?.aborted)throw new Error("Operation aborted");if(await this.db.transaction().execute(async B=>{const tr=remoteCursorToRow(e);await B.insertInto("sync_cursors").values(tr).onConflict(rr=>rr.column("remote_name").doUpdateSet({...tr,updated_at:sql`NOW()`})).execute()}),I?.aborted)throw new Error("Operation aborted")}async remove(e,I){if(I?.aborted)throw new Error("Operation aborted");if(await this.db.transaction().execute(async B=>{await B.deleteFrom("sync_cursors").where("remote_name","=",e).execute()}),I?.aborted)throw new Error("Operation aborted")}}function rowToRemoteRecord(t){return{id:t.channel_id,name:t.name,collectionId:t.collection_id,channelConfig:{type:t.channel_type,parameters:t.channel_parameters??{}},filter:{documentId:t.filter_document_ids??[],scope:t.filter_scopes??[],branch:t.filter_branch},options:{},status:{push:{state:t.push_state,lastSuccessUtcMs:t.push_last_success_utc_ms?Number(t.push_last_success_utc_ms):void 0,lastFailureUtcMs:t.push_last_failure_utc_ms?Number(t.push_last_failure_utc_ms):void 0,failureCount:t.push_failure_count},pull:{state:t.pull_state,lastSuccessUtcMs:t.pull_last_success_utc_ms?Number(t.pull_last_success_utc_ms):void 0,lastFailureUtcMs:t.pull_last_failure_utc_ms?Number(t.pull_last_failure_utc_ms):void 0,failureCount:t.pull_failure_count}}}}function remoteRecordToRow(t){return{name:t.name,collection_id:t.collectionId,channel_type:t.channelConfig.type,channel_id:t.id,remote_name:t.name,channel_parameters:t.channelConfig.parameters,filter_document_ids:t.filter.documentId.length>0?t.filter.documentId:null,filter_scopes:t.filter.scope.length>0?t.filter.scope:null,filter_branch:t.filter.branch,push_state:t.status.push.state,push_last_success_utc_ms:t.status.push.lastSuccessUtcMs?BigInt(t.status.push.lastSuccessUtcMs):null,push_last_failure_utc_ms:t.status.push.lastFailureUtcMs?BigInt(t.status.push.lastFailureUtcMs):null,push_failure_count:t.status.push.failureCount,pull_state:t.status.pull.state,pull_last_success_utc_ms:t.status.pull.lastSuccessUtcMs?BigInt(t.status.pull.lastSuccessUtcMs):null,pull_last_failure_utc_ms:t.status.pull.lastFailureUtcMs?BigInt(t.status.pull.lastFailureUtcMs):null,pull_failure_count:t.status.pull.failureCount}}class KyselySyncRemoteStorage{db;constructor(e){this.db=e}async list(e){if(e?.aborted)throw new Error("Operation aborted");const I=await this.db.selectFrom("sync_remotes").selectAll().execute();if(e?.aborted)throw new Error("Operation aborted");return I.map(rowToRemoteRecord)}async get(e,I){if(I?.aborted)throw new Error("Operation aborted");const B=await this.db.selectFrom("sync_remotes").selectAll().where("name","=",e).executeTakeFirst();if(I?.aborted)throw new Error("Operation aborted");if(!B)throw new Error(`Remote not found: ${e}`);return rowToRemoteRecord(B)}async upsert(e,I){if(I?.aborted)throw new Error("Operation aborted");if(await this.db.transaction().execute(async B=>{const tr=remoteRecordToRow(e);await B.insertInto("sync_remotes").values(tr).onConflict(rr=>rr.column("name").doUpdateSet({...tr,updated_at:sql`NOW()`})).execute()}),I?.aborted)throw new Error("Operation aborted")}async remove(e,I){if(I?.aborted)throw new Error("Operation aborted");if(await this.db.transaction().execute(async B=>{await B.deleteFrom("sync_remotes").where("name","=",e).execute()}),I?.aborted)throw new Error("Operation aborted")}}var SyncOperationStatus;(function(t){t[t.Unknown=-1]="Unknown",t[t.TransportPending=0]="TransportPending",t[t.ExecutionPending=1]="ExecutionPending",t[t.Applied=2]="Applied",t[t.Error=3]="Error"})(SyncOperationStatus||(SyncOperationStatus={}));var ChannelErrorSource;(function(t){t.None="none",t.Channel="channel",t.Inbox="inbox",t.Outbox="outbox"})(ChannelErrorSource||(ChannelErrorSource={}));class SyncOperationAggregateError extends Error{errors;constructor(e){const I=e.map(B=>B.message).join("; ");super(`SyncOperation callback failed with ${e.length} error(s): ${I}`),this.name="SyncOperationAggregateError",this.errors=e}}class SyncOperation{id;remoteName;documentId;scopes;branch;operations;status;error;callbacks=[];constructor(e,I,B,tr,rr,ir){this.id=e,this.remoteName=I,this.documentId=B,this.scopes=tr,this.branch=rr,this.operations=ir,this.status=SyncOperationStatus.Unknown}on(e){this.callbacks.push(e)}started(){this.transition(SyncOperationStatus.TransportPending)}transported(){this.transition(SyncOperationStatus.ExecutionPending)}executed(){this.transition(SyncOperationStatus.Applied)}failed(e){this.error=e,this.transition(SyncOperationStatus.Error)}transition(e){const I=this.status;this.status=e;const B=[];for(const tr of this.callbacks)try{tr(this,I,e)}catch(rr){B.push(rr instanceof Error?rr:new Error(String(rr)))}if(B.length>0)throw new SyncOperationAggregateError(B)}}class MailboxAggregateError extends Error{errors;constructor(e){const I=e.map(B=>B.message).join("; ");super(`Mailbox callback failed with ${e.length} error(s): ${I}`),this.name="MailboxAggregateError",this.errors=e}}class Mailbox{itemsMap=new Map;addedCallbacks=[];removedCallbacks=[];get items(){return Array.from(this.itemsMap.values())}get(e){return this.itemsMap.get(e)}add(e){this.itemsMap.set(e.id,e);const I=[...this.addedCallbacks],B=[];for(const tr of I)try{tr(e)}catch(rr){B.push(rr instanceof Error?rr:new Error(String(rr)))}if(B.length>0)throw new MailboxAggregateError(B)}remove(e){this.itemsMap.delete(e.id);const I=[...this.removedCallbacks],B=[];for(const tr of I)try{tr(e)}catch(rr){B.push(rr instanceof Error?rr:new Error(String(rr)))}if(B.length>0)throw new MailboxAggregateError(B)}onAdded(e){this.addedCallbacks.push(e)}onRemoved(e){this.removedCallbacks.push(e)}}class ChannelError extends Error{source;error;constructor(e,I){super(`ChannelError[${e}]: ${I.message}`),this.name="ChannelError",this.source=e,this.error=I}}let syncOpCounter=0;function envelopeToSyncOperation(t,e){if(!t.operations||t.operations.length===0)throw new Error("Cannot create SyncOperation from envelope without operations");const I=t.operations,B=I[0],tr=B.context.documentId,rr=B.context.branch,ir=[...new Set(I.map(dr=>dr.context.scope))],lr=`syncop-${t.channelMeta.id}-${Date.now()}-${syncOpCounter++}`;return new SyncOperation(lr,e,tr,ir,rr,I)}class GqlChannel{inbox;outbox;deadLetter;channelId;remoteName;cursorStorage;config;isShutdown;pollTimer;failureCount;lastSuccessUtcMs;lastFailureUtcMs;constructor(e,I,B,tr){this.channelId=e,this.remoteName=I,this.cursorStorage=B,this.config={url:tr.url,authToken:tr.authToken,pollIntervalMs:tr.pollIntervalMs??5e3,retryBaseDelayMs:tr.retryBaseDelayMs??1e3,retryMaxDelayMs:tr.retryMaxDelayMs??3e5,maxFailures:tr.maxFailures??5,fetchFn:tr.fetchFn,collectionId:tr.collectionId,filter:tr.filter},this.isShutdown=!1,this.failureCount=0,this.inbox=new Mailbox,this.outbox=new Mailbox,this.deadLetter=new Mailbox,this.outbox.onAdded(rr=>{this.handleOutboxAdded(rr)})}shutdown(){this.isShutdown=!0,this.pollTimer&&(clearTimeout(this.pollTimer),this.pollTimer=void 0)}async init(){await this.touchRemoteChannel(),this.startPolling()}startPolling(){this.isShutdown||(this.pollTimer=setTimeout(()=>{this.poll().then(()=>{this.startPolling()})},this.config.pollIntervalMs))}async poll(){if(this.isShutdown||this.failureCount>=this.config.maxFailures)return;let e;try{e=await this.cursorStorage.get(this.remoteName)}catch(tr){this.handlePollError(tr);return}const I=e.cursorOrdinal;let B;try{B=await this.pollSyncEnvelopes(I)}catch(tr){this.handlePollError(tr);return}for(const tr of B)if(tr.type==="operations"&&tr.operations){const rr=envelopeToSyncOperation(tr,this.remoteName);rr.transported(),this.inbox.add(rr)}this.lastSuccessUtcMs=Date.now(),this.failureCount=0}handlePollError(e){this.failureCount++,this.lastFailureUtcMs=Date.now();const I=e instanceof Error?e:new Error(String(e)),B=new ChannelError(ChannelErrorSource.Inbox,I);console.error(`GqlChannel poll error (${this.failureCount}/${this.config.maxFailures}):`,B),this.failureCount>=this.config.maxFailures&&console.error(`GqlChannel ${this.channelId} exceeded failure threshold, stopping polls`)}async pollSyncEnvelopes(e){const I=`
24
24
  query PollSyncEnvelopes($channelId: String!, $cursorOrdinal: Int!) {