sliccy 4.30.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/ui/assets/{account-store-D8YLtENA.js → account-store-CeSn6D5H.js} +2 -2
  2. package/dist/ui/assets/{account-store-Mno_jQCd.js → account-store-rEr_WCiZ.js} +2 -2
  3. package/dist/ui/assets/adobe-C-0IO_h7.js +1 -0
  4. package/dist/ui/assets/adobe-CaPkrk12.js +2 -0
  5. package/dist/ui/assets/{adobe-oauth-state-DbTh2eai.js → adobe-oauth-state-Ct_9pMfk.js} +1 -1
  6. package/dist/ui/assets/{agent-message-to-chat-wRgLPEe1.js → agent-message-to-chat-BjwD-qSr.js} +1 -1
  7. package/dist/ui/assets/{apps-o9I4b9Pm.js → apps-DcaNdhLo.js} +1 -1
  8. package/dist/ui/assets/{azure-openai-C83eqmCB.js → azure-openai-Cd_zNvrH.js} +1 -1
  9. package/dist/ui/assets/{azure-openai-f8WoKIg-.js → azure-openai-Ck-Mz-fA.js} +1 -1
  10. package/dist/ui/assets/{connect-surface-CvI6NTHs.js → connect-surface-BHwPGe-M.js} +1 -1
  11. package/dist/ui/assets/dip-7QqevBKp.js +1 -0
  12. package/dist/ui/assets/{dist-BgeIZflL.js → dist-Ci080vMX.js} +1 -1
  13. package/dist/ui/assets/{dist-BJmAwsXW.js → dist-CngoSKj5.js} +1 -1
  14. package/dist/ui/assets/{ensure-speech-assets-C0Stgh12.js → ensure-speech-assets-BCU8IdGW.js} +1 -1
  15. package/dist/ui/assets/esp8266-DmQ_hpdd.js +1 -0
  16. package/dist/ui/assets/{esptool-operations-TFe7TNmm.js → esptool-operations-neFaXd8_.js} +2 -2
  17. package/dist/ui/assets/{fs-CrSOLRNj.js → fs-BjT1eFTD.js} +2 -2
  18. package/dist/ui/assets/{fs-CzSttrrl.js → fs-D-HMqXVP.js} +1 -1
  19. package/dist/ui/assets/{github-hZl4t20p.js → github-CAePhIbS.js} +1 -1
  20. package/dist/ui/assets/{github-BmM5aC3N.js → github-D9t7xSl1.js} +2 -2
  21. package/dist/ui/assets/{github-copilot-Bj1ghYQc.js → github-copilot-CBjlNHA-.js} +1 -1
  22. package/dist/ui/assets/{github-copilot-BZIPfQvl.js → github-copilot-CIvumkNp.js} +1 -1
  23. package/dist/ui/assets/{hear-BvgYe6O8.js → hear-DlTGQBhm.js} +1 -1
  24. package/dist/ui/assets/{kernel-worker-Dd37r1MP.js → kernel-worker-YTlCGWHk.js} +710 -698
  25. package/dist/ui/assets/{kokoro-engine-DTDdmRjz.js → kokoro-engine-Cwt0vpZc.js} +1 -1
  26. package/dist/ui/assets/{lick-ws-bridge-ECi4GOkD.js → lick-ws-bridge-D5EC6geF.js} +1 -1
  27. package/dist/ui/assets/{local-llm-CfWJl6vt.js → local-llm-CVuUH-FR.js} +1 -1
  28. package/dist/ui/assets/{main-DsOZX9Xj.js → main-D1QY7_Z4.js} +4 -4
  29. package/dist/ui/assets/{mount-CRZvM9UI.js → mount-BqN1qscB.js} +2 -2
  30. package/dist/ui/assets/{mount-CqXaKfK7.js → mount-Q0JajjqW.js} +1 -1
  31. package/dist/ui/assets/{new-session-DdSqwHlf.js → new-session-D6GL01oR.js} +2 -2
  32. package/dist/ui/assets/{oauth-bootstrap-BjTCYMG8.js → oauth-bootstrap-Bsf5hex-.js} +2 -2
  33. package/dist/ui/assets/{openai-codex-B-RybkTp.js → openai-codex-BsdKIPSM.js} +1 -1
  34. package/dist/ui/assets/{openai-codex-546PYqHn.js → openai-codex-Czv94Ma4.js} +1 -1
  35. package/dist/ui/assets/{panel-rpc-handlers-DJzxFT8f.js → panel-rpc-handlers-DAQb1krb.js} +1 -1
  36. package/dist/ui/assets/{provider-BtXp6v_N.js → provider-DCpkR_Qg.js} +2 -2
  37. package/dist/ui/assets/{provider-CHydGMT6.js → provider-DLxi6mrk.js} +1 -1
  38. package/dist/ui/assets/provider-store-access-Dcrp0Diw.js +1 -0
  39. package/dist/ui/assets/provider-store-access-Yo_qZb2h.js +1 -0
  40. package/dist/ui/assets/{providers-3UGTq8Zp.js → providers-DJP5gGuq.js} +1 -1
  41. package/dist/ui/assets/{quick-llm-CtmD_Eqd.js → quick-llm-BcoHwyQn.js} +1 -1
  42. package/dist/ui/assets/session-freezer-BhC1zshT.js +1 -0
  43. package/dist/ui/assets/{speak-CPWfWdxL.js → speak-DSQu3MNf.js} +1 -1
  44. package/dist/ui/assets/{sprinkle-manager-D45XqDS_.js → sprinkle-manager-CF1Tm9ux.js} +1 -1
  45. package/dist/ui/assets/{store-Di2gvYsr.js → store-BaxQOlne.js} +1 -1
  46. package/dist/ui/assets/{sudo-C--ZFBWF.js → sudo-zd7NVwiq.js} +1 -1
  47. package/dist/ui/assets/{transformers-env-BvQQxw7s.js → transformers-env-BTGVMAtZ.js} +1 -1
  48. package/dist/ui/assets/{tray-leave-runtime-DWRlcPcQ.js → tray-leave-runtime-CnI2i9ms.js} +1 -1
  49. package/dist/ui/assets/upgrade-detection-BI-uYXbr.js +1 -0
  50. package/dist/ui/assets/{wc-attach-hnjAgF3r.js → wc-attach-M_i0c5wx.js} +2 -2
  51. package/dist/ui/assets/{wc-detached-DPpzG1m4.js → wc-detached-Ba7UK8gf.js} +1 -1
  52. package/dist/ui/assets/{wc-extension-Bt6WVUQv.js → wc-extension-Bp34NH6Q.js} +2 -2
  53. package/dist/ui/assets/{wc-live-C6obLPXQ.js → wc-live-DOXieP5u.js} +5 -5
  54. package/dist/ui/assets/{wc-nav-B-0t6YAo.js → wc-nav-CR54-w22.js} +2 -2
  55. package/dist/ui/assets/{wc-onboarding-JjUXzEW1.js → wc-onboarding-1HOilLVc.js} +2 -2
  56. package/dist/ui/assets/{wc-placeholder-CTzKu6PN.js → wc-placeholder-BkzKHPa-.js} +3 -3
  57. package/dist/ui/assets/{wc-settings-DWj5Vh5K.js → wc-settings-RrQsJKwK.js} +2 -2
  58. package/dist/ui/assets/{wc-shell-DeV6jP6H.js → wc-shell-F5Wp6J-I.js} +3 -3
  59. package/dist/ui/assets/{wc-sprinkles-ybvU4BX1.js → wc-sprinkles-k6cLXsFx.js} +2 -2
  60. package/dist/ui/assets/{wc-tray-DxqLkc-f.js → wc-tray-DWJypzjx.js} +3 -3
  61. package/dist/ui/assets/{whisper-engine-CtV8ZqBe.js → whisper-engine-D-mBGSOg.js} +1 -1
  62. package/dist/ui/assets/{xai-grok-BMgUe5-z.js → xai-grok-BwWScA_U.js} +1 -1
  63. package/dist/ui/assets/{xai-grok-YbjS9qgk.js → xai-grok-CzzsjmSz.js} +1 -1
  64. package/dist/ui/index.html +2 -2
  65. package/dist/ui/packages/webapp/index.html +2 -2
  66. package/package.json +6 -6
  67. package/dist/ui/assets/adobe-BKV8wdW6.js +0 -2
  68. package/dist/ui/assets/adobe-NArV2EOF.js +0 -1
  69. package/dist/ui/assets/dip-CVVXtqJ5.js +0 -1
  70. package/dist/ui/assets/esp8266-crsTt7TM.js +0 -1
  71. package/dist/ui/assets/provider-store-access-BTTpQny7.js +0 -1
  72. package/dist/ui/assets/provider-store-access-DTMNyyhW.js +0 -1
  73. package/dist/ui/assets/session-freezer-C5kXYuKn.js +0 -1
  74. package/dist/ui/assets/upgrade-detection-4HyYnnIW.js +0 -1
@@ -1 +1 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{a as t,i as n,r}from"./transformers-env-BvQQxw7s.js";const i=e(`speech:kokoro`),a=`onnx-community/Kokoro-82M-v1.0-ONNX`;function o(e){return Object.entries(e).map(([e,t])=>({id:e,name:t.name||e,lang:t.language===`en-gb`||e.startsWith(`b`)?`en-GB`:`en-US`,...t.gender?{gender:t.gender}:{}}))}const s=`style_text_to_speech_2`,c=`StyleTextToSpeech2Model`;function l(e){return e?.model_type===s&&(!Array.isArray(e.architectures)||e.architectures.length===0)&&(e.architectures=[c]),e}const u=Symbol.for(`slicc.kokoro.style-tts2-arch-shim`);function d(e){let t=e?.AutoConfig,n=t?.from_pretrained;if(!t||typeof n!=`function`){i.debug(`style_text_to_speech_2 shim skipped: AutoConfig.from_pretrained unavailable`);return}if(n[u])return;let r=async(...e)=>{let r=await n.apply(t,e),a=r?.model_type===s&&(!Array.isArray(r.architectures)||r.architectures.length===0);return l(r),a&&i.debug(`style_text_to_speech_2 architectures injected for "${String(e[0])}": [${c}]`),r};r[u]=!0,t.from_pretrained=r,i.debug(`style_text_to_speech_2 architecture shim installed on AutoConfig.from_pretrained`)}let f=null,p=`idle`,m=null,h=null;function g(){return p}function _(){return m}function v(){return h}function y(e){return f||=(p=`loading`,b(e).then(e=>(p=`ready`,h=e,e),e=>{throw p=`failed`,f=null,i.error(`kokoro load failed`,e),e})),f}async function b(e){let s=await import(`./transformers.web-BxHOGVSB.js`);n(s.env),d(s),await r(a);let{KokoroTTS:c,TextSplitterStream:l}=await import(`./kokoro-BdpwC7DT.js`),u=t(),f=typeof navigator<`u`&&`gpu`in navigator,p=await c.from_pretrained(a,{device:f?`webgpu`:`wasm`,dtype:f?`fp32`:`q8`,progress_callback:t=>{if(t?.file){if(t.status===`progress`)u.update(t.file,t.loaded??0,t.total??0);else if(t.status===`done`)u.complete(t.file);else return;m=u.snapshot(),e?.(m)}}});i.info(`kokoro ready`,{model:a,device:f?`webgpu`:`wasm`});let h=o(p.voices);return{async synthesize(e,t){let n=await p.generate(e,{...t?.voice?{voice:t.voice}:{},...t?.speed?{speed:t.speed}:{}});return{audio:n.audio,sampleRate:n.sampling_rate}},async*synthesizeStream(e,t){let n={...t?.voice?{voice:t.voice}:{},...t?.speed?{speed:t.speed}:{}},r=new l;if(t?.splitPattern){let n=e.split(t.splitPattern).map(e=>e.trim()).filter(e=>e.length>0);r.push(...n)}else r.push(e);r.close();for await(let e of p.stream(r,n))yield{audio:e.audio.audio,sampleRate:e.audio.sampling_rate}},voices:()=>h}}export{g as a,v as i,y as n,_ as r,a as t};
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{a as t,i as n,r}from"./transformers-env-BTGVMAtZ.js";const i=e(`speech:kokoro`),a=`onnx-community/Kokoro-82M-v1.0-ONNX`;function o(e){return Object.entries(e).map(([e,t])=>({id:e,name:t.name||e,lang:t.language===`en-gb`||e.startsWith(`b`)?`en-GB`:`en-US`,...t.gender?{gender:t.gender}:{}}))}const s=`style_text_to_speech_2`,c=`StyleTextToSpeech2Model`;function l(e){return e?.model_type===s&&(!Array.isArray(e.architectures)||e.architectures.length===0)&&(e.architectures=[c]),e}const u=Symbol.for(`slicc.kokoro.style-tts2-arch-shim`);function d(e){let t=e?.AutoConfig,n=t?.from_pretrained;if(!t||typeof n!=`function`){i.debug(`style_text_to_speech_2 shim skipped: AutoConfig.from_pretrained unavailable`);return}if(n[u])return;let r=async(...e)=>{let r=await n.apply(t,e),a=r?.model_type===s&&(!Array.isArray(r.architectures)||r.architectures.length===0);return l(r),a&&i.debug(`style_text_to_speech_2 architectures injected for "${String(e[0])}": [${c}]`),r};r[u]=!0,t.from_pretrained=r,i.debug(`style_text_to_speech_2 architecture shim installed on AutoConfig.from_pretrained`)}let f=null,p=`idle`,m=null,h=null;function g(){return p}function _(){return m}function v(){return h}function y(e){return f||=(p=`loading`,b(e).then(e=>(p=`ready`,h=e,e),e=>{throw p=`failed`,f=null,i.error(`kokoro load failed`,e),e})),f}async function b(e){let s=await import(`./transformers.web-BxHOGVSB.js`);n(s.env),d(s),await r(a);let{KokoroTTS:c,TextSplitterStream:l}=await import(`./kokoro-BdpwC7DT.js`),u=t(),f=typeof navigator<`u`&&`gpu`in navigator,p=await c.from_pretrained(a,{device:f?`webgpu`:`wasm`,dtype:f?`fp32`:`q8`,progress_callback:t=>{if(t?.file){if(t.status===`progress`)u.update(t.file,t.loaded??0,t.total??0);else if(t.status===`done`)u.complete(t.file);else return;m=u.snapshot(),e?.(m)}}});i.info(`kokoro ready`,{model:a,device:f?`webgpu`:`wasm`});let h=o(p.voices);return{async synthesize(e,t){let n=await p.generate(e,{...t?.voice?{voice:t.voice}:{},...t?.speed?{speed:t.speed}:{}});return{audio:n.audio,sampleRate:n.sampling_rate}},async*synthesizeStream(e,t){let n={...t?.voice?{voice:t.voice}:{},...t?.speed?{speed:t.speed}:{}},r=new l;if(t?.splitPattern){let n=e.split(t.splitPattern).map(e=>e.trim()).filter(e=>e.length>0);r.push(...n)}else r.push(e);r.close();for await(let e of p.stream(r,n))yield{audio:e.audio.audio,sampleRate:e.audio.sampling_rate}},voices:()=>h}}export{g as a,v as i,y as n,_ as r,a as t};
@@ -1 +1 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{b as t,n,r,t as i,y as a}from"./kernel-worker-Dd37r1MP.js";const o=e(`lick-ws-bridge`);function s(e){if(e.stopped)return;let t;try{t=e.wsFactory(e.wsUrl)}catch(t){o.error(`Failed to construct lick WebSocket`,{url:e.wsUrl,error:t instanceof Error?t.message:String(t)}),c(e,`construct-threw`);return}e.socket=t,t.onopen=()=>{e.consecutiveFailures>0?o.info(`Lick WebSocket recovered`,{attempts:e.consecutiveFailures}):o.info(`Lick WebSocket connected`),e.consecutiveFailures=0,e.unrecoverableSignalled=!1},t.onmessage=n=>{u(e,t,n.data).catch(e=>{let t=typeof n.data==`string`?n.data.slice(0,200):`[non-string payload]`;o.error(`Failed to process lick message`,{error:e instanceof Error?e.message:String(e),preview:t})})},t.onclose=n=>{if(e.socket===t&&(e.socket=null),e.stopped)return;let r=n.reason?` reason=${JSON.stringify(n.reason)}`:``;c(e,`disconnected code=${n.code}${r}`)},t.onerror=t=>{let n=t.target;o.error(`Lick WebSocket error`,{url:e.wsUrl,readyState:n?.readyState,eventType:t.type})}}function c(e,t){if(e.reconnectHandle!=null){o.debug(`Lick WS failure during pending reconnect — keeping existing timer`,{cause:t});return}e.consecutiveFailures++;let n=Math.min(e.baseDelay*2**(e.consecutiveFailures-1),6e4),r={url:e.wsUrl,attempt:e.consecutiveFailures,cause:t,retryInMs:n};if(e.consecutiveFailures>=3?o.error(`Lick WebSocket still down`,r):o.warn(`Lick WebSocket down`,r),e.consecutiveFailures===20&&!e.unrecoverableSignalled){e.unrecoverableSignalled=!0;try{e.lickManager.emitEvent({type:`session-reload`,targetScoop:void 0,timestamp:new Date().toISOString(),body:{reason:`lick-ws-bridge-down`,url:e.wsUrl,attempts:e.consecutiveFailures}})}catch(e){o.error(`Failed to emit lick-ws-bridge-down signal`,{error:e instanceof Error?e.message:String(e)})}}l(e,n)}function l(e,t){e.stopped||e.reconnectHandle!=null||(e.reconnectHandle=e.setTimer(()=>{e.reconnectHandle=null,s(e)},t))}async function u(e,t,n){let r=JSON.parse(typeof n==`string`?n:String(n));if(r.requestId){let n=r.requestId,i=await p(e,r,n);if(e.stopped||e.socket!==t||t.readyState!==1){o.warn(`Lick reply dropped — socket changed/closed mid-request`,{type:r.type,requestId:n});return}try{t.send(JSON.stringify(i))}catch(e){o.error(`ws.send() failed delivering lick reply`,{type:r.type,requestId:n,error:e instanceof Error?e.message:String(e)})}return}if(r.type===`webhook_event`){d(e.lickManager,r);return}r.type===`navigate_event`&&f(e.lickManager,r)}function d(e,t){let n=typeof t.webhookId==`string`?t.webhookId:null;if(!n){o.error(`Malformed webhook_event from lick-ws`,{receivedKeys:Object.keys(t)});return}let r=t.headers&&typeof t.headers==`object`?t.headers:{};try{e.handleWebhookEvent(n,r,t.body)}catch(e){o.error(`Webhook event dispatch failed`,{webhookId:n,error:e instanceof Error?e.message:String(e)})}}function f(e,t){let n=typeof t.verb==`string`?t.verb:null,r=typeof t.target==`string`?t.target:null,i=typeof t.url==`string`&&t.url.length>0?t.url:null;if(n!==`handoff`&&n!==`upskill`||!r||!i){o.debug(`navigate_event dropped — invalid payload`,{hasVerb:!!n,hasTarget:!!r,hasUrl:!!i});return}let a={url:i,verb:n,target:r};typeof t.instruction==`string`&&(a.instruction=t.instruction),typeof t.branch==`string`&&(a.branch=t.branch),typeof t.path==`string`&&(a.path=t.path),typeof t.title==`string`&&(a.title=t.title),e.emitEvent({type:`navigate`,navigateUrl:i,targetScoop:void 0,timestamp:typeof t.timestamp==`string`?t.timestamp:new Date().toISOString(),body:a})}async function p(e,t,n){let{lickManager:r}=e;try{switch(t.type){case`list_webhooks`:return{type:`response`,requestId:n,data:r.listWebhooks().map(t=>({...t,url:m(e,t.id)}))};case`create_webhook`:{let i=await r.createWebhook(t.name||`default`,t.scoop,t.filter);return{type:`response`,requestId:n,data:{...i,url:m(e,i.id)}}}case`delete_webhook`:return await r.deleteWebhook(t.id)?{type:`response`,requestId:n,data:{ok:!0}}:{type:`response`,requestId:n,data:{error:`Webhook not found`}};case`list_crontasks`:return{type:`response`,requestId:n,data:r.listCronTasks()};case`create_crontask`:if(!t.name)throw Error(`name is required`);if(!t.cron)throw Error(`cron is required`);return{type:`response`,requestId:n,data:await r.createCronTask(t.name,t.cron,t.scoop,t.filter)};case`delete_crontask`:return await r.deleteCronTask(t.id)?{type:`response`,requestId:n,data:{ok:!0}}:{type:`response`,requestId:n,data:{error:`Cron task not found`}};case`tray_status`:{let e=a();return{type:`response`,requestId:n,data:{state:e.state,joinUrl:e.session?.joinUrl??null,workerBaseUrl:e.session?.workerBaseUrl??null,trayId:e.session?.trayId??null}}}default:return{type:`response`,requestId:n,error:`Unknown request type: ${t.type}`}}}catch(e){return{type:`response`,requestId:n,error:e instanceof Error?e.message:String(e)}}}function m(e,i){let a=t().session;return a?.webhookUrl?n(a.webhookUrl,i):e.webhookOriginOverride?`${e.webhookOriginOverride}/webhooks/${i}`:r(e.options.locationHref,i)}function h(e){if(e.stopped)return;e.stopped=!0,e.reconnectHandle!=null&&(e.clearTimer(e.reconnectHandle),e.reconnectHandle=null);let t=e.socket;if(e.socket=null,t)try{t.close()}catch(e){t.readyState!==3&&t.readyState!==2&&o.warn(`Lick socket close() threw before terminal state`,{readyState:t.readyState,error:e instanceof Error?e.message:String(e)})}}function g(e,t){try{new URL(t.locationHref)}catch(e){throw Error(`startLickWsBridge: invalid locationHref ${JSON.stringify(t.locationHref)}: ${e instanceof Error?e.message:String(e)}`)}let n=typeof t.lickWsUrl==`string`&&t.lickWsUrl.length>0?t.lickWsUrl:i(t.locationHref),r=null;if(typeof t.lickWsUrl==`string`&&t.lickWsUrl.length>0)try{let e=new URL(t.lickWsUrl);r=`${e.protocol===`wss:`?`https:`:`http:`}//${e.host}`}catch{r=null}let a={lickManager:e,options:t,wsUrl:n,webhookOriginOverride:r,baseDelay:t.reconnectDelayMs??3e3,wsFactory:t.webSocketFactory??(e=>new WebSocket(e)),setTimer:t.setTimeoutFn??setTimeout.bind(globalThis),clearTimer:t.clearTimeoutFn??clearTimeout.bind(globalThis),stopped:!1,socket:null,reconnectHandle:null,consecutiveFailures:0,unrecoverableSignalled:!1};return s(a),{stop(){h(a)}}}export{g as startLickWsBridge};
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{b as t,n,r,t as i,y as a}from"./kernel-worker-YTlCGWHk.js";const o=e(`lick-ws-bridge`);function s(e){if(e.stopped)return;let t;try{t=e.wsFactory(e.wsUrl)}catch(t){o.error(`Failed to construct lick WebSocket`,{url:e.wsUrl,error:t instanceof Error?t.message:String(t)}),c(e,`construct-threw`);return}e.socket=t,t.onopen=()=>{e.consecutiveFailures>0?o.info(`Lick WebSocket recovered`,{attempts:e.consecutiveFailures}):o.info(`Lick WebSocket connected`),e.consecutiveFailures=0,e.unrecoverableSignalled=!1},t.onmessage=n=>{u(e,t,n.data).catch(e=>{let t=typeof n.data==`string`?n.data.slice(0,200):`[non-string payload]`;o.error(`Failed to process lick message`,{error:e instanceof Error?e.message:String(e),preview:t})})},t.onclose=n=>{if(e.socket===t&&(e.socket=null),e.stopped)return;let r=n.reason?` reason=${JSON.stringify(n.reason)}`:``;c(e,`disconnected code=${n.code}${r}`)},t.onerror=t=>{let n=t.target;o.error(`Lick WebSocket error`,{url:e.wsUrl,readyState:n?.readyState,eventType:t.type})}}function c(e,t){if(e.reconnectHandle!=null){o.debug(`Lick WS failure during pending reconnect — keeping existing timer`,{cause:t});return}e.consecutiveFailures++;let n=Math.min(e.baseDelay*2**(e.consecutiveFailures-1),6e4),r={url:e.wsUrl,attempt:e.consecutiveFailures,cause:t,retryInMs:n};if(e.consecutiveFailures>=3?o.error(`Lick WebSocket still down`,r):o.warn(`Lick WebSocket down`,r),e.consecutiveFailures===20&&!e.unrecoverableSignalled){e.unrecoverableSignalled=!0;try{e.lickManager.emitEvent({type:`session-reload`,targetScoop:void 0,timestamp:new Date().toISOString(),body:{reason:`lick-ws-bridge-down`,url:e.wsUrl,attempts:e.consecutiveFailures}})}catch(e){o.error(`Failed to emit lick-ws-bridge-down signal`,{error:e instanceof Error?e.message:String(e)})}}l(e,n)}function l(e,t){e.stopped||e.reconnectHandle!=null||(e.reconnectHandle=e.setTimer(()=>{e.reconnectHandle=null,s(e)},t))}async function u(e,t,n){let r=JSON.parse(typeof n==`string`?n:String(n));if(r.requestId){let n=r.requestId,i=await p(e,r,n);if(e.stopped||e.socket!==t||t.readyState!==1){o.warn(`Lick reply dropped — socket changed/closed mid-request`,{type:r.type,requestId:n});return}try{t.send(JSON.stringify(i))}catch(e){o.error(`ws.send() failed delivering lick reply`,{type:r.type,requestId:n,error:e instanceof Error?e.message:String(e)})}return}if(r.type===`webhook_event`){d(e.lickManager,r);return}r.type===`navigate_event`&&f(e.lickManager,r)}function d(e,t){let n=typeof t.webhookId==`string`?t.webhookId:null;if(!n){o.error(`Malformed webhook_event from lick-ws`,{receivedKeys:Object.keys(t)});return}let r=t.headers&&typeof t.headers==`object`?t.headers:{};try{e.handleWebhookEvent(n,r,t.body)}catch(e){o.error(`Webhook event dispatch failed`,{webhookId:n,error:e instanceof Error?e.message:String(e)})}}function f(e,t){let n=typeof t.verb==`string`?t.verb:null,r=typeof t.target==`string`?t.target:null,i=typeof t.url==`string`&&t.url.length>0?t.url:null;if(n!==`handoff`&&n!==`upskill`||!r||!i){o.debug(`navigate_event dropped — invalid payload`,{hasVerb:!!n,hasTarget:!!r,hasUrl:!!i});return}let a={url:i,verb:n,target:r};typeof t.instruction==`string`&&(a.instruction=t.instruction),typeof t.branch==`string`&&(a.branch=t.branch),typeof t.path==`string`&&(a.path=t.path),typeof t.title==`string`&&(a.title=t.title),e.emitEvent({type:`navigate`,navigateUrl:i,targetScoop:void 0,timestamp:typeof t.timestamp==`string`?t.timestamp:new Date().toISOString(),body:a})}async function p(e,t,n){let{lickManager:r}=e;try{switch(t.type){case`list_webhooks`:return{type:`response`,requestId:n,data:r.listWebhooks().map(t=>({...t,url:m(e,t.id)}))};case`create_webhook`:{let i=await r.createWebhook(t.name||`default`,t.scoop,t.filter);return{type:`response`,requestId:n,data:{...i,url:m(e,i.id)}}}case`delete_webhook`:return await r.deleteWebhook(t.id)?{type:`response`,requestId:n,data:{ok:!0}}:{type:`response`,requestId:n,data:{error:`Webhook not found`}};case`list_crontasks`:return{type:`response`,requestId:n,data:r.listCronTasks()};case`create_crontask`:if(!t.name)throw Error(`name is required`);if(!t.cron)throw Error(`cron is required`);return{type:`response`,requestId:n,data:await r.createCronTask(t.name,t.cron,t.scoop,t.filter)};case`delete_crontask`:return await r.deleteCronTask(t.id)?{type:`response`,requestId:n,data:{ok:!0}}:{type:`response`,requestId:n,data:{error:`Cron task not found`}};case`tray_status`:{let e=a();return{type:`response`,requestId:n,data:{state:e.state,joinUrl:e.session?.joinUrl??null,workerBaseUrl:e.session?.workerBaseUrl??null,trayId:e.session?.trayId??null}}}default:return{type:`response`,requestId:n,error:`Unknown request type: ${t.type}`}}}catch(e){return{type:`response`,requestId:n,error:e instanceof Error?e.message:String(e)}}}function m(e,i){let a=t().session;return a?.webhookUrl?n(a.webhookUrl,i):e.webhookOriginOverride?`${e.webhookOriginOverride}/webhooks/${i}`:r(e.options.locationHref,i)}function h(e){if(e.stopped)return;e.stopped=!0,e.reconnectHandle!=null&&(e.clearTimer(e.reconnectHandle),e.reconnectHandle=null);let t=e.socket;if(e.socket=null,t)try{t.close()}catch(e){t.readyState!==3&&t.readyState!==2&&o.warn(`Lick socket close() threw before terminal state`,{readyState:t.readyState,error:e instanceof Error?e.message:String(e)})}}function g(e,t){try{new URL(t.locationHref)}catch(e){throw Error(`startLickWsBridge: invalid locationHref ${JSON.stringify(t.locationHref)}: ${e instanceof Error?e.message:String(e)}`)}let n=typeof t.lickWsUrl==`string`&&t.lickWsUrl.length>0?t.lickWsUrl:i(t.locationHref),r=null;if(typeof t.lickWsUrl==`string`&&t.lickWsUrl.length>0)try{let e=new URL(t.lickWsUrl);r=`${e.protocol===`wss:`?`https:`:`http:`}//${e.host}`}catch{r=null}let a={lickManager:e,options:t,wsUrl:n,webhookOriginOverride:r,baseDelay:t.reconnectDelayMs??3e3,wsFactory:t.webSocketFactory??(e=>new WebSocket(e)),setTimer:t.setTimeoutFn??setTimeout.bind(globalThis),clearTimer:t.clearTimeoutFn??clearTimeout.bind(globalThis),stopped:!1,socket:null,reconnectHandle:null,consecutiveFailures:0,unrecoverableSignalled:!1};return s(a),{stop(){h(a)}}}export{g as startLickWsBridge};
@@ -1,2 +1,2 @@
1
- import{u as e}from"./dist-BmWy99kl.js";import{n as t}from"./event-stream-BJI_nGaK.js";import{b as n}from"./account-store-D8YLtENA.js";import{t as r}from"./logger-DDBAeTLF.js";import{streamOpenAICompletions as i,streamSimpleOpenAICompletions as a}from"./openai-completions-DLI0t_lj.js";var o=r(`local-llm`),s=`local-llm`,c=`local`,l=`${s}-unconfigured`,u={id:s,name:`Local LLM (OpenAI-compatible)`,description:[`Connect to any OpenAI-compatible local model server.`,``,`Common base URLs:`,` • Ollama http://localhost:11434/v1`,` • LM Studio http://localhost:1234/v1`,` • llama.cpp http://localhost:8080/v1`,` • vLLM http://localhost:8000/v1`,` • mlx_lm http://localhost:8080/v1`,` • Jan http://localhost:1337/v1`,``,`Ollama needs OLLAMA_ORIGINS=* (or chrome-extension://*) so the`,`browser can reach it. macOS: launchctl setenv OLLAMA_ORIGINS "*".`].join(`
1
+ import{u as e}from"./dist-BmWy99kl.js";import{n as t}from"./event-stream-BJI_nGaK.js";import{b as n}from"./account-store-CeSn6D5H.js";import{t as r}from"./logger-DDBAeTLF.js";import{streamOpenAICompletions as i,streamSimpleOpenAICompletions as a}from"./openai-completions-DLI0t_lj.js";var o=r(`local-llm`),s=`local-llm`,c=`local`,l=`${s}-unconfigured`,u={id:s,name:`Local LLM (OpenAI-compatible)`,description:[`Connect to any OpenAI-compatible local model server.`,``,`Common base URLs:`,` • Ollama http://localhost:11434/v1`,` • LM Studio http://localhost:1234/v1`,` • llama.cpp http://localhost:8080/v1`,` • vLLM http://localhost:8000/v1`,` • mlx_lm http://localhost:8080/v1`,` • Jan http://localhost:1337/v1`,``,`Ollama needs OLLAMA_ORIGINS=* (or chrome-extension://*) so the`,`browser can reach it. macOS: launchctl setenv OLLAMA_ORIGINS "*".`].join(`
2
2
  `),requiresApiKey:!1,optionalApiKey:!0,apiKeyPlaceholder:`Leave empty for local servers, or paste a key for hosted endpoints`,apiKeyEnvVar:`LOCAL_LLM_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`http://localhost:11434/v1`,baseUrlDescription:`Ollama: 11434 • LM Studio: 1234 • llama.cpp/mlx: 8080 • vLLM: 8000 • Jan: 1337. Trailing /v1 required.`,requiresDeployment:!0,deploymentPlaceholder:`llama3.1:8b, qwen2.5-coder:14b`,deploymentDescription:`Comma-separated model IDs from your server. List them with: curl <baseUrl>/models | jq -r .data[].id`,getModelIds:()=>{let e=d(n(s));return e.length===0?[{id:l,name:`Local LLM (set base URL + model IDs in Settings)`,api:`openai`}]:e.map(e=>({id:e,name:e,api:`openai`,input:[`text`],context_window:32e3,max_tokens:4096}))}};function d(e){return e?e.split(`,`).map(e=>e.trim()).filter(Boolean):[]}var f=`openai-completions`,p=`${s}-openai`;function m(e){return{...e,api:f}}function h(e){let t=e??{};return!t.apiKey||t.apiKey.length===0?{...t,apiKey:c}:t}var g=(e,t,n={})=>e.id===l?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?i(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`),_=(e,t,n)=>e.id===l?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?a(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`);function v(e,n){let r=t(),i={role:`assistant`,content:[],api:e.api,provider:e.provider,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:n,timestamp:Date.now()};return queueMicrotask(()=>{r.push({type:`error`,reason:`error`,error:i}),r.end()}),r}function y(){e({api:p,stream:g,streamSimple:_})}function b(e){try{let t=new URL(e);return`${t.protocol}//${t.host}`}catch{return e.replace(/\/v1\/?$/,``).replace(/\/+$/,``)}}function x(e){let t=e.replace(/\/+$/,``);try{let e=new URL(t);if(e.pathname===``||e.pathname===`/`)return`${t}/v1`}catch{}return t}async function S(e,t,n){let r=`${x(e)}/models`,i={Accept:`application/json`};t&&t.length>0&&(i.Authorization=`Bearer ${t}`);let a=await fetch(r,{method:`GET`,headers:i,signal:n});if(!a.ok)throw Error(`GET ${r} -> ${a.status} ${a.statusText}`);let o=await a.json();return Array.isArray(o.data)?o.data.map(e=>e.id??``).filter(e=>e.length>0):[]}async function C(e,t){let n=b(e),r=await T(`${n}/api/version`,t);if(r&&typeof r.version==`string`)return{kind:`ollama`,version:r.version};let i=await T(`${n}/api/v0/models`,t);if(i&&i.object===`list`)return{kind:`lmstudio`};let a=await T(`${n}/props`,t);if(a&&`build_info`in a)return{kind:`llamacpp`,version:a.build_info?.version};let o=w(e);return o===`11434`?{kind:`ollama`}:o===`1234`?{kind:`lmstudio`}:o===`8000`?{kind:`vllm`}:o===`1337`?{kind:`jan`}:{kind:`unknown`}}function w(e){try{return new URL(e).port||null}catch{return null}}async function T(e,t){try{let n=await fetch(e,{method:`GET`,signal:t});return n.ok?await n.json():null}catch{return null}}async function E(e,t,n){let r={kind:`unknown`};try{r=await C(e,n)}catch{}try{let i=await S(e,t,n);return{ok:!0,runtime:r,models:i}}catch(t){let n=t instanceof Error?t.message:String(t),i=D(n,r.kind);return o.warn(`verifyConnection failed`,{baseUrl:e,runtime:r.kind,message:n}),{ok:!1,runtime:r,models:[],error:i}}}function D(e,t){let n=e.toLowerCase();return n.includes(`failed to fetch`)||n.includes(`networkerror`)?t===`ollama`?{kind:`cors`,message:e,hint:'Ollama rejects requests from non-localhost origins by default. Set OLLAMA_ORIGINS=* (or chrome-extension://*) and restart Ollama. macOS: `launchctl setenv OLLAMA_ORIGINS "*"` then quit and relaunch the Ollama app.'}:{kind:`connection`,message:e,hint:`Server unreachable. Check the URL and that the server is running.`}:n.includes(` 401`)||n.includes(` 403`)?{kind:`auth`,message:e,hint:`Server returned an auth error. If your endpoint requires a key, set it in Settings.`}:/-> \d{3} /.test(e)?{kind:`http`,message:e}:{kind:`unknown`,message:e}}export{u as config,C as detectRuntime,S as discoverModels,b as originOf,y as register,E as verifyConnection};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sudo-C--ZFBWF.js","assets/preload-helper-zJ_50EbN.js","assets/logger-DDBAeTLF.js","assets/proxied-fetch-CKDBmEMl.js","assets/chunk-aKtaBQYM.js","assets/fetch-body-D2PwksUW.js","assets/panel-responder-BKgfV-nl.js","assets/quick-llm-CtmD_Eqd.js","assets/account-store-D8YLtENA.js","assets/dist-BmWy99kl.js","assets/event-stream-BJI_nGaK.js","assets/json-parse-BUunmmNl.js","assets/__vite-browser-external-C7iut881.js","assets/context-compaction-CFWyOzX1.js","assets/src-DlEHAkLd.js","assets/secret-topology-bwXIzzAK.js","assets/secrets-bridge-client-BSipj-5f.js","assets/panel-rpc-DqT2FG7c.js","assets/bedrock-camp-9-QEmC9Z.js","assets/transform-messages-DzB_lMo-.js","assets/tool-ui-DfXu6quJ.js","assets/icons-BU6llBsN.js","assets/llm-session-id-DVmZ9C2t.js","assets/cdp-z9uzg44m.js","assets/remote-cdp-transport-Cf0sDZ5N.js","assets/main-cherry-BRV9Q0tu.js","assets/extension-bridge-transport-DYOF2OYC.js","assets/cdp-bridge-CUqQUcaF.js","assets/oauth-service-YGl8VFS-.js","assets/wc-permissions-registry-CR1rTd2H.js","assets/wc-shell-DeV6jP6H.js","assets/soundscape-cues-5_sT5Un6.js","assets/speech-CqQdPtyQ.js","assets/wc-shell-WkeczD9x.css","assets/oauth-bootstrap-BjTCYMG8.js","assets/legacy-styles-4PP74ISo.js","assets/connect-surface-CvI6NTHs.js","assets/wc-extension-Bt6WVUQv.js","assets/wc-live-C6obLPXQ.js","assets/hid-device-registry-D2LsJCRr.js","assets/usb-operations-CkcrNzZw.js","assets/serial-port-registry-Bc4wlwED.js","assets/usb-device-registry-BP58Vi0S.js","assets/sprinkle-bridge-Du2dCM8G.js","assets/shared-Bn9ltvMZ.js","assets/mime-types-ugOWOUZ9.js","assets/path-utils-DU6QhF_k.js","assets/sprinkle-renderer-GiRRbdBx.js","assets/theme-BBwuyzvz.js","assets/wc-detached-DPpzG1m4.js"])))=>i.map(i=>d[i]);
2
- import{n as e}from"./chunk-aKtaBQYM.js";import"./modulepreload-polyfill-Dezn_h7o.js";import{t}from"./preload-helper-zJ_50EbN.js";import{A as n,B as r,C as i,D as a,E as o,F as s,H as c,I as l,L as u,M as d,N as f,O as p,P as m,R as h,S as g,T as _,U as v,V as y,W as b,_ as x,a as S,b as C,c as ee,d as w,f as te,g as ne,h as re,i as T,j as ie,k as ae,l as oe,m as se,n as ce,o as le,p as ue,q as de,s as fe,t as pe,u as me,v as he,w as ge,x as _e,y as ve,z as ye}from"./account-store-D8YLtENA.js";import{t as E}from"./logger-DDBAeTLF.js";import{a as be,c as xe,o as Se,s as Ce,t as we}from"./proxied-fetch-CKDBmEMl.js";import{n as Te}from"./clipboard-DgFtRQbq.js";var Ee=`bridge`,De=`bridgeToken`,Oe=`role`,ke=`slicc.bridge.v1.`;function Ae(e){try{let t=new URL(e);return`${t.protocol===`wss:`?`https:`:`http:`}//${t.host}`}catch{return null}}function je(e){try{let t=new URL(e);return`${t.protocol}//${t.host}/licks-ws`}catch{return null}}function D(e){let t;try{t=new URLSearchParams(e)}catch{return null}let n=t.get(Ee),r=t.get(De);if(!n||!r||!/^wss?:\/\//.test(n))return null;let i=t.get(Oe),a=i===`leader`||i===`follower`?i:null;return{url:n,subprotocol:`${ke}${r}`,token:r,apiBaseUrl:Ae(n),lickWsUrl:je(n),role:a}}function Me(e){return typeof e==`object`&&!!e&&`source`in e&&`payload`in e&&typeof e.source==`string`}var Ne=`slicc:bridge-config`,Pe=`slicc:extension-delegate-config`;function Fe(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`slicc:ext-fetch`&&typeof t.extensionId==`string`&&!!t.request&&typeof t.request==`object`}var Ie=E(`boot/ext-fetch-delegate`);function Le(){let e=globalThis.chrome?.runtime;return e&&typeof e.connect==`function`?e:null}function Re(e,t,n){let r=Le();if(!r){try{t.postMessage({type:`response-error`,error:`extension-delegate: chrome.runtime.connect unavailable`})}catch{}t.close();return}let i=e.extensionId||n,a;try{a=r.connect(i,{name:`fetch-proxy.fetch`})}catch(e){try{t.postMessage({type:`response-error`,error:`extension-delegate: connect failed — ${e instanceof Error?e.message:String(e)}`})}catch{}t.close();return}let o=!1,s=()=>{o=!0;try{a.disconnect()}catch{}try{t.close()}catch{}};a.onMessage.addListener(e=>{if(o)return;let n=e;try{t.postMessage(n)}catch{}(n.type===`response-end`||n.type===`response-error`)&&s()}),a.onDisconnect.addListener(()=>{if(!o){try{t.postMessage({type:`response-error`,error:`extension-delegate: fetch-proxy port disconnected`})}catch{}s()}}),a.postMessage({type:`request`,...e.request})}function ze(e){typeof navigator>`u`||!navigator.serviceWorker||navigator.serviceWorker.addEventListener(`message`,t=>{if(!Fe(t.data))return;let n=t.ports?.[0];if(!n){Ie.warn(`delegated fetch envelope arrived without a response port`);return}Re(t.data,n,e)})}function Be(){if(typeof chrome<`u`&&chrome?.runtime?.id)return;let e=new Blob([`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sudo-zd7NVwiq.js","assets/preload-helper-zJ_50EbN.js","assets/logger-DDBAeTLF.js","assets/proxied-fetch-CKDBmEMl.js","assets/chunk-aKtaBQYM.js","assets/fetch-body-D2PwksUW.js","assets/panel-responder-BKgfV-nl.js","assets/quick-llm-BcoHwyQn.js","assets/account-store-CeSn6D5H.js","assets/dist-BmWy99kl.js","assets/event-stream-BJI_nGaK.js","assets/json-parse-BUunmmNl.js","assets/__vite-browser-external-C7iut881.js","assets/context-compaction-CFWyOzX1.js","assets/src-DlEHAkLd.js","assets/secret-topology-bwXIzzAK.js","assets/secrets-bridge-client-BSipj-5f.js","assets/panel-rpc-DqT2FG7c.js","assets/bedrock-camp-9-QEmC9Z.js","assets/transform-messages-DzB_lMo-.js","assets/tool-ui-DfXu6quJ.js","assets/icons-BU6llBsN.js","assets/llm-session-id-DVmZ9C2t.js","assets/cdp-z9uzg44m.js","assets/remote-cdp-transport-Cf0sDZ5N.js","assets/main-cherry-BRV9Q0tu.js","assets/extension-bridge-transport-DYOF2OYC.js","assets/cdp-bridge-CUqQUcaF.js","assets/oauth-service-YGl8VFS-.js","assets/wc-permissions-registry-CR1rTd2H.js","assets/wc-shell-F5Wp6J-I.js","assets/soundscape-cues-5_sT5Un6.js","assets/speech-CqQdPtyQ.js","assets/wc-shell-WkeczD9x.css","assets/oauth-bootstrap-Bsf5hex-.js","assets/legacy-styles-4PP74ISo.js","assets/connect-surface-BHwPGe-M.js","assets/wc-extension-Bp34NH6Q.js","assets/wc-live-DOXieP5u.js","assets/hid-device-registry-D2LsJCRr.js","assets/usb-operations-CkcrNzZw.js","assets/serial-port-registry-Bc4wlwED.js","assets/usb-device-registry-BP58Vi0S.js","assets/sprinkle-bridge-Du2dCM8G.js","assets/shared-Bn9ltvMZ.js","assets/mime-types-ugOWOUZ9.js","assets/path-utils-DU6QhF_k.js","assets/sprinkle-renderer-GiRRbdBx.js","assets/theme-BBwuyzvz.js","assets/wc-detached-Ba7UK8gf.js"])))=>i.map(i=>d[i]);
2
+ import{n as e}from"./chunk-aKtaBQYM.js";import"./modulepreload-polyfill-Dezn_h7o.js";import{t}from"./preload-helper-zJ_50EbN.js";import{A as n,B as r,C as i,D as a,E as o,F as s,H as c,I as l,L as u,M as d,N as f,O as p,P as m,R as h,S as g,T as _,U as v,V as y,W as b,_ as x,a as S,b as C,c as ee,d as w,f as te,g as ne,h as re,i as T,j as ie,k as ae,l as oe,m as se,n as ce,o as le,p as ue,q as de,s as fe,t as pe,u as me,v as he,w as ge,x as _e,y as ve,z as ye}from"./account-store-CeSn6D5H.js";import{t as E}from"./logger-DDBAeTLF.js";import{a as be,c as xe,o as Se,s as Ce,t as we}from"./proxied-fetch-CKDBmEMl.js";import{n as Te}from"./clipboard-DgFtRQbq.js";var Ee=`bridge`,De=`bridgeToken`,Oe=`role`,ke=`slicc.bridge.v1.`;function Ae(e){try{let t=new URL(e);return`${t.protocol===`wss:`?`https:`:`http:`}//${t.host}`}catch{return null}}function je(e){try{let t=new URL(e);return`${t.protocol}//${t.host}/licks-ws`}catch{return null}}function D(e){let t;try{t=new URLSearchParams(e)}catch{return null}let n=t.get(Ee),r=t.get(De);if(!n||!r||!/^wss?:\/\//.test(n))return null;let i=t.get(Oe),a=i===`leader`||i===`follower`?i:null;return{url:n,subprotocol:`${ke}${r}`,token:r,apiBaseUrl:Ae(n),lickWsUrl:je(n),role:a}}function Me(e){return typeof e==`object`&&!!e&&`source`in e&&`payload`in e&&typeof e.source==`string`}var Ne=`slicc:bridge-config`,Pe=`slicc:extension-delegate-config`;function Fe(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`slicc:ext-fetch`&&typeof t.extensionId==`string`&&!!t.request&&typeof t.request==`object`}var Ie=E(`boot/ext-fetch-delegate`);function Le(){let e=globalThis.chrome?.runtime;return e&&typeof e.connect==`function`?e:null}function Re(e,t,n){let r=Le();if(!r){try{t.postMessage({type:`response-error`,error:`extension-delegate: chrome.runtime.connect unavailable`})}catch{}t.close();return}let i=e.extensionId||n,a;try{a=r.connect(i,{name:`fetch-proxy.fetch`})}catch(e){try{t.postMessage({type:`response-error`,error:`extension-delegate: connect failed — ${e instanceof Error?e.message:String(e)}`})}catch{}t.close();return}let o=!1,s=()=>{o=!0;try{a.disconnect()}catch{}try{t.close()}catch{}};a.onMessage.addListener(e=>{if(o)return;let n=e;try{t.postMessage(n)}catch{}(n.type===`response-end`||n.type===`response-error`)&&s()}),a.onDisconnect.addListener(()=>{if(!o){try{t.postMessage({type:`response-error`,error:`extension-delegate: fetch-proxy port disconnected`})}catch{}s()}}),a.postMessage({type:`request`,...e.request})}function ze(e){typeof navigator>`u`||!navigator.serviceWorker||navigator.serviceWorker.addEventListener(`message`,t=>{if(!Fe(t.data))return;let n=t.ports?.[0];if(!n){Ie.warn(`delegated fetch envelope arrived without a response port`);return}Re(t.data,n,e)})}function Be(){if(typeof chrome<`u`&&chrome?.runtime?.id)return;let e=new Blob([`
3
3
  let lastPong = Date.now();
4
4
  let frozen = false;
5
5
  setInterval(() => {
@@ -19,6 +19,6 @@ import{n as e}from"./chunk-aKtaBQYM.js";import"./modulepreload-polyfill-Dezn_h7o
19
19
  }
20
20
  }
21
21
  };
22
- `],{type:`application/javascript`}),t=URL.createObjectURL(e),n=new Worker(t);URL.revokeObjectURL(t),n.onmessage=e=>{if(e.data.type===`ping`)n.postMessage({type:`pong`});else if(e.data.type===`freeze-detected`)console.error(`[freeze-watchdog] Main thread blocked for ${e.data.elapsed}ms — capturing trace on recovery`);else if(e.data.type===`freeze-recovered`){console.error(`[freeze-watchdog] Main thread recovered. Stack trace at recovery point:`),console.trace(`[freeze-watchdog] recovery stack`);let e=performance.getEntriesByType(`longtask`);e.length>0&&console.error(`[freeze-watchdog] Long tasks:`,e.map(e=>({duration:e.duration,startTime:e.startTime,name:e.name})))}},window.addEventListener(`beforeunload`,()=>{n.terminate()},{once:!0})}var Ve=`slicc-nuke-control`;function He(e=()=>location.reload()){if(typeof BroadcastChannel!=`function`)return()=>{};let t=new BroadcastChannel(Ve),n=t=>{let n=t.data;if(n?.type===`nuke-reload`){if(Array.isArray(n.keysToRemove)){for(let e of n.keysToRemove)if(typeof e==`string`)try{localStorage.removeItem(e)}catch{}}e()}};return t.addEventListener(`message`,n),()=>{t.removeEventListener(`message`,n),t.close()}}var O=null;function Ue(){return O||(O=He(),O)}var We=`tray`,Ge=`trayWorkerUrl`,Ke=`lead`;function k(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``,t.pathname!==`/`&&(t.pathname=t.pathname.replace(/\/+$/,``)||`/`);let n=t.toString();return n.endsWith(`/`)?n.slice(0,-1):n}catch{return null}}function qe(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``;let n=t.toString(),r=t.pathname.split(`/`).filter(Boolean);if(r.length<2||r.at(-2)!==`join`)return null;let[i,a,...o]=decodeURIComponent(r.at(-1)).split(`.`);if(!i||!a||o.length>0)return null;r.splice(-2,2),t.pathname=r.length>0?`/${r.join(`/`)}`:`/`;let s=k(t.toString());return s?{workerBaseUrl:s,trayId:i,joinUrl:n}:null}catch{return null}}function Je(e,t){let n=new URL(e);return n.searchParams.delete(Ge),n.searchParams.delete(Ke),n.searchParams.set(We,t),n.toString()}var A=`slicc.trayWorkerBaseUrl`,j=`slicc.trayJoinUrl`,Ye=`https://www.sliccy.ai`;function Xe(e,t){let n=k(e);if(!n)throw Error(`Invalid tray worker base URL: ${e}`);let r=t.replace(/^\/+/,``);return new URL(r,`${n}/`).toString()}function M(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``;let n=t.pathname.split(`/`).filter(Boolean),r=null;if(n.length>=2&&n.at(-2)===`tray`)r=decodeURIComponent(n.at(-1)),n.splice(-2,2),t.pathname=n.length>0?`/${n.join(`/`)}`:`/`;else if(n.length>=2&&n.at(-2)===`join`)return qe(t.toString());let i=k(t.toString());return i?{workerBaseUrl:i,trayId:r,joinUrl:null}:null}catch{return null}}function N(e){let t=M(e);return t?.joinUrl?t:null}function Ze(e,t){let n=N(t);return n?(e.setItem(j,n.joinUrl),e.setItem(A,n.workerBaseUrl),n):null}function Qe(e){return!!N(e?.getItem(`slicc.trayJoinUrl`)??null)}function $e(e,t){let n=k(e);if(!n)throw Error(`Invalid tray worker base URL: ${e}`);let r=t?.trim();return r?new URL(`tray/${encodeURIComponent(r)}`,`${n}/`).toString():n}function et(e,t,n){return Je(e,$e(t,n))}async function P(e){let t=rt(e.locationHref);if(t)return e.storage&&(t.joinUrl&&e.storage.setItem(j,t.joinUrl),e.storage.setItem(A,t.workerBaseUrl)),t;let n=N(e.storage?.getItem(`slicc.trayJoinUrl`)??null);if(n)return e.storage&&e.storage.setItem(A,n.workerBaseUrl),n;let r=e.runtimeConfigFetcher?await it(e.runtimeConfigFetcher):null;if(r?.joinConfig)return e.storage&&(e.storage.setItem(j,r.joinConfig.joinUrl),e.storage.setItem(A,r.joinConfig.workerBaseUrl)),r.joinConfig;let i=r?.workerBaseUrl??null,a=k(e.storage?.getItem(`slicc.trayWorkerBaseUrl`)??null),o=k(e.envBaseUrl??null),s=k(e.defaultWorkerBaseUrl??null),c=i??a??o??s;return c?(e.storage&&e.storage.setItem(A,c),{workerBaseUrl:c,trayId:null,joinUrl:null}):null}async function tt(e){return(await P(e))?.workerBaseUrl??null}async function nt(e=fetch){try{let t=await e(be(`/api/runtime-config`),{cache:`no-store`,headers:we()});return t.ok?await t.json():null}catch{return null}}function rt(e){try{let t=new URL(e),n=M(t.searchParams.get(We));if(n)return n;let r=M(t.searchParams.get(Ke));if(r)return r;let i=k(t.searchParams.get(Ge));return i?{workerBaseUrl:i,trayId:null,joinUrl:null}:qe(e)||null}catch{return null}}async function it(e){let t=await e();if(!t)return null;let n=N(t.trayJoinUrl??null);return{workerBaseUrl:k(t.trayWorkerBaseUrl??null),joinConfig:n}}var at=`slicc-cdp-superseded-banner`;function ot(e){if(e.getElementById(at))return;let t=e.createElement(`div`);t.id=at,t.setAttribute(`role`,`alert`),t.textContent=`Another SLICC tab or window has taken control of this browser instance. Only one tab can drive the browser per instance — close the other tabs, then reload this page to resume.`,t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`right:0`,`z-index:2147483647`,`padding:10px 16px`,`background:#b3261e`,`color:#fff`,`font:13px/1.4 system-ui,sans-serif`,`text-align:center`,`box-shadow:0 1px 4px rgba(0,0,0,0.3)`].join(`;`),e.body.appendChild(t)}new Set([{id:`chat`,label:`Chat`},{id:`terminal`,label:`Terminal`},{id:`files`,label:`Files`},{id:`memory`,label:`Memory`}].map(e=>e.id));function st(e,t){if(t){try{if(new URL(e).searchParams.get(`detached`)===`1`)return`extension-detached`}catch{}return`extension`}try{let t=new URL(e);return t.searchParams.get(`connect`)===`1`?`connect`:t.searchParams.get(`runtime`)===`hosted-leader`?`hosted-leader`:t.searchParams.get(`cherry`)===`1`?`cherry`:lt(t)?`electron-overlay`:`standalone`}catch{return`standalone`}}function ct(e,t){return e===`electron-overlay`||e===`hosted-leader`||e===`standalone`&&t}function lt(e){return e.pathname===`/electron`||e.pathname===`/electron/`||e.searchParams.get(`runtime`)===`electron-overlay`}var ut=e({setupSudoExtension:()=>ft,setupSudoStandalone:()=>dt});async function dt(e){let{installSudoTestHook:n}=await t(async()=>{let{installSudoTestHook:e}=await import(`./sudo-C--ZFBWF.js`);return{installSudoTestHook:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]));n()}async function ft(e){let{installPanelSudoResponder:n}=await t(async()=>{let{installPanelSudoResponder:e}=await import(`./sudo-C--ZFBWF.js`);return{installPanelSudoResponder:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]));n()}function pt(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`slicc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function mt(e){let t;try{t=new URLSearchParams(e)}catch{return null}if(t.get(`slicc`)!==`leader`)return null;let n=t.get(`ext`);return n?{extensionId:n}:null}function F(){return typeof globalThis.chrome?.runtime?.connect==`function`}var ht=[100,200,400,800,1600];async function gt(e,t,n,r=ht,i=e=>new Promise(t=>setTimeout(t,e))){let a=r.length+1,o=null;for(let s=0;s<a;s++)try{await e.connect(t),s>0&&n.info(`CDP bridge connect succeeded after retry`,{attempt:s+1});return}catch(e){o=e,s<r.length&&await i(r[s]??0)}n.warn(`Initial CDP connect failed after retries; worker-forwarded commands will retry on demand`,o instanceof Error?o.message:String(o))}async function _t(e){let{runtimeMode:n,envBaseUrl:r,window:i,log:a}=e,o=n===`electron-overlay`;a.info(`starting standalone with kernel worker`);let{BrowserAPI:s}=await t(async()=>{let{BrowserAPI:e}=await import(`./cdp-z9uzg44m.js`);return{BrowserAPI:e}},__vite__mapDeps([23,1,24,2]));await dt({log:a});let c,l,u,d=null,f=null,p=null,m=null,h=n===`cherry`?null:mt(i.location.search),g=!!h&&F(),_=n===`cherry`||g?null:D(i.location.search);_?.apiBaseUrl&&(d=_.apiBaseUrl,xe(_.apiBaseUrl),f=_.token,Se(_.token)),_?.lickWsUrl&&(p=_.lickWsUrl);let v=await nt(),y=ct(o?`electron-overlay`:`standalone`,v!==null)?Ye:null;if(await P({locationHref:i.location.href,storage:i.localStorage,envBaseUrl:r,defaultWorkerBaseUrl:y,runtimeConfigFetcher:async()=>v}),n===`cherry`){let{setupCherryFollower:e}=await t(async()=>{let{setupCherryFollower:e}=await import(`./main-cherry-BRV9Q0tu.js`);return{setupCherryFollower:e}},__vite__mapDeps([25,23,1,24,2])),n=await e();c=n.browser,l=n.joinUrl,u=n.transport}else if(h&&F()){a.info(`Routing CDP through the extension bridge (leader tab)`);let{ExtensionBridgeTransport:e}=await t(async()=>{let{ExtensionBridgeTransport:e}=await import(`./extension-bridge-transport-DYOF2OYC.js`);return{ExtensionBridgeTransport:e}},__vite__mapDeps([26,2,27]));c=new s(new e({extensionId:h.extensionId})),await gt(c,void 0,a),m=h.extensionId,Ce(h.extensionId)}else{c=new s,_&&a.info(`Routing CDP through local standalone bridge`,{url:_.url,role:_.role??`(unset)`});let e=_?{url:_.url,protocols:_.subprotocol}:void 0;_?.role===`follower`?(a.info(`Skipping CDP connect for follower overlay tab`),c.primeConnectOptions(e)):(await gt(c,e,a),c.setCdpSupersededHandler(()=>ot(i.document)))}let b=c.getTransport();return globalThis.__slicc_browser=c,{browser:c,realCdpTransport:b,cherryJoinUrl:l,cherryTransport:u,instanceId:pt(),isElectronOverlay:o,localApiBaseUrl:d,bridgeToken:f,localLickWsUrl:p,extensionDelegateId:m}}var I=E(`boot/sw-registration`);async function vt(e=null,t=null){let n=(()=>{try{return new URL(window.location.href).searchParams.get(`connect`)===`1`}catch{return!1}})();if(`serviceWorker`in navigator&&n&&await yt())return`reload-pending`;if(!(`serviceWorker`in navigator)||n)return`ready`;try{if(await navigator.serviceWorker.register(`/preview-sw.js`,{scope:`/preview/`}),I.info(`Preview SW registered`),!(typeof chrome<`u`&&chrome?.runtime?.id))try{await navigator.serviceWorker.register(`/llm-proxy-sw.js`,{scope:`/`}),I.info(`LLM-proxy SW registered`)}catch(e){I.error(`LLM-proxy SW registration failed — cross-origin LLM calls will hit CORS`,e)}if(navigator.serviceWorker.controller||await Promise.race([new Promise(e=>navigator.serviceWorker.addEventListener(`controllerchange`,()=>e(),{once:!0})),new Promise(e=>setTimeout(e,1500))]),!navigator.serviceWorker.controller&&!sessionStorage.getItem(`slicc-sw-reloaded`))return sessionStorage.setItem(`slicc-sw-reloaded`,`1`),I.info(`Reloading once to gain SW control`),location.reload(),`reload-pending`;sessionStorage.removeItem(`slicc-sw-reloaded`),e&&(L(e),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{L(e)})),t&&(R(t),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{R(t)}))}catch(e){I.error(`Preview SW registration failed — preview feature will not work`,e)}return`ready`}function L(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:Ne,apiBaseUrl:e.apiBaseUrl,token:e.token};try{t.postMessage(n)}catch(e){I.warn(`LLM-proxy SW bridge-config postMessage failed`,e)}}function R(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:Pe,extensionId:e.extensionId};try{t.postMessage(n)}catch(e){I.warn(`LLM-proxy SW extension-delegate postMessage failed`,e)}}async function yt(){try{let e=await navigator.serviceWorker.getRegistrations();if(await Promise.all(e.map(e=>e.unregister().catch(()=>!1))),navigator.serviceWorker.controller&&!sessionStorage.getItem(`slicc-connect-sw-cleared`))return sessionStorage.setItem(`slicc-connect-sw-cleared`,`1`),I.info(`connect mode: detaching from service worker (no proxy on worker origin)`),location.reload(),!0;sessionStorage.removeItem(`slicc-connect-sw-cleared`)}catch(e){I.error(`connect-mode SW cleanup failed`,e)}return!1}var z={state:`inactive`,joinUrl:null,trayId:null,error:null,lastPingTime:null,reconnectAttempts:0,attachAttempts:0,lastAttachCode:null,connectingSince:null,lastError:null};function B(){return{...z}}var bt=new Set;function xt(){if(bt.size!==0)for(let e of[...bt])try{e({...z})}catch{}}function St(e){z={...e},xt()}function Ct(e){z={...z,lastPingTime:e},xt()}var V=null,wt=!1;function Tt(){return typeof window>`u`||typeof document>`u`||document?.documentElement===void 0||typeof localStorage?.getItem!=`function`}function Et(){return Tt()?`standalone-worker`:typeof chrome<`u`&&chrome?.runtime?.id?`extension`:typeof document<`u`&&document.documentElement?.dataset?.electronOverlay?`electron`:`cli`}async function Dt(){if(!wt&&!(typeof localStorage<`u`&&typeof localStorage?.getItem==`function`&&localStorage.getItem(`telemetry-disabled`)===`true`))try{let e=Et();e!==`standalone-worker`&&typeof window<`u`?window.RUM_GENERATION=`slicc-${e}`:globalThis.RUM_GENERATION=`slicc-${e}`,e===`standalone-worker`?(V=(await t(()=>import(`./rum-worker-CwmNSpjO.js`),[])).default,self.addEventListener(`error`,e=>{let t=e;H(`js`,t.error?.message??t.message??``)}),self.addEventListener(`unhandledrejection`,e=>{let t=e.reason;H(`js`,t instanceof Error?t.message:String(t))})):e===`extension`?(V=(await t(()=>import(`./rum-DW84CvBs.js`),[])).default,typeof window<`u`&&(window.addEventListener(`error`,e=>{let t=e;H(`js`,t.error?.message??t.message??``)}),window.addEventListener(`unhandledrejection`,e=>{let t=e.reason;H(`js`,t instanceof Error?t.message:String(t))}))):(typeof window<`u`&&(window.SAMPLE_PAGEVIEWS_AT_RATE=`high`),Lt(),V=(await t(()=>import(`./src-C9oNvq2b.js`),[])).sampleRUM),wt=!0,V&&V(`navigate`,{source:typeof document<`u`?document.referrer:``,target:e})}catch{}}function Ot(e,t){V?.(`formsubmit`,{source:e,target:t})}function kt(e){V?.(`viewblock`,{source:e})}function At(e){V?.(`viewmedia`,{source:e})}function H(e,t){let n=t;if(typeof n==`string`){let e=Nt(n);if(e===null)return;n=e}V?.(`error`,{source:e,target:n})}function jt(e){V?.(`signup`,{source:e})}function Mt(e){return e.includes(`@vite/client`)||e.includes(`@vite/env`)||e.includes(`[vite]`)||/https?:\/\/localhost:\d+\/@vite\//.test(e)||/\/__vite_ping/.test(e)}function Nt(e){let t=e??``;if(t.includes(`@vite/`)||t.includes(`[vite]`)||t.includes(`__vite_ping`)){let e=t.split(`
22
+ `],{type:`application/javascript`}),t=URL.createObjectURL(e),n=new Worker(t);URL.revokeObjectURL(t),n.onmessage=e=>{if(e.data.type===`ping`)n.postMessage({type:`pong`});else if(e.data.type===`freeze-detected`)console.error(`[freeze-watchdog] Main thread blocked for ${e.data.elapsed}ms — capturing trace on recovery`);else if(e.data.type===`freeze-recovered`){console.error(`[freeze-watchdog] Main thread recovered. Stack trace at recovery point:`),console.trace(`[freeze-watchdog] recovery stack`);let e=performance.getEntriesByType(`longtask`);e.length>0&&console.error(`[freeze-watchdog] Long tasks:`,e.map(e=>({duration:e.duration,startTime:e.startTime,name:e.name})))}},window.addEventListener(`beforeunload`,()=>{n.terminate()},{once:!0})}var Ve=`slicc-nuke-control`;function He(e=()=>location.reload()){if(typeof BroadcastChannel!=`function`)return()=>{};let t=new BroadcastChannel(Ve),n=t=>{let n=t.data;if(n?.type===`nuke-reload`){if(Array.isArray(n.keysToRemove)){for(let e of n.keysToRemove)if(typeof e==`string`)try{localStorage.removeItem(e)}catch{}}e()}};return t.addEventListener(`message`,n),()=>{t.removeEventListener(`message`,n),t.close()}}var O=null;function Ue(){return O||(O=He(),O)}var We=`tray`,Ge=`trayWorkerUrl`,Ke=`lead`;function k(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``,t.pathname!==`/`&&(t.pathname=t.pathname.replace(/\/+$/,``)||`/`);let n=t.toString();return n.endsWith(`/`)?n.slice(0,-1):n}catch{return null}}function qe(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``;let n=t.toString(),r=t.pathname.split(`/`).filter(Boolean);if(r.length<2||r.at(-2)!==`join`)return null;let[i,a,...o]=decodeURIComponent(r.at(-1)).split(`.`);if(!i||!a||o.length>0)return null;r.splice(-2,2),t.pathname=r.length>0?`/${r.join(`/`)}`:`/`;let s=k(t.toString());return s?{workerBaseUrl:s,trayId:i,joinUrl:n}:null}catch{return null}}function Je(e,t){let n=new URL(e);return n.searchParams.delete(Ge),n.searchParams.delete(Ke),n.searchParams.set(We,t),n.toString()}var A=`slicc.trayWorkerBaseUrl`,j=`slicc.trayJoinUrl`,Ye=`https://www.sliccy.ai`;function Xe(e,t){let n=k(e);if(!n)throw Error(`Invalid tray worker base URL: ${e}`);let r=t.replace(/^\/+/,``);return new URL(r,`${n}/`).toString()}function M(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``;let n=t.pathname.split(`/`).filter(Boolean),r=null;if(n.length>=2&&n.at(-2)===`tray`)r=decodeURIComponent(n.at(-1)),n.splice(-2,2),t.pathname=n.length>0?`/${n.join(`/`)}`:`/`;else if(n.length>=2&&n.at(-2)===`join`)return qe(t.toString());let i=k(t.toString());return i?{workerBaseUrl:i,trayId:r,joinUrl:null}:null}catch{return null}}function N(e){let t=M(e);return t?.joinUrl?t:null}function Ze(e,t){let n=N(t);return n?(e.setItem(j,n.joinUrl),e.setItem(A,n.workerBaseUrl),n):null}function Qe(e){return!!N(e?.getItem(`slicc.trayJoinUrl`)??null)}function $e(e,t){let n=k(e);if(!n)throw Error(`Invalid tray worker base URL: ${e}`);let r=t?.trim();return r?new URL(`tray/${encodeURIComponent(r)}`,`${n}/`).toString():n}function et(e,t,n){return Je(e,$e(t,n))}async function P(e){let t=rt(e.locationHref);if(t)return e.storage&&(t.joinUrl&&e.storage.setItem(j,t.joinUrl),e.storage.setItem(A,t.workerBaseUrl)),t;let n=N(e.storage?.getItem(`slicc.trayJoinUrl`)??null);if(n)return e.storage&&e.storage.setItem(A,n.workerBaseUrl),n;let r=e.runtimeConfigFetcher?await it(e.runtimeConfigFetcher):null;if(r?.joinConfig)return e.storage&&(e.storage.setItem(j,r.joinConfig.joinUrl),e.storage.setItem(A,r.joinConfig.workerBaseUrl)),r.joinConfig;let i=r?.workerBaseUrl??null,a=k(e.storage?.getItem(`slicc.trayWorkerBaseUrl`)??null),o=k(e.envBaseUrl??null),s=k(e.defaultWorkerBaseUrl??null),c=i??a??o??s;return c?(e.storage&&e.storage.setItem(A,c),{workerBaseUrl:c,trayId:null,joinUrl:null}):null}async function tt(e){return(await P(e))?.workerBaseUrl??null}async function nt(e=fetch){try{let t=await e(be(`/api/runtime-config`),{cache:`no-store`,headers:we()});return t.ok?await t.json():null}catch{return null}}function rt(e){try{let t=new URL(e),n=M(t.searchParams.get(We));if(n)return n;let r=M(t.searchParams.get(Ke));if(r)return r;let i=k(t.searchParams.get(Ge));return i?{workerBaseUrl:i,trayId:null,joinUrl:null}:qe(e)||null}catch{return null}}async function it(e){let t=await e();if(!t)return null;let n=N(t.trayJoinUrl??null);return{workerBaseUrl:k(t.trayWorkerBaseUrl??null),joinConfig:n}}var at=`slicc-cdp-superseded-banner`;function ot(e){if(e.getElementById(at))return;let t=e.createElement(`div`);t.id=at,t.setAttribute(`role`,`alert`),t.textContent=`Another SLICC tab or window has taken control of this browser instance. Only one tab can drive the browser per instance — close the other tabs, then reload this page to resume.`,t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`right:0`,`z-index:2147483647`,`padding:10px 16px`,`background:#b3261e`,`color:#fff`,`font:13px/1.4 system-ui,sans-serif`,`text-align:center`,`box-shadow:0 1px 4px rgba(0,0,0,0.3)`].join(`;`),e.body.appendChild(t)}new Set([{id:`chat`,label:`Chat`},{id:`terminal`,label:`Terminal`},{id:`files`,label:`Files`},{id:`memory`,label:`Memory`}].map(e=>e.id));function st(e,t){if(t){try{if(new URL(e).searchParams.get(`detached`)===`1`)return`extension-detached`}catch{}return`extension`}try{let t=new URL(e);return t.searchParams.get(`connect`)===`1`?`connect`:t.searchParams.get(`runtime`)===`hosted-leader`?`hosted-leader`:t.searchParams.get(`cherry`)===`1`?`cherry`:lt(t)?`electron-overlay`:`standalone`}catch{return`standalone`}}function ct(e,t){return e===`electron-overlay`||e===`hosted-leader`||e===`standalone`&&t}function lt(e){return e.pathname===`/electron`||e.pathname===`/electron/`||e.searchParams.get(`runtime`)===`electron-overlay`}var ut=e({setupSudoExtension:()=>ft,setupSudoStandalone:()=>dt});async function dt(e){let{installSudoTestHook:n}=await t(async()=>{let{installSudoTestHook:e}=await import(`./sudo-zd7NVwiq.js`);return{installSudoTestHook:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]));n()}async function ft(e){let{installPanelSudoResponder:n}=await t(async()=>{let{installPanelSudoResponder:e}=await import(`./sudo-zd7NVwiq.js`);return{installPanelSudoResponder:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]));n()}function pt(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`slicc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function mt(e){let t;try{t=new URLSearchParams(e)}catch{return null}if(t.get(`slicc`)!==`leader`)return null;let n=t.get(`ext`);return n?{extensionId:n}:null}function F(){return typeof globalThis.chrome?.runtime?.connect==`function`}var ht=[100,200,400,800,1600];async function gt(e,t,n,r=ht,i=e=>new Promise(t=>setTimeout(t,e))){let a=r.length+1,o=null;for(let s=0;s<a;s++)try{await e.connect(t),s>0&&n.info(`CDP bridge connect succeeded after retry`,{attempt:s+1});return}catch(e){o=e,s<r.length&&await i(r[s]??0)}n.warn(`Initial CDP connect failed after retries; worker-forwarded commands will retry on demand`,o instanceof Error?o.message:String(o))}async function _t(e){let{runtimeMode:n,envBaseUrl:r,window:i,log:a}=e,o=n===`electron-overlay`;a.info(`starting standalone with kernel worker`);let{BrowserAPI:s}=await t(async()=>{let{BrowserAPI:e}=await import(`./cdp-z9uzg44m.js`);return{BrowserAPI:e}},__vite__mapDeps([23,1,24,2]));await dt({log:a});let c,l,u,d=null,f=null,p=null,m=null,h=n===`cherry`?null:mt(i.location.search),g=!!h&&F(),_=n===`cherry`||g?null:D(i.location.search);_?.apiBaseUrl&&(d=_.apiBaseUrl,xe(_.apiBaseUrl),f=_.token,Se(_.token)),_?.lickWsUrl&&(p=_.lickWsUrl);let v=await nt(),y=ct(o?`electron-overlay`:`standalone`,v!==null)?Ye:null;if(await P({locationHref:i.location.href,storage:i.localStorage,envBaseUrl:r,defaultWorkerBaseUrl:y,runtimeConfigFetcher:async()=>v}),n===`cherry`){let{setupCherryFollower:e}=await t(async()=>{let{setupCherryFollower:e}=await import(`./main-cherry-BRV9Q0tu.js`);return{setupCherryFollower:e}},__vite__mapDeps([25,23,1,24,2])),n=await e();c=n.browser,l=n.joinUrl,u=n.transport}else if(h&&F()){a.info(`Routing CDP through the extension bridge (leader tab)`);let{ExtensionBridgeTransport:e}=await t(async()=>{let{ExtensionBridgeTransport:e}=await import(`./extension-bridge-transport-DYOF2OYC.js`);return{ExtensionBridgeTransport:e}},__vite__mapDeps([26,2,27]));c=new s(new e({extensionId:h.extensionId})),await gt(c,void 0,a),m=h.extensionId,Ce(h.extensionId)}else{c=new s,_&&a.info(`Routing CDP through local standalone bridge`,{url:_.url,role:_.role??`(unset)`});let e=_?{url:_.url,protocols:_.subprotocol}:void 0;_?.role===`follower`?(a.info(`Skipping CDP connect for follower overlay tab`),c.primeConnectOptions(e)):(await gt(c,e,a),c.setCdpSupersededHandler(()=>ot(i.document)))}let b=c.getTransport();return globalThis.__slicc_browser=c,{browser:c,realCdpTransport:b,cherryJoinUrl:l,cherryTransport:u,instanceId:pt(),isElectronOverlay:o,localApiBaseUrl:d,bridgeToken:f,localLickWsUrl:p,extensionDelegateId:m}}var I=E(`boot/sw-registration`);async function vt(e=null,t=null){let n=(()=>{try{return new URL(window.location.href).searchParams.get(`connect`)===`1`}catch{return!1}})();if(`serviceWorker`in navigator&&n&&await yt())return`reload-pending`;if(!(`serviceWorker`in navigator)||n)return`ready`;try{if(await navigator.serviceWorker.register(`/preview-sw.js`,{scope:`/preview/`}),I.info(`Preview SW registered`),!(typeof chrome<`u`&&chrome?.runtime?.id))try{await navigator.serviceWorker.register(`/llm-proxy-sw.js`,{scope:`/`}),I.info(`LLM-proxy SW registered`)}catch(e){I.error(`LLM-proxy SW registration failed — cross-origin LLM calls will hit CORS`,e)}if(navigator.serviceWorker.controller||await Promise.race([new Promise(e=>navigator.serviceWorker.addEventListener(`controllerchange`,()=>e(),{once:!0})),new Promise(e=>setTimeout(e,1500))]),!navigator.serviceWorker.controller&&!sessionStorage.getItem(`slicc-sw-reloaded`))return sessionStorage.setItem(`slicc-sw-reloaded`,`1`),I.info(`Reloading once to gain SW control`),location.reload(),`reload-pending`;sessionStorage.removeItem(`slicc-sw-reloaded`),e&&(L(e),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{L(e)})),t&&(R(t),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{R(t)}))}catch(e){I.error(`Preview SW registration failed — preview feature will not work`,e)}return`ready`}function L(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:Ne,apiBaseUrl:e.apiBaseUrl,token:e.token};try{t.postMessage(n)}catch(e){I.warn(`LLM-proxy SW bridge-config postMessage failed`,e)}}function R(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:Pe,extensionId:e.extensionId};try{t.postMessage(n)}catch(e){I.warn(`LLM-proxy SW extension-delegate postMessage failed`,e)}}async function yt(){try{let e=await navigator.serviceWorker.getRegistrations();if(await Promise.all(e.map(e=>e.unregister().catch(()=>!1))),navigator.serviceWorker.controller&&!sessionStorage.getItem(`slicc-connect-sw-cleared`))return sessionStorage.setItem(`slicc-connect-sw-cleared`,`1`),I.info(`connect mode: detaching from service worker (no proxy on worker origin)`),location.reload(),!0;sessionStorage.removeItem(`slicc-connect-sw-cleared`)}catch(e){I.error(`connect-mode SW cleanup failed`,e)}return!1}var z={state:`inactive`,joinUrl:null,trayId:null,error:null,lastPingTime:null,reconnectAttempts:0,attachAttempts:0,lastAttachCode:null,connectingSince:null,lastError:null};function B(){return{...z}}var bt=new Set;function xt(){if(bt.size!==0)for(let e of[...bt])try{e({...z})}catch{}}function St(e){z={...e},xt()}function Ct(e){z={...z,lastPingTime:e},xt()}var V=null,wt=!1;function Tt(){return typeof window>`u`||typeof document>`u`||document?.documentElement===void 0||typeof localStorage?.getItem!=`function`}function Et(){return Tt()?`standalone-worker`:typeof chrome<`u`&&chrome?.runtime?.id?`extension`:typeof document<`u`&&document.documentElement?.dataset?.electronOverlay?`electron`:`cli`}async function Dt(){if(!wt&&!(typeof localStorage<`u`&&typeof localStorage?.getItem==`function`&&localStorage.getItem(`telemetry-disabled`)===`true`))try{let e=Et();e!==`standalone-worker`&&typeof window<`u`?window.RUM_GENERATION=`slicc-${e}`:globalThis.RUM_GENERATION=`slicc-${e}`,e===`standalone-worker`?(V=(await t(()=>import(`./rum-worker-CwmNSpjO.js`),[])).default,self.addEventListener(`error`,e=>{let t=e;H(`js`,t.error?.message??t.message??``)}),self.addEventListener(`unhandledrejection`,e=>{let t=e.reason;H(`js`,t instanceof Error?t.message:String(t))})):e===`extension`?(V=(await t(()=>import(`./rum-DW84CvBs.js`),[])).default,typeof window<`u`&&(window.addEventListener(`error`,e=>{let t=e;H(`js`,t.error?.message??t.message??``)}),window.addEventListener(`unhandledrejection`,e=>{let t=e.reason;H(`js`,t instanceof Error?t.message:String(t))}))):(typeof window<`u`&&(window.SAMPLE_PAGEVIEWS_AT_RATE=`high`),Lt(),V=(await t(()=>import(`./src-C9oNvq2b.js`),[])).sampleRUM),wt=!0,V&&V(`navigate`,{source:typeof document<`u`?document.referrer:``,target:e})}catch{}}function Ot(e,t){V?.(`formsubmit`,{source:e,target:t})}function kt(e){V?.(`viewblock`,{source:e})}function At(e){V?.(`viewmedia`,{source:e})}function H(e,t){let n=t;if(typeof n==`string`){let e=Nt(n);if(e===null)return;n=e}V?.(`error`,{source:e,target:n})}function jt(e){V?.(`signup`,{source:e})}function Mt(e){return e.includes(`@vite/client`)||e.includes(`@vite/env`)||e.includes(`[vite]`)||/https?:\/\/localhost:\d+\/@vite\//.test(e)||/\/__vite_ping/.test(e)}function Nt(e){let t=e??``;if(t.includes(`@vite/`)||t.includes(`[vite]`)||t.includes(`__vite_ping`)){let e=t.split(`
23
23
  `).filter(e=>!Mt(e)).join(`
24
- `).trim();return e?e.slice(0,200).replace(/(\/[a-z]+)(?:\/[^\s/]+)+/gi,`$1/.../`):null}return t.slice(0,200).replace(/(\/[a-z]+)(?:\/[^\s/]+)+/gi,`$1/.../`)}var Pt=Symbol.for(`slicc.telemetry.sendBeacon.wrapped`);function Ft(e){if(typeof e!=`string`)return{kind:`absent`};let t=Nt(e);return t===null?{kind:`noise`}:{kind:`kept`,value:t,mutated:t!==e}}function It(e){let t=Ft(e.source),n=Ft(e.target),r=t.kind!==`kept`,i=n.kind!==`kept`;if((t.kind!==`absent`||n.kind!==`absent`)&&r&&i)return!0;let a=!1;return t.kind===`kept`?t.mutated&&(e.source=t.value,a=!0):t.kind===`noise`&&(e.source=``,a=!0),n.kind===`kept`?n.mutated&&(e.target=n.value,a=!0):n.kind===`noise`&&(e.target=``,a=!0),a?JSON.stringify(e):null}function Lt(){if(typeof navigator>`u`||typeof navigator.sendBeacon!=`function`)return;let e=navigator.sendBeacon;if(e[Pt])return;let t=e.bind(navigator),n=((e,n)=>{try{let r=typeof n==`string`?n:n instanceof ArrayBuffer?new TextDecoder().decode(n):null;if(r&&r.length>0&&r.charCodeAt(0)===123){let n=JSON.parse(r);if(n?.checkpoint===`error`){let r=It(n);if(r===!0)return!0;if(r!==null)return t(e,r)}}}catch{}return t(e,n)});n[Pt]=!0,navigator.sendBeacon=n}function Rt(e,t){if(e.state===`inactive`&&t.state===`inactive`)return{kind:`leader-offer`,label:`Enable multi-browser sync`,caption:`Connect another browser to this session.`};if(e.state===`leader`&&e.session?.joinUrl)return{kind:`leader-copy`,joinUrl:e.session.joinUrl,label:`Enable multi-browser sync`,caption:`Share this URL to connect more browsers.`};if(e.state!==`inactive`){let t=e.state===`connecting`?`Setting up multi-browser sync…`:e.state===`reconnecting`?`Reconnecting…`:`Sync service unreachable.`;return{kind:`leader-pending`,label:`Multi-browser sync`,caption:e.error??t}}return{kind:`follower`,label:`Multi-browser sync`,caption:t.error??t.lastError??zt(t.state)??`Mirroring another browser.`}}function zt(e){switch(e){case`connected`:return`Connected — mirroring another browser.`;case`connecting`:return`Connecting to the other browser…`;case`reconnecting`:return`Reconnecting…`;case`disconnected`:return`Disconnected from the other browser.`;default:return null}}function Bt(e){let t=e.trim();if(!t)return`Paste a sync URL to continue.`;let n=null;try{n=new URL(t)}catch{return`That doesn’t look like a URL. Paste the full https://… link from the other browser.`}return n.protocol!==`https:`&&n.protocol!==`http:`?`Sync URLs must start with https://.`:n.pathname.includes(`/join/`)?`That sync URL is malformed. Re-copy it from the other browser and try again.`:`This URL is missing the /join/… capability. Use “Enable multi-browser sync” on the other browser.`}var Vt=e({ACCOUNTS_KEY:()=>pe,__test__:()=>ce,_testOnly_dispatchTrayJoinWithFailureFeedback:()=>Wt,addAccount:()=>T,applyProviderDefaults:()=>S,clearAllSettings:()=>le,clearApiKey:()=>fe,clearBaseUrl:()=>ee,clearSelectedProvider:()=>oe,describeInvalidJoinUrl:()=>Bt,downloadProviders:()=>Kt,exportProviders:()=>me,getAccounts:()=>w,getAllAvailableModels:()=>te,getAllExtraOAuthDomains:()=>ue,getApiKey:()=>se,getApiKeyForProvider:()=>re,getApiVersionForProvider:()=>ne,getAvailableProviders:()=>x,getBaseUrl:()=>he,getBaseUrlForProvider:()=>ve,getDeploymentForProvider:()=>C,getExtraOAuthDomains:()=>_e,getOAuthAccountInfo:()=>g,getProviderConfig:()=>i,getProviderModels:()=>ge,getRawApiKeyForProvider:()=>_,getSelectedModelId:()=>o,getSelectedProvider:()=>a,isModelHiddenFromPicker:()=>p,logoutOAuthAccount:()=>ae,maskOAuthTokenWithRetry:()=>n,migrateLegacyAuthOnlySelection:()=>ie,persistOAuthMaskViaServiceWorker:()=>d,providerOffersLlmModels:()=>f,removeAccount:()=>m,resolveCurrentModel:()=>s,resolveModelById:()=>l,resolveModelByShorthand:()=>u,saveOAuthAccount:()=>h,setApiKey:()=>ye,setBaseUrl:()=>r,setExtraOAuthDomains:()=>y,setExtraOAuthDomainsAsync:()=>c,setSelectedModelId:()=>v,setSelectedProvider:()=>b,showProviderSettings:()=>hn}),Ht=E(`provider-settings`);function Ut(){return typeof chrome<`u`&&!!chrome?.runtime?.id}function Wt(e,t){return Gt(e,t)}function Gt(e,t){let n=`tray-join-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,r=!1,i,a=()=>{r||(r=!0,i!==void 0&&clearTimeout(i),window.removeEventListener(`slicc:tray-join-failed`,o))},o=r=>{let i=r.detail;if(i.requestId!==void 0&&i.requestId!==n)return;if(a(),!t.isConnected){Ht.error(`Tray-join failure arrived after dialog dismissed (UX swallowed half-state)`,{joinUrl:e,error:i.error,requestId:n});return}let o=t.dataset.dismissTimer;if(o){let e=Number(o);Number.isFinite(e)&&clearTimeout(e),delete t.dataset.dismissTimer}t.textContent=`Sync failed: ${i.error}. Reload the page and try again.`,t.style.color=`var(--slicc-cone)`};return window.addEventListener(`slicc:tray-join-failed`,o),i=setTimeout(a,1e4),window.dispatchEvent(new CustomEvent(`slicc:tray-join`,{detail:{joinUrl:e,requestId:n}})),a}function Kt(){let e=JSON.stringify(me(),null,2),t=new Blob([e],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`providers.json`,r.click(),URL.revokeObjectURL(n)}function qt(e){return e.length<=10?`****`:e.slice(0,4)+`...`+e.slice(-4)}function U(e){let t=`http://www.w3.org/2000/svg`,n=document.createElementNS(t,`svg`);n.setAttribute(`width`,`14`),n.setAttribute(`height`,`14`),n.setAttribute(`viewBox`,`0 0 20 20`),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`1.5`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`);for(let r of e){let e=document.createElementNS(t,`path`);e.setAttribute(`d`,r),n.appendChild(e)}return n}var W={pen:[`M14.3 3.3a1.5 1.5 0 0 1 2.1 0l.3.3a1.5 1.5 0 0 1 0 2.1L7.7 14.8l-3.2.7.7-3.2z`],trash:[`M4 6h12`,`M8 6V4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2`,`M6 6v10a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V6`],logout:[`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,`M16 17l5-5-5-5`,`M21 12H9`],login:[`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,`M10 17l5-5-5-5`,`M15 12H3`]},G=`background: transparent; border: 1px solid var(--s2-border-subtle); color: var(--s2-content-secondary); border-radius: var(--s2-radius-s); padding: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: color 0.15s, border-color 0.15s;`;function K(e,t){e.addEventListener(`mouseenter`,()=>{e.style.color=t,e.style.borderColor=t}),e.addEventListener(`mouseleave`,()=>{e.style.color=`var(--s2-content-secondary)`,e.style.borderColor=`var(--s2-border-subtle)`})}function q(e){e.overlay.remove(),e.resolve((localStorage.getItem(`slicc_accounts`)??``)!==e.accountsBefore)}function J(e){e.options?.startInAddAccount?q(e):Y(e)}function Jt(e){let t=document.createElement(`div`);return t.style.cssText=`font-size: 11px; color: var(--s2-content-disabled); font-family: monospace; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`,e.loggedOut?(t.textContent=e.userName?`Logged out — was ${e.userName}`:`Logged out`,t.style.color=`var(--s2-content-disabled)`):e.userName?t.textContent=e.userName:e.accessToken?t.textContent=`Logged in`:t.textContent=qt(e.apiKey),e.baseUrl&&(t.textContent+=` • `+e.baseUrl),t}async function Yt(e,n){let{createOAuthLauncher:r,createInterceptingOAuthLauncherForCurrentRuntime:i}=await t(async()=>{let{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}=await import(`./oauth-service-YGl8VFS-.js`);return{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}},__vite__mapDeps([28,1,3,4,5,17,29])),a={forceReauth:!0};if(e.onOAuthLoginIntercepted){let t=await i();t&&await e.onOAuthLoginIntercepted(t,n,a)}else if(e.onOAuthLogin){let t=r();await e.onOAuthLogin(t,n,a)}}function Xt(e,t){let n=document.createElement(`button`);return n.style.cssText=G,n.setAttribute(`aria-label`,`Edit account`),n.appendChild(U(W.pen)),K(n,`var(--s2-accent)`),n.addEventListener(`click`,()=>Z(e,t)),n}function Zt(e,t,n){let r=document.createElement(`button`);return r.style.cssText=G,t.loggedOut===!0?(r.setAttribute(`aria-label`,`Log in`),r.setAttribute(`title`,`Log in`),r.appendChild(U(W.login)),K(r,`var(--s2-accent)`),r.addEventListener(`click`,()=>{Yt(n,()=>Y(e))})):(r.setAttribute(`aria-label`,`Log out`),r.setAttribute(`title`,`Log out`),r.appendChild(U(W.logout)),K(r,`var(--s2-warning, #f59e0b)`),r.addEventListener(`click`,()=>{(async()=>{await ae(t.providerId),Y(e)})()})),r}function Qt(e,t){let n=document.createElement(`button`);return n.style.cssText=G,n.setAttribute(`aria-label`,`Remove account`),n.appendChild(U(W.trash)),K(n,`var(--s2-negative)`),n.addEventListener(`click`,()=>{(async()=>{await m(t.providerId),Y(e)})()}),n}function $t(e,t){let n=i(t.providerId),r=document.createElement(`div`);r.style.cssText=`display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--s2-bg-layer-2); border-radius: var(--s2-radius-default); margin-bottom: 8px; border: 1px solid var(--s2-border-subtle);`;let a=document.createElement(`div`);a.style.cssText=`flex: 1; min-width: 0;`;let o=document.createElement(`div`);o.style.cssText=`font-size: 14px; font-weight: 600; color: var(--s2-content-default);`,o.textContent=n.name,a.appendChild(o),a.appendChild(Jt(t)),r.appendChild(a);let s=document.createElement(`div`);return s.style.cssText=`display: flex; gap: 4px; margin-left: 12px; flex-shrink: 0;`,s.appendChild(Xt(e,t)),n.isOAuth&&s.appendChild(Zt(e,t,n)),s.appendChild(Qt(e,t)),r.appendChild(s),r}function en(e){let t=document.createDocumentFragment(),n=document.createElement(`hr`);n.style.cssText=`border: none; border-top: 1px solid var(--s2-border-subtle); margin: 16px 0;`,t.appendChild(n);let r=document.createElement(`div`);r.className=`dialog__desc`,r.style.cssText=`font-weight: 600; margin-bottom: 8px;`,r.textContent=`Tray`,t.appendChild(r);let i=B(),a=i.state!==`inactive`,o=Qe(window.localStorage);if(a||o){let e=document.createElement(`div`);e.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); margin-bottom: 8px;`,e.textContent=`Follower: ${a?i.state:`configured`}`,i.error&&(e.textContent+=` — ${i.error}`,e.style.color=`var(--slicc-cone)`),t.appendChild(e)}let s=document.createElement(`button`);return s.className=`dialog__btn dialog__btn--secondary`,s.textContent=a||o?`Reconnect to other browser`:`Connect to another browser`,s.addEventListener(`click`,()=>Q(e)),t.appendChild(s),t}function Y(e){let{dialog:t}=e;t.innerHTML=``;let n=document.createElement(`div`);n.className=`dialog__title`,n.textContent=`Accounts`,t.appendChild(n);let r=w();if(r.length===0){let e=document.createElement(`div`);e.className=`dialog__desc`,e.textContent=`No accounts configured.`,t.appendChild(e)}else{let n=document.createElement(`div`);n.style.cssText=`margin-bottom: 16px;`;for(let t of r)n.appendChild($t(e,t));t.appendChild(n)}let i=document.createElement(`div`);i.style.cssText=`display: flex; gap: 8px;`;let a=document.createElement(`button`);a.className=r.length>0?`dialog__btn dialog__btn--secondary`:`dialog__btn`,a.style.flex=`1`,a.textContent=`Add Account`,a.addEventListener(`click`,()=>Z(e)),i.appendChild(a);let o=document.createElement(`button`);o.className=`dialog__btn dialog__btn--secondary`,o.style.flex=`1`,o.textContent=`Export`,o.addEventListener(`click`,()=>Kt()),i.appendChild(o),t.appendChild(i),t.appendChild(en(e));let s=document.createElement(`hr`);s.style.cssText=`border: none; border-top: 1px solid var(--s2-border-subtle); margin: 16px 0;`,t.appendChild(s);let c=document.createElement(`button`);c.className=`dialog__btn`,c.textContent=`Get Started`,c.addEventListener(`click`,()=>q(e)),t.appendChild(c)}function tn(e,t){let n=document.createElement(`select`);if(n.className=`dialog__input`,n.style.marginBottom=`8px`,t){let e=i(t.providerId),r=document.createElement(`option`);return r.value=t.providerId,r.textContent=e.name,n.appendChild(r),n.disabled=!0,n.style.opacity=`0.7`,n}let r=document.createElement(`option`);r.value=``,r.textContent=`Select a provider…`,r.disabled=!0,r.selected=!0,r.hidden=!0,n.appendChild(r);let a=new Set(w().map(e=>e.providerId)),o=[...x()].sort((e,t)=>i(e).name.localeCompare(i(t).name));for(let t of o){if(a.has(t))continue;if(e?.providerFilter){if(!e.providerFilter(t))continue}else if(!f(t))continue;let r=document.createElement(`option`);r.value=t,r.textContent=i(t).name,n.appendChild(r)}return n}function nn(e,t){let n=tn(e,t),r=document.createElement(`div`);r.className=`dialog__desc`,r.style.cssText=`font-size: 12px; color: var(--s2-content-tertiary); margin-bottom: 16px; margin-top: -4px;`;let i=document.createElement(`div`);i.style.cssText=`margin-bottom: 16px; display: none;`;let a=document.createElement(`button`);a.className=`dialog__btn`,a.textContent=`Login`,a.style.cssText=`width: 100%; margin-bottom: 8px;`,i.appendChild(a);let o=document.createElement(`div`);o.className=`dialog__desc`,o.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); text-align: center;`,i.appendChild(o);let s=document.createElement(`div`),c=document.createElement(`div`);c.className=`dialog__desc`,s.appendChild(c);let l=document.createElement(`input`);l.className=`dialog__input`,l.type=`password`,l.autocomplete=`off`,l.spellcheck=!1,t&&(l.value=t.apiKey),s.appendChild(l);let u=document.createElement(`div`),d=document.createElement(`div`);d.className=`dialog__desc`,d.textContent=`Base URL:`,u.appendChild(d);let f=document.createElement(`input`);f.className=`dialog__input`,f.type=`text`,f.autocomplete=`off`,f.spellcheck=!1,t?.baseUrl&&(f.value=t.baseUrl),u.appendChild(f);let p=document.createElement(`div`);p.className=`dialog__desc`,p.style.cssText=`font-size: 11px; color: var(--s2-content-secondary); margin-top: -12px; margin-bottom: 16px;`,u.appendChild(p);let m=document.createElement(`div`);m.style.display=`none`;let h=document.createElement(`div`);h.className=`dialog__desc`,h.textContent=`Deployment:`,m.appendChild(h);let g=document.createElement(`input`);g.className=`dialog__input`,g.type=`text`,g.autocomplete=`off`,g.spellcheck=!1,t?.deployment&&(g.value=t.deployment),m.appendChild(g);let _=document.createElement(`div`);_.className=`dialog__desc`,_.style.cssText=`font-size: 11px; color: var(--s2-content-secondary); margin-top: -12px; margin-bottom: 16px;`,m.appendChild(_);let v=document.createElement(`div`);v.style.display=`none`;let y=document.createElement(`div`);y.className=`dialog__desc`,y.textContent=`API Version:`,v.appendChild(y);let b=document.createElement(`input`);b.className=`dialog__input`,b.type=`text`,b.autocomplete=`off`,b.spellcheck=!1,t?.apiVersion&&(b.value=t.apiVersion),v.appendChild(b);let x=document.createElement(`div`);x.className=`dialog__desc`,x.style.cssText=`font-size: 11px; color: var(--s2-content-secondary); margin-top: -12px; margin-bottom: 16px;`,v.appendChild(x);let S=document.createElement(`div`);S.style.cssText=`color: var(--slicc-cone); font-size: 12px; margin-bottom: 8px; display: none;`;let C=document.createElement(`button`);return C.className=`dialog__btn`,C.textContent=t?`Save`:`Add`,{providerSelect:n,providerDesc:r,oauth:{section:i,loginBtn:a,status:o},apiKeySection:s,apiKeyLabel:c,apiKeyInput:l,baseUrlSection:u,baseUrlInput:f,baseUrlDesc:p,deploymentSection:m,deploymentInput:g,deploymentDesc:_,apiVersionSection:v,apiVersionInput:b,apiVersionDesc:x,errorEl:S,saveBtn:C}}function rn(e){let t=document.createElement(`div`);t.setAttribute(`data-slicc-device-code-prompt`,``),t.style.cssText=`display:flex;flex-direction:column;gap:8px`;let n=document.createElement(`div`);n.className=`dialog__desc`,n.textContent=`Verification code`,n.style.cssText=`font-size: 11px; color: var(--s2-content-tertiary);`;let r=document.createElement(`div`);r.textContent=e,r.style.cssText=[`font: 600 22px ui-monospace, SFMono-Regular, Menlo, monospace`,`letter-spacing: 2px`,`color: var(--s2-content-primary, #e6edf3)`,`background: var(--s2-bg-secondary, #161b22)`,`border: 1px solid var(--s2-border, #30363d)`,`border-radius: 6px`,`padding: 10px 12px`,`text-align: center`,`user-select: all`,`cursor: text`].join(`;`);let i=document.createElement(`div`);i.className=`dialog__desc`,i.style.cssText=`font-size: 12px; color: var(--s2-content-secondary);`,i.textContent=`Click Copy & Continue — we will open the GitHub authorization page in a new tab. Paste this code there if it is not already filled in.`;let a=document.createElement(`div`);a.style.cssText=`display:flex;gap:8px;justify-content:flex-end;margin-top:4px`;let o=document.createElement(`button`);o.type=`button`,o.className=`dialog__btn`,o.textContent=`Cancel`;let s=document.createElement(`button`);return s.type=`button`,s.className=`dialog__btn dialog__btn--primary`,s.textContent=`Copy & Continue`,a.appendChild(o),a.appendChild(s),t.appendChild(n),t.appendChild(r),t.appendChild(i),t.appendChild(a),{prompt:t,cancelBtn:o,continueBtn:s}}function an(e){return t=>new Promise(n=>{let r=e.loginBtn.style.display,i=e.status.style.display;e.loginBtn.style.display=`none`,e.status.style.display=`none`;let{prompt:a,cancelBtn:o,continueBtn:s}=rn(t.userCode),c=()=>{try{a.remove()}catch{}e.loginBtn.style.display=r,e.status.style.display=i};o.addEventListener(`click`,()=>{c(),n(`cancel`)}),s.addEventListener(`click`,()=>{(async()=>{try{await Te(t.userCode)}catch{}c(),e.status.style.display=i,e.status.textContent=`Waiting for you to authorize in the new tab…`,n(`continue`)})()}),e.section.appendChild(a)})}async function on(e,n){let r=n.providerSelect.value;if(!r)return;let a=i(r);if(!a.onOAuthLogin&&!a.onOAuthLoginIntercepted)return;let{status:o}=n.oauth,s=w().some(e=>e.providerId===r),c=ve(r);if(a.requiresBaseUrl&&!n.baseUrlInput.value.trim()&&!c){o.textContent=`Base URL is required.`,o.style.color=`var(--slicc-cone)`,n.baseUrlInput.focus();return}a.requiresBaseUrl&&n.baseUrlInput.value.trim()&&T(r,``,n.baseUrlInput.value.trim()),o.textContent=`Opening login window...`;try{if(a.onOAuthLoginIntercepted){let{createInterceptingOAuthLauncherForCurrentRuntime:r}=await t(async()=>{let{createInterceptingOAuthLauncherForCurrentRuntime:e}=await import(`./oauth-service-YGl8VFS-.js`);return{createInterceptingOAuthLauncherForCurrentRuntime:e}},__vite__mapDeps([28,1,3,4,5,17,29])),i=await r();if(!i)throw Error(`No controlled-browser CDP transport available — open SLICC in standalone mode or the Chrome extension.`);await a.onOAuthLoginIntercepted(i,()=>J(e),{presentDeviceCode:an(n.oauth)})}else if(a.onOAuthLogin){let{createOAuthLauncher:n}=await t(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-YGl8VFS-.js`);return{createOAuthLauncher:e}},__vite__mapDeps([28,1,3,4,5,17,29])),r=n();await a.onOAuthLogin(r,()=>J(e))}}catch(e){if(!s)try{await m(r)}catch{}Ht.error(`OAuth login failed`,{providerId:r,error:e instanceof Error?e.message:String(e)}),o.textContent=`Login failed: ${e instanceof Error?e.message:String(e)}`}}function sn(e,t){if(t.isOAuth){e.oauth.section.style.display=``,e.apiKeySection.style.display=`none`,e.baseUrlSection.style.display=t.requiresBaseUrl?``:`none`,t.requiresBaseUrl&&(e.baseUrlInput.placeholder=t.baseUrlPlaceholder||`https://...`,e.baseUrlDesc.textContent=t.baseUrlDescription||``),e.oauth.loginBtn.textContent=`Login with ${t.name}`,e.saveBtn.style.display=`none`;return}e.oauth.section.style.display=`none`;let n=t.requiresApiKey?`API Key`:`API Key (optional)`;e.apiKeyLabel.textContent=`${n}${t.apiKeyEnvVar?` (${t.apiKeyEnvVar})`:``}:`,e.apiKeyInput.placeholder=t.apiKeyPlaceholder||`API key`,e.apiKeySection.style.display=t.requiresApiKey||t.optionalApiKey?``:`none`,e.baseUrlInput.placeholder=t.baseUrlPlaceholder||`https://...`,e.baseUrlDesc.textContent=t.baseUrlDescription||``,e.baseUrlSection.style.display=t.requiresBaseUrl?``:`none`,e.saveBtn.style.display=``}function cn(e,t){t.requiresDeployment?(e.deploymentSection.style.display=``,e.deploymentInput.placeholder=t.deploymentPlaceholder||`deployment-name`,e.deploymentDesc.textContent=t.deploymentDescription||``):e.deploymentSection.style.display=`none`}function ln(e,t){t.requiresApiVersion?(e.apiVersionSection.style.display=``,!e.apiVersionInput.value&&t.apiVersionDefault&&(e.apiVersionInput.value=t.apiVersionDefault),e.apiVersionInput.placeholder=t.apiVersionDefault||`api-version`,e.apiVersionDesc.textContent=t.apiVersionDescription||``):e.apiVersionSection.style.display=`none`}function un(e){let t=e.providerSelect.value;if(!t){e.providerDesc.textContent=``,e.oauth.section.style.display=`none`,e.apiKeySection.style.display=`none`,e.baseUrlSection.style.display=`none`,e.deploymentSection.style.display=`none`,e.apiVersionSection.style.display=`none`,e.saveBtn.style.display=`none`;return}let n=i(t);e.providerDesc.textContent=n.description,sn(e,n),cn(e,n),ln(e,n)}function X(e,t){let n=t.providerSelect.value;if(!n)return;let r=i(n),a=(e,n)=>{t.errorEl.textContent=e,t.errorEl.style.display=``,n.focus()};if(r.requiresApiKey&&t.apiKeyInput.value.trim().length<5){a(`API key is required (at least 5 characters).`,t.apiKeyInput);return}if(r.requiresBaseUrl&&!t.baseUrlInput.value.trim()){a(`Base URL is required for this provider.`,t.baseUrlInput);return}if(r.requiresDeployment&&!t.deploymentInput.value.trim()){a(`Deployment name is required for this provider.`,t.deploymentInput);return}T(n,t.apiKeyInput.value.trim(),t.baseUrlInput.value.trim()||void 0,t.deploymentInput.value.trim()||void 0,t.apiVersionInput.value.trim()||void 0),J(e)}function dn(e,t){let{dialog:n,options:r}=e,i=w().length>0;if(r?.startInAddAccount){let t=document.createElement(`button`);t.className=`dialog__btn dialog__btn--secondary`,t.style.marginTop=`8px`,t.textContent=`Cancel`,t.addEventListener(`click`,()=>q(e)),n.appendChild(t)}else if(!t&&!i){let t=document.createElement(`button`);t.className=`dialog__btn dialog__btn--secondary`,t.style.marginTop=`8px`,t.textContent=`Connect to another browser`,t.addEventListener(`click`,()=>Q(e)),n.appendChild(t)}else if(i){let t=document.createElement(`button`);t.className=`dialog__btn dialog__btn--secondary`,t.style.marginTop=`8px`,t.textContent=`Back`,t.addEventListener(`click`,()=>Y(e)),n.appendChild(t)}}function Z(e,t){let{dialog:n}=e;n.innerHTML=``;let r=document.createElement(`div`);r.className=`dialog__title`,r.textContent=t?`Edit Account`:`Add Account`,n.appendChild(r);let a=document.createElement(`div`);a.className=`dialog__desc`,a.textContent=`Provider:`,n.appendChild(a);let o=nn(e.options,t);n.appendChild(o.providerSelect),n.appendChild(o.providerDesc),o.oauth.loginBtn.addEventListener(`click`,()=>{on(e,o)}),t?.userName&&(o.oauth.status.textContent=`Logged in as ${t.userName}`,o.oauth.loginBtn.textContent=`Re-login`),n.appendChild(o.oauth.section),n.appendChild(o.apiKeySection),n.appendChild(o.baseUrlSection),n.appendChild(o.deploymentSection),n.appendChild(o.apiVersionSection),n.appendChild(o.errorEl),o.providerSelect.addEventListener(`change`,()=>{o.errorEl.style.display=`none`,un(o)}),un(o),o.saveBtn.addEventListener(`click`,()=>X(e,o));let s=t=>{t.key===`Enter`&&X(e,o)};o.apiKeyInput.addEventListener(`keydown`,s),o.baseUrlInput.addEventListener(`keydown`,s),o.deploymentInput.addEventListener(`keydown`,s),o.apiVersionInput.addEventListener(`keydown`,s),n.appendChild(o.saveBtn),dn(e,!!t),requestAnimationFrame(()=>{let e=o.providerSelect.value;if(!e)return;let t=i(e);t.requiresApiKey?o.apiKeyInput.focus():t.requiresBaseUrl&&o.baseUrlInput.focus()})}function fn(e,t,n,r){if(Ut()){let e={type:`refresh-tray-runtime`,joinUrl:t,workerBaseUrl:n};chrome.runtime.sendMessage({source:`panel`,payload:e}).catch(()=>{})}else Gt(t,r);r.textContent=`Connecting…`,r.style.display=``,r.style.color=`var(--s2-content-secondary)`;let i=setTimeout(()=>{e.overlay.remove(),e.resolve(!1)},800);r.dataset.dismissTimer=String(i)}function pn(e,t){let{dialog:n}=e;n.innerHTML=``;let r=document.createElement(`div`);r.className=`dialog__title`,r.textContent=`Connect this browser?`,n.appendChild(r);let i=document.createElement(`div`);i.className=`dialog__desc`,i.style.marginBottom=`12px`,i.textContent=`You’ve been invited to mirror another SLICC browser. Click below to start syncing.`,n.appendChild(i);let a=document.createElement(`div`);a.className=`dialog__desc`,a.style.cssText=`font-family: monospace; font-size: 11px; color: var(--s2-content-secondary); word-break: break-all; margin-bottom: 16px; padding: 8px; background: var(--s2-bg-secondary); border-radius: 4px;`,a.textContent=t.length>80?t.slice(0,40)+`…`+t.slice(-37):t,n.appendChild(a);let o=document.createElement(`div`);o.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); margin-bottom: 8px; display: none;`,n.appendChild(o);let s=document.createElement(`button`);s.className=`dialog__btn`,s.textContent=`Connect`,s.addEventListener(`click`,()=>{let n=Ze(window.localStorage,t);if(!n){o.textContent=`Invalid sync URL.`,o.style.display=``,o.style.color=`var(--slicc-cone)`;return}fn(e,n.joinUrl,n.workerBaseUrl,o)}),n.appendChild(s);let c=document.createElement(`button`);c.className=`dialog__btn dialog__btn--secondary`,c.style.marginTop=`8px`,c.textContent=`Set up an account instead`,c.addEventListener(`click`,()=>Z(e)),n.appendChild(c)}function mn(){let e=document.createElement(`details`);e.style.cssText=`margin-bottom: 12px; font-size: 12px; color: var(--s2-content-secondary);`;let t=document.createElement(`summary`);t.style.cssText=`cursor: pointer; user-select: none; color: var(--s2-content-secondary);`,t.textContent=`How do I get the sync URL?`,e.appendChild(t);let n=document.createElement(`div`);n.style.cssText=`margin-top: 8px; padding: 10px 12px; background: var(--s2-bg-layer-2); border-radius: var(--s2-radius-default); border: 1px solid var(--s2-border-subtle); line-height: 1.5;`;let r=document.createElement(`ol`);r.style.cssText=`margin: 0; padding-left: 20px;`;for(let e of[`On the other SLICC, click the avatar (top right).`,`Choose “Enable multi-browser sync” — the URL is copied automatically.`,`Paste it below. Both browsers must be on the same SLICC version.`]){let t=document.createElement(`li`);t.textContent=e,r.appendChild(t)}return n.appendChild(r),e.appendChild(n),e}function Q(e){let{dialog:t}=e;t.innerHTML=``;let n=document.createElement(`div`);n.className=`dialog__title`,n.textContent=`Connect to another browser`,t.appendChild(n);let r=document.createElement(`div`);r.className=`dialog__desc`,r.style.marginBottom=`12px`,r.textContent=`Paste a multi-browser sync URL to mirror another SLICC browser.`,t.appendChild(r),t.appendChild(mn());let i=document.createElement(`div`);i.className=`dialog__desc`,i.textContent=`Sync URL:`,t.appendChild(i);let a=document.createElement(`input`);a.className=`dialog__input`,a.type=`text`,a.autocomplete=`off`,a.spellcheck=!1,a.placeholder=`https://www.sliccy.ai/join/<token>`,t.appendChild(a);let o=document.createElement(`div`);o.style.cssText=`color: var(--slicc-cone); font-size: 12px; margin-bottom: 8px; display: none;`,t.appendChild(o);let s=document.createElement(`div`);s.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); margin-bottom: 8px; display: none;`;let c=document.createElement(`button`);c.className=`dialog__btn`,c.textContent=`Connect`,c.addEventListener(`click`,()=>{let t=a.value.trim();if(!t){o.textContent=`Paste a sync URL to continue.`,o.style.display=``,a.focus();return}let n=Ze(window.localStorage,t);if(!n){o.textContent=Bt(t),o.style.display=``,a.focus();return}fn(e,n.joinUrl,n.workerBaseUrl,s)}),t.appendChild(c),t.appendChild(s);let l=document.createElement(`button`);l.className=`dialog__btn dialog__btn--secondary`,l.style.marginTop=`8px`,l.textContent=`Back`,l.addEventListener(`click`,()=>Z(e)),t.appendChild(l),a.addEventListener(`input`,()=>{o.style.display=`none`}),a.addEventListener(`keydown`,e=>{e.key===`Enter`&&c.click()}),requestAnimationFrame(()=>a.focus())}function hn(e){return jt(`button`),new Promise(t=>{let n=document.createElement(`div`);n.className=`dialog-overlay`;let r=document.createElement(`div`);r.className=`dialog`,r.style.cssText=`max-width: 480px; width: 90vw; padding: 32px;`;let i={overlay:n,dialog:r,options:e,accountsBefore:localStorage.getItem(`slicc_accounts`)??``,resolve:t};e?.startInAddAccount?Z(i):w().length>0?Y(i):e?.autoJoinUrl?pn(i,e.autoJoinUrl):e?.preferTrayJoin?Q(i):Z(i),n.appendChild(r),document.body.appendChild(n)})}var $=E(`main`);function gn(e){try{return new URL(e).searchParams.has(`ui-fixture`)}catch{return!1}}async function _n(){let e=document.getElementById(`app`);if(!e)throw Error(`#app element not found`);let n=typeof chrome<`u`&&!!chrome?.runtime?.id,r=st(window.location.href,n);if(gn(window.location.href)){let{mountWcUiPreview:n}=await t(async()=>{let{mountWcUiPreview:e}=await import(`./wc-shell-DeV6jP6H.js`).then(e=>e.a);return{mountWcUiPreview:e}},__vite__mapDeps([30,4,1,21,31,32,33]));n(e);return}Be(),Ue(),r!==`connect`&&Dt().catch(()=>{});let i=D(window.location.search),a=r===`cherry`?null:mt(window.location.search),o=!!a&&F();if(await vt(i?{apiBaseUrl:i.apiBaseUrl,token:i.token}:null,o&&a?{extensionId:a.extensionId}:null)===`reload-pending`)return;await de(),S();let{bootstrapOAuthReplicas:s}=await t(async()=>{let{bootstrapOAuthReplicas:e}=await import(`./oauth-bootstrap-BjTCYMG8.js`);return{bootstrapOAuthReplicas:e}},__vite__mapDeps([34,1,8,4,9,10,11,12,13,2,14,3,5,15,16,17,18,19,20]));if(await Promise.race([s().catch(e=>{$.error(`OAuth bootstrap failed`,e)}),new Promise(e=>setTimeout(e,1e4))]),r===`connect`){globalThis.__slicc_connect_mode=!0;let{loadLegacyStyles:n}=await t(async()=>{let{loadLegacyStyles:e}=await import(`./legacy-styles-4PP74ISo.js`);return{loadLegacyStyles:e}},__vite__mapDeps([35,1]));await n();let{mountConnectSurface:r}=await t(async()=>{let{mountConnectSurface:e}=await import(`./connect-surface-CvI6NTHs.js`);return{mountConnectSurface:e}},__vite__mapDeps([36,8,4,1,9,10,11,12,13,2,14,3,5,15,16,17,18,19,20]));await r(e);return}if(n){let{mountWcUiExtension:n}=await t(async()=>{let{mountWcUiExtension:e}=await import(`./wc-extension-Bt6WVUQv.js`);return{mountWcUiExtension:e}},__vite__mapDeps([37,1,38,8,4,9,10,11,12,13,2,14,3,5,15,16,17,18,19,20,30,21,31,32,33,39,40,41,42,43,44,45,46,47,48,29,49]));return n(e,$,r===`extension-detached`)}o&&a&&ze(a.extensionId);let{mountWcUiLive:c}=await t(async()=>{let{mountWcUiLive:e}=await import(`./wc-live-C6obLPXQ.js`);return{mountWcUiLive:e}},__vite__mapDeps([38,1,8,4,9,10,11,12,13,2,14,3,5,15,16,17,18,19,20,30,21,31,32,33,39,40,41,42,43,44,45,46,47,48,29]));return c(e,$,r)}_n().catch(e=>{$.error(`Fatal error`,e);let t=document.getElementById(`app`);if(t){let n=document.createElement(`div`);n.style.cssText=`padding: 2rem; text-align: center;`;let r=document.createElement(`h1`);r.style.color=`var(--s2-negative, #e34850)`,r.textContent=`Failed to start`;let i=document.createElement(`p`);for(i.style.color=`var(--s2-content-tertiary, #717171)`,i.textContent=e.message,n.appendChild(r),n.appendChild(i);t.firstChild;)t.removeChild(t.firstChild);t.appendChild(n)}});export{Qe as _,At as a,Ee as b,Ct as c,ut as d,Ye as f,Xe as g,et as h,Ot as i,St as l,A as m,hn as n,kt as o,j as p,Rt as r,B as s,Vt as t,_t as u,tt as v,Me as y};
24
+ `).trim();return e?e.slice(0,200).replace(/(\/[a-z]+)(?:\/[^\s/]+)+/gi,`$1/.../`):null}return t.slice(0,200).replace(/(\/[a-z]+)(?:\/[^\s/]+)+/gi,`$1/.../`)}var Pt=Symbol.for(`slicc.telemetry.sendBeacon.wrapped`);function Ft(e){if(typeof e!=`string`)return{kind:`absent`};let t=Nt(e);return t===null?{kind:`noise`}:{kind:`kept`,value:t,mutated:t!==e}}function It(e){let t=Ft(e.source),n=Ft(e.target),r=t.kind!==`kept`,i=n.kind!==`kept`;if((t.kind!==`absent`||n.kind!==`absent`)&&r&&i)return!0;let a=!1;return t.kind===`kept`?t.mutated&&(e.source=t.value,a=!0):t.kind===`noise`&&(e.source=``,a=!0),n.kind===`kept`?n.mutated&&(e.target=n.value,a=!0):n.kind===`noise`&&(e.target=``,a=!0),a?JSON.stringify(e):null}function Lt(){if(typeof navigator>`u`||typeof navigator.sendBeacon!=`function`)return;let e=navigator.sendBeacon;if(e[Pt])return;let t=e.bind(navigator),n=((e,n)=>{try{let r=typeof n==`string`?n:n instanceof ArrayBuffer?new TextDecoder().decode(n):null;if(r&&r.length>0&&r.charCodeAt(0)===123){let n=JSON.parse(r);if(n?.checkpoint===`error`){let r=It(n);if(r===!0)return!0;if(r!==null)return t(e,r)}}}catch{}return t(e,n)});n[Pt]=!0,navigator.sendBeacon=n}function Rt(e,t){if(e.state===`inactive`&&t.state===`inactive`)return{kind:`leader-offer`,label:`Enable multi-browser sync`,caption:`Connect another browser to this session.`};if(e.state===`leader`&&e.session?.joinUrl)return{kind:`leader-copy`,joinUrl:e.session.joinUrl,label:`Enable multi-browser sync`,caption:`Share this URL to connect more browsers.`};if(e.state!==`inactive`){let t=e.state===`connecting`?`Setting up multi-browser sync…`:e.state===`reconnecting`?`Reconnecting…`:`Sync service unreachable.`;return{kind:`leader-pending`,label:`Multi-browser sync`,caption:e.error??t}}return{kind:`follower`,label:`Multi-browser sync`,caption:t.error??t.lastError??zt(t.state)??`Mirroring another browser.`}}function zt(e){switch(e){case`connected`:return`Connected — mirroring another browser.`;case`connecting`:return`Connecting to the other browser…`;case`reconnecting`:return`Reconnecting…`;case`disconnected`:return`Disconnected from the other browser.`;default:return null}}function Bt(e){let t=e.trim();if(!t)return`Paste a sync URL to continue.`;let n=null;try{n=new URL(t)}catch{return`That doesn’t look like a URL. Paste the full https://… link from the other browser.`}return n.protocol!==`https:`&&n.protocol!==`http:`?`Sync URLs must start with https://.`:n.pathname.includes(`/join/`)?`That sync URL is malformed. Re-copy it from the other browser and try again.`:`This URL is missing the /join/… capability. Use “Enable multi-browser sync” on the other browser.`}var Vt=e({ACCOUNTS_KEY:()=>pe,__test__:()=>ce,_testOnly_dispatchTrayJoinWithFailureFeedback:()=>Wt,addAccount:()=>T,applyProviderDefaults:()=>S,clearAllSettings:()=>le,clearApiKey:()=>fe,clearBaseUrl:()=>ee,clearSelectedProvider:()=>oe,describeInvalidJoinUrl:()=>Bt,downloadProviders:()=>Kt,exportProviders:()=>me,getAccounts:()=>w,getAllAvailableModels:()=>te,getAllExtraOAuthDomains:()=>ue,getApiKey:()=>se,getApiKeyForProvider:()=>re,getApiVersionForProvider:()=>ne,getAvailableProviders:()=>x,getBaseUrl:()=>he,getBaseUrlForProvider:()=>ve,getDeploymentForProvider:()=>C,getExtraOAuthDomains:()=>_e,getOAuthAccountInfo:()=>g,getProviderConfig:()=>i,getProviderModels:()=>ge,getRawApiKeyForProvider:()=>_,getSelectedModelId:()=>o,getSelectedProvider:()=>a,isModelHiddenFromPicker:()=>p,logoutOAuthAccount:()=>ae,maskOAuthTokenWithRetry:()=>n,migrateLegacyAuthOnlySelection:()=>ie,persistOAuthMaskViaServiceWorker:()=>d,providerOffersLlmModels:()=>f,removeAccount:()=>m,resolveCurrentModel:()=>s,resolveModelById:()=>l,resolveModelByShorthand:()=>u,saveOAuthAccount:()=>h,setApiKey:()=>ye,setBaseUrl:()=>r,setExtraOAuthDomains:()=>y,setExtraOAuthDomainsAsync:()=>c,setSelectedModelId:()=>v,setSelectedProvider:()=>b,showProviderSettings:()=>hn}),Ht=E(`provider-settings`);function Ut(){return typeof chrome<`u`&&!!chrome?.runtime?.id}function Wt(e,t){return Gt(e,t)}function Gt(e,t){let n=`tray-join-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,r=!1,i,a=()=>{r||(r=!0,i!==void 0&&clearTimeout(i),window.removeEventListener(`slicc:tray-join-failed`,o))},o=r=>{let i=r.detail;if(i.requestId!==void 0&&i.requestId!==n)return;if(a(),!t.isConnected){Ht.error(`Tray-join failure arrived after dialog dismissed (UX swallowed half-state)`,{joinUrl:e,error:i.error,requestId:n});return}let o=t.dataset.dismissTimer;if(o){let e=Number(o);Number.isFinite(e)&&clearTimeout(e),delete t.dataset.dismissTimer}t.textContent=`Sync failed: ${i.error}. Reload the page and try again.`,t.style.color=`var(--slicc-cone)`};return window.addEventListener(`slicc:tray-join-failed`,o),i=setTimeout(a,1e4),window.dispatchEvent(new CustomEvent(`slicc:tray-join`,{detail:{joinUrl:e,requestId:n}})),a}function Kt(){let e=JSON.stringify(me(),null,2),t=new Blob([e],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`providers.json`,r.click(),URL.revokeObjectURL(n)}function qt(e){return e.length<=10?`****`:e.slice(0,4)+`...`+e.slice(-4)}function U(e){let t=`http://www.w3.org/2000/svg`,n=document.createElementNS(t,`svg`);n.setAttribute(`width`,`14`),n.setAttribute(`height`,`14`),n.setAttribute(`viewBox`,`0 0 20 20`),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`1.5`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`);for(let r of e){let e=document.createElementNS(t,`path`);e.setAttribute(`d`,r),n.appendChild(e)}return n}var W={pen:[`M14.3 3.3a1.5 1.5 0 0 1 2.1 0l.3.3a1.5 1.5 0 0 1 0 2.1L7.7 14.8l-3.2.7.7-3.2z`],trash:[`M4 6h12`,`M8 6V4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2`,`M6 6v10a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V6`],logout:[`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,`M16 17l5-5-5-5`,`M21 12H9`],login:[`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,`M10 17l5-5-5-5`,`M15 12H3`]},G=`background: transparent; border: 1px solid var(--s2-border-subtle); color: var(--s2-content-secondary); border-radius: var(--s2-radius-s); padding: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: color 0.15s, border-color 0.15s;`;function K(e,t){e.addEventListener(`mouseenter`,()=>{e.style.color=t,e.style.borderColor=t}),e.addEventListener(`mouseleave`,()=>{e.style.color=`var(--s2-content-secondary)`,e.style.borderColor=`var(--s2-border-subtle)`})}function q(e){e.overlay.remove(),e.resolve((localStorage.getItem(`slicc_accounts`)??``)!==e.accountsBefore)}function J(e){e.options?.startInAddAccount?q(e):Y(e)}function Jt(e){let t=document.createElement(`div`);return t.style.cssText=`font-size: 11px; color: var(--s2-content-disabled); font-family: monospace; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`,e.loggedOut?(t.textContent=e.userName?`Logged out — was ${e.userName}`:`Logged out`,t.style.color=`var(--s2-content-disabled)`):e.userName?t.textContent=e.userName:e.accessToken?t.textContent=`Logged in`:t.textContent=qt(e.apiKey),e.baseUrl&&(t.textContent+=` • `+e.baseUrl),t}async function Yt(e,n){let{createOAuthLauncher:r,createInterceptingOAuthLauncherForCurrentRuntime:i}=await t(async()=>{let{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}=await import(`./oauth-service-YGl8VFS-.js`);return{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}},__vite__mapDeps([28,1,3,4,5,17,29])),a={forceReauth:!0};if(e.onOAuthLoginIntercepted){let t=await i();t&&await e.onOAuthLoginIntercepted(t,n,a)}else if(e.onOAuthLogin){let t=r();await e.onOAuthLogin(t,n,a)}}function Xt(e,t){let n=document.createElement(`button`);return n.style.cssText=G,n.setAttribute(`aria-label`,`Edit account`),n.appendChild(U(W.pen)),K(n,`var(--s2-accent)`),n.addEventListener(`click`,()=>Z(e,t)),n}function Zt(e,t,n){let r=document.createElement(`button`);return r.style.cssText=G,t.loggedOut===!0?(r.setAttribute(`aria-label`,`Log in`),r.setAttribute(`title`,`Log in`),r.appendChild(U(W.login)),K(r,`var(--s2-accent)`),r.addEventListener(`click`,()=>{Yt(n,()=>Y(e))})):(r.setAttribute(`aria-label`,`Log out`),r.setAttribute(`title`,`Log out`),r.appendChild(U(W.logout)),K(r,`var(--s2-warning, #f59e0b)`),r.addEventListener(`click`,()=>{(async()=>{await ae(t.providerId),Y(e)})()})),r}function Qt(e,t){let n=document.createElement(`button`);return n.style.cssText=G,n.setAttribute(`aria-label`,`Remove account`),n.appendChild(U(W.trash)),K(n,`var(--s2-negative)`),n.addEventListener(`click`,()=>{(async()=>{await m(t.providerId),Y(e)})()}),n}function $t(e,t){let n=i(t.providerId),r=document.createElement(`div`);r.style.cssText=`display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--s2-bg-layer-2); border-radius: var(--s2-radius-default); margin-bottom: 8px; border: 1px solid var(--s2-border-subtle);`;let a=document.createElement(`div`);a.style.cssText=`flex: 1; min-width: 0;`;let o=document.createElement(`div`);o.style.cssText=`font-size: 14px; font-weight: 600; color: var(--s2-content-default);`,o.textContent=n.name,a.appendChild(o),a.appendChild(Jt(t)),r.appendChild(a);let s=document.createElement(`div`);return s.style.cssText=`display: flex; gap: 4px; margin-left: 12px; flex-shrink: 0;`,s.appendChild(Xt(e,t)),n.isOAuth&&s.appendChild(Zt(e,t,n)),s.appendChild(Qt(e,t)),r.appendChild(s),r}function en(e){let t=document.createDocumentFragment(),n=document.createElement(`hr`);n.style.cssText=`border: none; border-top: 1px solid var(--s2-border-subtle); margin: 16px 0;`,t.appendChild(n);let r=document.createElement(`div`);r.className=`dialog__desc`,r.style.cssText=`font-weight: 600; margin-bottom: 8px;`,r.textContent=`Tray`,t.appendChild(r);let i=B(),a=i.state!==`inactive`,o=Qe(window.localStorage);if(a||o){let e=document.createElement(`div`);e.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); margin-bottom: 8px;`,e.textContent=`Follower: ${a?i.state:`configured`}`,i.error&&(e.textContent+=` — ${i.error}`,e.style.color=`var(--slicc-cone)`),t.appendChild(e)}let s=document.createElement(`button`);return s.className=`dialog__btn dialog__btn--secondary`,s.textContent=a||o?`Reconnect to other browser`:`Connect to another browser`,s.addEventListener(`click`,()=>Q(e)),t.appendChild(s),t}function Y(e){let{dialog:t}=e;t.innerHTML=``;let n=document.createElement(`div`);n.className=`dialog__title`,n.textContent=`Accounts`,t.appendChild(n);let r=w();if(r.length===0){let e=document.createElement(`div`);e.className=`dialog__desc`,e.textContent=`No accounts configured.`,t.appendChild(e)}else{let n=document.createElement(`div`);n.style.cssText=`margin-bottom: 16px;`;for(let t of r)n.appendChild($t(e,t));t.appendChild(n)}let i=document.createElement(`div`);i.style.cssText=`display: flex; gap: 8px;`;let a=document.createElement(`button`);a.className=r.length>0?`dialog__btn dialog__btn--secondary`:`dialog__btn`,a.style.flex=`1`,a.textContent=`Add Account`,a.addEventListener(`click`,()=>Z(e)),i.appendChild(a);let o=document.createElement(`button`);o.className=`dialog__btn dialog__btn--secondary`,o.style.flex=`1`,o.textContent=`Export`,o.addEventListener(`click`,()=>Kt()),i.appendChild(o),t.appendChild(i),t.appendChild(en(e));let s=document.createElement(`hr`);s.style.cssText=`border: none; border-top: 1px solid var(--s2-border-subtle); margin: 16px 0;`,t.appendChild(s);let c=document.createElement(`button`);c.className=`dialog__btn`,c.textContent=`Get Started`,c.addEventListener(`click`,()=>q(e)),t.appendChild(c)}function tn(e,t){let n=document.createElement(`select`);if(n.className=`dialog__input`,n.style.marginBottom=`8px`,t){let e=i(t.providerId),r=document.createElement(`option`);return r.value=t.providerId,r.textContent=e.name,n.appendChild(r),n.disabled=!0,n.style.opacity=`0.7`,n}let r=document.createElement(`option`);r.value=``,r.textContent=`Select a provider…`,r.disabled=!0,r.selected=!0,r.hidden=!0,n.appendChild(r);let a=new Set(w().map(e=>e.providerId)),o=[...x()].sort((e,t)=>i(e).name.localeCompare(i(t).name));for(let t of o){if(a.has(t))continue;if(e?.providerFilter){if(!e.providerFilter(t))continue}else if(!f(t))continue;let r=document.createElement(`option`);r.value=t,r.textContent=i(t).name,n.appendChild(r)}return n}function nn(e,t){let n=tn(e,t),r=document.createElement(`div`);r.className=`dialog__desc`,r.style.cssText=`font-size: 12px; color: var(--s2-content-tertiary); margin-bottom: 16px; margin-top: -4px;`;let i=document.createElement(`div`);i.style.cssText=`margin-bottom: 16px; display: none;`;let a=document.createElement(`button`);a.className=`dialog__btn`,a.textContent=`Login`,a.style.cssText=`width: 100%; margin-bottom: 8px;`,i.appendChild(a);let o=document.createElement(`div`);o.className=`dialog__desc`,o.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); text-align: center;`,i.appendChild(o);let s=document.createElement(`div`),c=document.createElement(`div`);c.className=`dialog__desc`,s.appendChild(c);let l=document.createElement(`input`);l.className=`dialog__input`,l.type=`password`,l.autocomplete=`off`,l.spellcheck=!1,t&&(l.value=t.apiKey),s.appendChild(l);let u=document.createElement(`div`),d=document.createElement(`div`);d.className=`dialog__desc`,d.textContent=`Base URL:`,u.appendChild(d);let f=document.createElement(`input`);f.className=`dialog__input`,f.type=`text`,f.autocomplete=`off`,f.spellcheck=!1,t?.baseUrl&&(f.value=t.baseUrl),u.appendChild(f);let p=document.createElement(`div`);p.className=`dialog__desc`,p.style.cssText=`font-size: 11px; color: var(--s2-content-secondary); margin-top: -12px; margin-bottom: 16px;`,u.appendChild(p);let m=document.createElement(`div`);m.style.display=`none`;let h=document.createElement(`div`);h.className=`dialog__desc`,h.textContent=`Deployment:`,m.appendChild(h);let g=document.createElement(`input`);g.className=`dialog__input`,g.type=`text`,g.autocomplete=`off`,g.spellcheck=!1,t?.deployment&&(g.value=t.deployment),m.appendChild(g);let _=document.createElement(`div`);_.className=`dialog__desc`,_.style.cssText=`font-size: 11px; color: var(--s2-content-secondary); margin-top: -12px; margin-bottom: 16px;`,m.appendChild(_);let v=document.createElement(`div`);v.style.display=`none`;let y=document.createElement(`div`);y.className=`dialog__desc`,y.textContent=`API Version:`,v.appendChild(y);let b=document.createElement(`input`);b.className=`dialog__input`,b.type=`text`,b.autocomplete=`off`,b.spellcheck=!1,t?.apiVersion&&(b.value=t.apiVersion),v.appendChild(b);let x=document.createElement(`div`);x.className=`dialog__desc`,x.style.cssText=`font-size: 11px; color: var(--s2-content-secondary); margin-top: -12px; margin-bottom: 16px;`,v.appendChild(x);let S=document.createElement(`div`);S.style.cssText=`color: var(--slicc-cone); font-size: 12px; margin-bottom: 8px; display: none;`;let C=document.createElement(`button`);return C.className=`dialog__btn`,C.textContent=t?`Save`:`Add`,{providerSelect:n,providerDesc:r,oauth:{section:i,loginBtn:a,status:o},apiKeySection:s,apiKeyLabel:c,apiKeyInput:l,baseUrlSection:u,baseUrlInput:f,baseUrlDesc:p,deploymentSection:m,deploymentInput:g,deploymentDesc:_,apiVersionSection:v,apiVersionInput:b,apiVersionDesc:x,errorEl:S,saveBtn:C}}function rn(e){let t=document.createElement(`div`);t.setAttribute(`data-slicc-device-code-prompt`,``),t.style.cssText=`display:flex;flex-direction:column;gap:8px`;let n=document.createElement(`div`);n.className=`dialog__desc`,n.textContent=`Verification code`,n.style.cssText=`font-size: 11px; color: var(--s2-content-tertiary);`;let r=document.createElement(`div`);r.textContent=e,r.style.cssText=[`font: 600 22px ui-monospace, SFMono-Regular, Menlo, monospace`,`letter-spacing: 2px`,`color: var(--s2-content-primary, #e6edf3)`,`background: var(--s2-bg-secondary, #161b22)`,`border: 1px solid var(--s2-border, #30363d)`,`border-radius: 6px`,`padding: 10px 12px`,`text-align: center`,`user-select: all`,`cursor: text`].join(`;`);let i=document.createElement(`div`);i.className=`dialog__desc`,i.style.cssText=`font-size: 12px; color: var(--s2-content-secondary);`,i.textContent=`Click Copy & Continue — we will open the GitHub authorization page in a new tab. Paste this code there if it is not already filled in.`;let a=document.createElement(`div`);a.style.cssText=`display:flex;gap:8px;justify-content:flex-end;margin-top:4px`;let o=document.createElement(`button`);o.type=`button`,o.className=`dialog__btn`,o.textContent=`Cancel`;let s=document.createElement(`button`);return s.type=`button`,s.className=`dialog__btn dialog__btn--primary`,s.textContent=`Copy & Continue`,a.appendChild(o),a.appendChild(s),t.appendChild(n),t.appendChild(r),t.appendChild(i),t.appendChild(a),{prompt:t,cancelBtn:o,continueBtn:s}}function an(e){return t=>new Promise(n=>{let r=e.loginBtn.style.display,i=e.status.style.display;e.loginBtn.style.display=`none`,e.status.style.display=`none`;let{prompt:a,cancelBtn:o,continueBtn:s}=rn(t.userCode),c=()=>{try{a.remove()}catch{}e.loginBtn.style.display=r,e.status.style.display=i};o.addEventListener(`click`,()=>{c(),n(`cancel`)}),s.addEventListener(`click`,()=>{(async()=>{try{await Te(t.userCode)}catch{}c(),e.status.style.display=i,e.status.textContent=`Waiting for you to authorize in the new tab…`,n(`continue`)})()}),e.section.appendChild(a)})}async function on(e,n){let r=n.providerSelect.value;if(!r)return;let a=i(r);if(!a.onOAuthLogin&&!a.onOAuthLoginIntercepted)return;let{status:o}=n.oauth,s=w().some(e=>e.providerId===r),c=ve(r);if(a.requiresBaseUrl&&!n.baseUrlInput.value.trim()&&!c){o.textContent=`Base URL is required.`,o.style.color=`var(--slicc-cone)`,n.baseUrlInput.focus();return}a.requiresBaseUrl&&n.baseUrlInput.value.trim()&&T(r,``,n.baseUrlInput.value.trim()),o.textContent=`Opening login window...`;try{if(a.onOAuthLoginIntercepted){let{createInterceptingOAuthLauncherForCurrentRuntime:r}=await t(async()=>{let{createInterceptingOAuthLauncherForCurrentRuntime:e}=await import(`./oauth-service-YGl8VFS-.js`);return{createInterceptingOAuthLauncherForCurrentRuntime:e}},__vite__mapDeps([28,1,3,4,5,17,29])),i=await r();if(!i)throw Error(`No controlled-browser CDP transport available — open SLICC in standalone mode or the Chrome extension.`);await a.onOAuthLoginIntercepted(i,()=>J(e),{presentDeviceCode:an(n.oauth)})}else if(a.onOAuthLogin){let{createOAuthLauncher:n}=await t(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-YGl8VFS-.js`);return{createOAuthLauncher:e}},__vite__mapDeps([28,1,3,4,5,17,29])),r=n();await a.onOAuthLogin(r,()=>J(e))}}catch(e){if(!s)try{await m(r)}catch{}Ht.error(`OAuth login failed`,{providerId:r,error:e instanceof Error?e.message:String(e)}),o.textContent=`Login failed: ${e instanceof Error?e.message:String(e)}`}}function sn(e,t){if(t.isOAuth){e.oauth.section.style.display=``,e.apiKeySection.style.display=`none`,e.baseUrlSection.style.display=t.requiresBaseUrl?``:`none`,t.requiresBaseUrl&&(e.baseUrlInput.placeholder=t.baseUrlPlaceholder||`https://...`,e.baseUrlDesc.textContent=t.baseUrlDescription||``),e.oauth.loginBtn.textContent=`Login with ${t.name}`,e.saveBtn.style.display=`none`;return}e.oauth.section.style.display=`none`;let n=t.requiresApiKey?`API Key`:`API Key (optional)`;e.apiKeyLabel.textContent=`${n}${t.apiKeyEnvVar?` (${t.apiKeyEnvVar})`:``}:`,e.apiKeyInput.placeholder=t.apiKeyPlaceholder||`API key`,e.apiKeySection.style.display=t.requiresApiKey||t.optionalApiKey?``:`none`,e.baseUrlInput.placeholder=t.baseUrlPlaceholder||`https://...`,e.baseUrlDesc.textContent=t.baseUrlDescription||``,e.baseUrlSection.style.display=t.requiresBaseUrl?``:`none`,e.saveBtn.style.display=``}function cn(e,t){t.requiresDeployment?(e.deploymentSection.style.display=``,e.deploymentInput.placeholder=t.deploymentPlaceholder||`deployment-name`,e.deploymentDesc.textContent=t.deploymentDescription||``):e.deploymentSection.style.display=`none`}function ln(e,t){t.requiresApiVersion?(e.apiVersionSection.style.display=``,!e.apiVersionInput.value&&t.apiVersionDefault&&(e.apiVersionInput.value=t.apiVersionDefault),e.apiVersionInput.placeholder=t.apiVersionDefault||`api-version`,e.apiVersionDesc.textContent=t.apiVersionDescription||``):e.apiVersionSection.style.display=`none`}function un(e){let t=e.providerSelect.value;if(!t){e.providerDesc.textContent=``,e.oauth.section.style.display=`none`,e.apiKeySection.style.display=`none`,e.baseUrlSection.style.display=`none`,e.deploymentSection.style.display=`none`,e.apiVersionSection.style.display=`none`,e.saveBtn.style.display=`none`;return}let n=i(t);e.providerDesc.textContent=n.description,sn(e,n),cn(e,n),ln(e,n)}function X(e,t){let n=t.providerSelect.value;if(!n)return;let r=i(n),a=(e,n)=>{t.errorEl.textContent=e,t.errorEl.style.display=``,n.focus()};if(r.requiresApiKey&&t.apiKeyInput.value.trim().length<5){a(`API key is required (at least 5 characters).`,t.apiKeyInput);return}if(r.requiresBaseUrl&&!t.baseUrlInput.value.trim()){a(`Base URL is required for this provider.`,t.baseUrlInput);return}if(r.requiresDeployment&&!t.deploymentInput.value.trim()){a(`Deployment name is required for this provider.`,t.deploymentInput);return}T(n,t.apiKeyInput.value.trim(),t.baseUrlInput.value.trim()||void 0,t.deploymentInput.value.trim()||void 0,t.apiVersionInput.value.trim()||void 0),J(e)}function dn(e,t){let{dialog:n,options:r}=e,i=w().length>0;if(r?.startInAddAccount){let t=document.createElement(`button`);t.className=`dialog__btn dialog__btn--secondary`,t.style.marginTop=`8px`,t.textContent=`Cancel`,t.addEventListener(`click`,()=>q(e)),n.appendChild(t)}else if(!t&&!i){let t=document.createElement(`button`);t.className=`dialog__btn dialog__btn--secondary`,t.style.marginTop=`8px`,t.textContent=`Connect to another browser`,t.addEventListener(`click`,()=>Q(e)),n.appendChild(t)}else if(i){let t=document.createElement(`button`);t.className=`dialog__btn dialog__btn--secondary`,t.style.marginTop=`8px`,t.textContent=`Back`,t.addEventListener(`click`,()=>Y(e)),n.appendChild(t)}}function Z(e,t){let{dialog:n}=e;n.innerHTML=``;let r=document.createElement(`div`);r.className=`dialog__title`,r.textContent=t?`Edit Account`:`Add Account`,n.appendChild(r);let a=document.createElement(`div`);a.className=`dialog__desc`,a.textContent=`Provider:`,n.appendChild(a);let o=nn(e.options,t);n.appendChild(o.providerSelect),n.appendChild(o.providerDesc),o.oauth.loginBtn.addEventListener(`click`,()=>{on(e,o)}),t?.userName&&(o.oauth.status.textContent=`Logged in as ${t.userName}`,o.oauth.loginBtn.textContent=`Re-login`),n.appendChild(o.oauth.section),n.appendChild(o.apiKeySection),n.appendChild(o.baseUrlSection),n.appendChild(o.deploymentSection),n.appendChild(o.apiVersionSection),n.appendChild(o.errorEl),o.providerSelect.addEventListener(`change`,()=>{o.errorEl.style.display=`none`,un(o)}),un(o),o.saveBtn.addEventListener(`click`,()=>X(e,o));let s=t=>{t.key===`Enter`&&X(e,o)};o.apiKeyInput.addEventListener(`keydown`,s),o.baseUrlInput.addEventListener(`keydown`,s),o.deploymentInput.addEventListener(`keydown`,s),o.apiVersionInput.addEventListener(`keydown`,s),n.appendChild(o.saveBtn),dn(e,!!t),requestAnimationFrame(()=>{let e=o.providerSelect.value;if(!e)return;let t=i(e);t.requiresApiKey?o.apiKeyInput.focus():t.requiresBaseUrl&&o.baseUrlInput.focus()})}function fn(e,t,n,r){if(Ut()){let e={type:`refresh-tray-runtime`,joinUrl:t,workerBaseUrl:n};chrome.runtime.sendMessage({source:`panel`,payload:e}).catch(()=>{})}else Gt(t,r);r.textContent=`Connecting…`,r.style.display=``,r.style.color=`var(--s2-content-secondary)`;let i=setTimeout(()=>{e.overlay.remove(),e.resolve(!1)},800);r.dataset.dismissTimer=String(i)}function pn(e,t){let{dialog:n}=e;n.innerHTML=``;let r=document.createElement(`div`);r.className=`dialog__title`,r.textContent=`Connect this browser?`,n.appendChild(r);let i=document.createElement(`div`);i.className=`dialog__desc`,i.style.marginBottom=`12px`,i.textContent=`You’ve been invited to mirror another SLICC browser. Click below to start syncing.`,n.appendChild(i);let a=document.createElement(`div`);a.className=`dialog__desc`,a.style.cssText=`font-family: monospace; font-size: 11px; color: var(--s2-content-secondary); word-break: break-all; margin-bottom: 16px; padding: 8px; background: var(--s2-bg-secondary); border-radius: 4px;`,a.textContent=t.length>80?t.slice(0,40)+`…`+t.slice(-37):t,n.appendChild(a);let o=document.createElement(`div`);o.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); margin-bottom: 8px; display: none;`,n.appendChild(o);let s=document.createElement(`button`);s.className=`dialog__btn`,s.textContent=`Connect`,s.addEventListener(`click`,()=>{let n=Ze(window.localStorage,t);if(!n){o.textContent=`Invalid sync URL.`,o.style.display=``,o.style.color=`var(--slicc-cone)`;return}fn(e,n.joinUrl,n.workerBaseUrl,o)}),n.appendChild(s);let c=document.createElement(`button`);c.className=`dialog__btn dialog__btn--secondary`,c.style.marginTop=`8px`,c.textContent=`Set up an account instead`,c.addEventListener(`click`,()=>Z(e)),n.appendChild(c)}function mn(){let e=document.createElement(`details`);e.style.cssText=`margin-bottom: 12px; font-size: 12px; color: var(--s2-content-secondary);`;let t=document.createElement(`summary`);t.style.cssText=`cursor: pointer; user-select: none; color: var(--s2-content-secondary);`,t.textContent=`How do I get the sync URL?`,e.appendChild(t);let n=document.createElement(`div`);n.style.cssText=`margin-top: 8px; padding: 10px 12px; background: var(--s2-bg-layer-2); border-radius: var(--s2-radius-default); border: 1px solid var(--s2-border-subtle); line-height: 1.5;`;let r=document.createElement(`ol`);r.style.cssText=`margin: 0; padding-left: 20px;`;for(let e of[`On the other SLICC, click the avatar (top right).`,`Choose “Enable multi-browser sync” — the URL is copied automatically.`,`Paste it below. Both browsers must be on the same SLICC version.`]){let t=document.createElement(`li`);t.textContent=e,r.appendChild(t)}return n.appendChild(r),e.appendChild(n),e}function Q(e){let{dialog:t}=e;t.innerHTML=``;let n=document.createElement(`div`);n.className=`dialog__title`,n.textContent=`Connect to another browser`,t.appendChild(n);let r=document.createElement(`div`);r.className=`dialog__desc`,r.style.marginBottom=`12px`,r.textContent=`Paste a multi-browser sync URL to mirror another SLICC browser.`,t.appendChild(r),t.appendChild(mn());let i=document.createElement(`div`);i.className=`dialog__desc`,i.textContent=`Sync URL:`,t.appendChild(i);let a=document.createElement(`input`);a.className=`dialog__input`,a.type=`text`,a.autocomplete=`off`,a.spellcheck=!1,a.placeholder=`https://www.sliccy.ai/join/<token>`,t.appendChild(a);let o=document.createElement(`div`);o.style.cssText=`color: var(--slicc-cone); font-size: 12px; margin-bottom: 8px; display: none;`,t.appendChild(o);let s=document.createElement(`div`);s.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); margin-bottom: 8px; display: none;`;let c=document.createElement(`button`);c.className=`dialog__btn`,c.textContent=`Connect`,c.addEventListener(`click`,()=>{let t=a.value.trim();if(!t){o.textContent=`Paste a sync URL to continue.`,o.style.display=``,a.focus();return}let n=Ze(window.localStorage,t);if(!n){o.textContent=Bt(t),o.style.display=``,a.focus();return}fn(e,n.joinUrl,n.workerBaseUrl,s)}),t.appendChild(c),t.appendChild(s);let l=document.createElement(`button`);l.className=`dialog__btn dialog__btn--secondary`,l.style.marginTop=`8px`,l.textContent=`Back`,l.addEventListener(`click`,()=>Z(e)),t.appendChild(l),a.addEventListener(`input`,()=>{o.style.display=`none`}),a.addEventListener(`keydown`,e=>{e.key===`Enter`&&c.click()}),requestAnimationFrame(()=>a.focus())}function hn(e){return jt(`button`),new Promise(t=>{let n=document.createElement(`div`);n.className=`dialog-overlay`;let r=document.createElement(`div`);r.className=`dialog`,r.style.cssText=`max-width: 480px; width: 90vw; padding: 32px;`;let i={overlay:n,dialog:r,options:e,accountsBefore:localStorage.getItem(`slicc_accounts`)??``,resolve:t};e?.startInAddAccount?Z(i):w().length>0?Y(i):e?.autoJoinUrl?pn(i,e.autoJoinUrl):e?.preferTrayJoin?Q(i):Z(i),n.appendChild(r),document.body.appendChild(n)})}var $=E(`main`);function gn(e){try{return new URL(e).searchParams.has(`ui-fixture`)}catch{return!1}}async function _n(){let e=document.getElementById(`app`);if(!e)throw Error(`#app element not found`);let n=typeof chrome<`u`&&!!chrome?.runtime?.id,r=st(window.location.href,n);if(gn(window.location.href)){let{mountWcUiPreview:n}=await t(async()=>{let{mountWcUiPreview:e}=await import(`./wc-shell-F5Wp6J-I.js`).then(e=>e.a);return{mountWcUiPreview:e}},__vite__mapDeps([30,4,1,21,31,32,33]));n(e);return}Be(),Ue(),r!==`connect`&&Dt().catch(()=>{});let i=D(window.location.search),a=r===`cherry`?null:mt(window.location.search),o=!!a&&F();if(await vt(i?{apiBaseUrl:i.apiBaseUrl,token:i.token}:null,o&&a?{extensionId:a.extensionId}:null)===`reload-pending`)return;await de(),S();let{bootstrapOAuthReplicas:s}=await t(async()=>{let{bootstrapOAuthReplicas:e}=await import(`./oauth-bootstrap-Bsf5hex-.js`);return{bootstrapOAuthReplicas:e}},__vite__mapDeps([34,1,8,4,9,10,11,12,13,2,14,3,5,15,16,17,18,19,20]));if(await Promise.race([s().catch(e=>{$.error(`OAuth bootstrap failed`,e)}),new Promise(e=>setTimeout(e,1e4))]),r===`connect`){globalThis.__slicc_connect_mode=!0;let{loadLegacyStyles:n}=await t(async()=>{let{loadLegacyStyles:e}=await import(`./legacy-styles-4PP74ISo.js`);return{loadLegacyStyles:e}},__vite__mapDeps([35,1]));await n();let{mountConnectSurface:r}=await t(async()=>{let{mountConnectSurface:e}=await import(`./connect-surface-BHwPGe-M.js`);return{mountConnectSurface:e}},__vite__mapDeps([36,8,4,1,9,10,11,12,13,2,14,3,5,15,16,17,18,19,20]));await r(e);return}if(n){let{mountWcUiExtension:n}=await t(async()=>{let{mountWcUiExtension:e}=await import(`./wc-extension-Bp34NH6Q.js`);return{mountWcUiExtension:e}},__vite__mapDeps([37,1,38,8,4,9,10,11,12,13,2,14,3,5,15,16,17,18,19,20,30,21,31,32,33,39,40,41,42,43,44,45,46,47,48,29,49]));return n(e,$,r===`extension-detached`)}o&&a&&ze(a.extensionId);let{mountWcUiLive:c}=await t(async()=>{let{mountWcUiLive:e}=await import(`./wc-live-DOXieP5u.js`);return{mountWcUiLive:e}},__vite__mapDeps([38,1,8,4,9,10,11,12,13,2,14,3,5,15,16,17,18,19,20,30,21,31,32,33,39,40,41,42,43,44,45,46,47,48,29]));return c(e,$,r)}_n().catch(e=>{$.error(`Fatal error`,e);let t=document.getElementById(`app`);if(t){let n=document.createElement(`div`);n.style.cssText=`padding: 2rem; text-align: center;`;let r=document.createElement(`h1`);r.style.color=`var(--s2-negative, #e34850)`,r.textContent=`Failed to start`;let i=document.createElement(`p`);for(i.style.color=`var(--s2-content-tertiary, #717171)`,i.textContent=e.message,n.appendChild(r),n.appendChild(i);t.firstChild;)t.removeChild(t.firstChild);t.appendChild(n)}});export{Qe as _,At as a,Ee as b,Ct as c,ut as d,Ye as f,Xe as g,et as h,Ot as i,St as l,A as m,hn as n,kt as o,j as p,Rt as r,B as s,Vt as t,_t as u,tt as v,Me as y};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-D8YLtENA.js","assets/chunk-aKtaBQYM.js","assets/preload-helper-zJ_50EbN.js","assets/dist-BmWy99kl.js","assets/event-stream-BJI_nGaK.js","assets/json-parse-BUunmmNl.js","assets/__vite-browser-external-C7iut881.js","assets/context-compaction-CFWyOzX1.js","assets/logger-DDBAeTLF.js","assets/src-DlEHAkLd.js","assets/proxied-fetch-CKDBmEMl.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-bwXIzzAK.js","assets/secrets-bridge-client-BSipj-5f.js","assets/panel-rpc-DqT2FG7c.js","assets/bedrock-camp-9-QEmC9Z.js","assets/transform-messages-DzB_lMo-.js","assets/tool-ui-DfXu6quJ.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-zJ_50EbN.js";import{t}from"./mime-types-ugOWOUZ9.js";import{a as n,n as r,t as i}from"./proxied-fetch-CKDBmEMl.js";import"./src-DlEHAkLd.js";import{t as a}from"./types-idfTVsM8.js";import"./mount-id-_7_PCY9F.js";import{t as o}from"./mount-bridge-client-DDnAgZEL.js";function s(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function c(e){return e.split(`/`).pop()||`data`}function l(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var u=5*1024*1024,d=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=l(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??u,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new a(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new a(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new a(`EACCES`,`da access denied`,e);if(i.status>=400)throw new a(`EIO`,`da readFile failed: ${i.status}`,e);let o=i.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new a(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new a(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new a(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),i=await this.cache.getBody(r),o=s(c(e),t(e),n),l={"content-type":o.contentType,"content-length":String(o.body.byteLength)};i?.etag?l[`if-match`]=i.etag.startsWith(`W/`)?i.etag.slice(2):i.etag:i||(l[`if-none-match`]=`*`);let u=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:l,body:o.body}),d,f=1;try{d=await u()}catch{f=2,d=await u()}if(d.status===412){if(f===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new a(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let i=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,i);let o=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new a(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(d.status===401||d.status===403)throw new a(`EACCES`,`da write denied`,e);if(d.status>=400)throw new a(`EIO`,`da writeFile failed: ${d.status}`,e);let p=d.headers.get(`etag`)??``;await this.cache.putBody(r,n,p);let m=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new a(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new a(`EIO`,`da list failed: ${r.status}`,e);let i=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new a(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new a(`ENOENT`,`no such file or directory`,e)}throw new a(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new a(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new a(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new a(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function f(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var p=25*1024*1024,m=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=f(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??p,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new a(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new a(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new a(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new a(`EIO`,`s3 readFile failed: ${i.status}`,e);let o=i.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new a(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new a(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new a(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new a(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new a(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new a(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new a(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new a(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),o=this.parseListingXml(i);e.push(...o.contents),t=o.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new a(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new a(`ENOENT`,`no such file or directory`,e)}throw new a(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new a(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new a(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new a(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new a(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},h=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function g(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-D8YLtENA.js`).then(e=>e.r);return{getAccounts:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new h(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var _=`slicc-mount-cache`,v=`listings`,y=`bodies`,b=class{mountId;ttlMs;dbName;dbPromise=null;constructor(e){this.mountId=e.mountId,this.ttlMs=e.ttlMs,this.dbName=e.dbName??_}isStale(e,t){return Date.now()-e>=(t??this.ttlMs)}async openDb(){return this.dbPromise||=new Promise((e,t)=>{let n=indexedDB.open(this.dbName,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(v)||e.createObjectStore(v),e.objectStoreNames.contains(y)||e.createObjectStore(y)},n.onsuccess=()=>{let t=n.result;t.onversionchange=()=>{t.close(),this.dbPromise=null},t.onclose=()=>{this.dbPromise=null},e(t)},n.onerror=()=>t(n.error)}),this.dbPromise}key(e){return`${this.mountId}::${e}`}async getListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(v,`readonly`).objectStore(v).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putListing(e,t){let n=await this.openDb();return new Promise((r,i)=>{let a=n.transaction(v,`readwrite`),o={entries:t,cachedAt:Date.now()};a.objectStore(v).put(o,this.key(e)),a.oncomplete=()=>r(),a.onerror=()=>i(a.error)})}async invalidateListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(v,`readwrite`);i.objectStore(v).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async getBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(y,`readonly`).objectStore(y).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putBody(e,t,n){let r=await this.openDb(),i={body:t,etag:n,size:t.byteLength,cachedAt:Date.now()};try{await this.txPut(r,y,this.key(e),i)}catch(t){if(t instanceof DOMException&&t.name===`QuotaExceededError`){await this.evictLru(.25);try{await this.txPut(r,y,this.key(e),i)}catch{}return}throw t}}async invalidateBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(y,`readwrite`);i.objectStore(y).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async clearMount(){let e=await this.openDb(),t=`${this.mountId}::`,n=n=>new Promise((r,i)=>{let a=e.transaction(n,`readwrite`),o=a.objectStore(n),s=o.getAllKeys();s.onsuccess=()=>{for(let e of s.result)typeof e==`string`&&e.startsWith(t)&&o.delete(e)},a.oncomplete=()=>r(),a.onerror=()=>i(a.error)});await Promise.all([n(v),n(y)])}txPut(e,t,n,r){return new Promise((i,a)=>{let o=e.transaction(t,`readwrite`);o.objectStore(t).put(r,n),o.oncomplete=()=>i(),o.onerror=()=>a(o.error)})}async evictLru(e){let t=await this.openDb(),n=`${this.mountId}::`,r=await new Promise((e,r)=>{let i=t.transaction(y,`readonly`).objectStore(y),a=[],o=i.openCursor();o.onsuccess=()=>{let t=o.result;if(!t){e(a);return}if(typeof t.key==`string`&&t.key.startsWith(n)){let e=t.value;a.push({key:t.key,cachedAt:e.cachedAt})}t.continue()},o.onerror=()=>r(o.error)});r.sort((e,t)=>e.cachedAt-t.cachedAt);let i=Math.max(1,Math.ceil(r.length*e)),a=r.slice(0,i);await new Promise((e,n)=>{let r=t.transaction(y,`readwrite`),i=r.objectStore(y);for(let{key:e}of a)i.delete(e);r.oncomplete=()=>e(),r.onerror=()=>n(r.error)})}};function x(){return typeof chrome<`u`&&!!chrome?.runtime?.id}function S(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function C(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}var w=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),T=new Set([101,103,204,205,304]);function E(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new a(`EACCES`,e.error):e.errorCode===`invalid_request`?new a(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||w.has(String(e.errorCode))?new a(`EIO`,e.error):new a(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=S(e.bodyBase64)}catch(e){throw new a(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=T.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function D(e,t){let r;try{r=await fetch(n(e),{method:`POST`,headers:i({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new a(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await r.json()}catch(e){throw new a(`EIO`,`mount transport: response is not a JSON envelope (status ${r.status}): ${e instanceof Error?e.message:String(e)}`)}}async function O(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new a(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function k(e,t,n){return x()?O(e,n):r()?o(e,n):D(t,n)}function A(e){return async t=>E(await k(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?C(t.body):void 0}))}function j(e){let t=e?.getImsToken??(async()=>(await g()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new a(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return E(await k(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?C(e.body):void 0}))}}export{d as DaMountBackend,b as RemoteMountCache,m as S3MountBackend,j as makeSignedFetchDa,A as makeSignedFetchS3};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-CeSn6D5H.js","assets/chunk-aKtaBQYM.js","assets/preload-helper-zJ_50EbN.js","assets/dist-BmWy99kl.js","assets/event-stream-BJI_nGaK.js","assets/json-parse-BUunmmNl.js","assets/__vite-browser-external-C7iut881.js","assets/context-compaction-CFWyOzX1.js","assets/logger-DDBAeTLF.js","assets/src-DlEHAkLd.js","assets/proxied-fetch-CKDBmEMl.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-bwXIzzAK.js","assets/secrets-bridge-client-BSipj-5f.js","assets/panel-rpc-DqT2FG7c.js","assets/bedrock-camp-9-QEmC9Z.js","assets/transform-messages-DzB_lMo-.js","assets/tool-ui-DfXu6quJ.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-zJ_50EbN.js";import{t}from"./mime-types-ugOWOUZ9.js";import{a as n,n as r,t as i}from"./proxied-fetch-CKDBmEMl.js";import"./src-DlEHAkLd.js";import{t as a}from"./types-idfTVsM8.js";import"./mount-id-_7_PCY9F.js";import{t as o}from"./mount-bridge-client-DDnAgZEL.js";function s(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function c(e){return e.split(`/`).pop()||`data`}function l(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var u=5*1024*1024,d=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=l(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??u,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new a(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new a(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new a(`EACCES`,`da access denied`,e);if(i.status>=400)throw new a(`EIO`,`da readFile failed: ${i.status}`,e);let o=i.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new a(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new a(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new a(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),i=await this.cache.getBody(r),o=s(c(e),t(e),n),l={"content-type":o.contentType,"content-length":String(o.body.byteLength)};i?.etag?l[`if-match`]=i.etag.startsWith(`W/`)?i.etag.slice(2):i.etag:i||(l[`if-none-match`]=`*`);let u=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:l,body:o.body}),d,f=1;try{d=await u()}catch{f=2,d=await u()}if(d.status===412){if(f===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new a(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let i=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,i);let o=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new a(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(d.status===401||d.status===403)throw new a(`EACCES`,`da write denied`,e);if(d.status>=400)throw new a(`EIO`,`da writeFile failed: ${d.status}`,e);let p=d.headers.get(`etag`)??``;await this.cache.putBody(r,n,p);let m=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new a(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new a(`EIO`,`da list failed: ${r.status}`,e);let i=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new a(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new a(`ENOENT`,`no such file or directory`,e)}throw new a(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new a(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new a(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new a(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function f(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var p=25*1024*1024,m=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=f(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??p,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new a(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new a(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new a(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new a(`EIO`,`s3 readFile failed: ${i.status}`,e);let o=i.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new a(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new a(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new a(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new a(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new a(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new a(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new a(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new a(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),o=this.parseListingXml(i);e.push(...o.contents),t=o.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new a(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new a(`ENOENT`,`no such file or directory`,e)}throw new a(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new a(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new a(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new a(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new a(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},h=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function g(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-CeSn6D5H.js`).then(e=>e.r);return{getAccounts:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new h(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var _=`slicc-mount-cache`,v=`listings`,y=`bodies`,b=class{mountId;ttlMs;dbName;dbPromise=null;constructor(e){this.mountId=e.mountId,this.ttlMs=e.ttlMs,this.dbName=e.dbName??_}isStale(e,t){return Date.now()-e>=(t??this.ttlMs)}async openDb(){return this.dbPromise||=new Promise((e,t)=>{let n=indexedDB.open(this.dbName,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(v)||e.createObjectStore(v),e.objectStoreNames.contains(y)||e.createObjectStore(y)},n.onsuccess=()=>{let t=n.result;t.onversionchange=()=>{t.close(),this.dbPromise=null},t.onclose=()=>{this.dbPromise=null},e(t)},n.onerror=()=>t(n.error)}),this.dbPromise}key(e){return`${this.mountId}::${e}`}async getListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(v,`readonly`).objectStore(v).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putListing(e,t){let n=await this.openDb();return new Promise((r,i)=>{let a=n.transaction(v,`readwrite`),o={entries:t,cachedAt:Date.now()};a.objectStore(v).put(o,this.key(e)),a.oncomplete=()=>r(),a.onerror=()=>i(a.error)})}async invalidateListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(v,`readwrite`);i.objectStore(v).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async getBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(y,`readonly`).objectStore(y).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putBody(e,t,n){let r=await this.openDb(),i={body:t,etag:n,size:t.byteLength,cachedAt:Date.now()};try{await this.txPut(r,y,this.key(e),i)}catch(t){if(t instanceof DOMException&&t.name===`QuotaExceededError`){await this.evictLru(.25);try{await this.txPut(r,y,this.key(e),i)}catch{}return}throw t}}async invalidateBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(y,`readwrite`);i.objectStore(y).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async clearMount(){let e=await this.openDb(),t=`${this.mountId}::`,n=n=>new Promise((r,i)=>{let a=e.transaction(n,`readwrite`),o=a.objectStore(n),s=o.getAllKeys();s.onsuccess=()=>{for(let e of s.result)typeof e==`string`&&e.startsWith(t)&&o.delete(e)},a.oncomplete=()=>r(),a.onerror=()=>i(a.error)});await Promise.all([n(v),n(y)])}txPut(e,t,n,r){return new Promise((i,a)=>{let o=e.transaction(t,`readwrite`);o.objectStore(t).put(r,n),o.oncomplete=()=>i(),o.onerror=()=>a(o.error)})}async evictLru(e){let t=await this.openDb(),n=`${this.mountId}::`,r=await new Promise((e,r)=>{let i=t.transaction(y,`readonly`).objectStore(y),a=[],o=i.openCursor();o.onsuccess=()=>{let t=o.result;if(!t){e(a);return}if(typeof t.key==`string`&&t.key.startsWith(n)){let e=t.value;a.push({key:t.key,cachedAt:e.cachedAt})}t.continue()},o.onerror=()=>r(o.error)});r.sort((e,t)=>e.cachedAt-t.cachedAt);let i=Math.max(1,Math.ceil(r.length*e)),a=r.slice(0,i);await new Promise((e,n)=>{let r=t.transaction(y,`readwrite`),i=r.objectStore(y);for(let{key:e}of a)i.delete(e);r.oncomplete=()=>e(),r.onerror=()=>n(r.error)})}};function x(){return typeof chrome<`u`&&!!chrome?.runtime?.id}function S(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function C(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}var w=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),T=new Set([101,103,204,205,304]);function E(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new a(`EACCES`,e.error):e.errorCode===`invalid_request`?new a(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||w.has(String(e.errorCode))?new a(`EIO`,e.error):new a(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=S(e.bodyBase64)}catch(e){throw new a(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=T.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function D(e,t){let r;try{r=await fetch(n(e),{method:`POST`,headers:i({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new a(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await r.json()}catch(e){throw new a(`EIO`,`mount transport: response is not a JSON envelope (status ${r.status}): ${e instanceof Error?e.message:String(e)}`)}}async function O(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new a(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function k(e,t,n){return x()?O(e,n):r()?o(e,n):D(t,n)}function A(e){return async t=>E(await k(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?C(t.body):void 0}))}function j(e){let t=e?.getImsToken??(async()=>(await g()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new a(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return E(await k(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?C(e.body):void 0}))}}export{d as DaMountBackend,b as RemoteMountCache,m as S3MountBackend,j as makeSignedFetchDa,A as makeSignedFetchS3};
@@ -1 +1 @@
1
- import{n as e}from"./chunk-aKtaBQYM.js";import{t}from"./logger-LESFN7Hj.js";import"./backend-local-mrUgrni5.js";import{t as n}from"./types-idfTVsM8.js";import"./src-CpdsjHiA.js";import{t as r}from"./mime-types-BqLkKWa7.js";import{o as i,r as a,t as o}from"./proxied-fetch-CM0jk_Mr.js";import{t as s}from"./remote-cache-BL6NRenp.js";function c(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function l(e){return e.split(`/`).pop()||`data`}function u(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var d=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=u(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new n(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),r=await this.cache.getBody(t);if(r&&!this.cache.isStale(r.cachedAt))return r.body;let i={};r&&(i[`if-none-match`]=r.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:i});if(a.status===304&&r)return await this.cache.putBody(t,r.body,r.etag),r.body;if(a.status===404)throw await this.cache.invalidateBody(t),new n(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new n(`EACCES`,`da access denied`,e);if(a.status>=400)throw new n(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=this.toMountRelative(e),a=await this.cache.getBody(i),o=c(l(e),r(e),t),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let u=()=>this.transport({method:`POST`,path:this.toSourcePath(i),headers:s,body:o.body}),d,f=1;try{d=await u()}catch{f=2,d=await u()}if(d.status===412){if(f===2){let r=await this.transport({method:`HEAD`,path:this.toSourcePath(i)});if(r.status>=400)throw new n(`EIO`,`da reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(i,t,a);let o=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(i);try{await this.readFile(e)}catch{}throw new n(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(d.status===401||d.status===403)throw new n(`EACCES`,`da write denied`,e);if(d.status>=400)throw new n(`EIO`,`da writeFile failed: ${d.status}`,e);let p=d.headers.get(`etag`)??``;await this.cache.putBody(i,t,p);let m=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),r=await this.cache.getListing(t);if(r&&!this.cache.isStale(r.cachedAt))return r.entries;let i=await this.transport({method:`GET`,path:this.toListPath(t)});if(i.status===404)throw new n(`ENOENT`,`no such directory`,e);if(i.status>=400)throw new n(`EIO`,`da list failed: ${i.status}`,e);let a=(await i.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),r=await this.cache.getBody(t);if(r)return{kind:`file`,size:r.size,mtime:r.cachedAt,etag:r.etag};let i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new n(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let r=await this.cache.getListing(t);if(r)return{kind:`directory`,size:0,mtime:r.cachedAt};throw new n(`ENOENT`,`no such file or directory`,e)}throw new n(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),r=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(r.status===404)throw new n(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new n(`EACCES`,`da delete denied`,e);if(r.status>=400)throw new n(`EIO`,`da delete failed: ${r.status}`,e);await this.cache.invalidateBody(t);let i=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function f(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var p=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=f(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new n(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),r=await this.cache.getBody(t);if(r&&!this.cache.isStale(r.cachedAt))return r.body;let i={};r&&(i[`if-none-match`]=r.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:i});if(a.status===304&&r)return await this.cache.putBody(t,r.body,r.etag),r.body;if(a.status===404)throw await this.cache.invalidateBody(t),new n(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new n(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new n(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let r=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=await this.cache.getBody(r),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};i?a[`if-match`]=i.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(r),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let i=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(r)});if(i.status>=400)throw new n(`EIO`,`s3 reconcile HEAD failed: ${i.status}`,e);let a=i.headers.get(`etag`)??``;await this.cache.putBody(r,t,a);let o=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new n(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new n(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new n(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(r,t,l);let u=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let r={"list-type":`2`};this.parsed.prefix&&(r.prefix=`${this.parsed.prefix}/`),t&&(r[`continuation-token`]=t);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:r});if(i.status>=400)throw new n(`EIO`,`s3 list failed: ${i.status}`,`/`);let a=await i.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),r=await this.cache.getBody(t);if(r)return{kind:`file`,size:r.body.byteLength,mtime:r.cachedAt,etag:r.etag};let i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new n(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let r=await this.cache.getListing(t);if(r)return{kind:`directory`,size:0,mtime:r.cachedAt};throw new n(`ENOENT`,`no such file or directory`,e)}throw new n(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let r=this.toMountRelative(e);if(t?.recursive)throw new n(`EINVAL`,`recursive remove not yet supported on S3`,e);let i=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(r)});if(i.status===404)throw new n(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new n(`EACCES`,`s3 delete denied`,e);if(i.status>=400)throw new n(`EIO`,`s3 delete failed: ${i.status}`,e);await this.cache.invalidateBody(r);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},m=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function h(){let{getAccounts:e}=await import(`./account-store-Mno_jQCd.js`).then(e=>e.n),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new m(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}const g=t(`mount-bridge`),_=12e4;let v=null,y=1;const b=new Map;function x(e){let t=e;if(typeof t?.id!=`number`)return;let n=b.get(t.id);n&&(b.delete(t.id),clearTimeout(n.timer),n.resolve(t.response))}function S(){v=null;for(let[,e]of b)clearTimeout(e.timer),e.reject(new n(`EIO`,`mount.sign-and-forward port disconnected`));b.clear(),g.debug(`mount.sign-and-forward port disconnected; pending cleared, will reconnect`)}function C(){if(v)return v;let e=a();if(!e)return g.warn(`cannot open mount.sign-and-forward port: no extension delegate id`),null;if(typeof chrome>`u`||typeof chrome?.runtime?.connect!=`function`)return g.warn(`cannot open mount.sign-and-forward port: chrome.runtime.connect unavailable`),null;let t=chrome.runtime.connect,n=t(e,{name:`mount.sign-and-forward`});return n.onMessage.addListener(x),n.onDisconnect.addListener(S),v=n,n}function w(e,t){return typeof chrome>`u`&&a()?E(e,t):T(e,t)}function T(e,t){return new Promise((r,i)=>{let a=C();if(!a){i(new n(`EIO`,`mount transport failed: extension delegate unavailable (${e})`));return}let o=y++,s=setTimeout(()=>{b.delete(o)&&i(new n(`EIO`,`mount transport: ${e} timed out`))},_);b.set(o,{resolve:r,reject:i,timer:s});try{a.postMessage({id:o,type:e,envelope:t})}catch(e){b.delete(o),clearTimeout(s),v=null,i(new n(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)}`))}})}async function E(e,t){let{getPanelRpcClient:r}=await import(`./panel-rpc-D0J5pskz.js`).then(e=>e.i),i=r();if(!i)throw new n(`EIO`,`mount transport failed: panel-RPC client unavailable in worker realm (${e})`);let{reply:a}=await i.call(`mount-sign-and-forward`,{type:e,envelope:t},{timeoutMs:_});return a}function D(){return typeof chrome<`u`&&!!chrome?.runtime?.id}function O(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function k(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}const A=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),j=new Set([101,103,204,205,304]);function M(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new n(`EACCES`,e.error):e.errorCode===`invalid_request`?new n(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||A.has(String(e.errorCode))?new n(`EIO`,e.error):new n(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=O(e.bodyBase64)}catch(e){throw new n(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let r=j.has(e.status)?null:t;return new Response(r,{status:e.status,headers:new Headers(e.headers)})}async function N(e,t){let r;try{r=await fetch(i(e),{method:`POST`,headers:o({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new n(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await r.json()}catch(e){throw new n(`EIO`,`mount transport: response is not a JSON envelope (status ${r.status}): ${e instanceof Error?e.message:String(e)}`)}}async function P(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new n(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function F(e,t,n){return D()?P(e,n):a()?w(e,n):N(t,n)}function I(e){return async t=>M(await F(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?k(t.body):void 0}))}function L(e){let t=e?.getImsToken??(async()=>(await h()).getBearerToken());return async e=>{let r;try{r=await t()}catch(e){throw new n(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return M(await F(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:r,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?k(e.body):void 0}))}}var R=e({DaMountBackend:()=>d,RemoteMountCache:()=>s,S3MountBackend:()=>p,makeSignedFetchDa:()=>L,makeSignedFetchS3:()=>I});export{d as a,p as i,L as n,I as r,R as t};
1
+ import{n as e}from"./chunk-aKtaBQYM.js";import{t}from"./logger-LESFN7Hj.js";import"./backend-local-mrUgrni5.js";import{t as n}from"./types-idfTVsM8.js";import"./src-CpdsjHiA.js";import{t as r}from"./mime-types-BqLkKWa7.js";import{o as i,r as a,t as o}from"./proxied-fetch-CM0jk_Mr.js";import{t as s}from"./remote-cache-BL6NRenp.js";function c(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function l(e){return e.split(`/`).pop()||`data`}function u(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var d=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=u(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new n(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),r=await this.cache.getBody(t);if(r&&!this.cache.isStale(r.cachedAt))return r.body;let i={};r&&(i[`if-none-match`]=r.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:i});if(a.status===304&&r)return await this.cache.putBody(t,r.body,r.etag),r.body;if(a.status===404)throw await this.cache.invalidateBody(t),new n(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new n(`EACCES`,`da access denied`,e);if(a.status>=400)throw new n(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=this.toMountRelative(e),a=await this.cache.getBody(i),o=c(l(e),r(e),t),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let u=()=>this.transport({method:`POST`,path:this.toSourcePath(i),headers:s,body:o.body}),d,f=1;try{d=await u()}catch{f=2,d=await u()}if(d.status===412){if(f===2){let r=await this.transport({method:`HEAD`,path:this.toSourcePath(i)});if(r.status>=400)throw new n(`EIO`,`da reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(i,t,a);let o=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(i);try{await this.readFile(e)}catch{}throw new n(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(d.status===401||d.status===403)throw new n(`EACCES`,`da write denied`,e);if(d.status>=400)throw new n(`EIO`,`da writeFile failed: ${d.status}`,e);let p=d.headers.get(`etag`)??``;await this.cache.putBody(i,t,p);let m=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),r=await this.cache.getListing(t);if(r&&!this.cache.isStale(r.cachedAt))return r.entries;let i=await this.transport({method:`GET`,path:this.toListPath(t)});if(i.status===404)throw new n(`ENOENT`,`no such directory`,e);if(i.status>=400)throw new n(`EIO`,`da list failed: ${i.status}`,e);let a=(await i.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),r=await this.cache.getBody(t);if(r)return{kind:`file`,size:r.size,mtime:r.cachedAt,etag:r.etag};let i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new n(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let r=await this.cache.getListing(t);if(r)return{kind:`directory`,size:0,mtime:r.cachedAt};throw new n(`ENOENT`,`no such file or directory`,e)}throw new n(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),r=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(r.status===404)throw new n(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new n(`EACCES`,`da delete denied`,e);if(r.status>=400)throw new n(`EIO`,`da delete failed: ${r.status}`,e);await this.cache.invalidateBody(t);let i=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function f(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var p=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=f(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new n(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),r=await this.cache.getBody(t);if(r&&!this.cache.isStale(r.cachedAt))return r.body;let i={};r&&(i[`if-none-match`]=r.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:i});if(a.status===304&&r)return await this.cache.putBody(t,r.body,r.etag),r.body;if(a.status===404)throw await this.cache.invalidateBody(t),new n(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new n(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new n(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let r=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=await this.cache.getBody(r),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};i?a[`if-match`]=i.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(r),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let i=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(r)});if(i.status>=400)throw new n(`EIO`,`s3 reconcile HEAD failed: ${i.status}`,e);let a=i.headers.get(`etag`)??``;await this.cache.putBody(r,t,a);let o=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new n(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new n(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new n(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(r,t,l);let u=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let r={"list-type":`2`};this.parsed.prefix&&(r.prefix=`${this.parsed.prefix}/`),t&&(r[`continuation-token`]=t);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:r});if(i.status>=400)throw new n(`EIO`,`s3 list failed: ${i.status}`,`/`);let a=await i.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),r=await this.cache.getBody(t);if(r)return{kind:`file`,size:r.body.byteLength,mtime:r.cachedAt,etag:r.etag};let i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new n(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let r=await this.cache.getListing(t);if(r)return{kind:`directory`,size:0,mtime:r.cachedAt};throw new n(`ENOENT`,`no such file or directory`,e)}throw new n(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let r=this.toMountRelative(e);if(t?.recursive)throw new n(`EINVAL`,`recursive remove not yet supported on S3`,e);let i=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(r)});if(i.status===404)throw new n(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new n(`EACCES`,`s3 delete denied`,e);if(i.status>=400)throw new n(`EIO`,`s3 delete failed: ${i.status}`,e);await this.cache.invalidateBody(r);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},m=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function h(){let{getAccounts:e}=await import(`./account-store-rEr_WCiZ.js`).then(e=>e.n),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new m(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}const g=t(`mount-bridge`),_=12e4;let v=null,y=1;const b=new Map;function x(e){let t=e;if(typeof t?.id!=`number`)return;let n=b.get(t.id);n&&(b.delete(t.id),clearTimeout(n.timer),n.resolve(t.response))}function S(){v=null;for(let[,e]of b)clearTimeout(e.timer),e.reject(new n(`EIO`,`mount.sign-and-forward port disconnected`));b.clear(),g.debug(`mount.sign-and-forward port disconnected; pending cleared, will reconnect`)}function C(){if(v)return v;let e=a();if(!e)return g.warn(`cannot open mount.sign-and-forward port: no extension delegate id`),null;if(typeof chrome>`u`||typeof chrome?.runtime?.connect!=`function`)return g.warn(`cannot open mount.sign-and-forward port: chrome.runtime.connect unavailable`),null;let t=chrome.runtime.connect,n=t(e,{name:`mount.sign-and-forward`});return n.onMessage.addListener(x),n.onDisconnect.addListener(S),v=n,n}function w(e,t){return typeof chrome>`u`&&a()?E(e,t):T(e,t)}function T(e,t){return new Promise((r,i)=>{let a=C();if(!a){i(new n(`EIO`,`mount transport failed: extension delegate unavailable (${e})`));return}let o=y++,s=setTimeout(()=>{b.delete(o)&&i(new n(`EIO`,`mount transport: ${e} timed out`))},_);b.set(o,{resolve:r,reject:i,timer:s});try{a.postMessage({id:o,type:e,envelope:t})}catch(e){b.delete(o),clearTimeout(s),v=null,i(new n(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)}`))}})}async function E(e,t){let{getPanelRpcClient:r}=await import(`./panel-rpc-D0J5pskz.js`).then(e=>e.i),i=r();if(!i)throw new n(`EIO`,`mount transport failed: panel-RPC client unavailable in worker realm (${e})`);let{reply:a}=await i.call(`mount-sign-and-forward`,{type:e,envelope:t},{timeoutMs:_});return a}function D(){return typeof chrome<`u`&&!!chrome?.runtime?.id}function O(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function k(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}const A=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),j=new Set([101,103,204,205,304]);function M(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new n(`EACCES`,e.error):e.errorCode===`invalid_request`?new n(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||A.has(String(e.errorCode))?new n(`EIO`,e.error):new n(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=O(e.bodyBase64)}catch(e){throw new n(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let r=j.has(e.status)?null:t;return new Response(r,{status:e.status,headers:new Headers(e.headers)})}async function N(e,t){let r;try{r=await fetch(i(e),{method:`POST`,headers:o({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new n(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await r.json()}catch(e){throw new n(`EIO`,`mount transport: response is not a JSON envelope (status ${r.status}): ${e instanceof Error?e.message:String(e)}`)}}async function P(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new n(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function F(e,t,n){return D()?P(e,n):a()?w(e,n):N(t,n)}function I(e){return async t=>M(await F(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?k(t.body):void 0}))}function L(e){let t=e?.getImsToken??(async()=>(await h()).getBearerToken());return async e=>{let r;try{r=await t()}catch(e){throw new n(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return M(await F(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:r,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?k(e.body):void 0}))}}var R=e({DaMountBackend:()=>d,RemoteMountCache:()=>s,S3MountBackend:()=>p,makeSignedFetchDa:()=>L,makeSignedFetchS3:()=>I});export{d as a,p as i,L as n,I as r,R as t};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-CtmD_Eqd.js","assets/chunk-aKtaBQYM.js","assets/account-store-D8YLtENA.js","assets/preload-helper-zJ_50EbN.js","assets/dist-BmWy99kl.js","assets/event-stream-BJI_nGaK.js","assets/json-parse-BUunmmNl.js","assets/__vite-browser-external-C7iut881.js","assets/context-compaction-CFWyOzX1.js","assets/logger-DDBAeTLF.js","assets/src-DlEHAkLd.js","assets/proxied-fetch-CKDBmEMl.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-bwXIzzAK.js","assets/secrets-bridge-client-BSipj-5f.js","assets/panel-rpc-DqT2FG7c.js","assets/bedrock-camp-9-QEmC9Z.js","assets/transform-messages-DzB_lMo-.js","assets/tool-ui-DfXu6quJ.js","assets/icons-BU6llBsN.js","assets/main-DsOZX9Xj.js","assets/modulepreload-polyfill-Dezn_h7o.js","assets/clipboard-DgFtRQbq.js","assets/llm-session-id-DVmZ9C2t.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-zJ_50EbN.js";import{F as t,m as n}from"./account-store-D8YLtENA.js";import{t as r}from"./logger-DDBAeTLF.js";import"./main-DsOZX9Xj.js";import{t as i}from"./llm-session-id-DVmZ9C2t.js";import{SessionStore as a}from"./session-store-CCH7W8KY.js";import{o,s}from"./wc-live-C6obLPXQ.js";var c=r(`new-session`),l=`ui-new-session`,u=2e4,d=250;async function f(r){let d=r.enrichmentRaceMs??u,f=n()??void 0,m;try{m=t()}catch(e){c.info(`No active model — freezing without LLM enrichment`,{error:e instanceof Error?e.message:String(e)})}let h=m?.provider===`adobe`?{"X-Session-Id":i(l)}:void 0,g=new a;try{await g.init()}catch(e){return c.warn(`SessionStore init failed — cannot freeze`,{error:e instanceof Error?e.message:String(e)}),null}let _=await s({sessionStore:g,vfs:r.vfs,mode:`quick`});if(!_)return null;if(!f||!m)return c.info(`Frozen without enrichment (no LLM credentials) — left pending`,{filename:_.filename}),_;let v=m,y=o(r.vfs,_,{model:v,apiKey:f,headers:h,pickIcon:t=>e(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-CtmD_Eqd.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])).then(({pickLucideIcon:e})=>e(t))}).catch(e=>(c.warn(`Single-click enrichment threw (entry stays pending)`,{filename:_.filename,error:e instanceof Error?e.message:String(e)}),null)),b=await p(y,d,r.onProgress);return b.kind===`llm`?b.updated?{...b.updated,archive:_.archive}:_:(y.then(e=>{c.info(`Background enrichment resolved after race window`,{filename:_.filename,enriched:e?.filename??null}),r.onBackgroundEnriched?.(e)}),_)}async function p(e,t,n){let r=Date.now(),i,a;n?.(0),n&&(i=setInterval(()=>{n(Math.min(1,(Date.now()-r)/t))},d));let o=new Promise(e=>{a=setTimeout(()=>e({kind:`timer`}),t)}),s=e.then(e=>({kind:`llm`,updated:e}));try{return await Promise.race([s,o])}finally{i&&clearInterval(i),a&&clearTimeout(a),n?.(null)}}async function m(e){let t=new a;try{await t.init()}catch(e){return c.warn(`SessionStore init failed — cannot quick-freeze`,{error:e instanceof Error?e.message:String(e)}),null}return s({sessionStore:t,vfs:e.vfs,mode:`quick`})}export{f as runNewSessionFreeze,m as runNewSessionFreezeQuick};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-BcoHwyQn.js","assets/chunk-aKtaBQYM.js","assets/account-store-CeSn6D5H.js","assets/preload-helper-zJ_50EbN.js","assets/dist-BmWy99kl.js","assets/event-stream-BJI_nGaK.js","assets/json-parse-BUunmmNl.js","assets/__vite-browser-external-C7iut881.js","assets/context-compaction-CFWyOzX1.js","assets/logger-DDBAeTLF.js","assets/src-DlEHAkLd.js","assets/proxied-fetch-CKDBmEMl.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-bwXIzzAK.js","assets/secrets-bridge-client-BSipj-5f.js","assets/panel-rpc-DqT2FG7c.js","assets/bedrock-camp-9-QEmC9Z.js","assets/transform-messages-DzB_lMo-.js","assets/tool-ui-DfXu6quJ.js","assets/icons-BU6llBsN.js","assets/main-D1QY7_Z4.js","assets/modulepreload-polyfill-Dezn_h7o.js","assets/clipboard-DgFtRQbq.js","assets/llm-session-id-DVmZ9C2t.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-zJ_50EbN.js";import{F as t,m as n}from"./account-store-CeSn6D5H.js";import{t as r}from"./logger-DDBAeTLF.js";import"./main-D1QY7_Z4.js";import{t as i}from"./llm-session-id-DVmZ9C2t.js";import{SessionStore as a}from"./session-store-CCH7W8KY.js";import{o,s}from"./wc-live-DOXieP5u.js";var c=r(`new-session`),l=`ui-new-session`,u=2e4,d=250;async function f(r){let d=r.enrichmentRaceMs??u,f=n()??void 0,m;try{m=t()}catch(e){c.info(`No active model — freezing without LLM enrichment`,{error:e instanceof Error?e.message:String(e)})}let h=m?.provider===`adobe`?{"X-Session-Id":i(l)}:void 0,g=new a;try{await g.init()}catch(e){return c.warn(`SessionStore init failed — cannot freeze`,{error:e instanceof Error?e.message:String(e)}),null}let _=await s({sessionStore:g,vfs:r.vfs,mode:`quick`});if(!_)return null;if(!f||!m)return c.info(`Frozen without enrichment (no LLM credentials) — left pending`,{filename:_.filename}),_;let v=m,y=o(r.vfs,_,{model:v,apiKey:f,headers:h,pickIcon:t=>e(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-BcoHwyQn.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])).then(({pickLucideIcon:e})=>e(t))}).catch(e=>(c.warn(`Single-click enrichment threw (entry stays pending)`,{filename:_.filename,error:e instanceof Error?e.message:String(e)}),null)),b=await p(y,d,r.onProgress);return b.kind===`llm`?b.updated?{...b.updated,archive:_.archive}:_:(y.then(e=>{c.info(`Background enrichment resolved after race window`,{filename:_.filename,enriched:e?.filename??null}),r.onBackgroundEnriched?.(e)}),_)}async function p(e,t,n){let r=Date.now(),i,a;n?.(0),n&&(i=setInterval(()=>{n(Math.min(1,(Date.now()-r)/t))},d));let o=new Promise(e=>{a=setTimeout(()=>e({kind:`timer`}),t)}),s=e.then(e=>({kind:`llm`,updated:e}));try{return await Promise.race([s,o])}finally{i&&clearInterval(i),a&&clearTimeout(a),n?.(null)}}async function m(e){let t=new a;try{await t.init()}catch(e){return c.warn(`SessionStore init failed — cannot quick-freeze`,{error:e instanceof Error?e.message:String(e)}),null}return s({sessionStore:t,vfs:e.vfs,mode:`quick`})}export{f as runNewSessionFreeze,m as runNewSessionFreezeQuick};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-BtXp6v_N.js","assets/preload-helper-zJ_50EbN.js","assets/account-store-D8YLtENA.js","assets/chunk-aKtaBQYM.js","assets/dist-BmWy99kl.js","assets/event-stream-BJI_nGaK.js","assets/json-parse-BUunmmNl.js","assets/__vite-browser-external-C7iut881.js","assets/context-compaction-CFWyOzX1.js","assets/logger-DDBAeTLF.js","assets/src-DlEHAkLd.js","assets/proxied-fetch-CKDBmEMl.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-bwXIzzAK.js","assets/secrets-bridge-client-BSipj-5f.js","assets/panel-rpc-DqT2FG7c.js","assets/bedrock-camp-9-QEmC9Z.js","assets/transform-messages-DzB_lMo-.js","assets/tool-ui-DfXu6quJ.js","assets/global-db-CbuLl-zx.js","assets/types-idfTVsM8.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-zJ_50EbN.js";import{G as t,R as n,d as r}from"./account-store-D8YLtENA.js";import{t as i}from"./logger-DDBAeTLF.js";import"./main-DsOZX9Xj.js";var a=i(`oauth-bootstrap`),o=6e4;async function s(){try{let{ensureAllMcpProvidersRegistered:t}=await e(async()=>{let{ensureAllMcpProvidersRegistered:e}=await import(`./provider-BtXp6v_N.js`);return{ensureAllMcpProvidersRegistered:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])),n=await t();n.length>0&&a.debug(`Pre-registered MCP providers for OAuth bootstrap`,{count:n.length})}catch(e){a.warn(`Failed to pre-register MCP providers for OAuth bootstrap`,{error:e instanceof Error?e.message:String(e)})}let i=r();a.info(`Bootstrap OAuth replicas`,{count:i.length});for(let e of i){if(!e.accessToken){a.debug(`Skipping account without token`,{providerId:e.providerId});continue}if((e.tokenExpiresAt??1/0)-Date.now()<=o){let n=t(e.providerId);if(n?.onSilentRenew)try{if(await n.onSilentRenew()){a.info(`Silently renewed OAuth token`,{providerId:e.providerId});continue}a.warn(`Silent renewal yielded no token; user must re-authenticate`,{providerId:e.providerId});continue}catch(t){a.warn(`Silent renewal failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)});continue}a.debug(`Skipping expired account (no silent-renew hook)`,{providerId:e.providerId});continue}try{await n({providerId:e.providerId,accessToken:e.accessToken,refreshToken:e.refreshToken,tokenExpiresAt:e.tokenExpiresAt,userName:e.userName,userAvatar:e.userAvatar}),a.debug(`Bootstrapped OAuth replica`,{providerId:e.providerId})}catch(t){a.error(`OAuth bootstrap failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)})}}}export{s as bootstrapOAuthReplicas};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-DCpkR_Qg.js","assets/preload-helper-zJ_50EbN.js","assets/account-store-CeSn6D5H.js","assets/chunk-aKtaBQYM.js","assets/dist-BmWy99kl.js","assets/event-stream-BJI_nGaK.js","assets/json-parse-BUunmmNl.js","assets/__vite-browser-external-C7iut881.js","assets/context-compaction-CFWyOzX1.js","assets/logger-DDBAeTLF.js","assets/src-DlEHAkLd.js","assets/proxied-fetch-CKDBmEMl.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-bwXIzzAK.js","assets/secrets-bridge-client-BSipj-5f.js","assets/panel-rpc-DqT2FG7c.js","assets/bedrock-camp-9-QEmC9Z.js","assets/transform-messages-DzB_lMo-.js","assets/tool-ui-DfXu6quJ.js","assets/global-db-CbuLl-zx.js","assets/types-idfTVsM8.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-zJ_50EbN.js";import{G as t,R as n,d as r}from"./account-store-CeSn6D5H.js";import{t as i}from"./logger-DDBAeTLF.js";import"./main-D1QY7_Z4.js";var a=i(`oauth-bootstrap`),o=6e4;async function s(){try{let{ensureAllMcpProvidersRegistered:t}=await e(async()=>{let{ensureAllMcpProvidersRegistered:e}=await import(`./provider-DCpkR_Qg.js`);return{ensureAllMcpProvidersRegistered:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])),n=await t();n.length>0&&a.debug(`Pre-registered MCP providers for OAuth bootstrap`,{count:n.length})}catch(e){a.warn(`Failed to pre-register MCP providers for OAuth bootstrap`,{error:e instanceof Error?e.message:String(e)})}let i=r();a.info(`Bootstrap OAuth replicas`,{count:i.length});for(let e of i){if(!e.accessToken){a.debug(`Skipping account without token`,{providerId:e.providerId});continue}if((e.tokenExpiresAt??1/0)-Date.now()<=o){let n=t(e.providerId);if(n?.onSilentRenew)try{if(await n.onSilentRenew()){a.info(`Silently renewed OAuth token`,{providerId:e.providerId});continue}a.warn(`Silent renewal yielded no token; user must re-authenticate`,{providerId:e.providerId});continue}catch(t){a.warn(`Silent renewal failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)});continue}a.debug(`Skipping expired account (no silent-renew hook)`,{providerId:e.providerId});continue}try{await n({providerId:e.providerId,accessToken:e.accessToken,refreshToken:e.refreshToken,tokenExpiresAt:e.tokenExpiresAt,userName:e.userName,userAvatar:e.userAvatar}),a.debug(`Bootstrapped OAuth replica`,{providerId:e.providerId})}catch(t){a.error(`OAuth bootstrap failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)})}}}export{s as bootstrapOAuthReplicas};