sliccy 5.73.0 → 5.73.2

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 (65) hide show
  1. package/README.md +1 -1
  2. package/dist/ui/assets/{account-store-ffzft8RA.js → account-store-1sWsdBXV.js} +1 -1
  3. package/dist/ui/assets/{account-store-FTgVysIG.js → account-store-DWKDZbQl.js} +1 -1
  4. package/dist/ui/assets/{adobe-I3rKjE9U.js → adobe-DES2cp-y.js} +1 -1
  5. package/dist/ui/assets/{adobe-D0SpBft8.js → adobe-DHUcvdyP.js} +1 -1
  6. package/dist/ui/assets/{apps-ZtanVjeo.js → apps-DJx3akpR.js} +1 -1
  7. package/dist/ui/assets/{azure-openai-CXPvxWCj.js → azure-openai-C3DSYzL8.js} +1 -1
  8. package/dist/ui/assets/{azure-openai-DJ879ENP.js → azure-openai-D7xJ5VET.js} +1 -1
  9. package/dist/ui/assets/{cerebras-CxXzzUW7.js → cerebras-CnOHiorM.js} +1 -1
  10. package/dist/ui/assets/{cerebras-Dm3c0fkp.js → cerebras-EsczMAGe.js} +1 -1
  11. package/dist/ui/assets/{connect-surface-Vx1U3D8N.js → connect-surface-BTk8oHjU.js} +1 -1
  12. package/dist/ui/assets/{fs-WZPBDsP_.js → fs-C_SqCSvP.js} +2 -2
  13. package/dist/ui/assets/{fs-t1A190GT.js → fs-PoNPHaXB.js} +1 -1
  14. package/dist/ui/assets/{github-fhq-gi6t.js → github-DF16zQXQ.js} +1 -1
  15. package/dist/ui/assets/{github-BBc_vfgd.js → github-DjE0FC03.js} +2 -2
  16. package/dist/ui/assets/{github-copilot-CXcFYCsR.js → github-copilot-DeMLYZUN.js} +1 -1
  17. package/dist/ui/assets/{github-copilot-Cxuswuna.js → github-copilot-DiGxn4oA.js} +1 -1
  18. package/dist/ui/assets/{kernel-worker-DsXP7w81.js → kernel-worker-C-tryBGn.js} +20 -20
  19. package/dist/ui/assets/{lick-ws-bridge-BjjBwr4l.js → lick-ws-bridge-C3foeWDS.js} +1 -1
  20. package/dist/ui/assets/{local-llm-BgW1KM2E.js → local-llm-CWi0ZprP.js} +1 -1
  21. package/dist/ui/assets/{local-llm-Dq1Q8Puv.js → local-llm-Dq9HBaqe.js} +1 -1
  22. package/dist/ui/assets/{main-CreNiN0j.js → main-BMElPt_b.js} +3 -3
  23. package/dist/ui/assets/{mount-A3Op_5rE.js → mount-C7OeghLh.js} +2 -2
  24. package/dist/ui/assets/{mount-B6S6xyVl.js → mount-CAFjW1QS.js} +1 -1
  25. package/dist/ui/assets/{mount-recovery-DHLBeaXE.js → mount-recovery-B8VdqP8T.js} +1 -1
  26. package/dist/ui/assets/{new-session-C6L_ynot.js → new-session-BwNVjrlp.js} +2 -2
  27. package/dist/ui/assets/{oauth-bootstrap-D90o1Xh8.js → oauth-bootstrap-Bf7Ewk3g.js} +2 -2
  28. package/dist/ui/assets/{openai-codex-DK61m-yO.js → openai-codex-D9LHZUcr.js} +1 -1
  29. package/dist/ui/assets/{openai-codex-Cerqv4XW.js → openai-codex-je7irmYi.js} +1 -1
  30. package/dist/ui/assets/{openrouter-DCk6s2AG.js → openrouter-BIvugNQ1.js} +1 -1
  31. package/dist/ui/assets/{openrouter-D-PCKaTR.js → openrouter-BmRdV9UY.js} +1 -1
  32. package/dist/ui/assets/{openrouter-oauth-DOV5RsjU.js → openrouter-oauth-QExY6Qo3.js} +1 -1
  33. package/dist/ui/assets/{openrouter-oauth-BPwgh4t0.js → openrouter-oauth-lGTI8QBz.js} +1 -1
  34. package/dist/ui/assets/{panel-rpc-handlers-azFpH94I.js → panel-rpc-handlers-SvYz4p6A.js} +2 -2
  35. package/dist/ui/assets/{provider-Dzhp95UL.js → provider-CDDFVleF.js} +2 -2
  36. package/dist/ui/assets/{provider-zCxTYY9y.js → provider-dLnW_Qmu.js} +1 -1
  37. package/dist/ui/assets/{provider-settings-BSR3nkqj.js → provider-settings-BQ_ViD6o.js} +1 -1
  38. package/dist/ui/assets/{provider-settings-DcnfIdhT.js → provider-settings-BonXlQHx.js} +1 -1
  39. package/dist/ui/assets/provider-store-access-B_M384kS.js +1 -0
  40. package/dist/ui/assets/{provider-store-access-fcMv95UJ.js → provider-store-access-CDUXoK9n.js} +2 -2
  41. package/dist/ui/assets/{providers-Cm4vhL4Q.js → providers-B8AC4r1K.js} +2 -2
  42. package/dist/ui/assets/{providers-_af_79IP.js → providers-BE5wq_hp.js} +1 -1
  43. package/dist/ui/assets/{quick-llm-ZjFmZHUs.js → quick-llm-j8Lw8DXh.js} +1 -1
  44. package/dist/ui/assets/{session-freezer-BCgp4oCU.js → session-freezer-jCi1eAnA.js} +2 -2
  45. package/dist/ui/assets/{setup-sudo-1NK6EEZ8.js → setup-sudo-CglheNlM.js} +2 -2
  46. package/dist/ui/assets/{skills-CxjfKsSq.js → skills-B6K9VVT7.js} +1 -1
  47. package/dist/ui/assets/{store-DQOogFqL.js → store-Dpqwm0j1.js} +1 -1
  48. package/dist/ui/assets/{sudo-DMHt3FS1.js → sudo-Bfbjy3cy.js} +1 -1
  49. package/dist/ui/assets/{upgrade-detection-ByJE_b3A.js → upgrade-detection-DdRKki36.js} +1 -1
  50. package/dist/ui/assets/{wc-extension-FULWQDpl.js → wc-extension-K9Yoj8xX.js} +2 -2
  51. package/dist/ui/assets/{wc-follower-BkifL8NH.js → wc-follower-BmFSgVpW.js} +3 -3
  52. package/dist/ui/assets/{wc-live-Bve96hb7.js → wc-live-FQiVeP5H.js} +3 -3
  53. package/dist/ui/assets/{wc-nav-B1RXDdk9.js → wc-nav-CPTHD9Gm.js} +2 -2
  54. package/dist/ui/assets/{wc-onboarding-DPFBjJfc.js → wc-onboarding-Du7r32Nc.js} +2 -2
  55. package/dist/ui/assets/{wc-placeholder-CaLOEeHc.js → wc-placeholder-qw9xzwIX.js} +2 -2
  56. package/dist/ui/assets/{wc-settings-Dnx9RiIR.js → wc-settings-Dsqf_wFN.js} +2 -2
  57. package/dist/ui/assets/{wc-shell-EYbzlbB2.js → wc-shell-LFcAIFJQ.js} +2 -2
  58. package/dist/ui/assets/{wc-sprinkles-ZueChOOh.js → wc-sprinkles-CYSiEKaU.js} +2 -2
  59. package/dist/ui/assets/{wc-tray-BvRjHvCa.js → wc-tray-Dg2nqNkH.js} +2 -2
  60. package/dist/ui/assets/{xai-grok-oqmlvPIG.js → xai-grok-BvvyCW-L.js} +1 -1
  61. package/dist/ui/assets/{xai-grok-DMlzsKiK.js → xai-grok-D-owzioC.js} +1 -1
  62. package/dist/ui/index.html +5 -5
  63. package/dist/ui/packages/webapp/index.html +5 -5
  64. package/package.json +1 -1
  65. package/dist/ui/assets/provider-store-access-DDrRyE-X.js +0 -1
package/README.md CHANGED
@@ -11,7 +11,7 @@ If this scares, confuses, or excites you, keep reading.
11
11
 
12
12
  # slicc — Self-Licking Ice Cream Cone
13
13
 
14
- [![52% Vibe_Coded](https://img.shields.io/badge/52%25-Vibe_Coded-ff69b4?style=for-the-badge&logo=claude&logoColor=white)](https://github.com/ai-ecoverse/vibe-coded-badge-action)
14
+ [![53% Vibe_Coded](https://img.shields.io/badge/53%25-Vibe_Coded-ff69b4?style=for-the-badge&logo=claude&logoColor=white)](https://github.com/ai-ecoverse/vibe-coded-badge-action)
15
15
 
16
16
  [![npm](https://img.shields.io/npm/v/sliccy)](https://www.npmjs.com/package/sliccy)
17
17
 
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/oauth-service-lE9AyywH.js","assets/preload-helper-Czpn1I53.js","assets/proxied-fetch-D5h5REZy.js","assets/rolldown-runtime-aKtaBQYM.js","assets/base64-DpPqYZJF.js","assets/src-CS5gSDhT.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{n as e,t}from"./rolldown-runtime-aKtaBQYM.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{i as r,n as i,r as a}from"./compat-Spvv5tCW.js";import"./context-compaction-CW5AQ9bv.js";import{t as o}from"./logger-DDBAeTLF.js";import"./src-CS5gSDhT.js";import{o as s,t as c}from"./proxied-fetch-D5h5REZy.js";import{t as l}from"./secret-topology-CptRwAX3.js";import{t as u}from"./secrets-bridge-client-D6nwnBvr.js";import"./tool-ui-DfXu6quJ.js";import{n as d,o as f,t as p}from"./providers-Cm4vhL4Q.js";import{n as m,t as h}from"./panel-rpc-DmJSNs0I.js";import{r as g,t as _}from"./bedrock-camp-PMQ4Iu6f.js";var v=Symbol.for(`yaml.alias`),y=Symbol.for(`yaml.document`),b=Symbol.for(`yaml.map`),x=Symbol.for(`yaml.pair`),S=Symbol.for(`yaml.scalar`),C=Symbol.for(`yaml.seq`),w=Symbol.for(`yaml.node.type`),T=e=>!!e&&typeof e==`object`&&e[w]===v,E=e=>!!e&&typeof e==`object`&&e[w]===y,ee=e=>!!e&&typeof e==`object`&&e[w]===b,D=e=>!!e&&typeof e==`object`&&e[w]===x,O=e=>!!e&&typeof e==`object`&&e[w]===S,k=e=>!!e&&typeof e==`object`&&e[w]===C;function A(e){if(e&&typeof e==`object`)switch(e[w]){case b:case C:return!0}return!1}function j(e){if(e&&typeof e==`object`)switch(e[w]){case v:case b:case S:case C:return!0}return!1}var te=e=>(O(e)||A(e))&&!!e.anchor,M=Symbol(`break visit`),ne=Symbol(`skip children`),N=Symbol(`remove node`);function re(e,t){let n=ae(t);E(e)?P(null,e.contents,n,Object.freeze([e]))===N&&(e.contents=null):P(null,e,n,Object.freeze([]))}re.BREAK=M,re.SKIP=ne,re.REMOVE=N;function P(e,t,n,r){let i=oe(e,t,n,r);if(j(i)||D(i))return se(e,r,i),P(e,i,n,r);if(typeof i!=`symbol`){if(A(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=P(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===M)return M;else i===N&&(t.items.splice(e,1),--e)}}else if(D(t)){r=Object.freeze(r.concat(t));let e=P(`key`,t.key,n,r);if(e===M)return M;e===N&&(t.key=null);let i=P(`value`,t.value,n,r);if(i===M)return M;i===N&&(t.value=null)}}return i}async function ie(e,t){let n=ae(t);E(e)?await F(null,e.contents,n,Object.freeze([e]))===N&&(e.contents=null):await F(null,e,n,Object.freeze([]))}ie.BREAK=M,ie.SKIP=ne,ie.REMOVE=N;async function F(e,t,n,r){let i=await oe(e,t,n,r);if(j(i)||D(i))return se(e,r,i),F(e,i,n,r);if(typeof i!=`symbol`){if(A(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=await F(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===M)return M;else i===N&&(t.items.splice(e,1),--e)}}else if(D(t)){r=Object.freeze(r.concat(t));let e=await F(`key`,t.key,n,r);if(e===M)return M;e===N&&(t.key=null);let i=await F(`value`,t.value,n,r);if(i===M)return M;i===N&&(t.value=null)}}return i}function ae(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 oe(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(ee(t))return n.Map?.(e,t,r);if(k(t))return n.Seq?.(e,t,r);if(D(t))return n.Pair?.(e,t,r);if(O(t))return n.Scalar?.(e,t,r);if(T(t))return n.Alias?.(e,t,r)}function se(e,t,n){let r=t[t.length-1];if(A(r))r.items[e]=n;else if(D(r))e===`key`?r.key=n:r.value=n;else if(E(r))r.contents=n;else{let e=T(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var ce={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},le=e=>e.replace(/[!,[\]{}]/g,e=>ce[e]),ue=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+le(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&&j(e.contents)){let t={};re(e.contents,(e,n)=>{j(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(`
2
+ import{n as e,t}from"./rolldown-runtime-aKtaBQYM.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{i as r,n as i,r as a}from"./compat-Spvv5tCW.js";import"./context-compaction-CW5AQ9bv.js";import{t as o}from"./logger-DDBAeTLF.js";import"./src-CS5gSDhT.js";import{o as s,t as c}from"./proxied-fetch-D5h5REZy.js";import{t as l}from"./secret-topology-CptRwAX3.js";import{t as u}from"./secrets-bridge-client-D6nwnBvr.js";import"./tool-ui-DfXu6quJ.js";import{n as d,o as f,t as p}from"./providers-B8AC4r1K.js";import{n as m,t as h}from"./panel-rpc-DmJSNs0I.js";import{r as g,t as _}from"./bedrock-camp-PMQ4Iu6f.js";var v=Symbol.for(`yaml.alias`),y=Symbol.for(`yaml.document`),b=Symbol.for(`yaml.map`),x=Symbol.for(`yaml.pair`),S=Symbol.for(`yaml.scalar`),C=Symbol.for(`yaml.seq`),w=Symbol.for(`yaml.node.type`),T=e=>!!e&&typeof e==`object`&&e[w]===v,E=e=>!!e&&typeof e==`object`&&e[w]===y,ee=e=>!!e&&typeof e==`object`&&e[w]===b,D=e=>!!e&&typeof e==`object`&&e[w]===x,O=e=>!!e&&typeof e==`object`&&e[w]===S,k=e=>!!e&&typeof e==`object`&&e[w]===C;function A(e){if(e&&typeof e==`object`)switch(e[w]){case b:case C:return!0}return!1}function j(e){if(e&&typeof e==`object`)switch(e[w]){case v:case b:case S:case C:return!0}return!1}var te=e=>(O(e)||A(e))&&!!e.anchor,M=Symbol(`break visit`),ne=Symbol(`skip children`),N=Symbol(`remove node`);function re(e,t){let n=ae(t);E(e)?P(null,e.contents,n,Object.freeze([e]))===N&&(e.contents=null):P(null,e,n,Object.freeze([]))}re.BREAK=M,re.SKIP=ne,re.REMOVE=N;function P(e,t,n,r){let i=oe(e,t,n,r);if(j(i)||D(i))return se(e,r,i),P(e,i,n,r);if(typeof i!=`symbol`){if(A(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=P(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===M)return M;else i===N&&(t.items.splice(e,1),--e)}}else if(D(t)){r=Object.freeze(r.concat(t));let e=P(`key`,t.key,n,r);if(e===M)return M;e===N&&(t.key=null);let i=P(`value`,t.value,n,r);if(i===M)return M;i===N&&(t.value=null)}}return i}async function ie(e,t){let n=ae(t);E(e)?await F(null,e.contents,n,Object.freeze([e]))===N&&(e.contents=null):await F(null,e,n,Object.freeze([]))}ie.BREAK=M,ie.SKIP=ne,ie.REMOVE=N;async function F(e,t,n,r){let i=await oe(e,t,n,r);if(j(i)||D(i))return se(e,r,i),F(e,i,n,r);if(typeof i!=`symbol`){if(A(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=await F(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===M)return M;else i===N&&(t.items.splice(e,1),--e)}}else if(D(t)){r=Object.freeze(r.concat(t));let e=await F(`key`,t.key,n,r);if(e===M)return M;e===N&&(t.key=null);let i=await F(`value`,t.value,n,r);if(i===M)return M;i===N&&(t.value=null)}}return i}function ae(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 oe(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(ee(t))return n.Map?.(e,t,r);if(k(t))return n.Seq?.(e,t,r);if(D(t))return n.Pair?.(e,t,r);if(O(t))return n.Scalar?.(e,t,r);if(T(t))return n.Alias?.(e,t,r)}function se(e,t,n){let r=t[t.length-1];if(A(r))r.items[e]=n;else if(D(r))e===`key`?r.key=n:r.value=n;else if(E(r))r.contents=n;else{let e=T(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var ce={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},le=e=>e.replace(/[!,[\]{}]/g,e=>ce[e]),ue=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+le(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&&j(e.contents)){let t={};re(e.contents,(e,n)=>{j(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(`
3
3
  `)}};ue.defaultYaml={explicit:!1,version:`1.2`},ue.defaultTags={"!!":`tag:yaml.org,2002:`};function de(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 fe(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=fe(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=fe(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=fe(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=fe(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}return e.call(t,n,r)}function I(e,t,n){if(Array.isArray(e))return e.map((e,t)=>I(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!te(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 pe=class{constructor(e){Object.defineProperty(this,w,{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(!E(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=I(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?fe(i,{"":o},``,o):o}},me=class extends pe{constructor(e){super(v),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=[],re(e,{Node:(e,t)=>{(T(t)||te(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||=(I(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=he(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(de(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 he(e,t,n){if(T(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(A(t)){let r=0;for(let i of t.items){let t=he(e,i,n);t>r&&(r=t)}return r}else if(D(t)){let r=he(e,t.key,n),i=he(e,t.value,n);return Math.max(r,i)}return 1}var ge=e=>!e||typeof e!=`function`&&typeof e!=`object`,L=class extends pe{constructor(e){super(S),this.value=e}toJSON(e,t){return t?.keep?this.value:I(this.value,e,t)}toString(){return String(this.value)}};L.BLOCK_FOLDED=`BLOCK_FOLDED`,L.BLOCK_LITERAL=`BLOCK_LITERAL`,L.PLAIN=`PLAIN`,L.QUOTE_DOUBLE=`QUOTE_DOUBLE`,L.QUOTE_SINGLE=`QUOTE_SINGLE`;var _e=`tag:yaml.org,2002:`;function ve(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 ye(e,t,n){if(E(e)&&(e=e.contents),j(e))return e;if(D(e)){let t=n.schema[b].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 me(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=_e+t.slice(2));let l=ve(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new L(e);return c&&(c.node=t),t}l=e instanceof Map?o[b]:Symbol.iterator in Object(e)?o[C]:o[b]}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 L(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function be(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 ye(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var xe=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,Se=class extends pe{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=>j(t)||D(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(xe(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(A(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,be(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(A(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&&O(i)?i.value:i:A(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!D(t))return!1;let n=t.value;return n==null||e&&O(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 A(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(A(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,be(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},Ce=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function we(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var R=(e,t,n)=>e.endsWith(`
4
4
  `)?we(n,t):n.includes(`
5
5
  `)?`
@@ -1,4 +1,4 @@
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-_af_79IP.js";import{r as c,s as l,t as u}from"./proxied-fetch-ldIfAeIb.js";import"./src-Dk1QVJRd.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-BC810skI.js";import{d as h,f as g,l as _,r as v,t as y,u as b}from"./bedrock-camp-D_7EbOFH.js";const x=`slicc_oauth_extra_domains`;function S(e){try{let t=e.getItem(x);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 ee(e,t){try{e.setItem(x,JSON.stringify(t))}catch(e){throw Error(`Failed to persist OAuth extras (localStorage quota exceeded?): ${e instanceof Error?e.message:String(e)}`)}}function C(){return d()?`extension-direct`:c()?`extension-delegate`:globalThis.__slicc_connect_mode?`connect`:`node-rest`}function te(){return C()===`node-rest`}const ne=Symbol.for(`yaml.alias`),re=Symbol.for(`yaml.document`),w=Symbol.for(`yaml.map`),ie=Symbol.for(`yaml.pair`),T=Symbol.for(`yaml.scalar`),E=Symbol.for(`yaml.seq`),D=Symbol.for(`yaml.node.type`),O=e=>!!e&&typeof e==`object`&&e[D]===ne,ae=e=>!!e&&typeof e==`object`&&e[D]===re,oe=e=>!!e&&typeof e==`object`&&e[D]===w,k=e=>!!e&&typeof e==`object`&&e[D]===ie,A=e=>!!e&&typeof e==`object`&&e[D]===T,se=e=>!!e&&typeof e==`object`&&e[D]===E;function j(e){if(e&&typeof e==`object`)switch(e[D]){case w:case E:return!0}return!1}function M(e){if(e&&typeof e==`object`)switch(e[D]){case ne:case w:case T:case E:return!0}return!1}const ce=e=>(A(e)||j(e))&&!!e.anchor,N=Symbol(`break visit`),le=Symbol(`skip children`),P=Symbol(`remove node`);function ue(e,t){let n=me(t);ae(e)?de(null,e.contents,n,Object.freeze([e]))===P&&(e.contents=null):de(null,e,n,Object.freeze([]))}ue.BREAK=N,ue.SKIP=le,ue.REMOVE=P;function de(e,t,n,r){let i=he(e,t,n,r);if(M(i)||k(i))return ge(e,r,i),de(e,i,n,r);if(typeof i!=`symbol`){if(j(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=de(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===N)return N;else i===P&&(t.items.splice(e,1),--e)}}else if(k(t)){r=Object.freeze(r.concat(t));let e=de(`key`,t.key,n,r);if(e===N)return N;e===P&&(t.key=null);let i=de(`value`,t.value,n,r);if(i===N)return N;i===P&&(t.value=null)}}return i}async function fe(e,t){let n=me(t);ae(e)?await pe(null,e.contents,n,Object.freeze([e]))===P&&(e.contents=null):await pe(null,e,n,Object.freeze([]))}fe.BREAK=N,fe.SKIP=le,fe.REMOVE=P;async function pe(e,t,n,r){let i=await he(e,t,n,r);if(M(i)||k(i))return ge(e,r,i),pe(e,i,n,r);if(typeof i!=`symbol`){if(j(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=await pe(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===N)return N;else i===P&&(t.items.splice(e,1),--e)}}else if(k(t)){r=Object.freeze(r.concat(t));let e=await pe(`key`,t.key,n,r);if(e===N)return N;e===P&&(t.key=null);let i=await pe(`value`,t.value,n,r);if(i===N)return N;i===P&&(t.value=null)}}return i}function me(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 he(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(oe(t))return n.Map?.(e,t,r);if(se(t))return n.Seq?.(e,t,r);if(k(t))return n.Pair?.(e,t,r);if(A(t))return n.Scalar?.(e,t,r);if(O(t))return n.Alias?.(e,t,r)}function ge(e,t,n){let r=t[t.length-1];if(j(r))r.items[e]=n;else if(k(r))e===`key`?r.key=n:r.value=n;else if(ae(r))r.contents=n;else{let e=O(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}const _e={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},ve=e=>e.replace(/[!,[\]{}]/g,e=>_e[e]);var ye=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+ve(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&&M(e.contents)){let t={};ue(e.contents,(e,n)=>{M(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(`
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-BE5wq_hp.js";import{r as c,s as l,t as u}from"./proxied-fetch-ldIfAeIb.js";import"./src-Dk1QVJRd.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-BC810skI.js";import{d as h,f as g,l as _,r as v,t as y,u as b}from"./bedrock-camp-D_7EbOFH.js";const x=`slicc_oauth_extra_domains`;function S(e){try{let t=e.getItem(x);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 ee(e,t){try{e.setItem(x,JSON.stringify(t))}catch(e){throw Error(`Failed to persist OAuth extras (localStorage quota exceeded?): ${e instanceof Error?e.message:String(e)}`)}}function C(){return d()?`extension-direct`:c()?`extension-delegate`:globalThis.__slicc_connect_mode?`connect`:`node-rest`}function te(){return C()===`node-rest`}const ne=Symbol.for(`yaml.alias`),re=Symbol.for(`yaml.document`),w=Symbol.for(`yaml.map`),ie=Symbol.for(`yaml.pair`),T=Symbol.for(`yaml.scalar`),E=Symbol.for(`yaml.seq`),D=Symbol.for(`yaml.node.type`),O=e=>!!e&&typeof e==`object`&&e[D]===ne,ae=e=>!!e&&typeof e==`object`&&e[D]===re,oe=e=>!!e&&typeof e==`object`&&e[D]===w,k=e=>!!e&&typeof e==`object`&&e[D]===ie,A=e=>!!e&&typeof e==`object`&&e[D]===T,se=e=>!!e&&typeof e==`object`&&e[D]===E;function j(e){if(e&&typeof e==`object`)switch(e[D]){case w:case E:return!0}return!1}function M(e){if(e&&typeof e==`object`)switch(e[D]){case ne:case w:case T:case E:return!0}return!1}const ce=e=>(A(e)||j(e))&&!!e.anchor,N=Symbol(`break visit`),le=Symbol(`skip children`),P=Symbol(`remove node`);function ue(e,t){let n=me(t);ae(e)?de(null,e.contents,n,Object.freeze([e]))===P&&(e.contents=null):de(null,e,n,Object.freeze([]))}ue.BREAK=N,ue.SKIP=le,ue.REMOVE=P;function de(e,t,n,r){let i=he(e,t,n,r);if(M(i)||k(i))return ge(e,r,i),de(e,i,n,r);if(typeof i!=`symbol`){if(j(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=de(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===N)return N;else i===P&&(t.items.splice(e,1),--e)}}else if(k(t)){r=Object.freeze(r.concat(t));let e=de(`key`,t.key,n,r);if(e===N)return N;e===P&&(t.key=null);let i=de(`value`,t.value,n,r);if(i===N)return N;i===P&&(t.value=null)}}return i}async function fe(e,t){let n=me(t);ae(e)?await pe(null,e.contents,n,Object.freeze([e]))===P&&(e.contents=null):await pe(null,e,n,Object.freeze([]))}fe.BREAK=N,fe.SKIP=le,fe.REMOVE=P;async function pe(e,t,n,r){let i=await he(e,t,n,r);if(M(i)||k(i))return ge(e,r,i),pe(e,i,n,r);if(typeof i!=`symbol`){if(j(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=await pe(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===N)return N;else i===P&&(t.items.splice(e,1),--e)}}else if(k(t)){r=Object.freeze(r.concat(t));let e=await pe(`key`,t.key,n,r);if(e===N)return N;e===P&&(t.key=null);let i=await pe(`value`,t.value,n,r);if(i===N)return N;i===P&&(t.value=null)}}return i}function me(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 he(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(oe(t))return n.Map?.(e,t,r);if(se(t))return n.Seq?.(e,t,r);if(k(t))return n.Pair?.(e,t,r);if(A(t))return n.Scalar?.(e,t,r);if(O(t))return n.Alias?.(e,t,r)}function ge(e,t,n){let r=t[t.length-1];if(j(r))r.items[e]=n;else if(k(r))e===`key`?r.key=n:r.value=n;else if(ae(r))r.contents=n;else{let e=O(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}const _e={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},ve=e=>e.replace(/[!,[\]{}]/g,e=>_e[e]);var ye=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+ve(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&&M(e.contents)){let t={};ue(e.contents,(e,n)=>{M(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(`
2
2
  `)}};ye.defaultYaml={explicit:!1,version:`1.2`},ye.defaultTags={"!!":`tag:yaml.org,2002:`};function be(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 xe(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=xe(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=xe(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=xe(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=xe(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}return e.call(t,n,r)}function F(e,t,n){if(Array.isArray(e))return e.map((e,t)=>F(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!ce(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 Se=class{constructor(e){Object.defineProperty(this,D,{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(!ae(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=F(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?xe(i,{"":o},``,o):o}},Ce=class extends Se{constructor(e){super(ne),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=[],ue(e,{Node:(e,t)=>{(O(t)||ce(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||=(F(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=we(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(be(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 we(e,t,n){if(O(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(j(t)){let r=0;for(let i of t.items){let t=we(e,i,n);t>r&&(r=t)}return r}else if(k(t)){let r=we(e,t.key,n),i=we(e,t.value,n);return Math.max(r,i)}return 1}const Te=e=>!e||typeof e!=`function`&&typeof e!=`object`;var I=class extends Se{constructor(e){super(T),this.value=e}toJSON(e,t){return t?.keep?this.value:F(this.value,e,t)}toString(){return String(this.value)}};I.BLOCK_FOLDED=`BLOCK_FOLDED`,I.BLOCK_LITERAL=`BLOCK_LITERAL`,I.PLAIN=`PLAIN`,I.QUOTE_DOUBLE=`QUOTE_DOUBLE`,I.QUOTE_SINGLE=`QUOTE_SINGLE`;function Ee(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 De(e,t,n){if(ae(e)&&(e=e.contents),M(e))return e;if(k(e)){let t=n.schema[w].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 Ce(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=`tag:yaml.org,2002:`+t.slice(2));let l=Ee(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new I(e);return c&&(c.node=t),t}l=e instanceof Map?o[w]:Symbol.iterator in Object(e)?o[E]:o[w]}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 I(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function Oe(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 De(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}const ke=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;var Ae=class extends Se{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=>M(t)||k(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(ke(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(j(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,Oe(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(j(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&&A(i)?i.value:i:j(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!k(t))return!1;let n=t.value;return n==null||e&&A(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 j(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(j(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,Oe(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}};const je=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function Me(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const Ne=(e,t,n)=>e.endsWith(`
3
3
  `)?Me(n,t):n.includes(`
4
4
  `)?`
@@ -1 +1 @@
1
- import{n as e}from"./panel-rpc-CjFVE0nK.js";import{R as t,d as n,y as r}from"./account-store-FTgVysIG.js";import{n as i}from"./event-stream-qbAZIAKV.js";import{a,c as o,d as s,f as c,i as l,o as u,p as d,s as f}from"./bedrock-camp-D_7EbOFH.js";import{a as p,r as m,s as h,t as g}from"./legacy-api-aliases-CdGTJw-r.js";import{n as _}from"./llm-session-id-ZObKEXzb.js";import{n as v,t as ee}from"./silent-renew-backoff-DyzFsWYC.js";import{getOAuthPageOrigin as te}from"./oauth-service-foejPYvF.js";import"./provider-settings-DcnfIdhT.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 a(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]:`5.73.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)}: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,n,r)=>{let i=S(),a=await D(i),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),r?.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 t({providerId:`adobe`,accessToken:g.accessToken,tokenExpiresAt:Date.now()+g.expiresIn*1e3,userName:_.name,userAvatar:_.avatar,baseUrl:x.proxyEndpoint?void 0:i}),await $().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),n()},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 t({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,n){let r=P();await t({providerId:`adobe`,accessToken:e.accessToken,tokenExpiresAt:Date.now()+e.expiresIn*1e3,userName:r?.userName,userAvatar:r?.userAvatar,baseUrl:x.proxyEndpoint?void 0:n})}async function U(){try{let e=S(),{authorizeUrl:t,expectedNonce:n}=B(e,await D(e)),{createOAuthLauncher:r}=await import(`./oauth-service-foejPYvF.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]=`5.73.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=i();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=i();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 Z(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 de(){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,t){let n={input:0,output:0,cacheRead:0,cacheWrite:0},r=o(e);if(!r)return n;let i;for(let e of t.values()){let t=o(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}function pe(e,t,n){let r=`adobe-${e.api===`openai`?`openai`:`anthropic`}`,i=n.get(e.id);if(i)return{...i,provider:`adobe`,api:r};let a=fe(e.id,n);return{id:e.id,name:e.name??e.id,provider:`adobe`,api:r,baseUrl:t,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:a,inputCost:a.input,outputCost:a.output,cacheReadCost:a.cacheRead,cacheWriteCost:a.cacheWrite,reasoning:!0}}function me(e,t){for(let t of e)w.set(t.id,Z(t));let n=de();return e.map(e=>pe(e,t,n))}async function he(e){try{let t=e??await R(),n=S(),r=await fetch(`${n}/v1/models`,{headers:{Authorization:`Bearer ${t}`,[W]:`5.73.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 me(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 ge(){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 he(e);return r?(Q.set(t,r),r):ge()}function _e(){d({api:`adobe-anthropic`,stream:Y,streamSimple:X}),d({api:`adobe-openai`,stream:Y,streamSimple:X})}export{ue as __resetAdobeSessionIdWarningCacheForTests,I as config,$ as getAdobeModels,R as getValidAccessToken,le as isTokenExpired,_e as register};
1
+ import{n as e}from"./panel-rpc-CjFVE0nK.js";import{R as t,d as n,y as r}from"./account-store-DWKDZbQl.js";import{n as i}from"./event-stream-qbAZIAKV.js";import{a,c as o,d as s,f as c,i as l,o as u,p as d,s as f}from"./bedrock-camp-D_7EbOFH.js";import{a as p,r as m,s as h,t as g}from"./legacy-api-aliases-CdGTJw-r.js";import{n as _}from"./llm-session-id-ZObKEXzb.js";import{n as v,t as ee}from"./silent-renew-backoff-DyzFsWYC.js";import{getOAuthPageOrigin as te}from"./oauth-service-foejPYvF.js";import"./provider-settings-BonXlQHx.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 a(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]:`5.73.2`}});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)}: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,n,r)=>{let i=S(),a=await D(i),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),r?.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 t({providerId:`adobe`,accessToken:g.accessToken,tokenExpiresAt:Date.now()+g.expiresIn*1e3,userName:_.name,userAvatar:_.avatar,baseUrl:x.proxyEndpoint?void 0:i}),await $().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),n()},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 t({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,n){let r=P();await t({providerId:`adobe`,accessToken:e.accessToken,tokenExpiresAt:Date.now()+e.expiresIn*1e3,userName:r?.userName,userAvatar:r?.userAvatar,baseUrl:x.proxyEndpoint?void 0:n})}async function U(){try{let e=S(),{authorizeUrl:t,expectedNonce:n}=B(e,await D(e)),{createOAuthLauncher:r}=await import(`./oauth-service-foejPYvF.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]=`5.73.2`,{...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=i();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=i();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 Z(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 de(){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,t){let n={input:0,output:0,cacheRead:0,cacheWrite:0},r=o(e);if(!r)return n;let i;for(let e of t.values()){let t=o(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}function pe(e,t,n){let r=`adobe-${e.api===`openai`?`openai`:`anthropic`}`,i=n.get(e.id);if(i)return{...i,provider:`adobe`,api:r};let a=fe(e.id,n);return{id:e.id,name:e.name??e.id,provider:`adobe`,api:r,baseUrl:t,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:a,inputCost:a.input,outputCost:a.output,cacheReadCost:a.cacheRead,cacheWriteCost:a.cacheWrite,reasoning:!0}}function me(e,t){for(let t of e)w.set(t.id,Z(t));let n=de();return e.map(e=>pe(e,t,n))}async function he(e){try{let t=e??await R(),n=S(),r=await fetch(`${n}/v1/models`,{headers:{Authorization:`Bearer ${t}`,[W]:`5.73.2`}});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 me(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 ge(){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 he(e);return r?(Q.set(t,r),r):ge()}function _e(){d({api:`adobe-anthropic`,stream:Y,streamSimple:X}),d({api:`adobe-openai`,stream:Y,streamSimple:X})}export{ue as __resetAdobeSessionIdWarningCacheForTests,I as config,$ as getAdobeModels,R as getValidAccessToken,le as isTokenExpired,_e as register};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/oauth-service-lE9AyywH.js","assets/preload-helper-Czpn1I53.js","assets/proxied-fetch-D5h5REZy.js","assets/rolldown-runtime-aKtaBQYM.js","assets/base64-DpPqYZJF.js","assets/src-CS5gSDhT.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{n as e}from"./event-stream-qbAZIAKV.js";import{t}from"./preload-helper-Czpn1I53.js";import{a as n,i as r,r as i}from"./compat-Spvv5tCW.js";import{R as a,d as o,y as s}from"./account-store-ffzft8RA.js";import{a as c,r as l,s as u,t as d}from"./legacy-api-aliases-CRTuRAqQ.js";import{t as f}from"./panel-rpc-DmJSNs0I.js";import{a as p,c as m,i as h,o as g,s as _}from"./bedrock-camp-PMQ4Iu6f.js";import"./provider-settings-BSR3nkqj.js";import{n as v,t as ee}from"./silent-renew-backoff-Dzkpjjro.js";import{getOAuthPageOrigin as te}from"./oauth-service-lE9AyywH.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 p(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=s(`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:{[W]:`5.73.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 o().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)}: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 r=C(),i=await O(r),o=k(i),s=A(i),c=j(i),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 a({providerId:`adobe`,accessToken:g.accessToken,tokenExpiresAt:Date.now()+g.expiresIn*1e3,userName:_.name,userAvatar:_.avatar,baseUrl:S.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=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 a({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>F()?.accessToken?B():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(()=>B());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 le(){let e=F();return!e?.tokenExpiresAt||Date.now()>e.tokenExpiresAt-6e4}async function B(){if(typeof window>`u`){let e=f();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=ue().finally(()=>{R=null}),R)}function V(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 H(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 U(e,t){let n=F();await a({providerId:`adobe`,accessToken:e.accessToken,tokenExpiresAt:Date.now()+e.expiresIn*1e3,userName:n?.userName,userAvatar:n?.userAvatar,baseUrl:S.proxyEndpoint?void 0:t})}async function ue(){try{let e=C(),{authorizeUrl:n,expectedNonce:r}=V(e,await O(e)),{createOAuthLauncher:i}=await t(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-lE9AyywH.js`);return{createOAuthLauncher:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),a=await i()(n,{interactive:!1});if(!a||!H(a,r))return null;let o=I(a);return o?(await U(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 W=`X-Slicc-Version`;function G(e){let t={},n=W.toLowerCase();if(e.headers)for(let[r,i]of Object.entries(e.headers))r.toLowerCase()!==n&&(t[r]=i);return t[W]=`5.73.0`,{...e,headers:t}}var de=`adobe-provider-fallback`,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":ne(de)}}}function fe(){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()}}}var Y=(t,n,r={})=>{let i=e();return(async()=>{try{let e=await z();if(String(t.api).includes(`openai`)){let a=l({...t,baseUrl:`${C()}/v1`,api:`openai-completions`,compat:{...t.compat,supportsStore:!1,supportsDeveloperRole:!1}},n,G(q({...r,apiKey:e},`streamAdobe[openai]`)));for await(let e of a)i.push(e)}else{let a=d({...t,baseUrl:C(),api:`anthropic-messages`},n,G(q(x(t,h(t.id,t.name,{...r,apiKey:e})),`streamAdobe[anthropic]`)));for await(let e of a)i.push(e)}i.end()}catch(e){console.error(`[adobe] Stream error:`,e instanceof Error?e.message:String(e)),i.push(J(t,e)),i.end()}})(),i},X=(t,n,r)=>{let i=e();return(async()=>{try{let e=await z();if(String(t.api).includes(`openai`)){let a=u({...t,baseUrl:`${C()}/v1`,api:`openai-completions`,compat:{...t.compat,supportsStore:!1,supportsDeveloperRole:!1}},n,G(q({...r,apiKey:e},`streamSimpleAdobe[openai]`)));for await(let e of a)i.push(e)}else{let a=c({...t,baseUrl:C(),api:`anthropic-messages`},n,G(q(x(t,h(t.id,t.name,{...r,apiKey:e})),`streamSimpleAdobe[anthropic]`)));for await(let e of a)i.push(e)}i.end()}catch(e){console.error(`[adobe] Stream error:`,e instanceof Error?e.message:String(e)),i.push(J(t,e)),i.end()}})(),i};function pe(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 me(){let e=new Map;for(let t of r())try{for(let n of i(t))e.set(n.id,n)}catch{}return e}function he(e,t){let n={input:0,output:0,cacheRead:0,cacheWrite:0},r=m(e);if(!r)return n;let i;for(let e of t.values()){let t=m(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}function ge(e,t,n){let r=`adobe-${e.api===`openai`?`openai`:`anthropic`}`,i=n.get(e.id);if(i)return{...i,provider:`adobe`,api:r};let a=he(e.id,n);return{id:e.id,name:e.name??e.id,provider:`adobe`,api:r,baseUrl:t,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:a,inputCost:a.input,outputCost:a.output,cacheReadCost:a.cacheRead,cacheWriteCost:a.cacheWrite,reasoning:!0}}function Z(e,t){for(let t of e)T.set(t.id,pe(t));let n=me();return e.map(e=>ge(e,t,n))}async function _e(e){try{let t=e??await z(),n=C(),r=await fetch(`${n}/v1/models`,{headers:{Authorization:`Bearer ${t}`,[W]:`5.73.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 Z(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 ve(){return i(`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 _e(e);return r?(Q.set(t,r),r):ve()}function ye(){n({api:`adobe-anthropic`,stream:Y,streamSimple:X}),n({api:`adobe-openai`,stream:Y,streamSimple:X})}export{fe as __resetAdobeSessionIdWarningCacheForTests,L as config,$ as getAdobeModels,z as getValidAccessToken,le as isTokenExpired,ye as register};
2
+ import{n as e}from"./event-stream-qbAZIAKV.js";import{t}from"./preload-helper-Czpn1I53.js";import{a as n,i as r,r as i}from"./compat-Spvv5tCW.js";import{R as a,d as o,y as s}from"./account-store-1sWsdBXV.js";import{a as c,r as l,s as u,t as d}from"./legacy-api-aliases-CRTuRAqQ.js";import{t as f}from"./panel-rpc-DmJSNs0I.js";import{a as p,c as m,i as h,o as g,s as _}from"./bedrock-camp-PMQ4Iu6f.js";import"./provider-settings-BQ_ViD6o.js";import{n as v,t as ee}from"./silent-renew-backoff-Dzkpjjro.js";import{getOAuthPageOrigin as te}from"./oauth-service-lE9AyywH.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 p(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=s(`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:{[W]:`5.73.2`}});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 o().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)}: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 r=C(),i=await O(r),o=k(i),s=A(i),c=j(i),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 a({providerId:`adobe`,accessToken:g.accessToken,tokenExpiresAt:Date.now()+g.expiresIn*1e3,userName:_.name,userAvatar:_.avatar,baseUrl:S.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=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 a({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>F()?.accessToken?B():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(()=>B());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 le(){let e=F();return!e?.tokenExpiresAt||Date.now()>e.tokenExpiresAt-6e4}async function B(){if(typeof window>`u`){let e=f();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=ue().finally(()=>{R=null}),R)}function V(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 H(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 U(e,t){let n=F();await a({providerId:`adobe`,accessToken:e.accessToken,tokenExpiresAt:Date.now()+e.expiresIn*1e3,userName:n?.userName,userAvatar:n?.userAvatar,baseUrl:S.proxyEndpoint?void 0:t})}async function ue(){try{let e=C(),{authorizeUrl:n,expectedNonce:r}=V(e,await O(e)),{createOAuthLauncher:i}=await t(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-lE9AyywH.js`);return{createOAuthLauncher:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),a=await i()(n,{interactive:!1});if(!a||!H(a,r))return null;let o=I(a);return o?(await U(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 W=`X-Slicc-Version`;function G(e){let t={},n=W.toLowerCase();if(e.headers)for(let[r,i]of Object.entries(e.headers))r.toLowerCase()!==n&&(t[r]=i);return t[W]=`5.73.2`,{...e,headers:t}}var de=`adobe-provider-fallback`,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":ne(de)}}}function fe(){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()}}}var Y=(t,n,r={})=>{let i=e();return(async()=>{try{let e=await z();if(String(t.api).includes(`openai`)){let a=l({...t,baseUrl:`${C()}/v1`,api:`openai-completions`,compat:{...t.compat,supportsStore:!1,supportsDeveloperRole:!1}},n,G(q({...r,apiKey:e},`streamAdobe[openai]`)));for await(let e of a)i.push(e)}else{let a=d({...t,baseUrl:C(),api:`anthropic-messages`},n,G(q(x(t,h(t.id,t.name,{...r,apiKey:e})),`streamAdobe[anthropic]`)));for await(let e of a)i.push(e)}i.end()}catch(e){console.error(`[adobe] Stream error:`,e instanceof Error?e.message:String(e)),i.push(J(t,e)),i.end()}})(),i},X=(t,n,r)=>{let i=e();return(async()=>{try{let e=await z();if(String(t.api).includes(`openai`)){let a=u({...t,baseUrl:`${C()}/v1`,api:`openai-completions`,compat:{...t.compat,supportsStore:!1,supportsDeveloperRole:!1}},n,G(q({...r,apiKey:e},`streamSimpleAdobe[openai]`)));for await(let e of a)i.push(e)}else{let a=c({...t,baseUrl:C(),api:`anthropic-messages`},n,G(q(x(t,h(t.id,t.name,{...r,apiKey:e})),`streamSimpleAdobe[anthropic]`)));for await(let e of a)i.push(e)}i.end()}catch(e){console.error(`[adobe] Stream error:`,e instanceof Error?e.message:String(e)),i.push(J(t,e)),i.end()}})(),i};function pe(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 me(){let e=new Map;for(let t of r())try{for(let n of i(t))e.set(n.id,n)}catch{}return e}function he(e,t){let n={input:0,output:0,cacheRead:0,cacheWrite:0},r=m(e);if(!r)return n;let i;for(let e of t.values()){let t=m(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}function ge(e,t,n){let r=`adobe-${e.api===`openai`?`openai`:`anthropic`}`,i=n.get(e.id);if(i)return{...i,provider:`adobe`,api:r};let a=he(e.id,n);return{id:e.id,name:e.name??e.id,provider:`adobe`,api:r,baseUrl:t,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:a,inputCost:a.input,outputCost:a.output,cacheReadCost:a.cacheRead,cacheWriteCost:a.cacheWrite,reasoning:!0}}function Z(e,t){for(let t of e)T.set(t.id,pe(t));let n=me();return e.map(e=>ge(e,t,n))}async function _e(e){try{let t=e??await z(),n=C(),r=await fetch(`${n}/v1/models`,{headers:{Authorization:`Bearer ${t}`,[W]:`5.73.2`}});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 Z(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 ve(){return i(`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 _e(e);return r?(Q.set(t,r),r):ve()}function ye(){n({api:`adobe-anthropic`,stream:Y,streamSimple:X}),n({api:`adobe-openai`,stream:Y,streamSimple:X})}export{fe as __resetAdobeSessionIdWarningCacheForTests,L as config,$ as getAdobeModels,z as getValidAccessToken,le as isTokenExpired,ye as register};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./types-idfTVsM8.js";import{t as n}from"./global-db-DvmmimLY.js";const r=e(`mcp-apps`),i=`/workspace/.mcp/sprinkles`;async function a(e){if(e)return e;let{VirtualFS:t}=await import(`./fs-t1A190GT.js`).then(e=>e.t);return await t.create({dbName:n})}function o(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64)||`app`}function s(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function c(e,t){let n=s(t.title??t.name),r=t.description?s(t.description):``,i=s(t.templateUri??`about:blank`),a=JSON.stringify(e),o=JSON.stringify(t.name);return`<div class="mcp-app" data-sprinkle-title="${n}" style="display:flex;flex-direction:column;height:100%;min-height:0;">
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./types-idfTVsM8.js";import{t as n}from"./global-db-DvmmimLY.js";const r=e(`mcp-apps`),i=`/workspace/.mcp/sprinkles`;async function a(e){if(e)return e;let{VirtualFS:t}=await import(`./fs-PoNPHaXB.js`).then(e=>e.t);return await t.create({dbName:n})}function o(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64)||`app`}function s(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function c(e,t){let n=s(t.title??t.name),r=t.description?s(t.description):``,i=s(t.templateUri??`about:blank`),a=JSON.stringify(e),o=JSON.stringify(t.name);return`<div class="mcp-app" data-sprinkle-title="${n}" style="display:flex;flex-direction:column;height:100%;min-height:0;">
2
2
  <header class="mcp-app__header" style="padding:8px 12px;border-bottom:1px solid var(--s2-border-subtle,#3a3a3a);">
3
3
  <h2 style="font-size:14px;font-weight:600;margin:0;">${n}</h2>${r?`\n <p style="font-size:12px;margin:4px 0 0;color:var(--s2-content-secondary,#a0a0a0);">${r}</p>`:``}
4
4
  </header>
@@ -1 +1 @@
1
- import{n as e}from"./event-stream-qbAZIAKV.js";import{t}from"./models-Bnh9VDA1.js";import{a as n}from"./compat-Spvv5tCW.js";import{b as r,g as i}from"./account-store-ffzft8RA.js";import{r as a,t as o}from"./transform-messages-wECJwtH0.js";import{t as s}from"./openai-BxFF4GUL.js";var c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let e=r(c);if(!e)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return t.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:t.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=o(e.messages,t,d),r=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)r.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});r.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),i=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));i.length?r.push({role:`assistant`,content:n||null,tool_calls:i}):r.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;r.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return r}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}function g(e){return{role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,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:`stop`,timestamp:Date.now()}}function _(e,t){let n=t.apiKey;if(!n)throw Error(`Azure API key is required`);let r=e.baseUrl;if(!r)throw Error(`Azure endpoint is required`);let a={};e.headers&&Object.assign(a,e.headers),t.headers&&Object.assign(a,t.headers);let o=i(c)||l,u=e.id;return{client:new s({endpoint:r.replace(/\/+$/,``),apiKey:n,deployment:u,apiVersion:o,dangerouslyAllowBrowser:!0,defaultHeaders:a}),deployment:u}}function v(e,t){return[...e.systemPrompt?[{role:`system`,content:e.systemPrompt}]:[],...f(e,t)]}function y(e,n,r){r&&(e.usage.input=r.prompt_tokens??0,e.usage.output=r.completion_tokens??0,e.usage.totalTokens=r.total_tokens??0,t(n,e.usage))}function b(e){return e===`tool_calls`?`toolUse`:e===`length`?`length`:`stop`}function x(e,t,n){let{block:r,index:i}=m(t);r.text===``&&e.push({type:`text_start`,contentIndex:i,partial:t}),r.text+=n,e.push({type:`text_delta`,contentIndex:i,delta:n,partial:t})}function S(e,t,n){let r=n.id?h(t,n.id):void 0;if(r||!n.id)return r;let i={type:`toolCall`,id:n.id,name:n.function?.name??``,arguments:{},_partialJson:``};return t.content.push(i),e.push({type:`toolcall_start`,contentIndex:t.content.length-1,partial:t}),i}function C(e,t,n,r){n._partialJson+=r;try{n.arguments=JSON.parse(n._partialJson)}catch{}e.push({type:`toolcall_delta`,contentIndex:t.content.indexOf(n),delta:r,partial:t})}function w(e,t,n){for(let r of n){let n=S(e,t,r);n&&r.function?.arguments&&C(e,t,n,r.function.arguments)}}function T(e,t,n){let r=n.delta;r&&(r.content&&x(e,t,r.content),r.tool_calls&&w(e,t,r.tool_calls),n.finish_reason&&(t.stopReason=b(n.finish_reason)))}function E(e,t,n,r){try{n.arguments=JSON.parse(n._partialJson||`{}`)}catch{}delete n._partialJson,e.push({type:`toolcall_end`,contentIndex:r,toolCall:n,partial:t})}function D(e,t){for(let n=0;n<t.content.length;n+=1){let r=t.content[n];r.type===`toolCall`?E(e,t,r,n):r.type===`text`&&e.push({type:`text_end`,contentIndex:n,content:r.text,partial:t})}}async function O(e,t,n,r,i){let{client:a,deployment:o}=_(n,i),s=p(r.tools),c=await a.chat.completions.create({model:o,messages:v(r,n),stream:!0,stream_options:{include_usage:!0},...i.maxTokens?{max_completion_tokens:i.maxTokens}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...s?{tools:s}:{}});e.push({type:`start`,partial:t});for await(let r of c){y(t,n,r.usage);for(let n of r.choices??[])T(e,t,n)}D(e,t),e.push({type:`done`,reason:t.stopReason,message:t}),e.end()}function k(e,t,n,r){t.stopReason=r?`aborted`:`error`,t.errorMessage=n instanceof Error?n.message:JSON.stringify(n),e.push({type:`error`,reason:t.stopReason,error:t}),e.end()}var A=(t,n,r={})=>{let i=e(),a=g(t);return O(i,a,t,n,r).catch(e=>{k(i,a,e,!!r.signal?.aborted)}),i},j=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`Azure API key is required`);return A(e,t,{...a(e,n,r)})};function M(){n({api:`azure-openai-anthropic`,stream:A,streamSimple:j})}export{u as config,M as register};
1
+ import{n as e}from"./event-stream-qbAZIAKV.js";import{t}from"./models-Bnh9VDA1.js";import{a as n}from"./compat-Spvv5tCW.js";import{b as r,g as i}from"./account-store-1sWsdBXV.js";import{r as a,t as o}from"./transform-messages-wECJwtH0.js";import{t as s}from"./openai-BxFF4GUL.js";var c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let e=r(c);if(!e)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return t.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:t.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=o(e.messages,t,d),r=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)r.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});r.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),i=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));i.length?r.push({role:`assistant`,content:n||null,tool_calls:i}):r.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;r.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return r}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}function g(e){return{role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,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:`stop`,timestamp:Date.now()}}function _(e,t){let n=t.apiKey;if(!n)throw Error(`Azure API key is required`);let r=e.baseUrl;if(!r)throw Error(`Azure endpoint is required`);let a={};e.headers&&Object.assign(a,e.headers),t.headers&&Object.assign(a,t.headers);let o=i(c)||l,u=e.id;return{client:new s({endpoint:r.replace(/\/+$/,``),apiKey:n,deployment:u,apiVersion:o,dangerouslyAllowBrowser:!0,defaultHeaders:a}),deployment:u}}function v(e,t){return[...e.systemPrompt?[{role:`system`,content:e.systemPrompt}]:[],...f(e,t)]}function y(e,n,r){r&&(e.usage.input=r.prompt_tokens??0,e.usage.output=r.completion_tokens??0,e.usage.totalTokens=r.total_tokens??0,t(n,e.usage))}function b(e){return e===`tool_calls`?`toolUse`:e===`length`?`length`:`stop`}function x(e,t,n){let{block:r,index:i}=m(t);r.text===``&&e.push({type:`text_start`,contentIndex:i,partial:t}),r.text+=n,e.push({type:`text_delta`,contentIndex:i,delta:n,partial:t})}function S(e,t,n){let r=n.id?h(t,n.id):void 0;if(r||!n.id)return r;let i={type:`toolCall`,id:n.id,name:n.function?.name??``,arguments:{},_partialJson:``};return t.content.push(i),e.push({type:`toolcall_start`,contentIndex:t.content.length-1,partial:t}),i}function C(e,t,n,r){n._partialJson+=r;try{n.arguments=JSON.parse(n._partialJson)}catch{}e.push({type:`toolcall_delta`,contentIndex:t.content.indexOf(n),delta:r,partial:t})}function w(e,t,n){for(let r of n){let n=S(e,t,r);n&&r.function?.arguments&&C(e,t,n,r.function.arguments)}}function T(e,t,n){let r=n.delta;r&&(r.content&&x(e,t,r.content),r.tool_calls&&w(e,t,r.tool_calls),n.finish_reason&&(t.stopReason=b(n.finish_reason)))}function E(e,t,n,r){try{n.arguments=JSON.parse(n._partialJson||`{}`)}catch{}delete n._partialJson,e.push({type:`toolcall_end`,contentIndex:r,toolCall:n,partial:t})}function D(e,t){for(let n=0;n<t.content.length;n+=1){let r=t.content[n];r.type===`toolCall`?E(e,t,r,n):r.type===`text`&&e.push({type:`text_end`,contentIndex:n,content:r.text,partial:t})}}async function O(e,t,n,r,i){let{client:a,deployment:o}=_(n,i),s=p(r.tools),c=await a.chat.completions.create({model:o,messages:v(r,n),stream:!0,stream_options:{include_usage:!0},...i.maxTokens?{max_completion_tokens:i.maxTokens}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...s?{tools:s}:{}});e.push({type:`start`,partial:t});for await(let r of c){y(t,n,r.usage);for(let n of r.choices??[])T(e,t,n)}D(e,t),e.push({type:`done`,reason:t.stopReason,message:t}),e.end()}function k(e,t,n,r){t.stopReason=r?`aborted`:`error`,t.errorMessage=n instanceof Error?n.message:JSON.stringify(n),e.push({type:`error`,reason:t.stopReason,error:t}),e.end()}var A=(t,n,r={})=>{let i=e(),a=g(t);return O(i,a,t,n,r).catch(e=>{k(i,a,e,!!r.signal?.aborted)}),i},j=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`Azure API key is required`);return A(e,t,{...a(e,n,r)})};function M(){n({api:`azure-openai-anthropic`,stream:A,streamSimple:j})}export{u as config,M as register};
@@ -1 +1 @@
1
- import{b as e,g as t}from"./account-store-FTgVysIG.js";import{n}from"./event-stream-qbAZIAKV.js";import{o as r,r as i,t as a}from"./transform-messages-Bp94o3FD.js";import{p as o}from"./bedrock-camp-D_7EbOFH.js";import{t as s}from"./openai-CmTnPr9N.js";const c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let t=e(c);if(!t)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let n=t.split(`,`).map(e=>e.trim()).filter(Boolean);return n.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:n.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=a(e.messages,t,d),r=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)r.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});r.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),i=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));i.length?r.push({role:`assistant`,content:n||null,tool_calls:i}):r.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;r.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return r}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}function g(e){return{role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,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:`stop`,timestamp:Date.now()}}function _(e,n){let r=n.apiKey;if(!r)throw Error(`Azure API key is required`);let i=e.baseUrl;if(!i)throw Error(`Azure endpoint is required`);let a={};e.headers&&Object.assign(a,e.headers),n.headers&&Object.assign(a,n.headers);let o=t(c)||l,u=e.id;return{client:new s({endpoint:i.replace(/\/+$/,``),apiKey:r,deployment:u,apiVersion:o,dangerouslyAllowBrowser:!0,defaultHeaders:a}),deployment:u}}function v(e,t){return[...e.systemPrompt?[{role:`system`,content:e.systemPrompt}]:[],...f(e,t)]}function y(e,t,n){n&&(e.usage.input=n.prompt_tokens??0,e.usage.output=n.completion_tokens??0,e.usage.totalTokens=n.total_tokens??0,r(t,e.usage))}function b(e){return e===`tool_calls`?`toolUse`:e===`length`?`length`:`stop`}function x(e,t,n){let{block:r,index:i}=m(t);r.text===``&&e.push({type:`text_start`,contentIndex:i,partial:t}),r.text+=n,e.push({type:`text_delta`,contentIndex:i,delta:n,partial:t})}function S(e,t,n){let r=n.id?h(t,n.id):void 0;if(r||!n.id)return r;let i={type:`toolCall`,id:n.id,name:n.function?.name??``,arguments:{},_partialJson:``};return t.content.push(i),e.push({type:`toolcall_start`,contentIndex:t.content.length-1,partial:t}),i}function C(e,t,n,r){n._partialJson+=r;try{n.arguments=JSON.parse(n._partialJson)}catch{}e.push({type:`toolcall_delta`,contentIndex:t.content.indexOf(n),delta:r,partial:t})}function w(e,t,n){for(let r of n){let n=S(e,t,r);n&&r.function?.arguments&&C(e,t,n,r.function.arguments)}}function T(e,t,n){let r=n.delta;r&&(r.content&&x(e,t,r.content),r.tool_calls&&w(e,t,r.tool_calls),n.finish_reason&&(t.stopReason=b(n.finish_reason)))}function E(e,t,n,r){try{n.arguments=JSON.parse(n._partialJson||`{}`)}catch{}delete n._partialJson,e.push({type:`toolcall_end`,contentIndex:r,toolCall:n,partial:t})}function D(e,t){for(let n=0;n<t.content.length;n+=1){let r=t.content[n];r.type===`toolCall`?E(e,t,r,n):r.type===`text`&&e.push({type:`text_end`,contentIndex:n,content:r.text,partial:t})}}async function O(e,t,n,r,i){let{client:a,deployment:o}=_(n,i),s=p(r.tools),c=await a.chat.completions.create({model:o,messages:v(r,n),stream:!0,stream_options:{include_usage:!0},...i.maxTokens?{max_completion_tokens:i.maxTokens}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...s?{tools:s}:{}});e.push({type:`start`,partial:t});for await(let r of c){y(t,n,r.usage);for(let n of r.choices??[])T(e,t,n)}D(e,t),e.push({type:`done`,reason:t.stopReason,message:t}),e.end()}function k(e,t,n,r){t.stopReason=r?`aborted`:`error`,t.errorMessage=n instanceof Error?n.message:JSON.stringify(n),e.push({type:`error`,reason:t.stopReason,error:t}),e.end()}const A=(e,t,r={})=>{let i=n(),a=g(e);return O(i,a,e,t,r).catch(e=>{k(i,a,e,!!r.signal?.aborted)}),i},j=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`Azure API key is required`);let a=i(e,n,r);return A(e,t,{...a})};function M(){o({api:`azure-openai-anthropic`,stream:A,streamSimple:j})}export{u as config,M as register};
1
+ import{b as e,g as t}from"./account-store-DWKDZbQl.js";import{n}from"./event-stream-qbAZIAKV.js";import{o as r,r as i,t as a}from"./transform-messages-Bp94o3FD.js";import{p as o}from"./bedrock-camp-D_7EbOFH.js";import{t as s}from"./openai-CmTnPr9N.js";const c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let t=e(c);if(!t)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let n=t.split(`,`).map(e=>e.trim()).filter(Boolean);return n.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:n.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=a(e.messages,t,d),r=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)r.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});r.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),i=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));i.length?r.push({role:`assistant`,content:n||null,tool_calls:i}):r.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;r.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return r}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}function g(e){return{role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,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:`stop`,timestamp:Date.now()}}function _(e,n){let r=n.apiKey;if(!r)throw Error(`Azure API key is required`);let i=e.baseUrl;if(!i)throw Error(`Azure endpoint is required`);let a={};e.headers&&Object.assign(a,e.headers),n.headers&&Object.assign(a,n.headers);let o=t(c)||l,u=e.id;return{client:new s({endpoint:i.replace(/\/+$/,``),apiKey:r,deployment:u,apiVersion:o,dangerouslyAllowBrowser:!0,defaultHeaders:a}),deployment:u}}function v(e,t){return[...e.systemPrompt?[{role:`system`,content:e.systemPrompt}]:[],...f(e,t)]}function y(e,t,n){n&&(e.usage.input=n.prompt_tokens??0,e.usage.output=n.completion_tokens??0,e.usage.totalTokens=n.total_tokens??0,r(t,e.usage))}function b(e){return e===`tool_calls`?`toolUse`:e===`length`?`length`:`stop`}function x(e,t,n){let{block:r,index:i}=m(t);r.text===``&&e.push({type:`text_start`,contentIndex:i,partial:t}),r.text+=n,e.push({type:`text_delta`,contentIndex:i,delta:n,partial:t})}function S(e,t,n){let r=n.id?h(t,n.id):void 0;if(r||!n.id)return r;let i={type:`toolCall`,id:n.id,name:n.function?.name??``,arguments:{},_partialJson:``};return t.content.push(i),e.push({type:`toolcall_start`,contentIndex:t.content.length-1,partial:t}),i}function C(e,t,n,r){n._partialJson+=r;try{n.arguments=JSON.parse(n._partialJson)}catch{}e.push({type:`toolcall_delta`,contentIndex:t.content.indexOf(n),delta:r,partial:t})}function w(e,t,n){for(let r of n){let n=S(e,t,r);n&&r.function?.arguments&&C(e,t,n,r.function.arguments)}}function T(e,t,n){let r=n.delta;r&&(r.content&&x(e,t,r.content),r.tool_calls&&w(e,t,r.tool_calls),n.finish_reason&&(t.stopReason=b(n.finish_reason)))}function E(e,t,n,r){try{n.arguments=JSON.parse(n._partialJson||`{}`)}catch{}delete n._partialJson,e.push({type:`toolcall_end`,contentIndex:r,toolCall:n,partial:t})}function D(e,t){for(let n=0;n<t.content.length;n+=1){let r=t.content[n];r.type===`toolCall`?E(e,t,r,n):r.type===`text`&&e.push({type:`text_end`,contentIndex:n,content:r.text,partial:t})}}async function O(e,t,n,r,i){let{client:a,deployment:o}=_(n,i),s=p(r.tools),c=await a.chat.completions.create({model:o,messages:v(r,n),stream:!0,stream_options:{include_usage:!0},...i.maxTokens?{max_completion_tokens:i.maxTokens}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...s?{tools:s}:{}});e.push({type:`start`,partial:t});for await(let r of c){y(t,n,r.usage);for(let n of r.choices??[])T(e,t,n)}D(e,t),e.push({type:`done`,reason:t.stopReason,message:t}),e.end()}function k(e,t,n,r){t.stopReason=r?`aborted`:`error`,t.errorMessage=n instanceof Error?n.message:JSON.stringify(n),e.push({type:`error`,reason:t.stopReason,error:t}),e.end()}const A=(e,t,r={})=>{let i=n(),a=g(e);return O(i,a,e,t,r).catch(e=>{k(i,a,e,!!r.signal?.aborted)}),i},j=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`Azure API key is required`);let a=i(e,n,r);return A(e,t,{...a})};function M(){o({api:`azure-openai-anthropic`,stream:A,streamSimple:j})}export{u as config,M as register};
@@ -1 +1 @@
1
- import{n as e}from"./event-stream-qbAZIAKV.js";import{a as t}from"./compat-Spvv5tCW.js";import{h as n}from"./account-store-ffzft8RA.js";import{r,s as i}from"./legacy-api-aliases-CRTuRAqQ.js";var a=`cerebras`,o=`https://api.cerebras.ai/v1`,s=`openai-completions`,c=`${a}-openai`,l=`slicc-cerebras-models`,u=[],d=[{id:`gpt-oss-120b`,name:`GPT OSS 120B`,api:`openai`,reasoning:!0,input:[`text`],context_window:131072,max_tokens:40960},{id:`gemma-4-31b`,name:`Gemma 4 31B`,api:`openai`,reasoning:!1,input:[`text`,`image`],context_window:131072,max_tokens:40960},{id:`zai-glm-4.7`,name:`Z.AI GLM-4.7`,api:`openai`,reasoning:!1,input:[`text`],context_window:131072,max_tokens:40960}];function f(e){try{localStorage.setItem(l,JSON.stringify(e))}catch{}}function p(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function m(e){let t=e.id??``,n=d.find(e=>e.id===t);return{id:t,name:e.name??n?.name??t,api:`openai`,reasoning:e.capabilities?.reasoning??n?.reasoning??!1,input:e.capabilities?.vision?[`text`,`image`]:n?.input??[`text`],context_window:e.limits?.max_context_length??n?.context_window??8192,max_tokens:e.limits?.max_completion_tokens??n?.max_tokens??4096}}async function h(e){let t=await fetch(`${o}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(m).filter(e=>e.id.length>0);n.length>0&&(u=n,f(n))}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:c,provider:a,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 _=(t,n,i={})=>{let a=e();return(async()=>{try{let e=r({...t,baseUrl:o,api:s},n,i);for await(let t of e)a.push(t);a.end()}catch(e){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e)),a.push(g(t,e)),a.end()}})(),a},v=(t,n,r)=>{let a=e();return(async()=>{try{let e=i({...t,baseUrl:o,api:s},n,r);for await(let t of e)a.push(t);a.end()}catch(e){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e)),a.push(g(t,e)),a.end()}})(),a},y={id:a,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(u.length>0)return u;let e=p();return e.length>0?e:d},refreshModels:async e=>{let t=e??n(a)??``;if(t)try{await h(t)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function b(){t({api:c,stream:_,streamSimple:v})}export{y as config,b as register};
1
+ import{n as e}from"./event-stream-qbAZIAKV.js";import{a as t}from"./compat-Spvv5tCW.js";import{h as n}from"./account-store-1sWsdBXV.js";import{r,s as i}from"./legacy-api-aliases-CRTuRAqQ.js";var a=`cerebras`,o=`https://api.cerebras.ai/v1`,s=`openai-completions`,c=`${a}-openai`,l=`slicc-cerebras-models`,u=[],d=[{id:`gpt-oss-120b`,name:`GPT OSS 120B`,api:`openai`,reasoning:!0,input:[`text`],context_window:131072,max_tokens:40960},{id:`gemma-4-31b`,name:`Gemma 4 31B`,api:`openai`,reasoning:!1,input:[`text`,`image`],context_window:131072,max_tokens:40960},{id:`zai-glm-4.7`,name:`Z.AI GLM-4.7`,api:`openai`,reasoning:!1,input:[`text`],context_window:131072,max_tokens:40960}];function f(e){try{localStorage.setItem(l,JSON.stringify(e))}catch{}}function p(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function m(e){let t=e.id??``,n=d.find(e=>e.id===t);return{id:t,name:e.name??n?.name??t,api:`openai`,reasoning:e.capabilities?.reasoning??n?.reasoning??!1,input:e.capabilities?.vision?[`text`,`image`]:n?.input??[`text`],context_window:e.limits?.max_context_length??n?.context_window??8192,max_tokens:e.limits?.max_completion_tokens??n?.max_tokens??4096}}async function h(e){let t=await fetch(`${o}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(m).filter(e=>e.id.length>0);n.length>0&&(u=n,f(n))}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:c,provider:a,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 _=(t,n,i={})=>{let a=e();return(async()=>{try{let e=r({...t,baseUrl:o,api:s},n,i);for await(let t of e)a.push(t);a.end()}catch(e){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e)),a.push(g(t,e)),a.end()}})(),a},v=(t,n,r)=>{let a=e();return(async()=>{try{let e=i({...t,baseUrl:o,api:s},n,r);for await(let t of e)a.push(t);a.end()}catch(e){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e)),a.push(g(t,e)),a.end()}})(),a},y={id:a,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(u.length>0)return u;let e=p();return e.length>0?e:d},refreshModels:async e=>{let t=e??n(a)??``;if(t)try{await h(t)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function b(){t({api:c,stream:_,streamSimple:v})}export{y as config,b as register};
@@ -1 +1 @@
1
- import{h as e}from"./account-store-FTgVysIG.js";import{n as t}from"./event-stream-qbAZIAKV.js";import{p as n}from"./bedrock-camp-D_7EbOFH.js";import{r,s as i}from"./legacy-api-aliases-CdGTJw-r.js";const a=`cerebras`,o=`https://api.cerebras.ai/v1`,s=`openai-completions`,c=`${a}-openai`,l=`slicc-cerebras-models`;let u=[];const d=[{id:`gpt-oss-120b`,name:`GPT OSS 120B`,api:`openai`,reasoning:!0,input:[`text`],context_window:131072,max_tokens:40960},{id:`gemma-4-31b`,name:`Gemma 4 31B`,api:`openai`,reasoning:!1,input:[`text`,`image`],context_window:131072,max_tokens:40960},{id:`zai-glm-4.7`,name:`Z.AI GLM-4.7`,api:`openai`,reasoning:!1,input:[`text`],context_window:131072,max_tokens:40960}];function f(e){try{localStorage.setItem(l,JSON.stringify(e))}catch{}}function p(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function m(e){let t=e.id??``,n=d.find(e=>e.id===t);return{id:t,name:e.name??n?.name??t,api:`openai`,reasoning:e.capabilities?.reasoning??n?.reasoning??!1,input:e.capabilities?.vision?[`text`,`image`]:n?.input??[`text`],context_window:e.limits?.max_context_length??n?.context_window??8192,max_tokens:e.limits?.max_completion_tokens??n?.max_tokens??4096}}async function h(e){let t=await fetch(`${o}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(m).filter(e=>e.id.length>0);n.length>0&&(u=n,f(n))}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:c,provider:a,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 _=(e,n,i={})=>{let a=t();return(async()=>{try{let t=r({...e,baseUrl:o,api:s},n,i);for await(let e of t)a.push(e);a.end()}catch(t){console.error(`[cerebras] Stream error:`,t instanceof Error?t.message:String(t)),a.push(g(e,t)),a.end()}})(),a},v=(e,n,r)=>{let a=t();return(async()=>{try{let t=i({...e,baseUrl:o,api:s},n,r);for await(let e of t)a.push(e);a.end()}catch(t){console.error(`[cerebras] Stream error:`,t instanceof Error?t.message:String(t)),a.push(g(e,t)),a.end()}})(),a},y={id:a,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(u.length>0)return u;let e=p();return e.length>0?e:d},refreshModels:async t=>{let n=t??e(a)??``;if(n)try{await h(n)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function b(){n({api:c,stream:_,streamSimple:v})}export{y as config,b as register};
1
+ import{h as e}from"./account-store-DWKDZbQl.js";import{n as t}from"./event-stream-qbAZIAKV.js";import{p as n}from"./bedrock-camp-D_7EbOFH.js";import{r,s as i}from"./legacy-api-aliases-CdGTJw-r.js";const a=`cerebras`,o=`https://api.cerebras.ai/v1`,s=`openai-completions`,c=`${a}-openai`,l=`slicc-cerebras-models`;let u=[];const d=[{id:`gpt-oss-120b`,name:`GPT OSS 120B`,api:`openai`,reasoning:!0,input:[`text`],context_window:131072,max_tokens:40960},{id:`gemma-4-31b`,name:`Gemma 4 31B`,api:`openai`,reasoning:!1,input:[`text`,`image`],context_window:131072,max_tokens:40960},{id:`zai-glm-4.7`,name:`Z.AI GLM-4.7`,api:`openai`,reasoning:!1,input:[`text`],context_window:131072,max_tokens:40960}];function f(e){try{localStorage.setItem(l,JSON.stringify(e))}catch{}}function p(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function m(e){let t=e.id??``,n=d.find(e=>e.id===t);return{id:t,name:e.name??n?.name??t,api:`openai`,reasoning:e.capabilities?.reasoning??n?.reasoning??!1,input:e.capabilities?.vision?[`text`,`image`]:n?.input??[`text`],context_window:e.limits?.max_context_length??n?.context_window??8192,max_tokens:e.limits?.max_completion_tokens??n?.max_tokens??4096}}async function h(e){let t=await fetch(`${o}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(m).filter(e=>e.id.length>0);n.length>0&&(u=n,f(n))}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:c,provider:a,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 _=(e,n,i={})=>{let a=t();return(async()=>{try{let t=r({...e,baseUrl:o,api:s},n,i);for await(let e of t)a.push(e);a.end()}catch(t){console.error(`[cerebras] Stream error:`,t instanceof Error?t.message:String(t)),a.push(g(e,t)),a.end()}})(),a},v=(e,n,r)=>{let a=t();return(async()=>{try{let t=i({...e,baseUrl:o,api:s},n,r);for await(let e of t)a.push(e);a.end()}catch(t){console.error(`[cerebras] Stream error:`,t instanceof Error?t.message:String(t)),a.push(g(e,t)),a.end()}})(),a},y={id:a,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(u.length>0)return u;let e=p();return e.length>0?e:d},refreshModels:async t=>{let n=t??e(a)??``;if(n)try{await h(n)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function b(){n({api:c,stream:_,streamSimple:v})}export{y as config,b as register};
@@ -1,4 +1,4 @@
1
- import{C as e,P as t,d as n,f as r}from"./account-store-ffzft8RA.js";import{n as i}from"./provider-settings-BSR3nkqj.js";var a=`slicc_cloud_model_catalog`,o=`adobe`;function s(t){if(t===o)return!1;let n=e(t);return!(n.hidden||n.onOAuthLoginIntercepted)}function c(){try{let e=r().map(e=>({providerId:e.providerId,providerName:e.providerName,models:e.models.map(e=>({id:e.id,name:e.name}))}));localStorage.setItem(a,JSON.stringify(e))}catch{}}async function l(r){for(;r.firstChild;)r.removeChild(r.firstChild);r.className=`connect-surface`;let a=document.createElement(`h1`);a.className=`connect-surface__title`,a.textContent=`Connect providers`,r.appendChild(a);let l=document.createElement(`p`);l.className=`connect-surface__desc`,l.textContent=`Log in or add API keys for the providers your cone should use, then click Done to return to the dashboard.`,r.appendChild(l);let u=document.createElement(`div`);u.className=`connect-surface__accounts`,r.appendChild(u);function d(){for(;u.firstChild;)u.removeChild(u.firstChild);let r=n().filter(e=>e.providerId!==o);if(r.length===0){let e=document.createElement(`div`);e.className=`connect-surface__empty`,e.textContent=`No providers connected yet.`,u.appendChild(e)}else{let n=document.createElement(`div`);n.className=`connect-surface__accounts-list`;for(let i of r){let r=e(i.providerId),a=document.createElement(`div`);a.className=`connect-surface__account-row`;let o=document.createElement(`div`);o.className=`connect-surface__account-info`;let s=document.createElement(`div`);s.className=`connect-surface__account-name`,s.textContent=r.name,o.appendChild(s);let l=document.createElement(`div`);l.className=`connect-surface__account-detail`,i.userName?l.textContent=i.userName:i.accessToken?l.textContent=`Logged in`:l.textContent=i.apiKey?`API key set`:`No credentials`,o.appendChild(l),a.appendChild(o);let u=document.createElement(`button`);u.className=`connect-surface__remove-btn`,u.textContent=`Remove`,u.onclick=async()=>{await t(i.providerId),c(),d()},a.appendChild(u),n.appendChild(a)}u.appendChild(n)}let a=document.createElement(`button`);a.className=`connect-surface__add-btn`,a.textContent=r.length===0?`Add provider`:`Manage providers`,a.onclick=async()=>{await i({startInAddAccount:!0,providerFilter:s})&&(c(),d())},u.appendChild(a)}d(),c();let f=document.createElement(`div`);f.className=`connect-surface__footer`;let p=document.createElement(`button`);if(p.className=`connect-surface__done-btn`,p.textContent=`Done — return to dashboard`,p.onclick=()=>{c(),window.close()},f.appendChild(p),r.appendChild(f),!document.getElementById(`connect-surface-style`)){let e=document.createElement(`style`);e.id=`connect-surface-style`,e.textContent=`
1
+ import{C as e,P as t,d as n,f as r}from"./account-store-1sWsdBXV.js";import{n as i}from"./provider-settings-BQ_ViD6o.js";var a=`slicc_cloud_model_catalog`,o=`adobe`;function s(t){if(t===o)return!1;let n=e(t);return!(n.hidden||n.onOAuthLoginIntercepted)}function c(){try{let e=r().map(e=>({providerId:e.providerId,providerName:e.providerName,models:e.models.map(e=>({id:e.id,name:e.name}))}));localStorage.setItem(a,JSON.stringify(e))}catch{}}async function l(r){for(;r.firstChild;)r.removeChild(r.firstChild);r.className=`connect-surface`;let a=document.createElement(`h1`);a.className=`connect-surface__title`,a.textContent=`Connect providers`,r.appendChild(a);let l=document.createElement(`p`);l.className=`connect-surface__desc`,l.textContent=`Log in or add API keys for the providers your cone should use, then click Done to return to the dashboard.`,r.appendChild(l);let u=document.createElement(`div`);u.className=`connect-surface__accounts`,r.appendChild(u);function d(){for(;u.firstChild;)u.removeChild(u.firstChild);let r=n().filter(e=>e.providerId!==o);if(r.length===0){let e=document.createElement(`div`);e.className=`connect-surface__empty`,e.textContent=`No providers connected yet.`,u.appendChild(e)}else{let n=document.createElement(`div`);n.className=`connect-surface__accounts-list`;for(let i of r){let r=e(i.providerId),a=document.createElement(`div`);a.className=`connect-surface__account-row`;let o=document.createElement(`div`);o.className=`connect-surface__account-info`;let s=document.createElement(`div`);s.className=`connect-surface__account-name`,s.textContent=r.name,o.appendChild(s);let l=document.createElement(`div`);l.className=`connect-surface__account-detail`,i.userName?l.textContent=i.userName:i.accessToken?l.textContent=`Logged in`:l.textContent=i.apiKey?`API key set`:`No credentials`,o.appendChild(l),a.appendChild(o);let u=document.createElement(`button`);u.className=`connect-surface__remove-btn`,u.textContent=`Remove`,u.onclick=async()=>{await t(i.providerId),c(),d()},a.appendChild(u),n.appendChild(a)}u.appendChild(n)}let a=document.createElement(`button`);a.className=`connect-surface__add-btn`,a.textContent=r.length===0?`Add provider`:`Manage providers`,a.onclick=async()=>{await i({startInAddAccount:!0,providerFilter:s})&&(c(),d())},u.appendChild(a)}d(),c();let f=document.createElement(`div`);f.className=`connect-surface__footer`;let p=document.createElement(`button`);if(p.className=`connect-surface__done-btn`,p.textContent=`Done — return to dashboard`,p.onclick=()=>{c(),window.close()},f.appendChild(p),r.appendChild(f),!document.getElementById(`connect-surface-style`)){let e=document.createElement(`style`);e.id=`connect-surface-style`,e.textContent=`
2
2
  .connect-surface {
3
3
  padding: 2rem;
4
4
  max-width: 560px;
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-0FRaZO2z.js","assets/rolldown-runtime-aKtaBQYM.js","assets/dist-Bj10RLrf.js","assets/mount-A3Op_5rE.js","assets/preload-helper-Czpn1I53.js","assets/mime-types-ugOWOUZ9.js","assets/base64-DpPqYZJF.js","assets/src-CS5gSDhT.js","assets/proxied-fetch-D5h5REZy.js","assets/runtime-env-DH4NDw4t.js","assets/fetch-body-D2PwksUW.js","assets/types-idfTVsM8.js","assets/backend-local-smcj-_Ox.js","assets/tool-ui-DfXu6quJ.js","assets/logger-DDBAeTLF.js","assets/picker-approval-CdWaB1mR.js","assets/mount-picker-popup-Bs1o43Z5.js","assets/picker-popup-BvzmBsGL.js","assets/mount-table-store-CfQUN_2R.js","assets/mount-bridge-client-DHGevTQu.js","assets/port-bridge-client-CoFZLSYm.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-Czpn1I53.js";import{t}from"./logger-DDBAeTLF.js";import{t as n}from"./types-idfTVsM8.js";import{t as r}from"./backend-local-smcj-_Ox.js";import{a as i,i as a,n as o,t as s}from"./mount-table-store-CfQUN_2R.js";var c=t(`fs-watcher`),l=0;function u(e,t){return t===`/`||e===t||e.startsWith(t+`/`)}var d=class{registrations=new Map;watch(e,t,n){let r=`fsw-${++l}`;return this.registrations.set(r,{id:r,basePath:e,filter:t,callback:n}),c.debug(`Watch registered`,{id:r,basePath:e}),()=>{this.registrations.delete(r),c.debug(`Watch unregistered`,{id:r})}}notify(e){if(e.length!==0)for(let[,t]of this.registrations){let n=e.filter(e=>u(e.path,t.basePath)&&t.filter(e.path));if(n.length>0)try{t.callback(n)}catch(e){c.error(`Watch callback error`,{id:t.id,error:e instanceof Error?e.message:String(e)})}}}dispose(){this.registrations.clear(),c.debug(`All watchers disposed`)}get size(){return this.registrations.size}},f=t(`mount-index`),p=400,m=2e6,h=`SLICC_MOUNT_INDEX_MAX_DEPTH`,g=`SLICC_MOUNT_INDEX_MAX_ENTRIES`,_=256,v=class extends Error{cause;constructor(e,t){super(e),this.name=`MountIndexAbortError`,this.cause=t}};function y(e){let t=e.map(([e,t])=>`${e}\u0000${t.kind}`).sort(),n=t.length>_?t.slice(0,_):t;return`${t.length}\u0001${n.join(``)}`}async function b(e,t){let n=e.isSameEntry;if(typeof n!=`function`)return!1;try{return await n.call(e,t)}catch{return!1}}function x(e,t){return e instanceof Map?e.get(t):e[t]}function S(e){let t=e.trim();if(t===``)return;let n=Number(t);if(!(!Number.isInteger(n)||n<=0))return n}function C(e,t,n){let r=x(e,t);if(r===void 0||r.trim()===``)return n;let i=S(r);return i===void 0?(f.warn(`Ignoring invalid ${t}; expected a positive integer, using default`,{value:r,fallback:n}),n):i}function w(e){return{maxDepth:C(e,h,p),maxEntries:C(e,g,m)}}var T=class{mounts=new Map;listeners=new Set;registerMount(e,t,n=w({})){this.mounts.get(e)?.abortController?.abort();let r=new AbortController,i={handle:t,state:{status:`pending`,indexed:0},files:new Set,directories:new Set,abortController:r,limits:n};this.mounts.set(e,i),this.notifyListeners(),this.indexMount(e,i,r.signal)}unregisterMount(e){let t=this.mounts.get(e);t&&(t.abortController?.abort(),this.mounts.delete(e),this.notifyListeners())}async refreshMount(e,t){let n=this.mounts.get(e);if(!n)throw Error(`No mount at ${e}`);n.abortController?.abort();let r=new AbortController;n.abortController=r,n.state={status:`pending`,indexed:0},n.files.clear(),n.directories.clear(),t&&(n.limits=t),this.notifyListeners(),await this.indexMount(e,n,r.signal)}isReady(e){return this.mounts.get(e)?.state.status===`ready`}isAnyIndexing(){for(let e of this.mounts.values())if(e.state.status===`indexing`||e.state.status===`pending`)return!0;return!1}dispose(){for(let e of this.mounts.values())e.abortController?.abort();this.mounts.clear(),this.listeners.clear()}getState(e){return this.mounts.get(e)?.state}getFiles(e,t){let n=this.mounts.get(e);if(n?.state.status!==`ready`)return;if(!t)return[...n.files];let r=[];for(let e of n.files)t(e)&&r.push(e);return r}getDirectoryEntries(e,t){let n=this.mounts.get(e);if(n?.state.status!==`ready`)return;let r=t===`/`?`/`:t+`/`,i=new Map;for(let e of n.files){if(!e.startsWith(r))continue;let t=e.slice(r.length);t.includes(`/`)||i.set(t,`file`)}for(let e of n.directories){if(!e.startsWith(r))continue;let t=e.slice(r.length);t.includes(`/`)||i.set(t,`directory`)}return[...i.entries()].map(([e,t])=>({name:e,type:t}))}hasPath(e,t){let n=this.mounts.get(e);if(n?.state.status===`ready`)return n.files.has(t)||n.directories.has(t)}notifyWrite(e){let t=this.findMountForPath(e);if(!t)return;let n=this.mounts.get(t);if(n?.state.status!==`ready`)return;n.files.add(e);let r=e;for(;r!==t;){let e=r.lastIndexOf(`/`);if(e<=0)break;r=r.slice(0,e)||`/`,r.length>=t.length&&n.directories.add(r)}}notifyDelete(e){let t=this.findMountForPath(e);if(!t)return;let n=this.mounts.get(t);if(n?.state.status!==`ready`)return;n.files.delete(e),n.directories.delete(e);let r=e+`/`;for(let e of n.files)e.startsWith(r)&&n.files.delete(e);for(let e of n.directories)e.startsWith(r)&&n.directories.delete(e)}notifyRename(e,t){let n=this.findMountForPath(e);if(!n)return;let r=this.mounts.get(n);if(r?.state.status===`ready`){if(r.files.has(e)){r.files.delete(e),r.files.add(t);return}if(r.directories.has(e)){r.directories.delete(e),r.directories.add(t);let n=e+`/`,i=t+`/`;for(let e of[...r.files])e.startsWith(n)&&(r.files.delete(e),r.files.add(i+e.slice(n.length)));for(let e of[...r.directories])e.startsWith(n)&&(r.directories.delete(e),r.directories.add(i+e.slice(n.length)))}}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}findMountForPath(e){let t;for(let n of this.mounts.keys())(e===n||e.startsWith(n+`/`))&&(!t||n.length>t.length)&&(t=n);return t}notifyListeners(){for(let e of this.listeners)try{e()}catch{}}async indexMount(e,t,n){t.state={status:`indexing`,indexed:0},this.notifyListeners();try{if(await this.walkHandle(e,t.handle,t,n),n.aborted)return;t.state={status:`ready`,indexed:t.files.size+t.directories.size,total:t.files.size+t.directories.size},t.abortController=null,f.info(`Mount indexed`,{path:e,files:t.files.size,directories:t.directories.size})}catch(r){if(n.aborted)return;let i=r instanceof Error?r.message:String(r),a=r instanceof v?r.cause:`indexing-error`;t.state={status:`error`,indexed:0,error:i,abortCause:a},f.error(`Mount indexing failed`,{path:e,error:i,abortCause:a})}this.notifyListeners()}async walkHandle(e,t,n,r,i=0,a=new Map){if(r.aborted)return;this.enforceWalkBounds(i,n),n.directories.add(e);let o=await this.readChildren(t,r,n);if(r.aborted)return;let s=await this.confirmNoCycle(e,t,o,a),c=this.pushAncestor(a,s,e,t);try{await this.walkChildren(e,o,n,r,i,a)}finally{this.popAncestor(a,s,c)}}enforceWalkBounds(e,t){if(e>t.limits.maxDepth)throw new v(`mount indexing aborted: directory nesting exceeded ${t.limits.maxDepth} levels`,`depth-exceeded`);if(t.directories.size+t.files.size>=t.limits.maxEntries)throw new v(`mount indexing aborted: exceeded ${t.limits.maxEntries} entries`,`entries-exceeded`)}async readChildren(e,t,n){let r=e,i=[];for await(let e of r){if(t.aborted)break;if(n.directories.size+n.files.size+i.length>=n.limits.maxEntries)throw new v(`mount indexing aborted: exceeded ${n.limits.maxEntries} entries`,`entries-exceeded`);i.push(e)}return i}async confirmNoCycle(e,t,n,r){let i=y(n),a=r.get(i);if(a){for(let n of a)if(await b(n.handle,t))throw new v(`mount indexing aborted: self-referential mount cycle detected at ${e} (re-exposes ${n.path})`,`cycle-detected`)}return i}pushAncestor(e,t,n,r){let i=e.get(t);return i||(i=[],e.set(t,i)),i.push({path:n,handle:r,signature:t}),i}popAncestor(e,t,n){n.pop(),n.length===0&&e.delete(t)}async walkChildren(e,t,n,r,i,a){for(let[o,s]of t){if(r.aborted)return;let t=e===`/`?`/${o}`:`${e}/${o}`;s.kind===`file`?(n.files.add(t),n.state.indexed++):s.kind===`directory`&&await this.walkHandle(t,s,n,r,i+1,a),n.state.indexed%500==0&&(this.notifyListeners(),await new Promise(e=>setTimeout(e,0)))}}};function E(e){if(!e||e===`/`)return`/`;e.startsWith(`/`)||(e=`/`+e);let t=e.split(`/`),n=[];for(let e of t)e===``||e===`.`||(e===`..`?n.pop():n.push(e));return`/`+n.join(`/`)}function D(e){let t=E(e);if(t===`/`)return{dir:`/`,base:``};let n=t.lastIndexOf(`/`);return{dir:n===0?`/`:t.slice(0,n),base:t.slice(n+1)}}function O(e){let t=E(e);return t===`/`?[]:t.slice(1).split(`/`)}function k(...e){return E(e.join(`/`))}var A={"/dev/null":{stat:()=>({type:`file`,size:0,mtime:0,ctime:0}),read:e=>(e?.encoding??`utf-8`)===`utf-8`?``:new Uint8Array,readText:()=>``,write:()=>{}}},j=class{vfs;allowedPrefixes;readOnlyPrefixes;writeEnforcement;constructor(e,t,n=[],r=`hard`){this.vfs=e;let i=e=>{let t=E(e);return t.endsWith(`/`)?t:t+`/`};this.allowedPrefixes=t.map(i),this.readOnlyPrefixes=n.map(i),this.writeEnforcement=r}getAllPrefixes(){let e=this.vfs.listMounts().map(e=>e.endsWith(`/`)?e:e+`/`);return[...this.allowedPrefixes,...this.readOnlyPrefixes,...e]}isAllowed(e){let t=E(e);return this.getAllPrefixes().some(e=>t===e.slice(0,-1)||t.startsWith(e)||t===`/`||e.startsWith(t+`/`))}isAllowedStrict(e){let t=E(e);return this.getAllPrefixes().some(e=>t===e.slice(0,-1)||t.startsWith(e))}isWritable(e){let t=E(e);return this.allowedPrefixes.some(e=>t===e.slice(0,-1)||t.startsWith(e))}canWrite(e){return this.isWritable(e)}checkWrite(e){if(this.writeEnforcement!==`sudo-delegated`&&!this.isWritable(e))throw new n(`EACCES`,`permission denied`,E(e))}async resolveAndCheckRead(e){try{let t=await this.vfs.realpath(e);if(!this.isAllowedStrict(t))throw new n(`ENOENT`,`no such file or directory`,E(e));return t}catch(t){throw t instanceof n?t:new n(`ENOENT`,`no such file or directory`,E(e))}}async resolveAndCheckWrite(e){try{let t=await this.vfs.realpath(e);if(!this.isWritable(t)&&!this.isSymlinkEscapeAllowed(t))throw new n(`EACCES`,`permission denied`,E(e));return t}catch(t){throw t instanceof n?t:new n(`EACCES`,`permission denied`,E(e))}}isSymlinkEscapeAllowed(e){return!1}async checkParentRealpathEscape(e){let t=this.vfs.dirname(e),r=this.vfs.basename(e),i;try{i=await this.vfs.realpath(t)}catch(e){if(e instanceof n&&e.code===`EACCES`)throw e;return}let a=i+`/`+r;if(this.isWritable(a))return;let o=E(i)!==E(t);if(!(this.writeEnforcement===`sudo-delegated`&&!o))throw new n(`EACCES`,`permission denied`,E(e))}getUnderlyingFS(){return this.vfs}invalidatePaths(e){this.vfs.invalidatePaths(e)}isPathUnderMount(e){return this.vfs.isPathUnderMount(e)}async readFile(e,t){let r=A[E(e)];if(r)return r.read(t);if(!this.isAllowedStrict(e))throw new n(`ENOENT`,`no such file or directory`,E(e));let i=await this.resolveAndCheckRead(e);return this.vfs.readFile(i,t)}async readDir(e){if(!this.isAllowed(e))return[];let t=e;if(this.isAllowedStrict(e))try{t=await this.resolveAndCheckRead(e)}catch{return[]}let n=await this.vfs.readDir(t);if(!this.isAllowedStrict(e)){let t=E(e);return n.filter(e=>{let n=t===`/`?`/${e.name}`:`${t}/${e.name}`;return this.isAllowed(n)})}return n}async stat(e){let t=A[E(e)];if(t)return t.stat();if(!this.isAllowed(e))throw new n(`ENOENT`,`no such file or directory`,E(e));if(this.isAllowedStrict(e)){let t=await this.resolveAndCheckRead(e);return this.vfs.stat(t)}return this.vfs.stat(e)}scanPathForSymlinks(e,t){let n=E(e);if(n===`/`)return!1;let r=n.slice(1).split(`/`),i=t?r.length:r.length-1,a=``;for(let e=0;e<i;e++){a=a+`/`+r[e];let t=this.vfs.lstatSync(a);if(t===null)return null;if(t.type===`symlink`)return!0}return!1}statSync(e){let t=A[E(e)];return t?t.stat():!this.isAllowedStrict(e)||this.scanPathForSymlinks(e,!0)!==!1?null:this.vfs.statSync(e)}lstatSync(e){let t=A[E(e)];return t?t.stat():!this.isAllowed(e)||this.scanPathForSymlinks(e,!1)!==!1?null:this.vfs.lstatSync(e)}readDirSync(e){if(!this.isAllowed(e)||this.scanPathForSymlinks(e,!0)!==!1)return null;let t=this.vfs.readDirSync(e);if(t===null)return null;if(this.isAllowedStrict(e))return t;let n=E(e);return t.filter(e=>{let t=n===`/`?`/${e.name}`:`${n}/${e.name}`;return this.isAllowed(t)})}async realpath(e){let t;try{t=await this.vfs.realpath(e)}catch(t){throw t instanceof n?t:new n(`ENOENT`,`no such file or directory`,E(e))}if(!this.isAllowedStrict(t))throw new n(`ENOENT`,`no such file or directory`,E(e));return t}async exists(e){if(A[E(e)])return!0;if(!this.isAllowed(e))return!1;if(this.isAllowedStrict(e))try{await this.resolveAndCheckRead(e)}catch{return!1}return this.vfs.exists(e)}async readTextFile(e){let t=A[E(e)];if(t)return t.readText();if(!this.isAllowedStrict(e))throw new n(`ENOENT`,`no such file or directory`,E(e));let r=await this.resolveAndCheckRead(e);return this.vfs.readTextFile(r)}async*walk(e){if(!this.isAllowed(e))return;let t=e;if(this.isAllowedStrict(e))try{t=await this.resolveAndCheckRead(e)}catch{return}for await(let e of this.vfs.walk(t))this.isAllowed(e)&&(yield e)}async writeFile(e,t,r){let i=A[E(e)];if(i){i.write(t);return}this.checkWrite(e),await this.checkParentRealpathEscape(e);try{(await this.vfs.lstat(e)).type===`symlink`&&await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof n&&e.code===`EACCES`)throw e}return this.vfs.writeFile(e,t,r)}async mkdir(e,t){return this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mkdir(e,t)}async rm(e,t){this.checkWrite(e);try{(await this.vfs.lstat(e)).type===`symlink`||await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof n&&e.code===`EACCES`)throw e}return this.vfs.rm(e,t)}async rename(e,t){return this.checkWrite(e),this.checkWrite(t),await this.resolveAndCheckWrite(e),await this.checkParentRealpathEscape(t),this.vfs.rename(e,t)}async copyFile(e,t){if(!this.isAllowed(e))throw new n(`ENOENT`,`no such file or directory`,E(e));this.checkWrite(t);let r=await this.resolveAndCheckRead(e);await this.checkParentRealpathEscape(t);try{(await this.vfs.lstat(t)).type===`symlink`&&await this.resolveAndCheckWrite(t)}catch(e){if(e instanceof n&&e.code===`EACCES`)throw e}return this.vfs.copyFile(r,t)}async symlink(e,t){return this.checkWrite(t),await this.checkParentRealpathEscape(t),this.vfs.symlink(e,t)}async readlink(e){if(!this.isAllowedStrict(e))throw new n(`ENOENT`,`no such file or directory`,E(e));let t=await this.vfs.readlink(e),r;if(r=t.startsWith(`/`)?E(t):E(this.vfs.dirname(e)+`/`+t),!this.isAllowedStrict(r))throw new n(`ENOENT`,`no such file or directory`,E(e));return t}async lstat(e){let t=A[E(e)];if(t)return t.stat();if(!this.isAllowed(e))throw new n(`ENOENT`,`no such file or directory`,E(e));let r=E(e),i=this.vfs.dirname(r),a=this.vfs.basename(r),o;if(i===r)o=i;else try{o=await this.vfs.realpath(i)}catch{throw new n(`ENOENT`,`no such file or directory`,r)}let s=o===`/`?`/${a}`:`${o}/${a}`;if(!this.isAllowed(s))throw new n(`ENOENT`,`no such file or directory`,r);return this.vfs.lstat(s)}watch(e,t,r){if(!this.isAllowed(e))throw new n(`EACCES`,`permission denied`,E(e));let i=this.vfs.getWatcher();if(!i)throw new n(`EINVAL`,`no watcher configured`);return i.watch(E(e),t,r)}dirname(e){return this.vfs.dirname(e)}basename(e){return this.vfs.basename(e)}async mount(e,t,n){return this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mount(e,t,n)}async unmount(e){return this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.unmount(e)}listMounts(){return this.vfs.listMounts()}getMountIndex(){return this.vfs.getMountIndex()}async refreshMount(e,t){return this.checkWrite(e),this.vfs.refreshMount(e,t)}async dispose(){await this.vfs.dispose()}};function M(e,t){if(e instanceof n){let r=`${e.code}: `,i=e.message;throw i.startsWith(r)&&(i=i.slice(r.length)),e.path&&i.endsWith(` '${e.path}'`)&&(i=i.slice(0,i.length-` '${e.path}'`.length)),new n(e.code,i,t)}throw e}var N=[`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`EIO`];function P(e,t){if(e instanceof n)return e;let r=e?.code;if(typeof r==`string`){let i=r;if(N.includes(i))return new n(i,(e instanceof Error?e.message:String(e))||i,t)}let i=e instanceof Error?e.message:String(e);return i.includes(`ENOENT`)?new n(`ENOENT`,`no such file or directory`,t):i.includes(`EEXIST`)?new n(`EEXIST`,`file already exists`,t):i.includes(`ENOTDIR`)?new n(`ENOTDIR`,`not a directory`,t):i.includes(`EISDIR`)?new n(`EISDIR`,`is a directory`,t):i.includes(`ENOTEMPTY`)?new n(`ENOTEMPTY`,`directory not empty`,t):i.includes(`ELOOP`)?new n(`ELOOP`,`too many levels of symbolic links`,t):new n(`EINVAL`,i,t)}async function F(e,t,n,r){try{return await e.lstat(t)}catch(e){let t=P(e,r);if(t.code===`ENOENT`&&n)return null;throw t}}async function I(e,t,n){let r;try{r=await e.readlink(t)}catch(e){throw P(e,n)}return r.startsWith(`/`)?E(r):E(k(D(t).dir,r))}async function L(e,t,r,i,a,o){let s=t===`/`?`/${r}`:`${t}/${r}`;for(;;){let t=await F(e,s,i,a);if(t===null||!t.isSymbolicLink())return{resolved:s,hops:o};if(++o>10)throw new n(`ELOOP`,`too many symbolic links encountered`,a);s=await I(e,s,a)}}async function R(e,t,n){let r=E(n);if(t(r))return r;let i=r.split(`/`).filter(Boolean),a=`/`,o=0;for(let t=0;t<i.length;t++){let n=await L(e,a,i[t],t===i.length-1,r,o);a=n.resolved,o=n.hops}return a}async function z(e,t,n){return t(n)?n:R(e,t,n)}function B(e,t,n){return e.size===0||!e.has(n)||!t.isReady(n)?!1:!Array.from(e.keys()).some(e=>e!==n&&e.startsWith(n+`/`))}async function V(e,t){try{return await e(t)}catch{return t}}async function*H(e,t,n,r=0){let i=E(t);if(B(e.mountPoints,e.mountIndex,i)){let t=e.mountIndex.getFiles(i);if(t){for(let e of t)yield e;return}}let a=n??new Set;if(r>64||a.size>=1e5)return;let o=await V(t=>e.realpath(t),i);if(a.has(o))return;a.add(o);let s=await e.readDir(i);for(let t of s)yield*U(e,t,i===`/`?`/${t.name}`:`${i}/${t.name}`,a,r+1)}async function*U(e,t,n,r,i){if(t.type===`file`){yield n;return}if(t.type===`symlink`){yield*W(e,n,r,i);return}yield*H(e,n,r,i)}async function*W(e,t,n,r){try{let i=await e.stat(t);i.type===`file`?yield t:i.type===`directory`&&(yield*H(e,t,n,r))}catch{}}function G(){try{if(typeof globalThis.navigator?.storage?.getDirectory==`function`)return`opfs`}catch{}return`memory`}var K=class t{lfs;lfsSync;rawLfs=null;rawLfsSync=null;_ready;_readyResolved=!1;backend;mountPoints=new Map;opfsBackendFs=null;opfsHandle=null;mountRoot=``;internalMounts=new Set;watcher=null;dbName;mountSyncChannel=null;mountIndex=new T;_writeLock=Promise.resolve();constructor(e,n,r,i){if(this.dbName=e,this.backend=r===`opfs`?`opfs`:`memory`,this.lfs=this.makeDeferredLfs(),this.lfsSync=this.makeDeferredLfsSync(),this._ready=this.backend===`opfs`?t.initOpfsBackend(this,i,n===!0):t.initMemoryBackend(this,e,n===!0),this._ready.then(()=>{this._readyResolved=!0},()=>{}),typeof BroadcastChannel<`u`)try{this.mountSyncChannel=new BroadcastChannel(`vfs-mount-sync:${e}`),this.mountSyncChannel.onmessage=e=>{let{type:t,path:n,descriptor:r}=e.data??{};if(t===`mount`&&typeof n==`string`&&r)this.reconstructBackendFromDescriptor(r).then(e=>{this.mountPoints.set(n,e),e.kind===`local`&&this.mountIndex.registerMount(n,e.getHandle()),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}).catch(()=>{});else if(t===`unmount`&&typeof n==`string`){let e=this.mountPoints.get(n);this.mountPoints.delete(n),this.mountIndex.unregisterMount(n),e?.close(),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}}}catch{}}static async initOpfsBackend(n,r,i){let a=r??await t.acquireOpfsHandle(n.dbName,i);await t.seedOpfsMetadataSidecarIfMissing(a);let[o,{WebAccess:s}]=await Promise.all([e(()=>import(`./dist-0FRaZO2z.js`).then(e=>e.t),__vite__mapDeps([0,1])),e(()=>import(`./dist-Bj10RLrf.js`),__vite__mapDeps([2,0,1]))]);await t.ensureRootMount(o);let c=`/__opfs__/${n.dbName}`,l=t.opfsBackends.get(n.dbName);if(l&&i){try{o.umount(c)}catch{}t.opfsBackends.delete(n.dbName),l=void 0}if(!l){let e=await o.resolveMountConfig({backend:s,handle:a,metadata:`/.metadata.json`});try{o.mount(c,e)}catch{}l={backendFs:e,refs:0},t.opfsBackends.set(n.dbName,l)}l.refs+=1,n.opfsBackendFs=l.backendFs.index?l.backendFs:null,n.opfsHandle=a,n.mountRoot=c,n.rawLfs=o.promises,n.rawLfsSync=o}static async initMemoryBackend(n,r,i){let a=await e(()=>import(`./dist-0FRaZO2z.js`).then(e=>e.t),__vite__mapDeps([0,1]));await t.ensureRootMount(a);let o=`/__zenfs__/${r}`,s=t.memoryBackends.get(r);if(s&&i){try{a.umount(o)}catch{}t.memoryBackends.delete(r),s=void 0}s||(s={store:a.InMemory.create({label:r}),refs:0},t.memoryBackends.set(r,s)),s.refs+=1;try{a.mount(o,s.store)}catch{}n.mountRoot=o,n.rawLfs=a.promises,n.rawLfsSync=a,n.opfsBackendFs=null,n.opfsHandle=null}static rootMountReady=null;static memoryBackends=new Map;static opfsBackends=new Map;static async ensureRootMount(e){return t.rootMountReady||=(async()=>{await e.configureSingle({backend:e.InMemory,label:`__vfs_root__`})})(),t.rootMountReady}prefix(e){return this.mountRoot?e===`/`?this.mountRoot:this.mountRoot+e:e}unprefix(e){return!this.mountRoot||!e.startsWith(this.mountRoot)?e:e.slice(this.mountRoot.length)||`/`}makeDeferredLfs(){let e=e=>this.prefix(e),t=e=>this.unprefix(e),n=()=>{if(!this.rawLfs)throw Error(`VirtualFS used before init resolved`);return this.rawLfs};return{readFile:(t,r)=>this._readyResolved?n().readFile(e(t),r):this._ready.then(()=>n().readFile(e(t),r)),writeFile:(t,r,i)=>this._readyResolved?n().writeFile(e(t),r,i):this._ready.then(()=>n().writeFile(e(t),r,i)),readdir:t=>this._readyResolved?n().readdir(e(t)):this._ready.then(()=>n().readdir(e(t))),mkdir:(t,r)=>this._readyResolved?n().mkdir(e(t),r):this._ready.then(()=>n().mkdir(e(t),r)),rmdir:t=>this._readyResolved?n().rmdir(e(t)):this._ready.then(()=>n().rmdir(e(t))),unlink:t=>this._readyResolved?n().unlink(e(t)):this._ready.then(()=>n().unlink(e(t))),rename:(t,r)=>this._readyResolved?n().rename(e(t),e(r)):this._ready.then(()=>n().rename(e(t),e(r))),stat:t=>this._readyResolved?n().stat(e(t)):this._ready.then(()=>n().stat(e(t))),lstat:t=>this._readyResolved?n().lstat(e(t)):this._ready.then(()=>n().lstat(e(t))),symlink:(t,r)=>{let i=t.startsWith(`/`)?e(t):t;return this._readyResolved?n().symlink(i,e(r)):this._ready.then(()=>n().symlink(i,e(r)))},readlink:async r=>(this._readyResolved||await this._ready,t(await n().readlink(e(r)))),truncate:async(t,r)=>{this._readyResolved||await this._ready;let i=n();typeof i.truncate==`function`&&await i.truncate(e(t),r)},realpath:async r=>{this._readyResolved||await this._ready;let i=n();return typeof i.realpath==`function`?t(await i.realpath(e(r))):e(r)}}}makeDeferredLfsSync(){let e=e=>this.prefix(e),t=e=>this.unprefix(e);return{readdirSync:t=>{let n=this.rawLfsSync;return n?.readdirSync?n.readdirSync(e(t)):void 0},statSync:t=>{let n=this.rawLfsSync;return n?.statSync?n.statSync(e(t)):void 0},lstatSync:t=>{let n=this.rawLfsSync;return n?.lstatSync?n.lstatSync(e(t)):void 0},readlinkSync:n=>{let r=this.rawLfsSync;return r?.readlinkSync?t(r.readlinkSync(e(n))):void 0}}}static async seedOpfsMetadataSidecarIfMissing(e){let t=`.metadata.json`;try{await e.getFileHandle(t);return}catch(e){if(e?.name!==`NotFoundError`)throw e}let n=await(await e.getFileHandle(t,{create:!0})).createWritable(),r=JSON.stringify({version:1,maxSize:4294967295,entries:{}});await n.write(r),await n.close()}static async acquireOpfsHandle(e,t){let r=navigator.storage;if(!r?.getDirectory)throw new n(`EINVAL`,`OPFS is not available in this environment`);let i=await r.getDirectory();if(t)try{await i.removeEntry(e,{recursive:!0})}catch{}return i.getDirectoryHandle(e,{create:!0})}static _createSyncForTests(e){return new t(e)}static async create(e){let n=e?.dbName??`browser-fs`,r=e?.wipe===!0,i=e?.backend??G(),a=new t(n,r,i);return await a._ready,r&&await s().catch(()=>{}),a}async flush(){await this.writeOpfsMetadataSidecar()}async writeOpfsMetadataSidecar(){if(this.backend!==`opfs`)return;let e=this.opfsBackendFs,t=this.opfsHandle;if(!e||!t)return;let n=JSON.stringify(e.index.toJSON()),r=await(await t.getFileHandle(`.metadata.json`,{create:!0})).createWritable();await r.write(n),await r.close()}invalidatePaths(e){if(this.backend!==`opfs`||!this.opfsBackendFs)return;let t=this.opfsBackendFs;for(let n of e){let e=E(n);t.index.delete(e),t._handles?.delete(e)}}canWrite(e){return!0}setWatcher(e){this.watcher=e}getWatcher(){return this.watcher}async dispose(){if(this.mountSyncChannel?.close(),this.mountSyncChannel=null,this.watcher?.dispose(),this.watcher=null,this.mountIndex.dispose(),await this.writeOpfsMetadataSidecar(),this.mountRoot){let n=this.backend===`opfs`?t.opfsBackends:t.memoryBackends,r=n.get(this.dbName);if(r&&(--r.refs,r.refs<=0)){n.delete(this.dbName);try{(await e(()=>import(`./dist-0FRaZO2z.js`).then(e=>e.t),__vite__mapDeps([0,1]))).umount(this.mountRoot)}catch{}}}}readDirSync(e){let t=E(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.readdirSync!=`function`||typeof n.lstatSync!=`function`)return null;try{let e=n.readdirSync(t),r=[];for(let i of e){let e=t===`/`?`/${i}`:`${t}/${i}`;try{let t=n.lstatSync(e),a=t.isSymbolicLink()?`symlink`:t.isDirectory()?`directory`:`file`;r.push({name:i,type:a})}catch{}}return r}catch{return null}}statSync(e){let t=E(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.statSync!=`function`||typeof n.lstatSync!=`function`||typeof n.readlinkSync!=`function`)return null;let r=t;for(let e=0;e<=10;e++){let e;try{e=n.lstatSync(r)}catch{return null}if(!e.isSymbolicLink())return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs};let t;try{t=n.readlinkSync(r)}catch{return null}r=t.startsWith(`/`)?E(t):E(k(D(r).dir,t))}return null}lstatSync(e){let t=E(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.lstatSync!=`function`)return null;try{let e=n.lstatSync(t);if(e.isSymbolicLink()){let r=n.readlinkSync?n.readlinkSync(t):``;return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:r}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch{return null}}async mount(e,t,r){let a=E(e);if(this.mountPoints.has(a))throw new n(`EEXIST`,`mount point is already mounted`,a);try{if((await this.lstat(a)).type!==`directory`)throw new n(`ENOTDIR`,`mount point must be a directory`,a);if((await this.readDir(a)).length>0)throw new n(`ENOTEMPTY`,`mount point must be empty to avoid shadowing existing files`,a)}catch(e){if(!(e instanceof n)||e.code!==`ENOENT`)throw e}let{dir:o}=D(a);o!==`/`&&await this.mkdir(o,{recursive:!0});try{await this.lfs.mkdir(a)}catch{}if(this.mountPoints.set(a,t),t.kind===`local`){let e=w(r?.env??{});this.mountIndex.registerMount(a,t.getHandle(),e)}let s=t.kind===`local`?{kind:`local`,mountId:t.mountId,idbHandleKey:a}:t.kind===`s3`?{kind:`s3`,mountId:t.mountId,source:t.source,profile:t.profile??`default`}:{kind:`da`,mountId:t.mountId,source:t.source,profile:t.profile??`default`};try{this.mountSyncChannel?.postMessage({type:`mount`,path:a,descriptor:s})}catch{}this.watcher?.notify([{type:`modify`,path:a,entryType:`directory`}]);try{await i({targetPath:a,descriptor:s,createdAt:Date.now()},t.kind===`local`?t.getHandle():void 0)}catch{}}async unmount(e){let t=E(e),n=this.mountPoints.get(t);this.mountPoints.delete(t),this.mountIndex.unregisterMount(t);try{this.mountSyncChannel?.postMessage({type:`unmount`,path:t})}catch{}this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await n?.close();try{await a(t)}catch{}}async reconstructBackendFromDescriptor(t){switch(t.kind){case`local`:{let e=await o(t.idbHandleKey);if(!e)throw Error(`no handle stored for ${t.idbHandleKey}`);return r.fromHandle(e,{mountId:t.mountId})}case`s3`:{let{S3MountBackend:n,RemoteMountCache:r,makeSignedFetchS3:i}=await e(async()=>{let{S3MountBackend:e,RemoteMountCache:t,makeSignedFetchS3:n}=await import(`./mount-A3Op_5rE.js`);return{S3MountBackend:e,RemoteMountCache:t,makeSignedFetchS3:n}},__vite__mapDeps([3,4,5,6,7,8,1,9,10,11,12,13,14,15,16,17,18,19,20])),a=new r({mountId:t.mountId,ttlMs:3e4});return new n({source:t.source,profile:t.profile,cache:a,mountId:t.mountId,signedFetch:i(t.profile)})}case`da`:{let{DaMountBackend:n,RemoteMountCache:r,makeSignedFetchDa:i}=await e(async()=>{let{DaMountBackend:e,RemoteMountCache:t,makeSignedFetchDa:n}=await import(`./mount-A3Op_5rE.js`);return{DaMountBackend:e,RemoteMountCache:t,makeSignedFetchDa:n}},__vite__mapDeps([3,4,5,6,7,8,1,9,10,11,12,13,14,15,16,17,18,19,20])),a=new r({mountId:t.mountId,ttlMs:3e4});return new n({source:t.source,profile:t.profile,cache:a,mountId:t.mountId,signedFetch:i()})}}}listMounts(){let e=[];for(let t of this.mountPoints.keys())this.internalMounts.has(t)||e.push(t);return e}listInternalMounts(){return[...this.internalMounts]}listMountPoints(){let e=[];for(let[t,n]of this.mountPoints)this.internalMounts.has(t)||e.push({path:t,kind:n.kind});return e}async mountInternal(e,t){let r=E(e);if(this.mountPoints.has(r))throw new n(`EEXIST`,`mount point is already mounted`,r);let{dir:i}=D(r);i!==`/`&&await this.mkdir(i,{recursive:!0});try{await this.lfs.mkdir(r)}catch{}this.mountPoints.set(r,t),this.internalMounts.add(r),this.watcher?.notify([{type:`modify`,path:r,entryType:`directory`}])}async unmountInternal(e){let t=E(e);if(!this.internalMounts.has(t))throw new n(`ENOENT`,`not an internal mount point`,t);let r=this.mountPoints.get(t);this.mountPoints.delete(t),this.internalMounts.delete(t),this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await r?.close()}getMountIndex(){return this.mountIndex}async refreshMount(e,t){let r=E(e),i=this.mountPoints.get(r);if(!i)throw new n(`ENOENT`,`not a mount point`,r);let a=await i.refresh(t);return i.kind===`local`&&await this.mountIndex.refreshMount(r,w(t?.env??{})),a}isPathUnderMount(e){for(let t of this.mountPoints.keys())if(e===t||e.startsWith(t+`/`))return!0;return!1}findMount(e){let t=null;for(let[n,r]of this.mountPoints)(e===n||e.startsWith(n+`/`))&&(!t||n.length>t.mountPath.length)&&(t={mountPath:n,backend:r});return t?e===t.mountPath?{path:t.mountPath,backend:t.backend,relParts:[]}:{path:t.mountPath,backend:t.backend,relParts:e.slice(t.mountPath.length+1).split(`/`).filter(Boolean)}:null}async readFile(e,t){let r=E(e),i=this.findMount(r);if(i){if(i.relParts.length===0)throw new n(`EISDIR`,`is a directory`,r);let e=i.relParts.join(`/`);try{let n=await i.backend.readFile(e);return(t?.encoding??`utf-8`)===`utf-8`?new TextDecoder(`utf-8`).decode(n):n}catch(e){M(e,r)}}let a=await this.resolveSymlinks(r);try{return(t?.encoding??`utf-8`)===`utf-8`?await this.lfs.readFile(a,{encoding:`utf8`}):await this.lfs.readFile(a)}catch(e){throw P(e,r)}}async writeFile(e,t,r){let i=E(e),a=this.findMount(i);if(a){if(a.relParts.length===0)throw new n(`EISDIR`,`is a directory`,i);let e=a.relParts.join(`/`),r=!1;try{await this.stat(i),r=!0}catch{}let o=typeof t==`string`?new TextEncoder().encode(t):t instanceof Uint8Array?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t);try{await a.backend.writeFile(e,o)}catch(e){M(e,i)}this.watcher?.notify([{type:r?`modify`:`create`,path:i,entryType:`file`}]),this.mountIndex.notifyWrite(i);return}let o;try{o=await this.resolveSymlinks(i)}catch{o=i}let s=!1;try{await this.lfs.stat(o),s=!0}catch{}let{dir:c}=D(o);await this.withWriteLock(async()=>{c!==`/`&&await this.mkdirRecursiveUnlocked(c);let e=typeof t==`string`?new TextEncoder().encode(t).byteLength:(t instanceof Uint8Array,t.byteLength);try{await this.lfs.writeFile(o,t)}catch(e){if(c!==`/`&&e instanceof Error&&e.message.includes(`ENOENT`)){await this.mkdirRecursiveUnlocked(c);try{await this.lfs.writeFile(o,t)}catch(e){throw P(e,i)}}else throw P(e,i)}try{await this.lfs.truncate?.(o,e)}catch(e){throw P(e,i)}}),this.watcher?.notify([{type:s?`modify`:`create`,path:o,entryType:`file`}])}async readDir(e){let t=E(e),n=this.findMount(t);return n?this.readDirMounted(t,n):this.readDirLocal(t)}async readDirMounted(e,t){let n=this.mountIndex.getDirectoryEntries(t.path,e);if(n!==void 0){let t=new Map;for(let e of n)t.set(e.name,{name:e.name,type:e.type});return this.addNestedMountEntries(t,e),[...t.values()]}let r=t.relParts.join(`/`)||`/`,i;try{i=await t.backend.readDir(r)}catch(t){M(t,e)}let a=new Map;for(let e of i)a.set(e.name,{name:e.name,type:e.kind===`directory`?`directory`:`file`});return this.addNestedMountEntries(a,e),[...a.values()]}async readDirLocal(e){let t=await this.resolveSymlinks(e);try{let e=await this.lfs.readdir(t),n=[];for(let r of e){let e=await this.statDirEntry(t,r);e&&n.push(e)}return n}catch(t){throw P(t,e)}}async statDirEntry(e,t){let n=e===`/`?`/${t}`:`${e}/${t}`;try{let e=await this.lfs.lstat(n);return e.isSymbolicLink()?{name:t,type:`symlink`}:{name:t,type:e.isDirectory()?`directory`:`file`}}catch{return null}}addNestedMountEntries(e,t){let n=t===`/`?`/`:`${t}/`;for(let r of this.mountPoints.keys()){if(r===t||!r.startsWith(n))continue;let i=r.slice(n.length);!i||i.includes(`/`)||e.has(i)||e.set(i,{name:i,type:`directory`})}}async withWriteLock(e){let t,n=new Promise(e=>{t=e}),r=this._writeLock;this._writeLock=n,await r;try{return await e()}finally{t()}}async mkdirRecursiveUnlocked(e){let t=e.split(`/`).filter(Boolean),n=``;for(let e of t){n+=`/`+e;try{await this.lfs.mkdir(n)}catch(e){if(e instanceof Error&&!e.message.includes(`EEXIST`))throw P(e,n)}}}async mkdir(e,t){let n=E(e);if(n===`/`)return;let r=this.findMount(n);if(r){if(r.relParts.length===0)return;let e=r.relParts.join(`/`),t=await this.exists(n);try{await r.backend.mkdir(e)}catch(e){M(e,n)}t||this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}]);return}t?.recursive?await this.withWriteLock(()=>this.mkdirRecursiveUnlocked(n)):(await this.withWriteLock(async()=>{try{await this.lfs.mkdir(n)}catch(e){throw P(e,n)}}),this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}]))}async rm(e,t){let r=E(e),i=this.findMount(r);if(i){if(i.relParts.length===0)throw new n(`EINVAL`,`cannot remove a mount point — use unmount`,r);let e;try{e=(await this.stat(r)).type}catch{}let a=i.relParts.join(`/`);try{await i.backend.remove(a,{recursive:t?.recursive})}catch(e){M(e,r)}this.watcher?.notify([{type:`delete`,path:r,entryType:e}]),this.mountIndex.notifyDelete(r);return}try{let e=await this.lfs.lstat(r);await this.withWriteLock(async()=>{e.isSymbolicLink()?await this.lfs.unlink(r):e.isDirectory()?t?.recursive?await this.rmRecursiveUnlocked(r):await this.lfs.rmdir(r):await this.lfs.unlink(r),await this.writeOpfsMetadataSidecar()})}catch(e){throw P(e,r)}this.watcher?.notify([{type:`delete`,path:r}])}async rmRecursiveUnlocked(e){let t=await this.lfs.readdir(e);for(let n of t){let t=e===`/`?`/${n}`:`${e}/${n}`,r=await this.lfs.lstat(t);r.isSymbolicLink()?await this.lfs.unlink(t):r.isDirectory()?await this.rmRecursiveUnlocked(t):await this.lfs.unlink(t)}await this.lfs.rmdir(e)}async stat(e){let t=E(e),n=this.findMount(t);if(n){if(n.relParts.length===0)try{let e=await this.lfs.stat(t);return{type:`directory`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch{return{type:`directory`,size:0,mtime:Date.now(),ctime:Date.now()}}let e=n.relParts.join(`/`);try{let t=await n.backend.stat(e);return{type:t.kind===`directory`?`directory`:`file`,size:t.size,mtime:t.mtime,ctime:t.mtime}}catch(e){M(e,t)}}let r=await this.resolveSymlinks(t);try{let e=await this.lfs.stat(r);return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch(e){throw P(e,t)}}async exists(e){let t=E(e),n=this.findMount(t);if(n){if(n.relParts.length===0)return!0;try{return await this.stat(t),!0}catch{return!1}}try{return await this.stat(t),!0}catch{try{return await this.lfs.lstat(t),!0}catch{return!1}}}async rename(e,t){let n=E(e),r=E(t),i;try{i=(await this.lstat(n)).type}catch{}try{await this.lfs.rename(n,r)}catch(e){throw P(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:i},{type:`create`,path:r,entryType:i}]),this.mountIndex.notifyRename(n,r)}async readTextFile(e){return await this.readFile(e,{encoding:`utf-8`})}async*walk(e,t,n=0){yield*H({mountPoints:this.mountPoints,mountIndex:this.mountIndex,realpath:e=>this.realpath(e),readDir:e=>this.readDir(e),stat:e=>this.stat(e)},e,t,n)}async copyFile(e,t){if((await this.stat(e)).type===`directory`)throw new n(`EISDIR`,`is a directory`,e);let r=await this.readFile(e,{encoding:`binary`});await this.writeFile(t,r)}dirname(e){return D(E(e)).dir}basename(e){return D(E(e)).base}async symlink(e,t){let r=E(t);if(this.findMount(r))throw new n(`EINVAL`,`symlinks not supported on mounted filesystems`,r);let{dir:i}=D(r);await this.withWriteLock(async()=>{i!==`/`&&await this.mkdirRecursiveUnlocked(i);try{await this.lfs.symlink(e,r)}catch(t){if(i!==`/`&&t instanceof Error&&t.message.includes(`ENOENT`)){await this.mkdirRecursiveUnlocked(i);try{await this.lfs.symlink(e,r)}catch(e){throw P(e,r)}}else throw P(t,r)}await this.writeOpfsMetadataSidecar()}),this.watcher?.notify([{type:`create`,path:r,entryType:`symlink`}])}async readlink(e){let t=E(e);try{return await this.lfs.readlink(t)}catch(e){throw P(e,t)}}async lstat(e){let t=E(e);if(this.findMount(t))return this.stat(t);try{let e=await this.lfs.lstat(t);if(e.isSymbolicLink()){let n=await this.lfs.readlink(t);return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:n}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch(e){throw P(e,t)}}async realpath(e){return R(this.lfs,e=>this.findMount(e)!==null,e)}resolveSymlinks(e){return z(this.lfs,e=>this.findMount(e)!==null,e)}};export{n as FsError,d as FsWatcher,T as MountIndex,j as RestrictedFS,K as VirtualFS,k as joinPath,E as normalizePath,O as pathSegments,G as resolveVfsBackendFromEnv,D as splitPath};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-0FRaZO2z.js","assets/rolldown-runtime-aKtaBQYM.js","assets/dist-Bj10RLrf.js","assets/mount-C7OeghLh.js","assets/preload-helper-Czpn1I53.js","assets/mime-types-ugOWOUZ9.js","assets/base64-DpPqYZJF.js","assets/src-CS5gSDhT.js","assets/proxied-fetch-D5h5REZy.js","assets/runtime-env-DH4NDw4t.js","assets/fetch-body-D2PwksUW.js","assets/types-idfTVsM8.js","assets/backend-local-smcj-_Ox.js","assets/tool-ui-DfXu6quJ.js","assets/logger-DDBAeTLF.js","assets/picker-approval-CdWaB1mR.js","assets/mount-picker-popup-Bs1o43Z5.js","assets/picker-popup-BvzmBsGL.js","assets/mount-table-store-CfQUN_2R.js","assets/mount-bridge-client-DHGevTQu.js","assets/port-bridge-client-CoFZLSYm.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-Czpn1I53.js";import{t}from"./logger-DDBAeTLF.js";import{t as n}from"./types-idfTVsM8.js";import{t as r}from"./backend-local-smcj-_Ox.js";import{a as i,i as a,n as o,t as s}from"./mount-table-store-CfQUN_2R.js";var c=t(`fs-watcher`),l=0;function u(e,t){return t===`/`||e===t||e.startsWith(t+`/`)}var d=class{registrations=new Map;watch(e,t,n){let r=`fsw-${++l}`;return this.registrations.set(r,{id:r,basePath:e,filter:t,callback:n}),c.debug(`Watch registered`,{id:r,basePath:e}),()=>{this.registrations.delete(r),c.debug(`Watch unregistered`,{id:r})}}notify(e){if(e.length!==0)for(let[,t]of this.registrations){let n=e.filter(e=>u(e.path,t.basePath)&&t.filter(e.path));if(n.length>0)try{t.callback(n)}catch(e){c.error(`Watch callback error`,{id:t.id,error:e instanceof Error?e.message:String(e)})}}}dispose(){this.registrations.clear(),c.debug(`All watchers disposed`)}get size(){return this.registrations.size}},f=t(`mount-index`),p=400,m=2e6,h=`SLICC_MOUNT_INDEX_MAX_DEPTH`,g=`SLICC_MOUNT_INDEX_MAX_ENTRIES`,_=256,v=class extends Error{cause;constructor(e,t){super(e),this.name=`MountIndexAbortError`,this.cause=t}};function y(e){let t=e.map(([e,t])=>`${e}\u0000${t.kind}`).sort(),n=t.length>_?t.slice(0,_):t;return`${t.length}\u0001${n.join(``)}`}async function b(e,t){let n=e.isSameEntry;if(typeof n!=`function`)return!1;try{return await n.call(e,t)}catch{return!1}}function x(e,t){return e instanceof Map?e.get(t):e[t]}function S(e){let t=e.trim();if(t===``)return;let n=Number(t);if(!(!Number.isInteger(n)||n<=0))return n}function C(e,t,n){let r=x(e,t);if(r===void 0||r.trim()===``)return n;let i=S(r);return i===void 0?(f.warn(`Ignoring invalid ${t}; expected a positive integer, using default`,{value:r,fallback:n}),n):i}function w(e){return{maxDepth:C(e,h,p),maxEntries:C(e,g,m)}}var T=class{mounts=new Map;listeners=new Set;registerMount(e,t,n=w({})){this.mounts.get(e)?.abortController?.abort();let r=new AbortController,i={handle:t,state:{status:`pending`,indexed:0},files:new Set,directories:new Set,abortController:r,limits:n};this.mounts.set(e,i),this.notifyListeners(),this.indexMount(e,i,r.signal)}unregisterMount(e){let t=this.mounts.get(e);t&&(t.abortController?.abort(),this.mounts.delete(e),this.notifyListeners())}async refreshMount(e,t){let n=this.mounts.get(e);if(!n)throw Error(`No mount at ${e}`);n.abortController?.abort();let r=new AbortController;n.abortController=r,n.state={status:`pending`,indexed:0},n.files.clear(),n.directories.clear(),t&&(n.limits=t),this.notifyListeners(),await this.indexMount(e,n,r.signal)}isReady(e){return this.mounts.get(e)?.state.status===`ready`}isAnyIndexing(){for(let e of this.mounts.values())if(e.state.status===`indexing`||e.state.status===`pending`)return!0;return!1}dispose(){for(let e of this.mounts.values())e.abortController?.abort();this.mounts.clear(),this.listeners.clear()}getState(e){return this.mounts.get(e)?.state}getFiles(e,t){let n=this.mounts.get(e);if(n?.state.status!==`ready`)return;if(!t)return[...n.files];let r=[];for(let e of n.files)t(e)&&r.push(e);return r}getDirectoryEntries(e,t){let n=this.mounts.get(e);if(n?.state.status!==`ready`)return;let r=t===`/`?`/`:t+`/`,i=new Map;for(let e of n.files){if(!e.startsWith(r))continue;let t=e.slice(r.length);t.includes(`/`)||i.set(t,`file`)}for(let e of n.directories){if(!e.startsWith(r))continue;let t=e.slice(r.length);t.includes(`/`)||i.set(t,`directory`)}return[...i.entries()].map(([e,t])=>({name:e,type:t}))}hasPath(e,t){let n=this.mounts.get(e);if(n?.state.status===`ready`)return n.files.has(t)||n.directories.has(t)}notifyWrite(e){let t=this.findMountForPath(e);if(!t)return;let n=this.mounts.get(t);if(n?.state.status!==`ready`)return;n.files.add(e);let r=e;for(;r!==t;){let e=r.lastIndexOf(`/`);if(e<=0)break;r=r.slice(0,e)||`/`,r.length>=t.length&&n.directories.add(r)}}notifyDelete(e){let t=this.findMountForPath(e);if(!t)return;let n=this.mounts.get(t);if(n?.state.status!==`ready`)return;n.files.delete(e),n.directories.delete(e);let r=e+`/`;for(let e of n.files)e.startsWith(r)&&n.files.delete(e);for(let e of n.directories)e.startsWith(r)&&n.directories.delete(e)}notifyRename(e,t){let n=this.findMountForPath(e);if(!n)return;let r=this.mounts.get(n);if(r?.state.status===`ready`){if(r.files.has(e)){r.files.delete(e),r.files.add(t);return}if(r.directories.has(e)){r.directories.delete(e),r.directories.add(t);let n=e+`/`,i=t+`/`;for(let e of[...r.files])e.startsWith(n)&&(r.files.delete(e),r.files.add(i+e.slice(n.length)));for(let e of[...r.directories])e.startsWith(n)&&(r.directories.delete(e),r.directories.add(i+e.slice(n.length)))}}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}findMountForPath(e){let t;for(let n of this.mounts.keys())(e===n||e.startsWith(n+`/`))&&(!t||n.length>t.length)&&(t=n);return t}notifyListeners(){for(let e of this.listeners)try{e()}catch{}}async indexMount(e,t,n){t.state={status:`indexing`,indexed:0},this.notifyListeners();try{if(await this.walkHandle(e,t.handle,t,n),n.aborted)return;t.state={status:`ready`,indexed:t.files.size+t.directories.size,total:t.files.size+t.directories.size},t.abortController=null,f.info(`Mount indexed`,{path:e,files:t.files.size,directories:t.directories.size})}catch(r){if(n.aborted)return;let i=r instanceof Error?r.message:String(r),a=r instanceof v?r.cause:`indexing-error`;t.state={status:`error`,indexed:0,error:i,abortCause:a},f.error(`Mount indexing failed`,{path:e,error:i,abortCause:a})}this.notifyListeners()}async walkHandle(e,t,n,r,i=0,a=new Map){if(r.aborted)return;this.enforceWalkBounds(i,n),n.directories.add(e);let o=await this.readChildren(t,r,n);if(r.aborted)return;let s=await this.confirmNoCycle(e,t,o,a),c=this.pushAncestor(a,s,e,t);try{await this.walkChildren(e,o,n,r,i,a)}finally{this.popAncestor(a,s,c)}}enforceWalkBounds(e,t){if(e>t.limits.maxDepth)throw new v(`mount indexing aborted: directory nesting exceeded ${t.limits.maxDepth} levels`,`depth-exceeded`);if(t.directories.size+t.files.size>=t.limits.maxEntries)throw new v(`mount indexing aborted: exceeded ${t.limits.maxEntries} entries`,`entries-exceeded`)}async readChildren(e,t,n){let r=e,i=[];for await(let e of r){if(t.aborted)break;if(n.directories.size+n.files.size+i.length>=n.limits.maxEntries)throw new v(`mount indexing aborted: exceeded ${n.limits.maxEntries} entries`,`entries-exceeded`);i.push(e)}return i}async confirmNoCycle(e,t,n,r){let i=y(n),a=r.get(i);if(a){for(let n of a)if(await b(n.handle,t))throw new v(`mount indexing aborted: self-referential mount cycle detected at ${e} (re-exposes ${n.path})`,`cycle-detected`)}return i}pushAncestor(e,t,n,r){let i=e.get(t);return i||(i=[],e.set(t,i)),i.push({path:n,handle:r,signature:t}),i}popAncestor(e,t,n){n.pop(),n.length===0&&e.delete(t)}async walkChildren(e,t,n,r,i,a){for(let[o,s]of t){if(r.aborted)return;let t=e===`/`?`/${o}`:`${e}/${o}`;s.kind===`file`?(n.files.add(t),n.state.indexed++):s.kind===`directory`&&await this.walkHandle(t,s,n,r,i+1,a),n.state.indexed%500==0&&(this.notifyListeners(),await new Promise(e=>setTimeout(e,0)))}}};function E(e){if(!e||e===`/`)return`/`;e.startsWith(`/`)||(e=`/`+e);let t=e.split(`/`),n=[];for(let e of t)e===``||e===`.`||(e===`..`?n.pop():n.push(e));return`/`+n.join(`/`)}function D(e){let t=E(e);if(t===`/`)return{dir:`/`,base:``};let n=t.lastIndexOf(`/`);return{dir:n===0?`/`:t.slice(0,n),base:t.slice(n+1)}}function O(e){let t=E(e);return t===`/`?[]:t.slice(1).split(`/`)}function k(...e){return E(e.join(`/`))}var A={"/dev/null":{stat:()=>({type:`file`,size:0,mtime:0,ctime:0}),read:e=>(e?.encoding??`utf-8`)===`utf-8`?``:new Uint8Array,readText:()=>``,write:()=>{}}},j=class{vfs;allowedPrefixes;readOnlyPrefixes;writeEnforcement;constructor(e,t,n=[],r=`hard`){this.vfs=e;let i=e=>{let t=E(e);return t.endsWith(`/`)?t:t+`/`};this.allowedPrefixes=t.map(i),this.readOnlyPrefixes=n.map(i),this.writeEnforcement=r}getAllPrefixes(){let e=this.vfs.listMounts().map(e=>e.endsWith(`/`)?e:e+`/`);return[...this.allowedPrefixes,...this.readOnlyPrefixes,...e]}isAllowed(e){let t=E(e);return this.getAllPrefixes().some(e=>t===e.slice(0,-1)||t.startsWith(e)||t===`/`||e.startsWith(t+`/`))}isAllowedStrict(e){let t=E(e);return this.getAllPrefixes().some(e=>t===e.slice(0,-1)||t.startsWith(e))}isWritable(e){let t=E(e);return this.allowedPrefixes.some(e=>t===e.slice(0,-1)||t.startsWith(e))}canWrite(e){return this.isWritable(e)}checkWrite(e){if(this.writeEnforcement!==`sudo-delegated`&&!this.isWritable(e))throw new n(`EACCES`,`permission denied`,E(e))}async resolveAndCheckRead(e){try{let t=await this.vfs.realpath(e);if(!this.isAllowedStrict(t))throw new n(`ENOENT`,`no such file or directory`,E(e));return t}catch(t){throw t instanceof n?t:new n(`ENOENT`,`no such file or directory`,E(e))}}async resolveAndCheckWrite(e){try{let t=await this.vfs.realpath(e);if(!this.isWritable(t)&&!this.isSymlinkEscapeAllowed(t))throw new n(`EACCES`,`permission denied`,E(e));return t}catch(t){throw t instanceof n?t:new n(`EACCES`,`permission denied`,E(e))}}isSymlinkEscapeAllowed(e){return!1}async checkParentRealpathEscape(e){let t=this.vfs.dirname(e),r=this.vfs.basename(e),i;try{i=await this.vfs.realpath(t)}catch(e){if(e instanceof n&&e.code===`EACCES`)throw e;return}let a=i+`/`+r;if(this.isWritable(a))return;let o=E(i)!==E(t);if(!(this.writeEnforcement===`sudo-delegated`&&!o))throw new n(`EACCES`,`permission denied`,E(e))}getUnderlyingFS(){return this.vfs}invalidatePaths(e){this.vfs.invalidatePaths(e)}isPathUnderMount(e){return this.vfs.isPathUnderMount(e)}async readFile(e,t){let r=A[E(e)];if(r)return r.read(t);if(!this.isAllowedStrict(e))throw new n(`ENOENT`,`no such file or directory`,E(e));let i=await this.resolveAndCheckRead(e);return this.vfs.readFile(i,t)}async readDir(e){if(!this.isAllowed(e))return[];let t=e;if(this.isAllowedStrict(e))try{t=await this.resolveAndCheckRead(e)}catch{return[]}let n=await this.vfs.readDir(t);if(!this.isAllowedStrict(e)){let t=E(e);return n.filter(e=>{let n=t===`/`?`/${e.name}`:`${t}/${e.name}`;return this.isAllowed(n)})}return n}async stat(e){let t=A[E(e)];if(t)return t.stat();if(!this.isAllowed(e))throw new n(`ENOENT`,`no such file or directory`,E(e));if(this.isAllowedStrict(e)){let t=await this.resolveAndCheckRead(e);return this.vfs.stat(t)}return this.vfs.stat(e)}scanPathForSymlinks(e,t){let n=E(e);if(n===`/`)return!1;let r=n.slice(1).split(`/`),i=t?r.length:r.length-1,a=``;for(let e=0;e<i;e++){a=a+`/`+r[e];let t=this.vfs.lstatSync(a);if(t===null)return null;if(t.type===`symlink`)return!0}return!1}statSync(e){let t=A[E(e)];return t?t.stat():!this.isAllowedStrict(e)||this.scanPathForSymlinks(e,!0)!==!1?null:this.vfs.statSync(e)}lstatSync(e){let t=A[E(e)];return t?t.stat():!this.isAllowed(e)||this.scanPathForSymlinks(e,!1)!==!1?null:this.vfs.lstatSync(e)}readDirSync(e){if(!this.isAllowed(e)||this.scanPathForSymlinks(e,!0)!==!1)return null;let t=this.vfs.readDirSync(e);if(t===null)return null;if(this.isAllowedStrict(e))return t;let n=E(e);return t.filter(e=>{let t=n===`/`?`/${e.name}`:`${n}/${e.name}`;return this.isAllowed(t)})}async realpath(e){let t;try{t=await this.vfs.realpath(e)}catch(t){throw t instanceof n?t:new n(`ENOENT`,`no such file or directory`,E(e))}if(!this.isAllowedStrict(t))throw new n(`ENOENT`,`no such file or directory`,E(e));return t}async exists(e){if(A[E(e)])return!0;if(!this.isAllowed(e))return!1;if(this.isAllowedStrict(e))try{await this.resolveAndCheckRead(e)}catch{return!1}return this.vfs.exists(e)}async readTextFile(e){let t=A[E(e)];if(t)return t.readText();if(!this.isAllowedStrict(e))throw new n(`ENOENT`,`no such file or directory`,E(e));let r=await this.resolveAndCheckRead(e);return this.vfs.readTextFile(r)}async*walk(e){if(!this.isAllowed(e))return;let t=e;if(this.isAllowedStrict(e))try{t=await this.resolveAndCheckRead(e)}catch{return}for await(let e of this.vfs.walk(t))this.isAllowed(e)&&(yield e)}async writeFile(e,t,r){let i=A[E(e)];if(i){i.write(t);return}this.checkWrite(e),await this.checkParentRealpathEscape(e);try{(await this.vfs.lstat(e)).type===`symlink`&&await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof n&&e.code===`EACCES`)throw e}return this.vfs.writeFile(e,t,r)}async mkdir(e,t){return this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mkdir(e,t)}async rm(e,t){this.checkWrite(e);try{(await this.vfs.lstat(e)).type===`symlink`||await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof n&&e.code===`EACCES`)throw e}return this.vfs.rm(e,t)}async rename(e,t){return this.checkWrite(e),this.checkWrite(t),await this.resolveAndCheckWrite(e),await this.checkParentRealpathEscape(t),this.vfs.rename(e,t)}async copyFile(e,t){if(!this.isAllowed(e))throw new n(`ENOENT`,`no such file or directory`,E(e));this.checkWrite(t);let r=await this.resolveAndCheckRead(e);await this.checkParentRealpathEscape(t);try{(await this.vfs.lstat(t)).type===`symlink`&&await this.resolveAndCheckWrite(t)}catch(e){if(e instanceof n&&e.code===`EACCES`)throw e}return this.vfs.copyFile(r,t)}async symlink(e,t){return this.checkWrite(t),await this.checkParentRealpathEscape(t),this.vfs.symlink(e,t)}async readlink(e){if(!this.isAllowedStrict(e))throw new n(`ENOENT`,`no such file or directory`,E(e));let t=await this.vfs.readlink(e),r;if(r=t.startsWith(`/`)?E(t):E(this.vfs.dirname(e)+`/`+t),!this.isAllowedStrict(r))throw new n(`ENOENT`,`no such file or directory`,E(e));return t}async lstat(e){let t=A[E(e)];if(t)return t.stat();if(!this.isAllowed(e))throw new n(`ENOENT`,`no such file or directory`,E(e));let r=E(e),i=this.vfs.dirname(r),a=this.vfs.basename(r),o;if(i===r)o=i;else try{o=await this.vfs.realpath(i)}catch{throw new n(`ENOENT`,`no such file or directory`,r)}let s=o===`/`?`/${a}`:`${o}/${a}`;if(!this.isAllowed(s))throw new n(`ENOENT`,`no such file or directory`,r);return this.vfs.lstat(s)}watch(e,t,r){if(!this.isAllowed(e))throw new n(`EACCES`,`permission denied`,E(e));let i=this.vfs.getWatcher();if(!i)throw new n(`EINVAL`,`no watcher configured`);return i.watch(E(e),t,r)}dirname(e){return this.vfs.dirname(e)}basename(e){return this.vfs.basename(e)}async mount(e,t,n){return this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mount(e,t,n)}async unmount(e){return this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.unmount(e)}listMounts(){return this.vfs.listMounts()}getMountIndex(){return this.vfs.getMountIndex()}async refreshMount(e,t){return this.checkWrite(e),this.vfs.refreshMount(e,t)}async dispose(){await this.vfs.dispose()}};function M(e,t){if(e instanceof n){let r=`${e.code}: `,i=e.message;throw i.startsWith(r)&&(i=i.slice(r.length)),e.path&&i.endsWith(` '${e.path}'`)&&(i=i.slice(0,i.length-` '${e.path}'`.length)),new n(e.code,i,t)}throw e}var N=[`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`EIO`];function P(e,t){if(e instanceof n)return e;let r=e?.code;if(typeof r==`string`){let i=r;if(N.includes(i))return new n(i,(e instanceof Error?e.message:String(e))||i,t)}let i=e instanceof Error?e.message:String(e);return i.includes(`ENOENT`)?new n(`ENOENT`,`no such file or directory`,t):i.includes(`EEXIST`)?new n(`EEXIST`,`file already exists`,t):i.includes(`ENOTDIR`)?new n(`ENOTDIR`,`not a directory`,t):i.includes(`EISDIR`)?new n(`EISDIR`,`is a directory`,t):i.includes(`ENOTEMPTY`)?new n(`ENOTEMPTY`,`directory not empty`,t):i.includes(`ELOOP`)?new n(`ELOOP`,`too many levels of symbolic links`,t):new n(`EINVAL`,i,t)}async function F(e,t,n,r){try{return await e.lstat(t)}catch(e){let t=P(e,r);if(t.code===`ENOENT`&&n)return null;throw t}}async function I(e,t,n){let r;try{r=await e.readlink(t)}catch(e){throw P(e,n)}return r.startsWith(`/`)?E(r):E(k(D(t).dir,r))}async function L(e,t,r,i,a,o){let s=t===`/`?`/${r}`:`${t}/${r}`;for(;;){let t=await F(e,s,i,a);if(t===null||!t.isSymbolicLink())return{resolved:s,hops:o};if(++o>10)throw new n(`ELOOP`,`too many symbolic links encountered`,a);s=await I(e,s,a)}}async function R(e,t,n){let r=E(n);if(t(r))return r;let i=r.split(`/`).filter(Boolean),a=`/`,o=0;for(let t=0;t<i.length;t++){let n=await L(e,a,i[t],t===i.length-1,r,o);a=n.resolved,o=n.hops}return a}async function z(e,t,n){return t(n)?n:R(e,t,n)}function B(e,t,n){return e.size===0||!e.has(n)||!t.isReady(n)?!1:!Array.from(e.keys()).some(e=>e!==n&&e.startsWith(n+`/`))}async function V(e,t){try{return await e(t)}catch{return t}}async function*H(e,t,n,r=0){let i=E(t);if(B(e.mountPoints,e.mountIndex,i)){let t=e.mountIndex.getFiles(i);if(t){for(let e of t)yield e;return}}let a=n??new Set;if(r>64||a.size>=1e5)return;let o=await V(t=>e.realpath(t),i);if(a.has(o))return;a.add(o);let s=await e.readDir(i);for(let t of s)yield*U(e,t,i===`/`?`/${t.name}`:`${i}/${t.name}`,a,r+1)}async function*U(e,t,n,r,i){if(t.type===`file`){yield n;return}if(t.type===`symlink`){yield*W(e,n,r,i);return}yield*H(e,n,r,i)}async function*W(e,t,n,r){try{let i=await e.stat(t);i.type===`file`?yield t:i.type===`directory`&&(yield*H(e,t,n,r))}catch{}}function G(){try{if(typeof globalThis.navigator?.storage?.getDirectory==`function`)return`opfs`}catch{}return`memory`}var K=class t{lfs;lfsSync;rawLfs=null;rawLfsSync=null;_ready;_readyResolved=!1;backend;mountPoints=new Map;opfsBackendFs=null;opfsHandle=null;mountRoot=``;internalMounts=new Set;watcher=null;dbName;mountSyncChannel=null;mountIndex=new T;_writeLock=Promise.resolve();constructor(e,n,r,i){if(this.dbName=e,this.backend=r===`opfs`?`opfs`:`memory`,this.lfs=this.makeDeferredLfs(),this.lfsSync=this.makeDeferredLfsSync(),this._ready=this.backend===`opfs`?t.initOpfsBackend(this,i,n===!0):t.initMemoryBackend(this,e,n===!0),this._ready.then(()=>{this._readyResolved=!0},()=>{}),typeof BroadcastChannel<`u`)try{this.mountSyncChannel=new BroadcastChannel(`vfs-mount-sync:${e}`),this.mountSyncChannel.onmessage=e=>{let{type:t,path:n,descriptor:r}=e.data??{};if(t===`mount`&&typeof n==`string`&&r)this.reconstructBackendFromDescriptor(r).then(e=>{this.mountPoints.set(n,e),e.kind===`local`&&this.mountIndex.registerMount(n,e.getHandle()),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}).catch(()=>{});else if(t===`unmount`&&typeof n==`string`){let e=this.mountPoints.get(n);this.mountPoints.delete(n),this.mountIndex.unregisterMount(n),e?.close(),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}}}catch{}}static async initOpfsBackend(n,r,i){let a=r??await t.acquireOpfsHandle(n.dbName,i);await t.seedOpfsMetadataSidecarIfMissing(a);let[o,{WebAccess:s}]=await Promise.all([e(()=>import(`./dist-0FRaZO2z.js`).then(e=>e.t),__vite__mapDeps([0,1])),e(()=>import(`./dist-Bj10RLrf.js`),__vite__mapDeps([2,0,1]))]);await t.ensureRootMount(o);let c=`/__opfs__/${n.dbName}`,l=t.opfsBackends.get(n.dbName);if(l&&i){try{o.umount(c)}catch{}t.opfsBackends.delete(n.dbName),l=void 0}if(!l){let e=await o.resolveMountConfig({backend:s,handle:a,metadata:`/.metadata.json`});try{o.mount(c,e)}catch{}l={backendFs:e,refs:0},t.opfsBackends.set(n.dbName,l)}l.refs+=1,n.opfsBackendFs=l.backendFs.index?l.backendFs:null,n.opfsHandle=a,n.mountRoot=c,n.rawLfs=o.promises,n.rawLfsSync=o}static async initMemoryBackend(n,r,i){let a=await e(()=>import(`./dist-0FRaZO2z.js`).then(e=>e.t),__vite__mapDeps([0,1]));await t.ensureRootMount(a);let o=`/__zenfs__/${r}`,s=t.memoryBackends.get(r);if(s&&i){try{a.umount(o)}catch{}t.memoryBackends.delete(r),s=void 0}s||(s={store:a.InMemory.create({label:r}),refs:0},t.memoryBackends.set(r,s)),s.refs+=1;try{a.mount(o,s.store)}catch{}n.mountRoot=o,n.rawLfs=a.promises,n.rawLfsSync=a,n.opfsBackendFs=null,n.opfsHandle=null}static rootMountReady=null;static memoryBackends=new Map;static opfsBackends=new Map;static async ensureRootMount(e){return t.rootMountReady||=(async()=>{await e.configureSingle({backend:e.InMemory,label:`__vfs_root__`})})(),t.rootMountReady}prefix(e){return this.mountRoot?e===`/`?this.mountRoot:this.mountRoot+e:e}unprefix(e){return!this.mountRoot||!e.startsWith(this.mountRoot)?e:e.slice(this.mountRoot.length)||`/`}makeDeferredLfs(){let e=e=>this.prefix(e),t=e=>this.unprefix(e),n=()=>{if(!this.rawLfs)throw Error(`VirtualFS used before init resolved`);return this.rawLfs};return{readFile:(t,r)=>this._readyResolved?n().readFile(e(t),r):this._ready.then(()=>n().readFile(e(t),r)),writeFile:(t,r,i)=>this._readyResolved?n().writeFile(e(t),r,i):this._ready.then(()=>n().writeFile(e(t),r,i)),readdir:t=>this._readyResolved?n().readdir(e(t)):this._ready.then(()=>n().readdir(e(t))),mkdir:(t,r)=>this._readyResolved?n().mkdir(e(t),r):this._ready.then(()=>n().mkdir(e(t),r)),rmdir:t=>this._readyResolved?n().rmdir(e(t)):this._ready.then(()=>n().rmdir(e(t))),unlink:t=>this._readyResolved?n().unlink(e(t)):this._ready.then(()=>n().unlink(e(t))),rename:(t,r)=>this._readyResolved?n().rename(e(t),e(r)):this._ready.then(()=>n().rename(e(t),e(r))),stat:t=>this._readyResolved?n().stat(e(t)):this._ready.then(()=>n().stat(e(t))),lstat:t=>this._readyResolved?n().lstat(e(t)):this._ready.then(()=>n().lstat(e(t))),symlink:(t,r)=>{let i=t.startsWith(`/`)?e(t):t;return this._readyResolved?n().symlink(i,e(r)):this._ready.then(()=>n().symlink(i,e(r)))},readlink:async r=>(this._readyResolved||await this._ready,t(await n().readlink(e(r)))),truncate:async(t,r)=>{this._readyResolved||await this._ready;let i=n();typeof i.truncate==`function`&&await i.truncate(e(t),r)},realpath:async r=>{this._readyResolved||await this._ready;let i=n();return typeof i.realpath==`function`?t(await i.realpath(e(r))):e(r)}}}makeDeferredLfsSync(){let e=e=>this.prefix(e),t=e=>this.unprefix(e);return{readdirSync:t=>{let n=this.rawLfsSync;return n?.readdirSync?n.readdirSync(e(t)):void 0},statSync:t=>{let n=this.rawLfsSync;return n?.statSync?n.statSync(e(t)):void 0},lstatSync:t=>{let n=this.rawLfsSync;return n?.lstatSync?n.lstatSync(e(t)):void 0},readlinkSync:n=>{let r=this.rawLfsSync;return r?.readlinkSync?t(r.readlinkSync(e(n))):void 0}}}static async seedOpfsMetadataSidecarIfMissing(e){let t=`.metadata.json`;try{await e.getFileHandle(t);return}catch(e){if(e?.name!==`NotFoundError`)throw e}let n=await(await e.getFileHandle(t,{create:!0})).createWritable(),r=JSON.stringify({version:1,maxSize:4294967295,entries:{}});await n.write(r),await n.close()}static async acquireOpfsHandle(e,t){let r=navigator.storage;if(!r?.getDirectory)throw new n(`EINVAL`,`OPFS is not available in this environment`);let i=await r.getDirectory();if(t)try{await i.removeEntry(e,{recursive:!0})}catch{}return i.getDirectoryHandle(e,{create:!0})}static _createSyncForTests(e){return new t(e)}static async create(e){let n=e?.dbName??`browser-fs`,r=e?.wipe===!0,i=e?.backend??G(),a=new t(n,r,i);return await a._ready,r&&await s().catch(()=>{}),a}async flush(){await this.writeOpfsMetadataSidecar()}async writeOpfsMetadataSidecar(){if(this.backend!==`opfs`)return;let e=this.opfsBackendFs,t=this.opfsHandle;if(!e||!t)return;let n=JSON.stringify(e.index.toJSON()),r=await(await t.getFileHandle(`.metadata.json`,{create:!0})).createWritable();await r.write(n),await r.close()}invalidatePaths(e){if(this.backend!==`opfs`||!this.opfsBackendFs)return;let t=this.opfsBackendFs;for(let n of e){let e=E(n);t.index.delete(e),t._handles?.delete(e)}}canWrite(e){return!0}setWatcher(e){this.watcher=e}getWatcher(){return this.watcher}async dispose(){if(this.mountSyncChannel?.close(),this.mountSyncChannel=null,this.watcher?.dispose(),this.watcher=null,this.mountIndex.dispose(),await this.writeOpfsMetadataSidecar(),this.mountRoot){let n=this.backend===`opfs`?t.opfsBackends:t.memoryBackends,r=n.get(this.dbName);if(r&&(--r.refs,r.refs<=0)){n.delete(this.dbName);try{(await e(()=>import(`./dist-0FRaZO2z.js`).then(e=>e.t),__vite__mapDeps([0,1]))).umount(this.mountRoot)}catch{}}}}readDirSync(e){let t=E(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.readdirSync!=`function`||typeof n.lstatSync!=`function`)return null;try{let e=n.readdirSync(t),r=[];for(let i of e){let e=t===`/`?`/${i}`:`${t}/${i}`;try{let t=n.lstatSync(e),a=t.isSymbolicLink()?`symlink`:t.isDirectory()?`directory`:`file`;r.push({name:i,type:a})}catch{}}return r}catch{return null}}statSync(e){let t=E(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.statSync!=`function`||typeof n.lstatSync!=`function`||typeof n.readlinkSync!=`function`)return null;let r=t;for(let e=0;e<=10;e++){let e;try{e=n.lstatSync(r)}catch{return null}if(!e.isSymbolicLink())return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs};let t;try{t=n.readlinkSync(r)}catch{return null}r=t.startsWith(`/`)?E(t):E(k(D(r).dir,t))}return null}lstatSync(e){let t=E(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.lstatSync!=`function`)return null;try{let e=n.lstatSync(t);if(e.isSymbolicLink()){let r=n.readlinkSync?n.readlinkSync(t):``;return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:r}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch{return null}}async mount(e,t,r){let a=E(e);if(this.mountPoints.has(a))throw new n(`EEXIST`,`mount point is already mounted`,a);try{if((await this.lstat(a)).type!==`directory`)throw new n(`ENOTDIR`,`mount point must be a directory`,a);if((await this.readDir(a)).length>0)throw new n(`ENOTEMPTY`,`mount point must be empty to avoid shadowing existing files`,a)}catch(e){if(!(e instanceof n)||e.code!==`ENOENT`)throw e}let{dir:o}=D(a);o!==`/`&&await this.mkdir(o,{recursive:!0});try{await this.lfs.mkdir(a)}catch{}if(this.mountPoints.set(a,t),t.kind===`local`){let e=w(r?.env??{});this.mountIndex.registerMount(a,t.getHandle(),e)}let s=t.kind===`local`?{kind:`local`,mountId:t.mountId,idbHandleKey:a}:t.kind===`s3`?{kind:`s3`,mountId:t.mountId,source:t.source,profile:t.profile??`default`}:{kind:`da`,mountId:t.mountId,source:t.source,profile:t.profile??`default`};try{this.mountSyncChannel?.postMessage({type:`mount`,path:a,descriptor:s})}catch{}this.watcher?.notify([{type:`modify`,path:a,entryType:`directory`}]);try{await i({targetPath:a,descriptor:s,createdAt:Date.now()},t.kind===`local`?t.getHandle():void 0)}catch{}}async unmount(e){let t=E(e),n=this.mountPoints.get(t);this.mountPoints.delete(t),this.mountIndex.unregisterMount(t);try{this.mountSyncChannel?.postMessage({type:`unmount`,path:t})}catch{}this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await n?.close();try{await a(t)}catch{}}async reconstructBackendFromDescriptor(t){switch(t.kind){case`local`:{let e=await o(t.idbHandleKey);if(!e)throw Error(`no handle stored for ${t.idbHandleKey}`);return r.fromHandle(e,{mountId:t.mountId})}case`s3`:{let{S3MountBackend:n,RemoteMountCache:r,makeSignedFetchS3:i}=await e(async()=>{let{S3MountBackend:e,RemoteMountCache:t,makeSignedFetchS3:n}=await import(`./mount-C7OeghLh.js`);return{S3MountBackend:e,RemoteMountCache:t,makeSignedFetchS3:n}},__vite__mapDeps([3,4,5,6,7,8,1,9,10,11,12,13,14,15,16,17,18,19,20])),a=new r({mountId:t.mountId,ttlMs:3e4});return new n({source:t.source,profile:t.profile,cache:a,mountId:t.mountId,signedFetch:i(t.profile)})}case`da`:{let{DaMountBackend:n,RemoteMountCache:r,makeSignedFetchDa:i}=await e(async()=>{let{DaMountBackend:e,RemoteMountCache:t,makeSignedFetchDa:n}=await import(`./mount-C7OeghLh.js`);return{DaMountBackend:e,RemoteMountCache:t,makeSignedFetchDa:n}},__vite__mapDeps([3,4,5,6,7,8,1,9,10,11,12,13,14,15,16,17,18,19,20])),a=new r({mountId:t.mountId,ttlMs:3e4});return new n({source:t.source,profile:t.profile,cache:a,mountId:t.mountId,signedFetch:i()})}}}listMounts(){let e=[];for(let t of this.mountPoints.keys())this.internalMounts.has(t)||e.push(t);return e}listInternalMounts(){return[...this.internalMounts]}listMountPoints(){let e=[];for(let[t,n]of this.mountPoints)this.internalMounts.has(t)||e.push({path:t,kind:n.kind});return e}async mountInternal(e,t){let r=E(e);if(this.mountPoints.has(r))throw new n(`EEXIST`,`mount point is already mounted`,r);let{dir:i}=D(r);i!==`/`&&await this.mkdir(i,{recursive:!0});try{await this.lfs.mkdir(r)}catch{}this.mountPoints.set(r,t),this.internalMounts.add(r),this.watcher?.notify([{type:`modify`,path:r,entryType:`directory`}])}async unmountInternal(e){let t=E(e);if(!this.internalMounts.has(t))throw new n(`ENOENT`,`not an internal mount point`,t);let r=this.mountPoints.get(t);this.mountPoints.delete(t),this.internalMounts.delete(t),this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await r?.close()}getMountIndex(){return this.mountIndex}async refreshMount(e,t){let r=E(e),i=this.mountPoints.get(r);if(!i)throw new n(`ENOENT`,`not a mount point`,r);let a=await i.refresh(t);return i.kind===`local`&&await this.mountIndex.refreshMount(r,w(t?.env??{})),a}isPathUnderMount(e){for(let t of this.mountPoints.keys())if(e===t||e.startsWith(t+`/`))return!0;return!1}findMount(e){let t=null;for(let[n,r]of this.mountPoints)(e===n||e.startsWith(n+`/`))&&(!t||n.length>t.mountPath.length)&&(t={mountPath:n,backend:r});return t?e===t.mountPath?{path:t.mountPath,backend:t.backend,relParts:[]}:{path:t.mountPath,backend:t.backend,relParts:e.slice(t.mountPath.length+1).split(`/`).filter(Boolean)}:null}async readFile(e,t){let r=E(e),i=this.findMount(r);if(i){if(i.relParts.length===0)throw new n(`EISDIR`,`is a directory`,r);let e=i.relParts.join(`/`);try{let n=await i.backend.readFile(e);return(t?.encoding??`utf-8`)===`utf-8`?new TextDecoder(`utf-8`).decode(n):n}catch(e){M(e,r)}}let a=await this.resolveSymlinks(r);try{return(t?.encoding??`utf-8`)===`utf-8`?await this.lfs.readFile(a,{encoding:`utf8`}):await this.lfs.readFile(a)}catch(e){throw P(e,r)}}async writeFile(e,t,r){let i=E(e),a=this.findMount(i);if(a){if(a.relParts.length===0)throw new n(`EISDIR`,`is a directory`,i);let e=a.relParts.join(`/`),r=!1;try{await this.stat(i),r=!0}catch{}let o=typeof t==`string`?new TextEncoder().encode(t):t instanceof Uint8Array?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t);try{await a.backend.writeFile(e,o)}catch(e){M(e,i)}this.watcher?.notify([{type:r?`modify`:`create`,path:i,entryType:`file`}]),this.mountIndex.notifyWrite(i);return}let o;try{o=await this.resolveSymlinks(i)}catch{o=i}let s=!1;try{await this.lfs.stat(o),s=!0}catch{}let{dir:c}=D(o);await this.withWriteLock(async()=>{c!==`/`&&await this.mkdirRecursiveUnlocked(c);let e=typeof t==`string`?new TextEncoder().encode(t).byteLength:(t instanceof Uint8Array,t.byteLength);try{await this.lfs.writeFile(o,t)}catch(e){if(c!==`/`&&e instanceof Error&&e.message.includes(`ENOENT`)){await this.mkdirRecursiveUnlocked(c);try{await this.lfs.writeFile(o,t)}catch(e){throw P(e,i)}}else throw P(e,i)}try{await this.lfs.truncate?.(o,e)}catch(e){throw P(e,i)}}),this.watcher?.notify([{type:s?`modify`:`create`,path:o,entryType:`file`}])}async readDir(e){let t=E(e),n=this.findMount(t);return n?this.readDirMounted(t,n):this.readDirLocal(t)}async readDirMounted(e,t){let n=this.mountIndex.getDirectoryEntries(t.path,e);if(n!==void 0){let t=new Map;for(let e of n)t.set(e.name,{name:e.name,type:e.type});return this.addNestedMountEntries(t,e),[...t.values()]}let r=t.relParts.join(`/`)||`/`,i;try{i=await t.backend.readDir(r)}catch(t){M(t,e)}let a=new Map;for(let e of i)a.set(e.name,{name:e.name,type:e.kind===`directory`?`directory`:`file`});return this.addNestedMountEntries(a,e),[...a.values()]}async readDirLocal(e){let t=await this.resolveSymlinks(e);try{let e=await this.lfs.readdir(t),n=[];for(let r of e){let e=await this.statDirEntry(t,r);e&&n.push(e)}return n}catch(t){throw P(t,e)}}async statDirEntry(e,t){let n=e===`/`?`/${t}`:`${e}/${t}`;try{let e=await this.lfs.lstat(n);return e.isSymbolicLink()?{name:t,type:`symlink`}:{name:t,type:e.isDirectory()?`directory`:`file`}}catch{return null}}addNestedMountEntries(e,t){let n=t===`/`?`/`:`${t}/`;for(let r of this.mountPoints.keys()){if(r===t||!r.startsWith(n))continue;let i=r.slice(n.length);!i||i.includes(`/`)||e.has(i)||e.set(i,{name:i,type:`directory`})}}async withWriteLock(e){let t,n=new Promise(e=>{t=e}),r=this._writeLock;this._writeLock=n,await r;try{return await e()}finally{t()}}async mkdirRecursiveUnlocked(e){let t=e.split(`/`).filter(Boolean),n=``;for(let e of t){n+=`/`+e;try{await this.lfs.mkdir(n)}catch(e){if(e instanceof Error&&!e.message.includes(`EEXIST`))throw P(e,n)}}}async mkdir(e,t){let n=E(e);if(n===`/`)return;let r=this.findMount(n);if(r){if(r.relParts.length===0)return;let e=r.relParts.join(`/`),t=await this.exists(n);try{await r.backend.mkdir(e)}catch(e){M(e,n)}t||this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}]);return}t?.recursive?await this.withWriteLock(()=>this.mkdirRecursiveUnlocked(n)):(await this.withWriteLock(async()=>{try{await this.lfs.mkdir(n)}catch(e){throw P(e,n)}}),this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}]))}async rm(e,t){let r=E(e),i=this.findMount(r);if(i){if(i.relParts.length===0)throw new n(`EINVAL`,`cannot remove a mount point — use unmount`,r);let e;try{e=(await this.stat(r)).type}catch{}let a=i.relParts.join(`/`);try{await i.backend.remove(a,{recursive:t?.recursive})}catch(e){M(e,r)}this.watcher?.notify([{type:`delete`,path:r,entryType:e}]),this.mountIndex.notifyDelete(r);return}try{let e=await this.lfs.lstat(r);await this.withWriteLock(async()=>{e.isSymbolicLink()?await this.lfs.unlink(r):e.isDirectory()?t?.recursive?await this.rmRecursiveUnlocked(r):await this.lfs.rmdir(r):await this.lfs.unlink(r),await this.writeOpfsMetadataSidecar()})}catch(e){throw P(e,r)}this.watcher?.notify([{type:`delete`,path:r}])}async rmRecursiveUnlocked(e){let t=await this.lfs.readdir(e);for(let n of t){let t=e===`/`?`/${n}`:`${e}/${n}`,r=await this.lfs.lstat(t);r.isSymbolicLink()?await this.lfs.unlink(t):r.isDirectory()?await this.rmRecursiveUnlocked(t):await this.lfs.unlink(t)}await this.lfs.rmdir(e)}async stat(e){let t=E(e),n=this.findMount(t);if(n){if(n.relParts.length===0)try{let e=await this.lfs.stat(t);return{type:`directory`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch{return{type:`directory`,size:0,mtime:Date.now(),ctime:Date.now()}}let e=n.relParts.join(`/`);try{let t=await n.backend.stat(e);return{type:t.kind===`directory`?`directory`:`file`,size:t.size,mtime:t.mtime,ctime:t.mtime}}catch(e){M(e,t)}}let r=await this.resolveSymlinks(t);try{let e=await this.lfs.stat(r);return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch(e){throw P(e,t)}}async exists(e){let t=E(e),n=this.findMount(t);if(n){if(n.relParts.length===0)return!0;try{return await this.stat(t),!0}catch{return!1}}try{return await this.stat(t),!0}catch{try{return await this.lfs.lstat(t),!0}catch{return!1}}}async rename(e,t){let n=E(e),r=E(t),i;try{i=(await this.lstat(n)).type}catch{}try{await this.lfs.rename(n,r)}catch(e){throw P(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:i},{type:`create`,path:r,entryType:i}]),this.mountIndex.notifyRename(n,r)}async readTextFile(e){return await this.readFile(e,{encoding:`utf-8`})}async*walk(e,t,n=0){yield*H({mountPoints:this.mountPoints,mountIndex:this.mountIndex,realpath:e=>this.realpath(e),readDir:e=>this.readDir(e),stat:e=>this.stat(e)},e,t,n)}async copyFile(e,t){if((await this.stat(e)).type===`directory`)throw new n(`EISDIR`,`is a directory`,e);let r=await this.readFile(e,{encoding:`binary`});await this.writeFile(t,r)}dirname(e){return D(E(e)).dir}basename(e){return D(E(e)).base}async symlink(e,t){let r=E(t);if(this.findMount(r))throw new n(`EINVAL`,`symlinks not supported on mounted filesystems`,r);let{dir:i}=D(r);await this.withWriteLock(async()=>{i!==`/`&&await this.mkdirRecursiveUnlocked(i);try{await this.lfs.symlink(e,r)}catch(t){if(i!==`/`&&t instanceof Error&&t.message.includes(`ENOENT`)){await this.mkdirRecursiveUnlocked(i);try{await this.lfs.symlink(e,r)}catch(e){throw P(e,r)}}else throw P(t,r)}await this.writeOpfsMetadataSidecar()}),this.watcher?.notify([{type:`create`,path:r,entryType:`symlink`}])}async readlink(e){let t=E(e);try{return await this.lfs.readlink(t)}catch(e){throw P(e,t)}}async lstat(e){let t=E(e);if(this.findMount(t))return this.stat(t);try{let e=await this.lfs.lstat(t);if(e.isSymbolicLink()){let n=await this.lfs.readlink(t);return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:n}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch(e){throw P(e,t)}}async realpath(e){return R(this.lfs,e=>this.findMount(e)!==null,e)}resolveSymlinks(e){return z(this.lfs,e=>this.findMount(e)!==null,e)}};export{n as FsError,d as FsWatcher,T as MountIndex,j as RestrictedFS,K as VirtualFS,k as joinPath,E as normalizePath,O as pathSegments,G as resolveVfsBackendFromEnv,D as splitPath};