sliccy 6.7.1 → 6.8.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 (172) hide show
  1. package/dist/node-server/_shared/tray-sync-protocol.d.ts +4 -0
  2. package/dist/node-server/_shared/tray-sync-protocol.d.ts.map +1 -1
  3. package/dist/node-server/_shared/tray-sync-protocol.js.map +1 -1
  4. package/dist/ui/assets/AdobeClean-Regular-CVsq5gF7.otf +0 -0
  5. package/dist/ui/assets/account-store-DUSlZEzF.js +43 -0
  6. package/dist/ui/assets/account-store-DhDTX9zd.js +101 -0
  7. package/dist/ui/assets/adobe-7V016zh-.js +2 -0
  8. package/dist/ui/assets/adobe-loXjnN_r.js +1 -0
  9. package/dist/ui/assets/{anthropic-messages-C8dDJE2X.js → anthropic-messages-BbI5c8JA.js} +2 -2
  10. package/dist/ui/assets/anthropic-messages-BqlIV27l.js +39 -0
  11. package/dist/ui/assets/{apps-e_6VBmSq.js → apps-CuM4GlQ9.js} +1 -1
  12. package/dist/ui/assets/azure-openai-1tfWxXow.js +1 -0
  13. package/dist/ui/assets/azure-openai-BlNyP04F.js +1 -0
  14. package/dist/ui/assets/azure-openai-responses-C1EEdmtw.js +1 -0
  15. package/dist/ui/assets/azure-openai-responses-DOqakjfa.js +1 -0
  16. package/dist/ui/assets/bedrock-camp-CHi38ceE.js +1 -0
  17. package/dist/ui/assets/bedrock-camp-CVX95quY.js +1 -0
  18. package/dist/ui/assets/cerebras-8oZMzEdi.js +1 -0
  19. package/dist/ui/assets/cerebras-pWMXfh08.js +1 -0
  20. package/dist/ui/assets/compat-BhgG-Qr-.js +2 -0
  21. package/dist/ui/assets/{connect-surface-BfL-Hz8-.js → connect-surface-CfPtIx1L.js} +1 -1
  22. package/dist/ui/assets/{context-compaction-C3e7rcEG.js → context-compaction-gzCxn8vG.js} +1 -1
  23. package/dist/ui/assets/{event-stream-qbAZIAKV.js → diagnostics-DN_idNHx.js} +1 -1
  24. package/dist/ui/assets/{dip-BubHLPf_.js → dip-ByAv1QK8.js} +1 -1
  25. package/dist/ui/assets/dist-BlzIXVXL.js +2 -0
  26. package/dist/ui/assets/dist-DIYpvNeF.js +2 -0
  27. package/dist/ui/assets/error-body-CqsCxuQ4.js +1 -0
  28. package/dist/ui/assets/{fs-dFnZMZlE.js → fs-B-xo85PC.js} +1 -1
  29. package/dist/ui/assets/fs-MKXdQd34.js +2 -0
  30. package/dist/ui/assets/github-BhUX6t5B.js +2 -0
  31. package/dist/ui/assets/{github-BVpq_CRW.js → github-Zr_a3MeC.js} +1 -1
  32. package/dist/ui/assets/github-copilot-C2boII4t.js +2 -0
  33. package/dist/ui/assets/github-copilot-CkiL57PB.js +1 -0
  34. package/dist/ui/assets/google-generative-ai-BjzUffX7.js +1 -0
  35. package/dist/ui/assets/google-generative-ai-CUyKfom8.js +1 -0
  36. package/dist/ui/assets/{google-shared-BAKd3aSn.js → google-shared-Bvf-cbUv.js} +1 -1
  37. package/dist/ui/assets/{google-shared-CCLlnqMF.js → google-shared-Dh_qL7z7.js} +1 -1
  38. package/dist/ui/assets/google-vertex-Bf_2YfBL.js +1 -0
  39. package/dist/ui/assets/google-vertex-Dc8m8x5E.js +1 -0
  40. package/dist/ui/assets/{kernel-worker-lVell-lm.js → kernel-worker-nX203MeP.js} +645 -627
  41. package/dist/ui/assets/{legacy-api-aliases-BWm3gxUe.js → legacy-api-aliases-DrEKVikN.js} +1 -1
  42. package/dist/ui/assets/{legacy-api-aliases-YuuBU-he.js → legacy-api-aliases-MR6kosFL.js} +1 -1
  43. package/dist/ui/assets/{local-llm-DE4-Y_h8.js → local-llm-CX7q6Yli.js} +1 -1
  44. package/dist/ui/assets/{local-llm-C4iAjYRB.js → local-llm-D_j99cTQ.js} +1 -1
  45. package/dist/ui/assets/{main-D27SqZeW.js → main-DS0A6F7x.js} +3 -3
  46. package/dist/ui/assets/{mistral-conversations-CIMZoDT4.js → mistral-conversations-CkIx9cg4.js} +3 -3
  47. package/dist/ui/assets/{mistral-conversations-CKK59QJS.js → mistral-conversations-Ct4-30zw.js} +3 -3
  48. package/dist/ui/assets/models-DmWu8BeM.js +1 -0
  49. package/dist/ui/assets/{mount-CumPEsj1.js → mount-DO4lhFtI.js} +1 -1
  50. package/dist/ui/assets/{mount-DVK2IjbO.js → mount-IJboS6Gs.js} +2 -2
  51. package/dist/ui/assets/{mount-recovery-DKXX_1FG.js → mount-recovery-C8ZE4hoL.js} +1 -1
  52. package/dist/ui/assets/{new-session-CQEb_ELT.js → new-session-CJBZ_8zu.js} +2 -2
  53. package/dist/ui/assets/{oauth-bootstrap-CYlXs7B2.js → oauth-bootstrap-CQEwwPvA.js} +2 -2
  54. package/dist/ui/assets/openai-codex-BpsUGh4U.js +1 -0
  55. package/dist/ui/assets/openai-codex-responses-BdgEOEuS.js +7 -0
  56. package/dist/ui/assets/openai-codex-responses-CLGX-aTS.js +7 -0
  57. package/dist/ui/assets/openai-codex-xMkqwST3.js +1 -0
  58. package/dist/ui/assets/openai-completions-BnbrI3UF.js +5 -0
  59. package/dist/ui/assets/openai-completions-DgBXkZQB.js +5 -0
  60. package/dist/ui/assets/openai-responses-BCmB_39F.js +1 -0
  61. package/dist/ui/assets/openai-responses-ltU_A4Wo.js +1 -0
  62. package/dist/ui/assets/{openai-responses-shared-IJFiSqdz.js → openai-responses-shared-BhTvPbKN.js} +4 -4
  63. package/dist/ui/assets/{openai-responses-shared-CiIL52L-.js → openai-responses-shared-ULQmXcCD.js} +4 -4
  64. package/dist/ui/assets/{openrouter-D_A0LLAn.js → openrouter-BPF_Du_N.js} +1 -1
  65. package/dist/ui/assets/{openrouter-YF0qDkZL.js → openrouter-QoFhCA5x.js} +1 -1
  66. package/dist/ui/assets/openrouter-images-1178rM_U.js +1 -0
  67. package/dist/ui/assets/openrouter-images-HP0r87fI.js +1 -0
  68. package/dist/ui/assets/{openrouter-models-Bu1Cy5AD.js → openrouter-models-DmontTTG.js} +1 -1
  69. package/dist/ui/assets/{openrouter-models-CfnkMx5-.js → openrouter-models-gCCUSdgw.js} +1 -1
  70. package/dist/ui/assets/{openrouter-oauth-BdvGV1hT.js → openrouter-oauth-Da9o3C2F.js} +1 -1
  71. package/dist/ui/assets/{openrouter-oauth-CWQNt3C8.js → openrouter-oauth-DqUqqCYO.js} +1 -1
  72. package/dist/ui/assets/openrouter.models-Byp0hyfF.js +1 -0
  73. package/dist/ui/assets/openrouter.models-C8HitxAG.js +1 -0
  74. package/dist/ui/assets/{panel-rpc-handlers-DH5GGDDd.js → panel-rpc-handlers-DKpka_10.js} +2 -2
  75. package/dist/ui/assets/pi-messages-BcCsdrH5.js +7 -0
  76. package/dist/ui/assets/pi-messages-CrwvmK0e.js +7 -0
  77. package/dist/ui/assets/{provider-BV6eZmoA.js → provider-BA7z134_.js} +2 -2
  78. package/dist/ui/assets/{provider--bQJkc5T.js → provider-sepH36Nw.js} +1 -1
  79. package/dist/ui/assets/{provider-settings-BAT6df9n.js → provider-settings-CRF2kKcK.js} +1 -1
  80. package/dist/ui/assets/{provider-settings-DzNWqjkF.js → provider-settings-D5WKqwpE.js} +1 -1
  81. package/dist/ui/assets/provider-store-access-B40OdlSt.js +2 -0
  82. package/dist/ui/assets/provider-store-access-bbQatTup.js +1 -0
  83. package/dist/ui/assets/providers-BzxrP4Hq.js +2 -0
  84. package/dist/ui/assets/{providers-id1wrHDJ.js → providers-C26ABraX.js} +1 -1
  85. package/dist/ui/assets/{quick-llm-w90NI9-v.js → quick-llm-t2DQRu1Y.js} +1 -1
  86. package/dist/ui/assets/{redirect-uri-D1Ck0rOI.js → redirect-uri-CR_ilbaG.js} +1 -1
  87. package/dist/ui/assets/{session-freezer-DMTLWQpb.js → session-freezer-CUKxmO0P.js} +3 -3
  88. package/dist/ui/assets/{setup-feature-flags-remote-DhuliMqP.js → setup-feature-flags-remote-HN29QXlD.js} +1 -1
  89. package/dist/ui/assets/{setup-standalone-prelude-kjwkWB9z.js → setup-standalone-prelude-DdcmJUGt.js} +1 -1
  90. package/dist/ui/assets/setup-sudo-BFwfxRmv.js +2 -0
  91. package/dist/ui/assets/{skills-BvarZh19.js → skills-Cujpe9Kq.js} +1 -1
  92. package/dist/ui/assets/sprinkle-manager-DbCWJGba.js +1 -0
  93. package/dist/ui/assets/{sprinkle-renderer-oLgy--3J.js → sprinkle-renderer-DZ_7mdV4.js} +3 -3
  94. package/dist/ui/assets/{src-BTviaay1.js → src-CEt1Bu14.js} +190 -233
  95. package/dist/ui/assets/{store-6Or6yQCn.js → store-D6p4BCww.js} +1 -1
  96. package/dist/ui/assets/{sudo-rNEZM9VR.js → sudo-zNk3uG8n.js} +1 -1
  97. package/dist/ui/assets/{theme-C8b_iQ_9.js → theme-BOdTMzQ7.js} +1 -1
  98. package/dist/ui/assets/theme-engine-BMhxbTGC.js +3 -0
  99. package/dist/ui/assets/transform-messages-D27pVLZ-.js +1 -0
  100. package/dist/ui/assets/transform-messages-DgR3h-Ck.js +1 -0
  101. package/dist/ui/assets/{upgrade-detection-BLm2WdEO.js → upgrade-detection-64-kAIzr.js} +1 -1
  102. package/dist/ui/assets/{wc-attach-7hrcOh0v.js → wc-attach-Cq2ws1YL.js} +2 -2
  103. package/dist/ui/assets/{wc-extension-BOYGDoDe.js → wc-extension-CyL1zCEX.js} +2 -2
  104. package/dist/ui/assets/{wc-follower-DaAimIhN.js → wc-follower-BpcrgNk2.js} +3 -3
  105. package/dist/ui/assets/wc-live-D7E7KhSJ.js +8 -0
  106. package/dist/ui/assets/{wc-nav-B8uMwG_o.js → wc-nav-CJNNkXLC.js} +2 -2
  107. package/dist/ui/assets/{wc-onboarding-CMf55U73.js → wc-onboarding-BmBe2z97.js} +2 -2
  108. package/dist/ui/assets/{wc-placeholder-ComAbt41.js → wc-placeholder-5YpXlSbB.js} +2 -2
  109. package/dist/ui/assets/{wc-settings-BqqP9tNw.js → wc-settings-bMvADJAg.js} +3 -3
  110. package/dist/ui/assets/{wc-shell-DZs5ls6O.js → wc-shell-Z9bBLCqP.js} +4 -4
  111. package/dist/ui/assets/{wc-sprinkles-m8vl63Ub.js → wc-sprinkles-CG91alBG.js} +2 -2
  112. package/dist/ui/assets/wc-tray-BtZWoIdJ.js +2 -0
  113. package/dist/ui/assets/wc-tray-scoops-DIT9CbNq.js +5 -0
  114. package/dist/ui/assets/xai-grok-Bkec2E69.js +1 -0
  115. package/dist/ui/assets/xai-grok-C5JWIQiB.js +1 -0
  116. package/dist/ui/index.html +13 -13
  117. package/dist/ui/packages/webapp/index.html +13 -13
  118. package/package.json +7 -6
  119. package/dist/ui/assets/account-store-DIVNUQIo.js +0 -43
  120. package/dist/ui/assets/account-store-DcRnavVA.js +0 -101
  121. package/dist/ui/assets/adobe-CF_jJ0UM.js +0 -1
  122. package/dist/ui/assets/adobe-D_SNyGSN.js +0 -2
  123. package/dist/ui/assets/anthropic-messages-BFic5zKY.js +0 -39
  124. package/dist/ui/assets/azure-openai-CxtqP-NJ.js +0 -1
  125. package/dist/ui/assets/azure-openai-Djl4rJs-.js +0 -1
  126. package/dist/ui/assets/azure-openai-responses-B_twhN44.js +0 -1
  127. package/dist/ui/assets/azure-openai-responses-CzG7X9qb.js +0 -1
  128. package/dist/ui/assets/bedrock-camp-CJY4i7di.js +0 -1
  129. package/dist/ui/assets/bedrock-camp-DS0ilb3O.js +0 -1
  130. package/dist/ui/assets/cerebras-BGrvllaj.js +0 -1
  131. package/dist/ui/assets/cerebras-Ba5_8dhF.js +0 -1
  132. package/dist/ui/assets/compat-CkpNnFQS.js +0 -2
  133. package/dist/ui/assets/diagnostics-BsVbaNHR.js +0 -1
  134. package/dist/ui/assets/dist-BhEJb2Dl.js +0 -2
  135. package/dist/ui/assets/dist-Bj10RLrf.js +0 -2
  136. package/dist/ui/assets/error-body-C0EnfbdK.js +0 -1
  137. package/dist/ui/assets/fs-BMKjfoBZ.js +0 -2
  138. package/dist/ui/assets/github-0TMFcANZ.js +0 -2
  139. package/dist/ui/assets/github-copilot-B9_AQHaE.js +0 -2
  140. package/dist/ui/assets/github-copilot-DNN7ukUL.js +0 -1
  141. package/dist/ui/assets/google-generative-ai-4YtIu_sJ.js +0 -1
  142. package/dist/ui/assets/google-generative-ai-DzD1vsXe.js +0 -1
  143. package/dist/ui/assets/google-vertex-8lUayXF0.js +0 -1
  144. package/dist/ui/assets/google-vertex-oQOD3HKr.js +0 -1
  145. package/dist/ui/assets/models-Bnh9VDA1.js +0 -1
  146. package/dist/ui/assets/openai-codex-DP-I3MPQ.js +0 -1
  147. package/dist/ui/assets/openai-codex-GH6Gu6dQ.js +0 -1
  148. package/dist/ui/assets/openai-codex-responses-DRR6raXn.js +0 -7
  149. package/dist/ui/assets/openai-codex-responses-DU5CHdDQ.js +0 -7
  150. package/dist/ui/assets/openai-completions-B9S6450Q.js +0 -5
  151. package/dist/ui/assets/openai-completions-DhKgaAgM.js +0 -5
  152. package/dist/ui/assets/openai-responses-C4_jiYtu.js +0 -1
  153. package/dist/ui/assets/openai-responses-DmKhLxzV.js +0 -1
  154. package/dist/ui/assets/openrouter-images-6_MxZkJZ.js +0 -1
  155. package/dist/ui/assets/openrouter-images-BixC5B6a.js +0 -1
  156. package/dist/ui/assets/openrouter.models-DS1_VkCm.js +0 -1
  157. package/dist/ui/assets/openrouter.models-HnnH-abS.js +0 -1
  158. package/dist/ui/assets/pi-messages-DRdk3sMN.js +0 -7
  159. package/dist/ui/assets/pi-messages-fKU_b1SK.js +0 -7
  160. package/dist/ui/assets/provider-store-access-D3z7HxfS.js +0 -2
  161. package/dist/ui/assets/provider-store-access-DP-G6pVf.js +0 -1
  162. package/dist/ui/assets/providers-BqGRsgfs.js +0 -2
  163. package/dist/ui/assets/setup-sudo-DUk8aFKL.js +0 -2
  164. package/dist/ui/assets/sprinkle-manager-HaNmX2ye.js +0 -1
  165. package/dist/ui/assets/theme-engine-jfuTMXZM.js +0 -3
  166. package/dist/ui/assets/transform-messages-Bp94o3FD.js +0 -1
  167. package/dist/ui/assets/transform-messages-wECJwtH0.js +0 -1
  168. package/dist/ui/assets/wc-floatbar-online-B6FIfDc-.js +0 -5
  169. package/dist/ui/assets/wc-live-BZ18v3RK.js +0 -8
  170. package/dist/ui/assets/wc-tray-BAQeWy1x.js +0 -2
  171. package/dist/ui/assets/xai-grok-Cnf1-HJF.js +0 -1
  172. package/dist/ui/assets/xai-grok-QAH8xapu.js +0 -1
@@ -0,0 +1,101 @@
1
+ import{n as e,t}from"./rolldown-runtime-aKtaBQYM.js";import{t as n}from"./logger-LESFN7Hj.js";import{n as r,r as i}from"./panel-rpc-CjFVE0nK.js";import{n as a,o,t as s}from"./providers-C26ABraX.js";import"./src-BcePBv4G.js";import{r as c,s as l,t as u}from"./proxied-fetch-GabK83LB.js";import{t as d}from"./runtime-env-byAg9ij-.js";import{i as f,r as p}from"./tool-ui-t6ocn6AG.js";import{t as m}from"./port-bridge-client-DXYvHFiB.js";import{n as h,r as g,t as ee}from"./tool-result-images-AGln5sut.js";import{c as _,d as v,f as te,l as ne,r as re,t as ie,u as ae}from"./bedrock-camp-CHi38ceE.js";const oe=`slicc_oauth_extra_domains`;function se(e){try{let t=e.getItem(oe);if(!t)return{};let n=JSON.parse(t);if(typeof n!=`object`||!n||Array.isArray(n))return{};let r={};for(let[e,t]of Object.entries(n)){if(typeof e!=`string`||!Array.isArray(t))continue;let n=t.filter(e=>typeof e==`string`&&e.length>0);n.length>0&&(r[e]=n)}return r}catch{return{}}}function ce(e,t){try{e.setItem(oe,JSON.stringify(t))}catch(e){throw Error(`Failed to persist OAuth extras (localStorage quota exceeded?): ${e instanceof Error?e.message:String(e)}`)}}function le(){return d()?`extension-direct`:c()?`extension-delegate`:globalThis.__slicc_connect_mode?`connect`:`node-rest`}function ue(){return le()===`node-rest`}const y={assign:0,create:0,clone:0,discard:0,update:0};function b(e,t){return y.assign+=1,{...e,...t}}function de(e,t,n){return e>=t&&e<=n}function fe(e){return e===8205}function pe(e){return de(e,55296,56319)}function me(e){return de(e,127462,127487)}function he(e){return de(e,65024,65039)}function ge(e){return de(e,768,879)||de(e,6832,6911)||de(e,7616,7679)||de(e,65056,65071)}function _e(e){return e>65535?2:1}function ve(e,t){for(;t<e.length;){let n=e.codePointAt(t);if(ge(n)||he(n))t+=_e(n);else break}return t}function ye(e,t){let n=e.codePointAt(t),r=t+_e(n);for(r=ve(e,r);r<e.length-1&&e[r]===`‍`;){let t=e.codePointAt(r+1);r+=1+_e(t),r=ve(e,r)}return me(n)&&r<e.length&&me(e.codePointAt(r))&&(r+=_e(e.codePointAt(r))),r}function be(e){return pe(e)||ge(e)||he(e)||fe(e)}function xe(e){let t=0,n=0;for(;n<e.length;)n=ye(e,n),t++;return t}function Se(e,t){if(t===0)return!0;let n=0,r=0;for(;r<e.length;)if(r=ye(e,r),n++,n>=t)return!0;return!1}function Ce(e,t){let n=0,r=0;for(;r<e.length;)if(r=ye(e,r),n++,n>t)return!1;return!0}function we(e,t){if(t===0)return!0;let n=0;for(;n<e.length;){if(be(e.charCodeAt(n)))return Se(e,t);if(n++,n>=t)return!0}return!1}function Te(e,t){let n=0;for(;n<e.length;){if(be(e.charCodeAt(n)))return Ce(e,t);if(n++,n>t)return!1}return!0}var Ee=e({Entries:()=>$e,EntriesRegExp:()=>Qe,Every:()=>Ye,EveryAll:()=>Xe,GraphemeCount:()=>Ke,HasPropertyKey:()=>w,IsArray:()=>De,IsBigInt:()=>Oe,IsBoolean:()=>ke,IsClassInstance:()=>We,IsConstructor:()=>Ae,IsDeepEqual:()=>it,IsEqual:()=>S,IsFunction:()=>je,IsGreaterEqualThan:()=>He,IsGreaterThan:()=>ze,IsInteger:()=>Me,IsLessEqualThan:()=>Ve,IsLessThan:()=>Be,IsMaxLength:()=>qe,IsMinLength:()=>Je,IsMultipleOf:()=>Ue,IsNull:()=>Ne,IsNumber:()=>Pe,IsObject:()=>x,IsObjectNotArray:()=>Fe,IsString:()=>Ie,IsSymbol:()=>Le,IsUndefined:()=>Re,IsUnsafePropertyKey:()=>Ze,IsValueLike:()=>Ge,Keys:()=>T,ShiftLeft:()=>C,Symbols:()=>et,Values:()=>tt});function De(e){return Array.isArray(e)}function Oe(e){return S(typeof e,`bigint`)}function ke(e){return S(typeof e,`boolean`)}function Ae(e){if(Re(e)||!je(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function je(e){return S(typeof e,`function`)}function Me(e){return Number.isInteger(e)}function Ne(e){return S(e,null)}function Pe(e){return Number.isFinite(e)}function Fe(e){return x(e)&&!De(e)}function x(e){return S(typeof e,`object`)&&!Ne(e)}function Ie(e){return S(typeof e,`string`)}function Le(e){return S(typeof e,`symbol`)}function Re(e){return S(e,void 0)}function S(e,t){return e===t}function ze(e,t){return e>t}function Be(e,t){return e<t}function Ve(e,t){return e<=t}function He(e,t){return e>=t}function Ue(e,t){if(Oe(e)||Oe(t))return BigInt(e)%BigInt(t)===0n;if(!Pe(e)||Me(e)&&1/t%1==0)return!0;let n=e%t;return Math.min(Math.abs(n),Math.abs(n-t),Math.abs(n+t))<1e-10}function We(e){if(!x(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return!Ne(t)&&S(typeof t.constructor,`function`)&&!(S(t.constructor,globalThis.Object)||S(t.constructor.name,`Object`))}function Ge(e){return Oe(e)||ke(e)||Ne(e)||Pe(e)||Ie(e)||Re(e)}function Ke(e){return xe(e)}function qe(e,t){return Te(e,t)}function Je(e,t){return we(e,t)}function Ye(e,t,n){for(let r=t;r<e.length;r++)if(!n(e[r],r))return!1;return!0}function Xe(e,t,n){let r=!0;for(let i=t;i<e.length;i++)n(e[i],i)||(r=!1);return r}function C(e,t,n){return S(e.length,0)?n():t(e[0],e.slice(1))}function Ze(e){return S(e,`__proto__`)||S(e,`constructor`)||S(e,`prototype`)}function w(e,t){return Ze(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function Qe(e){return T(e).map(t=>[RegExp(`^${t}$`),e[t]])}function $e(e){return Object.entries(e)}function T(e){return Object.getOwnPropertyNames(e)}function et(e){return Object.getOwnPropertySymbols(e)}function tt(e){return Object.values(e)}function nt(e,t){if(!x(t))return!1;let n=T(e);return S(n.length,T(t).length)&&n.every(n=>it(e[n],t[n]))}function rt(e,t){return De(t)&&S(e.length,t.length)&&e.every((n,r)=>it(e[r],t[r]))}function it(e,t){return De(e)?rt(e,t):x(e)?nt(e,t):S(e,t)}function at(e){return e instanceof Boolean}function ot(e){return e instanceof Number}function st(e){return e instanceof String}function ct(e){return globalThis.ArrayBuffer.isView(e)}function lt(e){return e instanceof globalThis.RegExp}function ut(e){return e instanceof globalThis.Date}function dt(e){return e instanceof globalThis.Set}function ft(e){return e instanceof globalThis.Map}function pt(e){return e}function mt(e){return w(e,`~kind`)||w(e,`~unsafe`)}function ht(e){let t={},n=Object.getOwnPropertyDescriptors(e);for(let e of Object.keys(n)){if(Ze(e))continue;let r=n[e];w(r,`value`)&&Object.defineProperty(t,e,{...r,value:Ct(r.value)})}return t}function gt(e){let t={};for(let n of T(e))Ze(n)||(t[n]=Ct(e[n]));for(let n of et(e))t[n]=Ct(e[n]);return t}function _t(e){return We(e)?pt(e):mt(e)?ht(e):gt(e)}function vt(e){return e.map(e=>Ct(e))}function yt(e){return e.slice()}function bt(e){return new RegExp(e.source,e.flags)}function xt(e){return new Map(Ct([...e.entries()]))}function St(e){return new Set(Ct([...e.values()]))}function Ct(e){return ct(e)?yt(e):lt(e)?bt(e):ft(e)?xt(e):dt(e)?St(e):De(e)?vt(e):x(e)?_t(e):e}function wt(e){return y.clone+=1,Ct(e)}const Tt={immutableTypes:!1,maxErrors:8,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function Et(){return Tt}function Dt(e,t){for(let n of Object.keys(t))Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:!1,value:t[n]});return e}function Ot(e,t){return{...e,...t}}function E(e,t,n={}){y.create+=1;let r=Et(),i=Ot(t,n),a=r.enumerableKind?Ot(i,e):Dt(i,e);return r.immutableTypes?Object.freeze(a):a}function kt(e,t){y.discard+=1;let n={},r=Object.getOwnPropertyDescriptors(wt(e)),i=new Set(t);for(let e of Object.keys(r))i.has(e)||Object.defineProperty(n,e,r[e]);return n}function D(e,t,n){y.update+=1;let r=Et(),i=wt(e);for(let e of Object.keys(t))Object.defineProperty(i,e,{configurable:!0,writable:!0,enumerable:r.enumerableKind,value:t[e]});for(let e of Object.keys(n))Object.defineProperty(i,e,{configurable:!0,enumerable:!0,writable:!0,value:n[e]});return i}function O(e,t){return x(e)&&w(e,`~kind`)&&S(e[`~kind`],t)}function At(e){return x(e)}function k(e,t,n){return E({"~kind":`Deferred`},{type:`deferred`,action:e,parameters:t,options:n},{})}function jt(e){return O(e,`Deferred`)}function Mt(e){return D(e,{"~readonly":!0},{})}function Nt(e,t){return D(Mt(e),{},t)}function Pt(e,t,n,r){return Nt(q(e,t,n),r)}function Ft(e){return D(e,{"~optional":!0},{})}function It(e,t){return D(Ft(e),{},t)}function Lt(e,t,n,r){return It(q(e,t,n),r)}function Rt(e,t){return E({"~kind":`Array`},{type:`array`,items:e},t)}function zt(e){return O(e,`Array`)}function Bt(e){return kt(e,[`~kind`,`type`,`items`])}function Vt(e,t,n={}){return E({"~kind":`Constructor`},{type:`constructor`,parameters:e,instanceType:t},n)}function Ht(e){return O(e,`Constructor`)}function Ut(e){return kt(e,[`~kind`,`type`,`parameters`,`instanceType`])}function Wt(e,t,n={}){return E({"~kind":`Function`},{type:`function`,parameters:e,returnType:t},n)}function Gt(e){return O(e,`Function`)}function Kt(e){return kt(e,[`~kind`,`type`,`parameters`,`returnType`])}function qt(e,t){return E({"~kind":`Ref`},{$ref:e},t)}function Jt(e){return O(e,`Ref`)}function Yt(e,t){return E({"~kind":`Generic`},{type:`generic`,parameters:e,expression:t})}function Xt(e){return O(e,`Generic`)}function Zt(e){return E({"~kind":`Any`},{},e)}function Qt(e){return O(e,`Any`)}function $t(e){return E({"~kind":`Never`},{not:{}},e)}function en(e){return O(e,`Never`)}function tn(e,t={}){return It(e,t)}function nn(e){return tn(e)}function rn(e){return At(e)&&w(e,`~optional`)}function an(e){return T(e).filter(t=>!rn(e[t]))}function on(e){return T(e)}function sn(e){return tt(e)}function A(e,t={}){let n=an(e);return E({"~kind":`Object`},{type:`object`,...n.length>0?{required:n}:{},properties:e},t)}function j(e){return O(e,`Object`)}function cn(e){return kt(e,[`~kind`,`type`,`properties`,`required`])}function ln(e){return E({"~kind":`Unknown`},{},e)}function un(e){return O(e,`Unknown`)}function dn(e,t,n){return E({"~kind":`Cyclic`},{$defs:T(e).reduce((t,n)=>({...t,[n]:D(e[n],{},{$id:n})}),{}),$ref:t},n)}function fn(e){return O(e,`Cyclic`)}function pn(e){return Fe(e)&&w(e,`~unsafe`)&&Ne(e[`~unsafe`])}function mn(e){return O(e,`Infer`)}function hn(e,t,n,r={}){return E({"~kind":`Dependent`},{if:e,then:t,else:n},r)}function gn(e){return O(e,`Dependent`)}function _n(e){return kt(e,[`~kind`,`if`,`then`,`else`])}function vn(e){return O(e,`Enum`)}function yn(e,t={}){return E({"~kind":`Intersect`},{allOf:e},t)}function M(e){return O(e,`Intersect`)}function bn(e){return kt(e,[`~kind`,`allOf`])}function xn(){throw Error(`Unreachable`)}var Sn=e({Hash:()=>Yn,HashCode:()=>Jn});function Cn(e){let t=new Set,n=e;for(;n&&n!==Object.prototype;){for(let e of Reflect.ownKeys(n))e!==`constructor`&&typeof e!=`symbol`&&t.add(e);n=Object.getPrototypeOf(n)}return[...t]}function wn(e){return typeof e==`number`}var N;(function(e){e[e.Array=0]=`Array`,e[e.BigInt=1]=`BigInt`,e[e.Boolean=2]=`Boolean`,e[e.Date=3]=`Date`,e[e.Constructor=4]=`Constructor`,e[e.Function=5]=`Function`,e[e.Null=6]=`Null`,e[e.Number=7]=`Number`,e[e.Object=8]=`Object`,e[e.RegExp=9]=`RegExp`,e[e.String=10]=`String`,e[e.Symbol=11]=`Symbol`,e[e.TypeArray=12]=`TypeArray`,e[e.Undefined=13]=`Undefined`})(N||={});let Tn=BigInt(`14695981039346656037`);const[En,Dn]=[BigInt(`1099511628211`),BigInt(`18446744073709551616`)],On=Array.from({length:256}).map((e,t)=>BigInt(t)),kn=new Float64Array(1),An=new DataView(kn.buffer),jn=new Uint8Array(kn.buffer);function P(e){Tn^=On[e],Tn=Tn*En%Dn}function Mn(e){P(N.Array);for(let t of e)qn(t)}function Nn(e){P(N.BigInt),An.setBigInt64(0,e);for(let e of jn)P(e)}function Pn(e){P(N.Boolean),P(+!!e)}function Fn(e){P(N.Constructor),qn(e.toString())}function In(e){P(N.Date),qn(e.getTime())}function Ln(e){P(N.Function),qn(e.toString())}function Rn(e){P(N.Null)}function zn(e){P(N.Number),An.setFloat64(0,e,!0);for(let e of jn)P(e)}function Bn(e){P(N.Object);for(let t of Cn(e).sort())qn(t),qn(e[t])}function Vn(e){P(N.RegExp),Un(e.toString())}const Hn=new TextEncoder;function Un(e){P(N.String);for(let t of Hn.encode(e))P(t)}function Wn(e){P(N.Symbol),qn(e.toString())}function Gn(e){P(N.TypeArray);let t=new Uint8Array(e.buffer);for(let e=0;e<t.length;e++)P(t[e])}function Kn(e){return P(N.Undefined)}function qn(e){return ct(e)?Gn(e):ut(e)?In(e):lt(e)?Vn(e):at(e)?Pn(e.valueOf()):st(e)?Un(e.valueOf()):ot(e)?zn(e.valueOf()):wn(e)?zn(e):De(e)?Mn(e):ke(e)?Pn(e):Oe(e)?Nn(e):Ae(e)?Fn(e):Ne(e)?Rn(e):x(e)?Bn(e):Ie(e)?Un(e):Le(e)?Wn(e):Re(e)?Kn(e):je(e)?Ln(e):xn()}function Jn(e){return Tn=BigInt(`14695981039346656037`),qn(e),Tn}function Yn(e){return Jn(e).toString(16).padStart(16,`0`)}function Xn(e){return At(e)&&w(e,`~codec`)&&x(e[`~codec`])&&w(e[`~codec`],`encode`)&&w(e[`~codec`],`decode`)}function Zn(e){return At(e)&&w(e,`~immutable`)}function Qn(e,t={}){return Nt(e,t)}function $n(e){return At(e)&&w(e,`~readonly`)}function er(e){return E({"~kind":`BigInt`},{type:`bigint`},e)}function tr(e){return O(e,`BigInt`)}function nr(e){return O(e,`Boolean`)}const rr=`-?(?:0|[1-9][0-9]*)`;function ir(e){return E({"~kind":`Integer`},{type:`integer`},e)}function ar(e){return O(e,`Integer`)}var or=class extends Error{constructor(e){super(`Invalid Literal value`),Object.defineProperty(this,"cause",{value:{value:e},writable:!1,configurable:!1,enumerable:!1})}};function sr(e){return Oe(e)?`bigint`:ke(e)?`boolean`:Pe(e)?`number`:Ie(e)?`string`:(()=>{throw new or(e)})()}function F(e,t){return E({"~kind":`Literal`},{type:sr(e),const:e},t)}function cr(e){return Oe(e)||ke(e)||Pe(e)||Ie(e)}function lr(e){return I(e)&&Oe(e.const)}function ur(e){return I(e)&&ke(e.const)}function dr(e){return I(e)&&Pe(e.const)}function fr(e){return I(e)&&Ie(e.const)}function I(e){return O(e,`Literal`)}function pr(e){return E({"~kind":`Null`},{type:`null`},e)}function mr(e){return O(e,`Null`)}const hr=`-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?`;function gr(e){return E({"~kind":`Number`},{type:`number`},e)}function _r(e){return O(e,`Number`)}function vr(e){return E({"~kind":`Symbol`},{type:`symbol`},e)}function yr(e){return O(e,`Symbol`)}function br(e){return E({"~kind":`String`},{type:`string`},e)}function xr(e){return O(e,`String`)}function L(e,t={}){return E({"~kind":`Union`},{anyOf:e},t)}function R(e){return O(e,`Union`)}function Sr(e){return kt(e,[`~kind`,`anyOf`])}function Cr(e){let t=Ka(e);return S(t.length,2)?t[0]:[]}function wr(e){return!0}function Tr(e){return C(e,(e,t)=>Dr(e)?Tr(t):!1,()=>!0)}function Er(e){return!S(e.length,0)&&Tr(e)}function Dr(e){return R(e)?Er(e.anyOf):I(e)?wr(e.const):!1}function Or(e){return Er(e)}function kr(e){return E({"~kind":`TemplateLiteral`},{type:`string`,pattern:e},{})}function Ar(e,t,n=[]){return C(e,(e,r)=>Ar(r,t,[...n,`${e}${t}`]),()=>n)}function jr(e,t){return S(e.length,0)?[`${t}`]:Ar(e,t)}function Mr(e,t,n=[]){return C(t,(t,r)=>Mr(e,r,[...n,...Nr(e,t)]),()=>n)}function Nr(e,t){return R(t)?Mr(e,t.anyOf):I(t)?jr(e,t.const):xn()}function Pr(e,t){return C(t,(t,n)=>Pr(Nr(e,t),n),()=>e)}function Fr(e){return e.map(e=>F(e))}function Ir(e){return L(Fr(Pr([],e)))}function Lr(e){return S(e.length,0)?xn():S(e.length,1)&&I(e[0])?e[0]:Ir(e)}function Rr(e){let t=Cr(e);return S(t.length,0)?br():Or(t)?Lr(t):kr(e)}function zr(e){let t=Rr(e);return mo(t)?br():t}function Br(e,t){return E({"~kind":`Record`},{type:`object`,patternProperties:{[e]:t}})}function Vr(e){return Br(Wi,e)}function Hr(e){return A({true:e,false:e})}function Ur(e,t={}){let[n,r,i]=[e,e.length,!1];return E({"~kind":`Tuple`},{type:`array`,additionalItems:i,items:n,minItems:r},t)}function z(e){return O(e,`Tuple`)}function Wr(e){return kt(e,[`~kind`,`type`,`items`,`minItems`,`additionalItems`])}function Gr(e){return kt(e,[`~readonly`])}function Kr(e,t){return D(Gr(e),{},t)}function qr(e,t,n,r){return Kr(q(e,t,n),r)}function Jr(e,t={}){return Kr(e,t)}function Yr(e){return kt(e,[`~optional`])}function Xr(e,t){return D(Yr(e),{},t)}function Zr(e,t,n,r){return Xr(q(e,t,n),r)}function Qr(e,t={}){return Xr(e,t)}function $r(e){return e.reduceRight((e,t,n)=>({[n]:t,...e}),{})}function ei(e){return A($r(e.items))}function ti(e,t){return $n(e)?!!$n(t):!1}function ni(e,t){return rn(e)?!!rn(t):!1}function ri(e,t){let n=ti(e,t),r=ni(e,t),i=Jr(Qr(bi([e,t])));return n&&r?Qn(tn(i)):n&&!r?Qn(i):!n&&r?tn(i):i}function ii(e,t,n){return n in e?n in t?ri(e[n],t[n]):e[n]:n in t?t[n]:$t()}function ai(e,t){return[...new Set([...T(t),...T(e)])].reduce((n,r)=>({...n,[r]:ii(e,t,r)}),{})}function oi(e){return j(e)?e.properties:z(e)?$r(e.items):xn()}function si(e,t){return A(ai(oi(e),oi(t)))}function ci(e,t){let n=pc(e,t);return S(n,`left-inside`)?e:S(n,`right-inside`)||S(n,`equal`)?t:$t()}function li(e){return j(e)||z(e)}function ui(e,t){let n=R(e),r=R(t);return n||r}function di(e,t){let n=Ci(e),r=Ci(t),i=ui(n,r),a=li(n),o=li(r);return i?bi([n,r]):a&&o?si(n,r):a&&!o?n:!a&&o?r:ci(n,r)}function fi(e,t,n=[]){return C(t,(t,r)=>fi(e,r,[...n,di(e,t)]),()=>S(n.length,0)?[e]:n)}function pi(e,t,n=[]){return C(e,(e,r)=>pi(r,t,[...n,...mi([e],t)]),()=>n)}function mi(e,t=[]){return C(e,(e,n)=>R(e)?mi(n,pi(e.anyOf,t)):mi(n,fi(e,t)),()=>t)}function hi(e,t){return yo(fc({},e,t))?[]:[e]}function gi(e,t){return e.reduce((e,n)=>[...e,...hi(n,t)],[])}function _i(e,t){let n=Ci(e);return Si(gi(R(n)?n.anyOf:[n],t))}function vi(e,t,n){return Si([yn([e,t]),_i(n,e)])}function yi(e){return Si(e.map(e=>F(e)))}function bi(e){return wi(vc(mi(e)))}function xi(e){return Ci(zr(e))}function Si(e){return wi(vc(e))}function Ci(e){return gn(e)?vi(e.if,e.then,e.else):vn(e)?yi(e.enum):M(e)?bi(e.allOf):mo(e)?xi(e.pattern):R(e)?Si(e.anyOf):e}function wi(e){return S(e.length,1)?e[0]:S(e.length,0)?$t():L(e)}function Ti(e,t){return zi(yi(e),t)}function Ei(e,t){return Br(Hi,t)}function Di(e,t){return zi(bi(e),t)}function Oi(e,t){return Ie(e)||Pe(e)?A({[e]:t}):S(e,!1)?A({false:t}):S(e,!0)?A({true:t}):A({})}function ki(e,t){return Br(Ui,t)}function Ai(e,t){return w(e,`pattern`)&&(Ie(e.pattern)||e.pattern instanceof RegExp)?Br(e.pattern.toString(),t):Br(Wi,t)}function ji(e,t){return Or(Cr(e))?zi(xi(e),t):Br(e,t)}function Mi(e){return R(e)?Ni(e.anyOf):[e]}function Ni(e){return e.reduce((e,t)=>[...e,...Mi(t)],[])}function Pi(e){return e.some(e=>xr(e)||_r(e)||ar(e))}function Fi(e,t){return S(Pi(e),!0)?Br(Wi,t):void 0}function Ii(e,t){return e.reduce((e,n)=>I(n)&&(Ie(n.const)||Pe(n.const))?{...e,[n.const]:t}:e,{})}function Li(e,t){return A(Ii(e,t))}function Ri(e,t){let n=Ni(e),r=Fi(n,t);return At(r)?r:Li(n,t)}function zi(e,t){return Qt(e)?Vr(t):nr(e)?Hr(t):vn(e)?Ti(e.enum,t):ar(e)?Ei(e,t):M(e)?Di(e.allOf,t):I(e)?Oi(e.const,t):_r(e)?ki(e,t):R(e)?Ri(e.anyOf,t):xr(e)?Ai(e,t):mo(e)?ji(e.pattern,t):A({})}function Bi(e,t,n){return K([e])?D(zi(e,t),{},n):Gi(e,t,n)}function Vi(e,t,n,r,i){return Bi(q(e,t,n),q(e,t,r),i)}const Hi=`^${rr}$`,Ui=`^${hr}$`,Wi=`^.*$`;function Gi(e,t,n={}){return k(`Record`,[e,t],n)}function Ki(e,t,n={}){return Bi(e,t,n)}function qi(e,t){return Br(e,t)}function Ji(e){return S(e,Wi)?br():S(e,Hi)?ir():S(e,Ui)?gr():Rr(e)}function Yi(e){return T(e.patternProperties)[0]}function Xi(e){return Ji(Yi(e))}function Zi(e){return e.patternProperties[Yi(e)]}function Qi(e){return O(e,`Record`)}function $i(e){return E({"~kind":`Rest`},{type:`rest`,items:e},{})}function ea(e){return O(e,`Rest`)}function ta(e){return O(e,`This`)}function na(e){return E({"~kind":`Undefined`},{type:`undefined`},e)}function ra(e){return O(e,`Undefined`)}function ia(e){return O(e,`Void`)}function aa(e){return er()}function oa(e){return br()}function sa(e){return gr()}function ca(e){return ir()}function la(e){return $t()}function ua(e){return F(e)}function da(e){return e}function fa(e){return L(e[1])}function pa(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function ma(e){return[e[0],...e[1]]}function ha(e){return e}function ga(e){return e[1]}function _a(e){return S(e.length,2)}function va(e,t,n){return _a(e)?t(e[0],e[1]):n()}function ya(e,t){return S(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function ba(e,t){for(let n=0;n<e.length;n++){let r=ya(e[n],t);if(_a(r))return r}return[]}function xa(e,t){return Array.from({length:t-e+1},(t,n)=>String.fromCharCode(e+n))}const Sa=[...xa(97,122),...xa(65,90)],Ca=[`0`,...xa(49,57)];function wa(e){let t=e.indexOf(`*/`);return S(t,-1)?``:e.slice(t+2)}function Ta(e){let t=e.indexOf(`
2
+ `);return S(t,-1)?``:e.slice(t)}function Ea(e){return e.replace(/^[ \t\r\f\v]+/,``)}function Da(e){let t=Ea(e);return t.startsWith(`/*`)?Da(wa(t.slice(2))):t.startsWith(`//`)?Da(Ta(t.slice(2))):t}function Oa(e){let t=e.trimStart();return t.startsWith(`/*`)?Oa(wa(t.slice(2))):t.startsWith(`//`)?Oa(Ta(t.slice(2))):t}[...Ca];function ka(e,t){return ba([e],t)}function Aa(e,t){return S(e,``)?[``,t]:e.startsWith(`
3
+ `)?ka(e,Da(t)):e.startsWith(` `)?ka(e,t):ka(e,Oa(t))}[...Sa,...Ca],[...Ca];function ja(e){return S(e,``)?[]:[e.slice(0,1),e.slice(1)]}function Ma(e,t){return C(e,(e,n)=>t.startsWith(e)?!0:Ma(n,t),()=>!1)}function Na(e,t,n=``){return va(ja(t),(r,i)=>Ma(e,t)?[n,t]:Na(e,i,`${n}${r}`),()=>[])}function Pa(e,t){return va(Na(e,t),(e,t)=>S(e,``)?[]:[e,t],()=>[])}const B=(e,t,n=()=>[])=>e.length===2?t(e):n(),Fa=e=>B(Aa(`-?(?:0|[1-9][0-9]*)n`,e),([e,t])=>[aa(e),t]),Ia=e=>B(Aa(`.*`,e),([e,t])=>[oa(e),t]),La=e=>B(Aa(`-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?`,e),([e,t])=>[sa(e),t]),Ra=e=>B(Aa(`-?(?:0|[1-9][0-9]*)`,e),([e,t])=>[ca(e),t]),za=e=>B(Aa(`(?!)`,e),([e,t])=>[la(e),t]),Ba=e=>B(Pa([`-?(?:0|[1-9][0-9]*)n`,`.*`,`-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?`,`-?(?:0|[1-9][0-9]*)`,`(?!)`,`(`,`)`,`$`,`|`],e),([e,t])=>[ua(e),t]),Va=e=>B(B(Fa(e),([e,t])=>[e,t],()=>B(Ia(e),([e,t])=>[e,t],()=>B(La(e),([e,t])=>[e,t],()=>B(Ra(e),([e,t])=>[e,t],()=>B(za(e),([e,t])=>[e,t],()=>B(Ha(e),([e,t])=>[e,t],()=>B(Ba(e),([e,t])=>[e,t],()=>[]))))))),([e,t])=>[da(e),t]),Ha=e=>B(B(Aa(`(`,e),([e,t])=>B(Ga(t),([t,n])=>B(Aa(`)`,n),([n,r])=>[[e,t,n],r]))),([e,t])=>[fa(e),t]),Ua=e=>B(B(B(Wa(e),([e,t])=>B(Aa(`|`,t),([t,n])=>B(Ua(n),([n,r])=>[[e,t,n],r]))),([e,t])=>[e,t],()=>B(B(Wa(e),([e,t])=>[[e],t]),([e,t])=>[e,t],()=>B([[],e],([e,t])=>[e,t],()=>[]))),([e,t])=>[pa(e),t]),Wa=e=>B(B(Va(e),([e,t])=>B(Ga(t),([t,n])=>[[e,t],n])),([e,t])=>[ma(e),t]),Ga=e=>B(B(Ua(e),([e,t])=>[e,t],()=>B(Wa(e),([e,t])=>[e,t],()=>[])),([e,t])=>[ha(e),t]),Ka=e=>B(B(Aa(`^`,e),([e,t])=>B(Ga(t),([t,n])=>B(Aa(`$`,n),([n,r])=>[[e,t,n],r]))),([e,t])=>[ga(e),t]);function qa(e){return e.join(`|`)}function Ja(e){return e.slice(1,e.length-1)}function Ya(e,t,n){return oo(t,`${n}${e}`)}function Xa(e,t){return oo(e,`${t}-?(?:0|[1-9][0-9]*)n`)}function Za(e,t){return oo(e,`${t}${rr}`)}function Qa(e,t){return oo(e,`${t}${hr}`)}function $a(e,t){return ao(L([F(`false`),F(`true`)]),e,t)}function eo(e,t){return oo(e,`${t}.*`)}function to(e,t,n){return oo(t,`${n}${Ja(e)}`)}function no(e,t,n){return ao(lo(e,{}),t,n)}function ro(e,t,n){return ao(yi(e),t,n)}function io(e,t,n,r=[]){return C(e,(e,i)=>io(i,t,n,[...r,ao(e,[],``)]),()=>oo(t,`${n}(${qa(r)})`))}function ao(e,t,n){return vn(e)?ro(e.enum,t,n):ar(e)?Za(t,n):I(e)?Ya(e.const,t,n):tr(e)?Xa(t,n):nr(e)?$a(t,n):_r(e)?Qa(t,n):xr(e)?eo(t,n):mo(e)?to(e.pattern,t,n):po(e)?no(e.parameters[0],t,n):R(e)?io(e.anyOf,t,n):`(?!)`}function oo(e,t){return C(e,(e,n)=>ao(e,n,t),()=>t)}function so(e){return`^${oo(e,``)}$`}function co(e){return kr(so(e))}function lo(e,t){return K(e)?D(co(e),{},t):fo(e,t)}function uo(e,t,n,r){return lo(_f(e,t,n),r)}function fo(e,t={}){return k(`TemplateLiteral`,[e],t)}function po(e){return At(e)&&w(e,`action`)&&S(e.action,`TemplateLiteral`)}function mo(e){return O(e,`TemplateLiteral`)}function ho(e){return E({"~kind":`ExtendsUnion`},{inferred:e})}function go(e){return x(e)&&w(e,`~kind`)&&w(e,`inferred`)&&S(e[`~kind`],`ExtendsUnion`)&&x(e.inferred)}function V(e){return E({"~kind":`ExtendsTrue`},{inferred:e})}function _o(e){return x(e)&&w(e,`~kind`)&&w(e,`inferred`)&&S(e[`~kind`],`ExtendsTrue`)&&x(e.inferred)}function H(){return E({"~kind":`ExtendsFalse`},{})}function vo(e){return x(e)&&w(e,`~kind`)&&S(e[`~kind`],`ExtendsFalse`)}function yo(e){return go(e)||_o(e)}function U(e,t,n){return yo(e)?t(e.inferred):n()}function bo(e,t,n,r){return U(G(e,n,r),r=>V(b(b(e,r),{[t]:n})),()=>H())}function xo(e,t){return V(e)}function So(e,t,n,r,i){return U(G(e,t,n),e=>U(G(e,t,r),e=>V(e),()=>H()),()=>U(G(e,t,i),e=>V(e),()=>H()))}function Co(e,t,n){return G(e,t,yi(n))}function wo(e,t,n){return C(n,(n,r)=>U(G(e,t,n),e=>wo(e,t,r),()=>H()),()=>V(e))}function To(e,t,n){return G(e,t,xi(n))}function Eo(e,t,n){return C(n,(n,r)=>U(G(e,t,n),e=>V(e),()=>Eo(e,t,r)),()=>H())}function W(e,t,n){return Qt(n)?xo(e,t):gn(n)?So(e,t,n.if,n.then,n.else):vn(n)?Co(e,t,n.enum):mn(n)?bo(e,n.name,t,n.extends):M(n)?wo(e,t,n.allOf):mo(n)?To(e,t,n.pattern):R(n)?Eo(e,t,n.anyOf):un(n)?V(e):H()}function Do(e,t,n){return mn(n)?W(e,t,n):Qt(n)||un(n)?V(e):ho(e)}function Oo(e,t){let n=Zn(e),r=Zn(t);return n&&r||!n&&r?!0:!(n&&!r)}function ko(e,t,n,r){return zt(r)?Oo(t,r)?G(e,n,r.items):H():W(e,t,r)}function Ao(e,t,n){return tr(n)?V(e):W(e,t,n)}function jo(e,t,n){return nr(n)?V(e):W(e,t,n)}function Mo(e,t,n,r,i){let a=mn(r)?t:r,o=mn(r)?r:t,s=rn(t),c=rn(r);return!s&&c?H():U(G(e,a,o),e=>Fo(e,n,i),()=>H())}function No(e,t,n,r){return C(r,(r,i)=>Mo(e,t,n,r,i),()=>rn(t)?V(e):H())}function Po(e,t,n){return C(t,(t,r)=>No(e,t,r,n),()=>V(e))}function Fo(e,t,n){return Po(e,t,n)}function Io(e,t,n){return ia(n)?V(e):G(e,t,n)}function Lo(e,t,n,r){return Qt(r)||un(r)?V(e):Ht(r)?U(Fo(e,t,r.parameters),e=>Io(e,n,r.instanceType),()=>H()):H()}function Ro(e,t,n,r,i){return U(G(e,t,i),()=>G(e,n,i),()=>G(e,r,i))}function zo(e,t,n){return G(e,yi(t),n)}function Bo(e,t,n,r){return Qt(r)||un(r)?V(e):Gt(r)?U(Fo(e,t,r.parameters),e=>Io(e,n,r.returnType),()=>H()):H()}function Vo(e,t,n){return ar(n)||_r(n)?V(e):W(e,t,n)}function Ho(e,t,n){return G(e,bi(t),n)}function Uo(e,t,n){return t===n?V(e):H()}function Wo(e,t,n){return I(n)?Uo(e,t,n.const):tr(n)?V(e):W(e,F(t),n)}function Go(e,t,n){return I(n)?Uo(e,t,n.const):nr(n)?V(e):W(e,F(t),n)}function Ko(e,t,n){return I(n)?Uo(e,t,n.const):_r(n)?V(e):W(e,F(t),n)}function qo(e,t,n){return I(n)?Uo(e,t,n.const):xr(n)?V(e):W(e,F(t),n)}function Jo(e,t,n){return Oe(t.const)?Wo(e,t.const,n):ke(t.const)?Go(e,t.const,n):Pe(t.const)?Ko(e,t.const,n):Ie(t.const)?qo(e,t.const,n):xn()}function Yo(e,t,n){return mn(n)?W(e,t,n):V(e)}function Xo(e,t,n){return mr(n)?V(e):W(e,t,n)}function Zo(e,t,n){return _r(n)?V(e):W(e,t,n)}function Qo(e,t,n){return rn(t)?rn(n)?V(e):H():V(e)}function $o(e,t,n){return mn(n)&&en(n.extends)?H():U(G(e,t,n),e=>Qo(e,t,n),()=>H())}function es(e,t){return e.reduce((e,n)=>n in t&&yo(t[n])?{...e,...t[n].inferred}:xn(),{})}function ts(e,t,n){let r={};for(let i of T(n))r[i]=i in t?$o({},t[i],n[i]):rn(n[i])?mn(n[i])?V(b(e,{[n[i].name]:n[i].extends})):V(e):H();let i=tt(r).every(e=>yo(e)),a=i?es(T(r),r):{};return i?V(a):H()}function ns(e,t,n){let r=ts(e,t,n);return yo(r)?V(b(e,r.inferred)):H()}function rs(e,t,n){return ns(e,t,n)}function is(e,t){return T(t).reduce((n,r)=>({...n,[r]:w(e,r)?R(n[r])?L([...n[r].anyOf,t[r]]):L([e[r],t[r]]):t[r]}),e)}function as(e,t,n,r){return C(t,(t,i)=>U(G({},e[t],n),t=>as(e,i,n,is(r,t)),()=>H()),()=>V(r))}function os(e,t,n,r){return as(t,T(t),r,e)}function ss(e,t,n){return Qi(n)?os(e,t,Yi(n),Zi(n)):j(n)?rs(e,t,n.properties):W(e,A(t),n)}function cs(e,t){return S(T(t).length,0)?V(e):H()}function ls(e,t,n,r,i){return G(e,n,i)}function us(e,t,n,r){return Qi(r)?ls(e,Ji(t),n,Ji(Yi(r)),Zi(r)):j(r)?cs(e,r.properties):Qt(r)||un(r)?V(e):H()}function ds(e,t,n){return xr(n)?V(e):W(e,t,n)}function fs(e,t,n){return yr(n)?V(e):W(e,t,n)}function ps(e,t,n){return G(e,xi(t),n)}function ms(e,t){return E({"~kind":`Inferrable`},{name:e,type:t},{})}function hs(e){return x(e)&&w(e,`~kind`)&&w(e,`name`)&&w(e,`type`)&&S(e[`~kind`],`Inferrable`)&&Ie(e.name)&&x(e.type)}function gs(e){return ea(e)?mn(e.items)?zt(e.items.extends)?ms(e.items.name,e.items.extends.items):un(e.items.extends)?ms(e.items.name,e.items.extends):void 0:xn():void 0}function _s(e){return mn(e)?ms(e.name,e.extends):void 0}function vs(e,t,n=[]){return C(e,(e,r)=>U(G({},e,t),()=>vs(r,t,[...n,e]),()=>void 0),()=>n)}function ys(e,t,n,r){let i=vs(n,r);return De(i)?V(b(e,{[t]:Ur(i)})):H()}function bs(e,t,n,r){let i=vs(n,r);return De(i)?V(b(e,{[t]:L(i)})):H()}function xs(e){return[...e].reverse()}function Ss(e,t){return t?xs(e):e}function Cs(e){let t=e.length>0?e[0]:void 0;return At(At(t)?gs(t):void 0)}function ws(e,t,n,r,i,a){return U(G(e,n,i),e=>Ds(e,t,r,a),()=>H())}function Ts(e,t,n,r,i){let a=gs(r);return hs(a)?ys(e,a.name,Ss(n,t),a.type):C(n,(n,a)=>ws(e,t,n,a,r,i),()=>H())}function Es(e,t,n,r){return C(r,(r,i)=>Ts(e,t,n,r,i),()=>S(n.length,0)?V(e):H())}function Ds(e,t,n,r){return Es(e,t,n,r)}function Os(e,t,n){let r=gf(e,mf([],[]),n),i=Cs(r);return Ds(e,i,Ss(t,i),Ss(r,i))}function ks(e,t,n){let r=_s(n);return hs(r)?bs(e,r.name,t,r.type):C(t,(t,r)=>U(G(e,t,n),e=>ks(e,r,n),()=>H()),()=>V(e))}function As(e,t,n){let r=gf(e,mf([],[]),t);return z(n)?Os(e,r,n.items):zt(n)?ks(e,r,n.items):W(e,Ur(r),n)}function js(e,t,n){return ia(n)||ra(n)?V(e):W(e,t,n)}function Ms(e,t,n){return C(n,(n,r)=>U(G(e,t,n),e=>V(e),()=>Ms(e,t,r)),()=>H())}function Ns(e,t,n){return C(t,(t,r)=>U(Ms(e,t,n),e=>Ns(e,r,n),()=>H()),()=>V(e))}function Ps(e,t,n){let r=_s(n);return hs(r)?bs(e,r.name,t,r.type):R(n)?Ns(e,t,n.anyOf):Ns(e,t,[n])}function Fs(e,t,n){return mn(n)?W(e,t,n):Qt(n)||un(n)?V(e):H()}function Is(e,t,n){return ia(n)?V(e):W(e,t,n)}function G(e,t,n){return Qt(t)?Do(e,t,n):zt(t)?ko(e,t,t.items,n):tr(t)?Ao(e,t,n):nr(t)?jo(e,t,n):Ht(t)?Lo(e,t.parameters,t.instanceType,n):gn(t)?Ro(e,t.if,t.then,t.else,n):vn(t)?zo(e,t.enum,n):Gt(t)?Bo(e,t.parameters,t.returnType,n):ar(t)?Vo(e,t,n):M(t)?Ho(e,t.allOf,n):I(t)?Jo(e,t,n):en(t)?Yo(e,t,n):mr(t)?Xo(e,t,n):_r(t)?Zo(e,t,n):j(t)?ss(e,t.properties,n):Qi(t)?us(e,Yi(t),Zi(t),n):xr(t)?ds(e,t,n):yr(t)?fs(e,t,n):mo(t)?ps(e,t.pattern,n):z(t)?As(e,t.items,n):ra(t)?js(e,t,n):R(t)?Ps(e,t.anyOf,n):un(t)?Fs(e,t,n):ia(t)?Is(e,t,n):H()}function Ls(e,t){return bi([...e,A(t)])}function Rs(e,t,n){return K(e)?D(Ls(e,t),{},n):Bs(e,t,n)}function zs(e,t,n,r,i){return Rs(_f(e,t,n),hf(e,t,r),i)}function Bs(e,t,n={}){return k(`Interface`,[e,t],n)}function Vs(e){return At(e)&&w(e,`action`)&&S(e.action,`Interface`)}function Hs(e,t,n){return e.includes(n)?!0:Gs([...e,n],t,t[n])}function Us(e,t,n){return Ws(e,t,sn(n))}function Ws(e,t,n){return C(n,(n,r)=>Gs(e,t,n)?!0:Ws(e,t,r),()=>!1)}function Gs(e,t,n){return Jt(n)?Hs(e,t,n.$ref):zt(n)?Gs(e,t,n.items):Ht(n)?Ws(e,t,[...n.parameters,n.instanceType]):Gt(n)?Ws(e,t,[...n.parameters,n.returnType]):Vs(n)?Us(e,t,n.parameters[1]):M(n)?Ws(e,t,n.allOf):j(n)?Us(e,t,n.properties):R(n)?Ws(e,t,n.anyOf):z(n)?Ws(e,t,n.items):Qi(n)?Gs(e,t,Zi(n)):!1}function Ks(e,t,n){return Gs(e,t,n)}function qs(e,t){return t.reduce((t,n)=>Ks([n],e,e[n])?[...t,n]:t,[])}function Js(e){return qs(e,on(e))}function Ys(e,t,n){return n.includes(t)?n:t in e?Qs(e,e[t],[...n,t]):xn()}function Xs(e,t,n){return Zs(e,sn(t),n)}function Zs(e,t,n){return t.reduce((t,n)=>Qs(e,n,t),n)}function Qs(e,t,n){return Jt(t)?Ys(e,t.$ref,n):zt(t)?Qs(e,t.items,n):Ht(t)?Zs(e,[...t.parameters,t.instanceType],n):Gt(t)?Zs(e,[...t.parameters,t.returnType],n):Vs(t)?Xs(e,t.parameters[1],n):M(t)?Zs(e,t.allOf,n):j(t)?Xs(e,t.properties,n):R(t)?Zs(e,t.anyOf,n):z(t)?Zs(e,t.items,n):Qi(t)?Qs(e,Zi(t),n):n}function $s(e,t,n){return Qs(e,n,[t])}function ec(e){return Zt()}function tc(e){return T(e).reduce((t,n)=>({...t,[n]:rc(e[n])}),{})}function nc(e){return e.reduce((e,t)=>[...e,rc(t)],[])}function rc(e){return Jt(e)?ec(e.$ref):zt(e)?Rt(rc(e.items),Bt(e)):Ht(e)?Vt(nc(e.parameters),rc(e.instanceType)):Gt(e)?Wt(nc(e.parameters),rc(e.returnType)):M(e)?yn(nc(e.allOf)):j(e)?A(tc(e.properties)):Qi(e)?Ki(Xi(e),rc(Zi(e))):R(e)?L(nc(e.anyOf)):z(e)?Ur(nc(e.items)):e}function ic(e,t){return t in e?rc(e[t]):ln()}function ac(e){return ic(e.$defs,e.$ref)}function oc(e,t,n){let r=_f(e,mf([],[]),t),i=hf({},mf([],[]),n);return bi([...r,A(i)])}function sc(e,t){return T(e).filter(e=>t.includes(e)).reduce((t,n)=>{let r=e[n],i=Vs(r)?oc(e,r.parameters[0],r.parameters[1]):r;return{...t,[n]:i}},{})}function cc(e,t,n){return dn(sc(e,$s(e,t,n)),t)}function lc(e,t){return t in e?Jt(e[t])?lc(e,e[t].$ref):e[t]:$t()}function uc(e,t){return lc(e,t)}function dc(e){return fn(e)?ac(e):pn(e)?ln():e}function fc(e,t,n){return G(e,dc(t),dc(n))}function pc(e,t){let n=[un(e)?H():fc({},e,t),un(e)?V({}):fc({},t,e)];return yo(n[0])&&yo(n[1])?`equal`:yo(n[0])&&vo(n[1])?`left-inside`:vo(n[0])&&yo(n[1])?`right-inside`:`disjoint`}function mc(e,t){return t.filter(t=>pc(e,t)!==`right-inside`)}function hc(e,t){return S(t.some(t=>{let n=pc(e,t);return S(n,`left-inside`)||S(n,`equal`)}),!1)}function gc(e,t){let n=Ci(e);return Qt(n)?[n]:hc(n,t)?[...mc(n,t),n]:t}function _c(e){return e.reduce((e,t)=>j(t)?[...e,t]:en(t)?e:gc(t,e),[])}function vc(e){return Ni(_c(e))}function yc(e,t){return D(Ci(e),{},t)}function bc(e,t,n,r){return yc(q(e,t,n),r)}function xc(e,t=[]){return jt(e)&&S(e.action,`Conditional`)?Jt(e.parameters[0])?xc(e.parameters[2],xc(e.parameters[3],[...t,e.parameters[0].$ref])):xc(e.parameters[2],xc(e.parameters[3],t)):jt(e)&&S(e.action,`Mapped`)&&jt(e.parameters[1])&&S(e.parameters[1].action,`KeyOf`)&&Jt(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function Sc(e,t){return e.reduce((e,n)=>[...e,t.includes(n.name)],[])}function Cc(e,t,n=[]){return C(e,(e,r)=>C(t,(t,i)=>Cc(r,i,[...n,[t,e]]),()=>n),()=>n)}function wc(e){return R(e)?[...e.anyOf]:[e]}function Tc(e,t){return e.reduce((e,n)=>[...e,[...n,t]],[])}function Ec(e,t){return t.reduce((t,n)=>[...t,...Tc(e,n)],[])}function Dc(e){return e.reduce((e,t)=>S(t[0],!0)?Ec(e,wc(t[1])):Ec(e,[t[1]]),[[]])}function Oc(e,t,n){let r=Cc(t,Sc(e,xc(n)));return jt(n)&&S(n.action,`Conditional`)||jt(n)&&S(n.action,`Mapped`)?Dc(r):[t]}function kc(){return[`(not-resolvable)`,$t()]}function Ac(){return[`(not-generic)`,$t()]}function jc(e,t,n){return[e,Yt(t,n)]}function Mc(e,t,n){return t in e?Nc(e,t,e[t],n):kc()}function Nc(e,t,n,r){return Xt(n)?jc(t,n.parameters,n.expression):Jt(n)?Mc(e,n.$ref,r):Ac()}function Pc(e,t,n){return Nc(e,`(anonymous)`,t,n)}function Fc(e,t,n){if(mn(t)||qc(t)||yo(fc({},t,n)))return;let r={parameter:e,expect:n,actual:t};throw Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:r})}function Ic(e,t,n,r,i){let a=q(e,t,i);return Fc(n,a,r),b(e,{[n]:a})}function Lc(e,t,n,r,i){let a=q(e,t,n.extends),o=q(e,t,n.equals);return C(i,(i,o)=>Rc(Ic(e,t,n.name,a,i),t,r,o),()=>Rc(Ic(e,t,n.name,a,o),t,r,[]))}function Rc(e,t,n,r){return C(n,(n,i)=>Lc(e,t,n,i,r),()=>e)}function zc(e,t,n,r){return Rc(e,t,n,r)}function Bc(e){return ze(e.callstack.length,0)?e.callstack[e.callstack.length-1]:``}function Vc(e,t){return S(Bc(e),t)}function Hc(e,t,n,r,i,a){let o=zc(e,t,r,a),s=q(o,mf([...t.callstack,n.$ref],t.visited),i);return q(o,mf([],[]),s)}function Uc(e,t,n,r,i,a){return a.reduce((a,o)=>[...a,Hc(e,t,n,r,i,o)],[])}function Wc(e,t,n,r,i,a){let o=Uc(e,t,n,r,i,Oc(r,a,i));return S(o.length,1)?o[0]:Si(o)}function Gc(e,t,n,r){let i=_f(e,t,r),a=Pc(e,n,r),o=a[0],s=a[1];return Xt(s)?Vc(t,o)?Kc(qt(o),i):Wc(e,t,qt(o),s.parameters,s.expression,i):Kc(n,i)}function Kc(e,t){return E({"~kind":`Call`},{type:`call`,target:e,arguments:t},{})}function qc(e){return O(e,`Call`)}function Jc(e){return kt(e,[`~immutable`])}function Yc(e,t){return D(Jc(e),{},t)}function Xc(e,t,n,r){return Yc(q(e,t,n),r)}function Zc(e,t){return e(t)}function Qc(e,t){return Ie(t)?F(Zc(e,t)):F(t)}function $c(e,t){return tl(e,xi(t))}function el(e,t){return L(t.map(t=>tl(e,t)))}function tl(e,t){return I(t)?Qc(e,t.const):mo(t)?$c(e,t.pattern):R(t)?el(e,t.anyOf):t}function nl(e,t={}){return k(`Capitalize`,[e],t)}function rl(e,t={}){return k(`Lowercase`,[e],t)}function il(e,t={}){return k(`Uncapitalize`,[e],t)}function al(e,t={}){return k(`Uppercase`,[e],t)}const ol=e=>e[0].toUpperCase()+e.slice(1),sl=e=>e.toLowerCase(),cl=e=>e[0].toLowerCase()+e.slice(1),ll=e=>e.toUpperCase();function ul(e,t){return K([e])?D(tl(ol,e),{},t):nl(e,t)}function dl(e,t){return K([e])?D(tl(sl,e),{},t):rl(e,t)}function fl(e,t){return K([e])?D(tl(cl,e),{},t):il(e,t)}function pl(e,t){return K([e])?D(tl(ll,e),{},t):al(e,t)}function ml(e,t,n,r){return ul(q(e,t,n),r)}function hl(e,t,n,r){return dl(q(e,t,n),r)}function gl(e,t,n,r){return fl(q(e,t,n),r)}function _l(e,t,n,r){return pl(q(e,t,n),r)}function vl(e,t,n,r,i={}){return k(`Conditional`,[e,t,n,r],i)}function yl(e,t,n,r,i,a){let o=fc(e,n,r);return go(o)?L([q(o.inferred,t,i),q(e,t,a)]):_o(o)?q(o.inferred,t,i):q(e,t,a)}function bl(e,t,n,r,i,a,o){return K([n,r])?D(yl(e,t,n,r,i,a),{},o):vl(n,r,i,a,o)}function xl(e,t,n,r,i,a,o){return bl(e,t,q(e,t,n),q(e,t,r),i,a,o)}function Sl(e,t={}){return k(`ConstructorParameters`,[e],t)}function Cl(e){let t=Ht(e)?e.parameters:[];return Ur(gf({},mf([],[]),t))}function wl(e,t){return K([e])?D(Cl(e),{},t):Sl(e,t)}function Tl(e,t,n,r){return wl(q(e,t,n),r)}function El(e,t,n={}){return k(`Exclude`,[e,t],n)}function Dl(e,t,n){return K([e,t])?D(_i(e,t),{},n):El(e,t,n)}function Ol(e,t,n,r,i){return Dl(q(e,t,n),q(e,t,r),i)}function kl(e,t,n={}){return k(`Extract`,[e,t],n)}function Al(e,t){return yo(fc({},e,t))?[e]:[]}function jl(e,t){return e.reduce((e,n)=>[...e,...Al(n,t)],[])}function Ml(e,t){let n=Ci(e);return Si(jl(R(n)?n.anyOf:[n],t))}function Nl(e,t,n){return K([e,t])?D(Ml(e,t),{},n):kl(e,t,n)}function Pl(e,t,n,r,i){return Nl(q(e,t,n),q(e,t,r),i)}function Fl(e,t,n={}){return k(`Index`,[e,t],n)}function Il(e,t){return Gl(uc(e,t))}function Ll(e,t,n){return Gl(vi(e,t,n))}function Rl(e,t){let n=T(e).filter(e=>!w(t,e)),r=T(t).filter(t=>!w(e,t)),i=T(e).filter(e=>w(t,e)),a=n.reduce((t,n)=>({...t,[n]:e[n]}),{}),o=r.reduce((e,n)=>({...e,[n]:t[n]}),{}),s=i.reduce((n,r)=>({...n,[r]:bi([e[r],t[r]])}),{});return b(b(a,o),s)}function zl(e){return e.reduce((e,t)=>Rl(e,Gl(t)),{})}function Bl(e){return e}function Vl(e){return Gl(ei(Ur(e)))}function Hl(e,t){return T(e).filter(e=>e in t).reduce((n,r)=>({...n,[r]:Si([e[r],t[r]])}),{})}function Ul(e,t){return C(e,(e,n)=>Ul(n,Hl(t,Gl(e))),()=>t)}function Wl(e){return C(e,(e,t)=>Ul(t,Gl(e)),()=>xn())}function Gl(e){return fn(e)?Il(e.$defs,e.$ref):gn(e)?Ll(e.if,e.then,e.else):M(e)?zl(e.allOf):R(e)?Wl(e.anyOf):z(e)?Vl(e.items):j(e)?Bl(e.properties):{}}function Kl(e){return A(Gl(e))}const ql=RegExp(`^(?:0|[1-9][0-9]*)$`);function Jl(e){let t=`${e}`;return ql.test(t)?parseInt(t):e}function Yl(e){return F(Jl(e))}function Xl(e){return e.map(e=>Zl(e))}function Zl(e){return M(e)?yn(Xl(e.allOf)):R(e)?L(Xl(e.anyOf)):I(e)?Yl(e.const):e}function Ql(e,t){return yo(fc({},Zl(t),gr()))?e:I(t)&&S(t.const,`length`)?gr():$t()}function $l(e,t){return ou(uc(e,t))}function eu(e,t,n){return ou(vi(e,t,n))}function tu(e){return ou(yi(e))}function nu(e){return ou(bi(e))}function ru(e){return[`${e}`]}function iu(e){return ou(xi(e))}function au(e){return e.reduce((e,t)=>[...e,...ou(t)],[])}function ou(e){return fn(e)?$l(e.$defs,e.$ref):gn(e)?eu(e.if,e.then,e.else):vn(e)?tu(e.enum):M(e)?nu(e.allOf):I(e)?ru(e.const):mo(e)?iu(e.pattern):R(e)?au(e.anyOf):[]}function su(e){return ou(e)}function cu(e,t){return t.map(t=>lu(e,t))}function lu(e,t){return zt(t)?Rt(lu(e,t.items)):Ht(t)?Vt(cu(e,t.parameters),lu(e,t.instanceType)):Gt(t)?Wt(cu(e,t.parameters),lu(e,t.returnType)):z(t)?Ur(cu(e,t.items)):R(t)?L(cu(e,t.anyOf)):M(t)?yn(cu(e,t.allOf)):ta(t)?A(e):t}function uu(e,t){return lu(e,t)}function du(e,t){return uu(e,t in e?e[t]:$t())}function fu(e,t){return t.reduce((t,n)=>[...t,du(e,n)],[])}function pu(e,t){return Si(fu(e,su(t)))}const mu=new RegExp(Hi);function hu(e){return e.filter(e=>mu.test(e))}function gu(e){return Si(fu(e,hu(on(e))))}function _u(e,t){return _r(t)?gu(e):pu(e,t)}function vu(e){return F(Jl(e))}function yu(e){return e.map(e=>bu(e))}function bu(e){return M(e)?yn(yu(e.allOf)):R(e)?L(yu(e.anyOf)):I(e)?vu(e.const):e}function xu(e,t){return e.reduceRight((e,n,r)=>yo(fc({},F(r),t))?[n,...e]:e,[])}function Su(e,t){return wi(xu(e,bu(t)))}function Cu(e){return wi(e)}function wu(e,t){return I(t)&&S(t.const,`length`)?F(e.length):_r(t)||ar(t)?Cu(e):Su(e,t)}function Tu(e,t){return zt(e)?Ql(e.items,t):j(e)?_u(e.properties,t):z(e)?wu(e.items,t):$t()}function Eu(e){return fn(e)||gn(e)||M(e)||R(e)?Kl(e):e}function Du(e,t,n){return K([e,t])?D(Tu(Eu(e),t),{},n):Fl(e,t,n)}function Ou(e,t,n,r,i){return Du(q(e,t,n),q(e,t,r),i)}function ku(e,t={}){return k(`InstanceType`,[e],t)}function Au(e){return Ht(e)?e.instanceType:$t()}function ju(e,t){return K([e])?D(Au(e),{},t):ku(e,t)}function Mu(e,t,n,r={}){return ju(q(e,t,n),r)}function Nu(e,t={}){return k(`KeyOf`,[e],t)}function Pu(){return L([gr(),br(),vr()])}function Fu(e){return gr()}function Iu(e){return e.reduce((e,t)=>cr(t)?[...e,F(Jl(t))]:xn(),[])}function Lu(e){return wi(Iu(T(e)))}function Ru(e){return Xi(e)}function zu(e){return wi(e.map((e,t)=>F(t)))}function Bu(e){return Qt(e)?Pu():zt(e)?Fu(e.items):j(e)?Lu(e.properties):Qi(e)?Ru(e):z(e)?zu(e.items):$t()}function Vu(e){return fn(e)||gn(e)||M(e)||R(e)?Kl(e):e}function Hu(e,t){return K([e])?D(Bu(Vu(e)),{},t):Nu(e,t)}function Uu(e,t,n,r){return Hu(q(e,t,n),r)}function Wu(e,t,n,r,i={}){return k(`Mapped`,[e,t,n,r],i)}function Gu(e){return Yu(xi(e))}function Ku(e){return e.reduce((e,t)=>[...e,...Yu(t)],[])}function qu(e){return Yu(yi(e))}function Ju(e){return Pe(e)?[F(`${e}`)]:[F(e)]}function Yu(e){return vn(e)?qu(e.enum):I(e)?Ju(e.const):mo(e)?Gu(e.pattern):R(e)?Ku(e.anyOf):[e]}function Xu(e){return Yu(e)}function Zu(e){return mo(e)?xi(e.pattern):e}function Qu(e,t,n,r,i,a){let o=b(e,{[n.name]:r}),s=Zu(q(o,t,i)),c=q(o,t,a);return dr(s)||fr(s)?{[s.const]:c}:{}}function $u(e,t,n,r,i,a){return r.reduce((r,o)=>[...r,Qu(e,t,n,o,i,a)],[])}function ed(e){return e.reduce((e,t)=>[...e,A(t)],[])}function td(e,t,n,r,i,a){return bi(ed($u(e,t,n,Xu(r),i,a)))}function nd(e,t,n,r,i,a,o){return K([r])?D(td(e,t,n,r,i,a),{},o):Wu(n,r,i,a,o)}function rd(e,t,n,r,i,a,o){return nd(e,t,n,q(e,t,r),i,a,o)}function id(e,t,n){let r=b(e,t);return T(t).filter(e=>n.includes(e)).reduce((e,n)=>({...e,[n]:cc(r,n,t[n])}),{})}function ad(e,t,n){let r=b(e,t);return T(t).filter(e=>!n.includes(e)).reduce((e,n)=>({...e,[n]:q(r,mf([],[]),t[n])}),{})}function od(e,t,n){let r=Js(t),i=id(e,t,r),a=ad(e,t,r);return D({...i,...a},{},n)}function sd(e,t,n,r){return od(e,n,r)}function cd(e,t={}){return k(`NonNullable`,[e],t)}function ld(e){return Dl(e,L([pr(),na()]),{})}function ud(e,t){return K([e])?D(ld(e),{},t):cd(e,t)}function dd(e,t,n,r){return ud(q(e,t,n),r)}function fd(e,t,n={}){return k(`Omit`,[e,t],n)}function pd(e){let t=Kl(e);return j(t)?t.properties:xn()}function md(e,t){return T(e).reduce((n,r)=>t.includes(r)?n:{...n,[r]:e[r]},{})}function hd(e,t){return A(md(pd(e),su(t)))}function gd(e,t,n){return K([e,t])?D(hd(e,t),{},n):fd(e,t,n)}function _d(e,t,n,r,i){return gd(q(e,t,n),q(e,t,r),i)}function vd(e,t={}){return k(`Parameters`,[e],t)}function yd(e){let t=Gt(e)?e.parameters:[];return Ur(gf({},mf([],[]),t))}function bd(e,t){return K([e])?D(yd(e),{},t):vd(e,t)}function xd(e,t,n,r){return bd(q(e,t,n),r)}function Sd(e,t={}){return k(`Partial`,[e],t)}function Cd(e,t){let n=Od(uc(e,t));return dn(b(e,{[t]:n}),t)}function wd(e,t,n){return Od(vi(e,t,n))}function Td(e){return Od(bi(e))}function Ed(e){return L(e.map(e=>Od(e)))}function Dd(e){return A(T(e).reduce((t,n)=>({...t,[n]:tn(e[n])}),{}))}function Od(e){return fn(e)?Cd(e.$defs,e.$ref):gn(e)?wd(e.if,e.then,e.else):M(e)?Td(e.allOf):R(e)?Ed(e.anyOf):j(e)?Dd(e.properties):A({})}function kd(e,t){return K([e])?D(Od(e),{},t):Sd(e,t)}function Ad(e,t,n,r){return kd(q(e,t,n),r)}function jd(e,t,n={}){return k(`Pick`,[e,t],n)}function Md(e,t){return T(e).reduce((n,r)=>t.includes(r)?b(n,{[r]:e[r]}):n,{})}function Nd(e,t){return A(Md(pd(e),su(t)))}function Pd(e,t,n){return K([e,t])?D(Nd(e,t),{},n):jd(e,t,n)}function Fd(e,t,n,r,i){return Pd(q(e,t,n),q(e,t,r),i)}function Id(e,t={}){return k(`ReadonlyObject`,[e],t)}function Ld(e){return Tf(Rt(e))}function Rd(e,t){let n=Wd(uc(e,t));return dn(b(e,{[t]:n}),t)}function zd(e,t,n){return Wd(vi(e,t,n))}function Bd(e){return Wd(bi(e))}function Vd(e){return A(T(e).reduce((t,n)=>({...t,[n]:Qn(e[n])}),{}))}function Hd(e){return Tf(Ur(e))}function Ud(e){return L(e.map(e=>Wd(e)))}function Wd(e){return zt(e)?Ld(e.items):fn(e)?Rd(e.$defs,e.$ref):gn(e)?zd(e.if,e.then,e.else):M(e)?Bd(e.allOf):j(e)?Vd(e.properties):z(e)?Hd(e.items):R(e)?Ud(e.anyOf):e}function Gd(e,t){return K([e])?D(Wd(e),{},t):Id(e)}function Kd(e,t,n,r){return Gd(q(e,t,n),r)}function qd(e,t,n,r){return t.visited.includes(r)?n:r in e?q(e,mf(t.callstack,[...t.visited,r]),e[r]):n}function Jd(e,t){let n=$d(uc(e,t));return dn(b(e,{[t]:n}),t)}function Yd(e,t,n){return $d(vi(e,t,n))}function Xd(e){return $d(bi(e))}function Zd(e){return L(e.map(e=>$d(e)))}function Qd(e){return A(T(e).reduce((t,n)=>({...t,[n]:Qr(e[n])}),{}))}function $d(e){return fn(e)?Jd(e.$defs,e.$ref):gn(e)?Yd(e.if,e.then,e.else):M(e)?Xd(e.allOf):R(e)?Zd(e.anyOf):j(e)?Qd(e.properties):A({})}function ef(e,t={}){return k(`Required`,[e],t)}function tf(e,t){return K([e])?D($d(e),{},t):ef(e,t)}function nf(e,t,n,r){return tf(q(e,t,n),r)}function rf(e,t={}){return k(`ReturnType`,[e],t)}function af(e){return Gt(e)?e.returnType:$t()}function of(e,t){return K([e])?D(af(e),{},t):rf(e,t)}function sf(e,t,n,r={}){return of(q(e,t,n),r)}function cf(e,t){return k(`With`,[e,t],{})}function lf(e,t){return uf(e,t)}function uf(e,t){return K([e])?D(e,{},t):cf(e,t)}function df(e,t,n,r){return uf(q(e,t,n),r)}function ff(e){return ea(e)?z(e.items)?pf(e.items.items):mn(e.items)||Jt(e.items)?[e]:[$t()]:[e]}function pf(e){return e.reduce((e,t)=>[...e,...ff(t)],[])}function mf(e,t){return{callstack:e,visited:t}}function K(e){return C(e,(e,t)=>!Jt(e)&&K(t),()=>!0)}function hf(e,t,n){return T(n).reduce((r,i)=>({...r,[i]:q(e,t,n[i])}),{})}function gf(e,t,n){return pf(_f(e,t,n))}function _f(e,t,n){return n.map(n=>q(e,t,n))}function vf(e,t){let n=rn(e)?It(t,{}):t,r=$n(e)?Nt(n,{}):n;return Zn(e)?Cf(r,{}):r}function yf(e,t,n,r,i){return S(n,`AddImmutable`)?wf(e,t,r[0],i):S(n,`RemoveImmutable`)?Xc(e,t,r[0],i):S(n,`AddReadonly`)?Pt(e,t,r[0],i):S(n,`RemoveReadonly`)?qr(e,t,r[0],i):S(n,`AddOptional`)?Lt(e,t,r[0],i):S(n,`RemoveOptional`)?Zr(e,t,r[0],i):S(n,`Capitalize`)?ml(e,t,r[0],i):S(n,`Conditional`)?xl(e,t,r[0],r[1],r[2],r[3],i):S(n,`ConstructorParameters`)?Tl(e,t,r[0],i):S(n,`Evaluate`)?bc(e,t,r[0],i):S(n,`Exclude`)?Ol(e,t,r[0],r[1],i):S(n,`Extract`)?Pl(e,t,r[0],r[1],i):S(n,`Index`)?Ou(e,t,r[0],r[1],i):S(n,`InstanceType`)?Mu(e,t,r[0],i):S(n,`Interface`)?zs(e,t,r[0],r[1],i):S(n,`KeyOf`)?Uu(e,t,r[0],i):S(n,`Lowercase`)?hl(e,t,r[0],i):S(n,`Mapped`)?rd(e,t,r[0],r[1],r[2],r[3],i):S(n,`Module`)?sd(e,t,r[0],i):S(n,`NonNullable`)?dd(e,t,r[0],i):S(n,`Pick`)?Fd(e,t,r[0],r[1],i):S(n,`Parameters`)?xd(e,t,r[0],i):S(n,`Partial`)?Ad(e,t,r[0],i):S(n,`Omit`)?_d(e,t,r[0],r[1],i):S(n,`ReadonlyObject`)?Kd(e,t,r[0],i):S(n,`Record`)?Vi(e,t,r[0],r[1],i):S(n,`Required`)?nf(e,t,r[0],i):S(n,`ReturnType`)?sf(e,t,r[0],i):S(n,`TemplateLiteral`)?uo(e,t,r[0],i):S(n,`Uncapitalize`)?gl(e,t,r[0],i):S(n,`Uppercase`)?_l(e,t,r[0],i):S(n,`With`)?df(e,t,r[0],r[1]):k(n,r,i)}function bf(e,t,n){return vf(n,Jt(n)?qd(e,t,n,n.$ref):zt(n)?Rt(q(e,t,n.items),Bt(n)):qc(n)?Gc(e,t,n.target,n.arguments):Ht(n)?Vt(_f(e,t,n.parameters),q(e,t,n.instanceType),Ut(n)):Gt(n)?Wt(_f(e,t,n.parameters),q(e,t,n.returnType),Kt(n)):gn(n)?hn(q(e,t,n.if),q(e,t,n.then),q(e,t,n.else),_n(n)):M(n)?yn(_f(e,t,n.allOf),bn(n)):j(n)?A(hf(e,t,n.properties),cn(n)):Qi(n)?qi(Yi(n),q(e,t,Zi(n))):ea(n)?$i(q(e,t,n.items)):z(n)?Ur(gf(e,t,n.items),Wr(n)):R(n)?L(_f(e,t,n.anyOf),Sr(n)):n)}function q(e,t,n){return jt(n)?yf(e,t,n.action,n.parameters,n.options):bf(e,t,n)}function xf(e,t){return q(e,mf([],[]),t)}function Sf(e){return D(e,{"~immutable":!0},{})}function Cf(e,t){return D(Sf(e),{},t)}function wf(e,t,n,r){return Cf(q(e,t,n),r)}function Tf(e,t={}){return Cf(e,t)}function Ef(e,t={}){return yc(e,t)}function Df(e,t){let n=pc(e,t);return S(n,`right-inside`)?1:+!!S(n,`disjoint`)}function Of(e,t,n=[]){return C(t,(r,i)=>S(Df(e,r),1)?Of(e,i,[...n,r]):[...n,e,...t],()=>[...n,e])}function kf(e,t=[]){return C(e,(e,n)=>kf(n,Of(e,t)),()=>t)}function Af(e){return kf(e)}const jf=Symbol.for(`yaml.alias`),Mf=Symbol.for(`yaml.document`),Nf=Symbol.for(`yaml.map`),Pf=Symbol.for(`yaml.pair`),Ff=Symbol.for(`yaml.scalar`),If=Symbol.for(`yaml.seq`),Lf=Symbol.for(`yaml.node.type`),Rf=e=>!!e&&typeof e==`object`&&e[Lf]===jf,zf=e=>!!e&&typeof e==`object`&&e[Lf]===Mf,Bf=e=>!!e&&typeof e==`object`&&e[Lf]===Nf,J=e=>!!e&&typeof e==`object`&&e[Lf]===Pf,Y=e=>!!e&&typeof e==`object`&&e[Lf]===Ff,Vf=e=>!!e&&typeof e==`object`&&e[Lf]===If;function Hf(e){if(e&&typeof e==`object`)switch(e[Lf]){case Nf:case If:return!0}return!1}function X(e){if(e&&typeof e==`object`)switch(e[Lf]){case jf:case Nf:case Ff:case If:return!0}return!1}const Uf=e=>(Y(e)||Hf(e))&&!!e.anchor,Wf=Symbol(`break visit`),Gf=Symbol(`skip children`),Kf=Symbol(`remove node`);function qf(e,t){let n=Zf(t);zf(e)?Jf(null,e.contents,n,Object.freeze([e]))===Kf&&(e.contents=null):Jf(null,e,n,Object.freeze([]))}qf.BREAK=Wf,qf.SKIP=Gf,qf.REMOVE=Kf;function Jf(e,t,n,r){let i=Qf(e,t,n,r);if(X(i)||J(i))return $f(e,r,i),Jf(e,i,n,r);if(typeof i!=`symbol`){if(Hf(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=Jf(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===Wf)return Wf;else i===Kf&&(t.items.splice(e,1),--e)}}else if(J(t)){r=Object.freeze(r.concat(t));let e=Jf(`key`,t.key,n,r);if(e===Wf)return Wf;e===Kf&&(t.key=null);let i=Jf(`value`,t.value,n,r);if(i===Wf)return Wf;i===Kf&&(t.value=null)}}return i}async function Yf(e,t){let n=Zf(t);zf(e)?await Xf(null,e.contents,n,Object.freeze([e]))===Kf&&(e.contents=null):await Xf(null,e,n,Object.freeze([]))}Yf.BREAK=Wf,Yf.SKIP=Gf,Yf.REMOVE=Kf;async function Xf(e,t,n,r){let i=await Qf(e,t,n,r);if(X(i)||J(i))return $f(e,r,i),Xf(e,i,n,r);if(typeof i!=`symbol`){if(Hf(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=await Xf(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===Wf)return Wf;else i===Kf&&(t.items.splice(e,1),--e)}}else if(J(t)){r=Object.freeze(r.concat(t));let e=await Xf(`key`,t.key,n,r);if(e===Wf)return Wf;e===Kf&&(t.key=null);let i=await Xf(`value`,t.value,n,r);if(i===Wf)return Wf;i===Kf&&(t.value=null)}}return i}function Zf(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Qf(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(Bf(t))return n.Map?.(e,t,r);if(Vf(t))return n.Seq?.(e,t,r);if(J(t))return n.Pair?.(e,t,r);if(Y(t))return n.Scalar?.(e,t,r);if(Rf(t))return n.Alias?.(e,t,r)}function $f(e,t,n){let r=t[t.length-1];if(Hf(r))r.items[e]=n;else if(J(r))e===`key`?r.key=n:r.value=n;else if(zf(r))r.contents=n;else{let e=Rf(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}const ep={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},tp=e=>e.replace(/[!,[\]{}]/g,e=>ep[e]);var np=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+tp(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&X(e.contents)){let t={};qf(e.contents,(e,n)=>{X(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)i===`!!`&&a===`tag:yaml.org,2002:`||(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
4
+ `)}};np.defaultYaml={explicit:!1,version:`1.2`},np.defaultTags={"!!":`tag:yaml.org,2002:`};function rp(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function ip(e,t,n,r){if(r&&typeof r==`object`)if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=ip(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=ip(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=ip(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=ip(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}return e.call(t,n,r)}function ap(e,t,n){if(Array.isArray(e))return e.map((e,t)=>ap(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!Uf(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var op=class{constructor(e){Object.defineProperty(this,Lf,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!zf(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=ap(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?ip(i,{"":o},``,o):o}},sp=class extends op{constructor(e){super(jf),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],qf(e,{Node:(e,t)=>{(Rf(t)||Uf(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}return r}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,a=this.resolve(r,t);if(!a){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let o=n.get(a);if(o||=(ap(a,null,t),n.get(a)),o?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=cp(r,a,n)),o.count*o.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return o.res}toString(e,t,n){let r=`*${this.source}`;if(e){if(rp(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function cp(e,t,n){if(Rf(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(Hf(t)){let r=0;for(let i of t.items){let t=cp(e,i,n);t>r&&(r=t)}return r}else if(J(t)){let r=cp(e,t.key,n),i=cp(e,t.value,n);return Math.max(r,i)}return 1}const lp=e=>!e||typeof e!=`function`&&typeof e!=`object`;var Z=class extends op{constructor(e){super(Ff),this.value=e}toJSON(e,t){return t?.keep?this.value:ap(this.value,e,t)}toString(){return String(this.value)}};Z.BLOCK_FOLDED=`BLOCK_FOLDED`,Z.BLOCK_LITERAL=`BLOCK_LITERAL`,Z.PLAIN=`PLAIN`,Z.QUOTE_DOUBLE=`QUOTE_DOUBLE`,Z.QUOTE_SINGLE=`QUOTE_SINGLE`;function up(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function dp(e,t,n){if(zf(e)&&(e=e.contents),X(e))return e;if(J(e)){let t=n.schema[Nf].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??=i(e),new sp(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=`tag:yaml.org,2002:`+t.slice(2));let l=up(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new Z(e);return c&&(c.node=t),t}l=e instanceof Map?o[Nf]:Symbol.iterator in Object(e)?o[If]:o[Nf]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new Z(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function fp(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return dp(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}const pp=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;var mp=class extends op{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>X(t)||J(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(pp(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(Hf(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,fp(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(Hf(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&Y(i)?i.value:i:Hf(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!J(t))return!1;let n=t.value;return n==null||e&&Y(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return Hf(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(Hf(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,fp(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}};const hp=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function gp(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const _p=(e,t,n)=>e.endsWith(`
5
+ `)?gp(n,t):n.includes(`
6
+ `)?`
7
+ `+gp(n,t):(e.endsWith(` `)?``:` `)+n,vp=`flow`;function yp(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,ee=-1;n===`block`&&(h=bp(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}ee=h}if(r===`
8
+ `)n===`block`&&(h=bp(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
9
+ `&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
10
+ `&&t!==` `&&(f=h)}if(h>=d)if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>ee+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let _=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?_=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(_+=`${e[i]}\\`),_+=`\n${t}${e.slice(i+1,a)}`)}return _}function bp(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
11
+ `);r=t,i=t+1,a=e[i]}return r}const xp=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Sp=e=>/^(%|---|\.\.\.)/m.test(e);function Cp(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
12
+ `){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function wp(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(Sp(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
13
+
14
+ `;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
15
+ `,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:yp(o,a,`quoted`,xp(t,!1))}function Tp(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
16
+ `)||/[ \t]\n|\n[ \t]/.test(e))return wp(e,t);let n=t.indent||(Sp(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:yp(r,n,vp,xp(t,!1))}function Ep(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=wp;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?Tp:i&&!t?wp:n?Tp:wp}return r(e,t)}let Dp;try{Dp=RegExp(`(^|(?<!
17
+ ))
18
+ +(?!
19
+ |$)`,`g`)}catch{Dp=/\n+(?!\n|$)/g}function Op({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return Ep(n,r);let l=r.indent||(r.forceBlockIndent||Sp(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===Z.BLOCK_FOLDED?!1:t===Z.BLOCK_LITERAL||!Cp(n,c,l.length);if(!n)return u?`|
20
+ `:`>
21
+ `;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
22
+ `&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
23
+ `);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
24
+ `&&(p=p.slice(0,-1)),p.replace(Dp,`$&${l}`));let h=!1,g,ee=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
25
+ `)ee=g;else break}let _=n.substring(0,ee<g?ee+1:g);_&&=(n=n.substring(_.length),_.replace(/\n+/g,`$&${l}`));let v=(h?l?`2`:`1`:``)+d;if(e&&(v+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),!u){let e=n.replace(/\n+/g,`
26
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=xp(r,!0);o!==`folded`&&t!==Z.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=yp(`${_}${e}${p}`,l,`block`,a);if(!i)return`>${v}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${v}\n${l}${_}${n}${p}`}function kp(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
27
+ `)||u&&/[[\]{},]/.test(a))return Ep(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
28
+ `)?Ep(a,t):Op(e,t,n,r);if(!s&&!u&&i!==Z.PLAIN&&a.includes(`
29
+ `))return Op(e,t,n,r);if(Sp(a)){if(c===``)return t.forceBlockIndent=!0,Op(e,t,n,r);if(s&&c===l)return Ep(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return Ep(a,t)}return s?d:yp(d,c,vp,xp(t,!1))}function Ap(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==Z.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=Z.QUOTE_DOUBLE);let c=e=>{switch(e){case Z.BLOCK_FOLDED:case Z.BLOCK_LITERAL:return i||a?Ep(o.value,t):Op(o,t,n,r);case Z.QUOTE_DOUBLE:return wp(o.value,t);case Z.QUOTE_SINGLE:return Tp(o.value,t);case Z.PLAIN:return kp(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function jp(e,t){let n=Object.assign({blockQuote:!0,commentString:hp,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function Mp(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(Y(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function Np(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(Y(e)||Hf(e))&&e.anchor;a&&rp(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function Pp(e,t,n,r){if(J(e))return e.toString(t,n,r);if(Rf(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=X(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=Mp(t.doc.schema.tags,a);let o=Np(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):Y(a)?Ap(a,t,n,r):a.toString(t,n,r);return o?Y(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function Fp({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=X(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(Hf(e)||!X(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||Hf(e)||(Y(e)?e.type===Z.BLOCK_FOLDED||e.type===Z.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=Pp(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=_p(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=_p(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=_p(g,n.indent,l(f))));let ee,_,v;X(t)?(ee=!!t.spaceBefore,_=t.commentBefore,v=t.comment):(ee=!1,_=null,v=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&Y(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&Vf(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let te=!1,ne=Pp(t,n,()=>te=!0,()=>h=!0),re=` `;if(f||ee||_){if(re=ee?`
30
+ `:``,_){let e=l(_);re+=`\n${gp(e,n.indent)}`}ne===``&&!n.inFlow?re===`
31
+ `&&v&&(re=`
32
+
33
+ `):re+=`\n${n.indent}`}else if(!p&&Hf(t)){let e=ne[0],r=ne.indexOf(`
34
+ `),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=ne.indexOf(` `);e===`&`&&n!==-1&&n<r&&ne[n+1]===`!`&&(n=ne.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(re=`\n${n.indent}`)}}else(ne===``||ne[0]===`
35
+ `)&&(re=``);return g+=re+ne,n.inFlow?te&&r&&r():v&&!te?g+=_p(g,n.indent,l(v)):h&&i&&i(),g}function Ip(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}const Lp={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new Z(Symbol(`<<`)),{addToJSMap:zp}),stringify:()=>`<<`},Rp=(e,t)=>(Lp.identify(t)||Y(t)&&(!t.type||t.type===Z.PLAIN)&&Lp.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===Lp.tag&&e.default);function zp(e,t,n){let r=Vp(e,n);if(Vf(r))for(let n of r.items)Bp(e,t,n);else if(Array.isArray(r))for(let n of r)Bp(e,t,n);else Bp(e,t,r)}function Bp(e,t,n){let r=Vp(e,n);if(!Bf(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function Vp(e,t){return e&&Rf(t)?t.resolve(e.doc,e):t}function Hp(e,t,{key:n,value:r}){if(X(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(Rp(e,n))zp(e,t,r);else{let i=ap(n,``,e);if(t instanceof Map)t.set(i,ap(r,i,e));else if(t instanceof Set)t.add(i);else{let a=Up(n,i,e),o=ap(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function Up(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(X(e)&&n?.doc){let t=jp(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),Ip(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function Wp(e,t,n){return new Gp(dp(e,void 0,n),dp(t,void 0,n))}var Gp=class e{constructor(e,t=null){Object.defineProperty(this,Lf,{value:Pf}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return X(n)&&(n=n.clone(t)),X(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return Hp(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?Fp(this,e,t,n):JSON.stringify(this)}};function Kp(e,t,n){return(t.inFlow??e.flow?Jp:qp)(e,t,n)}function qp({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(X(i))!d&&i.spaceBefore&&f.push(``),Yp(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(J(i)){let e=X(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),Yp(n,f,e.commentBefore,d))}d=!1;let s=Pp(i,u,()=>o=null,()=>d=!0);o&&(s+=_p(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
36
+ `}}return e?(p+=`
37
+ `+gp(l(e),c),s&&s()):d&&o&&o(),p}function Jp({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(X(i))i.spaceBefore&&d.push(``),Yp(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(J(i)){let e=X(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),Yp(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=X(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=Pp(i,c,()=>a=null);l||=d.length>u||o.includes(`
38
+ `),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=_p(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
39
+ `;return`${e}\n${i}${p}`}else return`${f}${o}${d.join(` `)}${o}${p}`}function Yp({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=gp(t(r),e);n.push(i.trimStart())}}function Xp(e,t){let n=Y(t)?t.value:t;for(let r of e)if(J(r)&&(r.key===t||r.key===n||Y(r.key)&&r.key.value===n))return r}var Zp=class extends mp{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(Nf,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(Wp(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=J(e)?e:!e||typeof e!=`object`||!(`key`in e)?new Gp(e,e?.value):new Gp(e.key,e.value);let r=Xp(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);Y(r.value)&&lp(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=Xp(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=Xp(this.items,e)?.value;return(!t&&Y(n)?n.value:n)??void 0}has(e){return!!Xp(this.items,e)}set(e,t){this.add(new Gp(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)Hp(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!J(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Kp(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}};const Qp={collection:`map`,default:!0,nodeClass:Zp,tag:`tag:yaml.org,2002:map`,resolve(e,t){return Bf(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>Zp.from(e,t,n)};var $p=class extends mp{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(If,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=em(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=em(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&Y(r)?r.value:r}has(e){let t=em(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=em(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];Y(r)&&lp(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(ap(e,String(r++),t));return n}toString(e,t,n){return e?Kp(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(dp(a,void 0,n))}}return i}};function em(e){let t=Y(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}const tm={collection:`seq`,default:!0,nodeClass:$p,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return Vf(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>$p.from(e,t,n)};function nm(e){return typeof e==`bigint`||Number.isInteger(e)}const rm=({value:e})=>JSON.stringify(e),im=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:rm},{identify:e=>e==null,createNode:()=>new Z(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:rm},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:rm},{identify:nm,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>nm(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:rm}];[Qp,tm].concat(im,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}});function am(e,t,n){let{replacer:r}=n,i=new $p(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e))if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`);else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(Wp(o,s,n))}return i}var om=class e extends $p{constructor(){super(),this.add=Zp.prototype.add.bind(this),this.delete=Zp.prototype.delete.bind(this),this.get=Zp.prototype.get.bind(this),this.has=Zp.prototype.has.bind(this),this.set=Zp.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(J(e)?(r=ap(e.key,``,t),i=ap(e.value,r,t)):r=ap(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=am(e,t,n),i=new this;return i.items=r.items,i}};om.tag=`tag:yaml.org,2002:omap`;var sm=class e extends Zp{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=J(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new Gp(e.key,null):new Gp(e,null),Xp(this.items,t.key)||this.items.push(t)}get(e,t){let n=Xp(this.items,e);return!t&&J(n)?Y(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=Xp(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new Gp(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(Wp(e,null,n));return i}};sm.tag=`tag:yaml.org,2002:set`;const cm=Symbol(`break visit`),lm=Symbol(`skip children`),um=Symbol(`remove item`);function dm(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),fm(Object.freeze([]),e,t)}dm.BREAK=cm,dm.SKIP=lm,dm.REMOVE=um,dm.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},dm.parentCollection=(e,t)=>{let n=dm.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function fm(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=fm(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===cm)return cm;else r===um&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}t(((e,t)=>{function n(e){return Array.isArray(e)?e:[e]}let r=/^\s+$/,i=/(?:[^\\]|^)\\$/,a=/^\\!/,o=/^\\#/,s=/\r?\n/g,c=/^\.{0,2}\/|^\.{1,2}$/,l=/\/$/,u=`node-ignore`;typeof Symbol<`u`&&(u=Symbol.for(`node-ignore`));let d=u,f=(e,t,n)=>(Object.defineProperty(e,t,{value:n}),n),p=/([0-z])-([0-z])/g,m=()=>!1,h=e=>e.replace(p,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:``),g=e=>{let{length:t}=e;return e.slice(0,t-t%2)},ee=[[/^\uFEFF/,()=>``],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,n)=>t+(n.indexOf(`\\`)===0?` `:``)],[/(\\+?)\s/g,(e,t)=>{let{length:n}=t;return t.slice(0,n-n%2)+` `}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>`[^/]`],[/^\//,()=>`^`],[/\//g,()=>`\\/`],[/^\^*\\\*\\\*\\\//,()=>`^(?:.*\\/)?`],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?`^`:`(?:^|\\/)`}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,n)=>t+6<n.length?`(?:\\/[^\\/]+)*`:`\\/.+`],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,n)=>t+n.replace(/\\\*/g,`[^\\/]*`)],[/\\\\\\(?=[$.|*+(){^])/g,()=>`\\`],[/\\\\/g,()=>`\\`],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,n,r,i)=>t===`\\`?`\\[${n}${g(r)}${i}`:i===`]`&&r.length%2==0?`[${h(n)}${r}]`:`[]`],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`]],_=/(^|\\\/)?\\\*$/,v=`regex`,te=`checkRegex`,ne={[v](e,t){return`${t?`${t}[^/]+`:`[^/]*`}(?=$|\\/$)`},[te](e,t){return`${t?`${t}[^/]*`:`[^/]*`}(?=$|\\/$)`}},re=e=>ee.reduce((t,[n,r])=>t.replace(n,r.bind(e)),e),ie=e=>typeof e==`string`,ae=e=>e&&ie(e)&&!r.test(e)&&!i.test(e)&&e.indexOf(`#`)!==0,oe=e=>e.split(s).filter(Boolean);var se=class{constructor(e,t,n,r,i,a){this.pattern=e,this.mark=t,this.negative=i,f(this,`body`,n),f(this,`ignoreCase`,r),f(this,`regexPrefix`,a)}get regex(){let e=`_regex`;return this[e]?this[e]:this._make(v,e)}get checkRegex(){let e=`_checkRegex`;return this[e]?this[e]:this._make(te,e)}_make(e,t){let n=this.regexPrefix.replace(_,ne[e]),r=this.ignoreCase?new RegExp(n,`i`):new RegExp(n);return f(this,t,r)}};let ce=({pattern:e,mark:t},n)=>{let r=!1,i=e;i.indexOf(`!`)===0&&(r=!0,i=i.substr(1)),i=i.replace(a,`!`).replace(o,`#`);let s=re(i);return new se(e,t,i,n,r,s)};var le=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[d]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(ie(e)&&(e={pattern:e}),ae(e.pattern)){let t=ce(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,n(ie(e)?oe(e):e).forEach(this._add,this),this._added}test(e,t,n){let r=!1,i=!1,a;this._rules.forEach(o=>{let{negative:s}=o;i===s&&r!==i||s&&!r&&!i&&!t||o[n].test(e)&&(r=!s,i=s,a=s?void 0:o)});let o={ignored:r,unignored:i};return a&&(o.rule=a),o}};let ue=(e,t)=>{throw new t(e)},y=(e,t,n)=>ie(e)?e?!y.isNotRelative(e)||n(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):n(`path must not be empty`,TypeError):n(`path must be a string, but got \`${t}\``,TypeError),b=e=>c.test(e);y.isNotRelative=b,y.convert=e=>e;var de=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){f(this,d,!0),this._rules=new le(t),this._strictPathCheck=!n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,t,n,r){let i=e&&y.convert(e);return y(i,e,this._strictPathCheck?ue:m),this._t(i,t,n,r)}checkIgnore(e){if(!l.test(e))return this.test(e);let t=e.split(`/`).filter(Boolean);if(t.pop(),t.length){let e=this._t(t.join(`/`)+`/`,this._testCache,!0,t);if(e.ignored)return e}return this._rules.test(e,!1,te)}_t(e,t,n,r){if(e in t)return t[e];if(r||=e.split(`/`).filter(Boolean),r.pop(),!r.length)return t[e]=this._rules.test(e,n,v);let i=this._t(r.join(`/`)+`/`,t,n,r);return t[e]=i.ignored?i:this._rules.test(e,n,v)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return n(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}};let fe=e=>new de(e),pe=e=>y(e&&y.convert(e),e,m),me=()=>{y.convert=e=>/^\\\\\?\\/.test(e)||/["<>|\u0000-\u001F]+/u.test(e)?e:e.replace(/\\/g,`/`);let e=/^[a-z]:\//i;y.isNotRelative=t=>e.test(t)||b(t)};typeof process<`u`&&process.platform===`win32`&&me(),t.exports=fe,fe.default=fe,t.exports.isPathValid=pe,f(t.exports,Symbol.for(`setupWindows`),me)}))(),globalThis.Buffer,A({command:br({description:`Bash command to execute`}),timeout:nn(gr({description:`Timeout in seconds (optional, no default timeout)`}))});var pm=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends pm{};function mm(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function hm(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function gm(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function _m(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function vm(e,t){return gm(e,t,``)}function ym(e,t){return _m(e,t,``)}function bm(e,t){return t.slice(0,xm(e,t))}function xm(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function Sm(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function Cm(e,t){if(t)return Tm(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function wm(e,t){if(t)return Tm(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function Tm(e,t){if(!t)return[wm(e),Cm(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=Sm(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}const Em=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,Dm=RegExp(`[${Em}]+|\\s+|[^${Em}]`,`ug`);new class extends pm{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=Sm(e,r)}else n=e.match(Dm)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&Om(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&Om(n,i,r,null,t.intlSegmenter),e}};function Om(e,t,n,r,i){if(t&&n){let[a,o]=Tm(t.value,i),[s,c]=Tm(n.value,i);if(e){let r=mm(a,s);e.value=_m(e.value,s,r),t.value=vm(t.value,r),n.value=vm(n.value,r)}if(r){let e=hm(o,c);r.value=gm(r.value,c,e),t.value=ym(t.value,e),n.value=ym(n.value,e)}}else if(n){if(e){let e=wm(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=wm(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=wm(r.value,i),[a,o]=Tm(t.value,i),s=mm(n,a);t.value=vm(t.value,s);let c=hm(vm(n,s),o);t.value=ym(t.value,c),r.value=gm(r.value,n,c),e.value=_m(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=wm(r.value,i),n=bm(Cm(t.value,i),e);t.value=ym(t.value,n)}else if(e){let n=bm(Cm(e.value,i),wm(t.value,i));t.value=vm(t.value,n)}}new class extends pm{tokenize(e){let t=RegExp(`(\\r?\\n)|[${Em}]+|[^\\S\\n\\r]+|[^${Em}]`,`ug`);return e.match(t)||[]}},new class extends pm{constructor(){super(...arguments),this.tokenize=km}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
40
+ `))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
41
+ `))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
42
+ `)&&(e=e.slice(0,-1)),t.endsWith(`
43
+ `)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function km(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
44
+ `));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function Am(e){return e==`.`||e==`!`||e==`?`}new class extends pm{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(Am(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends pm{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends pm{constructor(){super(...arguments),this.tokenize=km}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(jm(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function jm(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a;for(a=0;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=jm(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=jm(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends pm{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};const Mm=A({oldText:br({description:`Exact text for one targeted replacement. It must be unique in the original file and must not overlap with any other edits[].oldText in the same call.`}),newText:br({description:`Replacement text for this targeted edit.`})},{});A({path:br({description:`Path to the file to edit (relative or absolute)`}),edits:Rt(Mm,{description:`One or more targeted replacements. Each edit is matched against the original file, not incrementally. Do not include overlapping or nested edits. If two changes touch the same block or nearby lines, merge them into one edit instead.`})},{}),A({path:br({description:`Path to the file to read (relative or absolute)`}),offset:nn(gr({description:`Line number to start reading from (1-indexed)`})),limit:nn(gr({description:`Maximum number of lines to read`}))}),A({path:br({description:`Path to the file to write (relative or absolute)`}),content:br({description:`Content to write to the file`})});const Nm={enabled:!0,reserveTokens:16384,keepRecentTokens:2e4};function Pm(e,t,n){return n.enabled?e>t-n.reserveTokens:!1}function Fm(e){if(typeof e==`string`)return e.length;let t=0;for(let n of e)n.type===`text`&&n.text?t+=n.text.length:n.type===`image`&&(t+=4800);return t}function Im(e){let t=0;switch(e.role){case`user`:return t=Fm(e.content),Math.ceil(t/4);case`assistant`:{let n=e;for(let e of n.content)e.type===`text`?t+=e.text.length:e.type===`thinking`?t+=e.thinking.length:e.type===`toolCall`&&(t+=e.name.length+JSON.stringify(e.arguments).length);return Math.ceil(t/4)}case`custom`:case`toolResult`:return t=Fm(e.content),Math.ceil(t/4);case`bashExecution`:return t=e.command.length+e.output.length,Math.ceil(t/4);case`branchSummary`:case`compactionSummary`:return t=e.summary.length,Math.ceil(t/4)}return 0}const Lm=n(`context-compaction`);function Rm(e,t){return e.role===t}function zm(e){let t=0;for(;t<e.length&&Rm(e[t],`toolResult`);){let n=e[t];Lm.warn(`Dropping orphaned toolResult (no preceding assistant message)`,{toolCallId:n.toolCallId}),t++}return t>0?e.slice(t):e}function Bm(e){let t=[];for(let n of e){let e=n;switch(e.role){case`user`:t.push(`<user>\n${Vm(e.content)}\n</user>`);break;case`assistant`:t.push(`<assistant>\n${Vm(e.content)}\n</assistant>`);break;case`toolResult`:{let n=e.toolName??`tool`;t.push(`<tool-result name="${n}">\n${Vm(e.content)}\n</tool-result>`);break}case`bashExecution`:t.push(`<bash>\n$ ${e.command??``}\n${e.output??``}\n</bash>`);break;case`branchSummary`:case`compactionSummary`:t.push(`<prior-summary>\n${e.summary??``}\n</prior-summary>`);break;default:t.push(`<${e.role}>\n${Vm(e.content)}\n</${e.role}>`)}}return t.join(`
45
+
46
+ `)}function Vm(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return``;let t=[];for(let n of e){let e=n;e.type===`text`&&e.text?t.push(e.text):e.type===`thinking`&&e.thinking?t.push(`[thinking] ${e.thinking}`):e.type===`toolCall`?t.push(`[tool-call ${e.name??`?`}] ${JSON.stringify(e.arguments??{})}`):e.type===`image`&&t.push(`[image]`)}return t.join(`
47
+ `)}function Hm(e){return`You are a context compaction assistant. You are shown the prefix of a conversation between a user and an AI coding assistant, and asked to produce either a structured summary, durable memory bullets, or a short title — depending on the user's instruction.
48
+
49
+ Do NOT continue the conversation. Do NOT answer questions inside the conversation. Output ONLY what the user asks for in the format specified.
50
+
51
+ <conversation>
52
+ ${e}
53
+ </conversation>`}async function Um(e,t,n,r,i,a,o){let s=await ne(e,{systemPrompt:n,messages:[{role:`user`,content:[{type:`text`,text:r}],timestamp:Date.now()}]},{maxTokens:i,apiKey:t,headers:a,signal:o});if(s.stopReason===`error`)throw Error(`Compaction call failed: ${s.errorMessage||`Unknown error`}`);return s.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
54
+ `).trim()}function Wm(e){if(typeof e==`string`)return e.length;if(!Array.isArray(e))return 0;let t=0;for(let n of e){let e=n;if(e.type===`text`&&e.text)t+=e.text.length;else if(e.type===`thinking`&&e.thinking)t+=e.thinking.length;else if(e.type===`toolCall`&&e.arguments!==void 0)try{t+=JSON.stringify(e.arguments).length}catch{}else e.type===`image`&&e.source?.data&&(t+=e.source.data.length)}return t}function Gm(e,t){let n=Math.max(1,Math.round(e/1024));return`[${t===`assistant`?`Assistant message elided`:`Tool result elided`}: ${n} KB, exceeds half the context window. Re-run with smaller arguments — e.g. open --view --size low.]`}function Km(e){let t=e.role,n=e.content,r=Wm(n);if(t===`toolResult`)return{...e,content:[{type:`text`,text:Gm(r,t)}]};let i=(Array.isArray(n)?n.filter(e=>e.type===`toolCall`):[]).map(e=>{let t=0;if(e.arguments!==void 0)try{t=JSON.stringify(e.arguments).length}catch{}return{type:e.type,id:e.id,name:e.name,arguments:{elided:!0,originalBytes:t}}});return{...e,content:[{type:`text`,text:Gm(r,t)},...i]}}function qm(e,t,n){let r=(t-n)/2,i=0,a=0;return{messages:e.map(e=>{if(Im(e)<=r)return e;let t=e.role;if(t!==`toolResult`&&t!==`assistant`)return e;let n=e,o=Wm(n.content);return t===`toolResult`?(i++,a+=o,Km(e)):(Array.isArray(n.content)?n.content:[]).filter(e=>e.type===`toolCall`).length===0?e:(i++,a+=o,Km(e))}),elidedCount:i,elidedBytes:a}}function Jm(e){let t=0;for(let n of e)t+=Im(n);return t}function Ym(e,t){return e.length!==t.length||e.some((e,n)=>e!==t[n])}function Xm(e,t){try{e.onCompactionStateChange?.(t)}catch(e){Lm.warn(`onCompactionStateChange listener threw`,{error:e instanceof Error?e.message:String(e)})}}function Zm(e,t,n,r,i,a){if(t<=n*i)return{messages:e,isHopeless:!1,earlyReturn:null};let o=qm(e,n,r),s=o.messages;return Lm.warn(`Compaction hopeless branch`,{totalTokens:t,contextWindow:n,multiplier:i,elidedCount:o.elidedCount,elidedBytes:o.elidedBytes}),{messages:s,isHopeless:!0,earlyReturn:Pm(Jm(s),n,a)?null:s}}function Qm(e,t){let n=0,r=e.length;for(let i=e.length-1;i>=0;i--){let a=Im(e[i]);if(n+a>t&&r<e.length)break;n+=a,r=i}for(;r>0&&Rm(e[r],`toolResult`);)r--;return r<=0||r>=e.length?(Lm.warn(`Cannot find valid cut point for compaction`),null):{messagesToSummarize:e.slice(0,r),messagesToKeep:zm(e.slice(r))}}async function $m(e,t,n,r){if(e.onMemoryUpdates)try{Xm(e,`extracting-memory`);let i=await Um(e.model,t,n,`From the conversation above, extract durable memories worth persisting to a global memory file shared across future sessions.
55
+
56
+ Focus on:
57
+ - User preferences, working style, opinions stated explicitly.
58
+ - Stable project facts (architecture decisions, conventions, constraints).
59
+ - Validated approaches the user accepted ("yes, exactly", "perfect"), not just corrections.
60
+ - External resources/links the user named.
61
+
62
+ DO NOT include:
63
+ - Ephemeral state (current task, in-progress work).
64
+ - Information already obvious from the codebase (file paths, function names, framework conventions).
65
+ - Generic restatements of what the conversation was about.
66
+
67
+ If nothing in the conversation is worth persisting, return exactly the single line:
68
+ NONE
69
+
70
+ Otherwise, output ONLY a markdown bullet list (one bullet per memory), no headers, no preamble, no follow-up. Each bullet is one line. Be specific. Prefer one fact per bullet over multi-clause sentences.`,2048,e.headers,r);if(i?.trim()&&i.trim()!==`NONE`)try{await e.onMemoryUpdates(i.trim()),Lm.info(`Memory extraction applied`,{bulletsLength:i.length})}catch(e){Lm.warn(`onMemoryUpdates callback threw`,{error:e instanceof Error?e.message:String(e)})}else Lm.info(`Memory extraction returned no durable memories`)}catch(e){Lm.warn(`Memory extraction call failed (compaction still applied)`,{error:e instanceof Error?e.message:String(e)})}}async function eh(e,t,n,r,i,a,o){try{let s=Hm(Bm(n)),c=Math.floor(.8*i);Xm(e,`summarizing`);let l=await Um(e.model,t,s,`Produce a structured context checkpoint summary of the conversation above that another LLM can use to continue the work.
71
+
72
+ Use this EXACT format:
73
+
74
+ ## Goal
75
+ [What is the user trying to accomplish? Can be multiple items if the session covers different tasks.]
76
+
77
+ ## Constraints & Preferences
78
+ - [Any constraints, preferences, or requirements mentioned by user]
79
+ - [Or "(none)" if none were mentioned]
80
+
81
+ ## Progress
82
+ ### Done
83
+ - [x] [Completed tasks/changes]
84
+
85
+ ### In Progress
86
+ - [ ] [Current work]
87
+
88
+ ### Blocked
89
+ - [Issues preventing progress, if any]
90
+
91
+ ## Key Decisions
92
+ - **[Decision]**: [Brief rationale]
93
+
94
+ ## Next Steps
95
+ 1. [Ordered list of what should happen next]
96
+
97
+ ## Critical Context
98
+ - [Any data, examples, or references needed to continue]
99
+ - [Or "(none)" if not applicable]
100
+
101
+ Keep each section concise. Preserve exact file paths, function names, and error messages. Output ONLY the summary, with no preamble or follow-up.`,c,e.headers,o),u={role:`user`,content:[{type:`text`,text:`<context-summary>\n${l}\n</context-summary>`}],timestamp:Date.now()};return Lm.info(`LLM summarization successful`,{originalMessages:a,compactedMessages:1+r.length,summaryLength:l.length}),await $m(e,t,s,o),Xm(e,`idle`),[u,...r]}catch(e){return Lm.warn(`LLM summarization failed, falling back to naive drop`,{error:e instanceof Error?e.message:String(e)}),null}}function th(e){let t=e.contextWindow??2e5,n=e.reserveTokens??Nm.reserveTokens,r=e.keepRecentTokens??Nm.keepRecentTokens,i=e.hopelessMultiplier??4,a={enabled:!0,reserveTokens:n,keepRecentTokens:r};return async(o,s,c)=>{if(o.length===0)return o;let l=Jm(o);if(!c?.force&&!Pm(l,t,a))return o;let u=Zm(o,l,t,n,i,a);if(u.earlyReturn)return u.earlyReturn;let d=u.messages,f=u.isHopeless;Lm.info(`Context compaction triggered`,{totalTokens:l,contextWindow:t,threshold:t-n,messageCount:d.length});let p=Qm(d,r);if(!p)return d;let{messagesToSummarize:m,messagesToKeep:h}=p;Lm.info(`Compaction cut point`,{summarizing:m.length,keeping:h.length});let g=f?void 0:e.getApiKey();if(g){let t=await eh(e,g,m,h,n,o.length,s);if(t)return t}else f||Lm.warn(`No API key available for LLM summarization, falling back to naive drop`);Xm(e,`idle`);let ee={role:`user`,content:[{type:`text`,text:`[Earlier conversation messages were compacted to save context space]`}],timestamp:Date.now()};return Lm.info(`Naive compaction applied`,{originalMessages:o.length,compactedMessages:1+h.length}),[ee,...h]}}const nh=m({portName:`secrets.crud`,panelRpcOp:`secrets-bridge`,timeoutMs:1e4,onUnavailable:`resolve-undefined`,makeError:e=>Error(e),logNamespace:`secrets-bridge`,toPortMessage:({type:e,payload:t})=>({type:e,...t}),toPanelRpcPayload:({type:e,payload:t})=>({type:e,payload:t})});function rh(e,t){return nh({type:e,payload:t})}const ih=n(`secret-scrub`),ah=async e=>e;function oh(){let e=le();return e===`extension-direct`?async e=>{if(!e)return e;try{let t=await new Promise(t=>{chrome.runtime.sendMessage({type:`secrets.scrub-tool-result`,text:e},e=>t(e??{}))});return t.error?(ih.debug(`SW scrub-tool-result returned error`,{error:t.error}),e):typeof t.text==`string`?t.text:e}catch(t){return ih.debug(`SW scrub-tool-result failed`,{error:t instanceof Error?t.message:String(t)}),e}}:e===`extension-delegate`?async e=>{if(!e)return e;try{let t=await rh(`secrets.scrub-tool-result`,{text:e});return t?.error?(ih.debug(`Bridge scrub-tool-result returned error`,{error:t.error}),e):typeof t?.text==`string`?t.text:e}catch(t){return ih.debug(`Bridge scrub-tool-result failed`,{error:t instanceof Error?t.message:String(t)}),e}}:e===`connect`?ah:async e=>{if(!e)return e;try{let t=await fetch(l(`/api/secrets/scrub`),{method:`POST`,headers:u({"content-type":`application/json`}),body:JSON.stringify({text:e})});if(!t.ok)return ih.debug(`Server scrub-tool-result returned non-ok`,{status:t.status}),e;let n=await t.json();return typeof n.text==`string`?n.text:e}catch(t){return ih.debug(`Server scrub-tool-result failed`,{error:t instanceof Error?t.message:String(t)}),e}}}const sh=n(`tool-adapter`);function ch(e){let t=[],n=0;for(let r of e.matchAll(ee())){let i=h(r[0]);if(!i)continue;let a=e.slice(n,r.index);a.trim()&&t.push({type:`text`,text:a.trimEnd()}),t.push({type:`image`,mimeType:i.mimeType,data:i.data}),n=r.index+r[0].length}let r=e.slice(n);return(r.trim()||t.length===0)&&t.push({type:`text`,text:r||e}),t}async function lh(e){let t=ch(e),n=[];for(let e of t)e.type===`image`?n.push(await g(e)):n.push(e);return n}function uh(e,t,n,r){if(!r)return{tracked:null,effectiveSignal:n};let i=r.processManager.spawn({kind:`tool`,argv:[e.name,...gh(t)],owner:r.owner,ppid:r.getParentPid?.()});n?.aborted?r.processManager.signal(i.pid,`SIGINT`):n&&n.addEventListener(`abort`,()=>r.processManager.signal(i.pid,`SIGINT`),{once:!0});let a=r.processManager.onSignal((e,t)=>{e.pid!==i.pid||t!==`SIGKILL`||r.processManager.exit(i.pid,null)});return{tracked:{record:i,manager:r.processManager,unsubscribeKill:a},effectiveSignal:i.abort.signal}}function dh(e,t){e&&e.manager.exit(e.record.pid,t)}async function fh(e,t,n){if(!n||typeof e!=`string`||e.length===0)return e;try{return await n.scrubToolResult(e)}catch(n){return sh.warn(`Tool-result scrub failed, falling back to unscrubbed content`,{tool:t,error:n instanceof Error?n.message:String(n)}),e}}async function ph(e,t){try{return await lh(e)}catch(n){return sh.warn(`Image processing failed, falling back to raw content`,{tool:t,error:n instanceof Error?n.message:String(n)}),ch(e)}}function mh(e,t,n){return{name:e.name,label:e.name,description:e.description,parameters:e.inputSchema,async execute(r,i,a,o){let s;o&&(s=f({onUpdate:o,toolName:e.name,toolCallId:r}));let c=uh(e,i,a,t);try{let t=await e.execute(i??{},c.effectiveSignal),r=await ph(await fh(t.content,e.name,n),e.name);return dh(c.tracked,+!!t.isError),{content:r,details:{isError:t.isError}}}catch(e){throw dh(c.tracked,c.tracked?.record.abort.signal.aborted?null:1),e}finally{s&&p(s),c.tracked?.unsubscribeKill()}}}}function hh(e,t,n){return e.map(e=>mh(e,t,n))}function gh(e){if(typeof e!=`object`||!e)return[];let t=e;for(let e of[`command`,`file_path`,`path`,`pattern`,`url`,`key`,`name`,`query`,`message`]){let n=t[e];if(typeof n==`string`&&n.length>0)return[n]}for(let e of Object.values(t))if(typeof e==`string`&&e.length>0)return[e];return[]}function _h(e,t){let n={input:0,output:0,cacheRead:0,cacheWrite:0},r=_(e);if(!r)return n;let i;for(let e of t.values()){let t=_(e.id);!t||t.family!==r.family||(!i||t.major>i.major||t.major===i.major&&t.minor>i.minor)&&(i={major:t.major,minor:t.minor,cost:e.cost})}return i?.cost??n}var vh=e({ACCOUNTS_KEY:()=>xh,__test__:()=>Ah,addAccount:()=>Xh,applyProviderDefaults:()=>zh,clearAllSettings:()=>Sg,clearApiKey:()=>_g,clearBaseUrl:()=>bg,clearSelectedProvider:()=>mg,exportProviders:()=>xg,getAccounts:()=>$,getAllAvailableModels:()=>Uh,getAllExtraOAuthDomains:()=>qh,getApiKey:()=>hg,getApiKeyForProvider:()=>ag,getApiVersionForProvider:()=>cg,getAvailableProviders:()=>jh,getBaseUrl:()=>vg,getBaseUrlForProvider:()=>og,getDeploymentForProvider:()=>sg,getExtraOAuthDomains:()=>Wh,getOAuthAccountInfo:()=>Lh,getProviderConfig:()=>Ph,getProviderModels:()=>Ih,getRawApiKeyForProvider:()=>ig,getSelectedModelId:()=>lg,getSelectedProvider:()=>fg,isModelHiddenFromPicker:()=>Vh,logoutOAuthAccount:()=>$h,maskOAuthTokenWithRetry:()=>eg,migrateLegacyAuthOnlySelection:()=>Oh,persistOAuthMaskViaServiceWorker:()=>tg,providerOffersLlmModels:()=>Mh,removeAccount:()=>Qh,resolveCurrentModel:()=>Dg,resolveModelById:()=>Eg,resolveModelByShorthand:()=>Og,resolveModelIdForScoop:()=>Ag,saveOAuthAccount:()=>rg,setApiKey:()=>gg,setBaseUrl:()=>yg,setExtraOAuthDomains:()=>Gh,setExtraOAuthDomainsAsync:()=>Kh,setSelectedModelId:()=>ug,setSelectedProvider:()=>pg});const yh=ae,bh=v,xh=`slicc_accounts`,Sh=`selected-model`,Ch=[`slicc_provider`,`slicc_api_key`,`slicc_base_url`,`anthropic_api_key`,`api_provider`,`azure_resource`,`bedrock_region`],wh=new Set([`github`]);function Th(e){let t;try{t=te()}catch{return!1}return t.includes(e)&&!o(e)}let Eh=!1;function Dh(){if(!Eh){Eh=!0;for(let e of Ch)try{localStorage.removeItem(e)}catch{}Oh()}}function Oh(){try{let e=localStorage.getItem(Sh);if(e){let t=e.indexOf(`:`);if(t>0){let n=e.slice(0,t);(wh.has(n)||Th(n))&&localStorage.removeItem(Sh)}}}catch{}try{let e=localStorage.getItem(xh);if(!e)return;let t=JSON.parse(e);if(!Array.isArray(t))return;let n=t.filter(e=>!(typeof e==`object`&&e&&typeof e.providerId==`string`&&Th(e.providerId)));n.length!==t.length&&localStorage.setItem(xh,JSON.stringify(n))}catch{}}function kh(){Eh=!1}const Ah={_resetLegacyCleanup:kh};function jh(){let e=te().filter(o),t=a();return[...new Set([...e,...t])].filter(e=>!s(e)?.hidden)}function Mh(e){try{if(Ih(e).length>0)return!0}catch{}try{if(v(e).length>0)return!0}catch{}let t=s(e);return!!(t?.modelOverrides&&Object.keys(t.modelOverrides).length>0)}function Nh(e,t){try{if(Ih(e).some(e=>e.id===t))return!0}catch{}try{if(v(e).some(e=>e.id===t))return!0}catch{}let n=s(e);return!!(n?.modelOverrides&&Object.hasOwn(n.modelOverrides,t))}function Ph(e){return s(e)||{id:e,name:e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),description:`${e} provider`,requiresApiKey:!0,requiresBaseUrl:!1}}function Fh(e,t){t.context_window!==void 0&&(e.contextWindow=t.context_window),t.max_tokens!==void 0&&(e.maxTokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),t.cost!==void 0&&(e.cost=t.cost,e.inputCost=t.cost.input,e.outputCost=t.cost.output,e.cacheReadCost=t.cost.cacheRead,e.cacheWriteCost=t.cost.cacheWrite),t.compat!==void 0&&(e.compat={...e.compat??{},...t.compat}),t.thinkingLevelMap!==void 0&&(e.thinkingLevelMap={...e.thinkingLevelMap??{},...t.thinkingLevelMap})}function Ih(e){try{if(e===`bedrock-camp`){let e=ie(og(`bedrock-camp`));return bh(`amazon-bedrock`).filter(t=>re(t,e)).map(e=>({...e,api:`bedrock-camp-converse`,provider:`bedrock-camp`}))}let t=Ph(e);if(t.getModelIds){let n;try{n=t.getModelIds()}catch(t){return Q.error(`Provider getModelIds callback failed`,{providerId:e,error:t instanceof Error?t.message:String(t)}),[]}let r=new Map;for(let e of te())try{for(let t of bh(e))r.set(t.id,t)}catch{}return n.map(n=>{let i=n.api===`openai`?`openai`:`anthropic`,a=`${e}-${i}`,o=r.get(n.id),s;if(o)s={...o,api:a,provider:e};else if(s=wg(e,n.id,``,a),n.name&&(s.name=n.name),i===`anthropic`){let e=_h(n.id,r);s.cost=e,s.inputCost=e.input,s.outputCost=e.output,s.cacheReadCost=e.cacheRead,s.cacheWriteCost=e.cacheWrite}let c=t.modelOverrides?.[n.id];return c&&Fh(s,c),Fh(s,n),s})}if(t.isOAuth){let n=bh(`anthropic`),r=`${e}-anthropic`;return n.map(n=>{let i={...n,api:r,provider:e},a=t.modelOverrides?.[n.id];return a&&Fh(i,a),i})}return bh(e===`azure-ai-foundry`?`anthropic`:e)}catch(t){return Q.error(`Failed to load models`,{providerId:e,error:t instanceof Error?t.message:String(t)}),[]}}function Lh(e){let t=$().find(t=>t.providerId===e);if(!t?.accessToken)return null;let n=!!t.tokenExpiresAt&&Date.now()>t.tokenExpiresAt-6e4;return{token:t.accessToken,maskedValue:t.maskedValue,expiresAt:t.tokenExpiresAt,userName:t.userName,userAvatar:t.userAvatar,scopes:t.scopes,expired:n}}const Rh=Object.assign({})[`/packages/webapp/providers.json`]??[],Q=n(`provider-settings`);function zh(e=Rh){if(e.length===0||$().length>0)return;let t=new Set(jh());for(let n of e)if(!(!n.providerId||!n.apiKey)){if(!t.has(n.providerId)){Q.warn(`Unknown provider "${n.providerId}" in providers.json — skipping`);continue}Xh(n.providerId,n.apiKey,n.baseUrl)}let n=e.find(e=>e.providerId&&e.apiKey&&t.has(e.providerId));n?.model&&!localStorage.getItem(Sh)&&localStorage.setItem(Sh,`${n.providerId}:${n.model}`)}const Bh=[/haiku/i];function Vh(e){return Bh.some(t=>t.test(e))}function Hh(e){return e.filter(e=>!Vh(e.id))}function Uh(){let e=$();if(e.length===0)return[];let t=new Map;for(let n of e){if(t.has(n.providerId))continue;let e=Ph(n.providerId);if(e.hidden||Th(n.providerId))continue;let r=Hh(Ih(n.providerId));if(r.length===0)continue;let i={providerId:n.providerId,providerName:e.name,models:r};t.set(n.providerId,i)}return[...t.values()]}function $(){Dh();let e=localStorage.getItem(xh);if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`object`&&!!e&&typeof e.providerId==`string`&&typeof e.apiKey==`string`):[]}catch{return[]}}function Wh(e){return se(localStorage)[e]??[]}function Gh(e,t){let n=se(localStorage),r=t.map(e=>e.trim()).filter(e=>e.length>0);r.length===0?delete n[e]:n[e]=r,ce(localStorage,n)}async function Kh(e,t){if(i()){Gh(e,t);return}let n=r();if(!n)throw Error(`setExtraOAuthDomainsAsync: no DOM and no panel-rpc client — cannot persist to page localStorage`);let{storeAfter:a}=await n.call(`oauth-extras-set`,{providerId:e,domains:t});try{ce(localStorage,a)}catch(t){Q.warn(`worker-shim mirror failed after successful page write — reload to refresh`,{providerId:e,error:t instanceof Error?t.message:String(t)})}}function qh(){return se(localStorage)}function Jh(e){localStorage.setItem(xh,JSON.stringify(e))}async function Yh(e){if(i()){Jh(e);return}let t=r();if(!t)throw Error(`saveAccountsAsync: no DOM and no panel-rpc client — cannot persist to page localStorage`);let n=JSON.stringify(e),{storedJson:a}=await t.call(`save-oauth-accounts`,{accountsJson:n});try{localStorage.setItem(xh,a)}catch(e){Q.warn(`worker-shim mirror failed after successful page write — reload to refresh`,{error:e instanceof Error?e.message:String(e)})}}function Xh(e,t,n,r,i){let a=$().filter(t=>t.providerId!==e),o={providerId:e,apiKey:t};n&&(o.baseUrl=n),r&&(o.deployment=r),i&&(o.apiVersion=i),a.push(o),Jh(a)}async function Zh(e){let t=le();try{if(t===`extension-direct`){let t=await new Promise(t=>{chrome.runtime.sendMessage({type:`secrets.delete`,name:`oauth.${e}.token`},n=>{chrome.runtime.lastError&&Q.error(`SW secrets.delete transport failed`,{providerId:e,error:chrome.runtime.lastError.message}),t(n??{})})});t.error&&Q.error(`SW secrets.delete returned error`,{providerId:e,error:t.error})}else if(t===`extension-delegate`){let t=await rh(`secrets.delete`,{name:`oauth.${e}.token`});t?.error&&Q.error(`Bridge secrets.delete returned error`,{providerId:e,error:t.error})}else if(t!==`connect`){let t=await fetch(l(`/api/secrets/oauth/${e}`),{method:`DELETE`,headers:u()});!t.ok&&t.status!==404&&Q.warn(`OAuth replica DELETE non-ok`,{providerId:e,status:t.status})}}catch(n){Q.error(`OAuth replica removal failed`,{providerId:e,topology:t,error:n instanceof Error?n.message:String(n)})}}async function Qh(e){let t=$().find(t=>t.providerId===e),n=Ph(e);t&&n?.isOAuth&&await $h(e),await Zh(e),await Yh($().filter(t=>t.providerId!==e));let r=localStorage.getItem(Sh)??``,i=r.indexOf(`:`);i>0&&r.slice(0,i)===e&&localStorage.removeItem(Sh)}async function $h(e){let t=$().find(t=>t.providerId===e);if(!t)return;let n=Ph(e);if(n?.isOAuth){if(n.onOAuthLogout)try{await n.onOAuthLogout()}catch(t){Q.warn(`onOAuthLogout failed`,{providerId:e,error:t instanceof Error?t.message:String(t)})}if(n.getOAuthLogoutUrl){let r=n.getOAuthLogoutUrl(t);if(r){let{openIdpLogoutUrl:t}=await import(`./oauth-service-bKcyWLK0.js`);await t(r).catch(t=>{Q.warn(`IdP logout popup failed`,{providerId:e,error:t instanceof Error?t.message:String(t)})})}}await Yh($().map(t=>t.providerId===e?{providerId:t.providerId,apiKey:``,baseUrl:t.baseUrl,userName:t.userName,userAvatar:t.userAvatar,loggedOut:!0}:t)),await Zh(e)}}async function eg(e,t={}){let n=Math.max(1,t.attempts??3),r=t.delayMs??150,i=t.sleep??(e=>new Promise(t=>setTimeout(t,e))),a;for(let t=0;t<n;t++){let o=await e();if(o.maskedValue)return{maskedValue:o.maskedValue};o.error&&(a=o.error),t<n-1&&await i(r)}return{lastError:a}}async function tg(e,t,n){let r={providerId:e.providerId,accessToken:e.accessToken,domains:e.domains.join(`,`)},{maskedValue:i,lastError:a}=await eg(()=>t.sendMaskRequest(r),n);if(!i){Q.error(`OAuth mask give-up: no masked value after retries`,{providerId:e.providerId,reason:a??`no error reported (cold SW or empty reply)`});return}let o=t.getAccounts(),s=o.find(t=>t.providerId===e.providerId);s&&(s.maskedValue=i,await t.saveAccounts(o))}function ng(e,t){if(e.accessToken)return`scopes`in e?e.scopes:t?.scopes}async function rg(e){let t=$().find(t=>t.providerId===e.providerId),n=$().filter(t=>t.providerId!==e.providerId);n.push({providerId:e.providerId,apiKey:``,accessToken:e.accessToken,refreshToken:e.refreshToken,tokenExpiresAt:e.tokenExpiresAt,userName:e.userName,userAvatar:e.userAvatar,baseUrl:e.baseUrl??t?.baseUrl,scopes:ng(e,t)}),await Yh(n);let r=Ph(e.providerId)?.oauthTokenDomains??[],i=Wh(e.providerId),a=new Set,o=[];for(let e of[...r,...i]){let t=e.toLowerCase();a.has(t)||(a.add(t),o.push(e))}if(o.length===0)return;let s=le();try{if(s===`extension-direct`)await tg({providerId:e.providerId,accessToken:e.accessToken,domains:o},{sendMaskRequest:t=>new Promise(n=>{chrome.runtime.sendMessage({type:`secrets.mask-oauth-token`,...t},t=>{chrome.runtime.lastError&&Q.error(`SW mask-oauth-token transport failed`,{providerId:e.providerId,error:chrome.runtime.lastError.message});let r=typeof t==`object`&&t?t:void 0;r?.error&&Q.warn(`SW mask-oauth-token returned error`,{providerId:e.providerId,error:r.error}),n(r??{})})}),getAccounts:$,saveAccounts:Yh});else if(s===`extension-delegate`)await tg({providerId:e.providerId,accessToken:e.accessToken,domains:o},{sendMaskRequest:t=>rh(`secrets.mask-oauth-token`,t).then(t=>(t?.error&&Q.warn(`Bridge mask-oauth-token returned error`,{providerId:e.providerId,error:t.error}),t??{})).catch(t=>(Q.error(`Bridge mask-oauth-token transport failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)}),{})),getAccounts:$,saveAccounts:Yh});else if(s!==`connect`){let t=await fetch(l(`/api/secrets/oauth-update`),{method:`POST`,headers:u({"Content-Type":`application/json`}),body:JSON.stringify({providerId:e.providerId,accessToken:e.accessToken,domains:o})});if(t.ok){let n=await t.json();if(typeof n.maskedValue==`string`){let t=$(),r=t.find(t=>t.providerId===e.providerId);r&&(r.maskedValue=n.maskedValue,await Yh(t))}else Q.warn(`OAuth replica POST ok but missing maskedValue`,{providerId:e.providerId})}else Q.warn(`OAuth replica POST non-ok`,{providerId:e.providerId,status:t.status})}}catch(t){Q.error(`OAuth replica sync failed`,{providerId:e.providerId,topology:s,error:t instanceof Error?t.message:String(t)})}}function ig(e){let t=$().find(t=>t.providerId===e);return t&&(t.accessToken||t.apiKey)||null}function ag(e){let t=$().find(t=>t.providerId===e);return t?t.accessToken||t.apiKey||(Ph(e).optionalApiKey?`local`:null):null}function og(e){return $().find(t=>t.providerId===e)?.baseUrl??null}function sg(e){return $().find(t=>t.providerId===e)?.deployment??null}function cg(e){return $().find(t=>t.providerId===e)?.apiVersion??null}function lg(){let e=localStorage.getItem(Sh)||``,t=e.indexOf(`:`);return t>=0?e.slice(t+1):e}function ug(e){let t=e.indexOf(`:`);if(t>0){let n=e.slice(0,t),r=new Set([...a(),...jh()]),i=n.includes(`.`);if(r.has(n)||!i){localStorage.setItem(Sh,e);return}}let n=fg();localStorage.setItem(Sh,`${n}:${e}`)}function dg(){return localStorage.getItem(Sh)||``}function fg(){let e=dg(),t=e.indexOf(`:`);if(t>0)return e.slice(0,t);let n=$(),r=lg();if(r){let e=n.find(e=>Mh(e.providerId)&&Nh(e.providerId,r));if(e)return e.providerId}let i=n.find(e=>Mh(e.providerId));return i?i.providerId:n.length>0?n[0].providerId:`anthropic`}function pg(e){let t=lg();localStorage.setItem(Sh,`${e}:${t}`)}function mg(){let e=lg();localStorage.setItem(Sh,e)}function hg(){return ag(fg())}function gg(e){let t=fg();Xh(t,e,og(t)??void 0)}async function _g(){await Qh(fg())}function vg(){return og(fg())}function yg(e){let t=fg(),n=ig(t);n&&Xh(t,n,e||void 0)}function bg(){let e=fg(),t=ig(e);t&&Xh(e,t)}function xg(){let e=$(),t=fg(),n=lg();return e.map(e=>{let r={providerId:e.providerId,apiKey:e.apiKey};return e.baseUrl&&(r.baseUrl=e.baseUrl),e.providerId===t&&n&&(r.model=n),r})}async function Sg(){let e=$();await Promise.allSettled(e.map(e=>Qh(e.providerId))),localStorage.removeItem(xh),localStorage.removeItem(Sh);for(let e of Ch)localStorage.removeItem(e)}function Cg(e){return/^(?:gpt[-.]?|o[0-9]|chatgpt)/i.test(e)?`openai`:`anthropic`}function wg(e,t,n,r){return{id:t,name:t,provider:e,api:r??`${e}-${Cg(t)}`,baseUrl:n??``,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},reasoning:!0}}function Tg(e,t){return t.isOAuth||e===`azure-ai-foundry`?`anthropic`:e===`bedrock-camp`?`amazon-bedrock`:e}function Eg(e){if(!e)return Dg();let t=fg(),n=og(t),r=Ph(t);try{let i=Tg(t,r),a=yh(i,e);if(!a?.id)throw Error(`Model ${e} not found`);let o=a;return r.isOAuth?o=Ih(t).find(t=>t.id===e)||{...o,api:`${t}-anthropic`,provider:t}:t===`bedrock-camp`&&(o={...o,api:`bedrock-camp-converse`,provider:`bedrock-camp`}),n&&(o={...o,baseUrl:n}),o}catch(i){if(Q.debug(`resolveModelById: pi-ai lookup miss, using provider fallback`,{providerId:t,modelId:e,error:i instanceof Error?i.message:String(i)}),r.isOAuth){let r=Ih(t).find(t=>t.id===e);return r?n?{...r,baseUrl:n}:r:wg(t,e,n)}return Dg()}}function Dg(){let e=fg(),t=lg(),n=og(e),r=Ih(e),i=Ph(e),a=i.defaultModelId?r.find(e=>e.id.toLowerCase().includes(i.defaultModelId.toLowerCase()))?.id:void 0,o=t||a||r[0]?.id||`claude-sonnet-4-6`;try{let t=Tg(e,i),a=yh(t,o);if(!a?.id)throw Error(`Model ${o} not found in ${t} registry`);let s=a;return i.isOAuth?s=r.find(e=>e.id===o)||{...s,api:`${e}-anthropic`,provider:e}:e===`bedrock-camp`&&(s={...s,api:`bedrock-camp-converse`,provider:`bedrock-camp`}),n&&(s={...s,baseUrl:n}),s}catch(t){Q.debug(`resolveCurrentModel: pi-ai lookup miss, using provider fallback`,{providerId:e,effectiveModelId:o,error:t instanceof Error?t.message:String(t)});let a=r.find(e=>e.id===o);return a?n?{...a,baseUrl:n}:a:i.isOAuth?wg(e,o,n):yh(`anthropic`,`claude-sonnet-4-0`)}}function Og(e){let t=e.toLowerCase();if(!t)return null;let n=null;try{n=fg()}catch{}if(n!==null){let e=kg(t,[n]);if(e!==null)return e}return kg(t,$().map(e=>e.providerId))}function kg(e,t){let n=null,r=-1;for(let i of t)for(let t of Ih(i)){let i=t.id.toLowerCase(),a=(t.name??``).toLowerCase();if(!i.includes(e)&&!a.includes(e))continue;let o=t.contextWindow??0;(o>r||o===r&&jg(t.id,n??``)>0)&&(r=o,n=t.id)}return n}function Ag(e){if(!e)return null;let t=[e],n=Og(e);n!==null&&n!==e&&t.push(n);let r=[];try{r=Ih(fg())}catch{}for(let n of t)if(!(r.length>0&&!r.some(e=>e.id===n)))try{if(Eg(n).id===n)return n}catch(t){Q.debug(`resolveModelIdForScoop: candidate did not resolve`,{input:e,candidate:n,error:t instanceof Error?t.message:String(t)})}return null}function jg(e,t){let n=e.match(/\d+/g)?.map(Number)??[],r=t.match(/\d+/g)?.map(Number)??[],i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=(n[e]??0)-(r[e]??0);if(t!==0)return t}return 0}export{Af as $,$e as $t,eg as A,ue as An,Xn as At,gg as B,A as Bt,Ph as C,Ie as Cn,ur as Ct,fg as D,Ge as Dn,ar as Dt,lg as E,Ze as En,F as Et,Dg as F,M as Ft,pg as G,Gt,Gh as H,en as Ht,Eg as I,vn as It,oh as J,zt as Jt,_h as K,Ht as Kt,Og as L,fn as Lt,tg as M,Sn as Mt,Mh as N,xn as Nt,Vh as O,T as On,nr as Ot,Qh as P,yn as Pt,zm as Q,wt as Qt,Ag as R,ln as Rt,Lh as S,Fe as Sn,lr as St,ig as T,Re as Tn,fr as Tt,Kh as U,Jt as Ut,yg as V,rn as Vt,ug as W,qt as Wt,th as X,At as Xt,rh as Y,Rt as Yt,Ym as Z,Et as Zt,jh as _,Je as _n,br as _t,zh as a,Oe as an,ra as at,sg as b,Pe as bn,mr as bt,bg as c,it as cn,Xi as ct,$ as d,He as dn,z as dt,Qe as en,Ef as et,Uh as f,ze as fn,Ur as ft,cg as g,qe as gn,xr as gt,ag as h,Be as hn,L as ht,Xh as i,De as in,ia as it,Oh as j,le as jn,Yn as jt,$h as k,Ee as kn,tr as kt,mg as l,S as ln,Yi as lt,hg as m,Ve as mn,R as mt,Ah as n,Xe as nn,lf as nt,Sg as o,ke as on,Qi as ot,qh as p,Me as pn,zr as pt,hh as q,Bt as qt,vh as r,w as rn,mo as rt,_g as s,Ae as sn,Ki as st,xh as t,Ye as tn,xf as tt,xg as u,je as un,Zi as ut,vg as v,Ue as vn,yr as vt,Ih as w,Le as wn,dr as wt,Wh as x,x as xn,I as xt,og as y,Ne as yn,_r as yt,rg as z,j as zt};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/oauth-service-D0NOHMOb.js","assets/preload-helper-Czpn1I53.js","assets/proxied-fetch-A48etSCh.js","assets/rolldown-runtime-aKtaBQYM.js","assets/base64-DpPqYZJF.js","assets/src-BStYtmHq.js","assets/runtime-env-DH4NDw4t.js","assets/fetch-body-D2PwksUW.js","assets/panel-rpc-DmJSNs0I.js","assets/wc-permissions-registry-Blyunq37.js"])))=>i.map(i=>d[i]);
2
+ import{K as e,d as t,y as n,z as r}from"./account-store-DUSlZEzF.js";import{a as i}from"./diagnostics-DN_idNHx.js";import{t as a}from"./preload-helper-Czpn1I53.js";import{a as o,i as s,r as c}from"./compat-BhgG-Qr-.js";import{a as l,r as u,s as d,t as f}from"./legacy-api-aliases-DrEKVikN.js";import{t as p}from"./panel-rpc-DmJSNs0I.js";import{a as m,i as h,o as g,s as _}from"./bedrock-camp-CVX95quY.js";import"./provider-settings-CRF2kKcK.js";import{n as v,t as ee}from"./silent-renew-backoff-HDNNYx7x.js";import{getOAuthPageOrigin as te}from"./oauth-service-D0NOHMOb.js";import{t as ne}from"./llm-session-id-bZQs6gBN.js";var re={proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`};function y(e,t){return m(e,t)}function b(e,t,n){return e!==`xhigh`||!t?e:_(t,n)?`xhigh`:g(t,n)?`max`:`high`}function ie(e,t){let n=e?t?.thinkingLevelMap?.[e]:void 0;return b((()=>{if(typeof n==`string`)return n;switch(e){case`minimal`:case`low`:return`low`;case`medium`:return`medium`;case`xhigh`:return`xhigh`;default:return`high`}})(),t?.id,t?.name)}function ae(e,t){return async(n,r)=>{let i=t?await t(n,r)??n:n,a=i.thinking;return a&&a.type===`enabled`&&(i.thinking={type:`adaptive`,...a.display===void 0?{}:{display:a.display}},i.output_config={...i.output_config??{},effort:e}),i}}function x(e,t){if(!y(e.id,e.name))return t;let n=t,r=b(n.effort??ie(n.reasoning,e),e.id,e.name);return{...t,onPayload:ae(r,n.onPayload)}}function oe(e,t){let n={id:e.id,name:e.name??e.id},r=t?.api??e.api,i=t?.context_window??e.context_window,a=t?.max_tokens??e.max_tokens,o=t?.reasoning??e.reasoning,s=t?.input??e.input;r&&(n.api=r),i!==void 0&&(n.context_window=i),a!==void 0&&(n.max_tokens=a),o!==void 0&&(n.reasoning=o),s&&(n.input=s);let c=t?.cost??e.cost;return c&&(n.cost=c),/haiku/i.test(e.id)&&(n.compat={supportsEagerToolInputStreaming:!1}),/sonnet-5\b/i.test(e.id)&&!n.thinkingLevelMap&&(n.thinkingLevelMap={xhigh:`xhigh`}),n}var S=Object.assign({"/packages/webapp/providers/adobe-config.json":re})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function C(){let e=n(`adobe`);if(e)return e.replace(/\/$/,``);if(S.proxyEndpoint)return S.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}var w=new Map,T=new Map,E=`slicc-adobe-models`;function D(e){try{localStorage.setItem(E,JSON.stringify(e))}catch{}}async function O(e){let t=w.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[G]:`6.8.0`}});if(t.ok){let n=await t.json();return w.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}return{}}function k(e){let t=e.clientId||S.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function A(e){return e.scopes||S.scopes}function j(e){return e.imsEnvironment||S.imsEnvironment||`prod`}var M={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function N(e){return M[e??S.imsEnvironment??`prod`]??M.prod}var P=typeof chrome<`u`&&!!chrome?.runtime?.id;function F(){return t().find(e=>e.providerId===`adobe`)}async function se(e,t){try{let n=await fetch(`${N(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function I(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10),scope:n.get(`scope`)??void 0}:null}var L={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!S.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`,`admin.hlx.page`,`admin.hlx.live`,`admin.aem.page`,`admin.aem.live`],getModelIds:()=>{let e=e=>oe(e,T.get(e.id));for(let t of Q.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id,reasoning:t.reasoning,input:t.input,cost:t.cost}));return D(n),n}for(let t of w.values())if(t.models?.length)return t.models.map(t=>e(t));try{let e=localStorage.getItem(E);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,t,n)=>{let i=C(),a=await O(i),o=k(a),s=A(a),c=j(a),l=P?null:await te(),u=P?null:v({pageHref:l.href,pageOrigin:l.origin,configuredRedirectUri:S.redirectUri},()=>crypto.randomUUID()),d=P?S.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:u.redirectUri,f=u?.oauthState,p=u?.expectedNonce??null,m=new URLSearchParams({client_id:o,scope:s,response_type:`token`,redirect_uri:d});f&&m.set(`state`,f),n?.forceReauth&&m.set(`prompt`,`login`);let h=await e(`${N(c)}/ims/authorize/v2?${m}`);if(!h)return;if(p&&h)try{if(new URL(h).searchParams.get(`nonce`)!==p){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let g=I(h);if(!g){console.error(`[adobe] Could not extract token from redirect URL`);return}let _=await se(g.accessToken,c);await r({providerId:`adobe`,accessToken:g.accessToken,tokenExpiresAt:Date.now()+g.expiresIn*1e3,userName:_.name,userAvatar:_.avatar,scopes:g.scope,baseUrl:S.proxyEndpoint?void 0:i}),await $().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),t()},onOAuthLogout:async()=>{let e=F();if(e?.accessToken)try{let t=w.values().next().value??{},n=t.clientId||S.clientId,r=j(t);if(n){let t=await fetch(`${N(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await r({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>F()?.accessToken?V():null,refreshModels:async e=>{await $(e);let t=L.getModelIds?.();t?.length&&D(t)}},R=null,ce=ee();async function z(){let e=F();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);let t=await ce.run(()=>V());if(t)return t;let n=F();if((n?.tokenExpiresAt??0)-Date.now()>0&&n?.accessToken)return n.accessToken;throw Error(`Adobe session expired — please log in again`)}function B(){let e=F();return!e?.tokenExpiresAt||Date.now()>e.tokenExpiresAt-6e4}async function V(){if(typeof window>`u`){let e=p();if(!e)return null;try{let{accessToken:t}=await e.call(`silent-renew`,{providerId:`adobe`},{timeoutMs:13e4});return t}catch(e){return console.warn(`[adobe] worker→page silent-renew bridge failed:`,e instanceof Error?e.message:String(e)),null}}return R||(R=le().finally(()=>{R=null}),R)}function H(e,t){let n=k(t),r=A(t),i=j(t),a=P?null:v({pageHref:window.location.href,pageOrigin:window.location.origin,configuredRedirectUri:S.redirectUri},()=>crypto.randomUUID()),o=P?S.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:a.redirectUri,s=a?.oauthState,c=a?.expectedNonce??null,l=new URLSearchParams({client_id:n,scope:r,response_type:`token`,redirect_uri:o,prompt:`none`});return s&&l.set(`state`,s),{authorizeUrl:`${N(i)}/ims/authorize/v2?${l}`,expectedNonce:c,proxyEndpoint:e}}function U(e,t){if(!t)return!0;try{if(new URL(e).searchParams.get(`nonce`)!==t)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),!1}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}return!0}async function W(e,t){let n=F();await r({providerId:`adobe`,accessToken:e.accessToken,tokenExpiresAt:Date.now()+e.expiresIn*1e3,userName:n?.userName,userAvatar:n?.userAvatar,scopes:e.scope,baseUrl:S.proxyEndpoint?void 0:t})}async function le(){try{let e=C(),{authorizeUrl:t,expectedNonce:n}=H(e,await O(e)),{createOAuthLauncher:r}=await a(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-D0NOHMOb.js`);return{createOAuthLauncher:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),i=await r()(t,{interactive:!1});if(!i||!U(i,n))return null;let o=I(i);return o?(await W(o,e),console.log(`[adobe] Token renewed silently`),await $().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),o.accessToken):null}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}}var G=`X-Slicc-Version`;function K(e){let t={},n=G.toLowerCase();if(e.headers)for(let[r,i]of Object.entries(e.headers))r.toLowerCase()!==n&&(t[r]=i);return t[G]=`6.8.0`,{...e,headers:t}}var ue=`adobe-provider-fallback`,q=new Set;function J(e,t){if(e.headers){for(let[t,n]of Object.entries(e.headers))if(t.toLowerCase()===`x-session-id`&&n!=null)return e}return q.has(t)||(q.add(t),console.warn(`[adobe] Missing X-Session-Id from ${t} — using daily fallback. Attach an X-Session-Id header at the call site (see scoop-context.ts streamWithSessionId or docs/pitfalls.md).`)),{...e,headers:{...e.headers??{},"X-Session-Id":ne(ue)}}}function de(){q.clear()}function Y(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}var X=(e,t,n={})=>{let r=i();return(async()=>{try{let i=await z();if(String(e.api).includes(`openai`)){let a=u({...e,baseUrl:`${C()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,K(J({...n,apiKey:i},`streamAdobe[openai]`)));for await(let e of a)r.push(e)}else{let a=f({...e,baseUrl:C(),api:`anthropic-messages`},t,K(J(x(e,h(e.id,e.name,{...n,apiKey:i})),`streamAdobe[anthropic]`)));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(Y(e,t)),r.end()}})(),r},Z=(e,t,n)=>{let r=i();return(async()=>{try{let i=await z();if(String(e.api).includes(`openai`)){let a=d({...e,baseUrl:`${C()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,K(J({...n,apiKey:i},`streamSimpleAdobe[openai]`)));for await(let e of a)r.push(e)}else{let a=l({...e,baseUrl:C(),api:`anthropic-messages`},t,K(J(x(e,h(e.id,e.name,{...n,apiKey:i})),`streamSimpleAdobe[anthropic]`)));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(Y(e,t)),r.end()}})(),r};function fe(e){let t={id:e.id,name:e.name};return e.api!==void 0&&(t.api=e.api),e.context_window!==void 0&&(t.context_window=e.context_window),e.max_tokens!==void 0&&(t.max_tokens=e.max_tokens),e.reasoning!==void 0&&(t.reasoning=e.reasoning),e.input!==void 0&&(t.input=e.input),t}function pe(){let e=new Map;for(let t of s())try{for(let n of c(t))e.set(n.id,n)}catch{}return e}function me(t,n,r){let i=`adobe-${t.api===`openai`?`openai`:`anthropic`}`,a=r.get(t.id);if(a)return{...a,provider:`adobe`,api:i};let o=e(t.id,r);return{id:t.id,name:t.name??t.id,provider:`adobe`,api:i,baseUrl:n,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:o,inputCost:o.input,outputCost:o.output,cacheReadCost:o.cacheRead,cacheWriteCost:o.cacheWrite,reasoning:!0}}function he(e,t){for(let t of e)T.set(t.id,fe(t));let n=pe();return e.map(e=>me(e,t,n))}async function ge(e){try{let t=e??await z(),n=C(),r=await fetch(`${n}/v1/models`,{headers:{Authorization:`Bearer ${t}`,[G]:`6.8.0`}});if(!r.ok)console.warn(`[adobe] Proxy /v1/models returned ${r.status}, falling back to Anthropic models`);else{let e=await r.json();if(e.data?.length)return he(e.data,n)}}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return null}var Q=new Map;function _e(){return c(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}async function $(e){let t=C(),n=Q.get(t);if(n)return n;let r=await ge(e);return r?(Q.set(t,r),r):_e()}function ve(){o({api:`adobe-anthropic`,stream:X,streamSimple:Z}),o({api:`adobe-openai`,stream:X,streamSimple:Z})}export{de as __resetAdobeSessionIdWarningCacheForTests,L as config,I as extractTokenFromUrl,$ as getAdobeModels,z as getValidAccessToken,B as isTokenExpired,ve as register};
@@ -0,0 +1 @@
1
+ import{n as e}from"./panel-rpc-CjFVE0nK.js";import{K as t,d as n,y as r,z as i}from"./account-store-DhDTX9zd.js";import{a}from"./diagnostics-DN_idNHx.js";import{a as o,d as s,f as c,i as l,o as u,p as d,s as f}from"./bedrock-camp-CHi38ceE.js";import{a as p,r as m,s as h,t as g}from"./legacy-api-aliases-MR6kosFL.js";import{n as _}from"./llm-session-id-ZObKEXzb.js";import{n as v,t as ee}from"./silent-renew-backoff-Chq7fPuc.js";import{getOAuthPageOrigin as te}from"./oauth-service-bKcyWLK0.js";import"./provider-settings-D5WKqwpE.js";var ne={proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`};function re(e,t){return o(e,t)}function y(e,t,n){return e!==`xhigh`||!t?e:f(t,n)?`xhigh`:u(t,n)?`max`:`high`}function ie(e,t){let n=e?t?.thinkingLevelMap?.[e]:void 0;return y((()=>{if(typeof n==`string`)return n;switch(e){case`minimal`:case`low`:return`low`;case`medium`:return`medium`;case`xhigh`:return`xhigh`;default:return`high`}})(),t?.id,t?.name)}function ae(e,t){return async(n,r)=>{let i=t?await t(n,r)??n:n,a=i.thinking;return a&&a.type===`enabled`&&(i.thinking={type:`adaptive`,...a.display===void 0?{}:{display:a.display}},i.output_config={...i.output_config??{},effort:e}),i}}function b(e,t){if(!re(e.id,e.name))return t;let n=t,r=y(n.effort??ie(n.reasoning,e),e.id,e.name);return{...t,onPayload:ae(r,n.onPayload)}}function oe(e,t){let n={id:e.id,name:e.name??e.id},r=t?.api??e.api,i=t?.context_window??e.context_window,a=t?.max_tokens??e.max_tokens,o=t?.reasoning??e.reasoning,s=t?.input??e.input;r&&(n.api=r),i!==void 0&&(n.context_window=i),a!==void 0&&(n.max_tokens=a),o!==void 0&&(n.reasoning=o),s&&(n.input=s);let c=t?.cost??e.cost;return c&&(n.cost=c),/haiku/i.test(e.id)&&(n.compat={supportsEagerToolInputStreaming:!1}),/sonnet-5\b/i.test(e.id)&&!n.thinkingLevelMap&&(n.thinkingLevelMap={xhigh:`xhigh`}),n}const x=Object.assign({"/packages/webapp/providers/adobe-config.json":ne})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function S(){let e=r(`adobe`);if(e)return e.replace(/\/$/,``);if(x.proxyEndpoint)return x.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}const C=new Map,w=new Map,T=`slicc-adobe-models`;function E(e){try{localStorage.setItem(T,JSON.stringify(e))}catch{}}async function D(e){let t=C.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[W]:`6.8.0`}});if(t.ok){let n=await t.json();return C.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}return{}}function O(e){let t=e.clientId||x.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function k(e){return e.scopes||x.scopes}function A(e){return e.imsEnvironment||x.imsEnvironment||`prod`}const j={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function M(e){return j[e??x.imsEnvironment??`prod`]??j.prod}const N=typeof chrome<`u`&&!!chrome?.runtime?.id;function P(){return n().find(e=>e.providerId===`adobe`)}async function se(e,t){try{let n=await fetch(`${M(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function F(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10),scope:n.get(`scope`)??void 0}:null}const I={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!x.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`,`admin.hlx.page`,`admin.hlx.live`,`admin.aem.page`,`admin.aem.live`],getModelIds:()=>{let e=e=>oe(e,w.get(e.id));for(let t of Q.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id,reasoning:t.reasoning,input:t.input,cost:t.cost}));return E(n),n}for(let t of C.values())if(t.models?.length)return t.models.map(t=>e(t));try{let e=localStorage.getItem(T);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,t,n)=>{let r=S(),a=await D(r),o=O(a),s=k(a),c=A(a),l=N?null:await te(),u=N?null:v({pageHref:l.href,pageOrigin:l.origin,configuredRedirectUri:x.redirectUri},()=>crypto.randomUUID()),d=N?x.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:u.redirectUri,f=u?.oauthState,p=u?.expectedNonce??null,m=new URLSearchParams({client_id:o,scope:s,response_type:`token`,redirect_uri:d});f&&m.set(`state`,f),n?.forceReauth&&m.set(`prompt`,`login`);let h=await e(`${M(c)}/ims/authorize/v2?${m}`);if(!h)return;if(p&&h)try{if(new URL(h).searchParams.get(`nonce`)!==p){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let g=F(h);if(!g){console.error(`[adobe] Could not extract token from redirect URL`);return}let _=await se(g.accessToken,c);await i({providerId:`adobe`,accessToken:g.accessToken,tokenExpiresAt:Date.now()+g.expiresIn*1e3,userName:_.name,userAvatar:_.avatar,scopes:g.scope,baseUrl:x.proxyEndpoint?void 0:r}),await $().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),t()},onOAuthLogout:async()=>{let e=P();if(e?.accessToken)try{let t=C.values().next().value??{},n=t.clientId||x.clientId,r=A(t);if(n){let t=await fetch(`${M(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await i({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>P()?.accessToken?z():null,refreshModels:async e=>{await $(e);let t=I.getModelIds?.();t?.length&&E(t)}};let L=null;const ce=ee();async function R(){let e=P();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);let t=await ce.run(()=>z());if(t)return t;let n=P();if((n?.tokenExpiresAt??0)-Date.now()>0&&n?.accessToken)return n.accessToken;throw Error(`Adobe session expired — please log in again`)}function le(){let e=P();return!e?.tokenExpiresAt||Date.now()>e.tokenExpiresAt-6e4}async function z(){if(typeof window>`u`){let t=e();if(!t)return null;try{let{accessToken:e}=await t.call(`silent-renew`,{providerId:`adobe`},{timeoutMs:13e4});return e}catch(e){return console.warn(`[adobe] worker→page silent-renew bridge failed:`,e instanceof Error?e.message:String(e)),null}}return L||(L=U().finally(()=>{L=null}),L)}function B(e,t){let n=O(t),r=k(t),i=A(t),a=N?null:v({pageHref:window.location.href,pageOrigin:window.location.origin,configuredRedirectUri:x.redirectUri},()=>crypto.randomUUID()),o=N?x.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:a.redirectUri,s=a?.oauthState,c=a?.expectedNonce??null,l=new URLSearchParams({client_id:n,scope:r,response_type:`token`,redirect_uri:o,prompt:`none`});return s&&l.set(`state`,s),{authorizeUrl:`${M(i)}/ims/authorize/v2?${l}`,expectedNonce:c,proxyEndpoint:e}}function V(e,t){if(!t)return!0;try{if(new URL(e).searchParams.get(`nonce`)!==t)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),!1}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}return!0}async function H(e,t){let n=P();await i({providerId:`adobe`,accessToken:e.accessToken,tokenExpiresAt:Date.now()+e.expiresIn*1e3,userName:n?.userName,userAvatar:n?.userAvatar,scopes:e.scope,baseUrl:x.proxyEndpoint?void 0:t})}async function U(){try{let e=S(),{authorizeUrl:t,expectedNonce:n}=B(e,await D(e)),{createOAuthLauncher:r}=await import(`./oauth-service-bKcyWLK0.js`),i=await r()(t,{interactive:!1});if(!i||!V(i,n))return null;let a=F(i);return a?(await H(a,e),console.log(`[adobe] Token renewed silently`),await $().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),a.accessToken):null}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}}const W=`X-Slicc-Version`;function G(e){let t={};if(e.headers)for(let[n,r]of Object.entries(e.headers))n.toLowerCase()!==`x-slicc-version`&&(t[n]=r);return t[W]=`6.8.0`,{...e,headers:t}}const K=new Set;function q(e,t){if(e.headers){for(let[t,n]of Object.entries(e.headers))if(t.toLowerCase()===`x-session-id`&&n!=null)return e}return K.has(t)||(K.add(t),console.warn(`[adobe] Missing X-Session-Id from ${t} — using daily fallback. Attach an X-Session-Id header at the call site (see scoop-context.ts streamWithSessionId or docs/pitfalls.md).`)),{...e,headers:{...e.headers??{},"X-Session-Id":_(`adobe-provider-fallback`)}}}function ue(){K.clear()}function J(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const Y=(e,t,n={})=>{let r=a();return(async()=>{try{let i=await R();if(String(e.api).includes(`openai`)){let a=m({...e,baseUrl:`${S()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,G(q({...n,apiKey:i},`streamAdobe[openai]`)));for await(let e of a)r.push(e)}else{let a=g({...e,baseUrl:S(),api:`anthropic-messages`},t,G(q(b(e,l(e.id,e.name,{...n,apiKey:i})),`streamAdobe[anthropic]`)));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(J(e,t)),r.end()}})(),r},X=(e,t,n)=>{let r=a();return(async()=>{try{let i=await R();if(String(e.api).includes(`openai`)){let a=h({...e,baseUrl:`${S()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,G(q({...n,apiKey:i},`streamSimpleAdobe[openai]`)));for await(let e of a)r.push(e)}else{let a=p({...e,baseUrl:S(),api:`anthropic-messages`},t,G(q(b(e,l(e.id,e.name,{...n,apiKey:i})),`streamSimpleAdobe[anthropic]`)));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(J(e,t)),r.end()}})(),r};function de(e){let t={id:e.id,name:e.name};return e.api!==void 0&&(t.api=e.api),e.context_window!==void 0&&(t.context_window=e.context_window),e.max_tokens!==void 0&&(t.max_tokens=e.max_tokens),e.reasoning!==void 0&&(t.reasoning=e.reasoning),e.input!==void 0&&(t.input=e.input),t}function Z(){let e=new Map;for(let t of c())try{for(let n of s(t))e.set(n.id,n)}catch{}return e}function fe(e,n,r){let i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`,a=r.get(e.id);if(a)return{...a,provider:`adobe`,api:i};let o=t(e.id,r);return{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:n,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:o,inputCost:o.input,outputCost:o.output,cacheReadCost:o.cacheRead,cacheWriteCost:o.cacheWrite,reasoning:!0}}function pe(e,t){for(let t of e)w.set(t.id,de(t));let n=Z();return e.map(e=>fe(e,t,n))}async function me(e){try{let t=e??await R(),n=S(),r=await fetch(`${n}/v1/models`,{headers:{Authorization:`Bearer ${t}`,[W]:`6.8.0`}});if(!r.ok)console.warn(`[adobe] Proxy /v1/models returned ${r.status}, falling back to Anthropic models`);else{let e=await r.json();if(e.data?.length)return pe(e.data,n)}}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return null}const Q=new Map;function he(){return s(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}async function $(e){let t=S(),n=Q.get(t);if(n)return n;let r=await me(e);return r?(Q.set(t,r),r):he()}function ge(){d({api:`adobe-anthropic`,stream:Y,streamSimple:X}),d({api:`adobe-openai`,stream:Y,streamSimple:X})}export{ue as __resetAdobeSessionIdWarningCacheForTests,I as config,F as extractTokenFromUrl,$ as getAdobeModels,R as getValidAccessToken,le as isTokenExpired,ge as register};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./event-stream-qbAZIAKV.js";import{i as t,n,o as r,r as i,t as a}from"./transform-messages-Bp94o3FD.js";import{n as o,t as s}from"./json-parse-CpLf0aqK.js";import{t as c}from"./provider-env-DwY8YuMk.js";import{t as l}from"./deferred-tools-DNuoafg8.js";import{t as u}from"./headers-CbDaTl3c.js";import{t as d}from"./provider-retry-C8PJzY_l.js";import{t as f}from"./sanitize-unicode-DmIE6hZJ.js";import{a as p}from"./constrained-sampling-DafcjXU6.js";import{n as ee,t as m}from"./github-copilot-headers-DRgtIyTm.js";function h(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function g(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}let te=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return te=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function ne(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}const re=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};var _=class extends Error{},v=class e extends _{constructor(t,n,r,i,a){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`request-id`),this.error=n,this.type=a??null}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new ie({message:r,cause:re(n)});let a=n,o=a?.error?.type;return t===400?new oe(t,a,r,i,o):t===401?new se(t,a,r,i,o):t===403?new ce(t,a,r,i,o):t===404?new le(t,a,r,i,o):t===409?new ue(t,a,r,i,o):t===422?new de(t,a,r,i,o):t===429?new fe(t,a,r,i,o):t>=500?new pe(t,a,r,i,o):new e(t,a,r,i,o)}},y=class extends v{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},ie=class extends v{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},ae=class extends ie{constructor({message:e}={}){super({message:e??`Request timed out.`})}},oe=class extends v{},se=class extends v{},ce=class extends v{},le=class extends v{},ue=class extends v{},de=class extends v{},fe=class extends v{},pe=class extends v{};const me=/^[a-z][a-z0-9+.-]*:/i,he=e=>me.test(e);let ge=e=>(ge=Array.isArray,ge(e)),_e=ge;function ve(e){return typeof e==`object`?e??{}:{}}function ye(e){if(!e)return!0;for(let t in e)return!1;return!0}function be(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const xe=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new _(`${e} must be an integer`);if(t<0)throw new _(`${e} must be a positive integer`);return t},Se=e=>{try{return JSON.parse(e)}catch{return}},Ce=e=>new Promise(t=>setTimeout(t,e)),b=`0.91.1`,we=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`;function Te(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}const Ee=()=>{let e=Te();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":b,"X-Stainless-OS":ke(Deno.build.os),"X-Stainless-Arch":Oe(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":b,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":b,"X-Stainless-OS":ke(globalThis.process.platform??`unknown`),"X-Stainless-Arch":Oe(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=De();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":b,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":b,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}};function De(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}const Oe=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,ke=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`);let Ae;const je=()=>Ae??=Ee();function Me(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Ne(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function Pe(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Ne({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function Fe(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function Ie(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}const Le=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)});function Re(e){return Object.entries(e).filter(([e,t])=>t!==void 0).map(([e,t])=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(t===null)return`${encodeURIComponent(e)}=`;throw new _(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join(`&`)}function ze(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}let Be;function Ve(e){let t;return(Be??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}let He;function Ue(e){let t;return(He??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var x,S,We=class{constructor(){x.set(this,void 0),S.set(this,void 0),h(this,x,new Uint8Array,`f`),h(this,S,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Ve(e):e;h(this,x,ze([g(this,x,`f`),t]),`f`);let n=[],r;for(;(r=Ge(g(this,x,`f`),g(this,S,`f`)))!=null;){if(r.carriage&&g(this,S,`f`)==null){h(this,S,r.index,`f`);continue}if(g(this,S,`f`)!=null&&(r.index!==g(this,S,`f`)+1||r.carriage)){n.push(Ue(g(this,x,`f`).subarray(0,g(this,S,`f`)-1))),h(this,x,g(this,x,`f`).subarray(g(this,S,`f`)),`f`),h(this,S,null,`f`);continue}let e=g(this,S,`f`)===null?r.preceding:r.preceding-1,t=Ue(g(this,x,`f`).subarray(0,e));n.push(t),h(this,x,g(this,x,`f`).subarray(r.index),`f`),h(this,S,null,`f`)}return n}flush(){return g(this,x,`f`).length?this.decode(`
1
+ import{i as e}from"./diagnostics-DN_idNHx.js";import{i as t,n,o as r,r as i,t as a}from"./transform-messages-D27pVLZ-.js";import{n as o,t as s}from"./json-parse-CpLf0aqK.js";import{t as c}from"./provider-env-DwY8YuMk.js";import{t as l}from"./deferred-tools-DNuoafg8.js";import{t as u}from"./headers-CbDaTl3c.js";import{t as d}from"./provider-retry-C8PJzY_l.js";import{t as f}from"./sanitize-unicode-DmIE6hZJ.js";import{a as p}from"./constrained-sampling-DafcjXU6.js";import{n as ee,t as m}from"./github-copilot-headers-DRgtIyTm.js";function h(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function g(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}let te=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return te=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function ne(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}const re=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};var _=class extends Error{},v=class e extends _{constructor(t,n,r,i,a){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`request-id`),this.error=n,this.type=a??null}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new ie({message:r,cause:re(n)});let a=n,o=a?.error?.type;return t===400?new oe(t,a,r,i,o):t===401?new se(t,a,r,i,o):t===403?new ce(t,a,r,i,o):t===404?new le(t,a,r,i,o):t===409?new ue(t,a,r,i,o):t===422?new de(t,a,r,i,o):t===429?new fe(t,a,r,i,o):t>=500?new pe(t,a,r,i,o):new e(t,a,r,i,o)}},y=class extends v{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},ie=class extends v{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},ae=class extends ie{constructor({message:e}={}){super({message:e??`Request timed out.`})}},oe=class extends v{},se=class extends v{},ce=class extends v{},le=class extends v{},ue=class extends v{},de=class extends v{},fe=class extends v{},pe=class extends v{};const me=/^[a-z][a-z0-9+.-]*:/i,he=e=>me.test(e);let ge=e=>(ge=Array.isArray,ge(e)),_e=ge;function ve(e){return typeof e==`object`?e??{}:{}}function ye(e){if(!e)return!0;for(let t in e)return!1;return!0}function be(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const xe=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new _(`${e} must be an integer`);if(t<0)throw new _(`${e} must be a positive integer`);return t},Se=e=>{try{return JSON.parse(e)}catch{return}},Ce=e=>new Promise(t=>setTimeout(t,e)),b=`0.91.1`,we=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`;function Te(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}const Ee=()=>{let e=Te();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":b,"X-Stainless-OS":ke(Deno.build.os),"X-Stainless-Arch":Oe(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":b,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":b,"X-Stainless-OS":ke(globalThis.process.platform??`unknown`),"X-Stainless-Arch":Oe(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=De();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":b,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":b,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}};function De(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}const Oe=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,ke=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`);let Ae;const je=()=>Ae??=Ee();function Me(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Ne(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function Pe(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Ne({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function Fe(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function Ie(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}const Le=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)});function Re(e){return Object.entries(e).filter(([e,t])=>t!==void 0).map(([e,t])=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(t===null)return`${encodeURIComponent(e)}=`;throw new _(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join(`&`)}function ze(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}let Be;function Ve(e){let t;return(Be??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}let He;function Ue(e){let t;return(He??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var x,S,We=class{constructor(){x.set(this,void 0),S.set(this,void 0),h(this,x,new Uint8Array,`f`),h(this,S,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Ve(e):e;h(this,x,ze([g(this,x,`f`),t]),`f`);let n=[],r;for(;(r=Ge(g(this,x,`f`),g(this,S,`f`)))!=null;){if(r.carriage&&g(this,S,`f`)==null){h(this,S,r.index,`f`);continue}if(g(this,S,`f`)!=null&&(r.index!==g(this,S,`f`)+1||r.carriage)){n.push(Ue(g(this,x,`f`).subarray(0,g(this,S,`f`)-1))),h(this,x,g(this,x,`f`).subarray(g(this,S,`f`)),`f`),h(this,S,null,`f`);continue}let e=g(this,S,`f`)===null?r.preceding:r.preceding-1,t=Ue(g(this,x,`f`).subarray(0,e));n.push(t),h(this,x,g(this,x,`f`).subarray(r.index),`f`),h(this,S,null,`f`)}return n}flush(){return g(this,x,`f`).length?this.decode(`
2
2
  `):[]}};x=new WeakMap,S=new WeakMap,We.NEWLINE_CHARS=new Set([`
3
3
  `,`\r`]),We.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ge(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function Ke(e){for(let t=0;t<e.length-1;t++){if(e[t]===10&&e[t+1]===10||e[t]===13&&e[t+1]===13)return t+2;if(e[t]===13&&e[t+1]===10&&t+3<e.length&&e[t+2]===13&&e[t+3]===10)return t+4}return-1}const qe={off:0,error:200,warn:300,info:400,debug:500},Je=(e,t,n)=>{if(e){if(be(qe,e))return e;w(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(qe))}`)}};function C(){}function Ye(e,t,n){return!t||qe[e]>qe[n]?C:t[e].bind(t)}const Xe={error:C,warn:C,info:C,debug:C};let Ze=new WeakMap;function w(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Xe;let r=Ze.get(t);if(r&&r[0]===n)return r[1];let i={error:Ye(`error`,t,n),warn:Ye(`warn`,t,n),info:Ye(`info`,t,n),debug:Ye(`debug`,t,n)};return Ze.set(t,[n,i]),i}const T=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`x-api-key`||e.toLowerCase()===`authorization`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);var Qe,$e=class e{constructor(e,t,n){this.iterator=e,Qe.set(this,void 0),this.controller=t,h(this,Qe,n,`f`)}static fromSSEResponse(t,n,r){let i=!1,a=r?w(r):console;async function*o(){if(i)throw new _("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let e of et(t,n)){if(e.event===`completion`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event===`message_start`||e.event===`message_delta`||e.event===`message_stop`||e.event===`content_block_start`||e.event===`content_block_delta`||e.event===`content_block_stop`||e.event===`message`||e.event===`user.message`||e.event===`user.interrupt`||e.event===`user.tool_confirmation`||e.event===`user.custom_tool_result`||e.event===`agent.message`||e.event===`agent.thinking`||e.event===`agent.tool_use`||e.event===`agent.tool_result`||e.event===`agent.mcp_tool_use`||e.event===`agent.mcp_tool_result`||e.event===`agent.custom_tool_use`||e.event===`agent.thread_context_compacted`||e.event===`session.status_running`||e.event===`session.status_idle`||e.event===`session.status_rescheduled`||e.event===`session.status_terminated`||e.event===`session.error`||e.event===`session.deleted`||e.event===`span.model_request_start`||e.event===`span.model_request_end`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event!==`ping`&&e.event===`error`){let n=Se(e.data)??e.data,r=n?.error?.type;throw new v(void 0,n,void 0,t.headers,r)}}e=!0}catch(e){if(ne(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new We,n=Fe(t);for await(let t of n)for(let n of e.decode(t))yield n;for(let t of e.flush())yield t}async function*o(){if(i)throw new _("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of a())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(ne(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(Qe=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,g(this,Qe,`f`)),new e(()=>i(n),this.controller,g(this,Qe,`f`))]}toReadableStream(){let e=this,t;return Ne({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{let{value:n,done:r}=await t.next();if(r)return e.close();let i=Ve(JSON.stringify(n)+`
4
4
  `);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.()}})}};async function*et(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new _(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new _(`Attempted to iterate over a response with no body`);let n=new nt,r=new We,i=Fe(e.body);for await(let e of tt(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}async function*tt(e){let t=new Uint8Array;for await(let n of e){if(n==null)continue;let e=n instanceof ArrayBuffer?new Uint8Array(n):typeof n==`string`?Ve(n):n,r=new Uint8Array(t.length+e.length);r.set(t),r.set(e,t.length),t=r;let i;for(;(i=Ke(t))!==-1;)yield t.slice(0,i),t=t.slice(i)}t.length>0&&(yield t)}var nt=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
@@ -36,4 +36,4 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
36
36
  `));let t=e.map(e=>e.type===`text`?{type:`text`,text:f(e.text)}:{type:`image`,source:{type:`base64`,media_type:e.mimeType,data:e.data}});return t.some(e=>e.type===`text`)||t.unshift({type:`text`,text:`(see attached image)`}),t}function jr(e){return{supportsEagerToolInputStreaming:e.compat?.supportsEagerToolInputStreaming??!0,supportsLongCacheRetention:e.compat?.supportsLongCacheRetention??!0,sendSessionAffinityHeaders:e.compat?.sendSessionAffinityHeaders??!1,supportsCacheControlOnTools:e.compat?.supportsCacheControlOnTools??!0,supportsTemperature:e.compat?.supportsTemperature??!0,allowEmptySignature:e.compat?.allowEmptySignature??!1,supportsStrictTools:e.compat?.supportsStrictTools??!1,supportsToolReferences:e.compat?.supportsToolReferences??Mr(e)}}function Mr(e){if(e.provider!==`anthropic`||e.id.includes(`haiku`))return!1;let t=e.id.match(/^claude-(?:opus|sonnet|fable)-(\d+)(?:-(\d+))?(?:-|$)/);if(!t)return!1;let n=Number(t[1]),r=t[2]&&t[2].length<8?Number(t[2]):0;return n>4||n===4&&r>=5}function Nr(...e){let t={};for(let n of e)n&&Object.assign(t,n);return t}function Pr(e,t){if(!e)return!1;let n=t.toLowerCase();for(let[t,r]of Object.entries(e))if(t.toLowerCase()===n&&r!==null&&r.trim().length>0)return!0;return!1}function Fr(e,t,n){if(!t&&!(Pr(n,`authorization`)||Pr(n,`x-api-key`)||Pr(n,`cf-aig-authorization`)))throw Error(`No API key for provider: ${e}`)}const Ir=new Set([`message_start`,`message_delta`,`message_stop`,`content_block_start`,`content_block_delta`,`content_block_stop`]);function Lr(e){if(!e.event&&e.data.length===0)return null;let t={event:e.event,data:e.data.join(`
37
37
  `),raw:[...e.raw]};return e.event=null,e.data=[],e.raw=[],t}function Rr(e,t){if(e===``)return Lr(t);if(t.raw.push(e),e.startsWith(`:`))return null;let n=e.indexOf(`:`),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n+1);return i.startsWith(` `)&&(i=i.slice(1)),r===`event`?t.event=i:r===`data`&&t.data.push(i),null}function zr(e){let t=e.indexOf(`\r`),n=e.indexOf(`
38
38
  `);return t===-1?n:n===-1?t:Math.min(t,n)}function Br(e){let t=zr(e);if(t===-1)return null;let n=t+1;return e[t]===`\r`&&e[n]===`
39
- `&&(n+=1),{line:e.slice(0,t),rest:e.slice(n)}}async function*Vr(e,t){let n=e.getReader(),r=new TextDecoder,i={event:null,data:[],raw:[]},a=``;try{for(;;){if(t?.aborted)throw Error(`Request was aborted`);let{value:e,done:o}=await n.read();if(o)break;a+=r.decode(e,{stream:!0});let s=Br(a);for(;s;){a=s.rest;let e=Rr(s.line,i);e&&(yield e),s=Br(a)}}a+=r.decode();let e=Br(a);for(;e;){a=e.rest;let t=Rr(e.line,i);t&&(yield t),e=Br(a)}if(a.length>0){let e=Rr(a,i);e&&(yield e)}let o=Lr(i);o&&(yield o)}finally{n.releaseLock()}}async function*Hr(e,t){if(!e.body)throw Error(`Attempted to iterate over an Anthropic response with no body`);let n=!1,r=!1;for await(let i of Vr(e.body,t)){if(i.event===`error`)throw Error(i.data);if(Ir.has(i.event??``))try{let e=s(i.data);e.type===`message_start`?n=!0:e.type===`message_stop`&&(r=!0),yield e}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Could not parse Anthropic SSE event ${i.event}: ${t}; data=${i.data}; raw=${i.raw.join(`\\n`)}`)}}if(n&&!r)throw Error(`Anthropic stream ended before message_stop`)}const Ur=(t,n,i)=>{let a=new e;return(async()=>{let e={role:`assistant`,content:[],api:t.api,provider:t.provider,model:t.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let s,c;if(i?.client)s=i.client,c=!1;else{let e=i?.apiKey;Fr(t.provider,e,i?.headers);let r;if(t.provider===`github-copilot`){let e=ee(n.messages);r=m({messages:n.messages,hasImages:e})}let a=Tr(i?.cacheRetention,i?.env)===`none`?void 0:i?.sessionId,o=qr(t,e,i?.interleavedThinking??!0,Qr(t,n),i?.headers,r,a);s=o.client,c=o.isOAuthToken}let l=Jr(t,n,c,i),f=await i?.onPayload?.(l,t);f!==void 0&&(l=f);let p={...i?.signal?{signal:i.signal}:{},...i?.timeoutMs===void 0?{}:{timeout:i.timeoutMs},maxRetries:0},h=await d(()=>s.messages.create({...l,stream:!0},p).asResponse(),{maxRetries:i?.maxRetries,maxRetryDelayMs:i?.maxRetryDelayMs,signal:i?.signal});await i?.onResponse?.({status:h.status,headers:u(h.headers)},t),a.push({type:`start`,partial:e});let g=e.content;for await(let s of Hr(h,i?.signal))if(s.type===`message_start`)e.responseId=s.message.id,e.usage.input=s.message.usage.input_tokens||0,e.usage.output=s.message.usage.output_tokens||0,e.usage.cacheRead=s.message.usage.cache_read_input_tokens||0,e.usage.cacheWrite=s.message.usage.cache_creation_input_tokens||0,e.usage.cacheWrite1h=s.message.usage.cache_creation?.ephemeral_1h_input_tokens||0,e.usage.totalTokens=e.usage.input+e.usage.output+e.usage.cacheRead+e.usage.cacheWrite,r(t,e.usage);else if(s.type===`content_block_start`){if(s.content_block.type===`text`){let t={type:`text`,text:``,index:s.index};e.content.push(t),a.push({type:`text_start`,contentIndex:e.content.length-1,partial:e})}else if(s.content_block.type===`thinking`){let t={type:`thinking`,thinking:``,thinkingSignature:``,index:s.index};e.content.push(t),a.push({type:`thinking_start`,contentIndex:e.content.length-1,partial:e})}else if(s.content_block.type===`redacted_thinking`){let t={type:`thinking`,thinking:`[Reasoning redacted]`,thinkingSignature:s.content_block.data,redacted:!0,index:s.index};e.content.push(t),a.push({type:`thinking_start`,contentIndex:e.content.length-1,partial:e})}else if(s.content_block.type===`tool_use`){let t={type:`toolCall`,id:s.content_block.id,name:c?kr(s.content_block.name,n.tools):s.content_block.name,arguments:s.content_block.input??{},partialJson:``,index:s.index};e.content.push(t),a.push({type:`toolcall_start`,contentIndex:e.content.length-1,partial:e})}}else if(s.type===`content_block_delta`){if(s.delta.type===`text_delta`){let t=g.findIndex(e=>e.index===s.index),n=g[t];n&&n.type===`text`&&(n.text+=s.delta.text,a.push({type:`text_delta`,contentIndex:t,delta:s.delta.text,partial:e}))}else if(s.delta.type===`thinking_delta`){let t=g.findIndex(e=>e.index===s.index),n=g[t];n&&n.type===`thinking`&&(n.thinking+=s.delta.thinking,a.push({type:`thinking_delta`,contentIndex:t,delta:s.delta.thinking,partial:e}))}else if(s.delta.type===`input_json_delta`){let t=g.findIndex(e=>e.index===s.index),n=g[t];n&&n.type===`toolCall`&&(n.partialJson+=s.delta.partial_json,n.arguments=o(n.partialJson),a.push({type:`toolcall_delta`,contentIndex:t,delta:s.delta.partial_json,partial:e}))}else if(s.delta.type===`signature_delta`){let e=g[g.findIndex(e=>e.index===s.index)];e&&e.type===`thinking`&&(e.thinkingSignature=e.thinkingSignature||``,e.thinkingSignature+=s.delta.signature)}}else if(s.type===`content_block_stop`){let t=g.findIndex(e=>e.index===s.index),n=g[t];n&&(delete n.index,n.type===`text`?a.push({type:`text_end`,contentIndex:t,content:n.text,partial:e}):n.type===`thinking`?a.push({type:`thinking_end`,contentIndex:t,content:n.thinking,partial:e}):n.type===`toolCall`&&(n.arguments=o(n.partialJson),delete n.partialJson,a.push({type:`toolcall_end`,contentIndex:t,toolCall:n,partial:e})))}else if(s.type===`message_delta`){if(s.delta.stop_reason){let t=ei(s.delta.stop_reason,s.delta.stop_details);e.stopReason=t.stopReason,t.errorMessage&&(e.errorMessage=t.errorMessage)}if(s.usage){s.usage.input_tokens!=null&&(e.usage.input=s.usage.input_tokens),s.usage.output_tokens!=null&&(e.usage.output=s.usage.output_tokens),s.usage.cache_read_input_tokens!=null&&(e.usage.cacheRead=s.usage.cache_read_input_tokens),s.usage.cache_creation_input_tokens!=null&&(e.usage.cacheWrite=s.usage.cache_creation_input_tokens);let t=s.usage.output_tokens_details?.thinking_tokens;t!=null&&(e.usage.reasoning=t)}e.usage.totalTokens=e.usage.input+e.usage.output+e.usage.cacheRead+e.usage.cacheWrite,r(t,e.usage)}if(i?.signal?.aborted)throw Error(`Request was aborted`);if(e.stopReason===`aborted`||e.stopReason===`error`)throw Error(e.errorMessage||`An unknown error occurred`);a.push({type:`done`,reason:e.stopReason,message:e}),a.end()}catch(t){for(let t of e.content)delete t.index,delete t.partialJson;e.stopReason=i?.signal?.aborted?`aborted`:`error`,e.errorMessage=t instanceof Error?t.message:JSON.stringify(t),a.push({type:`error`,reason:e.stopReason,error:e}),a.end()}})(),a};function Wr(e,t){let n=t?e.thinkingLevelMap?.[t]:void 0;if(typeof n==`string`)return n;switch(t){case`minimal`:case`low`:return`low`;case`medium`:return`medium`;case`high`:return`high`;default:return`high`}}const Gr=(e,r,a)=>{Fr(e.provider,a?.apiKey,a?.headers);let o=i(e,r,a,a?.apiKey);if(!a?.reasoning)return Ur(e,r,{...o,thinkingEnabled:!1});if(e.compat?.forceAdaptiveThinking===!0){let t=Wr(e,a.reasoning);return Ur(e,r,{...o,thinkingEnabled:!0,effort:t})}let s=n(o.maxTokens,e.maxTokens,a.reasoning,a.thinkingBudgets),c=t(e,r,s.maxTokens);return Ur(e,r,{...o,maxTokens:c,thinkingEnabled:!0,thinkingBudgetTokens:Math.min(s.thinkingBudget,Math.max(0,c-1024))})};function Kr(e){return e.includes(`sk-ant-oat`)}function qr(e,t,n,r,i,a,o){let s=n&&e.compat?.forceAdaptiveThinking!==!0,c=[];if(r&&c.push(`fine-grained-tool-streaming-2025-05-14`),s&&c.push(`interleaved-thinking-2025-05-14`),e.provider===`github-copilot`)return{client:new $({apiKey:null,authToken:t??null,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:Nr({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,...c.length>0?{"anthropic-beta":c.join(`,`)}:{}},e.headers,a,i)}),isOAuthToken:!1};if(t&&Kr(t))return{client:new $({apiKey:null,authToken:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:Nr({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,"anthropic-beta":[`claude-code-20250219`,`oauth-2025-04-20`,...c].join(`,`),"user-agent":`claude-cli/2.1.75`,"x-app":`cli`},e.headers,i)}),isOAuthToken:!0};let l=o&&jr(e).sendSessionAffinityHeaders?{"x-session-affinity":o}:{},u=Nr({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,...c.length>0?{"anthropic-beta":c.join(`,`)}:{}},l,e.headers,i);return{client:new $({apiKey:t??null,authToken:null,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:u}),isOAuthToken:!1}}function Jr(e,t,n,r){let{cacheControl:i}=Er(e,r?.cacheRetention,r?.env),o=jr(e),s=a(t.messages,e,Yr),c=n?Or:e=>e,u=l({...t,messages:s},o.supportsToolReferences,c),d=u.immediate,p=[...u.deferred.values()];d.length===0&&p.length>0&&(d=p,p=[]);let ee=new Set(p.map(e=>c(e.name))),m={model:e.id,messages:Zr(s,n,i,o.allowEmptySignature,ee,c),max_tokens:r?.maxTokens??e.maxTokens,stream:!0};if(n?(m.system=[{type:`text`,text:`You are Claude Code, Anthropic's official CLI for Claude.`,...i?{cache_control:i}:{}}],t.systemPrompt&&m.system.push({type:`text`,text:f(t.systemPrompt),...i?{cache_control:i}:{}})):t.systemPrompt&&(m.system=[{type:`text`,text:f(t.systemPrompt),...i?{cache_control:i}:{}}]),r?.temperature!==void 0&&!r?.thinkingEnabled&&o.supportsTemperature&&(m.temperature=r.temperature),(d.length>0||p.length>0)&&(m.tools=[...$r(d,n,o.supportsEagerToolInputStreaming,o.supportsStrictTools,o.supportsCacheControlOnTools?i:void 0),...$r(p,n,o.supportsEagerToolInputStreaming,o.supportsStrictTools,void 0,!0)]),e.reasoning)if(r?.thinkingEnabled){let t=r.thinkingDisplay??`summarized`;e.compat?.forceAdaptiveThinking===!0?(m.thinking={type:`adaptive`,display:t},r.effort&&(m.output_config=(r.effort,{effort:r.effort}))):m.thinking={type:`enabled`,budget_tokens:r.thinkingBudgetTokens||1024,display:t}}else r?.thinkingEnabled===!1&&e.thinkingLevelMap?.off!==null&&(m.thinking={type:`disabled`});if(r?.metadata){let e=r.metadata.user_id;typeof e==`string`&&(m.metadata={user_id:e})}return r?.toolChoice&&(typeof r.toolChoice==`string`?m.tool_choice={type:r.toolChoice}:m.tool_choice=r.toolChoice),m}function Yr(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function Xr(e,t,n,r,i){let a=[];for(let o of e.addedToolNames??[]){let e=i(o);!n.has(e)||r.has(e)||(r.add(e),a.push({type:`tool_reference`,tool_name:t?Or(o):o}))}let o=Ar(e.content);return{toolResult:{type:`tool_result`,tool_use_id:e.toolCallId,content:a.length>0?a:o,is_error:e.isError},siblingContent:a.length===0?[]:typeof o==`string`?[{type:`text`,text:o}]:o}}function Zr(e,t,n,r=!1,i=new Set,a=e=>e){let o=[],s=new Set;for(let n=0;n<e.length;n++){let c=e[n];if(c.role===`user`)if(typeof c.content==`string`)c.content.trim().length>0&&o.push({role:`user`,content:f(c.content)});else{let e=c.content.map(e=>e.type===`text`?{type:`text`,text:f(e.text)}:{type:`image`,source:{type:`base64`,media_type:e.mimeType,data:e.data}}).filter(e=>e.type!==`text`||e.text.trim().length>0);if(e.length===0)continue;o.push({role:`user`,content:e})}else if(c.role===`assistant`){let e=[];for(let n of c.content)if(n.type===`text`){if(n.text.trim().length===0)continue;e.push({type:`text`,text:f(n.text)})}else if(n.type===`thinking`){if(n.redacted){e.push({type:`redacted_thinking`,data:n.thinkingSignature});continue}let t=n.thinkingSignature,i=!!t&&t.trim().length>0;if(n.thinking.trim().length===0&&!i)continue;i?e.push({type:`thinking`,thinking:f(n.thinking),signature:t}):e.push(r?{type:`thinking`,thinking:f(n.thinking),signature:``}:{type:`text`,text:f(n.thinking)})}else n.type===`toolCall`&&e.push({type:`tool_use`,id:n.id,name:t?Or(n.name):n.name,input:n.arguments??{}});if(e.length===0)continue;o.push({role:`assistant`,content:e})}else if(c.role===`toolResult`){let r=[],c=[],l=n;for(;l<e.length&&e[l].role===`toolResult`;){let n=Xr(e[l],t,i,s,a);r.push(n.toolResult),c.push(...n.siblingContent),l++}n=l-1,o.push({role:`user`,content:[...r,...c]})}}if(n&&o.length>0){let e=o[o.length-1];if(e.role===`user`)if(Array.isArray(e.content)){let t=e.content[e.content.length-1];t&&(t.type===`text`||t.type===`image`||t.type===`tool_result`)&&(t.cache_control=n)}else typeof e.content==`string`&&(e.content=[{type:`text`,text:e.content,cache_control:n}])}return o}function Qr(e,t){return!!t.tools?.length&&!jr(e).supportsEagerToolInputStreaming}function $r(e,t,n,r,i,a=!1){return e?e.map((o,s)=>{let c=p(o,r),l=o.parameters,u={type:`object`,properties:l.properties??{},required:l.required??[]},d=c===!0?{...o.parameters,...u}:u;return{name:t?Or(o.name):o.name,description:o.description,...n?{eager_input_streaming:!0}:{},...c===!0?{strict:!0}:{},input_schema:d,...a?{defer_loading:!0}:{},...i&&s===e.length-1?{cache_control:i}:{}}}):[]}function ei(e,t){switch(e){case`end_turn`:return{stopReason:`stop`};case`max_tokens`:return{stopReason:`length`};case`tool_use`:return{stopReason:`toolUse`};case`refusal`:return{stopReason:`error`,errorMessage:t?.explanation||`The model refused to complete the request`};case`pause_turn`:return{stopReason:`stop`};case`stop_sequence`:return{stopReason:`stop`};case`sensitive`:return{stopReason:`error`};default:throw Error(`Unhandled stop reason: ${e}`)}}export{Ur as stream,Gr as streamSimple};
39
+ `&&(n+=1),{line:e.slice(0,t),rest:e.slice(n)}}async function*Vr(e,t){let n=e.getReader(),r=new TextDecoder,i={event:null,data:[],raw:[]},a=``;try{for(;;){if(t?.aborted)throw Error(`Request was aborted`);let{value:e,done:o}=await n.read();if(o)break;a+=r.decode(e,{stream:!0});let s=Br(a);for(;s;){a=s.rest;let e=Rr(s.line,i);e&&(yield e),s=Br(a)}}a+=r.decode();let e=Br(a);for(;e;){a=e.rest;let t=Rr(e.line,i);t&&(yield t),e=Br(a)}if(a.length>0){let e=Rr(a,i);e&&(yield e)}let o=Lr(i);o&&(yield o)}finally{n.releaseLock()}}async function*Hr(e,t){if(!e.body)throw Error(`Attempted to iterate over an Anthropic response with no body`);let n=!1,r=!1;for await(let i of Vr(e.body,t)){if(i.event===`error`)throw Error(i.data);if(Ir.has(i.event??``))try{let e=s(i.data);e.type===`message_start`?n=!0:e.type===`message_stop`&&(r=!0),yield e}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Could not parse Anthropic SSE event ${i.event}: ${t}; data=${i.data}; raw=${i.raw.join(`\\n`)}`)}}if(n&&!r)throw Error(`Anthropic stream ended before message_stop`)}const Ur=(t,n,i)=>{let a=new e;return(async()=>{let e={role:`assistant`,content:[],api:t.api,provider:t.provider,model:t.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`pending`,timestamp:Date.now()};try{let s,c;if(i?.client)s=i.client,c=!1;else{let e=i?.apiKey;Fr(t.provider,e,i?.headers);let r;if(t.provider===`github-copilot`){let e=ee(n.messages);r=m({messages:n.messages,hasImages:e})}let a=Tr(i?.cacheRetention,i?.env)===`none`?void 0:i?.sessionId,o=qr(t,e,i?.interleavedThinking??!0,Qr(t,n),i?.headers,i?.fetch,r,a);s=o.client,c=o.isOAuthToken}let l=Jr(t,n,c,i),f=await i?.onPayload?.(l,t);f!==void 0&&(l=f);let p={...i?.signal?{signal:i.signal}:{},...i?.timeoutMs===void 0?{}:{timeout:i.timeoutMs},maxRetries:0},h=await d(()=>s.messages.create({...l,stream:!0},p).asResponse(),{maxRetries:i?.maxRetries,maxRetryDelayMs:i?.maxRetryDelayMs,signal:i?.signal});await i?.onResponse?.({status:h.status,headers:u(h.headers)},t),a.push({type:`start`,partial:e});let g=e.content;for await(let s of Hr(h,i?.signal))if(s.type===`message_start`)e.responseId=s.message.id,e.usage.input=s.message.usage.input_tokens||0,e.usage.output=s.message.usage.output_tokens||0,e.usage.cacheRead=s.message.usage.cache_read_input_tokens||0,e.usage.cacheWrite=s.message.usage.cache_creation_input_tokens||0,e.usage.cacheWrite1h=s.message.usage.cache_creation?.ephemeral_1h_input_tokens||0,e.usage.totalTokens=e.usage.input+e.usage.output+e.usage.cacheRead+e.usage.cacheWrite,r(t,e.usage);else if(s.type===`content_block_start`){if(s.content_block.type===`text`){let t={type:`text`,text:``,index:s.index};e.content.push(t),a.push({type:`text_start`,contentIndex:e.content.length-1,partial:e})}else if(s.content_block.type===`thinking`){let t={type:`thinking`,thinking:``,thinkingSignature:``,index:s.index};e.content.push(t),a.push({type:`thinking_start`,contentIndex:e.content.length-1,partial:e})}else if(s.content_block.type===`redacted_thinking`){let t={type:`thinking`,thinking:`[Reasoning redacted]`,thinkingSignature:s.content_block.data,redacted:!0,index:s.index};e.content.push(t),a.push({type:`thinking_start`,contentIndex:e.content.length-1,partial:e})}else if(s.content_block.type===`tool_use`){let t={type:`toolCall`,id:s.content_block.id,name:c?kr(s.content_block.name,n.tools):s.content_block.name,arguments:s.content_block.input??{},partialJson:``,index:s.index};e.content.push(t),a.push({type:`toolcall_start`,contentIndex:e.content.length-1,partial:e})}}else if(s.type===`content_block_delta`){if(s.delta.type===`text_delta`){let t=g.findIndex(e=>e.index===s.index),n=g[t];n&&n.type===`text`&&(n.text+=s.delta.text,a.push({type:`text_delta`,contentIndex:t,delta:s.delta.text,partial:e}))}else if(s.delta.type===`thinking_delta`){let t=g.findIndex(e=>e.index===s.index),n=g[t];n&&n.type===`thinking`&&(n.thinking+=s.delta.thinking,a.push({type:`thinking_delta`,contentIndex:t,delta:s.delta.thinking,partial:e}))}else if(s.delta.type===`input_json_delta`){let t=g.findIndex(e=>e.index===s.index),n=g[t];n&&n.type===`toolCall`&&(n.partialJson+=s.delta.partial_json,n.arguments=o(n.partialJson),a.push({type:`toolcall_delta`,contentIndex:t,delta:s.delta.partial_json,partial:e}))}else if(s.delta.type===`signature_delta`){let e=g[g.findIndex(e=>e.index===s.index)];e&&e.type===`thinking`&&(e.thinkingSignature=e.thinkingSignature||``,e.thinkingSignature+=s.delta.signature)}}else if(s.type===`content_block_stop`){let t=g.findIndex(e=>e.index===s.index),n=g[t];n&&(delete n.index,n.type===`text`?a.push({type:`text_end`,contentIndex:t,content:n.text,partial:e}):n.type===`thinking`?a.push({type:`thinking_end`,contentIndex:t,content:n.thinking,partial:e}):n.type===`toolCall`&&(n.arguments=o(n.partialJson),delete n.partialJson,a.push({type:`toolcall_end`,contentIndex:t,toolCall:n,partial:e})))}else if(s.type===`message_delta`){if(s.delta.stop_reason){e.rawStopReason=s.delta.stop_reason;let t=ei(s.delta.stop_reason,s.delta.stop_details);e.stopReason=t.stopReason,t.errorMessage&&(e.errorMessage=t.errorMessage)}if(s.usage){s.usage.input_tokens!=null&&(e.usage.input=s.usage.input_tokens),s.usage.output_tokens!=null&&(e.usage.output=s.usage.output_tokens),s.usage.cache_read_input_tokens!=null&&(e.usage.cacheRead=s.usage.cache_read_input_tokens),s.usage.cache_creation_input_tokens!=null&&(e.usage.cacheWrite=s.usage.cache_creation_input_tokens);let t=s.usage.output_tokens_details?.thinking_tokens;t!=null&&(e.usage.reasoning=t)}e.usage.totalTokens=e.usage.input+e.usage.output+e.usage.cacheRead+e.usage.cacheWrite,r(t,e.usage)}if(i?.signal?.aborted)throw Error(`Request was aborted`);if(e.stopReason===`pending`)throw Error(`Anthropic stream ended without a stop reason`);if(e.stopReason===`aborted`||e.stopReason===`error`)throw Error(e.errorMessage||`An unknown error occurred`);a.push({type:`done`,reason:e.stopReason,message:e}),a.end()}catch(t){for(let t of e.content)delete t.index,delete t.partialJson;e.stopReason=i?.signal?.aborted?`aborted`:`error`,e.errorMessage=t instanceof Error?t.message:JSON.stringify(t),a.push({type:`error`,reason:e.stopReason,error:e}),a.end()}})(),a};function Wr(e,t){let n=t?e.thinkingLevelMap?.[t]:void 0;if(typeof n==`string`)return n;switch(t){case`minimal`:case`low`:return`low`;case`medium`:return`medium`;case`high`:return`high`;default:return`high`}}const Gr=(e,r,a)=>{Fr(e.provider,a?.apiKey,a?.headers);let o=i(e,r,a,a?.apiKey);if(!a?.reasoning)return Ur(e,r,{...o,thinkingEnabled:!1});if(e.compat?.forceAdaptiveThinking===!0){let t=Wr(e,a.reasoning);return Ur(e,r,{...o,thinkingEnabled:!0,effort:t})}let s=n(o.maxTokens,e.maxTokens,a.reasoning,a.thinkingBudgets),c=t(e,r,s.maxTokens);return Ur(e,r,{...o,maxTokens:c,thinkingEnabled:!0,thinkingBudgetTokens:Math.min(s.thinkingBudget,Math.max(0,c-1024))})};function Kr(e){return e.includes(`sk-ant-oat`)}function qr(e,t,n,r,i,a,o,s){let c=n&&e.compat?.forceAdaptiveThinking!==!0,l=[];if(r&&l.push(`fine-grained-tool-streaming-2025-05-14`),c&&l.push(`interleaved-thinking-2025-05-14`),e.provider===`github-copilot`)return{client:new $({apiKey:null,authToken:t??null,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,fetch:a,defaultHeaders:Nr({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,...l.length>0?{"anthropic-beta":l.join(`,`)}:{}},e.headers,o,i)}),isOAuthToken:!1};if(t&&Kr(t))return{client:new $({apiKey:null,authToken:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,fetch:a,defaultHeaders:Nr({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,"anthropic-beta":[`claude-code-20250219`,`oauth-2025-04-20`,...l].join(`,`),"user-agent":`claude-cli/2.1.75`,"x-app":`cli`},e.headers,i)}),isOAuthToken:!0};let u=s&&jr(e).sendSessionAffinityHeaders?{"x-session-affinity":s}:{},d=Nr({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,...l.length>0?{"anthropic-beta":l.join(`,`)}:{}},u,e.headers,i);return{client:new $({apiKey:t??null,authToken:null,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,fetch:a,defaultHeaders:d}),isOAuthToken:!1}}function Jr(e,t,n,r){let{cacheControl:i}=Er(e,r?.cacheRetention,r?.env),o=jr(e),s=a(t.messages,e,Yr),c=n?Or:e=>e,u=l({...t,messages:s},o.supportsToolReferences,c),d=u.immediate,p=[...u.deferred.values()];d.length===0&&p.length>0&&(d=p,p=[]);let ee=new Set(p.map(e=>c(e.name))),m={model:e.id,messages:Zr(s,n,i,o.allowEmptySignature,ee,c),max_tokens:r?.maxTokens??e.maxTokens,stream:!0};if(n?(m.system=[{type:`text`,text:`You are Claude Code, Anthropic's official CLI for Claude.`,...i?{cache_control:i}:{}}],t.systemPrompt&&m.system.push({type:`text`,text:f(t.systemPrompt),...i?{cache_control:i}:{}})):t.systemPrompt&&(m.system=[{type:`text`,text:f(t.systemPrompt),...i?{cache_control:i}:{}}]),r?.temperature!==void 0&&!r?.thinkingEnabled&&o.supportsTemperature&&(m.temperature=r.temperature),(d.length>0||p.length>0)&&(m.tools=[...$r(d,n,o.supportsEagerToolInputStreaming,o.supportsStrictTools,o.supportsCacheControlOnTools?i:void 0),...$r(p,n,o.supportsEagerToolInputStreaming,o.supportsStrictTools,void 0,!0)]),e.reasoning)if(r?.thinkingEnabled){let t=r.thinkingDisplay??`summarized`;e.compat?.forceAdaptiveThinking===!0?(m.thinking={type:`adaptive`,display:t},r.effort&&(m.output_config=(r.effort,{effort:r.effort}))):m.thinking={type:`enabled`,budget_tokens:r.thinkingBudgetTokens||1024,display:t}}else r?.thinkingEnabled===!1&&e.thinkingLevelMap?.off!==null&&(m.thinking={type:`disabled`});if(r?.metadata){let e=r.metadata.user_id;typeof e==`string`&&(m.metadata={user_id:e})}return r?.toolChoice&&(typeof r.toolChoice==`string`?m.tool_choice={type:r.toolChoice}:m.tool_choice=r.toolChoice),m}function Yr(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function Xr(e,t,n,r,i){let a=[];for(let o of e.addedToolNames??[]){let e=i(o);!n.has(e)||r.has(e)||(r.add(e),a.push({type:`tool_reference`,tool_name:t?Or(o):o}))}let o=Ar(e.content);return{toolResult:{type:`tool_result`,tool_use_id:e.toolCallId,content:a.length>0?a:o,is_error:e.isError},siblingContent:a.length===0?[]:typeof o==`string`?[{type:`text`,text:o}]:o}}function Zr(e,t,n,r=!1,i=new Set,a=e=>e){let o=[],s=new Set;for(let n=0;n<e.length;n++){let c=e[n];if(c.role===`user`)if(typeof c.content==`string`)c.content.trim().length>0&&o.push({role:`user`,content:f(c.content)});else{let e=c.content.map(e=>e.type===`text`?{type:`text`,text:f(e.text)}:{type:`image`,source:{type:`base64`,media_type:e.mimeType,data:e.data}}).filter(e=>e.type!==`text`||e.text.trim().length>0);if(e.length===0)continue;o.push({role:`user`,content:e})}else if(c.role===`assistant`){let e=[];for(let n of c.content)if(n.type===`text`){if(n.text.trim().length===0)continue;e.push({type:`text`,text:f(n.text)})}else if(n.type===`thinking`){if(n.redacted){e.push({type:`redacted_thinking`,data:n.thinkingSignature});continue}let t=n.thinkingSignature,i=!!t&&t.trim().length>0;if(n.thinking.trim().length===0&&!i)continue;i?e.push({type:`thinking`,thinking:f(n.thinking),signature:t}):e.push(r?{type:`thinking`,thinking:f(n.thinking),signature:``}:{type:`text`,text:f(n.thinking)})}else n.type===`toolCall`&&e.push({type:`tool_use`,id:n.id,name:t?Or(n.name):n.name,input:n.arguments??{}});if(e.length===0)continue;o.push({role:`assistant`,content:e})}else if(c.role===`toolResult`){let r=[],c=[],l=n;for(;l<e.length&&e[l].role===`toolResult`;){let n=Xr(e[l],t,i,s,a);r.push(n.toolResult),c.push(...n.siblingContent),l++}n=l-1,o.push({role:`user`,content:[...r,...c]})}}if(n&&o.length>0){let e=o[o.length-1];if(e.role===`user`)if(Array.isArray(e.content)){let t=e.content[e.content.length-1];t&&(t.type===`text`||t.type===`image`||t.type===`tool_result`)&&(t.cache_control=n)}else typeof e.content==`string`&&(e.content=[{type:`text`,text:e.content,cache_control:n}])}return o}function Qr(e,t){return!!t.tools?.length&&!jr(e).supportsEagerToolInputStreaming}function $r(e,t,n,r,i,a=!1){return e?e.map((o,s)=>{let c=p(o,r),l=o.parameters,u={type:`object`,properties:l.properties??{},required:l.required??[]},d=c===!0?{...o.parameters,...u}:u;return{name:t?Or(o.name):o.name,description:o.description,...n?{eager_input_streaming:!0}:{},...c===!0?{strict:!0}:{},input_schema:d,...a?{defer_loading:!0}:{},...i&&s===e.length-1?{cache_control:i}:{}}}):[]}function ei(e,t){switch(e){case`end_turn`:return{stopReason:`stop`};case`max_tokens`:return{stopReason:`length`};case`tool_use`:return{stopReason:`toolUse`};case`refusal`:return{stopReason:`error`,errorMessage:t?.explanation||`The model refused to complete the request`};case`pause_turn`:return{stopReason:`stop`};case`stop_sequence`:return{stopReason:`stop`};case`sensitive`:return{stopReason:`error`,errorMessage:`Provider stopped with: sensitive`};default:throw Error(`Unhandled stop reason: ${e}`)}}export{Ur as stream,Gr as streamSimple};