@verdocs/web-sdk 5.0.24 → 5.0.27
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/{Datastore-931fd77e.js → Datastore-e39f8315.js} +29 -24
- package/dist/cjs/Datastore-e39f8315.js.map +1 -0
- package/dist/cjs/verdocs-build.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-checkbox_6.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-envelope-recipient-link_2.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-envelope-recipient-summary.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-envelope-sidebar.cjs.entry.js +25 -1
- package/dist/cjs/verdocs-envelope-sidebar.cjs.entry.js.map +1 -1
- package/dist/cjs/verdocs-field-attachment_13.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-field-payment.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-kba-dialog_2.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-menu-panel_2.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-preview_6.cjs.entry.js +5 -2
- package/dist/cjs/verdocs-preview_6.cjs.entry.js.map +1 -1
- package/dist/cjs/verdocs-sign.cjs.entry.js +7 -7
- package/dist/cjs/verdocs-sign.cjs.entry.js.map +1 -1
- package/dist/cjs/verdocs-template-document-page_2.cjs.entry.js +1 -1
- package/dist/collection/components/embeds/verdocs-sign/verdocs-sign.css +1 -1
- package/dist/collection/components/embeds/verdocs-sign/verdocs-sign.js +5 -5
- package/dist/collection/components/embeds/verdocs-sign/verdocs-sign.js.map +1 -1
- package/dist/collection/components/envelopes/verdocs-envelope-sidebar/verdocs-envelope-sidebar.js +24 -0
- package/dist/collection/components/envelopes/verdocs-envelope-sidebar/verdocs-envelope-sidebar.js.map +1 -1
- package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.js +4 -1
- package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.js.map +1 -1
- package/dist/components/{p-78de9e65.js → p-0e4ebc84.js} +3 -3
- package/dist/components/{p-78de9e65.js.map → p-0e4ebc84.js.map} +1 -1
- package/dist/components/{p-e4a97ad5.js → p-143a763f.js} +3 -3
- package/dist/components/{p-e4a97ad5.js.map → p-143a763f.js.map} +1 -1
- package/dist/components/{p-2d8b46e5.js → p-16b073b8.js} +2 -2
- package/dist/components/{p-2d8b46e5.js.map → p-16b073b8.js.map} +1 -1
- package/dist/components/{p-e9528d9f.js → p-1d4829fb.js} +3 -3
- package/dist/components/{p-e9528d9f.js.map → p-1d4829fb.js.map} +1 -1
- package/dist/components/{p-ca3e45f3.js → p-27a8eef0.js} +2 -2
- package/dist/components/{p-ca3e45f3.js.map → p-27a8eef0.js.map} +1 -1
- package/dist/components/{p-fcf13666.js → p-550377ba.js} +13 -13
- package/dist/components/{p-fcf13666.js.map → p-550377ba.js.map} +1 -1
- package/dist/components/{p-1ce18a42.js → p-619747d7.js} +2 -2
- package/dist/components/{p-1ce18a42.js.map → p-619747d7.js.map} +1 -1
- package/dist/components/{p-e95ded6b.js → p-631808d5.js} +18 -15
- package/dist/components/p-631808d5.js.map +1 -0
- package/dist/components/{p-e4799d51.js → p-7bd7baa6.js} +3 -3
- package/dist/components/{p-e4799d51.js.map → p-7bd7baa6.js.map} +1 -1
- package/dist/components/{p-1ab01232.js → p-813ed998.js} +3 -3
- package/dist/components/{p-1ab01232.js.map → p-813ed998.js.map} +1 -1
- package/dist/components/{p-a415ce22.js → p-8c965486.js} +3 -3
- package/dist/components/{p-a415ce22.js.map → p-8c965486.js.map} +1 -1
- package/dist/components/{p-681e7dd4.js → p-99128b47.js} +3 -3
- package/dist/components/{p-681e7dd4.js.map → p-99128b47.js.map} +1 -1
- package/dist/components/{p-53168eec.js → p-ac7694c0.js} +2 -2
- package/dist/components/{p-53168eec.js.map → p-ac7694c0.js.map} +1 -1
- package/dist/components/{p-ecfc85ae.js → p-b5e479db.js} +3 -3
- package/dist/components/{p-ecfc85ae.js.map → p-b5e479db.js.map} +1 -1
- package/dist/components/{p-f6156f7a.js → p-c422d9a0.js} +3 -3
- package/dist/components/{p-f6156f7a.js.map → p-c422d9a0.js.map} +1 -1
- package/dist/components/{p-c4c9feda.js → p-c4310332.js} +3 -3
- package/dist/components/{p-c4c9feda.js.map → p-c4310332.js.map} +1 -1
- package/dist/components/{p-91d65fde.js → p-c5045788.js} +3 -3
- package/dist/components/{p-91d65fde.js.map → p-c5045788.js.map} +1 -1
- package/dist/components/{p-3828cb31.js → p-d4be87ef.js} +29 -24
- package/dist/components/p-d4be87ef.js.map +1 -0
- package/dist/components/{p-28e3b2e3.js → p-d54466ed.js} +14 -14
- package/dist/components/{p-28e3b2e3.js.map → p-d54466ed.js.map} +1 -1
- package/dist/components/{p-eb2ad8d0.js → p-e39c327c.js} +2 -2
- package/dist/components/{p-eb2ad8d0.js.map → p-e39c327c.js.map} +1 -1
- package/dist/components/{p-eb12a71c.js → p-f238b25b.js} +2 -2
- package/dist/components/{p-eb12a71c.js.map → p-f238b25b.js.map} +1 -1
- package/dist/components/{p-bfed2f8d.js → p-f7cf2401.js} +2 -2
- package/dist/components/{p-bfed2f8d.js.map → p-f7cf2401.js.map} +1 -1
- package/dist/components/verdocs-build.js +20 -20
- package/dist/components/verdocs-envelope-recipient-link.js +1 -1
- package/dist/components/verdocs-envelope-recipient-summary.js +1 -1
- package/dist/components/verdocs-envelope-sidebar.js +26 -2
- package/dist/components/verdocs-envelope-sidebar.js.map +1 -1
- package/dist/components/verdocs-field-attachment.js +1 -1
- package/dist/components/verdocs-field-checkbox.js +1 -1
- package/dist/components/verdocs-field-date.js +1 -1
- package/dist/components/verdocs-field-dropdown.js +1 -1
- package/dist/components/verdocs-field-initial.js +1 -1
- package/dist/components/verdocs-field-payment.js +2 -2
- package/dist/components/verdocs-field-radio.js +1 -1
- package/dist/components/verdocs-field-signature.js +1 -1
- package/dist/components/verdocs-field-textarea.js +1 -1
- package/dist/components/verdocs-field-textbox.js +1 -1
- package/dist/components/verdocs-field-timestamp.js +1 -1
- package/dist/components/verdocs-preview.js +1 -1
- package/dist/components/verdocs-send.js +1 -1
- package/dist/components/verdocs-sign.js +8 -8
- package/dist/components/verdocs-sign.js.map +1 -1
- package/dist/components/verdocs-template-attachments.js +1 -1
- package/dist/components/verdocs-template-build-tabs.js +1 -1
- package/dist/components/verdocs-template-document-page.js +1 -1
- package/dist/components/verdocs-template-field-properties.js +1 -1
- package/dist/components/verdocs-template-fields.js +1 -1
- package/dist/components/verdocs-template-role-properties.js +1 -1
- package/dist/components/verdocs-template-roles.js +1 -1
- package/dist/components/verdocs-view.js +1 -1
- package/dist/esm/{Datastore-3f924d94.js → Datastore-77cb8d9c.js} +29 -24
- package/dist/esm/Datastore-77cb8d9c.js.map +1 -0
- package/dist/esm/verdocs-build.entry.js +1 -1
- package/dist/esm/verdocs-checkbox_6.entry.js +1 -1
- package/dist/esm/verdocs-envelope-recipient-link_2.entry.js +1 -1
- package/dist/esm/verdocs-envelope-recipient-summary.entry.js +1 -1
- package/dist/esm/verdocs-envelope-sidebar.entry.js +25 -1
- package/dist/esm/verdocs-envelope-sidebar.entry.js.map +1 -1
- package/dist/esm/verdocs-field-attachment_13.entry.js +1 -1
- package/dist/esm/verdocs-field-payment.entry.js +1 -1
- package/dist/esm/verdocs-kba-dialog_2.entry.js +1 -1
- package/dist/esm/verdocs-menu-panel_2.entry.js +1 -1
- package/dist/esm/verdocs-preview_6.entry.js +5 -2
- package/dist/esm/verdocs-preview_6.entry.js.map +1 -1
- package/dist/esm/verdocs-sign.entry.js +7 -7
- package/dist/esm/verdocs-sign.entry.js.map +1 -1
- package/dist/esm/verdocs-template-document-page_2.entry.js +1 -1
- package/dist/esm-es5/Datastore-77cb8d9c.js +2 -0
- package/dist/esm-es5/Datastore-77cb8d9c.js.map +1 -0
- package/dist/esm-es5/verdocs-build.entry.js +1 -1
- package/dist/esm-es5/verdocs-checkbox_6.entry.js +1 -1
- package/dist/esm-es5/verdocs-envelope-recipient-link_2.entry.js +1 -1
- package/dist/esm-es5/verdocs-envelope-recipient-summary.entry.js +1 -1
- package/dist/esm-es5/verdocs-envelope-sidebar.entry.js +1 -1
- package/dist/esm-es5/verdocs-envelope-sidebar.entry.js.map +1 -1
- package/dist/esm-es5/verdocs-field-attachment_13.entry.js +1 -1
- package/dist/esm-es5/verdocs-field-payment.entry.js +1 -1
- package/dist/esm-es5/verdocs-kba-dialog_2.entry.js +1 -1
- package/dist/esm-es5/verdocs-menu-panel_2.entry.js +1 -1
- package/dist/esm-es5/verdocs-preview_6.entry.js +1 -1
- package/dist/esm-es5/verdocs-preview_6.entry.js.map +1 -1
- package/dist/esm-es5/verdocs-sign.entry.js +1 -1
- package/dist/esm-es5/verdocs-sign.entry.js.map +1 -1
- package/dist/esm-es5/verdocs-template-document-page_2.entry.js +1 -1
- package/dist/verdocs-web-sdk/{p-f6ed768d.entry.js → p-00063a35.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-1902bf04.entry.js → p-104863b5.entry.js} +2 -2
- package/dist/verdocs-web-sdk/p-1f2c019d.system.entry.js +2 -0
- package/dist/verdocs-web-sdk/p-1f2c019d.system.entry.js.map +1 -0
- package/dist/verdocs-web-sdk/{p-fc29a754.entry.js → p-25aa3bd3.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-b1a9dc79.entry.js → p-4e9a8e8e.entry.js} +2 -2
- package/dist/verdocs-web-sdk/p-4e9a8e8e.entry.js.map +1 -0
- package/dist/verdocs-web-sdk/p-52c3e8b0.system.js +2 -0
- package/dist/verdocs-web-sdk/p-52c3e8b0.system.js.map +1 -0
- package/dist/verdocs-web-sdk/{p-7975ec40.system.entry.js → p-578e65d4.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-407c0725.system.entry.js → p-5bcf921b.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-26106576.system.entry.js → p-5c065719.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-7ffebea3.entry.js → p-5ebfe76c.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-80952d72.system.entry.js → p-6e93814f.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/p-6e93814f.system.entry.js.map +1 -0
- package/dist/verdocs-web-sdk/{p-086ee7f1.system.entry.js → p-6eee289a.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-cc230abf.entry.js → p-6f1e2f2f.entry.js} +2 -2
- package/dist/verdocs-web-sdk/p-70247599.system.entry.js +2 -0
- package/dist/verdocs-web-sdk/p-70247599.system.entry.js.map +1 -0
- package/dist/verdocs-web-sdk/{p-e84cf41e.entry.js → p-8369273d.entry.js} +2 -2
- package/dist/verdocs-web-sdk/p-a285560f.entry.js +2 -0
- package/dist/verdocs-web-sdk/p-a285560f.entry.js.map +1 -0
- package/dist/verdocs-web-sdk/p-b7799ec0.entry.js +2 -0
- package/dist/verdocs-web-sdk/p-b7799ec0.entry.js.map +1 -0
- package/dist/verdocs-web-sdk/{p-a4d94e2e.entry.js → p-b8945173.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-d4aff253.entry.js → p-b9fee1a7.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-34c2298e.system.entry.js → p-cabfdb9d.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-90690dde.system.entry.js → p-d1d95df4.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-60da8e6b.entry.js → p-d3a8c6b8.entry.js} +2 -2
- package/dist/verdocs-web-sdk/p-d4be87ef.js +2 -0
- package/dist/verdocs-web-sdk/p-d4be87ef.js.map +1 -0
- package/dist/verdocs-web-sdk/p-e2b70dfb.system.js +1 -1
- package/dist/verdocs-web-sdk/{p-208a8b41.system.entry.js → p-e3efeb57.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-dc5c275f.system.entry.js → p-e83d06d4.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-32cf09f0.system.entry.js → p-ecfe8987.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
- package/package.json +3 -3
- package/dist/cjs/Datastore-931fd77e.js.map +0 -1
- package/dist/components/p-3828cb31.js.map +0 -1
- package/dist/components/p-e95ded6b.js.map +0 -1
- package/dist/esm/Datastore-3f924d94.js.map +0 -1
- package/dist/esm-es5/Datastore-3f924d94.js +0 -2
- package/dist/esm-es5/Datastore-3f924d94.js.map +0 -1
- package/dist/verdocs-web-sdk/p-2175c81a.system.entry.js +0 -2
- package/dist/verdocs-web-sdk/p-2175c81a.system.entry.js.map +0 -1
- package/dist/verdocs-web-sdk/p-23d6f064.entry.js +0 -2
- package/dist/verdocs-web-sdk/p-23d6f064.entry.js.map +0 -1
- package/dist/verdocs-web-sdk/p-3828cb31.js +0 -2
- package/dist/verdocs-web-sdk/p-3828cb31.js.map +0 -1
- package/dist/verdocs-web-sdk/p-65be7617.system.js +0 -2
- package/dist/verdocs-web-sdk/p-65be7617.system.js.map +0 -1
- package/dist/verdocs-web-sdk/p-80952d72.system.entry.js.map +0 -1
- package/dist/verdocs-web-sdk/p-b1a9dc79.entry.js.map +0 -1
- package/dist/verdocs-web-sdk/p-c4a10e58.system.entry.js +0 -2
- package/dist/verdocs-web-sdk/p-c4a10e58.system.entry.js.map +0 -1
- package/dist/verdocs-web-sdk/p-db1faf41.entry.js +0 -2
- package/dist/verdocs-web-sdk/p-db1faf41.entry.js.map +0 -1
- /package/dist/verdocs-web-sdk/{p-f6ed768d.entry.js.map → p-00063a35.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-1902bf04.entry.js.map → p-104863b5.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-fc29a754.entry.js.map → p-25aa3bd3.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-7975ec40.system.entry.js.map → p-578e65d4.system.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-407c0725.system.entry.js.map → p-5bcf921b.system.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-26106576.system.entry.js.map → p-5c065719.system.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-7ffebea3.entry.js.map → p-5ebfe76c.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-086ee7f1.system.entry.js.map → p-6eee289a.system.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-cc230abf.entry.js.map → p-6f1e2f2f.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-e84cf41e.entry.js.map → p-8369273d.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-a4d94e2e.entry.js.map → p-b8945173.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-d4aff253.entry.js.map → p-b9fee1a7.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-34c2298e.system.entry.js.map → p-cabfdb9d.system.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-90690dde.system.entry.js.map → p-d1d95df4.system.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-60da8e6b.entry.js.map → p-d3a8c6b8.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-208a8b41.system.entry.js.map → p-e3efeb57.system.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-dc5c275f.system.entry.js.map → p-e83d06d4.system.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-32cf09f0.system.entry.js.map → p-ecfe8987.system.entry.js.map} +0 -0
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["getTypeOf","thing","EMPTY_STRING","STRING","BOOLEAN","NUMBER","FUNCTION","TYPE","DEFAULT","LISTENER","ADD","HAS","IDS","TABLE","TABLES","TABLE_IDS","ROW","ROW_COUNT","ROW_IDS","CELL","CELL_IDS","VALUE","VALUES","VALUE_IDS","id","key","isFiniteNumber","isFinite","isInstanceOf","cls","isUndefined","ifNotUndefined","value","then","otherwise","isTypeStringOrBoolean","type","isFunction","isArray","Array","slice","arrayOrString","start","end","size","length","test","regex","subject","arrayHas","array","includes","arrayEvery","cb","every","arrayIsEqual","array1","array2","value1","index","arraySort","sorter","sort","arrayForEach","forEach","arrayMap","map","arrayReduce","initial","reduce","arrayPush","values","_i","arguments","push","apply","arrayShift","shift","object","Object","getPrototypeOf","obj","objEntries","entries","objFrozen","isFrozen","isObject","objPrototype","prototype","objIds","keys","objFreeze","freeze","objHas","objDel","objToArray","_a","objSize","objIsEmpty","objValidate","validateChild","onInvalidObj","emptyIsValid","child","collSizeN","collSizer","coll","collValues","total","coll2","collSize","collSize2","collSize3","collSize4","collHas","keyOrValue","has","collIsEmpty","__spreadArray","collClear","clear","collForEach","collDel","delete","mapNew","Map","mapKeys","mapGet","get","mapForEach","mapMap","mapSet","set","mapEnsure","getDefaultValue","hadExistingValue","mapMatch","del","mapToObj","valueMapper","excludeMapValue","excludeObjValue","mapValue","objValue","mapToObj2","childMap","mapToObj3","mapClone","map2","mapClone2","mapClone3","visitTree","node","path","ensureLeaf","pruneLeaf","p","nodeOrLeaf","leaf","getCellOrValueType","cellOrValue","setOrDelCell","store","tableId","rowId","cellId","cell","delCell","setCell","setOrDelValue","valueId","delValue","setValue","setNew","entryOrEntries","Set","setAdd","add","INTEGER","getPoolFunctions","pool","nextId","reuse","getWildcardedLeaves","deepIdSet","leaves","deep","node2","getListenerFunctions","getThing","getId","releaseId","allListeners","addListener","listener","idSetNode","pathGetters","extraArgsGetter","callListeners","ids","extraArgs","delListener","idOrNulls","idSet","callListener","_b","callWithIds","call","id2","defaultSorter","sortKey1","sortKey2","pairNew","pairCollSize2","pair","func","pairNewMap","pairClone","pairIsEqual","entry1","entry2","jsonString","JSON","stringify","jsonParse","parse","jsonStringWithMap","_key","fromEntries","idsChanged","changedIds","addedOrRemoved","createStore","hasTablesSchema","hasValuesSchema","hadTables","hadValues","transactions","internalListeners","changedTableIds","changedTableCellIds","changedRowCount","changedRowIds","changedCellIds","changedCells","changedValueIds","changedValues","invalidCells","invalidValues","tablesSchemaMap","tablesSchemaRowCache","valuesSchemaMap","valuesDefaulted","valuesNonDefaulted","tablePoolFunctions","tableCellIds","tablesMap","valuesMap","hasTablesListeners","tablesListeners","tableIdsListeners","hasTableListeners","tableListeners","tableCellIdsListeners","hasTableCellListeners","rowCountListeners","rowIdsListeners","sortedRowIdsListeners","hasRowListeners","rowListeners","cellIdsListeners","hasCellListeners","cellListeners","invalidCellListeners","invalidValueListeners","hasValuesListeners","valuesListeners","valueIdsListeners","hasValueListeners","valueListeners","startTransactionListeners","finishTransactionListeners","delListenerImpl","callListenerImpl","validateTablesSchema","tableSchema","tableSchema2","validateCellOrValueSchema","validateValuesSchema","valuesSchema","schema","_child","validateContent","validateTables","tables","validateTable","cellInvalid","table","row","validateRow","skipDefaults","addDefaultsToRow","getValidatedCell","validCell","cellSchema","validateValues","addDefaultsToValues","getValidatedValue","validValue","valueInvalid","valueSchema","rowDefaulted","rowNonDefaulted","setValidTablesSchema","tablesSchema","_tablesSchema","tableSchemaMap","def","setValidValuesSchema","_valuesSchema","setOrDelTables","delTables","setTables","setValidContent","delValues","setValues","setValidTables","_tables","setValidTable","delValidTable","tableIdsChanged","tableMap","setValidRow","delValidRow","forceDel","rowIdsChanged","rowMap","setValidCell","delValidCell","cellIdsChanged","oldCell","cellChanged","setCellIntoDefaultRow","setOrDelValues","setValidValues","_valuesMap","setValidValue","delValidValue","valueIdsChanged","oldValue","valueChanged","getNewRowId","getOrCreateTable","defaultCell","delCell2","cellId2","defaultValue","cellIds","count","newCell","newValue","invalidCell","defaultedCell","invalidValue","defaultedValue","getCellChange","getCell","getValueChange","getValue","callInvalidCellListeners","mutator","rows","cells","callInvalidValueListeners","callIdsAndHasListenersIfChanged","idListeners","hasListeners","changedId","changed","callTabularListenersForChanges","hasTablesNow","hasTables","emptySortedRowIdListeners","emptyIdAndHasListeners","emptyOtherListeners","changes","changedCount","getRowCount","calledSortableTableIds_1","sortableCellIds_1","rowCellIds","tablesChanged_1","tableChanged","rowChanged","callValuesListenersForChanges","hasValuesNow","hasValues","valuesChanged_1","fluentTransaction","actions","args","transaction","getContent","getTables","getValues","getTableIds","getTable","getTableCellIds","getRowIds","getSortedRowIds","descending","offset","limit","cell1","cell2","getRow","getCellIds","getValueIds","hasTable","hasTableCell","hasRow","hasCell","hasValue","getTablesJson","getValuesJson","getJson","getTablesSchemaJson","getValuesSchemaJson","getSchemaJson","setContent","content","content2","setTable","tableId2","setRow","rowId2","addRow","reuseRowIds","setPartialRow","partialRow","table_1","setPartialValues","partialValues","valueId2","applyChanges","delTable","delRow","setTablesJson","tablesJson","setValuesJson","valuesJson","setJson","tablesAndValuesJson","setTablesSchema","setValuesSchema","delValuesSchema","setSchema","delTablesSchema","delSchema","doRollback","startTransaction","result","finishTransaction","getTransactionChanges","changedCell","changedValue","getTransactionLog","forEachTable","tableCallback","rowCallback","cellCallback","forEachTableCell","tableCellCallback","forEachRow","forEachCell","forEachValue","valueCallback","addSortedRowIdsListener","sortedRowIds","newSortedRowIds","addStartTransactionListener","addWillFinishTransactionListener","addDidFinishTransactionListener","listenerId","getListenerStats","tableIds","rowCount","rowIds","valueIds","setInternalListeners","preStartTransaction","preFinishTransaction","postFinishTransaction","cellChanged2","valueChanged2","isMergeable","InvalidCell","InvalidValue","listenable","argumentCount","console","log","safeJsonParse","val","fallback","e","objectToRow","concat","rowToObject","startsWith","replace","Store","subscribe","getter","forceReload","callback","addRowListener","catch","error","unsubscribe","getTemplate","endpoint_1","templateId_1","endpoint","templateId","reload","template","sent","updateTemplate","getEnvelope","envelopeId_1","envelopeId","envelope","updateEnvelope","getField","source","sourceId","fieldName","fieldOverride","field_1","fields","find","field","name","roleNames","roles","role","findIndex","role_name","Math","max","field_2","recipients","recipient"],"sources":["node_modules/tinybase/index.js","src/utils/Datastore.ts"],"sourcesContent":["const getTypeOf = (thing) => typeof thing;\nconst EMPTY_STRING = '';\nconst STRING = getTypeOf(EMPTY_STRING);\nconst BOOLEAN = getTypeOf(true);\nconst NUMBER = getTypeOf(0);\nconst FUNCTION = getTypeOf(getTypeOf);\nconst TYPE = 'type';\nconst DEFAULT = 'default';\nconst SUM = 'sum';\nconst AVG = 'avg';\nconst MIN = 'min';\nconst MAX = 'max';\nconst LISTENER = 'Listener';\nconst RESULT = 'Result';\nconst GET = 'get';\nconst SET = 'set';\nconst ADD = 'add';\nconst DEL = 'del';\nconst HAS = 'Has';\nconst IDS = 'Ids';\nconst TABLE = 'Table';\nconst TABLES = TABLE + 's';\nconst TABLE_IDS = TABLE + IDS;\nconst ROW = 'Row';\nconst ROW_COUNT = ROW + 'Count';\nconst ROW_IDS = ROW + IDS;\nconst SORTED_ROW_IDS = 'Sorted' + ROW + IDS;\nconst CELL = 'Cell';\nconst CELL_IDS = CELL + IDS;\nconst VALUE = 'Value';\nconst VALUES = VALUE + 's';\nconst VALUE_IDS = VALUE + IDS;\nconst TRANSACTION = 'Transaction';\nconst id = (key) => EMPTY_STRING + key;\nconst strStartsWith = (str, prefix) => str.startsWith(prefix);\nconst strEndsWith = (str, suffix) => str.endsWith(suffix);\nconst strSplit = (str, separator = EMPTY_STRING, limit) =>\n str.split(separator, limit);\n\nconst GLOBAL = globalThis;\nconst math = Math;\nconst mathMax = math.max;\nconst mathMin = math.min;\nconst mathFloor = math.floor;\nconst isFiniteNumber = isFinite;\nconst isInstanceOf = (thing, cls) => thing instanceof cls;\nconst isUndefined = (thing) => thing == void 0;\nconst ifNotUndefined = (value, then, otherwise) =>\n isUndefined(value) ? otherwise?.() : then(value);\nconst isTypeStringOrBoolean = (type) => type == STRING || type == BOOLEAN;\nconst isString = (thing) => getTypeOf(thing) == STRING;\nconst isFunction = (thing) => getTypeOf(thing) == FUNCTION;\nconst isArray = (thing) => Array.isArray(thing);\nconst slice = (arrayOrString, start, end) => arrayOrString.slice(start, end);\nconst size = (arrayOrString) => arrayOrString.length;\nconst test = (regex, subject) => regex.test(subject);\nconst getUndefined = () => void 0;\n\nconst arrayHas = (array, value) => array.includes(value);\nconst arrayEvery = (array, cb) => array.every(cb);\nconst arrayIsEqual = (array1, array2) =>\n size(array1) === size(array2) &&\n arrayEvery(array1, (value1, index) => array2[index] === value1);\nconst arrayIsSorted = (array, sorter) =>\n arrayEvery(\n array,\n (value, index) => index == 0 || sorter(array[index - 1], value) <= 0,\n );\nconst arraySort = (array, sorter) => array.sort(sorter);\nconst arrayForEach = (array, cb) => array.forEach(cb);\nconst arrayMap = (array, cb) => array.map(cb);\nconst arraySum = (array) => arrayReduce(array, (i, j) => i + j, 0);\nconst arrayIsEmpty = (array) => size(array) == 0;\nconst arrayReduce = (array, cb, initial) => array.reduce(cb, initial);\nconst arrayClear = (array, to) => array.splice(0, to);\nconst arrayPush = (array, ...values) => array.push(...values);\nconst arrayPop = (array) => array.pop();\nconst arrayUnshift = (array, ...values) => array.unshift(...values);\nconst arrayShift = (array) => array.shift();\n\nconst object = Object;\nconst getPrototypeOf = (obj) => object.getPrototypeOf(obj);\nconst objEntries = object.entries;\nconst objFrozen = object.isFrozen;\nconst isObject = (obj) =>\n !isUndefined(obj) &&\n ifNotUndefined(\n getPrototypeOf(obj),\n (objPrototype) =>\n objPrototype == object.prototype ||\n isUndefined(getPrototypeOf(objPrototype)),\n\n /* istanbul ignore next */\n () => true,\n );\nconst objIds = object.keys;\nconst objFreeze = object.freeze;\nconst objNew = (entries = []) => object.fromEntries(entries);\nconst objHas = (obj, id) => id in obj;\nconst objDel = (obj, id) => {\n delete obj[id];\n return obj;\n};\nconst objForEach = (obj, cb) =>\n arrayForEach(objEntries(obj), ([id, value]) => cb(value, id));\nconst objToArray = (obj, cb) =>\n arrayMap(objEntries(obj), ([id, value]) => cb(value, id));\nconst objSize = (obj) => size(objIds(obj));\nconst objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;\nconst objEnsure = (obj, id, getDefaultValue) => {\n if (!objHas(obj, id)) {\n obj[id] = getDefaultValue();\n }\n return obj[id];\n};\nconst objValidate = (obj, validateChild, onInvalidObj, emptyIsValid = 0) => {\n if (\n isUndefined(obj) ||\n !isObject(obj) ||\n (!emptyIsValid && objIsEmpty(obj)) ||\n objFrozen(obj)\n ) {\n onInvalidObj?.();\n return false;\n }\n objToArray(obj, (child, id) => {\n if (!validateChild(child, id)) {\n objDel(obj, id);\n }\n });\n return emptyIsValid ? true : !objIsEmpty(obj);\n};\n\nconst collSizeN = (collSizer) => (coll) =>\n arrayReduce(collValues(coll), (total, coll2) => total + collSizer(coll2), 0);\nconst collSize = (coll) => coll?.size ?? 0;\nconst collSize2 = collSizeN(collSize);\nconst collSize3 = collSizeN(collSize2);\nconst collSize4 = collSizeN(collSize3);\nconst collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;\nconst collIsEmpty = (coll) => isUndefined(coll) || collSize(coll) == 0;\nconst collValues = (coll) => [...(coll?.values() ?? [])];\nconst collClear = (coll) => coll.clear();\nconst collForEach = (coll, cb) => coll?.forEach(cb);\nconst collDel = (coll, keyOrValue) => coll?.delete(keyOrValue);\n\nconst mapNew = (entries) => new Map(entries);\nconst mapKeys = (map) => [...(map?.keys() ?? [])];\nconst mapGet = (map, key) => map?.get(key);\nconst mapForEach = (map, cb) =>\n collForEach(map, (value, key) => cb(key, value));\nconst mapMap = (coll, cb) =>\n arrayMap([...(coll?.entries() ?? [])], ([key, value]) => cb(value, key));\nconst mapSet = (map, key, value) =>\n isUndefined(value) ? (collDel(map, key), map) : map?.set(key, value);\nconst mapEnsure = (map, key, getDefaultValue, hadExistingValue) => {\n if (!collHas(map, key)) {\n mapSet(map, key, getDefaultValue());\n } else {\n hadExistingValue?.(mapGet(map, key));\n }\n return mapGet(map, key);\n};\nconst mapMatch = (map, obj, set, del = mapSet) => {\n objToArray(obj, (value, id) => set(map, id, value));\n mapForEach(map, (id) => (objHas(obj, id) ? 0 : del(map, id)));\n return map;\n};\nconst mapToObj = (map, valueMapper, excludeMapValue, excludeObjValue) => {\n const obj = {};\n collForEach(map, (mapValue, id) => {\n if (!excludeMapValue?.(mapValue, id)) {\n const objValue = valueMapper ? valueMapper(mapValue, id) : mapValue;\n if (!excludeObjValue?.(objValue)) {\n obj[id] = objValue;\n }\n }\n });\n return obj;\n};\nconst mapToObj2 = (map, valueMapper, excludeMapValue) =>\n mapToObj(\n map,\n (childMap) => mapToObj(childMap, valueMapper, excludeMapValue),\n collIsEmpty,\n objIsEmpty,\n );\nconst mapToObj3 = (map, valueMapper, excludeMapValue) =>\n mapToObj(\n map,\n (childMap) => mapToObj2(childMap, valueMapper, excludeMapValue),\n collIsEmpty,\n objIsEmpty,\n );\nconst mapClone = (map, mapValue) => {\n const map2 = mapNew();\n collForEach(map, (value, key) => map2.set(key, mapValue?.(value) ?? value));\n return map2;\n};\nconst mapClone2 = (map) => mapClone(map, mapClone);\nconst mapClone3 = (map) => mapClone(map, mapClone2);\nconst visitTree = (node, path, ensureLeaf, pruneLeaf, p = 0) =>\n ifNotUndefined(\n (ensureLeaf ? mapEnsure : mapGet)(\n node,\n path[p],\n p > size(path) - 2 ? ensureLeaf : mapNew,\n ),\n (nodeOrLeaf) => {\n if (p > size(path) - 2) {\n if (pruneLeaf?.(nodeOrLeaf)) {\n mapSet(node, path[p]);\n }\n return nodeOrLeaf;\n }\n const leaf = visitTree(nodeOrLeaf, path, ensureLeaf, pruneLeaf, p + 1);\n if (collIsEmpty(nodeOrLeaf)) {\n mapSet(node, path[p]);\n }\n return leaf;\n },\n );\n\nconst getCellOrValueType = (cellOrValue) => {\n const type = getTypeOf(cellOrValue);\n return isTypeStringOrBoolean(type) ||\n (type == NUMBER && isFiniteNumber(cellOrValue))\n ? type\n : void 0;\n};\nconst isCellOrValueOrNullOrUndefined = (cellOrValue) =>\n isUndefined(cellOrValue) || !isUndefined(getCellOrValueType(cellOrValue));\nconst setOrDelCell = (store, tableId, rowId, cellId, cell) =>\n isUndefined(cell)\n ? store.delCell(tableId, rowId, cellId, true)\n : store.setCell(tableId, rowId, cellId, cell);\nconst setOrDelValue = (store, valueId, value) =>\n isUndefined(value) ? store.delValue(valueId) : store.setValue(valueId, value);\n\nconst setNew = (entryOrEntries) =>\n new Set(\n isArray(entryOrEntries) || isUndefined(entryOrEntries)\n ? entryOrEntries\n : [entryOrEntries],\n );\nconst setAdd = (set, value) => set?.add(value);\n\nconst getDefinableFunctions = (\n store,\n getDefaultThing,\n validateRowValue,\n addListener,\n callListeners,\n) => {\n const hasRow = store.hasRow;\n const tableIds = mapNew();\n const things = mapNew();\n const thingIdListeners = mapNew();\n const allRowValues = mapNew();\n const allSortKeys = mapNew();\n const storeListenerIds = mapNew();\n const getStore = () => store;\n const getThingIds = () => mapKeys(tableIds);\n const forEachThing = (cb) => mapForEach(things, cb);\n const hasThing = (id) => collHas(things, id);\n const getTableId = (id) => mapGet(tableIds, id);\n const getThing = (id) => mapGet(things, id);\n const setThing = (id, thing) => mapSet(things, id, thing);\n const addStoreListeners = (id, andCall, ...listenerIds) => {\n const set = mapEnsure(storeListenerIds, id, setNew);\n arrayForEach(\n listenerIds,\n (listenerId) =>\n setAdd(set, listenerId) && andCall && store.callListener(listenerId),\n );\n return listenerIds;\n };\n const delStoreListeners = (id, ...listenerIds) =>\n ifNotUndefined(mapGet(storeListenerIds, id), (allListenerIds) => {\n arrayForEach(\n arrayIsEmpty(listenerIds) ? collValues(allListenerIds) : listenerIds,\n (listenerId) => {\n store.delListener(listenerId);\n collDel(allListenerIds, listenerId);\n },\n );\n if (collIsEmpty(allListenerIds)) {\n mapSet(storeListenerIds, id);\n }\n });\n const setDefinition = (id, tableId) => {\n mapSet(tableIds, id, tableId);\n if (!collHas(things, id)) {\n mapSet(things, id, getDefaultThing());\n mapSet(allRowValues, id, mapNew());\n mapSet(allSortKeys, id, mapNew());\n callListeners(thingIdListeners);\n }\n };\n const setDefinitionAndListen = (\n id,\n tableId,\n onChanged,\n getRowValue,\n getSortKey,\n ) => {\n setDefinition(id, tableId);\n const changedRowValues = mapNew();\n const changedSortKeys = mapNew();\n const rowValues = mapGet(allRowValues, id);\n const sortKeys = mapGet(allSortKeys, id);\n const processRow = (rowId) => {\n const getCell = (cellId) => store.getCell(tableId, rowId, cellId);\n const oldRowValue = mapGet(rowValues, rowId);\n const newRowValue = hasRow(tableId, rowId)\n ? validateRowValue(getRowValue(getCell, rowId))\n : void 0;\n if (\n !(\n oldRowValue === newRowValue ||\n (isArray(oldRowValue) &&\n isArray(newRowValue) &&\n arrayIsEqual(oldRowValue, newRowValue))\n )\n ) {\n mapSet(changedRowValues, rowId, [oldRowValue, newRowValue]);\n }\n if (!isUndefined(getSortKey)) {\n const oldSortKey = mapGet(sortKeys, rowId);\n const newSortKey = hasRow(tableId, rowId)\n ? getSortKey(getCell, rowId)\n : void 0;\n if (oldSortKey != newSortKey) {\n mapSet(changedSortKeys, rowId, newSortKey);\n }\n }\n };\n const processTable = (force) => {\n onChanged(\n () => {\n collForEach(changedRowValues, ([, newRowValue], rowId) =>\n mapSet(rowValues, rowId, newRowValue),\n );\n collForEach(changedSortKeys, (newSortKey, rowId) =>\n mapSet(sortKeys, rowId, newSortKey),\n );\n },\n changedRowValues,\n changedSortKeys,\n rowValues,\n sortKeys,\n force,\n );\n collClear(changedRowValues);\n collClear(changedSortKeys);\n };\n mapForEach(rowValues, processRow);\n if (store.hasTable(tableId)) {\n arrayForEach(store.getRowIds(tableId), (rowId) => {\n if (!collHas(rowValues, rowId)) {\n processRow(rowId);\n }\n });\n }\n processTable(true);\n delStoreListeners(id);\n addStoreListeners(\n id,\n 0,\n store.addRowListener(tableId, null, (_store, _tableId, rowId) =>\n processRow(rowId),\n ),\n store.addTableListener(tableId, () => processTable()),\n );\n };\n const delDefinition = (id) => {\n mapSet(tableIds, id);\n mapSet(things, id);\n mapSet(allRowValues, id);\n mapSet(allSortKeys, id);\n delStoreListeners(id);\n callListeners(thingIdListeners);\n };\n const addThingIdsListener = (listener) =>\n addListener(listener, thingIdListeners);\n const destroy = () => mapForEach(storeListenerIds, delDefinition);\n return [\n getStore,\n getThingIds,\n forEachThing,\n hasThing,\n getTableId,\n getThing,\n setThing,\n setDefinition,\n setDefinitionAndListen,\n delDefinition,\n addThingIdsListener,\n destroy,\n addStoreListeners,\n delStoreListeners,\n ];\n};\nconst getRowCellFunction = (getRowCell, defaultCellValue) =>\n isString(getRowCell)\n ? (getCell) => getCell(getRowCell)\n : (getRowCell ?? (() => defaultCellValue ?? EMPTY_STRING));\nconst getCreateFunction = (getFunction, initFunction) => {\n const thingsByStore = /* @__PURE__ */ new WeakMap();\n return (store) => {\n if (!thingsByStore.has(store)) {\n thingsByStore.set(store, getFunction(store));\n }\n const thing = thingsByStore.get(store);\n initFunction?.(thing);\n return thing;\n };\n};\n\nconst INTEGER = /^\\d+$/;\nconst getPoolFunctions = () => {\n const pool = [];\n let nextId = 0;\n return [\n (reuse) => (reuse ? arrayShift(pool) : null) ?? EMPTY_STRING + nextId++,\n (id) => {\n if (test(INTEGER, id) && size(pool) < 1e3) {\n arrayPush(pool, id);\n }\n },\n ];\n};\n\nconst getWildcardedLeaves = (deepIdSet, path = [EMPTY_STRING]) => {\n const leaves = [];\n const deep = (node, p) =>\n p == size(path)\n ? arrayPush(leaves, node)\n : path[p] === null\n ? collForEach(node, (node2) => deep(node2, p + 1))\n : arrayForEach([path[p], null], (id) => deep(mapGet(node, id), p + 1));\n deep(deepIdSet, 0);\n return leaves;\n};\nconst getListenerFunctions = (getThing) => {\n let thing;\n const [getId, releaseId] = getPoolFunctions();\n const allListeners = mapNew();\n const addListener = (\n listener,\n idSetNode,\n path,\n pathGetters = [],\n extraArgsGetter = () => [],\n ) => {\n thing ??= getThing();\n const id = getId(1);\n mapSet(allListeners, id, [\n listener,\n idSetNode,\n path,\n pathGetters,\n extraArgsGetter,\n ]);\n setAdd(visitTree(idSetNode, path ?? [EMPTY_STRING], setNew), id);\n return id;\n };\n const callListeners = (idSetNode, ids, ...extraArgs) =>\n arrayForEach(getWildcardedLeaves(idSetNode, ids), (set) =>\n collForEach(set, (id) =>\n mapGet(allListeners, id)[0](thing, ...(ids ?? []), ...extraArgs),\n ),\n );\n const delListener = (id) =>\n ifNotUndefined(mapGet(allListeners, id), ([, idSetNode, idOrNulls]) => {\n visitTree(idSetNode, idOrNulls ?? [EMPTY_STRING], void 0, (idSet) => {\n collDel(idSet, id);\n return collIsEmpty(idSet) ? 1 : 0;\n });\n mapSet(allListeners, id);\n releaseId(id);\n return idOrNulls;\n });\n const callListener = (id) =>\n ifNotUndefined(\n mapGet(allListeners, id),\n ([listener, , path = [], pathGetters, extraArgsGetter]) => {\n const callWithIds = (...ids) => {\n const index = size(ids);\n if (index == size(path)) {\n listener(thing, ...ids, ...extraArgsGetter(ids));\n } else if (isUndefined(path[index])) {\n arrayForEach(pathGetters[index]?.(...ids) ?? [], (id2) =>\n callWithIds(...ids, id2),\n );\n } else {\n callWithIds(...ids, path[index]);\n }\n };\n callWithIds();\n },\n );\n return [addListener, callListeners, delListener, callListener];\n};\n\nconst createCheckpoints = getCreateFunction(\n (store) => {\n let backwardIdsSize = 100;\n let currentId;\n let cellsDelta = mapNew();\n let valuesDelta = mapNew();\n let listening = 1;\n let nextCheckpointId;\n let checkpointsChanged;\n const checkpointIdsListeners = mapNew();\n const checkpointListeners = mapNew();\n const [addListener, callListeners, delListenerImpl] = getListenerFunctions(\n () => checkpoints,\n );\n const deltas = mapNew();\n const labels = mapNew();\n const backwardIds = [];\n const forwardIds = [];\n const updateStore = (oldOrNew, checkpointId) => {\n listening = 0;\n store.transaction(() => {\n const [cellsDelta2, valuesDelta2] = mapGet(deltas, checkpointId);\n collForEach(cellsDelta2, (table, tableId) =>\n collForEach(table, (row, rowId) =>\n collForEach(row, (oldNew, cellId) =>\n setOrDelCell(store, tableId, rowId, cellId, oldNew[oldOrNew]),\n ),\n ),\n );\n collForEach(valuesDelta2, (oldNew, valueId) =>\n setOrDelValue(store, valueId, oldNew[oldOrNew]),\n );\n });\n listening = 1;\n };\n const clearCheckpointId = (checkpointId) => {\n mapSet(deltas, checkpointId);\n mapSet(labels, checkpointId);\n callListeners(checkpointListeners, [checkpointId]);\n };\n const clearCheckpointIds = (checkpointIds, to) =>\n arrayForEach(\n arrayClear(checkpointIds, to ?? size(checkpointIds)),\n clearCheckpointId,\n );\n const trimBackwardsIds = () =>\n clearCheckpointIds(backwardIds, size(backwardIds) - backwardIdsSize);\n const storeChanged = () =>\n ifNotUndefined(currentId, () => {\n arrayPush(backwardIds, currentId);\n trimBackwardsIds();\n clearCheckpointIds(forwardIds);\n currentId = void 0;\n checkpointsChanged = 1;\n });\n const storeUnchanged = () => {\n currentId = arrayPop(backwardIds);\n checkpointsChanged = 1;\n };\n let cellListenerId;\n let valueListenerId;\n const addCheckpointImpl = (label = EMPTY_STRING) => {\n if (isUndefined(currentId)) {\n currentId = EMPTY_STRING + nextCheckpointId++;\n mapSet(deltas, currentId, [cellsDelta, valuesDelta]);\n setCheckpoint(currentId, label);\n cellsDelta = mapNew();\n valuesDelta = mapNew();\n checkpointsChanged = 1;\n }\n return currentId;\n };\n const goBackwardImpl = () => {\n if (!arrayIsEmpty(backwardIds)) {\n arrayUnshift(forwardIds, addCheckpointImpl());\n updateStore(0, currentId);\n currentId = arrayPop(backwardIds);\n checkpointsChanged = 1;\n }\n };\n const goForwardImpl = () => {\n if (!arrayIsEmpty(forwardIds)) {\n arrayPush(backwardIds, currentId);\n currentId = arrayShift(forwardIds);\n updateStore(1, currentId);\n checkpointsChanged = 1;\n }\n };\n const callListenersIfChanged = () => {\n if (checkpointsChanged) {\n callListeners(checkpointIdsListeners);\n checkpointsChanged = 0;\n }\n };\n const setSize = (size2) => {\n backwardIdsSize = size2;\n trimBackwardsIds();\n return checkpoints;\n };\n const addCheckpoint = (label) => {\n const id = addCheckpointImpl(label);\n callListenersIfChanged();\n return id;\n };\n const setCheckpoint = (checkpointId, label) => {\n if (\n hasCheckpoint(checkpointId) &&\n mapGet(labels, checkpointId) !== label\n ) {\n mapSet(labels, checkpointId, label);\n callListeners(checkpointListeners, [checkpointId]);\n }\n return checkpoints;\n };\n const getStore = () => store;\n const getCheckpointIds = () => [\n [...backwardIds],\n currentId,\n [...forwardIds],\n ];\n const forEachCheckpoint = (checkpointCallback) =>\n mapForEach(labels, checkpointCallback);\n const hasCheckpoint = (checkpointId) => collHas(deltas, checkpointId);\n const getCheckpoint = (checkpointId) => mapGet(labels, checkpointId);\n const goBackward = () => {\n goBackwardImpl();\n callListenersIfChanged();\n return checkpoints;\n };\n const goForward = () => {\n goForwardImpl();\n callListenersIfChanged();\n return checkpoints;\n };\n const goTo = (checkpointId) => {\n const action = arrayHas(backwardIds, checkpointId)\n ? goBackwardImpl\n : arrayHas(forwardIds, checkpointId)\n ? goForwardImpl\n : null;\n while (!isUndefined(action) && checkpointId != currentId) {\n action();\n }\n callListenersIfChanged();\n return checkpoints;\n };\n const addCheckpointIdsListener = (listener) =>\n addListener(listener, checkpointIdsListeners);\n const addCheckpointListener = (checkpointId, listener) =>\n addListener(listener, checkpointListeners, [checkpointId]);\n const delListener = (listenerId) => {\n delListenerImpl(listenerId);\n return checkpoints;\n };\n const clear = () => {\n clearCheckpointIds(backwardIds);\n clearCheckpointIds(forwardIds);\n if (!isUndefined(currentId)) {\n clearCheckpointId(currentId);\n }\n currentId = void 0;\n nextCheckpointId = 0;\n addCheckpoint();\n return checkpoints;\n };\n const clearForward = () => {\n if (!arrayIsEmpty(forwardIds)) {\n clearCheckpointIds(forwardIds);\n callListeners(checkpointIdsListeners);\n }\n return checkpoints;\n };\n const destroy = () => {\n store.delListener(cellListenerId);\n store.delListener(valueListenerId);\n };\n const getListenerStats = () => ({\n checkpointIds: collSize2(checkpointIdsListeners),\n checkpoint: collSize2(checkpointListeners),\n });\n const _registerListeners = () => {\n cellListenerId = store.addCellListener(\n null,\n null,\n null,\n (_store, tableId, rowId, cellId, newCell, oldCell) => {\n if (listening) {\n storeChanged();\n const table = mapEnsure(cellsDelta, tableId, mapNew);\n const row = mapEnsure(table, rowId, mapNew);\n const oldNew = mapEnsure(row, cellId, () => [oldCell, void 0]);\n oldNew[1] = newCell;\n if (\n oldNew[0] === newCell &&\n collIsEmpty(mapSet(row, cellId)) &&\n collIsEmpty(mapSet(table, rowId)) &&\n collIsEmpty(mapSet(cellsDelta, tableId))\n ) {\n storeUnchanged();\n }\n callListenersIfChanged();\n }\n },\n );\n valueListenerId = store.addValueListener(\n null,\n (_store, valueId, newValue, oldValue) => {\n if (listening) {\n storeChanged();\n const oldNew = mapEnsure(valuesDelta, valueId, () => [\n oldValue,\n void 0,\n ]);\n oldNew[1] = newValue;\n if (\n oldNew[0] === newValue &&\n collIsEmpty(mapSet(valuesDelta, valueId))\n ) {\n storeUnchanged();\n }\n callListenersIfChanged();\n }\n },\n );\n };\n const checkpoints = {\n setSize,\n addCheckpoint,\n setCheckpoint,\n getStore,\n getCheckpointIds,\n forEachCheckpoint,\n hasCheckpoint,\n getCheckpoint,\n goBackward,\n goForward,\n goTo,\n addCheckpointIdsListener,\n addCheckpointListener,\n delListener,\n clear,\n clearForward,\n destroy,\n getListenerStats,\n _registerListeners,\n };\n return objFreeze(checkpoints.clear());\n },\n (checkpoints) => checkpoints._registerListeners(),\n);\n\nconst MASK6 = 63;\nconst ENCODE = /* @__PURE__ */ strSplit(\n '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz',\n);\nconst DECODE = /* @__PURE__ */ mapNew(\n /* @__PURE__ */ arrayMap(ENCODE, (char, index) => [char, index]),\n);\nconst encode = (num) => ENCODE[num & MASK6];\nconst decode = (str, pos) => mapGet(DECODE, str[pos]) ?? 0;\n\nconst getRandomValues = GLOBAL.crypto\n ? (array) => GLOBAL.crypto.getRandomValues(array)\n : /* istanbul ignore next */\n (array) => arrayMap(array, () => mathFloor(math.random() * 256));\nconst defaultSorter = (sortKey1, sortKey2) =>\n (sortKey1 ?? 0) < (sortKey2 ?? 0) ? -1 : 1;\nconst getUniqueId = (length = 16) =>\n arrayReduce(\n getRandomValues(new Uint8Array(length)),\n (uniqueId, number) => uniqueId + encode(number),\n '',\n );\n\nconst createIndexes = getCreateFunction((store) => {\n const sliceIdsListeners = mapNew();\n const sliceRowIdsListeners = mapNew();\n const [addListener, callListeners, delListenerImpl] = getListenerFunctions(\n () => indexes,\n );\n const [\n getStore,\n getIndexIds,\n forEachIndexImpl,\n hasIndex,\n getTableId,\n getIndex,\n setIndex,\n ,\n setDefinitionAndListen,\n delDefinition,\n addIndexIdsListener,\n destroy,\n ] = getDefinableFunctions(\n store,\n mapNew,\n (value) =>\n isUndefined(value)\n ? EMPTY_STRING\n : isArray(value)\n ? arrayMap(value, id)\n : id(value),\n addListener,\n callListeners,\n );\n const hasSlice = (indexId, sliceId) => collHas(getIndex(indexId), sliceId);\n const setIndexDefinition = (\n indexId,\n tableId,\n getSliceIdOrIds,\n getSortKey,\n sliceIdSorter,\n rowIdSorter = defaultSorter,\n ) => {\n const sliceIdArraySorter = isUndefined(sliceIdSorter)\n ? void 0\n : ([id1], [id2]) => sliceIdSorter(id1, id2);\n setDefinitionAndListen(\n indexId,\n tableId,\n (change, changedSliceIds, changedSortKeys, sliceIds, sortKeys, force) => {\n let sliceIdsChanged = 0;\n const changedSlices = setNew();\n const unsortedSlices = setNew();\n const index = getIndex(indexId);\n collForEach(\n changedSliceIds,\n ([oldSliceIdOrIds, newSliceIdOrIds], rowId) => {\n const oldSliceIds = setNew(oldSliceIdOrIds);\n const newSliceIds = setNew(newSliceIdOrIds);\n collForEach(oldSliceIds, (oldSliceId) =>\n collDel(newSliceIds, oldSliceId)\n ? collDel(oldSliceIds, oldSliceId)\n : 0,\n );\n collForEach(oldSliceIds, (oldSliceId) => {\n setAdd(changedSlices, oldSliceId);\n ifNotUndefined(mapGet(index, oldSliceId), (oldSlice) => {\n collDel(oldSlice, rowId);\n if (collIsEmpty(oldSlice)) {\n mapSet(index, oldSliceId);\n sliceIdsChanged = 1;\n }\n });\n });\n collForEach(newSliceIds, (newSliceId) => {\n setAdd(changedSlices, newSliceId);\n if (!collHas(index, newSliceId)) {\n mapSet(index, newSliceId, setNew());\n sliceIdsChanged = 1;\n }\n setAdd(mapGet(index, newSliceId), rowId);\n if (!isUndefined(getSortKey)) {\n setAdd(unsortedSlices, newSliceId);\n }\n });\n },\n );\n change();\n if (!collIsEmpty(sortKeys)) {\n if (force) {\n mapForEach(index, (sliceId) => setAdd(unsortedSlices, sliceId));\n } else {\n mapForEach(changedSortKeys, (rowId) =>\n ifNotUndefined(mapGet(sliceIds, rowId), (sliceId) =>\n setAdd(unsortedSlices, sliceId),\n ),\n );\n }\n collForEach(unsortedSlices, (sliceId) => {\n const rowIdArraySorter = (rowId1, rowId2) =>\n rowIdSorter(\n mapGet(sortKeys, rowId1),\n mapGet(sortKeys, rowId2),\n sliceId,\n );\n const sliceArray = [...mapGet(index, sliceId)];\n if (!arrayIsSorted(sliceArray, rowIdArraySorter)) {\n mapSet(\n index,\n sliceId,\n setNew(arraySort(sliceArray, rowIdArraySorter)),\n );\n setAdd(changedSlices, sliceId);\n }\n });\n }\n if (sliceIdsChanged || force) {\n if (!isUndefined(sliceIdArraySorter)) {\n const indexArray = [...index];\n if (!arrayIsSorted(indexArray, sliceIdArraySorter)) {\n setIndex(\n indexId,\n mapNew(arraySort(indexArray, sliceIdArraySorter)),\n );\n sliceIdsChanged = 1;\n }\n }\n }\n if (sliceIdsChanged) {\n callListeners(sliceIdsListeners, [indexId]);\n }\n collForEach(changedSlices, (sliceId) =>\n callListeners(sliceRowIdsListeners, [indexId, sliceId]),\n );\n },\n getRowCellFunction(getSliceIdOrIds),\n ifNotUndefined(getSortKey, getRowCellFunction),\n );\n return indexes;\n };\n const forEachIndex = (indexCallback) =>\n forEachIndexImpl((indexId, slices) =>\n indexCallback(indexId, (sliceCallback) =>\n forEachSliceImpl(indexId, sliceCallback, slices),\n ),\n );\n const forEachSlice = (indexId, sliceCallback) =>\n forEachSliceImpl(indexId, sliceCallback, getIndex(indexId));\n const forEachSliceImpl = (indexId, sliceCallback, slices) => {\n const tableId = getTableId(indexId);\n collForEach(slices, (rowIds, sliceId) =>\n sliceCallback(sliceId, (rowCallback) =>\n collForEach(rowIds, (rowId) =>\n rowCallback(rowId, (cellCallback) =>\n store.forEachCell(tableId, rowId, cellCallback),\n ),\n ),\n ),\n );\n };\n const delIndexDefinition = (indexId) => {\n delDefinition(indexId);\n return indexes;\n };\n const getSliceIds = (indexId) => mapKeys(getIndex(indexId));\n const getSliceRowIds = (indexId, sliceId) =>\n collValues(mapGet(getIndex(indexId), sliceId));\n const addSliceIdsListener = (indexId, listener) =>\n addListener(listener, sliceIdsListeners, [indexId]);\n const addSliceRowIdsListener = (indexId, sliceId, listener) =>\n addListener(listener, sliceRowIdsListeners, [indexId, sliceId]);\n const delListener = (listenerId) => {\n delListenerImpl(listenerId);\n return indexes;\n };\n const getListenerStats = () => ({\n sliceIds: collSize2(sliceIdsListeners),\n sliceRowIds: collSize3(sliceRowIdsListeners),\n });\n const indexes = {\n setIndexDefinition,\n delIndexDefinition,\n getStore,\n getIndexIds,\n forEachIndex,\n forEachSlice,\n hasIndex,\n hasSlice,\n getTableId,\n getSliceIds,\n getSliceRowIds,\n addIndexIdsListener,\n addSliceIdsListener,\n addSliceRowIdsListener,\n delListener,\n destroy,\n getListenerStats,\n };\n return objFreeze(indexes);\n});\n\nconst numericAggregators = /* @__PURE__ */ mapNew([\n [\n AVG,\n [\n (numbers, length) => arraySum(numbers) / length,\n (metric, add, length) => metric + (add - metric) / (length + 1),\n (metric, remove, length) => metric + (metric - remove) / (length - 1),\n (metric, add, remove, length) => metric + (add - remove) / length,\n ],\n ],\n [\n MAX,\n [\n (numbers) => mathMax(...numbers),\n (metric, add) => mathMax(add, metric),\n (metric, remove) => (remove == metric ? void 0 : metric),\n (metric, add, remove) =>\n remove == metric ? void 0 : mathMax(add, metric),\n ],\n ],\n [\n MIN,\n [\n (numbers) => mathMin(...numbers),\n (metric, add) => mathMin(add, metric),\n (metric, remove) => (remove == metric ? void 0 : metric),\n (metric, add, remove) =>\n remove == metric ? void 0 : mathMin(add, metric),\n ],\n ],\n [\n SUM,\n [\n (numbers) => arraySum(numbers),\n (metric, add) => metric + add,\n (metric, remove) => metric - remove,\n (metric, add, remove) => metric - remove + add,\n ],\n ],\n]);\nconst getAggregateValue = (\n aggregateValue,\n oldLength,\n newValues,\n changedValues,\n aggregators,\n force = false,\n) => {\n if (collIsEmpty(newValues)) {\n return void 0;\n }\n const [aggregate, aggregateAdd, aggregateRemove, aggregateReplace] =\n aggregators;\n force ||= isUndefined(aggregateValue);\n collForEach(changedValues, ([oldValue, newValue]) => {\n if (!force) {\n aggregateValue = isUndefined(oldValue)\n ? aggregateAdd?.(aggregateValue, newValue, oldLength++)\n : isUndefined(newValue)\n ? aggregateRemove?.(aggregateValue, oldValue, oldLength--)\n : aggregateReplace?.(aggregateValue, newValue, oldValue, oldLength);\n force ||= isUndefined(aggregateValue);\n }\n });\n return force\n ? aggregate(collValues(newValues), collSize(newValues))\n : aggregateValue;\n};\n\nconst createMetrics = getCreateFunction((store) => {\n const metricListeners = mapNew();\n const [addListener, callListeners, delListenerImpl] = getListenerFunctions(\n () => metrics,\n );\n const [\n getStore,\n getMetricIds,\n forEachMetric,\n hasMetric,\n getTableId,\n getMetric,\n setMetric,\n ,\n setDefinitionAndListen,\n delDefinition,\n addMetricIdsListener,\n destroy,\n ] = getDefinableFunctions(\n store,\n getUndefined,\n (value) =>\n isNaN(value) ||\n isUndefined(value) ||\n value === true ||\n value === false ||\n value === EMPTY_STRING\n ? void 0\n : value * 1,\n addListener,\n callListeners,\n );\n const setMetricDefinition = (\n metricId,\n tableId,\n aggregate,\n getNumber,\n aggregateAdd,\n aggregateRemove,\n aggregateReplace,\n ) => {\n const aggregators = isFunction(aggregate)\n ? [aggregate, aggregateAdd, aggregateRemove, aggregateReplace]\n : (mapGet(numericAggregators, aggregate) ??\n mapGet(numericAggregators, SUM));\n setDefinitionAndListen(\n metricId,\n tableId,\n (change, changedNumbers, _changedSortKeys, numbers, _sortKeys, force) => {\n const oldMetric = getMetric(metricId);\n const oldLength = collSize(numbers);\n force ||= isUndefined(oldMetric);\n change();\n let newMetric = getAggregateValue(\n oldMetric,\n oldLength,\n numbers,\n changedNumbers,\n aggregators,\n force,\n );\n if (!isFiniteNumber(newMetric)) {\n newMetric = void 0;\n }\n if (newMetric != oldMetric) {\n setMetric(metricId, newMetric);\n callListeners(metricListeners, [metricId], newMetric, oldMetric);\n }\n },\n getRowCellFunction(getNumber, 1),\n );\n return metrics;\n };\n const delMetricDefinition = (metricId) => {\n delDefinition(metricId);\n return metrics;\n };\n const addMetricListener = (metricId, listener) =>\n addListener(listener, metricListeners, [metricId]);\n const delListener = (listenerId) => {\n delListenerImpl(listenerId);\n return metrics;\n };\n const getListenerStats = () => ({\n metric: collSize2(metricListeners),\n });\n const metrics = {\n setMetricDefinition,\n delMetricDefinition,\n getStore,\n getMetricIds,\n forEachMetric,\n hasMetric,\n getTableId,\n getMetric,\n addMetricIdsListener,\n addMetricListener,\n delListener,\n destroy,\n getListenerStats,\n };\n return objFreeze(metrics);\n});\n\nconst createQueries = getCreateFunction((store) => {\n const createStore = store.createStore;\n const preStore = createStore();\n const resultStore = createStore();\n const preStoreListenerIds = mapNew();\n const {\n addListener,\n callListeners,\n delListener: delListenerImpl,\n } = resultStore;\n const [\n getStore,\n getQueryIds,\n forEachQuery,\n hasQuery,\n getTableId,\n ,\n ,\n setDefinition,\n ,\n delDefinition,\n addQueryIdsListenerImpl,\n destroy,\n addStoreListeners,\n delStoreListeners,\n ] = getDefinableFunctions(\n store,\n () => true,\n getUndefined,\n addListener,\n callListeners,\n );\n const addPreStoreListener = (preStore2, queryId, ...listenerIds) =>\n arrayForEach(listenerIds, (listenerId) =>\n setAdd(\n mapEnsure(\n mapEnsure(preStoreListenerIds, queryId, mapNew),\n preStore2,\n setNew,\n ),\n listenerId,\n ),\n );\n const resetPreStores = (queryId) => {\n ifNotUndefined(\n mapGet(preStoreListenerIds, queryId),\n (queryPreStoreListenerIds) => {\n mapForEach(queryPreStoreListenerIds, (preStore2, listenerIds) =>\n collForEach(listenerIds, (listenerId) =>\n preStore2.delListener(listenerId),\n ),\n );\n collClear(queryPreStoreListenerIds);\n },\n );\n arrayForEach([resultStore, preStore], (store2) => store2.delTable(queryId));\n };\n const synchronizeTransactions = (queryId, fromStore, toStore) =>\n addPreStoreListener(\n fromStore,\n queryId,\n fromStore.addStartTransactionListener(toStore.startTransaction),\n fromStore.addDidFinishTransactionListener(() =>\n toStore.finishTransaction(),\n ),\n );\n const setQueryDefinition = (queryId, tableId, build) => {\n setDefinition(queryId, tableId);\n resetPreStores(queryId);\n const selectEntries = [];\n const joinEntries = [[null, [tableId, null, null, [], mapNew()]]];\n const wheres = [];\n const groupEntries = [];\n const havings = [];\n const select = (arg1, arg2) => {\n const selectEntry = isFunction(arg1)\n ? [size(selectEntries) + EMPTY_STRING, arg1]\n : [\n isUndefined(arg2) ? arg1 : arg2,\n (getTableCell) => getTableCell(arg1, arg2),\n ];\n arrayPush(selectEntries, selectEntry);\n return {as: (selectedCellId) => (selectEntry[0] = selectedCellId)};\n };\n const join = (joinedTableId, arg1, arg2) => {\n const fromIntermediateJoinedTableId =\n isUndefined(arg2) || isFunction(arg1) ? null : arg1;\n const onArg = isUndefined(fromIntermediateJoinedTableId) ? arg1 : arg2;\n const joinEntry = [\n joinedTableId,\n [\n joinedTableId,\n fromIntermediateJoinedTableId,\n isFunction(onArg) ? onArg : (getCell) => getCell(onArg),\n [],\n mapNew(),\n ],\n ];\n arrayPush(joinEntries, joinEntry);\n return {as: (joinedTableId2) => (joinEntry[0] = joinedTableId2)};\n };\n const where = (arg1, arg2, arg3) =>\n arrayPush(\n wheres,\n isFunction(arg1)\n ? arg1\n : isUndefined(arg3)\n ? (getTableCell) => getTableCell(arg1) === arg2\n : (getTableCell) => getTableCell(arg1, arg2) === arg3,\n );\n const group = (\n selectedCellId,\n aggregate,\n aggregateAdd,\n aggregateRemove,\n aggregateReplace,\n ) => {\n const groupEntry = [\n selectedCellId,\n [\n selectedCellId,\n isFunction(aggregate)\n ? [aggregate, aggregateAdd, aggregateRemove, aggregateReplace]\n : (mapGet(numericAggregators, aggregate) ?? [\n (_cells, length) => length,\n ]),\n ],\n ];\n arrayPush(groupEntries, groupEntry);\n return {as: (groupedCellId) => (groupEntry[0] = groupedCellId)};\n };\n const having = (arg1, arg2) =>\n arrayPush(\n havings,\n isFunction(arg1)\n ? arg1\n : (getSelectedOrGroupedCell) =>\n getSelectedOrGroupedCell(arg1) === arg2,\n );\n build({select, join, where, group, having});\n const selects = mapNew(selectEntries);\n if (collIsEmpty(selects)) {\n return queries;\n }\n const joins = mapNew(joinEntries);\n mapForEach(joins, (asTableId, [, fromAsTableId]) =>\n ifNotUndefined(mapGet(joins, fromAsTableId), ({3: toAsTableIds}) =>\n isUndefined(asTableId) ? 0 : arrayPush(toAsTableIds, asTableId),\n ),\n );\n const groups = mapNew(groupEntries);\n let selectJoinWhereStore = preStore;\n if (collIsEmpty(groups) && arrayIsEmpty(havings)) {\n selectJoinWhereStore = resultStore;\n } else {\n synchronizeTransactions(queryId, selectJoinWhereStore, resultStore);\n const groupedSelectedCellIds = mapNew();\n mapForEach(groups, (groupedCellId, [selectedCellId, aggregators]) =>\n setAdd(mapEnsure(groupedSelectedCellIds, selectedCellId, setNew), [\n groupedCellId,\n aggregators,\n ]),\n );\n const groupBySelectedCellIds = setNew();\n mapForEach(selects, (selectedCellId) =>\n collHas(groupedSelectedCellIds, selectedCellId)\n ? 0\n : setAdd(groupBySelectedCellIds, selectedCellId),\n );\n const tree = mapNew();\n const writeGroupRow = (\n leaf,\n changedGroupedSelectedCells,\n selectedRowId,\n forceRemove,\n ) =>\n ifNotUndefined(\n leaf,\n ([selectedCells, selectedRowIds, groupRowId, groupRow]) => {\n mapForEach(\n changedGroupedSelectedCells,\n (selectedCellId, [newCell]) => {\n const selectedCell = mapEnsure(\n selectedCells,\n selectedCellId,\n mapNew,\n );\n const oldLeafCell = mapGet(selectedCell, selectedRowId);\n const newLeafCell = forceRemove ? void 0 : newCell;\n if (oldLeafCell !== newLeafCell) {\n const oldNewSet = setNew([[oldLeafCell, newLeafCell]]);\n const oldLength = collSize(selectedCell);\n mapSet(selectedCell, selectedRowId, newLeafCell);\n collForEach(\n mapGet(groupedSelectedCellIds, selectedCellId),\n ([groupedCellId, aggregators]) => {\n const aggregateValue = getAggregateValue(\n groupRow[groupedCellId],\n oldLength,\n selectedCell,\n oldNewSet,\n aggregators,\n );\n groupRow[groupedCellId] = isUndefined(\n getCellOrValueType(aggregateValue),\n )\n ? null\n : aggregateValue;\n },\n );\n }\n },\n );\n if (\n collIsEmpty(selectedRowIds) ||\n !arrayEvery(havings, (having2) =>\n having2((cellId) => groupRow[cellId]),\n )\n ) {\n resultStore.delRow(queryId, groupRowId);\n } else if (isUndefined(groupRowId)) {\n leaf[2] = resultStore.addRow(queryId, groupRow);\n } else {\n resultStore.setRow(queryId, groupRowId, groupRow);\n }\n },\n );\n addPreStoreListener(\n selectJoinWhereStore,\n queryId,\n selectJoinWhereStore.addRowListener(\n queryId,\n null,\n (_store, _tableId, selectedRowId, getCellChange) => {\n const oldPath = [];\n const newPath = [];\n const changedGroupedSelectedCells = mapNew();\n const rowExists = selectJoinWhereStore.hasRow(\n queryId,\n selectedRowId,\n );\n let changedLeaf = !rowExists;\n collForEach(groupBySelectedCellIds, (selectedCellId) => {\n const [changed, oldCell, newCell] = getCellChange(\n queryId,\n selectedRowId,\n selectedCellId,\n );\n arrayPush(oldPath, oldCell);\n arrayPush(newPath, newCell);\n changedLeaf ||= changed;\n });\n mapForEach(groupedSelectedCellIds, (selectedCellId) => {\n const [changed, , newCell] = getCellChange(\n queryId,\n selectedRowId,\n selectedCellId,\n );\n if (changedLeaf || changed) {\n mapSet(changedGroupedSelectedCells, selectedCellId, [newCell]);\n }\n });\n if (changedLeaf) {\n writeGroupRow(\n visitTree(tree, oldPath, void 0, ([, selectedRowIds]) => {\n collDel(selectedRowIds, selectedRowId);\n return collIsEmpty(selectedRowIds);\n }),\n changedGroupedSelectedCells,\n selectedRowId,\n 1,\n );\n }\n if (rowExists) {\n writeGroupRow(\n visitTree(\n tree,\n newPath,\n () => {\n const groupRow = {};\n collForEach(\n groupBySelectedCellIds,\n (selectedCellId) =>\n (groupRow[selectedCellId] =\n selectJoinWhereStore.getCell(\n queryId,\n selectedRowId,\n selectedCellId,\n )),\n );\n return [mapNew(), setNew(), void 0, groupRow];\n },\n ([, selectedRowIds]) => {\n setAdd(selectedRowIds, selectedRowId);\n },\n ),\n changedGroupedSelectedCells,\n selectedRowId,\n );\n }\n },\n ),\n );\n }\n synchronizeTransactions(queryId, store, selectJoinWhereStore);\n const writeSelectRow = (rootRowId) => {\n const getTableCell = (arg1, arg2) =>\n store.getCell(\n ...(isUndefined(arg2)\n ? [tableId, rootRowId, arg1]\n : arg1 === tableId\n ? [tableId, rootRowId, arg2]\n : [\n mapGet(joins, arg1)?.[0],\n mapGet(mapGet(joins, arg1)?.[4], rootRowId)?.[0],\n arg2,\n ]),\n );\n selectJoinWhereStore.transaction(() =>\n arrayEvery(wheres, (where2) => where2(getTableCell))\n ? mapForEach(selects, (asCellId, tableCellGetter) =>\n setOrDelCell(\n selectJoinWhereStore,\n queryId,\n rootRowId,\n asCellId,\n tableCellGetter(getTableCell, rootRowId),\n ),\n )\n : selectJoinWhereStore.delRow(queryId, rootRowId),\n );\n };\n const listenToTable = (rootRowId, tableId2, rowId, joinedTableIds2) => {\n const getCell = (cellId) => store.getCell(tableId2, rowId, cellId);\n arrayForEach(joinedTableIds2, (remoteAsTableId) => {\n const [realJoinedTableId, , on, nextJoinedTableIds, remoteIdPair] =\n mapGet(joins, remoteAsTableId);\n const remoteRowId = on?.(getCell, rootRowId);\n const [previousRemoteRowId, previousRemoteListenerId] =\n mapGet(remoteIdPair, rootRowId) ?? [];\n if (remoteRowId != previousRemoteRowId) {\n if (!isUndefined(previousRemoteListenerId)) {\n delStoreListeners(queryId, previousRemoteListenerId);\n }\n mapSet(\n remoteIdPair,\n rootRowId,\n isUndefined(remoteRowId)\n ? null\n : [\n remoteRowId,\n ...addStoreListeners(\n queryId,\n 1,\n store.addRowListener(realJoinedTableId, remoteRowId, () =>\n listenToTable(\n rootRowId,\n realJoinedTableId,\n remoteRowId,\n nextJoinedTableIds,\n ),\n ),\n ),\n ],\n );\n }\n });\n writeSelectRow(rootRowId);\n };\n const {3: joinedTableIds} = mapGet(joins, null);\n selectJoinWhereStore.transaction(() =>\n addStoreListeners(\n queryId,\n 1,\n store.addRowListener(tableId, null, (_store, _tableId, rootRowId) => {\n if (store.hasRow(tableId, rootRowId)) {\n listenToTable(rootRowId, tableId, rootRowId, joinedTableIds);\n } else {\n selectJoinWhereStore.delRow(queryId, rootRowId);\n collForEach(joins, ({4: idsByRootRowId}) =>\n ifNotUndefined(\n mapGet(idsByRootRowId, rootRowId),\n ([, listenerId]) => {\n delStoreListeners(queryId, listenerId);\n mapSet(idsByRootRowId, rootRowId);\n },\n ),\n );\n }\n }),\n ),\n );\n return queries;\n };\n const delQueryDefinition = (queryId) => {\n resetPreStores(queryId);\n delDefinition(queryId);\n return queries;\n };\n const addQueryIdsListener = (listener) =>\n addQueryIdsListenerImpl(() => listener(queries));\n const delListener = (listenerId) => {\n delListenerImpl(listenerId);\n return queries;\n };\n const getListenerStats = () => {\n const {\n tables: _1,\n tableIds: _2,\n transaction: _3,\n ...stats\n } = resultStore.getListenerStats();\n return stats;\n };\n const queries = {\n setQueryDefinition,\n delQueryDefinition,\n getStore,\n getQueryIds,\n forEachQuery,\n hasQuery,\n getTableId,\n addQueryIdsListener,\n delListener,\n destroy,\n getListenerStats,\n };\n objToArray(\n {\n [TABLE]: [1, 1],\n [TABLE + CELL_IDS]: [0, 1],\n [ROW_COUNT]: [0, 1],\n [ROW_IDS]: [0, 1],\n [SORTED_ROW_IDS]: [0, 5],\n [ROW]: [1, 2],\n [CELL_IDS]: [0, 2],\n [CELL]: [1, 3],\n },\n ([hasAndForEach, argumentCount], gettable) => {\n arrayForEach(\n hasAndForEach ? [GET, 'has', 'forEach'] : [GET],\n (prefix) =>\n (queries[prefix + RESULT + gettable] = (...args) =>\n resultStore[prefix + gettable](...args)),\n );\n queries[ADD + RESULT + gettable + LISTENER] = (...args) =>\n resultStore[ADD + gettable + LISTENER](\n ...slice(args, 0, argumentCount),\n (_store, ...listenerArgs) =>\n args[argumentCount](queries, ...listenerArgs),\n true,\n );\n },\n );\n return objFreeze(queries);\n});\n\nconst createRelationships = getCreateFunction((store) => {\n const remoteTableIds = mapNew();\n const remoteRowIdListeners = mapNew();\n const localRowIdsListeners = mapNew();\n const linkedRowIdsListeners = mapNew();\n const [addListener, callListeners, delListenerImpl] = getListenerFunctions(\n () => relationships,\n );\n const [\n getStore,\n getRelationshipIds,\n forEachRelationshipImpl,\n hasRelationship,\n getLocalTableId,\n getRelationship,\n ,\n ,\n setDefinitionAndListen,\n delDefinition,\n addRelationshipIdsListener,\n destroy,\n ] = getDefinableFunctions(\n store,\n () => [mapNew(), mapNew(), mapNew(), mapNew()],\n (value) => (isUndefined(value) ? void 0 : value + EMPTY_STRING),\n addListener,\n callListeners,\n );\n const getLinkedRowIdsCache = (relationshipId, firstRowId, skipCache) =>\n ifNotUndefined(\n getRelationship(relationshipId),\n ([remoteRows, , linkedRowsCache]) => {\n if (!collHas(linkedRowsCache, firstRowId)) {\n const linkedRows = setNew();\n if (\n getLocalTableId(relationshipId) != getRemoteTableId(relationshipId)\n ) {\n setAdd(linkedRows, firstRowId);\n } else {\n let rowId = firstRowId;\n while (!isUndefined(rowId) && !collHas(linkedRows, rowId)) {\n setAdd(linkedRows, rowId);\n rowId = mapGet(remoteRows, rowId);\n }\n }\n if (skipCache) {\n return linkedRows;\n }\n mapSet(linkedRowsCache, firstRowId, linkedRows);\n }\n return mapGet(linkedRowsCache, firstRowId);\n },\n );\n const delLinkedRowIdsCache = (relationshipId, firstRowId) =>\n ifNotUndefined(getRelationship(relationshipId), ([, , linkedRowsCache]) =>\n mapSet(linkedRowsCache, firstRowId),\n );\n const setRelationshipDefinition = (\n relationshipId,\n localTableId,\n remoteTableId,\n getRemoteRowId2,\n ) => {\n mapSet(remoteTableIds, relationshipId, remoteTableId);\n setDefinitionAndListen(\n relationshipId,\n localTableId,\n (change, changedRemoteRowIds) => {\n const changedLocalRows = setNew();\n const changedRemoteRows = setNew();\n const changedLinkedRows = setNew();\n const [localRows, remoteRows] = getRelationship(relationshipId);\n collForEach(\n changedRemoteRowIds,\n ([oldRemoteRowId, newRemoteRowId], localRowId) => {\n if (!isUndefined(oldRemoteRowId)) {\n setAdd(changedRemoteRows, oldRemoteRowId);\n ifNotUndefined(\n mapGet(remoteRows, oldRemoteRowId),\n (oldRemoteRow) => {\n collDel(oldRemoteRow, localRowId);\n if (collIsEmpty(oldRemoteRow)) {\n mapSet(remoteRows, oldRemoteRowId);\n }\n },\n );\n }\n if (!isUndefined(newRemoteRowId)) {\n setAdd(changedRemoteRows, newRemoteRowId);\n if (!collHas(remoteRows, newRemoteRowId)) {\n mapSet(remoteRows, newRemoteRowId, setNew());\n }\n setAdd(mapGet(remoteRows, newRemoteRowId), localRowId);\n }\n setAdd(changedLocalRows, localRowId);\n mapSet(localRows, localRowId, newRemoteRowId);\n mapForEach(\n mapGet(linkedRowIdsListeners, relationshipId),\n (firstRowId) => {\n if (\n collHas(\n getLinkedRowIdsCache(relationshipId, firstRowId),\n localRowId,\n )\n ) {\n setAdd(changedLinkedRows, firstRowId);\n }\n },\n );\n },\n );\n change();\n collForEach(changedLocalRows, (localRowId) =>\n callListeners(remoteRowIdListeners, [relationshipId, localRowId]),\n );\n collForEach(changedRemoteRows, (remoteRowId) =>\n callListeners(localRowIdsListeners, [relationshipId, remoteRowId]),\n );\n collForEach(changedLinkedRows, (firstRowId) => {\n delLinkedRowIdsCache(relationshipId, firstRowId);\n callListeners(linkedRowIdsListeners, [relationshipId, firstRowId]);\n });\n },\n getRowCellFunction(getRemoteRowId2),\n );\n return relationships;\n };\n const forEachRelationship = (relationshipCallback) =>\n forEachRelationshipImpl((relationshipId) =>\n relationshipCallback(relationshipId, (rowCallback) =>\n store.forEachRow(getLocalTableId(relationshipId), rowCallback),\n ),\n );\n const delRelationshipDefinition = (relationshipId) => {\n mapSet(remoteTableIds, relationshipId);\n delDefinition(relationshipId);\n return relationships;\n };\n const getRemoteTableId = (relationshipId) =>\n mapGet(remoteTableIds, relationshipId);\n const getRemoteRowId = (relationshipId, localRowId) =>\n mapGet(getRelationship(relationshipId)?.[0], localRowId);\n const getLocalRowIds = (relationshipId, remoteRowId) =>\n collValues(mapGet(getRelationship(relationshipId)?.[1], remoteRowId));\n const getLinkedRowIds = (relationshipId, firstRowId) =>\n isUndefined(getRelationship(relationshipId))\n ? [firstRowId]\n : collValues(getLinkedRowIdsCache(relationshipId, firstRowId, true));\n const addRemoteRowIdListener = (relationshipId, localRowId, listener) =>\n addListener(listener, remoteRowIdListeners, [relationshipId, localRowId]);\n const addLocalRowIdsListener = (relationshipId, remoteRowId, listener) =>\n addListener(listener, localRowIdsListeners, [relationshipId, remoteRowId]);\n const addLinkedRowIdsListener = (relationshipId, firstRowId, listener) => {\n getLinkedRowIdsCache(relationshipId, firstRowId);\n return addListener(listener, linkedRowIdsListeners, [\n relationshipId,\n firstRowId,\n ]);\n };\n const delListener = (listenerId) => {\n delLinkedRowIdsCache(...(delListenerImpl(listenerId) ?? []));\n return relationships;\n };\n const getListenerStats = () => ({\n remoteRowId: collSize3(remoteRowIdListeners),\n localRowIds: collSize3(localRowIdsListeners),\n linkedRowIds: collSize3(linkedRowIdsListeners),\n });\n const relationships = {\n setRelationshipDefinition,\n delRelationshipDefinition,\n getStore,\n getRelationshipIds,\n forEachRelationship,\n hasRelationship,\n getLocalTableId,\n getRemoteTableId,\n getRemoteRowId,\n getLocalRowIds,\n getLinkedRowIds,\n addRelationshipIdsListener,\n addRemoteRowIdListener,\n addLocalRowIdsListener,\n addLinkedRowIdsListener,\n delListener,\n destroy,\n getListenerStats,\n };\n return objFreeze(relationships);\n});\n\nconst textEncoder = /* @__PURE__ */ new GLOBAL.TextEncoder();\nconst getHash = (value) => {\n let hash = 2166136261;\n arrayForEach(textEncoder.encode(value), (char) => {\n hash ^= char;\n hash +=\n (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);\n });\n return hash >>> 0;\n};\n\nconst stampClone = ([value, time]) => stampNew(value, time);\nconst stampCloneWithHash = ([value, time, hash]) => [value, time, hash];\nconst stampNew = (value, time) => (time ? [value, time] : [value]);\nconst stampNewWithHash = (value, time, hash) => [value, time, hash];\nconst getStampHash = (stamp) => stamp[2];\nconst hashIdAndHash = (id, hash) => getHash(id + ':' + hash);\nconst replaceTimeHash = (oldTime, newTime) =>\n newTime > oldTime ? (oldTime ? getHash(oldTime) : 0) ^ getHash(newTime) : 0;\nconst getLatestTime = (time1, time2) =>\n /* istanbul ignore next */\n ((time1 ?? '') > (time2 ?? '') ? time1 : time2) ?? '';\nconst stampUpdate = (stamp, time, hash) => {\n if (time > stamp[1]) {\n stamp[1] = time;\n }\n stamp[2] = hash >>> 0;\n};\nconst stampNewObj = (time = EMPTY_STRING) => stampNew(objNew(), time);\nconst stampNewMap = (time = EMPTY_STRING) => [mapNew(), time, 0];\nconst stampMapToObjWithHash = (\n [map, time, hash],\n mapper = stampCloneWithHash,\n) => [mapToObj(map, mapper), time, hash];\nconst stampMapToObjWithoutHash = ([map, time], mapper = stampClone) =>\n stampNew(mapToObj(map, mapper), time);\nconst stampValidate = (stamp, validateThing) =>\n isArray(stamp) &&\n size(stamp) == 3 &&\n isString(stamp[1]) &&\n getTypeOf(stamp[2]) == NUMBER &&\n isFiniteNumber(stamp[2]) &&\n validateThing(stamp[0]);\n\nconst pairNew = (value) => [value, value];\nconst pairCollSize2 = (pair, func = collSize2) => func(pair[0]) + func(pair[1]);\nconst pairNewMap = () => [mapNew(), mapNew()];\nconst pairClone = (array) => [...array];\nconst pairIsEqual = ([entry1, entry2]) => entry1 === entry2;\n\nconst jsonString = JSON.stringify;\nconst jsonParse = JSON.parse;\nconst jsonStringWithMap = (obj) =>\n jsonString(obj, (_key, value) =>\n isInstanceOf(value, Map) ? object.fromEntries([...value]) : value,\n );\n\nconst idsChanged = (changedIds, id2, addedOrRemoved) =>\n mapSet(\n changedIds,\n id2,\n mapGet(changedIds, id2) == -addedOrRemoved ? void 0 : addedOrRemoved,\n );\nconst createStore = () => {\n let hasTablesSchema;\n let hasValuesSchema;\n let hadTables = false;\n let hadValues = false;\n let transactions = 0;\n let internalListeners = [];\n const changedTableIds = mapNew();\n const changedTableCellIds = mapNew();\n const changedRowCount = mapNew();\n const changedRowIds = mapNew();\n const changedCellIds = mapNew();\n const changedCells = mapNew();\n const changedValueIds = mapNew();\n const changedValues = mapNew();\n const invalidCells = mapNew();\n const invalidValues = mapNew();\n const tablesSchemaMap = mapNew();\n const tablesSchemaRowCache = mapNew();\n const valuesSchemaMap = mapNew();\n const valuesDefaulted = mapNew();\n const valuesNonDefaulted = setNew();\n const tablePoolFunctions = mapNew();\n const tableCellIds = mapNew();\n const tablesMap = mapNew();\n const valuesMap = mapNew();\n const hasTablesListeners = pairNewMap();\n const tablesListeners = pairNewMap();\n const tableIdsListeners = pairNewMap();\n const hasTableListeners = pairNewMap();\n const tableListeners = pairNewMap();\n const tableCellIdsListeners = pairNewMap();\n const hasTableCellListeners = pairNewMap();\n const rowCountListeners = pairNewMap();\n const rowIdsListeners = pairNewMap();\n const sortedRowIdsListeners = pairNewMap();\n const hasRowListeners = pairNewMap();\n const rowListeners = pairNewMap();\n const cellIdsListeners = pairNewMap();\n const hasCellListeners = pairNewMap();\n const cellListeners = pairNewMap();\n const invalidCellListeners = pairNewMap();\n const invalidValueListeners = pairNewMap();\n const hasValuesListeners = pairNewMap();\n const valuesListeners = pairNewMap();\n const valueIdsListeners = pairNewMap();\n const hasValueListeners = pairNewMap();\n const valueListeners = pairNewMap();\n const startTransactionListeners = mapNew();\n const finishTransactionListeners = pairNewMap();\n const [addListener, callListeners, delListenerImpl, callListenerImpl] =\n getListenerFunctions(() => store);\n const validateTablesSchema = (tableSchema) =>\n objValidate(tableSchema, (tableSchema2) =>\n objValidate(tableSchema2, validateCellOrValueSchema),\n );\n const validateValuesSchema = (valuesSchema) =>\n objValidate(valuesSchema, validateCellOrValueSchema);\n const validateCellOrValueSchema = (schema) => {\n if (!objValidate(schema, (_child, id2) => arrayHas([TYPE, DEFAULT], id2))) {\n return false;\n }\n const type = schema[TYPE];\n if (!isTypeStringOrBoolean(type) && type != NUMBER) {\n return false;\n }\n if (getCellOrValueType(schema[DEFAULT]) != type) {\n objDel(schema, DEFAULT);\n }\n return true;\n };\n const validateContent = isArray;\n const validateTables = (tables) =>\n objValidate(tables, validateTable, cellInvalid);\n const validateTable = (table, tableId) =>\n (!hasTablesSchema ||\n collHas(tablesSchemaMap, tableId) ||\n /* istanbul ignore next */\n cellInvalid(tableId)) &&\n objValidate(\n table,\n (row, rowId) => validateRow(tableId, rowId, row),\n () => cellInvalid(tableId),\n );\n const validateRow = (tableId, rowId, row, skipDefaults) =>\n objValidate(\n skipDefaults ? row : addDefaultsToRow(row, tableId, rowId),\n (cell, cellId) =>\n ifNotUndefined(\n getValidatedCell(tableId, rowId, cellId, cell),\n (validCell) => {\n row[cellId] = validCell;\n return true;\n },\n () => false,\n ),\n () => cellInvalid(tableId, rowId),\n );\n const getValidatedCell = (tableId, rowId, cellId, cell) =>\n hasTablesSchema\n ? ifNotUndefined(\n mapGet(mapGet(tablesSchemaMap, tableId), cellId),\n (cellSchema) =>\n getCellOrValueType(cell) != cellSchema[TYPE]\n ? cellInvalid(tableId, rowId, cellId, cell, cellSchema[DEFAULT])\n : cell,\n () => cellInvalid(tableId, rowId, cellId, cell),\n )\n : isUndefined(getCellOrValueType(cell))\n ? cellInvalid(tableId, rowId, cellId, cell)\n : cell;\n const validateValues = (values, skipDefaults) =>\n objValidate(\n skipDefaults ? values : addDefaultsToValues(values),\n (value, valueId) =>\n ifNotUndefined(\n getValidatedValue(valueId, value),\n (validValue) => {\n values[valueId] = validValue;\n return true;\n },\n () => false,\n ),\n () => valueInvalid(),\n );\n const getValidatedValue = (valueId, value) =>\n hasValuesSchema\n ? ifNotUndefined(\n mapGet(valuesSchemaMap, valueId),\n (valueSchema) =>\n getCellOrValueType(value) != valueSchema[TYPE]\n ? valueInvalid(valueId, value, valueSchema[DEFAULT])\n : value,\n () => valueInvalid(valueId, value),\n )\n : isUndefined(getCellOrValueType(value))\n ? valueInvalid(valueId, value)\n : value;\n const addDefaultsToRow = (row, tableId, rowId) => {\n ifNotUndefined(\n mapGet(tablesSchemaRowCache, tableId),\n ([rowDefaulted, rowNonDefaulted]) => {\n collForEach(rowDefaulted, (cell, cellId) => {\n if (!objHas(row, cellId)) {\n row[cellId] = cell;\n }\n });\n collForEach(rowNonDefaulted, (cellId) => {\n if (!objHas(row, cellId)) {\n cellInvalid(tableId, rowId, cellId);\n }\n });\n },\n );\n return row;\n };\n const addDefaultsToValues = (values) => {\n if (hasValuesSchema) {\n collForEach(valuesDefaulted, (value, valueId) => {\n if (!objHas(values, valueId)) {\n values[valueId] = value;\n }\n });\n collForEach(valuesNonDefaulted, (valueId) => {\n if (!objHas(values, valueId)) {\n valueInvalid(valueId);\n }\n });\n }\n return values;\n };\n const setValidTablesSchema = (tablesSchema) =>\n mapMatch(\n tablesSchemaMap,\n tablesSchema,\n (_tablesSchema, tableId, tableSchema) => {\n const rowDefaulted = mapNew();\n const rowNonDefaulted = setNew();\n mapMatch(\n mapEnsure(tablesSchemaMap, tableId, mapNew),\n tableSchema,\n (tableSchemaMap, cellId, cellSchema) => {\n mapSet(tableSchemaMap, cellId, cellSchema);\n ifNotUndefined(\n cellSchema[DEFAULT],\n (def) => mapSet(rowDefaulted, cellId, def),\n () => setAdd(rowNonDefaulted, cellId),\n );\n },\n );\n mapSet(tablesSchemaRowCache, tableId, [rowDefaulted, rowNonDefaulted]);\n },\n (_tablesSchema, tableId) => {\n mapSet(tablesSchemaMap, tableId);\n mapSet(tablesSchemaRowCache, tableId);\n },\n );\n const setValidValuesSchema = (valuesSchema) =>\n mapMatch(\n valuesSchemaMap,\n valuesSchema,\n (_valuesSchema, valueId, valueSchema) => {\n mapSet(valuesSchemaMap, valueId, valueSchema);\n ifNotUndefined(\n valueSchema[DEFAULT],\n (def) => mapSet(valuesDefaulted, valueId, def),\n () => setAdd(valuesNonDefaulted, valueId),\n );\n },\n (_valuesSchema, valueId) => {\n mapSet(valuesSchemaMap, valueId);\n mapSet(valuesDefaulted, valueId);\n collDel(valuesNonDefaulted, valueId);\n },\n );\n const setOrDelTables = (tables) =>\n objIsEmpty(tables) ? delTables() : setTables(tables);\n const setValidContent = ([tables, values]) => {\n (objIsEmpty(tables) ? delTables : setTables)(tables);\n (objIsEmpty(values) ? delValues : setValues)(values);\n };\n const setValidTables = (tables) =>\n mapMatch(\n tablesMap,\n tables,\n (_tables, tableId, table) => setValidTable(tableId, table),\n (_tables, tableId) => delValidTable(tableId),\n );\n const setValidTable = (tableId, table) =>\n mapMatch(\n mapEnsure(tablesMap, tableId, () => {\n tableIdsChanged(tableId, 1);\n mapSet(tablePoolFunctions, tableId, getPoolFunctions());\n mapSet(tableCellIds, tableId, mapNew());\n return mapNew();\n }),\n table,\n (tableMap, rowId, row) => setValidRow(tableId, tableMap, rowId, row),\n (tableMap, rowId) => delValidRow(tableId, tableMap, rowId),\n );\n const setValidRow = (tableId, tableMap, rowId, row, forceDel) =>\n mapMatch(\n mapEnsure(tableMap, rowId, () => {\n rowIdsChanged(tableId, rowId, 1);\n return mapNew();\n }),\n row,\n (rowMap, cellId, cell) =>\n setValidCell(tableId, rowId, rowMap, cellId, cell),\n (rowMap, cellId) =>\n delValidCell(tableId, tableMap, rowId, rowMap, cellId, forceDel),\n );\n const setValidCell = (tableId, rowId, rowMap, cellId, cell) => {\n if (!collHas(rowMap, cellId)) {\n cellIdsChanged(tableId, rowId, cellId, 1);\n }\n const oldCell = mapGet(rowMap, cellId);\n if (cell !== oldCell) {\n cellChanged(tableId, rowId, cellId, oldCell, cell);\n mapSet(rowMap, cellId, cell);\n }\n };\n const setCellIntoDefaultRow = (tableId, tableMap, rowId, cellId, validCell) =>\n ifNotUndefined(\n mapGet(tableMap, rowId),\n (rowMap) => setValidCell(tableId, rowId, rowMap, cellId, validCell),\n () =>\n setValidRow(\n tableId,\n tableMap,\n rowId,\n addDefaultsToRow({[cellId]: validCell}, tableId, rowId),\n ),\n );\n const setOrDelValues = (values) =>\n objIsEmpty(values) ? delValues() : setValues(values);\n const setValidValues = (values) =>\n mapMatch(\n valuesMap,\n values,\n (_valuesMap, valueId, value) => setValidValue(valueId, value),\n (_valuesMap, valueId) => delValidValue(valueId),\n );\n const setValidValue = (valueId, value) => {\n if (!collHas(valuesMap, valueId)) {\n valueIdsChanged(valueId, 1);\n }\n const oldValue = mapGet(valuesMap, valueId);\n if (value !== oldValue) {\n valueChanged(valueId, oldValue, value);\n mapSet(valuesMap, valueId, value);\n }\n };\n const getNewRowId = (tableId, reuse) => {\n const [getId] = mapGet(tablePoolFunctions, tableId);\n let rowId;\n do {\n rowId = getId(reuse);\n } while (collHas(mapGet(tablesMap, tableId), rowId));\n return rowId;\n };\n const getOrCreateTable = (tableId) =>\n mapGet(tablesMap, tableId) ?? setValidTable(tableId, {});\n const delValidTable = (tableId) => setValidTable(tableId, {});\n const delValidRow = (tableId, tableMap, rowId) => {\n const [, releaseId] = mapGet(tablePoolFunctions, tableId);\n releaseId(rowId);\n setValidRow(tableId, tableMap, rowId, {}, true);\n };\n const delValidCell = (tableId, table, rowId, row, cellId, forceDel) => {\n const defaultCell = mapGet(\n mapGet(tablesSchemaRowCache, tableId)?.[0],\n cellId,\n );\n if (!isUndefined(defaultCell) && !forceDel) {\n return setValidCell(tableId, rowId, row, cellId, defaultCell);\n }\n const delCell2 = (cellId2) => {\n cellChanged(tableId, rowId, cellId2, mapGet(row, cellId2));\n cellIdsChanged(tableId, rowId, cellId2, -1);\n mapSet(row, cellId2);\n };\n if (isUndefined(defaultCell)) {\n delCell2(cellId);\n } else {\n mapForEach(row, delCell2);\n }\n if (collIsEmpty(row)) {\n rowIdsChanged(tableId, rowId, -1);\n if (collIsEmpty(mapSet(table, rowId))) {\n tableIdsChanged(tableId, -1);\n mapSet(tablesMap, tableId);\n mapSet(tablePoolFunctions, tableId);\n mapSet(tableCellIds, tableId);\n }\n }\n };\n const delValidValue = (valueId) => {\n const defaultValue = mapGet(valuesDefaulted, valueId);\n if (!isUndefined(defaultValue)) {\n return setValidValue(valueId, defaultValue);\n }\n valueChanged(valueId, mapGet(valuesMap, valueId));\n valueIdsChanged(valueId, -1);\n mapSet(valuesMap, valueId);\n };\n const tableIdsChanged = (tableId, addedOrRemoved) =>\n idsChanged(changedTableIds, tableId, addedOrRemoved);\n const rowIdsChanged = (tableId, rowId, addedOrRemoved) =>\n idsChanged(\n mapEnsure(changedRowIds, tableId, mapNew),\n rowId,\n addedOrRemoved,\n ) &&\n mapSet(\n changedRowCount,\n tableId,\n mapEnsure(changedRowCount, tableId, () => 0) + addedOrRemoved,\n );\n const cellIdsChanged = (tableId, rowId, cellId, addedOrRemoved) => {\n const cellIds = mapGet(tableCellIds, tableId);\n const count = mapGet(cellIds, cellId) ?? 0;\n if (\n (count == 0 && addedOrRemoved == 1) ||\n (count == 1 && addedOrRemoved == -1)\n ) {\n idsChanged(\n mapEnsure(changedTableCellIds, tableId, mapNew),\n cellId,\n addedOrRemoved,\n );\n }\n mapSet(\n cellIds,\n cellId,\n count != -addedOrRemoved ? count + addedOrRemoved : null,\n );\n idsChanged(\n mapEnsure(mapEnsure(changedCellIds, tableId, mapNew), rowId, mapNew),\n cellId,\n addedOrRemoved,\n );\n };\n const cellChanged = (tableId, rowId, cellId, oldCell, newCell) => {\n mapEnsure(\n mapEnsure(mapEnsure(changedCells, tableId, mapNew), rowId, mapNew),\n cellId,\n () => [oldCell, 0],\n )[1] = newCell;\n internalListeners[3]?.(tableId, rowId, cellId, newCell);\n };\n const valueIdsChanged = (valueId, addedOrRemoved) =>\n idsChanged(changedValueIds, valueId, addedOrRemoved);\n const valueChanged = (valueId, oldValue, newValue) => {\n mapEnsure(changedValues, valueId, () => [oldValue, 0])[1] = newValue;\n internalListeners[4]?.(valueId, newValue);\n };\n const cellInvalid = (tableId, rowId, cellId, invalidCell, defaultedCell) => {\n arrayPush(\n mapEnsure(\n mapEnsure(mapEnsure(invalidCells, tableId, mapNew), rowId, mapNew),\n cellId,\n () => [],\n ),\n invalidCell,\n );\n return defaultedCell;\n };\n const valueInvalid = (valueId, invalidValue, defaultedValue) => {\n arrayPush(\n mapEnsure(invalidValues, valueId, () => []),\n invalidValue,\n );\n return defaultedValue;\n };\n const getCellChange = (tableId, rowId, cellId) =>\n ifNotUndefined(\n mapGet(mapGet(mapGet(changedCells, tableId), rowId), cellId),\n ([oldCell, newCell]) => [true, oldCell, newCell],\n () => [false, ...pairNew(getCell(tableId, rowId, cellId))],\n );\n const getValueChange = (valueId) =>\n ifNotUndefined(\n mapGet(changedValues, valueId),\n ([oldValue, newValue]) => [true, oldValue, newValue],\n () => [false, ...pairNew(getValue(valueId))],\n );\n const callInvalidCellListeners = (mutator) =>\n !collIsEmpty(invalidCells) && !collIsEmpty(invalidCellListeners[mutator])\n ? collForEach(\n mutator ? mapClone3(invalidCells) : invalidCells,\n (rows, tableId) =>\n collForEach(rows, (cells, rowId) =>\n collForEach(cells, (invalidCell, cellId) =>\n callListeners(\n invalidCellListeners[mutator],\n [tableId, rowId, cellId],\n invalidCell,\n ),\n ),\n ),\n )\n : 0;\n const callInvalidValueListeners = (mutator) =>\n !collIsEmpty(invalidValues) && !collIsEmpty(invalidValueListeners[mutator])\n ? collForEach(\n mutator ? mapClone(invalidValues) : invalidValues,\n (invalidValue, valueId) =>\n callListeners(\n invalidValueListeners[mutator],\n [valueId],\n invalidValue,\n ),\n )\n : 0;\n const callIdsAndHasListenersIfChanged = (\n changedIds,\n idListeners,\n hasListeners,\n ids,\n ) => {\n if (!collIsEmpty(changedIds)) {\n callListeners(idListeners, ids, () => mapToObj(changedIds));\n mapForEach(changedIds, (changedId, changed) =>\n callListeners(hasListeners, [...(ids ?? []), changedId], changed == 1),\n );\n return 1;\n }\n };\n const callTabularListenersForChanges = (mutator) => {\n const hasTablesNow = hasTables();\n if (hasTablesNow != hadTables) {\n callListeners(hasTablesListeners[mutator], void 0, hasTablesNow);\n }\n const emptySortedRowIdListeners = collIsEmpty(\n sortedRowIdsListeners[mutator],\n );\n const emptyIdAndHasListeners =\n collIsEmpty(cellIdsListeners[mutator]) &&\n collIsEmpty(hasCellListeners[mutator]) &&\n collIsEmpty(rowIdsListeners[mutator]) &&\n collIsEmpty(hasRowListeners[mutator]) &&\n collIsEmpty(tableCellIdsListeners[mutator]) &&\n collIsEmpty(hasTableCellListeners[mutator]) &&\n collIsEmpty(rowCountListeners[mutator]) &&\n emptySortedRowIdListeners &&\n collIsEmpty(tableIdsListeners[mutator]) &&\n collIsEmpty(hasTableListeners[mutator]);\n const emptyOtherListeners =\n collIsEmpty(cellListeners[mutator]) &&\n collIsEmpty(rowListeners[mutator]) &&\n collIsEmpty(tableListeners[mutator]) &&\n collIsEmpty(tablesListeners[mutator]);\n if (!emptyIdAndHasListeners || !emptyOtherListeners) {\n const changes = mutator\n ? [\n mapClone(changedTableIds),\n mapClone2(changedTableCellIds),\n mapClone(changedRowCount),\n mapClone2(changedRowIds),\n mapClone3(changedCellIds),\n mapClone3(changedCells),\n ]\n : [\n changedTableIds,\n changedTableCellIds,\n changedRowCount,\n changedRowIds,\n changedCellIds,\n changedCells,\n ];\n if (!emptyIdAndHasListeners) {\n callIdsAndHasListenersIfChanged(\n changes[0],\n tableIdsListeners[mutator],\n hasTableListeners[mutator],\n );\n collForEach(changes[1], (changedIds, tableId) =>\n callIdsAndHasListenersIfChanged(\n changedIds,\n tableCellIdsListeners[mutator],\n hasTableCellListeners[mutator],\n [tableId],\n ),\n );\n collForEach(changes[2], (changedCount, tableId) => {\n if (changedCount != 0) {\n callListeners(\n rowCountListeners[mutator],\n [tableId],\n getRowCount(tableId),\n );\n }\n });\n const calledSortableTableIds = setNew();\n collForEach(changes[3], (changedIds, tableId) => {\n if (\n callIdsAndHasListenersIfChanged(\n changedIds,\n rowIdsListeners[mutator],\n hasRowListeners[mutator],\n [tableId],\n ) &&\n !emptySortedRowIdListeners\n ) {\n callListeners(sortedRowIdsListeners[mutator], [tableId, null]);\n setAdd(calledSortableTableIds, tableId);\n }\n });\n if (!emptySortedRowIdListeners) {\n collForEach(changes[5], (rows, tableId) => {\n if (!collHas(calledSortableTableIds, tableId)) {\n const sortableCellIds = setNew();\n collForEach(rows, (cells) =>\n collForEach(cells, ([oldCell, newCell], cellId) =>\n newCell !== oldCell\n ? setAdd(sortableCellIds, cellId)\n : collDel(cells, cellId),\n ),\n );\n collForEach(sortableCellIds, (cellId) =>\n callListeners(sortedRowIdsListeners[mutator], [\n tableId,\n cellId,\n ]),\n );\n }\n });\n }\n collForEach(changes[4], (rowCellIds, tableId) =>\n collForEach(rowCellIds, (changedIds, rowId) =>\n callIdsAndHasListenersIfChanged(\n changedIds,\n cellIdsListeners[mutator],\n hasCellListeners[mutator],\n [tableId, rowId],\n ),\n ),\n );\n }\n if (!emptyOtherListeners) {\n let tablesChanged;\n collForEach(changes[5], (rows, tableId) => {\n let tableChanged;\n collForEach(rows, (cells, rowId) => {\n let rowChanged;\n collForEach(cells, ([oldCell, newCell], cellId) => {\n if (newCell !== oldCell) {\n callListeners(\n cellListeners[mutator],\n [tableId, rowId, cellId],\n newCell,\n oldCell,\n getCellChange,\n );\n tablesChanged = tableChanged = rowChanged = 1;\n }\n });\n if (rowChanged) {\n callListeners(\n rowListeners[mutator],\n [tableId, rowId],\n getCellChange,\n );\n }\n });\n if (tableChanged) {\n callListeners(tableListeners[mutator], [tableId], getCellChange);\n }\n });\n if (tablesChanged) {\n callListeners(tablesListeners[mutator], void 0, getCellChange);\n }\n }\n }\n };\n const callValuesListenersForChanges = (mutator) => {\n const hasValuesNow = hasValues();\n if (hasValuesNow != hadValues) {\n callListeners(hasValuesListeners[mutator], void 0, hasValuesNow);\n }\n const emptyIdAndHasListeners =\n collIsEmpty(valueIdsListeners[mutator]) &&\n collIsEmpty(hasValueListeners[mutator]);\n const emptyOtherListeners =\n collIsEmpty(valueListeners[mutator]) &&\n collIsEmpty(valuesListeners[mutator]);\n if (!emptyIdAndHasListeners || !emptyOtherListeners) {\n const changes = mutator\n ? [mapClone(changedValueIds), mapClone(changedValues)]\n : [changedValueIds, changedValues];\n if (!emptyIdAndHasListeners) {\n callIdsAndHasListenersIfChanged(\n changes[0],\n valueIdsListeners[mutator],\n hasValueListeners[mutator],\n );\n }\n if (!emptyOtherListeners) {\n let valuesChanged;\n collForEach(changes[1], ([oldValue, newValue], valueId) => {\n if (newValue !== oldValue) {\n callListeners(\n valueListeners[mutator],\n [valueId],\n newValue,\n oldValue,\n getValueChange,\n );\n valuesChanged = 1;\n }\n });\n if (valuesChanged) {\n callListeners(valuesListeners[mutator], void 0, getValueChange);\n }\n }\n }\n };\n const fluentTransaction = (actions, ...args) => {\n transaction(() => actions(...arrayMap(args, id)));\n return store;\n };\n const getContent = () => [getTables(), getValues()];\n const getTables = () => mapToObj3(tablesMap);\n const getTableIds = () => mapKeys(tablesMap);\n const getTable = (tableId) => mapToObj2(mapGet(tablesMap, id(tableId)));\n const getTableCellIds = (tableId) =>\n mapKeys(mapGet(tableCellIds, id(tableId)));\n const getRowCount = (tableId) => collSize(mapGet(tablesMap, id(tableId)));\n const getRowIds = (tableId) => mapKeys(mapGet(tablesMap, id(tableId)));\n const getSortedRowIds = (tableId, cellId, descending, offset = 0, limit) =>\n arrayMap(\n slice(\n arraySort(\n mapMap(mapGet(tablesMap, id(tableId)), (row, rowId) => [\n isUndefined(cellId) ? rowId : mapGet(row, id(cellId)),\n rowId,\n ]),\n ([cell1], [cell2]) =>\n defaultSorter(cell1, cell2) * (descending ? -1 : 1),\n ),\n offset,\n isUndefined(limit) ? limit : offset + limit,\n ),\n ([, rowId]) => rowId,\n );\n const getRow = (tableId, rowId) =>\n mapToObj(mapGet(mapGet(tablesMap, id(tableId)), id(rowId)));\n const getCellIds = (tableId, rowId) =>\n mapKeys(mapGet(mapGet(tablesMap, id(tableId)), id(rowId)));\n const getCell = (tableId, rowId, cellId) =>\n mapGet(mapGet(mapGet(tablesMap, id(tableId)), id(rowId)), id(cellId));\n const getValues = () => mapToObj(valuesMap);\n const getValueIds = () => mapKeys(valuesMap);\n const getValue = (valueId) => mapGet(valuesMap, id(valueId));\n const hasTables = () => !collIsEmpty(tablesMap);\n const hasTable = (tableId) => collHas(tablesMap, id(tableId));\n const hasTableCell = (tableId, cellId) =>\n collHas(mapGet(tableCellIds, id(tableId)), id(cellId));\n const hasRow = (tableId, rowId) =>\n collHas(mapGet(tablesMap, id(tableId)), id(rowId));\n const hasCell = (tableId, rowId, cellId) =>\n collHas(mapGet(mapGet(tablesMap, id(tableId)), id(rowId)), id(cellId));\n const hasValues = () => !collIsEmpty(valuesMap);\n const hasValue = (valueId) => collHas(valuesMap, id(valueId));\n const getTablesJson = () => jsonStringWithMap(tablesMap);\n const getValuesJson = () => jsonStringWithMap(valuesMap);\n const getJson = () => jsonStringWithMap([tablesMap, valuesMap]);\n const getTablesSchemaJson = () => jsonStringWithMap(tablesSchemaMap);\n const getValuesSchemaJson = () => jsonStringWithMap(valuesSchemaMap);\n const getSchemaJson = () =>\n jsonStringWithMap([tablesSchemaMap, valuesSchemaMap]);\n const setContent = (content) =>\n fluentTransaction(() => {\n const content2 = isFunction(content) ? content() : content;\n if (validateContent(content2)) {\n setValidContent(content2);\n }\n });\n const setTables = (tables) =>\n fluentTransaction(() =>\n validateTables(tables) ? setValidTables(tables) : 0,\n );\n const setTable = (tableId, table) =>\n fluentTransaction(\n (tableId2) =>\n validateTable(table, tableId2) ? setValidTable(tableId2, table) : 0,\n tableId,\n );\n const setRow = (tableId, rowId, row) =>\n fluentTransaction(\n (tableId2, rowId2) =>\n validateRow(tableId2, rowId2, row)\n ? setValidRow(tableId2, getOrCreateTable(tableId2), rowId2, row)\n : 0,\n tableId,\n rowId,\n );\n const addRow = (tableId, row, reuseRowIds = true) =>\n transaction(() => {\n let rowId = void 0;\n if (validateRow(tableId, rowId, row)) {\n tableId = id(tableId);\n setValidRow(\n tableId,\n getOrCreateTable(tableId),\n (rowId = getNewRowId(tableId, reuseRowIds ? 1 : 0)),\n row,\n );\n }\n return rowId;\n });\n const setPartialRow = (tableId, rowId, partialRow) =>\n fluentTransaction(\n (tableId2, rowId2) => {\n if (validateRow(tableId2, rowId2, partialRow, 1)) {\n const table = getOrCreateTable(tableId2);\n objToArray(partialRow, (cell, cellId) =>\n setCellIntoDefaultRow(tableId2, table, rowId2, cellId, cell),\n );\n }\n },\n tableId,\n rowId,\n );\n const setCell = (tableId, rowId, cellId, cell) =>\n fluentTransaction(\n (tableId2, rowId2, cellId2) =>\n ifNotUndefined(\n getValidatedCell(\n tableId2,\n rowId2,\n cellId2,\n isFunction(cell) ? cell(getCell(tableId2, rowId2, cellId2)) : cell,\n ),\n (validCell) =>\n setCellIntoDefaultRow(\n tableId2,\n getOrCreateTable(tableId2),\n rowId2,\n cellId2,\n validCell,\n ),\n ),\n tableId,\n rowId,\n cellId,\n );\n const setValues = (values) =>\n fluentTransaction(() =>\n validateValues(values) ? setValidValues(values) : 0,\n );\n const setPartialValues = (partialValues) =>\n fluentTransaction(() =>\n validateValues(partialValues, 1)\n ? objToArray(partialValues, (value, valueId) =>\n setValidValue(valueId, value),\n )\n : 0,\n );\n const setValue = (valueId, value) =>\n fluentTransaction(\n (valueId2) =>\n ifNotUndefined(\n getValidatedValue(\n valueId2,\n isFunction(value) ? value(getValue(valueId2)) : value,\n ),\n (validValue) => setValidValue(valueId2, validValue),\n ),\n valueId,\n );\n const applyChanges = (changes) =>\n fluentTransaction(() => {\n objToArray(changes[0], (table, tableId) =>\n isUndefined(table)\n ? delTable(tableId)\n : objToArray(table, (row, rowId) =>\n isUndefined(row)\n ? delRow(tableId, rowId)\n : objToArray(row, (cell, cellId) =>\n setOrDelCell(store, tableId, rowId, cellId, cell),\n ),\n ),\n );\n objToArray(changes[1], (value, valueId) =>\n setOrDelValue(store, valueId, value),\n );\n });\n const setTablesJson = (tablesJson) => {\n try {\n setOrDelTables(jsonParse(tablesJson));\n } catch {}\n return store;\n };\n const setValuesJson = (valuesJson) => {\n try {\n setOrDelValues(jsonParse(valuesJson));\n } catch {}\n return store;\n };\n const setJson = (tablesAndValuesJson) =>\n fluentTransaction(() => {\n try {\n const [tables, values] = jsonParse(tablesAndValuesJson);\n setOrDelTables(tables);\n setOrDelValues(values);\n } catch {\n setTablesJson(tablesAndValuesJson);\n }\n });\n const setTablesSchema = (tablesSchema) =>\n fluentTransaction(() => {\n if ((hasTablesSchema = validateTablesSchema(tablesSchema))) {\n setValidTablesSchema(tablesSchema);\n if (!collIsEmpty(tablesMap)) {\n const tables = getTables();\n delTables();\n setTables(tables);\n }\n }\n });\n const setValuesSchema = (valuesSchema) =>\n fluentTransaction(() => {\n if ((hasValuesSchema = validateValuesSchema(valuesSchema))) {\n const values = getValues();\n delValuesSchema();\n delValues();\n hasValuesSchema = true;\n setValidValuesSchema(valuesSchema);\n setValues(values);\n }\n });\n const setSchema = (tablesSchema, valuesSchema) =>\n fluentTransaction(() => {\n setTablesSchema(tablesSchema);\n setValuesSchema(valuesSchema);\n });\n const delTables = () => fluentTransaction(() => setValidTables({}));\n const delTable = (tableId) =>\n fluentTransaction(\n (tableId2) =>\n collHas(tablesMap, tableId2) ? delValidTable(tableId2) : 0,\n tableId,\n );\n const delRow = (tableId, rowId) =>\n fluentTransaction(\n (tableId2, rowId2) =>\n ifNotUndefined(mapGet(tablesMap, tableId2), (tableMap) =>\n collHas(tableMap, rowId2)\n ? delValidRow(tableId2, tableMap, rowId2)\n : 0,\n ),\n tableId,\n rowId,\n );\n const delCell = (tableId, rowId, cellId, forceDel) =>\n fluentTransaction(\n (tableId2, rowId2, cellId2) =>\n ifNotUndefined(mapGet(tablesMap, tableId2), (tableMap) =>\n ifNotUndefined(mapGet(tableMap, rowId2), (rowMap) =>\n collHas(rowMap, cellId2)\n ? delValidCell(\n tableId2,\n tableMap,\n rowId2,\n rowMap,\n cellId2,\n forceDel,\n )\n : 0,\n ),\n ),\n tableId,\n rowId,\n cellId,\n );\n const delValues = () => fluentTransaction(() => setValidValues({}));\n const delValue = (valueId) =>\n fluentTransaction(\n (valueId2) =>\n collHas(valuesMap, valueId2) ? delValidValue(valueId2) : 0,\n valueId,\n );\n const delTablesSchema = () =>\n fluentTransaction(() => {\n setValidTablesSchema({});\n hasTablesSchema = false;\n });\n const delValuesSchema = () =>\n fluentTransaction(() => {\n setValidValuesSchema({});\n hasValuesSchema = false;\n });\n const delSchema = () =>\n fluentTransaction(() => {\n delTablesSchema();\n delValuesSchema();\n });\n const transaction = (actions, doRollback) => {\n if (transactions != -1) {\n startTransaction();\n const result = actions();\n finishTransaction(doRollback);\n return result;\n }\n };\n const startTransaction = () => {\n if (transactions != -1) {\n transactions++;\n }\n if (transactions == 1) {\n internalListeners[0]?.();\n callListeners(startTransactionListeners);\n }\n return store;\n };\n const getTransactionChanges = () => [\n mapToObj(\n changedCells,\n (table, tableId) =>\n mapGet(changedTableIds, tableId) === -1\n ? void 0\n : mapToObj(\n table,\n (row, rowId) =>\n mapGet(mapGet(changedRowIds, tableId), rowId) === -1\n ? void 0\n : mapToObj(\n row,\n ([, newCell]) => newCell,\n (changedCell) => pairIsEqual(changedCell),\n ),\n collIsEmpty,\n objIsEmpty,\n ),\n collIsEmpty,\n objIsEmpty,\n ),\n mapToObj(\n changedValues,\n ([, newValue]) => newValue,\n (changedValue) => pairIsEqual(changedValue),\n ),\n 1,\n ];\n const getTransactionLog = () => [\n !collIsEmpty(changedCells),\n !collIsEmpty(changedValues),\n mapToObj3(changedCells, pairClone, pairIsEqual),\n mapToObj3(invalidCells),\n mapToObj(changedValues, pairClone, pairIsEqual),\n mapToObj(invalidValues),\n mapToObj(changedTableIds),\n mapToObj2(changedRowIds),\n mapToObj3(changedCellIds),\n mapToObj(changedValueIds),\n ];\n const finishTransaction = (doRollback) => {\n if (transactions > 0) {\n transactions--;\n if (transactions == 0) {\n transactions = 1;\n callInvalidCellListeners(1);\n if (!collIsEmpty(changedCells)) {\n callTabularListenersForChanges(1);\n }\n callInvalidValueListeners(1);\n if (!collIsEmpty(changedValues)) {\n callValuesListenersForChanges(1);\n }\n if (doRollback?.(store)) {\n collForEach(changedCells, (table, tableId) =>\n collForEach(table, (row, rowId) =>\n collForEach(row, ([oldCell], cellId) =>\n setOrDelCell(store, tableId, rowId, cellId, oldCell),\n ),\n ),\n );\n collClear(changedCells);\n collForEach(changedValues, ([oldValue], valueId) =>\n setOrDelValue(store, valueId, oldValue),\n );\n collClear(changedValues);\n }\n callListeners(finishTransactionListeners[0], void 0);\n transactions = -1;\n callInvalidCellListeners(0);\n if (!collIsEmpty(changedCells)) {\n callTabularListenersForChanges(0);\n }\n callInvalidValueListeners(0);\n if (!collIsEmpty(changedValues)) {\n callValuesListenersForChanges(0);\n }\n internalListeners[1]?.();\n callListeners(finishTransactionListeners[1], void 0);\n internalListeners[2]?.();\n transactions = 0;\n hadTables = hasTables();\n hadValues = hasValues();\n arrayForEach(\n [\n changedTableIds,\n changedTableCellIds,\n changedRowCount,\n changedRowIds,\n changedCellIds,\n changedCells,\n invalidCells,\n changedValueIds,\n changedValues,\n invalidValues,\n ],\n collClear,\n );\n }\n }\n return store;\n };\n const forEachTable = (tableCallback) =>\n collForEach(tablesMap, (tableMap, tableId) =>\n tableCallback(tableId, (rowCallback) =>\n collForEach(tableMap, (rowMap, rowId) =>\n rowCallback(rowId, (cellCallback) =>\n mapForEach(rowMap, cellCallback),\n ),\n ),\n ),\n );\n const forEachTableCell = (tableId, tableCellCallback) =>\n mapForEach(mapGet(tableCellIds, id(tableId)), tableCellCallback);\n const forEachRow = (tableId, rowCallback) =>\n collForEach(mapGet(tablesMap, id(tableId)), (rowMap, rowId) =>\n rowCallback(rowId, (cellCallback) => mapForEach(rowMap, cellCallback)),\n );\n const forEachCell = (tableId, rowId, cellCallback) =>\n mapForEach(mapGet(mapGet(tablesMap, id(tableId)), id(rowId)), cellCallback);\n const forEachValue = (valueCallback) => mapForEach(valuesMap, valueCallback);\n const addSortedRowIdsListener = (\n tableId,\n cellId,\n descending,\n offset,\n limit,\n listener,\n mutator,\n ) => {\n let sortedRowIds = getSortedRowIds(\n tableId,\n cellId,\n descending,\n offset,\n limit,\n );\n return addListener(\n () => {\n const newSortedRowIds = getSortedRowIds(\n tableId,\n cellId,\n descending,\n offset,\n limit,\n );\n if (!arrayIsEqual(newSortedRowIds, sortedRowIds)) {\n sortedRowIds = newSortedRowIds;\n listener(\n store,\n tableId,\n cellId,\n descending,\n offset,\n limit,\n sortedRowIds,\n );\n }\n },\n sortedRowIdsListeners[mutator ? 1 : 0],\n [tableId, cellId],\n [getTableIds],\n );\n };\n const addStartTransactionListener = (listener) =>\n addListener(listener, startTransactionListeners);\n const addWillFinishTransactionListener = (listener) =>\n addListener(listener, finishTransactionListeners[0]);\n const addDidFinishTransactionListener = (listener) =>\n addListener(listener, finishTransactionListeners[1]);\n const callListener = (listenerId) => {\n callListenerImpl(listenerId);\n return store;\n };\n const delListener = (listenerId) => {\n delListenerImpl(listenerId);\n return store;\n };\n const getListenerStats = () => ({\n hasTables: pairCollSize2(hasTablesListeners),\n tables: pairCollSize2(tablesListeners),\n tableIds: pairCollSize2(tableIdsListeners),\n hasTable: pairCollSize2(hasTableListeners),\n table: pairCollSize2(tableListeners),\n tableCellIds: pairCollSize2(tableCellIdsListeners),\n hasTableCell: pairCollSize2(hasTableCellListeners, collSize3),\n rowCount: pairCollSize2(rowCountListeners),\n rowIds: pairCollSize2(rowIdsListeners),\n sortedRowIds: pairCollSize2(sortedRowIdsListeners),\n hasRow: pairCollSize2(hasRowListeners, collSize3),\n row: pairCollSize2(rowListeners, collSize3),\n cellIds: pairCollSize2(cellIdsListeners, collSize3),\n hasCell: pairCollSize2(hasCellListeners, collSize4),\n cell: pairCollSize2(cellListeners, collSize4),\n invalidCell: pairCollSize2(invalidCellListeners, collSize4),\n hasValues: pairCollSize2(hasValuesListeners),\n values: pairCollSize2(valuesListeners),\n valueIds: pairCollSize2(valueIdsListeners),\n hasValue: pairCollSize2(hasValueListeners),\n value: pairCollSize2(valueListeners),\n invalidValue: pairCollSize2(invalidValueListeners),\n transaction:\n collSize2(startTransactionListeners) +\n pairCollSize2(finishTransactionListeners),\n });\n const setInternalListeners = (\n preStartTransaction,\n preFinishTransaction,\n postFinishTransaction,\n cellChanged2,\n valueChanged2,\n ) =>\n (internalListeners = [\n preStartTransaction,\n preFinishTransaction,\n postFinishTransaction,\n cellChanged2,\n valueChanged2,\n ]);\n const store = {\n getContent,\n getTables,\n getTableIds,\n getTable,\n getTableCellIds,\n getRowCount,\n getRowIds,\n getSortedRowIds,\n getRow,\n getCellIds,\n getCell,\n getValues,\n getValueIds,\n getValue,\n hasTables,\n hasTable,\n hasTableCell,\n hasRow,\n hasCell,\n hasValues,\n hasValue,\n getTablesJson,\n getValuesJson,\n getJson,\n getTablesSchemaJson,\n getValuesSchemaJson,\n getSchemaJson,\n hasTablesSchema: () => hasTablesSchema,\n hasValuesSchema: () => hasValuesSchema,\n setContent,\n setTables,\n setTable,\n setRow,\n addRow,\n setPartialRow,\n setCell,\n setValues,\n setPartialValues,\n setValue,\n applyChanges,\n setTablesJson,\n setValuesJson,\n setJson,\n setTablesSchema,\n setValuesSchema,\n setSchema,\n delTables,\n delTable,\n delRow,\n delCell,\n delValues,\n delValue,\n delTablesSchema,\n delValuesSchema,\n delSchema,\n transaction,\n startTransaction,\n getTransactionChanges,\n getTransactionLog,\n finishTransaction,\n forEachTable,\n forEachTableCell,\n forEachRow,\n forEachCell,\n forEachValue,\n addSortedRowIdsListener,\n addStartTransactionListener,\n addWillFinishTransactionListener,\n addDidFinishTransactionListener,\n callListener,\n delListener,\n getListenerStats,\n isMergeable: () => false,\n // only used internally by other modules\n createStore,\n addListener,\n callListeners,\n setInternalListeners,\n };\n objToArray(\n {\n [HAS + TABLES]: [0, hasTablesListeners, [], () => [hasTables()]],\n [TABLES]: [0, tablesListeners],\n [TABLE_IDS]: [0, tableIdsListeners],\n [HAS + TABLE]: [\n 1,\n hasTableListeners,\n [getTableIds],\n (ids) => [hasTable(...ids)],\n ],\n [TABLE]: [1, tableListeners, [getTableIds]],\n [TABLE + CELL_IDS]: [1, tableCellIdsListeners, [getTableIds]],\n [HAS + TABLE + CELL]: [\n 2,\n hasTableCellListeners,\n [getTableIds, getTableCellIds],\n (ids) => [hasTableCell(...ids)],\n ],\n [ROW_COUNT]: [1, rowCountListeners, [getTableIds]],\n [ROW_IDS]: [1, rowIdsListeners, [getTableIds]],\n [HAS + ROW]: [\n 2,\n hasRowListeners,\n [getTableIds, getRowIds],\n (ids) => [hasRow(...ids)],\n ],\n [ROW]: [2, rowListeners, [getTableIds, getRowIds]],\n [CELL_IDS]: [2, cellIdsListeners, [getTableIds, getRowIds]],\n [HAS + CELL]: [\n 3,\n hasCellListeners,\n [getTableIds, getRowIds, getCellIds],\n (ids) => [hasCell(...ids)],\n ],\n [CELL]: [\n 3,\n cellListeners,\n [getTableIds, getRowIds, getCellIds],\n (ids) => pairNew(getCell(...ids)),\n ],\n InvalidCell: [3, invalidCellListeners],\n [HAS + VALUES]: [0, hasValuesListeners, [], () => [hasValues()]],\n [VALUES]: [0, valuesListeners],\n [VALUE_IDS]: [0, valueIdsListeners],\n [HAS + VALUE]: [\n 1,\n hasValueListeners,\n [getValueIds],\n (ids) => [hasValue(...ids)],\n ],\n [VALUE]: [\n 1,\n valueListeners,\n [getValueIds],\n (ids) => pairNew(getValue(ids[0])),\n ],\n InvalidValue: [1, invalidValueListeners],\n },\n ([argumentCount, idSetNode, pathGetters, extraArgsGetter], listenable) => {\n store[ADD + listenable + LISTENER] = (...args) =>\n addListener(\n args[argumentCount],\n idSetNode[args[argumentCount + 1] ? 1 : 0],\n argumentCount > 0 ? slice(args, 0, argumentCount) : void 0,\n pathGetters,\n extraArgsGetter,\n );\n },\n );\n return objFreeze(store);\n};\n\nconst SHIFT36 = 2 ** 36;\nconst SHIFT30 = 2 ** 30;\nconst SHIFT24 = 2 ** 24;\nconst SHIFT18 = 2 ** 18;\nconst SHIFT12 = 2 ** 12;\nconst SHIFT6 = 2 ** 6;\nconst encodeTimeAndCounter = (logicalTime42, counter24) =>\n encode(logicalTime42 / SHIFT36) +\n encode(logicalTime42 / SHIFT30) +\n encode(logicalTime42 / SHIFT24) +\n encode(logicalTime42 / SHIFT18) +\n encode(logicalTime42 / SHIFT12) +\n encode(logicalTime42 / SHIFT6) +\n encode(logicalTime42) +\n encode(counter24 / SHIFT18) +\n encode(counter24 / SHIFT12) +\n encode(counter24 / SHIFT6) +\n encode(counter24);\nconst decodeTimeAndCounter = (hlc16) => [\n decode(hlc16, 0) * SHIFT36 +\n decode(hlc16, 1) * SHIFT30 +\n decode(hlc16, 2) * SHIFT24 +\n decode(hlc16, 3) * SHIFT18 +\n decode(hlc16, 4) * SHIFT12 +\n decode(hlc16, 5) * SHIFT6 +\n decode(hlc16, 6),\n decode(hlc16, 7) * SHIFT18 +\n decode(hlc16, 8) * SHIFT12 +\n decode(hlc16, 9) * SHIFT6 +\n decode(hlc16, 10),\n];\nconst getHlcFunctions = (uniqueId) => {\n let logicalTime = 0;\n let lastCounter = -1;\n const clientPart = ifNotUndefined(\n uniqueId,\n (uniqueId2) => {\n const clientHash30 = getHash(uniqueId2);\n return (\n encode(clientHash30 / SHIFT24) +\n encode(clientHash30 / SHIFT18) +\n encode(clientHash30 / SHIFT12) +\n encode(clientHash30 / SHIFT6) +\n encode(clientHash30)\n );\n },\n () => getUniqueId(5),\n );\n const getHlc = () => {\n seenHlc();\n return encodeTimeAndCounter(logicalTime, ++lastCounter) + clientPart;\n };\n const seenHlc = (hlc) => {\n const previousLogicalTime = logicalTime;\n const [remoteLogicalTime, remoteCounter] =\n isUndefined(hlc) || hlc == '' ? [0, 0] : decodeTimeAndCounter(hlc);\n logicalTime = mathMax(\n previousLogicalTime,\n remoteLogicalTime,\n GLOBAL.HLC_TIME ?? Date.now(),\n );\n lastCounter =\n logicalTime == previousLogicalTime\n ? logicalTime == remoteLogicalTime\n ? mathMax(lastCounter, remoteCounter)\n : lastCounter\n : logicalTime == remoteLogicalTime\n ? remoteCounter\n : -1;\n };\n return [getHlc, seenHlc];\n};\n\nconst LISTENER_ARGS = {\n HasTable: 1,\n Table: 1,\n TableCellIds: 1,\n HasTableCell: 2,\n RowCount: 1,\n RowIds: 1,\n SortedRowIds: 5,\n HasRow: 2,\n Row: 2,\n CellIds: 2,\n HasCell: 3,\n Cell: 3,\n HasValue: 1,\n Value: 1,\n InvalidCell: 3,\n InvalidValue: 1,\n};\nconst newContentStampMap = (time = EMPTY_STRING) => [\n stampNewMap(time),\n stampNewMap(time),\n];\nconst validateMergeableContent = (mergeableContent) =>\n isArray(mergeableContent) &&\n size(mergeableContent) == 2 &&\n stampValidate(mergeableContent[0], (tableStamps) =>\n objValidate(\n tableStamps,\n (tableStamp) =>\n stampValidate(tableStamp, (rowStamps) =>\n objValidate(\n rowStamps,\n (rowStamp) =>\n stampValidate(rowStamp, (cellStamps) =>\n objValidate(\n cellStamps,\n (cellStamp) =>\n stampValidate(cellStamp, isCellOrValueOrNullOrUndefined),\n void 0,\n 1,\n ),\n ),\n void 0,\n 1,\n ),\n ),\n void 0,\n 1,\n ),\n ) &&\n stampValidate(mergeableContent[1], (values) =>\n objValidate(\n values,\n (value) => stampValidate(value, isCellOrValueOrNullOrUndefined),\n void 0,\n 1,\n ),\n );\nconst createMergeableStore = (uniqueId) => {\n let listeningToRawStoreChanges = 1;\n let contentStampMap = newContentStampMap();\n let defaultingContent = 0;\n const touchedCells = mapNew();\n const touchedValues = setNew();\n const [getHlc, seenHlc] = getHlcFunctions(uniqueId);\n const store = createStore();\n const disableListeningToRawStoreChanges = (actions) => {\n const wasListening = listeningToRawStoreChanges;\n listeningToRawStoreChanges = 0;\n actions();\n listeningToRawStoreChanges = wasListening;\n return mergeableStore;\n };\n const mergeContentOrChanges = (contentOrChanges, isContent = 0) => {\n const tablesChanges = {};\n const valuesChanges = {};\n const [\n [tablesObj, incomingTablesTime = EMPTY_STRING, incomingTablesHash = 0],\n values,\n ] = contentOrChanges;\n const [tablesStampMap, valuesStampMap] = contentStampMap;\n const [tableStampMaps, oldTablesTime, oldTablesHash] = tablesStampMap;\n let tablesHash = isContent ? incomingTablesHash : oldTablesHash;\n let tablesTime = incomingTablesTime;\n objForEach(\n tablesObj,\n (\n [rowsObj, incomingTableTime = EMPTY_STRING, incomingTableHash = 0],\n tableId,\n ) => {\n const tableStampMap = mapEnsure(tableStampMaps, tableId, stampNewMap);\n const [rowStampMaps, oldTableTime, oldTableHash] = tableStampMap;\n let tableHash = isContent ? incomingTableHash : oldTableHash;\n let tableTime = incomingTableTime;\n objForEach(rowsObj, (row, rowId) => {\n const [rowTime, oldRowHash, rowHash] = mergeCellsOrValues(\n row,\n mapEnsure(rowStampMaps, rowId, stampNewMap),\n objEnsure(objEnsure(tablesChanges, tableId, objNew), rowId, objNew),\n isContent,\n );\n tableHash ^= isContent\n ? 0\n : (oldRowHash ? hashIdAndHash(rowId, oldRowHash) : 0) ^\n hashIdAndHash(rowId, rowHash);\n tableTime = getLatestTime(tableTime, rowTime);\n });\n tableHash ^= isContent\n ? 0\n : replaceTimeHash(oldTableTime, incomingTableTime);\n stampUpdate(tableStampMap, incomingTableTime, tableHash);\n tablesHash ^= isContent\n ? 0\n : (oldTableHash ? hashIdAndHash(tableId, oldTableHash) : 0) ^\n hashIdAndHash(tableId, tableStampMap[2]);\n tablesTime = getLatestTime(tablesTime, tableTime);\n },\n );\n tablesHash ^= isContent\n ? 0\n : replaceTimeHash(oldTablesTime, incomingTablesTime);\n stampUpdate(tablesStampMap, incomingTablesTime, tablesHash);\n const [valuesTime] = mergeCellsOrValues(\n values,\n valuesStampMap,\n valuesChanges,\n isContent,\n );\n seenHlc(getLatestTime(tablesTime, valuesTime));\n return [tablesChanges, valuesChanges, 1];\n };\n const mergeCellsOrValues = (\n things,\n thingsStampMap,\n thingsChanges,\n isContent,\n ) => {\n const [\n thingsObj,\n incomingThingsTime = EMPTY_STRING,\n incomingThingsHash = 0,\n ] = things;\n const [thingStampMaps, oldThingsTime, oldThingsHash] = thingsStampMap;\n let thingsTime = incomingThingsTime;\n let thingsHash = isContent ? incomingThingsHash : oldThingsHash;\n objForEach(\n thingsObj,\n ([thing, thingTime, incomingThingHash = 0], thingId) => {\n const thingStampMap = mapEnsure(thingStampMaps, thingId, () => [\n void 0,\n EMPTY_STRING,\n 0,\n ]);\n const [, oldThingTime, oldThingHash] = thingStampMap;\n if (!oldThingTime || thingTime > oldThingTime) {\n stampUpdate(\n thingStampMap,\n thingTime,\n isContent\n ? incomingThingHash\n : getHash(jsonStringWithMap(thing ?? null) + ':' + thingTime),\n );\n thingStampMap[0] = thing;\n thingsChanges[thingId] = thing;\n thingsHash ^= isContent\n ? 0\n : hashIdAndHash(thingId, oldThingHash) ^\n hashIdAndHash(thingId, thingStampMap[2]);\n thingsTime = getLatestTime(thingsTime, thingTime);\n }\n },\n );\n thingsHash ^= isContent\n ? 0\n : replaceTimeHash(oldThingsTime, incomingThingsTime);\n stampUpdate(thingsStampMap, incomingThingsTime, thingsHash);\n return [thingsTime, oldThingsHash, thingsStampMap[2]];\n };\n const preStartTransaction = () => {};\n const preFinishTransaction = () => {};\n const postFinishTransaction = () => {\n collClear(touchedCells);\n collClear(touchedValues);\n };\n const cellChanged = (tableId, rowId, cellId, newCell) => {\n setAdd(\n mapEnsure(mapEnsure(touchedCells, tableId, mapNew), rowId, setNew),\n cellId,\n );\n if (listeningToRawStoreChanges) {\n mergeContentOrChanges([\n [\n {\n [tableId]: [\n {\n [rowId]: [\n {\n [cellId]: [\n newCell,\n defaultingContent ? EMPTY_STRING : getHlc(),\n ],\n },\n ],\n },\n ],\n },\n ],\n [{}],\n 1,\n ]);\n }\n };\n const valueChanged = (valueId, newValue) => {\n setAdd(touchedValues, valueId);\n if (listeningToRawStoreChanges) {\n mergeContentOrChanges([\n [{}],\n [{[valueId]: [newValue, defaultingContent ? EMPTY_STRING : getHlc()]}],\n 1,\n ]);\n }\n };\n const getMergeableContent = () => [\n stampMapToObjWithHash(contentStampMap[0], (tableStampMap) =>\n stampMapToObjWithHash(tableStampMap, (rowStampMap) =>\n stampMapToObjWithHash(rowStampMap),\n ),\n ),\n stampMapToObjWithHash(contentStampMap[1]),\n ];\n const getMergeableContentHashes = () => [\n contentStampMap[0][2],\n contentStampMap[1][2],\n ];\n const getMergeableTableHashes = () =>\n mapToObj(contentStampMap[0][0], getStampHash);\n const getMergeableTableDiff = (otherTableHashes) => {\n const newTables = stampNewObj(contentStampMap[0][1]);\n const differingTableHashes = {};\n mapForEach(\n contentStampMap[0][0],\n (tableId, [tableStampMap, tableTime, hash]) =>\n objHas(otherTableHashes, tableId)\n ? hash != otherTableHashes[tableId]\n ? (differingTableHashes[tableId] = hash)\n : 0\n : (newTables[0][tableId] = stampMapToObjWithoutHash(\n [tableStampMap, tableTime],\n (rowStampMap) => stampMapToObjWithoutHash(rowStampMap),\n )),\n );\n return [newTables, differingTableHashes];\n };\n const getMergeableRowHashes = (otherTableHashes) => {\n const rowHashes = {};\n objForEach(otherTableHashes, (otherTableHash, tableId) =>\n ifNotUndefined(\n mapGet(contentStampMap[0][0], tableId),\n ([rowStampMaps, , tableHash]) =>\n tableHash != otherTableHash\n ? mapForEach(\n rowStampMaps,\n (rowId, [, , rowHash]) =>\n (objEnsure(rowHashes, tableId, objNew)[rowId] = rowHash),\n )\n : 0,\n ),\n );\n return rowHashes;\n };\n const getMergeableRowDiff = (otherTableRowHashes) => {\n const newRows = stampNewObj(contentStampMap[0][1]);\n const differingRowHashes = {};\n objForEach(otherTableRowHashes, (otherRowHashes, tableId) =>\n mapForEach(\n mapGet(contentStampMap[0][0], tableId)?.[0],\n (rowId, [rowStampMap, rowTime, hash]) =>\n objHas(otherRowHashes, rowId)\n ? hash !== otherRowHashes[rowId]\n ? (objEnsure(differingRowHashes, tableId, objNew)[rowId] = hash)\n : 0\n : (objEnsure(newRows[0], tableId, stampNewObj)[0][rowId] =\n stampMapToObjWithoutHash([rowStampMap, rowTime])),\n ),\n );\n return [newRows, differingRowHashes];\n };\n const getMergeableCellHashes = (otherTableRowHashes) => {\n const cellHashes = {};\n objForEach(otherTableRowHashes, (otherRowHashes, tableId) =>\n ifNotUndefined(mapGet(contentStampMap[0][0], tableId), ([rowStampMaps]) =>\n objForEach(otherRowHashes, (otherRowHash, rowId) =>\n ifNotUndefined(\n mapGet(rowStampMaps, rowId),\n ([cellStampMaps, , rowHash]) =>\n rowHash !== otherRowHash\n ? mapForEach(\n cellStampMaps,\n (cellId, [, , cellHash]) =>\n (objEnsure(\n objEnsure(cellHashes, tableId, objNew),\n rowId,\n objNew,\n )[cellId] = cellHash),\n )\n : 0,\n ),\n ),\n ),\n );\n return cellHashes;\n };\n const getMergeableCellDiff = (otherTableRowCellHashes) => {\n const [[tableStampMaps, tablesTime]] = contentStampMap;\n const tablesObj = {};\n objForEach(otherTableRowCellHashes, (otherRowCellHashes, tableId) =>\n objForEach(otherRowCellHashes, (otherCellHashes, rowId) =>\n ifNotUndefined(\n mapGet(tableStampMaps, tableId),\n ([rowStampMaps, tableTime]) =>\n ifNotUndefined(\n mapGet(rowStampMaps, rowId),\n ([cellStampMaps, rowTime]) =>\n mapForEach(cellStampMaps, (cellId, [cell, cellTime, hash]) =>\n hash !== otherCellHashes[cellId]\n ? (objEnsure(\n objEnsure(tablesObj, tableId, () =>\n stampNewObj(tableTime),\n )[0],\n rowId,\n () => stampNewObj(rowTime),\n )[0][cellId] = [cell, cellTime])\n : 0,\n ),\n ),\n ),\n ),\n );\n return stampNew(tablesObj, tablesTime);\n };\n const getMergeableValueHashes = () =>\n mapToObj(contentStampMap[1][0], getStampHash);\n const getMergeableValueDiff = (otherValueHashes) => {\n const [, [valueStampMaps, valuesTime]] = contentStampMap;\n const values = mapToObj(\n valueStampMaps,\n stampClone,\n ([, , hash], valueId) => hash == otherValueHashes?.[valueId],\n );\n return stampNew(values, valuesTime);\n };\n const setMergeableContent = (mergeableContent) =>\n disableListeningToRawStoreChanges(() =>\n validateMergeableContent(mergeableContent)\n ? store.transaction(() => {\n store.delTables().delValues();\n contentStampMap = newContentStampMap();\n store.applyChanges(mergeContentOrChanges(mergeableContent, 1));\n })\n : 0,\n );\n const setDefaultContent = (content) => {\n store.transaction(() => {\n defaultingContent = 1;\n store.setContent(content);\n defaultingContent = 0;\n });\n return mergeableStore;\n };\n const getTransactionMergeableChanges = (withHashes = false) => {\n const [\n [tableStampMaps, tablesTime, tablesHash],\n [valueStampMaps, valuesTime, valuesHash],\n ] = contentStampMap;\n const newStamp = withHashes ? stampNewWithHash : stampNew;\n const tablesObj = {};\n collForEach(touchedCells, (touchedTable, tableId) =>\n ifNotUndefined(\n mapGet(tableStampMaps, tableId),\n ([rowStampMaps, tableTime, tableHash]) => {\n const tableObj = {};\n collForEach(touchedTable, (touchedRow, rowId) =>\n ifNotUndefined(\n mapGet(rowStampMaps, rowId),\n ([cellStampMaps, rowTime, rowHash]) => {\n const rowObj = {};\n collForEach(touchedRow, (cellId) => {\n ifNotUndefined(\n mapGet(cellStampMaps, cellId),\n ([cell, time, hash]) =>\n (rowObj[cellId] = newStamp(cell, time, hash)),\n );\n });\n tableObj[rowId] = newStamp(rowObj, rowTime, rowHash);\n },\n ),\n );\n tablesObj[tableId] = newStamp(tableObj, tableTime, tableHash);\n },\n ),\n );\n const valuesObj = {};\n collForEach(touchedValues, (valueId) =>\n ifNotUndefined(\n mapGet(valueStampMaps, valueId),\n ([value, time, hash]) =>\n (valuesObj[valueId] = newStamp(value, time, hash)),\n ),\n );\n return [\n newStamp(tablesObj, tablesTime, tablesHash),\n newStamp(valuesObj, valuesTime, valuesHash),\n 1,\n ];\n };\n const applyMergeableChanges = (mergeableChanges) =>\n disableListeningToRawStoreChanges(() =>\n store.applyChanges(mergeContentOrChanges(mergeableChanges)),\n );\n const merge = (mergeableStore2) => {\n const mergeableChanges = getMergeableContent();\n const mergeableChanges2 = mergeableStore2.getMergeableContent();\n mergeableStore2.applyMergeableChanges(mergeableChanges);\n return applyMergeableChanges(mergeableChanges2);\n };\n const mergeableStore = {\n getMergeableContent,\n getMergeableContentHashes,\n getMergeableTableHashes,\n getMergeableTableDiff,\n getMergeableRowHashes,\n getMergeableRowDiff,\n getMergeableCellHashes,\n getMergeableCellDiff,\n getMergeableValueHashes,\n getMergeableValueDiff,\n setMergeableContent,\n setDefaultContent,\n getTransactionMergeableChanges,\n applyMergeableChanges,\n merge,\n };\n store.setInternalListeners(\n preStartTransaction,\n preFinishTransaction,\n postFinishTransaction,\n cellChanged,\n valueChanged,\n );\n objToArray(\n store,\n (method, name) =>\n (mergeableStore[name] = // fluent methods\n strStartsWith(name, SET) ||\n strStartsWith(name, DEL) ||\n strStartsWith(name, 'apply') ||\n strEndsWith(name, TRANSACTION) ||\n name == 'call' + LISTENER\n ? (...args) => {\n method(...args);\n return mergeableStore;\n }\n : strStartsWith(name, ADD) && strEndsWith(name, LISTENER)\n ? (...args) => {\n const listenerArg = LISTENER_ARGS[slice(name, 3, -8)] ?? 0;\n const listener = args[listenerArg];\n args[listenerArg] = (_store, ...args2) =>\n listener(mergeableStore, ...args2);\n return method(...args);\n }\n : name == 'isMergeable'\n ? () => true\n : method),\n );\n return objFreeze(mergeableStore);\n};\n\nexport {\n createCheckpoints,\n createIndexes,\n createMergeableStore,\n createMetrics,\n createQueries,\n createRelationships,\n createStore,\n defaultSorter,\n getUniqueId,\n};\n","import {createStore, Row} from 'tinybase';\nimport {getTemplate, VerdocsEndpoint} from '@verdocs/js-sdk';\nimport type {IEnvelope, IEnvelopeField, ITemplate, ITemplateField} from '@verdocs/js-sdk';\n\nconst store = createStore();\n\n// For now, we clear the database every page load to keep it clean and small.\n// We're only using it to synchronize data between isolated components. e-Signing\n// flows don't really benefit from \"offline-first\" approaches anyway, since most\n// of a user's interactions need to go through our servers anyway.\nstore.delTables();\nstore.delValues();\nconsole.log('[STORE] Data store initialized.');\n\nexport const safeJsonParse = (val: any, fallback?: any) => {\n try {\n return JSON.parse(val);\n } catch (e) {\n return fallback || null;\n }\n};\n\nexport const objectToRow = (obj: Object): Row => {\n const row: Row = {};\n for (let key in obj) {\n if (typeof obj[key] === 'string' || typeof obj[key] === 'number' || typeof obj[key] === 'boolean') {\n row[key] = obj[key];\n } else if (obj[key] === null) {\n row[`__null__${key}`] = '';\n } else if (Array.isArray(obj[key])) {\n row[`__array__${key}`] = JSON.stringify(obj[key]);\n } else if (typeof obj[key] === 'object') {\n row[`__object__${key}`] = JSON.stringify(obj[key]);\n }\n }\n\n return row;\n};\n\nexport const rowToObject = <T extends {}>(row: Row): T => {\n const obj = {} as T;\n\n for (let key in row) {\n if (key.startsWith('__null__')) {\n obj[key.replace('__null__', '')] = null;\n } else if (typeof row[key] === 'string' && key.startsWith('__array__')) {\n obj[key.replace('__array__', '')] = safeJsonParse(row[key]);\n } else if (typeof row[key] === 'string' && key.startsWith('__object__')) {\n obj[key.replace('__object__', '')] = safeJsonParse(row[key]);\n } else {\n obj[key] = row[key];\n }\n }\n\n return obj;\n};\n\nexport type TRowUpdatedCallback<T> = (row: T) => void;\nexport type TRowGetter<T> = () => Promise<T>;\n\nexport const Store = {\n store,\n\n // Extends the store's listener mechanism with two features:\n // 1. Apply typing to the return result, and pass the whole updated value to the callback instead\n // of just the \"changes\".\n // 2. Fire the callback immediately with the current value, so that the component can initialize.\n subscribe<T extends object>(tableId: string, rowId: string, getter: TRowGetter<T>, forceReload: boolean, callback: TRowUpdatedCallback<T>): string {\n // We call the callback immediately if the row exists so we get an SWR-like behavior.\n if (store.hasRow(tableId, rowId)) {\n callback(rowToObject<T>(store.getRow(tableId, rowId)));\n }\n\n const listenerId = store.addRowListener(tableId, rowId, () => {\n const row = store.getRow(tableId, rowId);\n callback(rowToObject<T>(row));\n });\n\n if (!store.hasRow(tableId, rowId) || forceReload) {\n console.log('[STORE] Loading/reloading', {tableId, rowId});\n getter()\n .then(result => {\n // We don't need to call the callback because it's already listening\n store.setRow(tableId, rowId, objectToRow(result));\n })\n .catch(e => {\n console.error('[STORE] Error getting row', {tableId, rowId, forceReload}, e);\n });\n }\n\n return listenerId;\n },\n\n unsubscribe(listenerId: string) {\n store.delListener(listenerId);\n },\n\n async getTemplate(endpoint: VerdocsEndpoint, templateId: string, reload: boolean = false): Promise<ITemplate | null> {\n if (!reload) {\n if (!store.hasRow('templates', templateId)) {\n return null;\n }\n\n const row = store.getRow('templates', templateId);\n return rowToObject<ITemplate>(row);\n }\n\n const template = await getTemplate(endpoint, templateId);\n console.log('[STORE] Reloading template', template);\n store.setRow('templates', templateId, objectToRow(template));\n return template;\n },\n\n updateTemplate(templateId: string, template: ITemplate) {\n store.setRow('templates', templateId, objectToRow(template));\n return template;\n },\n\n async getEnvelope(endpoint: VerdocsEndpoint, envelopeId: string, reload: boolean = false): Promise<ITemplate | null> {\n if (!reload) {\n if (!store.hasRow('envelopes', envelopeId)) {\n return null;\n }\n\n const row = store.getRow('envelopes', envelopeId);\n return rowToObject<ITemplate>(row);\n }\n\n const envelope = await getTemplate(endpoint, envelopeId);\n store.setRow('envelopes', envelopeId, objectToRow(envelope));\n return envelope;\n },\n\n updateEnvelope(envelopeId: string, envelope: IEnvelope) {\n store.setRow('envelopes', envelopeId, objectToRow(envelope));\n return envelope;\n },\n\n // Get a field from an already-loaded envelope or template. Intended to be\n // called by the verdocs-field-* components themselves which are only rendered\n // after a template or envelope is already loaded and cached in the store, so\n // no attempt is made to load the parent record if it isn't already known.\n getField(source: 'template' | 'envelope', sourceId: string, fieldName: string, fieldOverride: ITemplateField | IEnvelopeField | null | undefined) {\n if (source === 'template') {\n const row = store.getRow('templates', sourceId);\n const template = rowToObject<ITemplate>(row);\n const field = (template.fields || []).find(field => field.name === fieldName);\n\n const roleNames = (template.roles || []).map(role => role.name);\n const index = roleNames.findIndex(name => name === field.role_name);\n\n return {index: Math.max(index, 0), field: fieldOverride || field};\n } else {\n const row = store.getRow('envelopes', sourceId);\n const envelope = rowToObject<IEnvelope>(row);\n const field = (envelope.fields || []).find(field => field.name === fieldName);\n\n const roleNames = (envelope.recipients || []).map(recipient => recipient.role_name);\n const index = roleNames.findIndex(name => name === field.role_name);\n\n return {index, field: fieldOverride || field};\n }\n },\n};\n"],"mappings":"yuDAAA,IAAM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A,G,QAGTC,eAAc,SAACF,EAAoBC,GACjClX,MAAMgR,OAAO,YAAaiG,EAAYzB,YAAY0B,IAClD,OAAOA,C,EAOTE,SAAQ,SAACC,EAAiCC,EAAkBC,EAAmBC,GAC7E,GAAIH,IAAW,WAAY,CACzB,IAAM7O,EAAMxI,MAAM6P,OAAO,YAAayH,GACtC,IAAMV,EAAWlB,YAAuBlN,GACxC,IAAMiP,GAASb,EAASc,QAAU,IAAIC,MAAK,SAAAC,GAAS,OAAAA,EAAMC,OAASN,CAAf,IAEpD,IAAMO,GAAalB,EAASmB,OAAS,IAAI/d,KAAI,SAAAge,GAAQ,OAAAA,EAAKH,IAAL,IACrD,IAAMpe,EAAQqe,EAAUG,WAAU,SAAAJ,GAAQ,OAAAA,IAASJ,EAAMS,SAAf,IAE1C,MAAO,CAACze,MAAO0e,KAAKC,IAAI3e,EAAO,GAAIme,MAAOJ,GAAiBC,E,KACtD,CACL,IAAMjP,EAAMxI,MAAM6P,OAAO,YAAayH,GACtC,IAAMJ,EAAWxB,YAAuBlN,GACxC,IAAM6P,GAASnB,EAASQ,QAAU,IAAIC,MAAK,SAAAC,GAAS,OAAAA,EAAMC,OAASN,CAAf,IAEpD,IAAMO,GAAaZ,EAASoB,YAAc,IAAIte,KAAI,SAAAue,GAAa,OAAAA,EAAUL,SAAV,IAC/D,IAAMze,EAAQqe,EAAUG,WAAU,SAAAJ,GAAQ,OAAAA,IAASQ,EAAMH,SAAf,IAE1C,MAAO,CAACze,MAAKA,EAAEme,MAAOJ,GAAiBa,E","ignoreList":[]}
|
@@ -1,2 +0,0 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,i,t,n){function s(e){return e instanceof t?e:new t((function(i){i(e)}))}return new(t||(t=Promise))((function(t,o){function r(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n["throw"](e))}catch(e){o(e)}}function l(e){e.done?t(e.value):s(e.value).then(r,a)}l((n=n.apply(e,i||[])).next())}))};var __generator=this&&this.__generator||function(e,i){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,s,o,r;return r={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(r[Symbol.iterator]=function(){return this}),r;function a(e){return function(i){return l([e,i])}}function l(a){if(n)throw new TypeError("Generator is already executing.");while(r&&(r=0,a[0]&&(t=0)),t)try{if(n=1,s&&(o=a[0]&2?s["return"]:a[0]?s["throw"]||((o=s["return"])&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;if(s=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:t.label++;return{value:a[1],done:false};case 5:t.label++;s=a[1];a=[0];continue;case 7:a=t.ops.pop();t.trys.pop();continue;default:if(!(o=t.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){t.label=a[1];break}if(a[0]===6&&t.label<o[1]){t.label=o[1];o=a;break}if(o&&t.label<o[2]){t.label=o[2];t.ops.push(a);break}if(o[2])t.ops.pop();t.trys.pop();continue}a=i.call(e,t)}catch(e){a=[6,e];s=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};System.register(["./p-9186f42e.system.js","@verdocs/js-sdk","./p-d738b5db.system.js","./p-9b26e4e0.system.js","./p-c8a15cb7.system.js","./p-65be7617.system.js","./p-2c5350ec.system.js"],(function(e){"use strict";var i,t,n,s,o,r,a,l,d,c,v,p,h,f,u,w,m,g;return{setters:[function(e){i=e.r;t=e.c;n=e.h;s=e.F;o=e.H},function(e){r=e.VerdocsEndpoint;a=e.getEnvelope;l=e.resendInvitation;d=e.cancelEnvelope;c=e.formatFullName;v=e.updateEnvelope;p=e.userIsEnvelopeOwner;h=e.capitalize},function(e){f=e.F},function(e){u=e.V},function(e){w=e.S},function(e){m=e.S},function(e){g=e.f}],execute:function(){var b='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-envelope-sidebar{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;-ms-flex-direction:row;flex-direction:row;display:-ms-flexbox;display:flex;-ms-flex:0 0 56px;flex:0 0 56px;width:56px;min-height:400px;height:100%;background:#41435e;-webkit-transition:0.5s cubic-bezier(0.35, 0, 0.25, 1);transition:0.5s cubic-bezier(0.35, 0, 0.25, 1)}verdocs-envelope-sidebar.open{-ms-flex:0 0 400px;flex:0 0 400px;max-width:100%;width:400px}@media screen and (max-width: 500px){verdocs-envelope-sidebar.open{-ms-flex:0 0 300px;flex:0 0 300px;width:300px}}verdocs-envelope-sidebar .side-buttons{-ms-flex-direction:column;flex-direction:column;-ms-flex:0 0 56px;flex:0 0 56px;display:-ms-flexbox;display:flex}verdocs-envelope-sidebar .side-buttons button{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;height:50px;outline:none;border:none;border-left:2px solid transparent;background:none;width:100%}verdocs-envelope-sidebar .side-buttons button.active{border-left:2px solid #50bd80}verdocs-envelope-sidebar .side-buttons button svg{color:white;width:24px;height:24px}verdocs-envelope-sidebar .content{-ms-flex:1;flex:1;display:none;color:white;-ms-flex-direction:column;flex-direction:column;padding:12px 16px 16px}verdocs-envelope-sidebar.open .content{display:-ms-flexbox;display:flex;overflow-y:scroll}verdocs-envelope-sidebar verdocs-ok-dialog .content{color:black}verdocs-envelope-sidebar .title{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-bottom:12px;font-size:16px;line-height:24px;font-weight:400}verdocs-envelope-sidebar .label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:12px;line-height:16px;color:rgba(255, 255, 255, 0.54)}verdocs-envelope-sidebar .value{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-bottom:14px;font-size:14px;font-weight:500;line-height:16px;color:#fff}verdocs-envelope-sidebar .manage-recipients-button{-ms-flex-item-align:center;align-self:center;white-space:nowrap;width:100%;margin:0 0 10px 0}verdocs-envelope-sidebar .manage-recipients-button .label{color:#ffffff;font-size:14px}verdocs-envelope-sidebar .manage-recipients-button button{width:100%}verdocs-envelope-sidebar .recipient-detail{-ms-flex:0;flex:0;padding:8px;font-size:14px;position:relative;-ms-flex-direction:column;flex-direction:column;border:solid 1px #979797;margin-bottom:16px}verdocs-envelope-sidebar .recipient-header{-ms-flex-direction:row;flex-direction:row;-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;gap:6px;-ms-flex-align:center;align-items:center;margin-bottom:4px}verdocs-envelope-sidebar .recipient-number{width:24px;height:24px;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;border-radius:24px;font-size:14px;font-weight:500;border:solid 1px #979797}verdocs-envelope-sidebar .recipient-name{-ms-flex:1;flex:1;-webkit-box-sizing:border-box;box-sizing:border-box;text-transform:capitalize}verdocs-envelope-sidebar .recipient-status{-ms-flex:0 0 100px;flex:0 0 100px;border-radius:5px;text-align:center;-webkit-box-sizing:border-box;box-sizing:border-box;max-width:100px;min-width:100px;background-color:#616161;text-transform:capitalize;font-size:14px;padding:3px 0}verdocs-envelope-sidebar .recipient-status.invited{background-color:#ff8f00}verdocs-envelope-sidebar .recipient-status.opened{background-color:#616161}verdocs-envelope-sidebar .recipient-status.signed,verdocs-envelope-sidebar .recipient-status.submitted{background-color:#2e7d32}verdocs-envelope-sidebar .recipient-status.pending{background-color:#0277bd}verdocs-envelope-sidebar .recipient-status.canceled,verdocs-envelope-sidebar .recipient-status.declined{background-color:#c62828}@media screen and (max-width: 500px){verdocs-envelope-sidebar .recipient-status{-ms-flex:1 1 60px;flex:1 1 60px;max-width:60px;min-width:60px}}verdocs-envelope-sidebar .recipient-content{-ms-flex-direction:column;flex-direction:column}verdocs-envelope-sidebar .recipient-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}verdocs-envelope-sidebar .history-entry{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;padding:8px 0 0;margin:8px 0 0;border-top:1px solid #dddddd}verdocs-envelope-sidebar .history-entry .activity-icon{margin-right:14px}verdocs-envelope-sidebar .history-entry .activity-icon svg{width:24px;height:24px;fill:#ffffff}verdocs-envelope-sidebar .history-entry .activity-text{font-size:14px;line-height:16px;margin-bottom:4px}verdocs-envelope-sidebar .history-entry .activity-date{font-size:12px;line-height:16px;color:rgba(255, 255, 255, 0.54)}verdocs-envelope-sidebar .content .history-entry:first-of-type{border-top:none}verdocs-envelope-sidebar .reminders{margin:15px 0 30px 0}verdocs-envelope-sidebar .reminders .form-row{margin:8px 0 0;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row}verdocs-envelope-sidebar .reminders .form-row .reminders-label{display:-ms-flexbox;display:flex;-ms-flex:1;flex:1}verdocs-envelope-sidebar .reminders .form-row .form-label{-ms-flex:1;flex:1}verdocs-envelope-sidebar .reminders .form-row verdocs-text-input{margin:0;width:100px}';var x=b;var y=24*60*60*1e3;var k='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="#ffffff"><path stroke-linecap="round" stroke-linejoin="round" d="M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z" /></svg>';var z='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="#ffffff"><path stroke-linecap="round" stroke-linejoin="round" d="M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z" /></svg>';var M='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="#ffffff"><path stroke-linecap="round" stroke-linejoin="round" d="M9 12h3.75M9 15h3.75M9 18h3.75m3 .75H18a2.25 2.25 0 002.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 00-1.123-.08m-5.801 0c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 00.75-.75 2.25 2.25 0 00-.1-.664m-5.8 0A2.251 2.251 0 0113.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m0 0H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V9.375c0-.621-.504-1.125-1.125-1.125H8.25zM6.75 12h.008v.008H6.75V12zm0 3h.008v.008H6.75V15zm0 3h.008v.008H6.75V18z" /></svg>';var D={visibility:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#ffffff"><path d="M12 15a3 3 0 100-6 3 3 0 000 6z" /><path fill-rule="evenodd" d="M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 010-1.113zM17.25 12a5.25 5.25 0 11-10.5 0 5.25 5.25 0 0110.5 0z" clip-rule="evenodd" /></svg>',pencil:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#ffffff"><path d="M21.731 2.269a2.625 2.625 0 00-3.712 0l-1.157 1.157 3.712 3.712 1.157-1.157a2.625 2.625 0 000-3.712zM19.513 8.199l-3.712-3.712-12.15 12.15a5.25 5.25 0 00-1.32 2.214l-.8 2.685a.75.75 0 00.933.933l2.685-.8a5.25 5.25 0 002.214-1.32L19.513 8.2z" /></svg>',mail:'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"/></svg>',contact_mail:'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"/></svg>',done:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#ffffff"><path fill-rule="evenodd" d="M19.916 4.626a.75.75 0 01.208 1.04l-9 13.5a.75.75 0 01-1.154.114l-6-6a.75.75 0 011.06-1.06l5.353 5.353 8.493-12.739a.75.75 0 011.04-.208z" clip-rule="evenodd" /></svg>',send:'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>',gesture:'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M4.59 6.89c.7-.71 1.4-1.35 1.71-1.22.5.2 0 1.03-.3 1.52-.25.42-2.86 3.89-2.86 6.31 0 1.28.48 2.34 1.34 2.98.75.56 1.74.73 2.64.46 1.07-.31 1.95-1.4 3.06-2.77 1.21-1.49 2.83-3.44 4.08-3.44 1.63 0 1.65 1.01 1.76 1.79-3.78.64-5.38 3.67-5.38 5.37 0 1.7 1.44 3.09 3.21 3.09 1.63 0 4.29-1.33 4.69-6.1H21v-2.5h-2.47c-.15-1.65-1.09-4.2-4.03-4.2-2.25 0-4.18 1.91-4.94 2.84-.58.73-2.06 2.48-2.29 2.72-.25.3-.68.84-1.11.84-.45 0-.72-.83-.36-1.92.35-1.09 1.4-2.86 1.85-3.52.78-1.14 1.3-1.92 1.3-3.28C8.95 3.69 7.31 3 6.44 3 5.12 3 3.97 4 3.72 4.25c-.36.36-.66.66-.88.93l1.75 1.71zm9.29 11.66c-.31 0-.74-.26-.74-.72 0-.6.73-2.2 2.87-2.76-.3 2.69-1.43 3.48-2.13 3.48z"/></svg>',clear:'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>',check_circle:'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>',link:'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg>',cancel:'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"/></svg>',done_all:'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M18 7l-1.41-1.41-6.34 6.34 1.41 1.41L18 7zm4.24-1.41L11.66 16.17 7.48 12l-1.41 1.41L11.66 19l12-12-1.42-1.41zM.41 13.41L6 19l1.41-1.41L1.83 12 .41 13.41z"/></svg>',create:'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg>',perm_identity:'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg>',people:'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"/></svg>',contact_email:'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M21 8V7l-3 2-3-2v1l3 2 3-2zm1-5H2C.9 3 0 3.9 0 5v14c0 1.1.9 2 2 2h20c1.1 0 1.99-.9 1.99-2L24 5c0-1.1-.9-2-2-2zM8 6c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm6 12H2v-1c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1zm8-6h-8V6h8v6z"/></svg>',textsms:'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM9 11H7V9h2v2zm4 0h-2V9h2v2zm4 0h-2V9h2v2z"/></svg>',verified_user:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#ffffff"><path fill-rule="evenodd" d="M12.516 2.17a.75.75 0 00-1.032 0 11.209 11.209 0 01-7.877 3.08.75.75 0 00-.722.515A12.74 12.74 0 002.25 9.75c0 5.942 4.064 10.933 9.563 12.348a.749.749 0 00.374 0c5.499-1.415 9.563-6.406 9.563-12.348 0-1.39-.223-2.73-.635-3.985a.75.75 0 00-.722-.516l-.143.001c-2.996 0-5.717-1.17-7.734-3.08zm3.094 8.016a.75.75 0 10-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.14-.094l3.75-5.25z" clip-rule="evenodd" /></svg>',account_circle:'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z"/></svg>'};var _=e("verdocs_envelope_sidebar",function(){function e(e){i(this,e);this.sdkError=t(this,"sdkError",7);this.envelopeUpdated=t(this,"envelopeUpdated",7);this.toggle=t(this,"toggle",7);this.another=t(this,"another",7);this.envelopeListenerId=null;this.endpoint=r.getDefault();this.envelopeId="";this.activeTab=1;this.panelOpen=false;this.showRecipientDialog="";this.showCancelDialog=false;this.remindersEnabled=false;this.updatingReminders=false;this.initialReminder=null;this.followupReminders=null;this.loading=true;this.envelope=null}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,i,t;return __generator(this,(function(n){try{this.endpoint.loadSession();if(!this.envelopeId){console.log("[SIDEBAR] Missing required envelope ID ".concat(this.envelopeId));return[2]}if(!this.endpoint.session){console.log("[SIDEBAR] Unable to start session, must be authenticated");return[2]}this.listenToEnvelope()}catch(n){console.log("[SIDEBAR] Error loading envelope",n);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new w(n.message,(i=n.response)===null||i===void 0?void 0:i.status,(t=n.response)===null||t===void 0?void 0:t.data))}return[2]}))}))};e.prototype.disconnectedCallback=function(){this.unlistenToEnvelope()};e.prototype.listenToEnvelope=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(i){console.log("[SIDEBAR] Loading envelope",this.envelopeId);this.unlistenToEnvelope();m.subscribe("envelopes",this.envelopeId,(function(){return a(e.endpoint,e.envelopeId)}),false,(function(i){var t,n;e.envelope=i;e.loading=false;e.sortEnvelopeRecipients();e.initialReminder=(t=e.envelope)===null||t===void 0?void 0:t.initial_reminder;e.followupReminders=(n=e.envelope)===null||n===void 0?void 0:n.followup_reminders;e.remindersEnabled=!!e.initialReminder}));return[2]}))}))};e.prototype.unlistenToEnvelope=function(){if(this.envelopeListenerId){m.store.delListener(this.envelopeListenerId);this.envelopeListenerId=null}};e.prototype.sortEnvelopeRecipients=function(){var e;(((e=this.envelope)===null||e===void 0?void 0:e.recipients)||[]).sort((function(e,i){return e.sequence===i.sequence?e.order-i.order:e.sequence-i.sequence}))};e.prototype.setTab=function(e){var i;this.panelOpen=e!==this.activeTab||!this.panelOpen;(i=this.toggle)===null||i===void 0?void 0:i.emit({open:this.panelOpen});this.activeTab=e};e.prototype.canResendRecipient=function(e){var i;return!["pending","declined","submitted","canceled"].includes(e.status)&&!["complete","declined","canceled"].includes((i=this.envelope)===null||i===void 0?void 0:i.status)};e.prototype.handleRecipientAction=function(e,i){var t;console.log("[SIDEBAR] Recipient action",i,e);switch(i){case"reminder":l(this.endpoint,this.envelopeId,e.role_name).then((function(){u("Reminder Sent",{style:"success"})})).catch((function(e){console.log("[SIDEBAR] Error resending invitation",e);u("Error resending invitation: "+e.message,{style:"error"})}));break;case"inperson":this.showRecipientDialog=e.role_name;break;case"modify":u("This feature will be enabled in a future release. Please try again later.",{style:"info"});break;case"details":u("This feature will be enabled in a future release. Please try again later.",{style:"info"});break}(t=this.envelopeUpdated)===null||t===void 0?void 0:t.emit({endpoint:this.endpoint,envelope:this.envelope,event:i})};e.prototype.handleCancelEnvelope=function(){var e=this;this.loading=true;d(this.endpoint,this.envelopeId).then((function(i){return __awaiter(e,void 0,void 0,(function(){var e,t;return __generator(this,(function(n){console.log("[SIDEBAR] Envelope canceled",i);u("Envelope canceled",{style:"success"});t=JSON.parse(JSON.stringify(this.envelope));t.status="canceled";m.updateEnvelope(this.envelopeId,t);this.loading=false;this.panelOpen=false;(e=this.envelopeUpdated)===null||e===void 0?void 0:e.emit({endpoint:this.endpoint,envelope:t,event:"canceled"});return[2]}))}))})).catch((function(i){console.log("[SIDEBAR] Error canceling envelope",i);e.loading=false;u("Error canceling envelope: "+i.message,{style:"error"})}))};e.prototype.prepareHistoryEntries=function(){var e=this;var i,t,n,s,o,r;var a=[];var l=((i=this.envelope)===null||i===void 0?void 0:i.history_entries)||[];a.push({icon:"pencil",message:"Envelope created.",date:new Date((t=this.envelope)===null||t===void 0?void 0:t.created_at)});if(((n=this.envelope)===null||n===void 0?void 0:n.status)==="complete"){a.push({icon:"pencil",message:"Envelope completed.",date:new Date((s=this.envelope)===null||s===void 0?void 0:s.updated_at)})}var d=l.some((function(e){return e.event==="owner:canceled"}));if(((o=this.envelope)===null||o===void 0?void 0:o.status)==="canceled"&&!d){a.push({icon:"pencil",message:"Envelope Cancelled.",date:new Date((r=this.envelope)===null||r===void 0?void 0:r.canceled_at)})}l.forEach((function(i){var t;var n=(((t=e.envelope)===null||t===void 0?void 0:t.recipients)||[]).find((function(e){return e.role_name===i.role_name}));var s=c(n);switch(i.event.toLowerCase()){case"recipient:signed":a.push({icon:"gesture",message:"Signed by ".concat(s,"."),date:new Date(i.created_at)});break;case"recipient:declined":a.push({icon:"clear",message:"Declined by ".concat(s,"."),date:new Date(i.created_at)});break;case"recipient:opened":switch(i.event_detail){case"email":case"mail":a.push({icon:"visibility",message:"Opened by ".concat(s,", via email."),date:new Date(i.created_at)});break;case"sms":a.push({icon:"visibility",message:"Opened by ".concat(s,", via SMS."),date:new Date(i.created_at)});break;case"in_person_link":a.push({icon:"visibility",message:"Opened by ".concat(s,", via In-person link."),date:new Date(i.created_at)});break;case"in_app":a.push({icon:"visibility",message:"Opened by ".concat(s,", via dashboard."),date:new Date(i.created_at)});break;default:a.push({icon:"visibility",message:"Opened by ".concat(s,"."),date:new Date(i.created_at)})}break;case"recipient:submitted":switch(i.event_detail){case"approver":a.push({icon:"check_circle",message:"Approved by ".concat(s,"."),date:new Date(i.created_at)});break;default:a.push({icon:"send",message:"Submitted by ".concat(s,"."),date:new Date(i.created_at)});break}break;case"recipient:prepared":a.push({icon:"send",message:"Prepared by ".concat(s,"."),date:new Date(i.created_at)});break;case"recipient:claimed":if(i.event_detail==="guest"){a.push({icon:"account_circle",message:"".concat(s," claimed the Envelope as a guest."),date:new Date(i.created_at)})}else if(i.event_detail==="profile"){a.push({icon:"verified_user",message:"".concat(s," claimed the Envelope as a verified user."),date:new Date(i.created_at)})}break;case"recipient:agreed":a.push({icon:"done",message:"".concat(s," agreed to use electronic records and signatures."),date:new Date(i.created_at)});break;case"recipient:invited":if(i.event_detail==="sms"){a.push({icon:"textsms",message:"".concat(s," has been invited via SMS."),date:new Date(i.created_at)})}else{a.push({icon:"mail",message:"".concat(s," has been invited via email."),date:new Date(i.created_at)})}break;case"recipient:reminder":if(i.event_detail==="sms"){a.push({icon:"textsms",message:"".concat(s," sent a reminder via SMS."),date:new Date(i.created_at)})}else{a.push({icon:"mail",message:"".concat(s," sent a reminder via email."),date:new Date(i.created_at)})}break;case"invitation:resent":a.push({icon:"mail",message:"Invitation was resent to ".concat(s).concat(i.event_detail==="reminder"?" by reminder":"","."),date:new Date(i.created_at)});break;case"envelope:cc":a.push({icon:"contact_mail",message:"A copy has been sent to ".concat(s,"."),date:new Date(i.created_at)});break;case"recipient:delegated":a.push({icon:"people",message:i.event_detail,date:new Date(i.created_at)});break;case"recipient:updated_info":a.push({icon:"perm_identity",message:i.event_detail,date:new Date(i.created_at)});break;case"owner:updated_recipient_info":a.push({icon:"perm_identity",message:i.event_detail,date:new Date(i.created_at)});break;case"created":a.push({icon:"create",message:"Envelope was created.",date:new Date(i.created_at)});break;case"completed":a.push({icon:"done_all",message:"Envelope was completed.",date:new Date(i.created_at)});break;case"envelope:canceled":case"envelope_canceled":case"canceled":case"owner:canceled":a.push({icon:"cancel",message:"Envelope was canceled by the creator.",date:new Date(i.created_at)});break;case"owner:get_in_person_link":a.push({icon:"link",message:"Owner accessed the In-person link for ".concat(n,"."),date:new Date(i.created_at)});break;default:console.log("[SIDEBAR] Unknown history type",i);break}}));a.sort((function(e,i){return i.date.getTime()-e.date.getTime()}));return a};e.prototype.handleToggleReminders=function(){if(this.remindersEnabled){return this.handleSetReminders(null,null)}else{return this.handleSetReminders(y,3*y)}};e.prototype.handleSetReminders=function(e,i){var t=this;console.log("Updating reminders...");this.updatingReminders=true;v(this.endpoint,this.envelopeId,{initial_reminder:e,followup_reminders:i}).then((function(e){console.log("Updated",e);m.updateEnvelope(t.envelopeId,e);t.initialReminder=e.initial_reminder;t.followupReminders=e.followup_reminders;t.remindersEnabled=!!e.initial_reminder;t.updatingReminders=false})).catch((function(e){var i,n,s;console.log("Error updating envelope",e);t.initialReminder=(i=t.envelope)===null||i===void 0?void 0:i.initial_reminder;t.followupReminders=(n=t.envelope)===null||n===void 0?void 0:n.followup_reminders;t.remindersEnabled=!!((s=t.envelope)===null||s===void 0?void 0:s.initial_reminder);t.updatingReminders=false;alert(e.response.data.error)}))};e.prototype.render=function(){var e=this;var i,t,r,a,l,d,v,u,w,m,b,x;if(this.loading){return n(o,null)}var _=p(this.endpoint.profile,this.envelope);var S=this.prepareHistoryEntries();var B=((i=this.envelope)===null||i===void 0?void 0:i.status)!=="pending"&&((t=this.envelope)===null||t===void 0?void 0:t.status)!=="in progress";return n(o,{class:this.panelOpen?"open":""},n("div",{class:"side-buttons"},n("button",{class:this.activeTab===1?"active":"",onClick:function(){return e.setTab(1)},innerHTML:k}),n("button",{class:this.activeTab===2?"active":"",onClick:function(){return e.setTab(2)},innerHTML:z}),n("button",{class:this.activeTab===3?"active":"",onClick:function(){return e.setTab(3)},innerHTML:M})),this.activeTab===1&&n("div",{class:"content"},n("div",{class:"title"},"Details"),n("div",{class:"label"},"Envelope ID"),n("div",{class:"value"},(r=this.envelope)===null||r===void 0?void 0:r.id),n("div",{class:"label"},"Date Created"),n("div",{class:"value"},g(new Date((a=this.envelope)===null||a===void 0?void 0:a.created_at),f)),n("div",{class:"label"},"Last Modified"),n("div",{class:"value"},g(new Date((l=this.envelope)===null||l===void 0?void 0:l.updated_at),f)),n("div",{class:"label"},"Status"),n("div",{class:"value"},h((d=this.envelope)===null||d===void 0?void 0:d.status)),n("div",{class:"label"},"Owner ID"),n("div",{class:"value"},(v=this.envelope)===null||v===void 0?void 0:v.profile_id),n("div",{class:"label"},"Owner Name"),n("div",{class:"value"},c((u=this.envelope)===null||u===void 0?void 0:u.profile)),n("div",{class:"label"},"Owner Email"),n("div",{class:"value"},(m=(w=this.envelope)===null||w===void 0?void 0:w.profile)===null||m===void 0?void 0:m.email)),this.activeTab===2&&n("div",{class:"content"},n("div",{class:"title"},"Recipients"),(b=this.envelope)===null||b===void 0?void 0:b.recipients.map((function(i,t){var s;var o=i.status!=="submitted"&&i.status!=="canceled"&&i.status!=="declined";var r=e.canResendRecipient(i);var a=c(i);return n("div",{class:"recipient-detail"},n("div",{class:"recipient-header"},n("div",{class:"recipient-number"},t+1),n("div",{class:"recipient-name"},i.role_name),n("div",{class:(s={"recipient-status":true},s[i.status]=true,s)},i.status),_&&!B&&n("verdocs-dropdown",{onOptionSelected:function(t){return e.handleRecipientAction(i,t.detail.id)},options:[{id:"reminder",label:"Send Reminder",disabled:!r},{id:"inperson",label:"Get In-Person Link",disabled:!o}]})),n("dic",{class:"recipient-content"},n("div",{class:"recipient-name"},a),n("div",{class:"recipient-name"},i.email),n("div",{class:"recipient-name"},i.phone)))})),_&&n("div",{class:"reminders"},n("div",{class:"form-row"},n("div",{class:"reminders-label"},"Reminders"),n("verdocs-switch",{disabled:B||this.updatingReminders,checked:this.remindersEnabled,onCheckedChange:function(){return e.handleToggleReminders()}})),this.remindersEnabled&&n(s,null,n("div",{class:"form-row"},"NOTE: Reminders will only be sent for up to 14 days."),n("div",{class:"form-row"},n("div",{class:"form-label"},"Initial Reminder (days):"),n("verdocs-text-input",{placeholder:"In hours...",disabled:B||this.updatingReminders,value:String(Math.floor(this.initialReminder/y)),onBlur:function(i){e.initialReminder=Number(i.target.value)*y;e.handleSetReminders(e.initialReminder,e.followupReminders)}})),n("div",{class:"form-row"},n("div",{class:"form-label"},"Follow-up Reminders:"),n("verdocs-text-input",{placeholder:"In hours...",disabled:B||this.updatingReminders,value:String(Math.floor(this.followupReminders/y)),onBlur:function(i){e.followupReminders=Number(i.target.value)*y;e.handleSetReminders(e.initialReminder,e.followupReminders)}})),n("div",{class:"form-row"},n("div",{class:"form-label"},"Next Reminder:"),n("div",{style:{color:"#dddddd"}},g(new Date((x=this.envelope)===null||x===void 0?void 0:x.next_reminder),"P p"))))),_&&n("verdocs-button",{class:"manage-recipients-button",variant:"standard",label:"Cancel Envelope",onClick:function(){return e.showCancelDialog=!B},disabled:B})),this.activeTab===3&&n("div",{class:"content"},n("div",{class:"title"},"History"),S.map((function(e){return n("div",{class:"history-entry"},n("div",{class:"activity-icon",innerHTML:D[e.icon]||e.icon}),n("div",{class:"activity-details"},n("div",{class:"activity-text"},e.message),n("div",{class:"activity-date"},g(e.date,f))))}))),this.showRecipientDialog&&n("verdocs-envelope-recipient-link",{envelopeId:this.envelopeId,roleName:this.showRecipientDialog,onNext:function(){return e.showRecipientDialog=""}}),this.showCancelDialog&&n("verdocs-ok-dialog",{heading:"Cancel Envelope?",message:"Are you sure you want to cancel this Envelope? This action cannot be undone.",onNext:function(){e.showCancelDialog=false;e.handleCancelEnvelope()}}))};return e}());_.style=x}}}));
|
2
|
-
//# sourceMappingURL=p-2175c81a.system.entry.js.map
|