@betteroffice/xlsx 0.5.1 → 0.6.1

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 (50) hide show
  1. package/LICENSES/MIT-ruzstd.txt +21 -0
  2. package/LICENSES/MIT-twox-hash.txt +21 -0
  3. package/LICENSES/MIT-wuff.txt +20 -0
  4. package/README.md +45 -10
  5. package/dist/chunk-3HDY7PGX.js +1 -0
  6. package/dist/chunk-4YUSZI3G.js +2 -0
  7. package/dist/chunk-6OSHYRMV.js +1 -0
  8. package/dist/chunk-AZDGFDN2.js +1 -0
  9. package/dist/chunk-B5K4E4KI.js +1 -0
  10. package/dist/chunk-E4HKBJOP.js +7 -0
  11. package/dist/chunk-FEO7P5TH.js +1 -0
  12. package/dist/chunk-GHET7GIK.js +1 -0
  13. package/dist/chunk-JABP2QRG.js +1 -0
  14. package/dist/chunk-K2GIAESV.js +2 -0
  15. package/dist/chunk-KNQOCV7P.js +1 -0
  16. package/dist/chunk-OUNTNO7R.js +1 -0
  17. package/dist/chunk-QUHWI3QK.js +1 -0
  18. package/dist/chunk-S6UYP4BX.js +1 -0
  19. package/dist/chunk-T4GUPT57.js +1 -0
  20. package/dist/chunk-VJDPZ75R.js +1 -0
  21. package/dist/chunk-X5HR6GJB.js +4 -0
  22. package/dist/collaboration.js +1 -1
  23. package/dist/{editPeer-DiFeIMPk.d.ts → editPeer-CVhOkqsr.d.ts} +426 -61
  24. package/dist/generated/preflight/xlsx_preflight_bg.wasm +0 -0
  25. package/dist/generated/xlsx_wasm_bg.wasm +0 -0
  26. package/dist/generated/xlsx_wasm_lean_bg.wasm +0 -0
  27. package/dist/headless.d.ts +8 -2
  28. package/dist/headless.js +1 -1
  29. package/dist/index.d.ts +27 -5
  30. package/dist/index.js +1 -4
  31. package/dist/sessionWorker.missing.d.ts +3 -0
  32. package/dist/sessionWorker.missing.js +1 -0
  33. package/dist/sessionWorker.node.d.ts +3 -0
  34. package/dist/sessionWorker.node.js +1 -0
  35. package/dist/{types-DdoEoFSX.d.ts → types-BXjmeL2E.d.ts} +71 -3
  36. package/dist/wasm-preflight.d.ts +26 -0
  37. package/dist/wasm-preflight.js +1 -0
  38. package/dist/worker.d.ts +3 -3
  39. package/dist/worker.js +1 -1
  40. package/dist/xlsxSessionWorker.mjs +7 -1
  41. package/dist/xlsxSessionWorker.node.mjs +1 -0
  42. package/dist/xlsxWorkerStart.d.ts +11 -0
  43. package/dist/xlsxWorkerStart.js +1 -0
  44. package/package.json +20 -6
  45. package/dist/chunk-DIDVDN7H.js +0 -1
  46. package/dist/chunk-HJJEOLPD.js +0 -1
  47. package/dist/chunk-JGTBRHCP.js +0 -1
  48. package/dist/chunk-K7TMSGNA.js +0 -1
  49. package/dist/chunk-SXM2HKJL.js +0 -4
  50. /package/dist/{xlsxSessionWorker.d.ts → xlsxSessionWorker.node.d.ts} +0 -0
@@ -1 +1,7 @@
1
- import {i,e,j,H,ca,K,n,b,a,g,Z,ba,t,z,y,r,v,f,o,M,P,O,k,N,A,m,w,F,aa,c as c$1,d as d$1,u,U,_,Q,W,S,V,$,T,R,Y as Y$1}from'./chunk-K7TMSGNA.js';import {a as a$1,c,b as b$1,d}from'./chunk-DIDVDN7H.js';import {b as b$2,u as u$1,d as d$2}from'./chunk-JGTBRHCP.js';import {a as a$2}from'./chunk-O2XFH626.js';async function je(t){let e=await fetch(t);if(typeof WebAssembly.compileStreaming=="function")try{return await WebAssembly.compileStreaming(e.clone())}catch(o){if(!e.ok||!["basic","cors","default"].includes(e.type)||e.headers.get("Content-Type")==="application/wasm")throw o}return WebAssembly.compile(await e.arrayBuffer())}function St(t,e$1,o,f=je){let a,r=false;function s(){return a||(a=f(e$1),a.catch(()=>{})),a}return t.listen(c=>{e(c)&&c.kind==="wasm-compile"&&s();}),async c=>{if(c!==void 0)return o(c);let g=s(),q;try{q=await g;}catch(k){throw a===g&&(a=void 0),k}if(await o(q),!r){r=true;let k={protocol:1,kind:"wasm-module",url:e$1.href,module:q};try{t.post(k);}catch{}}}}var ze=class{constructor(e){a$2(this,"emit",e);a$2(this,"listener",null);}connect(){}disconnect(){this.emit("disconnect");}send(e){return this.emit(e),true}onEvent(e){return this.listener=e,()=>{this.listener===e&&(this.listener=null,this.emit("unsubscribe"));}}deliver(e){this.listener?.(e);}};function Ct(t){let e=new Map,o=[],f=false,a=false,r=null,s=(n,l)=>{if(a)return;let p=!f&&o.length===0,m=o[o.length-1];m?.provider===n?m.out.push(l):o.push({provider:n,out:[l]}),p&&t.onOutput?.();},c=()=>{let n=r;if(!n||n.updates.length===0)return;r={updates:[],arrivals:[],single:true};let l=t.merge(n.updates,n.single&&n.updates.length===1);if("failed"in l){for(let p of n.arrivals)p.fail(l.failed);return}n.arrivals.forEach((p,m)=>p.settle(m===n.arrivals.length-1?l.applied:null));},g=(n,l,p)=>{if(!r)throw new Error("Collaboration updates merge only within a pipe burst");return r.updates.push(...l),r.arrivals.push(t.arrive(n)),r.single&&(r.single=p),null},q=n=>({clientId:t.clientId,encodeStateVector:()=>(c(),t.read.encodeStateVector()),encodeStateAsUpdate:l=>(c(),t.read.encodeStateAsUpdate(l)),...t.read.encodeStateAsUpdateChunks&&{encodeStateAsUpdateChunks:(l,p)=>(c(),t.read.encodeStateAsUpdateChunks(l,p))},applyUpdate:l=>g(n(),[l],true),applyUpdateChunks:l=>g(n(),l,false),onUpdate:t.onUpdate}),k=(n,l)=>{let p,m=new ze(D=>{p.echo||s(n,typeof D=="string"?{do:D,through:p.through}:{do:"send",data:b$2(D),through:p.through});}),E=t.createProvider(q(()=>p.provider),m,l);p={id:n,provider:E,transport:m,through:0,echo:false,leaveClock:null,stop:[]};let U=false;return p.stop.push(E.onStatus(({status:D,synced:Z})=>s(n,{do:"status",status:D,synced:Z,through:p.through})),E.onError(D=>{p.echo||s(n,{do:"error",error:{code:D.code,message:D.message},through:p.through});}),E.onPeers(D=>{U&&s(n,{do:"peers",peers:[...D],timeOrigin:d$2(),through:p.through});})),U=true,e.set(n,p),p},b=(n,l)=>{n.echo=true;try{l();}finally{n.echo=false;}},v=n=>{let l=e.get(n.provider);for(let p of n.ops){if(p.op==="create"){l??(l=k(n.provider,p.options)),l.through=p.seq;continue}if(!l){s(n.provider,{do:"lost"});return}let m=l;switch(m.through=p.seq,p.op){case "connect":b(m,()=>m.provider.connect());break;case "disconnect":b(m,()=>m.provider.disconnect());break;case "fail":b(m,()=>m.transport.deliver({type:"error",error:t.transportError(p.error)}));break;case "destroy":b(m,()=>m.provider.destroy());for(let E of m.stop)E();e.delete(m.id),l=void 0;break;case "cursor":m.provider.setCursor(p.cursor,p.broadcast);break;case "event":{let{event:E}=p;m.transport.deliver(E.type==="message"?{type:"message",data:new Uint8Array(E.data)}:E);break}}}},P=()=>{for(let n of e.values()){let l=t.leave(n.provider),p=l?.clock??null;p!==n.leaveClock&&(n.leaveClock=p,s(n.id,{do:"leave",data:l?b$2(l.frame):null,through:n.through}));}};return {run(n){if(!a){f=true,r={updates:[],arrivals:[],single:true};try{v(n),c();}finally{r=null,f=false;}}},drain(){f=true;try{P();}finally{f=false;}if(o.length===0)return;let n=o;o=[];let l=[];for(let p of n)for(let m of p.out)(m.do==="send"||m.do==="leave"&&m.data)&&l.push(m.data);return {batches:n,transfer:l}},dispose(){if(!a){a=true;for(let n of e.values()){for(let l of n.stop)l();n.echo=true;try{n.provider.destroy();}catch{}}e.clear(),o=[];}}}}var Gt=256,Kt=64,Yt=128,Se=1e5,Oe=1048576,Wt=16*1024*1024;function ce(t,e,o,f=false){let a=s=>{let c=o[e.indexOf(s)];if(f&&c===void 0)throw new aa("target-sheet-missing");return c??s},r=s=>Array.isArray(s)?s.map(r):!s||typeof s!="object"?s:Object.fromEntries(Object.entries(s).map(([c,g])=>[c,c==="sheetId"&&typeof g=="string"?a(g):(c==="sheetIds"||c==="changedSheets")&&Array.isArray(g)?g.map(a):r(g)]));return r(t)}function Zt(t){let e="";for(let o=t+1;o>0;o=Math.floor((o-1)/26))e=String.fromCharCode(65+(o-1)%26)+e;return e}function de(t){if(!Number.isSafeInteger(t.row)||t.row<0||t.row>=1048576||!Number.isSafeInteger(t.col)||t.col<0||t.col>=16384)throw new aa("missing-target");return `${Zt(t.col)}${t.row+1}`}function Je(t){if(t.kind==="rowCol"){if(de(t.start),de(t.end),t.start.row>t.end.row||t.start.col>t.end.col)throw new aa("missing-target");return {start:t.start,end:t.end}}let e=/^\$?([A-Za-z]+)\$?([1-9]\d*)(?::\$?([A-Za-z]+)\$?([1-9]\d*))?$/.exec(t.a1);if(!e)throw new aa("missing-target");let o=(f,a)=>{let r=0;for(let c of f.toUpperCase())r=r*26+c.charCodeAt(0)-64;let s={row:Number(a)-1,col:r-1};return de(s),s};return Je({kind:"rowCol",start:o(e[1],e[2]),end:o(e[3]??e[1],e[4]??e[2])})}function Y(t,e,o=t.sheetInfo().sheetIds){let f=o.indexOf(e.sheetId);if(f<0)throw new aa("target-sheet-missing");let{start:a,end:r}=Je(e.range);return {sheet:f,start:a,end:r,range:`${de(a)}:${de(r)}`}}function Et(t,e,o){let{start:f,end:a}=Y(t,o,e.sheetIds);if(o.activeCell&&(de(o.activeCell),o.activeCell.row<f.row||o.activeCell.row>a.row||o.activeCell.col<f.col||o.activeCell.col>a.col))throw new aa("missing-target")}function Fe(t,e,o,f=t.sheetInfo().sheetIds){let a=f[e];if(a===void 0)throw new aa("missing-target");let r={sheetId:a,range:o};return Y(t,r,f),r}function Pt(t,e,o,f,a=t.sheetInfo().sheetIds){return Fe(t,e,{kind:"rowCol",start:{row:o,col:f},end:{row:o,col:f}},a)}function Xe(t,e){let o=t.version(),f=new TextEncoder,a=f.encode(JSON.stringify({expectVersion:o,steps:[]})).length,r=[],s=0,c=0,g=a,q=()=>{if(r.length===0)return;let k=t.validateEdits({expectVersion:o,steps:r});if(!k.ok)throw new aa(k.failure.code,k);r=[],s=c=0,g=a;};for(let k of e){let{start:b,end:v}=Je(k.target.range),P=(v.row-b.row+1)*(v.col-b.col+1),n=k.op==="setCellInputs"?k.inputs.flat().reduce((m,E)=>m+E.length,0):0,l={op:"patchStyle",target:k.target,patch:{}},p=f.encode(JSON.stringify(l)).length+1;if((r.length===Yt||s+P>Se||c+n>Oe||g+p>Wt)&&q(),P>Se||n>Oe||g+p>Wt)throw new aa("limit-exceeded");r.push(l),s+=P,c+=n,g+=p;}q();}function qt(t,e,o=t.sheetInfo().sheetIds){let f=new Map;for(let c of e)Pt(t,c.sheet,c.row,c.col,o),f.set(`${c.sheet}:${c.row}:${c.col}`,c);let a=[...f.values()].sort((c,g)=>c.sheet-g.sheet||c.row-g.row||c.col-g.col),r=[],s=new Map;for(let c=0;c<a.length;){let g=a[c++],q=g,k=[g.input],b=g.input.length;for(;c<a.length&&a[c].sheet===g.sheet&&a[c].row===g.row&&a[c].col===q.col+1&&k.length<Se&&b+a[c].input.length<=Oe;)q=a[c++],k.push(q.input),b+=q.input.length;let v=`${g.sheet}:${g.col}:${q.col}`,P=s.get(v);if(P?.step.target.range.kind==="rowCol"&&P.step.target.range.end.row===g.row-1&&P.cells+k.length<=Se&&P.text+b<=Oe)P.step.target.range.end.row=g.row,P.step.inputs.push(k),P.cells+=k.length,P.text+=b;else {let n={op:"setCellInputs",target:Fe(t,g.sheet,{kind:"rowCol",start:{row:g.row,col:g.col},end:{row:g.row,col:q.col}},o),inputs:[k]};r.push(n),s.set(v,{step:n,cells:k.length,text:b});}}return r}function Qe(t,e,o){try{return t.captureFormat(e,o)}catch(f){throw f instanceof Error&&!(f instanceof WebAssembly.RuntimeError)&&/^sheet \d+ is not an editable worksheet$/.test(f.message)?new aa("unsupported"):f}}function Ie(t,e,o){let f=Y(t,Fe(t,e,{kind:"a1",a1:o})),a=t.readCells({ranges:[]});if(!a.ok)throw new Error(a.failure.message);if(!a.sheets[e].editable)throw Qe(t,e,"A1"),new aa("locked-target");if((f.end.row-f.start.row+1)*(f.end.col-f.start.col+1)>1e5)throw new aa("limit-exceeded")}function eo(t,e){if(e.end.row<1048575&&e.end.col<16383)return e;let o=t.selectionData(e.sheet,0,0,"usedRange").usedRange;if(!o)return null;let f={row:Math.max(e.start.row,o.top),col:Math.max(e.start.col,o.left)},a={row:Math.min(e.end.row,o.bottom),col:Math.min(e.end.col,o.right)};return f.row>a.row||f.col>a.col?null:{...e,start:f,end:a,range:`${de(f)}:${de(a)}`}}function to(t,e,o){if(o.kind==="select"||o.kind==="setReadOnly"||o.kind==="applyUpdate"||o.kind==="collabPipe")throw new aa("invalid-command");let f=o.payload;if(o.kind==="applyOps"&&"toolbar"in f){let{toolbar:s}=f;if(!s.target)throw new aa("invalid-command");let c=Y(t,s.target,e.sheetIds),g=s.id==="clear"?eo(t,c):c;if(!g)return {method:"editCells",args:[c.sheet,[]]};if(s.id==="clear"&&(g.end.row-g.start.row+1)*(g.end.col-g.start.col+1)>Se)throw new aa("limit-exceeded");s.id!=="clear"&&Ie(t,g.sheet,g.range);let q=s.id==="clear"?{}:t.selectionFormatting(g.sheet,g.range),k=s.id==="merge"?t.mergedRanges(g.sheet,g.range):[],b=Y$1(s,g,q,k);if(!b)throw new aa("invalid-command");return b}if(o.kind==="applyFormat"&&"formatToken"in f){let s=e.formats.get(f.formatToken);if(!s)throw new aa("invalid-command");let c=Y(t,f.target,e.sheetIds);return {method:"applyFormat",args:[c.sheet,c.range,s]}}if(o.kind==="applyFormat"&&"capturedFrom"in f){let s=Y(t,f.target,e.sheetIds),c=Y(t,f.capturedFrom,e.sheetIds);if((c.end.row-c.start.row+1)*(c.end.col-c.start.col+1)>1e5)throw new aa("limit-exceeded");return {method:"applyFormat",args:[s.sheet,s.range,Qe(t,c.sheet,c.range)]}}if(!("args"in f))throw new aa("invalid-command");let a={method:o.kind,args:[...f.args],calculation:f.calculation},r=()=>{if(e.bases.get(o.basis.version)!==e.sheetRevision)throw new aa("stale-target")};if(a.method==="applyOps"){let s=[...e.sheetIds],c=e.nextSheetId;return a.args[0]=a.args[0].map(g=>{let{target:q=f.target,...k}=g;if(q){let b=Y(t,q,s);if(k.type==="removeSheet")k.index=b.sheet;else if(k.type==="moveSheet")k.from=b.sheet;else if("sheet"in k)k.sheet=b.sheet;else throw new aa("invalid-command")}else if(("sheet"in k||"index"in k||k.type==="moveSheet"||k.type==="setDefinedNames"||k.type==="restoreSheet")&&(r(),s.length!==e.sheetIds.length||s.some((b,v)=>b!==e.sheetIds[v])))throw new aa("stale-target");if(k.type==="addSheet")s.splice(k.index,0,`command-sheet:${c++}`);else if(k.type==="removeSheet")s.splice(k.index,1);else if(k.type==="moveSheet"){let[b]=s.splice(k.from,1);s.splice(k.to,0,b);}return k}),a}if(a.method==="propose")return a.args[2]=a.args[2].map(s=>{let{target:c=f.target,...g}=s;return c?g.sheet=Y(t,c,e.sheetIds).sheet:r(),g}),a;if(f.target){let s=Y(t,f.target,e.sheetIds);switch(a.method){case "editCell":if(s.start.row!==s.end.row||s.start.col!==s.end.col)throw new aa("invalid-command");a.args=[s.sheet,s.start.row,s.start.col,a.args[3]];break;case "editCells":a.args[0]=s.sheet;break;case "patchRangeStyle":case "setNumberFormat":case "applyFormat":a.args[0]=s.sheet,a.args[1]=s.range;break;case "setActiveSheet":a.args[0]=s.sheet;break;case "moveChart":case "moveRange":a.args[0]=s.sheet;break;default:throw new aa("invalid-command")}}else ["editCell","editCells","patchRangeStyle","setNumberFormat","applyFormat","setActiveSheet","moveChart","moveRange"].includes(a.method)&&r();return a}function oo(t,e,o){switch(o.method){case "applyEdits":if(o.args[0].expectVersion!==t.version())throw new aa("stale-version");for(let f of o.args[0].steps)Y(t,f.target,e.sheetIds);o.args[0]=ce(o.args[0],e.sheetIds,t.sheetInfo().sheetIds);break;case "editCell":{let[f,a,r]=o.args;Xe(t,[{op:"patchStyle",target:Pt(t,f,a,r,e.info?.sheetIds),patch:{}}]);break}case "editCells":{let[f,a]=o.args;Xe(t,qt(t,a.map(r=>({...r,sheet:f})),e.info?.sheetIds));break}case "applyOps":for(let f of o.args[0]){let a=f,r=a.type==="setColWidth"?a.width:a.type==="setRowHeight"?a.height:void 0,s=a.type==="setColWidth"?255:409.5;if(r!=null&&(typeof r!="number"||!Number.isFinite(r)||r<0||r>s))throw new aa("invalid-step")}break;case "patchRangeStyle":case "setNumberFormat":Ie(t,o.args[0],o.args[1]);break;case "propose":if(!t.isProposalsAvailable())throw new aa("unsupported");Xe(t,qt(t,o.args[2],e.info?.sheetIds));break;case "acceptProposal":if(!t.isProposalsAvailable())throw new aa("unsupported");if(!t.listProposals().some(f=>f.id===o.args[0]))throw new aa("missing-target");break;case "applyFormat":if(Ie(t,o.args[0],o.args[1]),o.args[2].rows===0||o.args[2].columns===0||o.args[2].formats.length!==o.args[2].rows*o.args[2].columns)throw new aa("invalid-command");break;case "setActiveSheet":case "moveChart":case "moveRange":Fe(t,o.args[0],{kind:"a1",a1:"A1"});break}}function At(t,e){if(t instanceof aa)return t;if(e==="acceptProposal"&&t instanceof k)return new aa("stale-proposal",{cells:t.cells,targets:t.targets});if(!(!(t instanceof Error)||t instanceof WebAssembly.RuntimeError)){if(e==="applyOps"&&t.message==="structural operations are unavailable in collaborative mode")return new aa("unsupported");if(t.message==="calculation context is unavailable for collaborative workbooks")return new aa("unsupported");if(["applyOps","patchRangeStyle","setNumberFormat","applyFormat","propose","acceptProposal"].includes(e??"")&&t.message==="number format table is full")return new aa("limit-exceeded");if(e==="applyOps"&&(t.message==="invalid collaborative workbook state: too many sheet merge edits"||t.message==="invalid collaborative workbook state: too many sheet hyperlink edits"))return new aa("limit-exceeded");if(e==="applyOps"&&(/^formula at sheet \d+, [A-Z]+[1-9]\d* cannot be safely rewritten$/.test(t.message)||/^(?:defined name|chart reference in) .+ cannot be safely rewritten$/.test(t.message)||/^.+ references cells this edit would move, and it cannot be rewritten$/.test(t.message)||/^anchor \d+ of .+ is held by two sheets that disagree on where it sits$/.test(t.message)||/^chart .+ cannot change how it follows a grid edit$/.test(t.message)||/^chart .+ cannot be resized: a one-cell extent is not written back$/.test(t.message)||/^chart .+ cannot change its anchor kind$/.test(t.message)))return new aa("unsupported");if(e==="moveRange"&&(/^range move cannot safely preserve .+$/.test(t.message)||/^.+ contains worksheet features a cell move cannot safely preserve$/.test(t.message)||/^.+ references cells this move would relocate, and it cannot be rewritten$/.test(t.message)))return new aa("unsupported");if(e==="applyOps"&&/^chart frame .+ does not hold the chart part and anchor this op was recorded against; its drawing has changed$/.test(t.message))return new aa("stale-target");if((e==="editCell"||e==="editCells"||e==="propose"||e==="acceptProposal"||e==="moveRange")&&/^(?:cell number must be finite|cell text exceeds Excel's length limit|formula exceeds the length limit)$/.test(t.message))return new aa("invalid-step");if((e==="applyOps"||e==="patchRangeStyle"||e==="setNumberFormat"||e==="applyFormat")&&(/^(?:font family must not be empty|font size must be between 1 and 400|captured format dimensions do not match its cells)$/.test(t.message)||/^invalid color .*; expected #rrggbb$/.test(t.message)))return new aa("invalid-step");if(e==="applyOps"&&(/^the anchor of .+ would leave the sheet grid$/.test(t.message)||/^defined name .+ has a formula above the length limit$/.test(t.message)||/^(?:chart reference exceeds the supported length|chart reference contains a character xml cannot carry)$/.test(t.message)))return new aa("invalid-step");if((e==="applyOps"||e==="moveChart")&&/^(?:anchor offset is out of range|anchor extent is not positive|anchor corners are inverted or coincident|anchor cell is outside the worksheet grid|anchor extends beyond the worksheet grid)$/.test(t.message))return new aa("invalid-step");if(e==="applyOps"&&/^bad ops: /.test(t.message)||e==="applyFormat"&&/^bad format args: /.test(t.message)||e==="editCells"&&/^bad edit args: /.test(t.message)||e==="moveRange"&&/^bad (?:move range args|range|move destination): /.test(t.message)||e==="applyEdits"&&/^malformed request: /.test(t.message))return new aa("invalid-command");if((e==="applyOps"||e==="moveChart"||e==="moveRange")&&(/^(?:sheet(?: index)?|row|column) \d+ (?:is )?out of range$/.test(t.message)||/^cell row \d+, column \d+ is out of range$/.test(t.message)||/^sheet \d+ is not an editable worksheet$/.test(t.message)||/^invalid sheet name: /.test(t.message)||/^duplicate sheet name: /.test(t.message)||/^(?:row|column) operation (?:count must be positive|exceeds sheet bounds)$/.test(t.message)||/^range \d+x\d+ exceeds the \d+-cell copy cap$/.test(t.message)||/^(?:workbook has no sheets|sheet contains too many hyperlinks|hyperlink must have a destination|hyperlink field exceeds its length limit)$/.test(t.message)||/^workbook contains (?:a non-finite cell number|cell text above Excel's length limit|a formula above the length limit|an invalid cell style index|an invalid column width|an invalid row height|overlapping merged ranges)$/.test(t.message)||/^no chart frame on this sheet is named /.test(t.message)||/^chart .+ is pinned to the sheet and cannot be moved$/.test(t.message)||/^(?:row|column) insertion would (?:discard content at|push a chart anchor past) the sheet boundary$/.test(t.message)||/^(?:freeze pane is out of range|range start must be above and left of range end|restore sheet operations are internal)$/.test(t.message)))return new aa("invalid-step")}}function Te(t,e,o,f,a=null){return {identity:t,epoch:e.epoch,throughSeq:0,selection:o,readOnly:false,statuses:new Map,bases:new Map([[e.version,0]]),sheetRevision:0,historySelections:[],sheetIds:[...f],nextSheetId:f.length,calculation:a,formats:new Map}}function Ce(t,e){let o=e.editState,f=!o||e.catalogDirty;(!e.info||f)&&(e.info=t.sheetInfo());let a=e.info;if(!e.editableSheets||f){let n=t.readCells({ranges:[]});if(!n.ok)throw new Error(n.failure.message);e.editableSheets=n.sheets.map(l=>l.editable);}let r=t.historyState(),s=JSON.stringify(e.selection),c=e.formattingSelection!==s,g=o?.formatting,q=o?.mergedRanges,k=o?.formattingAvailable??false,b=o?.selectionEditable??false;if(!g||e.formattingDirty||c){let n=Y(t,e.selection,e.sheetIds),{sheet:l,start:p,end:m}=n;b=e.editableSheets[l],k=b&&(m.row-p.row+1)*(m.col-p.col+1)<=1e5,g=k?t.selectionFormatting(l,n.range):{};}if(!q||e.mergesDirty||c){let n=Y(t,e.selection,e.sheetIds);q=t.mergedRanges(n.sheet,n.range);}e.formattingSelection=s,e.formattingDirty=e.mergesDirty=e.catalogDirty=false;let v={canUndo:r.canUndo,canRedo:r.canRedo,formatting:g,formattingAvailable:k,selectionEditable:b,mergedRanges:q??[],calculation:t.calculationStatus(),sheets:f?e.sheetIds.map((n,l)=>({id:n,index:l,name:a.sheetNames[l]})):o.sheets,activeSheet:a.activeSheet,readOnly:e.readOnly,...e.historyReset?{historyReset:true}:{}},P={};for(let n of Object.keys(v))(!o||o[n]!==v[n]&&JSON.stringify(o[n])!==JSON.stringify(v[n]))&&Object.assign(P,{[n]:v[n]});return e.editState=v,Object.keys(P).length>0?P:void 0}function ro(t,e,o,f){if($(o,e.pipeFrameBytes),o.frame&&o.frame.sheet>=t.sheetCount())throw new aa("missing-target");if(o.kind==="collabPipe"){if(!f)throw new aa("unsupported");let p=t.version();f(o.payload);let m=e.pipeFrameBytes??(e.pipeFrameBytes=new Map);for(let U of o.payload.ops)if(U.op==="create")m.has(o.payload.provider)||m.set(o.payload.provider,U.options.maxFrameBytes??u$1);else if(m.has(o.payload.provider))U.op==="destroy"&&m.delete(o.payload.provider);else break;let E=t.version()!==p;return E&&(e.formattingDirty=e.mergesDirty=e.catalogDirty=true),{seq:o.seq,status:E?"applied":"noop",committed:E,...E?{result:{remoteUpdate:true,proposals:t.listProposals()}}:{}}}if(o.kind==="applyUpdate"){let p=t.version(),m=false;for(let E of [o.payload.update,...o.payload.updates??[]]){let U=t.version();try{t.applyUpdate(E);}catch(D){if(!(D instanceof Error)||D instanceof WebAssembly.RuntimeError||t.version()!==U)throw D;if(U===p)throw new aa("invalid-update");m=true;break}}return e.formattingDirty=e.mergesDirty=e.catalogDirty=true,{seq:o.seq,status:t.version()===p?"noop":"applied",committed:t.version()!==p,result:{remoteUpdate:true,proposals:t.listProposals(),...m?{refusedUpdate:"invalid-update"}:{}}}}if(o.kind==="select"){Et(t,e,o.payload.selection);let p=JSON.stringify(e.selection)!==JSON.stringify(o.payload.selection);return e.selection=structuredClone(o.payload.selection),{seq:o.seq,status:p?"applied":"noop",committed:false}}if(o.kind==="setReadOnly"){let p=e.readOnly!==o.payload.readOnly;return e.readOnly=o.payload.readOnly,{seq:o.seq,status:p?"applied":"noop",committed:false}}let a=o.kind==="applyOps"&&"toolbar"in o.payload&&o.payload.toolbar.id==="refreshProposals";if(o.kind==="setActiveSheet"&&o.payload.expectVersion!==void 0&&o.payload.expectVersion!==t.version())throw new aa("stale-version");if(e.readOnly&&o.kind!=="setActiveSheet"&&!a)throw new aa("read-only");if(o.payload.selection&&Et(t,e,o.payload.selection),a)return {seq:o.seq,status:"applied",committed:false,result:{proposals:t.listProposals()}};if(o.kind==="applyOps"&&"toolbar"in o.payload&&o.payload.toolbar.id==="paintFormat"){let{target:p}=o.payload.toolbar;if(!p)throw new aa("invalid-command");let m=Y(t,p,e.sheetIds);Ie(t,m.sheet,m.range);let E=Qe(t,m.sheet,m.range),U=globalThis.crypto.getRandomValues(new Uint8Array(16)),D=`format:${Array.from(U,ee=>ee.toString(16).padStart(2,"0")).join("")}`;e.formats.set(D,E),e.formats.size>Kt&&e.formats.delete(e.formats.keys().next().value),o.payload.selection&&(e.selection=structuredClone(o.payload.selection));let Z={formatToken:D};return {seq:o.seq,status:"applied",committed:false,result:Z}}let r=to(t,e,o);if(oo(t,e,r),r.method==="setActiveSheet"&&o.payload.selection&&e.sheetIds[r.args[0]]!==o.payload.selection.sheetId)throw new aa("invalid-command");let s=t.version(),c=e.info?.activeSheet??t.sheetInfo().activeSheet,g$1=t.historyState(),q=structuredClone(e.selection),k=[...e.sheetIds],b;try{r.calculation&&t.setCalculationContext(r.calculation),b=O(t,r);}catch(p){let m=At(p,r.method);throw m&&t.version()===s?(r.calculation&&t.setCalculationContext(e.calculation),m):new g(p instanceof WebAssembly.RuntimeError?"trap":"crash",`Workbook command failed at sequence ${o.seq} (${o.kind})`,p instanceof Error?p.message:String(p))}if(N(b)){if(r.method!=="applyEdits"||t.version()!==s)throw new g("crash","Workbook command failed after dispatch");let p=b;throw r.calculation&&t.setCalculationContext(e.calculation),new aa(p.failure.code,p)}r.calculation&&(e.calculation={...r.calculation});let v=t.version()!==s,P=t.historyState();if(v&&r.method==="applyOps")for(let p of r.args[0]){let m=p;if(m.type==="addSheet")e.sheetIds.splice(m.index,0,`command-sheet:${e.nextSheetId++}`);else if(m.type==="removeSheet")e.sheetIds.splice(m.index,1);else if(m.type==="moveSheet"){let[E]=e.sheetIds.splice(m.from,1);e.sheetIds.splice(m.to,0,E);}}if(r.method==="undo"||r.method==="redo"){if(v){let p=r.method==="undo"?g$1.undoDepth:P.undoDepth,m=e.historySelections[p];if(m){e.sheetIds=[...r.method==="undo"?m.beforeSheets:m.afterSheets],e.selection=structuredClone(r.method==="undo"?m.before:m.after);let E=e.sheetIds.indexOf(e.selection.sheetId);E>=0&&t.setActiveSheet(E);}}}else o.payload.selection&&(e.selection=structuredClone(o.payload.selection));if(v){if(r.method==="undo"||r.method==="redo")e.formattingDirty=e.mergesDirty=true,e.catalogDirty=true;else if(r.method==="applyOps"){let p=r.args[0].map(E=>E.type),m=p.some(E=>["insertRows","deleteRows","insertCols","deleteCols","addSheet","removeSheet","moveSheet"].includes(E));e.formattingDirty=m||p.some(E=>["setCell","patchRangeStyle","setRangeNumberFormat","applyRangeFormat","restoreColStyles"].includes(E)),e.mergesDirty=m||p.some(E=>["mergeCells","unmergeCells"].includes(E)),e.catalogDirty=p.some(E=>["addSheet","removeSheet","moveSheet","renameSheet"].includes(E));}else (r.method==="patchRangeStyle"||r.method==="setNumberFormat"||r.method==="applyFormat"||r.method==="acceptProposal"||r.method==="moveRange"||r.method==="applyEdits"&&r.args[0].steps.some(p=>p.op==="patchStyle"||p.op==="setNumberFormat"))&&(e.formattingDirty=true);(k.length!==e.sheetIds.length||k.some((p,m)=>p!==e.sheetIds[m]))&&(e.sheetRevision+=1);}let n=!e.info||e.catalogDirty||r.method==="setActiveSheet"||r.method==="undo"||r.method==="redo"?t.sheetInfo():e.info;if(e.info=n,(!e.sheetIds.includes(e.selection.sheetId)||r.method==="setActiveSheet"&&!o.payload.selection&&c!==n.activeSheet)&&(e.selection={sheetId:e.sheetIds[n.activeSheet],range:{kind:"a1",a1:"A1"}}),r.method!=="undo"&&r.method!=="redo"&&v&&P.undoDepth>g$1.undoDepth){e.historySelections.length>g$1.undoDepth+1&&(e.historySelections.length=g$1.undoDepth+1);let p=structuredClone(e.selection);if(r.method==="editCell"){let[m,E,U]=r.args;p={sheetId:e.sheetIds[m],activeCell:{row:E,col:U},range:{kind:"rowCol",start:{row:E,col:U},end:{row:E,col:U}}};}e.historySelections[P.undoDepth]={before:q,after:p,beforeSheets:k,afterSheets:[...e.sheetIds]};}let l=r.method==="setActiveSheet"?c!==n.activeSheet||JSON.stringify(q)!==JSON.stringify(e.selection):r.method==="propose"||r.method==="acceptProposal"||r.method==="rejectProposal"&&b===true;return {seq:o.seq,status:v||l?"applied":"noop",committed:v,...b===void 0?{}:{result:ce(b,n.sheetIds,e.sheetIds)}}}function Rt(t,e,o,f,a=false,r){let s;try{if(f)throw new aa(f);if(a)s={seq:o.seq,status:"cancelled",reason:"dependency-refused",committed:!1,affectedSeqs:[o.seq]};else {if(!e.bases.has(o.basis.version))throw new aa("stale-basis");s=ro(t,e,o,r);}}catch(b){let v=At(b);if(!v)throw b instanceof g?b:new g(b instanceof WebAssembly.RuntimeError?"trap":"crash","Workbook command failed",b instanceof Error?b.message:String(b));s={seq:o.seq,status:"refused",reason:v.reason,committed:false,affectedSeqs:[o.seq],...v.result===void 0?{}:{result:ce(v.result,t.sheetInfo().sheetIds,e.sheetIds)}};}let c=t.version();if(e.bases.has(o.basis.version)){let b=e.bases.get(o.basis.version);e.bases.delete(o.basis.version),e.bases.set(o.basis.version,b);}e.bases.set(c,e.sheetRevision),e.bases.size>Gt&&e.bases.delete(e.bases.keys().next().value);let g$1=JSON.stringify(e.selection),q=g$1!==e.publishedSelection||s.status==="refused"||s.status==="cancelled"?structuredClone(e.selection):void 0;s.status!=="refused"&&s.status!=="cancelled"&&(e.publishedSelection=g$1);let k;try{k=Ce(t,e);}catch(b){throw new g(b instanceof WebAssembly.RuntimeError?"trap":"crash","Workbook command state projection failed",b instanceof Error?b.message:String(b))}return {throughSeq:o.seq,version:c,statuses:[s],...q?{selection:q}:{},...k?{editState:k}:{}}}var no=4096,xt=4096;function Ot(t,e){let o=new WeakMap,f=4096;function a(r,s,c){if(--f<0||c>32)return false;if(Object.is(r,s))return true;if(r===null||s===null||typeof r!="object"||typeof s!="object")return false;if(o.has(r))return o.get(r)===s;if(o.set(r,s),r instanceof Date||s instanceof Date)return r instanceof Date&&s instanceof Date&&Object.is(r.getTime(),s.getTime());if(r instanceof RegExp||s instanceof RegExp)return r instanceof RegExp&&s instanceof RegExp&&r.source===s.source&&r.flags===s.flags;if(r instanceof Number||s instanceof Number||r instanceof Boolean||s instanceof Boolean||r instanceof String||s instanceof String)return r.constructor===s.constructor&&Object.is(r.valueOf(),s.valueOf());if(r instanceof ArrayBuffer||s instanceof ArrayBuffer||ArrayBuffer.isView(r)||ArrayBuffer.isView(s)){let b=n=>n instanceof ArrayBuffer?new Uint8Array(n):ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):void 0,v=b(r),P=b(s);if(!v||!P||r.constructor!==s.constructor||v.byteLength!==P.byteLength||v.byteLength>f)return false;f-=v.byteLength;for(let n=0;n<v.length;n+=1)if(v[n]!==P[n])return false;return true}if(r instanceof Map||s instanceof Map||r instanceof Set||s instanceof Set){if(r.constructor!==s.constructor||!(r instanceof Map||r instanceof Set)||!(s instanceof Map||s instanceof Set)||r.size!==s.size||r.size>f)return false;let b=r.entries(),v=s.entries();for(let P=0;P<r.size;P+=1)if(!a(b.next().value,v.next().value,c+1))return false;return true}if(Array.isArray(r)!==Array.isArray(s)||Array.isArray(r)&&Array.isArray(s)&&r.length!==s.length||Object.getPrototypeOf(r)!==Object.getPrototypeOf(s)||!Array.isArray(r)&&Object.getPrototypeOf(r)!==Object.prototype&&Object.getPrototypeOf(r)!==null)return false;let g=Object.keys(r);if(g.length>f||g.length!==Object.keys(s).length)return false;let q=r,k=s;return g.every(b=>d$1(s,b)&&a(q[b],k[b],c+1))}return a(t,e,0)}function so(t=[]){let e=[];function o(a){let r=0,s=e.length;for(;r<s;){let c=Math.floor((r+s)/2),g=e[c];if(a<g[0])s=c;else if(a>g[1])r=c+1;else return true}return false}function f(a){if(!Number.isSafeInteger(a)||a<=0)throw new TypeError("Invalid replay sequence");let r=0;for(;r<e.length&&e[r][1]<a-1;)r+=1;let s=e[r];if(s&&s[0]<=a+1){s[0]=Math.min(s[0],a),s[1]=Math.max(s[1],a);let c=e[r+1];c&&c[0]<=s[1]+1&&(s[1]=Math.max(s[1],c[1]),e.splice(r+1,1));return}if(e.length===no)throw new g("out-of-memory","Command replay ledger exhausted: 4096 disjoint ranges per epoch");e.splice(r,0,[a,a]);}for(let a of t)f(a);return {contains:o,add:f}}function It(t){return {...t,...t.affectedSeqs===void 0?{}:{affectedSeqs:[...t.affectedSeqs]}}}function Ft(t,e){let o=e instanceof Error?e.message:String(e),f={name:R,refusal:{seq:t}};return Object.assign(new Error(`Command ${t} has an unknown outcome: ${o}`),f)}function io(t){return t instanceof Error&&!(t instanceof g)&&!(typeof WebAssembly<"u"&&t instanceof WebAssembly.RuntimeError)}function ye(t){if(t instanceof g)return t;let e=typeof WebAssembly<"u"&&t instanceof WebAssembly.RuntimeError;return new g(e?"trap":"crash",t instanceof Error?t.message:String(t))}function Tt(t){let e=t.retainedOutcomes??256,{session:o,incarnation:f,epoch:a$1,getVersion:r,apply:s,frame:c,snapshot:g$1,prunedDuplicateReason:q}=t,k=t.throughSeq??0,b$1=r();if(!Number.isSafeInteger(e)||e<0||!Number.isSafeInteger(k)||k<0||!Number.isFinite(b$1)||q!==void 0&&(typeof q!="string"||q.length===0))throw new TypeError("Invalid command host ledger");let v=new Map,P=so(t.refusedSeqs),n=new Set(t.replayAppliedSeqs);for(let u of n)if(!Number.isSafeInteger(u)||u<=0)throw new TypeError("Invalid replay sequence");let l,p=Promise.resolve(),m=0,E=0,U=0,D=0,Z=0,ee=new Map,ue,T$1,ie=false,Q$1=false,oe=k,w=0,A=t.queries?_():0,I=new Map;function _(){let u=t.layoutRevision?.()??0;if(!Number.isSafeInteger(u)||u<0)throw new TypeError("Invalid layout revision");return u}function H(u,S=[]){if(!(!t.checkRefusals||V.includes(u)||S.includes(u)||["stale-epoch","stale-incarnation","wrong-session","stale-version","dependency-refused","unknown-outcome","disposed"].includes(u)))throw M(new TypeError(`Undeclared refusal: ${u}`))}function M(u){return l=u,X(),u}function z(u){if(U===xt&&!l&&M(new g("out-of-memory","Command handler capacity exceeded")),l)return Promise.reject(l);U+=1;let O=p.then(()=>{if(l)throw l;return u()}).finally(()=>{U-=1,X();});return p=O.then(()=>{},()=>{}),O}function J(u){let S=ee.get(u);if(S){ee.delete(u);for(let O of S)O();}}function X(){if(!l)return;let u=l,S=[...ee.values()],O=[...I.values()];ee.clear(),I.clear();for(let W of S)for(let j of W)j();for(let W of O)for(let j of W)j.reject(u);}async function re(){try{let u=await c({coversThroughSeq:k,version:b$1});if(u===void 0)return;let S=c$1(u)?u.value:u;if(!T({session:o,incarnation:f,epoch:a$1,throughSeq:k,version:b$1,outcomes:[],frame:S})||S.coversThroughSeq!==k)throw new Error("Frame does not cover the settled command boundary");return u}catch(u){throw M(ye(u))}}async function te(){let u=await re();if(u===void 0)throw new Error("No frame is available at the settled command boundary");return u}function ne(u){if(u.status==="refused"||u.status==="cancelled")try{P.add(u.seq);}catch(S){throw M(ye(S))}if(k=u.seq,e>0&&(v.set(u.seq,It(u)),v.size>e&&v.delete(v.keys().next().value)),I.size)for(let S of [...I.keys()].sort((O,W)=>O-W)){if(S>k)break;let O=I.get(S);if(O){I.delete(S);for(let W of O)W.start();}}return u}function B(u,S,O=false){return {seq:u,status:O?"cancelled":"refused",reason:S,committed:false}}function y(u,S){let O={session:o,incarnation:f,epoch:a$1,throughSeq:k,version:b$1,outcomes:u?[It(u)]:[]};try{S&&d$1(S,"selection")&&(!ie||!(t.selectionEquals??Ot)(ue,S.selection))&&(ue=Q(S.selection),ie=!0,O.selection=Q(ue),t.queries&&(w+=1)),S&&d$1(S,"editState")&&(!Q$1||!(t.editStateEquals??Ot)(T$1,S.editState))&&(T$1=Q(S.editState),Q$1=!0,O.editState=Q(T$1)),t.queries&&(A=_(),O.revisions={selection:w,layout:A});}catch(W){throw M(ye(W))}return O}async function i(u){if(m>0||E>1)return u;try{let S=await re();if(S===void 0)return u;if(c$1(S)){if(u.frame=S.value,!T(u)||u.frame.coversThroughSeq!==k)throw new Error("Frame does not cover the settled command boundary");return b(u,S.transfer)}if(u.frame=S,!T(u)||S.coversThroughSeq!==k)throw new Error("Frame does not cover the settled command boundary");return u}catch(S){throw M(ye(S))}}function d(u){try{let S=r();if(!Number.isFinite(S)||S!==b$1)throw new Error("Version changed outside a command");return S}catch(S){throw M(Ft(u,S))}}function h(u){return S(u)&&u.session===o&&u.incarnation===f&&u.basis.epoch===a$1}async function C(u){if(!S(u))throw new TypeError("Invalid command envelope");if(u.session!==o)return y(B(u.seq,"wrong-session"));if(u.incarnation!==f)return y(B(u.seq,"stale-incarnation"));if(u.basis.epoch!==a$1){let N=B(u.seq,"stale-epoch");return y(u.seq>k?ne(N):N)}if(u.seq<=k)return i(y(v.get(u.seq)??(q===void 0?{seq:u.seq,status:"duplicate"}:B(u.seq,q))));if(P.contains(u.seq))return i(y(ne(B(u.seq,"unknown-outcome"))));if(u.afterSeq!==void 0&&P.contains(u.afterSeq))return i(y(ne(B(u.seq,"dependency-refused",true))));let S$1=u.replay===true&&n.has(u.seq);if(t.commands){if(!d$1(t.commands,u.kind))return i(y(ne(B(u.seq,"unsupported"))));if(t.commands[u.kind].admission==="local-write"&&!S$1&&t.readOnly?.())return i(y(ne(B(u.seq,"read-only"))))}let O=d(u.seq);if(u.expectVersion&&!S$1&&u.basis.version!==O)return i(y(ne(B(u.seq,"stale-version"))));let W;try{if(W=await s(u,{basis:u.basis,currentVersion:O,replayPreviouslyApplied:S$1}),!W||typeof W!="object"||W.status!=="applied"&&W.status!=="noop"&&W.status!=="cancelled"&&W.status!=="refused"||W.status==="applied"&&W.committed!==void 0&&W.committed!==!1||W.status==="cancelled"&&W.reason!==void 0&&typeof W.reason!="string")throw new Error("Invalid format apply result");let N=r();if(!Number.isFinite(N)||(W.status==="applied"&&W.committed!==!1?N<=O:N!==O))throw new Error(`${W.status} violated the command version contract`);b$1=N;}catch(N){throw M(Ft(u.seq,N))}W.status==="refused"&&H(W.reason,t.commands?.[u.kind]?.refusals);let j=W.status==="refused"?{...B(u.seq,W.reason),...W.affectedSeqs===void 0?{}:{affectedSeqs:W.affectedSeqs}}:W.status==="cancelled"?{seq:u.seq,status:"cancelled",committed:false,...W.reason===void 0?{}:{reason:W.reason}}:W.status==="applied"&&W.committed===false?{seq:u.seq,status:"applied",committed:false}:{seq:u.seq,status:W.status},G=y(ne(j),W);return W.status==="noop"&&t.deferFrame?.(u,W)?G:i(G)}let R={lane:"input",mutates:true,reframes:true,reorderable:false};function $(u,S){return {ok:false,refusal:{code:u,...S===void 0?{}:{detail:S}}}}function F(u){return !!u&&typeof u=="object"&&typeof u.session=="string"&&[u.incarnation,u.epoch,u.afterSeq].every(S=>Number.isSafeInteger(S)&&S>=0)}function L(u,S,O){return z(async()=>{let W$1;try{W$1=await t.queries.handlers[S](O,u);}catch(G){if(G instanceof g||typeof WebAssembly<"u"&&G instanceof WebAssembly.RuntimeError)throw M(ye(G));return $("invalid-payload",G instanceof Error?G.message:String(G))}if(W(W$1))return H(W$1.refusal.code,t.queries.specs[S].refusals),{ok:false,refusal:W$1.refusal};let j={ok:true,value:c$1(W$1)?W$1.value:W$1,at:{incarnation:f,epoch:a$1,throughSeq:k,doc:b$1,selection:w,layout:_()}};return c$1(W$1)?b(j,W$1.transfer):j})}return {handler(u,S){let O=h(S),W=O&&m>0;O&&(oe=Math.max(oe,S.seq),m=Math.max(0,m-1),E+=1);let j=z(()=>C(S));return W&&J(++D),X(),j.finally(()=>{O&&(E-=1),X();})},policy(u){return h(u)&&(m+=1,oe=Math.max(oe,u.seq)),{...R}},query(u,S,O,W){return l?Promise.reject(l):!F(S)||typeof O!="string"||!Array.isArray(W)?Promise.resolve($("invalid-payload")):S.session!==o||S.incarnation!==f||S.epoch!==a$1||S.afterSeq>oe?Promise.resolve($("stale")):!t.queries||!d$1(t.queries.specs,O)||!d$1(t.queries.handlers,O)?Promise.resolve($("unsupported")):k>=S.afterSeq?L(u,O,W):a(new Promise((j,G)=>{let N=I.get(S.afterSeq);N||I.set(S.afterSeq,N=[]),N.push({start:()=>{L(u,O,W).then(j,G);},reject:G});}))},queryPolicy(u,S,O){return {lane:"interactive",reorderable:(t.queries&&d$1(t.queries.specs,S)?t.queries.specs[S]:void 0)?.stale!=="answer-at-fence"}},revise(u){if(l)throw l;let S=b$1,O=A;b$1=r();let W=y(void 0,u);return b$1!==S||A!==O||d$1(W,"selection")||d$1(W,"editState")?W:void 0},checkpoint(u){return z(async()=>{let S;try{let O=r();if(O!==b$1)throw new Error("Version changed before checkpoint");let W;try{W=(await g$1()).slice();}catch(j){throw r()===O&&io(j)&&(S=j),j}if(r()!==O)throw new Error("Snapshot changed the command version");return b({state:W,epoch:a$1,version:b$1,throughSeq:k},[W.buffer])}catch(O){throw S||M(ye(O))}})},checkpointPolicy(){return {lane:"input",reorderable:false}},frame(){return Z===xt&&!l&&M(new g("out-of-memory","Command frame capacity exceeded")),l?(X(),Promise.reject(l)):m===0?z(te):(Z+=1,new Promise((u,S)=>{let O=D+m,W=ee.get(O);W||ee.set(O,W=[]),W.push(()=>{Z-=1,z(te).then(u,S);});}))}}}var Mt={capture:()=>{},restore:()=>{}},Ge=new Uint8Array([88,76,83,88,82,69,67,86]),Ut=3,le=21,ao=new Set([3,5,6,7]);function _t(t){let e=()=>{throw new TypeError("Unsupported workbook recovery checkpoint")};if(t.length<42||!Ge.every((a,r)=>t[r]===a)||!ao.has(t[8]))return e();let o=41,f=0;for(let a=0;a<=28;a+=7){let r=t[o++];if(r===void 0)return e();if(f+=(r&127)*2**a,r<128){if(f>t.length-o)return e();try{let s=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(t.subarray(o,o+f)));return typeof s?.collaborative!="boolean"?e():s.collaborative}catch{return e()}}}return e()}function Me(t,e=2166136261){for(let o of t)e=Math.imul(e^o,16777619);return e>>>0}function Nt(t,e,o,f,a=[],r={version:o,dirty:o>0},s=Mt,c={}){s.capture(e);let g=[];for(let P of [...a].sort((n,l)=>n-l)){let n=g[g.length-1];n&&P<=n[1]+1?n[1]=Math.max(n[1],P):g.push([P,P]);}let q={session:e.identity.session,epoch:e.epoch,throughSeq:e.throughSeq,revision:o,engineVersion:f.find(([P])=>P===o)[1],versions:f,bases:[...e.bases],refusedSeqs:a,refusedRanges:c.refusedRanges??g,refusedOutcomes:c.refusedOutcomes??[],statuses:[...e.statuses],selection:e.selection,readOnly:e.readOnly,sheetIds:e.sheetIds,nextSheetId:e.nextSheetId,sheetRevision:e.sheetRevision,calculation:e.calculation,formats:[...e.formats],hostVersion:r.version,dirty:r.dirty,...c.historySelections?{historySelections:c.historySelections}:{}},k=new TextEncoder().encode(JSON.stringify(q));if(k.length>4294967295||t.length===0||t.length>4294967295)throw new RangeError("Workbook recovery checkpoint size is out of range");let b=new Uint8Array(le+k.length+t.length),v=new DataView(b.buffer);return b.set(Ge),v.setUint8(8,Ut),v.setUint32(9,k.length,true),v.setUint32(13,t.length,true),b.set(k,le),b.set(t,le+k.length),v.setUint32(17,Me(b.subarray(le),Me(b.subarray(0,17))),true),b}function Ht(t){let e=()=>{throw new TypeError("Invalid workbook recovery checkpoint")};(t.length<le||!Ge.every((n,l)=>t[l]===n))&&e();let o=new DataView(t.buffer,t.byteOffset,t.byteLength),f=o.getUint32(9,true),a=o.getUint32(13,true);(o.getUint8(8)!==Ut||f===0||a===0||le+f+a!==t.length||Me(t.subarray(le),Me(t.subarray(0,17)))!==o.getUint32(17,true))&&e();let r=JSON.parse(new TextDecoder("utf-8",{fatal:true}).decode(t.subarray(le,le+f))),s=t.subarray(le+f),c=n=>typeof n=="number"&&Number.isSafeInteger(n)&&n>=0,g=(n,l,p)=>Array.isArray(n)&&n.length<=256&&n.every(m=>Array.isArray(m)&&m.length===2&&l(m[0])&&p(m[1]))&&new Set(n.map(m=>m[0])).size===n.length,q=n=>typeof n=="string"&&n.length>0,k=n=>{if(n===null)return true;if(!n||typeof n!="object")return false;let l=n,p=(m,E)=>m&&m.range&&Array.isArray(E)&&E.length>0&&E.every(q)&&new Set(E).size===E.length&&E.includes(m.sheetId);return !!(p(l.before,l.beforeSheets)&&p(l.after,l.afterSheets))},b=n=>{if(!n||typeof n!="object")return false;let l=n;return c(l.seq)&&l.seq>0&&(l.status==="refused"||l.status==="cancelled")&&q(l.reason)&&l.committed===false&&(l.affectedSeqs===void 0||Array.isArray(l.affectedSeqs)&&l.affectedSeqs.every(p=>c(p)&&p>0))},v=n=>{if(!n||typeof n!="object")return false;let l=n;return c(l.seq)&&l.seq>0&&["applied","noop","refused","cancelled"].includes(l.status??"")&&typeof l.committed=="boolean"&&(l.affectedSeqs===void 0||Array.isArray(l.affectedSeqs)&&l.affectedSeqs.every(c))&&(l.reason===void 0||q(l.reason))},P=n=>{if(!n||typeof n!="object")return false;let l=n;return c(l.rows)&&l.rows>0&&c(l.columns)&&l.columns>0&&l.rows*l.columns<=1e5&&Array.isArray(l.formats)&&l.formats.length===l.rows*l.columns};return (!r||!q(r.session)||!q(r.engineVersion)||!c(r.epoch)||r.epoch===0||![r.throughSeq,r.revision,r.hostVersion,r.sheetRevision,r.nextSheetId].every(c)||typeof r.readOnly!="boolean"||typeof r.dirty!="boolean"||!Array.isArray(r.sheetIds)||r.sheetIds.length===0||!r.sheetIds.every(q)||new Set(r.sheetIds).size!==r.sheetIds.length||r.sheetIds.some(n=>n.startsWith("command-sheet:")&&(!c(Number(n.slice(14)))||Number(n.slice(14))>=r.nextSheetId))||!g(r.versions,c,q)||!g(r.bases,q,c)||!r.versions.some(([n,l])=>n===r.revision&&l===r.engineVersion)||!r.bases.some(([n])=>n===r.engineVersion)||!Array.isArray(r.refusedSeqs)||r.refusedSeqs.length>256||new Set(r.refusedSeqs).size!==r.refusedSeqs.length||!r.refusedSeqs.every(n=>c(n)&&n>0&&n<=r.throughSeq)||!Array.isArray(r.refusedRanges)||r.refusedRanges.length>4096||!r.refusedRanges.every((n,l,p)=>{if(!Array.isArray(n)||n.length!==2||!c(n[0])||!c(n[1])||n[0]===0||n[0]>n[1]||n[1]>r.throughSeq)return false;let m=p[l-1];return l===0||Array.isArray(m)&&m[1]<n[0]-1})||!r.refusedSeqs.every(n=>r.refusedRanges.some(([l,p])=>n>=l&&n<=p))||!g(r.statuses,c,v)||!r.statuses.every(([n,l])=>n===l.seq&&n<=r.throughSeq&&r.refusedSeqs.includes(n)===(l.status==="refused"||l.status==="cancelled"))||!r.statuses.every(([n,l])=>r.refusedRanges.some(([p,m])=>n>=p&&n<=m)===(l.status==="refused"||l.status==="cancelled"))||!g(r.refusedOutcomes,c,b)||!r.refusedOutcomes.every(([n,l])=>n===l.seq&&r.statuses.some(([p,m])=>p===n&&m.status===l.status&&m.reason===l.reason)&&(l.affectedSeqs??[]).every(p=>r.statuses.some(([m,E])=>m===p&&E.status===l.status&&E.reason===l.reason&&E.committed===false)))||!g(r.formats,q,P)||r.formats.length>64||r.historySelections!==void 0&&(!Array.isArray(r.historySelections)||!r.historySelections.every(k))||!r.selection||!r.sheetIds.includes(r.selection.sheetId)||s.length===0)&&e(),r.calculation!==null&&(!r.calculation||!Number.isFinite(r.calculation.nowSerial)||!c(r.calculation.randSeed)||r.calculation.randSeed>4294967295)&&e(),{...r,engine:s}}function $t(t,e,o,f=Mt){if(t.version()!==e.engineVersion||t.sheetCount()!==e.sheetIds.length||o.session!==e.session)throw new TypeError("Workbook recovery boundary mismatch");let a=Te(o,{epoch:e.epoch,version:e.engineVersion},e.selection,e.sheetIds,e.calculation),r=Y(t,e.selection,e.sheetIds),s=e.selection.activeCell;if(s&&(!Number.isSafeInteger(s.row)||!Number.isSafeInteger(s.col)||s.row<r.start.row||s.row>r.end.row||s.col<r.start.col||s.col>r.end.col))throw new TypeError("Invalid recovery selection");return Object.assign(a,{throughSeq:e.throughSeq,readOnly:e.readOnly,nextSheetId:e.nextSheetId,sheetRevision:e.sheetRevision,bases:new Map(e.bases),formats:new Map(e.formats),historyReset:e.historySelections===void 0,historySelections:structuredClone(e.historySelections??[]).map(c=>c??void 0)}),a.statuses=new Map(e.statuses),f.restore(t),Ce(t,a),a}function Dt(t,e){return t===e||JSON.stringify(t)===JSON.stringify(e)}function Vt(t){let{handle:e,state:o}=t,f=t.now??(()=>performance.now()),a=new Map,r=t.revision??0,s=0,c=new Map(t.versions??[[r,e.version()]]),g$1=new Set(t.refusedSeqs),q=t.refusedRanges?.map(([w,A])=>[w,A])??[],k=new Map(t.refusedOutcomes);if(!t.refusedRanges)for(let w of [...g$1].sort((A,I)=>A-I))Z$1(w);let b$1=new Map,v,P=false,n,l,p=Promise.resolve(),m,E=o.historyReset===true,U$1=new Set,D=[];function Z$1(w){let A=q[q.length-1];if(A&&w<=A[1]+1)A[1]=Math.max(A[1],w);else {if(q.length===4096)throw new g("out-of-memory","Workbook refusal ledger exhausted");q.push([w,w]);}}function ee(w,A){o.statuses.set(w,structuredClone(A)),o.statuses.size>256&&o.statuses.delete(o.statuses.keys().next().value);for(let I of g$1)o.statuses.has(I)||g$1.delete(I);for(let I of a.keys())o.statuses.has(I)||a.delete(I);for(let I of k.keys())o.statuses.has(I)||k.delete(I);}function ue(w){return w.payload.compatibility?w.payload.compatibility:{...o.identity,seq:w.seq,basis:{epoch:w.basis.epoch,version:c.get(w.basis.version)??""},afterSeq:w.afterSeq,kind:w.kind,payload:w.payload.payload,...Z(w.payload.frame)?{frame:w.payload.frame}:{}}}function T(w){if(_(w),w.session!==o.identity.session||w.incarnation!==o.identity.incarnation||w.basis.epoch!==o.epoch)throw new Error("Workbook command identity or epoch mismatch")}let ie=Tt({session:o.identity.session,incarnation:1,epoch:o.epoch,throughSeq:o.throughSeq,refusedSeqs:q.map(([,w])=>w),getVersion:()=>r-s,selectionEquals:Dt,editStateEquals:Dt,apply(w){let A=ue({...w,basis:{...w.basis,version:w.basis.version+s}}),I;if(w.payload.compatibility){if(T(A),A.seq!==w.seq||A.seq!==o.throughSeq+1)throw new Error(`Expected workbook command sequence ${o.throughSeq+1}`);A.afterSeq!==void 0&&!o.statuses.has(A.afterSeq)&&(I="dependency-expired");}let _=e.version(),H;try{H=Rt(e,o,A,I,!1,t.applyPipe);}catch(J){throw m=J instanceof g?J:new g(J instanceof WebAssembly.RuntimeError?"trap":"crash","Workbook command failed",J instanceof Error?J.message:String(J)),m}let M=H.statuses[0];w.kind!=="collabPipe"&&Z(b$1.get(w.seq)?.frame)&&(P=true),E&&(H.selection=structuredClone(o.selection),H.editState=o.editState,E=false),e.version()!==_&&(r+=1,c.set(r,e.version()),c.size>256&&c.delete(c.keys().next().value),t.onCommit?.()),a.set(w.seq,H),ee(w.seq,M),o.throughSeq=w.seq;let z={...H.selection?{selection:H.selection}:{},...H.editState?{editState:H.editState}:{}};return M.status==="refused"?{status:"refused",reason:M.reason,affectedSeqs:M.affectedSeqs,...z}:M.status==="cancelled"?{status:"cancelled",reason:M.reason,...z}:M.status==="applied"?{status:"applied",...M.committed?{}:{committed:false},...z}:{status:"noop",...z}},frame({coversThroughSeq:w}){let A=b$1.get(w),I=n??A?.frame;if(!Z(I)||I.sheet>=e.sheetCount())return;let _=v?.request;if(!n&&!P&&A?.pipe&&v?.version===e.version()&&_&&_.sheet===I.sheet&&_.zoom===I.zoom&&_.dpr===I.dpr&&_.viewport.x===I.viewport.x&&_.viewport.y===I.viewport.y&&_.viewport.width===I.viewport.width&&_.viewport.height===I.viewport.height)return;let H=t.frame(I,w);return v={version:H.version,request:structuredClone(I)},P=false,b({coversThroughSeq:w,revision:H.epoch,payload:H},[H.displayList])},snapshot:async()=>{let w=D.shift();await Promise.all(w?.settled??[]);let A=w?.preserveHistory===true,I=f();try{return Nt(t.captureRecovery?.()??u(e,o.throughSeq,A),o,r,[...c],[...g$1],t.sessionState?.(),void 0,{refusedRanges:q,refusedOutcomes:[...k],...A?{historySelections:o.historySelections}:{}})}finally{w&&(w.encodeMs=Math.max(0,f()-I));}}});async function Q(w,A){if(m)throw m;A.payload.compatibility&&T(A.payload.compatibility);let I=o.throughSeq,_,H=new Promise(M=>{_=M;});U$1.add(H),b$1.set(A.seq,{frame:A.payload.frame??(A.kind==="applyUpdate"||A.kind==="collabPipe"?l:void 0),pipe:A.kind==="collabPipe"}),A.payload.frame&&(l=A.payload.frame),b$1.size>256&&b$1.delete(b$1.keys().next().value);try{let M=A.afterSeq,z=M===void 0?void 0:q.find(([d,h])=>M>=d&&M<=h),J=await ie.handler(w,{...A,basis:{...A.basis,version:A.basis.version-s},...z?{afterSeq:z[1]}:{}}),X=c$1(J)?J.value:J;o.throughSeq=Math.max(o.throughSeq,X.throughSeq);let re=X.outcomes.map(d=>{let h=(d.status==="refused"||d.status==="cancelled")&&A.session===o.identity.session&&A.incarnation===1&&(A.basis.epoch===o.epoch||d.seq===X.throughSeq&&!o.statuses.has(d.seq)&&!a.has(d.seq))&&d.seq>I&&d.seq<=X.throughSeq;h&&(g$1.add(d.seq),Z$1(d.seq),k.set(d.seq,{...d,...d.affectedSeqs?{affectedSeqs:[...d.affectedSeqs]}:{}}));let C=A.session===o.identity.session&&A.incarnation===1&&A.basis.epoch===o.epoch,R=C?a.get(d.seq):void 0,$=C?o.statuses.get(d.seq):void 0,F=R?.statuses[0]??$??{...d,status:d.status==="duplicate"?"noop":d.status,committed:!1,affectedSeqs:d.affectedSeqs??[d.seq]};!R&&h&&ee(d.seq,F);let L=C&&d.status==="duplicate"?k.get(d.seq)??($&&($.status==="refused"||$.status==="cancelled")?{seq:$.seq,status:$.status,committed:!1,...$.reason?{reason:$.reason}:{},...$.status==="refused"&&$.affectedSeqs?{affectedSeqs:$.affectedSeqs}:{}}:void 0):void 0;return {...L??d,...L?.affectedSeqs?{affectedSeqs:[...L.affectedSeqs]}:{},workbook:!R&&$?structuredClone(F):F}}),te=a.get(A.seq),ne=X.version+s,B=c.get(ne)??e.version(),y={throughSeq:X.throughSeq,version:B,statuses:re.map(d=>d.workbook),...te?.selection?{selection:te.selection}:{},...te?.editState?{editState:te.editState}:{}};!te&&re.some(d=>d.status==="refused"||d.status==="cancelled")&&(y.selection=structuredClone(o.selection),y.editState=o.editState);let i={...X,version:ne,engineVersion:B,outcomes:re,compatibility:y};return c$1(J)?b(i,J.transfer):i}catch(M){throw m||(U(M)?(m=new g("crash",M.message),m):M)}finally{U$1.delete(H),_();}}function oe(w){let A=p.then(async()=>{n=w??l,w&&(l=w);try{return await ie.frame()}finally{n=void 0;}});return p=A.then(()=>{},()=>{}),A}return {validateDirectEdits(){if(o.throughSeq!==0||U$1.size!==0)throw new Error("Direct edits require an unused command host");if(m)throw m},synchronizeDirectEdits(w=e.version()){return r+=1,s+=1,c.set(r,w),c.size>256&&c.delete(c.keys().next().value),o.bases.set(w,o.sheetRevision),o.bases.size>256&&o.bases.delete(o.bases.keys().next().value),o.formattingDirty=true,{revision:r,versions:[...c],refusedSeqs:[...g$1]}},handler:Q,policy:w=>({...ie.policy(w),lane:w.kind==="applyUpdate"||w.kind==="collabPipe"?"collab":"input",userInput:w.kind!=="applyUpdate"&&w.kind!=="collabPipe"}),async checkpoint(w,A=false){let I={settled:[...U$1],preserveHistory:A,encodeMs:0};D.push(I);let _=await ie.checkpoint(w),H=c$1(_)?_.value:_,M={...H,version:H.version+s,encodeMs:I.encodeMs};return c$1(_)?b(M,_.transfer):M},checkpointPolicy:ie.checkpointPolicy,frame:()=>oe(),rememberFrame(w){l=w,v={version:e.version(),request:structuredClone(w)};},requestFrame:oe,async command(w){T(w);let A=w.seq<=o.throughSeq;if(A){let M=o.statuses.get(w.seq);if(!M)throw new Error(`Expected workbook command sequence ${o.throughSeq+1}`);let z={throughSeq:o.throughSeq,version:e.version(),statuses:[structuredClone(M)]};return {...z,shared:{session:o.identity.session,incarnation:1,epoch:o.epoch,throughSeq:o.throughSeq,version:r,engineVersion:e.version(),compatibility:z,outcomes:[{seq:M.seq,status:M.status,workbook:structuredClone(M),...M.committed?{}:{committed:false}}]}}}let I=await Q(null,{session:w.session,incarnation:1,seq:w.seq,basis:{epoch:w.basis.epoch,version:r},afterSeq:w.afterSeq,kind:w.kind,payload:{payload:w.payload,compatibility:w,frame:A?void 0:w.frame}}),_=c$1(I)?I.value:I,H={..._.compatibility,shared:_,..._.frame?{frame:_.frame.payload}:{}};return c$1(I)?b(H,I.transfer):H}}}function Bt(t){return t.sheetIds.map((e,o)=>({id:e,index:o,name:t.sheetNames[o]}))}function Lt(){let t=globalThis.crypto.getRandomValues(new Uint8Array(16));return Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")}function jt(t$1,e={}){let o,f$1=false,a$2=0,r$1=false,s=0,c$1=0,g$1=0,q=false,k$1=false,b$2={session:Lt(),incarnation:Lt()},v$1,P$1,n$1=false,l=()=>{},p,m$1,E,U,D=[],Z$1=new TextEncoder;function ee(){f$1||m$1!==void 0||(m$1=setTimeout(()=>{m$1=void 0;let y=p?.drain();y&&B.emit("collaborationPipe",y.batches,y.transfer);},0));}function ue(y){if(!p)throw new aa("unsupported");p.run(y);}function T(){if(f$1)throw new Error("Workbook session is disposed");if(!o)throw new Error("Workbook session is not open");return o}function ie(){f$1=true,m$1!==void 0&&clearTimeout(m$1),m$1=void 0,p?.dispose(),p=void 0;let y=o;o=void 0,l(),l=()=>{},y?.dispose(),E=void 0,U=void 0,D.length=0,v$1=void 0,P$1=void 0;}function Q(y,i){if(!Number.isInteger(i)||i<0||i>=y.sheetCount())throw new RangeError("Sheet index is out of range")}function oe(y,i){let d=T();if(!v$1?.throughSeq)return i(y);let h=d.sheetInfo().sheetIds,C;try{C=ce(y,v$1.sheetIds,h,!0);}catch(R){if(!(R instanceof aa))throw R;return {ok:false,version:d.version(),failure:{code:"missing-target",message:"The command sheet no longer exists"}}}return ce(i(C),h,v$1.sheetIds)}function w$1(y,i){let d=T();Q(d,i);let h=Z$1.encode(m(d,y,i)).buffer;return s+=1,{displayList:h,version:d.version(),epoch:s,sequence:v$1?.throughSeq||c$1,sheet:i,viewport:y,mergedRanges:d.visibleMergedRanges(i,y)}}function A$1(y,i){let d=T();if(!r())throw new F;Q(d,y);let h=d.sheetInfo().activeSheet;try{return y!==h&&d.setActiveSheet(y),I(i(d))}finally{y!==h&&d.setActiveSheet(h);}}function I(y){let i=y.buffer instanceof ArrayBuffer&&y.byteOffset===0&&y.byteLength===y.buffer.byteLength?y.buffer:new Uint8Array(y).buffer;return b(i,[i])}function _(y){let i=T(),d=i.exportStructured(y);if(!v$1?.throughSeq)return d;let h=y?.maxBytes,C=h!==void 0&&Number.isFinite(h)?h:8*1024*1024,R=ce(d,i.sheetInfo().sheetIds,v$1.sheetIds);return R.ok&&Z$1.encode(JSON.stringify(R.content)).byteLength>C?{ok:false,version:R.version,failure:{code:"limit-exceeded",target:null,message:"The exported content exceeds maxBytes"}}:R}function H$1(y){let i=T();Q(i,y);let{contentWidth:d,contentHeight:h,frozenRows:C,frozenCols:R,initialScrollX:$,initialScrollY:F}=i.sheetInfoFor(y),L=i.cellRect(y,Math.max(0,C-1),Math.max(0,R-1));return {sheet:y,version:i.version(),contentWidth:d,contentHeight:h,frozenRows:C,frozenCols:R,initialScrollX:$,initialScrollY:F,frozenWidth:R===0?0:L.x+L.w,frozenHeight:C===0?0:L.y+L.h}}function M$1(y){P$1=Vt({handle:T(),state:v$1,applyPipe:ue,...y?{revision:y.revision,versions:y.versions,refusedSeqs:y.refusedSeqs,refusedRanges:y.refusedRanges,refusedOutcomes:y.refusedOutcomes}:{},sessionState:()=>({version:a$2,dirty:r$1}),frame:(i,d)=>({...w$1(i.viewport,i.sheet),...b$2,sequence:d,coversThroughSeq:d,requestGeneration:i.requestGeneration??i.generation,zoom:i.zoom,dpr:i.dpr}),onCommit(){a$2+=1,r$1=true,B.emit("changed",{version:a$2,dirty:r$1});}});}let z$1={beginPeerSnapshot(y,i,d){let h=T();if(U=void 0,!q||k$1)throw new Error("Worker peer snapshot requires pending retained hydration");try{return w(h).begin(i,d),U={version:h.version(),sequence:c$1,records:i,bytes:d},{version:U.version,sequence:c$1}}catch(C){try{w(h).end();}catch{}throw new Error(C instanceof Error?C.message:String(C))}},pullPeerSnapshot(){let y=T();try{let i=J(y),d=[],h=0;for(;d.length<i.records&&h<i.bytes;){let C=i.pending??w(y).next();if(i.pending=void 0,C===void 0)break;let R=C.buffer;if(!(R instanceof ArrayBuffer)||C.byteOffset!==0||C.byteLength!==R.byteLength)throw new Error("Worker peer snapshot chunk is not transferable");if(d.length>0&&h+C.byteLength>i.bytes){i.pending=C;break}d.push(R),h+=C.byteLength;}return d.length===0?void 0:b(d,d)}catch(i){U=void 0;try{w(y).end();}catch{}throw new Error(i instanceof Error?i.message:String(i))}},endPeerSnapshot(y,i){let d=T();try{i||J(d),w(d).end();}catch(h){try{w(d).end();}catch{}throw new Error(h instanceof Error?h.message:String(h))}finally{U=void 0;}},preview(y,i,d,h){let C=T();if(Q(C,d),!E)throw new Error("Worker preview requires retained hydration");let R=A(E.bytes,{},E.hydration);try{for(let F of D){R.setCalculationContext(F.calculation);try{O(R,F.op);}catch(L){if(!(L instanceof k)||!F.staleProposal)throw L}}for(let F of h){M({sequence:1,calculation:{nowSerial:0,randSeed:0},op:F}),F.calculation&&R.setCalculationContext(F.calculation);let L=O(R,F);if(N(L))throw new Error(`Preview refused: ${JSON.stringify(L)}`)}let $=Z$1.encode(m(R,i,d)).buffer;return b({displayList:$,version:R.version(),epoch:0,sequence:c$1,sheet:d,viewport:i,mergedRanges:R.visibleMergedRanges(d,i)},[$])}finally{R.dispose();}},attachPeer(y,i,d){if(k$1=false,i!==T().version()||d!==c$1)throw new P("version-mismatch","Workbook worker state differs from retained peer hydration");k$1=true,E=void 0,D.length=0;},detachPeer(){k$1=false;},replay(y,i){if(M(i),q&&!k$1)throw new P("mutation-outside-replay","Workbook replay requires an attached edit peer");let d=T();if(i.sequence!==c$1+1){let C=new Error(`Expected workbook replay sequence ${c$1+1}, got ${i.sequence}`);throw C.name="WorkbookReplayOrderError",C}let h=i.op;try{let C=d.version();d.setCalculationContext(i.calculation);let R;try{if(R=O(d,!q&&h.method==="applyEdits"?{method:"applyEdits",args:[{...h.args[0],expectVersion:C}]}:h),i.staleProposal)throw new Error("Expected a stale proposal refresh")}catch(F){if(!(F instanceof k)||!i.staleProposal||JSON.stringify({cells:F.cells,targets:F.targets})!==JSON.stringify(i.staleProposal))throw F}if(N(R))throw new Error(`Engine refused replay: ${JSON.stringify(R)}`);let $=d.version()!==C;return c$1=i.sequence,E&&D.push(structuredClone(i)),$&&(g$1+=1,a$2+=1,r$1=!0,B.emit("changed",{version:a$2,dirty:r$1})),{sequence:c$1,revision:g$1,version:a$2,result:R}}catch(C){let R=`Workbook replay diverged at sequence ${i.sequence} (${h.method})`;throw new g(C instanceof WebAssembly.RuntimeError?"trap":"crash",R,`${R}: ${C instanceof Error?C.message:String(C)}`)}}};function J(y){if(!U)throw new Error("Worker peer snapshot is not active");if(U.version!==y.version()||U.sequence!==c$1)throw new Error("Workbook changed during peer snapshot");return U}let X={async openRecovery(y,i,d={}){if(f$1)throw new Error("Workbook session is disposed");if(o)throw new Error("Workbook session is already open");let h=Ht(i.state);if(i.epoch!==h.epoch||i.version!==h.revision||i.throughSeq!==h.throughSeq)throw new TypeError("Workbook recovery envelope mismatch");if(_t(h.engine))throw new Error("Recovery is unavailable for collaborative workbooks");if(await(e.initWasm??n)(d.wasm),f$1)throw new Error("Workbook session is disposed");let C=v(h.engine,h.throughSeq);try{b$2.session=h.session,v$1=$t(C,h,b$2),a$2=h.hostVersion,r$1=h.dirty,o=C,M$1(h);let R=C.sheetInfo();return {format:"xlsx",stage:"ready",version:a$2,dirty:r$1,sheets:v$1.sheetIds.map(($,F)=>({id:$,index:F,name:R.sheetNames[F]})),activeSheet:R.activeSheet,commandContext:{...b$2,basis:{epoch:v$1.epoch,version:C.version()}},throughSeq:v$1.throughSeq,revision:h.revision,historyReset:v$1.historyReset===!0,pngExport:r(),selection:v$1.selection,editState:v$1.editState}}catch(R){throw o=void 0,v$1=void 0,P$1=void 0,C.dispose(),R}},async open(y$1,i,d$1={}){if(f$1)throw new Error("Workbook session is disposed");if(o)throw new Error("Workbook session is already open");let h=d$1.initialViewport;if(h&&!Z({sheet:h.sheet??0,viewport:{x:0,y:0,width:h.width,height:h.height},zoom:h.zoom,dpr:h.dpr,generation:h.requestGeneration}))throw new TypeError("Invalid workbook initial paint request");let C="retainPeerHydration"in d$1&&d$1.retainPeerHydration===true;q=C;let R=d$1.wasm;if(C&&R instanceof ArrayBuffer&&(R=await WebAssembly.compile(R)),await(e.initWasm??n)(R),R??(R=e.wasmModule?.()),f$1)throw new Error("Workbook session is disposed");let $=d$1.calculation??(C&&!d$1.collaborative?{nowSerial:ba(Date.now()),randSeed:globalThis.crypto.getRandomValues(new Uint32Array(1))[0]>>>0}:void 0),F=t(new Uint8Array(i),{collaborative:d$1.collaborative,clientId:d$1.clientId,calculation:$});n$1=d$1.collaborative===true;try{if(d$1.initialUpdate){if(!n$1||C)throw new Error("Initial updates require a collaborative worker replica");F.applyUpdate(d$1.initialUpdate);}d$1.recoveryVersion!==void 0&&z(F,d$1.recoveryVersion),h?.sheet!==void 0&&(Q(F,h.sheet),F.setActiveSheet(h.sheet));let L;if(C&&(E={bytes:new Uint8Array(i).slice(),hydration:y(F)}),E){let N=JSON.parse(E.hydration);L=N.calculation_context===void 0?void 0:N.calculation_context===null?null:{nowSerial:N.calculation_context.now_serial,randSeed:N.workbook.rand_seed};}C&&R instanceof WebAssembly.Module&&t$1.post({protocol:1,kind:"wasm-module",url:j().href,module:R,hydration:E.hydration,version:F.version(),sequence:c$1});let u=F.sheetInfo(),S=Bt(u);o=F,n$1&&!C&&(l=F.onUpdate((N,be)=>{B.emit("collaborationUpdate",{update:N,origin:be});})),n$1&&!C&&(p=Ct({clientId:F.clientId,read:{encodeStateVector:()=>F.encodeStateVector(),encodeStateAsUpdate:N=>F.encodeStateAsUpdate(N)},onUpdate:N=>F.onUpdate(N),merge(N){for(let be of N){let _e=F.version();try{F.applyUpdate(be);}catch(fe){if(!(fe instanceof Error)||fe instanceof WebAssembly.RuntimeError||F.version()!==_e)throw fe;return {failed:fe}}}return {applied:null}},createProvider:(N,be,_e)=>{let fe=new d(N,be,_e);return Object.assign(fe,{onPeers:Xt=>fe.onAwareness(Xt)})},arrive:b$1,leave:c,transportError:N=>new a$1(N.code,N.message),onOutput:ee})),v$1=Te(b$2,{epoch:1,version:F.version()},{sheetId:u.sheetIds[u.activeSheet],range:{kind:"a1",a1:"A1"}},u.sheetIds,$??null),M$1(),C&&B.emit("peerOpened",{version:F.version(),initialCalculation:L});let O={...v$1};(h||!C&&d$1.includeEditState)&&Ce(F,O);let W={format:"xlsx",stage:"ready",version:a$2,dirty:r$1,...n$1&&!C?{clientId:F.clientId}:{},sheets:S,activeSheet:u.activeSheet,pngExport:r(),commandContext:{...b$2,basis:{epoch:v$1.epoch,version:F.version()}},...!C&&O.editState?{editState:O.editState,selection:v$1.selection}:{}};if(!h)return W;let j$1=H$1(u.activeSheet),G={...w$1({x:j$1.initialScrollX,y:j$1.initialScrollY,width:h.width/h.zoom,height:h.height/h.zoom},u.activeSheet),...b$2,coversThroughSeq:0,requestGeneration:h.requestGeneration,zoom:h.zoom,dpr:h.dpr};return P$1.rememberFrame({sheet:u.activeSheet,viewport:G.viewport,zoom:h.zoom,dpr:h.dpr,generation:h.requestGeneration}),b({...W,initialPaint:{sheetView:j$1,frame:G,editState:O.editState}},[G.displayList])}catch(L){throw o=void 0,v$1=void 0,P$1=void 0,E=void 0,p?.dispose(),p=void 0,l(),l=()=>{},F.dispose(),L}},version:()=>T().version(),collaborationStateVector(){return te(),T().encodeStateVector()},collaborationStateAsUpdate(y,i){return te(),T().encodeStateAsUpdate(i)},listDefinedNames:(y,i)=>T().listDefinedNames(i),readCells:(y,i)=>oe(i,d=>T().readCells(d)),findText:(y,i)=>oe(i,d=>T().findText(d)),validateEdits:(y,i)=>i.expectVersion!==T().version()?T().validateEdits(i):oe(i,d=>T().validateEdits(d)),applyEdits(y,i){if(v$1?.throughSeq)throw new Error("Workbook command sessions require command batches");P$1?.validateDirectEdits();let d=T().applyEdits(i);return d.ok&&d.applied&&(P$1?.synchronizeDirectEdits(d.version),a$2+=1,r$1=true,B.emit("changed",{version:a$2,dirty:r$1})),d},async command(y,i){re(),(i.kind==="applyUpdate"||i.kind==="collabPipe")&&te();let d=T().version(),h=await P$1.command(i);return T().version()!==d&&B.scheduler.bump({version:true,generation:true}),h},edit(y,i){return re(),(i.kind==="applyUpdate"||i.kind==="collabPipe")&&te(),P$1.handler(null,i)},checkpoint(y,i=false){return re(),P$1.checkpoint(null,i)},commandFrame(y,i){re();let d=i?P$1.requestFrame(i):P$1.frame();return a(d.catch(h=>{if(!(h instanceof Error&&!(h instanceof g)&&h.message==="No frame is available at the settled command boundary"))throw h}))},frame(y,i,d={}){let h=w$1(i,d.sheet??T().sheetInfo().activeSheet);return b(h,[h.displayList])},sheetView(y,i){return H$1(i)},cellGeometry(y,i,d,h){let C=T();return Q(C,i),{sheet:i,version:C.version(),rect:C.cellRect(i,d,h),scrollPosition:C.cellPosition(i,d,h)}},selectionData(y,i,d,h,C){let R=T();return Q(R,i),R.selectionData(i,d,h,C)},cellInputs(y,i,d){let h=T();return Q(h,i),{sheet:i,version:h.version(),cells:h.rangeCells(i,d)}},captureFormat(y,i,d){let h=T();return Q(h,i),h.captureFormat(i,d)},sheets:()=>Bt({...T().sheetInfo(),...v$1?.throughSeq?{sheetIds:v$1.sheetIds}:{}}),calculationStatus:()=>T().calculationStatus(),renderPng(y,i,d={}){return A$1(d.sheet??T().sheetInfo().activeSheet,h=>h.renderPng(i))},renderRangePng(y,i,d={}){return A$1(d.sheet??T().sheetInfo().activeSheet,h=>h.renderRangePng(i))},exportStructured:(y,i)=>_(i),exportMarkdown(y,i,d){let h=T(),C=h.exportMarkdown(i,d);if(!v$1?.throughSeq)return C;if(C.ok){let R=_(i);if(!R.ok)return R}return ce(C,h.sheetInfo().sheetIds,v$1.sheetIds)},printDisplayList(y,i,d,h,C){let R=T();return Q(R,i),I(Z$1.encode(JSON.stringify(R.printDisplayList(i,d,h,C))))},save(){let y=T().save(),i=y.buffer instanceof ArrayBuffer&&y.byteOffset===0&&y.byteLength===y.buffer.byteLength?y.buffer:new Uint8Array(y).buffer;return b(i,[i])},dispose(){T(),ie();}};function re(){if(T(),!P$1)throw new Error("Workbook commands are not open");if(q||k$1||c$1>0)throw new Error("Workbook commands require a session without an edit peer")}function te(){if(re(),!n$1)throw new Error("Workbook session is not collaborative")}for(let y of Object.keys(X)){let i=H[y],d=X[y];Object.defineProperty(X,y,{enumerable:true,value:(...h)=>{let C=typeof i=="function"?i(...h.slice(1)):i;if(q&&C.mutates)throw new P("mutation-outside-replay",`Cannot call ${y} outside workbook edit-peer replay in retained hydration mode`);return d(...h)}});}let ne={...t$1,post(y,i){let d=f(y)&&y.kind==="reply"?p?.drain():void 0,h=d?{collabPipe:d.batches}:void 0;t$1.post(h?{...y,...h}:y,d?[...i??[],...d.transfer]:i);}},B=ca(ne,{handlers:{...X,...z$1},policies:{...H,...K,edit:y=>P$1?.policy(y)??{lane:"input",reorderable:false},checkpoint:()=>P$1?.checkpointPolicy()??{lane:"input",reorderable:false}},context:null,onDispose:ie,trapFailure:lo});return B}function lo(t){let e=o();return e?new g("out-of-memory","The workbook is too large: the spreadsheet engine ran out of memory",`An allocation of ${e.bytes} bytes failed with ${Math.round(e.memoryBytes/2**20)} MiB of engine memory; ${t.message}${t.diagnostics?`: ${t.diagnostics}`:""}`):void 0}var Ue=i(self),Ke,zt=false;Ue.listen(t=>{e(t)&&t.kind==="call"&&t.method==="open"&&(zt=t.args[1]?.retainPeerHydration===true);});var co={...Ue,post:(...t)=>{zt&&f(t[0])&&t[0].kind==="wasm-module"||Ue.post(...t);}},uo=jt(Ue,{initWasm:St(co,j(),n,async t=>(Ke=await je(t),Ke)),wasmModule:()=>Ke});Object.assign(globalThis,{__betterofficeEngineProgress:()=>uo.progress()});
1
+ var zc=Object.defineProperty;var U=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(r){throw n=[r],r}};var Mt=(e,t)=>{for(var n in t)zc(e,n,{get:t[n],enumerable:!0})};var fs,Z,je=U(()=>{"use strict";fs="SessionSuperseded",Z=class extends Error{constructor(n,r,o){super(r);this.code=n;this.diagnostics=o;this.name="SessionFailure"}code;diagnostics}});function vr(e){us=e}function xr(e){try{return typeof e=="string"&&new URL(e).href===e}catch{return!1}}function ps(e,t){let n=Jc(o=>e.postMessage(o)),r=o=>{n.receive(o.data)&&o.stopImmediatePropagation()};return e.addEventListener("message",r),t(n.source),()=>{e.removeEventListener("message",r),n.dispose()}}function Jc(e,t=15e3){let n=++Xc,r=0,o=!1,s,i,l=new Map,a=new Map;function f(){if(i!==void 0)return;let p=setTimeout(()=>{if(i===p){s=new Set(a.keys()),l.clear();for(let y of a.values())y.finish()}},t);i=p}return{source:(p,{fresh:y=!1}={})=>{if(o)return Promise.reject(new Z("disposed","Font pack channel is closed"));if(s)return Promise.resolve(void 0);let k=y?void 0:l.get(p);if(!k){let u=`font-pack:${n}:${++r}`;if(k=new Promise((h,C)=>{let v=(P,L)=>{a.delete(u),a.size===0&&(clearTimeout(i),i=void 0),L?C(L):h(P)};a.set(u,{finish:v}),f();try{e({protocol:1,kind:"font-pack-request",id:u,pack:p})}catch(P){v(void 0,new Z("message",String(P)))}}),!y){l.set(p,k);let h=()=>{l.get(p)===k&&l.delete(p)};k.then(h,h)}}return k},receive(p){let y=p;if(y?.protocol!==1||y.kind!=="font-pack-reply")return!1;if(typeof y.id!="string")return!0;s?.has(y.id)&&(s=void 0);let k=a.get(y.id);if(k)if(!(y.urls===void 0||y.urls!==null&&typeof y.urls=="object"&&!Array.isArray(y.urls)&&Object.values(y.urls).every(xr))||y.error!==void 0)k.finish(void 0,new Z("message",y.error??"Invalid font asset URLs"));else{let h=y.cdn,C=h&&Number.isInteger(h.timeoutMs)&&h.timeoutMs>0&&h.timeoutMs<=4294967295&&(h.baseUrl===!1||xr(h.baseUrl)&&/^https?:\/\//.test(h.baseUrl)),v=xr(y.pageUrl)?y.pageUrl:void 0;k.finish({urls:y.urls,...C?{cdn:h}:{},...v?{pageUrl:v}:{}})}return!0},dispose(){o=!0,s=void 0;for(let p of a.values())p.finish(void 0,new Z("disposed","Font pack channel is closed"));l.clear()}}}var us,Ue,bn,Xc,tt=U(()=>{"use strict";je();us=async()=>{};Ue=(...e)=>us(...e),bn=class extends TypeError{constructor(t){super(`Failed to resolve module specifier '${t}'`)}};Xc=0});function ht(){return Ae[Hc]??=new Map}function ys(e){return e.process?.versions?.node!==void 0||e.Deno!==void 0||e.Bun!==void 0}function gs(e){return e.window?.document!=null&&!ys(e)}function ws(e){if(e&&!(e.implicit&&ys(Ae[bs]??Ae)))return{...e}}function Nt(){let e=Ae[yn];if(e)return ws(e);if(gs(Ae[bs]??Ae))return{baseUrl:_r,timeoutMs:gn,implicit:!0}}function wn(e,t){e===void 0?delete Ae[yn]:Ae[yn]={...e},t?Ae[Cr]=t:delete Ae[Cr]}function Pr(e){return ws(Ae[Cr]||e===void 0?Ae[yn]:e.cdn)}function Rr(e=Nt()??null){return e?JSON.stringify([e.baseUrl,e.timeoutMs,e.implicit]):""}var _r,gn,yn,Cr,Hc,bs,Ae,It=U(()=>{"use strict";tt();_r="https://cdn.jsdelivr.net/npm/",gn=1e4,yn=Symbol.for("betteroffice.fonts.cdn"),Cr=Symbol.for("betteroffice.fonts.cdn.configured-here"),Hc=Symbol.for("betteroffice.fonts.cdn.cooldown"),bs=Symbol.for("betteroffice.fonts.cdn.test-globals"),Ae=globalThis});var ks=U(()=>{"use strict";It();tt()});function jc(e,t){let n=new Set,r=!1;function o(s,i){if(r)return()=>{};e.addEventListener(s,i);let l=()=>{e.removeEventListener(s,i),n.delete(l)};return n.add(l),e.start?.(),l}return{post(s,i=[]){if(r)throw new Z("disposed","Session transport is closed");e.postMessage(s,i)},listen(s){return o("message",i=>s(i.data))},onError(s){let i=o("error",a=>s(new Z("crash",a.message||"Session worker crashed"))),l=o("messageerror",()=>s(new Z("message","Session transport received an unreadable message")));return()=>{i(),l()}},close(){if(!r){r=!0;for(let s of[...n])s();t()}}}}function Ss(e){return jc(e,()=>e.close?.())}var xs=U(()=>{"use strict";ks();je()});function Bt(e){return{[Cs]:!0,promise:e}}function _s(e){return Ut(e)&&e[Cs]===!0}function he(e,t){return{[vs]:!0,value:e,transfer:t}}function ve(e){return Ut(e)&&e[vs]===!0}function pe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ut(e){return e!==null&&typeof e=="object"}function Fr(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function bt(e){if(!Ut(e)||e.protocol!==1)return!1;if(e.kind==="wasm-compile"){if(e.pending!==void 0&&e.pending!==!0||e.bytes!==void 0&&!(e.bytes instanceof ArrayBuffer))return!1;if(e.stream===void 0)return!0;try{return Object.prototype.toString.call(e.stream)==="[object ReadableStream]"}catch{return!1}}return e.kind==="dispose"||e.kind==="call"&&Fr(e.id)&&typeof e.method=="string"&&Array.isArray(e.args)}function kn(e){if(!Ut(e)||e.protocol!==1)return!1;switch(e.kind){case"wasm-accept":return!0;case"wasm-module":try{return typeof e.url=="string"&&(e.hydration===void 0||typeof e.hydration=="string")&&Object.prototype.toString.call(e.module)==="[object WebAssembly.Module]"}catch{return!1}case"reply":return Fr(e.id)&&(e.ok===!0&&pe(e,"value")||e.ok===!1&&Ut(e.error)&&typeof e.error.name=="string"&&typeof e.error.message=="string");case"event":return typeof e.name=="string"&&pe(e,"payload");case"progress":return Fr(e.id);case"failure":return["crash","trap","out-of-memory","message","silence","disposed"].includes(e.code)&&typeof e.message=="string"&&(e.diagnostics===void 0||typeof e.diagnostics=="string");default:return!1}}var vs,Cs,Be=U(()=>{"use strict";vs=Symbol("session-transfer"),Cs=Symbol("session-deferred")});function Ps(e){let t=globalThis.process;if(typeof t?.getBuiltinModule=="function")try{return t.getBuiltinModule(e)}catch{return}}function Dt(e,t=!1){if(e.protocol!=="file:")return;let n=Ps("node:fs"),r=Ps("node:url");if(!(!n||!r))try{return n.readFileSync(r.fileURLToPath(e.href))}catch(o){if(t)throw o;return}}function Rs(e){return Dt(e)??e}function Fs(e,t){let n=t instanceof Error?t.message:String(t);return Object.assign(new Error(`Could not load the packaged WASM asset ${e.href} (${n}); pass its bytes or a compiled WebAssembly.Module to initWasm(input)`),{cause:t})}var Sn=U(()=>{"use strict"});async function Ar(e){let t=await fetch(e);if(typeof WebAssembly.compileStreaming=="function")try{return await WebAssembly.compileStreaming(t.clone())}catch(n){if(!t.ok||!["basic","cors","default"].includes(t.type)||t.headers.get("Content-Type")==="application/wasm")throw n}return WebAssembly.compile(await t.arrayBuffer())}async function $c(e){let t=Dt(e);return t?WebAssembly.compile(t):Ar(e)}function Er(e){return typeof Worker=="function"?Ar(e):$c(e)}async function As(e){let t=new Response(e,{headers:{"Content-Type":"application/wasm"}});return typeof WebAssembly.compileStreaming=="function"?WebAssembly.compileStreaming(t):WebAssembly.compile(await t.arrayBuffer())}function Tr(e,t,n,r=Ar){let o,s,i=!1;function l(){return o||(o=r(t),o.catch(()=>{})),o}return e.listen(a=>{if(!bt(a)||a.kind!=="wasm-compile")return;if(a.pending){if(!o){o=new Promise(d=>{s=d}),o.catch(()=>{});try{e.post({protocol:1,kind:"wasm-accept"})}catch{}}return}let f=s;if(s=void 0,f){let d=a.stream?As(a.stream):a.bytes?WebAssembly.compile(a.bytes):r(t);d.catch(()=>{}),f(d)}else a.stream||a.bytes?o?a.stream?.cancel().catch(()=>{}):(o=a.stream?As(a.stream):WebAssembly.compile(a.bytes),o.catch(()=>{})):l()}),async a=>{if(a!==void 0)return n(a);let f=l(),d;try{d=await f}catch(p){throw o===f&&(o=void 0),p}if(await n(d),!i){i=!0;let p={protocol:1,kind:"wasm-module",url:t.href,module:d};try{e.post(p)}catch{}}}}var Es=U(()=>{"use strict";Be();Sn()});function nt(e=!0){return e?new URL("./generated/xlsx_wasm_bg.wasm",import.meta.url):new URL("./generated/xlsx_wasm_lean_bg.wasm",import.meta.url)}var xn=U(()=>{"use strict"});var Ls,Ts=U(()=>{Ls="0.5.0"});var Ws,Os=U(()=>{Ws="0.5.0"});var Ns,Ms=U(()=>{Ns="0.5.0"});function Is(e){return{check:Zc,load:(t,n,r,o)=>ed(t,n,e,r,o)}}function Yc(e,t){return t||e instanceof vn&&(e.status===404||e.status===410)?"url":"base"}function Cn(e){return e.origin+e.pathname.split("/assets/",1)[0]}function qt(e,t){let n=Date.now();if(e.unavailable&&n<e.unavailable.until)return e.unavailable.error;let r=e.invalid.get(t);if(r&&n<r.until)return r.error;r&&e.invalid.delete(t)}function Zc(e){let t=ht().get(Cn(e)),n=t&&qt(t,e.href);if(n)throw n}function Us(e){let t=ht().get(Cn(e));if(!t)return;let n=qt(t,e.href);if(n)throw n;let r=new URL("./",e).href;for(let o of t.invalid.keys()){if(!o.startsWith(r))continue;let s=qt(t,o);if(s)throw s}}function Bs(e,t){let n=ht().get(Cn(e));if(!n)return;let r=Math.max(n.unavailable?.until??0,n.invalid.get(e.href)?.until??0);if(t){let o=new URL("./",t).href;for(let[s,i]of n.invalid)s.startsWith(o)&&(r=Math.max(r,i.until))}return r>Date.now()?r:void 0}async function ed(e,t,n,r,o){o?.();let s=ht(),i=Cn(t),l=s.get(i);l||(l={transfer:Promise.resolve(),invalid:new Map,warnedUntil:0},s.set(i,l));let a=l,f=qt(a,t.href);if(f)throw f;let d=(h,C=!1)=>{let v=Date.now(),P=v+Qc,L=new Lr(n,h);return s.get(i)!==a||(Yc(h,C)==="base"?a.unavailable={error:L,until:P}:a.invalid.set(t.href,{error:L,until:P}),a.warnedUntil<=v&&(a.warnedUntil=P,console.warn(L.diagnostic.detail))),L},p=a.transfer.then(async()=>{let h=qt(a,t.href);if(h)throw h;o?.();try{return{bytes:await td(e,t),unavailable:a.unavailable}}catch(C){throw d(C)}});a.transfer=p.then(()=>{},()=>{});let{bytes:y,unavailable:k}=await p,u=await r(y,async h=>{try{return await h()}catch(C){throw d(C,!0)}});if(a.unavailable===k){a.unavailable=void 0;let h=Date.now();[...a.invalid.values()].every(({until:C})=>C<=h)&&(a.warnedUntil=0)}return u}async function td(e,t){let n=new AbortController,{signal:r}=n,o,s,i,l=new Promise((d,p)=>{i=p}),a=()=>{clearTimeout(o),o=setTimeout(()=>{let d=new DOMException(`No font data received for ${gn} ms`,"TimeoutError");n.abort(d),i(d),s&&s.cancel(d).catch(()=>{})},gn)},f=async()=>{let d=await fetch(t,{signal:r,credentials:"omit",referrerPolicy:"no-referrer"});try{if(r.aborted)throw r.reason;if(d.type==="opaque"||d.type==="error")throw new Error(`No readable response for bundled font ${e}`);if(!d.ok)throw new vn(e,d.status)}catch(v){throw d.body?.cancel().catch(()=>{}),v}a();let p=d.body;if(typeof p?.getReader!="function")return d.arrayBuffer();let y=p.getReader();s=y;let k=[],u=0;try{for(;;){let{done:v,value:P}=await y.read();if(r.aborted)throw r.reason;if(v)break;P.byteLength!==0&&(k.push(P),u+=P.byteLength,a())}}finally{y.releaseLock(),s=void 0}let h=new Uint8Array(u),C=0;for(let v of k)h.set(v,C),C+=v.byteLength;return h.buffer};a();try{return await Promise.race([f(),l])}finally{clearTimeout(o)}}function Ds(e,t,n){if(n!==void 0)return new URL(`${e.pack}/${e.version}/${t}`,n);let r=nd[e.pack];if(r===void 0)throw new Error(`Unknown font pack: ${e.pack}`);return new URL(`${_r}@betteroffice/fonts-${e.pack}@${r}/assets/${t}`)}function qs(e){let t=e.timeoutMs??3e4;if(!Number.isInteger(t)||t<=0||t>4294967295)throw new RangeError("Font CDN timeoutMs must be a positive 32-bit integer");let n=!1;if(e.baseUrl!==!1){let r=String(e.baseUrl),o=new URL(r.endsWith("/")?r:`${r}/`,typeof location>"u"?void 0:location.href);if(o.protocol!=="https:"&&o.protocol!=="http:")throw new TypeError("Font CDN baseUrl must use HTTP or HTTPS");n=o.href}ht().clear(),wn({baseUrl:n,timeoutMs:t},!0)}function zs(){return Nt()??{baseUrl:!1,timeoutMs:3e4}}var Lr,Qc,vn,nd,_n=U(()=>{"use strict";Ts();Os();Ms();It();It();Lr=class extends Error{constructor(t,n){let r=n instanceof Error?n.message:String(n),o=`Cannot load @betteroffice/fonts-${t} from cdn.jsdelivr.net: ${r}. To opt out, install @betteroffice/fonts-${t} or call configureFontCdn({ baseUrl: false }).`;super(o),this.name="ImplicitFontCdnError",this.diagnostic={pack:t,reason:"cdn-unavailable",detail:o}}},Qc=6e4,vn=class extends Error{constructor(n,r){super(`Failed to fetch bundled font ${n}: HTTP ${r}`);this.status=r}};nd={latin:Ls,intl:Ws,cjk:Ns}});var yt,Pn=U(()=>{yt={format:1,pack:"intl",version:"0.4.2",faces:[{file:"NotoSansArmenian-Bold.ttf.zst",source:"NotoSansArmenian-Bold.ttf",family:"NotoSansArmenian",codec:"zstd",encodedLength:8822,byteLength:30784,sha256:"58e4529f7f44d1fcfbd5d81d446b656f1230267ebfa96f8006956f18fbe4bbe2",dict:"NotoSansArmenian-Regular.ttf.zst"},{file:"NotoSansArmenian-Regular.ttf.zst",source:"NotoSansArmenian-Regular.ttf",family:"NotoSansArmenian",codec:"zstd",encodedLength:15648,byteLength:30752,sha256:"720df88c332417a235b4d6209d14ec2e2bf4bfe2a954b7453d869ea593bfce1e",dict:null},{file:"NotoSansBengali-Bold.ttf.zst",source:"NotoSansBengali-Bold.ttf",family:"NotoSansBengali",codec:"zstd",encodedLength:44599,byteLength:144828,sha256:"923c6a4c2eb618a57ed83f4bca855b4f5287b87906a4d9df40a2ffa8ebd8c2e8",dict:"NotoSansBengali-Regular.ttf.zst"},{file:"NotoSansBengali-Regular.ttf.zst",source:"NotoSansBengali-Regular.ttf",family:"NotoSansBengali",codec:"zstd",encodedLength:66348,byteLength:143072,sha256:"b55c62ee531e3214da6c0701daecea89a52ba42db7d8206b92e6b51f397a3193",dict:null},{file:"NotoSansCherokee-Bold.ttf.zst",source:"NotoSansCherokee-Bold.ttf",family:"NotoSansCherokee",codec:"zstd",encodedLength:41795,byteLength:108548,sha256:"5d60c5479b6e9af2f9fa6ede6ebeba471dd8c391333bcca91c2f9d0903279c6c",dict:"NotoSansCherokee-Regular.ttf.zst"},{file:"NotoSansCherokee-Regular.ttf.zst",source:"NotoSansCherokee-Regular.ttf",family:"NotoSansCherokee",codec:"zstd",encodedLength:44913,byteLength:94732,sha256:"c052352137ae8d283840a0e2991a675d47859d8fdbae5726d373d4f0d97a8c87",dict:null},{file:"NotoSansDevanagari-Bold.ttf.zst",source:"NotoSansDevanagari-Bold.ttf",family:"NotoSansDevanagari",codec:"zstd",encodedLength:56006,byteLength:250176,sha256:"6a09c8d797cfc803d32cdc731e809424d74cbaff59f503de34ade421a08e5bc2",dict:"NotoSansDevanagari-Regular.ttf.zst"},{file:"NotoSansDevanagari-Regular.ttf.zst",source:"NotoSansDevanagari-Regular.ttf",family:"NotoSansDevanagari",codec:"zstd",encodedLength:89070,byteLength:243520,sha256:"4e3c66638958c3e2ab5d37f47a8deb89fffeb7be9985c665a519bbc7ba762313",dict:null},{file:"NotoSansEthiopic-Bold.ttf.zst",source:"NotoSansEthiopic-Bold.ttf",family:"NotoSansEthiopic",codec:"zstd",encodedLength:61195,byteLength:375172,sha256:"b45f16db963a94ccb6590b65d3b0e48f55cde011f7c0d4f3c00531e6b8500d6f",dict:"NotoSansEthiopic-Regular.ttf.zst"},{file:"NotoSansEthiopic-Regular.ttf.zst",source:"NotoSansEthiopic-Regular.ttf",family:"NotoSansEthiopic",codec:"zstd",encodedLength:119123,byteLength:376804,sha256:"f6f7fc379db9438959a2b0527e7a2cf36ea9c84626d56ec444fff37fc24c3c10",dict:null},{file:"NotoSansGeorgian-Bold.ttf.zst",source:"NotoSansGeorgian-Bold.ttf",family:"NotoSansGeorgian",codec:"zstd",encodedLength:18204,byteLength:54748,sha256:"a7f6bc365b7c33372e9ff0b0422f35dad52df501a8fcd4e8766cefa430508693",dict:"NotoSansGeorgian-Regular.ttf.zst"},{file:"NotoSansGeorgian-Regular.ttf.zst",source:"NotoSansGeorgian-Regular.ttf",family:"NotoSansGeorgian",codec:"zstd",encodedLength:27389,byteLength:52888,sha256:"d3e33254b09e7bb2c5cf0f17e554b80462056c5a107097f258d495168c3a9346",dict:null},{file:"NotoSansGujarati-Bold.ttf.zst",source:"NotoSansGujarati-Bold.ttf",family:"NotoSansGujarati",codec:"zstd",encodedLength:44632,byteLength:201032,sha256:"7c1da9cad53f83804a330bad413b015987f4b6520da54263b0e39b7b8736525b",dict:"NotoSansGujarati-Regular.ttf.zst"},{file:"NotoSansGujarati-Regular.ttf.zst",source:"NotoSansGujarati-Regular.ttf",family:"NotoSansGujarati",codec:"zstd",encodedLength:69158,byteLength:200704,sha256:"9b5a7aaeeb649a2e75a49d8b006a1f87db1b61c0df3b001609f4e0725d88dbf6",dict:null},{file:"NotoSansGurmukhi-Bold.ttf.zst",source:"NotoSansGurmukhi-Bold.ttf",family:"NotoSansGurmukhi",codec:"zstd",encodedLength:15855,byteLength:55088,sha256:"4f1bb4b1a05a0ebe1520678132a9448fce8f1741552c5292d7df7a7786d2c956",dict:"NotoSansGurmukhi-Regular.ttf.zst"},{file:"NotoSansGurmukhi-Regular.ttf.zst",source:"NotoSansGurmukhi-Regular.ttf",family:"NotoSansGurmukhi",codec:"zstd",encodedLength:27099,byteLength:55172,sha256:"658d0207da305a1411c539a8b0bbeda64d4146e54fb4827facddb890b6b90d74",dict:null},{file:"NotoSansKannada-Bold.ttf.zst",source:"NotoSansKannada-Bold.ttf",family:"NotoSansKannada",codec:"zstd",encodedLength:42864,byteLength:187208,sha256:"3db1507b3f856185fc7c00dc0addfd4797a8ea6955b86d1d21fa659cc9d5e849",dict:"NotoSansKannada-Regular.ttf.zst"},{file:"NotoSansKannada-Regular.ttf.zst",source:"NotoSansKannada-Regular.ttf",family:"NotoSansKannada",codec:"zstd",encodedLength:64931,byteLength:182416,sha256:"9ad74dc64838c6855b96f671fc08e425a58921b9d0c71712ea79c328a27e6e38",dict:null},{file:"NotoSansKhmer-Bold.ttf.zst",source:"NotoSansKhmer-Bold.ttf",family:"NotoSansKhmer",codec:"zstd",encodedLength:27171,byteLength:113740,sha256:"17e5bb518c0ea3d998d42bf920d0771a79dc6f3c12c5d9f3c122c7e6c8ce3076",dict:"NotoSansKhmer-Regular.ttf.zst"},{file:"NotoSansKhmer-Regular.ttf.zst",source:"NotoSansKhmer-Regular.ttf",family:"NotoSansKhmer",codec:"zstd",encodedLength:42214,byteLength:114576,sha256:"e66675f2082788f0511a714bef5a1748928294b38c8e286a96ea73a864b5e605",dict:null},{file:"NotoSansLao-Bold.ttf.zst",source:"NotoSansLao-Bold.ttf",family:"NotoSansLao",codec:"zstd",encodedLength:10216,byteLength:37252,sha256:"18e3bf1443320fa807f9b85a9971d2bc3efe28b41bb96f75fde2096acb316709",dict:"NotoSansLao-Regular.ttf.zst"},{file:"NotoSansLao-Regular.ttf.zst",source:"NotoSansLao-Regular.ttf",family:"NotoSansLao",codec:"zstd",encodedLength:17035,byteLength:35884,sha256:"0a86e5e1ccfe34ca78c43fac6829dc751b42bcc469272a9a55325aae587bfbe7",dict:null},{file:"NotoSansLaoLooped-Bold.ttf.zst",source:"NotoSansLaoLooped-Bold.ttf",family:"NotoSansLaoLooped",codec:"zstd",encodedLength:17272,byteLength:56240,sha256:"b686a828bb3eac6cf426c4673666d79447142fb7841d870ed37c68a7608965d6",dict:"NotoSansLaoLooped-Regular.ttf.zst"},{file:"NotoSansLaoLooped-Regular.ttf.zst",source:"NotoSansLaoLooped-Regular.ttf",family:"NotoSansLaoLooped",codec:"zstd",encodedLength:26737,byteLength:56300,sha256:"fb41283aee26c91b93f3df6c11229054bf64407c494c4ee874b536b1330a06c8",dict:null},{file:"NotoSansMalayalam-Bold.ttf.zst",source:"NotoSansMalayalam-Bold.ttf",family:"NotoSansMalayalam",codec:"zstd",encodedLength:34189,byteLength:118480,sha256:"d5c52d4fdf019feb21cdb748573308fa5fdd94a81d5bc71c603c076207039590",dict:"NotoSansMalayalam-Regular.ttf.zst"},{file:"NotoSansMalayalam-Regular.ttf.zst",source:"NotoSansMalayalam-Regular.ttf",family:"NotoSansMalayalam",codec:"zstd",encodedLength:50562,byteLength:112936,sha256:"c08de7fa8d032a5d6a4d120fb82c78cec60b362a4e73fa26360d89759ff2a7f9",dict:null},{file:"NotoSansMongolian-Regular.ttf.zst",source:"NotoSansMongolian-Regular.ttf",family:"NotoSansMongolian",codec:"zstd",encodedLength:99547,byteLength:360756,sha256:"10f9066fe5cedcaa41c17d471bcadc7fb22880ce81ff2c06578671768ff44fbb",dict:null},{file:"NotoSansMyanmar-Bold.ttf.zst",source:"NotoSansMyanmar-Bold.ttf",family:"NotoSansMyanmar",codec:"zstd",encodedLength:52073,byteLength:208760,sha256:"99a8c6768416747653232ded39292e789ca579f4272adfb2886f6aa219d20302",dict:"NotoSansMyanmar-Regular.ttf.zst"},{file:"NotoSansMyanmar-Regular.ttf.zst",source:"NotoSansMyanmar-Regular.ttf",family:"NotoSansMyanmar",codec:"zstd",encodedLength:81274,byteLength:195088,sha256:"fafce4db400bc0b214907ccdbfb0ad2f18a57bfefd08c8a571830b84088cf2fc",dict:null},{file:"NotoSansOriya-Bold.ttf.zst",source:"NotoSansOriya-Bold.ttf",family:"NotoSansOriya",codec:"zstd",encodedLength:36105,byteLength:130104,sha256:"1c575e8aba40d6baf200e8abac534e9517f431d38cc8131715643037eec149da",dict:"NotoSansOriya-Regular.ttf.zst"},{file:"NotoSansOriya-Regular.ttf.zst",source:"NotoSansOriya-Regular.ttf",family:"NotoSansOriya",codec:"zstd",encodedLength:49661,byteLength:131216,sha256:"a16645d056017927406546aa78e4ce15e782fd8783467267b75450453d007415",dict:null},{file:"NotoSansSinhala-Bold.ttf.zst",source:"NotoSansSinhala-Bold.ttf",family:"NotoSansSinhala",codec:"zstd",encodedLength:51450,byteLength:192976,sha256:"e1f8867effb18940b02173a120641e526e5aaa8efc176870e62b2d49b1e6fd3f",dict:"NotoSansSinhala-Regular.ttf.zst"},{file:"NotoSansSinhala-Regular.ttf.zst",source:"NotoSansSinhala-Regular.ttf",family:"NotoSansSinhala",codec:"zstd",encodedLength:61235,byteLength:154912,sha256:"9e32612d47004552f3125e78648a9e2e7899a216ccd3cefbb93a9b5f4c809feb",dict:null},{file:"NotoSansSyriac-Regular.ttf.zst",source:"NotoSansSyriac-Regular.ttf",family:"NotoSansSyriac",codec:"zstd",encodedLength:29056,byteLength:73796,sha256:"4440929bf1a47bb50179e8d8495641d208c63d607355e451f29ea2d3e5343290",dict:null},{file:"NotoSansTamil-Bold.ttf.zst",source:"NotoSansTamil-Bold.ttf",family:"NotoSansTamil",codec:"zstd",encodedLength:22566,byteLength:77176,sha256:"683682d585698b8b44da066d4903762d8aaa471bdffb919ac869753689ba3950",dict:"NotoSansTamil-Regular.ttf.zst"},{file:"NotoSansTamil-Regular.ttf.zst",source:"NotoSansTamil-Regular.ttf",family:"NotoSansTamil",codec:"zstd",encodedLength:34612,byteLength:73992,sha256:"3c0a186feb3c63c7f6d63e1511dcdc144e745ae09b98e217c83f3e317974f6f9",dict:null},{file:"NotoSansTelugu-Bold.ttf.zst",source:"NotoSansTelugu-Bold.ttf",family:"NotoSansTelugu",codec:"zstd",encodedLength:63586,byteLength:243412,sha256:"ec98c4f82abfe52ebe00be298d39c469deb86cf027929987759ba1eab361fbb4",dict:"NotoSansTelugu-Regular.ttf.zst"},{file:"NotoSansTelugu-Regular.ttf.zst",source:"NotoSansTelugu-Regular.ttf",family:"NotoSansTelugu",codec:"zstd",encodedLength:80967,byteLength:235176,sha256:"b274780b69d1d23fe84b55e809a152cb2ac5306d33864b1f87622f6971871aae",dict:null},{file:"NotoSansThaana-Bold.ttf.zst",source:"NotoSansThaana-Bold.ttf",family:"NotoSansThaana",codec:"zstd",encodedLength:8975,byteLength:27e3,sha256:"476597290f449013cb07477b1089219db333c6af9ec0e436a74139ea9b2c8536",dict:"NotoSansThaana-Regular.ttf.zst"},{file:"NotoSansThaana-Regular.ttf.zst",source:"NotoSansThaana-Regular.ttf",family:"NotoSansThaana",codec:"zstd",encodedLength:14841,byteLength:27308,sha256:"7543935bdcef770c9d3dd54222651b29040e5ec82f3bc58542392b2c7a9cbd3c",dict:null},{file:"NotoSansThai-Bold.ttf.zst",source:"NotoSansThai-Bold.ttf",family:"NotoSansThai",codec:"zstd",encodedLength:10184,byteLength:37824,sha256:"2ac6c6e8a478e23b15f76e4894af1fa2210f8f350e4e6e54aad530bec03efbfb",dict:"NotoSansThai-Regular.ttf.zst"},{file:"NotoSansThai-Regular.ttf.zst",source:"NotoSansThai-Regular.ttf",family:"NotoSansThai",codec:"zstd",encodedLength:18343,byteLength:37780,sha256:"61cf814eec46b294d6ea4401ac295d0cecd5207bd2331dcc5a15e7301d30ee44",dict:null},{file:"NotoSansTifinagh-Regular.ttf.zst",source:"NotoSansTifinagh-Regular.ttf",family:"NotoSansTifinagh",codec:"zstd",encodedLength:32867,byteLength:79376,sha256:"8058054786bc572007193988654d1ded342bc2538c2d91c50d1a7238ea1a99cc",dict:null},{file:"NotoSerifTibetan-Bold.ttf.zst",source:"NotoSerifTibetan-Bold.ttf",family:"NotoSerifTibetan",codec:"zstd",encodedLength:180961,byteLength:602368,sha256:"1e8ca12dff8bf6adee21f5b0a6ba827fc2f9b3c515655983438371d1275e1d53",dict:"NotoSerifTibetan-Regular.ttf.zst"},{file:"NotoSerifTibetan-Regular.ttf.zst",source:"NotoSerifTibetan-Regular.ttf",family:"NotoSerifTibetan",codec:"zstd",encodedLength:196887,byteLength:609688,sha256:"ee97bf3dc56e813651db734c9f35f8f1d41e7e31acf5f7d893e64ad22b292446",dict:null}]}});var rt,Rn=U(()=>{rt={format:1,schema:1,pack:"latin",version:"0.4.2",faces:[{file:"Caladea-Bold.ttf.zst",source:"Caladea-Bold.ttf",family:"Caladea",codec:"woff2t+zstd",encodedLength:21905,byteLength:84468,sha256:"2232eb978a52d6cf5bc68bf47f8f3cd1e25dbd97269ced65f42f5cfb7636e556",dict:"Caladea-Regular.ttf.zst"},{file:"Caladea-BoldItalic.ttf.zst",source:"Caladea-BoldItalic.ttf",family:"Caladea",codec:"woff2t+zstd",encodedLength:28887,byteLength:83332,sha256:"2f7b738168c95adb66b9a16675e004ab91da23f92439baadcbe0188a5aa57e3d",dict:"Caladea-Regular.ttf.zst"},{file:"Caladea-Italic.ttf.zst",source:"Caladea-Italic.ttf",family:"Caladea",codec:"woff2t+zstd",encodedLength:28027,byteLength:83748,sha256:"609d28fb3c53bcc14d9996e51590cc422bf4ffd96e3cbd613605ccf75cda2b6e",dict:"Caladea-Regular.ttf.zst"},{file:"Caladea-Regular.ttf.zst",source:"Caladea-Regular.ttf",family:"Caladea",codec:"woff2t+zstd",encodedLength:33985,byteLength:81576,sha256:"da44b1e107daf242afbd765b8d4b5de5d52bc369f71b3666bff7e8dd0c45a8c7",dict:null},{file:"Carlito-Bold.ttf.zst",source:"Carlito-Bold.ttf",family:"Carlito",codec:"woff2t+zstd",encodedLength:159534,byteLength:686544,sha256:"708f167f7c3215cdbd270d40f89217530c37cb4281aa16b27791e2ce61e2de40",dict:"Carlito-Regular.ttf.zst"},{file:"Carlito-BoldItalic.ttf.zst",source:"Carlito-BoldItalic.ttf",family:"Carlito",codec:"woff2t+zstd",encodedLength:192091,byteLength:812632,sha256:"7aa387d2a7bb4c29b6613ebfed2ee5b203379715b32325d060cc2256ffcf0434",dict:"Carlito-Regular.ttf.zst"},{file:"Carlito-Italic.ttf.zst",source:"Carlito-Italic.ttf",family:"Carlito",codec:"woff2t+zstd",encodedLength:169386,byteLength:619352,sha256:"251f8a2efce3f042a9e8d72d167aef42d009c965725b23b4b766fde42d623e58",dict:"Carlito-Regular.ttf.zst"},{file:"Carlito-Regular.ttf.zst",source:"Carlito-Regular.ttf",family:"Carlito",codec:"woff2t+zstd",encodedLength:201493,byteLength:632084,sha256:"4cd4f010f14990501a59c127bf6b489ffddebf9563196c933c02ff80f6069d56",dict:null},{file:"ComicRelief-Bold.ttf.zst",source:"ComicRelief-Bold.ttf",family:"ComicRelief",codec:"woff2t+zstd",encodedLength:40330,byteLength:94684,sha256:"111224e5cd44fb9e704f09f669919688b4fe77b7bcc5ddb0851cb5902e13156b",dict:"ComicRelief-Regular.ttf.zst"},{file:"ComicRelief-Regular.ttf.zst",source:"ComicRelief-Regular.ttf",family:"ComicRelief",codec:"woff2t+zstd",encodedLength:39050,byteLength:80324,sha256:"b53344de83f058df9b3415b0eab23dfb0a9753a3891c6c7748ff6a7529f6cca2",dict:null},{file:"DMSans-Bold.ttf.zst",source:"DMSans-Bold.ttf",family:"DMSans",codec:"woff2t+zstd",encodedLength:12993,byteLength:57104,sha256:"97fb8612dc026b4e9311d7fc07f97d16000d6c715e8c3b02dd414699b94cbb58",dict:"DMSans-Regular.ttf.zst"},{file:"DMSans-BoldItalic.ttf.zst",source:"DMSans-BoldItalic.ttf",family:"DMSans",codec:"woff2t+zstd",encodedLength:20842,byteLength:61664,sha256:"9fe83e925d8e54d12badf24d4c692b474a66bacac87b367a49fc8b8367dbf8d7",dict:"DMSans-Regular.ttf.zst"},{file:"DMSans-Italic.ttf.zst",source:"DMSans-Italic.ttf",family:"DMSans",codec:"woff2t+zstd",encodedLength:19858,byteLength:61796,sha256:"508b80473a75336ef2409d6e9e91db99dceac0bde5ecbedff20c04baf4fc15f4",dict:"DMSans-Regular.ttf.zst"},{file:"DMSans-Regular.ttf.zst",source:"DMSans-Regular.ttf",family:"DMSans",codec:"woff2t+zstd",encodedLength:24149,byteLength:57184,sha256:"2b937658a9738fd7e6c5c58272304b18909d1d77367eeff5e45c30349c634fe3",dict:null},{file:"DMSerifDisplay-Italic.ttf.zst",source:"DMSerifDisplay-Italic.ttf",family:"DMSerifDisplay",codec:"woff2t+zstd",encodedLength:24017,byteLength:68828,sha256:"b0f60b2bb27387e5a5adee9ae82d9892d913899fd8779243f01710919ce7378e",dict:"DMSerifDisplay-Regular.ttf.zst"},{file:"DMSerifDisplay-Regular.ttf.zst",source:"DMSerifDisplay-Regular.ttf",family:"DMSerifDisplay",codec:"woff2t+zstd",encodedLength:32202,byteLength:70680,sha256:"554fd2457ac34a78429fe507c57fdc7a165c0e397839d23469593b4482d57cc4",dict:null},{file:"Gelasio-Bold.ttf.zst",source:"Gelasio-Bold.ttf",family:"Gelasio",codec:"woff2t+zstd",encodedLength:28791,byteLength:108424,sha256:"41ba5cfbf13a39fc632ef6a3bcc17266263051772a7a0f672402f677a1f3ff1a",dict:"Gelasio-Regular.ttf.zst"},{file:"Gelasio-BoldItalic.ttf.zst",source:"Gelasio-BoldItalic.ttf",family:"Gelasio",codec:"woff2t+zstd",encodedLength:39212,byteLength:108444,sha256:"7fcfbd0b37d52274fc5c1f614d550d4cc1130e7847f5bdcda8349abe8f321fff",dict:"Gelasio-Regular.ttf.zst"},{file:"Gelasio-Italic.ttf.zst",source:"Gelasio-Italic.ttf",family:"Gelasio",codec:"woff2t+zstd",encodedLength:38046,byteLength:108428,sha256:"f509ba5f3758c52c1499f6a1e7f33434bae22763a39e12b21220b31e7b694127",dict:"Gelasio-Regular.ttf.zst"},{file:"Gelasio-Regular.ttf.zst",source:"Gelasio-Regular.ttf",family:"Gelasio",codec:"woff2t+zstd",encodedLength:44536,byteLength:108244,sha256:"39b7530d21ee6974fd976b8b7b3344388c26b0d6a10e4588e28725c00821b1d9",dict:null},{file:"Heebo-Bold.ttf.zst",source:"Heebo-Bold.ttf",family:"Heebo",codec:"woff2t+zstd",encodedLength:15367,byteLength:43076,sha256:"332bdc93d6793764328ad645d6c916ceeccbab8bee57014d74bb1d67a9aa3f0b",dict:"Heebo-Regular.ttf.zst"},{file:"Heebo-Regular.ttf.zst",source:"Heebo-Regular.ttf",family:"Heebo",codec:"woff2t+zstd",encodedLength:20855,byteLength:42700,sha256:"f77d0f8bf7f50913ae04cef33cdd5f89e0bb413c0b0c8aac528a9fc47b751f19",dict:null},{file:"Inter-Bold.ttf.zst",source:"Inter-Bold.ttf",family:"Inter",codec:"woff2t+zstd",encodedLength:62864,byteLength:345568,sha256:"4517d0eee11ae5d4a0c3dd15ffe7836daa241b1d3531fe005995f3da91350c84",dict:"Inter-Regular.ttf.zst"},{file:"Inter-BoldItalic.ttf.zst",source:"Inter-BoldItalic.ttf",family:"Inter",codec:"woff2t+zstd",encodedLength:105501,byteLength:349012,sha256:"1ec39173a03a5b37e53a8e1b47b31cda544f9b27e5ecce02f7d139aec664e57a",dict:"Inter-Regular.ttf.zst"},{file:"Inter-Italic.ttf.zst",source:"Inter-Italic.ttf",family:"Inter",codec:"woff2t+zstd",encodedLength:98252,byteLength:347140,sha256:"acdbe0bdb8315cbbe45018c80c1c320cb997c89c09f5b3583e30ccb724c7be09",dict:"Inter-Regular.ttf.zst"},{file:"Inter-Regular.ttf.zst",source:"Inter-Regular.ttf",family:"Inter",codec:"woff2t+zstd",encodedLength:123512,byteLength:343792,sha256:"b622889ba11c7ce42298e6c161a63e83e88674f04f53fd1823eb1805116c35d3",dict:null},{file:"LiberationMono-Bold.ttf.zst",source:"LiberationMono-Bold.ttf",family:"LiberationMono",codec:"woff2t+zstd",encodedLength:98360,byteLength:307964,sha256:"0afd655a6cdd339c1d242045a63af2d0009b1b66af4fc36da89da900abf4abe8",dict:"LiberationMono-Regular.ttf.zst"},{file:"LiberationMono-BoldItalic.ttf.zst",source:"LiberationMono-BoldItalic.ttf",family:"LiberationMono",codec:"woff2t+zstd",encodedLength:99395,byteLength:284012,sha256:"7f4f09b69a4d781c6de982153a10aeb1d7b2a56749756fc38c87c8dcc930216c",dict:"LiberationMono-Regular.ttf.zst"},{file:"LiberationMono-Italic.ttf.zst",source:"LiberationMono-Italic.ttf",family:"LiberationMono",codec:"woff2t+zstd",encodedLength:91094,byteLength:281492,sha256:"e77cde86fd02a11aa01a479c397317b314214f175429e760f1afdbac16f7bcb9",dict:"LiberationMono-Regular.ttf.zst"},{file:"LiberationMono-Regular.ttf.zst",source:"LiberationMono-Regular.ttf",family:"LiberationMono",codec:"woff2t+zstd",encodedLength:133511,byteLength:319464,sha256:"918e5910b9226ffc2c154bfcd16c54af2430ff82e4cb11ad826213b84cfbf9f3",dict:null},{file:"LiberationSans-Bold.ttf.zst",source:"LiberationSans-Bold.ttf",family:"LiberationSans",codec:"woff2t+zstd",encodedLength:118901,byteLength:414428,sha256:"246d4db41e2f51a64ed99e372dbee7ce67ef31b10d9122dd675c365a826f2c3a",dict:"LiberationSans-Regular.ttf.zst"},{file:"LiberationSans-BoldItalic.ttf.zst",source:"LiberationSans-BoldItalic.ttf",family:"LiberationSans",codec:"woff2t+zstd",encodedLength:125494,byteLength:408960,sha256:"688c23f57881a9f504742bfed5e6d84b8b679973d0b4ed364fe18c41745c7a7a",dict:"LiberationSans-Regular.ttf.zst"},{file:"LiberationSans-Italic.ttf.zst",source:"LiberationSans-Italic.ttf",family:"LiberationSans",codec:"woff2t+zstd",encodedLength:121743,byteLength:415768,sha256:"89c48340314ca981b6c15e1ea87346248eeb63b44f10bf2f8aa2b5a9bb910091",dict:"LiberationSans-Regular.ttf.zst"},{file:"LiberationSans-Regular.ttf.zst",source:"LiberationSans-Regular.ttf",family:"LiberationSans",codec:"woff2t+zstd",encodedLength:160582,byteLength:410684,sha256:"988219c3d1d8d929b1b67599864a9f94f209dd3f1124a7ebb625b26e215d1543",dict:null},{file:"LiberationSerif-Bold.ttf.zst",source:"LiberationSerif-Bold.ttf",family:"LiberationSerif",codec:"woff2t+zstd",encodedLength:113267,byteLength:370084,sha256:"abbc8f40b5f46100a3b9a2497b8fd084ad18376851efdecf8dd509ccb58f2c38",dict:"LiberationSerif-Regular.ttf.zst"},{file:"LiberationSerif-BoldItalic.ttf.zst",source:"LiberationSerif-BoldItalic.ttf",family:"LiberationSerif",codec:"woff2t+zstd",encodedLength:127059,byteLength:376752,sha256:"e2881162ee8df048564f71b9a0cee11eb44fb10b58218a76a2021f5300af638f",dict:"LiberationSerif-Regular.ttf.zst"},{file:"LiberationSerif-Italic.ttf.zst",source:"LiberationSerif-Italic.ttf",family:"LiberationSerif",codec:"woff2t+zstd",encodedLength:123578,byteLength:375624,sha256:"6435e5bc7d756c790d1b696ca69ffa7fe87b1bcea93c55b1724697d1f6fd2fbe",dict:"LiberationSerif-Regular.ttf.zst"},{file:"LiberationSerif-Regular.ttf.zst",source:"LiberationSerif-Regular.ttf",family:"LiberationSerif",codec:"woff2t+zstd",encodedLength:156988,byteLength:393560,sha256:"e1c83ee51195cf5877a30100141741b6527d2cb70d97030a3e297dd79cd90af9",dict:null},{file:"Montserrat-Bold.ttf.zst",source:"Montserrat-Bold.ttf",family:"Montserrat",codec:"woff2t+zstd",encodedLength:67001,byteLength:382660,sha256:"ea6848a18ec0c29c676713548624e062bb423759823ed12a718cc6c0ae868edc",dict:"Montserrat-Regular.ttf.zst"},{file:"Montserrat-BoldItalic.ttf.zst",source:"Montserrat-BoldItalic.ttf",family:"Montserrat",codec:"woff2t+zstd",encodedLength:100368,byteLength:387916,sha256:"501313b93e7cff4b54c4cffaada1802de6f30d56fb33a4765909f3e9dd7c98ff",dict:"Montserrat-Regular.ttf.zst"},{file:"Montserrat-Italic.ttf.zst",source:"Montserrat-Italic.ttf",family:"Montserrat",codec:"woff2t+zstd",encodedLength:88097,byteLength:387668,sha256:"28f70408cc5823af7b38a80fb6b75feb4b9e48a3a786798aa43ed66c94bba4e8",dict:"Montserrat-Regular.ttf.zst"},{file:"Montserrat-Regular.ttf.zst",source:"Montserrat-Regular.ttf",family:"Montserrat",codec:"woff2t+zstd",encodedLength:116235,byteLength:382512,sha256:"1847e0c96868041ac80f348625fadf2126b823e693b1b99836921220f8c789e8",dict:null},{file:"NotoNaskhArabic-Regular.ttf.zst",source:"NotoNaskhArabic-Regular.ttf",family:"NotoNaskhArabic",codec:"woff2t+zstd",encodedLength:87473,byteLength:247336,sha256:"16485107fe2151208892e7007d6393c6b07c35a2bd15aeab76ffa74e90200fe0",dict:null},{file:"NotoSansArabic-Bold.ttf.zst",source:"NotoSansArabic-Bold.ttf",family:"NotoSansArabic",codec:"woff2t+zstd",encodedLength:59452,byteLength:261460,sha256:"9eed45f76952c9f557a9d17464dcda8e28fa9eeedb0a7c673ae4ab6959d4f21f",dict:"NotoSansArabic-Regular.ttf.zst"},{file:"NotoSansArabic-Regular.ttf.zst",source:"NotoSansArabic-Regular.ttf",family:"NotoSansArabic",codec:"woff2t+zstd",encodedLength:80208,byteLength:234892,sha256:"e199135893cf81284289849d27bb90c85127565b045f5020fbf378420a357a23",dict:null},{file:"NotoSansHebrew-Bold.ttf.zst",source:"NotoSansHebrew-Bold.ttf",family:"NotoSansHebrew",codec:"woff2t+zstd",encodedLength:4768,byteLength:26860,sha256:"e27d1e835526a42abe895271be0e7ebc84cfcd3905591e3eb233a67d54feaac1",dict:"NotoSansHebrew-Regular.ttf.zst"},{file:"NotoSansHebrew-Regular.ttf.zst",source:"NotoSansHebrew-Regular.ttf",family:"NotoSansHebrew",codec:"woff2t+zstd",encodedLength:11741,byteLength:26860,sha256:"ceab815ea653db4b433adf5b1e5d4bf0cf6e770eba2d1e007a3733af5bc0ca4c",dict:null},{file:"OpenSans-Bold.ttf.zst",source:"OpenSans-Bold.ttf",family:"OpenSans",codec:"woff2t+zstd",encodedLength:35237,byteLength:131376,sha256:"a5e58d48453979fe3bbf23741685a38eafa5844213478518eeba49b04ffd724a",dict:"OpenSans-Regular.ttf.zst"},{file:"OpenSans-BoldItalic.ttf.zst",source:"OpenSans-BoldItalic.ttf",family:"OpenSans",codec:"woff2t+zstd",encodedLength:53635,byteLength:136572,sha256:"253b170672a6ef00759c13f0d9e6d722cc6ca3250a6755137036efa0dbb42f26",dict:"OpenSans-Regular.ttf.zst"},{file:"OpenSans-Italic.ttf.zst",source:"OpenSans-Italic.ttf",family:"OpenSans",codec:"woff2t+zstd",encodedLength:55398,byteLength:136904,sha256:"9219305ac95ecc0a6b24edf1c51ccd642be4c12c72a00cb23501e2bc8fd7ec4e",dict:"OpenSans-Regular.ttf.zst"},{file:"OpenSans-Regular.ttf.zst",source:"OpenSans-Regular.ttf",family:"OpenSans",codec:"woff2t+zstd",encodedLength:63052,byteLength:131348,sha256:"321402fc191778afd1e4c5c6582d8ba776f1a4fde5fa36727915196d3ee5b250",dict:null},{file:"Oswald-Bold.ttf.zst",source:"Oswald-Bold.ttf",family:"Oswald",codec:"woff2t+zstd",encodedLength:21980,byteLength:79124,sha256:"9ca59ad293d09b4aca68767e6d5035879e5abe62622375bfee14be5056740cac",dict:"Oswald-Regular.ttf.zst"},{file:"Oswald-Regular.ttf.zst",source:"Oswald-Regular.ttf",family:"Oswald",codec:"woff2t+zstd",encodedLength:30980,byteLength:78864,sha256:"666626e668f6a733640ce821133444b4de3106ae9d63c1384d2cb81e5387a058",dict:null},{file:"Poppins-Bold.ttf.zst",source:"Poppins-Bold.ttf",family:"Poppins",codec:"woff2t+zstd",encodedLength:9889,byteLength:28380,sha256:"ae4fe8bf5b0d0952734cb319b2e4be3bb07f392b054d45ff227008cba41f723d",dict:"Poppins-Regular.ttf.zst"},{file:"Poppins-BoldItalic.ttf.zst",source:"Poppins-BoldItalic.ttf",family:"Poppins",codec:"woff2t+zstd",encodedLength:11833,byteLength:30644,sha256:"a46a88258dd9db50d31014ae337bab75f10df50582ec41a87cebabb863cb3262",dict:"Poppins-Regular.ttf.zst"},{file:"Poppins-Italic.ttf.zst",source:"Poppins-Italic.ttf",family:"Poppins",codec:"woff2t+zstd",encodedLength:11275,byteLength:31028,sha256:"59dacd6fc164e4609e59f4aba9159fd4380134fdc3819a78df80e1cfd2ab3f3f",dict:"Poppins-Regular.ttf.zst"},{file:"Poppins-Regular.ttf.zst",source:"Poppins-Regular.ttf",family:"Poppins",codec:"woff2t+zstd",encodedLength:12849,byteLength:28744,sha256:"08301da3d6d5b96e10ab21ecd44805061516495f3b5e991d4abe4086b51f516d",dict:null},{file:"Roboto-Bold.ttf.zst",source:"Roboto-Bold.ttf",family:"Roboto",codec:"woff2t+zstd",encodedLength:40499,byteLength:159516,sha256:"22daa6ad3481345ba565236d92ba6ee20ba3f0d3955316aa9adfe98342e9fcdf",dict:"Roboto-Regular.ttf.zst"},{file:"Roboto-BoldItalic.ttf.zst",source:"Roboto-BoldItalic.ttf",family:"Roboto",codec:"woff2t+zstd",encodedLength:50838,byteLength:165300,sha256:"6bcd40c6c30d71d34cbb409868bf471ceb8fd3518419a1526de555c8b26482fe",dict:"Roboto-Regular.ttf.zst"},{file:"Roboto-Italic.ttf.zst",source:"Roboto-Italic.ttf",family:"Roboto",codec:"woff2t+zstd",encodedLength:45173,byteLength:164436,sha256:"35453ffbd70a5ff93e7071bcad710382861138071ff3e360db50904132832c4b",dict:"Roboto-Regular.ttf.zst"},{file:"Roboto-Regular.ttf.zst",source:"Roboto-Regular.ttf",family:"Roboto",codec:"woff2t+zstd",encodedLength:73157,byteLength:158800,sha256:"ec8cb7b5fe7a4fee22fbf83ff1d9182b816d3720841f5c81465613b0eefe51a1",dict:null},{file:"Selawik-Bold.ttf.zst",source:"Selawik-Bold.ttf",family:"Selawik",codec:"woff2t+zstd",encodedLength:11215,byteLength:37160,sha256:"91fbcbb62d2f81b353d79983e1581a09d6aa29284feb4c7a61bf74b11643beee",dict:"Selawik-Regular.ttf.zst"},{file:"Selawik-Light.ttf.zst",source:"Selawik-Light.ttf",family:"Selawik",codec:"woff2t+zstd",encodedLength:10825,byteLength:37336,sha256:"0453552666983f7f1223fd465408614633a87e55e51ba2d7caec23984756f201",dict:"Selawik-Regular.ttf.zst"},{file:"Selawik-Regular.ttf.zst",source:"Selawik-Regular.ttf",family:"Selawik",codec:"woff2t+zstd",encodedLength:15274,byteLength:37332,sha256:"d21efc27f5faa09d6c97dfc9d8e04e1485b7b541f673f8370776aa0f6a15de41",dict:null},{file:"Selawik-Semibold.ttf.zst",source:"Selawik-Semibold.ttf",family:"Selawik",codec:"woff2t+zstd",encodedLength:11167,byteLength:37296,sha256:"49bdfb67bf85474297499685acf27ddcf341e2b44574d73e5a3a1f14db918216",dict:"Selawik-Regular.ttf.zst"},{file:"Selawik-Semilight.ttf.zst",source:"Selawik-Semilight.ttf",family:"Selawik",codec:"woff2t+zstd",encodedLength:10626,byteLength:37356,sha256:"7f7e6dc7fbf1a958237bb2458b7ad4dcb6a5b4653e0080d5ff22e68b27dda23b",dict:"Selawik-Regular.ttf.zst"},{file:"SourceSans3-Bold.ttf.zst",source:"SourceSans3-Bold.ttf",family:"SourceSans3",codec:"woff2t+zstd",encodedLength:59669,byteLength:381448,sha256:"0dc147bb4ef75eba8f7e850d9d7b171bc415fbd34ff9e2507093064e4d40ef0c",dict:"SourceSans3-Regular.ttf.zst"},{file:"SourceSans3-BoldItalic.ttf.zst",source:"SourceSans3-BoldItalic.ttf",family:"SourceSans3",codec:"woff2t+zstd",encodedLength:64432,byteLength:241716,sha256:"882bed09dd50d5b640d2bfb3a7949a176fbe6edf00c6337eeadbc91dab87e49e",dict:"SourceSans3-Regular.ttf.zst"},{file:"SourceSans3-Italic.ttf.zst",source:"SourceSans3-Italic.ttf",family:"SourceSans3",codec:"woff2t+zstd",encodedLength:63358,byteLength:241888,sha256:"485b89001477742fff8f2c79161c663e7e71fbecc15acfd4c242fae8e226c10a",dict:"SourceSans3-Regular.ttf.zst"},{file:"SourceSans3-Regular.ttf.zst",source:"SourceSans3-Regular.ttf",family:"SourceSans3",codec:"woff2t+zstd",encodedLength:113140,byteLength:381684,sha256:"5ebbfd4b12455f56d84839d4c389c46f8c7ff930bb4ce2acb80bf76a624b1ce2",dict:null}]}});var Fn,Or=U(()=>{Fn={format:1,schema:1,pack:"base-latin",version:"1",faces:[{file:"BetterOfficeBaseLatin-Regular.ttf.zst",source:"BetterOfficeBaseLatin-Regular.ttf",family:"BetterOffice Base Latin",codec:"zstd",dict:null,encodedLength:48737,byteLength:85920,sha256:"51d1dcec287000a2043782a69b9ee7f035ae834e465951499176c3355407da43"},{file:"BetterOfficeBaseLatin-Bold.ttf.zst",source:"BetterOfficeBaseLatin-Bold.ttf",family:"BetterOffice Base Latin",codec:"zstd",dict:null,encodedLength:18848,byteLength:34548,sha256:"9bf0b21fed98275570a190200a97896689558ba7693bc85832aa482eb29c80b7"},{file:"BetterOfficeBaseLatin-Italic.ttf.zst",source:"BetterOfficeBaseLatin-Italic.ttf",family:"BetterOffice Base Latin",codec:"zstd",dict:null,encodedLength:19853,byteLength:35704,sha256:"b17266b332d081245d500e9a1f136725f2741e98e34d93e30309ba803ce96d60"},{file:"BetterOfficeBaseLatin-BoldItalic.ttf.zst",source:"BetterOfficeBaseLatin-BoldItalic.ttf",family:"BetterOffice Base Latin",codec:"zstd",dict:null,encodedLength:19803,byteLength:35616,sha256:"ae4d6b157e91f89673009bf2a3d8748eaba978b1daeb81323cc6c4c88589861a"}]}});function Pe(e,t,n,r){return[{family:e,metricCompatWith:t,weight:400,style:"normal",file:`${n}-Regular.ttf`,byteLength:r[0]},{family:e,metricCompatWith:t,weight:700,style:"normal",file:`${n}-Bold.ttf`,byteLength:r[1]},{family:e,metricCompatWith:t,weight:400,style:"italic",file:`${n}-Italic.ttf`,byteLength:r[2]},{family:e,metricCompatWith:t,weight:700,style:"italic",file:`${n}-BoldItalic.ttf`,byteLength:r[3]}]}function le(e,t,n){return["Regular","Bold"].flatMap(r=>{let o=`${n}-${r}.ttf.zst`,s=id.get(o);return s===void 0?[]:[{family:e,weight:r==="Bold"?700:400,style:"normal",file:o,byteLength:s,script:t}]})}function zt(e){let t=e.trim().toLowerCase();return Js.get(Xs[t]??t)}function ke(e,t,n){let r=zt(e);if(!r)return;if(r==="Selawik"){if(n)return;let l=e.trim().toLowerCase(),a=t&&l==="segoe ui semibold"?"segoe ui":l,f=t&&a==="segoe ui"?700:400;return Ce.find(d=>d.metricCompatWith?.toLowerCase()===a&&d.weight===f)}let o=Ce.filter(l=>l.family===r),s=t?700:400,i=n?"italic":"normal";return o.find(l=>l.weight===s&&l.style===i)??o.find(l=>l.weight===400&&l.style==="normal")}function Nr(e,t,n){if(e.trim().toLowerCase()===Mr.toLowerCase())return $e.find(l=>l.weight===(t?700:400)&&l.style===(n?"italic":"normal"));if(zt(e)==="Selawik")return n?void 0:ke(e,t,!1);let r=e.trim().toLowerCase(),o=cd.get(r)??dd[r]??zt(e),s=t?700:400,i=n?"italic":"normal";return Ce.find(l=>l.family===o&&l.weight===s&&l.style===i)}function Ir(e,t,n,r){let o=r===void 0?void 0:fd[r.trim().toLowerCase()]?.[e],s=Ce.filter(a=>a.script===e);if(o!==void 0){let a=s.find(f=>f.family===o&&f.weight===400&&f.style==="normal");if(a!==void 0)return a}if(s.length===0)return;let i=t?700:400,l=n?"italic":"normal";return s.find(a=>a.weight===i&&a.style===l)??s.find(a=>a.weight===i&&a.style==="normal")??s.find(a=>a.weight===400&&a.style==="normal")??s[0]}function ud(e){let t=e.toLowerCase();return/sans[ -]?serif/.test(t)?!1:t.includes("antiqua")||t.includes("bookman")||t.includes("calisto")||t.includes("schoolbook")||t.includes("goudy")||t.includes("perpetua")||t.includes("rockwell")||t.includes("caslon")||t.includes("constantia")||t.includes("didot")||t.includes("baskerville")||t.includes("times")||t.includes("georgia")||t.includes("garamond")||t.includes("palatino")||t.includes("baskerville")||t.includes("bodoni")||t.includes("cambria")||t.includes("minion")||t.includes("mincho")||t.includes("\u660E\u671D")||t.includes("\u660E\u9AD4")||t.includes("\u5B8B")||t.includes("ming")||t.includes("song")||t.includes("serif")}function Hs(e){return pd.get(e.trim().toLowerCase())}function js(e,t,n){let r=e.trim().split(/[\s-]+/);if(r.length<2||!md.has(r[r.length-1].toLowerCase()))return;let o=r.slice(0,-1).join(" "),s=t&&zt(o)!=="Selawik",i=ke(o,s,n);return i&&(!s||i.weight===700)?i:ke(o,!1,n)}function Ur(e,t,n){return js(e,t,n)}function hd(e){let t=e.toLowerCase();return t.includes("consolas")||t.includes("monaco")||t.includes("menlo")||t.includes("console")||t.includes("andale")||t.includes("inconsolata")||t.includes("cascadia")||t.includes("typewriter")||/(^|[\s-])mono([\s-]|$)/.test(t)}function yd(e,t){let n=e.trim().split(/[\s-]+/);if(!(n.length<2||!bd.has(n[n.length-1].toLowerCase())))return ke(n.slice(0,-1).join(" "),!0,t)}function $s(e,t,n,r="powerpoint"){return An(e,t,n,r).face}function An(e,t,n,r="powerpoint"){let o=ke(e,t,n),s=Wr(e,t,n,r,o!==void 0);if(s.file!==o?.file)return{face:s,onlyIfPrimaryFails:!1};let i=s.family==="Liberation Sans"?"Calibri":"Arial";return{face:ke(i,t,n),onlyIfPrimaryFails:!0}}function Br(e,t,n,r="powerpoint"){let o=ke(e,t,n);if((o??Wr(e,t,n,r)).family==="Selawik")return o?$s(e,t,n,r):Wr(e,t,n,r,!0)}function Wr(e,t,n,r,o=!1){let s=js(e,t,n);if(s&&(!o||s.family!=="Selawik"))return s;s&&(t=!1);let i=yd(e,n);if(i&&(!o||i.family!=="Selawik"))return i;if(gd.has(e.trim().toLowerCase()))return ke("Arial",t,n);if(hd(e))return ke("Courier New",t,n);let l=Hs(e);if(l){let d=ke(l.family,t,n);if(d)return d}let a=r==="word"?"Arial":"Calibri",f=ud(e)?"Times New Roman":a;return ke(f,t,n)}function Vs(e,t=!1,n=!1){let r=t?n?"boldItalic":"bold":n?"italic":"regular";return Hs(e)?.digitAdvances[r]}function wd(e,t,n,r=!1,o=!1){let s=Vs(e,r,o);return s!==void 0?Math.round(s*t):Math.max(...[..."0123456789"].map(i=>Math.round(n(i))))}var Mr,$e,id,ad,ld,Ce,Xs,Js,cd,dd,fd,pd,md,bd,gd,gt=U(()=>{"use strict";Pn();Rn();Or();Mr="BetterOffice Base Latin",$e=Fn.faces.map(e=>({family:Mr,weight:e.source.includes("-Bold")?700:400,style:e.source.includes("Italic")?"italic":"normal",file:e.file,byteLength:e.byteLength}));id=new Map(yt.faces.map(({file:e,byteLength:t})=>[e,t]));ad=[...Pe("Carlito","Calibri","Carlito",[628032,682468,615236,808508]),{family:"Selawik",metricCompatWith:"Segoe UI",weight:400,style:"normal",file:"Selawik-Regular.ttf",byteLength:44224},{family:"Selawik",metricCompatWith:"Segoe UI",weight:700,style:"normal",file:"Selawik-Bold.ttf",byteLength:44068},{family:"Selawik",metricCompatWith:"Segoe UI Light",weight:400,style:"normal",file:"Selawik-Light.ttf",byteLength:44232},{family:"Selawik",metricCompatWith:"Segoe UI Semilight",weight:400,style:"normal",file:"Selawik-Semilight.ttf",byteLength:44260},{family:"Selawik",metricCompatWith:"Segoe UI Semibold",weight:400,style:"normal",file:"Selawik-Semibold.ttf",byteLength:44192},...Pe("Caladea","Cambria","Caladea",[81600,84492,83780,83356]),...Pe("Liberation Sans","Arial","LiberationSans",[410712,414456,415816,408996]),...Pe("Liberation Serif","Times New Roman","LiberationSerif",[393576,370096,375632,376772]),...Pe("Liberation Mono","Courier New","LiberationMono",[319508,307996,281536,284068]),...Pe("Gelasio","Georgia","Gelasio",[107588,107864,107904,107932]),...Pe("Inter","Inter","Inter",[341396,343104,344784,346628]),...Pe("Roboto","Roboto","Roboto",[157584,158316,163212,164100]),...Pe("Source Sans 3","Source Sans Pro","SourceSans3",[379576,379468,240444,240384]),...Pe("DM Sans","DM Sans","DMSans",[56856,56784,61472,61324]),...Pe("Open Sans","Open Sans","OpenSans",[130484,130504,136020,135700]),...Pe("Montserrat","Montserrat","Montserrat",[374500,374640,384612,384792]),...Pe("Poppins","Poppins","Poppins",[28468,28108,30772,30388]),{family:"Oswald",metricCompatWith:"Oswald",weight:400,style:"normal",file:"Oswald-Regular.ttf",byteLength:78404},{family:"Oswald",metricCompatWith:"Oswald",weight:700,style:"normal",file:"Oswald-Bold.ttf",byteLength:78736},{family:"Heebo",metricCompatWith:"Heebo",weight:400,style:"normal",file:"Heebo-Regular.ttf",byteLength:42368},{family:"Heebo",metricCompatWith:"Heebo",weight:700,style:"normal",file:"Heebo-Bold.ttf",byteLength:42732},{family:"DM Serif Display",metricCompatWith:"DM Serif Display",weight:400,style:"normal",file:"DMSerifDisplay-Regular.ttf",byteLength:70440},{family:"DM Serif Display",metricCompatWith:"DM Serif Display",weight:400,style:"italic",file:"DMSerifDisplay-Italic.ttf",byteLength:68560},{family:"Comic Relief",metricCompatWith:"Comic Sans MS",weight:400,style:"normal",file:"ComicRelief-Regular.ttf",byteLength:80324},{family:"Comic Relief",metricCompatWith:"Comic Sans MS",weight:700,style:"normal",file:"ComicRelief-Bold.ttf",byteLength:94684},{family:"Noto Sans Hebrew",weight:400,style:"normal",file:"NotoSansHebrew-Regular.ttf",byteLength:26860,script:"hebrew"},{family:"Noto Sans Hebrew",weight:700,style:"normal",file:"NotoSansHebrew-Bold.ttf",byteLength:26860,script:"hebrew"},{family:"Noto Sans Arabic",weight:400,style:"normal",file:"NotoSansArabic-Regular.ttf",byteLength:234892,script:"arabic"},{family:"Noto Sans Arabic",weight:700,style:"normal",file:"NotoSansArabic-Bold.ttf",byteLength:261460,script:"arabic"},{family:"Noto Naskh Arabic",weight:400,style:"normal",file:"NotoNaskhArabic-Regular.ttf",byteLength:247336,script:"arabic"},...le("Noto Sans Thai","thai","NotoSansThai"),...le("Noto Sans Lao","lao","NotoSansLao"),...le("Noto Sans Khmer","khmer","NotoSansKhmer"),...le("Noto Sans Myanmar","myanmar","NotoSansMyanmar"),...le("Noto Sans Devanagari","devanagari","NotoSansDevanagari"),...le("Noto Sans Bengali","bengali","NotoSansBengali"),...le("Noto Sans Gurmukhi","gurmukhi","NotoSansGurmukhi"),...le("Noto Sans Gujarati","gujarati","NotoSansGujarati"),...le("Noto Sans Oriya","oriya","NotoSansOriya"),...le("Noto Sans Tamil","tamil","NotoSansTamil"),...le("Noto Sans Telugu","telugu","NotoSansTelugu"),...le("Noto Sans Kannada","kannada","NotoSansKannada"),...le("Noto Sans Malayalam","malayalam","NotoSansMalayalam"),...le("Noto Sans Sinhala","sinhala","NotoSansSinhala"),...le("Noto Sans Armenian","armenian","NotoSansArmenian"),...le("Noto Sans Georgian","georgian","NotoSansGeorgian"),...le("Noto Sans Ethiopic","ethiopic","NotoSansEthiopic"),...le("Noto Serif Tibetan","tibetan","NotoSerifTibetan"),...le("Noto Sans Mongolian","mongolian","NotoSansMongolian"),...le("Noto Sans Syriac","syriac","NotoSansSyriac"),...le("Noto Sans Thaana","thaana","NotoSansThaana"),...le("Noto Sans Cherokee","cherokee","NotoSansCherokee"),...le("Noto Sans Lao Looped","lao","NotoSansLaoLooped"),...le("Noto Sans Tifinagh","tifinagh","NotoSansTifinagh"),{family:"Noto Sans SC",metricCompatWith:"Microsoft YaHei",weight:400,style:"normal",file:"NotoSansSC-Regular.otf.zst",byteLength:8331336,script:"cjk-sc"},{family:"Noto Serif SC",metricCompatWith:"SimSun",weight:400,style:"normal",file:"NotoSerifSC-Regular.otf.zst",byteLength:11625800,script:"cjk-sc"},{family:"Noto Sans TC",metricCompatWith:"Microsoft JhengHei",weight:400,style:"normal",file:"NotoSansTC-Regular.otf.zst",byteLength:5683368,script:"cjk-tc"},{family:"Noto Sans JP",metricCompatWith:"MS Gothic",weight:400,style:"normal",file:"NotoSansJP-Regular.otf.zst",byteLength:4533028,script:"cjk-jp"},{family:"Noto Sans KR",metricCompatWith:"Malgun Gothic",weight:400,style:"normal",file:"NotoSansKR-Regular.otf.zst",byteLength:4644748,script:"cjk-kr"}],ld=new Map(rt.faces.map(e=>[e.source,e])),Ce=ad.map(e=>{let t=ld.get(e.file);return t===void 0?e:{...e,file:t.file,byteLength:t.byteLength}}),Xs={helvetica:"arial",times:"times new roman",courier:"courier new",helv:"arial","arial mt":"arial",arialmt:"arial","tms rmn":"times new roman","times roman":"times new roman",timesnewroman:"times new roman",timesnewromanps:"times new roman",timesnewromanpsmt:"times new roman",arimo:"arial","liberation sans":"arial","nimbus sans":"arial","helvetica neue":"arial",carlito:"calibri",tinos:"times new roman","liberation serif":"times new roman","nimbus roman":"times new roman",cousine:"courier new","liberation mono":"courier new","nimbus mono ps":"courier new",caladea:"cambria",simhei:"microsoft yahei",dengxian:"microsoft yahei",\u5FAE\u8F6F\u96C5\u9ED1:"microsoft yahei",\u9ED1\u4F53:"microsoft yahei",\u7B49\u7EBF:"microsoft yahei",nsimsun:"simsun",fangsong:"simsun",kaiti:"simsun",\u5B8B\u4F53:"simsun",\u4EFF\u5B8B:"simsun",\u6977\u4F53:"simsun",\u5FAE\u8EDF\u6B63\u9ED1\u9AD4:"microsoft jhenghei",pmingliu:"microsoft jhenghei",mingliu:"microsoft jhenghei","dfkai-sb":"microsoft jhenghei",\u65B0\u7D30\u660E\u9AD4:"microsoft jhenghei",\u7D30\u660E\u9AD4:"microsoft jhenghei",\u6A19\u6977\u9AD4:"microsoft jhenghei","ms pgothic":"ms gothic","ms ui gothic":"ms gothic",meiryo:"ms gothic","yu gothic":"ms gothic","\uFF4D\uFF53 \u30B4\u30B7\u30C3\u30AF":"ms gothic","\uFF4D\uFF53 \uFF50\u30B4\u30B7\u30C3\u30AF":"ms gothic",\u30E1\u30A4\u30EA\u30AA:"ms gothic",\u6E38\u30B4\u30B7\u30C3\u30AF:"ms gothic","ms mincho":"ms gothic","ms pmincho":"ms gothic","yu mincho":"ms gothic","\uFF4D\uFF53 \u660E\u671D":"ms gothic","\uFF4D\uFF53 \uFF50\u660E\u671D":"ms gothic",\u6E38\u660E\u671D:"ms gothic","\uB9D1\uC740 \uACE0\uB515":"malgun gothic",gulim:"malgun gothic",dotum:"malgun gothic",batang:"malgun gothic",gungsuh:"malgun gothic",\uAD74\uB9BC:"malgun gothic",\uB3CB\uC6C0:"malgun gothic",\uBC14\uD0D5:"malgun gothic",\uAD81\uC11C:"malgun gothic"},Js=new Map;for(let e of Ce)e.metricCompatWith!==void 0&&Js.set(e.metricCompatWith.toLowerCase(),e.family);cd=new Map(Ce.map(e=>[e.family.toLowerCase(),e.family])),dd={"noto serif tc":"Noto Sans TC","noto serif jp":"Noto Sans JP","noto serif kr":"Noto Sans KR"};fd={"simplified arabic":{arabic:"Noto Naskh Arabic"},"traditional arabic":{arabic:"Noto Naskh Arabic"}};pd=new Map([["verdana",{family:"Montserrat",digitAdvances:{regular:.636,bold:.711,italic:.636,boldItalic:.711}}]]);md=new Set(["thin","hairline","extralight","ultralight","semilight","light","medium"]);bd=new Set(["black","heavy","extrabold","ultrabold","extrablack","ultra"]);gd=new Set(["wingdings","wingdings 2","wingdings 3","webdings"])});var Dr,Ks=U(()=>{Dr={thresholds:[1e3,800,600,400,250,150],tiers:["ffffffffffffffff7fffffff00000000ffffdffffffffffffffffffffffffffffffffffffffffdffffffffffffffffffffffffffffffffefffffffffffffffffff7fffff7c30ffffffffd7f0fffffffb30ff7ffff67f0000ffffffffffffffffffffffff03bfffff3fffff7fffffffffffffffffffffffffffbe00805619004700000010ffff00000000003e0000003f00000000000000008044000008004406010000000031000000000000000000000000000000000000040200008c00000000400000000000000000000000001000","ffffffffffffffff7fffffff00000000ffffdffffffffffffffffffffffffffffffffffffffffdffffffffff4cddc443008380033fffe00fff31ccfcff0033337c0000cd0000033e08100000180002800000008100000000ffffffffffffffffffffffff003c000c0fcf00000ccfcc0f03f3819f00ccc3cc773e008006090047000000105ada0000000000360000003f000000000000000080440000080044060100000000310000000000000000000000000000000000000002000004000000","ffffffffffffffff7fffffff00000000ffffdfffffffffffffffffff0c0f000f00000f00000cf19800003f000004000000018003000000000000000000000000000000000000000000000000000000000000000100000000ffff0002ffffffff0002ffff0000000000000000000000000000000000000000771a00000609004700000000180000000000000000000000000000000000000080040000080044060100000000310000000000000000000000000000000000000000000004000000","ffffffffffffffff7fffffff00000000ffffdfffffffffffffffffff0c0f000f00000f00000cf19800003f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000771a0000060900470000000010000000","ffffffffffffffff7fffffff00000000fbffdbfeffffffffffffffff0c0f000f00000c00000c319800000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000771a0000060000440000000010000000","ffffffffffffffff7fffffff00000000fbffdbfeffffffffffffffff0c0f000f00000c00000c319800000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000771a0000060000440000000010000000"],levels:"1111555554444111111111111444411113333222255553333222255553355554400000000000000000000000000000000000000000000000000333331444"}});function Sd(){return[...new Set([...Ce,...$e].map(e=>e.file))]}function Qs(e){Gs??=new Map(Sd().map((n,r)=>[n,Number(Dr.levels[r]??0)]));let t=Gs.get(e)??0;return t>0?Dr.tiers[t-1]:void 0}var Gs,Ys=U(()=>{"use strict";Ks();gt()});function Zs(e,t,n){let r=new Map,o=(s,i)=>{let l=`${s.file}|${i?.measureAs??""}|${i?.onlyIfPrimaryFails??!1}`,a=r.get(l);if(a===void 0){let f=n?.(s),d=Qs(s.file);a=Object.assign(()=>e(s),i,{...f&&{slices:f},...d===void 0?void 0:{coverage:d},...t&&{readOnlyBytes:()=>t(s)}}),r.set(l,a)}return a};return{resolveBaseLatin(s,i){let l=$e.find(a=>a.weight===(s?700:400)&&a.style===(i?"italic":"normal"));return l?o(l):void 0},resolve(s,i,l){let a=ke(s,i,l);return a?o(a,{measureAs:a.family==="Selawik"?a.metricCompatWith:void 0}):void 0},resolveFamily(s,i,l){let a=Nr(s,i,l);return a?o(a):void 0},resolveScriptFallback(s,i,l,a){let f=Ir(s,i,l,a);return f?o(f):void 0},resolveGlyphFallback(s,i,l,a="powerpoint"){let f=Br(s,i,l,a);return f?o(f):void 0},resolveLightVariant(s,i,l){let a=Ur(s,i,l);return a?o(a):void 0},resolveLastResort(s,i,l,a){let{face:f,onlyIfPrimaryFails:d}=An(s,i,l,a);return o(f,d?{onlyIfPrimaryFails:d}:void 0)}}}var ei=U(()=>{"use strict";gt();Ys()});function ti(e){let t=globalThis.process;if(typeof t?.getBuiltinModule=="function")try{return t.getBuiltinModule(e)}catch{return}}function xd(e){if(e.protocol!=="file:")return;let t=globalThis;if(t.process?.versions?.node!==void 0&&t.Deno===void 0&&typeof t.process.getBuiltinModule!="function")throw ri||(ri=!0,console.warn(`[@betteroffice/fonts] ${ni}`)),new Error(ni);let n=ti("node:fs"),r=ti("node:url");if(!(!n||!r))try{let o=n.readFileSync(r.fileURLToPath(e.href));return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}catch{return}}function vd(e,t){if(t.byteLength!==e.byteLength)throw new Error(`Bundled font ${e.file} has ${t.byteLength} bytes; expected ${e.byteLength}`);return t}async function qr(e,t,n){let r=xd(t);if(r)return r;let o=await fetch(t,n===void 0?void 0:{signal:AbortSignal.timeout(n),credentials:"omit",referrerPolicy:"no-referrer"});if(!o.ok)throw new Error(`Failed to fetch bundled font ${e}: HTTP ${o.status}`);return o.arrayBuffer()}function oi(e,t,n){let r=`${t.href}|${e.byteLength}|${n??""}`,o=En.get(r);if(o)return o;let s=(async()=>vd(e,await qr(e.file,t,n)))();return s.catch(()=>{En.get(r)===s&&En.delete(r)}),En.set(r,s),s}var ni,ri,En,zr=U(()=>{"use strict";ni="Reading bundled fonts from installed packages needs Node.js 20.16+ or 22.3+ (process.getBuiltinModule); upgrade Node.js or pass a font baseUrl.",ri=!1;En=new Map});var ii,si=U(()=>{ii={format:1,schema:1,pack:"cjk",version:"0.4.2",faces:[{file:"NotoSansJP-Regular.otf.zst",source:"NotoSansJP-Regular.otf",family:"NotoSansJP",codec:"zstd",encodedLength:3595531,byteLength:4533028,sha256:"dff723ba59d57d136764a04b9b2d03205544f7cd785a711442d6d2d085ac5073",dict:null,slices:{format:1,index:"NotoSansJP-Regular/slices.json",indexSha256:"9fd53a1857302a7d9b3dc2b9f3e8039b6d13c64e0a79d416ddbca8a692bc415d"}},{file:"NotoSansKR-Regular.otf.zst",source:"NotoSansKR-Regular.otf",family:"NotoSansKR",codec:"zstd",encodedLength:3420953,byteLength:4644748,sha256:"69975a0ac8472717870aefeab0a4d52739308d90856b9955313b2ad5e0148d68",dict:null,slices:{format:1,index:"NotoSansKR-Regular/slices.json",indexSha256:"309e142311ef7c1b73b6052ba4ddb09f77a06d2ebc20243fbbed55cb872ce47d"}},{file:"NotoSansSC-Regular.otf.zst",source:"NotoSansSC-Regular.otf",family:"NotoSansSC",codec:"zstd",encodedLength:6444964,byteLength:8331336,sha256:"faa6c9df652116dde789d351359f3d7e5d2285a2b2a1f04a2d7244df706d5ea9",dict:null,slices:{format:1,index:"NotoSansSC-Regular/slices.json",indexSha256:"73a0d2d52944be3db939ec12c1331521429d7ad2f7bff5b9342f6942fc671d90"}},{file:"NotoSansTC-Regular.otf.zst",source:"NotoSansTC-Regular.otf",family:"NotoSansTC",codec:"zstd",encodedLength:4456580,byteLength:5683368,sha256:"5bab0cb3c1cf89dde07c4a95a4054b195afbcfe784d69d75c340780712237537",dict:null,slices:{format:1,index:"NotoSansTC-Regular/slices.json",indexSha256:"e246aab5dbca74d596959ca46a6693733b137bacc0bda47e8dd6f3d02aeeb857"}},{file:"NotoSerifSC-Regular.otf.zst",source:"NotoSerifSC-Regular.otf",family:"NotoSerifSC",codec:"zstd",encodedLength:8743526,byteLength:11625800,sha256:"e8f396decc1f0963a016a989c3d8852e863d1350996f573860a80767c83a1cd3",dict:null,slices:{format:1,index:"NotoSerifSC-Regular/slices.json",indexSha256:"7e1cf89eaa36520084c6b74bb3fd6bcbe595bc674fed4d834db967abde54b675"}}]}});function Te(e,t){return e>>>t|e<<32-t}function Pd(e){let t=new Uint8Array(e),n=new Uint8Array(Math.ceil((t.length+9)/64)*64);n.set(t),n[t.length]=128;let r=new DataView(n.buffer);r.setUint32(n.length-8,Math.floor(t.length/536870912)),r.setUint32(n.length-4,t.length*8);let o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=new Uint32Array(64);for(let i=0;i<n.length;i+=64){for(let h=0;h<16;h++)s[h]=r.getUint32(i+h*4);for(let h=16;h<64;h++){let C=s[h-15],v=s[h-2];s[h]=s[h-16]+(Te(C,7)^Te(C,18)^C>>>3)+s[h-7]+(Te(v,17)^Te(v,19)^v>>>10)}let[l,a,f,d,p,y,k,u]=o;for(let h=0;h<64;h++){let C=u+(Te(p,6)^Te(p,11)^Te(p,25))+(p&y^~p&k)+_d[h]+s[h],v=(Te(l,2)^Te(l,13)^Te(l,22))+(l&a^l&f^a&f);u=k,k=y,y=p,p=d+C>>>0,d=f,f=a,a=l,l=C+v>>>0}for(let[h,C]of[l,a,f,d,p,y,k,u].entries())o[h]+=C}return Array.from(o,i=>i.toString(16).padStart(8,"0")).join("")}async function ai(e){if(globalThis.crypto?.subtle===void 0)return Pd(e);let t=new Uint8Array(await crypto.subtle.digest("SHA-256",e));return Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}var _d,li=U(()=>{"use strict";_d=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298])});async function Xr(){let e=(await Ue("decoder"))?.urls?.["fontpack.wasm"];return e===void 0?void 0:new URL(e)}async function ci(e){if(e.protocol==="file:"){let{Deno:n,Bun:r}=globalThis;try{let o=Dt(e,!0);if(o)return o;if(n)return await n.readFile(e);if(r)return new Uint8Array(await r.file(e).arrayBuffer())}catch(o){throw o instanceof Error&&o.name==="NotFound"&&Object.assign(o,{code:"ENOENT"}),o}}let t=await fetch(e,{signal:AbortSignal.timeout(3e4)});if(!t.ok)throw Object.assign(new Error(`Cannot load font decoder wasm: HTTP ${t.status}`),{decoderStatus:t.status});return new Uint8Array(await t.arrayBuffer())}var Tn=U(()=>{"use strict";tt();Sn();tt()});var Hr={};Mt(Hr,{decodeFontBytes:()=>Wd,decodeFontFace:()=>mi,releaseFontDecoder:()=>Ad});function Ad(){ot.clear()}function Jr(e){let t=globalThis.process;if(typeof t?.getBuiltinModule=="function")try{return t.getBuiltinModule(e)}catch{return}}function di(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function Xt(e){return new Uint8Array(e).buffer}function Le(){return new Error("Font face is corrupt or truncated, or uses a wrong dictionary")}function Ed(e,t){if(e.length<5)throw Le();let n=e[4];if(n&8)throw Le();let r=(n&32)!==0,o=n>>>6,s=o===0?r?1:0:1<<o,i=5+(r?0:1),l=[0,1,2,4][n&3];if(i+=l,e.length<i+s)throw Le();if(s===0)throw new Error("Font face has no decoded content size");let a=0n;for(let d=0;d<s;d++)a|=BigInt(e[i+d])<<BigInt(8*d);if(o===1&&(a+=256n),a>BigInt(t))throw new Error(`Font face is too large: ${a} decoded bytes exceed ${t}`);if((n&4)===0)throw new Error("Font face has no content checksum");i+=s;let f=!1;for(;!f;){if(i+3>e.length)throw Le();let d=e[i]|e[i+1]<<8|e[i+2]<<16;f=(d&1)!==0;let p=d>>>1&3;if(p===3||(i+=3+(p===1?1:d>>>3),i>e.length))throw Le()}if(i+4!==e.length)throw new Error("Font face is corrupt or must contain exactly one zstd frame");return Number(a)}async function Td(e){let t;if(e.protocol==="file:")t=(await WebAssembly.instantiate(Xt(await ci(e,Jr)),{})).instance;else{if(typeof fetch!="function")throw new Error("Cannot fetch font decoder wasm");let r=await fetch(e,{signal:AbortSignal.timeout(3e4),credentials:"omit",referrerPolicy:"no-referrer"});if(!r.ok)throw Object.assign(new Error(`Cannot load font decoder wasm: HTTP ${r.status}`),{decoderStatus:r.status});if(/^https?:$/.test(e.protocol)&&typeof Response<"u"&&typeof WebAssembly.instantiateStreaming=="function")try{t=(await WebAssembly.instantiateStreaming(r.clone(),{})).instance}catch{t=(await WebAssembly.instantiate(await r.arrayBuffer(),{})).instance}else t=(await WebAssembly.instantiate(await r.arrayBuffer(),{})).instance}let n=t.exports;if(!(n.memory instanceof WebAssembly.Memory)||["fp_alloc","fp_free","fp_decode","fp_decode_face","fp_out_ptr","fp_out_len","fp_out_free","fp_payload_ptr","fp_payload_len","fp_payload_free"].some(r=>typeof n[r]!="function"))throw new Error("Font decoder wasm has incompatible exports");return n}function Ld(e){let{decoderStatus:t,code:n}=e??{};return t===403||t===404||t===410?`HTTP ${t}`:n==="ENOENT"?"no such file":void 0}async function ui(e){let t=[],n;for(let r of[()=>e,Xr]){let o=await r();if(o===void 0||r===Xr&&o.href===e?.href)continue;let s=fi.get(o.href);if(s!==void 0){t.push(`${o.href} (${s})`);continue}try{let i=await pi(o);for(;i.failed;)i=await pi(o);return i}catch(i){let l=Ld(i);if(l===void 0)throw i;fi.set(o.href,l),t.push(`${o.href} (${l})`),n=i}}throw Object.assign(new Error(`Font decoder wasm not found: ${t.join(", ")||"no decoder URL"}. Serve @betteroffice/fonts/dist/decoder/fontpack.wasm at the first location, or let the bundler emit the package decoder.`),{cause:n})}function pi(e){let t=e.href,n=ot.get(t);if(n)return n;let r=Td(e).then(o=>{let s={wasm:o,failed:!1,invalidate(){s.failed=!0,ot.get(t)===r&&ot.delete(t)}};return s});return ot.set(t,r),r.catch(()=>{ot.get(t)===r&&ot.delete(t)}),r}function Ln(e){switch(e){case-2:return new Error("Font face has no decoded content size");case-3:return new Error("Font face is too large for maxOutput");case-4:return new Error("Font face checksum failed: corrupt face or wrong dictionary");case-5:return new Error("Font face dictionary is missing or wrong");case-7:return new Error("Cannot allocate memory for font face");case-9:return new Error("Font face has no content checksum");case-10:return new Error("Font face WOFF2 reconstruction failed");default:return Le()}}function Od(e,t,n,r,o,s){let{wasm:i}=e;function l(d){try{return d()}catch{throw e.invalidate(),new Error("Font face could not be decoded")}}let a=0,f=0;try{if(a=l(()=>i.fp_alloc(t.length))>>>0,!a)throw Ln(-7);if(new Uint8Array(i.memory.buffer,a,t.length).set(t),n?.length){if(f=l(()=>i.fp_alloc(n.length))>>>0,!f)throw Ln(-7);new Uint8Array(i.memory.buffer,f,n.length).set(n)}let d=l(()=>s==="zstd"?i.fp_decode(a,t.length,f,n?.length??0,r):i.fp_decode_face(a,t.length,f,n?.length??0,r,1));if(d!==0)throw Ln(d);let p=l(()=>i.fp_out_len())>>>0;if(p>r)throw Ln(-3);let y=Xt(new Uint8Array(i.memory.buffer,l(()=>i.fp_out_ptr())>>>0,p));if(s==="zstd"){if(p!==o)throw Le();return{font:y}}let k=l(()=>i.fp_payload_len())>>>0;if(k!==o)throw Le();let u=Xt(new Uint8Array(i.memory.buffer,l(()=>i.fp_payload_ptr())>>>0,k));return{font:y,payload:u}}finally{e.failed||(l(()=>i.fp_out_free()),l(()=>i.fp_payload_free()),f&&l(()=>i.fp_free(f,n?.length??0)),a&&l(()=>i.fp_free(a,t.length)))}}async function Wd(e,t,n){return(await mi(e,t,n)).font}async function mi(e,t,n){let r=n?.codec??"zstd";if(r!=="zstd"&&r!=="woff2t+zstd")throw new Error(`Unsupported font face codec: ${r}`);let o=di(e);if(o.length<4||o[0]!==40||o[1]!==181||o[2]!==47||o[3]!==253)return{font:Xt(o)};let s=n?.maxOutput??Rd;if(!Number.isSafeInteger(s)||s<0||s>2147483647)throw new Error("Font face maxOutput must be an integer from 0 to 2147483647");let i=r==="woff2t+zstd"?Math.min(s,Fd):s,l=Ed(o,i),a=t===void 0?void 0:di(t);if(r==="woff2t+zstd"&&(o.length>i||(a?.length??0)>i))throw new Error("Font face is too large for maxOutput");let f=r==="woff2t+zstd"?void 0:Jr("node:zlib");if(typeof f?.zstdDecompressSync=="function")try{let p=Jr("node:buffer"),y=f.zstdDecompressSync(o,{dictionary:a===void 0?void 0:p?.Buffer.from(a)??a,maxOutputLength:Math.max(1,i)});if(y.byteLength!==l)throw Le();return{font:Xt(y)}}catch(p){let y=p instanceof Error?p.message:String(p);throw new Error(`Font face is corrupt or uses a wrong dictionary: ${y}`)}let d=await ui(n?.wasmUrl);for(;d.failed;)d=await ui(n?.wasmUrl);return Od(d,o,a,i,l,r)}var Rd,Fd,ot,fi,jr=U(()=>{"use strict";Tn();Rd=64*1024*1024,Fd=64*1024*1024,ot=new Map;fi=new Map});function Wn(e){let t=e;if(t?.format!==1||t.schema!==void 0&&t.schema!==1||!Array.isArray(t.faces))throw new Error("Unsupported font pack manifest");for(let n of t.faces)if(n.codec!=="zstd"&&n.codec!=="woff2t+zstd")throw new Error(`Unsupported font face codec: ${n.codec}`);return t}function Jt(e){return Id.has(e)}function Mn(e){return Nd.has(e)}function Bd(e){return Ud.has(e)}async function On(e,t,n,r,o,s,i){let l=s?.decoder,a=Dd;l!==void 0&&(a=hi.get(l)??new Map,hi.set(l,a));let f=i??await n(e),d=typeof r=="function"?r(f):r,p=t.faces.find(C=>C.file===e.file);if(p===void 0)throw new Error(`Unknown bundled font asset: ${e.file}`);let y=typeof d=="object"?"implicit":d??"",k=`${t.pack}|${t.version}|${f.href}|${p.codec}|${p.dict}|${p.encodedLength}|${e.byteLength}|${p.sha256}|${y}|${o?.href??""}`,u=a.get(k);if(u===void 0){u=(async()=>{let P=p.dict===null?void 0:t.faces.find(g=>g.file===p.dict);if(p.dict!==null&&(P===void 0||P.dict!==null||P.codec!==p.codec||P.family!==p.family))throw new Error(`Missing bundled font dictionary for ${e.file}`);let L=P&&{...e,file:P.file,byteLength:P.byteLength},B=L&&await n(L),D=B&&(typeof r=="function"?r(B):r),V=B&&typeof D=="object"?()=>D.check(B):void 0,R=()=>L&&On(L,t,n,r,o,s,B),J=g=>{if(g.byteLength!==p.encodedLength)throw new Error(`Bundled font ${e.file} has ${g.byteLength} encoded bytes; expected ${p.encodedLength}`);return g},O=async(g,c)=>{let b=c===void 0?void 0:(c.payload??c.font).slice(0),S=await gi(o,l)(g,{codec:p.codec,dict:b,maxOutput:64*1024*1024});if(S.font.byteLength!==e.byteLength)throw new Error(`Bundled font ${e.file} has ${S.font.byteLength} bytes; expected ${e.byteLength}`);if(await ai(S.font)!==p.sha256)throw new Error(`Bundled font ${e.file} SHA-256 mismatch`);if(p.codec==="woff2t+zstd"&&S.payload===void 0)throw new Error(`Missing bundled font dictionary payload for ${e.file}`);return S};if(typeof d=="object")return d.load(e.file,f,async(g,c)=>{await c(()=>J(g));let b=await R();return c(()=>O(g,b))},V);V?.();let[F,x]=await Promise.all([qr(e.file,f,d).then(J),R()]);return O(F,x)})(),a.set(k,u);let C=u,v=()=>{a.get(k)===C&&a.delete(k)};u.then(s?.retain===!1?v:void 0,v)}let h=u;return h.then(C=>qd(C,e)?C:(a.get(k)===h&&a.delete(k),On(e,t,n,r,o,s)))}function qd(e,t){return e.font.byteLength===t.byteLength&&e.payload?.byteLength!==0}function Ht(e){return Mn(e.file)?yi:Jt(e.file)?bi:Bd(e.file)?$r:Md}function gi(e,t){return t??(async(n,r)=>(await Promise.resolve().then(()=>(jr(),Hr))).decodeFontFace(n,r.dict,{...r,wasmUrl:e}))}function Nn(e,t){let n=gi(e,t);return async(r,o)=>(await n(r,{codec:"zstd",maxOutput:o})).font}function In(e){return $r.faces.find(t=>t.file===e)?.slices}async function jt(e,t,n,r,o=Ht(e),s){return(await On(e,o,t,n,r,s)).font.slice(0)}async function wi(...e){let[t,n,r,o,s=Ht(t),i]=e;return(await On(t,s,n,r,o,i)).font}var bi,Md,$r,yi,Nd,Id,Ud,Dd,hi,ki=U(()=>{"use strict";Rn();Pn();si();Or();zr();li();bi=Wn(rt),Md=Wn(yt),$r=Wn(ii),yi=Wn(Fn),Nd=new Set(yi.faces.map(e=>e.file)),Id=new Set(bi.faces.map(e=>e.file)),Ud=new Set($r.faces.map(e=>e.file));Dd=new Map,hi=new WeakMap});function Si(e){let t=globalThis.process;if(typeof t?.getBuiltinModule=="function")try{return t.getBuiltinModule(e)}catch{return}}function wt(e,t,n){return{pack:e,reason:t,detail:`@betteroffice/fonts-${e} ${n}; its faces are substituted`}}function xi(e,t){let n=[...t].sort();if(!n.length)return;let r=n.length>1?` and ${n.length-1} more files`:"";return wt(e,"missing-file",`is missing ${n[0]}${r}`)}function zd(e,t){let n=Si("node:fs"),r=Si("node:url");if(t.protocol!=="file:"||!n||!r)return;let o=a=>r.fileURLToPath(new URL(a,t).href),s=a=>a.filter(f=>!n.statSync(o(f),{throwIfNoEntry:!1})?.isFile()),i;try{i=n.readFileSync(o("manifest.json"),"utf8")}catch(a){return a.code==="ENOENT"?xi(e,[...s(Un[e]),"manifest.json"])??null:wt(e,"invalid-manifest","has an unreadable manifest")}let l;try{l=JSON.parse(i)?.version}catch{return wt(e,"invalid-manifest","has an unreadable manifest")}return l!==Vr?wt(e,"version-mismatch",`${typeof l=="string"?l:"of unknown version"} does not match the ${Vr} release the engine needs`):xi(e,s(Un[e]))??null}async function vi(e,t=!0){let n=[];for(let r of["latin","intl","cjk"]){let o;try{o=await e[r]()}catch{n.push(wt(r,"invalid-manifest","has an unreadable manifest"));continue}if(!o)continue;let s=Un[r].filter(a=>a in o),i=s[0]??Object.keys(o)[0],l=!t||i===void 0?void 0:zd(r,o[i]());if(l!==void 0){l&&n.push(l);continue}s.length<Un[r].length&&n.push(wt(r,"version-mismatch",`of unknown version does not match the ${Vr} release the engine needs`))}return n}var Un,Vr,Ci=U(()=>{"use strict";Pn();Rn();gt();Un={latin:rt.faces.map(e=>e.file),intl:yt.faces.map(({file:e})=>e),cjk:Ce.filter(e=>e.script?.startsWith("cjk-")).map(e=>e.file)},Vr=rt.version});function Bn(e){return e instanceof Error&&e.diagnostic?.reason==="cdn-unavailable"}function Dn({diagnostic:e}){typeof globalThis.dispatchEvent=="function"&&typeof CustomEvent=="function"&&globalThis.dispatchEvent(new CustomEvent("betteroffice:font-pack-diagnostic",{detail:{...e}}))}var Kr=U(()=>{});function Gr(e,t){let n=typeof e=="string"?e:e.href,r=n.endsWith("/")?n:`${n}/`;try{return new URL(r,t)}catch{throw new TypeError(`Font baseUrl must be absolute when no browser location exists: ${r}`)}}function Fi(e,{inspectDisk:t=!0,pageLocation:n,localCdn:r}={}){let o=new Set(Ce.filter(x=>x.script?.startsWith("cjk-")).map(x=>x.file)),s=new Set(Ce.filter(x=>x.file.endsWith(".ttf.zst")&&!Jt(x.file)).map(x=>x.file)),i=new WeakMap,l=new Set;function a(x,g,c,b){if(!b?.baseUrl||c==="base")return;let S=Ht(x);if(!S.faces.some(M=>M.file===x.file))return;let W=Ds(S,g,b.implicit?void 0:b.baseUrl);return i.set(W,b.implicit?Is(c):b.timeoutMs),W}function f(x){return i.get(x)}function d(x){let g=f(x);return typeof g=="number"?g:void 0}function p(x){if(x!==void 0){if(!n)return Gr(x,globalThis.location?.href);try{return Gr(x,void 0)}catch{let g=n().then(c=>Gr(x,c));return g.catch(()=>{}),g}}}async function y(x,g,c=!1){let{file:b,script:S}=x;if(g!==void 0)return new URL(b,g);let W=Mn(b)?"base":Jt(b)?"latin":s.has(b)?"intl":S?.startsWith("cjk-")||o.has(b)?"cjk":void 0;if(W){let{urls:M,cdn:G}=await e(W),re=M?.[b];if(re)return re();let Y=a(x,b,W,c&&G?.implicit?void 0:G);if(Y)return Y;if(W==="latin"&&!M)throw new st(`Bundled font ${b} needs @betteroffice/fonts-latin - install @betteroffice/fonts-latin`);if(W==="intl"&&!M)throw new qn(`Bundled font ${b} needs the optional intl add-on - install @betteroffice/fonts-intl`);if(W==="cjk")throw new $t(M?`Bundled font ${b} needs a compressed @betteroffice/fonts-cjk release matching @betteroffice/fonts`:`Bundled font ${b} needs the optional CJK add-on \u2014 install @betteroffice/fonts-cjk`)}throw new Error(`Unknown bundled font asset: ${b}`)}function k(x,g,{urls:c,cdn:b}){let S=c?.[g];if(S)return S();let W=a(x,g,"cjk",b);if(W)return W;throw new $t(c?`Font slice ${g} needs a @betteroffice/fonts-cjk release matching @betteroffice/fonts`:`Font slice ${g} needs the optional CJK add-on \u2014 install @betteroffice/fonts-cjk`)}function u(x,g,c){let b=In(x.file);if(!b)return;let S=g instanceof URL?g:void 0,W=M=>M&&new URL("decoder/fontpack.wasm",M);return{ref:b,base:S?.href??"",url:async M=>{let G=g instanceof Promise?await g:g;return G?new URL(M,G):k(x,M,await e("cjk"))},prepareUrls:S?void 0:async()=>{if(g instanceof Promise){let Y=await g;return{base:Y.href,url:async te=>new URL(te,Y),decode:Nn(W(Y),c?.decoder)}}let M=await e("cjk"),G=r?{urls:M.urls,cdn:r()}:M,re=k(x,b.index,G);return{base:typeof f(re)=="object"?`${re.href}#implicit`:re.href,url:Object.assign(async Y=>Y===b.index?re:k(x,Y,G),{implicitCdn:Y=>G.cdn?.implicit===!0&&!G.urls?.[Y]}),timeoutMs:d(re)}},loadWholeForExport:()=>L(x,jt,g,{...c,strict:!0}),requestTimeoutMs:d,decode:g instanceof Promise?async(M,G)=>Nn(W(await g),c?.decoder)(M,G):Nn(W(S),c?.decoder),decoder:c?.decoder,retain:c?.retain}}async function h(x){try{let g=await y(x,void 0);return typeof f(g)!="object"||!l.has(g.href)}catch(g){if(g instanceof st)return!1;throw g}}function C(x){return x?.[Ri]===!0}async function v(x,g){let c=async b=>{let S=await y(b,void 0);if(typeof f(S)!="object")return;let W=g&&In(b.file);return Bs(S,W?new URL(W.index,S):void 0)};try{let b=Ht(x).faces.find(({file:M})=>M===x.file)?.dict,S=await c(x),W=b?await c({...x,file:b}):void 0;return Math.max(S??0,W??0)||void 0}catch(b){if(C(b))return 1/0;throw b}}function P(x,g,c){return L(x,jt,p(g?.baseUrl),c)}async function L(x,g,c,b,S=!1,W){let M=c instanceof Promise?await c:c,G=b?.strict==="except-optional-cdn-failure",re,Y=async te=>{let oe=await y(te,M,S),ce=typeof f(oe)=="object";G&&ce&&te===x&&(re=oe.href);let me=b?.strict&&ce&&In(te.file);return me&&Us(new URL(me.index,oe)),oe};try{let te=await(Mn(x.file)||Jt(x.file)||s.has(x.file)||o.has(x.file)?g(x,Y,f,M===void 0?void 0:new URL("decoder/fontpack.wasm",M),void 0,b):Y(x).then(oe=>oi(x,oe,d(oe))));return re&&l.delete(re),te}catch(te){if(M!==void 0)throw te;if(Bn(te)){let oe=te.diagnostic.pack!=="latin";if(b?.strict&&!(G&&oe))throw te;Dn(te),W?.();let ce=await B(x,g,b,oe);return re&&oe&&l.add(re),ce}if(b?.strict===!0)throw te;if(te instanceof $t||te instanceof qn)return B(x,g,b,!0);throw te}}async function B(x,g,c,b){let S=x.weight>=600;if(b){let M=ke(x.family.includes("Serif")?"Times New Roman":"Arial",S,x.style==="italic");try{return await L(M,g,void 0,c,!0)}catch(G){if(!(G instanceof st))throw G}}let W=$e.find(({weight:M,style:G})=>M===700===S&&G===x.style);return L(W,g,void 0,c)}let D=new Map,V=new WeakMap;function R(x,g,c,b){if(typeof document>"u"||typeof FontFace>"u"||document.fonts===void 0)return Promise.resolve();let S=g??x.family,W=D;b?.decoder!==void 0&&(W=V.get(b.decoder)??new Map,V.set(b.decoder,W));let M=`${S}|${x.weight}|${x.style}|${Rr()}`,G=W.get(M);if(G)return G;let re=!1,Y=()=>{W.get(M)===te&&W.delete(M)},te=(async()=>{let oe=await L(x,jt,p(c?.baseUrl),b,!1,()=>{re=!0}),ce=new FontFace(S,oe,{weight:String(x.weight),style:x.style});await ce.load(),document.fonts.add(ce)})();return te.then(()=>{re&&Y()},Y),W.set(M,te),te}function J(x,g){let c=p(x?.baseUrl),b=Zs(S=>L(S,jt,c,g),S=>L(S,wi,c,g),S=>u(S,c,g));return c===void 0&&(b.faceUnavailableUntil=S=>v(S,!!g?.strict)),b}let O=async(x,{codec:g,dict:c,maxOutput:b})=>{let S=await Promise.resolve().then(()=>(jr(),Hr));try{return await S.decodeFontFace(x,c,{codec:g,maxOutput:b})}finally{S.releaseFontDecoder()}};async function F(){let x=async g=>(await e(g)).urls;return vi({latin:()=>x("latin"),intl:()=>x("intl"),cjk:()=>x("cjk")},t)}return{bundledFaceInstalled:h,isMissingFontAddon:C,loadBundledFontBytes:P,registerBundledFontFace:R,createFontProvider:J,decodeFontFaceOutsideEngine:O,checkFontPacks:F}}var Ri,_i,Pi,st,$t,qn,Ai=U(()=>{"use strict";gt();ei();zr();ki();Ci();Kr();_n();Ri=Symbol.for("@betteroffice/fonts/missing-addon"),st=class extends(Pi=Error,_i=Ri,Pi){constructor(n){super(n);this[_i]=!0;this.name="MissingFontAddonError"}},$t=class extends st{},qn=class extends st{}});var Qr={};Mt(Qr,{BASE_LATIN_FAMILY:()=>Mr,BASE_LATIN_FONTS:()=>$e,BUNDLED_FONTS:()=>Ce,WORD_FAMILY_ALIASES:()=>Xs,bundledFaceInstalled:()=>Jd,checkFontPacks:()=>Gd,configureFontCdn:()=>qs,createFontProvider:()=>Vd,decodeFontFaceOutsideEngine:()=>Kd,fontCdnConfiguration:()=>zs,isMissingFontAddon:()=>Hd,loadBundledFontBytes:()=>jd,maxDigitWidth:()=>wd,registerBundledFontFace:()=>$d,resolveBundledFamilyFace:()=>Nr,resolveDigitAdvance:()=>Vs,resolveGlyphFallbackFace:()=>Br,resolveLastResortChoice:()=>An,resolveLastResortFace:()=>$s,resolveLightVariantFace:()=>Ur,resolveMetricCompatFace:()=>ke,resolveMetricCompatFamily:()=>zt,resolveScriptFallbackFace:()=>Ir});var Xd,Jd,Hd,jd,$d,Vd,Kd,Gd,Ei=U(()=>{"use strict";_n();Ai();Tn();_n();gt();Xd=async e=>{let t=await Ue(e);return{urls:t?.urls&&Object.setPrototypeOf(Object.fromEntries(Object.entries(t.urls).map(([n,r])=>[n,()=>new URL(r)])),null),cdn:Pr(t)}},{bundledFaceInstalled:Jd,isMissingFontAddon:Hd,loadBundledFontBytes:jd,registerBundledFontFace:$d,createFontProvider:Vd,decodeFontFaceOutsideEngine:Kd,checkFontPacks:Gd}=Fi(Xd,{inspectDisk:!1,pageLocation:async()=>(await Ue("base",{fresh:!0}))?.pageUrl})});async function Qd(e){if(!(await Ue("base"))?.urls)throw new bn(e)}async function Yr(){return await Qd("@betteroffice/fonts"),Qr}var Zr=U(()=>{tt();Ei();Tn()});function to(){return m.allocationFailure()}function no(e,t,n,r){let o=Ee(e,m.__wbindgen_malloc),s=j,i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j;var a=qe(n)?0:Ee(n,m.__wbindgen_malloc),f=j;let d=m.decodeFontFace(o,s,i,l,a,f,!qe(r),qe(r)?0:r);if(d[2])throw q(d[1]);return q(d[0])}function Yd(){return{__proto__:null,"./xlsx_wasm_bg.js":{__proto__:null,__wbg_Error_30c8987f7c2ed4e2:function(t,n){return Error($(t,n))},__wbg___wbindgen_is_function_1f9d30630b8b1d3d:function(t){return typeof t=="function"},__wbg___wbindgen_is_undefined_8865fb403f8fe9d8:function(t){return t===void 0},__wbg___wbindgen_throw_41e9ee4f547fc59a:function(t,n){throw new Error($(t,n))},__wbg_call_6137034ef55c9d0f:function(){return zn(function(t,n){return t.call(n)},arguments)},__wbg_error_1ca51171bd9a2708:function(t,n){console.error($(t,n))},__wbg_getRandomValues_a608c4436c19407a:function(){return zn(function(t,n){globalThis.crypto.getRandomValues(De(t,n))},arguments)},__wbg_getTimezoneOffset_2e851fdaecc2dc92:function(t){return t.getTimezoneOffset()},__wbg_get_31af05bd4842a84f:function(){return zn(function(t,n){return Reflect.get(t,n)},arguments)},__wbg_new_2bdcdfcebdfc34d2:function(t,n){return new TypeError($(t,n))},__wbg_new_343a093a3c2ffb4e:function(t,n){return new Error($(t,n))},__wbg_new_34e56228080aa9f8:function(t){return new Date(t)},__wbg_new_617a8cdb8bb1130e:function(){return new Object},__wbg_new_from_slice_9a868026ffa4208a:function(t,n){return new Uint8Array(De(t,n))},__wbg_now_aa4ccb83129e9e55:function(){return Date.now()},__wbg_now_b64b08137b67aa67:function(){return performance.now()},__wbg_set_145a351398b48c65:function(){return zn(function(t,n,r){return Reflect.set(t,n,r)},arguments)},__wbg_static_accessor_GLOBAL_266715b9d96ba635:function(){let t=typeof global>"u"?null:global;return qe(t)?0:Vt(t)},__wbg_static_accessor_GLOBAL_THIS_10fb7dc1ae063179:function(){let t=typeof globalThis>"u"?null:globalThis;return qe(t)?0:Vt(t)},__wbg_static_accessor_SELF_0b583911f537483a:function(){let t=typeof self>"u"?null:self;return qe(t)?0:Vt(t)},__wbg_static_accessor_WINDOW_d7f903d1508cbdc4:function(){let t=typeof window>"u"?null:window;return qe(t)?0:Vt(t)},__wbindgen_generic_0000000000000001:function(t){return t},__wbindgen_generic_0000000000000002:function(t,n){return $(t,n)},__wbindgen_init_externref_table:function(){let t=m.__wbindgen_externrefs,n=t.grow(4);t.set(0,void 0),t.set(n+0,void 0),t.set(n+1,null),t.set(n+2,!0),t.set(n+3,!1)}}}}function Vt(e){let t=m.__externref_table_alloc();return m.__wbindgen_externrefs.set(t,e),t}function De(e,t){return e=e>>>0,kt().subarray(e/1,e/1+t)}function $(e,t){return ef(e>>>0,t)}function kt(){return(Kt===null||Kt.byteLength===0)&&(Kt=new Uint8Array(m.memory.buffer)),Kt}function zn(e,t){try{return e.apply(this,t)}catch(n){let r=Vt(n);m.__wbindgen_exn_store(r)}}function qe(e){return e==null}function Ee(e,t){let n=t(e.length*1,1)>>>0;return kt().set(e,n/1),j=e.length,n}function Q(e,t,n){if(n===void 0){let l=Gt.encode(e),a=t(l.length,1)>>>0;return kt().subarray(a,a+l.length).set(l),j=l.length,a}let r=e.length,o=t(r,1)>>>0,s=kt(),i=0;for(;i<r;i++){let l=e.charCodeAt(i);if(l>127)break;s[o+i]=l}if(i!==r){i!==0&&(e=e.slice(i)),o=n(o,r,r=i+e.length*3,1)>>>0;let l=kt().subarray(o+i,o+r),a=Gt.encodeInto(e,l);i+=a.written,o=n(o,r,i,1)>>>0}return j=i,o}function q(e){let t=m.__wbindgen_externrefs.get(e);return m.__externref_table_dealloc(e),t}function ef(e,t){return eo+=t,eo>=Zd&&(Xn=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Xn.decode(),eo=t),Xn.decode(kt().subarray(e,e+t))}function rf(e,t){return nf=e,m=e.exports,tf=t,Kt=null,m.__wbindgen_start(),m}async function of(e,t){if(typeof Response=="function"&&e instanceof Response){if(!e.ok)throw new Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function ro(e){if(m!==void 0)return m;if(e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),e===void 0)throw new Error("xlsx-wasm requires an explicit module or URL");let t=Yd();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await of(await e,t);return rf(n,r)}var Re,St,Ti,Li,Kt,Xn,Zd,eo,Gt,j,tf,nf,m,Oi=U(()=>{"use strict";Re=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Ti.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Ti.unregister(this),t}free(){let t=this.__destroy_into_raw();m.__wbg_xlsxdocument_free(t,0)}acceptProposalJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_acceptProposalJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}adoptPeerVersion(t){let n=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),r=j,o=m.xlsxdocument_adoptPeerVersion(this.__wbg_ptr,n,r);if(o[1])throw q(o[0])}applyEditsJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_applyEditsJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}applyFormatJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_applyFormatJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}applyOpsJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_applyOpsJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}applyOpsProfiledJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_applyOpsProfiledJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}applyUpdateJson(t){let n,r;try{let i=Ee(t,m.__wbindgen_malloc),l=j,a=m.xlsxdocument_applyUpdateJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}beginPeerSnapshot(t,n){let r=m.xlsxdocument_beginPeerSnapshot(this.__wbg_ptr,t,n);if(r[1])throw q(r[0])}calculationStatusJson(){let t,n;try{let s=m.xlsxdocument_calculationStatusJson(this.__wbg_ptr);var r=s[0],o=s[1];if(s[3])throw r=0,o=0,q(s[2]);return t=r,n=o,$(r,o)}finally{m.__wbindgen_free(t,n,1)}}captureFormatJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_captureFormatJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}cellJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_cellJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}cellPositionJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_cellPositionJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}cellRectJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_cellRectJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}chartAtPointJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_chartAtPointJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}chartsJson(t){let n,r;try{let i=m.xlsxdocument_chartsJson(this.__wbg_ptr,t);var o=i[0],s=i[1];if(i[3])throw o=0,s=0,q(i[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}clearUpdateObservation(){m.xlsxdocument_clearUpdateObservation(this.__wbg_ptr)}get clientId(){return m.xlsxdocument_clientId(this.__wbg_ptr)}conditionalFormatsJson(t){let n,r;try{let i=m.xlsxdocument_conditionalFormatsJson(this.__wbg_ptr,t);var o=i[0],s=i[1];if(i[3])throw o=0,s=0,q(i[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}displayListForJson(t,n){let r,o;try{let l=Q(n,m.__wbindgen_malloc,m.__wbindgen_realloc),a=j,f=m.xlsxdocument_displayListForJson(this.__wbg_ptr,t,l,a);var s=f[0],i=f[1];if(f[3])throw s=0,i=0,q(f[2]);return r=s,o=i,$(s,i)}finally{m.__wbindgen_free(r,o,1)}}displayListJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_displayListJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}displayListProfiledJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_displayListProfiledJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}documentVersion(){let t,n;try{let r=m.xlsxdocument_documentVersion(this.__wbg_ptr);return t=r[0],n=r[1],$(r[0],r[1])}finally{m.__wbindgen_free(t,n,1)}}drainUpdateEvent(){let t=m.xlsxdocument_drainUpdateEvent(this.__wbg_ptr);if(t[3])throw q(t[2]);var n=De(t[0],t[1]).slice();return m.__wbindgen_free(t[0],t[1]*1,1),n}editCellJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_editCellJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}editCellProfiledJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_editCellProfiledJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}editCellsJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_editCellsJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}editChartsJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_editChartsJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}encodeDiff(t){let n=Ee(t,m.__wbindgen_malloc),r=j,o=m.xlsxdocument_encodeDiff(this.__wbg_ptr,n,r);if(o[3])throw q(o[2]);var s=De(o[0],o[1]).slice();return m.__wbindgen_free(o[0],o[1]*1,1),s}encodeStateAsUpdate(){let t=m.xlsxdocument_encodeStateAsUpdate(this.__wbg_ptr);var n=De(t[0],t[1]).slice();return m.__wbindgen_free(t[0],t[1]*1,1),n}encodeStateVector(){let t=m.xlsxdocument_encodeStateVector(this.__wbg_ptr);var n=De(t[0],t[1]).slice();return m.__wbindgen_free(t[0],t[1]*1,1),n}endPeerSnapshot(){m.xlsxdocument_endPeerSnapshot(this.__wbg_ptr)}exportMarkdownJson(t,n){let r,o;try{let l=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),a=j,f=Q(n,m.__wbindgen_malloc,m.__wbindgen_realloc),d=j,p=m.xlsxdocument_exportMarkdownJson(this.__wbg_ptr,l,a,f,d);var s=p[0],i=p[1];if(p[3])throw s=0,i=0,q(p[2]);return r=s,o=i,$(s,i)}finally{m.__wbindgen_free(r,o,1)}}exportStructuredJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_exportStructuredJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}fillRangeJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_fillRangeJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}findTextJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_findTextJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}historyStateJson(){let t,n;try{let s=m.xlsxdocument_historyStateJson(this.__wbg_ptr);var r=s[0],o=s[1];if(s[3])throw r=0,o=0,q(s[2]);return t=r,n=o,$(r,o)}finally{m.__wbindgen_free(t,n,1)}}listDefinedNamesJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_listDefinedNamesJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}listProposalsJson(){let t,n;try{let s=m.xlsxdocument_listProposalsJson(this.__wbg_ptr);var r=s[0],o=s[1];if(s[3])throw r=0,o=0,q(s[2]);return t=r,n=o,$(r,o)}finally{m.__wbindgen_free(t,n,1)}}mediaBytes(t){let n=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),r=j,o=m.xlsxdocument_mediaBytes(this.__wbg_ptr,n,r);if(o[3])throw q(o[2]);var s=De(o[0],o[1]).slice();return m.__wbindgen_free(o[0],o[1]*1,1),s}mergedRangesJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_mergedRangesJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}moveChartJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_moveChartJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}moveRangeJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_moveRangeJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}nextPeerSnapshotChunk(){let t=m.xlsxdocument_nextPeerSnapshotChunk(this.__wbg_ptr);if(t[2])throw q(t[1]);return q(t[0])}static openCollaborative(t,n){let r=Ee(t,m.__wbindgen_malloc),o=j,s=m.xlsxdocument_openCollaborative(r,o,n);if(s[2])throw q(s[1]);return e.__wrap(s[0])}static openRecalculatingStale(t,n){let r=Ee(t,m.__wbindgen_malloc),o=j;var s=qe(n)?0:Q(n,m.__wbindgen_malloc,m.__wbindgen_realloc),i=j;let l=m.xlsxdocument_openRecalculatingStale(r,o,s,i);if(l[2])throw q(l[1]);return e.__wrap(l[0])}static openRecoveryCheckpoint(t,n){let r=Ee(t,m.__wbindgen_malloc),o=j,s=m.xlsxdocument_openRecoveryCheckpoint(r,o,n);if(s[2])throw q(s[1]);return e.__wrap(s[0])}static openWithCalculationJson(t,n){let r=Ee(t,m.__wbindgen_malloc),o=j,s=Q(n,m.__wbindgen_malloc,m.__wbindgen_realloc),i=j,l=m.xlsxdocument_openWithCalculationJson(r,o,s,i);if(l[2])throw q(l[1]);return e.__wrap(l[0])}static openWithPeerHydrationJson(t,n){let r=Ee(t,m.__wbindgen_malloc),o=j,s=Q(n,m.__wbindgen_malloc,m.__wbindgen_realloc),i=j,l=m.xlsxdocument_openWithPeerHydrationJson(r,o,s,i);if(l[2])throw q(l[1]);return e.__wrap(l[0])}static open(t){let n=Ee(t,m.__wbindgen_malloc),r=j,o=m.xlsxdocument_open(n,r);if(o[2])throw q(o[1]);return e.__wrap(o[0])}patchRangeStyleJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_patchRangeStyleJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}peerHydrationJson(){let t,n;try{let s=m.xlsxdocument_peerHydrationJson(this.__wbg_ptr);var r=s[0],o=s[1];if(s[3])throw r=0,o=0,q(s[2]);return t=r,n=o,$(r,o)}finally{m.__wbindgen_free(t,n,1)}}pngDisplayListJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_pngDisplayListJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}printDisplayListJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_printDisplayListJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}proposeJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_proposeJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}rangeCellsJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_rangeCellsJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}rangePngDisplayListJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_rangePngDisplayListJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}readCellsJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_readCellsJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}recalculateJson(){let t,n;try{let s=m.xlsxdocument_recalculateJson(this.__wbg_ptr);var r=s[0],o=s[1];if(s[3])throw r=0,o=0,q(s[2]);return t=r,n=o,$(r,o)}finally{m.__wbindgen_free(t,n,1)}}recoveryCheckpoint(t,n){let r=m.xlsxdocument_recoveryCheckpoint(this.__wbg_ptr,t,qe(n)?16777215:n?1:0);if(r[3])throw q(r[2]);var o=De(r[0],r[1]).slice();return m.__wbindgen_free(r[0],r[1]*1,1),o}redoJson(){let t,n;try{let s=m.xlsxdocument_redoJson(this.__wbg_ptr);var r=s[0],o=s[1];if(s[3])throw r=0,o=0,q(s[2]);return t=r,n=o,$(r,o)}finally{m.__wbindgen_free(t,n,1)}}rejectProposalJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_rejectProposalJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}resizeChartJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_resizeChartJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}saveBytes(){let t=m.xlsxdocument_saveBytes(this.__wbg_ptr);if(t[3])throw q(t[2]);var n=De(t[0],t[1]).slice();return m.__wbindgen_free(t[0],t[1]*1,1),n}saveWarningsJson(){let t,n;try{let s=m.xlsxdocument_saveWarningsJson(this.__wbg_ptr);var r=s[0],o=s[1];if(s[3])throw r=0,o=0,q(s[2]);return t=r,n=o,$(r,o)}finally{m.__wbindgen_free(t,n,1)}}searchTextJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_searchTextJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}selectionDataJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_selectionDataJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}selectionFormattingJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_selectionFormattingJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}setActiveSheet(t){let n=m.xlsxdocument_setActiveSheet(this.__wbg_ptr,t);if(n[1])throw q(n[0])}setCalculationContextJson(t){let n=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),r=j,o=m.xlsxdocument_setCalculationContextJson(this.__wbg_ptr,n,r);if(o[1])throw q(o[0])}setRangeNumberFormatJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_setRangeNumberFormatJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}sheetCount(){return m.xlsxdocument_sheetCount(this.__wbg_ptr)>>>0}sheetInfoForJson(t){let n,r;try{let i=m.xlsxdocument_sheetInfoForJson(this.__wbg_ptr,t);var o=i[0],s=i[1];if(i[3])throw o=0,s=0,q(i[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}sheetInfoJson(){let t,n;try{let s=m.xlsxdocument_sheetInfoJson(this.__wbg_ptr);var r=s[0],o=s[1];if(s[3])throw r=0,o=0,q(s[2]);return t=r,n=o,$(r,o)}finally{m.__wbindgen_free(t,n,1)}}startUpdateObservation(){let t=m.xlsxdocument_startUpdateObservation(this.__wbg_ptr);if(t[1])throw q(t[0])}translateFormulasJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_translateFormulasJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}undoJson(){let t,n;try{let s=m.xlsxdocument_undoJson(this.__wbg_ptr);var r=s[0],o=s[1];if(s[3])throw r=0,o=0,q(s[2]);return t=r,n=o,$(r,o)}finally{m.__wbindgen_free(t,n,1)}}validateEditsJson(t){let n,r;try{let i=Q(t,m.__wbindgen_malloc,m.__wbindgen_realloc),l=j,a=m.xlsxdocument_validateEditsJson(this.__wbg_ptr,i,l);var o=a[0],s=a[1];if(a[3])throw o=0,s=0,q(a[2]);return n=o,r=s,$(o,s)}finally{m.__wbindgen_free(n,r,1)}}static version(){let t,n;try{let r=m.xlsxdocument_version();return t=r[0],n=r[1],$(r[0],r[1])}finally{m.__wbindgen_free(t,n,1)}}visibleMergedRangesJson(t,n){let r,o;try{let l=Q(n,m.__wbindgen_malloc,m.__wbindgen_realloc),a=j,f=m.xlsxdocument_visibleMergedRangesJson(this.__wbg_ptr,t,l,a);var s=f[0],i=f[1];if(f[3])throw s=0,i=0,q(f[2]);return r=s,o=i,$(s,i)}finally{m.__wbindgen_free(r,o,1)}}};Symbol.dispose&&(Re.prototype[Symbol.dispose]=Re.prototype.free);St=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Li.unregister(this),t}free(){let t=this.__destroy_into_raw();m.__wbg_xlsxsnapshotbuilder_free(t,0)}advance(t,n){let r=m.xlsxsnapshotbuilder_advance(this.__wbg_ptr,t,n);if(r[2])throw q(r[1]);return r[0]!==0}finish(){let t=this.__destroy_into_raw(),n=m.xlsxsnapshotbuilder_finish(t);if(n[2])throw q(n[1]);return Re.__wrap(n[0])}constructor(){let t=m.xlsxsnapshotbuilder_new();return this.__wbg_ptr=t,Li.register(this,this.__wbg_ptr,this),this}push(t){let n=Ee(t,m.__wbindgen_malloc),r=j,o=m.xlsxsnapshotbuilder_push(this.__wbg_ptr,n,r);if(o[1])throw q(o[0])}};Symbol.dispose&&(St.prototype[Symbol.dispose]=St.prototype.free);Ti=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>m.__wbg_xlsxdocument_free(e,1)),Li=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>m.__wbg_xlsxsnapshotbuilder_free(e,1));Kt=null;Xn=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Xn.decode();Zd=2146435072,eo=0;Gt=new TextEncoder;"encodeInto"in Gt||(Gt.encodeInto=function(e,t){let n=Gt.encode(e);return t.set(n),{read:e.length,written:n.length}});j=0});var it,oo=U(()=>{"use strict";Zr();Oi();it="wasm"});function Qt(e){return(e instanceof Uint8Array?e:new Uint8Array(e)).slice()}function Wi(e){return{font:Qt(e.font).buffer,...e.payload===void 0?{}:{payload:Qt(e.payload).buffer}}}var Mi=U(()=>{"use strict"});function ue(e){return typeof WebAssembly<"u"&&e instanceof WebAssembly.RuntimeError||e instanceof Error&&("code"in e&&e.code===df||e.message.startsWith(ff)||e.message===uf)}function so(e){let t=e===void 0?null:pf.exec(e);return t?{bytes:Number(t[1]),budgetBytes:Number(t[2])}:null}var df,ff,uf,pf,Ve=U(()=>{"use strict";df="GenericFailure",ff="BetterOffice engine memory budget exceeded",uf="This engine object failed in an earlier call and can only be freed";pf=/BetterOffice engine memory budget exceeded \((\d+) bytes over a (\d+)-byte budget\)/});function Ni(e){if(e.length===0)return;let t=globalThis.process;if(typeof t?.emitWarning=="function")for(let{message:n}of e)t.emitWarning(n,{type:"BetterOfficeSaveWarning",code:"BETTEROFFICE_SAVE_WARNING"})}var Ii=U(()=>{"use strict"});function Jn(e,t,n={}){let r=io.get(e);if(!r)throw new Error("Workbook PNG fonts are unavailable");return r(t,n)}var io,ao=U(()=>{"use strict";io=new WeakMap});var Oe,Hn=U(()=>{"use strict";Oe=class extends Error{code;constructor(t,n){super(n),this.name="PngExportError",this.code=t}}});function lo(){return typeof document<"u"?document.fonts:globalThis.fonts}function xt(e,t){return new Oe("font-unavailable",`The font "${e}" could not load, so the ${t} was not exported with a substitute.`)}async function Bi(e){let t=new Map;for(let d of e.fonts)t.set(We(d),d);let n=lo(),r=new Map,o=new Map,s=new Map,i=[],l=()=>{for(let d of i)n?.delete(d)},a=(Ui.get(e.prefix)??0)+1;Ui.set(e.prefix,a);let f=async d=>{let p=r.get(d);if(!p){if(!n||typeof FontFace>"u")throw xt(d.family,e.subject);p=`${e.prefix}-${a}-${r.size}`;let y=await new FontFace(p,d.bytes.slice().buffer,{weight:d.face?.bold??d.bold?"700":"400",style:d.face?.italic??d.italic?"italic":"normal"}).load().catch(()=>{throw xt(d.family,e.subject)});n.add(y),i.push(y),r.set(d,p)}return p};try{for(let[d,p]of t){let y=e.choose(e.faces,p);if(!y)continue;let k=await f(y);o.set(d,{family:k,face:y});let u=[k];for(let h of e.fallbacks?.(p)??[]){let C=await f(h);u.includes(C)||u.push(C)}s.set(d,u)}if(n&&typeof n.load=="function")for(let[d,p]of t){let y=o.get(d),k=await n.load(e.canvasFont(p,y?.family??p.family)).catch(()=>{throw xt(p.family,e.subject)});if(y&&!k?.length)throw xt(p.family,e.subject)}return{family:d=>o.get(We(d))?.family,face:d=>o.get(We(d))?.face,families:d=>[...s.get(We(d))??[]],release:l}}catch(d){throw l(),d}}var Ui,We,co=U(()=>{"use strict";Hn();Ui=new Map,We=e=>JSON.stringify([e.family,e.bold,e.italic,e.id??null])});function Di(e){let t=!1,n=!1,r=!1,o=!1,s=!1,i=[];for(let a of e){let f=a.codePointAt(0);vt(hf,f)?s=!0:vt(bf,f)?o=!0:vt(yf,f)?r=!0:vt(gf,f)?n=!0:vt(wf,f)&&(t=!0);let d=mf.find(([,p])=>vt(p,f))?.[0];d&&!i.includes(d)&&i.push(d)}let l=[];return n&&l.push("cjk-jp"),r&&l.push("cjk-kr"),t&&!n&&!r&&l.push("cjk-sc"),o&&l.push("arabic"),s&&l.push("hebrew"),l.push(...i),l}var mf,hf,bf,yf,gf,wf,vt,qi=U(()=>{"use strict";mf=[["thai",[[3584,3711]]],["lao",[[3712,3839]]],["khmer",[[6016,6143],[6624,6655]]],["myanmar",[[4096,4255],[43488,43519],[43616,43647],[71376,71423]]],["devanagari",[[2304,2431],[43232,43263],[72448,72543]]],["bengali",[[2432,2559]]],["gurmukhi",[[2560,2687]]],["gujarati",[[2688,2815]]],["oriya",[[2816,2943]]],["tamil",[[2944,3071],[73664,73727]]],["telugu",[[3072,3199]]],["kannada",[[3200,3327]]],["malayalam",[[3328,3455]]],["sinhala",[[3456,3583],[70112,70143]]],["armenian",[[1328,1423],[64275,64279]]],["georgian",[[4256,4351],[7312,7359],[11520,11567]]],["ethiopic",[[4608,4991],[4992,5023],[11648,11743],[43776,43823],[124896,124927]]],["tibetan",[[3840,4095]]],["mongolian",[[6144,6319],[71264,71295]]],["syriac",[[1792,1871],[2144,2159]]],["thaana",[[1920,1983]]],["cherokee",[[5024,5119],[43888,43967]]],["tifinagh",[[11568,11647]]]],hf=[[1424,1535],[64285,64335]],bf=[[1536,1791],[1872,1919],[2160,2303],[64336,65023],[65136,65279]],yf=[[4352,4607],[12592,12687],[43360,43391],[44032,55295],[65440,65500]],gf=[[12352,12543],[12784,12799],[65382,65439]],wf=[[12288,12351],[13312,19903],[19968,40959],[63744,64255],[65072,65103],[65280,65381],[131072,262143]],vt=(e,t)=>e.some(([n,r])=>t>=n&&t<=r)});function fo(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}function uo(e,t){let n=Object.keys(e);return n.length===t.length&&t.every(r=>n.includes(r))}function zi(e){let t="";for(let n=e+1;n>0;n=Math.floor((n-1)/26))t=String.fromCharCode(65+(n-1)%26)+t;return t}function Xi(e){if(typeof e!="object"||e===null||Array.isArray(e)||!uo(e,["row","col"]))throw new TypeError(jn);let{row:t,col:n}=e;if(!fo(t)||!fo(n))throw new TypeError(jn);return{row:t,col:n}}function kf(e){if(typeof e=="string")return e;if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError(jn);let t=e.kind;if(t==="a1"&&uo(e,["kind","a1"])&&typeof e.a1=="string")return e.a1;if(t==="rowCol"&&uo(e,["kind","start","end"])){let n=Xi(e.start),r=Xi(e.end);if(n.row>r.row||n.col>r.col)throw new RangeError("range start must be above and left of its end");return`${zi(n.col)}${n.row+1}:${zi(r.col)}${r.row+1}`}throw new TypeError(jn)}function Ji(e,t){if(fo(e)){if(e>=t.length)throw new RangeError(`sheet index ${e} out of range for ${t.length} sheet(s)`);return e}if(typeof e=="string"){let n=t.indexOf(e);if(n<0)throw new RangeError(`no sheet named ${JSON.stringify(e)}`);return n}throw new TypeError("sheet must be a name (string) or an index (number)")}function mo(e,t,n){if(typeof e!="object"||e===null)throw new TypeError("target must be { sheet, viewport } or { sheet, range }");let r=t.scale??1;if(typeof r!="number"||!Number.isFinite(r)||r<=0)throw new RangeError(`scale must be a positive number, got ${String(r)}`);for(let s of["maxWidth","maxHeight"]){let i=t[s];if(i!==void 0&&(!Number.isInteger(i)||i<=0))throw new RangeError(`${s} must be a positive integer`)}let{sheet:o}=e;if("viewport"in e&&!("range"in e)){let s=e.viewport;if(typeof s!="object"||s===null||!["x","y","width","height"].every(i=>Number.isFinite(s[i])))throw new TypeError("viewport must be { x, y, width, height } in finite numbers");return{sheet:Ji(o,n),viewport:{x:s.x,y:s.y,width:s.width,height:s.height}}}if("range"in e&&!("viewport"in e)){let s=e.range;return{sheet:Ji(o,n),range:s==="used"?"used":kf(s)}}throw new TypeError("target must be { sheet, viewport } or { sheet, range }")}function xf(e){return po[0]=e,Sf[0]-=1,po[0]}function Hi(e,t,n){if(t===void 0)return e;let r=Math.fround(n),o=Math.fround(Math.fround(t)/r);for(;o>0&&Math.ceil(Math.fround(o*r))>t;)o=xf(o);return Math.min(Math.fround(e),o)}function vf(e,t){let n=t.scale??1;return{...e,width:Hi(e.width,t.maxWidth,n),height:Hi(e.height,t.maxHeight,n)}}function Cf(e,t){return JSON.stringify({range:e==="used"?void 0:e,scale:t.scale??1,maxWidth:t.maxWidth,maxHeight:t.maxHeight})}function Vn(e,t,n){let r=n.scale??1;if("viewport"in t){let s=vf(t.viewport,n);return{list:JSON.parse(e.onSheet(t.sheet,()=>e.doc.pngDisplayListJson(JSON.stringify(s)))),dpr:r,width:Math.max(1,Math.ceil(Math.fround(s.width*r))),height:Math.max(1,Math.ceil(Math.fround(s.height*r)))}}let o=JSON.parse(e.onSheet(t.sheet,()=>e.doc.rangePngDisplayListJson(Cf(t.range,n))));return{list:o,dpr:1,width:Math.max(1,Math.ceil(o.width)),height:Math.max(1,Math.ceil(o.height))}}var jn,$n,ho,po,Sf,Kn=U(()=>{"use strict";jn="range must be an A1 string or a range address";$n=16384,ho=16777216,po=new Float32Array(1),Sf=new Uint32Array(po.buffer)});function Ct(e){let t=e.italic?"italic ":"",n=e.bold?"bold ":"",r=e.cssFontFamily??(e.fontFamily?e.chart?e.fontFamily:`"${e.fontFamily.replace(/"/g,'\\"')}", sans-serif`:"sans-serif");return`${t}${n}${at(e)}px ${r}`}function at(e){return e.fontSize*_f}var _f,bo=U(()=>{"use strict";_f=1.3333333333333333});var ji,$i=U(()=>{"use strict";ji={gray125:[17,0,68,0,17,0,68,0],gray0625:[1,0,16,0,1,0,16,0],mediumGray:[85,170,85,170,85,170,85,170],darkGray:[119,221,119,221,119,221,119,221],lightGray:[17,68,17,68,17,68,17,68],darkHorizontal:[255,255,0,0,255,255,0,0],darkVertical:[51,51,51,51,51,51,51,51],darkDown:[51,102,204,153,51,102,204,153],darkUp:[51,153,204,102,51,153,204,102],darkGrid:[255,255,51,51,255,255,51,51],darkTrellis:[51,255,204,255,51,255,204,255],lightHorizontal:[255,0,0,0,255,0,0,0],lightVertical:[17,17,17,17,17,17,17,17],lightDown:[17,34,68,136,17,34,68,136],lightUp:[17,136,68,34,17,136,68,34],lightGrid:[255,17,17,17,255,17,17,17],lightTrellis:[17,170,68,170,17,170,68,170]}});function go(e,t,n,r){let o=t.text,s=t.align??"left",i=n.parts;if(i.length===0&&!n.overflow){e.textAlign=s,r(e,t,o,n.left+yo(s,n.width,0),s);return}e.textAlign="left";let l=0,a=0,f=!1;for(let y=0;y<i.length;y++){let k=i[y],u=Vi(o,k.offset);a+=Ki(e,o,l,u),k.kind==="padding"?(a+=e.measureText(k.character).width,l=u+1):(f=!0,l=u)}if(a+=Ki(e,o,l,o.length),n.overflow&&a>n.width){let k=(n.general===void 0?void 0:Rf(n.general,n.width,e))??Pf(n.width,e);r(e,t,k,n.left+yo(s,n.width,e.measureText(k).width),"left");return}let d=f?Math.max(0,n.width-a):0,p=n.left+yo(s,n.width,a+d);l=0;for(let y=0;y<i.length;y++){let k=i[y],u=Vi(o,k.offset);if(u>l){let h=o.slice(l,u);r(e,t,h,p,"left"),p+=e.measureText(h).width}if(k.kind==="padding")p+=e.measureText(k.character).width,l=u+1;else{let h=e.measureText(k.character).width;h>0&&d>=h&&r(e,t,k.character.repeat(Math.floor(d/h)),p,"left"),p+=d,l=u}}l<o.length&&r(e,t,l===0?o:o.slice(l),p,"left")}function Vi(e,t){let n=0;for(let r=0;r<t&&n<e.length;){let o=e.codePointAt(n);r+=o<128?1:o<2048?2:o<65536?3:4,n+=o>65535?2:1}return n}function Ki(e,t,n,r){return r<=n?0:e.measureText(n===0&&r===t.length?t:t.slice(n,r)).width}function yo(e,t,n){return e==="right"?t-n:e==="center"?(t-n)/2:0}function Pf(e,t){let n=t.measureText("#").width;return n>0&&e>0?"#".repeat(Math.max(1,Math.floor(e/n))):""}function Rf(e,t,n){if(!Number.isFinite(e)||e===0)return;let r=Math.floor(Math.log10(Math.abs(e)));if(r>=-4&&r<11)for(let o=Math.min(15,Math.max(0,10-r));o>=0;o--){let s=10**o,i=Math.sign(e)*Math.round(Math.abs(e)*s)/s,l=Gi(i.toFixed(o));if(Number(l)!==0&&n.measureText(l).width<=t)return l}for(let o=5;o>=0;o--){let s=Ff(e,o);if(n.measureText(s).width<=t)return s}}function Ff(e,t){let[n,r]=Math.abs(e).toExponential(14).split("e"),o=n.replace(".",""),s=Number(r),i=o.slice(0,t+1);if(o.charCodeAt(t+1)>=53){let a=i.search(/[0-8]9*$/);a<0?(i=`1${"0".repeat(t)}`,s++):i=`${i.slice(0,a)}${Number(i[a])+1}${"0".repeat(i.length-a-1)}`}let l=i.length>1?Gi(`${i[0]}.${i.slice(1)}`):i;return`${e<0?"-":""}${l}E${s<0?"-":"+"}${Math.abs(s).toString().padStart(2,"0")}`}function Gi(e){return e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e}var Qi=U(()=>{"use strict"});function ea(e){if(Yt===void 0){let r=Intl.Segmenter;try{Yt=typeof r=="function"?new r(void 0,{granularity:"grapheme"}):null}catch{Yt=null}}if(Yt)return[...Yt.segment(e)].map(r=>r.index+r.segment.length);let t=[],n=0;for(let r of e)t.push(n+=r.length);return t}function ta(e,t,n){let r=Number.isNaN(t)?Number.POSITIVE_INFINITY:t,o=[],i=(e.endsWith(`
2
+ `)?e.slice(0,e.endsWith(`\r
3
+ `)?-2:-1):e).split(`
4
+ `);return i.forEach((l,a)=>{Af(l.endsWith("\r")?l.slice(0,-1):l,r,n,o),a<i.length-1&&(o[o.length-1]=o[o.length-1].replace(/ +$/,""))}),o}function Af(e,t,n,r){if(n(e)<=t){r.push(e);return}let o=0,s=null;for(let[i,l]of na(e)){if(s!==null){if(n(e.slice(o,l))<=t){s=l;continue}r.push(e.slice(o,s)),o=i}if(s=l,n(e.slice(o,l))<=t)continue;let a=o,f=ea(e.slice(a,l)).map(p=>a+p),d=0;for(let p=Yi(e,o,f,d,t,n);p!==null;)r.push(e.slice(o,f[p])),o=f[p],d=p+1,p=Yi(e,o,f,d,t,n)}r.push(e.slice(o))}function Yi(e,t,n,r,o,s){let i=r,l;for(let a=1;;a*=2){let f=Math.min(i+a,n.length-1);if(f===i)return null;if(s(e.slice(t,n[f]))>o){l=f;break}i=f}for(;l-i>1;){let a=i+Math.floor((l-i)/2);s(e.slice(t,n[a]))>o?l=a:i=a}return i}function na(e){let t=[],n=0;for(let r of e.split(" "))r.length>0&&t.push([n,n+r.length]),n+=r.length+1;return t}function ra(e,t,n){let r=Number.isNaN(t)?Number.POSITIVE_INFINITY:t,o=[],i=(e.endsWith(`
5
+ `)?e.slice(0,e.endsWith(`\r
6
+ `)?-2:-1):e).split(`
7
+ `),l=0;return i.forEach((a,f)=>{let d=l;l+=a.length+1,Ef(e,d,d+(a.endsWith("\r")?a.length-1:a.length),r,n,o);let p=o[o.length-1];f<i.length-1&&(p[1]=p[0]+e.slice(p[0],p[1]).replace(/ +$/,"").length)}),o}function Ef(e,t,n,r,o,s){if(o(t,n)<=r){s.push([t,n]);return}let i=t,l=null,a=na(e.slice(t,n)).map(([f,d])=>[t+f,t+d]);for(let[f,d]of a){if(l!==null){if(o(i,d)<=r){l=d;continue}s.push([i,l]),i=f}if(l=d,o(i,d)<=r)continue;let p=i,y=ea(e.slice(p,d)).map(u=>p+u),k=0;for(let u=Zi(i,y,k,r,o);u!==null;)s.push([i,y[u]]),i=y[u],k=u+1,u=Zi(i,y,k,r,o)}s.push([i,n])}function Zi(e,t,n,r,o){let s=n,i;for(let l=1;;l*=2){let a=Math.min(s+l,t.length-1);if(a===s)return null;if(o(e,t[a])>r){i=a;break}s=a}for(;i-s>1;){let l=s+Math.floor((i-s)/2);o(e,t[l])>r?i=l:s=l}return s}function Gn(e,t,n,r){let o=Math.max(n-1,0),s=r.valign==="top"?t:r.valign==="center"?t-o/2:t-o;return e+r.lineHeight*s}var Yt,wo=U(()=>{"use strict"});function Lf(e){return Tf.test(e)}function oa(e,t){let n=Math.max(0,Math.min(e.length,Math.floor(t))),r=e.charCodeAt(n),o=e.charCodeAt(n-1);return n>0&&n<e.length&&r>=56320&&r<=57343&&o>=55296&&o<=56319?n-1:n}function Of(e,t){return e&&t!==void 0&&t!=="single"?t:void 0}function sa(e,t){let n=t?.underline??e.underline===!0,r=t?.cssFontFamily??(t?.fontFamily===void 0?e.cssFontFamily:void 0);return{...e,runs:void 0,fontFamily:t?.fontFamily??e.fontFamily,cssFontFamily:r,fontSize:t?.fontSize??e.fontSize,bold:t?.bold??e.bold===!0,italic:t?.italic??e.italic===!0,underline:n,underlineStyle:Of(n,t?.underlineStyle??e.underlineStyle),strike:t?.strike??e.strike===!0,color:t?.color??e.color}}function ia(e,t){return e.cmd.fontFamily===t.cmd.fontFamily&&e.cmd.cssFontFamily===t.cmd.cssFontFamily&&e.cmd.fontSize===t.cmd.fontSize&&e.cmd.bold===t.cmd.bold&&e.cmd.italic===t.cmd.italic&&e.cmd.underline===t.cmd.underline&&e.cmd.underlineStyle===t.cmd.underlineStyle&&e.cmd.strike===t.cmd.strike&&e.cmd.color===t.cmd.color&&e.baseline===t.baseline}function Zt(e){let t=e.runs;if(!t?.length||e.stacked||e.rotationDeg!==void 0&&e.rotationDeg!==null||e.numberFormat||e.highlight||e.dashedUnderline||Lf(e.text))return;let n={text:"",start:0,end:0,cmd:sa(e)},r=[],o=(i,l,a)=>{if(l<=i)return;let f=r[r.length-1];f&&ia(f,a)?(f.text+=e.text.slice(i,l),f.end=l):r.push({...a,text:e.text.slice(i,l),start:i,end:l})},s=0;for(let i of t){let l=Math.max(oa(e.text,i.start),s),a=oa(e.text,i.end);a<=l||(o(s,l,n),o(l,a,{text:"",start:0,end:0,cmd:sa(e,i),baseline:i.baseline}),s=a)}if(o(s,e.text.length,n),!(r.length===0||r.length===1&&ia(r[0],n)))return r}function aa(e,t,n,r){let o=(i,l)=>t.flatMap(a=>{let f=Math.max(a.start,i),d=Math.min(a.end,l);return f<d?[{...a,text:e.slice(f,d),start:f,end:d}]:[]});return ra(e,n,(i,l)=>o(i,l).reduce((a,f)=>a+r(f,f.text),0)).map(([i,l])=>o(i,l))}var Tf,ko=U(()=>{"use strict";wo();Tf=/[֐-ࣿיִ-﷿ﹰ-ﻼ‏‫‮⁧\u{10800}-\u{10fff}\u{1e800}-\u{1efff}]/u});function ua(e,t,n,r={x:0,y:0},o={}){e.save(),e.setTransform(n,0,0,n,r.x,r.y),e.beginPath(),e.rect(0,0,t.width,t.height),e.clip(),e.clearRect(0,0,t.width,t.height);let s=Math.max(0,-r.x/n),i=Math.max(0,-r.y/n),l=Math.min(t.width,((e.canvas?.width??1/0)-r.x)/n),a=Math.min(t.height,((e.canvas?.height??1/0)-r.y)/n),f={x:s,y:i,w:l-s,h:a-i};for(let d of t.commands)Nf(e,d,n,r,o,f);e.restore()}function Nf(e,t,n,r,o,s){switch(t.op){case"image":en(e,t.clip,()=>Uf(e,t,o));return;case"fillRect":en(e,t.clip,()=>{e.fillStyle=t.color,e.fillRect(t.x,t.y,t.w,t.h)});return;case"patternFill":en(e,t.clip,()=>If(e,t,n,r));return;case"line":en(e,t.clip,()=>Df(e,t,n,r));return;case"path":en(e,t.clip,()=>Bf(e,t));return;case"text":qf(e,t,s);return}}function If(e,t,n,r){let o=ca.get(e);o||(o=new Map,ca.set(e,o));let s=`${t.pattern}/${t.fg}/${t.bg}/${n}`,i=o.get(s);if(!i){let f=typeof OffscreenCanvas=="function"?new OffscreenCanvas(8,8):typeof document<"u"?document.createElement("canvas"):new e.canvas.constructor(8,8);f.width=8,f.height=8;let d=f.getContext("2d"),p=d.createImageData(8,8),y=Number.parseInt(t.fg.slice(1),16),k=Number.parseInt(t.bg.slice(1),16),u=ji[t.pattern];for(let h=0;h<8;h+=1)for(let C=0;C<8;C+=1){let v=u[h]&1<<C?y:k,P=(h*8+C)*4;p.data[P]=v>>16&255,p.data[P+1]=v>>8&255,p.data[P+2]=v&255,p.data[P+3]=255}if(d.putImageData(p,0,0),i=e.createPattern(f,"repeat")??void 0,!i)return;o.size>=256&&o.clear(),o.set(s,i)}i.setTransform({a:1/n,b:0,c:0,d:1/n,e:(Math.round(t.originX*n+r.x)-r.x)/n,f:(Math.round(t.originY*n+r.y)-r.y)/n}),e.save(),e.imageSmoothingEnabled=!1,e.fillStyle=i;let l=(Math.round(t.x*n+r.x)-r.x)/n,a=(Math.round(t.y*n+r.y)-r.y)/n;e.fillRect(l,a,(Math.round((t.x+t.w)*n+r.x)-r.x)/n-l,(Math.round((t.y+t.h)*n+r.y)-r.y)/n-a),e.restore()}function Uf(e,t,n){let r=n.resolveImage?.(t.assetId);if(!r)return;let[o,s]="naturalWidth"in r?[r.naturalWidth,r.naturalHeight]:[r.width,r.height],{left:i=0,top:l=0,right:a=0,bottom:f=0}=t.crop??{},d=o*(1-i-a),p=s*(1-l-f);d>0&&p>0&&t.w>0&&t.h>0&&e.drawImage(r,o*i,s*l,d,p,t.x,t.y,t.w,t.h)}function en(e,t,n){if(!t){n();return}e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),n(),e.restore()}function Bf(e,t){e.beginPath();for(let n of t.commands)switch(n.type){case"move":e.moveTo(n.x,n.y);break;case"line":e.lineTo(n.x,n.y);break;case"quad":e.quadraticCurveTo(n.cpx,n.cpy,n.x,n.y);break;case"cubic":e.bezierCurveTo(n.cp1x,n.cp1y,n.cp2x,n.cp2y,n.x,n.y);break;case"close":e.closePath();break}e.fillStyle=t.fill,e.fill(),t.stroke&&(e.strokeStyle=t.stroke.color,e.lineWidth=t.stroke.width,e.setLineDash([]),e.stroke())}function Df(e,t,n,r){e.strokeStyle=t.color,e.save(),e.lineCap="butt";let{x1:o,y1:s,x2:i,y2:l}=t,a=Math.max(1,Math.round(t.width*n)),f=t.style==="double"&&t.rail===void 0;if(t.style&&!f&&(s===l?(s=l=(Math.floor(s*n+r.y)+a%2/2-r.y)/n,o=(Math.round(o*n+r.x)-r.x)/n,i=(Math.round(i*n+r.x)-r.x)/n):o===i&&(o=i=(Math.floor(o*n+r.x)+a%2/2-r.x)/n,s=(Math.round(s*n+r.y)-r.y)/n,l=(Math.round(l*n+r.y)-r.y)/n)),t.style==="double"){let p=t.rail===void 0?Math.max(t.width*.8,.8):(t.width-t.rail)/2,y=Math.abs(s-l)<=Math.abs(o-i),[k,u]=y?[0,p]:[p,0];e.lineWidth=t.rail??Math.max(t.width*.6,.5),e.setLineDash([]),tn(e,o-k,s-u,i-k,l-u),tn(e,o+k,s+u,i+k,l+u),e.restore();return}e.lineWidth=t.style?a/n:t.width;let d=t.style?.startsWith("medium")?t.width/2:t.width;e.setLineDash(t.style?Mf[t.style].map(p=>p*d):[]),tn(e,o,s,i,l),e.restore()}function tn(e,t,n,r,o){e.beginPath(),e.moveTo(t,n),e.lineTo(r,o),e.stroke()}function qf(e,t,n){e.save(),t.clip&&(e.beginPath(),e.rect(t.clip.x,t.clip.y,t.clip.w,t.clip.h),e.clip()),e.fillStyle=t.color;let r=Ct(t);e.font=r,e.textRendering="geometricPrecision",e.textBaseline="alphabetic";let o=t.runs?.length?Zt(t):void 0;if(o&&t.wrap)zf(e,t,t.wrap,o,da(r),n);else if(o)Co(e,t,o,t.y,da(r));else if(t.stacked)Vf(e,t);else if(t.rotationDeg!==void 0&&t.rotationDeg!==null)$f(e,t,t.rotationDeg);else if(t.numberFormat)go(e,t,t.numberFormat,So);else if(t.wrap){let s=t.wrap,i=t.align??"left";e.textAlign=la[i];let l=ta(t.text,s.width,f=>e.measureText(f).width),a=Math.min(l.length,s.maxLines??l.length);l.slice(0,a).forEach((f,d)=>{So(e,{...t,y:Gn(t.y,d,a,s)},f,t.x,i)})}else{let s=t.align??"left";e.textAlign=la[s],So(e,t,t.text,t.x,s)}e.restore()}function da(e){return{font:e,fonts:new Map,widths:new Map}}function pa(e,t){let n=e.fonts.get(t.cmd);return n===void 0&&(n=Ct(t.cmd),e.fonts.set(t.cmd,n)),n}function ma(e,t,n){t.font!==n&&(e.font=n,t.font=n)}function ha(e,t,n,r){let o=pa(t,n),s=t.widths.get(o);s===void 0&&(s=new Map,t.widths.set(o,s));let i=s.get(r);return i===void 0&&(ma(e,t,o),i=e.measureText(r).width,s.set(r,i)),i}function Co(e,t,n,r,o){let s=n.map(f=>ha(e,o,f,f.text)),i=s.reduce((f,d)=>f+d,0),l=t.align??"left",a=l==="right"?t.x-i:l==="center"?t.x-i/2:t.x;e.textAlign="left",n.forEach((f,d)=>{ma(e,o,pa(o,f)),Jf(e,f.cmd,f.text,a,r,s[d]),a+=s[d]})}function zf(e,t,n,r,o,s){let i=aa(t.text,r,n.width,(v,P)=>ha(e,o,v,P)),l=i.slice(0,Math.max(0,n.maxLines??i.length)),a=r.some(v=>v.cmd.fontSize!==r[0].cmd.fontSize)?Xf(t.y,t.fontSize,n,l):void 0;if(!a){l.forEach((v,P)=>{Co(e,t,v,Gn(t.y,P,l.length,n),o)});return}let f=t.clip??s,d=Math.max(f.y,s.y),p=Math.min(f.y+f.h,s.y+s.h),y=Math.max(f.x,s.x),k=Math.min(f.x+f.w,s.x+s.w);if(d>=p||y>=k)return;let{blockTop:u,metrics:h}=a,C=h.every(({size:v})=>v===t.fontSize);for(let[v,P]of l.entries()){let{top:L,size:B}=h[v],D=B*xo,V=C?Gn(t.y,v,l.length,n):u+(L+D);if((C?V-D:u+L)>=p)break;V+B*vo>d&&Co(e,t,P,V,o)}}function Xf(e,t,n,r){if(!Number.isFinite(t)||t<=0||!Number.isFinite(n.lineHeight)||n.lineHeight<=0)return;let o=[],s=0;for(let y of r){let k=y.reduce((h,C)=>Math.max(h,C.cmd.fontSize),y[0]?.cmd.fontSize??t),u=n.lineHeight*(k/t);if(!Number.isFinite(u)||u<=0)return;o.push({top:s,size:k}),s+=u}let i=o[o.length-1];if(!i)return;let a=i.top+i.size*xo+i.size*vo;if(!Number.isFinite(s)||!Number.isFinite(a))return;let f=e-t*xo,d=e+t*vo-a,p=n.valign==="top"?f:n.valign==="center"?f/2+d/2:d;return Number.isFinite(p)?{blockTop:p,metrics:o}:void 0}function Jf(e,t,n,r,o,s){if(e.fillStyle=t.color,e.fillText(n,r,o),!t.underline&&!t.strike)return;let i=at(t),l=Math.max(i*.05,.5);e.fillStyle=t.color,t.underline&&Qn(e,t,r,o+i*.1,s,l),t.strike&&e.fillRect(r,o-i*.26,s,l)}function Hf(e,t,n){let r=n*fa,o=Math.abs(t)*Math.PI/180,s=Math.abs(Math.cos(o)),i=Math.abs(Math.sin(o)),l=Number.POSITIVE_INFINITY;return s>1e-6&&(l=Math.min(l,(e.w-r*i)/s)),i>1e-6&&(l=Math.min(l,(e.h-r*s)/i)),Number.isFinite(l)||(l=Math.max(e.w,e.h)),Math.max(0,l)}function jf(e){let t=Intl.Segmenter;if(typeof t=="function")try{return[...new t(void 0,{granularity:"grapheme"}).segment(e)].map(n=>n.segment)}catch{return[...e]}return[...e]}function $f(e,t,n){let r=t.rotationBox??t.clip??{x:t.x,y:t.y,w:0,h:0},o=at(t),s=[{text:t.text,offset:0}],i=e.measureText(t.text).width;if(t.numberFormat){let J=Hf(r,n,o),O=[];if(go(e,{...t,numberFormat:void 0},{...t.numberFormat,left:0,width:J},(F,x,g,c,b)=>{let S=e.measureText(g).width,W=b==="right"?c-S:b==="center"?c-S/2:c;O.push({text:g,x:W})}),O.length>0){let F=Math.min(...O.map(g=>g.x)),x=Math.max(...O.map(g=>g.x+e.measureText(g.text).width));s=O.map(g=>({text:g.text,offset:g.x-F})),i=Math.max(0,x-F)}}let l=e.measureText(t.text),a=(n===90?l.fontBoundingBoxAscent:void 0)??(l.actualBoundingBoxAscent||o*.8),f=(n===90?l.fontBoundingBoxDescent:void 0)??(l.actualBoundingBoxDescent||o*.2),d=a+f,p=-n*Math.PI/180,y=Math.cos(p),k=Math.sin(p),u=Math.abs(i*y)+Math.abs(d*k),h=Math.abs(i*k)+Math.abs(d*y),C=t.align??"left",v=C==="center"?r.x+(r.w-u)/2:C==="right"?r.x+r.w-u:r.x,P=t.rotationValign??"bottom",L=P==="top"?r.y:P==="center"?r.y+(r.h-h)/2:r.y+r.h-h,B=v+u/2,D=L+h/2;e.save(),e.translate(B,D),e.rotate(p),t.highlight&&(e.fillStyle=t.highlight,e.fillRect(-i/2-2,-d/2-1,i+4,d+2),e.fillStyle=t.color),e.textBaseline="alphabetic";let V=(a-f)/2;if(t.numberFormat){e.textAlign="left";for(let J of s)e.fillText(J.text,-i/2+J.offset,V)}else e.textAlign="center",e.fillText(t.text,0,V);let R=Math.max(o*.05,.5);e.fillStyle=t.color,t.underline?Qn(e,t,-i/2,V+o*.1,i,R):t.dashedUnderline&&e.fillRect(-i/2,V+o*.1,i,R),t.strike&&e.fillRect(-i/2,V-o*.26,i,R),e.restore()}function Vf(e,t){let n=t.rotationBox??t.clip??{x:t.x,y:t.y,w:0,h:0},r=at(t),o=r*fa,s=r*Wf,i=jf(t.text),l=i.length*o,a=t.rotationValign??"bottom",f=a==="top"?n.y:a==="center"?n.y+(n.h-l)/2:n.y+n.h-l,d=t.align??"left",p=t.clip??n,y=Math.max(0,Math.floor((p.y-f)/o)),k=Math.min(i.length-1,Math.ceil((p.y+p.h-f)/o)-1);e.textAlign="left",e.textBaseline="alphabetic";for(let u=y;u<=k;u+=1){let h=i[u],C=e.measureText(h).width,v=d==="center"?n.x+(n.w-C)/2:d==="right"?n.x+n.w-C:n.x;if(v+C<=p.x||v>=p.x+p.w)continue;let P=f+u*o+s;t.highlight&&(e.fillStyle=t.highlight,e.fillRect(v-2,P-s-1,C+4,o+2),e.fillStyle=t.color),e.fillText(h,v,P);let L=Math.max(r*.05,.5);e.fillStyle=t.color,t.underline&&Qn(e,t,v,P+r*.1,C,L),t.strike&&e.fillRect(v,P-r*.26,C,L),t.dashedUnderline&&(e.save(),e.strokeStyle=t.color,e.lineWidth=L,e.setLineDash([3,2]),tn(e,v,P+r*.1,v+C,P+r*.1),e.restore())}}function So(e,t,n,r,o){t.highlight&&Gf(e,t,n,r,o),e.fillStyle=t.color,e.fillText(n,r,t.y),(t.underline||t.strike||t.dashedUnderline)&&Kf(e,t,n,r,o)}function Kf(e,t,n,r,o){let s=e.measureText(n).width,i=o==="right"?r-s:o==="center"?r-s/2:r,l=at(t),a=Math.max(l*.05,.5);e.fillStyle=t.color,t.underline&&Qn(e,t,i,t.y+l*.1,s,a),t.strike&&e.fillRect(i,t.y-l*.26,s,a),t.dashedUnderline&&(e.save(),e.strokeStyle=t.color,e.lineWidth=a,e.setLineDash([3,2]),tn(e,i,t.y+l*.1,i+s,t.y+l*.1),e.restore())}function Qn(e,t,n,r,o,s){e.fillRect(n,r,o,s),(t.underlineStyle==="double"||t.underlineStyle==="doubleAccounting")&&e.fillRect(n,r+s+Math.max(s,1),o,s)}function Gf(e,t,n,r,o){let s=e.measureText(n),i=s.width,l=o==="right"?r-i:o==="center"?r-i/2:r,a=at(t),f=s.actualBoundingBoxAscent||a*.8,d=s.actualBoundingBoxDescent||a*.2;e.fillStyle=t.highlight,e.fillRect(l-2,t.y-f-1,i+4,f+d+2)}var fa,Wf,xo,vo,la,Mf,ca,ba=U(()=>{"use strict";bo();$i();Qi();ko();wo();fa=1.2,Wf=.8,xo=96/72*.7,vo=96/72*.2,la={left:"left",center:"center",right:"right"},Mf={dashed:[4,2],dotted:[1,2],mediumDashed:[8,4],dashDot:[4,2,1,2],mediumDashDot:[8,4,2,4],dashDotDot:[4,2,1,2,1,2],mediumDashDotDot:[8,4,2,4,2,4],slantDashDot:[4,2,1,2]},ca=new WeakMap});function Zn(){if(typeof OffscreenCanvas=="function")return!0;if(typeof document>"u")return!1;try{return document.createElement("canvas").getContext("2d")!==null}catch{return!1}}async function _o(e,t){let{width:n,height:r,dpr:o}=t;if(n>$n||r>$n||n*r>ho)throw new Oe("canvas-too-large",`A ${n}x${r}px PNG is over the ${$n}px side or ${ho} pixel limit; lower the scale or set maxWidth and maxHeight.`);t.signal?.throwIfAborted();let s=await Bi({prefix:"bo-xlsx-png",fonts:Po(e),faces:t.fonts??[],choose:eu,fallbacks:t.fallbacks,subject:"sheet",canvasFont:(i,l)=>Ct({op:"text",x:0,y:0,text:"",color:"#000000",fontSize:12,fontFamily:l,bold:i.bold,italic:i.italic})});try{await ru(e),t.signal?.throwIfAborted();let i=Qf(n,r),l=i.getContext("2d");if(!l)throw _t("PNG export needs a 2d canvas context.");return ua(l,tu(e,s.families),o),l.save(),l.setTransform(1,0,0,1,0,0),l.globalCompositeOperation="destination-over",l.fillStyle="#ffffff",l.fillRect(0,0,n,r),l.restore(),t.signal?.throwIfAborted(),new Uint8Array(await(await Yf(i)).arrayBuffer())}finally{s.release()}}function _t(e="PNG export needs a canvas, and this environment has none."){return new Oe("canvas-unavailable",`${e} Use @betteroffice/xlsx-native.`)}function Qf(e,t){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(e,t);if(typeof document>"u")throw _t();let n=document.createElement("canvas");return n.width=e,n.height=t,n}function Yf(e){return"convertToBlob"in e?e.convertToBlob({type:"image/png"}):new Promise((t,n)=>{e.toBlob(r=>{r?t(r):n(new Oe("canvas-too-large","The canvas produced no PNG."))},"image/png")})}function ga(e){if(!e.fontFamily)return;if(!e.chart)return e.fontFamily;let t=e.fontFamily.split(",")[0]?.trim().replace(/^(['"])(.*)\1$/,"$2");return t&&!Zf.has(t.toLowerCase())?t:void 0}function Yn(e){let t=ga(e);return t===void 0?void 0:{family:t,bold:e.bold===!0,italic:e.italic===!0}}function wa(e){return[{text:e.text,font:Yn(e)},...(Zt(e)??[]).map(t=>({text:t.text,font:Yn(t.cmd)}))]}function ka(e){let t=new Map;for(let n of e.commands)if(n.op==="text")for(let{text:r,font:o}of wa(n)){if(!o)continue;let s=Di(r),i=JSON.stringify([We(o),s]);t.has(i)||t.set(i,{font:o,scripts:s})}return[...t.values()]}function Po(e){let t=new Map;for(let n of e.commands)if(n.op==="text")for(let{font:r}of wa(n))r&&t.set(JSON.stringify(r),r);return[...t.values()]}function eu(e,t){for(let[n,r]of[[t.bold,t.italic],[t.bold,!1],[!1,t.italic],[!1,!1]]){let o;for(let s of e)ya(s.family)===ya(t.family)&&(s.bold??!1)===n&&(s.italic??!1)===r&&(o=s);if(o)return o}}function tu(e,t){let n=!1,r=e.commands.map(o=>{let s=o.op==="text"?Yn(o):void 0,i=s?t(s):[],l=o.op==="text"?nu(o,t,i.length>0):void 0;if(!i.length&&!l||o.op!=="text")return o;if(n=!0,!i.length)return{...o,runs:l};let a=i.map(f=>`"${f}"`).join(", ");return{...o,fontFamily:o.chart?`"${i[0]}", ${o.fontFamily}`:i[0],cssFontFamily:`${a}, ${o.chart?o.fontFamily:"sans-serif"}`,...l?{runs:l}:{}}});return n?{...e,commands:r}:e}function nu(e,t,n){let r=ga(e);if(!(!e.runs||!Zt(e)))return e.runs.map(o=>{let s=o.fontFamily??r;if(s===void 0)return o;let i=t({family:s,bold:o.bold??e.bold===!0,italic:o.italic??e.italic===!0});return i.length?{...o,fontFamily:i[0],cssFontFamily:`${i.map(l=>`"${l}"`).join(", ")}, sans-serif`}:n?{...o,fontFamily:s}:o})}async function ru(e){let t=lo();if(!t||typeof t.load!="function")return;let n=new Map;for(let r of e.commands)r.op==="text"&&!Yn(r)&&n.set(Ct(r),r.fontFamily??"sans-serif");for(let[r,o]of n)await t.load(r).catch(()=>{throw xt(o,"sheet")})}var Zf,ya,er=U(()=>{"use strict";Hn();co();qi();Kn();ba();bo();ko();Zf=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-sans-serif","ui-serif","ui-monospace"]);ya=e=>e.trim().toLowerCase()});var Ca={};Mt(Ca,{defaultSheetFaces:()=>au});async function xa(e,t,n){let r=await t(e.resolveBundledFamilyFace(n.family,n.bold,n.italic));if(r)return r;let o=await t(e.resolveGlyphFallbackFace(n.family,n.bold,n.italic,"word"));return o||(await t(e.resolveLastResortChoice(n.family,n.bold,n.italic,"word").face)??e.BASE_LATIN_FONTS.find(i=>i.weight===700===n.bold&&i.style==="italic"===n.italic))}async function su(e,t,{font:n,scripts:r}){let o=[],s=a=>{a&&!o.some(f=>va(f,a))&&o.push(a)},i=await t(e.resolveBundledFamilyFace(n.family,n.bold,n.italic));s(i);for(let a of r)s(await t(e.resolveScriptFallbackFace(a,n.bold,n.italic,n.family)));s(await t(e.resolveGlyphFallbackFace(n.family,n.bold,n.italic,"word")));let l=e.resolveLastResortChoice(n.family,n.bold,n.italic,"word");return(!l.onlyIfPrimaryFails||!i)&&s(await t(l.face)),o}async function iu(e,t,n){let r=new Set(n.filter(s=>s.scripts.length).map(s=>We(s.font))),o=new Map;for(let s of n){let i=We(s.font),l=o.get(i)??{font:s.font,faces:[]};if(o.set(i,l),!r.has(i)){l.faces.length||l.faces.push(await xa(e,t,s.font));continue}for(let a of await su(e,t,s))l.faces.some(f=>va(f,a))||l.faces.push(a)}for(let s of o.values())s.faces.length||s.faces.push(await xa(e,t,s.font));return o}async function au(e,t,n=new Set){t?.throwIfAborted();let r=ou().then(async i=>{let l=new Set,a=async y=>y&&!l.has(y.file)&&await i.bundledFaceInstalled(y).catch(()=>!0)?y:void 0,f=async(y,k)=>{try{let u=new Uint8Array(await i.loadBundledFontBytes(y,void 0,{decoder:tr,strict:!0})),h={bold:y.weight===700,italic:y.style==="italic"};return{family:y.family,...h,bytes:u,face:h}}catch(u){if(Bn(u)&&(u.diagnostic.pack==="cjk"||u.diagnostic.pack==="intl")){l.add(y.file),n.has(u)||(n.add(u),Dn(u));return}let h=u instanceof Error?u.message:String(u);throw new Oe("font-unavailable",`${y.family} for ${k} could not load: ${h}`)}},d=new Map,p=(y,k)=>{let u=d.get(y.file);return u||(u=f(y,k),d.set(y.file,u)),u};for(;;){let y=await iu(i,a,e),k=l.size,u=[],h=new Map;if(await Promise.all([...y].map(async([C,{font:v,faces:P}])=>{let[L,...B]=await Promise.all(P.map(V=>p(V,v.family)));L&&u.push({...L,family:v.family,bold:v.bold,italic:v.italic});let D=B.filter(V=>V!==void 0);D.length&&h.set(C,D)})),l.size===k)return{faces:u,fallbacks:C=>[...h.get(We(C))??[]]};t?.throwIfAborted()}});if(!t)return r;let o,s=new Promise((i,l)=>{o=()=>l(t.reason),t.addEventListener("abort",o,{once:!0})});r.catch(()=>{});try{return await Promise.race([r,s])}finally{t.removeEventListener("abort",o)}}var Sa,ou,va,_a=U(()=>{"use strict";Kr();Zr();Hn();co();Pt();ou=()=>Sa??=Yr().catch(e=>{throw Sa=void 0,e});va=(e,t)=>e.family===t.family&&e.weight===t.weight&&e.style===t.style});async function Ra(e,t,n){if(!Zn())throw _t();let{list:r,...o}=Vn(e,t,n);if(n.fonts!==void 0)return _o(r,{...o,signal:n.signal,fonts:n.fonts});Pa??=await Promise.resolve().then(()=>(_a(),Ca));let{faces:s,fallbacks:i}=await Pa.defaultSheetFaces(ka(r),n.signal,e.reportedFontCdnErrors);return _o(r,{...o,signal:n.signal,fonts:s,fallbacks:i})}var Pa,Fa=U(()=>{"use strict";er();Kn()});var Aa=U(()=>{});function nr(e,t){if(typeof e!="object"||e===null)return!1;let n=e,r=o=>!!o&&Number.isSafeInteger(o.row)&&o.row>=0&&Number.isSafeInteger(o.col)&&o.col>=0;return typeof n.sheet=="string"&&n.sheet.length>0&&n.sheet.length<=cu&&r(n.anchor)&&r(n.head)}var Se,lt,Ea,Ta,cu,ct=U(()=>{"use strict";Aa();Se=16777216,lt=Number.MAX_SAFE_INTEGER-1,Ea=1048576,Ta=16384,cu=256});function La(e){let t=e.saveWarningsJson;return typeof t=="function"?JSON.parse(t.call(e)):[]}function du(e){if(!e.startsWith("{"))return null;try{let t=JSON.parse(e);return t.code!=="displayTooLarge"||typeof t.cells!="number"||!Number.isSafeInteger(t.cells)||typeof t.maxCells!="number"||!Number.isSafeInteger(t.maxCells)||t.maxCells<=0||t.cells<=t.maxCells?null:new Ro(t.cells,t.maxCells)}catch{return null}}function fu(e){if(e.startsWith("Stale proposal:"))return new Me([]);if(!e.startsWith("{"))return null;try{let t=JSON.parse(e);return t.code!=="staleProposal"||!Array.isArray(t.cells)?null:new Me(t.cells,Array.isArray(t.targets)?t.targets:[])}catch{return null}}function Fo(e,t,n){let r=Ma.get(e);if(!r)throw new Error("Workbook display list is unavailable");return r(t,n)}async function uu(e){let t=await e;if(t instanceof WebAssembly.Module||Object.prototype.toString.call(t)==="[object WebAssembly.Module]")return t;if((typeof t=="string"||t instanceof URL||typeof Request=="function"&&t instanceof Request)&&(t=await fetch(t)),typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.compileStreaming=="function")try{return await WebAssembly.compileStreaming(t.clone())}catch(n){if(!t.ok||!["basic","cors","default"].includes(t.type)||t.headers.get("Content-Type")==="application/wasm")throw n}t=await t.arrayBuffer()}return WebAssembly.compile(t)}function ze(e,t={}){if(rr)return Promise.resolve();if(nn)return nn;let n=t.png!==!1,r,o=e??Rs(r=nt(it==="native"||n)),s=it==="native"||e===void 0&&n?o:uu(o);return nn=ro({module_or_path:s}).then(i=>{Wa=i.memory,rr=!0},i=>{throw nn=void 0,r&&it!=="native"?Fs(r,i):dt(i)}),nn}function Na(){if(!rr)throw new Error("xlsx wasm is not initialized; call initWasm() first")}function dt(e){if(e instanceof Error)return e;let t=typeof e=="string"?e:String(e);return du(t)??new Error(t)}function Ia(){if(!rr)return null;let e=to();return e>0?{bytes:e,memoryBytes:Wa?.buffer.byteLength??0}:null}function or(){return it==="native"||Zn()}function Ua(e,t={}){return ja(e,t)}function Ao(e,t,n=!1){let r=Da.get(e);if(!r)throw new TypeError("Workbook does not support recovery checkpoints");return r(t,n)}function Eo(e,t,n={}){Na();try{let r=Re.openRecoveryCheckpoint(e,t);return $a(r,n,!0)}catch(r){throw dt(r)}}function ft(e){let t=za.get(e);if(!t)throw new TypeError("Workbook does not support peer snapshots");return t}function Xa(e){let t=Ba.get(e);if(!t)throw new TypeError("Workbook does not support peer hydration");return t()}function Ja(e,t){let n=qa.get(e);if(!n)throw new TypeError("Workbook does not support peer version adoption");n(t)}function Ha(e,t,n){return ja(e,t,n)}function ja(e,t,n){if(t.calculation!==void 0&&(Ga(t.calculation),t.collaborative===!0))throw new TypeError("calculation context is unavailable for collaborative workbooks");if(t.recalculate!==void 0&&t.recalculate!=="all"&&t.recalculate!=="stale")throw new TypeError("recalculate must be 'all' or 'stale'");if(t.recalculate==="stale"&&t.collaborative===!0)throw new TypeError("recalculate 'stale' is unavailable for collaborative workbooks");Na();let r=Qa(t),o;try{n!==void 0?o=Re.openWithPeerHydrationJson(e,n):t.recalculate==="stale"?o=Re.openRecalculatingStale(e,t.calculation===void 0?void 0:JSON.stringify(t.calculation)):t.calculation!==void 0?o=Re.openWithCalculationJson(e,JSON.stringify(t.calculation)):o=r===void 0?Re.open(e):Re.openCollaborative(e,r)}catch(s){throw dt(s)}return $a(o,t,n!==void 0)}function $a(e,t,n){let r=Qa(t),o=new Map,s=new Map,i=new Set,l=[],a=0,f=0,d=!1,p=t.calculation!==void 0||n&&r===void 0,y=!1,k=0,u=!1,h=!1;function C(){if(!i.size)return;let c=g.listProposals();for(let b of i)try{b(structuredClone(c))}catch(S){console.error("xlsx proposal listener failed",S)}}function v(c){!c.truncated||h||(h=!0,console.warn("xlsx: displayTooLarge: frame truncated at the display cell limit"))}function P(){if(d)throw new Error("workbook handle is disposed")}function L(){if(!(d||u||k!==0)){u=!0;try{for(;!d&&l.length>0;){let c=l.shift();if(!c)break;for(let[b,S]of[...o]){if(d)return;if(o.get(b)===S)try{S(c.update.slice(),c.origin,{fromPeer:c.fromPeer})}catch{}}}}finally{u=!1,d&&(l.length=0)}}}function B(){if(!(!y||d))for(;;){let c=e.drainUpdateEvent();if(c.byteLength===0)return;let b=c[0];if(b!==0&&b!==1)throw new Error(`xlsx wasm returned unknown update origin ${b}`);l.push({update:c.subarray(1),origin:b===0?"local":"remote",fromPeer:b===1||a>0})}}function D(c,b=!1){P(),k+=1;try{let S,W,M=!1;try{S=c()}catch(G){W=G,M=!0}if(b&&!(M&&ue(W)))try{B()}catch(G){M||(W=G,M=!0)}if(M)throw dt(W);return S}finally{k-=1,k===0&&L()}}function V(c){return D(c,!0)}function R(c,b=!1){return D(()=>JSON.parse(c()),b)}function J(c){return{reportedFontCdnErrors:c,doc:e,onSheet:(b,S)=>{let W=R(()=>e.sheetInfoJson()).activeSheet;if(b===W)return D(S);V(()=>e.setActiveSheet(b));try{return D(S)}finally{V(()=>e.setActiveSheet(W))}}}}function O(c,b){let S=JSON.stringify(c);return b===void 0?e.displayListJson(S):e.displayListForJson(b,S)}function F(){y||(D(()=>e.startUpdateObservation()),y=!0)}function x(){!y||o.size>0||d||(l.length=0,D(()=>e.clearUpdateObservation()),y=!1)}let g={get clientId(){return D(()=>e.clientId)},setCalculationContext(c){if(P(),c!==null&&(Ga(c),r!==void 0))throw new TypeError("calculation context is unavailable for collaborative workbooks");D(()=>e.setCalculationContextJson(JSON.stringify(c))),p=c!==null},encodeStateVector(){return D(()=>e.encodeStateVector())},encodeStateAsUpdate(c){return D(()=>c===void 0?e.encodeStateAsUpdate():e.encodeDiff(c))},applyUpdate(c){a+=1;try{return R(()=>e.applyUpdateJson(c),!0)}finally{a-=1}},onUpdate(c){if(P(),typeof c!="function")throw new TypeError("update listener must be a function");let b=f++;o.set(b,c);try{F()}catch(W){throw o.delete(b),W}let S=!0;return()=>{S&&(S=!1,o.delete(b),x())}},sheetInfo(){return R(()=>e.sheetInfoJson())},sheetCount(){return D(()=>e.sheetCount())},sheetInfoFor(c){if(!Number.isInteger(c)||c<0||c>=g.sheetCount())throw new RangeError("Sheet index is out of range");return R(()=>e.sheetInfoForJson(c))},recalculate(){return P(),R(()=>e.recalculateJson(),!0)},calculationStatus(){return D(()=>{let c=e.calculationStatusJson;return typeof c!="function"?{limitedCells:[],unevaluatedCells:[]}:JSON.parse(c.call(e))})},displayList(c){let b=R(()=>O(c));return v(b),b},displayListProfiled(c){let b=R(()=>e.displayListProfiledJson(JSON.stringify(c)));return v(b.displayList),b},printDisplayList(c,b,S,W){return R(()=>e.printDisplayListJson(JSON.stringify({sheet:c,range:b,metrics:S,gridlines:W})))},chartAtPoint(c,b,S){return R(()=>e.chartAtPointJson(JSON.stringify({viewport:c,x:b,y:S})))},mediaBytes(c){return D(()=>e.mediaBytes(c))},moveChart(c,b,S,W,M){return R(()=>e.moveChartJson(JSON.stringify({sheet:c,chart:b,dx:S,dy:W,protectedSheets:M?.protectedSheets})),!0)},resizeChart(c,b,S,W){return R(()=>e.resizeChartJson(JSON.stringify({sheet:c,chart:b,...S,protectedSheets:W?.protectedSheets})),!0)},setActiveSheet(c){V(()=>e.setActiveSheet(c))},editCell(c,b,S,W,M){return R(()=>e.editCellJson(JSON.stringify({sheet:c,row:b,col:S,input:W,protectedSheets:M?.protectedSheets})),!0)},editCellProfiled(c,b,S,W){return R(()=>e.editCellProfiledJson(JSON.stringify({sheet:c,row:b,col:S,input:W})),!0)},editCells(c,b,S){return R(()=>e.editCellsJson(JSON.stringify({sheet:c,edits:b,protectedSheets:S?.protectedSheets})),!0)},fillRange(c,b,S){return R(()=>e.fillRangeJson(JSON.stringify({sheet:c,source:b,destination:S})),!0)},moveRange(c,b,S){return R(()=>e.moveRangeJson(JSON.stringify({sheet:c,source:b,destination:S})),!0)},setHyperlink(c,b){return R(()=>e.applyOpsJson(JSON.stringify({ops:[{type:"setHyperlink",sheet:c,hyperlink:{range:b.range,external_target:b.externalTarget??null,location:b.location??null,tooltip:b.tooltip??null,display:b.display??null}}]})),!0)},removeHyperlink(c,b){return R(()=>e.applyOpsJson(JSON.stringify({ops:[{type:"removeHyperlink",sheet:c,range:b}]})),!0)},charts(c){return R(()=>e.chartsJson(c))},editCharts(c){return R(()=>e.editChartsJson(JSON.stringify(c)),!0)},conditionalFormats(c){return R(()=>e.conditionalFormatsJson(c))},applyOps(c){return R(()=>e.applyOpsJson(JSON.stringify({ops:c})),!0)},applyOpsProfiled(c){return R(()=>e.applyOpsProfiledJson(JSON.stringify({ops:c})),!0)},undo(){return R(()=>e.undoJson(),!0)},redo(){return R(()=>e.redoJson(),!0)},cell(c,b,S){return R(()=>e.cellJson(JSON.stringify({sheet:c,row:b,col:S})))},searchText(c,b){if(!c)return[];let S=b?.limit;if(S!==void 0&&(!Number.isSafeInteger(S)||S<0||S>4294967295))throw new RangeError("search limit must be an unsigned 32-bit integer");return R(()=>e.searchTextJson(JSON.stringify({query:c,caseSensitive:b?.caseSensitive??!1,...S===void 0?{}:{limit:S}})))},cellPosition(c,b,S){return R(()=>e.cellPositionJson(JSON.stringify({sheet:c,row:b,col:S})))},selectionData(c,b,S,W){return R(()=>e.selectionDataJson(JSON.stringify({sheet:c,row:b,col:S,direction:W})))},cellRect(c,b,S){return R(()=>e.cellRectJson(JSON.stringify({sheet:c,row:b,col:S})))},rangeCells(c,b){return R(()=>e.rangeCellsJson(JSON.stringify({sheet:c,range:b}))).cells},patchRangeStyle(c,b,S,W){return R(()=>e.patchRangeStyleJson(JSON.stringify({sheet:c,range:b,patch:S,protectedSheets:W?.protectedSheets})),!0)},setNumberFormat(c,b,S,W){let M=typeof S=="string"?{type:S}:S;return R(()=>e.setRangeNumberFormatJson(JSON.stringify({sheet:c,range:b,format:M,protectedSheets:W?.protectedSheets})),!0)},selectionFormatting(c,b){return R(()=>e.selectionFormattingJson(JSON.stringify({sheet:c,range:b})))},captureFormat(c,b){return R(()=>e.captureFormatJson(JSON.stringify({sheet:c,range:b})))},applyFormat(c,b,S,W){return R(()=>e.applyFormatJson(JSON.stringify({sheet:c,range:b,format:S,protectedSheets:W?.protectedSheets})),!0)},mergedRanges(c,b){return R(()=>e.mergedRangesJson(JSON.stringify({sheet:c,range:b}))).ranges},visibleMergedRanges(c,b){if(!Number.isInteger(c)||c<0||c>=g.sheetCount())throw new RangeError("Sheet index is out of range");return R(()=>e.visibleMergedRangesJson(c,JSON.stringify(b))).ranges},historyState(){return R(()=>e.historyStateJson())},renderPng(c,b={}){try{let S=mo(c,b,R(()=>e.sheetInfoJson()).sheetNames),W=Object.getOwnPropertyDescriptor(c,Symbol.for("@betteroffice/xlsx/reportedFontCdnErrors"))?.value;return Ra(J(W),S,b).catch(M=>Promise.reject(dt(M)))}catch(S){return Promise.reject(S)}},renderPngFonts:(c,b={})=>Jn(g,c,b),save(){let c=D(()=>e.saveBytes());return Ni(D(()=>La(e))),c},saveWithWarnings(){return{bytes:D(()=>e.saveBytes()),warnings:D(()=>La(e))}},propose(c,b,S){let W=V(()=>{let M=e.proposeJson;if(typeof M!="function")throw new Error("proposals not in this build");let G=S.map(({numberFormat:re,...Y})=>({...Y,...re===void 0?{}:{numberFormat:typeof re=="string"?{type:re}:re}}));return JSON.parse(M.call(e,JSON.stringify({agentId:c,note:b,edits:G})))});return C(),W},listProposals(){return D(()=>{let c=e.listProposalsJson;return typeof c!="function"?[]:JSON.parse(c.call(e)).proposals})},onProposalChange(c){if(P(),typeof c!="function")throw new TypeError("proposal listener must be a function");return i.add(c),()=>{i.delete(c)}},getProposalStatus(c){return g.listProposals().some(b=>b.id===c)?"pending":s.get(c)},isProposalStale(c){let b=Eo(Ao(g,0),0);try{return b.acceptProposal(c),!1}catch(S){if(S instanceof Me)return!0;throw S}finally{b.dispose()}},acceptProposal(c,b){try{let S=V(()=>{let W=e.acceptProposalJson;if(typeof W!="function")throw new Error("proposals not in this build");let M=JSON.parse(W.call(e,JSON.stringify({id:c,force:b?.force??!1})));return s.set(c,"accepted"),M});return C(),S}catch(S){let W=S instanceof Error?S.message:typeof S=="string"?S:String(S);throw fu(W)??dt(S)}},rejectProposal(c){let b=V(()=>{let S=e.rejectProposalJson;if(typeof S!="function")return!1;let W=JSON.parse(S.call(e,JSON.stringify({id:c}))).removed;return W&&s.set(c,"rejected"),W});return b&&C(),b},isProposalsAvailable(){return D(()=>typeof e.proposeJson=="function")},version(){return D(()=>e.documentVersion())},listDefinedNames(c={}){return R(()=>e.listDefinedNamesJson(JSON.stringify(c)))},readCells(c){return R(()=>e.readCellsJson(JSON.stringify(c)))},findText(c){return R(()=>e.findTextJson(JSON.stringify(c)))},validateEdits(c){return p&&c.calculation!==void 0&&Oa(c.calculation),R(()=>e.validateEditsJson(JSON.stringify(c)))},applyEdits(c){return p&&c.calculation!==void 0&&Oa(c.calculation),R(()=>e.applyEditsJson(JSON.stringify(c)),!0)},exportStructured(c={}){return R(()=>e.exportStructuredJson(JSON.stringify(c)))},exportMarkdown(c={},b={}){return R(()=>e.exportMarkdownJson(JSON.stringify(c),JSON.stringify(b)))},dispose(){if(d)return;d=!0,s.clear(),i.clear(),o.clear(),l.length=0;let c;if(y){try{e.clearUpdateObservation()}catch(b){c=b}y=!1}try{e.free()}catch(b){c??=b}if(c!==void 0)throw dt(c)}};return Ma.set(g,(c,b)=>{let S=D(()=>O(c,b));return!h&&S.includes('"truncated":true')&&v(JSON.parse(S)),S}),io.set(g,(c,b)=>Po(Vn(J(),mo(c,b,R(()=>e.sheetInfoJson()).sheetNames),b).list)),Da.set(g,(c,b)=>D(()=>e.recoveryCheckpoint(c,b))),Ba.set(g,()=>D(()=>e.peerHydrationJson())),qa.set(g,c=>D(()=>e.adoptPeerVersion(c))),za.set(g,{begin:(c,b)=>D(()=>e.beginPeerSnapshot(c,b)),next:()=>D(()=>e.nextPeerSnapshotChunk()),end:()=>D(()=>e.endPeerSnapshot())}),Va.set(g,c=>R(()=>e.translateFormulasJson(JSON.stringify(c)))),g}function Ka(e,t){let n=Va.get(e);if(!n)throw new TypeError("translateFormulasOn needs a workbook this package opened");return n(t)}function Ga(e){if(typeof e!="object"||e===null||Array.isArray(e)||Object.keys(e).some(r=>r!=="nowSerial"&&r!=="randSeed"))throw new TypeError("calculation must be an object with nowSerial and randSeed");let{nowSerial:t,randSeed:n}=e;if(typeof t!="number"||!Number.isFinite(t))throw new TypeError("nowSerial must be a finite number");if(typeof n!="number"||!Number.isInteger(n)||n<0||n>4294967295)throw new TypeError("randSeed must be an integer from 0 to 4294967295")}function Oa(e){if(typeof e!="object"||e===null||Array.isArray(e)||Object.keys(e).some(n=>n!=="nowSerial"))throw new TypeError("calculation must be an object with an optional nowSerial");let{nowSerial:t}=e;if(t!==void 0&&(typeof t!="number"||!Number.isFinite(t)))throw new TypeError("nowSerial must be a finite number")}function Qa(e){if(!e.collaborative){if(e.clientId!==void 0)throw new TypeError("clientId requires collaborative mode");return}if(e.clientId!==void 0){if(!Number.isSafeInteger(e.clientId)||e.clientId<=0||e.clientId>=lt)throw new RangeError("clientId must be a nonzero safe integer below Number.MAX_SAFE_INTEGER - 1");return e.clientId}let t=globalThis.crypto;if(!t||typeof t.getRandomValues!="function")throw new Error("crypto.getRandomValues is required to generate a collaboration client ID");let n=new Uint32Array(2),r;do t.getRandomValues(n),r=(n[0]&2097151)*4294967296+n[1];while(r===0||r>=lt);return r}var tr,Me,Ro,rr,Wa,nn,Ma,Ba,Da,qa,za,Va,Pt=U(()=>{"use strict";oo();Mi();Ve();Ii();xn();Sn();ao();Fa();Kn();er();ct();tr=async(e,{codec:t,dict:n,maxOutput:r})=>(await ze(),Wi(no(Qt(e),t,n===void 0?void 0:Qt(n),r)));Me=class extends Error{cells;targets;constructor(t,n=[]){super(`stale: ${t.join(", ")}`),this.name="StaleProposalError",this.cells=t,this.targets=n}},Ro=class extends Error{constructor(n,r){super(`requested viewport spans ${n} cells, exceeds the ${r}-cell display-list cap`);this.cells=n;this.maxCells=r;this.name="DisplayTooLargeError"}cells;maxCells;code="displayTooLarge"};rr=!1,Ma=new WeakMap;Ba=new WeakMap,Da=new WeakMap;qa=new WeakMap,za=new WeakMap;Va=new WeakMap});function el(e){let t={input:[],collab:[],interactive:[]},n=[],r=0,o=0,s=0,i=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,a=!1,f=!1,d=null,p=()=>e.now()-i<hu?pu:mu;function y(R=!1){a||f||(f=!0,(R?queueMicrotask:e.turn)(()=>{f=!1,B()}))}function k(R){for(let J of Ya)if(J!==R.lane)for(let O of t[J]){if(O.seq>R.seq)break;if(!(O.reorderable&&Za[R.lane]<Za[O.lane]))return!0}return!1}function u(){for(let R of Ya){let J=t[R][0];if(J&&!k(J))return J}return null}function h(){let R=u();if(!R)return null;let J=[t[R.lane].shift()];if(R.lane==="collab")for(;t.collab[0]&&!k(t.collab[0]);)J.push(t.collab.shift());return J}function C(R){return R.idleAfterInputMs===void 0?Number.NEGATIVE_INFINITY:l+R.idleAfterInputMs}async function v(R){for(let J of R){J.mutates&&(o+=1),(J.mutates||J.reframes)&&(s+=1);try{await J.run()}catch(O){e.failed?.(O)}}}async function P(){let R=e.now(),J=n.findIndex(F=>C(F)<=R);if(J<0)return!1;let[O]=n.splice(J,1);try{if(O.version!==o||O.generation!==s){if((O.onStale?.()??"cancel")==="cancel")return O.cancel?.(),!0;O.version=o,O.generation=s}await O.run(p())==="yield"&&n.push(O)}catch(F){O.fail?O.fail(F):e.failed?.(F)}return!0}function L(){if(d?.(),d=null,n.length===0)return;let R=Math.min(...n.map(C));d=e.timer(()=>{d=null,y()},Math.max(1,R-e.now()))}async function B(){if(a)return;a=!0;let R=!1;try{let O=h();O?(R=!0,await v(O)):n.length>0&&(R=await P())}catch(O){R=!0,e.failed?.(O)}finally{a=!1}let J=R?u():null;J?y(!J.reorderable):R&&n.length>0?y():L()}function D(R,J){V({kind:`${R.kind}:install`,version:R.version,generation:R.generation,onStale:()=>"cancel",cancel:()=>R.cancel?.(),fail:O=>R.cancel?.(O),run:async()=>(await R.install(J),"done")})}function V(R){n.push(R),a||(d?.(),d=null),y()}return{submit(R){if(R.userInput&&(i=e.now()),R.holdsIdleTasks&&(l=e.now()),R.key!==void 0){let J=t[R.lane];for(let O=J.length-1;O>=0;O-=1)if(J[O].replaceableBy===R.key)try{J.splice(O,1)[0].supersede?.()}catch(F){e.failed?.(F)}}t[R.lane].push({...R,seq:r++}),d?.(),d=null,y(!0)},schedule:V,dispatch(R){let J=R,O=()=>V({kind:J.kind,version:J.version,generation:J.generation,onStale:()=>"cancel",cancel:()=>J.cancel?.(),fail:x=>J.cancel?.(x),run:async()=>(await J.install(J.compute(J.input)),"done")});if(!e.executor){O();return}let F=(J.transfer?.length??0)>0;e.executor.run({kind:J.kind,input:J.input,transfer:J.transfer}).then(x=>D(J,x),x=>F?J.cancel?.(x):O())},budget:p,get version(){return o},get generation(){return s},bump(R){R.version&&(o+=1),(R.version||R.generation)&&(s+=1)},pending(){return{foreground:t.input.length+t.collab.length+t.interactive.length,background:n.length}}}}var Ya,Za,pu,mu,hu,tl=U(()=>{"use strict";Ya=["input","collab","interactive"],Za={input:0,collab:1,interactive:2,background:3},pu=8,mu=24,hu=1e3});function To(e){let t={name:e instanceof Error?e.name:"Error",message:e instanceof Error?e.message:String(e)};return e!==null&&typeof e=="object"&&"code"in e&&typeof e.code=="string"&&(t.code=e.code),e!==null&&typeof e=="object"&&"refusal"in e&&(t.refusal=e.refusal),t}function rn(e){return e instanceof Z||ue(e)}function yu(e){return e instanceof Z?e:new Z(rn(e)?"trap":"crash",To(e).message)}function nl(e,t){let n,r=F=>{let x=yu(F);return x.code==="trap"?t.trapFailure?.(x)??x:x},o=!1,s=()=>{},i=()=>{},l,a=new Set,f=0,d=new Set,p=new Set,y=()=>o||n!==void 0;function k(){s(),i();for(let F of d)clearTimeout(F);d.clear();for(let F of p)try{F.cancel()}catch{}p.clear();try{t.onDispose?.()}catch{}}function u(F){if(!y()){n=F;try{e.post({protocol:1,kind:"failure",code:F.code,message:F.message,...F.diagnostics===void 0?{}:{diagnostics:F.diagnostics}})}catch{}k()}}function h(F,x){if(!y())try{e.post(F,x)}catch(g){u(new Z("message",`Session could not post a message: ${To(g).message}`))}}function C(F,x){if(y())return()=>{};let g=setTimeout(()=>{d.delete(g),y()||F()},x);return d.add(g),()=>{clearTimeout(g),d.delete(g)}}function v(F){let x={end(){p.delete(x)},cancel(){x.end(),F?.()}};return F&&p.add(x),x}function P(F,x){if(y())return x;let g=c=>{if(y())return x;if(!rn(c))throw c;return u(r(c)),x};try{let c=F();return c instanceof Promise?c.catch(g):c}catch(c){return g(c)}}function L(F){let x=F.then(),g=c=>b=>{if(!y())try{return c(b)}catch(S){u(r(S));return}};return x.then=((c,b)=>Promise.prototype.then.call(x,c&&g(c),b&&g(b))),x}let B=t.executor,D=el({now:Date.now,turn:F=>{C(F,0)},timer:C,executor:B&&{run(F){return L(B.run(F))}},failed:F=>u(r(F))}),V={schedule(F){if(y()){try{F.cancel?.()}catch{}return}let x=v(F.cancel&&(()=>F.cancel()));D.schedule({kind:F.kind,idleAfterInputMs:F.idleAfterInputMs,get version(){return F.version},set version(g){F.version=g},get generation(){return F.generation},set generation(g){F.generation=g},...F.onStale?{onStale:()=>P(()=>F.onStale(),"cancel")}:{},...F.cancel?{cancel(){return x.end(),P(()=>F.cancel(),void 0)}}:{},...F.fail?{fail(g){return x.end(),P(()=>F.fail(g),void 0)}}:{},async run(g){if(y())return"done";try{let c=await F.run(g);return c==="done"&&x.end(),y()?"done":c}catch(c){if(x.end(),y())return"done";if(rn(c))return u(r(c)),"done";throw c}}})},dispatch(F){if(y()){try{F.cancel?.()}catch{}return}let x=v(F.cancel&&(()=>F.cancel()));D.dispatch({kind:F.kind,input:F.input,transfer:F.transfer,get version(){return F.version},set version(g){F.version=g},get generation(){return F.generation},set generation(g){F.generation=g},...F.cancel?{cancel(g){return x.end(),P(()=>F.cancel(g),void 0)}}:{},compute(g){return P(()=>F.compute(g),void 0)},async install(g){if(!y())try{await F.install(g)}catch(c){if(x.end(),y())return;if(rn(c)){u(r(c));return}throw c}finally{x.end()}}})},bump:F=>D.bump(F),budget:()=>D.budget(),pending:()=>D.pending(),get version(){return D.version},get generation(){return D.generation}};function R(F,x){ve(x)?h({protocol:1,kind:"reply",id:F,ok:!0,value:x.value},x.transfer):h({protocol:1,kind:"reply",id:F,ok:!0,value:x})}function J(F,x){rn(x)?u(r(x)):h({protocol:1,kind:"reply",id:F,ok:!1,error:To(x)})}async function O(F){if(!y()){l=F.id,f=Date.now();try{let x=t.handlers[F.method],g=await x(t.context,...F.args);_s(g)?(a.add(F.id),g.promise.then(c=>R(F.id,c),c=>J(F.id,c)).finally(()=>a.delete(F.id))):R(F.id,g)}catch(x){J(F.id,x)}finally{l===F.id&&(l=void 0)}}}return s=e.listen(F=>{if(!y()){if(!bt(F))u(new Z("message","Session received a malformed client message"));else if(F.kind==="dispose")o=!0,k(),e.close();else if(F.kind==="call"&&!n){let x=pe(t.policies,F.method)?t.policies[F.method]:void 0;if(!pe(t.handlers,F.method)||!x){h({protocol:1,kind:"reply",id:F.id,ok:!1,error:{name:"Error",message:`Unknown session method: ${F.method}`}});return}let g;try{g=typeof x=="function"?x(...F.args):x}catch(c){J(F.id,c);return}D.submit({...g,run:()=>O(F),supersede:()=>h({protocol:1,kind:"reply",id:F.id,ok:!1,error:{name:fs,message:"Superseded by a newer request"}})})}}}),i=e.onError(F=>u(r(F))),{scheduler:V,emit:(F,x,g)=>h({protocol:1,kind:"event",name:F,payload:x},g),progress(){let F=Date.now(),x=l??a.values().next().value;x===void 0||F-f<bu||(f=F,h({protocol:1,kind:"progress",id:x}))}}}var bu,rl=U(()=>{"use strict";Be();tl();je();Ve();bu=1e3});function Lo(e){wn(e)}var ol=U(()=>{"use strict";It()});function sl(e){return(e-new Date(e).getTimezoneOffset()*6e4)/864e5+25569}var il=U(()=>{"use strict"});function al(e){for(;;){let t=e();if(!JSON.parse(t).conditionalPending)return t}}var ll=U(()=>{"use strict"});function cl(e){let t=[];for(let n of e)n.op==="event"&&n.event.type==="message"&&t.push(n.event.data);return t}function Oo(e){return e.buffer instanceof ArrayBuffer&&e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.slice().buffer}function ku(e){let t=e;return typeof t=="object"&&t!==null&&gu.has(t.code)&&typeof t.message=="string"}function Su(e,t){if(typeof e!="object"||e===null)return!1;let n=e;switch(n.type){case"open":return!0;case"message":return n.data instanceof ArrayBuffer&&n.data.byteLength<=t;case"close":return n.reason===void 0||typeof n.reason=="string";default:return!1}}function dl(e,t,n){if(typeof e!="object"||e===null)return!1;let{provider:r,ops:o}=e;return!Number.isSafeInteger(r)||r<0||!Array.isArray(o)||o.length===0?!1:o.every(s=>{if(typeof s!="object"||s===null)return!1;let i=s;if(!wu(i.seq))return!1;switch(i.op){case"create":return typeof i.options=="object"&&i.options!==null&&Object.keys(i.options).every(l=>n.optionKeys.has(l));case"connect":case"disconnect":case"destroy":return!0;case"fail":return ku(i.error);case"cursor":return typeof i.broadcast=="boolean"&&(i.cursor===null||n.validCursor(i.cursor,t));case"event":return Su(i.event,t);default:return!1}})}function sr(){let e=globalThis.performance;return typeof e?.now!="function"?0:typeof e.timeOrigin=="number"?e.timeOrigin:Date.now()-e.now()}var gu,wu,ir=U(()=>{gu=new Set(["backpressure","protocol","replica","transport"]),wu=e=>Number.isSafeInteger(e)&&e>=0});function ul(e,t){if(e==="bold"||e==="italic"||e==="strikethrough"||e==="paintFormat"||e==="clear"||e==="refreshProposals")return t===null;if((e==="merge"||e==="textWrapping")&&t===null)return!0;if(!t||typeof t!="object"||Array.isArray(t))return!1;let n=t,r=o=>typeof n.value=="string"&&o.includes(n.value);switch(e){case"fontFamily":return typeof n.family=="string"&&n.family.trim()!=="";case"fontSize":return typeof n.points=="number"&&Number.isFinite(n.points)&&n.points>=1&&n.points<=400;case"fontSizeStep":case"decimalPlaces":return n.direction==="increase"||n.direction==="decrease";case"textColor":case"fillColor":case"borderColor":return typeof n.color=="string"&&/^#[0-9a-f]{6}$/i.test(n.color);case"numberFormat":return r(["automatic","plainText","number","percent","scientific","currency","date","time","custom"]);case"borderPreset":return r(["all","inner","horizontal","vertical","outer","left","top","right","bottom","none"]);case"borderStyle":return r(["solid","dashed","dotted","double"]);case"merge":return r(["all","horizontal","vertical","unmerge"]);case"horizontalAlignment":return r(["left","center","right"]);case"verticalAlignment":return r(["top","middle","bottom"]);case"textWrapping":return r(["overflow","wrap","clip"]);default:return!1}}function pl(e,t,n,r){let{id:o,args:s}=e,{sheet:i,range:l,start:a,end:f}=t,d=s,p=y=>({method:"patchRangeStyle",args:[i,l,y]});switch(o){case"clear":{let y=[];for(let k=a.row;k<=f.row;k++)for(let u=a.col;u<=f.col;u++)y.push({row:k,col:u,input:""});return{method:"editCells",args:[i,y]}}case"bold":return p({bold:n.bold!==!0});case"italic":return p({italic:n.italic!==!0});case"strikethrough":return p({strikethrough:n.strikethrough!==!0});case"fontFamily":return p({fontFamily:d.family});case"fontSize":return p({fontSize:d.points});case"fontSizeStep":{let y=n.fontSize??10,k=d.direction==="increase"?fl.find(u=>u>y)??y+1:[...fl].reverse().find(u=>u<y)??Math.max(1,y-1);return p({fontSize:k})}case"textColor":return p({textColor:d.color});case"fillColor":return p({fillColor:d.color});case"horizontalAlignment":return p({horizontalAlignment:d.value});case"verticalAlignment":return p({verticalAlignment:d.value});case"textWrapping":return p({textWrapping:s===null?n.textWrapping==="wrap"?"overflow":"wrap":d.value});case"borderPreset":return p({border:{preset:d.value,style:n.borderStyle??"solid",color:n.borderColor??"#000000"}});case"borderStyle":return p({border:{style:d.value}});case"borderColor":return p({border:{color:d.color}});case"numberFormat":return{method:"setNumberFormat",args:[i,l,d.value==="custom"?{type:"custom",pattern:n.numberFormatPattern??"0.00"}:d.value]};case"decimalPlaces":return{method:"setNumberFormat",args:[i,l,d.direction==="increase"?"increaseDecimal":"decreaseDecimal"]};case"merge":{let y=s===null?r.length>0?"unmerge":"all":d.value;if((y==="horizontal"?f.row-a.row+1:y==="vertical"?f.col-a.col+1:y==="all"?1:r.length)>xu)throw new H("limit-exceeded");let u=[];if(y==="all")u.push({type:"mergeCells",sheet:i,range:{start:a,end:f}});else if(y==="horizontal")for(let h=a.row;h<=f.row;h++)u.push({type:"mergeCells",sheet:i,range:{start:{row:h,col:a.col},end:{row:h,col:f.col}}});else if(y==="vertical")for(let h=a.col;h<=f.col;h++)u.push({type:"mergeCells",sheet:i,range:{start:{row:a.row,col:h},end:{row:f.row,col:h}}});else for(let h of r)u.push({type:"unmergeCells",sheet:i,range:h});return{method:"applyOps",args:[u]}}default:return}}var fl,xu,Wo=U(()=>{"use strict";on();fl=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],xu=4096});function ee(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function de(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function Rt(e){return typeof e=="number"&&Number.isFinite(e)}function sn(e){return ee(e)&&de(e.row)&&de(e.col)}function vu(e){return!ee(e)||typeof e.sheetId!="string"||!ee(e.range)?!1:e.range.kind==="a1"?typeof e.range.a1=="string":e.range.kind==="rowCol"&&sn(e.range.start)&&sn(e.range.end)}function yl(e){return Array.isArray(e)&&Array.from(e).every(t=>typeof t=="string")}function ml(e){return Array.isArray(e)&&Array.from(e).every(yl)}function Xe(e,t){return Object.entries(t).every(([n,r])=>e[n]===void 0||r(e[n]))}function Ne(e){return t=>typeof t=="string"&&e.includes(t)}function gl(e){return ee(e)&&Xe(e,{bold:t=>typeof t=="boolean",italic:t=>typeof t=="boolean",strikethrough:t=>typeof t=="boolean",fontFamily:t=>typeof t=="string",fontSize:Rt,textColor:t=>typeof t=="string",fillColor:t=>typeof t=="string",border:t=>ee(t)&&Xe(t,{preset:Ne(["all","inner","horizontal","vertical","outer","left","top","right","bottom","none"]),style:Ne(["solid","dashed","dotted","double"]),color:n=>typeof n=="string"}),horizontalAlignment:Ne(["left","center","right"]),verticalAlignment:Ne(["top","middle","bottom"]),textWrapping:Ne(["overflow","wrap","clip"]),clear:t=>Array.isArray(t)&&Array.from(t).every(Ne(["bold","italic","strikethrough","fontFamily","fontSize","textColor","fillColor","borders","horizontalAlignment","verticalAlignment","textWrapping"]))})}function Mo(e){return Ne(["automatic","plainText","number","percent","scientific","currency","date","time","increaseDecimal","decreaseDecimal"])(e)||ee(e)&&e.type==="custom"&&typeof e.pattern=="string"}function hl(e){return ee(e)&&Xe(e,{formula:t=>t===null||typeof t=="string",displayText:t=>typeof t=="string",value:t=>ee(t)&&(t.kind==="empty"||t.kind==="number"&&Rt(t.value)||t.kind==="text"&&typeof t.value=="string"||t.kind==="bool"&&typeof t.value=="boolean"||t.kind==="error"&&Ne(["#DIV/0!","#N/A","#NAME?","#NULL!","#NUM!","#REF!","#VALUE!","#SPILL!","#CALC!"])(t.value))})}function _u(e){return!ee(e)||typeof e.expectVersion!="string"||!Array.isArray(e.steps)||!Object.keys(e).every(t=>Cu.includes(t))?!1:Xe(e,{source:Ne(["host","agent"]),history:Ne(["separate","none"]),calculation:t=>ee(t)&&Object.keys(t).every(n=>n==="nowSerial")&&Xe(t,{nowSerial:Rt})})&&Array.from(e.steps).every(t=>{if(!ee(t)||!vu(t.target)||!Xe(t,{expect:n=>ee(n)&&Array.isArray(n.cells)&&Array.from(n.cells).every(r=>Array.isArray(r)&&Array.from(r).every(hl))}))return!1;switch(t.op){case"setCellInputs":return ml(t.inputs);case"setCellValues":return Array.isArray(t.values)&&Array.from(t.values).every(n=>Array.isArray(n)&&Array.from(n).every(r=>ee(r)&&hl({value:r})));case"setFormulas":return ml(t.formulas);case"setNumberFormat":return Mo(t.format);case"patchStyle":return gl(t.patch);case"replaceText":return typeof t.query=="string"&&t.query.length>0&&typeof t.replacement=="string"&&Xe(t,{entireCell:n=>typeof n=="boolean",lookIn:n=>n==="values"||n==="formulas"})&&t.expect===void 0;default:return!1}})}function Pu(e){return ee(e)&&ee(e.font)&&Au(e.fill)&&Tu(e.border)&&ee(e.numberFormat)&&typeof e.numberFormat.kind=="string"&&ee(e.alignment)}function wl(e){return e==="Auto"?!0:!ee(e)||Object.keys(e).length!==1?!1:"Rgb"in e?typeof e.Rgb=="string":"Indexed"in e?de(e.Indexed)&&e.Indexed<=255:ee(e.Theme)&&de(e.Theme.idx)&&e.Theme.idx<=255&&typeof e.Theme.tint=="number"&&Number.isFinite(e.Theme.tint)}function No(e){return e==null||wl(e)}function Au(e){if(e==="None")return!0;if(!ee(e)||Object.keys(e).length!==1)return!1;if("Solid"in e)return wl(e.Solid);let t=e.Pattern;return ee(t)&&typeof t.pattern=="string"&&Ru.has(t.pattern)&&No(t.fg)&&No(t.bg)}function Eu(e){return e==null||ee(e)&&typeof e.style=="string"&&Fu.has(e.style)&&No(e.color)}function Tu(e){return ee(e)&&["left","right","top","bottom"].every(t=>Eu(e[t]))}function Lu(e){if(!ee(e)||!Array.isArray(e.args))return!1;let t=Array.from(e.args);switch(e.method){case"editCell":return t.length===4&&t.slice(0,3).every(de)&&typeof t[3]=="string";case"editCells":return t.length===2&&de(t[0])&&Array.isArray(t[1])&&Array.from(t[1]).every(n=>sn(n)&&ee(n)&&typeof n.input=="string"&&(n.copyFrom===void 0||ee(n.copyFrom)&&sn(n.copyFrom)&&n.copyFrom.row<1048576&&n.copyFrom.col<16384));case"applyEdits":return t.length===1&&_u(t[0]);case"applyOps":return t.length===1&&Array.isArray(t[0])&&Array.from(t[0]).every(n=>ee(n)&&typeof n.type=="string");case"propose":return t.length===3&&typeof t[0]=="string"&&(t[1]===null||typeof t[1]=="string")&&Array.isArray(t[2])&&Array.from(t[2]).every(n=>ee(n)&&de(n.sheet)&&sn(n)&&typeof n.input=="string"&&Xe(n,{numberFormat:Mo}));case"acceptProposal":return t.length>=1&&t.length<=2&&typeof t[0]=="string"&&(t[1]===void 0||ee(t[1])&&Xe(t[1],{force:n=>typeof n=="boolean"}));case"rejectProposal":return t.length===1&&typeof t[0]=="string";case"patchRangeStyle":return t.length===3&&de(t[0])&&typeof t[1]=="string"&&gl(t[2]);case"setNumberFormat":return t.length===3&&de(t[0])&&typeof t[1]=="string"&&Mo(t[2]);case"applyFormat":return t.length===3&&de(t[0])&&typeof t[1]=="string"&&ee(t[2])&&de(t[2].rows)&&de(t[2].columns)&&Array.isArray(t[2].formats)&&Array.from(t[2].formats).every(Pu);case"moveChart":return t.length===4&&de(t[0])&&typeof t[1]=="string"&&t.slice(2).every(Rt);case"resizeChart":return t.length===3&&de(t[0])&&typeof t[1]=="string"&&ee(t[2])&&["left","top","right","bottom"].every(n=>Rt(t[2][n]));case"moveRange":return t.length===3&&de(t[0])&&typeof t[1]=="string"&&typeof t[2]=="string";case"fillRange":return t.length===3&&de(t[0])&&typeof t[1]=="string"&&typeof t[2]=="string";case"undo":case"redo":return t.length===0;case"setActiveSheet":return t.length===1&&de(t[0]);default:return!1}}function an(e){if(!ee(e)||!de(e.sequence)||e.sequence===0||!ee(e.calculation)||!Rt(e.calculation.nowSerial)||!de(e.calculation.randSeed)||e.calculation.randSeed>4294967295||!Lu(e.op)||e.staleProposal!==void 0&&(!ee(e.staleProposal)||!yl(e.staleProposal.cells)||!Array.isArray(e.staleProposal.targets)||!Array.from(e.staleProposal.targets).every(t=>ee(t)&&de(t.sheet)&&de(t.row)&&de(t.col)&&typeof t.sheetId=="string"&&typeof t.a1=="string")||!ee(e.op)||e.op.method!=="acceptProposal")){let t=new TypeError("Malformed workbook replay envelope");throw t.name="WorkbookReplayValidationError",t}}function ln(e){return ee(e)&&e.ok===!1}function Ft(e,t){switch(t.method){case"editCell":return e.editCell(...t.args);case"editCells":return e.editCells(...t.args);case"applyEdits":return e.applyEdits(...t.args);case"applyOps":return e.applyOps(...t.args);case"propose":return e.propose(...t.args);case"acceptProposal":return e.acceptProposal(...t.args);case"rejectProposal":return e.rejectProposal(...t.args);case"patchRangeStyle":return e.patchRangeStyle(...t.args);case"setNumberFormat":return e.setNumberFormat(...t.args);case"applyFormat":return e.applyFormat(...t.args);case"moveChart":return e.moveChart(...t.args);case"resizeChart":return e.resizeChart(...t.args);case"moveRange":return e.moveRange(...t.args);case"fillRange":return e.fillRange(...t.args);case"undo":return e.undo(...t.args);case"redo":return e.redo(...t.args);case"setActiveSheet":return e.setActiveSheet(...t.args)}}var bl,Cu,Ru,Fu,ar=U(()=>{"use strict";bl={beginPeerSnapshot:{lane:"interactive",reorderable:!1},pullPeerSnapshot:{lane:"interactive",reorderable:!1},endPeerSnapshot:{lane:"interactive",reorderable:!1},preview:{lane:"input",reorderable:!1},attachPeer:{lane:"input",reorderable:!1},detachPeer:{lane:"input",reorderable:!1},replay:{lane:"input",mutates:!0,userInput:!0,reorderable:!1}};Cu=["expectVersion","steps","source","history","calculation"];Ru=new Set(["gray125","gray0625","mediumGray","darkGray","lightGray","darkHorizontal","darkVertical","darkDown","darkUp","darkGrid","darkTrellis","lightHorizontal","lightVertical","lightDown","lightUp","lightGrid","lightTrellis"]),Fu=new Set(["Thin","Medium","Thick","Dashed","Dotted","Double","Hair","MediumDashed","DashDot","MediumDashDot","DashDotDot","MediumDashDotDot","SlantDashDot"])});function Wu(e,t){if(!dl(e,Number.MAX_SAFE_INTEGER,{validCursor:nr,optionKeys:Ou}))return!1;let n=t?.get(e.provider);for(let r of e.ops){if(r.op==="create"&&n===void 0&&(n=r.options.maxFrameBytes??Se,!Number.isSafeInteger(n)||n<=0)||r.op==="event"&&r.event.type==="message"&&r.event.data.byteLength>(n??Se))return!1;r.op==="destroy"&&(n=void 0)}return!0}function Fe(e){if(!e||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function Ge(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function Ke(e){return typeof e=="number"&&Number.isFinite(e)}function Mu(e){let t=1e6,n=16777216,r=new Set,o=(s,i)=>{if(--t<0||i>64)return!1;if(typeof s=="string")return n-=s.length,n>=0;if(s==null||typeof s=="boolean")return!0;if(typeof s=="number")return Ke(s);if(!Array.isArray(s)&&!Fe(s)||r.has(s))return!1;r.add(s);let l=!0;if(Array.isArray(s)){if(s.length>t)l=!1;else for(let a=0;a<s.length;a++)if(!Object.prototype.hasOwnProperty.call(s,a)||!o(s[a],i+1)){l=!1;break}}else for(let a in s)if(n-=a.length,n<0||!o(s[a],i+1)){l=!1;break}return r.delete(s),l};return o(e,0)}function Io(e){return Fe(e)&&Ge(e.row)&&Ge(e.col)}function ut(e){return Fe(e)&&typeof e.sheetId=="string"&&Fe(e.range)&&(e.range.kind==="a1"?typeof e.range.a1=="string":e.range.kind==="rowCol"&&Io(e.range.start)&&Io(e.range.end))}function kl(e){return ut(e)&&Fe(e)&&(e.activeCell===void 0||Io(e.activeCell))}function pt(e){return Fe(e)&&Ge(e.sheet)&&Ge(e.generation)&&(e.requestGeneration===void 0||Ge(e.requestGeneration))&&Ke(e.zoom)&&e.zoom>0&&Ke(e.dpr)&&e.dpr>0&&Fe(e.viewport)&&Ke(e.viewport.x)&&Ke(e.viewport.y)&&Ke(e.viewport.width)&&e.viewport.width>0&&Ke(e.viewport.height)&&e.viewport.height>0}function Uo(e){if(!Fe(e)||typeof e.session!="string"||typeof e.incarnation!="string"||!Ge(e.seq)||e.seq===0||!Fe(e.basis)||!Ge(e.basis.epoch)||typeof e.basis.version!="string"||e.afterSeq!==void 0&&(!Ge(e.afterSeq)||e.afterSeq===0||e.afterSeq>=e.seq))throw new TypeError("Malformed workbook command envelope")}function Sl(e,t){let n=e.payload,{frame:r}=e,o=Fe(n)&&(n.selection===void 0||kl(n.selection));if(o&&Fe(n))if(o=(n.inputTime===void 0||Ke(n.inputTime))&&(n.undoGroupId===void 0||typeof n.undoGroupId=="string")&&(n.target===void 0||ut(n.target)),e.kind==="setActiveSheet"&&n.expectVersion!==void 0&&(o&&=typeof n.expectVersion=="string"),e.kind==="select")o&&=kl(n.selection);else if(e.kind==="collabPipe")o&&=Wu(n,t);else if(e.kind==="applyUpdate")o&&=n.update instanceof Uint8Array&&(n.updates===void 0||Array.isArray(n.updates)&&n.updates.every(s=>s instanceof Uint8Array));else if(e.kind==="setReadOnly")o&&=typeof n.readOnly=="boolean"&&(n.allowHostProposals===void 0||typeof n.allowHostProposals=="boolean");else if(e.kind==="applyOps"&&"toolbar"in n)o&&=!("args"in n)&&Fe(n.toolbar)&&(n.toolbar.id==="refreshProposals"?n.toolbar.target===void 0:ut(n.toolbar.target))&&ul(n.toolbar.id,n.toolbar.args);else if(e.kind==="applyFormat"&&"formatToken"in n)o&&=!("args"in n)&&!("capturedFrom"in n)&&ut(n.target)&&typeof n.formatToken=="string"&&n.formatToken.length>0;else if(e.kind==="applyFormat"&&"capturedFrom"in n)o&&=ut(n.target)&&ut(n.capturedFrom);else{if(e.kind==="applyOps"||e.kind==="propose"){let s=Array.isArray(n.args)?n.args[e.kind==="applyOps"?0:2]:void 0;o&&=Array.isArray(s)&&s.every(i=>Fe(i)&&(i.target===void 0||ut(i.target)))}try{if(e.kind==="applyEdits"&&!Mu(n.args))throw new H("invalid-command");an({sequence:e.seq,calculation:n.calculation??{nowSerial:0,randSeed:0},op:{method:e.kind,args:n.args}})}catch(s){if(e.kind!=="applyEdits"&&(!(s instanceof Error)||s.name!=="WorkbookReplayValidationError"))throw s;o=!1}}if(r!==void 0&&(o&&=pt(r)),!o)throw new H("invalid-command")}var Ou,H,on=U(()=>{"use strict";ir();ct();Wo();ar();Ou=new Set(["maxFrameBytes","maxMessagesPerFrame","user"]);H=class extends Error{constructor(n,r){super(n);this.reason=n;this.result=r;this.name="WorkbookCommandRefusal"}reason;result}});function Ye(e,t,n,r=!1){let o=i=>{let l=n[t.indexOf(i)];if(r&&l===void 0)throw new H("target-sheet-missing");return l??i},s=i=>Array.isArray(i)?i.map(s):!i||typeof i!="object"?i:Object.fromEntries(Object.entries(i).map(([l,a])=>[l,l==="sheetId"&&typeof a=="string"?o(a):(l==="sheetIds"||l==="changedSheets")&&Array.isArray(a)?a.map(o):s(a)]));return s(e)}function Bu(e){let t="";for(let n=e+1;n>0;n=Math.floor((n-1)/26))t=String.fromCharCode(65+(n-1)%26)+t;return t}function Qe(e){if(!Number.isSafeInteger(e.row)||e.row<0||e.row>=1048576||!Number.isSafeInteger(e.col)||e.col<0||e.col>=16384)throw new H("missing-target");return`${Bu(e.col)}${e.row+1}`}function cn(e){if(e.kind==="rowCol"){if(Qe(e.start),Qe(e.end),e.start.row>e.end.row||e.start.col>e.end.col)throw new H("missing-target");return{start:e.start,end:e.end}}let t=/^\$?([A-Za-z]+)\$?([1-9]\d*)(?::\$?([A-Za-z]+)\$?([1-9]\d*))?$/.exec(e.a1);if(!t)throw new H("missing-target");let n=(r,o)=>{let s=0;for(let l of r.toUpperCase())s=s*26+l.charCodeAt(0)-64;let i={row:Number(o)-1,col:s-1};return Qe(i),i};return cn({kind:"rowCol",start:n(t[1],t[2]),end:n(t[3]??t[1],t[4]??t[2])})}function be(e,t,n=e.sheetInfo().sheetIds){let r=n.indexOf(t.sheetId);if(r<0)throw new H("target-sheet-missing");let{start:o,end:s}=cn(t.range);return{sheet:r,start:o,end:s,range:`${Qe(o)}:${Qe(s)}`}}function vl(e,t,n){let{start:r,end:o}=be(e,n,t.sheetIds);if(n.activeCell&&(Qe(n.activeCell),n.activeCell.row<r.row||n.activeCell.row>o.row||n.activeCell.col<r.col||n.activeCell.col>o.col))throw new H("missing-target")}function dn(e,t,n,r=e.sheetInfo().sheetIds){let o=r[t];if(o===void 0)throw new H("missing-target");let s={sheetId:o,range:n};return be(e,s,r),s}function _l(e,t,n,r,o=e.sheetInfo().sheetIds){return dn(e,t,{kind:"rowCol",start:{row:n,col:r},end:{row:n,col:r}},o)}function Bo(e,t,n){if(!t.editableSheets||t.catalogDirty){let p=e.readCells({ranges:[]});if(!p.ok)throw new Error(p.failure.message);t.editableSheets=p.sheets.map(y=>y.editable)}let r=e.version(),o=new TextEncoder,s=o.encode(JSON.stringify({expectVersion:r,steps:[]})).length,i=[],l=0,a=0,f=s,d=()=>{if(i.length===0)return;let p=e.validateEdits({expectVersion:r,steps:i});if(!p.ok)throw new H(p.failure.code,p);i=[],l=a=0,f=s};for(let p of n){let{start:y,end:k}=cn(p.target.range),u=(k.row-y.row+1)*(k.col-y.col+1),h=p.op==="setCellInputs"?p.inputs.flat().reduce((P,L)=>P+L.length,0):0,C=t.editableSheets[be(e,p.target,t.info?.sheetIds).sheet]?{op:"patchStyle",target:p.target,patch:{}}:p,v=o.encode(JSON.stringify(C)).length+1;if((i.length===Uu||l+u>At.cells||a+h>cr||f+v>xl)&&d(),u>At.cells||h>cr||f+v>xl)throw new H("limit-exceeded");i.push(C),l+=u,a+=h,f+=v}d()}function Cl(e,t,n=e.sheetInfo().sheetIds){let r=new Map;for(let l of t)_l(e,l.sheet,l.row,l.col,n),r.set(`${l.sheet}:${l.row}:${l.col}`,l);let o=[...r.values()].sort((l,a)=>l.sheet-a.sheet||l.row-a.row||l.col-a.col),s=[],i=new Map;for(let l=0;l<o.length;){let a=o[l++],f=a,d=[a.input],p=a.input.length;for(;l<o.length&&o[l].sheet===a.sheet&&o[l].row===a.row&&o[l].col===f.col+1&&d.length<At.cells&&p+o[l].input.length<=cr;)f=o[l++],d.push(f.input),p+=f.input.length;let y=`${a.sheet}:${a.col}:${f.col}`,k=i.get(y);if(k?.step.target.range.kind==="rowCol"&&k.step.target.range.end.row===a.row-1&&k.cells+d.length<=At.cells&&k.text+p<=cr)k.step.target.range.end.row=a.row,k.step.inputs.push(d),k.cells+=d.length,k.text+=p;else{let u={op:"setCellInputs",target:dn(e,a.sheet,{kind:"rowCol",start:{row:a.row,col:a.col},end:{row:a.row,col:f.col}},n),inputs:[d]};s.push(u),i.set(y,{step:u,cells:d.length,text:p})}}return s}function qo(e,t,n){try{return e.captureFormat(t,n)}catch(r){throw r instanceof Error&&!ue(r)&&/^sheet \d+ is not an editable worksheet$/.test(r.message)?new H("unsupported"):r}}function dr(e,t,n){let r=be(e,dn(e,t,{kind:"a1",a1:n})),o=e.readCells({ranges:[]});if(!o.ok)throw new Error(o.failure.message);if(!o.sheets[t].editable)throw qo(e,t,"A1"),new H("locked-target");if((r.end.row-r.start.row+1)*(r.end.col-r.start.col+1)>1e5)throw new H("limit-exceeded")}function Du(e,t){if(t.end.row<Ea-1&&t.end.col<Ta-1)return t;let n=e.selectionData(t.sheet,0,0,"usedRange").usedRange;if(!n)return null;let r={row:Math.max(t.start.row,n.top),col:Math.max(t.start.col,n.left)},o={row:Math.min(t.end.row,n.bottom),col:Math.min(t.end.col,n.right)};return r.row>o.row||r.col>o.col?null:{...t,start:r,end:o,range:`${Qe(r)}:${Qe(o)}`}}function qu(e,t,n){if(n.kind==="select"||n.kind==="setReadOnly"||n.kind==="applyUpdate"||n.kind==="collabPipe")throw new H("invalid-command");let r=n.payload;if(n.kind==="applyOps"&&"toolbar"in r){let{toolbar:i}=r;if(!i.target)throw new H("invalid-command");let l=be(e,i.target,t.sheetIds),a=i.id==="clear"?Du(e,l):l;if(!a)return{method:"editCells",args:[l.sheet,[]]};if(i.id==="clear"&&(a.end.row-a.start.row+1)*(a.end.col-a.start.col+1)>At.cells)throw new H("limit-exceeded");i.id!=="clear"&&dr(e,a.sheet,a.range);let f=i.id==="clear"?{}:e.selectionFormatting(a.sheet,a.range),d=i.id==="merge"?e.mergedRanges(a.sheet,a.range):[],p=pl(i,a,f,d);if(!p)throw new H("invalid-command");return p}if(n.kind==="applyFormat"&&"formatToken"in r){let i=t.formats.get(r.formatToken);if(!i)throw new H("invalid-command");let l=be(e,r.target,t.sheetIds);return{method:"applyFormat",args:[l.sheet,l.range,i]}}if(n.kind==="applyFormat"&&"capturedFrom"in r){let i=be(e,r.target,t.sheetIds),l=be(e,r.capturedFrom,t.sheetIds);if((l.end.row-l.start.row+1)*(l.end.col-l.start.col+1)>1e5)throw new H("limit-exceeded");return{method:"applyFormat",args:[i.sheet,i.range,qo(e,l.sheet,l.range)]}}if(!("args"in r))throw new H("invalid-command");let o={method:n.kind,args:[...r.args],calculation:r.calculation},s=()=>{if(t.bases.get(n.basis.version)!==t.sheetRevision)throw new H("stale-target")};if(o.method==="applyOps"){let i=[...t.sheetIds],l=t.nextSheetId;return o.args[0]=o.args[0].map(a=>{let{target:f=r.target,...d}=a;if(f){let p=be(e,f,i);if(d.type==="removeSheet")d.index=p.sheet;else if(d.type==="moveSheet")d.from=p.sheet;else if("sheet"in d)d.sheet=p.sheet;else throw new H("invalid-command")}else if(("sheet"in d||"index"in d||typeof d.scope=="number"||d.type==="moveSheet"||d.type==="setDefinedNames"||d.type==="restoreSheet"||d.type==="setTables")&&(s(),i.length!==t.sheetIds.length||i.some((p,y)=>p!==t.sheetIds[y])))throw new H("stale-target");if(d.type==="addSheet")i.splice(d.index,0,`command-sheet:${l++}`);else if(d.type==="removeSheet")i.splice(d.index,1);else if(d.type==="moveSheet"){let[p]=i.splice(d.from,1);i.splice(d.to,0,p)}return d}),o}if(o.method==="propose")return o.args[2]=o.args[2].map(i=>{let{target:l=r.target,...a}=i;return l?a.sheet=be(e,l,t.sheetIds).sheet:s(),a}),o;if(r.target){let i=be(e,r.target,t.sheetIds);switch(o.method){case"editCell":if(i.start.row!==i.end.row||i.start.col!==i.end.col)throw new H("invalid-command");o.args=[i.sheet,i.start.row,i.start.col,o.args[3]];break;case"editCells":o.args[0]=i.sheet;break;case"patchRangeStyle":case"setNumberFormat":case"applyFormat":o.args[0]=i.sheet,o.args[1]=i.range;break;case"setActiveSheet":o.args[0]=i.sheet;break;case"moveChart":case"resizeChart":case"moveRange":case"fillRange":o.args[0]=i.sheet;break;default:throw new H("invalid-command")}}else["editCell","editCells","patchRangeStyle","setNumberFormat","applyFormat","setActiveSheet","moveChart","resizeChart","moveRange","fillRange"].includes(o.method)&&s();return o}function zu(e,t,n){switch(n.method){case"applyEdits":if(n.args[0].expectVersion!==e.version())throw new H("stale-version");for(let r of n.args[0].steps)be(e,r.target,t.sheetIds);n.args[0]=Ye(n.args[0],t.sheetIds,e.sheetInfo().sheetIds);break;case"editCell":{let[r,o,s,i]=n.args;Bo(e,t,[{op:"setCellInputs",target:_l(e,r,o,s,t.info?.sheetIds),inputs:[[i]]}]);break}case"editCells":{let[r,o]=n.args;Bo(e,t,Cl(e,o.map(s=>({...s,sheet:r})),t.info?.sheetIds));break}case"applyOps":for(let r of n.args[0]){let o=r,s=o.type==="setColWidth"?o.width:o.type==="setRowHeight"?o.height:void 0,i=o.type==="setColWidth"?255:409.5;if(s!=null&&(typeof s!="number"||!Number.isFinite(s)||s<0||s>i))throw new H("invalid-step")}break;case"patchRangeStyle":case"setNumberFormat":dr(e,n.args[0],n.args[1]);break;case"propose":if(!e.isProposalsAvailable())throw new H("unsupported");Bo(e,t,Cl(e,n.args[2],t.info?.sheetIds));break;case"acceptProposal":if(!e.isProposalsAvailable())throw new H("unsupported");if(!e.listProposals().some(r=>r.id===n.args[0]))throw new H("missing-target");break;case"applyFormat":if(dr(e,n.args[0],n.args[1]),n.args[2].rows===0||n.args[2].columns===0||n.args[2].formats.length!==n.args[2].rows*n.args[2].columns)throw new H("invalid-command");break;case"setActiveSheet":case"moveChart":case"resizeChart":case"moveRange":dn(e,n.args[0],{kind:"a1",a1:"A1"});break;case"fillRange":{let[r,o,s]=n.args,i=dn(e,r,{kind:"a1",a1:o});be(e,{sheetId:i.sheetId,range:{kind:"a1",a1:s}},t.sheetIds);let l=cn({kind:"a1",a1:o}),a=cn({kind:"a1",a1:s});if(l.start.row!==a.start.row||l.start.col!==a.start.col||a.end.row<l.end.row||a.end.col<l.end.col)throw new H("invalid-step");if((a.end.row-a.start.row+1)*(a.end.col-a.start.col+1)>At.cells)throw new H("limit-exceeded");break}}}function Xu(e){if(/^(?:chart |anchor \d+ of )/.test(e)||e==="range move cannot safely preserve charts"||e==="fill cannot safely preserve charts anchored in the filled range")return"chart";if(e==="range move cannot safely preserve Excel tables"||e==="fill cannot safely preserve Excel tables"||/^cannot move sheet \d+ tracks: table .+ covers the moved tracks$/.test(e))return"table";if(e==="fill cannot safely preserve hyperlinks"||e==="fill cannot safely preserve comments"||e==="fill cannot safely preserve data validations"||e==="fill cannot safely preserve conditional formats")return"fill";let t=/^(.+?) references cells this (?:edit would move|move would relocate), and it cannot be rewritten$/.exec(e)?.[1].toLowerCase().replace(/^\//,"");return t?t.startsWith("xl/charts/")||t.startsWith("xl/drawings/")?"chart":t.startsWith("xl/tables/")?"table":t.startsWith("xl/pivottables/")||t.startsWith("xl/pivotcache/")?"pivot":"other":"other"}function lr(e){let t={failure:{code:"unsupported",cause:Xu(e),message:e}};return new H("unsupported",t)}function Pl(e,t){if(e instanceof H)return e;if(t==="acceptProposal"&&e instanceof Me)return new H("stale-proposal",{cells:e.cells,targets:e.targets});if(!(!(e instanceof Error)||ue(e))){if(/^(?:[A-Z]+[1-9]\d* is locked on protected sheet |sheet [\s\S]+ is protected$)/.test(e.message))return new H("locked-target",{ok:!1,failure:{code:"locked-target",message:e.message}});if(t==="applyOps"&&(e.message==="structural operations are unavailable in collaborative mode"||e.message==="collaborative sheets can only be added at the end of the workbook"))return new H("unsupported");if(e.message==="calculation context is unavailable for collaborative workbooks")return new H("unsupported");if(t==="undo"&&e.message==="undo would remove a sheet that holds collaborators' edits")return new H("unsupported");if(["applyOps","patchRangeStyle","setNumberFormat","applyFormat","propose","acceptProposal"].includes(t??"")&&e.message==="number format table is full")return new H("limit-exceeded");if(t==="applyOps"&&(e.message==="invalid collaborative workbook state: too many sheet merge edits"||e.message==="invalid collaborative workbook state: too many sheet hyperlink edits"))return new H("limit-exceeded");if(t==="applyOps"&&(/^formula at sheet \d+, [A-Z]+[1-9]\d* cannot be safely rewritten$/.test(e.message)||/^(?:defined name|chart reference in) .+ cannot be safely rewritten$/.test(e.message)||/^.+ references cells this edit would move, and it cannot be rewritten$/.test(e.message)||/^anchor \d+ of .+ is held by two sheets that disagree on where it sits$/.test(e.message)||/^chart .+ cannot change how it follows a grid edit$/.test(e.message)||/^chart .+ cannot be resized: a one-cell extent is not written back$/.test(e.message)||/^chart .+ cannot change its anchor kind$/.test(e.message)||/^cannot move sheet \d+ tracks: .+$/.test(e.message))||t==="resizeChart"&&/^(?:chart .+ is pinned to the sheet and cannot be resized|chart .+ cannot be resized: a one-cell extent is not written back|chart .+ cannot be resized to that size)$/.test(e.message)||t==="moveRange"&&(/^range move cannot safely preserve .+$/.test(e.message)||/^.+ contains worksheet features a cell move cannot safely preserve$/.test(e.message)||/^.+ references cells this move would relocate, and it cannot be rewritten$/.test(e.message))||t==="fillRange"&&/^fill cannot safely preserve .+$/.test(e.message))return lr(e.message);if(t==="applyOps"&&/^chart frame .+ does not hold the chart part and anchor this op was recorded against; its drawing has changed$/.test(e.message))return new H("stale-target");if((t==="editCell"||t==="editCells"||t==="propose"||t==="acceptProposal"||t==="moveRange")&&/^(?:cell number must be finite|cell text exceeds Excel's length limit|formula exceeds the length limit)$/.test(e.message))return new H("invalid-step");if(t==="fillRange"&&/^(?:fill destination must start at the source's top-left cell and contain it|fill cannot copy a formula above the length limit)$/.test(e.message))return new H("invalid-step");if((t==="applyOps"||t==="patchRangeStyle"||t==="setNumberFormat"||t==="applyFormat")&&(/^(?:font family must not be empty|font size must be between 1 and 400|captured format dimensions do not match its cells)$/.test(e.message)||/^invalid color .*; expected #rrggbb$/.test(e.message)))return new H("invalid-step");if(t==="applyOps"&&(/^the anchor of .+ would leave the sheet grid$/.test(e.message)||/^defined name .+ has a formula above the length limit$/.test(e.message)||/^(?:chart reference exceeds the supported length|chart reference contains a character xml cannot carry|sheet name contains a character xml cannot carry, and the workbook references the sheet)$/.test(e.message)||/^the (?:data validation|extension data validation|extension conditional format|sparkline|extension) formulas on sheet .+ cannot follow the sheet (?:rename|removal)$/.test(e.message)))return new H("invalid-step");if((t==="applyOps"||t==="moveChart"||t==="resizeChart")&&/^(?:anchor offset is out of range|anchor extent is not positive|anchor corners are inverted or coincident|anchor cell is outside the worksheet grid|anchor extends beyond the worksheet grid)$/.test(e.message))return new H("invalid-step");if(t==="applyOps"&&/^bad ops: /.test(e.message)||t==="resizeChart"&&/^bad chart resize args: /.test(e.message)||t==="applyFormat"&&/^bad format args: /.test(e.message)||t==="editCells"&&/^bad edit args: /.test(e.message)||t==="moveRange"&&/^bad (?:move range args|range|move destination): /.test(e.message)||t==="fillRange"&&/^bad (?:fill args|range): /.test(e.message)||t==="applyEdits"&&/^malformed request: /.test(e.message))return new H("invalid-command");if((t==="applyOps"||t==="moveChart"||t==="resizeChart"||t==="moveRange"||t==="fillRange")&&(/^(?:sheet(?: index)?|row|column) \d+ (?:is )?out of range$/.test(e.message)||/^cell row \d+, column \d+ is out of range$/.test(e.message)||/^sheet \d+ is not an editable worksheet$/.test(e.message)||/^invalid sheet name: /.test(e.message)||/^duplicate sheet name: /.test(e.message)||/^(?:row|column) operation (?:count must be positive|exceeds sheet bounds)$/.test(e.message)||/^range \d+x\d+ exceeds the \d+-cell copy cap$/.test(e.message)||/^(?:workbook has no sheets|sheet contains too many hyperlinks|hyperlink must have a destination|hyperlink field exceeds its length limit)$/.test(e.message)||/^workbook contains (?:a non-finite cell number|cell text above Excel's length limit|a formula above the length limit|an invalid cell style index|an invalid column width|an invalid row height|overlapping merged ranges)$/.test(e.message)||/^no chart frame on this sheet is named /.test(e.message)||/^chart .+ is pinned to the sheet and cannot be moved$/.test(e.message)||/^(?:row|column) insertion would (?:discard content at|push a chart anchor past) the sheet boundary$/.test(e.message)||/^(?:freeze pane is out of range|range start must be above and left of range end|restore sheet operations are internal)$/.test(e.message)))return new H("invalid-step")}}function fr(e,t,n,r,o=null){return{identity:e,epoch:t.epoch,throughSeq:0,selection:n,readOnly:!1,statuses:new Map,bases:new Map([[t.version,0]]),sheetRevision:0,historySelections:[],sheetIds:[...r],nextSheetId:r.length,calculation:o,formats:new Map}}function fn(e,t){let n=t.editState,r=!n||t.catalogDirty;(!t.info||r)&&(t.info=e.sheetInfo());let o=t.info;if(!t.editableSheets||r){let u=e.readCells({ranges:[]});if(!u.ok)throw new Error(u.failure.message);t.editableSheets=u.sheets.map(h=>h.editable)}let s=e.historyState(),i=JSON.stringify(t.selection),l=t.formattingSelection!==i,a=n?.formatting,f=n?.mergedRanges,d=n?.formattingAvailable??!1,p=n?.selectionEditable??!1;if(!a||t.formattingDirty||l){let u=be(e,t.selection,t.sheetIds),{sheet:h,start:C,end:v}=u;p=t.editableSheets[h],d=p&&(v.row-C.row+1)*(v.col-C.col+1)<=1e5,a=d?e.selectionFormatting(h,u.range):{}}if(!f||t.mergesDirty||l){let u=be(e,t.selection,t.sheetIds);f=e.mergedRanges(u.sheet,u.range)}t.formattingSelection=i,t.formattingDirty=t.mergesDirty=t.catalogDirty=!1;let y={canUndo:s.canUndo,canRedo:s.canRedo,formatting:a,formattingAvailable:d,selectionEditable:p,mergedRanges:f??[],calculation:e.calculationStatus(),sheets:r?t.sheetIds.map((u,h)=>({id:u,index:h,name:o.sheetNames[h]})):n.sheets,activeSheet:o.activeSheet,readOnly:t.readOnly,...t.historyReset?{historyReset:!0}:{}},k={};for(let u of Object.keys(y))(!n||n[u]!==y[u]&&JSON.stringify(n[u])!==JSON.stringify(y[u]))&&Object.assign(k,{[u]:y[u]});return t.editState=y,Object.keys(k).length>0?k:void 0}function Do(e,t,n){let r=e.sheetInfo();if(r.sheetIds.length===n.length&&r.sheetIds.every((s,i)=>s===n[i]))return;let o=new Map(n.map((s,i)=>[s,t.sheetIds[i]]));t.sheetIds=r.sheetIds.map(s=>o.get(s)??s),t.sheetRevision+=1,t.sheetIds.includes(t.selection.sheetId)||(t.selection={sheetId:t.sheetIds[r.activeSheet],range:{kind:"a1",a1:"A1"}})}function Ju(e,t,n,r){if(Sl(n,t.pipeFrameBytes),n.frame&&n.frame.sheet>=e.sheetCount())throw new H("missing-target");if(n.kind==="collabPipe"){if(!r)throw new H("unsupported");let P=e.version(),L=e.sheetInfo().sheetIds;r(n.payload),Do(e,t,L);let B=t.pipeFrameBytes??=new Map;for(let V of n.payload.ops)if(V.op==="create")B.has(n.payload.provider)||B.set(n.payload.provider,V.options.maxFrameBytes??Se);else if(B.has(n.payload.provider))V.op==="destroy"&&B.delete(n.payload.provider);else break;let D=e.version()!==P;return D&&(t.formattingDirty=t.mergesDirty=t.catalogDirty=!0),{seq:n.seq,status:D?"applied":"noop",committed:D,...D?{result:{remoteUpdate:!0,proposals:e.listProposals()}}:{}}}if(n.kind==="applyUpdate"){let P=e.version(),L=e.sheetInfo().sheetIds,B=!1;for(let D of[n.payload.update,...n.payload.updates??[]]){let V=e.version();try{e.applyUpdate(D)}catch(R){if(!(R instanceof Error)||ue(R)||e.version()!==V)throw R;if(V===P)throw new H("invalid-update");B=!0;break}}return Do(e,t,L),t.formattingDirty=t.mergesDirty=t.catalogDirty=!0,{seq:n.seq,status:e.version()===P?"noop":"applied",committed:e.version()!==P,result:{remoteUpdate:!0,proposals:e.listProposals(),...B?{refusedUpdate:"invalid-update"}:{}}}}if(n.kind==="select"){vl(e,t,n.payload.selection);let P=JSON.stringify(t.selection)!==JSON.stringify(n.payload.selection);return t.selection=structuredClone(n.payload.selection),{seq:n.seq,status:P?"applied":"noop",committed:!1}}if(n.kind==="setReadOnly"){let P=t.readOnly!==n.payload.readOnly||!!t.allowHostProposals!=!!n.payload.allowHostProposals;return t.readOnly=n.payload.readOnly,t.allowHostProposals=n.payload.allowHostProposals===!0,{seq:n.seq,status:P?"applied":"noop",committed:!1}}let o=n.kind==="applyOps"&&"toolbar"in n.payload&&n.payload.toolbar.id==="refreshProposals";if(n.kind==="setActiveSheet"&&n.payload.expectVersion!==void 0&&n.payload.expectVersion!==e.version())throw new H("stale-version");let s=t.allowHostProposals&&(n.kind==="propose"||n.kind==="acceptProposal"||n.kind==="rejectProposal");if(t.readOnly&&!s&&n.kind!=="setActiveSheet"&&!o)throw new H("read-only");if(n.payload.selection&&vl(e,t,n.payload.selection),o)return{seq:n.seq,status:"applied",committed:!1,result:{proposals:e.listProposals()}};if(n.kind==="applyOps"&&"toolbar"in n.payload&&n.payload.toolbar.id==="paintFormat"){let{target:P}=n.payload.toolbar;if(!P)throw new H("invalid-command");let L=be(e,P,t.sheetIds);dr(e,L.sheet,L.range);let B=qo(e,L.sheet,L.range),D=globalThis.crypto.getRandomValues(new Uint8Array(16)),V=`format:${Array.from(D,J=>J.toString(16).padStart(2,"0")).join("")}`;t.formats.set(V,B),t.formats.size>Iu&&t.formats.delete(t.formats.keys().next().value),n.payload.selection&&(t.selection=structuredClone(n.payload.selection));let R={formatToken:V};return{seq:n.seq,status:"applied",committed:!1,result:R}}let i=qu(e,t,n);if(zu(e,t,i),i.method==="setActiveSheet"&&n.payload.selection&&t.sheetIds[i.args[0]]!==n.payload.selection.sheetId)throw new H("invalid-command");let l=e.version(),a=t.info?.activeSheet??e.sheetInfo().activeSheet,f=e.historyState(),d=structuredClone(t.selection),p=[...t.sheetIds],y=t.collaborative&&(i.method==="undo"||i.method==="redo"||i.method==="applyOps"&&i.args[0].some(P=>P.type==="addSheet"))?e.sheetInfo().sheetIds:void 0,k;try{i.calculation&&e.setCalculationContext(i.calculation),k=Ft(e,i)}catch(P){let L=Pl(P,i.method);throw L&&e.version()===l?(i.calculation&&e.setCalculationContext(t.calculation),L):new Z(ue(P)?"trap":"crash",`Workbook command failed at sequence ${n.seq} (${n.kind})`,P instanceof Error?P.message:String(P))}if(ln(k)){if(i.method!=="applyEdits"||e.version()!==l)throw new Z("crash","Workbook command failed after dispatch");let P=k;throw i.calculation&&e.setCalculationContext(t.calculation),new H(P.failure.code,P)}i.calculation&&(t.calculation={...i.calculation});let u=e.version()!==l,h=e.historyState();if(u&&y)Do(e,t,y);else if(u&&i.method==="applyOps")for(let P of i.args[0]){let L=P;if(L.type==="addSheet")t.sheetIds.splice(L.index,0,`command-sheet:${t.nextSheetId++}`);else if(L.type==="removeSheet")t.sheetIds.splice(L.index,1);else if(L.type==="moveSheet"){let[B]=t.sheetIds.splice(L.from,1);t.sheetIds.splice(L.to,0,B)}}if(i.method==="undo"||i.method==="redo"){if(u){let P=i.method==="undo"?f.undoDepth:h.undoDepth,L=t.historySelections[P];if(L){y||(t.sheetIds=[...i.method==="undo"?L.beforeSheets:L.afterSheets]),t.selection=structuredClone(i.method==="undo"?L.before:L.after);let B=t.sheetIds.indexOf(t.selection.sheetId);B>=0&&e.setActiveSheet(B)}}}else n.payload.selection&&(t.selection=structuredClone(n.payload.selection));if(u){if(i.method==="undo"||i.method==="redo")t.formattingDirty=t.mergesDirty=!0,t.catalogDirty=!0;else if(i.method==="applyOps"){let P=i.args[0].map(B=>B.type),L=P.some(B=>["insertRows","deleteRows","insertCols","deleteCols","addSheet","removeSheet","moveSheet"].includes(B));t.formattingDirty=L||P.some(B=>["setCell","patchRangeStyle","setRangeNumberFormat","applyRangeFormat","restoreColStyles"].includes(B)),t.mergesDirty=L||P.some(B=>["mergeCells","unmergeCells"].includes(B)),t.catalogDirty=P.some(B=>["addSheet","removeSheet","moveSheet","renameSheet"].includes(B))}else(i.method==="patchRangeStyle"||i.method==="setNumberFormat"||i.method==="applyFormat"||i.method==="acceptProposal"||i.method==="moveRange"||i.method==="fillRange"||i.method==="applyEdits"&&i.args[0].steps.some(P=>P.op==="patchStyle"||P.op==="setNumberFormat"))&&(t.formattingDirty=!0);(p.length!==t.sheetIds.length||p.some((P,L)=>P!==t.sheetIds[L]))&&(t.sheetRevision+=1)}let C=!t.info||t.catalogDirty||i.method==="setActiveSheet"||i.method==="undo"||i.method==="redo"?e.sheetInfo():t.info;if(t.info=C,(!t.sheetIds.includes(t.selection.sheetId)||i.method==="setActiveSheet"&&!n.payload.selection&&a!==C.activeSheet)&&(t.selection={sheetId:t.sheetIds[C.activeSheet],range:{kind:"a1",a1:"A1"}}),i.method!=="undo"&&i.method!=="redo"&&u&&h.undoDepth>f.undoDepth){t.historySelections.length>f.undoDepth+1&&(t.historySelections.length=f.undoDepth+1);let P=structuredClone(t.selection);if(i.method==="editCell"){let[L,B,D]=i.args;P={sheetId:t.sheetIds[L],activeCell:{row:B,col:D},range:{kind:"rowCol",start:{row:B,col:D},end:{row:B,col:D}}}}t.historySelections[h.undoDepth]={before:d,after:P,beforeSheets:p,afterSheets:[...t.sheetIds]}}let v=i.method==="setActiveSheet"?a!==C.activeSheet||JSON.stringify(d)!==JSON.stringify(t.selection):i.method==="propose"||i.method==="acceptProposal"||i.method==="rejectProposal"&&k===!0;return{seq:n.seq,status:u||v?"applied":"noop",committed:u,...k===void 0?{}:{result:Ye(k,C.sheetIds,t.sheetIds)}}}function Rl(e,t,n,r,o=!1,s){let i,l=n.kind==="applyUpdate"||n.kind==="collabPipe";try{if(r&&!l)throw new H(r);if(o&&!l)i={seq:n.seq,status:"cancelled",reason:"dependency-refused",committed:!1,affectedSeqs:[n.seq]};else{if(!l&&!t.bases.has(n.basis.version))throw new H("stale-basis");i=Ju(e,t,n,s)}}catch(y){let k=Pl(y);if(!k)throw y instanceof Z?y:new Z(ue(y)?"trap":"crash","Workbook command failed",y instanceof Error?y.message:String(y));i={seq:n.seq,status:"refused",reason:k.reason,committed:!1,affectedSeqs:[n.seq],...k.result===void 0?{}:{result:Ye(k.result,e.sheetInfo().sheetIds,t.sheetIds)}}}let a=e.version();if(t.bases.has(n.basis.version)){let y=t.bases.get(n.basis.version);t.bases.delete(n.basis.version),t.bases.set(n.basis.version,y)}t.bases.set(a,t.sheetRevision),t.bases.size>Nu&&t.bases.delete(t.bases.keys().next().value);let f=JSON.stringify(t.selection),d=f!==t.publishedSelection||i.status==="refused"||i.status==="cancelled"?structuredClone(t.selection):void 0;i.status!=="refused"&&i.status!=="cancelled"&&(t.publishedSelection=f);let p;try{p=fn(e,t)}catch(y){throw new Z(ue(y)?"trap":"crash","Workbook command state projection failed",y instanceof Error?y.message:String(y))}return{throughSeq:n.seq,version:a,statuses:[i],...d?{selection:d}:{},...p?{editState:p}:{}}}var Nu,Iu,Uu,At,cr,xl,ur=U(()=>{"use strict";ct();je();Pt();on();Wo();ar();Ve();Nu=256,Iu=64,Uu=128,At={cells:1e5},cr=1048576,xl=16*1024*1024});function un(e){let t=globalThis;return typeof t.structuredClone=="function"?t.structuredClone(e):Et(e,new Map)}function Et(e,t){if(typeof e=="function"||typeof e=="symbol")throw new TypeError("Unsupported command data");if(e===null||typeof e!="object")return e;if(t.has(e))return t.get(e);if(typeof Blob<"u"&&e instanceof Blob||typeof File<"u"&&e instanceof File)return t.set(e,e),e;if(ArrayBuffer.isView(e)){let r=Et(e.buffer,t),o=e.constructor,s=e instanceof DataView?new DataView(r,e.byteOffset,e.byteLength):new o(r,e.byteOffset,e.byteLength/o.BYTES_PER_ELEMENT);return t.set(e,s),s}if(typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return t.set(e,e),e;if(e instanceof ArrayBuffer){let r=e.slice(0);return t.set(e,r),r}if(e instanceof Date){let r=new Date(e.getTime());return t.set(e,r),r}if(e instanceof RegExp){let r=new RegExp(e.source,e.flags);return t.set(e,r),r}if(e instanceof Number||e instanceof String||e instanceof Boolean||Object.getPrototypeOf(e)===BigInt.prototype){let r=Object(e.valueOf());return t.set(e,r),r}if(e instanceof Map){let r=new Map;t.set(e,r);for(let[o,s]of e)r.set(Et(o,t),Et(s,t));return r}if(e instanceof Set){let r=new Set;t.set(e,r);for(let o of e)r.add(Et(o,t));return r}let n=Array.isArray(e)?new Array(e.length):{};t.set(e,n);for(let r of Object.keys(e))Object.defineProperty(n,r,{value:Et(e[r],t),enumerable:!0,configurable:!0,writable:!0});return n}var Fl=U(()=>{"use strict"});function El(e){return ju(e)&&e[Hu]===!0}function ju(e){return e!==null&&typeof e=="object"}var Al,Hu,Tl=U(()=>{"use strict";Be();Al=["read-only","stale","superseded","not-ready","busy","disposed","invalid-payload","unsupported","dependency-refused","unknown-outcome"],Hu=Symbol("session-refusal")});function Xo(e){return Ze(e)&&typeof e.session=="string"&&Je(e.incarnation)&&pn(e.seq)&&Ze(e.basis)&&Je(e.basis.epoch)&&Tt(e.basis.version)&&(e.afterSeq===void 0||pn(e.afterSeq))&&(e.expectVersion===void 0||typeof e.expectVersion=="boolean")&&typeof e.kind=="string"&&pe(e,"payload")&&(e.inputTime===void 0||Tt(e.inputTime))&&(e.lastInputTime===void 0||Tt(e.lastInputTime))&&(e.group===void 0||typeof e.group=="string")&&(e.replay===void 0||e.replay===!0)}function pr(e){return Ze(e)&&typeof e.session=="string"&&Je(e.incarnation)&&Je(e.epoch)&&Je(e.throughSeq)&&Tt(e.version)&&Array.isArray(e.outcomes)&&e.outcomes.every($u)&&(e.frame===void 0||Vu(e.frame))&&(e.revisions===void 0||Ze(e.revisions)&&Je(e.revisions.selection)&&Je(e.revisions.layout))}function Ll(e){return e instanceof Error&&e.name===zo&&Ze(e)&&Ze(e.refusal)&&pn(e.refusal.seq)}function Ze(e){return e!==null&&typeof e=="object"}function Tt(e){return typeof e=="number"&&Number.isFinite(e)}function Je(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function pn(e){return Je(e)&&e>0}function $u(e){return Ze(e)&&pn(e.seq)&&(e.status==="applied"||e.status==="noop"||e.status==="refused"||e.status==="cancelled"||e.status==="duplicate")&&(e.reason===void 0||typeof e.reason=="string")&&(e.committed===void 0||e.committed===!1)&&(e.affectedSeqs===void 0||Array.isArray(e.affectedSeqs)&&e.affectedSeqs.every(pn))}function Vu(e){return Ze(e)&&Je(e.coversThroughSeq)&&Tt(e.revision)&&(e.baseRevision===void 0||Tt(e.baseRevision))&&pe(e,"payload")}var zo,Jo=U(()=>{"use strict";Be();zo="CommandOutcomeUnknown"});function Wl(e,t){let n=new WeakMap,r=4096;function o(s,i,l){if(--r<0||l>32)return!1;if(Object.is(s,i))return!0;if(s===null||i===null||typeof s!="object"||typeof i!="object")return!1;if(n.has(s))return n.get(s)===i;if(n.set(s,i),s instanceof Date||i instanceof Date)return s instanceof Date&&i instanceof Date&&Object.is(s.getTime(),i.getTime());if(s instanceof RegExp||i instanceof RegExp)return s instanceof RegExp&&i instanceof RegExp&&s.source===i.source&&s.flags===i.flags;if(s instanceof Number||i instanceof Number||s instanceof Boolean||i instanceof Boolean||s instanceof String||i instanceof String)return s.constructor===i.constructor&&Object.is(s.valueOf(),i.valueOf());if(s instanceof ArrayBuffer||i instanceof ArrayBuffer||ArrayBuffer.isView(s)||ArrayBuffer.isView(i)){let p=u=>u instanceof ArrayBuffer?new Uint8Array(u):ArrayBuffer.isView(u)?new Uint8Array(u.buffer,u.byteOffset,u.byteLength):void 0,y=p(s),k=p(i);if(!y||!k||s.constructor!==i.constructor||y.byteLength!==k.byteLength||y.byteLength>r)return!1;r-=y.byteLength;for(let u=0;u<y.length;u+=1)if(y[u]!==k[u])return!1;return!0}if(s instanceof Map||i instanceof Map||s instanceof Set||i instanceof Set){if(s.constructor!==i.constructor||!(s instanceof Map||s instanceof Set)||!(i instanceof Map||i instanceof Set)||s.size!==i.size||s.size>r)return!1;let p=s.entries(),y=i.entries();for(let k=0;k<s.size;k+=1)if(!o(p.next().value,y.next().value,l+1))return!1;return!0}if(Array.isArray(s)!==Array.isArray(i)||Array.isArray(s)&&Array.isArray(i)&&s.length!==i.length||Object.getPrototypeOf(s)!==Object.getPrototypeOf(i)||!Array.isArray(s)&&Object.getPrototypeOf(s)!==Object.prototype&&Object.getPrototypeOf(s)!==null)return!1;let a=Object.keys(s);if(a.length>r||a.length!==Object.keys(i).length)return!1;let f=s,d=i;return a.every(p=>pe(i,p)&&o(f[p],d[p],l+1))}return o(e,t,0)}function Gu(e=[]){let t=[];function n(o){let s=0,i=t.length;for(;s<i;){let l=Math.floor((s+i)/2),a=t[l];if(o<a[0])i=l;else if(o>a[1])s=l+1;else return!0}return!1}function r(o){if(!Number.isSafeInteger(o)||o<=0)throw new TypeError("Invalid replay sequence");let s=0;for(;s<t.length&&t[s][1]<o-1;)s+=1;let i=t[s];if(i&&i[0]<=o+1){i[0]=Math.min(i[0],o),i[1]=Math.max(i[1],o);let l=t[s+1];l&&l[0]<=i[1]+1&&(i[1]=Math.max(i[1],l[1]),t.splice(s+1,1));return}if(t.length===Ku)throw new Z("out-of-memory","Command replay ledger exhausted: 4096 disjoint ranges per epoch");t.splice(s,0,[o,o])}for(let o of e)r(o);return{contains:n,add:r}}function Ml(e){return{...e,...e.affectedSeqs===void 0?{}:{affectedSeqs:[...e.affectedSeqs]}}}function Nl(e,t){let n=t instanceof Error?t.message:String(t),r={name:zo,refusal:{seq:e}},o=Object.assign(new Error(`Command ${e} has an unknown outcome: ${n}`),r);return Object.defineProperty(o,"cause",{value:t,writable:!0,configurable:!0}),o}function Qu(e){return e instanceof Error&&!(e instanceof Z)&&!ue(e)}function Lt(e){if(e instanceof Z)return e;let t=ue(e);return new Z(t?"trap":"crash",e instanceof Error?e.message:String(e))}function Il(e){let t=e.retainedOutcomes??256,{session:n,incarnation:r,epoch:o,getVersion:s,apply:i,frame:l,snapshot:a,prunedDuplicateReason:f}=e,d=e.throughSeq??0,p=s();if(!Number.isSafeInteger(t)||t<0||!Number.isSafeInteger(d)||d<0||!Number.isFinite(p)||f!==void 0&&(typeof f!="string"||f.length===0))throw new TypeError("Invalid command host ledger");let y=new Map,k=Gu(e.refusedSeqs),u=new Set(e.replayAppliedSeqs);for(let _ of u)if(!Number.isSafeInteger(_)||_<=0)throw new TypeError("Invalid replay sequence");let h,C=Promise.resolve(),v=0,P=0,L=0,B=0,D=0,V=new Map,R,J,O=!1,F=!1,x=d,g=0,c=e.queries?S():0,b=new Map;function S(){let _=e.layoutRevision?.()??0;if(!Number.isSafeInteger(_)||_<0)throw new TypeError("Invalid layout revision");return _}function W(_,N=[]){if(!(!e.checkRefusals||Al.includes(_)||N.includes(_)||["stale-epoch","stale-incarnation","wrong-session","stale-version","dependency-refused","unknown-outcome","disposed"].includes(_)))throw M(new TypeError(`Undeclared refusal: ${_}`))}function M(_){return h=_,Y(),_}function G(_){if(L===Ol&&!h&&M(new Z("out-of-memory","Command handler capacity exceeded")),h)return Promise.reject(h);L+=1;let K=C.then(()=>{if(h)throw h;return _()}).finally(()=>{L-=1,Y()});return C=K.then(()=>{},()=>{}),K}function re(_){let N=V.get(_);if(N){V.delete(_);for(let K of N)K()}}function Y(){if(!h)return;let _=h,N=[...V.values()],K=[...b.values()];V.clear(),b.clear();for(let X of N)for(let fe of X)fe();for(let X of K)for(let fe of X)fe.reject(_)}async function te(){try{let _=await l({coversThroughSeq:d,version:p});if(_===void 0)return;let N=ve(_)?_.value:_;if(!pr({session:n,incarnation:r,epoch:o,throughSeq:d,version:p,outcomes:[],frame:N})||N.coversThroughSeq!==d)throw new Error("Frame does not cover the settled command boundary");return _}catch(_){throw M(Lt(_))}}async function oe(){let _=await te();if(_===void 0)throw new Error("No frame is available at the settled command boundary");return _}function ce(_){if(_.status==="refused"||_.status==="cancelled")try{k.add(_.seq)}catch(N){throw M(Lt(N))}if(d=_.seq,t>0&&(y.set(_.seq,Ml(_)),y.size>t&&y.delete(y.keys().next().value)),b.size)for(let N of[...b.keys()].sort((K,X)=>K-X)){if(N>d)break;let K=b.get(N);if(K){b.delete(N);for(let X of K)X.start()}}return _}function me(_,N,K=!1){return{seq:_,status:K?"cancelled":"refused",reason:N,committed:!1}}function ae(_,N){let K={session:n,incarnation:r,epoch:o,throughSeq:d,version:p,outcomes:_?[Ml(_)]:[]};try{N&&pe(N,"selection")&&(!O||!(e.selectionEquals??Wl)(R,N.selection))&&(R=un(N.selection),O=!0,K.selection=un(R),e.queries&&(g+=1)),N&&pe(N,"editState")&&(!F||!(e.editStateEquals??Wl)(J,N.editState))&&(J=un(N.editState),F=!0,K.editState=un(J)),e.queries&&(c=S(),K.revisions={selection:g,layout:c})}catch(X){throw M(Lt(X))}return K}async function E(_){if(v>0||P>1)return _;try{let N=await te();if(N===void 0)return _;if(ve(N)){if(_.frame=N.value,!pr(_)||_.frame.coversThroughSeq!==d)throw new Error("Frame does not cover the settled command boundary");return he(_,N.transfer)}if(_.frame=N,!pr(_)||N.coversThroughSeq!==d)throw new Error("Frame does not cover the settled command boundary");return _}catch(N){throw M(Lt(N))}}function w(_){try{let N=s();if(!Number.isFinite(N)||N!==p)throw new Error("Version changed outside a command");return N}catch(N){throw M(Nl(_,N))}}function A(_){return Xo(_)&&_.session===n&&_.incarnation===r&&_.basis.epoch===o}async function T(_){if(!Xo(_))throw new TypeError("Invalid command envelope");if(_.session!==n)return ae(me(_.seq,"wrong-session"));if(_.incarnation!==r)return ae(me(_.seq,"stale-incarnation"));if(_.basis.epoch!==o){let ge=me(_.seq,"stale-epoch");return ae(_.seq>d?ce(ge):ge)}if(_.seq<=d)return E(ae(y.get(_.seq)??(f===void 0?{seq:_.seq,status:"duplicate"}:me(_.seq,f))));if(k.contains(_.seq))return E(ae(ce(me(_.seq,"unknown-outcome"))));if(_.afterSeq!==void 0&&k.contains(_.afterSeq))return E(ae(ce(me(_.seq,"dependency-refused",!0))));let N=_.replay===!0&&u.has(_.seq);if(e.commands){if(!pe(e.commands,_.kind))return E(ae(ce(me(_.seq,"unsupported"))));if(e.commands[_.kind].admission==="local-write"&&!N&&e.readOnly?.())return E(ae(ce(me(_.seq,"read-only"))))}let K=w(_.seq);if(_.expectVersion&&!N&&_.basis.version!==K)return E(ae(ce(me(_.seq,"stale-version"))));let X;try{if(X=await i(_,{basis:_.basis,currentVersion:K,replayPreviouslyApplied:N}),!X||typeof X!="object"||X.status!=="applied"&&X.status!=="noop"&&X.status!=="cancelled"&&X.status!=="refused"||X.status==="applied"&&X.committed!==void 0&&X.committed!==!1||X.status==="cancelled"&&X.reason!==void 0&&typeof X.reason!="string")throw new Error("Invalid format apply result");let ge=s();if(!Number.isFinite(ge)||(X.status==="applied"&&X.committed!==!1?ge<=K:ge!==K))throw new Error(`${X.status} violated the command version contract`);p=ge}catch(ge){throw M(Nl(_.seq,ge))}X.status==="refused"&&W(X.reason,e.commands?.[_.kind]?.refusals);let fe=X.status==="refused"?{...me(_.seq,X.reason),...X.affectedSeqs===void 0?{}:{affectedSeqs:X.affectedSeqs}}:X.status==="cancelled"?{seq:_.seq,status:"cancelled",committed:!1,...X.reason===void 0?{}:{reason:X.reason}}:X.status==="applied"&&X.committed===!1?{seq:_.seq,status:"applied",committed:!1}:{seq:_.seq,status:X.status},xe=ae(ce(fe),X);return X.status==="noop"&&e.deferFrame?.(_,X)?xe:E(xe)}let I={lane:"input",mutates:!0,reframes:!0,reorderable:!1};function z(_,N){return{ok:!1,refusal:{code:_,...N===void 0?{}:{detail:N}}}}function we(_){return!!_&&typeof _=="object"&&typeof _.session=="string"&&[_.incarnation,_.epoch,_.afterSeq].every(N=>Number.isSafeInteger(N)&&N>=0)}function ie(_,N,K){return G(async()=>{let X;try{X=await e.queries.handlers[N](K,_)}catch(xe){if(xe instanceof Z||ue(xe))throw M(Lt(xe));return z("invalid-payload",xe instanceof Error?xe.message:String(xe))}if(El(X))return W(X.refusal.code,e.queries.specs[N].refusals),{ok:!1,refusal:X.refusal};let fe={ok:!0,value:ve(X)?X.value:X,at:{incarnation:r,epoch:o,throughSeq:d,doc:p,selection:g,layout:S()}};return ve(X)?he(fe,X.transfer):fe})}return{handler(_,N){let K=A(N),X=K&&v>0;K&&(x=Math.max(x,N.seq),v=Math.max(0,v-1),P+=1);let fe=G(()=>T(N));return X&&re(++B),Y(),fe.finally(()=>{K&&(P-=1),Y()})},policy(_){return A(_)&&(v+=1,x=Math.max(x,_.seq)),{...I}},query(_,N,K,X){return h?Promise.reject(h):!we(N)||typeof K!="string"||!Array.isArray(X)?Promise.resolve(z("invalid-payload")):N.session!==n||N.incarnation!==r||N.epoch!==o||N.afterSeq>x?Promise.resolve(z("stale")):!e.queries||!pe(e.queries.specs,K)||!pe(e.queries.handlers,K)?Promise.resolve(z("unsupported")):d>=N.afterSeq?ie(_,K,X):Bt(new Promise((fe,xe)=>{let ge=b.get(N.afterSeq);ge||b.set(N.afterSeq,ge=[]),ge.push({start:()=>{ie(_,K,X).then(fe,xe)},reject:xe})}))},queryPolicy(_,N,K){return{lane:"interactive",reorderable:(e.queries&&pe(e.queries.specs,N)?e.queries.specs[N]:void 0)?.stale!=="answer-at-fence"}},revise(_){if(h)throw h;let N=p,K=c;p=s();let X=ae(void 0,_);return p!==N||c!==K||pe(X,"selection")||pe(X,"editState")?X:void 0},checkpoint(_){return G(async()=>{let N;try{let K=s();if(K!==p)throw new Error("Version changed before checkpoint");let X;try{X=(await a()).slice()}catch(fe){throw s()===K&&Qu(fe)&&(N=fe),fe}if(s()!==K)throw new Error("Snapshot changed the command version");return he({state:X,epoch:o,version:p,throughSeq:d},[X.buffer])}catch(K){throw N||M(Lt(K))}})},checkpointPolicy(){return{lane:"input",reorderable:!1}},frame(){return D===Ol&&!h&&M(new Z("out-of-memory","Command frame capacity exceeded")),h?(Y(),Promise.reject(h)):v===0?G(oe):(D+=1,new Promise((_,N)=>{let K=B+v,X=V.get(K);X||V.set(K,X=[]),X.push(()=>{D-=1,G(oe).then(_,N)})}))}}}var Ku,Ol,Ul=U(()=>{"use strict";Be();je();Fl();Tl();Jo();Ve();Ku=4096,Ol=4096});function ql(e){let t=()=>{throw new TypeError("Unsupported workbook recovery checkpoint")};return e.length<42||!Ho.every((n,r)=>e[r]===n)||e[8]!==Yu||e[41]>1?t():e[41]===1}function mr(e,t=2166136261){for(let n of e)t=Math.imul(t^n,16777619);return t>>>0}function zl(e,t,n,r,o=[],s={version:n,dirty:n>0},i=Bl,l={}){i.capture(t);let a=[];for(let k of[...o].sort((u,h)=>u-h)){let u=a[a.length-1];u&&k<=u[1]+1?u[1]=Math.max(u[1],k):a.push([k,k])}let f={session:t.identity.session,epoch:t.epoch,throughSeq:t.throughSeq,revision:n,engineVersion:r.find(([k])=>k===n)[1],versions:r,bases:[...t.bases],refusedSeqs:o,refusedRanges:l.refusedRanges??a,refusedOutcomes:l.refusedOutcomes??[],statuses:[...t.statuses],selection:t.selection,readOnly:t.readOnly,allowHostProposals:t.allowHostProposals===!0,sheetIds:t.sheetIds,nextSheetId:t.nextSheetId,sheetRevision:t.sheetRevision,calculation:t.calculation,formats:[...t.formats],hostVersion:s.version,dirty:s.dirty,...l.historySelections?{historySelections:l.historySelections}:{}},d=new TextEncoder().encode(JSON.stringify(f));if(d.length>4294967295||e.length===0||e.length>4294967295)throw new RangeError("Workbook recovery checkpoint size is out of range");let p=new Uint8Array(Ie+d.length+e.length),y=new DataView(p.buffer);return p.set(Ho),y.setUint8(8,Dl),y.setUint32(9,d.length,!0),y.setUint32(13,e.length,!0),p.set(d,Ie),p.set(e,Ie+d.length),y.setUint32(17,mr(p.subarray(Ie),mr(p.subarray(0,17))),!0),p}function Xl(e){let t=()=>{throw new TypeError("Invalid workbook recovery checkpoint")};(e.length<Ie||!Ho.every((u,h)=>e[h]===u))&&t();let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(9,!0),o=n.getUint32(13,!0);(n.getUint8(8)!==Dl||r===0||o===0||Ie+r+o!==e.length||mr(e.subarray(Ie),mr(e.subarray(0,17)))!==n.getUint32(17,!0))&&t();let s=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e.subarray(Ie,Ie+r))),i=e.subarray(Ie+r),l=u=>typeof u=="number"&&Number.isSafeInteger(u)&&u>=0,a=(u,h,C)=>Array.isArray(u)&&u.length<=256&&u.every(v=>Array.isArray(v)&&v.length===2&&h(v[0])&&C(v[1]))&&new Set(u.map(v=>v[0])).size===u.length,f=u=>typeof u=="string"&&u.length>0,d=u=>{if(u===null)return!0;if(!u||typeof u!="object")return!1;let h=u,C=(v,P)=>v&&v.range&&Array.isArray(P)&&P.length>0&&P.every(f)&&new Set(P).size===P.length&&P.includes(v.sheetId);return!!(C(h.before,h.beforeSheets)&&C(h.after,h.afterSheets))},p=u=>{if(!u||typeof u!="object")return!1;let h=u;return l(h.seq)&&h.seq>0&&(h.status==="refused"||h.status==="cancelled")&&f(h.reason)&&h.committed===!1&&(h.affectedSeqs===void 0||Array.isArray(h.affectedSeqs)&&h.affectedSeqs.every(C=>l(C)&&C>0))},y=u=>{if(!u||typeof u!="object")return!1;let h=u;return l(h.seq)&&h.seq>0&&["applied","noop","refused","cancelled"].includes(h.status??"")&&typeof h.committed=="boolean"&&(h.affectedSeqs===void 0||Array.isArray(h.affectedSeqs)&&h.affectedSeqs.every(l))&&(h.reason===void 0||f(h.reason))},k=u=>{if(!u||typeof u!="object")return!1;let h=u;return l(h.rows)&&h.rows>0&&l(h.columns)&&h.columns>0&&h.rows*h.columns<=1e5&&Array.isArray(h.formats)&&h.formats.length===h.rows*h.columns};return(!s||!f(s.session)||!f(s.engineVersion)||!l(s.epoch)||s.epoch===0||![s.throughSeq,s.revision,s.hostVersion,s.sheetRevision,s.nextSheetId].every(l)||typeof s.readOnly!="boolean"||typeof s.dirty!="boolean"||s.allowHostProposals!==void 0&&typeof s.allowHostProposals!="boolean"||!Array.isArray(s.sheetIds)||s.sheetIds.length===0||!s.sheetIds.every(f)||new Set(s.sheetIds).size!==s.sheetIds.length||s.sheetIds.some(u=>u.startsWith("command-sheet:")&&(!l(Number(u.slice(14)))||Number(u.slice(14))>=s.nextSheetId))||!a(s.versions,l,f)||!a(s.bases,f,l)||!s.versions.some(([u,h])=>u===s.revision&&h===s.engineVersion)||!s.bases.some(([u])=>u===s.engineVersion)||!Array.isArray(s.refusedSeqs)||s.refusedSeqs.length>256||new Set(s.refusedSeqs).size!==s.refusedSeqs.length||!s.refusedSeqs.every(u=>l(u)&&u>0&&u<=s.throughSeq)||!Array.isArray(s.refusedRanges)||s.refusedRanges.length>4096||!s.refusedRanges.every((u,h,C)=>{if(!Array.isArray(u)||u.length!==2||!l(u[0])||!l(u[1])||u[0]===0||u[0]>u[1]||u[1]>s.throughSeq)return!1;let v=C[h-1];return h===0||Array.isArray(v)&&v[1]<u[0]-1})||!s.refusedSeqs.every(u=>s.refusedRanges.some(([h,C])=>u>=h&&u<=C))||!a(s.statuses,l,y)||!s.statuses.every(([u,h])=>u===h.seq&&u<=s.throughSeq&&s.refusedSeqs.includes(u)===(h.status==="refused"||h.status==="cancelled"))||!s.statuses.every(([u,h])=>s.refusedRanges.some(([C,v])=>u>=C&&u<=v)===(h.status==="refused"||h.status==="cancelled"))||!a(s.refusedOutcomes,l,p)||!s.refusedOutcomes.every(([u,h])=>u===h.seq&&s.statuses.some(([C,v])=>C===u&&v.status===h.status&&v.reason===h.reason)&&(h.affectedSeqs??[]).every(C=>s.statuses.some(([v,P])=>v===C&&P.status===h.status&&P.reason===h.reason&&P.committed===!1)))||!a(s.formats,f,k)||s.formats.length>64||s.historySelections!==void 0&&(!Array.isArray(s.historySelections)||!s.historySelections.every(d))||!s.selection||!s.sheetIds.includes(s.selection.sheetId)||i.length===0)&&t(),s.calculation!==null&&(!s.calculation||!Number.isFinite(s.calculation.nowSerial)||!l(s.calculation.randSeed)||s.calculation.randSeed>4294967295)&&t(),{...s,allowHostProposals:s.allowHostProposals===!0,engine:i}}function Jl(e,t,n,r=Bl){if(e.version()!==t.engineVersion||e.sheetCount()!==t.sheetIds.length||n.session!==t.session)throw new TypeError("Workbook recovery boundary mismatch");let o=fr(n,{epoch:t.epoch,version:t.engineVersion},t.selection,t.sheetIds,t.calculation),s=be(e,t.selection,t.sheetIds),i=t.selection.activeCell;if(i&&(!Number.isSafeInteger(i.row)||!Number.isSafeInteger(i.col)||i.row<s.start.row||i.row>s.end.row||i.col<s.start.col||i.col>s.end.col))throw new TypeError("Invalid recovery selection");return Object.assign(o,{throughSeq:t.throughSeq,readOnly:t.readOnly,allowHostProposals:t.allowHostProposals===!0,nextSheetId:t.nextSheetId,sheetRevision:t.sheetRevision,bases:new Map(t.bases),formats:new Map(t.formats),historyReset:t.historySelections===void 0,historySelections:structuredClone(t.historySelections??[]).map(l=>l??void 0)}),o.statuses=new Map(t.statuses),r.restore(e),fn(e,o),o}var Bl,Ho,Dl,Ie,Yu,jo=U(()=>{"use strict";ur();Bl={capture:()=>{},restore:()=>{}},Ho=new Uint8Array([88,76,83,88,82,69,67,86]),Dl=3,Ie=21,Yu=8});function Hl(e,t){return e===t||JSON.stringify(e)===JSON.stringify(t)}function jl(e){let{handle:t,state:n}=e,r=e.now??(()=>performance.now()),o=new Map,s=e.revision??0,i=0,l=new Map(e.versions??[[s,t.version()]]),a=new Set(e.refusedSeqs),f=e.refusedRanges?.map(([g,c])=>[g,c])??[],d=new Map(e.refusedOutcomes);if(!e.refusedRanges)for(let g of[...a].sort((c,b)=>c-b))D(g);let p=new Map,y,k=!1,u,h,C=Promise.resolve(),v,P=n.historyReset===!0,L=new Set,B=[];function D(g){let c=f[f.length-1];if(c&&g<=c[1]+1)c[1]=Math.max(c[1],g);else{if(f.length===4096)throw new Z("out-of-memory","Workbook refusal ledger exhausted");f.push([g,g])}}function V(g,c){n.statuses.set(g,structuredClone(c)),n.statuses.size>256&&n.statuses.delete(n.statuses.keys().next().value);for(let b of a)n.statuses.has(b)||a.delete(b);for(let b of o.keys())n.statuses.has(b)||o.delete(b);for(let b of d.keys())n.statuses.has(b)||d.delete(b)}function R(g){return g.payload.compatibility?g.payload.compatibility:{...n.identity,seq:g.seq,basis:{epoch:g.basis.epoch,version:l.get(g.basis.version)??""},afterSeq:g.afterSeq,kind:g.kind,payload:g.payload.payload,...pt(g.payload.frame)?{frame:g.payload.frame}:{}}}function J(g){if(Uo(g),g.session!==n.identity.session||g.incarnation!==n.identity.incarnation||g.basis.epoch!==n.epoch)throw new Error("Workbook command identity or epoch mismatch")}let O=Il({session:n.identity.session,incarnation:1,epoch:n.epoch,throughSeq:n.throughSeq,refusedSeqs:f.map(([,g])=>g),getVersion:()=>s-i,selectionEquals:Hl,editStateEquals:Hl,apply(g){let c=R({...g,basis:{...g.basis,version:g.basis.version+i}}),b;if(g.payload.compatibility){if(J(c),c.seq!==g.seq||c.seq!==n.throughSeq+1)throw new Error(`Expected workbook command sequence ${n.throughSeq+1}`);c.kind!=="applyUpdate"&&c.kind!=="collabPipe"&&c.afterSeq!==void 0&&!n.statuses.has(c.afterSeq)&&(b="dependency-expired")}let S=te=>{try{return te()}catch(oe){throw v=oe instanceof Z?oe:new Z(ue(oe)?"trap":"crash","Workbook command failed",oe instanceof Error?oe.message:String(oe)),v}},W=S(()=>t.version()),M=S(()=>Rl(t,n,c,b,!1,e.applyPipe)),G=M.statuses[0];g.kind!=="collabPipe"&&pt(p.get(g.seq)?.frame)&&(k=!0),P&&(M.selection=structuredClone(n.selection),M.editState=n.editState,P=!1);let re=S(()=>t.version());re!==W&&(s+=1,l.set(s,re),l.size>256&&l.delete(l.keys().next().value),e.onCommit?.()),o.set(g.seq,M),V(g.seq,G),n.throughSeq=g.seq;let Y={...M.selection?{selection:M.selection}:{},...M.editState?{editState:M.editState}:{}};return G.status==="refused"?{status:"refused",reason:G.reason,affectedSeqs:G.affectedSeqs,...Y}:G.status==="cancelled"?{status:"cancelled",reason:G.reason,...Y}:G.status==="applied"?{status:"applied",...G.committed?{}:{committed:!1},...Y}:{status:"noop",...Y}},frame({coversThroughSeq:g}){let c=p.get(g),b=u??c?.frame;if(!pt(b)||b.sheet>=t.sheetCount())return;let S=y?.request;if(!u&&!k&&c?.pipe&&y?.version===t.version()&&S&&S.sheet===b.sheet&&S.zoom===b.zoom&&S.dpr===b.dpr&&S.viewport.x===b.viewport.x&&S.viewport.y===b.viewport.y&&S.viewport.width===b.viewport.width&&S.viewport.height===b.viewport.height)return;let W=e.frame(b,g);return y={version:W.version,request:structuredClone(b)},k=!1,he({coversThroughSeq:g,revision:W.epoch,payload:W},[W.displayList])},snapshot:async()=>{let g=B.shift();await Promise.all(g?.settled??[]);let c=g?.preserveHistory===!0,b=r();try{return zl(e.captureRecovery?.()??Ao(t,n.throughSeq,c),n,s,[...l],[...a],e.sessionState?.(),void 0,{refusedRanges:f,refusedOutcomes:[...d],...c?{historySelections:n.historySelections}:{}})}finally{g&&(g.encodeMs=Math.max(0,r()-b))}}});async function F(g,c){if(v)throw v;c.payload.compatibility&&J(c.payload.compatibility);let b=n.throughSeq,S,W=new Promise(M=>{S=M});L.add(W),p.set(c.seq,{frame:c.payload.frame??(c.kind==="applyUpdate"||c.kind==="collabPipe"?h:void 0),pipe:c.kind==="collabPipe"}),c.payload.frame&&(h=c.payload.frame),p.size>256&&p.delete(p.keys().next().value);try{let M=c.afterSeq,G=M===void 0?void 0:f.find(([w,A])=>M>=w&&M<=A),re=await O.handler(g,{...c,basis:{...c.basis,version:c.basis.version-i},...G?{afterSeq:G[1]}:{}}),Y=ve(re)?re.value:re;n.throughSeq=Math.max(n.throughSeq,Y.throughSeq);let te=Y.outcomes.map(w=>{let A=(w.status==="refused"||w.status==="cancelled")&&c.session===n.identity.session&&c.incarnation===1&&(c.basis.epoch===n.epoch||w.seq===Y.throughSeq&&!n.statuses.has(w.seq)&&!o.has(w.seq))&&w.seq>b&&w.seq<=Y.throughSeq;A&&(a.add(w.seq),D(w.seq),d.set(w.seq,{...w,...w.affectedSeqs?{affectedSeqs:[...w.affectedSeqs]}:{}}));let T=c.session===n.identity.session&&c.incarnation===1&&c.basis.epoch===n.epoch,I=T?o.get(w.seq):void 0,z=T?n.statuses.get(w.seq):void 0,we=I?.statuses[0]??z??{...w,status:w.status==="duplicate"?"noop":w.status,committed:!1,affectedSeqs:w.affectedSeqs??[w.seq]};!I&&A&&V(w.seq,we);let ie=T&&w.status==="duplicate"?d.get(w.seq)??(z&&(z.status==="refused"||z.status==="cancelled")?{seq:z.seq,status:z.status,committed:!1,...z.reason?{reason:z.reason}:{},...z.status==="refused"&&z.affectedSeqs?{affectedSeqs:z.affectedSeqs}:{}}:void 0):void 0;return{...ie??w,...ie?.affectedSeqs?{affectedSeqs:[...ie.affectedSeqs]}:{},workbook:!I&&z?structuredClone(we):we}}),oe=o.get(c.seq),ce=Y.version+i,me=l.get(ce)??t.version(),ae={throughSeq:Y.throughSeq,version:me,statuses:te.map(w=>w.workbook),...oe?.selection?{selection:oe.selection}:{},...oe?.editState?{editState:oe.editState}:{}};!oe&&te.some(w=>w.status==="refused"||w.status==="cancelled")&&(ae.selection=structuredClone(n.selection),ae.editState=n.editState);let E={...Y,version:ce,engineVersion:me,outcomes:te,compatibility:ae};return ve(re)?he(E,re.transfer):E}catch(M){throw v||(Ll(M)?(v=new Z("crash",M.message),v):M)}finally{L.delete(W),S()}}function x(g){let c=C.then(async()=>{u=g??h,g&&(h=g);try{return await O.frame()}finally{u=void 0}});return C=c.then(()=>{},()=>{}),c}return{validateDirectEdits(){if(n.throughSeq!==0||L.size!==0)throw new Error("Direct edits require an unused command host");if(v)throw v},synchronizeDirectEdits(g=t.version()){return s+=1,i+=1,l.set(s,g),l.size>256&&l.delete(l.keys().next().value),n.bases.set(g,n.sheetRevision),n.bases.size>256&&n.bases.delete(n.bases.keys().next().value),n.formattingDirty=!0,{revision:s,versions:[...l],refusedSeqs:[...a]}},handler:F,policy:g=>({...O.policy(g),lane:g.kind==="applyUpdate"||g.kind==="collabPipe"?"collab":"input",userInput:g.kind!=="applyUpdate"&&g.kind!=="collabPipe"}),async checkpoint(g,c=!1){let b={settled:[...L],preserveHistory:c,encodeMs:0};B.push(b);let S=await O.checkpoint(g),W=ve(S)?S.value:S,M={...W,version:W.version+i,encodeMs:b.encodeMs};return ve(S)?he(M,S.transfer):M},checkpointPolicy:O.checkpointPolicy,frame:()=>x(),rememberFrame(g){h=g,y={version:t.version(),request:structuredClone(g)}},requestFrame:x,async command(g){J(g);let c=g.seq<=n.throughSeq;if(c){let M=n.statuses.get(g.seq);if(!M)throw new Error(`Expected workbook command sequence ${n.throughSeq+1}`);let G={throughSeq:n.throughSeq,version:t.version(),statuses:[structuredClone(M)]};return{...G,shared:{session:n.identity.session,incarnation:1,epoch:n.epoch,throughSeq:n.throughSeq,version:s,engineVersion:t.version(),compatibility:G,outcomes:[{seq:M.seq,status:M.status,workbook:structuredClone(M),...M.committed?{}:{committed:!1}}]}}}let b=await F(null,{session:g.session,incarnation:1,seq:g.seq,basis:{epoch:g.basis.epoch,version:s},afterSeq:g.afterSeq,kind:g.kind,payload:{payload:g.payload,compatibility:g,frame:c?void 0:g.frame}}),S=ve(b)?b.value:b,W={...S.compatibility,shared:S,...S.frame?{frame:S.frame.payload}:{}};return ve(b)?he(W,b.transfer):W}}}var $l=U(()=>{"use strict";Ul();Jo();Be();je();Pt();jo();ur();on();Ve()});var $o,Vl=U(()=>{"use strict";$o={decodeFontFace:{lane:"interactive"},open:{lane:"interactive"},openRecovery:{lane:"input",reorderable:!1},version:{lane:"interactive"},collaborationStateVector:{lane:"collab",reorderable:!1},collaborationStateAsUpdate:{lane:"collab",reorderable:!1},listDefinedNames:{lane:"interactive"},readCells:{lane:"interactive"},findText:{lane:"interactive"},validateEdits:{lane:"interactive"},applyEdits:{lane:"input",mutates:!0,userInput:!0},command:{lane:"input",userInput:!0,reorderable:!1},edit:{lane:"input",userInput:!0,mutates:!0,reframes:!0,reorderable:!1},checkpoint:{lane:"input",reorderable:!1},commandFrame:{lane:"input",reorderable:!1},frame:{lane:"interactive",reframes:!0,key:"frame",replaceableBy:"frame"},sheetView:{lane:"interactive"},cellGeometry:{lane:"interactive"},cellInputs:{lane:"interactive"},translateFormulas:{lane:"interactive"},selectionData:{lane:"interactive",reorderable:!1},captureFormat:{lane:"interactive",reorderable:!1},sheets:{lane:"interactive"},calculationStatus:{lane:"interactive"},renderPng:{lane:"interactive",reorderable:!1},renderPngFonts:{lane:"interactive",reorderable:!1},exportStructured:{lane:"interactive",reorderable:!1},exportMarkdown:{lane:"interactive",reorderable:!1},printDisplayList:{lane:"interactive",reorderable:!1},save:{lane:"interactive"},saveWithWarnings:{lane:"interactive"},dispose:{lane:"interactive"}}});var Ot,Kl=U(()=>{"use strict";Ot=class extends Error{constructor(n,r){super(r);this.code=n;this.name="WorkbookPeerHydrationError",this.refusal={code:n}}code;refusal}});function Gl(e){let t=new Map,n=[],r=!1,o=!1,s=null,i=(u,h)=>{if(o)return;let C=!r&&n.length===0,v=n[n.length-1];v?.provider===u?v.out.push(h):n.push({provider:u,out:[h]}),C&&e.onOutput?.()},l=()=>{let u=s;if(!u||u.updates.length===0)return;s={updates:[],arrivals:[],single:!0};let h=e.merge(u.updates,u.single&&u.updates.length===1);if("failed"in h){for(let C of u.arrivals)C.fail(h.failed);return}u.arrivals.forEach((C,v)=>C.settle(v===u.arrivals.length-1?h.applied:null))},a=(u,h,C)=>{if(!s)throw new Error("Collaboration updates merge only within a pipe burst");return s.updates.push(...h),s.arrivals.push(e.arrive(u)),s.single&&=C,null},f=u=>({clientId:e.clientId,encodeStateVector:()=>(l(),e.read.encodeStateVector()),encodeStateAsUpdate:h=>(l(),e.read.encodeStateAsUpdate(h)),...e.read.encodeStateAsUpdateChunks&&{encodeStateAsUpdateChunks:(h,C)=>(l(),e.read.encodeStateAsUpdateChunks(h,C))},applyUpdate:h=>a(u(),[h],!0),applyUpdateChunks:h=>a(u(),h,!1),onUpdate:e.onUpdate}),d=(u,h)=>{let C,v=new Vo(B=>{C.echo||i(u,typeof B=="string"?{do:B,through:C.through}:{do:"send",data:Oo(B),through:C.through})}),P=e.createProvider(f(()=>C.provider),v,h);C={id:u,provider:P,transport:v,through:0,echo:!1,leaveClock:null,stop:[]};let L=!1;return C.stop.push(P.onStatus(({status:B,synced:D})=>i(u,{do:"status",status:B,synced:D,through:C.through})),P.onError(B=>{C.echo||i(u,{do:"error",error:{code:B.code,message:B.message},through:C.through})}),P.onPeers(B=>{L&&i(u,{do:"peers",peers:[...B],timeOrigin:sr(),through:C.through})})),L=!0,t.set(u,C),C},p=(u,h)=>{u.echo=!0;try{h()}finally{u.echo=!1}},y=u=>{let h=t.get(u.provider);for(let C of u.ops){if(C.op==="create"){h??=d(u.provider,C.options),h.through=C.seq;continue}if(!h){i(u.provider,{do:"lost"});return}let v=h;switch(v.through=C.seq,C.op){case"connect":p(v,()=>v.provider.connect());break;case"disconnect":p(v,()=>v.provider.disconnect());break;case"fail":p(v,()=>v.transport.deliver({type:"error",error:e.transportError(C.error)}));break;case"destroy":p(v,()=>v.provider.destroy());for(let P of v.stop)P();t.delete(v.id),h=void 0;break;case"cursor":v.provider.setCursor(C.cursor,C.broadcast);break;case"event":{let{event:P}=C;v.transport.deliver(P.type==="message"?{type:"message",data:new Uint8Array(P.data)}:P);break}}}},k=()=>{for(let u of t.values()){let h=e.leave(u.provider),C=h?.clock??null;C!==u.leaveClock&&(u.leaveClock=C,i(u.id,{do:"leave",data:h?Oo(h.frame):null,through:u.through}))}};return{run(u){if(!o){r=!0,s={updates:[],arrivals:[],single:!0};try{y(u),l()}finally{s=null,r=!1}}},drain(){r=!0;try{k()}finally{r=!1}if(n.length===0)return;let u=n;n=[];let h=[];for(let C of u)for(let v of C.out)(v.do==="send"||v.do==="leave"&&v.data)&&h.push(v.data);return{batches:u,transfer:h}},dispose(){if(!o){o=!0;for(let u of t.values()){for(let h of u.stop)h();u.echo=!0;try{u.provider.destroy()}catch{}}t.clear(),n=[]}}}}var Vo,Ql=U(()=>{ir();Vo=class{constructor(t){this.emit=t}emit;listener=null;connect(){}disconnect(){this.emit("disconnect")}send(t){return this.emit(t),!0}onEvent(t){return this.listener=t,()=>{this.listener===t&&(this.listener=null,this.emit("unsubscribe"))}}deliver(t){this.listener?.(t)}}});function Zu(e){return e instanceof Error&&e.message?e.message:typeof e=="string"&&e?e:"Unknown error"}function np(e){if(e[0]!==0||e[1]!==2)return!1;let t=0;for(let n=2,r=0;n<Math.min(e.byteLength,7);n++,r+=7)if(t+=(e[n]&127)*2**r,e[n]<128)return n+1+t===e.byteLength;return!1}var ep,Ko,tp,hr,Yl=U(()=>{ir();ep=["backpressure","protocol","replica","transport"],Ko=64,tp=250;hr=class{constructor(t,n,r){this.transport=n;this.options=r;this.endpoint=t.open(o=>this.receive(o),o=>this.lose(o)),this.enqueue({op:"create",seq:++this.seq,options:r.worker})}transport;options;endpoint;statusListeners=new Map;errorListeners=new Map;peerListeners=new Map;nextListenerId=0;connectionStatus="disconnected";isSynced=!1;peerList=[];seq=0;floor=0;sendFloor=0;inboundBytes=0;flushingFrames=!1;queue=[];posting=!1;flushQueued=!1;heldTimer=null;urgent=!1;unsubscribeTransport=null;subscription=0;wantsConnection=!1;connectAttempt=0;leaveFrame=null;pendingFrames=[];queuedBytes=0;isDestroyed=!1;closed=!1;get status(){return this.connectionStatus}get synced(){return this.isSynced}get pendingBytes(){return this.queuedBytes}get peers(){return this.peerList}setCursor(t,n){this.isDestroyed||this.enqueue({op:"cursor",seq:++this.seq,cursor:t,broadcast:n})}onPeers(t){if(this.isDestroyed)return()=>{};let n=this.nextListenerId++;return this.peerListeners.set(n,t),t(this.peers),()=>this.peerListeners.delete(n)}onStatus(t){if(this.isDestroyed)return()=>{};let n=this.nextListenerId++;return this.statusListeners.set(n,t),()=>this.statusListeners.delete(n)}onError(t){if(this.isDestroyed)return()=>{};let n=this.nextListenerId++;return this.errorListeners.set(n,t),()=>this.errorListeners.delete(n)}connect(){if(this.isDestroyed||this.connectionStatus==="connected"||this.connectionStatus==="connecting")return;if(this.closed){this.report(this.options.makeError("replica","Collaboration replica is retired"));return}this.wantsConnection=!0,this.floor=++this.seq,this.enqueue({op:"connect",seq:this.floor});let t=++this.connectAttempt;if(this.setStatus("connecting",!1),!(!this.wantsConnection||this.isDestroyed||t!==this.connectAttempt)){if(!this.unsubscribeTransport){let n=++this.subscription,r;try{if(r=this.transport.onEvent(o=>this.forward(n,o)),typeof r!="function")throw new TypeError("Transport event subscription must return a function")}catch(o){this.subscription+=1,this.fail(this.transportError("Failed to subscribe to transport events",o));return}if(!this.wantsConnection||this.isDestroyed||t!==this.connectAttempt||n!==this.subscription){try{r()}catch(o){this.isDestroyed||this.report(this.transportError("Failed to unsubscribe from stale transport events",o))}return}this.unsubscribeTransport=r}try{let n=this.transport.connect();n&&n.catch(r=>{!this.isDestroyed&&this.wantsConnection&&this.connectAttempt===t&&this.fail(this.transportError("Transport connect failed",r))})}catch(n){this.fail(this.transportError("Transport connect failed",n))}}}disconnect(){if(this.isDestroyed)return;if(this.closed){this.setStatus("disconnected",!1);return}if(!(this.wantsConnection||this.unsubscribeTransport!==null||this.connectionStatus!=="disconnected"))return;this.sendLeave(),this.floor=++this.seq,this.enqueue({op:"disconnect",seq:this.floor});let n=this.release(!0);this.setStatus("disconnected",!1);for(let r of n)this.report(r)}destroy(){if(this.isDestroyed)return;let t=!this.closed&&(this.wantsConnection||this.unsubscribeTransport!==null||this.connectionStatus==="connecting"||this.connectionStatus==="connected");t&&this.sendLeave(),this.floor=++this.seq,this.enqueue({op:"destroy",seq:this.floor});let n=this.closed?[]:this.release(t);this.isDestroyed=!0,this.setStatus("destroyed",!1);for(let r of n)this.report(r);this.statusListeners.clear(),this.errorListeners.clear(),this.peerListeners.clear()}transportError(t,n){return this.options.normalize("transport",t,n)}release(t){this.wantsConnection=!1,this.connectAttempt+=1,this.leaveFrame=null,this.clearQueue(),this.clearPeers();let n=[],r=this.unsubscribeTransport;if(this.unsubscribeTransport=null,this.subscription+=1,r)try{r()}catch(o){n.push(this.transportError("Failed to unsubscribe from transport events",o))}if(!t)return n;try{let o=this.transport.disconnect();o&&o.catch(s=>{this.isDestroyed||this.report(this.transportError("Transport disconnect failed",s))})}catch(o){n.push(this.transportError("Transport disconnect failed",o))}return n}fail(t){if(this.isDestroyed||!this.wantsConnection)return;let n=t.code;this.floor=++this.seq,this.enqueue({op:"fail",seq:this.floor,error:{code:typeof n=="string"&&ep.includes(n)?n:"transport",message:t.message}});let r=this.release(!0);this.setStatus("disconnected",!1),this.report(t);for(let o of r)this.report(o)}sendLeave(){let t=this.leaveFrame;if(this.leaveFrame=null,!(!t||!this.options.hasUser||!this.unsubscribeTransport||this.connectionStatus!=="connected"))try{this.transport.send(t)}catch(n){this.report(this.transportError("Failed to send awareness leave",n))}}enqueue(t,n=!1){this.closed||(this.queue.push(t),this.schedule(n))}schedule(t){if(t||(this.urgent=!0),!(this.posting||this.flushQueued)){if(t){this.heldTimer??=setTimeout(()=>{this.heldTimer=null,this.flush()},tp);return}this.flushQueued=!0,queueMicrotask(()=>{this.flushQueued=!1,this.flush()})}}flush(){if(this.posting||this.closed||this.queue.length===0)return;this.heldTimer!==null&&(clearTimeout(this.heldTimer),this.heldTimer=null);let t=this.queue;this.queue=[],this.urgent=!1,this.posting=!0;let n=t.some(s=>s.op==="destroy"),r=t.reduce((s,i)=>i.op==="event"&&i.event.type==="message"?s+i.event.data.byteLength+Ko:s,0),o;try{o=this.endpoint.post(t,cl(t))}catch(s){o=Promise.reject(s)}o.then(()=>{this.posting=!1,this.inboundBytes-=r,n?this.close():this.urgent?this.flush():this.queue.length>0&&this.schedule(!0)},s=>{this.posting=!1,this.inboundBytes-=r,this.lose(Zu(s))})}forward(t,n){if(!(this.closed||this.isDestroyed||t!==this.subscription))switch(n.type){case"message":if(this.inboundBytes===0?n.data.byteLength>this.options.maxPendingBytes:n.data.byteLength+Ko>this.options.maxPendingBytes-this.inboundBytes){this.fail(this.options.makeError("backpressure","Pending replica data exceeds the byte limit"));return}this.inboundBytes+=n.data.byteLength+Ko,this.enqueue({op:"event",seq:++this.seq,event:{type:"message",data:n.data.slice().buffer}},!this.isSynced&&np(n.data)&&this.inboundBytes<=this.options.maxPendingBytes/2);return;case"open":case"close":this.clearQueue(),n.type==="close"&&(this.connectAttempt+=1,this.leaveFrame=null),this.sendFloor=++this.seq,this.enqueue({op:"event",seq:this.sendFloor,event:n.type==="open"?{type:"open"}:{type:"close",...n.reason!==void 0&&{reason:n.reason}}}),n.type==="close"&&(this.clearPeers(),this.setStatus("disconnected",!1));return;case"drain":this.flushPending();return;case"error":this.fail(this.transportError("Transport error",n.error));return;default:this.fail(this.options.makeError("transport","Unknown transport event"))}}receive(t){for(let n of t){if(this.closed||this.isDestroyed)return;if(n.do==="lost"){this.lose("Collaboration replica is retired");return}if(!(n.through<this.floor))switch(n.do){case"unsubscribe":{let r=this.release(!1);for(let o of r)this.report(o);break}case"disconnect":{this.wantsConnection=!1;let r=this.release(!0);for(let o of r)this.report(o);break}case"send":n.through>=this.sendFloor&&this.send(new Uint8Array(n.data));break;case"leave":n.through>=this.sendFloor&&(this.leaveFrame=n.data?new Uint8Array(n.data):null);break;case"status":n.through>=this.sendFloor&&this.setStatus(n.status,n.synced);break;case"peers":{if(n.through<this.sendFloor||n.peers.length===0&&this.peerList.length===0)break;let r=this.options.rebasePeer,o=n.timeOrigin-sr();this.peerList=r?n.peers.map(s=>r(s,o)):n.peers,this.emitPeers();break}case"error":this.report(this.options.makeError(n.error.code,n.error.message));break}}}send(t){if(!this.unsubscribeTransport)return;if(this.pendingFrames.length>0){this.queueFrame(t);return}let n=this.sendFloor,r;try{r=this.transport.send(t.slice())}catch(o){this.fail(this.transportError("Transport send failed",o));return}if(typeof r!="boolean"){this.fail(this.options.makeError("transport","Transport send must return a boolean"));return}!r&&this.unsubscribeTransport!==null&&n===this.sendFloor&&this.queueFrame(t)}queueFrame(t){if(t.byteLength>this.options.maxPendingBytes-this.queuedBytes){this.fail(this.options.makeError("backpressure",`Pending collaboration data exceeds ${this.options.maxPendingBytes} bytes`));return}this.pendingFrames.push(t),this.queuedBytes+=t.byteLength}flushPending(){if(!this.flushingFrames){this.flushingFrames=!0;try{for(;this.unsubscribeTransport&&this.pendingFrames.length>0;){let t=this.pendingFrames[0],n;try{n=this.transport.send(t.slice())}catch(r){this.fail(this.transportError("Transport send failed",r));return}if(typeof n!="boolean"){this.fail(this.options.makeError("transport","Transport send must return a boolean"));return}if(!n||this.pendingFrames[0]!==t)return;this.pendingFrames.shift(),this.queuedBytes-=t.byteLength}}finally{this.flushingFrames=!1}}}clearQueue(){this.pendingFrames.length=0,this.queuedBytes=0}lose(t){if(this.closed||(this.close(),this.isDestroyed))return;this.sendLeave();let n=this.release(this.wantsConnection||this.connectionStatus!=="disconnected");setTimeout(()=>{if(!this.isDestroyed){this.setStatus("disconnected",!1),this.report(this.options.makeError("replica",t));for(let r of n)this.report(r)}},0)}close(){this.closed||(this.closed=!0,this.queue=[],this.heldTimer!==null&&(clearTimeout(this.heldTimer),this.heldTimer=null),this.endpoint.close())}clearPeers(){this.peerList.length!==0&&(this.peerList=[],this.emitPeers())}setStatus(t,n){if(!(this.connectionStatus===t&&this.isSynced===n)){this.connectionStatus=t,n&&!this.isSynced&&this.queue.length>0&&this.schedule(!1),this.isSynced=n;for(let[r,o]of[...this.statusListeners])if(this.statusListeners.get(r)===o)try{o({status:t,synced:n})}catch{}}}emitPeers(){let t=this.peers;for(let[n,r]of[...this.peerListeners])if(this.peerListeners.get(n)===r)try{r(t)}catch{}}report(t){for(let[n,r]of[...this.errorListeners])if(this.errorListeners.get(n)===r)try{r(t)}catch{}}}});function nc(e){return e?{sheet:e.sheet,anchor:{...e.anchor},head:{...e.head}}:null}function rp(e){return{user:{...e.user},cursor:nc(e.cursor)}}function rc(e,t){return!e||!t?e===t:e.sheet===t.sheet&&e.anchor.row===t.anchor.row&&e.anchor.col===t.anchor.col&&e.head.row===t.head.row&&e.head.col===t.head.col}function op(e,t){return!e||!t?e===t:e.user.name===t.user.name&&e.user.color===t.user.color&&rc(e.cursor,t.cursor)}function sp(e){return Zl[e%Zl.length]}function Yo(e,t){if(typeof e!="string"||!/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(e))return sp(t);let n=e.slice(1).toUpperCase();return n.length===6?`#${n}`:`#${n[0]}${n[0]}${n[1]}${n[1]}${n[2]}${n[2]}`}function oc(e,t){return{name:e?.name.trim().slice(0,br)||"Anonymous",color:Yo(e?.color,t)}}function sc(e,t,n,r,o={}){let s=o.maxPeers??Qo;if(!Number.isSafeInteger(s)||s<1)throw new RangeError("Awareness peer limit must be a positive integer");let i=!1,l=0;for(let a of t){if(a.clientId===n)continue;let f=e.get(a.clientId);if(f&&a.clock<f.clock)continue;if(f&&a.clock===f.clock){f.lastSeen=r;continue}if(!f&&e.size>=s){l+=1;continue}let d=a.state?.cursor!=null&&(!f?.state||!rc(f.state.cursor,a.state.cursor)),p=a.state?rp(a.state):null;i||=!op(f?.state??null,p),e.set(a.clientId,{clock:a.clock,state:p,lastSeen:r,cursorMovedAt:d?r:f?.cursorMovedAt??0})}return l>0&&o.onPeersDiscarded?.(l),i}function ic(e,t,n=Go){let r=!1;for(let[o,s]of e)t-s.lastSeen<n||(r||=s.state!==null,e.delete(o));return r}function ac(e){let t=[];for(let[n,r]of e)r.state&&t.push({clientId:n,clock:r.clock,user:{...r.state.user},cursor:nc(r.state.cursor),lastSeen:r.lastSeen,cursorMovedAt:r.cursorMovedAt});return t.sort((n,r)=>n.clientId-r.clientId),t}function lc(e,t){return nr(e,t)}var ec,tc,Go,br,mn,Qo,Zl,Zo=U(()=>{"use strict";ct();ec=80,tc=2e4,Go=45e3,br=128,mn=256,Qo=1024,Zl=["#0B57D0","#B3261E","#146C2E","#6B4EFF","#8E24AA","#00639B","#8E4E00","#7D5260"]});function _e(e){if(!Number.isSafeInteger(e)||e<0)throw new ne("varUint value must be a non-negative safe integer");let t=[],n=e;for(;n>=128;)t.push(n%128|128),n=Math.floor(n/128);return t.push(n),Uint8Array.from(t)}function Wt(e,t){let n=0;for(let s of e)if(n+=s.byteLength,n>t)throw new ne(`Frame exceeds ${t} bytes`);let r=new Uint8Array(n),o=0;for(let s of e)r.set(s,o),o+=s.byteLength;return r}function dp(e){let t=new TextEncoder().encode(e);return[_e(t.byteLength),t]}function yr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function cc(e){if(!yr(e))throw new ne("Awareness cell must be an object");let{row:t,col:n}=e;if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<0)throw new ne("Awareness cell coordinates must be non-negative safe integers");return{row:t,col:n}}function bc(e,t){if(e===null)return null;if(!yr(e)||!yr(e.user))throw new ne("Awareness state must contain a user");let{name:n,color:r}=e.user;if(typeof n!="string"||n.length===0||n.length>br)throw new ne(`Awareness user name must contain 1 to ${br} characters`);let o=Yo(r,t),s=e.cursor;if(s==null)return{user:{name:n,color:o},cursor:null};if(!yr(s)||typeof s.sheet!="string")throw new ne("Awareness cursor must contain a sheet identifier");if(s.sheet.length===0||s.sheet.length>mn)throw new ne(`Awareness sheet identifier must contain 1 to ${mn} characters`);return{user:{name:n,color:o},cursor:{sheet:s.sheet,anchor:cc(s.anchor),head:cc(s.head)}}}function ns(e,t,n){return Wt([_e(dc),_e(e),_e(t.byteLength),t],n)}function wr(e,t=Se){return ns(pc,e,t)}function rs(e,t=Se){return ns(mc,e,t)}function os(e,t=Se){return ns(hc,e,t)}function ss(e,t=Se){if(e.length>hn)throw new ne(`Awareness update exceeds ${hn} states`);let n=[_e(e.length)];for(let o of e){if(!Number.isSafeInteger(o.clientId)||o.clientId<=0)throw new ne("Awareness clientId must be a positive safe integer");if(!Number.isSafeInteger(o.clock)||o.clock<0)throw new ne("Awareness clock must be a non-negative safe integer");let s=bc(o.state,o.clientId);n.push(_e(o.clientId),_e(o.clock),...dp(JSON.stringify(s)))}let r=Wt(n,t);return Wt([_e(fc),_e(r.byteLength),r],t)}function yc(e=Se){return Wt([_e(uc)],e)}function gc(e,t=hn,n){if(!(e instanceof Uint8Array))throw new ne("Awareness update must be a Uint8Array");if(!Number.isSafeInteger(t)||t<1)throw new ne("Awareness state limit must be a positive integer");let r=new gr(e),o=r.readVarUint();if(o>t){let l=new ne(`Awareness update exceeds ${t} states`);if(!n)throw l;n(l)}let s=[],i=Math.min(o,t);for(let l=0;l<i;l++){let a,f,d;try{a=r.readVarUint(),f=r.readVarUint(),d=r.readVarString()}catch(p){if(!n)throw p;return n(new ne(`Awareness entry ${l+1} could not be decoded: ${p instanceof Error?p.message:"Unknown error"}`)),s}try{if(a<=0)throw new ne("Awareness clientId must be a positive safe integer");let p=JSON.parse(d);s.push({clientId:a,clock:f,state:bc(p,a)})}catch(p){let y=p instanceof ne?p:new ne(`Invalid awareness JSON${p instanceof Error?`: ${p.message}`:""}`);if(!n)throw y;n(new ne(`Awareness entry ${l+1} discarded: ${y.message}`))}}if(o<=t&&!r.done){let l=new ne("Trailing awareness update data");if(!n)throw l;n(l)}return s}function et(e){let t=es.byteLength+32,n=e.byteLength-t;if(n<0)return e;for(let r=0;r<es.byteLength;r+=1)if(e[n+r]!==es[r])return e;return e.subarray(0,n)}function kc(e){let t=0,n=()=>{let i=0n;for(let l=0;l<cp&&t<e.byteLength;l+=1){let a=e[t++];if(i|=BigInt(a&127)<<BigInt(7*l),a<128)return i}},r=n();if(r===void 0)return;let o=t,s=[];for(let i=r;i>0n;i-=1n){let l=t,a=n(),f=n();if(a===void 0||f===void 0)return;s.push({client:a,clock:f,start:l,end:t})}return t===e.byteLength?{header:o,entries:s}:void 0}function Sc(e){let t=et(e),n=kc(t);if(!n)return e;let{header:r,entries:o}=n;if(!(o.length>=fp||o.some(({client:s})=>s===wc)))return Wt([_e(o.length+1),t.subarray(r),_e(lt),_e(0),e.subarray(t.byteLength)],Number.MAX_SAFE_INTEGER)}function is(e){let t=et(e),n=kc(t);if(!n)return{stateVector:e,open:!1};let r=n.entries.filter(({client:o,clock:s})=>o!==wc||s!==0n);return r.length===n.entries.length?{stateVector:e,open:!1}:{stateVector:Wt([_e(r.length),...r.map(({start:o,end:s})=>t.subarray(o,s)),e.subarray(t.byteLength)],Number.MAX_SAFE_INTEGER),open:!0}}function xc(e,t=Se,n=ts){if(!(e instanceof Uint8Array))throw new ne("Frame must be a Uint8Array");if(e.byteLength===0)throw new ne("Frame is empty");if(e.byteLength>t)throw new ne(`Frame exceeds ${t} bytes`);if(!Number.isSafeInteger(n)||n<1)throw new ne("Message limit must be a positive integer");let r=new gr(e),o=[];for(;!r.done;){if(o.length>=n)throw new ne(`Frame exceeds ${n} messages`);let s=r.readVarUint();switch(s){case dc:{let i=r.readVarUint(),l=r.readVarUint8Array();if(i===pc)o.push({type:"sync-step-1",stateVector:l});else if(i===mc)o.push({type:"sync-step-2",update:l});else if(i===hc)o.push({type:"update",update:l});else throw new ne(`Unknown sync message type ${i}`);break}case fc:o.push({type:"awareness",update:r.readVarUint8Array()});break;case ip:{let i=r.readVarUint();if(i!==ap)throw new ne(`Unknown auth message type ${i}`);o.push({type:"auth",reason:r.readVarString()});break}case uc:o.push({type:"query-awareness"});break;default:throw new ne(`Unknown top-level message type ${s}`)}}return o}var ts,hn,dc,fc,ip,uc,pc,mc,hc,ap,lp,cp,es,ne,gr,wc,fp,vc=U(()=>{"use strict";ct();Zo();ct();ts=4096,hn=1024,dc=0,fc=1,ip=2,uc=3,pc=0,mc=1,hc=2,ap=0,lp=Number.MAX_SAFE_INTEGER,cp=10,es=new TextEncoder().encode("\0betteroffice-document-fingerprint-v1\0"),ne=class extends Error{constructor(t){super(t),this.name="ProtocolError"}},gr=class{constructor(t){this.bytes=t}bytes;offset=0;get done(){return this.offset===this.bytes.byteLength}readVarUint(){let t=0,n=1,r=0;for(;;){if(this.offset>=this.bytes.byteLength)throw new ne("Truncated varUint");let o=this.bytes[this.offset++],s=o&127;if(s>Math.floor((lp-t)/n))throw new ne("varUint exceeds Number.MAX_SAFE_INTEGER");if(t+=s*n,r+=1,(o&128)===0){if(r>1&&s===0)throw new ne("Non-canonical varUint");return t}if(r>=8)throw new ne("varUint exceeds Number.MAX_SAFE_INTEGER");n*=128}}readVarUint8Array(){let t=this.readVarUint(),n=this.bytes.byteLength-this.offset;if(t>n)throw new ne("Truncated varUint8Array");let r=this.bytes.slice(this.offset,this.offset+t);return this.offset+=t,r}readVarString(){let t=this.readVarUint8Array();try{return new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch(n){throw new ne(`Invalid UTF-8 string${n instanceof Error?`: ${n.message}`:""}`)}}};wc=BigInt(lt),fp=65536});var ye,as=U(()=>{"use strict";ye=class extends Error{code;cause;constructor(t,n,r){super(n),this.name="CollaborationError",this.code=t,this.cause=r}}});function Cc(e){return up.get(e)}function _c(e){return pp.get(e)}var up,pp,Pc=U(()=>{"use strict";up=new WeakMap;pp=new WeakMap});function ls(e,t,n){if(!Number.isSafeInteger(t)||t<(n?0:1))throw new RangeError(`${e} must be ${n?"a non-negative":"a positive"} integer`);return t}function bp(e){return e instanceof Error&&e.message?e.message:typeof e=="string"&&e?e:"Unknown error"}function se(e,t,n){return n instanceof ye?n:new ye(e,`${t}: ${bp(n)}`,n)}function He(e,t){if(!(e instanceof Uint8Array))throw new TypeError(`${t} must return a Uint8Array`);return e.slice()}function cs(e){e.unref?.()}function Ac(e){return Rc.get(e)()}function Ec(e){return Fc.get(e)()}var mp,hp,Rc,Fc,kr,Tc=U(()=>{"use strict";Yl();vc();Zo();as();Pc();mp=Se,hp=1e3;Rc=new WeakMap,Fc=new WeakMap;kr=class{replica;piped;asyncReplica;replicaTail=Promise.resolve();replicaBytes=0;updateBatch=null;syncArrival;openEpoch=0;transport;maxFrameBytes;maxMessagesPerFrame;maxPendingBytes;statusListeners=new Map;errorListeners=new Map;awarenessListeners=new Map;awarenessStore=new Map;awarenessUser;pendingFrames=[];unsubscribeReplica;unsubscribeTransport=()=>{};hasTransportSubscription=!1;connectionStatus="disconnected";isSynced=!1;wantsConnection=!1;isOpen=!1;isDestroyed=!1;epoch=0;connectAttempt=0;nextListenerId=0;queuedBytes=0;isFlushing=!1;transportCleanup;statusRevision=0;awarenessClock=0;reportedClockExhaustion=!1;awarenessCursor=null;lastAwarenessSentAt=Number.NEGATIVE_INFINITY;awarenessBroadcastTimer;awarenessHeartbeatTimer;awarenessExpiryTimer;hasPublishedAwarenessForOpen=!1;constructor(t,n,r={}){this.replica=t,this.asyncReplica=Cc(t),this.transport=n,this.maxFrameBytes=ls("maxFrameBytes",r.maxFrameBytes??Se,!1),this.maxMessagesPerFrame=ls("maxMessagesPerFrame",r.maxMessagesPerFrame??ts,!1),this.maxPendingBytes=ls("maxPendingBytes",r.maxPendingBytes??mp,!0),this.awarenessUser=oc(r.user,t.clientId),Rc.set(this,()=>this.beginArrival()),Fc.set(this,()=>this.leaveFrame());let o=_c(t);if(o){this.unsubscribeReplica=()=>{};let s;this.piped=new hr(o,{connect:()=>this.connectPipedTransport(()=>s?.()),disconnect:()=>{this.wantsConnection=!1,this.connectAttempt+=1;let i=this.cleanupTransport(()=>{},!0);if(i.length)throw i[0]},send:i=>n.send(i),onEvent:i=>{if(!this.transportCleanup)return n.onEvent(i);let l=!0,a=()=>{},f=()=>{s=void 0;try{let d=n.onEvent(i);if(typeof d!="function")throw new TypeError("Transport event subscription must return a function");l?a=d:d()}catch(d){throw se("transport","Failed to subscribe to transport events",d)}};return s=f,()=>{l=!1,s===f&&(s=void 0),a()}}},{worker:{maxFrameBytes:this.maxFrameBytes,maxMessagesPerFrame:this.maxMessagesPerFrame,user:{...this.awarenessUser}},maxPendingBytes:this.maxPendingBytes,hasUser:!0,makeError:(i,l,a)=>new ye(i,l,a),normalize:se});return}try{this.unsubscribeReplica=t.onUpdate((s,i)=>{i==="local"&&this.forwardLocalUpdate(s)})}catch(s){throw se("replica","Failed to observe replica updates",s)}}get status(){return this.piped?this.piped.status:this.connectionStatus}get synced(){return this.piped?this.piped.synced:this.isSynced}get pendingBytes(){return this.piped?this.piped.pendingBytes:this.queuedBytes}get peers(){return this.piped?this.piped.peers:ac(this.awarenessStore)}connect(){if(this.piped)return this.piped.connect();this.isDestroyed||this.isOpen||this.connectionStatus==="connecting"||(this.wantsConnection=!0,this.setStatus("connecting",!1),!(this.transportCleanup||this.isDestroyed||!this.wantsConnection)&&this.startConnection())}connectPipedTransport(t){this.wantsConnection=!0;let n=++this.connectAttempt;return this.transportCleanup?this.transportCleanup.then(()=>{if(!(this.isDestroyed||!this.wantsConnection||n!==this.connectAttempt)&&(t(),!(this.isDestroyed||!this.wantsConnection||n!==this.connectAttempt)))return this.transport.connect()}):this.transport.connect()}startConnection(){if(this.isDestroyed||!this.wantsConnection||this.isOpen||this.transportCleanup)return;let t=this.hasTransportSubscription?this.epoch:++this.epoch,n=++this.connectAttempt;if(this.setStatus("connecting",!1),!!this.isCurrent(t)){if(!this.hasTransportSubscription){let r;try{if(r=this.transport.onEvent(o=>this.handleTransportEvent(t,o)),typeof r!="function")throw new TypeError("Transport event subscription must return a function")}catch(o){this.failConnection(t,se("transport","Failed to subscribe to transport events",o));return}if(!this.isCurrent(t)){try{r()}catch(o){this.isDestroyed||this.report(se("transport","Failed to unsubscribe from stale transport events",o))}return}this.unsubscribeTransport=r,this.hasTransportSubscription=!0}try{let r=this.transport.connect();r&&r.catch(o=>{this.isCurrent(t)&&this.connectAttempt===n&&this.failConnection(t,se("transport","Transport connect failed",o))})}catch(r){this.failConnection(t,se("transport","Transport connect failed",r))}}}disconnect(){if(this.piped)return this.piped.disconnect();if(this.isDestroyed||!(this.wantsConnection||this.isOpen||this.hasTransportSubscription||this.connectionStatus!=="disconnected"))return;this.clearPending(),this.resetReplicaQueue(),this.publishAwareness(null,"best-effort"),this.stopAwarenessTimers(),this.clearAwarenessPeers(),this.hasPublishedAwarenessForOpen=!1,this.wantsConnection=!1,this.isOpen=!1,this.epoch+=1,this.connectAttempt+=1;let n=this.takeTransportSubscription(),r=this.cleanupTransport(n,!0);this.setStatus("disconnected",!1);for(let o of r)this.report(o)}destroy(){if(this.piped){this.isDestroyed=!0,this.piped.destroy(),this.errorListeners.clear();return}if(this.isDestroyed)return;let t=this.wantsConnection||this.isOpen||this.hasTransportSubscription||this.connectionStatus==="connecting"||this.connectionStatus==="connected";this.clearPending(),this.resetReplicaQueue(),this.publishAwareness(null,"best-effort"),this.stopAwarenessTimers(),this.clearAwarenessPeers(),this.hasPublishedAwarenessForOpen=!1,this.isDestroyed=!0,this.wantsConnection=!1,this.isOpen=!1,this.epoch+=1,this.connectAttempt+=1;let n=this.takeTransportSubscription(),r=this.cleanupTransport(n,t);this.setStatus("destroyed",!1);for(let o of r)this.report(o);try{this.unsubscribeReplica()}catch(o){this.report(se("replica","Failed to unsubscribe from replica updates",o))}this.unsubscribeReplica=()=>{},this.statusListeners.clear(),this.errorListeners.clear(),this.awarenessListeners.clear()}onStatus(t){if(this.isDestroyed)return()=>{};if(typeof t!="function")throw new TypeError("status listener must be a function");if(this.piped)return this.piped.onStatus(t);let n=this.nextListenerId++;return this.statusListeners.set(n,t),()=>this.statusListeners.delete(n)}onError(t){if(this.isDestroyed)return()=>{};if(typeof t!="function")throw new TypeError("error listener must be a function");let n=this.piped?.onError(t),r=this.nextListenerId++;return this.errorListeners.set(r,t),()=>{n?.(),this.errorListeners.delete(r)}}onAwareness(t){if(this.isDestroyed)return()=>{};if(typeof t!="function")throw new TypeError("awareness listener must be a function");if(this.piped)return this.piped.onPeers(r=>{try{t(r)}catch{}});let n=this.nextListenerId++;this.awarenessListeners.set(n,t);try{t(this.peers)}catch{}return()=>this.awarenessListeners.delete(n)}setCursor(t){if(this.isDestroyed)return;let n=t?lc(t):!1;if(this.awarenessCursor=t&&n?{sheet:t.sheet,anchor:{...t.anchor},head:{...t.head}}:null,t&&!n&&this.report(new ye("protocol",`Awareness cursor needs a sheet identifier of 1 to ${mn} characters and non-negative cell coordinates; cursor dropped`)),this.piped){this.piped.setCursor(this.awarenessCursor,!0);return}if(!this.isOpen||!this.wantsConnection)return;let r=ec-(Date.now()-this.lastAwarenessSentAt);if(r<=0){this.publishAwareness();return}this.awarenessBroadcastTimer||(this.awarenessBroadcastTimer=setTimeout(()=>{this.awarenessBroadcastTimer=void 0,this.publishAwareness()},r),cs(this.awarenessBroadcastTimer))}isCurrent(t){return!this.isDestroyed&&this.wantsConnection&&t===this.epoch}failConnection(t,n){if(!this.isCurrent(t))return;this.resetReplicaQueue(),this.stopAwarenessTimers(),this.clearAwarenessPeers(),this.hasPublishedAwarenessForOpen=!1,this.wantsConnection=!1,this.isOpen=!1,this.epoch+=1,this.connectAttempt+=1;let r=this.takeTransportSubscription();this.clearPending();let o=this.cleanupTransport(r,!0);this.setStatus("disconnected",!1),this.report(n);for(let s of o)this.report(s)}takeTransportSubscription(){let t=this.unsubscribeTransport;return this.unsubscribeTransport=()=>{},this.hasTransportSubscription=!1,t}cleanupTransport(t,n){let r=[];try{t()}catch(o){r.push(se("transport","Failed to unsubscribe from transport events",o))}if(!n||this.transportCleanup)return r;try{let o=this.transport.disconnect();if(o){let s=!1,i=Promise.resolve(o).catch(l=>{s=!0,this.isDestroyed||this.report(se("transport","Transport disconnect failed",l))}).finally(()=>{this.transportCleanup===i&&(s&&!this.isDestroyed&&(this.wantsConnection=!1,this.piped?.disconnect()),this.transportCleanup=void 0,!this.isDestroyed&&(s?this.piped||this.setStatus("disconnected",!1):this.wantsConnection&&!this.piped&&this.startConnection()))});this.transportCleanup=i}}catch(o){r.push(se("transport","Transport disconnect failed",o))}return r}handleTransportEvent(t,n){if(this.isCurrent(t))switch(n.type){case"open":this.handleOpen(t);break;case"message":this.isOpen&&this.handleMessage(t,n.data);break;case"close":this.resetReplicaQueue(),this.stopAwarenessTimers(),this.clearAwarenessPeers(),this.hasPublishedAwarenessForOpen=!1,this.isOpen=!1,this.connectAttempt+=1,this.clearPending(),this.setStatus("disconnected",!1);break;case"error":this.failConnection(t,se("transport","Transport error",n.error));break;case"drain":this.isOpen&&this.flushPending();break;default:this.failConnection(t,new ye("transport","Unknown transport event"))}}handleOpen(t){if(this.isOpen)return;let n=++this.openEpoch;if(this.replicaTail=Promise.resolve(),this.replicaBytes=0,this.updateBatch=null,this.isOpen=!0,this.hasPublishedAwarenessForOpen=!1,this.clearPending(),this.setStatus("connected",!1),!this.isCurrent(t)||!this.isOpen)return;if(this.asyncReplica){Promise.resolve().then(()=>{if(this.isCurrentOpen(t,n))return this.asyncReplica.encodeStateVector()}).then(s=>{this.isCurrentOpen(t,n)&&this.sendHandshake(t,He(s,"encodeStateVector"),n)}).catch(s=>{this.isCurrentOpen(t,n)&&this.failConnection(t,se("replica","Failed to encode replica state vector",s))});return}let r;try{r=He(this.replica.encodeStateVector(),"encodeStateVector")}catch(o){this.failConnection(t,se("replica","Failed to encode replica state vector",o));return}this.sendHandshake(t,r,n)}sendHandshake(t,n,r){if(!this.isCurrentOpen(t,r))return;let o;try{o=Sc(n),this.sendFrame(wr(o??n,this.maxFrameBytes))}catch(s){this.failConnection(t,se("protocol","Failed to encode collaboration handshake",s));return}if(!o&&this.isCurrentOpen(t,r)&&this.sendFullUpdate(t,r),!!this.isCurrentOpen(t,r)){try{this.sendFrame(yc(this.maxFrameBytes))}catch(s){this.report(se("protocol","Failed to encode awareness query",s))}this.isCurrentOpen(t,r)&&(this.hasPublishedAwarenessForOpen||this.publishAwareness(),this.isCurrentOpen(t,r)&&this.startAwarenessTimers())}}sendFullUpdate(t,n){let r=i=>{if(this.isCurrentOpen(t,n))try{this.sendFrame(os(i,this.maxFrameBytes))}catch(l){this.failConnection(t,se("protocol","Failed to encode collaboration handshake",l))}},o=i=>{this.isCurrentOpen(t,n)&&this.failConnection(t,se("replica","Failed to encode replica update",i))};if(this.asyncReplica){this.asyncReplica.encodeStateAsUpdate().then(i=>He(i,"encodeStateAsUpdate")).then(r,o);return}let s;try{s=He(this.replica.encodeStateAsUpdate(),"encodeStateAsUpdate")}catch(i){o(i);return}r(s)}handleMessage(t,n,r){let o;try{if(!(n instanceof Uint8Array))throw new TypeError("Frame must be a Uint8Array");if(n.byteLength>this.maxFrameBytes)throw new RangeError(`Frame exceeds ${this.maxFrameBytes} bytes`);o=r??xc(n,this.maxFrameBytes,this.maxMessagesPerFrame)}catch(s){this.failConnection(t,se("protocol","Invalid collaboration frame",s));return}if(this.asyncReplica&&!r){let s=[];for(let i of o){if(!this.isCurrent(t)||!this.isOpen)return;i.type==="sync-step-1"||i.type==="sync-step-2"||i.type==="update"?s.push(i):this.handleMessage(t,new Uint8Array,[i])}s.length&&this.isCurrent(t)&&this.isOpen&&(this.asyncReplica.applyUpdateChunks&&s.every(i=>i.type==="update")?this.enqueueRemoteUpdates(t,n.byteLength,s.map(i=>i.update)):this.enqueueReplicaMessages(t,n.byteLength,s));return}for(let s of o){if(!this.isCurrent(t)||!this.isOpen)return;switch(s.type){case"sync-step-1":this.respondToSyncStep1(t,s.stateVector);break;case"sync-step-2":{let i=this.syncArrival,l=this.syncArrival={deferred:!1};try{this.applyRemoteUpdate(t,s.update)&&this.isCurrent(t)&&!l.deferred&&this.setStatus("connected",!0)}finally{this.syncArrival=i}break}case"update":this.applyRemoteUpdate(t,s.update);break;case"awareness":try{let i=[],l=0,a=sc(this.awarenessStore,gc(s.update,hn,f=>i.push(f)),this.replica.clientId,Date.now(),{onPeersDiscarded:f=>{l=f}});for(let f of i)this.report(se("protocol","Invalid awareness update",f));if(l>0&&this.report(new ye("protocol",`${l} awareness ${l===1?"entry was":"entries were"} discarded because the tracked peer limit of ${Qo} was reached`)),!this.isCurrent(t)||!this.isOpen)return;a&&this.emitAwareness()}catch(i){this.report(se("protocol","Invalid awareness update",i))}break;case"auth":this.failConnection(t,new ye("protocol",s.reason?`Authentication denied: ${s.reason}`:"Authentication denied"));return;case"query-awareness":this.publishAwareness();break}}}isCurrentOpen(t,n){return this.isCurrent(t)&&this.isOpen&&n===this.openEpoch}resetReplicaQueue(){this.openEpoch+=1,this.replicaTail=Promise.resolve(),this.replicaBytes=0,this.updateBatch=null}enqueueReplicaMessages(t,n,r){if(n>this.maxPendingBytes-this.replicaBytes){this.failConnection(t,new ye("backpressure","Pending replica data exceeds the byte limit"));return}this.replicaBytes+=n,this.updateBatch=null;let o=this.openEpoch,s=this.replicaTail.then(async()=>{for(let i of r){if(!this.isCurrentOpen(t,o))return;try{if(i.type==="sync-step-1"){let l=is(i.stateVector),a=await this.asyncReplica.encodeStateAsUpdate(et(l.stateVector).slice());if(!this.isCurrentOpen(t,o))return;if(this.sendFrame(rs(He(a,"encodeStateAsUpdate"),this.maxFrameBytes)),l.open&&this.isCurrentOpen(t,o)){let f=He(await this.asyncReplica.encodeStateVector(),"encodeStateVector");this.isCurrentOpen(t,o)&&this.sendFrame(wr(f,this.maxFrameBytes))}}else(i.type==="sync-step-2"||i.type==="update")&&(await this.asyncReplica.applyUpdate(et(i.update).slice()),i.type==="sync-step-2"&&this.isCurrentOpen(t,o)&&this.setStatus("connected",!0))}catch(l){this.isCurrentOpen(t,o)&&this.failConnection(t,se("replica","Async replica operation failed",l));return}}}).finally(()=>{o===this.openEpoch&&(this.replicaBytes-=n)});this.replicaTail=s.catch(()=>{})}enqueueRemoteUpdates(t,n,r){if(n>this.maxPendingBytes-this.replicaBytes){this.failConnection(t,new ye("backpressure","Pending replica data exceeds the byte limit"));return}this.replicaBytes+=n;let o=this.openEpoch,s=r.map(f=>et(f).slice()),i=this.updateBatch;if(i?.connection===o){i.updates.push(...s),i.bytes+=n;return}let l={connection:o,bytes:n,updates:s};this.updateBatch=l;let a=this.replicaTail.then(async()=>{if(this.updateBatch===l&&(this.updateBatch=null),!!this.isCurrentOpen(t,o))try{l.updates.length===1?await this.asyncReplica.applyUpdate(l.updates[0]):await this.asyncReplica.applyUpdateChunks(l.updates)}catch(f){this.isCurrentOpen(t,o)&&this.failConnection(t,se("replica","Async replica operation failed",f))}}).finally(()=>{o===this.openEpoch&&(this.replicaBytes-=l.bytes)});this.replicaTail=a.catch(()=>{})}respondToSyncStep1(t,n){let r=is(n),o;try{o=He(this.replica.encodeStateAsUpdate(et(r.stateVector).slice()),"encodeStateAsUpdate")}catch(i){this.failConnection(t,se("replica","Failed to encode replica update",i));return}try{this.sendFrame(rs(o,this.maxFrameBytes))}catch(i){this.failConnection(t,se("protocol","Failed to encode SyncStep2",i));return}if(!r.open||!this.isCurrent(t)||!this.isOpen)return;let s;try{s=He(this.replica.encodeStateVector(),"encodeStateVector")}catch(i){this.failConnection(t,se("replica","Failed to encode replica state vector",i));return}try{this.sendFrame(wr(s,this.maxFrameBytes))}catch(i){this.failConnection(t,se("protocol","Failed to encode collaboration handshake",i))}}beginArrival(){let t=this.epoch,n=this.openEpoch,r=this.syncArrival;r&&(r.deferred=!0);let o=!1,s=i=>{o||(o=!0,this.isCurrentOpen(t,n)&&i())};return{settle:()=>s(()=>{r&&this.setStatus("connected",!0)}),fail:i=>s(()=>this.failConnection(t,se("replica","Failed to apply remote update",i)))}}leaveFrame(){if(!this.isOpen||this.isDestroyed||!this.wantsConnection||this.awarenessClock>=Number.MAX_SAFE_INTEGER)return null;try{let t=this.awarenessClock+1;return{clock:t,frame:ss([{clientId:this.replica.clientId,clock:t,state:null}],this.maxFrameBytes)}}catch{return null}}applyRemoteUpdate(t,n){try{return this.replica.applyUpdate(et(n).slice()),!0}catch(r){return this.failConnection(t,se("replica","Failed to apply remote update",r)),!1}}forwardLocalUpdate(t){if(this.isDestroyed||!this.isOpen||!this.wantsConnection)return;let n=this.epoch,r;try{r=He(t,"Replica update")}catch(o){this.failConnection(n,se("replica","Invalid replica update",o));return}try{this.sendFrame(os(r,this.maxFrameBytes))}catch(o){this.failConnection(n,se("protocol","Failed to encode update",o))}}publishAwareness(t="current",n="queued"){if(!(!this.isOpen||this.isDestroyed||!this.wantsConnection)){if(this.awarenessBroadcastTimer&&(clearTimeout(this.awarenessBroadcastTimer),this.awarenessBroadcastTimer=void 0),this.awarenessClock>=Number.MAX_SAFE_INTEGER){n==="queued"&&!this.reportedClockExhaustion&&(this.reportedClockExhaustion=!0,this.report(new ye("protocol","Awareness clock exhausted")));return}this.awarenessClock+=1;try{this.hasPublishedAwarenessForOpen=!0;let r=ss([{clientId:this.replica.clientId,clock:this.awarenessClock,state:t===null?null:{user:this.awarenessUser,cursor:this.awarenessCursor}}],this.maxFrameBytes);n==="best-effort"?this.sendBestEffort(r):this.sendFrame(r),this.lastAwarenessSentAt=Date.now()}catch(r){n==="queued"&&this.report(se("protocol","Failed to encode awareness update",r))}}}startAwarenessTimers(){this.stopAwarenessTimers(),this.awarenessHeartbeatTimer=setInterval(()=>{this.publishAwareness()},tc),this.awarenessExpiryTimer=setInterval(()=>{ic(this.awarenessStore,Date.now(),Go)&&this.emitAwareness()},hp),cs(this.awarenessHeartbeatTimer),cs(this.awarenessExpiryTimer)}stopAwarenessTimers(){this.awarenessBroadcastTimer&&clearTimeout(this.awarenessBroadcastTimer),this.awarenessHeartbeatTimer&&clearInterval(this.awarenessHeartbeatTimer),this.awarenessExpiryTimer&&clearInterval(this.awarenessExpiryTimer),this.awarenessBroadcastTimer=void 0,this.awarenessHeartbeatTimer=void 0,this.awarenessExpiryTimer=void 0}clearAwarenessPeers(){if(this.awarenessStore.size===0)return;let t=this.peers.length>0;this.awarenessStore.clear(),t&&this.emitAwareness()}emitAwareness(){let t=this.peers;for(let[n,r]of[...this.awarenessListeners])if(this.awarenessListeners.get(n)===r)try{r(t)}catch{}}sendFrame(t){if(!this.isOpen||this.isDestroyed||!this.wantsConnection)return;let n=this.epoch;if(this.pendingFrames.length>0){this.queueFrame(n,t);return}let r;try{r=this.transport.send(t.slice())}catch(o){this.failConnection(n,se("transport","Transport send failed",o));return}if(typeof r!="boolean"){this.failConnection(n,new ye("transport","Transport send must return a boolean"));return}!r&&this.isCurrent(n)&&this.isOpen&&this.queueFrame(n,t)}sendBestEffort(t){try{this.transport.send(t.slice())}catch{}}queueFrame(t,n){if(n.byteLength>this.maxPendingBytes-this.queuedBytes){this.failConnection(t,new ye("backpressure",`Pending collaboration data exceeds ${this.maxPendingBytes} bytes`));return}let r=n.slice();this.pendingFrames.push(r),this.queuedBytes+=r.byteLength}flushPending(){if(!this.isFlushing){this.isFlushing=!0;try{for(;this.isOpen&&!this.isDestroyed&&this.pendingFrames.length>0;){let t=this.epoch,n=this.pendingFrames[0],r;try{r=this.transport.send(n.slice())}catch(o){this.failConnection(t,se("transport","Transport send failed",o));return}if(typeof r!="boolean"){this.failConnection(t,new ye("transport","Transport send must return a boolean"));return}if(!r||!this.isOpen||this.pendingFrames[0]!==n)return;this.pendingFrames.shift(),this.queuedBytes-=n.byteLength}}finally{this.isFlushing=!1}}}clearPending(){this.pendingFrames.length=0,this.queuedBytes=0}setStatus(t,n){if(this.connectionStatus===t&&this.isSynced===n)return;this.connectionStatus=t,this.isSynced=n;let r=++this.statusRevision,o={status:t,synced:n};for(let[s,i]of[...this.statusListeners]){if(this.statusRevision!==r)return;if(this.statusListeners.get(s)===i)try{i(o)}catch{}}}report(t){for(let[n,r]of[...this.errorListeners])if(this.errorListeners.get(n)===r)try{r(t)}catch{}}}});var Lc={};Mt(Lc,{createWorkbookCollaborationHost:()=>yp});function yp(e,t){return Gl({clientId:e.clientId,read:{encodeStateVector:()=>e.encodeStateVector(),encodeStateAsUpdate:n=>e.encodeStateAsUpdate(n)},onUpdate:n=>e.onUpdate(n),merge(n){for(let r of n){let o=e.version();try{e.applyUpdate(r)}catch(s){if(!(s instanceof Error)||ue(s)||e.version()!==o)throw s;return{failed:s}}}return{applied:null}},createProvider:(n,r,o)=>{let s=new kr(n,r,o);return Object.assign(s,{onPeers:i=>s.onAwareness(i)})},arrive:Ac,leave:Ec,transportError:n=>new ye(n.code,n.message),onOutput:t})}var Oc=U(()=>{"use strict";Ql();Tc();as();Ve()});function Wc(e){return e.sheetIds.map((t,n)=>({id:t,index:n,name:e.sheetNames[n]}))}function Mc(){let e=globalThis.crypto.getRandomValues(new Uint8Array(16));return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}function Nc(e,t={}){let n,r=!1,o,s=0,i=!1,l=0,a=0,f=0,d=!1,p=!1,y={session:Mc(),incarnation:Mc()},k,u,h=!1,C=()=>{},v,P,L,B,D=[],V=new TextEncoder;function R(){r||P!==void 0||(P=setTimeout(()=>{P=void 0;let E=v?.drain();E&&ae.emit("collaborationPipe",E.batches,E.transfer)},0))}function J(E){if(!v)throw new H("unsupported");v.run(E)}function O(){if(r)throw new Error("Workbook session is disposed");if(!n)throw new Error("Workbook session is not open");return n}function F(){r=!0,P!==void 0&&clearTimeout(P),P=void 0,v?.dispose(),v=void 0;let E=n;n=void 0,C(),C=()=>{},E?.dispose(),L=void 0,B=void 0,D.length=0,k=void 0,u=void 0}function x(E,w){if(!Number.isInteger(w)||w<0||w>=E.sheetCount())throw new RangeError("Sheet index is out of range")}function g(E,w){let A=O();if(!k?.throughSeq)return w(E);let T=A.sheetInfo().sheetIds,I;try{I=Ye(E,k.sheetIds,T,!0)}catch(z){if(!(z instanceof H))throw z;return{ok:!1,version:A.version(),failure:{code:"missing-target",message:"The command sheet no longer exists"}}}return Ye(w(I),T,k.sheetIds)}function c(E,w){let A=O();x(A,w);let T=V.encode(Fo(A,E,w)).buffer;return l+=1,{displayList:T,version:A.version(),epoch:l,sequence:k?.throughSeq||a,sheet:w,viewport:E,mergedRanges:A.visibleMergedRanges(w,E)}}function b(E,w){let A=O();if(!or())throw _t();return Bt(A.renderPng(E,w).then(S))}function S(E){let w=E.buffer instanceof ArrayBuffer&&E.byteOffset===0&&E.byteLength===E.buffer.byteLength?E.buffer:new Uint8Array(E).buffer;return he(w,[w])}function W(E){let w=O(),A=w.exportStructured(E);if(!k?.throughSeq)return A;let T=E?.maxBytes,I=T!==void 0&&Number.isFinite(T)?T:8*1024*1024,z=Ye(A,w.sheetInfo().sheetIds,k.sheetIds);return z.ok&&V.encode(JSON.stringify(z.content)).byteLength>I?{ok:!1,version:z.version,failure:{code:"limit-exceeded",target:null,message:"The exported content exceeds maxBytes"}}:z}function M(E){let w=O();x(w,E);let{contentWidth:A,contentHeight:T,frozenRows:I,frozenCols:z,initialScrollX:we,initialScrollY:ie}=w.sheetInfoFor(E),_=w.cellRect(E,Math.max(0,I-1),Math.max(0,z-1));return{sheet:E,version:w.version(),contentWidth:A,contentHeight:T,frozenRows:I,frozenCols:z,initialScrollX:we,initialScrollY:ie,frozenWidth:z===0?0:_.x+_.w,frozenHeight:I===0?0:_.y+_.h}}function G(E){u=jl({handle:O(),state:k,applyPipe:J,...E?{revision:E.revision,versions:E.versions,refusedSeqs:E.refusedSeqs,refusedRanges:E.refusedRanges,refusedOutcomes:E.refusedOutcomes}:{},sessionState:()=>({version:s,dirty:i}),frame:(w,A)=>({...c(w.viewport,w.sheet),...y,sequence:A,coversThroughSeq:A,requestGeneration:w.requestGeneration??w.generation,zoom:w.zoom,dpr:w.dpr}),onCommit(){s+=1,i=!0,ae.emit("changed",{version:s,dirty:i})}})}let re={beginPeerSnapshot(E,w,A){let T=O();if(B=void 0,!d||p)throw new Error("Worker peer snapshot requires pending retained hydration");try{return ft(T).begin(w,A),B={version:T.version(),sequence:a,records:w,bytes:A},{version:B.version,sequence:a}}catch(I){try{ft(T).end()}catch{}throw new Error(I instanceof Error?I.message:String(I))}},pullPeerSnapshot(){let E=O();try{let w=Y(E),A=[],T=0;for(;A.length<w.records&&T<w.bytes;){let I=w.pending??ft(E).next();if(w.pending=void 0,I===void 0)break;let z=I.buffer;if(!(z instanceof ArrayBuffer)||I.byteOffset!==0||I.byteLength!==z.byteLength)throw new Error("Worker peer snapshot chunk is not transferable");if(A.length>0&&T+I.byteLength>w.bytes){w.pending=I;break}A.push(z),T+=I.byteLength}return A.length===0?void 0:he(A,A)}catch(w){B=void 0;try{ft(E).end()}catch{}throw new Error(w instanceof Error?w.message:String(w))}},endPeerSnapshot(E,w){let A=O();try{w||Y(A),ft(A).end()}catch(T){try{ft(A).end()}catch{}throw new Error(T instanceof Error?T.message:String(T))}finally{B=void 0}},preview(E,w,A,T){let I=O();if(x(I,A),!L)throw new Error("Worker preview requires retained hydration");let z=Ha(L.bytes,{},L.hydration);try{for(let ie of D){z.setCalculationContext(ie.calculation);try{Ft(z,ie.op)}catch(_){if(!(_ instanceof Me)||!ie.staleProposal)throw _}}for(let ie of T){an({sequence:1,calculation:{nowSerial:0,randSeed:0},op:ie}),ie.calculation&&z.setCalculationContext(ie.calculation);let _=Ft(z,ie);if(ln(_))throw new ds(_)}let we=V.encode(al(()=>Fo(z,w,A))).buffer;return he({displayList:we,version:z.version(),epoch:0,sequence:a,sheet:A,viewport:w,mergedRanges:z.visibleMergedRanges(A,w)},[we])}finally{z.dispose()}},attachPeer(E,w,A){if(p=!1,w!==O().version()||A!==a)throw new Ot("version-mismatch","Workbook worker state differs from retained peer hydration");p=!0,L=void 0,D.length=0},detachPeer(){p=!1},replay(E,w){if(an(w),d&&!p)throw new Ot("mutation-outside-replay","Workbook replay requires an attached edit peer");let A=O();if(w.sequence!==a+1){let I=new Error(`Expected workbook replay sequence ${a+1}, got ${w.sequence}`);throw I.name="WorkbookReplayOrderError",I}let T=w.op;try{let I=A.version();A.setCalculationContext(w.calculation);let z;try{if(z=Ft(A,!d&&T.method==="applyEdits"?{method:"applyEdits",args:[{...T.args[0],expectVersion:I}]}:T),w.staleProposal)throw new Error("Expected a stale proposal refresh")}catch(ie){if(!(ie instanceof Me)||!w.staleProposal||JSON.stringify({cells:ie.cells,targets:ie.targets})!==JSON.stringify(w.staleProposal))throw ie}if(ln(z))throw new Error(`Engine refused replay: ${JSON.stringify(z)}`);let we=A.version()!==I;return a=w.sequence,L&&D.push(structuredClone(w)),we&&(f+=1,s+=1,i=!0,ae.emit("changed",{version:s,dirty:i})),{sequence:a,revision:f,version:s,result:z}}catch(I){let z=`Workbook replay diverged at sequence ${w.sequence} (${T.method})`;throw new Z(ue(I)?"trap":"crash",z,`${z}: ${I instanceof Error?I.message:String(I)}`)}}};function Y(E){if(!B)throw new Error("Worker peer snapshot is not active");if(B.version!==E.version()||B.sequence!==a)throw new Error("Workbook changed during peer snapshot");return B}let te={async decodeFontFace(E,w,A,T){if(r)throw new Error("Workbook session is disposed");if(await(t.initWasm??ze)(T,o===void 0?void 0:{png:o}),r)throw new Error("Workbook session is disposed");let I=await tr(w,A);return he(I,I.payload===void 0?[I.font]:[I.font,I.payload])},async openRecovery(E,w,A={}){if(r)throw new Error("Workbook session is disposed");if(n)throw new Error("Workbook session is already open");let T=Xl(w.state);if(w.epoch!==T.epoch||w.version!==T.revision||w.throughSeq!==T.throughSeq)throw new TypeError("Workbook recovery envelope mismatch");if(ql(T.engine))throw new Error("Recovery is unavailable for collaborative workbooks");if(Lo(A.fontCdn),o=A.png,await(t.initWasm??ze)(A.wasm,{png:A.png}),r)throw new Error("Workbook session is disposed");let I=Eo(T.engine,T.throughSeq);try{y.session=T.session,k=Jl(I,T,y),s=T.hostVersion,i=T.dirty,n=I,G(T);let z=I.sheetInfo();return{format:"xlsx",stage:"ready",version:s,dirty:i,sheets:k.sheetIds.map((we,ie)=>({id:we,index:ie,name:z.sheetNames[ie]})),activeSheet:z.activeSheet,commandContext:{...y,basis:{epoch:k.epoch,version:I.version()}},throughSeq:k.throughSeq,revision:T.revision,historyReset:k.historyReset===!0,pngExport:or(),selection:k.selection,editState:k.editState}}catch(z){throw n=void 0,k=void 0,u=void 0,I.dispose(),z}},async open(E,w,A={}){if(r)throw new Error("Workbook session is disposed");if(n)throw new Error("Workbook session is already open");let T=A.initialViewport;if(T&&!pt({sheet:T.sheet??0,viewport:{x:0,y:0,width:T.width,height:T.height},zoom:T.zoom,dpr:T.dpr,generation:T.requestGeneration}))throw new TypeError("Invalid workbook initial paint request");let I="retainPeerHydration"in A&&A.retainPeerHydration===!0;d=I;let z=A.wasm;if(I&&z instanceof ArrayBuffer&&(z=await WebAssembly.compile(z)),Lo(A.fontCdn),o=A.png,await(t.initWasm??ze)(z,{png:A.png}),z??=t.wasmModule?.(),r)throw new Error("Workbook session is disposed");let we=A.collaborative&&!I?await gp.load():void 0;if(r)throw new Error("Workbook session is disposed");let ie=A.calculation??(I&&!A.collaborative?{nowSerial:sl(Date.now()),randSeed:globalThis.crypto.getRandomValues(new Uint32Array(1))[0]>>>0}:void 0),_=Ua(new Uint8Array(w),{collaborative:A.collaborative,clientId:A.clientId,calculation:ie,recalculate:A.recalculate});h=A.collaborative===!0;try{if(A.initialUpdate){if(!h||I)throw new Error("Initial updates require a collaborative worker replica");_.applyUpdate(A.initialUpdate)}A.recoveryVersion!==void 0&&Ja(_,A.recoveryVersion),T?.sheet!==void 0&&(x(_,T.sheet),_.setActiveSheet(T.sheet));let N;if(I&&(L={bytes:new Uint8Array(w).slice(),hydration:Xa(_)}),L){let mt=JSON.parse(L.hydration);N=mt.calculation_context===void 0?void 0:mt.calculation_context===null?null:{nowSerial:mt.calculation_context.now_serial,randSeed:mt.workbook.rand_seed}}I&&z instanceof WebAssembly.Module&&e.post({protocol:1,kind:"wasm-module",url:nt(A.png!==!1).href,module:z,hydration:L.hydration,version:_.version(),sequence:a});let K=_.sheetInfo(),X=Wc(K);n=_,h&&!I&&(C=_.onUpdate((mt,qc)=>{ae.emit("collaborationUpdate",{update:mt,origin:qc})})),h&&!I&&(v=we.createWorkbookCollaborationHost(_,R)),k=fr(y,{epoch:1,version:_.version()},{sheetId:K.sheetIds[K.activeSheet],range:{kind:"a1",a1:"A1"}},K.sheetIds,ie??null),k.collaborative=h&&!I,G(),I&&ae.emit("peerOpened",{version:_.version(),initialCalculation:N});let fe={...k};(T||!I&&A.includeEditState)&&fn(_,fe);let xe={format:"xlsx",stage:"ready",version:s,dirty:i,...h&&!I?{clientId:_.clientId}:{},sheets:X,activeSheet:K.activeSheet,pngExport:or(),commandContext:{...y,basis:{epoch:k.epoch,version:_.version()}},...!I&&fe.editState?{editState:fe.editState,selection:k.selection}:{}};if(!T)return xe;let ge=M(K.activeSheet),Sr={...c({x:ge.initialScrollX,y:ge.initialScrollY,width:T.width/T.zoom,height:T.height/T.zoom},K.activeSheet),...y,coversThroughSeq:0,requestGeneration:T.requestGeneration,zoom:T.zoom,dpr:T.dpr};return u.rememberFrame({sheet:K.activeSheet,viewport:Sr.viewport,zoom:T.zoom,dpr:T.dpr,generation:T.requestGeneration}),he({...xe,initialPaint:{sheetView:ge,frame:Sr,editState:fe.editState}},[Sr.displayList])}catch(N){throw n=void 0,k=void 0,u=void 0,L=void 0,v?.dispose(),v=void 0,C(),C=()=>{},_.dispose(),N}},version:()=>O().version(),collaborationStateVector(){return ce(),O().encodeStateVector()},collaborationStateAsUpdate(E,w){return ce(),O().encodeStateAsUpdate(w)},listDefinedNames:(E,w)=>O().listDefinedNames(w),readCells:(E,w)=>g(w,A=>O().readCells(A)),findText:(E,w)=>g(w,A=>O().findText(A)),validateEdits:(E,w)=>w.expectVersion!==O().version()?O().validateEdits(w):g(w,A=>O().validateEdits(A)),applyEdits(E,w){if(k?.throughSeq)throw new Error("Workbook command sessions require command batches");u?.validateDirectEdits();let A=O().applyEdits(w);return A.ok&&A.applied&&(u?.synchronizeDirectEdits(A.version),s+=1,i=!0,ae.emit("changed",{version:s,dirty:i})),A},async command(E,w){oe(),(w.kind==="applyUpdate"||w.kind==="collabPipe")&&ce();let A=O().version(),T=await u.command(w);return O().version()!==A&&ae.scheduler.bump({version:!0,generation:!0}),T},edit(E,w){return oe(),(w.kind==="applyUpdate"||w.kind==="collabPipe")&&ce(),u.handler(null,w)},checkpoint(E,w=!1){return oe(),u.checkpoint(null,w)},commandFrame(E,w){oe();let A=w?u.requestFrame(w):u.frame();return Bt(A.catch(T=>{if(!(T instanceof Error&&!(T instanceof Z)&&T.message==="No frame is available at the settled command boundary"))throw T}))},frame(E,w,A={}){let T=c(w,A.sheet??O().sheetInfo().activeSheet);return he(T,[T.displayList])},sheetView(E,w){return M(w)},cellGeometry(E,w,A,T){let I=O();return x(I,w),{sheet:w,version:I.version(),rect:I.cellRect(w,A,T),scrollPosition:I.cellPosition(w,A,T)}},selectionData(E,w,A,T,I){let z=O();return x(z,w),z.selectionData(w,A,T,I)},cellInputs(E,w,A){let T=O();return x(T,w),{sheet:w,version:T.version(),cells:T.rangeCells(w,A)}},translateFormulas:(E,w)=>Ka(O(),w),captureFormat(E,w,A){let T=O();return x(T,w),T.captureFormat(w,A)},sheets:()=>Wc({...O().sheetInfo(),...k?.throughSeq?{sheetIds:k.sheetIds}:{}}),calculationStatus:()=>O().calculationStatus(),renderPng:(E,w,A={})=>b(w,A),renderPngFonts:(E,w,A={})=>Jn(O(),w,{...A,fonts:void 0}),exportStructured:(E,w)=>W(w),exportMarkdown(E,w,A){let T=O(),I=T.exportMarkdown(w,A);if(!k?.throughSeq)return I;if(I.ok){let z=W(w);if(!z.ok)return z}return Ye(I,T.sheetInfo().sheetIds,k.sheetIds)},printDisplayList(E,w,A,T,I){let z=O();return x(z,w),S(V.encode(JSON.stringify(z.printDisplayList(w,A,T,I))))},save(){let E=O().save(),w=E.buffer instanceof ArrayBuffer&&E.byteOffset===0&&E.byteLength===E.buffer.byteLength?E.buffer:new Uint8Array(E).buffer;return he(w,[w])},saveWithWarnings(){let{bytes:E,warnings:w}=O().saveWithWarnings(),A=E.buffer instanceof ArrayBuffer&&E.byteOffset===0&&E.byteLength===E.buffer.byteLength?E.buffer:new Uint8Array(E).buffer;return he({bytes:A,warnings:w},[A])},dispose(){O(),F()}};function oe(){if(O(),!u)throw new Error("Workbook commands are not open");if(d||p||a>0)throw new Error("Workbook commands require a session without an edit peer")}function ce(){if(oe(),!h)throw new Error("Workbook session is not collaborative")}for(let E of Object.keys(te)){let w=$o[E],A=te[E];Object.defineProperty(te,E,{enumerable:!0,value:(...T)=>{let I=typeof w=="function"?w(...T.slice(1)):w;if(d&&I.mutates)throw new Ot("mutation-outside-replay",`Cannot call ${E} outside workbook edit-peer replay in retained hydration mode`);return A(...T)}})}let me={...e,post(E,w){let A=kn(E)&&E.kind==="reply"?v?.drain():void 0,T=A?{collabPipe:A.batches}:void 0;e.post(T?{...E,...T}:E,A?[...w??[],...A.transfer]:w)}},ae=nl(me,{handlers:{...te,...re},policies:{...$o,...bl,edit:E=>u?.policy(E)??{lane:"input",reorderable:!1},checkpoint:()=>u?.checkpointPolicy()??{lane:"input",reorderable:!1}},context:null,onDispose:F,trapFailure:wp});return ae}function wp(e){let t=so(e.message)??so(e.diagnostics),n=t?{bytes:t.bytes,memoryBytes:t.budgetBytes}:Ia();return n?new Z("out-of-memory","The workbook is too large: the spreadsheet engine ran out of memory",`An allocation of ${n.bytes} bytes failed with ${Math.round(n.memoryBytes/2**20)} MiB of engine memory; ${e.message}${e.diagnostics?`: ${e.diagnostics}`:""}`):void 0}var gp,ds,Ic=U(()=>{"use strict";rl();ol();Be();er();je();xn();Pt();ao();il();ll();ur();$l();on();Vl();ar();Kl();jo();Ve();gp={load:()=>Promise.resolve().then(()=>(Oc(),Lc))},ds=class extends Error{constructor(n){super(`Preview refused: ${JSON.stringify(n)}`);this.refusal=n;this.name="WorkbookPreviewRefusal";let r=n.failure;this.code=typeof r?.code=="string"?r.code:"refused"}refusal;code}});var Bc={};Mt(Bc,{startSessionWorker:()=>kp});function kp(e){let t=e;if(t[Uc])return;t[Uc]=!0;let n=Ss(e),r,o=!1;n.listen(f=>{bt(f)&&f.kind==="call"&&f.method==="open"&&(o=f.args[1]?.retainPeerHydration===!0)});let s={...n,post:(...f)=>{o&&kn(f[0])&&f[0].kind==="wasm-module"||n.post(...f)}},i=Tr(s,nt(),ze,async f=>(r=await Er(f),r)),l,a=Nc(n,{initWasm:it==="native"?ze:(f,d)=>d?.png!==!1?i(f):(l??=Tr(s,nt(!1),ze,async p=>(r=await Er(p),r)),l(f)),wasmModule:()=>r});Object.assign(globalThis,{__betterofficeEngineProgress:()=>a.progress()})}var Uc,Dc=U(()=>{"use strict";xs();Be();Es();xn();oo();Pt();Ic();Uc=Symbol.for("betteroffice.xlsx.worker.started")});tt();ps(self,vr);var ms=["message","messageerror"];function hs(e,t,n,r){let o=e,s=Symbol.for(r);if(o[s])return;o[s]=!0;let i=[],l=new WeakSet,a=f=>{l.has(f)||(f.stopImmediatePropagation(),i?.push(f))};for(let f of ms)e.addEventListener(f,a);t().then(f=>{f(e);for(let d=i?.shift();d;d=i?.shift()){let p=new MessageEvent(d.type,{data:d.data,ports:[...d.ports],origin:d.origin,lastEventId:d.lastEventId});l.add(p),e.dispatchEvent(p)}i=null;for(let d of ms)e.removeEventListener(d,a)}).catch(f=>{i=null,e.postMessage(n(f instanceof Error?f.message:String(f))),setTimeout(()=>{throw f})})}hs(self,()=>Promise.resolve().then(()=>(Dc(),Bc)).then(e=>e.startSessionWorker),e=>({protocol:1,kind:"failure",code:"crash",message:e}),"betteroffice.xlsx.worker");