efficient-office 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Slides-JI73C3NW.js → Slides-LJW5C24V.js} +1 -1
- package/dist/SlidesEditor-ETCUQVJ7.js +1 -0
- package/dist/Spreadsheet-I5XA7TU7.js +1 -0
- package/dist/{chunk-B6JN7D6G.js → chunk-3KJZFUBH.js} +1 -1
- package/dist/{chunk-N26CBJZA.js → chunk-4M3QRYCH.js} +1 -1
- package/dist/{chunk-GLT7O6TV.js → chunk-4MGZXE3N.js} +1 -1
- package/dist/chunk-MZJSGEU3.js +1 -0
- package/dist/chunk-UDEPDAZI.js +1 -0
- package/dist/importSpreadsheet-ZXS3RSKE.js +1 -0
- package/dist/slides/index.js +1 -1
- package/dist/slides/slides.css +0 -1
- package/dist/spreadsheet/index.d.ts +4 -1
- package/dist/spreadsheet/index.js +1 -1
- package/dist/{workbookPdf-C5SSN226.js → workbookPdf-63WIOPEC.js} +1 -1
- package/dist/xlsxFile-GYMIRUWG.js +1 -0
- package/package.json +1 -1
- package/dist/SlidesEditor-5WCXE27J.js +0 -1
- package/dist/Spreadsheet-I3RO4HSS.js +0 -1
- package/dist/chunk-7K7AY3V3.js +0 -1
- package/dist/chunk-VKCG3LPQ.js +0 -1
- package/dist/importSpreadsheet-4U3KEJ76.js +0 -1
- package/dist/xlsxFile-B2JCZCOL.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{FileList as e}from"./chunk-PMGQ5GUH.js";import{importDeckFile as t}from"./chunk-6ZFEBY6H.js";import{PptxPasswordError as n,PptxUnreadableError as i}from"./chunk-MDG2ADZ7.js";import{STARTERS as s,starterDeck as l}from"./chunk-Q7NVDOCX.js";import{useSlidesHost as o,useSlidesWords as r}from"./chunk-BGAR3P46.js";import{SlideView as a}from"./chunk-B2X3NIQR.js";import"./chunk-PXOQN7D6.js";import"./chunk-B32ASXHM.js";import{placeCopy as c}from"./chunk-XYVQTQ6N.js";import{lazy as d,Suspense as m,useCallback as p,useEffect as u,useState as h}from"react";import{Button as f,EmptyState as k,IconButton as y,toast as b}from"efficient-shell/ui";import{Icon as N}from"efficient-shell/icons";import{jsx as v,jsxs as C}from"react/jsx-runtime";var w=e=>({title:e.placeholderTitle,subtitle:e.placeholderSubtitle,body:e.placeholderBody,dealerPitch:e.dealerPitch,monthlyReport:e.monthlyReport}),F=d(()=>import("./SlidesEditor-
|
|
1
|
+
import{FileList as e}from"./chunk-PMGQ5GUH.js";import{importDeckFile as t}from"./chunk-6ZFEBY6H.js";import{PptxPasswordError as n,PptxUnreadableError as i}from"./chunk-MDG2ADZ7.js";import{STARTERS as s,starterDeck as l}from"./chunk-Q7NVDOCX.js";import{useSlidesHost as o,useSlidesWords as r}from"./chunk-BGAR3P46.js";import{SlideView as a}from"./chunk-B2X3NIQR.js";import"./chunk-PXOQN7D6.js";import"./chunk-B32ASXHM.js";import{placeCopy as c}from"./chunk-XYVQTQ6N.js";import{lazy as d,Suspense as m,useCallback as p,useEffect as u,useState as h}from"react";import{Button as f,EmptyState as k,IconButton as y,toast as b}from"efficient-shell/ui";import{Icon as N}from"efficient-shell/icons";import{jsx as v,jsxs as C}from"react/jsx-runtime";var w=e=>({title:e.placeholderTitle,subtitle:e.placeholderSubtitle,body:e.placeholderBody,dealerPitch:e.dealerPitch,monthlyReport:e.monthlyReport}),F=d(()=>import("./SlidesEditor-ETCUQVJ7.js")),j=["pptx"];function D({id:e,onClose:t,note:n}){const i=r(),{store:s}=o(),[l,a]=h(null),[c,d]=h(!1),[b,w]=h(n??null),j=p(()=>{s.get(e).then(e=>a(t=>({deck:e,nonce:(t?.nonce??0)+1})),()=>d(!0))},[e,s]);if(u(j,[j]),c)return v("div",{className:"slides-list-empty",children:v(k,{title:i.openFailed,children:v(f,{onClick:t,children:i.backToDecks})})});if(!l)return null;const D=v(m,{fallback:null,children:v(F,{deck:l.deck,onClose:t,onReload:j},l.nonce)});return b?C("div",{className:"slides-with-note",children:[C("div",{className:"slides-import-note",role:"status",children:[v(N,{name:"info",size:16}),v("span",{children:b}),v(y,{"aria-label":i.dismiss,onClick:()=>w(null),children:v(N,{name:"close",size:14})})]}),v("div",{className:"slides-with-note-body",children:D})]}):D}function P(){const d=r(),{store:m,canCreate:u=!0,canDelete:f=!0,chooseFile:k,storeImage:y}=o(),[N,F]=h(null),[P,g]=h(null),x=p(()=>m.list(),[m]);if(N)return v(D,{id:N.id,note:N.note,onClose:()=>F(null)});const B=u&&v("div",{className:"slides-starters","aria-label":d.startFrom,role:"group",children:s.map(e=>{const t="blank"===e?null:l(e,w(d));return C("button",{type:"button",className:"slides-starter",disabled:!!P,onClick:()=>{(async e=>{if(!P)try{const t=await m.create("blank"===e?d.untitledDeck:d.starterName(e));"blank"!==e&&await m.save(t.id,l(e,w(d)),t.version),F({id:t.id})}catch{b.error(d.createFailed)}})(e)},children:[v("span",{className:"slides-starter-thumb",children:t?v(a,{slide:t.slides[0],width:128}):v("span",{className:"slides-starter-blank"})}),v("span",{children:d.starterName(e)})]},e)})});return v(e,{extra:B,words:{windowTitle:d.slidesPanel,heading:d.decks,newFile:d.newDeck,emptyTitle:d.emptyTitle,emptyBody:d.emptyBody,deleteConfirm:d.deleteConfirm,createFailed:d.createFailed,deleteFailed:d.deleteFailed},files:d.files,list:x,create:()=>m.create(d.untitledDeck),rename:m.rename,remove:m.remove,canCreate:u,canDelete:f,accept:".pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation",choose:k&&{run:k,request:{title:d.files.choosing(d.fileKind,d.slidesPanel),extensions:j}},onOpen:e=>F({id:e}),onOpenFile:(e,s)=>{if(P)return;const l=d.files.opening(e.name);g(l),t(m,e,{storeImage:y,onProgress:e=>g(`${l} ${Math.round(100*e)}%`)}).then(async t=>{const n=await c(s,t.id);b.success(d.files.savedCopy(t.title,e.name,n?s?.location:void 0)),F({id:t.id,note:d.importNotes({skipped:t.notes.skipped,animations:t.notes.animationsDropped,fonts:t.notes.fontsReplaced})})}).catch(t=>{b.error(t instanceof n?d.pptxPasswordProtected:t instanceof i?t.message:d.files.openFailed(e.name))}).finally(()=>g(null))},busy:P})}export{D as OpenDeck,P as default,w as starterWords};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mergeDecks as e}from"./chunk-3RFDQOTI.js";import{LAYOUTS as t,THEMES as n,applyTheme as i,ensureFonts as l,fontsOf as r,slideFromLayout as o,themeOf as s}from"./chunk-Q7NVDOCX.js";import{SlidesConflict as a,useSlidesHost as d,useSlidesWords as c}from"./chunk-BGAR3P46.js";import{DEFAULT_TRANSITION_SECONDS as m,PPTX_SHAPES as u,SlideView as h,applyStyle as p,boxStyle as f,chartToGrid as b,clicksOf as g,connectorPath as v,editorHtml as y,gridToChart as k,indent as w,insertColumn as x,insertRow as C,listMarkers as S,mergeAt as N,mergeCells as z,moveAnimation as I,nearestSide as D,newAnimation as M,paragraphsIn as E,paragraphsOf as A,plainText as P,readParagraphs as F,relayConnectors as T,removeColumn as L,removeRow as j,restoreSelection as $,selectionOffsets as R,seriesOf as B,setCell as W,setParagraphs as O,shapePath as K,shownSlides as U,stateAt as H,styleAt as V,toggleList as _,transitionKeyframes as J,unmergeCell as q,videoSource as X,withEnds as G,withParagraphs as Q}from"./chunk-B2X3NIQR.js";import{DECK_FONT as Y,DECK_FONTS as Z,HANDLES as ee,NO_FILL as te,SHAPE_KINDS as ne,SLIDE_H as ie,SLIDE_W as le,angleTo as re,asDocument as oe,boundsOf as se,boxesTouch as ae,bringForward as de,copySlide as ce,historyReducer as me,insertSlideAfter as ue,moveSlide as he,newElement as pe,newId as fe,removeElements as be,removeSlide as ge,resizeBox as ve,shiftElement as ye,snapBox as ke,updateElements as we,updateSlide as xe}from"./chunk-PXOQN7D6.js";import"./chunk-B32ASXHM.js";import{useCallback as Ce,useEffect as Se,useMemo as Ne,useReducer as ze,useRef as Ie,useState as De}from"react";import{saveIndicator as Me,useAutosave as Ee}from"efficient-easel/autosave";import{EaselIconButton as Ae,EaselTopBar as Pe,SaveState as Fe,TopBarCluster as Te,TopBarDivider as Le}from"efficient-easel/chrome";import{useEaselStrings as je}from"efficient-easel/strings";import"efficient-easel/shell.css";import"efficient-easel/chrome.css";import"efficient-easel/panel.css";import"efficient-easel/fields.css";import{AvatarGroup as $e,Avatar as Re,Button as Be,ContextMenu as We,DropdownMenu as Oe,IconButton as Ke,Input as Ue,Popover as He,registerModalEscapeInterceptor as Ve,Textarea as _e,useContextMenu as Je}from"efficient-shell/ui";import{Icon as qe}from"efficient-shell/icons";import{toast as Xe}from"efficient-shell";import{useRef as Ge,useState as Qe}from"react";import{Button as Ye,IconButton as Ze,Textarea as et}from"efficient-shell/ui";import{Icon as tt}from"efficient-shell/icons";import{toast as nt}from"efficient-shell";import{Button as it,IconButton as lt,Select as rt,Slider as ot,Switch as st}from"efficient-shell/ui";import{Icon as at}from"efficient-shell/icons";import{jsx as dt,jsxs as ct}from"react/jsx-runtime";var mt=["none","fade","slide","push","zoom","flip"],ut=["appear","fadeIn","flyIn","zoomIn","fadeOut"],ht=(e,t)=>({none:e.transitionNone,fade:e.transitionFade,slide:e.transitionSlide,push:e.transitionPush,zoom:e.transitionZoom,flip:e.transitionFlip}[t]),pt=(e,t)=>({appear:e.effectAppear,fadeIn:e.effectFadeIn,flyIn:e.effectFlyIn,zoomIn:e.effectZoomIn,fadeOut:e.effectFadeOut}[t]);function ft(e,t){return t?"text"===t.type?P(A(t)).split("\n")[0].slice(0,32)||e.elementText:{shape:e.elementShape,image:e.elementImage,video:e.elementVideo,connector:e.elementConnector,chart:e.elementChart,table:e.elementTable}[t.type]:""}function bt({slide:e,slideNumber:t,selected:n,onSlide:i,onAllSlides:l,onPlay:r}){const o=c(),s=e.animations??[],a=e=>i({animations:e.length>0?e:void 0}),d=(e,t)=>a(s.map(n=>n.id===e?{...n,...t}:n)),u=1===n.length?n[0]:null;return ct("aside",{className:"slides-inspector",children:[dt("h3",{children:o.motion}),ct("div",{className:"slides-section",children:[dt("p",{className:"slides-label",children:`${o.transition} · ${o.slideNumber(t)}`}),dt("div",{className:"slides-pills",role:"radiogroup","aria-label":o.transition,children:mt.map(t=>{const n=(e.transition?.kind??"none")===t;return dt("button",{type:"button",role:"radio","aria-checked":n,className:"slides-pill",onClick:()=>i({transition:"none"===t?void 0:{kind:t,duration:e.transition?.duration??m}}),children:ht(o,t)},t)})}),e.transition&&dt(ot,{label:o.duration,min:.1,max:5,step:.1,precision:1,suffix:"s",value:e.transition.duration,onChange:t=>i({transition:{...e.transition,duration:t??m}})}),ct("div",{className:"slides-actions",children:[dt(it,{variant:"secondary",size:"sm",onClick:()=>l({transition:e.transition}),children:o.applyToAll}),dt(it,{variant:"secondary",size:"sm",leftIcon:dt(at,{name:"play",size:14}),onClick:r,children:o.play})]})]}),ct("div",{className:"slides-section",children:[dt("p",{className:"slides-label",children:o.animations}),0===s.length&&dt("small",{className:"slides-hint",children:o.noAnimations}),s.map((t,n)=>{const i=e.elements.find(e=>e.id===t.elementId);return ct("div",{className:"slides-animation",children:[ct("div",{className:"slides-animation-head",children:[dt("span",{className:"slides-animation-number",children:n+1}),dt("span",{className:"slides-animation-name",children:ft(o,i)}),dt(lt,{"aria-label":o.moveEarlier,size:"sm",disabled:0===n,onClick:()=>a(I(s,n,n-1)),children:dt(at,{name:"chevron-up",size:14})}),dt(lt,{"aria-label":o.moveLater,size:"sm",disabled:n===s.length-1,onClick:()=>a(I(s,n,n+1)),children:dt(at,{name:"chevron-down",size:14})}),dt(lt,{"aria-label":o.removeAnimation,size:"sm",onClick:()=>a(s.filter(e=>e.id!==t.id)),children:dt(at,{name:"trash",size:14})})]}),dt(rt,{"aria-label":o.animations,size:"sm",value:t.effect,onChange:e=>d(t.id,{effect:e,from:"flyIn"===e?t.from??"bottom":void 0}),options:ut.map(e=>({value:e,label:pt(o,e)}))}),"flyIn"===t.effect&&dt(rt,{"aria-label":o.effectFlyIn,size:"sm",value:t.from??"bottom",onChange:e=>d(t.id,{from:e}),options:[{value:"left",label:o.fromLeft},{value:"right",label:o.fromRight},{value:"top",label:o.fromTop},{value:"bottom",label:o.fromBottom}]}),dt(rt,{"aria-label":o.startClick,size:"sm",value:t.start,onChange:e=>d(t.id,{start:e}),options:[{value:"click",label:o.startClick},{value:"withPrevious",label:o.startWithPrevious},{value:"afterPrevious",label:o.startAfterPrevious}]}),dt(ot,{label:o.duration,min:.1,max:5,step:.1,precision:1,suffix:"s",value:t.duration,onChange:e=>d(t.id,{duration:e??.5})}),"text"===i?.type&&dt(st,{label:o.byParagraph,checked:!!t.byParagraph,onChange:e=>d(t.id,{byParagraph:e||void 0})})]},t.id)}),u?ct("div",{className:"slides-actions",children:[dt(it,{variant:"secondary",size:"sm",leftIcon:dt(at,{name:"add",size:14}),onClick:()=>a([...s,M(u.id)]),children:o.addAnimation}),dt(it,{variant:"secondary",size:"sm",onClick:()=>a([...s,M(u.id,"fadeOut")]),children:o.effectFadeOut})]}):dt("small",{className:"slides-hint",children:o.selectToAnimate})]})]})}import{Fragment as gt,jsx as vt,jsxs as yt}from"react/jsx-runtime";function kt(e){return e.filter(e=>!e.parent).map(t=>({first:t,replies:e.filter(e=>e.parent===t.id)}))}function wt({placeholder:e,label:t,onPost:n,autoFocus:i}){const{people:l}=d(),r=c(),[o,s]=Qe(""),[a,m]=Qe([]),u=Ge(new Map),h=Ge(null),p=()=>{const e=o.trim();if(!e)return;const t=[...u.current].filter(([,t])=>e.includes(`@${t}`)).map(([e])=>e);n(e,t).then(()=>{s(""),u.current.clear()},()=>nt.error(r.commentFailed))};return yt("div",{className:"slides-composer",children:[vt(et,{ref:h,rows:2,"aria-label":t,placeholder:e,autoFocus:i,value:o,onChange:e=>{s(e.target.value),(e=>{const t=(e=>e.match(/@([\p{L}\p{N} .'-]{0,30})$/u)?.[1])(e);if(void 0===t||!l)return m([]);l(t.trim()).then(e=>m(e.slice(0,6)),()=>m([]))})(e.target.value)},onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&p()}}),a.length>0&&vt("ul",{className:"slides-mentions",role:"listbox","aria-label":t,children:a.map(e=>vt("li",{role:"option","aria-selected":!1,onMouseDown:t=>{t.preventDefault(),(e=>{const t=o.replace(/@([\p{L}\p{N} .'-]{0,30})$/u,`@${e.name} `);u.current.set(e.id,e.name),s(t),m([]),h.current?.focus()})(e)},children:e.name},e.id))}),vt("div",{className:"slides-actions slides-actions-end",children:vt(Ye,{size:"sm",disabled:!o.trim(),onClick:p,children:t})})]})}function xt({comment:e,mine:t,onSave:n,onDelete:i}){const l=c(),[r,o]=Qe(!1),[s,a]=Qe(e.body);return yt("div",{className:"slides-comment",children:[yt("div",{className:"slides-comment-head",children:[vt("span",{className:"slides-avatar","aria-hidden":"true",children:Ct(e.authorName)}),vt("span",{className:"slides-comment-author",children:e.authorName}),vt("time",{className:"slides-comment-time",dateTime:e.createdAt,children:new Date(e.createdAt).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}),t&&!r&&yt(gt,{children:[vt(Ze,{"aria-label":l.editComment,size:"sm",onClick:()=>o(!0),children:vt(tt,{name:"edit",size:14})}),vt(Ze,{"aria-label":l.deleteComment,size:"sm",onClick:i,children:vt(tt,{name:"trash",size:14})})]})]}),r?yt("div",{className:"slides-composer",children:[vt(et,{rows:2,"aria-label":l.editComment,value:s,onChange:e=>a(e.target.value)}),yt("div",{className:"slides-actions slides-actions-end",children:[vt(Ye,{variant:"secondary",size:"sm",onClick:()=>o(!1),children:l.cancel}),vt(Ye,{size:"sm",onClick:()=>{n(s.trim()),o(!1)},disabled:!s.trim(),children:l.save})]})]}):vt("p",{className:"slides-comment-body",children:e.body})]})}var Ct=e=>e.split(/\s+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join("")||"?";function St({comments:e,slides:t,slide:n,selectedId:i,focusId:l,onAdd:r,onUpdate:o,onRemove:s,onShowSlide:a}){const m=c(),{currentUser:u}=d(),[h,p]=Qe(!1),f=kt(e).filter(e=>h||!e.first.resolvedAt).sort((e,i)=>{const l=e=>e.first.slideId===n.id?0:1,r=e=>t.findIndex(t=>t.id===e.first.slideId);return l(e)-l(i)||r(e)-r(i)||e.first.createdAt.localeCompare(i.first.createdAt)}),b=n.elements.find(e=>e.id===i);return yt("aside",{className:"slides-inspector slides-comments",children:[vt("h3",{children:m.comments}),yt("div",{className:"slides-section",children:[vt("p",{className:"slides-label",children:b?ft(m,b):m.onSlide}),vt(wt,{label:m.post,placeholder:m.commentPlaceholder,onPost:(e,t)=>r({slideId:n.id,elementId:i??"",body:e,parent:null,mentions:t})},`${n.id}-${i??""}`),yt("label",{className:"slides-check",children:[vt("input",{type:"checkbox",checked:h,onChange:e=>p(e.target.checked)}),m.showResolved]})]}),0===f.length&&vt("p",{className:"slides-empty",children:m.noComments}),f.map(({first:e,replies:n})=>{const i=t.findIndex(t=>t.id===e.slideId),d=t[i]?.elements.find(t=>t.id===e.elementId);return yt("article",{className:"slides-thread","data-focus":l===e.id||void 0,"data-resolved":e.resolvedAt?"":void 0,children:[yt("button",{type:"button",className:"slides-thread-where",onClick:()=>a(e.slideId),children:[m.slideNumber(i+1),e.elementId?` · ${d?ft(m,d):m.objectGone}`:""]}),[e,...n].map(e=>vt(xt,{comment:e,mine:e.authorId===u?.id,onSave:t=>o(e.id,{body:t}),onDelete:()=>s(e.id)},e.id)),e.resolvedAt?yt("div",{className:"slides-actions slides-actions-between",children:[vt("small",{className:"slides-hint",children:`${m.resolvedBy} · ${e.resolvedByName}`}),vt(Ye,{variant:"secondary",size:"sm",onClick:()=>o(e.id,{resolved:!1}),children:m.reopen})]}):yt(gt,{children:[vt(wt,{label:m.reply,placeholder:m.replyPlaceholder,onPost:(t,n)=>r({slideId:e.slideId,elementId:e.elementId,body:t,parent:e.id,mentions:n})}),vt("div",{className:"slides-actions slides-actions-end",children:vt(Ye,{variant:"secondary",size:"sm",leftIcon:vt(tt,{name:"check",size:14}),onClick:()=>o(e.id,{resolved:!0}),children:m.resolve})})]})]},e.id)})]})}import{useCallback as Nt,useEffect as zt,useState as It}from"react";import{Button as Dt,confirm as Mt,prompt as Et}from"efficient-shell/ui";import{Icon as At}from"efficient-shell/icons";import{toast as Pt}from"efficient-shell";import{jsx as Ft,jsxs as Tt}from"react/jsx-runtime";var Lt=e=>new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"});function jt({deckId:e,previewing:t,onPreview:n,onRestore:i,refreshKey:l}){const r=c(),{versions:o}=d(),[s,a]=It(null),m=Nt(()=>{o&&o.list(e).then(a,()=>Pt.error(r.versionsFailed))},[e,o,r.versionsFailed]);if(zt(m,[m,l]),!o)return null;const u=async(t,n="")=>{const i=await Et({title:r.nameVersion,message:r.versionName,defaultValue:n});if(null!==i)try{t?await o.rename(e,t,i.trim()):await o.name(e,i.trim()),m()}catch{Pt.error(r.versionsFailed)}};return Tt("aside",{className:"slides-inspector",children:[Ft("h3",{children:r.versionHistory}),Ft("div",{className:"slides-section",children:Ft(Dt,{variant:"secondary",size:"sm",leftIcon:Ft(At,{name:"bookmark",size:14}),onClick:()=>{u(null)},children:r.nameVersion})}),0===s?.length&&Ft("p",{className:"slides-empty",children:r.noVersions}),Ft("ul",{className:"slides-versions",children:s?.map(l=>Tt("li",{"data-current":t===l.id||void 0,children:[Ft("button",{type:"button",className:"slides-version-name",onClick:()=>{u(l.id,l.name)},children:l.name||Lt(l.createdAt)}),l.name&&Ft("small",{children:Lt(l.createdAt)}),Ft("small",{children:l.editorNames.join(", ")}),Tt("div",{className:"slides-actions",children:[Ft(Dt,{variant:"secondary",size:"sm",onClick:()=>{t===l.id?n(null,null):o.get(e,l.id).then(e=>n(l.id,e),()=>Pt.error(r.versionsFailed))},children:t===l.id?r.closePreview:r.previewVersion}),Ft(Dt,{variant:"secondary",size:"sm",onClick:()=>{(async t=>{if(await Mt({title:r.restore,message:r.restoreConfirm(Lt(t.createdAt)),confirmLabel:r.restore}))try{i(await o.get(e,t.id))}catch{Pt.error(r.restoreFailed)}})(l)},children:r.restore})]})]},l.id))})]})}import{useEffect as $t,useMemo as Rt,useRef as Bt,useState as Wt}from"react";import{Button as Ot,registerModalEscapeInterceptor as Kt}from"efficient-shell/ui";import{Icon as Ut}from"efficient-shell/icons";import{useLayoutEffect as Ht,useRef as Vt,useState as _t}from"react";import{createPortal as Jt}from"react-dom";import{jsx as qt,jsxs as Xt}from"react/jsx-runtime";function Gt(e){const[t,n]=_t(0);return Ht(()=>{const t=e.current;if(!t)return;const i=t.ownerDocument.defaultView,l=()=>n(Math.min(t.clientWidth,t.clientHeight*le/ie));l();const r=new(i?.ResizeObserver??ResizeObserver)(l);return r.observe(t),()=>r.disconnect()},[e]),t}function Qt({slide:e,popup:t,number:n,motion:i,fonts:r,transition:o,onLink:s,onAdvance:a}){const[d]=_t(()=>{const e=t.document.createElement("div");return e.style.cssText="position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:#000;cursor:pointer;overflow:hidden",t.document.body.appendChild(e),{current:e}}),c=Gt(d),[m,u]=_t(null),p=Vt(e),f=Vt(null),b=Vt(null);Ht(()=>{r&&l(t.document,r)},[r,t]),Ht(()=>{const t=p.current;p.current=e,t.id!==e.id&&o?u(t):u(null)},[e,o]),Ht(()=>{if(!m||!o)return;const{incoming:e,outgoing:n}=J(o),i={duration:1e3*o.duration,easing:"ease-in-out",fill:"both"},l=f.current?.animate(e,i),r=b.current?.animate(n,i),s=t.setTimeout(()=>u(null),1e3*o.duration+30);return()=>{t.clearTimeout(s),l?.cancel(),r?.cancel()}},[m,o,t]);const g=Vt(!1);return Jt(Xt("div",{style:{position:"relative",width:c,height:c*ie/le},onClick:()=>{if(!g.current&&t.document.documentElement.requestFullscreen)return g.current=!0,void t.document.documentElement.requestFullscreen().catch(()=>{});a?.()},children:[m&&qt("div",{ref:b,style:{position:"absolute",inset:0},children:qt(h,{slide:m,width:c})}),qt("div",{ref:f,style:{position:"absolute",inset:0},children:qt(h,{slide:e,width:c,number:n,motion:i,options:{live:!0,onLink:s}})})]}),d.current)}import{jsx as Yt,jsxs as Zt}from"react/jsx-runtime";var en=e=>String(e).padStart(2,"0");function tn({slides:e,startIndex:t,numbers:n,fonts:i,popup:l,onEnd:r}){const o=Rt(()=>U(e),[e]),s=Math.max(0,o.findIndex(e=>e>=t)),[a,d]=Wt({at:s,step:0}),[m,u]=Wt(!0),p=function(){const[e,t]=Wt(0);return $t(()=>{const e=Date.now(),n=setInterval(()=>t(Math.floor((Date.now()-e)/1e3)),1e3);return()=>clearInterval(n)},[]),`${en(Math.floor(e/60))}:${en(e%60)}`}(),f=c(),b=Bt(null),v=Gt(b),y=t=>{const n=function(e,t,n,i){const l=e[t[n.at]];if(1===i)return l&&n.step<g(l)?{at:n.at,step:n.step+1}:n.at<t.length-1?{at:n.at+1,step:0}:n;if(n.step>0)return{at:n.at,step:n.step-1};if(0===n.at)return n;const r=e[t[n.at-1]];return{at:n.at-1,step:g(r)}}(e,o,a,t);u(n.at!==a.at&&1===t),d(n)},k=Bt({go:y,onEnd:r});k.current={go:y,onEnd:r},$t(()=>{const e=e=>{["ArrowRight","ArrowDown","PageDown"," ","Enter"].includes(e.key)?(e.preventDefault(),k.current.go(1)):["ArrowLeft","ArrowUp","PageUp","Backspace"].includes(e.key)&&(e.preventDefault(),k.current.go(-1))};return window.addEventListener("keydown",e),l?.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e),l?.removeEventListener("keydown",e)}},[l]),$t(()=>Kt(()=>(k.current.onEnd(),!0)),[]),$t(()=>{if(!l)return;const e=e=>{"Escape"===e.key&&k.current.onEnd()};return l.addEventListener("keydown",e),()=>{l.removeEventListener("keydown",e),l.close()}},[l]);const w=o[Math.min(a.at,o.length-1)],x=e[w],C=o[a.at+1],S=void 0!==C?e[C]:void 0,N=g(x),z=Rt(()=>H(x,a.step),[x,a.step]),I=t=>{if(t.startsWith("#slide=")){const n=e.findIndex(e=>e.id===t.slice(7));-1!==n&&(e=>{const t=o.indexOf(e);-1!==t&&(u(!0),d({at:t,step:0}))})(n)}else window.open(t,"_blank","noopener")},D=n?w+1:void 0;return Zt("div",{className:"slides-presenter",children:[Zt("div",{className:"slides-presenter-head",children:[Yt("span",{className:"slides-presenter-clock",children:p}),Zt("span",{children:[f.slideOf(w+1,e.length),N>0&&` · ${f.presenterStep(a.step,N)}`]}),Yt(Ot,{variant:"secondary",onClick:r,leftIcon:Yt(Ut,{name:"close",size:16}),children:f.endShow})]}),!l&&Yt("p",{className:"slides-presenter-blocked",children:f.popupBlocked}),Zt("div",{className:"slides-presenter-body",children:[Zt("div",{className:"slides-presenter-main",children:[Yt("div",{ref:b,className:"slides-presenter-current",children:Yt(h,{slide:x,width:v,number:D,motion:z,options:{onLink:I}})}),Zt("div",{className:"slides-presenter-steps",children:[Yt(Ot,{variant:"secondary",onClick:()=>y(-1),leftIcon:Yt(Ut,{name:"arrow-left",size:16}),children:f.back}),Yt(Ot,{variant:"secondary",onClick:()=>y(1),rightIcon:Yt(Ut,{name:"arrow-right",size:16}),children:f.next})]})]}),Zt("div",{className:"slides-presenter-side",children:[Yt("p",{className:"slides-presenter-label",children:f.nextSlide}),S?Yt(h,{slide:S,width:280,number:n?C+1:void 0}):Yt("p",{children:f.endOfDeck}),Yt("p",{className:"slides-presenter-label",children:f.notes}),Yt("p",{className:"slides-presenter-notes",children:x.notes||f.noNotes})]})]}),l&&Yt(Qt,{slide:x,popup:l,number:D,motion:z,fonts:i,transition:m&&0===a.step?x.transition:void 0,onLink:I,onAdvance:()=>y(1)})]})}import{useState as nn}from"react";import{SettingsColour as ln}from"efficient-easel/panel";import{Button as rn}from"efficient-shell/ui";import{IconButton as on}from"efficient-shell/ui";import{Input as sn}from"efficient-shell/ui";import{Select as an}from"efficient-shell/ui";import{Slider as dn}from"efficient-shell/ui";import{Switch as cn}from"efficient-shell/ui";import{Icon as mn}from"efficient-shell/icons";import{Fragment as un,jsx as hn,jsxs as pn}from"react/jsx-runtime";var fn=e=>e===te?"#ffffff":e;function bn({label:e,value:t,onChange:n}){return pn("label",{className:"slides-number",children:[hn("span",{children:e}),hn(sn,{type:"number",value:Math.round(t),onChange:e=>{const t=Number(e.target.value);""!==e.target.value&&Number.isFinite(t)&&n(t)}})]})}function gn(e){return[{label:e.alignLeft,icon:"box-x-start",action:{kind:"align",to:"left"}},{label:e.alignCentre,icon:"box-x-center",action:{kind:"align",to:"center"}},{label:e.alignRight,icon:"box-x-end",action:{kind:"align",to:"right"}},{label:e.alignTop,icon:"box-y-start",action:{kind:"align",to:"top"}},{label:e.alignMiddle,icon:"box-y-center",action:{kind:"align",to:"middle"}},{label:e.alignBottom,icon:"box-y-end",action:{kind:"align",to:"bottom"}},{label:e.distributeAcross,icon:"box-x-between",action:{kind:"distribute",axis:"horizontal"}},{label:e.distributeDown,icon:"box-y-between",action:{kind:"distribute",axis:"vertical"}}]}function vn({chart:e,accents:t,onChange:n}){const i=c(),l=b(e),r="pie"===e.kind||"donut"===e.kind;return pn("div",{className:"slides-field",children:[hn("span",{children:i.values}),hn("div",{className:"slides-grid-edit",style:{gridTemplateColumns:`repeat(${l[0].length}, minmax(0, 1fr))`},children:l.map((r,o)=>r.map((r,s)=>hn("input",{"aria-label":0===o?i.seriesName:0===s?i.rows:`${l[0][s]} ${l[o][0]}`,className:"slides-grid-cell","data-head":0===o||0===s||void 0,value:r,disabled:0===o&&0===s,inputMode:o>0&&s>0?"decimal":void 0,onChange:i=>((i,r,o)=>n(k(e,l.map((e,t)=>e.map((e,n)=>t===i&&n===r?o:e)),t)))(o,s,i.target.value)},`${o}-${s}`)))}),pn("div",{className:"slides-actions",children:[!r&&hn(rn,{variant:"secondary",size:"sm",leftIcon:hn(mn,{name:"add",size:14}),onClick:()=>n(k(e,l.map((e,t)=>[...e,0===t?`${i.addSeries} ${e.length}`:"0"]),t)),children:i.addSeries}),hn(rn,{variant:"secondary",size:"sm",leftIcon:hn(mn,{name:"add",size:14}),onClick:()=>n(k(e,[...l,l[0].map((e,t)=>0===t?"":"0")],t)),children:i.addCategory})]})]})}function yn({slide:e,selected:t,onChangeSlide:n,onChangeSelected:i,onAlign:l,onForward:r,onDelete:o,onArrange:s,cells:a,accents:m=[]}){const u=c(),{pickImage:h}=d();if(0===t.length)return pn("aside",{className:"slides-inspector",children:[hn("h3",{children:u.slide}),pn("div",{className:"slides-section",children:[hn(ln,{label:u.background,value:e.background,onChange:e=>n({background:e})}),hn(cn,{label:u.skipSlide,checked:!!e.skip,onChange:e=>n({skip:e||void 0})})]})]});const p=1===t.length?t[0]:null,f={text:u.elementText,shape:u.elementShape,image:u.elementImage,video:u.elementVideo,connector:u.elementConnector,chart:u.elementChart,table:u.elementTable},g=e=>i(t=>({...t,...e})),v=e=>{s?s(e):"align"!==e.kind||"left"!==e.to&&"center"!==e.to&&"right"!==e.to?"order"===e.kind&&"forward"===e.to&&r():l(e.to)},y=t.some(e=>e.groupId),w=t.every(e=>e.locked);return pn("aside",{className:"slides-inspector",children:[hn("h3",{children:p?f[p.type]:u.objects(t.length)}),p&&"connector"!==p.type&&pn("div",{className:"slides-section",children:[hn("p",{className:"slides-label",children:u.positionAndSize}),pn("div",{className:"slides-numbers",children:[hn(bn,{label:"X",value:p.x,onChange:e=>g({x:e})}),hn(bn,{label:"Y",value:p.y,onChange:e=>g({y:e})}),hn(bn,{label:u.width,value:p.w,onChange:e=>g({w:Math.max(20,e)})}),hn(bn,{label:u.height,value:p.h,onChange:e=>g({h:Math.max(20,e)})}),hn(bn,{label:u.angle,value:p.rotation,onChange:e=>g({rotation:e})})]})]}),pn("div",{className:"slides-section",children:[hn("p",{className:"slides-label",children:u.align}),hn("div",{className:"slides-actions",children:gn(u).map(({label:e,icon:t,action:n})=>hn(on,{"aria-label":e,size:"sm",onClick:()=>v(n),children:hn(mn,{name:t,size:16})},e))}),pn("div",{className:"slides-actions",children:[hn(on,{"aria-label":u.bringToFront,size:"sm",onClick:()=>v({kind:"order",to:"front"}),children:hn(mn,{name:"move-up",size:16})}),hn(on,{"aria-label":u.bringForward,size:"sm",onClick:()=>v({kind:"order",to:"forward"}),children:hn(mn,{name:"layers",size:16})}),hn(on,{"aria-label":u.sendBackward,size:"sm",onClick:()=>v({kind:"order",to:"backward"}),children:hn(mn,{name:"arrow-down",size:16})}),hn(on,{"aria-label":u.sendToBack,size:"sm",onClick:()=>v({kind:"order",to:"back"}),children:hn(mn,{name:"move-down",size:16})}),t.length>1&&!y&&hn(on,{"aria-label":u.group,size:"sm",onClick:()=>v({kind:"group"}),children:hn(mn,{name:"rectangle-group",size:16})}),y&&hn(on,{"aria-label":u.ungroup,size:"sm",onClick:()=>v({kind:"ungroup"}),children:hn(mn,{name:"detach",size:16})}),hn(on,{"aria-label":w?u.unlock:u.lock,size:"sm",pressed:w,onClick:()=>v({kind:"lock",locked:!w}),children:hn(mn,{name:"lock",size:16})}),hn(on,{"aria-label":u.delete,size:"sm",onClick:o,children:hn(mn,{name:"trash",size:16})})]})]}),"shape"===p?.type&&pn("div",{className:"slides-section",children:[hn(an,{"aria-label":u.elementShape,value:p.shape,onChange:e=>g({shape:e}),options:ne.map(e=>({value:e,label:u.shapeName(e)}))}),"line"!==p.shape&&hn(ln,{label:u.colour,value:fn(p.fill),onChange:e=>g({fill:e})}),(p.stroke||"line"===p.shape)&&hn(ln,{label:u.outlineColour,value:fn(p.stroke??p.fill),onChange:e=>g({stroke:e})}),"line"!==p.shape&&!p.stroke&&hn(rn,{variant:"secondary",size:"sm",onClick:()=>g({stroke:"#2c2c2a",strokeWidth:4}),children:u.outline}),(p.stroke||"line"===p.shape)&&hn(dn,{label:u.lineWidth,min:1,max:40,value:p.strokeWidth??4,onChange:e=>g({strokeWidth:e??4})}),"line"===p.shape&&pn(un,{children:[hn(cn,{label:u.arrowStart,checked:!!p.arrowStart,onChange:e=>g({arrowStart:e})}),hn(cn,{label:u.arrowEnd,checked:!!p.arrowEnd,onChange:e=>g({arrowEnd:e})})]})]}),"connector"===p?.type&&pn("div",{className:"slides-section",children:[hn(an,{"aria-label":u.route,value:p.route,onChange:e=>g({route:e}),options:[{value:"straight",label:u.routeStraight},{value:"elbow",label:u.routeElbow},{value:"curved",label:u.routeCurved}]}),hn(ln,{label:u.outlineColour,value:p.stroke,onChange:e=>g({stroke:e})}),hn(dn,{label:u.lineWidth,min:1,max:40,value:p.strokeWidth,onChange:e=>g({strokeWidth:e??4})}),hn(cn,{label:u.arrowStart,checked:!!p.arrowStart,onChange:e=>g({arrowStart:e})}),hn(cn,{label:u.arrowEnd,checked:!!p.arrowEnd,onChange:e=>g({arrowEnd:e})})]}),"image"===p?.type&&hn(kn,{element:p,pickImage:h,onChange:g,onChangeSelected:i}),"video"===p?.type&&pn("div",{className:"slides-section",children:[pn("label",{className:"slides-field",children:[hn("span",{children:u.videoAddress}),hn(sn,{value:p.src,placeholder:"https://youtu.be/…",onChange:e=>g({src:e.target.value.trim()})}),hn("small",{children:u.videoHint})]}),pn("label",{className:"slides-field",children:[hn("span",{children:u.description}),hn(sn,{value:p.alt,onChange:e=>g({alt:e.target.value})})]})]}),"chart"===p?.type&&pn("div",{className:"slides-section",children:[hn("p",{className:"slides-label",children:u.data}),hn(an,{"aria-label":u.chartType,value:p.kind,onChange:e=>g({kind:e}),options:[{value:"bar",label:u.chartBar},{value:"hbar",label:u.chartHbar},{value:"line",label:u.line},{value:"area",label:u.chartArea},{value:"pie",label:u.chartPie},{value:"donut",label:u.chartDonut}]}),hn(vn,{chart:p,accents:m,onChange:e=>i(()=>e)}),hn(an,{"aria-label":u.legend,value:p.legend??"auto",onChange:e=>g({legend:"auto"===e?void 0:e}),options:[{value:"auto",label:u.legend},{value:"bottom",label:u.legendBottom},{value:"right",label:u.legendRight},{value:"none",label:u.legendNone}]}),hn(ln,{label:u.colour,value:p.series?.[0]?.color??p.color,onChange:e=>i(t=>{const n=t,i=b(n);return k({...n,color:e,series:n.series?.map((t,n)=>0===n?{...t,color:e}:t)},i,m)})})]}),"table"===p?.type&&hn(wn,{table:p,cells:a??null,onChange:e=>i(()=>e)})]})}function kn({element:e,pickImage:t,onChange:n,onChangeSelected:i}){const l=c(),r=e.crop??{left:0,top:0,right:0,bottom:0};return pn("div",{className:"slides-section",children:[t?hn(rn,{variant:"secondary",block:!0,onClick:()=>{const{id:n}=e;t().then(e=>{e&&i(t=>t.id===n?{...t,src:e}:t)})},children:e.src?l.replaceImage:l.chooseImage}):pn("label",{className:"slides-field",children:[hn("span",{children:l.imageAddress}),hn(sn,{value:e.src,onChange:e=>n({src:e.target.value})})]}),pn("label",{className:"slides-field",children:[hn("span",{children:l.description}),hn(sn,{value:e.alt,onChange:e=>n({alt:e.target.value})})]}),hn("p",{className:"slides-label",children:l.crop}),["left","top","right","bottom"].map(e=>hn(dn,{label:l[{left:"cropLeft",top:"cropTop",right:"cropRight",bottom:"cropBottom"}[e]],min:0,max:45,suffix:"%",value:Math.round(100*r[e]),onChange:t=>((e,t)=>{const i={...r,[e]:Math.max(0,Math.min(.45,(t??0)/100))};n({crop:i.left||i.top||i.right||i.bottom?i:void 0})})(e,t)},e)),hn(dn,{label:l.opacity,min:0,max:100,suffix:"%",value:Math.round(100*(e.opacity??1)),onChange:e=>n({opacity:null===e||e>=100?void 0:e/100})})]})}function wn({table:e,cells:t,onChange:n}){const i=c(),[l]=nn(i.cellEditHint),r=t??{row:e.rows.length-1,col:(e.rows[0]?.length??1)-1,rows:1,cols:1},o=N(e,r.row,r.col);return pn("div",{className:"slides-section",children:[hn("small",{className:"slides-hint",children:l}),pn("div",{className:"slides-actions slides-actions-words",children:[hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(C(e,r.row)),children:i.insertRowAbove}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(C(e,r.row+r.rows)),children:i.insertRowBelow}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(x(e,r.col)),children:i.insertColumnLeft}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(x(e,r.col+r.cols)),children:i.insertColumnRight}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(j(e,r.row)),children:i.deleteRow}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(L(e,r.col)),children:i.deleteColumn}),t&&t.rows*t.cols>1&&hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(z(e,t)),children:i.mergeCells}),o&&hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(q(e,r.row,r.col)),children:i.unmergeCells})]}),hn(ln,{label:i.headingColour,value:fn(e.headerFill),onChange:t=>n({...e,headerFill:t})}),hn(ln,{label:i.borderColour,value:e.borderColor??"#b4b2a9",onChange:t=>n({...e,borderColor:t})}),hn(dn,{label:i.borderWidth,min:0,max:12,value:e.borderWidth??2,onChange:t=>n({...e,borderWidth:t??2})})]})}import{useState as xn}from"react";import{Button as Cn,ContextMenu as Sn,useContextMenu as Nn}from"efficient-shell/ui";import{Icon as zn}from"efficient-shell/icons";import{jsx as In,jsxs as Dn}from"react/jsx-runtime";function Mn({slides:e,currentId:t,onShow:n,onAdd:i,onMove:l,onDuplicate:r,onDelete:o,onSkip:s,numbers:a,visitors:d=[]}){const[m,u]=xn(null),p=c(),f=Nn(),b=f.state?e.findIndex(e=>e.id===f.state?.data):-1;return Dn("nav",{className:"slides-rail","aria-label":p.slidesPanel,children:[e.map((e,i)=>Dn("div",{className:"slides-thumb","data-current":e.id===t||void 0,"data-skipped":e.skip||void 0,draggable:!0,onDragStart:()=>u(e.id),onDragEnd:()=>u(null),onDragOver:e=>e.preventDefault(),onContextMenu:t=>f.open(t,e.id),onDrop:()=>{m&&m!==e.id&&l(m,i),u(null)},children:[In("span",{className:"slides-thumb-number",children:i+1}),Dn("div",{role:"button",tabIndex:0,"aria-label":p.slideNumber(i+1),"aria-current":e.id===t,className:"slides-thumb-image",onClick:()=>n(e.id),onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),n(e.id))},children:[In(h,{slide:e,width:132,number:a?i+1:void 0}),e.skip&&In("span",{className:"slides-thumb-skip",title:p.skipped,children:In(zn,{name:"eye-off",size:14})}),In("span",{className:"slides-thumb-visitors",children:d.filter(t=>t.slide===e.id).map(e=>In("span",{title:e.user.name,style:{background:e.color}},e.key))})]})]},e.id)),In(Cn,{variant:"secondary",block:!0,onClick:i,children:p.addSlide}),b>=0&&In(Sn,{...f.props,items:(g=e[b],[{key:"duplicate",label:p.duplicateSlide,icon:In(zn,{name:"copy",size:14}),onSelect:()=>r(g.id)},...s?[{key:"skip",label:g.skip?p.unskipSlide:p.skipSlide,icon:In(zn,{name:"eye-off",size:14}),onSelect:()=>s(g.id)}]:[],{type:"divider",key:"d-delete"},{key:"delete",label:p.deleteSlide,danger:!0,icon:In(zn,{name:"trash",size:14}),onSelect:()=>o(g.id)}]),"aria-label":p.slideNumber(b+1)})]});var g}import{useLayoutEffect as En,useRef as An,useState as Pn}from"react";function Fn(e,t){const n=[...e.elements];for(let e=1;e<n.length;e+=1)t.has(n[e].id)&&!t.has(n[e-1].id)&&([n[e],n[e-1]]=[n[e-1],n[e]]);return{...e,elements:n}}function Tn(e,t){const n=e.elements.filter(e=>!t.has(e.id));return{...e,elements:[...n,...e.elements.filter(e=>t.has(e.id))]}}function Ln(e,t){const n=e.elements.filter(e=>!t.has(e.id));return{...e,elements:[...e.elements.filter(e=>t.has(e.id)),...n]}}var jn={x:0,y:0,w:le,h:ie};function $n(e,t){const n=new Set(e.elements.filter(e=>t.has(e.id)&&e.groupId).map(e=>e.groupId));return new Set(e.elements.filter(e=>t.has(e.id)||e.groupId&&n.has(e.groupId)).map(e=>e.id))}var Rn="efficient-office/slide-elements";function Bn(e){try{const t=JSON.parse(e);return t?.type===Rn&&Array.isArray(t.elements)?t.elements:null}catch{return null}}function Wn(e,t){const n=new Map(t.map(e=>[e.id,fe()])),i=new Map,l=t.some(t=>e.elements.some(e=>e.id===t.id))?40:0,r=t.map(e=>{const t={...ye(e,l,l),id:n.get(e.id),locked:void 0};var r;if(e.groupId&&(t.groupId=(r=e.groupId,i.has(r)||i.set(r,fe()),i.get(r))),"connector"===t.type){const e=({attach:e,...t})=>{const i=e&&n.get(e.id);return i?{...t,attach:{...e,id:i}}:t};return{...t,start:e(t.start),end:e(t.end)}}return t});return{slide:{...e,elements:[...e.elements,...r]},ids:r.map(e=>e.id)}}import{useEffect as On,useLayoutEffect as Kn,useRef as Un}from"react";import{registerModalEscapeInterceptor as Hn}from"efficient-shell/ui";import{jsx as Vn}from"react/jsx-runtime";var _n=e=>e.reduce((e,t)=>e+t.runs.reduce((e,t)=>e+t.text.length,0),0)+e.length-1;function Jn({element:e,onCommit:t,onEnd:n,onEditing:i,onLinkShortcut:l}){const r=c(),o=Un(null),s=Un(A(e)),a=Un({start:0,end:_n(s.current)}),d=Un(t);d.current=t;const m=Un(n);m.current=n;const u=Un(i);u.current=i;const h=()=>{const t=o.current;t&&(t.innerHTML=y(e,s.current))},b=()=>{const{start:e,end:t}=a.current,n=s.current,i=e!==t,{runs:l,...r}=n[E(n,e,t)[0]??0]??{runs:[]};u.current({style:i?V(n,e,t):V(n,0,_n(n)),paragraph:r,hasRange:i,applyRun:e=>g((t,n,i)=>n===i?p(t,0,_n(t),e):p(t,n,i,e)),applyParagraph:e=>g((t,n,i)=>O(t,n,i,e)),toggleList:e=>g((t,n,i)=>_(t,n,i,e)),indent:e=>g((t,n,i)=>w(t,n,i,e))})},g=e=>{const t=o.current;if(!t)return;const{start:n,end:i}=a.current;s.current=e(s.current,n,i),h(),t.focus(),$(t,n,i),b()};return Kn(()=>{const e=o.current;if(!e)return;h(),e.focus();const t=_n(s.current);$(e,0,t),a.current={start:0,end:t},b()},[]),On(()=>Hn(()=>!!o.current?.contains(o.current.ownerDocument.activeElement)&&(m.current(),!0)),[]),On(()=>{const e=o.current;if(!e)return;const t=e.ownerDocument,n=()=>{const t=R(e);t&&(a.current=t,b())};return t.addEventListener("selectionchange",n),()=>{t.removeEventListener("selectionchange",n),u.current(null),d.current(s.current)}},[]),Vn("div",{ref:o,contentEditable:!0,role:"textbox","aria-multiline":"true","aria-label":r.slideText,suppressContentEditableWarning:!0,className:"slides-text-edit",style:{...f(e),display:"flex",flexDirection:"column",justifyContent:{top:"flex-start",middle:"center",bottom:"flex-end"}[e.anchor??"top"]},onPointerDown:e=>e.stopPropagation(),onInput:()=>{const e=o.current,t=s.current,n=F(e);s.current=n;if((n.some(e=>e.list)||t.some(e=>e.list))&&n.length!==t.length){const t=R(e)??a.current;h(),$(e,t.start,t.end)}},onPaste:e=>{e.preventDefault();const t=e.clipboardData.getData("text/plain");o.current?.ownerDocument.execCommand("insertText",!1,t)},onKeyDown:e=>{e.stopPropagation();const t=e.metaKey||e.ctrlKey,n=e.key.toLowerCase(),i=V(s.current,a.current.start,a.current.end);t&&"b"===n?(e.preventDefault(),g((e,t,n)=>p(e,t,n,{bold:!i.bold}))):t&&"i"===n?(e.preventDefault(),g((e,t,n)=>p(e,t,n,{italic:!i.italic||void 0}))):t&&"u"===n?(e.preventDefault(),g((e,t,n)=>p(e,t,n,{underline:!i.underline||void 0}))):t&&"k"===n?(e.preventDefault(),l?.()):"Tab"===e.key?(e.preventDefault(),g((t,n,i)=>w(t,n,i,e.shiftKey?-1:1))):"Escape"===e.key&&m.current()}})}import{Fragment as qn,jsx as Xn,jsxs as Gn}from"react/jsx-runtime";var Qn={x:[],y:[]};function Yn({text:e,onDone:t}){const n=An(null);return En(()=>{const t=n.current;t&&(t.innerText=e,t.focus(),t.ownerDocument.getSelection()?.selectAllChildren(t))},[]),Xn("div",{ref:n,contentEditable:"plaintext-only",role:"textbox",suppressContentEditableWarning:!0,className:"slides-cell-edit",onPointerDown:e=>e.stopPropagation(),onBlur:e=>t(e.currentTarget.innerText.replace(/\n+$/,"")),onKeyDown:e=>{e.stopPropagation(),"Escape"===e.key&&t(null),"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e.currentTarget.blur())}})}function Zn({slide:e,selected:t,onSelect:n,onLive:i,onSettle:l,onCommit:r,onEditing:o,onLink:s,cells:a,onCells:d,onContextMenu:c,visitors:m=[],pins:u=[],onPin:p,grid:f,slideNumber:b}){const g=An(null),[v,y]=Pn(0),[k,w]=Pn(Qn),[x,C]=Pn(null),[S,N]=Pn(null),[z,I]=Pn(null),M=An(null);En(()=>{const e=g.current;if(!e)return;const t=()=>{y(Math.max(0,Math.min(e.clientWidth-48,(e.clientHeight-48)*le/ie)))};t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);const E=v/le,P=An(null),F=e=>{const t=P.current?.getBoundingClientRect();return{x:(e.clientX-(t?.left??0))/E,y:(e.clientY-(t?.top??0))/E}},L=(t,n,i=!1)=>{for(let l=e.elements.length-1;l>=0;l-=1){const r=e.elements[l];if(r.locked&&!i)continue;const o=-r.rotation*Math.PI/180,s=t-(r.x+r.w/2),a=n-(r.y+r.h/2),d=s*Math.cos(o)-a*Math.sin(o),c=s*Math.sin(o)+a*Math.cos(o);if(Math.abs(d)<=r.w/2&&Math.abs(c)<=r.h/2)return r}return null},j=(e,t)=>{e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),M.current=t},$=l=>{const r=M.current;if(!r)return;const{x:o,y:s}=F(l);if("marquee"===r.kind){const t={x:Math.min(r.px,o),y:Math.min(r.py,s),w:Math.abs(o-r.px),h:Math.abs(s-r.py)};C(t);const i=new Set(e.elements.filter(e=>!e.locked&&ae(t,e)).map(e=>e.id));n($n(e,i))}else if("move"===r.kind){const e=r.start.elements.filter(e=>t.has(e.id)),n=r.start.elements.filter(e=>!t.has(e.id)),a=se(e),d={...a,x:a.x+o-r.px,y:a.y+s-r.py},c=l.altKey?{box:d,guides:Qn}:ke(d,n);w(c.guides);const m=c.box.x-a.x,u=c.box.y-a.y;i(T(we(r.start,t,e=>ye(e,m,u)),t))}else if("resize"===r.kind){const e=we(r.start,new Set([r.id]),e=>{const t=-e.rotation*Math.PI/180,n=o-r.px,i=s-r.py,a=n*Math.cos(t)-i*Math.sin(t),d=n*Math.sin(t)+i*Math.cos(t);return{...e,...ve(e,r.handle,a,d,l.shiftKey)}});i(T(e))}else if("rotate"===r.kind){const e=we(r.start,new Set([r.id]),e=>({...e,rotation:re(e,o,s,l.shiftKey)}));i(T(e))}else{const e=r.start.elements.find(e=>e.id===r.id&&"connector"===e.type);if(!e)return;const t=l.altKey?null:D(r.start.elements,o,s,e.id),n=t?{x:t.x,y:t.y,attach:{id:t.id,side:t.side}}:{x:o,y:s},a="start"===r.end?n:e.start,d="end"===r.end?n:e.end;i(we(r.start,new Set([e.id]),()=>G(e,a,d)))}},R=()=>{const e=M.current;M.current=null,w(Qn),C(null),e&&"marquee"!==e.kind&&l()},B=e.elements.filter(e=>t.has(e.id)),O=1===B.length?B[0]:void 0,K=e.elements.find(e=>e.id===S&&"text"===e.type),U=An({slide:e,onCommit:r});U.current={slide:e,onCommit:r};const H=(e,t=null,n="slides-selection",i)=>Gn("div",{className:n,style:{left:e.x*E,top:e.y*E,width:e.w*E,height:e.h*E,transform:e.rotation?`rotate(${e.rotation}deg)`:void 0,...i?{borderColor:i.color}:{}},children:[i&&Xn("span",{className:"slides-visitor-name",style:{background:i.color},children:i.name}),t]},`${n}-${e.id}-${i?.name??""}`),V="table"===O?.type?O:null;return Xn("div",{ref:g,className:"slides-pane",children:Gn("div",{ref:P,className:"slides-stage",style:{width:v,height:v*ie/le},onPointerDown:i=>{if(0!==i.button)return;S&&N(null);const{x:l,y:r}=F(i),o=L(l,r);if(!o)return i.shiftKey||n(new Set),d(null),void j(i,{kind:"marquee",px:l,py:r});if("table"===o.type&&t.has(o.id)&&1===t.size){const e=i.target.closest("[data-cell]")?.dataset.cell;if(e){const[t,n]=e.split(":").map(Number);if(i.shiftKey&&a){const e=Math.min(a.row,t),i=Math.min(a.col,n);return void d({row:e,col:i,rows:Math.max(a.row+a.rows-1,t)-e+1,cols:Math.max(a.col+a.cols-1,n)-i+1})}d({row:t,col:n,rows:1,cols:1})}}else d(null);let s=t;const c=$n(e,new Set([o.id]));if(i.shiftKey){const e=new Set(t),i=!e.has(o.id);for(const t of c)i?e.add(t):e.delete(t);s=e,n(e)}else t.has(o.id)||(s=c,n(s));s.has(o.id)&&j(i,{kind:"move",start:e,px:l,py:r})},onPointerMove:$,onPointerUp:R,onPointerCancel:R,onContextMenu:i=>{const{x:l,y:r}=F(i),o=L(l,r,!0);o&&!t.has(o.id)&&n($n(e,new Set([o.id]))),c(i,o?.id??null)},onDoubleClick:e=>{const{x:t,y:i}=F(e),l=L(t,i);if("text"===l?.type)n(new Set([l.id])),N(l.id);else if("table"===l?.type){const t=e.target.closest("[data-cell]")?.dataset.cell;if(t){const[e,n]=t.split(":").map(Number);I({id:l.id,row:e,col:n})}}},children:[Xn(h,{slide:e,width:v,number:b,editingId:K?.id,options:V?{cellEditor:(J=V,(t,n)=>z&&z.id===J.id&&z.row===t&&z.col===n?Xn(Yn,{text:J.rows[t][n],onDone:i=>{I(null),null!==i&&i!==J.rows[t][n]&&r(we(e,new Set([J.id]),()=>W(J,t,n,i)))}}):void 0)}:void 0,editor:K&&Xn(Jn,{element:K,onCommit:(_=K.id,e=>{const{slide:t,onCommit:n}=U.current,i=t.elements.find(e=>e.id===_&&"text"===e.type);if(!i)return;const l=Q(i,e);JSON.stringify(l.paragraphs)===JSON.stringify(A(i))&&l.text===i.text||n(we(t,new Set([_]),()=>l))}),onEnd:()=>N(null),onEditing:o,onLinkShortcut:s},K.id)}),f&&Xn("div",{className:"slides-grid",style:{backgroundSize:`${60*E}px ${60*E}px`}}),m.flatMap(t=>e.elements.filter(e=>t.selected.includes(e.id)).map(e=>H(e,null,"slides-visitor",t))),!K&&B.map(t=>H(t,O?.id!==t.id||t.locked?t.locked?Xn("span",{className:"slides-lock","aria-hidden":"true"}):null:(t=>"connector"===t.type?["start","end"].map(n=>{const i=t[n];return Xn("div",{className:"slides-handle slides-end","data-held":i.attach?"":void 0,style:{left:(i.x-t.x)*E,top:(i.y-t.y)*E},onPointerDown:i=>j(i,{kind:"end",start:e,id:t.id,end:n}),onPointerMove:$,onPointerUp:R,onPointerCancel:R},n)}):Gn(qn,{children:[ee.map(n=>Xn("div",{className:`slides-handle slides-handle-${n}`,onPointerDown:i=>j(i,{kind:"resize",start:e,id:t.id,handle:n,...ti(F(i))}),onPointerMove:$,onPointerUp:R,onPointerCancel:R},n)),Xn("div",{className:"slides-rotate-stem"}),Xn("div",{className:"slides-rotate",onPointerDown:n=>j(n,{kind:"rotate",start:e,id:t.id}),onPointerMove:$,onPointerUp:R,onPointerCancel:R})]}))(t))),V&&a&&Xn("div",{className:"slides-cells","aria-hidden":"true",style:ei(P.current,V,a,E)}),u.map(e=>Xn("button",{type:"button",className:"slides-pin",style:{left:e.x*E,top:e.y*E},onPointerDown:e=>e.stopPropagation(),onClick:()=>p?.(e.id),children:e.count},e.id)),k.x.map(e=>Xn("div",{className:"slides-guide slides-guide-x",style:{left:e*E}},`x${e}`)),k.y.map(e=>Xn("div",{className:"slides-guide slides-guide-y",style:{top:e*E}},`y${e}`)),x&&Xn("div",{className:"slides-marquee",style:{left:x.x*E,top:x.y*E,width:x.w*E,height:x.h*E}})]})});var _,J}function ei(e,t,n,i){const l=e?.querySelector(`[data-element="${CSS.escape(t.id)}"] [data-cell="${n.row}:${n.col}"]`),r=e?.querySelector(`[data-element="${CSS.escape(t.id)}"] [data-cell="${n.row+n.rows-1}:${n.col+n.cols-1}"]`)??l;if(!e||!l||!r)return{display:"none"};const o=e.getBoundingClientRect(),s=l.getBoundingClientRect(),a=r.getBoundingClientRect();return{left:s.left-o.left,top:s.top-o.top,width:a.right-s.left,height:a.bottom-s.top}}var ti=({x:e,y:t})=>({px:e,py:t});import{ColorPicker as ni,DropdownMenu as ii,IconButton as li,prompt as ri,Select as oi}from"efficient-shell/ui";import{Icon as si}from"efficient-shell/icons";import{toast as ai}from"efficient-shell";import{jsx as di,jsxs as ci}from"react/jsx-runtime";var mi=[12,16,20,24,28,32,40,48,56,64,72,96,120,160],ui=[1,1.15,1.25,1.5,2];function hi({element:e,editing:t,slides:n,accents:i,onBox:l}){const r=c(),o=A(e),s=P(o).length,a=t?t.style:V(o,0,s),d=t?t.paragraph:o[0]??{runs:[]},m=a.size??(t?.hasRange?void 0:e.fontSize)??e.fontSize,u=a.font??e.font??Z[0],h=a.bold??e.bold,f=e=>{t?t.applyRun(e):l(t=>{const n={},i={...e};"size"in e&&e.size&&(n.fontSize=e.size,i.size=void 0),"bold"in e&&(n.bold=!!e.bold,i.bold=void 0),"color"in e&&e.color&&(n.color=e.color,i.color=void 0),"font"in e&&e.font&&(n.font=e.font,i.font=void 0);const l=A(t);return Q({...t,...n},p(l,0,P(l).length,i))})},b=e=>{t?t.applyParagraph(e):l(t=>Q(t,O(A(t),0,Number.MAX_SAFE_INTEGER,e)))},g=e=>{t?t.toggleList(e):l(t=>Q(t,_(A(t),0,Number.MAX_SAFE_INTEGER,e)))},v=e=>{t?t.indent(e):l(t=>Q(t,w(A(t),0,Number.MAX_SAFE_INTEGER,e)))},y=async()=>{const e=await ri({title:r.link,message:r.linkPrompt,allowEmpty:!0,defaultValue:a.link?.startsWith("#slide=")?"":a.link??""});if(null==e)return;if(!e.trim())return void f({link:void 0});const t=function(e,t){const n=e.trim();if(!n)return null;if(/^\d+$/.test(n)){const e=t[Number(n)-1];return e?`#slide=${e.id}`:null}return/^(https?:\/\/|mailto:)/i.test(n)?n:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?`mailto:${n}`:/^[\w-]+(\.[\w-]+)+(\/\S*)?$/.test(n)?`https://${n}`:null}(e,n);t?f({link:t}):ai.error(r.badLink)},k=e=>{const t=mi.findIndex(e=>e>=m),n=-1===t?mi.length-1:1===e?mi[t]>m?t:t+1:t-1;return mi[Math.max(0,Math.min(mi.length-1,n))]},x=d.align??e.align,C=(e,t,n,i)=>di(li,{"aria-label":e,size:"sm",pressed:i,onClick:n,children:di(si,{name:t,size:16})},e);return ci("div",{className:"slides-toolbar slides-texttools","data-text-toolbar":"",onMouseDown:e=>{e.target.closest('input, select, [role="combobox"], [role="listbox"]')||e.preventDefault()},children:[di("div",{className:"slides-tool-font",children:di(oi,{"aria-label":r.font,size:"sm",value:u,onChange:e=>f({font:String(e)}),options:Z.map(e=>({value:e,label:e}))})}),C(r.smaller,"remove",()=>f({size:k(-1)})),di("div",{className:"slides-tool-size",children:di(oi,{"aria-label":r.fontSize,size:"sm",value:String(Math.round(m)),onChange:e=>f({size:Number(e)}),options:[...new Set([...mi,Math.round(m)])].sort((e,t)=>e-t).map(e=>({value:String(e),label:String(e)}))})}),C(r.larger,"add",()=>f({size:k(1)})),di("span",{className:"slides-tool-gap"}),C(r.bold,"bold",()=>f({bold:!h}),h),C(r.italic,"italic",()=>f({italic:!a.italic||void 0}),!!a.italic),C(r.underline,"underline",()=>f({underline:!a.underline||void 0}),!!a.underline),C(r.strikethrough,"strike",()=>f({strike:!a.strike||void 0}),!!a.strike),di(ni,{label:r.textColour,size:"sm",value:a.color??e.color,presets:i,onChange:e=>f({color:e})}),di(ni,{label:r.highlight,size:"sm",value:a.highlight??"#ffffff",presets:["#fac775","#c0dd97","#b5d4f4","#f4c0d1"],clearable:!0,onChange:e=>f({highlight:e||void 0})}),C(r.link,"link",()=>{y()},!!a.link),di("span",{className:"slides-tool-gap"}),C(r.alignLeft,"align-left",()=>b(e=>({...e,align:"left"})),"left"===x),C(r.alignCentre,"align-center",()=>b(e=>({...e,align:"center"})),"center"===x),C(r.alignRight,"align-right",()=>b(e=>({...e,align:"right"})),"right"===x),C(r.alignJustify,"align-justify",()=>b(e=>({...e,align:"justify"})),"justify"===x),di("span",{className:"slides-tool-gap"}),C(r.bulletList,"list",()=>g("bullet"),"bullet"===d.list),C(r.numberedList,"numbered-list",()=>g("number"),"number"===d.list),C(r.indentLess,"chevron-left",()=>v(-1)),C(r.indentMore,"chevron-right",()=>v(1)),di(ii,{"aria-label":r.lineSpacing,trigger:di(si,{name:"line-spacing",size:16}),items:ui.map(e=>({type:"radio",key:String(e),label:String(e),checked:(d.lineHeight??1.25)===e,onSelect:()=>b(t=>({...t,lineHeight:1.25===e?void 0:e}))}))}),di(ii,{"aria-label":r.verticalAlign,trigger:di(si,{name:"v-align",size:16}),items:[...["top","middle","bottom"].map(t=>({type:"radio",key:t,label:r[t],checked:(e.anchor??"top")===t,onSelect:()=>l(e=>({...e,anchor:t}))})),{type:"divider",key:"d"},{type:"checkbox",key:"fit",label:r.shrinkToFit,checked:!!e.autofit,onSelect:()=>l(e=>({...e,autofit:!e.autofit||void 0}))}]})]})}import{SettingsColour as pi}from"efficient-easel/panel";import{Select as fi,Switch as bi}from"efficient-shell/ui";import{jsx as gi,jsxs as vi}from"react/jsx-runtime";function yi({doc:e,slide:t,onTheme:i,onDeck:l,onSlide:r}){const a=c(),d=s(e),m=e=>i({...d,...e,id:n.some(t=>t.id===d.id&&JSON.stringify({...t,...e})===JSON.stringify(t))?d.id:"custom"}),u={title:"Aa",subtitle:"",body:""};return vi("aside",{className:"slides-inspector",children:[gi("h3",{children:a.theme}),gi("div",{className:"slides-section",children:gi("div",{className:"slides-themes",children:n.map(e=>vi("button",{type:"button",className:"slides-theme-tile","aria-pressed":e.id===d.id,onClick:()=>i(e),children:[gi(h,{slide:{...o("title",e,u),elements:o("title",e,u).elements.slice(0,1)},width:96}),gi("span",{children:a.themeName(e.id)})]},e.id))})}),vi("div",{className:"slides-section",children:[gi("p",{className:"slides-label",children:a.colours}),gi(pi,{label:a.background,value:d.background,onChange:e=>m({background:e})}),gi(pi,{label:a.headingFont,value:d.heading,onChange:e=>m({heading:e})}),gi(pi,{label:a.bodyFont,value:d.text,onChange:e=>m({text:e})}),gi("div",{className:"slides-swatches","aria-hidden":"true",children:d.accents.map(e=>gi("span",{style:{background:e}},e))})]}),vi("div",{className:"slides-section",children:[gi(fi,{"aria-label":a.headingFont,value:d.headingFont,onChange:e=>m({headingFont:String(e)}),options:Z.map(e=>({value:e,label:`${a.headingFont}: ${e}`}))}),gi(fi,{"aria-label":a.bodyFont,value:d.bodyFont,onChange:e=>m({bodyFont:String(e)}),options:Z.map(e=>({value:e,label:`${a.bodyFont}: ${e}`}))})]}),vi("div",{className:"slides-section",children:[gi(bi,{label:a.slideNumbers,checked:!!e.slideNumbers,onChange:e=>l({slideNumbers:e||void 0})}),gi(bi,{label:a.skipSlide,checked:!!t.skip,onChange:e=>r({skip:e||void 0})})]})]})}import{useEffect as ki,useRef as wi,useState as xi}from"react";var Ci=["#1d9e75","#d85a30","#378add","#d4537e","#ba7517","#639922","#7f77dd","#993c1d"];function Si(e){let t=0;for(const n of e)t=31*t+n.charCodeAt(0)>>>0;return Ci[t%Ci.length]}var Ni=13.333,zi=e=>e/le*Ni,Ii=e=>e.replace("#","").toUpperCase(),Di=e=>Math.round(72*zi(e));function Mi(e){return`${e.replace(/[^\p{L}\p{N} _-]+/gu," ").replace(/ +/g," ").trim()||"Deck"}.pptx`}var Ei=e=>e===te?{type:"none"}:{color:Ii(e)},Ai=e=>e.stroke?{color:Ii(e.stroke),width:Di(e.strokeWidth??1)}:void 0;function Pi(e,t,n,i){const l=e.cellFills?.[n]?.[i]??(0===n?e.headerFill:null),r=e.cellColors?.[n]?.[i]??(0===n?e.headerColor:void 0),o=e.merges?.find(e=>e.row===n&&e.col===i);return{text:t,options:{...0===n?{bold:!0}:{},...l?{fill:Ei(l)}:{},...r?{color:Ii(r)}:{},...o?{rowspan:o.rows,colspan:o.cols}:{}}}}var Fi={bar:"bar",hbar:"bar",line:"line",area:"area",pie:"pie",donut:"doughnut"};function Ti(e,t,n){const i={x:zi(n.x),y:zi(n.y),w:zi(n.w),h:zi(n.h),rotate:n.rotation};switch(n.type){case"text":!function(e,t,n){const i=A(t),l=S(i),r=[];i.forEach((e,n)=>{const o=e.runs.length>0?e.runs:[{text:""}];o.forEach((s,a)=>{const d=a===o.length-1;r.push({text:s.text,options:{bold:s.bold??t.bold,italic:s.italic,underline:s.underline||s.link?{style:"sng"}:void 0,strike:s.strike?"sngStrike":void 0,color:Ii(s.color??t.color),highlight:s.highlight?Ii(s.highlight):void 0,fontSize:Di(s.size??t.fontSize),fontFace:s.font??t.font??Y,hyperlink:s.link&&!s.link.startsWith("#")?{url:s.link}:void 0,align:e.align??t.align,bullet:l[n]?"number"!==e.list||{type:"number"}:void 0,indentLevel:e.level||void 0,lineSpacingMultiple:e.lineHeight,breakLine:d&&n<i.length-1}})})}),e.addText(r,{...n,valign:t.anchor??"top",margin:0,fit:t.autofit?"shrink":void 0})}(t,n,i);break;case"shape":!function(e,t,n,i){"line"!==n.shape?t.addShape(u[n.shape],{...i,fill:Ei(n.fill),line:Ai(n),rectRadius:"roundRect"===n.shape&&void 0!==n.radius?zi(n.radius):void 0}):t.addShape(e.ShapeType.line,{...i,y:i.y+i.h/2,h:0,line:{color:Ii(n.stroke??n.fill),width:Di(n.strokeWidth??1),beginArrowType:n.arrowStart?"triangle":"none",endArrowType:n.arrowEnd?"triangle":"none"}})}(e,t,n,i);break;case"image":{if(!n.src)break;const e=n.crop;t.addImage({...i,path:n.src,altText:n.alt,transparency:void 0!==n.opacity?Math.round(100*(1-n.opacity)):void 0,...e&&(e.left||e.top||e.right||e.bottom)?{sizing:{type:"crop",x:zi(n.w*e.left/Math.max(.05,1-e.left-e.right)),y:zi(n.h*e.top/Math.max(.05,1-e.top-e.bottom)),w:i.w,h:i.h}}:{}});break}case"video":{const e=X(n.src);"youtube"===e?.kind?t.addMedia({...i,type:"online",link:`https://www.youtube.com/embed/${e.id}`}):n.src&&t.addText([{text:n.alt||n.src,options:{hyperlink:{url:n.src}}}],{...i,align:"center",valign:"middle",fill:{color:"2C2C2A"},color:"FFFFFF"});break}case"connector":!function(e,t,n){const i={color:Ii(n.stroke),width:Di(n.strokeWidth),beginArrowType:n.arrowStart?"triangle":"none",endArrowType:n.arrowEnd?"triangle":"none"};if("straight"===n.route){const l=Math.min(n.start.x,n.end.x),r=Math.min(n.start.y,n.end.y);return void t.addShape(e.ShapeType.line,{x:zi(l),y:zi(r),w:zi(Math.abs(n.end.x-n.start.x)),h:zi(Math.abs(n.end.y-n.start.y)),flipH:n.end.x<n.start.x!=n.end.y<n.start.y&&n.end.x<n.start.x,flipV:n.end.x<n.start.x!=n.end.y<n.start.y&&n.end.y<n.start.y,line:i})}const l=v(n),r=l.match(/-?\d+(\.\d+)?/g)?.map(Number)??[],o=[];if("elbow"===n.route){let e=r[0],t=r[1];o.push({x:e,y:t});for(const n of l.slice(l.indexOf(" ")+1).split(" ")){const i=Number(n.slice(1));"H"===n[0]?e=i:t=i,o.push({x:e,y:t})}}else{const[e,t,n,i,l,s,a,d]=r;for(let r=0;r<=16;r+=1){const c=r/16,m=1-c;o.push({x:m*m*m*e+3*m*m*c*n+3*m*c*c*l+c*c*c*a,y:m*m*m*t+3*m*m*c*i+3*m*c*c*s+c*c*c*d})}}t.addShape("custGeom",{x:zi(n.x),y:zi(n.y),w:zi(n.w),h:zi(n.h),points:o.map((e,t)=>0===t?{x:zi(e.x),y:zi(e.y),moveTo:!0}:{x:zi(e.x),y:zi(e.y)}),line:i})}(e,t,n);break;case"chart":!function(e,t,n,i){const{categories:l,series:r}=B(n),o="pie"===n.kind||"donut"===n.kind,s=(o?r.slice(0,1):r).map(e=>({name:e.name||" ",labels:l,values:e.values})),a=n.legend??(o||r.length>1?"bottom":"none");t.addChart(Fi[n.kind],s,{...i,barDir:"hbar"===n.kind?"bar":"col",chartColors:o?void 0:r.map(e=>Ii(e.color)),showValue:1===r.length&&!o,showPercent:o,showLegend:"none"!==a,legendPos:"right"===a?"r":"b"})}(0,t,n,i);break;case"table":!function(e,t,n){const{columnWidths:i,rowHeights:l,fontSize:r}=t,o=t.rows.map((e,n)=>e.flatMap((e,i)=>((e,t,n)=>e.merges?.some(e=>t>=e.row&&t<e.row+e.rows&&n>=e.col&&n<e.col+e.cols&&(t!==e.row||n!==e.col)))(t,n,i)?[]:[Pi(t,e,n,i)])),s=t.borderWidth??2;e.addTable(o,{...n,border:s?{type:"solid",color:Ii(t.borderColor??"#B4B2A9"),pt:Math.max(.25,Di(s))}:{type:"none"},...r?{fontSize:Di(r)}:{},...i?{colW:i.map(e=>e*n.w)}:{},...l?{rowH:l.map(zi)}:{}})}(t,n,i)}}async function Li(e,t){const n=await async function(e,t){const{default:n}=await(import("pptxgenjs")),i=new n;return i.defineLayout({name:"SLIDE_16_9",width:Ni,height:7.5}),i.layout="SLIDE_16_9",i.title=e,t.slides.forEach(e=>{const n=i.addSlide();n.background={color:Ii(e.background)},e.skip&&(n.hidden=!0),e.notes&&n.addNotes(e.notes);for(const t of e.elements)Ti(i,n,t);t.slideNumbers&&(n.slideNumber={x:zi(1780),y:zi(1010),fontSize:11,color:"888780"})}),i}(e,t);await n.writeFile({fileName:Mi(e)})}import{jsx as ji,jsxs as $i}from"react/jsx-runtime";var Ri=(e,t)=>e===t||JSON.stringify(e)===JSON.stringify(t),Bi=(e,t)=>({title:e.layoutTitle,titleBody:e.layoutTitleBody,section:e.layoutSection,twoColumns:e.layoutTwoColumns,titleOnly:e.layoutTitleOnly,blank:e.layoutBlank}[t]);function Wi({onPick:e}){const t=c();return ji(He,{"aria-label":t.addShape,triggerLabel:t.addShape,trigger:ji(qe,{name:"shape-rect",size:16}),children:({close:n})=>ji("div",{className:"slides-shape-grid",role:"listbox","aria-label":t.addShape,children:ne.filter(e=>"line"!==e).map(i=>ji("button",{type:"button",title:t.shapeName(i),"aria-label":t.shapeName(i),onClick:()=>{e(i),n()},children:ji("svg",{viewBox:"-2 -2 28 28",width:22,height:22,"aria-hidden":"true",children:ji("path",{d:K(i,24,24),fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinejoin:"round"})})},i))})})}function Oi(e,t){return kt(t).filter(t=>t.first.slideId===e.id&&!t.first.resolvedAt).map((t,n)=>{const i=e.elements.find(e=>e.id===t.first.elementId);return{id:t.first.id,x:i?i.x+i.w-8:1880-40*n,y:i?i.y-28:16,count:1+t.replies.length}})}function Ki({deck:n,onClose:m,onReload:u}){const f=c(),b=d(),{store:g}=b,[v,y]=De(n.title),[k,w]=ze(me,void 0,()=>({past:[],present:oe(n.document),future:[]})),x=k.present,C=s(x),[S,N]=De(x.slides[0].id),[z,I]=De(new Set),[D,M]=De(!0),[E,F]=De(null),[L,j]=De("inspector"),[$,R]=De(null),[B,W]=De(null),[O,K]=De(!1),[U,H]=De(null),[V,_]=De([]),[J,q]=De(null),[X,G]=De(0),Y=Ie(null),Z=Ie(""),ee=x.slides.find(e=>e.id===S)??x.slides[0],te=x.slides.indexOf(ee);Se(()=>l(document,r(x)),[x]);const ne=Ie(n.version),ie=Ie(oe(n.document)),le=Ie(x);le.current=x;const[re,ae]=De(!1),ve=Ie(!1),ke=Ce(async()=>{const t=await g.get(n.id),i=oe(t.document),l=ie.current,r=le.current,o=e(l,r,i);return w({type:"rebase",rebase:t=>e(l,t,i)}),ie.current=i,ne.current=t.version,Ri(r,l)||ve.current||(ve.current=!0,Xe.info(f.merged)),o},[n.id,g,f.merged]),He=Ie(Promise.resolve()),Ge=je(),Qe=Ee({save:async t=>{await He.current.catch(()=>{});let i=t;for(let t=0;;t+=1)try{return ne.current=await g.save(n.id,i,ne.current),ie.current=i,void G(e=>e+1)}catch(n){if(!(n instanceof a)||t>=3)throw n;const l=ie.current;await ke(),i=e(l,i,ie.current)}},onFailure:(e,t)=>{e instanceof a?(Qe.stop(),ae(!0)):0===t&&Xe.error(f.saveFailed)}}),Ye=Ie(x),{push:Ze,flush:et}=Qe;Se(()=>{x!==Ye.current&&(Ye.current=x,Ri(x,ie.current)||Ze(x))},[x,Ze]),Se(()=>()=>{et()},[et]);const tt=Ce(()=>{b.comments?.list(n.id).then(_,()=>{})},[b.comments,n.id]);Se(tt,[tt]);const nt=Ne(()=>[...z],[z]),it=function(e,t,n,i){const[l,r]=xi([]),o=wi(null),s=wi(n);s.current=n;const a=wi(i);a.current=i,ki(()=>{if(!e.live)return;const n=e.live(t,e=>{if("saved"===e.event)return a.current.saved(e.payload.version);if("comments"===e.event)return a.current.comments();if("bye"===e.event)return r(t=>t.filter(t=>t.key!==e.payload.key));const{user:t,key:n,slide:i,selected:l}=e.payload;r(e=>[...e.filter(e=>e.key!==n),{key:n,user:t,slide:i,selected:l,color:Si(t.id)}]),"hello"===e.event&&o.current?.send({type:"presence",...s.current})});return o.current=n,n.send({type:"hello",...s.current}),()=>{n.close(),o.current=null,r([])}},[e,t]);const d=JSON.stringify(n);return ki(()=>{o.current?.send({type:"presence",...s.current})},[d]),l}(b,n.id,{slide:ee.id,selected:nt},{saved:e=>{e===ne.current||Date.parse(e)&&Date.parse(e)===Date.parse(ne.current)||(He.current=He.current.then(()=>Qe.hasPending()?void 0:ke()).catch(()=>{}))},comments:tt}),lt=it.filter(e=>e.slide===ee.id).map(e=>({key:e.key,name:e.user.name,color:e.color,selected:e.selected})),rt=Ce(e=>w({type:"commit",doc:e}),[]),ot=e=>rt(xe(x,ee.id,()=>e)),st=e=>ot(T(we(ee,z,e))),at=Ie(null),dt=e=>{N(e),I(new Set),W(null)},ct={text:C.text,accents:C.accents,shapeFill:x.theme?C.accents[0]:"#afa9ec",bodyFont:C.bodyFont},mt=e=>{ot({...ee,elements:[...ee.elements,e]}),I(new Set([e.id])),j("inspector")},ut=e=>mt(pe(e,ct)),ht=e=>{const t=pe("connector",ct);mt({...t,route:"elbow"===e?"elbow":"curved"===e?"curved":"straight",arrowEnd:"line"!==e,arrowStart:"double"===e||void 0})},pt={title:f.placeholderTitle,subtitle:f.placeholderSubtitle,body:f.placeholderBody},ft=(e=("title"===ee.layout?"titleBody":ee.layout??"titleBody"))=>{const t=o(e,C,pt);rt(ue(x,ee.id,t)),dt(t.id)},gt=()=>{ot(T(be(ee,z))),I(new Set)},vt=e=>{const t=$n(ee,z);switch(e.kind){case"align":return ot(T(function(e,t,n){const i=e.elements.filter(e=>t.has(e.id));if(0===i.length)return e;const l=1===new Set(i.map(e=>e.groupId??e.id)).size?jn:se(i),r=e=>e.groupId??e.id,o=new Map;for(const e of i){const t=r(e);o.set(t,o.has(t)?se([o.get(t),e]):e)}const s=e=>{switch(n){case"left":return{dx:l.x-e.x,dy:0};case"right":return{dx:l.x+l.w-e.x-e.w,dy:0};case"center":return{dx:l.x+(l.w-e.w)/2-e.x,dy:0};case"top":return{dx:0,dy:l.y-e.y};case"bottom":return{dx:0,dy:l.y+l.h-e.y-e.h};case"middle":return{dx:0,dy:l.y+(l.h-e.h)/2-e.y}}},a=new Map([...o].map(([e,t])=>[e,s(t)]));return we(e,t,e=>{const{dx:t,dy:n}=a.get(r(e));return ye(e,t,n)})}(ee,t,e.to),t));case"distribute":return ot(T(function(e,t,n){const i=e.elements.filter(e=>t.has(e.id));if(i.length<3)return e;const l=e=>"horizontal"===n?e.x:e.y,r=e=>"horizontal"===n?e.w:e.h,o=[...i].sort((e,t)=>l(e)-l(t)),s=o[0],a=o[o.length-1],d=o.reduce((e,t)=>e+r(t),0),c=(l(a)+r(a)-l(s)-d)/(o.length-1),m=new Map;let u=l(s);for(const e of o)m.set(e.id,u),u+=r(e)+c;return we(e,t,e=>"horizontal"===n?ye(e,m.get(e.id)-e.x,0):ye(e,0,m.get(e.id)-e.y))}(ee,t,e.axis),t));case"order":return ot({front:Tn,forward:de,backward:Fn,back:Ln}[e.to](ee,t));case"group":return ot(function(e,t){if(t.size<2)return e;const n=fe();return we(e,t,e=>({...e,groupId:n}))}(ee,t));case"ungroup":return ot(function(e,t){return we(e,t,({groupId:e,...t})=>t)}(ee,t));case"lock":return ot(function(e,t,n){return we(e,t,({locked:e,...t})=>n?{...t,locked:n}:t)}(ee,t,e.locked))}},yt=e=>{const t=ee.elements.filter(e=>z.has(e.id));if(0===t.length)return;const n=(i=t,JSON.stringify({type:Rn,elements:i}));var i;Z.current=n,navigator.clipboard?.writeText(n).catch(()=>{}),e&>()},wt=async()=>{const e=Bn(await(navigator.clipboard?.readText().catch(()=>""))||Z.current)??Bn(Z.current);if(!e)return;const t=Wn(ee,e);ot(t.slide),I(new Set(t.ids))},xt=()=>{const e=Wn(ee,ee.elements.filter(e=>z.has(e.id)));ot(e.slide),I(new Set(e.ids))},Ct=()=>{b.comments&&j("comments")},Nt=(e=te)=>{const t=window.open("about:blank","_blank","popup,width=1280,height=720");t&&(t.document.title=v),F({popup:t,at:e})},zt=Ie(()=>!1);zt.current=()=>!(E||0===z.size&&!B&&!U)&&(I(new Set),W(null),H(null),!0),Se(()=>Ve(()=>zt.current()),[]);const It=Je(),Dt=z.size>0,Mt=ee.elements.filter(e=>z.has(e.id)),Et=Dt&&Mt.every(e=>e.locked),At=[{type:"submenu",key:"order",label:f.order,disabled:!Dt,items:[{key:"front",label:f.bringToFront,onSelect:()=>vt({kind:"order",to:"front"})},{key:"forward",label:f.bringForward,onSelect:()=>vt({kind:"order",to:"forward"})},{key:"backward",label:f.sendBackward,onSelect:()=>vt({kind:"order",to:"backward"})},{key:"back",label:f.sendToBack,onSelect:()=>vt({kind:"order",to:"back"})}]},{type:"submenu",key:"align",label:f.align,disabled:!Dt,items:gn(f).map(({label:e,action:t})=>({key:e,label:e,onSelect:()=>vt(t)}))},{key:"group",label:f.group,disabled:z.size<2,onSelect:()=>vt({kind:"group"})},{key:"ungroup",label:f.ungroup,disabled:!Mt.some(e=>e.groupId),onSelect:()=>vt({kind:"ungroup"})},{key:"lock",label:Et?f.unlock:f.lock,disabled:!Dt,onSelect:()=>vt({kind:"lock",locked:!Et})},{type:"divider",key:"d-grid"},{type:"checkbox",key:"grid",label:f.grid,checked:O,onSelect:()=>K(e=>!e)}],Pt=It.state?.data?[{key:"cut",label:f.cut,onSelect:()=>yt(!0)},{key:"copy",label:f.copy,onSelect:()=>yt(!1)},{key:"paste",label:f.paste,onSelect:()=>{wt()}},{key:"duplicate",label:f.duplicate,onSelect:xt},{key:"copy-style",label:f.copyStyle,onSelect:()=>{return Y.current=Mt[0]?"text"===(e=Mt[0]).type?{fontSize:e.fontSize,bold:e.bold,color:e.color,font:e.font}:"shape"===e.type?{fill:e.fill,stroke:e.stroke,strokeWidth:e.strokeWidth}:"connector"===e.type?{stroke:e.stroke,strokeWidth:e.strokeWidth}:{}:null;var e}},{key:"paste-style",label:f.pasteStyle,disabled:!Y.current,onSelect:()=>Y.current&&st(e=>function(e,t){if("text"===e.type){const n=A(e);return Q({...e,fontSize:t.fontSize??e.fontSize,bold:t.bold??e.bold,color:t.color??e.color,font:t.font},p(n,0,P(n).length,{size:void 0,bold:void 0,color:void 0,font:void 0}))}return"shape"===e.type?{...e,fill:t.fill??e.fill,stroke:t.stroke,strokeWidth:t.strokeWidth}:"connector"===e.type&&t.stroke?{...e,stroke:t.stroke,strokeWidth:t.strokeWidth??e.strokeWidth}:e}(e,Y.current))},{type:"divider",key:"d1"},...At.slice(0,5),...b.comments?[{type:"divider",key:"d2"},{key:"comment",label:f.comment,onSelect:Ct}]:[],{type:"divider",key:"d3"},{key:"delete",label:f.delete,danger:!0,onSelect:gt}]:[{key:"paste",label:f.paste,onSelect:()=>{wt()}},{key:"new-slide",label:f.newSlide,onSelect:()=>ft()},{key:"skip",label:ee.skip?f.unskipSlide:f.skipSlide,onSelect:()=>ot({...ee,skip:!ee.skip||void 0})},...b.comments?[{key:"comment",label:f.comment,onSelect:Ct}]:[]],Ft=1===Mt.length&&"text"===Mt[0].type?Mt[0]:null,Tt=(e,t,n)=>ji(Ke,{"aria-label":e,onClick:n,children:ji(qe,{name:t,size:16})},e),Lt=e=>j(t=>t===e?"inspector":e),$t=U?U.doc.slides.find(e=>e.id===ee.id)??U.doc.slides[Math.min(te,U.doc.slides.length-1)]:ee;return $i("div",{className:"es-editor slides-editor",onKeyDown:e=>{if(E||U)return;if(e.target.closest('input, textarea, select, [contenteditable], [role="listbox"], [role="menu"], [role="dialog"]'))return;const t=e.metaKey||e.ctrlKey,n=e.key.toLowerCase(),i=z.size>0;if(t&&"z"===n)e.preventDefault(),w({type:e.shiftKey?"redo":"undo"});else if(t&&"y"===n)e.preventDefault(),w({type:"redo"});else if(t&&"a"===n)e.preventDefault(),I(new Set(ee.elements.filter(e=>!e.locked).map(e=>e.id)));else if(t&&"d"===n&&i)e.preventDefault(),xt();else if(t&&("c"===n||"x"===n)&&i)e.preventDefault(),yt("x"===n);else if(t&&"v"===n)e.preventDefault(),wt();else if(t&&"g"===n&&i)e.preventDefault(),vt({kind:e.shiftKey?"ungroup":"group"});else if(t&&e.altKey&&"m"===n)e.preventDefault(),Ct();else if(t&&("ArrowUp"===e.key||"ArrowDown"===e.key)&&i){e.preventDefault();const t="ArrowUp"===e.key;vt({kind:"order",to:e.shiftKey?t?"front":"back":t?"forward":"backward"})}else if("Delete"!==e.key&&"Backspace"!==e.key||!i){if("Escape"===e.key)I(new Set),W(null);else if(e.key.startsWith("Arrow")&&i){e.preventDefault();const t=e.shiftKey?1:10,n="ArrowLeft"===e.key?-t:"ArrowRight"===e.key?t:0,i="ArrowUp"===e.key?-t:"ArrowDown"===e.key?t:0,l=new Set(ee.elements.filter(e=>z.has(e.id)&&!e.locked).map(e=>e.id));ot(T(we(ee,l,e=>ye(e,n,i)),l))}}else e.preventDefault(),gt()},tabIndex:-1,children:[$i(Pe,{children:[$i(Te,{children:[ji(Ae,{label:f.backToDecks,onClick:m,children:ji(qe,{name:"chevron-left",size:16})}),ji(Ae,{label:f.slidesPanel,state:D?"active":"inactive",onClick:()=>M(e=>!e),children:ji(qe,{name:"bars-3-bottom-left",size:16})}),ji("div",{className:"slides-title",children:ji(Ue,{"aria-label":f.deckName,value:v,onChange:e=>y(e.target.value),onBlur:()=>{const e=v.trim();e&&e!==n.title?g.rename(n.id,e).catch(()=>Xe.error(f.renameFailed)):y(e||n.title)}})}),ji(Fe,{...Me(Qe.state,Ge.save)}),ji(Le,{}),ji(Ae,{label:f.undo,disabled:0===k.past.length,onClick:()=>w({type:"undo"}),children:ji(qe,{name:"undo",size:16})}),ji(Ae,{label:f.redo,disabled:0===k.future.length,onClick:()=>w({type:"redo"}),children:ji(qe,{name:"redo",size:16})})]}),$i(Te,{kind:"right",children:[it.length>0&&ji("span",{className:"slides-visitors",title:f.editingNow(it.map(e=>e.user.name).join(", ")),children:ji($e,{size:"sm",max:4,children:[...new Map(it.map(e=>[e.user.id,e])).values()].map(e=>ji(Re,{name:e.user.name,size:"sm"},e.user.id))})}),b.versions&&ji(Ae,{label:f.versionHistory,state:"history"===L?"active":"inactive",onClick:()=>Lt("history"),children:ji(qe,{name:"clock",size:16})}),b.comments&&ji(Ae,{label:f.commentCount(kt(V).filter(e=>!e.first.resolvedAt).length),state:"comments"===L?"active":"inactive",onClick:()=>Lt("comments"),children:ji(qe,{name:"chat",size:16})}),ji(Oe,{"aria-label":f.export,trigger:$i("span",{className:"slides-export-trigger",children:[ji(qe,{name:"download",size:16}),f.export]}),items:[{key:"pptx",label:f.exportPptx,onSelect:()=>{Li(v,x).catch(()=>Xe.error(f.exportFailed))}},{key:"pdf",label:f.exportPdf,onSelect:()=>{(async()=>{const{deckToPdf:e}=await(import("./deckPdf-4RC7QJ45.js")),t=await e(x),n=URL.createObjectURL(t),i=document.createElement("a");i.href=n,i.download=`${v.trim()||"Deck"}.pdf`,i.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)})().catch(()=>Xe.error(f.exportFailed))}}]}),ji(Be,{leftIcon:ji(qe,{name:"play",size:16}),onClick:()=>Nt(),children:f.present})]})]}),re&&$i("div",{className:"slides-conflict",role:"alert",children:[ji("span",{children:f.conflict}),ji(Be,{variant:"secondary",onClick:u,children:f.reload})]}),U&&$i("div",{className:"slides-conflict",role:"status",children:[ji("span",{children:f.previewVersion}),ji(Be,{variant:"secondary",onClick:()=>H(null),children:f.closePreview})]}),$i("div",{className:"slides-body",children:[D&&ji(Mn,{slides:x.slides,currentId:ee.id,numbers:!!x.slideNumbers,visitors:it,onShow:dt,onAdd:()=>ft(),onMove:(e,t)=>rt(he(x,e,t)),onDuplicate:e=>{const t=x.slides.find(t=>t.id===e);if(!t)return;const n=ce(t);rt(ue(x,e,n)),dt(n.id)},onDelete:e=>{const t=ge(x,e);rt(t),e===ee.id&&dt(t.slides[Math.min(te,t.slides.length-1)].id)},onSkip:e=>rt(xe(x,e,e=>({...e,skip:!e.skip||void 0})))}),$i("div",{className:"slides-centre",children:[$i("div",{className:"slides-toolbar",children:[ji(Oe,{"aria-label":f.newSlide,trigger:$i("span",{className:"slides-export-trigger",children:[f.newSlide,ji(qe,{name:"chevron-down",size:14})]}),items:[{type:"label",key:"l",label:f.layouts},...t.map(e=>({key:e,label:Bi(f,e),onSelect:()=>ft(e)}))]}),Tt(f.addText,"type",()=>ut("text")),Tt(f.addImage,"image",()=>ut("image")),ji(Wi,{onPick:e=>mt({...pe("shape",ct),shape:e})}),ji(Oe,{"aria-label":f.addLine,trigger:ji(qe,{name:"line-solid",size:16}),items:[{key:"line",label:f.lineStraight,onSelect:()=>ht("line")},{key:"arrow",label:f.lineArrow,onSelect:()=>ht("arrow")},{key:"double",label:f.lineDoubleArrow,onSelect:()=>ht("double")},{key:"elbow",label:f.connectorElbow,onSelect:()=>ht("elbow")},{key:"curved",label:f.connectorCurved,onSelect:()=>ht("curved")}]}),Tt(f.addTable,"table",()=>ut("table")),Tt(f.addChart,"chart-bar",()=>ut("chart")),Tt(f.addVideo,"block-video",()=>ut("video")),ji("span",{className:"slides-tool-gap"}),ji(Oe,{"aria-label":f.arrange,trigger:$i("span",{className:"slides-export-trigger",children:[f.arrange,ji(qe,{name:"chevron-down",size:14})]}),items:At}),ji(Be,{variant:"theme"===L?"primary":"secondary",size:"sm",onClick:()=>Lt("theme"),children:f.theme}),ji(Be,{variant:"motion"===L?"primary":"secondary",size:"sm",onClick:()=>Lt("motion"),children:f.motion})]}),Ft&&!U&&ji(hi,{element:Ft,editing:$,slides:x.slides,accents:C.accents,onBox:e=>ot(we(ee,new Set([Ft.id]),t=>e(t)))}),U?ji("div",{className:"slides-pane slides-preview",children:ji(h,{slide:$t,width:720,number:U.doc.slideNumbers?te+1:void 0})}):ji(Zn,{slide:ee,selected:z,onSelect:e=>I(e),onLive:e=>{at.current??=x,w({type:"live",doc:xe(at.current,ee.id,()=>e)})},onSettle:()=>{at.current&&w({type:"settle",from:at.current}),at.current=null},onCommit:ot,onEditing:R,onLink:()=>{document.querySelector(`[data-text-toolbar] button[aria-label="${CSS.escape(f.link)}"]`)?.click()},cells:B,onCells:W,onContextMenu:(e,t)=>It.open(e,t),visitors:lt,pins:b.comments?Oi(ee,V):[],onPin:e=>{q(e),j("comments")},grid:O,slideNumber:x.slideNumbers?te+1:void 0},ee.id),$i("label",{className:"slides-notes",children:[ji("span",{children:f.speakerNotes}),ji(_e,{rows:2,value:ee.notes,onChange:e=>ot({...ee,notes:e.target.value})})]})]}),"inspector"===L&&ji(yn,{slide:ee,selected:Mt,onChangeSlide:e=>ot({...ee,...e}),onChangeSelected:st,onAlign:e=>vt({kind:"align",to:e}),onForward:()=>vt({kind:"order",to:"forward"}),onDelete:gt,onArrange:vt,cells:B,accents:C.accents}),"theme"===L&&ji(yi,{doc:x,slide:ee,onTheme:e=>rt(i(x,e)),onDeck:e=>rt({...x,...e}),onSlide:e=>ot({...ee,...e})}),"motion"===L&&ji(bt,{slide:ee,slideNumber:te+1,selected:Mt,onSlide:e=>ot({...ee,...e}),onAllSlides:e=>rt({...x,slides:x.slides.map(t=>({...t,...e}))}),onPlay:()=>Nt(te)}),"comments"===L&&b.comments&&ji(St,{comments:V,slides:x.slides,slide:ee,selectedId:1===Mt.length?Mt[0].id:null,focusId:J,onAdd:async e=>{const t=await b.comments.add(n.id,e);_(e=>[...e,t])},onUpdate:(e,t)=>b.comments.update(n.id,e,t).then(t=>_(n=>n.map(n=>n.id===e?t:n)),()=>Xe.error(f.commentFailed)),onRemove:e=>b.comments.remove(n.id,e).then(()=>_(t=>t.filter(t=>t.id!==e&&t.parent!==e)),()=>Xe.error(f.commentFailed)),onShowSlide:dt}),"history"===L&&ji(jt,{deckId:n.id,previewing:U?.id??null,refreshKey:X,onPreview:(e,t)=>H(e?{id:e,doc:oe(t)}:null),onRestore:e=>{H(null);const t=oe(e);rt(t),t.slides.some(e=>e.id===ee.id)||dt(t.slides[0].id)}})]}),It.state&&ji(We,{...It.props,items:Pt,"aria-label":f.arrange}),E&&ji(tn,{slides:x.slides,startIndex:E.at,numbers:!!x.slideNumbers,fonts:r(x),popup:E.popup,onEnd:()=>F(null)})]})}export{Ki as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{importSpreadsheetFile as e,readWithSheetJs as t}from"./chunk-3KJZFUBH.js";import{readXlsx as r,writeXlsx as n}from"./chunk-4M3QRYCH.js";import{SPREADSHEET_ACCEPT as o,SPREADSHEET_EXTENSIONS as l,SpreadsheetsConflict as a,sheetsOf as i,useSpreadsheetWords as c,useSpreadsheetsHost as s}from"./chunk-4MGZXE3N.js";import"./chunk-MZJSGEU3.js";import{DEFAULT_COL_WIDTH as u,DEFAULT_FONT_SIZE as d,DEFAULT_ROW_HEIGHT as f,FUNCTION_NAMES as h,MAX_COLS as m,MAX_ROWS as g,NUMBER_FORMATS as p,adjustDecimals as v,applyBorders as w,cellDisplay as x,cellLabel as b,changeStructure as y,clearValues as C,colLabel as k,columnValues as N,commitEntry as S,copyClip as D,cycleRefAbsolute as E,dataRegion as R,deleteSheet as T,duplicateSheet as M,editText as A,expandForMerges as z,fillRange as F,filteredRows as I,findCells as O,formatKey as L,formatNumber as P,isFormula as U,makeEvaluator as $,mergeRange as B,mergedAt as H,moveCells as K,newSheet as X,nextSheetName as W,normalizeRange as G,parseCsv as V,parseRangeLabel as Y,pasteClip as j,printRef as _,rangeContains as Z,rangeLabel as Q,rawAt as q,readEntry as J,renameSheet as ee,replaceInCell as te,selectionStats as re,serializeCsv as ne,sheetFromRows as oe,shiftFormula as le,sortRange as ae,tokenize as ie,unmergeRange as ce,updateFormats as se,usedBounds as ue,withFormat as de,writeCells as fe}from"./chunk-UDEPDAZI.js";import{FileList as he}from"./chunk-PMGQ5GUH.js";import"./chunk-B32ASXHM.js";import{placeCopy as me}from"./chunk-XYVQTQ6N.js";import{useCallback as ge,useEffect as pe,useMemo as ve,useRef as we,useState as xe}from"react";import{saveIndicator as be,useAutosave as ye}from"efficient-easel/autosave";import{SaveState as Ce}from"efficient-easel/chrome";import"efficient-easel/chrome.css";import{useEaselStrings as ke}from"efficient-easel/strings";import{WindowTitle as Ne,useBrowserLayoutEffect as Se,useWindowDirty as De}from"efficient-shell";import{Icon as Ee}from"efficient-shell/icons";import{Button as Re,Checkbox as Te,ColorPickerPanel as Me,ContextMenu as Ae,DropdownMenu as ze,EmptyState as Fe,IconButton as Ie,Input as Oe,LoadingSpinner as Le,Popover as Pe,PopupMenu as Ue,PopupMenuDivider as $e,PopupMenuItem as Be,confirmDestructive as He,registerModalEscapeInterceptor as Ke,toDateKey as Xe,toast as We,useContextMenu as Ge}from"efficient-shell/ui";import{SPREADSHEET_PREVIEW_UPDATE_EVENT as Ve,peekSpreadsheetPreviewStage as Ye,claimSpreadsheetPreviewStage as je}from"efficient-shell/apps";import{forwardRef as _e,useCallback as Ze,useEffect as Qe,useImperativeHandle as qe,useMemo as Je,useRef as et,useState as tt}from"react";import{Icon as rt}from"efficient-shell/icons";import{jsx as nt,jsxs as ot}from"react/jsx-runtime";var lt,at=46,it=24,ct=4/3;function st(e,t){const r=new Float64Array(e+1);for(let n=0;n<e;n++)r[n+1]=r[n]+t(n);return r}function ut(e,t){let r=0,n=e.length-2;for(;r<n;){const o=r+n+1>>1;e[o]<=t?r=o:n=o-1}return r}function dt(e,t){if(void 0===lt)try{lt=document.createElement("canvas").getContext("2d")}catch{lt=null}const r=(t?.fontSize??d)*ct;return lt?(lt.font=`${t?.italic?"italic ":""}${t?.bold?"bold ":""}${r}px system-ui, sans-serif`,lt.measureText(e).width):e.length*r*.55}var ft=_e(function({sheet:e,sheetIndex:t,evaluator:r,filterHidden:n,selection:o,showGridlines:l,showFormulas:a,clipRange:i,highlights:s,pointing:h,onSelect:m,onPoint:g,onEdit:p,onFill:v,onResizeCol:w,onResizeRow:b,onAutoFitCol:y,onAutoFitRow:C,onHeaderMenu:N,onFilterButton:S,renderEditor:D,onKeyDown:E,onCopy:R,onCut:T,onPaste:M},A){const F=c(),I=et(null),[O,P]=tt({x:0,y:0}),[U,$]=tt({width:1e3,height:600}),[B,K]=tt(null),[X,W]=tt(null),[V,Y]=tt(null);Qe(()=>{const e=I.current;if(!e)return;const t=()=>{e.clientWidth&&e.clientHeight&&$({width:e.clientWidth,height:e.clientHeight})};if(t(),"undefined"==typeof ResizeObserver)return;const r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[]);const j=Je(()=>{const n=new Map;for(const[o,l]of Object.entries(e.formats)){if(!l.fontSize&&!l.wrap)continue;const[a,i]=o.split(":").map(Number);if(void 0!==e.rowHeights[a])continue;const c=(l.fontSize??d)*ct*1.4;let s=1;if(l.wrap&&""!==q(e,a,i)){const n=(e.colWidths[i]??u)-8;s=x(e,t,r,a,i).text.split("\n").reduce((e,t)=>e+Math.max(1,Math.ceil(dt(t,l)/Math.max(n,1))),0)}const h=Math.ceil(c*s+6);h>(n.get(a)??f)&&n.set(a,h)}return n},[e,t,r]),_=Je(()=>new Set(e.hiddenRows),[e.hiddenRows]),Z=Je(()=>new Set(e.hiddenCols),[e.hiddenCols]),Q=Je(()=>st(e.rowCount,t=>_.has(t)||n.has(t)?0:X?.row===t?X.height:e.rowHeights[t]??j.get(t)??f),[e.rowCount,e.rowHeights,_,n,j,X]),J=Je(()=>st(e.colCount,t=>Z.has(t)?0:B?.col===t?B.width:e.colWidths[t]??u),[e.colCount,e.colWidths,Z,B]),ee=Math.min(e.frozenRows,e.rowCount),te=Math.min(e.frozenCols,e.colCount),re=Q[ee],ne=J[te],oe=J[e.colCount],le=Q[e.rowCount],ae=Ze(e=>at+J[e]-(e>=te?O.x:0),[J,te,O.x]),ie=Ze(e=>it+Q[e]-(e>=ee?O.y:0),[Q,ee,O.y]),ce=Ze(e=>{const t=I.current;if(!t)return;const r=t.clientWidth-at-ne,n=t.clientHeight-it-re;let{scrollLeft:o,scrollTop:l}=t;if(e.col>=te){const t=J[e.col]-ne,n=J[e.col+1]-ne;t<o?o=t:n>o+r&&(o=n-r)}if(e.row>=ee){const t=Q[e.row]-re,r=Q[e.row+1]-re;t<l?l=t:r>l+n&&(l=r-n)}t.scrollTo(o,l)},[J,Q,ne,re,te,ee]);qe(A,()=>({focus:()=>I.current?.focus({preventScroll:!0}),scrollTo:ce,measureColumn:n=>{let o=0;for(let l=0;l<e.cells.length;l++){if(""===q(e,l,n))continue;const a=e.formats[L(l,n)];o=Math.max(o,dt(x(e,t,r,l,n).text,a))}return Math.ceil(o+8+4)}}),[ce,e,t,r]);const se=Ze((e,t)=>{const r=I.current.getBoundingClientRect(),n=e-r.left-at,o=t-r.top-it,l=n<ne?n:n+I.current.scrollLeft,a=o<re?o:o+I.current.scrollTop;return{row:ut(Q,Math.max(0,Math.min(a,le-1))),col:ut(J,Math.max(0,Math.min(l,oe-1)))}},[J,Q,ne,re,oe,le]),ue=Ze((e,t)=>{const r=I.current,n=t=>{const n=r.getBoundingClientRect();t.clientY>n.bottom-4?r.scrollBy(0,24):t.clientY<n.top+it&&r.scrollBy(0,-24),t.clientX>n.right-4?r.scrollBy(24,0):t.clientX<n.left+at&&r.scrollBy(-24,0),e(t)},o=e=>{window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",o),window.removeEventListener("pointercancel",o),t(e)};window.addEventListener("pointermove",n),window.addEventListener("pointerup",o),window.addEventListener("pointercancel",o)},[]),de=Ze((t,r)=>{const n=z(e,G(t,r));m({active:t,range:n})},[e,m]),fe=Math.max(0,U.width-at-ne),he=Math.max(0,U.height-it-re),me=ut(Q,re+O.y),ge=ut(J,ne+O.x),pe=Math.min(e.rowCount-1,ut(Q,re+O.y+he)),ve=Math.min(e.colCount-1,ut(J,ne+O.x+fe)),we=(n,o,i,c)=>{const s=[],u=[],f=new Set,h=(n,o,i)=>{const c=L(n,o);if(f.has(c))return;f.add(c);const h=i?i.r2:n,m=i?i.c2:o,g=J[o],p=Q[n],v=J[m+1]-g,w=Q[h+1]-p;if(v<=0||w<=0)return;const b=e.formats[c],y=q(e,n,o),C=a&&"="===y[0]?{text:y,color:null,align:"left",error:!1}:x(e,t,r,n,o),k=b?.border,N="1px solid var(--ink)",S=!!b?.fill||!!k||!!i,D=l?"1px solid var(--line-subtle)":"1px solid transparent",E={position:"absolute",left:g,top:p,width:v,height:w,boxSizing:"border-box",borderRight:k?.right?N:D,borderBottom:k?.bottom?N:D,borderTop:k?.top?N:void 0,borderLeft:k?.left?N:void 0,background:b?.fill??(i?"var(--surface)":void 0)};if((S||l)&&s.push(nt("div",{style:E},`b${c}`)),!C.text)return;const R=b?.align??C.align;let T=C.text;"string"==typeof T&&!C.error&&"right"===C.align&&!b?.wrap&&dt(T,b)>v-4&&(T="#".repeat(Math.max(1,Math.floor(v/8))));let M=v,A=0;if(!i&&!b?.wrap&&"left"===C.align&&dt(T,b)>v-8){if("left"===R||"center"===R)for(let t=o+1;t<=Math.min(o+40,e.colCount-1)&&(""===q(e,n,t)&&!H(e,n,t));t++)M+=J[t+1]-J[t];if("right"===R||"center"===R)for(let t=o-1;t>=Math.max(o-40,0)&&(""===q(e,n,t)&&!H(e,n,t));t--)A+=J[t+1]-J[t]}const z=b?.vAlign??"bottom",F=C.error?"var(--danger-text)":C.color??b?.color;u.push(nt("div",{"data-cell":c,className:"pointer-events-none",style:{position:"absolute",left:g-A,top:p,width:M+A,height:w,boxSizing:"border-box",padding:"0 4px",overflow:"hidden",display:"flex",alignItems:"top"===z?"flex-start":"middle"===z?"center":"flex-end",justifyContent:b?.wrap?void 0:"right"===R?"flex-end":"center"===R?"center":"flex-start",textAlign:R,whiteSpace:b?.wrap?"pre-wrap":"pre",wordBreak:b?.wrap?"break-word":void 0,fontSize:(b?.fontSize??d)*ct,lineHeight:1.3,paddingBottom:"bottom"===z?2:void 0,fontWeight:b?.bold?700:void 0,fontStyle:b?.italic?"italic":void 0,textDecoration:[b?.underline?"underline":"",b?.strike?"line-through":""].join(" ").trim()||void 0,color:F},children:nt("span",{style:b?.wrap?{width:"100%"}:void 0,children:T})},`t${c}`))};for(let t=n;t<=o;t++)for(let r=i;r<=c;r++){const n=H(e,t,r);(!n||n.r1===t&&n.c1===r)&&h(t,r,n)}for(const t of e.merges)(t.r1<n||t.c1<i)&&t.r2>=n&&t.r1<=o&&t.c2>=i&&t.c1<=c&&h(t.r1,t.c1,t);return[...s,...u]},xe=(t,r,n,l)=>{const a=[],c=(e,o,i,c)=>{e.r2<t||e.r1>r||e.c2<n||e.c1>l||a.push(nt("div",{style:{position:"absolute",boxSizing:"border-box",pointerEvents:"none",left:J[e.c1],top:Q[e.r1],width:J[e.c2+1]-J[e.c1],height:Q[e.r2+1]-Q[e.r1],...i},children:c},o))},u=o.range,d=u.r1!==u.r2||u.c1!==u.c2,f=H(e,o.active.row,o.active.col),h=!!f&&f.r1===u.r1&&f.r2===u.r2&&f.c1===u.c1&&f.c2===u.c2;return c(u,"sel",{background:d&&!h?"color-mix(in srgb, var(--accent-fill) 12%, transparent)":void 0,border:"2px solid var(--accent-fill)"}),V&&c(V,"fill",{border:"1px dashed var(--ink-muted)"}),i&&c(i,"clip",{border:"2px dashed var(--accent-fill)"}),s.forEach((e,t)=>c(e.range,`ref${t}`,{border:`2px solid ${e.color}`,background:`color-mix(in srgb, ${e.color} 10%, transparent)`})),a},be=[];ee&&te&&be.push({key:"corner",left:at,top:it,width:ne,height:re,offsetX:0,offsetY:0,r1:0,r2:ee-1,c1:0,c2:te-1}),ee&&be.push({key:"top",left:at+ne,top:it,width:fe,height:re,offsetX:O.x,offsetY:0,r1:0,r2:ee-1,c1:ge,c2:ve}),te&&be.push({key:"left",left:at,top:it+re,width:ne,height:he,offsetX:0,offsetY:O.y,r1:me,r2:pe,c1:0,c2:te-1}),be.push({key:"main",left:at+ne,top:it+re,width:fe,height:he,offsetX:O.x,offsetY:O.y,r1:me,r2:pe,c1:ge,c2:ve});const ye=o.range,Ce=[];for(let e=0;e<te;e++)Ce.push(e);for(let e=ge;e<=ve;e++)Ce.push(e);const ke=[];for(let e=0;e<ee;e++)ke.push(e);for(let e=me;e<=pe;e++)ke.push(e);const Ne=0===ye.r1&&ye.r2===e.rowCount-1,Se=0===ye.c1&&ye.c2===e.colCount-1,De="absolute flex items-center justify-center select-none text-xs border-r border-b border-line",Ee="bg-accent-tint text-accent-text",Re="bg-surface-sunken text-ink-muted",Te=ye.r2<ee||ye.r2>=me,Me=ae(ye.c2+1),Ae=ie(ye.r2+1),ze=Te&&!h&&Me>=at&&Ae>=it&&Me<=U.width&&Ae<=U.height,Fe=H(e,o.active.row,o.active.col)??{r1:o.active.row,c1:o.active.col,r2:o.active.row,c2:o.active.col},Ie={x:ae(Fe.c1),y:ie(Fe.r1),width:J[Fe.c2+1]-J[Fe.c1],height:Q[Fe.r2+1]-Q[Fe.r1],viewportWidth:U.width,viewportHeight:U.height},{filter:Oe}=e,Le=Oe?.range.r1??-1,Pe=[];if(Oe&&(Le<ee||Le>=me&&Le<=pe))for(let e=Oe.range.c1;e<=Oe.range.c2;e++)J[e+1]>J[e]&&(e<te||e>=ge&&e<=ve)&&Pe.push(e);return nt("div",{ref:I,tabIndex:0,role:"grid","aria-label":e.name,"aria-rowcount":e.rowCount,"aria-colcount":e.colCount,className:"relative h-full w-full overflow-auto outline-none bg-surface text-ink",onScroll:e=>P({x:e.currentTarget.scrollLeft,y:e.currentTarget.scrollTop}),onKeyDown:E,onCopy:R,onCut:T,onPaste:M,children:nt("div",{style:{width:at+oe,height:it+le},children:ot("div",{className:"sticky top-0 left-0 overflow-hidden",style:{width:U.width,height:U.height},children:[ot("div",{className:"absolute inset-0",onPointerDown:t=>{if(0!==t.button)return;const r=se(t.clientX,t.clientY);if(h)return t.preventDefault(),g(G(r,r),!1),void ue(e=>g(G(r,se(e.clientX,e.clientY)),!1),e=>g(G(r,se(e.clientX,e.clientY)),!0));if(I.current?.focus({preventScroll:!0}),t.detail>=2)return t.preventDefault(),void p(r);const n=t.shiftKey?o.active:H(e,r.row,r.col)?{row:H(e,r.row,r.col).r1,col:H(e,r.row,r.col).c1}:r;de(n,r),ue(e=>de(n,se(e.clientX,e.clientY)),()=>{})},onContextMenu:e=>N(e,"cell",se(e.clientX,e.clientY)),children:[be.map(e=>nt("div",{className:"absolute overflow-hidden",style:{left:e.left,top:e.top,width:e.width,height:e.height},children:ot("div",{className:"absolute",style:{left:-e.offsetX,top:-e.offsetY,width:oe,height:le},children:[we(e.r1,e.r2,e.c1,e.c2),xe(e.r1,e.r2,e.c1,e.c2)]})},e.key)),re>0&&nt("div",{className:"absolute bg-line-strong pointer-events-none",style:{left:0,right:0,top:it+re-1,height:2}}),ne>0&&nt("div",{className:"absolute bg-line-strong pointer-events-none",style:{top:0,bottom:0,left:at+ne-1,width:2}})]}),Pe.map(e=>{const t=ae(e+1),r=ie(Le),n=Q[Le+1]-Q[Le],o=(Oe?.excluded[e]?.length??0)>0;return nt("button",{type:"button","aria-label":F.filterColumn(k(e)),onClick:t=>{t.stopPropagation(),S(e,t.currentTarget.getBoundingClientRect())},onPointerDown:e=>e.stopPropagation(),className:`absolute flex items-center justify-center rounded border ${o?"":"border-line"} ${o?"border-accent-fill bg-accent-tint":"bg-surface hover:bg-surface-sunken"}`,style:{left:t-19,top:r+Math.max(0,(n-17)/2),width:17,height:17},children:nt(rt,{name:"filter",size:11})},e)}),ze&&nt("div",{"aria-label":F.fillHandle,className:"absolute bg-accent-fill border border-surface cursor-crosshair",style:{left:Me-5,top:Ae-5,width:8,height:8},onPointerDown:e=>{e.preventDefault(),e.stopPropagation();const t=o.range;let r=null;ue(e=>{r=(e=>{const r=se(e.clientX,e.clientY);return(r.row>t.r2?r.row-t.r2:r.row<t.r1?t.r1-r.row:0)>=(r.col>t.c2?r.col-t.c2:r.col<t.c1?t.c1-r.col:0)?{...t,r1:Math.min(t.r1,r.row),r2:Math.max(t.r2,r.row)}:{...t,c1:Math.min(t.c1,r.col),c2:Math.max(t.c2,r.col)}})(e),Y(r)},()=>{Y(null),!r||r.r1===t.r1&&r.r2===t.r2&&r.c1===t.c1&&r.c2===t.c2||v(r)})}}),nt("div",{className:"absolute top-0 overflow-hidden bg-surface-sunken",style:{left:at,right:0,height:it},children:Ce.map(t=>{const r=J[t+1]-J[t];if(r<=0)return null;const n=J[t]-(t>=te?O.x:0),l=t>=ye.c1&&t<=ye.c2;return ot("div",{className:`${De} ${l?Ee:Re} ${l&&Ne?"font-semibold":""}`,style:{left:n,top:0,width:r,height:it},onPointerDown:r=>((t,r)=>{if(0!==t.button)return;I.current?.focus({preventScroll:!0});const n=t.shiftKey?o.active.col:r,l=t=>{const r={r1:0,c1:Math.min(n,t),r2:e.rowCount-1,c2:Math.max(n,t)};m({active:{row:0,col:n},range:r})};l(r),ue(e=>l(se(e.clientX,e.clientY).col),()=>{})})(r,t),onContextMenu:e=>N(e,"col",{row:0,col:t}),children:[k(t),nt("div",{className:"absolute top-0 bottom-0 cursor-col-resize",style:{right:-3,width:7},onPointerDown:e=>((e,t)=>{e.preventDefault(),e.stopPropagation();const r=e.clientX,n=J[t+1]-J[t],o=e=>Math.max(16,Math.round(n+e.clientX-r));ue(e=>K({col:t,width:o(e)}),e=>{K(null),o(e)!==n&&w(t,o(e))})})(e,t),onDoubleClick:e=>{e.stopPropagation(),y(t)}})]},t)})}),nt("div",{className:"absolute left-0 overflow-hidden bg-surface-sunken",style:{top:it,bottom:0,width:at},children:ke.map(t=>{const r=Q[t+1]-Q[t];if(r<=0)return null;const n=Q[t]-(t>=ee?O.y:0),l=t>=ye.r1&&t<=ye.r2;return ot("div",{className:`${De} ${l?Ee:Re} ${l&&Se?"font-semibold":""}`,style:{left:0,top:n,width:at,height:r},onPointerDown:r=>((t,r)=>{if(0!==t.button)return;I.current?.focus({preventScroll:!0});const n=t.shiftKey?o.active.row:r,l=t=>{const r={r1:Math.min(n,t),c1:0,r2:Math.max(n,t),c2:e.colCount-1};m({active:{row:n,col:0},range:r})};l(r),ue(e=>l(se(e.clientX,e.clientY).row),()=>{})})(r,t),onContextMenu:e=>N(e,"row",{row:t,col:0}),children:[t+1,nt("div",{className:"absolute left-0 right-0 cursor-row-resize",style:{bottom:-3,height:7},onPointerDown:e=>((e,t)=>{e.preventDefault(),e.stopPropagation();const r=e.clientY,n=Q[t+1]-Q[t],o=e=>Math.max(12,Math.round(n+e.clientY-r));ue(e=>W({row:t,height:o(e)}),e=>{W(null),o(e)!==n&&b(t,o(e))})})(e,t),onDoubleClick:e=>{e.stopPropagation(),C(t)}})]},t)})}),nt("div",{role:"button","aria-label":F.selectAll,className:`${De} top-0 left-0 cursor-pointer bg-surface-sunken hover:bg-line`,style:{width:at,height:it},onPointerDown:t=>{t.preventDefault(),I.current?.focus({preventScroll:!0}),m({active:{row:0,col:0},range:{r1:0,c1:0,r2:e.rowCount-1,c2:e.colCount-1}})},onContextMenu:e=>N(e,"corner",{row:0,col:0})}),D?.(Ie)]})})})}),ht=["#000000","#434343","#666666","#999999","#cccccc","#efefef","#ffffff","#c00000","#ff0000","#ffc000","#ffff00","#92d050","#00b050","#00b0f0","#0070c0","#002060","#7030a0","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#c9daf8","#d9d2e9","#ead1dc"],mt=["#1a73e8","#d93025","#7b1fa2","#188038","#e37400","#c5221f"];function gt(e,t){let r=!1;for(let n=0;n<t;n++)'"'===e[n]&&(r=!r);return r}function pt(e,t){if("="!==e[0]||gt(e,t))return null;const r=/[A-Za-z][A-Za-z0-9.]*$/.exec(e.slice(0,t));if(!r)return null;if("!"===e[r.index-1]||"("===e[t])return null;const n=r[0].toUpperCase(),o=h.filter(e=>e.startsWith(n));return o.length?{start:r.index,prefix:n,matches:o.slice(0,8)}:null}var vt={ABS:"value",AND:"condition1, [condition2, ...]",AVERAGE:"value1, [value2, ...]",AVERAGEIF:"range, criterion, [average_range]",AVERAGEIFS:"average_range, range1, criterion1, ...",CEILING:"value, [factor]","CEILING.MATH":"value, [factor]",CHOOSE:"index, choice1, [choice2, ...]",COLUMN:"[cell]",COLUMNS:"range",CONCAT:"value1, [value2, ...]",CONCATENATE:"value1, [value2, ...]",COS:"angle",COUNT:"value1, [value2, ...]",COUNTA:"value1, [value2, ...]",COUNTBLANK:"range",COUNTIF:"range, criterion",COUNTIFS:"range1, criterion1, ...",DATE:"year, month, day",DATEDIF:"start, end, unit",DAY:"date",DAYS:"end, start",EDATE:"start, months",EOMONTH:"start, months",EXACT:"text1, text2",EXP:"value",FIND:"find, within, [start]",FLOOR:"value, [factor]","FLOOR.MATH":"value, [factor]",FV:"rate, periods, payment, [present], [type]",HLOOKUP:"key, range, row, [approximate]",HOUR:"time",IF:"condition, if_true, [if_false]",IFERROR:"value, [if_error]",IFNA:"value, [if_na]",IFS:"condition1, value1, ...",INDEX:"range, row, [column]",INT:"value",ISBLANK:"value",ISERROR:"value",ISLOGICAL:"value",ISNA:"value",ISNUMBER:"value",ISTEXT:"value",LARGE:"range, k",LEFT:"text, [count]",LEN:"text",LN:"value",LOG:"value, [base]",LOG10:"value",LOWER:"text",MATCH:"key, range, [type]",MAX:"value1, [value2, ...]",MEDIAN:"value1, [value2, ...]",MID:"text, start, count",MIN:"value1, [value2, ...]",MINUTE:"time",MOD:"value, divisor",MODE:"value1, [value2, ...]","MODE.SNGL":"value1, [value2, ...]",MONTH:"date",N:"value",NA:"",NETWORKDAYS:"start, end, [holidays]",NOT:"condition",NOW:"",NPV:"rate, value1, [value2, ...]",OR:"condition1, [condition2, ...]",PI:"",PMT:"rate, periods, present, [future], [type]",POWER:"value, exponent",PRODUCT:"value1, [value2, ...]",PROPER:"text",PV:"rate, periods, payment, [future], [type]",RAND:"",RANDBETWEEN:"low, high",RANK:"value, range, [ascending]","RANK.EQ":"value, range, [ascending]",REPLACE:"text, start, count, new",REPT:"text, count",RIGHT:"text, [count]",ROUND:"value, [places]",ROUNDDOWN:"value, [places]",ROUNDUP:"value, [places]",ROW:"[cell]",ROWS:"range",SEARCH:"find, within, [start]",SECOND:"time",SIGN:"value",SIN:"angle",SMALL:"range, k",SQRT:"value",STDEV:"value1, [value2, ...]","STDEV.P":"value1, [value2, ...]","STDEV.S":"value1, [value2, ...]",STDEVP:"value1, [value2, ...]",SUBSTITUTE:"text, find, new, [occurrence]",SUM:"value1, [value2, ...]",SUMIF:"range, criterion, [sum_range]",SUMIFS:"sum_range, range1, criterion1, ...",SUMPRODUCT:"range1, [range2, ...]",SWITCH:"value, case1, result1, ..., [default]",TAN:"angle",TEXT:"value, format",TEXTJOIN:"delimiter, skip_blank, value1, ...",TIME:"hour, minute, second",TODAY:"",TRIM:"text",TRUNC:"value, [places]",UPPER:"text",VALUE:"text",VAR:"value1, [value2, ...]","VAR.P":"value1, [value2, ...]","VAR.S":"value1, [value2, ...]",VARP:"value1, [value2, ...]",VLOOKUP:"key, range, column, [approximate]",WEEKDAY:"date, [type]",XLOOKUP:"key, lookup_range, result_range, [if_not_found], [match_mode]",XOR:"condition1, [condition2, ...]",YEAR:"date",CHAR:"number",CLEAN:"text",CODE:"text",ISERR:"value",ISEVEN:"value",ISODD:"value",MAXIFS:"max_range, range1, criterion1, ...",MINIFS:"min_range, range1, criterion1, ...",MROUND:"value, factor",PERCENTILE:"range, percentile","PERCENTILE.INC":"range, percentile",QUARTILE:"range, quartile","QUARTILE.INC":"range, quartile",QUOTIENT:"dividend, divisor",REGEXEXTRACT:"text, regular_expression",REGEXMATCH:"text, regular_expression",REGEXREPLACE:"text, regular_expression, replacement",SUBTOTAL:"function_code, range1, [range2, ...]"};import{Fragment as wt,jsx as xt,jsxs as bt}from"react/jsx-runtime";var yt=[8,9,10,11,12,14,16,18,20,24,28,36],Ct="undefined"!=typeof navigator&&/Mac|iPhone|iPad/.test(navigator.platform),kt=Ct?"⌘":"Ctrl+";function Nt(e,t,r){const n=URL.createObjectURL(new Blob([e],{type:t})),o=document.createElement("a");o.href=n,o.download=r,o.click(),URL.revokeObjectURL(n)}var St=o;function Dt({spreadsheetId:t,onClose:r}){const n=c(),{store:o,canCreate:a=!0,canDelete:i=!0,chooseFile:u}=s(),[d]=xe(()=>null!=Ye()),[f,h]=xe(null),[m,g]=xe(null);if(!o||d)return xt(Mt,{onClose:r});if(t)return xt(Rt,{store:o,id:t,onClose:r});if(f?.id)return xt(Rt,{store:o,id:f.id,onClose:()=>h(null)},f.key);if(f?.file)return xt(Mt,{initialFile:f.file,hasStore:!0,onClose:()=>h(null)},f.key);return xt(he,{words:{windowTitle:n.filesHeading,heading:n.filesHeading,newFile:n.newFile,emptyTitle:n.filesEmptyTitle,emptyBody:n.filesEmptyBody,deleteConfirm:n.deleteConfirm,createFailed:n.createFailed,deleteFailed:n.deleteFailed},files:n.files,list:o.list,create:()=>o.create(n.untitled),rename:o.rename,remove:o.remove,canCreate:a,canDelete:i,accept:St,choose:u&&{run:u,request:{title:n.files.choosing(n.fileKind,n.filesHeading),extensions:l}},onOpen:e=>h({key:Date.now(),id:e}),onOpenFile:(t,r)=>{m||(g(n.files.opening(t.name)),e(o,t).then(async e=>{const o=await me(r,e.id);We.success(n.files.savedCopy(e.title,t.name,o?r?.location:void 0)),h({key:Date.now(),id:e.id})}).catch(()=>We.error(n.files.openFailed(t.name))).finally(()=>g(null)))},busy:m})}function Et({id:e,onClose:t}){return xt(Dt,{spreadsheetId:e,onClose:t})}function Rt({store:e,id:t,onClose:r,pane:n}){const o=c(),[l,a]=xe(null),[i,s]=xe(!1),u=ge(()=>{s(!1),e.get(t).then(e=>a(t=>({kept:e,nonce:(t?.nonce??0)+1})),()=>s(!0))},[t,e]);return pe(u,[u]),i?xt("div",{className:"office-open-failed",children:xt(Fe,{title:o.storedOpenFailed,children:r&&xt(Re,{onClick:r,children:o.backToFiles})})}):l?xt(Mt,{stored:{store:e,...l.kept},onClose:r,onReload:u,pane:n},l.nonce):xt(Le,{size:"sm",padding:"",className:"h-full",label:o.loading})}function Tt({initial:e,spreadsheetId:t,bridge:r,onSaveToFiles:n}){const{store:o}=s(),l=ve(()=>({bridge:r,onSaveToFiles:n}),[r,n]);return o&&t?xt(Rt,{store:o,id:t,pane:l}):xt(Mt,{initial:e??{rows:[],filename:""},pane:l})}function Mt({stored:e,initialFile:o,hasStore:l,onClose:s,onReload:u,initial:f,pane:h}){const x=c(),k=we(void 0);void 0===k.current&&(k.current=e?null:f?{token:-1,data:f}:Ye());const he=we(k.current?.data??null),[me]=xe(()=>{const e=k.current;if(!e)return null;const t=At(e.data,x.sheetName(1));return t?{sheet:t,title:e.data.filename.replace(/\.(csv|tsv|txt)$/i,"")}:-1===e.token&&e.data.filename?{sheet:X(x.sheetName(1)),title:e.data.filename}:null}),[Fe,Le]=xe(()=>e?i(e.workbook,x.sheetName(1)):me?[me.sheet]:[X(x.sheetName(1))]),[_e,Ze]=xe(0),[Qe,qe]=xe(e?.title??me?.title??x.untitled),[Je,et]=xe(()=>k.current?.data.onEmail),tt=we(Fe),rt=we([]),nt=we([]),[,ot]=xe(0),lt=ge(e=>{const t=tt.current,r=e(t);r!==t&&(rt.current.push(t),rt.current.length>100&&rt.current.shift(),nt.current=[],tt.current=r,Le(r),ot(e=>e+1))},[]),at=ge(e=>{rt.current=[],nt.current=[],tt.current=e,Le(e),Ze(0),ot(e=>e+1)},[]),it=ge(()=>{const e=rt.current.pop();e&&(nt.current.push(tt.current),tt.current=e,Le(e),Ze(t=>Math.min(t,e.length-1)),ot(e=>e+1))},[]),ct=ge(()=>{const e=nt.current.pop();e&&(rt.current.push(tt.current),tt.current=e,Le(e),Ze(t=>Math.min(t,e.length-1)),ot(e=>e+1))},[]),st=we(Fe),ut=we(e?.version??""),dt=we(e?.title??""),[Dt,Et]=xe(!1),Rt=ke(),Tt=ye({save:async t=>{e&&(ut.current=await e.store.save(e.id,{sheets:t},ut.current))},onFailure:(e,t)=>{e instanceof a?(Tt.stop(),Et(!0)):0===t&&We.error(x.saveFailed)}}),{push:Mt,flush:zt}=Tt,Ft=we(Fe);pe(()=>{e&&Fe!==Ft.current&&(Ft.current=Fe,Mt(Fe))},[Mt,Fe,e]),pe(()=>()=>{zt()},[zt]),De(e?Tt.state.pending||Dt:Fe!==st.current);const It=ge(e=>{const t=At(e,x.sheetName(1));t&&(at([t]),st.current=tt.current,qe(e.filename.replace(/\.(csv|tsv|txt)$/i,"")),et(()=>e.onEmail))},[at,x]);pe(()=>{const e=k.current;null!=e&&(je(e),e.data!==he.current&&It(e.data))},[]),pe(()=>{const e=k.current?.token;if(null==e)return;const t=t=>{const r=t.detail;r&&r.token===e&&It(r.data)};return window.addEventListener(Ve,t),()=>window.removeEventListener(Ve,t)},[]);const Ot=Math.min(_e,Fe.length-1),Lt=Fe[Ot],Pt=ve(()=>$(Fe),[Fe]),Ut=ve(()=>I(Lt,Ot,Pt),[Lt,Ot,Pt]),$t=we(null),Bt=we(null),[Ht,Kt]=xe({}),Xt=Ht[Lt.id]??{active:{row:0,col:0},range:{r1:0,c1:0,r2:0,c2:0}},Wt=we(_e);Wt.current=_e;const Gt=ge(e=>{Kt(t=>({...t,[tt.current[Math.min(Wt.current,tt.current.length-1)].id]:e}))},[]),Vt=Xt.active,Yt=Lt.formats[L(Vt.row,Vt.col)]??{},jt=q(Lt,Vt.row,Vt.col),[_t,Zt]=xe(null),Qt=we(_t);Qt.current=_t;const[qt,Jt]=xe(null),[er,tr]=xe(!0),[rr,nr]=xe(!1),[or,lr]=xe(null),[ar,ir]=xe(null),[cr,sr]=xe(!1),[ur,dr]=xe(null),[fr,hr]=xe(null),[mr,gr]=xe(!1),[pr,vr]=xe(""),[wr,xr]=xe(""),[br,yr]=xe({matchCase:!1,wholeCell:!1,inFormulas:!1}),Cr=we(null),kr=we(null),Nr=we(null),Sr=Ge(),Dr=Ge(),Er=ge(()=>{$t.current?.focus(),setTimeout(()=>{const e=document.activeElement;e&&e!==document.body&&!e.closest("[aria-haspopup]")||$t.current?.focus()},0)},[]),Rr=ge(e=>{lt(t=>{const r=Math.min(Wt.current,t.length-1),n=e(t[r]);return n===t[r]?t:t.map((e,t)=>t===r?n:e)})},[lt]),Tr=we(null),Mr=we(()=>!1);pe(()=>Ke(()=>!!Tr.current?.contains(document.activeElement)&&Mr.current()),[]);const Ar=ge(e=>Lt.hiddenRows.includes(e)||Ut.has(e),[Lt.hiddenRows,Ut]),zr=ge(e=>Lt.hiddenCols.includes(e),[Lt.hiddenCols]),Fr=ge(e=>{const t=H(Lt,e.row,e.col),r=t??{r1:e.row,c1:e.col,r2:e.row,c2:e.col};Gt({active:t?{row:t.r1,col:t.c1}:e,range:r}),$t.current?.scrollTo(e)},[Lt,Gt]),Ir=ge((e,t,r)=>{let{row:n,col:o}=e;const l=H(Lt,n,o);l&&(t>0&&(n=l.r2),t<0&&(n=l.r1),r>0&&(o=l.c2),r<0&&(o=l.c1));do{n+=t,o+=r}while(n>=0&&n<Lt.rowCount&&o>=0&&o<Lt.colCount&&(Ar(n)||zr(o)));return n<0||n>=Lt.rowCount||o<0||o>=Lt.colCount?e:{row:n,col:o}},[Lt,Ar,zr]),Or=ge((e,t,r)=>{const n=e=>""!==q(Lt,e.row,e.col);let o=e,l=Ir(o,t,r);if(l===o)return o;if(n(o)&&n(l)){for(;n(l);)if(o=l,l=Ir(o,t,r),l===o)return o;return o}for(;!n(l);)if(o=l,l=Ir(o,t,r),l===o)return o;return l},[Lt,Ir]),Lr=ge(e=>{const t=z(Lt,G(Xt.active,e));Gt({active:Xt.active,range:t}),$t.current?.scrollTo(e)},[Lt,Xt.active,Gt]),Pr=ge(()=>{const{range:e,active:t}=Xt;return{row:t.row===e.r1?e.r2:e.r1,col:t.col===e.c1?e.c2:e.c1}},[Xt]),Ur=we(null),$r=ge((e,t={})=>{const r=q(Lt,e.row,e.col),n=t.text??A(r,Lt.formats[L(e.row,e.col)]);Jt(e=>e?.cut?null:e),t.inBar||null!==Ur.current||(Ur.current=n.length),Zt({sheetId:Lt.id,row:e.row,col:e.col,text:n,mode:t.mode??(void 0!==t.text?"enter":"edit"),inBar:!!t.inBar,caret:n.length,pick:null,suggestion:0})},[Lt]),Br=ge(e=>{const t=Qt.current;if(!t)return!1;Qt.current=null,Zt(null),lt(r=>{const n=r.findIndex(e=>e.id===t.sheetId);if(n<0)return r;const o=r[n];if(t.text===A(q(o,t.row,t.col),o.formats[L(t.row,t.col)])&&!e)return r;let l=o;if(e)for(let r=e.r1;r<=e.r2;r++)for(let n=e.c1;n<=e.c2;n++){const e=U(t.text)?le(J(t.text).raw,r-t.row,n-t.col):t.text;l=S(l,r,n,e)}else l=S(l,t.row,t.col,t.text);return r.map((e,t)=>t===n?l:e)});const r=tt.current.findIndex(e=>e.id===t.sheetId);return r>=0&&r!==Wt.current&&Ze(r),!0},[lt]),Hr=ge(()=>{const e=Qt.current;if(Qt.current=null,Zt(null),e){const t=tt.current.findIndex(t=>t.id===e.sheetId);t>=0&&t!==Wt.current&&Ze(t)}Er()},[Er]),Kr=ge((e,t)=>{Fr(Ir(Xt.active,e,t)),Er()},[Er,Fr,Xt.active,Ir]);Se(()=>{if(!_t)return;const e=_t.inBar?Cr.current:kr.current;e&&(document.activeElement!==e&&e.focus({preventScroll:!0}),null!==Ur.current&&(e.setSelectionRange(Ur.current,Ur.current),Ur.current=null))},[_t]);const Xr=ge((e,t)=>{Zt(r=>r?{...r,text:e,caret:t,pick:null,suggestion:0}:r)},[]),Wr=_t?.sheetId===Lt.id,Gr=_t?pt(_t.text,_t.caret):null,Vr=_t?function(e,t){if("="!==e[0])return null;const r=[];let n=!1;for(let o=1;o<t;o++){const t=e[o];if('"'===t&&(n=!n),!n)if("("===t){const t=/([A-Za-z][A-Za-z0-9.]*)$/.exec(e.slice(1,o));r.push({name:t?t[1].toUpperCase():"",argIndex:0})}else")"===t?r.pop():","!==t&&";"!==t||!r.length||r[r.length-1].argIndex++}for(let e=r.length-1;e>=0;e--)if(r[e].name)return r[e];return null}(_t.text,_t.caret):null,Yr=!!_t&&(null!==_t.pick||function(e,t){if("="!==e[0]||gt(e,t))return!1;const r=e.slice(0,t).trimEnd(),n=e.slice(t).trimStart()[0];return!(void 0!==n&&!/[,;)+\-*/^&=<>%]/.test(n))&&/[=(,;+\-*/^&<>]$/.test(r)}(_t.text,_t.caret)),jr=ve(()=>_t?function(e,t,r,n,o){if("="!==e[0])return[];const l=[];let a=0;for(const i of ie(e.slice(1)).tokens){if("ref"!==i.type)continue;const e=mt[a++%mt.length];if(!(null===i.ref.sheet?r:i.ref.sheet.toLowerCase()===t.toLowerCase()))continue;const c=i.ref.b??i.ref.a,s=G({row:i.ref.a.row??0,col:i.ref.a.col??0},{row:c.row??n-1,col:c.col??o-1});l.push({range:s,color:e})}return l}(_t.text,Lt.name,Wr,Lt.rowCount,Lt.colCount):[],[_t,Lt.name,Lt.rowCount,Lt.colCount,Wr]),_r=ge((e,t)=>{const r=Qt.current;if(!r)return;const n=_({sheet:r.sheetId===tt.current[Wt.current].id?null:tt.current[Wt.current].name,a:{row:e.r1,col:e.c1,rowAbs:!1,colAbs:!1},b:e.r1===e.r2&&e.c1===e.c2?null:{row:e.r2,col:e.c2,rowAbs:!1,colAbs:!1}}),o=r.pick?.start??r.caret,l=r.pick?.end??r.caret,a=r.text.slice(0,o)+n+r.text.slice(l),i=o+n.length;Ur.current=i,Zt({...r,text:a,caret:i,pick:t?null:{start:o,end:i}})},[]),Zr=ge(e=>{const t=Qt.current,r=t?pt(t.text,t.caret):null;if(!t||!r)return;const n=function(e,t,r,n){const o=`${n}(`;return{text:e.slice(0,r)+o+e.slice(t),caret:r+o.length}}(t.text,t.caret,r.start,e);Ur.current=n.caret,Zt({...t,text:n.text,caret:n.caret,suggestion:0,pick:null})},[]),Qr=e=>{if(_t){if(e.stopPropagation(),Gr){if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=Gr.matches.length;return void Zt({..._t,suggestion:(_t.suggestion+("ArrowDown"===e.key?1:t-1))%t})}if("Tab"===e.key||"Enter"===e.key&&_t.suggestion>0)return e.preventDefault(),void Zr(Gr.matches[_t.suggestion])}if("Enter"===e.key){if(e.altKey){e.preventDefault();const{selectionStart:t,selectionEnd:r,value:n}=e.currentTarget,o=`${n.slice(0,t)}\n${n.slice(r)}`;return Ur.current=t+1,void Xr(o,t+1)}return e.preventDefault(),e.ctrlKey||e.metaKey?(Br(Xt.range),void Er()):(Br(),void Kr(e.shiftKey?-1:1,0))}if("Tab"===e.key)return e.preventDefault(),Br(),void Kr(0,e.shiftKey?-1:1);if("F4"===e.key){e.preventDefault();const t=function(e,t){if("="!==e[0])return null;const r=t-1;for(const t of ie(e.slice(1)).tokens){if("ref"!==t.type||r<t.start||r>t.end)continue;const n={...t.ref,a:E(t.ref.a),b:t.ref.b?E(t.ref.b):null},o=_(n);return{text:`=${e.slice(1,t.start+1)}${o}${e.slice(t.end+1)}`,caret:t.start+1+o.length}}return null}(_t.text,e.currentTarget.selectionStart);return void(t&&(Ur.current=t.caret,Xr(t.text,t.caret)))}"enter"!==_t.mode||_t.inBar||U(_t.text)||!e.key.startsWith("Arrow")||(e.preventDefault(),Br(),Kr("ArrowDown"===e.key?1:"ArrowUp"===e.key?-1:0,"ArrowRight"===e.key?1:"ArrowLeft"===e.key?-1:0))}},qr=e=>{const t=e.currentTarget.selectionStart;Zt(e=>e&&e.caret!==t?{...e,caret:t,pick:null}:e)},Jr=ge(e=>{Br(),e(),Er()},[Br,Er]),en=we(Xt);en.current=Xt;const tn=h?.bridge,rn=we(Qe);rn.current=Qe;const nn=Ht[Lt.id]?Xt:null,on=we(nn);on.current=nn,pe(()=>{if(tn)return tn.attach({sheets:()=>tt.current,activeSheet:()=>Math.min(Wt.current,tt.current.length-1),title:()=>rn.current||x.untitled,selection:()=>on.current?{sheet:Math.min(Wt.current,tt.current.length-1),range:on.current.range}:null,commit:e=>lt(()=>e),undoLast:it})},[tn,lt,x,it]),pe(()=>{tn?.changed()},[tn,nn,Ot,Fe,Qe]);const ln=ge(e=>{Jr(()=>Rr(t=>se(t,en.current.range,e)))},[Jr,Rr]),an=ge(e=>{const t=!Yt[e];ln(r=>de(r,e,t||void 0))},[Yt,ln]),cn=ge(e=>{ln(t=>de(t,"numFmt","General"===e?void 0:e))},[ln]),sn=ge(e=>{const t=Pt.value(Ot,Vt.row,Vt.col),r=v(Yt.numFmt??"General",e,"number"==typeof t?t:null);cn(r)},[Vt,Yt.numFmt,Pt,Ot,cn]),un=ge((e,t)=>{const{range:r}=Xt,[n,o]="row"===e?[r.r1,r.r2]:[r.c1,r.c2],l="row"===e?Lt.rowCount:Lt.colCount,a=o-n+1>=l?1:o-n+1;l+a>("row"===e?g:m)||Jr(()=>lt(r=>y(r,Ot,e,t?o+1:n,a)))},[Lt.colCount,Lt.rowCount,lt,Ot,Jr,Xt]),dn=ge(e=>{const{range:t}=Xt,[r,n]="row"===e?[t.r1,t.r2]:[t.c1,t.c2],o="row"===e?Lt.rowCount:Lt.colCount,l=Math.min(n-r+1,o-1);l<1||Jr(()=>{lt(t=>y(t,Ot,e,r,-l)),Fr({row:"row"===e?Math.min(r,o-l-1):Xt.active.row,col:"col"===e?Math.min(r,o-l-1):Xt.active.col})})},[Lt.colCount,Lt.rowCount,lt,Ot,Jr,Fr,Xt]),fn=ge(e=>{const{range:t}=Xt;Jr(()=>Rr(r=>{if("row"===e){const e=new Set(r.hiddenRows);for(let r=t.r1;r<=t.r2;r++)e.add(r);return{...r,hiddenRows:[...e]}}const n=new Set(r.hiddenCols);for(let e=t.c1;e<=t.c2;e++)n.add(e);return{...r,hiddenCols:[...n]}}))},[Jr,Xt,Rr]),hn=ge(e=>{Jr(()=>Rr(t=>"row"===e?{...t,hiddenRows:[]}:{...t,hiddenCols:[]}))},[Jr,Rr]),mn=ge(e=>{Jr(()=>Rr(t=>{const r=Xt.range.r1===Xt.range.r2&&Xt.range.c1===Xt.range.c2,n=0===Xt.range.r1&&Xt.range.r2===t.rowCount-1;let o=r?R(t,Xt.range):Xt.range;return n&&(o={...o,r2:Math.max(o.r1,ue(t)?.row??0)}),t.filter&&Z(t.filter.range,Xt.active.row,Xt.active.col)&&(o={...t.filter.range,r1:t.filter.range.r1+1}),ae(t,Ot,Pt,o,Xt.active.col,e)}))},[Pt,Ot,Jr,Xt,Rr]),gn=ge(()=>{ir(null),Jr(()=>Rr(e=>{if(e.filter)return{...e,filter:null};const t=R(e,Xt.range);return t.r1===t.r2?e:{...e,filter:{range:t,excluded:{}}}}))},[Jr,Xt.range,Rr]),pn=ge(()=>{Jr(()=>Rr(e=>e.merges.some(e=>Z(Xt.range,e.r1,e.c1))?ce(e,Xt.range):B(e,Xt.range)))},[Jr,Xt.range,Rr]),vn=ge((e,t)=>{Jr(()=>Rr(r=>({...r,frozenRows:e??r.frozenRows,frozenCols:t??r.frozenCols})))},[Jr,Rr]),wn=ge(e=>{const{range:t,active:r}=Xt,n=t.r1===t.r2&&t.c1===t.c2;let o="";if(n){const e=(e,t)=>"number"==typeof Pt.value(Ot,e,t);let t=r.row;for(;t>0&&e(t-1,r.col);)t--;let n=r.col;for(;n>0&&e(r.row,n-1);)n--;t<r.row?o=Q({r1:t,c1:r.col,r2:r.row-1,c2:r.col}):n<r.col&&(o=Q({r1:r.row,c1:n,r2:r.row,c2:r.col-1}))}else o=Q(t);const l=n?r:{row:t.r2+1,col:t.c1};Br(),n||Fr(l);const a=`=${e}(${o})`;Ur.current=a.length-1,$r(l,{text:a})},[Br,Pt,Ot,Fr,Xt,$r]),xn=ge((e,t)=>{const r=Xt.range,n={...r,r2:Math.min(r.r2,Math.max(r.r1,Lt.cells.length-1))},o=D(Lt,Ot,Pt,n,e);Jt(o),t?(t.preventDefault(),t.clipboardData.setData("text/plain",o.text)):navigator.clipboard?.writeText(o.text).catch(()=>{})},[Lt,Pt,Ot,Xt.range]),bn=ge((e,t)=>{const{range:r}=Xt;if(qt&&qt.text===e){if(qt.cut){const e=tt.current.findIndex(e=>e.id===qt.sheetId);if(e<0)return;let t=null;return lt(n=>{const o=K(n,e,qt,Ot,r);return t=o.range,o.sheets}),t&&Gt({active:{row:t.r1,col:t.c1},range:t}),void Jt(null)}return void Rr(e=>{const n=j(e,qt,r,t);return Gt({active:Xt.active,range:n.range}),n.sheet})}if(!e)return;const n=function(e){const t=e.replace(/\r\n?/g,"\n").replace(/\n$/,"");if(!t.includes("\t")&&!t.includes("\n"))return[[t]];if(!t.includes('"'))return t.split("\n").map(e=>e.split("\t"));const r=V(t.includes("\t")?t:`${t}\t`);return r.length?r:[[t]]}(e);Rr(e=>{let t=e;n.forEach((e,n)=>e.forEach((e,o)=>{t=S(t,r.r1+n,r.c1+o,e)}));const o=n.reduce((e,t)=>Math.max(e,t.length),1);return Gt({active:Xt.active,range:{r1:r.r1,c1:r.c1,r2:r.r1+n.length-1,c2:r.c1+o-1}}),t})},[qt,lt,Ot,Xt,Gt,Rr]),yn=ge(e=>{Jr(()=>{const t=navigator.clipboard?.readText?.();t?t.then(t=>bn(t,e)).catch(()=>{qt&&bn(qt.text,e)}):qt&&bn(qt.text,e)})},[qt,bn,Jr]);Mr.current=()=>Qt.current?(Hr(),!0):ar?(ir(null),Er(),!0):ur?(dr(null),Er(),!0):cr?(sr(!1),Er(),!0):null!==fr?(hr(null),Er(),!0):mr?(gr(!1),Er(),!0):!(!qt&&!or)&&(Jt(null),lr(null),!0);const Cn=Qe||x.spreadsheetFile,kn=ge(async()=>{Br();try{const e=tt.current;Nt(await n(e,$(e)),"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",`${Cn}.xlsx`),st.current=e,ot(e=>e+1)}catch{We.error(x.saveFailed)}},[Br,Cn,x]),Nn=()=>{const e=tt.current,t=Math.min(Wt.current,e.length-1);return ne(e[t],t,$(e))},Sn=async n=>{const o=n.name.replace(/\.(csv|tsv|txt|xlsx|xls|ods)$/i,"");try{if(Br(),/\.(xlsx|xls|ods)$/i.test(n.name)){const e=new Uint8Array(await n.arrayBuffer()),o=/\.xlsx$/i.test(n.name)&&"undefined"!=typeof DecompressionStream?await r(e):await t(e);lt(()=>o),Ze(0)}else{const e=V(await n.text());if(!e.length)return;Rr(t=>({...oe(t.name,e),id:t.id}))}e||qe(o)}catch{We.error(x.openFailed)}};pe(()=>{o&&Sn(o)},[]);const Dn=ve(()=>mr?O(Lt,Ot,Pt,pr,br):[],[Lt,Pt,mr,br,pr,Ot]),En=Dn.findIndex(e=>e.row===Xt.active.row&&e.col===Xt.active.col),Rn=e=>{if(!Dn.length)return;const t=En<0?e>0?0:Dn.length-1:(En+e+Dn.length)%Dn.length;Fr(Dn[t])},Tn=()=>{Br();const e=Ot+1;lt(t=>{const r=W(t,x.sheetBase);return[...t.slice(0,e),X(r),...t.slice(e)]}),Ze(e),Er()},Mn=()=>{if(!ur)return;const{index:e,name:t}=ur;dr(null);const r=t.trim();r&&r!==Fe[e]?.name&&(Fe.some((t,n)=>n!==e&&t.name.toLowerCase()===r.toLowerCase())?We.error(x.sheetNameTaken):lt(t=>ee(t,e,r)))},An=(e,t)=>{const r=e+t;r<0||r>=Fe.length||(lt(t=>{const n=[...t],[o]=n.splice(e,1);return n.splice(r,0,o),n}),e===Ot?Ze(r):r===Ot&&Ze(e))},zn=ge(e=>{Qt.current&&Br(),Gt(e),or&&(Rr(t=>se(t,e.range,()=>or)),lr(null))},[Br,or,Gt,Rr]),Fn=ge((e,t,r)=>{"cell"!==t||Z(Xt.range,r.row,r.col)?"col"!==t||0===Xt.range.r1&&Xt.range.r2===Lt.rowCount-1&&r.col>=Xt.range.c1&&r.col<=Xt.range.c2?"row"!==t||0===Xt.range.c1&&Xt.range.c2===Lt.colCount-1&&r.row>=Xt.range.r1&&r.row<=Xt.range.r2||Gt({active:{row:r.row,col:0},range:{r1:r.row,c1:0,r2:r.row,c2:Lt.colCount-1}}):Gt({active:{row:0,col:r.col},range:{r1:0,c1:r.col,r2:Lt.rowCount-1,c2:r.col}}):Fr(r),Sr.open(e,{kind:t,pos:r})},[Lt.colCount,Lt.rowCount,Sr,Fr,Xt.range,Gt]),In=ge((e,t)=>{if(!Lt.filter)return;const r=N(Lt,Ot,Pt,Lt.filter.range,e);ir({col:e,x:t.left,y:t.bottom+2,values:r,unticked:new Set(Lt.filter.excluded[e]??[]),search:""})},[Lt,Pt,Ot]),On=(e,t)=>{ir(null),Jr(()=>Rr(r=>{if(!r.filter)return r;const{range:n}=r.filter;return ae(r,Ot,Pt,{...n,r1:n.r1+1},e,t)}))},Ln=ve(()=>{const{range:e}=Xt;return e.r1===e.r2&&e.c1===e.c2?null:re(Lt,Ot,Pt,e,Ut)},[Lt,Pt,Ut,Ot,Xt]),Pn=e=>P(Number(e.toPrecision(12)),Ln?.firstFormat??"#,##0.##").text,Un=(e,t)=>bt("span",{className:"flex w-full items-center justify-between gap-6",children:[xt("span",{children:e}),xt("span",{className:"text-xs text-ink-faint",children:t})]}),$n=(e,t,r,n={})=>({key:e,label:t,onSelect:r,...n}),Bn=e=>({type:"divider",key:e}),Hn=[{key:"general",label:x.formatGeneral,code:p.general},{key:"number",label:x.formatNumber,code:p.number},{key:"percent",label:x.formatPercent,code:p.percent},{key:"scientific",label:x.formatScientific,code:p.scientific},{key:"currency",label:x.formatCurrency,code:p.currency},{key:"date",label:x.formatDate,code:p.date},{key:"time",label:x.formatTime,code:p.time},{key:"dateTime",label:x.formatDateTime,code:p.dateTime},{key:"text",label:x.formatText,code:p.text}].map(e=>({type:"radio",key:e.key,label:e.label,checked:(Yt.numFmt??"General")===e.code,onSelect:()=>cn(e.code)})),Kn=[["all",x.bordersAll],["outer",x.bordersOuter],["top",x.bordersTop],["bottom",x.bordersBottom],["left",x.bordersLeft],["right",x.bordersRight],["none",x.bordersNone]].map(([e,t])=>$n(e,t,()=>Jr(()=>Rr(t=>w(t,Xt.range,e))))),Xn=[...["left","center","right"].map(e=>({type:"radio",key:e,label:"left"===e?x.alignLeft:"center"===e?x.alignCenter:x.alignRight,checked:Yt.align===e,onSelect:()=>ln(t=>de(t,"align",e))})),Bn("v"),...["top","middle","bottom"].map(e=>({type:"radio",key:e,label:"top"===e?x.alignTop:"middle"===e?x.alignMiddle:x.alignBottom,checked:(Yt.vAlign??"bottom")===e,onSelect:()=>ln(t=>de(t,"vAlign",e))}))],Wn=yt.map(e=>({type:"radio",key:String(e),label:String(e),checked:(Yt.fontSize??d)===e,onSelect:()=>ln(t=>de(t,"fontSize",e===d?void 0:e))})),Gn=["SUM","AVERAGE","COUNT","MAX","MIN"].map(e=>$n(e,e,()=>wn(e))),Vn=[...[0,1,2].map(e=>({type:"radio",key:`r${e}`,label:x.freezeRows(e),checked:Lt.frozenRows===e,onSelect:()=>vn(e,null)})),{type:"radio",key:"rUp",label:x.freezeUpToRow(Vt.row+1),checked:Lt.frozenRows===Vt.row+1&&Vt.row>1,onSelect:()=>vn(Vt.row+1,null)},Bn("c"),...[0,1,2].map(e=>({type:"radio",key:`c${e}`,label:x.freezeColumns(e),checked:Lt.frozenCols===e,onSelect:()=>vn(null,e)})),{type:"radio",key:"cUp",label:x.freezeUpToColumn(b(0,Vt.col).replace(/\d+$/,"")),checked:Lt.frozenCols===Vt.col+1&&Vt.col>1,onSelect:()=>vn(null,Vt.col+1)}],Yn=[...e?[]:[$n("new",x.menuNew,()=>Jr(()=>{lt(()=>[X(x.sheetName(1))]),Ze(0),qe(x.untitled)}))],$n("open",x.menuOpen,()=>Bt.current?.click()),Bn("a"),$n("xlsx",Un(x.saveExcel,`${kt}S`),()=>{kn()}),$n("csv",x.saveCsv,()=>Jr(()=>Nt(Nn(),"text/csv",`${Cn}.csv`))),...Je?[Bn("b"),$n("email",x.email,()=>Jr(()=>Je(Nn(),`${Cn}.csv`)))]:[],...!e&&h?.onSaveToFiles?[Bn("c"),$n("keep",x.saveToFiles,()=>Jr(()=>h.onSaveToFiles?.(Qe.trim()||x.untitled,tt.current)))]:[]],jn=[$n("undo",Un(x.undo,`${kt}Z`),()=>Jr(it),{disabled:0===rt.current.length}),$n("redo",Un(x.redo,Ct?"⇧⌘Z":"Ctrl+Y"),()=>Jr(ct),{disabled:0===nt.current.length}),Bn("a"),$n("cut",Un(x.cut,`${kt}X`),()=>Jr(()=>xn(!0))),$n("copy",Un(x.copy,`${kt}C`),()=>Jr(()=>xn(!1))),$n("paste",Un(x.paste,`${kt}V`),()=>yn("all")),$n("pasteValues",x.pasteValues,()=>yn("values")),$n("pasteFormats",x.pasteFormats,()=>yn("formats")),Bn("b"),$n("find",Un(x.findReplace,`${kt}F`),()=>{gr(!0),setTimeout(()=>Nr.current?.focus(),0)}),$n("clear",Un(x.clearValues,"Delete"),()=>Jr(()=>Rr(e=>C(e,Xt.range))))],_n=[{type:"submenu",key:"freeze",label:x.freeze,items:Vn},{type:"checkbox",key:"gridlines",label:x.gridlines,checked:er,onSelect:()=>tr(e=>!e)},{type:"checkbox",key:"formulas",label:Un(x.showFormulas,`${kt}\``),checked:rr,onSelect:()=>nr(e=>!e)}],Zn=[$n("rowAbove",x.rowsAbove,()=>un("row",!1)),$n("rowBelow",x.rowsBelow,()=>un("row",!0)),$n("colLeft",x.columnsLeft,()=>un("col",!1)),$n("colRight",x.columnsRight,()=>un("col",!0)),Bn("a"),$n("sheet",x.sheet,Tn),{type:"submenu",key:"fn",label:x.function,items:Gn}],Qn=[{type:"submenu",key:"number",label:x.number,items:Hn},Bn("a"),$n("bold",Un(x.bold,`${kt}B`),()=>an("bold")),$n("italic",Un(x.italic,`${kt}I`),()=>an("italic")),$n("underline",Un(x.underline,`${kt}U`),()=>an("underline")),$n("strike",x.strikethrough,()=>an("strike")),{type:"submenu",key:"size",label:x.fontSize,items:Wn},Bn("b"),{type:"submenu",key:"align",label:x.alignment,items:Xn},{type:"submenu",key:"borders",label:x.borders,items:Kn},$n("wrap",x.wrapText,()=>an("wrap")),$n("merge",x.mergeCells,pn),Bn("c"),$n("clearFormat",x.clearFormatting,()=>Jr(()=>Rr(e=>se(e,Xt.range,()=>({})))))],qn=[$n("asc",x.sortAscending,()=>mn(!0)),$n("desc",x.sortDescending,()=>mn(!1)),Bn("a"),{type:"checkbox",key:"filter",label:x.filter,checked:!!Lt.filter,onSelect:gn},Bn("b"),$n("hideRows",x.hideRows,()=>fn("row")),$n("hideCols",x.hideColumns,()=>fn("col")),$n("unhideRows",x.unhideRows,()=>hn("row"),{disabled:!Lt.hiddenRows.length}),$n("unhideCols",x.unhideColumns,()=>hn("col"),{disabled:!Lt.hiddenCols.length})],Jn="rounded px-2 py-0.5 text-xs text-ink-muted hover:bg-line-subtle hover:text-ink",eo="inline-flex h-7 items-center gap-1 rounded px-2 text-xs text-ink-muted hover:bg-line-subtle hover:text-ink",to=xt("div",{className:"mx-1 h-4 w-px bg-line"}),ro=e=>e.preventDefault(),no=(e,t,r,n={})=>xt(Ie,{"aria-label":e,title:e,size:"sm",variant:"ghost",onMouseDown:ro,onClick:r,disabled:n.disabled,...void 0!==n.pressed?{"aria-pressed":n.pressed}:{},children:t}),oo=(e,t,r)=>xt(Pe,{triggerLabel:e,align:"start",triggerClassName:"inline-flex h-7 w-7 flex-col items-center justify-center rounded text-ink-muted hover:bg-line-subtle hover:text-ink",trigger:bt(wt,{children:[t,xt("span",{className:"h-0.5 w-4 rounded-sm",style:{background:Yt[r]??("color"===r?"var(--ink)":"var(--line)")}})]}),children:({close:t})=>xt(Me,{label:e,value:Yt[r]??"",presets:ht,clearable:!0,dragWrites:"end",onChange:e=>{ln(t=>de(t,r,e||void 0)),t()}})}),lo=e=>{if(!_t||!Wr||_t.inBar)return null;const t=Lt.formats[L(_t.row,_t.col)],r=(t?.fontSize??d)*(4/3),n=Math.min(Math.max(e.width,_t.text.length*r*.62+16),e.viewportWidth-e.x-4);return xt("textarea",{ref:kr,"aria-label":x.cellEditor,value:_t.text,spellCheck:!1,rows:1,onChange:e=>Xr(e.target.value,e.target.selectionStart),onSelect:qr,onKeyDown:Qr,onPointerDown:e=>e.stopPropagation(),className:"absolute resize-none overflow-hidden border-2 border-accent-fill bg-surface text-ink outline-none",style:{left:e.x,top:e.y,width:n,minHeight:e.height,height:Math.max(e.height,_t.text.split("\n").length*r*1.35+6),padding:"0 2px",fontSize:r,lineHeight:1.3,fontWeight:t?.bold?700:void 0,fontStyle:t?.italic?"italic":void 0,background:t?.fill??void 0,color:t?.color??void 0}})},ao=e=>{if(!_t||!Wr)return null;const t=e.y+e.height+2,r=Math.max(0,Math.min(e.x,e.viewportWidth-320));if(Gr)return bt("div",{role:"listbox","aria-label":x.functions,className:"absolute w-80 overflow-hidden rounded-lg border border-line bg-surface shadow-lg",style:{left:r,top:t},onPointerDown:e=>e.preventDefault(),children:[Gr.matches.map((e,t)=>bt("div",{role:"option","aria-selected":t===_t.suggestion,onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),Zr(e)},className:"flex cursor-pointer items-center justify-between gap-3 px-2 py-1 text-xs "+(t===_t.suggestion?"bg-accent-tint text-accent-text":"text-ink hover:bg-surface-sunken"),children:[xt("span",{className:"font-medium",children:e}),xt("span",{className:"truncate "+(t===_t.suggestion?"text-accent-text":"text-ink-muted"),children:x.functionHelp(e)})]},e)),bt("div",{className:"border-t border-line px-2 py-1 font-mono text-xs text-ink-muted",children:[Gr.matches[_t.suggestion],"(",vt[Gr.matches[_t.suggestion]]??"",")"]})]});if(Vr&&void 0!==vt[Vr.name]){const e=vt[Vr.name].split(", ");return bt("div",{className:"absolute max-w-md rounded-lg border border-line bg-surface px-2 py-1 text-xs text-ink-muted shadow-lg",style:{left:r,top:t},children:[bt("div",{className:"font-mono",children:[Vr.name,"(",e.map((t,r)=>bt("span",{children:[r>0?", ":"",xt("span",{className:r===Math.min(Vr.argIndex,e.length-1)?"font-semibold text-ink":"",children:t})]},t+r)),")"]}),xt("div",{className:"mt-0.5",children:x.functionHelp(Vr.name)})]})}return null},io=ar?ar.values.filter(e=>e.toLowerCase().includes(ar.search.toLowerCase())):[];return bt("div",{ref:Tr,className:"flex h-full flex-col bg-surface text-ink",children:[!h&&xt(Ne,{title:`${uo=Qe||x.untitled,uo.length>24?`${uo.slice(0,23)}…`:uo} - Spreadsheets`}),xt("input",{ref:Bt,type:"file",accept:St,onChange:e=>{const t=e.target.files?.[0];Bt.current&&(Bt.current.value=""),t&&Sn(t)},className:"hidden"}),bt("div",{className:"flex shrink-0 items-center gap-1 border-b border-line bg-surface-sunken px-2 py-1",children:[s&&xt(Ie,{"aria-label":x.backToFiles,title:x.backToFiles,size:"sm",variant:"ghost",onClick:()=>{zt(),s()},children:xt(Ee,{name:"arrow-left",size:16})}),cr?xt("input",{type:"text",value:Qe,autoFocus:!0,"aria-label":x.rename,onChange:e=>qe(e.target.value),onBlur:()=>{sr(!1);const t=Qe.trim()||x.untitled;if(t!==Qe&&qe(t),e&&t!==dt.current){const r=dt.current;dt.current=t,e.store.rename(e.id,t).catch(()=>{We.error(x.renameFailed),dt.current=r,qe(r)})}},onKeyDown:e=>{"Enter"===e.key&&(e.currentTarget.blur(),Er())},className:"w-40 rounded border border-line bg-surface px-2 py-0.5 text-sm font-medium text-ink"}):xt("button",{type:"button",onClick:()=>sr(!0),title:x.rename,className:"max-w-[200px] truncate rounded px-2 py-0.5 text-sm font-medium text-ink hover:bg-line-subtle",children:Qe||x.untitled}),xt(ze,{trigger:x.menuFile,items:Yn,align:"start",triggerClassName:Jn}),xt(ze,{trigger:x.menuEdit,items:jn,align:"start",triggerClassName:Jn}),xt(ze,{trigger:x.menuView,items:_n,align:"start",triggerClassName:Jn}),xt(ze,{trigger:x.menuInsert,items:Zn,align:"start",triggerClassName:Jn}),xt(ze,{trigger:x.menuFormat,items:Qn,align:"start",triggerClassName:Jn}),xt(ze,{trigger:x.menuData,items:qn,align:"start",triggerClassName:Jn}),(e||l)&&xt("span",{className:"office-save-state",children:xt(Ce,{...e?be(Tt.state,Rt.save):{tone:Fe!==st.current?"off-unsaved":"off",label:Fe!==st.current?x.noStoreEdited:x.noStoreClean}})})]}),Dt&&bt("div",{className:"office-conflict",role:"alert",children:[xt("span",{children:x.conflict}),xt(Re,{variant:"secondary",onClick:u,children:x.reload})]}),bt("div",{className:"flex shrink-0 flex-wrap items-center gap-0.5 border-b border-line bg-surface-sunken px-2 py-1",children:[no(x.undo,xt(Ee,{name:"undo",size:16}),()=>Jr(it),{disabled:0===rt.current.length}),no(x.redo,xt(Ee,{name:"redo",size:16}),()=>Jr(ct),{disabled:0===nt.current.length}),no(x.formatPainter,xt(Ee,{name:"copy-style",size:16}),()=>lr(e=>e?null:Yt),{pressed:!!or}),to,no(x.formatCurrency,xt(Ee,{name:"dollar",size:16}),()=>cn(Yt.numFmt===p.currency?"General":p.currency),{pressed:Yt.numFmt===p.currency}),no(x.formatPercent,xt(Ee,{name:"percent",size:16}),()=>cn(/%/.test(Yt.numFmt??"")?"General":"0%"),{pressed:/%/.test(Yt.numFmt??"")}),no(x.fewerDecimals,xt("span",{className:"text-xs",children:".0"}),()=>sn(-1)),no(x.moreDecimals,xt("span",{className:"text-xs",children:".00"}),()=>sn(1)),xt(ze,{trigger:bt("span",{title:x.number,className:"flex items-center gap-0.5",children:["123",xt(Ee,{name:"chevron-down",size:12})]}),"aria-label":x.number,items:Hn,align:"start",triggerClassName:eo}),to,xt(ze,{trigger:bt("span",{title:x.fontSize,className:"flex items-center gap-0.5",children:[Yt.fontSize??d,xt(Ee,{name:"chevron-down",size:12})]}),"aria-label":x.fontSize,items:Wn,align:"start",triggerClassName:eo}),no(x.bold,xt(Ee,{name:"bold",size:16}),()=>an("bold"),{pressed:!!Yt.bold}),no(x.italic,xt(Ee,{name:"italic",size:16}),()=>an("italic"),{pressed:!!Yt.italic}),no(x.underline,xt(Ee,{name:"underline",size:16}),()=>an("underline"),{pressed:!!Yt.underline}),no(x.strikethrough,xt(Ee,{name:"strike",size:16}),()=>an("strike"),{pressed:!!Yt.strike}),oo(x.textColor,xt(Ee,{name:"text-color",size:14}),"color"),oo(x.fillColor,xt(Ee,{name:"palette",size:14}),"fill"),to,xt(ze,{trigger:bt("span",{title:x.borders,className:"flex items-center gap-0.5",children:[xt(Ee,{name:"border-all",size:16}),xt(Ee,{name:"chevron-down",size:12})]}),"aria-label":x.borders,items:Kn,align:"start",triggerClassName:eo}),no(x.mergeCells,xt(Ee,{name:"grid",size:16}),pn,{pressed:Lt.merges.some(e=>Z(e,Vt.row,Vt.col))}),xt(ze,{trigger:bt("span",{title:x.alignment,className:"flex items-center gap-0.5",children:["center"===Yt.align?xt(Ee,{name:"align-center",size:16}):"right"===Yt.align?xt(Ee,{name:"align-right",size:16}):xt(Ee,{name:"align-left",size:16}),xt(Ee,{name:"chevron-down",size:12})]}),"aria-label":x.alignment,items:Xn,align:"start",triggerClassName:eo}),no(x.wrapText,xt(Ee,{name:"wrap",size:16}),()=>an("wrap"),{pressed:!!Yt.wrap}),to,no(x.filter,xt(Ee,{name:"filter",size:16}),gn,{pressed:!!Lt.filter}),no(x.sortAscending,xt(Ee,{name:"sort",size:16}),()=>mn(!0)),xt(ze,{trigger:bt("span",{title:x.functions,className:"flex items-center gap-0.5 text-sm",children:["Σ",xt(Ee,{name:"chevron-down",size:12})]}),"aria-label":x.functions,items:Gn,align:"end",triggerClassName:eo})]}),bt("div",{className:"flex shrink-0 items-start gap-1 border-b border-line bg-surface px-2 py-1",children:[xt("input",{type:"text","aria-label":x.nameBox,spellCheck:!1,value:fr??(_t&&Wr?b(_t.row,_t.col):Q(Xt.range)),onFocus:e=>{hr(e.target.value),e.target.select()},onChange:e=>hr(e.target.value),onBlur:()=>hr(null),onKeyDown:e=>{if("Enter"===e.key){const e=Y(fr??"");e&&e.r2<Lt.rowCount&&e.c2<Lt.colCount&&(Gt({active:{row:e.r1,col:e.c1},range:z(Lt,e)}),$t.current?.scrollTo({row:e.r1,col:e.c1})),hr(null),Er()}},className:"w-20 shrink-0 rounded border border-line bg-surface px-2 py-0.5 text-center text-xs text-ink"}),xt("span",{className:"select-none pt-0.5 font-serif text-sm italic text-ink-faint","aria-hidden":"true",children:"fx"}),xt("textarea",{ref:Cr,"aria-label":x.formulaBar,spellCheck:!1,rows:1,value:_t?_t.text:A(jt,Yt),onFocus:()=>{_t?_t.inBar||Zt({..._t,inBar:!0}):$r(Vt,{inBar:!0,mode:"edit"})},onChange:e=>{_t&&Xr(e.target.value,e.target.selectionStart)},onSelect:qr,onKeyDown:Qr,className:"max-h-24 min-h-[22px] flex-1 resize-y rounded border border-line bg-surface px-2 py-0.5 font-mono text-xs text-ink outline-none focus:border-accent-fill"})]}),mr&&bt("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-line bg-surface-sunken px-2 py-1 text-xs",children:[xt("div",{className:"w-44",children:xt(Oe,{ref:Nr,size:"sm","aria-label":x.find,placeholder:x.find,value:pr,onChange:e=>vr(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),Rn(e.shiftKey?-1:1))}})}),xt("span",{className:"w-16 text-center text-ink-muted",children:pr?x.hitCount(En<0?0:En+1,Dn.length):""}),no(x.previous,xt(Ee,{name:"arrow-up",size:14}),()=>Rn(-1)),no(x.next,xt(Ee,{name:"arrow-down",size:14}),()=>Rn(1)),xt("div",{className:"w-44",children:xt(Oe,{size:"sm","aria-label":x.replaceWith,placeholder:x.replaceWith,value:wr,onChange:e=>xr(e.target.value)})}),xt(Re,{size:"sm",variant:"secondary",disabled:!Dn.length,onClick:()=>{if(En<0)return void Rn(1);const{row:e,col:t}=Dn[En];Rr(r=>{const n=te(q(r,e,t),pr,wr,br);return n===q(r,e,t)?r:fe(r,[{row:e,col:t,raw:n}])}),Rn(1)},children:x.replace}),xt(Re,{size:"sm",variant:"secondary",disabled:!Dn.length,onClick:()=>{let e=0;Rr(t=>{const r=[];for(const{row:e,col:n}of Dn){const o=te(q(t,e,n),pr,wr,br);o!==q(t,e,n)&&r.push({row:e,col:n,raw:o})}return e=r.length,fe(t,r)}),We.success(x.replacedCount(e))},children:x.replaceAll}),xt(Te,{label:x.matchCase,checked:br.matchCase,onChange:e=>yr(t=>({...t,matchCase:e}))}),xt(Te,{label:x.wholeCell,checked:br.wholeCell,onChange:e=>yr(t=>({...t,wholeCell:e}))}),xt(Te,{label:x.inFormulas,checked:br.inFormulas,onChange:e=>yr(t=>({...t,inFormulas:e}))}),xt("div",{className:"ml-auto",children:no(x.close,xt(Ee,{name:"close",size:14}),()=>{gr(!1),Er()})})]}),xt("div",{className:"min-h-0 flex-1",children:xt(ft,{ref:$t,sheet:Lt,sheetIndex:Ot,evaluator:Pt,filterHidden:Ut,selection:Xt,showGridlines:er,showFormulas:rr,clipRange:qt&&qt.sheetId===Lt.id?qt.range:null,highlights:jr,pointing:Yr,onSelect:zn,onPoint:_r,onEdit:e=>{Br(),Fr(e),$r(H(Lt,e.row,e.col)?{row:H(Lt,e.row,e.col).r1,col:H(Lt,e.row,e.col).c1}:e)},onFill:e=>{const t=Xt.range;Rr(r=>F(r,t,e)),Gt({active:Xt.active,range:e})},onResizeCol:(e,t)=>Rr(r=>{const{range:n}=Xt,o=0===n.r1&&n.r2===r.rowCount-1&&e>=n.c1&&e<=n.c2,l={...r.colWidths};if(o)for(let e=n.c1;e<=n.c2;e++)l[e]=t;else l[e]=t;return{...r,colWidths:l}}),onResizeRow:(e,t)=>Rr(r=>({...r,rowHeights:{...r.rowHeights,[e]:t}})),onAutoFitCol:e=>{const t=Math.max(40,$t.current?.measureColumn(e)??0);Rr(r=>({...r,colWidths:{...r.colWidths,[e]:t}}))},onAutoFitRow:e=>Rr(t=>{const r={...t.rowHeights};return delete r[e],{...t,rowHeights:r}}),onHeaderMenu:Fn,onFilterButton:In,renderEditor:e=>bt(wt,{children:[lo(e),ao(e)]}),onKeyDown:t=>{if(_t)return;const r=t.ctrlKey||t.metaKey,n=t.key,o=n.toLowerCase(),l="ArrowUp"===n?[-1,0]:"ArrowDown"===n?[1,0]:"ArrowLeft"===n?[0,-1]:"ArrowRight"===n?[0,1]:null;if(l){t.preventDefault();const e=t.shiftKey?Pr():Xt.active,n=r?Or(e,l[0],l[1]):Ir(e,l[0],l[1]);return void(t.shiftKey?Lr(n):Fr(n))}if("Tab"===n||"Enter"===n){if(t.preventDefault(),"Enter"===n&&r)return;const e=Xt.range.r1!==Xt.range.r2||Xt.range.c1!==Xt.range.c2,o="Enter"===n?t.shiftKey?-1:1:0,l="Tab"===n?t.shiftKey?-1:1:0;if(e){const{range:e}=Xt;let{row:t,col:r}=Xt.active;return t+=o,r+=l,r>e.c2&&(r=e.c1,t=t+1>e.r2?e.r1:t+1),r<e.c1&&(r=e.c2,t=t-1<e.r1?e.r2:t-1),t>e.r2&&(t=e.r1,r=r+1>e.c2?e.c1:r+1),t<e.r1&&(t=e.r2,r=r-1<e.c1?e.c2:r-1),Gt({active:{row:t,col:r},range:e}),void $t.current?.scrollTo({row:t,col:r})}return void Fr(Ir(Xt.active,o,l))}if("Home"===n)return t.preventDefault(),void Fr(r?{row:Lt.frozenRows,col:Lt.frozenCols}:{row:Xt.active.row,col:0});if("End"===n){t.preventDefault();const e=ue(Lt);return void Fr(r?{row:e?.row??0,col:e?.col??0}:{row:Xt.active.row,col:Math.max(0,(Lt.cells[Xt.active.row]?.length??1)-1)})}if("PageDown"===n||"PageUp"===n){t.preventDefault();const e="PageDown"===n?25:-25;return void Fr({row:Math.max(0,Math.min(Lt.rowCount-1,Xt.active.row+e)),col:Xt.active.col})}if("Delete"===n||"Backspace"===n)return t.preventDefault(),void Rr(e=>C(e,Xt.range));if("F2"===n)return t.preventDefault(),void $r(Xt.active);if(" "===n&&(r||t.shiftKey))return t.preventDefault(),void Gt(r?{active:Xt.active,range:{r1:0,c1:Xt.range.c1,r2:Lt.rowCount-1,c2:Xt.range.c2}}:{active:Xt.active,range:{r1:Xt.range.r1,c1:0,r2:Xt.range.r2,c2:Lt.colCount-1}});if(!r)return!t.altKey||"="!==n&&"≠"!==n?1!==n.length||t.altKey?void("Process"!==n&&229!==t.keyCode||$r(Xt.active,{text:""})):(t.preventDefault(),void $r(Xt.active,{text:n})):(t.preventDefault(),void wn("SUM"));switch(o){case"z":return t.preventDefault(),void(t.shiftKey?ct():it());case"y":return t.preventDefault(),void ct();case"a":return t.preventDefault(),void Gt({active:Xt.active,range:{r1:0,c1:0,r2:Lt.rowCount-1,c2:Lt.colCount-1}});case"b":return t.preventDefault(),void an("bold");case"i":return t.preventDefault(),void an("italic");case"u":return t.preventDefault(),void an("underline");case"f":case"h":return t.preventDefault(),gr(!0),void setTimeout(()=>Nr.current?.focus(),0);case"s":return t.preventDefault(),void(e?zt():kn());case"d":{t.preventDefault();const{range:e}=Xt;return void(e.r2>e.r1?Rr(t=>F(t,{...e,r2:e.r1},e)):e.r1>0&&Rr(t=>F(t,{...e,r1:e.r1-1,r2:e.r1-1},{...e,r1:e.r1-1})))}case"r":{t.preventDefault();const{range:e}=Xt;return void(e.c2>e.c1?Rr(t=>F(t,{...e,c2:e.c1},e)):e.c1>0&&Rr(t=>F(t,{...e,c1:e.c1-1,c2:e.c1-1},{...e,c1:e.c1-1})))}case";":return t.preventDefault(),void Rr(e=>S(e,Xt.active.row,Xt.active.col,Xe(new Date)));case"`":return t.preventDefault(),void nr(e=>!e)}if(t.shiftKey){if("$"===n||"4"===n)return t.preventDefault(),void cn(p.currency);if("%"===n||"5"===n)return t.preventDefault(),void cn("0%")}},onCopy:e=>{_t||xn(!1,e)},onCut:e=>{_t||xn(!0,e)},onPaste:e=>{_t||(e.preventDefault(),bn(e.clipboardData.getData("text/plain"),"all"))}})}),bt("div",{className:"flex shrink-0 items-center border-t border-line bg-surface-sunken",children:[bt("div",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto px-1 py-1",children:[xt(Ie,{"aria-label":x.addSheet,title:x.addSheet,size:"sm",variant:"ghost",onClick:Tn,children:xt(Ee,{name:"add",size:14})}),Fe.map((e,t)=>xt("button",{type:"button",onClick:()=>(e=>{_t&&!Yr&&Br(),Ze(e),ir(null)})(t),onDoubleClick:()=>dr({index:t,name:e.name}),onContextMenu:e=>Dr.open(e,t),style:e.tabColor?{boxShadow:`inset 0 -3px 0 ${e.tabColor}`}:void 0,className:"whitespace-nowrap rounded px-3 py-1 text-xs font-medium "+(t===Ot?"bg-accent-tint text-accent-text":"text-ink-muted hover:bg-line-subtle hover:text-ink"),children:ur?.index===t?xt("input",{type:"text",value:ur.name,autoFocus:!0,"aria-label":x.rename,onChange:e=>dr({index:t,name:e.target.value}),onBlur:Mn,onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&Mn()},onClick:e=>e.stopPropagation(),className:"w-24 rounded border border-accent-fill bg-surface px-1 text-xs text-ink outline-none"}):e.name},e.id))]}),Ln&&Ln.count>0&&bt("div",{className:"flex shrink-0 items-center gap-3 border-l border-line px-3 py-1 text-xs text-ink-muted",children:[Ln.numbers>0&&bt("span",{children:[x.statSum,": ",Pn(Ln.sum)]}),null!==Ln.average&&bt("span",{children:[x.statAverage,": ",Pn(Ln.average)]}),bt("span",{children:[x.statCount,": ",Ln.count]}),Ln.numbers>0&&bt("span",{children:[x.statMin,": ",Pn(Ln.min)]}),Ln.numbers>0&&bt("span",{children:[x.statMax,": ",Pn(Ln.max)]})]})]}),Sr.state&&xt(Ae,{...Sr.props,items:(so=Sr.state.data.kind,[$n("cut",x.cut,()=>Jr(()=>xn(!0))),$n("copy",x.copy,()=>Jr(()=>xn(!1))),$n("paste",x.paste,()=>yn("all")),$n("pasteValues",x.pasteValues,()=>yn("values")),Bn("a"),..."col"!==so?[$n("rowAbove",x.rowsAbove,()=>un("row",!1)),$n("rowBelow",x.rowsBelow,()=>un("row",!0))]:[],..."row"!==so?[$n("colLeft",x.columnsLeft,()=>un("col",!1)),$n("colRight",x.columnsRight,()=>un("col",!0))]:[],Bn("b"),..."col"!==so?[$n("delRows",x.deleteRows,()=>dn("row"),{danger:!0})]:[],..."row"!==so?[$n("delCols",x.deleteColumns,()=>dn("col"),{danger:!0})]:[],$n("clear",x.clearValues,()=>Jr(()=>Rr(e=>C(e,Xt.range)))),Bn("c"),..."col"!==so?[$n("hideRows",x.hideRows,()=>fn("row"))]:[],..."row"!==so?[$n("hideCols",x.hideColumns,()=>fn("col"))]:[],..."col"!==so&&Lt.hiddenRows.length?[$n("unhideRows",x.unhideRows,()=>hn("row"))]:[],..."row"!==so&&Lt.hiddenCols.length?[$n("unhideCols",x.unhideColumns,()=>hn("col"))]:[]])}),Dr.state&&xt(Ae,{...Dr.props,items:(co=Dr.state.data,[$n("rename",x.rename,()=>dr({index:co,name:Fe[co].name})),$n("duplicate",x.duplicate,()=>{lt(e=>M(e,co,W(e,Fe[co].name))),Ze(co+1)}),$n("left",x.moveLeft,()=>An(co,-1),{disabled:0===co}),$n("right",x.moveRight,()=>An(co,1),{disabled:co===Fe.length-1}),{type:"submenu",key:"colour",label:x.tabColor,items:[$n("none",x.noColor,()=>lt(e=>e.map((e,t)=>t===co?{...e,tabColor:void 0}:e))),...ht.slice(7,17).map(e=>$n(e,bt("span",{className:"flex items-center gap-2",children:[xt("span",{className:"inline-block h-3 w-3 rounded-sm",style:{background:e}}),e]}),()=>lt(t=>t.map((t,r)=>r===co?{...t,tabColor:e}:t))))]},Bn("a"),$n("delete",x.deleteSheet,()=>{(async e=>{Fe.length<=1||(null===ue(Fe[e])||await He({title:x.deleteSheetTitle,message:x.deleteSheetMessage(Fe[e].name),confirmLabel:x.deleteSheet}))&&(lt(t=>T(t,e)),Ze(t=>t>e||t>=Fe.length-1?Math.max(0,t-1):t))})(co)},{danger:!0,disabled:Fe.length<=1})])}),ar&&bt(Ue,{portal:!0,minWidth:230,onClose:()=>ir(null),style:{position:"fixed",left:ar.x,top:ar.y},children:[xt(Be,{onClick:()=>On(ar.col,!0),children:x.sortAscending}),xt(Be,{onClick:()=>On(ar.col,!1),children:x.sortDescending}),xt($e,{}),xt("div",{className:"px-2 py-1",children:xt(Oe,{size:"sm","aria-label":x.find,placeholder:x.find,value:ar.search,onChange:e=>ir({...ar,search:e.target.value})})}),xt("div",{className:"max-h-52 overflow-y-auto px-2 py-1",children:io.map(e=>xt("div",{className:"py-0.5",children:xt(Te,{label:e||x.blank,checked:!ar.unticked.has(e),onChange:t=>{const r=new Set(ar.unticked);t?r.delete(e):r.add(e),ir({...ar,unticked:r})}})},e))}),bt("div",{className:"flex items-center justify-between gap-2 border-t border-line px-2 py-1",children:[xt(Re,{size:"sm",variant:"ghost",onClick:()=>ir({...ar,unticked:new Set}),children:x.clear}),xt(Re,{size:"sm",variant:"primary",onClick:()=>{if(!ar)return;const{col:e,unticked:t}=ar;ir(null),Jr(()=>Rr(r=>{if(!r.filter)return r;const n={...r.filter.excluded};return t.size?n[e]=[...t]:delete n[e],{...r,filter:{...r.filter,excluded:n}}}))},children:x.apply})]})]})]});var co,so,uo}function At(e,t){const r=e.rows?e.rows.map(e=>e.map(e=>String(e??""))):V(e.csv??"");return 0===r.length?null:oe(t,r)}export{Rt as OpenSpreadsheet,Et as SpreadsheetById,Tt as SpreadsheetPane,Dt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readXlsx as t}from"./chunk-
|
|
1
|
+
import{readXlsx as t}from"./chunk-4M3QRYCH.js";import{formatKey as e,newSheet as r,parseCsv as s,sheetFromRows as n,writeCells as c}from"./chunk-UDEPDAZI.js";import{titleOf as a}from"./chunk-XYVQTQ6N.js";async function o(t){const s=await(import("xlsx")),n=s.read(t,{type:"array",cellFormula:!0,cellNF:!0});return n.SheetNames.map(t=>{const a=n.Sheets[t],o=r(t),i=[],f={};if(a["!ref"]){const t=s.utils.decode_range(a["!ref"]);for(let r=t.s.r;r<=t.e.r;r++)for(let n=t.s.c;n<=t.e.c;n++){const t=a[s.utils.encode_cell({r:r,c:n})];if(!t||void 0===t.v&&!t.f)continue;const c=t.f?`=${t.f}`:"b"===t.t?t.v?"TRUE":"FALSE":String(t.v);i.push({row:r,col:n,raw:"s"===t.t&&/^(?:=|-?\d|'|true$|false$)/i.test(c)?`'${c}`:c}),t.z&&"General"!==t.z&&(f[e(r,n)]={numFmt:t.z})}}const l={};(a["!cols"]??[]).forEach((t,e)=>{t?.wpx&&(l[e]=t.wpx)});const m=(a["!merges"]??[]).map(t=>({r1:t.s.r,c1:t.s.c,r2:t.e.r,c2:t.e.c}));return{...c(o,i),formats:f,colWidths:l,merges:m}})}async function i(e,r,c="Sheet1"){const i=await async function(e,r){if(/\.(xlsx|xls|ods)$/i.test(e.name)){const r=new Uint8Array(await e.arrayBuffer());return/\.xlsx$/i.test(e.name)&&"undefined"!=typeof DecompressionStream?t(r):o(r)}const c=s(await e.text());return[n(r,c.length?c:[[""]])]}(r,c),f=a(r.name),l=await e.create(f);try{await e.save(l.id,{sheets:i},l.version)}catch(t){throw await e.remove(l.id).catch(()=>{}),t}return{id:l.id,title:f}}export{o as readWithSheetJs,i as importSpreadsheetFile};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DEFAULT_COL_WIDTH as t,DEFAULT_FONT_SIZE as e,DEFAULT_ROW_HEIGHT as n,FormulaError as r,colIndex as o,colLabel as s,formatKey as l,isFormula as i,newSheet as a,rangeLabel as m,shiftFormula as c,tokenize as f,usedBounds as u}from"./chunk-VKCG3LPQ.js";var h=(()=>{const t=new Uint32Array(256);for(let e=0;e<256;e++){let n=e;for(let t=0;t<8;t++)n=1&n?3988292384^n>>>1:n>>>1;t[e]=n>>>0}return t})();function d(t){let e=4294967295;for(let n=0;n<t.length;n++)e=h[255&(e^t[n])]^e>>>8;return(4294967295^e)>>>0}async function g(t,e){const n=e.writable.getWriter();return n.write(t).then(()=>n.close()).catch(()=>{}),new Uint8Array(await new Response(e.readable).arrayBuffer())}async function p(t){return"undefined"==typeof CompressionStream?null:g(t,new CompressionStream("deflate-raw"))}async function $(t){return g(t,new DecompressionStream("deflate-raw"))}async function b(t){const e=new TextEncoder,n=[],r=[];let o=0;for(const s of t){const t=e.encode(s.name),l=e.encode(s.text),i=await p(l),a=null===i||i.length>=l.length,m=a?l:i,c=d(l),f=new Uint8Array(30+t.length),u=new DataView(f.buffer);u.setUint32(0,67324752,!0),u.setUint16(4,20,!0),u.setUint16(6,2048,!0),u.setUint16(8,a?0:8,!0),u.setUint32(14,c,!0),u.setUint32(18,m.length,!0),u.setUint32(22,l.length,!0),u.setUint16(26,t.length,!0),f.set(t,30);const h=new Uint8Array(46+t.length),g=new DataView(h.buffer);g.setUint32(0,33639248,!0),g.setUint16(4,20,!0),g.setUint16(6,20,!0),g.setUint16(8,2048,!0),g.setUint16(10,a?0:8,!0),g.setUint32(16,c,!0),g.setUint32(20,m.length,!0),g.setUint32(24,l.length,!0),g.setUint16(28,t.length,!0),g.setUint32(42,o,!0),h.set(t,46),n.push(f,m),r.push(h),o+=f.length+m.length}const s=r.reduce((t,e)=>t+e.length,0),l=new Uint8Array(22),i=new DataView(l.buffer);i.setUint32(0,101010256,!0),i.setUint16(8,t.length,!0),i.setUint16(10,t.length,!0),i.setUint32(12,s,!0),i.setUint32(16,o,!0);const a=new Uint8Array(o+s+22);let m=0;for(const t of[...n,...r,l])a.set(t,m),m+=t.length;return a}async function x(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength);let n=-1;for(let r=t.length-22;r>=Math.max(0,t.length-66e3);r--)if(101010256===e.getUint32(r,!0)){n=r;break}if(n<0)throw new Error("Not a zip file");const r=e.getUint16(n+10,!0);let o=e.getUint32(n+16,!0);const s=new TextDecoder,l=new Map;for(let n=0;n<r;n++){const n=e.getUint16(o+10,!0),r=e.getUint32(o+20,!0),i=e.getUint16(o+28,!0),a=e.getUint16(o+30,!0),m=e.getUint16(o+32,!0),c=e.getUint32(o+42,!0),f=s.decode(t.subarray(o+46,o+46+i));if(o+=46+i+a+m,!/\.(xml|rels)$/i.test(f))continue;const u=c+30+e.getUint16(c+26,!0)+e.getUint16(c+28,!0),h=t.subarray(u,u+r);l.set(f,s.decode(8===n?await $(h):h))}return l}var w=new Set(["CONCAT","IFS","SWITCH","TEXTJOIN","XLOOKUP","XOR","IFNA","DAYS","STDEV.S","STDEV.P","VAR.S","VAR.P","MODE.SNGL","RANK.EQ","CEILING.MATH","FLOOR.MATH"]);function F(t){const{tokens:e}=f(t);let n="",r=0;for(const o of e){if("ident"!==o.type)continue;const e=o.value.replace(/^_xlfn\.(?:_xlws\.)?/i,"").replace(/^_xlws\./i,"");e!==o.value&&(n+=t.slice(r,o.start)+e,r=o.end)}return`=${n}${t.slice(r)}`}function y(t){return t.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}var A='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n',C="http://schemas.openxmlformats.org/spreadsheetml/2006/main",v="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function N(t){return`FF${t.replace("#","").toUpperCase().padStart(6,"0").slice(0,6)}`}var U=class{fonts=[`<font><sz val="${e}"/><name val="Arial"/></font>`];fills=['<fill><patternFill patternType="none"/></fill>','<fill><patternFill patternType="gray125"/></fill>'];borders=["<border><left/><right/><top/><bottom/><diagonal/></border>"];numFmts=[];xfs=['<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>'];seen=new Map;index(t,e){const n=t.indexOf(e);return n>=0?n:(t.push(e),t.length-1)}add(t){if(!t||!Object.keys(t).length)return 0;const n=JSON.stringify(t),r=this.seen.get(n);if(void 0!==r)return r;const o=this.index(this.fonts,`<font>${t.bold?"<b/>":""}${t.italic?"<i/>":""}${t.strike?"<strike/>":""}${t.underline?"<u/>":""}<sz val="${t.fontSize??e}"/>${t.color?`<color rgb="${N(t.color)}"/>`:""}<name val="Arial"/></font>`),s=t.fill?this.index(this.fills,`<fill><patternFill patternType="solid"><fgColor rgb="${N(t.fill)}"/><bgColor indexed="64"/></patternFill></fill>`):0,l=(t,e)=>e?`<${t} style="thin"><color auto="1"/></${t}>`:`<${t}/>`,i=t.border??{},a=this.index(this.borders,`<border>${l("left",i.left)}${l("right",i.right)}${l("top",i.top)}${l("bottom",i.bottom)}<diagonal/></border>`);let m=0;t.numFmt&&"General"!==t.numFmt&&(m="@"===t.numFmt?49:164+this.index(this.numFmts,t.numFmt));const c=t.align||t.vAlign||t.wrap?`<alignment${t.align?` horizontal="${t.align}"`:""}${t.vAlign?` vertical="${"middle"===t.vAlign?"center":t.vAlign}"`:""}${t.wrap?' wrapText="1"':""}/>`:"",f=`<xf numFmtId="${m}" fontId="${o}" fillId="${s}" borderId="${a}" xfId="0" applyFont="1"${s?' applyFill="1"':""}${a?' applyBorder="1"':""}${m?' applyNumberFormat="1"':""}${c?' applyAlignment="1"':""}${c?`>${c}</xf>`:"/>"}`;return this.xfs.push(f),this.seen.set(n,this.xfs.length-1),this.xfs.length-1}toXml(){const t=this.numFmts.length?`<numFmts count="${this.numFmts.length}">${this.numFmts.map((t,e)=>`<numFmt numFmtId="${164+e}" formatCode="${y(t)}"/>`).join("")}</numFmts>`:"";return`${A}<styleSheet xmlns="${C}">${t}<fonts count="${this.fonts.length}">${this.fonts.join("")}</fonts><fills count="${this.fills.length}">${this.fills.join("")}</fills><borders count="${this.borders.length}">${this.borders.join("")}</borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="${this.xfs.length}">${this.xfs.join("")}</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>`}};function S(t,e,n,o,a,m){const c=`${s(a)}${o+1}`,u=t.cells[o]?.[a]??"",h=t.formats[l(o,a)],d=m.add(h),g=d?` s="${d}"`:"";if(""===u)return d?`<c r="${c}"${g}/>`:"";const p=n.value(e,o,a);if(i(u)){const t=`<f>${y(function(t){const e=t.slice(1),{tokens:n}=f(e);let r="",o=0;for(let t=0;t<n.length;t++){const s=n[t],l=n[t+1];"ident"===s.type&&"op"===l?.type&&"("===l.value&&w.has(s.value.toUpperCase())&&(r+=`${e.slice(o,s.start)}_xlfn.${s.value.toUpperCase()}`,o=s.end)}return r+e.slice(o)}(u))}</f>`;if("number"==typeof p)return`<c r="${c}"${g}>${t}<v>${p}</v></c>`;if("boolean"==typeof p)return`<c r="${c}"${g} t="b">${t}<v>${p?1:0}</v></c>`;if(p instanceof r){return`<c r="${c}"${g} t="e">${t}<v>${/^#(?:REF!|N\/A|NAME\?|DIV\/0!|VALUE!|NUM!|NULL!)$/.test(p.code)?p.code:"#VALUE!"}</v></c>`}return`<c r="${c}"${g} t="str">${t}<v>${y(null===p?"":p)}</v></c>`}if("number"==typeof p)return`<c r="${c}"${g}><v>${p}</v></c>`;if("boolean"==typeof p)return`<c r="${c}"${g} t="b"><v>${p?1:0}</v></c>`;const $=String(p??"");return`<c r="${c}"${g} t="inlineStr"><is><t${$!==$.trim()||/\n/.test($)?' xml:space="preserve"':""}>${y($)}</t></is></c>`}function k(e,r,o,l){const i=u(e);let a=i?.row??0,c=i?.col??0;const f=new Map;for(const t of Object.keys(e.formats)){const[e,n]=t.split(":").map(Number);a=Math.max(a,e),c=Math.max(c,n),f.has(e)||f.set(e,[]),f.get(e).push(n)}const h=new Set(e.hiddenRows);for(const t of[...e.hiddenRows,...Object.keys(e.rowHeights).map(Number)])a=Math.max(a,t);const d=[];for(let t=0;t<=a;t++){const n=e.cells[t]??[],s=new Set(f.get(t)??[]);n.forEach((t,e)=>{""!==t&&s.add(e)});const i=e.rowHeights[t];if(!s.size&&void 0===i&&!h.has(t))continue;const a=[...s].sort((t,e)=>t-e).map(n=>S(e,r,o,t,n,l)).join(""),m=`${void 0!==i?` ht="${(.75*i).toFixed(2)}" customHeight="1"`:""}${h.has(t)?' hidden="1"':""}`;d.push(`<row r="${t+1}"${m}>${a}</row>`)}const g=new Set(e.hiddenCols),p=[...new Set([...Object.keys(e.colWidths).map(Number),...g])].sort((t,e)=>t-e),$=p.length?`<cols>${p.map(n=>`<col min="${n+1}" max="${n+1}" width="${(((e.colWidths[n]??t)-5)/7).toFixed(4)}" customWidth="1"${g.has(n)?' hidden="1"':""}/>`).join("")}</cols>`:"",{frozenRows:b,frozenCols:x}=e,w=b||x?`<pane${x?` xSplit="${x}"`:""}${b?` ySplit="${b}"`:""} topLeftCell="${s(x)}${b+1}" activePane="${b&&x?"bottomRight":b?"bottomLeft":"topRight"}" state="frozen"/>`:"",F=e.merges.length?`<mergeCells count="${e.merges.length}">${e.merges.map(t=>`<mergeCell ref="${m(t)}"/>`).join("")}</mergeCells>`:"",y=e.filter?`<autoFilter ref="${m(e.filter.range)}"/>`:"",v=e.tabColor?`<sheetPr><tabColor rgb="${N(e.tabColor)}"/></sheetPr>`:"";return`${A}<worksheet xmlns="${C}">${v}<dimension ref="A1:${s(c)}${a+1}"/><sheetViews><sheetView${0===r?' tabSelected="1"':""} workbookViewId="0">${w}</sheetView></sheetViews><sheetFormatPr defaultColWidth="${((t-5)/7).toFixed(4)}" defaultRowHeight="${(.75*n).toFixed(2)}" customHeight="1"/>${$}<sheetData>${d.join("")}</sheetData>${y}${F}</worksheet>`}async function I(t,e){const n=new U,r=function(t){const e=new Set;return t.map((t,n)=>{const r=t.name.replace(/[[\]:*?/\\]/g," ").trim().slice(0,31)||`Sheet ${n+1}`;let o=r;for(let t=2;e.has(o.toLowerCase());t++)o=`${r.slice(0,28)} ${t}`;return e.add(o.toLowerCase()),o})}(t),o=t.map((t,r)=>({name:`xl/worksheets/sheet${r+1}.xml`,text:k(t,r,e,n)})),l=t.map((t,e)=>{return t.filter?`<definedName name="_xlnm._FilterDatabase" localSheetId="${e}" hidden="1">${y(`'${r[e].replace(/'/g,"''")}'!${n=t.filter.range,`$${s(n.c1)}$${n.r1+1}:$${s(n.c2)}$${n.r2+1}`}`)}</definedName>`:"";var n}).join("");return b([{name:"[Content_Types].xml",text:`${A}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>${t.map((t,e)=>`<Override PartName="/xl/worksheets/sheet${e+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`).join("")}</Types>`},{name:"_rels/.rels",text:`${A}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${v}/officeDocument" Target="xl/workbook.xml"/></Relationships>`},{name:"xl/workbook.xml",text:`${A}<workbook xmlns="${C}" xmlns:r="${v}"><sheets>${r.map((t,e)=>`<sheet name="${y(t)}" sheetId="${e+1}" r:id="rId${e+1}"/>`).join("")}</sheets>${l?`<definedNames>${l}</definedNames>`:""}<calcPr calcId="0" fullCalcOnLoad="1"/></workbook>`},{name:"xl/_rels/workbook.xml.rels",text:`${A}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${t.map((t,e)=>`<Relationship Id="rId${e+1}" Type="${v}/worksheet" Target="worksheets/sheet${e+1}.xml"/>`).join("")}<Relationship Id="rId${t.length+1}" Type="${v}/styles" Target="styles.xml"/></Relationships>`},{name:"xl/styles.xml",text:n.toXml()},...o])}var T={1:"0",2:"0.00",3:"#,##0",4:"#,##0.00",9:"0%",10:"0.00%",11:"0.00E+00",14:"dd/mm/yyyy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"dd/mm/yyyy h:mm",37:"#,##0;(#,##0)",38:"#,##0;[Red](#,##0)",39:"#,##0.00;(#,##0.00)",40:"#,##0.00;[Red](#,##0.00)",45:"mm:ss",46:"[h]:mm:ss",47:"mm:ss.0",48:"##0.0E+0",49:"@"},E=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47","0563C1","954F72"],M={0:"000000",1:"FFFFFF",2:"FF0000",3:"00FF00",4:"0000FF",5:"FFFF00",6:"FF00FF",7:"00FFFF",8:"000000",9:"FFFFFF",10:"FF0000",11:"00FF00",12:"0000FF",13:"FFFF00",14:"FF00FF",15:"00FFFF"};function R(t){if(!t)return;const e=t.getAttribute("rgb");if(e)return`#${e.slice(-6).toLowerCase()}`;const n=Number(t.getAttribute("tint")??0),r=t.getAttribute("theme");if(null!==r){const t=E[Number(r)];return t?`#${function(t,e){const n=n=>{const r=parseInt(t.slice(n,n+2),16),o=e<0?r*(1+e):r+(255-r)*e;return Math.round(o).toString(16).padStart(2,"0")};return`${n(0)}${n(2)}${n(4)}`}(t,n)}`.toLowerCase():void 0}const o=t.getAttribute("indexed");if(null!==o){const t=M[Number(o)];return t?`#${t}`.toLowerCase():void 0}}var D=t=>(new DOMParser).parseFromString(t,"application/xml"),j=(t,e)=>Array.from(t.getElementsByTagNameNS("*",e)),O=(t,e)=>j(t,e)[0],L=(t,e)=>Array.from(t.children).filter(t=>t.localName===e);function V(t){const e=/^([A-Z]+)(\d+)$/.exec(t);return{row:Number(e[2])-1,col:o(e[1])}}function z(t){const[e,n=e]=t.replace(/\$/g,"").split(":"),r=V(e),o=V(n);return{r1:r.row,c1:r.col,r2:o.row,c2:o.col}}function P(t,e,n,r){const o=D(e),s=a(t),i=[],m={},f=new Map;for(const t of j(o,"c")){const e=t.getAttribute("r");if(!e)continue;const{row:o,col:s}=V(e),a=r[Number(t.getAttribute("s")??0)];a&&Object.keys(a).length&&(m[l(o,s)]=a);const u=L(t,"f")[0],h=L(t,"v")[0]?.textContent??"",d=t.getAttribute("t");let g="";if(u){const t=u.getAttribute("si");if("shared"===u.getAttribute("t")&&null!==t)if(u.textContent)f.set(t,{text:u.textContent,row:o,col:s}),g=F(u.textContent);else{const e=f.get(t);e&&(g=c(F(e.text),o-e.row,s-e.col))}else u.textContent&&(g=F(u.textContent))}if(g||(g="s"===d?n[Number(h)]??"":"inlineStr"===d?j(t,"t").map(t=>t.textContent??"").join(""):"b"===d?"1"===h?"TRUE":"FALSE":h,"s"!==d&&"inlineStr"!==d&&"str"!==d||!/^(?:=|-?\d|'|true$|false$)/i.test(g)||(g=`'${g}`)),""!==g){for(;i.length<=o;)i.push([]);for(;i[o].length<=s;)i[o].push("");i[o][s]=g}}const u={},h=[];for(const t of j(o,"col")){const e=Number(t.getAttribute("min"))-1,n=Math.min(Number(t.getAttribute("max"))-1,e+500),r=Number(t.getAttribute("width")??0);for(let o=e;o<=n;o++)r&&"1"===t.getAttribute("customWidth")&&(u[o]=Math.round(7*r+5)),"1"===t.getAttribute("hidden")&&h.push(o)}const d={},g=[];for(const t of j(o,"row")){const e=Number(t.getAttribute("r"))-1,n=t.getAttribute("ht");n&&"1"===t.getAttribute("customHeight")&&(d[e]=Math.round(Number(n)/.75)),"1"===t.getAttribute("hidden")&&g.push(e)}const p=O(o,"pane"),$="frozen"===p?.getAttribute("state"),b=O(o,"autoFilter")?.getAttribute("ref"),x=R(O(o,"tabColor"));return{...s,tabColor:x,cells:i,formats:m,colWidths:u,rowHeights:d,hiddenCols:h,hiddenRows:g,merges:j(o,"mergeCell").map(t=>z(t.getAttribute("ref")??"A1")),frozenRows:$?Number(p?.getAttribute("ySplit")??0):0,frozenCols:$?Number(p?.getAttribute("xSplit")??0):0,filter:b?{range:z(b),excluded:{}}:null,rowCount:Math.max(s.rowCount,i.length+100),colCount:Math.max(s.colCount,i.reduce((t,e)=>Math.max(t,e.length),0))}}async function H(t){const e=await x(t),n=e.get("xl/workbook.xml");if(!n)throw new Error("Not a workbook");const r=D(e.get("xl/_rels/workbook.xml.rels")??"<Relationships/>"),o=new Map(j(r,"Relationship").map(t=>[t.getAttribute("Id"),t.getAttribute("Target")??""])),s=e.get("xl/sharedStrings.xml")?j(D(e.get("xl/sharedStrings.xml")),"si").map(t=>j(t,"t").filter(t=>"rPh"!==t.parentElement?.localName).map(t=>t.textContent??"").join("")):[],l=function(t){if(!t)return[];const e=D(t),n=new Map(j(e,"numFmt").map(t=>[Number(t.getAttribute("numFmtId")),t.getAttribute("formatCode")??""])),r=O(e,"fonts"),o=O(e,"fills"),s=O(e,"borders"),l=O(e,"cellXfs");if(!l)return[];const i=r?L(r,"font"):[],a=o?L(o,"fill"):[],m=s?L(s,"border"):[],c=Number(i[0]?L(i[0],"sz")[0]?.getAttribute("val")??0:0);return L(l,"xf").map(t=>{const e={},r=Number(t.getAttribute("numFmtId")??0),o=n.get(r)??T[r];o&&"General"!==o&&(e.numFmt=o);const s=i[Number(t.getAttribute("fontId")??0)];if(s){L(s,"b").length&&(e.bold=!0),L(s,"i").length&&(e.italic=!0),L(s,"u").length&&(e.underline=!0),L(s,"strike").length&&(e.strike=!0);const t=Number(L(s,"sz")[0]?.getAttribute("val")??0);t&&t!==c&&(e.fontSize=t);const n=R(L(s,"color")[0]);n&&"#000000"!==n&&(e.color=n)}const l=a[Number(t.getAttribute("fillId")??0)]?.getElementsByTagNameNS("*","patternFill")[0];if(l&&"solid"===l.getAttribute("patternType")){const t=R(L(l,"fgColor")[0]);t&&(e.fill=t)}const f=m[Number(t.getAttribute("borderId")??0)];if(f){const t=t=>!!L(f,t)[0]?.getAttribute("style"),n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")};(n.top||n.right||n.bottom||n.left)&&(e.border={...n.top?{top:!0}:{},...n.right?{right:!0}:{},...n.bottom?{bottom:!0}:{},...n.left?{left:!0}:{}})}const u=L(t,"alignment")[0];if(u){const t=u.getAttribute("horizontal");"left"!==t&&"center"!==t&&"right"!==t||(e.align=t);const n=u.getAttribute("vertical");"top"!==n&&"bottom"!==n||(e.vAlign=n),"center"===n&&(e.vAlign="middle");const r=u.getAttribute("wrapText");"1"!==r&&"true"!==r||(e.wrap=!0)}return e})}(e.get("xl/styles.xml")),i=[];for(const t of j(D(n),"sheet")){const n=t.getAttribute("name")??`Sheet ${i.length+1}`,r=t.getAttributeNS(v,"id")??t.getAttribute("r:id"),a=o.get(r)??"",m=a.startsWith("/")?a.slice(1):`xl/${a}`,c=e.get(m);c&&i.push(P(n,c,s,l))}if(!i.length)throw new Error("No sheets");return i}export{b as zip,x as unzip,I as writeXlsx,H as readXlsx};
|
|
1
|
+
import{DEFAULT_COL_WIDTH as t,DEFAULT_FONT_SIZE as e,DEFAULT_ROW_HEIGHT as n,FormulaError as r,colIndex as o,colLabel as s,formatKey as l,isFormula as i,newSheet as a,rangeLabel as m,shiftFormula as c,tokenize as f,usedBounds as u}from"./chunk-UDEPDAZI.js";var h=(()=>{const t=new Uint32Array(256);for(let e=0;e<256;e++){let n=e;for(let t=0;t<8;t++)n=1&n?3988292384^n>>>1:n>>>1;t[e]=n>>>0}return t})();function d(t){let e=4294967295;for(let n=0;n<t.length;n++)e=h[255&(e^t[n])]^e>>>8;return(4294967295^e)>>>0}async function g(t,e){const n=e.writable.getWriter();return n.write(t).then(()=>n.close()).catch(()=>{}),new Uint8Array(await new Response(e.readable).arrayBuffer())}async function p(t){return"undefined"==typeof CompressionStream?null:g(t,new CompressionStream("deflate-raw"))}async function $(t){return g(t,new DecompressionStream("deflate-raw"))}async function b(t){const e=new TextEncoder,n=[],r=[];let o=0;for(const s of t){const t=e.encode(s.name),l=e.encode(s.text),i=await p(l),a=null===i||i.length>=l.length,m=a?l:i,c=d(l),f=new Uint8Array(30+t.length),u=new DataView(f.buffer);u.setUint32(0,67324752,!0),u.setUint16(4,20,!0),u.setUint16(6,2048,!0),u.setUint16(8,a?0:8,!0),u.setUint32(14,c,!0),u.setUint32(18,m.length,!0),u.setUint32(22,l.length,!0),u.setUint16(26,t.length,!0),f.set(t,30);const h=new Uint8Array(46+t.length),g=new DataView(h.buffer);g.setUint32(0,33639248,!0),g.setUint16(4,20,!0),g.setUint16(6,20,!0),g.setUint16(8,2048,!0),g.setUint16(10,a?0:8,!0),g.setUint32(16,c,!0),g.setUint32(20,m.length,!0),g.setUint32(24,l.length,!0),g.setUint16(28,t.length,!0),g.setUint32(42,o,!0),h.set(t,46),n.push(f,m),r.push(h),o+=f.length+m.length}const s=r.reduce((t,e)=>t+e.length,0),l=new Uint8Array(22),i=new DataView(l.buffer);i.setUint32(0,101010256,!0),i.setUint16(8,t.length,!0),i.setUint16(10,t.length,!0),i.setUint32(12,s,!0),i.setUint32(16,o,!0);const a=new Uint8Array(o+s+22);let m=0;for(const t of[...n,...r,l])a.set(t,m),m+=t.length;return a}async function x(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength);let n=-1;for(let r=t.length-22;r>=Math.max(0,t.length-66e3);r--)if(101010256===e.getUint32(r,!0)){n=r;break}if(n<0)throw new Error("Not a zip file");const r=e.getUint16(n+10,!0);let o=e.getUint32(n+16,!0);const s=new TextDecoder,l=new Map;for(let n=0;n<r;n++){const n=e.getUint16(o+10,!0),r=e.getUint32(o+20,!0),i=e.getUint16(o+28,!0),a=e.getUint16(o+30,!0),m=e.getUint16(o+32,!0),c=e.getUint32(o+42,!0),f=s.decode(t.subarray(o+46,o+46+i));if(o+=46+i+a+m,!/\.(xml|rels)$/i.test(f))continue;const u=c+30+e.getUint16(c+26,!0)+e.getUint16(c+28,!0),h=t.subarray(u,u+r);l.set(f,s.decode(8===n?await $(h):h))}return l}var w=new Set(["CONCAT","IFS","SWITCH","TEXTJOIN","XLOOKUP","XOR","IFNA","DAYS","STDEV.S","STDEV.P","VAR.S","VAR.P","MODE.SNGL","RANK.EQ","CEILING.MATH","FLOOR.MATH"]);function F(t){const{tokens:e}=f(t);let n="",r=0;for(const o of e){if("ident"!==o.type)continue;const e=o.value.replace(/^_xlfn\.(?:_xlws\.)?/i,"").replace(/^_xlws\./i,"");e!==o.value&&(n+=t.slice(r,o.start)+e,r=o.end)}return`=${n}${t.slice(r)}`}function y(t){return t.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}var A='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n',C="http://schemas.openxmlformats.org/spreadsheetml/2006/main",v="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function N(t){return`FF${t.replace("#","").toUpperCase().padStart(6,"0").slice(0,6)}`}var U=class{fonts=[`<font><sz val="${e}"/><name val="Arial"/></font>`];fills=['<fill><patternFill patternType="none"/></fill>','<fill><patternFill patternType="gray125"/></fill>'];borders=["<border><left/><right/><top/><bottom/><diagonal/></border>"];numFmts=[];xfs=['<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>'];seen=new Map;index(t,e){const n=t.indexOf(e);return n>=0?n:(t.push(e),t.length-1)}add(t){if(!t||!Object.keys(t).length)return 0;const n=JSON.stringify(t),r=this.seen.get(n);if(void 0!==r)return r;const o=this.index(this.fonts,`<font>${t.bold?"<b/>":""}${t.italic?"<i/>":""}${t.strike?"<strike/>":""}${t.underline?"<u/>":""}<sz val="${t.fontSize??e}"/>${t.color?`<color rgb="${N(t.color)}"/>`:""}<name val="Arial"/></font>`),s=t.fill?this.index(this.fills,`<fill><patternFill patternType="solid"><fgColor rgb="${N(t.fill)}"/><bgColor indexed="64"/></patternFill></fill>`):0,l=(t,e)=>e?`<${t} style="thin"><color auto="1"/></${t}>`:`<${t}/>`,i=t.border??{},a=this.index(this.borders,`<border>${l("left",i.left)}${l("right",i.right)}${l("top",i.top)}${l("bottom",i.bottom)}<diagonal/></border>`);let m=0;t.numFmt&&"General"!==t.numFmt&&(m="@"===t.numFmt?49:164+this.index(this.numFmts,t.numFmt));const c=t.align||t.vAlign||t.wrap?`<alignment${t.align?` horizontal="${t.align}"`:""}${t.vAlign?` vertical="${"middle"===t.vAlign?"center":t.vAlign}"`:""}${t.wrap?' wrapText="1"':""}/>`:"",f=`<xf numFmtId="${m}" fontId="${o}" fillId="${s}" borderId="${a}" xfId="0" applyFont="1"${s?' applyFill="1"':""}${a?' applyBorder="1"':""}${m?' applyNumberFormat="1"':""}${c?' applyAlignment="1"':""}${c?`>${c}</xf>`:"/>"}`;return this.xfs.push(f),this.seen.set(n,this.xfs.length-1),this.xfs.length-1}toXml(){const t=this.numFmts.length?`<numFmts count="${this.numFmts.length}">${this.numFmts.map((t,e)=>`<numFmt numFmtId="${164+e}" formatCode="${y(t)}"/>`).join("")}</numFmts>`:"";return`${A}<styleSheet xmlns="${C}">${t}<fonts count="${this.fonts.length}">${this.fonts.join("")}</fonts><fills count="${this.fills.length}">${this.fills.join("")}</fills><borders count="${this.borders.length}">${this.borders.join("")}</borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="${this.xfs.length}">${this.xfs.join("")}</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>`}};function S(t,e,n,o,a,m){const c=`${s(a)}${o+1}`,u=t.cells[o]?.[a]??"",h=t.formats[l(o,a)],d=m.add(h),g=d?` s="${d}"`:"";if(""===u)return d?`<c r="${c}"${g}/>`:"";const p=n.value(e,o,a);if(i(u)){const t=`<f>${y(function(t){const e=t.slice(1),{tokens:n}=f(e);let r="",o=0;for(let t=0;t<n.length;t++){const s=n[t],l=n[t+1];"ident"===s.type&&"op"===l?.type&&"("===l.value&&w.has(s.value.toUpperCase())&&(r+=`${e.slice(o,s.start)}_xlfn.${s.value.toUpperCase()}`,o=s.end)}return r+e.slice(o)}(u))}</f>`;if("number"==typeof p)return`<c r="${c}"${g}>${t}<v>${p}</v></c>`;if("boolean"==typeof p)return`<c r="${c}"${g} t="b">${t}<v>${p?1:0}</v></c>`;if(p instanceof r){return`<c r="${c}"${g} t="e">${t}<v>${/^#(?:REF!|N\/A|NAME\?|DIV\/0!|VALUE!|NUM!|NULL!)$/.test(p.code)?p.code:"#VALUE!"}</v></c>`}return`<c r="${c}"${g} t="str">${t}<v>${y(null===p?"":p)}</v></c>`}if("number"==typeof p)return`<c r="${c}"${g}><v>${p}</v></c>`;if("boolean"==typeof p)return`<c r="${c}"${g} t="b"><v>${p?1:0}</v></c>`;const $=String(p??"");return`<c r="${c}"${g} t="inlineStr"><is><t${$!==$.trim()||/\n/.test($)?' xml:space="preserve"':""}>${y($)}</t></is></c>`}function k(e,r,o,l){const i=u(e);let a=i?.row??0,c=i?.col??0;const f=new Map;for(const t of Object.keys(e.formats)){const[e,n]=t.split(":").map(Number);a=Math.max(a,e),c=Math.max(c,n),f.has(e)||f.set(e,[]),f.get(e).push(n)}const h=new Set(e.hiddenRows);for(const t of[...e.hiddenRows,...Object.keys(e.rowHeights).map(Number)])a=Math.max(a,t);const d=[];for(let t=0;t<=a;t++){const n=e.cells[t]??[],s=new Set(f.get(t)??[]);n.forEach((t,e)=>{""!==t&&s.add(e)});const i=e.rowHeights[t];if(!s.size&&void 0===i&&!h.has(t))continue;const a=[...s].sort((t,e)=>t-e).map(n=>S(e,r,o,t,n,l)).join(""),m=`${void 0!==i?` ht="${(.75*i).toFixed(2)}" customHeight="1"`:""}${h.has(t)?' hidden="1"':""}`;d.push(`<row r="${t+1}"${m}>${a}</row>`)}const g=new Set(e.hiddenCols),p=[...new Set([...Object.keys(e.colWidths).map(Number),...g])].sort((t,e)=>t-e),$=p.length?`<cols>${p.map(n=>`<col min="${n+1}" max="${n+1}" width="${(((e.colWidths[n]??t)-5)/7).toFixed(4)}" customWidth="1"${g.has(n)?' hidden="1"':""}/>`).join("")}</cols>`:"",{frozenRows:b,frozenCols:x}=e,w=b||x?`<pane${x?` xSplit="${x}"`:""}${b?` ySplit="${b}"`:""} topLeftCell="${s(x)}${b+1}" activePane="${b&&x?"bottomRight":b?"bottomLeft":"topRight"}" state="frozen"/>`:"",F=e.merges.length?`<mergeCells count="${e.merges.length}">${e.merges.map(t=>`<mergeCell ref="${m(t)}"/>`).join("")}</mergeCells>`:"",y=e.filter?`<autoFilter ref="${m(e.filter.range)}"/>`:"",v=e.tabColor?`<sheetPr><tabColor rgb="${N(e.tabColor)}"/></sheetPr>`:"";return`${A}<worksheet xmlns="${C}">${v}<dimension ref="A1:${s(c)}${a+1}"/><sheetViews><sheetView${0===r?' tabSelected="1"':""} workbookViewId="0">${w}</sheetView></sheetViews><sheetFormatPr defaultColWidth="${((t-5)/7).toFixed(4)}" defaultRowHeight="${(.75*n).toFixed(2)}" customHeight="1"/>${$}<sheetData>${d.join("")}</sheetData>${y}${F}</worksheet>`}async function I(t,e){const n=new U,r=function(t){const e=new Set;return t.map((t,n)=>{const r=t.name.replace(/[[\]:*?/\\]/g," ").trim().slice(0,31)||`Sheet ${n+1}`;let o=r;for(let t=2;e.has(o.toLowerCase());t++)o=`${r.slice(0,28)} ${t}`;return e.add(o.toLowerCase()),o})}(t),o=t.map((t,r)=>({name:`xl/worksheets/sheet${r+1}.xml`,text:k(t,r,e,n)})),l=t.map((t,e)=>{return t.filter?`<definedName name="_xlnm._FilterDatabase" localSheetId="${e}" hidden="1">${y(`'${r[e].replace(/'/g,"''")}'!${n=t.filter.range,`$${s(n.c1)}$${n.r1+1}:$${s(n.c2)}$${n.r2+1}`}`)}</definedName>`:"";var n}).join("");return b([{name:"[Content_Types].xml",text:`${A}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>${t.map((t,e)=>`<Override PartName="/xl/worksheets/sheet${e+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`).join("")}</Types>`},{name:"_rels/.rels",text:`${A}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${v}/officeDocument" Target="xl/workbook.xml"/></Relationships>`},{name:"xl/workbook.xml",text:`${A}<workbook xmlns="${C}" xmlns:r="${v}"><sheets>${r.map((t,e)=>`<sheet name="${y(t)}" sheetId="${e+1}" r:id="rId${e+1}"/>`).join("")}</sheets>${l?`<definedNames>${l}</definedNames>`:""}<calcPr calcId="0" fullCalcOnLoad="1"/></workbook>`},{name:"xl/_rels/workbook.xml.rels",text:`${A}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${t.map((t,e)=>`<Relationship Id="rId${e+1}" Type="${v}/worksheet" Target="worksheets/sheet${e+1}.xml"/>`).join("")}<Relationship Id="rId${t.length+1}" Type="${v}/styles" Target="styles.xml"/></Relationships>`},{name:"xl/styles.xml",text:n.toXml()},...o])}var T={1:"0",2:"0.00",3:"#,##0",4:"#,##0.00",9:"0%",10:"0.00%",11:"0.00E+00",14:"dd/mm/yyyy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"dd/mm/yyyy h:mm",37:"#,##0;(#,##0)",38:"#,##0;[Red](#,##0)",39:"#,##0.00;(#,##0.00)",40:"#,##0.00;[Red](#,##0.00)",45:"mm:ss",46:"[h]:mm:ss",47:"mm:ss.0",48:"##0.0E+0",49:"@"},E=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47","0563C1","954F72"],M={0:"000000",1:"FFFFFF",2:"FF0000",3:"00FF00",4:"0000FF",5:"FFFF00",6:"FF00FF",7:"00FFFF",8:"000000",9:"FFFFFF",10:"FF0000",11:"00FF00",12:"0000FF",13:"FFFF00",14:"FF00FF",15:"00FFFF"};function R(t){if(!t)return;const e=t.getAttribute("rgb");if(e)return`#${e.slice(-6).toLowerCase()}`;const n=Number(t.getAttribute("tint")??0),r=t.getAttribute("theme");if(null!==r){const t=E[Number(r)];return t?`#${function(t,e){const n=n=>{const r=parseInt(t.slice(n,n+2),16),o=e<0?r*(1+e):r+(255-r)*e;return Math.round(o).toString(16).padStart(2,"0")};return`${n(0)}${n(2)}${n(4)}`}(t,n)}`.toLowerCase():void 0}const o=t.getAttribute("indexed");if(null!==o){const t=M[Number(o)];return t?`#${t}`.toLowerCase():void 0}}var D=t=>(new DOMParser).parseFromString(t,"application/xml"),j=(t,e)=>Array.from(t.getElementsByTagNameNS("*",e)),O=(t,e)=>j(t,e)[0],L=(t,e)=>Array.from(t.children).filter(t=>t.localName===e);function z(t){const e=/^([A-Z]+)(\d+)$/.exec(t);return{row:Number(e[2])-1,col:o(e[1])}}function P(t){const[e,n=e]=t.replace(/\$/g,"").split(":"),r=z(e),o=z(n);return{r1:r.row,c1:r.col,r2:o.row,c2:o.col}}function V(t,e,n,r){const o=D(e),s=a(t),i=[],m={},f=new Map;for(const t of j(o,"c")){const e=t.getAttribute("r");if(!e)continue;const{row:o,col:s}=z(e),a=r[Number(t.getAttribute("s")??0)];a&&Object.keys(a).length&&(m[l(o,s)]=a);const u=L(t,"f")[0],h=L(t,"v")[0]?.textContent??"",d=t.getAttribute("t");let g="";if(u){const t=u.getAttribute("si");if("shared"===u.getAttribute("t")&&null!==t)if(u.textContent)f.set(t,{text:u.textContent,row:o,col:s}),g=F(u.textContent);else{const e=f.get(t);e&&(g=c(F(e.text),o-e.row,s-e.col))}else u.textContent&&(g=F(u.textContent))}if(g||(g="s"===d?n[Number(h)]??"":"inlineStr"===d?j(t,"t").map(t=>t.textContent??"").join(""):"b"===d?"1"===h?"TRUE":"FALSE":h,"s"!==d&&"inlineStr"!==d&&"str"!==d||!/^(?:=|-?\d|'|true$|false$)/i.test(g)||(g=`'${g}`)),""!==g){for(;i.length<=o;)i.push([]);for(;i[o].length<=s;)i[o].push("");i[o][s]=g}}const u={},h=[];for(const t of j(o,"col")){const e=Number(t.getAttribute("min"))-1,n=Math.min(Number(t.getAttribute("max"))-1,e+500),r=Number(t.getAttribute("width")??0);for(let o=e;o<=n;o++)r&&"1"===t.getAttribute("customWidth")&&(u[o]=Math.round(7*r+5)),"1"===t.getAttribute("hidden")&&h.push(o)}const d={},g=[];for(const t of j(o,"row")){const e=Number(t.getAttribute("r"))-1,n=t.getAttribute("ht");n&&"1"===t.getAttribute("customHeight")&&(d[e]=Math.round(Number(n)/.75)),"1"===t.getAttribute("hidden")&&g.push(e)}const p=O(o,"pane"),$="frozen"===p?.getAttribute("state"),b=O(o,"autoFilter")?.getAttribute("ref"),x=R(O(o,"tabColor"));return{...s,tabColor:x,cells:i,formats:m,colWidths:u,rowHeights:d,hiddenCols:h,hiddenRows:g,merges:j(o,"mergeCell").map(t=>P(t.getAttribute("ref")??"A1")),frozenRows:$?Number(p?.getAttribute("ySplit")??0):0,frozenCols:$?Number(p?.getAttribute("xSplit")??0):0,filter:b?{range:P(b),excluded:{}}:null,rowCount:Math.max(s.rowCount,i.length+100),colCount:Math.max(s.colCount,i.reduce((t,e)=>Math.max(t,e.length),0))}}async function H(t){const e=await x(t),n=e.get("xl/workbook.xml");if(!n)throw new Error("Not a workbook");const r=D(e.get("xl/_rels/workbook.xml.rels")??"<Relationships/>"),o=new Map(j(r,"Relationship").map(t=>[t.getAttribute("Id"),t.getAttribute("Target")??""])),s=e.get("xl/sharedStrings.xml")?j(D(e.get("xl/sharedStrings.xml")),"si").map(t=>j(t,"t").filter(t=>"rPh"!==t.parentElement?.localName).map(t=>t.textContent??"").join("")):[],l=function(t){if(!t)return[];const e=D(t),n=new Map(j(e,"numFmt").map(t=>[Number(t.getAttribute("numFmtId")),t.getAttribute("formatCode")??""])),r=O(e,"fonts"),o=O(e,"fills"),s=O(e,"borders"),l=O(e,"cellXfs");if(!l)return[];const i=r?L(r,"font"):[],a=o?L(o,"fill"):[],m=s?L(s,"border"):[],c=Number(i[0]?L(i[0],"sz")[0]?.getAttribute("val")??0:0);return L(l,"xf").map(t=>{const e={},r=Number(t.getAttribute("numFmtId")??0),o=n.get(r)??T[r];o&&"General"!==o&&(e.numFmt=o);const s=i[Number(t.getAttribute("fontId")??0)];if(s){L(s,"b").length&&(e.bold=!0),L(s,"i").length&&(e.italic=!0),L(s,"u").length&&(e.underline=!0),L(s,"strike").length&&(e.strike=!0);const t=Number(L(s,"sz")[0]?.getAttribute("val")??0);t&&t!==c&&(e.fontSize=t);const n=R(L(s,"color")[0]);n&&"#000000"!==n&&(e.color=n)}const l=a[Number(t.getAttribute("fillId")??0)]?.getElementsByTagNameNS("*","patternFill")[0];if(l&&"solid"===l.getAttribute("patternType")){const t=R(L(l,"fgColor")[0]);t&&(e.fill=t)}const f=m[Number(t.getAttribute("borderId")??0)];if(f){const t=t=>!!L(f,t)[0]?.getAttribute("style"),n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")};(n.top||n.right||n.bottom||n.left)&&(e.border={...n.top?{top:!0}:{},...n.right?{right:!0}:{},...n.bottom?{bottom:!0}:{},...n.left?{left:!0}:{}})}const u=L(t,"alignment")[0];if(u){const t=u.getAttribute("horizontal");"left"!==t&&"center"!==t&&"right"!==t||(e.align=t);const n=u.getAttribute("vertical");"top"!==n&&"bottom"!==n||(e.vAlign=n),"center"===n&&(e.vAlign="middle");const r=u.getAttribute("wrapText");"1"!==r&&"true"!==r||(e.wrap=!0)}return e})}(e.get("xl/styles.xml")),i=[];for(const t of j(D(n),"sheet")){const n=t.getAttribute("name")??`Sheet ${i.length+1}`,r=t.getAttributeNS(v,"id")??t.getAttribute("r:id"),a=o.get(r)??"",m=a.startsWith("/")?a.slice(1):`xl/${a}`,c=e.get(m);c&&i.push(V(n,c,s,l))}if(!i.length)throw new Error("No sheets");return i}export{b as zip,x as unzip,I as writeXlsx,H as readXlsx};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ENGLISH_WORDS as r}from"./chunk-
|
|
1
|
+
import{ENGLISH_WORDS as r}from"./chunk-MZJSGEU3.js";import{newSheet as e}from"./chunk-UDEPDAZI.js";var t=["xlsx","xls","ods","csv","tsv","txt"],s=t.map(r=>`.${r}`).join(",");import{createContext as o,useContext as a}from"react";import{jsx as n}from"react/jsx-runtime";var c=o(r);function i({words:r,children:e}){return n(c.Provider,{value:r,children:e})}var m=()=>a(c);import{createContext as l,useContext as u}from"react";import{jsx as v}from"react/jsx-runtime";var p=class extends Error{},x=l({});function d({value:r,children:e}){return v(x.Provider,{value:r,children:e})}var f=()=>u(x);function h(r,t){const s=Array.isArray(r?.sheets)?r.sheets:[];return s.length?s.map(r=>({...e(r.name),...r,cells:(r.cells??[]).map(r=>(r??[]).map(r=>r??""))})):[e(t)]}export{t as SPREADSHEET_EXTENSIONS,s as SPREADSHEET_ACCEPT,i as SpreadsheetWordsProvider,m as useSpreadsheetWords,p as SpreadsheetsConflict,d as SpreadsheetsProvider,f as useSpreadsheetsHost,h as sheetsOf};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ENGLISH_FILE_WORDS as e,ZH_HANS_FILE_WORDS as t}from"./chunk-B32ASXHM.js";var a={ABS:"Absolute value",AND:"True if all are true",AVERAGE:"Average of numbers",AVERAGEIF:"Average where a test passes",AVERAGEIFS:"Average on many tests",CEILING:"Rounds up to a multiple","CEILING.MATH":"Rounds up to a multiple",CHAR:"Character for a Unicode number",CHOOSE:"Picks by position",CLEAN:"Removes control characters",CODE:"Unicode number of the first character",COLUMN:"Column number",COLUMNS:"Number of columns",CONCAT:"Joins text",CONCATENATE:"Joins text",COS:"Cosine",COUNT:"Counts numbers",COUNTA:"Counts non-blank cells",COUNTBLANK:"Counts blank cells",COUNTIF:"Counts where a test passes",COUNTIFS:"Counts on many tests",DATE:"Builds a date",DATEDIF:"Time between dates",DAY:"Day of the month",DAYS:"Days between dates",EDATE:"Date some months away",EOMONTH:"Last day of a month",EXACT:"Same text, case included",EXP:"e to a power",FIND:"Position of text, case exact",FLOOR:"Rounds down to a multiple","FLOOR.MATH":"Rounds down to a multiple",FV:"Future value",HLOOKUP:"Looks along the top row",HOUR:"Hour of a time",IF:"One value or another",IFERROR:"A fallback for an error",IFNA:"A fallback for #N/A",IFS:"First test that passes",INDEX:"The cell at a position",INT:"Rounds down to a whole number",ISBLANK:"True if blank",ISERR:"True if an error other than #N/A",ISERROR:"True if an error",ISEVEN:"True if even",ISLOGICAL:"True if TRUE or FALSE",ISNA:"True if #N/A",ISNUMBER:"True if a number",ISODD:"True if odd",ISTEXT:"True if text",LARGE:"The kth largest",LEFT:"Text from the start",LEN:"Length of text",LN:"Natural logarithm",LOG:"Logarithm",LOG10:"Base-10 logarithm",LOWER:"Lower case",MATCH:"Position of a value",MAX:"Largest number",MAXIFS:"Largest where all tests pass",MEDIAN:"Middle number",MID:"Text from the middle",MIN:"Smallest number",MINIFS:"Smallest where all tests pass",MINUTE:"Minute of a time",MOD:"Remainder",MODE:"Most common number","MODE.SNGL":"Most common number",MONTH:"Month of a date",MROUND:"Rounds to the nearest multiple",N:"A value as a number",NA:"The #N/A error",NETWORKDAYS:"Working days between dates",NOT:"The opposite",NOW:"Date and time now",NPV:"Net present value",OR:"True if any is true",PERCENTILE:"Value at a percentile","PERCENTILE.INC":"Value at a percentile",PI:"The number pi",PMT:"Loan payment",POWER:"A number to a power",PRODUCT:"Multiplies numbers",PROPER:"Capitals on each word",PV:"Present value",QUARTILE:"Value at a quartile","QUARTILE.INC":"Value at a quartile",QUOTIENT:"Whole part of a division",RAND:"Random from 0 to 1",RANDBETWEEN:"Random whole number",RANK:"Rank in a list","RANK.EQ":"Rank in a list",REGEXEXTRACT:"Text a pattern finds",REGEXMATCH:"True if a pattern matches",REGEXREPLACE:"Replaces what a pattern finds",REPLACE:"Replaces by position",REPT:"Repeats text",RIGHT:"Text from the end",ROUND:"Rounds a number",ROUNDDOWN:"Rounds toward zero",ROUNDUP:"Rounds away from zero",ROW:"Row number",ROWS:"Number of rows",SEARCH:"Position of text, any case",SECOND:"Second of a time",SIGN:"Sign of a number",SIN:"Sine",SMALL:"The kth smallest",SQRT:"Square root",STDEV:"Standard deviation of a sample","STDEV.P":"Standard deviation of everything","STDEV.S":"Standard deviation of a sample",STDEVP:"Standard deviation of everything",SUBSTITUTE:"Replaces text",SUBTOTAL:"Total that skips other subtotals",SUM:"Adds numbers",SUMIF:"Adds where a test passes",SUMIFS:"Adds on many tests",SUMPRODUCT:"Multiplies, then adds",SWITCH:"Picks a result by value",TAN:"Tangent",TEXT:"A number as formatted text",TEXTJOIN:"Joins with a separator",TIME:"Builds a time",TODAY:"Today's date",TRIM:"Removes extra spaces",TRUNC:"Cuts off decimals",UPPER:"Upper case",VALUE:"Text as a number",VAR:"Variance of a sample","VAR.P":"Variance of everything","VAR.S":"Variance of a sample",VARP:"Variance of everything",VLOOKUP:"Looks down the first column",WEEKDAY:"Day of the week",XLOOKUP:"Looks up in any column",XOR:"True if an odd number are true",YEAR:"Year of a date"},o={ABS:"绝对值",AND:"全部为真时返回真",AVERAGE:"数字的平均值",AVERAGEIF:"满足条件的平均值",AVERAGEIFS:"满足多个条件的平均值",CEILING:"向上舍入到倍数","CEILING.MATH":"向上舍入到倍数",CHAR:"Unicode 编号对应的字符",CHOOSE:"按位置选择",CLEAN:"删除控制字符",CODE:"首字符的 Unicode 编号",COLUMN:"列号",COLUMNS:"列数",CONCAT:"连接文本",CONCATENATE:"连接文本",COS:"余弦",COUNT:"统计数字个数",COUNTA:"统计非空单元格",COUNTBLANK:"统计空单元格",COUNTIF:"统计满足条件的个数",COUNTIFS:"统计满足多个条件的个数",DATE:"生成日期",DATEDIF:"两个日期的间隔",DAY:"月份中的第几天",DAYS:"两个日期相差的天数",EDATE:"相隔若干个月的日期",EOMONTH:"月份的最后一天",EXACT:"文本完全相同",EXP:"e 的幂",FIND:"文本位置(区分大小写)",FLOOR:"向下舍入到倍数","FLOOR.MATH":"向下舍入到倍数",FV:"未来值",HLOOKUP:"在首行中查找",HOUR:"时间中的小时",IF:"二选一返回值",IFERROR:"出错时的备用值",IFNA:"#N/A 时的备用值",IFS:"第一个满足的条件",INDEX:"指定位置的单元格",INT:"向下取整",ISBLANK:"为空时返回真",ISERR:"为 #N/A 以外的错误时返回真",ISERROR:"为错误时返回真",ISEVEN:"为偶数时返回真",ISLOGICAL:"为逻辑值时返回真",ISNA:"为 #N/A 时返回真",ISNUMBER:"为数字时返回真",ISODD:"为奇数时返回真",ISTEXT:"为文本时返回真",LARGE:"第 k 大的值",LEFT:"从开头截取文本",LEN:"文本长度",LN:"自然对数",LOG:"对数",LOG10:"以 10 为底的对数",LOWER:"转为小写",MATCH:"值的位置",MAX:"最大值",MAXIFS:"满足全部条件的最大值",MEDIAN:"中位数",MID:"从中间截取文本",MIN:"最小值",MINIFS:"满足全部条件的最小值",MINUTE:"时间中的分钟",MOD:"余数",MODE:"出现最多的数字","MODE.SNGL":"出现最多的数字",MONTH:"日期中的月份",MROUND:"舍入到最接近的倍数",N:"转为数字",NA:"#N/A 错误",NETWORKDAYS:"两个日期之间的工作日",NOT:"取反",NOW:"当前日期和时间",NPV:"净现值",OR:"任一为真时返回真",PERCENTILE:"百分位数","PERCENTILE.INC":"百分位数",PI:"圆周率",PMT:"贷款每期还款额",POWER:"幂运算",PRODUCT:"数字相乘",PROPER:"每个单词首字母大写",PV:"现值",QUARTILE:"四分位数","QUARTILE.INC":"四分位数",QUOTIENT:"除法的整数部分",RAND:"0 到 1 之间的随机数",RANDBETWEEN:"随机整数",RANK:"在列表中的排名","RANK.EQ":"在列表中的排名",REGEXEXTRACT:"提取正则表达式匹配的文本",REGEXMATCH:"匹配正则表达式时返回真",REGEXREPLACE:"替换正则表达式匹配的文本",REPLACE:"按位置替换",REPT:"重复文本",RIGHT:"从末尾截取文本",ROUND:"四舍五入",ROUNDDOWN:"向零舍入",ROUNDUP:"远离零舍入",ROW:"行号",ROWS:"行数",SEARCH:"文本位置(不区分大小写)",SECOND:"时间中的秒",SIGN:"数字的符号",SIN:"正弦",SMALL:"第 k 小的值",SQRT:"平方根",STDEV:"样本标准差","STDEV.P":"总体标准差","STDEV.S":"样本标准差",STDEVP:"总体标准差",SUBSTITUTE:"替换文本",SUBTOTAL:"跳过其他小计的汇总",SUM:"数字求和",SUMIF:"对满足条件的值求和",SUMIFS:"对满足多个条件的值求和",SUMPRODUCT:"相乘后求和",SWITCH:"按值选择结果",TAN:"正切",TEXT:"数字转为带格式的文本",TEXTJOIN:"用分隔符连接",TIME:"生成时间",TODAY:"今天的日期",TRIM:"删除多余空格",TRUNC:"截去小数",UPPER:"转为大写",VALUE:"文本转为数字",VAR:"样本方差","VAR.P":"总体方差","VAR.S":"样本方差",VARP:"总体方差",VLOOKUP:"在首列中查找",WEEKDAY:"星期几",XLOOKUP:"在任意列中查找",XOR:"奇数个为真时返回真",YEAR:"日期中的年份"},r={pdfPageFailed:e=>`Page ${e} couldn't be drawn for the PDF.`,files:e,fileKind:"Excel",untitled:"Untitled",backToFiles:"Back to files",filesHeading:"Spreadsheets",newFile:"New spreadsheet",openFile:"Open a file",filesEmptyTitle:"Make your first spreadsheet",filesEmptyBody:"Every change saves by itself.",deleteFile:"Delete",createFailed:"The spreadsheet could not be made.",deleteFailed:"The spreadsheet could not be deleted.",storedOpenFailed:"This spreadsheet could not be opened.",loading:"Loading",renameFailed:"The spreadsheet could not be renamed.",conflict:"Somebody else saved this spreadsheet, so your latest changes are not saved. Reload to see theirs.",reload:"Reload",noStoreEdited:"Not saved. Save as Excel to keep your changes",saveToFiles:"Save to Files",noStoreClean:"No autosave here. Save as Excel to keep a copy",deleteConfirm:e=>`Delete "${e}"? Nobody can open it again.`,spreadsheetFile:"spreadsheet",sheetBase:"Sheet",menuFile:"File",menuEdit:"Edit",menuView:"View",menuInsert:"Insert",menuFormat:"Format",menuData:"Data",menuNew:"New",menuOpen:"Open",saveExcel:"Save as Excel (.xlsx)",saveCsv:"Download this sheet as CSV",email:"Email",undo:"Undo",redo:"Redo",cut:"Cut",copy:"Copy",paste:"Paste",pasteValues:"Paste values only",pasteFormats:"Paste formatting only",findReplace:"Find and replace",clearValues:"Clear contents",freeze:"Freeze",gridlines:"Gridlines",showFormulas:"Show formulas",rowsAbove:"Rows above",rowsBelow:"Rows below",columnsLeft:"Columns left",columnsRight:"Columns right",sheet:"Sheet",function:"Function",functions:"Functions",number:"Number format",bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",fontSize:"Font size",alignment:"Alignment",borders:"Borders",wrapText:"Wrap text",mergeCells:"Merge cells",clearFormatting:"Clear formatting",sortAscending:"Sort A to Z",sortDescending:"Sort Z to A",filter:"Filter",hideRows:"Hide rows",hideColumns:"Hide columns",unhideRows:"Show hidden rows",unhideColumns:"Show hidden columns",deleteRows:"Delete rows",deleteColumns:"Delete columns",formatGeneral:"Automatic",formatNumber:"Number",formatPercent:"Percent",formatScientific:"Scientific",formatCurrency:"Currency",formatDate:"Date",formatTime:"Time",formatDateTime:"Date and time",formatText:"Plain text",bordersAll:"All borders",bordersOuter:"Outer borders",bordersTop:"Top border",bordersBottom:"Bottom border",bordersLeft:"Left border",bordersRight:"Right border",bordersNone:"No borders",alignLeft:"Left",alignCenter:"Center",alignRight:"Right",alignTop:"Top",alignMiddle:"Middle",alignBottom:"Bottom",formatPainter:"Paint format",fewerDecimals:"Fewer decimal places",moreDecimals:"More decimal places",textColor:"Text color",fillColor:"Fill color",nameBox:"Selected cells",formulaBar:"Formula bar",cellEditor:"Cell contents",selectAll:"Select all",fillHandle:"Fill",find:"Find",replaceWith:"Replace with",replace:"Replace",replaceAll:"Replace all",previous:"Previous",next:"Next",close:"Close",matchCase:"Match case",wholeCell:"Whole cell",inFormulas:"In formulas",addSheet:"Add sheet",rename:"Rename",duplicate:"Duplicate",moveLeft:"Move left",moveRight:"Move right",tabColor:"Tab color",noColor:"No color",deleteSheet:"Delete sheet",deleteSheetTitle:"Delete this sheet?",sheetNameTaken:"Another sheet already has that name.",saveFailed:"Could not save the workbook. Try again.",openFailed:"Could not open that file. It may be damaged or an unsupported type.",statSum:"Sum",statAverage:"Average",statCount:"Count",statMin:"Min",statMax:"Max",blank:"(Blank)",clear:"Clear",apply:"Apply",sheetName:e=>`Sheet ${e}`,filterColumn:e=>`Filter column ${e}`,freezeRows:e=>0===e?"No frozen rows":1===e?"1 row":`${e} rows`,freezeColumns:e=>0===e?"No frozen columns":1===e?"1 column":`${e} columns`,freezeUpToRow:e=>`Up to row ${e}`,freezeUpToColumn:e=>`Up to column ${e}`,hitCount:(e,t)=>`${e} of ${t}`,replacedCount:e=>1===e?"Replaced in 1 cell":`Replaced in ${e} cells`,deleteSheetMessage:e=>`"${e}" and everything on it will be deleted. Formulas that use it will show #REF!.`,functionHelp:e=>a[e]??String(e)},l={pdfPageFailed:e=>`第 ${e} 页无法绘制到 PDF。`,files:t,fileKind:"Excel",untitled:"未命名",backToFiles:"返回文件",filesHeading:"电子表格",newFile:"新建电子表格",openFile:"打开文件",filesEmptyTitle:"创建您的第一个电子表格",filesEmptyBody:"每次更改都会自动保存。",deleteFile:"删除",createFailed:"无法创建电子表格。",deleteFailed:"无法删除电子表格。",storedOpenFailed:"无法打开此电子表格。",loading:"正在加载",renameFailed:"无法重命名电子表格。",conflict:"其他人已保存此电子表格,您最近的更改尚未保存。请重新加载以查看他们的版本。",reload:"重新加载",noStoreEdited:"未保存。请另存为 Excel 以保留更改",saveToFiles:"保存到文件",noStoreClean:"此处不会自动保存。请另存为 Excel 以保留副本",deleteConfirm:e=>`删除“${e}”?之后任何人都无法再打开它。`,spreadsheetFile:"电子表格",sheetBase:"工作表",menuFile:"文件",menuEdit:"编辑",menuView:"视图",menuInsert:"插入",menuFormat:"格式",menuData:"数据",menuNew:"新建",menuOpen:"打开",saveExcel:"另存为 Excel(.xlsx)",saveCsv:"将此工作表下载为 CSV",email:"发送邮件",undo:"撤销",redo:"重做",cut:"剪切",copy:"复制",paste:"粘贴",pasteValues:"仅粘贴数值",pasteFormats:"仅粘贴格式",findReplace:"查找和替换",clearValues:"清除内容",freeze:"冻结",gridlines:"网格线",showFormulas:"显示公式",rowsAbove:"在上方插入行",rowsBelow:"在下方插入行",columnsLeft:"在左侧插入列",columnsRight:"在右侧插入列",sheet:"工作表",function:"函数",functions:"函数",number:"数字格式",bold:"粗体",italic:"斜体",underline:"下划线",strikethrough:"删除线",fontSize:"字号",alignment:"对齐",borders:"边框",wrapText:"自动换行",mergeCells:"合并单元格",clearFormatting:"清除格式",sortAscending:"升序排序",sortDescending:"降序排序",filter:"筛选",hideRows:"隐藏行",hideColumns:"隐藏列",unhideRows:"显示隐藏的行",unhideColumns:"显示隐藏的列",deleteRows:"删除行",deleteColumns:"删除列",formatGeneral:"自动",formatNumber:"数字",formatPercent:"百分比",formatScientific:"科学计数",formatCurrency:"货币",formatDate:"日期",formatTime:"时间",formatDateTime:"日期和时间",formatText:"纯文本",bordersAll:"所有边框",bordersOuter:"外边框",bordersTop:"上边框",bordersBottom:"下边框",bordersLeft:"左边框",bordersRight:"右边框",bordersNone:"无边框",alignLeft:"左对齐",alignCenter:"居中",alignRight:"右对齐",alignTop:"顶端对齐",alignMiddle:"垂直居中",alignBottom:"底端对齐",formatPainter:"格式刷",fewerDecimals:"减少小数位",moreDecimals:"增加小数位",textColor:"文字颜色",fillColor:"填充颜色",nameBox:"所选单元格",formulaBar:"编辑栏",cellEditor:"单元格内容",selectAll:"全选",fillHandle:"填充",find:"查找",replaceWith:"替换为",replace:"替换",replaceAll:"全部替换",previous:"上一个",next:"下一个",close:"关闭",matchCase:"区分大小写",wholeCell:"整个单元格",inFormulas:"在公式中",addSheet:"添加工作表",rename:"重命名",duplicate:"复制工作表",moveLeft:"左移",moveRight:"右移",tabColor:"标签颜色",noColor:"无颜色",deleteSheet:"删除工作表",deleteSheetTitle:"删除此工作表?",sheetNameTaken:"已有工作表使用该名称。",saveFailed:"无法保存工作簿,请重试。",openFailed:"无法打开该文件,文件可能已损坏或类型不受支持。",statSum:"求和",statAverage:"平均值",statCount:"计数",statMin:"最小值",statMax:"最大值",blank:"(空白)",clear:"清除",apply:"应用",sheetName:e=>`工作表 ${e}`,filterColumn:e=>`筛选 ${e} 列`,freezeRows:e=>0===e?"不冻结行":`${e} 行`,freezeColumns:e=>0===e?"不冻结列":`${e} 列`,freezeUpToRow:e=>`冻结至第 ${e} 行`,freezeUpToColumn:e=>`冻结至 ${e} 列`,hitCount:(e,t)=>`${e} / ${t}`,replacedCount:e=>`已替换 ${e} 个单元格`,deleteSheetMessage:e=>`将删除“${e}”及其全部内容。引用它的公式将显示 #REF!。`,functionHelp:e=>o[e]??String(e)};export{r as ENGLISH_WORDS,l as ZH_HANS_WORDS};
|