@powerhousedao/connect 5.1.0-dev.40 → 5.1.0-dev.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/assets/AddDriveModal-BaSbhuJK.js +1 -0
  2. package/dist/assets/{ClearStorageModal-i8ZGETjQ.js → ClearStorageModal-DNS9RTC0.js} +1 -1
  3. package/dist/assets/{CookiesPolicyModal-BwjmJbrm.js → CookiesPolicyModal-DlLrF2hX.js} +1 -1
  4. package/dist/assets/CreateDocumentModal-CRTfHWzv.js +1 -0
  5. package/dist/assets/{DebugSettingsModal-D1gb8edA.js → DebugSettingsModal-Eq7TqMQT.js} +1 -1
  6. package/dist/assets/{DeleteDriveModal-C-dfGwTm.js → DeleteDriveModal-KNKA7qY6.js} +1 -1
  7. package/dist/assets/DeleteItemModal-CEqXRMrA.js +1 -0
  8. package/dist/assets/DisclaimerModal-bJnIFjtk.js +1 -0
  9. package/dist/assets/DriveSettingsModal-CP1lHUhL.js +1 -0
  10. package/dist/assets/{ExportDocumentWithErrorsModal-BSgb0yls.js → ExportDocumentWithErrorsModal-rOR8wz5b.js} +1 -1
  11. package/dist/assets/{SettingsModal-fw_kNd_b.js → SettingsModal-D5RCstxT.js} +1 -1
  12. package/dist/assets/UpgradeDriveModal-fu3JsSOD.js +1 -0
  13. package/dist/assets/{design_system-DL9J1XTp.js → design_system-l3R1weVu.js} +1 -1
  14. package/dist/assets/design_system_connect-KS4QoPWt.js +47 -0
  15. package/dist/assets/{design_system_ui-DtMSMFD-.js → design_system_ui-IKiIoZe3.js} +1 -1
  16. package/dist/assets/document_drive-DxP3aSj9.js +316 -0
  17. package/dist/assets/{document_engineering-H5WHF82B.js → document_engineering-DRCCh3ab.js} +1 -1
  18. package/dist/assets/{document_model-DXYoB_YO.js → document_model-C2IPS8BP.js} +2 -2
  19. package/dist/assets/{document_model_editor-Ib_f5qZi.js → document_model_editor-DPD0-qP4.js} +4 -4
  20. package/dist/assets/{drive_explorer-BKMfWnQL.js → drive_explorer-CTA4POOd.js} +2 -2
  21. package/dist/assets/{graphql-editor-xhOcRrtr.js → graphql-editor-C2lSOeJ_.js} +1 -1
  22. package/dist/assets/{hooks-CNcTloQw.js → hooks-bE2oXawu.js} +1 -1
  23. package/dist/assets/index-BmesSDbk.js +28 -0
  24. package/dist/assets/index-D2e9nPBJ.js +18 -0
  25. package/dist/assets/index-DGEkQuau.css +1 -0
  26. package/dist/assets/{json-editor-CfsREnfc.js → json-editor-Bf1e_E6j.js} +1 -1
  27. package/dist/assets/{nodefs-D5eWehIq.js → nodefs-D4kpsXx1.js} +1 -1
  28. package/dist/assets/{opfs-ahp-BhtgbgIQ.js → opfs-ahp-dpwlpnDG.js} +1 -1
  29. package/dist/assets/{reactor_browser-Bo-Pj3Xo.js → reactor_browser-JiebDbow.js} +7 -7
  30. package/dist/assets/{state-schemas-CVg0B4xO.js → state-schemas-C8gHy8E0.js} +2 -2
  31. package/dist/index.html +10 -10
  32. package/lib/package.copy.json +1 -1
  33. package/lib/src/components/document-editor-container.d.ts +1 -1
  34. package/lib/src/components/document-editor-container.d.ts.map +1 -1
  35. package/lib/src/components/document-editor-container.js +19 -16
  36. package/lib/src/components/document-editor-container.js.map +1 -1
  37. package/lib/src/components/drive-editor-container.js +4 -4
  38. package/lib/src/components/drive-editor-container.js.map +1 -1
  39. package/lib/src/components/modal/modals/InspectorModal/InspectorModal.d.ts.map +1 -1
  40. package/lib/src/components/modal/modals/InspectorModal/InspectorModal.js +3 -1
  41. package/lib/src/components/modal/modals/InspectorModal/InspectorModal.js.map +1 -1
  42. package/lib/src/components/modal/modals/InspectorModal/useDbExplorer.d.ts +3 -4
  43. package/lib/src/components/modal/modals/InspectorModal/useDbExplorer.d.ts.map +1 -1
  44. package/lib/src/components/modal/modals/InspectorModal/useDbExplorer.js +110 -8
  45. package/lib/src/components/modal/modals/InspectorModal/useDbExplorer.js.map +1 -1
  46. package/lib/src/pages/content.d.ts.map +1 -1
  47. package/lib/src/pages/content.js +5 -5
  48. package/lib/src/pages/content.js.map +1 -1
  49. package/lib/src/store/reactor.d.ts.map +1 -1
  50. package/lib/src/store/reactor.js.map +1 -1
  51. package/lib/src/utils/reactor.d.ts +1 -1
  52. package/lib/src/utils/reactor.d.ts.map +1 -1
  53. package/lib/src/utils/reactor.js.map +1 -1
  54. package/lib/style.css +15 -0
  55. package/lib/tsconfig.tsbuildinfo +1 -1
  56. package/package.copy.json +1 -1
  57. package/package.json +10 -10
  58. package/dist/assets/AddDriveModal-B0BJbb7V.js +0 -1
  59. package/dist/assets/CreateDocumentModal-DPVzin5z.js +0 -1
  60. package/dist/assets/DeleteItemModal-Btvqqu2u.js +0 -1
  61. package/dist/assets/DisclaimerModal-Cpyn6VQS.js +0 -1
  62. package/dist/assets/DriveSettingsModal-D1XL765u.js +0 -1
  63. package/dist/assets/UpgradeDriveModal-Cq74G4UV.js +0 -1
  64. package/dist/assets/design_system_connect-CISKydOj.js +0 -45
  65. package/dist/assets/document_drive-BjCTBivJ.js +0 -316
  66. package/dist/assets/index-4Fn7VRBH.js +0 -18
  67. package/dist/assets/index-6ooL5A0g.js +0 -25
  68. package/dist/assets/index-SqSJYSgG.css +0 -1
@@ -1 +1 @@
1
- import"./sentry_react-cODD7zWc.js";import"./document_model_editor-Ib_f5qZi.js";import"./react-DQSxOgtG.js";
1
+ import"./sentry_react-cODD7zWc.js";import"./document_model_editor-DPD0-qP4.js";import"./react-DQSxOgtG.js";
@@ -17,7 +17,7 @@ ${J}`,z.pop(),`[${ie}]`}let A=Object.keys(N);const R=A.length;if(R===0)return"{}
17
17
  ${B}`;let V="",W="",ae=Math.min(R,T);u(N)&&(V+=d(N,Y,T),A=A.slice(N.length),ae-=N.length,W=Y),D&&(A=a(A,M)),z.push(N);for(let ie=0;ie<ae;ie++){const re=A[ie],se=I(re,N[re],z,q,B);se!==void 0&&(V+=`${W}${o(re)}: ${se}`,W=Y)}if(R>T){const ie=R-T;V+=`${W}"...": "${E(ie)} not stringified"`,W=Y}return W!==""&&(V=`
18
18
  ${B}${V}
19
19
  ${J}`),z.pop(),`{${V}}`}case"number":return isFinite(N)?String(N):S?S(N):"null";case"boolean":return N===!0?"true":"false";case"undefined":return;case"bigint":if(O)return String(N);default:return S?S(N):void 0}}function j(U,N,z){switch(typeof N){case"string":return o(N);case"object":{if(N===null)return"null";if(typeof N.toJSON=="function"){if(N=N.toJSON(U),typeof N!="object")return j(U,N,z);if(N===null)return"null"}if(z.indexOf(N)!==-1)return v;let q="";const B=N.length!==void 0;if(B&&Array.isArray(N)){if(N.length===0)return"[]";if(F<z.length+1)return'"[Array]"';z.push(N);const V=Math.min(N.length,T);let W=0;for(;W<V-1;W++){const ie=j(String(W),N[W],z);q+=ie!==void 0?ie:"null",q+=","}const ae=j(String(W),N[W],z);if(q+=ae!==void 0?ae:"null",N.length-1>T){const ie=N.length-T-1;q+=`,"... ${E(ie)} not stringified"`}return z.pop(),`[${q}]`}let J=Object.keys(N);const A=J.length;if(A===0)return"{}";if(F<z.length+1)return'"[Object]"';let R="",Y=Math.min(A,T);B&&u(N)&&(q+=d(N,",",T),J=J.slice(N.length),Y-=N.length,R=","),D&&(J=a(J,M)),z.push(N);for(let V=0;V<Y;V++){const W=J[V],ae=j(W,N[W],z);ae!==void 0&&(q+=`${R}${o(W)}:${ae}`,R=",")}if(A>T){const V=A-T;q+=`${R}"...":"${E(V)} not stringified"`}return z.pop(),`{${q}}`}case"number":return isFinite(N)?String(N):S?S(N):"null";case"boolean":return N===!0?"true":"false";case"undefined":return;case"bigint":if(O)return String(N);default:return S?S(N):void 0}}function c(U,N,z){if(arguments.length>1){let q="";if(typeof z=="number"?q=" ".repeat(Math.min(z,10)):typeof z=="string"&&(q=z.slice(0,10)),N!=null){if(typeof N=="function")return G("",{"":U},[],N,q,"");if(Array.isArray(N))return te("",U,[],f(N),q,"")}if(q.length!==0)return I("",U,[],q,"")}return j("",U,[])}return c}})(st,st.exports)),st.exports}var Cr=Dr();const _t=ln(Cr);_t.configure;const Vt=_t,Mr=[1518500249,1859775393,-1894007588,-899497514];function Nr(e){return new zr}class zr{constructor(){this.A=1732584193,this.B=-271733879,this.C=-1732584194,this.D=271733878,this.E=-1009589776,this._size=0,this._sp=0,(!at||Ge>=8e3)&&(at=new ArrayBuffer(8e3),Ge=0),this._byte=new Uint8Array(at,Ge,80),this._word=new Int32Array(at,Ge,20),Ge+=80}update(t){if(typeof t=="string")return this._utf8(t);if(t==null)throw new TypeError("Invalid type: "+typeof t);const n=t.byteOffset,r=t.byteLength;let i=r/64|0,o=0;if(i&&!(n&3)&&!(this._size%64)){const s=new Int32Array(t.buffer,n,i*16);for(;i--;)this._int32(s,o>>2),o+=64;this._size+=o}if(t.BYTES_PER_ELEMENT!==1&&t.buffer){const s=new Uint8Array(t.buffer,n+o,r-o);return this._uint8(s)}return o===r?this:this._uint8(t,o)}_uint8(t,n){const{_byte:r,_word:i}=this,o=t.length;for(n=n|0;n<o;){const a=this._size%64;let s=a;for(;n<o&&s<64;)r[s++]=t[n++];s>=64&&this._int32(i),this._size+=s-a}return this}_utf8(t){const{_byte:n,_word:r}=this,i=t.length;let o=this._sp;for(let a=0;a<i;){const s=this._size%64;let u=s;for(;a<i&&u<64;){let d=t.charCodeAt(a++)|0;d<128?n[u++]=d:d<2048?(n[u++]=192|d>>>6,n[u++]=128|d&63):d<55296||d>57343?(n[u++]=224|d>>>12,n[u++]=128|d>>>6&63,n[u++]=128|d&63):o?(d=((o&1023)<<10)+(d&1023)+65536,n[u++]=240|d>>>18,n[u++]=128|d>>>12&63,n[u++]=128|d>>>6&63,n[u++]=128|d&63,o=0):o=d}u>=64&&(this._int32(r),r[0]=r[16]),this._size+=u-s}return this._sp=o,this}_int32(t,n){let{A:r,B:i,C:o,D:a,E:s}=this,u=0;for(n=n|0;u<16;)Ne[u++]=Ce(t[n++]);for(u=16;u<80;u++)Ne[u]=Ur(Ne[u-3]^Ne[u-8]^Ne[u-14]^Ne[u-16]);for(u=0;u<80;u++){const d=u/20|0,_=jr(r)+Fr(d,i,o,a)+s+Ne[u]+Mr[d]|0;s=a,a=o,o=Br(i),i=r,r=_}this.A=r+this.A|0,this.B=i+this.B|0,this.C=o+this.C|0,this.D=a+this.D|0,this.E=s+this.E|0}digest(t){const{_byte:n,_word:r}=this;let i=this._size%64|0;for(n[i++]=128;i&3;)n[i++]=0;if(i>>=2,i>14){for(;i<16;)r[i++]=0;i=0,this._int32(r)}for(;i<16;)r[i++]=0;const o=this._size*8,a=(o&4294967295)>>>0,s=(o-a)/4294967296;return s&&(r[14]=Ce(s)),a&&(r[15]=Ce(a)),this._int32(r),t==="hex"?this._hex():this._bin()}_hex(){const{A:t,B:n,C:r,D:i,E:o}=this;return Ve(t)+Ve(n)+Ve(r)+Ve(i)+Ve(o)}_bin(){const{A:t,B:n,C:r,D:i,E:o,_byte:a,_word:s}=this;return s[0]=Ce(t),s[1]=Ce(n),s[2]=Ce(r),s[3]=Ce(i),s[4]=Ce(o),a.slice(0,20)}}const Ne=new Int32Array(80);let at,Ge=0;const Ve=e=>(e+4294967296).toString(16).substr(-8),Pr=(e=>e<<24&4278190080|e<<8&16711680|e>>8&65280|e>>24&255),Lr=(e=>e),Ce=$r()?Lr:Pr,Ur=e=>e<<1|e>>>31,jr=e=>e<<5|e>>>27,Br=e=>e<<30|e>>>2;function Fr(e,t,n,r){return e===0?t&n|~t&r:e===2?t&n|t&r|n&r:t^n^r}function $r(){return new Uint8Array(new Uint16Array([65279]).buffer)[0]===254}const Dt=(e,t="sha1",n="base64",r)=>{if(!["sha1"].includes(t))throw new Error(`Hashing algorithm not supported: "${t}". Available: sha1`);if(!["base64","hex"].includes(n))throw new Error(`Hash encoding not supported: "${n}". Available: base64, hex`);const i=Zr(e,t);return n==="hex"?Hr(i):Wr(i)};function Wr(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Hr(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}function Zr(e,t="sha1"){if(!["sha1"].includes(t))throw new Error("Hashing algorithm not supported: Available: sha1");return Nr().update(e).digest()}function Gr(e){return(new Date(e).getTime()/1e3).toFixed(0)}function Vr({documentId:e,signer:t,action:n,previousStateHash:r}){const{scope:i,type:o}=n;return[Gr(new Date),t.app.key,Dt([e,i,o,_t(n.input)].join("")),r]}const Xr=new TextEncoder;function Kr(e){const t=e.join(""),n=`Signed Operation:
20
- `+t.length.toString();return Xr.encode(n+t)}function Jr(e){const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return Array.prototype.map.call(t,n=>("00"+n.toString(16)).slice(-2)).join("")}class un extends Error{data;constructor(t){super(),this.name="InvalidActionInputError",this.data=t,this.message=this.message||`Invalid action input: ${JSON.stringify(t,null,2)}`}}class qr extends un{issues;constructor(t){super(t),this.issues=t,this.name="InvalidActionInputZodError"}}class Yr extends Error{_scope;_document;_operation;constructor(t,n,r){super(),this.name="HashMismatchError",this._document=n,this._scope=t,this._operation=r,this.message=JSON.stringify({error:`Hash mismatch on document ${n.header.id}, scope ${t}, index ${r.index}`,document:n,operation:r},null,1)}get document(){return this._document}get scope(){return this._scope}get operation(){return this._operation}}const Qr=e=>e!=null;Rr().refine(e=>Qr(e));const ei=Qe(["LOAD_STATE"]),ti=Qe(["PRUNE"]),ni=Qe(["REDO"]),ri=Qe(["SET_NAME"]),ii=Qe(["UNDO"]);function Le(){return L()}function oi(){return Ar([si(),li(),ui(),ci(),pi()])}function si(){return ee({id:L(),timestampUtcMs:L(),input:Tt(()=>cn()),type:ei,scope:Le()})}function cn(){return ee({operations:$e(),state:Tt(()=>ai())})}function ai(){return ee({data:an().nullish(),name:L()})}function li(){return ee({id:L(),timestampUtcMs:L(),input:Tt(()=>pn()),type:ti,scope:Le()})}function pn(){return ee({end:$e().nullish(),start:$e().nullish()})}const dn=$e;function ui(){return ee({id:L(),timestampUtcMs:L().datetime(),input:dn(),type:ni,scope:Le()})}const fn=L;function ci(){return ee({id:L(),timestampUtcMs:L().datetime(),input:fn(),type:ri,scope:be("global")})}const hn=$e;function pi(){return ee({id:L(),timestampUtcMs:L().datetime(),input:hn(),type:ii,scope:Le()})}function mn(e){return globalThis.crypto.randomUUID()}function gn(e,t,n,r){const i=`${e}:${t}:${n}:${r}`;return Dt(i,"sha1","hex").slice(0,32)}const di=(e=1,t="global")=>oe("UNDO",e,void 0,hn,t),fi=(e=1,t="global")=>oe("REDO",e,void 0,dn,t),hi=(e,t,n="global")=>oe("PRUNE",{start:e,end:t},void 0,pn,n),_n=(e,t)=>oe("LOAD_STATE",{state:e,operations:t},void 0,cn),bn=(e="global")=>oe("NOOP",void 0,void 0,void 0,e);function oe(e,t,n,r,i="global"){if(!e)throw new Error("Empty action type");if(typeof e!="string")throw new Error(`Invalid action type: ${JSON.stringify(e)}`);const o={id:mn(),timestampUtcMs:new Date().toISOString(),type:e,input:t,scope:i};try{r?.().parse(o.input)}catch(a){throw a instanceof kr?new qr(a.issues):new un(a)}return o}const mi=e=>({id:e.id,timestampUtcMs:e.timestampUtcMs,type:e.type,input:e.input,scope:e.scope,context:e.context,attachments:e.attachments}),gi=(e,t,n,r)=>({...e,action:e,id:gn(r.documentId,r.scope,r.branch,e.id),timestampUtcMs:new Date().toISOString(),hash:"",error:void 0,index:t,skip:n}),_i=(e,t,n,r)=>{const i=gn(r.documentId,r.scope,r.branch,e.action.id);if(e.id&&e.id!==i)throw new Error(`Operation id mismatch: ${e.id} !== ${i}`);return{...e,hash:"",error:void 0,index:t,skip:n,id:i}},bi=(e,t)=>{if(!e.action)throw new Error("Operation has no action");return{...e,action:{...e.action,context:t}}},yi=(e,t,n=[])=>({user:e,app:t,signatures:n});async function Ei(e,t){const n=Vr(e),r=Kr(n),i=await t(r);return[...n,`0x${Jr(i)}`]}async function ua(e,t,n,r,i){const a=t(n,e,void 0,{reuseOperationResultingState:!0}).operations[e.scope];if(!a)throw new Error(`No operations found for scope: ${e.scope}`);const s=a.at(-1);if(!s)throw new Error("Action was not applied");const u=a.at(-2)?.hash??"",d=await Ei({documentId:n.header.id,signer:r,action:e,previousStateHash:u},i),_={signer:yi(r.user,r.app,[...r.signatures,d])};return bi(s,_)}const Si=e=>`${e.documentType}:${e.createdAtUtcIso}:${e.nonce}`;function wi(e){let t;return{async publicKey(){return e},async sign(n){throw new Error("verification-only signer cannot sign data")},async signAction(n,r){throw new Error("verification-only signer cannot sign actions")},async verify(n,r){t||(t=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:"P-256"},!0,["verify"]));let i;try{i=await crypto.subtle.verify({name:"ECDSA",hash:"SHA-256"},t,new Uint8Array(r),new Uint8Array(n))}catch{throw new Error("invalid signature")}if(!i)throw new Error("invalid signature")}}}const Oi=e=>wi(e.sig.publicKey),xi=async(e,t,n)=>{const r=Si(e),o=new TextEncoder().encode(r),a=Uint8Array.from(atob(t),s=>s.charCodeAt(0));await n.verify(o,a)},ca=async e=>{const t=Oi(e);return xi({documentType:e.documentType,createdAtUtcIso:e.createdAtUtcIso,nonce:e.sig.nonce},e.id,t)},vi=(e=mn(),t="")=>({id:e,sig:{publicKey:{},nonce:""},documentType:t,createdAtUtcIso:new Date().toISOString(),slug:"",name:"",branch:"main",revision:{document:0},lastModifiedAtUtcIso:new Date().toISOString(),meta:{}});function Ii(e){return["UNDO","REDO"].includes(e.type)}function Ai(e){return e.type==="UNDO"}function yn(e){return["SET_NAME","UNDO","REDO","PRUNE","LOAD_STATE"].includes(e.type)}function Ri(e,t){const n=e(t);return{header:vi(),state:n,initialState:n,operations:{global:[],local:[]},clipboard:[]}}function Ct(e,t="global"){const n=_t(e.state[t]||"");return Dt(n)}const ki=e=>e;function En(e,t,n,r,i,o={},a){const{checkHashes:s=!0,reuseOperationResultingState:u,operationResultingStateParser:d=Mt}=a||{};let _=e;const g=[],x=new Set([...Object.keys(t),"global","local"]),p={};for(const v of x)p[v]=[];if(u)for(const[v,O]of Object.entries(t)){if(!O)continue;const D=O.findLastIndex(F=>!!F.resultingState);if(D<0){g.push(...O);continue}const M=O[D];if(!(!M||!M.resultingState))try{const F=d(M.resultingState);_={..._,[v]:F};const T=p[v];T&&T.push(...O.slice(0,D+1)),g.push(...O.slice(D+1))}catch{g.push(...O)}}else g.push(...Object.values(t).flatMap(v=>v||[]));const E={header:r,state:ki(_),initialState:e,operations:p,clipboard:[]};let f=E;if(g.length)f=g.reduce((v,O)=>n(v,O.action,i,{ignoreSkipOperations:!0,checkHashes:s,replayOptions:{operation:O}}),E);else for(const v of Object.values(p)){if(!v)continue;const O=v.at(-1);O&&(f=wn(f,O.action.scope))}if(!s)for(const v of Object.keys(f.state))for(let O=g.length-1;O>=0;O--){const D=g[O];if(D.action.scope===v){if(D.hash!==Ct(f,v))throw new Yr(v,f,D);break}}const b=new Set([...Object.keys(f.operations),...Object.keys(t),"global","local"]),m={};for(const v of b)m[v]=[];const h=Array.from(b).reduce((v,O)=>{const D=f.operations[O]||[];return{...v,[O]:[...D.map((M,F)=>({...M,timestamp:t[O]?.[F]?.timestampUtcMs??M.timestampUtcMs}))]}},m),S=r?r.lastModifiedAtUtcIso:Object.values(h).reduce((v,O)=>{if(!O)return v;const D=O.at(-1);return D&&D.timestampUtcMs>v?D.timestampUtcMs:v},E.header.lastModifiedAtUtcIso);return r&&(f.header={...r,revision:f.header.revision,lastModifiedAtUtcIso:S}),{...f,operations:h}}function Mt(e){const t=typeof e;if(t==="string")return JSON.parse(e);if(t==="object")return e;throw new Error(`Providing resulting state is of type: ${t}`)}var Xt;(function(e){e.UNEXPECTED_INDEX="UNEXPECTED_INDEX"})(Xt||(Xt={}));var Kt;(function(e){e.DUPLICATED_INDEX="DUPLICATED_INDEX",e.MISSING_INDEX="MISSING_INDEX"})(Kt||(Kt={}));function Re(e){const t=[];let n=e.length-1;for(;n>-1;){t.unshift(e[n]);const r=(e[n]?.index||0)-(e[n]?.skip||0)-1;let i=n-1;for(;i>-1&&(e[i]?.index||0)>r;)i--;n=i}return t}function Te(e){return e.slice().sort((t,n)=>t.skip-n.skip).sort((t,n)=>t.index-n.index)}function pa(e,t,n){return[...t,...n].sort((r,i)=>new Date(r.timestampUtcMs||"").getTime()-new Date(i.timestampUtcMs||"").getTime()).map((r,i)=>({...r,index:e.index+i,skip:i===0?e.skip:0}))}function Sn(e,t){const n=e,r=t,i={index:n.index,skip:n.skip,type:n.type??null,scope:n.scope??null,input:n.input??null},o={index:r.index,skip:r.skip,type:r.type??null,scope:r.scope??null,input:r.input??null};return Vt(i)===Vt(o)}function da(e,t){const n=Re(Te(e.slice())),r=Re(Te(t.slice()));if(n.length<1)return[r,[]];const i=[];let o=!1;for(;r.length>0;){const a=r[0];let s=n.shift();for(;s&&Ti(s,a);)i.push(s),s=n.shift();if(s?o||(Sn(s,a)?(r.shift(),i.push(s)):(n.unshift(s),o=!0)):o=!0,o){let u=r.shift();for(;u;)i.push(u),u=r.shift()}}if(!o){let a=n.shift();for(;a;)i.push(a),a=n.shift()}return[Re(i),n]}function Ti(e,t){return e.index<t.index||e.index===t.index&&e.id===t.id&&e.skip<t.skip}function Di(e,t){const n=[],r=[],i=[],o=Math.max(e.length,t.length);let a=!1;for(let s=0;s<o;s++){const u=e[s],d=t[s];u&&d?!a&&Sn(u,d)?n.push(u):(a=!0,r.push(u),i.push(d)):u?r.push(u):d&&i.push(d)}return[n,r,i]}function fa(e,t,n){const[r,i,o]=Di(Re(e),Re(t)),a=St(r),s=1+Math.max(a,St(i),St(o)),u=Ni(o,i),d=n({index:s,skip:s-(a+1)},i,u);return r.concat(d)}function St(e){const t=e[e.length-1];return t?t.index:-1}function Ci(e){if(e.length<1)return-1;const t=Re(e);let n=(t[t.length-1]?.skip||0)+1;return t.length>1&&(n+=t[t.length-2]?.skip||0),(t[t.length-1]?.index||-1)<n?-1:n}function ha(e){return e.reduce((n,r)=>(n[r.action.scope]||(n[r.action.scope]=[]),n[r.action.scope]?.push(r),n),{})}function ma(e,t){return e.filter(n=>!t.some(r=>n.action.type==="NOOP"&&n.skip===0&&n.index===r.index||n.index===r.index&&n.skip===r.skip&&n.action.scope===r.action.scope&&n.hash===r.hash&&n.action.type===r.action.type))}function Mi(e,t){const r=Te(e).at(-1)?.index??-1,i=r+1,o={...t,index:t.index??i};if(o.index<r)throw new Error(`The skip header operation index must be greater than or equal to ${r}`);return Re(Te([...e,o])).slice(0,-1)}function dt(e){return Object.entries(e).reduce((n,r)=>{const[i,o]=r;return o?{...n,[i]:Re(Te(o))}:n},{})}function Ni(e,t){return e.filter(n=>n.id?!t.some(r=>r.id===n.id):!0)}function zi(e){return e?Object.entries(e).reduce((n,[r,i])=>i?{...n,[r]:i.map(o=>{const{resultingState:a,...s}=o;return s})}:n,{}):{}}function Pi(e,t){return e.filter(n=>!t.some(r=>n.index===r.index))}function Li(e){return Te(Object.values(e.operations).flatMap(n=>n||[])).at(-1)?.timestampUtcMs||e.header.lastModifiedAtUtcIso}function Ui(e,t){return(e.operations[t]?.at(-1)?.index??-1??-1)+1}function wn(e,t){const n={...e.header,revision:{...e.header.revision,[t]:Ui(e,t)},lastModifiedAtUtcIso:Li(e)};return{...e,header:n}}function lt(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var wt={exports:{}},Jt;function ji(){return Jt||(Jt=1,(function(e,t){(function(n){e.exports=n()})(function(){return(function n(r,i,o){function a(d,_){if(!i[d]){if(!r[d]){var g=typeof lt=="function"&&lt;if(!_&&g)return g(d,!0);if(s)return s(d,!0);var x=new Error("Cannot find module '"+d+"'");throw x.code="MODULE_NOT_FOUND",x}var p=i[d]={exports:{}};r[d][0].call(p.exports,function(E){var f=r[d][1][E];return a(f||E)},p,p.exports,n,r,i,o)}return i[d].exports}for(var s=typeof lt=="function"&&lt,u=0;u<o.length;u++)a(o[u]);return a})({1:[function(n,r,i){var o=n("./utils"),a=n("./support"),s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(u){for(var d,_,g,x,p,E,f,b=[],m=0,h=u.length,S=h,v=o.getTypeOf(u)!=="string";m<u.length;)S=h-m,g=v?(d=u[m++],_=m<h?u[m++]:0,m<h?u[m++]:0):(d=u.charCodeAt(m++),_=m<h?u.charCodeAt(m++):0,m<h?u.charCodeAt(m++):0),x=d>>2,p=(3&d)<<4|_>>4,E=1<S?(15&_)<<2|g>>6:64,f=2<S?63&g:64,b.push(s.charAt(x)+s.charAt(p)+s.charAt(E)+s.charAt(f));return b.join("")},i.decode=function(u){var d,_,g,x,p,E,f=0,b=0,m="data:";if(u.substr(0,m.length)===m)throw new Error("Invalid base64 input, it looks like a data url.");var h,S=3*(u=u.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(u.charAt(u.length-1)===s.charAt(64)&&S--,u.charAt(u.length-2)===s.charAt(64)&&S--,S%1!=0)throw new Error("Invalid base64 input, bad content length.");for(h=a.uint8array?new Uint8Array(0|S):new Array(0|S);f<u.length;)d=s.indexOf(u.charAt(f++))<<2|(x=s.indexOf(u.charAt(f++)))>>4,_=(15&x)<<4|(p=s.indexOf(u.charAt(f++)))>>2,g=(3&p)<<6|(E=s.indexOf(u.charAt(f++))),h[b++]=d,p!==64&&(h[b++]=_),E!==64&&(h[b++]=g);return h}},{"./support":30,"./utils":32}],2:[function(n,r,i){var o=n("./external"),a=n("./stream/DataWorker"),s=n("./stream/Crc32Probe"),u=n("./stream/DataLengthProbe");function d(_,g,x,p,E){this.compressedSize=_,this.uncompressedSize=g,this.crc32=x,this.compression=p,this.compressedContent=E}d.prototype={getContentWorker:function(){var _=new a(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new u("data_length")),g=this;return _.on("end",function(){if(this.streamInfo.data_length!==g.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),_},getCompressedWorker:function(){return new a(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},d.createWorkerFrom=function(_,g,x){return _.pipe(new s).pipe(new u("uncompressedSize")).pipe(g.compressWorker(x)).pipe(new u("compressedSize")).withStreamInfo("compression",g)},r.exports=d},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var o=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new o("STORE compression")},uncompressWorker:function(){return new o("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var o=n("./utils"),a=(function(){for(var s,u=[],d=0;d<256;d++){s=d;for(var _=0;_<8;_++)s=1&s?3988292384^s>>>1:s>>>1;u[d]=s}return u})();r.exports=function(s,u){return s!==void 0&&s.length?o.getTypeOf(s)!=="string"?(function(d,_,g,x){var p=a,E=x+g;d^=-1;for(var f=x;f<E;f++)d=d>>>8^p[255&(d^_[f])];return-1^d})(0|u,s,s.length,0):(function(d,_,g,x){var p=a,E=x+g;d^=-1;for(var f=x;f<E;f++)d=d>>>8^p[255&(d^_.charCodeAt(f))];return-1^d})(0|u,s,s.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var o=null;o=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:o}},{lie:37}],7:[function(n,r,i){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=n("pako"),s=n("./utils"),u=n("./stream/GenericWorker"),d=o?"uint8array":"array";function _(g,x){u.call(this,"FlateWorker/"+g),this._pako=null,this._pakoAction=g,this._pakoOptions=x,this.meta={}}i.magic="\b\0",s.inherits(_,u),_.prototype.processChunk=function(g){this.meta=g.meta,this._pako===null&&this._createPako(),this._pako.push(s.transformTo(d,g.data),!1)},_.prototype.flush=function(){u.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},_.prototype.cleanUp=function(){u.prototype.cleanUp.call(this),this._pako=null},_.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var g=this;this._pako.onData=function(x){g.push({data:x,meta:g.meta})}},i.compressWorker=function(g){return new _("Deflate",g)},i.uncompressWorker=function(){return new _("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function o(p,E){var f,b="";for(f=0;f<E;f++)b+=String.fromCharCode(255&p),p>>>=8;return b}function a(p,E,f,b,m,h){var S,v,O=p.file,D=p.compression,M=h!==d.utf8encode,F=s.transformTo("string",h(O.name)),T=s.transformTo("string",d.utf8encode(O.name)),G=O.comment,te=s.transformTo("string",h(G)),I=s.transformTo("string",d.utf8encode(G)),j=T.length!==O.name.length,c=I.length!==G.length,U="",N="",z="",q=O.dir,B=O.date,J={crc32:0,compressedSize:0,uncompressedSize:0};E&&!f||(J.crc32=p.crc32,J.compressedSize=p.compressedSize,J.uncompressedSize=p.uncompressedSize);var A=0;E&&(A|=8),M||!j&&!c||(A|=2048);var R=0,Y=0;q&&(R|=16),m==="UNIX"?(Y=798,R|=(function(W,ae){var ie=W;return W||(ie=ae?16893:33204),(65535&ie)<<16})(O.unixPermissions,q)):(Y=20,R|=(function(W){return 63&(W||0)})(O.dosPermissions)),S=B.getUTCHours(),S<<=6,S|=B.getUTCMinutes(),S<<=5,S|=B.getUTCSeconds()/2,v=B.getUTCFullYear()-1980,v<<=4,v|=B.getUTCMonth()+1,v<<=5,v|=B.getUTCDate(),j&&(N=o(1,1)+o(_(F),4)+T,U+="up"+o(N.length,2)+N),c&&(z=o(1,1)+o(_(te),4)+I,U+="uc"+o(z.length,2)+z);var V="";return V+=`
20
+ `+t.length.toString();return Xr.encode(n+t)}function Jr(e){const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return Array.prototype.map.call(t,n=>("00"+n.toString(16)).slice(-2)).join("")}class un extends Error{data;constructor(t){super(),this.name="InvalidActionInputError",this.data=t,this.message=this.message||`Invalid action input: ${JSON.stringify(t,null,2)}`}}class qr extends un{issues;constructor(t){super(t),this.issues=t,this.name="InvalidActionInputZodError"}}class Yr extends Error{_scope;_document;_operation;constructor(t,n,r){super(),this.name="HashMismatchError",this._document=n,this._scope=t,this._operation=r,this.message=JSON.stringify({error:`Hash mismatch on document ${n.header.id}, scope ${t}, index ${r.index}`,document:n,operation:r},null,1)}get document(){return this._document}get scope(){return this._scope}get operation(){return this._operation}}const Qr=e=>e!=null;Rr().refine(e=>Qr(e));const ei=Qe(["LOAD_STATE"]),ti=Qe(["PRUNE"]),ni=Qe(["REDO"]),ri=Qe(["SET_NAME"]),ii=Qe(["UNDO"]);function Le(){return L()}function oi(){return Ar([si(),li(),ui(),ci(),pi()])}function si(){return ee({id:L(),timestampUtcMs:L(),input:Tt(()=>cn()),type:ei,scope:Le()})}function cn(){return ee({operations:$e(),state:Tt(()=>ai())})}function ai(){return ee({data:an().nullish(),name:L()})}function li(){return ee({id:L(),timestampUtcMs:L(),input:Tt(()=>pn()),type:ti,scope:Le()})}function pn(){return ee({end:$e().nullish(),start:$e().nullish()})}const dn=$e;function ui(){return ee({id:L(),timestampUtcMs:L().datetime(),input:dn(),type:ni,scope:Le()})}const fn=L;function ci(){return ee({id:L(),timestampUtcMs:L().datetime(),input:fn(),type:ri,scope:be("global")})}const hn=$e;function pi(){return ee({id:L(),timestampUtcMs:L().datetime(),input:hn(),type:ii,scope:Le()})}function mn(e){return globalThis.crypto.randomUUID()}function gn(e,t,n,r){const i=`${e}:${t}:${n}:${r}`;return Dt(i,"sha1","hex").slice(0,32)}const di=(e=1,t="global")=>oe("UNDO",e,void 0,hn,t),fi=(e=1,t="global")=>oe("REDO",e,void 0,dn,t),hi=(e,t,n="global")=>oe("PRUNE",{start:e,end:t},void 0,pn,n),_n=(e,t)=>oe("LOAD_STATE",{state:e,operations:t},void 0,cn),bn=(e="global")=>oe("NOOP",void 0,void 0,void 0,e);function oe(e,t,n,r,i="global"){if(!e)throw new Error("Empty action type");if(typeof e!="string")throw new Error(`Invalid action type: ${JSON.stringify(e)}`);const o={id:mn(),timestampUtcMs:new Date().toISOString(),type:e,input:t,scope:i};try{r?.().parse(o.input)}catch(a){throw a instanceof kr?new qr(a.issues):new un(a)}return o}const mi=e=>({id:e.id,timestampUtcMs:e.timestampUtcMs,type:e.type,input:e.input,scope:e.scope,context:e.context,attachments:e.attachments}),gi=(e,t,n,r)=>({...e,action:e,id:gn(r.documentId,r.scope,r.branch,e.id),timestampUtcMs:new Date().toISOString(),hash:"",error:void 0,index:t,skip:n}),_i=(e,t,n,r)=>{const i=gn(r.documentId,r.scope,r.branch,e.action.id);return{...e,hash:"",error:void 0,index:t,skip:n,id:i}},bi=(e,t)=>{if(!e.action)throw new Error("Operation has no action");return{...e,action:{...e.action,context:t}}},yi=(e,t,n=[])=>({user:e,app:t,signatures:n});async function Ei(e,t){const n=Vr(e),r=Kr(n),i=await t(r);return[...n,`0x${Jr(i)}`]}async function ua(e,t,n,r,i){const a=t(n,e,void 0,{reuseOperationResultingState:!0}).operations[e.scope];if(!a)throw new Error(`No operations found for scope: ${e.scope}`);const s=a.at(-1);if(!s)throw new Error("Action was not applied");const u=a.at(-2)?.hash??"",d=await Ei({documentId:n.header.id,signer:r,action:e,previousStateHash:u},i),_={signer:yi(r.user,r.app,[...r.signatures,d])};return bi(s,_)}const Si=e=>`${e.documentType}:${e.createdAtUtcIso}:${e.nonce}`;function wi(e){let t;return{async publicKey(){return e},async sign(n){throw new Error("verification-only signer cannot sign data")},async signAction(n,r){throw new Error("verification-only signer cannot sign actions")},async verify(n,r){t||(t=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:"P-256"},!0,["verify"]));let i;try{i=await crypto.subtle.verify({name:"ECDSA",hash:"SHA-256"},t,new Uint8Array(r),new Uint8Array(n))}catch{throw new Error("invalid signature")}if(!i)throw new Error("invalid signature")}}}const Oi=e=>wi(e.sig.publicKey),xi=async(e,t,n)=>{const r=Si(e),o=new TextEncoder().encode(r),a=Uint8Array.from(atob(t),s=>s.charCodeAt(0));await n.verify(o,a)},ca=async e=>{const t=Oi(e);return xi({documentType:e.documentType,createdAtUtcIso:e.createdAtUtcIso,nonce:e.sig.nonce},e.id,t)},vi=(e=mn(),t="")=>({id:e,sig:{publicKey:{},nonce:""},documentType:t,createdAtUtcIso:new Date().toISOString(),slug:"",name:"",branch:"main",revision:{document:0},lastModifiedAtUtcIso:new Date().toISOString(),meta:{}});function Ii(e){return["UNDO","REDO"].includes(e.type)}function Ai(e){return e.type==="UNDO"}function yn(e){return["SET_NAME","UNDO","REDO","PRUNE","LOAD_STATE"].includes(e.type)}function Ri(e,t){const n=e(t);return{header:vi(),state:n,initialState:n,operations:{global:[],local:[]},clipboard:[]}}function Ct(e,t="global"){const n=_t(e.state[t]||"");return Dt(n)}const ki=e=>e;function En(e,t,n,r,i,o={},a){const{checkHashes:s=!0,reuseOperationResultingState:u,operationResultingStateParser:d=Mt}=a||{};let _=e;const g=[],x=new Set([...Object.keys(t),"global","local"]),p={};for(const v of x)p[v]=[];if(u)for(const[v,O]of Object.entries(t)){if(!O)continue;const D=O.findLastIndex(F=>!!F.resultingState);if(D<0){g.push(...O);continue}const M=O[D];if(!(!M||!M.resultingState))try{const F=d(M.resultingState);_={..._,[v]:F};const T=p[v];T&&T.push(...O.slice(0,D+1)),g.push(...O.slice(D+1))}catch{g.push(...O)}}else g.push(...Object.values(t).flatMap(v=>v||[]));const E={header:r,state:ki(_),initialState:e,operations:p,clipboard:[]};let f=E;if(g.length)f=g.reduce((v,O)=>n(v,O.action,i,{ignoreSkipOperations:!0,checkHashes:s,replayOptions:{operation:O}}),E);else for(const v of Object.values(p)){if(!v)continue;const O=v.at(-1);O&&(f=wn(f,O.action.scope))}if(!s)for(const v of Object.keys(f.state))for(let O=g.length-1;O>=0;O--){const D=g[O];if(D.action.scope===v){if(D.hash!==Ct(f,v))throw new Yr(v,f,D);break}}const b=new Set([...Object.keys(f.operations),...Object.keys(t),"global","local"]),m={};for(const v of b)m[v]=[];const h=Array.from(b).reduce((v,O)=>{const D=f.operations[O]||[];return{...v,[O]:[...D.map((M,F)=>({...M,timestamp:t[O]?.[F]?.timestampUtcMs??M.timestampUtcMs}))]}},m),S=r?r.lastModifiedAtUtcIso:Object.values(h).reduce((v,O)=>{if(!O)return v;const D=O.at(-1);return D&&D.timestampUtcMs>v?D.timestampUtcMs:v},E.header.lastModifiedAtUtcIso);return r&&(f.header={...r,revision:f.header.revision,lastModifiedAtUtcIso:S}),{...f,operations:h}}function Mt(e){const t=typeof e;if(t==="string")return JSON.parse(e);if(t==="object")return e;throw new Error(`Providing resulting state is of type: ${t}`)}var Xt;(function(e){e.UNEXPECTED_INDEX="UNEXPECTED_INDEX"})(Xt||(Xt={}));var Kt;(function(e){e.DUPLICATED_INDEX="DUPLICATED_INDEX",e.MISSING_INDEX="MISSING_INDEX"})(Kt||(Kt={}));function Re(e){const t=[];let n=e.length-1;for(;n>-1;){t.unshift(e[n]);const r=(e[n]?.index||0)-(e[n]?.skip||0)-1;let i=n-1;for(;i>-1&&(e[i]?.index||0)>r;)i--;n=i}return t}function Te(e){return e.slice().sort((t,n)=>t.skip-n.skip).sort((t,n)=>t.index-n.index)}function pa(e,t,n){return[...t,...n].sort((r,i)=>new Date(r.timestampUtcMs||"").getTime()-new Date(i.timestampUtcMs||"").getTime()).map((r,i)=>({...r,index:e.index+i,skip:i===0?e.skip:0}))}function Sn(e,t){const n=e,r=t,i={index:n.index,skip:n.skip,type:n.type??null,scope:n.scope??null,input:n.input??null},o={index:r.index,skip:r.skip,type:r.type??null,scope:r.scope??null,input:r.input??null};return Vt(i)===Vt(o)}function da(e,t){const n=Re(Te(e.slice())),r=Re(Te(t.slice()));if(n.length<1)return[r,[]];const i=[];let o=!1;for(;r.length>0;){const a=r[0];let s=n.shift();for(;s&&Ti(s,a);)i.push(s),s=n.shift();if(s?o||(Sn(s,a)?(r.shift(),i.push(s)):(n.unshift(s),o=!0)):o=!0,o){let u=r.shift();for(;u;)i.push(u),u=r.shift()}}if(!o){let a=n.shift();for(;a;)i.push(a),a=n.shift()}return[Re(i),n]}function Ti(e,t){return e.index<t.index||e.index===t.index&&e.id===t.id&&e.skip<t.skip}function Di(e,t){const n=[],r=[],i=[],o=Math.max(e.length,t.length);let a=!1;for(let s=0;s<o;s++){const u=e[s],d=t[s];u&&d?!a&&Sn(u,d)?n.push(u):(a=!0,r.push(u),i.push(d)):u?r.push(u):d&&i.push(d)}return[n,r,i]}function fa(e,t,n){const[r,i,o]=Di(Re(e),Re(t)),a=St(r),s=1+Math.max(a,St(i),St(o)),u=Ni(o,i),d=n({index:s,skip:s-(a+1)},i,u);return r.concat(d)}function St(e){const t=e[e.length-1];return t?t.index:-1}function Ci(e){if(e.length<1)return-1;const t=Re(e);let n=(t[t.length-1]?.skip||0)+1;return t.length>1&&(n+=t[t.length-2]?.skip||0),(t[t.length-1]?.index||-1)<n?-1:n}function ha(e){return e.reduce((n,r)=>(n[r.action.scope]||(n[r.action.scope]=[]),n[r.action.scope]?.push(r),n),{})}function ma(e,t){return e.filter(n=>!t.some(r=>n.action.type==="NOOP"&&n.skip===0&&n.index===r.index||n.index===r.index&&n.skip===r.skip&&n.action.scope===r.action.scope&&n.hash===r.hash&&n.action.type===r.action.type))}function Mi(e,t){const r=Te(e).at(-1)?.index??-1,i=r+1,o={...t,index:t.index??i};if(o.index<r)throw new Error(`The skip header operation index must be greater than or equal to ${r}`);return Re(Te([...e,o])).slice(0,-1)}function dt(e){return Object.entries(e).reduce((n,r)=>{const[i,o]=r;return o?{...n,[i]:Re(Te(o))}:n},{})}function Ni(e,t){return e.filter(n=>n.id?!t.some(r=>r.id===n.id):!0)}function zi(e){return e?Object.entries(e).reduce((n,[r,i])=>i?{...n,[r]:i.map(o=>{const{resultingState:a,...s}=o;return s})}:n,{}):{}}function Pi(e,t){return e.filter(n=>!t.some(r=>n.index===r.index))}function Li(e){return Te(Object.values(e.operations).flatMap(n=>n||[])).at(-1)?.timestampUtcMs||e.header.lastModifiedAtUtcIso}function Ui(e,t){return(e.operations[t]?.at(-1)?.index??-1??-1)+1}function wn(e,t){const n={...e.header,revision:{...e.header.revision,[t]:Ui(e,t)},lastModifiedAtUtcIso:Li(e)};return{...e,header:n}}function lt(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var wt={exports:{}},Jt;function ji(){return Jt||(Jt=1,(function(e,t){(function(n){e.exports=n()})(function(){return(function n(r,i,o){function a(d,_){if(!i[d]){if(!r[d]){var g=typeof lt=="function"&&lt;if(!_&&g)return g(d,!0);if(s)return s(d,!0);var x=new Error("Cannot find module '"+d+"'");throw x.code="MODULE_NOT_FOUND",x}var p=i[d]={exports:{}};r[d][0].call(p.exports,function(E){var f=r[d][1][E];return a(f||E)},p,p.exports,n,r,i,o)}return i[d].exports}for(var s=typeof lt=="function"&&lt,u=0;u<o.length;u++)a(o[u]);return a})({1:[function(n,r,i){var o=n("./utils"),a=n("./support"),s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(u){for(var d,_,g,x,p,E,f,b=[],m=0,h=u.length,S=h,v=o.getTypeOf(u)!=="string";m<u.length;)S=h-m,g=v?(d=u[m++],_=m<h?u[m++]:0,m<h?u[m++]:0):(d=u.charCodeAt(m++),_=m<h?u.charCodeAt(m++):0,m<h?u.charCodeAt(m++):0),x=d>>2,p=(3&d)<<4|_>>4,E=1<S?(15&_)<<2|g>>6:64,f=2<S?63&g:64,b.push(s.charAt(x)+s.charAt(p)+s.charAt(E)+s.charAt(f));return b.join("")},i.decode=function(u){var d,_,g,x,p,E,f=0,b=0,m="data:";if(u.substr(0,m.length)===m)throw new Error("Invalid base64 input, it looks like a data url.");var h,S=3*(u=u.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(u.charAt(u.length-1)===s.charAt(64)&&S--,u.charAt(u.length-2)===s.charAt(64)&&S--,S%1!=0)throw new Error("Invalid base64 input, bad content length.");for(h=a.uint8array?new Uint8Array(0|S):new Array(0|S);f<u.length;)d=s.indexOf(u.charAt(f++))<<2|(x=s.indexOf(u.charAt(f++)))>>4,_=(15&x)<<4|(p=s.indexOf(u.charAt(f++)))>>2,g=(3&p)<<6|(E=s.indexOf(u.charAt(f++))),h[b++]=d,p!==64&&(h[b++]=_),E!==64&&(h[b++]=g);return h}},{"./support":30,"./utils":32}],2:[function(n,r,i){var o=n("./external"),a=n("./stream/DataWorker"),s=n("./stream/Crc32Probe"),u=n("./stream/DataLengthProbe");function d(_,g,x,p,E){this.compressedSize=_,this.uncompressedSize=g,this.crc32=x,this.compression=p,this.compressedContent=E}d.prototype={getContentWorker:function(){var _=new a(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new u("data_length")),g=this;return _.on("end",function(){if(this.streamInfo.data_length!==g.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),_},getCompressedWorker:function(){return new a(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},d.createWorkerFrom=function(_,g,x){return _.pipe(new s).pipe(new u("uncompressedSize")).pipe(g.compressWorker(x)).pipe(new u("compressedSize")).withStreamInfo("compression",g)},r.exports=d},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var o=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new o("STORE compression")},uncompressWorker:function(){return new o("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var o=n("./utils"),a=(function(){for(var s,u=[],d=0;d<256;d++){s=d;for(var _=0;_<8;_++)s=1&s?3988292384^s>>>1:s>>>1;u[d]=s}return u})();r.exports=function(s,u){return s!==void 0&&s.length?o.getTypeOf(s)!=="string"?(function(d,_,g,x){var p=a,E=x+g;d^=-1;for(var f=x;f<E;f++)d=d>>>8^p[255&(d^_[f])];return-1^d})(0|u,s,s.length,0):(function(d,_,g,x){var p=a,E=x+g;d^=-1;for(var f=x;f<E;f++)d=d>>>8^p[255&(d^_.charCodeAt(f))];return-1^d})(0|u,s,s.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var o=null;o=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:o}},{lie:37}],7:[function(n,r,i){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=n("pako"),s=n("./utils"),u=n("./stream/GenericWorker"),d=o?"uint8array":"array";function _(g,x){u.call(this,"FlateWorker/"+g),this._pako=null,this._pakoAction=g,this._pakoOptions=x,this.meta={}}i.magic="\b\0",s.inherits(_,u),_.prototype.processChunk=function(g){this.meta=g.meta,this._pako===null&&this._createPako(),this._pako.push(s.transformTo(d,g.data),!1)},_.prototype.flush=function(){u.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},_.prototype.cleanUp=function(){u.prototype.cleanUp.call(this),this._pako=null},_.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var g=this;this._pako.onData=function(x){g.push({data:x,meta:g.meta})}},i.compressWorker=function(g){return new _("Deflate",g)},i.uncompressWorker=function(){return new _("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function o(p,E){var f,b="";for(f=0;f<E;f++)b+=String.fromCharCode(255&p),p>>>=8;return b}function a(p,E,f,b,m,h){var S,v,O=p.file,D=p.compression,M=h!==d.utf8encode,F=s.transformTo("string",h(O.name)),T=s.transformTo("string",d.utf8encode(O.name)),G=O.comment,te=s.transformTo("string",h(G)),I=s.transformTo("string",d.utf8encode(G)),j=T.length!==O.name.length,c=I.length!==G.length,U="",N="",z="",q=O.dir,B=O.date,J={crc32:0,compressedSize:0,uncompressedSize:0};E&&!f||(J.crc32=p.crc32,J.compressedSize=p.compressedSize,J.uncompressedSize=p.uncompressedSize);var A=0;E&&(A|=8),M||!j&&!c||(A|=2048);var R=0,Y=0;q&&(R|=16),m==="UNIX"?(Y=798,R|=(function(W,ae){var ie=W;return W||(ie=ae?16893:33204),(65535&ie)<<16})(O.unixPermissions,q)):(Y=20,R|=(function(W){return 63&(W||0)})(O.dosPermissions)),S=B.getUTCHours(),S<<=6,S|=B.getUTCMinutes(),S<<=5,S|=B.getUTCSeconds()/2,v=B.getUTCFullYear()-1980,v<<=4,v|=B.getUTCMonth()+1,v<<=5,v|=B.getUTCDate(),j&&(N=o(1,1)+o(_(F),4)+T,U+="up"+o(N.length,2)+N),c&&(z=o(1,1)+o(_(te),4)+I,U+="uc"+o(z.length,2)+z);var V="";return V+=`
21
21
  \0`,V+=o(A,2),V+=D.magic,V+=o(S,2),V+=o(v,2),V+=o(J.crc32,4),V+=o(J.compressedSize,4),V+=o(J.uncompressedSize,4),V+=o(F.length,2),V+=o(U.length,2),{fileRecord:g.LOCAL_FILE_HEADER+V+F+U,dirRecord:g.CENTRAL_FILE_HEADER+o(Y,2)+V+o(te.length,2)+"\0\0\0\0"+o(R,4)+o(b,4)+F+U+te}}var s=n("../utils"),u=n("../stream/GenericWorker"),d=n("../utf8"),_=n("../crc32"),g=n("../signature");function x(p,E,f,b){u.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=E,this.zipPlatform=f,this.encodeFileName=b,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}s.inherits(x,u),x.prototype.push=function(p){var E=p.meta.percent||0,f=this.entriesCount,b=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,u.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:f?(E+100*(f-b-1))/f:100}}))},x.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var E=this.streamFiles&&!p.file.dir;if(E){var f=a(p,E,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:f.fileRecord,meta:{percent:0}})}else this.accumulate=!0},x.prototype.closedSource=function(p){this.accumulate=!1;var E=this.streamFiles&&!p.file.dir,f=a(p,E,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),E)this.push({data:(function(b){return g.DATA_DESCRIPTOR+o(b.crc32,4)+o(b.compressedSize,4)+o(b.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:f.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},x.prototype.flush=function(){for(var p=this.bytesWritten,E=0;E<this.dirRecords.length;E++)this.push({data:this.dirRecords[E],meta:{percent:100}});var f=this.bytesWritten-p,b=(function(m,h,S,v,O){var D=s.transformTo("string",O(v));return g.CENTRAL_DIRECTORY_END+"\0\0\0\0"+o(m,2)+o(m,2)+o(h,4)+o(S,4)+o(D.length,2)+D})(this.dirRecords.length,f,p,this.zipComment,this.encodeFileName);this.push({data:b,meta:{percent:100}})},x.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},x.prototype.registerPrevious=function(p){this._sources.push(p);var E=this;return p.on("data",function(f){E.processChunk(f)}),p.on("end",function(){E.closedSource(E.previous.streamInfo),E._sources.length?E.prepareNextSource():E.end()}),p.on("error",function(f){E.error(f)}),this},x.prototype.resume=function(){return!!u.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},x.prototype.error=function(p){var E=this._sources;if(!u.prototype.error.call(this,p))return!1;for(var f=0;f<E.length;f++)try{E[f].error(p)}catch{}return!0},x.prototype.lock=function(){u.prototype.lock.call(this);for(var p=this._sources,E=0;E<p.length;E++)p[E].lock()},r.exports=x},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var o=n("../compressions"),a=n("./ZipFileWorker");i.generateWorker=function(s,u,d){var _=new a(u.streamFiles,d,u.platform,u.encodeFileName),g=0;try{s.forEach(function(x,p){g++;var E=(function(h,S){var v=h||S,O=o[v];if(!O)throw new Error(v+" is not a valid compression method !");return O})(p.options.compression,u.compression),f=p.options.compressionOptions||u.compressionOptions||{},b=p.dir,m=p.date;p._compressWorker(E,f).withStreamInfo("file",{name:x,dir:b,date:m,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(_)}),_.entriesCount=g}catch(x){_.error(x)}return _}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function o(){if(!(this instanceof o))return new o;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new o;for(var s in this)typeof this[s]!="function"&&(a[s]=this[s]);return a}}(o.prototype=n("./object")).loadAsync=n("./load"),o.support=n("./support"),o.defaults=n("./defaults"),o.version="3.10.1",o.loadAsync=function(a,s){return new o().loadAsync(a,s)},o.external=n("./external"),r.exports=o},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var o=n("./utils"),a=n("./external"),s=n("./utf8"),u=n("./zipEntries"),d=n("./stream/Crc32Probe"),_=n("./nodejsUtils");function g(x){return new a.Promise(function(p,E){var f=x.decompressed.getContentWorker().pipe(new d);f.on("error",function(b){E(b)}).on("end",function(){f.streamInfo.crc32!==x.decompressed.crc32?E(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}r.exports=function(x,p){var E=this;return p=o.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:s.utf8decode}),_.isNode&&_.isStream(x)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):o.prepareContent("the loaded zip file",x,!0,p.optimizedBinaryString,p.base64).then(function(f){var b=new u(p);return b.load(f),b}).then(function(f){var b=[a.Promise.resolve(f)],m=f.files;if(p.checkCRC32)for(var h=0;h<m.length;h++)b.push(g(m[h]));return a.Promise.all(b)}).then(function(f){for(var b=f.shift(),m=b.files,h=0;h<m.length;h++){var S=m[h],v=S.fileNameStr,O=o.resolve(S.fileNameStr);E.file(O,S.decompressed,{binary:!0,optimizedBinaryString:!0,date:S.date,dir:S.dir,comment:S.fileCommentStr.length?S.fileCommentStr:null,unixPermissions:S.unixPermissions,dosPermissions:S.dosPermissions,createFolders:p.createFolders}),S.dir||(E.file(O).unsafeOriginalName=v)}return b.zipComment.length&&(E.comment=b.zipComment),E})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var o=n("../utils"),a=n("../stream/GenericWorker");function s(u,d){a.call(this,"Nodejs stream input adapter for "+u),this._upstreamEnded=!1,this._bindStream(d)}o.inherits(s,a),s.prototype._bindStream=function(u){var d=this;(this._stream=u).pause(),u.on("data",function(_){d.push({data:_,meta:{percent:0}})}).on("error",function(_){d.isPaused?this.generatedError=_:d.error(_)}).on("end",function(){d.isPaused?d._upstreamEnded=!0:d.end()})},s.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},s.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=s},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var o=n("readable-stream").Readable;function a(s,u,d){o.call(this,u),this._helper=s;var _=this;s.on("data",function(g,x){_.push(g)||_._helper.pause(),d&&d(x)}).on("error",function(g){_.emit("error",g)}).on("end",function(){_.push(null)})}n("../utils").inherits(a,o),a.prototype._read=function(){this._helper.resume()},r.exports=a},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(o,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(o,a);if(typeof o=="number")throw new Error('The "data" argument must not be a number');return new Buffer(o,a)},allocBuffer:function(o){if(Buffer.alloc)return Buffer.alloc(o);var a=new Buffer(o);return a.fill(0),a},isBuffer:function(o){return Buffer.isBuffer(o)},isStream:function(o){return o&&typeof o.on=="function"&&typeof o.pause=="function"&&typeof o.resume=="function"}}},{}],15:[function(n,r,i){function o(O,D,M){var F,T=s.getTypeOf(D),G=s.extend(M||{},_);G.date=G.date||new Date,G.compression!==null&&(G.compression=G.compression.toUpperCase()),typeof G.unixPermissions=="string"&&(G.unixPermissions=parseInt(G.unixPermissions,8)),G.unixPermissions&&16384&G.unixPermissions&&(G.dir=!0),G.dosPermissions&&16&G.dosPermissions&&(G.dir=!0),G.dir&&(O=m(O)),G.createFolders&&(F=b(O))&&h.call(this,F,!0);var te=T==="string"&&G.binary===!1&&G.base64===!1;M&&M.binary!==void 0||(G.binary=!te),(D instanceof g&&D.uncompressedSize===0||G.dir||!D||D.length===0)&&(G.base64=!1,G.binary=!0,D="",G.compression="STORE",T="string");var I=null;I=D instanceof g||D instanceof u?D:E.isNode&&E.isStream(D)?new f(O,D):s.prepareContent(O,D,G.binary,G.optimizedBinaryString,G.base64);var j=new x(O,I,G);this.files[O]=j}var a=n("./utf8"),s=n("./utils"),u=n("./stream/GenericWorker"),d=n("./stream/StreamHelper"),_=n("./defaults"),g=n("./compressedObject"),x=n("./zipObject"),p=n("./generate"),E=n("./nodejsUtils"),f=n("./nodejs/NodejsStreamInputAdapter"),b=function(O){O.slice(-1)==="/"&&(O=O.substring(0,O.length-1));var D=O.lastIndexOf("/");return 0<D?O.substring(0,D):""},m=function(O){return O.slice(-1)!=="/"&&(O+="/"),O},h=function(O,D){return D=D!==void 0?D:_.createFolders,O=m(O),this.files[O]||o.call(this,O,null,{dir:!0,createFolders:D}),this.files[O]};function S(O){return Object.prototype.toString.call(O)==="[object RegExp]"}var v={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(O){var D,M,F;for(D in this.files)F=this.files[D],(M=D.slice(this.root.length,D.length))&&D.slice(0,this.root.length)===this.root&&O(M,F)},filter:function(O){var D=[];return this.forEach(function(M,F){O(M,F)&&D.push(F)}),D},file:function(O,D,M){if(arguments.length!==1)return O=this.root+O,o.call(this,O,D,M),this;if(S(O)){var F=O;return this.filter(function(G,te){return!te.dir&&F.test(G)})}var T=this.files[this.root+O];return T&&!T.dir?T:null},folder:function(O){if(!O)return this;if(S(O))return this.filter(function(T,G){return G.dir&&O.test(T)});var D=this.root+O,M=h.call(this,D),F=this.clone();return F.root=M.name,F},remove:function(O){O=this.root+O;var D=this.files[O];if(D||(O.slice(-1)!=="/"&&(O+="/"),D=this.files[O]),D&&!D.dir)delete this.files[O];else for(var M=this.filter(function(T,G){return G.name.slice(0,O.length)===O}),F=0;F<M.length;F++)delete this.files[M[F].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(O){var D,M={};try{if((M=s.extend(O||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=M.type.toLowerCase(),M.compression=M.compression.toUpperCase(),M.type==="binarystring"&&(M.type="string"),!M.type)throw new Error("No output type specified.");s.checkSupport(M.type),M.platform!=="darwin"&&M.platform!=="freebsd"&&M.platform!=="linux"&&M.platform!=="sunos"||(M.platform="UNIX"),M.platform==="win32"&&(M.platform="DOS");var F=M.comment||this.comment||"";D=p.generateWorker(this,M,F)}catch(T){(D=new u("error")).error(T)}return new d(D,M.type||"string",M.mimeType)},generateAsync:function(O,D){return this.generateInternalStream(O).accumulate(D)},generateNodeStream:function(O,D){return(O=O||{}).type||(O.type="nodebuffer"),this.generateInternalStream(O).toNodejsStream(D)}};r.exports=v},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var o=n("./DataReader");function a(s){o.call(this,s);for(var u=0;u<this.data.length;u++)s[u]=255&s[u]}n("../utils").inherits(a,o),a.prototype.byteAt=function(s){return this.data[this.zero+s]},a.prototype.lastIndexOfSignature=function(s){for(var u=s.charCodeAt(0),d=s.charCodeAt(1),_=s.charCodeAt(2),g=s.charCodeAt(3),x=this.length-4;0<=x;--x)if(this.data[x]===u&&this.data[x+1]===d&&this.data[x+2]===_&&this.data[x+3]===g)return x-this.zero;return-1},a.prototype.readAndCheckSignature=function(s){var u=s.charCodeAt(0),d=s.charCodeAt(1),_=s.charCodeAt(2),g=s.charCodeAt(3),x=this.readData(4);return u===x[0]&&d===x[1]&&_===x[2]&&g===x[3]},a.prototype.readData=function(s){if(this.checkOffset(s),s===0)return[];var u=this.data.slice(this.zero+this.index,this.zero+this.index+s);return this.index+=s,u},r.exports=a},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var o=n("../utils");function a(s){this.data=s,this.length=s.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(s){this.checkIndex(this.index+s)},checkIndex:function(s){if(this.length<this.zero+s||s<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+s+"). Corrupted zip ?")},setIndex:function(s){this.checkIndex(s),this.index=s},skip:function(s){this.setIndex(this.index+s)},byteAt:function(){},readInt:function(s){var u,d=0;for(this.checkOffset(s),u=this.index+s-1;u>=this.index;u--)d=(d<<8)+this.byteAt(u);return this.index+=s,d},readString:function(s){return o.transformTo("string",this.readData(s))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var s=this.readInt(4);return new Date(Date.UTC(1980+(s>>25&127),(s>>21&15)-1,s>>16&31,s>>11&31,s>>5&63,(31&s)<<1))}},r.exports=a},{"../utils":32}],19:[function(n,r,i){var o=n("./Uint8ArrayReader");function a(s){o.call(this,s)}n("../utils").inherits(a,o),a.prototype.readData=function(s){this.checkOffset(s);var u=this.data.slice(this.zero+this.index,this.zero+this.index+s);return this.index+=s,u},r.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var o=n("./DataReader");function a(s){o.call(this,s)}n("../utils").inherits(a,o),a.prototype.byteAt=function(s){return this.data.charCodeAt(this.zero+s)},a.prototype.lastIndexOfSignature=function(s){return this.data.lastIndexOf(s)-this.zero},a.prototype.readAndCheckSignature=function(s){return s===this.readData(4)},a.prototype.readData=function(s){this.checkOffset(s);var u=this.data.slice(this.zero+this.index,this.zero+this.index+s);return this.index+=s,u},r.exports=a},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var o=n("./ArrayReader");function a(s){o.call(this,s)}n("../utils").inherits(a,o),a.prototype.readData=function(s){if(this.checkOffset(s),s===0)return new Uint8Array(0);var u=this.data.subarray(this.zero+this.index,this.zero+this.index+s);return this.index+=s,u},r.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var o=n("../utils"),a=n("../support"),s=n("./ArrayReader"),u=n("./StringReader"),d=n("./NodeBufferReader"),_=n("./Uint8ArrayReader");r.exports=function(g){var x=o.getTypeOf(g);return o.checkSupport(x),x!=="string"||a.uint8array?x==="nodebuffer"?new d(g):a.uint8array?new _(o.transformTo("uint8array",g)):new s(o.transformTo("array",g)):new u(g)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var o=n("./GenericWorker"),a=n("../utils");function s(u){o.call(this,"ConvertWorker to "+u),this.destType=u}a.inherits(s,o),s.prototype.processChunk=function(u){this.push({data:a.transformTo(this.destType,u.data),meta:u.meta})},r.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var o=n("./GenericWorker"),a=n("../crc32");function s(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(s,o),s.prototype.processChunk=function(u){this.streamInfo.crc32=a(u.data,this.streamInfo.crc32||0),this.push(u)},r.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var o=n("../utils"),a=n("./GenericWorker");function s(u){a.call(this,"DataLengthProbe for "+u),this.propName=u,this.withStreamInfo(u,0)}o.inherits(s,a),s.prototype.processChunk=function(u){if(u){var d=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=d+u.data.length}a.prototype.processChunk.call(this,u)},r.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var o=n("../utils"),a=n("./GenericWorker");function s(u){a.call(this,"DataWorker");var d=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,u.then(function(_){d.dataIsReady=!0,d.data=_,d.max=_&&_.length||0,d.type=o.getTypeOf(_),d.isPaused||d._tickAndRepeat()},function(_){d.error(_)})}o.inherits(s,a),s.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var u=null,d=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":u=this.data.substring(this.index,d);break;case"uint8array":u=this.data.subarray(this.index,d);break;case"array":case"nodebuffer":u=this.data.slice(this.index,d)}return this.index=d,this.push({data:u,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function o(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}o.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,s){return this._listeners[a].push(s),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,s){if(this._listeners[a])for(var u=0;u<this._listeners[a].length;u++)this._listeners[a][u].call(this,s)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var s=this;return a.on("data",function(u){s.processChunk(u)}),a.on("end",function(){s.end()}),a.on("error",function(u){s.error(u)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,s){return this.extraStreamInfo[a]=s,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},r.exports=o},{}],29:[function(n,r,i){var o=n("../utils"),a=n("./ConvertWorker"),s=n("./GenericWorker"),u=n("../base64"),d=n("../support"),_=n("../external"),g=null;if(d.nodestream)try{g=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function x(E,f){return new _.Promise(function(b,m){var h=[],S=E._internalType,v=E._outputType,O=E._mimeType;E.on("data",function(D,M){h.push(D),f&&f(M)}).on("error",function(D){h=[],m(D)}).on("end",function(){try{var D=(function(M,F,T){switch(M){case"blob":return o.newBlob(o.transformTo("arraybuffer",F),T);case"base64":return u.encode(F);default:return o.transformTo(M,F)}})(v,(function(M,F){var T,G=0,te=null,I=0;for(T=0;T<F.length;T++)I+=F[T].length;switch(M){case"string":return F.join("");case"array":return Array.prototype.concat.apply([],F);case"uint8array":for(te=new Uint8Array(I),T=0;T<F.length;T++)te.set(F[T],G),G+=F[T].length;return te;case"nodebuffer":return Buffer.concat(F);default:throw new Error("concat : unsupported type '"+M+"'")}})(S,h),O);b(D)}catch(M){m(M)}h=[]}).resume()})}function p(E,f,b){var m=f;switch(f){case"blob":case"arraybuffer":m="uint8array";break;case"base64":m="string"}try{this._internalType=m,this._outputType=f,this._mimeType=b,o.checkSupport(m),this._worker=E.pipe(new a(m)),E.lock()}catch(h){this._worker=new s("error"),this._worker.error(h)}}p.prototype={accumulate:function(E){return x(this,E)},on:function(E,f){var b=this;return E==="data"?this._worker.on(E,function(m){f.call(b,m.data,m.meta)}):this._worker.on(E,function(){o.delay(f,arguments,b)}),this},resume:function(){return o.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(E){if(o.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new g(this,{objectMode:this._outputType!=="nodebuffer"},E)}},r.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var o=new ArrayBuffer(0);try{i.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(o),i.blob=a.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){for(var o=n("./utils"),a=n("./support"),s=n("./nodejsUtils"),u=n("./stream/GenericWorker"),d=new Array(256),_=0;_<256;_++)d[_]=252<=_?6:248<=_?5:240<=_?4:224<=_?3:192<=_?2:1;d[254]=d[254]=1;function g(){u.call(this,"utf-8 decode"),this.leftOver=null}function x(){u.call(this,"utf-8 encode")}i.utf8encode=function(p){return a.nodebuffer?s.newBufferFrom(p,"utf-8"):(function(E){var f,b,m,h,S,v=E.length,O=0;for(h=0;h<v;h++)(64512&(b=E.charCodeAt(h)))==55296&&h+1<v&&(64512&(m=E.charCodeAt(h+1)))==56320&&(b=65536+(b-55296<<10)+(m-56320),h++),O+=b<128?1:b<2048?2:b<65536?3:4;for(f=a.uint8array?new Uint8Array(O):new Array(O),h=S=0;S<O;h++)(64512&(b=E.charCodeAt(h)))==55296&&h+1<v&&(64512&(m=E.charCodeAt(h+1)))==56320&&(b=65536+(b-55296<<10)+(m-56320),h++),b<128?f[S++]=b:(b<2048?f[S++]=192|b>>>6:(b<65536?f[S++]=224|b>>>12:(f[S++]=240|b>>>18,f[S++]=128|b>>>12&63),f[S++]=128|b>>>6&63),f[S++]=128|63&b);return f})(p)},i.utf8decode=function(p){return a.nodebuffer?o.transformTo("nodebuffer",p).toString("utf-8"):(function(E){var f,b,m,h,S=E.length,v=new Array(2*S);for(f=b=0;f<S;)if((m=E[f++])<128)v[b++]=m;else if(4<(h=d[m]))v[b++]=65533,f+=h-1;else{for(m&=h===2?31:h===3?15:7;1<h&&f<S;)m=m<<6|63&E[f++],h--;1<h?v[b++]=65533:m<65536?v[b++]=m:(m-=65536,v[b++]=55296|m>>10&1023,v[b++]=56320|1023&m)}return v.length!==b&&(v.subarray?v=v.subarray(0,b):v.length=b),o.applyFromCharCode(v)})(p=o.transformTo(a.uint8array?"uint8array":"array",p))},o.inherits(g,u),g.prototype.processChunk=function(p){var E=o.transformTo(a.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var f=E;(E=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),E.set(f,this.leftOver.length)}else E=this.leftOver.concat(E);this.leftOver=null}var b=(function(h,S){var v;for((S=S||h.length)>h.length&&(S=h.length),v=S-1;0<=v&&(192&h[v])==128;)v--;return v<0||v===0?S:v+d[h[v]]>S?v:S})(E),m=E;b!==E.length&&(a.uint8array?(m=E.subarray(0,b),this.leftOver=E.subarray(b,E.length)):(m=E.slice(0,b),this.leftOver=E.slice(b,E.length))),this.push({data:i.utf8decode(m),meta:p.meta})},g.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=g,o.inherits(x,u),x.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=x},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var o=n("./support"),a=n("./base64"),s=n("./nodejsUtils"),u=n("./external");function d(f){return f}function _(f,b){for(var m=0;m<f.length;++m)b[m]=255&f.charCodeAt(m);return b}n("setimmediate"),i.newBlob=function(f,b){i.checkSupport("blob");try{return new Blob([f],{type:b})}catch{try{var m=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return m.append(f),m.getBlob(b)}catch{throw new Error("Bug : can't construct the Blob.")}}};var g={stringifyByChunk:function(f,b,m){var h=[],S=0,v=f.length;if(v<=m)return String.fromCharCode.apply(null,f);for(;S<v;)b==="array"||b==="nodebuffer"?h.push(String.fromCharCode.apply(null,f.slice(S,Math.min(S+m,v)))):h.push(String.fromCharCode.apply(null,f.subarray(S,Math.min(S+m,v)))),S+=m;return h.join("")},stringifyByChar:function(f){for(var b="",m=0;m<f.length;m++)b+=String.fromCharCode(f[m]);return b},applyCanBeUsed:{uint8array:(function(){try{return o.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return o.nodebuffer&&String.fromCharCode.apply(null,s.allocBuffer(1)).length===1}catch{return!1}})()}};function x(f){var b=65536,m=i.getTypeOf(f),h=!0;if(m==="uint8array"?h=g.applyCanBeUsed.uint8array:m==="nodebuffer"&&(h=g.applyCanBeUsed.nodebuffer),h)for(;1<b;)try{return g.stringifyByChunk(f,m,b)}catch{b=Math.floor(b/2)}return g.stringifyByChar(f)}function p(f,b){for(var m=0;m<f.length;m++)b[m]=f[m];return b}i.applyFromCharCode=x;var E={};E.string={string:d,array:function(f){return _(f,new Array(f.length))},arraybuffer:function(f){return E.string.uint8array(f).buffer},uint8array:function(f){return _(f,new Uint8Array(f.length))},nodebuffer:function(f){return _(f,s.allocBuffer(f.length))}},E.array={string:x,array:d,arraybuffer:function(f){return new Uint8Array(f).buffer},uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return s.newBufferFrom(f)}},E.arraybuffer={string:function(f){return x(new Uint8Array(f))},array:function(f){return p(new Uint8Array(f),new Array(f.byteLength))},arraybuffer:d,uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return s.newBufferFrom(new Uint8Array(f))}},E.uint8array={string:x,array:function(f){return p(f,new Array(f.length))},arraybuffer:function(f){return f.buffer},uint8array:d,nodebuffer:function(f){return s.newBufferFrom(f)}},E.nodebuffer={string:x,array:function(f){return p(f,new Array(f.length))},arraybuffer:function(f){return E.nodebuffer.uint8array(f).buffer},uint8array:function(f){return p(f,new Uint8Array(f.length))},nodebuffer:d},i.transformTo=function(f,b){if(b=b||"",!f)return b;i.checkSupport(f);var m=i.getTypeOf(b);return E[m][f](b)},i.resolve=function(f){for(var b=f.split("/"),m=[],h=0;h<b.length;h++){var S=b[h];S==="."||S===""&&h!==0&&h!==b.length-1||(S===".."?m.pop():m.push(S))}return m.join("/")},i.getTypeOf=function(f){return typeof f=="string"?"string":Object.prototype.toString.call(f)==="[object Array]"?"array":o.nodebuffer&&s.isBuffer(f)?"nodebuffer":o.uint8array&&f instanceof Uint8Array?"uint8array":o.arraybuffer&&f instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(f){if(!o[f.toLowerCase()])throw new Error(f+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(f){var b,m,h="";for(m=0;m<(f||"").length;m++)h+="\\x"+((b=f.charCodeAt(m))<16?"0":"")+b.toString(16).toUpperCase();return h},i.delay=function(f,b,m){setImmediate(function(){f.apply(m||null,b||[])})},i.inherits=function(f,b){function m(){}m.prototype=b.prototype,f.prototype=new m},i.extend=function(){var f,b,m={};for(f=0;f<arguments.length;f++)for(b in arguments[f])Object.prototype.hasOwnProperty.call(arguments[f],b)&&m[b]===void 0&&(m[b]=arguments[f][b]);return m},i.prepareContent=function(f,b,m,h,S){return u.Promise.resolve(b).then(function(v){return o.blob&&(v instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(v))!==-1)&&typeof FileReader<"u"?new u.Promise(function(O,D){var M=new FileReader;M.onload=function(F){O(F.target.result)},M.onerror=function(F){D(F.target.error)},M.readAsArrayBuffer(v)}):v}).then(function(v){var O=i.getTypeOf(v);return O?(O==="arraybuffer"?v=i.transformTo("uint8array",v):O==="string"&&(S?v=a.decode(v):m&&h!==!0&&(v=(function(D){return _(D,o.uint8array?new Uint8Array(D.length):new Array(D.length))})(v))),v):u.Promise.reject(new Error("Can't read the data of '"+f+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var o=n("./reader/readerFor"),a=n("./utils"),s=n("./signature"),u=n("./zipEntry"),d=n("./support");function _(g){this.files=[],this.loadOptions=g}_.prototype={checkSignature:function(g){if(!this.reader.readAndCheckSignature(g)){this.reader.index-=4;var x=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(x)+", expected "+a.pretty(g)+")")}},isSignature:function(g,x){var p=this.reader.index;this.reader.setIndex(g);var E=this.reader.readString(4)===x;return this.reader.setIndex(p),E},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var g=this.reader.readData(this.zipCommentLength),x=d.uint8array?"uint8array":"array",p=a.transformTo(x,g);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var g,x,p,E=this.zip64EndOfCentralSize-44;0<E;)g=this.reader.readInt(2),x=this.reader.readInt(4),p=this.reader.readData(x),this.zip64ExtensibleData[g]={id:g,length:x,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var g,x;for(g=0;g<this.files.length;g++)x=this.files[g],this.reader.setIndex(x.localHeaderOffset),this.checkSignature(s.LOCAL_FILE_HEADER),x.readLocalPart(this.reader),x.handleUTF8(),x.processAttributes()},readCentralDir:function(){var g;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(s.CENTRAL_FILE_HEADER);)(g=new u({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(g);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var g=this.reader.lastIndexOfSignature(s.CENTRAL_DIRECTORY_END);if(g<0)throw this.isSignature(0,s.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(g);var x=g;if(this.checkSignature(s.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(g=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(g),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,s.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var E=x-p;if(0<E)this.isSignature(x,s.CENTRAL_FILE_HEADER)||(this.reader.zero=E);else if(E<0)throw new Error("Corrupted zip: missing "+Math.abs(E)+" bytes.")},prepareReader:function(g){this.reader=o(g)},load:function(g){this.prepareReader(g),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=_},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var o=n("./reader/readerFor"),a=n("./utils"),s=n("./compressedObject"),u=n("./crc32"),d=n("./utf8"),_=n("./compressions"),g=n("./support");function x(p,E){this.options=p,this.loadOptions=E}x.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var E,f;if(p.skip(22),this.fileNameLength=p.readInt(2),f=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(f),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((E=(function(b){for(var m in _)if(Object.prototype.hasOwnProperty.call(_,m)&&_[m].magic===b)return _[m];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new s(this.compressedSize,this.uncompressedSize,this.crc32,E,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var E=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(E),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=o(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var E,f,b,m=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<m;)E=p.readInt(2),f=p.readInt(2),b=p.readData(f),this.extraFields[E]={id:E,length:f,value:b};p.setIndex(m)},handleUTF8:function(){var p=g.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=d.utf8decode(this.fileName),this.fileCommentStr=d.utf8decode(this.fileComment);else{var E=this.findExtraFieldUnicodePath();if(E!==null)this.fileNameStr=E;else{var f=a.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(f)}var b=this.findExtraFieldUnicodeComment();if(b!==null)this.fileCommentStr=b;else{var m=a.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(m)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var E=o(p.value);return E.readInt(1)!==1||u(this.fileName)!==E.readInt(4)?null:d.utf8decode(E.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var E=o(p.value);return E.readInt(1)!==1||u(this.fileComment)!==E.readInt(4)?null:d.utf8decode(E.readData(p.length-5))}return null}},r.exports=x},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function o(E,f,b){this.name=E,this.dir=b.dir,this.date=b.date,this.comment=b.comment,this.unixPermissions=b.unixPermissions,this.dosPermissions=b.dosPermissions,this._data=f,this._dataBinary=b.binary,this.options={compression:b.compression,compressionOptions:b.compressionOptions}}var a=n("./stream/StreamHelper"),s=n("./stream/DataWorker"),u=n("./utf8"),d=n("./compressedObject"),_=n("./stream/GenericWorker");o.prototype={internalStream:function(E){var f=null,b="string";try{if(!E)throw new Error("No output type specified.");var m=(b=E.toLowerCase())==="string"||b==="text";b!=="binarystring"&&b!=="text"||(b="string"),f=this._decompressWorker();var h=!this._dataBinary;h&&!m&&(f=f.pipe(new u.Utf8EncodeWorker)),!h&&m&&(f=f.pipe(new u.Utf8DecodeWorker))}catch(S){(f=new _("error")).error(S)}return new a(f,b,"")},async:function(E,f){return this.internalStream(E).accumulate(f)},nodeStream:function(E,f){return this.internalStream(E||"nodebuffer").toNodejsStream(f)},_compressWorker:function(E,f){if(this._data instanceof d&&this._data.compression.magic===E.magic)return this._data.getCompressedWorker();var b=this._decompressWorker();return this._dataBinary||(b=b.pipe(new u.Utf8EncodeWorker)),d.createWorkerFrom(b,E,f)},_decompressWorker:function(){return this._data instanceof d?this._data.getContentWorker():this._data instanceof _?this._data:new s(this._data)}};for(var g=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],x=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<g.length;p++)o.prototype[g[p]]=x;r.exports=o},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(o){var a,s,u=o.MutationObserver||o.WebKitMutationObserver;if(u){var d=0,_=new u(E),g=o.document.createTextNode("");_.observe(g,{characterData:!0}),a=function(){g.data=d=++d%2}}else if(o.setImmediate||o.MessageChannel===void 0)a="document"in o&&"onreadystatechange"in o.document.createElement("script")?function(){var f=o.document.createElement("script");f.onreadystatechange=function(){E(),f.onreadystatechange=null,f.parentNode.removeChild(f),f=null},o.document.documentElement.appendChild(f)}:function(){setTimeout(E,0)};else{var x=new o.MessageChannel;x.port1.onmessage=E,a=function(){x.port2.postMessage(0)}}var p=[];function E(){var f,b;s=!0;for(var m=p.length;m;){for(b=p,p=[],f=-1;++f<m;)b[f]();m=p.length}s=!1}r.exports=function(f){p.push(f)!==1||s||a()}}).call(this,typeof ot<"u"?ot:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var o=n("immediate");function a(){}var s={},u=["REJECTED"],d=["FULFILLED"],_=["PENDING"];function g(m){if(typeof m!="function")throw new TypeError("resolver must be a function");this.state=_,this.queue=[],this.outcome=void 0,m!==a&&f(this,m)}function x(m,h,S){this.promise=m,typeof h=="function"&&(this.onFulfilled=h,this.callFulfilled=this.otherCallFulfilled),typeof S=="function"&&(this.onRejected=S,this.callRejected=this.otherCallRejected)}function p(m,h,S){o(function(){var v;try{v=h(S)}catch(O){return s.reject(m,O)}v===m?s.reject(m,new TypeError("Cannot resolve promise with itself")):s.resolve(m,v)})}function E(m){var h=m&&m.then;if(m&&(typeof m=="object"||typeof m=="function")&&typeof h=="function")return function(){h.apply(m,arguments)}}function f(m,h){var S=!1;function v(M){S||(S=!0,s.reject(m,M))}function O(M){S||(S=!0,s.resolve(m,M))}var D=b(function(){h(O,v)});D.status==="error"&&v(D.value)}function b(m,h){var S={};try{S.value=m(h),S.status="success"}catch(v){S.status="error",S.value=v}return S}(r.exports=g).prototype.finally=function(m){if(typeof m!="function")return this;var h=this.constructor;return this.then(function(S){return h.resolve(m()).then(function(){return S})},function(S){return h.resolve(m()).then(function(){throw S})})},g.prototype.catch=function(m){return this.then(null,m)},g.prototype.then=function(m,h){if(typeof m!="function"&&this.state===d||typeof h!="function"&&this.state===u)return this;var S=new this.constructor(a);return this.state!==_?p(S,this.state===d?m:h,this.outcome):this.queue.push(new x(S,m,h)),S},x.prototype.callFulfilled=function(m){s.resolve(this.promise,m)},x.prototype.otherCallFulfilled=function(m){p(this.promise,this.onFulfilled,m)},x.prototype.callRejected=function(m){s.reject(this.promise,m)},x.prototype.otherCallRejected=function(m){p(this.promise,this.onRejected,m)},s.resolve=function(m,h){var S=b(E,h);if(S.status==="error")return s.reject(m,S.value);var v=S.value;if(v)f(m,v);else{m.state=d,m.outcome=h;for(var O=-1,D=m.queue.length;++O<D;)m.queue[O].callFulfilled(h)}return m},s.reject=function(m,h){m.state=u,m.outcome=h;for(var S=-1,v=m.queue.length;++S<v;)m.queue[S].callRejected(h);return m},g.resolve=function(m){return m instanceof this?m:s.resolve(new this(a),m)},g.reject=function(m){var h=new this(a);return s.reject(h,m)},g.all=function(m){var h=this;if(Object.prototype.toString.call(m)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=m.length,v=!1;if(!S)return this.resolve([]);for(var O=new Array(S),D=0,M=-1,F=new this(a);++M<S;)T(m[M],M);return F;function T(G,te){h.resolve(G).then(function(I){O[te]=I,++D!==S||v||(v=!0,s.resolve(F,O))},function(I){v||(v=!0,s.reject(F,I))})}},g.race=function(m){var h=this;if(Object.prototype.toString.call(m)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=m.length,v=!1;if(!S)return this.resolve([]);for(var O=-1,D=new this(a);++O<S;)M=m[O],h.resolve(M).then(function(F){v||(v=!0,s.resolve(D,F))},function(F){v||(v=!0,s.reject(D,F))});var M;return D}},{immediate:36}],38:[function(n,r,i){var o={};(0,n("./lib/utils/common").assign)(o,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=o},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var o=n("./zlib/deflate"),a=n("./utils/common"),s=n("./utils/strings"),u=n("./zlib/messages"),d=n("./zlib/zstream"),_=Object.prototype.toString,g=0,x=-1,p=0,E=8;function f(m){if(!(this instanceof f))return new f(m);this.options=a.assign({level:x,method:E,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},m||{});var h=this.options;h.raw&&0<h.windowBits?h.windowBits=-h.windowBits:h.gzip&&0<h.windowBits&&h.windowBits<16&&(h.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var S=o.deflateInit2(this.strm,h.level,h.method,h.windowBits,h.memLevel,h.strategy);if(S!==g)throw new Error(u[S]);if(h.header&&o.deflateSetHeader(this.strm,h.header),h.dictionary){var v;if(v=typeof h.dictionary=="string"?s.string2buf(h.dictionary):_.call(h.dictionary)==="[object ArrayBuffer]"?new Uint8Array(h.dictionary):h.dictionary,(S=o.deflateSetDictionary(this.strm,v))!==g)throw new Error(u[S]);this._dict_set=!0}}function b(m,h){var S=new f(h);if(S.push(m,!0),S.err)throw S.msg||u[S.err];return S.result}f.prototype.push=function(m,h){var S,v,O=this.strm,D=this.options.chunkSize;if(this.ended)return!1;v=h===~~h?h:h===!0?4:0,typeof m=="string"?O.input=s.string2buf(m):_.call(m)==="[object ArrayBuffer]"?O.input=new Uint8Array(m):O.input=m,O.next_in=0,O.avail_in=O.input.length;do{if(O.avail_out===0&&(O.output=new a.Buf8(D),O.next_out=0,O.avail_out=D),(S=o.deflate(O,v))!==1&&S!==g)return this.onEnd(S),!(this.ended=!0);O.avail_out!==0&&(O.avail_in!==0||v!==4&&v!==2)||(this.options.to==="string"?this.onData(s.buf2binstring(a.shrinkBuf(O.output,O.next_out))):this.onData(a.shrinkBuf(O.output,O.next_out)))}while((0<O.avail_in||O.avail_out===0)&&S!==1);return v===4?(S=o.deflateEnd(this.strm),this.onEnd(S),this.ended=!0,S===g):v!==2||(this.onEnd(g),!(O.avail_out=0))},f.prototype.onData=function(m){this.chunks.push(m)},f.prototype.onEnd=function(m){m===g&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},i.Deflate=f,i.deflate=b,i.deflateRaw=function(m,h){return(h=h||{}).raw=!0,b(m,h)},i.gzip=function(m,h){return(h=h||{}).gzip=!0,b(m,h)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var o=n("./zlib/inflate"),a=n("./utils/common"),s=n("./utils/strings"),u=n("./zlib/constants"),d=n("./zlib/messages"),_=n("./zlib/zstream"),g=n("./zlib/gzheader"),x=Object.prototype.toString;function p(f){if(!(this instanceof p))return new p(f);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},f||{});var b=this.options;b.raw&&0<=b.windowBits&&b.windowBits<16&&(b.windowBits=-b.windowBits,b.windowBits===0&&(b.windowBits=-15)),!(0<=b.windowBits&&b.windowBits<16)||f&&f.windowBits||(b.windowBits+=32),15<b.windowBits&&b.windowBits<48&&(15&b.windowBits)==0&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new _,this.strm.avail_out=0;var m=o.inflateInit2(this.strm,b.windowBits);if(m!==u.Z_OK)throw new Error(d[m]);this.header=new g,o.inflateGetHeader(this.strm,this.header)}function E(f,b){var m=new p(b);if(m.push(f,!0),m.err)throw m.msg||d[m.err];return m.result}p.prototype.push=function(f,b){var m,h,S,v,O,D,M=this.strm,F=this.options.chunkSize,T=this.options.dictionary,G=!1;if(this.ended)return!1;h=b===~~b?b:b===!0?u.Z_FINISH:u.Z_NO_FLUSH,typeof f=="string"?M.input=s.binstring2buf(f):x.call(f)==="[object ArrayBuffer]"?M.input=new Uint8Array(f):M.input=f,M.next_in=0,M.avail_in=M.input.length;do{if(M.avail_out===0&&(M.output=new a.Buf8(F),M.next_out=0,M.avail_out=F),(m=o.inflate(M,u.Z_NO_FLUSH))===u.Z_NEED_DICT&&T&&(D=typeof T=="string"?s.string2buf(T):x.call(T)==="[object ArrayBuffer]"?new Uint8Array(T):T,m=o.inflateSetDictionary(this.strm,D)),m===u.Z_BUF_ERROR&&G===!0&&(m=u.Z_OK,G=!1),m!==u.Z_STREAM_END&&m!==u.Z_OK)return this.onEnd(m),!(this.ended=!0);M.next_out&&(M.avail_out!==0&&m!==u.Z_STREAM_END&&(M.avail_in!==0||h!==u.Z_FINISH&&h!==u.Z_SYNC_FLUSH)||(this.options.to==="string"?(S=s.utf8border(M.output,M.next_out),v=M.next_out-S,O=s.buf2string(M.output,S),M.next_out=v,M.avail_out=F-v,v&&a.arraySet(M.output,M.output,S,v,0),this.onData(O)):this.onData(a.shrinkBuf(M.output,M.next_out)))),M.avail_in===0&&M.avail_out===0&&(G=!0)}while((0<M.avail_in||M.avail_out===0)&&m!==u.Z_STREAM_END);return m===u.Z_STREAM_END&&(h=u.Z_FINISH),h===u.Z_FINISH?(m=o.inflateEnd(this.strm),this.onEnd(m),this.ended=!0,m===u.Z_OK):h!==u.Z_SYNC_FLUSH||(this.onEnd(u.Z_OK),!(M.avail_out=0))},p.prototype.onData=function(f){this.chunks.push(f)},p.prototype.onEnd=function(f){f===u.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg},i.Inflate=p,i.inflate=E,i.inflateRaw=function(f,b){return(b=b||{}).raw=!0,E(f,b)},i.ungzip=E},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(u){for(var d=Array.prototype.slice.call(arguments,1);d.length;){var _=d.shift();if(_){if(typeof _!="object")throw new TypeError(_+"must be non-object");for(var g in _)_.hasOwnProperty(g)&&(u[g]=_[g])}}return u},i.shrinkBuf=function(u,d){return u.length===d?u:u.subarray?u.subarray(0,d):(u.length=d,u)};var a={arraySet:function(u,d,_,g,x){if(d.subarray&&u.subarray)u.set(d.subarray(_,_+g),x);else for(var p=0;p<g;p++)u[x+p]=d[_+p]},flattenChunks:function(u){var d,_,g,x,p,E;for(d=g=0,_=u.length;d<_;d++)g+=u[d].length;for(E=new Uint8Array(g),d=x=0,_=u.length;d<_;d++)p=u[d],E.set(p,x),x+=p.length;return E}},s={arraySet:function(u,d,_,g,x){for(var p=0;p<g;p++)u[x+p]=d[_+p]},flattenChunks:function(u){return[].concat.apply([],u)}};i.setTyped=function(u){u?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,a)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,s))},i.setTyped(o)},{}],42:[function(n,r,i){var o=n("./common"),a=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{s=!1}for(var u=new o.Buf8(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;function _(g,x){if(x<65537&&(g.subarray&&s||!g.subarray&&a))return String.fromCharCode.apply(null,o.shrinkBuf(g,x));for(var p="",E=0;E<x;E++)p+=String.fromCharCode(g[E]);return p}u[254]=u[254]=1,i.string2buf=function(g){var x,p,E,f,b,m=g.length,h=0;for(f=0;f<m;f++)(64512&(p=g.charCodeAt(f)))==55296&&f+1<m&&(64512&(E=g.charCodeAt(f+1)))==56320&&(p=65536+(p-55296<<10)+(E-56320),f++),h+=p<128?1:p<2048?2:p<65536?3:4;for(x=new o.Buf8(h),f=b=0;b<h;f++)(64512&(p=g.charCodeAt(f)))==55296&&f+1<m&&(64512&(E=g.charCodeAt(f+1)))==56320&&(p=65536+(p-55296<<10)+(E-56320),f++),p<128?x[b++]=p:(p<2048?x[b++]=192|p>>>6:(p<65536?x[b++]=224|p>>>12:(x[b++]=240|p>>>18,x[b++]=128|p>>>12&63),x[b++]=128|p>>>6&63),x[b++]=128|63&p);return x},i.buf2binstring=function(g){return _(g,g.length)},i.binstring2buf=function(g){for(var x=new o.Buf8(g.length),p=0,E=x.length;p<E;p++)x[p]=g.charCodeAt(p);return x},i.buf2string=function(g,x){var p,E,f,b,m=x||g.length,h=new Array(2*m);for(p=E=0;p<m;)if((f=g[p++])<128)h[E++]=f;else if(4<(b=u[f]))h[E++]=65533,p+=b-1;else{for(f&=b===2?31:b===3?15:7;1<b&&p<m;)f=f<<6|63&g[p++],b--;1<b?h[E++]=65533:f<65536?h[E++]=f:(f-=65536,h[E++]=55296|f>>10&1023,h[E++]=56320|1023&f)}return _(h,E)},i.utf8border=function(g,x){var p;for((x=x||g.length)>g.length&&(x=g.length),p=x-1;0<=p&&(192&g[p])==128;)p--;return p<0||p===0?x:p+u[g[p]]>x?p:x}},{"./common":41}],43:[function(n,r,i){r.exports=function(o,a,s,u){for(var d=65535&o|0,_=o>>>16&65535|0,g=0;s!==0;){for(s-=g=2e3<s?2e3:s;_=_+(d=d+a[u++]|0)|0,--g;);d%=65521,_%=65521}return d|_<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var o=(function(){for(var a,s=[],u=0;u<256;u++){a=u;for(var d=0;d<8;d++)a=1&a?3988292384^a>>>1:a>>>1;s[u]=a}return s})();r.exports=function(a,s,u,d){var _=o,g=d+u;a^=-1;for(var x=d;x<g;x++)a=a>>>8^_[255&(a^s[x])];return-1^a}},{}],46:[function(n,r,i){var o,a=n("../utils/common"),s=n("./trees"),u=n("./adler32"),d=n("./crc32"),_=n("./messages"),g=0,x=4,p=0,E=-2,f=-1,b=4,m=2,h=8,S=9,v=286,O=30,D=19,M=2*v+1,F=15,T=3,G=258,te=G+T+1,I=42,j=113,c=1,U=2,N=3,z=4;function q(l,$){return l.msg=_[$],$}function B(l){return(l<<1)-(4<l?9:0)}function J(l){for(var $=l.length;0<=--$;)l[$]=0}function A(l){var $=l.state,P=$.pending;P>l.avail_out&&(P=l.avail_out),P!==0&&(a.arraySet(l.output,$.pending_buf,$.pending_out,P,l.next_out),l.next_out+=P,$.pending_out+=P,l.total_out+=P,l.avail_out-=P,$.pending-=P,$.pending===0&&($.pending_out=0))}function R(l,$){s._tr_flush_block(l,0<=l.block_start?l.block_start:-1,l.strstart-l.block_start,$),l.block_start=l.strstart,A(l.strm)}function Y(l,$){l.pending_buf[l.pending++]=$}function V(l,$){l.pending_buf[l.pending++]=$>>>8&255,l.pending_buf[l.pending++]=255&$}function W(l,$){var P,w,y=l.max_chain_length,k=l.strstart,H=l.prev_length,Z=l.nice_match,C=l.strstart>l.w_size-te?l.strstart-(l.w_size-te):0,X=l.window,Q=l.w_mask,K=l.prev,ne=l.strstart+G,de=X[k+H-1],ue=X[k+H];l.prev_length>=l.good_match&&(y>>=2),Z>l.lookahead&&(Z=l.lookahead);do if(X[(P=$)+H]===ue&&X[P+H-1]===de&&X[P]===X[k]&&X[++P]===X[k+1]){k+=2,P++;do;while(X[++k]===X[++P]&&X[++k]===X[++P]&&X[++k]===X[++P]&&X[++k]===X[++P]&&X[++k]===X[++P]&&X[++k]===X[++P]&&X[++k]===X[++P]&&X[++k]===X[++P]&&k<ne);if(w=G-(ne-k),k=ne-G,H<w){if(l.match_start=$,Z<=(H=w))break;de=X[k+H-1],ue=X[k+H]}}while(($=K[$&Q])>C&&--y!=0);return H<=l.lookahead?H:l.lookahead}function ae(l){var $,P,w,y,k,H,Z,C,X,Q,K=l.w_size;do{if(y=l.window_size-l.lookahead-l.strstart,l.strstart>=K+(K-te)){for(a.arraySet(l.window,l.window,K,K,0),l.match_start-=K,l.strstart-=K,l.block_start-=K,$=P=l.hash_size;w=l.head[--$],l.head[$]=K<=w?w-K:0,--P;);for($=P=K;w=l.prev[--$],l.prev[$]=K<=w?w-K:0,--P;);y+=K}if(l.strm.avail_in===0)break;if(H=l.strm,Z=l.window,C=l.strstart+l.lookahead,X=y,Q=void 0,Q=H.avail_in,X<Q&&(Q=X),P=Q===0?0:(H.avail_in-=Q,a.arraySet(Z,H.input,H.next_in,Q,C),H.state.wrap===1?H.adler=u(H.adler,Z,Q,C):H.state.wrap===2&&(H.adler=d(H.adler,Z,Q,C)),H.next_in+=Q,H.total_in+=Q,Q),l.lookahead+=P,l.lookahead+l.insert>=T)for(k=l.strstart-l.insert,l.ins_h=l.window[k],l.ins_h=(l.ins_h<<l.hash_shift^l.window[k+1])&l.hash_mask;l.insert&&(l.ins_h=(l.ins_h<<l.hash_shift^l.window[k+T-1])&l.hash_mask,l.prev[k&l.w_mask]=l.head[l.ins_h],l.head[l.ins_h]=k,k++,l.insert--,!(l.lookahead+l.insert<T)););}while(l.lookahead<te&&l.strm.avail_in!==0)}function ie(l,$){for(var P,w;;){if(l.lookahead<te){if(ae(l),l.lookahead<te&&$===g)return c;if(l.lookahead===0)break}if(P=0,l.lookahead>=T&&(l.ins_h=(l.ins_h<<l.hash_shift^l.window[l.strstart+T-1])&l.hash_mask,P=l.prev[l.strstart&l.w_mask]=l.head[l.ins_h],l.head[l.ins_h]=l.strstart),P!==0&&l.strstart-P<=l.w_size-te&&(l.match_length=W(l,P)),l.match_length>=T)if(w=s._tr_tally(l,l.strstart-l.match_start,l.match_length-T),l.lookahead-=l.match_length,l.match_length<=l.max_lazy_match&&l.lookahead>=T){for(l.match_length--;l.strstart++,l.ins_h=(l.ins_h<<l.hash_shift^l.window[l.strstart+T-1])&l.hash_mask,P=l.prev[l.strstart&l.w_mask]=l.head[l.ins_h],l.head[l.ins_h]=l.strstart,--l.match_length!=0;);l.strstart++}else l.strstart+=l.match_length,l.match_length=0,l.ins_h=l.window[l.strstart],l.ins_h=(l.ins_h<<l.hash_shift^l.window[l.strstart+1])&l.hash_mask;else w=s._tr_tally(l,0,l.window[l.strstart]),l.lookahead--,l.strstart++;if(w&&(R(l,!1),l.strm.avail_out===0))return c}return l.insert=l.strstart<T-1?l.strstart:T-1,$===x?(R(l,!0),l.strm.avail_out===0?N:z):l.last_lit&&(R(l,!1),l.strm.avail_out===0)?c:U}function re(l,$){for(var P,w,y;;){if(l.lookahead<te){if(ae(l),l.lookahead<te&&$===g)return c;if(l.lookahead===0)break}if(P=0,l.lookahead>=T&&(l.ins_h=(l.ins_h<<l.hash_shift^l.window[l.strstart+T-1])&l.hash_mask,P=l.prev[l.strstart&l.w_mask]=l.head[l.ins_h],l.head[l.ins_h]=l.strstart),l.prev_length=l.match_length,l.prev_match=l.match_start,l.match_length=T-1,P!==0&&l.prev_length<l.max_lazy_match&&l.strstart-P<=l.w_size-te&&(l.match_length=W(l,P),l.match_length<=5&&(l.strategy===1||l.match_length===T&&4096<l.strstart-l.match_start)&&(l.match_length=T-1)),l.prev_length>=T&&l.match_length<=l.prev_length){for(y=l.strstart+l.lookahead-T,w=s._tr_tally(l,l.strstart-1-l.prev_match,l.prev_length-T),l.lookahead-=l.prev_length-1,l.prev_length-=2;++l.strstart<=y&&(l.ins_h=(l.ins_h<<l.hash_shift^l.window[l.strstart+T-1])&l.hash_mask,P=l.prev[l.strstart&l.w_mask]=l.head[l.ins_h],l.head[l.ins_h]=l.strstart),--l.prev_length!=0;);if(l.match_available=0,l.match_length=T-1,l.strstart++,w&&(R(l,!1),l.strm.avail_out===0))return c}else if(l.match_available){if((w=s._tr_tally(l,0,l.window[l.strstart-1]))&&R(l,!1),l.strstart++,l.lookahead--,l.strm.avail_out===0)return c}else l.match_available=1,l.strstart++,l.lookahead--}return l.match_available&&(w=s._tr_tally(l,0,l.window[l.strstart-1]),l.match_available=0),l.insert=l.strstart<T-1?l.strstart:T-1,$===x?(R(l,!0),l.strm.avail_out===0?N:z):l.last_lit&&(R(l,!1),l.strm.avail_out===0)?c:U}function se(l,$,P,w,y){this.good_length=l,this.max_lazy=$,this.nice_length=P,this.max_chain=w,this.func=y}function ce(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=h,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*M),this.dyn_dtree=new a.Buf16(2*(2*O+1)),this.bl_tree=new a.Buf16(2*(2*D+1)),J(this.dyn_ltree),J(this.dyn_dtree),J(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(F+1),this.heap=new a.Buf16(2*v+1),J(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*v+1),J(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function pe(l){var $;return l&&l.state?(l.total_in=l.total_out=0,l.data_type=m,($=l.state).pending=0,$.pending_out=0,$.wrap<0&&($.wrap=-$.wrap),$.status=$.wrap?I:j,l.adler=$.wrap===2?0:1,$.last_flush=g,s._tr_init($),p):q(l,E)}function fe(l){var $=pe(l);return $===p&&(function(P){P.window_size=2*P.w_size,J(P.head),P.max_lazy_match=o[P.level].max_lazy,P.good_match=o[P.level].good_length,P.nice_match=o[P.level].nice_length,P.max_chain_length=o[P.level].max_chain,P.strstart=0,P.block_start=0,P.lookahead=0,P.insert=0,P.match_length=P.prev_length=T-1,P.match_available=0,P.ins_h=0})(l.state),$}function ge(l,$,P,w,y,k){if(!l)return E;var H=1;if($===f&&($=6),w<0?(H=0,w=-w):15<w&&(H=2,w-=16),y<1||S<y||P!==h||w<8||15<w||$<0||9<$||k<0||b<k)return q(l,E);w===8&&(w=9);var Z=new ce;return(l.state=Z).strm=l,Z.wrap=H,Z.gzhead=null,Z.w_bits=w,Z.w_size=1<<Z.w_bits,Z.w_mask=Z.w_size-1,Z.hash_bits=y+7,Z.hash_size=1<<Z.hash_bits,Z.hash_mask=Z.hash_size-1,Z.hash_shift=~~((Z.hash_bits+T-1)/T),Z.window=new a.Buf8(2*Z.w_size),Z.head=new a.Buf16(Z.hash_size),Z.prev=new a.Buf16(Z.w_size),Z.lit_bufsize=1<<y+6,Z.pending_buf_size=4*Z.lit_bufsize,Z.pending_buf=new a.Buf8(Z.pending_buf_size),Z.d_buf=1*Z.lit_bufsize,Z.l_buf=3*Z.lit_bufsize,Z.level=$,Z.strategy=k,Z.method=P,fe(l)}o=[new se(0,0,0,0,function(l,$){var P=65535;for(P>l.pending_buf_size-5&&(P=l.pending_buf_size-5);;){if(l.lookahead<=1){if(ae(l),l.lookahead===0&&$===g)return c;if(l.lookahead===0)break}l.strstart+=l.lookahead,l.lookahead=0;var w=l.block_start+P;if((l.strstart===0||l.strstart>=w)&&(l.lookahead=l.strstart-w,l.strstart=w,R(l,!1),l.strm.avail_out===0)||l.strstart-l.block_start>=l.w_size-te&&(R(l,!1),l.strm.avail_out===0))return c}return l.insert=0,$===x?(R(l,!0),l.strm.avail_out===0?N:z):(l.strstart>l.block_start&&(R(l,!1),l.strm.avail_out),c)}),new se(4,4,8,4,ie),new se(4,5,16,8,ie),new se(4,6,32,32,ie),new se(4,4,16,16,re),new se(8,16,32,32,re),new se(8,16,128,128,re),new se(8,32,128,256,re),new se(32,128,258,1024,re),new se(32,258,258,4096,re)],i.deflateInit=function(l,$){return ge(l,$,h,15,8,0)},i.deflateInit2=ge,i.deflateReset=fe,i.deflateResetKeep=pe,i.deflateSetHeader=function(l,$){return l&&l.state?l.state.wrap!==2?E:(l.state.gzhead=$,p):E},i.deflate=function(l,$){var P,w,y,k;if(!l||!l.state||5<$||$<0)return l?q(l,E):E;if(w=l.state,!l.output||!l.input&&l.avail_in!==0||w.status===666&&$!==x)return q(l,l.avail_out===0?-5:E);if(w.strm=l,P=w.last_flush,w.last_flush=$,w.status===I)if(w.wrap===2)l.adler=0,Y(w,31),Y(w,139),Y(w,8),w.gzhead?(Y(w,(w.gzhead.text?1:0)+(w.gzhead.hcrc?2:0)+(w.gzhead.extra?4:0)+(w.gzhead.name?8:0)+(w.gzhead.comment?16:0)),Y(w,255&w.gzhead.time),Y(w,w.gzhead.time>>8&255),Y(w,w.gzhead.time>>16&255),Y(w,w.gzhead.time>>24&255),Y(w,w.level===9?2:2<=w.strategy||w.level<2?4:0),Y(w,255&w.gzhead.os),w.gzhead.extra&&w.gzhead.extra.length&&(Y(w,255&w.gzhead.extra.length),Y(w,w.gzhead.extra.length>>8&255)),w.gzhead.hcrc&&(l.adler=d(l.adler,w.pending_buf,w.pending,0)),w.gzindex=0,w.status=69):(Y(w,0),Y(w,0),Y(w,0),Y(w,0),Y(w,0),Y(w,w.level===9?2:2<=w.strategy||w.level<2?4:0),Y(w,3),w.status=j);else{var H=h+(w.w_bits-8<<4)<<8;H|=(2<=w.strategy||w.level<2?0:w.level<6?1:w.level===6?2:3)<<6,w.strstart!==0&&(H|=32),H+=31-H%31,w.status=j,V(w,H),w.strstart!==0&&(V(w,l.adler>>>16),V(w,65535&l.adler)),l.adler=1}if(w.status===69)if(w.gzhead.extra){for(y=w.pending;w.gzindex<(65535&w.gzhead.extra.length)&&(w.pending!==w.pending_buf_size||(w.gzhead.hcrc&&w.pending>y&&(l.adler=d(l.adler,w.pending_buf,w.pending-y,y)),A(l),y=w.pending,w.pending!==w.pending_buf_size));)Y(w,255&w.gzhead.extra[w.gzindex]),w.gzindex++;w.gzhead.hcrc&&w.pending>y&&(l.adler=d(l.adler,w.pending_buf,w.pending-y,y)),w.gzindex===w.gzhead.extra.length&&(w.gzindex=0,w.status=73)}else w.status=73;if(w.status===73)if(w.gzhead.name){y=w.pending;do{if(w.pending===w.pending_buf_size&&(w.gzhead.hcrc&&w.pending>y&&(l.adler=d(l.adler,w.pending_buf,w.pending-y,y)),A(l),y=w.pending,w.pending===w.pending_buf_size)){k=1;break}k=w.gzindex<w.gzhead.name.length?255&w.gzhead.name.charCodeAt(w.gzindex++):0,Y(w,k)}while(k!==0);w.gzhead.hcrc&&w.pending>y&&(l.adler=d(l.adler,w.pending_buf,w.pending-y,y)),k===0&&(w.gzindex=0,w.status=91)}else w.status=91;if(w.status===91)if(w.gzhead.comment){y=w.pending;do{if(w.pending===w.pending_buf_size&&(w.gzhead.hcrc&&w.pending>y&&(l.adler=d(l.adler,w.pending_buf,w.pending-y,y)),A(l),y=w.pending,w.pending===w.pending_buf_size)){k=1;break}k=w.gzindex<w.gzhead.comment.length?255&w.gzhead.comment.charCodeAt(w.gzindex++):0,Y(w,k)}while(k!==0);w.gzhead.hcrc&&w.pending>y&&(l.adler=d(l.adler,w.pending_buf,w.pending-y,y)),k===0&&(w.status=103)}else w.status=103;if(w.status===103&&(w.gzhead.hcrc?(w.pending+2>w.pending_buf_size&&A(l),w.pending+2<=w.pending_buf_size&&(Y(w,255&l.adler),Y(w,l.adler>>8&255),l.adler=0,w.status=j)):w.status=j),w.pending!==0){if(A(l),l.avail_out===0)return w.last_flush=-1,p}else if(l.avail_in===0&&B($)<=B(P)&&$!==x)return q(l,-5);if(w.status===666&&l.avail_in!==0)return q(l,-5);if(l.avail_in!==0||w.lookahead!==0||$!==g&&w.status!==666){var Z=w.strategy===2?(function(C,X){for(var Q;;){if(C.lookahead===0&&(ae(C),C.lookahead===0)){if(X===g)return c;break}if(C.match_length=0,Q=s._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++,Q&&(R(C,!1),C.strm.avail_out===0))return c}return C.insert=0,X===x?(R(C,!0),C.strm.avail_out===0?N:z):C.last_lit&&(R(C,!1),C.strm.avail_out===0)?c:U})(w,$):w.strategy===3?(function(C,X){for(var Q,K,ne,de,ue=C.window;;){if(C.lookahead<=G){if(ae(C),C.lookahead<=G&&X===g)return c;if(C.lookahead===0)break}if(C.match_length=0,C.lookahead>=T&&0<C.strstart&&(K=ue[ne=C.strstart-1])===ue[++ne]&&K===ue[++ne]&&K===ue[++ne]){de=C.strstart+G;do;while(K===ue[++ne]&&K===ue[++ne]&&K===ue[++ne]&&K===ue[++ne]&&K===ue[++ne]&&K===ue[++ne]&&K===ue[++ne]&&K===ue[++ne]&&ne<de);C.match_length=G-(de-ne),C.match_length>C.lookahead&&(C.match_length=C.lookahead)}if(C.match_length>=T?(Q=s._tr_tally(C,1,C.match_length-T),C.lookahead-=C.match_length,C.strstart+=C.match_length,C.match_length=0):(Q=s._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++),Q&&(R(C,!1),C.strm.avail_out===0))return c}return C.insert=0,X===x?(R(C,!0),C.strm.avail_out===0?N:z):C.last_lit&&(R(C,!1),C.strm.avail_out===0)?c:U})(w,$):o[w.level].func(w,$);if(Z!==N&&Z!==z||(w.status=666),Z===c||Z===N)return l.avail_out===0&&(w.last_flush=-1),p;if(Z===U&&($===1?s._tr_align(w):$!==5&&(s._tr_stored_block(w,0,0,!1),$===3&&(J(w.head),w.lookahead===0&&(w.strstart=0,w.block_start=0,w.insert=0))),A(l),l.avail_out===0))return w.last_flush=-1,p}return $!==x?p:w.wrap<=0?1:(w.wrap===2?(Y(w,255&l.adler),Y(w,l.adler>>8&255),Y(w,l.adler>>16&255),Y(w,l.adler>>24&255),Y(w,255&l.total_in),Y(w,l.total_in>>8&255),Y(w,l.total_in>>16&255),Y(w,l.total_in>>24&255)):(V(w,l.adler>>>16),V(w,65535&l.adler)),A(l),0<w.wrap&&(w.wrap=-w.wrap),w.pending!==0?p:1)},i.deflateEnd=function(l){var $;return l&&l.state?($=l.state.status)!==I&&$!==69&&$!==73&&$!==91&&$!==103&&$!==j&&$!==666?q(l,E):(l.state=null,$===j?q(l,-3):p):E},i.deflateSetDictionary=function(l,$){var P,w,y,k,H,Z,C,X,Q=$.length;if(!l||!l.state||(k=(P=l.state).wrap)===2||k===1&&P.status!==I||P.lookahead)return E;for(k===1&&(l.adler=u(l.adler,$,Q,0)),P.wrap=0,Q>=P.w_size&&(k===0&&(J(P.head),P.strstart=0,P.block_start=0,P.insert=0),X=new a.Buf8(P.w_size),a.arraySet(X,$,Q-P.w_size,P.w_size,0),$=X,Q=P.w_size),H=l.avail_in,Z=l.next_in,C=l.input,l.avail_in=Q,l.next_in=0,l.input=$,ae(P);P.lookahead>=T;){for(w=P.strstart,y=P.lookahead-(T-1);P.ins_h=(P.ins_h<<P.hash_shift^P.window[w+T-1])&P.hash_mask,P.prev[w&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=w,w++,--y;);P.strstart=w,P.lookahead=T-1,ae(P)}return P.strstart+=P.lookahead,P.block_start=P.strstart,P.insert=P.lookahead,P.lookahead=0,P.match_length=P.prev_length=T-1,P.match_available=0,l.next_in=Z,l.input=C,l.avail_in=H,P.wrap=k,p},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(o,a){var s,u,d,_,g,x,p,E,f,b,m,h,S,v,O,D,M,F,T,G,te,I,j,c,U;s=o.state,u=o.next_in,c=o.input,d=u+(o.avail_in-5),_=o.next_out,U=o.output,g=_-(a-o.avail_out),x=_+(o.avail_out-257),p=s.dmax,E=s.wsize,f=s.whave,b=s.wnext,m=s.window,h=s.hold,S=s.bits,v=s.lencode,O=s.distcode,D=(1<<s.lenbits)-1,M=(1<<s.distbits)-1;e:do{S<15&&(h+=c[u++]<<S,S+=8,h+=c[u++]<<S,S+=8),F=v[h&D];t:for(;;){if(h>>>=T=F>>>24,S-=T,(T=F>>>16&255)===0)U[_++]=65535&F;else{if(!(16&T)){if((64&T)==0){F=v[(65535&F)+(h&(1<<T)-1)];continue t}if(32&T){s.mode=12;break e}o.msg="invalid literal/length code",s.mode=30;break e}G=65535&F,(T&=15)&&(S<T&&(h+=c[u++]<<S,S+=8),G+=h&(1<<T)-1,h>>>=T,S-=T),S<15&&(h+=c[u++]<<S,S+=8,h+=c[u++]<<S,S+=8),F=O[h&M];n:for(;;){if(h>>>=T=F>>>24,S-=T,!(16&(T=F>>>16&255))){if((64&T)==0){F=O[(65535&F)+(h&(1<<T)-1)];continue n}o.msg="invalid distance code",s.mode=30;break e}if(te=65535&F,S<(T&=15)&&(h+=c[u++]<<S,(S+=8)<T&&(h+=c[u++]<<S,S+=8)),p<(te+=h&(1<<T)-1)){o.msg="invalid distance too far back",s.mode=30;break e}if(h>>>=T,S-=T,(T=_-g)<te){if(f<(T=te-T)&&s.sane){o.msg="invalid distance too far back",s.mode=30;break e}if(j=m,(I=0)===b){if(I+=E-T,T<G){for(G-=T;U[_++]=m[I++],--T;);I=_-te,j=U}}else if(b<T){if(I+=E+b-T,(T-=b)<G){for(G-=T;U[_++]=m[I++],--T;);if(I=0,b<G){for(G-=T=b;U[_++]=m[I++],--T;);I=_-te,j=U}}}else if(I+=b-T,T<G){for(G-=T;U[_++]=m[I++],--T;);I=_-te,j=U}for(;2<G;)U[_++]=j[I++],U[_++]=j[I++],U[_++]=j[I++],G-=3;G&&(U[_++]=j[I++],1<G&&(U[_++]=j[I++]))}else{for(I=_-te;U[_++]=U[I++],U[_++]=U[I++],U[_++]=U[I++],2<(G-=3););G&&(U[_++]=U[I++],1<G&&(U[_++]=U[I++]))}break}}break}}while(u<d&&_<x);u-=G=S>>3,h&=(1<<(S-=G<<3))-1,o.next_in=u,o.next_out=_,o.avail_in=u<d?d-u+5:5-(u-d),o.avail_out=_<x?x-_+257:257-(_-x),s.hold=h,s.bits=S}},{}],49:[function(n,r,i){var o=n("../utils/common"),a=n("./adler32"),s=n("./crc32"),u=n("./inffast"),d=n("./inftrees"),_=1,g=2,x=0,p=-2,E=1,f=852,b=592;function m(I){return(I>>>24&255)+(I>>>8&65280)+((65280&I)<<8)+((255&I)<<24)}function h(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function S(I){var j;return I&&I.state?(j=I.state,I.total_in=I.total_out=j.total=0,I.msg="",j.wrap&&(I.adler=1&j.wrap),j.mode=E,j.last=0,j.havedict=0,j.dmax=32768,j.head=null,j.hold=0,j.bits=0,j.lencode=j.lendyn=new o.Buf32(f),j.distcode=j.distdyn=new o.Buf32(b),j.sane=1,j.back=-1,x):p}function v(I){var j;return I&&I.state?((j=I.state).wsize=0,j.whave=0,j.wnext=0,S(I)):p}function O(I,j){var c,U;return I&&I.state?(U=I.state,j<0?(c=0,j=-j):(c=1+(j>>4),j<48&&(j&=15)),j&&(j<8||15<j)?p:(U.window!==null&&U.wbits!==j&&(U.window=null),U.wrap=c,U.wbits=j,v(I))):p}function D(I,j){var c,U;return I?(U=new h,(I.state=U).window=null,(c=O(I,j))!==x&&(I.state=null),c):p}var M,F,T=!0;function G(I){if(T){var j;for(M=new o.Buf32(512),F=new o.Buf32(32),j=0;j<144;)I.lens[j++]=8;for(;j<256;)I.lens[j++]=9;for(;j<280;)I.lens[j++]=7;for(;j<288;)I.lens[j++]=8;for(d(_,I.lens,0,288,M,0,I.work,{bits:9}),j=0;j<32;)I.lens[j++]=5;d(g,I.lens,0,32,F,0,I.work,{bits:5}),T=!1}I.lencode=M,I.lenbits=9,I.distcode=F,I.distbits=5}function te(I,j,c,U){var N,z=I.state;return z.window===null&&(z.wsize=1<<z.wbits,z.wnext=0,z.whave=0,z.window=new o.Buf8(z.wsize)),U>=z.wsize?(o.arraySet(z.window,j,c-z.wsize,z.wsize,0),z.wnext=0,z.whave=z.wsize):(U<(N=z.wsize-z.wnext)&&(N=U),o.arraySet(z.window,j,c-U,N,z.wnext),(U-=N)?(o.arraySet(z.window,j,c-U,U,0),z.wnext=U,z.whave=z.wsize):(z.wnext+=N,z.wnext===z.wsize&&(z.wnext=0),z.whave<z.wsize&&(z.whave+=N))),0}i.inflateReset=v,i.inflateReset2=O,i.inflateResetKeep=S,i.inflateInit=function(I){return D(I,15)},i.inflateInit2=D,i.inflate=function(I,j){var c,U,N,z,q,B,J,A,R,Y,V,W,ae,ie,re,se,ce,pe,fe,ge,l,$,P,w,y=0,k=new o.Buf8(4),H=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!I||!I.state||!I.output||!I.input&&I.avail_in!==0)return p;(c=I.state).mode===12&&(c.mode=13),q=I.next_out,N=I.output,J=I.avail_out,z=I.next_in,U=I.input,B=I.avail_in,A=c.hold,R=c.bits,Y=B,V=J,$=x;e:for(;;)switch(c.mode){case E:if(c.wrap===0){c.mode=13;break}for(;R<16;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}if(2&c.wrap&&A===35615){k[c.check=0]=255&A,k[1]=A>>>8&255,c.check=s(c.check,k,2,0),R=A=0,c.mode=2;break}if(c.flags=0,c.head&&(c.head.done=!1),!(1&c.wrap)||(((255&A)<<8)+(A>>8))%31){I.msg="incorrect header check",c.mode=30;break}if((15&A)!=8){I.msg="unknown compression method",c.mode=30;break}if(R-=4,l=8+(15&(A>>>=4)),c.wbits===0)c.wbits=l;else if(l>c.wbits){I.msg="invalid window size",c.mode=30;break}c.dmax=1<<l,I.adler=c.check=1,c.mode=512&A?10:12,R=A=0;break;case 2:for(;R<16;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}if(c.flags=A,(255&c.flags)!=8){I.msg="unknown compression method",c.mode=30;break}if(57344&c.flags){I.msg="unknown header flags set",c.mode=30;break}c.head&&(c.head.text=A>>8&1),512&c.flags&&(k[0]=255&A,k[1]=A>>>8&255,c.check=s(c.check,k,2,0)),R=A=0,c.mode=3;case 3:for(;R<32;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}c.head&&(c.head.time=A),512&c.flags&&(k[0]=255&A,k[1]=A>>>8&255,k[2]=A>>>16&255,k[3]=A>>>24&255,c.check=s(c.check,k,4,0)),R=A=0,c.mode=4;case 4:for(;R<16;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}c.head&&(c.head.xflags=255&A,c.head.os=A>>8),512&c.flags&&(k[0]=255&A,k[1]=A>>>8&255,c.check=s(c.check,k,2,0)),R=A=0,c.mode=5;case 5:if(1024&c.flags){for(;R<16;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}c.length=A,c.head&&(c.head.extra_len=A),512&c.flags&&(k[0]=255&A,k[1]=A>>>8&255,c.check=s(c.check,k,2,0)),R=A=0}else c.head&&(c.head.extra=null);c.mode=6;case 6:if(1024&c.flags&&(B<(W=c.length)&&(W=B),W&&(c.head&&(l=c.head.extra_len-c.length,c.head.extra||(c.head.extra=new Array(c.head.extra_len)),o.arraySet(c.head.extra,U,z,W,l)),512&c.flags&&(c.check=s(c.check,U,W,z)),B-=W,z+=W,c.length-=W),c.length))break e;c.length=0,c.mode=7;case 7:if(2048&c.flags){if(B===0)break e;for(W=0;l=U[z+W++],c.head&&l&&c.length<65536&&(c.head.name+=String.fromCharCode(l)),l&&W<B;);if(512&c.flags&&(c.check=s(c.check,U,W,z)),B-=W,z+=W,l)break e}else c.head&&(c.head.name=null);c.length=0,c.mode=8;case 8:if(4096&c.flags){if(B===0)break e;for(W=0;l=U[z+W++],c.head&&l&&c.length<65536&&(c.head.comment+=String.fromCharCode(l)),l&&W<B;);if(512&c.flags&&(c.check=s(c.check,U,W,z)),B-=W,z+=W,l)break e}else c.head&&(c.head.comment=null);c.mode=9;case 9:if(512&c.flags){for(;R<16;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}if(A!==(65535&c.check)){I.msg="header crc mismatch",c.mode=30;break}R=A=0}c.head&&(c.head.hcrc=c.flags>>9&1,c.head.done=!0),I.adler=c.check=0,c.mode=12;break;case 10:for(;R<32;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}I.adler=c.check=m(A),R=A=0,c.mode=11;case 11:if(c.havedict===0)return I.next_out=q,I.avail_out=J,I.next_in=z,I.avail_in=B,c.hold=A,c.bits=R,2;I.adler=c.check=1,c.mode=12;case 12:if(j===5||j===6)break e;case 13:if(c.last){A>>>=7&R,R-=7&R,c.mode=27;break}for(;R<3;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}switch(c.last=1&A,R-=1,3&(A>>>=1)){case 0:c.mode=14;break;case 1:if(G(c),c.mode=20,j!==6)break;A>>>=2,R-=2;break e;case 2:c.mode=17;break;case 3:I.msg="invalid block type",c.mode=30}A>>>=2,R-=2;break;case 14:for(A>>>=7&R,R-=7&R;R<32;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}if((65535&A)!=(A>>>16^65535)){I.msg="invalid stored block lengths",c.mode=30;break}if(c.length=65535&A,R=A=0,c.mode=15,j===6)break e;case 15:c.mode=16;case 16:if(W=c.length){if(B<W&&(W=B),J<W&&(W=J),W===0)break e;o.arraySet(N,U,z,W,q),B-=W,z+=W,J-=W,q+=W,c.length-=W;break}c.mode=12;break;case 17:for(;R<14;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}if(c.nlen=257+(31&A),A>>>=5,R-=5,c.ndist=1+(31&A),A>>>=5,R-=5,c.ncode=4+(15&A),A>>>=4,R-=4,286<c.nlen||30<c.ndist){I.msg="too many length or distance symbols",c.mode=30;break}c.have=0,c.mode=18;case 18:for(;c.have<c.ncode;){for(;R<3;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}c.lens[H[c.have++]]=7&A,A>>>=3,R-=3}for(;c.have<19;)c.lens[H[c.have++]]=0;if(c.lencode=c.lendyn,c.lenbits=7,P={bits:c.lenbits},$=d(0,c.lens,0,19,c.lencode,0,c.work,P),c.lenbits=P.bits,$){I.msg="invalid code lengths set",c.mode=30;break}c.have=0,c.mode=19;case 19:for(;c.have<c.nlen+c.ndist;){for(;se=(y=c.lencode[A&(1<<c.lenbits)-1])>>>16&255,ce=65535&y,!((re=y>>>24)<=R);){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}if(ce<16)A>>>=re,R-=re,c.lens[c.have++]=ce;else{if(ce===16){for(w=re+2;R<w;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}if(A>>>=re,R-=re,c.have===0){I.msg="invalid bit length repeat",c.mode=30;break}l=c.lens[c.have-1],W=3+(3&A),A>>>=2,R-=2}else if(ce===17){for(w=re+3;R<w;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}R-=re,l=0,W=3+(7&(A>>>=re)),A>>>=3,R-=3}else{for(w=re+7;R<w;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}R-=re,l=0,W=11+(127&(A>>>=re)),A>>>=7,R-=7}if(c.have+W>c.nlen+c.ndist){I.msg="invalid bit length repeat",c.mode=30;break}for(;W--;)c.lens[c.have++]=l}}if(c.mode===30)break;if(c.lens[256]===0){I.msg="invalid code -- missing end-of-block",c.mode=30;break}if(c.lenbits=9,P={bits:c.lenbits},$=d(_,c.lens,0,c.nlen,c.lencode,0,c.work,P),c.lenbits=P.bits,$){I.msg="invalid literal/lengths set",c.mode=30;break}if(c.distbits=6,c.distcode=c.distdyn,P={bits:c.distbits},$=d(g,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,P),c.distbits=P.bits,$){I.msg="invalid distances set",c.mode=30;break}if(c.mode=20,j===6)break e;case 20:c.mode=21;case 21:if(6<=B&&258<=J){I.next_out=q,I.avail_out=J,I.next_in=z,I.avail_in=B,c.hold=A,c.bits=R,u(I,V),q=I.next_out,N=I.output,J=I.avail_out,z=I.next_in,U=I.input,B=I.avail_in,A=c.hold,R=c.bits,c.mode===12&&(c.back=-1);break}for(c.back=0;se=(y=c.lencode[A&(1<<c.lenbits)-1])>>>16&255,ce=65535&y,!((re=y>>>24)<=R);){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}if(se&&(240&se)==0){for(pe=re,fe=se,ge=ce;se=(y=c.lencode[ge+((A&(1<<pe+fe)-1)>>pe)])>>>16&255,ce=65535&y,!(pe+(re=y>>>24)<=R);){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}A>>>=pe,R-=pe,c.back+=pe}if(A>>>=re,R-=re,c.back+=re,c.length=ce,se===0){c.mode=26;break}if(32&se){c.back=-1,c.mode=12;break}if(64&se){I.msg="invalid literal/length code",c.mode=30;break}c.extra=15&se,c.mode=22;case 22:if(c.extra){for(w=c.extra;R<w;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}c.length+=A&(1<<c.extra)-1,A>>>=c.extra,R-=c.extra,c.back+=c.extra}c.was=c.length,c.mode=23;case 23:for(;se=(y=c.distcode[A&(1<<c.distbits)-1])>>>16&255,ce=65535&y,!((re=y>>>24)<=R);){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}if((240&se)==0){for(pe=re,fe=se,ge=ce;se=(y=c.distcode[ge+((A&(1<<pe+fe)-1)>>pe)])>>>16&255,ce=65535&y,!(pe+(re=y>>>24)<=R);){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}A>>>=pe,R-=pe,c.back+=pe}if(A>>>=re,R-=re,c.back+=re,64&se){I.msg="invalid distance code",c.mode=30;break}c.offset=ce,c.extra=15&se,c.mode=24;case 24:if(c.extra){for(w=c.extra;R<w;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}c.offset+=A&(1<<c.extra)-1,A>>>=c.extra,R-=c.extra,c.back+=c.extra}if(c.offset>c.dmax){I.msg="invalid distance too far back",c.mode=30;break}c.mode=25;case 25:if(J===0)break e;if(W=V-J,c.offset>W){if((W=c.offset-W)>c.whave&&c.sane){I.msg="invalid distance too far back",c.mode=30;break}ae=W>c.wnext?(W-=c.wnext,c.wsize-W):c.wnext-W,W>c.length&&(W=c.length),ie=c.window}else ie=N,ae=q-c.offset,W=c.length;for(J<W&&(W=J),J-=W,c.length-=W;N[q++]=ie[ae++],--W;);c.length===0&&(c.mode=21);break;case 26:if(J===0)break e;N[q++]=c.length,J--,c.mode=21;break;case 27:if(c.wrap){for(;R<32;){if(B===0)break e;B--,A|=U[z++]<<R,R+=8}if(V-=J,I.total_out+=V,c.total+=V,V&&(I.adler=c.check=c.flags?s(c.check,N,V,q-V):a(c.check,N,V,q-V)),V=J,(c.flags?A:m(A))!==c.check){I.msg="incorrect data check",c.mode=30;break}R=A=0}c.mode=28;case 28:if(c.wrap&&c.flags){for(;R<32;){if(B===0)break e;B--,A+=U[z++]<<R,R+=8}if(A!==(4294967295&c.total)){I.msg="incorrect length check",c.mode=30;break}R=A=0}c.mode=29;case 29:$=1;break e;case 30:$=-3;break e;case 31:return-4;case 32:default:return p}return I.next_out=q,I.avail_out=J,I.next_in=z,I.avail_in=B,c.hold=A,c.bits=R,(c.wsize||V!==I.avail_out&&c.mode<30&&(c.mode<27||j!==4))&&te(I,I.output,I.next_out,V-I.avail_out)?(c.mode=31,-4):(Y-=I.avail_in,V-=I.avail_out,I.total_in+=Y,I.total_out+=V,c.total+=V,c.wrap&&V&&(I.adler=c.check=c.flags?s(c.check,N,V,I.next_out-V):a(c.check,N,V,I.next_out-V)),I.data_type=c.bits+(c.last?64:0)+(c.mode===12?128:0)+(c.mode===20||c.mode===15?256:0),(Y==0&&V===0||j===4)&&$===x&&($=-5),$)},i.inflateEnd=function(I){if(!I||!I.state)return p;var j=I.state;return j.window&&(j.window=null),I.state=null,x},i.inflateGetHeader=function(I,j){var c;return I&&I.state?(2&(c=I.state).wrap)==0?p:((c.head=j).done=!1,x):p},i.inflateSetDictionary=function(I,j){var c,U=j.length;return I&&I.state?(c=I.state).wrap!==0&&c.mode!==11?p:c.mode===11&&a(1,j,U,0)!==c.check?-3:te(I,j,U,U)?(c.mode=31,-4):(c.havedict=1,x):p},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var o=n("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],s=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],u=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],d=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(_,g,x,p,E,f,b,m){var h,S,v,O,D,M,F,T,G,te=m.bits,I=0,j=0,c=0,U=0,N=0,z=0,q=0,B=0,J=0,A=0,R=null,Y=0,V=new o.Buf16(16),W=new o.Buf16(16),ae=null,ie=0;for(I=0;I<=15;I++)V[I]=0;for(j=0;j<p;j++)V[g[x+j]]++;for(N=te,U=15;1<=U&&V[U]===0;U--);if(U<N&&(N=U),U===0)return E[f++]=20971520,E[f++]=20971520,m.bits=1,0;for(c=1;c<U&&V[c]===0;c++);for(N<c&&(N=c),I=B=1;I<=15;I++)if(B<<=1,(B-=V[I])<0)return-1;if(0<B&&(_===0||U!==1))return-1;for(W[1]=0,I=1;I<15;I++)W[I+1]=W[I]+V[I];for(j=0;j<p;j++)g[x+j]!==0&&(b[W[g[x+j]]++]=j);if(M=_===0?(R=ae=b,19):_===1?(R=a,Y-=257,ae=s,ie-=257,256):(R=u,ae=d,-1),I=c,D=f,q=j=A=0,v=-1,O=(J=1<<(z=N))-1,_===1&&852<J||_===2&&592<J)return 1;for(;;){for(F=I-q,G=b[j]<M?(T=0,b[j]):b[j]>M?(T=ae[ie+b[j]],R[Y+b[j]]):(T=96,0),h=1<<I-q,c=S=1<<z;E[D+(A>>q)+(S-=h)]=F<<24|T<<16|G|0,S!==0;);for(h=1<<I-1;A&h;)h>>=1;if(h!==0?(A&=h-1,A+=h):A=0,j++,--V[I]==0){if(I===U)break;I=g[x+b[j]]}if(N<I&&(A&O)!==v){for(q===0&&(q=N),D+=c,B=1<<(z=I-q);z+q<U&&!((B-=V[z+q])<=0);)z++,B<<=1;if(J+=1<<z,_===1&&852<J||_===2&&592<J)return 1;E[v=A&O]=N<<24|z<<16|D-f|0}}return A!==0&&(E[D+A]=I-q<<24|64<<16|0),m.bits=N,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var o=n("../utils/common"),a=0,s=1;function u(y){for(var k=y.length;0<=--k;)y[k]=0}var d=0,_=29,g=256,x=g+1+_,p=30,E=19,f=2*x+1,b=15,m=16,h=7,S=256,v=16,O=17,D=18,M=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],F=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],G=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],te=new Array(2*(x+2));u(te);var I=new Array(2*p);u(I);var j=new Array(512);u(j);var c=new Array(256);u(c);var U=new Array(_);u(U);var N,z,q,B=new Array(p);function J(y,k,H,Z,C){this.static_tree=y,this.extra_bits=k,this.extra_base=H,this.elems=Z,this.max_length=C,this.has_stree=y&&y.length}function A(y,k){this.dyn_tree=y,this.max_code=0,this.stat_desc=k}function R(y){return y<256?j[y]:j[256+(y>>>7)]}function Y(y,k){y.pending_buf[y.pending++]=255&k,y.pending_buf[y.pending++]=k>>>8&255}function V(y,k,H){y.bi_valid>m-H?(y.bi_buf|=k<<y.bi_valid&65535,Y(y,y.bi_buf),y.bi_buf=k>>m-y.bi_valid,y.bi_valid+=H-m):(y.bi_buf|=k<<y.bi_valid&65535,y.bi_valid+=H)}function W(y,k,H){V(y,H[2*k],H[2*k+1])}function ae(y,k){for(var H=0;H|=1&y,y>>>=1,H<<=1,0<--k;);return H>>>1}function ie(y,k,H){var Z,C,X=new Array(b+1),Q=0;for(Z=1;Z<=b;Z++)X[Z]=Q=Q+H[Z-1]<<1;for(C=0;C<=k;C++){var K=y[2*C+1];K!==0&&(y[2*C]=ae(X[K]++,K))}}function re(y){var k;for(k=0;k<x;k++)y.dyn_ltree[2*k]=0;for(k=0;k<p;k++)y.dyn_dtree[2*k]=0;for(k=0;k<E;k++)y.bl_tree[2*k]=0;y.dyn_ltree[2*S]=1,y.opt_len=y.static_len=0,y.last_lit=y.matches=0}function se(y){8<y.bi_valid?Y(y,y.bi_buf):0<y.bi_valid&&(y.pending_buf[y.pending++]=y.bi_buf),y.bi_buf=0,y.bi_valid=0}function ce(y,k,H,Z){var C=2*k,X=2*H;return y[C]<y[X]||y[C]===y[X]&&Z[k]<=Z[H]}function pe(y,k,H){for(var Z=y.heap[H],C=H<<1;C<=y.heap_len&&(C<y.heap_len&&ce(k,y.heap[C+1],y.heap[C],y.depth)&&C++,!ce(k,Z,y.heap[C],y.depth));)y.heap[H]=y.heap[C],H=C,C<<=1;y.heap[H]=Z}function fe(y,k,H){var Z,C,X,Q,K=0;if(y.last_lit!==0)for(;Z=y.pending_buf[y.d_buf+2*K]<<8|y.pending_buf[y.d_buf+2*K+1],C=y.pending_buf[y.l_buf+K],K++,Z===0?W(y,C,k):(W(y,(X=c[C])+g+1,k),(Q=M[X])!==0&&V(y,C-=U[X],Q),W(y,X=R(--Z),H),(Q=F[X])!==0&&V(y,Z-=B[X],Q)),K<y.last_lit;);W(y,S,k)}function ge(y,k){var H,Z,C,X=k.dyn_tree,Q=k.stat_desc.static_tree,K=k.stat_desc.has_stree,ne=k.stat_desc.elems,de=-1;for(y.heap_len=0,y.heap_max=f,H=0;H<ne;H++)X[2*H]!==0?(y.heap[++y.heap_len]=de=H,y.depth[H]=0):X[2*H+1]=0;for(;y.heap_len<2;)X[2*(C=y.heap[++y.heap_len]=de<2?++de:0)]=1,y.depth[C]=0,y.opt_len--,K&&(y.static_len-=Q[2*C+1]);for(k.max_code=de,H=y.heap_len>>1;1<=H;H--)pe(y,X,H);for(C=ne;H=y.heap[1],y.heap[1]=y.heap[y.heap_len--],pe(y,X,1),Z=y.heap[1],y.heap[--y.heap_max]=H,y.heap[--y.heap_max]=Z,X[2*C]=X[2*H]+X[2*Z],y.depth[C]=(y.depth[H]>=y.depth[Z]?y.depth[H]:y.depth[Z])+1,X[2*H+1]=X[2*Z+1]=C,y.heap[1]=C++,pe(y,X,1),2<=y.heap_len;);y.heap[--y.heap_max]=y.heap[1],(function(ue,we){var We,xe,He,he,rt,Et,Ae=we.dyn_tree,Ht=we.max_code,xr=we.stat_desc.static_tree,vr=we.stat_desc.has_stree,Ir=we.stat_desc.extra_bits,Zt=we.stat_desc.extra_base,Ze=we.stat_desc.max_length,it=0;for(he=0;he<=b;he++)ue.bl_count[he]=0;for(Ae[2*ue.heap[ue.heap_max]+1]=0,We=ue.heap_max+1;We<f;We++)Ze<(he=Ae[2*Ae[2*(xe=ue.heap[We])+1]+1]+1)&&(he=Ze,it++),Ae[2*xe+1]=he,Ht<xe||(ue.bl_count[he]++,rt=0,Zt<=xe&&(rt=Ir[xe-Zt]),Et=Ae[2*xe],ue.opt_len+=Et*(he+rt),vr&&(ue.static_len+=Et*(xr[2*xe+1]+rt)));if(it!==0){do{for(he=Ze-1;ue.bl_count[he]===0;)he--;ue.bl_count[he]--,ue.bl_count[he+1]+=2,ue.bl_count[Ze]--,it-=2}while(0<it);for(he=Ze;he!==0;he--)for(xe=ue.bl_count[he];xe!==0;)Ht<(He=ue.heap[--We])||(Ae[2*He+1]!==he&&(ue.opt_len+=(he-Ae[2*He+1])*Ae[2*He],Ae[2*He+1]=he),xe--)}})(y,k),ie(X,de,y.bl_count)}function l(y,k,H){var Z,C,X=-1,Q=k[1],K=0,ne=7,de=4;for(Q===0&&(ne=138,de=3),k[2*(H+1)+1]=65535,Z=0;Z<=H;Z++)C=Q,Q=k[2*(Z+1)+1],++K<ne&&C===Q||(K<de?y.bl_tree[2*C]+=K:C!==0?(C!==X&&y.bl_tree[2*C]++,y.bl_tree[2*v]++):K<=10?y.bl_tree[2*O]++:y.bl_tree[2*D]++,X=C,de=(K=0)===Q?(ne=138,3):C===Q?(ne=6,3):(ne=7,4))}function $(y,k,H){var Z,C,X=-1,Q=k[1],K=0,ne=7,de=4;for(Q===0&&(ne=138,de=3),Z=0;Z<=H;Z++)if(C=Q,Q=k[2*(Z+1)+1],!(++K<ne&&C===Q)){if(K<de)for(;W(y,C,y.bl_tree),--K!=0;);else C!==0?(C!==X&&(W(y,C,y.bl_tree),K--),W(y,v,y.bl_tree),V(y,K-3,2)):K<=10?(W(y,O,y.bl_tree),V(y,K-3,3)):(W(y,D,y.bl_tree),V(y,K-11,7));X=C,de=(K=0)===Q?(ne=138,3):C===Q?(ne=6,3):(ne=7,4)}}u(B);var P=!1;function w(y,k,H,Z){V(y,(d<<1)+(Z?1:0),3),(function(C,X,Q,K){se(C),Y(C,Q),Y(C,~Q),o.arraySet(C.pending_buf,C.window,X,Q,C.pending),C.pending+=Q})(y,k,H)}i._tr_init=function(y){P||((function(){var k,H,Z,C,X,Q=new Array(b+1);for(C=Z=0;C<_-1;C++)for(U[C]=Z,k=0;k<1<<M[C];k++)c[Z++]=C;for(c[Z-1]=C,C=X=0;C<16;C++)for(B[C]=X,k=0;k<1<<F[C];k++)j[X++]=C;for(X>>=7;C<p;C++)for(B[C]=X<<7,k=0;k<1<<F[C]-7;k++)j[256+X++]=C;for(H=0;H<=b;H++)Q[H]=0;for(k=0;k<=143;)te[2*k+1]=8,k++,Q[8]++;for(;k<=255;)te[2*k+1]=9,k++,Q[9]++;for(;k<=279;)te[2*k+1]=7,k++,Q[7]++;for(;k<=287;)te[2*k+1]=8,k++,Q[8]++;for(ie(te,x+1,Q),k=0;k<p;k++)I[2*k+1]=5,I[2*k]=ae(k,5);N=new J(te,M,g+1,x,b),z=new J(I,F,0,p,b),q=new J(new Array(0),T,0,E,h)})(),P=!0),y.l_desc=new A(y.dyn_ltree,N),y.d_desc=new A(y.dyn_dtree,z),y.bl_desc=new A(y.bl_tree,q),y.bi_buf=0,y.bi_valid=0,re(y)},i._tr_stored_block=w,i._tr_flush_block=function(y,k,H,Z){var C,X,Q=0;0<y.level?(y.strm.data_type===2&&(y.strm.data_type=(function(K){var ne,de=4093624447;for(ne=0;ne<=31;ne++,de>>>=1)if(1&de&&K.dyn_ltree[2*ne]!==0)return a;if(K.dyn_ltree[18]!==0||K.dyn_ltree[20]!==0||K.dyn_ltree[26]!==0)return s;for(ne=32;ne<g;ne++)if(K.dyn_ltree[2*ne]!==0)return s;return a})(y)),ge(y,y.l_desc),ge(y,y.d_desc),Q=(function(K){var ne;for(l(K,K.dyn_ltree,K.l_desc.max_code),l(K,K.dyn_dtree,K.d_desc.max_code),ge(K,K.bl_desc),ne=E-1;3<=ne&&K.bl_tree[2*G[ne]+1]===0;ne--);return K.opt_len+=3*(ne+1)+5+5+4,ne})(y),C=y.opt_len+3+7>>>3,(X=y.static_len+3+7>>>3)<=C&&(C=X)):C=X=H+5,H+4<=C&&k!==-1?w(y,k,H,Z):y.strategy===4||X===C?(V(y,2+(Z?1:0),3),fe(y,te,I)):(V(y,4+(Z?1:0),3),(function(K,ne,de,ue){var we;for(V(K,ne-257,5),V(K,de-1,5),V(K,ue-4,4),we=0;we<ue;we++)V(K,K.bl_tree[2*G[we]+1],3);$(K,K.dyn_ltree,ne-1),$(K,K.dyn_dtree,de-1)})(y,y.l_desc.max_code+1,y.d_desc.max_code+1,Q+1),fe(y,y.dyn_ltree,y.dyn_dtree)),re(y),Z&&se(y)},i._tr_tally=function(y,k,H){return y.pending_buf[y.d_buf+2*y.last_lit]=k>>>8&255,y.pending_buf[y.d_buf+2*y.last_lit+1]=255&k,y.pending_buf[y.l_buf+y.last_lit]=255&H,y.last_lit++,k===0?y.dyn_ltree[2*H]++:(y.matches++,k--,y.dyn_ltree[2*(c[H]+g+1)]++,y.dyn_dtree[2*R(k)]++),y.last_lit===y.lit_bufsize-1},i._tr_align=function(y){V(y,2,3),W(y,S,te),(function(k){k.bi_valid===16?(Y(k,k.bi_buf),k.bi_buf=0,k.bi_valid=0):8<=k.bi_valid&&(k.pending_buf[k.pending++]=255&k.bi_buf,k.bi_buf>>=8,k.bi_valid-=8)})(y)}},{"../utils/common":41}],53:[function(n,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(o){(function(a,s){if(!a.setImmediate){var u,d,_,g,x=1,p={},E=!1,f=a.document,b=Object.getPrototypeOf&&Object.getPrototypeOf(a);b=b&&b.setTimeout?b:a,u={}.toString.call(a.process)==="[object process]"?function(v){Tr.nextTick(function(){h(v)})}:(function(){if(a.postMessage&&!a.importScripts){var v=!0,O=a.onmessage;return a.onmessage=function(){v=!1},a.postMessage("","*"),a.onmessage=O,v}})()?(g="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",S,!1):a.attachEvent("onmessage",S),function(v){a.postMessage(g+v,"*")}):a.MessageChannel?((_=new MessageChannel).port1.onmessage=function(v){h(v.data)},function(v){_.port2.postMessage(v)}):f&&"onreadystatechange"in f.createElement("script")?(d=f.documentElement,function(v){var O=f.createElement("script");O.onreadystatechange=function(){h(v),O.onreadystatechange=null,d.removeChild(O),O=null},d.appendChild(O)}):function(v){setTimeout(h,0,v)},b.setImmediate=function(v){typeof v!="function"&&(v=new Function(""+v));for(var O=new Array(arguments.length-1),D=0;D<O.length;D++)O[D]=arguments[D+1];var M={callback:v,args:O};return p[x]=M,u(x),x++},b.clearImmediate=m}function m(v){delete p[v]}function h(v){if(E)setTimeout(h,0,v);else{var O=p[v];if(O){E=!0;try{(function(D){var M=D.callback,F=D.args;switch(F.length){case 0:M();break;case 1:M(F[0]);break;case 2:M(F[0],F[1]);break;case 3:M(F[0],F[1],F[2]);break;default:M.apply(s,F)}})(O)}finally{m(v),E=!1}}}}function S(v){v.source===a&&typeof v.data=="string"&&v.data.indexOf(g)===0&&h(+v.data.slice(g.length))}})(typeof self>"u"?o===void 0?this:o:self)}).call(this,typeof ot<"u"?ot:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(wt)),wt.exports}var Bi=ji();const On=ln(Bi);function Fi(e){const t=[],n=Object.keys(e);for(const r of n){const i=e[r];if(!i)continue;const o=i.sort((s,u)=>s.index-u.index);let a=-1;for(let s=0;s<o.length;s++)a=a+1+o[s].skip,o[s].index!==a&&t.push({message:`Invalid operation index ${o[s].index} at position ${s}`,details:{position:s,operation:o[s],scope:o[s].action.scope}})}return t}function $i(e){const t=new On,n=e.header;return t.file("header.json",JSON.stringify(n,null,2)),t.file("state.json",JSON.stringify(e.initialState||{},null,2)),t.file("current-state.json",JSON.stringify(e.state||{},null,2)),t.file("operations.json",JSON.stringify(zi(e.operations),null,2)),t}async function Wi(e,t){const r=await $i(e).generateAsync({type:"blob"}),i=await t.createWritable();await i.write(r),await i.close()}async function Hi(e,t,n){const r=new On;return await r.loadAsync(e),Zi(r,t,n)}async function Zi(e,t,n){const r=e.file("state.json");if(!r)throw new Error("Initial state not found");const i=await r.async("string"),o=JSON.parse(i),a=e.file("header.json");if(!a)throw new Error("Document header not found - file format may be outdated");const s=JSON.parse(await a.async("string")),u=e.file("operations.json");if(!u)throw new Error("Operations history not found");const d=JSON.parse(await u.async("string")),_=dt(d),g=Fi(_);if(g.length){const p=g.map(E=>E.message);throw new Error(p.join(`
22
22
  `))}return En(o,_,t,s,void 0,{},n)}const me={Remove:"remove",Replace:"replace",Add:"add"},xn=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),Gi=Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"),ct=Symbol.iterator,Ee={mutable:"mutable",immutable:"immutable"},Nt={};function qe(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function qt(e,t){if(t in e){let n=Reflect.getPrototypeOf(e);for(;n;){const r=Reflect.getOwnPropertyDescriptor(n,t);if(r)return r;n=Reflect.getPrototypeOf(n)}}}function zt(e){return Object.getPrototypeOf(e)===Set.prototype}function Pt(e){return Object.getPrototypeOf(e)===Map.prototype}function ye(e){var t;return(t=e.copy)!==null&&t!==void 0?t:e.original}function Me(e){return!!le(e)}function le(e){return typeof e!="object"?null:e?.[xn]}function Lt(e){var t;const n=le(e);return n?(t=n.copy)!==null&&t!==void 0?t:n.original:e}function Oe(e,t){if(!e||typeof e!="object")return!1;let n;return Object.getPrototypeOf(e)===Object.prototype||Array.isArray(e)||e instanceof Map||e instanceof Set||!!t?.mark&&((n=t.mark(e,Ee))===Ee.immutable||typeof n=="function")}function vn(e,t=[]){if(Object.hasOwnProperty.call(e,"key")){const n=e.parent.copy,r=le(De(n,e.key));if(r!==null&&r?.original!==e.original)return null;const i=e.parent.type===3,o=i?Array.from(e.parent.setMap.keys()).indexOf(e.key):e.key;if(!(i&&n.size>o||qe(n,o)))return null;t.push(o)}if(e.parent)return vn(e.parent,t);t.reverse();try{Vi(e.copy,t)}catch{return null}return t}function Ue(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function De(e,t){return Ue(e)===2?e.get(t):e[t]}function et(e,t,n){Ue(e)===2?e.set(t,n):e[t]=n}function Ot(e,t){const n=le(e);return(n?ye(n):e)[t]}function ke(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function xt(e){if(e)for(;e.finalities.revoke.length>0;)e.finalities.revoke.pop()()}function Pe(e,t){return t?e:[""].concat(e).map(n=>{const r=`${n}`;return r.indexOf("/")===-1&&r.indexOf("~")===-1?r:r.replace(/~/g,"~0").replace(/\//g,"~1")}).join("/")}function Vi(e,t){for(let n=0;n<t.length-1;n+=1){const r=t[n];if(e=De(Ue(e)===3?Array.from(e):e,r),typeof e!="object")throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}return e}function Xi(e){const t=Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach(n=>{let r=Reflect.getOwnPropertyDescriptor(e,n);if(r.enumerable&&r.configurable&&r.writable){t[n]=e[n];return}r.writable||(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(r={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[n]}),Reflect.defineProperty(t,n,r)}),t}const Ki=Object.prototype.propertyIsEnumerable;function In(e,t){let n;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set){if(!zt(e)){const r=Object.getPrototypeOf(e).constructor;return new r(e.values())}return Set.prototype.difference?Set.prototype.difference.call(e,new Set):new Set(e.values())}else if(e instanceof Map){if(!Pt(e)){const r=Object.getPrototypeOf(e).constructor;return new r(e)}return new Map(e)}else if(t?.mark&&(n=t.mark(e,Ee),n!==void 0)&&n!==Ee.mutable){if(n===Ee.immutable)return Xi(e);if(typeof n=="function"){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return n()}throw new Error(`Unsupported mark result: ${n}`)}else if(typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype){const r={};return Object.keys(e).forEach(i=>{r[i]=e[i]}),Object.getOwnPropertySymbols(e).forEach(i=>{Ki.call(e,i)&&(r[i]=e[i])}),r}else throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function _e(e){e.copy||(e.copy=In(e.original,e.options))}function Je(e){if(!Oe(e))return Lt(e);if(Array.isArray(e))return e.map(Je);if(e instanceof Map){const n=Array.from(e.entries()).map(([r,i])=>[r,Je(i)]);if(!Pt(e)){const r=Object.getPrototypeOf(e).constructor;return new r(n)}return new Map(n)}if(e instanceof Set){const n=Array.from(e).map(Je);if(!zt(e)){const r=Object.getPrototypeOf(e).constructor;return new r(n)}return new Set(n)}const t=Object.create(Object.getPrototypeOf(e));for(const n in e)t[n]=Je(e[n]);return t}function pt(e){return Me(e)?Je(e):e}function Ie(e){var t;e.assignedMap=(t=e.assignedMap)!==null&&t!==void 0?t:new Map,e.operated||(e.operated=!0,e.parent&&Ie(e.parent))}function Yt(){throw new Error("Cannot modify frozen object")}function Fe(e,t,n,r,i){{n=n??new WeakMap,r=r??[],i=i??[];const a=n.has(e)?n.get(e):e;if(r.length>0){const s=r.indexOf(a);if(a&&typeof a=="object"&&s!==-1)throw r[0]===a?new Error("Forbids circular reference"):new Error(`Forbids circular reference: ~/${i.slice(0,s).map((u,d)=>{if(typeof u=="symbol")return`[${u.toString()}]`;const _=r[d];return typeof u=="object"&&(_ instanceof Map||_ instanceof Set)?Array.from(_.keys()).indexOf(u):u}).join("/")}`);r.push(a),i.push(t)}else r.push(a)}if(Object.isFrozen(e)||Me(e)){r.pop(),i.pop();return}switch(Ue(e)){case 2:for(const[s,u]of e)Fe(s,s,n,r,i),Fe(u,s,n,r,i);e.set=e.clear=e.delete=Yt;break;case 3:for(const s of e)Fe(s,s,n,r,i);e.add=e.clear=e.delete=Yt;break;case 1:Object.freeze(e);let a=0;for(const s of e)Fe(s,a,n,r,i),a+=1;break;default:Object.freeze(e),Object.keys(e).forEach(s=>{const u=e[s];Fe(u,s,n,r,i)})}r.pop(),i.pop()}function Ut(e,t){const n=Ue(e);if(n===0)Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)});else if(n===1){let r=0;for(const i of e)t(r,i,e),r+=1}else e.forEach((r,i)=>t(i,r,e))}function An(e,t,n){if(Me(e)||!Oe(e,n)||t.has(e)||Object.isFrozen(e))return;const r=e instanceof Set,i=r?new Map:void 0;if(t.add(e),Ut(e,(o,a)=>{var s;if(Me(a)){const u=le(a);_e(u);const d=!((s=u.assignedMap)===null||s===void 0)&&s.size||u.operated?u.copy:u.original;et(r?i:e,o,d)}else An(a,t,n)}),i){const o=e,a=Array.from(o);o.clear(),a.forEach(s=>{o.add(i.has(s)?i.get(s):s)})}}function Ji(e,t){const n=e.type===3?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&n&&An(De(n,t),e.finalities.handledSet,e.options)}function vt(e){e.type===3&&e.copy&&(e.copy.clear(),e.setMap.forEach(t=>{e.copy.add(Lt(t))}))}function It(e,t,n,r){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(n&&r){const o=vn(e);o&&t(e,o,n,r)}e.finalized=!0}}function jt(e,t,n,r){const i=le(n);i&&(i.callbacks||(i.callbacks=[]),i.callbacks.push((o,a)=>{var s;const u=e.type===3?e.setMap:e.copy;if(ke(De(u,t),n)){let d=i.original;i.copy&&(d=i.copy),vt(e),It(e,r,o,a),e.options.enableAutoFreeze&&(e.options.updatedValues=(s=e.options.updatedValues)!==null&&s!==void 0?s:new WeakMap,e.options.updatedValues.set(d,i.original)),et(u,t,d)}}),e.options.enableAutoFreeze&&i.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),Oe(n,e.options)&&e.finalities.draft.push(()=>{const o=e.type===3?e.setMap:e.copy;ke(De(o,t),n)&&Ji(e,t)})}function qi(e,t,n,r,i){let{original:o,assignedMap:a,options:s}=e,u=e.copy;u.length<o.length&&([o,u]=[u,o],[n,r]=[r,n]);for(let d=0;d<o.length;d+=1)if(a.get(d.toString())&&u[d]!==o[d]){const _=t.concat([d]),g=Pe(_,i);n.push({op:me.Replace,path:g,value:pt(u[d])}),r.push({op:me.Replace,path:g,value:pt(o[d])})}for(let d=o.length;d<u.length;d+=1){const _=t.concat([d]),g=Pe(_,i);n.push({op:me.Add,path:g,value:pt(u[d])})}if(o.length<u.length){const{arrayLengthAssignment:d=!0}=s.enablePatches;if(d){const _=t.concat(["length"]),g=Pe(_,i);r.push({op:me.Replace,path:g,value:o.length})}else for(let _=u.length;o.length<_;_-=1){const g=t.concat([_-1]),x=Pe(g,i);r.push({op:me.Remove,path:x})}}}function Yi({original:e,copy:t,assignedMap:n},r,i,o,a){n.forEach((s,u)=>{const d=De(e,u),_=pt(De(t,u)),g=s?qe(e,u)?me.Replace:me.Add:me.Remove;if(ke(d,_)&&g===me.Replace)return;const x=r.concat(u),p=Pe(x,a);i.push(g===me.Remove?{op:g,path:p}:{op:g,path:p,value:_}),o.push(g===me.Add?{op:me.Remove,path:p}:g===me.Remove?{op:me.Add,path:p,value:d}:{op:me.Replace,path:p,value:d})})}function Qi({original:e,copy:t},n,r,i,o){let a=0;e.forEach(s=>{if(!t.has(s)){const u=n.concat([a]),d=Pe(u,o);r.push({op:me.Remove,path:d,value:s}),i.unshift({op:me.Add,path:d,value:s})}a+=1}),a=0,t.forEach(s=>{if(!e.has(s)){const u=n.concat([a]),d=Pe(u,o);r.push({op:me.Add,path:d,value:s}),i.unshift({op:me.Remove,path:d,value:s})}a+=1})}function Ye(e,t,n,r){const{pathAsArray:i=!0}=e.options.enablePatches;switch(e.type){case 0:case 2:return Yi(e,t,n,r,i);case 1:return qi(e,t,n,r,i);case 3:return Qi(e,t,n,r,i)}}let At=!1;const ft=(e,t,n=!1)=>{if(typeof e=="object"&&e!==null&&(!Oe(e,t)||n)&&!At)throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")};function eo(e){At=!0;let t;try{t=e()}finally{At=!1}return t}const Rt={get size(){return ye(le(this)).size},has(e){return ye(le(this)).has(e)},set(e,t){const n=le(this),r=ye(n);return(!r.has(e)||!ke(r.get(e),t))&&(_e(n),Ie(n),n.assignedMap.set(e,!0),n.copy.set(e,t),jt(n,e,t,Ye)),this},delete(e){if(!this.has(e))return!1;const t=le(this);return _e(t),Ie(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear(){const e=le(this);if(this.size){_e(e),Ie(e),e.assignedMap=new Map;for(const[t]of e.original)e.assignedMap.set(t,!1);e.copy.clear()}},forEach(e,t){const n=le(this);ye(n).forEach((r,i)=>{e.call(t,this.get(i),i,this)})},get(e){var t,n;const r=le(this),i=ye(r).get(e),o=((n=(t=r.options).mark)===null||n===void 0?void 0:n.call(t,i,Ee))===Ee.mutable;if(r.options.strict&&ft(i,r.options,o),o||r.finalized||!Oe(i,r.options)||i!==r.original.get(e))return i;const a=Nt.createDraft({original:i,parentDraft:r,key:e,finalities:r.finalities,options:r.options});return _e(r),r.copy.set(e,a),a},keys(){return ye(le(this)).keys()},values(){const e=this.keys();return{[ct]:()=>this.values(),next:()=>{const t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const e=this.keys();return{[ct]:()=>this.entries(),next:()=>{const t=e.next();if(t.done)return t;const n=this.get(t.value);return{done:!1,value:[t.value,n]}}}},[ct](){return this.entries()}},to=Reflect.ownKeys(Rt),Qt=(e,t,{isValuesIterator:n})=>()=>{var r,i;const o=t.next();if(o.done)return o;const a=o.value;let s=e.setMap.get(a);const u=le(s),d=((i=(r=e.options).mark)===null||i===void 0?void 0:i.call(r,s,Ee))===Ee.mutable;if(e.options.strict&&ft(a,e.options,d),!d&&!u&&Oe(a,e.options)&&!e.finalized&&e.original.has(a)){const _=Nt.createDraft({original:a,parentDraft:e,key:a,finalities:e.finalities,options:e.options});e.setMap.set(a,_),s=_}else u&&(s=u.proxy);return{done:!1,value:n?s:[s,s]}},ht={get size(){return le(this).setMap.size},has(e){const t=le(this);if(t.setMap.has(e))return!0;_e(t);const n=le(e);return!!(n&&t.setMap.has(n.original))},add(e){const t=le(this);return this.has(e)||(_e(t),Ie(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),jt(t,e,e,Ye)),this},delete(e){if(!this.has(e))return!1;const t=le(this);_e(t),Ie(t);const n=le(e);return n&&t.setMap.has(n.original)?(t.assignedMap.set(n.original,!1),t.setMap.delete(n.original)):(!n&&t.setMap.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.setMap.delete(e))},clear(){if(!this.size)return;const e=le(this);_e(e),Ie(e);for(const t of e.original)e.assignedMap.set(t,!1);e.setMap.clear()},values(){const e=le(this);_e(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:Qt(e,t,{isValuesIterator:!0})}},entries(){const e=le(this);_e(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:Qt(e,t,{isValuesIterator:!1})}},keys(){return this.values()},[ct](){return this.values()},forEach(e,t){const n=this.values();let r=n.next();for(;!r.done;)e.call(t,r.value,r.value,this),r=n.next()}};Set.prototype.difference&&Object.assign(ht,{intersection(e){return Set.prototype.intersection.call(new Set(this.values()),e)},union(e){return Set.prototype.union.call(new Set(this.values()),e)},difference(e){return Set.prototype.difference.call(new Set(this.values()),e)},symmetricDifference(e){return Set.prototype.symmetricDifference.call(new Set(this.values()),e)},isSubsetOf(e){return Set.prototype.isSubsetOf.call(new Set(this.values()),e)},isSupersetOf(e){return Set.prototype.isSupersetOf.call(new Set(this.values()),e)},isDisjointFrom(e){return Set.prototype.isDisjointFrom.call(new Set(this.values()),e)}});const no=Reflect.ownKeys(ht),Rn={get(e,t,n){var r,i;const o=(r=e.copy)===null||r===void 0?void 0:r[t];if(o&&e.finalities.draftsCache.has(o))return o;if(t===xn)return e;let a;if(e.options.mark){const d=t==="size"&&(e.original instanceof Map||e.original instanceof Set)?Reflect.get(e.original,t):Reflect.get(e.original,t,n);if(a=e.options.mark(d,Ee),a===Ee.mutable)return e.options.strict&&ft(d,e.options,!0),d}const s=ye(e);if(s instanceof Map&&to.includes(t))return t==="size"?Object.getOwnPropertyDescriptor(Rt,"size").get.call(e.proxy):Rt[t].bind(e.proxy);if(s instanceof Set&&no.includes(t))return t==="size"?Object.getOwnPropertyDescriptor(ht,"size").get.call(e.proxy):ht[t].bind(e.proxy);if(!qe(s,t)){const d=qt(s,t);return d?"value"in d?d.value:(i=d.get)===null||i===void 0?void 0:i.call(e.proxy):void 0}const u=s[t];if(e.options.strict&&ft(u,e.options),e.finalized||!Oe(u,e.options))return u;if(u===Ot(e.original,t)){if(_e(e),e.copy[t]=Bt({original:e.original[t],parentDraft:e,key:e.type===1?Number(t):t,finalities:e.finalities,options:e.options}),typeof a=="function"){const d=le(e.copy[t]);return _e(d),Ie(d),d.copy}return e.copy[t]}return Me(u)&&e.finalities.draftsCache.add(u),u},set(e,t,n){var r;if(e.type===3||e.type===2)throw new Error("Map/Set draft does not support any property assignment.");let i;if(e.type===1&&t!=="length"&&!(Number.isInteger(i=Number(t))&&i>=0&&(t===0||i===0||String(i)===String(t))))throw new Error("Only supports setting array indices and the 'length' property.");const o=qt(ye(e),t);if(o?.set)return o.set.call(e.proxy,n),!0;const a=Ot(ye(e),t),s=le(a);return s&&ke(s.original,n)?(e.copy[t]=n,e.assignedMap=(r=e.assignedMap)!==null&&r!==void 0?r:new Map,e.assignedMap.set(t,!1),!0):(ke(n,a)&&(n!==void 0||qe(e.original,t))||(_e(e),Ie(e),qe(e.original,t)&&ke(n,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=n,jt(e,t,n,Ye)),!0)},has(e,t){return t in ye(e)},ownKeys(e){return Reflect.ownKeys(ye(e))},getOwnPropertyDescriptor(e,t){const n=ye(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},getPrototypeOf(e){return Reflect.getPrototypeOf(e.original)},setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(e,t){var n;return e.type===1?Rn.set.call(this,e,t,void 0,e.proxy):(Ot(e.original,t)!==void 0||t in e.original?(_e(e),Ie(e),e.assignedMap.set(t,!1)):(e.assignedMap=(n=e.assignedMap)!==null&&n!==void 0?n:new Map,e.assignedMap.delete(t)),e.copy&&delete e.copy[t],!0)}};function Bt(e){const{original:t,parentDraft:n,key:r,finalities:i,options:o}=e,a=Ue(t),s={type:a,finalized:!1,parent:n,original:t,copy:null,proxy:null,finalities:i,options:o,setMap:a===3?new Map(t.entries()):void 0};(r||"key"in e)&&(s.key=r);const{proxy:u,revoke:d}=Proxy.revocable(a===1?Object.assign([],s):s,Rn);if(i.revoke.push(d),s.proxy=u,n){const _=n;_.finalities.draft.push((g,x)=>{var p,E;const f=le(u);let b=_.type===3?_.setMap:_.copy;const m=De(b,r),h=le(m);if(h){let S=h.original;h.operated&&(S=Lt(m)),vt(h),It(h,Ye,g,x),_.options.enableAutoFreeze&&(_.options.updatedValues=(p=_.options.updatedValues)!==null&&p!==void 0?p:new WeakMap,_.options.updatedValues.set(S,h.original)),et(b,r,S)}(E=f.callbacks)===null||E===void 0||E.forEach(S=>{S(g,x)})})}else{const _=le(u);_.finalities.draft.push((g,x)=>{vt(_),It(_,Ye,g,x)})}return u}Nt.createDraft=Bt;function ro(e,t,n,r,i){var o;const a=le(e),s=(o=a?.original)!==null&&o!==void 0?o:e,u=!!t.length;if(a?.operated)for(;a.finalities.draft.length>0;)a.finalities.draft.pop()(n,r);const d=u?t[0]:a?a.operated?a.copy:a.original:e;return a&&xt(a),i&&Fe(d,d,a?.options.updatedValues),[d,n&&u?[{op:me.Replace,path:[],value:t[0]}]:n,r&&u?[{op:me.Replace,path:[],value:s}]:r]}function io(e,t){var n;const r={draft:[],revoke:[],handledSet:new WeakSet,draftsCache:new WeakSet};let i,o;t.enablePatches&&(i=[],o=[]);const s=((n=t.mark)===null||n===void 0?void 0:n.call(t,e,Ee))===Ee.mutable||!Oe(e,t)?e:Bt({original:e,parentDraft:null,finalities:r,options:t});return[s,(u=[])=>{const[d,_,g]=ro(s,u,i,o,t.enableAutoFreeze);return t.enablePatches?[d,_,g]:d}]}function kt(e){const{rootDraft:t,value:n,useRawReturn:r=!1,isRoot:i=!0}=e;Ut(n,(o,a,s)=>{const u=le(a);if(u&&t&&u.finalities===t.finalities){e.isContainDraft=!0;const d=u.original;if(s instanceof Set){const _=Array.from(s);s.clear(),_.forEach(g=>s.add(o===g?d:g))}else et(s,o,d)}else typeof a=="object"&&a!==null&&(e.value=a,e.isRoot=!1,kt(e))}),i&&(e.isContainDraft||console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."),r&&console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."))}function kn(e){var t;const n=le(e);if(!Oe(e,n?.options))return e;const r=Ue(e);if(n&&!n.operated)return n.original;let i;function o(){i=r===2?Pt(e)?new Map(e):new(Object.getPrototypeOf(e)).constructor(e):r===3?Array.from(n.setMap.values()):In(e,n?.options)}if(n){n.finalized=!0;try{o()}finally{n.finalized=!1}}else i=e;if(Ut(i,(a,s)=>{if(n&&ke(De(n.original,a),s))return;const u=kn(s);u!==s&&(i===e&&o(),et(i,a,u))}),r===3){const a=(t=n?.original)!==null&&t!==void 0?t:i;return zt(a)?new Set(i):new(Object.getPrototypeOf(a)).constructor(i)}return i}function en(e){if(!Me(e))throw new Error(`current() is only used for Draft, parameter: ${e}`);return kn(e)}const oo=e=>function t(n,r,i){var o,a,s;if(typeof n=="function"&&typeof r!="function")return function(O,...D){return t(O,M=>n.call(this,M,...D),r)};const u=n,d=r;let _=i;if(typeof r!="function"&&(_=r),_!==void 0&&Object.prototype.toString.call(_)!=="[object Object]")throw new Error(`Invalid options: ${_}, 'options' should be an object.`);_=Object.assign(Object.assign({},e),_);const g=Me(u)?en(u):u,x=Array.isArray(_.mark)?((O,D)=>{for(const M of _.mark){if(typeof M!="function")throw new Error(`Invalid mark: ${M}, 'mark' should be a function.`);const F=M(O,D);if(F)return F}}):_.mark,p=(o=_.enablePatches)!==null&&o!==void 0?o:!1,E=(a=_.strict)!==null&&a!==void 0?a:!1,b={enableAutoFreeze:(s=_.enableAutoFreeze)!==null&&s!==void 0?s:!1,mark:x,strict:E,enablePatches:p};if(!Oe(g,b)&&typeof g=="object"&&g!==null)throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");const[m,h]=io(g,b);if(typeof r!="function"){if(!Oe(g,b))throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");return[m,h]}let S;try{S=d(m)}catch(O){throw xt(le(m)),O}const v=O=>{const D=le(m);if(!Me(O)){if(O!==void 0&&!ke(O,m)&&D?.operated)throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");const F=O?.[Gi];if(F){const T=F[0];return b.strict&&typeof O=="object"&&O!==null&&kt({rootDraft:D,value:O,useRawReturn:!0}),h([T])}if(O!==void 0)return typeof O=="object"&&O!==null&&kt({rootDraft:D,value:O}),h([O])}if(O===m||O===void 0)return h([]);const M=le(O);if(b===M.options){if(M.operated)throw new Error("Cannot return a modified child draft.");return h([en(O)])}return h([O])};return S instanceof Promise?S.then(v,O=>{throw xt(le(m)),O}):v(S)},Ft=oo();Object.prototype.constructor.toString();function so(e,t){return{...e,header:{...e.header,name:t}}}function ao(e,t,n){const{scope:r}=t;return Ft({document:e,action:t,skip:n,reuseLastOperationIndex:!1},o=>{const a=[...e.operations[r]],s=Te(a);o.action=bn(r);const u=s.at(-1);let d=u?.index??-1;const _=u?.action.type!=="NOOP";_?d=d+1:o.reuseLastOperationIndex=!0;const g=_?[...s,{index:d,skip:0}]:s;if(o.skip=Ci(g),u&&o.skip>u.skip+1&&(o.skip=o.skip+1),o.skip<0)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history")})}function lo(e,t,n){const{scope:r,input:i}=t;return Ft({document:e,action:t,skip:n,reuseLastOperationIndex:!1},a=>{if(a.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(typeof i!="number"||i>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(typeof i!="number"||i<1)throw new Error("Invalid REDO action: invalid redo input value");if(a.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const s=a.document.clipboard.findLastIndex(d=>d.action.scope===r);if(s<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${r}"`);const u=a.document.clipboard.splice(s,1)[0];a.action={type:u.action.type,scope:u.action.scope,input:u.action.input}})}function uo(e,t){return{...e,header:{...e.header,name:t.state.name},state:t.state.data}}function mt(e,t,n,r,i,o=Tn,a={},s){const u=Dn(n,o);return En(e,t,u,r,i,a,s)}function co(e,t,n,r,i){if(["UNDO","REDO","PRUNE"].includes(t.type))return e;const o=t.scope;let a=[];e.operations[o]&&(a=e.operations[o].slice());const u=a.sort((g,x)=>g.index-x.index).at(-1)?.index??-1,d=n?u:u+1,_=gi(t,d,r,i);return a.push(_),{...e,operations:{...e.operations,[o]:a}}}function po(e,t,n,r,i){const o=t.action.scope,a=e.operations[o],s=a?a.slice():[],d=s.sort((x,p)=>x.index-p.index).at(-1)?.index??-1,_=n?d:d+1;if(t.index-r>_)throw new Error(`Missing operations: expected ${_} with skip 0 or equivalent, got index ${t.index} with skip ${r}`);const g=_i(t,t.index,r,i);return s.push(g),{...e,operations:{...e.operations,[o]:s}}}function fo(e,t,n,r,i,o){let a;return o?a=po(e,o,n,r,i):a=co(e,t,n,r,i),a=wn(a,t.scope),a}function ho(e,t,n){const r=oi().parse(t);switch(r.type){case"SET_NAME":return so(e,r.input);case"PRUNE":return bo(e,r.input,n);case"LOAD_STATE":return uo(e,r.input);default:return e}}function mo(e,t,n){switch(t.type){case"UNDO":return ao(e,t,n);case"REDO":return lo(e,t,n);default:return{document:e,action:t,skip:n,reuseLastOperationIndex:!1}}}function go(e,t,n,r,i=!1,o=Mt){const a=t.scope,s=e.operations[a];if(!s)return e;const u=s.at(-1);if(!u)return e;const d=dt({...e.operations,[a]:Mi(s,u)});let _;const x=d[a]?.at(-1);if(i&&x?.resultingState)_=o(x.resultingState);else{const{state:p}=mt(e.initialState,d,n,e.header,void 0,void 0,void 0,{reuseOperationResultingState:i,operationResultingStateParser:o});_=p[a]}return{...e,state:{...e.state,[a]:_},operations:dt({...e.operations})}}function _o(e,t,n,r=!1,i=Mt){const o=e.operations[t];if(!o)return e;const a=[...o],s=Te(a);s.pop();const u=dt({...e.operations}),d=u[t];if(!d)return e;const _=[...d],g=Pi(Re(s),_),x=mt(e.initialState,u,n,e.header,void 0,void 0,void 0,{reuseOperationResultingState:r,operationResultingStateParser:i}),p=Te([...e.clipboard,...g].filter(E=>E.action.type!=="NOOP")).reverse();return{...x,clipboard:p}}function Tn(e,t,n,r,i={}){const{skip:o,ignoreSkipOperations:a=!1,reuseOperationResultingState:s=!1,operationResultingStateParser:u,pruneOnSkip:d=!0,branch:_="main"}=i;let g=mi(t),x=o??i.replayOptions?.operation.skip??0,p={...e},E=!1;const f=!a&&x>0;if(Ii(g)){const{skip:O,action:D,document:M,reuseLastOperationIndex:F}=mo(e,g,x);g=D,x=O,p=M,E=F}else p={...p,clipboard:[]};yn(g)&&(p=ho(p,g,n));const b={documentId:e.header.id,scope:g.scope,branch:_};if(p=fo(p,g,E,x,b,i.replayOptions?.operation),Ai(t))return _o(p,t.scope,n);if(f){const O=go(p,g,n,x,s,u);d?p=O:p={...O,operations:p.operations}}if(p=Ft(p,O=>{try{const D=n(O.state,g,r);D&&eo(()=>{O.state=D})}catch(D){const M=p.operations[g.scope];if(!M)throw new Error(`No operations found for scope: ${g.scope}`);const F=M.length-1,T=O.operations[g.scope];if(!T)throw new Error(`No operations found in draft for scope: ${g.scope}`);if(T[F].error=D.message,T[F].skip=0,f){O.state={...e.state};const G=e.operations[g.scope];if(!G)throw new Error(`No operations found for scope: ${g.scope}`);O.operations={...e.operations,[g.scope]:[...G,{...T[F]}]}}}}),["UNDO","REDO","PRUNE"].includes(g.type))return p;const m=g.scope||"global";let h=Ct(p,m);i.replayOptions?.operation.hash&&i.replayOptions.operation.hash!==""&&(h=i.replayOptions.operation.hash);const v=p.operations[m]?.at(-1);return v&&(v.hash=h,s&&(v.resultingState=JSON.stringify(p.state[m]))),p}function Dn(e,t=Tn){return(r,i,o,a)=>t(r,i,e,o,a)}function bo(e,t,n){const r=e.operations.global;if(!r)throw new Error("No global operations found");let{start:i,end:o}=t;i=i||0,o=o||r.length;const a=r.slice(i,o),s=r.slice(0,i),u=r.slice(o),d=mt(e.initialState,{...e.operations,global:s.concat(a)},n,e.header),_=d.state,g=d.header.name,x=s.length,p=s.length?s[s.length-1].timestampUtcMs:u.length?u[0].timestampUtcMs:new Date().toISOString(),E=_n({name:g,..._},a.length);return mt(e.initialState,{...e.operations,global:[...s,{skip:0,...E,action:E,timestampUtcMs:p,index:x,hash:Ct({state:_},"global")},...u.map((f,b)=>({...f,index:x+b+1}))]},n,e.header)}const yo="sha1",Eo="base64";function Cn(){return{}}function Mn(){return{version:0,hash:{algorithm:yo,encoding:Eo}}}function $t(){return{auth:Cn(),document:Mn()}}function So(e){return{...Cn(),...e}}function wo(e){return{...Mn(),...e}}function Oo(e,t){return{auth:So(e),document:wo(t)}}function Nn(){return ee({__typename:be("AddChangeLogItemInput").optional(),content:L(),id:L(),insertBefore:L().nullable()})}function zn(){return ee({description:L().nullish(),id:L(),name:L()})}function Pn(){return ee({errorCode:L().nullish(),errorDescription:L().nullish(),errorName:L().nullish(),errorTemplate:L().nullish(),id:L(),operationId:L()})}function xo(){return ee({example:L(),id:L(),operationId:L()})}function Ln(){return ee({description:L().nullish(),id:L(),moduleId:L(),name:L(),reducer:L().nullish(),schema:L().nullish(),template:L().nullish(),scope:Le().nullish()})}function Un(){return ee({scope:L(),example:L(),id:L(),insertBefore:L().nullish()})}function vo(){return ee({__typename:be("Author").optional(),name:L(),website:L().nullable()})}function jn(){return ee({__typename:be("CodeExample").optional(),id:L(),value:L()})}function Bn(){return ee({__typename:be("DeleteChangeLogItemInput").optional(),id:L()})}function Fn(){return ee({id:L()})}function $n(){return ee({id:L()})}function Io(){return ee({id:L()})}function Wn(){return ee({id:L()})}function Hn(){return ee({scope:L(),id:L()})}function Ao(){return ee({__typename:be("DocumentModelGlobalState").optional(),author:vo(),description:L(),extension:L(),id:L(),name:L(),specifications:Se(Ro())})}function Ro(){return ee({__typename:be("DocumentSpecification").optional(),changeLog:Se(L()),modules:Se(ko()),state:Mo(),version:$e().int()})}function ko(){return ee({__typename:be("ModuleSpecification").optional(),description:L().nullable(),id:L(),name:L(),operations:Se(To())})}function Zn(){return ee({newModuleId:L(),operationId:L()})}function To(){return ee({__typename:be("OperationSpecification").optional(),description:L().nullable(),errors:Se(Do()),examples:Se(jn()),id:L(),name:L().nullable(),reducer:L().nullable(),schema:L().nullable(),template:L().nullable(),scope:Le()})}function Do(){return ee({__typename:be("OperationErrorSpecification").optional(),code:L().nullable(),description:L().nullable(),id:L(),name:L().nullable(),template:L().nullable()})}function Gn(){return ee({__typename:be("ReorderChangeLogItemsInput").optional(),order:Se(L())})}function Vn(){return ee({moduleId:L(),order:Se(L())})}function Xn(){return ee({order:Se(L())})}function Kn(){return ee({operationId:L(),order:Se(L())})}function Co(){return ee({operationId:L(),order:Se(L())})}function Jn(){return ee({scope:L(),order:Se(L())})}function qn(){return ee({authorName:L()})}function Yn(){return ee({authorWebsite:L()})}function Qn(){return ee({scope:L(),initialValue:L()})}function er(){return ee({description:L()})}function tr(){return ee({extension:L()})}function nr(){return ee({id:L()})}function rr(){return ee({name:L()})}function ir(){return ee({description:L().nullish(),id:L()})}function or(){return ee({id:L(),name:L().nullish()})}function sr(){return ee({description:L().nullish(),id:L()})}function ar(){return ee({errorCode:L().nullish(),id:L()})}function lr(){return ee({errorDescription:L().nullish(),id:L()})}function ur(){return ee({errorName:L().nullish(),id:L()})}function cr(){return ee({errorTemplate:L().nullish(),id:L()})}function pr(){return ee({id:L(),name:L().nullish()})}function dr(){return ee({id:L(),scope:Le()})}function fr(){return ee({id:L(),reducer:L().nullish()})}function hr(){return ee({id:L(),schema:L().nullish()})}function mr(){return ee({id:L(),template:L().nullish()})}function gr(){return ee({scope:L(),schema:L()})}function tn(){return ee({__typename:be("State").optional(),examples:Se(jn()),initialValue:L(),schema:L()})}function Mo(){return ee({global:tn(),local:tn()})}function _r(){return ee({__typename:be("UpdateChangeLogItemInput").optional(),id:L(),newContent:L()})}function No(){return ee({example:L(),id:L()})}function br(){return ee({scope:L(),id:L(),newExample:L()})}const zo=e=>oe("SET_NAME",e,void 0,fn,"global"),Po=e=>oe("SET_MODEL_NAME",{...e},void 0,rr,"global"),Lo=e=>oe("SET_MODEL_ID",{...e},void 0,nr,"global"),Uo=e=>oe("SET_MODEL_EXTENSION",{...e},void 0,tr,"global"),jo=e=>oe("SET_MODEL_DESCRIPTION",{...e},void 0,er,"global"),Bo=e=>oe("SET_AUTHOR_NAME",{...e},void 0,qn,"global"),Fo=e=>oe("SET_AUTHOR_WEBSITE",{...e},void 0,Yn,"global"),$o=e=>oe("ADD_MODULE",{...e},void 0,zn,"global"),Wo=e=>oe("SET_MODULE_NAME",{...e},void 0,or,"global"),Ho=e=>oe("SET_MODULE_DESCRIPTION",{...e},void 0,ir,"global"),Zo=e=>oe("DELETE_MODULE",{...e},void 0,Fn,"global"),Go=e=>oe("REORDER_MODULES",{...e},void 0,Xn,"global"),Vo=e=>oe("ADD_OPERATION",{...e},void 0,Ln,"global"),Xo=e=>oe("SET_OPERATION_NAME",{...e},void 0,pr,"global"),Ko=e=>oe("SET_OPERATION_SCOPE",{...e},void 0,dr,"global"),Jo=e=>oe("SET_OPERATION_SCHEMA",{...e},void 0,hr,"global"),qo=e=>oe("SET_OPERATION_DESCRIPTION",{...e},void 0,sr,"global"),Yo=e=>oe("SET_OPERATION_TEMPLATE",{...e},void 0,mr,"global"),Qo=e=>oe("SET_OPERATION_REDUCER",{...e},void 0,fr,"global"),es=e=>oe("MOVE_OPERATION",{...e},void 0,Zn,"global"),ts=e=>oe("DELETE_OPERATION",{...e},void 0,Wn,"global"),ns=e=>oe("REORDER_MODULE_OPERATIONS",{...e},void 0,Vn,"global"),rs=e=>oe("ADD_OPERATION_ERROR",{...e},void 0,Pn,"global"),is=e=>oe("SET_OPERATION_ERROR_CODE",{...e},void 0,ar,"global"),os=e=>oe("SET_OPERATION_ERROR_NAME",{...e},void 0,ur,"global"),ss=e=>oe("SET_OPERATION_ERROR_DESCRIPTION",{...e},void 0,lr,"global"),as=e=>oe("SET_OPERATION_ERROR_TEMPLATE",{...e},void 0,cr,"global"),ls=e=>oe("DELETE_OPERATION_ERROR",{...e},void 0,$n,"global"),us=e=>oe("REORDER_OPERATION_ERRORS",{...e},void 0,Kn,"global"),cs=e=>oe("SET_STATE_SCHEMA",{...e},void 0,gr,"global"),ps=e=>oe("SET_INITIAL_STATE",{...e},void 0,Qn,"global"),ds=e=>oe("ADD_STATE_EXAMPLE",{...e},void 0,Un,"global"),fs=e=>oe("UPDATE_STATE_EXAMPLE",{...e},void 0,br,"global"),hs=e=>oe("DELETE_STATE_EXAMPLE",{...e},void 0,Hn,"global"),ms=e=>oe("REORDER_STATE_EXAMPLES",{...e},void 0,Jn,"global"),gs=e=>oe("ADD_CHANGE_LOG_ITEM",{...e},void 0,Nn,"global"),_s=e=>oe("UPDATE_CHANGE_LOG_ITEM",{...e},void 0,_r,"global"),bs=e=>oe("DELETE_CHANGE_LOG_ITEM",{...e},void 0,Bn,"global"),ys=e=>oe("REORDER_CHANGE_LOG_ITEMS",{...e},void 0,Gn,"global"),Es=()=>oe("RELEASE_NEW_VERSION",{},void 0,void 0,"global"),Ss={setName:zo,undo:di,redo:fi,prune:hi,loadState:_n,noop:bn},ws={setModelName:Po,setModelId:Lo,setModelExtension:Uo,setModelDescription:jo,setAuthorName:Bo,setAuthorWebsite:Fo,addModule:$o,setModuleName:Wo,setModuleDescription:Ho,deleteModule:Zo,reorderModules:Go,addOperation:Vo,setOperationName:Xo,setOperationScope:Ko,setOperationSchema:Jo,setOperationDescription:qo,setOperationTemplate:Yo,setOperationReducer:Qo,moveOperation:es,deleteOperation:ts,reorderModuleOperations:ns,addOperationError:rs,setOperationErrorCode:is,setOperationErrorName:os,setOperationErrorDescription:ss,setOperationErrorTemplate:as,deleteOperationError:ls,reorderOperationErrors:us,setStateSchema:cs,setInitialState:ps,addStateExample:ds,updateStateExample:fs,deleteStateExample:hs,reorderStateExamples:ms,addChangeLogItem:gs,updateChangeLogItem:_s,deleteChangeLogItem:bs,reorderChangeLogItems:ys,releaseNewVersion:Es},Os={...Ss,...ws},xs="phdm",vs={},Is={id:"",name:"",extension:"",description:"",author:{name:"",website:""},specifications:[{version:1,changeLog:[],state:{global:{schema:"",initialValue:"",examples:[]},local:{schema:"",initialValue:"",examples:[]}},modules:[]}]},As={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:[],state:{global:{schema:`type CodeExample {
23
23
  id: ID!
@@ -227,4 +227,4 @@ type DocumentModelGlobalState {
227
227
  }`,template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"REORDER_STATE_EXAMPLES",id:"",description:"Changes the order of state examples for a document scope",schema:`input ReorderStateExamplesInput {
228
228
  scope: String!
229
229
  order: [ID!]!
230
- }`,template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}]}]},yr="powerhouse/document-model",Rs=ee({id:L(),name:L(),createdAtUtcIso:L(),lastModifiedAtUtcIso:L(),documentType:L()}),ks=ee({global:an()}),Ts=Rs.extend({documentType:be(yr)}),gt=ks.extend({global:Ao()}),Er=ee({header:Ts,state:gt,initialState:gt});function Ds(e){return gt.safeParse(e).success}function Cs(e){gt.parse(e)}function Ms(e){return Er.safeParse(e).success}function Ns(e){Er.parse(e)}const zs=new RegExp("([\\p{Ll}\\d])(\\p{Lu})","gu"),Ps=new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])","gu"),Ls=new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d","u"),Us=/[^\p{L}\d]+/giu,nn="$1\0$2",rn="";function Sr(e){let t=e.trim();t=t.replace(zs,nn).replace(Ps,nn),t=t.replace(Us,"\0");let n=0,r=t.length;for(;t.charAt(n)==="\0";)n++;if(n===r)return[];for(;t.charAt(r-1)==="\0";)r--;return t.slice(n,r).split(/\0/g)}function js(e){const t=Sr(e);for(let n=0;n<t.length;n++){const r=t[n],i=Ls.exec(r);if(i){const o=i.index+(i[1]??i[2]).length;t.splice(n,1,r.slice(0,o),r.slice(o))}}return t}function Bs(e,t){const[n,r,i]=tt(e,t);return n+r.map(bt(t?.locale)).join(t?.delimiter??" ")+i}function on(e,t){const[n,r,i]=tt(e,t),o=bt(t?.locale),a=yt(t?.locale),s=t?.mergeAmbiguousCharacters?Wt(o,a):Fs(o,a);return n+r.map(s).join(t?.delimiter??"")+i}function ga(e,t){const[n,r,i]=tt(e,t),o=bt(t?.locale),a=yt(t?.locale);return n+r.map(Wt(o,a)).join(" ")+i}function _a(e,t){const[n,r,i]=tt(e,t);return n+r.map(yt(t?.locale)).join("_")+i}function ba(e,t){const[n,r,i]=tt(e,t),o=bt(t?.locale),a=yt(t?.locale),s=Wt(o,a);return n+r.map((u,d)=>d===0?s(u):o(u)).join(" ")+i}function ya(e,t){return Bs(e,{delimiter:"_",...t})}function bt(e){return e===!1?t=>t.toLowerCase():t=>t.toLocaleLowerCase(e)}function yt(e){return e===!1?t=>t.toUpperCase():t=>t.toLocaleUpperCase(e)}function Wt(e,t){return n=>`${t(n[0])}${e(n.slice(1))}`}function Fs(e,t){return(n,r)=>{const i=n[0];return(r>0&&i>="0"&&i<="9"?"_"+i:t(i))+e(n.slice(1))}}function tt(e,t={}){const n=t.split??(t.separateNumbers?js:Sr),r=t.prefixCharacters??rn,i=t.suffixCharacters??rn;let o=0,a=e.length;for(;o<e.length;){const s=e.charAt(o);if(!r.includes(s))break;o++}for(;a>o;){const s=a-1,u=e.charAt(s);if(!i.includes(u))break;a=s}return[e.slice(0,o),n(e.slice(o,a)),e.slice(a)]}const $s=["UNDO","REDO","PRUNE","LOAD_STATE","SET_NAME","NOOP"];function Ws(e){return $s.includes(e.toUpperCase())}function Hs(e,t){const n=e.specifications[e.specifications.length-1];if(!n)return[];const r=[];for(const i of n.modules)for(const o of i.operations)t&&o.id===t||o.name&&r.push(o.name.toUpperCase());return r}function sn(e,t,n){if(!e)return;const r=e.toUpperCase();if(Ws(e))throw new Error(`Operation name "${e}" is reserved. Please use a different name.`);if(Hs(t,n).includes(r))throw new Error(`Operation name "${e}" is already used by another operation. Operation names must be unique across all modules.`)}function Ea(e,t=!1){const n=[];if(t&&e==="")return n;try{const r=JSON.parse(e);!t&&!Object.keys(r).length&&n.push({message:"Initial state cannot be empty",details:{initialState:e}})}catch{n.push({message:"Invalid initial state",details:{initialState:e}})}return n}function Sa(e,t,n="",r=!0){const i=[];if(!r&&!e)return i.push({message:"State schema is required",details:{schema:e}}),i;if(r&&!e)return i;const o=`${on(t)}${on(n)}State`;return new RegExp(`\\btype\\s+${o}(?:\\s|\\{|@|$)`).test(e)||i.push({message:`Invalid state schema name. Expected type ${o}`,details:{schema:e}}),i}function wa(e){const t=[];e.length||t.push({message:"Modules are required",details:{modules:e}});const n=e.reduce((r,i)=>[...r,...Zs(i)],[]);return[...t,...n]}function Zs(e){const t=[];e.name||t.push({message:"Module name is required",details:{module:e}}),e.operations.length||t.push({message:"Module operations are required",details:{module:e}});const n=e.operations.reduce((r,i)=>[...r,...Gs(i)],[]);return[...t,...n]}function Gs(e){const t=[];return e.name||t.push({message:"Operation name is required",details:{operation:e}}),e.schema||t.push({message:"Operation schema is required",details:{operation:e}}),t}function nt(e){const t={};return e.forEach((n,r)=>t[n]=r),(n,r)=>(t[r.id]||999999)-(t[n.id]||999999)}const je={setModelNameOperation(e,t){e.name=t.input.name},setModelIdOperation(e,t){e.id=t.input.id},setModelExtensionOperation(e,t){e.extension=t.input.extension},setModelDescriptionOperation(e,t){e.description=t.input.description},setAuthorNameOperation(e,t){e.author=e.author||{name:"",website:null},e.author.name=t.input.authorName},setAuthorWebsiteOperation(e,t){e.author=e.author||{name:"",website:null},e.author.website=t.input.authorWebsite}},Xe={addModuleOperation(e,t){e.specifications[e.specifications.length-1].modules.push({id:t.input.id,name:t.input.name,description:t.input.description||"",operations:[]})},setModuleNameOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].id===t.input.id&&(n.modules[r].name=t.input.name||"")},setModuleDescriptionOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].id===t.input.id&&(n.modules[r].description=t.input.description||"")},deleteModuleOperation(e,t){const n=e.specifications[e.specifications.length-1];n.modules=n.modules.filter(r=>r.id!=t.input.id)},reorderModulesOperation(e,t){e.specifications[e.specifications.length-1].modules.sort(nt(t.input.order))}},ze={addOperationErrorOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.operationId&&n.modules[r].operations[i].errors.push({id:t.input.id,name:t.input.errorName||"",code:t.input.errorCode||"",description:t.input.errorDescription||"",template:t.input.errorTemplate||""})},setOperationErrorCodeOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let o=0;o<n.modules[r].operations[i].errors.length;o++)n.modules[r].operations[i].errors[o].id==t.input.id&&(n.modules[r].operations[i].errors[o].code=t.input.errorCode||"")},setOperationErrorNameOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let o=0;o<n.modules[r].operations[i].errors.length;o++)n.modules[r].operations[i].errors[o].id==t.input.id&&(n.modules[r].operations[i].errors[o].name=t.input.errorName||"")},setOperationErrorDescriptionOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let o=0;o<n.modules[r].operations[i].errors.length;o++)n.modules[r].operations[i].errors[o].id==t.input.id&&(n.modules[r].operations[i].errors[o].description=t.input.errorDescription||"")},setOperationErrorTemplateOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let o=0;o<n.modules[r].operations[i].errors.length;o++)n.modules[r].operations[i].errors[o].id==t.input.id&&(n.modules[r].operations[i].errors[o].template=t.input.errorTemplate||"")},deleteOperationErrorOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].errors=n.modules[r].operations[i].errors.filter(o=>o.id!=t.input.id)},reorderOperationErrorsOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.operationId&&n.modules[r].operations[i].errors.sort(nt(t.input.order))}},ut={addOperationExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.operationId&&n.modules[r].operations[i].examples.push({id:t.input.id,value:t.input.example})},updateOperationExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let o=0;o<n.modules[r].operations[i].examples.length;o++)n.modules[r].operations[i].examples[o].id==t.input.id&&(n.modules[r].operations[i].examples[o].value=t.input.example)},deleteOperationExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].examples=n.modules[r].operations[i].examples.filter(o=>o.id!=t.input.id)},reorderOperationExamplesOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.operationId&&n.modules[r].operations[i].examples.sort(nt(t.input.order))}},ve={addOperationOperation(e,t){sn(t.input.name,e);const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].id==t.input.moduleId&&n.modules[r].operations.push({id:t.input.id,name:t.input.name,description:t.input.description||"",schema:t.input.schema||"",template:t.input.template||t.input.description||"",reducer:t.input.reducer||"",errors:[],examples:[],scope:t.input.scope||"global"})},setOperationNameOperation(e,t){t.input.name&&sn(t.input.name,e,t.input.id);const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].name=t.input.name||"")},setOperationScopeOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].scope=t.input.scope||"global")},setOperationSchemaOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].schema=t.input.schema||"")},setOperationDescriptionOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].description=t.input.description||"")},setOperationTemplateOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].template=t.input.template||"")},setOperationReducerOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].reducer=t.input.reducer||"")},moveOperationOperation(e,t){const n=[],r=e.specifications[e.specifications.length-1];for(let i=0;i<r.modules.length;i++)r.modules[i].operations=r.modules[i].operations.filter(o=>o.id==t.input.operationId?(n.push(o),!1):!0);for(let i=0;i<r.modules.length;i++)r.modules[i].id==t.input.newModuleId&&r.modules[i].operations.push(...n)},deleteOperationOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].operations=n.modules[r].operations.filter(i=>i.id!=t.input.id)},reorderModuleOperationsOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].id==t.input.moduleId&&n.modules[r].operations.sort(nt(t.input.order))}},Be={setStateSchemaOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].schema=t.input.schema;else throw new Error(`Invalid scope: ${t.input.scope}`)},setInitialStateOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].initialValue=t.input.initialValue;else throw new Error(`Invalid scope: ${t.input.scope}`)},addStateExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].examples.push({id:t.input.id,value:t.input.example});else throw new Error(`Invalid scope: ${t.input.scope}`)},updateStateExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];if(!Object.keys(n.state).includes(t.input.scope))throw new Error(`Invalid scope: ${t.input.scope}`);const r=n.state[t.input.scope].examples;for(let i=0;i<r.length;i++)r[i].id==t.input.id&&(r[i].value=t.input.newExample)},deleteStateExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].examples=n.state[t.input.scope].examples.filter(r=>r.id!=t.input.id);else throw new Error(`Invalid scope: ${t.input.scope}`)},reorderStateExamplesOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].examples.sort(nt(t.input.order));else throw new Error(`Invalid scope: ${t.input.scope}`)}},Ke={addChangeLogItemOperation(e,t){throw new Error('Reducer "addChangeLogItemOperation" not yet implemented')},updateChangeLogItemOperation(e,t){throw new Error('Reducer "updateChangeLogItemOperation" not yet implemented')},deleteChangeLogItemOperation(e,t){throw new Error('Reducer "deleteChangeLogItemOperation" not yet implemented')},reorderChangeLogItemsOperation(e,t){throw new Error('Reducer "reorderChangeLogItemsOperation" not yet implemented')},releaseNewVersionOperation(e,t){throw new Error('Reducer "releaseNewVersionOperation" not yet implemented')}},Vs=(e,t)=>{if(yn(t))return e;switch(t.type){case"SET_MODEL_NAME":rr().parse(t.input),je.setModelNameOperation(e.global,t);break;case"SET_MODEL_ID":nr().parse(t.input),je.setModelIdOperation(e.global,t);break;case"SET_MODEL_EXTENSION":tr().parse(t.input),je.setModelExtensionOperation(e.global,t);break;case"SET_MODEL_DESCRIPTION":er().parse(t.input),je.setModelDescriptionOperation(e.global,t);break;case"SET_AUTHOR_NAME":qn().parse(t.input),je.setAuthorNameOperation(e.global,t);break;case"SET_AUTHOR_WEBSITE":Yn().parse(t.input),je.setAuthorWebsiteOperation(e.global,t);break;case"ADD_CHANGE_LOG_ITEM":Nn().parse(t.input),Ke.addChangeLogItemOperation(e.global,t);break;case"UPDATE_CHANGE_LOG_ITEM":_r().parse(t.input),Ke.updateChangeLogItemOperation(e.global,t);break;case"DELETE_CHANGE_LOG_ITEM":Bn().parse(t.input),Ke.deleteChangeLogItemOperation(e.global,t);break;case"REORDER_CHANGE_LOG_ITEMS":Gn().parse(t.input),Ke.reorderChangeLogItemsOperation(e.global,t);break;case"RELEASE_NEW_VERSION":if(Object.keys(t.input).length>0)throw new Error("Expected empty input for action RELEASE_NEW_VERSION");Ke.releaseNewVersionOperation(e.global,t);break;case"ADD_MODULE":zn().parse(t.input),Xe.addModuleOperation(e.global,t);break;case"SET_MODULE_NAME":or().parse(t.input),Xe.setModuleNameOperation(e.global,t);break;case"SET_MODULE_DESCRIPTION":ir().parse(t.input),Xe.setModuleDescriptionOperation(e.global,t);break;case"DELETE_MODULE":Fn().parse(t.input),Xe.deleteModuleOperation(e.global,t);break;case"REORDER_MODULES":Xn().parse(t.input),Xe.reorderModulesOperation(e.global,t);break;case"ADD_OPERATION_ERROR":Pn().parse(t.input),ze.addOperationErrorOperation(e.global,t);break;case"SET_OPERATION_ERROR_CODE":ar().parse(t.input),ze.setOperationErrorCodeOperation(e.global,t);break;case"SET_OPERATION_ERROR_NAME":ur().parse(t.input),ze.setOperationErrorNameOperation(e.global,t);break;case"SET_OPERATION_ERROR_DESCRIPTION":lr().parse(t.input),ze.setOperationErrorDescriptionOperation(e.global,t);break;case"SET_OPERATION_ERROR_TEMPLATE":cr().parse(t.input),ze.setOperationErrorTemplateOperation(e.global,t);break;case"DELETE_OPERATION_ERROR":$n().parse(t.input),ze.deleteOperationErrorOperation(e.global,t);break;case"REORDER_OPERATION_ERRORS":Kn().parse(t.input),ze.reorderOperationErrorsOperation(e.global,t);break;case"ADD_OPERATION_EXAMPLE":xo().parse(t.input),ut.addOperationExampleOperation(e.global,t);break;case"UPDATE_OPERATION_EXAMPLE":No().parse(t.input),ut.updateOperationExampleOperation(e.global,t);break;case"DELETE_OPERATION_EXAMPLE":Io().parse(t.input),ut.deleteOperationExampleOperation(e.global,t);break;case"REORDER_OPERATION_EXAMPLES":Co().parse(t.input),ut.reorderOperationExamplesOperation(e.global,t);break;case"ADD_OPERATION":Ln().parse(t.input),ve.addOperationOperation(e.global,t);break;case"SET_OPERATION_NAME":pr().parse(t.input),ve.setOperationNameOperation(e.global,t);break;case"SET_OPERATION_SCOPE":dr().parse(t.input),ve.setOperationScopeOperation(e.global,t);break;case"SET_OPERATION_SCHEMA":hr().parse(t.input),ve.setOperationSchemaOperation(e.global,t);break;case"SET_OPERATION_DESCRIPTION":sr().parse(t.input),ve.setOperationDescriptionOperation(e.global,t);break;case"SET_OPERATION_TEMPLATE":mr().parse(t.input),ve.setOperationTemplateOperation(e.global,t);break;case"SET_OPERATION_REDUCER":fr().parse(t.input),ve.setOperationReducerOperation(e.global,t);break;case"MOVE_OPERATION":Zn().parse(t.input),ve.moveOperationOperation(e.global,t);break;case"DELETE_OPERATION":Wn().parse(t.input),ve.deleteOperationOperation(e.global,t);break;case"REORDER_MODULE_OPERATIONS":Vn().parse(t.input),ve.reorderModuleOperationsOperation(e.global,t);break;case"SET_STATE_SCHEMA":gr().parse(t.input),Be.setStateSchemaOperation(e.global,t);break;case"SET_INITIAL_STATE":Qn().parse(t.input),Be.setInitialStateOperation(e.global,t);break;case"ADD_STATE_EXAMPLE":Un().parse(t.input),Be.addStateExampleOperation(e.global,t);break;case"UPDATE_STATE_EXAMPLE":br().parse(t.input),Be.updateStateExampleOperation(e.global,t);break;case"DELETE_STATE_EXAMPLE":Hn().parse(t.input),Be.deleteStateExampleOperation(e.global,t);break;case"REORDER_STATE_EXAMPLES":Jn().parse(t.input),Be.reorderStateExamplesOperation(e.global,t);break;default:return e}},wr=Dn(Vs),Xs=(e,t)=>Wi(e,t),Ks=e=>Hi(e,wr),Or=e=>({...$t(),global:{...Is,...e?.global??{}},local:{...vs,...e?.local??{}}});function Js(){return{...$t(),author:{name:"",website:""},description:"",extension:"",id:"",name:"",specifications:[]}}function qs(){return{}}function Ys(e){return{...Js(),...e||{}}}function Qs(e){return{...qs()}}function ea(e,t,n){return{...Oo(e?.auth,e?.document),global:Ys(t),local:Qs()}}function ta(e){const t=Ri(Or,e);return t.header.documentType=yr,t}const na=e=>Ds(e),ra=e=>{Cs(e)},ia=e=>Ms(e),oa=e=>{Ns(e)},sa={fileExtension:xs,createState:Or,createDocument:ta,loadFromInput:Ks,saveToFileHandle:Xs,isStateOfType:na,assertIsStateOfType:ra,isDocumentOfType:ia,assertIsDocumentOfType:oa},Oa={reducer:wr,documentModel:ea($t(),As),actions:Os,utils:sa};export{yr as $,pa as A,ks as B,lt as C,ya as D,_a as E,ba as F,Po as G,cs as H,Lo as I,jo as J,Uo as K,Bo as L,Fo as M,ps as N,$o as O,Wo as P,Zo as Q,Xo as R,Jo as S,qo as T,ts as U,rs as V,ls as W,os as X,Vo as Y,ga as Z,ua as _,Dn as a,$i as a0,Os as a1,Ea as a2,Sa as a3,wa as a4,fi as a5,di as a6,Oa as a7,Rs as b,oe as c,Wi as d,Hi as e,Ri as f,mn as g,$t as h,yn as i,ea as j,gn as k,vi as l,Ct as m,ha as n,Re as o,on as p,da as q,ma as r,Te as s,fa as t,Ti as u,ca as v,dt as w,En as x,Mi as y,Pi as z};
230
+ }`,template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}]}]},yr="powerhouse/document-model",Rs=ee({id:L(),name:L(),createdAtUtcIso:L(),lastModifiedAtUtcIso:L(),documentType:L()}),ks=ee({global:an()}),Ts=Rs.extend({documentType:be(yr)}),gt=ks.extend({global:Ao()}),Er=ee({header:Ts,state:gt,initialState:gt});function Ds(e){return gt.safeParse(e).success}function Cs(e){gt.parse(e)}function Ms(e){return Er.safeParse(e).success}function Ns(e){Er.parse(e)}const zs=new RegExp("([\\p{Ll}\\d])(\\p{Lu})","gu"),Ps=new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])","gu"),Ls=new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d","u"),Us=/[^\p{L}\d]+/giu,nn="$1\0$2",rn="";function Sr(e){let t=e.trim();t=t.replace(zs,nn).replace(Ps,nn),t=t.replace(Us,"\0");let n=0,r=t.length;for(;t.charAt(n)==="\0";)n++;if(n===r)return[];for(;t.charAt(r-1)==="\0";)r--;return t.slice(n,r).split(/\0/g)}function js(e){const t=Sr(e);for(let n=0;n<t.length;n++){const r=t[n],i=Ls.exec(r);if(i){const o=i.index+(i[1]??i[2]).length;t.splice(n,1,r.slice(0,o),r.slice(o))}}return t}function Bs(e,t){const[n,r,i]=tt(e,t);return n+r.map(bt(t?.locale)).join(t?.delimiter??" ")+i}function on(e,t){const[n,r,i]=tt(e,t),o=bt(t?.locale),a=yt(t?.locale),s=t?.mergeAmbiguousCharacters?Wt(o,a):Fs(o,a);return n+r.map(s).join(t?.delimiter??"")+i}function ga(e,t){const[n,r,i]=tt(e,t),o=bt(t?.locale),a=yt(t?.locale);return n+r.map(Wt(o,a)).join(" ")+i}function _a(e,t){const[n,r,i]=tt(e,t);return n+r.map(yt(t?.locale)).join("_")+i}function ba(e,t){const[n,r,i]=tt(e,t),o=bt(t?.locale),a=yt(t?.locale),s=Wt(o,a);return n+r.map((u,d)=>d===0?s(u):o(u)).join(" ")+i}function ya(e,t){return Bs(e,{delimiter:"_",...t})}function bt(e){return e===!1?t=>t.toLowerCase():t=>t.toLocaleLowerCase(e)}function yt(e){return e===!1?t=>t.toUpperCase():t=>t.toLocaleUpperCase(e)}function Wt(e,t){return n=>`${t(n[0])}${e(n.slice(1))}`}function Fs(e,t){return(n,r)=>{const i=n[0];return(r>0&&i>="0"&&i<="9"?"_"+i:t(i))+e(n.slice(1))}}function tt(e,t={}){const n=t.split??(t.separateNumbers?js:Sr),r=t.prefixCharacters??rn,i=t.suffixCharacters??rn;let o=0,a=e.length;for(;o<e.length;){const s=e.charAt(o);if(!r.includes(s))break;o++}for(;a>o;){const s=a-1,u=e.charAt(s);if(!i.includes(u))break;a=s}return[e.slice(0,o),n(e.slice(o,a)),e.slice(a)]}const $s=["UNDO","REDO","PRUNE","LOAD_STATE","SET_NAME","NOOP"];function Ws(e){return $s.includes(e.toUpperCase())}function Hs(e,t){const n=e.specifications[e.specifications.length-1];if(!n)return[];const r=[];for(const i of n.modules)for(const o of i.operations)t&&o.id===t||o.name&&r.push(o.name.toUpperCase());return r}function sn(e,t,n){if(!e)return;const r=e.toUpperCase();if(Ws(e))throw new Error(`Operation name "${e}" is reserved. Please use a different name.`);if(Hs(t,n).includes(r))throw new Error(`Operation name "${e}" is already used by another operation. Operation names must be unique across all modules.`)}function Ea(e,t=!1){const n=[];if(t&&e==="")return n;try{const r=JSON.parse(e);!t&&!Object.keys(r).length&&n.push({message:"Initial state cannot be empty",details:{initialState:e}})}catch{n.push({message:"Invalid initial state",details:{initialState:e}})}return n}function Sa(e,t,n="",r=!0){const i=[];if(!r&&!e)return i.push({message:"State schema is required",details:{schema:e}}),i;if(r&&!e)return i;const o=`${on(t)}${on(n)}State`;return new RegExp(`\\btype\\s+${o}(?:\\s|\\{|@|$)`).test(e)||i.push({message:`Invalid state schema name. Expected type ${o}`,details:{schema:e}}),i}function wa(e){const t=[];e.length||t.push({message:"Modules are required",details:{modules:e}});const n=e.reduce((r,i)=>[...r,...Zs(i)],[]);return[...t,...n]}function Zs(e){const t=[];e.name||t.push({message:"Module name is required",details:{module:e}}),e.operations.length||t.push({message:"Module operations are required",details:{module:e}});const n=e.operations.reduce((r,i)=>[...r,...Gs(i)],[]);return[...t,...n]}function Gs(e){const t=[];return e.name||t.push({message:"Operation name is required",details:{operation:e}}),e.schema||t.push({message:"Operation schema is required",details:{operation:e}}),t}function nt(e){const t={};return e.forEach((n,r)=>t[n]=r),(n,r)=>(t[r.id]||999999)-(t[n.id]||999999)}const je={setModelNameOperation(e,t){e.name=t.input.name},setModelIdOperation(e,t){e.id=t.input.id},setModelExtensionOperation(e,t){e.extension=t.input.extension},setModelDescriptionOperation(e,t){e.description=t.input.description},setAuthorNameOperation(e,t){e.author=e.author||{name:"",website:null},e.author.name=t.input.authorName},setAuthorWebsiteOperation(e,t){e.author=e.author||{name:"",website:null},e.author.website=t.input.authorWebsite}},Xe={addModuleOperation(e,t){e.specifications[e.specifications.length-1].modules.push({id:t.input.id,name:t.input.name,description:t.input.description||"",operations:[]})},setModuleNameOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].id===t.input.id&&(n.modules[r].name=t.input.name||"")},setModuleDescriptionOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].id===t.input.id&&(n.modules[r].description=t.input.description||"")},deleteModuleOperation(e,t){const n=e.specifications[e.specifications.length-1];n.modules=n.modules.filter(r=>r.id!=t.input.id)},reorderModulesOperation(e,t){e.specifications[e.specifications.length-1].modules.sort(nt(t.input.order))}},ze={addOperationErrorOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.operationId&&n.modules[r].operations[i].errors.push({id:t.input.id,name:t.input.errorName||"",code:t.input.errorCode||"",description:t.input.errorDescription||"",template:t.input.errorTemplate||""})},setOperationErrorCodeOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let o=0;o<n.modules[r].operations[i].errors.length;o++)n.modules[r].operations[i].errors[o].id==t.input.id&&(n.modules[r].operations[i].errors[o].code=t.input.errorCode||"")},setOperationErrorNameOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let o=0;o<n.modules[r].operations[i].errors.length;o++)n.modules[r].operations[i].errors[o].id==t.input.id&&(n.modules[r].operations[i].errors[o].name=t.input.errorName||"")},setOperationErrorDescriptionOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let o=0;o<n.modules[r].operations[i].errors.length;o++)n.modules[r].operations[i].errors[o].id==t.input.id&&(n.modules[r].operations[i].errors[o].description=t.input.errorDescription||"")},setOperationErrorTemplateOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let o=0;o<n.modules[r].operations[i].errors.length;o++)n.modules[r].operations[i].errors[o].id==t.input.id&&(n.modules[r].operations[i].errors[o].template=t.input.errorTemplate||"")},deleteOperationErrorOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].errors=n.modules[r].operations[i].errors.filter(o=>o.id!=t.input.id)},reorderOperationErrorsOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.operationId&&n.modules[r].operations[i].errors.sort(nt(t.input.order))}},ut={addOperationExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.operationId&&n.modules[r].operations[i].examples.push({id:t.input.id,value:t.input.example})},updateOperationExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let o=0;o<n.modules[r].operations[i].examples.length;o++)n.modules[r].operations[i].examples[o].id==t.input.id&&(n.modules[r].operations[i].examples[o].value=t.input.example)},deleteOperationExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].examples=n.modules[r].operations[i].examples.filter(o=>o.id!=t.input.id)},reorderOperationExamplesOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.operationId&&n.modules[r].operations[i].examples.sort(nt(t.input.order))}},ve={addOperationOperation(e,t){sn(t.input.name,e);const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].id==t.input.moduleId&&n.modules[r].operations.push({id:t.input.id,name:t.input.name,description:t.input.description||"",schema:t.input.schema||"",template:t.input.template||t.input.description||"",reducer:t.input.reducer||"",errors:[],examples:[],scope:t.input.scope||"global"})},setOperationNameOperation(e,t){t.input.name&&sn(t.input.name,e,t.input.id);const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].name=t.input.name||"")},setOperationScopeOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].scope=t.input.scope||"global")},setOperationSchemaOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].schema=t.input.schema||"")},setOperationDescriptionOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].description=t.input.description||"")},setOperationTemplateOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].template=t.input.template||"")},setOperationReducerOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].reducer=t.input.reducer||"")},moveOperationOperation(e,t){const n=[],r=e.specifications[e.specifications.length-1];for(let i=0;i<r.modules.length;i++)r.modules[i].operations=r.modules[i].operations.filter(o=>o.id==t.input.operationId?(n.push(o),!1):!0);for(let i=0;i<r.modules.length;i++)r.modules[i].id==t.input.newModuleId&&r.modules[i].operations.push(...n)},deleteOperationOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].operations=n.modules[r].operations.filter(i=>i.id!=t.input.id)},reorderModuleOperationsOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].id==t.input.moduleId&&n.modules[r].operations.sort(nt(t.input.order))}},Be={setStateSchemaOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].schema=t.input.schema;else throw new Error(`Invalid scope: ${t.input.scope}`)},setInitialStateOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].initialValue=t.input.initialValue;else throw new Error(`Invalid scope: ${t.input.scope}`)},addStateExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].examples.push({id:t.input.id,value:t.input.example});else throw new Error(`Invalid scope: ${t.input.scope}`)},updateStateExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];if(!Object.keys(n.state).includes(t.input.scope))throw new Error(`Invalid scope: ${t.input.scope}`);const r=n.state[t.input.scope].examples;for(let i=0;i<r.length;i++)r[i].id==t.input.id&&(r[i].value=t.input.newExample)},deleteStateExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].examples=n.state[t.input.scope].examples.filter(r=>r.id!=t.input.id);else throw new Error(`Invalid scope: ${t.input.scope}`)},reorderStateExamplesOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].examples.sort(nt(t.input.order));else throw new Error(`Invalid scope: ${t.input.scope}`)}},Ke={addChangeLogItemOperation(e,t){throw new Error('Reducer "addChangeLogItemOperation" not yet implemented')},updateChangeLogItemOperation(e,t){throw new Error('Reducer "updateChangeLogItemOperation" not yet implemented')},deleteChangeLogItemOperation(e,t){throw new Error('Reducer "deleteChangeLogItemOperation" not yet implemented')},reorderChangeLogItemsOperation(e,t){throw new Error('Reducer "reorderChangeLogItemsOperation" not yet implemented')},releaseNewVersionOperation(e,t){throw new Error('Reducer "releaseNewVersionOperation" not yet implemented')}},Vs=(e,t)=>{if(yn(t))return e;switch(t.type){case"SET_MODEL_NAME":rr().parse(t.input),je.setModelNameOperation(e.global,t);break;case"SET_MODEL_ID":nr().parse(t.input),je.setModelIdOperation(e.global,t);break;case"SET_MODEL_EXTENSION":tr().parse(t.input),je.setModelExtensionOperation(e.global,t);break;case"SET_MODEL_DESCRIPTION":er().parse(t.input),je.setModelDescriptionOperation(e.global,t);break;case"SET_AUTHOR_NAME":qn().parse(t.input),je.setAuthorNameOperation(e.global,t);break;case"SET_AUTHOR_WEBSITE":Yn().parse(t.input),je.setAuthorWebsiteOperation(e.global,t);break;case"ADD_CHANGE_LOG_ITEM":Nn().parse(t.input),Ke.addChangeLogItemOperation(e.global,t);break;case"UPDATE_CHANGE_LOG_ITEM":_r().parse(t.input),Ke.updateChangeLogItemOperation(e.global,t);break;case"DELETE_CHANGE_LOG_ITEM":Bn().parse(t.input),Ke.deleteChangeLogItemOperation(e.global,t);break;case"REORDER_CHANGE_LOG_ITEMS":Gn().parse(t.input),Ke.reorderChangeLogItemsOperation(e.global,t);break;case"RELEASE_NEW_VERSION":if(Object.keys(t.input).length>0)throw new Error("Expected empty input for action RELEASE_NEW_VERSION");Ke.releaseNewVersionOperation(e.global,t);break;case"ADD_MODULE":zn().parse(t.input),Xe.addModuleOperation(e.global,t);break;case"SET_MODULE_NAME":or().parse(t.input),Xe.setModuleNameOperation(e.global,t);break;case"SET_MODULE_DESCRIPTION":ir().parse(t.input),Xe.setModuleDescriptionOperation(e.global,t);break;case"DELETE_MODULE":Fn().parse(t.input),Xe.deleteModuleOperation(e.global,t);break;case"REORDER_MODULES":Xn().parse(t.input),Xe.reorderModulesOperation(e.global,t);break;case"ADD_OPERATION_ERROR":Pn().parse(t.input),ze.addOperationErrorOperation(e.global,t);break;case"SET_OPERATION_ERROR_CODE":ar().parse(t.input),ze.setOperationErrorCodeOperation(e.global,t);break;case"SET_OPERATION_ERROR_NAME":ur().parse(t.input),ze.setOperationErrorNameOperation(e.global,t);break;case"SET_OPERATION_ERROR_DESCRIPTION":lr().parse(t.input),ze.setOperationErrorDescriptionOperation(e.global,t);break;case"SET_OPERATION_ERROR_TEMPLATE":cr().parse(t.input),ze.setOperationErrorTemplateOperation(e.global,t);break;case"DELETE_OPERATION_ERROR":$n().parse(t.input),ze.deleteOperationErrorOperation(e.global,t);break;case"REORDER_OPERATION_ERRORS":Kn().parse(t.input),ze.reorderOperationErrorsOperation(e.global,t);break;case"ADD_OPERATION_EXAMPLE":xo().parse(t.input),ut.addOperationExampleOperation(e.global,t);break;case"UPDATE_OPERATION_EXAMPLE":No().parse(t.input),ut.updateOperationExampleOperation(e.global,t);break;case"DELETE_OPERATION_EXAMPLE":Io().parse(t.input),ut.deleteOperationExampleOperation(e.global,t);break;case"REORDER_OPERATION_EXAMPLES":Co().parse(t.input),ut.reorderOperationExamplesOperation(e.global,t);break;case"ADD_OPERATION":Ln().parse(t.input),ve.addOperationOperation(e.global,t);break;case"SET_OPERATION_NAME":pr().parse(t.input),ve.setOperationNameOperation(e.global,t);break;case"SET_OPERATION_SCOPE":dr().parse(t.input),ve.setOperationScopeOperation(e.global,t);break;case"SET_OPERATION_SCHEMA":hr().parse(t.input),ve.setOperationSchemaOperation(e.global,t);break;case"SET_OPERATION_DESCRIPTION":sr().parse(t.input),ve.setOperationDescriptionOperation(e.global,t);break;case"SET_OPERATION_TEMPLATE":mr().parse(t.input),ve.setOperationTemplateOperation(e.global,t);break;case"SET_OPERATION_REDUCER":fr().parse(t.input),ve.setOperationReducerOperation(e.global,t);break;case"MOVE_OPERATION":Zn().parse(t.input),ve.moveOperationOperation(e.global,t);break;case"DELETE_OPERATION":Wn().parse(t.input),ve.deleteOperationOperation(e.global,t);break;case"REORDER_MODULE_OPERATIONS":Vn().parse(t.input),ve.reorderModuleOperationsOperation(e.global,t);break;case"SET_STATE_SCHEMA":gr().parse(t.input),Be.setStateSchemaOperation(e.global,t);break;case"SET_INITIAL_STATE":Qn().parse(t.input),Be.setInitialStateOperation(e.global,t);break;case"ADD_STATE_EXAMPLE":Un().parse(t.input),Be.addStateExampleOperation(e.global,t);break;case"UPDATE_STATE_EXAMPLE":br().parse(t.input),Be.updateStateExampleOperation(e.global,t);break;case"DELETE_STATE_EXAMPLE":Hn().parse(t.input),Be.deleteStateExampleOperation(e.global,t);break;case"REORDER_STATE_EXAMPLES":Jn().parse(t.input),Be.reorderStateExamplesOperation(e.global,t);break;default:return e}},wr=Dn(Vs),Xs=(e,t)=>Wi(e,t),Ks=e=>Hi(e,wr),Or=e=>({...$t(),global:{...Is,...e?.global??{}},local:{...vs,...e?.local??{}}});function Js(){return{...$t(),author:{name:"",website:""},description:"",extension:"",id:"",name:"",specifications:[]}}function qs(){return{}}function Ys(e){return{...Js(),...e||{}}}function Qs(e){return{...qs()}}function ea(e,t,n){return{...Oo(e?.auth,e?.document),global:Ys(t),local:Qs()}}function ta(e){const t=Ri(Or,e);return t.header.documentType=yr,t}const na=e=>Ds(e),ra=e=>{Cs(e)},ia=e=>Ms(e),oa=e=>{Ns(e)},sa={fileExtension:xs,createState:Or,createDocument:ta,loadFromInput:Ks,saveToFileHandle:Xs,isStateOfType:na,assertIsStateOfType:ra,isDocumentOfType:ia,assertIsDocumentOfType:oa},Oa={reducer:wr,documentModel:ea($t(),As),actions:Os,utils:sa};export{yr as $,pa as A,ks as B,lt as C,ya as D,_a as E,ba as F,Po as G,cs as H,Lo as I,jo as J,Uo as K,Bo as L,Fo as M,ps as N,$o as O,Wo as P,Zo as Q,Xo as R,Jo as S,qo as T,ts as U,rs as V,ls as W,os as X,Vo as Y,ga as Z,ua as _,Dn as a,$i as a0,Os as a1,Ii as a2,Ea as a3,Sa as a4,wa as a5,fi as a6,di as a7,Oa as a8,Rs as b,oe as c,Wi as d,Hi as e,Ri as f,mn as g,$t as h,yn as i,ea as j,gn as k,vi as l,Ct as m,ha as n,Re as o,on as p,da as q,ma as r,Te as s,fa as t,Ti as u,ca as v,dt as w,En as x,Mi as y,Pi as z};