@visulima/vis 2.0.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/LICENSE.md +95 -65
  3. package/dist/bin.js +1 -1
  4. package/dist/binx.js +1 -1
  5. package/dist/packem_chunks/CONFIG_FILES.js +2 -2
  6. package/dist/packem_chunks/bloom-status.js +1 -1
  7. package/dist/packem_chunks/bloom-sync.js +1 -1
  8. package/dist/packem_chunks/catalog.js +47 -47
  9. package/dist/packem_chunks/cli-exec.js +1 -1
  10. package/dist/packem_chunks/cli-main.js +141 -141
  11. package/dist/packem_chunks/dispatch.js +1 -1
  12. package/dist/packem_chunks/fix.js +1 -1
  13. package/dist/packem_chunks/handler.js +1 -1
  14. package/dist/packem_chunks/handler10.js +1 -1
  15. package/dist/packem_chunks/handler11.js +1 -1
  16. package/dist/packem_chunks/handler12.js +1 -1
  17. package/dist/packem_chunks/handler13.js +1 -1
  18. package/dist/packem_chunks/handler14.js +1 -1
  19. package/dist/packem_chunks/handler15.js +1 -1
  20. package/dist/packem_chunks/handler16.js +1 -1
  21. package/dist/packem_chunks/handler17.js +1 -1
  22. package/dist/packem_chunks/handler18.js +1 -1
  23. package/dist/packem_chunks/handler19.js +1 -1
  24. package/dist/packem_chunks/handler2.js +1 -1
  25. package/dist/packem_chunks/handler20.js +1 -1
  26. package/dist/packem_chunks/handler21.js +1 -1
  27. package/dist/packem_chunks/handler22.js +1 -1
  28. package/dist/packem_chunks/handler23.js +1 -1
  29. package/dist/packem_chunks/handler24.js +1 -1
  30. package/dist/packem_chunks/handler26.js +1 -1
  31. package/dist/packem_chunks/handler27.js +1 -1
  32. package/dist/packem_chunks/handler28.js +1 -1
  33. package/dist/packem_chunks/handler29.js +1 -1
  34. package/dist/packem_chunks/handler3.js +1 -1
  35. package/dist/packem_chunks/handler30.js +1 -1
  36. package/dist/packem_chunks/handler4.js +1 -1
  37. package/dist/packem_chunks/handler5.js +1 -1
  38. package/dist/packem_chunks/handler50.js +1 -1
  39. package/dist/packem_chunks/handler51.js +1 -1
  40. package/dist/packem_chunks/handler53.js +1 -1
  41. package/dist/packem_chunks/handler54.js +1 -1
  42. package/dist/packem_chunks/handler55.js +1 -1
  43. package/dist/packem_chunks/handler58.js +1 -1
  44. package/dist/packem_chunks/handler59.js +1 -1
  45. package/dist/packem_chunks/handler6.js +1 -1
  46. package/dist/packem_chunks/handler60.js +1 -1
  47. package/dist/packem_chunks/handler61.js +1 -1
  48. package/dist/packem_chunks/handler62.js +1 -1
  49. package/dist/packem_chunks/handler63.js +1 -1
  50. package/dist/packem_chunks/handler64.js +1 -1
  51. package/dist/packem_chunks/handler66.js +1 -1
  52. package/dist/packem_chunks/handler67.js +13 -13
  53. package/dist/packem_chunks/handler68.js +1 -1
  54. package/dist/packem_chunks/handler69.js +1 -1
  55. package/dist/packem_chunks/handler7.js +1 -1
  56. package/dist/packem_chunks/handler70.js +5 -5
  57. package/dist/packem_chunks/handler71.js +1 -1
  58. package/dist/packem_chunks/handler72.js +1 -1
  59. package/dist/packem_chunks/handler73.js +1 -1
  60. package/dist/packem_chunks/handler74.js +15 -15
  61. package/dist/packem_chunks/handler75.js +1 -1
  62. package/dist/packem_chunks/handler76.js +1 -1
  63. package/dist/packem_chunks/handler77.js +1 -1
  64. package/dist/packem_chunks/handler78.js +1 -1
  65. package/dist/packem_chunks/handler8.js +1 -1
  66. package/dist/packem_chunks/handler9.js +1 -1
  67. package/dist/packem_chunks/heal-accept.js +1 -1
  68. package/dist/packem_chunks/heal.js +1 -1
  69. package/dist/packem_chunks/help-command.js +1 -1
  70. package/dist/packem_chunks/index2.js +6 -4
  71. package/dist/packem_chunks/index3.js +1 -1
  72. package/dist/packem_chunks/index4.js +49 -49
  73. package/dist/packem_chunks/keys-refresh.js +1 -1
  74. package/dist/packem_chunks/lean.js +1 -1
  75. package/dist/packem_chunks/list.js +1 -1
  76. package/dist/packem_chunks/loader.js +1 -1
  77. package/dist/packem_chunks/orchestrator.js +2 -2
  78. package/dist/packem_chunks/prune.js +1 -1
  79. package/dist/packem_chunks/registry.js +10 -10
  80. package/dist/packem_chunks/status.js +1 -1
  81. package/dist/packem_chunks/sync.js +1 -1
  82. package/dist/packem_chunks/sync2.js +1 -1
  83. package/dist/packem_chunks/tripwire.js +1 -1
  84. package/dist/packem_chunks/ts-loader.js +1 -1
  85. package/dist/packem_chunks/verify-lockfile.js +1 -1
  86. package/dist/packem_shared/{advisories-CCBGdU8U.js → advisories-DsXRmIA5.js} +1 -1
  87. package/dist/packem_shared/{affected-selection-Dj-ymxhw.js → affected-selection-BE6VFCDV.js} +1 -1
  88. package/dist/packem_shared/{affected-shas-PwkVbPch.js → affected-shas-BKEu4RZc.js} +1 -1
  89. package/dist/packem_shared/{ai-analysis-bGCAc1jR.js → ai-analysis-DikAj6rX.js} +1 -1
  90. package/dist/packem_shared/{ai-fix-DV5-dHBY.js → ai-fix-bfWo0cZX.js} +1 -1
  91. package/dist/packem_shared/{augment-24KX2nkI.js → augment-BkJxi_GW.js} +1 -1
  92. package/dist/packem_shared/{bin-CtzhnYMp.js → bin-B-TytgzW.js} +1 -1
  93. package/dist/packem_shared/{build-scripts-w4SNeR7D.js → build-scripts-DWypBQ--.js} +1 -1
  94. package/dist/packem_shared/{command-runtime-BLFPUYAT.js → command-runtime-DQ7ZpLYL.js} +1 -1
  95. package/dist/packem_shared/{cyclonedx-C4KaVTn1.js → cyclonedx-DLBi65MV.js} +1 -1
  96. package/dist/packem_shared/dependency-scan-ZLOuLkGN.js +1 -0
  97. package/dist/packem_shared/{docker-DaVs-9wK.js → docker-B4zAZCZG.js} +15 -15
  98. package/dist/packem_shared/{en-D3CfXlO7.js → en-BDYMmM2_.js} +1 -1
  99. package/dist/packem_shared/{failure-log-CTneNcio.js → failure-log-DyhWPqno.js} +1 -1
  100. package/dist/packem_shared/glob-BUjyjdE8-Dp_QcayW.js +1 -0
  101. package/dist/packem_shared/index-BLtnel38.js +35 -0
  102. package/dist/packem_shared/index-CuKDxOCI.js +1 -0
  103. package/dist/packem_shared/index-tNFGWxc0.js +39 -0
  104. package/dist/packem_shared/{lifecycle-B8A2T3gx.js → lifecycle-KY9umOg6.js} +1 -1
  105. package/dist/packem_shared/{lockfile-Bccery3L.js → lockfile-YAuZf1gh.js} +1 -1
  106. package/dist/packem_shared/{manifests-BDkwiVbh.js → manifests-BwTn_1ad.js} +1 -1
  107. package/dist/packem_shared/{min-release-age-OaYpLwux.js → min-release-age-6avfn81h.js} +1 -1
  108. package/dist/packem_shared/{missing-package-json-BqS-OnKd.js → missing-package-json-Cl0vdz6K.js} +1 -1
  109. package/dist/packem_shared/{native-config-sync-Ds1FtcrM.js → native-config-sync-CHMCJx7H.js} +7 -7
  110. package/dist/packem_shared/{osv-bloom-pKp7urSB.js → osv-bloom-DdqDnLCt.js} +2 -2
  111. package/dist/packem_shared/package-version-BNRJ3o9C.js +4 -0
  112. package/dist/packem_shared/{packument-HBVbyf7x.js → packument-B9-WqReu.js} +1 -1
  113. package/dist/packem_shared/{pm-runner-C6eTANt1.js → pm-runner-DRybtzOV.js} +1 -1
  114. package/dist/packem_shared/{project-name-filter-CJ3XX2TI.js → project-name-filter-Dw0fC6IO.js} +1 -1
  115. package/dist/packem_shared/{provenance-D4Cza8cp.js → provenance-CLxuqCfL.js} +1 -1
  116. package/dist/packem_shared/{readJsonSync-DweZd5ZA-0eZh9sGm.js → readJsonSync-DweZd5ZA-CtrDlqpb.js} +1 -1
  117. package/dist/packem_shared/{registry-keys-C0ez2VND.js → registry-keys-cTN24144.js} +1 -1
  118. package/dist/packem_shared/{resolve-explicit-BbT764KS.js → resolve-explicit-Uw6WQl9R.js} +1 -1
  119. package/dist/packem_shared/{resolve-runtime-D_vZovbB.js → resolve-runtime-DztanwkZ.js} +1 -1
  120. package/dist/packem_shared/{run-file-DyPFFN9U.js → run-file-CaE5_xBY.js} +1 -1
  121. package/dist/packem_shared/{runtime-check-D4um-yQq.js → runtime-check-C32yE57I.js} +1 -1
  122. package/dist/packem_shared/{s1ngularity-St6dhKiq.js → s1ngularity-BIYhg82u.js} +1 -1
  123. package/dist/packem_shared/{scan-progress-q-N2JtIp.js → scan-progress-DWfY4zkp.js} +1 -1
  124. package/dist/packem_shared/{selectors-Ce_6UAoY.js → selectors-D2j4M9Ul.js} +1 -1
  125. package/dist/packem_shared/{signatures-Dyeyg1q9.js → signatures-C8iQ5fUq.js} +1 -1
  126. package/dist/packem_shared/target-merge-DLxJTcxn.js +11 -0
  127. package/dist/packem_shared/{target-options-7XcbqGDe.js → target-options-3t4-2F-F.js} +1 -1
  128. package/dist/packem_shared/{toolchain-C_pNMBM6.js → toolchain-BPzbahcQ.js} +1 -1
  129. package/dist/packem_shared/{typosquats-xzcAGPiM.js → typosquats-BWrmhh36.js} +1 -1
  130. package/dist/packem_shared/{use-measured-height-CBjN0fle.js → use-measured-height-BwAwGHjw.js} +1 -1
  131. package/dist/packem_shared/verify-CzUPT6Uk.js +1 -0
  132. package/dist/packem_shared/{vis-update-app-DMAC2pPf.js → vis-update-app-D6Wq8ZHM.js} +1 -1
  133. package/dist/packem_shared/{vis-user-error-xmha3L4n.js → vis-user-error-CfM4_ORo.js} +1 -1
  134. package/dist/packem_shared/{watch-BXOOX7lx.js → watch-D_oAxW_Z.js} +1 -1
  135. package/dist/packem_shared/{watch-loop-Q7UpkVbr.js → watch-loop-BrjblOz5.js} +1 -1
  136. package/dist/runtime/preload.js +1 -1
  137. package/index.d.ts +204 -204
  138. package/index.js +26 -26
  139. package/package.json +13 -13
  140. package/dist/packem_shared/dependency-scan-D_ona0Qm.js +0 -1
  141. package/dist/packem_shared/glob-BUjyjdE8-C4M8e02u.js +0 -1
  142. package/dist/packem_shared/index-CTMU29dI.js +0 -1
  143. package/dist/packem_shared/index-uBVnF4ji.js +0 -35
  144. package/dist/packem_shared/package-version-C47v64aB.js +0 -4
  145. package/dist/packem_shared/public-api-WqUCiyIe.js +0 -131
  146. package/dist/packem_shared/target-merge-Cfy7c__2.js +0 -11
  147. package/dist/packem_shared/verify-Dve9PQj3.js +0 -1
@@ -1,4 +1,4 @@
1
- import{createRequire as sr}from"node:module";import{w as oe,J as $s,K as nr,b as or,j as bs,z as ar,p as cr}from"../packem_shared/index-uBVnF4ji.js";import{expandAffected as lr,getChangedFiles as dr,buildEnhancedPath as ur,enforceProjectConstraints as hr,expandTokensInString as Ht,parsePartition as fr,TaskScheduler as pr,createTaskGraph as gr,reverseTaskGraph as mr,resolveTurboEnvCompat as wr,CompositeLifeCycle as Yt,defaultTaskRunner as Jt,createLogReporter as vr,readLastRunSummary as yr,getLastRunSummaryPath as kr,runConcurrently as Ze,generateRunSummary as Kt,writeChromeTrace as xr,writeRunSummary as jr,TerminalBuffer as wt}from"@visulima/task-runner";import{I as Ve}from"../packem_shared/index-BWl4DbMp.js";import{J as $r,I as br,K as Xt,M as Sr,P as Tr,ah as Ir,b as Cr,ai as Rr,aj as Er,ak as Mr,al as Fr}from"./cli-main.js";import{r as H,l as i,m,i as c,h as he,R as X,X as Pr,C as Or,v as Ar,S as Dr}from"./catalog.js";import{a as Xe}from"../packem_shared/vis-user-error-xmha3L4n.js";import{d as Br,r as Lr}from"../packem_shared/lockfile-Bccery3L.js";import{a as Ss}from"../packem_shared/public-api-WqUCiyIe.js";import{F as Vr}from"../packem_shared/failure-log-CTneNcio.js";import{r as Hr}from"../packem_shared/command-runtime-BLFPUYAT.js";import{r as Yr}from"../packem_shared/toolchain-C_pNMBM6.js";import{i as Jr,r as Kr,s as Xr,a as Qr,c as Zr,d as ei,e as ti,H as si,f as ri,b as ii}from"../packem_shared/lifecycle-B8A2T3gx.js";import{s as ni}from"../packem_shared/affected-selection-Dj-ymxhw.js";import{c as Zt,p as oi,a as ai,b as ci,r as li,f as di,s as ui}from"../packem_shared/project-name-filter-CJ3XX2TI.js";import{p as hi,r as fi,f as pi,a as gi}from"../packem_shared/selectors-Ce_6UAoY.js";import{r as ot,l as yt,d as mi,s as wi,m as vi,a as yi}from"../packem_shared/target-options-7XcbqGDe.js";import{o as ki,l as xi,c as et}from"../packem_shared/en-D3CfXlO7.js";import{T as Ts,C as Is,D as at,E as Cs}from"../packem_shared/symbols-DPTlrJ3B.js";import{Dialog as ji}from"@visulima/tui-kit/dialog";import{V as ut,E as ts,q as Ii,j as Ci}from"../packem_shared/index.server-CusjRLCh.js";import{parseStacktrace as Ri,codeFrame as Ei}from"@visulima/error";import{originalPositionFor as Mi,sourceContentFor as Fi,loadSourceMap as Pi}from"@visulima/source-map";import{ScrollView as Rs}from"@visulima/tui-kit/scroll-view";import{Spinner as Es}from"@visulima/tui-kit/spinner";import{c as ss,a as Li,s as rs}from"../packem_shared/watch-BXOOX7lx.js";import pt from"./index.js";let rr;const ir=s=>(rr??=sr(import.meta.url))(s),ze=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ee=s=>{if(typeof ze<"u"&&ze.versions&&ze.versions.node){const[e,t]=ze.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return ze.getBuiltinModule(s)}return ir(s)},{existsSync:Ae,mkdirSync:Nr,writeFileSync:vt,readFileSync:Ge,openSync:Gr,statSync:Qt,readSync:_r,closeSync:qr,mkdtempSync:Wr}=Ee("node:fs"),{createInterface:Ur,emitKeypressEvents:zr}=Ee("node:readline"),{isAbsolute:$i,resolve:es,dirname:bi,relative:Si}=Ee("node:path"),{fileURLToPath:Ti}=Ee("node:url"),{createHash:Oi}=Ee("node:crypto"),{mkdir:Ai,appendFile:ct}=Ee("node:fs/promises"),{platform:Di,homedir:kt,tmpdir:Bi}=Ee("node:os"),{spawn:Ni}=Ee("node:child_process"),Ms=s=>s===155||s===157||s===144||s===152||s===158||s===159,Fs=(s,e)=>{for(let t=e;t<s.length;t+=1){const r=s.codePointAt(t);if(r>=64&&r<=126)return t}return-1},tt=(s,e,t)=>{for(let r=e;r<s.length;r+=1){const a=s.codePointAt(r);if(a===156||t&&a===7)return r;if(a===27&&s.codePointAt(r+1)===92)return r+1}return-1},Gi=(s,e)=>{const t=s.codePointAt(e+1);return t===91?Fs(s,e+2):t===93?tt(s,e+2,!0):t===80||t===88||t===94||t===95?tt(s,e+2,!1):t!==void 0?e+1:-1},_i=(s,e)=>{const t=s.codePointAt(e);return t===155?Fs(s,e+1):t===157?tt(s,e+1,!0):t===144||t===152||t===158||t===159?tt(s,e+1,!1):-1},qi=s=>{if(s.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<s.length;e+=1)if(Ms(s.codePointAt(e)))return!0;return!1},Wi=s=>{if(!qi(s))return s;let e="",t=0,r=0;const{length:a}=s;for(;r<a;){const o=s.codePointAt(r);let n;if(o===27)n=Gi(s,r);else if(Ms(o))n=_i(s,r);else{r+=1;continue}n===-1&&(n=a-1),e+=s.slice(t,r),t=n+1,r=n+1}return e+=s.slice(t),e},is=new WeakSet,Ui=s=>{if(is.has(s))return;const e=["y","mo","w","d","h","m","s","ms"];for(const r of e)if(!Object.hasOwn(s,r))throw new TypeError(`Missing required property: ${r}`);if(s.future!==void 0&&typeof s.future!="string")throw new TypeError("Properties future and past must be of type string");if(s.past!==void 0&&typeof s.past!="string")throw new TypeError("Properties future and past must be of type string");const t=["y","mo","w","d","h","m","s","ms"];for(const r of t)if(typeof s[r]!="string"&&typeof s[r]!="function")throw new TypeError(`Property ${r} must be of type string or function`);if(s.decimal&&typeof s.decimal!="string")throw new TypeError("Property decimal must be of type string");if(s.delimiter&&typeof s.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(s._digitReplacements&&!Array.isArray(s._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(s._numberFirst&&typeof s._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(s.unitMap&&typeof s.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(s.unitMap&&Object.values(s.unitMap).some(r=>typeof r!="string"))throw new TypeError("All values in unitMap must be of type string");is.add(s)},Ps=(s,e)=>{if(!Number.isFinite(s)||e<0||Number.isInteger(s))return s;const t=10**e,r=Number((s*t).toPrecision(15));return Math.trunc(r)/t},ns=({unitCount:s,unitName:e},t,r)=>{let{spacer:a}=r;const{maxDecimalPoints:o}=r;let n=".";r.decimal!==void 0?n=r.decimal:t.decimal!==void 0&&(n=t.decimal);let d;"digitReplacements"in r?d=r.digitReplacements:"_digitReplacements"in t&&(d=t._digitReplacements);let u,g=s;o!==void 0&&(g=Ps(s,o));const h=g.toString();if(!t._hideCountIf2||s!==2)if(d){u="";for(const j of h)u+=j==="."?n:d[j]}else u=h.replace(".",n);else u="";const f=t[e];let l=f;return typeof f=="function"&&(l=f(s)),t._hideCountIf2&&s===2&&(a=""),t._numberFirst?l+a+u:u+a+l},zi=(s,e)=>{const{units:t}=e;if(t.length===0)return[];const{unitMeasures:r}=e,a=e.largest??Number.POSITIVE_INFINITY,o={};let n,d,u,g=s;for(d=0;d<t.length;d++){n=t[d];const f=r[n];u=d===t.length-1?g/f:Math.floor(g/f),o[n]=u,g-=u*f}if(e.round){let f=a;for(d=0;d<t.length;d++)if(n=t[d],u=o[n],u!==0&&(f--,f===0)){for(let l=d+1;l<t.length;l++){const j=t[l],C=o[j];o[n]=(o[n]??0)+C*r[j]/r[n],o[j]=0}break}for(d=t.length-1;d>=0;d--){if(n=t[d],u=o[n],u===0)continue;const l=Math.round(u);if(o[n]=l,d===0)break;const j=t[d-1],C=r[j],U=Math.floor(l*r[n]/C);if(U)o[j]=(o[j]??0)+U,o[n]=0;else break}}const h=[];for(d=0;d<t.length&&h.length<a;d++){if(n=t[d],u=o[n],u&&!e.round&&h.length===a-1){let f,l=0;for(f=d+1,t.length;f<t.length;f++){const j=t[f];l+=o[j]*(e.unitMeasures[j]/e.unitMeasures[n])}u+=l,e.maxDecimalPoints!==void 0&&(u=Ps(u,e.maxDecimalPoints))}u&&h.push({unitCount:u,unitName:n})}return h},Vi=(s,e,t)=>{const{language:r,units:a}=e;if(s.length===0){const f=a.at(-1);return ns({unitCount:0,unitName:f},r,e)}const{conjunction:o,serialComma:n}=e;let d=", ";e.delimiter!==void 0?d=e.delimiter:r.delimiter!==void 0&&(d=r.delimiter);let u="";e.timeAdverb&&t!==0&&(u=r.future??"",t<0&&(u=r.past??""));const g=s.map(f=>ns(f,r,e));let h;return!o||s.length===1?h=g.join(d):s.length===2?h=g.join(o):h=g.slice(0,-1).join(d)+(n?",":"")+o+(g.at(-1)??""),u&&(h=u.replace("%s",h)),h},Hi=(s,e)=>{if(Number.isNaN(s))throw new TypeError("Expected a valid number");if(typeof s!="number")throw new TypeError("Expected a number for milliseconds input");const t={conjunction:"",language:ki,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...e};Ui(t.language);const r=Math.abs(s),a=zi(r,t);return Vi(a,t,s)},be="@voidzero-dev/vite-task-client",xt="@visulima/task-runner-client",st=`npm:${xt}@^1`,Os=oe(".vis",".vite-client-override-declined"),rt="pnpm-workspace.yaml",Yi=["dependencies","devDependencies","optionalDependencies","peerDependencies"],As=s=>{try{return JSON.parse(Ge(s,"utf8"))}catch{return}},Ji=s=>{const e=oe(s,rt);if(Ae(e))try{return Ss(Ge(e,"utf8")).toJS()?.overrides}catch{return}},Ki=s=>s==="pnpm"||s==="aube"?"pnpm.overrides":s==="yarn"?"resolutions":"overrides",Xi=s=>{const e=oe(s,rt);try{const t=Ss(Ge(e,"utf8"));return t.setIn(["overrides",be],st),vt(e,t.toString()),!0}catch{return!1}},os=s=>s!==void 0&&Yi.some(e=>s[e]?.[be]!==void 0),Qi=(s,e)=>s!==void 0&&(s.pnpm?.overrides?.[be]!==void 0||s.overrides?.[be]!==void 0||s.resolutions?.[be]!==void 0)||e?.[be]!==void 0,Zi=(s,e=[])=>{const t=As(oe(s,"package.json")),r=Ae(oe(s,"node_modules","@voidzero-dev","vite-task-client"));return{alreadyOverridden:Qi(t,Ji(s)),declined:Ae(oe(s,Os)),manager:Br(s)?.manager,present:os(t)||r||e.some(a=>os(a))}},en=s=>{try{const e=oe(s,Os);Nr($s(e),{recursive:!0}),vt(e,`Declined adding the ${be} → ${xt} override.
1
+ import{createRequire as sr}from"node:module";import{w as oe,J as $s,K as nr,b as or,j as bs,z as ar,r as cr}from"../packem_shared/index-BLtnel38.js";import{expandAffected as lr,getChangedFiles as dr,buildEnhancedPath as ur,enforceProjectConstraints as hr,expandTokensInString as Ht,parsePartition as fr,TaskScheduler as pr,createTaskGraph as gr,reverseTaskGraph as mr,resolveTurboEnvCompat as wr,CompositeLifeCycle as Yt,defaultTaskRunner as Jt,createLogReporter as vr,readLastRunSummary as yr,getLastRunSummaryPath as kr,runConcurrently as Ze,generateRunSummary as Kt,writeChromeTrace as xr,writeRunSummary as jr,TerminalBuffer as wt}from"@visulima/task-runner";import{I as Ve}from"../packem_shared/index-BWl4DbMp.js";import{J as $r,I as br,K as Xt,M as Sr,P as Tr,ah as Ir,b as Cr,ai as Rr,aj as Er,ak as Mr,al as Fr}from"./cli-main.js";import{r as H,l as i,m,i as c,h as he,R as X,X as Pr,C as Or,v as Ar,S as Dr}from"./catalog.js";import{a as Xe}from"../packem_shared/vis-user-error-CfM4_ORo.js";import{d as Br,r as Lr}from"../packem_shared/lockfile-YAuZf1gh.js";import{I as Ss}from"../packem_shared/index-tNFGWxc0.js";import{F as Vr}from"../packem_shared/failure-log-DyhWPqno.js";import{r as Hr}from"../packem_shared/command-runtime-DQ7ZpLYL.js";import{r as Yr}from"../packem_shared/toolchain-BPzbahcQ.js";import{i as Jr,r as Kr,s as Xr,a as Qr,c as Zr,d as ei,e as ti,H as si,f as ri,b as ii}from"../packem_shared/lifecycle-KY9umOg6.js";import{s as ni}from"../packem_shared/affected-selection-BE6VFCDV.js";import{c as Zt,p as oi,a as ai,b as ci,r as li,f as di,s as ui}from"../packem_shared/project-name-filter-Dw0fC6IO.js";import{p as hi,r as fi,f as pi,a as gi}from"../packem_shared/selectors-D2j4M9Ul.js";import{r as ot,l as yt,d as mi,s as wi,m as vi,a as yi}from"../packem_shared/target-options-3t4-2F-F.js";import{o as ki,l as xi,c as et}from"../packem_shared/en-BDYMmM2_.js";import{T as Ts,C as Is,D as at,E as Cs}from"../packem_shared/symbols-DPTlrJ3B.js";import{Dialog as ji}from"@visulima/tui-kit/dialog";import{V as ut,E as ts,q as Ii,j as Ci}from"../packem_shared/index.server-CusjRLCh.js";import{parseStacktrace as Ri,codeFrame as Ei}from"@visulima/error";import{originalPositionFor as Mi,sourceContentFor as Fi,loadSourceMap as Pi}from"@visulima/source-map";import{ScrollView as Rs}from"@visulima/tui-kit/scroll-view";import{Spinner as Es}from"@visulima/tui-kit/spinner";import{c as ss,a as Li,s as rs}from"../packem_shared/watch-D_oAxW_Z.js";import pt from"./index.js";let rr;const ir=s=>(rr??=sr(import.meta.url))(s),ze=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ee=s=>{if(typeof ze<"u"&&ze.versions&&ze.versions.node){const[e,t]=ze.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return ze.getBuiltinModule(s)}return ir(s)},{existsSync:Ae,mkdirSync:Nr,writeFileSync:vt,readFileSync:Ge,openSync:Gr,statSync:Qt,readSync:_r,closeSync:qr,mkdtempSync:Wr}=Ee("node:fs"),{createInterface:Ur,emitKeypressEvents:zr}=Ee("node:readline"),{isAbsolute:$i,resolve:es,dirname:bi,relative:Si}=Ee("node:path"),{fileURLToPath:Ti}=Ee("node:url"),{createHash:Oi}=Ee("node:crypto"),{mkdir:Ai,appendFile:ct}=Ee("node:fs/promises"),{platform:Di,homedir:kt,tmpdir:Bi}=Ee("node:os"),{spawn:Ni}=Ee("node:child_process"),Ms=s=>s===155||s===157||s===144||s===152||s===158||s===159,Fs=(s,e)=>{for(let t=e;t<s.length;t+=1){const r=s.codePointAt(t);if(r>=64&&r<=126)return t}return-1},tt=(s,e,t)=>{for(let r=e;r<s.length;r+=1){const a=s.codePointAt(r);if(a===156||t&&a===7)return r;if(a===27&&s.codePointAt(r+1)===92)return r+1}return-1},Gi=(s,e)=>{const t=s.codePointAt(e+1);return t===91?Fs(s,e+2):t===93?tt(s,e+2,!0):t===80||t===88||t===94||t===95?tt(s,e+2,!1):t!==void 0?e+1:-1},_i=(s,e)=>{const t=s.codePointAt(e);return t===155?Fs(s,e+1):t===157?tt(s,e+1,!0):t===144||t===152||t===158||t===159?tt(s,e+1,!1):-1},qi=s=>{if(s.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<s.length;e+=1)if(Ms(s.codePointAt(e)))return!0;return!1},Wi=s=>{if(!qi(s))return s;let e="",t=0,r=0;const{length:a}=s;for(;r<a;){const o=s.codePointAt(r);let n;if(o===27)n=Gi(s,r);else if(Ms(o))n=_i(s,r);else{r+=1;continue}n===-1&&(n=a-1),e+=s.slice(t,r),t=n+1,r=n+1}return e+=s.slice(t),e},is=new WeakSet,Ui=s=>{if(is.has(s))return;const e=["y","mo","w","d","h","m","s","ms"];for(const r of e)if(!Object.hasOwn(s,r))throw new TypeError(`Missing required property: ${r}`);if(s.future!==void 0&&typeof s.future!="string")throw new TypeError("Properties future and past must be of type string");if(s.past!==void 0&&typeof s.past!="string")throw new TypeError("Properties future and past must be of type string");const t=["y","mo","w","d","h","m","s","ms"];for(const r of t)if(typeof s[r]!="string"&&typeof s[r]!="function")throw new TypeError(`Property ${r} must be of type string or function`);if(s.decimal&&typeof s.decimal!="string")throw new TypeError("Property decimal must be of type string");if(s.delimiter&&typeof s.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(s._digitReplacements&&!Array.isArray(s._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(s._numberFirst&&typeof s._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(s.unitMap&&typeof s.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(s.unitMap&&Object.values(s.unitMap).some(r=>typeof r!="string"))throw new TypeError("All values in unitMap must be of type string");is.add(s)},Ps=(s,e)=>{if(!Number.isFinite(s)||e<0||Number.isInteger(s))return s;const t=10**e,r=Number((s*t).toPrecision(15));return Math.trunc(r)/t},ns=({unitCount:s,unitName:e},t,r)=>{let{spacer:a}=r;const{maxDecimalPoints:o}=r;let n=".";r.decimal!==void 0?n=r.decimal:t.decimal!==void 0&&(n=t.decimal);let d;"digitReplacements"in r?d=r.digitReplacements:"_digitReplacements"in t&&(d=t._digitReplacements);let u,g=s;o!==void 0&&(g=Ps(s,o));const h=g.toString();if(!t._hideCountIf2||s!==2)if(d){u="";for(const j of h)u+=j==="."?n:d[j]}else u=h.replace(".",n);else u="";const f=t[e];let l=f;return typeof f=="function"&&(l=f(s)),t._hideCountIf2&&s===2&&(a=""),t._numberFirst?l+a+u:u+a+l},zi=(s,e)=>{const{units:t}=e;if(t.length===0)return[];const{unitMeasures:r}=e,a=e.largest??Number.POSITIVE_INFINITY,o={};let n,d,u,g=s;for(d=0;d<t.length;d++){n=t[d];const f=r[n];u=d===t.length-1?g/f:Math.floor(g/f),o[n]=u,g-=u*f}if(e.round){let f=a;for(d=0;d<t.length;d++)if(n=t[d],u=o[n],u!==0&&(f--,f===0)){for(let l=d+1;l<t.length;l++){const j=t[l],C=o[j];o[n]=(o[n]??0)+C*r[j]/r[n],o[j]=0}break}for(d=t.length-1;d>=0;d--){if(n=t[d],u=o[n],u===0)continue;const l=Math.round(u);if(o[n]=l,d===0)break;const j=t[d-1],C=r[j],U=Math.floor(l*r[n]/C);if(U)o[j]=(o[j]??0)+U,o[n]=0;else break}}const h=[];for(d=0;d<t.length&&h.length<a;d++){if(n=t[d],u=o[n],u&&!e.round&&h.length===a-1){let f,l=0;for(f=d+1,t.length;f<t.length;f++){const j=t[f];l+=o[j]*(e.unitMeasures[j]/e.unitMeasures[n])}u+=l,e.maxDecimalPoints!==void 0&&(u=Ps(u,e.maxDecimalPoints))}u&&h.push({unitCount:u,unitName:n})}return h},Vi=(s,e,t)=>{const{language:r,units:a}=e;if(s.length===0){const f=a.at(-1);return ns({unitCount:0,unitName:f},r,e)}const{conjunction:o,serialComma:n}=e;let d=", ";e.delimiter!==void 0?d=e.delimiter:r.delimiter!==void 0&&(d=r.delimiter);let u="";e.timeAdverb&&t!==0&&(u=r.future??"",t<0&&(u=r.past??""));const g=s.map(f=>ns(f,r,e));let h;return!o||s.length===1?h=g.join(d):s.length===2?h=g.join(o):h=g.slice(0,-1).join(d)+(n?",":"")+o+(g.at(-1)??""),u&&(h=u.replace("%s",h)),h},Hi=(s,e)=>{if(Number.isNaN(s))throw new TypeError("Expected a valid number");if(typeof s!="number")throw new TypeError("Expected a number for milliseconds input");const t={conjunction:"",language:ki,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...e};Ui(t.language);const r=Math.abs(s),a=zi(r,t);return Vi(a,t,s)},be="@voidzero-dev/vite-task-client",xt="@visulima/task-runner-client",st=`npm:${xt}@^1`,Os=oe(".vis",".vite-client-override-declined"),rt="pnpm-workspace.yaml",Yi=["dependencies","devDependencies","optionalDependencies","peerDependencies"],As=s=>{try{return JSON.parse(Ge(s,"utf8"))}catch{return}},Ji=s=>{const e=oe(s,rt);if(Ae(e))try{return Ss(Ge(e,"utf8")).toJS()?.overrides}catch{return}},Ki=s=>s==="pnpm"||s==="aube"?"pnpm.overrides":s==="yarn"?"resolutions":"overrides",Xi=s=>{const e=oe(s,rt);try{const t=Ss(Ge(e,"utf8"));return t.setIn(["overrides",be],st),vt(e,t.toString()),!0}catch{return!1}},os=s=>s!==void 0&&Yi.some(e=>s[e]?.[be]!==void 0),Qi=(s,e)=>s!==void 0&&(s.pnpm?.overrides?.[be]!==void 0||s.overrides?.[be]!==void 0||s.resolutions?.[be]!==void 0)||e?.[be]!==void 0,Zi=(s,e=[])=>{const t=As(oe(s,"package.json")),r=Ae(oe(s,"node_modules","@voidzero-dev","vite-task-client"));return{alreadyOverridden:Qi(t,Ji(s)),declined:Ae(oe(s,Os)),manager:Br(s)?.manager,present:os(t)||r||e.some(a=>os(a))}},en=s=>{try{const e=oe(s,Os);Nr($s(e),{recursive:!0}),vt(e,`Declined adding the ${be} → ${xt} override.
2
2
  Delete this file to be asked again.
3
3
  `)}catch{}},tn=(s,e="npm")=>{const t=`${e} install`;if((e==="pnpm"||e==="aube")&&Ae(oe(s,rt))&&Xi(s))return{file:rt,installCommand:t};const r=oe(s,"package.json"),a=As(r);if(!a)return;const o=Ki(e);o==="pnpm.overrides"?(a.pnpm??={},a.pnpm.overrides??={},a.pnpm.overrides[be]=st):(a[o]??={},a[o][be]=st);try{vt(r,`${JSON.stringify(a,void 0,4)}
4
4
  `)}catch{return}return{file:"package.json",installCommand:t}},sn=async(s,e)=>{const t=Zi(s,e.projectManifests);if(!t.present||t.alreadyOverridden||t.declined)return!1;const r=Ur({input:process.stdin,output:process.stdout});try{e.logger.info(`Detected ${be}. Its cache hints no-op under @visulima/task-runner unless aliased to ${xt} (a drop-in replacement).`);const a=await new Promise(n=>{r.question("Add the override now? [y/N] ",n)});if(!/^y(?:es)?$/i.test(a.trim()))return en(s),e.logger.info("Skipped. Delete .vis/.vite-client-override-declined to be asked again."),!1;const o=tn(s,t.manager);return o===void 0?(e.logger.warn("Could not write the override automatically — add it manually (see @visulima/task-runner-client README)."),!1):(e.logger.info(`Added "${be}": "${st}" to ${o.file}. Run \`${o.installCommand}\` to apply it.`),!0)}finally{r.close()}},rn=({interactive:s,taskPty:e,workspacePty:t})=>e===!0?!0:e===!1?!1:s&&t!==!1,nn=s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),on=(s,e,t)=>{const r=new Set,a=[];if(s===void 0||s.trim()==="")return{skipTaskIds:r,unmatchedPatterns:a};const o=[...t],n=new Set(o),d=new Map;for(const u of o){const g=u.lastIndexOf(":");if(g===-1)continue;const h=u.slice(g+1),f=d.get(h);f===void 0?d.set(h,[u]):f.push(u)}for(const u of nn(s)){if(u.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${u}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(n.has(u)){r.add(u);continue}const g=hi(u);if(!g){a.push(u);continue}let h=!1;switch(g.kind){case"all":{const f=d.get(g.target)??[];for(const l of f)r.add(l),h=!0;break}case"project":{const f=g.projects?.[0];if(f!==void 0){const l=`${f}:${g.target}`;n.has(l)&&(r.add(l),h=!0)}break}case"tag":{const{tag:f}=g;if(f!==void 0){const l=d.get(g.target)??[];for(const j of l){const C=j.slice(0,j.lastIndexOf(":"));e.projects[C]?.tags?.includes(f)===!0&&(r.add(j),h=!0)}}break}}h||a.push(u)}return{skipTaskIds:r,unmatchedPatterns:a}},an=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,cn=new Set(["0","!","#","$","*","-","?","@","_"]),ln=s=>{const e=new Map;for(const t of s.matchAll(an)){const r=t[1],a=t[3],o=t[2],n=r??a;if(n===void 0||cn.has(n))continue;const d=o!==void 0,u=e.get(n);u===void 0?e.set(n,d):u&&!d&&e.set(n,!1)}return[...e.entries()].map(([t,r])=>({hasDefault:r,name:t}))},dn=s=>{const{command:e,processEnv:t,taskEnv:r,taskId:a}=s,o=ln(e);if(o.length===0)return;const n=[];for(const{hasDefault:d,name:u}of o){if(d)continue;const g=r[u],h=t[u];g===void 0&&h===void 0&&n.push(u)}if(n.length!==0)return{missing:n.toSorted(),taskId:a}},un=s=>{const e=s.missing.map(t=>`$${t}`).join(", ");return`Strict env: ${s.taskId} references unset variable${s.missing.length===1?"":"s"} ${e}. Set ${s.missing.length===1?"it":"them"} in the task env, an envFile, or the parent shell — or opt out with options.strictEnv: false.`},hn=new RegExp("[\x1B›]\\[[0-?]*[ -/]*[@-~]","g"),ht=s=>s.replaceAll(hn,"").replaceAll("\r","");class as{#e=[];#r=new Set;#s=new Map;#i=new Map;constructor(e=[]){for(const t of e)this.#i.set(t,{id:t,status:"pending",tailLines:[]});this.#e=[...e],this.#n()}getSnapshot=()=>this.#s;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});getIds(){return this.#e}getState(e){return this.#i.get(e)}getDockState(){let e=!1,t=!1;for(const r of this.#i.values())r.status==="crashed"||r.status==="failed"?e=!0:(r.status==="pending"||r.status==="starting")&&(t=!0);return e?"crash":t?"boot":"ready"}registerService(e){this.#i.has(e)||(this.#i.set(e,{id:e,status:"pending",tailLines:[]}),this.#e=[...this.#e,e],this.#o())}markStarting(e){this.#t(e,t=>({...t,errorMessage:void 0,startedAt:t.startedAt??Date.now(),status:"starting"}))}markStarted(e,t){this.#t(e,r=>({...r,startedAt:r.startedAt??Date.now(),status:r.status==="ready"?"ready":"starting"}))}markReady(e,t){this.#t(e,r=>({...r,errorMessage:void 0,port:t.port,readyAt:Date.now(),status:"ready"}))}markFailed(e,t,r){const a=r?.message;this.#t(e,o=>({...o,errorMessage:ht(a??t),status:"failed"}))}markCrashed(e,t){const r=t.slice(-256).map(a=>ht(a));this.#t(e,a=>({...a,errorMessage:r.length>0?r[r.length-1]:"process exited",status:"crashed",tailLines:r}))}appendLog(e,t){const r=t.split(`
@@ -1,4 +1,4 @@
1
- import{createRequire as bs}from"node:module";import{E as De,s as Wt,V as ai,I as Nr,q as ii}from"../packem_shared/index.server-CusjRLCh.js";import{j as ws,l as Ir,v as At,b as Tr,P as Pt,z as $s,w as _t}from"../packem_shared/index-uBVnF4ji.js";import{g as ks}from"../packem_shared/_commonjsHelpers-B5Y90VFO.js";import{fingerprint as yt,scan as si,scanFiles as Ps,inspectRuleset as As,listRules as Er,listRequiredValidators as xs,scanGitHistory as Cs}from"@visulima/secret-scanner";import{am as js,an as Ur,p as de}from"./cli-main.js";import{a as Is}from"../packem_shared/readJsonSync-DweZd5ZA-0eZh9sGm.js";let vs;const ys=e=>(vs??=bs(import.meta.url))(e),Tt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,jr=e=>{if(typeof Tt<"u"&&Tt.versions&&Tt.versions.node){const[t,n]=Tt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Tt.getBuiltinModule(e)}return ys(e)},{createRequire:Ns}=jr("node:module"),{pathToFileURL:li}=jr("node:url"),{execFileSync:Ts}=jr("node:child_process"),Es={one:{},two:{},three:{},four:{}},Ds={one:{},two:{},three:{}},Hs={},Os=[],ar={methods:Es,model:Ds,compute:Hs,hooks:Os},Gs=e=>Object.prototype.toString.call(e)==="[object Array]",Fs={compute:function(e){const{world:t}=this,n=t.compute;return typeof e=="string"&&n.hasOwnProperty(e)?n[e](this):Gs(e)?e.forEach(r=>{t.compute.hasOwnProperty(r)?n[r](this):console.warn("no compute:",e)}):typeof e=="function"?e(this):console.warn("no compute:",e),this}},Vs=function(e){return this.fullPointer.forEach((t,n)=>{const r=this.update([t]);e(r,n)}),this},zs=function(e,t){const n=this.fullPointer.map((o,a)=>{const i=this.update([o]),s=e(i,a);return s===void 0?this.none():s});if(n.length===0)return t||this.update([]);if(n[0]!==void 0&&(typeof n[0]=="string"||typeof n[0]=="object"&&(n[0]===null||!n[0].isView)))return n;let r=[];return n.forEach(o=>{r=r.concat(o.fullPointer)}),this.toView(r)},Bs=function(e){let t=this.fullPointer;return t=t.filter((n,r)=>{const o=this.update([n]);return e(o,r)}),this.update(t)},Ss=function(e){const t=this.fullPointer.find((n,r)=>{const o=this.update([n]);return e(o,r)});return this.update([t])},_s=function(e){return this.fullPointer.some((t,n)=>{const r=this.update([t]);return e(r,n)})},Ms=function(e=1){let t=this.fullPointer,n=Math.floor(Math.random()*t.length);return n+e>this.length&&(n=this.length-e,n=n<0?0:n),t=t.slice(n,n+e),this.update(t)},Ls={forEach:Vs,map:zs,filter:Bs,find:Ss,some:_s,random:Ms},He={termList:function(){return this.methods.one.termList(this.docs)},terms:function(e){const t=this.match(".");return typeof e=="number"?t.eq(e):t},groups:function(e){if(e||e===0)return this.update(this._groups[e]||[]);const t={};return Object.keys(this._groups).forEach(n=>{t[n]=this.update(this._groups[n])}),t},eq:function(e){let t=this.pointer;return t||(t=this.docs.map((n,r)=>[r])),t[e]?this.update([t[e]]):this.none()},first:function(){return this.eq(0)},last:function(){const e=this.fullPointer.length-1;return this.eq(e)},firstTerms:function(){return this.match("^.")},lastTerms:function(){return this.match(".$")},slice:function(e,t){let n=this.pointer||this.docs.map((r,o)=>[o]);return n=n.slice(e,t),this.update(n)},all:function(){return this.update().toView()},fullSentences:function(){const e=this.fullPointer.map(t=>[t[0]]);return this.update(e).toView()},none:function(){return this.update([])},isDoc:function(e){if(!e||!e.isView)return!1;const t=this.fullPointer,n=e.fullPointer;return!t.length===n.length?!1:t.every((r,o)=>n[o]?r[0]===n[o][0]&&r[1]===n[o][1]&&r[2]===n[o][2]:!1)},wordCount:function(){return this.docs.reduce((e,t)=>(e+=t.filter(n=>n.text!=="").length,e),0)},isFull:function(){const e=this.pointer;if(!e)return!0;if(e.length===0||e[0][0]!==0)return!1;let t=0,n=0;return this.document.forEach(r=>t+=r.length),this.docs.forEach(r=>n+=r.length),t===n},getNth:function(e){return typeof e=="number"?this.eq(e):typeof e=="string"?this.if(e):this}};He.group=He.groups;He.fullSentence=He.fullSentences;He.sentence=He.fullSentences;He.lastTerm=He.lastTerms;He.firstTerm=He.firstTerms;const ir=Object.assign({},He,Fs,Ls);ir.get=ir.eq;let En=class yn{constructor(t,n,r={}){[["document",t],["world",ar],["_groups",r],["_cache",null],["viewType","View"]].forEach(o=>{Object.defineProperty(this,o[0],{value:o[1],writable:!0})}),this.ptrs=n}get docs(){let t=this.document;return this.ptrs&&(t=ar.methods.one.getDoc(this.ptrs,this.document)),t}get pointer(){return this.ptrs}get methods(){return this.world.methods}get model(){return this.world.model}get hooks(){return this.world.hooks}get isView(){return!0}get found(){return this.docs.length>0}get length(){return this.docs.length}get fullPointer(){const{docs:t,ptrs:n,document:r}=this;return(n||t.map((o,a)=>[a])).map(o=>{let[a,i,s,l,u]=o;return i=i||0,s=s||(r[a]||[]).length,r[a]&&r[a][i]&&(l=l||r[a][i].id,r[a][s-1]&&(u=u||r[a][s-1].id)),[a,i,s,l,u]})}update(t){const n=new yn(this.document,t);if(this._cache&&t&&t.length>0){const r=[];t.forEach((o,a)=>{const[i,s,l]=o;o.length===1?r[a]=this._cache[i]:s===0&&this.document[i].length===l&&(r[a]=this._cache[i])}),r.length>0&&(n._cache=r)}return n.world=this.world,n}toView(t){return new yn(this.document,t||this.pointer)}fromText(t){const{methods:n}=this,r=n.one.tokenize.fromString(t,this.world),o=new yn(r);return o.world=this.world,o.compute(["normal","freeze","lexicon"]),this.world.compute.preTagger&&o.compute("preTagger"),o.compute("unfreeze"),o}clone(){let t=this.document.slice(0);t=t.map(r=>r.map(o=>(o=Object.assign({},o),o.tags=new Set(o.tags),o)));const n=this.update(this.pointer);return n.document=t,n._cache=this._cache,n}};Object.assign(En.prototype,ir);const Ks="14.15.1",Qr=function(e){return e&&typeof e=="object"&&!Array.isArray(e)},Js=function(e){return Object.prototype.toString.call(e)==="[object Array]"};function ui(e,t){if(Qr(t))for(const n in t)Qr(t[n])?(e[n]||Object.assign(e,{[n]:{}}),ui(e[n],t[n])):Object.assign(e,{[n]:t[n]});return e}function Ws(e,t){for(const n in t)e[n]=e[n]||{},Object.assign(e[n],t[n]);return e}const qs=function(e,t){const n=e.two.models||{};Object.keys(t).forEach(r=>{t[r].pastTense&&(n.toPast&&(n.toPast.ex[r]=t[r].pastTense),n.fromPast&&(n.fromPast.ex[t[r].pastTense]=r)),t[r].presentTense&&(n.toPresent&&(n.toPresent.ex[r]=t[r].presentTense),n.fromPresent&&(n.fromPresent.ex[t[r].presentTense]=r)),t[r].gerund&&(n.toGerund&&(n.toGerund.ex[r]=t[r].gerund),n.fromGerund&&(n.fromGerund.ex[t[r].gerund]=r)),t[r].comparative&&(n.toComparative&&(n.toComparative.ex[r]=t[r].comparative),n.fromComparative&&(n.fromComparative.ex[t[r].comparative]=r)),t[r].superlative&&(n.toSuperlative&&(n.toSuperlative.ex[r]=t[r].superlative),n.fromSuperlative&&(n.fromSuperlative.ex[t[r].superlative]=r))})},ci=function(e,t,n,r){if(Js(e)){e.forEach(l=>ci(l,t,n,r));return}const{methods:o,model:a,compute:i,hooks:s}=t;e.methods&&Ws(o,e.methods),e.model&&ui(a,e.model),e.irregulars&&qs(a,e.irregulars),e.compute&&Object.assign(i,e.compute),s&&(t.hooks=s.concat(e.hooks||[])),e.api&&e.api(n),e.lib&&Object.keys(e.lib).forEach(l=>r[l]=e.lib[l]),e.tags&&r.addTags(e.tags),e.words&&r.addWords(e.words),e.frozen&&r.addWords(e.frozen,!0),e.mutate&&e.mutate(t,r)},Rs=function(e){const t=process.env?process.env:self.env||{};return t.DEBUG_TAGS=e==="tagger"||e===!0?!0:"",t.DEBUG_MATCH=e==="match"||e===!0?!0:"",t.DEBUG_CHUNKS=e==="chunker"||e===!0?!0:"",this},Us=e=>Object.prototype.toString.call(e)==="[object Object]",sr=function(e){return Object.prototype.toString.call(e)==="[object Array]"},Qs=function(e){return e.map(t=>t.terms.map(n=>(sr(n.tags)&&(n.tags=new Set(n.tags)),n)))},Zs=function(e){return e.map(t=>t.map(n=>({text:n,normal:n,pre:"",post:" ",tags:new Set})))},hi=function(e,t,n){const{methods:r}=n,o=new t([]);if(o.world=n,typeof e=="number"&&(e=String(e)),!e)return o;if(typeof e=="string"){const a=r.one.tokenize.fromString(e,n);return new t(a)}if(Us(e)&&e.isView)return new t(e.document,e.ptrs);if(sr(e)){if(sr(e[0])){const i=Zs(e);return new t(i)}const a=Qs(e);return new t(a)}return o},Cn=Object.assign({},ar),T=function(e,t){t&&T.addWords(t);const n=hi(e,En,Cn);return e&&n.compute(Cn.hooks),n};Object.defineProperty(T,"_world",{value:Cn,writable:!0});T.tokenize=function(e,t){const{compute:n}=this._world;t&&T.addWords(t);const r=hi(e,En,Cn);return n.contractions&&r.compute(["alias","normal","machine","contractions"]),r};T.plugin=function(e){return ci(e,this._world,En,this),this};T.extend=T.plugin;T.world=function(){return this._world};T.model=function(){return this._world.model};T.methods=function(){return this._world.methods};T.hooks=function(){return this._world.hooks};T.verbose=Rs;T.version=Ks;const Xs=function(e){return e.map(t=>{const n=new Set;return t.forEach(r=>{r.normal!==""&&n.add(r.normal),r.switch&&n.add(`%${r.switch}%`),r.implicit&&n.add(r.implicit),r.machine&&n.add(r.machine),r.root&&n.add(r.root),r.alias&&r.alias.forEach(a=>n.add(a));const o=Array.from(r.tags);for(let a=0;a<o.length;a+=1)n.add("#"+o[a])}),n})},Ys={one:{cacheDoc:Xs}},el={cache:function(){return this._cache=this.methods.one.cacheDoc(this.document),this},uncache:function(){return this._cache=null,this}},tl=function(e){Object.assign(e.prototype,el)},nl={cache:function(e){e._cache=e.methods.one.cacheDoc(e.document)}},rl={api:tl,compute:nl,methods:Ys},ol={toLowerCase:function(){return this.termList().forEach(e=>{e.text=e.text.toLowerCase()}),this},toUpperCase:function(){return this.termList().forEach(e=>{e.text=e.text.toUpperCase()}),this},toTitleCase:function(){return this.termList().forEach(e=>{e.text=e.text.replace(/^ *[a-z\u00C0-\u00FF]/,t=>t.toUpperCase())}),this},toCamelCase:function(){return this.docs.forEach(e=>{e.forEach((t,n)=>{n!==0&&(t.text=t.text.replace(/^ *[a-z\u00C0-\u00FF]/,r=>r.toUpperCase())),n!==e.length-1&&(t.post="")})}),this}},Zr=e=>new RegExp("^\\p{Lu}[\\p{Ll}'’]","u").test(e)||new RegExp("^\\p{Lu}$","u").test(e),al=e=>e.replace(new RegExp("^\\p{Ll}","u"),t=>t.toUpperCase()),il=e=>e.replace(new RegExp("^\\p{Lu}","u"),t=>t.toLowerCase()),di=(e,t,n)=>{if(n.forEach(r=>r.dirty=!0),e){const r=[t,0].concat(n);Array.prototype.splice.apply(e,r)}return e},zt=function(e){const t=/ $/,n=/[-–—]/,r=e[e.length-1];r&&!t.test(r.post)&&!n.test(r.post)&&(r.post+=" ")},Xr=(e,t,n)=>{const r=/[-.?!,;:)–—'"]/g,o=e[t-1];if(!o)return;const a=o.post;if(r.test(a)){const i=a.match(r).join(""),s=n[n.length-1];s.post=i+s.post,o.post=o.post.replace(r,"")}},sl=function(e,t,n){const r=e[t];if(t!==0||!Zr(r.text))return;n[0].text=al(n[0].text);const o=e[t];o.tags.has("ProperNoun")||o.tags.has("Acronym")||Zr(o.text)&&o.text.length>1&&(o.text=il(o.text))},ll=function(e,t,n,r){const[o,a,i]=t;a===0||i===r[o].length?zt(n):(zt(n),zt([e[t[1]]])),sl(e,a,n),di(e,a,n)},ul=function(e,t,n,r){const[o,,a]=t,i=(r[o]||[]).length;a<i?(Xr(e,a,n),zt(n)):i===a&&(zt(e),Xr(e,a,n),r[o+1]&&(n[n.length-1].post+=" ")),di(e,t[2],n),t[4]=n[n.length-1].id};let Et=0;const Yr=e=>(e=e.length<3?"0"+e:e,e.length<3?"0"+e:e),gi=function(e){let[t,n]=e.index||[0,0];Et+=1,Et=Et>46655?0:Et,t=t>46655?0:t,n=n>1294?0:n;let r=Yr(Et.toString(36));r+=Yr(t.toString(36));let o=n.toString(36);o=o.length<2?"0"+o:o,r+=o;const a=parseInt(Math.random()*36,10);return r+=a.toString(36),e.normal+"|"+r.toUpperCase()},eo=function(e){e.has("@hasContraction")&&typeof e.contractions=="function"&&e.grow("@hasContraction").contractions().expand()},to=e=>Object.prototype.toString.call(e)==="[object Array]",cl=function(e){return e=e.map(t=>(t.id=gi(t),t)),e},hl=function(e,t){const{methods:n}=t;return typeof e=="string"?n.one.tokenize.fromString(e,t)[0]:typeof e=="object"&&e.isView?e.clone().docs[0]||[]:to(e)?to(e[0])?e[0]:e:[]},no=function(e,t,n){const{document:r,world:o}=t;t.uncache();const a=t.fullPointer,i=t.fullPointer;t.forEach((l,u)=>{const c=l.fullPointer[0],[d]=c,p=r[d];let x=hl(e,o);x.length!==0&&(x=cl(x),n?(eo(t.update([c]).firstTerm()),ll(p,c,x,r)):(eo(t.update([c]).lastTerm()),ul(p,c,x,r)),r[d]&&r[d][c[1]]&&(c[3]=r[d][c[1]].id),i[u]=c,c[2]+=x.length,a[u]=c)});const s=t.toView(a);return t.ptrs=i,s.compute(["id","index","freeze","lexicon"]),s.world.compute.preTagger&&s.compute("preTagger"),s.compute("unfreeze"),s},lt={insertAfter:function(e){return no(e,this,!1)},insertBefore:function(e){return no(e,this,!0)}};lt.append=lt.insertAfter;lt.prepend=lt.insertBefore;lt.insert=lt.insertAfter;const dl=/\$[0-9a-z]+/g,Dr={},gl=e=>new RegExp("^\\p{Lu}[\\p{Ll}'’]","u").test(e)||new RegExp("^\\p{Lu}$","u").test(e),pl=e=>e.replace(new RegExp("^\\p{Ll}","u"),t=>t.toUpperCase()),ml=e=>e.replace(new RegExp("^\\p{Lu}","u"),t=>t.toLowerCase()),fl=function(e,t,n){return e.forEach(r=>{const o=t(r);r.replaceWith(o,n)}),e},bl=function(e,t){if(typeof e!="string")return e;const n=t.groups();return e=e.replace(dl,r=>{const o=r.replace(/\$/,"");return n.hasOwnProperty(o)?n[o].text():r}),e};Dr.replaceWith=function(e,t={}){let n=this.fullPointer;const r=this;if(this.uncache(),typeof e=="function")return fl(r,e,t);const o=r.docs[0];if(!o)return r;const a=t.possessives&&o[o.length-1].tags.has("Possessive"),i=t.case&&gl(o[0].text);e=bl(e,r);const s=this.update(n);n=n.map(p=>p.slice(0,3));const l=(s.docs[0]||[]).map(p=>Array.from(p.tags)),u=s.docs[0][0].pre,c=s.docs[0][s.docs[0].length-1].post;if(typeof e=="string"&&(e=this.fromText(e).compute("id")),r.insertAfter(e),s.has("@hasContraction")&&r.contractions&&r.grow("@hasContraction+").contractions().expand(),r.delete(s),a){const p=r.docs[0],x=p[p.length-1];x.tags.has("Possessive")||(x.text+="'s",x.normal+="'s",x.tags.add("Possessive"))}if(u&&r.docs[0]&&(r.docs[0][0].pre=u),c&&r.docs[0]){const p=r.docs[0][r.docs[0].length-1];p.post.trim()||(p.post=c)}const d=r.toView(n).compute(["index","freeze","lexicon"]);if(d.world.compute.preTagger&&d.compute("preTagger"),d.compute("unfreeze"),t.tags&&d.terms().forEach((p,x)=>{p.tagSafe(l[x])}),!d.docs[0]||!d.docs[0][0])return d;if(t.case){const p=i?pl:ml;d.docs[0][0].text=p(d.docs[0][0].text)}return d};Dr.replace=function(e,t,n){if(e&&!t)return this.replaceWith(e,n);const r=this.match(e);return r.found?(this.soften(),r.replaceWith(t,n)):this};const vl=function(e,t){const n=e.length-1,r=e[n],o=e[n-t];o&&r&&(o.post+=r.post,o.post=o.post.replace(/ +([.?!,;:])/,"$1"),o.post=o.post.replace(/[,;:]+([.?!])/,"$1"))},yl=function(e,t){t.forEach(n=>{const[r,o,a]=n,i=a-o;e[r]&&(a===e[r].length&&a>1&&vl(e[r],i),e[r].splice(o,i))});for(let n=e.length-1;n>=0;n-=1)if(e[n].length===0&&(e.splice(n,1),n===e.length&&e[n-1])){const r=e[n-1],o=r[r.length-1];o&&(o.post=o.post.trimEnd())}return e},wl=function(e,t){return e=e.map(n=>{const[r]=n;return t[r]&&t[r].forEach(o=>{const a=o[2]-o[1];n[1]<=o[1]&&n[2]>=o[2]&&(n[2]-=a)}),n}),e.forEach((n,r)=>{if(n[1]===0&&n[2]==0)for(let o=r+1;o<e.length;o+=1)e[o][0]-=1,e[o][0]<0&&(e[o][0]=0)}),e=e.filter(n=>n[2]-n[1]>0),e=e.map(n=>(n[3]=null,n[4]=null,n)),e},lr={remove:function(e){const{indexN:t}=this.methods.one.pointer;this.uncache();let n=this.all(),r=this;e&&(n=this,r=this.match(e));const o=!n.ptrs;r.has("@hasContraction")&&r.contractions&&r.grow("@hasContraction").contractions().expand();let a=n.fullPointer;const i=r.fullPointer.reverse(),s=yl(this.document,i),l=t(i);return a=wl(a,l),n.ptrs=a,n.document=s,n.compute("index"),o&&(n.ptrs=void 0),e?n.toView(a):(this.ptrs=[],n.none())}};lr.delete=lr.remove;const Mt={pre:function(e,t){return e===void 0&&this.found?this.docs[0][0].pre:(this.docs.forEach(n=>{const r=n[0];t===!0?r.pre+=e:r.pre=e}),this)},post:function(e,t){if(e===void 0){const n=this.docs[this.docs.length-1];return n[n.length-1].post}return this.docs.forEach(n=>{const r=n[n.length-1];t===!0?r.post+=e:r.post=e}),this},trim:function(){if(!this.found)return this;const e=this.docs,t=e[0][0];t.pre=t.pre.trimStart();const n=e[e.length-1],r=n[n.length-1];return r.post=r.post.trimEnd(),this},hyphenate:function(){return this.docs.forEach(e=>{e.forEach((t,n)=>{n!==0&&(t.pre=""),e[n+1]&&(t.post="-")})}),this},dehyphenate:function(){const e=/[-–—]/;return this.docs.forEach(t=>{t.forEach(n=>{e.test(n.post)&&(n.post=" ")})}),this},toQuotations:function(e,t){return e=e||'"',t=t||'"',this.docs.forEach(n=>{n[0].pre=e+n[0].pre;const r=n[n.length-1];r.post=t+r.post}),this},toParentheses:function(e,t){return e=e||"(",t=t||")",this.docs.forEach(n=>{n[0].pre=e+n[0].pre;const r=n[n.length-1];r.post=t+r.post}),this}};Mt.deHyphenate=Mt.dehyphenate;Mt.toQuotation=Mt.toQuotations;const $l=(e,t)=>e.normal<t.normal?-1:e.normal>t.normal?1:0,kl=(e,t)=>{const n=e.normal.trim().length,r=t.normal.trim().length;return n<r?1:n>r?-1:0},Pl=(e,t)=>e.words<t.words?1:e.words>t.words?-1:0,Al=(e,t)=>e[0]<t[0]?1:e[0]>t[0]?-1:e[1]>t[1]?1:-1,xl=function(e){const t={};return e.forEach(n=>{t[n.normal]=t[n.normal]||0,t[n.normal]+=1}),e.sort((n,r)=>{const o=t[n.normal],a=t[r.normal];return o<a?1:o>a?-1:0}),e},Vn={alpha:$l,length:kl,wordCount:Pl,sequential:Al,byFreq:xl},Cl=new Set(["index","sequence","seq","sequential","chron","chronological"]),jl=new Set(["freq","frequency","topk","repeats"]),Nl=new Set(["alpha","alphabetical"]),Il=function(e,t){let n=e.fullPointer;return n=n.sort((r,o)=>(r=e.update([r]),o=e.update([o]),t(r,o))),e.ptrs=n,e},Tl=function(e){const{docs:t,pointer:n}=this;if(this.uncache(),typeof e=="function")return Il(this,e);e=e||"alpha";const r=n||t.map((a,i)=>[i]);let o=t.map((a,i)=>({index:i,words:a.length,normal:a.map(s=>s.machine||s.normal||"").join(" "),pointer:r[i]}));return Cl.has(e)&&(e="sequential"),Nl.has(e)&&(e="alpha"),jl.has(e)?(o=Vn.byFreq(o),this.update(o.map(a=>a.pointer))):typeof Vn[e]=="function"?(o=o.sort(Vn[e]),this.update(o.map(a=>a.pointer))):this},El=function(){let e=this.pointer||this.docs.map((t,n)=>[n]);return e=[].concat(e),e=e.reverse(),this._cache&&(this._cache=this._cache.reverse()),this.update(e)},Dl=function(){const e=new Set;return this.filter(t=>{const n=t.text("machine");return e.has(n)?!1:(e.add(n),!0)})},Hl={unique:Dl,reverse:El,sort:Tl},Ol=e=>Object.prototype.toString.call(e)==="[object Array]",pi=function(e,t){if(e.length>0){const n=e[e.length-1],r=n[n.length-1];/ /.test(r.post)===!1&&(r.post+=" ")}return e=e.concat(t),e},Gl=function(e,t){if(e.document===t.document){const n=e.fullPointer.concat(t.fullPointer);return e.toView(n).compute("index")}return t.fullPointer.forEach(n=>{n[0]+=e.document.length}),e.document=pi(e.document,t.docs),e.all()},Fl={concat:function(e){if(typeof e=="string"){const t=this.fromText(e);if(!this.found||!this.ptrs)this.document=this.document.concat(t.document);else{const n=this.fullPointer,r=n[n.length-1][0];this.document.splice(r,0,...t.document)}return this.all().compute("index")}if(typeof e=="object"&&e.isView)return Gl(this,e);if(Ol(e)){const t=pi(this.document,e);return this.document=t,this.all()}return this}},Vl=function(){return this.ptrs=this.fullPointer,this},zl=function(){let e=this.ptrs;return!e||e.length<1?this:(e=e.map(t=>t.slice(0,3)),this.ptrs=e,this)},Bl={harden:Vl,soften:zl},Sl=Object.assign({},ol,lt,Dr,lr,Mt,Hl,Fl,Bl),_l=function(e){Object.assign(e.prototype,Sl)},Ml={id:function(e){const t=e.docs;for(let n=0;n<t.length;n+=1)for(let r=0;r<t[n].length;r+=1){const o=t[n][r];o.id=o.id||gi(o)}}},Ll={api:_l,compute:Ml},Kl=[{word:"@",out:["at"]},{word:"arent",out:["are","not"]},{word:"alot",out:["a","lot"]},{word:"brb",out:["be","right","back"]},{word:"cannot",out:["can","not"]},{word:"dun",out:["do","not"]},{word:"can't",out:["can","not"]},{word:"shan't",out:["should","not"]},{word:"won't",out:["will","not"]},{word:"that's",out:["that","is"]},{word:"what's",out:["what","is"]},{word:"let's",out:["let","us"]},{word:"dunno",out:["do","not","know"]},{word:"gonna",out:["going","to"]},{word:"gotta",out:["have","got","to"]},{word:"gimme",out:["give","me"]},{word:"outta",out:["out","of"]},{word:"tryna",out:["trying","to"]},{word:"gtg",out:["got","to","go"]},{word:"im",out:["i","am"]},{word:"imma",out:["I","will"]},{word:"imo",out:["in","my","opinion"]},{word:"irl",out:["in","real","life"]},{word:"ive",out:["i","have"]},{word:"rn",out:["right","now"]},{word:"tbh",out:["to","be","honest"]},{word:"wanna",out:["want","to"]},{word:"c'mere",out:["come","here"]},{word:"c'mon",out:["come","on"]},{word:"shoulda",out:["should","have"]},{word:"coulda",out:["coulda","have"]},{word:"woulda",out:["woulda","have"]},{word:"musta",out:["must","have"]},{word:"tis",out:["it","is"]},{word:"twas",out:["it","was"]},{word:"y'know",out:["you","know"]},{word:"ne'er",out:["never"]},{word:"o'er",out:["over"]},{after:"ll",out:["will"]},{after:"ve",out:["have"]},{after:"re",out:["are"]},{after:"m",out:["am"]},{before:"c",out:["ce"]},{before:"m",out:["me"]},{before:"n",out:["ne"]},{before:"qu",out:["que"]},{before:"s",out:["se"]},{before:"t",out:["tu"]},{word:"shouldnt",out:["should","not"]},{word:"couldnt",out:["could","not"]},{word:"wouldnt",out:["would","not"]},{word:"hasnt",out:["has","not"]},{word:"wasnt",out:["was","not"]},{word:"isnt",out:["is","not"]},{word:"cant",out:["can","not"]},{word:"dont",out:["do","not"]},{word:"wont",out:["will","not"]},{word:"howd",out:["how","did"]},{word:"whatd",out:["what","did"]},{word:"whend",out:["when","did"]},{word:"whered",out:["where","did"]}],Jl={st:!0,nd:!0,rd:!0,th:!0,am:!0,pm:!0,max:!0,"°":!0,s:!0,e:!0,er:!0,ère:!0,ème:!0},Wl={one:{contractions:Kl,numberSuffixes:Jl}},zn=function(e,t,n){const[r,o]=t;!n||n.length===0||(n=n.map((a,i)=>(a.implicit=a.text,a.machine=a.text,a.pre="",a.post="",a.text="",a.normal="",a.index=[r,o+i],a)),n[0]&&(n[0].pre=e[r][o].pre,n[n.length-1].post=e[r][o].post,n[0].text=e[r][o].text,n[0].normal=e[r][o].normal),e[r].splice(o,1,...n))},ql=/'/,Rl=new Set(["what","how","when","where","why"]),Ul=new Set(["be","go","start","think","need"]),Ql=new Set(["been","gone"]),Zl=function(e,t){const n=e[t].normal.split(ql)[0];if(Rl.has(n))return[n,"did"];if(e[t+1]){if(Ql.has(e[t+1].normal))return[n,"had"];if(Ul.has(e[t+1].normal))return[n,"would"]}return null},Xl=function(e,t){return e[t].normal==="ain't"||e[t].normal==="aint"?null:[e[t].normal.replace(/n't/,""),"not"]},Hr=/'/,Yl=/(e|é|aison|sion|tion)$/,eu=/(age|isme|acle|ege|oire)$/,tu=(e,t)=>{const n=e[t].normal.split(Hr)[1];return n&&n.endsWith("e")?["la",n]:["le",n]},nu=(e,t)=>{const n=e[t].normal.split(Hr)[1];return n&&Yl.test(n)&&!eu.test(n)?["du",n]:n&&n.endsWith("s")?["des",n]:["de",n]},ru=(e,t)=>["je",e[t].normal.split(Hr)[1]],Bn={preJ:ru,preL:tu,preD:nu},ou=/^([0-9.]{1,4}[a-z]{0,2}) ?[-–—] ?([0-9]{1,4}[a-z]{0,2})$/i,au=/^([0-9]{1,2}(:[0-9][0-9])?(am|pm)?) ?[-–—] ?([0-9]{1,2}(:[0-9][0-9])?(am|pm)?)$/i,iu=/^[0-9]{3}-[0-9]{4}$/,su=function(e,t){const n=e[t];let r=n.text.match(ou);return r!==null?n.tags.has("PhoneNumber")===!0||iu.test(n.text)?null:[r[1],"to",r[2]]:(r=n.text.match(au),r!==null?[r[1],"to",r[4]]:null)},lu=/^([+-]?[0-9][.,0-9]*)([a-z°²³µ/]+)$/,uu=function(e,t,n){const r=n.model.one.numberSuffixes||{},o=e[t].text.match(lu);if(o!==null){const a=o[2].toLowerCase().trim();return r.hasOwnProperty(a)?null:[o[1],a]}return null},ro=/'/,cu=/^[0-9][^-–—]*[-–—].*?[0-9]/,oo=function(e,t,n,r){const o=t.update();o.document=[e];let a=n+r;n>0&&(n-=1),e[a]&&(a+=1),o.ptrs=[[0,n,a]]},ao={t:(e,t)=>Xl(e,t),d:(e,t)=>Zl(e,t)},io={j:(e,t)=>Bn.preJ(e,t),l:(e,t)=>Bn.preL(e,t),d:(e,t)=>Bn.preD(e,t)},hu=function(e,t,n,r){for(let o=0;o<e.length;o+=1){const a=e[o];if(a.word===t.normal)return a.out;if(r!==null&&r===a.after)return[n].concat(a.out);if(n!==null&&n===a.before&&r&&r.length>2)return a.out.concat(r)}return null},Sn=function(e,t){const n=t.fromText(e.join(" "));return n.compute(["id","alias"]),n.docs[0]},du=function(e,t){for(let n=t+1;n<5&&e[n];n+=1)if(e[n].normal==="been")return["there","has"];return["there","is"]},gu=e=>{const{world:t,document:n}=e,{model:r,methods:o}=t,a=r.one.contractions||[];n.forEach((i,s)=>{for(let l=i.length-1;l>=0;l-=1){let u=null,c=null;if(ro.test(i[l].normal)===!0){const p=i[l].normal.split(ro);u=p[0],c=p[1]}let d=hu(a,i[l],u,c);if(!d&&ao.hasOwnProperty(c)&&(d=ao[c](i,l,t)),!d&&io.hasOwnProperty(u)&&(d=io[u](i,l)),u==="there"&&c==="s"&&(d=du(i,l)),d){d=Sn(d,e),zn(n,[s,l],d),oo(n[s],e,l,d.length);continue}if(cu.test(i[l].normal)){d=su(i,l),d&&(d=Sn(d,e),zn(n,[s,l],d),o.one.setTag(d,"NumberRange",t),d[2]&&d[2].tags.has("Time")&&o.one.setTag([d[0]],"Time",t,null,"time-range"),oo(n[s],e,l,d.length));continue}d=uu(i,l,t),d&&(d=Sn(d,e),zn(n,[s,l],d),o.one.setTag([d[1]],"Unit",t,null,"contraction-unit"))}})},pu={contractions:gu},mu={model:Wl,compute:pu,hooks:["contractions"]},so=function(e){const t=e.world,{model:n,methods:r}=e.world,o=r.one.setTag,{frozenLex:a}=n.one,i=n.one._multiCache||{};e.docs.forEach(s=>{for(let l=0;l<s.length;l+=1){const u=s[l],c=u.machine||u.normal;if(i[c]!==void 0&&s[l+1]){const d=l+i[c]-1;for(let p=d;p>l;p-=1){const x=s.slice(l,p+1),O=x.map(M=>M.machine||M.normal).join(" ");if(a.hasOwnProperty(O)===!0){o(x,a[O],t,!1,"1-frozen-multi-lexicon"),x.forEach(M=>M.frozen=!0);continue}}}if(a[c]!==void 0&&a.hasOwnProperty(c)){o([u],a[c],t,!1,"1-freeze-lexicon"),u.frozen=!0;continue}}})},fu=function(e){return e.docs.forEach(t=>{t.forEach(n=>{delete n.frozen})}),e},bu={frozen:so,freeze:so,unfreeze:fu},lo=e=>"\x1B[34m"+e+"\x1B[0m",uo=e=>"\x1B[3m\x1B[2m"+e+"\x1B[0m",co=function(e){e.docs.forEach(t=>{console.log(lo(`
1
+ import{createRequire as bs}from"node:module";import{E as De,s as Wt,V as ai,I as Nr,q as ii}from"../packem_shared/index.server-CusjRLCh.js";import{j as ws,l as Ir,v as At,b as Tr,P as Pt,z as $s,w as _t}from"../packem_shared/index-BLtnel38.js";import{g as ks}from"../packem_shared/_commonjsHelpers-B5Y90VFO.js";import{fingerprint as yt,scan as si,scanFiles as Ps,inspectRuleset as As,listRules as Er,listRequiredValidators as xs,scanGitHistory as Cs}from"@visulima/secret-scanner";import{am as js,an as Ur,p as de}from"./cli-main.js";import{a as Is}from"../packem_shared/readJsonSync-DweZd5ZA-CtrDlqpb.js";let vs;const ys=e=>(vs??=bs(import.meta.url))(e),Tt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,jr=e=>{if(typeof Tt<"u"&&Tt.versions&&Tt.versions.node){const[t,n]=Tt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Tt.getBuiltinModule(e)}return ys(e)},{createRequire:Ns}=jr("node:module"),{pathToFileURL:li}=jr("node:url"),{execFileSync:Ts}=jr("node:child_process"),Es={one:{},two:{},three:{},four:{}},Ds={one:{},two:{},three:{}},Hs={},Os=[],ar={methods:Es,model:Ds,compute:Hs,hooks:Os},Gs=e=>Object.prototype.toString.call(e)==="[object Array]",Fs={compute:function(e){const{world:t}=this,n=t.compute;return typeof e=="string"&&n.hasOwnProperty(e)?n[e](this):Gs(e)?e.forEach(r=>{t.compute.hasOwnProperty(r)?n[r](this):console.warn("no compute:",e)}):typeof e=="function"?e(this):console.warn("no compute:",e),this}},Vs=function(e){return this.fullPointer.forEach((t,n)=>{const r=this.update([t]);e(r,n)}),this},zs=function(e,t){const n=this.fullPointer.map((o,a)=>{const i=this.update([o]),s=e(i,a);return s===void 0?this.none():s});if(n.length===0)return t||this.update([]);if(n[0]!==void 0&&(typeof n[0]=="string"||typeof n[0]=="object"&&(n[0]===null||!n[0].isView)))return n;let r=[];return n.forEach(o=>{r=r.concat(o.fullPointer)}),this.toView(r)},Bs=function(e){let t=this.fullPointer;return t=t.filter((n,r)=>{const o=this.update([n]);return e(o,r)}),this.update(t)},Ss=function(e){const t=this.fullPointer.find((n,r)=>{const o=this.update([n]);return e(o,r)});return this.update([t])},_s=function(e){return this.fullPointer.some((t,n)=>{const r=this.update([t]);return e(r,n)})},Ms=function(e=1){let t=this.fullPointer,n=Math.floor(Math.random()*t.length);return n+e>this.length&&(n=this.length-e,n=n<0?0:n),t=t.slice(n,n+e),this.update(t)},Ls={forEach:Vs,map:zs,filter:Bs,find:Ss,some:_s,random:Ms},He={termList:function(){return this.methods.one.termList(this.docs)},terms:function(e){const t=this.match(".");return typeof e=="number"?t.eq(e):t},groups:function(e){if(e||e===0)return this.update(this._groups[e]||[]);const t={};return Object.keys(this._groups).forEach(n=>{t[n]=this.update(this._groups[n])}),t},eq:function(e){let t=this.pointer;return t||(t=this.docs.map((n,r)=>[r])),t[e]?this.update([t[e]]):this.none()},first:function(){return this.eq(0)},last:function(){const e=this.fullPointer.length-1;return this.eq(e)},firstTerms:function(){return this.match("^.")},lastTerms:function(){return this.match(".$")},slice:function(e,t){let n=this.pointer||this.docs.map((r,o)=>[o]);return n=n.slice(e,t),this.update(n)},all:function(){return this.update().toView()},fullSentences:function(){const e=this.fullPointer.map(t=>[t[0]]);return this.update(e).toView()},none:function(){return this.update([])},isDoc:function(e){if(!e||!e.isView)return!1;const t=this.fullPointer,n=e.fullPointer;return!t.length===n.length?!1:t.every((r,o)=>n[o]?r[0]===n[o][0]&&r[1]===n[o][1]&&r[2]===n[o][2]:!1)},wordCount:function(){return this.docs.reduce((e,t)=>(e+=t.filter(n=>n.text!=="").length,e),0)},isFull:function(){const e=this.pointer;if(!e)return!0;if(e.length===0||e[0][0]!==0)return!1;let t=0,n=0;return this.document.forEach(r=>t+=r.length),this.docs.forEach(r=>n+=r.length),t===n},getNth:function(e){return typeof e=="number"?this.eq(e):typeof e=="string"?this.if(e):this}};He.group=He.groups;He.fullSentence=He.fullSentences;He.sentence=He.fullSentences;He.lastTerm=He.lastTerms;He.firstTerm=He.firstTerms;const ir=Object.assign({},He,Fs,Ls);ir.get=ir.eq;let En=class yn{constructor(t,n,r={}){[["document",t],["world",ar],["_groups",r],["_cache",null],["viewType","View"]].forEach(o=>{Object.defineProperty(this,o[0],{value:o[1],writable:!0})}),this.ptrs=n}get docs(){let t=this.document;return this.ptrs&&(t=ar.methods.one.getDoc(this.ptrs,this.document)),t}get pointer(){return this.ptrs}get methods(){return this.world.methods}get model(){return this.world.model}get hooks(){return this.world.hooks}get isView(){return!0}get found(){return this.docs.length>0}get length(){return this.docs.length}get fullPointer(){const{docs:t,ptrs:n,document:r}=this;return(n||t.map((o,a)=>[a])).map(o=>{let[a,i,s,l,u]=o;return i=i||0,s=s||(r[a]||[]).length,r[a]&&r[a][i]&&(l=l||r[a][i].id,r[a][s-1]&&(u=u||r[a][s-1].id)),[a,i,s,l,u]})}update(t){const n=new yn(this.document,t);if(this._cache&&t&&t.length>0){const r=[];t.forEach((o,a)=>{const[i,s,l]=o;o.length===1?r[a]=this._cache[i]:s===0&&this.document[i].length===l&&(r[a]=this._cache[i])}),r.length>0&&(n._cache=r)}return n.world=this.world,n}toView(t){return new yn(this.document,t||this.pointer)}fromText(t){const{methods:n}=this,r=n.one.tokenize.fromString(t,this.world),o=new yn(r);return o.world=this.world,o.compute(["normal","freeze","lexicon"]),this.world.compute.preTagger&&o.compute("preTagger"),o.compute("unfreeze"),o}clone(){let t=this.document.slice(0);t=t.map(r=>r.map(o=>(o=Object.assign({},o),o.tags=new Set(o.tags),o)));const n=this.update(this.pointer);return n.document=t,n._cache=this._cache,n}};Object.assign(En.prototype,ir);const Ks="14.15.1",Qr=function(e){return e&&typeof e=="object"&&!Array.isArray(e)},Js=function(e){return Object.prototype.toString.call(e)==="[object Array]"};function ui(e,t){if(Qr(t))for(const n in t)Qr(t[n])?(e[n]||Object.assign(e,{[n]:{}}),ui(e[n],t[n])):Object.assign(e,{[n]:t[n]});return e}function Ws(e,t){for(const n in t)e[n]=e[n]||{},Object.assign(e[n],t[n]);return e}const qs=function(e,t){const n=e.two.models||{};Object.keys(t).forEach(r=>{t[r].pastTense&&(n.toPast&&(n.toPast.ex[r]=t[r].pastTense),n.fromPast&&(n.fromPast.ex[t[r].pastTense]=r)),t[r].presentTense&&(n.toPresent&&(n.toPresent.ex[r]=t[r].presentTense),n.fromPresent&&(n.fromPresent.ex[t[r].presentTense]=r)),t[r].gerund&&(n.toGerund&&(n.toGerund.ex[r]=t[r].gerund),n.fromGerund&&(n.fromGerund.ex[t[r].gerund]=r)),t[r].comparative&&(n.toComparative&&(n.toComparative.ex[r]=t[r].comparative),n.fromComparative&&(n.fromComparative.ex[t[r].comparative]=r)),t[r].superlative&&(n.toSuperlative&&(n.toSuperlative.ex[r]=t[r].superlative),n.fromSuperlative&&(n.fromSuperlative.ex[t[r].superlative]=r))})},ci=function(e,t,n,r){if(Js(e)){e.forEach(l=>ci(l,t,n,r));return}const{methods:o,model:a,compute:i,hooks:s}=t;e.methods&&Ws(o,e.methods),e.model&&ui(a,e.model),e.irregulars&&qs(a,e.irregulars),e.compute&&Object.assign(i,e.compute),s&&(t.hooks=s.concat(e.hooks||[])),e.api&&e.api(n),e.lib&&Object.keys(e.lib).forEach(l=>r[l]=e.lib[l]),e.tags&&r.addTags(e.tags),e.words&&r.addWords(e.words),e.frozen&&r.addWords(e.frozen,!0),e.mutate&&e.mutate(t,r)},Rs=function(e){const t=process.env?process.env:self.env||{};return t.DEBUG_TAGS=e==="tagger"||e===!0?!0:"",t.DEBUG_MATCH=e==="match"||e===!0?!0:"",t.DEBUG_CHUNKS=e==="chunker"||e===!0?!0:"",this},Us=e=>Object.prototype.toString.call(e)==="[object Object]",sr=function(e){return Object.prototype.toString.call(e)==="[object Array]"},Qs=function(e){return e.map(t=>t.terms.map(n=>(sr(n.tags)&&(n.tags=new Set(n.tags)),n)))},Zs=function(e){return e.map(t=>t.map(n=>({text:n,normal:n,pre:"",post:" ",tags:new Set})))},hi=function(e,t,n){const{methods:r}=n,o=new t([]);if(o.world=n,typeof e=="number"&&(e=String(e)),!e)return o;if(typeof e=="string"){const a=r.one.tokenize.fromString(e,n);return new t(a)}if(Us(e)&&e.isView)return new t(e.document,e.ptrs);if(sr(e)){if(sr(e[0])){const i=Zs(e);return new t(i)}const a=Qs(e);return new t(a)}return o},Cn=Object.assign({},ar),T=function(e,t){t&&T.addWords(t);const n=hi(e,En,Cn);return e&&n.compute(Cn.hooks),n};Object.defineProperty(T,"_world",{value:Cn,writable:!0});T.tokenize=function(e,t){const{compute:n}=this._world;t&&T.addWords(t);const r=hi(e,En,Cn);return n.contractions&&r.compute(["alias","normal","machine","contractions"]),r};T.plugin=function(e){return ci(e,this._world,En,this),this};T.extend=T.plugin;T.world=function(){return this._world};T.model=function(){return this._world.model};T.methods=function(){return this._world.methods};T.hooks=function(){return this._world.hooks};T.verbose=Rs;T.version=Ks;const Xs=function(e){return e.map(t=>{const n=new Set;return t.forEach(r=>{r.normal!==""&&n.add(r.normal),r.switch&&n.add(`%${r.switch}%`),r.implicit&&n.add(r.implicit),r.machine&&n.add(r.machine),r.root&&n.add(r.root),r.alias&&r.alias.forEach(a=>n.add(a));const o=Array.from(r.tags);for(let a=0;a<o.length;a+=1)n.add("#"+o[a])}),n})},Ys={one:{cacheDoc:Xs}},el={cache:function(){return this._cache=this.methods.one.cacheDoc(this.document),this},uncache:function(){return this._cache=null,this}},tl=function(e){Object.assign(e.prototype,el)},nl={cache:function(e){e._cache=e.methods.one.cacheDoc(e.document)}},rl={api:tl,compute:nl,methods:Ys},ol={toLowerCase:function(){return this.termList().forEach(e=>{e.text=e.text.toLowerCase()}),this},toUpperCase:function(){return this.termList().forEach(e=>{e.text=e.text.toUpperCase()}),this},toTitleCase:function(){return this.termList().forEach(e=>{e.text=e.text.replace(/^ *[a-z\u00C0-\u00FF]/,t=>t.toUpperCase())}),this},toCamelCase:function(){return this.docs.forEach(e=>{e.forEach((t,n)=>{n!==0&&(t.text=t.text.replace(/^ *[a-z\u00C0-\u00FF]/,r=>r.toUpperCase())),n!==e.length-1&&(t.post="")})}),this}},Zr=e=>new RegExp("^\\p{Lu}[\\p{Ll}'’]","u").test(e)||new RegExp("^\\p{Lu}$","u").test(e),al=e=>e.replace(new RegExp("^\\p{Ll}","u"),t=>t.toUpperCase()),il=e=>e.replace(new RegExp("^\\p{Lu}","u"),t=>t.toLowerCase()),di=(e,t,n)=>{if(n.forEach(r=>r.dirty=!0),e){const r=[t,0].concat(n);Array.prototype.splice.apply(e,r)}return e},zt=function(e){const t=/ $/,n=/[-–—]/,r=e[e.length-1];r&&!t.test(r.post)&&!n.test(r.post)&&(r.post+=" ")},Xr=(e,t,n)=>{const r=/[-.?!,;:)–—'"]/g,o=e[t-1];if(!o)return;const a=o.post;if(r.test(a)){const i=a.match(r).join(""),s=n[n.length-1];s.post=i+s.post,o.post=o.post.replace(r,"")}},sl=function(e,t,n){const r=e[t];if(t!==0||!Zr(r.text))return;n[0].text=al(n[0].text);const o=e[t];o.tags.has("ProperNoun")||o.tags.has("Acronym")||Zr(o.text)&&o.text.length>1&&(o.text=il(o.text))},ll=function(e,t,n,r){const[o,a,i]=t;a===0||i===r[o].length?zt(n):(zt(n),zt([e[t[1]]])),sl(e,a,n),di(e,a,n)},ul=function(e,t,n,r){const[o,,a]=t,i=(r[o]||[]).length;a<i?(Xr(e,a,n),zt(n)):i===a&&(zt(e),Xr(e,a,n),r[o+1]&&(n[n.length-1].post+=" ")),di(e,t[2],n),t[4]=n[n.length-1].id};let Et=0;const Yr=e=>(e=e.length<3?"0"+e:e,e.length<3?"0"+e:e),gi=function(e){let[t,n]=e.index||[0,0];Et+=1,Et=Et>46655?0:Et,t=t>46655?0:t,n=n>1294?0:n;let r=Yr(Et.toString(36));r+=Yr(t.toString(36));let o=n.toString(36);o=o.length<2?"0"+o:o,r+=o;const a=parseInt(Math.random()*36,10);return r+=a.toString(36),e.normal+"|"+r.toUpperCase()},eo=function(e){e.has("@hasContraction")&&typeof e.contractions=="function"&&e.grow("@hasContraction").contractions().expand()},to=e=>Object.prototype.toString.call(e)==="[object Array]",cl=function(e){return e=e.map(t=>(t.id=gi(t),t)),e},hl=function(e,t){const{methods:n}=t;return typeof e=="string"?n.one.tokenize.fromString(e,t)[0]:typeof e=="object"&&e.isView?e.clone().docs[0]||[]:to(e)?to(e[0])?e[0]:e:[]},no=function(e,t,n){const{document:r,world:o}=t;t.uncache();const a=t.fullPointer,i=t.fullPointer;t.forEach((l,u)=>{const c=l.fullPointer[0],[d]=c,p=r[d];let x=hl(e,o);x.length!==0&&(x=cl(x),n?(eo(t.update([c]).firstTerm()),ll(p,c,x,r)):(eo(t.update([c]).lastTerm()),ul(p,c,x,r)),r[d]&&r[d][c[1]]&&(c[3]=r[d][c[1]].id),i[u]=c,c[2]+=x.length,a[u]=c)});const s=t.toView(a);return t.ptrs=i,s.compute(["id","index","freeze","lexicon"]),s.world.compute.preTagger&&s.compute("preTagger"),s.compute("unfreeze"),s},lt={insertAfter:function(e){return no(e,this,!1)},insertBefore:function(e){return no(e,this,!0)}};lt.append=lt.insertAfter;lt.prepend=lt.insertBefore;lt.insert=lt.insertAfter;const dl=/\$[0-9a-z]+/g,Dr={},gl=e=>new RegExp("^\\p{Lu}[\\p{Ll}'’]","u").test(e)||new RegExp("^\\p{Lu}$","u").test(e),pl=e=>e.replace(new RegExp("^\\p{Ll}","u"),t=>t.toUpperCase()),ml=e=>e.replace(new RegExp("^\\p{Lu}","u"),t=>t.toLowerCase()),fl=function(e,t,n){return e.forEach(r=>{const o=t(r);r.replaceWith(o,n)}),e},bl=function(e,t){if(typeof e!="string")return e;const n=t.groups();return e=e.replace(dl,r=>{const o=r.replace(/\$/,"");return n.hasOwnProperty(o)?n[o].text():r}),e};Dr.replaceWith=function(e,t={}){let n=this.fullPointer;const r=this;if(this.uncache(),typeof e=="function")return fl(r,e,t);const o=r.docs[0];if(!o)return r;const a=t.possessives&&o[o.length-1].tags.has("Possessive"),i=t.case&&gl(o[0].text);e=bl(e,r);const s=this.update(n);n=n.map(p=>p.slice(0,3));const l=(s.docs[0]||[]).map(p=>Array.from(p.tags)),u=s.docs[0][0].pre,c=s.docs[0][s.docs[0].length-1].post;if(typeof e=="string"&&(e=this.fromText(e).compute("id")),r.insertAfter(e),s.has("@hasContraction")&&r.contractions&&r.grow("@hasContraction+").contractions().expand(),r.delete(s),a){const p=r.docs[0],x=p[p.length-1];x.tags.has("Possessive")||(x.text+="'s",x.normal+="'s",x.tags.add("Possessive"))}if(u&&r.docs[0]&&(r.docs[0][0].pre=u),c&&r.docs[0]){const p=r.docs[0][r.docs[0].length-1];p.post.trim()||(p.post=c)}const d=r.toView(n).compute(["index","freeze","lexicon"]);if(d.world.compute.preTagger&&d.compute("preTagger"),d.compute("unfreeze"),t.tags&&d.terms().forEach((p,x)=>{p.tagSafe(l[x])}),!d.docs[0]||!d.docs[0][0])return d;if(t.case){const p=i?pl:ml;d.docs[0][0].text=p(d.docs[0][0].text)}return d};Dr.replace=function(e,t,n){if(e&&!t)return this.replaceWith(e,n);const r=this.match(e);return r.found?(this.soften(),r.replaceWith(t,n)):this};const vl=function(e,t){const n=e.length-1,r=e[n],o=e[n-t];o&&r&&(o.post+=r.post,o.post=o.post.replace(/ +([.?!,;:])/,"$1"),o.post=o.post.replace(/[,;:]+([.?!])/,"$1"))},yl=function(e,t){t.forEach(n=>{const[r,o,a]=n,i=a-o;e[r]&&(a===e[r].length&&a>1&&vl(e[r],i),e[r].splice(o,i))});for(let n=e.length-1;n>=0;n-=1)if(e[n].length===0&&(e.splice(n,1),n===e.length&&e[n-1])){const r=e[n-1],o=r[r.length-1];o&&(o.post=o.post.trimEnd())}return e},wl=function(e,t){return e=e.map(n=>{const[r]=n;return t[r]&&t[r].forEach(o=>{const a=o[2]-o[1];n[1]<=o[1]&&n[2]>=o[2]&&(n[2]-=a)}),n}),e.forEach((n,r)=>{if(n[1]===0&&n[2]==0)for(let o=r+1;o<e.length;o+=1)e[o][0]-=1,e[o][0]<0&&(e[o][0]=0)}),e=e.filter(n=>n[2]-n[1]>0),e=e.map(n=>(n[3]=null,n[4]=null,n)),e},lr={remove:function(e){const{indexN:t}=this.methods.one.pointer;this.uncache();let n=this.all(),r=this;e&&(n=this,r=this.match(e));const o=!n.ptrs;r.has("@hasContraction")&&r.contractions&&r.grow("@hasContraction").contractions().expand();let a=n.fullPointer;const i=r.fullPointer.reverse(),s=yl(this.document,i),l=t(i);return a=wl(a,l),n.ptrs=a,n.document=s,n.compute("index"),o&&(n.ptrs=void 0),e?n.toView(a):(this.ptrs=[],n.none())}};lr.delete=lr.remove;const Mt={pre:function(e,t){return e===void 0&&this.found?this.docs[0][0].pre:(this.docs.forEach(n=>{const r=n[0];t===!0?r.pre+=e:r.pre=e}),this)},post:function(e,t){if(e===void 0){const n=this.docs[this.docs.length-1];return n[n.length-1].post}return this.docs.forEach(n=>{const r=n[n.length-1];t===!0?r.post+=e:r.post=e}),this},trim:function(){if(!this.found)return this;const e=this.docs,t=e[0][0];t.pre=t.pre.trimStart();const n=e[e.length-1],r=n[n.length-1];return r.post=r.post.trimEnd(),this},hyphenate:function(){return this.docs.forEach(e=>{e.forEach((t,n)=>{n!==0&&(t.pre=""),e[n+1]&&(t.post="-")})}),this},dehyphenate:function(){const e=/[-–—]/;return this.docs.forEach(t=>{t.forEach(n=>{e.test(n.post)&&(n.post=" ")})}),this},toQuotations:function(e,t){return e=e||'"',t=t||'"',this.docs.forEach(n=>{n[0].pre=e+n[0].pre;const r=n[n.length-1];r.post=t+r.post}),this},toParentheses:function(e,t){return e=e||"(",t=t||")",this.docs.forEach(n=>{n[0].pre=e+n[0].pre;const r=n[n.length-1];r.post=t+r.post}),this}};Mt.deHyphenate=Mt.dehyphenate;Mt.toQuotation=Mt.toQuotations;const $l=(e,t)=>e.normal<t.normal?-1:e.normal>t.normal?1:0,kl=(e,t)=>{const n=e.normal.trim().length,r=t.normal.trim().length;return n<r?1:n>r?-1:0},Pl=(e,t)=>e.words<t.words?1:e.words>t.words?-1:0,Al=(e,t)=>e[0]<t[0]?1:e[0]>t[0]?-1:e[1]>t[1]?1:-1,xl=function(e){const t={};return e.forEach(n=>{t[n.normal]=t[n.normal]||0,t[n.normal]+=1}),e.sort((n,r)=>{const o=t[n.normal],a=t[r.normal];return o<a?1:o>a?-1:0}),e},Vn={alpha:$l,length:kl,wordCount:Pl,sequential:Al,byFreq:xl},Cl=new Set(["index","sequence","seq","sequential","chron","chronological"]),jl=new Set(["freq","frequency","topk","repeats"]),Nl=new Set(["alpha","alphabetical"]),Il=function(e,t){let n=e.fullPointer;return n=n.sort((r,o)=>(r=e.update([r]),o=e.update([o]),t(r,o))),e.ptrs=n,e},Tl=function(e){const{docs:t,pointer:n}=this;if(this.uncache(),typeof e=="function")return Il(this,e);e=e||"alpha";const r=n||t.map((a,i)=>[i]);let o=t.map((a,i)=>({index:i,words:a.length,normal:a.map(s=>s.machine||s.normal||"").join(" "),pointer:r[i]}));return Cl.has(e)&&(e="sequential"),Nl.has(e)&&(e="alpha"),jl.has(e)?(o=Vn.byFreq(o),this.update(o.map(a=>a.pointer))):typeof Vn[e]=="function"?(o=o.sort(Vn[e]),this.update(o.map(a=>a.pointer))):this},El=function(){let e=this.pointer||this.docs.map((t,n)=>[n]);return e=[].concat(e),e=e.reverse(),this._cache&&(this._cache=this._cache.reverse()),this.update(e)},Dl=function(){const e=new Set;return this.filter(t=>{const n=t.text("machine");return e.has(n)?!1:(e.add(n),!0)})},Hl={unique:Dl,reverse:El,sort:Tl},Ol=e=>Object.prototype.toString.call(e)==="[object Array]",pi=function(e,t){if(e.length>0){const n=e[e.length-1],r=n[n.length-1];/ /.test(r.post)===!1&&(r.post+=" ")}return e=e.concat(t),e},Gl=function(e,t){if(e.document===t.document){const n=e.fullPointer.concat(t.fullPointer);return e.toView(n).compute("index")}return t.fullPointer.forEach(n=>{n[0]+=e.document.length}),e.document=pi(e.document,t.docs),e.all()},Fl={concat:function(e){if(typeof e=="string"){const t=this.fromText(e);if(!this.found||!this.ptrs)this.document=this.document.concat(t.document);else{const n=this.fullPointer,r=n[n.length-1][0];this.document.splice(r,0,...t.document)}return this.all().compute("index")}if(typeof e=="object"&&e.isView)return Gl(this,e);if(Ol(e)){const t=pi(this.document,e);return this.document=t,this.all()}return this}},Vl=function(){return this.ptrs=this.fullPointer,this},zl=function(){let e=this.ptrs;return!e||e.length<1?this:(e=e.map(t=>t.slice(0,3)),this.ptrs=e,this)},Bl={harden:Vl,soften:zl},Sl=Object.assign({},ol,lt,Dr,lr,Mt,Hl,Fl,Bl),_l=function(e){Object.assign(e.prototype,Sl)},Ml={id:function(e){const t=e.docs;for(let n=0;n<t.length;n+=1)for(let r=0;r<t[n].length;r+=1){const o=t[n][r];o.id=o.id||gi(o)}}},Ll={api:_l,compute:Ml},Kl=[{word:"@",out:["at"]},{word:"arent",out:["are","not"]},{word:"alot",out:["a","lot"]},{word:"brb",out:["be","right","back"]},{word:"cannot",out:["can","not"]},{word:"dun",out:["do","not"]},{word:"can't",out:["can","not"]},{word:"shan't",out:["should","not"]},{word:"won't",out:["will","not"]},{word:"that's",out:["that","is"]},{word:"what's",out:["what","is"]},{word:"let's",out:["let","us"]},{word:"dunno",out:["do","not","know"]},{word:"gonna",out:["going","to"]},{word:"gotta",out:["have","got","to"]},{word:"gimme",out:["give","me"]},{word:"outta",out:["out","of"]},{word:"tryna",out:["trying","to"]},{word:"gtg",out:["got","to","go"]},{word:"im",out:["i","am"]},{word:"imma",out:["I","will"]},{word:"imo",out:["in","my","opinion"]},{word:"irl",out:["in","real","life"]},{word:"ive",out:["i","have"]},{word:"rn",out:["right","now"]},{word:"tbh",out:["to","be","honest"]},{word:"wanna",out:["want","to"]},{word:"c'mere",out:["come","here"]},{word:"c'mon",out:["come","on"]},{word:"shoulda",out:["should","have"]},{word:"coulda",out:["coulda","have"]},{word:"woulda",out:["woulda","have"]},{word:"musta",out:["must","have"]},{word:"tis",out:["it","is"]},{word:"twas",out:["it","was"]},{word:"y'know",out:["you","know"]},{word:"ne'er",out:["never"]},{word:"o'er",out:["over"]},{after:"ll",out:["will"]},{after:"ve",out:["have"]},{after:"re",out:["are"]},{after:"m",out:["am"]},{before:"c",out:["ce"]},{before:"m",out:["me"]},{before:"n",out:["ne"]},{before:"qu",out:["que"]},{before:"s",out:["se"]},{before:"t",out:["tu"]},{word:"shouldnt",out:["should","not"]},{word:"couldnt",out:["could","not"]},{word:"wouldnt",out:["would","not"]},{word:"hasnt",out:["has","not"]},{word:"wasnt",out:["was","not"]},{word:"isnt",out:["is","not"]},{word:"cant",out:["can","not"]},{word:"dont",out:["do","not"]},{word:"wont",out:["will","not"]},{word:"howd",out:["how","did"]},{word:"whatd",out:["what","did"]},{word:"whend",out:["when","did"]},{word:"whered",out:["where","did"]}],Jl={st:!0,nd:!0,rd:!0,th:!0,am:!0,pm:!0,max:!0,"°":!0,s:!0,e:!0,er:!0,ère:!0,ème:!0},Wl={one:{contractions:Kl,numberSuffixes:Jl}},zn=function(e,t,n){const[r,o]=t;!n||n.length===0||(n=n.map((a,i)=>(a.implicit=a.text,a.machine=a.text,a.pre="",a.post="",a.text="",a.normal="",a.index=[r,o+i],a)),n[0]&&(n[0].pre=e[r][o].pre,n[n.length-1].post=e[r][o].post,n[0].text=e[r][o].text,n[0].normal=e[r][o].normal),e[r].splice(o,1,...n))},ql=/'/,Rl=new Set(["what","how","when","where","why"]),Ul=new Set(["be","go","start","think","need"]),Ql=new Set(["been","gone"]),Zl=function(e,t){const n=e[t].normal.split(ql)[0];if(Rl.has(n))return[n,"did"];if(e[t+1]){if(Ql.has(e[t+1].normal))return[n,"had"];if(Ul.has(e[t+1].normal))return[n,"would"]}return null},Xl=function(e,t){return e[t].normal==="ain't"||e[t].normal==="aint"?null:[e[t].normal.replace(/n't/,""),"not"]},Hr=/'/,Yl=/(e|é|aison|sion|tion)$/,eu=/(age|isme|acle|ege|oire)$/,tu=(e,t)=>{const n=e[t].normal.split(Hr)[1];return n&&n.endsWith("e")?["la",n]:["le",n]},nu=(e,t)=>{const n=e[t].normal.split(Hr)[1];return n&&Yl.test(n)&&!eu.test(n)?["du",n]:n&&n.endsWith("s")?["des",n]:["de",n]},ru=(e,t)=>["je",e[t].normal.split(Hr)[1]],Bn={preJ:ru,preL:tu,preD:nu},ou=/^([0-9.]{1,4}[a-z]{0,2}) ?[-–—] ?([0-9]{1,4}[a-z]{0,2})$/i,au=/^([0-9]{1,2}(:[0-9][0-9])?(am|pm)?) ?[-–—] ?([0-9]{1,2}(:[0-9][0-9])?(am|pm)?)$/i,iu=/^[0-9]{3}-[0-9]{4}$/,su=function(e,t){const n=e[t];let r=n.text.match(ou);return r!==null?n.tags.has("PhoneNumber")===!0||iu.test(n.text)?null:[r[1],"to",r[2]]:(r=n.text.match(au),r!==null?[r[1],"to",r[4]]:null)},lu=/^([+-]?[0-9][.,0-9]*)([a-z°²³µ/]+)$/,uu=function(e,t,n){const r=n.model.one.numberSuffixes||{},o=e[t].text.match(lu);if(o!==null){const a=o[2].toLowerCase().trim();return r.hasOwnProperty(a)?null:[o[1],a]}return null},ro=/'/,cu=/^[0-9][^-–—]*[-–—].*?[0-9]/,oo=function(e,t,n,r){const o=t.update();o.document=[e];let a=n+r;n>0&&(n-=1),e[a]&&(a+=1),o.ptrs=[[0,n,a]]},ao={t:(e,t)=>Xl(e,t),d:(e,t)=>Zl(e,t)},io={j:(e,t)=>Bn.preJ(e,t),l:(e,t)=>Bn.preL(e,t),d:(e,t)=>Bn.preD(e,t)},hu=function(e,t,n,r){for(let o=0;o<e.length;o+=1){const a=e[o];if(a.word===t.normal)return a.out;if(r!==null&&r===a.after)return[n].concat(a.out);if(n!==null&&n===a.before&&r&&r.length>2)return a.out.concat(r)}return null},Sn=function(e,t){const n=t.fromText(e.join(" "));return n.compute(["id","alias"]),n.docs[0]},du=function(e,t){for(let n=t+1;n<5&&e[n];n+=1)if(e[n].normal==="been")return["there","has"];return["there","is"]},gu=e=>{const{world:t,document:n}=e,{model:r,methods:o}=t,a=r.one.contractions||[];n.forEach((i,s)=>{for(let l=i.length-1;l>=0;l-=1){let u=null,c=null;if(ro.test(i[l].normal)===!0){const p=i[l].normal.split(ro);u=p[0],c=p[1]}let d=hu(a,i[l],u,c);if(!d&&ao.hasOwnProperty(c)&&(d=ao[c](i,l,t)),!d&&io.hasOwnProperty(u)&&(d=io[u](i,l)),u==="there"&&c==="s"&&(d=du(i,l)),d){d=Sn(d,e),zn(n,[s,l],d),oo(n[s],e,l,d.length);continue}if(cu.test(i[l].normal)){d=su(i,l),d&&(d=Sn(d,e),zn(n,[s,l],d),o.one.setTag(d,"NumberRange",t),d[2]&&d[2].tags.has("Time")&&o.one.setTag([d[0]],"Time",t,null,"time-range"),oo(n[s],e,l,d.length));continue}d=uu(i,l,t),d&&(d=Sn(d,e),zn(n,[s,l],d),o.one.setTag([d[1]],"Unit",t,null,"contraction-unit"))}})},pu={contractions:gu},mu={model:Wl,compute:pu,hooks:["contractions"]},so=function(e){const t=e.world,{model:n,methods:r}=e.world,o=r.one.setTag,{frozenLex:a}=n.one,i=n.one._multiCache||{};e.docs.forEach(s=>{for(let l=0;l<s.length;l+=1){const u=s[l],c=u.machine||u.normal;if(i[c]!==void 0&&s[l+1]){const d=l+i[c]-1;for(let p=d;p>l;p-=1){const x=s.slice(l,p+1),O=x.map(M=>M.machine||M.normal).join(" ");if(a.hasOwnProperty(O)===!0){o(x,a[O],t,!1,"1-frozen-multi-lexicon"),x.forEach(M=>M.frozen=!0);continue}}}if(a[c]!==void 0&&a.hasOwnProperty(c)){o([u],a[c],t,!1,"1-freeze-lexicon"),u.frozen=!0;continue}}})},fu=function(e){return e.docs.forEach(t=>{t.forEach(n=>{delete n.frozen})}),e},bu={frozen:so,freeze:so,unfreeze:fu},lo=e=>"\x1B[34m"+e+"\x1B[0m",uo=e=>"\x1B[3m\x1B[2m"+e+"\x1B[0m",co=function(e){e.docs.forEach(t=>{console.log(lo(`
2
2
  ┌─────────`)),t.forEach(n=>{let r=` ${uo("│")} `;const o=n.implicit||n.text||"-";n.frozen===!0?r+=`${lo(o)} ❄️`:r+=uo(o),console.log(r)})})},vu={compute:bu,mutate:e=>{const t=e.methods.one;t.termMethods.isFrozen=n=>n.frozen===!0,t.debug.freeze=co,t.debug.frozen=co},api:function(e){e.prototype.freeze=function(){return this.docs.forEach(t=>{t.forEach(n=>{n.frozen=!0})}),this},e.prototype.unfreeze=function(){this.compute("unfreeze")},e.prototype.isFrozen=function(){return this.match("@isFrozen+")}},hooks:["freeze"]},yu=function(e,t,n){const{model:r,methods:o}=n,a=o.one.setTag,i=r.one._multiCache||{},{lexicon:s}=r.one||{},l=e[t],u=l.machine||l.normal;if(i[u]!==void 0&&e[t+1]){const c=t+i[u]-1;for(let d=c;d>t;d-=1){const p=e.slice(t,d+1);if(p.length<=1)return!1;const x=p.map(O=>O.machine||O.normal).join(" ");if(s.hasOwnProperty(x)===!0){const O=s[x];return a(p,O,n,!1,"1-multi-lexicon"),O&&O.length===2&&(O[0]==="PhrasalVerb"||O[1]==="PhrasalVerb")&&a([p[1]],"Particle",n,!1,"1-phrasal-particle"),!0}}return!1}return null},ho=/^(under|over|mis|re|un|dis|semi|pre|post)-?/,wu=new Set(["Verb","Infinitive","PastTense","Gerund","PresentTense","Adjective","Participle"]),$u=function(e,t,n){const{model:r,methods:o}=n,a=o.one.setTag,{lexicon:i}=r.one,s=e[t],l=s.machine||s.normal;if(i[l]!==void 0&&i.hasOwnProperty(l))return a([s],i[l],n,!1,"1-lexicon"),!0;if(s.alias){const u=s.alias.find(c=>i.hasOwnProperty(c));if(u)return a([s],i[u],n,!1,"1-lexicon-alias"),!0}if(ho.test(l)===!0){const u=l.replace(ho,"");if(i.hasOwnProperty(u)&&u.length>3&&wu.has(i[u]))return a([s],i[u],n,!1,"1-lexicon-prefix"),!0}return null},ku=function(e){const t=e.world;e.docs.forEach(n=>{for(let r=0;r<n.length;r+=1)if(n[r].tags.size===0){let o=null;o=o||yu(n,r,t),o=o||$u(n,r,t)}})},Pu={lexicon:ku},Au=function(e){const t={},n={};return Object.keys(e).forEach(r=>{const o=e[r];r=r.toLowerCase().trim(),r=r.replace(/'s\b/,"");const a=r.split(/ /);a.length>1&&(n[a[0]]===void 0||a.length>n[a[0]])&&(n[a[0]]=a.length),t[r]=t[r]||o}),delete t[""],delete t[null],delete t[" "],{lex:t,_multi:n}},xu={one:{expandLexicon:Au}},Cu=function(e,t=!1){const n=this.world(),{methods:r,model:o}=n;if(!e)return;if(Object.keys(e).forEach(s=>{typeof e[s]=="string"&&e[s].startsWith("#")&&(e[s]=e[s].replace(/^#/,""))}),t===!0){const{lex:s,_multi:l}=r.one.expandLexicon(e,n);Object.assign(o.one._multiCache,l),Object.assign(o.one.frozenLex,s);return}if(r.two.expandLexicon){const{lex:s,_multi:l}=r.two.expandLexicon(e,n);Object.assign(o.one.lexicon,s),Object.assign(o.one._multiCache,l)}const{lex:a,_multi:i}=r.one.expandLexicon(e,n);Object.assign(o.one.lexicon,a),Object.assign(o.one._multiCache,i)},ju={addWords:Cu},Nu={one:{lexicon:{},_multiCache:{},frozenLex:{}}},Iu={model:Nu,methods:xu,compute:Pu,lib:ju,hooks:["lexicon"]},Tu=function(e,t){const{methods:n,model:r}=t;return n.one.tokenize.splitTerms(e,r).map(o=>n.one.tokenize.splitWhitespace(o,r)).map(o=>o.text.toLowerCase())},mi=function(e,t){const n=[{}],r=[null],o=[0],a=[];let i=0;e.forEach(function(s){let l=0;const u=Tu(s,t);for(let c=0;c<u.length;c++){const d=u[c];n[l]&&n[l].hasOwnProperty(d)?l=n[l][d]:(i++,n[l][d]=i,n[i]={},l=i,r[i]=null)}r[l]=[u.length]});for(const s in n[0])i=n[0][s],o[i]=0,a.push(i);for(;a.length;){const s=a.shift(),l=Object.keys(n[s]);for(let u=0;u<l.length;u+=1){const c=l[u],d=n[s][c];for(a.push(d),i=o[s];i>0&&!n[i].hasOwnProperty(c);)i=o[i];if(n.hasOwnProperty(i)){const p=n[i][c];o[d]=p,r[p]&&(r[d]=r[d]||[],r[d]=r[d].concat(r[p]))}else o[d]=0}}return{goNext:n,endAs:r,failTo:o}},Eu=function(e,t,n){let r=0;const o=[];for(let a=0;a<e.length;a++){const i=e[a][n.form]||e[a].normal;for(;r>0&&(t.goNext[r]===void 0||!t.goNext[r].hasOwnProperty(i));)r=t.failTo[r]||0;if(t.goNext[r].hasOwnProperty(i)&&(r=t.goNext[r][i],t.endAs[r])){const s=t.endAs[r];for(let l=0;l<s.length;l++){const u=s[l],c=e[a-u+1],[d,p]=c.index;o.push([d,p,p+u,c.id])}}}return o},Du=function(e,t){for(let n=0;n<e.length;n+=1)if(t.has(e[n])===!0)return!1;return!0},Hu=function(e,t,n){let r=[];n.form=n.form||"normal";const o=e.docs;if(!t.goNext||!t.goNext[0])return console.error("Compromise invalid lookup trie"),e.none();const a=Object.keys(t.goNext[0]);for(let i=0;i<o.length;i++){if(e._cache&&e._cache[i]&&Du(a,e._cache[i])===!0)continue;const s=o[i],l=Eu(s,t,n);l.length>0&&(r=r.concat(l))}return e.update(r)},Ou=e=>Object.prototype.toString.call(e)==="[object Object]";function Gu(e){e.prototype.lookup=function(t,n={}){if(!t)return this.none();typeof t=="string"&&(t=[t]);const r=Ou(t)?t:mi(t,this.world);let o=Hu(this,r,n);return o=o.settle(),o}}const _n=(e,t)=>{for(let n=e.length-1;n>=0;n-=1)if(e[n]!==t)return e=e.slice(0,n+1),e;return e},Fu=function(e){return e.goNext=e.goNext.map(t=>{if(Object.keys(t).length!==0)return t}),e.goNext=_n(e.goNext,void 0),e.failTo=_n(e.failTo,0),e.endAs=_n(e.endAs,null),e},ur={buildTrie:function(e){const t=mi(e,this.world());return Fu(t)}};ur.compile=ur.buildTrie;const Vu={api:Gu,lib:ur},go=function(e,t){return t&&e.forEach(n=>{const r=n[0];t[r]&&(n[0]=t[r][0],n[1]+=t[r][1],n[2]+=t[r][1])}),e},fi=function(e,t){let{ptrs:n}=e;const{byGroup:r}=e;return n=go(n,t),Object.keys(r).forEach(o=>{r[o]=go(r[o],t)}),{ptrs:n,byGroup:r}},qt=function(e,t,n){const r=n.methods.one;return typeof e=="number"&&(e=String(e)),typeof e=="string"&&(e=r.killUnicode(e,n),e=r.parseMatch(e,t,n)),e},bi=e=>Object.prototype.toString.call(e)==="[object Object]",Rt=e=>e&&bi(e)&&e.isView===!0,Ut=e=>e&&bi(e)&&e.isNet===!0,zu=function(e,t,n){const r=this.methods.one;if(Rt(e))return this.intersection(e);if(Ut(e))return this.sweep(e,{tagger:!1}).view.settle();e=qt(e,n,this.world);const o={regs:e,group:t},a=r.match(this.docs,o,this._cache),{ptrs:i,byGroup:s}=fi(a,this.fullPointer),l=this.toView(i);return l._groups=s,l},Bu=function(e,t,n){const r=this.methods.one;if(Rt(e))return this.intersection(e).eq(0);if(Ut(e))return this.sweep(e,{tagger:!1,matchOne:!0}).view;e=qt(e,n,this.world);const o={regs:e,group:t,justOne:!0},a=r.match(this.docs,o,this._cache),{ptrs:i,byGroup:s}=fi(a,this.fullPointer),l=this.toView(i);return l._groups=s,l},Su=function(e,t,n){const r=this.methods.one;if(Rt(e))return this.intersection(e).fullPointer.length>0;if(Ut(e))return this.sweep(e,{tagger:!1}).view.found;e=qt(e,n,this.world);const o={regs:e,group:t,justOne:!0};return r.match(this.docs,o,this._cache).ptrs.length>0},_u=function(e,t,n){const r=this.methods.one;if(Rt(e))return this.filter(l=>l.intersection(e).found);if(Ut(e)){const l=this.sweep(e,{tagger:!1}).view.settle();return this.if(l)}e=qt(e,n,this.world);const o={regs:e,group:t,justOne:!0};let a=this.fullPointer;const i=this._cache||[];a=a.filter((l,u)=>{const c=this.update([l]);return r.match(c.docs,o,i[u]).ptrs.length>0});const s=this.update(a);return this._cache&&(s._cache=a.map(l=>i[l[0]])),s},Mu=function(e,t,n){const{methods:r}=this,o=r.one;if(Rt(e))return this.filter(s=>!s.intersection(e).found);if(Ut(e)){const s=this.sweep(e,{tagger:!1}).view.settle();return this.ifNo(s)}e=qt(e,n,this.world);const a=this._cache||[],i=this.filter((s,l)=>{const u={regs:e,group:t,justOne:!0};return o.match(s.docs,u,a[l]).ptrs.length===0});return this._cache&&(i._cache=i.ptrs.map(s=>a[s[0]])),i},Lu={matchOne:Bu,match:zu,has:Su,if:_u,ifNo:Mu},Ku=function(e,t,n){const{indexN:r}=this.methods.one.pointer,o=[],a=r(this.fullPointer);Object.keys(a).forEach(s=>{const l=a[s].sort((u,c)=>u[1]>c[1]?1:-1)[0];l[1]>0&&o.push([l[0],0,l[1]])});const i=this.toView(o);return e?i.match(e,t,n):i},Ju=function(e,t,n){const{indexN:r}=this.methods.one.pointer,o=[],a=r(this.fullPointer),i=this.document;Object.keys(a).forEach(l=>{const u=a[l].sort((p,x)=>p[1]>x[1]?-1:1)[0],[c,,d]=u;d<i[c].length&&o.push([c,d,i[c].length])});const s=this.toView(o);return e?s.match(e,t,n):s},Wu=function(e,t,n){typeof e=="string"&&(e=this.world.methods.one.parseMatch(e,n,this.world)),e[e.length-1].end=!0;const r=this.fullPointer;return this.forEach((o,a)=>{const i=o.before(e,t);if(i.found){const s=i.terms();r[a][1]-=s.length,r[a][3]=s.docs[0][0].id}}),this.update(r)},qu=function(e,t,n){typeof e=="string"&&(e=this.world.methods.one.parseMatch(e,n,this.world)),e[0].start=!0;const r=this.fullPointer;return this.forEach((o,a)=>{const i=o.after(e,t);if(i.found){const s=i.terms();r[a][2]+=s.length,r[a][4]=null}}),this.update(r)},Ru=function(e,t,n){return this.growRight(e,t,n).growLeft(e,t,n)},Uu={before:Ku,after:Ju,growLeft:Wu,growRight:qu,grow:Ru},vi=function(e,t){return[e[0],e[1],t[2]]},Qu=function(e){return Object.prototype.toString.call(e)==="[object Array]"},Or=(e,t,n)=>typeof e=="string"||Qu(e)?t.match(e,n):e||t.none(),Gr=function(e,t){const[n,r,o]=e;return t.document[n]&&t.document[n][r]&&(e[3]=e[3]||t.document[n][r].id,t.document[n][o-1]&&(e[4]=e[4]||t.document[n][o-1].id)),e},xt={};xt.splitOn=function(e,t){const{splitAll:n}=this.methods.one.pointer,r=Or(e,this,t).fullPointer,o=n(this.fullPointer,r);let a=[];return o.forEach(i=>{a.push(i.passthrough),a.push(i.before),a.push(i.match),a.push(i.after)}),a=a.filter(i=>i),a=a.map(i=>Gr(i,this)),this.update(a)};xt.splitBefore=function(e,t){const{splitAll:n}=this.methods.one.pointer,r=Or(e,this,t).fullPointer,o=n(this.fullPointer,r);for(let i=0;i<o.length;i+=1)!o[i].after&&o[i+1]&&o[i+1].before&&o[i].match&&o[i].match[0]===o[i+1].before[0]&&(o[i].after=o[i+1].before,delete o[i+1].before);let a=[];return o.forEach(i=>{a.push(i.passthrough),a.push(i.before),i.match&&i.after?a.push(vi(i.match,i.after)):a.push(i.match)}),a=a.filter(i=>i),a=a.map(i=>Gr(i,this)),this.update(a)};xt.splitAfter=function(e,t){const{splitAll:n}=this.methods.one.pointer,r=Or(e,this,t).fullPointer,o=n(this.fullPointer,r);let a=[];return o.forEach(i=>{a.push(i.passthrough),i.before&&i.match?a.push(vi(i.before,i.match)):(a.push(i.before),a.push(i.match)),a.push(i.after)}),a=a.filter(i=>i),a=a.map(i=>Gr(i,this)),this.update(a)};xt.split=xt.splitAfter;const Zu=function(e,t){return!e||!t||e[0]!==t[0]?!1:e[2]===t[1]},po=function(e,t,n){const r=e.world,o=r.methods.one.parseMatch;t=t||".$",n=n||"^.";const a=o(t,{},r),i=o(n,{},r);a[a.length-1].end=!0,i[0].start=!0;const s=e.fullPointer,l=[s[0]];for(let u=1;u<s.length;u+=1){const c=l[l.length-1],d=s[u],p=e.update([c]),x=e.update([d]);Zu(c,d)&&p.has(a)&&x.has(i)?l[l.length-1]=[c[0],c[1],d[2],c[3],d[4]]:l.push(d)}return e.update(l)},Xu={joinIf:function(e,t){return po(this,e,t)},join:function(){return po(this)}},Oe=Object.assign({},Lu,Uu,xt,Xu);Oe.lookBehind=Oe.before;Oe.lookBefore=Oe.before;Oe.lookAhead=Oe.after;Oe.lookAfter=Oe.after;Oe.notIf=Oe.ifNo;const Yu=function(e){Object.assign(e.prototype,Oe)},ec=/(?:^|\s)([![^]*(?:<[^<]*>)?\/.*?[^\\/]\/[?\]+*$~]*)(?:\s|$)/,tc=/([!~[^]*(?:<[^<]*>)?\([^)]+[^\\)]\)[?\]+*$~]*)(?:\s|$)/,nc=/ /g,rc=e=>/^[![^]*(<[^<]*>)?\(/.test(e)&&/\)[?\]+*$~]*$/.test(e),mo=e=>/^[![^]*(<[^<]*>)?\//.test(e)&&/\/[?\]+*$~]*$/.test(e),fo=function(e){return e=e.map(t=>t.trim()),e=e.filter(t=>t),e},oc=function(e){const t=e.split(ec);let n=[];t.forEach(o=>{if(mo(o)){n.push(o);return}n=n.concat(o.split(tc))}),n=fo(n);let r=[];return n.forEach(o=>{rc(o)||mo(o)?r.push(o):r=r.concat(o.split(nc))}),r=fo(r),r},bo=/\{([0-9]+)?(, *[0-9]*)?\}/,vo=/&&/,ac=new RegExp(/^<\s*(\S+)\s*>/),yo=e=>e.charAt(0).toUpperCase()+e.substring(1),$e=e=>e.charAt(e.length-1),me=e=>e.charAt(0),wt=e=>e.substring(1),$t=e=>e.substring(0,e.length-1),Dt=function(e){return e=wt(e),e=$t(e),e},yi=function(e,t){const n={};for(let r=0;r<2;r+=1){if($e(e)==="$"&&(n.end=!0,e=$t(e)),me(e)==="^"&&(n.start=!0,e=wt(e)),$e(e)==="?"&&(n.optional=!0,e=$t(e)),(me(e)==="["||$e(e)==="]")&&(n.group=null,me(e)==="["&&(n.groupStart=!0),$e(e)==="]"&&(n.groupEnd=!0),e=e.replace(/^\[/,""),e=e.replace(/\]$/,""),me(e)==="<")){const o=ac.exec(e);o.length>=2&&(n.group=o[1],e=e.replace(o[0],""))}if($e(e)==="+"&&(n.greedy=!0,e=$t(e)),e!=="*"&&$e(e)==="*"&&e!=="\\*"&&(n.greedy=!0,e=$t(e)),me(e)==="!"&&(n.negative=!0,e=wt(e)),me(e)==="~"&&$e(e)==="~"&&e.length>2&&(e=Dt(e),n.fuzzy=!0,n.min=t.fuzzy||.85,/\(/.test(e)===!1))return n.word=e,n;if(me(e)==="/"&&$e(e)==="/")return e=Dt(e),t.caseSensitive&&(n.use="text"),n.regex=new RegExp(e),n;if(bo.test(e)===!0&&(e=e.replace(bo,(o,a,i)=>(i===void 0?(n.min=Number(a),n.max=Number(a)):(i=i.replace(/, */,""),a===void 0?(n.min=0,n.max=Number(i)):(n.min=Number(a),n.max=Number(i||999))),n.greedy=!0,n.min||(n.optional=!0),""))),me(e)==="("&&$e(e)===")"){vo.test(e)?(n.choices=e.split(vo),n.operator="and"):(n.choices=e.split("|"),n.operator="or"),n.choices[0]=wt(n.choices[0]);const o=n.choices.length-1;n.choices[o]=$t(n.choices[o]),n.choices=n.choices.map(a=>a.trim()),n.choices=n.choices.filter(a=>a),n.choices=n.choices.map(a=>a.split(/ /g).map(i=>yi(i,t))),e=""}if(me(e)==="{"&&$e(e)==="}"){if(e=Dt(e),n.root=e,/\//.test(e)){const o=n.root.split(/\//);n.root=o[0],n.pos=o[1],n.pos==="adj"&&(n.pos="Adjective"),n.pos=n.pos.charAt(0).toUpperCase()+n.pos.substr(1).toLowerCase(),o[2]!==void 0&&(n.sense=o[2])}return n}if(me(e)==="<"&&$e(e)===">")return e=Dt(e),n.chunk=yo(e),n.greedy=!0,n;if(me(e)==="%"&&$e(e)==="%")return e=Dt(e),n.switch=e,n}return me(e)==="#"?(n.tag=wt(e),n.tag=yo(n.tag),n):me(e)==="@"?(n.method=wt(e),n):e==="."?(n.anything=!0,n):e==="*"?(n.anything=!0,n.greedy=!0,n.optional=!0,n):(e&&(e=e.replace("\\*","*"),e=e.replace("\\.","."),t.caseSensitive?n.use="text":e=e.toLowerCase(),n.word=e),n)},ic=/[a-z0-9][-–—][a-z]/i,sc=function(e,t){const n=t.model.one.prefixes;for(let r=e.length-1;r>=0;r-=1){const o=e[r];if(o.word&&ic.test(o.word)){let a=o.word.split(/[-–—]/g);if(n.hasOwnProperty(a[0]))continue;a=a.filter(i=>i).reverse(),e.splice(r,1),a.forEach(i=>{const s=Object.assign({},o);s.word=i,e.splice(r,0,s)})}}return e},wo=function(e,t){const{all:n}=t.methods.two.transform.verb||{},r=e.root;return n?n(r,t.model):[]},$o=function(e,t){const{all:n}=t.methods.two.transform.noun||{};return n?n(e.root,t.model):[e.root]},ko=function(e,t){const{all:n}=t.methods.two.transform.adjective||{};return n?n(e.root,t.model):[e.root]},lc=function(e,t){return e=e.map(n=>{if(n.root)if(t.methods.two&&t.methods.two.transform){let r=[];n.pos?n.pos==="Verb"?r=r.concat(wo(n,t)):n.pos==="Noun"?r=r.concat($o(n,t)):n.pos==="Adjective"&&(r=r.concat(ko(n,t))):(r=r.concat(wo(n,t)),r=r.concat($o(n,t)),r=r.concat(ko(n,t))),r=r.filter(o=>o),r.length>0&&(n.operator="or",n.fastOr=new Set(r))}else n.machine=n.root,delete n.id,delete n.root;return n}),e},uc=function(e){let t=0,n=null;for(let r=0;r<e.length;r++){const o=e[r];o.groupStart===!0&&(n=o.group,n===null&&(n=String(t),t+=1)),n!==null&&(o.group=n),o.groupEnd===!0&&(n=null)}return e},cc=function(e){return e.map(t=>{if(t.choices!==void 0){if(t.operator!=="or"||t.fuzzy===!0)return t;t.choices.every(n=>{if(n.length!==1)return!1;const r=n[0];return r.fuzzy===!0||r.start||r.end?!1:r.word!==void 0&&r.negative!==!0&&r.optional!==!0&&r.method!==!0})===!0&&(t.fastOr=new Set,t.choices.forEach(n=>{t.fastOr.add(n[0].word)}),delete t.choices)}return t})},hc=function(e){return e.map(t=>(t.fuzzy&&t.choices&&t.choices.forEach(n=>{n.length===1&&n[0].word&&(n[0].fuzzy=!0,n[0].min=t.min)}),t))},dc=function(e){return e=uc(e),e=cc(e),e=hc(e),e},gc=function(e,t,n){if(e==null||e==="")return[];t=t||{},typeof e=="number"&&(e=String(e));let r=oc(e);return r=r.map(o=>yi(o,t)),r=sc(r,n),r=lc(r,n),r=dc(r),r},pc=function(e,t){for(const n of t)if(e.has(n))return!0;return!1},mc=function(e,t){for(let n=0;n<e.length;n+=1){const r=e[n];if(!(r.optional===!0||r.negative===!0||r.fuzzy===!0)){if(r.word!==void 0&&t.has(r.word)===!1||r.tag!==void 0&&t.has("#"+r.tag)===!1)return!0;if(r.fastOr&&pc(r.fastOr,t)===!1)return!1}}return!1},fc=function(e,t){const n=e.length,r=t.length;if(n===0)return r;if(r===0)return n;const o=(r>n?r:n)+1;if(Math.abs(n-r)>(o||100))return o||100;const a=[];for(let p=0;p<o;p++)a[p]=[p],a[p].length=o;for(let p=0;p<o;p++)a[0][p]=p;let i,s,l,u,c,d;for(let p=1;p<=n;++p)for(s=e[p-1],i=1;i<=r;++i){if(p===i&&a[p][i]>4)return n;l=t[i-1],u=s===l?0:1,c=a[p-1][i]+1,(d=a[p][i-1]+1)<c&&(c=d),(d=a[p-1][i-1]+u)<c&&(c=d),p>1&&i>1&&s===t[i-2]&&e[p-2]===l&&(d=a[p-2][i-2]+u)<c?a[p][i]=d:a[p][i]=c}return a[n][r]},bc=function(e,t,n=3){if(e===t)return 1;if(e.length<n||t.length<n)return 0;const r=fc(e,t),o=Math.max(e.length,t.length);return 1-(o===0?0:r/o)},vc=/([\u0022\uFF02\u0027\u201C\u2018\u201F\u201B\u201E\u2E42\u201A\u00AB\u2039\u2035\u2036\u2037\u301D\u0060\u301F])/,yc=/([\u0022\uFF02\u0027\u201D\u2019\u00BB\u203A\u2032\u2033\u2034\u301E\u00B4])/,Po=/^[-–—]$/,Ao=/ [-–—]{1,3} /,Ge=(e,t)=>e.post.indexOf(t)!==-1,Lt={hasQuote:e=>vc.test(e.pre)||yc.test(e.post),hasComma:e=>Ge(e,","),hasPeriod:e=>Ge(e,".")===!0&&Ge(e,"...")===!1,hasExclamation:e=>Ge(e,"!"),hasQuestionMark:e=>Ge(e,"?")||Ge(e,"¿"),hasEllipses:e=>Ge(e,"..")||Ge(e,"…"),hasSemicolon:e=>Ge(e,";"),hasColon:e=>Ge(e,":"),hasSlash:e=>/\//.test(e.text),hasHyphen:e=>Po.test(e.post)||Po.test(e.pre),hasDash:e=>Ao.test(e.post)||Ao.test(e.pre),hasContraction:e=>!!e.implicit,isAcronym:e=>e.tags.has("Acronym"),isKnown:e=>e.tags.size>0,isTitleCase:e=>new RegExp("^\\p{Lu}[a-z'\\u00C0-\\u00FF]","u").test(e.text),isUpperCase:e=>new RegExp("^\\p{Lu}+$","u").test(e.text)};Lt.hasQuotation=Lt.hasQuote;let jn=function(){};const wc=function(e,t,n,r){if(t.anything===!0)return!0;if(t.start===!0&&n!==0||t.end===!0&&n!==r-1)return!1;if(t.id!==void 0&&t.id===e.id)return!0;if(t.word!==void 0)return t.use?t.word===e[t.use]:e.machine!==null&&e.machine===t.word||e.alias!==void 0&&e.alias.hasOwnProperty(t.word)||t.fuzzy===!0&&(t.word===e.root||bc(t.word,e.normal)>=t.min)||e.alias&&e.alias.some(o=>o===t.word)?!0:t.word===e.text||t.word===e.normal;if(t.tag!==void 0)return e.tags.has(t.tag)===!0;if(t.method!==void 0)return typeof Lt[t.method]=="function"&&Lt[t.method](e)===!0;if(t.pre!==void 0)return e.pre&&e.pre.includes(t.pre);if(t.post!==void 0)return e.post&&e.post.includes(t.post);if(t.regex!==void 0){let o=e.normal;return t.use&&(o=e[t.use]),t.regex.test(o)}if(t.chunk!==void 0)return e.chunk===t.chunk;if(t.switch!==void 0)return e.switch===t.switch;if(t.machine!==void 0)return e.normal===t.machine||e.machine===t.machine||e.root===t.machine;if(t.sense!==void 0)return e.sense===t.sense;if(t.fastOr!==void 0){if(t.pos&&!e.tags.has(t.pos))return null;const o=e.root||e.implicit||e.machine||e.normal;return t.fastOr.has(o)||t.fastOr.has(e.text)}return t.choices!==void 0?t.operator==="and"?t.choices.every(o=>jn(e,o,n,r)):t.choices.some(o=>jn(e,o,n,r)):!1};jn=function(e,t,n,r){const o=wc(e,t,n,r);return t.negative===!0?!o:o};const ge=jn,$c=function(e,t){const n=Object.assign({},e.regs[e.r],{start:!1,end:!1}),r=e.t;for(;e.t<e.terms.length;e.t+=1){if(t&&ge(e.terms[e.t],t,e.start_i+e.t,e.phrase_length))return e.t;const o=e.t-r+1;if(n.max!==void 0&&o===n.max)return e.t;if(ge(e.terms[e.t],n,e.start_i+e.t,e.phrase_length)===!1)return n.min!==void 0&&o<n.min?null:e.t}return e.t},kc=function(e,t){let n=e.t;if(!t)return e.terms.length;for(;n<e.terms.length;n+=1)if(ge(e.terms[n],t,e.start_i+n,e.phrase_length)===!0)return n;return null},Pc=function(e,t){if(e.end===!0&&e.greedy===!0&&t.start_i+t.t<t.phrase_length-1){const n=Object.assign({},e,{end:!1});if(ge(t.terms[t.t],n,t.start_i+t.t,t.phrase_length)===!0)return!0}return!1},Dn=function(e,t){return e.groups[e.inGroup]||(e.groups[e.inGroup]={start:t,length:0}),e.groups[e.inGroup]},Ac=function(e){const{regs:t}=e,n=t[e.r],r=kc(e,t[e.r+1]);if(r===null||r===0||n.min!==void 0&&r-e.t<n.min)return null;if(n.max!==void 0&&r-e.t>n.max)return e.t=e.t+n.max,!0;if(e.hasGroup===!0){const o=Dn(e,e.t);o.length=r-e.t}return e.t=r,!0},xc=function(e){return Object.prototype.toString.call(e)==="[object Array]"},wi=function(e,t=0){const n=e.regs[e.r];let r=!1;for(let o=0;o<n.choices.length;o+=1){const a=n.choices[o];if(!xc(a))return!1;if(r=a.every((i,s)=>{let l=0;const u=e.t+s+t+l;if(e.terms[u]===void 0)return!1;const c=ge(e.terms[u],i,u+e.start_i,e.phrase_length);if(c===!0&&i.greedy===!0)for(let d=1;d<e.terms.length;d+=1){const p=e.terms[u+d];if(p)if(ge(p,i,e.start_i+d,e.phrase_length)===!0)l+=1;else break}return t+=l,c}),r){t+=a.length;break}}return r&&n.greedy===!0?wi(e,t):t},Cc=function(e){let t=0;return e.regs[e.r].choices.every(n=>{const r=n.every((o,a)=>{const i=e.t+a;return e.terms[i]===void 0?!1:ge(e.terms[i],o,i,e.phrase_length)});return r===!0&&n.length>t&&(t=n.length),r})===!0?t:!1},jc=function(e){const{regs:t}=e,n=t[e.r],r=wi(e);if(r){if(n.negative===!0)return null;if(e.hasGroup===!0){const o=Dn(e,e.t);o.length+=r}if(n.end===!0){const o=e.phrase_length;if(e.t+e.start_i+r!==o)return null}return e.t+=r,!0}else if(!n.optional)return null;return!0},Nc=function(e){const{regs:t}=e,n=t[e.r],r=Cc(e);if(r){if(n.negative===!0)return null;if(e.hasGroup===!0){const o=Dn(e,e.t);o.length+=r}if(n.end===!0){const o=e.phrase_length-1;if(e.t+e.start_i!==o)return null}return e.t+=r,!0}else if(!n.optional)return null;return!0},Ic=function(e,t,n){let r=0;for(let o=e.t;o<e.terms.length;o+=1){let a=ge(e.terms[o],t,e.start_i+e.t,e.phrase_length);if(a||n&&(a=ge(e.terms[o],n,e.start_i+e.t,e.phrase_length),a)||(r+=1,t.max!==void 0&&r===t.max))break}return r===0||t.min&&t.min>r?!1:(e.t+=r,!0)},Tc=function(e){const{regs:t}=e,n=t[e.r],r=Object.assign({},n);if(r.negative=!1,ge(e.terms[e.t],r,e.start_i+e.t,e.phrase_length))return!1;if(n.optional){const o=t[e.r+1];o&&(ge(e.terms[e.t],o,e.start_i+e.t,e.phrase_length)?e.r+=1:o.optional&&t[e.r+2]&&ge(e.terms[e.t],t[e.r+2],e.start_i+e.t,e.phrase_length)&&(e.r+=2))}return n.greedy?Ic(e,r,t[e.r+1]):(e.t+=1,!0)},Ec=function(e){const{regs:t}=e,n=t[e.r],r=e.terms[e.t],o=ge(r,t[e.r+1],e.start_i+e.t,e.phrase_length);if(n.negative||o){const a=e.terms[e.t+1];(!a||!ge(a,t[e.r+1],e.start_i+e.t,e.phrase_length))&&(e.r+=1)}},Dc=function(e){const{regs:t,phrase_length:n}=e,r=t[e.r];return e.t=$c(e,t[e.r+1]),e.t===null||r.min&&r.min>e.t||r.end===!0&&e.start_i+e.t!==n?null:!0},Hc=function(e){const t=e.terms[e.t],n=e.regs[e.r];if(t.implicit&&e.terms[e.t+1]){if(!e.terms[e.t+1].implicit)return;n.word===t.normal&&(e.t+=1),n.method==="hasContraction"&&(e.t+=1)}},Oc=function(e,t){const n=e.regs[e.r],r=Dn(e,t);e.t>1&&n.greedy?r.length+=e.t-t:r.length++},Mn=function(e){const{regs:t}=e,n=t[e.r],r=e.terms[e.t],o=e.t;return n.optional&&t[e.r+1]&&n.negative?!0:(n.optional&&t[e.r+1]&&Ec(e),r.implicit&&e.terms[e.t+1]&&Hc(e),e.t+=1,n.end===!0&&e.t!==e.terms.length&&n.greedy!==!0||n.greedy===!0&&!Dc(e)?null:(e.hasGroup===!0&&Oc(e,o),!0))},Fr=function(e,t,n,r){if(e.length===0||t.length===0)return null;const o={t:0,terms:e,r:0,regs:t,groups:{},start_i:n,phrase_length:r,inGroup:null};for(;o.r<t.length;o.r+=1){const s=t[o.r];if(o.hasGroup=!!s.group,o.hasGroup===!0?o.inGroup=s.group:o.inGroup=null,!o.terms[o.t]){if(t.slice(o.r).some(l=>!l.optional)===!1)break;return null}if(s.anything===!0&&s.greedy===!0){if(!Ac(o))return null;continue}if(s.choices!==void 0&&s.operator==="or"){if(!jc(o))return null;continue}if(s.choices!==void 0&&s.operator==="and"){if(!Nc(o))return null;continue}if(s.anything===!0){if(s.negative&&s.anything||!Mn(o))return null;continue}if(Pc(s,o)===!0){if(!Mn(o))return null;continue}if(s.negative){if(!Tc(o))return null;continue}if(ge(o.terms[o.t],s,o.start_i+o.t,o.phrase_length)===!0){if(!Mn(o))return null;continue}if(s.optional!==!0)return null}const a=[null,n,o.t+n];if(a[1]===a[2])return null;const i={};return Object.keys(o.groups).forEach(s=>{const l=o.groups[s],u=n+l.start;i[s]=[null,u,u+l.length]}),{pointer:a,groups:i}},Gc=function(e,t){const n=[],r={};return e.length===0?{ptrs:n,byGroup:r}:(typeof t=="number"&&(t=String(t)),t?e.forEach(o=>{o.groups[t]&&n.push(o.groups[t])}):e.forEach(o=>{n.push(o.pointer),Object.keys(o.groups).forEach(a=>{r[a]=r[a]||[],r[a].push(o.groups[a])})}),{ptrs:n,byGroup:r})},Fc=function(e,t,n){return e=e.filter(r=>{const[o,a,i]=r.pointer,s=n[o].slice(a,i);for(let l=0;l<s.length;l+=1){const u=s.slice(l);if(Fr(u,t,l,s.length)!==null)return!1}return!0}),e},$i=function(e,t){return e.pointer[0]=t,Object.keys(e.groups).forEach(n=>{e.groups[n][0]=t}),e},Vc=function(e,t,n){let r=Fr(e,t,0,e.length);return r?(r=$i(r,n),r):null},zc=function(e,t,n){n=n||[];const{regs:r,group:o,justOne:a}=t;let i=[];if(!r||r.length===0)return{ptrs:[],byGroup:{}};const s=r.filter(l=>l.optional!==!0&&l.negative!==!0).length;e:for(let l=0;l<e.length;l+=1){const u=e[l];if(!(n[l]&&mc(r,n[l]))){if(r[0].start===!0){const c=Vc(u,r,l);c&&i.push(c);continue}for(let c=0;c<u.length;c+=1){const d=u.slice(c);if(d.length<s)break;let p=Fr(d,r,c,u.length);if(p){if(p=$i(p,l),i.push(p),a===!0)break e;const x=p.pointer[2];Math.abs(x-1)>c&&(c=Math.abs(x-1))}}}}return r[r.length-1].end===!0&&(i=i.filter(l=>{const u=l.pointer[0];return e[u].length===l.pointer[2]})),t.notIf&&(i=Fc(i,t.notIf,e)),i=Gc(i,o),i.ptrs.forEach(l=>{const[u,c,d]=l;l[3]=e[u][c].id,l[4]=e[u][d-1].id}),i},Bc={one:{termMethods:Lt,parseMatch:gc,match:zc}},Sc={parseMatch:function(e,t){const n=this.world(),r=n.methods.one.killUnicode;return r&&(e=r(e,n)),n.methods.one.parseMatch(e,t,n)}},_c={api:Yu,methods:Bc,lib:Sc},Mc=/^\../,Lc=/^#./,Kc=e=>(e=e.replace(/&/g,"&amp;"),e=e.replace(/</g,"&lt;"),e=e.replace(/>/g,"&gt;"),e=e.replace(/"/g,"&quot;"),e=e.replace(/'/g,"&apos;"),e),Jc=function(e){let t="",n="</span>";return e=Kc(e),Mc.test(e)?t=`<span class="${e.replace(/^\./,"")}"`:Lc.test(e)?t=`<span id="${e.replace(/^#/,"")}"`:(t=`<${e}`,n=`</${e}>`),t+=">",{start:t,end:n}},Wc=function(e,t){const n={},r={};return Object.keys(t).forEach(o=>{let a=t[o];const i=Jc(o);typeof a=="string"&&(a=e.match(a)),a.docs.forEach(s=>{if(s.every(c=>c.implicit))return;const l=s[0].id;n[l]=n[l]||[],n[l].push(i.start);const u=s[s.length-1].id;r[u]=r[u]||[],r[u].push(i.end)})}),{starts:n,ends:r}},qc=function(e){const{starts:t,ends:n}=Wc(this,e);let r="";return this.docs.forEach(o=>{for(let a=0;a<o.length;a+=1){const i=o[a];t.hasOwnProperty(i.id)&&(r+=t[i.id].join("")),r+=i.pre||"",r+=i.text||"",n.hasOwnProperty(i.id)&&(r+=n[i.id].join("")),r+=i.post||""}}),r},Rc={html:qc},ki=/[,:;)\]*.?~!\u0022\uFF02\u201D\u2019\u00BB\u203A\u2032\u2033\u2034\u301E\u00B4—-]+$/,cr=/^[(['"*~\uFF02\u201C\u2018\u201F\u201B\u201E\u2E42\u201A\u00AB\u2039\u2035\u2036\u2037\u301D\u0060\u301F]+/,Uc=/[,:;)('"\u201D\]]/,Qc=/^[-–—]$/,Zc=/ /,it=function(e,t,n=!0){let r="";return e.forEach(o=>{let a=o.pre||"",i=o.post||"";t.punctuation==="some"&&(a=a.replace(cr,""),Qc.test(i)&&(i=" "),i=i.replace(Uc,""),i=i.replace(/\?!+/,"?"),i=i.replace(/!+/,"!"),i=i.replace(/\?+/,"?"),i=i.replace(/\.{2,}/,""),o.tags.has("Abbreviation")&&(i=i.replace(/\./,""))),t.whitespace==="some"&&(a=a.replace(/\s/,""),i=i.replace(/\s+/," ")),t.keepPunct||(a=a.replace(cr,""),i==="-"?i=" ":i=i.replace(ki,""));let s=o[t.form||"text"]||o.normal||"";t.form==="implicit"&&(s=o.implicit||o.text),t.form==="root"&&o.implicit&&(s=o.root||o.implicit||o.normal),(t.form==="machine"||t.form==="implicit"||t.form==="root")&&o.implicit&&(!i||!Zc.test(i))&&(i+=" "),r+=a+s+i}),n===!1&&(r=r.trim()),t.lowerCase===!0&&(r=r.toLowerCase()),r},Xc=function(e,t){let n="";if(!e||!e[0]||!e[0][0])return n;for(let r=0;r<e.length;r+=1)n+=it(e[r],t,!0);if(t.keepSpace||(n=n.trim()),t.keepEndPunct===!1){e[0][0].tags.has("Emoticon")||(n=n.replace(cr,""));const r=e[e.length-1];r[r.length-1].tags.has("Emoticon")||(n=n.replace(ki,"")),n.endsWith("'")&&!n.endsWith("s'")&&(n=n.replace(/'/,""))}return t.cleanWhitespace===!0&&(n=n.trim()),n},tt={text:{form:"text"},normal:{whitespace:"some",punctuation:"some",case:"some",unicode:"some",form:"normal"},machine:{keepSpace:!1,whitespace:"some",punctuation:"some",case:"none",unicode:"some",form:"machine"},root:{keepSpace:!1,whitespace:"some",punctuation:"some",case:"some",unicode:"some",form:"root"},implicit:{form:"implicit"}};tt.clean=tt.normal;tt.reduced=tt.root;const Pi=[];let st=0;for(;st<64;)Pi[st]=0|Math.sin(++st%Math.PI)*4294967296;const Vr=function(e){let t,n,r,o=decodeURI(encodeURI(e))+"€",a=o.length;const i=[t=1732584193,n=4023233417,~t,~n],s=[];for(e=--a/4+2|15,s[--e]=a*8;~a;)s[a>>2]|=o.charCodeAt(a)<<8*a--;for(st=o=0;st<e;st+=16){for(a=i;o<64;a=[r=a[3],t+((r=a[0]+[t&n|~t&r,r&t|~r&n,t^n^r,n^(t|~r)][a=o>>4]+Pi[o]+~~s[st|[o,5*o+1,3*o+5,7*o][a]&15])<<(a=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*a+o++%4])|r>>>-a),t,n])t=a[1]|0,n=a[2];for(o=4;o;)i[--o]+=a[o]}for(e="";o<32;)e+=(i[o>>3]>>(1^o++)*4&15).toString(16);return e},Yc={text:!0,terms:!0},xo={case:"none",unicode:"some",form:"machine",punctuation:"some"},Ln=function(e,t){return Object.assign({},e,t)},Ue={text:e=>it(e,{keepPunct:!0},!1),normal:e=>it(e,Ln(tt.normal,{keepPunct:!0}),!1),implicit:e=>it(e,Ln(tt.implicit,{keepPunct:!0}),!1),machine:e=>it(e,xo,!1),root:e=>it(e,Ln(xo,{form:"root"}),!1),hash:e=>Vr(it(e,{keepPunct:!0},!1)),offset:e=>{const t=Ue.text(e).length;return{index:e[0].offset.index,start:e[0].offset.start,length:t}},terms:e=>e.map(t=>{const n=Object.assign({},t);return n.tags=Array.from(t.tags),n}),confidence:(e,t,n)=>t.eq(n).confidence(),syllables:(e,t,n)=>t.eq(n).syllables(),sentence:(e,t,n)=>t.eq(n).fullSentence().text(),dirty:e=>e.some(t=>t.dirty===!0)};Ue.sentences=Ue.sentence;Ue.clean=Ue.normal;Ue.reduced=Ue.root;const eh=function(e,t){return t=t||{},typeof t=="string"&&(t={}),t=Object.assign({},Yc,t),t.offset&&e.compute("offset"),e.docs.map((n,r)=>{const o={};return Object.keys(t).forEach(a=>{t[a]&&Ue[a]&&(o[a]=Ue[a](n,e,r))}),o})},hr={json:function(e){const t=eh(this,e);return typeof e=="number"?t[e]:t}};hr.data=hr.json;const th=()=>typeof window<"u"&&window.document,nh=function(e){const t=this.methods.one.debug||{};return e&&t.hasOwnProperty(e)?(t[e](this),this):th()?(t.clientSide(this),this):(t.tags(this),this)},rh=function(e){const t=e.pre||"",n=e.post||"";return t+e.text+n},oh=function(e,t){const n={};return Object.keys(t).forEach(r=>{e.match(r).fullPointer.forEach(o=>{n[o[3]]={fn:t[r],end:o[2]}})}),n},Ai=function(e,t){const n=oh(e,t);let r="";return e.docs.forEach((o,a)=>{for(let i=0;i<o.length;i+=1){const s=o[i];if(n.hasOwnProperty(s.id)){const{fn:l,end:u}=n[s.id],c=e.update([[a,i,u]]);r+=o[i].pre||"",r+=l(c),i=u-1,r+=o[i].post||""}else r+=rh(s)}}),r},ah=e=>Object.prototype.toString.call(e)==="[object Object]",ih=function(e){const t={};return e.forEach(n=>{t[n]=t[n]||0,t[n]+=1}),Object.keys(t).map(n=>({normal:n,count:t[n]})).sort((n,r)=>n.count>r.count?-1:0)},sh=function(e){if(ah(e))return Ai(this,e);if(e==="text")return this.text();if(e==="normal")return this.text("normal");if(e==="root")return this.text("root");if(e==="machine"||e==="reduced")return this.text("machine");if(e==="hash"||e==="md5")return Vr(this.text());if(e==="json")return this.json();if(e==="offset"||e==="offsets")return this.compute("offset"),this.json({offset:!0});if(e==="array")return this.docs.map(t=>t.reduce((n,r)=>n+r.pre+r.text+r.post,"").trim()).filter(t=>t);if(e==="freq"||e==="frequency"||e==="topk")return ih(this.json({normal:!0}).map(t=>t.normal));if(e==="terms"){let t=[];return this.docs.forEach(n=>{let r=n.map(o=>o.text);r=r.filter(o=>o),t=t.concat(r)}),t}return e==="tags"?this.docs.map(t=>t.reduce((n,r)=>(n[r.implicit||r.normal]=Array.from(r.tags),n),{})):e==="debug"?this.debug():this.text()},lh={debug:nh,out:sh,wrap:function(e){return Ai(this,e)}},uh=e=>Object.prototype.toString.call(e)==="[object Object]",ch={text:function(e){let t={};if(e&&typeof e=="string"&&tt.hasOwnProperty(e)?t=Object.assign({},tt[e]):e&&uh(e)&&(t=Object.assign({},e)),t.keepSpace===void 0&&!this.isFull()&&(t.keepSpace=!1),t.keepEndPunct===void 0&&this.pointer){const n=this.pointer[0];n&&n[1]?t.keepEndPunct=!1:t.keepEndPunct=!0}return t.keepPunct===void 0&&(t.keepPunct=!0),t.keepSpace===void 0&&(t.keepSpace=!0),Xc(this.docs,t)}},hh=Object.assign({},lh,ch,hr,Rc),dh=function(e){Object.assign(e.prototype,hh)},gh=function(e){console.log("%c -=-=- ","background-color:#6699cc;"),e.forEach(t=>{console.groupCollapsed(t.text());const n=t.docs[0].map(r=>{let o=r.text||"-";r.implicit&&(o="["+r.implicit+"]");const a="["+Array.from(r.tags).join(", ")+"]";return{text:o,tags:a}});console.table(n,["text","tags"]),console.groupEnd()})},Be="\x1B[0m",ve={green:e=>"\x1B[32m"+e+Be,red:e=>"\x1B[31m"+e+Be,blue:e=>"\x1B[34m"+e+Be,magenta:e=>"\x1B[35m"+e+Be,cyan:e=>"\x1B[36m"+e+Be,yellow:e=>"\x1B[33m"+e+Be,black:e=>"\x1B[30m"+e+Be,dim:e=>"\x1B[2m"+e+Be,i:e=>"\x1B[3m"+e+Be},ph=function(e,t){return t.one.tagSet&&(e=e.map(n=>{if(!t.one.tagSet.hasOwnProperty(n))return n;const r=t.one.tagSet[n].color||"blue";return ve[r](n)})),e.join(", ")},mh=function(e){const{docs:t,model:n}=e;t.length===0&&console.log(ve.blue(`
3
3
  ──────`)),t.forEach(r=>{console.log(ve.blue(`
4
4
  ┌─────────`)),r.forEach(o=>{const a=[...o.tags||[]];let i=o.text||"-";o.sense&&(i=`{${o.normal}/${o.sense}}`),o.implicit&&(i="["+o.implicit+"]"),i=ve.yellow(i);let s="'"+i+"'";if(o.reference){const u=e.update([o.reference]).text("normal");s+=` - ${ve.dim(ve.i("["+u+"]"))}`}s=s.padEnd(18);const l=ve.blue(" │ ")+ve.i(s)+" - "+ph(a,n);console.log(l)})}),console.log(`
@@ -1 +1 @@
1
- import{createRequire as p}from"node:module";import{w as u,l as $,c as R}from"../packem_shared/index-uBVnF4ji.js";import{cleanWorkspace as j}from"#native";import{l as b}from"../packem_shared/missing-package-json-BqS-OnKd.js";import{p as c}from"./cli-main.js";import{o as w}from"../packem_shared/utils-CRueU43T.js";let g;const k=o=>(g??=p(import.meta.url))(o),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=o=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[r,n]=d.versions.node.split(".").map(Number);if(r>22||r===22&&n>=3||r===20&&n>=16)return d.getBuiltinModule(o)}return k(o)},{readdirSync:h,lstatSync:_,rmSync:v}=y("node:fs"),S=/node_modules/,q=/\.git/,C=o=>{const r=[],n=[o];for(;n.length>0;){const s=n.pop();let i;try{i=h(s)}catch{continue}for(const t of i){const e=u(s,t);try{const f=_(e);if(f.isSymbolicLink()||!f.isDirectory())continue}catch{continue}t==="node_modules"?r.push(e):t!==".git"&&t!==".hg"&&n.push(e)}}return r},P=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"],x=(o,r,n)=>{let s=0,i=!1;for(const t of P){const e=u(o,t);if($(e)){n.info(` ${e}`),s++;continue}}return{hadError:i,removed:s}},D=o=>{for(const r of R(o,{includeDirs:!1,includeSymlinks:!1,skip:[S,q]}))if(r.name==="package.json")return!0;return!1},m=(o,r,n)=>{let s=0,i=!1;for(const{packageDir:t}of b(o)){const e=u(o,t);if(!D(e)){if(r){n.info(` ${e}`),s++;continue}try{v(e,{force:!0,recursive:!0}),c.success(`Removed empty package ${e}`),s++}catch(f){c.error(`${e}: ${w(f)}`),i=!0}}}return{hadError:i,removed:s}},J=async({logger:o,options:r,workspaceRoot:n})=>{const s=n??process.cwd(),i=r.lockfile||!1,t=r.emptyPackages||!1;if(r.dryRun){const l=C(s);if(l.length>0){c.info("Would remove:");for(const a of l)o.info(` ${a}`)}else c.info("No node_modules directories found.");i&&x(s,!0,o),t&&(c.info("Would remove empty packages:"),m(s,!0,o));return}const e=j(s,i);for(const l of e.removed)c.success(`Removed ${l}`);for(const l of e.lockfilesRemoved)c.success(`Removed ${l}`);for(const l of e.errors)c.error(l);e.removed.length===0&&e.lockfilesRemoved.length===0?c.info("No node_modules directories found."):c.info(`Cleaned ${e.removed.length} node_modules director${e.removed.length===1?"y":"ies"}`);let f=!1;if(t){const{hadError:l,removed:a}=m(s,!1,o);f=l,a>0&&c.info(`Cleaned ${a} empty package director${a===1?"y":"ies"}`)}(e.errors.length>0||f)&&(process.exitCode=1)};export{J as default};
1
+ import{createRequire as p}from"node:module";import{w as u,l as $,e as R}from"../packem_shared/index-BLtnel38.js";import{cleanWorkspace as j}from"#native";import{l as b}from"../packem_shared/missing-package-json-Cl0vdz6K.js";import{p as c}from"./cli-main.js";import{o as w}from"../packem_shared/utils-CRueU43T.js";let g;const k=o=>(g??=p(import.meta.url))(o),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=o=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[r,n]=d.versions.node.split(".").map(Number);if(r>22||r===22&&n>=3||r===20&&n>=16)return d.getBuiltinModule(o)}return k(o)},{readdirSync:h,lstatSync:_,rmSync:v}=y("node:fs"),S=/node_modules/,q=/\.git/,C=o=>{const r=[],n=[o];for(;n.length>0;){const s=n.pop();let i;try{i=h(s)}catch{continue}for(const t of i){const e=u(s,t);try{const f=_(e);if(f.isSymbolicLink()||!f.isDirectory())continue}catch{continue}t==="node_modules"?r.push(e):t!==".git"&&t!==".hg"&&n.push(e)}}return r},P=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"],x=(o,r,n)=>{let s=0,i=!1;for(const t of P){const e=u(o,t);if($(e)){n.info(` ${e}`),s++;continue}}return{hadError:i,removed:s}},D=o=>{for(const r of R(o,{includeDirs:!1,includeSymlinks:!1,skip:[S,q]}))if(r.name==="package.json")return!0;return!1},m=(o,r,n)=>{let s=0,i=!1;for(const{packageDir:t}of b(o)){const e=u(o,t);if(!D(e)){if(r){n.info(` ${e}`),s++;continue}try{v(e,{force:!0,recursive:!0}),c.success(`Removed empty package ${e}`),s++}catch(f){c.error(`${e}: ${w(f)}`),i=!0}}}return{hadError:i,removed:s}},J=async({logger:o,options:r,workspaceRoot:n})=>{const s=n??process.cwd(),i=r.lockfile||!1,t=r.emptyPackages||!1;if(r.dryRun){const l=C(s);if(l.length>0){c.info("Would remove:");for(const a of l)o.info(` ${a}`)}else c.info("No node_modules directories found.");i&&x(s,!0,o),t&&(c.info("Would remove empty packages:"),m(s,!0,o));return}const e=j(s,i);for(const l of e.removed)c.success(`Removed ${l}`);for(const l of e.lockfilesRemoved)c.success(`Removed ${l}`);for(const l of e.errors)c.error(l);e.removed.length===0&&e.lockfilesRemoved.length===0?c.info("No node_modules directories found."):c.info(`Cleaned ${e.removed.length} node_modules director${e.removed.length===1?"y":"ies"}`);let f=!1;if(t){const{hadError:l,removed:a}=m(s,!1,o);f=l,a>0&&c.info(`Cleaned ${a} empty package director${a===1?"y":"ies"}`)}(e.errors.length>0||f)&&(process.exitCode=1)};export{J as default};
@@ -1 +1 @@
1
- import{h as t,M as l}from"../packem_shared/pm-runner-C6eTANt1.js";import{r as p,a as m}from"../packem_shared/command-runtime-BLFPUYAT.js";const g=async({logger:n,options:a,visConfig:o,workspaceRoot:c})=>{const s=c??process.cwd(),i=p({logger:n,options:a,visConfig:o},s),r=t(s,{backend:m(i),configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),e=l(r,a.check||!1,s,n);e!==0&&(process.exitCode=e)};export{g as default};
1
+ import{h as t,M as l}from"../packem_shared/pm-runner-DRybtzOV.js";import{r as p,a as m}from"../packem_shared/command-runtime-DQ7ZpLYL.js";const g=async({logger:n,options:a,visConfig:o,workspaceRoot:c})=>{const s=c??process.cwd(),i=p({logger:n,options:a,visConfig:o},s),r=t(s,{backend:m(i),configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),e=l(r,a.check||!1,s,n);e!==0&&(process.exitCode=e)};export{g as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as G}from"node:module";import{P as y,b as O}from"../packem_shared/index-uBVnF4ji.js";import{d as U,k as H,P,R as F,p as K}from"./heal.js";import{A as S,j}from"../packem_shared/pm-runner-C6eTANt1.js";import{p as a}from"./cli-main.js";let L;const N=e=>(L??=G(import.meta.url))(e),_=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=e=>{if(typeof _<"u"&&_.versions&&_.versions.node){const[t,o]=_.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return _.getBuiltinModule(e)}return N(e)},{readFile:$}=x("node:fs/promises"),{createInterface:D}=x("node:readline"),V=()=>!!process.stdout.isTTY&&process.env.CI!=="true",q=e=>new Promise(t=>{const o=D({input:process.stdin,output:process.stderr});o.question(`${e} (Y/n) `,i=>{o.close();const s=i.trim().toLowerCase();t(s===""||s==="y"||s==="yes")})}),M=(e,t)=>{const o=S(t),i=j(o,{exact:!1,filter:[],global:!1,optional:!1,packages:[e],peer:!1,saveDev:!1,workspace:!1,workspaceRoot:!1},t,console);return Promise.resolve({exitCode:i})},R=e=>`pnpm add ${e}`,Y=e=>e==="@gitbeaker/rest"?import("@gitbeaker/rest"):import("@octokit/rest"),B=async(e,t={})=>{const o=t.interactive??V(),i=t.prompt??q,s=t.runInstall??M,l=t.importImpl??Y,d=t.workspaceRoot??process.cwd();try{return await l(e)}catch(n){const{code:p}=n;if(p!=="ERR_MODULE_NOT_FOUND"&&p!=="MODULE_NOT_FOUND")throw n}if(!o)throw new Error(`${e} is not installed. \`vis ai heal accept\` needs it to talk to the host. Install it in your repo first:
1
+ import{createRequire as G}from"node:module";import{P as y,b as O}from"../packem_shared/index-BLtnel38.js";import{d as U,k as H,P,R as F,p as K}from"./heal.js";import{A as S,j}from"../packem_shared/pm-runner-DRybtzOV.js";import{p as a}from"./cli-main.js";let L;const N=e=>(L??=G(import.meta.url))(e),_=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=e=>{if(typeof _<"u"&&_.versions&&_.versions.node){const[t,o]=_.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return _.getBuiltinModule(e)}return N(e)},{readFile:$}=x("node:fs/promises"),{createInterface:D}=x("node:readline"),V=()=>!!process.stdout.isTTY&&process.env.CI!=="true",q=e=>new Promise(t=>{const o=D({input:process.stdin,output:process.stderr});o.question(`${e} (Y/n) `,i=>{o.close();const s=i.trim().toLowerCase();t(s===""||s==="y"||s==="yes")})}),M=(e,t)=>{const o=S(t),i=j(o,{exact:!1,filter:[],global:!1,optional:!1,packages:[e],peer:!1,saveDev:!1,workspace:!1,workspaceRoot:!1},t,console);return Promise.resolve({exitCode:i})},R=e=>`pnpm add ${e}`,Y=e=>e==="@gitbeaker/rest"?import("@gitbeaker/rest"):import("@octokit/rest"),B=async(e,t={})=>{const o=t.interactive??V(),i=t.prompt??q,s=t.runInstall??M,l=t.importImpl??Y,d=t.workspaceRoot??process.cwd();try{return await l(e)}catch(n){const{code:p}=n;if(p!=="ERR_MODULE_NOT_FOUND"&&p!=="MODULE_NOT_FOUND")throw n}if(!o)throw new Error(`${e} is not installed. \`vis ai heal accept\` needs it to talk to the host. Install it in your repo first:
2
2
  ${R(e)}`);if(!await i(`${e} isn't installed. Install it now?`))throw new Error(`${e} install declined. Re-run \`vis ai heal accept\` after installing manually:
3
3
  ${R(e)}`);const r=await s(e,d);if(r.exitCode!==0)throw new Error(`Install of ${e} failed (exit ${String(r.exitCode)}). Install manually and retry:
4
4
  ${R(e)}`);return await l(e)},J=e=>{const t=e.indexOf("/");if(t<=0||t===e.length-1)throw new Error(`Expected GITHUB_REPOSITORY in "owner/repo" form, got: ${e}`);return{owner:e.slice(0,t),repo:e.slice(t+1)}},W=async(e,t)=>{if(t.githubClient)return t.githubClient;const o=(await(t.loadSdk??B)("@octokit/rest")).Octokit;if(!o)throw new TypeError("Loaded `@octokit/rest` but no `Octokit` export was found. Reinstall the package or pin to a supported major.");return new o({auth:e})},z=async(e,t,o)=>{if(o.gitlabClient)return o.gitlabClient;const i=(await(o.loadSdk??B)("@gitbeaker/rest")).Gitlab;if(!i)throw new TypeError("Loaded `@gitbeaker/rest` but no `Gitlab` export was found. Reinstall the package or pin to a supported major.");return new i({host:t,token:e})},X=e=>e.replace(/\/api\/v\d+\/?$/,""),Q=async e=>{const{branch:t,ciContext:o,files:i,message:s,workspaceRoot:l}=e,d=e.readFile??(w=>$(w,"utf8"));if(!o.repo)throw new Error("Cannot commit on GitHub: GITHUB_REPOSITORY (owner/repo) is not set.");if(!o.token)throw new Error("Cannot commit on GitHub: GITHUB_TOKEN is not set. Grant the workflow `contents: write` and pass the token through.");const{owner:r,repo:n}=J(o.repo),p=await W(o.token,e),u=(await p.rest.git.getRef({owner:r,ref:`heads/${t}`,repo:n})).data.object.sha,h=(await p.rest.git.getCommit({commit_sha:u,owner:r,repo:n})).data.tree.sha,m=await Promise.all(i.map(async w=>{const C=y(l,w),k=await d(C),b=await p.rest.git.createBlob({content:Buffer.from(k,"utf8").toString("base64"),encoding:"base64",owner:r,repo:n});return{mode:"100644",path:w,sha:b.data.sha,type:"blob"}})),f=await p.rest.git.createTree({base_tree:h,owner:r,repo:n,tree:m}),g=await p.rest.git.createCommit({message:s,owner:r,parents:[u],repo:n,tree:f.data.sha});return await p.rest.git.updateRef({owner:r,ref:`heads/${t}`,repo:n,sha:g.data.sha}),{sha:g.data.sha,url:g.data.html_url}},Z=async e=>{const{branch:t,ciContext:o,files:i,message:s,workspaceRoot:l}=e,d=e.readFile??(m=>$(m,"utf8"));if(!o.repo)throw new Error("Cannot commit on GitLab: CI_PROJECT_ID / CI_PROJECT_PATH is not set.");if(!o.token)throw new Error("Cannot commit on GitLab: no token. CI_JOB_TOKEN cannot push commits — set GITLAB_TOKEN to a PAT/project-token with `api` scope.");if(!o.apiBaseUrl)throw new Error("Cannot commit on GitLab: CI_API_V4_URL is not set.");const r=X(o.apiBaseUrl),n=await z(o.token,r,e),p=await Promise.all(i.map(async m=>{const f=y(l,m);return{action:"update",content:await d(f),filePath:m}})),u=await n.Commits.create(o.repo,t,s,p),h=u.id??u.sha;if(!h)throw new Error("GitLab Commits.create returned no commit ID — cannot reference the new commit.");return{sha:h,url:u.web_url??u.webUrl}},ee=async e=>{if(e.files.length===0)throw new Error("Cannot commit: no files to include.");if(e.ciContext.provider==="github-actions")return await Q(e);if(e.ciContext.provider==="gitlab-ci")return await Z(e);throw new Error(`Cannot commit: unsupported CI provider \`${e.ciContext.provider}\`. Run \`vis ai heal accept\` from a recognised CI environment.`)},v="/vis heal accept",te=async e=>{if(!e)return;let t;try{t=await $(e,"utf8")}catch{return}const o=JSON.parse(t),i=o.comment?.body??"",s=o.comment?.user?.login??"",l=o.pull_request?.head?.repo?.full_name,d=o.pull_request?.base?.repo?.full_name??o.repository?.full_name,r=l!==void 0&&d!==void 0&&l!==d;return{actor:s,body:i,headRef:o.pull_request?.head?.ref,isFork:r}},oe=e=>{const t=e.VIS_HEAL_TRIGGER_BODY,o=e.VIS_HEAL_TRIGGER_ACTOR;if(!(!t||!o))return{actor:o,body:t,headRef:e.VIS_HEAL_HEAD_REF,isFork:!1}},re=e=>{const t=e.BUILDKITE_UNBLOCKER_EMAIL??e.BUILDKITE_UNBLOCKER;if(t)return{actor:t,body:v,headRef:e.BUILDKITE_BRANCH,isFork:!1}},ie=async(e,t)=>{if(e.provider==="github-actions")return await te(t.GITHUB_EVENT_PATH);if(e.provider==="gitlab-ci")return oe(t);if(e.provider==="buildkite")return re(t)},ae=(e,t)=>{const o=t.BUILDKITE_REPO;if(!o)return;const i=/(?:^|@|\/\/)github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/i.exec(o);if(i&&t.GITHUB_TOKEN)return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:e.prNumber,provider:"github-actions",repo:`${i[1]}/${i[2]}`,sha:e.sha,token:t.GITHUB_TOKEN};const s=/\/\/([^/]*gitlab[^/]*)\/([^/]+)\/(.+?)(?:\.git)?\/?$/i.exec(o),l=s?null:/@([^/:]*gitlab[^/:]*):([^/]+)\/(.+?)(?:\.git)?\/?$/i.exec(o),d=s??l;if(d&&t.GITLAB_TOKEN){const r=d[1];return{apiBaseUrl:t.CI_API_V4_URL??`https://${r}/api/v4`,buildId:void 0,buildNumber:void 0,prNumber:e.prNumber,provider:"gitlab-ci",repo:`${d[2]}/${d[3]}`,sha:e.sha,token:t.GITLAB_TOKEN}}},ne=async e=>{const t=e.fetchImpl??globalThis.fetch,o=`${(e.apiBaseUrl??"https://api.github.com").replace(/\/+$/,"")}/repos/${e.repo}/pulls/${String(e.prNumber)}`;try{const i=await t(o,{headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${e.token}`,"X-GitHub-Api-Version":"2022-11-28"}});return i.ok?(await i.json()).head?.ref:void 0}catch{return}},se=(e,t,o,i)=>{const s=t.map(l=>`- \`${l}\``).join(`
@@ -1,4 +1,4 @@
1
- import{createRequire as S}from"node:module";import{s as U,j as P,E as I,V as L,I as A}from"../packem_shared/index.server-CusjRLCh.js";import{b as O}from"../packem_shared/index-uBVnF4ji.js";import{readLastRunSummary as j}from"@visulima/task-runner";import{a as G,r as K,b as D,c as F}from"../packem_shared/ai-fix-DV5-dHBY.js";import{p as u,r as M}from"./cli-main.js";let R;const B=e=>(R??=S(import.meta.url))(e),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,o]=m.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return m.getBuiltinModule(e)}return B(e)},{spawn:h}=g("node:child_process"),{readFile:H}=g("node:fs/promises"),V=e=>{if(!e)return;const t=/^refs\/pull\/(\d+)\//.exec(e);return t?Number.parseInt(t[1],10):void 0},J=async e=>{if(!e)return{prNumber:void 0,sha:void 0};try{const t=await H(e,"utf8"),o=JSON.parse(t),r=o.pull_request?.number??o.issue?.number??o.number,i=o.pull_request?.head?.sha;return{prNumber:r,sha:i}}catch{return{prNumber:void 0,sha:void 0}}},q=async e=>{const t=V(e.GITHUB_REF),{prNumber:o,sha:r}=t===void 0?await J(e.GITHUB_EVENT_PATH):{prNumber:t,sha:void 0};return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:t??o,provider:"github-actions",repo:e.GITHUB_REPOSITORY,sha:r??e.GITHUB_SHA,token:e.GITHUB_TOKEN}},z=e=>{const t=e.CI_MERGE_REQUEST_IID,o=t!==void 0&&t!==""?Number.parseInt(t,10):void 0,r=e.CI_API_V4_URL,i=e.GITLAB_TOKEN??e.CI_TOKEN;return{apiBaseUrl:r,buildId:void 0,buildNumber:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"gitlab-ci",repo:e.CI_PROJECT_ID??e.CI_PROJECT_PATH,sha:e.CI_COMMIT_SHA,token:i}},Q=e=>{const t=e.BUILDKITE_PULL_REQUEST,o=t!==void 0&&t!==""&&t!=="false"?Number.parseInt(t,10):void 0,r=e.BUILDKITE_BUILD_NUMBER,i=r!==void 0&&r!==""?Number.parseInt(r,10):void 0,n=e.BUILDKITE_ORGANIZATION_SLUG,a=e.BUILDKITE_PIPELINE_SLUG,s=n!==void 0&&n!==""&&a!==void 0&&a!==""?`${n}/${a}`:void 0;return{apiBaseUrl:(e.BUILDKITE_API_BASE_URL??"https://api.buildkite.com").replace(/\/+$/,""),buildId:e.BUILDKITE_BUILD_ID,buildNumber:Number.isFinite(i)?i:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"buildkite",repo:s,sha:e.BUILDKITE_COMMIT,token:e.BUILDKITE_API_TOKEN}},Y=async(e=process.env)=>e.GITHUB_ACTIONS==="true"?await q(e):e.GITLAB_CI==="true"?z(e):e.BUILDKITE==="true"?Q(e):{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:void 0,provider:"unknown",repo:void 0,sha:void 0,token:void 0},Z=(e,t,o,r)=>new Promise(i=>{const n=["pr","comment",String(t),"--body-file","-"];r&&n.push("--repo",r);const a=h(e,n,{stdio:["pipe","ignore","pipe"]});let s="";a.stderr?.setEncoding("utf8"),a.stderr?.on("data",d=>{s+=d}),a.once("error",()=>{i({exitCode:127,stderr:s})}),a.once("close",d=>{i({exitCode:d??-1,stderr:s})}),a.stdin?.on("error",()=>{}),a.stdin?.end(o)}),W=async(e,t,o,r,i)=>{const n=`https://api.github.com/repos/${t}/issues/${String(o)}/comments`;try{const a=await e(n,{body:JSON.stringify({body:r}),headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"},method:"POST"});if(!a.ok){const s=await a.text().catch(()=>"");return{error:`GitHub REST returned ${String(a.status)}: ${s.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(a){return{error:a instanceof Error?a.message:String(a),ok:!1}}},X=async(e,t,o,r,i,n)=>{const a=encodeURIComponent(o),s=`${t.replace(/\/+$/,"")}/projects/${a}/merge_requests/${String(r)}/notes`;try{const d=await e(s,{body:JSON.stringify({body:i}),headers:{"Content-Type":"application/json","PRIVATE-TOKEN":n},method:"POST"});if(!d.ok){const c=await d.text().catch(()=>"");return{error:`GitLab REST returned ${String(d.status)}: ${c.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(d){return{error:d instanceof Error?d.message:String(d),ok:!1}}},tt=(e,t,o,r)=>new Promise(i=>{const n=h(e,["annotate","--style",o,"--context",r],{stdio:["pipe","ignore","pipe"]});let a="";n.stderr?.setEncoding("utf8"),n.stderr?.on("data",s=>{a+=s}),n.once("error",()=>{i({exitCode:127,stderr:a})}),n.once("close",s=>{i({exitCode:s??-1,stderr:a})}),n.stdin?.on("error",()=>{}),n.stdin?.end(t)}),et=async(e,t,o,r,i,n,a,s)=>{const[d,c]=o.split("/",2);if(!d||!c)return{error:`Buildkite repo identifier \`${o}\` is not in {org}/{pipeline} form.`,ok:!1};const f=`${t}/v2/organizations/${encodeURIComponent(d)}/pipelines/${encodeURIComponent(c)}/builds/${String(r)}/annotations`;try{const p=await e(f,{body:JSON.stringify({body:i,context:a,style:n}),headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},method:"POST"});if(!p.ok){const l=await p.text().catch(()=>"");return{error:`Buildkite REST returned ${String(p.status)}: ${l.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(p){return{error:p instanceof Error?p.message:String(p),ok:!1}}},ot=async(e,t,o,r)=>{const i=t.buildId?`vis-ai-heal-${t.buildId}`:"vis-ai-heal",n="info",a=await tt(o,e,n,i);if(a.exitCode===0)return{method:"buildkite-cli",posted:!0};if(!t.apiBaseUrl||!t.repo||t.buildNumber===void 0||!t.token){const d=[];return t.repo||d.push("BUILDKITE_ORGANIZATION_SLUG / BUILDKITE_PIPELINE_SLUG"),t.buildNumber===void 0&&d.push("BUILDKITE_BUILD_NUMBER"),t.token||d.push("BUILDKITE_API_TOKEN (with `write_build_annotations` scope)"),{error:`buildkite-agent annotate exited ${String(a.exitCode)} (${a.stderr.trim().slice(0,200)}); cannot fall back to REST without ${d.join(", ")}`,method:"buildkite-cli",posted:!1}}const s=await et(r,t.apiBaseUrl,t.repo,t.buildNumber,e,n,i,t.token);return s.ok?{method:"rest",posted:!0}:{error:`buildkite-agent annotate exited ${String(a.exitCode)}; REST fallback also failed: ${s.error??"unknown"}`,method:"rest",posted:!1}},rt=async(e,t,o,r)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};const i=await Z(o,t.prNumber,e,t.repo);if(i.exitCode===0)return{method:"gh-cli",posted:!0};if(!t.repo||!t.token)return{error:`gh exited ${String(i.exitCode)} (${i.stderr.trim().slice(0,200)}); cannot fall back to REST without GITHUB_REPOSITORY + GITHUB_TOKEN`,method:"gh-cli",posted:!1};const n=await W(r,t.repo,t.prNumber,e,t.token);return n.ok?{method:"rest",posted:!0}:{error:`gh exited ${String(i.exitCode)}; REST fallback also failed: ${n.error??"unknown"}`,method:"rest",posted:!1}},it=async(e,t,o)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};if(!t.apiBaseUrl||!t.repo)return{error:"GitLab CI context is missing CI_API_V4_URL or CI_PROJECT_ID; cannot post note.",method:"rest",posted:!1};if(!t.token)return{error:"GitLab CI context has no token. CI_JOB_TOKEN cannot post MR notes — set GITLAB_TOKEN to a personal/project access token with `api` scope.",method:"rest",posted:!1};const r=await X(o,t.apiBaseUrl,t.repo,t.prNumber,e,t.token);return r.ok?{method:"rest",posted:!0}:{error:r.error,method:"rest",posted:!1}},nt=async e=>{const{body:t,buildkiteAgentBin:o="buildkite-agent",context:r,fetchImpl:i=globalThis.fetch,ghBin:n="gh"}=e;return r.provider==="github-actions"?await rt(t,r,n,i):r.provider==="gitlab-ci"?await it(t,r,i):r.provider==="buildkite"?await ot(t,r,o,i):{method:"skipped",posted:!1}},b=e=>{let t=0,o=0;for(const r of e)r.status==="applied"?t+=1:o+=1;return{applied:t,failed:o}},k=(e,t,o)=>{const r=F(e,t,o),i=O(e,r);return i===""||i.startsWith("..")?r:i},at=(e,t,o,r)=>new Promise(i=>{const n=process.argv[1];if(!n){i({exitCode:-1,stderr:"Cannot locate vis bin (process.argv[1] missing).",stdout:""});return}const a=[n,"run",o,"--projects",t,"--no-cache","--summarize","--fail-fast"],s=h(process.execPath,a,{cwd:e,env:{...process.env,NO_COLOR:"1"},stdio:["ignore","pipe","pipe"]});let d="",c="";const f=setTimeout(()=>{s.kill("SIGTERM"),setTimeout(()=>s.kill("SIGKILL"),2e3).unref()},r);s.stdout?.setEncoding("utf8"),s.stdout?.on("data",p=>{d+=p}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",p=>{c+=p}),s.once("error",p=>{clearTimeout(f),i({exitCode:-1,stderr:p.message,stdout:d})}),s.once("close",p=>{clearTimeout(f),i({exitCode:p??-1,stderr:c,stdout:d})})}),st=6e4,T=e=>{let t=0;const o=e.match(/`{3,}/g);if(o)for(const r of o)t=Math.max(t,r.length);return"`".repeat(Math.max(3,t+1))},_=(e,t,o)=>{if(e.patches.length===0)return"_No patches proposed._";const r=[];for(const[i,n]of e.patches.entries()){const a=k(t,o,n.file),s=[`**[${String(i+1)}] \`${a}\`**`];n.reason&&s.push(`_${n.reason}_`);const d=T(`${n.oldString}
1
+ import{createRequire as S}from"node:module";import{s as U,j as P,E as I,V as L,I as A}from"../packem_shared/index.server-CusjRLCh.js";import{b as O}from"../packem_shared/index-BLtnel38.js";import{readLastRunSummary as j}from"@visulima/task-runner";import{a as G,r as K,b as D,c as F}from"../packem_shared/ai-fix-bfWo0cZX.js";import{p as u,r as M}from"./cli-main.js";let R;const B=e=>(R??=S(import.meta.url))(e),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,o]=m.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return m.getBuiltinModule(e)}return B(e)},{spawn:h}=g("node:child_process"),{readFile:H}=g("node:fs/promises"),V=e=>{if(!e)return;const t=/^refs\/pull\/(\d+)\//.exec(e);return t?Number.parseInt(t[1],10):void 0},J=async e=>{if(!e)return{prNumber:void 0,sha:void 0};try{const t=await H(e,"utf8"),o=JSON.parse(t),r=o.pull_request?.number??o.issue?.number??o.number,i=o.pull_request?.head?.sha;return{prNumber:r,sha:i}}catch{return{prNumber:void 0,sha:void 0}}},q=async e=>{const t=V(e.GITHUB_REF),{prNumber:o,sha:r}=t===void 0?await J(e.GITHUB_EVENT_PATH):{prNumber:t,sha:void 0};return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:t??o,provider:"github-actions",repo:e.GITHUB_REPOSITORY,sha:r??e.GITHUB_SHA,token:e.GITHUB_TOKEN}},z=e=>{const t=e.CI_MERGE_REQUEST_IID,o=t!==void 0&&t!==""?Number.parseInt(t,10):void 0,r=e.CI_API_V4_URL,i=e.GITLAB_TOKEN??e.CI_TOKEN;return{apiBaseUrl:r,buildId:void 0,buildNumber:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"gitlab-ci",repo:e.CI_PROJECT_ID??e.CI_PROJECT_PATH,sha:e.CI_COMMIT_SHA,token:i}},Q=e=>{const t=e.BUILDKITE_PULL_REQUEST,o=t!==void 0&&t!==""&&t!=="false"?Number.parseInt(t,10):void 0,r=e.BUILDKITE_BUILD_NUMBER,i=r!==void 0&&r!==""?Number.parseInt(r,10):void 0,n=e.BUILDKITE_ORGANIZATION_SLUG,a=e.BUILDKITE_PIPELINE_SLUG,s=n!==void 0&&n!==""&&a!==void 0&&a!==""?`${n}/${a}`:void 0;return{apiBaseUrl:(e.BUILDKITE_API_BASE_URL??"https://api.buildkite.com").replace(/\/+$/,""),buildId:e.BUILDKITE_BUILD_ID,buildNumber:Number.isFinite(i)?i:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"buildkite",repo:s,sha:e.BUILDKITE_COMMIT,token:e.BUILDKITE_API_TOKEN}},Y=async(e=process.env)=>e.GITHUB_ACTIONS==="true"?await q(e):e.GITLAB_CI==="true"?z(e):e.BUILDKITE==="true"?Q(e):{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:void 0,provider:"unknown",repo:void 0,sha:void 0,token:void 0},Z=(e,t,o,r)=>new Promise(i=>{const n=["pr","comment",String(t),"--body-file","-"];r&&n.push("--repo",r);const a=h(e,n,{stdio:["pipe","ignore","pipe"]});let s="";a.stderr?.setEncoding("utf8"),a.stderr?.on("data",d=>{s+=d}),a.once("error",()=>{i({exitCode:127,stderr:s})}),a.once("close",d=>{i({exitCode:d??-1,stderr:s})}),a.stdin?.on("error",()=>{}),a.stdin?.end(o)}),W=async(e,t,o,r,i)=>{const n=`https://api.github.com/repos/${t}/issues/${String(o)}/comments`;try{const a=await e(n,{body:JSON.stringify({body:r}),headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"},method:"POST"});if(!a.ok){const s=await a.text().catch(()=>"");return{error:`GitHub REST returned ${String(a.status)}: ${s.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(a){return{error:a instanceof Error?a.message:String(a),ok:!1}}},X=async(e,t,o,r,i,n)=>{const a=encodeURIComponent(o),s=`${t.replace(/\/+$/,"")}/projects/${a}/merge_requests/${String(r)}/notes`;try{const d=await e(s,{body:JSON.stringify({body:i}),headers:{"Content-Type":"application/json","PRIVATE-TOKEN":n},method:"POST"});if(!d.ok){const c=await d.text().catch(()=>"");return{error:`GitLab REST returned ${String(d.status)}: ${c.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(d){return{error:d instanceof Error?d.message:String(d),ok:!1}}},tt=(e,t,o,r)=>new Promise(i=>{const n=h(e,["annotate","--style",o,"--context",r],{stdio:["pipe","ignore","pipe"]});let a="";n.stderr?.setEncoding("utf8"),n.stderr?.on("data",s=>{a+=s}),n.once("error",()=>{i({exitCode:127,stderr:a})}),n.once("close",s=>{i({exitCode:s??-1,stderr:a})}),n.stdin?.on("error",()=>{}),n.stdin?.end(t)}),et=async(e,t,o,r,i,n,a,s)=>{const[d,c]=o.split("/",2);if(!d||!c)return{error:`Buildkite repo identifier \`${o}\` is not in {org}/{pipeline} form.`,ok:!1};const f=`${t}/v2/organizations/${encodeURIComponent(d)}/pipelines/${encodeURIComponent(c)}/builds/${String(r)}/annotations`;try{const p=await e(f,{body:JSON.stringify({body:i,context:a,style:n}),headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},method:"POST"});if(!p.ok){const l=await p.text().catch(()=>"");return{error:`Buildkite REST returned ${String(p.status)}: ${l.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(p){return{error:p instanceof Error?p.message:String(p),ok:!1}}},ot=async(e,t,o,r)=>{const i=t.buildId?`vis-ai-heal-${t.buildId}`:"vis-ai-heal",n="info",a=await tt(o,e,n,i);if(a.exitCode===0)return{method:"buildkite-cli",posted:!0};if(!t.apiBaseUrl||!t.repo||t.buildNumber===void 0||!t.token){const d=[];return t.repo||d.push("BUILDKITE_ORGANIZATION_SLUG / BUILDKITE_PIPELINE_SLUG"),t.buildNumber===void 0&&d.push("BUILDKITE_BUILD_NUMBER"),t.token||d.push("BUILDKITE_API_TOKEN (with `write_build_annotations` scope)"),{error:`buildkite-agent annotate exited ${String(a.exitCode)} (${a.stderr.trim().slice(0,200)}); cannot fall back to REST without ${d.join(", ")}`,method:"buildkite-cli",posted:!1}}const s=await et(r,t.apiBaseUrl,t.repo,t.buildNumber,e,n,i,t.token);return s.ok?{method:"rest",posted:!0}:{error:`buildkite-agent annotate exited ${String(a.exitCode)}; REST fallback also failed: ${s.error??"unknown"}`,method:"rest",posted:!1}},rt=async(e,t,o,r)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};const i=await Z(o,t.prNumber,e,t.repo);if(i.exitCode===0)return{method:"gh-cli",posted:!0};if(!t.repo||!t.token)return{error:`gh exited ${String(i.exitCode)} (${i.stderr.trim().slice(0,200)}); cannot fall back to REST without GITHUB_REPOSITORY + GITHUB_TOKEN`,method:"gh-cli",posted:!1};const n=await W(r,t.repo,t.prNumber,e,t.token);return n.ok?{method:"rest",posted:!0}:{error:`gh exited ${String(i.exitCode)}; REST fallback also failed: ${n.error??"unknown"}`,method:"rest",posted:!1}},it=async(e,t,o)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};if(!t.apiBaseUrl||!t.repo)return{error:"GitLab CI context is missing CI_API_V4_URL or CI_PROJECT_ID; cannot post note.",method:"rest",posted:!1};if(!t.token)return{error:"GitLab CI context has no token. CI_JOB_TOKEN cannot post MR notes — set GITLAB_TOKEN to a personal/project access token with `api` scope.",method:"rest",posted:!1};const r=await X(o,t.apiBaseUrl,t.repo,t.prNumber,e,t.token);return r.ok?{method:"rest",posted:!0}:{error:r.error,method:"rest",posted:!1}},nt=async e=>{const{body:t,buildkiteAgentBin:o="buildkite-agent",context:r,fetchImpl:i=globalThis.fetch,ghBin:n="gh"}=e;return r.provider==="github-actions"?await rt(t,r,n,i):r.provider==="gitlab-ci"?await it(t,r,i):r.provider==="buildkite"?await ot(t,r,o,i):{method:"skipped",posted:!1}},b=e=>{let t=0,o=0;for(const r of e)r.status==="applied"?t+=1:o+=1;return{applied:t,failed:o}},k=(e,t,o)=>{const r=F(e,t,o),i=O(e,r);return i===""||i.startsWith("..")?r:i},at=(e,t,o,r)=>new Promise(i=>{const n=process.argv[1];if(!n){i({exitCode:-1,stderr:"Cannot locate vis bin (process.argv[1] missing).",stdout:""});return}const a=[n,"run",o,"--projects",t,"--no-cache","--summarize","--fail-fast"],s=h(process.execPath,a,{cwd:e,env:{...process.env,NO_COLOR:"1"},stdio:["ignore","pipe","pipe"]});let d="",c="";const f=setTimeout(()=>{s.kill("SIGTERM"),setTimeout(()=>s.kill("SIGKILL"),2e3).unref()},r);s.stdout?.setEncoding("utf8"),s.stdout?.on("data",p=>{d+=p}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",p=>{c+=p}),s.once("error",p=>{clearTimeout(f),i({exitCode:-1,stderr:p.message,stdout:d})}),s.once("close",p=>{clearTimeout(f),i({exitCode:p??-1,stderr:c,stdout:d})})}),st=6e4,T=e=>{let t=0;const o=e.match(/`{3,}/g);if(o)for(const r of o)t=Math.max(t,r.length);return"`".repeat(Math.max(3,t+1))},_=(e,t,o)=>{if(e.patches.length===0)return"_No patches proposed._";const r=[];for(const[i,n]of e.patches.entries()){const a=k(t,o,n.file),s=[`**[${String(i+1)}] \`${a}\`**`];n.reason&&s.push(`_${n.reason}_`);const d=T(`${n.oldString}
2
2
  ${n.newString}`);s.push(`${d}diff`);for(const c of n.oldString.split(`
3
3
  `))s.push(`- ${c}`);for(const c of n.newString.split(`
4
4
  `))s.push(`+ ${c}`);s.push(d),r.push(s.join(`