@betteroffice/xlsx-react 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.
- package/README.md +39 -6
- package/dist/chunk-3KQXHXGC.js +5 -0
- package/dist/chunk-B27RY7VE.js +1 -0
- package/dist/chunk-BZJYJJ6T.js +1 -0
- package/dist/chunk-BZSN2GH3.js +1 -0
- package/dist/chunk-DRA7WYKM.js +1 -0
- package/dist/chunk-E4NERUDM.js +1 -0
- package/dist/chunk-FO7HA5DA.js +1 -0
- package/dist/chunk-NLAF4WIP.js +1 -0
- package/dist/chunk-O2XFH626.js +1 -0
- package/dist/chunk-PCFKBGCZ.js +2 -0
- package/dist/chunk-QQHWSDLQ.js +1 -0
- package/dist/chunk-RDV7BGSK.js +2 -0
- package/dist/chunk-UQEPJKDK.js +1 -0
- package/dist/chunk-WTQ7SZBY.js +1 -0
- package/dist/chunk-XP7OJI3S.js +1 -0
- package/dist/chunk-ZYRFP7C5.js +2 -0
- package/dist/index.d.ts +353 -57
- package/dist/index.js +1 -1
- package/dist/shortcuts.d.ts +189 -0
- package/dist/shortcuts.js +1 -0
- package/package.json +12 -5
- package/dist/chunk-2S2QUCJE.js +0 -1
- package/dist/chunk-OADYDRKQ.js +0 -3
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {V,W,a,G,Ua,H,x,A,u,k,j,pa as pa$1,qa,w,Na,Fa,Da,oa,i,f,e,c,C,F,E,na,q,l,ua as ua$1,ta,Q,P,ma as ma$1,X,va as va$1,xa as xa$1,Ba,wa as wa$1,ya as ya$1,I,S,Y,M,$,_,h,Ga,ra,sa,t,s,N,O,Ra as Ra$1,n,za,Ta,Aa,z,ga as ga$1,Ca as Ca$1,Wa,y,g,d,v,r,o,b}from'./chunk-OADYDRKQ.js';export{ma as EditorToolbar,R as EditorToolbarContext,G as LocaleProvider,la as Toolbar,aa as ToolbarButton,ia as ToolbarCommand,ga as ToolbarCommandButton,ha as ToolbarCommandSelect,da as ToolbarDropdown,ba as ToolbarGroup,ea as ToolbarMenuItem,fa as ToolbarMenuSeparator,ka as ToolbarOverflow,ca as ToolbarSeparator,Va as XlsxAsyncApiSyncAccessError,w as XlsxCommandAdmissionError,J as XlsxCommandProvider,Oa as XlsxPeerNotReadyError,ja as XlsxPluginToolbar,la as XlsxToolbar,Pa as XlsxWorkerEditorCollaborationError,Sa as XlsxWorkerSessionFailedError,Ma as defineXlsxPlugin,U as useEditorToolbar,H as useTranslation,M as useXlsxCommand,L as useXlsxCommandState,K as useXlsxCommands}from'./chunk-OADYDRKQ.js';import {useMemo,useEffect,useState,useRef,useCallback,useLayoutEffect,Component}from'react';import {selectionAt,isPngExportAvailable,isProposalsAvailable,initWasm,openWorkbook,normalizeRange,paintDisplayList,buildA11yGrid,cellAtPoint,chartRegionAtPoint,moveFocus,toTsv,selectionKeyReducer,extendTo,hyperlinkAtCell,safeExternalHyperlink,parseHyperlinkLocation,rangeRect,cellRect,WorkbookEditPeerFailedError,openWorkbookSession,StaleProposalError,fromTsv}from'@betteroffice/xlsx';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {workbookEditPeerOperations,localNowSerial,workbookSessionInternals,createWorkbookRecoveryMutators,WorkbookRecoveryRefusal}from'@betteroffice/xlsx/worker';import {flushSync}from'react-dom';function Fi(){let n;return {closed:new Promise(l=>{n=l;}),close:n}}function qi(n){return typeof n?.then=="function"}function Vo(n,r){return n.generation===r.generation&&n.source===r.source&&n.sheet===r.sheet&&n.row===r.row&&n.col===r.col}function Mi(n){let r=null,l=null,c=Fi(),y=false,f=false,A=false,I=new WeakSet,d=[],b=[],X=C=>d=d.filter(v=>!Vo(v,C)),x=C=>d=[...d.filter(v=>!Vo(v,C)),C],q=()=>{let C=n.generation();d=d.filter(v=>v.generation===C);},E=C=>{let v=C.then(()=>{},()=>{});l=v,v.then(()=>{l===v&&(l=null,y=false);});},W=(C,v)=>{if(l){let le=l.then(()=>false),oe=Promise.race([le,c.closed.then(()=>true)]).then(U=>U?v():C());return E(oe),oe}let L;try{L=C();}catch(le){return y=false,Promise.reject(le)}return qi(L)?(E(L),L):(y=false,Promise.resolve(L))},V=()=>{},g=()=>{throw new w("document-replaced")},K=()=>{y=true,f&&(A=true);},F=C=>I.has(C)?true:n.write(C)?(I.add(C),X(C),true):false,M=()=>(q(),d.length>0),j=C=>{X(C),b.push(C),W(()=>{b.splice(b.indexOf(C),1),!(C.generation!==n.generation()||F(C))&&(y=!0,!b.some(v=>Vo(v,C))&&(x(C),r===null&&n.restore(C)&&(r=C)));},V);},O=(C,v)=>{if(n.generation()!==v)throw new w("document-replaced");if(y||M())throw new w("input-failed");if(!(!C||C.generation!==v)){if(!F(C))throw y=true,x(C),new w("input-failed");r===C&&(r=null,n.close(C));}};return {get draft(){return r},get rejected(){return d},get pending(){return l!==null},setDraft(C){r=C;},input(C){return W(()=>{let v=le=>{le===!1&&K();},L;try{L=C();}catch{L=!1;}return qi(L)?L.then(v,()=>v(!1)):v(L)},V)},submit(C){return r===C&&(r=null),l?(j(C),true):C.generation!==n.generation()||F(C)?true:(x(C),r=C,false)},discard(C){X(C);},settle(){let C=r;return C?C.generation!==n.generation()?(r=null,true):l?(r=null,n.close(C),j(C),true):F(C)?(r===C&&(r=null,n.close(C)),true):false:true},runAfterPendingInput(C){if(M())return Promise.reject(new w("input-failed"));f=true,A=false;let v;try{v=n.seal();}finally{f=false;}if(v.refused)return Promise.reject(new w(v.refused));if(A)return Promise.reject(new w("input-failed"));let L=n.generation(),le=v.composition;if(le){let U=le.then(J=>{if(J)return n.sync(),r});return W(async()=>{let J=await U;if(J===void 0)throw new w("input-failed");return O(J,L),C()},g)}n.sync();let oe=r;return W(()=>(O(oe,L),C()),g)},reset(){c.close(),c=Fi(),l=null,y=false;}}}var el=new Set(["zoom","searchMenus","proposalsPanel"]);function Bi(n,r){let l=n.cell(r.sheet,r.top,r.left).a1,c=n.cell(r.sheet,r.bottom,r.right).a1;return `${l}:${c}`}function tl(n,r,l,c){let y={key:c,formatting:null,merged:[],canUndo:false,canRedo:false};try{let f=Bi(n,{sheet:r,...l,merged:[],formatting:null});y.formatting=n.selectionFormatting(r,f),y.merged=n.mergedRanges(r,f);}catch{}try{let f=n.historyState();y.canUndo=f.canUndo,y.canRedo=f.canRedo;}catch{}return y}function rl(n,r,l){let c=(f,A,I,d)=>({start:{row:f,col:A},end:{row:I,col:d}}),y=[];if(l==="all")y.push({type:"mergeCells",sheet:n,range:c(r.top,r.left,r.bottom,r.right)});else if(l==="horizontal")for(let f=r.top;f<=r.bottom;f++)y.push({type:"mergeCells",sheet:n,range:c(f,r.left,f,r.right)});else if(l==="vertical")for(let f=r.left;f<=r.right;f++)y.push({type:"mergeCells",sheet:n,range:c(r.top,f,r.bottom,f)});else for(let f of r.merged)y.push({type:"unmergeCells",sheet:n,range:c(f.start.row,f.start.col,f.end.row,f.end.col)});return y}function zi(n,r$1){let l=useRef(r$1);l.current=r$1;let c=useRef(null);useLayoutEffect(()=>{let y=b=>{let X=l.current,x=X.handle(),q=X.view();if(!x||X.status()!=="ready")return null;let E=q.selection?normalizeRange(q.selection):{top:0,left:0,bottom:0,right:0},W=[X.generation(),X.mutation(),q.sheet,E.top,E.left,E.bottom,E.right].join(":");return !b&&c.current?.key===W||(c.current=tl(x,q.sheet,E,W)),c.current},f=b=>{let X=l.current,x=X.view(),q=y(b),E=null;return x.chartSelected?E="chart":x.selection&&q&&(E={sheet:x.sheet,...normalizeRange(x.selection),merged:q.merged,formatting:q.formatting}),{status:X.status(),readOnly:X.readOnly(),collaborative:X.collaborative(),selection:E,canUndo:q?.canUndo??false,canRedo:q?.canRedo??false,pendingInput:X.coordinator.draft!==null,zoom:x.zoom,paintFormat:x.capturedFormat!==null,borderStyle:x.borderStyle??q?.formatting?.borderStyle??null,borderColor:x.borderColor??q?.formatting?.borderColor??null,pngExport:x.pngExport,proposals:x.proposalsAvailable?x.proposals.map(W=>({id:W.id,label:W.agentId})):null,proposalsPanelOpen:x.proposalsPanelOpen,fontFamilies:s,fontSizes:t,translate:X.translate}},A=(b,X,x)=>{let q=l.current,E=q.handle(),W=v=>({ok:false,failure:r(v,x)});if(!E)return W("editor-unavailable");let V=(v=true)=>({ok:true,status:v?"executed":"noop"}),g=v=>{try{return v()}catch(L){return q.fail(L),W("command-failed")}},K=v=>g(()=>{let L=v();return q.apply(L),V(L.applied)}),F=X,M=typeof x.selection=="object"?x.selection:null,j=()=>{if(!M)throw new Error("no cell selection");return {sheet:M.sheet,range:Bi(E,M)}},O=v=>K(()=>{let{sheet:L,range:le}=j();return E.patchRangeStyle(L,le,v)}),C=M?.formatting??null;switch(b){case "bold":return O({bold:C?.bold!==true});case "italic":return O({italic:C?.italic!==true});case "strikethrough":return O({strikethrough:C?.strikethrough!==true});case "paintFormat":return x.paintFormat?(q.setCapturedFormat(null,null),V()):g(()=>{let{sheet:v,range:L}=j(),le=`${v}:${M.top}:${M.left}:${M.bottom}:${M.right}`;return q.setCapturedFormat(E.captureFormat(v,L),le),V()});case "fontFamily":return O({fontFamily:F.family});case "fontSize":return O({fontSize:F.points});case "fontSizeStep":{let v=C?.fontSize??10,L=x.fontSizes,le=F.direction==="increase"?L.find(oe=>oe>v)??v+1:[...L].reverse().find(oe=>oe<v)??Math.max(1,v-1);return O({fontSize:le})}case "textColor":return O({textColor:F.color});case "fillColor":return O({fillColor:F.color});case "numberFormat":return K(()=>{let{sheet:v,range:L}=j();return F.value==="custom"?E.setNumberFormat(v,L,{type:"custom",pattern:C?.numberFormatPattern??"0.00"}):E.setNumberFormat(v,L,F.value)});case "decimalPlaces":return K(()=>{let{sheet:v,range:L}=j();return E.setNumberFormat(v,L,F.direction==="increase"?"increaseDecimal":"decreaseDecimal")});case "borderPreset":return O({border:{preset:F.value,style:x.borderStyle??"solid",color:x.borderColor??"#000000"}});case "borderStyle":return q.setBorderStyle(F.value),O({border:{style:F.value}});case "borderColor":return q.setBorderColor(F.color),O({border:{color:F.color}});case "horizontalAlignment":return O({horizontalAlignment:F.value});case "verticalAlignment":return O({verticalAlignment:F.value});case "textWrapping":return O({textWrapping:F.value});case "merge":{if(!M)return W("cell-selection-required");let v=rl(M.sheet,M,F.value);return v.length===0?V(false):K(()=>E.applyOps(v))}case "undo":return K(()=>E.undo());case "redo":return K(()=>E.redo());case "save":return g(()=>(q.deliver(E.save()),V()));case "exportPng":return g(()=>(q.exportPng(),V()));case "print":{let v=q.generation();return q.afterPaint().then(L=>l.current.generation()!==v?W("document-replaced"):L?(window.print(),V()):W("render-failed"))}case "zoom":return x.zoom===F.scale?V(false):(q.setZoom(F.scale),V());case "proposalsPanel":{let v=X===null?!x.proposalsPanelOpen:F.open;return v===x.proposalsPanelOpen?V(false):(q.setProposalsPanelOpen(v),V())}case "proposalAccept":try{return q.apply(E.acceptProposal(F.proposalId,{force:F.force})),q.markStale(F.proposalId,null),q.refreshProposals(),V()}catch(v){return v instanceof StaleProposalError?(q.markStale(F.proposalId,v.cells),q.refreshProposals(),W("proposal-stale")):(q.fail(v),W("command-failed"))}case "proposalReject":return g(()=>{let v=E.rejectProposal(F.proposalId);return q.markStale(F.proposalId,null),q.refreshProposals(),v?V():W("proposal-not-found")});default:return W("unsupported-command")}},I=b=>{if(!v(b))return "document";let X=l.current.view();return X.chartSelected?"chart":X.selection?`${X.sheet}:${JSON.stringify(normalizeRange(X.selection))}`:"none"},d={requestSave:b=>l.current.requestSave?.(b)??b(),environment:f,ordered:b=>{let X=l.current;return !el.has(b)||X.coordinator.rejected.some(x=>x.generation===X.generation())},admit:b=>l.current.coordinator.runAfterPendingInput(b),perform:A,capture(b){let X=l.current;return X.handle()?{generation:X.generation(),target:I(b)}:null},resume(b,X){let x=l.current;return !x.handle()||x.generation()!==b.generation?"document-replaced":I(X)===b.target?null:"target-changed"},chrome:()=>({i18n:l.current.i18n()}),focusEditor:()=>l.current.focusGrid()};return n.attach(d),()=>n.detach(d)},[n]),useLayoutEffect(()=>{n.refresh();});}var ll={open:openWorkbookSession};function So(n,r){return n!==null&&n.sheet===r.sheet&&n.navigation===r.navigation&&n.zoom===r.zoom&&n.dpr===r.dpr&&n.width===r.width&&n.height===r.height&&Vi(n.viewport,r.viewport)}function Vi(n,r){return n.x===r.x&&n.y===r.y&&n.width===r.width&&n.height===r.height}function $i(n){return [n?.anchor,n?.focus].every(r=>r&&Number.isInteger(r.row)&&r.row>=0&&r.row<=1048575&&Number.isInteger(r.col)&&r.col>=0&&r.col<=16383)}var Ko=class{constructor(r,l,c,y,f$1=()=>true,A=0){a(this,"session",r);a(this,"changed",l);a(this,"report",c);a(this,"onReady",y);a(this,"isCurrent",f$1);a(this,"generation",A);a(this,"selectionNavigation",n());a(this,"emptySelection",selectionAt({row:0,col:0}));a(this,"alive",true);a(this,"failed",false);a(this,"active");a(this,"navigation",0);a(this,"selection",selectionAt({row:0,col:0}));a(this,"view",null);a(this,"painted",null);a(this,"scrollRevision",0);a(this,"scrollTarget",null);a(this,"surface",null);a(this,"raf",null);a(this,"revision",0);a(this,"pending",null);a(this,"running",false);a(this,"ready",false);a(this,"viewRequest",0);a(this,"waiters",new Set);a(this,"selectionContext",()=>{if(!this.current)return null;let r=this.session.confirmedBasis;return {owner:this,sheet:this.active,selection:this.selection??this.emptySelection,navigation:this.navigation,version:`${r.epoch}:${r.version}:${this.session.state.version}`}});a(this,"selectionMerges",(r=this.selectionContext())=>{let l=this.painted?.frame,c=l&&r&&l.sheet===r.sheet&&l.version===this.session.confirmedBasis.version?h(l.mergedRanges):void 0;return r?this.selectionNavigation.merges(r,c):{mergeAt:()=>null}});a(this,"selectionOptions",()=>({context:this.selectionContext,limits:()=>oa(this.painted?.frame.displayList??null,this.surface?.capture()?.viewport.height??0),hidden:()=>f(this.painted?.frame.displayList.grid),merges:this.selectionMerges,known:(r,l)=>{let c=this.painted?.frame;return this.selectionNavigation.known(r,l)||c?.sheet===r.sheet&&c.version===this.session.confirmedBasis.version&&g(c.displayList.grid,l)},query:(r,l)=>this.session.call.selectionData(r.sheet,r.selection.focus.row,r.selection.focus.col,l),apply:(r,l=this.active)=>this.placeCellsAsync(l,r,"nearest",false)}));this.active=r.state.activeSheet;}get current(){return this.alive&&!this.failed&&this.isCurrent()}getPositionAtPoint(r,l){return this.current?this.surface?.getPositionAtPoint?.(r,l)??null:null}connect(r){return this.surface=r,this.schedule(),()=>{this.surface===r&&(this.surface=null,this.cancelFrame());}}start(){this.show(this.active);}async show(r){if(!this.current||!this.validSheet(r))return false;this.beginNavigation();let l=++this.viewRequest;this.active=r,this.view=null,this.selection=selectionAt({row:0,col:0}),this.changed();try{let c=await this.session.call.sheetView(r);return !this.current||l!==this.viewRequest?!1:(this.presentView(c,{x:c.initialScrollX,y:c.initialScrollY}),!0)}catch(c){return this.current&&l===this.viewRequest&&this.fail(c),false}}selectCellsAsync(r,l,c="start"){return !this.current||!this.validSheet(r)||!$i(l)?Promise.resolve(false):this.selectionNavigation.select(l,{...this.selectionOptions(),apply:y=>this.placeCellsAsync(r,y,c)},r)}async placeCellsAsync(r,l,c="start",y=true){if(!this.current||!this.validSheet(r)||!$i(l))return false;let f=structuredClone(l),A=this.beginNavigation();this.viewRequest+=1,c==="nearest"&&r===this.active&&(this.selection=f,this.changed());try{let[I,d,b]=await Promise.all([this.view?.sheet===r?Promise.resolve(this.view):this.session.call.sheetView(r),f.anchor.row===f.focus.row&&f.anchor.col===f.focus.col?Promise.resolve(null):this.session.call.cellGeometry(r,f.anchor.row,f.anchor.col),this.session.call.cellGeometry(r,f.focus.row,f.focus.col)]);if(!this.current||A!==this.navigation)return !1;this.active=r,this.selection=f;let X=y?new Promise(v=>this.waiters.add({request:null,resolve:v})):null,x=this.surface?.capture()?.viewport;if(this.presentView({...I,contentWidth:Math.max(I.contentWidth,d?d.rect.x+d.rect.w:0,b.rect.x+b.rect.w),contentHeight:Math.max(I.contentHeight,d?d.rect.y+d.rect.h:0,b.rect.y+b.rect.h)},c==="nearest"&&x?sa(b.rect,f.focus,I,x):b.scrollPosition),!y)return !0;if(!await X||!this.current||A!==this.navigation)return !1;let q=this.painted;if(!q||!So(this.surface?.capture()??null,q.request))return !1;let{frame:E,request:W}=q,{viewport:V}=W,g=ua$1({top:f.focus.row,left:f.focus.col,bottom:f.focus.row,right:f.focus.col},E.mergedRanges??[]),K=rangeRect(E.displayList.grid,g);if(!K||K.w<=0||K.h<=0)return !1;let F=g.left<I.frozenCols?0:I.frozenWidth,M=g.top<I.frozenRows?0:I.frozenHeight,j=Math.min(V.width,E.displayList.width,g.right<I.frozenCols?I.frozenWidth:1/0),O=Math.min(V.height,E.displayList.height,g.bottom<I.frozenRows?I.frozenHeight:1/0),C=1/W.zoom;return j>F&&O>M&&Math.min(K.x+K.w,j+C)>Math.max(K.x,F-C)&&Math.min(K.y+K.h,O+C)>Math.max(K.y,M-C)}catch{return this.current&&A===this.navigation&&(this.view?this.schedule():this.show(this.active)),false}}setSelection(r){if(this.current){if(!r){this.placeSelection(null);return}this.selectionNavigation.select(r,{...this.selectionOptions(),apply:l=>(this.placeSelection(l),true)},void 0,true);}}placeSelection(r){this.beginNavigation(),this.selection=r,this.changed(),this.schedule();}afterPaint(){return this.current?this.painted&&So(this.surface?.capture()??null,this.painted.request)?Promise.resolve(true):(this.schedule(),new Promise(r=>this.waiters.add({request:void 0,resolve:r}))):Promise.resolve(false)}placedView(){this.scrollTarget=null;let r=this.surface?.capture()??null;for(let l of this.waiters)l.request===null&&(l.request=r);this.schedule();}schedule(){!this.current||!this.surface||(this.revision+=1,this.raf===null&&(this.raf=requestAnimationFrame(()=>{if(this.raf=null,!this.current||!this.view||this.scrollTarget)return;let r=this.surface?.capture();if(r){for(let l of this.waiters)l.request===null&&(l.request=r);this.pending={request:r,revision:this.revision},this.drain();}})));}fail(r){this.current&&(this.failed=true,this.cancelFrame(),this.finish(false),this.report(r),this.changed());}dispose(){this.alive&&(this.alive=false,this.cancelFrame(),this.finish(false),this.surface=null,this.painted=null,this.session.dispose().catch(()=>{}));}validSheet(r){return Number.isInteger(r)&&r>=0&&r<this.session.state.sheets.length}beginNavigation(){return this.finish(false),this.navigation+=1,this.revision+=1,this.pending=null,this.navigation}presentView(r,l){if(r.sheet!==this.active){this.fail(new Error("Unexpected sheet view"));return}this.view=r,this.scrollTarget=l,this.scrollRevision+=1,this.changed(),this.schedule();}cancelFrame(){this.raf!==null&&cancelAnimationFrame(this.raf),this.raf=null,this.pending=null;}finish(r){for(let l of this.waiters)l.resolve(r);this.waiters.clear();}matches(r,l){return l===this.revision&&r.navigation===this.navigation&&r.sheet===this.active&&this.scrollTarget===null&&So(this.surface?.capture()??null,r)}async drain(){if(!(this.running||!this.current)){this.running=true;try{for(;this.current&&this.pending;){let r=this.pending;this.pending=null;let{request:l,revision:c}=r;if(!this.matches(l,c)){this.raf===null&&this.schedule();continue}try{let y=await this.session.call.frame(l.viewport,{sheet:l.sheet});if(!this.current)break;if(!this.matches(l,c)){!this.pending&&this.raf===null&&this.schedule();continue}if(y.sheet!==l.sheet||!Vi(y.viewport,l.viewport))throw new Error("Unexpected workbook frame");if(this.surface.paint(y,l),!this.current)break;this.painted={frame:y,request:l},this.changed();for(let f of this.waiters)f.resolve(f.request===void 0||So(f.request,l));this.waiters.clear(),this.ready||(this.ready=!0,this.onReady());}catch(y){if(!this.current)break;y instanceof Error&&y.name==="SessionSuperseded"?this.pending||this.schedule():this.matches(l,c)&&this.fail(y);}}}finally{this.running=false;}}}};function Ui(n,r,l){let c=useRef({props:n,focus:l});c.current={props:n,focus:l};let y=useRef(0),[f,A]=useState(null),[,I]=useState(0),[d,b]=useState(null),[X,x]=useState(false),q=n.collaboration,E=useCallback(W=>{let V=W instanceof Error?W:new Error(W&&typeof W=="object"&&"message"in W?String(W.message):String(W));b(V.message),c.current.props.onError?.(V);},[]);return useEffect(()=>{let W=++y.current,V=new AbortController,g=false,K,F=()=>{},M,j=()=>!g&&W===y.current&&c.current.props.file===n.file,O=()=>{j()&&I(C=>C+1);};return A(null),b(null),x(!!n.file),q?(E(new Error("Collaboration is unavailable in the worker viewer")),x(false)):n.file&&(async()=>{try{let C=await ll.open(n.file,{signal:V.signal});if(!j()){C.dispose().catch(()=>{});return}K=new Ko(C,O,U=>{j()&&E(U);},()=>{j()&&(M=c.current.props.onReady?.(oe));},j,W);let v=K,L=async U=>{if(!v.current)return null;try{let J=await U(C);return v.current?J:null}catch(J){if(!v.current)return null;throw J}},le=()=>L(async U=>({ok:!1,version:await U.call.version(),failure:{code:"read-only",message:"The editor is read-only"}})),oe={handle:null,commands:r,save:()=>null,selectCells:()=>!1,flushPendingInput:async()=>{if(!v.current)throw new w("document-replaced")},getPositionAtPoint:(U,J)=>v.getPositionAtPoint(U,J),refreshProposals:()=>{},clearSelection:()=>v.setSelection(null),focus:()=>{v.current&&c.current.focus();},selectCellsAsync:(U,J)=>v.selectCellsAsync(U,J),saveAsync:()=>L(U=>U.save()),version:()=>L(U=>U.call.version()),readCells:U=>L(J=>J.call.readCells(U)),findText:U=>L(J=>J.call.findText(U)),validateEdits:le,applyEdits:le};F=C.onFailure(U=>v.fail(U)),C.failure&&v.fail(C.failure),A(v),x(!1),v.start();}catch(C){if(!j())return;K?.fail(C),K||E(C),x(false);}})(),()=>{g=true,y.current+=1,V.abort(),F();try{typeof M=="function"&&M();}finally{K?.dispose();}}},[n.file,q,r,E]),{run:f?.current?f:null,error:d,loading:X,reportError:E}}var Wo="#217346",gl="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",Zi={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"};function Yo(n){let r="";for(let l=n.col+1;l>0;l=Math.floor((l-1)/26))r=String.fromCharCode(65+(l-1)%26)+r;return `${r}${n.row+1}`}function vl(n){return `${Yo({row:n.top,col:n.left})}:${Yo({row:n.bottom,col:n.right})}`}function yl(n,r){let l=URL.createObjectURL(new Blob([new Uint8Array(n)],{type:gl})),c=document.createElement("a");c.href=l,c.download=r,document.body.appendChild(c),c.click(),c.remove(),URL.revokeObjectURL(l);}function Qi(n){let{t:r}=H(),l$1=useRef(null),c=useRef(null),y=useRef(null),[f$1]=useState(x),[A,I$1]=useState(1),d$1=useRef(A);d$1.current=A;let[b,X]=useState(null),[x$1,q$1]=useState(null),E=useRef(false),W=useRef(null),V=useCallback(()=>c.current?.focus({preventScroll:true}),[]),{run:g,loading:K,error:F,reportError:M}=Ui(n,f$1.store,V),j=useRef({run:g,props:n,zoom:A,selectedChart:b,loading:K,t:r,reportError:M});j.current={run:g,props:n,zoom:A,selectedChart:b,loading:K,t:r,reportError:M};let O=useRef(null),C=Q({document:()=>j.current.run?.current?j.current.run:null,onSaveRequest:n.onSaveRequest,fail:M}),v=useMemo(()=>({getPositionAtPoint(u,S){let $=j.current.run?.painted;return $?na($.frame.displayList,$.frame.sheet,y.current,u,S):null},capture(){let u=j.current.run,S=c.current,$=d$1.current;if(!u?.current||!u.view||!S||!y.current)return null;let Z=S.clientWidth,xe=S.clientHeight;return Z===0||xe===0?null:{sheet:u.active,navigation:u.navigation,zoom:$,dpr:window.devicePixelRatio||1,width:Z,height:xe,viewport:{x:S.scrollLeft/$,y:S.scrollTop/$,width:Z/$,height:xe/$}}},paint(u,S){let $=y.current,Z=$.getContext("2d");if(!Z)throw new Error("Canvas context is unavailable");$.width=Math.round(S.width*S.dpr),$.height=Math.round(S.height*S.dpr),$.style.width=`${S.width}px`,$.style.height=`${S.height}px`,paintDisplayList(Z,u.displayList,S.dpr*S.zoom);}}),[]);useLayoutEffect(()=>g?.connect(v),[g,v]),useLayoutEffect(()=>{!g?.current||!g.scrollTarget||!c.current||(c.current.scrollLeft=g.scrollTarget.x*d$1.current,c.current.scrollTop=g.scrollTarget.y*d$1.current,E.current=false,W.current=null,X(null),g.placedView());},[g,g?.scrollRevision]),useEffect(()=>{let u=c.current;if(!u||!g)return;let S=()=>g.schedule();S(),u.addEventListener("scroll",S,{passive:true});let $=new ResizeObserver(S);return $.observe(u),()=>{u.removeEventListener("scroll",S),$.disconnect();}},[g,A]);let L=(u,S,$,Z=false)=>{let xe=c.current,me=u.view,Xe=u.painted;if(!u.current||!me||!xe)return Promise.resolve(false);let We=S.focus,He=Xe?.frame.sheet===u.active&&Xe.frame.version===u.session.confirmedBasis.version?ra(Xe.frame.displayList,Xe.request.viewport,me,We):null;if(!He)return Z?Promise.resolve(u.selectionOptions().apply(S)):u.selectCellsAsync(u.active,S,"nearest");if($!==void 0&&!qa(xe,He,$))return Promise.resolve(false);$===void 0&&(Z?u.placeSelection(S):u.setSelection(S));let Q=d$1.current,_e=sa(He,We,me,{x:xe.scrollLeft/Q,y:xe.scrollTop/Q,width:xe.clientWidth/Q,height:xe.clientHeight/Q});return xe.scrollLeft=_e.x*Q,xe.scrollTop=_e.y*Q,u.schedule(),Promise.resolve(true)},le=useRef(A);useLayoutEffect(()=>{if(le.current===A)return;let u=le.current;if(le.current=A,!g?.current||!g.selection||b)return;let S=g.selection,$=g.navigation,Z=g.painted;if(Z&&g.view&&Z.frame.version===g.session.confirmedBasis.version?ra(Z.frame.displayList,Z.request.viewport,g.view,S.focus):null){L(g,S,u);return}let me=g.active;g.session.call.cellGeometry(me,S.focus.row,S.focus.col).then(Xe=>{let We=c.current;if(g.current&&j.current.run===g&&g.navigation===$&&d$1.current===A&&We&&qa(We,Xe.rect,u)){let He=d$1.current,Q={x:We.scrollLeft/He,y:We.scrollTop/He,width:We.clientWidth/He,height:We.clientHeight/He},_e=g.view&&sa(Xe.rect,S.focus,g.view,Q);_e&&(_e.x!==Q.x||_e.y!==Q.y)&&g.selectCellsAsync(me,S,"nearest");}}).catch(M);},[g,A]),useEffect(()=>{if(typeof window.matchMedia!="function")return;let u,S=()=>{j.current.run?.schedule(),u?.removeEventListener("change",S),u=window.matchMedia(`(resolution: ${window.devicePixelRatio||1}dppx)`),u.addEventListener("change",S);};return S(),()=>u?.removeEventListener("change",S)},[]),useEffect(()=>{let u=()=>{E.current=false;};return window.addEventListener("mouseup",u),()=>window.removeEventListener("mouseup",u)},[]);let oe=useMemo(()=>({requestSave:C,environment(){let{run:u,selectedChart:S,loading:$,t:Z}=j.current,xe=u?.selection;return {status:u?.current?"ready":$?"loading":"empty",readOnly:true,collaborative:false,canUndo:false,canRedo:false,pendingInput:false,selection:S?"chart":u&&xe?{sheet:u.active,...normalizeRange(xe),merged:u.painted?.frame.sheet===u.active?u.painted.frame.mergedRanges??[]:[],formatting:null}:null,zoom:d$1.current,paintFormat:false,borderStyle:null,borderColor:null,pngExport:false,proposals:null,proposalsPanelOpen:false,fontFamilies:s,fontSizes:t,translate:Z}},ordered:()=>false,admit:async u=>u(),perform(u,S){let{run:$,props:Z}=j.current;if(!$?.current)return {ok:false,failure:{code:"document-replaced",message:"Workbook is no longer open"}};if(u==="zoom"){let me=S.scale,Xe=d$1.current;return d$1.current=me,I$1(me),$.schedule(),{ok:true,status:me===Xe?"noop":"executed"}}if(u==="print")return $.afterPaint().then(me=>$.current?me?(window.print(),{ok:true,status:"executed"}):{ok:false,failure:{code:"render-failed",message:"Workbook was not painted"}}:{ok:false,failure:{code:"document-replaced",message:"Workbook is no longer open"}});if(u!=="save")return {ok:false,failure:{code:"read-only",message:"The editor is read-only"}};if(O.current?.run===$)return O.current.promise;let xe=$.session.save().then(me=>$.current?(Z.onSave?Z.onSave(me):yl(me,Z.fileName??"workbook.xlsx"),{ok:true,status:"executed"}):{ok:false,failure:{code:"document-replaced",message:"Workbook is no longer open"}}).catch(me=>($.current&&j.current.reportError(me),{ok:false,failure:{code:$.current?"command-failed":"document-replaced",message:String(me)}})).finally(()=>{O.current?.promise===xe&&(O.current=null);});return O.current={run:$,promise:xe},xe},capture:()=>j.current.run?{generation:j.current.run.generation,target:JSON.stringify([j.current.run.active,j.current.run.selection])}:null,resume:u=>!j.current.run?.current||u.generation!==j.current.run.generation?"document-replaced":u.target!==JSON.stringify([j.current.run.active,j.current.run.selection])?"target-changed":null,chrome:()=>({i18n:j.current.props.i18n}),focusEditor:V}),[V]);useLayoutEffect(()=>(f$1.attach(oe),()=>f$1.detach(oe)),[f$1,oe]),useLayoutEffect(()=>f$1.refresh()),P(f$1,l$1);let U=g?.painted,J=U?.frame.displayList,Oe=U?.request.zoom??A,N=g?.active??0,Ae=g?.selection??null,dt=U?.frame.sheet===N?Ae:null,Ct=g?.session.state.sheets??[],ot=n.showToolbar===false?null:n.toolbar??null;useEffect(()=>{b&&J&&!J.charts?.some(u=>u.id===b)&&X(null);},[J,b]),useEffect(()=>{if(q$1(null),!g?.current||!Ae||!ot)return;let u=false,S=g.navigation,$=Yo(Ae.focus);return g.session.call.cellInputs(N,$).then(Z=>{!u&&g.current&&g.navigation===S&&q$1(Z.cells[0]?.[0]??null);}).catch(Z=>{!u&&g.current&&g.navigation===S&&M(Z);}),()=>{u=true;}},[g,Ae,N,ot,M]);let Se={onNavigate:u=>{g&&g.selectCellsAsync(g.active,selectionAt(u)),V();},a1:x$1?.a1??"",value:x$1?.input??"",disabled:!g?.view||!Ae,readOnly:true,inputRef:null,onChange:()=>{},onCommit:()=>{},onCancel:()=>{},onBlur:()=>{},onCompositionStart:()=>{},onCompositionEnd:()=>{}},it=()=>oa(J??null,(c.current?.clientHeight??0)/Oe),Ue=u=>{if(!J||!y.current)return {cell:null,chart:null};let S=y.current.getBoundingClientRect(),$=(u.clientX-S.left)/Oe,Z=(u.clientY-S.top)/Oe;return {cell:J.grid?cellAtPoint(J.grid,$,Z):null,chart:chartRegionAtPoint(J.charts,$,Z)?.id??null}},xr=u=>{if(!g?.view||U?.frame.sheet!==N)return;let{cell:S,chart:$}=Ue(u);if(W.current=null,X($),$){V(),u.preventDefault();return}!S||!Ae||(g.setSelection(u.shiftKey?extendTo(Ae,S,it()):selectionAt(S)),W.current=S,E.current=true,V());},Be=u=>{let{cell:S,chart:$}=Ue(u);if(!S){E.current||(u.currentTarget.style.cursor="default",u.currentTarget.title="");return}if(!E.current){let Z=J?hyperlinkAtCell(J,S.row,S.col):null;u.currentTarget.style.cursor=$||Z?"pointer":"default",u.currentTarget.title=$?"":Z?.tooltip??"";return}g?.selection&&g.view&&U?.frame.sheet===N&&g.setSelection(extendTo(g.selection,S,it()));},vt=u=>{let{cell:S}=Ue(u),$=W.current;if(W.current=null,!g||!J||!S||!$||S.row!==$.row||S.col!==$.col)return;let Z=hyperlinkAtCell(J,S.row,S.col);if(!Z)return;let xe=safeExternalHyperlink(Z);if(xe){window.open(xe,"_blank","noopener,noreferrer");return}if(!Z.location)return;let me=parseHyperlinkLocation(Z.location,Ct[U.frame.sheet]?.name??"");if(!me)return;let Xe=Ct.findIndex(We=>We.name.toLowerCase()===me.sheetName.toLowerCase());Xe>=0&&g.selectCellsAsync(Xe,selectionAt(me));},ze=async()=>{if(!(!g?.current||!Ae))try{let u=await g.session.call.cellInputs(N,vl(await d(g.session,N,Ae)));g.current&&await navigator.clipboard.writeText(toTsv(u.cells));}catch{}},ft=u=>{let S=g?.selection;if(!g?.view||!S||q(u))return;if(b){u.key==="Escape"&&X(null),(u.key==="Escape"||u.key.startsWith("Arrow"))&&u.preventDefault();return}if(u.ctrlKey||u.metaKey){let me=u.key.toLowerCase();if(me==="c"||me==="x"){g.selectionNavigation.defer(g.selectionContext(),()=>{ze();})||ze(),u.preventDefault();return}if(me==="v"){u.preventDefault();return}}let $=l(u),Z=selectionKeyReducer(S,u,it()).type==="move";if($||Z){u.preventDefault();let me=g.active;g.selectionNavigation.enqueue(u,{context:()=>{if(!g.current||j.current.run!==g||g.active!==me||!g.selection||j.current.selectedChart)return null;let Xe=g.session.confirmedBasis;return {owner:g,sheet:me,selection:g.selection,navigation:g.navigation,version:`${Xe.epoch}:${Xe.version}:${g.session.state.version}`}},limits:()=>oa(g.painted?.frame.displayList??null,(c.current?.clientHeight??0)/d$1.current),hidden:()=>f(g.painted?.frame.displayList.grid),merges:g.selectionOptions().merges,known:g.selectionOptions().known,query:(Xe,We)=>g.session.call.selectionData(me,Xe.selection.focus.row,Xe.selection.focus.col,We),apply:async Xe=>{let We=g.navigation+1;return await L(g,Xe,void 0,true),g.current&&g.navigation===We&&g.active===me}});return}let xe=selectionKeyReducer(S,u,it(),void 0,f(J?.grid),h(g.painted?.frame.sheet===g.active?g.painted.frame.mergedRanges:void 0));xe.type==="move"&&L(g,xe.selection),xe.type!=="none"&&u.preventDefault();},Ce=U?.frame.mergedRanges?.slice(0,1024)??[],lt=J?.grid,yt=dt?ua$1(normalizeRange(dt),Ce):null,Mt=dt?ua$1({top:dt.focus.row,left:dt.focus.col,bottom:dt.focus.row,right:dt.focus.col},Ce):null,Pt=lt&&yt?rangeRect(lt,yt):null,kr=lt&&Mt?rangeRect(lt,Mt):null,pt=b?J?.charts?.find(u=>u.id===b)?.rect:null,Tt=J&&U?buildA11yGrid(J,dt,Ct[U.frame.sheet]?.name??"",{gridLabel:r("a11y.gridLabel"),rowHeaderLabel:r("a11y.rowHeaderLabel"),columnHeaderLabel:r("a11y.columnHeaderLabel"),cellLabel:r("a11y.cellLabel"),cellLabelSelected:r("a11y.cellLabelSelected"),emptyCellLabel:r("a11y.emptyCellLabel"),emptyCellLabelSelected:r("a11y.emptyCellLabelSelected")}):null,Rt=(u,S,$)=>{let Z=ta(u,Oe);return {position:"absolute",left:Z.x,top:Z.y,width:Z.w,height:Z.h,boxSizing:"border-box",border:S,background:$}};return jsx(I.Provider,{value:f$1.store,children:jsx(S.Provider,{value:true,children:jsx(Y.Provider,{value:Se,children:jsxs("div",{ref:l$1,className:n.className,role:"application","aria-label":r("editor.appLabel"),style:{position:"relative",display:"flex",flexDirection:"column",width:"100%",height:"100%",minWidth:0,color:"#202124",background:"#ffffff",fontFamily:"ui-sans-serif, system-ui, sans-serif"},children:[ot!=null&&jsx("div",{"data-testid":"xlsx-toolbar",style:{flex:"0 0 auto"},children:ot}),jsx("div",{"data-testid":"xlsx-workspace",style:{position:"relative",display:"flex",flex:1,minWidth:0,minHeight:0},children:jsx("div",{style:{position:"relative",display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0},children:jsxs("div",{ref:c,"data-testid":"xlsx-scroll",tabIndex:0,onKeyDown:ft,onMouseDown:xr,onMouseMove:Be,onClick:vt,onMouseLeave:u=>{u.currentTarget.style.cursor="default",u.currentTarget.title="";},style:{position:"relative",flex:1,overflow:"auto",minHeight:0,outline:"none"},children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:g?.view?g.view.contentWidth*A:"100%",height:g?.view?g.view.contentHeight*A:"100%"}}),jsxs("div",{style:{position:"sticky",top:0,left:0,width:0,height:0},children:[jsx("canvas",{ref:y,style:{display:"block",position:"absolute",top:0,left:0}}),jsxs("div",{"data-testid":"xlsx-overlay-host",style:{position:"absolute",top:0,left:0,width:0,height:0,pointerEvents:"none"},children:[Pt&&!b&&jsx("div",{"data-testid":"xlsx-selection",style:Rt(Pt,`1px solid ${Wo}`,"rgba(33, 115, 70, 0.12)")}),kr&&!b&&jsx("div",{style:Rt(kr,`2px solid ${Wo}`)}),pt&&jsx("div",{"data-testid":"xlsx-chart-selection","data-chart-id":b,"aria-hidden":true,style:{...Rt(pt,`2px solid ${Wo}`,"transparent"),boxShadow:"0 1px 6px rgba(0, 0, 0, 0.25)"}})]})]})]})})}),Tt&&jsxs(Fragment,{children:[jsxs("div",{style:Zi,role:"grid","aria-label":Tt.label,children:[jsxs("div",{role:"row",children:[jsx("span",{role:"columnheader"}),Tt.columnHeaders.map(u=>jsx("span",{role:"columnheader",children:u.label},u.col))]}),Tt.rows.map(u=>jsxs("div",{role:"row",children:[jsx("span",{role:"rowheader",children:u.header}),u.cells.map(S=>jsx("span",{role:"gridcell","aria-selected":S.selected,children:S.label},S.col))]},u.row))]}),Tt.charts.map((u,S)=>jsx("div",{style:Zi,role:"img","aria-label":u.label},`${S}:${u.label}`))]}),F&&jsx(ya$1,{kind:"open",details:F}),Ct.length>0&&jsx("div",{"data-testid":"xlsx-sheet-tabs",role:"tablist","aria-label":r("editor.sheetTabsLabel"),style:{display:"flex",gap:2,padding:"4px 6px",borderTop:"1px solid #e0e0e0",background:"#fafafa",overflowX:"auto"},children:Ct.map((u,S)=>jsx("button",{role:"tab","aria-selected":S===N,onClick:()=>{X(null),g?.show(S);},style:{border:"none",padding:"4px 12px",cursor:"pointer",borderBottom:S===N?`2px solid ${Wo}`:"2px solid transparent",fontWeight:S===N?600:400,background:S===N?"#ffffff":"transparent"},children:u.name},u.id))})]})})})})}var kl=new Set(["zoom","searchMenus","proposalsPanel"]);function ts(n,r){let l=n.cell(r.sheet,r.top,r.left).a1,c=n.cell(r.sheet,r.bottom,r.right).a1;return `${l}:${c}`}function Cl(n,r,l,c){let y={key:c,formatting:null,merged:[],canUndo:false,canRedo:false};try{let f=ts(n,{sheet:r,...l,merged:[],formatting:null});y.formatting=n.selectionFormatting(r,f),y.merged=n.mergedRanges(r,f);}catch{}try{let f=n.historyState();y.canUndo=f.canUndo,y.canRedo=f.canRedo;}catch{}return y}function Pl(n,r,l){let c=(f,A,I,d)=>({start:{row:f,col:A},end:{row:I,col:d}}),y=[];if(l==="all")y.push({type:"mergeCells",sheet:n,range:c(r.top,r.left,r.bottom,r.right)});else if(l==="horizontal")for(let f=r.top;f<=r.bottom;f++)y.push({type:"mergeCells",sheet:n,range:c(f,r.left,f,r.right)});else if(l==="vertical")for(let f=r.left;f<=r.right;f++)y.push({type:"mergeCells",sheet:n,range:c(r.top,f,r.bottom,f)});else for(let f of r.merged)y.push({type:"unmergeCells",sheet:n,range:c(f.start.row,f.start.col,f.end.row,f.end.col)});return y}function Rl(n){let r$1=null,l=null,c=d=>{let b=n(),X=b.peer(),x=b.view();if(!X||b.status()!=="ready")return null;let q=x.selection?normalizeRange(x.selection):{top:0,left:0,bottom:0,right:0},E=[b.generation(),b.mutation(),x.sheet,q.top,q.left,q.bottom,q.right].join(":");return !d&&r$1?.key===E||(r$1=Cl(X,x.sheet,q,E)),r$1},y=d=>{let b=n(),X=b.view(),x=c(d),q=null;return X.chartSelected?q="chart":X.selection&&(q={sheet:X.sheet,...normalizeRange(X.selection),merged:x?.merged??[],formatting:x?.formatting??null}),{status:b.status(),readOnly:b.readOnly(),collaborative:b.collaborative(),selection:q,canUndo:x?.canUndo??false,canRedo:x?.canRedo??false,pendingInput:b.coordinator.draft!==null||b.coordinator.committed.length>0,zoom:X.zoom,paintFormat:X.capturedFormat!==null,borderStyle:X.borderStyle??x?.formatting?.borderStyle??null,borderColor:X.borderColor??x?.formatting?.borderColor??null,pngExport:false,proposals:X.proposalsAvailable?X.proposals.map(E=>({id:E.id,label:E.agentId})):null,proposalsPanelOpen:X.proposalsPanelOpen,fontFamilies:s,fontSizes:t,translate:b.translate}},f=(d,b,X)=>{let x=n(),q=x.peer(),E=v=>({ok:false,failure:r(v,X)});if(d==="zoom"){let v=b.scale;return X.zoom===v?{ok:true,status:"noop"}:(x.setZoom(v),{ok:true,status:"executed"})}let W=x.editPeer();if(!q||!W)return E("editor-unavailable");let V=(v=true)=>({ok:true,status:v?"executed":"noop"}),g=v=>{try{return v()}catch(L){return za(L)?x.refuse?.({message:L.message}):x.fail(L),E("command-failed")}},K=v=>g(()=>{let L=v();return l?.(),x.apply(L),V(L.applied)}),F=b,M=typeof X.selection=="object"?X.selection:null,j=()=>{if(!M)throw new Error("no cell selection");return {sheet:M.sheet,range:ts(q,M)}},O=v=>K(()=>{let{sheet:L,range:le}=j();return W.patchRangeStyle(L,le,v)}),C=M?.formatting??null;switch(d){case "bold":return O({bold:C?.bold!==true});case "italic":return O({italic:C?.italic!==true});case "strikethrough":return O({strikethrough:C?.strikethrough!==true});case "paintFormat":return X.paintFormat?(x.setCapturedFormat(null,null),V()):g(()=>{let{sheet:v,range:L}=j(),le=`${v}:${M.top}:${M.left}:${M.bottom}:${M.right}`;return x.setCapturedFormat(q.captureFormat(v,L),le),V()});case "fontFamily":return O({fontFamily:F.family});case "fontSize":return O({fontSize:F.points});case "fontSizeStep":{let v=C?.fontSize??10,L=X.fontSizes,le=F.direction==="increase"?L.find(oe=>oe>v)??v+1:[...L].reverse().find(oe=>oe<v)??Math.max(1,v-1);return O({fontSize:le})}case "textColor":return O({textColor:F.color});case "fillColor":return O({fillColor:F.color});case "numberFormat":return K(()=>{let{sheet:v,range:L}=j();return F.value==="custom"?W.setNumberFormat(v,L,{type:"custom",pattern:C?.numberFormatPattern??"0.00"}):W.setNumberFormat(v,L,F.value)});case "decimalPlaces":return K(()=>{let{sheet:v,range:L}=j();return W.setNumberFormat(v,L,F.direction==="increase"?"increaseDecimal":"decreaseDecimal")});case "borderPreset":return O({border:{preset:F.value,style:X.borderStyle??"solid",color:X.borderColor??"#000000"}});case "borderStyle":return x.setBorderStyle(F.value),O({border:{style:F.value}});case "borderColor":return x.setBorderColor(F.color),O({border:{color:F.color}});case "horizontalAlignment":return O({horizontalAlignment:F.value});case "verticalAlignment":return O({verticalAlignment:F.value});case "textWrapping":return O({textWrapping:F.value});case "merge":{if(!M)return E("cell-selection-required");let v=Pl(M.sheet,M,F.value);return v.length===0?V(false):K(()=>W.applyOps(v))}case "undo":return K(()=>W.undo());case "redo":return K(()=>W.redo());case "save":{let v=x.generation();return l?.(),W.save().then(L=>n().generation()!==v?E("document-replaced"):(x.deliver(new Uint8Array(L)),V())).catch(L=>n().generation()!==v?E("document-replaced"):(x.fail(L),E("command-failed")))}case "exportPng":return E("png-unavailable");case "print":{let v=x.generation();return x.afterPaint().then(L=>n().generation()!==v?E("document-replaced"):L?(window.print(),V()):E("render-failed"))}case "proposalsPanel":{let v=b===null?!X.proposalsPanelOpen:F.open;return v===X.proposalsPanelOpen?V(false):(x.setProposalsPanelOpen(v),V())}case "proposalAccept":try{let v=W.acceptProposal(F.proposalId,{force:F.force});return l?.(),x.apply(v),x.markStale(F.proposalId,null),x.refreshProposals(),V()}catch(v){return v instanceof StaleProposalError?(l?.(),x.markStale(F.proposalId,v.cells),x.refreshProposals(),E("proposal-stale")):(x.fail(v),E("command-failed"))}case "proposalReject":return g(()=>{let v=W.rejectProposal(F.proposalId);return l?.(),x.markStale(F.proposalId,null),x.refreshProposals(),v?V():E("proposal-not-found")});default:return E("unsupported-command")}},A=d=>{if(!v(d))return "document";let b=n().view();return b.chartSelected?"chart":b.selection?`${b.sheet}:${JSON.stringify(normalizeRange(b.selection))}`:"none"};return {requestSave:d=>n().requestSave?.(d)??d(),environment:y,ordered:d=>{let b=n();return d==="save"&&b.coordinator.requestHydration("save").catch(()=>{}),!kl.has(d)||b.coordinator.rejected.some(X=>X.generation===b.generation())},refuse:d=>n().refuse?.(d),admit:(d,b)=>{let X=n().readOnly();return n().coordinator.runAfterPendingInput(async(x,q)=>{let E=n(),W=E.generation();if(await E.preview(),q.check(),n().generation()!==W)throw new w("document-replaced");if(E.coordinator.error)throw E.coordinator.error;l=q;try{let V=await d(X);if(V!==null&&typeof V=="object"&&"ok"in V&&V.ok===!1){let g="failure"in V?V.failure:{message:"Command was refused"};q.refuse(new z(g.message),b!==void 0&&o[b].mutatesDocument);}return V}finally{l=null;}},{recover:b===void 0||o[b].mutatesDocument,barrier:b==="save"})},perform:f,capture(d){let b=n();return b.status()==="empty"?null:{generation:b.generation(),target:A(d)}},resume(d,b){return n().generation()!==d.generation?"document-replaced":A(b)===d.target?null:"target-changed"},chrome:()=>({i18n:n().i18n()}),focusEditor:()=>n().focusGrid()}}function rs(n,r){let l=useRef(r);l.current=r,useLayoutEffect(()=>{let c=Rl(()=>l.current);return n.attach(c),()=>n.detach(c)},[n]),useLayoutEffect(()=>n.refresh());}var Jo=new WeakMap;function Wl(n,r){let l=Jo.get(n),c=l?{Component:l}:{loading:true},[y,f]=useState(()=>({load:n,chunk:c})),A=useRef(null);return useEffect(()=>{if(l)return;let I=true;if(!A.current||A.current.load!==n){let b;try{b=n();}catch(X){b=Promise.reject(X);}A.current={load:n,promise:b};}let d=A.current;return d.promise.then(b=>{!I||A.current!==d||(Jo.set(n,b.XlsxPeerlessWorkerEditor),f({load:n,chunk:{Component:b.XlsxPeerlessWorkerEditor}}));}).catch(b=>{!I||A.current!==d||(Jo.delete(n),f({load:n,chunk:{error:new r(b)}}));}),()=>{I=false;}},[n,r]),l?{Component:l}:y.load===n?y.chunk:{loading:true}}function ns({load:n,ErrorType:r,editorProps:l}){let c=Wl(n,r);if("error"in c)throw c.error;return "Component"in c?jsx(c.Component,{...l}):l.file?l.loadingIndicator??null:null}var Al={request:n=>requestAnimationFrame(n),cancel:n=>cancelAnimationFrame(n)};function os(n){return {...n,viewport:{...n.viewport}}}function is(n,r){return n.x===r.x&&n.y===r.y&&n.width===r.width&&n.height===r.height}function Zo(n,r){return n!==null&&n.generation===r.generation&&n.sheet===r.sheet&&n.navigation===r.navigation&&n.width===r.width&&n.height===r.height&&n.zoom===r.zoom&&n.dpr===r.dpr&&is(n.viewport,r.viewport)}var To=class{constructor(r){a(this,"options",r);a(this,"scheduler");a(this,"disposed",false);a(this,"failed",false);a(this,"raf",null);a(this,"revision",0);a(this,"pending",null);a(this,"running",false);a(this,"lastPaint",null);this.scheduler=r.scheduler??Al;}get painted(){return this.lastPaint}schedule(){!this.current||this.failed||(this.revision+=1,this.raf===null&&(this.raf=this.scheduler.request(()=>{if(this.raf=null,!this.current||this.failed)return;let r=this.capture();r&&(this.pending={request:r,revision:this.revision,sequence:this.options.sentSequence()},this.drain().catch(l=>this.fail(l)));})));}fail(r){if(!(!this.current||this.failed)){this.failed=true,this.cancelFrame();try{this.options.onError(r);}catch{}}}dispose(){this.disposed||(this.disposed=true,this.cancelFrame());}get current(){return !this.disposed&&(this.options.isCurrent?.()??true)}capture(){if(!this.current)return null;let r=this.options.capture();return r?.generation===this.options.generation?os(r):null}matches(r){return r.revision===this.revision&&Zo(this.capture(),r.request)}cancelFrame(){this.raf!==null&&this.scheduler.cancel(this.raf),this.raf=null,this.pending=null;}retry(r){let l=this.capture();!l||Zo(l,r.request)&&this.options.sentSequence()===r.sequence||!this.pending&&this.raf===null&&this.schedule();}publish(r,l,c,y){let f={...c,source:r,request:l,sequence:y,geometry:c.displayList.grid},A=this.lastPaint;this.lastPaint=f;try{this.options.publish(f);}catch(I){throw this.lastPaint===f&&(this.lastPaint=A),I}return f}async drain(){if(!(this.running||!this.current||this.failed)){this.running=true;try{for(;this.current&&!this.failed&&this.pending;){let r=this.pending;if(this.pending=null,!this.matches(r)){this.retry(r);continue}let{request:l}=r,c;try{c=await this.options.requestFrame(os(l));}catch(y){if(!this.current||this.failed)break;!Zo(this.capture(),l)||y instanceof Error&&y.name==="SessionSuperseded"?this.retry(r):this.fail(y);continue}if(!this.current||this.failed)break;if(!this.matches(r)||c.sheet!==l.sheet||!is(c.viewport,l.viewport)||!(c.sequence>=this.options.sentSequence())){this.retry(r);continue}try{this.publish("worker",l,{displayList:c.displayList,mergedRanges:c.mergedRanges??[],version:c.version},c.sequence);}catch(y){this.fail(y);}}}finally{this.running=false;}}}};var Yn="#217346",$l="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ds={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},Vl={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};function yn(n){let r="";for(let l=n.col+1;l>0;l=Math.floor((l-1)/26))r=String.fromCharCode(65+(l-1)%26)+r;return `${r}${n.row+1}`}function ps(n){return `${yn({row:n.top,col:n.left})}:${yn({row:n.bottom,col:n.right})}`}function Ul(n){return ps(normalizeRange(n))}function jn(n){return N(n.nativeEvent)!==null||O(n.target)}function yr(n){let[r,l]=useState(n),c=useRef(r),y=useCallback(f=>{c.current=typeof f=="function"?f(c.current):f,l(c.current);},[]);return [r,y,c]}function ni(n,r,l){if(!n||!r||n.sequence<l)return false;let c=n.request;return c.generation===r.generation&&c.sheet===r.sheet&&c.navigation===r.navigation&&c.zoom===r.zoom&&c.dpr===r.dpr&&c.width===r.width&&c.height===r.height&&JSON.stringify(c.viewport)===JSON.stringify(r.viewport)}function fs(n,r,l,c,y,f){return l?null:f==="start"?n:f==="center"?Math.max(0,n-Math.max(0,y-r)/2):n>=c&&n+r<=c+y?null:n<c||r>=y?n:Math.max(0,n+r-y)}var _l={load:()=>import('./chunk-2S2QUCJE.js')},Kl=()=>globalThis.location?.reload(),Zn=class extends Error{constructor(l){super("Failed to load the editor code. Reload the page to retry.");a(this,"cause",l);a(this,"code","chunk-load-failed");this.name="XlsxWorkerEditorChunkLoadError";}};function Gl({error:n,className:r,style:l}){let c=n instanceof Zn;return jsx(ya$1,{kind:c?"load":"open",details:n.message,onReload:c?Kl:void 0,className:r,style:{position:"relative",width:"100%",height:"100%",...l}})}var oi=class extends Component{constructor(){super(...arguments);a(this,"state",{error:null});a(this,"reported",null);}static getDerivedStateFromError(l){return {error:Ra$1(l)}}componentDidCatch(){let l=this.state.error;if(!(!l||this.reported===l)){this.reported=l;try{this.props.onError?.(l);}catch{}}}render(){return this.state.error?jsx(Gl,{error:this.state.error,className:this.props.className,style:this.props.style}):this.props.children}};function ii(n){return useRef(n.backend??"legacy").current==="peerless"?jsx(G,{i18n:n.i18n,children:jsx(oi,{onError:n.onError,className:n.className,style:n.style,children:jsx(ns,{load:_l.load,ErrorType:Zn,editorProps:n})})}):jsx(Yl,{...n})}function Yl(n$1){let{t:r}=H(),l$1=useRef(null),c$1=useRef(null),y=useRef(null),f$1=useRef(null),A=useRef(null),I$1=useRef(null),d=useRef(null),b$1=useRef(n$1);b$1.current=n$1;let[X]=useState(x),[x$1,q$1,E]=yr(0),[W,V,g$1]=yr(null),[K,F,M]=yr(null),j$1=useRef(()=>{}),O=useCallback(e=>{let o=typeof e=="function"?e(M.current):e;o&&!d.current?.peer&&(o.anchor.row||o.anchor.col||o.focus.row||o.focus.col)?j$1.current(o):F(o?k(o,j(d.current?.peer,E.current)):null);},[]),[C,v,L]=yr(1),[le,oe,U]=yr(null),[J,Oe]=useState(null),[N,Ae]=useState(null),dt=useRef(null),[Ct,ot]=useState(null),[Se,it]=useState(null),[Ue,xr]=useState(null),[Be,vt,ze]=yr(null),[ft,Ce]=useState(null),[lt,yt,Mt]=yr(null),Pt=useRef(null),kr=useRef(void 0),pt=useRef(void 0),[Tt,Rt,u]=yr([]),[S$1,$,Z]=yr(false),[xe,me]=useState({}),Xe=useRef(0),We=useRef(0),[He]=useState(n),Q$1=useRef(null),_e=useRef(false),Ze=useRef(null),ee=useRef(null),Ke=useRef(null),Ne=useRef(null),Et=useRef(()=>{}),Re=useRef(false),Cr=useRef(false),Te=useRef(null),Qe=useRef([]),xn=useRef(null),te=useRef(0),ro=useRef(0),Ie=useCallback(()=>c$1.current?.focus({preventScroll:true}),[]),pe=useCallback(e=>{let o=za(e);if(o||e instanceof w){ot((o??e).message);return}ot(e instanceof Error?e.message:String(e));},[]),$e=()=>!!(d.current?.current&&!d.current.retiring&&!d.current.failure&&!b$1.current.readOnly),At=useRef(null),[kn]=useState(()=>({getPositionAtPoint:(e,o)=>At.current?.getPositionAtPoint?.(e,o)??null,coordinator:()=>xn.current,readOnly:()=>b$1.current.readOnly??false,clearSelection:()=>At.current?.clearSelection(),focus:Ie,refreshProposals:()=>At.current?.refreshProposals(),recoverInput:()=>At.current.recoverInput(),selectCells:(...e)=>At.current?.selectCells(...e)??false,selectCellsAsync:(...e)=>At.current?.selectCellsAsync(...e)??Promise.resolve(false),apply:(e,o)=>At.current?.apply(e,o),previewEdits:(e,o,i)=>At.current?.previewEdits?.(e,o,i)??Promise.resolve(),canNavigateSync:()=>At.current?.canNavigateSync?.()??false})),{run:p,error:Ot,loading:re}=Ta(n$1,X.store,kn);d.current=p;let bt=useMemo(()=>({current:null}),[p]),Ge=useMemo(()=>new Map,[p]),St=useMemo(()=>new WeakMap,[p]),at=useMemo(()=>new Map,[p]),Fr=useMemo(()=>new WeakMap,[p]),lr=useMemo(()=>({current:p?.editPeer??null}),[p]);p?.editPeer&&!p.recovering&&(lr.current=p.editPeer);let ke=useMemo(()=>new Map,[p]),wt=useMemo(()=>new WeakSet,[p]),ye=useMemo(()=>[],[p]),st=useMemo(()=>new WeakMap,[p]),qe=useMemo(()=>new Set,[p]),ue=useMemo(()=>({revision:0,sequence:1/0,request:null,committed:null}),[p]),Zt=useMemo(()=>{let e=new Set;return {resolve(){for(let o of e)o();e.clear();},wait(o){return new Promise((i,a)=>{let h=()=>{e.delete(h),i();};e.add(h),o.then(h,w=>{e.delete(h),a(w);});})}}},[p]),_=useMemo(()=>{let e=p,o=Aa({generation:()=>e?.generation??0,capture:()=>({sheet:E.current,target:JSON.stringify(M.current)}),isReady:()=>e?.ready??false,isAcknowledged:()=>!e?.editPeer||e.editPeer.acknowledgedSequence>=e.editPeer.sentSequence,whenReady:()=>e?.whenHydrated()??Promise.reject(new w("editor-unavailable")),requestHydration:i=>e?.requestHydration(i),flushEdits:()=>e?.editPeer?.flush()??Promise.reject(new w("editor-unavailable")),async acknowledgeEdits(){!e?.editPeer||e.recovering||e.retiring||(await Zt.wait(workbookEditPeerOperations(e.editPeer).whenAcknowledged()),e.retiring||await bt.current?.acknowledgeEdits?.());},preview:i=>bt.current.preview(i),resolveDraft:i=>bt.current.resolveDraft(i),sameDraft:(i,a)=>i.draftId===a.draftId,seal:()=>bt.current?.seal()??{},sync:()=>bt.current?.sync(),write:(i,a)=>bt.current?.write(i,a)??false,onError:i=>e?.fail(i),onRefusal(i,a){if(e?.retiring){e.reportRefusal(i);return}let h=i instanceof Error?i.message:String(i);e?.recovering?flushSync(()=>ot(h)):ot(h),bt.current?.sync?.();let w=a?.revision??0;a&&!b$1.current.readOnly&&w>ro.current&&w===te.current&&(o.setDraft(a),a.source==="cell"?oe(a):Oe(a.value));}});return o},[p,bt,pe,Zt]);xn.current=_;let ar=useCallback(()=>{let e=d.current,o=c$1.current,i=L.current;return !e?.current||!g$1.current||!o||!y.current||!o.clientWidth||!o.clientHeight?null:{generation:e.generation,sheet:E.current,navigation:We.current,zoom:i,dpr:window.devicePixelRatio||1,width:o.clientWidth,height:o.clientHeight,viewport:{x:o.scrollLeft/i,y:o.scrollTop/i,width:o.clientWidth/i,height:o.clientHeight/i}}},[]),It=useCallback(()=>p?.current?p.failure&&!p.recovering?Promise.reject(p.failure):Promise.resolve():Promise.reject(new w("document-replaced")),[p]),Ht=useCallback((e,o,i)=>{for(let h of at.values()){let w=h.get(e);w?.operation===o&&(w.operation=i?.operation,w.input=i?.input,w.index=i?.index??-1);}let a=at.get(o);a?.delete(e),a?.size||at.delete(o);},[at]),Le=useCallback(async(e,o=true)=>{if(!(!p||p.failure||p.recovering||p.retiring)){if(e){let i=`${e.sheet}:${e.row}:${e.col}`,a=ke.get(i),h=ue.committed,w=Ge.get(i)??(h&&`${h.sheet}:${h.row}:${h.col}`===i?h.value:void 0);Ge.set(i,e.value);let P=St.get(e)??{method:"editCell",args:[e.sheet,e.row,e.col,e.value],calculation:{nowSerial:localNowSerial(Date.now()),randSeed:globalThis.crypto.getRandomValues(new Uint32Array(1))[0]>>>0}};if(St.set(e,P),a!==P){let H=at.get(P);H||at.set(P,H=new Map),H.set(i,{operation:a,input:w,index:a?ye.indexOf(a):-1});}if(e.unchanged&&wt.add(P),a&&a!==P&&wt.has(a)){let H=ye.indexOf(a);H>=0&&ye.splice(H,1);}ke.set(i,P),ye.includes(P)||ye.push(P),ue.sequence=1/0;let B=++ue.revision,z=()=>{let H=at.get(P)?.get(i),G=ye.indexOf(P);G>=0&&ye.splice(G,1),Ht(i,P,H);let se=ke.get(i)===P;if(se&&(H?.operation?(ke.set(i,H.operation),ye.includes(H.operation)||ye.splice(Math.max(0,H.index),0,H.operation)):ke.delete(i),H?.operation&&H.input!==void 0?Ge.set(i,H.input):Ge.delete(i)),!ke.size&&(se&&!qe.size||B===ue.revision)&&!p.retiring)it(ue.committed),ue.request=null;else if(se&&!p.retiring){let ge=[...ke.keys()].reverse()[0];if(ge){let[Je,De,et]=ge.split(":").map(Number);it({...e,sheet:Je,row:De,col:et,value:Ge.get(ge)??""});}}let be=!qe.size&&ye.every(ge=>st.has(ge));ue.sequence=be?Math.max(0,...ye.map(ge=>st.get(ge))):1/0,be&&Q$1.current?.schedule();};if(o&&Fr.set(e,z),p.ready){qe.size||flushSync(()=>it(e));return}let T=ar();if(qe.size){await It();return}if(T){let H=workbookSessionInternals.get(p.session);if(!H?.preview)throw new Error("Worker cell preview is unavailable");let G;try{G=await H.preview(T.viewport,T.sheet,ye.filter(ge=>!st.has(ge)));}catch(ge){throw o&&z(),ge}if(p.retiring||p.recovering||p.failure||!p.current||B!==ue.revision||(ue.request=T,ue.sequence=ye.every(ge=>st.has(ge))?p.editPeer?.sentSequence??1/0:1/0,qe.size)||(flushSync(()=>it(e)),p.ready))return;let se=dt.current,be=se?.getContext("2d");if(!se||!be)throw new Error("Preview canvas context is unavailable");se.width=Math.round(T.width*T.dpr),se.height=Math.round(T.height*T.dpr),se.style.width=`${T.width}px`,se.style.height=`${T.height}px`,paintDisplayList(be,G.displayList,T.dpr*T.zoom),se.dataset.previewReady="true";}}await It();}},[p,ar,It,Ge,ke,ue,St,Fr,at,Ht,st,qe,ye,wt]),qr=useCallback(async(e,o,i)=>{if(i?.method==="applyEdits"&&i.args[0].steps.some(P=>P.op!=="setCellInputs"))return qe.add(i),ue.revision+=1,ue.request=null,it(null),async()=>{qe.delete(i);};i&&(i.calculation??(i.calculation={nowSerial:localNowSerial(Date.now()),randSeed:globalThis.crypto.getRandomValues(new Uint32Array(1))[0]>>>0}));let a=new Map,h=new Map;for(let P of o)if(!Number.isInteger(e)||e<0||e>=(p?.session.state.sheets.length??0)||!Number.isInteger(P.row)||P.row<0||P.row>1048575||!Number.isInteger(P.col)||P.col<0||P.col>16383||!P.input.startsWith("=")&&[...P.input.replace(/^'/,"")].length>32767)throw new z("Invalid cell input or target");for(let P of o){let B=`${e}:${P.row}:${P.col}`,z=i??{method:"editCell",args:[e,P.row,P.col,P.input]},T=ke.get(B),H=at.get(z);H||at.set(z,H=new Map);let G=a.get(B)??(T===z?H.get(B):void 0)??{operation:T,input:Ge.get(B)??(ue.committed&&`${ue.committed.sheet}:${ue.committed.row}:${ue.committed.col}`===B?ue.committed.value:void 0),index:T?ye.indexOf(T):-1};if(a.set(B,G),H.set(B,G),Ge.set(B,P.input),T&&T!==z&&wt.has(T)){let se=ye.indexOf(T);se>=0&&ye.splice(se,1);}ke.set(B,z),h.set(B,z),ye.includes(z)||ye.push(z);}let w=async()=>{let P=false;for(let z of o){let T=`${e}:${z.row}:${z.col}`,H=h.get(T),G=a.get(T),se=G?.operation,be=G?.input;H&&Ht(T,H,G),ke.get(T)===H&&(se?(ke.set(T,se),ye.includes(se)||ye.splice(Math.max(0,G.index),0,se)):ke.delete(T),se&&be!==void 0?Ge.set(T,be):Ge.delete(T),P=true);}for(let z of new Set(h.values())){let T=ye.indexOf(z);T>=0&&ye.splice(T,1);}if(!P||!p||p.retiring||p.failure)return;let B=[...ke.entries()].reverse()[0];if(B){let[z,T,H]=B[0].split(":").map(Number),G={generation:p.generation,sheet:z,row:T,col:H,value:Ge.get(B[0])??"",source:"cell"};St.set(G,B[1]),await Le(G),ye.every(se=>st.has(se))&&(ue.sequence=p.editPeer?.sentSequence??1/0,Q$1.current?.schedule());}else ue.revision+=1,ue.request=null,ue.sequence=p.editPeer?.sentSequence??1/0,it(ue.committed);};try{let P=o[0]?{generation:p.generation,sheet:e,row:o[0].row,col:o[0].col,value:o[0].input,source:"cell"}:void 0;P&&St.set(P,h.get(`${e}:${P.row}:${P.col}`)),await(P?Le(P,!1):Promise.resolve());}catch(P){throw await w(),P}return w},[p,Le,Ht,Ge,ke,at,ue,St,st,qe,ye,wt]),Pr=useCallback(()=>{let e=d.current;if(!e?.peer){Rt([]);return}Rt(e.peer.listProposals()),e.recovering||Q$1.current?.schedule(),X.refresh();},[X]),Rr=useCallback(()=>{p?.retiring||p?.recovering||Q$1.current?.schedule();},[p]),Lt=useCallback(e=>{e&&(st.set(e,p?.editPeer?.sentSequence??0),qe.delete(e));let o=!qe.size&&ye.every(i=>st.has(i));ue.sequence=o?Math.max(0,...ye.map(i=>st.get(i))):1/0,!p?.recovering&&!p?.retiring&&Q$1.current?.schedule();},[p,ue,st,qe,ye]),Do=e=>{let o=_.draft;if(!(o&&(o.source!==e.source||o.sheet!==e.sheet||o.row!==e.row||o.col!==e.col||o.revision!==e.revision||o.value!==e.value&&o.modified!==false)))if(o&&_.setDraft(null),e.source==="cell"){let i=U.current;i&&i.sheet===e.sheet&&i.row===e.row&&i.col===e.col&&i.revision===e.revision&&(i.value===e.value||i.modified===false)&&(Re.current=true,oe(null));}else Oe(null);},Ye=useCallback((e,o)=>{let i=p;if(!(!i?.peer||i.retiring))try{!o&&ue.request&&(!("ok"in e)||e.ok)&&e.applied&&(ue.revision+=1,ue.request=null,it(null)),Lt(o),Xe.current+=1;let a=i.peer.sheetInfo();g$1.current&&a.activeSheet===E.current&&V({...g$1.current,...a,sheet:a.activeSheet,version:i.peer.version()}),Rr(),Pr(),(!("ok"in e)||e.ok)&&e.applied&&b$1.current.onChange?.(),X.refresh();}catch(a){i.fail(a);}},[p,X,Rr,Pr,Lt,ue]),Fo=useCallback(()=>{let e=d.current,o=ar(),i=Q$1.current;if(!e?.current||e.failure||!o||!i)return Promise.resolve(false);let a=e.editPeer?.sentSequence??0;return ni(i.painted,o,a)?Promise.resolve(true):(i.schedule(),new Promise(h=>{let w={request:o,sequence:a,resolve(B){clearTimeout(P),h(B);}},P=setTimeout(()=>{Qe.current=Qe.current.filter(B=>B!==w),h(false);},1e3);Qe.current.push(w);}))},[ar]),_t=useCallback((e,o)=>{let i=p;if(!i?.peer||!i.current||i.retiring)return false;let a=i.peer.sheetInfo();if(a.activeSheet!==e)return false;We.current+=1,q$1(e),V({...g$1.current,...a,sheet:e,version:i.peer.version(),frozenWidth:0,frozenHeight:0}),O(o?structuredClone(o):null),vt(null),yt(null),Pt.current=null,_.draft||(oe(null),Oe(null));let h=c$1.current;if(h&&o){let w=i.peer.cellPosition(e,o.focus.row,o.focus.col);h.scrollLeft=w.x*L.current,h.scrollTop=w.y*L.current;}return i.recovering||(Rr(),Q$1.current?.schedule()),X.refresh(),true},[X,_,Rr]),qo=useCallback(async()=>{let e=d.current;if(!e?.current||!e.peer||!e.editPeer)throw new w("editor-unavailable");let o=e.editPeer;lr.current=o;let i;try{i=createWorkbookRecoveryMutators(o);}catch(a){throw a instanceof WorkbookEditPeerFailedError?a:new WorkbookEditPeerFailedError(a instanceof Error?a:new Error(String(a)))}e.recovering=true,e.editPeer=new Proxy(o,{get(a,h){return h in i?Reflect.get(i,h):h==="flush"||h==="save"?()=>Promise.reject(e.failure??new Error("Worker is unavailable")):Reflect.get(a,h)}});try{Et.current(!0),_.draft&&_.submit(_.draft),await _.recover();}catch(a){throw a instanceof w||a instanceof WorkbookEditPeerFailedError?a:new WorkbookEditPeerFailedError(a instanceof Error?a:new Error(String(a)))}finally{e.editPeer=o,e.recovering=false,_.fail(e.failure??o.error??new Error("Worker is unavailable"));}},[_]);At.current={getPositionAtPoint:(e,o)=>{let i=Q$1.current?.painted;return !i||i.request.generation!==d.current?.generation?null:na(i.displayList,i.request.sheet,y.current,e,o)},coordinator:()=>_,readOnly:()=>b$1.current.readOnly??false,focus:Ie,clearSelection:()=>{_.settle(),oe(null),Oe(null),O(null),vt(null),yt(null),X.refresh();},refreshProposals:Pr,recoverInput:qo,selectCells:_t,previewEdits:qr,canNavigateSync:()=>ue.request===null,selectCellsAsync:async(e,o)=>_t(e,o),apply:Ye};let Kt=useRef(null),[Cn]=useState(()=>({handle:()=>d.current?.ready&&!d.current.failure?d.current.peer:null,admit:(e,o)=>Kt.current.admit(e,o),readOnlyRefusal:e=>Kt.current.readOnlyRefusal(e),applyEdits:(...e)=>Kt.current.applyEdits(...e),admitEdits:(...e)=>Kt.current.admitEdits(...e),commands:()=>X,navigator:{selectCells:(...e)=>Kt.current.navigator.selectCells(...e),scrollToCell:(...e)=>Kt.current.navigator.scrollToCell(...e)}})),Mo=useMemo(()=>{let e=p?.session.state.sheets[x$1]?.id;return e===void 0?null:{sheetId:e,sheetIndex:x$1,cells:K,chartId:Be?.id??null}},[p,x$1,K,Be]),xt=Na({...n$1,access:Cn,commands:X,readOnly:n$1.readOnly??false,handle:p?.ready&&!p.failure?p.peer:null,selection:Mo,canvasRef:y,t:r}),Jr=useRef(xt.presentGrid);Jr.current=xt.presentGrid;let[no,oo]=Fa(xt.managed),Er=useCallback(()=>{for(let e of Qe.current.splice(0))e.resolve(false);},[]);useLayoutEffect(()=>{if(ot(null),xr(null),it(null),O(null),V(null),oe(null),Oe(null),vt(null),Ce(null),Ae(null),I$1.current=null,yt(null),Rt([]),me({}),$(false),Xe.current=0,We.current+=1,_e.current=false,ee.current=null,Ke.current=null,Ne.current!==null&&clearTimeout(Ne.current),Ne.current=null,Te.current?.settle(false),Te.current=null,xt.beginLoad(),!p)return;let e=new To({generation:p.generation,capture:ar,isCurrent:()=>p.current&&!p.failure,requestFrame:i=>p.session.call.frame(i.viewport,{sheet:i.sheet}),sentSequence:()=>p.editPeer?.sentSequence??0,publish(i){let a=y.current,h=a?.getContext("2d");if(!a||!h)throw new Error("Canvas context is unavailable");let w=i.request;a.width=Math.round(w.width*w.dpr),a.height=Math.round(w.height*w.dpr),a.style.width=`${w.width}px`,a.style.height=`${w.height}px`,paintDisplayList(h,i.displayList,w.dpr*w.zoom),a.dataset.workerSequence=String(i.sequence),a.dataset.paintSource=i.source,a.dataset.workerZoom=String(w.zoom),xr(i),i.sequence>=ue.sequence&&(ke.clear(),ye.length=0,at.clear(),Ge.clear(),ue.request=null,ue.committed=null,flushSync(()=>it(null)));let P=p.session.state.sheets[w.sheet]?.id;Jr.current(P===void 0?null:{frame:i.displayList,zoom:w.zoom,viewport:w.viewport,version:i.version,sheetId:P});for(let B of Qe.current.slice()){let z=ni(i,B.request,B.sequence);(z||!ni(i,B.request,0))&&(Qe.current=Qe.current.filter(T=>T!==B),B.resolve(z));}p.firstPaint();},onError:i=>p.fail(i)});Q$1.current=e;let o=p.session.state.activeSheet;return q$1(o),p.session.call.sheetView(o).then(i=>{!p.current||p.failure||Q$1.current!==e||(V(i),O(selectionAt({row:0,col:0})),c$1.current&&(c$1.current.scrollLeft=i.initialScrollX*L.current,c$1.current.scrollTop=i.initialScrollY*L.current),e.schedule());}).catch(i=>p.fail(i)),()=>{e.dispose(),Q$1.current===e&&(Q$1.current=null),Er(),Jr.current(null);}},[p,ar,Er]),useEffect(()=>{let e=c$1.current;if(!e||!p)return;let o=()=>Q$1.current?.schedule();e.addEventListener("scroll",o,{passive:true});let i=new ResizeObserver(o);return i.observe(e),o(),()=>{e.removeEventListener("scroll",o),i.disconnect();}},[p,C]),useEffect(()=>{if(typeof window.matchMedia!="function")return;let e,o=()=>{Q$1.current?.schedule(),e?.removeEventListener("change",o),e=window.matchMedia(`(resolution: ${window.devicePixelRatio||1}dppx)`),e.addEventListener("change",o);};return o(),()=>e?.removeEventListener("change",o)},[]),useEffect(()=>{p?.failure&&(Q$1.current?.dispose(),Er(),ee.current=null,Et.current(true),Xt(),Te.current?.settle(true),Te.current=null);},[p,p?.failure,Er]),useEffect(()=>()=>{Er(),Ne.current!==null&&clearTimeout(Ne.current),Te.current?.settle(false),Te.current=null;},[Er]),useEffect(()=>{if(Ae(null),!p?.current||p.failure||!K||Be)return;if(p.ready&&p.peer){Ae(p.peer.cell(x$1,K.focus.row,K.focus.col));return}let e=false,o=We.current;return p.session.call.cellInputs(x$1,yn(K.focus)).then(i=>{!e&&p.current&&We.current===o&&Ae(i.cells[0]?.[0]??null);}).catch(i=>{!e&&p.current&&p.fail(i);}),()=>{e=true;}},[p,p?.peer,K,x$1,Be,Ue]);let Sr=()=>{let e=d.current;if(!e?.current||e.retiring||e.failure||!M.current)return null;let o=e.session.confirmedBasis;return {owner:e,sheet:E.current,selection:M.current,navigation:We.current,version:`${o.epoch}:${o.version}:${e.peer?.version()??o.version}:${e.session.state.version}`}},he=e=>He.defer(Sr(),e),Pe=()=>f(Q$1.current?.painted?.displayList.grid),mt=()=>{let e=Q$1.current?.painted,o=d.current,i=Sr(),a=h(e?.request.sheet===E.current&&e.version===o?.session.confirmedBasis.version?e.mergedRanges:void 0);return j(o?.peer,E.current,i?He.merges(i,a):a)},Bt=()=>({context:Sr,limits:ht,hidden:Pe,merges:mt,known:(e,o)=>{let i=d.current,a=Q$1.current?.painted;return !!(i?.peer||He.known(e,o)||a?.request.sheet===e.sheet&&a.version===i?.session.confirmedBasis.version&&g(a.displayList.grid,o))},query:(e,o)=>(d.current.peer??d.current.session.call).selectionData(e.sheet,e.selection.focus.row,e.selection.focus.col,o),apply:e=>(F(e),Hr(E.current,e),true)});j$1.current=e=>{He.select(e,{...Bt(),apply:o=>(F(o),true)});};let ct=e=>d.current?.peer?he(e):He.beforeInput({...Bt(),apply:o=>(F(o),true)},e,()=>pe(new w("editor-unavailable"))),ht=()=>oa(Q$1.current?.painted?.displayList??null,(c$1.current?.clientHeight??0)/L.current),Zr=(e,o,i)=>({generation:d.current.generation,sheet:E.current,...o,source:e,value:i,revision:++te.current,draftId:te.current}),Xt=()=>{let e=_.draft,o=e?.source==="cell"?f$1.current:A.current;if(e&&o&&e.value!==o.value){let i={...e,value:o.value,prefill:false,modified:true,revision:++te.current};_.setDraft(i),i.source==="cell"?oe(i):Oe(i.value);}},Pn=()=>{if(ee.current)return {refused:"gesture-active"};Et.current();let e=Te.current;return e?(e.source==="cell"?(Re.current=true,f$1.current?.blur(),Re.current=false):(Cr.current=true,A.current?.blur(),Cr.current=false),{composition:e.done}):{}};bt.current={generation:()=>p?.generation??0,capture:()=>({sheet:x$1,target:JSON.stringify(K)}),isReady:()=>p?.ready??false,whenReady:()=>p.whenHydrated(),requestHydration:e=>p.requestHydration(e),flushEdits:()=>p.editPeer.flush(),preview:Le,seal:Pn,sync:Xt,async acknowledgeEdits(){if(!(!p?.peer||!p.editPeer)){for(let e of ye.slice()){let o=st.get(e);if(o===void 0||o>p.editPeer.acknowledgedSequence)continue;let i=[...at.get(e)?.keys()??[]];if(i[0]){let[a,h,w]=i[0].split(":").map(Number);ue.committed={generation:p.generation,sheet:a,row:h,col:w,value:p.peer.cell(a,h,w).input,source:"cell"};}for(let a of i){let[h,w,P]=a.split(":").map(Number);Ht(a,e,{input:p.peer.cell(h,w,P).input,index:-1}),ke.get(a)===e&&(ke.delete(a),Ge.delete(a));}ye.splice(ye.indexOf(e),1),st.delete(e),Se&&St.get(Se)===e&&(St.delete(Se),Fr.delete(Se));}!qe.size&&ye.every(e=>st.has(e))&&(ue.sequence=p.editPeer.sentSequence);}},async resolveDraft(e){if(!e.value.startsWith("=")&&[...e.value.replace(/^'/,"")].length>32767)throw new z("Cell text exceeds 32,767 characters");if(e.modified!==false)return e;let o=`${e.sheet}:${e.row}:${e.col}`,i=Ge.get(o);if(i!==void 0)return {...e,value:i,modified:true};let a=p&&workbookSessionInternals.get(p.session),h=p?.peer?p.peer.cell(e.sheet,e.row,e.col).input:a?.cellInput?await a.cellInput(e.sheet,e.row,e.col):(await p.session.call.cellInputs(e.sheet,yn(e))).cells[0]?.[0]?.input??"";return {...e,value:h,modified:true,unchanged:true}},write(e,o){let i=p;if(!i?.ready||!i.peer||!i.editPeer)return false;if(i.peer.cell(e.sheet,e.row,e.col).input!==e.value){o.check();let a=St.get(e),h=workbookEditPeerOperations(i.recovering?lr.current:i.editPeer),w;try{w=a?p.recovering?h.applyRecoveryOp(a):h.applyQueuedOp(a):i.editPeer.editCell(e.sheet,e.row,e.col,e.value);}catch(P){throw za(P)&&Fr.get(e)?.(),P}o(),Ye(w,a);}else Lt(St.get(e));return i.retiring||Do(e),true}};let Qt=e=>{if(ct(()=>Qt(e)))return;let o=d.current,i$1=M.current;if(!$e()||!o||!i$1)return;_.draft&&(Xt(),_.settle(),Oe(null));let a=i(i$1.focus,mt()),h=Q$1.current?.painted?.displayList.grid;I$1.current=h?cellRect(h,a.row,a.col):null;let w={...Zr("cell",a,e??o.peer?.cell(E.current,a.row,a.col).input??""),prefill:e===void 0&&!o.peer,modified:e!==void 0};_.setDraft(w),oe(w),!(e!==void 0||o.peer)&&o.session.call.cellInputs(w.sheet,yn(a)).then(P=>{if(!o.current||o.failure||_.draft!==w||U.current!==w)return;let B={...w,value:P.cells[0]?.[0]?.input??"",prefill:false},z=f$1.current,T=z?.selectionStart,H=z?.selectionEnd;flushSync(()=>{oe(B),_.setDraft(B);}),z&&T!=null&&H!=null&&z.setSelectionRange(T,H);}).catch(P=>o.fail(P));},Dt=(e,o,i=false)=>{if(!i&&he(()=>Dt(e,o,true))||!$e()||Te.current)return;i||Xt();let a=_.draft;if(a?.source!==e||!_.submit(a))return;a.modified!==false&&!qe.size&&(ue.sequence=1/0,dt.current&&(dt.current.dataset.previewReady="false"),it(a)),e==="cell"?(Re.current=true,oe(null)):Oe(null);let h=selectionAt({row:a.row,col:a.col});o&&!d.current?.peer?(He.select(h,Bt()),He.enqueue({key:o==="down"||o==="up"?"Enter":"Tab",shiftKey:o==="up"||o==="left"},Bt())):O(o?moveFocus(h,o,{limits:ht(),hidden:Pe(),merges:mt()}):h),Ie();},Qr=()=>{he(Qr)||(_.setDraft(null),Re.current=true,oe(null),Oe(null),Ie());},Mr=e$1=>{if(ct(()=>Mr(e$1)))return;let o=d.current,i=M.current,a=i&&k(i,mt());if(!o?.current||o.failure||!a||e$1!=="copy"&&!$e())return;a!==i&&O(a);let h=E.current,w$1=normalizeRange(a),P=()=>p.peer?.selectionData(h,0,0,"usedRange").usedRange,B;if(e$1!=="paste")if(typeof ClipboardItem!="function"||typeof navigator.clipboard.write!="function"){if(e$1==="cut"){pe(new z("Cut requires clipboard write access"));return}}else {let be,ge,Je=new Promise((De,et)=>{be=De,ge=et;});Je.catch(()=>{});try{let De=navigator.clipboard.write([new ClipboardItem({"text/plain":Je})]).then(()=>!0,et=>{throw ge(et),new z(et instanceof Error?et.message:"Clipboard write failed",e$1==="cut")});De.catch(()=>{}),B={resolve:be,reject:ge,done:De};}catch(De){ge(De),pe(new z(De instanceof Error?De.message:"Clipboard write failed"));return}}let z$1=()=>e$1==="paste"?navigator.clipboard.readText():"",T,H,G;B?.done.catch(be=>{G=be,e$1==="cut"&&H&&H().catch(pe),pe(be);});let se=async(be,ge=false)=>{if(!(e$1==="cut"&&b(w$1)&&!ge)){if(e$1!=="copy"&&!T){let Je=e$1==="cut"&&b(w$1)?await(p.peer??p.session.call).selectionData?.(h,0,0,"usedRange"):void 0,De=e$1==="paste"?[]:e(w$1,()=>Je?.usedRange);if(!De)throw new z("Clear exceeds the cell limit");if(e$1==="cut"&&De.length===0)return;e$1==="paste"&&fromTsv(be).forEach((et,or)=>et.forEach((Fn,ir)=>De.push({row:w$1.top+or,col:w$1.left+ir,input:Fn}))),T={method:"editCells",args:[h,De]};}if(T&&!ge&&(H=await qr(h,T.args[1],T)),G)throw await H?.(),G}};_.clipboard(z$1,async(be,ge,Je)=>{if(e$1!=="copy"&&!T&&await se(be,true),e$1!=="paste"){let ir=toTsv(o.peer.rangeCells(h,ps(c(w$1,P)))),qn;if(B)B.resolve(new Blob([ir],{type:"text/plain"})),qn=await B.done;else try{await navigator.clipboard.writeText(ir),qn=!0;}catch(ao){throw new z(ao instanceof Error?ao.message:"Clipboard write failed")}if(!o.current)throw new w("document-replaced");if(Je.check(),!qn)throw new z("Clipboard write was refused",e$1==="cut");if(e$1==="copy")return}if(!T)return;let De=T,et=De.args[1];if(et.length===0)return;Je.check();let or=workbookEditPeerOperations(p.recovering?lr.current:p.editPeer),Fn=p.recovering?or.applyRecoveryOp(De):or.applyQueuedOp(De);Je(),Ye(Fn,De),e$1==="paste"&&M.current===a&&E.current===h&&O({anchor:{row:w$1.top,col:w$1.left},focus:{row:Math.max(...et.map(ir=>ir.row)),col:Math.max(...et.map(ir=>ir.col))}});},{sheet:h,target:JSON.stringify(w$1)},e$1!=="copy"?se:void 0,e$1!=="copy").catch(async be=>{B?.reject(be),za(be)&&await H?.(),pe(be);});},Gt=()=>{if(!$e()||!M.current)return;let e$1=E.current,o=normalizeRange(M.current),i,a,h=async()=>{let w=b(o)?await(p.peer??p.session.call).selectionData?.(e$1,0,0,"usedRange"):void 0,P=e(o,()=>w?.usedRange);if(!P)throw new z("Clear exceeds the cell limit");P.length!==0&&(i={method:"editCells",args:[e$1,P]},b(o)||(a=await qr(e$1,P,i)));};_.runAfterPendingInput(async(w,P)=>{if(i||await h(),!i)return;P.check();let B=workbookEditPeerOperations(p.recovering?lr.current:p.editPeer),z=p.recovering?B.applyRecoveryOp(i):B.applyQueuedOp(i);P(),Ye(z,i);},{kind:"input",target:{sheet:e$1,target:JSON.stringify(o)},prepare:async()=>{b(o)||await h();}}).catch(async w=>{za(w)&&await a?.(),pe(w);});},Rn=(e,o)=>{let i=p;if(!i?.current||i.failure)return;let a=w=>{let P=!i.peer;P&&(We.current+=1,q$1(e),F(w)),_.runAfterPendingInput(async(B,z)=>{z.check(),i.editPeer.setActiveSheet(e),z(),P?E.current===e&&_t(e,M.current):_t(e,w);},{kind:"input",target:{sheet:e,target:JSON.stringify(w)}}).catch(pe);},h=structuredClone(o);i.peer?a(h):He.select(h,{...Bt(),apply:w=>(a(w),true)},e,true);},Xr=(e,o,i,a,h=false)=>{let w=p;if(!w?.current||!h&&!$e()||i===0&&a===0)return;let P=async(z,T)=>{await It(),T.check();let H=w.editPeer.moveChart(e,o,i,a);T(),Ye(H),Ce(null);},B={kind:"chart",target:{sheet:e,target:o},input:{dx:i,dy:a}};(h?_.input(P,B):_.runAfterPendingInput(P,B)).catch(pe);},er=(e=false)=>{let o=Ke.current;Ke.current=null,o&&Xr(o.sheet,o.id,o.dx,o.dy,e),Ne.current!==null&&clearTimeout(Ne.current),Ne.current=null;};Et.current=er,p&&(p.beforeRetire=()=>{_.retire(),Zt.resolve(),Q$1.current?.dispose(),Xt(),Te.current?.settle(true),Te.current=null,er(true);});let cr=useRef(Xr);cr.current=Xr,useEffect(()=>{let e=i=>{_e.current=false;let a=ee.current;ee.current=null,a&&i.button===0?cr.current(a.sheet,a.id,(i.clientX-a.clientX)/a.zoom,(i.clientY-a.clientY)/a.zoom):Ce(null);},o=()=>{_e.current=false,ee.current=null,Ce(null),Et.current();};return window.addEventListener("mouseup",e),window.addEventListener("blur",o),()=>{window.removeEventListener("mouseup",e),window.removeEventListener("blur",o);}},[]);let Or=e=>{let o=Q$1.current?.painted,i=y.current;if(!o||o.request.sheet!==E.current||!i)return {cell:null,chart:null};let a=i.getBoundingClientRect(),h=(e.clientX-a.left)/o.request.zoom,w=(e.clientY-a.top)/o.request.zoom;return {cell:o.geometry?cellAtPoint(o.geometry,h,w):null,chart:chartRegionAtPoint(o.displayList.charts,h,w)}},Oo=e=>{if(jn(e)||d.current?.failure||f$1.current?.contains(e.target))return;let{cell:o,chart:i$1}=Or(e),a=U.current!==null;if(a?Dt("cell"):_.draft?.source==="formula"&&Dt("formula"),Et.current(),ee.current=null,Ze.current=null,i$1){vt({id:i$1.id,movable:i$1.movable}),$e()&&i$1.movable&&e.button===0&&(ee.current={id:i$1.id,sheet:E.current,zoom:Q$1.current?.painted?.request.zoom??L.current,clientX:e.clientX,clientY:e.clientY}),Ie(),e.preventDefault();return}vt(null),!(!o||!M.current)&&(O(e.shiftKey?extendTo(M.current,o,ht()):selectionAt(i(o,mt()))),Ze.current=a?null:o,_e.current=true,Ie());},io=e=>{if(jn(e)||d.current?.failure)return;let o=ee.current;if(o){if(!e.buttons){ee.current=null,Ce(null);return}Ce({x:e.clientX-o.clientX,y:e.clientY-o.clientY}),e.currentTarget.style.cursor="move",e.currentTarget.title="";return}let{cell:i,chart:a}=Or(e);if(_e.current&&i&&M.current){O(extendTo(M.current,i,ht()));return}let h=i&&Q$1.current?.painted?hyperlinkAtCell(Q$1.current.painted.displayList,i.row,i.col):null;e.currentTarget.style.cursor=a?.movable&&$e()?"move":a||h?"pointer":"default",e.currentTarget.title=a?"":h?.tooltip??"";},Ho=e=>{if(jn(e)||d.current?.failure)return;let{cell:o}=Or(e),i=Ze.current;Ze.current=null;let a=Q$1.current?.painted?.displayList;if(!o||!i||!a||o.row!==i.row||o.col!==i.col)return;let h=hyperlinkAtCell(a,o.row,o.col);if(!h)return;let w=safeExternalHyperlink(h);if(w){window.open(w,"_blank","noopener,noreferrer");return}if(!h.location)return;let P=d.current.session.state.sheets,B=parseHyperlinkLocation(h.location,P[E.current]?.name??"");if(!B)return;let z=P.findIndex(T=>T.name.toLowerCase()===B.sheetName.toLowerCase());z>=0&&Rn(z,selectionAt(B));},zt=e=>{if(jn(e)||d.current?.failure||!g$1.current||!M.current||U.current||q(e))return;let o=e.metaKey||e.ctrlKey,i=ze.current;if(i){if(e.key==="Escape"){ee.current=null,Ke.current=null,Ce(null),vt(null),Ne.current!==null&&clearTimeout(Ne.current),Ne.current=null,e.preventDefault();return}let z=!o&&Vl[e.key];if(z){if($e()&&i.movable){let T=e.shiftKey?10:1,H=Q$1.current?.painted?.request.zoom??L.current,G=Ke.current??{id:i.id,sheet:E.current,dx:0,dy:0};Ke.current={...G,dx:G.dx+z[0]*T,dy:G.dy+z[1]*T},Ce({x:Ke.current.dx*H,y:Ke.current.dy*H}),Ne.current!==null&&clearTimeout(Ne.current),Ne.current=setTimeout(()=>Et.current(),250);}e.preventDefault();}return}if(o){let z=e.key.toLowerCase();if(z==="c"||z==="x"||z==="v"){let T=z==="c"?"copy":z==="x"?"cut":"paste";he(()=>Mr(T))||Mr(T),e.preventDefault();return}}let a=l(e),h={key:e.key,ctrlKey:e.ctrlKey,metaKey:e.metaKey,altKey:e.altKey,shiftKey:e.shiftKey},w=a||selectionKeyReducer(M.current,h,ht()).type==="move",P=()=>{if(!M.current)return;if(U.current){if(h.key==="Enter"||h.key==="Tab")Dt("cell",h.key==="Enter"?h.shiftKey?"up":"down":h.shiftKey?"left":"right",true);else if(h.key==="Escape")Qr();else if(h.key.length===1&&!h.ctrlKey&&!h.metaKey&&!h.altKey){let G={...U.current,value:U.current.value+h.key};f$1.current&&(f$1.current.value=G.value),_.setDraft(G),oe(G);}return}if(!d.current?.peer&&w){He.enqueue(h,Bt());return}let z=M.current,T=a?d.current?.peer?.selectionData(E.current,z.focus.row,z.focus.col,a==="region"?void 0:a):void 0,H=selectionKeyReducer(z,h,ht(),T,Pe(),mt());H.type==="move"?(O(H.selection),Hr(E.current,M.current)):H.type==="startEdit"?Qt(H.initialInput):H.type==="clear"&&Gt();};if(!d.current?.peer&&w){e.preventDefault(),He.defer(Sr(),P,true)||He.enqueue(h,Bt());return}(selectionKeyReducer(M.current,h,ht(),void 0,Pe(),mt()).type!=="none"||a)&&(e.preventDefault(),he(P)||P());},en=(e,o,i,a,h,w)=>{let P=d.current,B=c$1.current;if(!P?.current||!w()||!B||E.current!==o)return;let z=e.sheetInfo(),T=e.cellPosition(o,i,a),H=e.cellRect(o,i,a),G=L.current;g$1.current&&V(pa$1(B,g$1.current,H,G));let se=Ca$1(Q$1.current?.painted?.displayList.grid,z.frozenRows,z.frozenCols),be=fs(T.x,H.w,a<z.frozenCols,B.scrollLeft/G,B.clientWidth/G-se.width,h),ge=fs(T.y,H.h,i<z.frozenRows,B.scrollTop/G,B.clientHeight/G-se.height,h);be!==null&&(B.scrollLeft=be*G),ge!==null&&(B.scrollTop=ge*G),P.recovering||Q$1.current?.schedule();},Hr=(e,o,i)=>{let a=d.current;if(!a?.current)return;let h=()=>a.current&&d.current===a&&E.current===e&&M.current===o;if(a.peer){let T=c$1.current;if(i!==void 0&&(!T||!qa(T,a.peer.cellRect(e,o.focus.row,o.focus.col),i)))return;en(a.peer,e,o.focus.row,o.focus.col,"nearest",h);return}let w=T=>{let H=c$1.current,G=g$1.current;if(!h()||!H||!G||G.sheet!==e||i!==void 0&&!qa(H,T,i))return;let se=L.current;(T.x+T.w>G.contentWidth||T.y+T.h>G.contentHeight)&&V(pa$1(H,G,T,se));let be=sa(T,o.focus,G,{x:H.scrollLeft/se,y:H.scrollTop/se,width:H.clientWidth/se,height:H.clientHeight/se});(H.scrollLeft!==be.x*se||H.scrollTop!==be.y*se)&&(H.scrollLeft=be.x*se,H.scrollTop=be.y*se,Q$1.current?.schedule());},P=Q$1.current?.painted,B=g$1.current,z=P?.request.sheet===e&&B?ra(P.displayList,P.request.viewport,B,o.focus):null;z?w(z):a.session.call.cellGeometry(e,o.focus.row,o.focus.col).then(T=>w(T.rect)).catch(pe);},En=useRef(C);useLayoutEffect(()=>{if(En.current===C)return;let e=En.current;En.current=C;let o=M.current;o&&!ze.current&&Hr(E.current,o,e);},[C]);let Sn=(e,o,i)=>{if(!i||!Number.isInteger(i.row)||!Number.isInteger(i.col)||i.row<0||i.col<0||i.row>1048575||i.col>16383)return false;try{return e.cellPosition(o,i.row,i.col),!0}catch{return false}};Kt.current={handle:Cn.handle,commands:()=>X,async admit(e,o){try{return {ok:!0,value:await _.runAfterPendingInput(async(a,h)=>{if(d.current?.peer!==e)throw new w("document-replaced");await It(),h.check();let w$1=o();if(d.current?.recovering&&w$1!==null&&typeof w$1=="object"&&("refused"in w$1||"ok"in w$1&&w$1.ok===!1))throw new w("input-failed");return w$1!==null&&typeof w$1=="object"&&("refused"in w$1||"ok"in w$1&&w$1.ok===!1)?h.refuse(new z("Plugin request was refused")):h(),w$1},{kind:"plugin",recover:!1})}}catch(i){return {ok:false,code:i instanceof w&&i.code==="document-replaced"?"document-replaced":"input-failed",error:i}}},async admitEdits(e,o,i,a){let h=p,w$1=h?.editPeer;if(!h||!w$1||h.peer!==e)return {ok:false,code:"document-replaced",error:new w("document-replaced")};let P={method:"applyEdits",args:[structuredClone(o)]},B=workbookEditPeerOperations(w$1),z$1=Kt.current.readOnlyRefusal(e);try{return {ok:!0,value:await _.runAfterPendingInput(async(H,G)=>{await It(),G.check();let se=i(h.recovering);if(se)return G.refuse(new z("Plugin write permission was refused")),se;if(z$1)return G.refuse(new z(z$1.failure.message)),z$1;let be=()=>h.recovering?B.applyRecoveryOp(P):B.applyQueuedOp(P),ge;try{ge=h.recovering?be():a(be);}catch(Je){if(!(Je instanceof WorkbookRecoveryRefusal))throw Je;ge=Je.result;}return ge.ok?(G(),Ye(ge),ge):(G.refuse(new z(ge.failure.message),!0),ge)},{kind:"plugin",input:P})}}catch(T){return {ok:false,code:T instanceof w&&T.code==="document-replaced"?"document-replaced":"input-failed",error:T}}},readOnlyRefusal:e=>b$1.current.readOnly?{ok:false,version:e.version(),failure:{code:"read-only",message:"The editor is read-only"}}:null,applyEdits(e,o,i,a){let h=i();if(h)return h;let w=Kt.current.readOnlyRefusal(e);if(w)return w;let P=a(()=>d.current.editPeer.applyEdits(o));return Ye(P),P},navigator:{selectCells(e,o,i,a){let h=e.sheetInfo().sheetIds.indexOf(o?.sheetId);return h<0||!Sn(e,h,o?.selection?.anchor)||!Sn(e,h,o?.selection?.focus)?"missing-target":(d.current.editPeer.setActiveSheet(h),_t(h,o.selection),en(e,h,o.selection.focus.row,o.selection.focus.col,"nearest",a),i&&Ie(),null)},scrollToCell(e,o,i,a){let h=e.sheetInfo().sheetIds.indexOf(o?.sheetId);return h<0||!Sn(e,h,o)?"missing-target":(h!==E.current&&(d.current.editPeer.setActiveSheet(h),_t(h,null)),en(e,h,o.row,o.col,i,a),null)}}};let Xn=Q({document:()=>d.current?.current&&!d.current.retiring&&!d.current.failure?d.current:null,onSaveRequest:n$1.onSaveRequest,fail:pe});rs(X,{requestSave:Xn,peer:()=>p?.peer??null,editPeer:()=>p?.editPeer??null,status:()=>p?.ready?"ready":p&&!p.failure||re?"loading":"empty",readOnly:()=>b$1.current.readOnly??false,collaborative:()=>false,mutation:()=>Xe.current,generation:()=>p?.generation??0,view:()=>({sheet:E.current,selection:M.current,chartSelected:ze.current!==null,zoom:L.current,capturedFormat:Mt.current,borderStyle:kr.current,borderColor:pt.current,proposals:u.current,proposalsAvailable:isProposalsAvailable(),proposalsPanelOpen:Z.current,pngExport:false}),coordinator:_,preview:()=>Le(),recovering:()=>d.current?.recovering??false,i18n:()=>b$1.current.i18n,translate:r,apply:Ye,fail:e=>p?.fail(e),setZoom:e=>{v(e),Q$1.current?.schedule();},setProposalsPanelOpen:$,setCapturedFormat:(e,o)=>{yt(e),Pt.current=o;},setBorderStyle:e=>{kr.current=e;},setBorderColor:e=>{pt.current=e;},markStale:(e,o)=>me(({[e]:i,...a})=>o?{...a,[e]:o}:a),refreshProposals:Pr,deliver(e){if(b$1.current.onSave)b$1.current.onSave(e);else {let o=URL.createObjectURL(new Blob([new Uint8Array(e)],{type:$l})),i=document.createElement("a");i.href=o,i.download=b$1.current.fileName??"workbook.xlsx",document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(o);}},afterPaint:Fo,focusGrid:Ie,refuse:e=>ot(e.message)}),P(X,l$1),useEffect(()=>{if(!lt||!K||!$e()||_e.current)return;let e=normalizeRange(K);if(`${x$1}:${e.top}:${e.left}:${e.bottom}:${e.right}`===Pt.current)return;let i=lt,a=Ul(K);yt(null),Pt.current=null,_.runAfterPendingInput(async(h,w)=>{await It(),w.check();let P=p.editPeer.applyFormat(x$1,a,i);w(),Ye(P),Ie();},{kind:"input",target:{sheet:x$1,target:a}}).catch(pe);},[lt,K,x$1,_,It,Ye,pe,Ie]),useLayoutEffect(()=>{if(!n$1.readOnly)return;Xt(),ro.current=te.current;let e=_.draft?.source;Re.current=true,Cr.current=true,Te.current?.settle(true),Te.current=null,oe(null),Oe(null),yt(null),Pt.current=null,_e.current=false,Ze.current=null,ee.current=null,Ke.current=null,Ce(null),Ne.current!==null&&clearTimeout(Ne.current),Ne.current=null,(_.draft||_.pending)&&_.drain().catch(pe),e==="cell"&&Ie(),Cr.current=false;},[n$1.readOnly,_]);let Wn=e=>{if(ct(()=>Wn(e))||!$e())return;e==="formula"&&_.draft?.source!=="formula"&&M.current&&(Xt(),_.settle(),Re.current=true,oe(null),_.setDraft(Zr(e,i(M.current.focus,mt()),A.current?.value??"")));let o,i$1=new Promise(a=>{o=a;});Te.current={source:e,done:i$1,settle:o};},ur=e=>{if(he(()=>ur(e))||!Te.current)return;let o=_.draft;if(e!==void 0&&o){let i={...o,value:e};_.setDraft(i),o.source==="cell"?oe(i):Oe(e);}else Xt();Te.current?.settle(true),Te.current=null;},ut=useCallback(e=>{e||bt.current?.sync?.(),f$1.current=e,e&&(Re.current=false),!e&&Te.current?.source==="cell"&&(Te.current.settle(true),Te.current=null);},[bt]),Nt=useCallback(e=>{e||bt.current?.sync?.(),A.current=e,!e&&Te.current?.source==="formula"&&(Te.current.settle(true),Te.current=null);},[bt]);useLayoutEffect(()=>{if(!le||p?.failure)return;let e=f$1.current;e&&document.activeElement!==e&&(e.focus({preventScroll:true}),e.setSelectionRange(e.value.length,e.value.length));},[le!==null]);let Tn=e=>{let o=M.current;if(!$e()||!o||ze.current)return;let i$1=_.draft;i$1&&i$1.source!=="formula"&&(Xt(),_.settle(),Re.current=true,oe(null),i$1=null),_.setDraft({...i$1??Zr("formula",i(o.focus,mt()),e),value:e,modified:true,revision:++te.current});},$t={onNavigate:e=>{He.select(selectionAt(e),Bt()),Ie();},a1:K?yn(K.focus):"",value:(Te.current?.source==="formula"?A.current?.value:void 0)??J??N?.input??"",disabled:!W||!K||!!Ot,readOnly:!$e()||Be!==null,inputRef:Nt,onChange(e){!$e()||!M.current||ze.current||(Oe(e),ct(()=>Tn(e))||Tn(e));},onCommit:e=>Dt("formula",e),onCancel:Qr,onBlur:()=>{Cr.current||Dt("formula");},onCompositionStart:()=>Wn("formula"),onCompositionEnd:()=>ur(A.current?.value)},je=Ue?.displayList;useEffect(()=>{!Be||!je||je.charts?.some(e=>e.id===Be.id)||(Et.current(),ee.current=null,Ce(null),vt(null));},[Be,je]);let Wt=Ue?.request.zoom??C,Yt=Ue?.request.sheet===x$1?K:null,tr=Ue?.mergedRanges??[],jt=je?.grid,An=Yt?ua$1(normalizeRange(Yt),tr):null,In=Yt?ua$1({top:Yt.focus.row,left:Yt.focus.col,bottom:Yt.focus.row,right:Yt.focus.col},tr):null,Br=jt&&An?rangeRect(jt,An):null,dr=jt&&In?rangeRect(jt,In):null,so=le?(jt&&le.sheet===Ue?.request.sheet?cellRect(jt,le.row,le.col):null)??I$1.current??{x:0,y:0,w:96,h:24}:null,rr=Se&&jt&&Se.sheet===Ue?.request.sheet?rangeRect(jt,ua$1({top:Se.row,left:Se.col,bottom:Se.row,right:Se.col},tr)):null,zr=Be?je?.charts?.find(e=>e.id===Be.id)?.rect:null,tn=p?.session.state.sheets??[],nr=je&&Ue?buildA11yGrid(je,Yt,tn[Ue.request.sheet]?.name??"",{gridLabel:r("a11y.gridLabel"),rowHeaderLabel:r("a11y.rowHeaderLabel"),columnHeaderLabel:r("a11y.columnHeaderLabel"),cellLabel:r("a11y.cellLabel"),cellLabelSelected:r("a11y.cellLabelSelected"),emptyCellLabel:r("a11y.emptyCellLabel"),emptyCellLabelSelected:r("a11y.emptyCellLabelSelected")}):null,Wr=(e,o,i)=>{let a=ta(e,Wt);return {position:"absolute",left:a.x,top:a.y,width:a.w,height:a.h,boxSizing:"border-box",border:o,background:i}},lo=jsxs(ma$1,{mode:"commands",children:[jsx(ma$1.Toolbar,{}),jsxs("div",{style:{display:"flex",padding:"4px 8px"},children:[jsx(ma$1.FormulaBar,{}),isProposalsAvailable()&&jsx(ga$1,{id:"proposalsPanel"})]})]}),Ln=n$1.showToolbar===false?null:n$1.toolbar===void 0?n$1.readOnly?null:lo:n$1.toolbar,Dn=e=>xt.managed?jsx(Ga,{host:xt.host,placement:e,activations:xt.activations.filter(o=>o.plugin.panel?.placement===e),available:oo}):null;return jsx(I.Provider,{value:X.store,children:jsx(S.Provider,{value:true,children:jsx(Y.Provider,{value:$t,children:jsxs("div",{ref:l$1,className:n$1.className,role:"application","aria-label":r("editor.appLabel"),style:{position:"relative",display:"flex",flexDirection:"column",width:"100%",height:"100%",minWidth:0,color:"#202124",background:"#ffffff",fontFamily:"ui-sans-serif, system-ui, sans-serif"},children:[Ln!=null&&jsx("div",{"data-testid":"xlsx-toolbar",style:{flex:"0 0 auto"},children:Ln}),jsxs("div",{ref:no,"data-testid":"xlsx-workspace",style:{position:"relative",display:"flex",flex:1,minWidth:0,minHeight:0},children:[Dn("left"),jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0},children:[isProposalsAvailable()&&S$1&&jsx(xa$1,{proposals:Tt,staleFor:xe,style:{top:4,right:8,width:"min(320px, calc(100% - 16px))",maxHeight:"min(420px, calc(100% - 12px))"}}),jsxs("div",{ref:c$1,"data-testid":"xlsx-scroll",tabIndex:0,onKeyDown:zt,onMouseDown:Oo,onMouseMove:io,onClick:Ho,onDoubleClick:e=>{if(jn(e)||U.current||Or(e).chart)return;let o=Or(e).cell;o&&je&&hyperlinkAtCell(je,o.row,o.col)||Qt();},onMouseLeave:e=>{e.currentTarget.style.cursor="default",e.currentTarget.title="";},style:{position:"relative",flex:1,overflow:"auto",minHeight:0,outline:"none"},children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:W?W.contentWidth*C:"100%",height:W?W.contentHeight*C:"100%"}}),jsxs("div",{style:{position:"sticky",top:0,left:0,width:0,height:0},children:[jsx("canvas",{ref:y,style:{display:"block",position:"absolute",top:0,left:0}}),Se&&(p?.ready?jsx("div",{"data-testid":"xlsx-commit-preview","aria-hidden":true,style:{...Wr(rr??{x:0,y:0,w:96,h:24},"none","#fff"),color:"#000",padding:`0 ${8*Wt}px`,overflow:"hidden",whiteSpace:"pre",display:Se.sheet===x$1&&(!jt||rr)?"block":"none",font:`${13*Wt}px system-ui, sans-serif`,lineHeight:`${(rr?.h??24)*Wt}px`,pointerEvents:"none"},children:Se.value}):jsx("canvas",{ref:dt,"data-testid":"xlsx-commit-preview","aria-hidden":true,style:{position:"absolute",left:0,top:0,pointerEvents:"none"},children:Se.value})),xt.managed&&jsx(Ba,{host:xt.host,activations:xt.activations,layerRef:xt.overlayLayerRef,width:(je?.width??0)*Wt,height:(je?.height??0)*Wt}),jsxs("div",{"data-testid":"xlsx-overlay-host",style:{position:"absolute",top:0,left:0,width:0,height:0,pointerEvents:"none"},children:[Br&&!Be&&jsx("div",{"data-testid":"xlsx-selection",style:Wr(Br,`1px solid ${Yn}`,"rgba(33, 115, 70, 0.12)")}),dr&&!Be&&!le&&jsx("div",{style:Wr(dr,`2px solid ${Yn}`)}),zr&&jsx("div",{"data-testid":"xlsx-chart-selection","data-chart-id":Be?.id,"aria-hidden":true,style:{...Wr(zr,`2px solid ${Yn}`),transform:`translate(${ft?.x??0}px, ${ft?.y??0}px)`,boxShadow:"0 1px 6px rgba(0, 0, 0, 0.25)"}}),le&&so&&jsx("input",{ref:ut,"data-testid":"xlsx-cell-editor",value:(Te.current?.source==="cell"?f$1.current?.value:void 0)??le.value,disabled:!!Ot||n$1.readOnly,onChange:e=>{if(!$e())return;let o={...le,value:e.target.value,prefill:false,modified:true,revision:++te.current};oe(o),_.setDraft(o);},onCompositionStart:()=>Wn("cell"),onCompositionEnd:e=>ur(e.currentTarget.value),onKeyDown:e=>{q(e)||e.stopPropagation(),!(e.nativeEvent.isComposing||e.keyCode===229)&&(e.key==="Enter"?(Dt("cell",e.shiftKey?"up":"down"),e.preventDefault()):e.key==="Tab"?(Dt("cell",e.shiftKey?"left":"right"),e.preventDefault()):e.key==="Escape"&&(Qr(),e.preventDefault()));},onBlur:()=>{if(Re.current){Re.current=false;return}Dt("cell");},style:{...Wr(so,`2px solid ${Yn}`,"#ffffff"),padding:"0 3px",font:`${13*Wt}px system-ui, sans-serif`,pointerEvents:"auto",outline:"none"}})]})]})]}),Dn("bottom")]}),Dn("right")]}),nr&&jsxs(Fragment,{children:[jsxs("div",{style:ds,role:"grid","aria-label":nr.label,children:[jsxs("div",{role:"row",children:[jsx("span",{role:"columnheader"}),nr.columnHeaders.map(e=>jsx("span",{role:"columnheader",children:e.label},e.col))]}),nr.rows.map(e=>jsxs("div",{role:"row",children:[jsx("span",{role:"rowheader",children:e.header}),e.cells.map(o=>jsx("span",{role:"gridcell","aria-selected":o.selected,children:o.label},o.col))]},e.row))]}),nr.charts.map((e,o)=>jsx("div",{style:ds,role:"img","aria-label":e.label},`${o}:${e.label}`))]}),Ct&&jsx("div",{"data-testid":"xlsx-input-refusal",role:"alert",style:{position:"relative",zIndex:1},children:Ct}),Ot&&jsxs("div",{"data-testid":"xlsx-error",role:"alert",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",padding:16,textAlign:"center",color:"#b00020"},children:[r("editor.openError"),": ",Ot.message]}),tn.length>0&&jsx("div",{"data-testid":"xlsx-sheet-tabs",role:"tablist","aria-label":r("editor.sheetTabsLabel"),style:{display:"flex",gap:2,padding:"4px 6px",borderTop:"1px solid #e0e0e0",background:"#fafafa",overflowX:"auto"},children:tn.map((e,o)=>jsx("button",{role:"tab","aria-selected":o===x$1,disabled:!!Ot,onClick:()=>Rn(o,selectionAt({row:0,col:0})),style:{border:"none",padding:"4px 12px",cursor:"pointer",background:o===x$1?"#ffffff":"transparent",borderBottom:o===x$1?`2px solid ${Yn}`:"2px solid transparent",fontWeight:o===x$1?600:400},children:e.name},e.id))})]})})})})}var Jl={deprecated:`[XlsxEditor] \`experimentalWorkerOpen={false}\` selects the deprecated in-thread engine. Omit it and \`${Ua}\` to use the worker-owned async editor.`,"no-worker":"[XlsxEditor] `Worker` is not available in this environment; using the deprecated in-thread engine.","no-offscreen-canvas":"[XlsxEditor] `OffscreenCanvas` is not available in this environment; using the deprecated in-thread engine.","legacy-sync-api":`[XlsxEditor] \`${Ua}\` keeps the deprecated synchronous API on the in-thread engine, removed in 0.6.0. Omit it to use the async editor.`},si=Symbol.for("@betteroffice/xlsx-react/engine-warnings"),li=globalThis,ms=li[si]??(li[si]=new Set);function Lo(n){let r=Jl[n];ms.has(r)||(ms.add(r),console.warn(r));}function hs(n,r,l,c=()=>{}){async function y$1(I){return await n.flushPendingInput(),I()}let f=async I=>{l();try{let d=await I();return l(),d}catch(d){throw l(),d}},A=n.handle;return Wa({hydrated:true,failure:null,version:()=>f(()=>n.version()),readCells(I){let d=structuredClone(I);return f(()=>n.readCells(d))},findText(I){let d=structuredClone(I);return f(()=>n.findText(d))},validateEdits(I){let d=structuredClone(I);return f(()=>n.validateEdits(d))},applyEdits(I){let d=structuredClone(I);return f(()=>n.applyEdits(d))},save:()=>f(async()=>{let I;try{await n.flushPendingInput(),l();try{I=n.save();}catch(d){if(!(d instanceof br)||d.code!=="input-pending")throw d;await n.flushPendingInput(),l(),I=n.save();}}catch(d){throw d instanceof br?new w("input-failed"):d}return l(),c()?.(I),I}),whenHydrated:n.flushPendingInput,recoverySave:()=>y$1(()=>({bytes:n.save(),recovery:true})),commands:y(n.commands).guarded(l),collaboration:r?{clientId:A.clientId,encodeStateVector:()=>y$1(()=>A.encodeStateVector()),encodeStateAsUpdate(I){let d=I?.slice();return y$1(()=>A.encodeStateAsUpdate(d))},applyUpdate(I){let d=I.slice();return y$1(()=>A.applyUpdate(d))},onUpdate:I=>A.onUpdate(I)}:null,focus:n.focus,renderPng(I){let d=structuredClone(I);return y$1(()=>A.renderPng(d))},renderRangePng(I){let d=structuredClone(I);return y$1(()=>A.renderRangePng(d))},exportStructured(I){let d=structuredClone(I);return y$1(()=>A.exportStructured(d))},exportMarkdown(I,d){let b=structuredClone([I,d]);return y$1(()=>A.exportMarkdown(...b))},printDisplayList(...I){let d=structuredClone(I);return y$1(()=>A.printDisplayList(...d))}})}function Qn(n){return {ok:false,version:n.version(),failure:{code:"read-only",message:"The editor is read-only"}}}var br=class extends Error{constructor(l){super(l==="input-pending"?'Accepted input is still being written; await commands.execute("save", null)':"A cell entry could not be written; correct or discard it first");a(this,"code",l);this.name="XlsxSaveRefusedError";}},Gr=96,Yr=24,eo="#217346",ua=87,da=1024,fa="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",pa=1,ma=10,ha=250,ga=1e3,va={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};function ya(n,r,l){let c=[{op:"fillRect",x:0,y:0,w:n,h:r,color:"#ffffff"}],y=Math.ceil(n/Gr),f=Math.ceil(r/Yr);for(let A=0;A<=y;A++)c.push({op:"line",x1:A*Gr,y1:0,x2:A*Gr,y2:r,width:1,color:"#e0e0e0"});for(let A=0;A<=f;A++)c.push({op:"line",x1:0,y1:A*Yr,x2:n,y2:A*Yr,width:1,color:"#e0e0e0"});return c.push({op:"fillRect",x:0,y:0,w:n,h:Yr,color:"#f3f3f3"}),c.push({op:"fillRect",x:0,y:0,w:Gr,h:r,color:"#f3f3f3"}),c.push({op:"text",x:Gr+8,y:Yr+18,text:l,fontSize:14,color:"#202020",clip:{x:Gr,y:Yr,w:Gr*3,h:Yr},align:"left"}),{width:n,height:r,commands:c}}function bs(n,r,l){let c=new Blob([new Uint8Array(n)],{type:l}),y=URL.createObjectURL(c),f=document.createElement("a");f.href=y,f.download=r,document.body.appendChild(f),f.click(),f.remove(),URL.revokeObjectURL(y);}function ba(n){return `${(n??"workbook.xlsx").replace(/\.xlsx$/i,"")}.png`}function ui(n,r){return n.generation===r.generation&&n.view===r.view&&n.mutation>=r.mutation}function ws(n,r,l,c,y,f){return l?null:f==="start"?n:f==="center"?Math.max(0,n-Math.max(0,y-r)/2):n>=c&&n+r<=c+y?null:n<c||r>=y?n:Math.max(0,n+r-y)}function wa(n,r,l){let c=n.displayList({...l,x:0,y:0}).grid;return Ca$1(c,r.frozenRows,r.frozenCols,l)}function xa(n,r,l,c,y,f){let A=n.sheetInfo(),I=n.cellPosition(r,l,c),d=n.cellRect(r,l,c),b=A.frozenRows>0||A.frozenCols>0?wa(n,A,f):{width:0,height:0};return {x:ws(I.x,d.w,c<A.frozenCols,f.x,Math.max(0,f.width-b.width),y),y:ws(I.y,d.h,l<A.frozenRows,f.y,Math.max(0,f.height-b.height),y)}}function wn(n){return N(n.nativeEvent)!==null||O(n.target)}function xs(n,r){return typeof r=="string"?n.sheetInfo().sheetIds.indexOf(r):-1}function ks(n){return typeof n=="number"&&Number.isInteger(n)&&n>=0}function di(n,r,l,c){if(!ks(l)||!ks(c))return false;try{return n.cellPosition(r,l,c),!0}catch{return false}}var Cs={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},Ps={workspace:{position:"relative",display:"flex",flex:1,minWidth:0,minHeight:0},center:{position:"relative",display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0}},to={shell:{flex:"0 0 auto",minHeight:ua,padding:"4px 0 5px",borderBottom:`1px solid ${V.line}`,background:"#ffffff",color:V.ink,boxSizing:"border-box"},rail:{...W,margin:"0 8px",overflowX:"auto",overflowY:"hidden"},host:{flex:"0 0 auto"},proposals:{marginLeft:"auto",paddingLeft:6,flex:"0 0 auto"},count:{display:"inline-grid",placeItems:"center",minWidth:15,height:15,marginLeft:-3,padding:"0 4px",borderRadius:8,background:V.accent,color:V.accentInk,fontSize:10,fontWeight:700,lineHeight:1,boxSizing:"border-box"}};function jr(n){let[r,l]=useState(n),c=useRef(r),y=useCallback(f=>{c.current=typeof f=="function"?f(c.current):f,l(c.current);},[]);return [r,y,c]}function ka(n){let r=n.experimentalWorkerOpen===false,l=useMemo(()=>({}),[n.file,n.collaboration,r]),c=()=>({identity:l,reason:r?"deprecated":typeof Worker!="function"?"no-worker":typeof OffscreenCanvas!="function"?"no-offscreen-canvas":void 0}),[y,f]=useState(c),A=y.identity===l?y:c();return y!==A&&f(A),useEffect(()=>{A.reason&&Lo(A.reason);},[A.reason]),A.reason?jsx(Ca,{...n}):jsx(ii,{...n,backend:"peerless"})}function Ca(n){let r=useRef(n);r.current=n;let l=useRef(null),c=useCallback(y=>{l.current=y;let f=n.onReady?.(hs(y,n.collaboration!==void 0,()=>{if(l.current!==y)throw new w("document-replaced")},()=>r.current.onSave));return ()=>{l.current===y&&(l.current=null),f?.();}},[n.onReady,n.collaboration]);return jsx(Rs,{...n,experimentalWorkerOpen:false,onReady:c})}function Pa(n){let r=useMemo(()=>n.file instanceof ArrayBuffer?new Uint8Array(n.file):n.file,[n.file]),l={...n,file:r};return jsx(G,{i18n:n.i18n,children:l[Ua]===true?jsx(Ra,{...l}):jsx(ka,{...l})})}function Ra(n){useEffect(()=>{Lo("legacy-sync-api");},[]);let r=n.experimentalWorkerOpen,l=n.collaboration,c=useMemo(()=>({}),[n.file,l,r]),y=()=>({identity:c,reason:r===false?"deprecated":r!==true?"in-thread":typeof Worker!="function"?"no-worker":void 0,editor:!n.readOnly}),[f,A]=useState(y),I=f.identity===c?f:y(),d=I.editor||!n.readOnly;return (f!==I||f.editor!==d)&&A({...I,editor:d}),useEffect(()=>{I.reason&&I.reason!=="in-thread"&&Lo(I.reason);},[I.reason]),I.reason?jsx(Rs,{...n}):d?jsx(ii,{...n}):jsx(Qi,{...n})}function Rs({file:n,fileName:r,onSave:l$1,downloadOnSave:c$1,onSaveRequest:y,onChange:f$1,onDocumentChange:A$1,initialZoom:I$1,loadingIndicator:d,style:b,onError:X$1,collaboration:x$1,onReady:q$1,className:E$1,readOnly:W=false,toolbar:V,showToolbar:g=true,i18n:K,plugins:F$1,pluginGrants:M,onPluginError:j$1}){let{t:O}=H(),C$1=x$1!==void 0,v=x$1?.clientId,L=x$1?.initialUpdate,le=x$1?.onReplica,oe=x$1?.provider,[U]=useState(x),J=useRef(null),Oe=useRef(null),N=useRef(null),Ae=useRef(null),dt=useRef(()=>null),Ct=useRef(null),ot=useRef(null),[Se]=useState(()=>new A),it=useRef(null),Ue=useRef(null),xr=useRef(null),Be=useRef(false),vt=useRef(null),ze=useRef(null),ft=useRef(null),Ce=useRef(null),lt=useRef(false),yt=useRef(false),Mt=useRef(()=>{}),Pt=useRef(()=>true),kr=useRef(()=>false),pt=useRef(0),Tt=useRef(0),Rt=useRef(null),[u$1]=useState(()=>Mi({generation:()=>pt.current,seal:()=>Rt.current?.seal()??{},sync:()=>Rt.current?.sync(),write:t=>Rt.current?.write(t)??false,close:t=>Rt.current?.close(t),restore:t=>Rt.current?.restore(t)??false})),S$1=useRef(null),$=useRef(false),Z=useRef(null),xe=useRef([]),me=useRef(q$1);me.current=q$1;let Xe=useRef(X$1);Xe.current=X$1;let We=useRef(f$1);We.current=f$1;let He=useRef(A$1);He.current=A$1;let Q$1=useRef(null),_e=useCallback(t=>{let s=t.version();return s===Q$1.current?false:(Q$1.current=s,He.current?.({version:s}),true)},[]),Ze=useRef(W);Ze.current=W;let[ee,Ke,Ne]=jr(null),[Et,Re]=useState(null),[Cr,Te]=useState(null),[Qe,xn]=useState(null),[te,ro,Ie]=jr(null),[pe,$e]=useState(null),[At,kn]=useState(null),[p,Ot]=useState(null),[re,bt,Ge]=jr(u(I$1)),[St,at]=useState(0),[Fr,lr]=useState(false),[ke,wt,ye]=jr(null),[st,qe]=useState(null),[ue,Zt]=useState(null),[_,ar]=useState([]),It=useRef(null),Ht=()=>j(N.current,Pe.current,h(It.current?.sheet===Pe.current?It.current.ranges:void 0)),Le=useCallback(t=>{let s=typeof t=="function"?t(Ie.current):t;ro(s?k(s,j(N.current,Pe.current)):null);},[]),qr=useRef(void 0),Pr=useRef(void 0),[Rr,Lt,Do]=jr(null),Ye=useRef(null),[Fo,_t,qo]=jr([]),[Kt,Cn,Mo]=jr(false),[xt,Jr]=useState(null),[no,oo]=useState([]),[Er,Sr]=useState({}),he=ee?.activeSheet??0,Pe=useMemo(()=>({get current(){return Ne.current?.activeSheet??0}}),[Ne]),mt=useCallback((t,s,m,R)=>({generation:pt.current,sheet:Pe.current,row:s,col:m,value:R,source:t}),[]),Bt=useCallback(t=>{Le(selectionAt({row:t.row,col:t.col})),t.source==="cell"?$e({row:t.row,col:t.col,value:t.value}):Ot(t.value);},[]),ct=useCallback(t=>{if(u$1.draft)return;let s=u$1.rejected.find(m=>m.sheet===t&&m.generation===pt.current);s&&(u$1.setDraft(s),Bt(s));},[u$1,Bt]),ht=useCallback(()=>{u$1.setDraft(null),$e(null),Ot(null);},[u$1]),Zr=useCallback(()=>{Pt.current()&&(Le(null),wt(null),ht(),Lt(null),Ye.current=null,ct(Pe.current),U.refresh());},[ht,ct,Pe,U,Le,wt,Lt]),Xt=useCallback((t,s,m)=>{t.setActiveSheet(s),Ke(t.sheetInfo()),Le(m?structuredClone(m):null),wt(null),ht(),Lt(null),Ye.current=null,ct(s),Re(null),U.refresh();},[ht,ct,U]),Pn=useCallback((t,s)=>{let m=N.current;if(!m||!Number.isInteger(t))return false;try{let R=m.sheetInfo();if(t<0||t>=R.sheetNames.length)return !1;m.cellPosition(t,s.anchor.row,s.anchor.col);let D=m.cellPosition(t,s.focus.row,s.focus.col);return Pt.current()?(Xt(m,t,s),requestAnimationFrame(()=>{let k=J.current;k&&(k.scrollLeft=D.x*Ge.current,k.scrollTop=D.y*Ge.current);}),!0):!1}catch{return false}},[Xt]),Qt=useCallback((t,s,m,R,D)=>{let k=N.current,ie=pt.current;requestAnimationFrame(()=>{let ce=J.current;if(!(!ce||!k||!D()||N.current!==k||pt.current!==ie||Pe.current!==t))try{let ve=Ge.current,Me=Ne.current;Me&&Ke(pa$1(ce,Me,k.cellRect(t,s,m),ve));let Fe=xa(k,t,s,m,R,{x:ce.scrollLeft/ve,y:ce.scrollTop/ve,width:ce.clientWidth/ve,height:ce.clientHeight/ve});Fe.x!==null&&(ce.scrollLeft=Fe.x*ve),Fe.y!==null&&(ce.scrollTop=Fe.y*ve);}catch{}});},[Pe]),Dt=useRef(re);useEffect(()=>{if(Dt.current===re)return;let t=Dt.current;Dt.current=re;let s=Ie.current,m=J.current,R=N.current;if(!s||!m||!R)return;let{row:D,col:k}=s.focus;qa(m,R.cellRect(Pe.current,D,k),t)&&Qt(Pe.current,D,k,"nearest",()=>Ie.current===s);},[re,Qt]),useEffect(()=>{W&&(ht(),Lt(null),Ye.current=null,ze.current=null,qe(null),ft.current=null,Zt(null),Ce.current!=null&&clearTimeout(Ce.current),Ce.current=null);},[W]);let Qr=useMemo(()=>isPngExportAvailable(),[]),Mr=useMemo(()=>isProposalsAvailable(),[]),Gt=useCallback((t,s)=>N.current!==t?Promise.reject(new w("document-replaced")):u$1.runAfterPendingInput(()=>{if(N.current!==t)throw new w("document-replaced");return s()}),[u$1]),Rn=useCallback(async(t,s)=>{try{return {ok:!0,value:await Gt(t,s)}}catch(m){if(!(m instanceof w))throw m;return {ok:false,code:m.code==="document-replaced"||m.code==="editor-unavailable"?"document-replaced":"input-failed",error:m}}},[Gt]),Xr=useCallback((t,s,m,R=D=>D())=>{let D=m?.()??null;if(D)return D;if(Ze.current)return Qn(t);let k=R(()=>t.applyEdits(s));return k.ok&&k.applied&&(_e(t),We.current?.(),U.refresh()),k},[U,_e]),er=useCallback(()=>{let t=N.current;if(!t){_t([]);return}try{_t(t.listProposals());}catch{_t([]);}at(s=>s+1);},[]),cr=useRef({admit:Rn,applyBatch:Xr,navigator:null});cr.current.admit=Rn,cr.current.applyBatch=Xr;let[Or]=useState(()=>{let t=()=>{let s=cr.current.navigator;if(!s)throw new Error("The editor is not ready");return s};return {handle:()=>N.current,admit:(s,m)=>cr.current.admit(s,m),readOnlyRefusal:s=>Ze.current?Qn(s):null,applyEdits:(s,m,R,D)=>cr.current.applyBatch(s,m,R,D),commands:()=>U,navigator:{selectCells:(...s)=>t().selectCells(...s),scrollToCell:(...s)=>t().scrollToCell(...s)}}}),[Oo,io]=useState(null),Ho=useMemo(()=>{let t=ee?.sheetIds[he];return t===void 0?null:{sheetId:t,sheetIndex:he,cells:te?structuredClone(te):null,chartId:ke?.id??null}},[ee,he,te,ke]),zt=Na({plugins:F$1,pluginGrants:M,onPluginError:j$1,access:Or,commands:U,readOnly:W,handle:Oo,selection:Ho,canvasRef:Oe,t:O}),en=zt.beginLoad,Hr=zt.presentGrid,[En,Sn]=Fa(zt.managed);useEffect(()=>{if(pt.current+=1,en(),io(null),ht(),wt(null),ft.current=null,Zt(null),Ce.current!=null&&(clearTimeout(Ce.current),Ce.current=null),_t([]),Sr({}),Cn(false),Jr(null),ar([]),It.current=null,qr.current=void 0,Pr.current=void 0,Lt(null),Te(null),Ye.current=null,yt.current=false,Ct.current=null,!n){N.current=null,Ke(null),Le(null),Re(null);return}N.current=null,Ke(null),Le(null);let t=null,s=()=>{},m=()=>{},R=false,D=()=>{let k=m;m=()=>{};try{k();}catch{}};return initWasm().then(()=>{if(!R)try{t=openWorkbook(n,{collaborative:C$1,clientId:v}),L&&t.applyUpdate(L.slice()),N.current=t,Q$1.current=t.version(),s=t.onUpdate((ce,ve,{fromPeer:Me})=>{if(!(R||!t)){Se.changed(),Tt.current+=1;try{Ke(t.sheetInfo()),at(Fe=>Fe+1),Sr({}),er(),Re(null),_e(t)&&Me&&We.current?.();}catch(Fe){Re(Fe instanceof Error?Fe.message:String(Fe));}}}),yt.current=!0,Ke(t.sheetInfo()),Le(selectionAt({row:0,col:0})),Jr(t),Re(null),er();let k=t,ie=me.current?.({clearSelection:Zr,commands:U.store,handle:t,refreshProposals:er,focus:()=>J.current?.focus(),flushPendingInput:async()=>{if(N.current!==k)throw new w("document-replaced");if(Be.current)throw new w("gesture-active");if(await Gt(k,()=>{}),N.current!==k)throw new w("document-replaced")},getPositionAtPoint:(ce,ve)=>N.current===k?dt.current(ce,ve):null,save:()=>{if(N.current!==k)throw new w("document-replaced");if(kr.current())throw new br("input-failed");if(u$1.pending||S$1.current||ze.current||Be.current)throw new br("input-pending");if(!Pt.current())throw new br("input-failed");return k.save()},selectCells:Pn,version:()=>Gt(k,()=>k.version()),readCells:ce=>Gt(k,()=>k.readCells(ce)),findText:ce=>Gt(k,()=>k.findText(ce)),validateEdits:async ce=>Ze.current&&N.current===k?Qn(k):Gt(k,()=>Ze.current?Qn(k):k.validateEdits(ce)),applyEdits:async ce=>Ze.current&&N.current===k?Qn(k):Gt(k,()=>Xr(k,ce))});typeof ie=="function"&&(m=ie),io(k);}catch(k){D(),s(),s=()=>{},t?.dispose(),t=null,N.current=null,Ke(null),Le(null),Re(k instanceof Error?k.message:String(k));try{Xe.current?.(k instanceof Error?k:new Error(String(k)));}catch{}}},k=>{if(!R){N.current=null,Ke(null),Le(null),Re(k instanceof Error?k.message:String(k));try{Xe.current?.(k instanceof Error?k:new Error(String(k)));}catch{}}}),()=>{R=true,S$1.current?.settle(false),S$1.current=null,D(),s(),t?.dispose(),N.current=null,u$1.reset();}},[n,C$1,v,L,Zr,Gt,Xr,en,U,u$1,_e,er,Pn]),useEffect(()=>{if(!ee||!yt.current)return;let t=J.current;t&&(yt.current=false,t.scrollLeft=ee.initialScrollX*re,t.scrollTop=ee.initialScrollY*re);},[ee,re]),useEffect(()=>{if(!(!le||!xt))return le(xt),()=>le(null)},[le,xt]),useEffect(()=>{if(oo([]),!!oe)return oe.onAwareness(t=>oo([...t]))},[oe]),useEffect(()=>()=>oe?.setCursor(null),[oe]),useEffect(()=>{if(!oe)return;let t=ee?.sheetIds[he];if(!te||!t){oe.setCursor(null);return}let s=normalizeRange(te);oe.setCursor({sheet:t,anchor:te.range?{row:s.top,col:s.left}:{...te.anchor},head:te.range?{row:s.bottom,col:s.right}:{...te.focus}});},[oe,te,ee,he,St]);let Xn=useCallback(()=>{let t=J.current,s=Oe.current;if(!t||!s)return;let m=s.getContext("2d");if(!m)return;let R=window.devicePixelRatio||1,D=t.clientWidth,k=t.clientHeight;if(D===0||k===0)return;s.width=Math.round(D*R),s.height=Math.round(k*R),s.style.width=`${D}px`,s.style.height=`${k}px`;let ie=D/re,ce=k/re,ve={x:t.scrollLeft/re,y:t.scrollTop/re,width:ie,height:ce},Me=N.current,Fe;if(Me)try{Fe=Me.displayList(ve);}catch(sr){Ae.current=null,Ct.current=null,Hr(null),xn(null),Te(sr instanceof Error?sr.message:String(sr));return}else Fe=ya(ie,ce,O("editor.demoCellText"));let Nr=[],Mn=Fe.grid,fr=Mn?Da(Mn):null;if(Me&&fr)try{let sr=Me.cell(he,fr.top,fr.left).a1,Is=Me.cell(he,fr.bottom,fr.right).a1;Nr=Me.mergedRanges(he,`${sr}:${Is}`).slice(0,da);}catch{}paintDisplayList(m,Fe,R*re),Ae.current=Fe,Ct.current={frame:Fe,zoom:re,sheet:he,handle:Me};let rn=null;try{rn=Me?Me.version():null;}catch{}let uo=Ne.current?.sheetIds[he];if(Hr(rn!==null&&uo!==void 0?{frame:Fe,zoom:re,version:rn,sheetId:uo,viewport:ve}:null),Te(null),ar(Nr),It.current={sheet:he,ranges:Nr},xn(Fe),!Me)return;let On={generation:pt.current,mutation:Tt.current,view:`${he}:${re}`};Z.current=On;let fo=xe.current;xe.current=fo.filter(sr=>!ui(On,sr.mark));for(let sr of fo)ui(On,sr.mark)&&sr.resolve(true);},[he,Hr,O,re]);useEffect(()=>{let t=J.current;if(!t)return;let s=()=>{ot.current==null&&(ot.current=requestAnimationFrame(()=>{ot.current=null,Xn();}));};Xn(),t.addEventListener("scroll",s,{passive:true});let m=new ResizeObserver(s);return m.observe(t),()=>{t.removeEventListener("scroll",s),m.disconnect(),ot.current!=null&&(cancelAnimationFrame(ot.current),ot.current=null);}},[Xn,ee,Et,St]);let Wn=useCallback(()=>{let t={generation:pt.current,mutation:Tt.current,view:`${Pe.current}:${Ge.current}`},s=Z.current;return s&&ui(s,t)?Promise.resolve(true):new Promise(m=>{let R={mark:t,resolve:k=>{clearTimeout(D),m(k);}},D=setTimeout(()=>{xe.current=xe.current.filter(k=>k!==R),m(false);},ga);xe.current.push(R);})},[]);useEffect(()=>{let t=N.current;if(!t||!te||!ee){kn(null);return}try{kn(t.cell(he,te.focus.row,te.focus.col));}catch{kn(null);}},[te,ee,he,St]),useEffect(()=>{let t=()=>{Be.current=false,lr(false);};return window.addEventListener("mouseup",t),()=>window.removeEventListener("mouseup",t)},[]);let ur=useMemo(()=>!Qe||!ee?null:buildA11yGrid(Qe,te,ee.sheetNames[he]??"",{gridLabel:O("a11y.gridLabel"),rowHeaderLabel:O("a11y.rowHeaderLabel"),columnHeaderLabel:O("a11y.columnHeaderLabel"),cellLabel:O("a11y.cellLabel"),cellLabelSelected:O("a11y.cellLabelSelected"),emptyCellLabel:O("a11y.emptyCellLabel"),emptyCellLabelSelected:O("a11y.emptyCellLabelSelected")}),[Qe,te,ee,he,O]),ut=useCallback(()=>{J.current?.focus({preventScroll:true});},[]);useEffect(()=>{pe&&Ue.current?.focus({preventScroll:true});},[pe]);let Nt=useCallback(t=>{t.applied&&Se.changed(),Tt.current+=1,Ke(t.sheetInfo),at(s=>s+1),er(),t.applied&&(_e(N.current),We.current?.());},[er,Se,_e]);Rt.current={seal(){if(ze.current)return {refused:"gesture-active"};Mt.current();let t=S$1.current;return t?(t.source==="cell"?(lt.current=true,Ue.current?.blur(),lt.current=false):($.current=true,xr.current?.blur(),$.current=false),{composition:t.done}):{}},sync(){let t=u$1.draft,s=t?.source==="cell"?Ue.current:xr.current;t&&s&&s.value!==t.value&&u$1.setDraft({...t,value:s.value});},write(t){let s=N.current;if(!s)return false;if(Ze.current)return true;try{return s.cell(t.sheet,t.row,t.col).input!==t.value&&Nt(s.editCell(t.sheet,t.row,t.col,t.value)),!0}catch(m){return Re(m instanceof Error?m.message:String(m)),false}},close(t){if(t.source==="formula"){Ot(null);return}let s=document.activeElement===Ue.current;lt.current=true,Ue.current?.blur(),lt.current=false,$e(null),s&&ut();},restore(t){return t.sheet!==Pe.current?false:(Bt(t),true)}},kr.current=()=>u$1.rejected.some(t=>t.generation===pt.current),Pt.current=()=>N.current?(Mt.current(),ze.current=null,qe(null),lr(false),u$1.settle()):false;let Tn=useCallback(t=>{let s=N.current;if(!s)return null;let m=normalizeRange(t),R=s.cell(he,m.top,m.left).a1,D=s.cell(he,m.bottom,m.right).a1;return `${R}:${D}`},[he]),$t=useCallback(()=>oa(Ae.current,(J.current?.clientHeight??0)/re),[re]),je=useCallback((t,s)=>{let m=Oe.current,R=Ae.current?.grid;if(!m||!R)return null;let D=m.getBoundingClientRect();return cellAtPoint(R,(t-D.left)/re,(s-D.top)/re)},[re]),Wt=useCallback((t,s)=>{let m=Oe.current,R=Ct.current;if(!m||!R)return null;let D=m.getBoundingClientRect();return chartRegionAtPoint(R.frame.charts,(t-D.left)/R.zoom,(s-D.top)/R.zoom)},[]),Yt=useMemo(()=>ke?Qe?.charts?.find(t=>t.id===ke.id)??null:null,[Qe,ke]);useEffect(()=>{!ke||!Qe||Qe.charts?.some(t=>t.id===ke.id)||(Mt.current(),ze.current=null,qe(null),wt(null));},[Qe,ke]);let tr=useCallback((t,s,m)=>{let R=N.current;if(!R||W||s===0&&m===0)return;let D=he;u$1.input(()=>{if(!(N.current!==R||Ze.current))try{return Nt(R.moveChart(D,t,s,m)),!0}catch(k){return Re(k instanceof Error?k.message:String(k)),false}});},[he,Nt,W,u$1]),jt=useCallback(()=>{Ce.current!=null&&(clearTimeout(Ce.current),Ce.current=null);let t=ft.current;ft.current=null,Zt(null),t&&tr(t.id,t.dx,t.dy);},[tr]);Mt.current=jt;let An=useCallback((t,s,m)=>{let R=ft.current;R&&R.id!==t&&Mt.current();let D=ft.current??{dx:0,dy:0},k={id:t,dx:D.dx+s,dy:D.dy+m};ft.current=k,Zt({x:k.dx,y:k.dy}),Ce.current!=null&&clearTimeout(Ce.current),Ce.current=setTimeout(()=>{Ce.current=null;let ie=ft.current;ft.current=null,Zt(null),ie&&(ie.dx!==0||ie.dy!==0)&&In.current(ie.id,ie.dx,ie.dy);},ha);},[]),In=useRef(tr);In.current=tr,useEffect(()=>{let t=m=>{let R=ze.current;ze.current=null,qe(null),!(!R||m.button!==0)&&tr(R.id,(m.clientX-R.clientX)/re,(m.clientY-R.clientY)/re);},s=()=>{ze.current=null,qe(null),Mt.current();};return window.addEventListener("mouseup",t),window.addEventListener("blur",s),()=>{window.removeEventListener("mouseup",t),window.removeEventListener("blur",s);}},[tr,re]),useEffect(()=>()=>{Ce.current!=null&&clearTimeout(Ce.current),Ce.current=null,ft.current=null;},[]);let Br=useCallback(t=>{let s=N.current,m=Ie.current;if(!s||!m||W)return;let{row:R,col:D}=i(m.focus,Ht()),k=t??"";if(t===void 0)try{k=s.cell(Pe.current,R,D).input;}catch{k="";}$e({row:R,col:D,value:k}),u$1.setDraft(mt("cell",R,D,k));},[Ie,Pe,W,u$1,mt]),dr=useCallback(t=>{if(!N.current||!pe||W)return;let{row:s,col:m,value:R}=pe,D=u$1.draft,k=D?.source==="cell"&&D.row===s&&D.col===m?D:mt("cell",s,m,R);if(!u$1.submit(k))return;lt.current=true,$e(null);let ie=selectionAt({row:s,col:m});Le(t?moveFocus(ie,t,{limits:$t(),hidden:f(Ae.current?.grid),merges:Ht()}):ie),ut(),ct(Pe.current);},[pe,$t,ut,W,u$1,mt,ct]),so=useCallback(()=>{lt.current=true;let t=u$1.draft;t?.source==="cell"&&u$1.discard(t),u$1.setDraft(null),$e(null),ut(),ct(Pe.current);},[ut,u$1,ct]),rr=useCallback(()=>{let t=N.current,s=Ie.current;return !t||!s?null:{handle:t,sheet:Pe.current,range:normalizeRange(s)}},[Ie,Pe]),zr=useCallback(({handle:t,sheet:s,range:m})=>{if(!(N.current!==t||Ze.current))try{let R=e(m,()=>t.selectionData(s,0,0,"usedRange").usedRange);if(!R){Re("Clear exceeds the cell limit");return}return Nt(t.editCells(s,R)),!0}catch(R){return Re(R instanceof Error?R.message:String(R)),false}},[Nt]),tn=useCallback(()=>{let t=rr();t&&!W&&u$1.input(()=>zr(t));},[rr,zr,W,u$1]),nr=useCallback(async({handle:t,sheet:s,range:m},R=false)=>{let D=Se.begin();try{let k=c(m,()=>t.selectionData(s,0,0,"usedRange").usedRange),ie=t.cell(s,k.top,k.left).a1,ce=t.cell(s,k.bottom,k.right).a1,ve=t.rangeCells(s,`${ie}:${ce}`),Me=!R&&typeof ClipboardItem=="function"&&typeof navigator.clipboard.write=="function";return Me?await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([toTsv(ve)],{type:"text/plain"}),"text/html":C(D,toTsv(ve))})]):await navigator.clipboard.writeText(toTsv(ve)),Me&&N.current===t&&Se.capture(D,{owner:t,sheet:s,range:k,cells:ve,cut:!1},Me),!0}catch(k){return Re(k instanceof Error?k.message:String(k)),false}},[Se]),Wr=useCallback(async()=>{let t=rr();t&&await nr(t);},[rr,nr]),lo=useCallback(()=>{let t=rr();if(!t)return;let s=Se.escaped,m=nr(t,true);W||u$1.input(async()=>Se.escaped===s&&await m?zr(t):void 0);},[rr,Se,nr,zr,W,u$1]),Ln=useCallback(()=>{let t=N.current,s=Ie.current,m=s&&k(s,j(t,Pe.current));if(!t||!m||W)return Promise.resolve();m!==s&&Le(m);let R=Se.current,D=(async()=>{try{return await F()}catch(ce){return Re(ce instanceof Error?ce.message:String(ce)),null}})(),k$1=Pe.current,ie=normalizeRange(m);return u$1.input(async()=>{let ce=await D;if(!(ce===null||Ze.current||N.current!==t))try{let{text:ve,html:Me}=ce,Fe=Se.paste(t,ve,ie,Me,k$1,R),Nr=Fe?[]:E(ve);if(!Fe&&Nr.length===0)return;let Mn=Fe?.edits??[],fr=1;return Fe||Nr.forEach((rn,uo)=>{fr=Math.max(fr,rn.length),rn.forEach((On,fo)=>Mn.push({row:ie.top+uo,col:ie.left+fo,input:On}));}),Nt(t.editCells(k$1,Mn)),Ie.current===m&&Pe.current===k$1&&Le({anchor:{row:ie.top,col:ie.left},focus:{row:Fe?.bottom??ie.top+Nr.length-1,col:Fe?.right??ie.left+fr-1}}),!0}catch(ve){return Re(ve instanceof Error?ve.message:String(ve)),false}})},[Ie,Pe,Nt,W,u$1,Le,Se]);useEffect(()=>{let t=N.current;if(!t||!te||!Rr||Fr||W)return;let s=normalizeRange(te);if(`${he}:${s.top}:${s.left}:${s.bottom}:${s.right}`===Ye.current)return;let R=Tn(te);if(!R)return;let D=he,k=Rr;Lt(null),Ye.current=null,u$1.input(()=>{if(!(N.current!==t||Ze.current))try{return Nt(t.applyFormat(D,R,k)),ut(),!0}catch(ie){return Re(ie instanceof Error?ie.message:String(ie)),false}});},[te,Rr,Fr,he,Tn,Nt,ut,W,u$1]);let Dn=useCallback(t=>{l$1&&l$1(t),(c$1??!l$1)&&bs(t,r??"workbook.xlsx",fa);},[l$1,r,c$1]);dt.current=(t,s)=>{let m=Ct.current;return !m?.handle||m.handle!==N.current?null:na(m.frame,m.sheet,Oe.current,t,s)};let e$1=useCallback(()=>{let t=N.current,s=J.current;if(!t||!s)throw new Error("the workbook is not open");let m=t.renderPng({x:s.scrollLeft/re,y:s.scrollTop/re,width:s.clientWidth/re,height:s.clientHeight/re});bs(m,ba(r),"image/png");},[r,re]),o=useCallback(t=>{let s=u$1.draft;!N.current||s?.source!=="formula"||W||u$1.submit(s)&&(Ot(null),t&&Le(m=>m&&moveFocus(m,t,{limits:$t(),hidden:f(Ae.current?.grid),merges:Ht()})),ct(Pe.current));},[u$1,$t,W,ct]),i$1=useCallback(t=>{let s=N.current;if(!s||!te||!ee||pe||wn(t)||q(t))return;let m=t.metaKey||t.ctrlKey,R=t.key.toLowerCase();if(ke){if(t.key==="Escape"){ze.current=null,qe(null),ft.current=null,Zt(null),Ce.current!=null&&(clearTimeout(Ce.current),Ce.current=null),wt(null),t.preventDefault();return}let ce=m?void 0:va[t.key];if(ce){let ve=pa*(t.shiftKey?ma:1);!W&&ke.movable&&An(ke.id,ce[0]*ve,ce[1]*ve),t.preventDefault();}return}if(m){if(R==="c"){Wr(),t.preventDefault();return}if(R==="v"){Ln(),t.preventDefault();return}if(R==="x"){lo(),t.preventDefault();return}}let D=l(t),k;try{k=D?s.selectionData(Pe.current,te.focus.row,te.focus.col,D==="region"?void 0:D):void 0;}catch(ce){if(D!=="usedRange"&&D!=="rowEnd")throw ce;t.preventDefault();return}let ie=selectionKeyReducer(te,{key:t.key,shiftKey:t.shiftKey,metaKey:t.metaKey,ctrlKey:t.ctrlKey,altKey:t.altKey},$t(),k,f(Ae.current?.grid),Ht());switch(ie.type){case "move":Le(ie.selection),Qt(Pe.current,ie.selection.focus.row,ie.selection.focus.col,"nearest",()=>Ie.current===ie.selection),t.preventDefault();break;case "startEdit":Br(ie.initialInput),t.preventDefault();break;case "clear":tn(),t.preventDefault();break;}},[te,ee,pe,$t,Wr,Ln,lo,Br,tn,ke,An,Qt,W]),a=useCallback(t=>{if(wn(t))return;let s=pe!=null;if(s&&Ue.current?.contains(t.target))return;ze.current=null,Mt.current();let m=Wt(t.clientX,t.clientY);if(m){s&&dr(),wt({id:m.id,movable:!W&&m.movable}),!W&&m.movable&&t.button===0&&(ze.current={id:m.id,clientX:t.clientX,clientY:t.clientY}),qe(null),vt.current=null,ut(),t.preventDefault();return}if(wt(null),qe(null),!te)return;let R=je(t.clientX,t.clientY);R&&(s&&dr(),t.shiftKey?Le(D=>D&&extendTo(D,R,$t())):Le(selectionAt(i(R,Ht()))),vt.current=s?null:R,Be.current=true,lr(true),ut());},[pe,te,je,Wt,$t,ut,dr,W]),h$1=useCallback(t=>{let s=ze.current;if(wn(t)){s||(t.currentTarget.style.cursor="default",t.currentTarget.title="");return}if(s){if(t.buttons===0){ze.current=null,qe(null);return}t.currentTarget.style.cursor="move",t.currentTarget.title="",qe({x:t.clientX-s.clientX,y:t.clientY-s.clientY});return}let m=je(t.clientX,t.clientY);if(!m){Be.current||(t.currentTarget.style.cursor="default",t.currentTarget.title="");return}if(!Be.current){let R=Wt(t.clientX,t.clientY);if(R){t.currentTarget.style.cursor=!W&&R.movable?"move":"pointer",t.currentTarget.title="";return}let D=Ae.current?hyperlinkAtCell(Ae.current,m.row,m.col):null;t.currentTarget.style.cursor=D?"pointer":"default",t.currentTarget.title=D?.tooltip??"";return}Le(R=>R&&extendTo(R,m,$t()));},[je,Wt,$t,W]),w$1=useCallback(t=>{let s=N.current,m=Ae.current;if(!s||!m||!ee)return false;let R=hyperlinkAtCell(m,t.row,t.col);if(!R)return false;let D=safeExternalHyperlink(R);if(D)return window.open(D,"_blank","noopener,noreferrer"),true;if(!R.location)return true;let k=ee.sheetNames[he]??"",ie=parseHyperlinkLocation(R.location,k);if(!ie)return true;let ce=ee.sheetNames.findIndex(ve=>ve.toLowerCase()===ie.sheetName.toLowerCase());if(ce<0)return true;try{s.setActiveSheet(ce);let ve=s.cellPosition(ce,ie.row,ie.col);Ke(s.sheetInfo()),requestAnimationFrame(()=>{let Me=J.current;Me&&(Me.scrollLeft=ve.x*re,Me.scrollTop=ve.y*re);}),Le(selectionAt({row:ie.row,col:ie.col})),ht(),Lt(null),Ye.current=null,Re(null);}catch(ve){Re(ve instanceof Error?ve.message:String(ve));}return true},[he,ee,re]),P$1=useCallback(t=>{if(wn(t))return;if(pe){vt.current=null;return}let s=je(t.clientX,t.clientY),m=vt.current;vt.current=null,!(!s||!m||s.row!==m.row||s.col!==m.col)&&w$1(s);},[w$1,pe,je]),B=useCallback(t=>{if(pe||wn(t)||Wt(t.clientX,t.clientY))return;let s=je(t.clientX,t.clientY);s&&Ae.current&&hyperlinkAtCell(Ae.current,s.row,s.col)||te&&Br();},[pe,Br,je,Wt,te]),z=useCallback(t=>{t.currentTarget.style.cursor="default",t.currentTarget.title="";},[]),T=Qe?.grid,H$1=te?ua$1(normalizeRange(te),_):null,G=te?ua$1({top:te.focus.row,left:te.focus.col,bottom:te.focus.row,right:te.focus.col},_):null,se=T&&H$1?rangeRect(T,H$1):null,be=T&&G?rangeRect(T,G):null,ge=T&&pe?cellRect(T,pe.row,pe.col):null,Je=se?ta(se,re):null,De=be?ta(be,re):null,et=ge?ta(ge,re):null,or=Yt?ta(Yt.rect,re):null,Fn=ee?ee.contentWidth*re:void 0,ir=ee?ee.contentHeight*re:void 0,qn=p??At?.input??"",ao=t=>{let s=N.current;if(s&&Pt.current())try{s.setActiveSheet(t),yt.current=!0,Le(selectionAt({row:0,col:0})),wt(null),ht(),Lt(null),Ye.current=null,Ke(s.sheetInfo()),ct(t),U.refresh();}catch(m){Re(m instanceof Error?m.message:String(m));}};cr.current.navigator={selectCells(t,s,m,R){let D=xs(t,s?.sheetId),k=s?.selection;return D<0||!di(t,D,k?.anchor?.row,k?.anchor?.col)||!di(t,D,k?.focus?.row,k?.focus?.col)?"missing-target":(Xt(t,D,k),Qt(D,k.focus.row,k.focus.col,"nearest",R),m&&ut(),null)},scrollToCell(t,s,m,R){let D=xs(t,s?.sheetId);return D<0||!di(t,D,s.row,s.col)?"missing-target":(D!==Pe.current&&Xt(t,D,null),Qt(D,s.row,s.col,m,R),null)}};let Es={requestSave:Q({document:()=>N.current,onSaveRequest:y,fail:t=>Re(t instanceof Error?t.message:String(t))}),handle:()=>N.current,status:()=>N.current?"ready":n&&!Et?"loading":"empty",readOnly:()=>Ze.current,collaborative:()=>C$1,mutation:()=>Tt.current,generation:()=>pt.current,view:()=>({sheet:Pe.current,selection:Ie.current,chartSelected:ye.current!==null,zoom:Ge.current,capturedFormat:Do.current,borderStyle:qr.current,borderColor:Pr.current,proposals:qo.current,proposalsAvailable:Mr,proposalsPanelOpen:Mo.current,pngExport:Qr}),coordinator:u$1,i18n:()=>K,translate:O,apply:Nt,fail:t=>Re(t instanceof Error?t.message:String(t)),setZoom:bt,setProposalsPanelOpen:Cn,setCapturedFormat:(t,s)=>{Lt(t),Ye.current=s;},setBorderStyle:t=>{qr.current=t;},setBorderColor:t=>{Pr.current=t;},markStale:(t,s)=>Sr(({[t]:m,...R})=>s?{...R,[t]:s}:R),refreshProposals:er,deliver:Dn,exportPng:e$1,afterPaint:Wn,focusGrid:ut};zi(U,Es),P(U,it);let fi=t=>{let s=()=>{},m=new Promise(R=>{s=D=>setTimeout(()=>R(D),0);});S$1.current={source:t,done:m,settle:s};},pi=()=>{S$1.current?.settle(true),S$1.current=null;},co=useCallback(t=>{let s=S$1.current;s?.source===t&&(s.settle(false),S$1.current=null);},[]),Ss=useCallback(t=>{Ue.current=t,t||co("cell");},[co]),Xs=useCallback(t=>{xr.current=t,t||co("formula");},[co]),mi=!W&&te!==null&&ke===null,Ws={onNavigate:t=>{Pn(Pe.current,selectionAt(t)),ut();},a1:At?.a1??"",value:qn,disabled:!ee||!te,readOnly:!mi,inputRef:Xs,onChange:t=>{let s=Ie.current;if(!mi||Ze.current||!s||ye.current)return;Ot(t);let m=i(s.focus,Ht());u$1.setDraft(mt("formula",m.row,m.col,t));},onCommit:t=>{o(t),ut();},onCancel:()=>{let t=u$1.draft;t?.source==="formula"&&(u$1.discard(t),u$1.setDraft(null)),Ot(null),ut(),ct(he);},onBlur:()=>{$.current||o();},onCompositionStart:()=>fi("formula"),onCompositionEnd:pi},Ts=jsxs(ma$1,{mode:"commands",children:[jsx(ma$1.Toolbar,{}),jsxs("div",{style:to.rail,role:"group","aria-label":O("toolbar.formulaBarLabel"),children:[jsx(ma$1.FormulaBar,{}),jsx("div",{style:X,"aria-hidden":"true"}),jsx(va$1,{peers:no,sheetIds:ee?.sheetIds??[],sheetNames:ee?.sheetNames??[],activeSheet:he}),Mr&&jsx("div",{style:to.proposals,children:jsx(Ea,{})})]})]}),hi=g?V===void 0?W?null:Ts:V:null,Bo=t=>zt.managed?jsx(Ga,{host:zt.host,placement:t,activations:zt.activations.filter(s=>s.plugin.panel?.placement===t),available:Sn}):null,As=jsxs("div",{ref:it,className:E$1,role:"application","aria-label":O("editor.appLabel"),onKeyDownCapture:t=>{!wn(t)&&t.key==="Escape"&&Se.escape();},style:{position:"relative",display:"flex",flexDirection:"column",width:"100%",height:"100%",minWidth:0,color:"#202124",background:"#ffffff",fontFamily:"ui-sans-serif, system-ui, sans-serif",...b},children:[n&&!N.current&&!Et&&d,hi!=null&&jsx("div",{"data-testid":"xlsx-toolbar",style:V===void 0?to.shell:to.host,children:hi}),jsxs("div",{ref:En,"data-testid":"xlsx-workspace",style:Ps.workspace,children:[Bo("left"),jsxs("div",{style:Ps.center,children:[Mr&&Kt&&jsx(xa$1,{proposals:Fo,staleFor:Er,style:{top:4,right:8,width:"min(320px, calc(100% - 16px))",maxHeight:"min(420px, calc(100% - 12px))"}}),jsxs("div",{ref:J,"data-testid":"xlsx-scroll",tabIndex:0,onKeyDown:i$1,onMouseDown:a,onMouseMove:h$1,onMouseLeave:z,onClick:P$1,onDoubleClick:B,style:{position:"relative",flex:1,overflow:"auto",minHeight:0,outline:"none"},children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:Fn??"100%",height:ir??"100%"}}),jsxs("div",{style:{position:"sticky",top:0,left:0,width:0,height:0},children:[jsx("canvas",{ref:Oe,style:{display:"block",position:"absolute",top:0,left:0}}),zt.managed&&jsx(Ba,{host:zt.host,activations:zt.activations,layerRef:zt.overlayLayerRef,width:(Qe?.width??0)*re,height:(Qe?.height??0)*re}),jsxs("div",{"data-testid":"xlsx-overlay-host",style:{position:"absolute",top:0,left:0,width:0,height:0,pointerEvents:"none"},children:[Je&&!ke&&jsx("div",{"data-testid":"xlsx-selection",style:{position:"absolute",left:Je.x,top:Je.y,width:Je.w,height:Je.h,boxSizing:"border-box",border:`1px solid ${eo}`,background:"rgba(33, 115, 70, 0.12)"}}),or&&jsx("div",{"data-testid":"xlsx-chart-selection","data-chart-id":ke?.id,"aria-hidden":true,style:{position:"absolute",left:or.x+(st?.x??0)+(ue?.x??0)*re,top:or.y+(st?.y??0)+(ue?.y??0)*re,width:or.w,height:or.h,boxSizing:"border-box",border:`2px solid ${eo}`,boxShadow:"0 1px 6px rgba(0, 0, 0, 0.25)",background:st?"rgba(33, 115, 70, 0.08)":"transparent"}}),De&&!ke&&!pe&&jsx("div",{style:{position:"absolute",left:De.x,top:De.y,width:De.w,height:De.h,boxSizing:"border-box",border:`2px solid ${eo}`}}),jsx(wa$1,{peers:no,grid:T,sheetIds:ee?.sheetIds??[],activeSheet:he,zoom:re,mergedRanges:_}),!W&&pe&&et&&jsx("input",{ref:Ss,"data-testid":"xlsx-cell-editor",value:pe.value,onChange:t=>{let s=t.target.value;$e(m=>m&&{...m,value:s}),pe&&u$1.setDraft(mt("cell",pe.row,pe.col,s));},onCompositionStart:()=>fi("cell"),onCompositionEnd:pi,onKeyDown:t=>{q(t)||t.stopPropagation(),!(t.nativeEvent.isComposing||t.keyCode===229)&&(t.key==="Enter"?(dr(t.shiftKey?"up":"down"),t.preventDefault()):t.key==="Tab"?(dr(t.shiftKey?"left":"right"),t.preventDefault()):t.key==="Escape"&&(so(),t.preventDefault()));},onBlur:()=>{if(lt.current){lt.current=false;return}dr();},style:{position:"absolute",left:et.x,top:et.y,width:et.w,height:et.h,boxSizing:"border-box",border:`2px solid ${eo}`,padding:"0 3px",font:`${13*re}px system-ui, sans-serif`,background:"#ffffff",pointerEvents:"auto",outline:"none"}})]})]})]}),Bo("bottom")]}),Bo("right")]}),ur&&jsxs(Fragment,{children:[jsxs("div",{style:Cs,role:"grid","aria-label":ur.label,children:[jsxs("div",{role:"row",children:[jsx("span",{role:"columnheader"}),ur.columnHeaders.map(t=>jsx("span",{role:"columnheader",children:t.label},t.col))]}),ur.rows.map(t=>jsxs("div",{role:"row",children:[jsx("span",{role:"rowheader",children:t.header}),t.cells.map(s=>jsx("span",{role:"gridcell","aria-selected":s.selected,children:s.label},s.col))]},t.row))]}),ur.charts.map((t,s)=>jsx("div",{style:Cs,role:"img","aria-label":t.label},`${s}:${t.label}`))]}),Cr&&jsx("div",{"data-testid":"xlsx-render-error",role:"alert",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",padding:16,textAlign:"center",color:"#b00020",background:"#ffffff"},children:Cr}),Et&&jsx(ya$1,{kind:"open",details:Et}),ee&&ee.sheetNames.length>0&&jsx("div",{"data-testid":"xlsx-sheet-tabs",role:"tablist","aria-label":O("editor.sheetTabsLabel"),style:{display:"flex",gap:2,padding:"4px 6px",borderTop:"1px solid #e0e0e0",background:"#fafafa",overflowX:"auto"},children:ee.sheetNames.map((t,s)=>{let m=s===ee.activeSheet;return jsx("button",{role:"tab","aria-selected":m,onClick:()=>ao(s),style:{border:"none",padding:"4px 12px",cursor:"pointer",borderBottom:m?`2px solid ${eo}`:"2px solid transparent",fontWeight:m?600:400,background:m?"#ffffff":"transparent"},children:t},s)})})]});return jsx(I.Provider,{value:U.store,children:jsx(S.Provider,{value:true,children:jsx(Y.Provider,{value:Ws,children:As})})})}function Ea(){let n=M("proposalsPanel"),r=n.state.value??0;return jsxs($,{testId:"xlsx-proposals-button",onClick:()=>{n.execute();},disabled:!n.state.enabled,description:n.state.enabled?void 0:n.state.disabledReason.message,active:n.state.active===true,toggle:true,ariaExpanded:n.state.active===true,title:n.label,style:{width:r>0?42:28},children:[jsx(_,{name:"proposals",size:18}),r>0&&jsx("span",{"data-testid":"xlsx-proposals-count",style:to.count,children:r})]})}export{Pa as XlsxEditor,br as XlsxSaveRefusedError,Zn as XlsxWorkerEditorChunkLoadError};
|
|
1
|
+
import {a as a$1}from'./chunk-BZJYJJ6T.js';export{a as XlsxSaveRefusedError}from'./chunk-BZSN2GH3.js';import {a as a$2}from'./chunk-UQEPJKDK.js';export{b as XlsxPeerNotReadyError,c as XlsxWorkerEditorCollaborationError,d as XlsxWorkerSessionFailedError}from'./chunk-UQEPJKDK.js';export{a as XlsxAsyncApiSyncAccessError}from'./chunk-QQHWSDLQ.js';import {b,na,d}from'./chunk-NLAF4WIP.js';export{ja as EditorToolbar,P as EditorToolbarContext,b as LocaleProvider,ia as Toolbar,Z as ToolbarButton,fa as ToolbarCommand,da as ToolbarCommandButton,ea as ToolbarCommandSelect,aa as ToolbarDropdown,_ as ToolbarGroup,ba as ToolbarMenuItem,ca as ToolbarMenuSeparator,ha as ToolbarOverflow,$ as ToolbarSeparator,u as XlsxCommandAdmissionError,H as XlsxCommandProvider,ga as XlsxPluginToolbar,ia as XlsxToolbar,ka as defineXlsxPlugin,T as useEditorToolbar,c as useTranslation,K as useXlsxCommand,J as useXlsxCommandState,I as useXlsxCommands}from'./chunk-NLAF4WIP.js';import'./chunk-WTQ7SZBY.js';import {a}from'./chunk-O2XFH626.js';import {useMemo,useState,lazy,useEffect,Component,Suspense,useRef}from'react';import {jsx}from'react/jsx-runtime';var n=class extends Error{constructor(o){super("Failed to load the editor code. Reload the page to retry.");a(this,"cause",o);a(this,"code","chunk-load-failed");this.name="XlsxWorkerEditorChunkLoadError";}};var A={legacy:()=>import('./chunk-B27RY7VE.js').then(r=>({default:r.LegacyXlsxEditor})),inThread:()=>import('./chunk-DRA7WYKM.js').then(r=>({default:r.XlsxAsyncInThreadSession}))},pr=()=>globalThis.location?.reload(),E=class extends Component{constructor(){super(...arguments);a(this,"state",{error:null});a(this,"reported",null);}static getDerivedStateFromError(o){return {error:o instanceof Error?o:new Error(String(o))}}componentDidCatch(){let o=this.state.error;if(!(!o||this.reported===o)){this.reported=o;try{this.props.onError?.(o);}catch{}}}render(){let{error:o}=this.state,{file:s,loadingIndicator:i,className:d$1,style:t,children:x}=this.props,p=o instanceof n;return o?jsx(d,{kind:p?"load":"open",details:o.message,onReload:p?pr:void 0,className:d$1,style:{position:"relative",width:"100%",height:"100%",...t}}):jsx(Suspense,{fallback:s?i??null:null,children:x})}};function L(r){throw new n(r)}function v(r){let[e]=useState(()=>lazy(()=>Promise.resolve().then(A.legacy).catch(L)));return jsx(E,{...r,children:jsx(e,{...r})})}function R(r){let[e]=useState(()=>lazy(()=>Promise.resolve().then(A.inThread).catch(L)));return jsx(E,{...r,children:jsx(e,{...r})})}var f=new WeakMap;function ur(r,e){let o=f.get(r),s=o?{Component:o}:{loading:true},[i,d]=useState(()=>({load:r,chunk:s})),t=useRef(null);return useEffect(()=>{if(o)return;let x=true;if(!t.current||t.current.load!==r){let a;try{a=r();}catch(B){a=Promise.reject(B);}t.current={load:r,promise:a};}let p=t.current;return p.promise.then(a=>{!x||t.current!==p||(f.set(r,a.XlsxPeerlessWorkerEditor),d({load:r,chunk:{Component:a.XlsxPeerlessWorkerEditor}}));}).catch(a=>{!x||t.current!==p||(f.delete(r),d({load:r,chunk:{error:new e(a)}}));}),()=>{x=false;}},[r,e]),o?{Component:o}:i.load===r?i.chunk:{loading:true}}function w({load:r,ErrorType:e,editorProps:o}){let s=ur(r,e);if("error"in s)throw s.error;return "Component"in s?jsx(s.Component,{...o}):o.file?o.loadingIndicator??null:null}var Er={load:()=>import('./chunk-RDV7BGSK.js')},y=false;function N(){y||(y=true,import('./chunk-RDV7BGSK.js').catch(()=>{y=false;}));}var fr=()=>globalThis.location?.reload();function yr({error:r,className:e,style:o}){let s=r instanceof n;return jsx(d,{kind:s?"load":"open",details:r.message,onReload:s?fr:void 0,className:e,style:{position:"relative",width:"100%",height:"100%",...o}})}var h=class extends Component{constructor(){super(...arguments);a(this,"state",{error:null});a(this,"reported",null);}static getDerivedStateFromError(o){return {error:a$2(o)}}componentDidCatch(){let o=this.state.error;if(!(!o||this.reported===o)){this.reported=o;try{this.props.onError?.(o);}catch{}}}render(){return this.state.error?jsx(yr,{error:this.state.error,className:this.props.className,style:this.props.style}):this.props.children}};function F(r){return jsx(b,{i18n:r.i18n,children:jsx(h,{onError:r.onError,className:r.className,style:r.style,children:jsx(w,{load:Er.load,ErrorType:n,editorProps:r})})})}function kr(r){let e=r.experimentalWorkerOpen===false,o=useMemo(()=>({}),[r.file,r.collaboration,e]),s=()=>({identity:o,reason:e?"deprecated":typeof Worker!="function"?"no-worker":typeof OffscreenCanvas!="function"?"no-offscreen-canvas":void 0}),[i,d]=useState(s),t=i.identity===o?i:s();return i!==t&&d(t),useEffect(()=>{t.reason&&a$1(t.reason);},[t.reason]),t.reason||N(),t.reason?jsx(R,{...r}):jsx(F,{...r,backend:"peerless"})}function Cr(r){let e=useMemo(()=>r.file instanceof ArrayBuffer?new Uint8Array(r.file):r.file,[r.file]),o={...r,file:e};return jsx(b,{i18n:r.i18n,children:o[na]===true?jsx(v,{...o}):jsx(kr,{...o})})}export{Cr as XlsxEditor,n as XlsxWorkerEditorChunkLoadError};
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A chord such as `Mod+Shift+V`. `Mod` is Cmd on macOS and Ctrl elsewhere; `Ctrl` is the physical
|
|
3
|
+
* Control key on macOS and the same as `Mod` elsewhere.
|
|
4
|
+
* @experimental
|
|
5
|
+
*/
|
|
6
|
+
type ShortcutChord = string;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* What a host sets for one shortcut id: chords that replace the defaults, `null` to disable it,
|
|
10
|
+
* or a per-platform form where an absent platform keeps its default.
|
|
11
|
+
* @experimental
|
|
12
|
+
*/
|
|
13
|
+
type ShortcutBinding = ShortcutChord | readonly ShortcutChord[] | null | {
|
|
14
|
+
mac?: ShortcutChord | readonly ShortcutChord[] | null;
|
|
15
|
+
other?: ShortcutChord | readonly ShortcutChord[] | null;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A host binding the editor changed or refused. `displaced-default` is informational: the host
|
|
19
|
+
* chord `chord` of `id` took over the default of `displaced`.
|
|
20
|
+
* @experimental
|
|
21
|
+
*/
|
|
22
|
+
interface ShortcutIssue {
|
|
23
|
+
code: 'unknown-id' | 'invalid-chord' | 'reserved-chord' | 'duplicate-chord' | 'displaced-default';
|
|
24
|
+
id: string;
|
|
25
|
+
chord?: string;
|
|
26
|
+
/** The other shortcut id involved, for `duplicate-chord` and `displaced-default`. */
|
|
27
|
+
other?: string;
|
|
28
|
+
}
|
|
29
|
+
interface ResolvedShortcuts {
|
|
30
|
+
/** Effective canonical chords by id; an id without chords is absent or empty. */
|
|
31
|
+
chords: ReadonlyMap<string, readonly string[]>;
|
|
32
|
+
/** The id each effective canonical chord runs. */
|
|
33
|
+
owners: ReadonlyMap<string, string>;
|
|
34
|
+
issues: readonly ShortcutIssue[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type NumberFormat = 'automatic' | 'plainText' | 'number' | 'percent' | 'scientific' | 'currency' | 'date' | 'time' | 'custom';
|
|
38
|
+
type BorderPreset = 'all' | 'inner' | 'horizontal' | 'vertical' | 'outer' | 'left' | 'top' | 'right' | 'bottom' | 'none';
|
|
39
|
+
type BorderStyle = 'solid' | 'dashed' | 'dotted' | 'double';
|
|
40
|
+
type HorizontalAlignment = 'left' | 'center' | 'right';
|
|
41
|
+
type VerticalAlignment = 'top' | 'middle' | 'bottom';
|
|
42
|
+
type TextWrapping = 'overflow' | 'wrap' | 'clip';
|
|
43
|
+
type MergeAction = 'all' | 'horizontal' | 'vertical' | 'unmerge';
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Arguments of every XLSX editor command, keyed by command id.
|
|
47
|
+
* @experimental
|
|
48
|
+
*/
|
|
49
|
+
interface XlsxCommandArgs {
|
|
50
|
+
bold: null;
|
|
51
|
+
italic: null;
|
|
52
|
+
strikethrough: null;
|
|
53
|
+
/** Captures the selection's formatting; the next selection receives it. */
|
|
54
|
+
paintFormat: null;
|
|
55
|
+
fontFamily: {
|
|
56
|
+
family: string;
|
|
57
|
+
};
|
|
58
|
+
/** Size in points, 1 to 400. */
|
|
59
|
+
fontSize: {
|
|
60
|
+
points: number;
|
|
61
|
+
};
|
|
62
|
+
fontSizeStep: {
|
|
63
|
+
direction: 'increase' | 'decrease';
|
|
64
|
+
};
|
|
65
|
+
/** `#rrggbb`. */
|
|
66
|
+
textColor: {
|
|
67
|
+
color: string;
|
|
68
|
+
};
|
|
69
|
+
/** `#rrggbb`. */
|
|
70
|
+
fillColor: {
|
|
71
|
+
color: string;
|
|
72
|
+
};
|
|
73
|
+
/** `'custom'` applies the selection's custom pattern, or `0.00`. */
|
|
74
|
+
numberFormat: {
|
|
75
|
+
value: NumberFormat;
|
|
76
|
+
};
|
|
77
|
+
decimalPlaces: {
|
|
78
|
+
direction: 'increase' | 'decrease';
|
|
79
|
+
};
|
|
80
|
+
/** Applies the preset with the current border style and color. */
|
|
81
|
+
borderPreset: {
|
|
82
|
+
value: BorderPreset;
|
|
83
|
+
};
|
|
84
|
+
borderStyle: {
|
|
85
|
+
value: BorderStyle;
|
|
86
|
+
};
|
|
87
|
+
/** `#rrggbb`. */
|
|
88
|
+
borderColor: {
|
|
89
|
+
color: string;
|
|
90
|
+
};
|
|
91
|
+
merge: {
|
|
92
|
+
value: MergeAction;
|
|
93
|
+
};
|
|
94
|
+
horizontalAlignment: {
|
|
95
|
+
value: HorizontalAlignment;
|
|
96
|
+
};
|
|
97
|
+
verticalAlignment: {
|
|
98
|
+
value: VerticalAlignment;
|
|
99
|
+
};
|
|
100
|
+
textWrapping: {
|
|
101
|
+
value: TextWrapping;
|
|
102
|
+
};
|
|
103
|
+
searchMenus: null;
|
|
104
|
+
findReplace: null;
|
|
105
|
+
save: null;
|
|
106
|
+
exportPng: null;
|
|
107
|
+
print: null;
|
|
108
|
+
undo: null;
|
|
109
|
+
redo: null;
|
|
110
|
+
/** 1 is 100%; 0.1 to 5. */
|
|
111
|
+
zoom: {
|
|
112
|
+
scale: number;
|
|
113
|
+
};
|
|
114
|
+
/** `null` toggles the panel. */
|
|
115
|
+
proposalsPanel: {
|
|
116
|
+
open: boolean;
|
|
117
|
+
} | null;
|
|
118
|
+
/** `force` applies a proposal whose cells changed since it was staged. */
|
|
119
|
+
proposalAccept: {
|
|
120
|
+
proposalId: string;
|
|
121
|
+
force?: boolean;
|
|
122
|
+
};
|
|
123
|
+
proposalReject: {
|
|
124
|
+
proposalId: string;
|
|
125
|
+
};
|
|
126
|
+
cut: null;
|
|
127
|
+
copy: null;
|
|
128
|
+
/** Pastes values and formats from the clipboard. */
|
|
129
|
+
paste: null;
|
|
130
|
+
/** Pastes only the clipboard's text. */
|
|
131
|
+
pastePlainText: null;
|
|
132
|
+
/** Clears the values of the selected cells, keeping their formats. */
|
|
133
|
+
clearContents: null;
|
|
134
|
+
/** Inserts as many rows as the selection spans. */
|
|
135
|
+
insertRows: {
|
|
136
|
+
position: 'above' | 'below';
|
|
137
|
+
};
|
|
138
|
+
/** Inserts as many columns as the selection spans. */
|
|
139
|
+
insertColumns: {
|
|
140
|
+
position: 'left' | 'right';
|
|
141
|
+
};
|
|
142
|
+
deleteRows: null;
|
|
143
|
+
deleteColumns: null;
|
|
144
|
+
/** Inserts a sheet before the active one. */
|
|
145
|
+
insertSheet: null;
|
|
146
|
+
deleteSheet: null;
|
|
147
|
+
/** `null` opens the active sheet's name for editing. */
|
|
148
|
+
renameSheet: {
|
|
149
|
+
name: string;
|
|
150
|
+
} | null;
|
|
151
|
+
moveSheet: {
|
|
152
|
+
direction: 'left' | 'right';
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/** @experimental */
|
|
156
|
+
type XlsxCommandId = keyof XlsxCommandArgs;
|
|
157
|
+
/**
|
|
158
|
+
* A command a plugin contributes, registered as `plugin:<pluginId>/<localId>`.
|
|
159
|
+
* @experimental
|
|
160
|
+
*/
|
|
161
|
+
type XlsxPluginCommandId = `plugin:${string}/${string}`;
|
|
162
|
+
|
|
163
|
+
type XlsxNullArgsCommandId = {
|
|
164
|
+
[K in XlsxCommandId]: null extends XlsxCommandArgs[K] ? K : never;
|
|
165
|
+
}[XlsxCommandId];
|
|
166
|
+
/**
|
|
167
|
+
* Every id a host can bind: commands that run without arguments and plugin commands.
|
|
168
|
+
* @experimental
|
|
169
|
+
*/
|
|
170
|
+
type XlsxShortcutId = XlsxNullArgsCommandId | XlsxPluginCommandId;
|
|
171
|
+
/**
|
|
172
|
+
* Host changes to the editor's shortcuts. An omitted id keeps its default; chords replace all of
|
|
173
|
+
* its defaults; `null` disables it and leaves the keystroke to the host or browser. A chord taken
|
|
174
|
+
* from another command's default wins over it. `cut`, `copy`, `paste` and `pastePlainText` read
|
|
175
|
+
* and write the clipboard with the async Clipboard API, which browsers may gate behind a prompt.
|
|
176
|
+
* Navigation and editing keys of the grid, and select all, cannot be bound.
|
|
177
|
+
* @experimental
|
|
178
|
+
*/
|
|
179
|
+
type XlsxShortcuts = Readonly<Partial<Record<XlsxShortcutId, ShortcutBinding>>>;
|
|
180
|
+
/**
|
|
181
|
+
* The effective bindings a host map produces and what was wrong with it, for checking a map
|
|
182
|
+
* outside the editor.
|
|
183
|
+
* @experimental
|
|
184
|
+
*/
|
|
185
|
+
declare function resolveXlsxShortcuts(shortcuts: XlsxShortcuts | undefined, options?: {
|
|
186
|
+
mac?: boolean;
|
|
187
|
+
}): ResolvedShortcuts;
|
|
188
|
+
|
|
189
|
+
export { type ResolvedShortcuts, type ShortcutBinding, type ShortcutChord, type ShortcutIssue, type XlsxShortcutId, type XlsxShortcuts, resolveXlsxShortcuts };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _=new Set(["Ctrl","Mod","Shift","Alt"]),I="Space Enter Tab Escape Backspace Delete Home End PageUp PageDown ArrowUp ArrowDown ArrowLeft ArrowRight".split(" "),L={escape:"Esc",delete:"Del",pageup:"Page Up",pagedown:"Page Down",arrowup:"\u2191",arrowdown:"\u2193",arrowleft:"\u2190",arrowright:"\u2192"};Object.fromEntries(I.map(t=>[t.toLowerCase(),t]));var E=Object.fromEntries(I.map(t=>[t.toLowerCase(),L[t.toLowerCase()]??t])),w=/^f([1-9]|1[0-2])$/;function X(){return typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform)}function p(t){let e=t.split("+"),a=e.length>1&&e[e.length-1]===""?"+":e[e.length-1],r=new Set(e.slice(0,-1));return {ctrl:r.has("Ctrl"),mod:r.has("Mod"),shift:r.has("Shift"),alt:r.has("Alt"),key:a.toLowerCase()}}function x(t){if(typeof t!="string"||t.length===0)return null;let e=t.split("+");if(!(e.length>1&&e[e.length-1]===""?e.slice(0,-2):e.slice(0,-1)).every(K=>_.has(K)))return null;let r=p(t);if(r.key.length===0)return null;let R=r.key==="+"?"=":r.key;return [r.ctrl&&"Ctrl",r.mod&&"Mod",r.alt&&"Alt",r.shift&&"Shift",R].filter(Boolean).join("+")}function v(t,e){let a=x(t);if(!a||e)return a;let r=p(a);return x([(r.ctrl||r.mod)&&"Mod",r.alt&&"Alt",r.shift&&"Shift",r.key].filter(Boolean).join("+"))}function k(t){return [...t].length===1||Object.hasOwn(E,t)||w.test(t)}function M(t){let e=p(t);return e.ctrl||e.mod||e.alt||w.test(e.key)}function B(t,e){if(t===null||typeof t=="string"||Array.isArray(t))return typeof t=="string"?[t]:t;let a=t[e?"mac":"other"];return typeof a=="string"?[a]:a}function O(t,e,a){let{mac:r,isBindable:R,isReserved:K}=a,g=[],N=new Map(t.map(n=>[n.id,n])),f=new Map,A=new Set;for(let[n,i]of Object.entries(e??{})){if(i===void 0)continue;if(!N.has(n)&&!R(n)){g.push({code:"unknown-id",id:n});continue}let l=B(i,r);if(l===void 0)continue;if(l===null||l.length===0){A.add(n);continue}let u=[];for(let c of l){let d=typeof c=="string"?v(c,r):null;!d||!k(p(d).key)||!M(d)?g.push({code:"invalid-chord",id:n,chord:String(c)}):K?.(d,n)?g.push({code:"reserved-chord",id:n,chord:c}):u.includes(d)||u.push(d);}u.length>0&&f.set(n,u);}let S=new Map;for(let[n,i]of f)for(let l of i)S.set(l,[...S.get(l)??[],n]);for(let[n,i]of S)i.length<2||(i.forEach((l,u)=>{g.push({code:"duplicate-chord",id:l,chord:n,other:i[(u+1)%i.length]});let c=f.get(l).filter(d=>d!==n);c.length>0?f.set(l,c):f.delete(l);}),S.delete(n));let C=new Map,y=new Map;for(let[n,i]of f){C.set(n,Object.freeze(i));for(let l of i)y.set(l,n);}for(let{id:n,chords:i}of t){if(f.has(n))continue;if(A.has(n)){C.set(n,Object.freeze([]));continue}let l=[];for(let u of i){let c=v(u,r),d=y.get(c);d===void 0?l.push(c):d!==n&&g.push({code:"displaced-default",id:d,chord:c,other:n});}C.set(n,Object.freeze(l));for(let u of l)y.set(u,n);}for(let n of A)C.has(n)||C.set(n,Object.freeze([]));return {chords:C,owners:y,issues:Object.freeze(g)}}function U(t){let e=x(t);return e&&!p(e).ctrl?e:null}function o(t,e,a,r=[]){return Object.freeze({id:t,labelKey:e,mutatesDocument:a,shortcuts:Object.freeze(r)})}var m=t=>({chord:t,args:null}),b=Object.freeze({bold:o("bold","toolbar.bold",true,[m("Mod+B")]),italic:o("italic","toolbar.italic",true,[m("Mod+I")]),strikethrough:o("strikethrough","toolbar.strikethrough",true),paintFormat:o("paintFormat","toolbar.paintFormat",true),fontFamily:o("fontFamily","toolbar.fontFamily",true),fontSize:o("fontSize","toolbar.fontSize",true),fontSizeStep:o("fontSizeStep","commands.fontSizeStep",true),textColor:o("textColor","toolbar.textColor",true),fillColor:o("fillColor","toolbar.fillColor",true),numberFormat:o("numberFormat","commands.numberFormat",true),decimalPlaces:o("decimalPlaces","commands.decimalPlaces",true),borderPreset:o("borderPreset","toolbar.borders",true),borderStyle:o("borderStyle","commands.borderStyle",true),borderColor:o("borderColor","toolbar.borderColor",true),merge:o("merge","toolbar.mergeCells",true),horizontalAlignment:o("horizontalAlignment","toolbar.horizontalAlignment",true),verticalAlignment:o("verticalAlignment","toolbar.verticalAlignment",true),textWrapping:o("textWrapping","toolbar.textWrapping",true),searchMenus:o("searchMenus","toolbar.searchMenus",false),findReplace:o("findReplace","commands.findReplace",false,[m("Mod+H")]),save:o("save","toolbar.save",false,[m("Mod+S")]),exportPng:o("exportPng","toolbar.exportPng",false),print:o("print","toolbar.print",false),undo:o("undo","toolbar.undo",true,[m("Mod+Z")]),redo:o("redo","toolbar.redo",true,[m("Mod+Shift+Z"),m("Mod+Y")]),zoom:o("zoom","toolbar.zoom",false),proposalsPanel:o("proposalsPanel","proposals.panelLabel",false),proposalAccept:o("proposalAccept","proposals.accept",true),proposalReject:o("proposalReject","proposals.reject",false),cut:o("cut","commands.cut",true,[m("Mod+X")]),copy:o("copy","commands.copy",false,[m("Mod+C")]),paste:o("paste","commands.paste",true,[m("Mod+V")]),pastePlainText:o("pastePlainText","commands.pastePlainText",true,[m("Mod+Shift+V")]),clearContents:o("clearContents","commands.clearContents",true),insertRows:o("insertRows","commands.insertRowsAbove",true),insertColumns:o("insertColumns","commands.insertColumnsLeft",true),deleteRows:o("deleteRows","commands.deleteRows",true),deleteColumns:o("deleteColumns","commands.deleteColumns",true),insertSheet:o("insertSheet","commands.insertSheet",true),deleteSheet:o("deleteSheet","commands.deleteSheet",true),renameSheet:o("renameSheet","commands.renameSheet",true),moveSheet:o("moveSheet","commands.moveSheetLeft",true)});Object.freeze(Object.keys(b));function T(t){return typeof t=="string"&&Object.prototype.hasOwnProperty.call(b,t)}var G=/^plugin:[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?\/[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;function P(t){return typeof t=="string"&&G.test(t)}var V=Object.freeze(Object.values(b).flatMap(t=>t.shortcuts.map(e=>({id:t.id,shortcut:e}))));new Set(V.map(({shortcut:t})=>U(t.chord)));var $=new Set(["arrowup","arrowdown","arrowleft","arrowright","tab","enter","escape","home","end","pageup","pagedown","f2","delete","backspace"]);function D(t){let e=p(t),a=e.mod||e.ctrl||e.alt;return $.has(e.key)||(e.mod||e.ctrl)&&e.key==="a"||!a&&e.key==="f6"||!a&&e.shift&&e.key==="f10"}var W=["automatic","plainText","number","percent","scientific","currency","date","time","custom"],q=["all","inner","horizontal","vertical","outer","left","top","right","bottom","none"],H=["solid","dashed","dotted","double"],Z=["left","center","right"],Y=["top","middle","bottom"],J=["overflow","wrap","clip"],Q=["all","horizontal","vertical","unmerge"];var ee=1,te=400,oe=.1,ne=5;var re=new Set(["increase","decrease"]);function s(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function h(t,e){return typeof e=="string"&&t.includes(e)}function ae(t){return typeof t=="string"&&/^#[0-9a-f]{6}$/i.test(t)}function z(t,e,a){return typeof t=="number"&&Number.isFinite(t)&&t>=e&&t<=a}function F(t,e){switch(t){case "fontFamily":return s(e)&&typeof e.family=="string"&&e.family.trim()!=="";case "fontSize":return s(e)&&z(e.points,ee,te);case "fontSizeStep":case "decimalPlaces":return s(e)&&typeof e.direction=="string"&&re.has(e.direction);case "textColor":case "fillColor":case "borderColor":return s(e)&&ae(e.color);case "numberFormat":return s(e)&&h(W,e.value);case "borderPreset":return s(e)&&h(q,e.value);case "borderStyle":return s(e)&&h(H,e.value);case "merge":return s(e)&&h(Q,e.value);case "horizontalAlignment":return s(e)&&h(Z,e.value);case "verticalAlignment":return s(e)&&h(Y,e.value);case "textWrapping":return s(e)&&h(J,e.value);case "zoom":return s(e)&&z(e.scale,oe,ne);case "proposalsPanel":return e===null||s(e)&&typeof e.open=="boolean";case "proposalAccept":return s(e)&&typeof e.proposalId=="string"&&(e.force===void 0||typeof e.force=="boolean");case "proposalReject":return s(e)&&typeof e.proposalId=="string";case "insertRows":return s(e)&&(e.position==="above"||e.position==="below");case "insertColumns":return s(e)&&(e.position==="left"||e.position==="right");case "moveSheet":return s(e)&&(e.direction==="left"||e.direction==="right");case "renameSheet":return e===null||s(e)&&typeof e.name=="string";default:return e===null}}function se(){return Object.values(b).flatMap(t=>{let e=t.shortcuts;return e.length===0?[]:[{id:t.id,chords:e.map(({chord:a})=>a)}]})}function le(t){return P(t)||T(t)&&F(t,null)}function ie(t,e={}){return O(se(),t,{mac:e.mac??X(),isBindable:le,isReserved:a=>D(a)})}export{ie as resolveXlsxShortcuts};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@betteroffice/xlsx-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Excel-faithful React XLSX spreadsheet editor and viewer: full OOXML fidelity, real-time human + AI agent collaboration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xlsx",
|
|
@@ -29,19 +29,26 @@
|
|
|
29
29
|
"exports": {
|
|
30
30
|
".": {
|
|
31
31
|
"types": "./dist/index.d.ts",
|
|
32
|
-
"import": "./dist/index.js"
|
|
32
|
+
"import": "./dist/index.js",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./shortcuts": {
|
|
36
|
+
"types": "./dist/shortcuts.d.ts",
|
|
37
|
+
"import": "./dist/shortcuts.js",
|
|
38
|
+
"default": "./dist/shortcuts.js"
|
|
33
39
|
}
|
|
34
40
|
},
|
|
35
41
|
"files": [
|
|
36
42
|
"dist"
|
|
37
43
|
],
|
|
38
44
|
"scripts": {
|
|
39
|
-
"build": "tsup",
|
|
45
|
+
"build": "tsup && tsup --config tsup.shortcuts.config.ts",
|
|
40
46
|
"typecheck": "tsc --noEmit -p ."
|
|
41
47
|
},
|
|
42
48
|
"dependencies": {
|
|
43
|
-
"@betteroffice/
|
|
44
|
-
"@betteroffice/xlsx
|
|
49
|
+
"@betteroffice/fonts": "^0.5.0",
|
|
50
|
+
"@betteroffice/xlsx": "0.6.1",
|
|
51
|
+
"@betteroffice/xlsx-i18n": "0.6.1"
|
|
45
52
|
},
|
|
46
53
|
"peerDependencies": {
|
|
47
54
|
"react": "^18.0.0 || ^19.0.0",
|