sliccy 5.31.4 → 5.31.5
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.
- package/dist/ui/assets/{account-store-QLqDJZ3y.js → account-store-Bk7BU4R2.js} +1 -1
- package/dist/ui/assets/{account-store-CjP3u0Xj.js → account-store-CWYCPgAg.js} +2 -2
- package/dist/ui/assets/{adobe-D014kRHR.js → adobe-b9KONAKs.js} +1 -1
- package/dist/ui/assets/{adobe-oauth-state-Bw9cHJvy.js → adobe-oauth-state-mA3vu6Bf.js} +1 -1
- package/dist/ui/assets/{adobe-1kG8VxBi.js → adobe-xFuU2zCa.js} +1 -1
- package/dist/ui/assets/{agent-message-to-chat-DAZlC-W0.js → agent-message-to-chat-D7tDL1mh.js} +1 -1
- package/dist/ui/assets/{apps-CQfWRwG1.js → apps-DjoNkGOL.js} +1 -1
- package/dist/ui/assets/{azure-openai-D4Y91RF2.js → azure-openai-DbeGNEJJ.js} +1 -1
- package/dist/ui/assets/{azure-openai-DzS94JlK.js → azure-openai-r8cj7flx.js} +1 -1
- package/dist/ui/assets/{cerebras-CCUO5Bgl.js → cerebras-DHXm2Opl.js} +1 -1
- package/dist/ui/assets/{cerebras-kxgog_fc.js → cerebras-DSz7FIO_.js} +1 -1
- package/dist/ui/assets/{connect-surface-BtGC0JlX.js → connect-surface-Ce0cz8Sc.js} +1 -1
- package/dist/ui/assets/dip-7kvHeBSg.js +1 -0
- package/dist/ui/assets/{dist-B8waMwOf.js → dist-Bp_iacBp.js} +1 -1
- package/dist/ui/assets/{dist-NK6NkUbO.js → dist-ClXA2s8_.js} +1 -1
- package/dist/ui/assets/{ensure-speech-assets-D5QLe0MT.js → ensure-speech-assets-CBkFedDM.js} +1 -1
- package/dist/ui/assets/esp8266-BuqxV-Rf.js +1 -0
- package/dist/ui/assets/{esptool-operations-9SVL1aTu.js → esptool-operations-Dyb_KlG3.js} +2 -2
- package/dist/ui/assets/{fs-Cm5Q5rbx.js → fs-CtR0lVGQ.js} +1 -1
- package/dist/ui/assets/{fs-DClGwY5x.js → fs-Cza4C_VI.js} +2 -2
- package/dist/ui/assets/{github-5cJ0OWUB.js → github-CyuBASDb.js} +2 -2
- package/dist/ui/assets/{github-DvQEBnqP.js → github-D6l0k87E.js} +1 -1
- package/dist/ui/assets/{github-copilot-BdkOFmSZ.js → github-copilot-BxtkvNkA.js} +1 -1
- package/dist/ui/assets/{github-copilot-BbNKKeqF.js → github-copilot-CgxdBB7O.js} +1 -1
- package/dist/ui/assets/{hear-C2QG7EBv.js → hear-DPr4m8os.js} +1 -1
- package/dist/ui/assets/{kernel-worker-dBGEcbBm.js → kernel-worker-DZdJjW09.js} +19 -19
- package/dist/ui/assets/{kokoro-engine-r1z4FFxZ.js → kokoro-engine-DtX15dky.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-Cc3lPQgg.js → lick-ws-bridge-DW_om-XF.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-BvQNg7SI.js → lick-ws-bridge-F1bk9Ndr.js} +1 -1
- package/dist/ui/assets/{local-llm-DrnMUVlA.js → local-llm-BUh467MT.js} +1 -1
- package/dist/ui/assets/{main-CPkFUsXk.js → main-DVF1KaMV.js} +4 -4
- package/dist/ui/assets/{mount-m-BOnULA.js → mount-BJAgT6cd.js} +2 -2
- package/dist/ui/assets/{mount-C4uwVpr7.js → mount-CAEbJLup.js} +1 -1
- package/dist/ui/assets/{new-session-CxrL_CWN.js → new-session-DuIKoj8h.js} +2 -2
- package/dist/ui/assets/{oauth-bootstrap-CDQPQ8Ho.js → oauth-bootstrap-C1t3F5l9.js} +2 -2
- package/dist/ui/assets/{openai-codex-w1Ka-WDf.js → openai-codex-7a3yMxhL.js} +1 -1
- package/dist/ui/assets/{openai-codex-B6ur6j3g.js → openai-codex-BNJ1y0s8.js} +1 -1
- package/dist/ui/assets/{page-follower-tray-C9Fqqzib.js → page-follower-tray-wxp2UQxg.js} +1 -1
- package/dist/ui/assets/{panel-rpc-handlers-DgrIEdqQ.js → panel-rpc-handlers-CfN2Vxm8.js} +2 -2
- package/dist/ui/assets/{provider-8lZWJTdm.js → provider-CDfndD9E.js} +2 -2
- package/dist/ui/assets/{provider-DKySmzpb.js → provider-CYVtAuph.js} +1 -1
- package/dist/ui/assets/provider-store-access-BCxDzrP_.js +1 -0
- package/dist/ui/assets/provider-store-access-C0J_PJos.js +1 -0
- package/dist/ui/assets/{providers-TpMPsx54.js → providers-BrRzKc33.js} +2 -2
- package/dist/ui/assets/{providers-B3pIB8gh.js → providers-CzILNNm-.js} +1 -1
- package/dist/ui/assets/{quick-llm-BRIFeEdv.js → quick-llm-C3DL1kkz.js} +1 -1
- package/dist/ui/assets/session-freezer-BAlnZq3r.js +1 -0
- package/dist/ui/assets/{speak-CWClYEDF.js → speak-BvV9R1Ep.js} +1 -1
- package/dist/ui/assets/{sprinkle-manager--5UxyLSA.js → sprinkle-manager-WFdDIrH2.js} +1 -1
- package/dist/ui/assets/{sprinkle-renderer-Bc0oWiBK.js → sprinkle-renderer-Bd0WVTH3.js} +1 -1
- package/dist/ui/assets/{store-Mv68Y-cH.js → store-DYEVj3Mn.js} +1 -1
- package/dist/ui/assets/{sudo-CcKvrbuS.js → sudo-Dov5vvU-.js} +1 -1
- package/dist/ui/assets/{transformers-env-X1AdbDU-.js → transformers-env-DtlYTSDz.js} +1 -1
- package/dist/ui/assets/{tray-leader-eM_igB1C.js → tray-leader-DYLxucjO.js} +1 -1
- package/dist/ui/assets/{tray-leave-runtime-DBU7Ic9c.js → tray-leave-runtime-bo512Gb_.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-CfImj_q5.js → upgrade-detection-ssTKZKw3.js} +1 -1
- package/dist/ui/assets/{voice-reply-C8VjCUaj.js → voice-reply-C7IdeZWx.js} +1 -1
- package/dist/ui/assets/{wc-attach-Doo7OGT5.js → wc-attach-DqUMF3SN.js} +2 -2
- package/dist/ui/assets/{wc-extension-B6EAyp6S.js → wc-extension-C4v5cPUY.js} +2 -2
- package/dist/ui/assets/{wc-follower-2aecKVEz.js → wc-follower-Crqux2kQ.js} +3 -3
- package/dist/ui/assets/{wc-live-DQLH_pQE.js → wc-live-DQFQdors.js} +5 -5
- package/dist/ui/assets/{wc-nav-DWpnwKpW.js → wc-nav-CaLNkUtj.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-C-y0ZiMT.js → wc-onboarding-Dl79TUXT.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-Cy7INDNF.js → wc-placeholder-CbKpW6j0.js} +3 -3
- package/dist/ui/assets/{wc-settings-DzNAgUGS.js → wc-settings-BCItZ-R5.js} +2 -2
- package/dist/ui/assets/{wc-shell-Djik448Y.js → wc-shell-BPSFQuzD.js} +3 -3
- package/dist/ui/assets/{wc-sprinkles-Jss4eZGw.js → wc-sprinkles-DFSkoMFZ.js} +2 -2
- package/dist/ui/assets/{wc-tray-Cx_9mhYu.js → wc-tray-CB5grpTa.js} +2 -2
- package/dist/ui/assets/{whisper-engine-D8ajA8nU.js → whisper-engine-CDLEuuEq.js} +1 -1
- package/dist/ui/assets/{xai-grok-C9i8WcJE.js → xai-grok-BHUG3fUE.js} +1 -1
- package/dist/ui/assets/{xai-grok-267N2Xuf.js → xai-grok-CwvM0E_f.js} +1 -1
- package/dist/ui/index.html +3 -3
- package/dist/ui/packages/webapp/index.html +3 -3
- package/package.json +1 -1
- package/dist/ui/assets/dip-MMWTvMmO.js +0 -1
- package/dist/ui/assets/esp8266-BtqgI4Fj.js +0 -1
- package/dist/ui/assets/provider-store-access-YMOMgBCh.js +0 -1
- package/dist/ui/assets/provider-store-access-gaNq5xWg.js +0 -1
- package/dist/ui/assets/session-freezer-8K2DjgO1.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./logger-LESFN7Hj.js";import{a as t,i as n,o as r,r as i}from"./transformers-env-
|
|
1
|
+
import{t as e}from"./logger-LESFN7Hj.js";import{a as t,i as n,o as r,r as i}from"./transformers-env-DtlYTSDz.js";const a=e(`speech:espeak`),o=`/workspace/node_modules/espeak-ng/dist/`,s=`espeak-ng.js`,c=`espeak-ng.wasm`;async function l(e,t,n,r){let i=`phonemes.txt`;return(await e({arguments:[`-q`,`-b=1`,`--ipa`,`-v`,n,`--phonout`,i,t],...r?{locateFile:r}:{}})).FS.readFile(i,{encoding:`utf8`}).split(`
|
|
2
2
|
`).map(e=>e.trim()).filter(e=>e.length>0)}function u(e,t){return async n=>{let r=URL.createObjectURL(new Blob([new Uint8Array(t)],{type:`application/wasm`}));try{let t=e=>e.endsWith(`.wasm`)?r:n.locateFile?.(e)??e;return await e({...n,locateFile:t})}finally{URL.revokeObjectURL(r)}}}function d(e){if(typeof BroadcastChannel>`u`)return Promise.reject(Error(`Cannot read VFS path ${e}: BroadcastChannel unavailable`));let t=new BroadcastChannel(`preview-vfs`),n=`espeak-${Date.now()}-${Math.random().toString(36).slice(2)}`;return new Promise((r,i)=>{let a=e=>{t.removeEventListener(`message`,s),t.close(),e()},o=setTimeout(()=>a(()=>i(Error(`ENOENT: ${e} (timed out)`))),3e4),s=t=>{let s=t.data;if(!(s?.type!==`preview-vfs-response`||s.id!==n))if(clearTimeout(o),typeof s.error==`string`)a(()=>i(Error(s.error)));else if(s.content instanceof Uint8Array){let e=s.content;a(()=>r(e))}else if(typeof s.content==`string`){let e=s.content;a(()=>r(new TextEncoder().encode(e)))}else a(()=>i(Error(`Empty preview-vfs response for ${e}`)))};t.addEventListener(`message`,s),t.postMessage({type:`preview-vfs-read`,id:n,path:e,asText:!1})})}async function f(){let[e,t]=await Promise.all([d(`${o}${s}`),d(`${o}${c}`)]),n=URL.createObjectURL(new Blob([new Uint8Array(e)],{type:`text/javascript`}));try{return{factory:u((await import(n)).default,t)}}finally{URL.revokeObjectURL(n)}}let p=f,m=null;function h(){return m||=p().then(({factory:e,locateFile:t})=>(a.info(`espeak-ng multilingual phonemizer loaded`),(n,r)=>l(e,n,r,t)),e=>{throw m=null,a.error(`espeak-ng load failed`,e),e}),m}const g=Object.freeze({e:`es`,f:`fr-fr`,i:`it`,h:`hi`,p:`pt-br`});function _(e){return g[e[0]]??null}const v=RegExp(`(\\s*[${`;:,.!?¡¿—…"«»“”(){}[]`.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}]+\\s*)+`,`g`);function y(e){let t=[],n=0;for(let r of e.matchAll(v)){let i=r[0],a=r.index??0;n<a&&t.push({punct:!1,text:e.slice(n,a)}),i.length>0&&t.push({punct:!0,text:i}),n=a+i.length}return n<e.length&&t.push({punct:!1,text:e.slice(n)}),t}function b(e){return e.replace(/kəkˈoːɹoʊ/g,`kˈoʊkəɹoʊ`).replace(/kəkˈɔːɹəʊ/g,`kˈəʊkəɹəʊ`).replace(/(?<=[a-zɹrː])(?=hˈʌndɹɪd)/g,` `).replace(/ z(?=[;:,.!?¡¿—…"«»“” ]|$)/g,`z`).trim()}async function x(e,t,n){let r=y(e);return b((await Promise.all(r.map(async e=>e.punct?e.text:(await n(e.text,t)).join(` `)))).join(``))}const S=e(`speech:kokoro`),C=`onnx-community/Kokoro-82M-v1.0-ONNX`,w={a:`en-US`,b:`en-GB`,e:`es-ES`,f:`fr-FR`,i:`it-IT`,h:`hi-IN`,p:`pt-BR`,j:`ja-JP`,z:`zh-CN`},T=new Set([`en-US`,`en-GB`,`es-ES`,`fr-FR`,`it-IT`,`hi-IN`,`pt-BR`]);function E(e){let[t,n]=e.split(`-`);return n?`${t.toLowerCase()}-${n.toUpperCase()}`:t.toLowerCase()}function D(e,t){if(!t)return!1;if(T.has(t))return!0;if(t.includes(`-`))return!1;let n=w[e[0]];return n!==void 0&&T.has(n)&&n.split(`-`)[0].toLowerCase()===t}function O(e){return Object.entries(e).map(([e,t])=>{let n=t.language?E(t.language):w[e[0]];return{id:e,name:t.name||e,lang:n??`en-US`,onDevice:D(e,n),...t.gender?{gender:t.gender}:{}}})}const k=Object.freeze({ef_dora:{name:`Dora`,gender:`Female`},em_alex:{name:`Alex`,gender:`Male`},em_santa:{name:`Santa`,gender:`Male`},ff_siwis:{name:`Siwis`,gender:`Female`},hf_alpha:{name:`Alpha`,gender:`Female`},hf_beta:{name:`Beta`,gender:`Female`},hm_omega:{name:`Omega`,gender:`Male`},hm_psi:{name:`Psi`,gender:`Male`},if_sara:{name:`Sara`,gender:`Female`},im_nicola:{name:`Nicola`,gender:`Male`},pf_dora:{name:`Dora`,gender:`Female`},pm_alex:{name:`Alex`,gender:`Male`},pm_santa:{name:`Santa`,gender:`Male`},jf_alpha:{name:`Alpha`,gender:`Female`},jf_gongitsune:{name:`Gongitsune`,gender:`Female`},jf_nezumi:{name:`Nezumi`,gender:`Female`},jf_tebukuro:{name:`Tebukuro`,gender:`Female`},jm_kumo:{name:`Kumo`,gender:`Male`},zf_xiaobei:{name:`Xiaobei`,gender:`Female`},zf_xiaoni:{name:`Xiaoni`,gender:`Female`},zf_xiaoxiao:{name:`Xiaoxiao`,gender:`Female`},zf_xiaoyi:{name:`Xiaoyi`,gender:`Female`},zm_yunjian:{name:`Yunjian`,gender:`Male`},zm_yunxi:{name:`Yunxi`,gender:`Male`},zm_yunxia:{name:`Yunxia`,gender:`Male`},zm_yunyang:{name:`Yunyang`,gender:`Male`}});function A(e){let t={...e};for(let[e,n]of Object.entries(k))e in t||(t[e]=n);return O(t)}const j=`style_text_to_speech_2`,M=`StyleTextToSpeech2Model`;function N(e){return e?.model_type===j&&(!Array.isArray(e.architectures)||e.architectures.length===0)&&(e.architectures=[M]),e}const P=Symbol.for(`slicc.kokoro.style-tts2-arch-shim`);function F(e){let t=e?.AutoConfig,n=t?.from_pretrained;if(!t||typeof n!=`function`){S.debug(`style_text_to_speech_2 shim skipped: AutoConfig.from_pretrained unavailable`);return}if(n[P])return;let r=async(...e)=>{let r=await n.apply(t,e),i=r?.model_type===j&&(!Array.isArray(r.architectures)||r.architectures.length===0);return N(r),i&&S.debug(`style_text_to_speech_2 architectures injected for "${String(e[0])}": [${M}]`),r};r[P]=!0,t.from_pretrained=r,S.debug(`style_text_to_speech_2 architecture shim installed on AutoConfig.from_pretrained`)}async function I(e,t,n,r,i,a){let o=await x(t,n,a),s=e.tokenizer,{input_ids:c}=s(o,{truncation:!0}),l=await e.generate_from_ids(c,{voice:r,...i?{speed:i}:{}});return{audio:l.audio,sampleRate:l.sampling_rate}}const L=/(?<=[.!?。!?…])\s+|\n{2,}/u;function R(e,t){let n=t??L,r=e.split(n).map(e=>e.trim()).filter(e=>e.length>0),i=e.trim();return r.length>0?r:i?[i]:[]}let z=null,B=`idle`,V=null,H=null;function U(){return B}function W(){return V}function G(){return H}function K(e){return z||=(B=`loading`,q(e).then(e=>(B=`ready`,H=e,e),e=>{throw B=`failed`,z=null,S.error(`kokoro load failed`,e),e})),z}async function q(e){let a=await import(`./transformers.web-C6PlPLR-.js`);n(a.env),F(a),await i(C),await t();let{KokoroTTS:o,TextSplitterStream:s}=await import(`./kokoro-C-DxSDte.js`),c=r(),l=typeof navigator<`u`&&`gpu`in navigator,u=await o.from_pretrained(C,{device:l?`webgpu`:`wasm`,dtype:l?`fp32`:`q8`,progress_callback:t=>{if(t?.file){if(t.status===`progress`)c.update(t.file,t.loaded??0,t.total??0);else if(t.status===`done`)c.complete(t.file);else return;V=c.snapshot(),e?.(V)}}});S.info(`kokoro ready`,{model:C,device:l?`webgpu`:`wasm`});let d=A(u.voices);return{async synthesize(e,t){let n=t?.voice??`af_heart`,r=_(n);if(r){let i=await h();return I(u,e,r,n,t?.speed,i)}let i=await u.generate(e,{...t?.voice?{voice:t.voice}:{},...t?.speed?{speed:t.speed}:{}});return{audio:i.audio,sampleRate:i.sampling_rate}},async*synthesizeStream(e,t){let n=t?.voice??`af_heart`,r=_(n);if(r){let i=await h();for(let a of R(e,t?.splitPattern))yield await I(u,a,r,n,t?.speed,i);return}let i={...t?.voice?{voice:t.voice}:{},...t?.speed?{speed:t.speed}:{}},a=new s;if(t?.splitPattern){let n=e.split(t.splitPattern).map(e=>e.trim()).filter(e=>e.length>0);a.push(...n)}else a.push(e);a.close();for await(let e of u.stream(a,i))yield{audio:e.audio.audio,sampleRate:e.audio.sampling_rate}},voices:()=>d}}export{U as a,c,G as i,K as n,o,W as r,s,C as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./logger-DDBAeTLF.js";import"./main-
|
|
1
|
+
import{t as e}from"./logger-DDBAeTLF.js";import"./main-DVF1KaMV.js";import"./tray-leader-DYLxucjO.js";e(`lick-ws-bridge`);function t(e){let t=typeof e.verb==`string`?e.verb:null,n=typeof e.target==`string`?e.target:null,r=typeof e.url==`string`&&e.url.length>0?e.url:null;if(t!==`handoff`&&t!==`upskill`||!n||!r)return null;let i={url:r,verb:t,target:n};return typeof e.instruction==`string`&&(i.instruction=e.instruction),typeof e.branch==`string`&&(i.branch=e.branch),typeof e.path==`string`&&(i.path=e.path),typeof e.title==`string`&&(i.title=e.title),{type:`navigate`,navigateUrl:r,targetScoop:void 0,timestamp:typeof e.timestamp==`string`?e.timestamp:new Date().toISOString(),body:i}}export{t as mapNavigatePayloadToLickEvent};
|
|
@@ -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-
|
|
1
|
+
import{t as e}from"./logger-LESFN7Hj.js";import{b as t,n,r,t as i,y as a}from"./kernel-worker-DZdJjW09.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 m(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`&&p(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){let t=typeof e.verb==`string`?e.verb:null,n=typeof e.target==`string`?e.target:null,r=typeof e.url==`string`&&e.url.length>0?e.url:null;if(t!==`handoff`&&t!==`upskill`||!n||!r)return null;let i={url:r,verb:t,target:n};return typeof e.instruction==`string`&&(i.instruction=e.instruction),typeof e.branch==`string`&&(i.branch=e.branch),typeof e.path==`string`&&(i.path=e.path),typeof e.title==`string`&&(i.title=e.title),{type:`navigate`,navigateUrl:r,targetScoop:void 0,timestamp:typeof e.timestamp==`string`?e.timestamp:new Date().toISOString(),body:i}}function p(e,t){let n=f(t);if(!n){o.debug(`navigate_event dropped — invalid payload`,{hasVerb:typeof t.verb==`string`,hasTarget:typeof t.target==`string`,hasUrl:typeof t.url==`string`&&t.url.length>0});return}e.emitEvent(n)}async function m(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:h(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:h(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 h(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 g(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 _(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(){g(a)}}}export{_ as startLickWsBridge};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{s as e}from"./models-ByRUWfA-.js";import{a as t,c as n,f as r}from"./compat-DADQxxLV.js";import{b as i}from"./account-store-
|
|
1
|
+
import{s as e}from"./models-ByRUWfA-.js";import{a as t,c as n,f as r}from"./compat-DADQxxLV.js";import{b as i}from"./account-store-Bk7BU4R2.js";import{t as a}from"./logger-DDBAeTLF.js";var o=a(`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(i(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,r={})=>e.id===l?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?n(m(e),t,h(r)):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?r(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`);function v(t,n){let r=e(),i={role:`assistant`,content:[],api:t.api,provider:t.provider,model:t.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:n,timestamp:Date.now()};return queueMicrotask(()=>{r.push({type:`error`,reason:`error`,error:i}),r.end()}),r}function y(){t({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-
|
|
2
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import"./modulepreload-polyfill-Dezn_h7o.js";import{t}from"./preload-helper-CZgWQFsJ.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,s as de,t as fe,u as pe,v as me,w as he,x as ge,y as _e,z as ve}from"./account-store-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sudo-Dov5vvU-.js","assets/preload-helper-CZgWQFsJ.js","assets/logger-DDBAeTLF.js","assets/proxied-fetch-iGqLvoxh.js","assets/rolldown-runtime-aKtaBQYM.js","assets/src-BdPw21ST.js","assets/fetch-body-D2PwksUW.js","assets/quick-llm-C3DL1kkz.js","assets/compat-DADQxxLV.js","assets/models-ByRUWfA-.js","assets/provider-env-D37PhSJu.js","assets/__vite-browser-external-SwrSgYTf.js","assets/account-store-Bk7BU4R2.js","assets/context-compaction-DaxQExZG.js","assets/secret-topology-DnYeyyJY.js","assets/secrets-bridge-client-x_puVSDN.js","assets/port-bridge-client-BJ5rcoKH.js","assets/tool-ui-DfXu6quJ.js","assets/providers-BrRzKc33.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-DbZ6Mjym.js","assets/transform-messages-D7OsqBmU.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-C5g936Qd.js","assets/panel-responder-BKgfV-nl.js","assets/extension-bridge-transport-WLbnai-d.js","assets/cdp-bridge-CUqQUcaF.js","assets/lick-ws-bridge-DW_om-XF.js","assets/tray-leader-DYLxucjO.js","assets/cdp-D7cRI5-J.js","assets/navigation-watcher-C2s0i0h4.js","assets/handoff-link-w8LYa3Ua.js","assets/remote-cdp-transport-DTCu2BgA.js","assets/main-cherry-CqL2Gwv5.js","assets/synthetic-cdp-transport-DLIt5SkY.js","assets/oauth-service-BSqTYvb6.js","assets/wc-permissions-registry-Blyunq37.js","assets/wc-shell-BPSFQuzD.js","assets/speech-C5U8h4In.js","assets/soundscape-cues-5_sT5Un6.js","assets/wc-shell-WkeczD9x.css","assets/wc-follower-Crqux2kQ.js","assets/wc-attach-DqUMF3SN.js","assets/wc-live-DQFQdors.js","assets/hid-device-registry-6w-g8ZpF.js","assets/serial-port-registry-DsPZvGpT.js","assets/usb-operations-D-YdmmuG.js","assets/usb-device-registry-k6vTKonT.js","assets/shared-BtKwD6I9.js","assets/mime-types-ugOWOUZ9.js","assets/sprinkle-renderer-Bd0WVTH3.js","assets/theme-Bgsl5v2i.js","assets/theme-engine-DqVfCCym.js","assets/sprinkle-bridge-CZr9Wcf7.js","assets/page-follower-tray-wxp2UQxg.js","assets/wc-sprinkles-DFSkoMFZ.js","assets/oauth-bootstrap-C1t3F5l9.js","assets/legacy-styles-CuB1P3LZ.js","assets/connect-surface-Ce0cz8Sc.js","assets/wc-extension-C4v5cPUY.js","assets/wc-detached-B3WCbbZT.js","assets/messages-BD4p8GuF.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import"./modulepreload-polyfill-Dezn_h7o.js";import{t}from"./preload-helper-CZgWQFsJ.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,s as de,t as fe,u as pe,v as me,w as he,x as ge,y as _e,z as ve}from"./account-store-Bk7BU4R2.js";import{t as E}from"./logger-DDBAeTLF.js";import{r as ye}from"./src-BdPw21ST.js";import{a as be,c as xe,o as Se,s as Ce,t as we}from"./proxied-fetch-iGqLvoxh.js";import{a as Te}from"./providers-BrRzKc33.js";import"./messages-BD4p8GuF.js";import{n as Ee}from"./clipboard-DuHpK59o.js";var De=`bridge`,Oe=`bridgeToken`,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 Me(e){let t;try{t=new URLSearchParams(e)}catch{return null}let n=t.get(De),r=t.get(Oe);if(!n||!r||!/^wss?:\/\//.test(n))return null;let i=t.get(ye),a=i===`leader`||i===`follower`?i:null;return{url:n,subprotocol:`${ke}${r}`,token:r,apiBaseUrl:Ae(n),lickWsUrl:je(n),role:a}}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"./rolldown-runtime-aKtaBQYM.js";import"./modulepreload-polyfi
|
|
|
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 D=null;function Ue(){return D||(D=He(),D)}var O=`tray`,We=`trayWorkerUrl`,Ge=`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 A(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 Ke(e,t){let n=new URL(e);return n.searchParams.delete(We),n.searchParams.delete(Ge),n.searchParams.set(O,t),n.toString()}var j=`slicc.trayWorkerBaseUrl`,M=`slicc.trayJoinUrl`,qe=`https://www.sliccy.ai`;function Je(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 N(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 A(t.toString());let i=k(t.toString());return i?{workerBaseUrl:i,trayId:r,joinUrl:null}:null}catch{return null}}function P(e){let t=N(e);return t?.joinUrl?t:null}function F(e,t){let n=P(t);return n?(e.setItem(M,n.joinUrl),e.setItem(j,n.workerBaseUrl),n):null}function Ye(e){return!!P(e?.getItem(`slicc.trayJoinUrl`)??null)}function Xe(e,t){let n=!1;try{let t=new URL(e),r=t.searchParams.get(O);if(r!==null){n=!0;let e=N(r);if(e?.joinUrl)return e.joinUrl}t.searchParams.get(`slicc`)===`leader`&&(n=!0)}catch{}let r=N(e);return r?.joinUrl?r.joinUrl:(r?.trayId&&(n=!0),n?null:P(t?.getItem(`slicc.trayJoinUrl`)??null)?.joinUrl??null)}function Ze(e){try{let t=new URL(e);t.searchParams.delete(O);let n=t.pathname.split(`/`).filter(Boolean);return n.length>=2&&n.at(-2)===`join`&&(n.splice(-2,2),t.pathname=n.length>0?`/${n.join(`/`)}`:`/`),t.toString()}catch{return e}}function Qe(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 $e(e,t,n){return Ke(e,Qe(t,n))}async function et(e){let t=rt(e.locationHref);if(t)return e.storage&&(t.joinUrl&&e.storage.setItem(M,t.joinUrl),e.storage.setItem(j,t.workerBaseUrl)),t;let n=P(e.storage?.getItem(`slicc.trayJoinUrl`)??null);if(n)return e.storage&&e.storage.setItem(j,n.workerBaseUrl),n;let r=e.runtimeConfigFetcher?await it(e.runtimeConfigFetcher):null;if(r?.joinConfig)return e.storage&&(e.storage.setItem(M,r.joinConfig.joinUrl),e.storage.setItem(j,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(j,c),{workerBaseUrl:c,trayId:null,joinUrl:null}):null}async function tt(e){return(await et(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=N(t.searchParams.get(O));if(n)return n;let r=N(t.searchParams.get(Ge));if(r)return r;let i=k(t.searchParams.get(We));return i?{workerBaseUrl:i,trayId:null,joinUrl:null}:A(e)||null}catch{return null}}async function it(e){let t=await e();if(!t)return null;let n=P(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,n){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`:Xe(e,n===void 0?typeof window<`u`?window.localStorage:null:n)?`follower`: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-CcKvrbuS.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,23,24]));n()}async function ft(e){let{installPanelSudoResponder:n}=await t(async()=>{let{installPanelSudoResponder:e}=await import(`./sudo-CcKvrbuS.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,23,24]));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 I(){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,n,r){let{ExtensionBridgeTransport:i}=await t(async()=>{let{ExtensionBridgeTransport:e}=await import(`./extension-bridge-transport-WLbnai-d.js`);return{ExtensionBridgeTransport:e}},__vite__mapDeps([25,2,26])),{mapNavigatePayloadToLickEvent:a}=await t(async()=>{let{mapNavigatePayloadToLickEvent:e}=await import(`./lick-ws-bridge-Cc3lPQgg.js`);return{mapNavigatePayloadToLickEvent:e}},__vite__mapDeps([27,2,28,4,3,1,5,6])),o=null,s=[],c=!1,l=e=>{o=e;for(let t of s)e.sendForwardedLick(t);s.length=0},u=new e(new i({extensionId:n,onLick:e=>{let t=a(e);if(t){if(o){o.sendForwardedLick(t);return}s.length>=50&&(s.shift(),c||(c=!0,r.warn(`extension-bridge lick buffer overflow (cap 50); dropping oldest pending licks until the kernel client attaches`))),s.push(t)}}}));return await gt(u,void 0,r),{browser:u,attachLickForwardingClient:l}}async function vt(e){let{runtimeMode:n,envBaseUrl:r,window:i,log:a}=e,o=n===`electron-overlay`;a.info(`setting up standalone page runtime (BrowserAPI + CDP)`,{runtimeMode:n});let{BrowserAPI:s}=await t(async()=>{let{BrowserAPI:e}=await import(`./cdp-D7cRI5-J.js`);return{BrowserAPI:e}},__vite__mapDeps([29,2,30,31,32,4]));await dt({log:a});let c,l,u,d=null,f=null,p=null,m=null,h,g=n===`cherry`?null:mt(i.location.search),_=!!g&&I(),v=n===`cherry`||_?null:Me(i.location.search);v?.apiBaseUrl&&(d=v.apiBaseUrl,xe(v.apiBaseUrl),f=v.token,Se(v.token)),v?.lickWsUrl&&(p=v.lickWsUrl);let y=await nt(),b=ct(n,y!==null)?qe:null;if(await et({locationHref:i.location.href,storage:i.localStorage,envBaseUrl:r,defaultWorkerBaseUrl:b,runtimeConfigFetcher:async()=>y}),n===`cherry`){let{setupCherryFollower:e}=await t(async()=>{let{setupCherryFollower:e}=await import(`./main-cherry-CqL2Gwv5.js`);return{setupCherryFollower:e}},__vite__mapDeps([33,2,29,30,31,32,4,34])),n=await e();c=n.browser,l=n.joinUrl,u=n.transport}else if(g&&I()){a.info(`Routing CDP through the extension bridge (leader tab)`);let e=await _t(s,g.extensionId,a);c=e.browser,h=e.attachLickForwardingClient,m=g.extensionId,Ce(g.extensionId)}else{c=new s,v&&a.info(`Routing CDP through local standalone bridge`,{url:v.url,role:v.role??`(unset)`});let e=v?{url:v.url,protocols:v.subprotocol}:void 0;v?.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 x=c.getTransport();return globalThis.__slicc_browser=c,{browser:c,realCdpTransport:x,cherryJoinUrl:l,cherryTransport:u,instanceId:pt(),isElectronOverlay:o,localApiBaseUrl:d,bridgeToken:f,localLickWsUrl:p,extensionDelegateId:m,attachLickForwardingClient:h}}var L=E(`boot/sw-registration`);async function yt(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 xt())return`reload-pending`;if(!(`serviceWorker`in navigator)||n)return`ready`;try{if(await navigator.serviceWorker.register(`/preview-sw.js`,{scope:`/preview/`}),L.info(`Preview SW registered`),!(typeof chrome<`u`&&chrome?.runtime?.id))try{await navigator.serviceWorker.register(`/llm-proxy-sw.js`,{scope:`/`}),L.info(`LLM-proxy SW registered`)}catch(e){L.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`),L.info(`Reloading once to gain SW control`),location.reload(),`reload-pending`;sessionStorage.removeItem(`slicc-sw-reloaded`),e&&(bt(e),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{bt(e)})),t&&(R(t),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{R(t)}))}catch(e){L.error(`Preview SW registration failed — preview feature will not work`,e)}return`ready`}function bt(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){L.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){L.warn(`LLM-proxy SW extension-delegate postMessage failed`,e)}}async function xt(){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`),L.info(`connect mode: detaching from service worker (no proxy on worker origin)`),location.reload(),!0;sessionStorage.removeItem(`slicc-connect-sw-cleared`)}catch(e){L.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 St(){return{...z}}var Ct=`slicc.followerTrayStatus`,B=new Set;function wt(e){return B.add(e),()=>{B.delete(e)}}function Tt(){if(B.size!==0)for(let e of[...B])try{e({...z})}catch{}}function Et(e){z={...e},Tt()}function Dt(e){z={...z,lastPingTime:e},Tt()}function Ot(e){return typeof e==`string`&&e.startsWith(`No API key configured`)}function kt(e){if(!e)return!1;let t=e.toLowerCase();return t.includes(`the provided model identifier is invalid`)||t.includes(`model not allowed`)}function At(e){return e?e.toLowerCase().includes(`please log in again`):!1}function jt(e){return Ot(e)||kt(e)||At(e)}var V=null,Mt=!1;function Nt(){return typeof window>`u`||typeof document>`u`||document?.documentElement===void 0||typeof localStorage?.getItem!=`function`}function Pt(){return Nt()?`standalone-worker`:typeof chrome<`u`&&chrome?.runtime?.id?`extension`:typeof document<`u`&&document.documentElement?.dataset?.electronOverlay?`electron`:`cli`}async function Ft(){if(!Mt&&!(typeof localStorage<`u`&&typeof localStorage?.getItem==`function`&&localStorage.getItem(`telemetry-disabled`)===`true`))try{let e=Pt();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`),Gt(),V=(await t(()=>import(`./src-C9oNvq2b.js`),[])).sampleRUM),Mt=!0,V&&V(`navigate`,{source:typeof document<`u`?document.referrer:``,target:e})}catch{}}function It(e,t){V?.(`formsubmit`,{source:e,target:t})}function Lt(e){V?.(`viewblock`,{source:e})}function Rt(e){V?.(`viewmedia`,{source:e})}function H(e,t){let n=t;if(typeof n==`string`){if(jt(n))return;let e=Vt(n);if(e===null)return;n=e}V?.(`error`,{source:e,target:n})}function zt(e){V?.(`signup`,{source:e})}function Bt(e){return e.includes(`@vite/client`)||e.includes(`@vite/env`)||e.includes(`[vite]`)||/https?:\/\/localhost:\d+\/@vite\//.test(e)||/\/__vite_ping/.test(e)}function Vt(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 D=null;function Ue(){return D||(D=He(),D)}var O=`tray`,We=`trayWorkerUrl`,Ge=`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 A(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 Ke(e,t){let n=new URL(e);return n.searchParams.delete(We),n.searchParams.delete(Ge),n.searchParams.set(O,t),n.toString()}var j=`slicc.trayWorkerBaseUrl`,M=`slicc.trayJoinUrl`,qe=`https://www.sliccy.ai`;function Je(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 N(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 A(t.toString());let i=k(t.toString());return i?{workerBaseUrl:i,trayId:r,joinUrl:null}:null}catch{return null}}function P(e){let t=N(e);return t?.joinUrl?t:null}function F(e,t){let n=P(t);return n?(e.setItem(M,n.joinUrl),e.setItem(j,n.workerBaseUrl),n):null}function Ye(e){return!!P(e?.getItem(`slicc.trayJoinUrl`)??null)}function Xe(e,t){let n=!1;try{let t=new URL(e),r=t.searchParams.get(O);if(r!==null){n=!0;let e=N(r);if(e?.joinUrl)return e.joinUrl}t.searchParams.get(`slicc`)===`leader`&&(n=!0)}catch{}let r=N(e);return r?.joinUrl?r.joinUrl:(r?.trayId&&(n=!0),n?null:P(t?.getItem(`slicc.trayJoinUrl`)??null)?.joinUrl??null)}function Ze(e){try{let t=new URL(e);t.searchParams.delete(O);let n=t.pathname.split(`/`).filter(Boolean);return n.length>=2&&n.at(-2)===`join`&&(n.splice(-2,2),t.pathname=n.length>0?`/${n.join(`/`)}`:`/`),t.toString()}catch{return e}}function Qe(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 $e(e,t,n){return Ke(e,Qe(t,n))}async function et(e){let t=rt(e.locationHref);if(t)return e.storage&&(t.joinUrl&&e.storage.setItem(M,t.joinUrl),e.storage.setItem(j,t.workerBaseUrl)),t;let n=P(e.storage?.getItem(`slicc.trayJoinUrl`)??null);if(n)return e.storage&&e.storage.setItem(j,n.workerBaseUrl),n;let r=e.runtimeConfigFetcher?await it(e.runtimeConfigFetcher):null;if(r?.joinConfig)return e.storage&&(e.storage.setItem(M,r.joinConfig.joinUrl),e.storage.setItem(j,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(j,c),{workerBaseUrl:c,trayId:null,joinUrl:null}):null}async function tt(e){return(await et(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=N(t.searchParams.get(O));if(n)return n;let r=N(t.searchParams.get(Ge));if(r)return r;let i=k(t.searchParams.get(We));return i?{workerBaseUrl:i,trayId:null,joinUrl:null}:A(e)||null}catch{return null}}async function it(e){let t=await e();if(!t)return null;let n=P(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)}function st(e,t,n){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`:Xe(e,n===void 0?typeof window<`u`?window.localStorage:null:n)?`follower`: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-Dov5vvU-.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,23,24]));n()}async function ft(e){let{installPanelSudoResponder:n}=await t(async()=>{let{installPanelSudoResponder:e}=await import(`./sudo-Dov5vvU-.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,23,24]));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 I(){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,n,r){let{ExtensionBridgeTransport:i}=await t(async()=>{let{ExtensionBridgeTransport:e}=await import(`./extension-bridge-transport-WLbnai-d.js`);return{ExtensionBridgeTransport:e}},__vite__mapDeps([25,2,26])),{mapNavigatePayloadToLickEvent:a}=await t(async()=>{let{mapNavigatePayloadToLickEvent:e}=await import(`./lick-ws-bridge-DW_om-XF.js`);return{mapNavigatePayloadToLickEvent:e}},__vite__mapDeps([27,2,28,4,3,1,5,6])),o=null,s=[],c=!1,l=e=>{o=e;for(let t of s)e.sendForwardedLick(t);s.length=0},u=new e(new i({extensionId:n,onLick:e=>{let t=a(e);if(t){if(o){o.sendForwardedLick(t);return}s.length>=50&&(s.shift(),c||(c=!0,r.warn(`extension-bridge lick buffer overflow (cap 50); dropping oldest pending licks until the kernel client attaches`))),s.push(t)}}}));return await gt(u,void 0,r),{browser:u,attachLickForwardingClient:l}}async function vt(e){let{runtimeMode:n,envBaseUrl:r,window:i,log:a}=e,o=n===`electron-overlay`;a.info(`setting up standalone page runtime (BrowserAPI + CDP)`,{runtimeMode:n});let{BrowserAPI:s}=await t(async()=>{let{BrowserAPI:e}=await import(`./cdp-D7cRI5-J.js`);return{BrowserAPI:e}},__vite__mapDeps([29,2,30,31,32,4]));await dt({log:a});let c,l,u,d=null,f=null,p=null,m=null,h,g=n===`cherry`?null:mt(i.location.search),_=!!g&&I(),v=n===`cherry`||_?null:Me(i.location.search);v?.apiBaseUrl&&(d=v.apiBaseUrl,xe(v.apiBaseUrl),f=v.token,Se(v.token)),v?.lickWsUrl&&(p=v.lickWsUrl);let y=await nt(),b=ct(n,y!==null)?qe:null;if(await et({locationHref:i.location.href,storage:i.localStorage,envBaseUrl:r,defaultWorkerBaseUrl:b,runtimeConfigFetcher:async()=>y}),n===`cherry`){let{setupCherryFollower:e}=await t(async()=>{let{setupCherryFollower:e}=await import(`./main-cherry-CqL2Gwv5.js`);return{setupCherryFollower:e}},__vite__mapDeps([33,2,29,30,31,32,4,34])),n=await e();c=n.browser,l=n.joinUrl,u=n.transport}else if(g&&I()){a.info(`Routing CDP through the extension bridge (leader tab)`);let e=await _t(s,g.extensionId,a);c=e.browser,h=e.attachLickForwardingClient,m=g.extensionId,Ce(g.extensionId)}else{c=new s,v&&a.info(`Routing CDP through local standalone bridge`,{url:v.url,role:v.role??`(unset)`});let e=v?{url:v.url,protocols:v.subprotocol}:void 0;v?.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 x=c.getTransport();return globalThis.__slicc_browser=c,{browser:c,realCdpTransport:x,cherryJoinUrl:l,cherryTransport:u,instanceId:pt(),isElectronOverlay:o,localApiBaseUrl:d,bridgeToken:f,localLickWsUrl:p,extensionDelegateId:m,attachLickForwardingClient:h}}var L=E(`boot/sw-registration`);async function yt(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 xt())return`reload-pending`;if(!(`serviceWorker`in navigator)||n)return`ready`;try{if(await navigator.serviceWorker.register(`/preview-sw.js`,{scope:`/preview/`}),L.info(`Preview SW registered`),!(typeof chrome<`u`&&chrome?.runtime?.id))try{await navigator.serviceWorker.register(`/llm-proxy-sw.js`,{scope:`/`}),L.info(`LLM-proxy SW registered`)}catch(e){L.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`),L.info(`Reloading once to gain SW control`),location.reload(),`reload-pending`;sessionStorage.removeItem(`slicc-sw-reloaded`),e&&(bt(e),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{bt(e)})),t&&(R(t),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{R(t)}))}catch(e){L.error(`Preview SW registration failed — preview feature will not work`,e)}return`ready`}function bt(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){L.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){L.warn(`LLM-proxy SW extension-delegate postMessage failed`,e)}}async function xt(){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`),L.info(`connect mode: detaching from service worker (no proxy on worker origin)`),location.reload(),!0;sessionStorage.removeItem(`slicc-connect-sw-cleared`)}catch(e){L.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 St(){return{...z}}var Ct=`slicc.followerTrayStatus`,B=new Set;function wt(e){return B.add(e),()=>{B.delete(e)}}function Tt(){if(B.size!==0)for(let e of[...B])try{e({...z})}catch{}}function Et(e){z={...e},Tt()}function Dt(e){z={...z,lastPingTime:e},Tt()}function Ot(e){return typeof e==`string`&&e.startsWith(`No API key configured`)}function kt(e){if(!e)return!1;let t=e.toLowerCase();return t.includes(`the provided model identifier is invalid`)||t.includes(`model not allowed`)}function At(e){return e?e.toLowerCase().includes(`please log in again`):!1}function jt(e){return Ot(e)||kt(e)||At(e)}var V=null,Mt=!1;function Nt(){return typeof window>`u`||typeof document>`u`||document?.documentElement===void 0||typeof localStorage?.getItem!=`function`}function Pt(){return Nt()?`standalone-worker`:typeof chrome<`u`&&chrome?.runtime?.id?`extension`:typeof document<`u`&&document.documentElement?.dataset?.electronOverlay?`electron`:`cli`}async function Ft(){if(!Mt&&!(typeof localStorage<`u`&&typeof localStorage?.getItem==`function`&&localStorage.getItem(`telemetry-disabled`)===`true`))try{let e=Pt();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`),Gt(),V=(await t(()=>import(`./src-C9oNvq2b.js`),[])).sampleRUM),Mt=!0,V&&V(`navigate`,{source:typeof document<`u`?document.referrer:``,target:e})}catch{}}function It(e,t){V?.(`formsubmit`,{source:e,target:t})}function Lt(e){V?.(`viewblock`,{source:e})}function Rt(e){V?.(`viewmedia`,{source:e})}function H(e,t){let n=t;if(typeof n==`string`){if(jt(n))return;let e=Vt(n);if(e===null)return;n=e}V?.(`error`,{source:e,target:n})}function zt(e){V?.(`signup`,{source:e})}function Bt(e){return e.includes(`@vite/client`)||e.includes(`@vite/env`)||e.includes(`[vite]`)||/https?:\/\/localhost:\d+\/@vite\//.test(e)||/\/__vite_ping/.test(e)}function Vt(e){let t=e??``;if(t.includes(`@vite/`)||t.includes(`[vite]`)||t.includes(`__vite_ping`)){let e=t.split(`
|
|
23
23
|
`).filter(e=>!Bt(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 Ht=Symbol.for(`slicc.telemetry.sendBeacon.wrapped`);function Ut(e){if(typeof e!=`string`)return{kind:`absent`};let t=Vt(e);return t===null?{kind:`noise`}:{kind:`kept`,value:t,mutated:t!==e}}function Wt(e){let t=Ut(e.source),n=Ut(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 Gt(){if(typeof navigator>`u`||typeof navigator.sendBeacon!=`function`)return;let e=navigator.sendBeacon;if(e[Ht])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=Wt(n);if(r===!0)return!0;if(r!==null)return t(e,r)}}}catch{}return t(e,n)});n[Ht]=!0,navigator.sendBeacon=n}function Kt(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??qt(t.state)??`Mirroring another browser.`}}function qt(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 Jt(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 Yt=e({ACCOUNTS_KEY:()=>fe,__test__:()=>ce,_testOnly_dispatchTrayJoinWithFailureFeedback:()=>Qt,addAccount:()=>T,applyProviderDefaults:()=>S,clearAllSettings:()=>le,clearApiKey:()=>de,clearBaseUrl:()=>ee,clearSelectedProvider:()=>oe,describeInvalidJoinUrl:()=>Jt,downloadProviders:()=>en,exportProviders:()=>pe,getAccounts:()=>w,getAllAvailableModels:()=>te,getAllExtraOAuthDomains:()=>ue,getApiKey:()=>se,getApiKeyForProvider:()=>re,getApiVersionForProvider:()=>ne,getAvailableProviders:()=>x,getBaseUrl:()=>me,getBaseUrlForProvider:()=>_e,getDeploymentForProvider:()=>C,getExtraOAuthDomains:()=>ge,getOAuthAccountInfo:()=>g,getProviderConfig:()=>i,getProviderModels:()=>he,getRawApiKeyForProvider:()=>_,getSelectedModelId:()=>o,getSelectedProvider:()=>a,isModelHiddenFromPicker:()=>p,logoutOAuthAccount:()=>ae,maskOAuthTokenWithRetry:()=>n,migrateLegacyAuthOnlySelection:()=>ie,persistOAuthMaskViaServiceWorker:()=>d,providerOffersLlmModels:()=>f,reloginOAuthAccount:()=>Y,removeAccount:()=>m,resolveCurrentModel:()=>s,resolveModelById:()=>l,resolveModelByShorthand:()=>u,saveOAuthAccount:()=>h,setApiKey:()=>ve,setBaseUrl:()=>r,setExtraOAuthDomains:()=>y,setExtraOAuthDomainsAsync:()=>c,setSelectedModelId:()=>v,setSelectedProvider:()=>b,showProviderSettings:()=>Cn}),Xt=E(`provider-settings`);function Zt(){return typeof chrome<`u`&&!!chrome?.runtime?.id}function Qt(e,t){return $t(e,t)}function $t(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){Xt.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 en(){let e=JSON.stringify(pe(),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 tn(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):X(e)}function nn(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=tn(e.apiKey),e.baseUrl&&(t.textContent+=` • `+e.baseUrl),t}async function Y(e,n){let{createOAuthLauncher:r,createInterceptingOAuthLauncherForCurrentRuntime:i}=await t(async()=>{let{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}=await import(`./oauth-service-BSqTYvb6.js`);return{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}},__vite__mapDeps([35,1,3,4,5,6,19,36])),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 rn(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 an(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`,()=>{Y(n,()=>X(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),X(e)})()})),r}function on(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),X(e)})()}),n}function sn(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(nn(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(rn(e,t)),n.isOAuth&&s.appendChild(an(e,t,n)),s.appendChild(on(e,t)),r.appendChild(s),r}function cn(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=St(),a=i.state!==`inactive`,o=Ye(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 X(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(sn(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`,()=>en()),i.appendChild(o),t.appendChild(i),t.appendChild(cn(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 ln(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 un(e,t){let n=ln(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 dn(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 fn(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}=dn(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 Ee(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 pn(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=_e(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-BSqTYvb6.js`);return{createInterceptingOAuthLauncherForCurrentRuntime:e}},__vite__mapDeps([35,1,3,4,5,6,19,36])),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:fn(n.oauth)})}else if(a.onOAuthLogin){let{createOAuthLauncher:n}=await t(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-BSqTYvb6.js`);return{createOAuthLauncher:e}},__vite__mapDeps([35,1,3,4,5,6,19,36])),r=n();await a.onOAuthLogin(r,()=>J(e))}}catch(e){if(!s)try{await m(r)}catch{}Xt.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 mn(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 hn(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 gn(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 _n(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,mn(e,n),hn(e,n),gn(e,n)}function vn(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 yn(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`,()=>X(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=un(e.options,t);n.appendChild(o.providerSelect),n.appendChild(o.providerDesc),o.oauth.loginBtn.addEventListener(`click`,()=>{pn(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`,_n(o)}),_n(o),o.saveBtn.addEventListener(`click`,()=>vn(e,o));let s=t=>{t.key===`Enter`&&vn(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),yn(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 bn(e,t,n,r){if(Zt()){let e={type:`refresh-tray-runtime`,joinUrl:t,workerBaseUrl:n};chrome.runtime.sendMessage({source:`panel`,payload:e}).catch(()=>{})}else $t(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 xn(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=F(window.localStorage,t);if(!n){o.textContent=`Invalid sync URL.`,o.style.display=``,o.style.color=`var(--slicc-cone)`;return}bn(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 Sn(){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(Sn());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=F(window.localStorage,t);if(!n){o.textContent=Jt(t),o.style.display=``,a.focus();return}bn(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 Cn(e){return zt(`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?X(i):e?.autoJoinUrl?xn(i,e.autoJoinUrl):e?.preferTrayJoin?Q(i):Z(i),n.appendChild(r),document.body.appendChild(n)})}var $=E(`main`);function wn(e){try{return new URL(e).searchParams.has(`ui-fixture`)}catch{return!1}}async function Tn(){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(wn(window.location.href)){let{mountWcUiPreview:n}=await t(async()=>{let{mountWcUiPreview:e}=await import(`./wc-shell-Djik448Y.js`).then(e=>e.a);return{mountWcUiPreview:e}},__vite__mapDeps([37,4,1,23,38,39,40]));n(e);return}Be(),Ue(),r!==`connect`&&Ft().catch(()=>{});let i=Me(window.location.search),a=r===`cherry`?null:mt(window.location.search),o=!!a&&I();if(await yt(i?{apiBaseUrl:i.apiBaseUrl,token:i.token}:null,o&&a?{extensionId:a.extensionId}:null)===`reload-pending`)return;if(!n&&(r===`follower`||r===`cherry`)){let{mountWcUiFollower:n}=await t(async()=>{let{mountWcUiFollower:e}=await import(`./wc-follower-2aecKVEz.js`);return{mountWcUiFollower:e}},__vite__mapDeps([41,1,2,32,4,37,23,38,39,40,42,5,36,43,8,9,10,11,12,13,3,6,14,15,16,17,18,19,20,21,44,45,46,47,28,48,49,50,51,52,53,54,55]));return n(e,$,r)}await Te(),S();let{bootstrapOAuthReplicas:s}=await t(async()=>{let{bootstrapOAuthReplicas:e}=await import(`./oauth-bootstrap-CDQPQ8Ho.js`);return{bootstrapOAuthReplicas:e}},__vite__mapDeps([56,1,12,4,8,9,10,11,13,2,5,3,6,14,15,16,17,18,19,20,21]));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-CuB1P3LZ.js`);return{loadLegacyStyles:e}},__vite__mapDeps([57,1]));await n();let{mountConnectSurface:r}=await t(async()=>{let{mountConnectSurface:e}=await import(`./connect-surface-BtGC0JlX.js`);return{mountConnectSurface:e}},__vite__mapDeps([58,12,4,1,8,9,10,11,13,2,5,3,6,14,15,16,17,18,19,20,21]));await r(e);return}if(n){let{mountWcUiExtension:n}=await t(async()=>{let{mountWcUiExtension:e}=await import(`./wc-extension-B6EAyp6S.js`);return{mountWcUiExtension:e}},__vite__mapDeps([59,1,60,61,43,8,9,10,11,4,12,13,2,5,3,6,14,15,16,17,18,19,20,21,36,44,45,46,47,23,28,48,49,37,38,39,40,50,51,52,53]));return n(e,$,r===`extension-detached`)}o&&a&&ze(a.extensionId);let{mountWcUiLive:c}=await t(async()=>{let{mountWcUiLive:e}=await import(`./wc-live-DQLH_pQE.js`);return{mountWcUiLive:e}},__vite__mapDeps([43,1,8,9,10,11,4,12,13,2,5,3,6,14,15,16,17,18,19,20,21,36,44,45,46,47,23,28,48,49,37,38,39,40,50,51,52,53]));return c(e,$,r)}Tn().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{Ye as C,Ze as D,F as E,De as O,Je as S,tt as T,ut as _,H as a,j as b,At as c,Ct as d,St as f,vt as g,wt as h,It as i,kt as l,Et as m,Cn as n,Rt as o,Dt as p,Kt as r,Lt as s,Yt as t,Ot as u,qe as v,Xe as w,$e as x,M 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 Ht=Symbol.for(`slicc.telemetry.sendBeacon.wrapped`);function Ut(e){if(typeof e!=`string`)return{kind:`absent`};let t=Vt(e);return t===null?{kind:`noise`}:{kind:`kept`,value:t,mutated:t!==e}}function Wt(e){let t=Ut(e.source),n=Ut(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 Gt(){if(typeof navigator>`u`||typeof navigator.sendBeacon!=`function`)return;let e=navigator.sendBeacon;if(e[Ht])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=Wt(n);if(r===!0)return!0;if(r!==null)return t(e,r)}}}catch{}return t(e,n)});n[Ht]=!0,navigator.sendBeacon=n}function Kt(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??qt(t.state)??`Mirroring another browser.`}}function qt(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 Jt(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 Yt=e({ACCOUNTS_KEY:()=>fe,__test__:()=>ce,_testOnly_dispatchTrayJoinWithFailureFeedback:()=>Qt,addAccount:()=>T,applyProviderDefaults:()=>S,clearAllSettings:()=>le,clearApiKey:()=>de,clearBaseUrl:()=>ee,clearSelectedProvider:()=>oe,describeInvalidJoinUrl:()=>Jt,downloadProviders:()=>en,exportProviders:()=>pe,getAccounts:()=>w,getAllAvailableModels:()=>te,getAllExtraOAuthDomains:()=>ue,getApiKey:()=>se,getApiKeyForProvider:()=>re,getApiVersionForProvider:()=>ne,getAvailableProviders:()=>x,getBaseUrl:()=>me,getBaseUrlForProvider:()=>_e,getDeploymentForProvider:()=>C,getExtraOAuthDomains:()=>ge,getOAuthAccountInfo:()=>g,getProviderConfig:()=>i,getProviderModels:()=>he,getRawApiKeyForProvider:()=>_,getSelectedModelId:()=>o,getSelectedProvider:()=>a,isModelHiddenFromPicker:()=>p,logoutOAuthAccount:()=>ae,maskOAuthTokenWithRetry:()=>n,migrateLegacyAuthOnlySelection:()=>ie,persistOAuthMaskViaServiceWorker:()=>d,providerOffersLlmModels:()=>f,reloginOAuthAccount:()=>Y,removeAccount:()=>m,resolveCurrentModel:()=>s,resolveModelById:()=>l,resolveModelByShorthand:()=>u,saveOAuthAccount:()=>h,setApiKey:()=>ve,setBaseUrl:()=>r,setExtraOAuthDomains:()=>y,setExtraOAuthDomainsAsync:()=>c,setSelectedModelId:()=>v,setSelectedProvider:()=>b,showProviderSettings:()=>Cn}),Xt=E(`provider-settings`);function Zt(){return typeof chrome<`u`&&!!chrome?.runtime?.id}function Qt(e,t){return $t(e,t)}function $t(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){Xt.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 en(){let e=JSON.stringify(pe(),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 tn(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):X(e)}function nn(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=tn(e.apiKey),e.baseUrl&&(t.textContent+=` • `+e.baseUrl),t}async function Y(e,n){let{createOAuthLauncher:r,createInterceptingOAuthLauncherForCurrentRuntime:i}=await t(async()=>{let{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}=await import(`./oauth-service-BSqTYvb6.js`);return{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}},__vite__mapDeps([35,1,3,4,5,6,19,36])),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 rn(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 an(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`,()=>{Y(n,()=>X(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),X(e)})()})),r}function on(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),X(e)})()}),n}function sn(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(nn(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(rn(e,t)),n.isOAuth&&s.appendChild(an(e,t,n)),s.appendChild(on(e,t)),r.appendChild(s),r}function cn(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=St(),a=i.state!==`inactive`,o=Ye(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 X(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(sn(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`,()=>en()),i.appendChild(o),t.appendChild(i),t.appendChild(cn(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 ln(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 un(e,t){let n=ln(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 dn(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 fn(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}=dn(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 Ee(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 pn(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=_e(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-BSqTYvb6.js`);return{createInterceptingOAuthLauncherForCurrentRuntime:e}},__vite__mapDeps([35,1,3,4,5,6,19,36])),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:fn(n.oauth)})}else if(a.onOAuthLogin){let{createOAuthLauncher:n}=await t(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-BSqTYvb6.js`);return{createOAuthLauncher:e}},__vite__mapDeps([35,1,3,4,5,6,19,36])),r=n();await a.onOAuthLogin(r,()=>J(e))}}catch(e){if(!s)try{await m(r)}catch{}Xt.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 mn(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 hn(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 gn(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 _n(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,mn(e,n),hn(e,n),gn(e,n)}function vn(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 yn(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`,()=>X(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=un(e.options,t);n.appendChild(o.providerSelect),n.appendChild(o.providerDesc),o.oauth.loginBtn.addEventListener(`click`,()=>{pn(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`,_n(o)}),_n(o),o.saveBtn.addEventListener(`click`,()=>vn(e,o));let s=t=>{t.key===`Enter`&&vn(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),yn(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 bn(e,t,n,r){if(Zt()){let e={type:`refresh-tray-runtime`,joinUrl:t,workerBaseUrl:n};chrome.runtime.sendMessage({source:`panel`,payload:e}).catch(()=>{})}else $t(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 xn(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=F(window.localStorage,t);if(!n){o.textContent=`Invalid sync URL.`,o.style.display=``,o.style.color=`var(--slicc-cone)`;return}bn(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 Sn(){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(Sn());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=F(window.localStorage,t);if(!n){o.textContent=Jt(t),o.style.display=``,a.focus();return}bn(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 Cn(e){return zt(`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?X(i):e?.autoJoinUrl?xn(i,e.autoJoinUrl):e?.preferTrayJoin?Q(i):Z(i),n.appendChild(r),document.body.appendChild(n)})}var $=E(`main`);function wn(e){try{return new URL(e).searchParams.has(`ui-fixture`)}catch{return!1}}async function Tn(){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(wn(window.location.href)){let{mountWcUiPreview:n}=await t(async()=>{let{mountWcUiPreview:e}=await import(`./wc-shell-BPSFQuzD.js`).then(e=>e.a);return{mountWcUiPreview:e}},__vite__mapDeps([37,4,1,23,38,39,40]));n(e);return}Be(),Ue(),r!==`connect`&&Ft().catch(()=>{});let i=Me(window.location.search),a=r===`cherry`?null:mt(window.location.search),o=!!a&&I();if(await yt(i?{apiBaseUrl:i.apiBaseUrl,token:i.token}:null,o&&a?{extensionId:a.extensionId}:null)===`reload-pending`)return;if(!n&&(r===`follower`||r===`cherry`)){let{mountWcUiFollower:n}=await t(async()=>{let{mountWcUiFollower:e}=await import(`./wc-follower-Crqux2kQ.js`);return{mountWcUiFollower:e}},__vite__mapDeps([41,1,2,32,4,37,23,38,39,40,42,5,36,43,8,9,10,11,12,13,3,6,14,15,16,17,18,19,20,21,44,45,46,47,28,48,49,50,51,52,53,54,55]));return n(e,$,r)}await Te(),S();let{bootstrapOAuthReplicas:s}=await t(async()=>{let{bootstrapOAuthReplicas:e}=await import(`./oauth-bootstrap-C1t3F5l9.js`);return{bootstrapOAuthReplicas:e}},__vite__mapDeps([56,1,12,4,8,9,10,11,13,2,5,3,6,14,15,16,17,18,19,20,21]));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-CuB1P3LZ.js`);return{loadLegacyStyles:e}},__vite__mapDeps([57,1]));await n();let{mountConnectSurface:r}=await t(async()=>{let{mountConnectSurface:e}=await import(`./connect-surface-Ce0cz8Sc.js`);return{mountConnectSurface:e}},__vite__mapDeps([58,12,4,1,8,9,10,11,13,2,5,3,6,14,15,16,17,18,19,20,21]));await r(e);return}if(n){let{mountWcUiExtension:n}=await t(async()=>{let{mountWcUiExtension:e}=await import(`./wc-extension-C4v5cPUY.js`);return{mountWcUiExtension:e}},__vite__mapDeps([59,1,60,61,43,8,9,10,11,4,12,13,2,5,3,6,14,15,16,17,18,19,20,21,36,44,45,46,47,23,28,48,49,37,38,39,40,50,51,52,53]));return n(e,$,r===`extension-detached`)}o&&a&&ze(a.extensionId);let{mountWcUiLive:c}=await t(async()=>{let{mountWcUiLive:e}=await import(`./wc-live-DQFQdors.js`);return{mountWcUiLive:e}},__vite__mapDeps([43,1,8,9,10,11,4,12,13,2,5,3,6,14,15,16,17,18,19,20,21,36,44,45,46,47,23,28,48,49,37,38,39,40,50,51,52,53]));return c(e,$,r)}Tn().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{Ye as C,Ze as D,F as E,De as O,Je as S,tt as T,ut as _,H as a,j as b,At as c,Ct as d,St as f,vt as g,wt as h,It as i,kt as l,Et as m,Cn as n,Rt as o,Dt as p,Kt as r,Lt as s,Yt as t,Ot as u,qe as v,Xe as w,$e as x,M as y};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-
|
|
2
|
-
import{t as e}from"./preload-helper-CZgWQFsJ.js";import{t}from"./mime-types-ugOWOUZ9.js";import{a as n,o as r}from"./src-BdPw21ST.js";import{a as i,n as a,t as o}from"./proxied-fetch-iGqLvoxh.js";import{t as s}from"./types-idfTVsM8.js";import"./backend-local-BgTSBOxM.js";import"./mount-table-store-CfQUN_2R.js";import{t as c}from"./mount-bridge-client-DHpxu7lQ.js";function l(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 u(e){return e.split(`/`).pop()||`data`}function d(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 f=5*1024*1024,p=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=d(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??f,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new s(`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 s(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new s(`EACCES`,`da access denied`,e);if(i.status>=400)throw new s(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new s(`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 s(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),i=await this.cache.getBody(r),a=l(u(e),t(e),n),o={"content-type":a.contentType,"content-length":String(a.body.byteLength)};i?.etag?o[`if-match`]=i.etag.startsWith(`W/`)?i.etag.slice(2):i.etag:i||(o[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:o,body:a.body}),d,f=1;try{d=await c()}catch{f=2,d=await c()}if(d.status===412){if(f===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new s(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let i=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,i);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new s(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(d.status===401||d.status===403)throw new s(`EACCES`,`da write denied`,e);if(d.status>=400)throw new s(`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 s(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new s(`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()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new s(`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(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,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 s(`ENOENT`,`no such file or directory`,e)}throw new s(`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 s(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new s(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new s(`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 m(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 h=25*1024*1024,g=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=m(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??h,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new s(`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 s(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new s(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new s(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new s(`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 s(`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 a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,c=1;try{o=await a()}catch{c=2,o=await a()}if(o.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 s(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new s(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new s(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new s(`EIO`,`s3 writeFile failed: ${o.status}`,e);let l=o.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 s(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.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()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new s(`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 s(`ENOENT`,`no such file or directory`,e)}throw new s(`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 s(`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 s(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new s(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new s(`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}},_=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function v(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-QLqDJZ3y.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,18,19])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new _(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var y=`slicc-mount-cache`,b=`listings`,x=`bodies`,S=class{mountId;ttlMs;dbName;dbPromise=null;constructor(e){this.mountId=e.mountId,this.ttlMs=e.ttlMs,this.dbName=e.dbName??y}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(b)||e.createObjectStore(b),e.objectStoreNames.contains(x)||e.createObjectStore(x)},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(b,`readonly`).objectStore(b).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(b,`readwrite`),o={entries:t,cachedAt:Date.now()};a.objectStore(b).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(b,`readwrite`);i.objectStore(b).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(x,`readonly`).objectStore(x).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,x,this.key(e),i)}catch(t){if(t instanceof DOMException&&t.name===`QuotaExceededError`){await this.evictLru(.25);try{await this.txPut(r,x,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(x,`readwrite`);i.objectStore(x).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(b),n(x)])}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(x,`readonly`).objectStore(x),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(x,`readwrite`),i=r.objectStore(x);for(let{key:e}of a)i.delete(e);r.oncomplete=()=>e(),r.onerror=()=>n(r.error)})}};function C(){return typeof chrome<`u`&&!!chrome?.runtime?.id}var w=n,T=r,E=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),D=new Set([101,103,204,205,304]);function O(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new s(`EACCES`,e.error):e.errorCode===`invalid_request`?new s(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||E.has(String(e.errorCode))?new s(`EIO`,e.error):new s(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=w(e.bodyBase64)}catch(e){throw new s(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=D.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function k(e,t){let n;try{n=await fetch(i(e),{method:`POST`,headers:o({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new s(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new s(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function A(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new s(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function j(e,t,n){return C()?A(e,n):a()?c(e,n):k(t,n)}function M(e){return async t=>O(await j(`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?T(t.body):void 0}))}function N(e){let t=e?.getImsToken??(async()=>(await v()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new s(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return O(await j(`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?T(e.body):void 0}))}}export{p as DaMountBackend,S as RemoteMountCache,g as S3MountBackend,N as makeSignedFetchDa,M as makeSignedFetchS3};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-Bk7BU4R2.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-CZgWQFsJ.js","assets/compat-DADQxxLV.js","assets/models-ByRUWfA-.js","assets/provider-env-D37PhSJu.js","assets/__vite-browser-external-SwrSgYTf.js","assets/context-compaction-DaxQExZG.js","assets/logger-DDBAeTLF.js","assets/src-BdPw21ST.js","assets/proxied-fetch-iGqLvoxh.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-DnYeyyJY.js","assets/secrets-bridge-client-x_puVSDN.js","assets/port-bridge-client-BJ5rcoKH.js","assets/tool-ui-DfXu6quJ.js","assets/providers-BrRzKc33.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-DbZ6Mjym.js","assets/transform-messages-D7OsqBmU.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{t as e}from"./preload-helper-CZgWQFsJ.js";import{t}from"./mime-types-ugOWOUZ9.js";import{a as n,o as r}from"./src-BdPw21ST.js";import{a as i,n as a,t as o}from"./proxied-fetch-iGqLvoxh.js";import{t as s}from"./types-idfTVsM8.js";import"./backend-local-BgTSBOxM.js";import"./mount-table-store-CfQUN_2R.js";import{t as c}from"./mount-bridge-client-DHpxu7lQ.js";function l(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 u(e){return e.split(`/`).pop()||`data`}function d(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 f=5*1024*1024,p=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=d(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??f,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new s(`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 s(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new s(`EACCES`,`da access denied`,e);if(i.status>=400)throw new s(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new s(`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 s(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),i=await this.cache.getBody(r),a=l(u(e),t(e),n),o={"content-type":a.contentType,"content-length":String(a.body.byteLength)};i?.etag?o[`if-match`]=i.etag.startsWith(`W/`)?i.etag.slice(2):i.etag:i||(o[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:o,body:a.body}),d,f=1;try{d=await c()}catch{f=2,d=await c()}if(d.status===412){if(f===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new s(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let i=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,i);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new s(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(d.status===401||d.status===403)throw new s(`EACCES`,`da write denied`,e);if(d.status>=400)throw new s(`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 s(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new s(`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()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new s(`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(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,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 s(`ENOENT`,`no such file or directory`,e)}throw new s(`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 s(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new s(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new s(`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 m(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 h=25*1024*1024,g=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=m(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??h,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new s(`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 s(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new s(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new s(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new s(`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 s(`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 a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,c=1;try{o=await a()}catch{c=2,o=await a()}if(o.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 s(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new s(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new s(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new s(`EIO`,`s3 writeFile failed: ${o.status}`,e);let l=o.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 s(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.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()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new s(`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 s(`ENOENT`,`no such file or directory`,e)}throw new s(`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 s(`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 s(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new s(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new s(`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}},_=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function v(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-Bk7BU4R2.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,18,19])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new _(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var y=`slicc-mount-cache`,b=`listings`,x=`bodies`,S=class{mountId;ttlMs;dbName;dbPromise=null;constructor(e){this.mountId=e.mountId,this.ttlMs=e.ttlMs,this.dbName=e.dbName??y}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(b)||e.createObjectStore(b),e.objectStoreNames.contains(x)||e.createObjectStore(x)},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(b,`readonly`).objectStore(b).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(b,`readwrite`),o={entries:t,cachedAt:Date.now()};a.objectStore(b).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(b,`readwrite`);i.objectStore(b).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(x,`readonly`).objectStore(x).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,x,this.key(e),i)}catch(t){if(t instanceof DOMException&&t.name===`QuotaExceededError`){await this.evictLru(.25);try{await this.txPut(r,x,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(x,`readwrite`);i.objectStore(x).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(b),n(x)])}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(x,`readonly`).objectStore(x),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(x,`readwrite`),i=r.objectStore(x);for(let{key:e}of a)i.delete(e);r.oncomplete=()=>e(),r.onerror=()=>n(r.error)})}};function C(){return typeof chrome<`u`&&!!chrome?.runtime?.id}var w=n,T=r,E=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),D=new Set([101,103,204,205,304]);function O(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new s(`EACCES`,e.error):e.errorCode===`invalid_request`?new s(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||E.has(String(e.errorCode))?new s(`EIO`,e.error):new s(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=w(e.bodyBase64)}catch(e){throw new s(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=D.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function k(e,t){let n;try{n=await fetch(i(e),{method:`POST`,headers:o({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new s(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new s(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function A(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new s(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function j(e,t,n){return C()?A(e,n):a()?c(e,n):k(t,n)}function M(e){return async t=>O(await j(`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?T(t.body):void 0}))}function N(e){let t=e?.getImsToken??(async()=>(await v()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new s(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return O(await j(`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?T(e.body):void 0}))}}export{p as DaMountBackend,S as RemoteMountCache,g as S3MountBackend,N as makeSignedFetchDa,M as makeSignedFetchS3};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{_ as t,g as n,o as r,r as i,t as a}from"./proxied-fetch-BVw2cmL4.js";import"./backend-local-mrUgrni5.js";import{t as o}from"./types-idfTVsM8.js";import{t as s}from"./mime-types-BqLkKWa7.js";import{t as c}from"./remote-cache-D59F5FOx.js";import{t as l}from"./port-bridge-client-vT8ubtB-.js";function u(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 d(e){return e.split(`/`).pop()||`data`}function f(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 p=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=f(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new o(`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 o(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new o(`EACCES`,`da access denied`,e);if(i.status>=400)throw new o(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),s=a?Number(a):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new o(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new o(`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,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new o(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n),i=u(d(e),s(e),t),a={"content-type":i.contentType,"content-length":String(i.body.byteLength)};r?.etag?a[`if-match`]=r.etag.startsWith(`W/`)?r.etag.slice(2):r.etag:r||(a[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(n),headers:a,body:i.body}),l,f=1;try{l=await c()}catch{f=2,l=await c()}if(l.status===412){if(f===2){let r=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(r.status>=400)throw new o(`EIO`,`da reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new o(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new o(`EACCES`,`da write denied`,e);if(l.status>=400)throw new o(`EIO`,`da writeFile failed: ${l.status}`,e);let p=l.headers.get(`etag`)??``;await this.cache.putBody(n,t,p);let m=n.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 o(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new o(`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()??``,a=r.join(`/`),s=await this.cache.getListing(a);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 o(`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(a,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 o(`ENOENT`,`no such file or directory`,e)}throw new o(`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 o(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new o(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new o(`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 m(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 h=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=m(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new o(`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 o(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new o(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new o(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),s=a?Number(a):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new o(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new o(`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 o(`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 a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),s,c=1;try{s=await a()}catch{c=2,s=await a()}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 o(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new o(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new o(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new o(`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 o(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.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()??``,a=r.join(`/`),s=await this.cache.getListing(a);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 o(`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 o(`ENOENT`,`no such file or directory`,e)}throw new o(`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 o(`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 o(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new o(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new o(`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}},g=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function _(){let{getAccounts:e}=await import(`./account-store-CjP3u0Xj.js`).then(e=>e.n),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new g(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}const v=l({portName:`mount.sign-and-forward`,panelRpcOp:`mount-sign-and-forward`,timeoutMs:12e4,onUnavailable:`reject`,makeError:e=>new o(`EIO`,`mount transport failed: ${e}`),logNamespace:`mount-bridge`,toPortMessage:({type:e,envelope:t})=>({type:e,envelope:t}),toPanelRpcPayload:({type:e,envelope:t})=>({type:e,envelope:t})});function y(e,t){return v({type:e,envelope:t})}function b(){return typeof chrome<`u`&&!!chrome?.runtime?.id}const x=n,S=t,C=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),w=new Set([101,103,204,205,304]);function T(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new o(`EACCES`,e.error):e.errorCode===`invalid_request`?new o(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||C.has(String(e.errorCode))?new o(`EIO`,e.error):new o(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=x(e.bodyBase64)}catch(e){throw new o(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=w.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function E(e,t){let n;try{n=await fetch(r(e),{method:`POST`,headers:a({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new o(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new o(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function D(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new o(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function O(e,t,n){return b()?D(e,n):i()?y(e,n):E(t,n)}function k(e){return async t=>T(await O(`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?S(t.body):void 0}))}function A(e){let t=e?.getImsToken??(async()=>(await _()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new o(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return T(await O(`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?S(e.body):void 0}))}}var j=e({DaMountBackend:()=>p,RemoteMountCache:()=>c,S3MountBackend:()=>h,makeSignedFetchDa:()=>A,makeSignedFetchS3:()=>k});export{p as a,h as i,A as n,k as r,j as t};
|
|
1
|
+
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{_ as t,g as n,o as r,r as i,t as a}from"./proxied-fetch-BVw2cmL4.js";import"./backend-local-mrUgrni5.js";import{t as o}from"./types-idfTVsM8.js";import{t as s}from"./mime-types-BqLkKWa7.js";import{t as c}from"./remote-cache-D59F5FOx.js";import{t as l}from"./port-bridge-client-vT8ubtB-.js";function u(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 d(e){return e.split(`/`).pop()||`data`}function f(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 p=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=f(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new o(`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 o(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new o(`EACCES`,`da access denied`,e);if(i.status>=400)throw new o(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),s=a?Number(a):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new o(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new o(`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,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new o(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n),i=u(d(e),s(e),t),a={"content-type":i.contentType,"content-length":String(i.body.byteLength)};r?.etag?a[`if-match`]=r.etag.startsWith(`W/`)?r.etag.slice(2):r.etag:r||(a[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(n),headers:a,body:i.body}),l,f=1;try{l=await c()}catch{f=2,l=await c()}if(l.status===412){if(f===2){let r=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(r.status>=400)throw new o(`EIO`,`da reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new o(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new o(`EACCES`,`da write denied`,e);if(l.status>=400)throw new o(`EIO`,`da writeFile failed: ${l.status}`,e);let p=l.headers.get(`etag`)??``;await this.cache.putBody(n,t,p);let m=n.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 o(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new o(`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()??``,a=r.join(`/`),s=await this.cache.getListing(a);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 o(`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(a,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 o(`ENOENT`,`no such file or directory`,e)}throw new o(`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 o(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new o(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new o(`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 m(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 h=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=m(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new o(`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 o(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new o(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new o(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),s=a?Number(a):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new o(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new o(`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 o(`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 a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),s,c=1;try{s=await a()}catch{c=2,s=await a()}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 o(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new o(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new o(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new o(`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 o(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.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()??``,a=r.join(`/`),s=await this.cache.getListing(a);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 o(`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 o(`ENOENT`,`no such file or directory`,e)}throw new o(`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 o(`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 o(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new o(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new o(`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}},g=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function _(){let{getAccounts:e}=await import(`./account-store-CWYCPgAg.js`).then(e=>e.n),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new g(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}const v=l({portName:`mount.sign-and-forward`,panelRpcOp:`mount-sign-and-forward`,timeoutMs:12e4,onUnavailable:`reject`,makeError:e=>new o(`EIO`,`mount transport failed: ${e}`),logNamespace:`mount-bridge`,toPortMessage:({type:e,envelope:t})=>({type:e,envelope:t}),toPanelRpcPayload:({type:e,envelope:t})=>({type:e,envelope:t})});function y(e,t){return v({type:e,envelope:t})}function b(){return typeof chrome<`u`&&!!chrome?.runtime?.id}const x=n,S=t,C=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),w=new Set([101,103,204,205,304]);function T(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new o(`EACCES`,e.error):e.errorCode===`invalid_request`?new o(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||C.has(String(e.errorCode))?new o(`EIO`,e.error):new o(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=x(e.bodyBase64)}catch(e){throw new o(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=w.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function E(e,t){let n;try{n=await fetch(r(e),{method:`POST`,headers:a({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new o(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new o(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function D(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new o(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function O(e,t,n){return b()?D(e,n):i()?y(e,n):E(t,n)}function k(e){return async t=>T(await O(`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?S(t.body):void 0}))}function A(e){let t=e?.getImsToken??(async()=>(await _()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new o(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return T(await O(`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?S(e.body):void 0}))}}var j=e({DaMountBackend:()=>p,RemoteMountCache:()=>c,S3MountBackend:()=>h,makeSignedFetchDa:()=>A,makeSignedFetchS3:()=>k});export{p as a,h as i,A as n,k as r,j as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-
|
|
2
|
-
import{t as e}from"./preload-helper-CZgWQFsJ.js";import{F as t,m as n}from"./account-store-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-C3DL1kkz.js","assets/rolldown-runtime-aKtaBQYM.js","assets/compat-DADQxxLV.js","assets/models-ByRUWfA-.js","assets/preload-helper-CZgWQFsJ.js","assets/provider-env-D37PhSJu.js","assets/__vite-browser-external-SwrSgYTf.js","assets/account-store-Bk7BU4R2.js","assets/context-compaction-DaxQExZG.js","assets/logger-DDBAeTLF.js","assets/src-BdPw21ST.js","assets/proxied-fetch-iGqLvoxh.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-DnYeyyJY.js","assets/secrets-bridge-client-x_puVSDN.js","assets/port-bridge-client-BJ5rcoKH.js","assets/tool-ui-DfXu6quJ.js","assets/providers-BrRzKc33.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-DbZ6Mjym.js","assets/transform-messages-D7OsqBmU.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-C5g936Qd.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{t as e}from"./preload-helper-CZgWQFsJ.js";import{F as t,m as n}from"./account-store-Bk7BU4R2.js";import{t as r}from"./logger-DDBAeTLF.js";import"./main-DVF1KaMV.js";import{t as i}from"./llm-session-id-bZQs6gBN.js";import{SessionStore as a}from"./session-store-DAM8GRJ0.js";import{a as o,i as s}from"./wc-live-DQFQdors.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 o({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=s(r.vfs,_,{model:v,apiKey:f,headers:h,pickIcon:t=>e(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-C3DL1kkz.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])).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 o({sessionStore:t,vfs:e.vfs,mode:`quick`})}export{f as runNewSessionFreeze,m as runNewSessionFreezeQuick};
|