sandforge 1.82.0 → 1.83.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 (200) hide show
  1. package/lib/{chunk-JLZRZL5E.mjs → chunk-262TP6UU.mjs} +1 -1
  2. package/lib/{chunk-Z42PHCVZ.mjs → chunk-27BBEGUD.mjs} +1 -1
  3. package/lib/{chunk-YGJF55VJ.mjs → chunk-2ADSD5WK.mjs} +1 -1
  4. package/lib/{chunk-KIMQQ6JQ.mjs → chunk-2GSMHGIV.mjs} +1 -1
  5. package/lib/chunk-2K5BYZQM.mjs +8 -0
  6. package/lib/{chunk-DJCGURW7.mjs → chunk-2KTGDYUH.mjs} +1 -1
  7. package/lib/{chunk-YAJQS3OL.mjs → chunk-2N73W63D.mjs} +1 -1
  8. package/lib/{chunk-LXDSRP2W.mjs → chunk-2R6GFNKF.mjs} +1 -1
  9. package/lib/{chunk-VZVICK7Q.mjs → chunk-2WMKJVD2.mjs} +1 -1
  10. package/lib/{chunk-CV47FDQW.mjs → chunk-36Y225OM.mjs} +1 -1
  11. package/lib/{chunk-3C2ZZIFN.mjs → chunk-3CM7LAPE.mjs} +1 -1
  12. package/lib/{chunk-HIHCYMSL.mjs → chunk-3OVTKRS4.mjs} +1 -1
  13. package/lib/{chunk-XFU3HRUV.mjs → chunk-3V4YH5KO.mjs} +1 -1
  14. package/lib/{chunk-XO5FBOQF.mjs → chunk-446GBKAC.mjs} +1 -1
  15. package/lib/{chunk-ZUOPC4W2.mjs → chunk-4GCYGQXD.mjs} +1 -1
  16. package/lib/{chunk-GCGHHN4K.mjs → chunk-4V3QO7HF.mjs} +1 -1
  17. package/lib/{chunk-VZT4E2OJ.mjs → chunk-4X5D3MSV.mjs} +1 -1
  18. package/lib/{chunk-P55MKIZX.mjs → chunk-5OGNK3JP.mjs} +1 -1
  19. package/lib/{chunk-3MGMNK3Q.mjs → chunk-6KOUYHEY.mjs} +1 -1
  20. package/lib/chunk-6QSHWIZI.mjs +48 -0
  21. package/lib/chunk-6VOQFISN.mjs +7 -0
  22. package/lib/{chunk-VYOYXTCU.mjs → chunk-6YC2ELCU.mjs} +1 -1
  23. package/lib/chunk-77IVKH7R.mjs +7 -0
  24. package/lib/{chunk-JKT5YAQ2.mjs → chunk-77MZRBWX.mjs} +1 -1
  25. package/lib/{chunk-PR74GYVI.mjs → chunk-7BQMBXKX.mjs} +1 -1
  26. package/lib/{chunk-SZGGFST2.mjs → chunk-7DPHZWA4.mjs} +1 -1
  27. package/lib/chunk-7V2UYZ6S.mjs +7 -0
  28. package/lib/{chunk-HKUWHVI7.mjs → chunk-7WSQ65WG.mjs} +1 -1
  29. package/lib/{chunk-LHU6CPGE.mjs → chunk-7ZBDACVG.mjs} +1 -1
  30. package/lib/{chunk-WT3SCUHS.mjs → chunk-AG24QMSY.mjs} +1 -1
  31. package/lib/{chunk-A65ADTCR.mjs → chunk-AHUGG3WU.mjs} +1 -1
  32. package/lib/{chunk-ZXFL2MSN.mjs → chunk-ALBY5SOH.mjs} +1 -1
  33. package/lib/chunk-AXFD2OH6.mjs +7 -0
  34. package/lib/{chunk-JESRFE2Z.mjs → chunk-BH76USTQ.mjs} +1 -1
  35. package/lib/{chunk-DBBPDSFN.mjs → chunk-BPHTA6KP.mjs} +1 -1
  36. package/lib/{chunk-3SKLBRPL.mjs → chunk-BT43WSOS.mjs} +1 -1
  37. package/lib/{chunk-32EUNQT6.mjs → chunk-BVZ5H3N4.mjs} +1 -1
  38. package/lib/{chunk-PWVDNN2C.mjs → chunk-C6RKM4BB.mjs} +1 -1
  39. package/lib/{chunk-27Z76O2O.mjs → chunk-CDWZGQAJ.mjs} +1 -1
  40. package/lib/chunk-CGZGL6VT.mjs +7 -0
  41. package/lib/{chunk-P63WJMXQ.mjs → chunk-CN5HGFG4.mjs} +1 -1
  42. package/lib/{chunk-Y4TDVDP2.mjs → chunk-CQAFVEKP.mjs} +1 -1
  43. package/lib/{chunk-G2JR3F63.mjs → chunk-CTPLYUXA.mjs} +1 -1
  44. package/lib/chunk-CXKZ6TYV.mjs +9 -0
  45. package/lib/{chunk-FKK5YBGZ.mjs → chunk-D6JT4PAB.mjs} +1 -1
  46. package/lib/{chunk-3CX7GPCR.mjs → chunk-D7XUNWWU.mjs} +1 -1
  47. package/lib/{chunk-PPHVWUFY.mjs → chunk-DB5RVDC5.mjs} +1 -1
  48. package/lib/{chunk-LAUOSXMN.mjs → chunk-DIGUC7S4.mjs} +1 -1
  49. package/lib/{chunk-6GQUZ4IP.mjs → chunk-DKDKCGXV.mjs} +1 -1
  50. package/lib/chunk-DMT5SCO3.mjs +7 -0
  51. package/lib/{chunk-KKOA62S4.mjs → chunk-DNQKVCUV.mjs} +4 -3
  52. package/lib/{chunk-3XG25GTF.mjs → chunk-DSR2MSBH.mjs} +1 -1
  53. package/lib/{chunk-ZHIZY3ZC.mjs → chunk-E3RQ575Y.mjs} +1 -1
  54. package/lib/{chunk-SAMWHL22.mjs → chunk-EOQON3E5.mjs} +1 -1
  55. package/lib/{chunk-2JZGCCPG.mjs → chunk-ETNQHIDI.mjs} +1 -1
  56. package/lib/chunk-F5SBGJWW.mjs +7 -0
  57. package/lib/chunk-FBXH4VRQ.mjs +7 -0
  58. package/lib/chunk-FKCIGJOI.mjs +15 -0
  59. package/lib/{chunk-NWOI25WY.mjs → chunk-FVLFO2S6.mjs} +1 -1
  60. package/lib/{chunk-MKTXJCXN.mjs → chunk-FYWNSMOZ.mjs} +1 -1
  61. package/lib/{chunk-52EXDVPN.mjs → chunk-GEEWPTV5.mjs} +1 -1
  62. package/lib/{chunk-XSKPYGMT.mjs → chunk-GLN4PI5P.mjs} +1 -1
  63. package/lib/{chunk-DWMRIWV5.mjs → chunk-GT5ZKU6V.mjs} +1 -1
  64. package/lib/chunk-GTRU5AV5.mjs +7 -0
  65. package/lib/chunk-H33DVU3D.mjs +7 -0
  66. package/lib/{chunk-YAIIRFKJ.mjs → chunk-HQZUQXDC.mjs} +1 -1
  67. package/lib/{chunk-MUEQRIK7.mjs → chunk-HVX2AFYW.mjs} +1 -1
  68. package/lib/chunk-I3ZO76LL.mjs +21 -0
  69. package/lib/{chunk-7WSLT5VX.mjs → chunk-I5C4O3VA.mjs} +1 -1
  70. package/lib/{chunk-6VSZNZHH.mjs → chunk-IHGYJZZ2.mjs} +1 -1
  71. package/lib/{chunk-DIS254AN.mjs → chunk-ISA2NYJV.mjs} +1 -1
  72. package/lib/{chunk-GGUOIDWP.mjs → chunk-ISAUCWYK.mjs} +1 -1
  73. package/lib/{chunk-ZUTUYBNW.mjs → chunk-ISOSTAJR.mjs} +1 -1
  74. package/lib/chunk-IXIY6Q4M.mjs +7 -0
  75. package/lib/{chunk-2UU42PTD.mjs → chunk-J3TIHLWG.mjs} +1 -1
  76. package/lib/{chunk-GGNUACTY.mjs → chunk-JAV6F6OA.mjs} +1 -1
  77. package/lib/chunk-JBWJ6UEZ.mjs +7 -0
  78. package/lib/{chunk-C2N2TNEU.mjs → chunk-JH4ZTVQN.mjs} +1 -1
  79. package/lib/{chunk-FOIWWK7G.mjs → chunk-JIPT5FUD.mjs} +1 -1
  80. package/lib/{chunk-7EYQYZJP.mjs → chunk-JREKJO3D.mjs} +1 -1
  81. package/lib/{chunk-VQJMP3DC.mjs → chunk-JUOQUG7U.mjs} +1 -1
  82. package/lib/chunk-JYUMD357.mjs +7 -0
  83. package/lib/{chunk-KP5G6FUC.mjs → chunk-K7G3W7XH.mjs} +1 -1
  84. package/lib/{chunk-T7WREYA5.mjs → chunk-KKS2KFBT.mjs} +1 -1
  85. package/lib/{chunk-TMA34QMA.mjs → chunk-KWAVSZ2B.mjs} +1 -1
  86. package/lib/{chunk-H4JUYUSL.mjs → chunk-KXUOHACP.mjs} +1 -1
  87. package/lib/{chunk-STRMWSIQ.mjs → chunk-L3I6DAHX.mjs} +1 -1
  88. package/lib/{chunk-TCBAE65A.mjs → chunk-L47JCNP3.mjs} +1 -1
  89. package/lib/{chunk-5K2I2DMP.mjs → chunk-L4MSL4U7.mjs} +1 -1
  90. package/lib/chunk-L4RJX7DG.mjs +7 -0
  91. package/lib/{chunk-47UHTN3Q.mjs → chunk-L6CLN664.mjs} +1 -1
  92. package/lib/chunk-LI2XNV7F.mjs +7 -0
  93. package/lib/chunk-LP2D3JJP.mjs +7 -0
  94. package/lib/{chunk-KJYEQHYP.mjs → chunk-LWES2KZE.mjs} +1 -1
  95. package/lib/{chunk-3HEMJTAP.mjs → chunk-LYOGCIYD.mjs} +2 -2
  96. package/lib/{chunk-VPDEJGPS.mjs → chunk-MJD6CPZZ.mjs} +1 -1
  97. package/lib/{chunk-SNEOKYV7.mjs → chunk-MTM4KG3T.mjs} +1 -1
  98. package/lib/{chunk-J24TIGSI.mjs → chunk-N2HYG3BL.mjs} +1 -1
  99. package/lib/chunk-N5UIE4IR.mjs +7 -0
  100. package/lib/{chunk-YMDFF657.mjs → chunk-NDFFIJL5.mjs} +1 -1
  101. package/lib/{chunk-WOOUISSO.mjs → chunk-NFEBX75O.mjs} +1 -1
  102. package/lib/{chunk-ZUBBEP75.mjs → chunk-NNV7IGM7.mjs} +1 -1
  103. package/lib/{chunk-Q3DY7TO2.mjs → chunk-NS6ONPWL.mjs} +1 -1
  104. package/lib/{chunk-IVZJSDJD.mjs → chunk-O7GCCRPW.mjs} +1 -1
  105. package/lib/{chunk-A7JJWOLT.mjs → chunk-OO24ZYYJ.mjs} +1 -1
  106. package/lib/chunk-OOIDCHBQ.mjs +9 -0
  107. package/lib/{chunk-AUS6NFLZ.mjs → chunk-OS5GE52G.mjs} +1 -1
  108. package/lib/chunk-OS6HFJ7L.mjs +7 -0
  109. package/lib/{chunk-V3R45ZWT.mjs → chunk-OTJH6AEA.mjs} +1 -1
  110. package/lib/{chunk-PBE44M2Y.mjs → chunk-OUU47Y7A.mjs} +1 -1
  111. package/lib/{chunk-BN33LVPQ.mjs → chunk-P6WRYJN3.mjs} +1 -1
  112. package/lib/{chunk-JJITOWZK.mjs → chunk-PDRXM5WN.mjs} +1 -1
  113. package/lib/{chunk-RYRMUPMY.mjs → chunk-PGRY365W.mjs} +1 -1
  114. package/lib/chunk-Q4PPI3KG.mjs +7 -0
  115. package/lib/chunk-QFTF2PGS.mjs +21 -0
  116. package/lib/chunk-QKJXIY6L.mjs +7 -0
  117. package/lib/{chunk-PYRZFUVU.mjs → chunk-QLRWU3MB.mjs} +1 -1
  118. package/lib/chunk-QO4MPHZD.mjs +7 -0
  119. package/lib/chunk-QP3JLFIO.mjs +7 -0
  120. package/lib/{chunk-NLB3RGIY.mjs → chunk-QQDZQCO2.mjs} +1 -1
  121. package/lib/{chunk-7CVDVBEE.mjs → chunk-QXB6U3ZP.mjs} +1 -1
  122. package/lib/chunk-R3OM3X4L.mjs +8 -0
  123. package/lib/chunk-R7GKMAT4.mjs +7 -0
  124. package/lib/{chunk-YT22LMF7.mjs → chunk-RVCPQVKM.mjs} +1 -1
  125. package/lib/{chunk-TWV4A5RK.mjs → chunk-RZKJQOOC.mjs} +1 -1
  126. package/lib/chunk-S4PRKKGC.mjs +8 -0
  127. package/lib/{chunk-JH27IKCO.mjs → chunk-SX6QWYCQ.mjs} +1 -1
  128. package/lib/{chunk-UHFLKP26.mjs → chunk-T36DZJPH.mjs} +1 -1
  129. package/lib/{chunk-CZLJZQCS.mjs → chunk-T7DDS4UQ.mjs} +1 -1
  130. package/lib/chunk-TCEXCHXR.mjs +7 -0
  131. package/lib/chunk-TMIESDE5.mjs +7 -0
  132. package/lib/chunk-TQJ5NPRC.mjs +7 -0
  133. package/lib/chunk-TUPZY2QJ.mjs +7 -0
  134. package/lib/{chunk-GBGHJTPC.mjs → chunk-U2CTKIPE.mjs} +1 -1
  135. package/lib/{chunk-3HROD5RE.mjs → chunk-U4YFYSF3.mjs} +1 -1
  136. package/lib/{chunk-Q6SXNKV2.mjs → chunk-UIR77ZJD.mjs} +1 -1
  137. package/lib/{chunk-FA4ZKDCU.mjs → chunk-UOHZW2L4.mjs} +1 -1
  138. package/lib/{chunk-7PY3VQP3.mjs → chunk-VXZ5PTOM.mjs} +1 -1
  139. package/lib/{chunk-7LKI7OAS.mjs → chunk-VZLJZEV2.mjs} +1 -1
  140. package/lib/{chunk-YH4DYI6D.mjs → chunk-W3BQGMTR.mjs} +1 -1
  141. package/lib/{chunk-CELEBWEZ.mjs → chunk-WABXKL4N.mjs} +1 -1
  142. package/lib/{chunk-EEFUE2ES.mjs → chunk-WAYQLQAD.mjs} +1 -1
  143. package/lib/{chunk-RCYEBY42.mjs → chunk-WBELLGNE.mjs} +1 -1
  144. package/lib/{chunk-SFGZFB4F.mjs → chunk-WJAZ5LHL.mjs} +1 -1
  145. package/lib/{chunk-JQZTMFO7.mjs → chunk-WXU6ZJIV.mjs} +1 -1
  146. package/lib/{chunk-GJ6SZVHT.mjs → chunk-WZN36ACK.mjs} +1 -1
  147. package/lib/{chunk-XU25YA46.mjs → chunk-X2XZQ434.mjs} +1 -1
  148. package/lib/{chunk-QAPVKPEC.mjs → chunk-X4HZD5U2.mjs} +1 -1
  149. package/lib/chunk-X6XNTOGO.mjs +7 -0
  150. package/lib/{chunk-XK5W7BVE.mjs → chunk-XAMMIPZ4.mjs} +1 -1
  151. package/lib/{chunk-DT3T7FRD.mjs → chunk-XAUQXYPW.mjs} +1 -1
  152. package/lib/{chunk-C3LNYAVJ.mjs → chunk-XCJUNX63.mjs} +1 -1
  153. package/lib/chunk-XJICAOAQ.mjs +7 -0
  154. package/lib/{chunk-CBL42DUU.mjs → chunk-XKFHTBAB.mjs} +1 -1
  155. package/lib/{chunk-O2PUGRNW.mjs → chunk-XMQ5R6TC.mjs} +1 -1
  156. package/lib/chunk-XPXEQKLR.mjs +7 -0
  157. package/lib/{chunk-6KP6WETK.mjs → chunk-Y7YUNRKK.mjs} +1 -1
  158. package/lib/{chunk-WSUKC2U3.mjs → chunk-YBZIDW6W.mjs} +1 -1
  159. package/lib/{chunk-RTWYLOCA.mjs → chunk-YEVB7LVK.mjs} +1 -1
  160. package/lib/{chunk-L4INJ5TZ.mjs → chunk-Z3MGN42K.mjs} +1 -1
  161. package/lib/{chunk-EOFO3PHS.mjs → chunk-ZB5E7NHU.mjs} +1 -1
  162. package/lib/chunk-ZCOSME6P.mjs +7 -0
  163. package/lib/{chunk-HFUDCNU5.mjs → chunk-ZOSESZ22.mjs} +1 -1
  164. package/lib/chunk-ZTHC42X6.mjs +7 -0
  165. package/lib/{chunk-XZISAZA6.mjs → chunk-ZXOUWHYE.mjs} +1 -1
  166. package/lib/sandforge-autopilot.mjs +1 -1
  167. package/lib/sandforge-backup.mjs +1 -1
  168. package/lib/sandforge-checkpoint.mjs +1 -1
  169. package/lib/sandforge-cleanup.mjs +1 -1
  170. package/lib/sandforge-clone.mjs +1 -1
  171. package/lib/sandforge-compare.mjs +1 -1
  172. package/lib/sandforge-dataops.mjs +1 -1
  173. package/lib/sandforge-empty.mjs +4 -4
  174. package/lib/sandforge-env.mjs +98 -99
  175. package/lib/sandforge-frozen.mjs +1 -1
  176. package/lib/sandforge-mcp.mjs +2 -2
  177. package/lib/sandforge-monitor.mjs +1 -1
  178. package/lib/sandforge-pipeline.mjs +1 -1
  179. package/lib/sandforge-seed.mjs +1 -1
  180. package/lib/sandforge-sync.mjs +1 -1
  181. package/lib/sandforge-users.mjs +21 -23
  182. package/oclif.manifest.json +1 -1
  183. package/package.json +1 -1
  184. package/lib/chunk-42BFLWHR.mjs +0 -7
  185. package/lib/chunk-466F37VD.mjs +0 -7
  186. package/lib/chunk-7SDZR6SR.mjs +0 -7
  187. package/lib/chunk-BMTNTBBM.mjs +0 -7
  188. package/lib/chunk-CCEH7L53.mjs +0 -7
  189. package/lib/chunk-DIL62SUN.mjs +0 -7
  190. package/lib/chunk-FZF23M6R.mjs +0 -7
  191. package/lib/chunk-GHPR5UVV.mjs +0 -7
  192. package/lib/chunk-HQQVANWQ.mjs +0 -20
  193. package/lib/chunk-IRZJU2PG.mjs +0 -22
  194. package/lib/chunk-ISSP2FZ5.mjs +0 -7
  195. package/lib/chunk-JFNLKHY6.mjs +0 -8
  196. package/lib/chunk-O4BROUGM.mjs +0 -7
  197. package/lib/chunk-PE435FVH.mjs +0 -15
  198. package/lib/chunk-RLWB7F26.mjs +0 -7
  199. package/lib/chunk-WEMLDUQA.mjs +0 -7
  200. package/lib/chunk-ZQO5PDX5.mjs +0 -48
@@ -1,7 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{b as ie,c as se,d as Vt,e as Jt,f as be}from"./chunk-XU25YA46.mjs";import{a as Zt,e as Xt}from"./chunk-O2PUGRNW.mjs";import{J as re,P as Ue,a as Kt}from"./chunk-7SDZR6SR.mjs";import{f as Le,p as ge,s as Be,u as Yt,w as $e}from"./chunk-3SKLBRPL.mjs";import{b as me,d as ue}from"./chunk-VPDEJGPS.mjs";import{c as qt}from"./chunk-PBE44M2Y.mjs";import{G as Ht}from"./chunk-XZISAZA6.mjs";import{c as Wt}from"./chunk-L4INJ5TZ.mjs";import{c as Gt,e as Fe,g as Me,h as pe}from"./chunk-TZE3Y7IQ.mjs";import{a as $t,b as V}from"./chunk-CA5NAXSU.mjs";import{C as dt,D as pt,E as mt,Ea as zt,F as ut,Fa as St,Fb as Rt,J as gt,K as bt,Ka as ae,L as ft,La as Ae,M as yt,N as ht,Pa as M,Qa as xt,Ra as F,Sa as Ee,Sc as Nt,Ta as It,Ua as kt,Va as Ce,Wa as Te,Wb as wt,Xa as _e,Yb as vt,Zb as At,ac as Et,ad as Dt,bc as Ct,bd as Ft,cb as Ne,cc as Tt,cd as Mt,de as Lt,ed as Ut,ee as Bt,fb as jt,fd as De,gb as Pt,hb as Ot,jc as _t,n as rt,s as we,t as it,u as st,v as ct,w as ne,y as lt,z as ve}from"./chunk-ZQO5PDX5.mjs";import{b as a,c as Oe,e as g,f as r,g as et,i as D,k as c,l as o,m as tt,o as de,p as Re,s as x,u as w,v,w as ot,x as nt,y as G,z as at}from"./chunk-WZQEK4WT.mjs";function sa(e,t,n){return async s=>{let d=s.map(f=>`${f.objectApiName} (${f.records})`).join(", ");e.log(`[WARN] ${n}: the user may not delete ${d} in the target: those records stay`);let p=e.infraServices?.confirmRemovalLeavingUndeletable;if(!p)return!0;let u=e.orgManager.getOrg(t);return p({org:Nt(u,t),objects:s})}}var Qt={code:"NOT_INITIALIZED",message:"Production Guard is not initialized \u2014 infrastructure services missing"};function ca(){return Object.assign(new Error(Qt.message),{code:Qt.code})}var qe={blocked:"GUARD_BLOCKED",declined:"GUARD_DECLINED"};function la(e){return Object.assign(new Error(`Operation blocked by Production Guard: ${e}`),{code:qe.blocked})}function da(e){return e instanceof Error&&e.code===qe.blocked?qe.blocked:void 0}function Bo(e){return e.robustness??zt}function pa(e){return e.bulkManager??new Kt(Bo(e).bulk.maxConcurrentJobs)}var $o={"sync:schedule":"sync:schedule:","sync:pipeline":"sync:pipeline:","seed:pipeline":"seed:pipeline:","offline-replay":"offline-replay-"};function ma(e,t,n){return{id:`${$o[e]}${t}`,type:n,timestamp:Date.now()}}function ua(e,t,n,s){return{id:e.nextId(),type:n,timestamp:Date.now(),correlationId:t.id,payload:s}}function ga(e,t,n,s,d={}){let p=t==="error"?null:d.autoDismissMs===void 0?5e3:d.autoDismissMs,u={id:e.nextId(),type:"notification",timestamp:Date.now(),payload:{level:t,title:n,message:s,...p===null?{}:{autoDismissMs:p},...d.actions?{actions:d.actions}:{},...d.code?{code:d.code}:{}}};e.broker.postToWebview(u),e.log(`[TX] notification: ${n}`)}function ba(e,t,n,s){let d={id:e.nextId(),type:"operation:started",timestamp:Date.now(),payload:{operationId:t,module:n,description:s}};e.broker.postToWebview(d)}function fa(e,t,n,s,d,p){let u={id:e.nextId(),type:"operation:progress",timestamp:Date.now(),payload:{operationId:t,percentage:n,processedRecords:s,totalRecords:d,currentStep:p}};e.broker.postToWebview(u)}function ya(e,t,n){let s={id:e.nextId(),type:"operation:completed",timestamp:Date.now(),payload:{operationId:t,result:n}};e.broker.postToWebview(s)}var qo=Symbol("sandforge.uncorrelated");function eo(e,t,n,s,d,p={}){let u=V(d),f=d instanceof qt?d:void 0,k=qo in s,E=p.code??f?.code??"UNKNOWN";k||Ko(e.broker,u,E),e.log(`[ERR] ${t}: ${u}${k?` (uncorrelated: ${String(s.reason)})`:""}`);let O={id:e.nextId(),type:n,timestamp:Date.now(),...k?{}:{correlationId:s.id},payload:{message:u,code:E,retryable:p.retryable??!1,...f?{orgId:f.orgId}:{},...p.extraPayload}};e.broker.postToWebview(O),e.log(`[TX] ${n}: ${u}`)}function ha(e,t){let n={id:e.nextId(),type:t.type,timestamp:Date.now(),payload:t.payload};e.broker.postToWebview(n)}function za(e){let t=e?.getSandforgeSetting;if(!(!t||!t("grappe.enabled",!1)))return{enabled:!0,autoActivateThreshold:t("grappe.autoActivateThreshold",1e4),maxWorkers:rt.maxWorkers,grappeSize:t("grappe.grappeSize",5e3),strategy:"round_robin",backPressure:{enabled:!1,maxQueueDepth:3,highWaterMark:80,lowWaterMark:60,strategy:"pause",monitoringInterval:5e3},checkpointing:!0,isolationLevel:"per_grappe"}}function Sa(e){let t=new Set(e.map(s=>s.batchSize)),[n]=t;return{...e.length>0?{objectName:e.map(s=>s.objectApiName).join(", ")}:{},...t.size===1&&n!==void 0?{batchSize:n}:{}}}function xa(e,t,n,s,d={}){let p={id:e.nextId(),type:"operation:failed",timestamp:Date.now(),payload:{operationId:t,error:n,retryable:s,...d.extraPayload}};e.broker.postToWebview(p),d.authored!==!0&&Zo(e,n,d.context)}var Go=[/^Operation cancelled by user\b/,/^Operation blocked by Production Guard: /,/^Production Guard is not initialized\b/,/^Duplicate operation: /,/^A backup or rollback operation is already running for org /,/^Object describe not available for '/,/^CRUD_FLS_DENIED: /,/^CRUD\/FLS check failed for /,/^No backup found for operation /,/^Backup \S+ was taken from org /,/^Restore not run: /,/^Pipeline failed$/,/^Pipeline did not start: /,/^Pipeline ran out of time: /,/^Org not found: /,/^No credentials for org /,/^Invalid username format: /];function Wo(e){return Go.some(t=>t.test(e))}var to=1e4,Ge=new WeakMap;function Ko(e,t,n){let s=De(t,{code:n});if(!s?.actionKey)return;let d=Ge.get(e)??new Map,p=Date.now();for(let[u,f]of d)p-f>to&&d.delete(u);d.set(s.code,p),Ge.set(e,d)}function Ho(e,t){let n=Ge.get(e)?.get(t);return n!==void 0&&Date.now()-n<=to}function Zo(e,t,n={}){if(!(e.broker.panelCount>0)||Wo(t))return;let d=$t(t,Ut)??"UNKNOWN",p=De(t,{code:d});if(p?.actionKey){if(Ho(e.broker,p.code))return;e.broker.showFixSuggestion({source:"catalogue",code:p.code,actionKey:p.actionKey});return}let u=e.errorResolver;u&&u.resolveError({errorCode:d,message:t},n).then(f=>{e.broker.showFixSuggestion({source:"model",text:Xo(f)})}).catch(f=>{e.log?.(`[ERR] operation:failed resolution: ${V(f)}`)})}function Xo(e){return e.suggestions[0]?.description||e.explanation}import{isAbsolute as tn}from"node:path";var i=a().min(1).max(128),l=a().regex(/^[A-Za-z][A-Za-z0-9_]*$/,"Invalid Salesforce API name").max(80),so=c(l).max(300),m=a().min(1).max(200),J=a().max(2e3).refine(Fe,{message:Me}),on=a().refine(Gt,{message:"ORDER BY clause must list only field names with optional ASC/DESC and NULLS FIRST/LAST (no LIMIT, OFFSET, FOR UPDATE or subquery)."}),y=100,co=1e4,B=o({keepDays:g().int().min(ve.min).max(ve.max).optional(),excluded:c(l).max(y).refine(e=>new Set(e).size===e.length,"An object is left out twice").optional()}).strict(),he={sweepLate:r().optional(),sweepUntied:r().optional()};function nn(e){return Wt(e)}function an(e,t='turn on "Copy the files of these records"'){return _t(e)?`Sync copies files with the records they hang on, not as an object of their own: "${e}" keeps its content in a file body. Remove it from this configuration and ${t} instead; the sync was not started.`:`Sync does not copy "${e}": no copy writes it \u2014 users and their access, metadata, a record's history, feed or sharing rows, and the records the platform keeps for itself are not data a copy carries. Remove it from this configuration; the sync was not started.`}var rn=w(gt,{error:e=>e.input==="manual"?"Manual conflict review is not available for a sync run: no run shows its conflicts to anyone before it writes. Pick source wins, target wins, newest wins or merge \u2014 target wins keeps every value the target holds where the two orgs differ. The sync was not started.":`Conflict strategy "${String(e.input)}" is not one a sync run acts on: pick source wins, target wins, newest wins or merge. The sync was not started.`}),sn=bt.extend({objectApiName:l.refine(e=>!nn(e),{error:e=>an(String(e.input))}),externalIdField:nt(e=>typeof e=="string"&&e.trim()===""?void 0:e,l.optional()),where:J.optional(),orderBy:on.optional(),batchSize:g().int().positive().max(co).optional()}).strip().refine(e=>e.operation!=="upsert"||(e.externalIdField??"Id").toLowerCase()!=="id",{path:["externalIdField"],error:e=>`An upsert of "${String(e.input.objectApiName)}" needs an External ID field: matching on Id cannot work, because the id belongs to the source org and the target has never issued it. Name an External ID field both orgs share, or set the operation to insert. The sync was not started.`}).superRefine((e,t)=>{let n=Ft([e]);n.length!==0&&t.addIssue({code:G.custom,message:`${Mt(n)} The sync was not started.`,params:{unreadablePatterns:n}})});function oo(e){return et({error:()=>`Sync does not run Apex: remove "${e}" from this configuration. The sync was not started so the script cannot be skipped without you knowing.`}).optional()}var Ke=ft.extend({id:m.optional(),sourceOrgId:i,targetOrgId:i,objects:c(sn).min(1).max(y),conflictStrategy:rn,createdAt:a().max(40).optional(),updatedAt:a().max(40).optional(),preScript:oo("preScript"),postScript:oo("postScript"),dryRun:v(!1,{error:()=>'A sync configuration cannot ask for a dry run: remove "dryRun" from it. A run of it writes to the target org; to see what it would write, simulate it from the Sync page. The run was not started, so it cannot write while you believed it was only reporting.'}).optional()}).strip().superRefine((e,t)=>{e.direction==="target_to_source"&&t.addIssue({code:G.custom,path:["direction"],message:'Sync writes source to target only: direction "target_to_source" is not supported. Swap the source and target orgs to copy the other way. The sync was not started, so it cannot write into the org you meant to read from.'}),e.mode!=="full"&&e.mode!=="delta"&&t.addIssue({code:G.custom,path:["mode"],message:`Sync runs a full or a delta sync only: mode "${e.mode}" is not implemented. Set mode to "full" or "delta". The sync was not started, so it cannot replay the whole object set while you believed it was reading changes only.`}),e.mode==="delta"&&e.objects.forEach((n,s)=>{n.operation==="upsert"||n.operation==="update"||t.addIssue({code:G.custom,path:["objects",s,"operation"],message:`A delta sync writes ${n.objectApiName} again for every record it reads twice, and ${n.operation} would ${n.operation==="insert"?"create a second copy":"delete a record already gone"}. Write it by upsert on an External ID, or by update, or run the configuration in full. The sync was not started.`})}),e.propagateDeletes===!0&&(e.mode!=="delta"?t.addIssue({code:G.custom,path:["propagateDeletes"],message:'Deletions are carried by a delta sync only, which knows since when to look for them: set mode to "delta", or turn deletions off. The sync was not started.'}):e.objects.forEach((n,s)=>{if(n.operation!=="upsert"&&n.operation!=="update")return;let d=Ht(n);"refused"in d&&t.addIssue({code:G.custom,path:["objects",s],message:`${d.refused} Turn deletions off, or carry a source field onto the key. The sync was not started.`})}))}),Ea=o({suggestedName:a().min(1).max(255).refine(e=>!e.includes("/")&&!e.includes("\\"),"suggestedName must not contain a path"),content:a().max(32*1024*1024),extensions:c(a().regex(/^[A-Za-z0-9]+$/)).max(8).optional()}),Ca=o({config:Ke,muteAutomation:r().optional(),checkpointFirst:B.optional()}),Ta=o({config:Ke,checkpointFirst:B.optional()}),_a=o({operationId:m}),Na=o({config:Ke}),Da=o({id:m}),Fa=o({orgId:i,targetOrgId:i.optional()}),Ma=o({sourceOrgId:i,targetOrgId:i,objectApiName:l}),lo=w(["source_wins","target_wins","newest_wins","manual","merge"]),cn=Re("kind",[o({kind:v("id")}),o({kind:v("externalId"),field:l}),o({kind:v("syncConfig"),configId:m})]),Ua=o({sourceOrgId:i,targetOrgId:i,watchedObjects:c(l).min(1).max(y),apply:c(o({objectApiName:l,match:cn,applyDeletes:r()})).max(y),conflictStrategy:lo,flushIntervalMs:g().int().min(50).max(6e4),maxBatchSize:g().int().min(1).max(200),keepContactPoints:r().optional()}).refine(e=>e.apply.every(t=>e.watchedObjects.includes(t.objectApiName)),{message:"Every applied object must be watched.",path:["apply"]}),La=o({sessionId:a().max(200)}),Ba=o({sourceOrgId:i,targetOrgId:i}),$a=o({conflictId:a().min(1).max(500),eventReplayId:g().optional(),resolution:lo,fieldResolutions:x(a(),o({value:D(),source:w(["source","target","manual"])})).optional()}),qa=o({entryId:m}),Ga=o({runId:m}),Wa=o({realtime:v(!0).optional()}).optional(),Ka=o({sourceOrgId:i,targetOrgId:i,objects:c(l).max(y),configId:m.optional()}),Ha=o({runId:m,includeChanged:r().optional(),sweep:r().optional(),again:r().optional(),muteAutomation:r().optional(),...he}),Za=o({runId:m}),Xa=o({runId:m,again:r().optional(),sweptObjects:so.optional()}),Ya=o({runId:m}),Va=o({runId:m,includeChanged:r().optional(),sweep:r().optional(),again:r().optional(),muteAutomation:r().optional(),...he}),Ja=o({runId:m}),Qa=o({format:w(["csv","json"]),entryIds:c(m).max(500).optional()}),ln=o({id:m,name:a().min(1).max(200),configId:m,cron:a().min(1).max(100),timezone:a().min(1).max(100),enabled:r(),maxRetries:g().int().min(0).max(10),notifyOnComplete:r(),notifyOnFailure:r(),createdAt:a().max(40),updatedAt:a().max(40),version:g().int().positive()}).strip(),er=o({schedule:ln}),tr=o({scheduleId:m,enabled:r()}),or=o({scheduleId:m}),dn=dt.extend({objectApiName:l,recordCount:g().int().positive().max(ne),batchSize:g().int().positive().max(co).optional()}).loose(),pn=pt.extend({childObject:l,lookupField:l,parentObject:l}).superRefine((e,t)=>{e.parents.kind==="existing"&&e.parents.where!==void 0&&!Fe(e.parents.where)&&t.addIssue({code:G.custom,path:["parents","where"],message:Me})}),mn=mt.extend({objects:c(dn).min(1).max(y),relations:c(pn).max(y).optional()}).loose().superRefine(ut),nr=o({orgId:i,template:mn,muteAutomation:r().optional(),checkpointFirst:B.optional(),fit:o({share:g().gt(0).max(1),withinMB:g().positive().max(1e6).optional(),before:g().int().positive().max(ne*y)}).strict().optional(),locale:a().regex(/^[a-z]{2,3}(?:_[A-Za-z0-9]{2,4}){0,2}$/).optional(),dryRun:r().optional()}),ar=o({orgId:i}),rr=o({orgId:i,objects:c(l).min(1).max(y),publishes:r().optional()}).strict(),ir=o({orgId:i,objectApiName:l}),sr=o({id:m}),cr=o({template:x(a(),D())}),lr=o({description:a().max(1e4)}),dr=o({}).strict(),pr=o({orgId:i,pack:ae,seed:Ae.shape.seed,articleBodyField:l.optional()}).strict(),mr=o({orgId:i,pack:ae,options:Ae,locale:a().regex(/^[a-z]{2,3}(?:_[A-Za-z0-9]{2,4}){0,2}$/).optional(),muteAutomation:r().optional(),checkpointFirst:B.optional()}).strict(),ur=o({orgId:i}).strict(),gr=o({pack:ae,overwrite:r().optional()}).strict(),br=o({runId:m,choice:Rt,overwrite:r().optional()}).strict(),un=131072,gn=o({objectApiName:l,whereClause:J.optional()}).loose(),fr=o({sourceOrgId:i}),yr=o({sourceOrgId:i,targetOrgId:i,objects:c(gn).min(1).max(y),upsert:r().optional(),externalIdField:l.optional(),previewId:m.optional(),keepContactPoints:r().optional(),checkpointFirst:B.optional()}).refine(e=>!e.upsert||e.externalIdField!==void 0,{message:"externalIdField is required when upsert is true",path:["externalIdField"]}),bn=o({csvHeader:a().min(1).max(500),sfFieldApiName:a().max(80),sfFieldType:a().max(40),sfFieldLength:g().int().positive().nullable()}).loose(),hr=o({orgId:i,objectApiName:l,records:c(x(a(),a().max(un))).min(1).max(st),columnMappings:c(bn).min(1).max(ct),externalIdField:l.optional(),checkpointFirst:B.optional()}),zr=o({orgId:i,objects:c(l).min(1).max(y),wheres:x(l,J).optional(),slices:r().optional()}).refine(e=>Object.keys(e.wheres??{}).every(t=>e.objects.some(n=>n.toLowerCase()===t.toLowerCase())),{message:"A filter names an object the backup reads: give it in objects",path:["wheres"]}),Sr=o({orgId:i}),xr=o({orgId:i,templateId:a().min(1).max(200).optional()}),Ir=o({orgId:i,operationId:a().min(1).max(200)}),kr=o({orgId:i,operationIds:c(a().min(1).max(200)).min(1).max(1e3).optional()}),W={acceptAutomation:r().optional(),acceptEmails:r().optional(),muteAutomation:r().optional()},X={fromPage:v(!0).optional()},jr=o({orgId:i,operationId:m,rewriteAll:r().optional(),includeChanged:r().optional(),slices:c(g().int().positive()).min(1).max(lt*y).optional(),...W,...X}),Pr=o({orgId:i,act:w(["masking","restore","cleanup"]),objects:c(o({objectApiName:l,records:g().int().min(0)})).max(y),erasure:r().optional(),...W,...X}),He={objects:c(l).min(1).max(y).optional(),where:J.optional()},Ze=e=>e.where===void 0||e.where.trim()===""||e.objects?.length===1,Xe={message:"A WHERE clause filters the rows of one object: name exactly one in objects",path:["where"]},Or=o({orgId:i,templateId:m,...He,resumeFrom:m.optional(),snapshot:r().optional(),slices:r().optional(),maxRequests:g().int().positive().max(1e9).optional(),abandon:r().optional(),...W,...X}).refine(Ze,Xe).refine(e=>!(e.snapshot===!0&&e.resumeFrom!==void 0&&e.slices!==!0),{message:"A resume takes no snapshot: the run it resumes has written over some of its rows",path:["snapshot"]}).refine(e=>!(e.slices===!0&&e.snapshot===!1),{message:"A run in slices backs each slice up before it masks it: it cannot keep no snapshot",path:["slices"]}).refine(e=>e.maxRequests===void 0||e.slices===!0,{message:"A bound on requests stops a run in slices between two of them: give slices too",path:["maxRequests"]}).refine(e=>e.abandon!==!0||e.resumeFrom===void 0&&e.snapshot!==!0&&e.maxRequests===void 0,{message:"Giving up a set of slices masks nothing: it takes no resume, snapshot or bound",path:["abandon"]}),Rr=o({orgId:i,templateId:m,...He,slices:r().optional()}).refine(Ze,Xe),wr=o({orgId:i,templateId:m,...He}).refine(Ze,Xe),vr=o({name:a().trim().min(1).max(jt),rules:c(Ot).min(1).max(Pt).refine(e=>new Set(e.map(t=>t.fieldPattern.toLowerCase())).size===e.length,"A field has two rules")}),Ar=o({templateId:m}),Er=o({orgId:i,objectNames:c(l).min(1).max(y)}),Cr=o({orgId:i,objects:c(o({objectApiName:l,duplicateKey:l.optional()})).min(1).max(10).refine(e=>new Set(e.map(t=>t.objectApiName.toLowerCase())).size===e.length,{message:"Each object may be named once per scan"}),staleDays:g().int().min(1).max(3650)}),po=c(l).min(1).max(10).refine(e=>new Set(e.map(t=>t.toLowerCase())).size===e.length,{message:"Each object may be named once per request"}),Tr=o({orgId:i,objects:po}),_r=o({orgId:i,objects:po,requestId:Oe().optional(),email:a().trim().refine(Ct,"Not an email address").optional(),name:a().refine(Tt,"Not a name").optional(),phone:a().refine(Et,"Not a phone number").optional()}).refine(e=>e.email!==void 0||e.name!==void 0||e.phone!==void 0,{message:"A search needs an email address, a name or a phone number"}),fn=o({orgId:i,requestId:Oe()}),ze=a().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,"Not a record Id"),Nr=o({runId:m,recordId:ze}).strict(),Dr=fn.extend({mode:w(["anonymize","delete"]),records:c(o({objectApiName:l,ids:c(ze).min(1).max(200)})).min(1).max(10).refine(e=>new Set(e.map(t=>t.objectApiName.toLowerCase())).size===e.length,{message:"Each object may be named once per request"}),dryRun:r(),...W}),yn=Re("kind",[o({kind:v("stale"),days:g().int().min(1).max(3650)}),o({kind:v("orphans"),fieldApiName:l}),o({kind:v("duplicates"),keyField:l})]),mo=o({orgId:i,objectApiName:l,recommendation:yn}),Fr=mo.extend({after:o({skip:g().int().nonnegative().max(1e8),id:ze.optional(),modified:a().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:?\d{2})$/).optional()}).strict().optional()}),Mr=mo.extend({dryRun:r(),...W,...X}),We=2e3,uo={mode:w(["objects","org"]),objects:c(l).min(1).max(We).optional(),excluded:c(l).max(We).optional(),customSettings:r().optional(),files:r().optional(),managedPackages:r().optional(),unrestorable:r().optional()},hn=o(uo).strict().refine(e=>e.mode==="objects"==(e.objects!==void 0),{message:"The objects picked are named in objects mode, and only there"}),Ur=o({orgId:i,...uo,objects:c(l).max(We).optional()}).strict().refine(e=>e.mode==="objects"==(e.objects!==void 0),{message:"The objects picked are named in objects mode, and only there"}),Lr=o({orgId:i,request:hn,deleteMode:w(["recycle","hard"]),checkpointFirst:r().optional(),acceptNoUndo:r().optional(),acceptPeopleActive:r().optional(),...W,...X}),Br=o({orgId:i,previewId:m.optional(),resumeRunId:a().regex(/^em-\d{8}-\d{6}-[a-z0-9]{4}$/).optional(),acceptNoUndo:r().optional(),acceptPeopleActive:r().optional(),checkpointFirst:r().optional(),...W,...X}).refine(e=>e.previewId===void 0!=(e.resumeRunId===void 0),{message:"An emptying acts on a preview, or takes up a run: one of them"}),$r=o({operationId:m}),qr=o({orgId:i,runId:a().regex(/^em-\d{8}-\d{6}-[a-z0-9]{4}$/),...W,...X}),Gr=o({orgId:i}),Wr=o({orgId:i}).strict(),Kr=o({alertId:m}),go=o({sourceOrgId:i,targetOrgId:i}),Hr=go.extend({types:c(a().min(1).max(80)).min(1).max(50),includeManaged:r().optional()}),zn=o({componentType:w(At),fullName:a().min(1).max(400).regex(/^[^\u0000-\u001f\u007f]+$/,"A component name holds no control character")}),Zr=go.extend({components:c(zn).min(1).max(500).refine(e=>new Set(e.map(t=>`${t.componentType}:${t.fullName}`)).size===e.length,{message:"Each component may be named once per deployment"}),testLevel:w(wt),runTests:c(a().max(255).regex(vt,"Not an Apex class name")).max(100).optional()}).refine(e=>e.sourceOrgId!==e.targetOrgId,{message:"The source and the target are the same org",path:["targetOrgId"]}).refine(e=>e.testLevel!=="RunSpecifiedTests"||(e.runTests?.length??0)>0,{message:"RunSpecifiedTests names at least one test class",path:["runTests"]}),Xr=o({validationId:a().regex(/^0Af[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/,"Not a deployment id"),targetOrgId:i}).strict(),Sn=a().regex(/^\d+\.\d+\.\d+$/,"Invalid semver"),ye=a().regex(/^[A-Za-z][A-Za-z0-9_]*\.[A-Za-z][A-Za-z0-9_]*$/,"Expected an Object.field key").max(170),xn=o({name:a().min(1).max(80),label:a().min(1).max(200),filterField:l,valuesSoql:a().min(1).max(4e3)}),In=o({name:a().min(1).max(80),label:a().min(1).max(200),whereFragment:J}),no=de([o({action:v("clear")}),o({action:v("replace"),value:a().max(255)})]),bo=o({rootObject:l,axes:c(xn).max(20),edgeCases:c(In).max(50),budgetMaxRecords:g().int().positive().max(1e5).optional(),candidatesPerCombination:g().int().positive().max(20).optional(),expectedObjects:c(l).max(100).optional(),maxNodes:g().int().min(10).max(500).optional(),excludedObjects:c(l).max(200).optional(),excludedFields:x(l,c(l).max(500)).optional(),sasDir:a().min(1).max(500).optional(),datasetDir:a().min(1).max(500).optional(),rulesFilePath:a().min(1).max(500).optional(),datasetVersion:Sn.optional(),protectedOrgIds:c(i).max(50).optional(),identityKeys:x(l,c(l).min(1).max(10)).optional(),undeletableObjects:x(l,l).optional(),requiredLookupPlaceholders:x(ye,o({name:a().min(1).max(200),recordTypeDeveloperName:a().min(1).max(97).optional(),targetObjectApiName:l.optional()})).optional(),requiredFieldDefaults:x(ye,D()).optional(),picklistRules:x(ye,no).optional(),defaultPicklistRule:no.optional(),duplicateErrorPatterns:c(a().min(1).max(200)).max(50).optional(),mockDetection:o({metadataTypeApiName:l,isMockedFieldApiName:l}).optional(),mandatoryLookups:x(l,c(l).min(1).max(50)).optional(),presenceKeys:x(l,l).optional()}),Yr=o({config:bo}),Vr=o({sourceOrgId:i}),Jr=o({fields:c(ye).min(1).max(2e3)}),Qr=o({sourceOrgId:i,author:a().min(1).max(120).optional()}),ce=o({organizationId:kt,checkpointId:F}).strict(),kn=bo.pick({requiredFieldDefaults:!0,requiredLookupPlaceholders:!0,picklistRules:!0,defaultPicklistRule:!0,identityKeys:!0,undeletableObjects:!0,duplicateErrorPatterns:!0,mockDetection:!0,protectedOrgIds:!0}).strict(),fo=ce.extend({choices:Ne,config:kn.optional()}).strict(),jn=fo.extend({choices:Ne.optional()}).strict(),ti=o({targetOrgId:i,replay:fo.optional(),pilot:r().optional(),reload:r().optional(),writeEncrypted:r().optional(),maxRecords:g().int().positive().max(1e6).optional(),muteAutomation:r().optional(),checkpointFirst:B.optional(),sweep:r().optional(),...he,includeChanged:r().optional(),acceptEmails:r().optional(),acceptAutomation:r().optional(),goneFirst:c(ze).max(1e6).optional()}),Pn=o({targetOrgId:i}),oi=Pn.extend({replay:jn.optional()}),ni=o({targetOrgId:i,loadedAt:a().min(1).max(64),includeChanged:r().optional(),sweep:r().optional(),...he,muteAutomation:r().optional(),replay:ce.optional()}),ai=o({targetOrgId:i,loadedAt:a().min(1).max(64),reload:r().optional(),replay:ce.optional()}),ri=o({targetOrgId:i,loadedAt:a().min(1).max(64),sweptObjects:so.optional(),reload:r().optional(),replay:ce.optional()}),ii=o({targetOrgId:i,loadedAt:a().min(1).max(64),includeChanged:r().optional(),replay:ce.optional()}),yo=1e3,ho=3650,On=200,Z=c(l).min(1).max(yo).refine(e=>new Set(e).size===e.length,"An object is named twice");function zo(e){return e.mode==="picked"?e.objects!==void 0:e.objects===void 0}var So=de([v("all"),c(l.refine(e=>e.toLowerCase().endsWith("__c"),"A custom setting's API name ends in __c")).min(1).max(yo).refine(e=>new Set(e.map(t=>t.toLowerCase())).size===e.length,"A custom setting is named twice")]),xo={path:["objects"],message:'Name the objects with "picked", and none with "everything"'},si=o({orgId:i.optional()}).optional(),Rn=1e6,Io=g().int().min(1).max(Rn),ci=o({orgId:i,mode:_e,objects:Z.optional(),excluded:Z.optional(),customSettings:So.optional(),maxTotal:Io.optional()}).refine(zo,xo),li=o({orgId:i,name:Te,mode:_e,objects:Z.optional(),excluded:Z.optional(),customSettings:So.optional(),maxTotal:Io.optional(),keepDays:g().int().min(0).max(ho),ignoredFields:Ce.optional()}).refine(zo,xo),di=o({checkpointId:F,objects:Z.optional(),muteAutomation:r().optional(),acceptOutside:r().optional()}),pi=o({checkpointId:F,previewId:Ee,objects:Z.optional(),acceptAutomation:r(),muteAutomation:r().optional(),acceptEmails:r().optional(),acceptNoUndo:r(),acceptRecreate:r(),acceptOutside:r(),acceptUnseen:r(),fromPage:v(!0).optional()}),mi=o({checkpointId:F,previewId:Ee,objects:Z,acceptOutside:r()}),ui=o({checkpointId:F}),wn=200,gi=o({token:m,orgId:i,key:a().min(1).max(wn),keepDays:g().int().min(0).max(ho)}),bi=o({checkpointId:F,rewindId:It,acceptAutomation:r(),muteAutomation:r().optional(),acceptEmails:r().optional(),fromPage:v(!0).optional()}),fi=o({checkpointIds:c(F).min(1).max(On).refine(e=>new Set(e).size===e.length,"A checkpoint is named twice")}),yi=o({checkpointId:F,keep:r()}),hi=o({checkpointId:F,name:Te}),zi=o({checkpointId:F,fields:Ce}),vn=500,Si=o({orgIds:c(i).min(1).max(vn).refine(e=>new Set(e).size===e.length,"An org is named twice").optional()}).strict().optional(),xi=o({sourceOrgId:i,targetOrgId:i,includeStandardObjects:r()}),Ii=o({sourceOrgId:i,objectApiNames:c(l).min(1).max(it)}),ki=o({sourceOrgId:i,targetOrgId:i,selectedObjects:c(l).max(y),includeStandardObjects:r(),maxDepth:g().int().min(1).max(10).optional(),maxObjects:g().int().min(1).max(500).optional()}),ji=o({complianceFramework:ht,objectFilters:x(a(),J).optional(),overrides:c(o({objectApiName:l,fieldApiName:l,method:de([yt,v("skip")])})).max(500).optional()}),Pi=o({grappeThreshold:g().int().nonnegative(),keepContactPoints:r().optional(),muteAutomation:r().optional(),checkpointFirst:B.optional()}),Oi=o({mode:o({share:v(!0).optional(),caps:x(l,g().int().min(1).max(ne)).refine(e=>Object.keys(e).length<=y,"Too many caps").optional(),all:g().int().min(1).max(ne).optional(),withinMB:g().positive().max(1e6).optional()}).strict().refine(e=>e.share===!0||e.caps!==void 0||e.all!==void 0,"Fit by share, by caps, or both"),muteAutomation:r().optional(),checkpointFirst:B.optional()}),Ri=o({objectApiName:l}),wi=o({orgId:i.optional(),sourceOrgId:i.optional(),alreadySelected:c(l).max(y).optional()}).loose(),vi=o({orgId:i.optional(),sourceOrgId:i.optional(),objectApiName:l.optional(),alreadySelected:c(l).max(y).optional(),selectedObjects:c(l).max(y).optional(),availableObjects:c(l).max(500).optional()}).loose(),Ai=o({sourceOrgId:i,targetOrgId:i.optional(),selectedObjects:c(l).min(1).max(y),parentObjects:c(l).max(y).optional()}).loose(),An=St.extend({sourceOrgId:i,targetOrgId:i,selectedObjects:c(l).min(1).max(y),parentObjects:c(l).max(y).default([])}).loose(),Ei=o({config:An.optional(),sourceOrgId:i.optional(),targetOrgId:i.optional(),selectedObjects:c(l).min(1).max(y).optional(),parentObjects:c(l).max(y).optional()}).loose(),En=a().min(1).max(5e4),Ci=o({conversationId:m,message:a().max(5e4)}),Ti=o({title:a().min(1).max(300)}),_i=o({conversationId:m}),Ni=o({apiKey:a().min(1).max(500),errorResolution:r().optional()}),Di=o({enabled:r().optional(),errorResolution:r().optional()}),Fi=o({orgId:i,objectName:l,sampleSize:g().int().positive().max(1e4).optional()}),Mi=o({orgId:i,prompt:a().trim().min(1).max(2e3).optional(),soql:a().trim().min(1).max(2e4).optional()}).refine(e=>e.prompt===void 0!=(e.soql===void 0),{message:"Send a prompt to draft from or a query to check, not both and not neither"}),Ui=o({description:En,orgIds:c(i).max(50).optional()}),Li=o({requestId:m}),fe=c(a().min(1).max(M.picklistValue)).max(M.picklistValues),ao={label:a().max(M.agentLabel).optional(),description:a().max(M.agentDescription).optional()},Bi=o({text:a().trim().min(1).max(M.text),language:ae.shape.language,casePicklists:o({Status:fe.optional(),Origin:fe.optional(),Priority:fe.optional(),Type:fe.optional()}).optional(),agent:o({topics:c(o({name:a().min(1).max(M.agentName),...ao,actions:c(o({name:a().min(1).max(M.agentName),...ao})).max(M.agentActions)})).max(M.agentTopics)}).optional(),draft:xt.optional(),maskOnly:r().optional()}),$i=o({filePath:a().min(1).max(2e3)}),qi=o({name:a().max(200),config:x(a(),D())}),Gi=o({operationId:m.optional(),executionId:m.optional(),objectName:a().min(1).max(200).optional()}).loose(),Wi=o({policyId:m}),Ki=o({policy:x(a(),D())}),Hi=o({policyId:m,orgId:i}),Zi=o({module:a().min(1).max(50).optional(),orgId:i.optional(),offset:g().int().min(0).max(we).optional(),limit:g().int().min(1).max(we).optional()}).optional(),Xi=o({operationId:m.optional()}).optional(),Cn=w(["syncMappings","forgePlans","pipelines","anonymizationTemplates"]),Yi=o({categories:c(Cn).min(1).max(50)}),Vi=o({json:a().min(1).max(5e6),overwrite:r()}),Ji=o({json:a().min(1).max(5e6)}),Qi=o({orgId:a().max(128),authMethod:a().min(1).max(50),alias:a().max(100).optional(),loginUrl:a().max(500).optional(),username:a().max(300).optional(),password:a().max(500).optional(),securityToken:a().max(100).optional(),clientId:a().max(256).optional(),jwtKeyFile:a().max(4096).optional()}).loose(),ko=a().trim().max(100).regex(/^[\w.-]*$/,"an alias is letters, digits, dots, dashes and underscores").optional(),Tn=a().trim().min(1,"the username is required").max(80).regex(/^[\w.@+-]+$/,"a username is written like an email address"),jo=a().trim().min(1,"the consumer key is required").max(256).regex(/^[A-Za-z0-9._-]+={0,2}$/,"a consumer key is letters, digits, dots, dashes and underscores"),_n=a().trim().min(1,"the private key file is required").max(4096).regex(/^[^\u0000-\u001f\u007f]+$/,"the private key file path holds a control character").refine(e=>tn(e),"give the private key file as an absolute path"),es=o({alias:ko,loginUrl:a().max(500).optional(),username:Tn,clientId:jo,jwtKeyFile:_n}).loose(),ts=o({alias:ko,loginUrl:a().max(500).optional(),clientId:jo}).loose(),os=o({requestId:m}),ns=o({orgId:i}),as=o({orgId:i}),rs=o({orgId:i}).strict(),is=o({orgId:i,alias:a().trim().min(1).max(100),color:a().regex(/^#[0-9A-Fa-f]{6}$/),tags:c(a().trim().min(1).max(50)).max(20),staging:r().optional()}),ss=o({key:a().min(1).max(200),value:D()}),cs=o({enabled:r()}),ls=o({lng:w(["en","fr","de","es","ja","pt-BR"])}),ds=o({targetOrgId:i,sourceOrgId:i.optional()}),ps=o({moduleId:a().min(1).max(64),route:a().min(1).max(64),overlay:r()}),ms=o({moduleId:a().min(1).max(64)}),Nn=80,Dn=ot(e=>Lt(e)||Bt(e)||typeof e=="string"&&e.trim()!==""&&e.length<=Nn,{message:"Not a pipeline step type"}),Fn=o({pipeline:o({name:a().min(1).max(200),steps:c(o({type:Dn,config:x(a(),D()).default({})}).loose()).max(200),variables:c(x(a(),D())).max(200).default([]),triggers:c(x(a(),D())).max(50).default([])}).loose(),variables:x(a(),a().max(2e3)).optional(),dryRun:r().optional()}),Mn=tt({since:at.datetime({offset:!0}),runner:w(["cron","taskScheduler","githubActions"]),file:a().min(1).max(255).refine(e=>!/[\\/]/.test(e),"The file's name, without its folder"),digest:a().regex(/^sha256:[0-9a-f]{64}$/,"Not a digest: sha256: and 64 hex digits")}),us=Fn.shape.pipeline.extend({id:a().min(1).max(200),runsOutside:Mn.optional()}),gs=o({pipelineId:m}),bs=o({id:a().max(200),config:x(a(),D())}),fs=o({id:m}),ys=o({operationId:m,stepId:m,decision:w(["approved","rejected"])}),Un=255,Po={pipelineId:m,stepId:m},hs=o({pipelineId:m}),zs=o({...Po,typed:a().min(1).max(Un)}),Ss=o(Po),xs=o({category:a().max(100).optional(),query:a().max(500).optional()}).loose().optional(),Is=o({templateId:m});function Ln(e){return e.issues.slice(0,3).map(t=>`${t.path.join(".")||"(root)"}: ${t.message}`).join("; ")}function Bn(e){let t=e.issues.map(n=>n.code==="custom"?n.params?.unreadablePatterns:void 0);return t.every(n=>n!==void 0)?t.flat():void 0}function ks(e,t,n,s){let d=e.safeParse(t.payload);if(!d.success){let p=Ln(d.error),u=Bn(d.error);return eo(s,t.type,n,t,new Error(`Invalid payload \u2014 ${p}`),u?{code:Dt,extraPayload:{rules:u}}:{code:"INVALID_PAYLOAD"}),null}return d.data}var $n=5;function Se(e){return e.slice(0,15)}function qn(e){let t=e.errors?.[0];if(t===void 0)return"The org gave no reason.";if(typeof t=="string")return t;let n=t.statusCode??"",s=t.message??"";return n&&s?`${n}: ${s}`:n||s||"The org gave no reason."}function Oo(e){let t=new Set;for(let n of e){let s=n.Id;typeof s=="string"&&t.add(Se(s))}return t}async function Ro(e){let t=[],n=[],s={},d=!1,p=!1,u=e.stampsFor,f=ie(e.org),k=e.org.serverTime?.bind(e.org),E=u&&k?Date.now()+await se({serverTime:k})-re:Number.NaN;for(let{objectApiName:O,ids:A}of e.plan){let I={objectApiName:O,planned:A.length,undeleted:0,alreadyBack:0,goneForGood:0,refused:0,reasons:[]};t.push(I);let z=_=>{I.reasons.length<$n&&!I.reasons.includes(_)&&I.reasons.push(_)},R=pe(O);for(let _=0;_<A.length;_+=me){let C=A.slice(_,_+me);if(p||e.signal?.aborted){p=!0,I.notReached=(I.notReached??0)+C.length,n.push(...C);continue}let[ee]=ue(C,me),K,te;try{K=Oo((await e.org.queryDeleted(`SELECT Id FROM ${R} WHERE Id IN (${ee}) AND IsDeleted = true`)).records),te=Oo((await e.org.query(`SELECT Id FROM ${R} WHERE Id IN (${ee})`)).records)}catch(j){I.refused+=C.length,z(`The recycle bin could not be read: ${V(j)}`),n.push(...C);continue}let h=C.filter(j=>K.has(Se(j)));for(let j of C)K.has(Se(j))||(te.has(Se(j))?I.alreadyBack++:I.goneForGood++);if(h.length===0)continue;let U;try{d=!0;let j=await e.undelete(h),T=Array.isArray(j)?j:[j];U=h.map((H,oe)=>T[oe]??{success:!1})}catch(j){let T=V(j);U=h.map(()=>({success:!1,errors:[T]}))}let Y=[];U.forEach((j,T)=>{if(j.success===!0){I.undeleted++,u?.(h[T])&&Y.push(h[T]);return}I.refused++,z(qn(j)),n.push(h[T])}),Y.length>0&&Number.isFinite(E)&&Object.assign(s,await be(e.org,R,Y,E,f))}}return{objects:t,left:n,wrote:d,cancelled:p,stamps:s}}function wo(e){return e.refused+e.goneForGood+(e.notReached??0)}async function Gn(e,t,n,s){let d=new Map(Object.entries(s).map(([u,f])=>[u.slice(0,15),Date.parse(f)])),p=new Set;for(let{objectApiName:u,ids:f}of t){let k=pe(u);for(let E of ue(f)){let O;try{O=(await e.query(`SELECT Id, LastModifiedDate FROM ${k} WHERE Id IN (${E})`)).records}catch{continue}for(let A of O){if(typeof A.Id!="string")continue;let I=A.Id.slice(0,15),z=Date.parse(String(A.LastModifiedDate??""));(z<=n||z<=(d.get(I)??Number.NaN))&&p.add(I)}}}return p}function vo(e){let t=Date.parse(e.startedAt),n=Date.parse(e.lastWrittenAt??e.end?.at??"");return Number.isFinite(n)?{runRecordedAt:new Date(n),...Number.isFinite(t)?{runDurationMs:Math.max(0,n-t)}:{}}:{}}function Wn(e){return e.filter(t=>t.deleted+t.alreadyGone>0).map(t=>t.objectApiName)}async function Ms(e){let{run:t,includeChanged:n}=e,s=e.again===!0,d=ge(t,s),p=d.reduce((b,S)=>b+S.ids.length,0),u=Be(t),f=u.reduce((b,S)=>b+S.ids.length,0),k=Yt(t),E=k.reduce((b,S)=>b+S.ids.length,0),O=[],A=e.backups,I=e.undelete;k.length>0&&!I&&O.push(`The ${E} record(s) the run deleted could not be brought back from the recycle bin here: the next removal offers them again.`),u.length>0&&!A&&O.push(`The values from before the run of ${f} record(s) it wrote over could not be read here: they were not put back, and the next removal offers them again.`);let z,R,_={},C=(e.earlierRuns??[]).map(b=>({runId:b.runId,keys:new Set([...ge(b),...Be(b)].flatMap(({ids:S})=>S.map(L=>L.slice(0,15))))})),ee=b=>C.some(({keys:S})=>S.has(b.slice(0,15))),K=e.sweep,te=u.length>0&&A||k.length>0&&I||K?async b=>{if(k.length>0&&I){let N=u.length>0&&A?await Gn(e.org,u,await Vt(e.org,xe(t)),t.removal?.removalStamps??{}):void 0,q=N?Date.now()+await se(e.org)-re:0;if(R=await Ro({org:e.org,plan:k,undelete:I,...C.length>0?{stampsFor:ee}:{},...e.signal?{signal:e.signal}:{}}),N&&R.wrote){let P=ie(e.org);for(let{objectApiName:Pe,ids:Mo}of u){let Uo=Mo.filter(Lo=>N.has(Lo.slice(0,15)));Object.assign(_,await be(e.org,Pe,Uo,q,P))}}if(R.cancelled||e.signal?.aborted)return R.wrote}if(u.length>0&&A){let N={...t.removal?.removalStamps,..._};z=await Jt({org:e.org,plan:u,backups:A,...xe(t)!==void 0?{lastWriteAt:xe(t)}:{},includeChanged:n,...Object.keys(N).length>0?{stamps:N}:{},...t.unkept?{unkept:t.unkept}:{},...C.length>0?{stampsFor:ee}:{},...e.signal?{signal:e.signal}:{}})}let S=(R?.wrote??!1)||(z?.wrote??!1);if(z?.cancelled||e.signal?.aborted)return S;let L=K?await K(b):!1;return S||L}:void 0,h=await Ue(e.org,d,{...vo(t),...t.removal?.removalStamps?{removalStamps:t.removal.removalStamps}:{},...t.removal?.removalSpans?{removalSpans:t.removal.removalSpans}:{},includeChanged:n,...te?{sweep:te}:{},...e.afterRemoval?{afterRemoval:e.afterRemoval}:{},...e.automationMade?{automationMade:e.automationMade}:{},...e.runUserId?{runUserId:e.runUserId}:{},...e.onUndeletable?{onUndeletable:e.onUndeletable}:{},...e.beforeFirstWrite?{beforeFirstWrite:e.beforeFirstWrite}:{},signal:e.signal,onProgress:e.onProgress}),U=new Date().toISOString();if(h.stoppedForUndeletable)return{result:{runId:t.runId,status:"cancelled",includeChanged:n,objects:[],finishedAt:U},planned:p,plannedBack:f,plannedUndelete:E,notes:[],stoppedForUndeletable:!0};let Y=s?void 0:t.removal?.undo?.removedAt,j={runId:t.runId,status:Zn(Xn(Zt(h.objects,h.cancelled),h.objects,z),h.objects,z,R),includeChanged:n,objects:h.objects,finishedAt:U,...Y?{leftBy:Y}:{},...z&&z.objects.length>0?{restored:z.objects}:{},...R&&R.objects.length>0?{undeleted:R.objects}:{}},T=Xt(j,p,t.removal?.undo,s),H=new Set(h.gone),oe=H.size>0||s&&T?d.flatMap(({ids:b})=>b.filter(S=>!H.has(S))):void 0,Je={..._,...h.stamps},Qe=Object.keys(Je).length>0,No=z?.objects.some(b=>b.restored+(b.restoredWithout??0)>0)===!0,Do=R!==void 0&&!R.cancelled;if(T||Qe||h.span||oe||z||R)try{await e.store.updateRemoval(t.runId,b=>({...b,...T?{undo:T}:{},...Qe?{removalStamps:{...b.removalStamps,...Je}}:{},...h.span?{removalSpans:[...b.removalSpans??[],h.span]}:{},...oe?{removalLeft:oe}:{},...z?{restoreLeft:z.left}:{},...No?{restoredAt:U}:{},...R?{undeleteLeft:R.left}:{},...Do?{undeletedAt:U}:{}}))}catch(b){O.push(`What this removal did could not be kept (${b instanceof Error?b.message:String(b)}): the next removal of the run may set out to take records already gone.`)}let Fo=Object.keys(z?.stamps??{}).length>0?await Kn(e.org,t,e.earlierRuns??[]):new Map,ke=[];for(let{runId:b,keys:S}of C){let L=Fo.get(b),N=Object.fromEntries(Object.entries({...R?.stamps,...z?.stamps}).filter(([P])=>S.has(P.slice(0,15))&&!L?.has(P.slice(0,15)))),q=Object.keys(N).length;if(q!==0)try{await e.store.updateRemoval(b,P=>({...P,removalStamps:{...P.removalStamps,...N},...h.span?{removalSpans:[...P.removalSpans??[],h.span]}:{}})),ke.push({runId:b,records:q})}catch(P){O.push(`What this removal gave back of ${q} record(s) the run ${b} wrote too could not be kept on it (${P instanceof Error?P.message:String(P)}): its removal reads them as changed since it.`)}}let le=e.configs;if(le&&H.size>0&&le.isSaved(t.configId)){let b={sourceOrgId:t.sourceOrgId,targetOrgId:$e(t)};try{let S=d.filter(P=>Le.includes(P.objectApiName)).flatMap(({ids:P})=>P.filter(Pe=>H.has(Pe))),L=le.forgetFiles(t.configId,b,S),N=Wn(h.objects).filter(P=>!Le.includes(P)),q=le.markRemoved(t.configId,b,[...new Set([...N,...L.map(P=>P.objectApiName)])],U);j={...j,...q.length>0?{readWhole:q}:{},...L.length>0?{filesForgotten:L.length}:{}}}catch(S){O.push(`The configuration could not be told what this removal took (${S instanceof Error?S.message:String(S)}): run it full next time.`)}}let je;if(e.links&&H.size>0)try{je=await e.links.forget(t.configId,{sourceOrgId:t.sourceOrgId,targetOrgId:$e(t)},[...H])}catch(b){O.push(`Which records of the target this removal took could not be forgotten (${b instanceof Error?b.message:String(b)}): a later run of the configuration may point a lookup at one of them.`)}return{result:j,planned:p,plannedBack:f,plannedUndelete:E,notes:O,...je?{linksForgotten:je}:{},...ke.length>0?{earlierStamped:ke}:{},...h.duplicateSets?{duplicateSets:h.duplicateSets}:{}}}async function Us(e){let{run:t}=e,n=ge(t);return{outcome:await Ue(e.org,n,{...vo(t),...t.removal?.removalStamps?{removalStamps:t.removal.removalStamps}:{},...t.removal?.removalSpans?{removalSpans:t.removal.removalSpans}:{},includeChanged:e.includeChanged,...e.runUserId?{runUserId:e.runUserId}:{},previewOnly:!0,...e.signal?{signal:e.signal}:{}}),planned:n.reduce((d,p)=>d+p.ids.length,0)}}async function Kn(e,t,n){let s=new Map,d=Object.entries(t.heldBefore??{});if(d.length===0||n.length===0)return s;let p=await ie(e)(),u=await se(e);for(let f of n){let k=Date.parse(xe(f)??""),E=Number.isFinite(k)?k+u+re:Number.NEGATIVE_INFINITY,O=new Set;for(let[A,{at:I,by:z}]of d)Date.parse(I)>E&&(p!==void 0&&z!==void 0&&z.slice(0,15)===p||O.add(A));O.size>0&&s.set(f.runId,O)}return s}function xe(e){return e.lastWriteAt??e.lastWrittenAt??e.end?.at}function Hn(e){return e.keptChanged+e.refused+e.notKept+(e.notReached??0)+(e.restoredWithout??0)}function Zn(e,t,n,s){if(!s||e==="cancelled")return e;if(s.cancelled)return"cancelled";let d=s.objects.some(u=>wo(u)>0);if(e==="success"&&!d)return"success";let p=t.some(u=>u.deleted>0)||(n?.objects??[]).some(u=>u.restored>0)||s.objects.some(u=>u.undeleted>0);return e==="partial"||p?"partial":"failure"}function Xn(e,t,n){if(!n||e==="cancelled")return e;if(n.cancelled)return"cancelled";let s=n.objects.some(p=>Hn(p)>0);return e==="success"&&!s?"success":t.some(p=>p.deleted>0)||n.objects.some(p=>p.restored+(p.restoredWithout??0)>0)?"partial":"failure"}function Bs(e){let t=e?.getSandforgeSetting?.("backup.maxAgeDays",30);return typeof t=="number"&&Number.isFinite(t)&&t>0?t:0}function $s(e,t,n){let s=[],d=0,p=Number.POSITIVE_INFINITY;for(let u of e){let f=t(u.backup);if(!f){d+=u.ids.length;continue}s.push(u);let k=Date.parse(f.timestamp??"");n>0&&Number.isFinite(k)&&(p=Math.min(p,k+n*864e5))}return{kept:s,notKept:d,...Number.isFinite(p)?{keptUntil:new Date(p).toISOString()}:{}}}var Ye="backupSet:",Yn="backups",Ve=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,Q=a().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/),$=g().int().nonnegative(),Vn=o({index:g().int().positive(),afterId:a().regex(Ve).optional(),lastId:a().regex(Ve).optional(),rows:$,snapshotId:a().min(1).max(240),takenAt:Q.optional(),readSince:Q.optional(),state:w(["pending","snapshotted","masking","masked","restored"]),masked:$,refused:$,deletedSince:$,nothingToMask:$,unanswered:$.optional(),late:v(!0).optional(),sizeUsed:g().int().positive(),lateLeft:$.optional(),lateOf:g().int().positive().optional(),lateAfterId:a().regex(Ve).optional(),restoredAt:Q.optional()}),Jn=o({objectApiName:a().min(1).max(255),where:a().max(2e3).optional(),select:a().max(1e5).optional(),done:r(),tailLeft:$.optional(),slices:c(Vn)}),Ao=o({setId:a().min(1).max(200),kind:w(["masking","backup"]),orgId:a().min(1).max(200),organizationId:a().max(18).optional(),templateId:a().min(1).max(200).optional(),fingerprint:a().regex(/^[0-9a-f]{64}$/).optional(),size:g().int().positive(),state:w(["open","done","abandoned"]),startedAt:Q,serverStartedAt:Q.optional(),lastActivityAt:Q,requestsSpent:$,keyCheck:a().regex(/^[0-9a-f]{16}$/).optional(),objects:c(Jn)});function Gs(e,t){return`${e}-s${String(t).padStart(4,"0")}`}function Ie(e){return e.objects.flatMap(t=>t.slices).sort((t,n)=>t.index-n.index)}function Ws(e){return Ie(e).reduce((t,n)=>Math.max(t,n.index),0)+1}function Co(e){return e.state==="masked"||e.state==="snapshotted"||e.state==="restored"}function Qn(e){return Ie(e).reduce((t,n)=>t+n.rows,0)}function To(e,t,n){return{index:t.index,objectApiName:e,snapshotId:t.snapshotId,rows:t.rows,masked:t.masked,refused:t.refused,deletedSince:t.deletedSince,nothingToMask:t.nothingToMask,state:t.state,...t.late?{late:!0}:{},...t.sizeUsed<n?{sizeUsed:t.sizeUsed}:{},...t.restoredAt?{restoredAt:t.restoredAt}:{}}}function ea(e){return e.objects.reduce((t,n)=>t+(n.tailLeft??0)+n.slices.reduce((s,d)=>s+(d.lateLeft??0),0),0)}function Ks(e,t){return{setId:e.setId,size:e.size,state:e.state,objects:e.objects.map(n=>({objectApiName:n.objectApiName,slices:n.slices.map(s=>To(n.objectApiName,s,e.size))})),lateRecords:ea(e),requestsSpent:t.requestsSpent,...t.stoppedOnBudget?{stoppedOnBudget:!0}:{},slicesLeft:e.objects.some(n=>!n.done||n.slices.some(s=>!Co(s)))}}function ta(e){return e.kind==="backup"&&e.state==="open"?"partial":e.state}function Hs(e){let t=Object.fromEntries(e.objects.flatMap(n=>n.where?[[n.objectApiName,n.where]]:[]));return{setId:e.setId,orgId:e.orgId,kind:e.kind,state:ta(e),startedAt:e.startedAt,lastActivityAt:e.lastActivityAt,size:e.size,totalRecords:Qn(e),...e.templateId?{templateId:e.templateId}:{},slices:e.objects.flatMap(n=>n.slices.map(s=>To(n.objectApiName,s,e.size))),...Object.keys(t).length>0?{wheres:t}:{}}}function Zs(e){let t=Ie(e);return{setId:e.setId,savedAt:e.lastActivityAt,done:t.filter(Co).length,total:t.length,state:e.state,size:e.size}}var Eo=class{constructor(t){this.configStore=t}configStore;get(t){let n=Ao.safeParse(this.configStore.get(this.key(t)));return n.success&&n.data.setId===t?n.data:void 0}save(t){this.configStore.set(this.key(t.setId),Ao.parse(t),Yn)}delete(t){this.configStore.delete(this.key(t))}list(t){return this.configStore.getKeysByPrefix(Ye).map(n=>this.get(n.slice(Ye.length))).filter(n=>n!==void 0).filter(n=>t===void 0||n.orgId===t)}openFor(t,n){return this.list(t).find(s=>s.kind==="masking"&&s.state==="open"&&s.templateId===n)}ofSnapshot(t){return this.list().find(n=>Ie(n).some(s=>s.snapshotId===t))}key(t){return`${Ye}${t}`}};async function Ys(e,t){let n=e.check(t);if(!n.allowed)return{check:n,decision:"refused"};if(!await e.confirmIfNeeded(n,t.orgTier))return{check:n,decision:"declined"};let d=n.requiresConfirmation&&e.canAskForConfirmation===!0;return{check:n,decision:d?"confirmed":"allowed"}}var _o={allowed:0,confirmed:1,declined:2,refused:3};function Vs(e,t){return e===void 0||_o[t]>_o[e]?t:e}export{sa as a,Qt as b,ca as c,qe as d,la as e,da as f,Bo as g,pa as h,ma as i,ua as j,ga as k,ba as l,fa as m,ya as n,eo as o,ha as p,za as q,Sa as r,xa as s,i as t,l as u,so as v,B as w,nn as x,an as y,Ke as z,Ea as A,Ca as B,Ta as C,_a as D,Na as E,Da as F,Fa as G,Ma as H,Ua as I,La as J,Ba as K,$a as L,qa as M,Ga as N,Wa as O,Ka as P,Ha as Q,Za as R,Xa as S,Ya as T,Va as U,Ja as V,Qa as W,er as X,tr as Y,or as Z,mn as _,nr as $,ar as aa,rr as ba,ir as ca,sr as da,cr as ea,lr as fa,dr as ga,pr as ha,mr as ia,ur as ja,gr as ka,br as la,fr as ma,yr as na,hr as oa,zr as pa,Sr as qa,xr as ra,Ir as sa,kr as ta,jr as ua,Pr as va,Or as wa,Rr as xa,wr as ya,vr as za,Ar as Aa,Er as Ba,Cr as Ca,Tr as Da,_r as Ea,fn as Fa,Nr as Ga,Dr as Ha,Fr as Ia,Mr as Ja,Ur as Ka,Lr as La,Br as Ma,$r as Na,qr as Oa,Gr as Pa,Wr as Qa,Kr as Ra,go as Sa,Hr as Ta,Zr as Ua,Xr as Va,bo as Wa,Yr as Xa,Vr as Ya,Jr as Za,Qr as _a,ti as $a,oi as ab,ni as bb,ai as cb,ri as db,ii as eb,si as fb,ci as gb,li as hb,di as ib,pi as jb,mi as kb,ui as lb,gi as mb,bi as nb,fi as ob,yi as pb,hi as qb,zi as rb,Si as sb,xi as tb,Ii as ub,ki as vb,ji as wb,Pi as xb,Oi as yb,Ri as zb,wi as Ab,vi as Bb,Ai as Cb,Ei as Db,Ci as Eb,Ti as Fb,_i as Gb,Ni as Hb,Di as Ib,Fi as Jb,Mi as Kb,Ui as Lb,Li as Mb,Bi as Nb,$i as Ob,qi as Pb,Gi as Qb,Wi as Rb,Ki as Sb,Hi as Tb,Zi as Ub,Xi as Vb,Yi as Wb,Vi as Xb,Ji as Yb,Qi as Zb,es as _b,ts as $b,os as ac,ns as bc,as as cc,rs as dc,is as ec,ss as fc,cs as gc,ls as hc,ds as ic,Fn as jc,Mn as kc,us as lc,gs as mc,bs as nc,fs as oc,ys as pc,hs as qc,zs as rc,Ss as sc,xs as tc,Is as uc,Ln as vc,ks as wc,Ro as xc,Ms as yc,Us as zc,xe as Ac,Zn as Bc,Xn as Cc,Ys as Dc,Vs as Ec,Bs as Fc,$s as Gc,Gs as Hc,Ie as Ic,Ws as Jc,Co as Kc,ea as Lc,Ks as Mc,ta as Nc,Hs as Oc,Zs as Pc,Eo as Qc};
@@ -1,8 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{p as it,q as vn}from"./chunk-VZVICK7Q.mjs";import{d as kn,h as Fn,m as Pn}from"./chunk-7PY3VQP3.mjs";import{b as gn}from"./chunk-SU65Z2BA.mjs";import{a as Bn,b as $n}from"./chunk-HF6LAK3G.mjs";import{j as wn,k as Rn,l as An,m as Sn,n as En}from"./chunk-HFUDCNU5.mjs";import{a as Tn,b as On}from"./chunk-TQ2TQHTT.mjs";import{d as st}from"./chunk-HFSBDM7B.mjs";import{c as yn,g as Ee,h as ot,j as bn}from"./chunk-OHEOJISY.mjs";import{a as hn}from"./chunk-EADHKH3A.mjs";import{E as te,_ as pn,b as ee,da as mn,q as Ae,r as Se,t as rt}from"./chunk-KIMQQ6JQ.mjs";import{h as nt}from"./chunk-TZE3Y7IQ.mjs";import{b as P}from"./chunk-CA5NAXSU.mjs";import{$ as Kt,Ac as an,Ad as ln,Bc as dn,Bd as et,Cd as cn,Fd as fn,Gd as tt,Id as be,Nd as we,Od as Re,P as zt,Sc as Ze,X as Qt,Z as Ht,_ as pe,aa as Yt,ba as Xt,ca as Jt,da as Zt,fa as me,ga as en,ha as tn,ia as nn,m as qt,pc as rn,rc as on,s as Vt,sc as sn,xd as he,yd as un,zd as ye}from"./chunk-ZQO5PDX5.mjs";import{b as H,e as x,i as fe,k as ge,l as $,s as Je}from"./chunk-WZQEK4WT.mjs";var Eo=/^[A-Za-z][A-Za-z0-9_]{0,79}$/;function Nn(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}function xn(e){return Array.isArray(e)?e.filter(t=>typeof t=="object"&&t):[]}function Cn(e){return typeof e=="string"&&Eo.test(e)?e:void 0}function Mn(e){let t=new Map;for(let r of xn(Nn(e,"variables"))){let o=r.name,i=Cn(r.objectType);typeof o=="string"&&i&&t.set(o.toLowerCase(),i)}let n=[];for(let r of xn(Nn(e,"recordCreates"))){let o=r.inputReference,i=Cn(r.object)??(typeof o=="string"?t.get(o.toLowerCase()):void 0);i&&!n.some(s=>s.toLowerCase()===i.toLowerCase())&&n.push(i)}return n}var In={AccountPartner:["Role"],CampaignMember:["Status"],Case:["Status"],Contract:["Status"],Lead:["Status"],Opportunity:["StageName"],OpportunityPartner:["Role"],Order:["Status"],Partner:["Role"],ServiceAppointment:["Status"],Solution:["Status"],Task:["Priority","Status"],WorkOrder:["Status"],WorkOrderLineItem:["Status"]};function od(e,t){let n=new Map,r=t!==void 0&&Object.prototype.hasOwnProperty.call(In,t)?In[t]:[];for(let o of e){let i=o.type==="multipicklist";if(o.type!=="picklist"&&!i&&!o.picklistValues?.length)continue;let s=(o.type==="combobox"||o.restrictedPicklist===!1)&&!r.includes(o.name);n.set(o.name,{multi:i,restricted:o.restrictedPicklist===!0,required:o.nillable===!1&&o.defaultedOnCreate!==!0,...o.controllerName?{controllerName:o.controllerName}:{},...s?{anyValue:s}:{}})}return n}var To=new Set;function Oo(e,t){let n=new Set(e),r=[],o=new Set,i=(s,a)=>{if(o.has(s))return;let d=t.get(s)?.controllerName;d&&n.has(d)&&a<e.length&&i(d,a+1),!o.has(s)&&(o.add(s),r.push(s))};for(let s of e)i(s,0);return r}function ko(e){return typeof e=="boolean"?String(e):typeof e=="string"&&e!==""?e:void 0}function Fo(e,t){let n=new Map;for(let r of e){let o=t(r),i=n.get(o)??[];i.includes(r)||i.push(r),n.set(o,i)}return[...n]}function Po(e,t,n,r,o,i,s){let a=new Set(o.values),d=a,l,u=r.controllerName?ko(e[r.controllerName]):void 0,f=u===void 0?void 0:o.allowedByControllingValue?.get(u);f&&(d=new Set(o.values.filter(R=>f.has(R))),l=r.controllerName);let g=n.filter(R=>!d.has(R));if(g.length===0)return[];let p=R=>s&&!s.has(R)?"not-in-target":a.has(R)?"controlling-value":"record-type",m,b,w=n.filter(R=>d.has(R));return r.multi&&w.length>0?e[t]=w.join(";"):(o.defaultValue!==null&&d.has(o.defaultValue)?(m=o.defaultValue,b="default"):r.required&&(m=o.values.find(R=>d.has(R)),b=m===void 0?void 0:"first"),m===void 0?delete e[t]:e[t]=m),Fo(g,p).map(([R,O])=>({field:t,reason:R,values:O,recordType:i,...R==="controlling-value"&&l?{controllingField:l}:{},...m!==void 0&&b?{replacedBy:m,replacement:b}:{}}))}function sd(e,t,n,r,o=To){let i=[];for(let s of Oo(Object.keys(e),n)){let a=e[s];if(typeof a!="string"||o.has(s))continue;let d=n.get(s),l=t?.get(s),u=d?.restricted?r?.picklists.get(s):void 0;if(!l&&!u)continue;if(a===""){delete e[s];continue}let f=d?.multi?a.split(";"):[a];if(d&&u&&r){i.push(...Po(e,s,f,d,u,r.recordType,l));continue}if(!l||d?.anyValue)continue;let g=f.filter(m=>!l.has(m));if(g.length===0)continue;let p=f.filter(m=>l.has(m));d?.multi&&p.length>0?e[s]=p.join(";"):delete e[s],i.push({field:s,reason:"not-in-target",values:[...new Set(g)]})}return i}var Bo="012000000000000AAA",Te="Master",Dn="";function id(e,t){return e?.get(typeof t=="string"?t:Dn)}async function $o(e,t,n){try{return{picklists:await e(t,n)}}catch(r){return{error:P(r)}}}var jn=class{constructor(t){this.read=t}read;reads=new Map;said=new Set;async forRows(t){let n=new Map,r=[],{read:o}=this;if(!o)return{byRecordType:n,notes:r};if(t.withoutRecordTypes){let l=[...t.fields].filter(([f,g])=>g.restricted&&g.controllerName&&t.written(f)).map(([f])=>f),u=new Set(l.filter(f=>t.rows.some(g=>typeof g[f]=="string"&&g[f]!=="")));if(u.size>0){let f={targetId:Bo,developerName:Te},g=await this.readFor(o,t.objectApiName,f.targetId);this.keep(n,r,t.objectApiName,Dn,u,f,g)}return{byRecordType:n,notes:r}}if(!t.recordTypeMappings||!t.written("RecordTypeId"))return{byRecordType:n,notes:r};let i=[...t.fields].filter(([l,u])=>u.restricted&&t.written(l)).map(([l])=>l);if(i.length===0)return{byRecordType:n,notes:r};let s=new Map(t.recordTypeMappings.map(l=>[l.sourceId,l])),a=new Map;for(let l of t.rows){let u=l.RecordTypeId;if(!(typeof u!="string"||!s.has(u)))for(let f of i){let g=l[f];if(typeof g!="string"||g==="")continue;let p=a.get(u)??new Set;p.add(f),a.set(u,p)}}let d=await Promise.all([...a].map(async([l,u])=>{let f=s.get(l);return{sourceId:l,fields:u,target:f,answer:await this.readFor(o,t.objectApiName,f.targetId)}}));for(let{sourceId:l,fields:u,target:f,answer:g}of d)this.keep(n,r,t.objectApiName,l,u,f,g);return{byRecordType:n,notes:r}}readFor(t,n,r){let o=`${n}|${r}`,i=this.reads.get(o);return i||(i=$o(t,n,r),this.reads.set(o,i)),i}keep(t,n,r,o,i,s,a){let d=`${r}|${s.targetId}`;if("error"in a){this.said.has(d)||(this.said.add(d),n.push({recordType:s.developerName,error:a.error}));return}t.set(o,{recordType:s.developerName,picklists:a.picklists});let l=[...i].filter(u=>!a.picklists.has(u)&&!this.said.has(`${d}|${u}`));if(l.length!==0){for(let u of l)this.said.add(`${d}|${u}`);n.push({recordType:s.developerName,leftOut:l})}}};function ad(e){return e.error!==void 0?{recordSummary:`(picklist values of record type ${e.recordType} could not be read \u2014 checked against each field's values)`,messages:[e.error]}:{recordSummary:`(picklist values of record type ${e.recordType} not given for ${(e.leftOut??[]).join(", ")} \u2014 checked against each field's values)`,messages:[`The target's answer for record type ${e.recordType} leaves out ${(e.leftOut??[]).join(", ")}.`]}}var _n=class{entries=new Map;get size(){return this.entries.size}add(t,n){for(let r of n){let o=[t,r.field,r.reason,r.recordType??"",r.controllingField??"",r.replacement??"",r.replacedBy??""].join("\0"),i=this.entries.get(o);if(i){i.entry.rows++;for(let s of r.values)i.values.add(s);continue}this.entries.set(o,{entry:{objectApiName:t,field:r.field,reason:r.reason,values:[],rows:1,...r.recordType!==void 0?{recordType:r.recordType}:{},...r.controllingField!==void 0?{controllingField:r.controllingField}:{},...r.replacedBy!==void 0?{replacedBy:r.replacedBy}:{},...r.replacement!==void 0?{replacement:r.replacement}:{}},values:new Set(r.values)})}}list(){return[...this.entries.values()].map(({entry:t,values:n})=>({...t,values:[...n].sort()}))}};function vo(e){let t=`${e.rows} row${e.rows===1?"":"s"}`,n=e.values.map(i=>`"${i}"`).join(", "),r=e.reason==="not-in-target"?"not a value of the field in the target":e.reason==="record-type"?`not allowed for record type ${e.recordType??""}`:`not allowed with the value of ${e.controllingField??"its controlling field"}`,o=e.replacedBy===void 0?"left out":e.replacement==="first"?`replaced by "${e.replacedBy}", the first value record type ${e.recordType??""} allows: the field is required and has no default there`:`replaced by "${e.replacedBy}", the default of record type ${e.recordType??""}`;return`${e.field} on ${t}: ${n} ${r}, ${o}`}function dd(e){return e.length===0?"":`, picklist values not written as read: ${e.map(vo).join("; ")}`}function pd(e){let t={...e.picklistValueMappings?.length?{picklistValueMappings:e.picklistValueMappings}:{},...e.recordTypeMappings?.length?{recordTypeMappings:e.recordTypeMappings}:{},...e.defaultValues?.length?{defaultValues:e.defaultValues}:{},...e.truncateFields?.length?{truncateFields:e.truncateFields}:{},...e.ignoredGaps?.length?{ignoredGaps:e.ignoredGaps}:{},...e.skippedRows?.length?{skippedRows:e.skippedRows}:{}};return Object.keys(t).length>0?t:void 0}var No=new Set(["picklist_value_refused","picklist_value_absent","currency_inactive"]);function Un(e){let t=zt(e.gapId);return t?t.objectApiName!==e.object?{ignored:`the gap is of ${t.objectApiName}, not of ${e.object}`}:t.field===void 0||t.value===void 0?{ignored:"the gap names no field and value whose rows to hold back"}:No.has(t.kind)?{held:{field:t.field,...t.recordType!==void 0?{recordType:t.recordType}:{},value:t.value}}:{ignored:`a ${t.kind} gap does not offer it: its rows are not exactly those holding its value`}:{ignored:"not the id of a gap"}}function md(e){let t=Un(e);return"ignored"in t?t.ignored:void 0}function Ln(e,t,n){if(e===void 0)return!0;let r=t??Te;if(e===r)return!0;let o=Ee(e),i=Ee(r);if(o.namespacePrefix!==void 0||i.namespacePrefix===void 0||i.developerName!==e)return!1;if(n===void 0)return!0;let s=ot(e,n,a=>a);return"found"in s&&s.found.namespacePrefix===i.namespacePrefix}function xo(e){return e==null||e===""}var Wn=class{entries=new Map;get size(){return this.entries.size}add(t,n=1){let r=[t.kind,t.objectApiName,t.field??"",t.recordType??"",t.from??"",t.to??""].join("\0"),o=this.entries.get(r);if(o){o.rows+=n;return}this.entries.set(r,{...t,rows:n})}list(){return[...this.entries.values()].map(t=>({...t}))}},Oe=class{picklists=new Map;defaults=new Map;truncated=new Map;skipped=new Map;ignoredGaps;constructor(t){for(let n of t?.picklistValueMappings??[]){let r=this.picklists.get(n.object)??[];r.push(n),this.picklists.set(n.object,r)}for(let n of t?.defaultValues??[]){let r=this.defaults.get(n.object)??[];r.push(n),this.defaults.set(n.object,r)}for(let{object:n,field:r}of t?.truncateFields??[]){let o=this.truncated.get(n)??new Set;o.add(r),this.truncated.set(n,o)}this.ignoredGaps=new Set(t?.ignoredGaps??[]);for(let n of t?.skippedRows??[]){let r=Un(n);if(!("held"in r))continue;let o=this.skipped.get(n.object)??[];o.push(r.held),this.skipped.set(n.object,o)}}skipsRowsOf(t){return this.skipped.has(t)}namesARecordTypeBare(t){return[...(this.picklists.get(t)??[]).map(r=>r.recordType),...(this.skipped.get(t)??[]).map(r=>r.recordType)].some(r=>r!==void 0&&r!==Te&&Ee(r).namespacePrefix===void 0)}holdsBack(t,n,r,o,i){for(let s of this.skipped.get(t)??[]){if(!Ln(s.recordType,r,i))continue;let a=n(s.field);if(!(typeof a!="string"||!a.split(";").includes(s.value)))return o.add({kind:"skip_rows",objectApiName:t,field:s.field,...s.recordType!==void 0?{recordType:s.recordType}:{},from:s.value}),!0}return!1}changesRowsOf(t){return this.picklists.has(t)||this.defaults.has(t)}defaultOf(t,n){let r=this.defaults.get(t)?.find(o=>o.field===n);return r===void 0?void 0:String(r.value)}applyToRow(t,n,r,o,i){for(let s of this.picklists.get(t)??[]){if(!Ln(s.recordType,r,i))continue;let a=n[s.field];if(typeof a!="string"||a==="")continue;let d=a.split(";");if(!d.includes(s.from))continue;let l=d.flatMap(u=>u!==s.from?[u]:s.to===null?[]:[s.to]);l.length===0?delete n[s.field]:n[s.field]=[...new Set(l)].join(";"),o.add({kind:s.to===null?"leave_empty":"map_value",objectApiName:t,field:s.field,...s.recordType!==void 0?{recordType:s.recordType}:{},from:s.from,...s.to!==null?{to:s.to}:{}})}for(let{field:s,value:a}of this.defaults.get(t)??[])xo(n[s])&&(n[s]=a,o.add({kind:"set_default",objectApiName:t,field:s,to:String(a)}))}truncate(t,n,r,o){for(let i of this.truncated.get(t)??[]){let s=n[i],a=r.get(i);typeof s!="string"||a===void 0||a<=0||s.length<=a||(n[i]=s.slice(0,a),o.add({kind:"truncate",objectApiName:t,field:i}))}}truncatedFieldsOf(t){return this.truncated.get(t)??new Set}};function hd(e,t){let n=new Map(t.map(s=>[s.objectApiName,s])),r=[],o=new Map,i=[];for(let s of e){let a=n.get(s.object),d=Gn(s.object,s.from,a?.source??[],"the source");if("reason"in d){i.push({decision:s,reason:d.reason});continue}if(s.to===null){o.set(d.type.recordTypeId,s);continue}let l=Gn(s.object,s.to,a?.target??[],"the target");if("reason"in l){i.push({decision:s,reason:l.reason});continue}o.set(d.type.recordTypeId,s),r.push({sourceId:d.type.recordTypeId,targetId:l.type.recordTypeId,developerName:l.type.developerName})}return{mappings:r,bySource:o,unresolved:i}}function Gn(e,t,n,r){let o=ot(t,n.filter(i=>!i.master),st);if("found"in o)return{type:o.found};if("ambiguous"in o){let i=o.ambiguous.map(st),s=i.find(a=>a.namespacePrefix);return{reason:bn(e,t,r,i)+(s?"; a package's is named with its namespace: "+yn(s.namespacePrefix,s.developerName):"")}}return{reason:`${r} has no ${e} record type named ${t}`}}function yd(e,t){return t.bySource.size===0?e?[...e]:void 0:[...(e??[]).filter(n=>!t.bySource.has(n.sourceId)),...t.mappings]}import{createHash as $i}from"node:crypto";import{createHash as jo}from"node:crypto";var qn="lineage:runs",Co="lineage";function Vn(e){let t=e.objects.filter(s=>s.records>0);if(t.length===0)return null;let n="source",r="target",o=[{id:n,type:"source",label:e.source.label,origin:e.source.origin,...e.source.orgId?{orgId:e.source.orgId}:{}}],i=[];for(let s of t){let a=`object:${s.objectApiName}`;o.push({id:a,type:"object",label:s.objectApiName,objectApiName:s.objectApiName,recordCount:s.records}),i.push({sourceId:n,targetId:a}),i.push({sourceId:a,targetId:r,recordCount:s.records})}return o.push({id:r,type:"destination",label:e.target.label,orgId:e.target.orgId,origin:"org"}),{nodes:o,edges:i,operationId:e.operationId,generatedAt:e.generatedAt,module:e.module,action:e.action}}var ke=class{constructor(t,n=100){this.configStore=t;this.limit=n}configStore;limit;save(t){let n=this.read().filter(r=>r.operationId!==t.operationId);n.push(t),this.configStore.set(qn,n.slice(-this.limit),Co)}get(t){let n=this.read();return t===void 0?n[n.length-1]??null:n.find(r=>r.operationId===t)??null}runs(){return this.read().reverse().map(t=>({operationId:t.operationId,generatedAt:t.generatedAt,...t.module?{module:t.module}:{},...t.action?{action:t.action}:{},...Mo(t)}))}read(){let t=this.configStore.get(qn);return Array.isArray(t)?t.filter(Io):[]}};function Mo(e){let t=e.nodes.find(n=>n.type==="destination");return t?{targetLabel:t.label}:{}}function Io(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.operationId=="string"&&typeof t.generatedAt=="string"&&Array.isArray(t.nodes)&&Array.isArray(t.edges)}var _o=100,zn="audit:trail",Do="audit",at=class{constructor(t,n=Vt){this.configStore=t;this.limit=n}configStore;limit;append(t){let n=this.read();n.push(t),this.configStore.set(zn,n.slice(-this.limit),Do)}list(t={}){let n=this.read().reverse(),r=n.filter(s=>(t.module===void 0||s.module===t.module)&&(t.orgId===void 0||s.orgId===t.orgId)),o=t.offset??0,i=t.limit??_o;return{entries:r.slice(o,o+i),total:r.length,offset:o,facets:Lo(n)}}read(){let t=this.configStore.get(zn);return Array.isArray(t)?t.filter(Wo):[]}};function Lo(e){let t=new Set,n=new Map;for(let r of e)t.add(r.module),r.orgId!==void 0&&!n.has(r.orgId)&&n.set(r.orgId,r.orgAlias);return{modules:[...t].sort(),orgs:[...n].map(([r,o])=>o?{orgId:r,orgAlias:o}:{orgId:r})}}function Wo(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.id=="string"&&typeof t.action=="string"&&typeof t.module=="string"&&typeof t.timestamp=="string"}var Td="ABORTED_BEFORE_START";function Go(e){let t=e?.trim().toLowerCase();if(t)return`sha256:${jo("sha256").update(t).digest("hex").slice(0,12)}`}function Od(e,t,n=new Date){try{let r=e.services?.getSandforgeSetting?.("safety.auditLogging",!0)!==!1;if(!r&&t.outcome==="stopped"&&t.code===void 0)return;let o=n.toISOString(),i=e.orgManager.getOrg(t.orgId),s=i?Ze(i):void 0,a=Go(i?.username),d=t.source?.origin==="org"?t.source.orgId:void 0,l=d!==void 0?e.orgManager.getOrg(d):void 0,u=l?Ze(l):void 0,f=t.objects??[];if(new at(e.configStore).append({id:crypto.randomUUID(),action:t.action,module:t.module,orgId:t.orgId,...s?{orgAlias:s}:{},...d!==void 0?{sourceOrgId:d}:{},...u?{sourceOrgAlias:u}:{},operationId:t.operationId,outcome:t.outcome,...r&&t.guard?{guard:t.guard}:{},objects:[...f],...t.leftBy?{leftBy:t.leftBy}:{},...a?{userId:a}:{},...t.context?{context:t.context}:{},...t.verdict?{verdict:t.verdict}:{},...t.muted?{muted:t.muted}:{},...t.checkpointId?{checkpointId:t.checkpointId}:{},...t.beforeRun?{beforeRun:{...t.beforeRun}}:{},...t.fit?{fit:{...t.fit}}:{},details:{...t.details,...t.code?{code:t.code}:{}},timestamp:o}),!t.source)return;let g=Vn({operationId:t.operationId,module:t.module,action:t.action,source:t.source.origin==="org"?{origin:"org",orgId:t.source.orgId,label:u??t.source.orgId}:{origin:t.source.origin,label:t.source.label??""},target:{label:s??t.orgId,orgId:t.orgId},objects:Uo(f,t.carried),generatedAt:o});g&&new ke(e.configStore).save(g)}catch(r){e.log(`[WARN] audit trail: run ${t.operationId} was not recorded \u2014 ${P(r)}`)}}function Uo(e,t){return t?Object.entries(t).map(([n,r])=>({objectApiName:n,records:r})):e.map(n=>({objectApiName:n.objectApiName,records:n.created+n.updated+(n.upserted??0)}))}function Qn(e){return{objectApiName:e,created:0,updated:0,deleted:0,failed:0}}var qo="__pass2__";function Hn(e){let t=e.errors??[],n=t.some(i=>i.skipped===!0),r=t.some(i=>i.objectApiName===qo&&i.failedCount>0);return e.failedCount===0&&e.failedReads.length===0&&!n&&!r?"success":e.successCount+e.updatedCount+e.linkedCount+(e.wouldInsertCount??0)>0?"partial":"failure"}function Fd(e,t,n){return{forgeId:`forge-${Date.now()}`,status:n.status,graph:t,duration:Date.now()-n.startedAt,timestamp:new Date().toISOString(),idRemapCount:e.remapCount,idRemapTable:e.remapTable,idRemapExisting:e.existingSourceIds,...e.withTheirRecordSourceIds?{idRemapWithTheirRecord:e.withTheirRecordSourceIds}:{},...e.withTheirRecordCount!==void 0&&e.withTheirRecordCount>0?{withTheirRecordCount:e.withTheirRecordCount}:{},...e.linkedToCreatedCount!==void 0&&e.linkedToCreatedCount>0?{linkedToCreatedCount:e.linkedToCreatedCount}:{},createdCount:e.successCount,...e.updatedCount>0?{updatedCount:e.updatedCount}:{},linkedExistingCount:e.linkedCount,existingRecords:e.existingRecords,idRemapByObject:e.remapByObject,idRemapCreated:e.createdByObject,readByObject:e.readByObject,failedReads:e.failedReads,errors:e.errors,truncatedObjects:e.truncatedObjects,...e.cappedObjects?{cappedObjects:e.cappedObjects}:{},...e.fieldExclusionsUnmatched?{fieldExclusionsUnmatched:e.fieldExclusionsUnmatched}:{},...e.orphanParentsCapped?{orphanParentsCapped:e.orphanParentsCapped}:{},...e.files?{files:e.files}:{},...e.fileContentFieldsLeftOut?{fileContentFieldsLeftOut:e.fileContentFieldsLeftOut}:{},...e.encryptedFieldsLeftOut?{encryptedFieldsLeftOut:e.encryptedFieldsLeftOut}:{},...e.picklistValuesChanged?{picklistValuesChanged:e.picklistValuesChanged}:{},...e.currenciesReplaced?{currenciesReplaced:e.currenciesReplaced}:{},...e.recordTypesGiven?{recordTypesGiven:e.recordTypesGiven}:{},...e.writtenWithoutFields?{writtenWithoutFields:e.writtenWithoutFields}:{},...e.lookupsLeftEmptyByFilter?{lookupsLeftEmptyByFilter:e.lookupsLeftEmptyByFilter}:{},...e.contactPoints?{contactPoints:e.contactPoints}:{},...e.writtenBetween?{writtenBetween:e.writtenBetween}:{},...e.apiCalls!==void 0?{apiCalls:e.apiCalls}:{},...e.dryRun?{dryRun:!0,wouldInsertCount:e.wouldInsertCount}:{},...e.gaps?{gaps:e.gaps}:{},...e.decisionsApplied?{decisionsApplied:e.decisionsApplied}:{},...e.mayHaveBeenWritten?{mayHaveBeenWritten:e.mayHaveBeenWritten}:{},...e.remapInJournal?{remapInJournal:!0}:{},...e.sample?{sample:e.sample}:{},...e.roots?{roots:e.roots}:{},...e.reads?{reads:e.reads}:{}}}var Kn="RUN_CANCELLED";function vd(e){return{idRemapByObject:e.remapByObject,errors:e.errors,notSentByObject:e.notSentByObject,writtenWithoutFields:e.writtenWithoutFields,mayHaveBeenWritten:e.mayHaveBeenWritten}}function Nd(e){let t=new Map,n=r=>{let o=t.get(r)??Qn(r);return t.set(r,o),o};for(let r of e.idRemapByObject??[]){let o=n(r.objectApiName);o.created+=r.created,o.updated+=r.updated??0}for(let r of e.errors??[]){if(r.objectApiName.startsWith("__")||r.referenceData===!0||r.stage==="scope"&&r.failedCount===0&&r.skipped!==!0)continue;let o=n(r.objectApiName);o.failed+=r.failedCount,r.skipped===!0&&(o.skipped=r.failedCount>0?"counted":"uncounted")}for(let r of e.notSentByObject??[]){let o=n(r.objectApiName);o.notSent=(o.notSent??0)+r.notSent}for(let r of e.writtenWithoutFields??[]){let o=n(r.objectApiName);o.writtenWithoutFields=(o.writtenWithoutFields??0)+r.rows}for(let{objectApiName:r,sourceIds:o}of e.mayHaveBeenWritten??[]){let i=n(r);i.mayHaveBeenWritten=(i.mayHaveBeenWritten??0)+o.length}return[...t.values()]}function xd(e,t){return t.some(r=>r.created+r.updated>0)?"cancelled":(e?Hn(e):"success")==="success"?"stopped":"cancelled"}function Cd(e){return e?{details:{contactPoints:e.neutralized?"neutralized":"kept",contactPointFields:e.fields.length,contactPointValues:e.values}}:{}}function Md(e){return Object.fromEntries((e.idRemapByObject??[]).map(t=>[t.objectApiName,t.created+t.linked+(t.updated??0)]))}var zd=2e3,Qd=1e4,zo=Qt;function Hd(e,t,n=zo){let r=t!==void 0&&t>0?Math.floor(t):void 0;return r!==void 0&&r<=n?[]:e.nodes.filter(o=>o.included&&o.recordCountUnknown!==!0).map(o=>({objectApiName:o.objectApiName,rows:r===void 0?o.recordCount:Math.min(o.recordCount,r)})).filter(o=>o.rows>n).sort((o,i)=>i.rows-o.rows)}var ir=.8,se=1024,Pe=2*se,ar=4*se,Qo=8*se,Ho=1*se,Ko=4*se,Yo=255,Xo=/__kav$/i,Jo=new Map([ee,Ae,Se,"Campaign","CampaignMember"].map(e=>[e.toLowerCase(),e]));function Be(e){return Jo.get(e.toLowerCase())??e}function Yn(e,t=0){let n=0;for(let r of Object.values(e))typeof r=="string"&&r.length>t&&(n+=Buffer.byteLength(r,"utf8"));return n}function ut(e,t){let n=Be(e);return n===ee?Yn(t):n===Ae?rt(t)?ar:Pe:n===Se&&rt(t)?0:n==="Campaign"?Qo:n==="CampaignMember"?Ho:Xo.test(e)?Ko+Yn(t,Yo):Pe}function Zo(e,t){let n=Math.min(t.personAccounts??0,t.rows),r=t.rows-n,o=Be(e);return o===Ae?r*Pe+n*ar:o===Se?r*Pe:r*ut(e,{})}function es(e){let t=e.map(({objectApiName:m,rows:b,counted:w,mayAdd:R=0,mayBeByThePlatform:O})=>{let T={rows:R,storageBytes:R*ut(m,{}),...R>0?{mayAdd:R}:{},...O&&O.rows>0?{mayBeByThePlatform:O}:{}};return w?{objectApiName:m,...T,rows:w.rows+T.rows,storageBytes:Zo(m,w)+T.storageBytes}:{objectApiName:m,...T,rows:b.length+T.rows,storageBytes:b.reduce((M,E)=>M+ut(m,E),0)+T.storageBytes}}).filter(({rows:m})=>m>0).sort((m,b)=>b.rows-m.rows||m.objectApiName.localeCompare(b.objectApiName)),n=e.reduce((m,b)=>m+(b.leftOut?.writtenBefore??0),0),r=e.filter(m=>(m.leftOut?.heldBack??0)>0).map(({objectApiName:m,leftOut:b})=>({objectApiName:m,rows:b?.heldBack??0})),o=e.filter(m=>(m.leftOut?.byThePlatform??0)>0).map(({objectApiName:m,leftOut:b})=>({objectApiName:m,rows:b?.byThePlatform??0})),i=e.flatMap(({objectApiName:m,leftOut:b})=>b?.linkedByValue&&b.linkedByValue.rows>0?[{objectApiName:m,...b.linkedByValue}]:[]),s=m=>e.filter(b=>(b.leftOut?.[m]??0)>0).map(({objectApiName:b,leftOut:w})=>({objectApiName:b,rows:w?.[m]??0})),a=s("recordTypeNotInTarget"),d=s("withoutParent"),l=s("noParentInSource"),u=s("outsideFilter"),f=s("linkedToTarget"),g=s("currencyReplaced"),p=e.flatMap(({objectApiName:m,leftEmpty:b=[]})=>b.filter(({rows:w})=>w>0).map(({field:w,rows:R})=>({objectApiName:m,field:w,rows:R})));return{objects:t,...p.length>0?{leftEmpty:p}:{},totalRows:t.reduce((m,b)=>m+b.rows,0),storageBytes:t.reduce((m,b)=>m+b.storageBytes,0),...n>0||r.length>0||a.length>0||o.length>0||i.length>0||d.length>0||l.length>0||u.length>0||f.length>0||g.length>0?{leftOut:{writtenBefore:n,heldBack:r,...a.length>0?{recordTypeNotInTarget:a}:{},...o.length>0?{byThePlatform:o}:{},...i.length>0?{linkedByValue:i}:{},...d.length>0?{withoutParent:d}:{},...l.length>0?{noParentInSource:l}:{},...u.length>0?{outsideFilter:u}:{},...f.length>0?{linkedToTarget:f}:{},...g.length>0?{currencyReplaced:g}:{}}}:{}}}function Kd(e){return JSON.stringify([e.sourceOrgId,e.targetOrgId,e.inputMode,e.recordId??null,e.soqlQuery??null,e.templateId??null,e.aiPrompt??null,...e.queryScope==="records"?["records"]:[]])}var ts=16,Xn=class{kept=new Map;note(t,n,r=Date.now()){this.kept.delete(t),this.kept.set(t,{at:r,total:n.totalRows,objects:n.objects.map(({objectApiName:o,rows:i})=>({objectApiName:o,rows:i}))});for(let o of this.kept.keys()){if(this.kept.size<=ts)break;this.kept.delete(o)}}of(t){return this.kept.get(t)}},ns=500;function rs(e,t){return e>2*t||e-t>ns}function Yd(e,t,n=Date.now()){return{minutesBefore:Math.max(1,Math.ceil((n-e.at)/6e4)),total:e.total,objects:e.objects.map(({objectApiName:r,rows:o})=>({objectApiName:r,rows:o})),...rs(t,e.total)?{farAbove:!0}:{}}}function Xd(e){let t=e.objects.reduce((n,r)=>n+(r.mayAdd??0),0);return t>0?{pricesForLines:t}:{}}function Jd(e){let t=e.objects.find(n=>n.mayBeByThePlatform)?.mayBeByThePlatform;return!t||t.rows<=0?{}:{rolesMayBeByThePlatform:{rows:t.rows,...t.before===!0?{before:!0}:{}}}}var Fe=$({Max:x(),Remaining:x()}).loose(),os=$({DataStorageMB:Fe,DailyApiRequests:Fe.optional(),DailyBulkApiBatches:Fe.optional(),FileStorageMB:Fe.optional()}).loose(),ss=$({DailyApiRequests:$({Max:x(),Remaining:x()}).loose()}).loose(),is="the org does not tell this user its daily API requests";function dr(e,t,n){if(e!==null&&typeof e=="object"&&!(t in e))throw new Error(n)}async function as(e){let t=await e.request({method:"GET",url:"/limits"});dr(t,"DataStorageMB",qt);let n=os.parse(t);return{maxMB:n.DataStorageMB.Max,remainingMB:n.DataStorageMB.Remaining,...n.DailyApiRequests?{dailyApiRequests:{max:n.DailyApiRequests.Max,remaining:n.DailyApiRequests.Remaining}}:{},...n.DailyBulkApiBatches?{dailyBulkApiBatches:{max:n.DailyBulkApiBatches.Max,remaining:n.DailyBulkApiBatches.Remaining}}:{},...n.FileStorageMB?{fileStorage:{maxMB:n.FileStorageMB.Max,remainingMB:n.FileStorageMB.Remaining}}:{}}}async function Jn(e){let t=await e.request({method:"GET",url:"/limits"});dr(t,"DailyApiRequests",is);let n=ss.parse(t);return{max:n.DailyApiRequests.Max,remaining:n.DailyApiRequests.Remaining}}var lt=200,ur=2e3,ds=.1;function us(e){return e.reduce((t,{rows:n,bulk:r,readRows:o,perCall:i})=>{let s=Math.min(lt,Math.max(1,i??lt)),a=n<=0?0:r?En(n):Math.ceil(n/s),d=o&&o>0?Math.ceil(o/ur):0;return t+a+d},0)}var pt=["checkpoint","mute","readBack","deliverability","fit"],ls={checkpoint:"for the checkpoint taken first",mute:"to assign and take back the permission sets that mute the target's automation",readBack:"to read back the record types the target gave",deliverability:"to read whether the target delivers its emails",fit:"to fit the run to the storage"};function cs(e){return pt.reduce((t,n)=>t+Math.max(0,e[n]??0),e.run)}function fs(e){return pt.some(t=>(e[t]??0)>0)?{...e}:void 0}function dt(e,t){let n=typeof e=="number"?void 0:fs(e),r=typeof e=="number"?e:cs(e),o=n?{parts:n}:{};if(!t)return{verdict:"unread",estimate:r,unread:"the limits the org answered list no DailyApiRequests",...o};if("unread"in t)return{verdict:"unread",estimate:r,unread:t.unread,...o};let{max:i,remaining:s}=t;return{verdict:r>s?"exceeds":s-r<ds*i?"near":"fits",estimate:r,max:i,remaining:s,...o}}function gs(e){if(!e)return"";let t=pt.filter(n=>(e[n]??0)>0).map((n,r)=>`${e[n]}${r===0?" of them":""} ${ls[n]}`);return t.length>0?` (${t.join(", ")})`:""}var ne="API_BUDGET_EXCEEDED";function ps(e,t,n){if(e.verdict==="exceeds")return`The run takes about ${e.estimate} API requests${gs(e.parts)}, and ${t} has ${e.remaining} of its ${e.max} daily requests left: it would stop part way through, its records refused with REQUEST_LIMIT_EXCEEDED. Run it once the org has requests to spare \u2014 the limit is counted over the last 24 hours \u2014 or write fewer records. `+(n?`${n} `:"")+"Nothing was written."}function ms(e){return e.verdict==="near"?{apiRequests:{estimate:e.estimate,remaining:e.remaining,max:e.max,...e.parts?{parts:{...e.parts}}:{}}}:{}}var $e="CHECKPOINT_REFUSED";function hs(e){return e?{checkpoint:e.estimate.apiRequests}:{}}function ys(e){let t=e?.refusal;if(t!==void 0)return{code:$e,message:it(t),refusal:t}}var bs="The run was stopped while it took the checkpoint first: nothing of it was kept, and nothing was written.";async function Zd(e){let t;try{t=await e()}catch(n){return{stop:{code:$e,message:vn(n)}}}return t.taken?{checkpoint:t.checkpoint}:"stopped"in t?{stop:{code:Kn,message:bs}}:{stop:{code:$e,message:it(t.refusal),refusal:t.refusal}}}var Zn=1e4,ws=1e4,Rs=.01;function As(e,t,n){return t<2e3||Bn.has(e)||(n??$n).has(e)}function ve(e,t,n){if(t<=0)return{jobs:[],rest:0};if(As(e,t,n.restOnly))return{jobs:[],rest:t};let r=[];for(let o=t;o>0;o-=Zn){let i=Math.min(o,Zn);if(i<2e3)return{jobs:r,rest:i};r.push(i)}return{jobs:r,rest:0}}function Ss(e){return Rn({stateReads:Sn(e,wn,"save")})}function Es(e,t,n){let{jobs:r,rest:o}=ve(e,t,n);return r.reduce((i,s)=>i+Ss(s),0)+Math.ceil(o/lt)}var Ts=4,Os=3;function ks(e){let t=new Set(e.updatedAfterInsert??[]),n=new Map((e.plan.leftOut?.linkedByValue??[]).map(({objectApiName:d,rows:l})=>[d,l])),r=[...e.plan.objects.map(({objectApiName:d,rows:l})=>({objectApiName:d,rows:l+(n.get(d)??0)})),...[...n].filter(([d])=>!e.plan.objects.some(l=>l.objectApiName===d)).map(([d,l])=>({objectApiName:d,rows:l}))],o=e.plan.objects.filter(({objectApiName:d})=>t.has(d)).map(({objectApiName:d,rows:l})=>({objectApiName:d,rows:l})),{bulk:i}=e,s=e.files!==void 0&&e.files>0?e.files:0,a=i?Ts*r.filter(({rows:d})=>d>0).length:0;return{run:(i?[...r,...o].reduce((d,{objectApiName:l,rows:u})=>d+Es(l,u,i),0):us([...r,...o]))+s+a+Math.max(0,e.sentBefore??0),...hs(e.checkpoint),...e.mute!==void 0&&e.mute>0?{mute:e.mute}:{},...e.readBack!==void 0&&e.readBack>0?{readBack:e.readBack}:{},...e.deliverability!==void 0&&e.deliverability>0?{deliverability:e.deliverability}:{}}}var Fs=200;function Ps(e){let t={...e.measures.restOnly?{restOnly:e.measures.restOnly}:{}},n=new Set(e.updatedAfterInsert??[]),r=e.plan.objects.map(({objectApiName:a,rows:d})=>({objectApiName:a,rows:d,writes:ve(a,d,t),updates:n.has(a)?ve(a,d,t):void 0})),o=r.flatMap(({writes:a,updates:d})=>d?[a,d]:[a]),i=e.measures.files,s=i&&"count"in i&&i.count>0?i.count:0;return{objects:r.map(({objectApiName:a,rows:d,writes:l})=>({objectApiName:a,rows:d,jobs:l.jobs.length})),sourceRequests:(e.measures.sourceReads??r.reduce((a,{rows:d})=>a+Math.ceil(Math.max(0,d)/ur),0)+s+Math.ceil(s/Fs))+Os*r.filter(({rows:a})=>a>0).length+(e.sourceSentBefore===void 0?Math.max(0,e.measures.heldReads??0):Math.max(0,e.sourceSentBefore)),bulkBatches:o.reduce((a,{jobs:d})=>a+d.reduce((l,u)=>l+Math.ceil(u/ws),0),0),durationSeconds:o.reduce((a,{jobs:d,rest:l})=>a+d.reduce((u,f)=>u+An(f,"save"),0)+l*Rs,0),restObjects:r.filter(({rows:a,writes:d})=>a>0&&d.jobs.length===0).map(({objectApiName:a})=>a)}}var Bs="the limits the org answered list no DailyBulkApiBatches";function $s(e,t){if(e.verdict==="exceeds")return`The run writes through Bulk API jobs that take about ${e.estimate} of the daily Bulk API batches, and ${t} has ${e.remaining} of its ${e.max} left: its jobs would be refused part way through. Run it once the org has batches to spare \u2014 the limit is counted over the last 24 hours, and Bulk API 1.0 shares it \u2014 or leave objects out. Nothing was written.`}function vs(e,t){if(e.verdict==="exceeds")return`The run reads the source records in about ${e.estimate} API requests, and ${t} has ${e.remaining} of its ${e.max} daily requests left: the reads would stop part way through, and the org's own integrations with them. Run it once the org has requests to spare \u2014 the limit is counted over the last 24 hours \u2014 or leave objects out. Nothing was written.`}function Ns(e,t){if(e.verdict==="exceeds")return`The files to copy take about ${L(e.estimateMB)} MB of file storage, and ${t} has ${e.remainingMB} MB left of ${e.maxMB} MB: leave out the objects whose files take it, turn the copy of files off on Review, or free file storage in ${t}. Nothing was written.`}function xs(e,t){return`A clone of the whole org reads a few objects whole, and ${e.map(({objectApiName:r,rows:o})=>`${r} (${o} rows)`).join(", ")} ${e.length===1?"holds":"hold"} more than the ${t} rows of one object the sandforge.forge.maxRecordsPerObject setting lets a run hold at once: raise the setting or leave the object out on Review. Nothing was written.`}var Cs=200;function Ms(e){if(!e||e.length===0)return;let t=Math.min(...e.map(r=>r.bound)),n=e.map(({objectApiName:r,rows:o})=>({objectApiName:r,rows:o}));return{code:"READ_BOUND_EXCEEDED",message:xs(n,t),readBound:{bound:t,objects:n.slice(0,Cs)}}}var lr="FILES_UNREAD",cr="FILE_STORAGE_UNREAD";function Is(e,t,n){if(!e)return{};if("unmeasured"in e)return{files:{unmeasured:!0},stop:{code:lr,message:`The source would neither sum nor list its files, so what they take of the file storage ${n} has left is not known: turn the copy of files off on Review, or run it again once the source answers. Nothing was written.`}};if(e.count<=0)return{};let r=fr({storageBytes:e.bytes},"unread"in t?t:t.fileStorage??{unread:"the limits the org answered list no FileStorageMB"});if(r.verdict==="unread")return{files:{count:e.count,check:r},stop:{code:cr,message:`The file storage ${n} has left could not be read (${r.unread}), so the ${e.count} files to copy could not be checked against it: turn the copy of files off on Review, or run it again once the org answers. Nothing was written.`}};let o=Ns(r,n);return{files:{count:e.count,check:r},...o!==void 0&&r.verdict==="exceeds"?{stop:{code:"STORAGE_EXCEEDED",message:o,storage:{estimateMB:Number(L(r.estimateMB)),remainingMB:r.remainingMB,kind:"files"}}}:{}}}function js(e){let t=e.wholeOrg,n=t?.measures.files,r=dt(ks({...e,...t?{bulk:t.measures.restOnly?{restOnly:t.measures.restOnly}:{},...n&&"count"in n?{files:n.count}:{}}:{}}),e.budget),o=ps(r,e.target),i=[],s=ys(e.checkpoint);s&&i.push(s),o!==void 0&&i.push({code:ne,message:o,...t&&r.verdict==="exceeds"?{api:{kind:"requests",org:"target",estimate:r.estimate,remaining:r.remaining}}:{}});let a;if(t){let f=Ps({...e,measures:t.measures,...t.sourceSentBefore!==void 0?{sourceSentBefore:t.sourceSentBefore}:{}}),g=f.bulkBatches>0?dt(f.bulkBatches,t.bulkBatches??{unread:Bs}):void 0,p=g&&$s(g,e.target);p!==void 0&&g?.verdict==="exceeds"&&i.push({code:ne,message:p,api:{kind:"bulkBatches",org:"target",estimate:g.estimate,remaining:g.remaining}});let m=dt(f.sourceRequests,t.sourceBudget),b=vs(m,t.source);b!==void 0&&m.verdict==="exceeds"&&i.push({code:ne,message:b,api:{kind:"requests",org:"source",estimate:m.estimate,remaining:m.remaining}}),a={source:m,...g?{bulkBatches:g}:{},cost:f}}let[d,...l]=i,u=l.filter(f=>f.code===ne);return{api:r,...d?{stop:d}:{},...t&&u.length>0?{alsoRefused:u}:{},...a?{wholeOrg:a}:{},asks:e.checkpoint!==void 0||t!==void 0,confirmation:{...ms(r),...e.checkpoint?{checkpoint:e.checkpoint}:{}}}}function fr(e,t,n=0){let r=Math.max(0,n),o=e.storageBytes+r,i=o/1048576,s=r>0?{automationMB:r/1048576}:{};if("unread"in t)return{verdict:"unread",estimateMB:i,unread:t.unread,...s};let{maxMB:a,remainingMB:d}=t;return{verdict:o>d*1048576?"exceeds":o>ir*d*1048576?"near":"fits",estimateMB:i,maxMB:a,remainingMB:d,...s}}function _s(e,t){if(!t||t.length===0)return 0;let n=new Map;for(let{objectApiName:r,bytes:o}of t)n.set(r,(n.get(r)??0)+Math.max(0,o));return e.objects.reduce((r,{objectApiName:o,rows:i})=>r+i*(n.get(o)??0),0)}function xe(e){return`about ${L(e.estimateMB)} MB of data storage`+(e.automationMB!==void 0&&e.automationMB>0?`, about ${L(e.automationMB)} MB of it for what the target's automation creates under them`:"")}function Ds(e,t){let n=es(e),r=t.emailTextBytes,o=e.some(s=>Be(s.objectApiName)===ee&&s.counted);if(r===void 0||!Number.isFinite(r)||!o)return n;let i=n.objects.map(s=>Be(s.objectApiName)===ee?{...s,storageBytes:s.storageBytes+Math.max(0,r)}:s);return{...n,objects:i,storageBytes:i.reduce((s,a)=>s+a.storageBytes,0)}}function Ls(e,t,n){return e.flatMap(({objectApiName:r,included:o,piiFields:i,anonymizeFields:s})=>{if(!o||!t.has(r))return[];let a=new Set(n?s:[]),d=i.filter(l=>!a.has(l));return d.length>0?[{objectApiName:r,fields:d}]:[]})}function Ws(e){let t=e.leftOut??[],n=new Set(t.map(({objectApiName:i})=>i)),r=[...t,...e.nodes.filter(i=>i.leftOutByUser===!0&&!n.has(i.objectApiName)).map(({objectApiName:i})=>({objectApiName:i,reason:"excludedByUser"}))],o=new Map;for(let{reason:i}of r)o.set(i,(o.get(i)??0)+1);return{objects:r,counts:[...o].map(([i,s])=>({reason:i,count:s})).sort((i,s)=>s.count-i.count||i.reason.localeCompare(s.reason))}}var Gs=2;async function eu(e){let t=w=>({unread:P(w)}),n=Ds(e.objects,e.measures),r=await as(e.target.limits).catch(t),o="unread"in r?await Jn(e.target.limits).catch(t):r.dailyApiRequests,i=await Jn(e.source.limits).catch(t),s=fr(n,r,_s(n,e.automation)),a=Si(s,e.target.org),d=e.sample?Hs({sample:e.sample,storage:r,target:e.target.org}):void 0,l=Is(e.measures.files,r,e.target.org),u=e.sentBefore?.(),f=js({plan:n,...e.updatedAfterInsert?{updatedAfterInsert:e.updatedAfterInsert}:{},...e.readBack!==void 0?{readBack:e.readBack}:{},...e.checkpoint?{checkpoint:e.checkpoint}:{},...e.mute!==void 0?{mute:e.mute}:{},deliverability:e.deliverability??Gs,...u?{sentBefore:u.target}:{},budget:o,target:e.target.org,wholeOrg:{measures:e.measures,bulkBatches:"unread"in r?r:r.dailyBulkApiBatches,sourceBudget:i,source:e.source.org,...u?.source!==void 0?{sourceSentBefore:u.source}:{}}}),g=[Ms(e.measures.readWholeOver),d,d===void 0&&a!==void 0&&s.verdict==="exceeds"?{code:"STORAGE_EXCEEDED",message:`${a} Nothing was written.`,storage:{estimateMB:Number(L(s.estimateMB)),remainingMB:s.remainingMB}}:void 0,l.stop,f.stop,...f.alsoRefused??[]].filter(w=>w!==void 0),p=e.measures.restOnly?{restOnly:e.measures.restOnly}:{},m=new Set(n.objects.map(({objectApiName:w})=>w)),{wholeOrg:b}=f;return{wouldInsert:n.objects.map(({objectApiName:w,rows:R})=>{let{jobs:O,rest:T}=ve(w,R,p);return{objectApiName:w,rows:R,jobs:O.length,byRest:T}}),totalRows:n.totalRows,targetRequests:f.api,sourceRequests:b.source,...b.bulkBatches?{bulkBatches:b.bulkBatches}:{},storage:s,...l.files?{files:l.files}:{},durationSeconds:b.cost.durationSeconds,leftOut:{...Ws(e.graph),...n.leftOut?{rows:n.leftOut}:{}},personalAsIs:Ls(e.graph.nodes,m,e.anonymizePII),wouldBeRefused:g,...e.measures.personAccountsAsBusiness?{personAccountsAsBusiness:e.measures.personAccountsAsBusiness}:{},...e.sample?{sample:e.sample}:{}}}var Us="SAMPLE_STORAGE_UNREAD",gr="SAMPLE_CANNOT_FIT",qs="SAMPLE_TOO_LARGE",pr="SAMPLE_PLAN_MISMATCH",ct="SAMPLE_PLAN_GONE";function Vs(e){let{storage:t,bounds:n,target:r}=e;if("unread"in t&&!(n.withinMB!==void 0||n.maxTotal!==void 0))return{code:Us,message:`The data storage ${r} has left could not be read (${t.unread}), and a sample is fitted to it: there is nothing to hold it to. Give the most it may take (--fit-within <MB>) or the most records (--max-total <n>), or run it again once the org answers. Nothing was written.`}}function zs(e,t){if(e.remainingMB===void 0||e.share===void 0)return;let n=Math.max(0,t.remainingMB-(e.roundingMB??0));return Math.floor(e.share*n*1048576)}function Qs(e){let{sample:t,storage:n,target:r}=e,o=zs(t.budget,n);if(o===void 0||t.storageBytes<=o)return;let i=Er(t.storageBytes/1048576,o/1048576),s=L(t.budget.bytes/1048576);return{code:"STORAGE_EXCEEDED",message:`The sample was fitted to ${s} MB of the data storage ${r} had left (${t.budget.remainingMB} MB), and ${r} now says ${n.remainingMB} MB left, which holds ${i.bound} MB of a sample: the sample takes about ${i.over} MB. Simulate again \u2014 run the dry run again \u2014 to draw a sample that fits: a run never cuts its sample short. Nothing was written.`,storage:{estimateMB:Number(i.over),remainingMB:n.remainingMB},sample:{fittedMB:Number(s),holdsMB:Number(i.bound)}}}function Hs(e){let{sample:t,storage:n,target:r}=e;return"unread"in n?Vs({storage:n,bounds:t.budget,target:r}):Qs({sample:t,storage:n,target:r})}var Ks=new Set(["gone","changed","otherOrg","otherSetup","otherSha"]),Ys={changed:"is no longer as its dry run wrote it: its ids changed since",otherOrg:"was drawn of another org than the source",otherSetup:"was drawn for another setup of the run \u2014 other flags, filters, objects or options of the sample",otherSha:"is not the plan its dry run printed"};function Xs(e,t){return t==="resume"?{code:ct,message:`The plan of the sample this run resumes ${e==="gone"?"is no longer on this machine":"is no longer as it was written"}: the records it was to write cannot be taken up after where it stopped (--resume). Remove what it wrote (--remove), or run the clone again without --resume to draw a new sample. Nothing was written.`,sample:{plan:e}}:e==="gone"?{code:ct,message:'No plan of a sample is at the path given to --fit-plan: give the folder its dry run printed ("sample plan: \u2026"), within a day of it, or leave --fit-plan out to draw a new sample. Nothing was written.',sample:{plan:e}}:{code:pr,message:`The plan given to --fit-plan ${Ys[e]}: run the dry run again with the flags of this run, and replay the plan it prints. Nothing was written.`,sample:{plan:e}}}var Js=new Set([qs,gr,ct,pr]),Zs=20;function tu(e,t){if(e instanceof Error){if(e.name==="SampleRefusedError"){let{code:n,heaviest:r,sample:o}=e;if(typeof n!="string"||!Js.has(n))return;let i=Array.isArray(r)?r.flatMap(d=>{let l=d?.objectApiName;return typeof l=="string"?[l]:[]}):[],s=Xt({code:n,sample:o})?.sample??{},a={...s,...n===gr&&s.heaviest===void 0&&i.length>0?{heaviest:i.slice(0,Zs)}:{}};return V.of({code:n,message:e.message,...Object.keys(a).length>0?{sample:a}:{}})}if(e.name==="SamplePlanError"&&t!=="draw"){let{refusal:n}=e;return typeof n!="string"||!Ks.has(n)?void 0:V.of(Xs(n,t))}}}var ei=$({SingleEmail:$({Max:x(),Remaining:x()}).loose().optional(),DailyWorkflowEmails:$({Max:x(),Remaining:x()}).loose().optional()}).loose();async function nu(e){let t=ei.parse(await e.request({method:"GET",url:"/limits"})),n={};for(let r of["SingleEmail","DailyWorkflowEmails"]){let o=t[r];o&&(n[r]={max:o.Max,remaining:o.Remaining})}return n}var ti=15;function mr(e){let t=e.SingleEmail;return t!==void 0&&t.max<=ti}function ni(e){return mr(e)&&e.DailyWorkflowEmails!==void 0}function ri(e,t,n=!1){let r=e.map(a=>({...a,sentBy:[...a.sentBy]})),o=(a,d)=>{let l=r.find(u=>u.objectApiName===a.objectApiName&&u.limit===d);if(!l){let u={...a,limit:d,sentBy:[...a.sentBy]};return r.push(u),u}l.perRecord+=a.perRecord;for(let u of a.sentBy)l.sentBy.includes(u)||l.sentBy.push(u);return l},i=e.filter(a=>a.limit==="SingleEmail"),s=e.filter(a=>a.limit==="DailyWorkflowEmails");if(n)for(let a of i)o(a,"DailyWorkflowEmails");if(t)for(let a of s)o(a,"SingleEmail").alertsAmong=!0;return r}function hr(e){let t=new Map(e.objects.map(n=>[n.objectApiName,{rows:n.rows,byThePlatform:0}]));for(let{objectApiName:n,rows:r}of e.leftOut?.byThePlatform??[]){let o=t.get(n)??{rows:0,byThePlatform:0};t.set(n,{rows:o.rows+r,byThePlatform:o.byThePlatform+r})}return t}function mt(e){return new Set([...hr(e)].flatMap(([t,{rows:n}])=>n>0?[t]:[]))}function oi(e,t,n){let r=hr(e),o=new Map;for(let s of t){let{rows:a,byThePlatform:d}=r.get(s.objectApiName)??{rows:0,byThePlatform:0};if(a===0)continue;let l=o.get(s.limit)??{limit:s.limit,objects:[],emails:0,verdict:"fits"};l.objects.push({objectApiName:s.objectApiName,rows:a,perRecord:s.perRecord,sentBy:s.sentBy,...d>0?{byThePlatform:d}:{}}),l.emails+=a*s.perRecord,o.set(s.limit,l)}let i=Ne(n)?n.unread:void 0;return[...o.values()].map(s=>{if(i!==void 0||Ne(n))return{...s,verdict:"unread",unread:i};let a=n[s.limit];return a?{...s,verdict:s.emails>a.remaining?"exceeds":"fits",remaining:a.remaining,max:a.max}:{...s,verdict:"unread",unread:`the org's limits list no ${s.limit}`}})}function Ne(e){return typeof e.unread=="string"}function si(e,t,n){let r=!Ne(n)&&mr(n),o=!Ne(n)&&ni(n),i=oi(e,ri(t,r,o),n);if(!r)return i;let s=mt(e);return t.some(d=>d.limit==="DailyWorkflowEmails"&&s.has(d.objectApiName))?i.map(d=>d.limit==="SingleEmail"?{...d,alertsCounted:!0}:d):i}async function ru(e){if(e.plan.totalRows===0||e.objects.length===0)return{checks:[]};let t;try{t=await e.readAutomation(e.objects)}catch(s){return{checks:[],unread:`the target's automation: ${P(s)}`}}let n=ai(t,ii(e.plan)),r=n!==void 0?{unread:n}:{},o=cn(t);if(o.length===0)return{checks:[],...r};let i=await e.readLimits().catch(s=>({unread:P(s)}));return{checks:si(e.plan,o,i),...r}}function ii(e){let t=mt(e);return(n,r)=>r==="insert"&&t.has(n)}function ai(e,t,n="the target's"){let r=[yr(e.unread,n),li(e,t)].filter(o=>o!==void 0).join("; ");return r!==""?r:void 0}var di={flows:"flows",processes:"processes",workflowRules:"workflow rules"};function yr(e,t){let n=e.flatMap(({part:r,reason:o})=>{let i=di[r];return i!==void 0?[`${t} ${i}: ${o}`]:[]});return n.length>0?n.join("; "):void 0}var K=10;function ui(e){if(e.condition!=="unreadable")return;let t=e.apiName.indexOf("__");return t>0?e.apiName.slice(0,t):void 0}function li(e,t){let n=e.objects.flatMap(o=>{let s=[...new Set(he(o).filter(d=>t(o.objectApiName,d.write)).flatMap(d=>d.fired).flatMap(({flow:d,keptQuiet:l})=>d!==void 0&&l!==!0&&d.condition!=="read"&&d.timing!=="beforeSave"?[d]:[]))].map(d=>{let l=ui(d);return l!==void 0?`${d.label} (package ${l}, whose flows the org lets no one read)`:d.label});if(s.length===0)return[];let a=s.length>K?` and ${s.length-K} more`:"";return[{count:s.length,words:`${s.slice(0,K).join(", ")}${a} on ${o.objectApiName}`}]});return n.length===0?void 0:`the definition${n.reduce((o,{count:i})=>o+i,0)===1?"":"s"} of ${n.map(({words:o})=>o).join("; ")}`}function ou(e){return{limit:e.limit,emails:e.emails,remaining:e.remaining??0,max:e.max??0,objects:e.objects.map(({objectApiName:t,perRecord:n})=>({objectApiName:t,perRecord:n})),...e.alertsCounted?{alertsCounted:!0}:{}}}function su(e){return{limit:e.limit,emails:e.emails,unread:e.unread??""}}var ci={SingleEmail:{one:"single email",more:"single emails"},DailyWorkflowEmails:{one:"workflow email",more:"workflow emails"}};function br(e,t){let n=ci[t];return`${e} ${e===1?n.one:n.more}`}function fi(e,t){return e.alertsCounted?`, its email alerts among them: ${t} counts them against its single emails, as a Developer Edition does`:""}function iu(e,t){let n=e.filter(o=>o.verdict==="exceeds");if(n.length===0)return;let r=n.map(o=>`about ${br(o.emails,o.limit)}`+(o.alertsCounted?" (its email alerts among them, as a Developer Edition counts them)":"")+`, ${o.remaining??0} of ${o.max??0} left today`).join("; ");return`The target's automation would make ${t} send ${r}: past them, each record whose flow fails in the save is refused (CANNOT_EXECUTE_FLOW_TRIGGER), and the org's own emails stop for the rest of the day. Assign the user a bypass that keeps what sends quiet \u2014 muting the target's automation for the run (--mute-automation on the command line, the Mute box on a page) assigns, for the run alone, those the target's flows test \u2014 or write fewer records.`}function au(e,t){return e.map(n=>{let r=n.objects.map(i=>`${i.perRecord} per ${i.objectApiName}, by ${i.sentBy.join(", ")}`+(i.byThePlatform?`; ${i.byThePlatform} ${i.objectApiName} written by the platform with ${te(i.objectApiName)}, whose flows run all the same`:"")).join("; "),o=` emails: these records make ${t} send about ${br(n.emails,n.limit)} (${r})`+fi(n,t);return n.verdict==="unread"?`${o}; what it has left today could not be read (${n.unread??""})`:n.verdict==="fits"?`${o}; it has ${n.remaining??"?"} of ${n.max??"?"} left today`:`${o}, more than the ${n.remaining??"?"} of ${n.max??"?"} it has left today: past them the action fails, and a record whose flow fails in the save is refused (CANNOT_EXECUTE_FLOW_TRIGGER). A bypass that keeps the flow quiet, or a smaller run, avoids it`})}var wr="EMAILS_NOT_ACCEPTED";function du(e,t={}){let n=[yr(e,"the target's"),...t.applyAssignmentRules===!0?e.filter(({part:r})=>r==="assignmentRules").map(({reason:r})=>`the target's assignment rules: ${r}`):[]].filter(r=>r!==void 0);return n.length>0?n.join("; "):void 0}function uu(e){return"requests"in e&&typeof e.requests=="number"?Math.max(0,e.requests):sr}function lu(e){let t=e?.read?.requests??0;return t>0?{deliverability:t}:{}}var Rr={clone:{run:"this clone",allTheSame:"to clone all the same"},sync:{run:"this sync",allTheSame:"to sync all the same"},seed:{run:"this seed",allTheSame:"to seed all the same"},autopilot:{run:"this Autopilot run",allTheSame:"to run it all the same"},rewind:{run:"this rewind",allTheSame:"to rewind all the same"},undo:{run:"this undo",allTheSame:"to undo all the same"},masking:{run:"this masking",allTheSame:"to mask all the same"},restore:{run:"this restore",allTheSame:"to restore all the same"},cleanup:{run:"this cleanup",allTheSame:"to delete all the same"},empty:{run:"this emptying",allTheSame:"to empty all the same"},load:{run:"this load",allTheSame:"to load all the same"}},gi={flow:"flow",process:"process",workflowRule:"workflow rule",assignmentRule:"assignment rule"},pi={email:"",notRead:" (its definition was not read)",assignment:" (applied: it can mail the owner it assigns)"};function Ar(e){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function re(e){let t=new Map;for(let n of e){let r=t.get(n.objectApiName)??[];r.push(`${gi[n.kind]} "${n.name}"${pi[n.why]}`),t.set(n.objectApiName,r)}return[...t].map(([n,r])=>{let o=r.length>K?[...r.slice(0,K),`${r.length-K} more`]:r;return`${Ar(o)} on ${n}`}).join("; ")}var er="read with one line of anonymous Apex that sends nothing";function Sr(e){return"level"in e&&e.level==="withheld"}function mi(e){return"unread"in e?`deliverability: not read (${e.unread}) \u2014 the run is refused without --accept-emails, as on All email`:e.level==="all"?`deliverability: All email \u2014 the emails of what still runs go out (${er})`:`deliverability: System email only or No access \u2014 none of the emails its flows, processes, workflow rules and Apex send goes out, and the org still counts them against its daily email limits (${er})`}function hi(e,t){let{run:n,allTheSame:r}=Rr[e.run],{target:o}=e,i=re(e.senders),s=e.sendersUnread,a=i!==""?`what still runs as ${n} writes its records sends some: ${i}`+(s!==void 0?`; what could not be read may send more (${s})`:""):`what runs as ${n} writes its records could not all be read (${s??""}), so it may send some`,d=[];"unread"in t?d.push(`Whether ${o} delivers the emails its automation sends could not be read (${t.unread}), and ${a}.`,`Nothing was written. Add --accept-emails ${r}, or check Setup > Deliverability: on System email only or No access, none of them goes out.`):d.push(`${o} delivers every email its automation sends (Setup > Deliverability: All email), and ${a}.`,e.keepsAddresses===!0?`They go to the addresses the records and the alerts name: those of the records ${n} writes, as they hold them, the records' owners, the records already in ${o}, and an address an alert names.`:`They go to the addresses the records and the alerts name: those ${n} writes are under .invalid, but not the records' owners, the records already in ${o}, nor an address an alert names.`,`Nothing was written. Add --accept-emails ${r}, set the org's deliverability to System email only, or turn off what sends them.`);let l=e.muteQuiets??[];if(l.length>0){let u=new Set(l.map(g=>`${g.objectApiName}\0${g.kind}\0${g.name}`)),f=e.senders.filter(g=>!u.has(`${g.objectApiName}\0${g.kind}\0${g.name}`));d.push(`--mute-automation keeps quiet ${re(l)}, which ${l.length===1?"tests":"test"} a bypass a permission set of ${o} holds`+(f.length>0?`; it cannot quiet ${re(f)}.`:"."))}return d.join(" ")}function cu(e){if(e.senders.length===0&&e.sendersUnread===void 0)return{verdict:"nothingSends",confirmation:{}};let t=e.reading??{unread:"the run did not read it"},n={reading:t,senders:[...e.senders],...e.sendersUnread!==void 0?{sendersUnread:e.sendersUnread}:{}},r=mi(t);return Sr(t)?{verdict:"withheld",deliverability:n,confirmation:{},line:r,audit:"withheld"}:{verdict:"asks",deliverability:n,confirmation:{deliverability:e.keepsAddresses===!0?{...n,keepsAddresses:!0}:n},...e.accepted?{}:{stop:{code:wr,message:hi(e,t)}},line:r,audit:"unread"in t?"unread":"all"}}function fu(e,t){let n=mt(t);return e.filter(r=>!n.has(r.objectApiName))}function gu(e){if(e.length===0)return;let t=[...new Set(e.map(n=>n.objectApiName))];return` emails: ${re(e)} send nothing: the run writes no ${Ar(t)} record. A real run is refused all the same, and names them: it asks before it reads which records it writes`}function pu(e){let t=d=>`${d.objectApiName}\0${d.kind}\0${d.name}`,n=new Set(e.planned.map(t)),r=e.held.filter(d=>!n.has(t(d)));if(r.length===0||e.accepted)return;let o=e.reading;if(o!==void 0&&Sr(o))return;let{run:i,allTheSame:s}=Rr[e.run],a=o===void 0?`whether ${e.target} delivers them was not read, as nothing that sends one was to run`:"unread"in o?`whether ${e.target} delivers them could not be read (${o.unread})`:`${e.target} delivers every one of them (All email)`;return{code:wr,relit:r,message:`The mute's lease does not hold every permission set it was to assign, and what they were to keep quiet still runs for ${i}: ${re(r)} may send emails, and ${a}. The run's question did not ask about them. Nothing was written. Add --accept-emails ${s}, or run it again once the lease can assign them.`}}function mu(e){return e.verdict==="unread"?{estimateMB:e.estimateMB,unread:e.unread}:{estimateMB:e.estimateMB,maxMB:e.maxMB,remainingMB:e.remainingMB,near:e.verdict==="near"}}function L(e){return ft(e,e<10?2:1)}function ft(e,t){if(e<=0)return"0";let n=10**t;return(Math.ceil(e*n-1e-9)/n).toString()}function Er(e,t){let n={over:e<10?2:1,bound:t<10?2:1};for(;;){let r={over:ft(e,n.over),bound:ft(t,n.bound)},o=Math.max(n.over,n.bound);if(Number(r.over)>Number(r.bound)||o>=6)return r;n={over:o+1,bound:o+1}}}function Tr(e){return e.map(({objectApiName:t,kind:n,name:r})=>({objectApiName:t,kind:n,name:r}))}function yi(e){return Tr(et(e,"insert"))}function bi(e,t){let n=new Set(t);return Tr(et(e,"update",r=>n.has(r)))}var Or=["lookups","statuses","invitees","retry","upsert"];function hu(e,t={}){let n=gt(e,t.leftOut),r=new Set(n),o=new Map,i=(u,f)=>{if(!r.has(u))return;let g=o.get(u)??new Set;g.add(f),o.set(u,g)},s=e.edges.filter(u=>Pn(u)&&r.has(u.sourceObject)&&r.has(u.targetObject)),a=new Map;for(let{sourceObject:u,targetObject:f}of s)u!==f&&a.set(u,[...a.get(u)??[],f]);let d=(u,f)=>{let g=new Set([u]),p=[u];for(let m=p.shift();m!==void 0;m=p.shift())for(let b of a.get(m)??[]){if(b===f)return!0;g.has(b)||(g.add(b),p.push(b))}return!1},l=s.filter(u=>u.required!==!0&&u.insertOnly!==!0);for(let{sourceObject:u,targetObject:f}of l)(u===f||d(f,u))&&i(f,"lookups");for(let u of Object.keys(mn))i(u,"statuses");for(let u of Object.keys(pn))i(u,"invitees");if(t.retry===!0)for(let{sourceObject:u,targetObject:f}of l)u!==f&&i(f,"retry");if(t.upsert===!0)for(let u of n)i(u,"upsert");return n.flatMap(u=>{let f=o.get(u);return f?[{objectApiName:u,steps:Or.filter(g=>f.has(g))}]:[]})}function wi(e){let t=new Set(e.flatMap(n=>n.steps));return Or.filter(n=>t.has(n))}function yu(e,t=[]){let n=new Set(t);return fn(e,(r,o)=>o==="insert"||o==="update"&&n.has(r))}function bu(e,t,n){let r=new Set(ye(e).map(s=>s.toLowerCase())),o=t.filter(s=>!r.has(s.toLowerCase())),i=we(e,o);return o.map(s=>{let a=i.find(l=>l.permission.toLowerCase()===s.toLowerCase()),d=a?.permissionSet?.name;return{permission:s,...d?{permissionSet:d}:{},others:a?.others.map(l=>l.name)??[],...a&&!d?{noneHolds:!0}:{},...d&&n?.alias&&n.username?{command:Re(d,n.alias,n.username)}:{}}})}function Ri(e){return e==="flows"||e==="triggers"||e==="processes"||e==="workflowRules"||e==="automation"}function ie(e){return e.unread.flatMap(({part:t,reason:n})=>Ri(t)?[{part:t,reason:n}]:[])}var wu="OWNER_MAP_INACTIVE",Ru="OWNER_MAP_UNKNOWN",V=class e extends Error{code;storage;ceiling;reason;api;readBound;sample;roots;constructor(t,n,r,o,i,s){super(n),this.name="ForgeRunGateError",this.code=t,r&&(this.storage=r),o!==void 0&&(this.ceiling=o),i!==void 0&&(this.reason=i),s?.api&&(this.api=s.api),s?.readBound&&(this.readBound=s.readBound),s?.sample&&(this.sample=s.sample),s?.roots&&(this.roots=s.roots)}static of(t){return new e(t.code,t.message,t.storage,void 0,t.refusal?.code,{...t.api?{api:t.api}:{},...t.readBound?{readBound:t.readBound}:{},...t.sample?{sample:t.sample}:{},...t.roots?{roots:t.roots}:{}})}get stop(){if(Yt(this.code))return{code:this.code,...this.storage?{storage:this.storage}:{},...this.ceiling!==void 0?{ceiling:this.ceiling}:{},...this.reason!==void 0&&this.code===$e?{reason:this.reason}:{},...this.api&&this.code===ne?{api:this.api}:{},...this.readBound&&this.code==="READ_BOUND_EXCEEDED"?{readBound:this.readBound}:{},...this.sample?{sample:this.sample}:{},...this.roots&&(Ai.has(this.code)||this.code==="STORAGE_EXCEEDED")?{roots:this.roots}:{}}}},Ai=new Set(["ROOTS_QUERY_REFUSED","NO_ROOTS","ROOTS_EXCEEDED","ROOTS_PLAN_MISMATCH","ROOTS_PLAN_GONE"]);function Au(e){return e instanceof V||e instanceof Error&&e.name==="ForgeRunGateError"&&typeof e.code=="string"}var tr="FILE_STORAGE_EXCEEDED";function Su(e){if(!(e instanceof Error)||e.name!=="ForgeFilesRefusedError")return;let{code:t,storage:n}=e;if(t===lr||t===cr)return new V(t,e.message);let r=n?.neededBytes,o=n?.remainingBytes;if(t!==tr||typeof r!="number"||typeof o!="number"||!Number.isFinite(r)||!Number.isFinite(o))return;let i=o/1048576;return new V(tr,e.message,{estimateMB:Number(Er(r/1048576,i).over),remainingMB:i,kind:"files"})}function Si(e,t){if(e.verdict==="exceeds")return`The records to write take ${xe(e)}, and ${t} has ${e.remainingMB} MB left of ${e.maxMB} MB: leave objects out, lower the records per object, or free data storage in ${t}.`}var nr=10;function Eu(e,t,n){let r=[`write gate: ${e.totalRows} record(s) to write to ${n}, ${xe(t)}`];for(let i of e.objects.slice(0,nr))r.push(` ${i.objectApiName.padEnd(42)}${String(i.rows).padStart(8)}`);let o=e.objects.slice(nr);if(o.length>0){let i=o.reduce((s,a)=>s+a.rows,0);r.push(` and ${o.length} more object(s), ${i} record(s)`)}for(let{objectApiName:i,mayAdd:s}of e.objects)s!==void 0&&r.push(` counted in: up to ${s} ${i} record(s) the run may read as it writes them, a price in the currency of the record its lines belong to, the source's own beside the one read`);for(let{objectApiName:i,mayBeByThePlatform:s}of e.objects)s!==void 0&&r.push(` counted in: up to ${s.rows} ${i} record(s) the platform `+(s.before===!0?`may have written with ${te(i)}, in the run this one takes up`:`may write itself with ${te(i)}`)+", which the run then links to and does not send");r.push(...Ei(e.leftOut));for(let{objectApiName:i,field:s,rows:a}of e.leftEmpty??[])r.push(` written empty: ${i}.${s} on ${a} record(s), the record it names held back by the run, never written`);return t.verdict==="unread"?(r.push(` the data storage ${n} has left could not be read (${t.unread}): whether the records fit is not known`),r):(r.push(` data storage of ${n}: ${t.remainingMB} MB left of ${t.maxMB} MB`),t.verdict==="near"&&r.push(` that is more than ${Math.round(ir*100)} % of what ${n} has left: Salesforce counts storage a while after a load, so less may be left than it says`),r)}function Ei(e){if(!e)return[];let t=[];e.writtenBefore>0&&t.push(` not counted: ${e.writtenBefore} record(s) the run it retries or resumes wrote, which it links to and does not write again`);for(let{objectApiName:n,rows:r}of e.heldBack)t.push(` not counted: ${n}, ${r} record(s), held back for a record type closed to the user the run writes as`);for(let{objectApiName:n,rows:r}of e.recordTypeNotInTarget??[])t.push(` not counted: ${n}, ${r} record(s), held back for a record type the target has none of, which it would refuse`);for(let{objectApiName:n,rows:r}of e.withoutParent??[])t.push(` not counted: ${n}, ${r} record(s) held back with a record they cannot be written without, held back itself`);for(let{objectApiName:n,rows:r}of e.noParentInSource??[])t.push(` not counted: ${n}, ${r} record(s) left aside: a lookup they may not leave empty names a record the source does not hold, which no copy can write`);for(let{objectApiName:n,rows:r}of e.outsideFilter??[])t.push(` not counted: ${n}, ${r} record(s) left aside: a lookup they may not leave empty names a record outside its object's filter, which the run does not copy`);for(let{objectApiName:n,rows:r}of e.byThePlatform??[])t.push(` not counted: ${n}, ${r} record(s) written by the platform with ${te(n)}, which the run links to and does not send`);for(let{objectApiName:n,rows:r,fields:o}of e.linkedByValue??[])t.push(` not counted: ${n}, ${r} record(s) the target holds under the same ${o.join(", ")}, which the run links to and does not create`);for(let{objectApiName:n,rows:r}of e.linkedToTarget??[])t.push(` not counted: ${n}, ${r} record(s), the standard price book: linked to the target's own, never written`);for(let{objectApiName:n,rows:r}of e.currencyReplaced??[])t.push(` not counted: ${n}, ${r} record(s) in a currency the target lacks, replaced by the source's own price in the currency written, for the same product and price book`);return t}var Ti={flow:e=>`flow "${e}" runs before a record is deleted, and can refuse the delete`,trigger:e=>`Apex trigger ${e} runs on a delete, and can refuse it`,packageTrigger:e=>`Apex trigger ${e}, installed by a managed package, runs on a delete and can refuse it; no one in the org can change it`,lock:()=>"once activated, a record locks the records under it, which a removal then takes only with it, or once it is back in Draft"},Oi=["flows","triggers"];function Tu(e,t,n=[],r="--remove"){let o=Oi.filter(s=>n.some(a=>a.part===s)),i=o.length===0?[]:[` ${o.map(s=>j[s]).join(" and ")} could not be read: whether one refuses the removal is not known`];if(e.length===0&&o.length===0)return[`reversibility: nothing found in ${t} that refuses a removal of this run's records (no flow before a delete, no Apex trigger on one, no record that locks past Draft)`];if(e.length===0){let s=[...o.includes("flows")?[]:["no flow before a delete"],...o.includes("triggers")?[]:["no Apex trigger on a delete"],"no record that locks past Draft"];return[`reversibility: nothing found in ${t} that refuses a removal of this run's records in what could be read (${s.join(", ")})`,...i]}return[`reversibility: a removal of this run's records (${r}) may be refused in ${t}:`,...e.map(({objectApiName:s,kind:a,name:d})=>` ${s}: ${Ti[a](d??"")}`),...i]}var j={flows:"the flows",triggers:"the Apex triggers",processes:"the Process Builder processes",workflowRules:"the workflow rules",automation:"the automation"};function W({kind:e,name:t}){return e==="flow"?`flow "${t}"`:e==="process"?`process "${t}"`:e==="workflowRule"?`workflow rule "${t}"`:`Apex trigger ${t}`}var ki={lookups:"a lookup filled in once its record exists",statuses:"an order or a contract given back its status after it went in as a draft",invitees:"an event's invitee given its answer",retry:"a lookup the run it retries left empty filled in",upsert:"a record the target holds written over by --upsert"};function Y(e){return e.map(t=>`${t.objectApiName}: ${W(t)}`).join("; ")}function ht(e,t,n){return e.flatMap(r=>{if(r.command){let o=r.others.length>0?`; ${r.others.join(", ")} hold${r.others.length===1?"s":""} it too`:"";return[`${r.permissionSet} is the smallest permission set of ${t} that holds ${r.permission}${o}. Assigned to the user ${n} writes as, it keeps quiet what ${r.permission} excludes: ${r.command}`]}return r.noneHolds?[`No permission set of ${t} holds ${r.permission}: an admin creates one that includes it, and assigns it to the user ${n} writes as.`]:[]})}function yt(e,t,n){let r=[...new Set(e.flatMap(o=>o.permissionSet??[]))];return!n||r.length===0?[]:[`With --mute-automation, the ${t} assigns ${r.join(", ")} to the user it writes as for the ${t} alone, under a lease, and what ${r.length===1?"it keeps":"they keep"} quiet does not fire.`]}function Ou(e,t,n={}){let r=n.updated??[],o=yi(e),i=bi(e,r.map(l=>l.objectApiName)),s=ie(e);if(o.length===0&&i.length===0&&s.length===0)return;let a=[];if(o.length>0&&a.push(`${t} runs automation on the records this clone inserts: ${Y(o)}.`),i.length>0){let l=wi(r.filter(u=>i.some(f=>f.objectApiName===u.objectApiName))).map(u=>ki[u]);a.push(`${t} runs automation as this clone updates records it inserted (${l.join("; ")}): ${Y(i)}.`)}let d=r.length>0?"inserts and updates":"inserts";for(let{part:l,reason:u}of s)a.push(`${j[l][0].toUpperCase()}${j[l].slice(1)} of ${t} could not be read (${u}), so what fires as the clone ${d} is not known.`);return a.push(...ht(n.assign??[],t,"the clone")),a.push(...yt(n.assign??[],"clone",n.mayMute===!0)),a.push(`Nothing was written. Add --accept-automation to clone all the same, or turn that automation off in ${t} first.`),a.join(" ")}function ku(e,t,n={}){let r=tt(e,n.drafted??[]),o=ie(e);if(r.length===0&&o.length===0)return;let i=[],s=r.filter(d=>d.write==="update"),a=r.filter(d=>d.write==="delete");if(a.length>0){let d=a.map(l=>`${l.objectApiName}: ${W(l)} (${oe[l.when]})`);i.push(`${t} runs automation on the records this removal deletes: ${d.join("; ")}.`)}s.length>0&&i.push(`${t} runs automation as this removal sets activated records back to Draft, the only way the platform deletes them: ${Y(s)}.`);for(let{part:d,reason:l}of o)i.push(`${j[d][0].toUpperCase()}${j[d].slice(1)} of ${t} could not be read (${l}), so what fires as the removal deletes is not known.`);return i.push(...ht(n.assign??[],t,"the removal")),i.push(...yt(n.assign??[],"removal",n.mayMute===!0)),i.push(`Nothing was deleted. Add --accept-automation to remove all the same, or turn that automation off in ${t} first.`),i.join(" ")}var oe={before:"before delete",after:"after delete",beforeAndAfter:"before and after delete"};function Fu(e,t,n,r){let o=[`removal automation: what ${t} runs as the removal takes the records back`];for(let s of tt(e,r))o.push(s.write==="delete"?` ${s.objectApiName}: ${oe[s.when]}: ${W(s)}`:` ${s.objectApiName}: set back to Draft before its delete: ${W(s)}`);let i=ie(e);o.length===1&&i.length===0&&o.push(` nothing fires on the ${n} object(s) it deletes records of`);for(let{part:s,reason:a}of i)o.push(` ${j[s]} could not be read: ${a}`);return o}var Fi={bringBack:"brought back from the recycle bin",recreate:"made again with a new Id",giveBack:"given back its values from before the run",setToDraft:"set back to Draft before its delete"};function Pu(e,t,n,r="removal",o){let i=ie(e),s=(a,d)=>{let l=[Pi[d](t)];for(let u of be(e,a))l.push(u.step==="delete"?` ${u.objectApiName}: ${oe[u.when]}: ${W(u)}`:` ${u.objectApiName}: ${Fi[u.step]}: ${W(u)}`);if(l.length===1&&i.length===0){let u=new Set(Object.values(a).flat()).size,f=Bi.has(d)?"deletes":"writes";l.push(` nothing fires on the ${u} object(s) it ${f} records of`)}return l};return[...s(n,r),...o?s(o,kr(r)):[],...i.map(({part:a,reason:d})=>` ${j[a]} could not be read: ${d}`)]}var Pi={removal:e=>`removal automation: what ${e} runs as the removal takes the run back`,reload:e=>`reload automation: what ${e} runs as the reload purges what earlier loads created`,reloadSweep:e=>`reload automation: what ${e} runs as the reload's sweep deletes what the target's automation made for the loads it replaces`,replayAgain:e=>`replay automation: what ${e} runs as the replay purges what earlier replays created`,replayAgainSweep:e=>`replay automation: what ${e} runs as the replay's sweep deletes what the target's automation made for the replays it replaces`};function Bu(e,t,n){let r=be(e,n.steps),o=n.sweep?be(e,n.sweep):[],i=ie(e);if(r.length===0&&o.length===0&&i.length===0)return;let s=l=>r.filter(u=>u.step===l),a=rr[n.subject??"removal"],d=[];if(s("bringBack").length>0&&d.push(`${t} runs automation as ${a.this} brings back from the recycle bin what the run deleted: ${Y(s("bringBack"))}.`),s("giveBack").length>0&&d.push(`${t} runs automation as ${a.this} gives the records the run wrote over their values from before it: ${Y(s("giveBack"))}.`),s("setToDraft").length>0&&d.push(`${t} runs automation as ${a.this} sets activated records back to Draft, the only way the platform deletes them: ${Y(s("setToDraft"))}.`),s("delete").length>0){let l=s("delete").map(u=>`${u.objectApiName}: ${W(u)} (${oe[u.when]})`);d.push(`${t} runs automation on the records ${a.this} deletes: ${l.join("; ")}.`)}if(o.length>0){let l=o.map(u=>`${u.objectApiName}: ${W(u)} (${oe[u.when]})`);d.push(`${t} runs automation on the records ${rr[kr(n.subject??"removal")].this} deletes: ${l.join("; ")}.`)}for(let{part:l,reason:u}of i)d.push(`${j[l][0].toUpperCase()}${j[l].slice(1)} of ${t} could not be read (${u}), so what fires as ${a.the} writes is not known.`);return d.push(...ht(n.assign??[],t,a.who)),d.push(...yt(n.assign??[],a.run,n.mayMute===!0)),d.push(`Nothing was written or deleted. Add --accept-automation to ${a.verb} all the same, or turn that automation off in ${t} first.`),d.join(" ")}var Bi=new Set(["reloadSweep","replayAgainSweep"]);function kr(e){return e==="replayAgain"||e==="replayAgainSweep"?"replayAgainSweep":"reloadSweep"}var rr={removal:{this:"this removal",the:"the removal",who:"the removal",run:"removal",verb:"remove"},reload:{this:"this reload's purge",the:"the reload's purge",who:"the reload",run:"reload",verb:"reload"},reloadSweep:{this:"this reload's sweep",the:"the reload's sweep",who:"the reload",run:"reload",verb:"reload"},replayAgain:{this:"this replay's purge",the:"the replay's purge",who:"the replay",run:"replay",verb:"replay again"},replayAgainSweep:{this:"this replay's sweep",the:"the replay's sweep",who:"the replay",run:"replay",verb:"replay again"}};var vi=2e3,Ni=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function Pr(e,t){let n=e!==void 0&&Number.isFinite(e)?Math.floor(e):t;return Math.min(pe,Math.max(1,n))}function Iu(e){return e===void 0||!Number.isFinite(e)?vi:Math.max(1,Math.floor(e/10))}function Br(e){return e!==void 0&&Number.isFinite(e)&&e>=1?Math.floor(e):Kt}function ju(e){let t=tn(e);if(t!==void 0)return{issue:t};let n=Jt(e);return n?{objectApiName:n.objectApiName,query:{...n.where!==null?{where:n.where}:{},...n.orderBy!==null?{orderBy:n.orderBy}:{},...n.limit!==null?{limit:n.limit}:{}}}:{issue:{kind:"noObject"}}}function _u(e){if(e.where!==void 0&&!Zt.safeParse(e.where).success)return{kind:"where"};if(e.orderBy!==void 0&&!en.safeParse(e.orderBy).success)return{kind:"orderBy"};if(e.limit!==void 0&&!(Number.isInteger(e.limit)&&e.limit>=1&&e.limit<=pe))return{kind:"limit"}}function Du(e,t,n,r){let o=nt(e),i=[...t.where!==void 0?[`(${t.where})`]:[],...n!==void 0&&n!==""?[`(${n})`]:[]],s=i.length>0?` WHERE ${i.join(" AND ")}`:"",a=t.limit!==void 0&&t.limit<=r?t.limit:r+1;return`SELECT Id FROM ${o}${s} ORDER BY ${t.orderBy??"Id"} LIMIT ${a}`}function xi(e,t,n){return!Number.isFinite(e)||e<1||!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0?0:Math.max(0,Math.min(Math.floor(e)-1,Math.floor(n*e/t)))}function Lu(e,t,n){let r=t.where!==void 0?` WHERE ${t.where}`:"";return`SELECT Id FROM ${nt(e)}${r} ORDER BY ${t.orderBy??me} LIMIT ${Math.max(1,Math.floor(n))}`}function Wu(e,t,n){if(e.verdict!=="exceeds")return;let r=xi(n.count,e.estimateMB,e.remainingMB),o=`the ${n.count} ${n.objectApiName} records the query chooses`,i=r>=1?`about ${r} of ${o} fit, each with what its clone copies: a LIMIT of ${r} in the query clones that many \u2014 after ORDER BY ${me}, the newest \u2014, or narrow its WHERE; or leave objects out, or free data storage in ${t}.`:`one of ${o} takes more than that by itself, with what its clone copies: leave objects out, clone less deep, or free data storage in ${t}.`;return{code:"STORAGE_EXCEEDED",message:`The records to write take ${xe(e)}, and ${t} has ${e.remainingMB} MB left of ${e.maxMB} MB: ${i} ${G}`,storage:{estimateMB:Number(L(e.estimateMB)),remainingMB:e.remainingMB},...X(n.objectApiName).roots?{roots:{objectApiName:n.objectApiName,...r>=1?{fits:r}:{}}}:{}}}function Ci(e){let t=new Set,n=[];for(let r of e){let o=Tn(r);t.has(o)||(t.add(o),n.push(r))}return n.sort(On)}function Fr(e){return $i("sha256").update(Ci(e).join(`
8
- `)).digest("hex")}function Gu(e){return Ni.test(e)}function Mi(e,t){let n=r=>r===void 0?void 0:r.replace(/\s+/g," ").trim();return n(e?.where)===n(t?.where)&&n(e?.orderBy??"Id")===n(t?.orderBy??"Id")&&e?.limit===t?.limit}function Uu(e,t){if(e.sourceOrgId!==t.sourceOrgId)return"otherOrg";if(e.objectApiName.toLowerCase()!==t.objectApiName.toLowerCase()||t.query!==void 0&&!Mi(e.query,t.query)||t.ids!==void 0&&Fr(t.ids)!==e.sha256)return"otherQuery";if(Fr(e.ids)!==e.sha256)return"changed"}var G="Nothing was written.";function X(e,t={}){return e!==void 0&&/^[A-Za-z][A-Za-z0-9_]{0,79}$/.test(e)?{roots:{objectApiName:e,...t}}:{}}function qu(e,t){return{code:"ROOTS_QUERY_REFUSED",message:`${nn(e)}. Nothing was read or written.`,...X(t)}}function Vu(e,t,n){let r=t?.where!==void 0?` WHERE ${t.where}`:"";return{code:"NO_ROOTS",message:t===void 0?`None of the ${e} records named is in the source org: there is nothing to clone. ${G}`:`The query chooses no ${e} record of the source org: there is nothing to clone. Count what it chooses there with sf data query -q "SELECT COUNT() FROM ${e}${r}", and check its WHERE. ${G}`,...X(e,{cap:n})}}function zu(e,t,n,r){let o=pe.toLocaleString("en-US"),i=n==="query"&&r?.orderBy!==void 0,s=`${i?"":`ORDER BY ${me} `}LIMIT ${t}`,a=n==="query"?`Give the query ${s}`+(r?.limit!==void 0?` in place of its LIMIT ${r.limit}`:"")+` to clone the first ${t} of its order, narrow its WHERE, or raise --max-roots (the sandforge.forge.maxRoots setting) up to ${o}; past that, copy a sample of the whole org with a filter on its roots.`:`Name ${t} at most, or raise --max-roots up to ${o}.`;return{code:"ROOTS_EXCEEDED",message:`The ${n==="query"?"query chooses":"records named are"} more than the ${t} ${e} records a run clones, and nothing holds ${n==="query"?"it":"them"} to that: refused before anything else was read, rather than cut at an order nobody chose. ${a} ${G}`,...X(e,{cap:t,...i?{ordered:!0}:{}})}}var Ii={otherOrg:"were read of another org than this run reads",otherQuery:"were chosen by another query, of another object, or are other records",changed:"are no longer the ids it was kept with"};function Qu(e,t){return{code:"ROOTS_PLAN_MISMATCH",message:`The records the dry run chose ${Ii[t]}: run the dry run again with this query, and give the run the plan it keeps. ${G}`,...X(e).roots?{roots:{objectApiName:e,plan:t}}:{}}}function Hu(e){return{code:"ROOTS_PLAN_GONE",message:`The run this one resumes cloned the records a query chose, and its journal does not name them: reading the query again could choose others. Remove what it wrote, then run the clone again. ${G}`,...X(e).roots?{roots:{objectApiName:e,plan:"gone"}}:{}}}function Ku(e,t,n){let r=n[n.length-1],o=r?` (${r.objectApiName} came to ${r.rows.toLocaleString("en-US")} after ${n.length} object${n.length===1?"":"s"})`:"";return{code:"READ_BOUND_EXCEEDED",message:`The ${e} roots reach more than ${t.toLocaleString("en-US")} records${o}, and a clone from records holds all it reads before it writes. Take fewer records (a LIMIT), clone less deep (--depth direct), leave objects out, or raise --max-read-total. `+G,readBound:{bound:t,objects:n.slice(0,200).map(i=>({...i})),of:"roots"}}}function Yu(e){let{bound:t,sent:n,next:r,objectApiName:o,sourceRequestsLeft:i}=e,s=i===void 0?"the source would not say what it has left today":`a tenth of the ${i.toLocaleString("en-US")} it has left today`;return{code:"API_BUDGET_EXCEEDED",message:`Reading what the ${e.roots} roots reach would send the source more than ${t.toLocaleString("en-US")} requests (${s}): ${n} sent, ${r} more for ${o}. Take fewer records, clone less deep (--depth direct), or leave objects out. ${G}`,api:{kind:"requests",org:"source",estimate:n+r,remaining:i??t,reading:{bound:t}}}}var bt=class{constructor(t,n){this.given=t;this.store=n}given;store;has(t){return this.given.has(t)||this.store?.mapping(t)?.earlier===!0}retried(t){return this.given.has(t)}get(t){let n=this.given.get(t);if(n!==void 0)return n;let r=this.store?.mapping(t);return r?.earlier?r.targetId:void 0}get from(){return this.given.size===0&&(this.store?.earlierMapped??0)>0?"resume":"retry"}get size(){return this.given.size+(this.store?.earlierMapped??0)}keys(){return this.given.keys()}[Symbol.iterator](){return this.given.entries()}};function U(e){return e!==void 0&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0}function $r(e){let t=e?.roots,n=e?.rootObjectApiName??t?.objectApiName,r=!!(n&&(e?.rootRecordId||t));return{isScoped:r,dryRun:e?.dryRun??!1,referenceFallback:e?.referenceFallback??(r?"nullify":"keep"),rootRecordId:e?.rootRecordId,rootObjectApiName:n,...t&&n?{roots:{...t,objectApiName:n,cap:Pr(t.cap,Ht),readTotal:Br(t.readTotal)}}:{},recordTypeMappings:e?.recordTypeMappings,maxRecordsPerObject:e?.maxRecordsPerObject,referenceDataObjects:new Set(e?.referenceDataObjects??["BusinessHours","OperatingHours"]),expandOrphanParents:e?.expandOrphanParents??!1,maxOrphanParentExpansions:e?.maxOrphanParentExpansions??20,upsertMode:e?.upsertMode==="auto"?"auto":"off",writeApi:e?.writeApi==="auto"?"auto":"rest",fieldExclusions:e?.fieldExclusions??{},excludedObjects:new Set(e?.excludedObjects??[]),ownerMappings:e?.ownerMappings??{},objectSoqlFilters:e?.objectSoqlFilters,fieldMappings:e?.fieldMappings??{},anonymization:e?.anonymization,keepContactPoints:e?.keepContactPoints===!0,files:e?.files?{maxFileBytes:Math.min(e.files.maxFileBytes>0?e.files.maxFileBytes:10*1048576,35*1048576),acceptedAsIs:e.files.acceptedAsIs===!0}:void 0,writtenBefore:new bt(new Map(Object.entries(e?.writtenBefore??{})),e?.stream?.store),beforeWrite:e?.beforeWrite,stream:e?.stream?{pageSize:U(e.stream.pageSize),ceiling:U(e.stream.ceiling),resumeAfter:e.stream.resumeAfter?new Map(Object.entries(e.stream.resumeAfter)):e.stream.store?.checkpoints()??new Map,onPage:e.stream.onPage,...e.stream.store?{store:e.stream.store}:{},...e.stream.summaryBound!==void 0?{summaryBound:Math.max(0,Math.floor(e.stream.summaryBound))}:{},...U(e.stream.secondPassPageSize)!==void 0?{secondPassPageSize:U(e.stream.secondPassPageSize)}:{},...U(e.stream.writeWindow)!==void 0?{writeWindow:U(e.stream.writeWindow)}:{},...e.stream.everything===!0?{everything:!0}:{},...U(e.stream.wholeReadBound)!==void 0?{wholeReadBound:U(e.stream.wholeReadBound)}:{},...e.stream.sample&&e.stream.everything===!0?{sample:e.stream.sample}:{}}:void 0,decisions:new Oe(e?.decisions),recordTypeDecisions:new Map}}async function vr(e,t){let{records:n,pages:r}=await hn(e,t);return{records:n,requests:r}}var Di=25,Lr=15,Ie=5,je=25,Rt=60,At=20,sr=6+Rt+At+1+6+1+20,ae=4,Li="SELECT ApiName, Label, TriggerType, RecordTriggerType, TriggerObjectOrEvent.QualifiedApiName, ActiveVersionId, HasAsyncAfterCommitPath FROM FlowDefinitionView WHERE IsActive = true AND TriggerType IN ('RecordBeforeSave', 'RecordAfterSave', 'RecordBeforeDelete')",Wi="SELECT Name, NamespacePrefix, TableEnumOrId, EntityDefinition.QualifiedApiName, UsageBeforeInsert, UsageAfterInsert, UsageBeforeUpdate, UsageAfterUpdate, UsageBeforeDelete, UsageAfterDelete, UsageAfterUndelete FROM ApexTrigger WHERE Status = 'Active'",Gi="SELECT ApiName, Label, TriggerObjectOrEvent.QualifiedApiName, ActiveVersionId FROM FlowDefinitionView WHERE IsActive = true AND ProcessType = 'Workflow'",Ui="SELECT Id, Name, NamespacePrefix, TableEnumOrId FROM WorkflowRule",qi="SELECT Name, SobjectType FROM AssignmentRule WHERE Active = true",Vi="SELECT DeveloperName, MasterLabel, SobjectType FROM DuplicateRule WHERE IsActive = true",zi="SELECT DeveloperName, NamespacePrefix FROM UserSetupEntityAccess WHERE KeyPrefix = '0CP'";function Nr(e){return`SELECT Metadata FROM Flow WHERE Id = '${e}'`}function Qi(e,t){if(t.length>Ie)throw new Error(`A Tooling composite holds ${Ie} queries, not ${t.length}`);return{allOrNone:!1,compositeRequest:t.map((n,r)=>({method:"GET",url:`${e}/tooling/query?q=${encodeURIComponent(n)}`,referenceId:`q${r}`}))}}function Hi(e,t){if(t.length>je)throw new Error(`A Tooling composite retrieves ${je} records, not ${t.length}`);return{allOrNone:!1,compositeRequest:t.map(({sobject:n,id:r},o)=>{if(!D.test(r))throw new Error(`Not a record id: ${r}`);return{method:"GET",url:`${e}/tooling/sobjects/${n}/${r}`,referenceId:`r${o}`}})}}var Me="PROCESSING_HALTED",Ki=$({compositeResponse:ge($({body:fe(),httpStatusCode:x(),referenceId:H()}).loose())}),Yi=$({records:ge(Je(H(),fe()))}).loose(),Xi=Je(H(),fe()),Ji=ge($({errorCode:H().optional(),message:H().optional()}).loose());function Wr(e,t,n,r,o){let i=Ki.safeParse(e);if(!i.success)throw new Error("The org answered the Tooling composite with no composite answer");let s=new Map(i.data.compositeResponse.map(a=>[a.referenceId,a]));return Array.from({length:t},(a,d)=>{let l=s.get(`${n}${d}`);if(!l)return{refused:`The org gave no answer to this ${r} of the composite`};if(l.httpStatusCode<400){let g=o(l.body);return g?{records:g}:{refused:`The org answered with status ${l.httpStatusCode} and no rows`}}let u=Ji.safeParse(l.body),f=u.success?u.data[0]:void 0;return{refused:f?[f.errorCode,f.message].filter(Boolean).join(": "):`status ${l.httpStatusCode}`,...f?.errorCode===Me?{halted:!0}:{}}})}function Zi(e,t){return Wr(e,t,"q","query",n=>{let r=Yi.safeParse(n);return r.success?r.data.records:void 0})}function ea(e,t){return Wr(e,t,"r","retrieve",n=>{let r=Xi.safeParse(n);return r.success?[r.data]:void 0})}function ta(e){return async t=>ea(await e.request({method:"POST",url:"/tooling/composite",body:JSON.stringify(Hi(`/services/data/v${e.version}`,t)),headers:{"Content-Type":"application/json"}}),t.length)}function ul(e){return{query:async(t,n)=>{let r=await e(t);return vr({query:async o=>r.query(o),queryMore:async o=>r.queryMore(o)},n)},toolingQuery:async(t,n)=>{let r=await e(t);return vr({query:async o=>r.tooling.query(o),queryMore:async o=>r.tooling.queryMore(o)},n)},toolingQueries:async(t,n)=>{let r=await e(t),o=await r.request({method:"POST",url:"/tooling/composite",body:JSON.stringify(Qi(`/services/data/v${r.version}`,n)),headers:{"Content-Type":"application/json"}});return Zi(o,n.length)},toolingRetrieves:async(t,n)=>ta(await e(t))(n)}}async function na(e,t,n,r){let o=t.map(u=>({retrieving:r?u.queries.filter(f=>f.retrieve!==void 0):[],waiting:r?u.queries.filter(f=>f.retrieve===void 0):[...u.queries],left:u.requests})),i={retrieving:je,waiting:Ie},s=(u,f)=>{for(let g of o){let p=f.filter(m=>m.queue===g).map(m=>m.query);p.length>0&&g[u].unshift(...p)}},a=(u,f)=>{for(let g of o){let p=f.filter(m=>m.queue===g).map(m=>m.query);p.length===0&&g.retrieving.length===0||(g.reason??=u,g.waiting.unshift(...p,...g.retrieving.splice(0)))}},d=0,l=async()=>{for(;;){let u=o.find(E=>E.left>0&&(E.retrieving.length>0||E.waiting.length>0));if(!u)return;let f=u.retrieving.length>0?"retrieving":"waiting";u.left--,d++;let g=[];for(let E of o){if(E!==u&&E.left<=0)continue;let C=i[f]-g.length;if(C<=0)break;for(let B of E[f].splice(0,C))g.push({query:B,queue:E})}let p;try{p=r&&f==="retrieving"?await r(g.map(({query:E})=>E.retrieve)):await e(g.map(({query:E})=>E.soql))}catch(E){let C=P(E);if(f==="retrieving")a(C,g);else for(let{query:B}of g)B.refused(C);continue}let m=f==="retrieving"?"retrieve":"query",b=[],w=[],R=0,O,T;if(g.forEach((E,C)=>{let B=p[C]??{refused:`The org gave no answer to this ${m} of the composite`};"records"in B?(E.query.take(B.records),R++):B.halted?(b.push(E),O??=B.refused):f==="retrieving"?(w.push(E),T??=B.refused):E.query.refused(B.refused)}),f==="retrieving"&&R===0){a(T??O??Me,g);continue}if(w.length>0){for(let{queue:E}of w)E.reason??=T;s("waiting",w)}if(b.length===0)continue;let M=g.length-b.length;if(M===0){for(let{query:E}of b)E.refused(O??Me);continue}i[f]=Math.min(i[f],M);for(let{queue:E}of b)E.reason=O;s(f,b)}};await Promise.all(Array.from({length:Math.max(1,n)},l));for(let u of o)for(let f of[...u.retrieving,...u.waiting])f.refused(u.reason??Me);return d}function ra(e){return`SELECT Metadata FROM WorkflowRule WHERE Id = '${e}'`}function oa(e){return`SELECT FlowVersionViewId, ApiName, ObjectType FROM FlowVariableView WHERE FlowVersionViewId IN (${e.map(n=>`'${n}'`).join(", ")})`}function sa(e){return`SELECT DurableId, QualifiedApiName FROM EntityDefinition WHERE QualifiedApiName IN (${e.map(n=>`'${n}'`).join(", ")})`}function ia(e){return`SELECT Id, DeveloperName, NamespacePrefix FROM CustomPermission WHERE DeveloperName IN (${e.map(n=>`'${n}'`).join(", ")})`}function aa(e){return`SELECT SetupEntityId, ParentId, Parent.Name, Parent.Label, Parent.NamespacePrefix FROM SetupEntityAccess WHERE SetupEntityType = 'CustomPermission' AND SetupEntityId IN (${e.map(n=>`'${n}'`).join(", ")}) AND Parent.IsOwnedByProfile = false AND Parent.PermissionSetGroupId = null`}function da(e,t){let n=t.map(r=>`'${r}'`).join(", ");return`SELECT ParentId, COUNT(Id) n FROM ${e} WHERE ParentId IN (${n}) GROUP BY ParentId`}var D=/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/,St=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,ua="myvariable_current",la={RecordBeforeSave:"beforeSave",RecordAfterSave:"afterSave",RecordBeforeDelete:"beforeDelete"},ca={Create:"create",Update:"update",CreateAndUpdate:"createAndUpdate",Delete:"delete"},Gr={onCreateOnly:"create",onAllChanges:"createAndUpdate",onCreateOrTriggeringUpdate:"createAndUpdate"},fa=[["UsageBeforeInsert","beforeInsert"],["UsageAfterInsert","afterInsert"],["UsageBeforeUpdate","beforeUpdate"],["UsageAfterUpdate","afterUpdate"],["UsageBeforeDelete","beforeDelete"],["UsageAfterDelete","afterDelete"],["UsageAfterUndelete","afterUndelete"]],ga={emailAlert:"email",emailSimple:"email",customNotificationAction:"notification",outboundMessage:"outbound"},pa={emailSimple:"SingleEmail",emailAlert:"DailyWorkflowEmails"},ma={Alert:"email",OutboundMessage:"outbound"},ha=new Set(["sms","mms","twilio","whatsapp","vonage","nexmo","messagebird","plivo","sinch"]);function Ot(e){if(typeof e!="object"||e===null)return;let t=e.QualifiedApiName;return typeof t=="string"&&t!==""?t:void 0}var h=e=>typeof e=="string"?e:"";function A(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}function N(e){return Array.isArray(e)?e.filter(t=>typeof t=="object"&&t):[]}function kt(e,t,n,r){return{apiName:e,label:t||e,timing:n,startsOn:r,condition:"notRead",permissions:[],paths:[],messages:[],switches:[]}}function ya(e){let t=Ot(e.TriggerObjectOrEvent),n=la[h(e.TriggerType)];if(!t||!n)return;let r=n==="beforeDelete"?"delete":ca[h(e.RecordTriggerType)]??"createAndUpdate",o=h(e.ActiveVersionId),i=kt(h(e.ApiName),h(e.Label),n,r);return e.HasAsyncAfterCommitPath===!0&&(i.paths=[{kind:"async"}]),{objectApiName:t,id:D.test(o)?o:null,flow:i}}function ba(e){let t=h(e.ActiveVersionId);return{objectApiName:Ot(e.TriggerObjectOrEvent),id:D.test(t)?t:null,flow:kt(h(e.ApiName),h(e.Label),"afterSave","createAndUpdate")}}function wa(e){let t=Ot(e.EntityDefinition)??(h(e.TableEnumOrId)||void 0),n=h(e.Name);if(!t||!n)return;let r=h(e.NamespacePrefix);return{objectApiName:t,trigger:{name:r?`${r}.${n}`:n,events:fa.filter(([o])=>e[o]===!0).map(([,o])=>o)}}}function xr(e){return e.startsOn==="create"||e.startsOn==="createAndUpdate"?e.timing==="afterSave"?0:1:e.startsOn==="update"?2:3}function Ur(e){let t=new Set(Yr(JSON.stringify(e??null)).filter(o=>de(o)==="Permission").map(Et));if(t.size===0)return[];let n=A(e,"filterFormula"),r=new Set((typeof n=="string"?ue(n):[]).filter(o=>de(o.reference)==="Permission"&&o.value===void 0).map(o=>Et(o.reference)));return[...t].sort((o,i)=>o.localeCompare(i)).map(o=>({name:o,bypass:r.has(o)}))}function qr(e){return typeof e!="string"?[]:Zr(ue(e)).filter(t=>de(t.reference)!=="Permission").map(t=>({...t,where:"start",bypass:!0}))}function Ra(e){let t=A(e,"filterFormula");if(typeof t=="string"&&t.trim()!=="")return[...new Set(De(t).flatMap(r=>{let o=Ea(r);return o?[o]:[]}))];let n=N(A(e,"filters"));return n.length===0||!Ta(h(A(e,"filterLogic")),n.length)?[]:[...new Set(n.filter(r=>h(r.operator)==="IsNull"&&A(r.value,"booleanValue")===!1).map(r=>h(r.field)).filter(r=>Aa.test(r)))]}var Aa=/^[A-Za-z][A-Za-z0-9_]*$/,Sa=/^(?:\{!\s*)?\$Record\.([A-Za-z][A-Za-z0-9_]*)\s*\}?$/i;function Ea(e){let t=z(e,"NOT");if(t===void 0)return;let n=Pt(t),r=z(n,"ISBLANK")??z(n,"ISNULL");return r===void 0?void 0:Sa.exec(r.trim())?.[1]}function Ta(e,t){let n=e.trim().toLowerCase();if(n==="and"||t===1&&n!=="or")return!0;if(!/^\d+(\s+and\s+\d+)*$/.test(n))return!1;let r=new Set(n.split(/\s+and\s+/).map(Number));return Array.from({length:t},(o,i)=>i+1).every(o=>r.has(o))}var Vr={permission:"Permission",setup:"Setup",user:"User",profile:"Profile",custommetadata:"CustomMetadata"},zr=String.raw`[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*`,Qr=new RegExp(String.raw`\$(?:Permission|Setup|User|Profile|CustomMetadata)\.${zr}`,"gi"),J=String.raw`(?:\{!\s*)?(\$(?:Permission|Setup|User|Profile|CustomMetadata)\.${zr})\s*\}?`,Oa=new RegExp(`^${J}$`,"i"),ka=new RegExp(`^NOT\\s+${J}$`,"i"),Hr=new RegExp(`^(?:${J}\\s*(==?|<>|!=)\\s*(TRUE|FALSE)|(TRUE|FALSE)\\s*(==?|<>|!=)\\s*${J})$`,"i"),Cr=String.raw`("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')`,Kr=new RegExp(`^(?:${J}\\s*(==?|<>|!=)\\s*${Cr}|${Cr}\\s*(==?|<>|!=)\\s*${J})$`,"i");function q(e){let t=e.indexOf("."),n=Vr[e.slice(1,t).toLowerCase()];return n?`$${n}${e.slice(t)}`:e}function de(e){return Vr[e.slice(1,e.indexOf(".")).toLowerCase()]}function Et(e){return e.slice(e.indexOf(".")+1)}function Yr(e){return[...new Set([...e.matchAll(Qr)].map(t=>q(t[0])))]}var Fa=new RegExp(`^${Qr.source}$`,"i");function Xr(e){return typeof e=="string"&&Fa.test(e)}function _e(e,t){return e.toLowerCase()===t.toLowerCase()}function Jr(e){return e.slice(1,-1).replace(/\\(.)/g,"$1")}function Zr(e){let t=new Map;for(let n of e)t.set(`${n.reference.toLowerCase()}=${n.value??""}`,n);return[...t.values()]}function Mr(e,t){return e.some(n=>_e(n.reference,t.reference)&&n.value===t.value)}function ue(e){return De(e).flatMap(Pa)}function Ft(e){return Tt(e).flatMap(Ba)}function Pa(e){let t=Hr.exec(e);if(t){let[,o,i,s,a,d,l]=t,u=i??d,f=(s??a).toUpperCase();return(u.startsWith("=")?f==="FALSE":f==="TRUE")?[{reference:q(o??l)}]:[]}let n=Kr.exec(e);if(n){let[,o,i,s,a,d,l]=n;return(i??d).startsWith("=")?[]:[{reference:q(o??l),value:Jr(s??a)}]}let r=z(e,"NOT");if(r===void 0){let o=ka.exec(e);return o?[{reference:q(o[1])}]:[]}return Ft(r)}function Ba(e){let t=Oa.exec(e);if(t)return[{reference:q(t[1])}];let n=Hr.exec(e);if(n){let[,i,s,a,d,l,u]=n,f=s??l,g=(a??d).toUpperCase();return(f.startsWith("=")?g==="TRUE":g==="FALSE")?[{reference:q(i??u)}]:[]}let r=Kr.exec(e);if(r){let[,i,s,a,d,l,u]=r;return(s??l).startsWith("=")?[{reference:q(i??u),value:Jr(a??d)}]:[]}let o=z(e,"NOT");return o===void 0?[]:ue(o)}function De(e){let t=Pt(e),n=z(t,"AND");if(n)return Le(n,",").flatMap(De);let r=Le(t,"&&");return r.length>1?r.flatMap(De):[t]}function Tt(e){let t=Pt(e),n=z(t,"OR");if(n)return Le(n,",").flatMap(Tt);let r=Le(t,"||");return r.length>1?r.flatMap(Tt):[t]}function z(e,t){let n=new RegExp(`^${t}\\s*\\(([\\s\\S]*)\\)$`,"i").exec(e);return n&&eo(n[1])?n[1]:void 0}function Pt(e){let t=e.trim();for(;t.startsWith("(")&&t.endsWith(")")&&eo(t.slice(1,-1));)t=t.slice(1,-1).trim();return t}function eo(e){let t=0;for(let{char:n,quoted:r}of to(e))if(!r){if(n==="(")t++;else if(n===")"&&--t<0)return!1}return t===0}function Le(e,t){let n=[],r=0,o=0;for(let{char:i,index:s,quoted:a}of to(e))a||(i==="("?r++:i===")"?r--:r===0&&e.startsWith(t,s)&&(n.push(e.slice(o,s).trim()),o=s+t.length));return n.push(e.slice(o).trim()),n.filter(i=>i!=="")}function*to(e){let t=null;for(let n=0;n<e.length;n++){let r=e[n];if(t){r==="\\"?n++:r===t&&(t=null),yield{char:r,index:n,quoted:!0};continue}if(r==='"'||r==="'"){t=r,yield{char:r,index:n,quoted:!0};continue}yield{char:r,index:n,quoted:!1}}}function $a(e){let t=A(e,"start");if(typeof t=="object"&&t!==null){let n=h(A(A(t,"connector"),"targetReference"))||void 0,r=N(A(t,"scheduledPaths")).map(o=>h(A(A(o,"connector"),"targetReference"))||void 0);return{name:n,everyPath:r.every(o=>o===n)}}return{name:h(A(e,"startElementReference"))||void 0,everyPath:!0}}function va(e,t){let n=e.leftValueReference,r=e.rightValue;if(Xr(n)){let i=q(n);if(typeof A(r,"booleanValue")=="boolean")return[{reference:i}];let s=A(r,"stringValue");return typeof s=="string"?[{reference:i,value:s}]:[]}let o=typeof n=="string"?t.get(n):void 0;return o===void 0?[]:[...Ft(o),...ue(o)]}function Na(e,t){let n=e.leftValueReference,r=typeof n=="string"?t.get(n):void 0;return Yr([typeof n=="string"?n:"",h(A(e.rightValue,"elementReference")),r??""].join(" "))}function xa(e,t,n){let{leftValueReference:r,operator:o,rightValue:i}=e;if(o!=="EqualTo"&&o!=="NotEqualTo")return"unknown";let s=o==="EqualTo",a=A(i,"booleanValue");if(Xr(r)){if(!_e(r,t.reference))return"unknown";if(typeof a=="boolean"&&t.value===void 0)return a===s?"true":"false";let u=A(i,"stringValue");return typeof u=="string"&&t.value!==void 0?u===t.value===s?"true":"false":"unknown"}let d=typeof r=="string"?n.get(r):void 0;if(d===void 0||typeof a!="boolean")return"unknown";let l=a===s;return Mr(Ft(d),t)?l?"true":"false":Mr(ue(d),t)?l?"false":"true":"unknown"}function Ca(e,t,n){let r=N(e.conditions);if(r.length===0)return"unknown";let o=r.map(s=>xa(s,t,n)),i=h(e.conditionLogic).toLowerCase()||"and";return i==="and"?o.includes("false")?"false":o.every(s=>s==="true")?"true":"unknown":i==="or"?o.includes("true")?"true":o.every(s=>s==="false")?"false":"unknown":"unknown"}function Ma(e,t,n){for(let r of N(e.rules)){let o=Ca(r,t,n),i=!h(A(r.connector,"targetReference"));if(o!=="false"){if(o==="true")return i;if(!i)return!1}}return!h(A(e.defaultConnector,"targetReference"))}function no(e){let t=N(A(e,"decisions")),n=new Map(N(A(e,"formulas")).filter(f=>typeof f.expression=="string").map(f=>[h(f.name),h(f.expression)])),r=f=>N(f.rules).flatMap(g=>N(g.conditions)),o=[...new Set(t.flatMap(f=>r(f).flatMap(g=>Na(g,n))))];if(o.length===0)return{permissions:[],switches:[]};let{name:i,everyPath:s}=$a(e),a=s?t.find(f=>h(f.name)===i):void 0,d=a?Zr(r(a).flatMap(f=>va(f,n))).filter(f=>Ma(a,f,n)):[],l=o.filter(f=>de(f)==="Permission").map(f=>({name:Et(f),bypass:d.some(g=>_e(g.reference,f)&&g.value===void 0),where:"decision"})).sort((f,g)=>f.name.localeCompare(g.name)),u=o.filter(f=>de(f)!=="Permission").flatMap(f=>{let g=d.filter(p=>_e(p.reference,f));return g.length>0?g.map(p=>({...p,where:"decision",bypass:!0})):[{reference:f,where:"decision",bypass:!1}]}).sort((f,g)=>f.reference.localeCompare(g.reference));return{permissions:l,switches:u}}function Ia(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(t=>t!=="").map(t=>t.toLowerCase())}function ja(...e){return e.some(t=>{let n=Ia(t);return n.some(r=>ha.has(r))||n.some((r,o)=>r==="text"&&/^messages?$/.test(n[o+1]??""))})}function ro(e){return N(A(e,"actionCalls")).flatMap(t=>{let n=h(t.actionType),r=h(t.label)||h(t.name)||h(t.actionName),o=ga[n],i=pa[n];return o?[{kind:o,name:r,...i?{limit:i}:{}}]:n==="apex"&&ja(h(t.actionName),h(t.name),r)?[{kind:"sms",name:r,guessed:!0}]:[]})}function _a(e){return N(A(A(e,"start"),"scheduledPaths")).map(t=>{let n=h(t.label)||h(t.name)||void 0;if(h(t.pathType)==="AsyncAfterCommit")return{kind:"async",label:n};let r=Number(t.offsetNumber),o=h(t.timeSource)==="RecordField"?h(t.recordField):"";return{kind:"scheduled",label:n,...Number.isFinite(r)?{offset:r}:{},...h(t.offsetUnit)?{unit:h(t.offsetUnit)}:{},...o?{field:o}:{}}})}function oo(e,t){let n=Mn(t);n.length>0&&(e.creates=n)}function Da(e,t){if(typeof t!="object"||t===null)return;let n=A(t,"start"),r=no(t);e.permissions=[...Ur(n),...r.permissions],e.switches=[...qr(A(n,"filterFormula")),...r.switches];let o=Ra(n);o.length>0&&(e.requiresFilled=o),e.paths=_a(t),e.messages=ro(t),oo(e,t)}function La(e,t){let n=new Map(N(A(t,"processMetadataValues")).map(o=>[h(o.name),h(A(o.value,"stringValue"))]));e.startsOn=Gr[n.get("TriggerType")??""]??"createAndUpdate";let r=no(t);return e.permissions=r.permissions,e.switches=r.switches,e.messages=ro(t),oo(e,t),n.get("ObjectType")||void 0}function Wa(e,t){e.startsOn=Gr[h(A(t,"triggerType"))]??"createAndUpdate";let n=A(t,"formula");e.permissions=typeof n=="string"?Ur({filterFormula:n}):[],e.switches=qr(n);let r=N(A(t,"workflowTimeTriggers"));return e.paths=r.map(o=>{let i=Number(o.timeLength);return{kind:"scheduled",...Number.isFinite(i)?{offset:i}:{},...h(o.workflowTimeTriggerUnit)?{unit:h(o.workflowTimeTriggerUnit)}:{},...h(o.offsetFromField)?{field:h(o.offsetFromField)}:{}}}),e.messages=[A(t,"actions"),...r.map(o=>o.actions)].flatMap(N).flatMap(o=>{let i=ma[h(o.type)];return i?[{kind:i,name:h(o.name),...i==="email"?{limit:"DailyWorkflowEmails"}:{}}]:[]}),A(t,"active")===!0}function so(e,t){return(e?`${e}__${t}`:t).toLowerCase()}function wt(e,t){let n=gn(t);return n===void 0?{part:e,reason:P(t)}:{part:e,reason:`the org could not be reached (${n})`,unreachable:n}}var Ir={flows:0,triggers:1,conditions:2,processes:3,workflowRules:4,definitions:5,assignmentRules:6,duplicateRules:7,userPermissions:8,permissionSets:9};function Ga(e){return[...e].sort((t,n)=>Ir[t.part]-Ir[n.part]||(t.reason<n.reason?-1:t.reason>n.reason?1:0))}async function Ce(e,t){let n=new Array(e.length),r=0,o=async()=>{for(;r<e.length;){let i=r++;n[i]=await e[i]()}};return await Promise.all(Array.from({length:Math.min(t,e.length)},o)),n}var jr=[on,kn,an,dn,sn],_r=["ProductCategory","ProductCatalog"];function gt(e,t=new Set){let{referenceDataObjects:n}=$r(void 0),r=e.nodes.filter(u=>u.included&&!t.has(u.objectApiName)&&!n.has(u.objectApiName)).map(u=>u.objectApiName),o=new Set(r),i=new Set(e.nodes.map(u=>u.objectApiName)),s=Object.entries(rn).filter(([u,{object:f}])=>o.has(u)&&!i.has(f)&&!t.has(f)).map(([,{object:u}])=>u),a=Fn(e,t),d=u=>e.edges.some(f=>f.required===!0&&u.includes(f.sourceObject)&&a.has(f.sourceObject)&&o.has(f.targetObject)),l=s.length>0||d(jr);return[...new Set([...r,...s,...l?jr.filter(u=>a.has(u)):[],...d(_r)?_r.filter(u=>a.has(u)):[]])]}var Dr=class{deps;constructor(t){this.deps=t}async readForGraph(t,n,r=new Set){return this.read(t,gt(n,r))}async read(t,n,r={}){let o=[],i=0,s=new Map(n.map(c=>[c.toLowerCase(),c])),a=c=>c===void 0?void 0:s.get(c.toLowerCase()),d=(c,y)=>async()=>{try{let S=await y();return i+=S.requests,S.records}catch(S){return i++,o.push(wt(c,S)),[]}},l=c=>()=>this.deps.query(t,c),u=c=>()=>this.deps.toolingQuery(t,c),f=async()=>[],g=n.some(c=>/^(case|lead)$/i.test(c)),[p,m,b,w,R,O]=await Ce([d("flows",l(Li)),d("triggers",u(Wi)),d("processes",l(Gi)),d("workflowRules",u(Ui)),g?d("assignmentRules",l(qi)):f,d("duplicateRules",l(Vi))],ae),T=p.map(ya).filter(c=>c!==void 0).flatMap(c=>{let y=a(c.objectApiName);return y?[{...c,objectApiName:y}]:[]}),M=m.map(wa).filter(c=>c!==void 0).flatMap(c=>{let y=a(c.objectApiName),S=c.trigger.events.some(k=>k!=="afterUndelete"||r.undeletes===!0);return y&&S?[{...c,objectApiName:y}]:[]}),E=b.map(ba),C=E.filter(c=>c.objectApiName===void 0&&c.id!==null).map(c=>c.id),B=n.filter(c=>c.includes("__")&&St.test(c)),ao=w.some(c=>/^01I/.test(h(c.TableEnumOrId))),[uo,lo]=await Ce([C.length>0?d("processes",l(oa(C))):f,ao&&B.length>0?d("workflowRules",l(sa(B))):f],ae),co=new Map(uo.filter(c=>h(c.ApiName).toLowerCase()===ua).map(c=>[h(c.FlowVersionViewId),h(c.ObjectType)]));for(let c of E)c.objectApiName===void 0&&c.id!==null&&(c.objectApiName=co.get(c.id)||void 0);let fo=new Map(lo.map(c=>[h(c.DurableId),h(c.QualifiedApiName)])),We=w.flatMap(c=>{let y=h(c.TableEnumOrId),S=a(fo.get(y)??y),k=h(c.Name),F=h(c.Id);if(!S||!k)return[];let I=h(c.NamespacePrefix),Q=I?`${I}.${k}`:k;return[{objectApiName:S,id:D.test(F)?F:null,flow:kt(Q,Q,"afterSave","createAndUpdate")}]}),Ge=E.filter(c=>c.objectApiName===void 0||a(c.objectApiName)!==void 0),go=new Map(n.map((c,y)=>[c,y])),le=c=>go.get(a(c.objectApiName)??"")??n.length,Ue=T.filter(c=>c.id!==null).sort((c,y)=>xr(c.flow)-xr(y.flow)||le(c)-le(y)||c.flow.label.localeCompare(y.flow.label)),Z=this.deps.toolingQueries,qe=Z?this.deps.toolingRetrieves:void 0,Bt=qe?je:Ie,$t=Z?Rt*Bt:Di,vt=Z?At*Bt:Lr,Ve=Ue.slice(0,$t),Nt=[...Ge.map(c=>({read:c,kind:"process"})),...We.map(c=>({read:c,kind:"rule"}))].filter(({read:c})=>c.id!==null).sort((c,y)=>le(c.read)-le(y.read)||(c.kind===y.kind?0:c.kind==="process"?-1:1)||c.read.flow.label.localeCompare(y.read.flow.label)),xt=Nt.slice(0,vt),ze,Qe,Ct=new Set,Mt=c=>c[0]?.Metadata,po=(c,y)=>{c.flow.condition="read",Da(c.flow,Mt(y))},mo=(c,y)=>{c.flow.condition="unreadable",ze??=y},ho=({read:c,kind:y})=>y==="process"?Nr(c.id):ra(c.id),yo=({read:c,kind:y},S)=>{let k=Mt(S);if(typeof k!="object"||k===null){c.flow.condition="unreadable";return}if(c.flow.condition="read",y==="process"){let F=La(c.flow,k);c.objectApiName??=F}else Wa(c.flow,k)||Ct.add(c.flow)},bo=({read:c},y)=>{c.flow.condition="unreadable",Qe??=y},It=(c,y,S,k,F)=>c.map(I=>({soql:y(I),retrieve:S(I),take:Q=>k(I,Q),refused:Q=>F(I,Q)})),jt=It(Ve,c=>Nr(c.id),c=>({sobject:"Flow",id:c.id}),po,mo),_t=It(xt,ho,({read:c,kind:y})=>({sobject:y==="process"?"Flow":"WorkflowRule",id:c.id}),yo,bo);Z?i+=await na(c=>Z(t,c),[{queries:jt,requests:Rt},{queries:_t,requests:At}],ae,qe&&(c=>qe(t,c))):await Ce([...jt,..._t].map(c=>async()=>{try{let y=await this.deps.toolingQuery(t,c.soql);i+=y.requests,c.take(y.records)}catch(y){i++,c.refused(P(y))}}),ae),ze!==void 0&&o.push(wt("conditions",ze)),Qe!==void 0&&o.push(wt("definitions",Qe));for(let c of[...T,...Ge,...We])c.id===null&&(c.flow.condition="unreadable");let Dt=Ge.flatMap(c=>{let y=a(c.objectApiName);return y?[{...c,objectApiName:y}]:[]}),Lt=We.filter(c=>!Ct.has(c.flow)),He=[...T,...Dt,...Lt].flatMap(c=>c.flow.permissions),Wt;if(He.length>0){let[c]=await Ce([d("userPermissions",l(zi))],ae);if(!o.some(y=>y.part==="userPermissions")){let y=new Set(c.map(S=>so(h(S.NamespacePrefix),h(S.DeveloperName))));Wt=y;for(let S of He)S.held=y.has(S.name.toLowerCase())}}let Gt=[...new Set(He.filter(c=>c.bypass&&c.held!==!0).map(c=>c.name))],Ke=Gt.length>0?await Ua(Gt,c=>d("permissionSets",l(c))(),()=>o.some(c=>c.part==="permissionSets"),async c=>{try{let y=await this.deps.query(t,c);return i+=y.requests,y.records}catch(y){throw i++,y}}):void 0,ce={};if(Ke?.some(c=>c.permissionSets.length>0)){let{toolingQueries:c,toolingRetrieves:y}=this.deps;try{let{readValidationRuleBypasses:S}=await import("./chunk-42BFLWHR.mjs"),k=await S(F=>this.deps.toolingQuery(t,F),n,c&&(F=>c(t,F)),y&&(F=>y(t,F)));i+=k.requests,ce.validationRuleBypasses=k.rules.flatMap(F=>F.permissions.some(I=>Wt?.has(I.toLowerCase()))?[]:[F]),k.notRead>0&&(ce.validationRulesNotRead=k.notRead)}catch(S){i++,ce.validationRulesUnread=P(S)}}let wo=c=>R.filter(y=>h(y.SobjectType).toLowerCase()===c.toLowerCase()).map(y=>({name:h(y.Name)})).sort((y,S)=>y.name.localeCompare(S.name)),Ro=c=>O.filter(y=>h(y.SobjectType).toLowerCase()===c.toLowerCase()).map(y=>({name:h(y.MasterLabel)||h(y.DeveloperName),developerName:h(y.DeveloperName)})).sort((y,S)=>y.name.localeCompare(S.name)),Ao=(c,y)=>c.label.localeCompare(y.label),Ye=(c,y)=>c.filter(S=>S.objectApiName===y).map(S=>S.flow).sort(Ao),Xe=new Map;for(let c of Ue.slice(Ve.length))Xe.set(c.objectApiName,(Xe.get(c.objectApiName)??0)+1);let Ut=n.flatMap(c=>{let y=Xe.get(c);return y?[{objectApiName:c,flows:y}]:[]}),So=n.map(c=>({objectApiName:c,flows:Ye(T,c),triggers:M.filter(y=>y.objectApiName===c).map(y=>y.trigger).sort((y,S)=>y.name.localeCompare(S.name)),processes:Ye(Dt,c),workflowRules:Ye(Lt,c),assignmentRules:wo(c),duplicateRules:Ro(c)})).filter(c=>c.flows.length>0||c.triggers.length>0||c.processes.length>0||c.workflowRules.length>0||c.assignmentRules.length>0||c.duplicateRules.length>0);return{objectsRead:[...n],objects:So,unread:Ga(o),conditionsNotRead:Ue.length-Ve.length,conditionsBound:$t,...Ut.length>0?{conditionsNotReadOn:Ut}:{},definitionsNotRead:Nt.length-xt.length,definitionsBound:vt,...Ke?{bypassGrants:Ke}:{},...ce,requests:i}}};function _(e){return e.slice(0,15)}async function Ua(e,t,n,r){let o=e.flatMap(p=>{let m=p.indexOf("__"),b=m>0?p.slice(0,m):"",w=m>0?p.slice(m+2):p;return St.test(w)&&(!b||St.test(b))?[{name:p,developerName:w}]:[]});if(o.length===0)return;let i=await t(ia([...new Set(o.map(p=>p.developerName))]));if(n())return;let s=new Map;for(let p of i){let m=h(p.Id);D.test(m)&&s.set(so(h(p.NamespacePrefix),h(p.DeveloperName)),m)}let a=o.flatMap(p=>{let m=s.get(p.name.toLowerCase());return m?[m]:[]}),d=a.length>0?await t(aa(a)):[];if(n())return;let l=[...new Set(d.map(p=>h(p.ParentId)).filter(p=>D.test(p)))],u=new Map;for(let p of["SetupEntityAccess","ObjectPermissions"]){if(l.length===0)break;let m=await t(da(p,l));if(n())return;for(let b of m){let w=_(h(b.ParentId)),R=typeof b.n=="number"?b.n:Number(b.n);u.set(w,(u.get(w)??0)+(Number.isFinite(R)?R:0))}}let f=new Map;for(let p of i){let m=h(p.Id);D.test(m)&&f.set(_(m),io(h(p.NamespacePrefix),h(p.DeveloperName)))}let g=r&&l.length>0?await za(l,f,r):void 0;return o.map(({name:p})=>{let m=s.get(p.toLowerCase()),b=new Map;for(let w of d){if(!m||_(h(w.SetupEntityId))!==_(m))continue;let R=_(h(w.ParentId)),O=w.Parent,T=h(A(O,"Name"));if(!T||b.has(R))continue;let M=h(A(O,"NamespacePrefix"));b.set(R,{name:M?`${M}__${T}`:T,label:h(A(O,"Label"))||T,grants:u.get(R)??0,...g===void 0?{}:"refused"in g?{customPermissionsUnread:g.refused}:{customPermissions:g.bySet.get(R)??[]}})}return{permission:p,permissionSets:[...b.values()].sort((w,R)=>w.grants-R.grants||w.name.localeCompare(R.name))}})}function io(e,t){return e?`${e}__${t}`:t}function qa(e){return`SELECT ParentId, SetupEntityId FROM SetupEntityAccess WHERE SetupEntityType = 'CustomPermission' AND ParentId IN (${e.map(n=>`'${n}'`).join(", ")})`}function Va(e){return`SELECT Id, DeveloperName, NamespacePrefix FROM CustomPermission WHERE Id IN (${e.map(n=>`'${n}'`).join(", ")})`}async function za(e,t,n){try{let r=await n(qa(e)),o=new Map(t),i=[...new Set(r.map(a=>h(a.SetupEntityId)).filter(a=>D.test(a)&&!o.has(_(a))))];if(i.length>0)for(let a of await n(Va(i))){let d=h(a.Id);D.test(d)&&o.set(_(d),io(h(a.NamespacePrefix),h(a.DeveloperName)))}let s=new Map;for(let a of r){let d=_(h(a.ParentId)),l=o.get(_(h(a.SetupEntityId)));if(!l)continue;let u=s.get(d)??[];u.includes(l)||u.push(l),s.set(d,u)}for(let a of s.values())a.sort((d,l)=>d.localeCompare(l));return{bySet:s}}catch(r){return{refused:P(r)}}}var Qa={insert:"on insert",update:"on update",delete:"on delete"},Ha={insert:{before:"before save",after:"after save",beforeAndAfter:"before and after save"},update:{before:"before save",after:"after save",beforeAndAfter:"before and after save"},delete:{before:"before delete",after:"after delete",beforeAndAfter:"before and after delete"}},Ka={flow:e=>`flow "${e}"`,trigger:e=>`Apex trigger ${e}`,process:e=>`process "${e}"`,workflowRule:e=>`workflow rule "${e}"`},Ya={flows:"the flows",triggers:"the Apex triggers",conditions:"the start conditions of some flows",processes:"the Process Builder processes",workflowRules:"the workflow rules",definitions:"the definitions of some processes or workflow rules",assignmentRules:"the assignment rules",duplicateRules:"the duplicate rules",userPermissions:"the custom permissions of the user the run writes as",permissionSets:"the permission sets that hold a bypass the user the run writes as does not"},Xa={email:"email",notification:"custom notification",outbound:"outbound message",sms:"text message"};function Ja(e){let t=e.guessed?" (guessed from the name of an Apex action)":"";return`${Xa[e.kind]} "${e.name}"${t}`}function Za(e){let t=e.label?` "${e.label}"`:"";if(e.kind==="async")return`asynchronous path${t}`;if(e.offset===void 0||e.unit===void 0)return`scheduled path${t}`;let n=Math.abs(e.offset),r=n===1?e.unit.replace(/s$/,""):e.unit,o=e.offset<0?"before":"after";return`scheduled path${t} (${n} ${r} ${o} ${e.field??"the save"})`}function ed(e){let t=e.value===void 0?"true":`'${e.value}'`;return e.where==="decision"?`its first decision ends it when ${e.reference} is ${t}`:`not when ${e.reference} is ${t}`}function td(e,t){let n=e.flow,r=n?.permissions??[],o=n?.switches??[],i=n?.messages??[],s=n?.paths??[],a=p=>p.held===!0?" (held)":p.held===!1?" (not held)":"",d=r.filter(p=>p.bypass&&p.where!=="decision"),l=r.filter(p=>p.bypass&&p.where==="decision"),u=r.filter(p=>!p.bypass&&p.where!=="decision"),f=[...r.filter(p=>!p.bypass&&p.where==="decision").map(p=>p.name),...o.filter(p=>!p.bypass).map(p=>p.reference)],g=e.kind==="flow"?"start condition":"definition";return[Ha[t][e.when],...i.length>0?[`SENDS MESSAGES: ${i.map(Ja).join(", ")}`]:[],...s.length>0?[`then after commit: ${s.map(Za).join(", ")}`]:[],...d.length>0?[`not for a user with ${d.map(p=>p.name+a(p)).join(", ")}`]:[],...l.length>0?[`its first decision ends it for a user with ${l.map(p=>p.name+a(p)).join(", ")}`]:[],...o.filter(p=>p.bypass).map(ed),...e.keptQuiet?["quiet for this run"]:[],...u.length>0?[`its start condition names ${u.map(p=>p.name).join(", ")}`]:[],...f.length>0?[`its decisions test ${f.join(", ")}`]:[],...n?.condition==="notRead"?[`${g} not read`]:[],...n?.condition==="unreadable"?[`${g} unreadable`]:[]]}function ll(e,t,n={}){let r=[`target automation: what ${t} runs on the ${e.objectsRead.length} object(s) the run writes`];for(let s of e.objects){r.push(` ${s.objectApiName}`);for(let{write:l,fired:u}of he(s)){let f=u.map(g=>`${Ka[g.kind](g.name)} (${td(g,l).join("; ")})`);r.push(` ${Qa[l]}: ${f.join(", ")}`)}let a=n.mayApplyAssignmentRules!==!1;for(let l of s.assignmentRules??[])r.push(n.applyAssignmentRules?` assignment rule "${l.name}": applied${a?" (--apply-assignment-rules)":""}: it can give the records it routes another owner, and mail that owner`:` assignment rule "${l.name}": not applied: the run sends Sforce-Auto-Assign: FALSE and keeps the owner it sets${a?" (--apply-assignment-rules applies it)":""}`);let d=s.duplicateRules??[];d.length>0&&r.push(` duplicate rules: ${d.map(l=>`"${l.name}"`).join(", ")}: the run saves a record a rule only alerts on; a rule that blocks still refuses it`)}e.objects.length===0&&r.push(ln(e.unread)?" nothing found in what could be read":" no active flow, process, workflow rule, Apex trigger, assignment rule or duplicate rule runs on them");let o=ye(e),i=un(e).filter(s=>!o.includes(s));if(i.length>0){r.push(` bypass: assign ${i.join(", ")} to the user the run writes as, and the flows whose start condition excludes them stay quiet`+(n.mayMute!==!1?"; --mute-automation assigns them for the run alone, and takes them back as it ends":""));for(let{permission:s,permissionSet:a,others:d}of we(e,i)){if(!a){r.push(` ${s}: no permission set of ${t} holds it: an admin creates one that includes it`);continue}let l=d.length>0?`; also held by ${d.map(f=>f.name).join(", ")}`:"",u=n.username?`: ${Re(a.name,t,n.username)}`:"";r.push(` ${s}: held by permission set ${a.name}, the smallest${l}${u}`)}}if(o.length>0&&r.push(` bypass held: the user the run writes as holds ${o.join(", ")}, and what excludes them stays quiet for this run`),e.conditionsNotRead>0){let s=(e.conditionsNotReadOn??[]).map(({objectApiName:a,flows:d})=>`${a} (${d})`).join(", ");r.push(` ${e.conditionsNotRead} start condition(s) not read: the read takes ${e.conditionsBound} at most`+(s?`; left unread on ${s}`:""))}(e.definitionsNotRead??0)>0&&r.push(` ${e.definitionsNotRead} process or workflow rule definition(s) not read: the read takes ${e.definitionsBound??Lr} at most`);for(let{part:s,reason:a}of e.unread)r.push(` ${Ya[s]} could not be read: ${a}`);return r.push(` read in ${e.requests} request(s) to ${t}`),r}export{ke as a,at as b,Td as c,Go as d,Od as e,Qn as f,Hn as g,Fd as h,Kn as i,vd as j,Nd as k,xd as l,Cd as m,Md as n,od as o,sd as p,id as q,jn as r,ad as s,_n as t,vo as u,dd as v,pd as w,md as x,Wn as y,hd as z,yd as A,Pr as B,Iu as C,ju as D,_u as E,Du as F,xi as G,Lu as H,Wu as I,Ci as J,Fr as K,Gu as L,Uu as M,qu as N,Vu as O,zu as P,Qu as Q,Hu as R,Ku as S,Yu as T,$r as U,vr as V,Di as W,Lr as X,Ie as Y,je as Z,Rt as _,At as $,sr as aa,Li as ba,Wi as ca,Gi as da,Ui as ea,qi as fa,Vi as ga,zi as ha,Nr as ia,Qi as ja,Hi as ka,Zi as la,ea as ma,ta as na,ul as oa,na as pa,ra as qa,oa as ra,sa,ia as ta,aa as ua,da as va,Ur as wa,qr as xa,Ra as ya,no as za,ro as Aa,_a as Ba,so as Ca,wt as Da,Ce as Ea,gt as Fa,Dr as Ga,Ua as Ha,qa as Ia,Va as Ja,ll as Ka,zd as La,Qd as Ma,zo as Na,Hd as Oa,ir as Pa,ut as Qa,Zo as Ra,es as Sa,Kd as Ta,Xn as Ua,rs as Va,Yd as Wa,Xd as Xa,Jd as Ya,is as Za,as as _a,Jn as $a,ds as ab,us as bb,cs as cb,dt as db,ne as eb,ps as fb,ms as gb,$e as hb,hs as ib,ys as jb,bs as kb,Zd as lb,ve as mb,Ts as nb,Os as ob,ks as pb,Ps as qb,Bs as rb,$s as sb,vs as tb,Ns as ub,xs as vb,Ms as wb,Is as xb,js as yb,fr as zb,_s as Ab,xe as Bb,Ds as Cb,Ls as Db,Ws as Eb,Gs as Fb,eu as Gb,Us as Hb,gr as Ib,qs as Jb,pr as Kb,ct as Lb,Vs as Mb,Hs as Nb,tu as Ob,nu as Pb,ti as Qb,mr as Rb,ni as Sb,ri as Tb,oi as Ub,si as Vb,ru as Wb,ii as Xb,ai as Yb,ou as Zb,su as _b,br as $b,iu as ac,au as bc,wr as cc,du as dc,uu as ec,lu as fc,mi as gc,cu as hc,fu as ic,gu as jc,pu as kc,mu as lc,L as mc,Er as nc,yi as oc,bi as pc,hu as qc,wi as rc,yu as sc,bu as tc,ie as uc,wu as vc,Ru as wc,V as xc,Au as yc,Su as zc,Si as Ac,Eu as Bc,Ei as Cc,Tu as Dc,ht as Ec,Ou as Fc,ku as Gc,Fu as Hc,Pu as Ic,Bu as Jc};
@@ -1,7 +0,0 @@
1
- import { createRequire as __sandforgeRequire } from 'node:module';
2
- import { fileURLToPath as __sandforgePath } from 'node:url';
3
- import { dirname as __sandforgeDirname } from 'node:path';
4
- const require = __sandforgeRequire(import.meta.url);
5
- const __filename = __sandforgePath(import.meta.url);
6
- const __dirname = __sandforgeDirname(__filename);
7
- import{a,b,c}from"./chunk-HIHCYMSL.mjs";import"./chunk-JESRFE2Z.mjs";import"./chunk-CBL42DUU.mjs";import"./chunk-MKTXJCXN.mjs";import"./chunk-RCYEBY42.mjs";import"./chunk-AUS6NFLZ.mjs";import"./chunk-DBBPDSFN.mjs";import"./chunk-GBGHJTPC.mjs";import"./chunk-YMDFF657.mjs";import"./chunk-7WSLT5VX.mjs";import"./chunk-YT22LMF7.mjs";import"./chunk-ZXFL2MSN.mjs";import"./chunk-PE435FVH.mjs";import"./chunk-PWVDNN2C.mjs";import"./chunk-6VSZNZHH.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-WB2RIVO3.mjs";import"./chunk-ISSP2FZ5.mjs";import"./chunk-XU25YA46.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-IVZJSDJD.mjs";import"./chunk-VZT4E2OJ.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-O2PUGRNW.mjs";import"./chunk-7SDZR6SR.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-3SKLBRPL.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-SAMWHL22.mjs";import"./chunk-6KP6WETK.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-J24TIGSI.mjs";import"./chunk-HKUWHVI7.mjs";import"./chunk-VPDEJGPS.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-PBE44M2Y.mjs";import"./chunk-ZUOPC4W2.mjs";import"./chunk-JQZTMFO7.mjs";import"./chunk-JFNLKHY6.mjs";import"./chunk-VZVICK7Q.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-7PY3VQP3.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-HFUDCNU5.mjs";import"./chunk-XZISAZA6.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-L4INJ5TZ.mjs";import"./chunk-KIMQQ6JQ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-PR74GYVI.mjs";import"./chunk-TMA34QMA.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as UNDO_AUTOMATION_LIFTED_BY,a as UndoStopped,c as undoCheckpoint};