@testmuai/kane-cli 0.6.9 → 0.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ChatSurface-TZ554O4U.js +8 -0
- package/dist/{ChromeProfilePicker-FSZB4SZR.js → ChromeProfilePicker-54CAJDUF.js} +1 -1
- package/dist/{CliFeedbackPrompt-WNMDCIHZ.js → CliFeedbackPrompt-TCAH4AHL.js} +1 -1
- package/dist/{CliUploadProgress-H4265KXU.js → CliUploadProgress-UURZ63VQ.js} +1 -1
- package/dist/{ConfigView-XCUZ44SP.js → ConfigView-5QGB7MUS.js} +1 -1
- package/dist/EvidenceViewOffer-SSAM4RRP.js +2 -0
- package/dist/{FolderPicker-S2XVCPYN.js → FolderPicker-Y5MAYFIJ.js} +1 -1
- package/dist/{HelpView-OPKRGNNM.js → HelpView-S3GJGSCE.js} +1 -1
- package/dist/{InfoBox-TW2PGJK5.js → InfoBox-LYTNNMVJ.js} +1 -1
- package/dist/{LinksBox-66M7XP5Y.js → LinksBox-5MSEKNSV.js} +1 -1
- package/dist/{ProfilesView-T2CFQPR5.js → ProfilesView-LTHE5UIO.js} +1 -1
- package/dist/{ProjectPicker-7ALN52CY.js → ProjectPicker-XMXIGHSE.js} +1 -1
- package/dist/{SaveSessionPrompt-HM3F6QML.js → SaveSessionPrompt-VQDEA4WA.js} +1 -1
- package/dist/SingleShotApp-A6PCNPLM.js +2 -0
- package/dist/{SummaryBox-BQZEGOIV.js → SummaryBox-WWF3G263.js} +1 -1
- package/dist/TestMdRunView-MQ7ZPFN2.js +2 -0
- package/dist/{WhoamiView-722MBPSG.js → WhoamiView-PDURYP7E.js} +1 -1
- package/dist/auth-I4RB4KO3.js +2 -0
- package/dist/bind-QJT726NE.js +6 -0
- package/dist/bootstrap-566PPFCC.js +2 -0
- package/dist/{bridge-V4FF5QPK.js → bridge-QCMEOQDD.js} +1 -1
- package/dist/{changelog-KMYZW5MI.js → changelog-OKYH4F7I.js} +1 -1
- package/dist/{chat-committer-MWZ4JQMM.js → chat-committer-OS7ULZMH.js} +1 -1
- package/dist/chat-controller-QLORQWJZ.js +2 -0
- package/dist/{chunk-LRA3V5GY.js → chunk-2WKX3RMA.js} +1 -1
- package/dist/chunk-2XMJ6YAE.js +2 -0
- package/dist/{chunk-FVM7TWKT.js → chunk-3AZTXJY4.js} +1 -1
- package/dist/{chunk-SHAA6FOD.js → chunk-3RZ63RBO.js} +1 -1
- package/dist/{chunk-U5QTE3WX.js → chunk-4CJ55EUY.js} +1 -1
- package/dist/{chunk-T4WZWKIU.js → chunk-54IB6CXK.js} +2 -2
- package/dist/chunk-54VQ46U2.js +14 -0
- package/dist/chunk-55Y65VPA.js +347 -0
- package/dist/chunk-5EOX4MEY.js +2 -0
- package/dist/{chunk-L4JIMNKW.js → chunk-6HYW5RFX.js} +1 -1
- package/dist/{chunk-L3HG5ONB.js → chunk-6W6AIDLJ.js} +1 -1
- package/dist/chunk-73OQDAXF.js +3 -0
- package/dist/{chunk-LEA6IHXC.js → chunk-7E24OCGX.js} +1 -1
- package/dist/{chunk-DKERZJYF.js → chunk-7MRBMDZ5.js} +1 -1
- package/dist/{chunk-345PY4SZ.js → chunk-7NLQ3QQD.js} +1 -1
- package/dist/chunk-7YPK6EDR.js +4 -0
- package/dist/chunk-BKM2LWU2.js +3 -0
- package/dist/{chunk-YY6WPFMT.js → chunk-DSOA6L73.js} +3 -3
- package/dist/{chunk-ZA4GR5R7.js → chunk-EAUUULJQ.js} +1 -1
- package/dist/chunk-EV3EHXEI.js +4 -0
- package/dist/chunk-F7WKDMX7.js +47 -0
- package/dist/{chunk-7Z64BL5D.js → chunk-FCHTL74E.js} +1 -1
- package/dist/chunk-FHKDTM5L.js +6 -0
- package/dist/{chunk-OSALXGD4.js → chunk-FMR2KPSK.js} +1 -1
- package/dist/{chunk-RGDQMKNJ.js → chunk-FRBYGSGJ.js} +1 -1
- package/dist/{chunk-GBYH35H5.js → chunk-FSB3FTIQ.js} +1 -1
- package/dist/{chunk-JHAGEBKE.js → chunk-GIMTSDNC.js} +1 -1
- package/dist/{chunk-FT4G3QGO.js → chunk-GLA6QL3T.js} +1 -1
- package/dist/chunk-H2W2UNTN.js +6 -0
- package/dist/{chunk-7BCZLDNX.js → chunk-HLRLP6TQ.js} +1 -1
- package/dist/{chunk-4FH2KFRT.js → chunk-HMM5FJJO.js} +1 -1
- package/dist/{chunk-TACPTX64.js → chunk-HOQEMPMQ.js} +2 -2
- package/dist/{chunk-MXLXKHW4.js → chunk-ICGHBZFZ.js} +1 -1
- package/dist/{chunk-TFVMSEIA.js → chunk-IQODWB32.js} +1 -1
- package/dist/{chunk-MBXWXBDM.js → chunk-J2KSZUOO.js} +1 -1
- package/dist/chunk-J44RN3FB.js +2 -0
- package/dist/{chunk-O4HWPV67.js → chunk-JXKRO2ZJ.js} +2 -2
- package/dist/{chunk-K5JGCJ2K.js → chunk-K7USHLVZ.js} +4 -4
- package/dist/{chunk-QZJID3OZ.js → chunk-KHJXOFDM.js} +1 -1
- package/dist/chunk-KHQHVSZ6.js +5 -0
- package/dist/{chunk-IWBPV3VS.js → chunk-KSZ72BSC.js} +1 -1
- package/dist/{chunk-QTHITA73.js → chunk-KXUSG5ZI.js} +1 -1
- package/dist/{chunk-DPOES6G3.js → chunk-LHDNJJGE.js} +1 -1
- package/dist/{chunk-P4SE6YON.js → chunk-M5PJQ5Y3.js} +1 -1
- package/dist/{chunk-QM3XF5TW.js → chunk-MFOH7EYR.js} +1 -1
- package/dist/{chunk-EWLLPUP4.js → chunk-MJBCBQC2.js} +1 -1
- package/dist/chunk-MMPFU2YC.js +2 -0
- package/dist/{chunk-RQM3DUSB.js → chunk-MR7CX5VT.js} +1 -1
- package/dist/{chunk-GNNMHYWE.js → chunk-MRP54NCJ.js} +1 -1
- package/dist/chunk-MTNUZEO7.js +12 -0
- package/dist/{chunk-RLICAFFQ.js → chunk-NJAHRITS.js} +1 -1
- package/dist/{chunk-OV2W7KBC.js → chunk-NTGYFYBP.js} +1 -1
- package/dist/{chunk-LMMOR7CR.js → chunk-NTNAHN25.js} +1 -1
- package/dist/{chunk-EASTDHNW.js → chunk-NUQ423YE.js} +1 -1
- package/dist/{chunk-U6TLLYRG.js → chunk-OGWC3J3C.js} +1 -1
- package/dist/chunk-OIYGGEUL.js +6 -0
- package/dist/{chunk-T2ULEJK7.js → chunk-POYZ6SAI.js} +2 -2
- package/dist/chunk-Q2F5QB2W.js +2 -0
- package/dist/{chunk-3YI4QRXF.js → chunk-QJIJC3KC.js} +1 -1
- package/dist/{chunk-G6F2BOFT.js → chunk-RFJAYURU.js} +1 -1
- package/dist/chunk-RGJIRS3B.js +2 -0
- package/dist/{chunk-CLYG26XV.js → chunk-RZJVQUBA.js} +35 -35
- package/dist/{chunk-QB4IOM3X.js → chunk-SURF5Z7Y.js} +1 -1
- package/dist/chunk-TDPWFYTJ.js +2 -0
- package/dist/chunk-V3UE6RJP.js +2 -0
- package/dist/chunk-VOHQA2SP.js +2 -0
- package/dist/{chunk-FFHBQK5N.js → chunk-XSKLH2MC.js} +2 -2
- package/dist/{chunk-OAEZKYYQ.js → chunk-XWSAKVEY.js} +2 -2
- package/dist/{chunk-F42YVALT.js → chunk-XXMNUJX4.js} +1 -1
- package/dist/{chunk-QZNUTCSD.js → chunk-XZRIQ3GF.js} +1 -1
- package/dist/chunk-Y5RNCJAN.js +19 -0
- package/dist/chunk-YSSTGJ7O.js +7 -0
- package/dist/chunk-Z2JSEL3I.js +4 -0
- package/dist/{chunk-R65HNFRB.js → chunk-ZNHXIRCM.js} +9 -9
- package/dist/{chunk-AU7WQ2O5.js → chunk-ZP4S5WGW.js} +1 -1
- package/dist/{chunk-NIKA2V6B.js → chunk-ZPCU6546.js} +1 -1
- package/dist/{config-Z4OS3HEE.js → config-QISRENF5.js} +1 -1
- package/dist/{cover-cmd-L2HSVDLH.js → cover-cmd-SV3I23UM.js} +1 -1
- package/dist/{credentials-TNEVAUHI.js → credentials-OGLK7MPV.js} +1 -1
- package/dist/docx-convert-ZBVQO2LG.js +2 -0
- package/dist/{dossier-ZHSHATVU.js → dossier-KJSJPWOW.js} +1 -1
- package/dist/{evidence-MA3LDBWG.js → evidence-HDD7T7DX.js} +1 -1
- package/dist/evolve-cmd-UE2BIMXK.js +2 -0
- package/dist/exit-manager-MXUD7GQ7.js +2 -0
- package/dist/{explain-VTRHEVUQ.js → explain-EBVIUS2X.js} +1 -1
- package/dist/{explain-cmd-E366QTAD.js → explain-cmd-DBUTPZHA.js} +1 -1
- package/dist/{explain-cmd-327F6ESA.js → explain-cmd-NWIYH5MI.js} +1 -1
- package/dist/extract-bind-6MQYKN3G.js +8 -0
- package/dist/{extract-cmd-LFVMG6UE.js → extract-cmd-2RUIWFZG.js} +1 -1
- package/dist/{gaps-cmd-IAEXXESW.js → gaps-cmd-CKCHH3HQ.js} +1 -1
- package/dist/{generate-headless-TYQRYQKJ.js → generate-headless-TUA3HGRX.js} +2 -2
- package/dist/index.js +67 -65
- package/dist/ingest-FIIO67ZN.js +2 -0
- package/dist/ingest-cmd-CRMY46YC.js +7 -0
- package/dist/interactive-bind-53FCRK34.js +10 -0
- package/dist/{lifecycle-cmd-KZOC4WDW.js → lifecycle-cmd-32LG364Q.js} +1 -1
- package/dist/{list-cmd-6X5U46RD.js → list-cmd-UTZ2PQUK.js} +1 -1
- package/dist/list-commands-F53ZNYOZ.js +2 -0
- package/dist/{logical-ids-RFGWBVML.js → logical-ids-I7B3VJEH.js} +1 -1
- package/dist/login-flow-D7KBR7XR.js +2 -0
- package/dist/{maintenance-cmd-UJG4LPWD.js → maintenance-cmd-BZAGSYGI.js} +1 -1
- package/dist/pdf-convert-S7VYE6AV.js +2 -0
- package/dist/{persist-recorded-session-RAL7UCQT.js → persist-recorded-session-5ZFS5SMZ.js} +1 -1
- package/dist/pipeline-MX3ZR5B3.js +2 -0
- package/dist/readmodel-S5RAQH3F.js +2 -0
- package/dist/reconcile-cmd-4377PWF5.js +2 -0
- package/dist/{recording-banner-MBR3Q7VD.js → recording-banner-ZZUF2MGT.js} +1 -1
- package/dist/{require-project-folder-KE7XOOFN.js → require-project-folder-NQBZFUPF.js} +1 -1
- package/dist/{revert-FRXNIP5R.js → revert-RQJE56HF.js} +1 -1
- package/dist/{review-cmd-XVWPSWU2.js → review-cmd-7LXGYHHQ.js} +1 -1
- package/dist/run-2AIQUJ55.js +2 -0
- package/dist/run-YH5SCBYD.js +2 -0
- package/dist/{run-test-md-ZCAWNP35.js → run-test-md-XOSCYVSS.js} +2 -2
- package/dist/{sessions-cmd-STHKGDX4.js → sessions-cmd-DTQYDZNT.js} +1 -1
- package/dist/{skill-installer-H5DPJJFW.js → skill-installer-VYIIWAK7.js} +1 -1
- package/dist/{spawner-C6B5J73J.js → spawner-7KXVKAD5.js} +1 -1
- package/dist/store-id-EOSGEKVK.js +2 -0
- package/dist/tcg-generate-U6OCCS2E.js +2 -0
- package/dist/testmd-actions-RPALXRZK.js +2 -0
- package/dist/token-refresh-S7CYBZTE.js +2 -0
- package/dist/{validate-basic-VBPGGHES.js → validate-basic-LP3S5PK7.js} +1 -1
- package/dist/{version-check-YPRCQJ7E.js → version-check-XP62HWLJ.js} +1 -1
- package/dist/{view-cmd-G4PGJRQH.js → view-cmd-GQBFCPDL.js} +1 -1
- package/dist/walk-session-YIKHE6PT.js +2 -0
- package/package.json +10 -6
- package/dist/ChatSurface-B2QJYKV4.js +0 -8
- package/dist/EvidenceViewOffer-5TJCRM2T.js +0 -2
- package/dist/SingleShotApp-YQYS6HTB.js +0 -2
- package/dist/TestMdRunView-7CL3PM3J.js +0 -2
- package/dist/bind-HNI5LCNK.js +0 -6
- package/dist/chat-controller-YX5A7R52.js +0 -2
- package/dist/chunk-2Z5MSC23.js +0 -12
- package/dist/chunk-4BAL4OGF.js +0 -7
- package/dist/chunk-4CKZAGBD.js +0 -2
- package/dist/chunk-4GXOBABK.js +0 -4
- package/dist/chunk-E4EHWO3J.js +0 -4
- package/dist/chunk-FXPPQL4D.js +0 -6
- package/dist/chunk-GLS46X7N.js +0 -5
- package/dist/chunk-M5JQXOCE.js +0 -12
- package/dist/chunk-RHNKYNNZ.js +0 -6
- package/dist/chunk-SORKKW7B.js +0 -6
- package/dist/chunk-VCYVSKPM.js +0 -2
- package/dist/chunk-VXLOEM2U.js +0 -347
- package/dist/chunk-XTO236AL.js +0 -14
- package/dist/chunk-XWIN3S7O.js +0 -4
- package/dist/evolve-cmd-DTW4EOXM.js +0 -2
- package/dist/exit-manager-VCSIUYBR.js +0 -2
- package/dist/extract-bind-DZLG4GUE.js +0 -5
- package/dist/ingest-CBQAXVH6.js +0 -2
- package/dist/ingest-cmd-JN6PLDE3.js +0 -3
- package/dist/interactive-bind-QEBWUJCN.js +0 -7
- package/dist/list-commands-BU2MSYRH.js +0 -2
- package/dist/login-flow-4L62GWLT.js +0 -2
- package/dist/pdf-convert-KYXI4FU4.js +0 -2
- package/dist/pipeline-PLI5WQKX.js +0 -2
- package/dist/readmodel-V3DVL6NP.js +0 -2
- package/dist/reconcile-cmd-UXY36ROJ.js +0 -2
- package/dist/run-5DQSL5KH.js +0 -2
- package/dist/run-B7BRNC3X.js +0 -2
- package/dist/tcg-generate-DIMZXAV3.js +0 -2
- package/dist/testmd-actions-X6XCV53D.js +0 -2
- package/dist/token-refresh-7PAPCMQK.js +0 -2
- package/dist/walk-session-GWOP27TX.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as b}from"./chunk-
|
|
2
|
+
import{a as b}from"./chunk-KXUSG5ZI.js";import{n as d,y as o}from"./chunk-MMPFU2YC.js";import{a as L}from"./chunk-HCBYKLMW.js";import{a as u,b as c,i as A}from"./chunk-C44QQJR4.js";import{a as D}from"./chunk-6YGTRKDT.js";import{e as h}from"./chunk-UR6MHSHU.js";var x=h(D(),1);import{readdirSync as N,mkdirSync as B,statSync as k}from"fs";import{join as P}from"path";var r=h(L(),1);function O(n){try{return N(n).filter(l=>{try{return k(P(n,l)).isDirectory()}catch{return!1}})}catch{return[]}}function E(n,l,f,v){return{name:n,path:l,label:n,isActive:v}}function H({currentPath:n,onSelect:l,onCancel:f}){let s=O(d).map(i=>{let e=P(d,i);return E(i,e,n,e===n)}),p=!n,R=s.length+2,[a,C]=(0,x.useState)(()=>{if(p)return 0;let i=s.findIndex(e=>e.isActive);return i>=0?i+1:0}),[T,I]=(0,x.useState)(!1),[S,g]=(0,x.useState)("");return A((i,e)=>{if(T){if(e.escape){I(!1),g("");return}if(e.return){let t=S.trim();if(t){let m=P(d,t);B(m,{recursive:!0}),l(m),f()}return}if(e.backspace||e.delete){g(t=>t.slice(0,-1));return}i&&!e.ctrl&&!e.meta&&g(t=>t+i);return}if(e.escape){f();return}if(e.upArrow){C(t=>Math.max(0,t-1));return}if(e.downArrow){C(t=>Math.min(R-1,t+1));return}if(e.return){if(a===0){p||l(""),f();return}if(a===s.length+1){B(d,{recursive:!0}),I(!0),g("");return}let t=s[a-1];t&&!t.isActive&&l(t.path),f();return}}),T?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile \u203A New"}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(c,{color:o.secondary,children:"Name: "}),(0,r.jsx)(c,{children:S}),(0,r.jsx)(c,{color:o.dim,children:"\u2588"})]}),(0,r.jsx)(b,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:"back"})]}):(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile"}),(0,r.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,r.jsxs)(c,{color:p?o.green:a===0?o.orange:o.dim,children:[a===0?"\u276F ":" ","Use temporary (no profile)",p?" \u25CF active":""]}),s.map((i,e)=>{let m=e+1===a,w=m?"\u276F ":" ",y=i.isActive?o.green:m?o.orange:void 0;return(0,r.jsxs)(c,{color:y,children:[w,i.label,i.isActive?" \u25CF active":""]},i.name)}),(0,r.jsxs)(c,{color:a===s.length+1?o.orange:o.dim,children:[a===s.length+1?"\u276F ":" ","+ Create new"]})]}),(0,r.jsx)(b,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}export{O as a,E as b,H as c};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as k,b as F}from"./chunk-VOHQA2SP.js";import{b as $}from"./chunk-NVGBE2DR.js";import{deflateSync as Y}from"zlib";function j(n,s){let e=Buffer.alloc(4);e.writeUInt32BE(s.length);let o=Buffer.concat([Buffer.from(n,"latin1"),s]),i=Buffer.alloc(4);return i.writeUInt32BE(F(o)),Buffer.concat([e,o,i])}var G={1:0,3:2,4:6};function N(n,s){let{width:e,height:o,channels:i}=s;if(n.byteLength!==e*o*i)throw new Error(`pngEncode: raw length ${n.byteLength} != ${e}x${o}x${i}`);let d=Buffer.alloc(13);d.writeUInt32BE(e,0),d.writeUInt32BE(o,4),d[8]=8,d[9]=G[i];let t=e*i,a=Buffer.alloc(o*(t+1));for(let f=0;f<o;f++)a[f*(t+1)]=0,n.copy(a,f*(t+1)+1,f*t,(f+1)*t);return Buffer.concat([Buffer.from([137,80,78,71,13,10,26,10]),j("IHDR",d),j("IDAT",Y(a)),j("IEND",Buffer.alloc(0))])}var U=64,X=16,J=12e6,V=6e6,K=5e3,W=3e4,H="",_=class extends Error{constructor(e,o){super(`${e}: ${o}`);this.code=e}};async function q(n,s,e){let o=n.objs.has(s)?n.objs:n.commonObjs.has(s)?n.commonObjs:null;if(o)try{return o.get(s)??null}catch{return null}if(e.remainingMs<=0)return null;let i=s.startsWith("g_")?n.commonObjs:n.objs,d,t=Date.now();try{return await Promise.race([new Promise(a=>{try{i.get(s,f=>a(f??null))}catch{a(null)}}),new Promise(a=>{d=setTimeout(()=>a(null),Math.min(K,e.remainingMs))})])}finally{clearTimeout(d),e.remainingMs-=Date.now()-t}}async function z(){let n=await import("pdfjs-dist/legacy/build/pdf.mjs");return n.default??n}async function oe(n,s){let e=await z();H=e.version;let o={remainingMs:s?.resolveBudgetMs??W},i,d=e.getDocument({data:new Uint8Array(n),isEvalSupported:!1,verbosity:0});try{i=await d.promise}catch(t){throw t.name==="PasswordException"?new _("PDF_ENCRYPTED","password-protected \u2014 decrypt and re-ingest"):new _("PDF_UNREADABLE",String(t.message??t))}try{let t=[],a=[],f=new Map,D=[],T=new Map,R=0,A=0;for(let u=1;u<=i.numPages;u++){let O=await i.getPage(u);t.push(`[page ${u}]`);let C=await O.getTextContent(),c="",E=null;for(let m of C.items){if(typeof m!="object"||m===null||!("str"in m))continue;let p=m,P=Math.round(p.transform[5]);E!==null&&P!==E&&c.trim()!==""&&(t.push(c.trimEnd()),c=""),c!==""&&!c.endsWith(" ")&&p.str!==""&&!p.str.startsWith(" ")&&P===E&&(c+=" "),c+=p.str,A+=p.str.trim().length,E=P,p.hasEOL&&c.trim()!==""&&(t.push(c.trimEnd()),c="",E=null)}c.trim()!==""&&t.push(c.trimEnd());let B=await O.getOperatorList(),M=0;for(let m=0;m<B.fnArray.length;m++){let p=B.fnArray[m]===e.OPS.paintImageXObject,P=B.fnArray[m]===e.OPS.paintInlineImageXObject;if(!p&&!P)continue;M+=1;let h=`p${u}-${M}`,l=(v,L,w,S)=>{a.push({ref:h,page:u,media_type:"image/png",...L?{blob:L}:{},...S?{appearance:S}:{},delivery:v,...w?{duplicate_of:w}:{}}),t.push(v==="duplicate"&&w?`[img#${h}: image on page ${u} \u2014 same as img#${w}; cite img#${w}]`:`[img#${h} omitted: ${v}]`)};if(P){l("unsupported-image-kind");continue}let r=await q(O,B.argsArray[m][0],o);if(!r?.data||!r.width||!r.height){l("undecodable");continue}let I;if(r.kind===e.ImageKind.RGB_24BPP)I=3;else if(r.kind===e.ImageKind.RGBA_32BPP)I=4;else{l("unsupported-image-kind");continue}let y;try{y=N(Buffer.from(r.data.buffer,r.data.byteOffset,r.data.byteLength),{width:r.width,height:r.height,channels:I})}catch{l("undecodable");continue}let g=$(y);f.set(g,y);let b=k(Buffer.from(r.data.buffer,r.data.byteOffset,r.data.byteLength),{width:r.width,height:r.height,channels:I});if(r.width<U||r.height<U){l("below-dimension-floor",g,void 0,b);continue}let x=T.get(g);if(x!==void 0){l("duplicate",g,x,b);continue}if(y.byteLength>V){l("image-too-large",g,void 0,b);continue}if(R+y.byteLength>J){l("vision-byte-budget-reached",g,void 0,b);continue}if(D.length>=X){l("image-cap-reached",g,void 0,b);continue}T.set(g,h),R+=y.byteLength,D.push(h),a.push({ref:h,page:u,media_type:"image/png",blob:g,appearance:b,delivery:"selected"}),t.push(`[img#${h}: image on page ${u}]`)}}if(A===0&&i.numPages>0)throw new _("PDF_NO_TEXT_LAYER","no extractable text \u2014 image-only or scanned pdfs are not supported yet");return{projection:t.join(`
|
|
3
|
+
`)+`
|
|
4
|
+
`,inventory:a,blobs:f,delivered:D,pages:i.numPages,converter:{name:"pdfjs-dist",version:e.version,policy:"v1"}}}finally{await d.destroy().catch(()=>{})}}export{U as a,X as b,J as c,V as d,H as e,_ as f,oe as g};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as ri,b as ii}from"./chunk-VOHQA2SP.js";import{b as ei}from"./chunk-NVGBE2DR.js";import{a as Rt,c as pt,e as Le}from"./chunk-UR6MHSHU.js";var di=pt(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.CHAR=`
|
|
3
|
+
\r -\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}`;wt.S=` \r
|
|
4
|
+
`;wt.NAME_START_CHAR=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";wt.NAME_CHAR="-"+wt.NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";wt.CHAR_RE=new RegExp("^["+wt.CHAR+"]$","u");wt.S_RE=new RegExp("^["+wt.S+"]+$","u");wt.NAME_START_CHAR_RE=new RegExp("^["+wt.NAME_START_CHAR+"]$","u");wt.NAME_CHAR_RE=new RegExp("^["+wt.NAME_CHAR+"]$","u");wt.NAME_RE=new RegExp("^["+wt.NAME_START_CHAR+"]["+wt.NAME_CHAR+"]*$","u");wt.NMTOKEN_RE=new RegExp("^["+wt.NAME_CHAR+"]+$","u");var tr=9,er=10,rr=13,ir=32;wt.S_LIST=[ir,er,rr,tr];function Ds(t){return t>=ir&&t<=55295||t===er||t===rr||t===tr||t>=57344&&t<=65533||t>=65536&&t<=1114111}wt.isChar=Ds;function ks(t){return t===ir||t===er||t===rr||t===tr}wt.isS=ks;function ci(t){return t>=65&&t<=90||t>=97&&t<=122||t===58||t===95||t===8204||t===8205||t>=192&&t<=214||t>=216&&t<=246||t>=248&&t<=767||t>=880&&t<=893||t>=895&&t<=8191||t>=8304&&t<=8591||t>=11264&&t<=12271||t>=12289&&t<=55295||t>=63744&&t<=64975||t>=65008&&t<=65533||t>=65536&&t<=983039}wt.isNameStartChar=ci;function Rs(t){return ci(t)||t>=48&&t<=57||t===45||t===46||t===183||t>=768&&t<=879||t>=8255&&t<=8256}wt.isNameChar=Rs});var _i=pt(ct=>{"use strict";Object.defineProperty(ct,"__esModule",{value:!0});ct.CHAR="-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}";ct.RESTRICTED_CHAR="-\b\v\f-\x7F-\x84\x86-\x9F";ct.S=` \r
|
|
5
|
+
`;ct.NAME_START_CHAR=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";ct.NAME_CHAR="-"+ct.NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";ct.CHAR_RE=new RegExp("^["+ct.CHAR+"]$","u");ct.RESTRICTED_CHAR_RE=new RegExp("^["+ct.RESTRICTED_CHAR+"]$","u");ct.S_RE=new RegExp("^["+ct.S+"]+$","u");ct.NAME_START_CHAR_RE=new RegExp("^["+ct.NAME_START_CHAR+"]$","u");ct.NAME_CHAR_RE=new RegExp("^["+ct.NAME_CHAR+"]$","u");ct.NAME_RE=new RegExp("^["+ct.NAME_START_CHAR+"]["+ct.NAME_CHAR+"]*$","u");ct.NMTOKEN_RE=new RegExp("^["+ct.NAME_CHAR+"]+$","u");var pi=9,xi=10,gi=13,mi=32;ct.S_LIST=[mi,xi,gi,pi];function Ss(t){return t>=1&&t<=55295||t>=57344&&t<=65533||t>=65536&&t<=1114111}ct.isChar=Ss;function Os(t){return t>=1&&t<=8||t===11||t===12||t>=14&&t<=31||t>=127&&t<=132||t>=134&&t<=159}ct.isRestrictedChar=Os;function Ns(t){return t===9||t===10||t===13||t>31&&t<127||t===133||t>159&&t<=55295||t>=57344&&t<=65533||t>=65536&&t<=1114111}ct.isCharAndNotRestricted=Ns;function Is(t){return t===mi||t===xi||t===gi||t===pi}ct.isS=Is;function vi(t){return t>=65&&t<=90||t>=97&&t<=122||t===58||t===95||t===8204||t===8205||t>=192&&t<=214||t>=216&&t<=246||t>=248&&t<=767||t>=880&&t<=893||t>=895&&t<=8191||t>=8304&&t<=8591||t>=11264&&t<=12271||t>=12289&&t<=55295||t>=63744&&t<=64975||t>=65008&&t<=65533||t>=65536&&t<=983039}ct.isNameStartChar=vi;function Ms(t){return vi(t)||t>=48&&t<=57||t===45||t===46||t===183||t>=768&&t<=879||t>=8255&&t<=8256}ct.isNameChar=Ms});var Ei=pt(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.NC_NAME_START_CHAR="A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";Mt.NC_NAME_CHAR="-"+Mt.NC_NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";Mt.NC_NAME_START_CHAR_RE=new RegExp("^["+Mt.NC_NAME_START_CHAR+"]$","u");Mt.NC_NAME_CHAR_RE=new RegExp("^["+Mt.NC_NAME_CHAR+"]$","u");Mt.NC_NAME_RE=new RegExp("^["+Mt.NC_NAME_START_CHAR+"]["+Mt.NC_NAME_CHAR+"]*$","u");function wi(t){return t>=65&&t<=90||t===95||t>=97&&t<=122||t>=192&&t<=214||t>=216&&t<=246||t>=248&&t<=767||t>=880&&t<=893||t>=895&&t<=8191||t>=8204&&t<=8205||t>=8304&&t<=8591||t>=11264&&t<=12271||t>=12289&&t<=55295||t>=63744&&t<=64975||t>=65008&&t<=65533||t>=65536&&t<=983039}Mt.isNCNameStartChar=wi;function Ls(t){return wi(t)||t===45||t===46||t>=48&&t<=57||t===183||t>=768&&t<=879||t>=8255&&t<=8256}Mt.isNCNameChar=Ls});var vr=pt(ue=>{"use strict";Object.defineProperty(ue,"__esModule",{value:!0});ue.SaxesParser=ue.EVENTS=void 0;var ce=di(),Ps=_i(),mr=Ei(),Lt=ce.isS,Bs=ce.isChar,De=ce.isNameStartChar,Ci=ce.isNameChar,Li=ce.S_LIST,Us=ce.NAME_RE,Hs=Ps.isChar,Xs=mr.isNCNameStartChar,$s=mr.isNCNameChar,Ys=mr.NC_NAME_RE,$e="http://www.w3.org/XML/1998/namespace",fe="http://www.w3.org/2000/xmlns/",qs={__proto__:null,xml:$e,xmlns:fe},zs={__proto__:null,amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},Ct=-1,zt=-2,bi=0,Gs=1,nr=2,Ws=3,oe=4,Vs=5,js=6,Zs=7,sr=8,Qs=9,Ks=10,Js=11,ta=12,Nt=13,Pe=14,ar=15,ea=16,or=17,ra=18,ia=19,hr=20,na=21,sa=22,aa=23,Ti=24,lr=25,Be=26,yi=27,oa=28,ha=29,Ai=30,la=31,fa=32,Kt=33,ua=34,fr=35,ke=36,ur=37,ca=38,Fi=39,Di=40,da=41,ki=42,pa=43,xa=44,cr=9,$t=10,dr=13,Ri=32,Si=33,Pi=34,Re=38,Bi=39,Ue=45,He=47,ga=59,Vt=60,he=61,Tt=62,kt=63,Ui=91,le=93,Oi=133,Ni=8232,Xe=t=>t===Pi||t===Bi,Hi=[Pi,Bi],ma=[...Hi,Ui,Tt],va=[...Hi,Vt,le],_a=[he,kt,...Li],wa=[...Li,Tt,Re,Vt];function xr(t,e,r){switch(e){case"xml":r!==$e&&t.fail(`xml prefix must be bound to ${$e}.`);break;case"xmlns":r!==fe&&t.fail(`xmlns prefix must be bound to ${fe}.`);break;default:}switch(r){case fe:t.fail(e===""?`the default namespace may not be set to ${r}.`:`may not assign a prefix (even "xmlns") to the URI ${fe}.`);break;case $e:switch(e){case"xml":break;case"":t.fail(`the default namespace may not be set to ${r}.`);break;default:t.fail("may not assign the xml namespace to another prefix.")}break;default:}}function Ea(t,e){for(let r of Object.keys(e))xr(t,r,e[r])}var Ca=t=>Ys.test(t),ba=t=>Us.test(t),Jt=0,Ii=1,pr=2;ue.EVENTS=["xmldecl","text","processinginstruction","doctype","comment","opentagstart","attribute","opentag","closetag","cdata","error","end","ready"];var Mi={xmldecl:"xmldeclHandler",text:"textHandler",processinginstruction:"piHandler",doctype:"doctypeHandler",comment:"commentHandler",opentagstart:"openTagStartHandler",attribute:"attributeHandler",opentag:"openTagHandler",closetag:"closeTagHandler",cdata:"cdataHandler",error:"errorHandler",end:"endHandler",ready:"readyHandler"},gr=class{constructor(e){this.opt=e??{},this.fragmentOpt=!!this.opt.fragment;let r=this.xmlnsOpt=!!this.opt.xmlns;if(this.trackPosition=this.opt.position!==!1,this.fileName=this.opt.fileName,r){this.nameStartCheck=Xs,this.nameCheck=$s,this.isName=Ca,this.processAttribs=this.processAttribsNS,this.pushAttrib=this.pushAttribNS,this.ns=Object.assign({__proto__:null},qs);let i=this.opt.additionalNamespaces;i!=null&&(Ea(this,i),Object.assign(this.ns,i))}else this.nameStartCheck=De,this.nameCheck=Ci,this.isName=ba,this.processAttribs=this.processAttribsPlain,this.pushAttrib=this.pushAttribPlain;this.stateTable=[this.sBegin,this.sBeginWhitespace,this.sDoctype,this.sDoctypeQuote,this.sDTD,this.sDTDQuoted,this.sDTDOpenWaka,this.sDTDOpenWakaBang,this.sDTDComment,this.sDTDCommentEnding,this.sDTDCommentEnded,this.sDTDPI,this.sDTDPIEnding,this.sText,this.sEntity,this.sOpenWaka,this.sOpenWakaBang,this.sComment,this.sCommentEnding,this.sCommentEnded,this.sCData,this.sCDataEnding,this.sCDataEnding2,this.sPIFirstChar,this.sPIRest,this.sPIBody,this.sPIEnding,this.sXMLDeclNameStart,this.sXMLDeclName,this.sXMLDeclEq,this.sXMLDeclValueStart,this.sXMLDeclValue,this.sXMLDeclSeparator,this.sXMLDeclEnding,this.sOpenTag,this.sOpenTagSlash,this.sAttrib,this.sAttribName,this.sAttribNameSawWhite,this.sAttribValue,this.sAttribValueQuoted,this.sAttribValueClosed,this.sAttribValueUnquoted,this.sCloseTag,this.sCloseTagSawWhite],this._init()}get closed(){return this._closed}_init(){var e;this.openWakaBang="",this.text="",this.name="",this.piTarget="",this.entity="",this.q=null,this.tags=[],this.tag=null,this.topNS=null,this.chunk="",this.chunkPosition=0,this.i=0,this.prevI=0,this.carriedFromPrevious=void 0,this.forbiddenState=Jt,this.attribList=[];let{fragmentOpt:r}=this;this.state=r?Nt:bi,this.reportedTextBeforeRoot=this.reportedTextAfterRoot=this.closedRoot=this.sawRoot=r,this.xmlDeclPossible=!r,this.xmlDeclExpects=["version"],this.entityReturnState=void 0;let{defaultXMLVersion:i}=this.opt;if(i===void 0){if(this.opt.forceXMLVersion===!0)throw new Error("forceXMLVersion set but defaultXMLVersion is not set");i="1.0"}this.setXMLVersion(i),this.positionAtNewLine=0,this.doctype=!1,this._closed=!1,this.xmlDecl={version:void 0,encoding:void 0,standalone:void 0},this.line=1,this.column=0,this.ENTITIES=Object.create(zs),(e=this.readyHandler)===null||e===void 0||e.call(this)}get position(){return this.chunkPosition+this.i}get columnIndex(){return this.position-this.positionAtNewLine}on(e,r){this[Mi[e]]=r}off(e){this[Mi[e]]=void 0}makeError(e){var r;let i=(r=this.fileName)!==null&&r!==void 0?r:"";return this.trackPosition&&(i.length>0&&(i+=":"),i+=`${this.line}:${this.column}`),i.length>0&&(i+=": "),new Error(i+e)}fail(e){let r=this.makeError(e),i=this.errorHandler;if(i===void 0)throw r;return i(r),this}write(e){if(this.closed)return this.fail("cannot write after close; assign an onready handler.");let r=!1;e===null?(r=!0,e=""):typeof e=="object"&&(e=e.toString()),this.carriedFromPrevious!==void 0&&(e=`${this.carriedFromPrevious}${e}`,this.carriedFromPrevious=void 0);let i=e.length,n=e.charCodeAt(i-1);!r&&(n===dr||n>=55296&&n<=56319)&&(this.carriedFromPrevious=e[i-1],i--,e=e.slice(0,i));let{stateTable:s}=this;for(this.chunk=e,this.i=0;this.i<i;)s[this.state].call(this);return this.chunkPosition+=i,r?this.end():this}close(){return this.write(null)}getCode10(){let{chunk:e,i:r}=this;if(this.prevI=r,this.i=r+1,r>=e.length)return Ct;let i=e.charCodeAt(r);if(this.column++,i<55296){if(i>=Ri||i===cr)return i;switch(i){case $t:return this.line++,this.column=0,this.positionAtNewLine=this.position,$t;case dr:return e.charCodeAt(r+1)===$t&&(this.i=r+2),this.line++,this.column=0,this.positionAtNewLine=this.position,zt;default:return this.fail("disallowed character."),i}}if(i>56319)return i>=57344&&i<=65533||this.fail("disallowed character."),i;let n=65536+(i-55296)*1024+(e.charCodeAt(r+1)-56320);return this.i=r+2,n>1114111&&this.fail("disallowed character."),n}getCode11(){let{chunk:e,i:r}=this;if(this.prevI=r,this.i=r+1,r>=e.length)return Ct;let i=e.charCodeAt(r);if(this.column++,i<55296){if(i>31&&i<127||i>159&&i!==Ni||i===cr)return i;switch(i){case $t:return this.line++,this.column=0,this.positionAtNewLine=this.position,$t;case dr:{let s=e.charCodeAt(r+1);(s===$t||s===Oi)&&(this.i=r+2)}case Oi:case Ni:return this.line++,this.column=0,this.positionAtNewLine=this.position,zt;default:return this.fail("disallowed character."),i}}if(i>56319)return i>=57344&&i<=65533||this.fail("disallowed character."),i;let n=65536+(i-55296)*1024+(e.charCodeAt(r+1)-56320);return this.i=r+2,n>1114111&&this.fail("disallowed character."),n}getCodeNorm(){let e=this.getCode();return e===zt?$t:e}unget(){this.i=this.prevI,this.column--}captureTo(e){let{i:r}=this,{chunk:i}=this;for(;;){let n=this.getCode(),s=n===zt,a=s?$t:n;if(a===Ct||e.includes(a))return this.text+=i.slice(r,this.prevI),a;s&&(this.text+=`${i.slice(r,this.prevI)}
|
|
6
|
+
`,r=this.i)}}captureToChar(e){let{i:r}=this,{chunk:i}=this;for(;;){let n=this.getCode();switch(n){case zt:this.text+=`${i.slice(r,this.prevI)}
|
|
7
|
+
`,r=this.i,n=$t;break;case Ct:return this.text+=i.slice(r),!1;default:}if(n===e)return this.text+=i.slice(r,this.prevI),!0}}captureNameChars(){let{chunk:e,i:r}=this;for(;;){let i=this.getCode();if(i===Ct)return this.name+=e.slice(r),Ct;if(!Ci(i))return this.name+=e.slice(r,this.prevI),i===zt?$t:i}}skipSpaces(){for(;;){let e=this.getCodeNorm();if(e===Ct||!Lt(e))return e}}setXMLVersion(e){this.currentXMLVersion=e,e==="1.0"?(this.isChar=Bs,this.getCode=this.getCode10):(this.isChar=Hs,this.getCode=this.getCode11)}sBegin(){this.chunk.charCodeAt(0)===65279&&(this.i++,this.column++),this.state=Gs}sBeginWhitespace(){let e=this.i,r=this.skipSpaces();switch(this.prevI!==e&&(this.xmlDeclPossible=!1),r){case Vt:if(this.state=ar,this.text.length!==0)throw new Error("no-empty text at start");break;case Ct:break;default:this.unget(),this.state=Nt,this.xmlDeclPossible=!1}}sDoctype(){var e;let r=this.captureTo(ma);switch(r){case Tt:{(e=this.doctypeHandler)===null||e===void 0||e.call(this,this.text),this.text="",this.state=Nt,this.doctype=!0;break}case Ct:break;default:this.text+=String.fromCodePoint(r),r===Ui?this.state=oe:Xe(r)&&(this.state=Ws,this.q=r)}}sDoctypeQuote(){let e=this.q;this.captureToChar(e)&&(this.text+=String.fromCodePoint(e),this.q=null,this.state=nr)}sDTD(){let e=this.captureTo(va);e!==Ct&&(this.text+=String.fromCodePoint(e),e===le?this.state=nr:e===Vt?this.state=js:Xe(e)&&(this.state=Vs,this.q=e))}sDTDQuoted(){let e=this.q;this.captureToChar(e)&&(this.text+=String.fromCodePoint(e),this.state=oe,this.q=null)}sDTDOpenWaka(){let e=this.getCodeNorm();switch(this.text+=String.fromCodePoint(e),e){case Si:this.state=Zs,this.openWakaBang="";break;case kt:this.state=Js;break;default:this.state=oe}}sDTDOpenWakaBang(){let e=String.fromCodePoint(this.getCodeNorm()),r=this.openWakaBang+=e;this.text+=e,r!=="-"&&(this.state=r==="--"?sr:oe,this.openWakaBang="")}sDTDComment(){this.captureToChar(Ue)&&(this.text+="-",this.state=Qs)}sDTDCommentEnding(){let e=this.getCodeNorm();this.text+=String.fromCodePoint(e),this.state=e===Ue?Ks:sr}sDTDCommentEnded(){let e=this.getCodeNorm();this.text+=String.fromCodePoint(e),e===Tt?this.state=oe:(this.fail("malformed comment."),this.state=sr)}sDTDPI(){this.captureToChar(kt)&&(this.text+="?",this.state=ta)}sDTDPIEnding(){let e=this.getCodeNorm();this.text+=String.fromCodePoint(e),e===Tt&&(this.state=oe)}sText(){this.tags.length!==0?this.handleTextInRoot():this.handleTextOutsideRoot()}sEntity(){let{i:e}=this,{chunk:r}=this;t:for(;;)switch(this.getCode()){case zt:this.entity+=`${r.slice(e,this.prevI)}
|
|
8
|
+
`,e=this.i;break;case ga:{let{entityReturnState:i}=this,n=this.entity+r.slice(e,this.prevI);this.state=i;let s;n===""?(this.fail("empty entity name."),s="&;"):(s=this.parseEntity(n),this.entity=""),(i!==Nt||this.textHandler!==void 0)&&(this.text+=s);break t}case Ct:this.entity+=r.slice(e);break t;default:}}sOpenWaka(){let e=this.getCode();if(De(e))this.state=ua,this.unget(),this.xmlDeclPossible=!1;else switch(e){case He:this.state=pa,this.xmlDeclPossible=!1;break;case Si:this.state=ea,this.openWakaBang="",this.xmlDeclPossible=!1;break;case kt:this.state=aa;break;default:this.fail("disallowed character in tag name"),this.state=Nt,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case"[CDATA[":!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0),this.state=hr,this.openWakaBang="";break;case"--":this.state=or,this.openWakaBang="";break;case"DOCTYPE":this.state=nr,(this.doctype||this.sawRoot)&&this.fail("inappropriately located doctype declaration."),this.openWakaBang="";break;default:this.openWakaBang.length>=7&&this.fail("incorrect syntax.")}}sComment(){this.captureToChar(Ue)&&(this.state=ra)}sCommentEnding(){var e;let r=this.getCodeNorm();r===Ue?(this.state=ia,(e=this.commentHandler)===null||e===void 0||e.call(this,this.text),this.text=""):(this.text+=`-${String.fromCodePoint(r)}`,this.state=or)}sCommentEnded(){let e=this.getCodeNorm();e!==Tt?(this.fail("malformed comment."),this.text+=`--${String.fromCodePoint(e)}`,this.state=or):this.state=Nt}sCData(){this.captureToChar(le)&&(this.state=na)}sCDataEnding(){let e=this.getCodeNorm();e===le?this.state=sa:(this.text+=`]${String.fromCodePoint(e)}`,this.state=hr)}sCDataEnding2(){var e;let r=this.getCodeNorm();switch(r){case Tt:{(e=this.cdataHandler)===null||e===void 0||e.call(this,this.text),this.text="",this.state=Nt;break}case le:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(r)}`,this.state=hr}}sPIFirstChar(){let e=this.getCodeNorm();this.nameStartCheck(e)?(this.piTarget+=String.fromCodePoint(e),this.state=Ti):e===kt||Lt(e)?(this.fail("processing instruction without a target."),this.state=e===kt?Be:lr):(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(e),this.state=Ti)}sPIRest(){let{chunk:e,i:r}=this;for(;;){let i=this.getCodeNorm();if(i===Ct){this.piTarget+=e.slice(r);return}if(!this.nameCheck(i)){this.piTarget+=e.slice(r,this.prevI);let n=i===kt;n||Lt(i)?this.piTarget==="xml"?(this.xmlDeclPossible||this.fail("an XML declaration must be at the start of the document."),this.state=n?Kt:yi):this.state=n?Be:lr:(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(i));break}}}sPIBody(){if(this.text.length===0){let e=this.getCodeNorm();e===kt?this.state=Be:Lt(e)||(this.text=String.fromCodePoint(e))}else this.captureToChar(kt)&&(this.state=Be)}sPIEnding(){var e;let r=this.getCodeNorm();if(r===Tt){let{piTarget:i}=this;i.toLowerCase()==="xml"&&this.fail("the XML declaration must appear at the start of the document."),(e=this.piHandler)===null||e===void 0||e.call(this,{target:i,body:this.text}),this.piTarget=this.text="",this.state=Nt}else r===kt?this.text+="?":(this.text+=`?${String.fromCodePoint(r)}`,this.state=lr);this.xmlDeclPossible=!1}sXMLDeclNameStart(){let e=this.skipSpaces();if(e===kt){this.state=Kt;return}e!==Ct&&(this.state=oa,this.name=String.fromCodePoint(e))}sXMLDeclName(){let e=this.captureTo(_a);if(e===kt){this.state=Kt,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(Lt(e)||e===he){if(this.name+=this.text,this.text="",!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail("did not expect any more name/value pairs.");break;case 1:this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`)}this.state=e===he?Ai:ha}}sXMLDeclEq(){let e=this.getCodeNorm();if(e===kt){this.state=Kt,this.fail("XML declaration is incomplete.");return}Lt(e)||(e!==he&&this.fail("value required."),this.state=Ai)}sXMLDeclValueStart(){let e=this.getCodeNorm();if(e===kt){this.state=Kt,this.fail("XML declaration is incomplete.");return}Lt(e)||(Xe(e)?this.q=e:(this.fail("value must be quoted."),this.q=Ri),this.state=la)}sXMLDeclValue(){let e=this.captureTo([this.q,kt]);if(e===kt){this.state=Kt,this.text="",this.fail("XML declaration is incomplete.");return}if(e===Ct)return;let r=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let i=r;this.xmlDecl.version=i,/^1\.[0-9]+$/.test(i)?this.opt.forceXMLVersion||this.setXMLVersion(i):this.fail("version number must match /^1\\.[0-9]+$/.");break}case"encoding":/^[A-Za-z][A-Za-z0-9._-]*$/.test(r)||this.fail("encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/."),this.xmlDeclExpects=["standalone"],this.xmlDecl.encoding=r;break;case"standalone":r!=="yes"&&r!=="no"&&this.fail('standalone value must match "yes" or "no".'),this.xmlDeclExpects=[],this.xmlDecl.standalone=r;break;default:}this.name="",this.state=fa}sXMLDeclSeparator(){let e=this.getCodeNorm();if(e===kt){this.state=Kt;return}Lt(e)||(this.fail("whitespace required."),this.unget()),this.state=yi}sXMLDeclEnding(){var e;this.getCodeNorm()===Tt?(this.piTarget!=="xml"?this.fail("processing instructions are not allowed before root."):this.name!=="version"&&this.xmlDeclExpects.includes("version")&&this.fail("XML declaration must contain a version."),(e=this.xmldeclHandler)===null||e===void 0||e.call(this,this.xmlDecl),this.name="",this.piTarget=this.text="",this.state=Nt):this.fail("The character ? is disallowed anywhere in XML declarations."),this.xmlDeclPossible=!1}sOpenTag(){var e;let r=this.captureNameChars();if(r===Ct)return;let i=this.tag={name:this.name,attributes:Object.create(null)};switch(this.name="",this.xmlnsOpt&&(this.topNS=i.ns=Object.create(null)),(e=this.openTagStartHandler)===null||e===void 0||e.call(this,i),this.sawRoot=!0,!this.fragmentOpt&&this.closedRoot&&this.fail("documents may contain only one root."),r){case Tt:this.openTag();break;case He:this.state=fr;break;default:Lt(r)||this.fail("disallowed character in tag name."),this.state=ke}}sOpenTagSlash(){this.getCode()===Tt?this.openSelfClosingTag():(this.fail("forward-slash in opening tag not followed by >."),this.state=ke)}sAttrib(){let e=this.skipSpaces();e!==Ct&&(De(e)?(this.unget(),this.state=ur):e===Tt?this.openTag():e===He?this.state=fr:this.fail("disallowed character in attribute name."))}sAttribName(){let e=this.captureNameChars();e===he?this.state=Fi:Lt(e)?this.state=ca:e===Tt?(this.fail("attribute without value."),this.pushAttrib(this.name,this.name),this.name=this.text="",this.openTag()):e!==Ct&&this.fail("disallowed character in attribute name.")}sAttribNameSawWhite(){let e=this.skipSpaces();switch(e){case Ct:return;case he:this.state=Fi;break;default:this.fail("attribute without value."),this.text="",this.name="",e===Tt?this.openTag():De(e)?(this.unget(),this.state=ur):(this.fail("disallowed character in attribute name."),this.state=ke)}}sAttribValue(){let e=this.getCodeNorm();Xe(e)?(this.q=e,this.state=Di):Lt(e)||(this.fail("unquoted attribute value."),this.state=ki,this.unget())}sAttribValueQuoted(){let{q:e,chunk:r}=this,{i}=this;for(;;)switch(this.getCode()){case e:this.pushAttrib(this.name,this.text+r.slice(i,this.prevI)),this.name=this.text="",this.q=null,this.state=da;return;case Re:this.text+=r.slice(i,this.prevI),this.state=Pe,this.entityReturnState=Di;return;case $t:case zt:case cr:this.text+=`${r.slice(i,this.prevI)} `,i=this.i;break;case Vt:this.text+=r.slice(i,this.prevI),this.fail("disallowed character.");return;case Ct:this.text+=r.slice(i);return;default:}}sAttribValueClosed(){let e=this.getCodeNorm();Lt(e)?this.state=ke:e===Tt?this.openTag():e===He?this.state=fr:De(e)?(this.fail("no whitespace between attributes."),this.unget(),this.state=ur):this.fail("disallowed character in attribute name.")}sAttribValueUnquoted(){let e=this.captureTo(wa);switch(e){case Re:this.state=Pe,this.entityReturnState=ki;break;case Vt:this.fail("disallowed character.");break;case Ct:break;default:this.text.includes("]]>")&&this.fail('the string "]]>" is disallowed in char data.'),this.pushAttrib(this.name,this.text),this.name=this.text="",e===Tt?this.openTag():this.state=ke}}sCloseTag(){let e=this.captureNameChars();e===Tt?this.closeTag():Lt(e)?this.state=xa:e!==Ct&&this.fail("disallowed character in closing tag.")}sCloseTagSawWhite(){switch(this.skipSpaces()){case Tt:this.closeTag();break;case Ct:break;default:this.fail("disallowed character in closing tag.")}}handleTextInRoot(){let{i:e,forbiddenState:r}=this,{chunk:i,textHandler:n}=this;t:for(;;)switch(this.getCode()){case Vt:{if(this.state=ar,n!==void 0){let{text:s}=this,a=i.slice(e,this.prevI);s.length!==0?(n(s+a),this.text=""):a.length!==0&&n(a)}r=Jt;break t}case Re:this.state=Pe,this.entityReturnState=Nt,n!==void 0&&(this.text+=i.slice(e,this.prevI)),r=Jt;break t;case le:switch(r){case Jt:r=Ii;break;case Ii:r=pr;break;case pr:break;default:throw new Error("impossible state")}break;case Tt:r===pr&&this.fail('the string "]]>" is disallowed in char data.'),r=Jt;break;case zt:n!==void 0&&(this.text+=`${i.slice(e,this.prevI)}
|
|
9
|
+
`),e=this.i,r=Jt;break;case Ct:n!==void 0&&(this.text+=i.slice(e));break t;default:r=Jt}this.forbiddenState=r}handleTextOutsideRoot(){let{i:e}=this,{chunk:r,textHandler:i}=this,n=!1;t:for(;;){let s=this.getCode();switch(s){case Vt:{if(this.state=ar,i!==void 0){let{text:a}=this,o=r.slice(e,this.prevI);a.length!==0?(i(a+o),this.text=""):o.length!==0&&i(o)}break t}case Re:this.state=Pe,this.entityReturnState=Nt,i!==void 0&&(this.text+=r.slice(e,this.prevI)),n=!0;break t;case zt:i!==void 0&&(this.text+=`${r.slice(e,this.prevI)}
|
|
10
|
+
`),e=this.i;break;case Ct:i!==void 0&&(this.text+=r.slice(e));break t;default:Lt(s)||(n=!0)}}n&&(!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0))}pushAttribNS(e,r){var i;let{prefix:n,local:s}=this.qname(e),a={name:e,prefix:n,local:s,value:r};if(this.attribList.push(a),(i=this.attributeHandler)===null||i===void 0||i.call(this,a),n==="xmlns"){let o=r.trim();this.currentXMLVersion==="1.0"&&o===""&&this.fail("invalid attempt to undefine prefix in XML 1.0"),this.topNS[s]=o,xr(this,s,o)}else if(e==="xmlns"){let o=r.trim();this.topNS[""]=o,xr(this,"",o)}}pushAttribPlain(e,r){var i;let n={name:e,value:r};this.attribList.push(n),(i=this.attributeHandler)===null||i===void 0||i.call(this,n)}end(){var e,r;this.sawRoot||this.fail("document must contain a root element.");let{tags:i}=this;for(;i.length>0;){let s=i.pop();this.fail(`unclosed tag: ${s.name}`)}this.state!==bi&&this.state!==Nt&&this.fail("unexpected end.");let{text:n}=this;return n.length!==0&&((e=this.textHandler)===null||e===void 0||e.call(this,n),this.text=""),this._closed=!0,(r=this.endHandler)===null||r===void 0||r.call(this),this._init(),this}resolve(e){var r,i;let n=this.topNS[e];if(n!==void 0)return n;let{tags:s}=this;for(let a=s.length-1;a>=0;a--)if(n=s[a].ns[e],n!==void 0)return n;return n=this.ns[e],n!==void 0?n:(i=(r=this.opt).resolvePrefix)===null||i===void 0?void 0:i.call(r,e)}qname(e){let r=e.indexOf(":");if(r===-1)return{prefix:"",local:e};let i=e.slice(r+1),n=e.slice(0,r);return(n===""||i===""||i.includes(":"))&&this.fail(`malformed name: ${e}.`),{prefix:n,local:i}}processAttribsNS(){var e;let{attribList:r}=this,i=this.tag;{let{prefix:a,local:o}=this.qname(i.name);i.prefix=a,i.local=o;let h=i.uri=(e=this.resolve(a))!==null&&e!==void 0?e:"";a!==""&&(a==="xmlns"&&this.fail('tags may not have "xmlns" as prefix.'),h===""&&(this.fail(`unbound namespace prefix: ${JSON.stringify(a)}.`),i.uri=a))}if(r.length===0)return;let{attributes:n}=i,s=new Set;for(let a of r){let{name:o,prefix:h,local:l}=a,p,f;h===""?(p=o==="xmlns"?fe:"",f=o):(p=this.resolve(h),p===void 0&&(this.fail(`unbound namespace prefix: ${JSON.stringify(h)}.`),p=h),f=`{${p}}${l}`),s.has(f)&&this.fail(`duplicate attribute: ${f}.`),s.add(f),a.uri=p,n[o]=a}this.attribList=[]}processAttribsPlain(){let{attribList:e}=this,r=this.tag.attributes;for(let{name:i,value:n}of e)r[i]!==void 0&&this.fail(`duplicate attribute: ${i}.`),r[i]=n;this.attribList=[]}openTag(){var e;this.processAttribs();let{tags:r}=this,i=this.tag;i.isSelfClosing=!1,(e=this.openTagHandler)===null||e===void 0||e.call(this,i),r.push(i),this.state=Nt,this.name=""}openSelfClosingTag(){var e,r,i;this.processAttribs();let{tags:n}=this,s=this.tag;s.isSelfClosing=!0,(e=this.openTagHandler)===null||e===void 0||e.call(this,s),(r=this.closeTagHandler)===null||r===void 0||r.call(this,s),(this.tag=(i=n[n.length-1])!==null&&i!==void 0?i:null)===null&&(this.closedRoot=!0),this.state=Nt,this.name=""}closeTag(){let{tags:e,name:r}=this;if(this.state=Nt,this.name="",r===""){this.fail("weird empty close tag."),this.text+="</>";return}let i=this.closeTagHandler,n=e.length;for(;n-- >0;){let s=this.tag=e.pop();if(this.topNS=s.ns,i?.(s),s.name===r)break;this.fail("unexpected close tag.")}n===0?this.closedRoot=!0:n<0&&(this.fail(`unmatched closing tag: ${r}.`),this.text+=`</${r}>`)}parseEntity(e){if(e[0]!=="#"){let i=this.ENTITIES[e];return i!==void 0?i:(this.fail(this.isName(e)?"undefined entity.":"disallowed character in entity name."),`&${e};`)}let r=NaN;return e[1]==="x"&&/^#x[0-9a-f]+$/i.test(e)?r=parseInt(e.slice(2),16):/^#[0-9]+$/.test(e)&&(r=parseInt(e.slice(1),10)),this.isChar(r)?String.fromCodePoint(r):(this.fail("malformed character entity."),`&${e};`)}};ue.SaxesParser=gr});var wr=pt((mh,Ki)=>{"use strict";var La=Rt("util"),Qi=Rt("stream"),Yt=Ki.exports=function(){Qi.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};La.inherits(Yt,Qi);Yt.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e}),process.nextTick(function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit("drain"))}.bind(this))};Yt.prototype.write=function(t,e){if(!this.writable)return this.emit("error",new Error("Stream not writable")),!1;let r;return Buffer.isBuffer(t)?r=t:r=Buffer.from(t,e||this._encoding),this._buffers.push(r),this._buffered+=r.length,this._process(),this._reads&&this._reads.length===0&&(this._paused=!0),this.writable&&!this._paused};Yt.prototype.end=function(t,e){t&&this.write(t,e),this.writable=!1,this._buffers&&(this._buffers.length===0?this._end():(this._buffers.push(null),this._process()))};Yt.prototype.destroySoon=Yt.prototype.end;Yt.prototype._end=function(){this._reads.length>0&&this.emit("error",new Error("Unexpected end of input")),this.destroy()};Yt.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))};Yt.prototype._processReadAllowingLess=function(t){this._reads.shift();let e=this._buffers[0];e.length>t.length?(this._buffered-=t.length,this._buffers[0]=e.slice(t.length),t.func.call(this,e.slice(0,t.length))):(this._buffered-=e.length,this._buffers.shift(),t.func.call(this,e))};Yt.prototype._processRead=function(t){this._reads.shift();let e=0,r=0,i=Buffer.alloc(t.length);for(;e<t.length;){let n=this._buffers[r++],s=Math.min(n.length,t.length-e);n.copy(i,e,0,s),e+=s,s!==n.length&&(this._buffers[--r]=n.slice(s))}r>0&&this._buffers.splice(0,r),this._buffered-=t.length,t.func.call(this,i)};Yt.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let t=this._reads[0];if(t.allowLess)this._processReadAllowingLess(t);else if(this._buffered>=t.length)this._processRead(t);else break}this._buffers&&!this.writable&&this._end()}catch(t){this.emit("error",t)}}});var Cr=pt(Er=>{"use strict";var jt=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];Er.getImagePasses=function(t,e){let r=[],i=t%8,n=e%8,s=(t-i)/8,a=(e-n)/8;for(let o=0;o<jt.length;o++){let h=jt[o],l=s*h.x.length,p=a*h.y.length;for(let f=0;f<h.x.length&&h.x[f]<i;f++)l++;for(let f=0;f<h.y.length&&h.y[f]<n;f++)p++;l>0&&p>0&&r.push({width:l,height:p,index:o})}return r};Er.getInterlaceIterator=function(t){return function(e,r,i){let n=e%jt[i].x.length,s=(e-n)/jt[i].x.length*8+jt[i].x[n],a=r%jt[i].y.length,o=(r-a)/jt[i].y.length*8+jt[i].y[a];return s*4+o*t*4}}});var br=pt((_h,Ji)=>{"use strict";Ji.exports=function(e,r,i){let n=e+r-i,s=Math.abs(n-e),a=Math.abs(n-r),o=Math.abs(n-i);return s<=a&&s<=o?e:a<=o?r:i}});var Tr=pt((wh,en)=>{"use strict";var Pa=Cr(),Ba=br();function tn(t,e,r){let i=t*e;return r!==8&&(i=Math.ceil(i/(8/r))),i}var pe=en.exports=function(t,e){let r=t.width,i=t.height,n=t.interlace,s=t.bpp,a=t.depth;if(this.read=e.read,this.write=e.write,this.complete=e.complete,this._imageIndex=0,this._images=[],n){let o=Pa.getImagePasses(r,i);for(let h=0;h<o.length;h++)this._images.push({byteWidth:tn(o[h].width,s,a),height:o[h].height,lineIndex:0})}else this._images.push({byteWidth:tn(r,s,a),height:i,lineIndex:0});a===8?this._xComparison=s:a===16?this._xComparison=s*2:this._xComparison=1};pe.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))};pe.prototype._unFilterType1=function(t,e,r){let i=this._xComparison,n=i-1;for(let s=0;s<r;s++){let a=t[1+s],o=s>n?e[s-i]:0;e[s]=a+o}};pe.prototype._unFilterType2=function(t,e,r){let i=this._lastLine;for(let n=0;n<r;n++){let s=t[1+n],a=i?i[n]:0;e[n]=s+a}};pe.prototype._unFilterType3=function(t,e,r){let i=this._xComparison,n=i-1,s=this._lastLine;for(let a=0;a<r;a++){let o=t[1+a],h=s?s[a]:0,l=a>n?e[a-i]:0,p=Math.floor((l+h)/2);e[a]=o+p}};pe.prototype._unFilterType4=function(t,e,r){let i=this._xComparison,n=i-1,s=this._lastLine;for(let a=0;a<r;a++){let o=t[1+a],h=s?s[a]:0,l=a>n?e[a-i]:0,p=a>n&&s?s[a-i]:0,f=Ba(l,h,p);e[a]=o+f}};pe.prototype._reverseFilterLine=function(t){let e=t[0],r,i=this._images[this._imageIndex],n=i.byteWidth;if(e===0)r=t.slice(1,n+1);else switch(r=Buffer.alloc(n),e){case 1:this._unFilterType1(t,r,n);break;case 2:this._unFilterType2(t,r,n);break;case 3:this._unFilterType3(t,r,n);break;case 4:this._unFilterType4(t,r,n);break;default:throw new Error("Unrecognised filter type - "+e)}this.write(r),i.lineIndex++,i.lineIndex>=i.height?(this._lastLine=null,this._imageIndex++,i=this._images[this._imageIndex]):this._lastLine=r,i?this.read(i.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}});var sn=pt((Eh,nn)=>{"use strict";var Ua=Rt("util"),rn=wr(),Ha=Tr(),Xa=nn.exports=function(t){rn.call(this);let e=[],r=this;this._filter=new Ha(t,{read:this.read.bind(this),write:function(i){e.push(i)},complete:function(){r.emit("complete",Buffer.concat(e))}}),this._filter.start()};Ua.inherits(Xa,rn)});var xe=pt((Ch,an)=>{"use strict";an.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}});var Fr=pt((bh,on)=>{"use strict";var yr=[];(function(){for(let t=0;t<256;t++){let e=t;for(let r=0;r<8;r++)e&1?e=3988292384^e>>>1:e=e>>>1;yr[t]=e}})();var Ar=on.exports=function(){this._crc=-1};Ar.prototype.write=function(t){for(let e=0;e<t.length;e++)this._crc=yr[(this._crc^t[e])&255]^this._crc>>>8;return!0};Ar.prototype.crc32=function(){return this._crc^-1};Ar.crc32=function(t){let e=-1;for(let r=0;r<t.length;r++)e=yr[(e^t[r])&255]^e>>>8;return e^-1}});var Dr=pt((Th,hn)=>{"use strict";var yt=xe(),$a=Fr(),Ft=hn.exports=function(t,e){this._options=t,t.checkCRC=t.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[yt.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[yt.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[yt.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[yt.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[yt.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[yt.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=e.read,this.error=e.error,this.metadata=e.metadata,this.gamma=e.gamma,this.transColor=e.transColor,this.palette=e.palette,this.parsed=e.parsed,this.inflateData=e.inflateData,this.finished=e.finished,this.simpleTransparency=e.simpleTransparency,this.headersFinished=e.headersFinished||function(){}};Ft.prototype.start=function(){this.read(yt.PNG_SIGNATURE.length,this._parseSignature.bind(this))};Ft.prototype._parseSignature=function(t){let e=yt.PNG_SIGNATURE;for(let r=0;r<e.length;r++)if(t[r]!==e[r]){this.error(new Error("Invalid file signature"));return}this.read(8,this._parseChunkBegin.bind(this))};Ft.prototype._parseChunkBegin=function(t){let e=t.readUInt32BE(0),r=t.readUInt32BE(4),i="";for(let s=4;s<8;s++)i+=String.fromCharCode(t[s]);let n=!!(t[4]&32);if(!this._hasIHDR&&r!==yt.TYPE_IHDR){this.error(new Error("Expected IHDR on beggining"));return}if(this._crc=new $a,this._crc.write(Buffer.from(i)),this._chunks[r])return this._chunks[r](e);if(!n){this.error(new Error("Unsupported critical chunk type "+i));return}this.read(e+4,this._skipChunk.bind(this))};Ft.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))};Ft.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))};Ft.prototype._parseChunkEnd=function(t){let e=t.readInt32BE(0),r=this._crc.crc32();if(this._options.checkCRC&&r!==e){this.error(new Error("Crc error - "+e+" - "+r));return}this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))};Ft.prototype._handleIHDR=function(t){this.read(t,this._parseIHDR.bind(this))};Ft.prototype._parseIHDR=function(t){this._crc.write(t);let e=t.readUInt32BE(0),r=t.readUInt32BE(4),i=t[8],n=t[9],s=t[10],a=t[11],o=t[12];if(i!==8&&i!==4&&i!==2&&i!==1&&i!==16){this.error(new Error("Unsupported bit depth "+i));return}if(!(n in yt.COLORTYPE_TO_BPP_MAP)){this.error(new Error("Unsupported color type"));return}if(s!==0){this.error(new Error("Unsupported compression method"));return}if(a!==0){this.error(new Error("Unsupported filter method"));return}if(o!==0&&o!==1){this.error(new Error("Unsupported interlace method"));return}this._colorType=n;let h=yt.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:e,height:r,depth:i,interlace:!!o,palette:!!(n&yt.COLORTYPE_PALETTE),color:!!(n&yt.COLORTYPE_COLOR),alpha:!!(n&yt.COLORTYPE_ALPHA),bpp:h,colorType:n}),this._handleChunkEnd()};Ft.prototype._handlePLTE=function(t){this.read(t,this._parsePLTE.bind(this))};Ft.prototype._parsePLTE=function(t){this._crc.write(t);let e=Math.floor(t.length/3);for(let r=0;r<e;r++)this._palette.push([t[r*3],t[r*3+1],t[r*3+2],255]);this.palette(this._palette),this._handleChunkEnd()};Ft.prototype._handleTRNS=function(t){this.simpleTransparency(),this.read(t,this._parseTRNS.bind(this))};Ft.prototype._parseTRNS=function(t){if(this._crc.write(t),this._colorType===yt.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(new Error("Transparency chunk must be after palette"));return}if(t.length>this._palette.length){this.error(new Error("More transparent colors than palette size"));return}for(let e=0;e<t.length;e++)this._palette[e][3]=t[e];this.palette(this._palette)}this._colorType===yt.COLORTYPE_GRAYSCALE&&this.transColor([t.readUInt16BE(0)]),this._colorType===yt.COLORTYPE_COLOR&&this.transColor([t.readUInt16BE(0),t.readUInt16BE(2),t.readUInt16BE(4)]),this._handleChunkEnd()};Ft.prototype._handleGAMA=function(t){this.read(t,this._parseGAMA.bind(this))};Ft.prototype._parseGAMA=function(t){this._crc.write(t),this.gamma(t.readUInt32BE(0)/yt.GAMMA_DIVISION),this._handleChunkEnd()};Ft.prototype._handleIDAT=function(t){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-t,this._parseIDAT.bind(this,t))};Ft.prototype._parseIDAT=function(t,e){if(this._crc.write(e),this._colorType===yt.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw new Error("Expected palette not found");this.inflateData(e);let r=t-e.length;r>0?this._handleIDAT(r):this._handleChunkEnd()};Ft.prototype._handleIEND=function(t){this.read(t,this._parseIEND.bind(this))};Ft.prototype._parseIEND=function(t){this._crc.write(t),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}});var kr=pt(fn=>{"use strict";var ln=Cr(),Ya=[function(){},function(t,e,r,i){if(i===e.length)throw new Error("Ran out of data");let n=e[i];t[r]=n,t[r+1]=n,t[r+2]=n,t[r+3]=255},function(t,e,r,i){if(i+1>=e.length)throw new Error("Ran out of data");let n=e[i];t[r]=n,t[r+1]=n,t[r+2]=n,t[r+3]=e[i+1]},function(t,e,r,i){if(i+2>=e.length)throw new Error("Ran out of data");t[r]=e[i],t[r+1]=e[i+1],t[r+2]=e[i+2],t[r+3]=255},function(t,e,r,i){if(i+3>=e.length)throw new Error("Ran out of data");t[r]=e[i],t[r+1]=e[i+1],t[r+2]=e[i+2],t[r+3]=e[i+3]}],qa=[function(){},function(t,e,r,i){let n=e[0];t[r]=n,t[r+1]=n,t[r+2]=n,t[r+3]=i},function(t,e,r){let i=e[0];t[r]=i,t[r+1]=i,t[r+2]=i,t[r+3]=e[1]},function(t,e,r,i){t[r]=e[0],t[r+1]=e[1],t[r+2]=e[2],t[r+3]=i},function(t,e,r){t[r]=e[0],t[r+1]=e[1],t[r+2]=e[2],t[r+3]=e[3]}];function za(t,e){let r=[],i=0;function n(){if(i===t.length)throw new Error("Ran out of data");let s=t[i];i++;let a,o,h,l,p,f,d,C;switch(e){default:throw new Error("unrecognised depth");case 16:d=t[i],i++,r.push((s<<8)+d);break;case 4:d=s&15,C=s>>4,r.push(C,d);break;case 2:p=s&3,f=s>>2&3,d=s>>4&3,C=s>>6&3,r.push(C,d,f,p);break;case 1:a=s&1,o=s>>1&1,h=s>>2&1,l=s>>3&1,p=s>>4&1,f=s>>5&1,d=s>>6&1,C=s>>7&1,r.push(C,d,f,p,l,h,o,a);break}}return{get:function(s){for(;r.length<s;)n();let a=r.slice(0,s);return r=r.slice(s),a},resetAfterLine:function(){r.length=0},end:function(){if(i!==t.length)throw new Error("extra data found")}}}function Ga(t,e,r,i,n,s){let a=t.width,o=t.height,h=t.index;for(let l=0;l<o;l++)for(let p=0;p<a;p++){let f=r(p,l,h);Ya[i](e,n,f,s),s+=i}return s}function Wa(t,e,r,i,n,s){let a=t.width,o=t.height,h=t.index;for(let l=0;l<o;l++){for(let p=0;p<a;p++){let f=n.get(i),d=r(p,l,h);qa[i](e,f,d,s)}n.resetAfterLine()}}fn.dataToBitMap=function(t,e){let r=e.width,i=e.height,n=e.depth,s=e.bpp,a=e.interlace,o;n!==8&&(o=za(t,n));let h;n<=8?h=Buffer.alloc(r*i*4):h=new Uint16Array(r*i*4);let l=Math.pow(2,n)-1,p=0,f,d;if(a)f=ln.getImagePasses(r,i),d=ln.getInterlaceIterator(r,i);else{let C=0;d=function(){let m=C;return C+=4,m},f=[{width:r,height:i}]}for(let C=0;C<f.length;C++)n===8?p=Ga(f[C],h,d,s,t,p):Wa(f[C],h,d,s,o,l);if(n===8){if(p!==t.length)throw new Error("extra data found")}else o.end();return h}});var Rr=pt((Ah,un)=>{"use strict";function Va(t,e,r,i,n){let s=0;for(let a=0;a<i;a++)for(let o=0;o<r;o++){let h=n[t[s]];if(!h)throw new Error("index "+t[s]+" not in palette");for(let l=0;l<4;l++)e[s+l]=h[l];s+=4}}function ja(t,e,r,i,n){let s=0;for(let a=0;a<i;a++)for(let o=0;o<r;o++){let h=!1;if(n.length===1?n[0]===t[s]&&(h=!0):n[0]===t[s]&&n[1]===t[s+1]&&n[2]===t[s+2]&&(h=!0),h)for(let l=0;l<4;l++)e[s+l]=0;s+=4}}function Za(t,e,r,i,n){let s=255,a=Math.pow(2,n)-1,o=0;for(let h=0;h<i;h++)for(let l=0;l<r;l++){for(let p=0;p<4;p++)e[o+p]=Math.floor(t[o+p]*s/a+.5);o+=4}}un.exports=function(t,e,r=!1){let i=e.depth,n=e.width,s=e.height,a=e.colorType,o=e.transColor,h=e.palette,l=t;return a===3?Va(t,l,n,s,h):(o&&ja(t,l,n,s,o),i!==8&&!r&&(i===16&&(l=Buffer.alloc(n*s*4)),Za(t,l,n,s,i))),l}});var pn=pt((Fh,dn)=>{"use strict";var Qa=Rt("util"),Sr=Rt("zlib"),cn=wr(),Ka=sn(),Ja=Dr(),to=kr(),eo=Rr(),Gt=dn.exports=function(t){cn.call(this),this._parser=new Ja(t,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=t,this.writable=!0,this._parser.start()};Qa.inherits(Gt,cn);Gt.prototype._handleError=function(t){this.emit("error",t),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on("error",function(){})),this.errord=!0};Gt.prototype._inflateData=function(t){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=Sr.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let r=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,i=Math.max(r,Sr.Z_MIN_CHUNK);this._inflate=Sr.createInflate({chunkSize:i});let n=r,s=this.emit.bind(this,"error");this._inflate.on("error",function(o){n&&s(o)}),this._filter.on("complete",this._complete.bind(this));let a=this._filter.write.bind(this._filter);this._inflate.on("data",function(o){n&&(o.length>n&&(o=o.slice(0,n)),n-=o.length,a(o))}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(t)};Gt.prototype._handleMetaData=function(t){this._metaData=t,this._bitmapInfo=Object.create(t),this._filter=new Ka(this._bitmapInfo)};Gt.prototype._handleTransColor=function(t){this._bitmapInfo.transColor=t};Gt.prototype._handlePalette=function(t){this._bitmapInfo.palette=t};Gt.prototype._simpleTransparency=function(){this._metaData.alpha=!0};Gt.prototype._headersFinished=function(){this.emit("metadata",this._metaData)};Gt.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit("error","No Inflate block"))};Gt.prototype._complete=function(t){if(this.errord)return;let e;try{let r=to.dataToBitMap(t,this._bitmapInfo);e=eo(r,this._bitmapInfo,this._options.skipRescale),r=null}catch(r){this._handleError(r);return}this.emit("parsed",e)}});var gn=pt((Dh,xn)=>{"use strict";var Ut=xe();xn.exports=function(t,e,r,i){let n=[Ut.COLORTYPE_COLOR_ALPHA,Ut.COLORTYPE_ALPHA].indexOf(i.colorType)!==-1;if(i.colorType===i.inputColorType){let m=(function(){let F=new ArrayBuffer(2);return new DataView(F).setInt16(0,256,!0),new Int16Array(F)[0]!==256})();if(i.bitDepth===8||i.bitDepth===16&&m)return t}let s=i.bitDepth!==16?t:new Uint16Array(t.buffer),a=255,o=Ut.COLORTYPE_TO_BPP_MAP[i.inputColorType];o===4&&!i.inputHasAlpha&&(o=3);let h=Ut.COLORTYPE_TO_BPP_MAP[i.colorType];i.bitDepth===16&&(a=65535,h*=2);let l=Buffer.alloc(e*r*h),p=0,f=0,d=i.bgColor||{};d.red===void 0&&(d.red=a),d.green===void 0&&(d.green=a),d.blue===void 0&&(d.blue=a);function C(){let m,F,w,T=a;switch(i.inputColorType){case Ut.COLORTYPE_COLOR_ALPHA:T=s[p+3],m=s[p],F=s[p+1],w=s[p+2];break;case Ut.COLORTYPE_COLOR:m=s[p],F=s[p+1],w=s[p+2];break;case Ut.COLORTYPE_ALPHA:T=s[p+1],m=s[p],F=m,w=m;break;case Ut.COLORTYPE_GRAYSCALE:m=s[p],F=m,w=m;break;default:throw new Error("input color type:"+i.inputColorType+" is not supported at present")}return i.inputHasAlpha&&(n||(T/=a,m=Math.min(Math.max(Math.round((1-T)*d.red+T*m),0),a),F=Math.min(Math.max(Math.round((1-T)*d.green+T*F),0),a),w=Math.min(Math.max(Math.round((1-T)*d.blue+T*w),0),a))),{red:m,green:F,blue:w,alpha:T}}for(let m=0;m<r;m++)for(let F=0;F<e;F++){let w=C(s,p);switch(i.colorType){case Ut.COLORTYPE_COLOR_ALPHA:case Ut.COLORTYPE_COLOR:i.bitDepth===8?(l[f]=w.red,l[f+1]=w.green,l[f+2]=w.blue,n&&(l[f+3]=w.alpha)):(l.writeUInt16BE(w.red,f),l.writeUInt16BE(w.green,f+2),l.writeUInt16BE(w.blue,f+4),n&&l.writeUInt16BE(w.alpha,f+6));break;case Ut.COLORTYPE_ALPHA:case Ut.COLORTYPE_GRAYSCALE:{let T=(w.red+w.green+w.blue)/3;i.bitDepth===8?(l[f]=T,n&&(l[f+1]=w.alpha)):(l.writeUInt16BE(T,f),n&&l.writeUInt16BE(w.alpha,f+2));break}default:throw new Error("unrecognised color Type "+i.colorType)}p+=o,f+=h}return l}});var _n=pt((kh,vn)=>{"use strict";var mn=br();function ro(t,e,r,i,n){for(let s=0;s<r;s++)i[n+s]=t[e+s]}function io(t,e,r){let i=0,n=e+r;for(let s=e;s<n;s++)i+=Math.abs(t[s]);return i}function no(t,e,r,i,n,s){for(let a=0;a<r;a++){let o=a>=s?t[e+a-s]:0,h=t[e+a]-o;i[n+a]=h}}function so(t,e,r,i){let n=0;for(let s=0;s<r;s++){let a=s>=i?t[e+s-i]:0,o=t[e+s]-a;n+=Math.abs(o)}return n}function ao(t,e,r,i,n){for(let s=0;s<r;s++){let a=e>0?t[e+s-r]:0,o=t[e+s]-a;i[n+s]=o}}function oo(t,e,r){let i=0,n=e+r;for(let s=e;s<n;s++){let a=e>0?t[s-r]:0,o=t[s]-a;i+=Math.abs(o)}return i}function ho(t,e,r,i,n,s){for(let a=0;a<r;a++){let o=a>=s?t[e+a-s]:0,h=e>0?t[e+a-r]:0,l=t[e+a]-(o+h>>1);i[n+a]=l}}function lo(t,e,r,i){let n=0;for(let s=0;s<r;s++){let a=s>=i?t[e+s-i]:0,o=e>0?t[e+s-r]:0,h=t[e+s]-(a+o>>1);n+=Math.abs(h)}return n}function fo(t,e,r,i,n,s){for(let a=0;a<r;a++){let o=a>=s?t[e+a-s]:0,h=e>0?t[e+a-r]:0,l=e>0&&a>=s?t[e+a-(r+s)]:0,p=t[e+a]-mn(o,h,l);i[n+a]=p}}function uo(t,e,r,i){let n=0;for(let s=0;s<r;s++){let a=s>=i?t[e+s-i]:0,o=e>0?t[e+s-r]:0,h=e>0&&s>=i?t[e+s-(r+i)]:0,l=t[e+s]-mn(a,o,h);n+=Math.abs(l)}return n}var co={0:ro,1:no,2:ao,3:ho,4:fo},po={0:io,1:so,2:oo,3:lo,4:uo};vn.exports=function(t,e,r,i,n){let s;if(!("filterType"in i)||i.filterType===-1)s=[0,1,2,3,4];else if(typeof i.filterType=="number")s=[i.filterType];else throw new Error("unrecognised filter types");i.bitDepth===16&&(n*=2);let a=e*n,o=0,h=0,l=Buffer.alloc((a+1)*r),p=s[0];for(let f=0;f<r;f++){if(s.length>1){let d=1/0;for(let C=0;C<s.length;C++){let m=po[s[C]](t,h,a,n);m<d&&(p=s[C],d=m)}}l[o]=p,o++,co[p](t,h,a,l,o,n),o+=a,h+=a}return l}});var Or=pt((Rh,wn)=>{"use strict";var Ot=xe(),xo=Fr(),go=gn(),mo=_n(),vo=Rt("zlib"),Zt=wn.exports=function(t){if(this._options=t,t.deflateChunkSize=t.deflateChunkSize||32*1024,t.deflateLevel=t.deflateLevel!=null?t.deflateLevel:9,t.deflateStrategy=t.deflateStrategy!=null?t.deflateStrategy:3,t.inputHasAlpha=t.inputHasAlpha!=null?t.inputHasAlpha:!0,t.deflateFactory=t.deflateFactory||vo.createDeflate,t.bitDepth=t.bitDepth||8,t.colorType=typeof t.colorType=="number"?t.colorType:Ot.COLORTYPE_COLOR_ALPHA,t.inputColorType=typeof t.inputColorType=="number"?t.inputColorType:Ot.COLORTYPE_COLOR_ALPHA,[Ot.COLORTYPE_GRAYSCALE,Ot.COLORTYPE_COLOR,Ot.COLORTYPE_COLOR_ALPHA,Ot.COLORTYPE_ALPHA].indexOf(t.colorType)===-1)throw new Error("option color type:"+t.colorType+" is not supported at present");if([Ot.COLORTYPE_GRAYSCALE,Ot.COLORTYPE_COLOR,Ot.COLORTYPE_COLOR_ALPHA,Ot.COLORTYPE_ALPHA].indexOf(t.inputColorType)===-1)throw new Error("option input color type:"+t.inputColorType+" is not supported at present");if(t.bitDepth!==8&&t.bitDepth!==16)throw new Error("option bit depth:"+t.bitDepth+" is not supported at present")};Zt.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}};Zt.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())};Zt.prototype.filterData=function(t,e,r){let i=go(t,e,r,this._options),n=Ot.COLORTYPE_TO_BPP_MAP[this._options.colorType];return mo(i,e,r,this._options,n)};Zt.prototype._packChunk=function(t,e){let r=e?e.length:0,i=Buffer.alloc(r+12);return i.writeUInt32BE(r,0),i.writeUInt32BE(t,4),e&&e.copy(i,8),i.writeInt32BE(xo.crc32(i.slice(4,i.length-4)),i.length-4),i};Zt.prototype.packGAMA=function(t){let e=Buffer.alloc(4);return e.writeUInt32BE(Math.floor(t*Ot.GAMMA_DIVISION),0),this._packChunk(Ot.TYPE_gAMA,e)};Zt.prototype.packIHDR=function(t,e){let r=Buffer.alloc(13);return r.writeUInt32BE(t,0),r.writeUInt32BE(e,4),r[8]=this._options.bitDepth,r[9]=this._options.colorType,r[10]=0,r[11]=0,r[12]=0,this._packChunk(Ot.TYPE_IHDR,r)};Zt.prototype.packIDAT=function(t){return this._packChunk(Ot.TYPE_IDAT,t)};Zt.prototype.packIEND=function(){return this._packChunk(Ot.TYPE_IEND,null)}});var Tn=pt((Sh,bn)=>{"use strict";var _o=Rt("util"),En=Rt("stream"),wo=xe(),Eo=Or(),Cn=bn.exports=function(t){En.call(this);let e=t||{};this._packer=new Eo(e),this._deflate=this._packer.createDeflate(),this.readable=!0};_o.inherits(Cn,En);Cn.prototype.pack=function(t,e,r,i){this.emit("data",Buffer.from(wo.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(e,r)),i&&this.emit("data",this._packer.packGAMA(i));let n=this._packer.filterData(t,e,r);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(s){this.emit("data",this._packer.packIDAT(s))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(n)}});var Rn=pt((Se,kn)=>{"use strict";var yn=Rt("assert").ok,ge=Rt("zlib"),Co=Rt("util"),An=Rt("buffer").kMaxLength;function te(t){if(!(this instanceof te))return new te(t);t&&t.chunkSize<ge.Z_MIN_CHUNK&&(t.chunkSize=ge.Z_MIN_CHUNK),ge.Inflate.call(this,t),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,t&&t.maxLength!=null&&(this._maxLength=t.maxLength)}function bo(t){return new te(t)}function Fn(t,e){e&&process.nextTick(e),t._handle&&(t._handle.close(),t._handle=null)}te.prototype._processChunk=function(t,e,r){if(typeof r=="function")return ge.Inflate._processChunk.call(this,t,e,r);let i=this,n=t&&t.length,s=this._chunkSize-this._offset,a=this._maxLength,o=0,h=[],l=0,p;this.on("error",function(m){p=m});function f(m,F){if(i._hadError)return;let w=s-F;if(yn(w>=0,"have should not go down"),w>0){let T=i._buffer.slice(i._offset,i._offset+w);if(i._offset+=w,T.length>a&&(T=T.slice(0,a)),h.push(T),l+=T.length,a-=T.length,a===0)return!1}return(F===0||i._offset>=i._chunkSize)&&(s=i._chunkSize,i._offset=0,i._buffer=Buffer.allocUnsafe(i._chunkSize)),F===0?(o+=n-m,n=m,!0):!1}yn(this._handle,"zlib binding closed");let d;do d=this._handle.writeSync(e,t,o,n,this._buffer,this._offset,s),d=d||this._writeState;while(!this._hadError&&f(d[0],d[1]));if(this._hadError)throw p;if(l>=An)throw Fn(this),new RangeError("Cannot create final Buffer. It would be larger than 0x"+An.toString(16)+" bytes");let C=Buffer.concat(h,l);return Fn(this),C};Co.inherits(te,ge.Inflate);function To(t,e){if(typeof e=="string"&&(e=Buffer.from(e)),!(e instanceof Buffer))throw new TypeError("Not a string or buffer");let r=t._finishFlushFlag;return r==null&&(r=ge.Z_FINISH),t._processChunk(e,r)}function Dn(t,e){return To(new te(e),t)}kn.exports=Se=Dn;Se.Inflate=te;Se.createInflate=bo;Se.inflateSync=Dn});var Nr=pt((Oh,On)=>{"use strict";var Sn=On.exports=function(t){this._buffer=t,this._reads=[]};Sn.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e})};Sn.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let t=this._reads[0];if(this._buffer.length&&(this._buffer.length>=t.length||t.allowLess)){this._reads.shift();let e=this._buffer;this._buffer=e.slice(t.length),t.func.call(this,e.slice(0,t.length))}else break}if(this._reads.length>0)throw new Error("There are some read requests waitng on finished stream");if(this._buffer.length>0)throw new Error("unrecognised content at end of stream")}});var In=pt(Nn=>{"use strict";var yo=Nr(),Ao=Tr();Nn.process=function(t,e){let r=[],i=new yo(t);return new Ao(e,{read:i.read.bind(i),write:function(s){r.push(s)},complete:function(){}}).start(),i.process(),Buffer.concat(r)}});var Bn=pt((Ih,Pn)=>{"use strict";var Mn=!0,Ln=Rt("zlib"),Fo=Rn();Ln.deflateSync||(Mn=!1);var Do=Nr(),ko=In(),Ro=Dr(),So=kr(),Oo=Rr();Pn.exports=function(t,e){if(!Mn)throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let r;function i(y){r=y}let n;function s(y){n=y}function a(y){n.transColor=y}function o(y){n.palette=y}function h(){n.alpha=!0}let l;function p(y){l=y}let f=[];function d(y){f.push(y)}let C=new Do(t);if(new Ro(e,{read:C.read.bind(C),error:i,metadata:s,gamma:p,palette:o,transColor:a,inflateData:d,simpleTransparency:h}).start(),C.process(),r)throw r;let F=Buffer.concat(f);f.length=0;let w;if(n.interlace)w=Ln.inflateSync(F);else{let x=((n.width*n.bpp*n.depth+7>>3)+1)*n.height;w=Fo(F,{chunkSize:x,maxLength:x})}if(F=null,!w||!w.length)throw new Error("bad png - invalid inflate data response");let T=ko.process(w,n);F=null;let S=So.dataToBitMap(T,n);T=null;let g=Oo(S,n,e.skipRescale);return n.data=g,n.gamma=l||0,n}});var $n=pt((Mh,Xn)=>{"use strict";var Un=!0,Hn=Rt("zlib");Hn.deflateSync||(Un=!1);var No=xe(),Io=Or();Xn.exports=function(t,e){if(!Un)throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let r=e||{},i=new Io(r),n=[];n.push(Buffer.from(No.PNG_SIGNATURE)),n.push(i.packIHDR(t.width,t.height)),t.gamma&&n.push(i.packGAMA(t.gamma));let s=i.filterData(t.data,t.width,t.height),a=Hn.deflateSync(s,i.getDeflateOptions());if(s=null,!a||!a.length)throw new Error("bad png - invalid compressed data response");return n.push(i.packIDAT(a)),n.push(i.packIEND()),Buffer.concat(n)}});var Yn=pt(Ir=>{"use strict";var Mo=Bn(),Lo=$n();Ir.read=function(t,e){return Mo(t,e||{})};Ir.write=function(t,e){return Lo(t,e)}});var Gn=pt(zn=>{"use strict";var Po=Rt("util"),qn=Rt("stream"),Bo=pn(),Uo=Tn(),Ho=Yn(),It=zn.PNG=function(t){qn.call(this),t=t||{},this.width=t.width|0,this.height=t.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,t.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new Bo(t),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(e){this.data=e,this.emit("parsed",e)}.bind(this)),this._packer=new Uo(t),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};Po.inherits(It,qn);It.sync=Ho;It.prototype.pack=function(){return!this.data||!this.data.length?(this.emit("error","No data provided"),this):(process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this)};It.prototype.parse=function(t,e){if(e){let r,i;r=function(n){this.removeListener("error",i),this.data=n,e(null,this)}.bind(this),i=function(n){this.removeListener("parsed",r),e(n,null)}.bind(this),this.once("parsed",r),this.once("error",i)}return this.end(t),this};It.prototype.write=function(t){return this._parser.write(t),!0};It.prototype.end=function(t){this._parser.end(t)};It.prototype._metadata=function(t){this.width=t.width,this.height=t.height,this.emit("metadata",t)};It.prototype._gamma=function(t){this.gamma=t};It.prototype._handleClose=function(){!this._parser.writable&&!this._packer.readable&&this.emit("close")};It.bitblt=function(t,e,r,i,n,s,a,o){if(r|=0,i|=0,n|=0,s|=0,a|=0,o|=0,r>t.width||i>t.height||r+n>t.width||i+s>t.height)throw new Error("bitblt reading outside image");if(a>e.width||o>e.height||a+n>e.width||o+s>e.height)throw new Error("bitblt writing outside image");for(let h=0;h<s;h++)t.data.copy(e.data,(o+h)*e.width+a<<2,(i+h)*t.width+r<<2,(i+h)*t.width+r+n<<2)};It.prototype.bitblt=function(t,e,r,i,n,s,a){return It.bitblt(this,t,e,r,i,n,s,a),this};It.adjustGamma=function(t){if(t.gamma){for(let e=0;e<t.height;e++)for(let r=0;r<t.width;r++){let i=t.width*e+r<<2;for(let n=0;n<3;n++){let s=t.data[i+n]/255;s=Math.pow(s,1/2.2/t.gamma),t.data[i+n]=Math.round(s*255)}}t.gamma=0}};It.prototype.adjustGamma=function(){It.adjustGamma(this)}});var jn=pt((Bh,Ye)=>{"use strict";var Vn=Vn||function(t){return Buffer.from(t).toString("base64")};function Xo(t){var e=this,r=Math.round,i=Math.floor,n=new Array(64),s=new Array(64),a=new Array(64),o=new Array(64),h,l,p,f,d=new Array(65535),C=new Array(65535),m=new Array(64),F=new Array(64),w=[],T=0,S=7,g=new Array(64),y=new Array(64),x=new Array(64),z=new Array(256),_=new Array(2048),X,R=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],U=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],O=[0,1,2,3,4,5,6,7,8,9,10,11],nt=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],k=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],mt=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],M=[0,1,2,3,4,5,6,7,8,9,10,11],I=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],tt=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function st(c){for(var N=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],H=0;H<64;H++){var L=i((N[H]*c+50)/100);L<1?L=1:L>255&&(L=255),n[R[H]]=L}for(var W=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],j=0;j<64;j++){var at=i((W[j]*c+50)/100);at<1?at=1:at>255&&(at=255),s[R[j]]=at}for(var ot=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],bt=0,gt=0;gt<8;gt++)for(var v=0;v<8;v++)a[bt]=1/(n[R[bt]]*ot[gt]*ot[v]*8),o[bt]=1/(s[R[bt]]*ot[gt]*ot[v]*8),bt++}function P(c,N){for(var H=0,L=0,W=new Array,j=1;j<=16;j++){for(var at=1;at<=c[j];at++)W[N[L]]=[],W[N[L]][0]=H,W[N[L]][1]=j,L++,H++;H*=2}return W}function vt(){h=P(U,O),l=P(mt,M),p=P(nt,k),f=P(I,tt)}function rt(){for(var c=1,N=2,H=1;H<=15;H++){for(var L=c;L<N;L++)C[32767+L]=H,d[32767+L]=[],d[32767+L][1]=H,d[32767+L][0]=L;for(var W=-(N-1);W<=-c;W++)C[32767+W]=H,d[32767+W]=[],d[32767+W][1]=H,d[32767+W][0]=N-1+W;c<<=1,N<<=1}}function G(){for(var c=0;c<256;c++)_[c]=19595*c,_[c+256>>0]=38470*c,_[c+512>>0]=7471*c+32768,_[c+768>>0]=-11059*c,_[c+1024>>0]=-21709*c,_[c+1280>>0]=32768*c+8421375,_[c+1536>>0]=-27439*c,_[c+1792>>0]=-5329*c}function B(c){for(var N=c[0],H=c[1]-1;H>=0;)N&1<<H&&(T|=1<<S),H--,S--,S<0&&(T==255?(u(255),u(0)):u(T),S=7,T=0)}function u(c){w.push(c)}function D(c){u(c>>8&255),u(c&255)}function ht(c,N){var H,L,W,j,at,ot,bt,gt,v=0,A,q=8,Et=64;for(A=0;A<q;++A){H=c[v],L=c[v+1],W=c[v+2],j=c[v+3],at=c[v+4],ot=c[v+5],bt=c[v+6],gt=c[v+7];var Z=H+gt,it=H-gt,xt=L+bt,$=L-bt,ft=W+ot,Dt=W-ot,_t=j+at,Bt=j-at,qt=Z+_t,Qt=Z-_t,ee=xt+ft,re=xt-ft;c[v]=qt+ee,c[v+4]=qt-ee;var me=(re+Qt)*.707106781;c[v+2]=Qt+me,c[v+6]=Qt-me,qt=Bt+Dt,ee=Dt+$,re=$+it;var ve=(qt-re)*.382683433,Oe=.5411961*qt+ve,_e=1.306562965*re+ve,we=ee*.707106781,Ee=it+we,Ce=it-we;c[v+5]=Ce+Oe,c[v+3]=Ce-Oe,c[v+1]=Ee+_e,c[v+7]=Ee-_e,v+=8}for(v=0,A=0;A<q;++A){H=c[v],L=c[v+8],W=c[v+16],j=c[v+24],at=c[v+32],ot=c[v+40],bt=c[v+48],gt=c[v+56];var $r=H+gt,Ge=H-gt,Yr=L+bt,qr=L-bt,zr=W+ot,Gr=W-ot,Wr=j+at,ls=j-at,be=$r+Wr,We=$r-Wr,Ne=Yr+zr,Ie=Yr-zr;c[v]=be+Ne,c[v+32]=be-Ne;var Vr=(Ie+We)*.707106781;c[v+16]=We+Vr,c[v+48]=We-Vr,be=ls+Gr,Ne=Gr+qr,Ie=qr+Ge;var jr=(be-Ie)*.382683433,Zr=.5411961*be+jr,Qr=1.306562965*Ie+jr,Kr=Ne*.707106781,Jr=Ge+Kr,ti=Ge-Kr;c[v+40]=ti+Zr,c[v+24]=ti-Zr,c[v+8]=Jr+Qr,c[v+56]=Jr-Qr,v++}var Me;for(A=0;A<Et;++A)Me=c[A]*N[A],m[A]=Me>0?Me+.5|0:Me-.5|0;return m}function lt(){D(65504),D(16),u(74),u(70),u(73),u(70),u(0),u(1),u(1),u(0),D(1),D(1),u(0),u(0)}function Q(c){if(c){D(65505),c[0]===69&&c[1]===120&&c[2]===105&&c[3]===102?D(c.length+2):(D(c.length+5+2),u(69),u(120),u(105),u(102),u(0));for(var N=0;N<c.length;N++)u(c[N])}}function K(c,N){D(65472),D(17),u(8),D(N),D(c),u(3),u(1),u(17),u(0),u(2),u(17),u(1),u(3),u(17),u(1)}function V(){D(65499),D(132),u(0);for(var c=0;c<64;c++)u(n[c]);u(1);for(var N=0;N<64;N++)u(s[N])}function b(){D(65476),D(418),u(0);for(var c=0;c<16;c++)u(U[c+1]);for(var N=0;N<=11;N++)u(O[N]);u(16);for(var H=0;H<16;H++)u(nt[H+1]);for(var L=0;L<=161;L++)u(k[L]);u(1);for(var W=0;W<16;W++)u(mt[W+1]);for(var j=0;j<=11;j++)u(M[j]);u(17);for(var at=0;at<16;at++)u(I[at+1]);for(var ot=0;ot<=161;ot++)u(tt[ot])}function E(c){typeof c>"u"||c.constructor!==Array||c.forEach(N=>{if(typeof N=="string"){D(65534);var H=N.length;D(H+2);var L;for(L=0;L<H;L++)u(N.charCodeAt(L))}})}function dt(){D(65498),D(12),u(3),u(1),u(0),u(2),u(17),u(3),u(17),u(0),u(63),u(0)}function Y(c,N,H,L,W){for(var j=W[0],at=W[240],ot,bt=16,gt=63,v=64,A=ht(c,N),q=0;q<v;++q)F[R[q]]=A[q];var Et=F[0]-H;H=F[0],Et==0?B(L[0]):(ot=32767+Et,B(L[C[ot]]),B(d[ot]));for(var Z=63;Z>0&&F[Z]==0;Z--);if(Z==0)return B(j),H;for(var it=1,xt;it<=Z;){for(var $=it;F[it]==0&&it<=Z;++it);var ft=it-$;if(ft>=bt){xt=ft>>4;for(var Dt=1;Dt<=xt;++Dt)B(at);ft=ft&15}ot=32767+F[it],B(W[(ft<<4)+C[ot]]),B(d[ot]),it++}return Z!=gt&&B(j),H}function J(){for(var c=String.fromCharCode,N=0;N<256;N++)z[N]=c(N)}this.encode=function(c,N){var H=new Date().getTime();N&&Pt(N),w=new Array,T=0,S=7,D(65496),lt(),E(c.comments),Q(c.exifBuffer),V(),K(c.width,c.height),b(),dt();var L=0,W=0,j=0;T=0,S=7,this.encode.displayName="_encode_";for(var at=c.data,ot=c.width,bt=c.height,gt=ot*4,v=ot*3,A,q=0,Et,Z,it,xt,$,ft,Dt,_t;q<bt;){for(A=0;A<gt;){for(xt=gt*q+A,$=xt,ft=-1,Dt=0,_t=0;_t<64;_t++)Dt=_t>>3,ft=(_t&7)*4,$=xt+Dt*gt+ft,q+Dt>=bt&&($-=gt*(q+1+Dt-bt)),A+ft>=gt&&($-=A+ft-gt+4),Et=at[$++],Z=at[$++],it=at[$++],g[_t]=(_[Et]+_[Z+256>>0]+_[it+512>>0]>>16)-128,y[_t]=(_[Et+768>>0]+_[Z+1024>>0]+_[it+1280>>0]>>16)-128,x[_t]=(_[Et+1280>>0]+_[Z+1536>>0]+_[it+1792>>0]>>16)-128;L=Y(g,a,L,h,p),W=Y(y,o,W,l,f),j=Y(x,o,j,l,f),A+=32}q+=8}if(S>=0){var Bt=[];Bt[1]=S+1,Bt[0]=(1<<S+1)-1,B(Bt)}if(D(65497),typeof Ye>"u")return new Uint8Array(w);return Buffer.from(w);var qt,Qt};function Pt(c){if(c<=0&&(c=1),c>100&&(c=100),X!=c){var N=0;c<50?N=Math.floor(5e3/c):N=Math.floor(200-c*2),st(N),X=c}}function Ht(){var c=new Date().getTime();t||(t=50),J(),vt(),rt(),G(),Pt(t);var N=new Date().getTime()-c}Ht()}typeof Ye<"u"?Ye.exports=Wn:typeof window<"u"&&(window["jpeg-js"]=window["jpeg-js"]||{},window["jpeg-js"].encode=Wn);function Wn(t,e){typeof e>"u"&&(e=50);var r=new Xo(e),i=r.encode(t,e);return{data:i,width:t.width,height:t.height}}});var Qn=pt((Uh,Lr)=>{"use strict";var Mr=(function(){"use strict";var e=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),r=4017,i=799,n=3406,s=2276,a=1567,o=3784,h=5793,l=2896;function p(){}function f(S,g){for(var y=0,x=[],z,_,X=16;X>0&&!S[X-1];)X--;x.push({children:[],index:0});var R=x[0],U;for(z=0;z<X;z++){for(_=0;_<S[z];_++){for(R=x.pop(),R.children[R.index]=g[y];R.index>0;){if(x.length===0)throw new Error("Could not recreate Huffman Table");R=x.pop()}for(R.index++,x.push(R);x.length<=z;)x.push(U={children:[],index:0}),R.children[R.index]=U.children,R=U;y++}z+1<X&&(x.push(U={children:[],index:0}),R.children[R.index]=U.children,R=U)}return x[0].children}function d(S,g,y,x,z,_,X,R,U,O){var nt=y.precision,k=y.samplesPerLine,mt=y.scanLines,M=y.mcusPerLine,I=y.progressive,tt=y.maxH,st=y.maxV,P=g,vt=0,rt=0;function G(){if(rt>0)return rt--,vt>>rt&1;if(vt=S[g++],vt==255){var v=S[g++];if(v)throw new Error("unexpected marker: "+(vt<<8|v).toString(16))}return rt=7,vt>>>7}function B(v){for(var A=v,q;(q=G())!==null;){if(A=A[q],typeof A=="number")return A;if(typeof A!="object")throw new Error("invalid huffman sequence")}return null}function u(v){for(var A=0;v>0;){var q=G();if(q===null)return;A=A<<1|q,v--}return A}function D(v){var A=u(v);return A>=1<<v-1?A:A+(-1<<v)+1}function ht(v,A){var q=B(v.huffmanTableDC),Et=q===0?0:D(q);A[0]=v.pred+=Et;for(var Z=1;Z<64;){var it=B(v.huffmanTableAC),xt=it&15,$=it>>4;if(xt===0){if($<15)break;Z+=16;continue}Z+=$;var ft=e[Z];A[ft]=D(xt),Z++}}function lt(v,A){var q=B(v.huffmanTableDC),Et=q===0?0:D(q)<<U;A[0]=v.pred+=Et}function Q(v,A){A[0]|=G()<<U}var K=0;function V(v,A){if(K>0){K--;return}for(var q=_,Et=X;q<=Et;){var Z=B(v.huffmanTableAC),it=Z&15,xt=Z>>4;if(it===0){if(xt<15){K=u(xt)+(1<<xt)-1;break}q+=16;continue}q+=xt;var $=e[q];A[$]=D(it)*(1<<U),q++}}var b=0,E;function dt(v,A){for(var q=_,Et=X,Z=0;q<=Et;){var it=e[q],xt=A[it]<0?-1:1;switch(b){case 0:var $=B(v.huffmanTableAC),ft=$&15,Z=$>>4;if(ft===0)Z<15?(K=u(Z)+(1<<Z),b=4):(Z=16,b=1);else{if(ft!==1)throw new Error("invalid ACn encoding");E=D(ft),b=Z?2:3}continue;case 1:case 2:A[it]?A[it]+=(G()<<U)*xt:(Z--,Z===0&&(b=b==2?3:0));break;case 3:A[it]?A[it]+=(G()<<U)*xt:(A[it]=E<<U,b=0);break;case 4:A[it]&&(A[it]+=(G()<<U)*xt);break}q++}b===4&&(K--,K===0&&(b=0))}function Y(v,A,q,Et,Z){var it=q/M|0,xt=q%M,$=it*v.v+Et,ft=xt*v.h+Z;v.blocks[$]===void 0&&O.tolerantDecoding||A(v,v.blocks[$][ft])}function J(v,A,q){var Et=q/v.blocksPerLine|0,Z=q%v.blocksPerLine;v.blocks[Et]===void 0&&O.tolerantDecoding||A(v,v.blocks[Et][Z])}var Pt=x.length,Ht,c,N,H,L,W;I?_===0?W=R===0?lt:Q:W=R===0?V:dt:W=ht;var j=0,at,ot;Pt==1?ot=x[0].blocksPerLine*x[0].blocksPerColumn:ot=M*y.mcusPerColumn,z||(z=ot);for(var bt,gt;j<ot;){for(c=0;c<Pt;c++)x[c].pred=0;if(K=0,Pt==1)for(Ht=x[0],L=0;L<z;L++)J(Ht,W,j),j++;else for(L=0;L<z;L++){for(c=0;c<Pt;c++)for(Ht=x[c],bt=Ht.h,gt=Ht.v,N=0;N<gt;N++)for(H=0;H<bt;H++)Y(Ht,W,j,N,H);if(j++,j===ot)break}if(j===ot)do{if(S[g]===255&&S[g+1]!==0)break;g+=1}while(g<S.length-2);if(rt=0,at=S[g]<<8|S[g+1],at<65280)throw new Error("marker was not found");if(at>=65488&&at<=65495)g+=2;else break}return g-P}function C(S,g){var y=[],x=g.blocksPerLine,z=g.blocksPerColumn,_=x<<3,X=new Int32Array(64),R=new Uint8Array(64);function U(P,vt,rt){var G=g.quantizationTable,B,u,D,ht,lt,Q,K,V,b,E=rt,dt;for(dt=0;dt<64;dt++)E[dt]=P[dt]*G[dt];for(dt=0;dt<8;++dt){var Y=8*dt;if(E[1+Y]==0&&E[2+Y]==0&&E[3+Y]==0&&E[4+Y]==0&&E[5+Y]==0&&E[6+Y]==0&&E[7+Y]==0){b=h*E[0+Y]+512>>10,E[0+Y]=b,E[1+Y]=b,E[2+Y]=b,E[3+Y]=b,E[4+Y]=b,E[5+Y]=b,E[6+Y]=b,E[7+Y]=b;continue}B=h*E[0+Y]+128>>8,u=h*E[4+Y]+128>>8,D=E[2+Y],ht=E[6+Y],lt=l*(E[1+Y]-E[7+Y])+128>>8,V=l*(E[1+Y]+E[7+Y])+128>>8,Q=E[3+Y]<<4,K=E[5+Y]<<4,b=B-u+1>>1,B=B+u+1>>1,u=b,b=D*o+ht*a+128>>8,D=D*a-ht*o+128>>8,ht=b,b=lt-K+1>>1,lt=lt+K+1>>1,K=b,b=V+Q+1>>1,Q=V-Q+1>>1,V=b,b=B-ht+1>>1,B=B+ht+1>>1,ht=b,b=u-D+1>>1,u=u+D+1>>1,D=b,b=lt*s+V*n+2048>>12,lt=lt*n-V*s+2048>>12,V=b,b=Q*i+K*r+2048>>12,Q=Q*r-K*i+2048>>12,K=b,E[0+Y]=B+V,E[7+Y]=B-V,E[1+Y]=u+K,E[6+Y]=u-K,E[2+Y]=D+Q,E[5+Y]=D-Q,E[3+Y]=ht+lt,E[4+Y]=ht-lt}for(dt=0;dt<8;++dt){var J=dt;if(E[8+J]==0&&E[16+J]==0&&E[24+J]==0&&E[32+J]==0&&E[40+J]==0&&E[48+J]==0&&E[56+J]==0){b=h*rt[dt+0]+8192>>14,E[0+J]=b,E[8+J]=b,E[16+J]=b,E[24+J]=b,E[32+J]=b,E[40+J]=b,E[48+J]=b,E[56+J]=b;continue}B=h*E[0+J]+2048>>12,u=h*E[32+J]+2048>>12,D=E[16+J],ht=E[48+J],lt=l*(E[8+J]-E[56+J])+2048>>12,V=l*(E[8+J]+E[56+J])+2048>>12,Q=E[24+J],K=E[40+J],b=B-u+1>>1,B=B+u+1>>1,u=b,b=D*o+ht*a+2048>>12,D=D*a-ht*o+2048>>12,ht=b,b=lt-K+1>>1,lt=lt+K+1>>1,K=b,b=V+Q+1>>1,Q=V-Q+1>>1,V=b,b=B-ht+1>>1,B=B+ht+1>>1,ht=b,b=u-D+1>>1,u=u+D+1>>1,D=b,b=lt*s+V*n+2048>>12,lt=lt*n-V*s+2048>>12,V=b,b=Q*i+K*r+2048>>12,Q=Q*r-K*i+2048>>12,K=b,E[0+J]=B+V,E[56+J]=B-V,E[8+J]=u+K,E[48+J]=u-K,E[16+J]=D+Q,E[40+J]=D-Q,E[24+J]=ht+lt,E[32+J]=ht-lt}for(dt=0;dt<64;++dt){var Pt=128+(E[dt]+8>>4);vt[dt]=Pt<0?0:Pt>255?255:Pt}}T(_*z*8);for(var O,nt,k=0;k<z;k++){var mt=k<<3;for(O=0;O<8;O++)y.push(new Uint8Array(_));for(var M=0;M<x;M++){U(g.blocks[k][M],R,X);var I=0,tt=M<<3;for(nt=0;nt<8;nt++){var st=y[mt+nt];for(O=0;O<8;O++)st[tt+O]=R[I++]}}}return y}function m(S){return S<0?0:S>255?255:S}p.prototype={load:function(g){var y=new XMLHttpRequest;y.open("GET",g,!0),y.responseType="arraybuffer",y.onload=(function(){var x=new Uint8Array(y.response||y.mozResponseArrayBuffer);this.parse(x),this.onload&&this.onload()}).bind(this),y.send(null)},parse:function(g){var y=this.opts.maxResolutionInMP*1e3*1e3,x=0,z=g.length;function _(){var $=g[x]<<8|g[x+1];return x+=2,$}function X(){var $=_(),ft=g.subarray(x,x+$-2);return x+=ft.length,ft}function R($){var ft=1,Dt=1,_t,Bt;for(Bt in $.components)$.components.hasOwnProperty(Bt)&&(_t=$.components[Bt],ft<_t.h&&(ft=_t.h),Dt<_t.v&&(Dt=_t.v));var qt=Math.ceil($.samplesPerLine/8/ft),Qt=Math.ceil($.scanLines/8/Dt);for(Bt in $.components)if($.components.hasOwnProperty(Bt)){_t=$.components[Bt];var ee=Math.ceil(Math.ceil($.samplesPerLine/8)*_t.h/ft),re=Math.ceil(Math.ceil($.scanLines/8)*_t.v/Dt),me=qt*_t.h,ve=Qt*_t.v,Oe=ve*me,_e=[];T(Oe*256);for(var we=0;we<ve;we++){for(var Ee=[],Ce=0;Ce<me;Ce++)Ee.push(new Int32Array(64));_e.push(Ee)}_t.blocksPerLine=ee,_t.blocksPerColumn=re,_t.blocks=_e}$.maxH=ft,$.maxV=Dt,$.mcusPerLine=qt,$.mcusPerColumn=Qt}var U=null,O=null,nt=null,k,mt,M=[],I=[],tt=[],st=[],P=_(),vt=-1;if(this.comments=[],P!=65496)throw new Error("SOI not found");for(P=_();P!=65497;){var rt,G,B;switch(P){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var u=X();if(P===65534){var D=String.fromCharCode.apply(null,u);this.comments.push(D)}P===65504&&u[0]===74&&u[1]===70&&u[2]===73&&u[3]===70&&u[4]===0&&(U={version:{major:u[5],minor:u[6]},densityUnits:u[7],xDensity:u[8]<<8|u[9],yDensity:u[10]<<8|u[11],thumbWidth:u[12],thumbHeight:u[13],thumbData:u.subarray(14,14+3*u[12]*u[13])}),P===65505&&u[0]===69&&u[1]===120&&u[2]===105&&u[3]===102&&u[4]===0&&(this.exifBuffer=u.subarray(5,u.length)),P===65518&&u[0]===65&&u[1]===100&&u[2]===111&&u[3]===98&&u[4]===101&&u[5]===0&&(O={version:u[6],flags0:u[7]<<8|u[8],flags1:u[9]<<8|u[10],transformCode:u[11]});break;case 65499:for(var ht=_(),lt=ht+x-2;x<lt;){var Q=g[x++];T(256);var K=new Int32Array(64);if(Q>>4===0)for(G=0;G<64;G++){var V=e[G];K[V]=g[x++]}else if(Q>>4===1)for(G=0;G<64;G++){var V=e[G];K[V]=_()}else throw new Error("DQT: invalid table spec");M[Q&15]=K}break;case 65472:case 65473:case 65474:_(),k={},k.extended=P===65473,k.progressive=P===65474,k.precision=g[x++],k.scanLines=_(),k.samplesPerLine=_(),k.components={},k.componentsOrder=[];var b=k.scanLines*k.samplesPerLine;if(b>y){var E=Math.ceil((b-y)/1e6);throw new Error(`maxResolutionInMP limit exceeded by ${E}MP`)}var dt=g[x++],Y,J=0,Pt=0;for(rt=0;rt<dt;rt++){Y=g[x];var Ht=g[x+1]>>4,c=g[x+1]&15,N=g[x+2];if(Ht<=0||c<=0)throw new Error("Invalid sampling factor, expected values above 0");k.componentsOrder.push(Y),k.components[Y]={h:Ht,v:c,quantizationIdx:N},x+=3}R(k),I.push(k);break;case 65476:var H=_();for(rt=2;rt<H;){var L=g[x++],W=new Uint8Array(16),j=0;for(G=0;G<16;G++,x++)j+=W[G]=g[x];T(16+j);var at=new Uint8Array(j);for(G=0;G<j;G++,x++)at[G]=g[x];rt+=17+j,(L>>4===0?st:tt)[L&15]=f(W,at)}break;case 65501:_(),mt=_();break;case 65500:_(),_();break;case 65498:var ot=_(),bt=g[x++],gt=[],v;for(rt=0;rt<bt;rt++){v=k.components[g[x++]];var A=g[x++];v.huffmanTableDC=st[A>>4],v.huffmanTableAC=tt[A&15],gt.push(v)}var q=g[x++],Et=g[x++],Z=g[x++],it=d(g,x,k,gt,mt,q,Et,Z>>4,Z&15,this.opts);x+=it;break;case 65535:g[x]!==255&&x--;break;default:if(g[x-3]==255&&g[x-2]>=192&&g[x-2]<=254){x-=3;break}else if(P===224||P==225){if(vt!==-1)throw new Error(`first unknown JPEG marker at offset ${vt.toString(16)}, second unknown JPEG marker ${P.toString(16)} at offset ${(x-1).toString(16)}`);vt=x-1;let $=_();if(g[x+$-2]===255){x+=$-2;break}}throw new Error("unknown JPEG marker "+P.toString(16))}P=_()}if(I.length!=1)throw new Error("only single frame JPEGs supported");for(var rt=0;rt<I.length;rt++){var xt=I[rt].components;for(var G in xt)xt[G].quantizationTable=M[xt[G].quantizationIdx],delete xt[G].quantizationIdx}this.width=k.samplesPerLine,this.height=k.scanLines,this.jfif=U,this.adobe=O,this.components=[];for(var rt=0;rt<k.componentsOrder.length;rt++){var v=k.components[k.componentsOrder[rt]];this.components.push({lines:C(k,v),scaleX:v.h/k.maxH,scaleY:v.v/k.maxV})}},getData:function(g,y){var x=this.width/g,z=this.height/y,_,X,R,U,O,nt,k,mt,M,I,tt=0,st,P,vt,rt,G,B,u,D,ht,lt,Q,K=g*y*this.components.length;T(K);var V=new Uint8Array(K);switch(this.components.length){case 1:for(_=this.components[0],I=0;I<y;I++)for(O=_.lines[0|I*_.scaleY*z],M=0;M<g;M++)st=O[0|M*_.scaleX*x],V[tt++]=st;break;case 2:for(_=this.components[0],X=this.components[1],I=0;I<y;I++)for(O=_.lines[0|I*_.scaleY*z],nt=X.lines[0|I*X.scaleY*z],M=0;M<g;M++)st=O[0|M*_.scaleX*x],V[tt++]=st,st=nt[0|M*X.scaleX*x],V[tt++]=st;break;case 3:for(Q=!0,this.adobe&&this.adobe.transformCode?Q=!0:typeof this.opts.colorTransform<"u"&&(Q=!!this.opts.colorTransform),_=this.components[0],X=this.components[1],R=this.components[2],I=0;I<y;I++)for(O=_.lines[0|I*_.scaleY*z],nt=X.lines[0|I*X.scaleY*z],k=R.lines[0|I*R.scaleY*z],M=0;M<g;M++)Q?(st=O[0|M*_.scaleX*x],P=nt[0|M*X.scaleX*x],vt=k[0|M*R.scaleX*x],D=m(st+1.402*(vt-128)),ht=m(st-.3441363*(P-128)-.71413636*(vt-128)),lt=m(st+1.772*(P-128))):(D=O[0|M*_.scaleX*x],ht=nt[0|M*X.scaleX*x],lt=k[0|M*R.scaleX*x]),V[tt++]=D,V[tt++]=ht,V[tt++]=lt;break;case 4:if(!this.adobe)throw new Error("Unsupported color mode (4 components)");for(Q=!1,this.adobe&&this.adobe.transformCode?Q=!0:typeof this.opts.colorTransform<"u"&&(Q=!!this.opts.colorTransform),_=this.components[0],X=this.components[1],R=this.components[2],U=this.components[3],I=0;I<y;I++)for(O=_.lines[0|I*_.scaleY*z],nt=X.lines[0|I*X.scaleY*z],k=R.lines[0|I*R.scaleY*z],mt=U.lines[0|I*U.scaleY*z],M=0;M<g;M++)Q?(st=O[0|M*_.scaleX*x],P=nt[0|M*X.scaleX*x],vt=k[0|M*R.scaleX*x],rt=mt[0|M*U.scaleX*x],G=255-m(st+1.402*(vt-128)),B=255-m(st-.3441363*(P-128)-.71413636*(vt-128)),u=255-m(st+1.772*(P-128))):(G=O[0|M*_.scaleX*x],B=nt[0|M*X.scaleX*x],u=k[0|M*R.scaleX*x],rt=mt[0|M*U.scaleX*x]),V[tt++]=255-G,V[tt++]=255-B,V[tt++]=255-u,V[tt++]=255-rt;break;default:throw new Error("Unsupported color mode")}return V},copyToImageData:function(g,y){var x=g.width,z=g.height,_=g.data,X=this.getData(x,z),R=0,U=0,O,nt,k,mt,M,I,tt,st,P;switch(this.components.length){case 1:for(nt=0;nt<z;nt++)for(O=0;O<x;O++)k=X[R++],_[U++]=k,_[U++]=k,_[U++]=k,y&&(_[U++]=255);break;case 3:for(nt=0;nt<z;nt++)for(O=0;O<x;O++)tt=X[R++],st=X[R++],P=X[R++],_[U++]=tt,_[U++]=st,_[U++]=P,y&&(_[U++]=255);break;case 4:for(nt=0;nt<z;nt++)for(O=0;O<x;O++)M=X[R++],I=X[R++],k=X[R++],mt=X[R++],tt=255-m(M*(1-mt/255)+mt),st=255-m(I*(1-mt/255)+mt),P=255-m(k*(1-mt/255)+mt),_[U++]=tt,_[U++]=st,_[U++]=P,y&&(_[U++]=255);break;default:throw new Error("Unsupported color mode")}}};var F=0,w=0;function T(S=0){var g=F+S;if(g>w){var y=Math.ceil((g-w)/1024/1024);throw new Error(`maxMemoryUsageInMB limit exceeded by at least ${y}MB`)}F=g}return p.resetMaxMemoryUsage=function(S){F=0,w=S},p.getBytesAllocated=function(){return F},p.requestMemoryAllocation=T,p})();typeof Lr<"u"?Lr.exports=Zn:typeof window<"u"&&(window["jpeg-js"]=window["jpeg-js"]||{},window["jpeg-js"].decode=Zn);function Zn(t,e={}){var r={colorTransform:void 0,useTArray:!1,formatAsRGBA:!0,tolerantDecoding:!0,maxResolutionInMP:100,maxMemoryUsageInMB:512},i={...r,...e},n=new Uint8Array(t),s=new Mr;s.opts=i,Mr.resetMaxMemoryUsage(i.maxMemoryUsageInMB*1024*1024),s.parse(n);var a=i.formatAsRGBA?4:3,o=s.width*s.height*a;try{Mr.requestMemoryAllocation(o);var h={width:s.width,height:s.height,exifBuffer:s.exifBuffer,data:i.useTArray?new Uint8Array(o):Buffer.alloc(o)};s.comments.length>0&&(h.comments=s.comments)}catch(l){throw l instanceof RangeError?new Error("Could not allocate enough memory for the image. Required: "+o):l instanceof ReferenceError&&l.message==="Buffer is not defined"?new Error("Buffer is not globally defined in this environment. Consider setting useTArray to true"):l}return s.copyToImageData(h,i.formatAsRGBA),h}});var Jn=pt((Hh,Kn)=>{"use strict";var $o=jn(),Yo=Qn();Kn.exports={encode:$o,decode:Yo}});import{createRequire as fs}from"module";var us=fs("/"),ae,cs,ds;try{ae=us("worker_threads"),cs=ae.Worker,ds=ae.isMarkedAsUntransferable}catch{}var St=Uint8Array,ie=Uint16Array,ps=Int32Array,ni=new St([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),si=new St([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),xs=new St([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ai=function(t,e){for(var r=new ie(31),i=0;i<31;++i)r[i]=e+=1<<t[i-1];for(var n=new ps(r[30]),i=1;i<30;++i)for(var s=r[i];s<r[i+1];++s)n[s]=s-r[i]<<5|i;return{b:r,r:n}},ae=ai(ni,2),oi=ae.b,gs=ae.r;oi[28]=258,gs[258]=28;var hi=ai(si,0),ms=hi.b,hh=hi.r,Qe=new ie(32768);for(ut=0;ut<32768;++ut)Wt=(ut&43690)>>1|(ut&21845)<<1,Wt=(Wt&52428)>>2|(Wt&13107)<<2,Wt=(Wt&61680)>>4|(Wt&3855)<<4,Qe[ut]=((Wt&65280)>>8|(Wt&255)<<8)>>1;var Wt,ut,ye=(function(t,e,r){for(var i=t.length,n=0,s=new ie(e);n<i;++n)t[n]&&++s[t[n]-1];var a=new ie(e);for(n=1;n<e;++n)a[n]=a[n-1]+s[n-1]<<1;var o;if(r){o=new ie(1<<e);var h=15-e;for(n=0;n<i;++n)if(t[n])for(var l=n<<4|t[n],p=e-t[n],f=a[t[n]-1]++<<p,d=f|(1<<p)-1;f<=d;++f)o[Qe[f]>>h]=l}else for(o=new ie(i),n=0;n<i;++n)t[n]&&(o[n]=Qe[a[t[n]-1]++]>>15-t[n]);return o}),Fe=new St(288);for(ut=0;ut<144;++ut)Fe[ut]=8;var ut;for(ut=144;ut<256;++ut)Fe[ut]=9;var ut;for(ut=256;ut<280;++ut)Fe[ut]=7;var ut;for(ut=280;ut<288;++ut)Fe[ut]=8;var ut,li=new St(32);for(ut=0;ut<32;++ut)li[ut]=5;var ut;var vs=ye(Fe,9,1);var _s=ye(li,5,1),Ve=function(t){for(var e=t[0],r=1;r<t.length;++r)t[r]>e&&(e=t[r]);return e},Xt=function(t,e,r){var i=e/8|0;return(t[i]|t[i+1]<<8)>>(e&7)&r},je=function(t,e){var r=e/8|0;return(t[r]|t[r+1]<<8|t[r+2]<<16)>>(e&7)},ws=function(t){return(t+7)/8|0},Ae=function(t,e,r){return(e==null||e<0)&&(e=0),(r==null||r>t.length)&&(r=t.length),new St(t.subarray(e,r))};var Es=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],At=function(t,e,r){var i=new Error(e||Es[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,At),!r)throw i;return i},Cs=function(t,e,r,i){var n=t.length,s=i?i.length:0;if(!n||e.f&&!e.l)return r||new St(0);var a=!r,o=a||e.i!=2,h=e.i;a&&(r=new St(n*3));var l=function(b){var E=r.length;if(b>E){var dt=new St(Math.max(E*2,b));dt.set(r),r=dt}},p=e.f||0,f=e.p||0,d=e.b||0,C=e.l,m=e.d,F=e.m,w=e.n,T=n*8;do{if(!C){p=Xt(t,f,1);var S=Xt(t,f+1,3);if(f+=3,S)if(S==1)C=vs,m=_s,F=9,w=5;else if(S==2){var z=Xt(t,f,31)+257,_=Xt(t,f+10,15)+4,X=z+Xt(t,f+5,31)+1;f+=14;for(var R=new St(X),U=new St(19),O=0;O<_;++O)U[xs[O]]=Xt(t,f+O*3,7);f+=_*3;for(var nt=Ve(U),k=(1<<nt)-1,mt=ye(U,nt,1),O=0;O<X;){var M=mt[Xt(t,f,k)];f+=M&15;var g=M>>4;if(g<16)R[O++]=g;else{var I=0,tt=0;for(g==16?(tt=3+Xt(t,f,3),f+=2,I=R[O-1]):g==17?(tt=3+Xt(t,f,7),f+=3):g==18&&(tt=11+Xt(t,f,127),f+=7);tt--;)R[O++]=I}}var st=R.subarray(0,z),P=R.subarray(z);F=Ve(st),w=Ve(P),C=ye(st,F,1),m=ye(P,w,1)}else At(1);else{var g=ws(f)+4,y=t[g-4]|t[g-3]<<8,x=g+y;if(x>n){h&&At(0);break}o&&l(d+y),r.set(t.subarray(g,x),d),e.b=d+=y,e.p=f=x*8,e.f=p;continue}if(f>T){h&&At(0);break}}o&&l(d+131072);for(var vt=(1<<F)-1,rt=(1<<w)-1,G=f;;G=f){var I=C[je(t,f)&vt],B=I>>4;if(f+=I&15,f>T){h&&At(0);break}if(I||At(2),B<256)r[d++]=B;else if(B==256){G=f,C=null;break}else{var u=B-254;if(B>264){var O=B-257,D=ni[O];u=Xt(t,f,(1<<D)-1)+oi[O],f+=D}var ht=m[je(t,f)&rt],lt=ht>>4;ht||At(3),f+=ht&15;var P=ms[lt];if(lt>3){var D=si[lt];P+=je(t,f)&(1<<D)-1,f+=D}if(f>T){h&&At(0);break}o&&l(d+131072);var Q=d+u;if(d<P){var K=s-P,V=Math.min(P,Q);for(K+d<0&&At(3);d<V;++d)r[d]=i[K+d]}for(;d<Q;++d)r[d]=r[d-P]}}e.l=C,e.p=G,e.b=d,e.f=p,C&&(p=1,e.m=F,e.d=m,e.n=w)}while(!p);return d!=r.length&&a?Ae(r,0,d):r.subarray(0,d)};var Te=new St(0);var ne=function(t,e){return t[e]|t[e+1]<<8},se=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},Ze=function(t,e){return se(t,e)+se(t,e+4)*4294967296};var bs=(function(){function t(e,r){typeof e=="function"&&(r=e,e={}),this.ondata=r;var i=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:i?i.length:0},this.o=new St(32768),this.p=new St(0),i&&this.o.set(i)}return t.prototype.e=function(e){if(this.ondata||At(5),this.d&&At(4),!this.p.length)this.p=e;else if(e.length){var r=new St(this.p.length+e.length);r.set(this.p),r.set(e,this.p.length),this.p=r}},t.prototype.c=function(e){this.s.i=+(this.d=e||!1);var r=this.s.b,i=Cs(this.p,this.s,this.o);this.ondata(Ae(i,r,this.s.b),this.d),this.o=Ae(i,this.s.b-32768),this.s.b=this.o.length,this.p=Ae(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(e,r){this.e(e),this.c(r)},t})();var Ke=typeof TextDecoder<"u"&&new TextDecoder,Ts=0;try{Ke.decode(Te,{stream:!0}),Ts=1}catch{}var ys=function(t){for(var e="",r=0;;){var i=t[r++],n=(i>127)+(i>223)+(i>239);if(r+n>t.length)return{s:e,r:Ae(t,r-1)};n?n==3?(i=((i&15)<<18|(t[r++]&63)<<12|(t[r++]&63)<<6|t[r++]&63)-65536,e+=String.fromCharCode(55296|i>>10,56320|i&1023)):n&1?e+=String.fromCharCode((i&31)<<6|t[r++]&63):e+=String.fromCharCode((i&15)<<12|(t[r++]&63)<<6|t[r++]&63):e+=String.fromCharCode(i)}};function As(t,e){if(e){for(var r="",i=0;i<t.length;i+=16384)r+=String.fromCharCode.apply(null,t.subarray(i,i+16384));return r}else{if(Ke)return Ke.decode(t);var n=ys(t),s=n.s,r=n.r;return r.length&&At(8),s}}var Fs=function(t,e,r,i,n,s,a){var o=n==4294967295,h=s==4294967295,l=a==4294967295,p=e+r,f=o+h+l;if(i&&f){for(;e+4<p;e+=4+ne(t,e+2))if(ne(t,e)==1)return[o?Ze(t,e+4+8*h):n,h?Ze(t,e+4):s,l?Ze(t,e+4+8*(h+o)):a,1];i<2&&At(13)}return[n,s,a,0]};var Je=(function(){function t(){}return t.prototype.push=function(e,r){this.ondata(null,e,r)},t.compression=0,t})();var fi=(function(){function t(){var e=this;this.i=new bs(function(r,i){e.ondata(null,r,i)})}return t.prototype.push=function(e,r){try{this.i.push(e,r)}catch(i){this.ondata(i,null,r)}},t.compression=8,t})();var ui=(function(){function t(e){this.onfile=e,this.k=[],this.o={0:Je},this.p=Te}return t.prototype.push=function(e,r){var i=this;if(this.onfile||At(5),this.p||At(4),this.c>0){var n=Math.min(this.c,e.length),s=e.subarray(0,n);if(this.c-=n,this.d?this.d.push(s,!this.c):this.k[0].push(s),e=e.subarray(n),e.length)return this.push(e,r)}else{var a=0,o=0,h=void 0,l=void 0;this.p.length?e.length?(l=new St(this.p.length+e.length),l.set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var p=l.length,f=this.c,d=f&&this.d,C=function(){var T=se(l,o);if(T==67324752){a=1,h=o,m.d=null,m.c=0;var S=ne(l,o+6),g=ne(l,o+8),y=S&2048,x=S&8,z=ne(l,o+26),_=ne(l,o+28);if(p>o+30+z+_){var X=[];m.k.unshift(X),a=2;var R=se(l,o+18),U=se(l,o+22),O=As(l.subarray(o+30,o+=30+z),!y),nt=Fs(l,o,_,2,R,U,0),k=nt[0],mt=nt[1],M=nt[3];x&&(k=-1-M),o+=_,m.c=k;var I,tt={name:O,compression:g,start:function(){if(tt.ondata||At(5),!k)tt.ondata(null,Te,!0);else{var st=i.o[g];st||tt.ondata(At(14,"unknown compression type "+g,1),null,!1),I=k<0?new st(O):new st(O,k,mt),I.ondata=function(G,B,u){tt.ondata(G,B,u)};for(var P=0,vt=X;P<vt.length;P++){var rt=vt[P];I.push(rt,!1)}i.k[0]==X&&i.c?i.d=I:I.push(Te,!0)}},terminate:function(){I&&I.terminate&&I.terminate()}};k>=0&&(tt.size=k,tt.originalSize=mt),m.onfile(tt)}return"break"}else if(f){if(T==134695760)return h=o+=12+(f==-2&&8),a=3,m.c=0,"break";if(T==33639248)return h=o-=4,a=3,m.c=0,"break"}},m=this;o<p-4;++o){var F=C();if(F==="break")break}if(this.p=Te,f<0){var w=a?l.subarray(0,h-12-(f==-2&&8)-(se(l,h-16)==134695760&&4)):l.subarray(0,o);d?d.push(w,!!a):this.k[+(a==2)].push(w)}if(a&2)return this.push(l.subarray(o),r);this.p=l.subarray(o)}r&&(this.c&&At(13),this.p=null)},t.prototype.register=function(e){this.o[e.compression]=e},t})();var Yi=Le(vr(),1);var Ta=1e4,ya=5e7,Aa=25e7,qi=5e6,zi=256,Gi=65536,_r=256,Wi=3e4,et=class extends Error{constructor(r,i){super(`${r}: ${i}`);this.code=r}},Fa="http://schemas.openxmlformats.org/package/2006/relationships",Da="http://schemas.openxmlformats.org/package/2006/content-types",ka=new Set(["http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument","http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument"]),Ra=["application/vnd.openxmlformats-officedocument.wordprocessingml.document.main","application/vnd.ms-word.document.main"];function Vi(t){return t.length===0?"empty name":t.includes("\\")?"backslash":t.includes("\0")?"NUL byte":t.startsWith("/")?"absolute path":/^[a-zA-Z]:/.test(t)?"drive letter":t.split("/").some(e=>e==="..")?"dot-dot segment":null}function Sa(t,e){let r=Math.max(0,t.length-65557),i=-1;for(let l=t.length-22;l>=r;l--)if(t.readUInt32LE(l)===101010256){i=l;break}if(i<0)throw new et("DOCX_UNREADABLE","not a zip archive (no end-of-central-directory)");let n=t.readUInt16LE(i+10);if(n>e)throw new et("DOCX_TOO_MANY_PARTS",`${n} entries > ${e} cap`);let s=t.readUInt32LE(i+16),a=[],o=new Set,h=s;for(let l=0;l<n;l++){if(h+46>t.length||t.readUInt32LE(h)!==33639248)throw new et("DOCX_UNREADABLE","malformed central directory");let p=t.readUInt32LE(h+16),f=t.readUInt16LE(h+28),d=t.readUInt16LE(h+30),C=t.readUInt16LE(h+32),m=t.subarray(h+46,h+46+f).toString("utf8"),F=Vi(m);if(F!==null)throw new et("DOCX_UNREADABLE",`unsafe entry name (${F}): ${JSON.stringify(m)}`);if(o.has(m))throw new et("DOCX_UNREADABLE",`duplicate entry: ${m}`);o.add(m),a.push({name:m,crc:p}),h+=46+f+d+C}return a}function Oa(t,e){let r=new Map,i=0,n=null,s=o=>{n||(n=o)},a=new ui(o=>{let h=Vi(o.name);if(h!==null){s(new et("DOCX_UNREADABLE",`unsafe entry name (${h}): ${JSON.stringify(o.name)}`));return}let l=[],p=0;o.ondata=(f,d,C)=>{if(f){s(new et("DOCX_UNREADABLE",`entry ${o.name}: ${f.message??String(f)}`));return}if(d&&d.length>0){if(p+=d.length,i+=d.length,p>e.maxPartBytes){s(new et("DOCX_PART_TOO_LARGE",`${o.name}: ${p} actual bytes > ${e.maxPartBytes} cap`));return}if(i>e.maxTotalBytes){s(new et("DOCX_BOMB",`total actual inflated bytes exceed ${e.maxTotalBytes} cap`));return}l.push(d)}C&&!n&&r.set(o.name,Buffer.concat(l))},o.start()});a.register(Je),a.register(fi);try{for(let o=0;o<t.length;o+=65536)if(a.push(t.subarray(o,Math.min(o+65536,t.length)),o+65536>=t.length),n)throw n}catch(o){throw o instanceof et?o:new et("DOCX_UNREADABLE",`zip stream: ${o instanceof Error?o.message:String(o)}`)}if(n)throw n;return r}function ji(t,e,r){let i=new Yi.SaxesParser({xmlns:!0}),n=null;if(i.on("doctype",()=>{n=new et("DOCX_UNREADABLE",`DOCTYPE not allowed (${e})`)}),i.on("error",s=>{n=n??new et("DOCX_UNREADABLE",`${e}: ${s.message}`)}),i.on("opentag",s=>{if(n)return;let a={};for(let[o,h]of Object.entries(s.attributes))a[h.local||o]=h.value;r(s.uri??"",s.local,a)}),i.write(t).close(),n)throw n}function Xi(t,e){let r=new Map;return ji(t,e,(i,n,s)=>{i===Fa&&n==="Relationship"&&s.Id&&s.Type&&s.Target!==void 0&&r.set(s.Id,{type:s.Type,target:s.Target,targetMode:s.TargetMode==="External"?"External":"Internal"})}),r}function Na(t){let e=new Map,r=new Map;return ji(t,"[Content_Types].xml",(i,n,s)=>{i===Da&&(n==="Default"&&s.Extension&&s.ContentType?e.set(s.Extension.toLowerCase(),s.ContentType):n==="Override"&&s.PartName&&s.ContentType&&r.set(s.PartName.replace(/^\//,""),s.ContentType))}),{defaults:e,overrides:r}}function Ia(t,e){let r=t.overrides.get(e);if(r)return r;let i=e.lastIndexOf(".");if(!(i<0))return t.defaults.get(e.slice(i+1).toLowerCase())}function $i(t,e){if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)||e.includes("\\")||e.includes("\0"))return null;let r;try{r=decodeURIComponent(e)}catch{return null}let i=r.startsWith("/")?[]:t.split("/").slice(0,-1).filter(n=>n.length>0);for(let n of r.split("/"))if(!(n===""||n===".")){if(n===".."){if(i.length===0)return null;i.pop();continue}i.push(n)}return i.length>0?i.join("/"):null}var Ma=Buffer.from([208,207,17,224,161,177,26,225]);function de(t){try{return t.length>=3&&t[0]===239&&t[1]===187&&t[2]===191?new TextDecoder("utf-8",{fatal:!0}).decode(t.subarray(3)):t.length>=2&&t[0]===255&&t[1]===254?new TextDecoder("utf-16le",{fatal:!0}).decode(t.subarray(2)):t.length>=2&&t[0]===254&&t[1]===255?new TextDecoder("utf-16be",{fatal:!0}).decode(t.subarray(2)):new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{throw new et("DOCX_UNREADABLE","XML part is not valid UTF-8/UTF-16 text")}}function Zi(t,e){if(t.length>=8&&t.subarray(0,8).equals(Ma))throw new et("DOCX_ENCRYPTED_OR_LEGACY","password-protected Office file (or a legacy .doc renamed .docx) \u2014 remove the password / save as .docx and re-ingest");let r={maxEntries:e?.maxEntries??Ta,maxPartBytes:e?.maxPartBytes??ya,maxTotalBytes:e?.maxTotalBytes??Aa},i=Sa(t,r.maxEntries),n=Oa(t,r),s=new Map(i.map(d=>[d.name,d]));if(n.size!==i.length)throw new et("DOCX_UNREADABLE",`central directory lists ${i.length} entries, stream produced ${n.size}`);for(let[d,C]of n){let m=s.get(d);if(!m)throw new et("DOCX_UNREADABLE",`entry ${d} missing from central directory`);if(ii(C)!==m.crc)throw new et("DOCX_UNREADABLE",`CRC mismatch: ${d}`)}let a=n.get("_rels/.rels");if(!a)throw new et("DOCX_NOT_WORDPROCESSING","no package relationships (_rels/.rels missing)");let o=Xi(de(a),"_rels/.rels"),h=null;for(let d of o.values()){if(!ka.has(d.type)||d.targetMode!=="Internal")continue;let C=$i("",d.target);if(C!==null&&n.has(C)){h=C;break}}if(h===null)throw new et("DOCX_NOT_WORDPROCESSING","this zip is not a Word document (no officeDocument relationship)");let l=n.get("[Content_Types].xml");if(!l)throw new et("DOCX_NOT_WORDPROCESSING","package has no [Content_Types].xml");let p=Ia(Na(de(l)),h);if(!p||!Ra.some(d=>p.startsWith(d)))throw new et("DOCX_NOT_WORDPROCESSING",`this zip is not a Word document (main part content type: ${p??"unknown"} \u2014 pptx/xlsx or unknown package)`);let f=new Map;return{parts:n,mainPart:h,relsFor(d){let C=f.get(d);if(C)return C;let m=d.lastIndexOf("/"),F=`${m>=0?d.slice(0,m+1):""}_rels/${m>=0?d.slice(m+1):d}.rels`,w=n.get(F),T=w?Xi(de(w),F):new Map;return f.set(d,T),T},resolveTarget:$i}}var ts=Le(Gn(),1),es=Le(Jn(),1);function rs(t){return t.length>=24&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71?t.toString("latin1",12,16)!=="IHDR"?{format:"png"}:{format:"png",width:t.readUInt32BE(16),height:t.readUInt32BE(20)}:t.length>=4&&t[0]===255&&t[1]===216&&t[2]===255?{format:"jpeg",...qo(t)}:t.length>=16&&t.toString("latin1",0,4)==="RIFF"&&t.toString("latin1",8,12)==="WEBP"?{format:"webp",...zo(t)}:t.length>=4&&t.toString("latin1",0,4).startsWith("GIF8")?{format:"gif"}:t.length>=2&&t[0]===66&&t[1]===77?{format:"bmp"}:t.length>=4&&(t[0]===73&&t[1]===73&&t[2]===42&&t[3]===0||t[0]===77&&t[1]===77&&t[2]===0&&t[3]===42)?{format:"tiff"}:t.length>=44&&t.readUInt32LE(0)===1&&t.toString("latin1",40,44)===" EMF"?{format:"emf"}:t.length>=4&&(t[0]===215&&t[1]===205&&t[2]===198&&t[3]===154||t[0]===1&&t[1]===0&&t[2]===9&&t[3]===0)?{format:"wmf"}:{format:"unknown"}}function qo(t){let e=2;for(;e+9<t.length;){if(t[e]!==255)return{};let r=t[e+1];if(r===216||r>=208&&r<=215){e+=2;continue}let i=t.readUInt16BE(e+2);if(r>=192&&r<=207&&r!==196&&r!==200&&r!==204)return{height:t.readUInt16BE(e+5),width:t.readUInt16BE(e+7)};if(i<2)return{};e+=2+i}return{}}function zo(t){let e=t.toString("latin1",12,16);if(e==="VP8X"&&t.length>=30)return{width:1+t.readUIntLE(24,3),height:1+t.readUIntLE(27,3)};if(e==="VP8 "&&t.length>=30)return t[23]!==157||t[24]!==1||t[25]!==42?{}:{width:t.readUInt16LE(26)&16383,height:t.readUInt16LE(28)&16383};if(e==="VP8L"&&t.length>=25){if(t[20]!==47)return{};let r=t.readUInt32LE(21);return{width:(r&16383)+1,height:(r>>>14&16383)+1}}return{}}function is(t,e){try{if(e==="png"){let r=ts.PNG.sync.read(t);return{data:Buffer.from(r.data),width:r.width,height:r.height,channels:4}}if(e==="jpeg"){let r=es.decode(t,{useTArray:!0,maxMemoryUsageInMB:512});return{data:Buffer.from(r.data),width:r.width,height:r.height,channels:4}}return null}catch{return null}}var ss=Le(vr(),1);var qe=new Set(["http://schemas.openxmlformats.org/wordprocessingml/2006/main","http://purl.oclc.org/ooxml/wordprocessingml/main"]),Go=new Set(["http://schemas.openxmlformats.org/drawingml/2006/main","http://purl.oclc.org/ooxml/drawingml/main"]),Wo=new Set(["http://schemas.openxmlformats.org/officeDocument/2006/math","http://purl.oclc.org/ooxml/officeDocument/math"]),ns="urn:schemas-microsoft-com:vml",Pr="http://schemas.openxmlformats.org/markup-compatibility/2006",ze=class{constructor(e,r,i=n=>this.tokens.push(n)){this.partName=e;this.budget=r;this.sink=i}tokens=[];storyRefs=[];stack=[];skipUntilDepth=[];fields=[];runVanish=[];acStack=[];txbxDepths=[];drawing=null;failed=null;setSink(e){this.sink=e}fail(e){this.failed||(this.failed=e)}abort(e){throw!this.failed&&e instanceof et&&(this.failed=e),e}emit(e){this.failed||(this.drawing&&e.t==="text"&&this.txbxDepths.length>0&&(this.drawing.emittedContent=!0),this.sink(e))}suppressed(){return this.skipUntilDepth.length>0}inInstruction(){return this.fields.some(e=>!e.hasSeparate)}parent(){return this.stack.length>=2?this.stack[this.stack.length-2]:void 0}depth(){return this.stack.length}onOpen(e,r,i){if(this.failed)return;this.budget.nodesRemaining-=1,this.budget.nodesRemaining<0&&this.abort(new et("DOCX_UNREADABLE",`XML node budget exhausted (${this.partName})`)),(this.budget.nodesRemaining&4095)===0&&this.budget.deadline!==void 0&&Date.now()>this.budget.deadline&&this.abort(new et("DOCX_UNREADABLE",`conversion budget exhausted (${this.partName})`)),this.stack.push({uri:e,local:r});let n=this.depth();if(n>_r&&this.abort(new et("DOCX_UNREADABLE",`XML nesting exceeds ${_r} (${this.partName})`)),this.suppressed())return;if(e===Pr&&r==="AlternateContent"){this.acStack.push({branchTaken:!1});return}if(e===Pr&&(r==="Choice"||r==="Fallback")){let a=this.acStack[this.acStack.length-1];if(!a)return;a.branchTaken?this.skipUntilDepth.push(n):a.branchTaken=!0;return}let s=qe.has(e);if((s&&r==="txbxContent"||e===ns&&r==="textbox")&&this.txbxDepths.push(n),s&&(r==="del"||r==="moveFrom"||r==="sdtPr"||r==="delText"||r==="pPrChange"||r==="rPrChange"||r==="sectPrChange"||r==="tblPrChange"||r==="trPrChange"||r==="tcPrChange")){this.skipUntilDepth.push(n);return}if(Wo.has(e)&&(r==="oMath"||r==="oMathPara")){this.emit({t:"marker",value:"[equation omitted]"}),this.skipUntilDepth.push(n);return}if(s&&r==="altChunk"){this.emit({t:"marker",value:"[embedded content omitted]"}),this.skipUntilDepth.push(n);return}if(s&&r==="tabs"){this.skipUntilDepth.push(n);return}if(s){switch(r){case"r":this.runVanish.push(!1);break;case"vanish":{let a=i.val;this.parent()?.local==="rPr"&&a!=="false"&&a!=="0"&&this.runVanish.length>0&&(this.runVanish[this.runVanish.length-1]=!0);break}case"fldChar":{let a=i.fldCharType;if(a==="begin")this.fields.push({hasSeparate:!1});else if(a==="separate"){let o=this.fields[this.fields.length-1];o&&(o.hasSeparate=!0)}else if(a==="end"){let o=this.fields.pop();o&&!o.hasSeparate&&this.emit({t:"marker",value:"[field: no stored result]"})}break}case"tab":this.parent()?.local==="r"&&!this.textSuppressed()&&this.emit({t:"tab"});break;case"br":case"cr":this.textSuppressed()||this.emit({t:"break"});break;case"noBreakHyphen":this.textSuppressed()||this.emit({t:"text",value:"\u2011"});break;case"softHyphen":break;case"sym":this.textSuppressed()||this.emit({t:"marker",value:"[symbol]"});break;case"numPr":this.parent()?.local==="pPr"&&this.emit({t:"marker",value:"- "});break;case"footnoteReference":i.id!==void 0&&!this.textSuppressed()&&this.emit({t:"note-ref",noteKind:"footnote",id:i.id});break;case"endnoteReference":i.id!==void 0&&!this.textSuppressed()&&this.emit({t:"note-ref",noteKind:"endnote",id:i.id});break;case"headerReference":case"footerReference":{let a=i.id;if(a){let o=i.type==="first"?"first":i.type==="even"?"even":"default";this.storyRefs.push({kind:r==="headerReference"?"header":"footer",type:o,relId:a})}break}case"drawing":this.drawing||(this.drawing={relId:null,kind:"drawing",external:!1,found:!1,emittedContent:!1});break;case"pict":case"object":this.drawing||(this.drawing={relId:null,kind:"vml",external:!1,found:!1,emittedContent:!1});break}return}if(Go.has(e)&&r==="blip"&&this.drawing&&!this.drawing.found){let a=this.relAttr(i,"embed"),o=this.relAttr(i,"link");a?(this.drawing.relId=a,this.drawing.external=!1,this.drawing.found=!0):o&&(this.drawing.relId=o,this.drawing.external=!0,this.drawing.found=!0);return}if(e===ns&&r==="imagedata"&&this.drawing&&!this.drawing.found){let a=this.relAttr(i,"id")??i.relid;a&&(this.drawing.relId=a,this.drawing.kind="vml",this.drawing.found=!0);return}}onClose(){let e=this.depth();this.skipUntilDepth[this.skipUntilDepth.length-1]===e&&this.skipUntilDepth.pop(),this.txbxDepths[this.txbxDepths.length-1]===e&&this.txbxDepths.pop();let i=this.stack.pop();if(!(!i||this.failed)&&!this.suppressed()){if(i.uri===Pr&&i.local==="AlternateContent"){this.acStack.pop();return}if(qe.has(i.uri))switch(i.local){case"r":this.runVanish.pop();break;case"p":this.emit({t:"para-end"});break;case"tc":this.emit({t:"table-cell-end"});break;case"tr":this.emit({t:"table-row-end"});break;case"drawing":case"pict":case"object":{let n=this.drawing;if(this.drawing=null,!n)break;n.found?this.emit({t:"image",relId:n.relId,kind:n.kind,external:n.external}):n.emittedContent||this.emit({t:"marker",value:"[object omitted: drawing]"});break}}}}onText(e){if(this.failed||this.suppressed()||e.length===0)return;let r=this.stack[this.stack.length-1];!r||!qe.has(r.uri)||r.local==="t"&&(this.textSuppressed()||(this.budget.textCharsRemaining!==void 0&&(this.budget.textCharsRemaining-=e.length,this.budget.textCharsRemaining<0&&this.abort(new Error(`PROJECTION_TOO_LARGE: projection text exceeds the conversion cap during the walk (${this.partName}) \u2014 split the document and re-ingest`))),this.emit({t:"text",value:e})))}textSuppressed(){return this.inInstruction()?!0:this.runVanish.length>0&&this.runVanish[this.runVanish.length-1]}relAttr(e,r){return e[r]}run(e){let r=new ss.SaxesParser({xmlns:!0});if(r.on("doctype",()=>{this.fail(new et("DOCX_UNREADABLE",`DOCTYPE not allowed (${this.partName})`))}),r.on("error",i=>{this.fail(new et("DOCX_UNREADABLE",`${this.partName}: ${i.message}`))}),r.on("opentag",i=>{let n={},s=Object.entries(i.attributes);s.length>zi&&this.abort(new et("DOCX_UNREADABLE",`too many attributes (${this.partName})`));for(let[a,o]of s)o.value.length>Gi&&this.abort(new et("DOCX_UNREADABLE",`oversized attribute (${this.partName})`)),n[o.local||a]=o.value;this.onOpen(i.uri??"",i.local,n)}),r.on("closetag",()=>this.onClose()),r.on("text",i=>this.onText(i)),r.write(e).close(),this.failed)throw this.failed}};function as(t,e){let r=e.budget??{nodesRemaining:Number.MAX_SAFE_INTEGER},i=new ze(e.partName,r);return i.run(t),{tokens:i.tokens,storyRefs:i.storyRefs}}var Br=class extends ze{notes=new Map;current=null;noteDepth=0;constructor(e,r){super(e,r),this.setSink(i=>this.current?.push(i))}onOpen(e,r,i){super.onOpen(e,r,i),!(!qe.has(e)||r!=="footnote"&&r!=="endnote")&&(i.type!==void 0&&i.type!=="normal"||(this.current=[],i.id!==void 0&&this.notes.set(i.id,this.current),this.noteDepth=this.depth()))}onClose(){let e=this.depth();super.onClose(),this.noteDepth===e&&(this.current=null,this.noteDepth=0)}};function os(t,e){let r=new Br(e.partName,e.budget??{nodesRemaining:Number.MAX_SAFE_INTEGER});return r.run(t),r.notes}var jo="v1",Zo="1.0.0+saxes6.0.0+fflate0.8.3+pngjs7.0.0+jpeg-js0.4.4",Qo=64,Ko=16,Jo=12e6,th=6e6,eh=5e7,rh=new Set(["http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes","http://purl.oclc.org/ooxml/officeDocument/relationships/footnotes"]),ih=new Set(["http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes","http://purl.oclc.org/ooxml/officeDocument/relationships/endnotes"]),nh={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},sh=new Set(["png","jpeg","webp"]);function ah(t){if(t==="body")return"in body";if(t.startsWith("header:"))return"in header";if(t.startsWith("footer:"))return"in footer";let e=/^(footnote|endnote):(.+)$/.exec(t);return e?`in ${e[1]} ${e[2]}`:`in ${t}`}var Xr=class{constructor(e,r){this.pkg=e;this.caps=r}inventory=[];blobs=new Map;delivered=[];n=0;deliveredBytes=0;firstRefByFp=new Map;count(){return this.n}occurrence(e,r,i){this.n+=1;let n=`i${this.n}`,s=ah(i),a=(w,T,S)=>{this.inventory.push({ref:n,loc:i,media_type:w,...S?.blob?{blob:S.blob}:{},...S?.appearance?{appearance:S.appearance}:{},delivery:T,...S?.duplicate_of?{duplicate_of:S.duplicate_of}:{}})},o=w=>`[img#${n} omitted: ${w}]`,h=e.relId!==null?this.pkg.relsFor(r).get(e.relId):void 0;if(e.external||h?.targetMode==="External")return a("application/octet-stream","external-image-not-fetched"),o("external-image-not-fetched");let l=h?this.pkg.resolveTarget(r,h.target):null,p=l!==null?this.pkg.parts.get(l):void 0;if(!p)return a("application/octet-stream","undecodable"),o("undecodable");let f=rs(p),d=nh[f.format],C=ei(p);if(this.blobs.set(C,p),!sh.has(f.format)){let w=f.format==="gif"||f.format==="bmp"||f.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";return a(d,w,{blob:C}),o(w)}if(f.width===void 0||f.height===void 0||f.width*f.height>this.caps.maxPixels)return a(d,"undecodable",{blob:C}),o("undecodable");let m;if(f.format==="png"||f.format==="jpeg"){let w=is(p,f.format);if(w===null)return a(d,"undecodable",{blob:C}),o("undecodable");m=ri(w.data,{width:w.width,height:w.height,channels:w.channels})}if(f.width<this.caps.dimensionFloor||f.height<this.caps.dimensionFloor)return a(d,"below-dimension-floor",{blob:C,appearance:m}),o("below-dimension-floor");let F=this.firstRefByFp.get(C);return F!==void 0?(a(d,"duplicate",{blob:C,appearance:m,duplicate_of:F}),`[img#${n}: image ${s} \u2014 same as img#${F}; cite img#${F}]`):p.byteLength>this.caps.imageMaxBytes?(a(d,"image-too-large",{blob:C,appearance:m}),o("image-too-large")):this.deliveredBytes+p.byteLength>this.caps.visionByteBudget?(a(d,"vision-byte-budget-reached",{blob:C,appearance:m}),o("vision-byte-budget-reached")):this.delivered.length>=this.caps.imageCap?(a(d,"image-cap-reached",{blob:C,appearance:m}),o("image-cap-reached")):(this.firstRefByFp.set(C,n),this.deliveredBytes+=p.byteLength,this.delivered.push(n),a(d,"selected",{blob:C,appearance:m}),`[img#${n}: image ${s}]`)}};function Ur(t,e){let r=[];for(let i of t)switch(i.t){case"text":r.push(i.value);break;case"tab":r.push(" ");break;case"break":r.push(`
|
|
11
|
+
`);break;case"para-end":r.push(`
|
|
12
|
+
`);break;case"table-cell-end":r[r.length-1]===`
|
|
13
|
+
`&&r.pop(),r.push(" ");break;case"table-row-end":r[r.length-1]===" "&&r.pop(),r.push(`
|
|
14
|
+
`);break;case"marker":r.push(i.value);break;case"note-ref":r.push(`[${i.noteKind} ${i.id}]`);break;case"image":{let n=e(i);n!==null&&r.push(n);break}}return r.join("")}function Hr(t){let e=0;for(let r of t)r.t==="text"&&(e+=r.value.length);return e}function hs(t,e,r){let i=t.parts.get(e);if(!i)throw new et("DOCX_UNREADABLE",`referenced part missing: ${e}`);return as(de(i),{partName:e,budget:r})}async function Zh(t,e){let r=Date.now()+(e?.budgetMs??Wi),i=m=>{if(Date.now()>r)throw new et("DOCX_UNREADABLE",`conversion budget exhausted (${m})`)},n=Zi(t),s={nodesRemaining:qi,textCharsRemaining:2*4e5,deadline:r},a={dimensionFloor:e?.caps?.dimensionFloor??Qo,imageCap:e?.caps?.imageCap??Ko,visionByteBudget:e?.caps?.visionByteBudget??Jo,imageMaxBytes:e?.caps?.imageMaxBytes??th,maxPixels:e?.caps?.maxPixels??eh},o=new Xr(n,a),h=hs(n,n.mainPart,s);i(n.mainPart);let l=Hr(h.tokens),p=[Ur(h.tokens,m=>o.occurrence(m,n.mainPart,"body"))],f=n.relsFor(n.mainPart),d=new Set;for(let m of["header","footer"])for(let F of h.storyRefs.filter(w=>w.kind===m)){let w=f.get(F.relId);if(!w||w.targetMode!=="Internal")continue;let T=n.resolveTarget(n.mainPart,w.target);if(T===null||!n.parts.has(T)||d.has(T))continue;d.add(T);let S=hs(n,T,s);i(T),l+=Hr(S.tokens);let g=F.type==="default"?`[${m}]`:`[${m} ${F.type}]`;p.push(`${g}
|
|
15
|
+
${Ur(S.tokens,y=>o.occurrence(y,T,`${m}:${T}`))}`)}for(let[m,F]of[["footnote",rh],["endnote",ih]]){let w=[];for(let g of h.tokens)g.t==="note-ref"&&g.noteKind===m&&!w.includes(g.id)&&w.push(g.id);if(w.length===0)continue;let T=null;for(let g of f.values())if(F.has(g.type)&&g.targetMode==="Internal"){T=n.resolveTarget(n.mainPart,g.target);break}if(T===null||!n.parts.has(T))continue;let S=os(de(n.parts.get(T)),{partName:T,budget:s});i(T);for(let g of w){let y=S.get(g);if(!y)continue;l+=Hr(y);let x=T;p.push(`[${m} ${g}]
|
|
16
|
+
${Ur(y,z=>o.occurrence(z,x,`${m}:${g}`))}`)}}if(l===0&&o.count()===0)throw new et("DOCX_NO_TEXT","no extractable text or images \u2014 nothing citable in this document");let C=p.join("");return C.endsWith(`
|
|
17
|
+
`)||(C+=`
|
|
18
|
+
`),{projection:C,inventory:o.inventory,blobs:o.blobs,delivered:o.delivered,converter:{name:"ooxml-walk",version:Zo,policy:jo}}}export{rs as a,is as b,jo as c,Zo as d,Qo as e,Ko as f,Jo as g,th as h,eh as i,Ur as j,Zh as k};
|
|
19
|
+
/*! Bundled license information:
|
|
20
|
+
|
|
21
|
+
xmlchars/xml/1.0/ed5.js:
|
|
22
|
+
(**
|
|
23
|
+
* Character classes and associated utilities for the 5th edition of XML 1.0.
|
|
24
|
+
*
|
|
25
|
+
* @author Louis-Dominique Dubeau
|
|
26
|
+
* @license MIT
|
|
27
|
+
* @copyright Louis-Dominique Dubeau
|
|
28
|
+
*)
|
|
29
|
+
|
|
30
|
+
xmlchars/xml/1.1/ed2.js:
|
|
31
|
+
(**
|
|
32
|
+
* Character classes and associated utilities for the 2nd edition of XML 1.1.
|
|
33
|
+
*
|
|
34
|
+
* @author Louis-Dominique Dubeau
|
|
35
|
+
* @license MIT
|
|
36
|
+
* @copyright Louis-Dominique Dubeau
|
|
37
|
+
*)
|
|
38
|
+
|
|
39
|
+
xmlchars/xmlns/1.0/ed3.js:
|
|
40
|
+
(**
|
|
41
|
+
* Character class utilities for XML NS 1.0 edition 3.
|
|
42
|
+
*
|
|
43
|
+
* @author Louis-Dominique Dubeau
|
|
44
|
+
* @license MIT
|
|
45
|
+
* @copyright Louis-Dominique Dubeau
|
|
46
|
+
*)
|
|
47
|
+
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as c}from"./chunk-
|
|
2
|
+
import{b as c}from"./chunk-J2KSZUOO.js";import{d as l}from"./chunk-5YPBPZUR.js";function h(f,o,u){let n=o.resolve(u);if(!n)return{target:null,entries:[]};let t=new Set([n.cid]),r=n.cid;for(;o.superseded.has(r);){let s=o.superseded.get(r);if(typeof s!="string"||t.has(s))break;t.add(s),r=s}let d=o.nodeLabel.get(n.cid)??"(unknown)",{records:p}=c(f),i=[];for(let s of p){for(let e of s.nodes)t.has(e.cid)&&i.push({seq:s.seq,ts:s.ts,kind:"minted",detail:`minted ${e.label} ${e.cid}`});for(let e of s.judgements??[])t.has(e.about)&&i.push({seq:s.seq,ts:s.ts,kind:"judgement",rationale:e.rationale,detail:`judgement on ${e.about}`,by:e.by});for(let e of s.review)t.has(e.id)&&i.push({seq:s.seq,ts:s.ts,kind:"review",detail:`${e.resolution}${e.reason?` \u2014 ${e.reason}`:""}`,by:e.by});for(let e of s.supersessions)e.kind==="node"&&(t.has(e.old)||e.new!==null&&t.has(e.new))&&i.push({seq:s.seq,ts:s.ts,kind:"supersession",detail:`${e.old} \u2192 ${String(e.new)} \u2014 ${e.reason}`,by:e.by});for(let e of s.names??[])t.has(e.cid)&&i.push({seq:s.seq,ts:s.ts,kind:"name",detail:`named ${e.slug}`,by:e.by});if(d===l.SOURCE)for(let[e,a]of Object.entries(s.source_head_moves))(t.has(a??"")||o.heads.get(e)!==void 0&&t.has(n.cid)&&e===o.getNode(n.cid)?.content?.source_id)&&i.push({seq:s.seq,ts:s.ts,kind:"head_move",detail:`${e} head \u2192 ${String(a)}`})}return i.sort((s,e)=>e.seq-s.seq),{target:{cid:n.cid,tip:n.tip,label:d,slug:o.nameOf.get(n.cid)},entries:i}}export{h as a};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{existsSync as f,mkdirSync as K,readFileSync as l,readdirSync as L,renameSync as y,rmSync as _,writeFileSync as $,openSync as q,closeSync as F}from"fs";import{randomBytes as H}from"crypto";import{join as w}from"path";var d=class extends Error{constructor(t,i){super(`${t}: ${i}`);this.code=t}},R=1440*60*1e3,A=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,N=n=>w(n,"sessions"),O=(n,e)=>w(N(n),e),g=(n,e)=>w(O(n,e),"state.json"),m=(n,e)=>w(O(n,e),".lock"),E=n=>(n?.now??(()=>new Date))();function P(n){if(!Number.isInteger(n)||n<=0)return!1;try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}function v(n,e){let t=`${n}.tmp-${process.pid}`;$(t,e,{mode:384}),y(t,n)}function b(n,e,t,i=0){if(i>20)throw new d("SESSION_LOCKED",`${e}: lock contention did not settle`);let o=m(n,e),s=H(8).toString("hex"),a=JSON.stringify({pid:process.pid,ts:t.toISOString(),nonce:s})+`
|
|
3
|
+
`;try{let r=q(o,"wx",384);return $(r,a),F(r),s}catch(r){if(r.code!=="EEXIST")throw r;let p=!1,u;try{let c=JSON.parse(l(o,"utf8")),h=t.getTime()-new Date(c.ts).getTime();p=!P(c.pid)||h>=R,u=c.nonce}catch{p=!0}if(!p)throw new d("SESSION_LOCKED",`${e} is held by another live process`);let S=`${o}.break-${s}`;try{y(o,S);let c;try{c=JSON.parse(l(S,"utf8"))}catch{c=null}if(c===null||c.nonce===u)_(S,{force:!0});else try{y(S,o)}catch{_(S,{force:!0})}}catch(c){if(c.code!=="ENOENT")throw c}return b(n,e,t,i+1)}}function C(n,e,t,i,o){let s=()=>{try{if(JSON.parse(l(m(n,e),"utf8")).nonce!==i)throw new d("SESSION_LOCK_LOST",`${e} lock was taken over`)}catch(r){throw r instanceof d?r:new d("SESSION_LOCK_LOST",`${e} lock file unreadable/gone`)}},a=()=>v(g(n,e),JSON.stringify(t)+`
|
|
4
|
+
`);return{get state(){return t},isApplied:r=>t.applied_events.includes(r),markApplied(r){s(),t={...t,applied_events:[...new Set([...t.applied_events,...r])].sort()},a()},save(r){s();let{agent_state:p,pending:u,assumed:S,read_basis:c,corpus_cursor:h,expires_at:I,force:k,conv_source:x,held_receipts:T,force_scope:D,user_session_id:J}=r;t={...t,...p!==void 0?{agent_state:p}:{},...u!==void 0?{pending:u}:{},...S!==void 0?{assumed:S}:{},...c!==void 0?{read_basis:c}:{},...h!==void 0?{corpus_cursor:h}:{},...I!==void 0?{expires_at:I}:{},...k!==void 0?{force:k}:{},...x!==void 0?{conv_source:x}:{},...T!==void 0?{held_receipts:T}:{},...D!==void 0?{force_scope:D}:{},...J!==void 0?{user_session_id:J}:{}},a()},complete(){s(),_(O(n,e),{recursive:!0,force:!0})},release(){try{s(),_(m(n,e),{force:!0})}catch(r){if(r instanceof d||r.code==="ENOENT")return;throw r}}}}function X(n,e,t){if(!A.test(e.sid))throw new d("SESSION_MISSING",`bad sid ${JSON.stringify(e.sid)}`);let i=E(t);if(f(g(n,e.sid)))throw new d("SESSION_LOCKED",`${e.sid} already exists \u2014 resume it`);K(O(n,e.sid),{recursive:!0,mode:448});let o=b(n,e.sid,i),s={schema:1,applied_events:[],...e};return v(g(n,e.sid),JSON.stringify(s)+`
|
|
5
|
+
`),C(n,e.sid,s,o,t)}function z(n,e,t){if(!A.test(e)||!f(g(n,e)))throw new d("SESSION_MISSING",`no session ${e}`);let i=E(t),o=b(n,e,i),s=JSON.parse(l(g(n,e),"utf8"));if(new Date(s.expires_at).getTime()<=i.getTime())throw _(m(n,e),{force:!0}),new d("SESSION_EXPIRED",`${e} expired at ${s.expires_at}`);let a={...s,expires_at:new Date(i.getTime()+R).toISOString()};return v(g(n,e),JSON.stringify(a)+`
|
|
6
|
+
`),C(n,e,a,o,t)}function Q(n,e){let t=g(n,e);return f(t)?JSON.parse(l(t,"utf8")):null}function Z(n){let e=N(n);if(!f(e))return[];let t=[];for(let i of L(e)){let o=g(n,i);if(f(o))try{let s=JSON.parse(l(o,"utf8"));t.push({sid:s.sid,mode:s.mode,created_at:s.created_at,expires_at:s.expires_at,pendingCount:s.pending.questions.length+s.pending.proposals.length,verb:s.verb,use_case:s.use_case})}catch{t.push({sid:i,mode:"?",created_at:"",expires_at:"",pendingCount:0,corrupt:!0})}}return t.sort((i,o)=>i.created_at<o.created_at?-1:1)}function B(n,e){let t=E(e),i=[],o=[],s=N(n);if(!f(s))return{removed:i,skipped:o};for(let a of L(s)){if(e?.sid&&a!==e.sid)continue;let r=!1,p=!1;try{let u=JSON.parse(l(g(n,a),"utf8"));r=new Date(u.expires_at).getTime()<=t.getTime()}catch{p=!0}if(e?.sid||e?.all||r||p&&e?.all){try{let u=JSON.parse(l(m(n,a),"utf8"));if(P(u.pid)&&u.pid!==process.pid){o.push({sid:a,reason:`in use by live pid ${u.pid}`});continue}}catch{}_(O(n,a),{recursive:!0,force:!0}),i.push(a)}}return{removed:i,skipped:o}}export{d as a,X as b,z as c,Q as d,Z as e,B as f};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as b,d as _}from"./chunk-NVGBE2DR.js";import{a as g,c as h}from"./chunk-
|
|
2
|
+
import{c as b,d as _}from"./chunk-NVGBE2DR.js";import{a as g,c as h}from"./chunk-6HYW5RFX.js";import{e as S}from"./chunk-J2KSZUOO.js";import{d as f,f as v}from"./chunk-5YPBPZUR.js";var V=n=>`conv#turn=${n}`;function E(n,o){for(let t of n.split(`
|
|
3
3
|
`))if(t.trim())try{let r=JSON.parse(t);if(r.turn===o)return r.text}catch{}return null}var y={format:"conversation",media_type:"text/x-conversation",anchors_supported:["#turn="]};function $(n){let{contextDir:o,graph:t,sessionStamp:r}=n,e=`su-conv-${r}`,u=t.heads.get(e);if(typeof u=="string")return{record:null,errors:[{code:"CONV_SOURCE_EXISTS",detail:`${e} already exists \u2014 resume it`}],sourceId:e,cid:u};let i=b(o,Buffer.from("","utf8")),c=h(e,i),a=v("source",c);if(a.length>0)return{record:null,errors:a.map(s=>({code:s.code,detail:s.detail})),sourceId:e,cid:""};let d=g("source",c);return{record:S(o,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:d,label:f.SOURCE,content:c}],edges:[],review:[],supersessions:[],source_head_moves:{[e]:d},media:{[e]:y},conv:{source_id:e,turn:0,append_of:null}},{expectPrev:t.latestHash}).record,errors:null,sourceId:e,cid:d}}function G(n){let{contextDir:o,graph:t,sourceId:r,text:e,force:u}=n,i=t.heads.get(r),c=t.convChains.get(r);if(typeof i!="string"||!c)return{record:null,errors:[{code:"CONV_SOURCE_MISSING",detail:`${r} is not a live conversation source`}]};let d=t.getNode(i)?.content?.blob;if(typeof d!="string")return{record:null,errors:[{code:"CONV_SOURCE_MISSING",detail:`${r} head node unreadable`}]};let l=_(o,d)?.toString("utf8")??"",s=c.turns;if(!u&&s>0&&E(l,s)===e)return{record:null,errors:null,turn:s,cid:i,idempotent:!0};let p=s+1,C=`${l}${JSON.stringify({turn:p,text:e})}
|
|
4
4
|
`,O=b(o,Buffer.from(C,"utf8")),x=h(r,O),m=g("source",x);return{record:S(o,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:m,label:f.SOURCE,content:x}],edges:[],review:[],supersessions:[],source_head_moves:{[r]:m},media:{[r]:y},conv:{source_id:r,turn:p,append_of:i}},{expectPrev:t.latestHash}).record,errors:null,turn:p,cid:m,idempotent:!1}}export{V as a,E as b,$ as c,G as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as q}from"./chunk-
|
|
2
|
+
import{a as q}from"./chunk-6HYW5RFX.js";import{a as b,b as S,d as C}from"./chunk-J2KSZUOO.js";import{a as R,e as I,f as j,g as L,h as F}from"./chunk-5YPBPZUR.js";import{existsSync as E,mkdirSync as P,readFileSync as k,renameSync as J,rmSync as W,writeFileSync as K}from"fs";import{dirname as V,join as y}from"path";var O=o=>y(o,"derived"),D=o=>y(O(o),"index.json");function U(o,e){let r=e.startsWith("sha256:")?e.slice(7):e;return y(O(o),"nodes",r.slice(0,2),r.slice(2)+".json")}function $(){return{applied:{seq:0,hash:null},heads:{},trust:{},nodeLabel:{},forward:{},extracted:[],design_of:{},exec:{},superseded:{},names:{},archivedReason:{},appliedEvents:[],conv:{},media:{}}}function M(o){let e=D(o);if(!E(e))return null;try{let r=JSON.parse(k(e,"utf8"));return r.superseded===void 0||r.names===void 0||r.archivedReason===void 0||r.appliedEvents===void 0||r.conv===void 0||r.media===void 0||r.exec===void 0||r.reverse!==void 0?null:r}catch{return null}}function T(o,e){P(V(o),{recursive:!0});let r=`${o}.tmp-${process.pid}`;K(r,e),J(r,o)}function w(o,e,r,p,f={}){let u=f.writeNodeFiles!==!1,h=new Set(e.extracted),m=new Set(e.appliedEvents);r.forEach((i,v)=>{for(let n of i.nodes){let s=U(o,n.cid);u&&!E(s)&&T(s,JSON.stringify({label:n.label,content:n.content})+`
|
|
3
3
|
`),!(n.cid in e.trust)&&n.content.derived===!0&&(e.trust[n.cid]="derived"),e.nodeLabel[n.cid]=n.label}i.proposal_id!=null&&typeof i.extraction_of=="string"&&h.add(i.extraction_of),i.design_of&&((e.design_of??={})[i.design_of.uc_cid]={engine:i.design_of.engine,seq:i.seq});for(let n of i.executions??[])((e.exec??={})[n.about]??=[]).push(n);for(let n of i.edges){let{quote:s,...t}=n.props,c=e.forward[n.src]??=[];c.some(a=>a.ecid===n.ecid)||c.push({...n,props:t}),i.proposal_id!=null&&n.type===I.DERIVES&&typeof n.props.source_cid=="string"&&h.add(n.props.source_cid)}for(let n of i.review)n.resolution==="approved"||n.resolution==="edited"?(e.trust[n.id]="trusted",delete e.archivedReason[n.id]):n.resolution==="rejected"?(e.trust[n.id]="archived",n.reason?e.archivedReason[n.id]=n.reason:delete e.archivedReason[n.id]):n.resolution==="reset"&&(e.trust[n.id]="derived",delete e.archivedReason[n.id]);for(let n of i.supersessions)n.kind==="node"?n.new===n.old?delete e.superseded[n.old]:e.superseded[n.old]=n.new:e.superseded[n.ecid]=null;for(let n of i.names??[])e.names[n.slug]=n.cid;for(let[n,s]of Object.entries(i.source_head_moves))e.heads[n]=s;for(let n of i.event_ids??[])m.add(n);if(i.media)for(let[n,s]of Object.entries(i.media)){let t=i.source_head_moves[n];typeof t=="string"&&(e.media[t]=s)}if(i.conv){let n=i.source_head_moves[i.conv.source_id];if(typeof n=="string"){let s=e.conv[i.conv.source_id],t=s&&s.chain.length>0?s.chain[s.chain.length-1]:null;i.conv.append_of===t?e.conv[i.conv.source_id]={turns:i.conv.turn,chain:[...s?.chain??[],n]}:e.conv[i.conv.source_id]={turns:i.conv.turn,chain:[n]}}}for(let[n,s]of Object.entries(i.source_head_moves))i.conv?.source_id!==n&&e.conv[n]!==void 0&&(e.conv[n]=typeof s=="string"?{turns:e.conv[n].turns,chain:[s]}:{turns:e.conv[n].turns,chain:[]});e.applied={seq:i.seq,hash:p[v]}}),e.extracted=[...h].sort(),e.appliedEvents=[...m].sort()}function x(o,e){T(D(o),JSON.stringify(e)+`
|
|
4
4
|
`)}function Y(o){let e=y(o,"meta.json");if(E(e))try{let r=JSON.parse(k(e,"utf8"));if(r.schema!==R||r.canonicalizer!=="v1")throw new b(`schema fence: store is ${r.schema}/${r.canonicalizer}, this build is ${R}/${"v1"} \u2014 migrate explicitly (kane-cli context rebuild after upgrading)`)}catch(r){throw r instanceof b?r:new b(`corrupt meta.json in ${o} \u2014 fix or remove it`)}}function z(o){Y(o);let e=M(o);if(e===null){e=$();let{records:f,hashes:u}=S(o);return w(o,e,f,u),x(o,e),e}let{records:r,hashes:p}=C(o,e.applied.seq,e.applied.hash);return r.length>0&&(w(o,e,r,p),x(o,e)),e}function X(o){return W(O(o),{recursive:!0,force:!0}),z(o)}function ee(o){let e=[],r=[],p=[];try{({records:r,hashes:p}=S(o))}catch(s){return{ok:!1,issues:[s instanceof b?s.message:String(s)],records:0}}let f=$();w(o,f,r,p,{writeNodeFiles:!1});let u=M(o),h=0,m=f;if(u!==null&&u.applied.seq<r.length){let s=u.applied.seq;u.applied.hash===(s===0?null:p[s-1])&&(h=r.length-s,m=$(),w(o,m,r.slice(0,s),p.slice(0,s),{writeNodeFiles:!1}))}if(u===null)e.push("derived/index.json missing or corrupt (run kane-cli context rebuild)");else{let s=t=>JSON.stringify(N(t));for(let t of["applied","heads","trust","nodeLabel","forward","extracted","superseded","names","archivedReason","appliedEvents","conv","media","design_of","exec"])s(m[t])!==s(u[t])&&e.push(`derived drift in index.${t} (run kane-cli context rebuild)`)}let i=new Set;for(let s of Object.values(f.forward))for(let t of s)i.add(t.ecid);let v=new Set;for(let s of r)for(let t of s.supersessions)t.kind==="node"?(t.old in f.nodeLabel||e.push(`SUPERSEDE_UNKNOWN_OLD: ${t.old} (record ${s.seq})`),t.new!==null&&t.new!==t.old&&!(t.new in f.nodeLabel)&&e.push(`SUPERSEDE_UNKNOWN_NEW: ${String(t.new)} (record ${s.seq})`),t.new===t.old?v.delete(t.old):(v.has(t.old)&&e.push(`DOUBLE_SUPERSEDE: ${t.old} re-superseded while live (record ${s.seq})`),v.add(t.old))):i.has(t.ecid)||e.push(`SUPERSEDE_UNKNOWN_ECID: ${t.ecid} (record ${s.seq})`);for(let s of Object.keys(f.superseded)){let t=new Set,c=s;for(;c!==null&&c in f.superseded;){if(t.has(c)){e.push(`SUPERSEDE_CYCLE: chain from ${s} revisits ${c}`);break}t.add(c),c=f.superseded[c]}}for(let[s,t]of Object.entries(f.names))t in f.nodeLabel||e.push(`NAME_UNKNOWN_TARGET: slug ${s} \u2192 ${t} not in the graph`);for(let s of r)for(let t of s.edges){let c=f.nodeLabel[t.src]??"(unknown)",a=f.nodeLabel[t.dst]??"(unknown)";for(let d of F(t.type,c,a,t.props))e.push(`${d.code}: ${t.ecid} ${d.detail}`)}let n=new Map;for(let s of Object.values(f.forward))for(let t of s){if(t.ecid in f.superseded)continue;let c=n.get(t.type)??[];c.push(t),n.set(t.type,c)}for(let[s,t]of n){let c=L(s);if(c?.acyclic){let a=new Map;for(let l of t)a.set(l.src,[...a.get(l.src)??[],l.dst]);let d=new Map,g=l=>{d.set(l,1);for(let _ of a.get(l)??[])if(d.get(_)===1||d.get(_)===void 0&&g(_))return!0;return d.set(l,2),!1};for(let l of a.keys())if(d.get(l)===void 0&&g(l)){e.push(`EDGE_CYCLE: live ${s} edges form a cycle reachable from ${l}`);break}}if(c?.cardinality==="one-live-per-src"||c?.cardinality==="one-live-per-src-and-dst"){let a=new Map;for(let d of t)d.dst in f.superseded||a.set(d.src,(a.get(d.src)??0)+1);for(let[d,g]of a)g>1&&e.push(`CARDINALITY_VIOLATION: ${g} live ${s} edges from ${d} (one-live-per-src)`)}if(c?.cardinality==="one-live-per-src-and-dst"){let a=new Map;for(let d of t)d.src in f.superseded||d.dst in f.superseded||a.set(d.dst,(a.get(d.dst)??0)+1);for(let[d,g]of a)g>1&&e.push(`CARDINALITY_VIOLATION: ${g} live ${s} edges onto ${d} (one-live-per-dst)`)}}for(let[s,t]of Object.entries(m.nodeLabel)){let c=U(o,s);if(!E(c)){e.push(`missing node file for ${s} (run kane-cli context rebuild)`);continue}try{let a=JSON.parse(k(c,"utf8"));(a.label!==t||q(a.label,a.content)!==s)&&e.push(`node file content mismatch for ${s} (run kane-cli context rebuild)`);for(let d of j(a.label,a.content))e.push(`${d.code}: ${s} ${d.detail}`)}catch{e.push(`corrupt node file for ${s} (run kane-cli context rebuild)`)}}return{ok:e.length===0,issues:e,records:r.length,...h>0?{pending:h}:{}}}function N(o){return Array.isArray(o)?o.map(N):o&&typeof o=="object"?Object.fromEntries(Object.entries(o).sort(([e],[r])=>e<r?-1:1).map(([e,r])=>[e,N(r)])):o}export{U as a,z as b,X as c,ee as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as m}from"./chunk-
|
|
2
|
+
import{a as m}from"./chunk-KXUSG5ZI.js";import{y as t}from"./chunk-MMPFU2YC.js";import{a as p}from"./chunk-HCBYKLMW.js";import{a,b as r,i as u}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var c=n(b(),1);var e=n(p(),1);function R({onSubmit:l}){let[o,f]=(0,c.useState)(0),s=(0,c.useRef)(!1);return u((x,i)=>{s.current||(i.leftArrow||i.rightArrow?f(d=>d===0?1:0):i.return?(s.current=!0,l(o===0?"positive":"negative")):i.escape&&(s.current=!0,l(null)))}),(0,e.jsxs)(a,{flexDirection:"column",marginTop:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(r,{color:t.secondary,children:"Rate this session: "}),(0,e.jsx)(r,{color:o===0?t.orange:t.dim,children:o===0?"[ \u{1F44D} ]":" \u{1F44D} "}),(0,e.jsx)(r,{children:" "}),(0,e.jsx)(r,{color:o===1?t.orange:t.dim,children:o===1?"[ \u{1F44E} ]":" \u{1F44E} "})]}),(0,e.jsx)(m,{bindings:[{keys:"\u2190/\u2192",label:"select"},{keys:"\u21B5",label:"submit"}],escBackLabel:"skip"})]})}export{R as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as R}from"./chunk-
|
|
2
|
+
import{a as R}from"./chunk-KXUSG5ZI.js";import{y as r}from"./chunk-MMPFU2YC.js";import{a as Y}from"./chunk-HCBYKLMW.js";import{a,b as i,i as X}from"./chunk-C44QQJR4.js";import{a as G}from"./chunk-6YGTRKDT.js";import{e as P}from"./chunk-UR6MHSHU.js";var u=P(G(),1);var e=P(Y(),1),f=5;function K(t,I){if(!I)return t;let c=I.toLowerCase();return t.filter(B=>B.label.toLowerCase().includes(c))}function J(t){let{title:I,items:c,loading:B=!1,loadingText:F,error:L=null,itemNoun:T="items",onSelect:H,onCancel:E,defaultActiveId:w,onTab:y,extraHint:N}=t,[x,d]=(0,u.useState)(0),[S,g]=(0,u.useState)(0),[s,A]=(0,u.useState)(""),[C,h]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(c.length===0)return;if(t.preserveSelectionById&&C!==null){let n=c.findIndex(o=>o.id===C);if(n>=0){g(Math.floor(n/f)),d(n%f);return}}let l=w?c.findIndex(n=>n.id===w):c.findIndex(n=>n.isActive);l>=0?(g(Math.floor(l/f)),d(l%f),t.preserveSelectionById&&h(c[l].id)):t.preserveSelectionById&&(g(0),d(0),h(c[0]?.id??null))},[c,w,t.preserveSelectionById,C]),(0,u.useEffect)(()=>{if(!t.onSearch)return;let l=setTimeout(()=>t.onSearch(s),t.searchDebounceMs??250);return()=>clearTimeout(l)},[s,t.onSearch,t.searchDebounceMs]);let m=t.onSearch?c:K(c,s),M=S*f,p=Math.min(M+f,m.length),D=Math.ceil(m.length/f),O=p-M,v=m.slice(M,p);return X((l,n)=>{if(L){n.escape&&E();return}if(n.escape){s?(A(""),d(0),g(0)):E();return}if(n.tab&&y){y();return}if(n.upArrow){if(x>0){let o=x-1;d(o),t.preserveSelectionById&&h(v[o]?.id??null)}else if(S>0){let o=S-1,b=f-1;g(o),d(b),t.preserveSelectionById&&h(m[o*f+b]?.id??null)}return}if(n.downArrow){if(x<O-1){let o=x+1;d(o),t.preserveSelectionById&&h(v[o]?.id??null)}else if(S<D-1){let o=S+1,b=0;g(o),d(b),t.preserveSelectionById&&h(m[o*f+b]?.id??null)}return}if(n.return&&v[x]){H(v[x]);return}if(n.backspace||n.delete){A(o=>o.slice(0,-1)),d(0),g(0);return}l&&!n.ctrl&&!n.meta&&(A(o=>o+l),d(0),g(0))},{isActive:!B}),B?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:r.orange,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(i,{color:r.secondary,children:F??`Loading ${T}\u2026`})})]}):L?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:r.red,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(i,{color:r.red,children:L})}),(0,e.jsx)(R,{bindings:[]})]}):(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(i,{color:r.orange,bold:!0,children:I}),(0,e.jsxs)(i,{color:r.dim,children:[" (",m.length,!t.onSearch&&s?`/${c.length}`:""," ",T,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(a,{marginTop:1,children:[(0,e.jsx)(i,{color:r.secondary,children:s?"filter: ":""}),s?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(i,{children:s}),(0,e.jsx)(i,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(i,{color:r.dim,children:["Search ",T,"\u2026"]}),(0,e.jsx)(i,{inverse:!0,children:" "})]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(i,{color:r.secondary,children:["Searching ",T,"\u2026"]}):m.length===0?(0,e.jsxs)(i,{color:r.dim,children:["No ",T,' match "',s,'"']}):v.map((l,n)=>{let o=n===x,b=o?"\u276F ":" ",$=l.isActive?r.green:o?r.orange:void 0;return(0,e.jsxs)(i,{color:$,children:[b,l.label,l.isActive?" \u25CF selected":""]},l.id)})}),!t.searching&&D>1&&(0,e.jsx)(a,{marginTop:1,children:(0,e.jsxs)(i,{color:r.dim,children:["Page ",S+1,"/",D]})}),t.footer&&(0,e.jsx)(a,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(R,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},{keys:"\u21B5",label:"select"},...y&&N?[{keys:"tab",label:N}]:[]],escBackLabel:s?"clear":"back to chat"})]})}export{J as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as $}from"./chunk-YCCUBQY4.js";import{a as U}from"./chunk-
|
|
2
|
+
import{a as $}from"./chunk-YCCUBQY4.js";import{a as U}from"./chunk-GIMTSDNC.js";import{a as T}from"./chunk-2WVKOZ6W.js";import{a as k}from"./chunk-KHJXOFDM.js";import{a as _}from"./chunk-KXUSG5ZI.js";import{y as i}from"./chunk-MMPFU2YC.js";import{a as O}from"./chunk-HCBYKLMW.js";import{a as u,b as s}from"./chunk-C44QQJR4.js";import{a as K}from"./chunk-6YGTRKDT.js";import{e as S}from"./chunk-UR6MHSHU.js";var e=S(K(),1);var r=S(O(),1);function V(n,x,c){return{id:n,label:`${x} (${n})`,isActive:n===c}}function se({resolver:n,currentProjectId:x,env:c,onSelect:w,onCancel:C}){let[q,B]=(0,e.useState)([]),[D,l]=(0,e.useState)(!0),[H,m]=(0,e.useState)(!1),[J,g]=(0,e.useState)(!1),[Q,P]=(0,e.useState)(null),[d,p]=(0,e.useState)("list"),[v,R]=(0,e.useState)(""),[E,h]=(0,e.useState)(null),[I,X]=(0,e.useState)(""),b=(0,e.useRef)(!1),A=(0,e.useRef)(!0);(0,e.useEffect)(()=>{if(!n){P("Login first to browse projects"),l(!1);return}let o=new AbortController,a=I.trim();return A.current?l(!0):a&&g(!0),m(!0),P(null),(async()=>{try{let t=n.cached??await n.resolve();if(!t){P("Login first to browse projects"),l(!1),m(!1),g(!1);return}let L=k(c),F=new T(L.tmsBaseUrl,t.username,t.access_key),f=!0,N=0,G=a?{signal:o.signal,name:a,perPage:10}:{signal:o.signal,perPage:10};for await(let y of F.listProjectsStream(G)){if(f&&(l(!1),g(!1),A.current=!1,f=!1),y.totalLoaded===0&&y.done&&N===0&&!a){b.current=!0,p("naming"),m(!1);return}let M=y.projects.map(j=>V(j.project_id,j.name,x));B(N===0?M:j=>[...j,...M]),N+=y.projects.length,y.done&&m(!1)}f&&(l(!1),m(!1),g(!1))}catch(t){if(t?.name==="AbortError")return;P(t instanceof Error?t.message:String(t)),l(!1),m(!1),g(!1)}})(),()=>o.abort()},[n,x,c,I]);let Y=(0,e.useCallback)(o=>{let a=o.trim();if(!a){h("Name cannot be empty");return}h(null),p("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let t=n.cached??await n.resolve();if(!t)throw new Error("Not authenticated");let L=k(c),f=await new T(L.tmsBaseUrl,t.username,t.access_key).createProject(a);w(f.id,f.name)}catch(t){h(t instanceof Error?t.message:String(t)),p("naming")}})()},[n,c,w]),z=(0,e.useCallback)(()=>{R(""),h(null),b.current?C():p("list")},[C]);return d==="naming"||d==="creating"?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(s,{color:i.orange,bold:!0,children:"Create new project"}),b.current&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.dim,children:"No projects yet \u2014 let's create one."})}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(s,{color:i.dim,children:"Name: "}),d==="naming"?(0,r.jsx)($,{value:v,onChange:o=>{R(o),E&&h(null)},onSubmit:Y,onCancel:z}):(0,r.jsx)(s,{children:v})]}),E&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.red,children:E})}),d==="creating"&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.dim,children:"Creating..."})}),d==="naming"&&(0,r.jsx)(_,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:b.current?"cancel":"back"})]}):(0,r.jsx)(U,{title:"Projects",items:q,loading:D,loadingMore:H,searching:J,preserveSelectionById:!0,onSearch:X,error:Q,itemNoun:"projects",onTab:()=>{b.current=!1,p("naming")},extraHint:"tab to create new",onSelect:o=>{let a=o.label.replace(` (${o.id})`,"");w(o.id,a)},onCancel:C})}export{V as a,se as b};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as k}from"./chunk-QJIJC3KC.js";import{y as u}from"./chunk-MMPFU2YC.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as m,b as s,k as b}from"./chunk-C44QQJR4.js";import{e as p}from"./chunk-UR6MHSHU.js";function B(t){let e=t;return e=e.replace(/@TS\{([^}]+)\}/g,"@S{$1}"),e=e.replace(/@TS-(\d+)/g,(o,i)=>`@S${parseInt(i,10)}.C1`),e=e.replace(/@TS(\d+)/g,(o,i)=>`@S${parseInt(i,10)}`),e=e.replace(/\\n/g,`
|
|
3
|
+
`),e}var c=p(f(),1),S=t=>t!==void 0&&/[A-Za-z0-9]/.test(t);function x(t){let e=[],o="",i=()=>{o&&(e.push({text:o}),o="")},d=(a,l,r)=>(a===0||!S(t[a-1]))&&(l+r>=t.length||!S(t[l+r])),n=0;for(;n<t.length;){let a=t.slice(n,n+2),l=t[n];if(a==="**"||a==="__"){let r=t.indexOf(a,n+2);if(r!==-1&&r>n+2&&(a==="**"||d(n,r,2))){i(),e.push({text:t.slice(n+2,r),bold:!0}),n=r+2;continue}}if(l==="`"){let r=t.indexOf("`",n+1);if(r!==-1&&r>n+1){i(),e.push({text:t.slice(n+1,r),code:!0}),n=r+1;continue}}if(l==="*"||l==="_"){let r=t.indexOf(l,n+1);if(r!==-1&&r>n+1&&(l==="*"||d(n,r,1))){i(),e.push({text:t.slice(n+1,r),italic:!0}),n=r+1;continue}}o+=l,n+=1}return i(),e.length===0&&e.push({text:""}),e}function h(t){return t.map((e,o)=>(0,c.jsx)(s,{bold:e.bold,italic:e.italic,color:e.code?u.dim:void 0,children:e.text},o))}function T(t){return t.split(`
|
|
4
|
+
`).map(e=>{if(e.trim()==="")return{kind:"blank"};let o=e.match(/^\s*[-*+]\s+(.*)$/);if(o)return{kind:"bullet",segs:x(o[1])};let i=e.match(/^\s*(\d+)\.\s+(.*)$/);if(i)return{kind:"numbered",n:i[1],segs:x(i[2])};let d=e.match(/^#{1,6}\s+(.*)$/);return d?{kind:"heading",segs:x(d[1])}:{kind:"para",segs:x(e)}})}function R(t,e,o=""){switch(t.kind){case"blank":return(0,c.jsx)(s,{children:o||" "},e);case"heading":return(0,c.jsxs)(s,{bold:!0,children:[o,h(t.segs)]},e);case"bullet":return(0,c.jsx)(m,{marginLeft:1,children:(0,c.jsxs)(s,{children:[o,"\u2022 ",h(t.segs)]})},e);case"numbered":return(0,c.jsx)(m,{marginLeft:1,children:(0,c.jsxs)(s,{children:[o,`${t.n}. `,h(t.segs)]})},e);default:return(0,c.jsxs)(s,{children:[o,h(t.segs)]},e)}}function $({text:t,accent:e=u.generateAccent}){let o=T(B(t)),{stdout:i}=b(),d=i?.columns??80;return(0,c.jsxs)(m,{marginBottom:1,children:[(0,c.jsx)(m,{width:2,flexShrink:0,children:(0,c.jsx)(s,{color:e,children:"\u2503"})}),(0,c.jsx)(m,{flexDirection:"column",width:d-2,children:o.map((n,a)=>R(n,a))})]})}var g=p(f(),1),I=5;function C({thinking:t,expanded:e,thinkingDone:o,maxLines:i=I}){if(!e)return(0,g.jsxs)(m,{paddingX:1,children:[(0,g.jsx)(s,{color:u.dim,children:o?"\u2237 thinking complete ":"\u2237 thinking\u2026 "}),(0,g.jsx)(s,{color:u.muted,children:o?"(ctrl+t to view)":"(ctrl+t to show)"})]});let d=t.split(`
|
|
5
|
+
`),n=Math.max(0,d.length-i),a=n>0?d.slice(-i).join(`
|
|
6
|
+
`):t;return(0,g.jsxs)(k,{variant:"default",paddingX:1,children:[n>0&&(0,g.jsxs)(s,{color:u.muted,children:["\u22EE (",n," earlier line",n===1?"":"s"," hidden)"]}),(0,g.jsx)(s,{color:u.dim,children:a}),o&&(0,g.jsx)(s,{color:u.muted,children:"\u2014 thinking complete"})]})}export{x as a,$ as b,C as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{existsSync as u}from"fs";import{dirname as f,resolve as i}from"path";import{fileURLToPath as d}from"url";var g=f(d(import.meta.url));function p(){return[i(g,".."),i(g,"../../..")]}function A(o){return{"darwin-arm64":"kane-cli-darwin-arm64","darwin-x64":"kane-cli-darwin-x64","linux-x64":"kane-cli-linux-x64","linux-arm64":"kane-cli-linux-arm64","win32-x64":"kane-cli-win-x64"}[o]??null}function h(){let o=A(`${process.platform}-${process.arch}`),n=process.platform==="win32"?"assurance-agent.exe":"assurance-agent";for(let r of p()){for(let s of o?["@testmuai","@lambdatestincprivate"]:[]){let e=i(r,"node_modules",s,o,"bin",n);if(u(e))return{cmd:e,args:[],tier:"platform"}}let a=i(r,"../assurance-agent/dist",n);if(u(a))return{cmd:a,args:[],tier:"sibling"};let t=i(r,"../assurance-agent/main.py");if(u(t)){let s=i(r,"../assurance-agent/.venv/bin/python");return{cmd:u(s)?s:"python3",args:[t],tier:"dev-python"}}}return null}function v(o,n={}){return{...process.env,...n,TESTMUAI_SOURCE:"kane-cli",TESTMUAI_SESSION_ID:o,ASSURANCE_LOG_LEVEL:process.env.ASSURANCE_LOG_LEVEL??"info"}}async function w(){if(process.env.TESTMUAI_API_KEY||process.env.TESTMUAI_BASIC_AUTH)return{};try{let{CredentialsManager:o}=await import("./credentials-
|
|
2
|
+
import{existsSync as u}from"fs";import{dirname as f,resolve as i}from"path";import{fileURLToPath as d}from"url";var g=f(d(import.meta.url));function p(){return[i(g,".."),i(g,"../../..")]}function A(o){return{"darwin-arm64":"kane-cli-darwin-arm64","darwin-x64":"kane-cli-darwin-x64","linux-x64":"kane-cli-linux-x64","linux-arm64":"kane-cli-linux-arm64","win32-x64":"kane-cli-win-x64"}[o]??null}function h(){let o=A(`${process.platform}-${process.arch}`),n=process.platform==="win32"?"assurance-agent.exe":"assurance-agent";for(let r of p()){for(let s of o?["@testmuai","@lambdatestincprivate"]:[]){let e=i(r,"node_modules",s,o,"bin",n);if(u(e))return{cmd:e,args:[],tier:"platform"}}let a=i(r,"../assurance-agent/dist",n);if(u(a))return{cmd:a,args:[],tier:"sibling"};let t=i(r,"../assurance-agent/main.py");if(u(t)){let s=i(r,"../assurance-agent/.venv/bin/python");return{cmd:u(s)?s:"python3",args:[t],tier:"dev-python"}}}return null}function v(o,n={}){return{...process.env,...n,TESTMUAI_SOURCE:"kane-cli",TESTMUAI_SESSION_ID:o,ASSURANCE_LOG_LEVEL:process.env.ASSURANCE_LOG_LEVEL??"info"}}async function w(){if(process.env.TESTMUAI_API_KEY||process.env.TESTMUAI_BASIC_AUTH)return{};try{let{CredentialsManager:o}=await import("./credentials-OGLK7MPV.js"),n=process.env.TESTMUAI_ENV==="stage"?"stage":"prod",r=new o,a=r.getActiveProfile()??"default",t={TESTMUAI_ENV:n},s=r.loadBasicAuth(a,n);if(s)return t.TESTMUAI_BASIC_AUTH=Buffer.from(`${s.username}:${s.access_key}`,"utf8").toString("base64"),t;let e=r.loadCredentials(a,n);if(e){try{let{refreshOAuthToken:l}=await import("./token-refresh-S7CYBZTE.js");await l({creds:r,profile:a,env:n,credentials:e})}catch{}let c=r.loadCredentials(a,n)??e;if(typeof c.access_token=="string"){let l=await E(n,c.access_token);return l?(t.TESTMUAI_BASIC_AUTH=l,t):(t.TESTMUAI_API_KEY=c.access_token,t)}}return{}}catch{return{}}}var _=8e3;function m(){return process.stderr.write("warn: session auth may expire during long runs \u2014 if that happens, run `kane-cli login` and retry\n"),null}async function E(o,n){if(process.env.TESTMUAI_BASE_URL)return null;try{let[{getEnvironment:r},{ControllerClient:a}]=await Promise.all([import("./config-QISRENF5.js"),import("./controller-client-RD2YEMAH.js")]),t=new a(r(o).controllerBaseUrl,n),s;try{let e=await Promise.race([t.getTmsCredentials().catch(()=>null),new Promise(c=>{s=setTimeout(()=>c(null),_)})]);return typeof e?.username!="string"||!e.username||typeof e.access_key!="string"||!e.access_key?m():Buffer.from(`${e.username}:${e.access_key}`,"utf8").toString("base64")}finally{clearTimeout(s)}}catch{return m()}}export{A as a,h as b,v as c,w as d};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as b}from"./chunk-
|
|
2
|
+
import{a as b}from"./chunk-4CJ55EUY.js";import{c as k}from"./chunk-RFHMDQXZ.js";import{a as C}from"./chunk-LHDNJJGE.js";import{q as m,r as u,s as f,t as x,u as y}from"./chunk-MMPFU2YC.js";import{createServer as S}from"http";import{randomBytes as A}from"crypto";import{URL as L}from"url";var P=class{profile;environment;creds;oauth;constructor(r="default",o="prod",e){this.profile=r,this.environment=o,this.creds=e??new C,this.oauth=new b(o)}async login(){let{server:r,port:o}=await this.startCallbackServer(),e=y(o);try{let t=this.creds.loadClient(this.profile,this.environment),i=t?.redirect_uris;(!t||!i?.includes(e))&&(t=await this.oauth.registerClient(e),this.creds.saveClient(this.profile,this.environment,t));let c=t.client_id,[h,d]=b.generatePkce(),a=A(32).toString("hex"),n=this.oauth.buildAuthorizationUrl(c,d,a,e),l=await this.waitForCallback(r,o,n,a);if(!l)throw new Error("Login cancelled or timed out");let p=await this.oauth.exchangeCode(l,c,h,e),g={access_token:p.access_token,refresh_token:p.refresh_token,expires_at:Math.floor(Date.now()/1e3)+p.expires_in,scope:p.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,g),this.creds.setActiveProfile(this.profile),g}catch(t){throw r.close(),t}}startCallbackServer(){return new Promise((r,o)=>{let e=u,t=()=>{let i=S();i.on("error",c=>{c.code==="EADDRINUSE"&&e<f?(e++,t()):o(new Error(`Failed to start callback server: ${c.message}. Ports ${u}-${f} are all in use.`))}),i.listen(e,m,()=>{r({server:i,port:e})})};t()})}waitForCallback(r,o,e,t){return new Promise(i=>{let c=!1,h=setTimeout(()=>d(null),12e4),d=a=>{c||(c=!0,clearTimeout(h),r.close(),i(a))};r.on("request",(a,n)=>{let l=new L(a.url??"/",`http://${m}:${o}`);if(l.pathname!==x){n.writeHead(404),n.end();return}let p=l.searchParams.get("state"),g=l.searchParams.get("code");if(l.searchParams.get("error")){n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),d(null);return}if(p!==t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),d(null);return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),d(g)}),k(e).catch(a=>{let n=a instanceof Error?a.message:String(a);process.stderr.write(`[auth] Could not open browser: ${n}
|
|
3
3
|
Please open this URL manually: ${e}
|
|
4
4
|
`)})})}};function v(s){let r=s.state==="success",o=r?"#22c55e":"#ef4444",e=r?"rgba(34, 197, 94, 0.12)":"rgba(239, 68, 68, 0.12)",t=r?'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7"/></svg>':'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',i=s.autoClose?"<script>setTimeout(function(){try{window.close();}catch(e){}}, 1500);</script>":"";return`<!doctype html>
|
|
5
5
|
<html lang="en">
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as H,d as z}from"./chunk-2YQ6TW77.js";import{b as p,c as E,d as j,e as y,f as M,g as C,i as A,l as D,m as F,p as T,r as $,s as O}from"./chunk-RKWJG3WW.js";import{a as B}from"./chunk-
|
|
2
|
+
import{c as H,d as z}from"./chunk-2YQ6TW77.js";import{b as p,c as E,d as j,e as y,f as M,g as C,i as A,l as D,m as F,p as T,r as $,s as O}from"./chunk-RKWJG3WW.js";import{a as B}from"./chunk-3AZTXJY4.js";import{p as R,q as k}from"./chunk-Y5RNCJAN.js";import{a as P}from"./chunk-MMPFU2YC.js";import{e as q}from"./chunk-UR6MHSHU.js";import{existsSync as f,mkdirSync as V,readFileSync as Z,renameSync as N,writeFileSync as K}from"fs";import{join as Q}from"path";function fe(e){D(p(e));let t=p(e);if(!f(t))return;let n=Q(t,"meta.json"),r=y(e);if(f(n)&&!f(r))try{V(j(e),{recursive:!0}),N(n,r)}catch(o){process.stderr.write(`warn: meta.json migration failed: ${o.message}
|
|
3
3
|
`)}let i=C(e);if(f(i)){let o="python";try{let c=new B().load();c.code_export?.language&&(o=c.code_export.language)}catch{}let a=M(e,"playwright",o);if(!f(a))try{N(i,a)}catch(c){process.stderr.write(`warn: generated-code migration failed: ${c.message}
|
|
4
4
|
`)}}if(f(r))try{let o=JSON.parse(Z(r,"utf8"));"md5sum"in o&&(delete o.md5sum,K(r,JSON.stringify(o,null,2)+`
|
|
5
5
|
`,"utf8"))}catch(o){process.stderr.write(`warn: meta.json md5sum strip failed: ${o.message}
|
|
6
|
-
`)}}async function ye(e){if(!e.isInteractive)return{recovered:!1};if(W(e.creds))return{recovered:!1};let{SingleShotApp:t}=await import("./SingleShotApp-
|
|
6
|
+
`)}}async function ye(e){if(!e.isInteractive)return{recovered:!1};if(W(e.creds))return{recovered:!1};let{SingleShotApp:t}=await import("./SingleShotApp-A6PCNPLM.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{render:r}=await import("./build-JIKYOZUH.js"),i=await import("./react-QWOAB3TB.js"),o={current:null},a={current:!1},{waitUntilExit:c,unmount:l}=r(i.default.createElement(n,null,i.default.createElement(t,{resultRef:o,mode:"login",loginCompleteRef:a})),{exitOnCtrlC:!1});k(()=>l()),await c();try{process.stdin.setRawMode?.(!1)}catch{}return process.stdout.write("\x1B[?25h"),a.current?{recovered:!0}:(R(0,"Startup gate cancelled"),{recovered:!1})}function W(e){let t=e.getActiveProfile(),n=e.getDefaultEnv();if(!t||!!!(e.loadBasicAuth(t,n)||e.loadCredentials(t,n)))return!1;let i=e.loadProfileConfig(t,n)??{};return!!i.project_id&&!!i.folder_id}var J=q(H(),1);import{existsSync as v,readFileSync as U,readdirSync as X,statSync as Y}from"fs";import{dirname as ee,isAbsolute as te,join as g,relative as x,resolve as re,sep as h}from"path";import{createHash as ne}from"crypto";var S="testmd-bundle.json",d=class extends Error{constructor(t){super(t),this.name="BundleUsageError"}},_=e=>e.split(h).join("/");function I(e){if(!v(e))return[];let t=[];for(let n of X(e).sort()){let r=g(e,n);Y(r).isDirectory()?t.push(...I(r)):t.push(r)}return t}function se(e){let t=e.map(r=>ee(r).split(h)),n=t[0];for(let r of t.slice(1)){let i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;n=n.slice(0,i)}return n.join(h)||h}function ie(e){for(let t of e){let n=F(t,U(t,"utf8"));for(let r of n.steps)if(r.body.kind==="import_ref"&&te(r.body.path))throw new d(`bundle sync: absolute @import is not portable after unzip: ${t} step ${r.index} (@import ${r.body.path})`)}}function G(e){let t=re(e),n=T(t);if(!n?.commit_id||!n?.test_id)throw new d(`bundle sync: ${t} is not authored \u2014 run \`kane-cli testmd run\` first (output-<stem>/.internal/meta.json needs commit_id + test_id)`);let r;try{r=O(t)}catch(s){throw s instanceof $?new d(`bundle sync: ${s.message}`):s}let i=[t];for(let s of r.steps)for(let u of s.trace.slice(1))i.includes(u.file)||i.push(u.file);ie(i);let o=[];for(let s of r.unitFiles){if(s.file===t)continue;let u=p(s.file);o.includes(u)||o.push(u)}let a=[...i],c=s=>{v(s)&&a.push(s)};c(E(t)),a.push(y(t)),c(g(p(t),".internal","execution.json")),a.push(...I(A(t)));for(let s of o)c(g(s,"Result.md")),a.push(...I(g(s,".internal","steps")));let l=se(a);if(v(g(l,S)))throw new d(`bundle sync: a real file named ${S} exists at the zip root (${l}) \u2014 it would collide with the generated manifest`);let b=a.map(s=>{let u=U(s);return{abs:s,rel:_(x(l,s)),sha256:ne("sha256").update(u).digest("hex"),bytes:u.length}}).sort((s,u)=>s.rel<u.rel?-1:1),m=_(x(l,t)),L={schema_version:2,entry:m,commit_id:n.commit_id,test_id:n.test_id,testcase_id:n.testcase_id??null,project_id:n.project_id??null,folder_id:n.folder_id??null,org_id:n.org_id??null,created_at:new Date().toISOString(),producer:{name:"kane-cli",version:P},files:b.map(s=>({path:s.rel,sha256:s.sha256,bytes:s.bytes})),units:r.unitFiles.filter(s=>s.file!==t).map(s=>({path:_(x(l,s.file)),kind:s.kind}))};return{zipRoot:l,entry:m,files:b,manifest:L}}var w=e=>e instanceof Error?e.message:String(e);function oe(e){return new Promise((t,n)=>{let r=(0,J.default)("zip",{zlib:{level:6}}),i=[];r.on("data",o=>i.push(o)),r.on("error",n),r.on("end",()=>t(Buffer.concat(i))),r.append(JSON.stringify(e.manifest,null,2)+`
|
|
7
7
|
`,{name:S});for(let o of e.files)r.file(o.abs,{name:o.rel});r.finalize()})}async function ae(e){let{plan:t,controller:n,testId:r,sessionId:i,commitId:o}=e,a;try{a=await oe(t)}catch(l){return{ok:!1,stage:"zip",error:w(l)}}let c;try{let l={key:"testmd",content_type:"application/zip",filename:`${o}-testmd.zip`},m=(await n.getPresignedUrls(r,i,[l])).urls?.testmd?.upload_url;if(!m)return{ok:!1,stage:"presign",error:"presign response missing testmd upload_url"};c=m}catch(l){return{ok:!1,stage:"presign",error:w(l)}}try{await z(c,a,"application/zip")}catch(l){return{ok:!1,stage:"upload",error:w(l)}}return{ok:!0,bytes:a.length}}async function Ee(e){let t;try{t=G(e.sourcePath)}catch(n){return n instanceof d?{ok:!1,stage:"collect",error:n.message}:{ok:!1,stage:"collect",error:w(n)}}return ae({...e,plan:t})}function je(e){return e.shouldUploadPipeline&&e.uploadSucceeded&&!!e.metaCommitId&&!!e.metaTestId}export{fe as a,ye as b,Ee as c,je as d};
|