document-model 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/cjs/document-model.js +20 -1
- package/dist/browser/cjs/document-model.js.map +1 -0
- package/dist/browser/cjs/document.js +15 -1
- package/dist/browser/cjs/document.js.map +1 -0
- package/dist/browser/cjs/index.js +14 -1
- package/dist/browser/cjs/index.js.map +1 -0
- package/dist/browser/cjs/internal/index-DdOJi6Ua.js +2336 -0
- package/dist/browser/cjs/internal/index-DdOJi6Ua.js.map +1 -0
- package/dist/browser/cjs/internal/index-pAtJQrtD.js +49 -0
- package/dist/browser/cjs/internal/index-pAtJQrtD.js.map +1 -0
- package/dist/browser/cjs/internal/object-CRlmL8Nt.js +4333 -0
- package/dist/browser/cjs/internal/object-CRlmL8Nt.js.map +1 -0
- package/dist/browser/es/document-model.js +17 -17
- package/dist/browser/es/document-model.js.map +1 -0
- package/dist/browser/es/document.js +13 -14
- package/dist/browser/es/document.js.map +1 -0
- package/dist/browser/es/index.js +12 -14
- package/dist/browser/es/index.js.map +1 -0
- package/dist/browser/es/internal/index-BsGRYydP.js +50 -0
- package/dist/browser/es/internal/index-BsGRYydP.js.map +1 -0
- package/dist/browser/es/internal/index-C1HKYMZA.js +2337 -0
- package/dist/browser/es/internal/index-C1HKYMZA.js.map +1 -0
- package/dist/browser/es/internal/object-B562qKhQ.js +4334 -0
- package/dist/browser/es/internal/object-B562qKhQ.js.map +1 -0
- package/dist/browser/src/document/actions/creators.d.ts +2 -1
- package/dist/browser/src/document/actions/index.d.ts +1 -0
- package/dist/browser/src/document/actions/types.d.ts +3 -2
- package/dist/browser/src/document/object.d.ts +9 -1128
- package/dist/browser/src/document/reducer.d.ts +16 -13
- package/dist/browser/src/document/schema/types.d.ts +1 -0
- package/dist/browser/src/document/schema/zod.d.ts +12 -8
- package/dist/browser/src/document/signal.d.ts +1 -0
- package/dist/browser/src/document/types.d.ts +9 -6
- package/dist/browser/src/document/utils/base.d.ts +7 -5
- package/dist/browser/src/document/utils/document-helpers.d.ts +1 -0
- package/dist/browser/src/document/utils/file.d.ts +3 -2
- package/dist/browser/src/document/utils/validation.d.ts +1 -0
- package/dist/browser/src/document-model/custom/reducers/header.d.ts +1 -0
- package/dist/browser/src/document-model/custom/reducers/module.d.ts +1 -0
- package/dist/browser/src/document-model/custom/reducers/operation-error.d.ts +1 -0
- package/dist/browser/src/document-model/custom/reducers/operation-example.d.ts +1 -0
- package/dist/browser/src/document-model/custom/reducers/operation.d.ts +1 -0
- package/dist/browser/src/document-model/custom/reducers/state.d.ts +1 -0
- package/dist/browser/src/document-model/custom/reducers/versioning.d.ts +1 -5
- package/dist/browser/src/document-model/custom/utils.d.ts +1 -0
- package/dist/browser/src/document-model/gen/actions.d.ts +1 -0
- package/dist/browser/src/document-model/gen/document-model.d.ts +2 -1
- package/dist/browser/src/document-model/gen/header/actions.d.ts +1 -0
- package/dist/browser/src/document-model/gen/header/creators.d.ts +1 -0
- package/dist/browser/src/document-model/gen/header/object.d.ts +1 -0
- package/dist/browser/src/document-model/gen/header/operations.d.ts +1 -0
- package/dist/browser/src/document-model/gen/module/actions.d.ts +1 -0
- package/dist/browser/src/document-model/gen/module/creators.d.ts +1 -0
- package/dist/browser/src/document-model/gen/module/object.d.ts +1 -0
- package/dist/browser/src/document-model/gen/module/operations.d.ts +1 -0
- package/dist/browser/src/document-model/gen/object.d.ts +8 -7
- package/dist/browser/src/document-model/gen/operation/actions.d.ts +1 -0
- package/dist/browser/src/document-model/gen/operation/creators.d.ts +1 -0
- package/dist/browser/src/document-model/gen/operation/object.d.ts +1 -0
- package/dist/browser/src/document-model/gen/operation/operations.d.ts +1 -0
- package/dist/browser/src/document-model/gen/operation-error/actions.d.ts +1 -0
- package/dist/browser/src/document-model/gen/operation-error/creators.d.ts +1 -0
- package/dist/browser/src/document-model/gen/operation-error/object.d.ts +1 -0
- package/dist/browser/src/document-model/gen/operation-error/operations.d.ts +1 -0
- package/dist/browser/src/document-model/gen/operation-example/actions.d.ts +1 -0
- package/dist/browser/src/document-model/gen/operation-example/creators.d.ts +1 -0
- package/dist/browser/src/document-model/gen/operation-example/object.d.ts +1 -0
- package/dist/browser/src/document-model/gen/operation-example/operations.d.ts +1 -0
- package/dist/browser/src/document-model/gen/reducer.d.ts +2 -1
- package/dist/browser/src/document-model/gen/schema/index.d.ts +2 -2
- package/dist/browser/src/document-model/gen/schema/types.d.ts +1 -0
- package/dist/browser/src/document-model/gen/schema/zod.d.ts +70 -69
- package/dist/browser/src/document-model/gen/state/actions.d.ts +1 -0
- package/dist/browser/src/document-model/gen/state/creators.d.ts +1 -0
- package/dist/browser/src/document-model/gen/state/object.d.ts +1 -0
- package/dist/browser/src/document-model/gen/state/operations.d.ts +1 -0
- package/dist/browser/src/document-model/gen/types.d.ts +4 -3
- package/dist/browser/src/document-model/gen/utils.d.ts +1 -0
- package/dist/browser/src/document-model/gen/versioning/actions.d.ts +1 -0
- package/dist/browser/src/document-model/gen/versioning/creators.d.ts +1 -0
- package/dist/browser/src/document-model/gen/versioning/object.d.ts +1 -0
- package/dist/browser/src/document-model/gen/versioning/operations.d.ts +1 -0
- package/dist/browser/src/document-model/index.d.ts +62 -65
- package/dist/browser/vite.config.d.ts +1 -1
- package/dist/browser/vitest.config.d.ts +1 -1
- package/dist/node/cjs/document-model.js +24 -1
- package/dist/node/cjs/document-model.js.map +1 -0
- package/dist/node/cjs/document.js +15 -1
- package/dist/node/cjs/document.js.map +1 -0
- package/dist/node/cjs/index.js +14 -1
- package/dist/node/cjs/index.js.map +1 -0
- package/dist/node/cjs/internal/index-BWc0K1Dk.js +2340 -0
- package/dist/node/cjs/internal/index-BWc0K1Dk.js.map +1 -0
- package/dist/node/cjs/internal/index-DxD7Ha1j.js +49 -0
- package/dist/node/cjs/internal/index-DxD7Ha1j.js.map +1 -0
- package/dist/node/cjs/internal/object-_zq9luMS.js +2335 -0
- package/dist/node/cjs/internal/object-_zq9luMS.js.map +1 -0
- package/dist/node/es/document-model.js +16 -16
- package/dist/node/es/document-model.js.map +1 -0
- package/dist/node/es/document.js +13 -18
- package/dist/node/es/document.js.map +1 -0
- package/dist/node/es/index.js +12 -18
- package/dist/node/es/index.js.map +1 -0
- package/dist/node/es/internal/index-D8WTToX1.js +2341 -0
- package/dist/node/es/internal/index-D8WTToX1.js.map +1 -0
- package/dist/node/es/internal/index-DkkBVgni.js +50 -0
- package/dist/node/es/internal/index-DkkBVgni.js.map +1 -0
- package/dist/node/es/internal/object-D3jjs7tr.js +2336 -0
- package/dist/node/es/internal/object-D3jjs7tr.js.map +1 -0
- package/dist/node/src/document/actions/creators.d.ts +2 -1
- package/dist/node/src/document/actions/index.d.ts +1 -0
- package/dist/node/src/document/actions/types.d.ts +3 -2
- package/dist/node/src/document/object.d.ts +9 -1128
- package/dist/node/src/document/reducer.d.ts +16 -13
- package/dist/node/src/document/schema/types.d.ts +1 -0
- package/dist/node/src/document/schema/zod.d.ts +12 -8
- package/dist/node/src/document/signal.d.ts +1 -0
- package/dist/node/src/document/types.d.ts +9 -6
- package/dist/node/src/document/utils/base.d.ts +7 -5
- package/dist/node/src/document/utils/document-helpers.d.ts +1 -0
- package/dist/node/src/document/utils/file.d.ts +3 -2
- package/dist/node/src/document/utils/validation.d.ts +1 -0
- package/dist/node/src/document-model/custom/reducers/header.d.ts +1 -0
- package/dist/node/src/document-model/custom/reducers/module.d.ts +1 -0
- package/dist/node/src/document-model/custom/reducers/operation-error.d.ts +1 -0
- package/dist/node/src/document-model/custom/reducers/operation-example.d.ts +1 -0
- package/dist/node/src/document-model/custom/reducers/operation.d.ts +1 -0
- package/dist/node/src/document-model/custom/reducers/state.d.ts +1 -0
- package/dist/node/src/document-model/custom/reducers/versioning.d.ts +1 -5
- package/dist/node/src/document-model/custom/utils.d.ts +1 -0
- package/dist/node/src/document-model/gen/actions.d.ts +1 -0
- package/dist/node/src/document-model/gen/document-model.d.ts +2 -1
- package/dist/node/src/document-model/gen/header/actions.d.ts +1 -0
- package/dist/node/src/document-model/gen/header/creators.d.ts +1 -0
- package/dist/node/src/document-model/gen/header/object.d.ts +1 -0
- package/dist/node/src/document-model/gen/header/operations.d.ts +1 -0
- package/dist/node/src/document-model/gen/module/actions.d.ts +1 -0
- package/dist/node/src/document-model/gen/module/creators.d.ts +1 -0
- package/dist/node/src/document-model/gen/module/object.d.ts +1 -0
- package/dist/node/src/document-model/gen/module/operations.d.ts +1 -0
- package/dist/node/src/document-model/gen/object.d.ts +8 -7
- package/dist/node/src/document-model/gen/operation/actions.d.ts +1 -0
- package/dist/node/src/document-model/gen/operation/creators.d.ts +1 -0
- package/dist/node/src/document-model/gen/operation/object.d.ts +1 -0
- package/dist/node/src/document-model/gen/operation/operations.d.ts +1 -0
- package/dist/node/src/document-model/gen/operation-error/actions.d.ts +1 -0
- package/dist/node/src/document-model/gen/operation-error/creators.d.ts +1 -0
- package/dist/node/src/document-model/gen/operation-error/object.d.ts +1 -0
- package/dist/node/src/document-model/gen/operation-error/operations.d.ts +1 -0
- package/dist/node/src/document-model/gen/operation-example/actions.d.ts +1 -0
- package/dist/node/src/document-model/gen/operation-example/creators.d.ts +1 -0
- package/dist/node/src/document-model/gen/operation-example/object.d.ts +1 -0
- package/dist/node/src/document-model/gen/operation-example/operations.d.ts +1 -0
- package/dist/node/src/document-model/gen/reducer.d.ts +2 -1
- package/dist/node/src/document-model/gen/schema/index.d.ts +2 -2
- package/dist/node/src/document-model/gen/schema/types.d.ts +1 -0
- package/dist/node/src/document-model/gen/schema/zod.d.ts +70 -69
- package/dist/node/src/document-model/gen/state/actions.d.ts +1 -0
- package/dist/node/src/document-model/gen/state/creators.d.ts +1 -0
- package/dist/node/src/document-model/gen/state/object.d.ts +1 -0
- package/dist/node/src/document-model/gen/state/operations.d.ts +1 -0
- package/dist/node/src/document-model/gen/types.d.ts +4 -3
- package/dist/node/src/document-model/gen/utils.d.ts +1 -0
- package/dist/node/src/document-model/gen/versioning/actions.d.ts +1 -0
- package/dist/node/src/document-model/gen/versioning/creators.d.ts +1 -0
- package/dist/node/src/document-model/gen/versioning/object.d.ts +1 -0
- package/dist/node/src/document-model/gen/versioning/operations.d.ts +1 -0
- package/dist/node/src/document-model/index.d.ts +62 -65
- package/dist/node/vite.config.d.ts +1 -1
- package/dist/node/vitest.config.d.ts +1 -1
- package/package.json +5 -4
- package/dist/browser/cjs/internal/index-DGWOisRG.js +0 -22
- package/dist/browser/cjs/internal/index-Dl3D9TzG.js +0 -1
- package/dist/browser/cjs/internal/object-DQmy6ar9.js +0 -25
- package/dist/browser/es/internal/index-BnpyOR6R.js +0 -46
- package/dist/browser/es/internal/index-DynAX_OS.js +0 -2104
- package/dist/browser/es/internal/object-DenwvByi.js +0 -2838
- package/dist/node/cjs/internal/index-B96klT84.js +0 -1
- package/dist/node/cjs/internal/index-CtqbrEO2.js +0 -22
- package/dist/node/cjs/internal/object-CXx7IaXb.js +0 -20
- package/dist/node/es/internal/index-DEAJDDrx.js +0 -46
- package/dist/node/es/internal/index-pNw-lk-q.js +0 -2108
- package/dist/node/es/internal/object-2jyfnUeK.js +0 -1736
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";var Tt=Object.defineProperty;var Rt=(t,e,r)=>e in t?Tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var be=(t,e,r)=>(Rt(t,typeof e!="symbol"?e+"":e,r),r);const s=require("./object-DQmy6ar9.js");require("immer");require("jszip");const o=require("zod"),xt=new RegExp("([\\p{Ll}\\d])(\\p{Lu})","gu"),Mt=new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])","gu"),Dt=new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d","u"),Nt=/[^\p{L}\d]+/giu,_e="$1\0$2",Ae="";function ze(t){let e=t.trim();e=e.replace(xt,_e).replace(Mt,_e),e=e.replace(Nt,"\0");let r=0,n=e.length;for(;e.charAt(r)==="\0";)r++;if(r===n)return[];for(;e.charAt(n-1)==="\0";)n--;return e.slice(r,n).split(/\0/g)}function Lt(t){const e=ze(t);for(let r=0;r<e.length;r++){const n=e[r],i=Dt.exec(n);if(i){const a=i.index+(i[1]??i[2]).length;e.splice(r,1,n.slice(0,a),n.slice(a))}}return e}function Ie(t,e){const[r,n,i]=wt(t,e),a=Pt(e==null?void 0:e.locale),l=jt(e==null?void 0:e.locale),d=e!=null&&e.mergeAmbiguousCharacters?Ct(a,l):yt(a,l);return r+n.map(d).join((e==null?void 0:e.delimiter)??"")+i}function Pt(t){return t===!1?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t)}function jt(t){return t===!1?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t)}function Ct(t,e){return r=>`${e(r[0])}${t(r.slice(1))}`}function yt(t,e){return(r,n)=>{const i=r[0];return(n>0&&i>="0"&&i<="9"?"_"+i:e(i))+t(r.slice(1))}}function wt(t,e={}){const r=e.split??(e.separateNumbers?Lt:ze),n=e.prefixCharacters??Ae,i=e.suffixCharacters??Ae;let a=0,l=t.length;for(;a<t.length;){const d=t.charAt(a);if(!n.includes(d))break;a++}for(;l>a;){const d=l-1,zt=t.charAt(d);if(!i.includes(zt))break;l=d}return[t.slice(0,a),r(t.slice(a,l)),t.slice(l)]}function T(t,e=!1){const r=[];if(e&&t==="")return r;try{const n=JSON.parse(t);!e&&!Object.keys(n).length&&r.push({message:"Initial state cannot be empty",details:{initialState:t}})}catch{r.push({message:"Invalid initial state",details:{initialState:t}})}return r}function R(t,e,r="",n=!0){const i=[];if(!n&&!t)return i.push({message:"State schema is required",details:{schema:t}}),i;if(n&&!t)return i;const a=`type ${Ie(e)}${Ie(r)}State`;return t.includes(a)||i.push({message:`Invalid state schema name. Expected ${a}`,details:{schema:t}}),i}function x(t){const e=[];t.length||e.push({message:"Modules are required",details:{modules:t}});const r=t.reduce((n,i)=>[...n,...b(i)],[]);return[...e,...r]}function b(t){const e=[];t.name||e.push({message:"Module name is required",details:{module:t}}),t.operations.length||e.push({message:"Module operations are required",details:{module:t}});const r=t.operations.reduce((n,i)=>[...n,..._(i)],[]);return[...e,...r]}function _(t){const e=[];return t.name||e.push({message:"Operation name is required",details:{operation:t}}),t.schema||e.push({message:"Operation schema is required",details:{operation:t}}),e}const kt=Object.freeze(Object.defineProperty({__proto__:null,validateInitialState:T,validateModule:b,validateModuleOperation:_,validateModules:x,validateStateSchemaName:R},Symbol.toStringTag,{value:"Module"})),M={id:"powerhouse/document-model",name:"DocumentModel",extension:"phdm",description:"The Powerhouse Document Model describes the state and operations of a document type.",author:{name:"Powerhouse",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],modules:[{name:"header",operations:[{name:"SetModelName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}],state:{global:{schema:"",initialValue:`{
|
|
2
|
-
"id": "",
|
|
3
|
-
"name": "",
|
|
4
|
-
"extension": "",
|
|
5
|
-
"description": "",
|
|
6
|
-
"author": {
|
|
7
|
-
"name": "",
|
|
8
|
-
"website": ""
|
|
9
|
-
},
|
|
10
|
-
"specifications": [
|
|
11
|
-
{
|
|
12
|
-
"version": 1,
|
|
13
|
-
"changeLog": [],
|
|
14
|
-
"state": {
|
|
15
|
-
"schema": "",
|
|
16
|
-
"initialValue": "",
|
|
17
|
-
"examples": []
|
|
18
|
-
},
|
|
19
|
-
"modules": []
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
}`,examples:[]},local:{schema:"",initialValue:"{}",examples:[]}}}]},Te=t=>t!=null,vt=o.z.any().refine(t=>Te(t));function D(){return o.z.object({__typename:o.z.literal("AddChangeLogItemInput").optional(),content:o.z.string(),id:o.z.string(),insertBefore:o.z.string().nullable()})}function N(){return o.z.object({description:o.z.string().nullish(),id:o.z.string(),name:o.z.string()})}function L(){return o.z.object({errorCode:o.z.string().nullish(),errorDescription:o.z.string().nullish(),errorName:o.z.string().nullish(),errorTemplate:o.z.string().nullish(),id:o.z.string(),operationId:o.z.string()})}function P(){return o.z.object({example:o.z.string(),id:o.z.string(),operationId:o.z.string()})}function j(){return o.z.object({description:o.z.string().nullish(),id:o.z.string(),moduleId:o.z.string(),name:o.z.string(),reducer:o.z.string().nullish(),schema:o.z.string().nullish(),template:o.z.string().nullish(),scope:A().nullish()})}function C(){return o.z.object({scope:o.z.string(),example:o.z.string(),id:o.z.string(),insertBefore:o.z.string().nullish()})}function Re(){return o.z.object({__typename:o.z.literal("Author").optional(),name:o.z.string(),website:o.z.string().nullable()})}function y(){return o.z.object({__typename:o.z.literal("CodeExample").optional(),id:o.z.string(),value:o.z.string()})}function w(){return o.z.object({__typename:o.z.literal("DeleteChangeLogItemInput").optional(),id:o.z.string()})}function k(){return o.z.object({id:o.z.string()})}function v(){return o.z.object({id:o.z.string()})}function U(){return o.z.object({id:o.z.string()})}function F(){return o.z.object({id:o.z.string()})}function $(){return o.z.object({scope:o.z.string(),id:o.z.string()})}function A(){return o.z.literal("global").or(o.z.literal("local"))}function Ut(){return o.z.union([D(),N(),L(),P(),j(),C(),w(),k(),v(),U(),F(),$(),V(),X(),H(),G(),B(),W(),q(),J(),K(),Q(),Y(),Z(),ee(),te(),re(),oe(),ne(),ie(),se(),ae(),pe(),le(),ce(),de(),ue(),me(),Ee(),he(),Oe()])}function Ft(){return o.z.object({__typename:o.z.literal("DocumentModelState").optional(),author:Re(),description:o.z.string(),extension:o.z.string(),id:o.z.string(),name:o.z.string(),specifications:o.z.array(xe())})}function xe(){return o.z.object({__typename:o.z.literal("DocumentSpecification").optional(),changeLog:o.z.array(o.z.string()),modules:o.z.array(Me()),state:Pe(),version:o.z.number()})}function Me(){return o.z.object({__typename:o.z.literal("Module").optional(),description:o.z.string().nullable(),id:o.z.string(),name:o.z.string(),operations:o.z.array(De())})}function V(){return o.z.object({newModuleId:o.z.string(),operationId:o.z.string()})}function De(){return o.z.object({__typename:o.z.literal("Operation").optional(),description:o.z.string().nullable(),errors:o.z.array(Ne()),examples:o.z.array(y()),id:o.z.string(),name:o.z.string().nullable(),reducer:o.z.string().nullable(),schema:o.z.string().nullable(),template:o.z.string().nullable(),scope:A()})}function Ne(){return o.z.object({__typename:o.z.literal("OperationError").optional(),code:o.z.string().nullable(),description:o.z.string().nullable(),id:o.z.string(),name:o.z.string().nullable(),template:o.z.string().nullable()})}function X(){return o.z.object({__typename:o.z.literal("ReorderChangeLogItemsInput").optional(),order:o.z.array(o.z.string())})}function H(){return o.z.object({moduleId:o.z.string(),order:o.z.array(o.z.string())})}function G(){return o.z.object({order:o.z.array(o.z.string())})}function B(){return o.z.object({operationId:o.z.string(),order:o.z.array(o.z.string())})}function W(){return o.z.object({operationId:o.z.string(),order:o.z.array(o.z.string())})}function q(){return o.z.object({scope:o.z.string(),order:o.z.array(o.z.string())})}function J(){return o.z.object({authorName:o.z.string()})}function K(){return o.z.object({authorWebsite:o.z.string()})}function Q(){return o.z.object({scope:o.z.string(),initialValue:o.z.string()})}function Y(){return o.z.object({description:o.z.string()})}function Z(){return o.z.object({extension:o.z.string()})}function ee(){return o.z.object({id:o.z.string()})}function te(){return o.z.object({name:o.z.string()})}function re(){return o.z.object({description:o.z.string().nullish(),id:o.z.string()})}function oe(){return o.z.object({id:o.z.string(),name:o.z.string().nullish()})}function ne(){return o.z.object({description:o.z.string().nullish(),id:o.z.string()})}function ie(){return o.z.object({errorCode:o.z.string().nullish(),id:o.z.string()})}function se(){return o.z.object({errorDescription:o.z.string().nullish(),id:o.z.string()})}function ae(){return o.z.object({errorName:o.z.string().nullish(),id:o.z.string()})}function pe(){return o.z.object({errorTemplate:o.z.string().nullish(),id:o.z.string()})}function le(){return o.z.object({id:o.z.string(),name:o.z.string().nullish()})}function Le(){return o.z.object({id:o.z.string(),scope:A()})}function ce(){return o.z.object({id:o.z.string(),reducer:o.z.string().nullish()})}function de(){return o.z.object({id:o.z.string(),schema:o.z.string().nullish()})}function ue(){return o.z.object({id:o.z.string(),template:o.z.string().nullish()})}function me(){return o.z.object({scope:o.z.string(),schema:o.z.string()})}function z(){return o.z.object({__typename:o.z.literal("State").optional(),examples:o.z.array(y()),initialValue:o.z.string(),schema:o.z.string()})}function Pe(){return o.z.object({global:z(),local:z()})}function Ee(){return o.z.object({__typename:o.z.literal("UpdateChangeLogItemInput").optional(),id:o.z.string(),newContent:o.z.string()})}function he(){return o.z.object({example:o.z.string(),id:o.z.string()})}function Oe(){return o.z.object({scope:o.z.string(),id:o.z.string(),newExample:o.z.string()})}const je=Object.freeze(Object.defineProperty({__proto__:null,AddChangeLogItemInputSchema:D,AddModuleInputSchema:N,AddOperationErrorInputSchema:L,AddOperationExampleInputSchema:P,AddOperationInputSchema:j,AddStateExampleInputSchema:C,AuthorSchema:Re,CodeExampleSchema:y,DeleteChangeLogItemInputSchema:w,DeleteModuleInputSchema:k,DeleteOperationErrorInputSchema:v,DeleteOperationExampleInputSchema:U,DeleteOperationInputSchema:F,DeleteStateExampleInputSchema:$,DocumentModelInputSchema:Ut,DocumentModelStateSchema:Ft,DocumentSpecificationSchema:xe,ModuleSchema:Me,MoveOperationInputSchema:V,OperationErrorSchema:Ne,OperationSchema:De,OperationScopeSchema:A,ReorderChangeLogItemsInputSchema:X,ReorderModuleOperationsInputSchema:H,ReorderModulesInputSchema:G,ReorderOperationErrorsInputSchema:B,ReorderOperationExamplesInputSchema:W,ReorderStateExamplesInputSchema:q,ScopeStateSchema:Pe,SetAuthorNameInputSchema:J,SetAuthorWebsiteInputSchema:K,SetInitialStateInputSchema:Q,SetModelDescriptionInputSchema:Y,SetModelExtensionInputSchema:Z,SetModelIdInputSchema:ee,SetModelNameInputSchema:te,SetModuleDescriptionInputSchema:re,SetModuleNameInputSchema:oe,SetOperationDescriptionInputSchema:ne,SetOperationErrorCodeInputSchema:ie,SetOperationErrorDescriptionInputSchema:se,SetOperationErrorNameInputSchema:ae,SetOperationErrorTemplateInputSchema:pe,SetOperationNameInputSchema:le,SetOperationReducerInputSchema:ce,SetOperationSchemaInputSchema:de,SetOperationScopeInputSchema:Le,SetOperationTemplateInputSchema:ue,SetStateSchemaInputSchema:me,StateSchema:z,UpdateChangeLogItemInputSchema:Ee,UpdateOperationExampleInputSchema:he,UpdateStateExampleInputSchema:Oe,definedNonNullAnySchema:vt,isDefinedNonNullAny:Te},Symbol.toStringTag,{value:"Module"})),u={setModelNameOperation(t,e){t.name=e.input.name},setModelIdOperation(t,e){t.id=e.input.id},setModelExtensionOperation(t,e){t.extension=e.input.extension},setModelDescriptionOperation(t,e){t.description=e.input.description},setAuthorNameOperation(t,e){t.author=t.author||{name:"",website:null},t.author.name=e.input.authorName},setAuthorWebsiteOperation(t,e){t.author=t.author||{name:"",website:null},t.author.website=e.input.authorWebsite}},O={addChangeLogItemOperation(t,e){throw new Error('Reducer "addChangeLogItemOperation" not yet implemented')},updateChangeLogItemOperation(t,e){throw new Error('Reducer "updateChangeLogItemOperation" not yet implemented')},deleteChangeLogItemOperation(t,e){throw new Error('Reducer "deleteChangeLogItemOperation" not yet implemented')},reorderChangeLogItemsOperation(t,e){throw new Error('Reducer "reorderChangeLogItemsOperation" not yet implemented')},releaseNewVersionOperation(t,e){throw new Error('Reducer "releaseNewVersionOperation" not yet implemented')}},$t=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},g={addModuleOperation(t,e){t.specifications[t.specifications.length-1].modules.push({id:e.input.id,name:e.input.name,description:e.input.description||"",operations:[]})},setModuleNameOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].id===e.input.id&&(r.modules[n].name=e.input.name||"")},setModuleDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].id===e.input.id&&(r.modules[n].description=e.input.description||"")},deleteModuleOperation(t,e){const r=t.specifications[t.specifications.length-1];r.modules=r.modules.filter(n=>n.id!=e.input.id)},reorderModulesOperation(t,e){t.specifications[t.specifications.length-1].modules.sort($t(e.input.order))}},Vt=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},c={addOperationErrorOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.operationId&&r.modules[n].operations[i].errors.push({id:e.input.id,name:e.input.errorName||"",code:e.input.errorCode||"",description:e.input.errorDescription||"",template:e.input.errorTemplate||""})},setOperationErrorCodeOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].errors.length;a++)r.modules[n].operations[i].errors[a].id==e.input.id&&(r.modules[n].operations[i].errors[a].code=e.input.errorCode||"")},setOperationErrorNameOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].errors.length;a++)r.modules[n].operations[i].errors[a].id==e.input.id&&(r.modules[n].operations[i].errors[a].name=e.input.errorName||"")},setOperationErrorDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].errors.length;a++)r.modules[n].operations[i].errors[a].id==e.input.id&&(r.modules[n].operations[i].errors[a].description=e.input.errorDescription||"")},setOperationErrorTemplateOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].errors.length;a++)r.modules[n].operations[i].errors[a].id==e.input.id&&(r.modules[n].operations[i].errors[a].template=e.input.errorTemplate||"")},deleteOperationErrorOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].errors=r.modules[n].operations[i].errors.filter(a=>a.id!=e.input.id)},reorderOperationErrorsOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.operationId&&r.modules[n].operations[i].errors.sort(Vt(e.input.order))}},Xt=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},f={addOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.operationId&&r.modules[n].operations[i].examples.push({id:e.input.id,value:e.input.example})},updateOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].examples.length;a++)r.modules[n].operations[i].examples[a].id==e.input.id&&(r.modules[n].operations[i].examples[a].value=e.input.example)},deleteOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].examples=r.modules[n].operations[i].examples.filter(a=>a.id!=e.input.id)},reorderOperationExamplesOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.operationId&&r.modules[n].operations[i].examples.sort(Xt(e.input.order))}},Ht=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},p={addOperationOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].id==e.input.moduleId&&r.modules[n].operations.push({id:e.input.id,name:e.input.name,description:e.input.description||"",schema:e.input.schema||"",template:e.input.template||e.input.description||"",reducer:e.input.reducer||"",errors:[],examples:[],scope:e.input.scope||"global"})},setOperationNameOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].name=e.input.name||"")},setOperationScopeOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].scope=e.input.scope||"global")},setOperationSchemaOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].schema=e.input.schema||"")},setOperationDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].description=e.input.description||"")},setOperationTemplateOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].template=e.input.template||"")},setOperationReducerOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].reducer=e.input.reducer||"")},moveOperationOperation(t,e){const r=[],n=t.specifications[t.specifications.length-1];for(let i=0;i<n.modules.length;i++)n.modules[i].operations=n.modules[i].operations.filter(a=>a.id==e.input.operationId?(r.push(a),!1):!0);for(let i=0;i<n.modules.length;i++)n.modules[i].id==e.input.newModuleId&&n.modules[i].operations.push(...r)},deleteOperationOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].operations=r.modules[n].operations.filter(i=>i.id!=e.input.id)},reorderModuleOperationsOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].id==e.input.moduleId&&r.modules[n].operations.sort(Ht(e.input.order))}},Gt=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},m={setStateSchemaOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].schema=e.input.schema;else throw new Error(`Invalid scope: ${e.input.scope}`)},setInitialStateOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].initialValue=e.input.initialValue;else throw new Error(`Invalid scope: ${e.input.scope}`)},addStateExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].examples.push({id:e.input.id,value:e.input.example});else throw new Error(`Invalid scope: ${e.input.scope}`)},updateStateExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];if(!Object.keys(r.state).includes(e.input.scope))throw new Error(`Invalid scope: ${e.input.scope}`);const n=r.state[e.input.scope].examples;for(let i=0;i<n.length;i++)n[i].id==e.input.id&&(n[i].value=e.input.newExample)},deleteStateExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].examples=r.state[e.input.scope].examples.filter(n=>n.id!=e.input.id);else throw new Error(`Invalid scope: ${e.input.scope}`)},reorderStateExamplesOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].examples.sort(Gt(e.input.order));else throw new Error(`Invalid scope: ${e.input.scope}`)}},Bt=(t,e)=>{if(s.isBaseAction(e))return t;switch(e.type){case"SET_MODEL_NAME":te().parse(e.input),u.setModelNameOperation(t.global,e);break;case"SET_MODEL_ID":ee().parse(e.input),u.setModelIdOperation(t.global,e);break;case"SET_MODEL_EXTENSION":Z().parse(e.input),u.setModelExtensionOperation(t.global,e);break;case"SET_MODEL_DESCRIPTION":Y().parse(e.input),u.setModelDescriptionOperation(t.global,e);break;case"SET_AUTHOR_NAME":J().parse(e.input),u.setAuthorNameOperation(t.global,e);break;case"SET_AUTHOR_WEBSITE":K().parse(e.input),u.setAuthorWebsiteOperation(t.global,e);break;case"ADD_CHANGE_LOG_ITEM":D().parse(e.input),O.addChangeLogItemOperation(t.global,e);break;case"UPDATE_CHANGE_LOG_ITEM":Ee().parse(e.input),O.updateChangeLogItemOperation(t.global,e);break;case"DELETE_CHANGE_LOG_ITEM":w().parse(e.input),O.deleteChangeLogItemOperation(t.global,e);break;case"REORDER_CHANGE_LOG_ITEMS":X().parse(e.input),O.reorderChangeLogItemsOperation(t.global,e);break;case"RELEASE_NEW_VERSION":if(Object.keys(e.input).length>0)throw new Error("Expected empty input for action RELEASE_NEW_VERSION");O.releaseNewVersionOperation(t.global,e);break;case"ADD_MODULE":N().parse(e.input),g.addModuleOperation(t.global,e);break;case"SET_MODULE_NAME":oe().parse(e.input),g.setModuleNameOperation(t.global,e);break;case"SET_MODULE_DESCRIPTION":re().parse(e.input),g.setModuleDescriptionOperation(t.global,e);break;case"DELETE_MODULE":k().parse(e.input),g.deleteModuleOperation(t.global,e);break;case"REORDER_MODULES":G().parse(e.input),g.reorderModulesOperation(t.global,e);break;case"ADD_OPERATION_ERROR":L().parse(e.input),c.addOperationErrorOperation(t.global,e);break;case"SET_OPERATION_ERROR_CODE":ie().parse(e.input),c.setOperationErrorCodeOperation(t.global,e);break;case"SET_OPERATION_ERROR_NAME":ae().parse(e.input),c.setOperationErrorNameOperation(t.global,e);break;case"SET_OPERATION_ERROR_DESCRIPTION":se().parse(e.input),c.setOperationErrorDescriptionOperation(t.global,e);break;case"SET_OPERATION_ERROR_TEMPLATE":pe().parse(e.input),c.setOperationErrorTemplateOperation(t.global,e);break;case"DELETE_OPERATION_ERROR":v().parse(e.input),c.deleteOperationErrorOperation(t.global,e);break;case"REORDER_OPERATION_ERRORS":B().parse(e.input),c.reorderOperationErrorsOperation(t.global,e);break;case"ADD_OPERATION_EXAMPLE":P().parse(e.input),f.addOperationExampleOperation(t.global,e);break;case"UPDATE_OPERATION_EXAMPLE":he().parse(e.input),f.updateOperationExampleOperation(t.global,e);break;case"DELETE_OPERATION_EXAMPLE":U().parse(e.input),f.deleteOperationExampleOperation(t.global,e);break;case"REORDER_OPERATION_EXAMPLES":W().parse(e.input),f.reorderOperationExamplesOperation(t.global,e);break;case"ADD_OPERATION":j().parse(e.input),p.addOperationOperation(t.global,e);break;case"SET_OPERATION_NAME":le().parse(e.input),p.setOperationNameOperation(t.global,e);break;case"SET_OPERATION_SCOPE":Le().parse(e.input),p.setOperationScopeOperation(t.global,e);break;case"SET_OPERATION_SCHEMA":de().parse(e.input),p.setOperationSchemaOperation(t.global,e);break;case"SET_OPERATION_DESCRIPTION":ne().parse(e.input),p.setOperationDescriptionOperation(t.global,e);break;case"SET_OPERATION_TEMPLATE":ue().parse(e.input),p.setOperationTemplateOperation(t.global,e);break;case"SET_OPERATION_REDUCER":ce().parse(e.input),p.setOperationReducerOperation(t.global,e);break;case"MOVE_OPERATION":V().parse(e.input),p.moveOperationOperation(t.global,e);break;case"DELETE_OPERATION":F().parse(e.input),p.deleteOperationOperation(t.global,e);break;case"REORDER_MODULE_OPERATIONS":H().parse(e.input),p.reorderModuleOperationsOperation(t.global,e);break;case"SET_STATE_SCHEMA":me().parse(e.input),m.setStateSchemaOperation(t.global,e);break;case"SET_INITIAL_STATE":Q().parse(e.input),m.setInitialStateOperation(t.global,e);break;case"ADD_STATE_EXAMPLE":C().parse(e.input),m.addStateExampleOperation(t.global,e);break;case"UPDATE_STATE_EXAMPLE":Oe().parse(e.input),m.updateStateExampleOperation(t.global,e);break;case"DELETE_STATE_EXAMPLE":$().parse(e.input),m.deleteStateExampleOperation(t.global,e);break;case"REORDER_STATE_EXAMPLES":q().parse(e.input),m.reorderStateExamplesOperation(t.global,e);break;default:return t}},h=s.createReducer(Bt),Wt={id:"",name:"",extension:"",description:"",author:{name:"",website:""},specifications:[{version:1,changeLog:[],state:{global:{schema:"",initialValue:"",examples:[]},local:{schema:"",initialValue:"",examples:[]}},modules:[]}]},qt={},S={fileExtension:"phdm",createState(t){return{global:{...Wt,...t==null?void 0:t.global},local:{...qt,...t==null?void 0:t.local}}},createExtendedState(t){return s.createExtendedState({...t,documentType:"powerhouse/document-model"},S.createState)},createDocument(t){return s.createDocument(S.createExtendedState(t),S.createState)},saveToFile(t,e,r){return s.saveToFile(t,e,"phdm",r)},saveToFileHandle(t,e){return s.saveToFileHandle(t,e)},loadFromFile(t){return s.loadFromFile(t,h)},loadFromInput(t){return s.loadFromInput(t,h)}},Ce=t=>s.createAction("SET_MODEL_NAME",{...t}),ye=t=>s.createAction("SET_MODEL_ID",{...t}),we=t=>s.createAction("SET_MODEL_EXTENSION",{...t}),ke=t=>s.createAction("SET_MODEL_DESCRIPTION",{...t}),ve=t=>s.createAction("SET_AUTHOR_NAME",{...t}),Ue=t=>s.createAction("SET_AUTHOR_WEBSITE",{...t});class Jt extends s.BaseDocument{setModelName(e,r){return this.dispatch(Ce(e),r)}setModelId(e,r){return this.dispatch(ye(e),r)}setModelExtension(e,r){return this.dispatch(we(e),r)}setModelDescription(e,r){return this.dispatch(ke(e),r)}setAuthorName(e,r){return this.dispatch(ve(e),r)}setAuthorWebsite(e,r){return this.dispatch(Ue(e),r)}}const Fe=t=>s.createAction("ADD_CHANGE_LOG_ITEM",{...t}),$e=t=>s.createAction("UPDATE_CHANGE_LOG_ITEM",{...t}),Ve=t=>s.createAction("DELETE_CHANGE_LOG_ITEM",{...t}),Xe=t=>s.createAction("REORDER_CHANGE_LOG_ITEMS",{...t}),He=()=>s.createAction("RELEASE_NEW_VERSION");class Kt extends s.BaseDocument{addChangeLogItem(e,r){return this.dispatch(Fe(e),r)}updateChangeLogItem(e,r){return this.dispatch($e(e),r)}deleteChangeLogItem(e,r){return this.dispatch(Ve(e),r)}reorderChangeLogItems(e,r){return this.dispatch(Xe(e),r)}releaseNewVersion(e){return this.dispatch(He(),e)}}const Ge=t=>s.createAction("ADD_MODULE",{...t}),Be=t=>s.createAction("SET_MODULE_NAME",{...t}),We=t=>s.createAction("SET_MODULE_DESCRIPTION",{...t}),qe=t=>s.createAction("DELETE_MODULE",{...t}),Je=t=>s.createAction("REORDER_MODULES",{...t});class Qt extends s.BaseDocument{addModule(e,r){return this.dispatch(Ge(e),r)}setModuleName(e,r){return this.dispatch(Be(e),r)}setModuleDescription(e,r){return this.dispatch(We(e),r)}deleteModule(e,r){return this.dispatch(qe(e),r)}reorderModules(e,r){return this.dispatch(Je(e),r)}}const Ke=t=>s.createAction("ADD_OPERATION_ERROR",{...t}),Qe=t=>s.createAction("SET_OPERATION_ERROR_CODE",{...t}),Ye=t=>s.createAction("SET_OPERATION_ERROR_NAME",{...t}),Ze=t=>s.createAction("SET_OPERATION_ERROR_DESCRIPTION",{...t}),et=t=>s.createAction("SET_OPERATION_ERROR_TEMPLATE",{...t}),tt=t=>s.createAction("DELETE_OPERATION_ERROR",{...t}),rt=t=>s.createAction("REORDER_OPERATION_ERRORS",{...t});class Yt extends s.BaseDocument{addOperationError(e,r){return this.dispatch(Ke(e),r)}setOperationErrorCode(e,r){return this.dispatch(Qe(e),r)}setOperationErrorName(e,r){return this.dispatch(Ye(e),r)}setOperationErrorDescription(e,r){return this.dispatch(Ze(e),r)}setOperationErrorTemplate(e,r){return this.dispatch(et(e),r)}deleteOperationError(e,r){return this.dispatch(tt(e),r)}reorderOperationErrors(e,r){return this.dispatch(rt(e),r)}}const ot=t=>s.createAction("ADD_OPERATION_EXAMPLE",{...t}),nt=t=>s.createAction("UPDATE_OPERATION_EXAMPLE",{...t}),it=t=>s.createAction("DELETE_OPERATION_EXAMPLE",{...t}),st=t=>s.createAction("REORDER_OPERATION_EXAMPLES",{...t});class Zt extends s.BaseDocument{addOperationExample(e,r){return this.dispatch(ot(e),r)}updateOperationExample(e,r){return this.dispatch(nt(e),r)}deleteOperationExample(e,r){return this.dispatch(it(e),r)}reorderOperationExamples(e,r){return this.dispatch(st(e),r)}}const at=t=>s.createAction("ADD_OPERATION",{...t}),pt=t=>s.createAction("SET_OPERATION_NAME",{...t}),lt=t=>s.createAction("SET_OPERATION_SCOPE",{...t}),ct=t=>s.createAction("SET_OPERATION_SCHEMA",{...t}),dt=t=>s.createAction("SET_OPERATION_DESCRIPTION",{...t}),ut=t=>s.createAction("SET_OPERATION_TEMPLATE",{...t}),mt=t=>s.createAction("SET_OPERATION_REDUCER",{...t}),Et=t=>s.createAction("MOVE_OPERATION",{...t}),ht=t=>s.createAction("DELETE_OPERATION",{...t}),Ot=t=>s.createAction("REORDER_MODULE_OPERATIONS",{...t});class er extends s.BaseDocument{addOperation(e,r){return this.dispatch(at(e),r)}setOperationName(e,r){return this.dispatch(pt(e),r)}setOperationScope(e,r){return this.dispatch(lt(e),r)}setOperationSchema(e,r){return this.dispatch(ct(e),r)}setOperationDescription(e,r){return this.dispatch(dt(e),r)}setOperationTemplate(e,r){return this.dispatch(ut(e),r)}setOperationReducer(e,r){return this.dispatch(mt(e),r)}moveOperation(e,r){return this.dispatch(Et(e),r)}deleteOperation(e,r){return this.dispatch(ht(e),r)}reorderModuleOperations(e,r){return this.dispatch(Ot(e),r)}}const gt=t=>s.createAction("SET_STATE_SCHEMA",{...t}),St=t=>s.createAction("SET_INITIAL_STATE",{...t}),ft=t=>s.createAction("ADD_STATE_EXAMPLE",{...t}),bt=t=>s.createAction("UPDATE_STATE_EXAMPLE",{...t}),_t=t=>s.createAction("DELETE_STATE_EXAMPLE",{...t}),At=t=>s.createAction("REORDER_STATE_EXAMPLES",{...t});class tr extends s.BaseDocument{setStateSchema(e,r){return this.dispatch(gt(e),r)}setInitialState(e,r){return this.dispatch(St(e),r)}addStateExample(e,r){return this.dispatch(ft(e),r)}updateStateExample(e,r){return this.dispatch(bt(e),r)}deleteStateExample(e,r){return this.dispatch(_t(e),r)}reorderStateExamples(e,r){return this.dispatch(At(e),r)}}var E;let I=(E=class extends s.BaseDocument{constructor(e,r){super(h,S.createDocument(e),r)}saveToFile(e,r){return super.saveToFile(e,E.fileExtension,r)}loadFromFile(e){return super.loadFromFile(e)}static async fromFile(e){const r=new this;return await r.loadFromFile(e),r}},be(E,"fileExtension","phdm"),E);s.applyMixins(I,[Jt,Kt,Qt,Yt,Zt,er,tr]);const rr=Object.freeze(Object.defineProperty({__proto__:null,addChangeLogItem:Fe,addModule:Ge,addOperation:at,addOperationError:Ke,addOperationExample:ot,addStateExample:ft,deleteChangeLogItem:Ve,deleteModule:qe,deleteOperation:ht,deleteOperationError:tt,deleteOperationExample:it,deleteStateExample:_t,moveOperation:Et,releaseNewVersion:He,reorderChangeLogItems:Xe,reorderModuleOperations:Ot,reorderModules:Je,reorderOperationErrors:rt,reorderOperationExamples:st,reorderStateExamples:At,setAuthorName:ve,setAuthorWebsite:Ue,setInitialState:St,setModelDescription:ke,setModelExtension:we,setModelId:ye,setModelName:Ce,setModuleDescription:We,setModuleName:Be,setOperationDescription:dt,setOperationErrorCode:Qe,setOperationErrorDescription:Ze,setOperationErrorName:Ye,setOperationErrorTemplate:et,setOperationName:pt,setOperationReducer:mt,setOperationSchema:ct,setOperationScope:lt,setOperationTemplate:ut,setStateSchema:gt,updateChangeLogItem:$e,updateOperationExample:nt,updateStateExample:bt},Symbol.toStringTag,{value:"Module"})),ge=I,Se={...S,...kt},fe={...s.BaseActions,...rr},It={Document:ge,reducer:h,actions:fe,utils:Se,documentModel:M},or=Object.freeze(Object.defineProperty({__proto__:null,Document:ge,DocumentModel:I,actions:fe,documentModel:M,module:It,reducer:h,utils:Se,validateInitialState:T,validateModule:b,validateModuleOperation:_,validateModules:x,validateStateSchemaName:R,z:je},Symbol.toStringTag,{value:"Module"}));exports.Document=ge;exports.DocumentModel=or;exports.DocumentModel$1=I;exports.actions=fe;exports.documentModel=M;exports.module=It;exports.reducer=h;exports.utils=Se;exports.validateInitialState=T;exports.validateModule=b;exports.validateModuleOperation=_;exports.validateModules=x;exports.validateStateSchemaName=R;exports.zod=je;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./object-DQmy6ar9.js"),t=Object.freeze(Object.defineProperty({__proto__:null,calculateSkipsLeft:e.calculateSkipsLeft,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,documentHelpers:e.documentHelpers,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,isNoopOperation:e.isNoopOperation,isSameDocument:e.isSameDocument,isUndoRedo:e.isUndoRedo,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,mapSkippedOperations:e.mapSkippedOperations,parseResultingState:e.parseResultingState,readOnly:e.readOnly,replayDocument:e.replayDocument,replayOperations:e.replayOperations,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle,sortMappedOperations:e.sortMappedOperations,sortOperations:e.sortOperations,validateOperations:e.validateOperations},Symbol.toStringTag,{value:"Module"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,processUndoRedo:e.processUndoRedo,updateDocument:e.updateDocument,updateHeader:e.updateHeader,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";var ni=Object.defineProperty;var oi=(i,r,o)=>r in i?ni(i,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[r]=o;var Bt=(i,r,o)=>(oi(i,typeof r!="symbol"?r+"":r,o),o);const ot=require("immer"),_=require("zod"),fe=require("jszip"),he=i=>i!=null,ai=_.z.any().refine(i=>he(i)),me=_.z.enum(["LOAD_STATE"]),de=_.z.enum(["PRUNE"]),xe=_.z.enum(["REDO"]),ge=_.z.enum(["SET_NAME"]),ye=_.z.enum(["UNDO"]);function si(){return _.z.object({__typename:_.z.literal("Action").optional(),type:_.z.string()})}function bt(){return _.z.literal("global").or(_.z.literal("local"))}function we(){return _.z.union([Ee(),Se(),ve(),_e(),Ae()])}function pi(){return _.z.object({__typename:_.z.literal("DocumentFile").optional(),data:_.z.string(),extension:_.z.string().nullable(),fileName:_.z.string().nullable(),mimeType:_.z.string()})}function Ee(){return _.z.object({input:_.z.lazy(()=>Vt()),type:me,scope:bt()})}function Vt(){return _.z.object({operations:_.z.number(),state:_.z.lazy(()=>be())})}function be(){return _.z.object({data:_.z.unknown().nullish(),name:_.z.string()})}function ci(){return _.z.object({__typename:_.z.literal("Operation").optional(),hash:_.z.string(),index:_.z.number(),timestamp:_.z.string().datetime(),type:_.z.string()})}function Se(){return _.z.object({input:_.z.lazy(()=>Wt()),type:de,scope:bt()})}function Wt(){return _.z.object({end:_.z.number().nullish(),start:_.z.number().nullish()})}const Xt=_.z.number;function ve(){return _.z.object({input:Xt(),type:xe,scope:bt()})}const Kt=_.z.string;function _e(){return _.z.object({input:Kt(),type:ge,scope:_.z.literal("global")})}function li(){return _.z.object({__typename:_.z.literal("SetNameOperation").optional(),hash:_.z.string(),index:_.z.number(),input:_.z.string(),timestamp:_.z.string().datetime(),type:_.z.string()})}const Gt=_.z.number;function Ae(){return _.z.object({input:Gt(),type:ye,scope:bt()})}const ui=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:si,BaseActionSchema:we,DocumentFileSchema:pi,LoadStateActionInputSchema:Vt,LoadStateActionSchema:Ee,LoadStateActionStateInputSchema:be,Load_StateSchema:me,OperationSchema:ci,OperationScopeSchema:bt,PruneActionInputSchema:Wt,PruneActionSchema:Se,PruneSchema:de,RedoActionInputSchema:Xt,RedoActionSchema:ve,RedoSchema:xe,SetNameActionInputSchema:Kt,SetNameActionSchema:_e,SetNameOperationSchema:li,Set_NameSchema:ge,UndoActionInputSchema:Gt,UndoActionSchema:Ae,UndoSchema:ye,definedNonNullAnySchema:ai,isDefinedNonNullAny:he},Symbol.toStringTag,{value:"Module"}));function Zt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Rt={exports:{}};(function(i,r){const{hasOwnProperty:o}=Object.prototype,p=Y();p.configure=Y,p.stringify=p,p.default=p,r.stringify=p,r.configure=Y,i.exports=p;const l=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;function f(w){return w.length<5e3&&!l.test(w)?`"${w}"`:JSON.stringify(w)}function c(w){if(w.length>200)return w.sort();for(let E=1;E<w.length;E++){const S=w[E];let z=E;for(;z!==0&&w[z-1]>S;)w[z]=w[z-1],z--;w[z]=S}return w}const a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function h(w){return a.call(w)!==void 0&&w.length!==0}function g(w,E,S){w.length<S&&(S=w.length);const z=E===","?"":" ";let J=`"0":${z}${w[0]}`;for(let V=1;V<S;V++)J+=`${E}"${V}":${z}${w[V]}`;return J}function y(w){if(o.call(w,"circularValue")){const E=w.circularValue;if(typeof E=="string")return`"${E}"`;if(E==null)return E;if(E===Error||E===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function b(w,E){let S;if(o.call(w,E)&&(S=w[E],typeof S!="boolean"))throw new TypeError(`The "${E}" argument must be of type boolean`);return S===void 0?!0:S}function O(w,E){let S;if(o.call(w,E)){if(S=w[E],typeof S!="number")throw new TypeError(`The "${E}" argument must be of type number`);if(!Number.isInteger(S))throw new TypeError(`The "${E}" argument must be an integer`);if(S<1)throw new RangeError(`The "${E}" argument must be >= 1`)}return S===void 0?1/0:S}function j(w){return w===1?"1 item":`${w} items`}function U(w){const E=new Set;for(const S of w)(typeof S=="string"||typeof S=="number")&&E.add(String(S));return E}function q(w){if(o.call(w,"strict")){const E=w.strict;if(typeof E!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(E)return S=>{let z=`Object can not safely be stringified. Received type ${typeof S}`;throw typeof S!="function"&&(z+=` (${S.toString()})`),new Error(z)}}}function Y(w){w={...w};const E=q(w);E&&(w.bigint===void 0&&(w.bigint=!1),"circularValue"in w||(w.circularValue=Error));const S=y(w),z=b(w,"bigint"),J=b(w,"deterministic"),V=O(w,"maximumDepth"),M=O(w,"maximumBreadth");function mt(W,m,v,D,B,C){let A=m[W];switch(typeof A=="object"&&A!==null&&typeof A.toJSON=="function"&&(A=A.toJSON(W)),A=D.call(m,W,A),typeof A){case"string":return f(A);case"object":{if(A===null)return"null";if(v.indexOf(A)!==-1)return S;let T="",F=",";const I=C;if(Array.isArray(A)){if(A.length===0)return"[]";if(V<v.length+1)return'"[Array]"';v.push(A),B!==""&&(C+=B,T+=`
|
|
2
|
-
${C}`,F=`,
|
|
3
|
-
${C}`);const X=Math.min(A.length,M);let tt=0;for(;tt<X-1;tt++){const ut=mt(String(tt),A,v,D,B,C);T+=ut!==void 0?ut:"null",T+=F}const et=mt(String(tt),A,v,D,B,C);if(T+=et!==void 0?et:"null",A.length-1>M){const ut=A.length-M-1;T+=`${F}"... ${j(ut)} not stringified"`}return B!==""&&(T+=`
|
|
4
|
-
${I}`),v.pop(),`[${T}]`}let R=Object.keys(A);const H=R.length;if(H===0)return"{}";if(V<v.length+1)return'"[Object]"';let $="",K="";B!==""&&(C+=B,F=`,
|
|
5
|
-
${C}`,$=" ");const Q=Math.min(H,M);J&&!h(A)&&(R=c(R)),v.push(A);for(let X=0;X<Q;X++){const tt=R[X],et=mt(tt,A,v,D,B,C);et!==void 0&&(T+=`${K}${f(tt)}:${$}${et}`,K=F)}if(H>M){const X=H-M;T+=`${K}"...":${$}"${j(X)} not stringified"`,K=F}return B!==""&&K.length>1&&(T=`
|
|
6
|
-
${C}${T}
|
|
7
|
-
${I}`),v.pop(),`{${T}}`}case"number":return isFinite(A)?String(A):E?E(A):"null";case"boolean":return A===!0?"true":"false";case"undefined":return;case"bigint":if(z)return String(A);default:return E?E(A):void 0}}function dt(W,m,v,D,B,C){switch(typeof m=="object"&&m!==null&&typeof m.toJSON=="function"&&(m=m.toJSON(W)),typeof m){case"string":return f(m);case"object":{if(m===null)return"null";if(v.indexOf(m)!==-1)return S;const A=C;let T="",F=",";if(Array.isArray(m)){if(m.length===0)return"[]";if(V<v.length+1)return'"[Array]"';v.push(m),B!==""&&(C+=B,T+=`
|
|
8
|
-
${C}`,F=`,
|
|
9
|
-
${C}`);const H=Math.min(m.length,M);let $=0;for(;$<H-1;$++){const Q=dt(String($),m[$],v,D,B,C);T+=Q!==void 0?Q:"null",T+=F}const K=dt(String($),m[$],v,D,B,C);if(T+=K!==void 0?K:"null",m.length-1>M){const Q=m.length-M-1;T+=`${F}"... ${j(Q)} not stringified"`}return B!==""&&(T+=`
|
|
10
|
-
${A}`),v.pop(),`[${T}]`}v.push(m);let I="";B!==""&&(C+=B,F=`,
|
|
11
|
-
${C}`,I=" ");let R="";for(const H of D){const $=dt(H,m[H],v,D,B,C);$!==void 0&&(T+=`${R}${f(H)}:${I}${$}`,R=F)}return B!==""&&R.length>1&&(T=`
|
|
12
|
-
${C}${T}
|
|
13
|
-
${A}`),v.pop(),`{${T}}`}case"number":return isFinite(m)?String(m):E?E(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(z)return String(m);default:return E?E(m):void 0}}function ct(W,m,v,D,B){switch(typeof m){case"string":return f(m);case"object":{if(m===null)return"null";if(typeof m.toJSON=="function"){if(m=m.toJSON(W),typeof m!="object")return ct(W,m,v,D,B);if(m===null)return"null"}if(v.indexOf(m)!==-1)return S;const C=B;if(Array.isArray(m)){if(m.length===0)return"[]";if(V<v.length+1)return'"[Array]"';v.push(m),B+=D;let $=`
|
|
14
|
-
${B}`;const K=`,
|
|
15
|
-
${B}`,Q=Math.min(m.length,M);let X=0;for(;X<Q-1;X++){const et=ct(String(X),m[X],v,D,B);$+=et!==void 0?et:"null",$+=K}const tt=ct(String(X),m[X],v,D,B);if($+=tt!==void 0?tt:"null",m.length-1>M){const et=m.length-M-1;$+=`${K}"... ${j(et)} not stringified"`}return $+=`
|
|
16
|
-
${C}`,v.pop(),`[${$}]`}let A=Object.keys(m);const T=A.length;if(T===0)return"{}";if(V<v.length+1)return'"[Object]"';B+=D;const F=`,
|
|
17
|
-
${B}`;let I="",R="",H=Math.min(T,M);h(m)&&(I+=g(m,F,M),A=A.slice(m.length),H-=m.length,R=F),J&&(A=c(A)),v.push(m);for(let $=0;$<H;$++){const K=A[$],Q=ct(K,m[K],v,D,B);Q!==void 0&&(I+=`${R}${f(K)}: ${Q}`,R=F)}if(T>M){const $=T-M;I+=`${R}"...": "${j($)} not stringified"`,R=F}return R!==""&&(I=`
|
|
18
|
-
${B}${I}
|
|
19
|
-
${C}`),v.pop(),`{${I}}`}case"number":return isFinite(m)?String(m):E?E(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(z)return String(m);default:return E?E(m):void 0}}function lt(W,m,v){switch(typeof m){case"string":return f(m);case"object":{if(m===null)return"null";if(typeof m.toJSON=="function"){if(m=m.toJSON(W),typeof m!="object")return lt(W,m,v);if(m===null)return"null"}if(v.indexOf(m)!==-1)return S;let D="";if(Array.isArray(m)){if(m.length===0)return"[]";if(V<v.length+1)return'"[Array]"';v.push(m);const F=Math.min(m.length,M);let I=0;for(;I<F-1;I++){const H=lt(String(I),m[I],v);D+=H!==void 0?H:"null",D+=","}const R=lt(String(I),m[I],v);if(D+=R!==void 0?R:"null",m.length-1>M){const H=m.length-M-1;D+=`,"... ${j(H)} not stringified"`}return v.pop(),`[${D}]`}let B=Object.keys(m);const C=B.length;if(C===0)return"{}";if(V<v.length+1)return'"[Object]"';let A="",T=Math.min(C,M);h(m)&&(D+=g(m,",",M),B=B.slice(m.length),T-=m.length,A=","),J&&(B=c(B)),v.push(m);for(let F=0;F<T;F++){const I=B[F],R=lt(I,m[I],v);R!==void 0&&(D+=`${A}${f(I)}:${R}`,A=",")}if(C>M){const F=C-M;D+=`${A}"...":"${j(F)} not stringified"`}return v.pop(),`{${D}}`}case"number":return isFinite(m)?String(m):E?E(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(z)return String(m);default:return E?E(m):void 0}}function $t(W,m,v){if(arguments.length>1){let D="";if(typeof v=="number"?D=" ".repeat(Math.min(v,10)):typeof v=="string"&&(D=v.slice(0,10)),m!=null){if(typeof m=="function")return mt("",{"":W},[],m,D,"");if(Array.isArray(m))return dt("",W,[],U(m),D,"")}if(D.length!==0)return ct("",W,[],D,"")}return lt("",W,[])}return $t}})(Rt,Rt.exports);var fi=Rt.exports;const yt=Zt(fi);yt.configure;let It;const hi=new Uint8Array(16);function mi(){if(!It&&(It=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!It))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return It(hi)}const G=[];for(let i=0;i<256;++i)G.push((i+256).toString(16).slice(1));function di(i,r=0){return G[i[r+0]]+G[i[r+1]]+G[i[r+2]]+G[i[r+3]]+"-"+G[i[r+4]]+G[i[r+5]]+"-"+G[i[r+6]]+G[i[r+7]]+"-"+G[i[r+8]]+G[i[r+9]]+"-"+G[i[r+10]]+G[i[r+11]]+G[i[r+12]]+G[i[r+13]]+G[i[r+14]]+G[i[r+15]]}const xi=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ue={randomUUID:xi};function gi(i,r,o){if(ue.randomUUID&&!r&&!i)return ue.randomUUID();i=i||{};const p=i.random||(i.rng||mi)();if(p[6]=p[6]&15|64,p[8]=p[8]&63|128,r){o=o||0;for(let l=0;l<16;++l)r[o+l]=p[l];return r}return di(p)}function yi(i,r){return{...i,name:r}}function wi(i,r,o){const{scope:p,input:l}=r,f={document:i,action:r,skip:o};return ot.produce(f,c=>{if(c.document.operations[p].length<1)throw new Error(`Cannot undo: no operations in history for scope "${p}"`);if(l<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(c.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const a=c.document.operations[p].at(-1),h=a&&a.type==="NOOP"&&a.skip>0;if(c.skip+=l,h){c.skip+=a.skip;const O=c.document.operations[p][c.document.operations[p].length-2];O&&a.index-O.index===1&&c.document.operations[p].pop()}if(c.document.operations[p].length<c.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const g=c.document.operations[p].length-1;let y=l,b=h?g-a.skip:g;for(;y>0&&b>=0;){const O=c.document.operations[p][b];if(!O){y--,b--;continue}O.type==="NOOP"&&O.skip>0?(b=b-(O.skip+1),c.skip+=O.skip+1):(c.document.clipboard.push({...O}),y--,b--)}c.action=ii(p)})}function Ei(i,r,o){const{scope:p,input:l}=r,f={document:i,action:r,skip:o};return ot.produce(f,c=>{if(c.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(l>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(l<1)throw new Error("Invalid REDO action: invalid redo input value");if(c.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const a=c.document.clipboard.findLastIndex(g=>g.scope===p);if(a<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${p}"`);const h=c.document.clipboard.splice(a,1)[0];c.action=ot.castDraft({type:h.type,scope:h.scope,input:h.input})})}function bi(i,r,o){const{scope:p}=r,l=i.operations[p];let{input:{start:f,end:c}}=r;f=f||0,c=c||l.length;const a=l.slice(f,c),h=l.slice(0,f),g=l.slice(c),y=jt(i.initialState,{...i.operations,[p]:h.concat(a)},o),{name:b,state:O}=y,j=h.length,U=h.length?h[h.length-1].timestamp:g.length?g[0].timestamp:new Date().toISOString();return jt(i.initialState,{...i.operations,[p]:[...h,{...pe({name:b,state:O},a.length),timestamp:U,index:j,hash:Ct({state:O},"global")},...g.map((q,Y)=>({...q,index:j+Y+1}))]},o)}function Si(i,r){return{...i,name:r.name,state:r.state??{global:{},local:{}}}}const Oe="SET_NAME",St="UNDO",vt="REDO",Dt="PRUNE",Fe="LOAD_STATE",vi="NOOP",Be={"application/andrew-inset":["ez"],"application/appinstaller":["appinstaller"],"application/applixware":["aw"],"application/appx":["appx"],"application/appxbundle":["appxbundle"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/automationml-aml+xml":["aml"],"application/automationml-amlx+zip":["amlx"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cpl+xml":["cpl"],"application/cu-seeme":["cu"],"application/cwl":["cwl"],"application/dash+xml":["mpd"],"application/dash-patch+xml":["mpp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdf":["fdf"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["*js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/media-policy-dataset+xml":["mpf"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["*mp4","*mpg4","mp4s","m4p"],"application/msix":["msix"],"application/msixbundle":["msixbundle"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-keys":["asc"],"application/pgp-signature":["sig","*asc"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/sql":["sql"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/watcherinfo+xml":["wif"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xfdf":["xfdf"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/aac":["adts","aac"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avci":["avci"],"image/avcs":["avcs"],"image/avif":["avif"],"image/bmp":["bmp","dib"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/dpx":["dpx"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm","jpgm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/jt":["jt"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/prc":["prc"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/u3d":["u3d"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/javascript":["js","mjs"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["md","markdown"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/wgsl":["wgsl"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","*jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};Object.freeze(Be);var it=function(i,r,o,p){if(o==="a"&&!p)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?i!==r||!p:!r.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return o==="m"?p:o==="a"?p.call(i):p?p.value:r.get(i)},gt,wt,ft;class _i{constructor(...r){gt.set(this,new Map),wt.set(this,new Map),ft.set(this,new Map);for(const o of r)this.define(o)}define(r,o=!1){for(let[p,l]of Object.entries(r)){p=p.toLowerCase(),l=l.map(a=>a.toLowerCase()),it(this,ft,"f").has(p)||it(this,ft,"f").set(p,new Set);const f=it(this,ft,"f").get(p);let c=!0;for(let a of l){const h=a.startsWith("*");if(a=h?a.slice(1):a,f==null||f.add(a),c&&it(this,wt,"f").set(p,a),c=!1,h)continue;const g=it(this,gt,"f").get(a);if(g&&g!=p&&!o)throw new Error(`"${p} -> ${a}" conflicts with "${g} -> ${a}". Pass \`force=true\` to override this definition.`);it(this,gt,"f").set(a,p)}}return this}getType(r){if(typeof r!="string")return null;const o=r.replace(/^.*[/\\]/,"").toLowerCase(),p=o.replace(/^.*\./,"").toLowerCase(),l=o.length<r.length;return!(p.length<o.length-1)&&l?null:it(this,gt,"f").get(p)??null}getExtension(r){var o;return typeof r!="string"?null:(r=(o=r==null?void 0:r.split)==null?void 0:o.call(r,";")[0],(r&&it(this,wt,"f").get(r.trim().toLowerCase()))??null)}getAllExtensions(r){return typeof r!="string"?null:it(this,ft,"f").get(r.toLowerCase())??null}_freeze(){this.define=()=>{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(const r of it(this,ft,"f").values())Object.freeze(r);return this}_getTestState(){return{types:it(this,gt,"f"),extensions:it(this,wt,"f")}}}gt=new WeakMap,wt=new WeakMap,ft=new WeakMap;const Ai=new _i(Be)._freeze();var Lt={exports:{}};typeof Object.create=="function"?Lt.exports=function(r,o){o&&(r.super_=o,r.prototype=Object.create(o.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:Lt.exports=function(r,o){if(o){r.super_=o;var p=function(){};p.prototype=o.prototype,r.prototype=new p,r.prototype.constructor=r}};var Ie=Lt.exports,Pt={exports:{}},je={},Tt={};Tt.byteLength=Bi;Tt.toByteArray=ji;Tt.fromByteArray=ki;var at=[],rt=[],Oi=typeof Uint8Array<"u"?Uint8Array:Array,zt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var xt=0,Fi=zt.length;xt<Fi;++xt)at[xt]=zt[xt],rt[zt.charCodeAt(xt)]=xt;rt[45]=62;rt[95]=63;function De(i){var r=i.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var o=i.indexOf("=");o===-1&&(o=r);var p=o===r?0:4-o%4;return[o,p]}function Bi(i){var r=De(i),o=r[0],p=r[1];return(o+p)*3/4-p}function Ii(i,r,o){return(r+o)*3/4-o}function ji(i){var r,o=De(i),p=o[0],l=o[1],f=new Oi(Ii(i,p,l)),c=0,a=l>0?p-4:p,h;for(h=0;h<a;h+=4)r=rt[i.charCodeAt(h)]<<18|rt[i.charCodeAt(h+1)]<<12|rt[i.charCodeAt(h+2)]<<6|rt[i.charCodeAt(h+3)],f[c++]=r>>16&255,f[c++]=r>>8&255,f[c++]=r&255;return l===2&&(r=rt[i.charCodeAt(h)]<<2|rt[i.charCodeAt(h+1)]>>4,f[c++]=r&255),l===1&&(r=rt[i.charCodeAt(h)]<<10|rt[i.charCodeAt(h+1)]<<4|rt[i.charCodeAt(h+2)]>>2,f[c++]=r>>8&255,f[c++]=r&255),f}function Di(i){return at[i>>18&63]+at[i>>12&63]+at[i>>6&63]+at[i&63]}function Ti(i,r,o){for(var p,l=[],f=r;f<o;f+=3)p=(i[f]<<16&16711680)+(i[f+1]<<8&65280)+(i[f+2]&255),l.push(Di(p));return l.join("")}function ki(i){for(var r,o=i.length,p=o%3,l=[],f=16383,c=0,a=o-p;c<a;c+=f)l.push(Ti(i,c,c+f>a?a:c+f));return p===1?(r=i[o-1],l.push(at[r>>2]+at[r<<4&63]+"==")):p===2&&(r=(i[o-2]<<8)+i[o-1],l.push(at[r>>10]+at[r>>4&63]+at[r<<2&63]+"=")),l.join("")}var Yt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Yt.read=function(i,r,o,p,l){var f,c,a=l*8-p-1,h=(1<<a)-1,g=h>>1,y=-7,b=o?l-1:0,O=o?-1:1,j=i[r+b];for(b+=O,f=j&(1<<-y)-1,j>>=-y,y+=a;y>0;f=f*256+i[r+b],b+=O,y-=8);for(c=f&(1<<-y)-1,f>>=-y,y+=p;y>0;c=c*256+i[r+b],b+=O,y-=8);if(f===0)f=1-g;else{if(f===h)return c?NaN:(j?-1:1)*(1/0);c=c+Math.pow(2,p),f=f-g}return(j?-1:1)*c*Math.pow(2,f-p)};Yt.write=function(i,r,o,p,l,f){var c,a,h,g=f*8-l-1,y=(1<<g)-1,b=y>>1,O=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,j=p?0:f-1,U=p?1:-1,q=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,c=y):(c=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-c))<1&&(c--,h*=2),c+b>=1?r+=O/h:r+=O*Math.pow(2,1-b),r*h>=2&&(c++,h/=2),c+b>=y?(a=0,c=y):c+b>=1?(a=(r*h-1)*Math.pow(2,l),c=c+b):(a=r*Math.pow(2,b-1)*Math.pow(2,l),c=0));l>=8;i[o+j]=a&255,j+=U,a/=256,l-=8);for(c=c<<l|a,g+=l;g>0;i[o+j]=c&255,j+=U,c/=256,g-=8);i[o+j-U]|=q*128};/*!
|
|
20
|
-
* The buffer module from node.js, for the browser.
|
|
21
|
-
*
|
|
22
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
23
|
-
* @license MIT
|
|
24
|
-
*/(function(i){var r=Tt,o=Yt,p=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=a,i.SlowBuffer=E,i.INSPECT_MAX_BYTES=50;var l=2147483647;i.kMaxLength=l,a.TYPED_ARRAY_SUPPORT=f(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function f(){try{var n=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(n,t),n.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function c(n){if(n>l)throw new RangeError('The value "'+n+'" is invalid for option "size"');var t=new Uint8Array(n);return Object.setPrototypeOf(t,a.prototype),t}function a(n,t,e){if(typeof n=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(n)}return h(n,t,e)}a.poolSize=8192;function h(n,t,e){if(typeof n=="string")return O(n,t);if(ArrayBuffer.isView(n))return U(n);if(n==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);if(nt(n,ArrayBuffer)||n&&nt(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(nt(n,SharedArrayBuffer)||n&&nt(n.buffer,SharedArrayBuffer)))return q(n,t,e);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var s=n.valueOf&&n.valueOf();if(s!=null&&s!==n)return a.from(s,t,e);var u=Y(n);if(u)return u;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return a.from(n[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n)}a.from=function(n,t,e){return h(n,t,e)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function g(n){if(typeof n!="number")throw new TypeError('"size" argument must be of type number');if(n<0)throw new RangeError('The value "'+n+'" is invalid for option "size"')}function y(n,t,e){return g(n),n<=0?c(n):t!==void 0?typeof e=="string"?c(n).fill(t,e):c(n).fill(t):c(n)}a.alloc=function(n,t,e){return y(n,t,e)};function b(n){return g(n),c(n<0?0:w(n)|0)}a.allocUnsafe=function(n){return b(n)},a.allocUnsafeSlow=function(n){return b(n)};function O(n,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=S(n,t)|0,s=c(e),u=s.write(n,t);return u!==e&&(s=s.slice(0,u)),s}function j(n){for(var t=n.length<0?0:w(n.length)|0,e=c(t),s=0;s<t;s+=1)e[s]=n[s]&255;return e}function U(n){if(nt(n,Uint8Array)){var t=new Uint8Array(n);return q(t.buffer,t.byteOffset,t.byteLength)}return j(n)}function q(n,t,e){if(t<0||n.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var s;return t===void 0&&e===void 0?s=new Uint8Array(n):e===void 0?s=new Uint8Array(n,t):s=new Uint8Array(n,t,e),Object.setPrototypeOf(s,a.prototype),s}function Y(n){if(a.isBuffer(n)){var t=w(n.length)|0,e=c(t);return e.length===0||n.copy(e,0,0,t),e}if(n.length!==void 0)return typeof n.length!="number"||Nt(n.length)?c(0):j(n);if(n.type==="Buffer"&&Array.isArray(n.data))return j(n.data)}function w(n){if(n>=l)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+l.toString(16)+" bytes");return n|0}function E(n){return+n!=n&&(n=0),a.alloc(+n)}a.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==a.prototype},a.compare=function(t,e){if(nt(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),nt(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var s=t.length,u=e.length,d=0,x=Math.min(s,u);d<x;++d)if(t[d]!==e[d]){s=t[d],u=e[d];break}return s<u?-1:u<s?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var s;if(e===void 0)for(e=0,s=0;s<t.length;++s)e+=t[s].length;var u=a.allocUnsafe(e),d=0;for(s=0;s<t.length;++s){var x=t[s];if(nt(x,Uint8Array))d+x.length>u.length?a.from(x).copy(u,d):Uint8Array.prototype.set.call(u,x,d);else if(a.isBuffer(x))x.copy(u,d);else throw new TypeError('"list" argument must be an Array of Buffers');d+=x.length}return u};function S(n,t){if(a.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||nt(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);var e=n.length,s=arguments.length>2&&arguments[2]===!0;if(!s&&e===0)return 0;for(var u=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return X(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return ut(n).length;default:if(u)return s?-1:X(n).length;t=(""+t).toLowerCase(),u=!0}}a.byteLength=S;function z(n,t,e){var s=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(n||(n="utf8");;)switch(n){case"hex":return A(this,t,e);case"utf8":case"utf-8":return m(this,t,e);case"ascii":return B(this,t,e);case"latin1":case"binary":return C(this,t,e);case"base64":return W(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),s=!0}}a.prototype._isBuffer=!0;function J(n,t,e){var s=n[t];n[t]=n[e],n[e]=s}a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)J(this,e,e+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)J(this,e,e+3),J(this,e+1,e+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)J(this,e,e+7),J(this,e+1,e+6),J(this,e+2,e+5),J(this,e+3,e+4);return this},a.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?m(this,0,t):z.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0},a.prototype.inspect=function(){var t="",e=i.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},p&&(a.prototype[p]=a.prototype.inspect),a.prototype.compare=function(t,e,s,u,d){if(nt(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),s===void 0&&(s=t?t.length:0),u===void 0&&(u=0),d===void 0&&(d=this.length),e<0||s>t.length||u<0||d>this.length)throw new RangeError("out of range index");if(u>=d&&e>=s)return 0;if(u>=d)return-1;if(e>=s)return 1;if(e>>>=0,s>>>=0,u>>>=0,d>>>=0,this===t)return 0;for(var x=d-u,k=s-e,N=Math.min(x,k),L=this.slice(u,d),Z=t.slice(e,s),P=0;P<N;++P)if(L[P]!==Z[P]){x=L[P],k=Z[P];break}return x<k?-1:k<x?1:0};function V(n,t,e,s,u){if(n.length===0)return-1;if(typeof e=="string"?(s=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Nt(e)&&(e=u?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(u)return-1;e=n.length-1}else if(e<0)if(u)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,s)),a.isBuffer(t))return t.length===0?-1:M(n,t,e,s,u);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?u?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):M(n,[t],e,s,u);throw new TypeError("val must be string, number or Buffer")}function M(n,t,e,s,u){var d=1,x=n.length,k=t.length;if(s!==void 0&&(s=String(s).toLowerCase(),s==="ucs2"||s==="ucs-2"||s==="utf16le"||s==="utf-16le")){if(n.length<2||t.length<2)return-1;d=2,x/=2,k/=2,e/=2}function N(ce,le){return d===1?ce[le]:ce.readUInt16BE(le*d)}var L;if(u){var Z=-1;for(L=e;L<x;L++)if(N(n,L)===N(t,Z===-1?0:L-Z)){if(Z===-1&&(Z=L),L-Z+1===k)return Z*d}else Z!==-1&&(L-=L-Z),Z=-1}else for(e+k>x&&(e=x-k),L=e;L>=0;L--){for(var P=!0,Ft=0;Ft<k;Ft++)if(N(n,L+Ft)!==N(t,Ft)){P=!1;break}if(P)return L}return-1}a.prototype.includes=function(t,e,s){return this.indexOf(t,e,s)!==-1},a.prototype.indexOf=function(t,e,s){return V(this,t,e,s,!0)},a.prototype.lastIndexOf=function(t,e,s){return V(this,t,e,s,!1)};function mt(n,t,e,s){e=Number(e)||0;var u=n.length-e;s?(s=Number(s),s>u&&(s=u)):s=u;var d=t.length;s>d/2&&(s=d/2);for(var x=0;x<s;++x){var k=parseInt(t.substr(x*2,2),16);if(Nt(k))return x;n[e+x]=k}return x}function dt(n,t,e,s){return Ot(X(t,n.length-e),n,e,s)}function ct(n,t,e,s){return Ot(tt(t),n,e,s)}function lt(n,t,e,s){return Ot(ut(t),n,e,s)}function $t(n,t,e,s){return Ot(et(t,n.length-e),n,e,s)}a.prototype.write=function(t,e,s,u){if(e===void 0)u="utf8",s=this.length,e=0;else if(s===void 0&&typeof e=="string")u=e,s=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(s)?(s=s>>>0,u===void 0&&(u="utf8")):(u=s,s=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var d=this.length-e;if((s===void 0||s>d)&&(s=d),t.length>0&&(s<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");u||(u="utf8");for(var x=!1;;)switch(u){case"hex":return mt(this,t,e,s);case"utf8":case"utf-8":return dt(this,t,e,s);case"ascii":case"latin1":case"binary":return ct(this,t,e,s);case"base64":return lt(this,t,e,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $t(this,t,e,s);default:if(x)throw new TypeError("Unknown encoding: "+u);u=(""+u).toLowerCase(),x=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function W(n,t,e){return t===0&&e===n.length?r.fromByteArray(n):r.fromByteArray(n.slice(t,e))}function m(n,t,e){e=Math.min(n.length,e);for(var s=[],u=t;u<e;){var d=n[u],x=null,k=d>239?4:d>223?3:d>191?2:1;if(u+k<=e){var N,L,Z,P;switch(k){case 1:d<128&&(x=d);break;case 2:N=n[u+1],(N&192)===128&&(P=(d&31)<<6|N&63,P>127&&(x=P));break;case 3:N=n[u+1],L=n[u+2],(N&192)===128&&(L&192)===128&&(P=(d&15)<<12|(N&63)<<6|L&63,P>2047&&(P<55296||P>57343)&&(x=P));break;case 4:N=n[u+1],L=n[u+2],Z=n[u+3],(N&192)===128&&(L&192)===128&&(Z&192)===128&&(P=(d&15)<<18|(N&63)<<12|(L&63)<<6|Z&63,P>65535&&P<1114112&&(x=P))}}x===null?(x=65533,k=1):x>65535&&(x-=65536,s.push(x>>>10&1023|55296),x=56320|x&1023),s.push(x),u+=k}return D(s)}var v=4096;function D(n){var t=n.length;if(t<=v)return String.fromCharCode.apply(String,n);for(var e="",s=0;s<t;)e+=String.fromCharCode.apply(String,n.slice(s,s+=v));return e}function B(n,t,e){var s="";e=Math.min(n.length,e);for(var u=t;u<e;++u)s+=String.fromCharCode(n[u]&127);return s}function C(n,t,e){var s="";e=Math.min(n.length,e);for(var u=t;u<e;++u)s+=String.fromCharCode(n[u]);return s}function A(n,t,e){var s=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>s)&&(e=s);for(var u="",d=t;d<e;++d)u+=ri[n[d]];return u}function T(n,t,e){for(var s=n.slice(t,e),u="",d=0;d<s.length-1;d+=2)u+=String.fromCharCode(s[d]+s[d+1]*256);return u}a.prototype.slice=function(t,e){var s=this.length;t=~~t,e=e===void 0?s:~~e,t<0?(t+=s,t<0&&(t=0)):t>s&&(t=s),e<0?(e+=s,e<0&&(e=0)):e>s&&(e=s),e<t&&(e=t);var u=this.subarray(t,e);return Object.setPrototypeOf(u,a.prototype),u};function F(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,s){t=t>>>0,e=e>>>0,s||F(t,e,this.length);for(var u=this[t],d=1,x=0;++x<e&&(d*=256);)u+=this[t+x]*d;return u},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,s){t=t>>>0,e=e>>>0,s||F(t,e,this.length);for(var u=this[t+--e],d=1;e>0&&(d*=256);)u+=this[t+--e]*d;return u},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t=t>>>0,e||F(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||F(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||F(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||F(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||F(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,s){t=t>>>0,e=e>>>0,s||F(t,e,this.length);for(var u=this[t],d=1,x=0;++x<e&&(d*=256);)u+=this[t+x]*d;return d*=128,u>=d&&(u-=Math.pow(2,8*e)),u},a.prototype.readIntBE=function(t,e,s){t=t>>>0,e=e>>>0,s||F(t,e,this.length);for(var u=e,d=1,x=this[t+--u];u>0&&(d*=256);)x+=this[t+--u]*d;return d*=128,x>=d&&(x-=Math.pow(2,8*e)),x},a.prototype.readInt8=function(t,e){return t=t>>>0,e||F(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},a.prototype.readInt16LE=function(t,e){t=t>>>0,e||F(t,2,this.length);var s=this[t]|this[t+1]<<8;return s&32768?s|4294901760:s},a.prototype.readInt16BE=function(t,e){t=t>>>0,e||F(t,2,this.length);var s=this[t+1]|this[t]<<8;return s&32768?s|4294901760:s},a.prototype.readInt32LE=function(t,e){return t=t>>>0,e||F(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t=t>>>0,e||F(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return t=t>>>0,e||F(t,4,this.length),o.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t=t>>>0,e||F(t,4,this.length),o.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||F(t,8,this.length),o.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||F(t,8,this.length),o.read(this,t,!1,52,8)};function I(n,t,e,s,u,d){if(!a.isBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>u||t<d)throw new RangeError('"value" argument is out of bounds');if(e+s>n.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,s,u){if(t=+t,e=e>>>0,s=s>>>0,!u){var d=Math.pow(2,8*s)-1;I(this,t,e,s,d,0)}var x=1,k=0;for(this[e]=t&255;++k<s&&(x*=256);)this[e+k]=t/x&255;return e+s},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,s,u){if(t=+t,e=e>>>0,s=s>>>0,!u){var d=Math.pow(2,8*s)-1;I(this,t,e,s,d,0)}var x=s-1,k=1;for(this[e+x]=t&255;--x>=0&&(k*=256);)this[e+x]=t/k&255;return e+s},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,1,255,0),this[e]=t&255,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},a.prototype.writeIntLE=function(t,e,s,u){if(t=+t,e=e>>>0,!u){var d=Math.pow(2,8*s-1);I(this,t,e,s,d-1,-d)}var x=0,k=1,N=0;for(this[e]=t&255;++x<s&&(k*=256);)t<0&&N===0&&this[e+x-1]!==0&&(N=1),this[e+x]=(t/k>>0)-N&255;return e+s},a.prototype.writeIntBE=function(t,e,s,u){if(t=+t,e=e>>>0,!u){var d=Math.pow(2,8*s-1);I(this,t,e,s,d-1,-d)}var x=s-1,k=1,N=0;for(this[e+x]=t&255;--x>=0&&(k*=256);)t<0&&N===0&&this[e+x+1]!==0&&(N=1),this[e+x]=(t/k>>0)-N&255;return e+s},a.prototype.writeInt8=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},a.prototype.writeInt16LE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeInt32LE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,s){return t=+t,e=e>>>0,s||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function R(n,t,e,s,u,d){if(e+s>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function H(n,t,e,s,u){return t=+t,e=e>>>0,u||R(n,t,e,4),o.write(n,t,e,s,23,4),e+4}a.prototype.writeFloatLE=function(t,e,s){return H(this,t,e,!0,s)},a.prototype.writeFloatBE=function(t,e,s){return H(this,t,e,!1,s)};function $(n,t,e,s,u){return t=+t,e=e>>>0,u||R(n,t,e,8),o.write(n,t,e,s,52,8),e+8}a.prototype.writeDoubleLE=function(t,e,s){return $(this,t,e,!0,s)},a.prototype.writeDoubleBE=function(t,e,s){return $(this,t,e,!1,s)},a.prototype.copy=function(t,e,s,u){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(s||(s=0),!u&&u!==0&&(u=this.length),e>=t.length&&(e=t.length),e||(e=0),u>0&&u<s&&(u=s),u===s||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(s<0||s>=this.length)throw new RangeError("Index out of range");if(u<0)throw new RangeError("sourceEnd out of bounds");u>this.length&&(u=this.length),t.length-e<u-s&&(u=t.length-e+s);var d=u-s;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,s,u):Uint8Array.prototype.set.call(t,this.subarray(s,u),e),d},a.prototype.fill=function(t,e,s,u){if(typeof t=="string"){if(typeof e=="string"?(u=e,e=0,s=this.length):typeof s=="string"&&(u=s,s=this.length),u!==void 0&&typeof u!="string")throw new TypeError("encoding must be a string");if(typeof u=="string"&&!a.isEncoding(u))throw new TypeError("Unknown encoding: "+u);if(t.length===1){var d=t.charCodeAt(0);(u==="utf8"&&d<128||u==="latin1")&&(t=d)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<s)throw new RangeError("Out of range index");if(s<=e)return this;e=e>>>0,s=s===void 0?this.length:s>>>0,t||(t=0);var x;if(typeof t=="number")for(x=e;x<s;++x)this[x]=t;else{var k=a.isBuffer(t)?t:a.from(t,u),N=k.length;if(N===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(x=0;x<s-e;++x)this[x+e]=k[x%N]}return this};var K=/[^+/0-9A-Za-z-_]/g;function Q(n){if(n=n.split("=")[0],n=n.trim().replace(K,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function X(n,t){t=t||1/0;for(var e,s=n.length,u=null,d=[],x=0;x<s;++x){if(e=n.charCodeAt(x),e>55295&&e<57344){if(!u){if(e>56319){(t-=3)>-1&&d.push(239,191,189);continue}else if(x+1===s){(t-=3)>-1&&d.push(239,191,189);continue}u=e;continue}if(e<56320){(t-=3)>-1&&d.push(239,191,189),u=e;continue}e=(u-55296<<10|e-56320)+65536}else u&&(t-=3)>-1&&d.push(239,191,189);if(u=null,e<128){if((t-=1)<0)break;d.push(e)}else if(e<2048){if((t-=2)<0)break;d.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;d.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;d.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return d}function tt(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function et(n,t){for(var e,s,u,d=[],x=0;x<n.length&&!((t-=2)<0);++x)e=n.charCodeAt(x),s=e>>8,u=e%256,d.push(u),d.push(s);return d}function ut(n){return r.toByteArray(Q(n))}function Ot(n,t,e,s){for(var u=0;u<s&&!(u+e>=t.length||u>=n.length);++u)t[u+e]=n[u];return u}function nt(n,t){return n instanceof t||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===t.name}function Nt(n){return n!==n}var ri=function(){for(var n="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var s=e*16,u=0;u<16;++u)t[s+u]=n[e]+n[u];return t}()})(je);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(i,r){var o=je,p=o.Buffer;function l(c,a){for(var h in c)a[h]=c[h]}p.from&&p.alloc&&p.allocUnsafe&&p.allocUnsafeSlow?i.exports=o:(l(o,r),r.Buffer=f);function f(c,a,h){return p(c,a,h)}f.prototype=Object.create(p.prototype),l(p,f),f.from=function(c,a,h){if(typeof c=="number")throw new TypeError("Argument must not be a number");return p(c,a,h)},f.alloc=function(c,a,h){if(typeof c!="number")throw new TypeError("Argument must be a number");var g=p(c);return a!==void 0?typeof h=="string"?g.fill(a,h):g.fill(a):g.fill(0),g},f.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return p(c)},f.allocUnsafeSlow=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return o.SlowBuffer(c)}})(Pt,Pt.exports);var Qt=Pt.exports,Te=Qt.Buffer;function kt(i,r){this._block=Te.alloc(i),this._finalSize=r,this._blockSize=i,this._len=0}kt.prototype.update=function(i,r){typeof i=="string"&&(r=r||"utf8",i=Te.from(i,r));for(var o=this._block,p=this._blockSize,l=i.length,f=this._len,c=0;c<l;){for(var a=f%p,h=Math.min(l-c,p-a),g=0;g<h;g++)o[a+g]=i[c+g];f+=h,c+=h,f%p===0&&this._update(o)}return this._len+=l,this};kt.prototype.digest=function(i){var r=this._len%this._blockSize;this._block[r]=128,this._block.fill(0,r+1),r>=this._finalSize&&(this._update(this._block),this._block.fill(0));var o=this._len*8;if(o<=4294967295)this._block.writeUInt32BE(o,this._blockSize-4);else{var p=(o&4294967295)>>>0,l=(o-p)/4294967296;this._block.writeUInt32BE(l,this._blockSize-8),this._block.writeUInt32BE(p,this._blockSize-4)}this._update(this._block);var f=this._hash();return i?f.toString(i):f};kt.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var ke=kt,Ui=Ie,Ue=ke,Ci=Qt.Buffer,$i=[1518500249,1859775393,-1894007588,-899497514],Ni=new Array(80);function _t(){this.init(),this._w=Ni,Ue.call(this,64,56)}Ui(_t,Ue);_t.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function zi(i){return i<<1|i>>>31}function Mi(i){return i<<5|i>>>27}function Ri(i){return i<<30|i>>>2}function Li(i,r,o,p){return i===0?r&o|~r&p:i===2?r&o|r&p|o&p:r^o^p}_t.prototype._update=function(i){for(var r=this._w,o=this._a|0,p=this._b|0,l=this._c|0,f=this._d|0,c=this._e|0,a=0;a<16;++a)r[a]=i.readInt32BE(a*4);for(;a<80;++a)r[a]=zi(r[a-3]^r[a-8]^r[a-14]^r[a-16]);for(var h=0;h<80;++h){var g=~~(h/20),y=Mi(o)+Li(g,p,l,f)+c+r[h]+$i[g]|0;c=f,f=l,l=Ri(p),p=o,o=y}this._a=o+this._a|0,this._b=p+this._b|0,this._c=l+this._c|0,this._d=f+this._d|0,this._e=c+this._e|0};_t.prototype._hash=function(){var i=Ci.allocUnsafe(20);return i.writeInt32BE(this._a|0,0),i.writeInt32BE(this._b|0,4),i.writeInt32BE(this._c|0,8),i.writeInt32BE(this._d|0,12),i.writeInt32BE(this._e|0,16),i};var Pi=_t;const qi=Zt(Pi);var Hi=Ie,Ce=ke,Ji=Qt.Buffer,Vi=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Wi=new Array(64);function At(){this.init(),this._w=Wi,Ce.call(this,64,56)}Hi(At,Ce);At.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function Xi(i,r,o){return o^i&(r^o)}function Ki(i,r,o){return i&r|o&(i|r)}function Gi(i){return(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10)}function Zi(i){return(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7)}function Yi(i){return(i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3}function Qi(i){return(i>>>17|i<<15)^(i>>>19|i<<13)^i>>>10}At.prototype._update=function(i){for(var r=this._w,o=this._a|0,p=this._b|0,l=this._c|0,f=this._d|0,c=this._e|0,a=this._f|0,h=this._g|0,g=this._h|0,y=0;y<16;++y)r[y]=i.readInt32BE(y*4);for(;y<64;++y)r[y]=Qi(r[y-2])+r[y-7]+Yi(r[y-15])+r[y-16]|0;for(var b=0;b<64;++b){var O=g+Zi(c)+Xi(c,a,h)+Vi[b]+r[b]|0,j=Gi(o)+Ki(o,p,l)|0;g=h,h=a,a=c,c=f+O|0,f=l,l=p,p=o,o=O+j|0}this._a=o+this._a|0,this._b=p+this._b|0,this._c=l+this._c|0,this._d=f+this._d|0,this._e=c+this._e|0,this._f=a+this._f|0,this._g=h+this._g|0,this._h=g+this._h|0};At.prototype._hash=function(){var i=Ji.allocUnsafe(32);return i.writeInt32BE(this._a,0),i.writeInt32BE(this._b,4),i.writeInt32BE(this._c,8),i.writeInt32BE(this._d,12),i.writeInt32BE(this._e,16),i.writeInt32BE(this._f,20),i.writeInt32BE(this._g,24),i.writeInt32BE(this._h,28),i};var tr=At;const er=Zt(tr),te=new Error("File system not available.");function ir(i,r,o){throw te}function $e(i){throw te}function rr(i){throw te}const nr=async i=>$e(),or={sha1:qi,sha256:er},Ut=(i,r="sha1")=>{if(!["sha1","sha256"].includes(r))throw new Error("Hashing algorithm not supported: Available: sha1, sha256");const o=or[r];return new o().update(i).digest("base64")};function Ne(i){const r=[],o=Object.keys(i);for(const p of o){const l=i[p].sort((f,c)=>f.index-c.index);for(let f=0;f<l.length;f++)l[f].index!==f&&r.push({message:`Invalid operation index ${l[f].index} at position ${f}`,details:{position:f,operation:l[f],scope:l[f].scope}})}return r}const ee=async i=>{const r=new fe,{name:o,revision:p,documentType:l,created:f,lastModified:c}=i,a={name:o,revision:p,documentType:l,created:f,lastModified:c};return r.file("header.json",JSON.stringify(a,null,2)),r.file("state.json",JSON.stringify(i.initialState||{},null,2)),r.file("operations.json",JSON.stringify(i.operations,null,2)),Object.keys(i.attachments).forEach(g=>{const{data:y,...b}=i.attachments[g];r.file(g,y,{base64:!0,createFolders:!0,comment:JSON.stringify(b)})}),r},ze=async(i,r,o,p)=>{await(await ee(i)).generateAsync({type:"uint8array",streamFiles:!0});const f=p??i.name,c=`.${o}.zip`;return ir(r,f.endsWith(c)?f:`${f}${c}`)},ar=async(i,r)=>{const p=await(await ee(i)).generateAsync({type:"blob"}),l=await r.createWritable();await l.write(p),await l.close()},qt=async(i,r,o)=>{const p=$e();return Me(p,r,o)},Me=async(i,r,o)=>{const p=new fe;return await p.loadAsync(i),sr(p,r,o)};async function sr(i,r,o){const p=i.file("state.json");if(!p)throw new Error("Initial state not found");const l=await p.async("string"),f=JSON.parse(l),c=i.file("header.json");let a;c&&(a=JSON.parse(await c.async("string")));const h=i.file("operations.json");if(!h)throw new Error("Operations history not found");const g=JSON.parse(await h.async("string")),y=Ne(g);if(y.length){const O=y.map(j=>j.message);throw new Error(O.join(`
|
|
25
|
-
`))}let b=ae(f,g,r,void 0,a,{},o);return a&&(b={...b,...a}),b}function Re(i){const r=i.replace(/^.*\./,"")||void 0,o=i.replace(/^.*[/\\]/,"")||void 0;return{extension:r,fileName:o}}async function pr(i){const{buffer:r,mimeType:o="application/octet-stream"}=await rr(),p=Re(i),l=r.toString("base64");return{data:l,hash:Ut(l),mimeType:o,...p}}async function cr(i){const r=await nr(),o=Ai.getType(i)||"application/octet-stream",p=Re(i),l=r.toString("base64");return{data:l,hash:Ut(l),mimeType:o,...p}}var Le=(i=>(i.UNEXPECTED_INDEX="UNEXPECTED_INDEX",i))(Le||{}),Pe=(i=>(i.DUPLICATED_INDEX="DUPLICATED_INDEX",i.MISSING_INDEX="MISSING_INDEX",i))(Pe||{});function ie(i){const r=[];let o=-1;for(const p of i){const l=p.index-p.skip;l!==o+1&&r.push({operation:{index:p.index,skip:p.skip},issue:"UNEXPECTED_INDEX",category:l>o+1?"MISSING_INDEX":"DUPLICATED_INDEX",message:`Expected index ${o+1} with skip 0 or equivalent, got index ${p.index} with skip ${p.skip}`}),o=p.index}return r}function st(i){var p,l,f;const r=[];let o=i.length-1;for(;o>-1;){r.unshift(i[o]);const c=(((p=i[o])==null?void 0:p.index)||0)-(((l=i[o])==null?void 0:l.skip)||0)-1;let a=o-1;for(;a>-1&&(((f=i[a])==null?void 0:f.index)||0)>c;)a--;o=a}return r}function lr(i){const r=[...i],o=r[r.length-1];return o&&(o.type==="NOOP"?r.push({...o,index:o.index,type:"NOOP",skip:Je(i)}):r.push({type:"NOOP",index:o.index+1,timestamp:new Date().toISOString(),input:{},skip:1,scope:o.scope,hash:o.hash})),r}function pt(i){return i.slice().sort((r,o)=>r.skip-o.skip).sort((r,o)=>r.index-o.index)}const ur=(i,r,o)=>[...r,...o].sort((p,l)=>new Date(p.timestamp).getTime()-new Date(l.timestamp).getTime()).map((p,l)=>({...p,index:i.index+l,skip:l===0?i.skip:0})),fr=(i,r,o)=>[...r,...o].sort((p,l)=>new Date(p.timestamp).getTime()-new Date(l.timestamp).getTime()).sort((p,l)=>p.index-l.index).map((p,l)=>({...p,index:i.index+l,skip:l===0?i.skip:0}));function re(i,r){return yt(i)===yt(r)}function hr(i,r){const o=st(pt(i.slice())),p=st(pt(r.slice()));if(o.length<1)return[p,[]];const l=[];let f=!1;for(;p.length>0;){const c=p[0];let a=o.shift();for(;a&&qe(a,c);)l.push(a),a=o.shift();if(a?f||(re(a,c)?(p.shift(),l.push(a)):(o.unshift(a),f=!0)):f=!0,f){let h=p.shift();for(;h;)l.push(h),h=p.shift()}}if(!f){let c=o.shift();for(;c;)l.push(c),c=o.shift()}return[st(l),o]}function qe(i,r){return i.index<r.index||i.index===r.index&&i.id===r.id&&i.skip<r.skip}function He(i,r){const o=[],p=[],l=[],f=Math.max(i.length,r.length);let c=!1;for(let a=0;a<f;a++){const h=i[a],g=r[a];h&&g?!c&&re(h,g)?o.push(h):(c=!0,p.push(h),l.push(g)):h?p.push(h):g&&l.push(g)}return[o,p,l]}function mr(i,r,o){const[p,l,f]=He(st(i),st(r)),c=Mt(p),a=1+Math.max(c,Mt(l),Mt(f)),h=We(f,l),g=o({index:a,skip:a-(c+1)},l,h);return p.concat(g)}function Mt(i){const r=i[i.length-1];return r?r.index:-1}function Je(i){var p,l,f;if(i.length<1)return-1;const r=st(i);let o=(((p=r[r.length-1])==null?void 0:p.skip)||0)+1;return r.length>1&&(o+=((l=r[r.length-2])==null?void 0:l.skip)||0),(((f=r[r.length-1])==null?void 0:f.index)||-1)<o?-1:o}const dr=i=>ie(st(pt(i))),xr=i=>i.reduce((o,p)=>{var l;return o[p.scope]||(o[p.scope]=[]),(l=o[p.scope])==null||l.push(p),o},{}),gr=(i,r)=>{var h;const o={integrityIssues:[],validOperations:[],invalidOperations:[],duplicatedOperations:[]},p=pt(i),l=pt(r),f=ie([...p,...l]),a=(h=[...f.filter(g=>g.category==="MISSING_INDEX")].sort((g,y)=>y.operation.index-g.operation.index).pop())==null?void 0:h.operation;for(const g of l){if(a&&g.index>=a.index){o.invalidOperations.push(g);continue}if(f.some(b=>b.operation.index===g.index&&b.operation.skip===g.skip&&b.category==="DUPLICATED_INDEX")){o.duplicatedOperations.push(g);continue}o.validOperations.push(g)}return o.integrityIssues.push(...f),o};function yr(i,r){return i.filter(o=>!r.some(p=>o.type==="NOOP"&&o.skip===0&&o.index===p.index||o.index===p.index&&o.skip===p.skip&&o.scope===p.scope&&o.hash===p.hash&&o.type===p.type))}function Ve(i,r){const[o]=pt(i).slice(-1),p=(o==null?void 0:o.index)??-1,l=p+1,f={...r,index:r.index??l};if(f.index<p)throw new Error(`The skip header operation index must be greater than or equal to ${p}`);return(st(pt([...i,f]))||[]).slice(0,-1)}function Ht(i){return{...Object.entries(i).reduce((o,p)=>{const[l,f]=p;return{...o,[l]:st(pt(f))}},{})}}function We(i,r){return i.filter(o=>o.id?!r.some(p=>p.id===o.id):!0)}const wr=Object.freeze(Object.defineProperty({__proto__:null,IntegrityIssueSubType:Pe,IntegrityIssueType:Le,addUndo:lr,attachBranch:hr,checkCleanedOperationsIntegrity:ie,checkOperationsIntegrity:dr,filterDuplicatedOperations:We,garbageCollect:st,garbageCollectDocumentOperations:Ht,groupOperationsByScope:xr,merge:mr,nextSkipNumber:Je,operationsAreEqual:re,precedes:qe,prepareOperations:gr,removeExistingOperations:yr,reshuffleByTimestamp:ur,reshuffleByTimestampAndIndex:fr,skipHeaderOperations:Ve,sortOperations:pt,split:He},Symbol.toStringTag,{value:"Module"}));function Er(i,r){let o;return"index"in r?o={...r}:o=i.operations[r.scope].at(-1),((o==null?void 0:o.index)??-1)+1}function ne(i,r){return{...i,revision:{...i.revision,[r.scope]:Er(i,r)},lastModified:new Date().toISOString()}}function br(i,r,o=0){if([St,vt,Dt].includes(r.type))return i;const{scope:p}=r,l=i.operations[p].slice();let f;const c=l.at(-1);let a=((c==null?void 0:c.index)??-1)+1;if("index"in r){if(r.index-o>a)throw new Error(`Missing operations: expected ${a} with skip 0 or equivalent, got index ${r.index} with skip ${o}`);a=r.index,f=r.id}else f=gi();return l.push({...r,id:f,index:a,timestamp:new Date().toISOString(),hash:"",scope:p,skip:o,error:void 0}),{...i,operations:{...i.operations,[p]:l}}}function Xe(i,r,o=0){let p=br(i,r,o);return p=ne(p,r),p}function Sr(i,r,o){switch(we().parse(r),r.type){case Oe:return yi(i,r.input);case Dt:return bi(i,r,o);case Fe:return Si(i,r.input.state);default:return i}}function vr(i,r,o){switch(r.type){case St:return wi(i,r,o);case vt:return Ei(i,r,o);default:return{document:i,action:r,skip:o}}}function _r(i,r,o,p,l=!1,f=se){const c=r.scope,a=i.operations[c].at(-1);if(!a)return i;const h=Ht({...i.operations,[c]:Ve(i.operations[c],a)});let g;const y=h[c].at(-1);if(l&&(y!=null&&y.resultingState))g=f(y.resultingState);else{const{state:b}=jt(i.initialState,h,o,void 0,void 0,void 0,void 0,{reuseHash:!0,reuseOperationResultingState:l,operationResultingStateParser:f});g=b[c]}return{...i,state:{...i.state,[c]:g},operations:Ht({...i.operations})}}function oe(i,r,o,p,l={}){const{skip:f,ignoreSkipOperations:c=!1,reuseHash:a=!1,reuseOperationResultingState:h=!1,operationResultingStateParser:g}=l,y={...r},b=f||0;let O={...i};const j=!c&&(b>0||"index"in y&&y.skip>0);return Jt(y)&&(O=Sr(O,y,o)),O=Xe(O,y,b),j&&(O=_r(O,y,o,b,h,g)),O=ot.produce(O,U=>{try{const q=o(U.state,y,p);if(q)return ot.castDraft({...O,state:q})}catch(q){const Y=O.operations[y.scope].length-1;U.operations[y.scope][Y].error=q.message,U.operations[y.scope][Y].skip=0,j&&(U.state=ot.castDraft({...i.state}),U.operations=ot.castDraft({...i.operations,[y.scope]:[...i.operations[y.scope],{...U.operations[y.scope][Y]}]}))}}),ot.produce(O,U=>{if([St,vt,Dt].includes(y.type))return U;const q=y.scope||"global",Y=a&&Object.prototype.hasOwnProperty.call(y,"hash")?y.hash:Ct(U,q),w=U.operations[q].at(-1);w&&(w.hash=Y,h&&(w.resultingState=U.state[q]),!Jt(y)&&y.attachments&&y.attachments.forEach(E=>{const{hash:S,...z}=E;U.attachments[S]={...z}}))})}function Ar(i){return i.type===vi&&i.skip!==void 0&&i.skip>0&&i.hash!==void 0}function Or(i){return[St,vt].includes(i.type)}function Jt(i){return[Oe,St,vt,Dt,Fe].includes(i.type)}function ht(i,r,o,p,l="global"){if(!i)throw new Error("Empty action type");if(typeof i!="string")throw new Error(`Invalid action type: ${JSON.stringify(i)}`);const f={type:i,input:r,scope:l};o&&(f.attachments=o);try{p==null||p().parse(f.input)}catch(c){throw new Error(`Invalid action input: ${c}`)}return f}function Ke(i,r=oe){return(o,p,l,f)=>r(o,p,i,l,f)}const Ge=(i,r)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...i,state:(r==null?void 0:r(i==null?void 0:i.state))??(i==null?void 0:i.state)??{global:{},local:{}}}),Ze=(i,r)=>{const o=Ge(i,r);return{...o,initialState:o,operations:{global:[],local:[]},clipboard:[]}},Ct=(i,r="global")=>Ut(yt(i.state[r]||"")),Fr=(i,r=1e3)=>{const o=Math.random()*r;return Ut(`${(i??new Date).toISOString()}${o}`)};function Et(i){return ot.castImmutable(ot.freeze(i,!0))}function Br(i,r){const o=[...i];let p=r||0,l=o.length>0?o[o.length-1].index:0;const f=[];for(const c of o.reverse()){if(p>0){const g=l-c.index;p-=g}if(p<0)throw new Error("Invalid operation index, missing operations");const a={ignore:p>0,operation:c},h=c.skip>0?c.skip+1:0;if(h>0&&h>p){const g=h-p;p=p+g}l=c.index,f.push(a)}return f.reverse()}function Ir(i,r,o){const p=i.slice().sort((a,h)=>a.skip-h.skip).sort((a,h)=>a.index-h.index);let l=o,f=0,c=r;for(const a of p.reverse()){const h=c-a.index;if(l=l-h,l>-1)f++,c=a.index;else break}return f}function jr(i){return Object.values(i).flatMap(r=>r).sort((r,o)=>new Date(r.timestamp).getTime()-new Date(o.timestamp).getTime())}function Dr(i){return Object.values(i).flatMap(r=>r).sort((r,o)=>new Date(r.operation.timestamp).getTime()-new Date(o.operation.timestamp).getTime())}function jt(i,r,o,p,l,f=oe,c={},a){const h=Ke(o,f);return ae(i,r,h,p,l,c,a)}function ae(i,r,o,p,l,f={},c){const{checkHashes:a=!0,reuseOperationResultingState:h,operationResultingStateParser:g=se}=c||{};let y=i;const b=[],O={global:[],local:[]};if(h)for(const[w,E]of Object.entries(r)){const S=E.findLastIndex(J=>!!J.resultingState);if(S<0){b.push(...E);continue}const z=E[S];try{const J=g(z.resultingState);y={...y,state:{...y.state,[w]:J}},O[w].push(...E.slice(0,S+1)),b.push(...E.slice(S+1))}catch{b.push(...E)}}else b.push(...Object.values(r).flat());const j=Ze(y);j.initialState=i,j.operations=O;let U=j;if(b.length)U=b.reduce((w,E)=>o(w,E,p,{skip:E.skip,ignoreSkipOperations:!0,reuseHash:!a}),j);else for(const w of Object.values(O)){const E=w.at(-1);E&&(U=ne(U,E))}if(!a)for(const w of Object.keys(U.state))for(let E=b.length-1;E>=0;E--){const S=b[E];if(S.scope===w){if(S.hash!==Ct(U,w))throw new Error(`Hash mismatch for scope ${w}`);break}}const q=Object.keys(U.operations).reduce((w,E)=>{const S=E;return{...w,[S]:[...U.operations[S].map((z,J)=>{var V;return{...z,timestamp:((V=r[S][J])==null?void 0:V.timestamp)??z.timestamp}})]}},{global:[],local:[]}),Y=Object.values(q).reduce((w,E)=>{const S=E[E.length-1];return(S==null?void 0:S.timestamp)>w&&(w=S.timestamp),w},i.lastModified);return{...U,operations:q,lastModified:Y}}function Tr(i,r){return yt(i)===yt(r)}function se(i){const r=typeof i;if(r==="string")return JSON.parse(i);if(r==="object")return i;throw new Error(`Providing resulting state is of type: ${r}`)}const Ye=i=>ht("SET_NAME",i,void 0,Kt,void 0),Qe=(i=1,r="global")=>ht("UNDO",i,void 0,Gt,r),ti=(i=1,r="global")=>ht("REDO",i,void 0,Xt,r),ei=(i,r,o="global")=>ht("PRUNE",{start:i,end:r},void 0,Wt,o),pe=(i,r)=>ht("LOAD_STATE",{state:i,operations:r},void 0,Vt),ii=(i="global")=>ht("NOOP",{},void 0,void 0,i),kr=Object.freeze(Object.defineProperty({__proto__:null,loadState:pe,noop:ii,prune:ei,redo:ti,setName:Ye,undo:Qe},Symbol.toStringTag,{value:"Module"}));class Ur{constructor(r,o,p){Bt(this,"_document");Bt(this,"_reducer");Bt(this,"_signalDispatch");this._reducer=r,this._document=o,this._signalDispatch=p}dispatch(r,o){return this._document=this._reducer(this._document,r,this._signalDispatch,o),this}saveToFile(r,o,p){return ze(this._document,r,o,p)}async loadFromFile(r){this._document=await qt(r,this._reducer)}static async stateFromFile(r,o){return await qt(r,o)}get state(){return Et(this._document.state)}get operations(){return Et(this._document.operations)}get name(){return this._document.name}get documentType(){return this._document.documentType}get created(){return this._document.created}get lastModified(){return this._document.lastModified}get revision(){return this._document.revision.global}getRevision(r){return this._document.revision[r]}get initialState(){return Et(this._document.initialState)}toDocument(){return Et(this._document)}getAttachment(r){return this._document.attachments[r]}setName(r){return this.dispatch(Ye(r)),this}undo(r){return this.dispatch(Qe(r)),this}redo(r){return this.dispatch(ti(r)),this}prune(r,o){return this.dispatch(ei(r,o)),this}loadState(r,o){return this.dispatch(pe(r,o)),this}}function Cr(i,r){r.forEach(o=>{Object.getOwnPropertyNames(o.prototype).forEach(p=>{Object.defineProperty(i.prototype,p,Object.getOwnPropertyDescriptor(o.prototype,p)||Object.create(null))})})}exports.BaseActions=kr;exports.BaseDocument=Ur;exports.applyMixins=Cr;exports.baseReducer=oe;exports.calculateSkipsLeft=Ir;exports.createAction=ht;exports.createDocument=Ze;exports.createExtendedState=Ge;exports.createReducer=Ke;exports.createZip=ee;exports.documentHelpers=wr;exports.getLocalFile=cr;exports.getRemoteFile=pr;exports.hashDocument=Ct;exports.hashKey=Fr;exports.isBaseAction=Jt;exports.isNoopOperation=Ar;exports.isSameDocument=Tr;exports.isUndoRedo=Or;exports.loadFromFile=qt;exports.loadFromInput=Me;exports.mapSkippedOperations=Br;exports.parseResultingState=se;exports.processUndoRedo=vr;exports.readOnly=Et;exports.replayDocument=ae;exports.replayOperations=jt;exports.saveToFile=ze;exports.saveToFileHandle=ar;exports.sortMappedOperations=Dr;exports.sortOperations=jr;exports.updateDocument=Xe;exports.updateHeader=ne;exports.validateOperations=Ne;exports.zod=ui;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { j as e, f as a, b as s, a as t, c as o, k as r, m as n, n as i, o as p, p as c, q as l, i as d, r as u, t as m, u as O, l as y, e as D, v as S, w as b, x as g, y as F, z as _, s as f, d as v, A as R, C as h, D as j, B as x, h as z, g as A, E as B, F as H, G as M, H as T, I as k } from "./object-DenwvByi.js";
|
|
2
|
-
const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
|
-
__proto__: null,
|
|
4
|
-
calculateSkipsLeft: e,
|
|
5
|
-
createAction: a,
|
|
6
|
-
createDocument: s,
|
|
7
|
-
createExtendedState: t,
|
|
8
|
-
createReducer: o,
|
|
9
|
-
createZip: r,
|
|
10
|
-
documentHelpers: n,
|
|
11
|
-
getLocalFile: i,
|
|
12
|
-
getRemoteFile: p,
|
|
13
|
-
hashDocument: c,
|
|
14
|
-
hashKey: l,
|
|
15
|
-
isBaseAction: d,
|
|
16
|
-
isNoopOperation: u,
|
|
17
|
-
isSameDocument: m,
|
|
18
|
-
isUndoRedo: O,
|
|
19
|
-
loadFromFile: y,
|
|
20
|
-
loadFromInput: D,
|
|
21
|
-
mapSkippedOperations: S,
|
|
22
|
-
parseResultingState: b,
|
|
23
|
-
readOnly: g,
|
|
24
|
-
replayDocument: F,
|
|
25
|
-
replayOperations: _,
|
|
26
|
-
saveToFile: f,
|
|
27
|
-
saveToFileHandle: v,
|
|
28
|
-
sortMappedOperations: R,
|
|
29
|
-
sortOperations: h,
|
|
30
|
-
validateOperations: j
|
|
31
|
-
}, Symbol.toStringTag, { value: "Module" })), L = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
32
|
-
__proto__: null,
|
|
33
|
-
BaseDocument: x,
|
|
34
|
-
actions: z,
|
|
35
|
-
applyMixins: A,
|
|
36
|
-
baseReducer: B,
|
|
37
|
-
processUndoRedo: H,
|
|
38
|
-
updateDocument: M,
|
|
39
|
-
updateHeader: T,
|
|
40
|
-
utils: E,
|
|
41
|
-
z: k
|
|
42
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
43
|
-
export {
|
|
44
|
-
L as D,
|
|
45
|
-
E as i
|
|
46
|
-
};
|