@noeva/etl-core 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/CHANGELOG.md +134 -0
  2. package/README.md +6 -11
  3. package/dist/{ai-BoTwcmUg.d.ts → ai-DyDIf-hQ.d.ts} +1 -1
  4. package/dist/{ambiente-della-pipeline-BoymQ6uN.d.ts → ambiente-della-pipeline-BhWsyLUR.d.ts} +2 -2
  5. package/dist/chunk-47NVGHUY.js +2 -0
  6. package/dist/chunk-5OE6F2MK.js +2 -0
  7. package/dist/{chunk-NZR6TZ42.js → chunk-5XVANFXO.js} +1 -1
  8. package/dist/chunk-672L5BGQ.js +1 -0
  9. package/dist/{chunk-4NPSBPBY.js → chunk-6QVYBDIS.js} +1 -1
  10. package/dist/{chunk-PE2QKU34.js → chunk-CEAMQIRO.js} +1 -1
  11. package/dist/chunk-DHQ3YOPX.js +5 -0
  12. package/dist/chunk-FBSNZG34.js +1 -0
  13. package/dist/{chunk-J3PBMWSP.js → chunk-GZWYRO3V.js} +1 -1
  14. package/dist/chunk-IODXIHU2.js +1 -0
  15. package/dist/{chunk-P6B2KLNJ.js → chunk-KEFIGSRS.js} +2 -2
  16. package/dist/chunk-KGWA46Y6.js +2 -0
  17. package/dist/chunk-L25W2QNS.js +1 -0
  18. package/dist/{chunk-JLPK6MMQ.js → chunk-OK3XRTGA.js} +1 -1
  19. package/dist/chunk-UHGHK6NP.js +1 -0
  20. package/dist/chunk-VL7DZWWO.js +2 -0
  21. package/dist/chunk-VVXT66DC.js +1 -0
  22. package/dist/chunk-ZKDCUSM2.js +6 -0
  23. package/dist/cli.js +2 -2
  24. package/dist/{client-DYA3wIyb.d.ts → client-BC_mLuT2.d.ts} +2 -2
  25. package/dist/config-BSdGSRPG.d.ts +37 -0
  26. package/dist/{config-BSUwK4p_.d.ts → config-DMafsY4H.d.ts} +3 -3
  27. package/dist/connector-kit.d.ts +14 -9
  28. package/dist/connector-kit.js +1 -1
  29. package/dist/connectors/excel.d.ts +391 -0
  30. package/dist/connectors/excel.js +10 -0
  31. package/dist/connectors/file.d.ts +12 -5
  32. package/dist/connectors/file.js +1 -1
  33. package/dist/connectors/http.d.ts +7 -7
  34. package/dist/connectors/http.js +1 -1
  35. package/dist/connectors/imap.d.ts +6 -6
  36. package/dist/connectors/imap.js +1 -1
  37. package/dist/connectors/jira.d.ts +6 -6
  38. package/dist/connectors/jira.js +2 -2
  39. package/dist/connectors/mail.d.ts +7 -7
  40. package/dist/connectors/mail.js +1 -1
  41. package/dist/connectors/mysql.d.ts +238 -0
  42. package/dist/connectors/mysql.js +2 -0
  43. package/dist/connectors/noeva.d.ts +6 -6
  44. package/dist/connectors/noeva.js +1 -1
  45. package/dist/connectors/oauth.d.ts +5 -5
  46. package/dist/connectors/oauth.js +1 -1
  47. package/dist/connectors/odoo.d.ts +309 -0
  48. package/dist/connectors/odoo.js +3 -0
  49. package/dist/connectors/postgres.d.ts +7 -6
  50. package/dist/connectors/postgres.js +1 -1
  51. package/dist/connectors/process.d.ts +1 -1
  52. package/dist/connectors/process.js +1 -1
  53. package/dist/connectors/sendgrid.d.ts +7 -7
  54. package/dist/connectors/sendgrid.js +1 -1
  55. package/dist/connectors/smtp.d.ts +8 -8
  56. package/dist/connectors/smtp.js +1 -1
  57. package/dist/connectors/sqlserver.d.ts +7 -6
  58. package/dist/connectors/sqlserver.js +1 -1
  59. package/dist/connectors/zoho.d.ts +6 -6
  60. package/dist/connectors/zoho.js +1 -1
  61. package/dist/contract.d.ts +2 -2
  62. package/dist/{credenziali-posta-f7HB2cYW.d.ts → credenziali-posta-C0az04uV.d.ts} +2 -2
  63. package/dist/{errors-bgSO6lGO.d.ts → errors-CRq1uNYZ.d.ts} +8 -1
  64. package/dist/etl.config.js +3 -3
  65. package/dist/guida/404.html +2 -2
  66. package/dist/guida/GUIDA_SVILUPPO.html +7 -7
  67. package/dist/guida/TECHNICAL_OVERVIEW.html +7 -7
  68. package/dist/guida/assets/{GUIDA_SVILUPPO.md.CrN52ZDN.js → GUIDA_SVILUPPO.md.Bvr7RKHN.js} +2 -2
  69. package/dist/guida/assets/TECHNICAL_OVERVIEW.md.C6HYc5_h.js +10 -0
  70. package/dist/guida/assets/{app.DeVEBaIz.js → app.uK-5scpr.js} +1 -1
  71. package/dist/guida/assets/chunks/@localSearchIndexroot.AxYI9rrX.js +1 -0
  72. package/dist/guida/assets/chunks/{VPLocalSearchBox.CsTQzJUK.js → VPLocalSearchBox.CB5vaMvW.js} +1 -1
  73. package/dist/guida/assets/chunks/{theme.Dfy0C_Zf.js → theme.z6u0J2Ii.js} +2 -2
  74. package/dist/guida/assets/connectors_README.md.B5QWzWUK.js +1 -0
  75. package/dist/guida/assets/connectors_README.md.B5QWzWUK.lean.js +1 -0
  76. package/dist/guida/assets/connectors_excel.md.CqGtwEB4.js +92 -0
  77. package/dist/guida/assets/connectors_excel.md.CqGtwEB4.lean.js +1 -0
  78. package/dist/guida/assets/{connectors_file.md.B1NJe0VJ.js → connectors_file.md.Dbofo9W5.js} +3 -3
  79. package/dist/guida/assets/{connectors_file.md.B1NJe0VJ.lean.js → connectors_file.md.Dbofo9W5.lean.js} +1 -1
  80. package/dist/guida/assets/connectors_mysql.md.fVCxQWUW.js +34 -0
  81. package/dist/guida/assets/connectors_mysql.md.fVCxQWUW.lean.js +1 -0
  82. package/dist/guida/assets/connectors_odoo.md.DprabV5e.js +19 -0
  83. package/dist/guida/assets/connectors_odoo.md.DprabV5e.lean.js +1 -0
  84. package/dist/guida/assets/{conventions_node-descriptor.md.MQaGlm8a.js → conventions_node-descriptor.md.C19dB-Tb.js} +4 -4
  85. package/dist/guida/assets/conventions_node-descriptor.md.C19dB-Tb.lean.js +1 -0
  86. package/dist/guida/assets/{conventions_run-report.md.D_pG07VG.js → conventions_run-report.md.iVSN9fNV.js} +1 -1
  87. package/dist/guida/assets/{conventions_versioni-di-pipeline.md.cy5nsizS.js → conventions_versioni-di-pipeline.md.DJPSthZ8.js} +1 -1
  88. package/dist/guida/assets/{conventions_versioni-di-pipeline.md.cy5nsizS.lean.js → conventions_versioni-di-pipeline.md.DJPSthZ8.lean.js} +1 -1
  89. package/dist/guida/assets/{nodes_README.md.CHGy_go6.js → nodes_README.md.BNAiSoJJ.js} +2 -2
  90. package/dist/guida/assets/{nodes_README.md.CHGy_go6.lean.js → nodes_README.md.BNAiSoJJ.lean.js} +1 -1
  91. package/dist/guida/assets/{nodes_lookup.md.BI8tgBIq.js → nodes_lookup.md.DrJFsfOJ.js} +1 -1
  92. package/dist/guida/assets/{nodes_sink.md.yAf_z4wO.js → nodes_sink.md.C1S-lAh2.js} +2 -2
  93. package/dist/guida/assets/{nodes_source.md.DP2i3GFv.js → nodes_source.md.BitUNtug.js} +2 -2
  94. package/dist/guida/assets/{nodes_task.md.Dk6VB7as.js → nodes_task.md.CejEQZcD.js} +2 -2
  95. package/dist/guida/assets/{nodes_task.md.Dk6VB7as.lean.js → nodes_task.md.CejEQZcD.lean.js} +1 -1
  96. package/dist/guida/assets/{nodes_transform.md.Bv5fg2Xx.js → nodes_transform.md.Ciycywnb.js} +1 -1
  97. package/dist/guida/assets/{runbooks_deployment.md.CwG77qGO.js → runbooks_deployment.md.BV8Izw4I.js} +1 -1
  98. package/dist/guida/assets/runbooks_excel-operazioni-distruttive.md.CEygSROg.js +16 -0
  99. package/dist/guida/assets/runbooks_excel-operazioni-distruttive.md.CEygSROg.lean.js +1 -0
  100. package/dist/guida/assets/{runbooks_sql-task-truncate-swap.md.C8viT-fp.js → runbooks_sql-task-truncate-swap.md.DAz41942.js} +5 -3
  101. package/dist/guida/assets/{runbooks_sql-task-truncate-swap.md.C8viT-fp.lean.js → runbooks_sql-task-truncate-swap.md.DAz41942.lean.js} +1 -1
  102. package/dist/guida/connectors/README.html +5 -5
  103. package/dist/guida/connectors/excel.html +118 -0
  104. package/dist/guida/connectors/file.html +7 -7
  105. package/dist/guida/connectors/http.html +4 -4
  106. package/dist/guida/connectors/imap.html +4 -4
  107. package/dist/guida/connectors/jira.html +5 -5
  108. package/dist/guida/connectors/mysql.html +60 -0
  109. package/dist/guida/connectors/noeva.html +5 -5
  110. package/dist/guida/connectors/oauth.html +5 -5
  111. package/dist/guida/connectors/odoo.html +45 -0
  112. package/dist/guida/connectors/postgres.html +5 -5
  113. package/dist/guida/connectors/process.html +4 -4
  114. package/dist/guida/connectors/sendgrid.html +4 -4
  115. package/dist/guida/connectors/smtp.html +4 -4
  116. package/dist/guida/connectors/sqlserver.html +4 -4
  117. package/dist/guida/connectors/zoho.html +4 -4
  118. package/dist/guida/conventions/node-columns.html +4 -4
  119. package/dist/guida/conventions/node-descriptor.html +8 -8
  120. package/dist/guida/conventions/run-report.html +6 -6
  121. package/dist/guida/conventions/run-trace.html +4 -4
  122. package/dist/guida/conventions/variabili-del-core.html +4 -4
  123. package/dist/guida/conventions/versioni-di-pipeline.html +6 -6
  124. package/dist/guida/guide/claude-code/index.html +4 -4
  125. package/dist/guida/guide/claude-code/prompt.html +5 -5
  126. package/dist/guida/guide/claude-code/strumenti.html +4 -4
  127. package/dist/guida/guide/grafo.html +4 -4
  128. package/dist/guida/guide/usare/app-desktop.html +4 -4
  129. package/dist/guida/guide/usare/esito-di-una-run.html +4 -4
  130. package/dist/guida/guide/usare/index.html +4 -4
  131. package/dist/guida/hashmap.json +1 -1
  132. package/dist/guida/index.html +4 -4
  133. package/dist/guida/nodes/README.html +5 -5
  134. package/dist/guida/nodes/action.html +4 -4
  135. package/dist/guida/nodes/ai.html +4 -4
  136. package/dist/guida/nodes/join.html +4 -4
  137. package/dist/guida/nodes/lookup.html +6 -6
  138. package/dist/guida/nodes/pipeline.html +4 -4
  139. package/dist/guida/nodes/route.html +4 -4
  140. package/dist/guida/nodes/sink.html +7 -7
  141. package/dist/guida/nodes/source.html +7 -7
  142. package/dist/guida/nodes/task.html +6 -6
  143. package/dist/guida/nodes/transform.html +6 -6
  144. package/dist/guida/nodes/try-catch.html +4 -4
  145. package/dist/guida/nodes/union.html +4 -4
  146. package/dist/guida/pagine.json +4 -0
  147. package/dist/guida/pipelines/README.html +4 -4
  148. package/dist/guida/pipelines/crm-leads-sync.html +4 -4
  149. package/dist/guida/pipelines/cross-workspace-csv-merge.html +4 -4
  150. package/dist/guida/pipelines/movimenti-per-conto.html +4 -4
  151. package/dist/guida/pipelines/orders-enriched-daily.html +4 -4
  152. package/dist/guida/pipelines/test-posta.html +4 -4
  153. package/dist/guida/runbooks/aggiornamento-pm2.html +4 -4
  154. package/dist/guida/runbooks/deploy-ecr.html +4 -4
  155. package/dist/guida/runbooks/deployment.html +6 -6
  156. package/dist/guida/runbooks/etl-worker.html +5 -5
  157. package/dist/guida/runbooks/excel-operazioni-distruttive.html +42 -0
  158. package/dist/guida/runbooks/graph-server.html +5 -5
  159. package/dist/guida/runbooks/mask-key.html +4 -4
  160. package/dist/guida/runbooks/oauth-google-posta.html +4 -4
  161. package/dist/guida/runbooks/rollback-di-pipeline.html +4 -4
  162. package/dist/guida/runbooks/scd2-rehash.html +4 -4
  163. package/dist/guida/runbooks/sql-task-truncate-swap.html +8 -6
  164. package/dist/guida/runbooks/stato-incrementale.html +4 -4
  165. package/dist/guida/sub-pipelines/README.html +4 -4
  166. package/dist/guida/sub-pipelines/riepilogo-ordini.html +4 -4
  167. package/dist/index.d.ts +9 -9
  168. package/dist/index.js +1 -1
  169. package/dist/{invio-Dwz3J7sP.d.ts → invio-9Ubb_cdR.d.ts} +3 -3
  170. package/dist/{istanza-per-il-piano-CucqUF7b.d.ts → istanza-per-il-piano-74NYhIHc.d.ts} +1 -1
  171. package/dist/{manifest-variabili-U1UfPDfF.d.ts → manifest-variabili-DRWUzmxU.d.ts} +1 -1
  172. package/dist/pipelines.d.ts +3 -3
  173. package/dist/pipelines.js +1 -1
  174. package/dist/{runnable-pipeline-CArkLzfv.d.ts → runnable-pipeline-CWgPwi6w.d.ts} +2 -2
  175. package/dist/{config-DIthC7n7.d.ts → sql-watermark-CQVvxhPZ.d.ts} +9 -40
  176. package/dist/testing.d.ts +3 -3
  177. package/dist/testing.js +1 -1
  178. package/dist/{trasporto-DpPLCEQ1.d.ts → trasporto-BaRdP6Wl.d.ts} +4 -4
  179. package/dist/{types-BVA7BIou.d.ts → types-_3rgLhje.d.ts} +21 -2
  180. package/dist/{variabili-dichiarate-DmfcxsT9.d.ts → variabili-dichiarate-CS-eC53K.d.ts} +1 -1
  181. package/kit/skills/etl-graph/SKILL.md +6 -3
  182. package/kit/skills/etl-graph/references/data-patterns.md +1 -1
  183. package/kit/skills/etl-graph/references/error-handling.md +3 -3
  184. package/kit/skills/etl-graph/references/wiring.md +10 -10
  185. package/kit/skills/new-connector/SKILL.md +2 -2
  186. package/package.json +16 -1
  187. package/dist/chunk-BVUOUBLW.js +0 -1
  188. package/dist/chunk-CRR3Q2C7.js +0 -2
  189. package/dist/chunk-LJ7DVP5F.js +0 -2
  190. package/dist/chunk-PKBSETMV.js +0 -2
  191. package/dist/chunk-QPJC4GWR.js +0 -1
  192. package/dist/chunk-RCRMQPFH.js +0 -5
  193. package/dist/chunk-RS5SGDUU.js +0 -1
  194. package/dist/chunk-RWPHH4E2.js +0 -1
  195. package/dist/chunk-SRFFKE5W.js +0 -6
  196. package/dist/chunk-WVODQB6Z.js +0 -1
  197. package/dist/chunk-XZMCC6VQ.js +0 -1
  198. package/dist/chunk-ZCYGHS7P.js +0 -2
  199. package/dist/guida/assets/TECHNICAL_OVERVIEW.md.DTIhkkg9.js +0 -10
  200. package/dist/guida/assets/chunks/@localSearchIndexroot.NgfCNDyz.js +0 -1
  201. package/dist/guida/assets/connectors_README.md.BqI2RLCu.js +0 -1
  202. package/dist/guida/assets/connectors_README.md.BqI2RLCu.lean.js +0 -1
  203. package/dist/guida/assets/conventions_node-descriptor.md.MQaGlm8a.lean.js +0 -1
  204. /package/dist/guida/assets/{GUIDA_SVILUPPO.md.CrN52ZDN.lean.js → GUIDA_SVILUPPO.md.Bvr7RKHN.lean.js} +0 -0
  205. /package/dist/guida/assets/{TECHNICAL_OVERVIEW.md.DTIhkkg9.lean.js → TECHNICAL_OVERVIEW.md.C6HYc5_h.lean.js} +0 -0
  206. /package/dist/guida/assets/{conventions_run-report.md.D_pG07VG.lean.js → conventions_run-report.md.iVSN9fNV.lean.js} +0 -0
  207. /package/dist/guida/assets/{nodes_lookup.md.BI8tgBIq.lean.js → nodes_lookup.md.DrJFsfOJ.lean.js} +0 -0
  208. /package/dist/guida/assets/{nodes_sink.md.yAf_z4wO.lean.js → nodes_sink.md.C1S-lAh2.lean.js} +0 -0
  209. /package/dist/guida/assets/{nodes_source.md.DP2i3GFv.lean.js → nodes_source.md.BitUNtug.lean.js} +0 -0
  210. /package/dist/guida/assets/{nodes_transform.md.Bv5fg2Xx.lean.js → nodes_transform.md.Ciycywnb.lean.js} +0 -0
  211. /package/dist/guida/assets/{runbooks_deployment.md.CwG77qGO.lean.js → runbooks_deployment.md.BV8Izw4I.lean.js} +0 -0
@@ -0,0 +1,10 @@
1
+ import {a as a$1}from'../chunk-47NVGHUY.js';import {a,e,g,Q,f,l,d}from'../chunk-CEAMQIRO.js';import {Readable}from'stream';import No from'jszip';import {StringDecoder}from'string_decoder';import {SaxesParser}from'saxes';import {posix}from'path';import {randomUUID}from'crypto';var rn={valore:null,errore:false},Gt={valore:null,errore:true};function Jt(n){return typeof n=="object"&&n!==null&&!(n instanceof Date)}a(Jt,"\xE8Oggetto");function an(n){if(n==null)return rn;if(typeof n=="string")return n===""?rn:{valore:n,errore:false};if(!Jt(n))return {valore:n,errore:false};if("error"in n)return Gt;if("formula"in n||"sharedFormula"in n)return "result"in n?an(n.result):rn;if(Array.isArray(n.richText)){let e=n.richText.map(o=>typeof o.text=="string"?o.text:"").join("");return e===""?rn:{valore:e,errore:false}}return typeof n.text=="string"?an(n.text):rn}a(an,"leggiCella");function Eo(n){let{valore:e}=an(n);return e instanceof Date?e.toISOString():typeof e=="string"?e.trim():typeof e=="number"||typeof e=="boolean"?String(e):""}a(Eo,"titoloDiCella");function V(n){let e=n,o="";for(;e>0;){let t=(e-1)%26;o=String.fromCharCode(65+t)+o,e=Math.floor((e-1)/26);}return o}a(V,"letteraDiColonna");function Un(n){let e=n.indexOf(":");return e<0?n:n.slice(e+1)}a(Un,"locale");function be(n,e){for(let[o,t]of Object.entries(n.attributes))if(Un(o)===e)return t}a(be,"attributo");function Xn(n){let e=new SaxesParser;e.on("error",i=>{throw i});let{apre:o,chiude:t,testo:r}=n;return o&&e.on("opentag",i=>o(Un(i.name),i)),t&&e.on("closetag",i=>t(Un(i.name))),r&&(e.on("text",r),e.on("cdata",r)),e}a(Xn,"creaParser");function Ie(n,e){Xn(e).write(n).close();}a(Ie,"leggiXml");function Do(n){let e=[],o="",t=false,r=0;return Ie(n,{apre(i){i==="si"?o="":i==="rPh"?r+=1:i==="t"&&(t=true);},chiude(i){i==="si"?e.push(o):i==="rPh"?r-=1:i==="t"&&(t=false);},testo(i){t&&r===0&&(o+=i);}}),e}a(Do,"leggiStringhe");function Ht(n){let e=0;for(let o of n){let t=o.charCodeAt(0);if(t<65||t>90)break;e=e*26+(t-64);}return e}a(Ht,"colonnaDi");var Qt=24*3600*1e3;function Kt(n,e){return new Date(Math.round((n-25569+(e?1462:0))*Qt))}a(Kt,"dataDaSeriale");function Yt(n,e){let{tipo:o,v:t}=n,r;if(o==="inlineStr")r=n.inline;else if(t===void 0||t==="")r=void 0;else if(o==="s")r=e.stringhe[Number(t)];else if(o==="str")r=t;else if(o==="b")r=t==="1"||t==="true";else if(o==="e")r={error:t};else if(o==="d")r=new Date(t);else {let i=Number(t);r=e.stiliDiData.has(n.stile)?Kt(i,e.date1904):i;}return n.formula?r===void 0?{formula:""}:{formula:"",result:r}:r}a(Yt,"valoreDi");async function*To(n,e){let o=[],t=0,r=[],i=0,a,l,s=false,f=0,d=Xn({apre(u,p){if(u==="row"){let g=Number(be(p,"r"));t=Number.isInteger(g)&&g>0?g:t+1,r=[],i=0;}else if(u==="c"){let g=be(p,"r");a={colonna:g!==void 0?Ht(g):i+1,tipo:be(p,"t")??"n",stile:Number(be(p,"s")??0),formula:false,v:void 0,inline:void 0},i=a.colonna;}else a!==void 0&&(u==="f"?a.formula=true:u==="v"?(a.v="",l="v"):u==="is"?(s=true,a.inline=""):u==="rPh"?f+=1:u==="t"&&s&&f===0&&(l="inline"));},chiude(u){if(u==="c"&&a!==void 0){let p=Yt(a,e);p!=null&&(r[a.colonna]=p),a=void 0;}else u==="row"?(r.length>0&&o.push({numero:t,celle:r}),r=[]):u==="v"||u==="t"?l=void 0:u==="is"?s=false:u==="rPh"&&(f-=1);},testo(u){a===void 0||l===void 0||(l==="v"?a.v=(a.v??"")+u:a.inline=(a.inline??"")+u);}}),m=new StringDecoder("utf8");for await(let u of n)for(d.write(m.write(Buffer.from(u)));o.length>0;){let p=o.shift();p!==void 0&&(yield p);}d.write(m.end()).close();for(let u of o)yield u;}a(To,"righeDelFoglio");function ei(n){return n>=14&&n<=22||n>=27&&n<=36||n>=45&&n<=47||n>=50&&n<=58}a(ei,"\xE8IdDiData");function ni(n){let e=n.replace(/\[[^\]]*]/g,"").replace(/"[^"]*"/g,"");return /[ymdhMsb]+/.test(e)}a(ni,"\xE8FormatoDiData");function Io(n){let e=new Map,o=[],t=false;Ie(n,{apre(i,a){i==="numFmt"?e.set(Number(a.attributes.numFmtId),a.attributes.formatCode??""):i==="cellXfs"?t=true:i==="xf"&&t&&o.push(Number(a.attributes.numFmtId??0));},chiude(i){i==="cellXfs"&&(t=false);}});let r=new Set;return o.forEach((i,a)=>{let l=e.get(i);(l!==void 0?ni(l):ei(i))&&r.add(a);}),r}a(Io,"stiliDiData");async function Oo(n){let e=[];for await(let o of n)e.push(Buffer.from(o));return Buffer.concat(e)}a(Oo,"inBuffer");function Mo(n){let e=[],o=false;return Ie(n,{apre(t,r){if(t==="workbookPr"){let i=be(r,"date1904");o=i==="1"||i==="true";}else t==="sheet"&&e.push({nome:be(r,"name")??"",rid:be(r,"id")??""});}}),{fogli:e,date1904:o}}a(Mo,"leggiWorkbook");function ti(n){if(n.startsWith("/"))return n.slice(1);let e=["xl"];for(let o of n.split("/"))o===".."?e.pop():o!=="."&&o!==""&&e.push(o);return e.join("/")}a(ti,"percorsoDi");function ii(n){let e=new Map;return Ie(n,{apre(o,t){if(o!=="Relationship")return;let r=be(t,"Id"),i=be(t,"Target");r!==void 0&&i!==void 0&&e.set(r,i);}}),e}a(ii,"relazioni");async function Vn(n,e){let o=n.file(e);if(o===null)throw new Error(`nel file manca \xAB${e}\xBB`);return o.async("string")}a(Vn,"testoDi");async function Lo(n,e){let o=await No.loadAsync(await Oo(n)),t=Mo(await Vn(o,"xl/workbook.xml")),r=e.toLowerCase(),i=t.fogli.find(u=>u.nome.toLowerCase()===r);if(i===void 0)return {trovato:false,fogli:t.fogli.map(u=>u.nome)};let a$1=ii(await Vn(o,"xl/_rels/workbook.xml.rels")).get(i.rid);if(a$1===void 0)throw new Error(`il foglio \xAB${i.nome}\xBB non ha una relazione nel workbook`);let l=o.file(ti(a$1));if(l===null)throw new Error(`nel file manca il foglio \xAB${i.nome}\xBB (${a$1})`);let s=o.file("xl/sharedStrings.xml"),f=o.file("xl/styles.xml"),d={stringhe:s?Do(await s.async("string")):[],stiliDiData:f?Io(await f.async("string")):new Set,date1904:t.date1904},m=a(async function*(){let u=new Readable().wrap(l.nodeStream());try{yield*To(u,d);}finally{u.destroy();}},"righe");return {trovato:true,nome:i.nome,righe:m()}}a(Lo,"apriFoglio");async function Po(n){let e=await No.loadAsync(await Oo(n));return Mo(await Vn(e,"xl/workbook.xml")).fogli.map(o=>o.nome)}a(Po,"elencaFogli");var ri=[".xlsx",".xlsm"];function Ne(n,e$1,o,t,r,i){let a=[`foglio \xAB${o}\xBB`,...t!==void 0?[`riga ${t}`]:[],...r!==void 0?[`colonna ${V(r)}`]:[]].join(", ");return new e(`${e$1}: ${a}: ${i}`,{stage:n})}a(Ne,"errore");function ai(n,e$1){let o=e$1.headerRow??1;if(e$1.path===void 0==(e$1.prefix===void 0))throw new g("excelSource: serve `path` oppure `prefix`, non entrambi n\xE9 nessuno");if(e$1.sheet===void 0==(e$1.sheets===void 0))throw new g("excelSource: serve `sheet` oppure `sheets`, non entrambi n\xE9 nessuno");if(e$1.sheets!==void 0&&e$1.sheets!=="all"&&e$1.sheets.length===0)throw new g("excelSource: `sheets` \xE8 un elenco vuoto");if((e$1.sheets==="all"||e$1.sheets!==void 0&&e$1.sheets.length>1)&&(e$1.sheetField??"")==="")throw new g("excelSource: con pi\xF9 fogli serve `sheetField`, il campo che dice da quale foglio viene il record");if(e$1.sheetField!==void 0&&e$1.sheetField==="")throw new g("excelSource: `sheetField` \xE8 vuoto");if(!Number.isInteger(o)||o<1)throw new g(`excelSource: headerRow deve essere un intero da 1, non ${o}`);let r=e$1.name??`${n.name}:excel`,i=e$1.columns?Q([...e$1.sheetField!==void 0?[e$1.sheetField]:[],...e$1.columns],"unknown"):void 0,a$2=[{label:"storage",value:n.name},e$1.path!==void 0?{label:"path",value:e$1.path}:{label:"prefix",value:e$1.prefix??""},{label:e$1.sheets===void 0?"foglio":"fogli",value:e$1.sheets===void 0?e$1.sheet??"":e$1.sheets==="all"?"tutti":e$1.sheets.join(", ")},{label:"riga d'intestazione",value:String(o)}];async function*l(){if(e$1.path!==void 0){yield e$1.path;return}for await(let m of n.list(e$1.prefix??""))(m.split("/").pop()??m).startsWith("~$")||ri.some(p=>m.toLowerCase().endsWith(p))&&(yield m);}a(l,"percorsi");function s(m,u,p){let g=p.celle.map(C=>Eo(C)),b=g.flatMap((C,T)=>C!==""?[T]:[]),h=b[0],y=b[b.length-1];if(h===void 0||y===void 0)throw Ne(r,m,u,p.numero,void 0,"la riga d'intestazione \xE8 vuota");let $=new Map,v=[];for(let C=h;C<=y;C+=1){let T=g[C]??"";if(T===""){if(e$1.columns===void 0)throw Ne(r,m,u,p.numero,C,"titolo vuoto");continue}let k=$.get(T);if(k!==void 0&&(e$1.columns===void 0||e$1.columns.includes(T)))throw Ne(r,m,u,p.numero,C,`titolo duplicato \xAB${T}\xBB (gi\xE0 alla colonna ${V(k)})`);k===void 0&&$.set(T,C),v.push({titolo:T,indice:C});}return e$1.columns===void 0?v:e$1.columns.map(C=>{let T=$.get(C);if(T===void 0)throw Ne(r,m,u,p.numero,void 0,`colonna \xAB${C}\xBB assente`);return {titolo:C,indice:T}})}a(s,"colonneDi");async function*f(m,u,p){let g=await Lo(n.get(m),u),b=g.trovato?g.nome:u;if(!g.trovato){if(e$1.onMissingSheet==="skip"){p.logger.warn("excel.foglio-assente",{file:m,foglio:u});return}throw Ne(r,m,u,void 0,void 0,`foglio inesistente (nel workbook: ${g.fogli.map(y=>`\xAB${y}\xBB`).join(", ")||"nessuno"})`)}let h;for await(let y of g.righe){if(p.signal.throwIfAborted(),y.numero<o)continue;if(h===void 0){if(y.numero!==o)throw Ne(r,m,u,o,void 0,"riga d'intestazione assente");h=s(m,u,y);continue}let $={},v=true,C=0;for(let{titolo:T,indice:k}of h){let S=an(y.celle[k]);S.errore&&(C+=1),S.valore!==null&&(v=false),$[T]=S.valore;}e$1.sheetField!==void 0&&e$1.sheetField!==""&&($={[e$1.sheetField]:b,...$}),C>0&&p.metrics.increment(`${r}:excel.errori-di-formula`,C),!(v&&C===0)&&(yield $);}if(h===void 0)throw Ne(r,m,u,o,void 0,"riga d'intestazione assente")}a(f,"leggiFoglio");async function*d(m,u){if(e$1.sheets===void 0){yield*f(m,e$1.sheet,u);return}let p=e$1.sheets==="all"?await Po(n.get(m)):e$1.sheets;for(let g of p)u.signal.throwIfAborted(),yield*f(m,g,u);}return a(d,"leggiFile"),{name:r,descriptor:{kind:"excel",...a$1(e$1.instanceId),details:a$2},...i?{columns:i}:{},async*extract(m){try{for await(let u of l())m.signal.throwIfAborted(),yield*d(u,m);}catch(u){throw u instanceof e?u:new e("Errore durante la lettura del file Excel",{stage:r},{cause:u})}}}}a(ai,"excelSource");var li={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function oe(n){return n.replace(/[&<>"]/g,e=>li[e]??e)}a(oe,"escapeXml");function _o(n){let e=n.replace(/_(x[0-9A-Fa-f]{4}_)/g,"_x005F_$1");return oe(e).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,o=>`_x${o.charCodeAt(0).toString(16).toUpperCase().padStart(4,"0")}_`)}a(_o,"escapeTesto");var si=Date.UTC(1900,2,1),ci=Date.UTC(1899,11,30),fi=864e5;function ie(n){if(n.length===0)return "il nome del foglio \xE8 vuoto";if(n.length>31)return `il nome del foglio supera 31 caratteri (${n.length})`;let e=n.match(/[/\\?*:[\]]/);if(e)return `il nome del foglio contiene il carattere vietato \xAB${e[0]}\xBB (vietati: / \\ ? * : [ ])`;if(n.startsWith("'")||n.endsWith("'"))return "il nome del foglio non pu\xF2 iniziare n\xE9 finire con un apostrofo";if(n.toLowerCase()==="history")return "\xABHistory\xBB \xE8 un nome riservato da Excel"}a(ie,"motivoNomeFoglioNonValido");function ui(n){return (n.getTime()-ci)/fi}a(ui,"seriale1900");var Be=a(n=>({ok:false,motivo:n}),"rifiuto"),qn=a(n=>n.length>32767?Be(`testo di ${n.length} caratteri, oltre il limite di una cella (${32767 .toLocaleString("it-IT")})`):{ok:true,cella:{tipo:"testo",valore:n}},"testo"),di=/[￾￿]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;function mi(n){if(n==null)return {ok:true,cella:null};if(typeof n=="string")return di.test(n)?Be("il testo contiene un carattere non valido in XML"):qn(n);if(typeof n=="boolean")return {ok:true,cella:{tipo:"booleano",valore:n}};if(typeof n=="bigint")return qn(n.toString());if(typeof n=="number"){if(!Number.isFinite(n))return Be(`il numero ${String(n)} non \xE8 rappresentabile`);if(Number.isInteger(n)){let e=BigInt(n).toString();if(e.replace(/^-/,"").length>15)return qn(e)}return {ok:true,cella:{tipo:"numero",valore:n}}}if(n instanceof Date){let e=n.getTime();return Number.isNaN(e)?Be("data non valida"):e<si?Be("data prima del 01/03/1900: Excel non la rappresenta senza errore"):{ok:true,cella:{tipo:"data",seriale:ui(n)}}}return Be(`tipo non scrivibile in una cella (${typeof n})`)}a(mi,"convertiValore");function zn(n,e){let o=[],t=e??Object.keys(n);if(e!==void 0){let i=new Set(e);for(let a of Object.keys(n))i.has(a)||o.push(`campo \xAB${a}\xBB: non \xE8 tra le colonne dichiarate`);}let r=t.map(i=>{let a=mi(n[i]);return a.ok?a.cella:(o.push(`campo \xAB${i}\xBB: ${a.motivo}`),null)});return {errori:o,celle:r}}a(zn,"valutaRecord");var Zo=255;function We(n){if(n.length===0)return "il nome della tabella \xE8 vuoto";if(n.length>Zo)return `il nome della tabella supera ${Zo} caratteri (${n.length})`;if(!/^[\p{L}_\\][\p{L}\p{N}_.\\]*$/u.test(n))return `il nome della tabella \xAB${n}\xBB non \xE8 valido: inizia con una lettera o _ e contiene solo lettere, cifre, _ e . (niente spazi)`;if(/^[rc]$/i.test(n))return `il nome della tabella \xAB${n}\xBB \xE8 riservato da Excel`;if(/^[a-z]{1,3}\d+$/i.test(n)||/^r\d*c\d*$/i.test(n))return `il nome della tabella \xAB${n}\xBB somiglia a un riferimento di cella`}a(We,"motivoNomeTabellaNonValido");var pi=/<!--[\s\S]*?-->|<!\[CDATA\[[\s\S]*?\]\]>|<\?[\s\S]*?\?>|<!DOCTYPE[^>]*>|<(\/?)([A-Za-z_][\w:.-]*)((?:\s+[\w:.-]+\s*=\s*(?:"[^"]*"|'[^']*'))*)\s*(\/?)>/g;function F(n,e=2,o=0,t=n.length){let r=[],i=[],a=new RegExp(pi.source,"g");a.lastIndex=o;for(let l=a.exec(n);l!==null&&l.index<t;l=a.exec(n)){let s=l[2];if(s===void 0)continue;let f=l[1]==="/",d=l[4]==="/";if(f){let m=i.pop();if(m===void 0||m.nome!==s)throw new Error(`XML non ben formato: \xAB</${s}>\xBB inatteso`);jo(i,r,{...m,inizioChiusura:l.index,fine:l.index+l[0].length},e);}else if(d){let m=l.index+l[0].length;jo(i,r,{nome:s,apertura:l[0],inizio:l.index,fineApertura:m,inizioChiusura:m,fine:m,figli:[]},e);}else i.push({nome:s,apertura:l[0],inizio:l.index,fineApertura:l.index+l[0].length,figli:[]});}if(i.length>0)throw new Error("XML non ben formato: tag non chiuso");return r}a(F,"scansiona");function jo(n,e,o,t){let r=n[n.length-1];r===void 0?e.push(o):n.length<t&&r.figli.push(o);}a(jo,"accoda");function D(n,e){return e.inizioChiusura===e.fine?[]:F(n,1,e.fineApertura,e.inizioChiusura)}a(D,"figliDi");function w(n,e){let t=new RegExp(`\\s${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`).exec(n),r=t?.[1]??t?.[2];return r===void 0?void 0:H(r)}a(w,"attributo");function I(n,e,o){let t=o.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;"),r=new RegExp(`(\\s${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*=\\s*)(?:"[^"]*"|'[^']*')`);return r.test(n)?n.replace(r,`$1"${t}"`):n.replace(/\s*(\/?)>$/,` ${e}="${t}"$1>`)}a(I,"conAttributo");function H(n){return n.replace(/&(#x[0-9a-fA-F]+|#\d+|amp|lt|gt|quot|apos);/g,(e,o)=>{switch(o){case "amp":return "&";case "lt":return "<";case "gt":return ">";case "quot":return '"';case "apos":return "'";default:return String.fromCodePoint(o.startsWith("#x")?parseInt(o.slice(2),16):parseInt(o.slice(1),10))}})}a(H,"decodifica");var x=class extends Error{static{a(this,"ModificaRifiutata");}name="ModificaRifiutata"};function P(n,e){return [...e].sort((o,t)=>t.da-o.da).reduce((o,t)=>o.slice(0,t.da)+t.testo+o.slice(t.a),n)}a(P,"applica");async function ce(n){try{return await No.loadAsync(n)}catch(e){throw new x(`non \xE8 un pacchetto OOXML valido (zip illeggibile: ${e instanceof Error?e.message:String(e)})`)}}a(ce,"apri");async function N(n,e){let o=n.file(e);if(o===null)throw new x(`nel pacchetto manca la parte ${e}`);return o.async("string")}a(N,"leggiParte");function we(n,e){let[o]=F(n);return (o?.figli??[]).flatMap(t=>{let r=w(t.apertura,"Id"),i=w(t.apertura,"Target");return r===void 0||i===void 0?[]:w(t.apertura,"TargetMode")==="External"?[]:[{id:r,tipo:w(t.apertura,"Type")??"",destinazione:i.startsWith("/")?i.slice(1):posix.normalize(posix.join(e,i))}]})}a(we,"relazioni");function Oe(n){let[e]=F(n),o=e?.figli.find(t=>t.nome==="sheets");return (o===void 0?[]:D(n,o)).map(t=>w(t.apertura,"name")??"")}a(Oe,"nomiDeiFogli");function ee(n,e){let o=Oe(n);return o.find(t=>t===e)??o.find(t=>t.toLowerCase()===e.toLowerCase())}a(ee,"foglioConNome");async function me(n,e,o){let[t]=F(e),r=t?.figli.find(u=>u.nome==="sheets"),i=r===void 0?[]:D(e,r),a=i.map(u=>w(u.apertura,"name")??""),l=ee(e,o),s=i.find(u=>w(u.apertura,"name")===l);if(s===void 0)throw new x(`il workbook non ha il foglio \xAB${o}\xBB (fogli presenti: ${a.join(", ")})`);let f=w(s.apertura,"r:id"),m=we(await N(n,"xl/_rels/workbook.xml.rels"),"xl").find(u=>u.id===f);if(m===void 0)throw new x(`il foglio \xAB${o}\xBB non ha una relazione nel workbook`);return m.destinazione}a(me,"parteDelFoglio");async function Ae(n,e){let o=posix.dirname(e),t=`${o}/_rels/${posix.basename(e)}.rels`,r=n.file(t);return r===null?[]:we(await r.async("string"),o).filter(i=>i.tipo.endsWith("/table")).map(i=>i.destinazione)}a(Ae,"tabelleDelFoglio");var hi=["oleSize","customWorkbookViews","pivotCaches","smartTagPr","smartTagTypes","webPublishing","fileRecoveryPr","webPublishObjects","extLst"];function le(n){let[e]=F(n);if(e===void 0)throw new x("workbook.xml senza elemento radice");let o=e.figli.find(i=>i.nome==="calcPr");if(o!==void 0)return w(o.apertura,"fullCalcOnLoad")==="1"?n:P(n,[{da:o.inizio,a:o.fineApertura,testo:I(o.apertura,"fullCalcOnLoad","1")}]);let r=e.figli.find(i=>hi.includes(i.nome))?.inizio??e.inizioChiusura;return P(n,[{da:r,a:r,testo:'<calcPr fullCalcOnLoad="1"/>'}])}a(le,"conRicalcoloAllApertura");async function ue(n){if(n.file("xl/calcChain.xml")===null)return;n.remove("xl/calcChain.xml");let e=a(async(o,t)=>{let r=await N(n,o),[i]=F(r),a=(i?.figli??[]).filter(l=>t(l.apertura)).map(l=>({da:l.inizio,a:l.fine,testo:""}));n.file(o,P(r,a));},"togli");await e("[Content_Types].xml",o=>w(o,"PartName")==="/xl/calcChain.xml"),await e("xl/_rels/workbook.xml.rels",o=>(w(o,"Target")??"").endsWith("calcChain.xml"));}a(ue,"togliCalcChain");async function pe(n){if(n.file("xl/calcChain.xml")!==null)return true;let e=n.file(/^xl\/worksheets\/[^/]+\.xml$/);for(let o of e)if(/<f[\s>/]/.test(await o.async("string")))return true;return false}a(pe,"haFormule");var Uo="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",Xo="application/vnd.ms-excel.sheet.macroEnabled.main+xml";async function Re(n,e){let[o]=F(await N(n,"[Content_Types].xml")),t=(o?.figli??[]).find(l=>w(l.apertura,"PartName")==="/xl/workbook.xml"),r=t===void 0?void 0:w(t.apertura,"ContentType");if(r===(e==="xlsm"?Xo:Uo))return;let a=r===Xo?".xlsm (con macro)":r===Uo?".xlsx (senza macro)":`un tipo che non \xE8 una cartella di lavoro (${r??"nessuno"})`;throw new x(`l'estensione dice .${e} ma il contenuto \xE8 ${a}: estensione e contenuto devono coincidere`)}a(Re,"controllaFormato");var bi="http://schemas.openxmlformats.org/spreadsheetml/2006/main",yi="http://schemas.openxmlformats.org/officeDocument/2006/relationships",wi="http://schemas.openxmlformats.org/package/2006/relationships",He="application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml",Vo=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ `;function Sn(n){let e=n.titoli.map((t,r)=>`<tableColumn id="${r+1}" name="${oe(t)}"/>`).join(""),o=oe(n.nome);return Vo+`<table xmlns="${bi}" id="${n.id}" name="${o}" displayName="${o}" ref="${n.ref}" totalsRowShown="0">`+(n.filtro?`<autoFilter ref="${n.ref}"/>`:"")+`<tableColumns count="${n.titoli.length}">${e}</tableColumns><tableStyleInfo name="TableStyleMedium2" showFirstColumn="0" showLastColumn="0" showRowStripes="1" showColumnStripes="0"/></table>`}a(Sn,"xmlTabella");function An(n){return Vo+`<Relationships xmlns="${wi}"><Relationship Id="rId1" Type="${yi}/table" Target="../tables/${n}"/></Relationships>`}a(An,"relazioniFoglioConTabella");function qo(n){let e=new Set(n),o=1;for(;e.has(`xl/tables/table${o}.xml`);)o+=1;return {numero:o,parte:`xl/tables/table${o}.xml`}}a(qo,"parteTabellaLibera");var Go='<tableParts count="1"><tablePart r:id="rId1"/></tableParts>';async function Jo(n,e){let o=We(e);if(o!==void 0)throw new x(o);let t=new Set,r=0;for(let s of n.file(/^xl\/tables\/[^/]+\.xml$/)){let f=await s.async("string"),[d]=F(f,1);if(d!==void 0){for(let m of ["name","displayName"]){let u=w(d.apertura,m);u!==void 0&&t.add(u.toLowerCase());}r=Math.max(r,Number(w(d.apertura,"id"))||0);}}let i=await N(n,"xl/workbook.xml"),[a]=F(i),l=a?.figli.find(s=>s.nome==="definedNames");for(let s of l===void 0?[]:D(i,l)){let f=w(s.apertura,"name");f!==void 0&&t.add(f.toLowerCase());}if(t.has(e.toLowerCase()))throw new x(`il nome \xAB${e}\xBB \xE8 gi\xE0 usato nel workbook da una tabella o da un nome definito: i nomi di tabella sono unici (senza badare alle maiuscole)`);return r+1}a(Jo,"riservaNomeDiTabella");var Gn=1;function Bo(n){return n.some(e=>e.celle.some(o=>o.cella.tipo==="formula"))}a(Bo,"haCelleFormula");var xi=a(n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"escapeFormulaXml");function $i(n,e){return n.replace(/^\s*=/,"").replaceAll("{row}",String(e)).replaceAll("{prev}",String(e-1))}a($i,"formulaDellaRiga");function ge(n,e,o){let t=o===void 0?"":` s="${o}"`;switch(e.tipo){case "testo":return `<c r="${n}"${t} t="inlineStr"><is><t xml:space="preserve">${_o(e.valore)}</t></is></c>`;case "numero":return `<c r="${n}"${t}><v>${e.valore}</v></c>`;case "booleano":return `<c r="${n}"${t} t="b"><v>${e.valore?1:0}</v></c>`;case "data":return `<c r="${n}" s="${o??Gn}"><v>${e.seriale}</v></c>`;case "formula":return `<c r="${n}"${t}><f>${xi($i(e.formula,Number(/\d+$/.exec(n)?.[0])))}</f></c>`}}a(ge,"xmlCella");function vi(n){return n===void 0||n.size===0?"":`<cols>${[...n].sort(([o],[t])=>o-t).map(([o,t])=>`<col min="${o}" max="${o}" width="${t}" customWidth="1"/>`).join("")}</cols>`}a(vi,"xmlColonne");function Ci(n,e){if(e!==true)return '<sheetViews><sheetView workbookViewId="0"/></sheetViews>';let o=`A${n+1}`;return `<sheetViews><sheetView workbookViewId="0"><pane ySplit="${n}" topLeftCell="${o}" activePane="bottomLeft" state="frozen"/><selection pane="bottomLeft" activeCell="${o}" sqref="${o}"/></sheetView></sheetViews>`}a(Ci,"xmlVista");function ln(n,e={}){let o=e.stileData??String(Gn),t=n[0]?.numero??1,r=1,i=1,a=n.filter(u=>u.celle.length>0).map(u=>{r=Math.max(r,u.numero);let p=u.numero===t,g=u.celle.map(({colonna:b,cella:h})=>{i=Math.max(i,b);let y=p?e.stileIntestazione:e.stileColonna?.get(b)??(h.tipo==="data"?o:void 0);return ge(`${V(b)}${u.numero}`,h,h.tipo==="data"&&y===void 0?o:y)}).join("");return `<row r="${u.numero}">${g}</row>`}).join(""),l=n.find(u=>u.celle.length>0)?.numero??1,s=Math.min(...n.flatMap(u=>u.celle.map(p=>p.colonna)),i),f=`${V(s)}${l}:${V(i)}${r}`,d=e.filtro===true?`<autoFilter ref="${V(s)}${t}:${V(i)}${r}"/>`:"";return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3
+ `+(e.conTabella===true?'<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">':'<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">')+`<dimension ref="${f}"/>`+Ci(t,e.congelaIntestazione)+'<sheetFormatPr defaultRowHeight="15"/>'+vi(e.larghezze)+`<sheetData>${a}</sheetData>`+d+'<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>'+(e.conTabella===true?Go:"")+"</worksheet>"}a(ln,"xmlFoglio");function zi(n){return n>=14&&n<=22||n>=27&&n<=36||n>=45&&n<=47||n>=50&&n<=58}a(zi,"\xE8FormatoIncorporatoDiData");function ki(n){let e=n.replace(/"[^"]*"/g,"").replace(/\[[^\]]*\]/g,"").replace(/\\./g,"").replace(/_./g,"");return /[dmyhs]/i.test(e)}a(ki,"\xE8CodiceDiData");function sn(n){let[e]=F(n),o=e?.figli??[],t=new Map,r=o.find(l=>l.nome==="numFmts");if(r!==void 0)for(let l of D(n,r)){let s=Number(w(l.apertura,"numFmtId")),f=w(l.apertura,"formatCode");f!==void 0&&t.set(s,H(f));}let i=o.find(l=>l.nome==="cellXfs"),a=i===void 0?[]:D(n,i);return l=>{let s=a[Number(l)];if(s===void 0)return false;let f=Number(w(s.apertura,"numFmtId")??"0"),d=t.get(f);return d===void 0?zi(f):ki(d)}}a(sn,"stiliDiData");function Wo(n){let[e]=F(n),o=e?.figli.find(i=>i.nome==="cellXfs"),t=o===void 0?0:D(n,o).length,r=sn(n);for(let i=0;i<t;i++)if(r(String(i)))return String(i)}a(Wo,"primoStileDiData");var Si=new Map([["0",1],["#,##0.00",4],["0.00%",10],["@",49]]);function Jn(n,e){if(e.length===0)return {xml:n,indici:[]};let[o]=F(n),t=o?.figli.find(v=>v.nome==="fonts"),r=o?.figli.find(v=>v.nome==="cellXfs");if(o===void 0||t===void 0||r===void 0)throw new x("styles.xml senza fonts o cellXfs: non si possono aggiungere stili");let i=o.figli.find(v=>v.nome==="numFmts"),a$1=new Map,l=163;for(let v of i===void 0?[]:D(n,i)){let C=Number(w(v.apertura,"numFmtId")),T=w(v.apertura,"formatCode");Number.isFinite(C)&&(l=Math.max(l,C)),T!==void 0&&!a$1.has(T)&&a$1.set(T,C);}let s=D(n,t),f=D(n,r).length,d=[],m=a(v=>{let C=Si.get(v);if(C!==void 0)return C;let T=a$1.get(v);return T!==void 0?T:(l+=1,a$1.set(v,l),d.push(`<numFmt numFmtId="${l}" formatCode="${oe(v)}"/>`),l)},"idDelCodice"),u,p="",g=a(()=>{if(u!==void 0)return u;let v=s[0],C=v===void 0?"":n.slice(v.fineApertura,v.inizioChiusura).replace(/<b\s*\/>/g,"");return u=s.length,p=`<font><b/>${C}</font>`,u},"fontGrassetto"),b=[],h=new Map,y=e.map(v=>{let C=`${v.codice??""}|${v.grassetto===true}`,T=h.get(C);if(T!==void 0)return T;let k=v.codice===void 0?0:m(v.codice),S=v.grassetto===true?g():0,z=(k!==0?' applyNumberFormat="1"':"")+(S!==0?' applyFont="1"':"");b.push(`<xf numFmtId="${k}" fontId="${S}" fillId="0" borderId="0" xfId="0"${z}/>`);let O=String(f+b.length-1);return h.set(C,O),O}),$=[];if(d.length>0)if(i===void 0)$.push({da:o.fineApertura,a:o.fineApertura,testo:`<numFmts count="${d.length}">${d.join("")}</numFmts>`});else {let v=D(n,i).length+d.length;$.push({da:i.inizio,a:i.fineApertura,testo:I(i.apertura,"count",String(v))},{da:i.inizioChiusura,a:i.inizioChiusura,testo:d.join("")});}return p!==""&&$.push({da:t.inizio,a:t.fineApertura,testo:I(t.apertura,"count",String(s.length+1))},{da:t.inizioChiusura,a:t.inizioChiusura,testo:p}),$.push({da:r.inizio,a:r.fineApertura,testo:I(r.apertura,"count",String(f+b.length))},{da:r.inizioChiusura,a:r.inizioChiusura,testo:b.join("")}),{xml:P(n,$),indici:y}}a(Jn,"aggiungiStili");var Ai="yyyy\\-mm\\-dd\\ hh:mm:ss";function Rn(n,e,o){let t=o?.formati??new Map,r=[],i=[...t.keys()];for(let h of i)r.push({codice:t.get(h)});let a=o?.intestazioneGrassetto===true;a&&r.push({grassetto:true});let l=e.some(h=>h.celle.some(y=>y.cella.tipo==="data"&&!t.has(y.colonna))),s=l?Wo(n):void 0,f=l&&s===void 0;f&&r.push({codice:Ai});let{xml:d,indici:m}=Jn(n,r),u=new Map(i.map((h,y)=>[h,m[y]])),p=i.length,g=a?m[p++]:void 0,b=f?m[p]:s;return {xml:d,stileColonna:u,stileIntestazione:g,stileData:b}}a(Rn,"stiliDelFoglio");var Qo="http://schemas.openxmlformats.org/spreadsheetml/2006/main",Fn="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Ko="http://schemas.openxmlformats.org/package/2006/relationships",cn=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
4
+ `,Fi=cn+`<styleSheet xmlns="${Qo}"><numFmts count="1"><numFmt numFmtId="164" formatCode="yyyy\\-mm\\-dd\\ hh:mm:ss"/></numFmts><fonts count="1"><font><sz val="11"/><name val="Calibri"/><family val="2"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="2"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/><xf numFmtId="164" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/></cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>`,Ei=a(n=>cn+'<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>'+(n?`<Override PartName="/xl/tables/table1.xml" ContentType="${He}"/>`:"")+"</Types>","tipiDiContenuto"),Di=cn+`<Relationships xmlns="${Ko}"><Relationship Id="rId1" Type="${Fn}/officeDocument" Target="xl/workbook.xml"/></Relationships>`,Ti=cn+`<Relationships xmlns="${Ko}"><Relationship Id="rId1" Type="${Fn}/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="${Fn}/styles" Target="styles.xml"/></Relationships>`;function Ho(n){return cn+`<workbook xmlns="${Qo}" xmlns:r="${Fn}"><bookViews><workbookView/></bookViews><sheets><sheet name="${oe(n)}" sheetId="1" r:id="rId1"/></sheets></workbook>`}a(Ho,"xmlWorkbook");async function Bn(n,e,o){let t=Rn(Fi,e,o),r=o?.tabella;if(r!==void 0){let a=We(r);if(a!==void 0)throw new x(a)}let i=new No;if(i.file("[Content_Types].xml",Ei(r!==void 0)),i.file("_rels/.rels",Di),i.file("xl/workbook.xml",Bo(e)?le(Ho(n)):Ho(n)),i.file("xl/_rels/workbook.xml.rels",Ti),i.file("xl/styles.xml",t.xml),i.file("xl/worksheets/sheet1.xml",ln(e,{...t.stileData===void 0?{}:{stileData:t.stileData},stileColonna:t.stileColonna,...t.stileIntestazione===void 0?{}:{stileIntestazione:t.stileIntestazione},...o?.larghezze===void 0?{}:{larghezze:o.larghezze},congelaIntestazione:o?.congelaIntestazione===true,filtro:o?.filtro===true&&r===void 0,conTabella:r!==void 0})),r!==void 0){let a=e[0],l=Math.max(...e.map(d=>d.numero)),s=(a?.celle??[]).map(d=>d.cella.tipo==="testo"?d.cella.valore:""),f=Math.max(...(a?.celle??[]).map(d=>d.colonna));i.file("xl/tables/table1.xml",Sn({id:1,nome:r,ref:`A${a?.numero??1}:${V(f)}${l}`,titoli:s,filtro:o?.filtro===true})),i.file("xl/worksheets/_rels/sheet1.xml.rels",An("table1.xml"));}return i.generateAsync({type:"uint8array",compression:"DEFLATE"})}a(Bn,"creaWorkbook");var Ii="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Ni="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml";function Oi(n){let e=new Set(n),o=1;for(;e.has(`xl/worksheets/sheet${o}.xml`);)o+=1;return o}a(Oi,"parteLibera");function Wn(n){return Oi(Object.keys(n.files))}a(Wn,"numeroFoglioLibero");async function Hn(n,e,o,t,r,i=[],a$1){let[l]=F(e),s=l?.figli.find(T=>T.nome==="sheets");if(l===void 0||s===void 0)throw new x("workbook.xml senza elemento sheets");let f=D(e,s).map(T=>Number(w(T.apertura,"sheetId"))),d=Math.max(0,...f.filter(Number.isFinite))+1,m=await N(n,"xl/_rels/workbook.xml.rels"),[u]=F(m);if(u===void 0)throw new x("workbook.xml.rels senza elemento radice");let g=`rId${Math.max(0,...u.figli.map(T=>Number(/^rId(\d+)$/.exec(w(T.apertura,"Id")??"")?.[1]??0)))+1}`,b=`xl/worksheets/sheet${t}.xml`,h=await N(n,"[Content_Types].xml"),[y]=F(h);if(y===void 0)throw new x("[Content_Types].xml senza elemento radice");n.file(b,r);for(let T of i)n.file(T.percorso,T.contenuto);a$1!==void 0&&n.file(`xl/worksheets/_rels/sheet${t}.xml.rels`,a$1);let $=await pe(n),v=P(e,[{da:s.inizioChiusura,a:s.inizioChiusura,testo:`<sheet name="${oe(o)}" sheetId="${d}" r:id="${g}"/>`}]);n.file("xl/workbook.xml",$?le(v):v),n.file("xl/_rels/workbook.xml.rels",P(m,[{da:u.inizioChiusura,a:u.inizioChiusura,testo:`<Relationship Id="${g}" Type="${Ii}/worksheet" Target="worksheets/sheet${t}.xml"/>`}]));let C=a((T,k)=>`<Override PartName="/${T}" ContentType="${k}"/>`,"override");n.file("[Content_Types].xml",P(h,[{da:y.inizioChiusura,a:y.inizioChiusura,testo:C(b,Ni)+i.map(T=>C(T.percorso,T.tipoContenuto)).join("")}]));}a(Hn,"registraFoglio");async function Yo(n,e,o,t){let r=ie(e);if(r!==void 0)throw new x(r);let i=await ce(n),a=await N(i,"xl/workbook.xml"),l=ee(a,e);if(l!==void 0)throw new x(`il foglio \xAB${l}\xBB esiste gi\xE0`);let s=t?.tabella,f=s===void 0?void 0:await Jo(i,s);if(i.file("xl/styles.xml")===null)throw new x("il workbook non ha styles.xml: non si possono aggiungere stili al foglio nuovo");let d=await N(i,"xl/styles.xml"),m=Rn(d,o,t),u=ln(o,{...m.stileData===void 0?{}:{stileData:m.stileData},stileColonna:m.stileColonna,...m.stileIntestazione===void 0?{}:{stileIntestazione:m.stileIntestazione},...t?.larghezze===void 0?{}:{larghezze:t.larghezze},congelaIntestazione:t?.congelaIntestazione===true,filtro:t?.filtro===true&&s===void 0,conTabella:s!==void 0});m.xml!==d&&i.file("xl/styles.xml",m.xml);let p=[],g,b=Wn(i);if(s!==void 0&&f!==void 0){let h=qo(Object.keys(i.files)),y=o[0],$=Math.max(...(y?.celle??[]).map(v=>v.colonna));p.push({percorso:h.parte,contenuto:Sn({id:f,nome:s,ref:`A${y?.numero??1}:${V($)}${Math.max(...o.map(v=>v.numero))}`,titoli:(y?.celle??[]).map(v=>v.cella.tipo==="testo"?v.cella.valore:""),filtro:t?.filtro===true}),tipoContenuto:He}),g=An(`table${h.numero}.xml`);}return await Hn(i,a,e,b,u,p,g),i.generateAsync({type:"uint8array",compression:"DEFLATE"})}a(Yo,"aggiungiFoglio");var Li=["drawing","legacyDrawing","legacyDrawingHF","drawingHF","picture","oleObjects","controls"],Pi=/\{[0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}\}/g;function _i(n){let[e]=F(n);return (e?.figli??[]).map(o=>({id:w(o.apertura,"Id")??"",tipo:w(o.apertura,"Type")??"",target:w(o.apertura,"Target")??"",esterna:w(o.apertura,"TargetMode")==="External"}))}a(_i,"relazioniGrezze");function et(n){let e=new Map;return n.replace(Pi,o=>{let t=o.toUpperCase(),r=e.get(t)??`{${randomUUID().toUpperCase()}}`;return e.set(t,r),r})}a(et,"conGuidNuovi");var Zi=a(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeRegex");async function ji(n){let e=new Set,o=0;for(let a of n.file(/^xl\/tables\/[^/]+\.xml$/)){let[l]=F(await a.async("string"),1);if(l!==void 0){for(let s of ["name","displayName"]){let f=w(l.apertura,s);f!==void 0&&e.add(f.toLowerCase());}o=Math.max(o,Number(w(l.apertura,"id"))||0);}}let t=await N(n,"xl/workbook.xml"),[r]=F(t),i=r?.figli.find(a=>a.nome==="definedNames");for(let a of i===void 0?[]:D(t,i)){let l=w(a.apertura,"name");l!==void 0&&e.add(l.toLowerCase());}return {nomi:e,idMax:o}}a(ji,"tabelleDelPacchetto");function Ui(n,e){let o=2;for(;e.has(`${n}_${o}`.toLowerCase());)o+=1;return `${n}_${o}`}a(Ui,"nomeTabellaLibero");async function Qn(n,e,o){let t=ie(o);if(t!==void 0)throw new x(t);let r=await ce(n),i=await N(r,"xl/workbook.xml");if(ee(i,o)!==void 0)throw new x(`il foglio \xAB${o}\xBB esiste gi\xE0`);if(ee(i,e)===void 0)throw new x(`il foglio modello \xAB${e}\xBB non c'\xE8 nel workbook (fogli presenti: ${Oe(i).join(", ")})`);let a$1=await me(r,i,e),l=await N(r,a$1),[s]=F(l);if(s===void 0)throw new x(`il foglio ${a$1} non ha radice`);let f=posix.dirname(a$1),d=r.file(`${f}/_rels/${posix.basename(a$1)}.rels`),m=d===null?[]:_i(await d.async("string")),u=[...s.figli.filter(S=>Li.includes(S.nome)).map(S=>S.nome),...l.includes("sparklineGroup")?["sparkline"]:[],...m.filter(S=>!S.esterna&&!S.tipo.endsWith("/table")).map(S=>S.tipo.slice(S.tipo.lastIndexOf("/")+1))];if(u.length>0)throw new x(`il foglio modello \xAB${e}\xBB contiene ${[...new Set(u)].join(", ")} (grafici, pivot, disegni o altre parti collegate): il layer non sa duplicarli e il clone li perderebbe; il foglio modello deve avere solo celle, stili e tabelle`);let p=await ji(r),g=[],b=[],h=a(()=>{let S=1;for(;r.file(`xl/tables/table${S}.xml`)!==null||g.some(z=>z.percorso===`xl/tables/table${S}.xml`);)S+=1;return `xl/tables/table${S}.xml`},"liberaTabella");for(let S of m){if(S.esterna){b.push(`<Relationship Id="${oe(S.id)}" Type="${oe(S.tipo)}" Target="${oe(S.target)}" TargetMode="External"/>`);continue}let z=S.target.startsWith("/")?S.target.slice(1):posix.normalize(posix.join(f,S.target)),O=r.file(z);if(O===null)throw new x(`il foglio modello \xAB${e}\xBB rimanda a ${z}, che nel pacchetto manca`);if(r.file(`${posix.dirname(z)}/_rels/${posix.basename(z)}.rels`)!==null)throw new x(`la tabella ${z} del foglio modello \xAB${e}\xBB ha relazioni proprie (una query esterna): il layer non sa duplicarla`);let L=await O.async("string"),[U]=F(L,1);if(U===void 0)throw new x(`la tabella ${z} non ha radice`);let J=w(U.apertura,"displayName")??w(U.apertura,"name")??"Tabella",K=Ui(J,p.nomi);p.nomi.add(K.toLowerCase()),p.idMax+=1;let j=I(U.apertura,"id",String(p.idMax));j=I(j,"name",K),j=I(j,"displayName",K);let q=new RegExp(`(?<![\\w.])${Zi(J)}\\[`,"g");L=et(P(L,[{da:U.inizio,a:U.fineApertura,testo:j}]).replace(q,`${K}[`)),l=l.replace(q,`${K}[`);let R=h();g.push({percorso:R,contenuto:L,tipoContenuto:He}),b.push(`<Relationship Id="${oe(S.id)}" Type="${oe(S.tipo)}" Target="../tables/${posix.basename(R)}"/>`);}let[y]=F(l),$=[],v=y?.figli.find(S=>S.nome==="sheetPr");v!==void 0&&w(v.apertura,"codeName")!==void 0&&$.push({da:v.inizio,a:v.fineApertura,testo:v.apertura.replace(/\s+codeName="[^"]*"/,"")});let C=y?.figli.find(S=>S.nome==="sheetViews");C!==void 0&&$.push({da:C.inizio,a:C.fine,testo:l.slice(C.inizio,C.fine).replace(/\s+tabSelected="[^"]*"/g,"")});let T=et(P(l,$)),k=b.length===0?void 0:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
5
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${b.join("")}</Relationships>`;return await Hn(r,i,o,Wn(r),T,g,k),/<f[\s>/]/.test(T)&&await ue(r),r.generateAsync({type:"uint8array",compression:"DEFLATE"})}a(Qn,"clonaFoglio");var Xi=/<c\s[^>]*?\/>|<c\s[^>]*?>[\s\S]*?<\/c>/g,Vi=/(<f(?:\s[^>]*)?>)([\s\S]*?)(<\/f>)/g;function xe(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}a(xe,"escapeFormula");function fn(n){let e=/^([A-Z]+)(\d+)(?::([A-Z]+)(\d+))?$/.exec(n);if(e?.[1]===void 0||e[2]===void 0)return;let o=a(i=>[...i].reduce((a,l)=>a*26+l.charCodeAt(0)-64,0),"colonna"),t=o(e[1]),r=Number(e[2]);return {c1:t,r1:r,c2:e[3]===void 0?t:o(e[3]),r2:e[4]===void 0?r:Number(e[4])}}a(fn,"intervallo");function Qe(n,e){let o=[];for(let t of n.matchAll(Xi)){let r=t[0];if(!r.includes("<f"))continue;let i=/^<c\s[^>]*?\/?>/.exec(r)?.[0]??"",a=w(i,"r");for(let l of r.matchAll(Vi)){let s=H(l[2]??""),f=e(s,a);if(f===s)continue;let d=(t.index??0)+(l.index??0)+(l[1]??"").length;o.push({da:d,a:d+(l[2]??"").length,testo:xe(f)});}}return o}a(Qe,"modificheFormule");async function ye(n,e,o){return $e(n,e,o),N(n,e)}a(ye,"leggiParteGrande");async function nt(n){let e=[];for(let o of n.file(/^xl\/tables\/[^/]+\.xml$/))e.push({parte:o.name,xml:await o.async("string")});return e}a(nt,"tutteLeTabelle");var qi=/(<(formula[12]?|xm:f|calculatedColumnFormula|totalsRowFormula)(?:\s[^>]*)?>)([\s\S]*?)(<\/\2>)/g;function Le(n,e){let o=[];for(let t of n.matchAll(qi)){let r=H(t[3]??""),i=e(r);if(i===r)continue;let a=(t.index??0)+(t[1]??"").length;o.push({da:a,a:a+(t[3]??"").length,testo:xe(i)});}for(let t of n.matchAll(/<hyperlink\b[^>]*>/g)){let r=w(t[0],"location");if(r===void 0)continue;let i=e(r);i!==r&&o.push({da:t.index??0,a:(t.index??0)+t[0].length,testo:I(t[0],"location",i)});}return o}a(Le,"modificheAltreFormule");function tt(n){if(n.replace(/"(?:[^"]|"")*"/g,'""').includes("!"))return "ha un riferimento a un altro foglio"}a(tt,"motivoNonTraducibile");function ot(n,e,o,t){return n.split(/\s+/).map(r=>{let i=fn(r);if(i===void 0||i.r2!==e||e<=t)return r;let a=`${V(i.c1)}${i.r1}`,l=`${V(i.c2)}${o}`;return a===l?a:`${a}:${l}`}).join(" ")}a(ot,"estendiSqref");function it(n,e,o,t){let r=[];for(let i of n.matchAll(/<(?:conditionalFormatting|dataValidation)\b[^>]*>/g)){let a=w(i[0],"sqref");if(a===void 0)continue;let l=ot(a,e,o,t);l!==a&&r.push({da:i.index??0,a:(i.index??0)+i[0].length,testo:I(i[0],"sqref",l)});}for(let i of n.matchAll(/(<xm:sqref>)([^<]*)(<\/xm:sqref>)/g)){let a=ot(i[2]??"",e,o,t);if(a===i[2])continue;let l=(i.index??0)+(i[1]??"").length;r.push({da:l,a:l+(i[2]??"").length,testo:a});}return r}a(it,"modificheIntervalli");async function rt(n,e){let o=new Set(e.map(t=>t.toLowerCase()));for(let t of n.file(/^xl\/pivotCache\/pivotCacheDefinition[^/]*\.xml$/)){let r=await N(n,t.name),[i]=F(r,3),a=i?.figli.find(s=>s.nome==="cacheSource")?.figli.find(s=>s.nome==="worksheetSource"),l=a&&w(a.apertura,"name");i===void 0||l===void 0||l===""||o.has(l.toLowerCase())&&w(i.apertura,"refreshOnLoad")!=="1"&&n.file(t.name,P(r,[{da:i.inizio,a:i.fineApertura,testo:I(i.apertura,"refreshOnLoad","1")}]));}}a(rt,"ricaricaPivotDelleTabelle");function Gi(n,e){let t=n.file(e)?._data?.uncompressedSize;return typeof t=="number"?t:void 0}a(Gi,"byteDecompressi");function $e(n,e,o){let t=o.maxByteFoglio;if(t===void 0)return;let r=Gi(n,e);if(r!==void 0&&r>t)throw new x(`il foglio ${e} \xE8 di ${r} byte decompressi, oltre il tetto di memoria di ${t}: alza ${o.opzioneTetto??"il tetto"} se la macchina regge`)}a($e,"controllaTetto");var Ji=/<c\s[^>]*?\/>|<c\s[^>]*?>[\s\S]*?<\/c>/g;function En(n){return [...n].reduce((e,o)=>e*26+o.charCodeAt(0)-64,0)}a(En,"numeroDiColonna");function Bi(n){let e=/^([A-Z]+)\d+$/.exec(n??"");return e?.[1]===void 0?void 0:En(e[1])}a(Bi,"colonnaDi");function Ke(n,e){return [...n.matchAll(new RegExp(`<${e}(?:\\s[^>]*)?>([\\s\\S]*?)</${e}>`,"g"))].map(o=>H(o[1]??"")).join("")}a(Ke,"testoDi");function _e(n){let[e]=F(n);return (e?.figli??[]).filter(o=>o.nome==="si").map(o=>Ke(n.slice(o.fineApertura,o.inizioChiusura).replace(/<rPh\b[\s\S]*?<\/rPh>/g,""),"t"))}a(_e,"stringheCondivise");function he(n,e){let o=[],t=n.slice(e.fineApertura,e.inizioChiusura),r=0;for(let i of t.matchAll(Ji)){let a=i[0],l=/^<c\s[^>]*?\/?>/.exec(a)?.[0]??"";r+=1;let s=Bi(w(l,"r"))??r,f=/<f>([\s\S]*?)<\/f>/.exec(a);o.push({colonna:s,inizio:e.fineApertura+(i.index??0),stile:w(l,"s"),formula:f?.[1],testo:a});}return o}a(he,"celleDi");function Ze(n,e){let o=/^<c\s[^>]*?\/?>/.exec(n.testo)?.[0]??"",t=w(o,"t");if(t==="inlineStr")return Ke(n.testo.replace(/<rPh\b[\s\S]*?<\/rPh>/g,""),"t").trim();let r=Ke(n.testo,"v");return t==="s"?(e()[Number(r)]??"").trim():r.trim()}a(Ze,"titoloDiCella");function Wi(n,e){return n.replace(/(?<![A-Za-z$![])(\$?)([A-Z]{1,3})(\$?)(\d+)(?![\d(])/g,(o,t,r,i,a)=>i==="$"?o:`${t}${r}${i}${Number(a)+e}`)}a(Wi,"traslaFormula");function Kn(n){let e=/^([A-Z]+)(\d+)(?::([A-Z]+)(\d+))?$/.exec(n);if(e?.[1]===void 0||e[2]===void 0)return;let o=En(e[1]),t=Number(e[2]);return {c1:o,r1:t,c2:e[3]===void 0?o:En(e[3]),r2:e[4]===void 0?t:Number(e[4])}}a(Kn,"intervallo");var Hi=a((n,e)=>n.replace(/\d+$/,String(e)),"conRiga");async function Qi(n,e,o,t){for(let r of await Ae(n,e)){let i=await N(n,r),[a]=F(i,1),l=a===void 0?void 0:w(a.apertura,"ref"),s=l===void 0?void 0:Kn(l);if(!(a===void 0||l===void 0||s===void 0)&&s.r1===o&&t.every(f=>f>=s.c1&&f<=s.c2)){if(Number(w(a.apertura,"totalsRowCount")??"0")>0)throw new x(`la tabella ${w(a.apertura,"displayName")??r} ha la riga dei totali: le righe nuove andrebbero sotto i totali; togli la riga dei totali o scrivi senza tabella`);return {parte:r,xml:i,ref:l,c1:s.c1,c2:s.c2,r2:s.r2}}}}a(Qi,"tabellaDelFoglio");function Ki(n,e,o){let[t]=F(n.xml);if(t===void 0)return [];let i=[t,...t.figli.filter(l=>l.nome==="autoFilter")].filter(l=>w(l.apertura,"ref")===n.ref).map(l=>({da:l.inizio,a:l.fineApertura,testo:I(l.apertura,"ref",e)})),a=t.figli.find(l=>l.nome==="tableColumns");if(o.length>0&&a!==void 0){let l=D(n.xml,a),s=Math.max(0,...l.map(f=>Number(w(f.apertura,"id"))||0));i.push({da:a.inizio,a:a.fineApertura,testo:I(a.apertura,"count",String(l.length+o.length))}),i.push({da:a.inizioChiusura,a:a.inizioChiusura,testo:o.map((f,d)=>`<tableColumn id="${s+1+d}" name="${oe(f)}"/>`).join("")});}return i}a(Ki,"modificheTabella");async function Ye(n,e){let o=await ce(n);e.formato!==void 0&&await Re(o,e.formato);let t=await N(o,"xl/workbook.xml");if(e.creaFoglioSeManca===true&&ee(t,e.foglio)===void 0){if(e.foglioModello!==void 0){let{foglioModello:A,...X}=e;return Ye(await Qn(n,A,e.foglio),{...X,creaFoglioSeManca:false})}return Yo(n,e.foglio,[e.intestazione,...e.righe],e.aspetto)}let r=await me(o,t,e.foglio);$e(o,r,e);let i=await N(o,r),a$1=await pe(o),[l]=F(i),s=l?.figli.find(A=>A.nome==="sheetData");if(l===void 0||s===void 0)throw new x(`il foglio ${r} non ha sheetData`);let f=0,d=D(i,s).map(A=>{let X=Number(w(A.apertura,"r"))||f+1;return f=X,{numero:X,nodo:A}}),m=d.find(A=>A.numero===e.intestazione.numero);if(m===void 0)throw new x(`il foglio \xAB${e.foglio}\xBB non ha la riga d'intestazione ${e.intestazione.numero}`);let u=o.file("xl/sharedStrings.xml")===null?"<sst/>":await N(o,"xl/sharedStrings.xml"),p,g=a(()=>p??=_e(u),"lette"),b=new Map;for(let A of he(i,m.nodo)){let X=Ze(A,g);X!==""&&!b.has(X)&&b.set(X,A.colonna);}let h=new Map,y=[];for(let A of e.intestazione.celle){if(A.cella.tipo!=="testo")continue;let X=A.cella.valore.trim(),re=b.get(X);re===void 0?y.push({dichiarata:A.colonna,titolo:X}):h.set(A.colonna,re);}let $=await Qi(o,r,e.intestazione.numero,[...h.values()]),v=new Set;for(let A of i.slice(s.fineApertura,s.inizioChiusura).matchAll(/<c\s[^>]*?\br="([A-Z]+)\d+"/g))v.add(En(A[1]??""));let C=Math.max(0,...v)+1;if($!==void 0&&y.length>0){let A=$.c2+1;y.every((re,te)=>!v.has(A+te))&&(C=A);}if(y.length>0&&C+y.length-1>16384)throw new x(`le colonne nuove (${y.map(A=>`\xAB${A.titolo}\xBB`).join(", ")}) superano il limite di Excel (${16384 .toLocaleString("it-IT")} colonne)`);y.forEach((A,X)=>h.set(A.dichiarata,C+X));let T=$!==void 0&&y.length>0&&C===$.c2+1,k=$===void 0||!T?$:{...$,c2:$.c2+y.length},S=[...h.values()],z=Math.max(...d.map(A=>A.numero)),O=e.sostituisci===true;if(!O&&k!==void 0&&z>k.r2)throw new x(`il foglio \xAB${e.foglio}\xBB ha righe sotto la tabella (la tabella finisce alla riga ${k.r2}, il foglio alla ${z}): aggiungere in fondo le sovrascriverebbe o le separerebbe dalla tabella`);let L=k?.r2??z,U=O?e.intestazione.numero:L;if(U+e.righe.length>1048576)throw new x(`${e.righe.length} righe dalla riga ${U+1} superano il limite di Excel (${1048576 .toLocaleString("it-IT")} righe)`);let J=L>e.intestazione.numero?d.find(A=>A.numero===L):void 0,K=new Map((J===void 0?[]:he(i,J.nodo)).map(A=>[A.colonna,A])),j=[...new Set([...S,...k===void 0?[]:Array.from({length:k.c2-k.c1+1},(A,X)=>k.c1+X)])].sort((A,X)=>A-X),q=o.file("xl/styles.xml")===null?void 0:await N(o,"xl/styles.xml"),R=y.flatMap(A=>{let X=e.aspetto?.formati?.get(A.dichiarata);return X===void 0?[]:[{n:A,codice:X}]}),_=q,Y=new Map;if(R.length>0){if(q===void 0)throw new x("il workbook non ha styles.xml: non si pu\xF2 dare un formato alle colonne aggiunte");let A=Jn(q,R.map(({codice:X})=>({codice:X})));_=A.xml,R.forEach(({n:X},re)=>Y.set(h.get(X.dichiarata),A.indici[re]));}let M=_===void 0?()=>false:sn(_),Z=new Map([...[...b].map(([A,X])=>[X,A]),...y.map((A,X)=>[C+X,A.titolo])]),B=false,Q=e.ripetiFormule!==false,W=J===void 0?"":J.nodo.apertura.replace(/^<row/,"").replace(/\/?>$/,"").replace(/\sr\s*=\s*"[^"]*"/,"").replace(/\sspans\s*=\s*"[^"]*"/,""),se=e.righe.map((A,X)=>{let re=U+1+X,te=new Map(A.celle.flatMap(({colonna:ae,cella:Te})=>{let de=h.get(ae);return de===void 0?[]:[[de,Te]]})),Ve=j.flatMap(ae=>{let Te=`${V(ae)}${re}`,de=K.get(ae),qe=te.get(ae),Ge=de?.stile??Y.get(ae);if(qe!==void 0){if(qe.tipo==="data"&&(Ge===void 0||!M(Ge)))throw new x(`riga ${re}: la colonna ${V(ae)} (\xAB${Z.get(ae)??""}\xBB) non ha un formato data nella riga precedente: scrivere una data senza aggiungere stili la mostrerebbe come numero`);return qe.tipo==="formula"&&(B=true),[ge(Te,qe,Ge)]}let So=Ge===void 0?"":` s="${Ge}"`;if(de?.formula!==void 0&&Q){let Ao=tt(de.formula);if(Ao!==void 0)throw new x(`la cella ${V(ae)}${L} (\xAB${Z.get(ae)??""}\xBB) ha la formula \xAB${de.formula}\xBB, che ${Ao}: non so ripeterla sulle righe nuove; dichiara la formula della colonna (formula) o metti repeatFormulas: false`);return B=true,[`<c r="${Te}"${So}><f>${Wi(de.formula,re-L)}</f></c>`]}return Ge===void 0?[]:[`<c r="${Te}"${So}/>`]});return `<row r="${re}"${W}>${Ve.join("")}</row>`}),Se=U+e.righe.length,Ee=O?d.filter(A=>A.numero>e.intestazione.numero):[],$n=Ee.some(A=>/<f[\s>/]/.test(i.slice(A.nodo.inizio,A.nodo.fine))),ne=[],De=se.join(""),zo=Ee[0];if(ne.push(zo!==void 0?{da:zo.nodo.inizio,a:s.inizioChiusura,testo:De}:s.inizioChiusura===s.fine?{da:s.inizio,a:s.fine,testo:`<sheetData>${De}</sheetData>`}:{da:s.inizioChiusura,a:s.inizioChiusura,testo:De}),y.length>0){let A=he(i,m.nodo),X=T?A.find(Ve=>Ve.colonna===C-1)?.stile:void 0,re=y.map((Ve,ae)=>ge(`${V(C+ae)}${e.intestazione.numero}`,{tipo:"testo",valore:Ve.titolo},X)).join(""),te=m.nodo;if(te.inizioChiusura===te.fine)ne.push({da:te.inizio,a:te.fine,testo:`${te.apertura.replace(/\s*\/>$/,">")}${re}</row>`});else {let ae=A.find(qe=>qe.colonna>C)?.inizio??te.inizioChiusura;ne.push({da:ae,a:ae,testo:re});let Te=w(te.apertura,"spans"),de=/^(\d+):(\d+)$/.exec(Te??"");de!==null&&ne.push({da:te.inizio,a:te.fineApertura,testo:I(te.apertura,"spans",`${de[1]}:${Math.max(Number(de[2]),C+y.length-1)}`)});}}let Ue=l.figli.find(A=>A.nome==="dimension"),ko=Ue===void 0?void 0:w(Ue.apertura,"ref");if(Ue!==void 0&&ko!==void 0){let A=Kn(ko);if(A!==void 0){let X=Math.max(A.c2,...j);ne.push({da:Ue.inizio,a:Ue.fineApertura,testo:I(Ue.apertura,"ref",`${V(A.c1)}${A.r1}:${V(X)}${O?Se:Math.max(A.r2,Se)}`)});}}let Xe=l.figli.find(A=>A.nome==="autoFilter"),Zn=Xe===void 0?void 0:w(Xe.apertura,"ref");if(k===void 0&&Xe!==void 0&&Zn!==void 0&&(O||Kn(Zn)?.r2===L)&&ne.push({da:Xe.inizio,a:Xe.fineApertura,testo:I(Xe.apertura,"ref",Hi(Zn,Se))}),O||ne.push(...it(i,L,Se,e.intestazione.numero)),o.file(r,P(i,ne)),_!==void 0&&_!==q&&o.file("xl/styles.xml",_),k!==void 0&&o.file(k.parte,P(k.xml,Ki(k,`${V(k.c1)}${m.numero}:${V(k.c2)}${Se}`,T?y.map(A=>A.titolo):[]))),k!==void 0){let[A]=F(k.xml,1),X=["displayName","name"].flatMap(re=>{let te=A===void 0?void 0:w(A.apertura,re);return te===void 0?[]:[te]});await rt(o,X);}return (a$1||B)&&o.file("xl/workbook.xml",le(t)),(B||$n)&&await ue(o),o.generateAsync({type:"uint8array",compression:"DEFLATE"})}a(Ye,"aggiungiRighe");function Yn(n,e){let o=0;for(let t of e)if(t<n)o+=1;else break;return o}a(Yn,"sopra");function ct(n,e){return e.includes(n)?void 0:n-Yn(n,e)}a(ct,"rimappaRiga");function at(n,e,o){let t=n-Yn(n,o),r=e-Yn(e+1,o);return r<t?void 0:[t,r]}a(at,"rimappaIntervallo");var lt="(\\$?)([A-Z]{1,3})(\\$?)(\\d+)",st="(\\$?)(\\d+)",Yi=new RegExp(`^${lt}(?::${lt})?$`),er=new RegExp(`^${st}:${st}$`);function en(n,e){let o=Yi.exec(n);if(o!==null){let[,r,i,a,l,s,f,d,m]=o,u=Number(l),p=m===void 0?u:Number(m),g=at(u,p,e);if(g===void 0)return;let b=`${r}${i}${a}${g[0]}`;return m===void 0?b:`${b}:${s}${f}${d}${g[1]}`}let t=er.exec(n);if(t!==null){let r=at(Number(t[2]),Number(t[4]),e);return r===void 0?void 0:`${t[1]}${r[0]}:${t[3]}${r[1]}`}return n}a(en,"rimappaRef");function dn(n,e){let o=n.split(/\s+/).filter(t=>t!=="").flatMap(t=>{let r=en(t,e);return r===void 0?[]:[r]});return o.length===0?void 0:o.join(" ")}a(dn,"rimappaSqref");var nr=new RegExp(['"(?:[^"]|"")*"',"\\[[^\\[\\]]*(?:\\[[^\\]]*\\][^\\[\\]]*)*\\]","(?<![A-Za-z0-9_.$])(?:('(?:[^']|'')+'|[A-Za-z_][\\w.]*)!)?(?<ref>\\$?[A-Z]{1,3}\\$?\\d+(?::\\$?[A-Z]{1,3}\\$?\\d+)?|\\$?\\d+:\\$?\\d+)(?![\\w(!])"].join("|"),"g");function or(n){return n.split(":").some(e=>/^\$?[A-Z]{1,3}\d+$/.test(e)||/^\d+$/.test(e))}a(or,"haRigaRelativa");var tr=a(n=>n.startsWith("'")?n.slice(1,-1).replace(/''/g,"'"):n,"senzaApici");function mn(n,e,o){let t=false,r=false,i=n.replace(nr,(...a)=>{let l=a[0],f=a[a.length-1]?.ref;if(f===void 0)return l;let d=a[1];if(!(d===void 0?o.stessoFoglio:tr(d).toLowerCase()===o.foglio.toLowerCase()))return l;t=true;let u=en(f,e)??"#REF!";return u!==f&&or(f)&&(r=true),l.slice(0,l.length-f.length)+u});return {testo:i,riferisce:t,cambiata:i!==n,rigaRelativaCambiata:r}}a(mn,"rimappaFormula");var fe='usa cancellaRighe: "svuota"',ir={scenarios:"scenari",customSheetViews:"viste personalizzate",cellWatches:"celle osservate",dataConsolidate:"un consolidamento dati"},rr=new Set(["table","hyperlink","printerSettings"]);function ft(n){return n.slice(n.lastIndexOf("/")+1)}a(ft,"nomeTipo");async function ar(n,e){let o=n.file(`${posix.dirname(e)}/_rels/${posix.basename(e)}.rels`);if(o===null)return "un disegno";let t=we(await o.async("string"),posix.dirname(e)).map(r=>ft(r.tipo));return t.includes("chart")?"un grafico":t.includes("image")?"un'immagine":"un disegno"}a(ar,"cosaHaIlDisegno");async function no(n,e,o,t=`togliere righe dal foglio \xAB${o}\xBB`,r=fe){let i=posix.dirname(e),a=n.file(`${i}/_rels/${posix.basename(e)}.rels`);if(a!==null)for(let l of we(await a.async("string"),i)){let s=ft(l.tipo);if(rr.has(s))continue;let f=s==="drawing"?await ar(n,l.destinazione):s==="pivotTable"?"una tabella pivot":s==="comments"||s==="vmlDrawing"?"dei commenti":`una parte \xAB${s}\xBB`;throw new x(`non si possono ${t}: ha ${f}, e il layer non sa riscriverne i riferimenti${r===""?"":`; ${r}`}`)}}a(no,"controllaRelazioni");async function lr(n,e,o){let t={foglio:e,stessoFoglio:false};for(let r of n.file(/^xl\/charts\/[^/]+\.xml$/)){let i=await r.async("string");for(let a of i.matchAll(/<c:f>([\s\S]*?)<\/c:f>/g))if(mn(a[1]??"",o,t).riferisce)throw new x(`non si possono togliere righe dal foglio \xAB${e}\xBB: un grafico (${r.name}) ne usa gli intervalli e il layer non sa riscriverli; ${fe}`)}for(let r of n.file(/^xl\/pivotCache\/pivotCacheDefinition[^/]*\.xml$/)){let i=await r.async("string"),a=/<worksheetSource\b[^>]*>/.exec(i)?.[0];if(a!==void 0&&w(a,"sheet")?.toLowerCase()===e.toLowerCase())throw new x(`non si possono togliere righe dal foglio \xAB${e}\xBB: una tabella pivot lo ha come sorgente (${r.name}) e il layer non sa riscrivere la sua cache; ${fe}`)}}a(lr,"controllaAltriRiferimenti");function ut(n,e){return D(n,e).map(o=>{let t=Number(w(o.apertura,"r"));if(!Number.isInteger(t)||t<1)throw new x("una riga del foglio non dichiara il suo numero (attributo r): il layer non sa spostarla");return {numero:t,nodo:o}})}a(ut,"righeDi");function dt(n,e,o,t,r){let i={foglio:o.foglio,stessoFoglio:t};return n.replace(/<f(\s[^>]*?)?(\/>|>([\s\S]*?)<\/f>)/g,(a,l,s,f)=>{let d=w(`<f${l??""}>`,"t");if(d==="dataTable")throw new x(`non si possono togliere righe dal foglio \xAB${o.foglio}\xBB: ${r} ha una tabella dati (what-if) alla riga ${e}; ${fe}`);let m=f===void 0?void 0:mn(f,o.tolte,i);if(d==="shared"&&m?.riferisce===true)throw new x(`non si possono togliere righe dal foglio \xAB${o.foglio}\xBB: ${r} ha una formula condivisa (riga ${e}) che cita le sue righe; riscrivila come formule normali oppure ${fe}`);let u=l??"";if(d==="shared"||d==="array"){let p=w(`<f${u}>`,"ref");if(p!==void 0){if(o.tolte.includes(e)&&d==="shared")throw new x(`non si possono togliere righe dal foglio \xAB${o.foglio}\xBB: la formula condivisa che parte dalla riga ${e} sta in una riga da togliere; ${fe}`);let g=en(p,o.tolte),b=d==="array"&&g!==void 0&&g.length!==0&&eo(g)===eo(p);if(g===void 0||d==="array"&&!b)throw new x(`non si possono togliere righe dal foglio \xAB${o.foglio}\xBB: una formula di matrice (${p}) perderebbe delle righe; ${fe}`);u=I(`<f${u}>`,"ref",g).slice(2,-1);}}return m===void 0?`<f${u}/>`:`<f${u}>${m.testo}</f>`})}a(dt,"riscriviFormule");var eo=a(n=>{let e=[...n.matchAll(/\d+/g)].map(o=>Number(o[0]));return (e[1]??e[0]??0)-(e[0]??0)},"dimensione");function sr(n,e,o){for(let t of n.matchAll(/<f(\s[^>]*?)?(?:\/>|>)/g)){let r=`<f${t[1]??""}>`,i=w(r,"t"),a=w(r,"ref");if(i==="shared"&&a!==void 0||i==="dataTable"||i==="array"&&a!==void 0&&eo(a)>0)throw new x(`non si possono togliere righe dal foglio \xAB${o.foglio}\xBB: la riga ${e} ha ${i==="shared"?"l'origine di una formula condivisa":i==="array"?`una formula di matrice (${a??""}) che si estende su altre righe`:"una tabella dati (what-if)"}; ${fe}`)}}a(sr,"controllaRigaTolta");function cr(n,e,o,t,r,i){let a=ct(o,t.tolte),l=n.slice(e.inizio,e.fine);if(a!==o){let s=e.apertura;l=I(s,"r",String(a))+l.slice(s.length),l=l.replace(/(<c(?:\s[^>]*?)?\sr=")([A-Z]+)\d+(")/g,(f,d,m,u)=>`${d}${m}${a}${u}`);}return /<f[\s>/]/.test(l)&&(l=dt(l,o,t,i,r)),l===n.slice(e.inizio,e.fine)?void 0:l}a(cr,"riscriviRiga");var fr=a(n=>{let e=/^\$?([A-Z]+)\$?(\d+)(?::\$?([A-Z]+)\$?(\d+))?$/.exec(n);return e?.[3]===void 0||e[1]===e[3]&&e[2]===e[4]},"\xE8CellaSingola");function pn(n,e,o,t,r,i){let a=D(n,e).filter(f=>f.nome===o),l=[],s=a.length;for(let f of a){let d=w(f.apertura,t);if(d===void 0)continue;let m=dn(d,r.tolte);m===void 0||i&&fr(m)?(l.push({da:f.inizio,a:f.fine,testo:""}),s-=1):m!==d&&l.push({da:f.inizio,a:f.fineApertura,testo:I(f.apertura,t,m)});}return l.length===0?[]:s===0?[{da:e.inizio,a:e.fine,testo:""}]:(w(e.apertura,"count")!==void 0&&l.push({da:e.inizio,a:e.fineApertura,testo:I(e.apertura,"count",String(s))}),l)}a(pn,"riscriviElenco");function Dn(n,e,o,t,r){let i=n.slice(e.fineApertura,e.inizioChiusura),a={foglio:o.foglio,stessoFoglio:t},l=[];for(let s of i.matchAll(/<(formula[12]?)>([\s\S]*?)<\/\1>/g)){let f=mn(s[2]??"",o.tolte,a);if(!f.cambiata)continue;if(f.rigaRelativaCambiata)throw new x(`non si possono togliere righe dal foglio \xAB${o.foglio}\xBB: ${r} ha una formula (${s[2]??""}) con riferimenti relativi che il layer non sa riscrivere; usa riferimenti assoluti oppure ${fe}`);let d=e.fineApertura+(s.index??0);l.push({da:d+`<${s[1]}>`.length,a:d+`<${s[1]}>`.length+(s[2]??"").length,testo:f.testo});}return l}a(Dn,"riscriviFormuleDelElenco");function ur(n,e,o){let[t]=F(n),r=t?.figli.find(a=>a.nome==="sheetData");if(t===void 0||r===void 0)throw new x(`${o} non ha sheetData`);let i=[];for(let{numero:a,nodo:l}of ut(n,r)){if(e.tolte.includes(a)){sr(n.slice(l.inizio,l.fine),a,e),i.push({da:l.inizio,a:l.fine,testo:""});continue}let s=cr(n,l,a,e,o,true);s!==void 0&&i.push({da:l.inizio,a:l.fine,testo:s});}for(let a of t.figli)switch(a.nome){case "dimension":{let l=w(a.apertura,"ref"),s=l===void 0?void 0:en(l,e.tolte);l!==void 0&&s!==void 0&&s!==l&&i.push({da:a.inizio,a:a.fineApertura,testo:I(a.apertura,"ref",s)});break}case "autoFilter":case "sortState":{let l=w(a.apertura,"ref"),s=l===void 0?void 0:dn(l,e.tolte);l!==void 0&&s!==void 0&&s!==l&&i.push({da:a.inizio,a:a.fineApertura,testo:I(a.apertura,"ref",s)});break}case "mergeCells":i.push(...pn(n,a,"mergeCell","ref",e,true));break;case "hyperlinks":i.push(...pn(n,a,"hyperlink","ref",e,false));break;case "ignoredErrors":i.push(...pn(n,a,"ignoredError","sqref",e,false));break;case "protectedRanges":i.push(...pn(n,a,"protectedRange","sqref",e,false));break;case "dataValidations":i.push(...pn(n,a,"dataValidation","sqref",e,false),...D(n,a).filter(l=>{let s=w(l.apertura,"sqref");return s===void 0||dn(s,e.tolte)!==void 0}).flatMap(l=>Dn(n,l,e,true,"una convalida dati")));break;case "conditionalFormatting":{let l=w(a.apertura,"sqref"),s=l===void 0?void 0:dn(l,e.tolte);if(l!==void 0&&s===void 0){i.push({da:a.inizio,a:a.fine,testo:""});break}i.push(...Dn(n,a,e,true,"una formattazione condizionale")),l!==void 0&&s!==void 0&&s!==l&&i.push({da:a.inizio,a:a.fineApertura,testo:I(a.apertura,"sqref",s)});break}case "extLst":if(/<xm:(?:sqref|f)>/.test(n.slice(a.inizio,a.fine)))throw new x(`non si possono togliere righe dal foglio \xAB${e.foglio}\xBB: ha formattazioni condizionali, convalide o sparkline estese (extLst) con riferimenti che il layer non sa riscrivere; ${fe}`);break;default:{let l=ir[a.nome];if(l!==void 0)throw new x(`non si possono togliere righe dal foglio \xAB${e.foglio}\xBB: ha ${l}, e il layer non sa riscriverne i riferimenti; ${fe}`)}}return i}a(ur,"modificheFoglioBersaglio");function dr(n,e,o){let[t]=F(n),r=t?.figli.find(a=>a.nome==="sheetData");if(t===void 0||r===void 0)return [];let i=[];for(let a of t.figli)a.nome==="conditionalFormatting"?i.push(...Dn(n,a,e,false,"una formattazione condizionale")):a.nome==="dataValidations"&&i.push(...D(n,a).flatMap(l=>Dn(n,l,e,false,"una convalida dati")));if(!/<f[\s>/]/.test(n))return i;for(let a of D(n,r)){let l=n.slice(a.inizio,a.fine);if(!/<f[\s>/]/.test(l))continue;let s=Number(w(a.apertura,"r"))||0,f=dt(l,s,e,false,o);f!==l&&i.push({da:a.inizio,a:a.fine,testo:f});}return i}a(dr,"modificheAltroFoglio");function mr(n,e){let o={foglio:e.foglio,stessoFoglio:false},t=[];for(let r of n.matchAll(/(<definedName\b[^>]*>)([\s\S]*?)<\/definedName>/g)){let i=mn(r[2]??"",e.tolte,o);if(!i.cambiata)continue;let a=(r.index??0)+(r[1]??"").length;t.push({da:a,a:a+(r[2]??"").length,testo:i.testo});}return t}a(mr,"modificheNomi");async function pr(n,e,o){let t=[];for(let r of await Ae(n,e)){let i=await N(n,r),[a]=F(i),l=a===void 0?void 0:w(a.apertura,"ref");if(a===void 0||l===void 0)continue;let s=w(a.apertura,"displayName")??r,f=[...l.matchAll(/\d+/g)].map(h=>Number(h[0])),d=f[0],m=f[f.length-1],u=Number(w(a.apertura,"totalsRowCount")??"0"),p=m-d-u,g=o.tolte.filter(h=>h>=d&&h<=m);if(g.length===0)continue;if(o.tolte.includes(d))throw new x(`non si pu\xF2 togliere l'intestazione (riga ${d}) della tabella ${s}; ${fe}`);if(u>0&&o.tolte.includes(m))throw new x(`non si pu\xF2 togliere la riga dei totali (riga ${m}) della tabella ${s}; ${fe}`);if(g.length>=p)throw new x(`togliere queste righe lascerebbe la tabella ${s} senza righe di dati; ${fe}`);let b=[a,...a.figli.filter(h=>h.nome==="autoFilter")].flatMap(h=>{let y=w(h.apertura,"ref"),$=y===void 0?void 0:en(y,o.tolte);return y!==void 0&&$!==void 0&&$!==y?[{da:h.inizio,a:h.fineApertura,testo:I(h.apertura,"ref",$)}]:[]});t.push({parte:r,xml:P(i,b)});}return t}a(pr,"modificheTabelle");async function oo(n,e){let o=await ce(n);e.formato!==void 0&&await Re(o,e.formato);let t=await N(o,"xl/workbook.xml"),r=await me(o,t,e.foglio);$e(o,r,e);let i=await N(o,r),[a]=F(i),l=a?.figli.find($=>$.nome==="sheetData");if(a===void 0||l===void 0)throw new x(`il foglio ${r} non ha sheetData`);let s=new Set(ut(i,l).map($=>$.numero)),f=[...new Set(e.righe)].filter($=>s.has($)).sort(($,v)=>$-v);if(f.length===0)return {bytes:n,rimosse:0};let d={foglio:e.foglio,tolte:f};await no(o,r,e.foglio),await lr(o,e.foglio,f);let m=P(i,ur(i,d,r)),u=await pr(o,r,d),p=[];for(let $ of o.file(/^xl\/worksheets\/[^/]+\.xml$/)){if($.name===r)continue;let v=await $.async("string"),C=dr(v,d,$.name);C.length>0&&p.push({parte:$.name,xml:P(v,C)});}let g=mr(t,d),b=await pe(o);o.file(r,m);for(let $ of [...u,...p])o.file($.parte,$.xml);let h=g.length>0?P(t,g):t,y=b?le(h):h;return y!==t&&o.file("xl/workbook.xml",y),await ue(o),{bytes:await o.generateAsync({type:"uint8array",compression:"DEFLATE"}),rimosse:f.length}}a(oo,"rimuoviRighe");var gr=Date.UTC(1899,11,30),hr=864e5,to="\0",mt=a(n=>new Date(Math.round(gr+n*hr)).toISOString(),"isoDiSeriale");function br(n){switch(n.tipo){case "testo":return n.valore.trim();case "numero":return String(n.valore);case "booleano":return String(n.valore);case "data":return mt(n.seriale);case "formula":return ""}}a(br,"canonicaDaScrivere");function pt(n,e,o){let t=/^<c\s[^>]*?\/?>/.exec(n.testo)?.[0]??"",r=w(t,"t");if(r==="inlineStr")return {k:"testo",v:Ke(n.testo.replace(/<rPh\b[\s\S]*?<\/rPh>/g,""),"t")};let i=Ke(n.testo,"v");if(i==="")return {k:"altro"};if(r==="s")return {k:"testo",v:e()[Number(i)]??""};if(r==="str")return {k:"testo",v:i};if(r==="b")return {k:"bool",v:i==="1"||i==="true"};if(r==="e"||r==="d")return {k:"altro"};let a=Number(i);return Number.isNaN(a)?{k:"altro"}:{k:"num",v:a,data:n.stile!==void 0&&o(n.stile)}}a(pt,"valoreEsistente");function yr(n){switch(n.k){case "testo":return n.v.trim()===""?void 0:n.v.trim();case "num":return n.data?mt(n.v):String(n.v);case "bool":return String(n.v);case "altro":return}}a(yr,"canonicaEsistente");function wr(n,e){switch(e.tipo){case "testo":return n.k==="testo"&&n.v===e.valore;case "numero":return n.k==="num"&&n.v===e.valore;case "booleano":return n.k==="bool"&&n.v===e.valore;case "data":return n.k==="num"&&Math.abs(n.v-e.seriale)<1e-9;case "formula":return true}}a(wr,"\xE8Uguale");async function io(n,e,o){let t=await me(n,e,o.foglio);$e(n,t,o);let r=await N(n,t),[i]=F(r),a$1=i?.figli.find(h=>h.nome==="sheetData");if(i===void 0||a$1===void 0)throw new x(`il foglio ${t} non ha sheetData`);let l=0,s=D(r,a$1).map(h=>{let y=Number(w(h.apertura,"r"))||l+1;return l=y,{numero:y,nodo:h}}),f=o.intestazione.numero,d=s.find(h=>h.numero===f);if(d===void 0)throw new x(`il foglio \xAB${o.foglio}\xBB non ha la riga d'intestazione ${f}`);let m=n.file("xl/sharedStrings.xml")===null?"<sst/>":await N(n,"xl/sharedStrings.xml"),u,p=a(()=>u??=_e(m),"condivise"),g=new Map;for(let h of he(r,d.nodo)){let y=Ze(h,p);y!==""&&!g.has(y)&&g.set(y,h.colonna);}let b=n.file("xl/styles.xml")===null?()=>false:sn(await N(n,"xl/styles.xml"));return {parte:t,xml:r,sheetData:a$1,righe:s,titoli:g,condivise:p,\u00E8Data:b,numeroIntestazione:f}}a(io,"apriFoglioDati");var gt=a((n,e)=>{let o=n.celle.find(t=>t.colonna===e)?.cella;return o?.tipo==="testo"?o.valore.trim():void 0},"titoloDi");function xr(n,e){return e.map(t=>{let r=n.celle.find(i=>i.colonna===t)?.cella;if(r===void 0)throw new x("un record non ha una parte della chiave");return br(r)}).join(to)}a(xr,"chiaveDelRecord");function $r(n,e){let o=new Map,t=e.chiave.map(r=>{let i=gt(e.intestazione,r);return i===void 0?void 0:n.titoli.get(i)});if(t.some(r=>r===void 0))return o;for(let{numero:r,nodo:i}of n.righe){if(r<=n.numeroIntestazione)continue;let a=new Map(he(n.xml,i).map(f=>[f.colonna,f])),l=t.map(f=>{let d=f===void 0?void 0:a.get(f);return d===void 0?void 0:yr(pt(d,n.condivise,n.\u00E8Data))});if(l.some(f=>f===void 0))continue;let s=l.join(to);o.set(s,[...o.get(s)??[],r]);}return o}a($r,"indiceDelFoglio");function Tn(n,e){let o=new Map,t=[];for(let r of n){let i=xr(r,e),a=o.get(i);a===void 0?(o.set(i,t.length),t.push({chiave:i,riga:r})):t[a]={chiave:i,riga:r};}return t}a(Tn,"righeDaApplicare");var vr=a(n=>n.split(to).join(" / "),"inChiaro");async function Cr(n,e,o){let t=await ce(n),r=await N(t,"xl/workbook.xml"),i=await io(t,r,e),a=new Map(i.righe.map(u=>[u.numero,u.nodo])),l=[],s=0,f=0,d=false;for(let{riga:u,numero:p}of o){let g=a.get(p);if(g===void 0)continue;let b=he(i.xml,g),h=new Map(b.map(k=>[k.colonna,k])),y=[],$=false;for(let{colonna:k,cella:S}of u.celle){let z=gt(e.intestazione,k),O=z===void 0?void 0:i.titoli.get(z);if(O===void 0||S.tipo==="formula")continue;let L=`${V(O)}${p}`,U=h.get(O);if(U!==void 0){let J=pt(U,i.condivise,i.\u00E8Data);if(wr(J,S)&&!/<f[\s>/]/.test(U.testo))continue;if(S.tipo==="data"&&(U.stile===void 0||!i.\u00E8Data(U.stile)))throw new x(`riga ${p}: la colonna ${V(O)} (\xAB${z??""}\xBB) non ha un formato data: scrivere una data senza aggiungere stili la mostrerebbe come numero`);/<f[\s>/]/.test(U.testo)&&(d=true),l.push({da:U.inizio,a:U.inizio+U.testo.length,testo:ge(L,S,U.stile)}),$=true;}else {if(S.tipo==="data")throw new x(`riga ${p}: la cella ${L} (\xAB${z??""}\xBB) \xE8 vuota e non ha un formato data: scrivere una data senza aggiungere stili la mostrerebbe come numero`);y.push({colonna:O,xml:ge(L,S)}),$=true;}}if(!$){f+=1;continue}if(s+=1,y.length===0)continue;y.sort((k,S)=>k.colonna-S.colonna);let v=Math.max(...y.map(k=>k.colonna));if(v>16384)throw new x("colonna oltre il limite di Excel");if(g.inizioChiusura===g.fine){l.push({da:g.inizio,a:g.fine,testo:`${g.apertura.replace(/\s*\/>$/,">")}${y.map(k=>k.xml).join("")}</row>`});continue}let C=new Map;for(let k of y){let z=b.find(O=>O.colonna>k.colonna)?.inizio??g.inizioChiusura;C.set(z,(C.get(z)??"")+k.xml);}for(let[k,S]of C)l.push({da:k,a:k,testo:S});let T=/^(\d+):(\d+)$/.exec(w(g.apertura,"spans")??"");T!==null&&Number(T[2])<v&&l.push({da:g.inizio,a:g.fineApertura,testo:I(g.apertura,"spans",`${T[1]}:${v}`)});}if(s===0)return {bytes:n,aggiornate:s,invariate:f};let m=await pe(t);return t.file(i.parte,P(i.xml,l)),(m||d)&&t.file("xl/workbook.xml",le(r)),d&&await ue(t),{bytes:await t.generateAsync({type:"uint8array",compression:"DEFLATE"}),aggiornate:s,invariate:f}}a(Cr,"applicaAggiornamenti");function zr(n,e,o){let t=false,r=false;return {corpo:he(n,e).map(a=>(/<(?:v|is|f)[\s>/]/.test(a.testo)&&(t=true),/<f[\s>/]/.test(a.testo)&&(r=true),a.stile===void 0?"":`<c r="${V(a.colonna)}${o}" s="${a.stile}"/>`)).join(""),cambiata:t,formule:r}}a(zr,"celleSvuotate");async function kr(n,e,o){let t=await ce(n),r=await N(t,"xl/workbook.xml"),i=await io(t,r,e),a=new Map(i.righe.map(d=>[d.numero,d.nodo])),l=[],s=0,f=false;for(let d of o){let m=a.get(d);if(m===void 0||m.inizioChiusura===m.fine)continue;let{corpo:u,cambiata:p,formule:g}=zr(i.xml,m,d);p&&(s+=1,f||=g,l.push({da:m.fineApertura,a:m.inizioChiusura,testo:u}));}return s===0?{bytes:n,cancellate:s}:(t.file(i.parte,P(i.xml,l)),f&&(t.file("xl/workbook.xml",le(r)),await ue(t)),{bytes:await t.generateAsync({type:"uint8array",compression:"DEFLATE"}),cancellate:s})}a(kr,"svuotaRighe");async function ro(n,e){let o=Tn(e.righe,e.chiave),t=e.cancella??new Set,r=o.filter(y=>!t.has(y.riga)),i=await ce(n);e.formato!==void 0&&await Re(i,e.formato);let a$1=await N(i,"xl/workbook.xml"),l=a(y=>Ye(n,{...e,righe:y}),"aggiungi");if(ee(a$1,e.foglio)===void 0)return {bytes:await l(r.map($=>$.riga)),aggiunte:r.length,aggiornate:0,invariate:0,cancellate:0,modificato:true};let s=await io(i,a$1,e),f=$r(s,e),d=[],m=[],u=[];for(let{chiave:y,riga:$}of o){let v=f.get(y),C=t.has($);if(v===void 0)C||d.push($);else {if(v.length>1)throw new x(`il foglio \xAB${e.foglio}\xBB ha pi\xF9 righe con la chiave \xAB${vr(y)}\xBB (righe ${v.join(", ")}): non si sa quale aggiornare`);C?u.push(v[0]):m.push({riga:$,numero:v[0]});}}let p=e.intestazione.celle.some(y=>y.cella.tipo==="testo"&&!s.titoli.has(y.cella.valore.trim())),g=d.length>0||p?await l(d):n,b=m.length===0?{bytes:g,aggiornate:0,invariate:0}:await Cr(g,e,m),h=u.length===0?{bytes:b.bytes,cancellate:0}:e.cancellaRighe==="svuota"?await kr(b.bytes,e,u):await oo(b.bytes,{foglio:e.foglio,righe:u,...e.formato===void 0?{}:{formato:e.formato},...e.maxByteFoglio===void 0?{}:{maxByteFoglio:e.maxByteFoglio},...e.opzioneTetto===void 0?{}:{opzioneTetto:e.opzioneTetto}}).then(y=>({bytes:y.bytes,cancellate:y.rimosse}));return {bytes:h.bytes,aggiunte:d.length,aggiornate:b.aggiornate,invariate:b.invariate,cancellate:h.cancellate,modificato:h.bytes!==n}}a(ro,"upsertRighe");function ao(n,e){let o=0;for(let t of e)if(t<n)o+=1;else break;return o}a(ao,"sopra");function nn(n,e){switch(e.tipo){case "elimina":return e.tolte.includes(n)?void 0:n-ao(n,e.tolte);case "inserisci":return n>=e.posizione?n+1:n;case "permuta":return e.verso.get(n)??n}}a(nn,"rimappaColonna");function In(n,e,o){if(o.tipo==="elimina"){let l=n-ao(n,o.tolte),s=e-ao(e+1,o.tolte);return s<l?{tipo:"sparito"}:{tipo:"ok",c1:l,c2:s}}if(o.tipo==="inserisci")return {tipo:"ok",c1:n>=o.posizione?n+1:n,c2:e>=o.posizione?e+1:e};let t=false;for(let l of o.verso.keys())l>=n&&l<=e&&(t=true);if(!t)return {tipo:"ok",c1:n,c2:e};let r=[];for(let l=n;l<=e;l+=1)r.push(nn(l,o)??l);r.sort((l,s)=>l-s);let i=r[0],a=r[r.length-1];return a-i===r.length-1?{tipo:"ok",c1:i,c2:a}:{tipo:"spezzato"}}a(In,"rimappaIntervalloColonne");var ht="(\\$?)([A-Z]{1,3})(\\$?)(\\d+)",bt="(\\$?)([A-Z]{1,3})",yt=new RegExp(`^${ht}(?::${ht})?$`),wt=new RegExp(`^${bt}:${bt}$`);function ve(n){let e=[...n].reduce((o,t)=>o*26+t.charCodeAt(0)-64,0);return e>=1&&e<=16384?e:void 0}a(ve,"numero");function je(n){let e=n,o="";for(;e>0;){let t=(e-1)%26;o=String.fromCharCode(65+t)+o,e=Math.floor((e-1)/26);}return o}a(je,"lettere");function Ce(n,e){let o=yt.exec(n);if(o!==null){let[,r,i,a,l,s,f,d,m]=o,u=ve(i),p=f===void 0?u:ve(f);if(u===void 0||p===void 0)return {tipo:"ok",ref:n};let g=In(u,p,e);if(g.tipo!=="ok")return g;let b=`${r}${je(g.c1)}${a}${l}`;return {tipo:"ok",ref:f===void 0?b:`${b}:${s}${je(g.c2)}${d}${m}`}}let t=wt.exec(n);if(t!==null){let r=ve(t[2]),i=ve(t[4]);if(r===void 0||i===void 0)return {tipo:"ok",ref:n};let a=In(r,i,e);return a.tipo!=="ok"?a:{tipo:"ok",ref:`${t[1]}${je(a.c1)}:${t[3]}${je(a.c2)}`}}return {tipo:"ok",ref:n}}a(Ce,"rimappaRefColonne");function Nn(n,e){let o=[];for(let t of n.split(/\s+/).filter(r=>r!=="")){let r=Ce(t,e);if(r.tipo==="spezzato")return {tipo:"spezzato",ref:t};r.tipo==="ok"&&o.push(r.ref);}return o.length===0?{tipo:"sparito"}:{tipo:"ok",sqref:o.join(" ")}}a(Nn,"rimappaSqrefColonne");var Sr=new RegExp(['"(?:[^"]|"")*"',"\\[[^\\[\\]]*(?:\\[[^\\]]*\\][^\\[\\]]*)*\\]","(?<![A-Za-z0-9_.$])(?:('(?:[^']|'')+'|[A-Za-z_\xC0-\uFFFF][\\w.\xC0-\uFFFF]*)!)?(?<ref>\\$?[A-Z]{1,3}\\$?\\d+(?::\\$?[A-Z]{1,3}\\$?\\d+)?|\\$?[A-Z]{1,3}:\\$?[A-Z]{1,3})(?![\\w(!])"].join("|"),"g"),Ar=a(n=>n.startsWith("'")?n.slice(1,-1).replace(/''/g,"'"):n,"senzaApici");function Rr(n){return n.split(":").some(e=>!e.startsWith("$"))}a(Rr,"haColonnaRelativa");function ze(n,e,o){let t=false,r=[],i=n.replace(Sr,(...a)=>{let l=a[0],f=a[a.length-1]?.ref;if(f===void 0)return l;let d=a[1];if(!(d===void 0?o.stessoFoglio:Ar(d).toLowerCase()===o.foglio.toLowerCase()))return l;let u=Ce(f,e);if(u.tipo==="spezzato")return r.push(l),l;let p=u.tipo==="ok"?u.ref:"#REF!";return p!==f&&Rr(f)&&(t=true),l.slice(0,l.length-f.length)+p});return {testo:i,cambiata:i!==n,colonnaRelativaCambiata:t,spezzati:r}}a(ze,"rimappaFormulaColonne");function On(n){let e=yt.exec(n);if(e!==null){let t=ve(e[2]),r=e[6]===void 0?t:ve(e[6]);return t===void 0||r===void 0?void 0:r-t+1}let o=wt.exec(n);if(o!==null){let t=ve(o[2]),r=ve(o[4]);return t===void 0||r===void 0?void 0:r-t+1}}a(On,"larghezzaRef");function Fe(n){let e=/^\$?([A-Z]{1,3})/.exec(n);return e?.[1]===void 0?void 0:ve(e[1])}a(Fe,"colonnaDiRef");var G=a((n,e)=>new x(`non si possono ${n.azione}: ${e}`),"rifiuto"),Fr={scenarios:"scenari",customSheetViews:"viste personalizzate",cellWatches:"celle osservate",dataConsolidate:"un consolidamento dati",colBreaks:"interruzioni di pagina fra le colonne"},xt=/<c\s[^>]*?\/>|<c\s[^>]*?>[\s\S]*?<\/c>/g,Er=a((n,e)=>On(n)===On(e),"larghezzaOk");function lo(n,e,o,t,r){return n.replace(/<f(\s[^>]*?)?(\/>|>([\s\S]*?)<\/f>)/g,(i,a,l,s)=>{let f=`<f${a??""}>`,d=w(f,"t");if(d==="dataTable"&&t)throw G(o,`${r} ha una tabella dati (what-if) in ${e}, e il layer non sa riscriverla`);let m=s===void 0?void 0:ze(s,o.mappa,{foglio:o.foglio,stessoFoglio:t});if(m!==void 0&&m.spezzati.length>0)throw G(o,`la formula di ${r} in ${e} cita ${m.spezzati.join(", ")}, che dopo lo spostamento non sarebbe pi\xF9 un intervallo contiguo`);if(d==="shared"&&m?.cambiata===true)throw G(o,`${r} ha una formula condivisa (${e}) che cita colonne che cambiano; riscrivila come formule normali`);let u=a??"",p=w(f,"ref");if(t&&(d==="shared"||d==="array")&&p!==void 0){let b=Ce(p,o.mappa);if(b.tipo!=="ok"||!Er(p,b.ref))throw G(o,`una formula ${d==="array"?"di matrice":"condivisa"} (${p}) di ${r} perderebbe o spezzerebbe delle colonne`);u=I(f,"ref",b.ref).slice(2,-1);}let g=m?.testo;return u===(a??"")&&g===s?i:g===void 0?`<f${u}/>`:`<f${u}>${g}</f>`})}a(lo,"riscriviFormuleCella");function Dr(n,e,o,t){for(let r of n.matchAll(/<f(\s[^>]*?)?(?:\/>|>)/g)){let i=`<f${r[1]??""}>`,a=w(i,"t"),l=w(i,"ref");if(a==="shared"&&l!==void 0||a==="dataTable"||a==="array"&&l!==void 0&&(On(l)??1)>1)throw G(o,`${t}: la cella ${e} ha ${a==="shared"?"l'origine di una formula condivisa":a==="array"?`una formula di matrice (${l??""}) che si estende su altre colonne`:"una tabella dati (what-if)"}`)}}a(Dr,"controllaCellaTolta");function Tr(n,e,o,t,r){if(e.inizioChiusura===e.fine)return;let i=n.slice(e.fineApertura,e.inizioChiusura),a=[];for(let d of i.matchAll(xt)){let m=d[0],u=/^<c\s[^>]*?\/?>/.exec(m)?.[0]??"",p=w(u,"r"),g=/^([A-Z]+)(\d+)$/.exec(p??""),b=Fe(p??"");if(p===void 0||g===null||b===void 0)throw G(t,`${r}: una cella della riga ${o} non dichiara la sua posizione (attributo r), e il layer non sa spostarla`);let h=nn(b,t.mappa);if(h===void 0){Dr(m,p,t,r);continue}/<f[\s>/]/.test(m)&&(m=lo(m,p,t,true,r)),h!==b&&(m=I(u,"r",`${je(h)}${g[2]}`)+m.slice(u.length)),a.push({colonna:h,testo:m});}if(t.nuova!==void 0&&o===t.rigaTitoli){let d=t.mappa.posizione;a.push({colonna:d,testo:ge(`${je(d)}${o}`,{tipo:"testo",valore:t.nuova.titolo},t.nuova.stile)});}a.sort((d,m)=>d.colonna-m.colonna);let l=i.replace(xt,""),s=a.map(d=>d.testo).join("")+l;return s===i?void 0:e.apertura.replace(/\sspans="[^"]*"/,"")+s+n.slice(e.inizioChiusura,e.fine)}a(Tr,"riscriviRiga");function Ir(n,e,o){if(o.tipo!=="permuta"){let a=In(n,e,o);return a.tipo==="ok"?[{min:a.c1,max:a.c2}]:[]}let t=[...o.verso.keys()].filter(a=>a>=n&&a<=e).sort((a,l)=>a-l),r=[],i=n;for(let a of t){a>i&&r.push({min:i,max:a-1});let l=o.verso.get(a);r.push({min:l,max:l}),i=a+1;}return i<=e&&r.push({min:i,max:e}),r}a(Ir,"segmenti");function Nr(n,e,o){let t=D(n,e).flatMap(a=>{let l=Number(w(a.apertura,"min")),s=Number(w(a.apertura,"max"));return !Number.isInteger(l)||!Number.isInteger(s)?[]:Ir(l,s,o.mappa).map(f=>({...f,testo:I(I(a.apertura,"min",String(f.min)),"max",String(f.max))}))});t.sort((a,l)=>a.min-l.min);let r=t.map(a=>a.testo).join(""),i=n.slice(e.fineApertura,e.inizioChiusura);return r===i?[]:t.length===0?[{da:e.inizio,a:e.fine,testo:""}]:[{da:e.fineApertura,a:e.inizioChiusura,testo:r}]}a(Nr,"riscriviCols");var Or=a(n=>{let e=/^\$?([A-Z]+)\$?(\d+)(?::\$?([A-Z]+)\$?(\d+))?$/.exec(n);return e?.[3]===void 0||e[1]===e[3]&&e[2]===e[4]},"\xE8CellaSingola");function hn(n,e,o,t,r,i,a){let l=D(n,e).filter(d=>d.nome===o),s=[],f=l.length;for(let d of l){let m=w(d.apertura,t);if(m===void 0)continue;let u=Nn(m,r.mappa);if(u.tipo==="spezzato")throw G(r,`${i} ha ${o==="mergeCell"?"una cella unita":"un riferimento"} (${u.ref}) che dopo lo spostamento non sarebbe pi\xF9 contiguo`);if(u.tipo==="sparito"||a&&Or(u.sqref)){s.push({da:d.inizio,a:d.fine,testo:""}),f-=1;continue}let p=u.sqref===m?d.apertura:I(d.apertura,t,u.sqref),g=w(d.apertura,"location");if(o==="hyperlink"&&g!==void 0){let b=ze(g,r.mappa,{foglio:r.foglio,stessoFoglio:true});if(b.spezzati.length>0)throw G(r,`${i} ha un collegamento a ${b.spezzati.join(", ")}, che dopo lo spostamento non sarebbe pi\xF9 contiguo`);b.cambiata&&(p=I(p,"location",b.testo));}p!==d.apertura&&s.push({da:d.inizio,a:d.fineApertura,testo:p});}return s.length===0?[]:f===0?[{da:e.inizio,a:e.fine,testo:""}]:(w(e.apertura,"count")!==void 0&&s.push({da:e.inizio,a:e.fineApertura,testo:I(e.apertura,"count",String(f))}),s)}a(hn,"riscriviElenco");function bn(n,e,o,t,r){let i=n.slice(e.fineApertura,e.inizioChiusura),a=[];for(let l of i.matchAll(/<(formula[12]?)>([\s\S]*?)<\/\1>/g)){let s=ze(l[2]??"",o.mappa,{foglio:o.foglio,stessoFoglio:t});if(s.spezzati.length>0)throw G(o,`${r} ha una formula (${l[2]??""}) con ${s.spezzati.join(", ")}, che dopo lo spostamento non sarebbe pi\xF9 contiguo`);if(!s.cambiata)continue;if(s.colonnaRelativaCambiata)throw G(o,`${r} ha una formula (${l[2]??""}) con riferimenti di colonna relativi che il layer non sa riscrivere; usa riferimenti assoluti`);let f=e.fineApertura+(l.index??0);a.push({da:f+`<${l[1]}>`.length,a:f+`<${l[1]}>`.length+(l[2]??"").length,testo:s.testo});}return a}a(bn,"riscriviFormuleDelElenco");function so(n,e,o,t){let r=w(e.apertura,"ref");if(r===void 0)return [];let i=Ce(r,o.mappa);if(i.tipo!=="ok")throw G(o,`il filtro di ${t} (${r}) ${i.tipo==="sparito"?"perderebbe tutte le sue colonne":"dopo lo spostamento non sarebbe pi\xF9 contiguo"}`);let a=[];i.ref!==r&&a.push({da:e.inizio,a:e.fineApertura,testo:I(e.apertura,"ref",i.ref)});let l=Fe(r),s=Fe(i.ref);for(let f of D(n,e))if(f.nome==="filterColumn"){let d=Number(w(f.apertura,"colId")),m=nn(l+d,o.mappa);m===void 0?a.push({da:f.inizio,a:f.fine,testo:""}):m-s!==d&&a.push({da:f.inizio,a:f.fineApertura,testo:I(f.apertura,"colId",String(m-s))});}else f.nome==="sortState"&&a.push(...$t(n,f,o,t));return a}a(so,"riscriviFiltro");function $t(n,e,o,t){let r=[],i=a(a=>{let l=w(a.apertura,"ref");if(l===void 0)return;let s=Ce(l,o.mappa);if(s.tipo!=="ok")throw G(o,`l'ordinamento di ${t} (${l}) non si sa riscrivere dopo lo spostamento`);s.ref!==l&&r.push({da:a.inizio,a:a.fineApertura,testo:I(a.apertura,"ref",s.ref)});},"riscrivi");i(e);for(let a of D(n,e))a.nome==="sortCondition"&&i(a);return r}a($t,"riscriviOrdinamento");function vt(n,e,o){let[t]=F(n),r=t?.figli.find(l=>l.nome==="sheetData");if(t===void 0||r===void 0)throw new x(`${o} non ha sheetData`);let i=[],a=0;for(let l of D(n,r)){let s=Number(w(l.apertura,"r"))||a+1;a=s;let f=Tr(n,l,s,e,o);f!==void 0&&i.push({da:l.inizio,a:l.fine,testo:f});}for(let l of t.figli)switch(l.nome){case "dimension":{let s=w(l.apertura,"ref"),f=s===void 0?void 0:Ce(s,e.mappa);s!==void 0&&f?.tipo==="ok"&&f.ref!==s&&i.push({da:l.inizio,a:l.fineApertura,testo:I(l.apertura,"ref",f.ref)});break}case "cols":i.push(...Nr(n,l,e));break;case "autoFilter":i.push(...so(n,l,e,o));break;case "sortState":i.push(...$t(n,l,e,o));break;case "mergeCells":i.push(...hn(n,l,"mergeCell","ref",e,o,true));break;case "hyperlinks":i.push(...hn(n,l,"hyperlink","ref",e,o,false));break;case "ignoredErrors":i.push(...hn(n,l,"ignoredError","sqref",e,o,false));break;case "protectedRanges":i.push(...hn(n,l,"protectedRange","sqref",e,o,false));break;case "dataValidations":i.push(...hn(n,l,"dataValidation","sqref",e,o,false),...D(n,l).filter(s=>{let f=w(s.apertura,"sqref");return f===void 0||Nn(f,e.mappa).tipo!=="sparito"}).flatMap(s=>bn(n,s,e,true,"una convalida dati")));break;case "conditionalFormatting":{let s=w(l.apertura,"sqref"),f=s===void 0?void 0:Nn(s,e.mappa);if(f?.tipo==="spezzato")throw G(e,`${o} ha una formattazione condizionale su ${f.ref} che dopo lo spostamento non sarebbe pi\xF9 contigua`);if(f?.tipo==="sparito"){i.push({da:l.inizio,a:l.fine,testo:""});break}i.push(...bn(n,l,e,true,"una formattazione condizionale")),s!==void 0&&f?.tipo==="ok"&&f.sqref!==s&&i.push({da:l.inizio,a:l.fineApertura,testo:I(l.apertura,"sqref",f.sqref)});break}case "extLst":if(/<xm:(?:sqref|f)>/.test(n.slice(l.inizio,l.fine)))throw G(e,`${o} ha formattazioni condizionali, convalide o sparkline estese (extLst) con riferimenti che il layer non sa riscrivere`);break;default:{let s=Fr[l.nome];if(s!==void 0)throw G(e,`${o} ha ${s}, e il layer non sa riscriverne i riferimenti`)}}return i}a(vt,"modificheFoglioBersaglio");var Mr=/[A-Za-z0-9_.À-￿]/,Lr=/^[A-Za-z_À-￿][A-Za-z0-9_.À-￿]*$/;function co(n){return n.replace(/(['[\]#])/g,"'$1")}a(co,"protetto");function Pr(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(Pr,"perRegex");function _r(n,e){let o=0;for(let t=e;t<n.length;t+=1){let r=n[t];if(r==="'"&&"[]#'".includes(n[t+1]??"\0"))t+=1;else if(r==="[")o+=1;else if(r==="]"&&(o-=1,o===0))return t}return -1}a(_r,"fineParentesi");function Zr(n,e,o){let t=e+1;for(;t<n.length;)if(n[t]===o)if(n[t+1]===o)t+=2;else return t+1;else t+=1;return n.length}a(Zr,"saltaQuotato");function on(n,e,o,t,r={}){let i=new RegExp(`\\[(@)?${Pr(co(o))}\\]`,"gi"),a$1=a(d=>d===void 0?`[${co(t)}]`:Lr.test(t)?`[@${t}]`:`[@[${co(t)}]]`,"nuovo"),l=a(d=>d.replace(i,(m,u)=>a$1(u)),"riscrivi"),s="",f=0;for(;f<n.length;){let d=n[f];if(d==='"'||d==="'"){let m=Zr(n,f,d);s+=n.slice(f,m),f=m;}else if(d==="["){let m=_r(n,f);if(m===-1){s+=n.slice(f);break}let u=f;for(;u>0&&Mr.test(n[u-1]);)u-=1;let p=n.slice(u,f),g=n.slice(f,m+1),b=p.toLowerCase()===e.toLowerCase()||p===""&&r.dentroLaTabella===true;s+=b?l(g):g,f=m+1;}else s+=d,f+=1;}return s}a(on,"riscriviColonna");var jr=/<c\s[^>]*?\/>|<c\s[^>]*?>[\s\S]*?<\/c>/g;async function Ct(n,e,o){for(let t of n.file(/^xl\/charts\/[^/]+\.xml$/)){let r=await t.async("string");for(let i of r.matchAll(/<(?:\w+:)?f>([^<]*)<\/(?:\w+:)?f>/g)){let a=ze(H(i[1]??""),e.mappa,{foglio:e.foglio,stessoFoglio:false});if(a.cambiata||a.spezzati.length>0)throw G(e,`un grafico (${t.name}) ne usa gli intervalli (${H(i[1]??"")}) e il layer non sa riscriverli`)}}for(let t of n.file(/^xl\/pivotCache\/pivotCacheDefinition[^/]*\.xml$/)){let r=await t.async("string"),i=/<worksheetSource\b[^>]*>/.exec(r)?.[0];if(i===void 0)continue;let a=w(i,"sheet"),l=w(i,"name");if(a?.toLowerCase()===e.foglio.toLowerCase()||l!==void 0&&o.some(s=>s.toLowerCase()===l.toLowerCase()))throw G(e,`una tabella pivot ha ${a===void 0?`la tabella \xAB${l??""}\xBB`:"il foglio"} come sorgente (${t.name}) e il layer non sa riscrivere la sua cache`)}}a(Ct,"controllaGraficiEPivot");function Ur(n){let e=/^\$?([A-Z]+)\$?(\d+)(?::\$?([A-Z]+)\$?(\d+))?$/.exec(n);if(e?.[1]===void 0||e[2]===void 0)return;let o=Fe(e[1]+"1"),t=e[3]===void 0?o:Fe(e[3]+"1");return {c1:o,c2:t,r1:Number(e[2]),r2:Number(e[4]??e[2])}}a(Ur,"rettangolo");function zt(n,e){return o=>{let t=ze(o,n.mappa,{foglio:n.foglio,stessoFoglio:e});if(t.spezzati.length>0)throw G(n,`una formula di tabella (${o}) cita ${t.spezzati.join(", ")}, che dopo lo spostamento non sarebbe pi\xF9 contiguo`);return t.testo}}a(zt,"riscriviFormuleTabella");async function kt(n,e,o){let t=[],r=[];for(let i of await Ae(n,e)){let a$1=await N(n,i),[l]=F(a$1),s=l===void 0?void 0:w(l.apertura,"ref"),f=s===void 0?void 0:Ur(s);if(l===void 0||s===void 0||f===void 0)continue;let d=w(l.apertura,"displayName")??i;if(/<(?:xmlColumnPr|queryTable)\b|\squeryTableFieldId=/.test(a$1))throw G(o,`la tabella ${d} \xE8 legata a una query o a una mappa XML, e il layer non sa riscriverla`);let m=l.figli.find(k=>k.nome==="tableColumns"),u=m===void 0?[]:D(a$1,m),p=a(k=>k>=f.c1&&k<=f.c2,"dentro"),g=o.mappa,b=u.map((k,S)=>S),h,y=[];if(g.tipo==="elimina"){b=b.filter(k=>!g.tolte.includes(f.c1+k));for(let k of u.keys())g.tolte.includes(f.c1+k)&&y.push(w(u[k].apertura,"name")??"");if(b.length===0&&u.length>0)throw G(o,`la tabella ${d} perderebbe tutte le sue colonne`)}else if(g.tipo==="inserisci"){if(f.c1<g.posizione&&g.posizione<=f.c2){if(f.r1!==o.rigaTitoli)throw G(o,`la colonna nuova cadrebbe dentro la tabella ${d}, che ha l'intestazione alla riga ${f.r1} e non alla riga dei titoli (${o.rigaTitoli})`);b.splice(g.posizione-f.c1,0,-1),h=o.nuova?.titolo;}}else {for(let[S,z]of g.verso)if(p(S)!==p(z))throw G(o,`il riordino porterebbe colonne dentro o fuori dalla tabella ${d} (${s})`);b=u.map((S,z)=>[...u.keys()].find(L=>nn(f.c1+L,g)===f.c1+z)??z);}r.push({parte:i,nome:d,...f,colonnePerse:y});let $=zt(o,true),v=b.map(k=>{if(k===-1)return `<tableColumn id="${Math.max(0,...u.map(L=>Number(w(L.apertura,"id")??"0")))+1}" name="${(h??"").replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}"/>`;let S=u[k],z=a$1.slice(S.inizio,S.fine);return P(z,Le(z,$))}),C=[],T=Ce(s,g);if(T.tipo!=="ok")throw G(o,`la tabella ${d} (${s}) non si sa riscrivere`);T.ref!==s&&C.push({da:l.inizio,a:l.fineApertura,testo:I(l.apertura,"ref",T.ref)});for(let k of l.figli)k.nome==="autoFilter"&&C.push(...so(a$1,k,o,`la tabella ${d}`));if(m!==void 0){let k=w(m.apertura,"count");k!==void 0&&Number(k)!==v.length&&C.push({da:m.inizio,a:m.fineApertura,testo:I(m.apertura,"count",String(v.length))});let S=v.join("");S!==a$1.slice(m.fineApertura,m.inizioChiusura)&&C.push({da:m.fineApertura,a:m.inizioChiusura,testo:S});}C.length>0&&t.push({parte:i,xml:P(a$1,C)});}return {scritture:t,tabelle:r}}a(kt,"modificheTabelle");async function St(n,e,o){let t=[];for(let r of n.file(/^xl\/tables\/[^/]+\.xml$/)){if(o.has(r.name))continue;let i=await r.async("string");if(!i.toLowerCase().includes(e.foglio.toLowerCase()))continue;let a=Le(i,zt(e,false));a.length>0&&t.push({parte:r.name,xml:P(i,a)});}return t}a(St,"modificheTabelleAltrui");function At(n,e,o){let t=[];for(let i of n.matchAll(jr)){let a=i[0];if(!/<f[\s>/]/.test(a))continue;let l=/^<c\s[^>]*?\/?>/.exec(a)?.[0]??"",s=lo(a,w(l,"r")??"?",e,false,o);s!==a&&t.push({da:i.index??0,a:(i.index??0)+a.length,testo:s});}let[r]=F(n);for(let i of r?.figli??[])if(i.nome==="conditionalFormatting")t.push(...bn(n,i,e,false,"una formattazione condizionale"));else if(i.nome==="dataValidations")t.push(...D(n,i).flatMap(a=>bn(n,a,e,false,"una convalida dati")));else if(i.nome==="hyperlinks")for(let a of D(n,i)){let l=w(a.apertura,"location");if(l===void 0)continue;let s=ze(l,e.mappa,{foglio:e.foglio,stessoFoglio:false});if(s.spezzati.length>0)throw G(e,`${o} ha un collegamento a ${s.spezzati.join(", ")}, che dopo lo spostamento non sarebbe pi\xF9 contiguo`);s.cambiata&&t.push({da:a.inizio,a:a.fineApertura,testo:I(a.apertura,"location",s.testo)});}return t}a(At,"modificheAltroFoglio");function Rt(n,e){let[o]=F(n),t=o?.figli.find(i=>i.nome==="definedNames"),r=[];for(let i of t===void 0?[]:D(n,t)){let a=H(n.slice(i.fineApertura,i.inizioChiusura)),l=ze(a,e.mappa,{foglio:e.foglio,stessoFoglio:false});if(l.spezzati.length>0)throw G(e,`il nome definito \xAB${w(i.apertura,"name")??""}\xBB cita ${l.spezzati.join(", ")}, che dopo lo spostamento non sarebbe pi\xF9 contiguo`);l.cambiata&&r.push({da:i.fineApertura,a:i.inizioChiusura,testo:xe(l.testo)});}return r}a(Rt,"modificheNomi");var Xr=a(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"perRegex");async function Ft(n,e,o,t,r){let i=o.filter(s=>e.mappa.tipo==="permuta"||s.colonnePerse.length>0);if(i.length===0)return;let a$1=a((s,f,d)=>{for(let m of i){if(new RegExp(`${Xr(m.nome)}\\[\\[[^\\]]*\\]\\s*:\\s*\\[`,"i").test(s))throw G(e,`${f} usa un intervallo di colonne della tabella ${m.nome} (${s}), che lo spostamento cambierebbe di significato`);for(let p of m.colonnePerse)if(on(s,m.nome,p,"",{dentroLaTabella:d(m)})!==s)throw G(e,`${f} cita con un riferimento strutturato la colonna \xAB${p}\xBB della tabella ${m.nome} (${s}), che diventerebbe #REF!`)}},"controlla");for(let s of n.file(/^xl\/worksheets\/[^/]+\.xml$/)){let f=await ye(n,s.name,r);if(!f.includes("["))continue;let d=s.name===t;Qe(f,(m,u)=>{let p=/^([A-Z]+)(\d+)$/.exec(u??""),g=p?.[1]===void 0?0:Fe(p[1])??0,b=Number(p?.[2]??0);return a$1(m,`una formula (${u??"?"})`,h=>d&&g>=h.c1&&g<=h.c2&&b>h.r1&&b<=h.r2),m});}for(let s of n.file(/^xl\/tables\/[^/]+\.xml$/)){let f=await s.async("string");Le(f,d=>(a$1(d,`una colonna calcolata (${s.name})`,m=>m.parte===s.name),d));}let l=await N(n,"xl/workbook.xml");for(let s of l.matchAll(/<definedName\b[^>]*name="([^"]*)"[^>]*>([\s\S]*?)<\/definedName>/g))a$1(H(s[2]??""),`il nome definito \xAB${s[1]??""}\xBB`,()=>false);}a(Ft,"controllaStrutturati");async function fo(n,e,o,t){let r=o??1,i=await N(n,"xl/workbook.xml"),a=await me(n,i,e),l=await ye(n,a,t),[s]=F(l),f=s?.figli.find(b=>b.nome==="sheetData");if(s===void 0||f===void 0)throw new x(`il foglio ${a} non ha sheetData`);let d=0,m=D(l,f).map(b=>{let h=Number(w(b.apertura,"r"))||d+1;return d=h,{numero:h,nodo:b}}).find(b=>b.numero===r);if(m===void 0)throw new x(`il foglio \xAB${e}\xBB non ha la riga d'intestazione ${r}`);let u=n.file("xl/sharedStrings.xml")===null?"<sst/>":await N(n,"xl/sharedStrings.xml"),p,g=he(l,m.nodo).map(b=>({titolo:Ze(b,()=>p??=_e(u)),colonna:b.colonna,stile:b.stile})).filter(b=>b.titolo!=="");return {foglio:ee(i,e)??e,parteFoglio:a,foglioXml:l,riga:r,titoli:g}}a(fo,"leggiIntestazione");function Mn(n,e){let o=e.trim().toLowerCase(),t=n.titoli.filter(r=>r.titolo.toLowerCase()===o);if(t.length>1)throw new x(`il titolo \xAB${e}\xBB compare in pi\xF9 colonne della riga ${n.riga} del foglio \xAB${n.foglio}\xBB: non si sa quale intendere`);return t[0]}a(Mn,"trova");async function uo(n,e,o,t,r,i){let a={foglio:e.foglio,mappa:o,azione:t,rigaTitoli:e.riga,...i===void 0?{}:{nuova:i}},l=await N(n,"xl/workbook.xml");await no(n,e.parteFoglio,e.foglio,t,"");let s=P(e.foglioXml,vt(e.foglioXml,a,e.parteFoglio)),{scritture:f,tabelle:d}=await kt(n,e.parteFoglio,a);await Ct(n,a,d.map(y=>y.nome)),await Ft(n,a,d,e.parteFoglio,r);let m=[];for(let y of n.file(/^xl\/worksheets\/[^/]+\.xml$/)){if(y.name===e.parteFoglio)continue;let $=await ye(n,y.name,r);if(!$.toLowerCase().includes(e.foglio.toLowerCase()))continue;let v=At($,a,y.name);v.length>0&&m.push({parte:y.name,xml:P($,v)});}let u=await St(n,a,new Set(d.map(y=>y.parte))),p=Rt(l,a);n.file(e.parteFoglio,s);for(let y of [...f,...m,...u])n.file(y.parte,y.xml);let g=p.length>0?P(l,p):l,h=await pe(n)?le(g):g;h!==l&&n.file("xl/workbook.xml",h),await ue(n);}a(uo,"eseguiMappa");async function Et(n,e,o){let t=await fo(n,e.foglio,e.rigaIntestazione,o),r=[...new Set(e.colonne.flatMap(i=>{let a=Mn(t,i);return a===void 0?[]:[a.colonna]}))].sort((i,a)=>i-a);return r.length===0?"gia-fatta":(await uo(n,t,{tipo:"elimina",tolte:r},`cancellare colonne dal foglio \xAB${t.foglio}\xBB`,o),"fatta")}a(Et,"cancellaColonne");async function Dt(n,e,o){let t=await fo(n,e.foglio,e.rigaIntestazione,o),r=e.ordine.map(l=>{let s=Mn(t,l);if(s===void 0)throw new x(`il foglio \xAB${t.foglio}\xBB non ha la colonna \xAB${l}\xBB nella riga ${t.riga} (colonne presenti: ${t.titoli.map(f=>f.titolo).join(", ")})`);return s.colonna});if(new Set(r).size!==r.length)throw new x("l'ordine cita due volte la stessa colonna");let i=[...r].sort((l,s)=>l-s),a=new Map;return r.forEach((l,s)=>{let f=i[s];l!==f&&a.set(l,f);}),a.size===0?"gia-fatta":(await uo(n,t,{tipo:"permuta",verso:a},`riordinare le colonne del foglio \xAB${t.foglio}\xBB`,o),"fatta")}a(Dt,"riordinaColonne");async function Tt(n,e,o){let t=false;for(let r of e.colonne){let i=await fo(n,e.foglio,e.rigaIntestazione,o);if(Mn(i,r.titolo)!==void 0)continue;let a=Mn(i,r.dopo);if(a===void 0)throw new x(`il foglio \xAB${i.foglio}\xBB non ha la colonna \xAB${r.dopo}\xBB nella riga ${i.riga}, dopo cui inserire \xAB${r.titolo}\xBB (colonne presenti: ${i.titoli.map(l=>l.titolo).join(", ")})`);await uo(n,i,{tipo:"inserisci",posizione:a.colonna+1},`inserire colonne nel foglio \xAB${i.foglio}\xBB`,o,{titolo:r.titolo.trim(),stile:a.stile}),t=true;}return t?"fatta":"gia-fatta"}a(Tt,"inserisciColonne");var mo="[A-Za-z_\xC0-\uFFFF][\\w.\xC0-\uFFFF]*",Vr="(\\$?[A-Z]{1,3}\\$?\\d+(?::\\$?[A-Z]{1,3}\\$?\\d+)?|\\$?[A-Z]{1,3}:\\$?[A-Z]{1,3}|\\$?\\d+:\\$?\\d+|[\\w.]+)?",It=new RegExp(['"(?:[^"]|"")*"',"\\[[^\\[\\]]*(?:\\[[^\\]]*\\][^\\[\\]]*)*\\]",`(?<![\\w.$'#])(?<nome>'(?:[^']|'')+'|${mo}(?::${mo})?)!${Vr}`].join("|"),"g"),qr=a(n=>n.startsWith("'")?n.slice(1,-1).replace(/''/g,"'"):n,"senzaApici");function Nt(n){return qr(n).split(":")}a(Nt,"fogliDi");function Gr(n){return new RegExp(`^${mo}$`).test(n)?/^[A-Za-z]{1,3}\d+$/.test(n)||/^[Rr]\d*(?:[Cc]\d*)?$/.test(n):true}a(Gr,"serveQuotare");function Ot(n,e,o){let t=n.replace(It,(...r)=>{let i=r[0],l=r[r.length-1]?.nome;if(l===void 0)return i;let s=Nt(l);if(!s.some(p=>p.toLowerCase()===e.toLowerCase()))return i;let f=s.map(p=>p.toLowerCase()===e.toLowerCase()?o:p),d=f.some(p=>Gr(p)),m=f.join(":");return (d?`'${m.replace(/'/g,"''")}'`:m)+i.slice(l.length)});return {testo:t,cambiata:t!==n}}a(Ot,"rinominaFoglioInFormula");function ke(n,e){let o=[];for(let t of n.matchAll(It)){let r=t.groups?.nome;r!==void 0&&Nt(r).some(i=>i.toLowerCase()===e.toLowerCase())&&o.push(t[0]);}return o}a(ke,"citazioniDelFoglio");var Jr=new Set(["table","drawing","vmlDrawing","comments","threadedComment","printerSettings","hyperlink"]),po=8,Br=a(n=>n.slice(n.lastIndexOf("/")+1),"nomeTipo");function go(n){let e=posix.dirname(n),o=posix.basename(n);return e==="."?`_rels/${o}.rels`:`${e}/_rels/${o}.rels`}a(go,"relsDi");async function Mt(n){let e=new Set,o=[""];for(;o.length>0;){let t=o.pop(),r=n.file(t===""?"_rels/.rels":go(t));if(r===null)continue;let i=t===""?"":posix.dirname(t);for(let a of we(await r.async("string"),i))e.has(a.destinazione)||n.file(a.destinazione)===null||(e.add(a.destinazione),o.push(a.destinazione));}return e}a(Mt,"raggiungibili");var Wr=/<(?:\w+:)?f>([^<]*)<\/(?:\w+:)?f>/g,Lt=/<(f|formula[12]?|xm:f|calculatedColumnFormula|totalsRowFormula)(?:\s[^>]*)?>([\s\S]*?)<\/\1>/g;async function Hr(n,e,o,t,r,i,a){let l=[],s=new Map,[f]=F(e),d=f?.figli.find(p=>p.nome==="sheets"),m=we(await N(n,"xl/_rels/workbook.xml.rels"),"xl");for(let p of d===void 0?[]:D(e,d)){let g=m.find(b=>b.id===w(p.apertura,"r:id"));g!==void 0&&s.set(g.destinazione,w(p.apertura,"name")??"");}for(let p of n.file(/^xl\/worksheets\/[^/]+\.xml$/)){if(p.name===i||r.has(p.name))continue;let g=await ye(n,p.name,a);if(!g.toLowerCase().includes(o.toLowerCase()))continue;let b=`foglio \xAB${s.get(p.name)??p.name}\xBB`;for(let h of g.matchAll(Lt))for(let y of ke(H(h[2]??""),o))l.push({dove:`una formula del ${b}`,cosa:y});for(let h of g.matchAll(/<hyperlink\b[^>]*>/g)){let y=w(h[0],"location");for(let $ of ke(y??"",o))l.push({dove:`un collegamento del ${b}`,cosa:$});}}for(let p of n.file(/^xl\/tables\/[^/]+\.xml$/)){if(r.has(p.name))continue;let g=await p.async("string");for(let b of g.matchAll(Lt))for(let h of ke(H(b[2]??""),o))l.push({dove:`una tabella (${p.name})`,cosa:h});}let u=f?.figli.find(p=>p.nome==="definedNames");for(let p of u===void 0?[]:D(e,u)){if(w(p.apertura,"localSheetId")===String(t))continue;let g=H(e.slice(p.fineApertura,p.inizioChiusura));for(let b of ke(g,o))l.push({dove:`il nome definito \xAB${w(p.apertura,"name")??""}\xBB`,cosa:b});}for(let p of n.file(/^xl\/charts\/[^/]+\.xml$/)){if(r.has(p.name))continue;let g=await p.async("string");for(let b of g.matchAll(Wr))for(let h of ke(H(b[1]??""),o))l.push({dove:`un grafico (${p.name})`,cosa:h});}for(let p of n.file(/^xl\/pivotCache\/pivotCacheDefinition[^/]*\.xml$/)){let g=await p.async("string"),b=/<worksheetSource\b[^>]*>/.exec(g)?.[0];b!==void 0&&w(b,"sheet")?.toLowerCase()===o.toLowerCase()&&l.push({dove:`una tabella pivot (${p.name})`,cosa:`sorgente ${w(b,"ref")??""}`.trim()});}return l}a(Hr,"chiLoCita");async function Pt(n,e,o){let t=await N(n,"xl/workbook.xml"),r=ee(t,e.foglio);if(r===void 0)return "gia-fatta";let i=Oe(t),a=i.indexOf(r),[l]=F(t),s=l?.figli.find(M=>M.nome==="sheets"),f=s===void 0?[]:D(t,s);if(f.filter((M,Z)=>Z!==a&&(w(M.apertura,"state")??"visible")==="visible").length===0)throw new x(`non si pu\xF2 cancellare il foglio \xAB${r}\xBB: un workbook deve avere almeno un foglio visibile`);let m=f[a],u=we(await N(n,"xl/_rels/workbook.xml.rels"),"xl"),p=m===void 0?void 0:w(m.apertura,"r:id"),g=u.find(M=>M.id===p);if(m===void 0||g===void 0)throw new x(`il foglio \xAB${r}\xBB non ha una relazione nel workbook`);let b=g.destinazione,h=n.file(go(b));if(h!==null)for(let M of we(await h.async("string"),posix.dirname(b))){let Z=Br(M.tipo);if(Z==="pivotTable")throw new x(`non si pu\xF2 cancellare il foglio \xAB${r}\xBB: ha una tabella pivot, e il layer non sa toglierne la cache`);if(!Jr.has(Z))throw new x(`non si pu\xF2 cancellare il foglio \xAB${r}\xBB: ha una parte \xAB${Z}\xBB che il layer non sa togliere`)}let y=await Mt(n),$=await N(n,"xl/_rels/workbook.xml.rels"),[v]=F($),C=v?.figli.find(M=>w(M.apertura,"Id")===p);if(C===void 0)throw new x("relazioni del workbook illeggibili");let T=P($,[{da:C.inizio,a:C.fine,testo:""}]);n.file("xl/_rels/workbook.xml.rels",T);let k=await Mt(n),S=new Set([...y].filter(M=>!k.has(M)));S.add(b);let z=await Hr(n,t,r,a,S,b,o);if(z.length>0){n.file("xl/_rels/workbook.xml.rels",$);let M=z.slice(0,po).map(B=>`${B.dove} (${B.cosa})`).join("; "),Z=z.length>po?` e altri ${z.length-po}`:"";throw new x(`non si pu\xF2 cancellare il foglio \xAB${r}\xBB: lo citano ${M}${Z}, che diventerebbero #REF!`)}let O=[{da:m.inizio,a:m.fine,testo:""}],L=l?.figli.find(M=>M.nome==="definedNames"),U=L===void 0?[]:D(t,L),J=U.length;for(let M of U){let Z=w(M.apertura,"localSheetId");if(Z===void 0)continue;let B=Number(Z);B===a?(O.push({da:M.inizio,a:M.fine,testo:""}),J-=1):B>a&&O.push({da:M.inizio,a:M.fineApertura,testo:I(M.apertura,"localSheetId",String(B-1))});}L!==void 0&&J===0&&(O.length=1,O.push({da:L.inizio,a:L.fine,testo:""}));let K=l?.figli.find(M=>M.nome==="bookViews");for(let M of K===void 0?[]:D(t,K)){let Z=M.apertura;for(let B of ["activeTab","firstSheet"]){let Q=w(Z,B);if(Q===void 0)continue;let W=Number(Q),se=W>a||W===a&&a===i.length-1?W-1:W;se!==W&&(Z=I(Z,B,String(se)));}Z!==M.apertura&&O.push({da:M.inizio,a:M.fineApertura,testo:Z});}for(let M of S)n.remove(M),n.remove(go(M));let j=await N(n,"[Content_Types].xml"),[q]=F(j),R=(q?.figli??[]).filter(M=>{let Z=w(M.apertura,"PartName");return Z!==void 0&&S.has(Z.slice(1))}).map(M=>({da:M.inizio,a:M.fine,testo:""}));n.file("[Content_Types].xml",P(j,R));let _=P(t,O),Y=await pe(n);return n.file("xl/workbook.xml",Y?le(_):_),await ue(n),"fatta"}a(Pt,"cancellaFoglio");var Qr=/<(?:\w+:)?f>([^<]*)<\/(?:\w+:)?f>/g;async function Kr(n,e){for(let o of n.file(/^xl\/charts\/[^/]+\.xml$/)){let t=await o.async("string");for(let r of t.matchAll(Qr))if(ke(H(r[1]??""),e).length>0)throw new x(`non si pu\xF2 rinominare il foglio \xAB${e}\xBB: un grafico (${o.name}) lo cita e il layer non sa riscriverne i riferimenti`)}for(let o of n.file(/^xl\/pivotCache\/pivotCacheDefinition[^/]*\.xml$/)){let t=await o.async("string"),r=/<worksheetSource\b[^>]*>/.exec(t)?.[0];if(r!==void 0&&w(r,"sheet")?.toLowerCase()===e.toLowerCase())throw new x(`non si pu\xF2 rinominare il foglio \xAB${e}\xBB: una tabella pivot lo ha come sorgente (${o.name}) e il layer non sa riscrivere la sua cache`)}for(let o of n.file(/^xl\/drawings\/[^/]+\.xml$/)){let t=await o.async("string");for(let r of t.matchAll(/\stextlink\s*=\s*"([^"]*)"/g))if(ke(H(r[1]??""),e).length>0)throw new x(`non si pu\xF2 rinominare il foglio \xAB${e}\xBB: una forma (${o.name}) \xE8 collegata a una sua cella e il layer non sa riscriverla`)}}a(Kr,"controllaChiNonSiRiscrive");async function _t(n,e,o){let t=ie(e.a);if(t!==void 0)throw new x(`nome nuovo: ${t}`);let r=await N(n,"xl/workbook.xml"),i=ee(r,e.da),a$1=ee(r,e.a);if(i===void 0){if(a$1!==void 0)return "gia-fatta";throw new x(`n\xE9 \xAB${e.da}\xBB n\xE9 \xAB${e.a}\xBB sono fogli del workbook`)}if(i===e.a)return "gia-fatta";if(a$1!==void 0&&a$1!==i)throw new x(`esiste gi\xE0 un foglio \xAB${a$1}\xBB (i nomi si confrontano senza badare alle maiuscole)`);await Kr(n,i);let l=a(g=>Ot(g,i,e.a).testo,"rinomina"),s=new Map,f=a(g=>g.toLowerCase().includes(i.toLowerCase()),"citano");for(let g of n.file(/^xl\/worksheets\/[^/]+\.xml$/)){let b=await ye(n,g.name,o);if(!f(b))continue;let h=[...Qe(b,y=>l(y)),...Le(b,l)];h.length>0&&s.set(g.name,P(b,h));}for(let g of n.file(/^xl\/tables\/[^/]+\.xml$/)){let b=await g.async("string");if(!f(b))continue;let h=Le(b,l);h.length>0&&s.set(g.name,P(b,h));}let d=[],[m]=F(r),u=m?.figli.find(g=>g.nome==="sheets");for(let g of u===void 0?[]:D(r,u))w(g.apertura,"name")===i&&d.push({da:g.inizio,a:g.fineApertura,testo:I(g.apertura,"name",e.a)});let p=m?.figli.find(g=>g.nome==="definedNames");for(let g of p===void 0?[]:D(r,p)){let b=H(r.slice(g.fineApertura,g.inizioChiusura)),h=l(b);h!==b&&d.push({da:g.fineApertura,a:g.inizioChiusura,testo:xe(h)});}for(let[g,b]of s)n.file(g,b);return n.file("xl/workbook.xml",P(r,d)),"fatta"}a(_t,"rinominaFoglio");async function ho(n,e,o={}){let t=await ce(n);o.formato!==void 0&&await Re(t,o.formato);let r=[];for(let[a,l]of e.entries())try{r.push(await Yr(t,l,o));}catch(s){throw s instanceof x?new x(`operazione ${a+1} (${l.op}): ${s.message}`):s}let i=r.includes("fatta");return i?{bytes:await t.generateAsync({type:"uint8array",compression:"DEFLATE"}),esiti:r,modificato:i}:{bytes:n,esiti:r,modificato:i}}a(ho,"applicaOperazioni");function Yr(n,e,o){switch(e.op){case "riordinaFogli":return ea(n,e);case "rinominaColonna":return na(n,e,o);case "rinominaFoglio":return _t(n,e,o);case "cancellaFoglio":return Pt(n,e,o);case "cancellaColonne":return Et(n,e,o);case "riordinaColonne":return Dt(n,e,o);case "inserisciColonne":return Tt(n,e,o)}}a(Yr,"esegui");async function ea(n,e){let o=await N(n,"xl/workbook.xml"),[t]=F(o),r=t?.figli.find(h=>h.nome==="sheets");if(t===void 0||r===void 0)throw new x("workbook.xml senza l'elenco dei fogli");let i=D(o,r),a$1=Oe(o),l=[];for(let h of e.ordine){let y=ee(o,h);if(y===void 0)throw new x(`il workbook non ha il foglio \xAB${h}\xBB (fogli presenti: ${a$1.join(", ")})`);let $=a$1.indexOf(y);if(l.includes($))throw new x(`il foglio \xAB${y}\xBB compare due volte nell'ordine`);l.push($);}let s=[...l,...a$1.map((h,y)=>y).filter(h=>!l.includes(h))];if(s.every((h,y)=>h===y))return "gia-fatta";let f=new Map(s.map((h,y)=>[h,y])),d=i[0],m=i[i.length-1],u=[{da:d.inizio,a:m.fine,testo:s.map(h=>{let y=i[h];return o.slice(y.inizio,y.fine)}).join("")}],p=a((h,y)=>{let $=w(h,y);if($===void 0)return;let v=f.get(Number($));return v===void 0?void 0:I(h,y,String(v))},"rimappa"),g=t.figli.find(h=>h.nome==="definedNames");for(let h of g===void 0?[]:D(o,g)){let y=p(h.apertura,"localSheetId");y!==void 0&&y!==h.apertura&&u.push({da:h.inizio,a:h.fineApertura,testo:y});}let b=t.figli.find(h=>h.nome==="bookViews");for(let h of b===void 0?[]:D(o,b)){let y=Number(w(h.apertura,"activeTab")??"0"),$=f.get(y),v=h.apertura;$!==void 0&&$!==y&&(v=I(v,"activeTab",String($))),v=p(v,"firstSheet")??v,v!==h.apertura&&u.push({da:h.inizio,a:h.fineApertura,testo:v});}return n.file("xl/workbook.xml",P(o,u)),"fatta"}a(ea,"riordinaFogli");async function na(n,e,o){let t=e.da.trim(),r=e.a.trim();if(r==="")throw new x("il nuovo titolo \xE8 vuoto");let i=e.rigaIntestazione??1,a$1=await N(n,"xl/workbook.xml"),l=await me(n,a$1,e.foglio),s=o;$e(n,l,s);let f=await N(n,l),[d]=F(f),m=d?.figli.find(z=>z.nome==="sheetData");if(d===void 0||m===void 0)throw new x(`il foglio ${l} non ha sheetData`);let u=0,p=D(f,m).map(z=>{let O=Number(w(z.apertura,"r"))||u+1;return u=O,{numero:O,nodo:z}}).find(z=>z.numero===i);if(p===void 0)throw new x(`il foglio \xAB${e.foglio}\xBB non ha la riga d'intestazione ${i}`);let g=n.file("xl/sharedStrings.xml")===null?"<sst/>":await N(n,"xl/sharedStrings.xml"),b,h=a(()=>b??=_e(g),"lette"),y=he(f,p.nodo).map(z=>({cella:z,titolo:Ze(z,h)})),$=y.find(z=>z.titolo===t),v=y.find(z=>z.titolo.toLowerCase()===r.toLowerCase());if($===void 0){if(v!==void 0)return "gia-fatta";throw new x(`n\xE9 \xAB${t}\xBB n\xE9 \xAB${r}\xBB sono titoli della riga ${i} del foglio \xAB${e.foglio}\xBB`)}if($.titolo===r)return "gia-fatta";if(v!==void 0&&v!==$)throw new x(`\xAB${r}\xBB esiste gi\xE0 nella riga ${i} del foglio \xAB${e.foglio}\xBB: rinominare creerebbe due colonne con lo stesso titolo`);let C=await oa(n,l,i,$.cella.colonna);if(C!==void 0&&/[\r\n\t]/.test(r))throw new x(`il titolo \xAB${r.replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")}\xBB ha a capo o tabulazioni: in una tabella non \xE8 ammesso (a capo)`);let T=ge(`${V($.cella.colonna)}${i}`,{tipo:"testo",valore:r},$.cella.stile),k=[{da:$.cella.inizio,a:$.cella.inizio+$.cella.testo.length,testo:T}],S=new Map;if(C!==void 0){let z=C.nome,O=a(j=>{let q=/^([A-Z]+)(\d+)$/.exec(j??""),R=fn(j??"");return q!==null&&R!==void 0&&R.c1>=C.c1&&R.c1<=C.c2&&R.r1>C.r1&&R.r1<=C.r2},"posizione"),L=n.file(/^xl\/worksheets\/[^/]+\.xml$/).map(j=>j.name);for(let j of L){let q=j===l?f:await ye(n,j,s),R=j===l;if(!q.toLowerCase().includes(z.toLowerCase())&&!(R&&q.includes("[")))continue;let _=Qe(q,(Y,M)=>on(Y,z,t,r,{dentroLaTabella:R&&O(M)}));R?k.push(..._):_.length>0&&S.set(j,P(q,_));}for(let j of await nt(n)){let q=j.parte===C.parte,R=[],[_]=F(j.xml,3),Y=_?.figli.find(Z=>Z.nome==="tableColumns"),M=Y===void 0?[]:D(j.xml,Y);if(q){let Z=M[$.cella.colonna-C.c1];if(Z===void 0)throw new x(`la tabella ${z} non ha la colonna ${$.cella.colonna-C.c1+1}`);let B=w(Z.apertura,"name");if(B?.toLowerCase()!==t.toLowerCase())throw new x(`la tabella ${z} chiama \xAB${B??""}\xBB la colonna dell'intestazione \xAB${t}\xBB: tabella e foglio non sono coerenti, il file va riparato in Excel`);R.push({da:Z.inizio,a:Z.fineApertura,testo:I(Z.apertura,"name",r)});}for(let Z of j.xml.matchAll(/(<(?:calculatedColumnFormula|totalsRowFormula)(?:\s[^>]*)?>)([\s\S]*?)(<\/(?:calculatedColumnFormula|totalsRowFormula)>)/g)){let B=H(Z[2]??""),Q=on(B,z,t,r,{dentroLaTabella:q});if(Q===B)continue;let W=(Z.index??0)+(Z[1]??"").length;R.push({da:W,a:W+(Z[2]??"").length,testo:xe(Q)});}R.length>0&&S.set(j.parte,P(j.xml,R));}let[U]=F(a$1),J=U?.figli.find(j=>j.nome==="definedNames"),K=[];for(let j of J===void 0?[]:D(a$1,J)){let q=H(a$1.slice(j.fineApertura,j.inizioChiusura)),R=on(q,z,t,r,{});R!==q&&K.push({da:j.fineApertura,a:j.inizioChiusura,testo:xe(R)});}K.length>0&&S.set("xl/workbook.xml",P(a$1,K));}n.file(l,P(f,k));for(let[z,O]of S)n.file(z,O);return "fatta"}a(na,"rinominaColonna");async function oa(n,e,o,t){for(let r of await Ae(n,e)){let i=await N(n,r),[a]=F(i,1),l=a===void 0?void 0:w(a.apertura,"ref"),s=l===void 0?void 0:fn(l);if(!(a===void 0||s===void 0)&&!(s.r1!==o||t<s.c1||t>s.c2))return {parte:r,xml:i,nome:w(a.apertura,"displayName")??w(a.apertura,"name")??"",...s}}}a(oa,"tabellaDellaColonna");var bo={text:"@",number:"#,##0.00",integer:"0",currency:'#,##0.00\\ "\u20AC"',percent:"0.00%",date:"yyyy\\-mm\\-dd",datetime:"yyyy\\-mm\\-dd\\ hh:mm:ss"};function Ut(n){return typeof n=="string"?bo[n]:n.code}a(Ut,"codiceDelFormato");var Zt=255;function Xt(n){if(typeof n=="string")return n in bo?void 0:`formato \xAB${n}\xBB sconosciuto (ammessi: ${Object.keys(bo).join(", ")}, oppure { code })`;if(typeof n!="object"||n===null||typeof n.code!="string")return "il formato \xE8 un nome o { code: string }";let e=n.code;if(e.trim()==="")return "il codice di formato \xE8 vuoto";if(e.length>Zt)return `il codice di formato supera ${Zt} caratteri`;if(/[\u0000-\u001F]/.test(e))return "il codice di formato contiene caratteri di controllo"}a(Xt,"motivoFormatoNonValido");var jt=255;function Vt(n){return Number.isFinite(n)&&n>0&&n<=jt?void 0:`la larghezza deve essere un numero tra 0 (escluso) e ${jt}, non ${n}`}a(Vt,"motivoLarghezzaNonValida");function qt(n,e,o){if(typeof e=="string")return {gruppi:[{nome:e,records:n,posizioni:n.map((a,l)=>l+1)}]};let t=[],r=new Map,i=o?.includes(e.field)===true;return n.forEach((a,l)=>{let s=a[e.field];if(typeof s!="string"){t.push(`record ${l+1}, campo \xAB${e.field}\xBB: non \xE8 un testo, quindi non d\xE0 il nome del foglio`);return}let f=ie(s);if(f!==void 0){t.push(`record ${l+1}, campo \xAB${e.field}\xBB: ${f}`);return}let d=s.toLowerCase(),m=r.get(d)??{nome:s,records:[],posizioni:[]};r.set(d,m);let u=Object.fromEntries(Object.entries(a).filter(([p])=>p!==e.field));m.records.push(i?a:u),m.posizioni.push(l+1);}),t.length>0?{errori:t}:{gruppi:[...r.values()]}}a(qt,"raggruppaPerFoglio");var yo=64*1024*1024,ta=20;function ia(n,e){if(n!==void 0)return n.map(t=>({field:t.field,title:t.title??t.field}));let o=new Set;for(let t of e)for(let r of Object.keys(t))o.add(r);return [...o].map(t=>({field:t,title:t}))}a(ia,"colonneDi");function ra(n){let e=[],o=new Map;n.length>16384&&e.push(`${n.length} colonne, oltre il limite di Excel (${16384})`);for(let t of n){t.title.trim()===""&&e.push(`titolo vuoto per il campo \xAB${t.field}\xBB`);let r=t.title.trim(),i=o.get(r);i!==void 0&&e.push(`titolo \xAB${r}\xBB ripetuto (campi \xAB${i}\xBB e \xAB${t.field}\xBB)`),o.set(r,t.field);}return e}a(ra,"controllaColonne");var aa=/\{([A-Za-z_][\w-]*)\}/g;function la(n,e){for(let o of n.columns??[]){if(o.formula===void 0)continue;let t=o.formula.replace(/^\s*=/,"").trim();if(t==="")throw new g(`excelSink: colonna \xAB${o.field}\xBB: formula vuota`);for(let r of t.matchAll(aa))if(r[1]!=="row"&&r[1]!=="prev")throw new g(`excelSink: colonna \xAB${o.field}\xBB: segnaposto \xAB{${r[1]}}\xBB sconosciuto nella formula (ammessi {row} e {prev})`);if(e.includes(o.field))throw new g(`excelSink: colonna \xAB${o.field}\xBB: una colonna con formula non pu\xF2 essere in key`)}}a(la,"controllaFormule");function yn(n){let e=posix.extname(n).toLowerCase();return e===".xlsx"?"xlsx":e===".xlsm"?"xlsm":void 0}a(yn,"formatoDi");function sa(n){let e=new Map,o=new Map;if((n.columns??[]).forEach((r,i)=>{if(r.format!==void 0){let a=Xt(r.format);if(a!==void 0)throw new g(`excelSink: colonna \xAB${r.field}\xBB: ${a}`);e.set(i+1,Ut(r.format));}if(r.width!==void 0){let a=Vt(r.width);if(a!==void 0)throw new g(`excelSink: colonna \xAB${r.field}\xBB: ${a}`);o.set(i+1,r.width);}}),n.table!==void 0){let r=We(n.table);if(r!==void 0)throw new g(`excelSink: ${r}`);if(typeof n.sheet!="string")throw new g("excelSink: table non si combina con il foglio da campo (sheet.field): ogni foglio avrebbe lo stesso nome di tabella")}if(!(e.size===0&&o.size===0&&n.boldHeader!==true&&n.freezeHeader!==true&&n.autoFilter!==true&&n.table===void 0))return {formati:e,larghezze:o,intestazioneGrassetto:n.boldHeader===true,congelaIntestazione:n.freezeHeader===true,filtro:n.autoFilter===true,...n.table===void 0?{}:{tabella:n.table}}}a(sa,"aspettoDi");function ca(n){let e=[],o=new Map;for(let t of n){/[\r\n\t]/.test(t.title)&&e.push(`titolo del campo \xAB${t.field}\xBB: con table non pu\xF2 avere a capo n\xE9 tabulazioni`);let r=t.title.trim().toLowerCase(),i=o.get(r);i!==void 0&&i!==t.title.trim()&&e.push(`titoli \xAB${i}\xBB e \xAB${t.title.trim()}\xBB uguali senza badare alle maiuscole: in una tabella Excel i nomi di colonna sono unici`),o.set(r,t.title.trim());}return e}a(ca,"controllaTitoliTabella");async function*wo(n){yield n;}a(wo,"unico");async function tn(n,e){if(n.fingerprint!==void 0)return await n.fingerprint(e)!==void 0;for await(let o of n.list(e))if(o===e)return true;return false}a(tn,"esiste");async function _n(n,e){let o=[];for await(let t of n.get(e))o.push(t);return Buffer.concat(o)}a(_n,"leggiTutto");function fa(n,e){let o=e.headerRow??1,t=e.onMissingFile??"create",r=e.onMissingSheet??"create",i=e.name??`${n.name}:excel`,a$2=e.onFileApertoInExcel??"error",l=e.maxSheetBytes??yo;if(!Number.isInteger(l)||l<1)throw new g(`excelSink: maxSheetBytes deve essere un intero da 1, non ${l}`);if(n.replace===void 0||n.capabilities?.includes("atomic-replace")!==true)throw new g(`excelSink: lo storage "${n.name}" non offre la sostituzione atomica (capacit\xE0 atomic-replace): il sink non scrive senza`);let s=n.replace.bind(n),f$1=yn(e.path);if(e.template!==void 0){if(yn(e.template)===void 0)throw new g(`excelSink: template deve essere un .xlsx o un .xlsm, non "${e.template}"`);if(yn(e.template)!==f$1)throw new g(`excelSink: il template "${e.template}" e il file "${e.path}" devono avere la stessa estensione`)}if(e.sheetTemplate!==void 0){let z=ie(e.sheetTemplate);if(z!==void 0)throw new g(`excelSink: sheetTemplate: ${z}`)}if(!Number.isInteger(o)||o<1)throw new g(`excelSink: headerRow deve essere un intero da 1, non ${o}`);let d=e.mode==="upsert",m=e.mode==="replace",u=e.cancellaQuando,p=m||u!==void 0;if(p&&e.destructive!==true)throw new g(`excelSink: ${m?"la modalit\xE0 replace":"cancellaQuando"} cancella dati e vuole destructive: true (compare nel DAG e nel report; runbook docs/runbooks/excel-operazioni-distruttive.md)`);if(!d&&(u!==void 0||e.cancellaRighe))throw new g("excelSink: cancellaQuando e cancellaRighe esistono solo in modalit\xE0 upsert");if(d&&u===void 0&&e.cancellaRighe)throw new g("excelSink: cancellaRighe senza cancellaQuando non ha effetto");if(u!==void 0){if(typeof u.field!="string"||u.field.trim()==="")throw new g("excelSink: cancellaQuando.field \xE8 vuoto");if(!["string","number","boolean"].includes(typeof u.equals))throw new g("excelSink: cancellaQuando.equals \xE8 un testo, un numero o un booleano");let z=e.cancellaRighe;if(z!==void 0&&z!=="svuota"&&z!=="rimuovi")throw new g(`excelSink: cancellaRighe \xAB${JSON.stringify(z)}\xBB sconosciuto (rimuovi, svuota)`)}let g$1=e.mode;if(g$1!=="append"&&!d&&!m)throw new g(`excelSink: modalit\xE0 \xAB${String(g$1)}\xBB sconosciuta (append, upsert, replace)`);let b=e.key,h=d&&Array.isArray(b)?b:[];if(d){if(h.length===0)throw new g("excelSink: in modalit\xE0 upsert key \xE8 obbligatoria");if(h.some(L=>L===""))throw new g("excelSink: key ha un nome di campo vuoto");if(new Set(h).size!==h.length)throw new g("excelSink: key ripete un campo");let z=e.columns?.map(L=>L.field),O=h.filter(L=>z?.includes(L)===false);if(O.length>0)throw new g(`excelSink: key ha campi che non sono in columns (${O.join(", ")})`)}let y=typeof e.sheet=="string"?ie(e.sheet):e.sheet.field===""?"sheet.field \xE8 vuoto":void 0;if(y!==void 0)throw new g(`excelSink: ${y}`);la(e,h);let $=sa(e),v=e.cancellaRighe??"rimuovi",C=u!==void 0&&e.columns?.some(z=>z.field===u.field)===true;async function T(z,O){let L=[];for await(let U of z)O.signal.throwIfAborted(),L.push(U);return L}a(T,"raccogli");function k(z){let O=z.map(R=>u!==void 0&&R[u.field]===u.equals),L=u===void 0||C?z:z.map(R=>Object.fromEntries(Object.entries(R).filter(([_])=>_!==u.field))),U=ia(e.columns,L),J=ra(U);e.table!==void 0&&J.push(...ca(U)),o+z.length>1048576&&J.push(`${z.length} record dalla riga ${o+1} superano il limite di Excel (${1048576 .toLocaleString("it-IT")} righe)`);let K=U.map(R=>R.field),j=new Map((e.columns??[]).flatMap((R,_)=>R.formula===void 0?[]:[[_,R.formula]])),q=[{numero:o,celle:U.map((R,_)=>({colonna:_+1,cella:{tipo:"testo",valore:R.title}}))}];return L.forEach((R,_)=>{let Y=o+1+_,M=j.size===0?R:Object.fromEntries(Object.entries(R).filter(([Q])=>!(e.columns??[]).some(W=>W.field===Q&&W.formula!==void 0))),Z=zn(M,K);for(let Q of Z.errori)J.push(`riga ${Y}, ${Q}`);for(let Q of h){let W=Z.celle[K.indexOf(Q)];(W==null||W.tipo==="testo"&&W.valore.trim()==="")&&J.push(`riga ${Y}, chiave \xAB${Q}\xBB: assente, nulla o vuota`);}let B=[];Z.celle.forEach((Q,W)=>{let se=j.get(W);se!==void 0?B.push({colonna:W+1,cella:{tipo:"formula",formula:se}}):Q!==null&&B.push({colonna:W+1,cella:Q});}),q.push({numero:Y,celle:B});}),J.length>0?{errori:J}:{righe:q,chiave:h.map(R=>K.indexOf(R)+1),cancella:new Set(q.filter((R,_)=>_>0&&O[_-1]===true))}}a(k,"costruisci");let S=posix.join(posix.dirname(e.path),`~$${posix.basename(e.path)}`);return {name:i,...d?{retrySafe:true}:{},exclusiveTarget:`excel:${e.instanceId??n.name}:${e.path}`,descriptor:{kind:"excel",...a$1(e.instanceId),details:[{label:"storage",value:n.name},{label:"path",value:e.path},{label:"foglio",value:typeof e.sheet=="string"?e.sheet:`dal campo ${e.sheet.field}`},{label:"modalit\xE0",value:e.mode},{label:"destructive",value:p?"true":"no"},...u===void 0?[]:[{label:"cancellaQuando",value:u.field},{label:"cancellaRighe",value:v}]]},async load(z,O){let L=a((R,_)=>new f(`${e.path}: ${R}`,{stage:i},_===void 0?void 0:{cause:_}),"fallito"),U=await T(z,O);if(U.length===0)return {written:0};let J=qt(U,e.sheet,e.columns?.map(R=>R.field)),K="errori"in J?void 0:J.gruppi.map(R=>({nome:R.nome,costruito:k(R.records),dinamico:typeof e.sheet!="string"})),j="errori"in J?J.errori:(K??[]).flatMap(R=>"errori"in R.costruito?R.costruito.errori.map(_=>R.dinamico?`foglio \xAB${R.nome}\xBB, ${_}`:_):[]);if(j.length>0){let R=j.slice(0,ta),_=j.length-R.length;throw L(`il batch non si scrive, nessun file toccato:
6
+ - ${R.join(`
7
+ - `)}${_>0?`
8
+ - \u2026 e altri ${_}`:""}`)}let q=a(R=>new f(`${e.path}: ${R}`,{stage:i,transient:true}),"transitorio");try{if(a$2==="error"&&await tn(n,S))throw q(`il file \xE8 aperto in Excel (esiste ${S}): non si scrive, riprova dopo la chiusura; onFileApertoInExcel: "ignore" scrive lo stesso`);let R=await n.fingerprint?.(e.path),_;if(await tn(n,e.path))_=await _n(n,e.path);else {if(t==="error")throw L("il workbook manca e onMissingFile \xE8 \xABerror\xBB");if(e.template!==void 0){if(!await tn(n,e.template))throw L(`il modello ${e.template} non esiste`);_=await _n(n,e.template);}else if(f$1==="xlsm")throw L("un .xlsm nuovo nasce solo da un modello .xlsm (opzione template): il layer non crea macro")}let Y=0,M=0,Z=0,B=0,Q=!1;for(let{nome:W,costruito:se}of K??[]){if(!("righe"in se))continue;let[Se,...Ee]=se.righe,$n={foglio:W,intestazione:Se,righe:Ee,creaFoglioSeManca:r==="create",...e.sheetTemplate===void 0?{}:{foglioModello:e.sheetTemplate},...m?{sostituisci:!0}:{},...e.repeatFormulas===void 0?{}:{ripetiFormule:e.repeatFormulas},...f$1===void 0?{}:{formato:f$1},...$===void 0?{}:{aspetto:$},maxByteFoglio:l,opzioneTetto:"maxSheetBytes"};if(_===void 0){let ne=d?Tn(Ee,se.chiave).map(De=>De.riga).filter(De=>!se.cancella.has(De)):Ee;_=await Bn(W,[Se,...ne],$),Y+=ne.length,Q=!0;}else if(d){let ne=await ro(_,{...$n,chiave:se.chiave,cancella:se.cancella,cancellaRighe:v});_=ne.bytes,Y+=ne.aggiunte,M+=ne.aggiornate,Z+=ne.invariate,B+=ne.cancellate,Q||=ne.modificato;}else _=await Ye(_,$n),Y+=Ee.length,Q=!0;}if(_===void 0)return {written:0};if(!Q)return O.metrics.increment(`${i}:excel.righe-invariate`,Z),{written:0};if(n.fingerprint!==void 0&&await n.fingerprint(e.path)!==R)throw q("il file \xE8 cambiato mentre il sink lo elaborava (scrittura concorrente): non si sostituisce, nessuna modifica persa");return await s(e.path,wo(_)),O.metrics.increment(`${i}:excel.righe-aggiunte`,Y),d&&(O.metrics.increment(`${i}:excel.righe-aggiornate`,M),O.metrics.increment(`${i}:excel.righe-invariate`,Z),u!==void 0&&O.metrics.increment(`${i}:excel.righe-cancellate`,B)),{written:Y+M}}catch(R){throw R instanceof f?R:R instanceof x?L(`${R.message}; il file non \xE8 stato toccato`,R):L("errore durante la scrittura del workbook",R)}}}}a(fa,"excelSink");var $o={reorderSheets:false,renameColumn:false,renameSheet:false,deleteSheet:true,deleteColumns:true,reorderColumns:false,insertColumns:false},ua="reorderSheets, renameColumn, renameSheet, deleteSheet, deleteColumns, reorderColumns, insertColumns";function xn(n,e,o){if(typeof o!="string"||o.trim()==="")throw new g(`${n}: ${e} \xE8 vuoto`)}a(xn,"testoNonVuoto");function vo(n,e){if(e!==void 0&&(!Number.isInteger(e)||e<1))throw new g(`${n}: headerRow deve essere un intero da 1, non ${e}`);return e}a(vo,"validaRiga");function wn(n,e,o){xn(n,e,o);let t=ie(o);if(t!==void 0)throw new g(`${n}: ${e}: ${t}`);return o}a(wn,"validaFoglio");function Co(n,e,o,t){if(!Array.isArray(o)||o.length<t)throw new g(`${n}: ${e} vuole almeno ${t===1?"un titolo":`${t} titoli`}`);let r=new Set;for(let i of o){xn(n,`${e}: il titolo`,i);let a=i.trim().toLowerCase();if(r.has(a))throw new g(`${n}: ${e} ripete \xAB${i}\xBB (senza badare alle maiuscole)`);r.add(a);}return o}a(Co,"validaTitoli");function da(n,e,o){let t=`excelTask "${n}", operazione ${o}`,r=e.op;if(r==="reorderSheets"){let i=e,a=i.order;if(!Array.isArray(a)||a.length===0)throw new g(`${t}: reorderSheets vuole order non vuoto`);let l=new Set;for(let s of a){if(typeof s!="string")throw new g(`${t}: order: il nome non \xE8 un testo`);let f=ie(s);if(f!==void 0)throw new g(`${t}: order: ${f}`);if(l.has(s.toLowerCase()))throw new g(`${t}: order ripete il foglio \xAB${s}\xBB (senza badare alle maiuscole)`);l.add(s.toLowerCase());}return {op:"riordinaFogli",ordine:i.order}}if(r==="renameColumn"){let i=e,a=ie(i.sheet);if(a!==void 0)throw new g(`${t}: sheet: ${a}`);if(typeof i.from!="string"||i.from.trim()==="")throw new g(`${t}: from \xE8 vuoto`);if(typeof i.to!="string"||i.to.trim()==="")throw new g(`${t}: to \xE8 vuoto`);if(i.from.trim()===i.to.trim())throw new g(`${t}: from e to sono uguali`);if(i.headerRow!==void 0&&(!Number.isInteger(i.headerRow)||i.headerRow<1))throw new g(`${t}: headerRow deve essere un intero da 1, non ${i.headerRow}`);return {op:"rinominaColonna",foglio:i.sheet,da:i.from,a:i.to,...i.headerRow===void 0?{}:{rigaIntestazione:i.headerRow}}}if(r==="renameSheet"){let i=e;if(xn(t,"from",i.from),wn(t,"to",i.to),i.from===i.to)throw new g(`${t}: from e to sono uguali`);return {op:"rinominaFoglio",da:i.from,a:i.to}}if(r==="deleteSheet")return {op:"cancellaFoglio",foglio:wn(t,"sheet",e.sheet)};if(r==="deleteColumns"){let i=e,a=wn(t,"sheet",i.sheet),l=Co(t,"columns",i.columns,1),s=vo(t,i.headerRow);return {op:"cancellaColonne",foglio:a,colonne:l,...s===void 0?{}:{rigaIntestazione:s}}}if(r==="reorderColumns"){let i=e,a=wn(t,"sheet",i.sheet),l=Co(t,"order",i.order,2),s=vo(t,i.headerRow);return {op:"riordinaColonne",foglio:a,ordine:l,...s===void 0?{}:{rigaIntestazione:s}}}if(r==="insertColumns"){let i=e,a=wn(t,"sheet",i.sheet),l=i.columns;if(!Array.isArray(l)||l.length===0)throw new g(`${t}: columns vuole almeno una colonna`);let s=l.map(d=>{if(xn(t,"columns: title",d.title),xn(t,"columns: after",d.after),/[\r\n\t]/.test(d.title))throw new g(`${t}: columns: title \xAB${d.title.replace(/\s/g," ")}\xBB ha a capo o tabulazioni`);return {titolo:d.title.trim(),dopo:d.after}});Co(t,"columns: title",s.map(d=>d.titolo),1);let f=vo(t,i.headerRow);return {op:"inserisciColonne",foglio:a,colonne:s,...f===void 0?{}:{rigaIntestazione:f}}}throw new g(`${t}: operazione \xAB${String(r)}\xBB sconosciuta (${ua})`)}a(da,"validaOperazione");function ma(n){switch(n.op){case "reorderSheets":return `reorderSheets: ${n.order.join(", ")}`;case "renameColumn":return `renameColumn ${n.sheet}: ${n.from} \u2192 ${n.to}`;case "renameSheet":return `renameSheet: ${n.from} \u2192 ${n.to}`;case "deleteSheet":return `deleteSheet: ${n.sheet}`;case "deleteColumns":return `deleteColumns ${n.sheet}: ${n.columns.join(", ")}`;case "reorderColumns":return `reorderColumns ${n.sheet}: ${n.order.join(", ")}`;case "insertColumns":return `insertColumns ${n.sheet}: ${n.columns.map(e=>`${e.title} dopo ${e.after}`).join(", ")}`}}a(ma,"descrivi");function pa(n,e){let o=e.name??`${n.name}:excel-task`,t=e.maxSheetBytes??yo,r=e.onFileApertoInExcel??"error";if(!Number.isInteger(t)||t<1)throw new g(`excelTask: maxSheetBytes deve essere un intero da 1, non ${t}`);if(n.replace===void 0||n.capabilities?.includes("atomic-replace")!==true)throw new g(`excelTask: lo storage "${n.name}" non offre la sostituzione atomica (capacit\xE0 atomic-replace): il task non scrive senza`);let i=n.replace.bind(n),a$2=yn(e.path);if(a$2===void 0)throw new g(`excelTask: path deve essere un .xlsx o un .xlsm, non "${e.path}"`);let l$1=e.operations;if(!Array.isArray(l$1)||l$1.length===0)throw new g(`excelTask "${o}": operations \xE8 vuoto`);let s=e.operations.map((u,p)=>da(o,u,p+1)),f=e.operations.some(u=>$o[u.op]);if(f&&e.destructive!==true){let u=e.operations.filter(p=>$o[p.op]).map(p=>p.op);throw new g(`excelTask "${o}": ${[...new Set(u)].join(", ")} cancella dati: serve destructive: true`)}let d=posix.join(posix.dirname(e.path),`~$${posix.basename(e.path)}`),m=new WeakMap;return {name:o,retrySafe:true,descriptor:{kind:"excel-task",...a$1(e.instanceId),details:[{label:"storage",value:n.name},{label:"path",value:e.path},...e.operations.map((u,p)=>({label:`operazione ${p+1}`,value:ma(u)})),{label:"destructive",value:f?"true":"no"}]},async run(u){let p=a((g,b={})=>new l(`${e.path}: ${g}`,{stage:o,...b.transient===true?{transient:true}:{}},b.cause===void 0?void 0:{cause:b.cause}),"fallito");u.signal.throwIfAborted();try{if(r==="error"&&await tn(n,d))throw p(`il file \xE8 aperto in Excel (esiste ${d}): non si scrive, riprova dopo la chiusura; onFileApertoInExcel: "ignore" scrive lo stesso`,{transient:!0});if(!await tn(n,e.path))throw p("il workbook non esiste");let g=await n.fingerprint?.(e.path),b=await _n(n,e.path),h=await ho(b,s,{formato:a$2,maxByteFoglio:t,opzioneTetto:"maxSheetBytes"}),y=h.esiti.map((v,C)=>({op:e.operations[C].op,outcome:v==="fatta"?"done":$o[e.operations[C].op]?"already-absent":"already-done"}));m.set(u,y);let $=y.filter(v=>v.outcome==="done").length;if(u.metrics.increment(`${o}:excel.operazioni-fatte`,$),u.metrics.increment(`${o}:excel.operazioni-gia-fatte`,y.length-$),!h.modificato)return;if(u.signal.throwIfAborted(),n.fingerprint!==void 0&&await n.fingerprint(e.path)!==g)throw p("il file \xE8 cambiato mentre il task lo elaborava (scrittura concorrente): non si sostituisce, nessuna modifica persa",{transient:!0});await i(e.path,wo(h.bytes));}catch(g){throw g instanceof l?g:g instanceof x?p(`${g.message}; il file non \xE8 stato toccato`,{cause:g}):u.signal.aborted?g:p("errore durante la modifica del workbook",{cause:g})}},writeReport:a(u=>{let p=m.get(u)??[],g=p.filter(b=>b.outcome==="done").length;return {operations:p.map(b=>({...b})),done:g,alreadyDone:p.length-g,destructive:f}},"writeReport")}}a(pa,"excelTask");function ga(n,e={}){if(e.sheet!==void 0){let t=ie(e.sheet);if(t!==void 0)throw new g(`excelValidate "${n}": ${t}`)}let o=e.columns?.map(t=>t.field);return {name:n,async*apply(t){for await(let r of t){let{errori:i}=zn(r,o);if(i.length>0)throw new d(`Record non scrivibile in Excel in "${n}":
9
+ - ${i.join(`
10
+ - `)}`,{stage:n,details:{errors:i}});yield r;}}}}a(ga,"excelValidate");export{fa as excelSink,ai as excelSource,pa as excelTask,ga as excelValidate};
@@ -1,12 +1,13 @@
1
- import { S as StorageProvider, F as FileCodec } from '../types-BVA7BIou.js';
2
- import { S as Sink, a as Source, W as WriteReportFn } from '../errors-bgSO6lGO.js';
1
+ import { S as StorageProvider, F as FileCodec } from '../types-_3rgLhje.js';
2
+ export { a as StorageCapability } from '../types-_3rgLhje.js';
3
+ import { a as Sink, S as Source, W as WriteReportFn } from '../errors-CRq1uNYZ.js';
3
4
  import { Readable, Writable } from 'node:stream';
4
5
  import { S3ClientConfig } from '@aws-sdk/client-s3';
5
- import { M as ManifestVariabili } from '../manifest-variabili-U1UfPDfF.js';
6
- import { I as IstanzaDichiarata } from '../ambiente-della-pipeline-BoymQ6uN.js';
6
+ import { M as ManifestVariabili } from '../manifest-variabili-DRWUzmxU.js';
7
+ import { I as IstanzaDichiarata } from '../ambiente-della-pipeline-BhWsyLUR.js';
7
8
  import { C as ConnectorRegistry } from '../registry-tB3G64MU.js';
8
9
  import 'zod';
9
- import '../variabili-dichiarate-DmfcxsT9.js';
10
+ import '../variabili-dichiarate-CS-eC53K.js';
10
11
 
11
12
  interface FileSourceOptions {
12
13
  readonly name?: string;
@@ -235,6 +236,12 @@ interface FilesystemStorageOptions {
235
236
  * `StorageProvider` su **filesystem locale** (`node:fs`, nessuna dipendenza).
236
237
  * I path sono relativi a `baseDir` (sandbox): un path che ne esce è rifiutato.
237
238
  * `list` è ricorsiva e restituisce path relativi con separatore `/`.
239
+ *
240
+ * Dichiara le capacità `atomic-replace` e `fingerprint`: `replace` scrive su un file
241
+ * temporaneo nella **stessa cartella** (stesso filesystem, quindi la rinomina è atomica)
242
+ * e lo rinomina sul destinatario; se la scrittura fallisce il temporaneo è rimosso e
243
+ * l'originale resta intatto. `fingerprint` è `dimensione:mtime(ns):inode`, quindi cambia
244
+ * anche per una sostituzione atomica (che cambia l'inode).
238
245
  */
239
246
  declare function filesystemStorage(options?: FilesystemStorageOptions): StorageProvider;
240
247
 
@@ -1 +1 @@
1
- export{z as LIMITE_ELENCO_NON_LETTI,v as MANIFEST_FTP,l as MANIFEST_S3,q as MANIFEST_SFTP,d as csvCodec,e as csvRawCodec,b as fileSink,a as fileSource,j as filesystemStorage,u as ftpStorage,w as istanzaFtpDichiarata,m as istanzaS3Dichiarata,r as istanzaSftpDichiarata,g as jsonCodec,x as loadFtpConfig,y as loadFtpRegistry,n as loadS3ClientConfig,o as loadS3Registry,s as loadSftpConfig,t as loadSftpRegistry,A as localFolderSource,c as memoryStorage,C as moveLocalFile,i as parquetCodec,k as s3Storage,p as sftpStorage,B as writeLocalFile,f as xlsxCodec,h as xmlCodec}from'../chunk-RCRMQPFH.js';import'../chunk-PKBSETMV.js';import'../chunk-PE2QKU34.js';
1
+ export{z as LIMITE_ELENCO_NON_LETTI,v as MANIFEST_FTP,l as MANIFEST_S3,q as MANIFEST_SFTP,d as csvCodec,e as csvRawCodec,b as fileSink,a as fileSource,j as filesystemStorage,u as ftpStorage,w as istanzaFtpDichiarata,m as istanzaS3Dichiarata,r as istanzaSftpDichiarata,g as jsonCodec,x as loadFtpConfig,y as loadFtpRegistry,n as loadS3ClientConfig,o as loadS3Registry,s as loadSftpConfig,t as loadSftpRegistry,A as localFolderSource,c as memoryStorage,C as moveLocalFile,i as parquetCodec,k as s3Storage,p as sftpStorage,B as writeLocalFile,f as xlsxCodec,h as xmlCodec}from'../chunk-DHQ3YOPX.js';import'../chunk-47NVGHUY.js';import'../chunk-CEAMQIRO.js';
@@ -1,12 +1,12 @@
1
- import { H as HttpConfig } from '../config-BSUwK4p_.js';
2
- export { D as DEFAULT_HTTP_TIMEOUT_MS, a as HttpAuth, b as HttpAuthKind, M as MANIFEST_HTTP, i as istanzaHttpDichiarata, l as loadHttpConfig } from '../config-BSUwK4p_.js';
3
- import { I as IstanzaPerIlPiano } from '../istanza-per-il-piano-CucqUF7b.js';
1
+ import { H as HttpConfig } from '../config-DMafsY4H.js';
2
+ export { D as DEFAULT_HTTP_TIMEOUT_MS, a as HttpAuth, b as HttpAuthKind, M as MANIFEST_HTTP, i as istanzaHttpDichiarata, l as loadHttpConfig } from '../config-DMafsY4H.js';
3
+ import { I as IstanzaPerIlPiano } from '../istanza-per-il-piano-74NYhIHc.js';
4
4
  import { C as ConnectorRegistry } from '../registry-tB3G64MU.js';
5
5
  import { ZodType } from 'zod';
6
- import { R as RateLimiter, b as RunContext, c as RateLimit, L as LookupResolver, d as RetryPolicy, A as Action } from '../errors-bgSO6lGO.js';
7
- import '../manifest-variabili-U1UfPDfF.js';
8
- import '../ambiente-della-pipeline-BoymQ6uN.js';
9
- import '../variabili-dichiarate-DmfcxsT9.js';
6
+ import { R as RateLimiter, c as RunContext, d as RateLimit, L as LookupResolver, e as RetryPolicy, A as Action } from '../errors-CRq1uNYZ.js';
7
+ import '../manifest-variabili-DRWUzmxU.js';
8
+ import '../ambiente-della-pipeline-BhWsyLUR.js';
9
+ import '../variabili-dichiarate-CS-eC53K.js';
10
10
 
11
11
  /**
12
12
  * L'API `id` per il piano (ADR-0089): quella risolta dall'ambiente, o
@@ -1 +1 @@
1
- export{h as DEFAULT_HTTP_LOOKUP_CONCURRENCY,a as DEFAULT_HTTP_TIMEOUT_MS,b as MANIFEST_HTTP,j as httpAction,i as httpLookup,c as istanzaHttpDichiarata,g as istanzaHttpPerIlPiano,d as loadHttpConfig,f as loadHttpInstance,e as loadHttpRegistry}from'../chunk-ZCYGHS7P.js';export{e as richiestaHttp,a as rispostaErroreHttp}from'../chunk-JLPK6MMQ.js';import'../chunk-PKBSETMV.js';import'../chunk-PE2QKU34.js';
1
+ export{h as DEFAULT_HTTP_LOOKUP_CONCURRENCY,a as DEFAULT_HTTP_TIMEOUT_MS,b as MANIFEST_HTTP,j as httpAction,i as httpLookup,c as istanzaHttpDichiarata,g as istanzaHttpPerIlPiano,d as loadHttpConfig,f as loadHttpInstance,e as loadHttpRegistry}from'../chunk-5OE6F2MK.js';export{e as richiestaHttp,a as rispostaErroreHttp}from'../chunk-OK3XRTGA.js';import'../chunk-47NVGHUY.js';import'../chunk-CEAMQIRO.js';
@@ -1,12 +1,12 @@
1
- import { C as ConfigError, a as Source, e as ConnectorDetail, f as ConnectorDescriptor, A as Action } from '../errors-bgSO6lGO.js';
2
- import { C as CredenzialiPosta } from '../credenziali-posta-f7HB2cYW.js';
3
- import { V as VariabileRisolta, R as RisoluzioneVariabili, M as ManifestVariabili } from '../manifest-variabili-U1UfPDfF.js';
4
- import { I as IstanzaDichiarata } from '../ambiente-della-pipeline-BoymQ6uN.js';
5
- import { I as IstanzaPerIlPiano } from '../istanza-per-il-piano-CucqUF7b.js';
1
+ import { C as ConfigError, S as Source, f as ConnectorDetail, g as ConnectorDescriptor, A as Action } from '../errors-CRq1uNYZ.js';
2
+ import { C as CredenzialiPosta } from '../credenziali-posta-C0az04uV.js';
3
+ import { V as VariabileRisolta, R as RisoluzioneVariabili, M as ManifestVariabili } from '../manifest-variabili-DRWUzmxU.js';
4
+ import { I as IstanzaDichiarata } from '../ambiente-della-pipeline-BhWsyLUR.js';
5
+ import { I as IstanzaPerIlPiano } from '../istanza-per-il-piano-74NYhIHc.js';
6
6
  import { C as ConnectorRegistry } from '../registry-tB3G64MU.js';
7
7
  import { I as ImapClientOptions, C as ClientImap } from '../client-ZuKAar0B.js';
8
8
  import 'zod';
9
- import '../variabili-dichiarate-DmfcxsT9.js';
9
+ import '../variabili-dichiarate-CS-eC53K.js';
10
10
  import 'imapflow';
11
11
 
12
12
  /** Credenziali IMAP: password oppure OAuth2 (vedi {@link CredenzialiPosta}). */
@@ -1 +1 @@
1
- export{a as MANIFEST_IMAP,j as imapFlagAction,i as imapSessione,h as imapSource,k as imapSpostaAction,b as istanzaImapDichiarata,f as istanzaImapPerIlPiano,c as loadImapConfig,e as loadImapInstance,d as loadImapRegistry,g as oggettoContiene}from'../chunk-RS5SGDUU.js';import'../chunk-LJ7DVP5F.js';import'../chunk-PKBSETMV.js';import'../chunk-PE2QKU34.js';
1
+ export{a as MANIFEST_IMAP,j as imapFlagAction,i as imapSessione,h as imapSource,k as imapSpostaAction,b as istanzaImapDichiarata,f as istanzaImapPerIlPiano,c as loadImapConfig,e as loadImapInstance,d as loadImapRegistry,g as oggettoContiene}from'../chunk-IODXIHU2.js';import'../chunk-VL7DZWWO.js';import'../chunk-47NVGHUY.js';import'../chunk-CEAMQIRO.js';
@@ -1,11 +1,11 @@
1
- import { C as ConfigError, c as RateLimit, d as RetryPolicy, A as Action, e as ConnectorDetail, L as LookupResolver, a as Source } from '../errors-bgSO6lGO.js';
2
- import { V as VariabileRisolta, M as ManifestVariabili } from '../manifest-variabili-U1UfPDfF.js';
3
- import { I as IstanzaDichiarata } from '../ambiente-della-pipeline-BoymQ6uN.js';
4
- import { H as HttpConfig } from '../config-BSUwK4p_.js';
5
- import { I as IstanzaPerIlPiano } from '../istanza-per-il-piano-CucqUF7b.js';
1
+ import { C as ConfigError, d as RateLimit, e as RetryPolicy, A as Action, f as ConnectorDetail, L as LookupResolver, S as Source } from '../errors-CRq1uNYZ.js';
2
+ import { V as VariabileRisolta, M as ManifestVariabili } from '../manifest-variabili-DRWUzmxU.js';
3
+ import { I as IstanzaDichiarata } from '../ambiente-della-pipeline-BhWsyLUR.js';
4
+ import { H as HttpConfig } from '../config-DMafsY4H.js';
5
+ import { I as IstanzaPerIlPiano } from '../istanza-per-il-piano-74NYhIHc.js';
6
6
  import { C as ConnectorRegistry } from '../registry-tB3G64MU.js';
7
7
  import 'zod';
8
- import '../variabili-dichiarate-DmfcxsT9.js';
8
+ import '../variabili-dichiarate-CS-eC53K.js';
9
9
 
10
10
  /**
11
11
  * Un documento ADF (Atlassian Document Format) in **testo semplice**: quello