@8sheets/data-grid 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +1 -1
  2. package/api/serialize.js +1 -1
  3. package/calc/engine.js +1 -1
  4. package/calc/functions/array.js +1 -1
  5. package/calc/functions/lookup.js +1 -1
  6. package/calc/parser.js +3 -3
  7. package/cells/axis-ops.js +1 -1
  8. package/cells/goto.js +1 -1
  9. package/cells/options.js +1 -1
  10. package/cells/view-options.js +1 -1
  11. package/charts/chartex.js +3 -3
  12. package/core/default-names.js +1 -1
  13. package/core/formula-refs.js +1 -1
  14. package/core/input.js +1 -1
  15. package/core/numfmt.js +1 -1
  16. package/core/sheet-group.js +1 -0
  17. package/core/tables.js +2 -2
  18. package/core/whatif.js +1 -1
  19. package/core/workbook.js +1 -1
  20. package/extras/getdata/persist.js +2 -2
  21. package/extras/getdata/steps.js +1 -1
  22. package/i18n/en/cells.js +1 -1
  23. package/i18n/en/charts.js +1 -1
  24. package/i18n/en/misc.js +1 -1
  25. package/i18n/en/pivot.js +1 -1
  26. package/i18n/en/ribbon.js +1 -1
  27. package/i18n/en/shell.js +1 -1
  28. package/i18n/pl/cells.js +1 -1
  29. package/i18n/pl/charts.js +1 -1
  30. package/i18n/pl/misc.js +1 -1
  31. package/i18n/pl/pivot.js +1 -1
  32. package/i18n/pl/ribbon.js +1 -1
  33. package/i18n/pl/shell.js +1 -1
  34. package/io/client.js +1 -1
  35. package/io/csv.js +8 -5
  36. package/io/export-blocks.js +1 -1
  37. package/io/plan.js +1 -1
  38. package/io/text-split.js +3 -0
  39. package/io/xlsx-read.js +1 -1
  40. package/io/xlsx-tail.js +1 -1
  41. package/io/xlsx-write.js +2 -2
  42. package/objects/chart-model.js +1 -1
  43. package/package.json +1 -1
  44. package/pivot/engine.js +1 -1
  45. package/pivot/xml.js +2 -2
  46. package/print/page-setup.js +1 -1
  47. package/slicers/custom-styles.js +1 -1
  48. package/slicers/table-file.js +1 -1
  49. package/table-view/files.js +1 -1
  50. package/table-view/labels.js +1 -1
  51. package/table-view/version.js +1 -1
  52. package/ui/protection-ui.js +1 -1
@@ -1 +1 @@
1
- import{colName as x,MAX_COLS as k,MAX_ROWS as T,parseRangeRef as C,quoteSheetName as J}from"../core/address.js";import{unescapeOoxml as Z,unescapeXml as F}from"../io/xml-scan.js";import{escapeMarkup as M,xmlText as K}from"../io/xml-escape.js";const l=72,f=72/25.4,N={1:{name:"Letter",w:8.5*l,h:11*l,common:!0},2:{name:"Letter Small",w:8.5*l,h:11*l},3:{name:"Tabloid",w:11*l,h:17*l,common:!0},4:{name:"Ledger",w:11*l,h:17*l,wide:!0,common:!0},5:{name:"Legal",w:8.5*l,h:14*l,common:!0},6:{name:"Statement",w:5.5*l,h:8.5*l,common:!0},7:{name:"Executive",w:7.25*l,h:10.5*l,common:!0},8:{name:"A3",w:297*f,h:420*f,common:!0},9:{name:"A4",w:210*f,h:297*f,common:!0},10:{name:"A4 Small",w:210*f,h:297*f},11:{name:"A5",w:148*f,h:210*f,common:!0},12:{name:"B4 (JIS)",w:257*f,h:364*f,common:!0},13:{name:"B5 (JIS)",w:182*f,h:257*f,common:!0},14:{name:"Folio",w:8.5*l,h:13*l},15:{name:"Quarto",w:215*f,h:275*f},16:{name:"10 x 14 in",w:10*l,h:14*l},17:{name:"11 x 17 in",w:11*l,h:17*l},18:{name:"Note",w:8.5*l,h:11*l},19:{name:"Envelope #9",w:3.875*l,h:8.875*l},20:{name:"Envelope #10",w:4.125*l,h:9.5*l,common:!0},21:{name:"Envelope #11",w:4.5*l,h:10.375*l},22:{name:"Envelope #12",w:4.75*l,h:11*l},23:{name:"Envelope #14",w:5*l,h:11.5*l},24:{name:"C",w:17*l,h:22*l},25:{name:"D",w:22*l,h:34*l},26:{name:"E",w:34*l,h:44*l},27:{name:"Envelope DL",w:110*f,h:220*f,common:!0},28:{name:"Envelope C5",w:162*f,h:229*f,common:!0},29:{name:"Envelope C3",w:324*f,h:458*f},30:{name:"Envelope C4",w:229*f,h:324*f},31:{name:"Envelope C6",w:114*f,h:162*f},32:{name:"Envelope C65",w:114*f,h:229*f},33:{name:"B4 (ISO)",w:250*f,h:353*f},34:{name:"Envelope B5",w:176*f,h:250*f},35:{name:"Envelope B6",w:125*f,h:176*f},36:{name:"Envelope Italy",w:110*f,h:230*f},37:{name:"Envelope Monarch",w:3.875*l,h:7.5*l},38:{name:"Envelope 6 3/4",w:3.625*l,h:6.5*l},39:{name:"US Standard Fanfold",w:11*l,h:14.875*l,wide:!0},40:{name:"German Standard Fanfold",w:8.5*l,h:12*l},41:{name:"German Legal Fanfold",w:8.5*l,h:13*l},42:{name:"ISO B4",w:250*f,h:353*f},43:{name:"Japanese Postcard",w:100*f,h:148*f},66:{name:"A2",w:420*f,h:594*f,common:!0},70:{name:"A6",w:105*f,h:148*f,common:!0}},ue={normal:{name:"Normal",left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},wide:{name:"Wide",left:1,right:1,top:1,bottom:1,header:.5,footer:.5},narrow:{name:"Narrow",left:.25,right:.25,top:.75,bottom:.75,header:.3,footer:.3}};function A(){return{paperSize:null,paperWidth:null,paperHeight:null,orientation:"default",scale:100,fitToPage:!1,fitToWidth:1,fitToHeight:1,firstPageNumber:1,useFirstPageNumber:!1,pageOrder:"downThenOver",blackAndWhite:!1,draft:!1,cellComments:"none",errors:"displayed",margins:{left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},horizontalCentered:!1,verticalCentered:!1,headings:!1,gridLines:!1,header:{odd:"",even:"",first:""},footer:{odd:"",even:"",first:""},differentOddEven:!1,differentFirst:!1,scaleWithDoc:!0,alignWithMargins:!0,rowBreaks:[],colBreaks:[],printAreas:[],titleRows:null,titleCols:null,extra:{pageSetup:{},printOptions:{},headerFooter:{}}}}function he(e){return e.pageSetup||(e.pageSetup=A()),e.pageSetup}function pe(e){return structuredClone(e)}function Q(e=globalThis.navigator?.language??"en-US"){const r=/[-_]([A-Za-z]{2})\b/.exec(e)?.[1]?.toUpperCase();return["US","CA","MX","PH","CL","CO","VE"].includes(r)?1:9}const z=e=>{const r=/^\s*([0-9.]+)\s*(mm|cm|in|pt|pc|pi)?\s*$/.exec(e??"");if(!r)return null;const t={mm:f,cm:10*f,in:l,pt:1,pc:12,pi:12};return Number(r[1])*(t[r[2]??"in"]??l)};function ge(e,r=Q()){const t=e.paperSize===null||!N[e.paperSize];let n,o,a;const s=z(e.paperWidth),c=z(e.paperHeight);if(t&&s!==null&&c!==null)n=s,o=c,a="Custom";else{const d=N[e.paperSize]??N[r]??N[9];n=d.w,o=d.h,a=d.name,d.wide&&([n,o]=[o,n])}return e.orientation==="landscape"&&([n,o]=[o,n]),{width:n,height:o,name:a}}const W=e=>{const r={};for(const t of(e??"").matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))t[1]==="xmlns"||t[1].startsWith("xmlns:")||(r[t[1]]=F(t[2]??t[3]??""));return r},D=e=>new RegExp(`<((?:[\\w.-]+:)?)${e}\\b([^>]*?)(?:/>|>([\\s\\S]*?)</\\1${e}\\s*>)`),V=e=>new RegExp(D(e).source,"g"),w=(e,r)=>{const t=D(r).exec(e);return t?{attrs:W(t[2]),inner:t[3]??"",at:t.index,end:t.index+t[0].length}:null},h=e=>e==="1"||e==="true",$=(e,r)=>{const t=Number(e);return e===void 0||e===""||!Number.isFinite(t)?r:t},B=(e,r)=>{const t={};for(const n of Object.keys(e))r.includes(n)||(t[n]=e[n]);return t},Y=["paperSize","paperWidth","paperHeight","scale","firstPageNumber","fitToWidth","fitToHeight","pageOrder","orientation","blackAndWhite","draft","cellComments","errors","useFirstPageNumber"],ee=["horizontalCentered","verticalCentered","headings","gridLines","gridLinesSet"],te=["differentOddEven","differentFirst","scaleWithDoc","alignWithMargins"];function j(e,r,t){const n=w(e,r);if(!n)return[];const o=[];for(const a of n.inner.matchAll(/<(?:[\w.-]+:)?brk\b([^>]*?)\/?>/g)){const s=W(a[1]),c=Number(s.id);h(s.man)&&Number.isInteger(c)&&c>0&&c<t&&o.push(c)}return[...new Set(o)].sort((a,s)=>a-s)}const S=(e,r)=>{const t=w(e,r);return t?Z(F(t.inner)):""};function we(e,r){const t=A(),n=w(e??"","pageSetUpPr");n&&(t.fitToPage=h(n.attrs.fitToPage));const o=r??"",a=w(o,"pageMargins");if(a)for(const i of Object.keys(t.margins))t.margins[i]=$(a.attrs[i],t.margins[i]);const s=w(o,"printOptions");s&&(t.horizontalCentered=h(s.attrs.horizontalCentered),t.verticalCentered=h(s.attrs.verticalCentered),t.headings=h(s.attrs.headings),t.gridLines=h(s.attrs.gridLines),t.extra.printOptions=B(s.attrs,ee),s.attrs.gridLinesSet!==void 0&&(t.extra.printOptions.gridLinesSet=s.attrs.gridLinesSet));const c=w(o,"pageSetup");if(c){const i=c.attrs;t.paperSize=i.paperSize!==void 0?$(i.paperSize,null):null,t.paperWidth=i.paperWidth??null,t.paperHeight=i.paperHeight??null,t.scale=$(i.scale,100),t.firstPageNumber=$(i.firstPageNumber,1),t.useFirstPageNumber=h(i.useFirstPageNumber),t.fitToWidth=$(i.fitToWidth,1),t.fitToHeight=$(i.fitToHeight,1),t.pageOrder=i.pageOrder==="overThenDown"?"overThenDown":"downThenOver",t.orientation=i.orientation==="landscape"||i.orientation==="portrait"?i.orientation:"default",t.blackAndWhite=h(i.blackAndWhite),t.draft=h(i.draft),t.cellComments=i.cellComments??"none",t.errors=i.errors??"displayed",t.extra.pageSetup=B(i,Y)}const d=w(o,"headerFooter");if(d){const i=d.attrs;t.differentOddEven=h(i.differentOddEven),t.differentFirst=h(i.differentFirst),t.scaleWithDoc=i.scaleWithDoc===void 0?!0:h(i.scaleWithDoc),t.alignWithMargins=i.alignWithMargins===void 0?!0:h(i.alignWithMargins),t.extra.headerFooter=B(i,te),t.header={odd:S(d.inner,"oddHeader"),even:S(d.inner,"evenHeader"),first:S(d.inner,"firstHeader")},t.footer={odd:S(d.inner,"oddFooter"),even:S(d.inner,"evenFooter"),first:S(d.inner,"firstFooter")}}return t.rowBreaks=j(o,"rowBreaks",T),t.colBreaks=j(o,"colBreaks",k),t}const R=e=>e.filter(([,r])=>r!=null).map(([r,t])=>` ${r}="${M(t)}"`).join(""),g=e=>e?"1":null;function b(e,r){if(!r)return"";const t=/^\s|\s$|\n/.test(r)?' xml:space="preserve"':"";return`<${e}${t}>${K(r)}</${e}>`}function y(e,r,t){if(!r||r.length===0)return"";const n=r.map(o=>`<brk id="${o}" max="${t}" man="1"/>`).join("");return`<${e} count="${r.length}" manualBreakCount="${r.length}">${n}</${e}>`}function ne(e){const r=A(),t=R([["horizontalCentered",g(e.horizontalCentered)],["verticalCentered",g(e.verticalCentered)],["headings",g(e.headings)],["gridLines",g(e.gridLines)],...Object.entries(e.extra?.printOptions??{})]),n=e.margins,o=R([["paperSize",e.paperSize],["paperHeight",e.paperHeight],["paperWidth",e.paperWidth],["scale",e.scale!==r.scale?e.scale:null],["firstPageNumber",e.useFirstPageNumber||e.firstPageNumber!==r.firstPageNumber?e.firstPageNumber:null],["fitToWidth",e.fitToWidth!==r.fitToWidth?e.fitToWidth:null],["fitToHeight",e.fitToHeight!==r.fitToHeight?e.fitToHeight:null],["pageOrder",e.pageOrder!==r.pageOrder?e.pageOrder:null],["orientation",e.orientation!=="default"?e.orientation:null],["blackAndWhite",g(e.blackAndWhite)],["draft",g(e.draft)],["cellComments",e.cellComments!=="none"?e.cellComments:null],["useFirstPageNumber",g(e.useFirstPageNumber)],["errors",e.errors!=="displayed"?e.errors:null],...Object.entries(e.extra?.pageSetup??{})]),a=[b("oddHeader",e.header.odd),b("oddFooter",e.footer.odd),b("evenHeader",e.header.even),b("evenFooter",e.footer.even),b("firstHeader",e.header.first),b("firstFooter",e.footer.first)].join(""),s=R([["differentOddEven",g(e.differentOddEven)],["differentFirst",g(e.differentFirst)],["scaleWithDoc",e.scaleWithDoc?null:"0"],["alignWithMargins",e.alignWithMargins?null:"0"],...Object.entries(e.extra?.headerFooter??{})]);return[t?`<printOptions${t}/>`:"",`<pageMargins left="${n.left}" right="${n.right}" top="${n.top}" bottom="${n.bottom}" header="${n.header}" footer="${n.footer}"/>`,o?`<pageSetup${o}/>`:"",a||s?`<headerFooter${s}>${a}</headerFooter>`:"",y("rowBreaks",e.rowBreaks,k-1),y("colBreaks",e.colBreaks,T-1)].join("")}const re=["printOptions","pageMargins","pageSetup","headerFooter","rowBreaks","colBreaks"],oe=/<(?:[\w.-]+:)?(?:customProperties|cellWatches|ignoredErrors|smartTags|drawing|legacyDrawing|legacyDrawingHF|drawingHF|picture|oleObjects|controls|webPublishItems|tableParts|extLst|AlternateContent)\b|<\/(?:[\w.-]+:)?worksheet\s*>/;function ie(e,r){let t=e??"</worksheet>",n=-1;for(const a of re){const s=V(a);t=t.replace(s,(c,d,i,m,u)=>((n<0||u<n)&&(n=u),""))}const o=ne(r);if(n<0||n>t.length){const a=oe.exec(t);n=a?a.index:t.length}return t.slice(0,n)+o+t.slice(n)}function xe(e,r){const t=A(),{pageSetup:n={},headerFooter:o={}}=r.extra??{},a={};for(const s of["usePrinterDefaults","copies","horizontalDpi","verticalDpi","r:id"])n[s]!==void 0&&(a[s]=n[s]);return ie(e,{...r,scale:t.scale,fitToWidth:t.fitToWidth,fitToHeight:t.fitToHeight,pageOrder:t.pageOrder,cellComments:t.cellComments,errors:t.errors,horizontalCentered:!1,verticalCentered:!1,headings:!1,gridLines:!1,rowBreaks:[],colBreaks:[],extra:{pageSetup:a,printOptions:{},headerFooter:o}})}function $e(e,r){const t=/<((?:[\w.-]+:)?)pageSetUpPr\b([^>]*?)\/>/.exec(e);if(t){const c=t[2].replace(/\s*fitToPage\s*=\s*(?:"[^"]*"|'[^']*')/,""),d=r.fitToPage?` fitToPage="1"${c}`:c;return d.trim()?`${e.slice(0,t.index)}<${t[1]}pageSetUpPr${d}/>${e.slice(t.index+t[0].length)}`:e.slice(0,t.index)+e.slice(t.index+t[0].length)}if(!r.fitToPage)return e;const n=/<\/((?:[\w.-]+:)?)sheetPr\s*>/.exec(e);if(n)return`${e.slice(0,n.index)}<${n[1]}pageSetUpPr fitToPage="1"/>${e.slice(n.index)}`;const o=/<((?:[\w.-]+:)?)sheetPr\b([^>]*?)\/>/.exec(e);if(o)return`${e.slice(0,o.index)}<${o[1]}sheetPr${o[2]}><${o[1]}pageSetUpPr fitToPage="1"/></${o[1]}sheetPr>${e.slice(o.index+o[0].length)}`;const a=/<((?:[\w.-]+:)?)worksheet\b[^>]*>/.exec(e);if(!a)return e;const s=a.index+a[0].length;return`${e.slice(0,s)}<${a[1]}sheetPr><${a[1]}pageSetUpPr fitToPage="1"/></${a[1]}sheetPr>${e.slice(s)}`}const E="_xlnm.Print_Area",O="_xlnm.Print_Titles";function U(e){const r=[];let t=!1,n=0;for(let o=0;o<e.length;o++){const a=e[o];a==="'"?t=!t:a===","&&!t&&(r.push(e.slice(n,o)),n=o+1)}return r.push(e.slice(n)),r.map(o=>o.trim().replace(/^\(|\)$/g,"")).filter(Boolean)}const v=e=>{const r=e.lastIndexOf("!");return r<0?e:e.slice(r+1)},H=e=>e.c0===0&&e.c1===k-1,I=e=>e.r0===0&&e.r1===T-1;function ae(e){const r=[];for(const t of U(e??"")){const n=C(v(t));n&&r.push(n)}return r}function se(e){const r={titleRows:null,titleCols:null};for(const t of U(e??"")){const n=C(v(t));n&&(H(n)?r.titleRows={r0:n.r0,r1:n.r1}:I(n)&&(r.titleCols={c0:n.c0,c1:n.c1}))}return r}function Se(e){const r=[];for(const t of(e??"").matchAll(/<(?:[\w.-]+:)?definedName\b([^>]*)>([\s\S]*?)<\/(?:[\w.-]+:)?definedName\s*>/g)){const n=W(t[1]);n.name!==E&&n.name!==O||n.localSheetId!==void 0&&r.push({name:n.name,localSheetId:Number(n.localSheetId),text:F(t[2])})}return r}function be(e,r,t){for(const n of r??[])n.localSheetId===t&&(n.name===E?e.printAreas=ae(n.text):n.name===O&&Object.assign(e,se(n.text)));return e}function le(e){if(I(e))return`$${x(e.c0)}:$${x(e.c1)}`;if(H(e))return`$${e.r0+1}:$${e.r1+1}`;const r=`$${x(e.c0)}$${e.r0+1}`;return e.r0===e.r1&&e.c0===e.c1?r:`${r}:$${x(e.c1)}$${e.r1+1}`}function Pe(e){const r=[];return e.forEach((t,n)=>{const o=t.pageSetup;if(!o)return;const a=J(t.name);o.printAreas.length>0&&r.push({name:E,localSheetId:n,text:o.printAreas.map(c=>`${a}!${le(c)}`).join(",")});const s=[];o.titleCols&&s.push(`${a}!$${x(o.titleCols.c0)}:$${x(o.titleCols.c1)}`),o.titleRows&&s.push(`${a}!$${o.titleRows.r0+1}:$${o.titleRows.r1+1}`),s.length>0&&r.push({name:O,localSheetId:n,text:s.join(",")})}),r}function ke(e,r){const t=/<((?:[\w.-]+:)?)definedName\b([^>]*)>[\s\S]*?<\/\1definedName\s*>/g;let n=e.replace(t,(c,d,i)=>{const m=W(i).name;return m===E||m===O?"":c});const o=r.map(c=>`<definedName name="${c.name}" localSheetId="${c.localSheetId}">${M(c.text)}</definedName>`).join(""),a=/<((?:[\w.-]+:)?)definedNames\b[^>]*>([\s\S]*?)<\/\1definedNames\s*>/.exec(n);if(a){const c=a[2]+o,d=c.trim()?`<${a[1]}definedNames>${c}</${a[1]}definedNames>`:"";return n.slice(0,a.index)+d+n.slice(a.index+a[0].length)}if(!o)return n;let s=-1;for(const c of[/<\/(?:[\w.-]+:)?sheets\s*>/,/<\/(?:[\w.-]+:)?functionGroups\s*>/,/<(?:[\w.-]+:)?functionGroups\b[^>]*\/>/,/<\/(?:[\w.-]+:)?externalReferences\s*>/]){const d=c.exec(n);d&&(s=Math.max(s,d.index+d[0].length))}return s<0||(n=`${n.slice(0,s)}<definedNames>${o}</definedNames>${n.slice(s)}`),n}const X={P:"page",N:"pages",D:"date",T:"time",F:"file",A:"sheet",Z:"path",G:"picture"},G=()=>({font:null,size:null,bold:!1,italic:!1,underline:0,strike:!1,script:0,color:null});function Te(e){const r={left:[],center:[],right:[]};let t=r.center,n=G(),o="";const a=()=>{o&&t.push({...n,text:o}),o=""},s=e??"";for(let c=0;c<s.length;c++){const d=s[c];if(d!=="&"){o+=d;continue}const i=s[++c];if(i===void 0)break;if(i==="&"){o+="&";continue}if(i==="L"||i==="C"||i==="R"){a(),t=i==="L"?r.left:i==="C"?r.center:r.right,n=G();continue}if(X[i]){a();const m={...n,field:X[i],offset:0};if(i==="P"){const u=/^[+-]\d+/.exec(s.slice(c+1,c+8));u&&(m.offset=Number(u[0]),c+=u[0].length)}t.push(m);continue}if(i==='"'){a();const m=s.indexOf('"',c+1),u=m<0?s.slice(c+1):s.slice(c+1,m);c=m<0?s.length:m;const[p,P=""]=u.split(",");n={...n},p&&p!=="-"&&(n.font=p.trim()),n.bold=/bold|fett|gras|pogrub/i.test(P),n.italic=/italic|oblique|kursywa/i.test(P);continue}if(i>="0"&&i<="9"){a();let m=c;for(;m+1<s.length&&m-c<2&&s[m+1]>="0"&&s[m+1]<="9";)m++;n={...n,size:Number(s.slice(c,m+1))},c=m;continue}if(i==="K"){a();const m=s.slice(c+1,c+7);n={...n,color:/^[0-9A-Fa-f]{6}$/.test(m)?`#${m}`:null},c+=m.length;continue}a(),n={...n},i==="B"?n.bold=!n.bold:i==="I"?n.italic=!n.italic:i==="U"?n.underline=n.underline===1?0:1:i==="E"?n.underline=n.underline===2?0:2:i==="S"?n.strike=!n.strike:i==="X"?n.script=n.script===1?0:1:i==="Y"&&(n.script=n.script===-1?0:-1)}return a(),r}function Ce({left:e="",center:r="",right:t=""}={}){return`${e?`&L${e}`:""}${r?`&C${r}`:""}${t?`&R${t}`:""}`}function Ne(e,r){e.printAreas=r.map(({r0:t,c0:n,r1:o,c1:a})=>({r0:t,c0:n,r1:o,c1:a}))}function Ae(e,r){const{r0:t,c0:n,r1:o,c1:a}=r;e.printAreas.push({r0:t,c0:n,r1:o,c1:a})}const q=(e,r)=>{e.includes(r)||(e.push(r),e.sort((t,n)=>t-n))};function We(e,r,t){r>0&&q(e.rowBreaks,r),t>0&&q(e.colBreaks,t)}function Ee(e,r,t){e.rowBreaks=e.rowBreaks.filter(n=>n!==r),e.colBreaks=e.colBreaks.filter(n=>n!==t)}function Oe(e){e.rowBreaks=[],e.colBreaks=[]}const L=(e,r,t)=>e<r?e:e+t;function _(e,r,t,n){if(n>0)return[L(e,t,n),L(r,t,n)];const o=t-n;if(e>=t&&r<o)return null;const a=e<t?e:e<o?t:e+n,s=r<t?r:r<o?t-1:r+n;return[a,s]}const ce=(e,r,t)=>e===0&&r===t-1;function ve(e,r){const{axis:t,at:n,n:o}=r,a=t==="row",s=a?T:k,c=i=>{const m=[];for(const u of i){if(o<0&&u>=n&&u<n-o)continue;const p=L(u,n,o);p>0&&p<s&&m.push(p)}return m};a?e.rowBreaks=c(e.rowBreaks):e.colBreaks=c(e.colBreaks);const d=[];for(const i of e.printAreas){const m=a?i.r0:i.c0,u=a?i.r1:i.c1;if(ce(m,u,s)){d.push(i);continue}const p=_(m,u,n,o);if(!p)continue;const P=Math.min(p[1],s-1);d.push(a?{...i,r0:p[0],r1:P}:{...i,c0:p[0],c1:P})}if(e.printAreas=d,a&&e.titleRows){const i=_(e.titleRows.r0,e.titleRows.r1,n,o);e.titleRows=i?{r0:i[0],r1:Math.min(i[1],s-1)}:null}if(!a&&e.titleCols){const i=_(e.titleCols.c0,e.titleCols.c1,n,o);e.titleCols=i?{c0:i[0],c1:Math.min(i[1],s-1)}:null}return e}function Fe(e){const r=C(v(e??""));return r&&H(r)?{r0:r.r0,r1:r.r1}:null}function Be(e){const r=C(v(e??""));return r&&I(r)?{c0:r.c0,c1:r.c1}:null}export{ue as MARGIN_PRESETS,N as PAPER_SIZES,Ae as addToPrintArea,be as applyPrintNames,Ce as buildHeaderFooter,pe as clonePageSetup,A as defaultPageSetup,Q as defaultPaperSize,he as getPageSetup,We as insertBreakAt,ne as pageSetupElementsXml,ge as paperDimensions,Te as parseHeaderFooter,ae as parsePrintArea,se as parsePrintTitles,Be as parseTitleCols,Fe as parseTitleRows,xe as patchChartSheetPageSetup,ke as patchWorkbookPrintNames,$e as patchWorksheetHead,ie as patchWorksheetTail,Pe as printNameEntries,Se as readPrintNamesXml,we as readWorksheetPageSetup,Ee as removeBreakAt,Oe as resetBreaks,Ne as setPrintArea,ve as shiftPageSetup};
1
+ import{colName as x,MAX_COLS as b,MAX_ROWS as T,parseRangeRef as C,quoteSheetName as J}from"../core/address.js";import{unescapeOoxml as Z,unescapeXml as F}from"../io/xml-scan.js";import{escapeMarkup as _,xmlText as K}from"../io/xml-escape.js";const c=72,f=72/25.4,N={1:{name:"Letter",w:8.5*c,h:11*c,common:!0},2:{name:"Letter Small",w:8.5*c,h:11*c},3:{name:"Tabloid",w:11*c,h:17*c,common:!0},4:{name:"Ledger",w:11*c,h:17*c,wide:!0,common:!0},5:{name:"Legal",w:8.5*c,h:14*c,common:!0},6:{name:"Statement",w:5.5*c,h:8.5*c,common:!0},7:{name:"Executive",w:7.25*c,h:10.5*c,common:!0},8:{name:"A3",w:297*f,h:420*f,common:!0},9:{name:"A4",w:210*f,h:297*f,common:!0},10:{name:"A4 Small",w:210*f,h:297*f},11:{name:"A5",w:148*f,h:210*f,common:!0},12:{name:"B4 (JIS)",w:257*f,h:364*f,common:!0},13:{name:"B5 (JIS)",w:182*f,h:257*f,common:!0},14:{name:"Folio",w:8.5*c,h:13*c},15:{name:"Quarto",w:215*f,h:275*f},16:{name:"10 x 14 in",w:10*c,h:14*c},17:{name:"11 x 17 in",w:11*c,h:17*c},18:{name:"Note",w:8.5*c,h:11*c},19:{name:"Envelope #9",w:3.875*c,h:8.875*c},20:{name:"Envelope #10",w:4.125*c,h:9.5*c,common:!0},21:{name:"Envelope #11",w:4.5*c,h:10.375*c},22:{name:"Envelope #12",w:4.75*c,h:11*c},23:{name:"Envelope #14",w:5*c,h:11.5*c},24:{name:"C",w:17*c,h:22*c},25:{name:"D",w:22*c,h:34*c},26:{name:"E",w:34*c,h:44*c},27:{name:"Envelope DL",w:110*f,h:220*f,common:!0},28:{name:"Envelope C5",w:162*f,h:229*f,common:!0},29:{name:"Envelope C3",w:324*f,h:458*f},30:{name:"Envelope C4",w:229*f,h:324*f},31:{name:"Envelope C6",w:114*f,h:162*f},32:{name:"Envelope C65",w:114*f,h:229*f},33:{name:"B4 (ISO)",w:250*f,h:353*f},34:{name:"Envelope B5",w:176*f,h:250*f},35:{name:"Envelope B6",w:125*f,h:176*f},36:{name:"Envelope Italy",w:110*f,h:230*f},37:{name:"Envelope Monarch",w:3.875*c,h:7.5*c},38:{name:"Envelope 6 3/4",w:3.625*c,h:6.5*c},39:{name:"US Standard Fanfold",w:11*c,h:14.875*c,wide:!0},40:{name:"German Standard Fanfold",w:8.5*c,h:12*c},41:{name:"German Legal Fanfold",w:8.5*c,h:13*c},42:{name:"ISO B4",w:250*f,h:353*f},43:{name:"Japanese Postcard",w:100*f,h:148*f},66:{name:"A2",w:420*f,h:594*f,common:!0},70:{name:"A6",w:105*f,h:148*f,common:!0}},he={normal:{name:"Normal",left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},wide:{name:"Wide",left:1,right:1,top:1,bottom:1,header:.5,footer:.5},narrow:{name:"Narrow",left:.25,right:.25,top:.75,bottom:.75,header:.3,footer:.3}};function A(){return{paperSize:null,paperWidth:null,paperHeight:null,orientation:"default",scale:100,fitToPage:!1,fitToWidth:1,fitToHeight:1,firstPageNumber:1,useFirstPageNumber:!1,pageOrder:"downThenOver",blackAndWhite:!1,draft:!1,cellComments:"none",errors:"displayed",margins:{left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},horizontalCentered:!1,verticalCentered:!1,headings:!1,gridLines:!1,header:{odd:"",even:"",first:""},footer:{odd:"",even:"",first:""},differentOddEven:!1,differentFirst:!1,scaleWithDoc:!0,alignWithMargins:!0,rowBreaks:[],colBreaks:[],printAreas:[],titleRows:null,titleCols:null,extra:{pageSetup:{},printOptions:{},headerFooter:{}}}}function ue(e){return e.pageSetup||(e.pageSetup=A()),e.pageSetup}function pe(e){return structuredClone(e)}function Q(e=globalThis.navigator?.language??"en-US"){const r=/[-_]([A-Za-z]{2})\b/.exec(e)?.[1]?.toUpperCase();return["US","CA","MX","PH","CL","CO","VE"].includes(r)?1:9}const z=e=>{const r=/^\s*([0-9.]+)\s*(mm|cm|in|pt|pc|pi)?\s*$/.exec(e??"");if(!r)return null;const t={mm:f,cm:10*f,in:c,pt:1,pc:12,pi:12};return Number(r[1])*(t[r[2]??"in"]??c)};function ge(e,r=Q()){const t=e.paperSize===null||!N[e.paperSize];let n,o,i;const s=z(e.paperWidth),l=z(e.paperHeight);if(t&&s!==null&&l!==null)n=s,o=l,i="Custom";else{const d=N[e.paperSize]??N[r]??N[9];n=d.w,o=d.h,i=d.name,d.wide&&([n,o]=[o,n])}return e.orientation==="landscape"&&([n,o]=[o,n]),{width:n,height:o,name:i}}const W=e=>{const r={};for(const t of(e??"").matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))t[1]==="xmlns"||t[1].startsWith("xmlns:")||(r[t[1]]=F(t[2]??t[3]??""));return r},D=e=>new RegExp(`<((?:[\\w.-]+:)?)${e}\\b([^>]*?)(?:/>|>([\\s\\S]*?)</\\1${e}\\s*>)`),V=e=>new RegExp(D(e).source,"g"),w=(e,r)=>{const t=D(r).exec(e);return t?{attrs:W(t[2]),inner:t[3]??"",at:t.index,end:t.index+t[0].length}:null},u=e=>e==="1"||e==="true",$=(e,r)=>{const t=Number(e);return e===void 0||e===""||!Number.isFinite(t)?r:t},B=(e,r)=>{const t={};for(const n of Object.keys(e))r.includes(n)||(t[n]=e[n]);return t},Y=["paperSize","paperWidth","paperHeight","scale","firstPageNumber","fitToWidth","fitToHeight","pageOrder","orientation","blackAndWhite","draft","cellComments","errors","useFirstPageNumber"],ee=["horizontalCentered","verticalCentered","headings","gridLines","gridLinesSet"],te=["differentOddEven","differentFirst","scaleWithDoc","alignWithMargins"];function j(e,r,t){const n=w(e,r);if(!n)return[];const o=[];for(const i of n.inner.matchAll(/<(?:[\w.-]+:)?brk\b([^>]*?)\/?>/g)){const s=W(i[1]),l=Number(s.id);u(s.man)&&Number.isInteger(l)&&l>0&&l<t&&o.push(l)}return[...new Set(o)].sort((i,s)=>i-s)}const S=(e,r)=>{const t=w(e,r);return t?Z(F(t.inner)):""};function we(e,r){const t=A(),n=w(e??"","pageSetUpPr");n&&(t.fitToPage=u(n.attrs.fitToPage));const o=r??"",i=w(o,"pageMargins");if(i)for(const a of Object.keys(t.margins))t.margins[a]=$(i.attrs[a],t.margins[a]);const s=w(o,"printOptions");s&&(t.horizontalCentered=u(s.attrs.horizontalCentered),t.verticalCentered=u(s.attrs.verticalCentered),t.headings=u(s.attrs.headings),t.gridLines=u(s.attrs.gridLines),t.extra.printOptions=B(s.attrs,ee),s.attrs.gridLinesSet!==void 0&&(t.extra.printOptions.gridLinesSet=s.attrs.gridLinesSet));const l=w(o,"pageSetup");if(l){const a=l.attrs;t.paperSize=a.paperSize!==void 0?$(a.paperSize,null):null,t.paperWidth=a.paperWidth??null,t.paperHeight=a.paperHeight??null,t.scale=$(a.scale,100),t.firstPageNumber=$(a.firstPageNumber,1),t.useFirstPageNumber=u(a.useFirstPageNumber),t.fitToWidth=$(a.fitToWidth,1),t.fitToHeight=$(a.fitToHeight,1),t.pageOrder=a.pageOrder==="overThenDown"?"overThenDown":"downThenOver",t.orientation=a.orientation==="landscape"||a.orientation==="portrait"?a.orientation:"default",t.blackAndWhite=u(a.blackAndWhite),t.draft=u(a.draft),t.cellComments=a.cellComments??"none",t.errors=a.errors??"displayed",t.extra.pageSetup=B(a,Y)}const d=w(o,"headerFooter");if(d){const a=d.attrs;t.differentOddEven=u(a.differentOddEven),t.differentFirst=u(a.differentFirst),t.scaleWithDoc=a.scaleWithDoc===void 0?!0:u(a.scaleWithDoc),t.alignWithMargins=a.alignWithMargins===void 0?!0:u(a.alignWithMargins),t.extra.headerFooter=B(a,te),t.header={odd:S(d.inner,"oddHeader"),even:S(d.inner,"evenHeader"),first:S(d.inner,"firstHeader")},t.footer={odd:S(d.inner,"oddFooter"),even:S(d.inner,"evenFooter"),first:S(d.inner,"firstFooter")}}return t.rowBreaks=j(o,"rowBreaks",T),t.colBreaks=j(o,"colBreaks",b),t}const R=e=>e.filter(([,r])=>r!=null).map(([r,t])=>` ${r}="${_(t)}"`).join(""),g=e=>e?"1":null;function P(e,r){if(!r)return"";const t=/^\s|\s$|\n/.test(r)?' xml:space="preserve"':"";return`<${e}${t}>${K(r)}</${e}>`}function y(e,r,t){if(!r||r.length===0)return"";const n=r.map(o=>`<brk id="${o}" max="${t}" man="1"/>`).join("");return`<${e} count="${r.length}" manualBreakCount="${r.length}">${n}</${e}>`}function ne(e){const r=A(),t=R([["horizontalCentered",g(e.horizontalCentered)],["verticalCentered",g(e.verticalCentered)],["headings",g(e.headings)],["gridLines",g(e.gridLines)],...Object.entries(e.extra?.printOptions??{})]),n=e.margins,o=R([["paperSize",e.paperSize],["paperHeight",e.paperHeight],["paperWidth",e.paperWidth],["scale",e.scale!==r.scale?e.scale:null],["firstPageNumber",e.useFirstPageNumber||e.firstPageNumber!==r.firstPageNumber?e.firstPageNumber:null],["fitToWidth",e.fitToWidth!==r.fitToWidth?e.fitToWidth:null],["fitToHeight",e.fitToHeight!==r.fitToHeight?e.fitToHeight:null],["pageOrder",e.pageOrder!==r.pageOrder?e.pageOrder:null],["orientation",e.orientation!=="default"?e.orientation:null],["blackAndWhite",g(e.blackAndWhite)],["draft",g(e.draft)],["cellComments",e.cellComments!=="none"?e.cellComments:null],["useFirstPageNumber",g(e.useFirstPageNumber)],["errors",e.errors!=="displayed"?e.errors:null],...Object.entries(e.extra?.pageSetup??{})]),i=[P("oddHeader",e.header.odd),P("oddFooter",e.footer.odd),P("evenHeader",e.header.even),P("evenFooter",e.footer.even),P("firstHeader",e.header.first),P("firstFooter",e.footer.first)].join(""),s=R([["differentOddEven",g(e.differentOddEven)],["differentFirst",g(e.differentFirst)],["scaleWithDoc",e.scaleWithDoc?null:"0"],["alignWithMargins",e.alignWithMargins?null:"0"],...Object.entries(e.extra?.headerFooter??{})]);return[t?`<printOptions${t}/>`:"",`<pageMargins left="${n.left}" right="${n.right}" top="${n.top}" bottom="${n.bottom}" header="${n.header}" footer="${n.footer}"/>`,o?`<pageSetup${o}/>`:"",i||s?`<headerFooter${s}>${i}</headerFooter>`:"",y("rowBreaks",e.rowBreaks,b-1),y("colBreaks",e.colBreaks,T-1)].join("")}const re=["printOptions","pageMargins","pageSetup","headerFooter","rowBreaks","colBreaks"],oe=/<(?:[\w.-]+:)?(?:customProperties|cellWatches|ignoredErrors|smartTags|drawing|legacyDrawing|legacyDrawingHF|drawingHF|picture|oleObjects|controls|webPublishItems|tableParts|extLst|AlternateContent)\b|<\/(?:[\w.-]+:)?worksheet\s*>/;function ie(e,r){let t=e??"</worksheet>",n=-1;for(const i of re){const s=V(i);t=t.replace(s,(l,d,a,m,h)=>((n<0||h<n)&&(n=h),""))}const o=ne(r);if(n<0||n>t.length){const i=oe.exec(t);n=i?i.index:t.length}return t.slice(0,n)+o+t.slice(n)}function xe(e,r){const t=A(),{pageSetup:n={},headerFooter:o={}}=r.extra??{},i={};for(const s of["usePrinterDefaults","copies","horizontalDpi","verticalDpi","r:id"])n[s]!==void 0&&(i[s]=n[s]);return ie(e,{...r,scale:t.scale,fitToWidth:t.fitToWidth,fitToHeight:t.fitToHeight,pageOrder:t.pageOrder,cellComments:t.cellComments,errors:t.errors,horizontalCentered:!1,verticalCentered:!1,headings:!1,gridLines:!1,rowBreaks:[],colBreaks:[],extra:{pageSetup:i,printOptions:{},headerFooter:o}})}function $e(e,r){const t=/<((?:[\w.-]+:)?)pageSetUpPr\b([^>]*?)\/>/.exec(e);if(t){const l=t[2].replace(/\s*fitToPage\s*=\s*(?:"[^"]*"|'[^']*')/,""),d=r.fitToPage?` fitToPage="1"${l}`:l;return d.trim()?`${e.slice(0,t.index)}<${t[1]}pageSetUpPr${d}/>${e.slice(t.index+t[0].length)}`:e.slice(0,t.index)+e.slice(t.index+t[0].length)}if(!r.fitToPage)return e;const n=/<\/((?:[\w.-]+:)?)sheetPr\s*>/.exec(e);if(n)return`${e.slice(0,n.index)}<${n[1]}pageSetUpPr fitToPage="1"/>${e.slice(n.index)}`;const o=/<((?:[\w.-]+:)?)sheetPr\b([^>]*?)\/>/.exec(e);if(o)return`${e.slice(0,o.index)}<${o[1]}sheetPr${o[2]}><${o[1]}pageSetUpPr fitToPage="1"/></${o[1]}sheetPr>${e.slice(o.index+o[0].length)}`;const i=/<((?:[\w.-]+:)?)worksheet\b[^>]*>/.exec(e);if(!i)return e;const s=i.index+i[0].length;return`${e.slice(0,s)}<${i[1]}sheetPr><${i[1]}pageSetUpPr fitToPage="1"/></${i[1]}sheetPr>${e.slice(s)}`}const E="_xlnm.Print_Area",O="_xlnm.Print_Titles";function U(e){const r=[];let t=!1,n=0;for(let o=0;o<e.length;o++){const i=e[o];i==="'"?t=!t:i===","&&!t&&(r.push(e.slice(n,o)),n=o+1)}return r.push(e.slice(n)),r.map(o=>o.trim().replace(/^\(|\)$/g,"")).filter(Boolean)}const v=e=>{const r=e.lastIndexOf("!");return r<0?e:e.slice(r+1)},H=e=>e.c0===0&&e.c1===b-1,I=e=>e.r0===0&&e.r1===T-1;function ae(e){const r=[];for(const t of U(e??"")){const n=C(v(t));n&&r.push(n)}return r}function se(e){const r={titleRows:null,titleCols:null};for(const t of U(e??"")){const n=C(v(t));n&&(H(n)?r.titleRows={r0:n.r0,r1:n.r1}:I(n)&&(r.titleCols={c0:n.c0,c1:n.c1}))}return r}function Se(e){const r=[];for(const t of(e??"").matchAll(/<(?:[\w.-]+:)?definedName\b([^>]*)>([\s\S]*?)<\/(?:[\w.-]+:)?definedName\s*>/g)){const n=W(t[1]);n.name!==E&&n.name!==O||n.localSheetId!==void 0&&r.push({name:n.name,localSheetId:Number(n.localSheetId),text:F(t[2])})}return r}function Pe(e,r,t){for(const n of r??[])n.localSheetId===t&&(n.name===E?e.printAreas=ae(n.text):n.name===O&&Object.assign(e,se(n.text)));return e}function ce(e){if(I(e))return`$${x(e.c0)}:$${x(e.c1)}`;if(H(e))return`$${e.r0+1}:$${e.r1+1}`;const r=`$${x(e.c0)}$${e.r0+1}`;return e.r0===e.r1&&e.c0===e.c1?r:`${r}:$${x(e.c1)}$${e.r1+1}`}function ke(e){const r=[];return e.forEach((t,n)=>{const o=t.pageSetup;if(!o)return;const i=J(t.name);o.printAreas.length>0&&r.push({name:E,localSheetId:n,text:o.printAreas.map(l=>`${i}!${ce(l)}`).join(",")});const s=[];o.titleCols&&s.push(`${i}!$${x(o.titleCols.c0)}:$${x(o.titleCols.c1)}`),o.titleRows&&s.push(`${i}!$${o.titleRows.r0+1}:$${o.titleRows.r1+1}`),s.length>0&&r.push({name:O,localSheetId:n,text:s.join(",")})}),r}function be(e,r){const t=/<((?:[\w.-]+:)?)definedName\b([^>]*)>[\s\S]*?<\/\1definedName\s*>/g;let n=e.replace(t,(l,d,a)=>{const m=W(a).name;return m===E||m===O?"":l});const o=r.map(l=>`<definedName name="${l.name}" localSheetId="${l.localSheetId}">${_(l.text)}</definedName>`).join(""),i=/<((?:[\w.-]+:)?)definedNames\b[^>]*>([\s\S]*?)<\/\1definedNames\s*>/.exec(n);if(i){const l=i[2]+o,d=l.trim()?`<${i[1]}definedNames>${l}</${i[1]}definedNames>`:"";return n.slice(0,i.index)+d+n.slice(i.index+i[0].length)}if(!o)return n;let s=-1;for(const l of[/<\/(?:[\w.-]+:)?sheets\s*>/,/<\/(?:[\w.-]+:)?functionGroups\s*>/,/<(?:[\w.-]+:)?functionGroups\b[^>]*\/>/,/<\/(?:[\w.-]+:)?externalReferences\s*>/]){const d=l.exec(n);d&&(s=Math.max(s,d.index+d[0].length))}return s<0||(n=`${n.slice(0,s)}<definedNames>${o}</definedNames>${n.slice(s)}`),n}const X={P:"page",N:"pages",D:"date",T:"time",F:"file",A:"sheet",Z:"path",G:"picture"},G=()=>({font:null,size:null,bold:!1,italic:!1,underline:0,strike:!1,script:0,color:null});function Te(e){const r={left:[],center:[],right:[]};let t=r.center,n=G(),o="";const i=()=>{o&&t.push({...n,text:o}),o=""},s=e??"";for(let l=0;l<s.length;l++){const d=s[l];if(d!=="&"){o+=d;continue}const a=s[++l];if(a===void 0)break;if(a==="&"){o+="&";continue}if(a==="L"||a==="C"||a==="R"){i(),t=a==="L"?r.left:a==="C"?r.center:r.right,n=G();continue}if(X[a]){i();const m={...n,field:X[a],offset:0};if(a==="P"){const h=/^[+-]\d+/.exec(s.slice(l+1,l+8));h&&(m.offset=Number(h[0]),l+=h[0].length)}t.push(m);continue}if(a==='"'){i();const m=s.indexOf('"',l+1),h=m<0?s.slice(l+1):s.slice(l+1,m);l=m<0?s.length:m;const[p,k=""]=h.split(",");n={...n},p&&p!=="-"&&(n.font=p.trim()),n.bold=/bold|fett|gras|pogrub/i.test(k),n.italic=/italic|oblique|kursywa/i.test(k);continue}if(a>="0"&&a<="9"){i();let m=l;for(;m+1<s.length&&m-l<2&&s[m+1]>="0"&&s[m+1]<="9";)m++;n={...n,size:Number(s.slice(l,m+1))},l=m;continue}if(a==="K"){i();const m=s.slice(l+1,l+7);n={...n,color:/^[0-9A-Fa-f]{6}$/.test(m)?`#${m}`:null},l+=m.length;continue}i(),n={...n},a==="B"?n.bold=!n.bold:a==="I"?n.italic=!n.italic:a==="U"?n.underline=n.underline===1?0:1:a==="E"?n.underline=n.underline===2?0:2:a==="S"?n.strike=!n.strike:a==="X"?n.script=n.script===1?0:1:a==="Y"&&(n.script=n.script===-1?0:-1)}return i(),r}function Ce({left:e="",center:r="",right:t=""}={}){return`${e?`&L${e}`:""}${r?`&C${r}`:""}${t?`&R${t}`:""}`}function Ne(e,r){e.printAreas=r.map(({r0:t,c0:n,r1:o,c1:i})=>({r0:t,c0:n,r1:o,c1:i}))}function Ae(e,r){let t={r0:r.r0,c0:r.c0,r1:r.r1,c1:r.c1};const n=(o,i)=>o.c0===i.c0&&o.c1===i.c1&&o.r0<=i.r1+1&&i.r0<=o.r1+1||o.r0===i.r0&&o.r1===i.r1&&o.c0<=i.c1+1&&i.c0<=o.c1+1;for(let o=!0;o;){o=!1;const i=e.printAreas.findIndex(s=>n(s,t));if(i>=0){const s=e.printAreas.splice(i,1)[0];t={r0:Math.min(s.r0,t.r0),c0:Math.min(s.c0,t.c0),r1:Math.max(s.r1,t.r1),c1:Math.max(s.c1,t.c1)},o=!0}}e.printAreas.push(t)}const q=(e,r)=>{e.includes(r)||(e.push(r),e.sort((t,n)=>t-n))};function We(e,r,t){r>0&&q(e.rowBreaks,r),t>0&&q(e.colBreaks,t)}function Ee(e,r,t){e.rowBreaks=e.rowBreaks.filter(n=>n!==r),e.colBreaks=e.colBreaks.filter(n=>n!==t)}function Oe(e){e.rowBreaks=[],e.colBreaks=[]}const L=(e,r,t)=>e<r?e:e+t;function M(e,r,t,n){if(n>0)return[L(e,t,n),L(r,t,n)];const o=t-n;if(e>=t&&r<o)return null;const i=e<t?e:e<o?t:e+n,s=r<t?r:r<o?t-1:r+n;return[i,s]}const le=(e,r,t)=>e===0&&r===t-1;function ve(e,r){const{axis:t,at:n,n:o}=r,i=t==="row",s=i?T:b,l=a=>{const m=[];for(const h of a){if(o<0&&h>=n&&h<n-o)continue;const p=L(h,n,o);p>0&&p<s&&m.push(p)}return m};i?e.rowBreaks=l(e.rowBreaks):e.colBreaks=l(e.colBreaks);const d=[];for(const a of e.printAreas){const m=i?a.r0:a.c0,h=i?a.r1:a.c1;if(le(m,h,s)){d.push(a);continue}const p=M(m,h,n,o);if(!p)continue;const k=Math.min(p[1],s-1);d.push(i?{...a,r0:p[0],r1:k}:{...a,c0:p[0],c1:k})}if(e.printAreas=d,i&&e.titleRows){const a=M(e.titleRows.r0,e.titleRows.r1,n,o);e.titleRows=a?{r0:a[0],r1:Math.min(a[1],s-1)}:null}if(!i&&e.titleCols){const a=M(e.titleCols.c0,e.titleCols.c1,n,o);e.titleCols=a?{c0:a[0],c1:Math.min(a[1],s-1)}:null}return e}function Fe(e){const r=C(v(e??""));return r&&H(r)?{r0:r.r0,r1:r.r1}:null}function Be(e){const r=C(v(e??""));return r&&I(r)?{c0:r.c0,c1:r.c1}:null}export{he as MARGIN_PRESETS,N as PAPER_SIZES,Ae as addToPrintArea,Pe as applyPrintNames,Ce as buildHeaderFooter,pe as clonePageSetup,A as defaultPageSetup,Q as defaultPaperSize,ue as getPageSetup,We as insertBreakAt,ne as pageSetupElementsXml,ge as paperDimensions,Te as parseHeaderFooter,ae as parsePrintArea,se as parsePrintTitles,Be as parseTitleCols,Fe as parseTitleRows,xe as patchChartSheetPageSetup,be as patchWorkbookPrintNames,$e as patchWorksheetHead,ie as patchWorksheetTail,ke as printNameEntries,Se as readPrintNamesXml,we as readWorksheetPageSetup,Ee as removeBreakAt,Oe as resetBreaks,Ne as setPrintArea,ve as shiftPageSetup};
@@ -1 +1 @@
1
- import{EXT as k,NS as W}from"./format.js";import{parseNode as K}from"../pivot/xml.js";import{xmlAttr as _}from"../io/xml-escape.js";import{dxfXml as G,parseDxfs as Y}from"../io/xlsx-tail.js";import{resolveColor as q}from"../io/xlsx-styles.js";import{bandRow as J}from"../core/tables.js";const j="{46F421CA-312F-682f-3DD2-61675219B42D}",U="{A0A4C193-F2C1-4fcb-8827-314CF55A85BB}",V=(e,l)=>e?.c?.find(i=>i.n===l)??null,Q=(e,l)=>e?e.c.filter(i=>i.n===l):[],v=e=>e.slice(e.indexOf(":")+1),Z=["wholeTable","headerRow","totalRow","firstColumn","lastColumn","firstRowStripe","secondRowStripe","firstColumnStripe","secondColumnStripe","firstHeaderCell","lastHeaderCell","firstTotalCell","lastTotalCell"],ee=["wholeTable","pageFieldLabels","pageFieldValues","firstColumnStripe","secondColumnStripe","firstRowStripe","secondRowStripe","firstColumn","headerRow","firstHeaderCell","firstSubtotalColumn","secondSubtotalColumn","thirdSubtotalColumn","blankRow","firstSubtotalRow","secondSubtotalRow","thirdSubtotalRow","firstColumnSubheading","secondColumnSubheading","thirdColumnSubheading","firstRowSubheading","secondRowSubheading","thirdRowSubheading","totalRow","lastColumn"],me=["unselectedItemWithData","selectedItemWithData","unselectedItemWithNoData","selectedItemWithNoData","hoveredUnselectedItemWithData","hoveredSelectedItemWithData","hoveredUnselectedItemWithNoData","hoveredSelectedItemWithNoData"],Se=["selectionLabel","timeLevel","periodLabel1","periodLabel2","selectedTimeBlock","unselectedTimeBlock","selectedTimeBlockSpace"];class te{constructor(){this.tableStyles=[],this.slicerStyles=[],this.timelineStyles=[],this.slicerDxfs=[],this.timelineDxfs=[],this.defaultTableStyle="TableStyleMedium2",this.defaultPivotStyle="PivotStyleLight16",this.defaultSlicerStyle="SlicerStyleLight1",this.defaultTimelineStyle="TimeSlicerStyleLight1",this.dirty=!1,this.version=0}find(l){return this.tableStyles.find(i=>i.name===l)??null}forTables(){return this.tableStyles.filter(l=>l.table)}forPivots(){return this.tableStyles.filter(l=>l.pivot)}setTableStyle(l,i,{table:d=!0,pivot:r=!1,elements:u={}}){const s=Object.entries(u).map(([o,f])=>({type:o,dxfId:le(l,f),...f.size?{size:f.size}:{}})),t={name:i,table:d,pivot:r,elements:s},a=this.tableStyles.findIndex(o=>o.name===i);return a>=0?this.tableStyles[a]=t:this.tableStyles.push(t),this.dirty=!0,this.version++,t}setSlicerStyle(l,i,{whole:d=null,header:r=null,elements:u={}}){this.setTableStyle(l,i,{table:!1,pivot:!1,elements:{...d?{wholeTable:d}:{},...r?{headerRow:r}:{}}});const s={name:i,elements:Object.entries(u).map(([a,o])=>({type:a,dxfId:this.slicerDxfs.push(o)-1}))},t=this.slicerStyles.findIndex(a=>a.name===i);return t>=0?this.slicerStyles[t]=s:this.slicerStyles.push(s),this.dirty=!0,s}setTimelineStyle(l,i,{whole:d=null,header:r=null,elements:u={}}){this.setTableStyle(l,i,{table:!1,pivot:!1,elements:{...d?{wholeTable:d}:{},...r?{headerRow:r}:{}}});const s={name:i,elements:Object.entries(u).map(([a,o])=>({type:a,dxfId:this.timelineDxfs.push(o)-1}))},t=this.timelineStyles.findIndex(a=>a.name===i);return t>=0?this.timelineStyles[t]=s:this.timelineStyles.push(s),this.dirty=!0,s}removeStyle(l){this.tableStyles=this.tableStyles.filter(i=>i.name!==l),this.slicerStyles=this.slicerStyles.filter(i=>i.name!==l),this.timelineStyles=this.timelineStyles.filter(i=>i.name!==l),this.dirty=!0,this.version++}savePlan(){return this.dirty?{tableStyles:this.tableStyles,slicerStyles:this.slicerStyles,timelineStyles:this.timelineStyles,slicerDxfs:this.slicerDxfs.map(G),timelineDxfs:this.timelineDxfs.map(G),defaultTableStyle:this.defaultTableStyle,defaultPivotStyle:this.defaultPivotStyle,defaultSlicerStyle:this.defaultSlicerStyle,defaultTimelineStyle:this.defaultTimelineStyle}:null}}function le(e,l){e.dxfs??=[];const{size:i,...d}=l;return e.dxfs.push(d),e.dxfs.length-1}const B=e=>(e?e.c.filter(l=>typeof l!="string"):[]).map(l=>({type:l.a.type,dxfId:Number(l.a.dxfId??-1),...l.a.size?{size:Number(l.a.size)}:{}})).filter(l=>l.dxfId>=0);function he(e,l=[]){const i=new te,d=typeof e=="string"?e:new TextDecoder().decode(e),r=t=>{const a=new RegExp(`<${t}:dxfs\\b[^>]*>([\\s\\S]*?)</${t}:dxfs>`).exec(d);return a?Y(new TextEncoder().encode(`<r><dxfs>${a[1]}</dxfs></r>`),o=>o?q(o,l):null):[]};i.slicerDxfs=r("x14"),i.timelineDxfs=r("x15");const u=K(e),s=V(u,"tableStyles");s&&(i.defaultTableStyle=s.a.defaultTableStyle??i.defaultTableStyle,i.defaultPivotStyle=s.a.defaultPivotStyle??i.defaultPivotStyle,i.tableStyles=Q(s,"tableStyle").map(t=>({name:t.a.name,table:t.a.table!=="0",pivot:t.a.pivot!=="0",elements:B(t)})));for(const t of V(u,"extLst")?.c??[])if(t.a?.uri===k.slicerStyles){const a=t.c.find(o=>v(o.n)==="slicerStyles");a&&(i.defaultSlicerStyle=a.a.defaultSlicerStyle??i.defaultSlicerStyle,i.slicerStyles=a.c.filter(o=>v(o.n)==="slicerStyle").map(o=>({name:o.a.name,elements:B(o.c.find(f=>v(f.n)==="slicerStyleElements"))})))}else if(t.a?.uri===k.timelineStyles){const a=t.c.find(o=>v(o.n)==="timelineStyles");a&&(i.defaultTimelineStyle=a.a.defaultTimelineStyle??i.defaultTimelineStyle,i.timelineStyles=a.c.filter(o=>v(o.n)==="timelineStyle").map(o=>({name:o.a.name,elements:B(o.c.find(f=>v(f.n)==="timelineStyleElements"))})))}return i}const H=(e,l)=>`<${e} type="${l.type}"${l.size?` size="${l.size}"`:""} dxfId="${l.dxfId}"/>`;function be(e,l){if(!l)return e;const i=n=>(l.slicerStyles.find(h=>h.name===n)?.elements.length??0)+(l.timelineStyles.find(h=>h.name===n)?.elements.length??0),d=`<tableStyles count="${l.tableStyles.length}" defaultTableStyle="${_(l.defaultTableStyle)}" defaultPivotStyle="${_(l.defaultPivotStyle)}"${l.tableStyles.length?`>${l.tableStyles.map(n=>`<tableStyle name="${_(n.name)}"${n.table?"":' table="0"'}${n.pivot?"":' pivot="0"'} count="${n.elements.length+i(n.name)}">${n.elements.map(h=>H("tableStyleElement",h)).join("")}</tableStyle>`).join("")}</tableStyles>`:"/>"}`;let r=e;if(/<tableStyles\b/.test(r))r=r.replace(/<tableStyles\b[^>]*?\/>|<tableStyles\b[\s\S]*?<\/tableStyles>/,d);else{const n=/<(?:colors|extLst)\b|<\/styleSheet>/.exec(r);r=`${r.slice(0,n.index)}${/<dxfs\b/.test(r)?"":'<dxfs count="0"/>'}${d}${r.slice(n.index)}`}const u=n=>{r=r.replace(new RegExp(`<ext\\b[^>]*uri="${n.replace(/[{}-]/g,"\\$&")}"[^>]*>[\\s\\S]*?</ext>`),"")};u(k.slicerStyles),u(k.timelineStyles),u(j),u(U);const s=(n,h,b,m)=>m.length?`<ext uri="${n}" xmlns:${h}="${b}"><${h}:dxfs count="${m.length}">${m.join("")}</${h}:dxfs></ext>`:"",t=`${s(j,"x14",W.x14,l.slicerDxfs)}`,a=`${s(U,"x15",W.x15,l.timelineDxfs)}`,o=`<ext uri="${k.slicerStyles}" xmlns:x14="${W.x14}"><x14:slicerStyles defaultSlicerStyle="${_(l.defaultSlicerStyle)}"${l.slicerStyles.length?`>${l.slicerStyles.map(n=>`<x14:slicerStyle name="${_(n.name)}"><x14:slicerStyleElements>${n.elements.map(h=>H("x14:slicerStyleElement",h)).join("")}</x14:slicerStyleElements></x14:slicerStyle>`).join("")}</x14:slicerStyles>`:"/>"}</ext>`,f=`<ext uri="${k.timelineStyles}" xmlns:x15="${W.x15}"><x15:timelineStyles defaultTimelineStyle="${_(l.defaultTimelineStyle)}"${l.timelineStyles.length?`>${l.timelineStyles.map(n=>`<x15:timelineStyle name="${_(n.name)}"><x15:timelineStyleElements>${n.elements.map(h=>H("x15:timelineStyleElement",h)).join("")}</x15:timelineStyleElements></x15:timelineStyle>`).join("")}</x15:timelineStyles>`:"/>"}</ext>`;return/<\/extLst>\s*<\/styleSheet>/.test(r)?r=r.replace(/<\/extLst>(\s*<\/styleSheet>)/,`${t}${o}${a}${f}</extLst>$1`):r=r.replace("</styleSheet>",`<extLst>${t}${o}${a}${f}</extLst></styleSheet>`),r}const O=(e,l,i,d=e.dxfs)=>{const r=l?.elements.find(u=>u.type===i);return r?d?.[r.dxfId]??{}:null},N=e=>{const l=e?.borders;return l?l.b?.color??l.t?.color??l.l?.color??l.r?.color??null:null},ie=["fill","color","bold","italic","underline","strike"],E=(e,l)=>{if(l)for(const i of ie)l[i]!==void 0&&(e[i]=l[i])},X=(e,l,i)=>e%(l+i)<l?0:1;function ye(e,l,i){const d=l?.find(i);if(!d)return null;const r=s=>d.elements.find(t=>t.type===s)?.size??1,u=Object.fromEntries(Z.map(s=>[s,O(e,d,s)]));return se(u,[r("firstRowStripe"),r("secondRowStripe")],[r("firstColumnStripe"),r("secondColumnStripe")],!0)}function se(e,l=[1,1],i=[1,1],d=!1){const r=(t,a,o)=>{const f={},n=t.r0+t.headerRows,h=t.r1-t.totalsRows,b=a>=n&&a<=h;return E(f,e.wholeTable),b&&(t.showColumnStripes&&E(f,X(o-t.c0,i[0],i[1])===0?e.firstColumnStripe:e.secondColumnStripe),t.showRowStripes!==!1&&E(f,X(J(t,a),l[0],l[1])===0?e.firstRowStripe:e.secondRowStripe)),t.showFirstColumn&&o===t.c0&&E(f,e.firstColumn),t.showLastColumn&&o===t.c1&&E(f,e.lastColumn),a<n?(E(f,e.headerRow),o===t.c0&&t.showFirstColumn&&E(f,e.firstHeaderCell),o===t.c1&&t.showLastColumn&&E(f,e.lastHeaderCell)):a>h&&(E(f,e.totalRow),o===t.c0&&t.showFirstColumn&&E(f,e.firstTotalCell),o===t.c1&&t.showLastColumn&&E(f,e.lastTotalCell)),f},u=(t,a,o,f,n)=>{const h=[],b=(R,w,y,T,S)=>{R?.borders&&T>=w&&S>=y&&h.push({borders:R.borders,r0:w,c0:y,r1:T,c1:S})},m=t.r0+t.headerRows,c=t.r1-t.totalsRows;if(b(e.wholeTable,t.r0,t.c0,t.r1,t.c1),t.showColumnStripes&&(e.firstColumnStripe?.borders||e.secondColumnStripe?.borders)){const R=i[0]+i[1];for(let w=t.c0;w<=Math.min(t.c1,n);w+=R)b(e.firstColumnStripe,m,w,c,Math.min(t.c1,w+i[0]-1)),b(e.secondColumnStripe,m,w+i[0],c,Math.min(t.c1,w+R-1))}if(t.showRowStripes!==!1&&(e.firstRowStripe?.borders||e.secondRowStripe?.borders)){const R=l[0]+l[1],w=m+Math.floor(Math.max(0,a-m)/R)*R;for(let y=w;y<=Math.min(c,o);y+=R)b(e.firstRowStripe,y,t.c0,Math.min(c,y+l[0]-1),t.c1),b(e.secondRowStripe,y+l[0],t.c0,Math.min(c,y+R-1),t.c1)}return t.showFirstColumn&&b(e.firstColumn,t.r0,t.c0,t.r1,t.c0),t.showLastColumn&&b(e.lastColumn,t.r0,t.c1,t.r1,t.c1),t.headerRows>0&&(b(e.headerRow,t.r0,t.c0,m-1,t.c1),t.showFirstColumn&&b(e.firstHeaderCell,t.r0,t.c0,m-1,t.c0),t.showLastColumn&&b(e.lastHeaderCell,t.r0,t.c1,m-1,t.c1)),t.totalsRows>0&&(b(e.totalRow,c+1,t.c0,t.r1,t.c1),t.showFirstColumn&&b(e.firstTotalCell,c+1,t.c0,t.r1,t.c0),t.showLastColumn&&b(e.lastTotalCell,c+1,t.c1,t.r1,t.c1)),h},s=e.headerRow;return{format:r,areas:u,custom:d,headerFill:s?.fill??null,headerInk:s?.color??(s?.fill?"#FFFFFF":"#000000"),headerRule:N(s),band:e.firstRowStripe?.fill??null,rule:N(e.wholeTable)??N(e.totalRow),body:e.wholeTable?.fill??null,ink:e.wholeTable?.color??null}}const z={medium:2,mediumDashed:2,mediumDashDot:2,mediumDashDotDot:2,slantDashDot:2,thick:3,double:3};function pe(e,l,i,{ra:d,rb:r,ca:u,cb:s,xs:t,ys:a,ox:o=0,oy:f=0,line:n=1,noFill:h=!1,setInk:b}){const m=Math.max(l.r0,d),c=Math.min(l.r1,r),R=Math.max(l.c0,u),w=Math.min(l.c1,s);for(let S=h?c+1:m;S<=c;S++){const p=a[S-d],x=a[S-d+1]-p;if(x!==0)for(let L=R;L<=w;L++){const $=t[L-u],A=t[L-u+1]-$;if(A===0)continue;const{fill:C}=i.format(l,S,L);C&&(b(C),e.fillRect(o+$,f+p,A,x))}}const y=(S,p,x,L,$)=>{b(S.color);const A=z[S.style]??1,C=$?L-A*n:L;S.style==="double"?(e.fillRect(o+p,f+C,x-p,n),e.fillRect(o+p,f+C+2*n,x-p,n)):e.fillRect(o+p,f+C,x-p,A*n)},T=(S,p,x,L,$)=>{b(S.color);const A=z[S.style]??1,C=$?L-A*n:L;S.style==="double"?(e.fillRect(o+C,f+p,n,x-p),e.fillRect(o+C+2*n,f+p,n,x-p)):e.fillRect(o+C,f+p,A*n,x-p)};for(const S of i.areas(l,m,c,R,w)){if(S.r1<d||S.r0>r||S.c1<u||S.c0>s)continue;const p=Math.max(S.c0,u),x=Math.min(S.c1,s),L=Math.max(S.r0,d),$=Math.min(S.r1,r),A=t[p-u],C=t[x-u+1],P=a[L-d],M=a[$-d+1],D=S.borders;if(D.h)for(let I=L;I<$+(S.r1>$?1:0);I++){const g=a[I-d+1];g!==a[I-d]&&y(D.h,A,C,g,!0)}if(D.v)for(let I=p;I<x+(S.c1>x?1:0);I++){const g=t[I-u+1];g!==t[I-u]&&T(D.v,P,M,g,!0)}D.t&&S.r0>=d&&y(D.t,A,C,P,!1),D.b&&S.r1<=r&&y(D.b,A,C,M,!0),D.l&&S.c0>=u&&T(D.l,P,M,A,!1),D.r&&S.c1<=s&&T(D.r,P,M,C,!0)}}const oe={NONE:0,PAGE_LABEL:1,PAGE_VALUE:2,CORNER:3,HEADER_BLANK:4,COL_CAPTION:5,ROW_CAPTION:6,COL_ITEM:7,COL_SUBTOTAL:8,COL_GRAND:9,DATA_HEADER:10,ROW_ITEM:11,ROW_PARENT:12,ROW_SUBTOTAL:13,ROW_GRAND:14,DATA:15,DATA_PARENT:16,DATA_SUBTOTAL:17,DATA_GRAND_ROW:18,DATA_GRAND_COL:19,PLACEHOLDER:20},F=(e,l,i,d)=>e<=0?l:e===1?i:d;function Re(e,l,i){const d=l?.find(i);return d?ne(Object.fromEntries(ee.map(r=>[r,O(e,d,r)])),!0):null}function ne(e,l=!1){const i=oe,d=e.wholeTable?.borders&&(e.wholeTable.borders.h||e.wholeTable.borders.v)?{...e.wholeTable,borders:{b:e.wholeTable.borders.h??null,r:e.wholeTable.borders.v??null}}:e.wholeTable&&{...e.wholeTable,borders:void 0};return{patch:(u,s,t,a={},o=0)=>{const f={},n=a.colHeaders===!1?null:e.headerRow,h=a.rowHeaders===!1?null:e.firstColumn,b=a.lastColumn===!1?null:e.lastColumn,m={},c=(T,S="tb")=>{T&&(E(f,T),T.borders&&(S.includes("t")&&T.borders.t&&(m.t=T.borders.t),S.includes("b")&&T.borders.b&&(m.b=T.borders.b),S.includes("l")&&T.borders.l&&(m.l=T.borders.l),S.includes("r")&&T.borders.r&&(m.r=T.borders.r)))};u!==i.PAGE_LABEL&&u!==i.PAGE_VALUE&&c(d,"br");const R=m.b,w=m.r;switch(t&4&&c(e.firstColumnStripe,"lr"),t&8&&c(e.secondColumnStripe,"lr"),t&1&&c(e.firstRowStripe),t&2&&c(e.secondRowStripe),u){case i.PAGE_LABEL:c(e.pageFieldLabels,"tblr");break;case i.PAGE_VALUE:c(e.pageFieldValues,"tblr");break;case i.CORNER:c(n),c(h,"lr"),c(e.firstHeaderCell,"tblr");break;case i.HEADER_BLANK:case i.COL_CAPTION:case i.DATA_HEADER:c(n);break;case i.ROW_CAPTION:c(n),c(e.firstHeaderCell,"tblr");break;case i.COL_ITEM:c(n),c(F(s,e.firstColumnSubheading,e.secondColumnSubheading,e.thirdColumnSubheading));break;case i.COL_SUBTOTAL:c(n),c(F(s,e.firstSubtotalColumn,e.secondSubtotalColumn,e.thirdSubtotalColumn),"lr");break;case i.COL_GRAND:c(n),c(b,"lr");break;case i.ROW_ITEM:c(h,"lr");break;case i.ROW_PARENT:c(h,"lr"),c(F(s,e.firstRowSubheading,e.secondRowSubheading,e.thirdRowSubheading));break;case i.ROW_SUBTOTAL:c(h,"lr"),c(F(s,e.firstSubtotalRow,e.secondSubtotalRow,e.thirdSubtotalRow));break;case i.ROW_GRAND:c(h,"lr"),c(e.totalRow);break;case i.DATA_PARENT:c(F(s,e.firstRowSubheading,e.secondRowSubheading,e.thirdRowSubheading));break;case i.DATA_SUBTOTAL:c(F(s,e.firstSubtotalRow,e.secondSubtotalRow,e.thirdSubtotalRow));break;case i.DATA_GRAND_ROW:c(e.totalRow);break;case i.DATA_GRAND_COL:c(b,"lr");break;case i.PLACEHOLDER:c(e.blankRow);break;default:}const y=e.wholeTable?.borders;return y&&o&&(o&1&&y.t&&!m.t&&(m.t=y.t),o&2&&y.b&&(!m.b||m.b===R)&&(m.b=y.b),o&4&&y.l&&!m.l&&(m.l=y.l),o&8&&y.r&&(!m.r||m.r===w)&&(m.r=y.r)),Object.keys(m).length&&(f.borders=m),f},stripe:e.firstRowStripe?.fill??null,custom:l,header:{},sub:{},grand:{},parent:{},page:{}}}function Te(e,l,i,d){const r=l?.slicerStyles.find(n=>n.name===i),u=l?.find(i);if(!r&&!u)return null;const s={...d},t=O(e,u,"wholeTable"),a=O(e,u,"headerRow");t?.fill&&(s.frameFill=t.fill),t?.color&&(s.ink=t.color);const o=N(t);o&&(s.frameLine=o),a?.color&&(s.captionInk=a.color),a?.fill&&(s.captionFill=a.fill);const f=(n,h,b,m)=>{const c=O(e,r,n,l.slicerDxfs);if(!c)return;c.fill&&(s[h]=c.fill),c.color&&(s[b]=c.color);const R=N(c);R&&m&&(s[m]=R)};return f("selectedItemWithData","selFill","selInk","selLine"),f("unselectedItemWithData","fill","itemInk","itemLine"),f("selectedItemWithNoData","selNoFill","selNoInk"),f("unselectedItemWithNoData","noFill","noInk"),s.hoverSelFill=s.selFill,s.hoverSelInk=s.selInk,s.hoverFill=s.fill,s.hoverInk=s.itemInk,f("hoveredSelectedItemWithData","hoverSelFill","hoverSelInk"),f("hoveredUnselectedItemWithData","hoverFill","hoverInk"),s}function we(e,l,i,d){const r=l?.timelineStyles.find(h=>h.name===i),u=l?.find(i);if(!r&&!u)return null;const s={...d},t=O(e,u,"wholeTable"),a=O(e,u,"headerRow");t?.fill&&(s.frameFill=t.fill);const o=N(t);o&&(s.frameLine=o),a?.color&&(s.captionInk=a.color);const f=(h,b)=>{const m=O(e,r,h,l.timelineDxfs);m?.fill&&(s[b]=m.fill)},n=(h,b)=>{const m=O(e,r,h,l.timelineDxfs);m?.color&&(s[b]=m.color)};return f("selectedTimeBlock","selFill"),f("unselectedTimeBlock","blockFill"),f("selectedTimeBlockSpace","selSpaceFill"),n("selectionLabel","labelInk"),n("timeLevel","levelInk"),n("periodLabel1","periodInk"),n("periodLabel2","subPeriodInk"),s}export{te as CustomStyles,ee as PIVOT_ELEMENTS,me as SLICER_ELEMENTS,Z as TABLE_ELEMENTS,Se as TIMELINE_ELEMENTS,le as addDxf,Re as customPivotPattern,Te as customSlicerColors,ye as customTableColors,we as customTimelineColors,ne as elementPivotPattern,se as elementTableColors,pe as paintCustomTable,he as parseCustomStyles,be as patchCustomStyles};
1
+ import{EXT as k,NS as W}from"./format.js";import{parseNode as K}from"../pivot/xml.js";import{xmlAttr as _}from"../io/xml-escape.js";import{dxfXml as G,parseDxfs as Y}from"../io/xlsx-tail.js";import{resolveColor as q}from"../io/xlsx-styles.js";import{bandRow as J}from"../core/tables.js";const j="{46F421CA-312F-682f-3DD2-61675219B42D}",U="{A0A4C193-F2C1-4fcb-8827-314CF55A85BB}",V=(e,l)=>e?.c?.find(i=>i.n===l)??null,Q=(e,l)=>e?e.c.filter(i=>i.n===l):[],v=e=>e.slice(e.indexOf(":")+1),Z=["wholeTable","headerRow","totalRow","firstColumn","lastColumn","firstRowStripe","secondRowStripe","firstColumnStripe","secondColumnStripe","firstHeaderCell","lastHeaderCell","firstTotalCell","lastTotalCell"],ee=["wholeTable","pageFieldLabels","pageFieldValues","firstColumnStripe","secondColumnStripe","firstRowStripe","secondRowStripe","firstColumn","headerRow","firstHeaderCell","firstSubtotalColumn","secondSubtotalColumn","thirdSubtotalColumn","blankRow","firstSubtotalRow","secondSubtotalRow","thirdSubtotalRow","firstColumnSubheading","secondColumnSubheading","thirdColumnSubheading","firstRowSubheading","secondRowSubheading","thirdRowSubheading","totalRow","lastColumn"],me=["unselectedItemWithData","selectedItemWithData","unselectedItemWithNoData","selectedItemWithNoData","hoveredUnselectedItemWithData","hoveredSelectedItemWithData","hoveredUnselectedItemWithNoData","hoveredSelectedItemWithNoData"],Se=["selectionLabel","timeLevel","periodLabel1","periodLabel2","selectedTimeBlock","unselectedTimeBlock","selectedTimeBlockSpace"];class te{constructor(){this.tableStyles=[],this.slicerStyles=[],this.timelineStyles=[],this.slicerDxfs=[],this.timelineDxfs=[],this.defaultTableStyle="TableStyleMedium2",this.defaultPivotStyle="PivotStyleLight16",this.defaultSlicerStyle="SlicerStyleLight1",this.defaultTimelineStyle="TimeSlicerStyleLight1",this.dirty=!1,this.version=0}find(l){return this.tableStyles.find(i=>i.name===l)??null}forTables(){return this.tableStyles.filter(l=>l.table)}forPivots(){return this.tableStyles.filter(l=>l.pivot)}setTableStyle(l,i,{table:d=!0,pivot:r=!1,elements:u={}}){const s=Object.entries(u).map(([o,f])=>({type:o,dxfId:le(l,f),...f.size?{size:f.size}:{}})),t={name:i,table:d,pivot:r,elements:s},a=this.tableStyles.findIndex(o=>o.name===i);return a>=0?this.tableStyles[a]=t:this.tableStyles.push(t),this.dirty=!0,this.version++,t}setSlicerStyle(l,i,{whole:d=null,header:r=null,elements:u={}}){this.setTableStyle(l,i,{table:!1,pivot:!1,elements:{...d?{wholeTable:d}:{},...r?{headerRow:r}:{}}});const s={name:i,elements:Object.entries(u).map(([a,o])=>({type:a,dxfId:this.slicerDxfs.push(o)-1}))},t=this.slicerStyles.findIndex(a=>a.name===i);return t>=0?this.slicerStyles[t]=s:this.slicerStyles.push(s),this.dirty=!0,s}setTimelineStyle(l,i,{whole:d=null,header:r=null,elements:u={}}){this.setTableStyle(l,i,{table:!1,pivot:!1,elements:{...d?{wholeTable:d}:{},...r?{headerRow:r}:{}}});const s={name:i,elements:Object.entries(u).map(([a,o])=>({type:a,dxfId:this.timelineDxfs.push(o)-1}))},t=this.timelineStyles.findIndex(a=>a.name===i);return t>=0?this.timelineStyles[t]=s:this.timelineStyles.push(s),this.dirty=!0,s}setDefaultTableStyle(l){return this.defaultTableStyle===l?!1:(this.defaultTableStyle=l,this.dirty=!0,this.version++,!0)}removeStyle(l){this.tableStyles=this.tableStyles.filter(i=>i.name!==l),this.slicerStyles=this.slicerStyles.filter(i=>i.name!==l),this.timelineStyles=this.timelineStyles.filter(i=>i.name!==l),this.dirty=!0,this.version++}savePlan(){return this.dirty?{tableStyles:this.tableStyles,slicerStyles:this.slicerStyles,timelineStyles:this.timelineStyles,slicerDxfs:this.slicerDxfs.map(G),timelineDxfs:this.timelineDxfs.map(G),defaultTableStyle:this.defaultTableStyle,defaultPivotStyle:this.defaultPivotStyle,defaultSlicerStyle:this.defaultSlicerStyle,defaultTimelineStyle:this.defaultTimelineStyle}:null}}function le(e,l){e.dxfs??=[];const{size:i,...d}=l;return e.dxfs.push(d),e.dxfs.length-1}const B=e=>(e?e.c.filter(l=>typeof l!="string"):[]).map(l=>({type:l.a.type,dxfId:Number(l.a.dxfId??-1),...l.a.size?{size:Number(l.a.size)}:{}})).filter(l=>l.dxfId>=0);function he(e,l=[]){const i=new te,d=typeof e=="string"?e:new TextDecoder().decode(e),r=t=>{const a=new RegExp(`<${t}:dxfs\\b[^>]*>([\\s\\S]*?)</${t}:dxfs>`).exec(d);return a?Y(new TextEncoder().encode(`<r><dxfs>${a[1]}</dxfs></r>`),o=>o?q(o,l):null):[]};i.slicerDxfs=r("x14"),i.timelineDxfs=r("x15");const u=K(e),s=V(u,"tableStyles");s&&(i.defaultTableStyle=s.a.defaultTableStyle??i.defaultTableStyle,i.defaultPivotStyle=s.a.defaultPivotStyle??i.defaultPivotStyle,i.tableStyles=Q(s,"tableStyle").map(t=>({name:t.a.name,table:t.a.table!=="0",pivot:t.a.pivot!=="0",elements:B(t)})));for(const t of V(u,"extLst")?.c??[])if(t.a?.uri===k.slicerStyles){const a=t.c.find(o=>v(o.n)==="slicerStyles");a&&(i.defaultSlicerStyle=a.a.defaultSlicerStyle??i.defaultSlicerStyle,i.slicerStyles=a.c.filter(o=>v(o.n)==="slicerStyle").map(o=>({name:o.a.name,elements:B(o.c.find(f=>v(f.n)==="slicerStyleElements"))})))}else if(t.a?.uri===k.timelineStyles){const a=t.c.find(o=>v(o.n)==="timelineStyles");a&&(i.defaultTimelineStyle=a.a.defaultTimelineStyle??i.defaultTimelineStyle,i.timelineStyles=a.c.filter(o=>v(o.n)==="timelineStyle").map(o=>({name:o.a.name,elements:B(o.c.find(f=>v(f.n)==="timelineStyleElements"))})))}return i}const H=(e,l)=>`<${e} type="${l.type}"${l.size?` size="${l.size}"`:""} dxfId="${l.dxfId}"/>`;function be(e,l){if(!l)return e;const i=n=>(l.slicerStyles.find(h=>h.name===n)?.elements.length??0)+(l.timelineStyles.find(h=>h.name===n)?.elements.length??0),d=`<tableStyles count="${l.tableStyles.length}" defaultTableStyle="${_(l.defaultTableStyle)}" defaultPivotStyle="${_(l.defaultPivotStyle)}"${l.tableStyles.length?`>${l.tableStyles.map(n=>`<tableStyle name="${_(n.name)}"${n.table?"":' table="0"'}${n.pivot?"":' pivot="0"'} count="${n.elements.length+i(n.name)}">${n.elements.map(h=>H("tableStyleElement",h)).join("")}</tableStyle>`).join("")}</tableStyles>`:"/>"}`;let r=e;if(/<tableStyles\b/.test(r))r=r.replace(/<tableStyles\b[^>]*?\/>|<tableStyles\b[\s\S]*?<\/tableStyles>/,d);else{const n=/<(?:colors|extLst)\b|<\/styleSheet>/.exec(r);r=`${r.slice(0,n.index)}${/<dxfs\b/.test(r)?"":'<dxfs count="0"/>'}${d}${r.slice(n.index)}`}const u=n=>{r=r.replace(new RegExp(`<ext\\b[^>]*uri="${n.replace(/[{}-]/g,"\\$&")}"[^>]*>[\\s\\S]*?</ext>`),"")};u(k.slicerStyles),u(k.timelineStyles),u(j),u(U);const s=(n,h,b,m)=>m.length?`<ext uri="${n}" xmlns:${h}="${b}"><${h}:dxfs count="${m.length}">${m.join("")}</${h}:dxfs></ext>`:"",t=`${s(j,"x14",W.x14,l.slicerDxfs)}`,a=`${s(U,"x15",W.x15,l.timelineDxfs)}`,o=`<ext uri="${k.slicerStyles}" xmlns:x14="${W.x14}"><x14:slicerStyles defaultSlicerStyle="${_(l.defaultSlicerStyle)}"${l.slicerStyles.length?`>${l.slicerStyles.map(n=>`<x14:slicerStyle name="${_(n.name)}"><x14:slicerStyleElements>${n.elements.map(h=>H("x14:slicerStyleElement",h)).join("")}</x14:slicerStyleElements></x14:slicerStyle>`).join("")}</x14:slicerStyles>`:"/>"}</ext>`,f=`<ext uri="${k.timelineStyles}" xmlns:x15="${W.x15}"><x15:timelineStyles defaultTimelineStyle="${_(l.defaultTimelineStyle)}"${l.timelineStyles.length?`>${l.timelineStyles.map(n=>`<x15:timelineStyle name="${_(n.name)}"><x15:timelineStyleElements>${n.elements.map(h=>H("x15:timelineStyleElement",h)).join("")}</x15:timelineStyleElements></x15:timelineStyle>`).join("")}</x15:timelineStyles>`:"/>"}</ext>`;return/<\/extLst>\s*<\/styleSheet>/.test(r)?r=r.replace(/<\/extLst>(\s*<\/styleSheet>)/,`${t}${o}${a}${f}</extLst>$1`):r=r.replace("</styleSheet>",`<extLst>${t}${o}${a}${f}</extLst></styleSheet>`),r}const O=(e,l,i,d=e.dxfs)=>{const r=l?.elements.find(u=>u.type===i);return r?d?.[r.dxfId]??{}:null},N=e=>{const l=e?.borders;return l?l.b?.color??l.t?.color??l.l?.color??l.r?.color??null:null},ie=["fill","color","bold","italic","underline","strike"],E=(e,l)=>{if(l)for(const i of ie)l[i]!==void 0&&(e[i]=l[i])},X=(e,l,i)=>e%(l+i)<l?0:1;function ye(e,l,i){const d=l?.find(i);if(!d)return null;const r=s=>d.elements.find(t=>t.type===s)?.size??1,u=Object.fromEntries(Z.map(s=>[s,O(e,d,s)]));return se(u,[r("firstRowStripe"),r("secondRowStripe")],[r("firstColumnStripe"),r("secondColumnStripe")],!0)}function se(e,l=[1,1],i=[1,1],d=!1){const r=(t,a,o)=>{const f={},n=t.r0+t.headerRows,h=t.r1-t.totalsRows,b=a>=n&&a<=h;return E(f,e.wholeTable),b&&(t.showColumnStripes&&E(f,X(o-t.c0,i[0],i[1])===0?e.firstColumnStripe:e.secondColumnStripe),t.showRowStripes!==!1&&E(f,X(J(t,a),l[0],l[1])===0?e.firstRowStripe:e.secondRowStripe)),t.showFirstColumn&&o===t.c0&&E(f,e.firstColumn),t.showLastColumn&&o===t.c1&&E(f,e.lastColumn),a<n?(E(f,e.headerRow),o===t.c0&&t.showFirstColumn&&E(f,e.firstHeaderCell),o===t.c1&&t.showLastColumn&&E(f,e.lastHeaderCell)):a>h&&(E(f,e.totalRow),o===t.c0&&t.showFirstColumn&&E(f,e.firstTotalCell),o===t.c1&&t.showLastColumn&&E(f,e.lastTotalCell)),f},u=(t,a,o,f,n)=>{const h=[],b=(R,w,y,T,S)=>{R?.borders&&T>=w&&S>=y&&h.push({borders:R.borders,r0:w,c0:y,r1:T,c1:S})},m=t.r0+t.headerRows,c=t.r1-t.totalsRows;if(b(e.wholeTable,t.r0,t.c0,t.r1,t.c1),t.showColumnStripes&&(e.firstColumnStripe?.borders||e.secondColumnStripe?.borders)){const R=i[0]+i[1];for(let w=t.c0;w<=Math.min(t.c1,n);w+=R)b(e.firstColumnStripe,m,w,c,Math.min(t.c1,w+i[0]-1)),b(e.secondColumnStripe,m,w+i[0],c,Math.min(t.c1,w+R-1))}if(t.showRowStripes!==!1&&(e.firstRowStripe?.borders||e.secondRowStripe?.borders)){const R=l[0]+l[1],w=m+Math.floor(Math.max(0,a-m)/R)*R;for(let y=w;y<=Math.min(c,o);y+=R)b(e.firstRowStripe,y,t.c0,Math.min(c,y+l[0]-1),t.c1),b(e.secondRowStripe,y+l[0],t.c0,Math.min(c,y+R-1),t.c1)}return t.showFirstColumn&&b(e.firstColumn,t.r0,t.c0,t.r1,t.c0),t.showLastColumn&&b(e.lastColumn,t.r0,t.c1,t.r1,t.c1),t.headerRows>0&&(b(e.headerRow,t.r0,t.c0,m-1,t.c1),t.showFirstColumn&&b(e.firstHeaderCell,t.r0,t.c0,m-1,t.c0),t.showLastColumn&&b(e.lastHeaderCell,t.r0,t.c1,m-1,t.c1)),t.totalsRows>0&&(b(e.totalRow,c+1,t.c0,t.r1,t.c1),t.showFirstColumn&&b(e.firstTotalCell,c+1,t.c0,t.r1,t.c0),t.showLastColumn&&b(e.lastTotalCell,c+1,t.c1,t.r1,t.c1)),h},s=e.headerRow;return{format:r,areas:u,custom:d,headerFill:s?.fill??null,headerInk:s?.color??(s?.fill?"#FFFFFF":"#000000"),headerRule:N(s),band:e.firstRowStripe?.fill??null,rule:N(e.wholeTable)??N(e.totalRow),body:e.wholeTable?.fill??null,ink:e.wholeTable?.color??null}}const z={medium:2,mediumDashed:2,mediumDashDot:2,mediumDashDotDot:2,slantDashDot:2,thick:3,double:3};function pe(e,l,i,{ra:d,rb:r,ca:u,cb:s,xs:t,ys:a,ox:o=0,oy:f=0,line:n=1,noFill:h=!1,setInk:b}){const m=Math.max(l.r0,d),c=Math.min(l.r1,r),R=Math.max(l.c0,u),w=Math.min(l.c1,s);for(let S=h?c+1:m;S<=c;S++){const p=a[S-d],x=a[S-d+1]-p;if(x!==0)for(let L=R;L<=w;L++){const $=t[L-u],D=t[L-u+1]-$;if(D===0)continue;const{fill:C}=i.format(l,S,L);C&&(b(C),e.fillRect(o+$,f+p,D,x))}}const y=(S,p,x,L,$)=>{b(S.color);const D=z[S.style]??1,C=$?L-D*n:L;S.style==="double"?(e.fillRect(o+p,f+C,x-p,n),e.fillRect(o+p,f+C+2*n,x-p,n)):e.fillRect(o+p,f+C,x-p,D*n)},T=(S,p,x,L,$)=>{b(S.color);const D=z[S.style]??1,C=$?L-D*n:L;S.style==="double"?(e.fillRect(o+C,f+p,n,x-p),e.fillRect(o+C+2*n,f+p,n,x-p)):e.fillRect(o+C,f+p,D*n,x-p)};for(const S of i.areas(l,m,c,R,w)){if(S.r1<d||S.r0>r||S.c1<u||S.c0>s)continue;const p=Math.max(S.c0,u),x=Math.min(S.c1,s),L=Math.max(S.r0,d),$=Math.min(S.r1,r),D=t[p-u],C=t[x-u+1],P=a[L-d],M=a[$-d+1],A=S.borders;if(A.h)for(let I=L;I<$+(S.r1>$?1:0);I++){const g=a[I-d+1];g!==a[I-d]&&y(A.h,D,C,g,!0)}if(A.v)for(let I=p;I<x+(S.c1>x?1:0);I++){const g=t[I-u+1];g!==t[I-u]&&T(A.v,P,M,g,!0)}A.t&&S.r0>=d&&y(A.t,D,C,P,!1),A.b&&S.r1<=r&&y(A.b,D,C,M,!0),A.l&&S.c0>=u&&T(A.l,P,M,D,!1),A.r&&S.c1<=s&&T(A.r,P,M,C,!0)}}const oe={NONE:0,PAGE_LABEL:1,PAGE_VALUE:2,CORNER:3,HEADER_BLANK:4,COL_CAPTION:5,ROW_CAPTION:6,COL_ITEM:7,COL_SUBTOTAL:8,COL_GRAND:9,DATA_HEADER:10,ROW_ITEM:11,ROW_PARENT:12,ROW_SUBTOTAL:13,ROW_GRAND:14,DATA:15,DATA_PARENT:16,DATA_SUBTOTAL:17,DATA_GRAND_ROW:18,DATA_GRAND_COL:19,PLACEHOLDER:20},F=(e,l,i,d)=>e<=0?l:e===1?i:d;function Re(e,l,i){const d=l?.find(i);return d?ne(Object.fromEntries(ee.map(r=>[r,O(e,d,r)])),!0):null}function ne(e,l=!1){const i=oe,d=e.wholeTable?.borders&&(e.wholeTable.borders.h||e.wholeTable.borders.v)?{...e.wholeTable,borders:{b:e.wholeTable.borders.h??null,r:e.wholeTable.borders.v??null}}:e.wholeTable&&{...e.wholeTable,borders:void 0};return{patch:(u,s,t,a={},o=0)=>{const f={},n=a.colHeaders===!1?null:e.headerRow,h=a.rowHeaders===!1?null:e.firstColumn,b=a.lastColumn===!1?null:e.lastColumn,m={},c=(T,S="tb")=>{T&&(E(f,T),T.borders&&(S.includes("t")&&T.borders.t&&(m.t=T.borders.t),S.includes("b")&&T.borders.b&&(m.b=T.borders.b),S.includes("l")&&T.borders.l&&(m.l=T.borders.l),S.includes("r")&&T.borders.r&&(m.r=T.borders.r)))};u!==i.PAGE_LABEL&&u!==i.PAGE_VALUE&&c(d,"br");const R=m.b,w=m.r;switch(t&4&&c(e.firstColumnStripe,"lr"),t&8&&c(e.secondColumnStripe,"lr"),t&1&&c(e.firstRowStripe),t&2&&c(e.secondRowStripe),u){case i.PAGE_LABEL:c(e.pageFieldLabels,"tblr");break;case i.PAGE_VALUE:c(e.pageFieldValues,"tblr");break;case i.CORNER:c(n),c(h,"lr"),c(e.firstHeaderCell,"tblr");break;case i.HEADER_BLANK:case i.COL_CAPTION:case i.DATA_HEADER:c(n);break;case i.ROW_CAPTION:c(n),c(e.firstHeaderCell,"tblr");break;case i.COL_ITEM:c(n),c(F(s,e.firstColumnSubheading,e.secondColumnSubheading,e.thirdColumnSubheading));break;case i.COL_SUBTOTAL:c(n),c(F(s,e.firstSubtotalColumn,e.secondSubtotalColumn,e.thirdSubtotalColumn),"lr");break;case i.COL_GRAND:c(n),c(b,"lr");break;case i.ROW_ITEM:c(h,"lr");break;case i.ROW_PARENT:c(h,"lr"),c(F(s,e.firstRowSubheading,e.secondRowSubheading,e.thirdRowSubheading));break;case i.ROW_SUBTOTAL:c(h,"lr"),c(F(s,e.firstSubtotalRow,e.secondSubtotalRow,e.thirdSubtotalRow));break;case i.ROW_GRAND:c(h,"lr"),c(e.totalRow);break;case i.DATA_PARENT:c(F(s,e.firstRowSubheading,e.secondRowSubheading,e.thirdRowSubheading));break;case i.DATA_SUBTOTAL:c(F(s,e.firstSubtotalRow,e.secondSubtotalRow,e.thirdSubtotalRow));break;case i.DATA_GRAND_ROW:c(e.totalRow);break;case i.DATA_GRAND_COL:c(b,"lr");break;case i.PLACEHOLDER:c(e.blankRow);break;default:}const y=e.wholeTable?.borders;return y&&o&&(o&1&&y.t&&!m.t&&(m.t=y.t),o&2&&y.b&&(!m.b||m.b===R)&&(m.b=y.b),o&4&&y.l&&!m.l&&(m.l=y.l),o&8&&y.r&&(!m.r||m.r===w)&&(m.r=y.r)),Object.keys(m).length&&(f.borders=m),f},stripe:e.firstRowStripe?.fill??null,custom:l,header:{},sub:{},grand:{},parent:{},page:{}}}function Te(e,l,i,d){const r=l?.slicerStyles.find(n=>n.name===i),u=l?.find(i);if(!r&&!u)return null;const s={...d},t=O(e,u,"wholeTable"),a=O(e,u,"headerRow");t?.fill&&(s.frameFill=t.fill),t?.color&&(s.ink=t.color);const o=N(t);o&&(s.frameLine=o),a?.color&&(s.captionInk=a.color),a?.fill&&(s.captionFill=a.fill);const f=(n,h,b,m)=>{const c=O(e,r,n,l.slicerDxfs);if(!c)return;c.fill&&(s[h]=c.fill),c.color&&(s[b]=c.color);const R=N(c);R&&m&&(s[m]=R)};return f("selectedItemWithData","selFill","selInk","selLine"),f("unselectedItemWithData","fill","itemInk","itemLine"),f("selectedItemWithNoData","selNoFill","selNoInk"),f("unselectedItemWithNoData","noFill","noInk"),s.hoverSelFill=s.selFill,s.hoverSelInk=s.selInk,s.hoverFill=s.fill,s.hoverInk=s.itemInk,f("hoveredSelectedItemWithData","hoverSelFill","hoverSelInk"),f("hoveredUnselectedItemWithData","hoverFill","hoverInk"),s}function we(e,l,i,d){const r=l?.timelineStyles.find(h=>h.name===i),u=l?.find(i);if(!r&&!u)return null;const s={...d},t=O(e,u,"wholeTable"),a=O(e,u,"headerRow");t?.fill&&(s.frameFill=t.fill);const o=N(t);o&&(s.frameLine=o),a?.color&&(s.captionInk=a.color);const f=(h,b)=>{const m=O(e,r,h,l.timelineDxfs);m?.fill&&(s[b]=m.fill)},n=(h,b)=>{const m=O(e,r,h,l.timelineDxfs);m?.color&&(s[b]=m.color)};return f("selectedTimeBlock","selFill"),f("unselectedTimeBlock","blockFill"),f("selectedTimeBlockSpace","selSpaceFill"),n("selectionLabel","labelInk"),n("timeLevel","levelInk"),n("periodLabel1","periodInk"),n("periodLabel2","subPeriodInk"),s}export{te as CustomStyles,ee as PIVOT_ELEMENTS,me as SLICER_ELEMENTS,Z as TABLE_ELEMENTS,Se as TIMELINE_ELEMENTS,le as addDxf,Re as customPivotPattern,Te as customSlicerColors,ye as customTableColors,we as customTimelineColors,ne as elementPivotPattern,se as elementTableColors,pe as paintCustomTable,he as parseCustomStyles,be as patchCustomStyles};
@@ -1 +1 @@
1
- import{readTableFilter as m}from"../cells/filter-file.js";import{escapeMarkup as d}from"../io/xml-escape.js";import{unescapeXml as b,unescapeXstring as p}from"../io/xml-scan.js";const f=/<tableColumn\b[^>]*?\/>|<tableColumn\b[^>]*>[\s\S]*?<\/tableColumn>/g;function w(o){const l=[],t=[];for(const s of o.matchAll(f)){const e=s[0],a=c=>new RegExp(`\\b${c}="([^"]*)"`).exec(e.slice(0,e.indexOf(">")+1))?.[1];l.push(Number(a("id")));const n=a("totalsRowFunction"),u=a("totalsRowLabel"),r=/<totalsRowFormula\b[^>]*>([\s\S]*?)<\/totalsRowFormula>/.exec(e)?.[1];u!==void 0?t.push({label:p(u)}):n&&n!=="none"?t.push(n==="custom"?{fn:n,formula:r!==void 0?b(r):""}:{fn:n}):t.push(null)}return{ids:l,totals:t}}async function F(o,l){for(const t of l){if(!t.part||!o.has(t.part))continue;const{ids:s,totals:e}=w(await o.text(t.part));s.length===t.columns.length&&(t.columnIds=s),t.totalsRows>0&&!t.totals&&(t.totals=e),R(t,await o.bytes(t.part))}}function R(o,l){if(!o.filter||o.filter.columns.size>0)return;const t=m(l);if(!t||t.columns.size===0)return;o.filter.columns=t.columns,t.buttons&&(o.filter.buttons=t.buttons),t.sortState&&(o.filter.sortState=t.sortState);const{sheet:s}=o;s.filteredRows??=new Set;for(let e=o.r0+o.headerRows;e<=o.r1-o.totalsRows;e++)s.rows.isHidden(e)&&s.filteredRows.add(e)}const $=(o,l)=>{const t=o.totals?.[l];return t?.fn==="custom"&&t.formula?`<totalsRowFormula>${d(t.formula)}</totalsRowFormula>`:""};function S(o,l){let t=0;return o.replace(f,s=>{const e=s.indexOf(">"),a=s[e-1]==="/",n=s.slice(0,a?e-1:e).replace(/\s(?:totalsRowLabel|totalsRowFunction)="[^"]*"/g,"").trimEnd(),u=a?"":s.slice(e+1,s.lastIndexOf("</tableColumn>")).replace(/<totalsRowFormula\b[^>]*>[\s\S]*?<\/totalsRowFormula>|<totalsRowFormula\b[^>]*\/>/,""),r=l.totals[t]??"",c=l.totalsChild?.[t]??"";t++;const i=`${u}${c}`;return i?`${n}${r}>${i}</tableColumn>`:`${n}${r}/>`})}export{F as loadTableDetails,w as parseTableColumns,S as patchTableColumns,$ as totalsChildXml};
1
+ import{readTableFilter as m}from"../cells/filter-file.js";import{escapeMarkup as d}from"../io/xml-escape.js";import{unescapeXml as b,unescapeXstring as p}from"../io/xml-scan.js";const f=/<tableColumn\b[^>]*?\/>|<tableColumn\b[^>]*>[\s\S]*?<\/tableColumn>/g;function w(o){const l=[],t=[];for(const s of o.matchAll(f)){const e=s[0],a=c=>new RegExp(`\\b${c}="([^"]*)"`).exec(e.slice(0,e.indexOf(">")+1))?.[1];l.push(Number(a("id")));const n=a("totalsRowFunction"),u=a("totalsRowLabel"),r=/<totalsRowFormula\b[^>]*>([\s\S]*?)<\/totalsRowFormula>/.exec(e)?.[1];u!==void 0?t.push({label:p(u)}):n&&n!=="none"?t.push(n==="custom"?{fn:n,formula:r!==void 0?b(r):""}:{fn:n}):t.push(null)}return{ids:l,totals:t}}async function F(o,l){for(const t of l){if(!t.part||!o.has(t.part))continue;const{ids:s,totals:e}=w(await o.text(t.part));s.length===t.columns.length&&(t.columnIds=s),!t.totals&&(t.totalsRows>0||e.some(Boolean))&&(t.totals=e),R(t,await o.bytes(t.part))}}function R(o,l){if(!o.filter||o.filter.columns.size>0)return;const t=m(l);if(!t||t.columns.size===0)return;o.filter.columns=t.columns,t.buttons&&(o.filter.buttons=t.buttons),t.sortState&&(o.filter.sortState=t.sortState);const{sheet:s}=o;s.filteredRows??=new Set;for(let e=o.r0+o.headerRows;e<=o.r1-o.totalsRows;e++)s.rows.isHidden(e)&&s.filteredRows.add(e)}const $=(o,l)=>{const t=o.totals?.[l];return t?.fn==="custom"&&t.formula?`<totalsRowFormula>${d(t.formula)}</totalsRowFormula>`:""};function S(o,l){let t=0;return o.replace(f,s=>{const e=s.indexOf(">"),a=s[e-1]==="/",n=s.slice(0,a?e-1:e).replace(/\s(?:totalsRowLabel|totalsRowFunction)="[^"]*"/g,"").trimEnd(),u=a?"":s.slice(e+1,s.lastIndexOf("</tableColumn>")).replace(/<totalsRowFormula\b[^>]*>[\s\S]*?<\/totalsRowFormula>|<totalsRowFormula\b[^>]*\/>/,""),r=l.totals[t]??"",c=l.totalsChild?.[t]??"";t++;const i=`${u}${c}`;return i?`${n}${r}>${i}</tableColumn>`:`${n}${r}/>`})}export{F as loadTableDetails,w as parseTableColumns,S as patchTableColumns,$ as totalsChildXml};
@@ -1 +1 @@
1
- import{Workbook as g}from"../core/workbook.js";import{BOOL as C,ERR as k,NUM as v,STR as b}from"../core/sheet.js";import{Engine as R}from"../calc/engine.js";import{readCsv as S,CsvWriter as B}from"../io/csv.js";import{buildBlock as T,newBlockBuffers as N}from"../io/export-blocks.js";import{buildPlan as O}from"../io/plan.js";import{writeXlsx as $}from"../io/xlsx-write.js";import{MAX_ROWS as z,MAX_COLS as I,colIndex as x}from"../core/address.js";import{display as P}from"./model.js";async function J(u,h={},i){if(/\.(?:csv|tsv|txt)$/i.test(u.name)){const e=new g;let n=0;const l={size:u.size,slice:(...a)=>u.slice(...a),stream:()=>u.stream().pipeThrough(new TransformStream({transform(a,d){n+=a.byteLength,d.enqueue(a)}}))};return await S(l,{onProgress:a=>i?.({records:Math.max(0,a-1),loaded:n,total:u.size}),delimiter:h.delimiter||(/\.tsv$/i.test(u.name)?" ":void 0),textColumns:new Set(h.textColumns),preserveIdentifiers:!0,addString:a=>e.strings.add(a),styleFor:a=>e.styles.derive(0,{numFmt:a}),onBatch:a=>e.sheet.applyBatch(a)}),{book:e,tables:[]}}const{IoClient:o}=await import("../io/client.js"),m=new o;try{const e=i?await X(u):null,n=await m.open(u,{onProgress:({cells:s})=>i?.({records:e?.columns?Math.floor(s/e.columns):null,loaded:s,total:e?.cells??null})}),{tables:l=[],names:a=[],fullCalcOnLoad:d,manualCalc:t}=m.meta;n.engine=new R(n),n.engine.manual=t,n.engine.setNames(a),n.engine.setTables(l.map(s=>({...s,sheet:n.sheets[s.sheetIndex]}))),n.engine.buildGraph({fullCalc:d}),t||await n.engine.whenIdle();const{openZip:r}=await import("../io/zip-reader.js"),c=await r(await m.packageOf(u));if([...c.entries.keys()].some(s=>s.startsWith("customXml/"))){const{DataSheets:s}=await import("../datasheets/manager.js"),p=new s(n);if(await p.load(c))for(const f of p.manager.tables.values())f.autoSync=!1,f.remote=null}return{book:n,tables:l}}finally{m.close()}}async function X(u){try{const{openZip:h}=await import("../io/zip-reader.js"),i=await h(u);let o=0,m=0,e=0;for(const n of i.entries.keys()){if(!/^xl\/worksheets\/[^/]+\.xml$/.test(n))continue;const l=(await i.stream(n)).pipeThrough(new TextDecoderStream).getReader();let a="";for(;a.length<4096&&!/<(?:\w+:)?sheetData/.test(a);){const{done:c,value:s}=await l.read();if(c)break;a+=s}l.cancel().catch(()=>{});const d=a.match(/<(?:\w+:)?dimension\s+ref="\$?([A-Z]+)\$?(\d+)(?::\$?([A-Z]+)\$?(\d+))?"/);if(!d)return null;const t=d[3]?x(d[3])-x(d[1])+1:1,r=d[4]?Number(d[4])-Number(d[2])+1:1;o+=t*r,t*r>e&&(e=t*r,m=t)}return o>1?{cells:o,columns:m}:null}catch{return null}}function q({book:u,tables:h}){const i=[];return u.sheets.forEach((o,m)=>{if(!(o.hidden||o.isChartSheet)){if(o.kindName==="table"){const e=o.view.spec,n=o.table.byName,l=t=>t.filter(r=>n.has(r.field)),a=l(e.columns).map(({field:t,caption:r,hidden:c,pinned:s,format:p})=>({field:t,caption:r,hidden:c,pinned:s,format:p})),d=a.some(t=>!t.hidden)?{columns:a,search:e.search,sort:l(e.sort),filters:l(e.filters),groups:l(e.groups).map(({field:t})=>({field:t})),total:l(e.totals)[0]??null,collapsed:[...o.view.collapsedPaths]}:null;i.push({name:o.name,sheet:m,native:!0,initialState:d,range:{r0:0,c0:0,r1:o.maxRow,c1:o.maxCol}});return}for(const e of h.filter(n=>n.sheetIndex===m))i.push({name:e.name,sheet:m,headers:e.columns,headerRows:e.headerRows,range:{r0:e.r0,c0:e.c0,r1:e.r1-e.totalsRows,c1:e.c1}});o.maxCol>=0&&o.maxRow>=0&&i.push({name:o.name,sheet:m,whole:!0,range:{r0:0,c0:0,r1:o.maxRow,c1:o.maxCol}})}}),i.sort((o,m)=>+!!o.whole-+!!m.whole)}async function G(u,h){const{view:i}=u;i.refresh();const o=i.columns,m=[],e={write:t=>{m.push(new Blob([t]))}};if(h==="csv"){const t=new B(e);await t.batch(o.map((c,s)=>[0,s,c.caption]));let r=[];for(let c=0;c<i.filteredCount;c++)for(let s=0;s<o.length;s++){const p=o[s];r.push([c+1,s,P(p.col.get(i.perm[c]),p.format)]),r.length===2048&&(await t.batch(r),r=[])}return await t.batch(r),await t.finish(i.filteredCount),new Blob(m,{type:"text/csv;charset=utf-8"})}if(!["xlsx","pdf"].includes(h)||i.filteredCount>=z||o.length>I)throw new Error("The result exceeds the XLSX row limit or the format is unsupported.");const n=new g,l=n.sheet;if(l.name="Results",o.forEach((t,r)=>{l.setCell(0,r,b,n.strings.add(t.caption));const c=n.styles.derive(0,{numFmt:t.format});for(let s=0;s<i.filteredCount;s++){const p=i.perm[s],f=t.col.kind(p);if(!f)continue;const w=t.col.get(p),y=f===b?n.strings.add(w):f===C?Number(w):f===k?w.index:w;l.setCell(s+1,r,f,y),c&&f===v&&l.setStyle(s+1,r,c)}}),h==="pdf"){const{createPrintJob:t}=await import("../print/paginate.js"),{writeJobPdf:r}=await import("../print/render-page.js"),c=(await import("../print/page-setup.js")).getPageSetup(l);return c.fitToPage=!0,c.fitToWidth=1,c.fitToHeight=0,await r(t(n,{sheets:[0]}),e,{title:"Results"}),new Blob(m,{type:"application/pdf"})}const a=O(n,{strings:0,styles:0,sheets:0}),d=N();return await $(e,a,{block:(t,r)=>T(l,n.strings,r,d)}),new Blob(m,{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}export{G as exportResults,J as openFile,q as sourcesOf};
1
+ import{Workbook as g}from"../core/workbook.js";import{BOOL as C,ERR as k,NUM as v,STR as b}from"../core/sheet.js";import{Engine as R}from"../calc/engine.js";import{readCsv as S,CsvWriter as B}from"../io/csv.js";import{buildBlock as T,newBlockBuffers as N}from"../io/export-blocks.js";import{buildPlan as O}from"../io/plan.js";import{writeXlsx as $}from"../io/xlsx-write.js";import{MAX_ROWS as z,MAX_COLS as I,colIndex as x}from"../core/address.js";import{display as P}from"./model.js";async function J(u,h={},i){if(/\.(?:csv|tsv|txt)$/i.test(u.name)){const e=new g;let n=0;const l={size:u.size,slice:(...a)=>u.slice(...a),stream:()=>u.stream().pipeThrough(new TransformStream({transform(a,d){n+=a.byteLength,d.enqueue(a)}}))};return await S(l,{onProgress:a=>i?.({records:Math.max(0,a-1),loaded:n,total:u.size}),delimiter:h.delimiter||(/\.tsv$/i.test(u.name)?" ":void 0),textColumns:new Set(h.textColumns),preserveIdentifiers:!0,addString:a=>e.strings.add(a),styleFor:a=>e.styles.derive(0,{numFmt:a}),onBatch:a=>e.sheet.applyBatch(a)}),{book:e,tables:[]}}const{IoClient:o}=await import("../io/client.js"),m=new o;try{const e=i?await X(u):null,n=await m.open(u,{onProgress:({cells:s})=>i?.({records:e?.columns?Math.floor(s/e.columns):null,loaded:s,total:e?.cells??null})}),{tables:l=[],names:a=[],fullCalcOnLoad:d,manualCalc:t}=m.meta;n.engine=new R(n),n.engine.manual=t,n.engine.setNames(a),n.engine.setTables(l.map(s=>({...s,sheet:n.sheets[s.sheetIndex]}))),n.engine.buildGraph({fullCalc:d}),t||await n.engine.whenIdle();const{openZip:r}=await import("../io/zip-reader.js"),c=await r(await m.packageOf(u));if([...c.entries.keys()].some(s=>s.startsWith("customXml/"))){const{DataSheets:s}=await import("../datasheets/manager.js"),p=new s(n);if(await p.load(c))for(const f of p.manager.tables.values())f.autoSync=!1,f.remote=null}return{book:n,tables:l}}finally{m.close()}}async function X(u){try{const{openZip:h}=await import("../io/zip-reader.js"),i=await h(u);let o=0,m=0,e=0;for(const n of i.entries.keys()){if(!/^xl\/worksheets\/[^/]+\.xml$/.test(n))continue;const l=(await i.stream(n)).pipeThrough(new TextDecoderStream).getReader();let a="";for(;a.length<4096&&!/<(?:\w+:)?sheetData/.test(a);){const{done:c,value:s}=await l.read();if(c)break;a+=s}l.cancel().catch(()=>{});const d=a.match(/<(?:\w+:)?dimension\s+ref="\$?([A-Z]+)\$?(\d+)(?::\$?([A-Z]+)\$?(\d+))?"/);if(!d)return null;const t=d[3]?x(d[3])-x(d[1])+1:1,r=d[4]?Number(d[4])-Number(d[2])+1:1;o+=t*r,t*r>e&&(e=t*r,m=t)}return o>1?{cells:o,columns:m}:null}catch{return null}}function q({book:u,tables:h}){const i=[];return u.sheets.forEach((o,m)=>{if(!(o.hidden||o.isChartSheet)){if(o.kindName==="table"){const e=o.view.spec,n=o.table.byName,l=t=>t.filter(r=>n.has(r.field)),a=l(e.columns).map(({field:t,caption:r,hidden:c,pinned:s,format:p})=>({field:t,caption:r,hidden:c,pinned:s,format:p})),d=a.some(t=>!t.hidden)?{columns:a,search:e.search,sort:l(e.sort),filters:l(e.filters),groups:l(e.groups).map(({field:t})=>({field:t})),total:l(e.totals)[0]??null,collapsed:[...o.view.collapsedPaths]}:null;i.push({name:o.name,sheet:m,native:!0,initialState:d,range:{r0:0,c0:0,r1:o.maxRow,c1:o.maxCol}});return}for(const e of h.filter(n=>n.sheetIndex===m))i.push({name:e.name,sheet:m,headers:e.columns,headerRows:e.headerRows,range:{r0:e.r0,c0:e.c0,r1:e.r1-e.totalsRows,c1:e.c1}});o.maxCol>=0&&o.maxRow>=0&&i.push({name:o.name,sheet:m,whole:!0,range:{r0:0,c0:0,r1:o.maxRow,c1:o.maxCol}})}}),i.sort((o,m)=>+!!o.whole-+!!m.whole)}async function G(u,h){const{view:i}=u;i.refresh();const o=i.columns,m=[],e={write:t=>{m.push(new Blob([t]))}};if(h==="csv"){const t=new B(e,",",{bom:!0});await t.batch(o.map((c,s)=>[0,s,c.caption]));let r=[];for(let c=0;c<i.filteredCount;c++)for(let s=0;s<o.length;s++){const p=o[s];r.push([c+1,s,P(p.col.get(i.perm[c]),p.format)]),r.length===2048&&(await t.batch(r),r=[])}return await t.batch(r),await t.finish(i.filteredCount),new Blob(m,{type:"text/csv;charset=utf-8"})}if(!["xlsx","pdf"].includes(h)||i.filteredCount>=z||o.length>I)throw new Error("The result exceeds the XLSX row limit or the format is unsupported.");const n=new g,l=n.sheet;if(l.name="Results",o.forEach((t,r)=>{l.setCell(0,r,b,n.strings.add(t.caption));const c=n.styles.derive(0,{numFmt:t.format});for(let s=0;s<i.filteredCount;s++){const p=i.perm[s],f=t.col.kind(p);if(!f)continue;const w=t.col.get(p),y=f===b?n.strings.add(w):f===C?Number(w):f===k?w.index:w;l.setCell(s+1,r,f,y),c&&f===v&&l.setStyle(s+1,r,c)}}),h==="pdf"){const{createPrintJob:t}=await import("../print/paginate.js"),{writeJobPdf:r}=await import("../print/render-page.js"),c=(await import("../print/page-setup.js")).getPageSetup(l);return c.fitToPage=!0,c.fitToWidth=1,c.fitToHeight=0,await r(t(n,{sheets:[0]}),e,{title:"Results"}),new Blob(m,{type:"application/pdf"})}const a=O(n,{strings:0,styles:0,sheets:0}),d=N();return await $(e,a,{block:(t,r)=>T(l,n.strings,r,d)}),new Blob(m,{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}export{G as exportResults,J as openFile,q as sourcesOf};
@@ -1 +1 @@
1
- const o={"Autosize column":"Dopasuj szerokość","Drag to resize, double-click to fit":"Przeciągnij, aby zmienić szerokość; kliknij dwukrotnie, aby dopasować",Dismiss:"Zamknij podpowiedź","Filter row":"Wiersz filtrów","Clear column filters":"Wyczyść filtry kolumn","Greater than or equal":"Większe lub równe","Less than or equal":"Mniejsze lub równe","Open a row with its arrow to see the order lines. One order opens at a time and scrolls with the records.":"Rozwiń wiersz strzałką, aby zobaczyć pozycje zamówienia. Naraz otwarte jest jedno zamówienie, które przewija się razem z rekordami.","Tick rows, or the header box for every match. Drag across cells and press Ctrl+C to copy them. Export offers the selected rows.":"Zaznacz wiersze lub pole w nagłówku, aby wybrać wszystkie pasujące. Przeciągnij po komórkach i naciśnij Ctrl+C, aby je skopiować. Eksport obejmie zaznaczone wiersze.",Quantity:"Ilość",Price:"Cena",Amount:"Kwota",Total:"Razem","Order lines":"Pozycje zamówienia","Order no.":"Zamówienie nr",Product:"Produkt","Expand details":"Rozwiń szczegóły","Collapse details":"Zwiń szczegóły","Conditional formatting":"Formatowanie warunkowe","Data bar":"Pasek danych","Colour scale":"Skala kolorów","Green fill":"Zielone tło","Red fill":"Czerwone tło","Amber fill":"Bursztynowe tło","Blue fill":"Niebieskie tło","Bold text":"Pogrubiony tekst",Custom:"Własny","No rules":"Brak reguł",Style:"Styl",Rule:"Reguła","Add rule":"Dodaj regułę","Clear rules":"Usuń reguły","Drag a header edge to resize it and double-click to fit, drag a header to move it. Bars, colour scales and the totals row cover every matching record.":"Przeciągnij krawędź nagłówka, aby zmienić szerokość, kliknij dwukrotnie, aby dopasować, przeciągnij nagłówek, aby przenieść kolumnę. Paski, skale kolorów i wiersz sum obejmują wszystkie pasujące rekordy.",Totals:"Sumy","No total":"Bez podsumowania","Select all matching records":"Zaznacz wszystkie pasujące rekordy","Select record":"Zaznacz rekord",selected:"zaznaczonych","All matching selected":"Zaznaczono wszystkie pasujące","All matching selected except":"Zaznaczono wszystkie pasujące oprócz","Clear selection":"Wyczyść zaznaczenie","All matching records":"Wszystkie pasujące rekordy","Selected records":"Zaznaczone rekordy",Records:"Rekordy","Select records to export first.":"Najpierw zaznacz rekordy do eksportu.","This source cannot export selected records.":"To źródło nie eksportuje zaznaczonych rekordów.","Row selection is off for this table.":"Zaznaczanie wierszy jest wyłączone w tej tabeli.","Wait for the records to load.":"Poczekaj na wczytanie rekordów.","Search “East”, open a column menu to sort, filter, group or pin, and select cells to see their sum.":"Wyszukaj „East”, otwórz menu kolumny, aby sortować, filtrować, grupować lub przypinać, i zaznacz komórki, aby zobaczyć ich sumę.","One million orders generated off the main thread. Type “>30” under Units or a name under Customer, sort or group: the work runs in a Worker.":"Milion zamówień wygenerowanych poza wątkiem głównym. Wpisz „>30” pod Units lub nazwę pod Customer, sortuj lub grupuj: obliczenia działają w Workerze.","Rows arrive in blocks of 100 from a simulated server with 150–400 ms latency and an unknown total. Scroll quickly, then sort or search.":"Wiersze przychodzą blokami po 100 z symulowanego serwera z opóźnieniem 150–400 ms i nieznaną liczbą rekordów. Przewiń szybko, potem posortuj lub wyszukaj.","An editable copy: double-click a cell or press Enter to edit, Ctrl+Z to undo. Units must be a whole number from 1 to 500.":"Edytowalna kopia: kliknij komórkę dwukrotnie lub naciśnij Enter, aby edytować, Ctrl+Z cofa. Units musi być liczbą całkowitą od 1 do 500.","The sales records as a pivot by region and product, with its chart. Choose Back to records to return.":"Sprzedaż jako tabela przestawna według regionu i produktu, z wykresem. Wybierz Wróć do rekordów, aby wrócić.","Choose East, West, North or South.":"Wybierz East, West, North lub South.","Units must be a whole number from 1 to 500.":"Units musi być liczbą całkowitą od 1 do 500.","Shift-click to sort by another column":"Shift + kliknięcie dodaje kolumnę do sortowania","Selected cells":"Zaznaczone komórki","System theme":"Motyw systemowy","Light theme":"Motyw jasny","Dark theme":"Motyw ciemny","Custom theme":"Motyw własny",Theme:"Motyw","Column menu":"Menu kolumny","Sort ascending":"Sortuj rosnąco","Sort descending":"Sortuj malejąco","Clear sort":"Usuń sortowanie","Hide column":"Ukryj kolumnę","is one of":"jest jednym z","Clear all":"Wyczyść wszystko",Unpin:"Odepnij",Ungroup:"Usuń grupowanie","The data changed. Reopen the record before editing.":"Dane się zmieniły. Otwórz rekord ponownie przed edycją.",Rows:"Wiersze",Chart:"Wykres",Pivot:"Tabela przestawna","Back to records":"Wróć do rekordów","Top 20 by absolute value":"Pierwsze 20 według wartości bezwzględnej","Choose different row and column fields.":"Wybierz różne pola dla wierszy i kolumn.","Pick values":"Wybierz wartości","No values":"Brak wartości","Back to workbook":"Wróć do arkusza","Read columns as text":"Wczytaj kolumny jako tekst",Delimiter:"Separator",Automatic:"Automatycznie","Reimport CSV":"Wczytaj CSV ponownie","Add record":"Dodaj rekord","Remove record":"Usuń rekord",Width:"Szerokość",Share:"Udostępnij","Share link":"Link do widoku","Copy link":"Kopiuj link","Revoke link":"Unieważnij link","Publish filtered copy":"Opublikuj przefiltrowaną kopię","Prepare file":"Przygotuj plik","This share link has expired or was revoked.":"Link wygasł lub został unieważniony.",Pages:"Strony",Scroll:"Przewijanie","Table view":"Widok tabeli","Open file":"Otwórz plik","Open workbook":"Otwórz arkusz","Sales example":"Przykład sprzedaży","Open a table":"Otwórz tabelę","Choose a CSV or Excel file to explore its records.":"Wybierz plik CSV lub Excel, aby przeglądać rekordy.","Search records":"Szukaj rekordów",Filter:"Filtr",Group:"Grupowanie",Columns:"Kolumny",Views:"Widoki",Export:"Eksport",Sort:"Sortowanie",Apply:"Zastosuj",Cancel:"Anuluj",Close:"Zamknij",Field:"Pole",Condition:"Warunek",Value:"Wartość",Contains:"Zawiera",Equals:"Równa się","Greater than":"Większe niż","Less than":"Mniejsze niż","Is blank":"Puste","Starts with":"Zaczyna się od","Not equal":"Różne od",Between:"Pomiędzy","Second value":"Druga wartość","Is not blank":"Niepuste",Ascending:"Rosnąco",Descending:"Malejąco",Remove:"Usuń","Reset view":"Resetuj widok",None:"Brak",Summary:"Podsumowanie",Sum:"Suma",Average:"Średnia",Minimum:"Minimum",Maximum:"Maksimum",Count:"Liczba",Distinct:"Unikatowe",Visible:"Widoczna",Pin:"Przypnij","Move up":"Przesuń wyżej","Move down":"Przesuń niżej","Save view":"Zapisz widok","View name":"Nazwa widoku",Restore:"Przywróć","Record details":"Szczegóły rekordu",Details:"Szczegóły",Previous:"Poprzednia",Next:"Następna",Page:"Strona",of:"z",records:"rekordów","Export results":"Eksportuj wyniki","No matching records":"Brak pasujących rekordów","Clear filters":"Wyczyść filtry","Loading…":"Wczytywanie…",Opening:"Otwieranie:","Preparing records":"Przygotowywanie rekordów","Loading records":"Wczytywanie rekordów","Building pivot":"Tworzenie tabeli przestawnej","Generating records":"Generowanie rekordów","Records read":"Wczytane rekordy","Cancelling…":"Anulowanie…","Loading cancelled.":"Wczytywanie anulowane.",Loaded:"Wczytano","No data":"Brak danych",Table:"Tabela",Source:"Źródło",Range:"Zakres","First row contains headers":"Nagłówki w pierwszym wierszu","Edit copy":"Edytuj kopię","Editing copy":"Edycja kopii","Save changes":"Zapisz zmiany",Undo:"Cofnij",Redo:"Ponów","Calculated field":"Pole obliczane",Formula:"Formuła",Name:"Nazwa",Add:"Dodaj","Group by":"Grupuj według","Sort by":"Sortuj według","Add group":"Dodaj grupę","Add sort":"Dodaj sortowanie",Order:"Kolejność","Use Tab to separate fields and a new line for each record.":"Rozdziel pola tabulatorem, a rekordy nową linią.","Paste rows":"Wklej wiersze","Starting field":"Pole początkowe","Changes live in this copy until exported.":"Zmiany pozostają w kopii do czasu eksportu.","Choose at least one visible column.":"Wybierz przynajmniej jedną widoczną kolumnę.","No saved views":"Brak zapisanych widoków","Rows per page":"Wierszy na stronę","Choose source":"Wybierz źródło",Format:"Format","Copy row":"Kopiuj wiersz",Copied:"Skopiowano",Download:"Pobierz","Local file":"Plik lokalny","View settings":"Ustawienia widoku","Saved views":"Zapisane widoki","Paste exceeds the available records or columns.":"Wklejane dane wykraczają poza dostępne rekordy lub kolumny.","Editing is disabled for this view.":"Edycja tego widoku jest wyłączona.","Save or discard your local edits before replacing this table. Continue?":"Zastąpienie tabeli odrzuci lokalne zmiany. Kontynuować?","Select a value":"Wybierz wartość","No table loaded":"Nie wczytano tabeli",Filters:"Filtry",Print:"Drukuj","Fill down":"Wypełnij w dół","Number of records":"Liczba rekordów","Original workbook":"Oryginalny skoroszyt",Edit:"Edytuj",Reset:"Resetuj",Saved:"Zapisano","Choose a range inside the source.":"Wybierz zakres w obrębie źródła.","Choose an unused column name and a formula.":"Wpisz nieużywaną nazwę kolumny oraz formułę.","This view is read-only.":"Widok tylko do odczytu.","This file contains no visible data.":"Plik nie zawiera widocznych danych.","This field is read-only.":"Pole tylko do odczytu.","Field unavailable.":"Pole jest niedostępne.","Record unavailable.":"Rekord jest niedostępny.","Invalid column.":"Nieprawidłowa kolumna.","This source is read-only.":"To źródło jest tylko do odczytu.","This field or record is read-only.":"To pole lub rekord jest tylko do odczytu.","Use the record editor for this source.":"W tym źródle zmieniaj dane w szczegółach rekordu.","The selection changed. Open Table view again.":"Zaznaczenie się zmieniło. Otwórz widok tabeli ponownie.","The result exceeds the XLSX row limit or the format is unsupported.":"Wynik przekracza limit wierszy XLSX albo ten format nie jest obsługiwany.","The pivot exceeds the worksheet dimensions.":"Tabela przestawna nie mieści się w arkuszu.","File sharing is unavailable on this device.":"Udostępnianie plików nie działa na tym urządzeniu.","Allow opening the workbook in a new tab.":"Zezwól na otwarcie arkusza w nowej karcie.","The example could not be opened.":"Nie udało się otworzyć przykładu.","Invalid snapshot address.":"Nieprawidłowy adres kopii.","Invalid table response.":"Nieprawidłowa odpowiedź źródła tabeli.","Table view closed.":"Widok tabeli został zamknięty."},r=o,i=a=>e=>a?.startsWith("pl")?o[e]??e:e;export{r as PL,i as translator};
1
+ const o={"Autosize column":"Dopasuj szerokość","Drag to resize, double-click to fit":"Przeciągnij, aby zmienić szerokość; kliknij dwukrotnie, aby dopasować",Dismiss:"Zamknij podpowiedź","Filter row":"Wiersz filtrów","Clear column filters":"Wyczyść filtry kolumn","Greater than or equal":"Większe lub równe","Less than or equal":"Mniejsze lub równe","Open a row with its arrow to see the order lines. One order opens at a time and scrolls with the records.":"Rozwiń wiersz strzałką, aby zobaczyć pozycje zamówienia. Naraz otwarte jest jedno zamówienie, które przewija się razem z rekordami.","Tick rows, or the header box for every match. Drag across cells and press Ctrl+C to copy them. Export offers the selected rows.":"Zaznacz wiersze lub pole w nagłówku, aby wybrać wszystkie pasujące. Przeciągnij po komórkach i naciśnij Ctrl+C, aby je skopiować. Eksport obejmie zaznaczone wiersze.",Quantity:"Ilość",Price:"Cena",Amount:"Kwota",Total:"Razem","Order lines":"Pozycje zamówienia","Order no.":"Zamówienie nr",Product:"Produkt","Expand details":"Rozwiń szczegóły","Collapse details":"Zwiń szczegóły","Conditional formatting":"Formatowanie warunkowe","Data bar":"Pasek danych","Colour scale":"Skala kolorów","Green fill":"Zielone tło","Red fill":"Czerwone tło","Amber fill":"Bursztynowe tło","Blue fill":"Niebieskie tło","Bold text":"Pogrubiony tekst",Custom:"Własny","No rules":"Brak reguł",Style:"Styl",Rule:"Reguła","Add rule":"Dodaj regułę","Clear rules":"Usuń reguły","Drag a header edge to resize it and double-click to fit, drag a header to move it. Bars, colour scales and the totals row cover every matching record.":"Przeciągnij krawędź nagłówka, aby zmienić szerokość, kliknij dwukrotnie, aby dopasować, przeciągnij nagłówek, aby przenieść kolumnę. Paski, skale kolorów i wiersz sum obejmują wszystkie pasujące rekordy.",Totals:"Sumy","No total":"Bez podsumowania","Select all matching records":"Zaznacz wszystkie pasujące rekordy","Select record":"Zaznacz rekord",selected:"zaznaczonych","All matching selected":"Zaznaczono wszystkie pasujące","All matching selected except":"Zaznaczono wszystkie pasujące oprócz","Clear selection":"Wyczyść zaznaczenie","All matching records":"Wszystkie pasujące rekordy","Selected records":"Zaznaczone rekordy",Records:"Rekordy","Select records to export first.":"Najpierw zaznacz rekordy do eksportu.","This source cannot export selected records.":"To źródło nie eksportuje zaznaczonych rekordów.","Row selection is off for this table.":"Zaznaczanie wierszy jest wyłączone w tej tabeli.","Wait for the records to load.":"Poczekaj na wczytanie rekordów.","Search “East”, open a column menu to sort, filter, group or pin, and select cells to see their sum.":"Wyszukaj „East”, otwórz menu kolumny, aby sortować, filtrować, grupować lub przypinać, i zaznacz komórki, aby zobaczyć ich sumę.","One million orders generated off the main thread. Type “>30” under Units or a name under Customer, sort or group: the work runs in a Worker.":"Milion zamówień wygenerowanych poza wątkiem głównym. Wpisz „>30” pod Units lub nazwę pod Customer, sortuj lub grupuj: obliczenia działają w Workerze.","Rows arrive in blocks of 100 from a simulated server with 150–400 ms latency and an unknown total. Scroll quickly, then sort or search.":"Wiersze przychodzą blokami po 100 z symulowanego serwera z opóźnieniem 150–400 ms i nieznaną liczbą rekordów. Przewiń szybko, potem posortuj lub wyszukaj.","An editable copy: double-click a cell or press Enter to edit, Ctrl+Z to undo. Units must be a whole number from 1 to 500.":"Edytowalna kopia: kliknij komórkę dwukrotnie lub naciśnij Enter, aby edytować, Ctrl+Z cofa. Units musi być liczbą całkowitą od 1 do 500.","The sales records as a pivot by region and product, with its chart. Choose Back to records to return.":"Sprzedaż jako tabela przestawna według regionu i produktu, z wykresem. Wybierz Wróć do rekordów, aby wrócić.","Choose East, West, North or South.":"Wybierz East, West, North lub South.","Units must be a whole number from 1 to 500.":"Units musi być liczbą całkowitą od 1 do 500.","Shift-click to sort by another column":"Shift + kliknięcie dodaje kolumnę do sortowania","Selected cells":"Zaznaczone komórki","System theme":"Motyw systemowy","Light theme":"Motyw jasny","Dark theme":"Motyw ciemny","Custom theme":"Motyw własny",Theme:"Motyw","Column menu":"Menu kolumny","Sort ascending":"Sortuj rosnąco","Sort descending":"Sortuj malejąco","Clear sort":"Usuń sortowanie","Hide column":"Ukryj kolumnę","is one of":"jest jednym z","Clear all":"Wyczyść wszystko",Unpin:"Odepnij",Ungroup:"Usuń grupowanie","The data changed. Reopen the record before editing.":"Dane się zmieniły. Otwórz rekord ponownie przed edycją.",Rows:"Wiersze",Chart:"Wykres",Pivot:"Tabela przestawna","Back to records":"Wróć do rekordów","Top 20 by absolute value":"Pierwsze 20 według wartości bezwzględnej","Choose different row and column fields.":"Wybierz różne pola dla wierszy i kolumn.","Pick values":"Wybierz wartości","No values":"Brak wartości","Back to workbook":"Wróć do arkusza","Read columns as text":"Wczytaj kolumny jako tekst",Delimiter:"Separator",Automatic:"Automatycznie","Reimport CSV":"Wczytaj CSV ponownie","Add record":"Dodaj rekord","Remove record":"Usuń rekord",Width:"Szerokość",Share:"Udostępnij","Share link":"Link do widoku","Copy link":"Kopiuj link","Revoke link":"Unieważnij link","Publish filtered copy":"Opublikuj przefiltrowaną kopię","Prepare file":"Przygotuj plik","This share link has expired or was revoked.":"Link wygasł lub został unieważniony.",Pages:"Strony",Scroll:"Przewijanie","Table view":"Widok tabeli","Open file":"Otwórz plik","Open workbook":"Otwórz arkusz","Sales example":"Przykład sprzedaży","Open a table":"Otwórz tabelę","Choose a CSV or Excel file to explore its records.":"Wybierz plik CSV lub Excel, aby przeglądać rekordy.","Search records":"Szukaj rekordów",Filter:"Filtr",Group:"Grupowanie",Columns:"Kolumny",Views:"Widoki",Export:"Eksport",Sort:"Sortowanie",Apply:"Zastosuj",Cancel:"Anuluj",Close:"Zamknij",Field:"Pole",Condition:"Warunek",Value:"Wartość",Contains:"Zawiera",Equals:"Równa się","Greater than":"Większe niż","Less than":"Mniejsze niż","Is blank":"Puste","Starts with":"Zaczyna się od","Not equal":"Różne od",Between:"Pomiędzy","Second value":"Druga wartość","Is not blank":"Niepuste",Ascending:"Rosnąco",Descending:"Malejąco",Remove:"Usuń","Reset view":"Resetuj widok",None:"Brak",Summary:"Podsumowanie",Sum:"Suma",Average:"Średnia",Minimum:"Minimum",Maximum:"Maksimum",Count:"Liczba",Distinct:"Unikatowe",Visible:"Widoczna",Pin:"Przypnij","Move up":"Przesuń wyżej","Move down":"Przesuń niżej","Save view":"Zapisz widok","View name":"Nazwa widoku",Restore:"Przywróć","Record details":"Szczegóły rekordu",Details:"Szczegóły",Previous:"Poprzednia",Next:"Następna",Page:"Strona",of:"z",records:"rekordów","Export results":"Eksportuj wyniki","No matching records":"Brak pasujących rekordów","Clear filters":"Wyczyść filtry","Loading…":"Wczytywanie…","A new version of 8sheets is ready.":"Nowa wersja 8sheets jest gotowa.",Reload:"Wczytaj ponownie",Later:"Później","Reload and lose your unsaved edits?":"Wczytać ponownie i utracić niezapisane zmiany?","8sheets was updated in another tab. Save your work, then reload to use the new version.":"Aplikacja 8sheets została zaktualizowana w innej karcie. Zapisz pracę, a potem wczytaj stronę ponownie, aby użyć nowej wersji.",Opening:"Otwieranie:","Preparing records":"Przygotowywanie rekordów","Loading records":"Wczytywanie rekordów","Building pivot":"Tworzenie tabeli przestawnej","Generating records":"Generowanie rekordów","Records read":"Wczytane rekordy","Cancelling…":"Anulowanie…","Loading cancelled.":"Wczytywanie anulowane.",Loaded:"Wczytano","No data":"Brak danych",Table:"Tabela",Source:"Źródło",Range:"Zakres","First row contains headers":"Nagłówki w pierwszym wierszu","Edit copy":"Edytuj kopię","Editing copy":"Edycja kopii","Save changes":"Zapisz zmiany",Undo:"Cofnij",Redo:"Ponów","Calculated field":"Pole obliczane",Formula:"Formuła",Name:"Nazwa",Add:"Dodaj","Group by":"Grupuj według","Sort by":"Sortuj według","Add group":"Dodaj grupę","Add sort":"Dodaj sortowanie",Order:"Kolejność","Use Tab to separate fields and a new line for each record.":"Rozdziel pola tabulatorem, a rekordy nową linią.","Paste rows":"Wklej wiersze","Starting field":"Pole początkowe","Changes live in this copy until exported.":"Zmiany pozostają w kopii do czasu eksportu.","Choose at least one visible column.":"Wybierz przynajmniej jedną widoczną kolumnę.","No saved views":"Brak zapisanych widoków","Rows per page":"Wierszy na stronę","Choose source":"Wybierz źródło",Format:"Format","Copy row":"Kopiuj wiersz",Copied:"Skopiowano",Download:"Pobierz","Local file":"Plik lokalny","View settings":"Ustawienia widoku","Saved views":"Zapisane widoki","Paste exceeds the available records or columns.":"Wklejane dane wykraczają poza dostępne rekordy lub kolumny.","Editing is disabled for this view.":"Edycja tego widoku jest wyłączona.","Save or discard your local edits before replacing this table. Continue?":"Zastąpienie tabeli odrzuci lokalne zmiany. Kontynuować?","Select a value":"Wybierz wartość","No table loaded":"Nie wczytano tabeli",Filters:"Filtry",Print:"Drukuj","Fill down":"Wypełnij w dół","Number of records":"Liczba rekordów","Original workbook":"Oryginalny skoroszyt",Edit:"Edytuj",Reset:"Resetuj",Saved:"Zapisano","Choose a range inside the source.":"Wybierz zakres w obrębie źródła.","Choose an unused column name and a formula.":"Wpisz nieużywaną nazwę kolumny oraz formułę.","This view is read-only.":"Widok tylko do odczytu.","This file contains no visible data.":"Plik nie zawiera widocznych danych.","This field is read-only.":"Pole tylko do odczytu.","Field unavailable.":"Pole jest niedostępne.","Record unavailable.":"Rekord jest niedostępny.","Invalid column.":"Nieprawidłowa kolumna.","This source is read-only.":"To źródło jest tylko do odczytu.","This field or record is read-only.":"To pole lub rekord jest tylko do odczytu.","Use the record editor for this source.":"W tym źródle zmieniaj dane w szczegółach rekordu.","The selection changed. Open Table view again.":"Zaznaczenie się zmieniło. Otwórz widok tabeli ponownie.","The result exceeds the XLSX row limit or the format is unsupported.":"Wynik przekracza limit wierszy XLSX albo ten format nie jest obsługiwany.","The pivot exceeds the worksheet dimensions.":"Tabela przestawna nie mieści się w arkuszu.","File sharing is unavailable on this device.":"Udostępnianie plików nie działa na tym urządzeniu.","Allow opening the workbook in a new tab.":"Zezwól na otwarcie arkusza w nowej karcie.","The example could not be opened.":"Nie udało się otworzyć przykładu.","Invalid snapshot address.":"Nieprawidłowy adres kopii.","Invalid table response.":"Nieprawidłowa odpowiedź źródła tabeli.","Table view closed.":"Widok tabeli został zamknięty."},r=o,i=a=>e=>a?.startsWith("pl")?o[e]??e:e;export{r as PL,i as translator};
@@ -1 +1 @@
1
- const o="1.0.0";export{o as VERSION};
1
+ const o="1.0.1";export{o as VERSION};
@@ -1 +1 @@
1
- import{allows as w,hashPassword as b,hasPassword as g,rangesEditable as m,SHEET_OPTIONS as v,structureLocked as y,verifyPassword as C,withoutPassword as E}from"../core/protection.js";import{el as c,openModal as p}from"./dialogs.js";import{t as l,tc as W}from"../i18n/index.js";const K=new Set(["entry","edit","clear","paste","paste-special","fill","replace","goal-seek"]),S={format:"formatCells",borders:"formatCells",merge:"formatCells","format-rule":"formatCells",sort:"sort",pivot:"pivotTables","clear-pivot":"pivotTables",scenario:"scenarios"};function k(e,t="The cell or chart you're trying to change is on a protected sheet. To make a change, unprotect the sheet."){p(e,"Protected",c("p",{textContent:l(t)}),[{label:"OK",primary:!0}],{width:380})}function _(e){return t=>{const{book:n,grid:s}=e,r=n.sheet,i=n.guardHint;if(n.guardHint=null,r.isChartSheet&&i?.option!=="objects")return!1;if(!r.protection||t==="outline"&&r.protectionExtras?.outline)return!0;let o;return i?.option?o=w(r,i.option)&&(!i.ranges||m(n,r,i.ranges)):K.has(t)?o=m(n,r,i?.ranges??s.selection.ranges):S[t]?o=w(r,S[t]):o=!1,o||k(e),o}}function j(e,t){return w(e.book.sheet,t)?!0:(k(e),!1)}function F(e){return y(e.book)?(k(e,"The workbook is protected, so sheets can't be added, moved, renamed, hidden or deleted."),!1):!0}function P(e){const t=c("input",{class:"dlg-input",type:"password",autocomplete:"new-password","aria-label":l(e)}),n=c("input",{class:"dlg-input",type:"password",autocomplete:"new-password","aria-label":l("Confirm password")}),s=c("div",{class:"dlg-error",role:"alert"});return{first:t,second:n,error:s,nodes:[c("label",{class:"dlg-row"},`${l(e)} `,t),c("label",{class:"dlg-row"},`${l("Confirm password:")} `,n),s],check(){return t.value!==n.value?(s.textContent=l("The passwords don't match."),!1):!0}}}function x(e,t,n,s){const r=c("input",{class:"dlg-input",type:"password",autocomplete:"current-password","aria-label":l("Password")}),i=c("div",{class:"dlg-error",role:"alert"});p(e,t,c("div",{},c("label",{class:"dlg-row"},`${l("Password:")} `,r),i),[{label:"Cancel"},{label:"OK",primary:!0,action:()=>{const o=r.value;return n(o).then(u=>{u&&s()}),!0}}],{width:340}),r.focus()}function f(e){e.book.dirty=!0,e.grid.invalidate(),e.ribbon.render(),e.shell.syncTitle()}function L(e){const{book:t,shell:n}=e,s=t.sheet;if(s.protection){const o=()=>{s.protection=null,s.protectionChanged=!0,n.setStatus("Sheet unprotected."),f(e)};if(!g(s.protection)){o();return}x(e,"Unprotect Sheet",async u=>{const d=await C(s.protection,u);return d||n.setStatus("The password you supplied is not correct."),d},o);return}const r=P("Password to unprotect (optional):"),i=v.map(([o,u,d])=>{const a=c("input",{type:"checkbox",checked:d});return{key:o,input:a,node:c("label",{class:"dlg-row dlg-check"},a,` ${W("protect",u)}`)}});p(e,"Protect Sheet",c("div",{},...r.nodes,c("div",{class:"dlg-label",textContent:l("Allow all users of this worksheet to:")}),c("div",{class:"dlg-scroll"},...i.map(o=>o.node))),[{label:"Cancel"},{label:"OK",primary:!0,action:()=>{if(!r.check())return!1;const o={sheet:"1"};for(const[a,,T]of v){const h=i.find(O=>O.key===a).input.checked;a==="objects"||a==="scenarios"||T?h||(o[a]="1"):h&&(o[a]="0")}const u=r.first.value,d=a=>{s.protection={...a,...o},s.protectionChanged=!0,n.setStatus("Sheet protected."),f(e)};return u?b(u).then(d):d({}),!0}}],{width:400}),r.first.focus()}function N(e){const{book:t,shell:n}=e;if(y(t)){const r=()=>{t.protection=null,t.protectionChanged=!0,n.setStatus("Workbook unprotected."),f(e)};if(!g(t.protection,"workbook")){r();return}x(e,"Unprotect Workbook",async i=>{const o=await C(t.protection,i,"workbook");return o||n.setStatus("The password you supplied is not correct."),o},r);return}const s=P("Password (optional):");p(e,"Protect Workbook",c("div",{},c("p",{textContent:l("Protects the structure: sheets can't be added, moved, renamed, hidden or deleted.")}),...s.nodes),[{label:"Cancel"},{label:"OK",primary:!0,action:()=>{if(!s.check())return!1;const r=o=>{t.protection={...E(t.protection??{}),...o,lockStructure:"1"},t.protectionChanged=!0,n.setStatus("Workbook protected."),f(e)},i=s.first.value;return i?b(i,"workbook").then(r):r({}),!0}}],{width:380}),s.first.focus()}export{j as guardOption,F as guardStructure,L as openProtectSheet,N as openProtectWorkbook,_ as protectionGuard,k as showBlocked};
1
+ import{allows as w,hashPassword as b,hasPassword as g,rangesEditable as m,SHEET_OPTIONS as v,structureLocked as y,verifyPassword as C,withoutPassword as E}from"../core/protection.js";import{el as c,openModal as p}from"./dialogs.js";import{t as l,tc as W}from"../i18n/index.js";const K=new Set(["entry","edit","clear","paste","paste-special","fill","replace","goal-seek","convert-number"]),S={format:"formatCells",borders:"formatCells",merge:"formatCells","format-rule":"formatCells",sort:"sort",filter:"autoFilter",pivot:"pivotTables","clear-pivot":"pivotTables",scenario:"scenarios"};function k(e,t="The cell or chart you're trying to change is on a protected sheet. To make a change, unprotect the sheet."){p(e,"Protected",c("p",{textContent:l(t)}),[{label:"OK",primary:!0}],{width:380})}function I(e){return t=>{const{book:n,grid:s}=e,r=n.sheet,i=n.guardHint;if(n.guardHint=null,r.isChartSheet&&i?.option!=="objects")return!1;if(!r.protection||t==="outline"&&r.protectionExtras?.outline)return!0;let o;return i?.option?o=w(r,i.option)&&(!i.ranges||m(n,r,i.ranges)):K.has(t)?o=m(n,r,i?.ranges??s.selection.ranges):S[t]?o=w(r,S[t]):o=!1,o||k(e),o}}function _(e,t){return w(e.book.sheet,t)?!0:(k(e),!1)}function j(e){return y(e.book)?(k(e,"The workbook is protected, so sheets can't be added, moved, renamed, hidden or deleted."),!1):!0}function P(e){const t=c("input",{class:"dlg-input",type:"password",autocomplete:"new-password","aria-label":l(e)}),n=c("input",{class:"dlg-input",type:"password",autocomplete:"new-password","aria-label":l("Confirm password")}),s=c("div",{class:"dlg-error",role:"alert"});return{first:t,second:n,error:s,nodes:[c("label",{class:"dlg-row"},`${l(e)} `,t),c("label",{class:"dlg-row"},`${l("Confirm password:")} `,n),s],check(){return t.value!==n.value?(s.textContent=l("The passwords don't match."),!1):!0}}}function x(e,t,n,s){const r=c("input",{class:"dlg-input",type:"password",autocomplete:"current-password","aria-label":l("Password")}),i=c("div",{class:"dlg-error",role:"alert"});p(e,t,c("div",{},c("label",{class:"dlg-row"},`${l("Password:")} `,r),i),[{label:"Cancel"},{label:"OK",primary:!0,action:()=>{const o=r.value;return n(o).then(u=>{u&&s()}),!0}}],{width:340}),r.focus()}function f(e){e.book.dirty=!0,e.grid.invalidate(),e.ribbon.render(),e.shell.syncTitle()}function L(e){const{book:t,shell:n}=e,s=t.sheet;if(s.protection){const o=()=>{s.protection=null,s.protectionChanged=!0,n.setStatus("Sheet unprotected."),f(e)};if(!g(s.protection)){o();return}x(e,"Unprotect Sheet",async u=>{const d=await C(s.protection,u);return d||n.setStatus("The password you supplied is not correct."),d},o);return}const r=P("Password to unprotect (optional):"),i=v.map(([o,u,d])=>{const a=c("input",{type:"checkbox",checked:d});return{key:o,input:a,node:c("label",{class:"dlg-row dlg-check"},a,` ${W("protect",u)}`)}});p(e,"Protect Sheet",c("div",{},...r.nodes,c("div",{class:"dlg-label",textContent:l("Allow all users of this worksheet to:")}),c("div",{class:"dlg-scroll"},...i.map(o=>o.node))),[{label:"Cancel"},{label:"OK",primary:!0,action:()=>{if(!r.check())return!1;const o={sheet:"1"};for(const[a,,T]of v){const h=i.find(O=>O.key===a).input.checked;a==="objects"||a==="scenarios"||T?h||(o[a]="1"):h&&(o[a]="0")}const u=r.first.value,d=a=>{s.protection={...a,...o},s.protectionChanged=!0,n.setStatus("Sheet protected."),f(e)};return u?b(u).then(d):d({}),!0}}],{width:400}),r.first.focus()}function N(e){const{book:t,shell:n}=e;if(y(t)){const r=()=>{t.protection=null,t.protectionChanged=!0,n.setStatus("Workbook unprotected."),f(e)};if(!g(t.protection,"workbook")){r();return}x(e,"Unprotect Workbook",async i=>{const o=await C(t.protection,i,"workbook");return o||n.setStatus("The password you supplied is not correct."),o},r);return}const s=P("Password (optional):");p(e,"Protect Workbook",c("div",{},c("p",{textContent:l("Protects the structure: sheets can't be added, moved, renamed, hidden or deleted.")}),...s.nodes),[{label:"Cancel"},{label:"OK",primary:!0,action:()=>{if(!s.check())return!1;const r=o=>{t.protection={...E(t.protection??{}),...o,lockStructure:"1"},t.protectionChanged=!0,n.setStatus("Workbook protected."),f(e)},i=s.first.value;return i?b(i,"workbook").then(r):r({}),!0}}],{width:380}),s.first.focus()}export{_ as guardOption,j as guardStructure,L as openProtectSheet,N as openProtectWorkbook,I as protectionGuard,k as showBlocked};