@verdocs/web-sdk 5.0.25 → 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 +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 +1 -1
- package/dist/cjs/verdocs-template-document-page_2.cjs.entry.js +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 +2 -2
- 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 +2 -2
- 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 +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 +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-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-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-9ab8bcaa.system.entry.js → p-1f2c019d.system.entry.js} +2 -2
- 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-4e3790db.system.entry.js → p-70247599.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-e84cf41e.entry.js → p-8369273d.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-f84ba101.entry.js → p-a285560f.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-75e53ae1.entry.js → p-b7799ec0.entry.js} +2 -2
- 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/custom-elements.json +0 -2156
- 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-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-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-9ab8bcaa.system.entry.js.map → p-1f2c019d.system.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-4e3790db.system.entry.js.map → p-70247599.system.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-f84ba101.entry.js.map → p-a285560f.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-75e53ae1.entry.js.map → p-b7799ec0.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,2 +1,2 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,t,i,o){function r(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,a){function s(e){try{c(o.next(e))}catch(e){a(e)}}function n(e){try{c(o["throw"](e))}catch(e){a(e)}}function c(e){e.done?i(e.value):r(e.value).then(s,n)}c((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},o,r,a,s;return s={next:n(0),throw:n(1),return:n(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function n(e){return function(t){return c([e,t])}}function c(n){if(o)throw new TypeError("Generator is already executing.");while(s&&(s=0,n[0]&&(i=0)),i)try{if(o=1,r&&(a=n[0]&2?r["return"]:n[0]?r["throw"]||((a=r["return"])&&a.call(r),0):r.next)&&!(a=a.call(r,n[1])).done)return a;if(r=0,a)n=[n[0]&2,a.value];switch(n[0]){case 0:case 1:a=n;break;case 4:i.label++;return{value:n[1],done:false};case 5:i.label++;r=n[1];n=[0];continue;case 7:n=i.ops.pop();i.trys.pop();continue;default:if(!(a=i.trys,a=a.length>0&&a[a.length-1])&&(n[0]===6||n[0]===2)){i=0;continue}if(n[0]===3&&(!a||n[1]>a[0]&&n[1]<a[3])){i.label=n[1];break}if(n[0]===6&&i.label<a[1]){i.label=a[1];a=n;break}if(a&&i.label<a[2]){i.label=a[2];i.ops.push(n);break}if(a[2])i.ops.pop();i.trys.pop();continue}n=t.call(e,i)}catch(e){n=[6,e];r=0}finally{o=a=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:true}}};System.register(["./p-9186f42e.system.js","@verdocs/js-sdk","./p-f29eb00a.system.js","./p-65be7617.system.js","./p-e0ac9edf.system.js","./p-21b1acec.system.js","./p-d738b5db.system.js","./p-2c5350ec.system.js"],(function(e){"use strict";var t,i,o,r,a,s,n,c,l,d,u,h,p,f;return{setters:[function(e){t=e.r;i=e.c;o=e.h;r=e.H;a=e.F;s=e.g},function(e){n=e.VerdocsEndpoint;c=e.getTemplateDocumentPageDisplayUri;l=e.getTemplate},function(e){d=e.t;u=e.j;h=e.g},function(e){p=e.S},function(e){f=e.c},function(){},function(){},function(){}],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-template-document-page{width:100%;position:relative}verdocs-template-document-page .verdocs-template-document-page-layer{position:absolute;top:0;left:0;right:0;bottom:0;-webkit-box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294);box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294)}verdocs-template-document-page .verdocs-template-document-page-layer.img{width:100%}verdocs-template-document-page .placeholder{opacity:0.1;width:612px;height:792px;-webkit-box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294);box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294)}";var v=b;var m=e("verdocs_template_document_page",function(){function e(e){t(this,e);this.pageRendered=i(this,"pageRendered",7);this.templateListenerId=null;this.endpoint=n.getDefault();this.editable=false;this.disabled=false;this.done=false;this.templateId="";this.documentId="";this.pageNumber=1;this.virtualWidth=612;this.virtualHeight=792;this.layers=[{name:"page",type:"canvas"}];this.containerId="verdocs-document-page-".concat(Math.random().toString(36).substring(2,11));this.renderedWidth=this.virtualWidth;this.renderedHeight=this.virtualHeight;this.naturalWidth=this.virtualWidth;this.naturalHeight=this.virtualHeight;this.aspectRatio=this.virtualWidth/this.virtualHeight;this.skipFirstNotification=true;this.pageDisplayUri="";this.xScale=1;this.yScale=1;this.loading=true;this.template=null}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:e=this;return[4,c(this.endpoint,this.documentId,this.pageNumber)];case 1:e.pageDisplayUri=t.sent();this.listenToTemplate();return[2]}}))}))};e.prototype.componentDidLoad=function(){var e=this;this.resizeObserver=new ResizeObserver(d((function(t){for(var i=0,o=t;i<o.length;i++){var r=o[i];var a=r.contentRect.width;e.renderedWidth=a;e.renderedHeight=e.virtualHeight*(a/e.virtualWidth)}e.notifyRenderedSize()}),100));this.resizeObserver.observe(this.container)};e.prototype.componentDidUpdate=function(){this.notifyRenderedSize()};e.prototype.disconnectedCallback=function(){var e;(e=this.resizeObserver)===null||e===void 0?void 0:e.disconnect();this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();p.subscribe("templates",this.templateId,(function(){return l(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){p.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.notifyRenderedSize=function(){if(this.skipFirstNotification){this.skipFirstNotification=false;return}var e=this.renderedWidth/this.virtualWidth;if(this.xScale!==e){this.xScale=e}var t=this.renderedHeight/this.virtualHeight;if(this.yScale!==t){this.yScale=t}this.pageRendered.emit({containerId:this.containerId,documentId:this.documentId,pageNumber:this.pageNumber,virtualWidth:this.virtualWidth,virtualHeight:this.virtualHeight,renderedWidth:this.renderedWidth,renderedHeight:this.renderedHeight,naturalWidth:this.naturalWidth,naturalHeight:this.naturalHeight,aspectRatio:this.aspectRatio,xScale:e,yScale:t})};e.prototype.render=function(){var e=this;if(this.loading){return o(r,null,o("img",{src:"https://public-assets.verdocs.com/loading-placeholder.png",class:"placeholder",alt:"Placeholder page"}))}var t="".concat(this.renderedHeight,"px");return o(r,{id:"".concat(this.containerId),style:{height:t,flex:"0 0 ".concat(t)}},this.layers.map((function(i){var r;return i.type==="div"?o("div",{class:"verdocs-template-document-page-layer",id:"".concat(e.containerId,"-").concat(i.name),style:{height:t}},i.name==="controls"&&(((r=e.template)===null||r===void 0?void 0:r.fields)||[]).filter((function(t){return t&&t.page===e.pageNumber})).map((function(t){var i,r;var s=h(t);var n=t.name,c=t.type,l=t.multiline;var d=e,p=d.xScale,f=d.yScale,b=d.templateId,v=d.editable,m=d.disabled,g=d.done,y=d.pageNumber;if(((i=t["setting"])===null||i===void 0?void 0:i.leading)>0||((r=t["settings"])===null||r===void 0?void 0:r.leading)>0){c="textarea";l=true}switch(c){case"textbox":return o("verdocs-field-textbox",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,multiline:l,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});case"textarea":return o("verdocs-field-textarea",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});case"date":return o("verdocs-field-date",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});case"attachment":return o("verdocs-field-attachment",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});case"dropdown":return o("verdocs-field-dropdown",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});case"initial":return o("verdocs-field-initial",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});case"signature":return o("verdocs-field-signature",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,e.xScale,e.yScale)});case"timestamp":return o("verdocs-field-timestamp",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});case"checkbox":return o("verdocs-field-checkbox",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});case"radio":return o("verdocs-field-radio",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});default:return o(a,null,n)}}))):e.pageDisplayUri?o("img",{class:"verdocs-template-document-page-layer img",id:"".concat(e.containerId,"-").concat(i.name),src:e.pageDisplayUri,alt:"Page ".concat(e.pageNumber),"aria-hidden":true,loading:"lazy",onLoad:function(t){e.naturalWidth=t.target.naturalWidth;e.naturalHeight=t.target.naturalHeight;e.aspectRatio=e.naturalWidth/e.naturalHeight;e.virtualHeight=e.virtualWidth/e.aspectRatio;e.renderedHeight=t.target.offsetWidth/e.aspectRatio}}):o("div",null)})))};Object.defineProperty(e.prototype,"container",{get:function(){return s(this)},enumerable:false,configurable:true});return e}());m.style=v;var g='@-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-toolbar-icon{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;display:inline-block}verdocs-toolbar-icon .icon{display:inline-block;cursor:pointer}verdocs-toolbar-icon .icon svg{fill:#5c6575}verdocs-toolbar-icon .tooltip{display:none;-webkit-box-shadow:0 0 10px 1px #999999;box-shadow:0 0 10px 1px #999999;background:#ffffff;color:#33364b;max-width:240px;font-weight:bold;padding:5px 10px;font-size:13px;position:relative;border-radius:4px;z-index:20000;white-space:nowrap}verdocs-toolbar-icon .tooltip .arrow,verdocs-toolbar-icon .tooltip .arrow::before{position:absolute;width:8px;height:8px;background:inherit}verdocs-toolbar-icon .tooltip .arrow{visibility:hidden;top:-4px}verdocs-toolbar-icon .tooltip .arrow::before{visibility:visible;content:"";-webkit-transform:rotate(45deg);transform:rotate(45deg)}verdocs-toolbar-icon .tooltip[data-show]{display:block}verdocs-toolbar-icon .tooltip[data-popper-placement^=top]>.arrow{bottom:-4px}verdocs-toolbar-icon .tooltip[data-popper-placement^=bottom]>.arrow{top:-4px}verdocs-toolbar-icon .tooltip[data-popper-placement^=left]>.arrow{right:-4px}verdocs-toolbar-icon .tooltip[data-popper-placement^=right]>.arrow{left:-4px}verdocs-toolbar-icon .tooltip[data-popper-placement^=left]{padding:3px 10px}verdocs-toolbar-icon .tooltip[data-popper-placement^=left]>.arrow{right:-1px}';var y=g;var x=e("verdocs_toolbar_icon",function(){function e(e){t(this,e);this.text="";this.icon="";this.placement="bottom";this.containerId="verdocs-toolbar-icon-".concat(Math.random().toString(36).substring(2,11))}e.prototype.componentDidLoad=function(){this.popperInstance=f(this.iconEl,this.tooltip,{placement:this.placement,modifiers:this.placement==="left"?[{name:"offset",options:{offset:[0,20]}}]:[]})};e.prototype.disconnectedCallback=function(){if(this.popperInstance){this.popperInstance.destroy();this.popperInstance=null}};e.prototype.show=function(){var e,t;(e=this.tooltip)===null||e===void 0?void 0:e.setAttribute("data-show","");(t=this.popperInstance)===null||t===void 0?void 0:t.update().catch((function(){}))};e.prototype.hide=function(){var e;(e=this.tooltip)===null||e===void 0?void 0:e.removeAttribute("data-show")};e.prototype.render=function(){var e=this;return o(r,{key:"98b2f6b2a2711df2cf8e687e38684d495b6e7d50",class:{}},o("div",{key:"49500d4d3348e2ccd6c9cbe7867645756c6cf5ef","aria-describedby":this.containerId,class:"icon",innerHTML:this.icon,onMouseEnter:function(){return e.show()},onFocus:function(){return e.show()},onMouseLeave:function(){return e.hide()},onBlur:function(){return e.hide()},ref:function(t){return e.iconEl=t}}),o("div",{key:"e64aa823a8a09b10a9166f96be633439d959d3ff",id:this.containerId,role:"tooltip",class:"tooltip","data-popper-placement":this.placement,ref:function(t){return e.tooltip=t}},this.text,o("div",{key:"399156e882824870173ecf3e4bcc35f2ba720b8c","data-popper-arrow":"true",class:"arrow"})))};return e}());x.style=y}}}));
|
2
|
-
//# sourceMappingURL=p-
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,t,i,o){function r(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,a){function s(e){try{c(o.next(e))}catch(e){a(e)}}function n(e){try{c(o["throw"](e))}catch(e){a(e)}}function c(e){e.done?i(e.value):r(e.value).then(s,n)}c((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},o,r,a,s;return s={next:n(0),throw:n(1),return:n(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function n(e){return function(t){return c([e,t])}}function c(n){if(o)throw new TypeError("Generator is already executing.");while(s&&(s=0,n[0]&&(i=0)),i)try{if(o=1,r&&(a=n[0]&2?r["return"]:n[0]?r["throw"]||((a=r["return"])&&a.call(r),0):r.next)&&!(a=a.call(r,n[1])).done)return a;if(r=0,a)n=[n[0]&2,a.value];switch(n[0]){case 0:case 1:a=n;break;case 4:i.label++;return{value:n[1],done:false};case 5:i.label++;r=n[1];n=[0];continue;case 7:n=i.ops.pop();i.trys.pop();continue;default:if(!(a=i.trys,a=a.length>0&&a[a.length-1])&&(n[0]===6||n[0]===2)){i=0;continue}if(n[0]===3&&(!a||n[1]>a[0]&&n[1]<a[3])){i.label=n[1];break}if(n[0]===6&&i.label<a[1]){i.label=a[1];a=n;break}if(a&&i.label<a[2]){i.label=a[2];i.ops.push(n);break}if(a[2])i.ops.pop();i.trys.pop();continue}n=t.call(e,i)}catch(e){n=[6,e];r=0}finally{o=a=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:true}}};System.register(["./p-9186f42e.system.js","@verdocs/js-sdk","./p-f29eb00a.system.js","./p-52c3e8b0.system.js","./p-e0ac9edf.system.js","./p-21b1acec.system.js","./p-d738b5db.system.js","./p-2c5350ec.system.js"],(function(e){"use strict";var t,i,o,r,a,s,n,c,l,d,u,h,p,f;return{setters:[function(e){t=e.r;i=e.c;o=e.h;r=e.H;a=e.F;s=e.g},function(e){n=e.VerdocsEndpoint;c=e.getTemplateDocumentPageDisplayUri;l=e.getTemplate},function(e){d=e.t;u=e.j;h=e.g},function(e){p=e.S},function(e){f=e.c},function(){},function(){},function(){}],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-template-document-page{width:100%;position:relative}verdocs-template-document-page .verdocs-template-document-page-layer{position:absolute;top:0;left:0;right:0;bottom:0;-webkit-box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294);box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294)}verdocs-template-document-page .verdocs-template-document-page-layer.img{width:100%}verdocs-template-document-page .placeholder{opacity:0.1;width:612px;height:792px;-webkit-box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294);box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294)}";var v=b;var m=e("verdocs_template_document_page",function(){function e(e){t(this,e);this.pageRendered=i(this,"pageRendered",7);this.templateListenerId=null;this.endpoint=n.getDefault();this.editable=false;this.disabled=false;this.done=false;this.templateId="";this.documentId="";this.pageNumber=1;this.virtualWidth=612;this.virtualHeight=792;this.layers=[{name:"page",type:"canvas"}];this.containerId="verdocs-document-page-".concat(Math.random().toString(36).substring(2,11));this.renderedWidth=this.virtualWidth;this.renderedHeight=this.virtualHeight;this.naturalWidth=this.virtualWidth;this.naturalHeight=this.virtualHeight;this.aspectRatio=this.virtualWidth/this.virtualHeight;this.skipFirstNotification=true;this.pageDisplayUri="";this.xScale=1;this.yScale=1;this.loading=true;this.template=null}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:e=this;return[4,c(this.endpoint,this.documentId,this.pageNumber)];case 1:e.pageDisplayUri=t.sent();this.listenToTemplate();return[2]}}))}))};e.prototype.componentDidLoad=function(){var e=this;this.resizeObserver=new ResizeObserver(d((function(t){for(var i=0,o=t;i<o.length;i++){var r=o[i];var a=r.contentRect.width;e.renderedWidth=a;e.renderedHeight=e.virtualHeight*(a/e.virtualWidth)}e.notifyRenderedSize()}),100));this.resizeObserver.observe(this.container)};e.prototype.componentDidUpdate=function(){this.notifyRenderedSize()};e.prototype.disconnectedCallback=function(){var e;(e=this.resizeObserver)===null||e===void 0?void 0:e.disconnect();this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();p.subscribe("templates",this.templateId,(function(){return l(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){p.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.notifyRenderedSize=function(){if(this.skipFirstNotification){this.skipFirstNotification=false;return}var e=this.renderedWidth/this.virtualWidth;if(this.xScale!==e){this.xScale=e}var t=this.renderedHeight/this.virtualHeight;if(this.yScale!==t){this.yScale=t}this.pageRendered.emit({containerId:this.containerId,documentId:this.documentId,pageNumber:this.pageNumber,virtualWidth:this.virtualWidth,virtualHeight:this.virtualHeight,renderedWidth:this.renderedWidth,renderedHeight:this.renderedHeight,naturalWidth:this.naturalWidth,naturalHeight:this.naturalHeight,aspectRatio:this.aspectRatio,xScale:e,yScale:t})};e.prototype.render=function(){var e=this;if(this.loading){return o(r,null,o("img",{src:"https://public-assets.verdocs.com/loading-placeholder.png",class:"placeholder",alt:"Placeholder page"}))}var t="".concat(this.renderedHeight,"px");return o(r,{id:"".concat(this.containerId),style:{height:t,flex:"0 0 ".concat(t)}},this.layers.map((function(i){var r;return i.type==="div"?o("div",{class:"verdocs-template-document-page-layer",id:"".concat(e.containerId,"-").concat(i.name),style:{height:t}},i.name==="controls"&&(((r=e.template)===null||r===void 0?void 0:r.fields)||[]).filter((function(t){return t&&t.page===e.pageNumber})).map((function(t){var i,r;var s=h(t);var n=t.name,c=t.type,l=t.multiline;var d=e,p=d.xScale,f=d.yScale,b=d.templateId,v=d.editable,m=d.disabled,g=d.done,y=d.pageNumber;if(((i=t["setting"])===null||i===void 0?void 0:i.leading)>0||((r=t["settings"])===null||r===void 0?void 0:r.leading)>0){c="textarea";l=true}switch(c){case"textbox":return o("verdocs-field-textbox",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,multiline:l,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});case"textarea":return o("verdocs-field-textarea",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});case"date":return o("verdocs-field-date",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});case"attachment":return o("verdocs-field-attachment",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});case"dropdown":return o("verdocs-field-dropdown",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});case"initial":return o("verdocs-field-initial",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});case"signature":return o("verdocs-field-signature",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,e.xScale,e.yScale)});case"timestamp":return o("verdocs-field-timestamp",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});case"checkbox":return o("verdocs-field-checkbox",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});case"radio":return o("verdocs-field-radio",{id:s,fieldname:n,source:"template",sourceid:b,editable:v,disabled:m,done:g,xscale:p,yscale:f,pagenumber:y,style:u(t,p,f)});default:return o(a,null,n)}}))):e.pageDisplayUri?o("img",{class:"verdocs-template-document-page-layer img",id:"".concat(e.containerId,"-").concat(i.name),src:e.pageDisplayUri,alt:"Page ".concat(e.pageNumber),"aria-hidden":true,loading:"lazy",onLoad:function(t){e.naturalWidth=t.target.naturalWidth;e.naturalHeight=t.target.naturalHeight;e.aspectRatio=e.naturalWidth/e.naturalHeight;e.virtualHeight=e.virtualWidth/e.aspectRatio;e.renderedHeight=t.target.offsetWidth/e.aspectRatio}}):o("div",null)})))};Object.defineProperty(e.prototype,"container",{get:function(){return s(this)},enumerable:false,configurable:true});return e}());m.style=v;var g='@-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-toolbar-icon{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;display:inline-block}verdocs-toolbar-icon .icon{display:inline-block;cursor:pointer}verdocs-toolbar-icon .icon svg{fill:#5c6575}verdocs-toolbar-icon .tooltip{display:none;-webkit-box-shadow:0 0 10px 1px #999999;box-shadow:0 0 10px 1px #999999;background:#ffffff;color:#33364b;max-width:240px;font-weight:bold;padding:5px 10px;font-size:13px;position:relative;border-radius:4px;z-index:20000;white-space:nowrap}verdocs-toolbar-icon .tooltip .arrow,verdocs-toolbar-icon .tooltip .arrow::before{position:absolute;width:8px;height:8px;background:inherit}verdocs-toolbar-icon .tooltip .arrow{visibility:hidden;top:-4px}verdocs-toolbar-icon .tooltip .arrow::before{visibility:visible;content:"";-webkit-transform:rotate(45deg);transform:rotate(45deg)}verdocs-toolbar-icon .tooltip[data-show]{display:block}verdocs-toolbar-icon .tooltip[data-popper-placement^=top]>.arrow{bottom:-4px}verdocs-toolbar-icon .tooltip[data-popper-placement^=bottom]>.arrow{top:-4px}verdocs-toolbar-icon .tooltip[data-popper-placement^=left]>.arrow{right:-4px}verdocs-toolbar-icon .tooltip[data-popper-placement^=right]>.arrow{left:-4px}verdocs-toolbar-icon .tooltip[data-popper-placement^=left]{padding:3px 10px}verdocs-toolbar-icon .tooltip[data-popper-placement^=left]>.arrow{right:-1px}';var y=g;var x=e("verdocs_toolbar_icon",function(){function e(e){t(this,e);this.text="";this.icon="";this.placement="bottom";this.containerId="verdocs-toolbar-icon-".concat(Math.random().toString(36).substring(2,11))}e.prototype.componentDidLoad=function(){this.popperInstance=f(this.iconEl,this.tooltip,{placement:this.placement,modifiers:this.placement==="left"?[{name:"offset",options:{offset:[0,20]}}]:[]})};e.prototype.disconnectedCallback=function(){if(this.popperInstance){this.popperInstance.destroy();this.popperInstance=null}};e.prototype.show=function(){var e,t;(e=this.tooltip)===null||e===void 0?void 0:e.setAttribute("data-show","");(t=this.popperInstance)===null||t===void 0?void 0:t.update().catch((function(){}))};e.prototype.hide=function(){var e;(e=this.tooltip)===null||e===void 0?void 0:e.removeAttribute("data-show")};e.prototype.render=function(){var e=this;return o(r,{key:"98b2f6b2a2711df2cf8e687e38684d495b6e7d50",class:{}},o("div",{key:"49500d4d3348e2ccd6c9cbe7867645756c6cf5ef","aria-describedby":this.containerId,class:"icon",innerHTML:this.icon,onMouseEnter:function(){return e.show()},onFocus:function(){return e.show()},onMouseLeave:function(){return e.hide()},onBlur:function(){return e.hide()},ref:function(t){return e.iconEl=t}}),o("div",{key:"e64aa823a8a09b10a9166f96be633439d959d3ff",id:this.containerId,role:"tooltip",class:"tooltip","data-popper-placement":this.placement,ref:function(t){return e.tooltip=t}},this.text,o("div",{key:"399156e882824870173ecf3e4bcc35f2ba720b8c","data-popper-arrow":"true",class:"arrow"})))};return e}());x.style=y}}}));
|
2
|
+
//# sourceMappingURL=p-d1d95df4.system.entry.js.map
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{r as e,c as i,h as s,H as o}from"./p-b9654a5e.js";import{VerdocsEndpoint as t,getEnvelope as r,getInPersonLink as l,getRecipientsWithActions as n,recipientCanAct as a,formatFullName as c}from"@verdocs/js-sdk";import{S as d}from"./p-fd97809c.js";import{S as p}from"./p-
|
2
|
-
//# sourceMappingURL=p-
|
1
|
+
import{r as e,c as i,h as s,H as o}from"./p-b9654a5e.js";import{VerdocsEndpoint as t,getEnvelope as r,getInPersonLink as l,getRecipientsWithActions as n,recipientCanAct as a,formatFullName as c}from"@verdocs/js-sdk";import{S as d}from"./p-fd97809c.js";import{S as p}from"./p-d4be87ef.js";const m='@-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-recipient-summary{top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;z-index:100000;position:fixed;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;font-family:"Inter", "Barlow", sans-serif;background-color:rgba(0, 0, 0, 0.4980392157)}verdocs-envelope-recipient-summary .summary-content{width:600px;display:-ms-flexbox;display:flex;max-width:90%;font-size:18px;-ms-flex:0 0 600px;flex:0 0 600px;border-radius:6px;background:#ffffff;-ms-flex-direction:column;flex-direction:column;padding:30px 20px 20px}verdocs-envelope-recipient-summary .summary-content .summary-title{font-size:20px;font-weight:700;margin:0 0 10px 0;color:#33364b}verdocs-envelope-recipient-summary .summary-recipient{display:-ms-flexbox;display:flex;color:#33364b;margin:8px 0 24px 0;-ms-flex-direction:column;flex-direction:column}verdocs-envelope-recipient-summary .summary-recipient .role-name{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;font-size:14px;font-weight:600;margin:0 0 8px 0;color:#092c4c}verdocs-envelope-recipient-summary .summary-recipient .role-info{gap:5px;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:end;align-items:flex-end}verdocs-envelope-recipient-summary .summary-recipient .role-full-name{-ms-flex:1;flex:1;height:34px;display:-ms-flexbox;display:flex;font-size:16px;padding:0 12px;border-radius:4px;-ms-flex-align:center;align-items:center;border:1px solid #cccccc;background:rgb(249, 250, 251)}verdocs-envelope-recipient-summary .summary-recipient .recipient-link{width:120px;padding:0 16px;font-weight:500;margin:0 0 0 8px;text-align:center;font-size:0.875rem;border-radius:100%;color:rgb(55, 65, 81);line-height:1.25rem;background-color:#d8d8d8;border:2px solid rgb(156, 163, 175)}verdocs-envelope-recipient-summary .summary-recipient .link-wrapper{gap:5px;display:-ms-flexbox;display:flex;margin:4px 0 0 0;-ms-flex-direction:row;flex-direction:row}verdocs-envelope-recipient-summary .summary-recipient .link-wrapper .link{-ms-flex:1;flex:1;height:34px;display:-ms-flexbox;display:flex;font-size:16px;padding:0 12px;overflow:hidden;border-radius:4px;-ms-flex-align:center;align-items:center;white-space:nowrap;text-overflow:ellipsis;border:1px solid #cccccc;background:rgb(249, 250, 251)}verdocs-envelope-recipient-summary .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;margin:10px 0 0 0;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}verdocs-envelope-recipient-summary .buttons verdocs-button{-ms-flex:0 0 120px;flex:0 0 120px;margin-left:10px;white-space:nowrap}verdocs-envelope-recipient-summary .buttons verdocs-button button{width:100%}';const u=m;const h=class{constructor(s){e(this,s);this.another=i(this,"another",7);this.view=i(this,"view",7);this.next=i(this,"next",7);this.sdkError=i(this,"sdkError",7);this.envelopeListenerId=null;this.endpoint=t.getDefault();this.envelopeId="";this.canSendAnother=true;this.canView=true;this.canDone=true;this.isOpen=undefined;this.recipientStatusIcons=[];this.containerId=`verdocs-status-indicator-${Math.random().toString(36).substring(2,11)}`;this.gettingLinks={};this.links={};this.loading=true;this.envelope=null}async componentWillLoad(){var e,i,s;try{this.endpoint.loadSession();if(!this.envelopeId){console.log(`[RECIPIENTS] Missing required envelope ID ${this.envelopeId}`);return}if(!this.endpoint.session){console.log("[RECIPIENTS] Unable to start session, must be authenticated");return}this.listenToEnvelope()}catch(o){console.log("[RECIPIENTS] Error loading envelope",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new d(o.message,(i=o.response)===null||i===void 0?void 0:i.status,(s=o.response)===null||s===void 0?void 0:s.data))}}disconnectedCallback(){this.unlistenToEnvelope()}async listenToEnvelope(){console.log("[SIDEBAR] Loading envelope",this.envelopeId);this.unlistenToEnvelope();p.subscribe("envelopes",this.envelopeId,(()=>r(this.endpoint,this.envelopeId)),false,(e=>{this.envelope=e;this.loading=false;this.sortEnvelopeRecipients()}))}unlistenToEnvelope(){if(this.envelopeListenerId){p.store.delListener(this.envelopeListenerId);this.envelopeListenerId=null}}sortEnvelopeRecipients(){var e;(((e=this.envelope)===null||e===void 0?void 0:e.recipients)||[]).sort(((e,i)=>e.sequence===i.sequence?e.order-i.order:e.sequence-i.sequence))}handleAnother(e){var i;e.preventDefault();(i=this.another)===null||i===void 0?void 0:i.emit({envelope:this.envelope})}handleView(e){var i;e.preventDefault();(i=this.view)===null||i===void 0?void 0:i.emit({envelope:this.envelope})}handleDone(e){var i;e.preventDefault();(i=this.next)===null||i===void 0?void 0:i.emit({envelope:this.envelope})}copyLink(e){navigator.clipboard.writeText(e).then((()=>{})).catch((e=>{var i;console.warn("[RECIPIENTS] Error copying to clipboard",e);(i=this.sdkError)===null||i===void 0?void 0:i.emit(e)}))}getLink(e){this.gettingLinks={...this.gettingLinks,[e.role_name]:true};l(this.endpoint,e.envelope_id,e.role_name).then((i=>{this.gettingLinks={...this.gettingLinks,[e.role_name]:false};this.links={...this.links,[e.role_name]:i.link};this.copyLink(i.link)})).catch((i=>{var s;this.gettingLinks={...this.gettingLinks,[e.role_name]:false};console.log("[RECIPIENTS] Error getting link",i);(s=this.sdkError)===null||s===void 0?void 0:s.emit(i)}))}render(){var e;if(this.loading){return s(o,null)}return s(o,null,s("div",{class:"summary-content"},s("h1",{class:"summary-title"},"Recipient Summary"),s("div",{class:"summary-rows"},(((e=this.envelope)===null||e===void 0?void 0:e.recipients)||[]).map((e=>{const i=n(this.envelope);const o=a(e,i);const t=this.links[e.role_name];const r=this.gettingLinks[e.role_name];const l=c(e);return s("div",{class:"summary-recipient"},s("div",{class:"role-name"},e.role_name),s("div",{class:"role-details"},s("div",{class:"role-info"},s("div",{class:"role-full-name"},l," (",e.email||e.phone,")"),o&&!t&&s("verdocs-button",{size:"small",variant:"outline",label:"Get Link",disabled:r,onClick:()=>this.getLink(e)})),t&&s("div",{class:"link-wrapper"},s("div",{class:"link"},t),s("verdocs-button",{size:"small",variant:"outline",label:"Copy",onClick:()=>this.copyLink(t)}))))}))),(this.canSendAnother||this.canView||this.canDone)&&s("div",{class:"buttons"},this.canSendAnother&&s("verdocs-button",{size:"small",label:"Send Another",onClick:e=>this.handleAnother(e)}),this.canView&&s("verdocs-button",{size:"small",label:"View Now",onClick:e=>this.handleView(e)}),this.canDone&&s("verdocs-button",{size:"small",label:"Done",onClick:e=>this.handleDone(e)}))))}};h.style=u;export{h as verdocs_envelope_recipient_summary};
|
2
|
+
//# sourceMappingURL=p-d3a8c6b8.entry.js.map
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import{getTemplate as t}from"@verdocs/js-sdk";const n=t=>typeof t;const s="";const o=n(s);const e=n(true);const c=n(0);const l=n(n);const r="type";const a="default";const i="Listener";const u="add";const f="Has";const d="Ids";const h="Table";const b=h+"s";const g=h+d;const T="Row";const _=T+"Count";const p=T+d;const S="Cell";const w=S+d;const m="Value";const C=m+"s";const V=m+d;const I=t=>s+t;const y=isFinite;const R=(t,n)=>t instanceof n;const v=t=>t==undefined;const J=(t,n,s)=>v(t)?s?.():n(t);const L=t=>t==o||t==e;const E=t=>n(t)==l;const O=t=>Array.isArray(t);const j=(t,n,s)=>t.slice(n,s);const N=t=>t.length;const F=(t,n)=>t.test(n);const M=(t,n)=>t.includes(n);const $=(t,n)=>t.every(n);const x=(t,n)=>N(t)===N(n)&&$(t,((t,s)=>n[s]===t));const A=(t,n)=>t.sort(n);const D=(t,n)=>t.forEach(n);const P=(t,n)=>t.map(n);const k=(t,n,s)=>t.reduce(n,s);const z=(t,...n)=>t.push(...n);const H=t=>t.shift();const W=Object;const q=t=>W.getPrototypeOf(t);const B=W.entries;const G=W.isFrozen;const K=t=>!v(t)&&J(q(t),(t=>t==W.prototype||v(q(t))),(()=>true));const Q=W.keys;const U=W.freeze;const X=(t=[])=>W.fromEntries(t);const Y=(t,n)=>n in t;const Z=(t,n)=>{delete t[n];return t};const tt=(t,n)=>D(B(t),(([t,s])=>n(s,t)));const nt=(t,n)=>P(B(t),(([t,s])=>n(s,t)));const st=(t,n)=>X(nt(t,((t,s)=>[s,n(t,s)])));const ot=t=>N(Q(t));const et=t=>K(t)&&ot(t)==0;const ct=(t,n,s,o=0)=>{if(v(t)||!K(t)||!o&&et(t)||G(t)){s?.();return false}tt(t,((s,o)=>{if(!n(s,o)){Z(t,o)}}));return o?true:!et(t)};const lt=t=>n=>k(ht(n),((n,s)=>n+t(s)),0);const rt=t=>t?.size??0;const at=lt(rt);const it=lt(at);const ut=lt(it);const ft=(t,n)=>t?.has(n)??false;const dt=t=>v(t)||rt(t)==0;const ht=t=>[...t?.values()??[]];const bt=t=>t.clear();const gt=(t,n)=>t?.forEach(n);const Tt=(t,n)=>t?.delete(n);const _t=t=>new Map(t);const pt=t=>[...t?.keys()??[]];const St=(t,n)=>t?.get(n);const wt=(t,n)=>gt(t,((t,s)=>n(s,t)));const mt=(t,n)=>P([...t?.entries()??[]],(([t,s])=>n(s,t)));const Ct=(t,n,s)=>v(s)?(Tt(t,n),t):t?.set(n,s);const Vt=(t,n,s,o)=>{if(!ft(t,n)){Ct(t,n,s())}else{o?.(St(t,n))}return St(t,n)};const It=(t,n,s,o=Ct)=>{st(n,((n,o)=>s(t,o,n)));wt(t,(s=>Y(n,s)?0:o(t,s)));return t};const yt=(t,n,s,o)=>{const e={};gt(t,((t,c)=>{if(!s?.(t,c)){const s=n?n(t,c):t;if(!o?.(s)){e[c]=s}}}));return e};const Rt=(t,n,s)=>yt(t,(t=>yt(t,n,s)),dt,et);const vt=(t,n,s)=>yt(t,(t=>Rt(t,n,s)),dt,et);const Jt=(t,n)=>{const s=_t();gt(t,((t,o)=>s.set(o,n?.(t)??t)));return s};const Lt=t=>Jt(t,Jt);const Et=t=>Jt(t,Lt);const Ot=(t,n,s,o,e=0)=>J((s?Vt:St)(t,n[e],e>N(n)-2?s:_t),(c=>{if(e>N(n)-2){if(o?.(c)){Ct(t,n[e])}return c}const l=Ot(c,n,s,o,e+1);if(dt(c)){Ct(t,n[e])}return l}));const jt=t=>{const s=n(t);return L(s)||s==c&&y(t)?s:undefined};const Nt=(t,n,s,o,e)=>v(e)?t.delCell(n,s,o,true):t.setCell(n,s,o,e);const Ft=(t,n,s)=>v(s)?t.delValue(n):t.setValue(n,s);const Mt=t=>new Set(O(t)||v(t)?t:[t]);const $t=(t,n)=>t?.add(n);const xt=/^\d+$/;const At=()=>{const t=[];let n=0;return[o=>(o?H(t):null)??s+n++,n=>{if(F(xt,n)&&N(t)<1e3){z(t,n)}}]};const Dt=(t,n=[s])=>{const o=[];const e=(t,s)=>s==N(n)?z(o,t):n[s]===null?gt(t,(t=>e(t,s+1))):D([n[s],null],(n=>e(St(t,n),s+1)));e(t,0);return o};const Pt=t=>{let n;const[o,e]=At();const c=_t();const l=(e,l,r,a=[],i=(()=>[]))=>{n??=t();const u=o(1);Ct(c,u,[e,l,r,a,i]);$t(Ot(l,r??[s],Mt),u);return u};const r=(t,s,...o)=>D(Dt(t,s),(t=>gt(t,(t=>St(c,t)[0](n,...s??[],...o)))));const a=t=>J(St(c,t),(([,n,o])=>{Ot(n,o??[s],undefined,(n=>{Tt(n,t);return dt(n)?1:0}));Ct(c,t);e(t);return o}));const i=t=>J(St(c,t),(([t,,s=[],o,e])=>{const c=(...l)=>{const r=N(l);if(r==N(s)){t(n,...l,...e(l))}else if(v(s[r])){D(o[r]?.(...l)??[],(t=>c(...l,t)))}else{c(...l,s[r])}};c()}));return[l,r,a,i]};const kt=(t,n)=>(t??0)<(n??0)?-1:1;const zt=t=>[t,t];const Ht=(t,n=at)=>n(t[0])+n(t[1]);const Wt=()=>[_t(),_t()];const qt=t=>[...t];const Bt=([t,n])=>t===n;const Gt=JSON.stringify;const Kt=JSON.parse;const Qt=t=>Gt(t,((t,n)=>R(n,Map)?W.fromEntries([...n]):n));const Ut=(t,n,s)=>Ct(t,n,St(t,n)==-s?undefined:s);const Xt=()=>{let t;let n;let s=false;let o=false;let e=0;let l=[];const d=_t();const y=_t();const R=_t();const N=_t();const F=_t();const $=_t();const k=_t();const H=_t();const W=_t();const q=_t();const B=_t();const G=_t();const K=_t();const Q=_t();const X=Mt();const tt=_t();const nt=_t();const ot=_t();const lt=_t();const ht=Wt();const Ot=Wt();const xt=Wt();const Dt=Wt();const Gt=Wt();const Yt=Wt();const Zt=Wt();const tn=Wt();const nn=Wt();const sn=Wt();const on=Wt();const en=Wt();const cn=Wt();const ln=Wt();const rn=Wt();const an=Wt();const un=Wt();const fn=Wt();const dn=Wt();const hn=Wt();const bn=Wt();const gn=Wt();const Tn=_t();const _n=Wt();const[pn,Sn,wn,mn]=Pt((()=>jo));const Cn=t=>ct(t,(t=>ct(t,In)));const Vn=t=>ct(t,In);const In=t=>{if(!ct(t,((t,n)=>M([r,a],n)))){return false}const n=t[r];if(!L(n)&&n!=c){return false}if(jt(t[a])!=n){Z(t,a)}return true};const yn=O;const Rn=t=>ct(t,vn,es);const vn=(n,s)=>(!t||ft(B,s)||es(s))&&ct(n,((t,n)=>Jn(s,n,t)),(()=>es(s)));const Jn=(t,n,s,o)=>ct(o?s:jn(s,t,n),((o,e)=>J(Ln(t,n,e,o),(t=>{s[e]=t;return true}),(()=>false))),(()=>es(t,n)));const Ln=(n,s,o,e)=>t?J(St(St(B,n),o),(t=>jt(e)!=t[r]?es(n,s,o,e,t[a]):e),(()=>es(n,s,o,e))):v(jt(e))?es(n,s,o,e):e;const En=(t,n)=>ct(n?t:Nn(t),((n,s)=>J(On(s,n),(n=>{t[s]=n;return true}),(()=>false))),(()=>cs()));const On=(t,s)=>n?J(St(K,t),(n=>jt(s)!=n[r]?cs(t,s,n[a]):s),(()=>cs(t,s))):v(jt(s))?cs(t,s):s;const jn=(t,n,s)=>{J(St(G,n),(([o,e])=>{gt(o,((n,s)=>{if(!Y(t,s)){t[s]=n}}));gt(e,(o=>{if(!Y(t,o)){es(n,s,o)}}))}));return t};const Nn=t=>{if(n){gt(Q,((n,s)=>{if(!Y(t,s)){t[s]=n}}));gt(X,(n=>{if(!Y(t,n)){cs(n)}}))}return t};const Fn=t=>It(B,t,((t,n,s)=>{const o=_t();const e=Mt();It(Vt(B,n,_t),s,((t,n,s)=>{Ct(t,n,s);J(s[a],(t=>Ct(o,n,t)),(()=>$t(e,n)))}));Ct(G,n,[o,e])}),((t,n)=>{Ct(B,n);Ct(G,n)}));const Mn=t=>It(K,t,((t,n,s)=>{Ct(K,n,s);J(s[a],(t=>Ct(Q,n,t)),(()=>$t(X,n)))}),((t,n)=>{Ct(K,n);Ct(Q,n);Tt(X,n)}));const $n=t=>et(t)?eo():zs(t);const xn=([t,n])=>{(et(t)?eo:zs)(t);(et(n)?ao:Ks)(n)};const An=t=>It(ot,t,((t,n,s)=>Dn(n,s)),((t,n)=>Kn(n)));const Dn=(t,n)=>It(Vt(ot,t,(()=>{Yn(t,1);Ct(tt,t,At());Ct(nt,t,_t());return _t()})),n,((n,s,o)=>Pn(t,n,s,o)),((n,s)=>Qn(t,n,s)));const Pn=(t,n,s,o,e)=>It(Vt(n,s,(()=>{Zn(t,s,1);return _t()})),o,((n,o,e)=>kn(t,s,n,o,e)),((o,c)=>Un(t,n,s,o,c,e)));const kn=(t,n,s,o,e)=>{if(!ft(s,o)){ts(t,n,o,1)}const c=St(s,o);if(e!==c){ns(t,n,o,c,e);Ct(s,o,e)}};const zn=(t,n,s,o,e)=>J(St(n,s),(n=>kn(t,s,n,o,e)),(()=>Pn(t,n,s,jn({[o]:e},t,s))));const Hn=t=>et(t)?ao():Ks(t);const Wn=t=>It(lt,t,((t,n,s)=>qn(n,s)),((t,n)=>Xn(n)));const qn=(t,n)=>{if(!ft(lt,t)){ss(t,1)}const s=St(lt,t);if(n!==s){os(t,s,n);Ct(lt,t,n)}};const Bn=(t,n)=>{const[s]=St(tt,t);let o;do{o=s(n)}while(ft(St(ot,t),o));return o};const Gn=t=>St(ot,t)??Dn(t,{});const Kn=t=>Dn(t,{});const Qn=(t,n,s)=>{const[,o]=St(tt,t);o(s);Pn(t,n,s,{},true)};const Un=(t,n,s,o,e,c)=>{const l=St(St(G,t)?.[0],e);if(!v(l)&&!c){return kn(t,s,o,e,l)}const r=n=>{ns(t,s,n,St(o,n));ts(t,s,n,-1);Ct(o,n)};if(v(l)){r(e)}else{wt(o,r)}if(dt(o)){Zn(t,s,-1);if(dt(Ct(n,s))){Yn(t,-1);Ct(ot,t);Ct(tt,t);Ct(nt,t)}}};const Xn=t=>{const n=St(Q,t);if(!v(n)){return qn(t,n)}os(t,St(lt,t));ss(t,-1);Ct(lt,t)};const Yn=(t,n)=>Ut(d,t,n);const Zn=(t,n,s)=>Ut(Vt(N,t,_t),n,s)&&Ct(R,t,Vt(R,t,(()=>0))+s);const ts=(t,n,s,o)=>{const e=St(nt,t);const c=St(e,s)??0;if(c==0&&o==1||c==1&&o==-1){Ut(Vt(y,t,_t),s,o)}Ct(e,s,c!=-o?c+o:null);Ut(Vt(Vt(F,t,_t),n,_t),s,o)};const ns=(t,n,s,o,e)=>{Vt(Vt(Vt($,t,_t),n,_t),s,(()=>[o,0]))[1]=e;l[3]?.(t,n,s,e)};const ss=(t,n)=>Ut(k,t,n);const os=(t,n,s)=>{Vt(H,t,(()=>[n,0]))[1]=s;l[4]?.(t,s)};const es=(t,n,s,o,e)=>{z(Vt(Vt(Vt(W,t,_t),n,_t),s,(()=>[])),o);return e};const cs=(t,n,s)=>{z(Vt(q,t,(()=>[])),n);return s};const ls=(t,n,s)=>J(St(St(St($,t),n),s),(([t,n])=>[true,t,n]),(()=>[false,...zt(Is(t,n,s))]));const rs=t=>J(St(H,t),(([t,n])=>[true,t,n]),(()=>[false,...zt(vs(t))]));const as=t=>!dt(W)&&!dt(an[t])?gt(t?Et(W):W,((n,s)=>gt(n,((n,o)=>gt(n,((n,e)=>Sn(an[t],[s,o,e],n))))))):0;const is=t=>!dt(q)&&!dt(un[t])?gt(t?Jt(q):q,((n,s)=>Sn(un[t],[s],n))):0;const us=(t,n,s,o)=>{if(!dt(t)){Sn(n,o,(()=>yt(t)));wt(t,((t,n)=>Sn(s,[...o??[],t],n==1)));return 1}};const fs=t=>{const n=Js();if(n!=s){Sn(ht[t],undefined,n)}const o=dt(sn[t]);const e=dt(cn[t])&&dt(ln[t])&&dt(nn[t])&&dt(on[t])&&dt(Yt[t])&&dt(Zt[t])&&dt(tn[t])&&o&&dt(xt[t])&&dt(Dt[t]);const c=dt(rn[t])&&dt(en[t])&&dt(Gt[t])&&dt(Ot[t]);if(!e||!c){const n=t?[Jt(d),Lt(y),Jt(R),Lt(N),Et(F),Et($)]:[d,y,R,N,F,$];if(!e){us(n[0],xt[t],Dt[t]);gt(n[1],((n,s)=>us(n,Yt[t],Zt[t],[s])));gt(n[2],((n,s)=>{if(n!=0){Sn(tn[t],[s],Ss(s))}}));const s=Mt();gt(n[3],((n,e)=>{if(us(n,nn[t],on[t],[e])&&!o){Sn(sn[t],[e,null]);$t(s,e)}}));if(!o){gt(n[5],((n,o)=>{if(!ft(s,o)){const s=Mt();gt(n,(t=>gt(t,(([n,o],e)=>o!==n?$t(s,e):Tt(t,e)))));gt(s,(n=>Sn(sn[t],[o,n])))}}))}gt(n[4],((n,s)=>gt(n,((n,o)=>us(n,cn[t],ln[t],[s,o])))))}if(!c){let s;gt(n[5],((n,o)=>{let e;gt(n,((n,c)=>{let l;gt(n,(([n,r],a)=>{if(r!==n){Sn(rn[t],[o,c,a],r,n,ls);s=e=l=1}}));if(l){Sn(en[t],[o,c],ls)}}));if(e){Sn(Gt[t],[o],ls)}}));if(s){Sn(Ot[t],undefined,ls)}}}};const ds=t=>{const n=Ns();if(n!=o){Sn(fn[t],undefined,n)}const s=dt(hn[t])&&dt(bn[t]);const e=dt(gn[t])&&dt(dn[t]);if(!s||!e){const n=t?[Jt(k),Jt(H)]:[k,H];if(!s){us(n[0],hn[t],bn[t])}if(!e){let s;gt(n[1],(([n,o],e)=>{if(o!==n){Sn(gn[t],[e],o,n,rs);s=1}}));if(s){Sn(dn[t],undefined,rs)}}}};const hs=(t,...n)=>{bo((()=>t(...P(n,I))));return jo};const bs=()=>[gs(),ys()];const gs=()=>vt(ot);const Ts=()=>pt(ot);const _s=t=>Rt(St(ot,I(t)));const ps=t=>pt(St(nt,I(t)));const Ss=t=>rt(St(ot,I(t)));const ws=t=>pt(St(ot,I(t)));const ms=(t,n,s,o=0,e)=>P(j(A(mt(St(ot,I(t)),((t,s)=>[v(n)?s:St(t,I(n)),s])),(([t],[n])=>kt(t,n)*(s?-1:1))),o,v(e)?e:o+e),(([,t])=>t));const Cs=(t,n)=>yt(St(St(ot,I(t)),I(n)));const Vs=(t,n)=>pt(St(St(ot,I(t)),I(n)));const Is=(t,n,s)=>St(St(St(ot,I(t)),I(n)),I(s));const ys=()=>yt(lt);const Rs=()=>pt(lt);const vs=t=>St(lt,I(t));const Js=()=>!dt(ot);const Ls=t=>ft(ot,I(t));const Es=(t,n)=>ft(St(nt,I(t)),I(n));const Os=(t,n)=>ft(St(ot,I(t)),I(n));const js=(t,n,s)=>ft(St(St(ot,I(t)),I(n)),I(s));const Ns=()=>!dt(lt);const Fs=t=>ft(lt,I(t));const Ms=()=>Qt(ot);const $s=()=>Qt(lt);const xs=()=>Qt([ot,lt]);const As=()=>Qt(B);const Ds=()=>Qt(K);const Ps=()=>Qt([B,K]);const ks=t=>hs((()=>{const n=E(t)?t():t;if(yn(n)){xn(n)}}));const zs=t=>hs((()=>Rn(t)?An(t):0));const Hs=(t,n)=>hs((t=>vn(n,t)?Dn(t,n):0),t);const Ws=(t,n,s)=>hs(((t,n)=>Jn(t,n,s)?Pn(t,Gn(t),n,s):0),t,n);const qs=(t,n,s=true)=>bo((()=>{let o=undefined;if(Jn(t,o,n)){t=I(t);Pn(t,Gn(t),o=Bn(t,s?1:0),n)}return o}));const Bs=(t,n,s)=>hs(((t,n)=>{if(Jn(t,n,s,1)){const o=Gn(t);st(s,((s,e)=>zn(t,o,n,e,s)))}}),t,n);const Gs=(t,n,s,o)=>hs(((t,n,s)=>J(Ln(t,n,s,E(o)?o(Is(t,n,s)):o),(o=>zn(t,Gn(t),n,s,o)))),t,n,s);const Ks=t=>hs((()=>En(t)?Wn(t):0));const Qs=t=>hs((()=>En(t,1)?st(t,((t,n)=>qn(n,t))):0));const Us=(t,n)=>hs((t=>J(On(t,E(n)?n(vs(t)):n),(n=>qn(t,n)))),t);const Xs=t=>hs((()=>{st(t[0],((t,n)=>v(t)?co(n):st(t,((t,s)=>v(t)?lo(n,s):st(t,((t,o)=>Nt(jo,n,s,o,t)))))));st(t[1],((t,n)=>Ft(jo,n,t)))}));const Ys=t=>{try{$n(Kt(t))}catch{}return jo};const Zs=t=>{try{Hn(Kt(t))}catch{}return jo};const to=t=>hs((()=>{try{const[n,s]=Kt(t);$n(n);Hn(s)}catch{Ys(t)}}));const no=n=>hs((()=>{if(t=Cn(n)){Fn(n);if(!dt(ot)){const t=gs();eo();zs(t)}}}));const so=t=>hs((()=>{if(n=Vn(t)){const s=ys();fo();ao();n=true;Mn(t);Ks(s)}}));const oo=(t,n)=>hs((()=>{no(t);so(n)}));const eo=()=>hs((()=>An({})));const co=t=>hs((t=>ft(ot,t)?Kn(t):0),t);const lo=(t,n)=>hs(((t,n)=>J(St(ot,t),(s=>ft(s,n)?Qn(t,s,n):0))),t,n);const ro=(t,n,s,o)=>hs(((t,n,s)=>J(St(ot,t),(e=>J(St(e,n),(c=>ft(c,s)?Un(t,e,n,c,s,o):0))))),t,n,s);const ao=()=>hs((()=>Wn({})));const io=t=>hs((t=>ft(lt,t)?Xn(t):0),t);const uo=()=>hs((()=>{Fn({});t=false}));const fo=()=>hs((()=>{Mn({});n=false}));const ho=()=>hs((()=>{uo();fo()}));const bo=(t,n)=>{if(e!=-1){go();const s=t();po(n);return s}};const go=()=>{if(e!=-1){e++}if(e==1){l[0]?.();Sn(Tn)}return jo};const To=()=>[yt($,((t,n)=>St(d,n)===-1?undefined:yt(t,((t,s)=>St(St(N,n),s)===-1?undefined:yt(t,(([,t])=>t),(t=>Bt(t)))),dt,et)),dt,et),yt(H,(([,t])=>t),(t=>Bt(t))),1];const _o=()=>[!dt($),!dt(H),vt($,qt,Bt),vt(W),yt(H,qt,Bt),yt(q),yt(d),Rt(N),vt(F),yt(k)];const po=t=>{if(e>0){e--;if(e==0){e=1;as(1);if(!dt($)){fs(1)}is(1);if(!dt(H)){ds(1)}if(t?.(jo)){gt($,((t,n)=>gt(t,((t,s)=>gt(t,(([t],o)=>Nt(jo,n,s,o,t)))))));bt($);gt(H,(([t],n)=>Ft(jo,n,t)));bt(H)}Sn(_n[0],undefined);e=-1;as(0);if(!dt($)){fs(0)}is(0);if(!dt(H)){ds(0)}l[1]?.();Sn(_n[1],undefined);l[2]?.();e=0;s=Js();o=Ns();D([d,y,R,N,F,$,W,k,H,q],bt)}}return jo};const So=t=>gt(ot,((n,s)=>t(s,(t=>gt(n,((n,s)=>t(s,(t=>wt(n,t)))))))));const wo=(t,n)=>wt(St(nt,I(t)),n);const mo=(t,n)=>gt(St(ot,I(t)),((t,s)=>n(s,(n=>wt(t,n)))));const Co=(t,n,s)=>wt(St(St(ot,I(t)),I(n)),s);const Vo=t=>wt(lt,t);const Io=(t,n,s,o,e,c,l)=>{let r=ms(t,n,s,o,e);return pn((()=>{const l=ms(t,n,s,o,e);if(!x(l,r)){r=l;c(jo,t,n,s,o,e,r)}}),sn[l?1:0],[t,n],[Ts])};const yo=t=>pn(t,Tn);const Ro=t=>pn(t,_n[0]);const vo=t=>pn(t,_n[1]);const Jo=t=>{mn(t);return jo};const Lo=t=>{wn(t);return jo};const Eo=()=>({hasTables:Ht(ht),tables:Ht(Ot),tableIds:Ht(xt),hasTable:Ht(Dt),table:Ht(Gt),tableCellIds:Ht(Yt),hasTableCell:Ht(Zt,it),rowCount:Ht(tn),rowIds:Ht(nn),sortedRowIds:Ht(sn),hasRow:Ht(on,it),row:Ht(en,it),cellIds:Ht(cn,it),hasCell:Ht(ln,ut),cell:Ht(rn,ut),invalidCell:Ht(an,ut),hasValues:Ht(fn),values:Ht(dn),valueIds:Ht(hn),hasValue:Ht(bn),value:Ht(gn),invalidValue:Ht(un),transaction:at(Tn)+Ht(_n)});const Oo=(t,n,s,o,e)=>l=[t,n,s,o,e];const jo={getContent:bs,getTables:gs,getTableIds:Ts,getTable:_s,getTableCellIds:ps,getRowCount:Ss,getRowIds:ws,getSortedRowIds:ms,getRow:Cs,getCellIds:Vs,getCell:Is,getValues:ys,getValueIds:Rs,getValue:vs,hasTables:Js,hasTable:Ls,hasTableCell:Es,hasRow:Os,hasCell:js,hasValues:Ns,hasValue:Fs,getTablesJson:Ms,getValuesJson:$s,getJson:xs,getTablesSchemaJson:As,getValuesSchemaJson:Ds,getSchemaJson:Ps,hasTablesSchema:()=>t,hasValuesSchema:()=>n,setContent:ks,setTables:zs,setTable:Hs,setRow:Ws,addRow:qs,setPartialRow:Bs,setCell:Gs,setValues:Ks,setPartialValues:Qs,setValue:Us,applyChanges:Xs,setTablesJson:Ys,setValuesJson:Zs,setJson:to,setTablesSchema:no,setValuesSchema:so,setSchema:oo,delTables:eo,delTable:co,delRow:lo,delCell:ro,delValues:ao,delValue:io,delTablesSchema:uo,delValuesSchema:fo,delSchema:ho,transaction:bo,startTransaction:go,getTransactionChanges:To,getTransactionLog:_o,finishTransaction:po,forEachTable:So,forEachTableCell:wo,forEachRow:mo,forEachCell:Co,forEachValue:Vo,addSortedRowIdsListener:Io,addStartTransactionListener:yo,addWillFinishTransactionListener:Ro,addDidFinishTransactionListener:vo,callListener:Jo,delListener:Lo,getListenerStats:Eo,isMergeable:()=>false,createStore:Xt,addListener:pn,callListeners:Sn,setInternalListeners:Oo};st({[f+b]:[0,ht,[],()=>[Js()]],[b]:[0,Ot],[g]:[0,xt],[f+h]:[1,Dt,[Ts],t=>[Ls(...t)]],[h]:[1,Gt,[Ts]],[h+w]:[1,Yt,[Ts]],[f+h+S]:[2,Zt,[Ts,ps],t=>[Es(...t)]],[_]:[1,tn,[Ts]],[p]:[1,nn,[Ts]],[f+T]:[2,on,[Ts,ws],t=>[Os(...t)]],[T]:[2,en,[Ts,ws]],[w]:[2,cn,[Ts,ws]],[f+S]:[3,ln,[Ts,ws,Vs],t=>[js(...t)]],[S]:[3,rn,[Ts,ws,Vs],t=>zt(Is(...t))],InvalidCell:[3,an],[f+C]:[0,fn,[],()=>[Ns()]],[C]:[0,dn],[V]:[0,hn],[f+m]:[1,bn,[Rs],t=>[Fs(...t)]],[m]:[1,gn,[Rs],t=>zt(vs(t[0]))],InvalidValue:[1,un]},(([t,n,s,o],e)=>{jo[u+e+i]=(...e)=>pn(e[t],n[e[t+1]?1:0],t>0?j(e,0,t):undefined,s,o)}));return U(jo)};const Yt=Xt();Yt.delTables();Yt.delValues();console.log("[STORE] Data store initialized.");const Zt=(t,n)=>{try{return JSON.parse(t)}catch(t){return n||null}};const tn=t=>{const n={};for(let s in t){if(typeof t[s]==="string"||typeof t[s]==="number"||typeof t[s]==="boolean"){n[s]=t[s]}else if(t[s]===null){n[`__null__${s}`]=""}else if(Array.isArray(t[s])){n[`__array__${s}`]=JSON.stringify(t[s])}else if(typeof t[s]==="object"){n[`__object__${s}`]=JSON.stringify(t[s])}}return n};const nn=t=>{const n={};for(let s in t){if(s.startsWith("__null__")){n[s.replace("__null__","")]=null}else if(typeof t[s]==="string"&&s.startsWith("__array__")){n[s.replace("__array__","")]=Zt(t[s])}else if(typeof t[s]==="string"&&s.startsWith("__object__")){n[s.replace("__object__","")]=Zt(t[s])}else{n[s]=t[s]}}return n};const sn={store:Yt,subscribe(t,n,s,o,e){if(Yt.hasRow(t,n)){e(nn(Yt.getRow(t,n)))}const c=Yt.addRowListener(t,n,(()=>{const s=Yt.getRow(t,n);e(nn(s))}));if(!Yt.hasRow(t,n)||o){console.log("[STORE] Loading/reloading",{tableId:t,rowId:n});s().then((s=>{Yt.setRow(t,n,tn(s))})).catch((s=>{console.error("[STORE] Error getting row",{tableId:t,rowId:n,forceReload:o},s)}))}return c},unsubscribe(t){Yt.delListener(t)},async getTemplate(n,s,o=false){if(!o){if(!Yt.hasRow("templates",s)){return null}const t=Yt.getRow("templates",s);return nn(t)}const e=await t(n,s);console.log("[STORE] Reloading template",e);Yt.setRow("templates",s,tn(e));return e},updateTemplate(t,n){Yt.setRow("templates",t,tn(n));return n},async getEnvelope(n,s,o=false){if(!o){if(!Yt.hasRow("envelopes",s)){return null}const t=Yt.getRow("envelopes",s);return nn(t)}const e=await t(n,s);Yt.setRow("envelopes",s,tn(e));return e},updateEnvelope(t,n){Yt.setRow("envelopes",t,tn(n));return n},getField(t,n,s,o){if(t==="template"){const t=Yt.getRow("templates",n);const e=nn(t);const c=(e.fields||[]).find((t=>t.name===s));const l=(e.roles||[]).map((t=>t.name));const r=l.findIndex((t=>t===c.role_name));return{index:Math.max(r,0),field:o||c}}else{const t=Yt.getRow("envelopes",n);const e=nn(t);const c=(e.fields||[]).find((t=>t.name===s));const l=(e.recipients||[]).map((t=>t.role_name));const r=l.findIndex((t=>t===c.role_name));return{index:r,field:o||c}}}};export{sn as S};
|
2
|
+
//# sourceMappingURL=p-d4be87ef.js.map
|
@@ -0,0 +1 @@
|
|
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","undefined","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","push","arrayShift","shift","object","Object","getPrototypeOf","obj","objEntries","entries","objFrozen","isFrozen","isObject","objPrototype","prototype","objIds","keys","objFreeze","freeze","objNew","fromEntries","objHas","objDel","objForEach","objToArray","objMap","objSize","objIsEmpty","objValidate","validateChild","onInvalidObj","emptyIsValid","child","collSizeN","collSizer","coll","collValues","total","coll2","collSize","collSize2","collSize3","collSize4","collHas","keyOrValue","has","collIsEmpty","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","callWithIds","id2","defaultSorter","sortKey1","sortKey2","pairNew","pairCollSize2","pair","func","pairNewMap","pairClone","pairIsEqual","entry1","entry2","jsonString","JSON","stringify","jsonParse","parse","jsonStringWithMap","_key","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","sortableCellIds","rowCellIds","tablesChanged","tableChanged","rowChanged","callValuesListenersForChanges","hasValuesNow","hasValues","valuesChanged","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","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","argumentCount","listenable","console","log","safeJsonParse","val","fallback","e","objectToRow","rowToObject","startsWith","replace","Store","subscribe","getter","forceReload","callback","addRowListener","catch","error","unsubscribe","getTemplate","endpoint","templateId","reload","template","updateTemplate","getEnvelope","envelopeId","envelope","updateEnvelope","getField","source","sourceId","fieldName","fieldOverride","field","fields","find","name","roleNames","roles","role","findIndex","role_name","Math","max","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 == undefined;\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 = () => undefined;\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 objMap = (obj, cb) =>\n objNew(objToArray(obj, (value, id) => [id, 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 objForEach(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 objMap(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 : undefined;\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 : undefined;\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 : undefined;\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], undefined, (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 = undefined;\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 = undefined;\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, undefined]);\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 undefined,\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 ? undefined\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 ? undefined : metric),\n (metric, add, remove) =>\n remove == metric ? undefined : mathMax(add, metric),\n ],\n ],\n [\n MIN,\n [\n (numbers) => mathMin(...numbers),\n (metric, add) => mathMin(add, metric),\n (metric, remove) => (remove == metric ? undefined : metric),\n (metric, add, remove) =>\n remove == metric ? undefined : 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 undefined;\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 ? undefined\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 = undefined;\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 ? undefined : 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, undefined, ([, 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(), undefined, 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 objMap(\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) ? undefined : 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 ? undefined : 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], undefined, 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], undefined, getCellChange);\n }\n }\n }\n };\n const callValuesListenersForChanges = (mutator) => {\n const hasValuesNow = hasValues();\n if (hasValuesNow != hadValues) {\n callListeners(hasValuesListeners[mutator], undefined, 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], undefined, 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 = undefined;\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 objMap(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 ? objMap(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 objMap(changes[0], (table, tableId) =>\n isUndefined(table)\n ? delTable(tableId)\n : objMap(table, (row, rowId) =>\n isUndefined(row)\n ? delRow(tableId, rowId)\n : objMap(row, (cell, cellId) =>\n setOrDelCell(store, tableId, rowId, cellId, cell),\n ),\n ),\n );\n objMap(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 ? undefined\n : mapToObj(\n table,\n (row, rowId) =>\n mapGet(mapGet(changedRowIds, tableId), rowId) === -1\n ? undefined\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], undefined);\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], undefined);\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 objMap(\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) : undefined,\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 undefined,\n 1,\n ),\n ),\n undefined,\n 1,\n ),\n ),\n undefined,\n 1,\n ),\n ) &&\n stampValidate(mergeableContent[1], (values) =>\n objValidate(\n values,\n (value) => stampValidate(value, isCellOrValueOrNullOrUndefined),\n undefined,\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 undefined,\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 objMap(\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":"8CAAA,MAAMA,EAAaC,UAAiBA,EACpC,MAAMC,EAAe,GACrB,MAAMC,EAASH,EAAUE,GACzB,MAAME,EAAUJ,EAAU,MAC1B,MAAMK,EAASL,EAAU,GACzB,MAAMM,EAAWN,EAAUA,GAC3B,MAAMO,EAAO,OACb,MAAMC,EAAU,UAKhB,MAAMC,EAAW,WAIjB,MAAMC,EAAM,MAEZ,MAAMC,EAAM,MACZ,MAAMC,EAAM,MACZ,MAAMC,EAAQ,QACd,MAAMC,EAASD,EAAQ,IACvB,MAAME,EAAYF,EAAQD,EAC1B,MAAMI,EAAM,MACZ,MAAMC,EAAYD,EAAM,QACxB,MAAME,EAAUF,EAAMJ,EAEtB,MAAMO,EAAO,OACb,MAAMC,EAAWD,EAAOP,EACxB,MAAMS,EAAQ,QACd,MAAMC,EAASD,EAAQ,IACvB,MAAME,EAAYF,EAAQT,EAE1B,MAAMY,EAAMC,GAAQvB,E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lP,MAAOkL,GAAciE,IACrBoF,aAAcrJ,GAAc4D,IAC5B+H,YACE9R,GAAUqK,IACVlE,GAAcmE,MAElB,MAAM+M,GAAuB,CAC3BC,EACAC,EACAC,EACAC,EACAC,IAEC/P,EAAoB,CACnB2P,EACAC,EACAC,EACAC,EACAC,GAEJ,MAAMxU,GAAQ,CACZ6O,cACAC,aACAE,eACAC,YACAC,mBACApB,eACAqB,aACAC,mBACAM,UACAC,cACAlD,WACAsC,aACAa,eACAjD,YACAa,aACAqC,YACAC,gBACAC,UACAC,WACAzB,aACA0B,YACAC,iBACAC,iBACAC,WACAC,uBACAC,uBACAC,iBACAnM,gBAAiB,IAAMA,EACvBC,gBAAiB,IAAMA,EACvBmM,cACA3G,aACA8G,YACAE,UACAE,UACAE,iBACA3Q,WACA0J,aACAmH,oBACAzQ,YACA4Q,gBACAG,iBACAE,iBACAE,WACAE,mBACAC,mBACAE,aACAtI,aACA2H,YACAC,UACAnR,WACA0J,aACAtJ,YACA0R,mBACAF,mBACAG,aACAxD,eACA0D,oBACAG,yBACAG,qBACAJ,qBACAK,gBACAI,oBACAE,cACAC,eACAC,gBACAE,2BACAG,+BACAC,oCACAC,mCACAlR,gBACAH,eACAuR,oBACAW,YAAa,IAAM,MAEnBtQ,eACApC,eACAK,iBACA+R,yBAEFpY,GACE,CACE,CAACtF,EAAMG,GAAS,CAAC,EAAGiP,GAAoB,GAAI,IAAM,CAAC2H,OACnD5W,CAACA,GAAS,CAAC,EAAGkP,IACdjP,CAACA,GAAY,CAAC,EAAGkP,IACjB,CAACtP,EAAME,GAAQ,CACb,EACAqP,GACA,CAACgJ,IACA3M,GAAQ,CAACwN,MAAYxN,KAExB1L,CAACA,GAAQ,CAAC,EAAGsP,GAAgB,CAAC+I,KAC9B,CAACrY,EAAQO,GAAW,CAAC,EAAGgP,GAAuB,CAAC8I,KAChD,CAACvY,EAAME,EAAQM,GAAO,CACpB,EACAkP,GACA,CAAC6I,GAAaE,IACb7M,GAAQ,CAACyN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