efficient-office 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Slides-JI73C3NW.js → Slides-LJW5C24V.js} +1 -1
- package/dist/SlidesEditor-ETCUQVJ7.js +1 -0
- package/dist/Spreadsheet-I5XA7TU7.js +1 -0
- package/dist/{chunk-B6JN7D6G.js → chunk-3KJZFUBH.js} +1 -1
- package/dist/{chunk-N26CBJZA.js → chunk-4M3QRYCH.js} +1 -1
- package/dist/{chunk-GLT7O6TV.js → chunk-4MGZXE3N.js} +1 -1
- package/dist/chunk-MZJSGEU3.js +1 -0
- package/dist/chunk-UDEPDAZI.js +1 -0
- package/dist/importSpreadsheet-ZXS3RSKE.js +1 -0
- package/dist/slides/index.js +1 -1
- package/dist/slides/slides.css +0 -1
- package/dist/spreadsheet/index.d.ts +4 -1
- package/dist/spreadsheet/index.js +1 -1
- package/dist/{workbookPdf-C5SSN226.js → workbookPdf-63WIOPEC.js} +1 -1
- package/dist/xlsxFile-GYMIRUWG.js +1 -0
- package/package.json +1 -1
- package/dist/SlidesEditor-5WCXE27J.js +0 -1
- package/dist/Spreadsheet-I3RO4HSS.js +0 -1
- package/dist/chunk-7K7AY3V3.js +0 -1
- package/dist/chunk-VKCG3LPQ.js +0 -1
- package/dist/importSpreadsheet-4U3KEJ76.js +0 -1
- package/dist/xlsxFile-B2JCZCOL.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=1048576,n=16384;function e(t){let n=t+1,e="";for(;n>0;){const t=(n-1)%26;e=String.fromCharCode(65+t)+e,n=Math.floor((n-1)/26)}return e}function r(t){let n=0;for(const e of t.toUpperCase())n=26*n+(e.charCodeAt(0)-64);return n-1}function o(t,n){return`${e(n)}${t+1}`}function s(t,n){return{r1:Math.min(t.row,n.row),c1:Math.min(t.col,n.col),r2:Math.max(t.row,n.row),c2:Math.max(t.col,n.col)}}function c(t){const n=o(t.r1,t.c1);return t.r1===t.r2&&t.c1===t.c2?n:`${n}:${o(t.r2,t.c2)}`}function u(t,n,e){return n>=t.r1&&n<=t.r2&&e>=t.c1&&e<=t.c2}function l(t,n){return t.r1<=n.r2&&t.r2>=n.r1&&t.c1<=n.c2&&t.c2>=n.c1}function i(t){const n=/^\$?([A-Za-z]{1,3})\$?(\d{1,7})(?::\$?([A-Za-z]{1,3})\$?(\d{1,7}))?$/.exec(t.trim());if(!n)return null;const e={row:Number(n[2])-1,col:r(n[1])},o=n[3]?{row:Number(n[4])-1,col:r(n[3])}:e;return e.row<0||o.row<0?null:s(e,o)}var a=class extends Error{},f=String.raw`(\$?)([A-Za-z]{1,3})(\$?)(\d{1,7})`,h=new RegExp(`^${f}(?::${f})?(?![A-Za-z0-9_.(])`),m=/^(\$?)([A-Za-z]{1,3}):(\$?)([A-Za-z]{1,3})(?![A-Za-z0-9_.(])/,g=/^(\$?)(\d{1,7}):(\$?)(\d{1,7})(?![A-Za-z0-9_.(])/,p=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/,d=/^[A-Za-z_][A-Za-z0-9_.]*/,w=/^#(?:REF!|N\/A|NAME\?|DIV\/0!|VALUE!|NUM!|NULL!)/i,M=/^(?:'((?:[^']|'')+)'|([A-Za-z_][A-Za-z0-9_.]*))!/;function b(t,n,e,o){return{col:r(n),row:Number(o)-1,colAbs:"$"===t,rowAbs:"$"===e}}function y(e){let o=null,s=0;const c=M.exec(e);c&&(o=void 0!==c[1]?c[1].replace(/''/g,"'"):c[2],s=c[0].length);const u=e.slice(s),l=h.exec(u);if(l){const e=b(l[1],l[2],l[3],l[4]);if(e.row<0||e.row>=t||e.col>=n)return null;const r=l[6]?b(l[5],l[6],l[7],l[8]):null;return r&&(r.row<0||r.row>=t||r.col>=n)?null:{ref:{sheet:o,a:e,b:r},length:s+l[0].length}}const i=m.exec(u);if(i){return{ref:{sheet:o,a:{col:r(i[2]),row:null,colAbs:"$"===i[1],rowAbs:!1},b:{col:r(i[4]),row:null,colAbs:"$"===i[3],rowAbs:!1}},length:s+i[0].length}}const a=g.exec(u);if(a&&Number(a[2])>0&&Number(a[4])>0){return{ref:{sheet:o,a:{col:null,row:Number(a[2])-1,colAbs:!1,rowAbs:"$"===a[1]},b:{col:null,row:Number(a[4])-1,colAbs:!1,rowAbs:"$"===a[3]}},length:s+a[0].length}}return null}var A=["<=",">=","<>","+","-","*","/","^","&","=","<",">","%","(",")",",",";"];function E(t){const n=[];let e=0;for(;e<t.length;){const r=t[e];if(/\s/.test(r)){e++;continue}const o=t.slice(e);if('"'===r){let r=e+1,o="",s=!1;for(;r<t.length;){if('"'===t[r]){if('"'===t[r+1]){o+='"',r+=2;continue}s=!0,r++;break}o+=t[r++]}if(!s)return{tokens:n,complete:!1};n.push({type:"string",value:o,start:e,end:r}),e=r;continue}if("#"===r){const t=w.exec(o);if(!t)return{tokens:n,complete:!1};n.push({type:"error",value:t[0].toUpperCase(),start:e,end:e+t[0].length}),e+=t[0].length;continue}const s=y(o);if(s){n.push({type:"ref",ref:s.ref,start:e,end:e+s.length}),e+=s.length;continue}const c=p.exec(o);if(c){n.push({type:"number",value:Number(c[0]),start:e,end:e+c[0].length}),e+=c[0].length;continue}const u=d.exec(o);if(u){n.push({type:"ident",value:u[0],start:e,end:e+u[0].length}),e+=u[0].length;continue}const l=A.find(t=>o.startsWith(t));if(!l)return{tokens:n,complete:!1};n.push({type:"op",value:l,start:e,end:e+l.length}),e+=l.length}return{tokens:n,complete:!0}}var N={"=":1,"<>":1,"<":1,">":1,"<=":1,">=":1,"&":2,"+":3,"-":3,"*":4,"/":4,"^":6},v=class{constructor(t){this.tokens=t}tokens;pos=0;peek(){return this.tokens[this.pos]}isOp(t){const n=this.peek();return"op"===n?.type&&n.value===t}run(){const t=this.expression(0);if(this.pos<this.tokens.length)throw new a("Unexpected text");return t}expression(t){let n=this.prefix();for(;;){const e=this.peek();if("op"!==e?.type)break;if("%"===e.value){this.pos++,n={kind:"percent",arg:n};continue}const r=N[e.value];if(void 0===r||r<=t)break;this.pos++,n={kind:"binary",op:e.value,left:n,right:this.expression(r)}}return n}prefix(){const t=this.peek();if(!t)throw new a("Formula ends early");switch(this.pos++,t.type){case"number":return{kind:"num",value:t.value};case"string":return{kind:"str",value:t.value};case"error":return{kind:"err",value:t.value};case"ref":return{kind:"ref",ref:t.ref};case"ident":{if(this.isOp("("))return this.call(t.value);const n=t.value.toUpperCase();return"TRUE"===n?{kind:"bool",value:!0}:"FALSE"===n?{kind:"bool",value:!1}:{kind:"err",value:"#NAME?"}}case"op":if("-"===t.value||"+"===t.value)return{kind:"unary",op:t.value,arg:this.expression(7)};if("("===t.value){const t=this.expression(0);if(!this.isOp(")"))throw new a("Missing )");return this.pos++,t}throw new a(`Unexpected ${t.value}`)}}call(t){this.pos++;const n=[];if(this.isOp(")"))return this.pos++,{kind:"call",name:t.toUpperCase(),args:n};for(;;){if(this.isOp(",")||this.isOp(";")||this.isOp(")")?n.push({kind:"empty"}):n.push(this.expression(0)),!this.isOp(",")&&!this.isOp(";")){if(this.isOp(")"))return this.pos++,{kind:"call",name:t.toUpperCase(),args:n};throw new a("Missing )")}this.pos++}}},C=new Map;function x(t){return t.length>1&&"="===t[0]}function $(t){return(null===t.col?"":`${t.colAbs?"$":""}${e(t.col)}`)+(null===t.row?"":`${t.rowAbs?"$":""}${t.row+1}`)}function R(t){return(null===(n=t.sheet)?"":/^[A-Za-z_][A-Za-z0-9_.]*$/.test(n)&&!h.test(n)?`${n}!`:`'${n.replace(/'/g,"''")}'!`)+$(t.a)+(t.b?`:${$(t.b)}`:"");var n}function T(t,n){if(!x(t))return t;const e=t.slice(1),{tokens:r}=E(e);let o="",s=0;for(const t of r){if("ref"!==t.type)continue;const r=n(t.ref);o+=e.slice(s,t.start)+(r?R(r):"#REF!"),s=t.end}return`=${o}${e.slice(s)}`}function S(e,r,o){const s=e=>{const s=null===e.row||e.rowAbs?e.row:e.row+r,c=null===e.col||e.colAbs?e.col:e.col+o;return null!==s&&(s<0||s>=t)||null!==c&&(c<0||c>=n)?null:{...e,row:s,col:c}};return T(e,t=>{const n=s(t.a),e=t.b?s(t.b):null;return!n||t.b&&!e?null:{...t,a:n,b:e}})}function O(t){return t.colAbs||t.rowAbs?t.colAbs&&t.rowAbs?{...t,colAbs:!1,rowAbs:!0}:!t.colAbs&&t.rowAbs?{...t,colAbs:!0,rowAbs:!1}:{...t,colAbs:!1,rowAbs:!1}:{...t,colAbs:!0,rowAbs:!0}}var U=t=>String(t).padStart(2,"0"),I={general:"General",number:"#,##0.00",percent:"0.00%",currency:'"$"#,##0.00',scientific:"0.00E+00",date:"yyyy-mm-dd",time:"h:mm:ss AM/PM",dateTime:"yyyy-mm-dd h:mm",text:"@"},D=864e5,L=Date.UTC(1899,11,30);function F(t,n,e){return Math.round((Date.UTC(t,n-1,e)-L)/D)}function k(t){const n=Math.floor(t),e=new Date(L+n*D),r=Math.round(86400*(t-n));return{year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),weekday:e.getUTCDay(),hours:Math.floor(r/3600)%24,minutes:Math.floor(r/60)%60,seconds:r%60}}var P=/\[(black|blue|cyan|green|magenta|red|white|yellow|color\s*\d+)\]/i;function V(t){const n=[];let e="",r=!1;for(let o=0;o<t.length;o++){const s=t[o];"\\"!==s?('"'===s&&(r=!r),";"!==s||r?e+=s:(n.push(e),e="")):e+=s+(t[++o]??"")}return n.push(e),n}function G(t){return t.replace(/\\./g,"").replace(/"[^"]*"/g,"").replace(/\[[^\]]*\]/g,"")}function z(t){return!(!t||"General"===t||"@"===t)&&/[ymdhs]/i.test(G(V(t)[0]).replace(/E\+/gi,""))}var W=["January","February","March","April","May","June","July","August","September","October","November","December"],H=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function j(t,n){const e=k(n),r=/AM\/PM|A\/P/i.test(G(t)),o=t.match(/"[^"]*"|\\.|\[[^\]]*\]|AM\/PM|A\/P|y+|m+|d+|h+|s+|./gi)??[];let s="";return o.forEach((t,n)=>{if('"'===t[0])s+=t.slice(1,-1);else if("\\"===t[0])s+=t.slice(1);else if("["===t[0])s+="";else if(/^AM\/PM$/i.test(t))s+=e.hours<12?"AM":"PM";else if(/^A\/P$/i.test(t))s+=e.hours<12?"A":"P";else if(/^y+$/i.test(t))s+=t.length<=2?U(e.year%100):String(e.year);else if(/^m+$/i.test(t))t.length<=2&&(t=>{for(let n=t-1;n>=0;n--){if(/^h+$/i.test(o[n]))return!0;if(/^[ymds]+$/i.test(o[n]))break}for(let n=t+1;n<o.length;n++){if(/^s+$/i.test(o[n]))return!0;if(/^[ymdh]+$/i.test(o[n]))break}return!1})(n)?s+=2===t.length?U(e.minutes):String(e.minutes):1===t.length?s+=String(e.month):2===t.length?s+=U(e.month):3===t.length?s+=W[e.month-1].slice(0,3):s+=W[e.month-1];else if(/^d+$/i.test(t))1===t.length?s+=String(e.day):2===t.length?s+=U(e.day):3===t.length?s+=H[e.weekday].slice(0,3):s+=H[e.weekday];else if(/^h+$/i.test(t)){const n=r?e.hours%12||12:e.hours;s+=2===t.length?U(n):String(n)}else/^s+$/i.test(t)?s+=2===t.length?U(e.seconds):String(e.seconds):s+=t}),s}function X(t,n){const e=/[eE]([+-])(0+|\?+|#+)$/.exec(t);if(e){const r=(t.slice(0,e.index).split(".")[1]??"").length,[o,s]=n.toExponential(r).split("e"),c=Number(s);return`${o}E${c<0?"-":"+"===e[1]?"+":""}${String(Math.abs(c)).padStart(e[2].length,"0")}`}const[r,o=""]=t.split("."),s=/,+$/.exec(r)?.[0].length??0,c=/[#0?],[#0?]/.test(r),u=(r.match(/0/g)??[]).length,l=o.replace(/[^#0?]/g,"").length,i=(o.match(/0/g)??[]).length,a=n/1e3**s,f=Math.abs(a).toFixed(Math.min(l,20));let[h,m=""]=f.split(".");for(;m.length>i&&m.endsWith("0");)m=m.slice(0,-1);return"0"===h&&0===u&&(h=""),h=h.padStart(u,"0"),c&&(h=h.replace(/\B(?=(\d{3})+(?!\d))/g,",")),m?`${h}.${m}`:(o.includes("."),h)}function Z(t){if(!Number.isFinite(t))return String(t);if(0===t)return"0";const n=Math.abs(t);if(n>=1e11||n<1e-9){const[n,e]=t.toExponential(5).split("e"),r=Number(e);return`${n.replace(/\.?0+$/,"")}E${r<0?"-":"+"}${U(Math.abs(r))}`}return String(Number(t.toPrecision(10)))}var _={black:"#000000",blue:"#0000ff",cyan:"#00ffff",green:"#00a650",magenta:"#ff00ff",red:"#ff0000",white:"#ffffff",yellow:"#ffff00"};function K(t,n){if(!n||"General"===n||"@"===n)return{text:Z(t),color:null};const e=V(n);let r=e[0],o=!1;t<0&&e.length>1?(r=e[1],o=!0):0===t&&e.length>2&&(r=e[2]);const s=P.exec(r),c=s?_[s[1].toLowerCase()]??null:null;if(/general/i.test(G(r)))return{text:r.replace(/\[[^\]]*\]/g,"").replace(/general/i,Z(o?-t:t)),color:c};if(z(r))return t<0?{text:Z(t),color:c}:{text:j(r,t),color:c};const u=o?Math.abs(t):t,l=function(t,n){const e=t.match(/"[^"]*"|\\.|\[[^\]]*\]|_.|\*.|[#0?][#0?,.]*(?:[eE][+-][0?#]+)?%?|%|./g)??[],r=n*100**(G(t).match(/%/g)??[]).length;let o="",s=!1;for(const t of e)if('"'===t[0])o+=t.slice(1,-1);else if("\\"===t[0])o+=t.slice(1);else if("["===t[0]){const n=/^\[\$([^-\]]*)/.exec(t);n&&(o+=n[1])}else if("_"===t[0])o+=" ";else if("*"===t[0])o+="";else if(/^[#0?]/.test(t)){const n=t.endsWith("%"),e=n?t.slice(0,-1):t;s||(o+=X(e,r),s=!0),n&&(o+="%")}else o+=t;return s?o:`${o}`}(r,Math.abs(u)),i=!/[1-9]/.test(l);return{text:!o&&t<0&&!i?`-${l}`:l,color:c}}function B(t,n){if(!n||"General"===n||"@"===n)return t;const e=V(n),r=e.length>=4?e[3]:e[0];return r.includes("@")?r.replace(/"([^"]*)"/g,"$1").replace(/\\(.)/g,"$1").replace(/@/g,t):t}function Y(t,n,e){let r=t;if(!r||"General"===r){const t=null===e?0:Math.min(9,(String(e).split(".")[1]??"").length);r=t>0?`0.${"0".repeat(t)}`:"0"}return"@"===r||z(r)?r:V(r).map(t=>{const e=t.match(/"[^"]*"|\\.|\[[^\]]*\]|./g)??[];let r=-1,o=-1;return e.forEach((t,n)=>{"."===t&&-1===o&&(o=n),"0"!==t&&"#"!==t&&"?"!==t||(r=n)}),-1===r?t:(1===n?-1===o?e.splice(r+1,0,".","0"):e.splice(r+1,0,"0"):-1!==o&&(r-o===1?e.splice(o,2):e.splice(r,1)),e.join(""))}).join(";")}var Q=/^(-?)\s*([$€£¥])\s*(-?)\s*([\d,]*\.?\d+)$/,J=/^[+-]?(?:\d{1,3}(?:,\d{3})+|\d+)?(?:\.\d+)?(?:[eE][+-]?\d+)?$/,q=/^[+-]?0\d/,tt=/^[+-]?\d{16,}$/,nt=/^(\d{4})-(\d{1,2})-(\d{1,2})$/,et=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})$/;function rt(){try{const t=new Intl.DateTimeFormat(void 0).formatToParts(new Date(2e3,11,31));return t.findIndex(t=>"day"===t.type)<t.findIndex(t=>"month"===t.type)}catch{return!0}}function ot(t,n,e){if(n<1||n>12||e<1||e>31)return!1;const r=new Date(Date.UTC(t,n-1,e));return r.getUTCMonth()===n-1&&r.getUTCDate()===e}function st(t){const n=t.trim();if(!n||q.test(n)||tt.test(n))return null;const e=Q.exec(n);if(e){const t=Number(e[4].replace(/,/g,""));if(Number.isNaN(t))return null;return{value:"-"===e[1]||"-"===e[3]?-t:t,kind:"currency",format:`"${e[2]}"#,##0${e[4].includes(".")?".00":""}`}}if(n.endsWith("%")){const t=n.slice(0,-1).trim();if(!t||!J.test(t))return null;return{value:Number(t.replace(/,/g,""))/100,kind:"percent",format:t.includes(".")?"0.00%":"0%"}}if(/\d/.test(n)&&J.test(n))return{value:Number(n.replace(/,/g,"")),kind:"number",format:n.includes(",")?n.includes(".")?"#,##0.00":"#,##0":null};const r=nt.exec(n);if(r&&ot(Number(r[1]),Number(r[2]),Number(r[3])))return{value:F(Number(r[1]),Number(r[2]),Number(r[3])),kind:"date",format:I.date};const o=et.exec(n);if(o){const t=Number(o[1]),n=Number(o[2]),e=2===o[3].length?2e3+Number(o[3]):Number(o[3]),[r,s]=rt()?[t,n]:[n,t];if(ot(e,s,r))return{value:F(e,s,r),kind:"date",format:rt()?"dd/mm/yyyy":"mm/dd/yyyy"}}return null}var ct=class{constructor(t){this.code=t}code;toString(){return this.code}},ut=t=>"object"==typeof t&&null!==t&&!(t instanceof ct),lt=t=>new ct(t),it=lt("#VALUE!"),at=lt("#DIV/0!"),ft=lt("#NUM!"),ht=lt("#N/A"),mt=lt("#REF!"),gt=lt("#NAME?"),pt=lt("#CIRC!"),dt=lt("#ERROR!"),wt=/^-?(?:0|[1-9]\d{0,14})(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function Mt(t){if(""===t)return null;if("'"===t[0])return t.slice(1);if(wt.test(t))return Number(t);const n=t.toUpperCase();return"TRUE"===n||"FALSE"!==n&&t}function bt(t){return ut(t)?0===t.rows||0===t.cols?null:t.at(0,0):t}function yt(t){if(null===t)return 0;if("number"==typeof t)return t;if("boolean"==typeof t)return t?1:0;if(t instanceof ct)return t;if(""===t.trim())return it;const n=st(t);return n?n.value:it}function At(t){return null===t?"":"number"==typeof t?Z(t):"boolean"==typeof t?t?"TRUE":"FALSE":t instanceof ct?t.code:t}function Et(t){if(null===t)return!1;if("boolean"==typeof t)return t;if("number"==typeof t)return 0!==t;if(t instanceof ct)return t;const n=t.toUpperCase();return"TRUE"===n||"FALSE"!==n&&it}function Nt(t,n){const e=t=>"number"==typeof t?0:"string"==typeof t?1:"boolean"==typeof t?2:3,r=null===t?"string"==typeof n?"":"boolean"!=typeof n&&0:t,o=null===n?"string"==typeof t?"":"boolean"!=typeof t&&0:n,s=e(r),c=e(o);if(s!==c)return s-c;if("number"==typeof r)return r-o;if("string"==typeof r){const t=r.toLowerCase(),n=o.toLowerCase();return t<n?-1:t>n?1:0}return"boolean"==typeof r?Number(r)-Number(o):0}function vt(t,n,e){if(n instanceof ct)return n;if(e instanceof ct)return e;switch(t){case"&":return At(n)+At(e);case"=":return 0===Nt(n,e);case"<>":return 0!==Nt(n,e);case"<":return Nt(n,e)<0;case">":return Nt(n,e)>0;case"<=":return Nt(n,e)<=0;case">=":return Nt(n,e)>=0}const r=yt(n),o=yt(e);if(r instanceof ct)return r;if(o instanceof ct)return o;switch(t){case"+":return r+o;case"-":return r-o;case"*":return r*o;case"/":return 0===o?at:r/o;case"^":{const t=r**o;return Number.isFinite(t)?t:ft}}return it}function Ct(t,n,e){return{rows:t,cols:n,at:e}}function xt(t,n,e){if(!ut(t)&&!ut(n))return e(t,n);const r=Math.max(ut(t)?t.rows:1,ut(n)?n.rows:1),o=Math.max(ut(t)?t.cols:1,ut(n)?n.cols:1),s=(t,n,e)=>{if(!ut(t))return t;const r=1===t.rows?0:n,o=1===t.cols?0:e;return r<t.rows&&o<t.cols?t.at(r,o):ht};return Ct(r,o,(r,o)=>e(s(t,r,o),s(n,r,o)))}function $t(t,n){if(ut(t))for(let e=0;e<t.rows;e++)for(let r=0;r<t.cols;r++)n(t.at(e,r),!0);else n(t,!1)}function Rt(t){const n=[];let e=null;for(const r of t)$t(r,(t,r)=>{if(e)return;if(t instanceof ct)return void(e=t);if("number"==typeof t)return void n.push(t);if(r||null===t)return;const o=yt(t);o instanceof ct?e=o:n.push(o)});return e??n}function Tt(t){return t.replace(/[.+^${}()|[\]\\]/g,"\\$&")}function St(t){let n="";for(let e=0;e<t.length;e++){const r=t[e];"~"===r&&e+1<t.length?n+=Tt(t[++e]):n+="*"===r?"[\\s\\S]*":"?"===r?"[\\s\\S]":Tt(r)}return new RegExp(`^${n}$`,"i")}var Ot=(t,n)=>{if(void 0===t)return n??it;const e=bt(t);return null===e&&void 0!==n?n:yt(e)},Ut=t=>{if(void 0===t)return it;const n=bt(t);return n instanceof ct?n:At(n)},It=t=>n=>{const e=Ot(n[0]);if(e instanceof ct)return e;const r=t(e);return Number.isFinite(r)?r:ft},Dt=t=>n=>{const e=Rt(n);return e instanceof ct?e:t(e)};var Lt=t=>n=>{const e=Ot(n[0]),r=Ot(n[1],0);if(e instanceof ct)return e;if(r instanceof ct)return r;return(e<0?-1:1)*function(t,n,e){const r=10**n;return e(Number((t*r).toPrecision(15)))/r}(Math.abs(e),Math.trunc(r),t)};function Ft(t,n){const e=t.length;if(e<(n?2:1))return at;const r=t.reduce((t,n)=>t+n,0)/e;return t.reduce((t,n)=>t+(n-r)**2,0)/(n?e-1:e)}function kt(t){return ut(t)?t:Ct(1,1,()=>t)}function Pt(t,n){const e=n??t[0][0];for(const[n]of t)if(n.rows!==e.rows||n.cols!==e.cols)return it;const r=t.map(([,t])=>function(t){if("string"!=typeof t)return n=>null===t?null===n:null!==n&&0===Nt(n,t);const n=/^(<=|>=|<>|=|<|>)?([\s\S]*)$/.exec(t),e=n[1]??"=",r=n[2],o=st(r);if(o){const t=o.value;return n=>{const r="number"==typeof n;switch(e){case"=":return r&&n===t;case"<>":return!(r&&n===t);case"<":return r&&n<t;case">":return r&&n>t;case"<=":return r&&n<=t;default:return r&&n>=t}}}if("="===e||"<>"===e){if(""===r)return t=>"="===e?null===t||""===t:null!==t&&""!==t;const t=St(r);return n=>{const r=null!==n&&!(n instanceof ct)&&t.test(At(n));return"="===e?r:!r}}return t=>{if("string"!=typeof t)return!1;const n=Nt(t,r);return"<"===e?n<0:">"===e?n>0:"<="===e?n<=0:n>=0}}(t)),o=[];for(let n=0;n<e.rows;n++)for(let s=0;s<e.cols;s++)t.every(([t],e)=>r[e](t.at(n,s)))&&o.push(e.at(n,s));return o}function Vt(t){let n=0;for(const e of t){if(e instanceof ct)return e;"number"==typeof e&&(n+=e)}return n}function Gt(t){let n=0,e=0;for(const r of t){if(r instanceof ct)return r;"number"==typeof r&&(n+=r,e++)}return e?n/e:at}function zt(t,n){if((t.length-n)%2!=0||t.length-n<2)return it;const e=[];for(let r=n;r<t.length;r+=2){const n=bt(t[r+1]);if(n instanceof ct)return n;e.push([kt(t[r]),n])}return e}function Wt(t,n,e,r=!1){const o=Math.max(n.rows,n.cols),s=t=>n.rows>=n.cols?n.at(t,0):n.at(0,t);if(0===e){const n=r&&"string"==typeof t?St(t):null;for(let e=0;e<o;e++){const r=s(e);if(n?"string"==typeof r&&n.test(r):null!==r&&!(r instanceof ct)&&0===Nt(r,t))return e}return-1}let c=-1;for(let n=0;n<o;n++){const r=s(n);if(null===r||r instanceof ct||typeof r!=typeof t)continue;const o=Nt(r,t);(1===e?o<=0:o>=0)&&(-1===c||(1===e?Nt(r,s(c))>0:Nt(r,s(c))<0))&&(c=n)}return c}function Ht(t,n){const e=bt(t[0]);if(e instanceof ct)return e;if(void 0===t[1])return it;const r=kt(t[1]),o=Ot(t[2]);if(o instanceof ct)return o;const s=void 0===t[3]||null===t[3]||Et(bt(t[3]));if(s instanceof ct)return s;const c=Math.trunc(o)-1,u=n?r.cols:r.rows,l=n?r.rows:r.cols;if(c<0)return it;if(c>=l)return mt;const i=Wt(e,n?Ct(1,u,(t,n)=>r.at(0,n)):Ct(u,1,t=>r.at(t,0)),s?1:0,!s);return-1===i?ht:n?r.at(c,i):r.at(i,c)}function jt(){const t=new Date;return F(t.getFullYear(),t.getMonth()+1,t.getDate())+(3600*t.getHours()+60*t.getMinutes()+t.getSeconds())/86400}var Xt=t=>n=>{const e=Ot(n[0]);return e instanceof ct?e:e<0?ft:t(k(e))};function Zt(t,n){const e=k(t),r=12*e.year+(e.month-1)+n;return{year:Math.floor(r/12),month:(r%12+12)%12+1,day:e.day}}function _t(t,n){return new Date(Date.UTC(t,n,0)).getUTCDate()}function Kt(t){const n=k(t).weekday;return 0===n||6===n}var Bt=(t,n)=>{const e=[];for(let r=0;r<n.length;r++){const o=Ot(t[r],n[r]);if(o instanceof ct)return o;e.push(o)}return e};function Yt(t,n){if(!t.length||n<0||n>1)return ft;const e=[...t].sort((t,n)=>t-n),r=n*(e.length-1),o=Math.floor(r);return o+1<e.length?e[o]+(r-o)*(e[o+1]-e[o]):e[o]}var Qt=t=>n=>{const e=zt(n,1);if(e instanceof ct)return e;const r=Pt(e,kt(n[0]));if(r instanceof ct)return r;const o=[];for(const t of r){if(t instanceof ct)return t;"number"==typeof t&&o.push(t)}return o.length?t(o):0},Jt=t=>{if(void 0===t)return it;const n=bt(t);return n instanceof ct?n:null===n?"":"string"==typeof n?n:it};function qt(t,n){let e=n?"g":"",r=t;const o=/^\(\?([ims]+)\)/.exec(r);if(o){for(const t of new Set(o[1]))e+=t;r=r.slice(o[0].length)}try{return new RegExp(r,e)}catch{return it}}function tn(t,n){const e=bt(t[0]??null);if("boolean"==typeof e)return it;const r=yt(e);return r instanceof ct?r:Math.abs(Math.trunc(r))%2===n}var nn=["AVERAGE","COUNT","COUNTA","MAX","MIN","PRODUCT","STDEV","STDEVP","SUM","VAR","VARP"],en=/^=\s*SUBTOTAL\s*\(/i,rn={SUM:Dt(t=>t.reduce((t,n)=>t+n,0)),AVERAGE:Dt(t=>t.length?t.reduce((t,n)=>t+n,0)/t.length:at),MIN:Dt(t=>t.length?Math.min(...t):0),MAX:Dt(t=>t.length?Math.max(...t):0),PRODUCT:Dt(t=>t.length?t.reduce((t,n)=>t*n,1):0),MEDIAN:Dt(t=>{if(!t.length)return ft;const n=[...t].sort((t,n)=>t-n),e=Math.floor(n.length/2);return n.length%2?n[e]:(n[e-1]+n[e])/2}),MODE:Dt(t=>{const n=new Map;let e=null,r=1;for(const o of t){const t=(n.get(o)??0)+1;n.set(o,t),t>r&&(r=t,e=o)}return e??ht}),STDEV:Dt(t=>{const n=Ft(t,!0);return n instanceof ct?n:Math.sqrt(n)}),STDEVP:Dt(t=>{const n=Ft(t,!1);return n instanceof ct?n:Math.sqrt(n)}),VAR:Dt(t=>Ft(t,!0)),VARP:Dt(t=>Ft(t,!1)),COUNT:t=>{let n=0;for(const e of t)$t(e,(t,e)=>{"number"==typeof t?n++:e||"boolean"!=typeof t?!e&&"string"==typeof t&&st(t)&&n++:n++});return n},COUNTA:t=>{let n=0;for(const e of t)$t(e,t=>{null!==t&&n++});return n},COUNTBLANK:t=>{let n=0;for(const e of t)$t(e,t=>{null!==t&&""!==t||n++});return n},ABS:It(Math.abs),INT:It(Math.floor),TRUNC:Lt(Math.floor),ROUND:Lt(Math.round),ROUNDUP:Lt(Math.ceil),ROUNDDOWN:Lt(Math.floor),SIGN:It(Math.sign),SQRT:It(Math.sqrt),EXP:It(Math.exp),LN:It(Math.log),LOG10:It(Math.log10),SIN:It(Math.sin),COS:It(Math.cos),TAN:It(Math.tan),LOG:t=>{const n=Ot(t[0]),e=Ot(t[1],10);if(n instanceof ct)return n;if(e instanceof ct)return e;const r=Math.log(n)/Math.log(e);return Number.isFinite(r)?r:ft},MOD:t=>{const n=Ot(t[0]),e=Ot(t[1]);return n instanceof ct?n:e instanceof ct?e:0===e?at:n-e*Math.floor(n/e)},POWER:t=>vt("^",bt(t[0]??null),bt(t[1]??null)),PI:()=>Math.PI,RAND:()=>Math.random(),RANDBETWEEN:t=>{const n=Ot(t[0]),e=Ot(t[1]);if(n instanceof ct)return n;if(e instanceof ct)return e;const r=Math.ceil(n),o=Math.floor(e);return r>o?ft:r+Math.floor(Math.random()*(o-r+1))},CEILING:t=>{const n=Ot(t[0]),e=Ot(t[1],1);return n instanceof ct?n:e instanceof ct?e:0===e?0:Math.ceil(Number((n/e).toPrecision(15)))*e},FLOOR:t=>{const n=Ot(t[0]),e=Ot(t[1],1);return n instanceof ct?n:e instanceof ct?e:0===e?at:Math.floor(Number((n/e).toPrecision(15)))*e},MROUND:t=>{const n=Ot(t[0]),e=Ot(t[1]);return n instanceof ct?n:e instanceof ct?e:0===e||0===n?0:Math.sign(n)!==Math.sign(e)?ft:Math.sign(n)*Math.round(Number(Math.abs(n/e).toPrecision(15)))*Math.abs(e)},QUOTIENT:t=>{const n=Ot(t[0]),e=Ot(t[1]);return n instanceof ct?n:e instanceof ct?e:0===e?at:Math.trunc(n/e)},SUMIF:t=>{const n=bt(t[1]??null);if(n instanceof ct)return n;const e=Pt([[kt(t[0]),n]],void 0!==t[2]?kt(t[2]):null);return e instanceof ct?e:Vt(e)},SUMIFS:t=>{const n=zt(t,1);if(n instanceof ct)return n;const e=Pt(n,kt(t[0]));return e instanceof ct?e:Vt(e)},AVERAGEIF:t=>{const n=bt(t[1]??null);if(n instanceof ct)return n;const e=Pt([[kt(t[0]),n]],void 0!==t[2]?kt(t[2]):null);return e instanceof ct?e:Gt(e)},AVERAGEIFS:t=>{const n=zt(t,1);if(n instanceof ct)return n;const e=Pt(n,kt(t[0]));return e instanceof ct?e:Gt(e)},COUNTIF:t=>{const n=bt(t[1]??null);if(n instanceof ct)return n;const e=Pt([[kt(t[0]),n]],null);return e instanceof ct?e:e.length},COUNTIFS:t=>{const n=zt(t,0);if(n instanceof ct)return n;const e=Pt(n,null);return e instanceof ct?e:e.length},MAXIFS:Qt(t=>Math.max(...t)),MINIFS:Qt(t=>Math.min(...t)),SUBTOTAL:(t,n)=>{const e=Ot(t[0]);if(e instanceof ct)return e;const r=Math.trunc(e),o=nn[(r>100?r-100:r)-1];if(!o||r>11&&r<101)return it;const s=t.slice(1).map(t=>{if(!ut(t)||!t.raw)return t;const n=t.raw.bind(t);return Ct(t.rows,t.cols,(e,r)=>en.test(n(e,r))?null:t.at(e,r))});return s.length?rn[o](s,n):it},SUMPRODUCT:t=>{if(!t.length)return it;const n=t.map(kt),{rows:e,cols:r}=n[0];if(n.some(t=>t.rows!==e||t.cols!==r))return it;let o=0;for(let t=0;t<e;t++)for(let e=0;e<r;e++){let r=1;for(const o of n){const s=o.at(t,e);if(s instanceof ct)return s;r*="number"==typeof s?s:"boolean"==typeof s&&1===n.length?Number(s):0}o+=r}return o},LARGE:t=>{const n=Rt([t[0]??null]),e=Ot(t[1]);if(n instanceof ct)return n;if(e instanceof ct)return e;const r=[...n].sort((t,n)=>n-t);return e<1||e>r.length?ft:r[Math.trunc(e)-1]},SMALL:t=>{const n=Rt([t[0]??null]),e=Ot(t[1]);if(n instanceof ct)return n;if(e instanceof ct)return e;const r=[...n].sort((t,n)=>t-n);return e<1||e>r.length?ft:r[Math.trunc(e)-1]},RANK:t=>{const n=Ot(t[0]),e=Rt([t[1]??null]),r=Ot(t[2],0);return n instanceof ct?n:e instanceof ct?e:r instanceof ct?r:e.includes(n)?1+e.filter(t=>r?t<n:t>n).length:ht},PERCENTILE:t=>{const n=Rt([t[0]??null]),e=Ot(t[1]);return n instanceof ct?n:e instanceof ct?e:Yt(n,e)},QUARTILE:t=>{const n=Rt([t[0]??null]),e=Ot(t[1]);if(n instanceof ct)return n;if(e instanceof ct)return e;const r=Math.trunc(e);return r<0||r>4?ft:Yt(n,r/4)},AND:t=>{let n=!1,e=!0,r=null;for(const o of t)$t(o,(t,o)=>{if(r)return;if(o&&"string"==typeof t)return;if(null===t)return;const s=Et(t);s instanceof ct?r=s:(n=!0,s||(e=!1))});return r??(n?e:it)},OR:t=>{let n=!1,e=!1,r=null;for(const o of t)$t(o,(t,o)=>{if(r)return;if(o&&"string"==typeof t)return;if(null===t)return;const s=Et(t);s instanceof ct?r=s:(n=!0,s&&(e=!0))});return r??(n?e:it)},XOR:t=>{let n=!1,e=null;for(const r of t)$t(r,t=>{if(e||null===t)return;const r=Et(t);r instanceof ct?e=r:r&&(n=!n)});return e??n},NOT:t=>{const n=Et(bt(t[0]??null));return n instanceof ct?n:!n},TRUE:()=>!0,FALSE:()=>!1,CONCAT:t=>{let n="",e=null;for(const r of t)$t(r,t=>{t instanceof ct?e??=t:n+=At(t)});return e??n},TEXTJOIN:t=>{const n=Ut(t[0]),e=Et(bt(t[1]??null));if(n instanceof ct)return n;if(e instanceof ct)return e;const r=[];let o=null;for(const n of t.slice(2))$t(n,t=>{if(t instanceof ct)return void(o??=t);const n=At(t);e&&""===n||r.push(n)});return o??r.join(n)},LEFT:t=>{const n=Ut(t[0]),e=Ot(t[1],1);return n instanceof ct?n:e instanceof ct?e:e<0?it:n.slice(0,Math.trunc(e))},RIGHT:t=>{const n=Ut(t[0]),e=Ot(t[1],1);return n instanceof ct?n:e instanceof ct?e:e<0?it:0===Math.trunc(e)?"":n.slice(-Math.trunc(e))},MID:t=>{const n=Ut(t[0]),e=Ot(t[1]),r=Ot(t[2]);return n instanceof ct?n:e instanceof ct?e:r instanceof ct?r:e<1||r<0?it:n.slice(Math.trunc(e)-1,Math.trunc(e)-1+Math.trunc(r))},LEN:t=>{const n=Ut(t[0]);return n instanceof ct?n:n.length},LOWER:t=>{const n=Ut(t[0]);return n instanceof ct?n:n.toLowerCase()},UPPER:t=>{const n=Ut(t[0]);return n instanceof ct?n:n.toUpperCase()},PROPER:t=>{const n=Ut(t[0]);return n instanceof ct?n:n.toLowerCase().replace(/(^|[^\p{L}])(\p{L})/gu,(t,n,e)=>n+e.toUpperCase())},TRIM:t=>{const n=Ut(t[0]);return n instanceof ct?n:n.trim().replace(/ +/g," ")},REPT:t=>{const n=Ut(t[0]),e=Ot(t[1]);return n instanceof ct?n:e instanceof ct?e:e<0||n.length*e>32767?it:n.repeat(Math.trunc(e))},EXACT:t=>{const n=Ut(t[0]),e=Ut(t[1]);return n instanceof ct?n:e instanceof ct?e:n===e},SUBSTITUTE:t=>{const n=Ut(t[0]),e=Ut(t[1]),r=Ut(t[2]);if(n instanceof ct)return n;if(e instanceof ct)return e;if(r instanceof ct)return r;if(""===e)return n;if(void 0===t[3])return n.split(e).join(r);const o=Ot(t[3]);if(o instanceof ct)return o;let s=-1;for(let t=0;t<o;t++)if(s=n.indexOf(e,s+1),-1===s)return n;return n.slice(0,s)+r+n.slice(s+e.length)},REPLACE:t=>{const n=Ut(t[0]),e=Ot(t[1]),r=Ot(t[2]),o=Ut(t[3]);return n instanceof ct?n:e instanceof ct?e:r instanceof ct?r:o instanceof ct?o:e<1||r<0?it:n.slice(0,e-1)+o+n.slice(e-1+r)},FIND:t=>{const n=Ut(t[0]),e=Ut(t[1]),r=Ot(t[2],1);if(n instanceof ct)return n;if(e instanceof ct)return e;if(r instanceof ct)return r;const o=e.indexOf(n,r-1);return-1===o?it:o+1},SEARCH:t=>{const n=Ut(t[0]),e=Ut(t[1]),r=Ot(t[2],1);if(n instanceof ct)return n;if(e instanceof ct)return e;if(r instanceof ct)return r;const o=new RegExp(St(n).source.slice(1,-1),"i").exec(e.slice(r-1));return o?o.index+r:it},TEXT:t=>{const n=bt(t[0]??null),e=Ut(t[1]);if(n instanceof ct)return n;if(e instanceof ct)return e;const r="string"==typeof n?st(n)?.value??null:null===n?0:"boolean"==typeof n?null:n;return null===r?B(At(n),e):K(r,e).text},VALUE:t=>{const n=bt(t[0]??null);return n instanceof ct||"number"==typeof n?n:st(At(n))?.value??it},CHAR:t=>{const n=Ot(t[0]);if(n instanceof ct)return n;const e=Math.trunc(n);return e<1||e>1114111||e>=55296&&e<=57343?it:String.fromCodePoint(e)},CODE:t=>{const n=Ut(t[0]);return n instanceof ct?n:""===n?it:n.codePointAt(0)},CLEAN:t=>{const n=Ut(t[0]);return n instanceof ct?n:n.replace(/[\x00-\x1f]/g,"")},REGEXMATCH:t=>{const n=Jt(t[0]),e=Jt(t[1]);if(n instanceof ct)return n;if(e instanceof ct)return e;const r=qt(e,!1);return r instanceof ct?r:r.test(n)},REGEXEXTRACT:t=>{const n=Jt(t[0]),e=Jt(t[1]);if(n instanceof ct)return n;if(e instanceof ct)return e;const r=qt(e,!1);if(r instanceof ct)return r;const o=r.exec(n);if(!o)return ht;if(1===o.length)return o[0];const s=o.slice(1).map(t=>t??"");return 1===s.length?s[0]:Ct(1,s.length,(t,n)=>s[n])},REGEXREPLACE:t=>{const n=Jt(t[0]),e=Jt(t[1]),r=Jt(t[2]);if(n instanceof ct)return n;if(e instanceof ct)return e;if(r instanceof ct)return r;const o=qt(e,!0);return o instanceof ct?o:n.replace(o,r)},VLOOKUP:t=>Ht(t,!1),HLOOKUP:t=>Ht(t,!0),XLOOKUP:t=>{const n=bt(t[0]??null);if(n instanceof ct)return n;if(void 0===t[1]||void 0===t[2])return it;const e=kt(t[1]),r=kt(t[2]),o=Ot(t[4],0);if(o instanceof ct)return o;const s=Wt(n,e,1===o?-1:-1===o?1:0,2===o);return-1===s?void 0!==t[3]&&null!==bt(t[3])?bt(t[3]):ht:e.rows>=e.cols?r.at(s,0):r.at(0,s)},MATCH:t=>{const n=bt(t[0]??null);if(n instanceof ct)return n;if(void 0===t[1])return it;const e=kt(t[1]),r=Ot(t[2],1);if(r instanceof ct)return r;if(e.rows>1&&e.cols>1)return ht;const o=Wt(n,e,0===r?0:r<0?-1:1,0===r);return-1===o?ht:o+1},INDEX:t=>{if(void 0===t[0])return it;const n=kt(t[0]),e=Ot(t[1],0),r=Ot(t[2],1===n.rows&&void 0===t[2]?0:1);if(e instanceof ct)return e;if(r instanceof ct)return r;const[o,s]=1===n.rows&&void 0===t[2]?[1,e]:[e,r];return o<0||s<0||o>n.rows||s>n.cols?mt:0===o?Ct(n.rows,1,t=>n.at(t,Math.max(s,1)-1)):0===s?Ct(1,n.cols,(t,e)=>n.at(o-1,e)):n.at(Math.trunc(o)-1,Math.trunc(s)-1)},ROWS:t=>void 0===t[0]?it:kt(t[0]).rows,COLUMNS:t=>void 0===t[0]?it:kt(t[0]).cols,TODAY:()=>Math.floor(jt()),NOW:()=>jt(),DATE:t=>{const n=Ot(t[0]),e=Ot(t[1]),r=Ot(t[2]);if(n instanceof ct)return n;if(e instanceof ct)return e;if(r instanceof ct)return r;const o=n<1900?n+1900:n;return F(o,1,1)+Math.round((Date.UTC(o,e-1,r)-Date.UTC(o,0,1))/864e5)},TIME:t=>{const n=Ot(t[0]),e=Ot(t[1]),r=Ot(t[2]);return n instanceof ct?n:e instanceof ct?e:r instanceof ct?r:(3600*n+60*e+r)/86400%1},YEAR:Xt(t=>t.year),MONTH:Xt(t=>t.month),DAY:Xt(t=>t.day),HOUR:Xt(t=>t.hours),MINUTE:Xt(t=>t.minutes),SECOND:Xt(t=>t.seconds),WEEKDAY:t=>{const n=Ot(t[0]),e=Ot(t[1],1);if(n instanceof ct)return n;if(e instanceof ct)return e;const r=k(n).weekday;return 1===e?r+1:2===e?(r+6)%7+1:3===e?(r+6)%7:ft},EDATE:t=>{const n=Ot(t[0]),e=Ot(t[1]);if(n instanceof ct)return n;if(e instanceof ct)return e;const{year:r,month:o,day:s}=Zt(n,Math.trunc(e));return F(r,o,Math.min(s,_t(r,o)))},EOMONTH:t=>{const n=Ot(t[0]),e=Ot(t[1]);if(n instanceof ct)return n;if(e instanceof ct)return e;const{year:r,month:o}=Zt(n,Math.trunc(e));return F(r,o,_t(r,o))},DAYS:t=>{const n=Ot(t[0]),e=Ot(t[1]);return n instanceof ct?n:e instanceof ct?e:Math.trunc(n)-Math.trunc(e)},DATEDIF:t=>{const n=Ot(t[0]),e=Ot(t[1]),r=Ut(t[2]);if(n instanceof ct)return n;if(e instanceof ct)return e;if(r instanceof ct)return r;if(n>e)return ft;const o=k(n),s=k(e),c=12*(s.year-o.year)+(s.month-o.month)-(s.day<o.day?1:0);switch(r.toUpperCase()){case"D":return Math.trunc(e)-Math.trunc(n);case"M":return c;case"Y":return Math.floor(c/12);default:return ft}},NETWORKDAYS:t=>{const n=Ot(t[0]),e=Ot(t[1]);if(n instanceof ct)return n;if(e instanceof ct)return e;const r=new Set;void 0!==t[2]&&$t(t[2],t=>{"number"==typeof t&&r.add(Math.trunc(t))});const o=Math.trunc(Math.min(n,e)),s=Math.trunc(Math.max(n,e));if(s-o>366e3)return ft;let c=0;for(let t=o;t<=s;t++)Kt(t)||r.has(t)||c++;return n<=e?c:-c},ISBLANK:t=>null===bt(t[0]??null),ISNUMBER:t=>"number"==typeof bt(t[0]??null),ISTEXT:t=>"string"==typeof bt(t[0]??null),ISLOGICAL:t=>"boolean"==typeof bt(t[0]??null),ISERROR:t=>bt(t[0]??null)instanceof ct,ISNA:t=>{const n=bt(t[0]??null);return n instanceof ct&&"#N/A"===n.code},ISERR:t=>{const n=bt(t[0]??null);return n instanceof ct&&"#N/A"!==n.code},ISEVEN:t=>tn(t,0),ISODD:t=>tn(t,1),N:t=>{const n=bt(t[0]??null);return n instanceof ct||"number"==typeof n?n:"boolean"==typeof n?Number(n):0},NA:()=>ht,PMT:t=>{const n=Bt(t,[void 0,void 0,void 0,0,0]);return n instanceof ct?n:0===n[1]?ft:function(t,n,e,r,o){if(0===t)return-(e+r)/n;const s=(1+t)**n;return-t*(e*s+r)/((s-1)*(1+t*o))}(n[0],n[1],n[2],n[3],n[4])},FV:t=>{const n=Bt(t,[void 0,void 0,void 0,0,0]);if(n instanceof ct)return n;const[e,r,o,s,c]=n;if(0===e)return-(s+o*r);const u=(1+e)**r;return-(s*u+o*(1+e*c)*(u-1)/e)},PV:t=>{const n=Bt(t,[void 0,void 0,void 0,0,0]);if(n instanceof ct)return n;const[e,r,o,s,c]=n;if(0===e)return-(s+o*r);const u=(1+e)**r;return-(s+o*(1+e*c)*(u-1)/e)/u},NPV:t=>{const n=Ot(t[0]),e=Rt(t.slice(1));return n instanceof ct?n:e instanceof ct?e:e.reduce((t,e,r)=>t+e/(1+n)**(r+1),0)}};rn.CONCATENATE=rn.CONCAT,rn["STDEV.S"]=rn.STDEV,rn["STDEV.P"]=rn.STDEVP,rn["VAR.S"]=rn.VAR,rn["VAR.P"]=rn.VARP,rn["CEILING.MATH"]=rn.CEILING,rn["FLOOR.MATH"]=rn.FLOOR,rn["MODE.SNGL"]=rn.MODE,rn["RANK.EQ"]=rn.RANK,rn["PERCENTILE.INC"]=rn.PERCENTILE,rn["QUARTILE.INC"]=rn.QUARTILE;var on={IF:(t,n)=>{if(t.length<2)return it;const e=Et(bt(n(t[0])));return e instanceof ct?e:e?n(t[1]):t.length>2&&n(t[2])},IFS:(t,n)=>{if(t.length<2||t.length%2)return it;for(let e=0;e<t.length;e+=2){const r=Et(bt(n(t[e])));if(r instanceof ct)return r;if(r)return n(t[e+1])}return ht},IFERROR:(t,n)=>{if(t.length<1)return it;const e=bt(n(t[0]));return e instanceof ct?t[1]?n(t[1]):"":e},IFNA:(t,n)=>{if(t.length<1)return it;const e=bt(n(t[0]));return e instanceof ct&&"#N/A"===e.code?t[1]?n(t[1]):"":e},SWITCH:(t,n)=>{if(t.length<3)return it;const e=bt(n(t[0]));if(e instanceof ct)return e;let r=1;for(;r+1<t.length;r+=2){const o=bt(n(t[r]));if(o instanceof ct)return o;if(0===Nt(e,o))return n(t[r+1])}return r<t.length?n(t[r]):ht},CHOOSE:(t,n)=>{if(t.length<2)return it;const e=yt(bt(n(t[0])));if(e instanceof ct)return e;const r=Math.trunc(e);return r<1||r>=t.length?it:n(t[r])},ROW:(t,n,e)=>t.length?"ref"===t[0].kind&&null!==t[0].ref.a.row?t[0].ref.a.row+1:it:e.row+1,COLUMN:(t,n,e)=>t.length?"ref"===t[0].kind&&null!==t[0].ref.a.col?t[0].ref.a.col+1:it:e.col+1},sn=[...new Set([...Object.keys(rn),...Object.keys(on)])].filter(t=>"TRUE"!==t&&"FALSE"!==t).sort();function cn(t){const n=t.map(()=>new Map),e=t.map(()=>new Set),r=new Map(t.map((t,n)=>[t.name.toLowerCase(),n]));let o=0;const s=(r,s,c)=>{const l=t[r]?.cells[s]?.[c];if(void 0===l||""===l)return null;if(!x(l))return Mt(l);const i=((t,n)=>2e4*t+n)(s,c),f=n[r].get(i);if(void 0!==f)return f;if(e[r].has(i))return pt;let h;e[r].add(i),o++;try{const t=u(function(t){const n=C.get(t);if(n){if(n instanceof a)throw n;return n}let e;try{const{tokens:n,complete:r}=E(t.slice(1));if(!r)throw new a("Unreadable text");e=new v(n).run()}catch(t){if(!(t instanceof a))throw t;e=t}if(C.size>=2e4&&C.clear(),C.set(t,e),e instanceof a)throw e;return e}(l),{sheet:r,row:s,col:c});h=bt(t),null===h&&(h=0)}catch(t){if(!(t instanceof a)){if(!(t instanceof RangeError)||o>1)throw t;return pt}h=dt}finally{o--,e[r].delete(i)}return n[r].set(i,h),h},c=(n,e)=>{let o=e.sheet;if(null!==n.sheet){const t=r.get(n.sheet.toLowerCase());if(void 0===t)return mt;o=t}const c=n.b??n.a;if(null===n.b)return s(o,n.a.row,n.a.col);const u=Math.min(n.a.row??0,c.row??0),l=Math.min(n.a.col??0,c.col??0),i=null===n.a.row?(n=>t[n].cells.length)(o)-1:Math.max(n.a.row,c.row),a=null===n.a.col?(n=>t[n].cells.reduce((t,n)=>Math.max(t,n.length),0))(o)-1:Math.max(n.a.col,c.col);return{...Ct(Math.max(0,i-u+1),Math.max(0,a-l+1),(t,n)=>s(o,u+t,l+n)),raw:(n,e)=>t[o].cells[u+n]?.[l+e]??""}},u=(t,n)=>{switch(t.kind){case"num":case"str":case"bool":return t.value;case"err":return lt(t.value);case"empty":return null;case"ref":return c(t.ref,n);case"unary":return xt(u(t.arg,n),null,n=>{const e=n instanceof ct?n:yt(n);return e instanceof ct?e:"-"===t.op?-e:e});case"percent":return xt(u(t.arg,n),100,(t,n)=>vt("/",t,n));case"binary":return xt(u(t.left,n),u(t.right,n),(n,e)=>vt(t.op,n,e));case"call":{const e=on[t.name];if(e)return e(t.args,t=>u(t,n),n);const r=rn[t.name];return r?r(t.args.map(t=>u(t,n)),n):gt}}};let l=!1;return{value:(n,e,r)=>t[n]?(l||(l=!0,t.forEach((t,n)=>{t.cells.forEach((t,e)=>t.forEach((t,r)=>{x(t)&&s(n,e,r)}));for(let e=t.cells.length-1;e>=0;e--){const r=t.cells[e];for(let t=r.length-1;t>=0;t--)x(r[t])&&s(n,e,t)}})),s(n,e,r)):null}}var un=100,ln=24,an=10;function fn(t,n=[]){return{id:crypto.randomUUID(),name:t,rowCount:Math.max(1e3,n.length+100),colCount:Math.max(26,n.reduce((t,n)=>Math.max(t,n.length),0)),cells:n,formats:{},colWidths:{},rowHeights:{},hiddenRows:[],hiddenCols:[],merges:[],frozenRows:0,frozenCols:0,filter:null}}var hn=(t,n)=>`${t}:${n}`,mn=(t,n,e)=>t.cells[n]?.[e]??"";function gn(t,n){const e=new Set(t.map(t=>t.name.toLowerCase()));for(let r=t.length+1;;r++){const t=`${n} ${r}`;if(!e.has(t.toLowerCase()))return t}}function pn(t){return cn(t)}function dn(t){let n=0,e=!1;for(const r of t)'"'===r?e=!e:e||"("!==r?e||")"!==r||n--:n++;return!e&&n>0?t+")".repeat(n):t}function wn(t,n){if(x(t))return{raw:dn(t),numFmt:null};if(""===t||"'"===t[0])return{raw:t,numFmt:null};if("@"===n?.numFmt)return{raw:`'${t}`,numFmt:null};const e=st(t);return e?{raw:String(e.value),numFmt:e.format}:{raw:t,numFmt:null}}function Mn(t,n){if(x(t)||""===t)return t;const e=Mt(t);if("number"!=typeof e||!n?.numFmt)return t;if(z(n.numFmt)){const t=k(e),n=`${t.year}-${U(t.month)}-${U(t.day)}`;return Number.isInteger(e)?n:`${n} ${U(t.hours)}:${U(t.minutes)}:${U(t.seconds)}`}return/%/.test(n.numFmt)?`${Z(100*e)}%`:t}var bn={text:"",color:null,align:"left",error:!1};function yn(t,n,e,r,o){const s=mn(t,r,o);return""===s?bn:function(t,n,e){if(null===t)return bn;if(t instanceof ct)return{text:t.code,color:null,align:"center",error:!0};if("boolean"==typeof t)return{text:t?"TRUE":"FALSE",color:null,align:"center",error:!1};const r=e?.numFmt;if("number"==typeof t){if(!(r&&"General"!==r||x(n)))return{text:n,color:null,align:"right",error:!1};const{text:e,color:o}=K(t,r??"General");return{text:e,color:o,align:"right",error:!1}}return{text:r?B(t,r):t,color:null,align:"left",error:!1}}(e.value(n,r,o),s,t.formats[hn(r,o)])}function An(t){let n=-1,e=-1;return t.cells.forEach((t,r)=>{for(let o=t.length-1;o>=0;o--)if(""!==t[o]){n=Math.max(n,r),e=Math.max(e,o);break}}),n<0?null:{row:n,col:e}}function En(t,n){if(!n.length)return t;const e=[...t.cells],r=new Set;let o=t.rowCount,s=t.colCount;for(const{row:t,col:c,raw:u}of n)if(""!==u||""!==(e[t]?.[c]??"")){for(;e.length<=t;)e.push([]);for(r.has(t)||(e[t]=[...e[t]],r.add(t));e[t].length<=c;)e[t].push("");e[t][c]=u,o=Math.max(o,t+1),s=Math.max(s,c+1)}return{...t,cells:e,rowCount:o,colCount:s}}function Nn(t,n,e,r){const o=hn(n,e),s=t.formats[o],{raw:c,numFmt:u}=wn(r,s),l=En(t,[{row:n,col:e,raw:c}]);return!u||s?.numFmt&&"General"!==s.numFmt?l:{...l,formats:{...l.formats,[o]:{...s,numFmt:u}}}}function vn(t,n){for(let e=t.r1;e<=t.r2;e++)for(let r=t.c1;r<=t.c2;r++)n(e,r)}function Cn(t,n){const e=[];return vn(function(t,n){const e=Math.min(n.r2,t.cells.length-1);return{...n,r2:Math.max(e,n.r1-1)}}(t,n),(n,r)=>{""!==mn(t,n,r)&&e.push({row:n,col:r,raw:""})}),En(t,e)}function xn(t,n,e){const r={...t.formats},o=(t,n)=>{const o=hn(t,n),s=e(r[o]??{});Object.keys(s).length?r[o]=s:delete r[o]};return vn((n.r2-n.r1+1)*(n.c2-n.c1+1)>2e5?{...n,r2:Math.min(n.r2,Math.max(t.cells.length,2e3))}:n,o),{...t,formats:r}}function $n(t,n,e){const r={...t};return void 0===e||!1===e?delete r[n]:r[n]=e,r}function Rn(t,n,e){const r={...t.formats};return vn(n,(t,o)=>{const s=hn(t,o),c=r[s]??{},u=((t,e)=>({...t===n.r1?{top:!0}:{},...t===n.r2?{bottom:!0}:{},...e===n.c1?{left:!0}:{},...e===n.c2?{right:!0}:{}}))(t,o);let l;switch(e){case"none":l={};break;case"all":l={top:!0,right:!0,bottom:!0,left:!0};break;case"outer":l={...c.border,...u};break;default:l=u[e]?{...c.border,[e]:!0}:c.border??{}}const i=$n(c,"border",Object.keys(l).length?l:void 0);Object.keys(i).length?r[s]=i:delete r[s]}),{...t,formats:r}}function Tn(t,n,e){return t.merges.find(t=>u(t,n,e))??null}function Sn(t,n){let e=n;for(let n=!0;n;){n=!1;for(const r of t.merges){if(!l(e,r))continue;const t={r1:Math.min(e.r1,r.r1),c1:Math.min(e.c1,r.c1),r2:Math.max(e.r2,r.r2),c2:Math.max(e.c2,r.c2)};t.r1===e.r1&&t.c1===e.c1&&t.r2===e.r2&&t.c2===e.c2||(e=t,n=!0)}}return e}function On(t,n){if(n.r1===n.r2&&n.c1===n.c2)return t;const e=[];vn(n,(r,o)=>{r===n.r1&&o===n.c1||""===mn(t,r,o)||e.push({row:r,col:o,raw:""})});const r=En(t,e);return{...r,merges:[...r.merges.filter(t=>!l(t,n)),n]}}function Un(t,n){return{...t,merges:t.merges.filter(t=>!l(t,n))}}function In(t,n,e){const r=t[n].name.toLowerCase();return t.map((t,o)=>{let s=!1;const c=t.cells.map(t=>{let c=!1;const u=t.map(t=>{if(!x(t))return t;const s=T(t,t=>(null===t.sheet?o===n:t.sheet.toLowerCase()===r)?e(t):t);return s!==t&&(c=!0),s});return c&&(s=!0),c?u:t});return s?{...t,cells:c}:t})}function Dn(t,n,e){if(e>0)return t>=n?t+e:t;const r=n-e;return t>=n&&t<r?null:t>=r?t+e:t}function Ln(t,n,e){const r={};for(const[o,s]of Object.entries(t)){const t=Dn(Number(o),n,e);null!==t&&(r[t]=s)}return r}function Fn(t,n,e,r){const[o,s]="row"===n?[t.r1,t.r2]:[t.c1,t.c2];let c,u;if(r>0)c=o>=e?o+r:o,u=s>=e?s+r:s;else{const t=e-r;if(c=o<e?o:o>=t?o+r:e,u=s<e?s:s>=t?s+r:e-1,c>u)return null}return"row"===n?{...t,r1:c,r2:u}:{...t,c1:c,c2:u}}function kn(t,n,e,r,o){const s=In(t,n,t=>function(t,n,e,r){const o=t=>"row"===n?t.row:t.col,s=(t,e)=>"row"===n?{...t,row:e}:{...t,col:e},c=o(t.a);if(null===c)return t;if(r>0){const n=t=>t>=e?t+r:t;return{...t,a:s(t.a,n(c)),b:t.b?s(t.b,n(o(t.b))):null}}const u=-r,l=e+u;if(!t.b)return c>=e&&c<l?null:{...t,a:s(t.a,c>=l?c-u:c)};const i=Math.min(c,o(t.b)),a=Math.max(c,o(t.b)),f=i<e?i:i>=l?i-u:e,h=a<e?a:a>=l?a-u:e-1;return f>h?null:{...t,a:s(t.a,f),b:s(t.b,h)}}(t,e,r,o));return s.map((t,s)=>{if(s!==n)return t;const c="row"===e?(()=>{const n=[...t.cells];return o>0?n.length>r&&n.splice(r,0,...Array.from({length:o},()=>[])):n.splice(r,-o),n})():t.cells.map(t=>{if(t.length<=r)return t;const n=[...t];return o>0?n.splice(r,0,...Array(o).fill("")):n.splice(r,-o),n}),u={};for(const[n,s]of Object.entries(t.formats)){const[t,c]=n.split(":").map(Number),l=Dn("row"===e?t:c,r,o);null!==l&&(u["row"===e?hn(l,c):hn(t,l)]=s)}const l=t.merges.map(t=>Fn(t,e,r,o)).filter(t=>null!==t&&(t.r1!==t.r2||t.c1!==t.c2)),i=t=>t.map(t=>Dn(t,r,o)).filter(t=>null!==t),a=t.filter?Fn(t.filter.range,e,r,o):null,f=t.filter&&a?{range:a,excluded:"col"===e?Ln(t.filter.excluded,r,o):t.filter.excluded}:null,h=t=>r<t?o>0?t+o:Math.max(r,t+o):t;return{...t,cells:c,formats:u,merges:l,filter:f,rowCount:"row"===e?Math.max(1,t.rowCount+o):t.rowCount,colCount:"col"===e?Math.max(1,t.colCount+o):t.colCount,rowHeights:"row"===e?Ln(t.rowHeights,r,o):t.rowHeights,colWidths:"col"===e?Ln(t.colWidths,r,o):t.colWidths,hiddenRows:"row"===e?i(t.hiddenRows):t.hiddenRows,hiddenCols:"col"===e?i(t.hiddenCols):t.hiddenCols,frozenRows:"row"===e?h(t.frozenRows):t.frozenRows,frozenCols:"col"===e?h(t.frozenCols):t.frozenCols}})}function Pn(t,n,e){return In(t,n,t=>null===t.sheet?t:{...t,sheet:e}).map((t,r)=>r===n?{...t,name:e}:t)}function Vn(t,n){return In(t,n,t=>null===t.sheet?t:null).filter((t,e)=>e!==n)}function Gn(t,n,e){const r={...t[n],id:crypto.randomUUID(),name:e};return[...t.slice(0,n+1),r,...t.slice(n+1)]}function zn(t,n,e,r,o,s){const c=[];for(let t=r.r1;t<=r.r2;t++)c.push(t);const u=new Map(c.map(t=>[t,e.value(n,t,o)])),l=[...c].sort((t,n)=>{const e=u.get(t),r=u.get(n),o=null===e||""===e,c=null===r||""===r;if(o||c)return o===c?t-n:o?1:-1;if(e instanceof ct||r instanceof ct)return e instanceof ct?1:-1;const l=Nt(e,r);return(s?l:-l)||t-n}),i=[],a={...t.formats},f=new Map;return vn(r,(n,e)=>f.set(hn(n,e),t.formats[hn(n,e)])),l.forEach((n,e)=>{const o=r.r1+e;for(let e=r.c1;e<=r.c2;e++){const r=mn(t,n,e);i.push({row:o,col:e,raw:x(r)?S(r,o-n,0):r});const s=f.get(hn(n,e));s?a[hn(o,e)]=s:delete a[hn(o,e)]}}),{...En(t,i),formats:a}}function Wn(t,n,e){const r=new Set,{filter:o}=t;if(!o)return r;for(const[s,c]of Object.entries(o.excluded)){if(!c.length)continue;const u=Number(s),l=new Set(c);for(let s=o.range.r1+1;s<=o.range.r2;s++)l.has(yn(t,n,e,s,u).text)&&r.add(s)}return r}function Hn(t,n){if(n.r1!==n.r2||n.c1!==n.c2)return n;const e=(n,e,r)=>{for(let o=e;o<=r;o++)if(""!==mn(t,n,o))return!1;return!0},r=(n,e,r)=>{for(let o=e;o<=r;o++)if(""!==mn(t,o,n))return!1;return!0};let{r1:o,r2:s,c1:c,c2:u}=n;for(let n=!0;n;)n=!1,o>0&&!e(o-1,c,u)&&(o--,n=!0),s<t.rowCount-1&&!e(s+1,c,u)&&(s++,n=!0),c>0&&!r(c-1,o,s)&&(c--,n=!0),u<t.colCount-1&&!r(u+1,o,s)&&(u++,n=!0);return{r1:o,c1:c,r2:s,c2:u}}var jn=/^(.*?)(\d+)$/;function Xn(t,n){const e=t.length,r=t.map(t=>{if(x(t))return null;const n=Mt(t);return"number"==typeof n?n:null});if(e>=2&&r.every(t=>null!==t)){const t=(r[e-1]-r[0])/(e-1);if(r.every((n,e)=>Math.abs(n-(r[0]+t*e))<1e-9))return String(Number((r[0]+t*n).toPrecision(15)))}const o=(n%e+e)%e,s=t[o];if("number"==typeof r[o]||x(s)||""===s||"'"===s[0])return s;const c=jn.exec(s);if(c&&c[1]&&1===e){const t=Number(c[2])+n;if(t>=0)return c[1]+String(t).padStart(c[2].length,"0")}return s}function Zn(t,n,e){const r=[],o={...t.formats},s=n.r2-n.r1+1,c=n.c2-n.c1+1,l=e.r1<n.r1||e.r2>n.r2;return vn(e,(e,i)=>{if(u(n,e,i))return;let a,f,h;if(l){const r=Array.from({length:s},(e,r)=>mn(t,n.r1+r,i)),o=e-n.r1;a=n.r1+(o%s+s)%s,f=i;const c=mn(t,a,f);h=x(c)?S(c,e-a,0):Xn(r,o)}else{const r=Array.from({length:c},(r,o)=>mn(t,e,n.c1+o)),o=i-n.c1;a=e,f=n.c1+(o%c+c)%c;const s=mn(t,a,f);h=x(s)?S(s,0,i-f):Xn(r,o)}r.push({row:e,col:i,raw:h});const m=t.formats[hn(a,f)];m?o[hn(e,i)]=m:delete o[hn(e,i)]}),{...En(t,r),formats:o}}function _n(t,n,e,r,o){const s=[];for(let o=r.r1;o<=r.r2;o++){const c=[];for(let s=r.c1;s<=r.c2;s++){const r=mn(t,o,s);c.push({raw:r,display:yn(t,n,e,o,s).text,value:""===r?null:e.value(n,o,s),format:t.formats[hn(o,s)]})}s.push(c)}return{sheetId:t.id,range:r,cut:o,cells:s,text:s.map(t=>t.map(t=>{return n=t.display,/["\t\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n;var n}).join("\t")).join("\n")}}function Kn(t,n,e,r){const o=n.cells.length,s=n.cells[0]?.length??0,c=e.r2-e.r1+1,u=e.c2-e.c1+1,l=c%o===0&&u%s===0,i=l?c:o,a=l?u:s,f=[],h={...t.formats};for(let t=0;t<i;t++)for(let c=0;c<a;c++){const u=n.cells[t%o][c%s],l=e.r1+t,i=e.c1+c;if("formats"!==r){let e=u.raw;"values"===r?(e=u.value instanceof ct?u.value.code:null===u.value?"":At(u.value),"number"==typeof u.value&&(e=String(u.value))):x(e)&&!n.cut&&(e=S(e,l-(n.range.r1+t%o),i-(n.range.c1+c%s))),f.push({row:l,col:i,raw:e})}"values"!==r&&(u.format?h[hn(l,i)]=u.format:delete h[hn(l,i)])}return{sheet:{...En(t,f),formats:h},range:{r1:e.r1,c1:e.c1,r2:e.r1+i-1,c2:e.c1+a-1}}}function Bn(t,n,e,r,o){const{range:s}=e,c=o.r1-s.r1,l=o.c1-s.c1,i=t[r].name,a=n!==r,f=In(t,n,t=>{const n=t.a.row,e=t.a.col,r=t.b?t.b.row:t.a.row,o=t.b?t.b.col:t.a.col;if(null===n||null===e||null===r||null===o)return t;if(!u(s,n,e)||!u(s,r,o))return t;const f=t=>({...t,row:t.row+c,col:t.col+l});return{...t,sheet:a?i:t.sheet,a:f(t.a),b:t.b?f(t.b):null}}),h=f.map((t,e)=>{if(e!==n)return t;const r={...t.formats};return vn(s,(t,n)=>{delete r[hn(t,n)]}),{...Cn(t,s),formats:r}}),m={...e,cells:e.cells.map((t,e)=>t.map((t,r)=>({...t,raw:mn(f[n],s.r1+e,s.c1+r)})))},g={r1:o.r1,c1:o.c1,r2:o.r1+e.cells.length-1,c2:o.c1+(e.cells[0]?.length??1)-1},p=Kn(h[r],m,g,"all");return{sheets:h.map((t,n)=>n===r?p.sheet:t),range:p.range}}function Yn(t,n){const e=n.matchCase?t:t.toLowerCase();return t=>{const r=n.matchCase?t:t.toLowerCase();return n.wholeCell?r===e:r.includes(e)}}function Qn(t,n,e,r,o){if(!r)return[];const s=Yn(r,o),c=[];return t.cells.forEach((r,u)=>r.forEach((r,l)=>{if(""===r)return;const i=o.inFormulas?r:yn(t,n,e,u,l).text;s(i)&&c.push({row:u,col:l})})),c}function Jn(t,n,e,r){if(x(t)&&!r.inFormulas)return t;if(r.wholeCell)return Yn(n,r)(t)?e:t;const o=r.matchCase?"g":"gi";return t.replace(new RegExp(n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o),()=>e)}function qn(t,n,e,r,o){let s,c=0,u=0,l=0,i=1/0,a=-1/0;const f=Math.min(r.r2,t.cells.length-1);for(let h=r.r1;h<=f;h++){if(o.has(h))continue;const f=t.cells[h];if(!f)continue;const m=Math.min(r.c2,f.length-1);for(let o=r.c1;o<=m;o++){if(""===f[o])continue;u++;const r=e.value(n,h,o);"number"==typeof r&&(l++,c+=r,r<i&&(i=r),r>a&&(a=r),s??=t.formats[hn(h,o)]?.numFmt)}}return{sum:c,average:l?c/l:null,count:u,numbers:l,min:i,max:a,firstFormat:s}}function te(t){const n=t.replace(/^/,""),e=n.slice(0,n.search(/\r?\n|$/)),r=e.includes("\t")&&!e.includes(",")||e.includes("\t")?"\t":",",o=[];let s=[],c="",u=!1,l=0;for(;l<n.length;){const t=n[l];if(u){if('"'===t){if('"'===n[l+1]){c+='"',l+=2;continue}u=!1,l++;continue}c+=t,l++}else'"'!==t||""!==c?t!==r?("\r"===t&&"\n"===n[l+1]&&l++,"\n"!==t&&"\r"!==t?(c+=t,l++):(s.push(c),o.push(s),s=[],c="",l++)):(s.push(c),c="",l++):(u=!0,l++)}return(""!==c||s.length)&&(s.push(c),o.push(s)),o.filter(t=>t.some(t=>""!==t))}function ne(t){return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function ee(t,n,e){const r=An(t);if(!r)return"";const o=[];for(let s=0;s<=r.row;s++){const c=[];for(let o=0;o<=r.col;o++){const r=mn(t,s,o),u=yn(t,n,e,s,o).text;c.push(ne("'"===r[0]&&/^[=+\-@]/.test(u)?r:u))}o.push(c.join(","))}return o.join("\n")}function re(t,n){const e=fn(t),r={},o=n.map((t,n)=>t.map((t,e)=>{const{raw:o,numFmt:s}=wn(t);return s&&(r[hn(n,e)]={numFmt:s}),o}));return{...e,cells:o,formats:r,rowCount:Math.max(e.rowCount,o.length+100),colCount:Math.max(e.colCount,o.reduce((t,n)=>Math.max(t,n.length),0))}}function oe(t,n,e,r,o){const s=new Set;for(let c=r.r1+1;c<=r.r2;c++)s.add(yn(t,n,e,c,o).text);return[...s].sort((t,n)=>t.localeCompare(n,void 0,{numeric:!0}))}export{t as MAX_ROWS,n as MAX_COLS,e as colLabel,r as colIndex,o as cellLabel,s as normalizeRange,c as rangeLabel,u as rangeContains,i as parseRangeLabel,E as tokenize,x as isFormula,R as printRef,S as shiftFormula,O as cycleRefAbsolute,I as NUMBER_FORMATS,K as formatNumber,Y as adjustDecimals,ct as FormulaError,sn as FUNCTION_NAMES,un as DEFAULT_COL_WIDTH,ln as DEFAULT_ROW_HEIGHT,an as DEFAULT_FONT_SIZE,fn as newSheet,hn as formatKey,mn as rawAt,gn as nextSheetName,pn as makeEvaluator,wn as readEntry,Mn as editText,yn as cellDisplay,An as usedBounds,En as writeCells,Nn as commitEntry,Cn as clearValues,xn as updateFormats,$n as withFormat,Rn as applyBorders,Tn as mergedAt,Sn as expandForMerges,On as mergeRange,Un as unmergeRange,kn as changeStructure,Pn as renameSheet,Vn as deleteSheet,Gn as duplicateSheet,zn as sortRange,Wn as filteredRows,Hn as dataRegion,Zn as fillRange,_n as copyClip,Kn as pasteClip,Bn as moveCells,Qn as findCells,Jn as replaceInCell,qn as selectionStats,te as parseCsv,ee as serializeCsv,re as sheetFromRows,oe as columnValues};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{importSpreadsheetFile as o}from"./chunk-3KJZFUBH.js";import"./chunk-4M3QRYCH.js";import"./chunk-UDEPDAZI.js";import"./chunk-XYVQTQ6N.js";export{o as importSpreadsheetFile};
|
package/dist/slides/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mergeDecks as o}from"../chunk-3RFDQOTI.js";import{importDeckFile as t}from"../chunk-6ZFEBY6H.js";import{PptxPasswordError as r,PptxUnreadableError as m}from"../chunk-MDG2ADZ7.js";import{SlidesConflict as i,SlidesProvider as p,browserSlidesStore as s}from"../chunk-BGAR3P46.js";import{SlideView as n}from"../chunk-B2X3NIQR.js";import{ENGLISH_WORDS as c,ZH_HANS_WORDS as e,asDocument as f}from"../chunk-PXOQN7D6.js";import{ENGLISH_FILE_WORDS as u,ZH_HANS_FILE_WORDS as a}from"../chunk-B32ASXHM.js";import{hasExtension as j}from"../chunk-XYVQTQ6N.js";import{lazy as h}from"react";var k=h(()=>import("../Slides-
|
|
1
|
+
import{mergeDecks as o}from"../chunk-3RFDQOTI.js";import{importDeckFile as t}from"../chunk-6ZFEBY6H.js";import{PptxPasswordError as r,PptxUnreadableError as m}from"../chunk-MDG2ADZ7.js";import{SlidesConflict as i,SlidesProvider as p,browserSlidesStore as s}from"../chunk-BGAR3P46.js";import{SlideView as n}from"../chunk-B2X3NIQR.js";import{ENGLISH_WORDS as c,ZH_HANS_WORDS as e,asDocument as f}from"../chunk-PXOQN7D6.js";import{ENGLISH_FILE_WORDS as u,ZH_HANS_FILE_WORDS as a}from"../chunk-B32ASXHM.js";import{hasExtension as j}from"../chunk-XYVQTQ6N.js";import{lazy as h}from"react";var k=h(()=>import("../Slides-LJW5C24V.js")),d=h(()=>import("../Slides-LJW5C24V.js").then(o=>({default:o.OpenDeck}))),l={"/slides":{component:k,label:"Slides",size:"3xl",appStyle:!0,flushBody:!0,autoHeight:!1}};async function P(o,t){const{importPptx:r}=await(import("../pptxImport-Y7TB6PYP.js"));return r(o,t)}async function B(o,t){const{deckToPdf:r}=await(import("../deckPdf-4RC7QJ45.js"));return r(o,t)}export{d as DeckEditor,u as ENGLISH_FILE_WORDS,c as ENGLISH_WORDS,r as PptxPasswordError,m as PptxUnreadableError,n as SlideView,k as Slides,i as SlidesConflict,p as SlidesProvider,a as ZH_HANS_FILE_WORDS,e as ZH_HANS_WORDS,f as asDocument,s as browserSlidesStore,B as deckToPdf,j as hasExtension,t as importDeckFile,P as importPptx,o as mergeDecks,l as slidesApps};
|
package/dist/slides/slides.css
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
.slides-thumb-number { font-size: 12px; opacity: 0.7; }
|
|
13
13
|
.slides-thumb-image { border: 1px solid var(--line); border-radius: 3px; overflow: hidden; cursor: pointer; width: fit-content; }
|
|
14
14
|
.slides-thumb[data-current] .slides-thumb-image { outline: 2px solid var(--slides-accent); outline-offset: 1px; }
|
|
15
|
-
.slides-thumb-actions { grid-column: 2; display: flex; justify-content: flex-end; gap: 2px; }
|
|
16
15
|
|
|
17
16
|
.slides-centre { flex: 1; min-width: 0; display: flex; flex-direction: column; }
|
|
18
17
|
.slides-toolbar { display: flex; gap: 2px; padding: 4px 8px; border-bottom: 1px solid var(--line); background: var(--surface); }
|
|
@@ -235,7 +235,10 @@ declare const SPREADSHEET_EXTENSIONS: readonly string[];
|
|
|
235
235
|
* host hands a language in through `SpreadsheetWordsProvider`.
|
|
236
236
|
*
|
|
237
237
|
* The zh-Hans words for the file list and saving (`backToFiles` to
|
|
238
|
-
* `deleteConfirm`) are machine-written, and no person has read them yet.
|
|
238
|
+
* `deleteConfirm`) are machine-written, and no person has read them yet. So are the
|
|
239
|
+
* help lines of the functions added with the Google Sheets gap's first tier (CHAR to
|
|
240
|
+
* SUBTOTAL: CHAR, CLEAN, CODE, ISERR, ISEVEN, ISODD, MAXIFS, MINIFS, MROUND,
|
|
241
|
+
* PERCENTILE, QUARTILE, QUOTIENT, the three REGEX functions and SUBTOTAL).
|
|
239
242
|
*/
|
|
240
243
|
|
|
241
244
|
interface SpreadsheetWords {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SPREADSHEET_EXTENSIONS as e,SpreadsheetWordsProvider as t,SpreadsheetsConflict as n,SpreadsheetsProvider as s}from"../chunk-
|
|
1
|
+
import{SPREADSHEET_EXTENSIONS as e,SpreadsheetWordsProvider as t,SpreadsheetsConflict as n,SpreadsheetsProvider as s}from"../chunk-4MGZXE3N.js";import{ENGLISH_WORDS as r,ZH_HANS_WORDS as o}from"../chunk-MZJSGEU3.js";import{cellDisplay as a,cellLabel as i,changeStructure as l,clearValues as c,colIndex as h,commitEntry as u,isFormula as p,makeEvaluator as m,newSheet as d,parseRangeLabel as f,rangeLabel as w,renameSheet as g,sortRange as b,updateFormats as k,usedBounds as S}from"../chunk-UDEPDAZI.js";import{ENGLISH_FILE_WORDS as j,ZH_HANS_FILE_WORDS as y}from"../chunk-B32ASXHM.js";import{hasExtension as I}from"../chunk-XYVQTQ6N.js";import{lazy as M}from"react";var _=class extends Error{};function x(e,t,n){if(!t)return Math.min(n,e.length-1);const s=e.findIndex(e=>e.name.toLowerCase()===t.trim().toLowerCase());if(s<0)throw new _(`there is no sheet "${t}" any more`);return s}function E(e){const t=f(e);if(!t)throw new _(`"${e}" is not a range`);return t}function X(e,t,n){return e.map((e,s)=>s===t?n(e):e)}function v(e,t){const n={...e},s=(e,t)=>{void 0!==t&&(null===t||!1===t?delete n[e]:n[e]=t)};return s("bold",t.bold),s("italic",t.italic),s("underline",t.underline),s("align",t.align),s("fill",t.fill),s("color",t.color),s("numFmt",t.numFmt),n}function U(e,t,n){let s=e;for(const e of n)switch(e.op){case"add_sheet":if(s.some(t=>t.name.toLowerCase()===e.name.toLowerCase()))throw new _(`there is already a sheet "${e.name}"`);s=[...s,d(e.name)];break;case"rename_sheet":s=g(s,x(s,e.sheet,t),e.name);break;case"set_cells":{const n=x(s,e.sheet,t),r=E(e.start);s=X(s,n,t=>{let n=t;return e.values.forEach((e,t)=>e.forEach((e,s)=>{n=u(n,r.r1+t,r.c1+s,e)})),n});break}case"clear":s=X(s,x(s,e.sheet,t),t=>c(t,E(e.range)));break;case"insert_rows":case"delete_rows":{const n=x(s,e.sheet,t);s=l(s,n,"row",e.at-1,"insert_rows"===e.op?e.count:-e.count);break}case"insert_columns":case"delete_columns":{const n=x(s,e.sheet,t);s=l(s,n,"col",h(e.at),"insert_columns"===e.op?e.count:-e.count);break}case"sort":{const n=x(s,e.sheet,t),r=m(s);s=X(s,n,t=>b(t,n,r,E(e.range),h(e.by),!e.descending));break}case"format":s=X(s,x(s,e.sheet,t),t=>k(t,E(e.range),t=>v(t,e.format)));break;default:throw new _("this spreadsheet does not make that change")}return s}function A(){let e=null,t={open:!1,title:"",selection:null};const n=new Set,s=new Map,r=e=>{if(e.open!==t.open||e.title!==t.title||e.selection?.sheet!==t.selection?.sheet||e.selection?.range!==t.selection?.range){t=e;for(const e of n)e()}};return{getState:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)}),attach:t=>(e=t,s.clear(),()=>{e===t&&(e=null,s.clear(),r({open:!1,title:"",selection:null}))}),changed(){if(!e)return;const t=e.sheets(),n=e.selection();r({open:!0,title:e.title(),selection:n&&t[n.sheet]?{sheet:t[n.sheet].name,range:w(n.range)}:null})},snapshot:()=>e?function(e,t,n,s){const r=m(t);return{title:e,sheets:t.map((e,t)=>{const n=S(e),s=[],o={};if(n)for(let l=0;l<=Math.min(n.row,4999);l++){const n=[],c=Math.min(e.cells[l]?.length??0,200);for(let s=0;s<c;s++){const c=e.cells[l][s]??"";""!==c?(n.push(a(e,t,r,l,s).text),p(c)&&(o[i(l,s)]=c)):n.push("")}s.push(n)}return{name:e.name,rows:s,formulas:o}}),activeSheet:Math.min(n,t.length-1),selection:s?{sheet:s.sheet,range:w(s.range)}:null}}(e.title(),e.sheets(),e.activeSheet(),e.selection()):null,apply(t,n){if(!e)return{applied:!1,reason:"the spreadsheet is closed"};if(s.has(t))return{applied:!0};const r=e.sheets();let o;try{o=U(r,e.activeSheet(),n)}catch(e){return{applied:!1,reason:e instanceof _?e.message:"it no longer fits the sheet"}}return e.commit(o),s.set(t,{before:r,after:o}),{applied:!0}},undo(t){const n=s.get(t);return e&&n?e.sheets()!==n.after?{applied:!1,reason:"the sheet has changed since"}:(e.undoLast(),s.delete(t),{applied:!0}):{applied:!1,reason:"the spreadsheet has been closed since"}}}}var C=M(()=>import("../Spreadsheet-I5XA7TU7.js")),L=M(()=>import("../Spreadsheet-I5XA7TU7.js").then(e=>({default:e.SpreadsheetById}))),P=M(()=>import("../Spreadsheet-I5XA7TU7.js").then(e=>({default:e.SpreadsheetPane}))),T={"/spreadsheet":{component:C,label:"Spreadsheets",size:"2xl",appStyle:!0,multiInstance:!0}};async function F(e){const{readXlsx:t}=await(import("../xlsxFile-GYMIRUWG.js"));return t(e)}async function G(e,t){const{workbookToPdf:n}=await(import("../workbookPdf-63WIOPEC.js"));return n(e,t)}async function Z(e,t){const{importSpreadsheetFile:n}=await(import("../importSpreadsheet-ZXS3RSKE.js"));return n(e,t)}export{j as ENGLISH_FILE_WORDS,r as ENGLISH_WORDS,e as SPREADSHEET_EXTENSIONS,_ as SheetEditRefused,C as Spreadsheet,L as SpreadsheetEditor,P as SpreadsheetPane,t as SpreadsheetWordsProvider,n as SpreadsheetsConflict,s as SpreadsheetsProvider,y as ZH_HANS_FILE_WORDS,o as ZH_HANS_WORDS,U as applySheetOps,A as createSheetBridge,I as hasExtension,Z as importSpreadsheetFile,F as readXlsx,T as spreadsheetApp,G as workbookToPdf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{rowPageStarts as t}from"./chunk-PWF37Y2N.js";import{ENGLISH_WORDS as e}from"./chunk-
|
|
1
|
+
import{rowPageStarts as t}from"./chunk-PWF37Y2N.js";import{ENGLISH_WORDS as e}from"./chunk-MZJSGEU3.js";import{DEFAULT_COL_WIDTH as o,cellDisplay as n,filteredRows as r,formatKey as s,makeEvaluator as a,usedBounds as i}from"./chunk-UDEPDAZI.js";import{drawJpeg as c,embeddedFonts as l,jpegPdf as d,openStage as p,settled as h}from"./chunk-JKYJGXJE.js";import"./chunk-B32ASXHM.js";var m=t=>t*(4/3),f=m(842),u=m(595),w=f-2*m(36),g=u-2*m(36),y="Calibri,Carlito,Arial,sans-serif",b=t=>Array.from({length:t},(t,e)=>e);function x(t,e,a){const c=i(t);if(!c)return{name:t.name,widths:[],rows:[],headerRows:0};const l=new Set([...t.hiddenRows,...r(t,e,a)]),d=new Set(t.hiddenCols),p=b(c.col+1).filter(t=>!d.has(t)),h=b(c.row+1).filter(t=>!l.has(t)).map(o=>p.map(r=>{const{text:i,align:c,color:l}=n(t,e,a,o,r),d=t.formats[s(o,r)];return{text:i,align:d?.align??c,color:d?.color??l,format:d}}));return{name:t.name,widths:p.map(e=>t.colWidths[e]??o),rows:h,headerRows:Math.min(Math.max(t.frozenRows,1),h.length)}}function E(t){const e=document.createElement("td");e.textContent=t.text;const{format:o}=t;return e.style.cssText=`border:.5pt solid #bbb;padding:1pt 3pt;vertical-align:top;overflow-wrap:anywhere;white-space:pre-wrap;text-align:${t.align}`,t.color&&(e.style.color=t.color),o?.fill&&(e.style.background=o.fill),o?.bold&&(e.style.fontWeight="700"),o?.italic&&(e.style.fontStyle="italic"),o?.fontSize&&(e.style.fontSize=`${o.fontSize}pt`),e}function R(t){const e=document.createElement("tr");return e.append(...t.map(E)),e}function v(t,e){const o=document.createElement("table"),n=t.widths.reduce((t,e)=>t+e,0);o.style.cssText=`border-collapse:collapse;table-layout:fixed;width:${n}px;font:10pt ${y};color:#000`;const r=document.createElement("colgroup");r.append(...t.widths.map(t=>Object.assign(document.createElement("col"),{style:`width:${t}px`})));const s=document.createElement("tbody");return s.append(...e.map(R)),o.append(r,s),o}function $(t){const e=document.createElement("div");return e.textContent=t,e.style.cssText=`font:600 13pt ${y};color:#000;margin-bottom:6pt`,e}function S({table:t,scale:e,starts:o},n){const r=document.createElement("div");if(r.style.cssText=`position:relative;overflow:hidden;background:#fff;width:${f}px;height:${u}px;padding:${m(36)}px;box-sizing:border-box`,r.append($(t.name)),t.rows.length){const s=o[n+1]??t.rows.length,a=v(t,[...t.rows.slice(0,t.headerRows),...t.rows.slice(o[n],s)]);a.style.transform=`scale(${e})`,a.style.transformOrigin="0 0",r.append(a)}return r}async function k(t,e,o,n){e.append(t);try{await h(t);return{jpeg:await c(t,{width:f,height:u,pixelRatio:2,quality:n,fontCss:o}),width:842,height:595}}finally{t.remove()}}async function A(o,n={}){const{signal:r,onProgress:s,quality:i}=n;r?.throwIfAborted();const c=p();try{const n=a(o),p=o.map((e,o)=>function(e,o){const n=e.widths.reduce((t,e)=>t+e,0),r=n>w?w/n:1,s=$(e.name),a=v(e,e.rows);o.append(s,a);const i=s.getBoundingClientRect().height+m(6),c=Array.from(a.querySelectorAll("tr"),t=>t.getBoundingClientRect().height);s.remove(),a.remove();const l=c.slice(0,e.headerRows).reduce((t,e)=>t+e,0),d=(g-i)/r,p=t(c.slice(e.headerRows),d,l).map(t=>t+e.headerRows);return{table:e,scale:r,starts:p}}(x(e,o,n),c.root)),h=p.reduce((t,e)=>t+e.starts.length,0),f=await l(c.root),u=[];for(const t of p)for(const o of t.starts.keys())r?.throwIfAborted(),u.push(await k(S(t,o),c.root,f,i).catch(t=>{throw new Error(e.pdfPageFailed(u.length+1),{cause:t})})),s?.(u.length,h);return d(u)}finally{c.close()}}export{x as sheetTable,A as workbookToPdf};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readXlsx as o,unzip as r,writeXlsx as m,zip as p}from"./chunk-4M3QRYCH.js";import"./chunk-UDEPDAZI.js";export{o as readXlsx,r as unzip,m as writeXlsx,p as zip};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{mergeDecks as e}from"./chunk-3RFDQOTI.js";import{LAYOUTS as t,THEMES as n,applyTheme as i,ensureFonts as l,fontsOf as r,slideFromLayout as s,themeOf as o}from"./chunk-Q7NVDOCX.js";import{SlidesConflict as a,useSlidesHost as d,useSlidesWords as c}from"./chunk-BGAR3P46.js";import{DEFAULT_TRANSITION_SECONDS as m,PPTX_SHAPES as u,SlideView as h,applyStyle as p,boxStyle as f,chartToGrid as b,clicksOf as g,connectorPath as v,editorHtml as y,gridToChart as k,indent as w,insertColumn as x,insertRow as C,listMarkers as S,mergeAt as N,mergeCells as z,moveAnimation as I,nearestSide as D,newAnimation as M,paragraphsIn as E,paragraphsOf as A,plainText as P,readParagraphs as F,relayConnectors as T,removeColumn as L,removeRow as j,restoreSelection as $,selectionOffsets as B,seriesOf as R,setCell as W,setParagraphs as O,shapePath as K,shownSlides as U,stateAt as H,styleAt as V,toggleList as _,transitionKeyframes as J,unmergeCell as q,videoSource as X,withEnds as G,withParagraphs as Q}from"./chunk-B2X3NIQR.js";import{DECK_FONT as Y,DECK_FONTS as Z,HANDLES as ee,NO_FILL as te,SHAPE_KINDS as ne,SLIDE_H as ie,SLIDE_W as le,angleTo as re,asDocument as se,boundsOf as oe,boxesTouch as ae,bringForward as de,copySlide as ce,historyReducer as me,insertSlideAfter as ue,moveSlide as he,newElement as pe,newId as fe,removeElements as be,removeSlide as ge,resizeBox as ve,shiftElement as ye,snapBox as ke,updateElements as we,updateSlide as xe}from"./chunk-PXOQN7D6.js";import"./chunk-B32ASXHM.js";import{useCallback as Ce,useEffect as Se,useMemo as Ne,useReducer as ze,useRef as Ie,useState as De}from"react";import{saveIndicator as Me,useAutosave as Ee}from"efficient-easel/autosave";import{EaselIconButton as Ae,EaselTopBar as Pe,SaveState as Fe,TopBarCluster as Te,TopBarDivider as Le}from"efficient-easel/chrome";import{useEaselStrings as je}from"efficient-easel/strings";import"efficient-easel/shell.css";import"efficient-easel/chrome.css";import"efficient-easel/panel.css";import"efficient-easel/fields.css";import{AvatarGroup as $e,Avatar as Be,Button as Re,ContextMenu as We,DropdownMenu as Oe,IconButton as Ke,Input as Ue,Popover as He,registerModalEscapeInterceptor as Ve,Textarea as _e,useContextMenu as Je}from"efficient-shell/ui";import{Icon as qe}from"efficient-shell/icons";import{toast as Xe}from"efficient-shell";import{useRef as Ge,useState as Qe}from"react";import{Button as Ye,IconButton as Ze,Textarea as et}from"efficient-shell/ui";import{Icon as tt}from"efficient-shell/icons";import{toast as nt}from"efficient-shell";import{Button as it,IconButton as lt,Select as rt,Slider as st,Switch as ot}from"efficient-shell/ui";import{Icon as at}from"efficient-shell/icons";import{jsx as dt,jsxs as ct}from"react/jsx-runtime";var mt=["none","fade","slide","push","zoom","flip"],ut=["appear","fadeIn","flyIn","zoomIn","fadeOut"],ht=(e,t)=>({none:e.transitionNone,fade:e.transitionFade,slide:e.transitionSlide,push:e.transitionPush,zoom:e.transitionZoom,flip:e.transitionFlip}[t]),pt=(e,t)=>({appear:e.effectAppear,fadeIn:e.effectFadeIn,flyIn:e.effectFlyIn,zoomIn:e.effectZoomIn,fadeOut:e.effectFadeOut}[t]);function ft(e,t){return t?"text"===t.type?P(A(t)).split("\n")[0].slice(0,32)||e.elementText:{shape:e.elementShape,image:e.elementImage,video:e.elementVideo,connector:e.elementConnector,chart:e.elementChart,table:e.elementTable}[t.type]:""}function bt({slide:e,slideNumber:t,selected:n,onSlide:i,onAllSlides:l,onPlay:r}){const s=c(),o=e.animations??[],a=e=>i({animations:e.length>0?e:void 0}),d=(e,t)=>a(o.map(n=>n.id===e?{...n,...t}:n)),u=1===n.length?n[0]:null;return ct("aside",{className:"slides-inspector",children:[dt("h3",{children:s.motion}),ct("div",{className:"slides-section",children:[dt("p",{className:"slides-label",children:`${s.transition} · ${s.slideNumber(t)}`}),dt("div",{className:"slides-pills",role:"radiogroup","aria-label":s.transition,children:mt.map(t=>{const n=(e.transition?.kind??"none")===t;return dt("button",{type:"button",role:"radio","aria-checked":n,className:"slides-pill",onClick:()=>i({transition:"none"===t?void 0:{kind:t,duration:e.transition?.duration??m}}),children:ht(s,t)},t)})}),e.transition&&dt(st,{label:s.duration,min:.1,max:5,step:.1,precision:1,suffix:"s",value:e.transition.duration,onChange:t=>i({transition:{...e.transition,duration:t??m}})}),ct("div",{className:"slides-actions",children:[dt(it,{variant:"secondary",size:"sm",onClick:()=>l({transition:e.transition}),children:s.applyToAll}),dt(it,{variant:"secondary",size:"sm",leftIcon:dt(at,{name:"play",size:14}),onClick:r,children:s.play})]})]}),ct("div",{className:"slides-section",children:[dt("p",{className:"slides-label",children:s.animations}),0===o.length&&dt("small",{className:"slides-hint",children:s.noAnimations}),o.map((t,n)=>{const i=e.elements.find(e=>e.id===t.elementId);return ct("div",{className:"slides-animation",children:[ct("div",{className:"slides-animation-head",children:[dt("span",{className:"slides-animation-number",children:n+1}),dt("span",{className:"slides-animation-name",children:ft(s,i)}),dt(lt,{"aria-label":s.moveEarlier,size:"sm",disabled:0===n,onClick:()=>a(I(o,n,n-1)),children:dt(at,{name:"chevron-up",size:14})}),dt(lt,{"aria-label":s.moveLater,size:"sm",disabled:n===o.length-1,onClick:()=>a(I(o,n,n+1)),children:dt(at,{name:"chevron-down",size:14})}),dt(lt,{"aria-label":s.removeAnimation,size:"sm",onClick:()=>a(o.filter(e=>e.id!==t.id)),children:dt(at,{name:"trash",size:14})})]}),dt(rt,{"aria-label":s.animations,size:"sm",value:t.effect,onChange:e=>d(t.id,{effect:e,from:"flyIn"===e?t.from??"bottom":void 0}),options:ut.map(e=>({value:e,label:pt(s,e)}))}),"flyIn"===t.effect&&dt(rt,{"aria-label":s.effectFlyIn,size:"sm",value:t.from??"bottom",onChange:e=>d(t.id,{from:e}),options:[{value:"left",label:s.fromLeft},{value:"right",label:s.fromRight},{value:"top",label:s.fromTop},{value:"bottom",label:s.fromBottom}]}),dt(rt,{"aria-label":s.startClick,size:"sm",value:t.start,onChange:e=>d(t.id,{start:e}),options:[{value:"click",label:s.startClick},{value:"withPrevious",label:s.startWithPrevious},{value:"afterPrevious",label:s.startAfterPrevious}]}),dt(st,{label:s.duration,min:.1,max:5,step:.1,precision:1,suffix:"s",value:t.duration,onChange:e=>d(t.id,{duration:e??.5})}),"text"===i?.type&&dt(ot,{label:s.byParagraph,checked:!!t.byParagraph,onChange:e=>d(t.id,{byParagraph:e||void 0})})]},t.id)}),u?ct("div",{className:"slides-actions",children:[dt(it,{variant:"secondary",size:"sm",leftIcon:dt(at,{name:"add",size:14}),onClick:()=>a([...o,M(u.id)]),children:s.addAnimation}),dt(it,{variant:"secondary",size:"sm",onClick:()=>a([...o,M(u.id,"fadeOut")]),children:s.effectFadeOut})]}):dt("small",{className:"slides-hint",children:s.selectToAnimate})]})]})}import{Fragment as gt,jsx as vt,jsxs as yt}from"react/jsx-runtime";function kt(e){return e.filter(e=>!e.parent).map(t=>({first:t,replies:e.filter(e=>e.parent===t.id)}))}function wt({placeholder:e,label:t,onPost:n,autoFocus:i}){const{people:l}=d(),r=c(),[s,o]=Qe(""),[a,m]=Qe([]),u=Ge(new Map),h=Ge(null),p=()=>{const e=s.trim();if(!e)return;const t=[...u.current].filter(([,t])=>e.includes(`@${t}`)).map(([e])=>e);n(e,t).then(()=>{o(""),u.current.clear()},()=>nt.error(r.commentFailed))};return yt("div",{className:"slides-composer",children:[vt(et,{ref:h,rows:2,"aria-label":t,placeholder:e,autoFocus:i,value:s,onChange:e=>{o(e.target.value),(e=>{const t=(e=>e.match(/@([\p{L}\p{N} .'-]{0,30})$/u)?.[1])(e);if(void 0===t||!l)return m([]);l(t.trim()).then(e=>m(e.slice(0,6)),()=>m([]))})(e.target.value)},onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&p()}}),a.length>0&&vt("ul",{className:"slides-mentions",role:"listbox","aria-label":t,children:a.map(e=>vt("li",{role:"option","aria-selected":!1,onMouseDown:t=>{t.preventDefault(),(e=>{const t=s.replace(/@([\p{L}\p{N} .'-]{0,30})$/u,`@${e.name} `);u.current.set(e.id,e.name),o(t),m([]),h.current?.focus()})(e)},children:e.name},e.id))}),vt("div",{className:"slides-actions slides-actions-end",children:vt(Ye,{size:"sm",disabled:!s.trim(),onClick:p,children:t})})]})}function xt({comment:e,mine:t,onSave:n,onDelete:i}){const l=c(),[r,s]=Qe(!1),[o,a]=Qe(e.body);return yt("div",{className:"slides-comment",children:[yt("div",{className:"slides-comment-head",children:[vt("span",{className:"slides-avatar","aria-hidden":"true",children:Ct(e.authorName)}),vt("span",{className:"slides-comment-author",children:e.authorName}),vt("time",{className:"slides-comment-time",dateTime:e.createdAt,children:new Date(e.createdAt).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}),t&&!r&&yt(gt,{children:[vt(Ze,{"aria-label":l.editComment,size:"sm",onClick:()=>s(!0),children:vt(tt,{name:"edit",size:14})}),vt(Ze,{"aria-label":l.deleteComment,size:"sm",onClick:i,children:vt(tt,{name:"trash",size:14})})]})]}),r?yt("div",{className:"slides-composer",children:[vt(et,{rows:2,"aria-label":l.editComment,value:o,onChange:e=>a(e.target.value)}),yt("div",{className:"slides-actions slides-actions-end",children:[vt(Ye,{variant:"secondary",size:"sm",onClick:()=>s(!1),children:l.cancel}),vt(Ye,{size:"sm",onClick:()=>{n(o.trim()),s(!1)},disabled:!o.trim(),children:l.save})]})]}):vt("p",{className:"slides-comment-body",children:e.body})]})}var Ct=e=>e.split(/\s+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join("")||"?";function St({comments:e,slides:t,slide:n,selectedId:i,focusId:l,onAdd:r,onUpdate:s,onRemove:o,onShowSlide:a}){const m=c(),{currentUser:u}=d(),[h,p]=Qe(!1),f=kt(e).filter(e=>h||!e.first.resolvedAt).sort((e,i)=>{const l=e=>e.first.slideId===n.id?0:1,r=e=>t.findIndex(t=>t.id===e.first.slideId);return l(e)-l(i)||r(e)-r(i)||e.first.createdAt.localeCompare(i.first.createdAt)}),b=n.elements.find(e=>e.id===i);return yt("aside",{className:"slides-inspector slides-comments",children:[vt("h3",{children:m.comments}),yt("div",{className:"slides-section",children:[vt("p",{className:"slides-label",children:b?ft(m,b):m.onSlide}),vt(wt,{label:m.post,placeholder:m.commentPlaceholder,onPost:(e,t)=>r({slideId:n.id,elementId:i??"",body:e,parent:null,mentions:t})},`${n.id}-${i??""}`),yt("label",{className:"slides-check",children:[vt("input",{type:"checkbox",checked:h,onChange:e=>p(e.target.checked)}),m.showResolved]})]}),0===f.length&&vt("p",{className:"slides-empty",children:m.noComments}),f.map(({first:e,replies:n})=>{const i=t.findIndex(t=>t.id===e.slideId),d=t[i]?.elements.find(t=>t.id===e.elementId);return yt("article",{className:"slides-thread","data-focus":l===e.id||void 0,"data-resolved":e.resolvedAt?"":void 0,children:[yt("button",{type:"button",className:"slides-thread-where",onClick:()=>a(e.slideId),children:[m.slideNumber(i+1),e.elementId?` · ${d?ft(m,d):m.objectGone}`:""]}),[e,...n].map(e=>vt(xt,{comment:e,mine:e.authorId===u?.id,onSave:t=>s(e.id,{body:t}),onDelete:()=>o(e.id)},e.id)),e.resolvedAt?yt("div",{className:"slides-actions slides-actions-between",children:[vt("small",{className:"slides-hint",children:`${m.resolvedBy} · ${e.resolvedByName}`}),vt(Ye,{variant:"secondary",size:"sm",onClick:()=>s(e.id,{resolved:!1}),children:m.reopen})]}):yt(gt,{children:[vt(wt,{label:m.reply,placeholder:m.replyPlaceholder,onPost:(t,n)=>r({slideId:e.slideId,elementId:e.elementId,body:t,parent:e.id,mentions:n})}),vt("div",{className:"slides-actions slides-actions-end",children:vt(Ye,{variant:"secondary",size:"sm",leftIcon:vt(tt,{name:"check",size:14}),onClick:()=>s(e.id,{resolved:!0}),children:m.resolve})})]})]},e.id)})]})}import{useCallback as Nt,useEffect as zt,useState as It}from"react";import{Button as Dt,confirm as Mt,prompt as Et}from"efficient-shell/ui";import{Icon as At}from"efficient-shell/icons";import{toast as Pt}from"efficient-shell";import{jsx as Ft,jsxs as Tt}from"react/jsx-runtime";var Lt=e=>new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"});function jt({deckId:e,previewing:t,onPreview:n,onRestore:i,refreshKey:l}){const r=c(),{versions:s}=d(),[o,a]=It(null),m=Nt(()=>{s&&s.list(e).then(a,()=>Pt.error(r.versionsFailed))},[e,s,r.versionsFailed]);if(zt(m,[m,l]),!s)return null;const u=async(t,n="")=>{const i=await Et({title:r.nameVersion,message:r.versionName,defaultValue:n});if(null!==i)try{t?await s.rename(e,t,i.trim()):await s.name(e,i.trim()),m()}catch{Pt.error(r.versionsFailed)}};return Tt("aside",{className:"slides-inspector",children:[Ft("h3",{children:r.versionHistory}),Ft("div",{className:"slides-section",children:Ft(Dt,{variant:"secondary",size:"sm",leftIcon:Ft(At,{name:"bookmark",size:14}),onClick:()=>{u(null)},children:r.nameVersion})}),0===o?.length&&Ft("p",{className:"slides-empty",children:r.noVersions}),Ft("ul",{className:"slides-versions",children:o?.map(l=>Tt("li",{"data-current":t===l.id||void 0,children:[Ft("button",{type:"button",className:"slides-version-name",onClick:()=>{u(l.id,l.name)},children:l.name||Lt(l.createdAt)}),l.name&&Ft("small",{children:Lt(l.createdAt)}),Ft("small",{children:l.editorNames.join(", ")}),Tt("div",{className:"slides-actions",children:[Ft(Dt,{variant:"secondary",size:"sm",onClick:()=>{t===l.id?n(null,null):s.get(e,l.id).then(e=>n(l.id,e),()=>Pt.error(r.versionsFailed))},children:t===l.id?r.closePreview:r.previewVersion}),Ft(Dt,{variant:"secondary",size:"sm",onClick:()=>{(async t=>{if(await Mt({title:r.restore,message:r.restoreConfirm(Lt(t.createdAt)),confirmLabel:r.restore}))try{i(await s.get(e,t.id))}catch{Pt.error(r.restoreFailed)}})(l)},children:r.restore})]})]},l.id))})]})}import{useEffect as $t,useMemo as Bt,useRef as Rt,useState as Wt}from"react";import{Button as Ot,registerModalEscapeInterceptor as Kt}from"efficient-shell/ui";import{Icon as Ut}from"efficient-shell/icons";import{useLayoutEffect as Ht,useRef as Vt,useState as _t}from"react";import{createPortal as Jt}from"react-dom";import{jsx as qt,jsxs as Xt}from"react/jsx-runtime";function Gt(e){const[t,n]=_t(0);return Ht(()=>{const t=e.current;if(!t)return;const i=t.ownerDocument.defaultView,l=()=>n(Math.min(t.clientWidth,t.clientHeight*le/ie));l();const r=new(i?.ResizeObserver??ResizeObserver)(l);return r.observe(t),()=>r.disconnect()},[e]),t}function Qt({slide:e,popup:t,number:n,motion:i,fonts:r,transition:s,onLink:o,onAdvance:a}){const[d]=_t(()=>{const e=t.document.createElement("div");return e.style.cssText="position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:#000;cursor:pointer;overflow:hidden",t.document.body.appendChild(e),{current:e}}),c=Gt(d),[m,u]=_t(null),p=Vt(e),f=Vt(null),b=Vt(null);Ht(()=>{r&&l(t.document,r)},[r,t]),Ht(()=>{const t=p.current;p.current=e,t.id!==e.id&&s?u(t):u(null)},[e,s]),Ht(()=>{if(!m||!s)return;const{incoming:e,outgoing:n}=J(s),i={duration:1e3*s.duration,easing:"ease-in-out",fill:"both"},l=f.current?.animate(e,i),r=b.current?.animate(n,i),o=t.setTimeout(()=>u(null),1e3*s.duration+30);return()=>{t.clearTimeout(o),l?.cancel(),r?.cancel()}},[m,s,t]);const g=Vt(!1);return Jt(Xt("div",{style:{position:"relative",width:c,height:c*ie/le},onClick:()=>{if(!g.current&&t.document.documentElement.requestFullscreen)return g.current=!0,void t.document.documentElement.requestFullscreen().catch(()=>{});a?.()},children:[m&&qt("div",{ref:b,style:{position:"absolute",inset:0},children:qt(h,{slide:m,width:c})}),qt("div",{ref:f,style:{position:"absolute",inset:0},children:qt(h,{slide:e,width:c,number:n,motion:i,options:{live:!0,onLink:o}})})]}),d.current)}import{jsx as Yt,jsxs as Zt}from"react/jsx-runtime";var en=e=>String(e).padStart(2,"0");function tn({slides:e,startIndex:t,numbers:n,fonts:i,popup:l,onEnd:r}){const s=Bt(()=>U(e),[e]),o=Math.max(0,s.findIndex(e=>e>=t)),[a,d]=Wt({at:o,step:0}),[m,u]=Wt(!0),p=function(){const[e,t]=Wt(0);return $t(()=>{const e=Date.now(),n=setInterval(()=>t(Math.floor((Date.now()-e)/1e3)),1e3);return()=>clearInterval(n)},[]),`${en(Math.floor(e/60))}:${en(e%60)}`}(),f=c(),b=Rt(null),v=Gt(b),y=t=>{const n=function(e,t,n,i){const l=e[t[n.at]];if(1===i)return l&&n.step<g(l)?{at:n.at,step:n.step+1}:n.at<t.length-1?{at:n.at+1,step:0}:n;if(n.step>0)return{at:n.at,step:n.step-1};if(0===n.at)return n;const r=e[t[n.at-1]];return{at:n.at-1,step:g(r)}}(e,s,a,t);u(n.at!==a.at&&1===t),d(n)},k=Rt({go:y,onEnd:r});k.current={go:y,onEnd:r},$t(()=>{const e=e=>{["ArrowRight","ArrowDown","PageDown"," ","Enter"].includes(e.key)?(e.preventDefault(),k.current.go(1)):["ArrowLeft","ArrowUp","PageUp","Backspace"].includes(e.key)&&(e.preventDefault(),k.current.go(-1))};return window.addEventListener("keydown",e),l?.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e),l?.removeEventListener("keydown",e)}},[l]),$t(()=>Kt(()=>(k.current.onEnd(),!0)),[]),$t(()=>{if(!l)return;const e=e=>{"Escape"===e.key&&k.current.onEnd()};return l.addEventListener("keydown",e),()=>{l.removeEventListener("keydown",e),l.close()}},[l]);const w=s[Math.min(a.at,s.length-1)],x=e[w],C=s[a.at+1],S=void 0!==C?e[C]:void 0,N=g(x),z=Bt(()=>H(x,a.step),[x,a.step]),I=t=>{if(t.startsWith("#slide=")){const n=e.findIndex(e=>e.id===t.slice(7));-1!==n&&(e=>{const t=s.indexOf(e);-1!==t&&(u(!0),d({at:t,step:0}))})(n)}else window.open(t,"_blank","noopener")},D=n?w+1:void 0;return Zt("div",{className:"slides-presenter",children:[Zt("div",{className:"slides-presenter-head",children:[Yt("span",{className:"slides-presenter-clock",children:p}),Zt("span",{children:[f.slideOf(w+1,e.length),N>0&&` · ${f.presenterStep(a.step,N)}`]}),Yt(Ot,{variant:"secondary",onClick:r,leftIcon:Yt(Ut,{name:"close",size:16}),children:f.endShow})]}),!l&&Yt("p",{className:"slides-presenter-blocked",children:f.popupBlocked}),Zt("div",{className:"slides-presenter-body",children:[Zt("div",{className:"slides-presenter-main",children:[Yt("div",{ref:b,className:"slides-presenter-current",children:Yt(h,{slide:x,width:v,number:D,motion:z,options:{onLink:I}})}),Zt("div",{className:"slides-presenter-steps",children:[Yt(Ot,{variant:"secondary",onClick:()=>y(-1),leftIcon:Yt(Ut,{name:"arrow-left",size:16}),children:f.back}),Yt(Ot,{variant:"secondary",onClick:()=>y(1),rightIcon:Yt(Ut,{name:"arrow-right",size:16}),children:f.next})]})]}),Zt("div",{className:"slides-presenter-side",children:[Yt("p",{className:"slides-presenter-label",children:f.nextSlide}),S?Yt(h,{slide:S,width:280,number:n?C+1:void 0}):Yt("p",{children:f.endOfDeck}),Yt("p",{className:"slides-presenter-label",children:f.notes}),Yt("p",{className:"slides-presenter-notes",children:x.notes||f.noNotes})]})]}),l&&Yt(Qt,{slide:x,popup:l,number:D,motion:z,fonts:i,transition:m&&0===a.step?x.transition:void 0,onLink:I,onAdvance:()=>y(1)})]})}import{useState as nn}from"react";import{SettingsColour as ln}from"efficient-easel/panel";import{Button as rn}from"efficient-shell/ui";import{IconButton as sn}from"efficient-shell/ui";import{Input as on}from"efficient-shell/ui";import{Select as an}from"efficient-shell/ui";import{Slider as dn}from"efficient-shell/ui";import{Switch as cn}from"efficient-shell/ui";import{Icon as mn}from"efficient-shell/icons";import{Fragment as un,jsx as hn,jsxs as pn}from"react/jsx-runtime";var fn=e=>e===te?"#ffffff":e;function bn({label:e,value:t,onChange:n}){return pn("label",{className:"slides-number",children:[hn("span",{children:e}),hn(on,{type:"number",value:Math.round(t),onChange:e=>{const t=Number(e.target.value);""!==e.target.value&&Number.isFinite(t)&&n(t)}})]})}function gn(e){return[{label:e.alignLeft,icon:"box-x-start",action:{kind:"align",to:"left"}},{label:e.alignCentre,icon:"box-x-center",action:{kind:"align",to:"center"}},{label:e.alignRight,icon:"box-x-end",action:{kind:"align",to:"right"}},{label:e.alignTop,icon:"box-y-start",action:{kind:"align",to:"top"}},{label:e.alignMiddle,icon:"box-y-center",action:{kind:"align",to:"middle"}},{label:e.alignBottom,icon:"box-y-end",action:{kind:"align",to:"bottom"}},{label:e.distributeAcross,icon:"box-x-between",action:{kind:"distribute",axis:"horizontal"}},{label:e.distributeDown,icon:"box-y-between",action:{kind:"distribute",axis:"vertical"}}]}function vn({chart:e,accents:t,onChange:n}){const i=c(),l=b(e),r="pie"===e.kind||"donut"===e.kind;return pn("div",{className:"slides-field",children:[hn("span",{children:i.values}),hn("div",{className:"slides-grid-edit",style:{gridTemplateColumns:`repeat(${l[0].length}, minmax(0, 1fr))`},children:l.map((r,s)=>r.map((r,o)=>hn("input",{"aria-label":0===s?i.seriesName:0===o?i.rows:`${l[0][o]} ${l[s][0]}`,className:"slides-grid-cell","data-head":0===s||0===o||void 0,value:r,disabled:0===s&&0===o,inputMode:s>0&&o>0?"decimal":void 0,onChange:i=>((i,r,s)=>n(k(e,l.map((e,t)=>e.map((e,n)=>t===i&&n===r?s:e)),t)))(s,o,i.target.value)},`${s}-${o}`)))}),pn("div",{className:"slides-actions",children:[!r&&hn(rn,{variant:"secondary",size:"sm",leftIcon:hn(mn,{name:"add",size:14}),onClick:()=>n(k(e,l.map((e,t)=>[...e,0===t?`${i.addSeries} ${e.length}`:"0"]),t)),children:i.addSeries}),hn(rn,{variant:"secondary",size:"sm",leftIcon:hn(mn,{name:"add",size:14}),onClick:()=>n(k(e,[...l,l[0].map((e,t)=>0===t?"":"0")],t)),children:i.addCategory})]})]})}function yn({slide:e,selected:t,onChangeSlide:n,onChangeSelected:i,onAlign:l,onForward:r,onDelete:s,onArrange:o,cells:a,accents:m=[]}){const u=c(),{pickImage:h}=d();if(0===t.length)return pn("aside",{className:"slides-inspector",children:[hn("h3",{children:u.slide}),pn("div",{className:"slides-section",children:[hn(ln,{label:u.background,value:e.background,onChange:e=>n({background:e})}),hn(cn,{label:u.skipSlide,checked:!!e.skip,onChange:e=>n({skip:e||void 0})})]})]});const p=1===t.length?t[0]:null,f={text:u.elementText,shape:u.elementShape,image:u.elementImage,video:u.elementVideo,connector:u.elementConnector,chart:u.elementChart,table:u.elementTable},g=e=>i(t=>({...t,...e})),v=e=>{o?o(e):"align"!==e.kind||"left"!==e.to&&"center"!==e.to&&"right"!==e.to?"order"===e.kind&&"forward"===e.to&&r():l(e.to)},y=t.some(e=>e.groupId),w=t.every(e=>e.locked);return pn("aside",{className:"slides-inspector",children:[hn("h3",{children:p?f[p.type]:u.objects(t.length)}),p&&"connector"!==p.type&&pn("div",{className:"slides-section",children:[hn("p",{className:"slides-label",children:u.positionAndSize}),pn("div",{className:"slides-numbers",children:[hn(bn,{label:"X",value:p.x,onChange:e=>g({x:e})}),hn(bn,{label:"Y",value:p.y,onChange:e=>g({y:e})}),hn(bn,{label:u.width,value:p.w,onChange:e=>g({w:Math.max(20,e)})}),hn(bn,{label:u.height,value:p.h,onChange:e=>g({h:Math.max(20,e)})}),hn(bn,{label:u.angle,value:p.rotation,onChange:e=>g({rotation:e})})]})]}),pn("div",{className:"slides-section",children:[hn("p",{className:"slides-label",children:u.align}),hn("div",{className:"slides-actions",children:gn(u).map(({label:e,icon:t,action:n})=>hn(sn,{"aria-label":e,size:"sm",onClick:()=>v(n),children:hn(mn,{name:t,size:16})},e))}),pn("div",{className:"slides-actions",children:[hn(sn,{"aria-label":u.bringToFront,size:"sm",onClick:()=>v({kind:"order",to:"front"}),children:hn(mn,{name:"move-up",size:16})}),hn(sn,{"aria-label":u.bringForward,size:"sm",onClick:()=>v({kind:"order",to:"forward"}),children:hn(mn,{name:"layers",size:16})}),hn(sn,{"aria-label":u.sendBackward,size:"sm",onClick:()=>v({kind:"order",to:"backward"}),children:hn(mn,{name:"arrow-down",size:16})}),hn(sn,{"aria-label":u.sendToBack,size:"sm",onClick:()=>v({kind:"order",to:"back"}),children:hn(mn,{name:"move-down",size:16})}),t.length>1&&!y&&hn(sn,{"aria-label":u.group,size:"sm",onClick:()=>v({kind:"group"}),children:hn(mn,{name:"rectangle-group",size:16})}),y&&hn(sn,{"aria-label":u.ungroup,size:"sm",onClick:()=>v({kind:"ungroup"}),children:hn(mn,{name:"detach",size:16})}),hn(sn,{"aria-label":w?u.unlock:u.lock,size:"sm",pressed:w,onClick:()=>v({kind:"lock",locked:!w}),children:hn(mn,{name:"lock",size:16})}),hn(sn,{"aria-label":u.delete,size:"sm",onClick:s,children:hn(mn,{name:"trash",size:16})})]})]}),"shape"===p?.type&&pn("div",{className:"slides-section",children:[hn(an,{"aria-label":u.elementShape,value:p.shape,onChange:e=>g({shape:e}),options:ne.map(e=>({value:e,label:u.shapeName(e)}))}),"line"!==p.shape&&hn(ln,{label:u.colour,value:fn(p.fill),onChange:e=>g({fill:e})}),(p.stroke||"line"===p.shape)&&hn(ln,{label:u.outlineColour,value:fn(p.stroke??p.fill),onChange:e=>g({stroke:e})}),"line"!==p.shape&&!p.stroke&&hn(rn,{variant:"secondary",size:"sm",onClick:()=>g({stroke:"#2c2c2a",strokeWidth:4}),children:u.outline}),(p.stroke||"line"===p.shape)&&hn(dn,{label:u.lineWidth,min:1,max:40,value:p.strokeWidth??4,onChange:e=>g({strokeWidth:e??4})}),"line"===p.shape&&pn(un,{children:[hn(cn,{label:u.arrowStart,checked:!!p.arrowStart,onChange:e=>g({arrowStart:e})}),hn(cn,{label:u.arrowEnd,checked:!!p.arrowEnd,onChange:e=>g({arrowEnd:e})})]})]}),"connector"===p?.type&&pn("div",{className:"slides-section",children:[hn(an,{"aria-label":u.route,value:p.route,onChange:e=>g({route:e}),options:[{value:"straight",label:u.routeStraight},{value:"elbow",label:u.routeElbow},{value:"curved",label:u.routeCurved}]}),hn(ln,{label:u.outlineColour,value:p.stroke,onChange:e=>g({stroke:e})}),hn(dn,{label:u.lineWidth,min:1,max:40,value:p.strokeWidth,onChange:e=>g({strokeWidth:e??4})}),hn(cn,{label:u.arrowStart,checked:!!p.arrowStart,onChange:e=>g({arrowStart:e})}),hn(cn,{label:u.arrowEnd,checked:!!p.arrowEnd,onChange:e=>g({arrowEnd:e})})]}),"image"===p?.type&&hn(kn,{element:p,pickImage:h,onChange:g,onChangeSelected:i}),"video"===p?.type&&pn("div",{className:"slides-section",children:[pn("label",{className:"slides-field",children:[hn("span",{children:u.videoAddress}),hn(on,{value:p.src,placeholder:"https://youtu.be/…",onChange:e=>g({src:e.target.value.trim()})}),hn("small",{children:u.videoHint})]}),pn("label",{className:"slides-field",children:[hn("span",{children:u.description}),hn(on,{value:p.alt,onChange:e=>g({alt:e.target.value})})]})]}),"chart"===p?.type&&pn("div",{className:"slides-section",children:[hn("p",{className:"slides-label",children:u.data}),hn(an,{"aria-label":u.chartType,value:p.kind,onChange:e=>g({kind:e}),options:[{value:"bar",label:u.chartBar},{value:"hbar",label:u.chartHbar},{value:"line",label:u.line},{value:"area",label:u.chartArea},{value:"pie",label:u.chartPie},{value:"donut",label:u.chartDonut}]}),hn(vn,{chart:p,accents:m,onChange:e=>i(()=>e)}),hn(an,{"aria-label":u.legend,value:p.legend??"auto",onChange:e=>g({legend:"auto"===e?void 0:e}),options:[{value:"auto",label:u.legend},{value:"bottom",label:u.legendBottom},{value:"right",label:u.legendRight},{value:"none",label:u.legendNone}]}),hn(ln,{label:u.colour,value:p.series?.[0]?.color??p.color,onChange:e=>i(t=>{const n=t,i=b(n);return k({...n,color:e,series:n.series?.map((t,n)=>0===n?{...t,color:e}:t)},i,m)})})]}),"table"===p?.type&&hn(wn,{table:p,cells:a??null,onChange:e=>i(()=>e)})]})}function kn({element:e,pickImage:t,onChange:n,onChangeSelected:i}){const l=c(),r=e.crop??{left:0,top:0,right:0,bottom:0};return pn("div",{className:"slides-section",children:[t?hn(rn,{variant:"secondary",block:!0,onClick:()=>{const{id:n}=e;t().then(e=>{e&&i(t=>t.id===n?{...t,src:e}:t)})},children:e.src?l.replaceImage:l.chooseImage}):pn("label",{className:"slides-field",children:[hn("span",{children:l.imageAddress}),hn(on,{value:e.src,onChange:e=>n({src:e.target.value})})]}),pn("label",{className:"slides-field",children:[hn("span",{children:l.description}),hn(on,{value:e.alt,onChange:e=>n({alt:e.target.value})})]}),hn("p",{className:"slides-label",children:l.crop}),["left","top","right","bottom"].map(e=>hn(dn,{label:l[{left:"cropLeft",top:"cropTop",right:"cropRight",bottom:"cropBottom"}[e]],min:0,max:45,suffix:"%",value:Math.round(100*r[e]),onChange:t=>((e,t)=>{const i={...r,[e]:Math.max(0,Math.min(.45,(t??0)/100))};n({crop:i.left||i.top||i.right||i.bottom?i:void 0})})(e,t)},e)),hn(dn,{label:l.opacity,min:0,max:100,suffix:"%",value:Math.round(100*(e.opacity??1)),onChange:e=>n({opacity:null===e||e>=100?void 0:e/100})})]})}function wn({table:e,cells:t,onChange:n}){const i=c(),[l]=nn(i.cellEditHint),r=t??{row:e.rows.length-1,col:(e.rows[0]?.length??1)-1,rows:1,cols:1},s=N(e,r.row,r.col);return pn("div",{className:"slides-section",children:[hn("small",{className:"slides-hint",children:l}),pn("div",{className:"slides-actions slides-actions-words",children:[hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(C(e,r.row)),children:i.insertRowAbove}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(C(e,r.row+r.rows)),children:i.insertRowBelow}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(x(e,r.col)),children:i.insertColumnLeft}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(x(e,r.col+r.cols)),children:i.insertColumnRight}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(j(e,r.row)),children:i.deleteRow}),hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(L(e,r.col)),children:i.deleteColumn}),t&&t.rows*t.cols>1&&hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(z(e,t)),children:i.mergeCells}),s&&hn(rn,{variant:"secondary",size:"sm",onClick:()=>n(q(e,r.row,r.col)),children:i.unmergeCells})]}),hn(ln,{label:i.headingColour,value:fn(e.headerFill),onChange:t=>n({...e,headerFill:t})}),hn(ln,{label:i.borderColour,value:e.borderColor??"#b4b2a9",onChange:t=>n({...e,borderColor:t})}),hn(dn,{label:i.borderWidth,min:0,max:12,value:e.borderWidth??2,onChange:t=>n({...e,borderWidth:t??2})})]})}import{useState as xn}from"react";import{Button as Cn}from"efficient-shell/ui";import{IconButton as Sn}from"efficient-shell/ui";import{Icon as Nn}from"efficient-shell/icons";import{jsx as zn,jsxs as In}from"react/jsx-runtime";function Dn({slides:e,currentId:t,onShow:n,onAdd:i,onMove:l,onDuplicate:r,onDelete:s,onSkip:o,numbers:a,visitors:d=[]}){const[m,u]=xn(null),p=c();return In("nav",{className:"slides-rail","aria-label":p.slidesPanel,children:[e.map((e,i)=>In("div",{className:"slides-thumb","data-current":e.id===t||void 0,"data-skipped":e.skip||void 0,draggable:!0,onDragStart:()=>u(e.id),onDragEnd:()=>u(null),onDragOver:e=>e.preventDefault(),onDrop:()=>{m&&m!==e.id&&l(m,i),u(null)},children:[zn("span",{className:"slides-thumb-number",children:i+1}),In("div",{role:"button",tabIndex:0,"aria-label":p.slideNumber(i+1),"aria-current":e.id===t,className:"slides-thumb-image",onClick:()=>n(e.id),onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),n(e.id))},children:[zn(h,{slide:e,width:132,number:a?i+1:void 0}),e.skip&&zn("span",{className:"slides-thumb-skip",title:p.skipped,children:zn(Nn,{name:"eye-off",size:14})}),zn("span",{className:"slides-thumb-visitors",children:d.filter(t=>t.slide===e.id).map(e=>zn("span",{title:e.user.name,style:{background:e.color}},e.key))})]}),e.id===t&&In("div",{className:"slides-thumb-actions",children:[zn(Sn,{"aria-label":p.duplicateSlide,size:"sm",onClick:()=>r(e.id),children:zn(Nn,{name:"copy",size:14})}),o&&zn(Sn,{"aria-label":e.skip?p.unskipSlide:p.skipSlide,size:"sm",pressed:!!e.skip,onClick:()=>o(e.id),children:zn(Nn,{name:"eye-off",size:14})}),zn(Sn,{"aria-label":p.deleteSlide,size:"sm",onClick:()=>s(e.id),children:zn(Nn,{name:"trash",size:14})})]})]},e.id)),zn(Cn,{variant:"secondary",block:!0,onClick:i,children:p.addSlide})]})}import{useLayoutEffect as Mn,useRef as En,useState as An}from"react";function Pn(e,t){const n=[...e.elements];for(let e=1;e<n.length;e+=1)t.has(n[e].id)&&!t.has(n[e-1].id)&&([n[e],n[e-1]]=[n[e-1],n[e]]);return{...e,elements:n}}function Fn(e,t){const n=e.elements.filter(e=>!t.has(e.id));return{...e,elements:[...n,...e.elements.filter(e=>t.has(e.id))]}}function Tn(e,t){const n=e.elements.filter(e=>!t.has(e.id));return{...e,elements:[...e.elements.filter(e=>t.has(e.id)),...n]}}var Ln={x:0,y:0,w:le,h:ie};function jn(e,t){const n=new Set(e.elements.filter(e=>t.has(e.id)&&e.groupId).map(e=>e.groupId));return new Set(e.elements.filter(e=>t.has(e.id)||e.groupId&&n.has(e.groupId)).map(e=>e.id))}var $n="efficient-office/slide-elements";function Bn(e){try{const t=JSON.parse(e);return t?.type===$n&&Array.isArray(t.elements)?t.elements:null}catch{return null}}function Rn(e,t){const n=new Map(t.map(e=>[e.id,fe()])),i=new Map,l=t.some(t=>e.elements.some(e=>e.id===t.id))?40:0,r=t.map(e=>{const t={...ye(e,l,l),id:n.get(e.id),locked:void 0};var r;if(e.groupId&&(t.groupId=(r=e.groupId,i.has(r)||i.set(r,fe()),i.get(r))),"connector"===t.type){const e=({attach:e,...t})=>{const i=e&&n.get(e.id);return i?{...t,attach:{...e,id:i}}:t};return{...t,start:e(t.start),end:e(t.end)}}return t});return{slide:{...e,elements:[...e.elements,...r]},ids:r.map(e=>e.id)}}import{useEffect as Wn,useLayoutEffect as On,useRef as Kn}from"react";import{registerModalEscapeInterceptor as Un}from"efficient-shell/ui";import{jsx as Hn}from"react/jsx-runtime";var Vn=e=>e.reduce((e,t)=>e+t.runs.reduce((e,t)=>e+t.text.length,0),0)+e.length-1;function _n({element:e,onCommit:t,onEnd:n,onEditing:i,onLinkShortcut:l}){const r=c(),s=Kn(null),o=Kn(A(e)),a=Kn({start:0,end:Vn(o.current)}),d=Kn(t);d.current=t;const m=Kn(n);m.current=n;const u=Kn(i);u.current=i;const h=()=>{const t=s.current;t&&(t.innerHTML=y(e,o.current))},b=()=>{const{start:e,end:t}=a.current,n=o.current,i=e!==t,{runs:l,...r}=n[E(n,e,t)[0]??0]??{runs:[]};u.current({style:i?V(n,e,t):V(n,0,Vn(n)),paragraph:r,hasRange:i,applyRun:e=>g((t,n,i)=>n===i?p(t,0,Vn(t),e):p(t,n,i,e)),applyParagraph:e=>g((t,n,i)=>O(t,n,i,e)),toggleList:e=>g((t,n,i)=>_(t,n,i,e)),indent:e=>g((t,n,i)=>w(t,n,i,e))})},g=e=>{const t=s.current;if(!t)return;const{start:n,end:i}=a.current;o.current=e(o.current,n,i),h(),t.focus(),$(t,n,i),b()};return On(()=>{const e=s.current;if(!e)return;h(),e.focus();const t=Vn(o.current);$(e,0,t),a.current={start:0,end:t},b()},[]),Wn(()=>Un(()=>!!s.current?.contains(s.current.ownerDocument.activeElement)&&(m.current(),!0)),[]),Wn(()=>{const e=s.current;if(!e)return;const t=e.ownerDocument,n=()=>{const t=B(e);t&&(a.current=t,b())};return t.addEventListener("selectionchange",n),()=>{t.removeEventListener("selectionchange",n),u.current(null),d.current(o.current)}},[]),Hn("div",{ref:s,contentEditable:!0,role:"textbox","aria-multiline":"true","aria-label":r.slideText,suppressContentEditableWarning:!0,className:"slides-text-edit",style:{...f(e),display:"flex",flexDirection:"column",justifyContent:{top:"flex-start",middle:"center",bottom:"flex-end"}[e.anchor??"top"]},onPointerDown:e=>e.stopPropagation(),onInput:()=>{const e=s.current,t=o.current,n=F(e);o.current=n;if((n.some(e=>e.list)||t.some(e=>e.list))&&n.length!==t.length){const t=B(e)??a.current;h(),$(e,t.start,t.end)}},onPaste:e=>{e.preventDefault();const t=e.clipboardData.getData("text/plain");s.current?.ownerDocument.execCommand("insertText",!1,t)},onKeyDown:e=>{e.stopPropagation();const t=e.metaKey||e.ctrlKey,n=e.key.toLowerCase(),i=V(o.current,a.current.start,a.current.end);t&&"b"===n?(e.preventDefault(),g((e,t,n)=>p(e,t,n,{bold:!i.bold}))):t&&"i"===n?(e.preventDefault(),g((e,t,n)=>p(e,t,n,{italic:!i.italic||void 0}))):t&&"u"===n?(e.preventDefault(),g((e,t,n)=>p(e,t,n,{underline:!i.underline||void 0}))):t&&"k"===n?(e.preventDefault(),l?.()):"Tab"===e.key?(e.preventDefault(),g((t,n,i)=>w(t,n,i,e.shiftKey?-1:1))):"Escape"===e.key&&m.current()}})}import{Fragment as Jn,jsx as qn,jsxs as Xn}from"react/jsx-runtime";var Gn={x:[],y:[]};function Qn({text:e,onDone:t}){const n=En(null);return Mn(()=>{const t=n.current;t&&(t.innerText=e,t.focus(),t.ownerDocument.getSelection()?.selectAllChildren(t))},[]),qn("div",{ref:n,contentEditable:"plaintext-only",role:"textbox",suppressContentEditableWarning:!0,className:"slides-cell-edit",onPointerDown:e=>e.stopPropagation(),onBlur:e=>t(e.currentTarget.innerText.replace(/\n+$/,"")),onKeyDown:e=>{e.stopPropagation(),"Escape"===e.key&&t(null),"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e.currentTarget.blur())}})}function Yn({slide:e,selected:t,onSelect:n,onLive:i,onSettle:l,onCommit:r,onEditing:s,onLink:o,cells:a,onCells:d,onContextMenu:c,visitors:m=[],pins:u=[],onPin:p,grid:f,slideNumber:b}){const g=En(null),[v,y]=An(0),[k,w]=An(Gn),[x,C]=An(null),[S,N]=An(null),[z,I]=An(null),M=En(null);Mn(()=>{const e=g.current;if(!e)return;const t=()=>{y(Math.max(0,Math.min(e.clientWidth-48,(e.clientHeight-48)*le/ie)))};t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);const E=v/le,P=En(null),F=e=>{const t=P.current?.getBoundingClientRect();return{x:(e.clientX-(t?.left??0))/E,y:(e.clientY-(t?.top??0))/E}},L=(t,n,i=!1)=>{for(let l=e.elements.length-1;l>=0;l-=1){const r=e.elements[l];if(r.locked&&!i)continue;const s=-r.rotation*Math.PI/180,o=t-(r.x+r.w/2),a=n-(r.y+r.h/2),d=o*Math.cos(s)-a*Math.sin(s),c=o*Math.sin(s)+a*Math.cos(s);if(Math.abs(d)<=r.w/2&&Math.abs(c)<=r.h/2)return r}return null},j=(e,t)=>{e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),M.current=t},$=l=>{const r=M.current;if(!r)return;const{x:s,y:o}=F(l);if("marquee"===r.kind){const t={x:Math.min(r.px,s),y:Math.min(r.py,o),w:Math.abs(s-r.px),h:Math.abs(o-r.py)};C(t);const i=new Set(e.elements.filter(e=>!e.locked&&ae(t,e)).map(e=>e.id));n(jn(e,i))}else if("move"===r.kind){const e=r.start.elements.filter(e=>t.has(e.id)),n=r.start.elements.filter(e=>!t.has(e.id)),a=oe(e),d={...a,x:a.x+s-r.px,y:a.y+o-r.py},c=l.altKey?{box:d,guides:Gn}:ke(d,n);w(c.guides);const m=c.box.x-a.x,u=c.box.y-a.y;i(T(we(r.start,t,e=>ye(e,m,u)),t))}else if("resize"===r.kind){const e=we(r.start,new Set([r.id]),e=>{const t=-e.rotation*Math.PI/180,n=s-r.px,i=o-r.py,a=n*Math.cos(t)-i*Math.sin(t),d=n*Math.sin(t)+i*Math.cos(t);return{...e,...ve(e,r.handle,a,d,l.shiftKey)}});i(T(e))}else if("rotate"===r.kind){const e=we(r.start,new Set([r.id]),e=>({...e,rotation:re(e,s,o,l.shiftKey)}));i(T(e))}else{const e=r.start.elements.find(e=>e.id===r.id&&"connector"===e.type);if(!e)return;const t=l.altKey?null:D(r.start.elements,s,o,e.id),n=t?{x:t.x,y:t.y,attach:{id:t.id,side:t.side}}:{x:s,y:o},a="start"===r.end?n:e.start,d="end"===r.end?n:e.end;i(we(r.start,new Set([e.id]),()=>G(e,a,d)))}},B=()=>{const e=M.current;M.current=null,w(Gn),C(null),e&&"marquee"!==e.kind&&l()},R=e.elements.filter(e=>t.has(e.id)),O=1===R.length?R[0]:void 0,K=e.elements.find(e=>e.id===S&&"text"===e.type),U=En({slide:e,onCommit:r});U.current={slide:e,onCommit:r};const H=(e,t=null,n="slides-selection",i)=>Xn("div",{className:n,style:{left:e.x*E,top:e.y*E,width:e.w*E,height:e.h*E,transform:e.rotation?`rotate(${e.rotation}deg)`:void 0,...i?{borderColor:i.color}:{}},children:[i&&qn("span",{className:"slides-visitor-name",style:{background:i.color},children:i.name}),t]},`${n}-${e.id}-${i?.name??""}`),V="table"===O?.type?O:null;return qn("div",{ref:g,className:"slides-pane",children:Xn("div",{ref:P,className:"slides-stage",style:{width:v,height:v*ie/le},onPointerDown:i=>{if(0!==i.button)return;S&&N(null);const{x:l,y:r}=F(i),s=L(l,r);if(!s)return i.shiftKey||n(new Set),d(null),void j(i,{kind:"marquee",px:l,py:r});if("table"===s.type&&t.has(s.id)&&1===t.size){const e=i.target.closest("[data-cell]")?.dataset.cell;if(e){const[t,n]=e.split(":").map(Number);if(i.shiftKey&&a){const e=Math.min(a.row,t),i=Math.min(a.col,n);return void d({row:e,col:i,rows:Math.max(a.row+a.rows-1,t)-e+1,cols:Math.max(a.col+a.cols-1,n)-i+1})}d({row:t,col:n,rows:1,cols:1})}}else d(null);let o=t;const c=jn(e,new Set([s.id]));if(i.shiftKey){const e=new Set(t),i=!e.has(s.id);for(const t of c)i?e.add(t):e.delete(t);o=e,n(e)}else t.has(s.id)||(o=c,n(o));o.has(s.id)&&j(i,{kind:"move",start:e,px:l,py:r})},onPointerMove:$,onPointerUp:B,onPointerCancel:B,onContextMenu:i=>{const{x:l,y:r}=F(i),s=L(l,r,!0);s&&!t.has(s.id)&&n(jn(e,new Set([s.id]))),c(i,s?.id??null)},onDoubleClick:e=>{const{x:t,y:i}=F(e),l=L(t,i);if("text"===l?.type)n(new Set([l.id])),N(l.id);else if("table"===l?.type){const t=e.target.closest("[data-cell]")?.dataset.cell;if(t){const[e,n]=t.split(":").map(Number);I({id:l.id,row:e,col:n})}}},children:[qn(h,{slide:e,width:v,number:b,editingId:K?.id,options:V?{cellEditor:(J=V,(t,n)=>z&&z.id===J.id&&z.row===t&&z.col===n?qn(Qn,{text:J.rows[t][n],onDone:i=>{I(null),null!==i&&i!==J.rows[t][n]&&r(we(e,new Set([J.id]),()=>W(J,t,n,i)))}}):void 0)}:void 0,editor:K&&qn(_n,{element:K,onCommit:(_=K.id,e=>{const{slide:t,onCommit:n}=U.current,i=t.elements.find(e=>e.id===_&&"text"===e.type);if(!i)return;const l=Q(i,e);JSON.stringify(l.paragraphs)===JSON.stringify(A(i))&&l.text===i.text||n(we(t,new Set([_]),()=>l))}),onEnd:()=>N(null),onEditing:s,onLinkShortcut:o},K.id)}),f&&qn("div",{className:"slides-grid",style:{backgroundSize:`${60*E}px ${60*E}px`}}),m.flatMap(t=>e.elements.filter(e=>t.selected.includes(e.id)).map(e=>H(e,null,"slides-visitor",t))),!K&&R.map(t=>H(t,O?.id!==t.id||t.locked?t.locked?qn("span",{className:"slides-lock","aria-hidden":"true"}):null:(t=>"connector"===t.type?["start","end"].map(n=>{const i=t[n];return qn("div",{className:"slides-handle slides-end","data-held":i.attach?"":void 0,style:{left:(i.x-t.x)*E,top:(i.y-t.y)*E},onPointerDown:i=>j(i,{kind:"end",start:e,id:t.id,end:n}),onPointerMove:$,onPointerUp:B,onPointerCancel:B},n)}):Xn(Jn,{children:[ee.map(n=>qn("div",{className:`slides-handle slides-handle-${n}`,onPointerDown:i=>j(i,{kind:"resize",start:e,id:t.id,handle:n,...ei(F(i))}),onPointerMove:$,onPointerUp:B,onPointerCancel:B},n)),qn("div",{className:"slides-rotate-stem"}),qn("div",{className:"slides-rotate",onPointerDown:n=>j(n,{kind:"rotate",start:e,id:t.id}),onPointerMove:$,onPointerUp:B,onPointerCancel:B})]}))(t))),V&&a&&qn("div",{className:"slides-cells","aria-hidden":"true",style:Zn(P.current,V,a,E)}),u.map(e=>qn("button",{type:"button",className:"slides-pin",style:{left:e.x*E,top:e.y*E},onPointerDown:e=>e.stopPropagation(),onClick:()=>p?.(e.id),children:e.count},e.id)),k.x.map(e=>qn("div",{className:"slides-guide slides-guide-x",style:{left:e*E}},`x${e}`)),k.y.map(e=>qn("div",{className:"slides-guide slides-guide-y",style:{top:e*E}},`y${e}`)),x&&qn("div",{className:"slides-marquee",style:{left:x.x*E,top:x.y*E,width:x.w*E,height:x.h*E}})]})});var _,J}function Zn(e,t,n,i){const l=e?.querySelector(`[data-element="${CSS.escape(t.id)}"] [data-cell="${n.row}:${n.col}"]`),r=e?.querySelector(`[data-element="${CSS.escape(t.id)}"] [data-cell="${n.row+n.rows-1}:${n.col+n.cols-1}"]`)??l;if(!e||!l||!r)return{display:"none"};const s=e.getBoundingClientRect(),o=l.getBoundingClientRect(),a=r.getBoundingClientRect();return{left:o.left-s.left,top:o.top-s.top,width:a.right-o.left,height:a.bottom-o.top}}var ei=({x:e,y:t})=>({px:e,py:t});import{ColorPicker as ti,DropdownMenu as ni,IconButton as ii,prompt as li,Select as ri}from"efficient-shell/ui";import{Icon as si}from"efficient-shell/icons";import{toast as oi}from"efficient-shell";import{jsx as ai,jsxs as di}from"react/jsx-runtime";var ci=[12,16,20,24,28,32,40,48,56,64,72,96,120,160],mi=[1,1.15,1.25,1.5,2];function ui({element:e,editing:t,slides:n,accents:i,onBox:l}){const r=c(),s=A(e),o=P(s).length,a=t?t.style:V(s,0,o),d=t?t.paragraph:s[0]??{runs:[]},m=a.size??(t?.hasRange?void 0:e.fontSize)??e.fontSize,u=a.font??e.font??Z[0],h=a.bold??e.bold,f=e=>{t?t.applyRun(e):l(t=>{const n={},i={...e};"size"in e&&e.size&&(n.fontSize=e.size,i.size=void 0),"bold"in e&&(n.bold=!!e.bold,i.bold=void 0),"color"in e&&e.color&&(n.color=e.color,i.color=void 0),"font"in e&&e.font&&(n.font=e.font,i.font=void 0);const l=A(t);return Q({...t,...n},p(l,0,P(l).length,i))})},b=e=>{t?t.applyParagraph(e):l(t=>Q(t,O(A(t),0,Number.MAX_SAFE_INTEGER,e)))},g=e=>{t?t.toggleList(e):l(t=>Q(t,_(A(t),0,Number.MAX_SAFE_INTEGER,e)))},v=e=>{t?t.indent(e):l(t=>Q(t,w(A(t),0,Number.MAX_SAFE_INTEGER,e)))},y=async()=>{const e=await li({title:r.link,message:r.linkPrompt,allowEmpty:!0,defaultValue:a.link?.startsWith("#slide=")?"":a.link??""});if(null==e)return;if(!e.trim())return void f({link:void 0});const t=function(e,t){const n=e.trim();if(!n)return null;if(/^\d+$/.test(n)){const e=t[Number(n)-1];return e?`#slide=${e.id}`:null}return/^(https?:\/\/|mailto:)/i.test(n)?n:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?`mailto:${n}`:/^[\w-]+(\.[\w-]+)+(\/\S*)?$/.test(n)?`https://${n}`:null}(e,n);t?f({link:t}):oi.error(r.badLink)},k=e=>{const t=ci.findIndex(e=>e>=m),n=-1===t?ci.length-1:1===e?ci[t]>m?t:t+1:t-1;return ci[Math.max(0,Math.min(ci.length-1,n))]},x=d.align??e.align,C=(e,t,n,i)=>ai(ii,{"aria-label":e,size:"sm",pressed:i,onClick:n,children:ai(si,{name:t,size:16})},e);return di("div",{className:"slides-toolbar slides-texttools","data-text-toolbar":"",onMouseDown:e=>{e.target.closest('input, select, [role="combobox"], [role="listbox"]')||e.preventDefault()},children:[ai("div",{className:"slides-tool-font",children:ai(ri,{"aria-label":r.font,size:"sm",value:u,onChange:e=>f({font:String(e)}),options:Z.map(e=>({value:e,label:e}))})}),C(r.smaller,"remove",()=>f({size:k(-1)})),ai("div",{className:"slides-tool-size",children:ai(ri,{"aria-label":r.fontSize,size:"sm",value:String(Math.round(m)),onChange:e=>f({size:Number(e)}),options:[...new Set([...ci,Math.round(m)])].sort((e,t)=>e-t).map(e=>({value:String(e),label:String(e)}))})}),C(r.larger,"add",()=>f({size:k(1)})),ai("span",{className:"slides-tool-gap"}),C(r.bold,"bold",()=>f({bold:!h}),h),C(r.italic,"italic",()=>f({italic:!a.italic||void 0}),!!a.italic),C(r.underline,"underline",()=>f({underline:!a.underline||void 0}),!!a.underline),C(r.strikethrough,"strike",()=>f({strike:!a.strike||void 0}),!!a.strike),ai(ti,{label:r.textColour,size:"sm",value:a.color??e.color,presets:i,onChange:e=>f({color:e})}),ai(ti,{label:r.highlight,size:"sm",value:a.highlight??"#ffffff",presets:["#fac775","#c0dd97","#b5d4f4","#f4c0d1"],clearable:!0,onChange:e=>f({highlight:e||void 0})}),C(r.link,"link",()=>{y()},!!a.link),ai("span",{className:"slides-tool-gap"}),C(r.alignLeft,"align-left",()=>b(e=>({...e,align:"left"})),"left"===x),C(r.alignCentre,"align-center",()=>b(e=>({...e,align:"center"})),"center"===x),C(r.alignRight,"align-right",()=>b(e=>({...e,align:"right"})),"right"===x),C(r.alignJustify,"align-justify",()=>b(e=>({...e,align:"justify"})),"justify"===x),ai("span",{className:"slides-tool-gap"}),C(r.bulletList,"list",()=>g("bullet"),"bullet"===d.list),C(r.numberedList,"numbered-list",()=>g("number"),"number"===d.list),C(r.indentLess,"chevron-left",()=>v(-1)),C(r.indentMore,"chevron-right",()=>v(1)),ai(ni,{"aria-label":r.lineSpacing,trigger:ai(si,{name:"line-spacing",size:16}),items:mi.map(e=>({type:"radio",key:String(e),label:String(e),checked:(d.lineHeight??1.25)===e,onSelect:()=>b(t=>({...t,lineHeight:1.25===e?void 0:e}))}))}),ai(ni,{"aria-label":r.verticalAlign,trigger:ai(si,{name:"v-align",size:16}),items:[...["top","middle","bottom"].map(t=>({type:"radio",key:t,label:r[t],checked:(e.anchor??"top")===t,onSelect:()=>l(e=>({...e,anchor:t}))})),{type:"divider",key:"d"},{type:"checkbox",key:"fit",label:r.shrinkToFit,checked:!!e.autofit,onSelect:()=>l(e=>({...e,autofit:!e.autofit||void 0}))}]})]})}import{SettingsColour as hi}from"efficient-easel/panel";import{Select as pi,Switch as fi}from"efficient-shell/ui";import{jsx as bi,jsxs as gi}from"react/jsx-runtime";function vi({doc:e,slide:t,onTheme:i,onDeck:l,onSlide:r}){const a=c(),d=o(e),m=e=>i({...d,...e,id:n.some(t=>t.id===d.id&&JSON.stringify({...t,...e})===JSON.stringify(t))?d.id:"custom"}),u={title:"Aa",subtitle:"",body:""};return gi("aside",{className:"slides-inspector",children:[bi("h3",{children:a.theme}),bi("div",{className:"slides-section",children:bi("div",{className:"slides-themes",children:n.map(e=>gi("button",{type:"button",className:"slides-theme-tile","aria-pressed":e.id===d.id,onClick:()=>i(e),children:[bi(h,{slide:{...s("title",e,u),elements:s("title",e,u).elements.slice(0,1)},width:96}),bi("span",{children:a.themeName(e.id)})]},e.id))})}),gi("div",{className:"slides-section",children:[bi("p",{className:"slides-label",children:a.colours}),bi(hi,{label:a.background,value:d.background,onChange:e=>m({background:e})}),bi(hi,{label:a.headingFont,value:d.heading,onChange:e=>m({heading:e})}),bi(hi,{label:a.bodyFont,value:d.text,onChange:e=>m({text:e})}),bi("div",{className:"slides-swatches","aria-hidden":"true",children:d.accents.map(e=>bi("span",{style:{background:e}},e))})]}),gi("div",{className:"slides-section",children:[bi(pi,{"aria-label":a.headingFont,value:d.headingFont,onChange:e=>m({headingFont:String(e)}),options:Z.map(e=>({value:e,label:`${a.headingFont}: ${e}`}))}),bi(pi,{"aria-label":a.bodyFont,value:d.bodyFont,onChange:e=>m({bodyFont:String(e)}),options:Z.map(e=>({value:e,label:`${a.bodyFont}: ${e}`}))})]}),gi("div",{className:"slides-section",children:[bi(fi,{label:a.slideNumbers,checked:!!e.slideNumbers,onChange:e=>l({slideNumbers:e||void 0})}),bi(fi,{label:a.skipSlide,checked:!!t.skip,onChange:e=>r({skip:e||void 0})})]})]})}import{useEffect as yi,useRef as ki,useState as wi}from"react";var xi=["#1d9e75","#d85a30","#378add","#d4537e","#ba7517","#639922","#7f77dd","#993c1d"];function Ci(e){let t=0;for(const n of e)t=31*t+n.charCodeAt(0)>>>0;return xi[t%xi.length]}var Si=13.333,Ni=e=>e/le*Si,zi=e=>e.replace("#","").toUpperCase(),Ii=e=>Math.round(72*Ni(e));function Di(e){return`${e.replace(/[^\p{L}\p{N} _-]+/gu," ").replace(/ +/g," ").trim()||"Deck"}.pptx`}var Mi=e=>e===te?{type:"none"}:{color:zi(e)},Ei=e=>e.stroke?{color:zi(e.stroke),width:Ii(e.strokeWidth??1)}:void 0;function Ai(e,t,n,i){const l=e.cellFills?.[n]?.[i]??(0===n?e.headerFill:null),r=e.cellColors?.[n]?.[i]??(0===n?e.headerColor:void 0),s=e.merges?.find(e=>e.row===n&&e.col===i);return{text:t,options:{...0===n?{bold:!0}:{},...l?{fill:Mi(l)}:{},...r?{color:zi(r)}:{},...s?{rowspan:s.rows,colspan:s.cols}:{}}}}var Pi={bar:"bar",hbar:"bar",line:"line",area:"area",pie:"pie",donut:"doughnut"};function Fi(e,t,n){const i={x:Ni(n.x),y:Ni(n.y),w:Ni(n.w),h:Ni(n.h),rotate:n.rotation};switch(n.type){case"text":!function(e,t,n){const i=A(t),l=S(i),r=[];i.forEach((e,n)=>{const s=e.runs.length>0?e.runs:[{text:""}];s.forEach((o,a)=>{const d=a===s.length-1;r.push({text:o.text,options:{bold:o.bold??t.bold,italic:o.italic,underline:o.underline||o.link?{style:"sng"}:void 0,strike:o.strike?"sngStrike":void 0,color:zi(o.color??t.color),highlight:o.highlight?zi(o.highlight):void 0,fontSize:Ii(o.size??t.fontSize),fontFace:o.font??t.font??Y,hyperlink:o.link&&!o.link.startsWith("#")?{url:o.link}:void 0,align:e.align??t.align,bullet:l[n]?"number"!==e.list||{type:"number"}:void 0,indentLevel:e.level||void 0,lineSpacingMultiple:e.lineHeight,breakLine:d&&n<i.length-1}})})}),e.addText(r,{...n,valign:t.anchor??"top",margin:0,fit:t.autofit?"shrink":void 0})}(t,n,i);break;case"shape":!function(e,t,n,i){"line"!==n.shape?t.addShape(u[n.shape],{...i,fill:Mi(n.fill),line:Ei(n),rectRadius:"roundRect"===n.shape&&void 0!==n.radius?Ni(n.radius):void 0}):t.addShape(e.ShapeType.line,{...i,y:i.y+i.h/2,h:0,line:{color:zi(n.stroke??n.fill),width:Ii(n.strokeWidth??1),beginArrowType:n.arrowStart?"triangle":"none",endArrowType:n.arrowEnd?"triangle":"none"}})}(e,t,n,i);break;case"image":{if(!n.src)break;const e=n.crop;t.addImage({...i,path:n.src,altText:n.alt,transparency:void 0!==n.opacity?Math.round(100*(1-n.opacity)):void 0,...e&&(e.left||e.top||e.right||e.bottom)?{sizing:{type:"crop",x:Ni(n.w*e.left/Math.max(.05,1-e.left-e.right)),y:Ni(n.h*e.top/Math.max(.05,1-e.top-e.bottom)),w:i.w,h:i.h}}:{}});break}case"video":{const e=X(n.src);"youtube"===e?.kind?t.addMedia({...i,type:"online",link:`https://www.youtube.com/embed/${e.id}`}):n.src&&t.addText([{text:n.alt||n.src,options:{hyperlink:{url:n.src}}}],{...i,align:"center",valign:"middle",fill:{color:"2C2C2A"},color:"FFFFFF"});break}case"connector":!function(e,t,n){const i={color:zi(n.stroke),width:Ii(n.strokeWidth),beginArrowType:n.arrowStart?"triangle":"none",endArrowType:n.arrowEnd?"triangle":"none"};if("straight"===n.route){const l=Math.min(n.start.x,n.end.x),r=Math.min(n.start.y,n.end.y);return void t.addShape(e.ShapeType.line,{x:Ni(l),y:Ni(r),w:Ni(Math.abs(n.end.x-n.start.x)),h:Ni(Math.abs(n.end.y-n.start.y)),flipH:n.end.x<n.start.x!=n.end.y<n.start.y&&n.end.x<n.start.x,flipV:n.end.x<n.start.x!=n.end.y<n.start.y&&n.end.y<n.start.y,line:i})}const l=v(n),r=l.match(/-?\d+(\.\d+)?/g)?.map(Number)??[],s=[];if("elbow"===n.route){let e=r[0],t=r[1];s.push({x:e,y:t});for(const n of l.slice(l.indexOf(" ")+1).split(" ")){const i=Number(n.slice(1));"H"===n[0]?e=i:t=i,s.push({x:e,y:t})}}else{const[e,t,n,i,l,o,a,d]=r;for(let r=0;r<=16;r+=1){const c=r/16,m=1-c;s.push({x:m*m*m*e+3*m*m*c*n+3*m*c*c*l+c*c*c*a,y:m*m*m*t+3*m*m*c*i+3*m*c*c*o+c*c*c*d})}}t.addShape("custGeom",{x:Ni(n.x),y:Ni(n.y),w:Ni(n.w),h:Ni(n.h),points:s.map((e,t)=>0===t?{x:Ni(e.x),y:Ni(e.y),moveTo:!0}:{x:Ni(e.x),y:Ni(e.y)}),line:i})}(e,t,n);break;case"chart":!function(e,t,n,i){const{categories:l,series:r}=R(n),s="pie"===n.kind||"donut"===n.kind,o=(s?r.slice(0,1):r).map(e=>({name:e.name||" ",labels:l,values:e.values})),a=n.legend??(s||r.length>1?"bottom":"none");t.addChart(Pi[n.kind],o,{...i,barDir:"hbar"===n.kind?"bar":"col",chartColors:s?void 0:r.map(e=>zi(e.color)),showValue:1===r.length&&!s,showPercent:s,showLegend:"none"!==a,legendPos:"right"===a?"r":"b"})}(0,t,n,i);break;case"table":!function(e,t,n){const{columnWidths:i,rowHeights:l,fontSize:r}=t,s=t.rows.map((e,n)=>e.flatMap((e,i)=>((e,t,n)=>e.merges?.some(e=>t>=e.row&&t<e.row+e.rows&&n>=e.col&&n<e.col+e.cols&&(t!==e.row||n!==e.col)))(t,n,i)?[]:[Ai(t,e,n,i)])),o=t.borderWidth??2;e.addTable(s,{...n,border:o?{type:"solid",color:zi(t.borderColor??"#B4B2A9"),pt:Math.max(.25,Ii(o))}:{type:"none"},...r?{fontSize:Ii(r)}:{},...i?{colW:i.map(e=>e*n.w)}:{},...l?{rowH:l.map(Ni)}:{}})}(t,n,i)}}async function Ti(e,t){const n=await async function(e,t){const{default:n}=await(import("pptxgenjs")),i=new n;return i.defineLayout({name:"SLIDE_16_9",width:Si,height:7.5}),i.layout="SLIDE_16_9",i.title=e,t.slides.forEach(e=>{const n=i.addSlide();n.background={color:zi(e.background)},e.skip&&(n.hidden=!0),e.notes&&n.addNotes(e.notes);for(const t of e.elements)Fi(i,n,t);t.slideNumbers&&(n.slideNumber={x:Ni(1780),y:Ni(1010),fontSize:11,color:"888780"})}),i}(e,t);await n.writeFile({fileName:Di(e)})}import{jsx as Li,jsxs as ji}from"react/jsx-runtime";var $i=(e,t)=>e===t||JSON.stringify(e)===JSON.stringify(t),Bi=(e,t)=>({title:e.layoutTitle,titleBody:e.layoutTitleBody,section:e.layoutSection,twoColumns:e.layoutTwoColumns,titleOnly:e.layoutTitleOnly,blank:e.layoutBlank}[t]);function Ri({onPick:e}){const t=c();return Li(He,{"aria-label":t.addShape,triggerLabel:t.addShape,trigger:Li(qe,{name:"shape-rect",size:16}),children:({close:n})=>Li("div",{className:"slides-shape-grid",role:"listbox","aria-label":t.addShape,children:ne.filter(e=>"line"!==e).map(i=>Li("button",{type:"button",title:t.shapeName(i),"aria-label":t.shapeName(i),onClick:()=>{e(i),n()},children:Li("svg",{viewBox:"-2 -2 28 28",width:22,height:22,"aria-hidden":"true",children:Li("path",{d:K(i,24,24),fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinejoin:"round"})})},i))})})}function Wi(e,t){return kt(t).filter(t=>t.first.slideId===e.id&&!t.first.resolvedAt).map((t,n)=>{const i=e.elements.find(e=>e.id===t.first.elementId);return{id:t.first.id,x:i?i.x+i.w-8:1880-40*n,y:i?i.y-28:16,count:1+t.replies.length}})}function Oi({deck:n,onClose:m,onReload:u}){const f=c(),b=d(),{store:g}=b,[v,y]=De(n.title),[k,w]=ze(me,void 0,()=>({past:[],present:se(n.document),future:[]})),x=k.present,C=o(x),[S,N]=De(x.slides[0].id),[z,I]=De(new Set),[D,M]=De(!0),[E,F]=De(null),[L,j]=De("inspector"),[$,B]=De(null),[R,W]=De(null),[O,K]=De(!1),[U,H]=De(null),[V,_]=De([]),[J,q]=De(null),[X,G]=De(0),Y=Ie(null),Z=Ie(""),ee=x.slides.find(e=>e.id===S)??x.slides[0],te=x.slides.indexOf(ee);Se(()=>l(document,r(x)),[x]);const ne=Ie(n.version),ie=Ie(se(n.document)),le=Ie(x);le.current=x;const[re,ae]=De(!1),ve=Ie(!1),ke=Ce(async()=>{const t=await g.get(n.id),i=se(t.document),l=ie.current,r=le.current,s=e(l,r,i);return w({type:"rebase",rebase:t=>e(l,t,i)}),ie.current=i,ne.current=t.version,$i(r,l)||ve.current||(ve.current=!0,Xe.info(f.merged)),s},[n.id,g,f.merged]),He=Ie(Promise.resolve()),Ge=je(),Qe=Ee({save:async t=>{await He.current.catch(()=>{});let i=t;for(let t=0;;t+=1)try{return ne.current=await g.save(n.id,i,ne.current),ie.current=i,void G(e=>e+1)}catch(n){if(!(n instanceof a)||t>=3)throw n;const l=ie.current;await ke(),i=e(l,i,ie.current)}},onFailure:(e,t)=>{e instanceof a?(Qe.stop(),ae(!0)):0===t&&Xe.error(f.saveFailed)}}),Ye=Ie(x),{push:Ze,flush:et}=Qe;Se(()=>{x!==Ye.current&&(Ye.current=x,$i(x,ie.current)||Ze(x))},[x,Ze]),Se(()=>()=>{et()},[et]);const tt=Ce(()=>{b.comments?.list(n.id).then(_,()=>{})},[b.comments,n.id]);Se(tt,[tt]);const nt=Ne(()=>[...z],[z]),it=function(e,t,n,i){const[l,r]=wi([]),s=ki(null),o=ki(n);o.current=n;const a=ki(i);a.current=i,yi(()=>{if(!e.live)return;const n=e.live(t,e=>{if("saved"===e.event)return a.current.saved(e.payload.version);if("comments"===e.event)return a.current.comments();if("bye"===e.event)return r(t=>t.filter(t=>t.key!==e.payload.key));const{user:t,key:n,slide:i,selected:l}=e.payload;r(e=>[...e.filter(e=>e.key!==n),{key:n,user:t,slide:i,selected:l,color:Ci(t.id)}]),"hello"===e.event&&s.current?.send({type:"presence",...o.current})});return s.current=n,n.send({type:"hello",...o.current}),()=>{n.close(),s.current=null,r([])}},[e,t]);const d=JSON.stringify(n);return yi(()=>{s.current?.send({type:"presence",...o.current})},[d]),l}(b,n.id,{slide:ee.id,selected:nt},{saved:e=>{e===ne.current||Date.parse(e)&&Date.parse(e)===Date.parse(ne.current)||(He.current=He.current.then(()=>Qe.hasPending()?void 0:ke()).catch(()=>{}))},comments:tt}),lt=it.filter(e=>e.slide===ee.id).map(e=>({key:e.key,name:e.user.name,color:e.color,selected:e.selected})),rt=Ce(e=>w({type:"commit",doc:e}),[]),st=e=>rt(xe(x,ee.id,()=>e)),ot=e=>st(T(we(ee,z,e))),at=Ie(null),dt=e=>{N(e),I(new Set),W(null)},ct={text:C.text,accents:C.accents,shapeFill:x.theme?C.accents[0]:"#afa9ec",bodyFont:C.bodyFont},mt=e=>{st({...ee,elements:[...ee.elements,e]}),I(new Set([e.id])),j("inspector")},ut=e=>mt(pe(e,ct)),ht=e=>{const t=pe("connector",ct);mt({...t,route:"elbow"===e?"elbow":"curved"===e?"curved":"straight",arrowEnd:"line"!==e,arrowStart:"double"===e||void 0})},pt={title:f.placeholderTitle,subtitle:f.placeholderSubtitle,body:f.placeholderBody},ft=(e=("title"===ee.layout?"titleBody":ee.layout??"titleBody"))=>{const t=s(e,C,pt);rt(ue(x,ee.id,t)),dt(t.id)},gt=()=>{st(T(be(ee,z))),I(new Set)},vt=e=>{const t=jn(ee,z);switch(e.kind){case"align":return st(T(function(e,t,n){const i=e.elements.filter(e=>t.has(e.id));if(0===i.length)return e;const l=1===new Set(i.map(e=>e.groupId??e.id)).size?Ln:oe(i),r=e=>e.groupId??e.id,s=new Map;for(const e of i){const t=r(e);s.set(t,s.has(t)?oe([s.get(t),e]):e)}const o=e=>{switch(n){case"left":return{dx:l.x-e.x,dy:0};case"right":return{dx:l.x+l.w-e.x-e.w,dy:0};case"center":return{dx:l.x+(l.w-e.w)/2-e.x,dy:0};case"top":return{dx:0,dy:l.y-e.y};case"bottom":return{dx:0,dy:l.y+l.h-e.y-e.h};case"middle":return{dx:0,dy:l.y+(l.h-e.h)/2-e.y}}},a=new Map([...s].map(([e,t])=>[e,o(t)]));return we(e,t,e=>{const{dx:t,dy:n}=a.get(r(e));return ye(e,t,n)})}(ee,t,e.to),t));case"distribute":return st(T(function(e,t,n){const i=e.elements.filter(e=>t.has(e.id));if(i.length<3)return e;const l=e=>"horizontal"===n?e.x:e.y,r=e=>"horizontal"===n?e.w:e.h,s=[...i].sort((e,t)=>l(e)-l(t)),o=s[0],a=s[s.length-1],d=s.reduce((e,t)=>e+r(t),0),c=(l(a)+r(a)-l(o)-d)/(s.length-1),m=new Map;let u=l(o);for(const e of s)m.set(e.id,u),u+=r(e)+c;return we(e,t,e=>"horizontal"===n?ye(e,m.get(e.id)-e.x,0):ye(e,0,m.get(e.id)-e.y))}(ee,t,e.axis),t));case"order":return st({front:Fn,forward:de,backward:Pn,back:Tn}[e.to](ee,t));case"group":return st(function(e,t){if(t.size<2)return e;const n=fe();return we(e,t,e=>({...e,groupId:n}))}(ee,t));case"ungroup":return st(function(e,t){return we(e,t,({groupId:e,...t})=>t)}(ee,t));case"lock":return st(function(e,t,n){return we(e,t,({locked:e,...t})=>n?{...t,locked:n}:t)}(ee,t,e.locked))}},yt=e=>{const t=ee.elements.filter(e=>z.has(e.id));if(0===t.length)return;const n=(i=t,JSON.stringify({type:$n,elements:i}));var i;Z.current=n,navigator.clipboard?.writeText(n).catch(()=>{}),e&>()},wt=async()=>{const e=Bn(await(navigator.clipboard?.readText().catch(()=>""))||Z.current)??Bn(Z.current);if(!e)return;const t=Rn(ee,e);st(t.slide),I(new Set(t.ids))},xt=()=>{const e=Rn(ee,ee.elements.filter(e=>z.has(e.id)));st(e.slide),I(new Set(e.ids))},Ct=()=>{b.comments&&j("comments")},Nt=(e=te)=>{const t=window.open("about:blank","_blank","popup,width=1280,height=720");t&&(t.document.title=v),F({popup:t,at:e})},zt=Ie(()=>!1);zt.current=()=>!(E||0===z.size&&!R&&!U)&&(I(new Set),W(null),H(null),!0),Se(()=>Ve(()=>zt.current()),[]);const It=Je(),Dt=z.size>0,Mt=ee.elements.filter(e=>z.has(e.id)),Et=Dt&&Mt.every(e=>e.locked),At=[{type:"submenu",key:"order",label:f.order,disabled:!Dt,items:[{key:"front",label:f.bringToFront,onSelect:()=>vt({kind:"order",to:"front"})},{key:"forward",label:f.bringForward,onSelect:()=>vt({kind:"order",to:"forward"})},{key:"backward",label:f.sendBackward,onSelect:()=>vt({kind:"order",to:"backward"})},{key:"back",label:f.sendToBack,onSelect:()=>vt({kind:"order",to:"back"})}]},{type:"submenu",key:"align",label:f.align,disabled:!Dt,items:gn(f).map(({label:e,action:t})=>({key:e,label:e,onSelect:()=>vt(t)}))},{key:"group",label:f.group,disabled:z.size<2,onSelect:()=>vt({kind:"group"})},{key:"ungroup",label:f.ungroup,disabled:!Mt.some(e=>e.groupId),onSelect:()=>vt({kind:"ungroup"})},{key:"lock",label:Et?f.unlock:f.lock,disabled:!Dt,onSelect:()=>vt({kind:"lock",locked:!Et})},{type:"divider",key:"d-grid"},{type:"checkbox",key:"grid",label:f.grid,checked:O,onSelect:()=>K(e=>!e)}],Pt=It.state?.data?[{key:"cut",label:f.cut,onSelect:()=>yt(!0)},{key:"copy",label:f.copy,onSelect:()=>yt(!1)},{key:"paste",label:f.paste,onSelect:()=>{wt()}},{key:"duplicate",label:f.duplicate,onSelect:xt},{key:"copy-style",label:f.copyStyle,onSelect:()=>{return Y.current=Mt[0]?"text"===(e=Mt[0]).type?{fontSize:e.fontSize,bold:e.bold,color:e.color,font:e.font}:"shape"===e.type?{fill:e.fill,stroke:e.stroke,strokeWidth:e.strokeWidth}:"connector"===e.type?{stroke:e.stroke,strokeWidth:e.strokeWidth}:{}:null;var e}},{key:"paste-style",label:f.pasteStyle,disabled:!Y.current,onSelect:()=>Y.current&&ot(e=>function(e,t){if("text"===e.type){const n=A(e);return Q({...e,fontSize:t.fontSize??e.fontSize,bold:t.bold??e.bold,color:t.color??e.color,font:t.font},p(n,0,P(n).length,{size:void 0,bold:void 0,color:void 0,font:void 0}))}return"shape"===e.type?{...e,fill:t.fill??e.fill,stroke:t.stroke,strokeWidth:t.strokeWidth}:"connector"===e.type&&t.stroke?{...e,stroke:t.stroke,strokeWidth:t.strokeWidth??e.strokeWidth}:e}(e,Y.current))},{type:"divider",key:"d1"},...At.slice(0,5),...b.comments?[{type:"divider",key:"d2"},{key:"comment",label:f.comment,onSelect:Ct}]:[],{type:"divider",key:"d3"},{key:"delete",label:f.delete,danger:!0,onSelect:gt}]:[{key:"paste",label:f.paste,onSelect:()=>{wt()}},{key:"new-slide",label:f.newSlide,onSelect:()=>ft()},{key:"skip",label:ee.skip?f.unskipSlide:f.skipSlide,onSelect:()=>st({...ee,skip:!ee.skip||void 0})},...b.comments?[{key:"comment",label:f.comment,onSelect:Ct}]:[]],Ft=1===Mt.length&&"text"===Mt[0].type?Mt[0]:null,Tt=(e,t,n)=>Li(Ke,{"aria-label":e,onClick:n,children:Li(qe,{name:t,size:16})},e),Lt=e=>j(t=>t===e?"inspector":e),$t=U?U.doc.slides.find(e=>e.id===ee.id)??U.doc.slides[Math.min(te,U.doc.slides.length-1)]:ee;return ji("div",{className:"es-editor slides-editor",onKeyDown:e=>{if(E||U)return;if(e.target.closest('input, textarea, select, [contenteditable], [role="listbox"], [role="menu"], [role="dialog"]'))return;const t=e.metaKey||e.ctrlKey,n=e.key.toLowerCase(),i=z.size>0;if(t&&"z"===n)e.preventDefault(),w({type:e.shiftKey?"redo":"undo"});else if(t&&"y"===n)e.preventDefault(),w({type:"redo"});else if(t&&"a"===n)e.preventDefault(),I(new Set(ee.elements.filter(e=>!e.locked).map(e=>e.id)));else if(t&&"d"===n&&i)e.preventDefault(),xt();else if(t&&("c"===n||"x"===n)&&i)e.preventDefault(),yt("x"===n);else if(t&&"v"===n)e.preventDefault(),wt();else if(t&&"g"===n&&i)e.preventDefault(),vt({kind:e.shiftKey?"ungroup":"group"});else if(t&&e.altKey&&"m"===n)e.preventDefault(),Ct();else if(t&&("ArrowUp"===e.key||"ArrowDown"===e.key)&&i){e.preventDefault();const t="ArrowUp"===e.key;vt({kind:"order",to:e.shiftKey?t?"front":"back":t?"forward":"backward"})}else if("Delete"!==e.key&&"Backspace"!==e.key||!i){if("Escape"===e.key)I(new Set),W(null);else if(e.key.startsWith("Arrow")&&i){e.preventDefault();const t=e.shiftKey?1:10,n="ArrowLeft"===e.key?-t:"ArrowRight"===e.key?t:0,i="ArrowUp"===e.key?-t:"ArrowDown"===e.key?t:0,l=new Set(ee.elements.filter(e=>z.has(e.id)&&!e.locked).map(e=>e.id));st(T(we(ee,l,e=>ye(e,n,i)),l))}}else e.preventDefault(),gt()},tabIndex:-1,children:[ji(Pe,{children:[ji(Te,{children:[Li(Ae,{label:f.backToDecks,onClick:m,children:Li(qe,{name:"chevron-left",size:16})}),Li(Ae,{label:f.slidesPanel,state:D?"active":"inactive",onClick:()=>M(e=>!e),children:Li(qe,{name:"bars-3-bottom-left",size:16})}),Li("div",{className:"slides-title",children:Li(Ue,{"aria-label":f.deckName,value:v,onChange:e=>y(e.target.value),onBlur:()=>{const e=v.trim();e&&e!==n.title?g.rename(n.id,e).catch(()=>Xe.error(f.renameFailed)):y(e||n.title)}})}),Li(Fe,{...Me(Qe.state,Ge.save)}),Li(Le,{}),Li(Ae,{label:f.undo,disabled:0===k.past.length,onClick:()=>w({type:"undo"}),children:Li(qe,{name:"undo",size:16})}),Li(Ae,{label:f.redo,disabled:0===k.future.length,onClick:()=>w({type:"redo"}),children:Li(qe,{name:"redo",size:16})})]}),ji(Te,{kind:"right",children:[it.length>0&&Li("span",{className:"slides-visitors",title:f.editingNow(it.map(e=>e.user.name).join(", ")),children:Li($e,{size:"sm",max:4,children:[...new Map(it.map(e=>[e.user.id,e])).values()].map(e=>Li(Be,{name:e.user.name,size:"sm"},e.user.id))})}),b.versions&&Li(Ae,{label:f.versionHistory,state:"history"===L?"active":"inactive",onClick:()=>Lt("history"),children:Li(qe,{name:"clock",size:16})}),b.comments&&Li(Ae,{label:f.commentCount(kt(V).filter(e=>!e.first.resolvedAt).length),state:"comments"===L?"active":"inactive",onClick:()=>Lt("comments"),children:Li(qe,{name:"chat",size:16})}),Li(Oe,{"aria-label":f.export,trigger:ji("span",{className:"slides-export-trigger",children:[Li(qe,{name:"download",size:16}),f.export]}),items:[{key:"pptx",label:f.exportPptx,onSelect:()=>{Ti(v,x).catch(()=>Xe.error(f.exportFailed))}},{key:"pdf",label:f.exportPdf,onSelect:()=>{(async()=>{const{deckToPdf:e}=await(import("./deckPdf-4RC7QJ45.js")),t=await e(x),n=URL.createObjectURL(t),i=document.createElement("a");i.href=n,i.download=`${v.trim()||"Deck"}.pdf`,i.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)})().catch(()=>Xe.error(f.exportFailed))}}]}),Li(Re,{leftIcon:Li(qe,{name:"play",size:16}),onClick:()=>Nt(),children:f.present})]})]}),re&&ji("div",{className:"slides-conflict",role:"alert",children:[Li("span",{children:f.conflict}),Li(Re,{variant:"secondary",onClick:u,children:f.reload})]}),U&&ji("div",{className:"slides-conflict",role:"status",children:[Li("span",{children:f.previewVersion}),Li(Re,{variant:"secondary",onClick:()=>H(null),children:f.closePreview})]}),ji("div",{className:"slides-body",children:[D&&Li(Dn,{slides:x.slides,currentId:ee.id,numbers:!!x.slideNumbers,visitors:it,onShow:dt,onAdd:()=>ft(),onMove:(e,t)=>rt(he(x,e,t)),onDuplicate:e=>{const t=x.slides.find(t=>t.id===e);if(!t)return;const n=ce(t);rt(ue(x,e,n)),dt(n.id)},onDelete:e=>{const t=ge(x,e);rt(t),e===ee.id&&dt(t.slides[Math.min(te,t.slides.length-1)].id)},onSkip:e=>rt(xe(x,e,e=>({...e,skip:!e.skip||void 0})))}),ji("div",{className:"slides-centre",children:[ji("div",{className:"slides-toolbar",children:[Li(Oe,{"aria-label":f.newSlide,trigger:ji("span",{className:"slides-export-trigger",children:[f.newSlide,Li(qe,{name:"chevron-down",size:14})]}),items:[{type:"label",key:"l",label:f.layouts},...t.map(e=>({key:e,label:Bi(f,e),onSelect:()=>ft(e)}))]}),Tt(f.addText,"type",()=>ut("text")),Tt(f.addImage,"image",()=>ut("image")),Li(Ri,{onPick:e=>mt({...pe("shape",ct),shape:e})}),Li(Oe,{"aria-label":f.addLine,trigger:Li(qe,{name:"line-solid",size:16}),items:[{key:"line",label:f.lineStraight,onSelect:()=>ht("line")},{key:"arrow",label:f.lineArrow,onSelect:()=>ht("arrow")},{key:"double",label:f.lineDoubleArrow,onSelect:()=>ht("double")},{key:"elbow",label:f.connectorElbow,onSelect:()=>ht("elbow")},{key:"curved",label:f.connectorCurved,onSelect:()=>ht("curved")}]}),Tt(f.addTable,"table",()=>ut("table")),Tt(f.addChart,"chart-bar",()=>ut("chart")),Tt(f.addVideo,"block-video",()=>ut("video")),Li("span",{className:"slides-tool-gap"}),Li(Oe,{"aria-label":f.arrange,trigger:ji("span",{className:"slides-export-trigger",children:[f.arrange,Li(qe,{name:"chevron-down",size:14})]}),items:At}),Li(Re,{variant:"theme"===L?"primary":"secondary",size:"sm",onClick:()=>Lt("theme"),children:f.theme}),Li(Re,{variant:"motion"===L?"primary":"secondary",size:"sm",onClick:()=>Lt("motion"),children:f.motion})]}),Ft&&!U&&Li(ui,{element:Ft,editing:$,slides:x.slides,accents:C.accents,onBox:e=>st(we(ee,new Set([Ft.id]),t=>e(t)))}),U?Li("div",{className:"slides-pane slides-preview",children:Li(h,{slide:$t,width:720,number:U.doc.slideNumbers?te+1:void 0})}):Li(Yn,{slide:ee,selected:z,onSelect:e=>I(e),onLive:e=>{at.current??=x,w({type:"live",doc:xe(at.current,ee.id,()=>e)})},onSettle:()=>{at.current&&w({type:"settle",from:at.current}),at.current=null},onCommit:st,onEditing:B,onLink:()=>{document.querySelector(`[data-text-toolbar] button[aria-label="${CSS.escape(f.link)}"]`)?.click()},cells:R,onCells:W,onContextMenu:(e,t)=>It.open(e,t),visitors:lt,pins:b.comments?Wi(ee,V):[],onPin:e=>{q(e),j("comments")},grid:O,slideNumber:x.slideNumbers?te+1:void 0},ee.id),ji("label",{className:"slides-notes",children:[Li("span",{children:f.speakerNotes}),Li(_e,{rows:2,value:ee.notes,onChange:e=>st({...ee,notes:e.target.value})})]})]}),"inspector"===L&&Li(yn,{slide:ee,selected:Mt,onChangeSlide:e=>st({...ee,...e}),onChangeSelected:ot,onAlign:e=>vt({kind:"align",to:e}),onForward:()=>vt({kind:"order",to:"forward"}),onDelete:gt,onArrange:vt,cells:R,accents:C.accents}),"theme"===L&&Li(vi,{doc:x,slide:ee,onTheme:e=>rt(i(x,e)),onDeck:e=>rt({...x,...e}),onSlide:e=>st({...ee,...e})}),"motion"===L&&Li(bt,{slide:ee,slideNumber:te+1,selected:Mt,onSlide:e=>st({...ee,...e}),onAllSlides:e=>rt({...x,slides:x.slides.map(t=>({...t,...e}))}),onPlay:()=>Nt(te)}),"comments"===L&&b.comments&&Li(St,{comments:V,slides:x.slides,slide:ee,selectedId:1===Mt.length?Mt[0].id:null,focusId:J,onAdd:async e=>{const t=await b.comments.add(n.id,e);_(e=>[...e,t])},onUpdate:(e,t)=>b.comments.update(n.id,e,t).then(t=>_(n=>n.map(n=>n.id===e?t:n)),()=>Xe.error(f.commentFailed)),onRemove:e=>b.comments.remove(n.id,e).then(()=>_(t=>t.filter(t=>t.id!==e&&t.parent!==e)),()=>Xe.error(f.commentFailed)),onShowSlide:dt}),"history"===L&&Li(jt,{deckId:n.id,previewing:U?.id??null,refreshKey:X,onPreview:(e,t)=>H(e?{id:e,doc:se(t)}:null),onRestore:e=>{H(null);const t=se(e);rt(t),t.slides.some(e=>e.id===ee.id)||dt(t.slides[0].id)}})]}),It.state&&Li(We,{...It.props,items:Pt,"aria-label":f.arrange}),E&&Li(tn,{slides:x.slides,startIndex:E.at,numbers:!!x.slideNumbers,fonts:r(x),popup:E.popup,onEnd:()=>F(null)})]})}export{Oi as default};
|