sliccy 6.105.0 → 6.105.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/node-server/_cloud_core/src/operations/list.d.ts.map +1 -1
  2. package/dist/node-server/_cloud_core/src/operations/list.js +149 -115
  3. package/dist/node-server/_shared/tray-signaling.d.ts +28 -1
  4. package/dist/node-server/_shared/tray-signaling.d.ts.map +1 -1
  5. package/dist/node-server/_shared/tray-signaling.js.map +1 -1
  6. package/dist/node-server/routes/lick-api.js +71 -4
  7. package/dist/ui/.vite/manifest.json +127 -127
  8. package/dist/ui/assets/SKILL-Boj7N1xe.js +1 -0
  9. package/dist/ui/assets/{account-store-DG6fHM_V.js → account-store-BaTmqQCH.js} +1 -1
  10. package/dist/ui/assets/{account-store-ChIwciCW.js → account-store-CHgSp6SB.js} +1 -1
  11. package/dist/ui/assets/{adobe-3WjIpRUT.js → adobe-CH2DsFrY.js} +1 -1
  12. package/dist/ui/assets/{adobe-DJkbFq9G.js → adobe-CpalWkIK.js} +1 -1
  13. package/dist/ui/assets/{agent-panels-tKYkUvdP.js → agent-panels-OnTGHQkG.js} +1 -1
  14. package/dist/ui/assets/{apply-layout-CM3LBbqI.js → apply-layout-B4zUEdwn.js} +1 -1
  15. package/dist/ui/assets/{apps-DjfwghFw.js → apps-KhIC51KH.js} +1 -1
  16. package/dist/ui/assets/{azure-openai-BdYS25f_.js → azure-openai-DzFu6LbW.js} +1 -1
  17. package/dist/ui/assets/{azure-openai-CtbbffyG.js → azure-openai-uxQv3w4B.js} +1 -1
  18. package/dist/ui/assets/cdp-ws-page-bridge-DI26JBMr.js +1 -0
  19. package/dist/ui/assets/{cerebras-cVRZgXZu.js → cerebras-r-in8Inh.js} +1 -1
  20. package/dist/ui/assets/{cerebras-cB1Un2e8.js → cerebras-uwqZLHdF.js} +1 -1
  21. package/dist/ui/assets/{connect-surface-DT_tKlEJ.js → connect-surface-COZ8qeD4.js} +1 -1
  22. package/dist/ui/assets/{dist-N1MMHRNk.js → dist-CIyvNQb4.js} +3 -3
  23. package/dist/ui/assets/{dist-BmTb9jmr.js → dist-CLbkZ_1_.js} +1 -1
  24. package/dist/ui/assets/{dist-BnDrtqYs.js → dist-ChNj9ewx.js} +1 -1
  25. package/dist/ui/assets/{dist-RekgwRC0.js → dist-DhiPJE96.js} +3 -3
  26. package/dist/ui/assets/{fs-C343c9le.js → fs-B7WAwF-q.js} +1 -1
  27. package/dist/ui/assets/{fs-CZt4jt7E.js → fs-CiufgGRG.js} +2 -2
  28. package/dist/ui/assets/{github-0N7JEs6o.js → github-C3CflEFq.js} +1 -1
  29. package/dist/ui/assets/{github-CbTrlTDc.js → github-CUPlgkJ4.js} +2 -2
  30. package/dist/ui/assets/{github-copilot-D8KEH9_8.js → github-copilot-BGah-ri-.js} +1 -1
  31. package/dist/ui/assets/{github-copilot-B_sSIHQ9.js → github-copilot-DnK9K-w0.js} +1 -1
  32. package/dist/ui/assets/{github-install-CORVkVS2.js → github-install-B3PxKIA9.js} +1 -1
  33. package/dist/ui/assets/{github-zip-Cx9nWjUO.js → github-zip-DlpU53sL.js} +1 -1
  34. package/dist/ui/assets/{js-realm-worker-5ergWUC8.js → js-realm-worker-zKU0v1vE.js} +1 -1
  35. package/dist/ui/assets/{kernel-worker-DAg1kk9T.js → kernel-worker-v5zxjG5E.js} +596 -596
  36. package/dist/ui/assets/lick-manager-DsQLFcKr.js +2 -0
  37. package/dist/ui/assets/{lick-manager-proxy-B953oJ2Q.js → lick-manager-proxy-DMaLHm_t.js} +1 -1
  38. package/dist/ui/assets/lick-ws-bridge-1UPwiSVX.js +1 -0
  39. package/dist/ui/assets/{local-llm-D7TUI-yw.js → local-llm-D-etSg11.js} +1 -1
  40. package/dist/ui/assets/{local-llm-BaGh_ZI-.js → local-llm-M_xiCmuW.js} +1 -1
  41. package/dist/ui/assets/{main-BcZbFpyc.js → main-BcfY0APV.js} +3 -3
  42. package/dist/ui/assets/{mount-3rB1M3LV.js → mount-Bx3D0gVr.js} +2 -2
  43. package/dist/ui/assets/{mount-ctgoIoWo.js → mount-CHtLYCJk.js} +1 -1
  44. package/dist/ui/assets/{mount-recovery-g_5aJYzL.js → mount-recovery-DL9GlfHA.js} +1 -1
  45. package/dist/ui/assets/new-session-COA3q4w7.js +2 -0
  46. package/dist/ui/assets/{oauth-bootstrap-yw-xe8Vv.js → oauth-bootstrap-BPR0IgmZ.js} +2 -2
  47. package/dist/ui/assets/{onboarding-orchestrator-B-FUyeGB.js → onboarding-orchestrator-5WhumpNJ.js} +1 -1
  48. package/dist/ui/assets/{openai-codex-BFok3oyS.js → openai-codex-CjwoH0Hy.js} +1 -1
  49. package/dist/ui/assets/{openai-codex-cLIR3T6l.js → openai-codex-pUiCqrNz.js} +1 -1
  50. package/dist/ui/assets/{openrouter-FWB-kSYo.js → openrouter-BCxd8O71.js} +1 -1
  51. package/dist/ui/assets/{openrouter-CDPyW_TQ.js → openrouter-CdL4vTyx.js} +1 -1
  52. package/dist/ui/assets/{openrouter-oauth-DAARzo5S.js → openrouter-oauth-CsUVNT2k.js} +1 -1
  53. package/dist/ui/assets/{openrouter-oauth-DZirIqg2.js → openrouter-oauth-Dj48fB3X.js} +1 -1
  54. package/dist/ui/assets/{panel-rpc-handlers-DrqsnYA3.js → panel-rpc-handlers-QwtLrbX7.js} +2 -2
  55. package/dist/ui/assets/{panelize-shell-giUuZ6dY.js → panelize-shell-CPME7tYP.js} +1 -1
  56. package/dist/ui/assets/provider-CKVeq844.js +2 -0
  57. package/dist/ui/assets/{provider-DUYOy2mD.js → provider-CR46uvW6.js} +1 -1
  58. package/dist/ui/assets/{provider-settings-Cw0rYGSz.js → provider-settings-e94aWkxT.js} +1 -1
  59. package/dist/ui/assets/provider-store-access-CamE9gn8.js +1 -0
  60. package/dist/ui/assets/provider-store-access-wSpMHw1M.js +1 -0
  61. package/dist/ui/assets/{providers-zHBaRRbi.js → providers-Bpgm6hcR.js} +1 -1
  62. package/dist/ui/assets/{providers-EvW22h9s.js → providers-N-GzEZuq.js} +2 -2
  63. package/dist/ui/assets/{quick-llm-CCC28hMC.js → quick-llm-Dx10uCk3.js} +1 -1
  64. package/dist/ui/assets/{recovery-screen-DRwDpcP6.js → recovery-screen-Xm3PO1gX.js} +1 -1
  65. package/dist/ui/assets/{redirect-uri-BUHYoStY.js → redirect-uri-BiQsjA10.js} +1 -1
  66. package/dist/ui/assets/{run-DL-Uxc18.js → run-Bu6cgQMI.js} +1 -1
  67. package/dist/ui/assets/{setup-feature-flags-remote-Czi_ny8P.js → setup-feature-flags-remote-Cf37xnQ1.js} +1 -1
  68. package/dist/ui/assets/sidecar-repair-6yH0jK3Q.js +1 -0
  69. package/dist/ui/assets/{skills-B9hTovVh.js → skills-Bm5AxgzO.js} +1 -1
  70. package/dist/ui/assets/slicc-version-rYLQXBjd.js +1 -0
  71. package/dist/ui/assets/{state-BKg54qnI.js → state-CJZU3MUJ.js} +1 -1
  72. package/dist/ui/assets/{store-Ckx5Qk8r.js → store-ByoR63_A.js} +1 -1
  73. package/dist/ui/assets/store-CKhg-xXm.js +1 -0
  74. package/dist/ui/assets/{sudo-BYKLWL8l.js → sudo-gXakxwpD.js} +1 -1
  75. package/dist/ui/assets/{sync-dialog-CaY6_dCO.js → sync-dialog-CtrrU_-X.js} +1 -1
  76. package/dist/ui/assets/{tray-sidecar-CHw8U7kW.js → tray-sidecar-DP-OKeYT.js} +1 -1
  77. package/dist/ui/assets/{upgrade-detection-BGI4k545.js → upgrade-detection-4KedpK0u.js} +1 -1
  78. package/dist/ui/assets/{voice-reply-BLB0WMGq.js → voice-reply-DJDzh5c_.js} +1 -1
  79. package/dist/ui/assets/{wc-attach-DfPSrixU.js → wc-attach-CHoh_npa.js} +2 -2
  80. package/dist/ui/assets/{wc-extension-DhuoWguy.js → wc-extension-DinzzE-u.js} +2 -2
  81. package/dist/ui/assets/{wc-float-label-cFzM9BsP.js → wc-float-label-_5Qu7XYI.js} +1 -1
  82. package/dist/ui/assets/{wc-floatbar-online-BKJPRq_0.js → wc-floatbar-online-DdJjsUiB.js} +1 -1
  83. package/dist/ui/assets/{wc-follower-oauth-CuUqosbc.js → wc-follower-oauth-CQymgqdo.js} +1 -1
  84. package/dist/ui/assets/{wc-follower-BiIsjqEt.js → wc-follower-orVLyho6.js} +3 -3
  85. package/dist/ui/assets/{wc-live-9ZO5QfgI.js → wc-live-Y30MNXP6.js} +7 -7
  86. package/dist/ui/assets/{wc-nav-DW3cMVIc.js → wc-nav-CObJ1-cm.js} +2 -2
  87. package/dist/ui/assets/{wc-onboarding-SeOTnz2o.js → wc-onboarding-13bz6Y1P.js} +2 -2
  88. package/dist/ui/assets/{wc-placeholder-BMJjSG0P.js → wc-placeholder-DEerShZk.js} +3 -3
  89. package/dist/ui/assets/{wc-settings-UD2VUoLt.js → wc-settings-S7sjuH3z.js} +3 -3
  90. package/dist/ui/assets/{wc-shell-hnMI7FOV.js → wc-shell-DHFdDKPB.js} +2 -2
  91. package/dist/ui/assets/{wc-shortcut-config-CqDAvdEe.js → wc-shortcut-config-CY9y5JD2.js} +1 -1
  92. package/dist/ui/assets/{wc-sprinkles-_BGRskZQ.js → wc-sprinkles-BX0o3VdV.js} +2 -2
  93. package/dist/ui/assets/{wc-transcript-export-DXo_nXRM.js → wc-transcript-export-BS7RBV-1.js} +2 -2
  94. package/dist/ui/assets/{wc-tray-Cy15l2Cc.js → wc-tray-CdT1k5xd.js} +2 -2
  95. package/dist/ui/assets/welcome-detection-DbHTpMYI.js +1 -0
  96. package/dist/ui/assets/{xai-grok-CKUQxsx-.js → xai-grok-DaoF-Hq_.js} +1 -1
  97. package/dist/ui/assets/{xai-grok-B6FjD17P.js → xai-grok-_z4Y3sUx.js} +1 -1
  98. package/dist/ui/index.html +3 -3
  99. package/dist/ui/llm-proxy-sw.js +1 -1
  100. package/dist/ui/packages/webapp/index.html +3 -3
  101. package/package.json +1 -1
  102. package/dist/ui/assets/SKILL-B-2ojpz4.js +0 -1
  103. package/dist/ui/assets/cdp-ws-page-bridge-D_PY6ku1.js +0 -1
  104. package/dist/ui/assets/lick-manager-CYlek4qq.js +0 -2
  105. package/dist/ui/assets/lick-ws-bridge-BJTVP6Z3.js +0 -1
  106. package/dist/ui/assets/new-session-D1hm84f7.js +0 -2
  107. package/dist/ui/assets/provider-DM7nUGRc.js +0 -2
  108. package/dist/ui/assets/provider-store-access-D4PsvZNr.js +0 -1
  109. package/dist/ui/assets/provider-store-access-DLlfWlp9.js +0 -1
  110. package/dist/ui/assets/sidecar-repair-FzgS788B.js +0 -1
  111. package/dist/ui/assets/slicc-version-mN6TT2sL.js +0 -1
  112. package/dist/ui/assets/store-DRjMIGJv.js +0 -1
  113. package/dist/ui/assets/welcome-detection-NLNTy3II.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{s as n}from"./src-CcFD5QfS.js";import{T as r,c as i,f as a,i as o,l as s,p as c,v as l,x as u,y as d}from"./db-DSIYsBgP.js";function f(e,t){if(e==null)return[];let n;if(Array.isArray(e))n=e.join(`, `).replace(/\n/g,`, `);else if(typeof e==`string`)n=e.replace(/\n/g,`, `);else return[];if(n.length===0)return[];let r=[],i=n.length,a=0;for(;a<i&&(a=p(n,a),!(a>=i));){if(n[a]!==`<`){a=m(n,a);continue}let e=n.indexOf(`>`,a+1);if(e===-1)break;let o=n.slice(a+1,e);a=e+1;let s=[];for(;a<i&&(a=p(n,a),!(a>=i));){if(n[a]===`,`){a++;break}if(n[a]!==`;`){a=m(n,a);break}a++,a=p(n,a);let e=a;for(;a<i&&ne(n.charCodeAt(a));)a++;if(a<i&&n[a]===`*`&&a++,e===a){a=m(n,a);break}let t=n.slice(e,a).toLowerCase();a=p(n,a);let r=``;if(a<i&&n[a]===`=`){if(a++,a=p(n,a),a<i&&n[a]===`"`){let e=te(n,a);r=e.value,a=e.end}else{let e=a;for(;a<i&&n[a]!==`;`&&n[a]!==`,`&&!ee(n[a]);)a++;r=n.slice(e,a)}}s.push([t,r])}let c=h(o,s,t);c&&r.push(c)}return r}function p(e,t){for(;t<e.length&&(e[t]===` `||e[t]===` `);)t++;return t}function ee(e){return e===` `||e===` `}function m(e,t){let n=!1;for(;t<e.length;){let r=e[t];if(n){if(r===`\\`&&t+1<e.length){t+=2;continue}r===`"`&&(n=!1)}else if(r===`"`)n=!0;else if(r===`,`)return t+1;t++}return t}function te(e,t){t++;let n=``;for(;t<e.length;){let r=e[t];if(r===`\\`)t++,t<e.length&&(n+=e[t],t++);else if(r===`"`)return{value:n,end:t+1};else n+=r,t++}return{value:n,end:t}}function ne(e){if(e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122)return!0;switch(e){case 33:case 35:case 36:case 37:case 38:case 39:case 42:case 43:case 45:case 46:case 94:case 95:case 96:case 124:case 126:return!0}return!1}function h(e,t,n){let r={},i={};for(let[e,n]of t){if(e.endsWith(`*`)){let t=_(n);t!=null&&(i[e.slice(0,-1)]=t);continue}e===`rel`&&`rel`in r||(r[e]=n)}for(let[e,t]of Object.entries(i))r[e]=t;let a=g(e,n),o=r.anchor==null?void 0:g(r.anchor,n),s={href:a,rel:(r.rel??``).split(/[ \t]+/).filter(e=>e.length>0),params:r};return o!=null&&(s.anchor=o),r.type!=null&&(s.type=r.type),r.title!=null&&(s.title=r.title),r.hreflang!=null&&(s.hreflang=r.hreflang),s}function g(e,t){if(!t)return e;try{return new URL(e,t).toString()}catch{return e}}function _(e){let t=e.indexOf(`'`);if(t===-1)return null;let n=e.indexOf(`'`,t+1);if(n===-1||e.slice(0,t).toLowerCase()!==`utf-8`)return null;try{return decodeURIComponent(e.slice(n+1))}catch{return null}}function v(e){if(!e)return[];let t=[];for(let[n,r]of Object.entries(e))n.toLowerCase()===`link`&&typeof r==`string`&&r.length>0&&t.push(r);return t}function y(e){for(let t of e)if(t.rel.includes(`ai-catalog`))return{kind:`ai-catalog`,url:t.href};return null}function re(e){return[e.origin??``,e.kind??``,e.url??``].join(`\0`)}const ie=`${n}/rel/handoff`,b=`${n}/rel/upskill`;function ae(e){let t=e.replace(/\/+$/,``),n=t.toLowerCase();return n.endsWith(`/skill.md`)?t.slice(0,-9):n===`skill.md`?``:t}const oe=/^[A-Za-z0-9._/-]+$/,x=/^[A-Za-z0-9._/-]+$/;function S(e){return!(e.length===0||e.length>250||!oe.test(e)||e.startsWith(`-`)||e.startsWith(`/`)||e.endsWith(`/`)||e.includes(`..`)||e.endsWith(`.lock`))}function C(e){return!(e.length===0||e.length>1024||!x.test(e)||e.startsWith(`-`)||e.startsWith(`/`)||e.includes(`..`))}function se(e,t){let n=t.branch;typeof n==`string`&&S(n)&&(e.branch=n);let r=t.path;if(typeof r==`string`&&r.length>0){let t=ae(r);t.length>0&&C(t)&&(e.path=t)}}function w(e){for(let t of e){if(t.rel.includes(ie)){let e={verb:`handoff`,target:t.href};return t.title!=null&&t.title.length>0&&(e.instruction=t.title),e}if(t.rel.includes(b)){let e={verb:`upskill`,target:t.href};return t.title!=null&&t.title.length>0&&(e.instruction=t.title),se(e,t.params),e}}return null}function T(e){return[e.verb,e.target,e.branch??``,e.path??``,e.instruction??``].join(`\0`)}function ce(e,t){let n=v(e);if(n.length===0)return{match:null,links:[]};let r=f(n,t);return{match:w(r),links:r}}function E(e){return Date.UTC(e.y,e.m-1,e.d,e.h,e.i,e.s)}function D(e,t){return e.y===t.y&&e.m===t.m&&e.d===t.d&&e.h===t.h&&e.i===t.i&&e.s===t.s}function O(e,t){let n=new Date(Date.parse(e));if(isNaN(n))throw Error(`Invalid ISO8601 passed to timezone parser.`);let r=e.substring(9);return r.includes(`Z`)||r.includes(`+`)||r.includes(`-`)?M(n.getUTCFullYear(),n.getUTCMonth()+1,n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),`Etc/UTC`):M(n.getFullYear(),n.getMonth()+1,n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),t)}function k(e,t,n){return A(O(e,t),n)}function A(e,t){let n=new Date(E(e)),r=j(n,e.tz),i=E(e)-E(r),a=new Date(n.getTime()+i),o=j(a,e.tz);if(D(o,e)){let t=new Date(a.getTime()-36e5);return D(j(t,e.tz),e)?t:a}let s=new Date(a.getTime()+E(e)-E(o));if(D(j(s,e.tz),e))return s;if(t)throw Error(`Invalid date passed to fromTZ()`);return a.getTime()>s.getTime()?a:s}function j(e,t){let n,r;try{n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`,hour12:!1}),r=n.formatToParts(e)}catch(e){let n=e instanceof Error?e.message:String(e);throw RangeError(`toTZ: Invalid timezone '${t}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${n}`)}let i={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let e of r)(e.type===`year`||e.type===`month`||e.type===`day`||e.type===`hour`||e.type===`minute`||e.type===`second`)&&(i[e.type]=parseInt(e.value,10));if(isNaN(i.year)||isNaN(i.month)||isNaN(i.day)||isNaN(i.hour)||isNaN(i.minute)||isNaN(i.second))throw Error(`toTZ: Failed to parse all date components from timezone '${t}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(i)}`);return i.hour===24&&(i.hour=0),{y:i.year,m:i.month,d:i.day,h:i.hour,i:i.minute,s:i.second,tz:t}}function M(e,t,n,r,i,a,o){return{y:e,m:t,d:n,h:r,i,s:a,tz:o}}var N=[1,2,4,8,16],P=class{pattern;timezone;mode;alternativeWeekdays;sloppyRanges;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;lastWeekday;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(e,t,n){this.pattern=e,this.timezone=t,this.mode=n?.mode??`auto`,this.alternativeWeekdays=n?.alternativeWeekdays??!1,this.sloppyRanges=n?.sloppyRanges??!1,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.lastWeekday=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!(typeof this.pattern==`string`||this.pattern instanceof String))throw TypeError(`CronPattern: Pattern has to be of type string.`);this.pattern.indexOf(`@`)>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.match(/\S+/g)||[``],t=e.length;if(e.length<5||e.length>7)throw TypeError(`CronPattern: invalid configuration format ('`+this.pattern+`'), exactly five, six, or seven space separated parts are required.`);if(this.mode!==`auto`){let e;switch(this.mode){case`5-part`:e=5;break;case`6-part`:e=6;break;case`7-part`:e=7;break;case`5-or-6-parts`:e=[5,6];break;case`6-or-7-parts`:e=[6,7];break;default:e=0}if(!(Array.isArray(e)?e.includes(t):t===e)){let n=Array.isArray(e)?e.join(` or `):e.toString();throw TypeError(`CronPattern: mode '${this.mode}' requires exactly ${n} parts, but pattern '${this.pattern}' has ${t} parts.`)}}if(e.length===5&&e.unshift(`0`),e.length===6&&e.push(`*`),e[3].toUpperCase()===`LW`?(this.lastWeekday=!0,e[3]=``):e[3].toUpperCase().indexOf(`L`)>=0&&(e[3]=e[3].replace(/L/gi,``),this.lastDayOfMonth=!0),e[3]==`*`&&(this.starDOM=!0),e[6]==`*`&&(this.starYear=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.alternativeWeekdays?this.replaceAlphaDaysQuartz(e[5]):this.replaceAlphaDays(e[5])),e[5].startsWith(`+`)&&(this.useAndLogic=!0,e[5]=e[5].substring(1),e[5]===``))throw TypeError(`CronPattern: Day-of-week field cannot be empty after '+' modifier.`);switch(e[5]==`*`&&(this.starDOW=!0),this.pattern.indexOf(`?`)>=0&&(e[0]=e[0].replace(/\?/g,`*`),e[1]=e[1].replace(/\?/g,`*`),e[2]=e[2].replace(/\?/g,`*`),e[3]=e[3].replace(/\?/g,`*`),e[4]=e[4].replace(/\?/g,`*`),e[5]=e[5].replace(/\?/g,`*`),e[6]&&=e[6].replace(/\?/g,`*`)),this.mode){case`5-part`:e[0]=`0`,e[6]=`*`;break;case`6-part`:e[6]=`*`;break;case`5-or-6-parts`:e[6]=`*`}this.throwAtIllegalCharacters(e),this.partToArray(`second`,e[0],0,1),this.partToArray(`minute`,e[1],0,1),this.partToArray(`hour`,e[2],0,1),this.partToArray(`day`,e[3],-1,1),this.partToArray(`month`,e[4],-1,1);let n=this.alternativeWeekdays?-1:0;this.partToArray(`dayOfWeek`,e[5],n,63),this.partToArray(`year`,e[6],0,1),!this.alternativeWeekdays&&this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,n,r){let i=this[e],a=e===`day`&&this.lastDayOfMonth,o=e===`day`&&this.lastWeekday;if(t===``&&!a&&!o)throw TypeError(`CronPattern: configuration entry `+e+` (`+t+`) is empty, check for trailing spaces.`);if(t===`*`)return i.fill(r);let s=t.split(`,`);if(s.length>1)for(let t=0;t<s.length;t++)this.partToArray(e,s[t],n,r);else t.indexOf(`-`)!==-1&&t.indexOf(`/`)!==-1?this.handleRangeWithStepping(t,e,n,r):t.indexOf(`-`)===-1?t.indexOf(`/`)===-1?t!==``&&this.handleNumber(t,e,n,r):this.handleStepping(t,e,n,r):this.handleRange(t,e,n,r)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===3?/[^/*0-9,\-WwLl]+/:t===5?/[^/*0-9,\-#Ll]+/:/[^/*0-9,\-]+/).test(e[t]))throw TypeError(`CronPattern: configuration entry `+t+` (`+e[t]+`) contains illegal characters.`)}handleNumber(e,t,n,r){let i=this.extractNth(e,t),a=e.toUpperCase().includes(`W`);if(t!==`day`&&a)throw TypeError(`CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.`);a&&(t=`nearestWeekdays`);let o=parseInt(i[0],10)+n;if(isNaN(o))throw TypeError(`CronPattern: `+t+` is not a number: '`+e+`'`);this.setPart(t,o,i[1]||r)}setPart(e,t,n){if(!Object.prototype.hasOwnProperty.call(this,e))throw TypeError(`CronPattern: Invalid part specified: `+e);if(e===`dayOfWeek`){if(t===7&&(t=0),t<0||t>6)throw RangeError(`CronPattern: Invalid value for dayOfWeek: `+t);this.setNthWeekdayOfMonth(t,n);return}if(e===`second`||e===`minute`){if(t<0||t>=60)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`hour`){if(t<0||t>=24)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`day`||e===`nearestWeekdays`){if(t<0||t>=31)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`month`){if(t<0||t>=12)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`year`&&(t<1||t>=1e4))throw RangeError(`CronPattern: Invalid value for `+e+`: `+t+` (supported range: 1-9999)`);this[e][t]=n}validateNotNaN(e,t){if(isNaN(e))throw TypeError(t)}validateRange(e,t,n,r,i){if(e>t)throw TypeError(`CronPattern: From value is larger than to value: '`+i+`'`);if(n!==void 0){if(n===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(n>this[r].length)throw TypeError(`CronPattern: Syntax error, steps cannot be greater than maximum value of part (`+this[r].length+`)`)}}handleRangeWithStepping(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in ranges with stepping.`);let i=this.extractNth(e,t),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw TypeError(`CronPattern: Syntax error, illegal range with stepping: '`+e+`'`);let[,o,s,c]=a,l=parseInt(o,10)+n,u=parseInt(s,10)+n,d=parseInt(c,10);this.validateNotNaN(l,`CronPattern: Syntax error, illegal lower range (NaN)`),this.validateNotNaN(u,`CronPattern: Syntax error, illegal upper range (NaN)`),this.validateNotNaN(d,`CronPattern: Syntax error, illegal stepping: (NaN)`),this.validateRange(l,u,d,t,e);for(let e=l;e<=u;e+=d)this.setPart(t,e,i[1]||r)}extractNth(e,t){let n=e,r;if(n.includes(`#`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: nth (#) only allowed in day-of-week field`);r=n.split(`#`)[1],n=n.split(`#`)[0]}else if(n.toUpperCase().endsWith(`L`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)`);r=`L`,n=n.slice(0,-1)}return[n,r]}handleRange(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in a range.`);let i=this.extractNth(e,t),a=i[0].split(`-`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal range: '`+e+`'`);let o=parseInt(a[0],10)+n,s=parseInt(a[1],10)+n;this.validateNotNaN(o,`CronPattern: Syntax error, illegal lower range (NaN)`),this.validateNotNaN(s,`CronPattern: Syntax error, illegal upper range (NaN)`),this.validateRange(o,s,void 0,t,e);for(let e=o;e<=s;e++)this.setPart(t,e,i[1]||r)}handleStepping(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in parts with stepping.`);let i=this.extractNth(e,t),a=i[0].split(`/`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal stepping: '`+e+`'`);if(this.sloppyRanges)a[0]===``&&(a[0]=`*`);else{if(a[0]===``)throw TypeError(`CronPattern: Syntax error, stepping with missing prefix ('`+e+`') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.`);if(a[0]!==`*`)throw TypeError(`CronPattern: Syntax error, stepping with numeric prefix ('`+e+`') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.`)}let o=0;a[0]!==`*`&&(o=parseInt(a[0],10)+n);let s=parseInt(a[1],10);this.validateNotNaN(s,`CronPattern: Syntax error, illegal stepping: (NaN)`),this.validateRange(0,this[t].length-1,s,t,e);for(let e=o;e<this[t].length;e+=s)this.setPart(t,e,i[1]||r)}replaceAlphaDays(e){return e.replace(/-sun/gi,`-7`).replace(/sun/gi,`0`).replace(/mon/gi,`1`).replace(/tue/gi,`2`).replace(/wed/gi,`3`).replace(/thu/gi,`4`).replace(/fri/gi,`5`).replace(/sat/gi,`6`)}replaceAlphaDaysQuartz(e){return e.replace(/sun/gi,`1`).replace(/mon/gi,`2`).replace(/tue/gi,`3`).replace(/wed/gi,`4`).replace(/thu/gi,`5`).replace(/fri/gi,`6`).replace(/sat/gi,`7`)}replaceAlphaMonths(e){return e.replace(/jan/gi,`1`).replace(/feb/gi,`2`).replace(/mar/gi,`3`).replace(/apr/gi,`4`).replace(/may/gi,`5`).replace(/jun/gi,`6`).replace(/jul/gi,`7`).replace(/aug/gi,`8`).replace(/sep/gi,`9`).replace(/oct/gi,`10`).replace(/nov/gi,`11`).replace(/dec/gi,`12`)}handleNicknames(e){let t=e.trim().toLowerCase();if(t===`@yearly`||t===`@annually`)return`0 0 1 1 *`;if(t===`@monthly`)return`0 0 1 * *`;if(t===`@weekly`)return`0 0 * * 0`;if(t===`@daily`||t===`@midnight`)return`0 0 * * *`;if(t===`@hourly`)return`0 * * * *`;if(t===`@reboot`)throw TypeError(`CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.`);return e}setNthWeekdayOfMonth(e,t){if(typeof t!=`number`&&t.toUpperCase()===`L`)this.dayOfWeek[e]=this.dayOfWeek[e]|32;else if(t===63)this.dayOfWeek[e]=63;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|N[t-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}},F=[31,28,31,30,31,30,31,31,30,31,30,31],I=[[`month`,`year`,0],[`day`,`month`,-1],[`hour`,`day`,0],[`minute`,`hour`,0],[`second`,`minute`,0]],L=class e{tz;ms;second;minute;hour;day;month;year;constructor(t,n){if(this.tz=n,t&&t instanceof Date){if(!isNaN(t))this.fromDate(t);else throw TypeError(`CronDate: Invalid date passed to CronDate constructor`)}else if(t==null)this.fromDate(new Date);else if(t&&typeof t==`string`)this.fromString(t);else if(t instanceof e)this.fromCronDate(t);else throw TypeError(`CronDate: Invalid type (`+typeof t+`) passed to CronDate constructor`)}getLastDayOfMonth(e,t){return t===1?new Date(Date.UTC(e,t+1,0)).getUTCDate():F[t]}getLastWeekday(e,t){let n=this.getLastDayOfMonth(e,t),r=new Date(Date.UTC(e,t,n)).getUTCDay();return r===0?n-2:r===6?n-1:n}getNearestWeekday(e,t,n){let r=this.getLastDayOfMonth(e,t);if(n>r)return-1;let i=new Date(Date.UTC(e,t,n)).getUTCDay();return i===0?n===r?n-2:n+1:i===6?n===1?n+2:n-1:n}isNthWeekdayOfMonth(e,t,n,r){let i=new Date(Date.UTC(e,t,n)).getUTCDay(),a=0;for(let r=1;r<=n;r++)new Date(Date.UTC(e,t,r)).getUTCDay()===i&&a++;if(r&63&&N[a-1]&r)return!0;if(r&32){let r=this.getLastDayOfMonth(e,t);for(let a=n+1;a<=r;a++)if(new Date(Date.UTC(e,t,a)).getUTCDay()===i)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0){if(typeof this.tz==`number`)this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else try{let t=j(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${t}`)}}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.month<0||this.day>F[this.month]||this.day<1||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}return!1}fromString(e){if(typeof this.tz==`number`){let t=k(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(k(e,this.tz))}findNext(e,t,n,r){return this._findMatch(e,t,n,r,1)}_findMatch(e,t,n,r,i){let a=this[t],o;n.lastDayOfMonth&&(o=this.getLastDayOfMonth(this.year,this.month));let s=!n.starDOW&&t==`day`?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0,c=this[t]+r,l=i===1?e=>e<n[t].length:e=>e>=0;for(let u=c;l(u);u+=i){let i=n[t][u];if(t===`day`&&!i){for(let e=0;e<n.nearestWeekdays.length;e++)if(n.nearestWeekdays[e]){let t=this.getNearestWeekday(this.year,this.month,e-r);if(t===-1)continue;if(t===u-r){i=1;break}}}if(t===`day`&&n.lastWeekday){let e=this.getLastWeekday(this.year,this.month);u-r===e&&(i=1)}if(t===`day`&&n.lastDayOfMonth&&u-r==o&&(i=1),t===`day`&&!n.starDOW){let t=n.dayOfWeek[(s+(u-r-1))%7];if(t&&t&63)t=+!!this.isNthWeekdayOfMonth(this.year,this.month,u-r,t);else if(t)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${t}`);n.useAndLogic?i&&=t:!e.domAndDow&&!n.starDOM?i||=t:i&&=t}if(i)return this[t]=u-r,a===this[t]?1:2}return 3}recurse(e,t,n){if(n===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let t=-1;for(let n=this.year+1;n<e.year.length&&n<1e4;n++)if(e.year[n]===1){t=n;break}if(t===-1)return null;this.year=t,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let r=this.findNext(t,I[n][0],e,I[n][2]);if(r>1){let i=n+1;for(;i<I.length;)this[I[i][0]]=-I[i][2],i++;if(r===3){if(this[I[n][1]]++,this[I[n][0]]=-I[n][2],this.apply(),n===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=e.year.length)return null}return this.recurse(e,t,0)}if(this.apply())return this.recurse(e,t,n-1)}return n+=1,n>=I.length?this:(e.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(e,t,n)}increment(e,t,n){return this.second+=t.interval!==void 0&&t.interval>1&&n?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}decrement(e,t){return this.second-=t.interval!==void 0&&t.interval>1?t.interval:1,this.ms=0,this.apply(),this.recurseBackward(e,t,0,0)}recurseBackward(e,t,n,r=0){if(r>1e4)return null;if(n===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let t=-1;for(let n=this.year-1;n>=0;n--)if(e.year[n]===1){t=n;break}if(t===-1)return null;this.year=t,this.month=11,this.day=31,this.hour=23,this.minute=59,this.second=59,this.ms=0}if(this.year<0)return null}let i=this.findPrevious(t,I[n][0],e,I[n][2]);if(i>1){let a=n+1;for(;a<I.length;){let t=I[a][0],n=I[a][2],r=this.getMaxPatternValue(t,e,n);this[t]=r,a++}if(i===3){if(this[I[n][1]]--,n===0){let e=this.getLastDayOfMonth(this.year,this.month);this.day>e&&(this.day=e)}if(n===1){if(this.day<=0)this.day=1;else{let e=this.year,t=this.month;for(;t<0;)t+=12,e--;for(;t>11;)t-=12,e++;let n=t===1?new Date(Date.UTC(e,t+1,0)).getUTCDate():F[t];this.day>n&&(this.day=n)}}this.apply();let i=I[n][0],a=I[n][2],o=this.getMaxPatternValue(i,e,a);if(i===`day`){let e=this.getLastDayOfMonth(this.year,this.month);this[i]=Math.min(o,e)}else this[i]=o;if(this.apply(),n===0){let t=I[1][2],n=this.getMaxPatternValue(`day`,e,t),r=this.getLastDayOfMonth(this.year,this.month),i=Math.min(n,r);i!==this.day&&(this.day=i,this.hour=this.getMaxPatternValue(`hour`,e,I[2][2]),this.minute=this.getMaxPatternValue(`minute`,e,I[3][2]),this.second=this.getMaxPatternValue(`second`,e,I[4][2]))}if(n===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0;)this.year--;if(this.year<0)return null}return this.recurseBackward(e,t,0,r+1)}if(this.apply())return this.recurseBackward(e,t,n-1,r+1)}return n+=1,n>=I.length?this:this.year<0?null:this.recurseBackward(e,t,n,r+1)}getMaxPatternValue(e,t,n){if(e===`day`&&t.lastDayOfMonth||e===`day`&&!t.starDOW)return this.getLastDayOfMonth(this.year,this.month);for(let r=t[e].length-1;r>=0;r--)if(t[e][r])return r-n;return t[e].length-1-n}findPrevious(e,t,n,r){return this._findMatch(e,t,n,r,-1)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz==`number`?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):A(M(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}match(e,t){if(!e.starYear&&(this.year<0||this.year>=e.year.length||e.year[this.year]===0))return!1;for(let n=0;n<I.length;n++){let r=I[n][0],i=I[n][2],a=this[r];if(a+i<0||a+i>=e[r].length)return!1;let o=e[r][a+i];if(r===`day`){if(!o){for(let t=0;t<e.nearestWeekdays.length;t++)if(e.nearestWeekdays[t]){let e=this.getNearestWeekday(this.year,this.month,t-i);if(e!==-1&&e===a){o=1;break}}}if(e.lastWeekday&&a===this.getLastWeekday(this.year,this.month)&&(o=1),e.lastDayOfMonth&&a===this.getLastDayOfMonth(this.year,this.month)&&(o=1),!e.starDOW){let n=new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),r=e.dayOfWeek[(n+(a-1))%7];r&&r&63&&(r=+!!this.isNthWeekdayOfMonth(this.year,this.month,a,r)),e.useAndLogic?o&&=r:!t.domAndDow&&!e.starDOM?o||=r:o&&=r}}if(!o)return!1}return!0}};function R(e){if(e===void 0&&(e={}),delete e.name,e.legacyMode!==void 0&&e.domAndDow===void 0?e.domAndDow=!e.legacyMode:e.domAndDow===void 0&&(e.domAndDow=!1),e.legacyMode=!e.domAndDow,e.paused=e.paused!==void 0&&e.paused,e.maxRuns=e.maxRuns===void 0?1/0:e.maxRuns,e.catch=e.catch!==void 0&&e.catch,e.interval=e.interval===void 0?0:parseInt(e.interval.toString(),10),e.utcOffset=e.utcOffset===void 0?void 0:parseInt(e.utcOffset.toString(),10),e.dayOffset=e.dayOffset===void 0?0:parseInt(e.dayOffset.toString(),10),e.unref=e.unref!==void 0&&e.unref,e.mode=e.mode===void 0?`auto`:e.mode,e.alternativeWeekdays=e.alternativeWeekdays!==void 0&&e.alternativeWeekdays,e.sloppyRanges=e.sloppyRanges!==void 0&&e.sloppyRanges,![`auto`,`5-part`,`6-part`,`7-part`,`5-or-6-parts`,`6-or-7-parts`].includes(e.mode))throw Error(`CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.`);if(e.startAt&&(e.startAt=new L(e.startAt,e.timezone)),e.stopAt&&(e.stopAt=new L(e.stopAt,e.timezone)),e.interval!==null){if(isNaN(e.interval))throw Error(`CronOptions: Supplied value for interval is not a number`);if(e.interval<0)throw Error(`CronOptions: Supplied value for interval can not be negative`)}if(e.utcOffset!==void 0){if(isNaN(e.utcOffset))throw Error(`CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.`);if(e.utcOffset<-870||e.utcOffset>870)throw Error(`CronOptions: utcOffset out of bounds.`);if(e.utcOffset!==void 0&&e.timezone)throw Error(`CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.`)}if(e.unref!==!0&&e.unref!==!1)throw Error(`CronOptions: Unref should be either true, false or undefined(false).`);if(e.dayOffset!==void 0&&e.dayOffset!==0&&isNaN(e.dayOffset))throw Error(`CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.`);return e}function z(e){return Object.prototype.toString.call(e)===`[object Function]`||typeof e==`function`||e instanceof Function}function B(e){return z(e)}function V(e){typeof Deno<`u`&&typeof Deno.unrefTimer<`u`?Deno.unrefTimer(e):e&&typeof e.unref<`u`&&e.unref()}var H=3e4,U=[],W=class{name;options;_states;fn;getTz(){return this.options.timezone||this.options.utcOffset}applyDayOffset(e){if(this.options.dayOffset!==void 0&&this.options.dayOffset!==0){let t=this.options.dayOffset*24*60*60*1e3;return new Date(e.getTime()+t)}return e}constructor(e,t,n){let r,i;if(z(t))i=t;else if(typeof t==`object`)r=t;else if(t!==void 0)throw Error(`Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).`);if(z(n))i=n;else if(typeof n==`object`)r=n;else if(n!==void 0)throw Error(`Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).`);if(this.name=r?.name,this.options=R(r),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:r?r.maxRuns:void 0,paused:r?r.paused:!1,pattern:new P(`* * * * *`,void 0,{mode:`auto`})},e&&(e instanceof Date||typeof e==`string`&&e.indexOf(`:`)>0)?this._states.once=new L(e,this.getTz()):this._states.pattern=new P(e,this.options.timezone,{mode:this.options.mode,alternativeWeekdays:this.options.alternativeWeekdays,sloppyRanges:this.options.sloppyRanges}),this.name){if(U.find(e=>e.name===this.name))throw Error(`Cron: Tried to initialize new named job '`+this.name+`', but name already taken.`);U.push(this)}return i!==void 0&&B(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let t=this._next(e);return t?this.applyDayOffset(t.getDate(!1)):null}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let n=t||this._states.currentRun||void 0;return this._enumerateRuns(e,n,`next`)}previousRuns(e,t){return this._enumerateRuns(e,t||void 0,`previous`)}_enumerateRuns(e,t,n){let r=[],i=t?new L(t,this.getTz()):null,a=n===`next`?this._next:this._previous;for(;e--;){let e=a.call(this,i);if(!e)break;let t=e.getDate(!1);r.push(this.applyDayOffset(t)),i=e}return r}match(e){if(this._states.once){let t=new L(e,this.getTz());t.ms=0;let n=new L(this._states.once,this.getTz());return n.ms=0,t.getTime()===n.getTime()}let t=new L(e,this.getTz());return t.ms=0,t.match(this._states.pattern,this.options)}getPattern(){if(!this._states.once)return this._states.pattern?this._states.pattern.pattern:void 0}getOnce(){return this._states.once?this._states.once.getDate():null}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,n=this.fn!==void 0,r=!this._states.kill;return t&&n&&r&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof L||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new L(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=U.indexOf(this);e>=0&&U.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw Error(`Cron: It is not allowed to schedule two functions using the same Croner instance.`);e&&(this.fn=e);let t=this.msToNext(),n=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||n===null?this:(t>H&&(t=H),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(n),t),this._states.currentTimeout&&this.options.unref&&V(this._states.currentTimeout),this)}async _trigger(e){this._states.blocking=!0,this._states.currentRun=new L(void 0,this.getTz());try{if(this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(e){if(z(this.options.catch))try{this.options.catch(e,this)}catch{}}else this.fn!==void 0&&await this.fn(this,this.options.context)}finally{this._states.previousRun=new L(e,this.getTz()),this._states.blocking=!1}}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,n=!this._states.paused&&t.getTime()>=e.getTime(),r=this._states.blocking&&this.options.protect;n&&!r?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):n&&r&&z(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),n=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),n=!e),e=new L(e,this.getTz()),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let r=this._states.once||new L(e,this.getTz());return!n&&r!==this._states.once&&(r=r.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||r===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&r.getTime()>=this.options.stopAt.getTime()?null:r}_previous(e){let t=new L(e,this.getTz());this.options.stopAt&&t.getTime()>this.options.stopAt.getTime()&&(t=this.options.stopAt);let n=new L(t,this.getTz());return this._states.once?this._states.once.getTime()<t.getTime()?this._states.once:null:(n=n.decrement(this._states.pattern,this.options),n===null||this.options.startAt&&n.getTime()<this.options.startAt.getTime()?null:n)}_calculatePreviousRun(e,t){let n=new L(void 0,this.getTz()),r=e;if(this.options.startAt.getTime()<=n.getTime()){r=this.options.startAt;let e=r.getTime()+this.options.interval*1e3;for(;e<=n.getTime();)r=new L(r,this.getTz()).increment(this._states.pattern,this.options,!0),e=r.getTime()+this.options.interval*1e3;t=!0}return r===null&&(r=void 0),[r,t]}};function G(e,t){try{return new W(e.trim(),{domAndDow:!0}).nextRun(t)??null}catch{return null}}var K=e({FORWARDABLE_TO_LEADER:()=>J,LickManager:()=>Y,buildActiveLicksError:()=>Q,getLickManager:()=>de,lickScoopMatches:()=>X,lickTargetCandidates:()=>Z});const q=t(`lick-manager`),J=new Set([`navigate`,`discovery`]);function le(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.verb!=`string`||typeof t.target!=`string`?null:T({verb:t.verb,target:t.target,branch:typeof t.branch==`string`?t.branch:void 0,path:typeof t.path==`string`?t.path:void 0,instruction:typeof t.instruction==`string`?t.instruction:void 0})}function ue(e){return!e.discoveryKind&&!e.discoveryUrl&&!e.discoveryOrigin?null:re({origin:e.discoveryOrigin,kind:e.discoveryKind,url:e.discoveryUrl})}var Y=class{webhooks=new Map;crontasks=new Map;cronInterval=null;eventHandler=null;forwarder=null;seenNavigateFingerprints=new Set;seenDiscoveryFingerprints=new Set;unitRoster=null;discoveryIgnore=null;async init(){await d();let e=await a();for(let t of e)this.webhooks.set(t.id,t);q.info(`Loaded webhooks`,{count:this.webhooks.size});let t=await s();for(let e of t)this.crontasks.set(e.id,e);q.info(`Loaded crontasks`,{count:this.crontasks.size}),await this.reconcileOrphans(),this.cronInterval=setInterval(()=>this.runCronScheduler(),6e4),q.info(`Cron scheduler started`)}setUnitRosterProvider(e){this.unitRoster=e}resolveLickTarget(e){let t=this.unitRoster?.();return t?t.some(t=>X(e,t.name,t.folder))?{status:`resolved`}:{status:`unresolved`,candidates:Z(t)}:{status:`unverifiable`}}setDiscoveryIgnore(e){this.discoveryIgnore=e}isOrphanedLick(e){return e?this.resolveLickTarget(e).status===`unresolved`:!1}async reconcileOrphans(){if(this.unitRoster){for(let e of Array.from(this.webhooks.values()))if(this.isOrphanedLick(e.scoop)){q.warn(`Removing orphaned webhook at init; target scoop no longer exists`,{id:e.id,name:e.name,scoop:e.scoop}),this.webhooks.delete(e.id);try{await i(e.id)}catch(t){q.warn(`Failed to delete orphaned webhook from DB`,{id:e.id,error:t instanceof Error?t.message:String(t)})}}for(let e of Array.from(this.crontasks.values()))if(this.isOrphanedLick(e.scoop)){q.warn(`Removing orphaned cron task at init; target scoop no longer exists`,{id:e.id,name:e.name,scoop:e.scoop}),this.crontasks.delete(e.id);try{await o(e.id)}catch(t){q.warn(`Failed to delete orphaned cron task from DB`,{id:e.id,error:t instanceof Error?t.message:String(t)})}}}}dispose(){this.cronInterval&&=(clearInterval(this.cronInterval),null)}setEventHandler(e){this.eventHandler=e}setForwarder(e){this.forwarder=e}dispatch(e){if(!(e.type===`discovery`&&this.shouldSuppressDiscovery(e))){if(this.forwarder&&J.has(e.type)){this.forwarder(e);return}this.eventHandler?.(e)}}handleForwardedEvent(e){e.type===`discovery`&&this.shouldSuppressDiscovery(e)||this.isDuplicateFingerprint(e)||this.eventHandler?.(e)}emitEvent(e){e.type===`discovery`&&this.shouldSuppressDiscovery(e)||this.isDuplicateFingerprint(e)||(q.info(`External lick event`,{type:e.type,target:e.targetScoop}),this.dispatch(e))}isDuplicateFingerprint(e){let t=null,n,r;if(e.type===`navigate`)t=le(e.body),n=this.seenNavigateFingerprints,r=`navigate`;else if(e.type===`discovery`)t=ue(e),n=this.seenDiscoveryFingerprints,r=`discovery`;else return!1;return t===null?!1:n.has(t)?(q.debug(`Suppressing duplicate ${r} lick`,{fingerprint:t}),!0):(n.add(t),!1)}shouldSuppressDiscovery(e){return e.discoverySource===`live-navigation`?this.discoveryIgnore?.(e)?(q.debug(`Suppressing ignored llms.txt discovery`,{origin:e.discoveryOrigin}),!0):!1:(q.debug(`Suppressing discovery without live-navigation provenance`),!0)}async createWebhook(e,t,n){let i=this.generateId(),a={id:i,name:e,createdAt:new Date().toISOString(),filter:n,scoop:t};return n&&this.compileFilter(n,!0),this.webhooks.set(i,a),await r(a),q.info(`Webhook created`,{id:i,name:e,scoop:t}),a}async deleteWebhook(e){return this.webhooks.has(e)?(this.webhooks.delete(e),await i(e),q.info(`Webhook deleted`,{id:e}),!0):await l(e)!==null&&(await i(e),q.info(`Webhook deleted`,{id:e}),!0)}listWebhooks(){return Array.from(this.webhooks.values())}getWebhook(e){return this.webhooks.get(e)}handleWebhookEvent(e,t,n){let r=this.webhooks.get(e);if(!r)return q.warn(`Webhook not found`,{webhookId:e}),`unknown-webhook`;if(this.isOrphanedLick(r.scoop))return q.warn(`Webhook target scoop not found — dropping delivery`,{webhookId:e,name:r.name,scoop:r.scoop}),`unresolved-target`;let i={type:`webhook`,webhookId:e,webhookName:r.name,targetScoop:r.scoop,timestamp:new Date().toISOString(),headers:t,body:n};if(r.filter)try{let t=this.compileFilter(r.filter,!0)(i);if(t===!1)return q.debug(`Webhook event dropped by filter`,{webhookId:e,name:r.name}),`filtered`;typeof t==`object`&&t&&(i=t)}catch(t){q.error(`Webhook filter error`,{webhookId:e,error:t instanceof Error?t.message:String(t)})}return q.info(`Webhook event received`,{webhookId:e,name:r.name,targetScoop:r.scoop}),this.dispatch(i),`delivered`}async createCronTask(e,t,n,r){let i=G(t,new Date);if(!i)throw Error(`Invalid cron expression`);r&&this.compileFilter(r,!1);let a=this.generateId(),o={id:a,name:e,cron:t,scoop:n,filter:r,nextRun:i.toISOString(),lastRun:null,status:`active`,createdAt:new Date().toISOString()};return this.crontasks.set(a,o),await u(o),q.info(`Cron task created`,{id:a,name:e,cron:t,scoop:n}),o}async deleteCronTask(e){return this.crontasks.has(e)?(this.crontasks.delete(e),await o(e),q.info(`Cron task deleted`,{id:e}),!0):await c(e)!==null&&(await o(e),q.info(`Cron task deleted`,{id:e}),!0)}listCronTasks(){return Array.from(this.crontasks.values())}getCronTask(e){return this.crontasks.get(e)}getLicksForScoop(e,t){return{webhooks:Array.from(this.webhooks.values()).filter(n=>X(n.scoop,e,t)),cronTasks:Array.from(this.crontasks.values()).filter(n=>X(n.scoop,e,t))}}async getLicksForScoopFromDb(e,t){let[n,r]=await Promise.all([a(),s()]);return{webhooks:n.filter(n=>X(n.scoop,e,t)),cronTasks:r.filter(n=>X(n.scoop,e,t))}}async deleteIfOrphanedCron(e){if(!this.isOrphanedLick(e.scoop))return!1;q.warn(`Deleting orphaned cron task; target scoop no longer exists`,{id:e.id,name:e.name,scoop:e.scoop}),this.crontasks.delete(e.id);try{await o(e.id)}catch(t){q.warn(`Failed to delete orphaned cron task from DB`,{id:e.id,error:t instanceof Error?t.message:String(t)})}return!0}async runCronScheduler(){let e=new Date;for(let t of this.crontasks.values())await this.deleteIfOrphanedCron(t)||t.status===`active`&&t.nextRun&&(new Date(t.nextRun)>e||await this.runDueCronTask(t,e))}async runDueCronTask(e,t){let n={time:t.toISOString()};if(e.filter)try{let r=this.compileFilter(e.filter,!1)(null);if(r===!1){q.debug(`Cron task skipped by filter`,{id:e.id,name:e.name}),e.nextRun=G(e.cron,t)?.toISOString()??null,e.lastRun=t.toISOString(),await u(e);return}typeof r==`object`&&r&&(n=r)}catch(t){q.error(`Cron filter error`,{id:e.id,error:t instanceof Error?t.message:String(t)})}let r={type:`cron`,cronId:e.id,cronName:e.name,targetScoop:e.scoop,timestamp:t.toISOString(),body:n};q.info(`Cron task running`,{id:e.id,name:e.name}),this.dispatch(r),e.nextRun=G(e.cron,t)?.toISOString()??null,e.lastRun=t.toISOString(),await u(e)}generateId(){let e=``;for(let t=0;t<12;t++)e+=`abcdefghijklmnopqrstuvwxyz0123456789`[Math.floor(Math.random()*36)];return e}compileFilter(e,t){try{return t?Function(`event`,`return (${e})(event);`):Function(`return (${e})();`)}catch(e){throw Error(`Invalid filter function: ${e instanceof Error?e.message:String(e)}`)}}};function X(e,t,n){return e?e===t||e===n||`${e}-scoop`===n:!1}function Z(e){let t=new Set;for(let n of e)t.add(n.folder),n.name&&n.name!==n.folder&&t.add(n.name);return Array.from(t)}function Q(e,t,n){if(t.length===0&&n.length===0)return null;let r=[];t.length>0&&r.push(`${t.length} active webhook${t.length>1?`s`:``}`),n.length>0&&r.push(`${n.length} active cron task${n.length>1?`s`:``}`);let i=[...t.map(e=>` webhook delete ${e.id}`),...n.map(e=>` crontask delete ${e.id}`)].join(`
2
+ `);return Error(`Cannot remove scoop '${e}': it has ${r.join(` and `)}. Unregister them first:\n${i}`)}let $=null;function de(){return $||=new Y,$}export{w as a,C as c,b as i,y as l,K as n,ce as o,G as r,S as s,Q as t,f as u};
@@ -1 +1 @@
1
- const e=5e3;function t(t,n=[]){let r=`lm-${Date.now()}-${Math.random().toString(36).slice(2)}`,i=new BroadcastChannel(`slicc-lick-manager`);return new Promise((a,o)=>{let s=setTimeout(()=>{i.close(),o(Error(`LickManager '${t}' timed out after ${e}ms — is the offscreen document running and has startLickManagerHost() been called?`))},e);i.onmessage=e=>{let t=e.data;t?.type===`lick-op-response`&&t.id===r&&(clearTimeout(s),i.close(),t.error?o(Error(t.error)):a(t.result))};try{i.postMessage({type:`lick-op`,id:r,op:t,args:n})}catch(e){clearTimeout(s),i.close(),o(Error(`LickManager '${t}' postMessage failed: ${e instanceof Error?e.message:String(e)}`))}})}function n(){return{createCronTask:(e,n,r,i)=>t(`createCronTask`,[e,n,r,i]),deleteCronTask:e=>t(`deleteCronTask`,[e]),createWebhook:(e,n,r)=>t(`createWebhook`,[e,n,r]),deleteWebhook:e=>t(`deleteWebhook`,[e])}}function r(){return t(`listCronTasks`)}function i(){return t(`listWebhooks`)}export{n as createLickManagerProxy,r as listCronTasksAsync,i as listWebhooksAsync};
1
+ const e=5e3;function t(t,n=[]){let r=`lm-${Date.now()}-${Math.random().toString(36).slice(2)}`,i=new BroadcastChannel(`slicc-lick-manager`);return new Promise((a,o)=>{let s=setTimeout(()=>{i.close(),o(Error(`LickManager '${t}' timed out after ${e}ms — is the offscreen document running and has startLickManagerHost() been called?`))},e);i.onmessage=e=>{let t=e.data;t?.type===`lick-op-response`&&t.id===r&&(clearTimeout(s),i.close(),t.error?o(Error(t.error)):a(t.result))};try{i.postMessage({type:`lick-op`,id:r,op:t,args:n})}catch(e){clearTimeout(s),i.close(),o(Error(`LickManager '${t}' postMessage failed: ${e instanceof Error?e.message:String(e)}`))}})}function n(){return{resolveLickTarget:e=>t(`resolveLickTarget`,[e]),createCronTask:(e,n,r,i)=>t(`createCronTask`,[e,n,r,i]),deleteCronTask:e=>t(`deleteCronTask`,[e]),createWebhook:(e,n,r)=>t(`createWebhook`,[e,n,r]),deleteWebhook:e=>t(`deleteWebhook`,[e])}}function r(){return t(`listCronTasks`)}function i(){return t(`listWebhooks`)}export{n as createLickManagerProxy,r as listCronTasksAsync,i as listWebhooksAsync};
@@ -0,0 +1 @@
1
+ import{t as e}from"./logger-LESFN7Hj.js";import"./logger-DQgFbfwx.js";import{a as t,i as n,n as r,r as i,t as a}from"./lick-urls-51I5JBZv.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)return o.error(`Malformed webhook_event from lick-ws`,{receivedKeys:Object.keys(t)}),`malformed`;let r=t.headers&&typeof t.headers==`object`?t.headers:{};try{return e.handleWebhookEvent(n,r,t.body)}catch(e){return o.error(`Webhook event dispatch failed`,{webhookId:n,error:e instanceof Error?e.message:String(e)}),`failed`}}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,r){let{lickManager:i}=e;try{switch(t.type){case`list_webhooks`:return{type:`response`,requestId:r,data:i.listWebhooks().map(t=>({...t,url:h(e,t.id)}))};case`create_webhook`:{let n=await i.createWebhook(t.name||`default`,t.scoop,t.filter);return{type:`response`,requestId:r,data:{...n,url:h(e,n.id)}}}case`webhook_event`:return{type:`response`,requestId:r,data:{disposition:d(i,t)}};case`delete_webhook`:return await i.deleteWebhook(t.id)?{type:`response`,requestId:r,data:{ok:!0}}:{type:`response`,requestId:r,data:{error:`Webhook not found`}};case`list_crontasks`:return{type:`response`,requestId:r,data:i.listCronTasks()};case`create_crontask`:if(!t.name)throw Error(`name is required`);if(!t.cron)throw Error(`cron is required`);return{type:`response`,requestId:r,data:await i.createCronTask(t.name,t.cron,t.scoop,t.filter)};case`delete_crontask`:return await i.deleteCronTask(t.id)?{type:`response`,requestId:r,data:{ok:!0}}:{type:`response`,requestId:r,data:{error:`Cron task not found`}};case`tray_status`:{let e=n();return{type:`response`,requestId:r,data:{state:e.state,joinUrl:e.session?.joinUrl??null,workerBaseUrl:e.session?.workerBaseUrl??null,trayId:e.session?.trayId??null}}}default:return{type:`response`,requestId:r,error:`Unknown request type: ${t.type}`}}}catch(e){return{type:`response`,requestId:r,error:e instanceof Error?e.message:String(e)}}}function h(e,n){let a=t().session;return a?.webhookUrl?r(a.webhookUrl,n):e.webhookOriginOverride?`${e.webhookOriginOverride}/webhooks/${n}`:i(e.options.locationHref,n)}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:a(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 i={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(i),{stop(){g(i)}}}export{_ as startLickWsBridge};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{b as n}from"./account-store-ChIwciCW.js";import{a as r}from"./diagnostics-DN_idNHx.js";import{u as i}from"./claude-model-version-3OcOMAHY.js";import{r as a,s as o}from"./legacy-api-aliases-C19b-Ryn.js";var s=e({config:()=>d,detectRuntime:()=>C,discoverModels:()=>S,originOf:()=>b,register:()=>y,verifyConnection:()=>E});const c=t(`local-llm`),l=`local-llm`,u=`${l}-unconfigured`,d={id:l,name:`Local LLM (OpenAI-compatible)`,description:[`Connect to any OpenAI-compatible local model server.`,``,`Common base URLs:`,` • Ollama http://localhost:11434/v1`,` • LM Studio http://localhost:1234/v1`,` • llama.cpp http://localhost:8080/v1`,` • vLLM http://localhost:8000/v1`,` • mlx_lm http://localhost:8080/v1`,` • Jan http://localhost:1337/v1`,``,`Ollama needs OLLAMA_ORIGINS=* (or chrome-extension://*) so the`,`browser can reach it. macOS: launchctl setenv OLLAMA_ORIGINS "*".`].join(`
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{b as n}from"./account-store-CHgSp6SB.js";import{a as r}from"./diagnostics-DN_idNHx.js";import{u as i}from"./claude-model-version-3OcOMAHY.js";import{r as a,s as o}from"./legacy-api-aliases-C19b-Ryn.js";var s=e({config:()=>d,detectRuntime:()=>C,discoverModels:()=>S,originOf:()=>b,register:()=>y,verifyConnection:()=>E});const c=t(`local-llm`),l=`local-llm`,u=`${l}-unconfigured`,d={id:l,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=f(n(l));return e.length===0?[{id:u,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 f(e){return e?e.split(`,`).map(e=>e.trim()).filter(Boolean):[]}const p=`${l}-openai`;function m(e){return{...e,api:`openai-completions`}}function h(e){let t=e??{};return!t.apiKey||t.apiKey.length===0?{...t,apiKey:`local`}:t}const g=(e,t,n={})=>e.id===u?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?a(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`),_=(e,t,n)=>e.id===u?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?o(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`);function v(e,t){let n=r(),i={role:`assistant`,content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t,timestamp:Date.now()};return queueMicrotask(()=>{n.push({type:`error`,reason:`error`,error:i}),n.end()}),n}function y(){i({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 c.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{s as n,d as t};
@@ -1,2 +1,2 @@
1
- import{b as e}from"./account-store-DG6fHM_V.js";import{a as t}from"./diagnostics-DN_idNHx.js";import{u as n}from"./claude-model-version-C0HLsjny.js";import{r,s as i}from"./legacy-api-aliases-7-tLus57.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(`
1
+ import{b as e}from"./account-store-BaTmqQCH.js";import{a as t}from"./diagnostics-DN_idNHx.js";import{u as n}from"./claude-model-version-C0HLsjny.js";import{r,s as i}from"./legacy-api-aliases-7-tLus57.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 t=d(e(s));return t.length===0?[{id:l,name:`Local LLM (set base URL + model IDs in Settings)`,api:`openai`}]:t.map(e=>({id:e,name:e,api:`openai`,input:[`text`],context_window:32e3,max_tokens:4096}))}};function d(e){return e?e.split(`,`).map(e=>e.trim()).filter(Boolean):[]}var f=`openai-completions`,p=`${s}-openai`;function m(e){return{...e,api:f}}function h(e){let t=e??{};return!t.apiKey||t.apiKey.length===0?{...t,apiKey:c}:t}var g=(e,t,n={})=>e.id===l?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?r(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`),_=(e,t,n)=>e.id===l?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?i(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`);function v(e,n){let r=t(),i={role:`assistant`,content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:n,timestamp:Date.now()};return queueMicrotask(()=>{r.push({type:`error`,reason:`error`,error:i}),r.end()}),r}function y(){n({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/setup-feature-flags-remote-Czi_ny8P.js","assets/feature-flags-ByMXaIc4.js","assets/tray-runtime-config-Bpo7AZhY.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-CFWkfPNA.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/base64-DJRlyqZu.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-GRCyib6X.js","assets/messages-BD4p8GuF.js","assets/sudo-BYKLWL8l.js","assets/logger-DDBAeTLF.js","assets/runtime-env-CgsZ7LTp.js","assets/runtime-env-E-i2SW1s.js","assets/quick-llm-CCC28hMC.js","assets/account-store-DG6fHM_V.js","assets/claude-model-version-C0HLsjny.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-BxrUfzom.js","assets/libesm-BypnjKEL.js","assets/float-topology-BYb7rxY5.js","assets/secret-topology-BE7Eyd3P.js","assets/secrets-bridge-client-CHZomqvU.js","assets/port-bridge-client-Cti-DmEY.js","assets/image-markers-CxJ9ZBgw.js","assets/tool-ui-DfXu6quJ.js","assets/providers-EvW22h9s.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-ZLR7gmJ4.js","assets/page-approval-service-Z5cL8IlA.js","assets/extension-bridge-transport-D3PItLFo.js","assets/pending-request-table-Dgn6qYdL.js","assets/lick-ws-bridge-rxCk9AYw.js","assets/logger-BoSvu4mW.js","assets/tray-leader-B_FxjW0d.js","assets/cdp-BzUC7d2h.js","assets/remote-cdp-transport-DeDqT7I4.js","assets/navigation-watcher-DrWMx-B4.js","assets/handoff-link-BObMRgsx.js","assets/main-cherry-C6fqCnLL.js","assets/synthetic-cdp-transport-Ds83IPjw.js","assets/oauth-service-DJuzPXsg.js","assets/permissions-surface-registry-CilCRwhh.js","assets/wc-shell-hnMI7FOV.js","assets/mime-types-k2E6ulyv.js","assets/telemetry-BVzuNdvW.js","assets/html-B_Hg2WOy.js","assets/speech-C5U8h4In.js","assets/soundscape-cues-5_sT5Un6.js","assets/wc-shell-WkeczD9x.css","assets/wc-follower-BiIsjqEt.js","assets/wc-follower-oauth-CuUqosbc.js","assets/slicc-app-url-BsBryEhn.js","assets/tray-follower-status-BAjnN7Ar.js","assets/record-C0lt6kKE.js","assets/shared-2T6O01rS.js","assets/sprinkle-renderer-C9L5ZRvl.js","assets/theme-CXRqxpw6.js","assets/theme-engine-By4GU_Wc.js","assets/wc-unit-context-oCIU0KAf.js","assets/export-spool-Eul4J1RP.js","assets/src-BWaKqLvQ.js","assets/wc-live-9ZO5QfgI.js","assets/types-idfTVsM8.js","assets/hid-device-registry-B2R-0rNt.js","assets/browser-DGwroBSO.js","assets/serial-port-registry-CCqklAEr.js","assets/usb-operations-BBXJ4GF8.js","assets/usb-device-registry-CRsCisej.js","assets/sprinkle-bridge-D4YmJlZ6.js","assets/wc-sprinkles-_BGRskZQ.js","assets/wc-attach-DfPSrixU.js","assets/wc-float-label-cFzM9BsP.js","assets/wc-floatbar-online-BKJPRq_0.js","assets/wc-permissions-WjSZrbPa.js","assets/oauth-bootstrap-yw-xe8Vv.js","assets/legacy-styles-DcRu2WCJ.js","assets/connect-surface-DT_tKlEJ.js","assets/wc-extension-DhuoWguy.js","assets/wc-detached-B3WCbbZT.js"])))=>i.map(i=>d[i]);
2
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import"./modulepreload-polyfill-P2Xu9kJm.js";import{A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,R as _,S as v,T as y,U as b,V as x,W as S,_ as C,a as w,b as ee,c as te,d as T,f as ne,g as re,h as ie,i as E,j as ae,k as oe,l as se,m as ce,n as le,o as ue,p as de,q as fe,s as pe,t as me,u as he,v as ge,w as _e,x as ve,y as ye,z as be}from"./account-store-DG6fHM_V.js";import{t as D}from"./preload-helper-Czpn1I53.js";import{t as O}from"./logger-DDBAeTLF.js";import{c as xe,l as Se,o as Ce,s as we}from"./src-CAWTvdAa.js";import"./proxied-fetch-CFWkfPNA.js";import{n as k,t as A}from"./runtime-env-Dlaokqg1.js";import{a as Te,o as Ee,s as De}from"./api-endpoint-GRCyib6X.js";import"./runtime-env-CgsZ7LTp.js";import{o as Oe,t as ke}from"./telemetry-BVzuNdvW.js";import{a as Ae}from"./providers-EvW22h9s.js";import"./messages-BD4p8GuF.js";import{n as je}from"./feature-flags-ByMXaIc4.js";import{c as Me,d as Ne,p as Pe,s as Fe,t as Ie,u as Le}from"./tray-runtime-config-Bpo7AZhY.js";import{t as Re}from"./tray-follower-status-BAjnN7Ar.js";import{n as ze}from"./clipboard-eqmn97SP.js";import{n as j}from"./tray-join-url-BIvzbiFR.js";var Be=`role`;function Ve(e){try{let t=new URL(e);return`${t.protocol===`wss:`?`https:`:`http:`}//${t.host}`}catch{return null}}function He(e){try{let t=new URL(e);return`${t.protocol}//${t.host}/licks-ws`}catch{return null}}function Ue(e){let t;try{t=new URLSearchParams(e)}catch{return null}let n=t.get(xe),r=t.get(we);if(!n||!r||!/^wss?:\/\//.test(n))return null;let i=t.get(Be),a=i===`leader`||i===`follower`?i:null;return{url:n,subprotocol:`${Ce}${r}`,token:r,apiBaseUrl:Ve(n),lickWsUrl:He(n),role:a}}var We=`slicc:bridge-config`,Ge=`slicc:extension-delegate-config`;function Ke(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 qe=O(`boot/ext-fetch-delegate`);function Je(){let e=globalThis.chrome?.runtime;return e&&typeof e.connect==`function`?e:null}function Ye(e,t,n){let r=Je();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 Xe(e){typeof navigator>`u`||!navigator.serviceWorker||navigator.serviceWorker.addEventListener(`message`,t=>{if(!Ke(t.data))return;let n=t.ports?.[0];if(!n){qe.warn(`delegated fetch envelope arrived without a response port`);return}Ye(t.data,n,e)})}var Ze=`slicc_feature_flags_remote`;function Qe(e){return`${Ze}:${e}`}function $e(e,t){let n=tt(t);je(e,nt(n,e)??{})}function et(e,t,n){try{e?.setItem(Qe(t),JSON.stringify(n))}catch{}}function tt(e){if(e!==void 0)return e;try{let e=globalThis.localStorage;return typeof e?.getItem!=`function`||typeof e.setItem!=`function`?void 0:e}catch{return}}function nt(e,t){try{let n=e?.getItem(Qe(t));return n?rt(JSON.parse(n)):null}catch{return null}}function rt(e){return!it(e)||Object.values(e).some(e=>typeof e!=`string`)?null:e}function it(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function at(e,t,n){if(t){try{if(new URL(e).searchParams.has(`detached`))return`extension-detached`}catch{}return`extension`}try{let t=new URL(e);if(t.searchParams.get(`connect`)===`1`)return`connect`;if(t.searchParams.get(`runtime`)===`hosted-leader`)return`hosted-leader`;if(t.searchParams.get(`cherry`)===`1`)return`cherry`;let r=n===void 0?typeof window<`u`?window.localStorage:null:n;return Le(e,r)?`follower`:st(t)?`electron-overlay`:`standalone`}catch{return`standalone`}}function ot(e,t){return e===`electron-overlay`||e===`hosted-leader`||e===`standalone`&&t}function st(e){return e.pathname===`/electron`||e.pathname===`/electron/`||e.searchParams.get(`runtime`)===`electron-overlay`}function ct(e,t){$e(e,t.storage),D(async()=>{let{refreshFeatureFlagsForPage:e}=await import(`./setup-feature-flags-remote-Czi_ny8P.js`);return{refreshFeatureFlagsForPage:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({refreshFeatureFlagsForPage:n})=>n(e,t)).catch(()=>{})}function lt(e){let t=at(e.locationHref,e.isExtension,e.storage);return ct(t,e),t}function ut(){if(k())return;let e=new Blob([`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/setup-feature-flags-remote-Cf37xnQ1.js","assets/feature-flags-ByMXaIc4.js","assets/tray-runtime-config-Bpo7AZhY.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-CFWkfPNA.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/base64-DJRlyqZu.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-GRCyib6X.js","assets/messages-BD4p8GuF.js","assets/sudo-gXakxwpD.js","assets/logger-DDBAeTLF.js","assets/runtime-env-CgsZ7LTp.js","assets/runtime-env-E-i2SW1s.js","assets/quick-llm-Dx10uCk3.js","assets/account-store-BaTmqQCH.js","assets/claude-model-version-C0HLsjny.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-BxrUfzom.js","assets/libesm-BypnjKEL.js","assets/float-topology-BYb7rxY5.js","assets/secret-topology-BE7Eyd3P.js","assets/secrets-bridge-client-CHZomqvU.js","assets/port-bridge-client-Cti-DmEY.js","assets/image-markers-CxJ9ZBgw.js","assets/tool-ui-DfXu6quJ.js","assets/providers-N-GzEZuq.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-ZLR7gmJ4.js","assets/page-approval-service-Z5cL8IlA.js","assets/extension-bridge-transport-D3PItLFo.js","assets/pending-request-table-Dgn6qYdL.js","assets/lick-ws-bridge-rxCk9AYw.js","assets/logger-BoSvu4mW.js","assets/tray-leader-B_FxjW0d.js","assets/cdp-BzUC7d2h.js","assets/remote-cdp-transport-DeDqT7I4.js","assets/navigation-watcher-DrWMx-B4.js","assets/handoff-link-BObMRgsx.js","assets/main-cherry-C6fqCnLL.js","assets/synthetic-cdp-transport-Ds83IPjw.js","assets/oauth-service-DJuzPXsg.js","assets/permissions-surface-registry-CilCRwhh.js","assets/wc-shell-DHFdDKPB.js","assets/mime-types-k2E6ulyv.js","assets/telemetry-BVzuNdvW.js","assets/html-B_Hg2WOy.js","assets/speech-C5U8h4In.js","assets/soundscape-cues-5_sT5Un6.js","assets/wc-shell-WkeczD9x.css","assets/wc-follower-orVLyho6.js","assets/wc-follower-oauth-CQymgqdo.js","assets/slicc-app-url-BsBryEhn.js","assets/tray-follower-status-BAjnN7Ar.js","assets/record-C0lt6kKE.js","assets/shared-2T6O01rS.js","assets/sprinkle-renderer-C9L5ZRvl.js","assets/theme-CXRqxpw6.js","assets/theme-engine-By4GU_Wc.js","assets/wc-unit-context-oCIU0KAf.js","assets/export-spool-Eul4J1RP.js","assets/src-BWaKqLvQ.js","assets/wc-live-Y30MNXP6.js","assets/types-idfTVsM8.js","assets/hid-device-registry-B2R-0rNt.js","assets/browser-DGwroBSO.js","assets/serial-port-registry-CCqklAEr.js","assets/usb-operations-BBXJ4GF8.js","assets/usb-device-registry-CRsCisej.js","assets/sprinkle-bridge-D4YmJlZ6.js","assets/wc-sprinkles-BX0o3VdV.js","assets/wc-attach-CHoh_npa.js","assets/wc-float-label-_5Qu7XYI.js","assets/wc-floatbar-online-DdJjsUiB.js","assets/wc-permissions-WjSZrbPa.js","assets/oauth-bootstrap-BPR0IgmZ.js","assets/legacy-styles-DcRu2WCJ.js","assets/connect-surface-COZ8qeD4.js","assets/wc-extension-DinzzE-u.js","assets/wc-detached-B3WCbbZT.js"])))=>i.map(i=>d[i]);
2
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import"./modulepreload-polyfill-P2Xu9kJm.js";import{A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,R as _,S as v,T as y,U as b,V as x,W as S,_ as C,a as w,b as ee,c as te,d as T,f as ne,g as re,h as ie,i as E,j as ae,k as oe,l as se,m as ce,n as le,o as ue,p as de,q as fe,s as pe,t as me,u as he,v as ge,w as _e,x as ve,y as ye,z as be}from"./account-store-BaTmqQCH.js";import{t as D}from"./preload-helper-Czpn1I53.js";import{t as O}from"./logger-DDBAeTLF.js";import{c as xe,l as Se,o as Ce,s as we}from"./src-CAWTvdAa.js";import"./proxied-fetch-CFWkfPNA.js";import{n as k,t as A}from"./runtime-env-Dlaokqg1.js";import{a as Te,o as Ee,s as De}from"./api-endpoint-GRCyib6X.js";import"./runtime-env-CgsZ7LTp.js";import{o as Oe,t as ke}from"./telemetry-BVzuNdvW.js";import{a as Ae}from"./providers-N-GzEZuq.js";import"./messages-BD4p8GuF.js";import{n as je}from"./feature-flags-ByMXaIc4.js";import{c as Me,d as Ne,p as Pe,s as Fe,t as Ie,u as Le}from"./tray-runtime-config-Bpo7AZhY.js";import{t as Re}from"./tray-follower-status-BAjnN7Ar.js";import{n as ze}from"./clipboard-eqmn97SP.js";import{n as j}from"./tray-join-url-BIvzbiFR.js";var Be=`role`;function Ve(e){try{let t=new URL(e);return`${t.protocol===`wss:`?`https:`:`http:`}//${t.host}`}catch{return null}}function He(e){try{let t=new URL(e);return`${t.protocol}//${t.host}/licks-ws`}catch{return null}}function Ue(e){let t;try{t=new URLSearchParams(e)}catch{return null}let n=t.get(xe),r=t.get(we);if(!n||!r||!/^wss?:\/\//.test(n))return null;let i=t.get(Be),a=i===`leader`||i===`follower`?i:null;return{url:n,subprotocol:`${Ce}${r}`,token:r,apiBaseUrl:Ve(n),lickWsUrl:He(n),role:a}}var We=`slicc:bridge-config`,Ge=`slicc:extension-delegate-config`;function Ke(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 qe=O(`boot/ext-fetch-delegate`);function Je(){let e=globalThis.chrome?.runtime;return e&&typeof e.connect==`function`?e:null}function Ye(e,t,n){let r=Je();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 Xe(e){typeof navigator>`u`||!navigator.serviceWorker||navigator.serviceWorker.addEventListener(`message`,t=>{if(!Ke(t.data))return;let n=t.ports?.[0];if(!n){qe.warn(`delegated fetch envelope arrived without a response port`);return}Ye(t.data,n,e)})}var Ze=`slicc_feature_flags_remote`;function Qe(e){return`${Ze}:${e}`}function $e(e,t){let n=tt(t);je(e,nt(n,e)??{})}function et(e,t,n){try{e?.setItem(Qe(t),JSON.stringify(n))}catch{}}function tt(e){if(e!==void 0)return e;try{let e=globalThis.localStorage;return typeof e?.getItem!=`function`||typeof e.setItem!=`function`?void 0:e}catch{return}}function nt(e,t){try{let n=e?.getItem(Qe(t));return n?rt(JSON.parse(n)):null}catch{return null}}function rt(e){return!it(e)||Object.values(e).some(e=>typeof e!=`string`)?null:e}function it(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function at(e,t,n){if(t){try{if(new URL(e).searchParams.has(`detached`))return`extension-detached`}catch{}return`extension`}try{let t=new URL(e);if(t.searchParams.get(`connect`)===`1`)return`connect`;if(t.searchParams.get(`runtime`)===`hosted-leader`)return`hosted-leader`;if(t.searchParams.get(`cherry`)===`1`)return`cherry`;let r=n===void 0?typeof window<`u`?window.localStorage:null:n;return Le(e,r)?`follower`:st(t)?`electron-overlay`:`standalone`}catch{return`standalone`}}function ot(e,t){return e===`electron-overlay`||e===`hosted-leader`||e===`standalone`&&t}function st(e){return e.pathname===`/electron`||e.pathname===`/electron/`||e.searchParams.get(`runtime`)===`electron-overlay`}function ct(e,t){$e(e,t.storage),D(async()=>{let{refreshFeatureFlagsForPage:e}=await import(`./setup-feature-flags-remote-Cf37xnQ1.js`);return{refreshFeatureFlagsForPage:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({refreshFeatureFlagsForPage:n})=>n(e,t)).catch(()=>{})}function lt(e){let t=at(e.locationHref,e.isExtension,e.storage);return ct(t,e),t}function ut(){if(k())return;let e=new Blob([`
3
3
  let lastPong = Date.now();
4
4
  let frozen = false;
5
5
  setInterval(() => {
@@ -19,4 +19,4 @@ import{n as e}from"./rolldown-runtime-Dd_uD5pT.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 dt=`slicc-nuke-control`,ft=[`slicc:welcome-flow-fired`,`slicc.trayJoinUrl`,`slicc.trayWorkerBaseUrl`];function pt(e=()=>location.reload()){if(typeof BroadcastChannel!=`function`)return()=>{};let t=new BroadcastChannel(dt),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 M=null;function mt(){return M||(M=pt(),M)}O(`stale-asset`);var ht=`slicc-stale-asset-reload`;function gt(e,t){if(typeof BroadcastChannel!=`function`)return()=>{};let n=new BroadcastChannel(ht),r=n=>{let r=n.data;r?.type===`stale-asset-reload`&&r.instanceId===e&&t(r.replayTurn===!0)};return n.addEventListener(`message`,r),()=>{n.removeEventListener(`message`,r),n.close()}}var _t=`slicc:stale-asset-reloaded-at`,vt=6e4,N=`slicc:stale-asset-replay`;function yt(e=window.sessionStorage){try{e.setItem(N,`1`)}catch{}}function bt(e=window.sessionStorage){try{return e.getItem(N)===`1`&&(e.removeItem(N),!0)}catch{return!1}}function xt(){return{reload:()=>window.location.reload(),storage:window.sessionStorage,now:()=>Date.now(),windowMs:vt,storageKey:_t}}function St(e,t,n){return e===null||t-e>=n}function P(e=xt()){let t;try{t=e.storage.getItem(e.storageKey)}catch{return!1}let n=t===null?null:Number(t),r=n!==null&&Number.isFinite(n)?n:null,i=e.now();if(!St(r,i,e.windowMs))return!1;try{e.storage.setItem(e.storageKey,String(i))}catch{return!1}return e.reload(),!0}var F=null,I=null;function Ct(e){F||(I={...xt(),...e},F=e=>{P(I)&&e.preventDefault()},window.addEventListener(`vite:preloadError`,F))}var L=null;function wt(e){return L||(L=gt(e,e=>{e&&yt(),P(I??void 0)}),L)}var Tt=`slicc-cdp-superseded-banner`;function Et(e){if(e.getElementById(Tt))return;let t=e.createElement(`div`);t.id=Tt,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)}var Dt=e({setupSudoExtension:()=>kt,setupSudoStandalone:()=>Ot});async function Ot(e){let{installSudoTestHook:t}=await D(async()=>{let{installSudoTestHook:e}=await import(`./sudo-BYKLWL8l.js`);return{installSudoTestHook:e}},__vite__mapDeps([12,6,13,4,5,7,3,8,9,10,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36]));t()}async function kt(e){let{installPanelSudoResponder:t}=await D(async()=>{let{installPanelSudoResponder:e}=await import(`./sudo-BYKLWL8l.js`);return{installPanelSudoResponder:e}},__vite__mapDeps([12,6,13,4,5,7,3,8,9,10,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36]));t()}function At(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`slicc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function jt(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}var Mt=[100,200,400,800,1600];async function R(e,t,n,r=Mt,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 Nt(e,t,n){let{ExtensionBridgeTransport:r}=await D(async()=>{let{ExtensionBridgeTransport:e}=await import(`./extension-bridge-transport-D3PItLFo.js`);return{ExtensionBridgeTransport:e}},__vite__mapDeps([37,13,38])),{mapDiscoveryPayloadToLickEvent:i,mapNavigatePayloadToLickEvent:a}=await D(async()=>{let{mapDiscoveryPayloadToLickEvent:e,mapNavigatePayloadToLickEvent:t}=await import(`./lick-ws-bridge-rxCk9AYw.js`);return{mapDiscoveryPayloadToLickEvent:e,mapNavigatePayloadToLickEvent:t}},__vite__mapDeps([39,13,40,41,5,4,6,7,3,8,9,10,14,15,2,11])),o=null,s=[],c=!1,l=e=>{o=e;for(let t of s)e.sendForwardedLick(t);s.length=0},u=e=>{if(e){if(o){o.sendForwardedLick(e);return}s.length>=50&&(s.shift(),c||(c=!0,n.warn(`extension-bridge lick buffer overflow (cap 50); dropping oldest pending licks until the kernel client attaches`))),s.push(e)}},d=new e(new r({extensionId:t,onLick:e=>{u(a(e))},onDiscovery:e=>{u(i(e))},onOpenSettings:()=>{globalThis.dispatchEvent(new CustomEvent(`slicc:open-settings-from-panel`))}}));return await R(d,void 0,n),{browser:d,attachLickForwardingClient:l}}async function Pt(e){let{runtimeMode:t,envBaseUrl:n,window:r,log:i}=e,a=t===`electron-overlay`;i.info(`setting up standalone page runtime (BrowserAPI + CDP)`,{runtimeMode:t});let{BrowserAPI:o}=await D(async()=>{let{BrowserAPI:e}=await import(`./cdp-BzUC7d2h.js`);return{BrowserAPI:e}},__vite__mapDeps([42,13,43,3,38,40,44,45]));await Ot({log:i});let s,c,l,u=null,d=null,f=null,p=null,m,h=t===`cherry`?null:jt(r.location.search),g=!!h&&A(),_=t===`cherry`||g?null:Ue(r.location.search);_?.apiBaseUrl&&(u=_.apiBaseUrl,De(_.apiBaseUrl),d=_.token,Te(_.token)),_?.lickWsUrl&&(f=_.lickWsUrl);let v=t===`cherry`||g||_!==null,y=await Fe(),b=ot(t,y!==null)?Ie:null;if(await Ne({locationHref:r.location.href,storage:r.localStorage,envBaseUrl:n,defaultWorkerBaseUrl:b,runtimeConfigFetcher:async()=>y}),t===`cherry`){let{setupCherryFollower:e}=await D(async()=>{let{setupCherryFollower:e}=await import(`./main-cherry-C6fqCnLL.js`);return{setupCherryFollower:e}},__vite__mapDeps([46,13,3,38,42,43,40,44,45,47])),t=await e();s=t.browser,c=t.joinUrl,l=t.transport}else if(h&&A()){i.info(`Routing CDP through the extension bridge (leader tab)`);let e=await Nt(o,h.extensionId,i);s=e.browser,m=e.attachLickForwardingClient,p=h.extensionId,Ee(h.extensionId)}else{s=new o,_&&i.info(`Routing CDP through local standalone bridge`,{url:_.url,role:_.role??`(unset)`});let e=_?{url:_.url,protocols:_.subprotocol}:void 0;_?.role===`follower`?(i.info(`Skipping CDP connect for follower overlay tab`),s.primeConnectOptions(e)):(await R(s,e,i),s.setCdpSupersededHandler(()=>Et(r.document)))}let x=s.getTransport();return globalThis.__slicc_browser=s,{browser:s,realCdpTransport:x,hasLocalCdpSurface:v,cherryJoinUrl:c,cherryTransport:l,instanceId:At(),isElectronOverlay:a,localApiBaseUrl:u,bridgeToken:d,localLickWsUrl:f,extensionDelegateId:p,attachLickForwardingClient:m}}var z=O(`boot/sw-registration`);async function Ft(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 It())return`reload-pending`;if(!(`serviceWorker`in navigator)||n)return`ready`;try{if(await navigator.serviceWorker.register(`/preview-sw.js`,{scope:`/preview/`}),z.info(`Preview SW registered`),!k())try{await navigator.serviceWorker.register(`/llm-proxy-sw.js`,{scope:`/`}),z.info(`LLM-proxy SW registered`)}catch(e){z.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`),z.info(`Reloading once to gain SW control`),location.reload(),`reload-pending`;sessionStorage.removeItem(`slicc-sw-reloaded`),e&&(B(e),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{B(e)})),t&&(V(t),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{V(t)}))}catch(e){z.error(`Preview SW registration failed — preview feature will not work`,e)}return`ready`}function B(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:We,apiBaseUrl:e.apiBaseUrl,token:e.token};try{t.postMessage(n)}catch(e){z.warn(`LLM-proxy SW bridge-config postMessage failed`,e)}}function V(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:Ge,extensionId:e.extensionId};try{t.postMessage(n)}catch(e){z.warn(`LLM-proxy SW extension-delegate postMessage failed`,e)}}async function It(){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`),z.info(`connect mode: detaching from service worker (no proxy on worker origin)`),location.reload(),!0;sessionStorage.removeItem(`slicc-connect-sw-cleared`)}catch(e){z.error(`connect-mode SW cleanup failed`,e)}return!1}var Lt=e({ACCOUNTS_KEY:()=>me,__test__:()=>le,addAccount:()=>E,applyProviderDefaults:()=>w,clearAllSettings:()=>ue,clearApiKey:()=>pe,clearBaseUrl:()=>te,clearSelectedProvider:()=>se,describeInvalidJoinUrl:()=>j,downloadProviders:()=>zt,exportProviders:()=>he,getAccounts:()=>T,getAllAvailableModels:()=>ne,getAllExtraOAuthDomains:()=>de,getApiKey:()=>ce,getApiKeyForProvider:()=>ie,getApiVersionForProvider:()=>re,getAvailableProviders:()=>C,getBaseUrl:()=>ge,getBaseUrlForProvider:()=>ye,getDeploymentForProvider:()=>ee,getExtraOAuthDomains:()=>ve,getOAuthAccountInfo:()=>v,getProviderConfig:()=>r,getProviderModels:()=>_e,getRawApiKeyForProvider:()=>y,getSelectedModelId:()=>a,getSelectedProvider:()=>i,isModelHiddenFromPicker:()=>h,logoutOAuthAccount:()=>oe,maskOAuthTokenWithRetry:()=>t,migrateLegacyAuthOnlySelection:()=>ae,modelRunsOnProvider:()=>p,persistOAuthMaskViaServiceWorker:()=>m,policyVisible:()=>g,providerOffersLlmModels:()=>o,reloginOAuthAccount:()=>Ht,removeAccount:()=>l,resolveCurrentModel:()=>f,resolveModelById:()=>_,resolveModelByShorthand:()=>be,resolveModelIdForScoop:()=>n,resolveModelSelectionForScoop:()=>x,saveOAuthAccount:()=>c,setApiKey:()=>b,setBaseUrl:()=>S,setExtraOAuthDomains:()=>s,setExtraOAuthDomainsAsync:()=>d,setSelectedModelId:()=>fe,setSelectedProvider:()=>u,showProviderSettings:()=>ln,testOnlyDispatchTrayJoinWithFailureFeedback:()=>Rt}),H=O(`provider-settings`);function Rt(e,t){return U(e,t)}function U(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){H.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 zt(){let e=JSON.stringify(he(),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 Bt(e){return e.length<=10?`****`:e.slice(0,4)+`...`+e.slice(-4)}function W(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 G={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`]},K=`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 q(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 J(e){e.overlay.remove(),e.resolve((localStorage.getItem(`slicc_accounts`)??``)!==e.accountsBefore)}function Y(e){e.options?.startInAddAccount?J(e):X(e)}function Vt(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)`):t.textContent=e.userName?e.userName:e.accessToken?`Logged in`:Bt(e.apiKey),e.baseUrl&&(t.textContent+=` • `+e.baseUrl),t}async function Ht(e,t){let{createOAuthLauncher:n,createInterceptingOAuthLauncherForCurrentRuntime:r}=await D(async()=>{let{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}=await import(`./oauth-service-DJuzPXsg.js`);return{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}},__vite__mapDeps([48,6,4,5,7,3,8,9,10,14,15,32,49])),i={forceReauth:!0};if(e.onOAuthLoginIntercepted){let n=await r();n&&await e.onOAuthLoginIntercepted(n,t,i)}else if(e.onOAuthLogin){let r=n();await e.onOAuthLogin(r,t,i)}}function Ut(e,t){let n=document.createElement(`button`);return n.style.cssText=K,n.setAttribute(`aria-label`,`Edit account`),n.appendChild(W(G.pen)),q(n,`var(--s2-accent)`),n.addEventListener(`click`,()=>Z(e,t)),n}function Wt(e,t,n){let r=document.createElement(`button`);return r.style.cssText=K,t.loggedOut===!0?(r.setAttribute(`aria-label`,`Log in`),r.setAttribute(`title`,`Log in`),r.appendChild(W(G.login)),q(r,`var(--s2-accent)`),r.addEventListener(`click`,()=>{Ht(n,()=>X(e))})):(r.setAttribute(`aria-label`,`Log out`),r.setAttribute(`title`,`Log out`),r.appendChild(W(G.logout)),q(r,`var(--s2-warning, #f59e0b)`),r.addEventListener(`click`,()=>{(async()=>{await oe(t.providerId),X(e)})()})),r}function Gt(e,t){let n=document.createElement(`button`);return n.style.cssText=K,n.setAttribute(`aria-label`,`Remove account`),n.appendChild(W(G.trash)),q(n,`var(--s2-negative)`),n.addEventListener(`click`,()=>{(async()=>{await l(t.providerId),X(e)})()}),n}function Kt(e,t){let n=r(t.providerId),i=document.createElement(`div`);i.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(Vt(t)),i.appendChild(a);let s=document.createElement(`div`);return s.style.cssText=`display: flex; gap: 4px; margin-left: 12px; flex-shrink: 0;`,s.appendChild(Ut(e,t)),n.isOAuth&&s.appendChild(Wt(e,t,n)),s.appendChild(Gt(e,t)),i.appendChild(s),i}function qt(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=Re(),a=i.state!==`inactive`,o=Me(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=T();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(Kt(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`,()=>zt()),i.appendChild(o),t.appendChild(i),t.appendChild(qt(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`,()=>J(e)),t.appendChild(c)}function Jt(e,t){let n=document.createElement(`select`);if(n.className=`dialog__input`,n.style.marginBottom=`8px`,t){let e=r(t.providerId),i=document.createElement(`option`);return i.value=t.providerId,i.textContent=e.name,n.appendChild(i),n.disabled=!0,n.style.opacity=`0.7`,n}let i=document.createElement(`option`);i.value=``,i.textContent=`Select a provider…`,i.disabled=!0,i.selected=!0,i.hidden=!0,n.appendChild(i);let a=new Set(T().map(e=>e.providerId)),s=[...C()].sort((e,t)=>r(e).name.localeCompare(r(t).name));for(let t of s){if(a.has(t))continue;if(e?.providerFilter){if(!e.providerFilter(t))continue}else if(!o(t))continue;let i=document.createElement(`option`);i.value=t,i.textContent=r(t).name,n.appendChild(i)}return n}function Yt(e,t){let n=Jt(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 Xt(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 Zt(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}=Xt(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 ze(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 Qt(e,t){let n=t.providerSelect.value;if(!n)return;let i=r(n);if(!i.onOAuthLogin&&!i.onOAuthLoginIntercepted)return;let{status:a}=t.oauth,o=T().some(e=>e.providerId===n),s=ye(n);if(i.requiresBaseUrl&&!t.baseUrlInput.value.trim()&&!s){a.textContent=`Base URL is required.`,a.style.color=`var(--slicc-cone)`,t.baseUrlInput.focus();return}i.requiresBaseUrl&&t.baseUrlInput.value.trim()&&E(n,``,t.baseUrlInput.value.trim()),a.textContent=`Opening login window...`;try{if(i.onOAuthLoginIntercepted){let{createInterceptingOAuthLauncherForCurrentRuntime:n}=await D(async()=>{let{createInterceptingOAuthLauncherForCurrentRuntime:e}=await import(`./oauth-service-DJuzPXsg.js`);return{createInterceptingOAuthLauncherForCurrentRuntime:e}},__vite__mapDeps([48,6,4,5,7,3,8,9,10,14,15,32,49])),r=await n();if(!r)throw Error(`No controlled-browser CDP transport available — open SLICC in standalone mode or the Chrome extension.`);await i.onOAuthLoginIntercepted(r,()=>Y(e),{presentDeviceCode:Zt(t.oauth)})}else if(i.onOAuthLogin){let{createOAuthLauncher:t}=await D(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-DJuzPXsg.js`);return{createOAuthLauncher:e}},__vite__mapDeps([48,6,4,5,7,3,8,9,10,14,15,32,49])),n=t();await i.onOAuthLogin(n,()=>Y(e))}}catch(e){if(!o)try{await l(n)}catch{}H.error(`OAuth login failed`,{providerId:n,error:e instanceof Error?e.message:String(e)}),a.textContent=`Login failed: ${e instanceof Error?e.message:String(e)}`}}function $t(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 en(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 tn(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 nn(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=r(t);e.providerDesc.textContent=n.description,$t(e,n),en(e,n),tn(e,n)}function rn(e,t){let n=t.providerSelect.value;if(!n)return;let i=r(n),a=(e,n)=>{t.errorEl.textContent=e,t.errorEl.style.display=``,n.focus()};if(i.requiresApiKey&&t.apiKeyInput.value.trim().length<5){a(`API key is required (at least 5 characters).`,t.apiKeyInput);return}if(i.requiresBaseUrl&&!t.baseUrlInput.value.trim()){a(`Base URL is required for this provider.`,t.baseUrlInput);return}if(i.requiresDeployment&&!t.deploymentInput.value.trim()){a(`Deployment name is required for this provider.`,t.deploymentInput);return}E(n,t.apiKeyInput.value.trim(),t.baseUrlInput.value.trim()||void 0,t.deploymentInput.value.trim()||void 0,t.apiVersionInput.value.trim()||void 0),Y(e)}function an(e,t){let{dialog:n,options:r}=e,i=T().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`,()=>J(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 i=document.createElement(`div`);i.className=`dialog__title`,i.textContent=t?`Edit Account`:`Add Account`,n.appendChild(i);let a=document.createElement(`div`);a.className=`dialog__desc`,a.textContent=`Provider:`,n.appendChild(a);let o=Yt(e.options,t);n.appendChild(o.providerSelect),n.appendChild(o.providerDesc),o.oauth.loginBtn.addEventListener(`click`,()=>{Qt(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`,nn(o)}),nn(o),o.saveBtn.addEventListener(`click`,()=>rn(e,o));let s=t=>{t.key===`Enter`&&rn(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),an(e,!!t),requestAnimationFrame(()=>{let e=o.providerSelect.value;if(!e)return;let t=r(e);t.requiresApiKey?o.apiKeyInput.focus():t.requiresBaseUrl&&o.baseUrlInput.focus()})}function on(e,t,n){U(t,n),n.textContent=`Connecting…`,n.style.display=``,n.style.color=`var(--s2-content-secondary)`;let r=setTimeout(()=>{e.overlay.remove(),e.resolve(!1)},800);n.dataset.dismissTimer=String(r)}function sn(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=Pe(window.localStorage,t);if(!n){o.textContent=`Invalid sync URL.`,o.style.display=``,o.style.color=`var(--slicc-cone)`;return}on(e,n.joinUrl,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 cn(){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(cn());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=`${Se}/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=Pe(window.localStorage,t);if(!n){o.textContent=j(t),o.style.display=``,a.focus();return}on(e,n.joinUrl,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 ln(e){return Oe(`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):T().length>0?X(i):e?.autoJoinUrl?sn(i,e.autoJoinUrl):e?.preferTrayJoin?Q(i):Z(i),n.appendChild(r),document.body.appendChild(n)})}var $=O(`main`);function un(e){try{return new URL(e).searchParams.has(`ui-fixture`)}catch{return!1}}async function dn(){Ct();let e=document.getElementById(`app`);if(!e)throw Error(`#app element not found`);let t=k(),n=lt({locationHref:window.location.href,storage:window.localStorage,envBaseUrl:null,isDev:!1,isExtension:t});if(un(window.location.href)){let{mountWcUiPreview:t}=await D(async()=>{let{mountWcUiPreview:e}=await import(`./wc-shell-hnMI7FOV.js`).then(e=>e.s);return{mountWcUiPreview:e}},__vite__mapDeps([50,5,6,13,51,7,3,29,52,8,14,15,53,35,54,55,56]));t(e);return}ut(),mt(),n!==`connect`&&ke().catch(()=>{});let r=Ue(window.location.search),i=n===`cherry`?null:jt(window.location.search),a=!!i&&A();if(await Ft(r?{apiBaseUrl:r.apiBaseUrl,token:r.token}:null,a&&i?{extensionId:i.extensionId}:null)===`reload-pending`)return;if(!t&&(n===`follower`||n===`cherry`)){let{mountWcUiFollower:t}=await D(async()=>{let{mountWcUiFollower:e}=await import(`./wc-follower-BiIsjqEt.js`);return{mountWcUiFollower:e}},__vite__mapDeps([57,6,13,50,5,51,7,3,29,52,8,14,15,53,35,54,55,56,58,59,43,38,60,61,62,9,63,64,65,66,67,68,69,17,18,19,20,21,22,23,24,4,10,25,26,27,28,30,31,32,33,1,2,11,49,70,71,72,73,74,75,41,76,77,78,79,80,81]));return t(e,$,n)}await Ae(),w();let{bootstrapOAuthReplicas:o}=await D(async()=>{let{bootstrapOAuthReplicas:e}=await import(`./oauth-bootstrap-yw-xe8Vv.js`);return{bootstrapOAuthReplicas:e}},__vite__mapDeps([82,17,5,6,18,19,20,21,22,23,24,13,3,4,7,8,9,10,25,15,26,27,28,29,30,31,32,33,40]));if(await Promise.race([o().catch(e=>{$.error(`OAuth bootstrap failed`,e)}),new Promise(e=>setTimeout(e,1e4))]),n===`connect`){globalThis.__slicc_connect_mode=!0;let{loadLegacyStyles:t}=await D(async()=>{let{loadLegacyStyles:e}=await import(`./legacy-styles-DcRu2WCJ.js`);return{loadLegacyStyles:e}},__vite__mapDeps([83,6]));await t();let{mountConnectSurface:n}=await D(async()=>{let{mountConnectSurface:e}=await import(`./connect-surface-DT_tKlEJ.js`);return{mountConnectSurface:e}},__vite__mapDeps([84,17,5,6,18,19,20,21,22,23,24,13,3,4,7,8,9,10,25,15,26,27,28,29,30,31,32,33]));await n(e);return}if(t){let{mountWcUiExtension:t}=await D(async()=>{let{mountWcUiExtension:e}=await import(`./wc-extension-DhuoWguy.js`);return{mountWcUiExtension:e}},__vite__mapDeps([85,6,69,5,17,18,19,20,21,22,23,24,13,3,4,7,8,9,10,25,15,26,27,28,29,30,31,32,33,50,51,52,14,53,35,54,55,56,1,2,11,60,68,49,70,71,72,73,74,75,41,61,62,63,64,65,76,66,86,79,80]));return t(e,$,n===`extension-detached`)}a&&i&&Xe(i.extensionId);let{mountWcUiLive:s}=await D(async()=>{let{mountWcUiLive:e}=await import(`./wc-live-9ZO5QfgI.js`).then(e=>e.r);return{mountWcUiLive:e}},__vite__mapDeps([69,5,17,6,18,19,20,21,22,23,24,13,3,4,7,8,9,10,25,15,26,27,28,29,30,31,32,33,50,51,52,14,53,35,54,55,56,1,2,11,60,68,49,70,71,72,73,74,75,41,61,62,63,64,65,76,66]));return s(e,$,n)}function fn(e,t){let n=document.createElement(`div`);n.style.cssText=`padding:2rem;text-align:center;font-family:system-ui;`;let r=document.createElement(`h1`);r.textContent=`Failed to start`;let i=document.createElement(`p`);i.textContent=t instanceof Error?t.message:String(t);let a=document.createElement(`button`);a.type=`button`,a.textContent=`Reload`,a.addEventListener(`click`,()=>location.reload()),n.append(r,i,a),e.replaceChildren(n)}async function pn(e,t){let n;try{({renderBootRecoveryScreen:n}=await D(()=>import(`./recovery-screen-DRwDpcP6.js`),[]))}catch{fn(e,t);return}if(n(e,t),t instanceof Error&&t.message.includes(`did not signal ready`))try{let{triageModuleWorkerHealth:r}=await D(async()=>{let{triageModuleWorkerHealth:e}=await import(`./worker-triage-BvsMZrdR.js`);return{triageModuleWorkerHealth:e}},[]),i=await r();i===`browser-wedged`&&n(e,t,{verdict:i})}catch{}}dn().catch(e=>{$.error(`Fatal error`,e);let t=document.getElementById(`app`);t&&pn(t,e)});export{bt as a,ft as c,Dt as i,tt as l,ln as n,P as o,Pt as r,wt as s,Lt as t,et as u};
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 dt=`slicc-nuke-control`,ft=[`slicc:welcome-flow-fired`,`slicc.trayJoinUrl`,`slicc.trayWorkerBaseUrl`];function pt(e=()=>location.reload()){if(typeof BroadcastChannel!=`function`)return()=>{};let t=new BroadcastChannel(dt),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 M=null;function mt(){return M||(M=pt(),M)}O(`stale-asset`);var ht=`slicc-stale-asset-reload`;function gt(e,t){if(typeof BroadcastChannel!=`function`)return()=>{};let n=new BroadcastChannel(ht),r=n=>{let r=n.data;r?.type===`stale-asset-reload`&&r.instanceId===e&&t(r.replayTurn===!0)};return n.addEventListener(`message`,r),()=>{n.removeEventListener(`message`,r),n.close()}}var _t=`slicc:stale-asset-reloaded-at`,vt=6e4,N=`slicc:stale-asset-replay`;function yt(e=window.sessionStorage){try{e.setItem(N,`1`)}catch{}}function bt(e=window.sessionStorage){try{return e.getItem(N)===`1`&&(e.removeItem(N),!0)}catch{return!1}}function xt(){return{reload:()=>window.location.reload(),storage:window.sessionStorage,now:()=>Date.now(),windowMs:vt,storageKey:_t}}function St(e,t,n){return e===null||t-e>=n}function P(e=xt()){let t;try{t=e.storage.getItem(e.storageKey)}catch{return!1}let n=t===null?null:Number(t),r=n!==null&&Number.isFinite(n)?n:null,i=e.now();if(!St(r,i,e.windowMs))return!1;try{e.storage.setItem(e.storageKey,String(i))}catch{return!1}return e.reload(),!0}var F=null,I=null;function Ct(e){F||(I={...xt(),...e},F=e=>{P(I)&&e.preventDefault()},window.addEventListener(`vite:preloadError`,F))}var L=null;function wt(e){return L||(L=gt(e,e=>{e&&yt(),P(I??void 0)}),L)}var Tt=`slicc-cdp-superseded-banner`;function Et(e){if(e.getElementById(Tt))return;let t=e.createElement(`div`);t.id=Tt,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)}var Dt=e({setupSudoExtension:()=>kt,setupSudoStandalone:()=>Ot});async function Ot(e){let{installSudoTestHook:t}=await D(async()=>{let{installSudoTestHook:e}=await import(`./sudo-gXakxwpD.js`);return{installSudoTestHook:e}},__vite__mapDeps([12,6,13,4,5,7,3,8,9,10,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36]));t()}async function kt(e){let{installPanelSudoResponder:t}=await D(async()=>{let{installPanelSudoResponder:e}=await import(`./sudo-gXakxwpD.js`);return{installPanelSudoResponder:e}},__vite__mapDeps([12,6,13,4,5,7,3,8,9,10,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36]));t()}function At(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`slicc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function jt(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}var Mt=[100,200,400,800,1600];async function R(e,t,n,r=Mt,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 Nt(e,t,n){let{ExtensionBridgeTransport:r}=await D(async()=>{let{ExtensionBridgeTransport:e}=await import(`./extension-bridge-transport-D3PItLFo.js`);return{ExtensionBridgeTransport:e}},__vite__mapDeps([37,13,38])),{mapDiscoveryPayloadToLickEvent:i,mapNavigatePayloadToLickEvent:a}=await D(async()=>{let{mapDiscoveryPayloadToLickEvent:e,mapNavigatePayloadToLickEvent:t}=await import(`./lick-ws-bridge-rxCk9AYw.js`);return{mapDiscoveryPayloadToLickEvent:e,mapNavigatePayloadToLickEvent:t}},__vite__mapDeps([39,13,40,41,5,4,6,7,3,8,9,10,14,15,2,11])),o=null,s=[],c=!1,l=e=>{o=e;for(let t of s)e.sendForwardedLick(t);s.length=0},u=e=>{if(e){if(o){o.sendForwardedLick(e);return}s.length>=50&&(s.shift(),c||(c=!0,n.warn(`extension-bridge lick buffer overflow (cap 50); dropping oldest pending licks until the kernel client attaches`))),s.push(e)}},d=new e(new r({extensionId:t,onLick:e=>{u(a(e))},onDiscovery:e=>{u(i(e))},onOpenSettings:()=>{globalThis.dispatchEvent(new CustomEvent(`slicc:open-settings-from-panel`))}}));return await R(d,void 0,n),{browser:d,attachLickForwardingClient:l}}async function Pt(e){let{runtimeMode:t,envBaseUrl:n,window:r,log:i}=e,a=t===`electron-overlay`;i.info(`setting up standalone page runtime (BrowserAPI + CDP)`,{runtimeMode:t});let{BrowserAPI:o}=await D(async()=>{let{BrowserAPI:e}=await import(`./cdp-BzUC7d2h.js`);return{BrowserAPI:e}},__vite__mapDeps([42,13,43,3,38,40,44,45]));await Ot({log:i});let s,c,l,u=null,d=null,f=null,p=null,m,h=t===`cherry`?null:jt(r.location.search),g=!!h&&A(),_=t===`cherry`||g?null:Ue(r.location.search);_?.apiBaseUrl&&(u=_.apiBaseUrl,De(_.apiBaseUrl),d=_.token,Te(_.token)),_?.lickWsUrl&&(f=_.lickWsUrl);let v=t===`cherry`||g||_!==null,y=await Fe(),b=ot(t,y!==null)?Ie:null;if(await Ne({locationHref:r.location.href,storage:r.localStorage,envBaseUrl:n,defaultWorkerBaseUrl:b,runtimeConfigFetcher:async()=>y}),t===`cherry`){let{setupCherryFollower:e}=await D(async()=>{let{setupCherryFollower:e}=await import(`./main-cherry-C6fqCnLL.js`);return{setupCherryFollower:e}},__vite__mapDeps([46,13,3,38,42,43,40,44,45,47])),t=await e();s=t.browser,c=t.joinUrl,l=t.transport}else if(h&&A()){i.info(`Routing CDP through the extension bridge (leader tab)`);let e=await Nt(o,h.extensionId,i);s=e.browser,m=e.attachLickForwardingClient,p=h.extensionId,Ee(h.extensionId)}else{s=new o,_&&i.info(`Routing CDP through local standalone bridge`,{url:_.url,role:_.role??`(unset)`});let e=_?{url:_.url,protocols:_.subprotocol}:void 0;_?.role===`follower`?(i.info(`Skipping CDP connect for follower overlay tab`),s.primeConnectOptions(e)):(await R(s,e,i),s.setCdpSupersededHandler(()=>Et(r.document)))}let x=s.getTransport();return globalThis.__slicc_browser=s,{browser:s,realCdpTransport:x,hasLocalCdpSurface:v,cherryJoinUrl:c,cherryTransport:l,instanceId:At(),isElectronOverlay:a,localApiBaseUrl:u,bridgeToken:d,localLickWsUrl:f,extensionDelegateId:p,attachLickForwardingClient:m}}var z=O(`boot/sw-registration`);async function Ft(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 It())return`reload-pending`;if(!(`serviceWorker`in navigator)||n)return`ready`;try{if(await navigator.serviceWorker.register(`/preview-sw.js`,{scope:`/preview/`}),z.info(`Preview SW registered`),!k())try{await navigator.serviceWorker.register(`/llm-proxy-sw.js`,{scope:`/`}),z.info(`LLM-proxy SW registered`)}catch(e){z.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`),z.info(`Reloading once to gain SW control`),location.reload(),`reload-pending`;sessionStorage.removeItem(`slicc-sw-reloaded`),e&&(B(e),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{B(e)})),t&&(V(t),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{V(t)}))}catch(e){z.error(`Preview SW registration failed — preview feature will not work`,e)}return`ready`}function B(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:We,apiBaseUrl:e.apiBaseUrl,token:e.token};try{t.postMessage(n)}catch(e){z.warn(`LLM-proxy SW bridge-config postMessage failed`,e)}}function V(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:Ge,extensionId:e.extensionId};try{t.postMessage(n)}catch(e){z.warn(`LLM-proxy SW extension-delegate postMessage failed`,e)}}async function It(){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`),z.info(`connect mode: detaching from service worker (no proxy on worker origin)`),location.reload(),!0;sessionStorage.removeItem(`slicc-connect-sw-cleared`)}catch(e){z.error(`connect-mode SW cleanup failed`,e)}return!1}var Lt=e({ACCOUNTS_KEY:()=>me,__test__:()=>le,addAccount:()=>E,applyProviderDefaults:()=>w,clearAllSettings:()=>ue,clearApiKey:()=>pe,clearBaseUrl:()=>te,clearSelectedProvider:()=>se,describeInvalidJoinUrl:()=>j,downloadProviders:()=>zt,exportProviders:()=>he,getAccounts:()=>T,getAllAvailableModels:()=>ne,getAllExtraOAuthDomains:()=>de,getApiKey:()=>ce,getApiKeyForProvider:()=>ie,getApiVersionForProvider:()=>re,getAvailableProviders:()=>C,getBaseUrl:()=>ge,getBaseUrlForProvider:()=>ye,getDeploymentForProvider:()=>ee,getExtraOAuthDomains:()=>ve,getOAuthAccountInfo:()=>v,getProviderConfig:()=>r,getProviderModels:()=>_e,getRawApiKeyForProvider:()=>y,getSelectedModelId:()=>a,getSelectedProvider:()=>i,isModelHiddenFromPicker:()=>h,logoutOAuthAccount:()=>oe,maskOAuthTokenWithRetry:()=>t,migrateLegacyAuthOnlySelection:()=>ae,modelRunsOnProvider:()=>p,persistOAuthMaskViaServiceWorker:()=>m,policyVisible:()=>g,providerOffersLlmModels:()=>o,reloginOAuthAccount:()=>Ht,removeAccount:()=>l,resolveCurrentModel:()=>f,resolveModelById:()=>_,resolveModelByShorthand:()=>be,resolveModelIdForScoop:()=>n,resolveModelSelectionForScoop:()=>x,saveOAuthAccount:()=>c,setApiKey:()=>b,setBaseUrl:()=>S,setExtraOAuthDomains:()=>s,setExtraOAuthDomainsAsync:()=>d,setSelectedModelId:()=>fe,setSelectedProvider:()=>u,showProviderSettings:()=>ln,testOnlyDispatchTrayJoinWithFailureFeedback:()=>Rt}),H=O(`provider-settings`);function Rt(e,t){return U(e,t)}function U(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){H.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 zt(){let e=JSON.stringify(he(),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 Bt(e){return e.length<=10?`****`:e.slice(0,4)+`...`+e.slice(-4)}function W(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 G={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`]},K=`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 q(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 J(e){e.overlay.remove(),e.resolve((localStorage.getItem(`slicc_accounts`)??``)!==e.accountsBefore)}function Y(e){e.options?.startInAddAccount?J(e):X(e)}function Vt(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)`):t.textContent=e.userName?e.userName:e.accessToken?`Logged in`:Bt(e.apiKey),e.baseUrl&&(t.textContent+=` • `+e.baseUrl),t}async function Ht(e,t){let{createOAuthLauncher:n,createInterceptingOAuthLauncherForCurrentRuntime:r}=await D(async()=>{let{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}=await import(`./oauth-service-DJuzPXsg.js`);return{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}},__vite__mapDeps([48,6,4,5,7,3,8,9,10,14,15,32,49])),i={forceReauth:!0};if(e.onOAuthLoginIntercepted){let n=await r();n&&await e.onOAuthLoginIntercepted(n,t,i)}else if(e.onOAuthLogin){let r=n();await e.onOAuthLogin(r,t,i)}}function Ut(e,t){let n=document.createElement(`button`);return n.style.cssText=K,n.setAttribute(`aria-label`,`Edit account`),n.appendChild(W(G.pen)),q(n,`var(--s2-accent)`),n.addEventListener(`click`,()=>Z(e,t)),n}function Wt(e,t,n){let r=document.createElement(`button`);return r.style.cssText=K,t.loggedOut===!0?(r.setAttribute(`aria-label`,`Log in`),r.setAttribute(`title`,`Log in`),r.appendChild(W(G.login)),q(r,`var(--s2-accent)`),r.addEventListener(`click`,()=>{Ht(n,()=>X(e))})):(r.setAttribute(`aria-label`,`Log out`),r.setAttribute(`title`,`Log out`),r.appendChild(W(G.logout)),q(r,`var(--s2-warning, #f59e0b)`),r.addEventListener(`click`,()=>{(async()=>{await oe(t.providerId),X(e)})()})),r}function Gt(e,t){let n=document.createElement(`button`);return n.style.cssText=K,n.setAttribute(`aria-label`,`Remove account`),n.appendChild(W(G.trash)),q(n,`var(--s2-negative)`),n.addEventListener(`click`,()=>{(async()=>{await l(t.providerId),X(e)})()}),n}function Kt(e,t){let n=r(t.providerId),i=document.createElement(`div`);i.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(Vt(t)),i.appendChild(a);let s=document.createElement(`div`);return s.style.cssText=`display: flex; gap: 4px; margin-left: 12px; flex-shrink: 0;`,s.appendChild(Ut(e,t)),n.isOAuth&&s.appendChild(Wt(e,t,n)),s.appendChild(Gt(e,t)),i.appendChild(s),i}function qt(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=Re(),a=i.state!==`inactive`,o=Me(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=T();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(Kt(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`,()=>zt()),i.appendChild(o),t.appendChild(i),t.appendChild(qt(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`,()=>J(e)),t.appendChild(c)}function Jt(e,t){let n=document.createElement(`select`);if(n.className=`dialog__input`,n.style.marginBottom=`8px`,t){let e=r(t.providerId),i=document.createElement(`option`);return i.value=t.providerId,i.textContent=e.name,n.appendChild(i),n.disabled=!0,n.style.opacity=`0.7`,n}let i=document.createElement(`option`);i.value=``,i.textContent=`Select a provider…`,i.disabled=!0,i.selected=!0,i.hidden=!0,n.appendChild(i);let a=new Set(T().map(e=>e.providerId)),s=[...C()].sort((e,t)=>r(e).name.localeCompare(r(t).name));for(let t of s){if(a.has(t))continue;if(e?.providerFilter){if(!e.providerFilter(t))continue}else if(!o(t))continue;let i=document.createElement(`option`);i.value=t,i.textContent=r(t).name,n.appendChild(i)}return n}function Yt(e,t){let n=Jt(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 Xt(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 Zt(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}=Xt(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 ze(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 Qt(e,t){let n=t.providerSelect.value;if(!n)return;let i=r(n);if(!i.onOAuthLogin&&!i.onOAuthLoginIntercepted)return;let{status:a}=t.oauth,o=T().some(e=>e.providerId===n),s=ye(n);if(i.requiresBaseUrl&&!t.baseUrlInput.value.trim()&&!s){a.textContent=`Base URL is required.`,a.style.color=`var(--slicc-cone)`,t.baseUrlInput.focus();return}i.requiresBaseUrl&&t.baseUrlInput.value.trim()&&E(n,``,t.baseUrlInput.value.trim()),a.textContent=`Opening login window...`;try{if(i.onOAuthLoginIntercepted){let{createInterceptingOAuthLauncherForCurrentRuntime:n}=await D(async()=>{let{createInterceptingOAuthLauncherForCurrentRuntime:e}=await import(`./oauth-service-DJuzPXsg.js`);return{createInterceptingOAuthLauncherForCurrentRuntime:e}},__vite__mapDeps([48,6,4,5,7,3,8,9,10,14,15,32,49])),r=await n();if(!r)throw Error(`No controlled-browser CDP transport available — open SLICC in standalone mode or the Chrome extension.`);await i.onOAuthLoginIntercepted(r,()=>Y(e),{presentDeviceCode:Zt(t.oauth)})}else if(i.onOAuthLogin){let{createOAuthLauncher:t}=await D(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-DJuzPXsg.js`);return{createOAuthLauncher:e}},__vite__mapDeps([48,6,4,5,7,3,8,9,10,14,15,32,49])),n=t();await i.onOAuthLogin(n,()=>Y(e))}}catch(e){if(!o)try{await l(n)}catch{}H.error(`OAuth login failed`,{providerId:n,error:e instanceof Error?e.message:String(e)}),a.textContent=`Login failed: ${e instanceof Error?e.message:String(e)}`}}function $t(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 en(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 tn(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 nn(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=r(t);e.providerDesc.textContent=n.description,$t(e,n),en(e,n),tn(e,n)}function rn(e,t){let n=t.providerSelect.value;if(!n)return;let i=r(n),a=(e,n)=>{t.errorEl.textContent=e,t.errorEl.style.display=``,n.focus()};if(i.requiresApiKey&&t.apiKeyInput.value.trim().length<5){a(`API key is required (at least 5 characters).`,t.apiKeyInput);return}if(i.requiresBaseUrl&&!t.baseUrlInput.value.trim()){a(`Base URL is required for this provider.`,t.baseUrlInput);return}if(i.requiresDeployment&&!t.deploymentInput.value.trim()){a(`Deployment name is required for this provider.`,t.deploymentInput);return}E(n,t.apiKeyInput.value.trim(),t.baseUrlInput.value.trim()||void 0,t.deploymentInput.value.trim()||void 0,t.apiVersionInput.value.trim()||void 0),Y(e)}function an(e,t){let{dialog:n,options:r}=e,i=T().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`,()=>J(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 i=document.createElement(`div`);i.className=`dialog__title`,i.textContent=t?`Edit Account`:`Add Account`,n.appendChild(i);let a=document.createElement(`div`);a.className=`dialog__desc`,a.textContent=`Provider:`,n.appendChild(a);let o=Yt(e.options,t);n.appendChild(o.providerSelect),n.appendChild(o.providerDesc),o.oauth.loginBtn.addEventListener(`click`,()=>{Qt(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`,nn(o)}),nn(o),o.saveBtn.addEventListener(`click`,()=>rn(e,o));let s=t=>{t.key===`Enter`&&rn(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),an(e,!!t),requestAnimationFrame(()=>{let e=o.providerSelect.value;if(!e)return;let t=r(e);t.requiresApiKey?o.apiKeyInput.focus():t.requiresBaseUrl&&o.baseUrlInput.focus()})}function on(e,t,n){U(t,n),n.textContent=`Connecting…`,n.style.display=``,n.style.color=`var(--s2-content-secondary)`;let r=setTimeout(()=>{e.overlay.remove(),e.resolve(!1)},800);n.dataset.dismissTimer=String(r)}function sn(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=Pe(window.localStorage,t);if(!n){o.textContent=`Invalid sync URL.`,o.style.display=``,o.style.color=`var(--slicc-cone)`;return}on(e,n.joinUrl,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 cn(){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(cn());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=`${Se}/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=Pe(window.localStorage,t);if(!n){o.textContent=j(t),o.style.display=``,a.focus();return}on(e,n.joinUrl,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 ln(e){return Oe(`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):T().length>0?X(i):e?.autoJoinUrl?sn(i,e.autoJoinUrl):e?.preferTrayJoin?Q(i):Z(i),n.appendChild(r),document.body.appendChild(n)})}var $=O(`main`);function un(e){try{return new URL(e).searchParams.has(`ui-fixture`)}catch{return!1}}async function dn(){Ct();let e=document.getElementById(`app`);if(!e)throw Error(`#app element not found`);let t=k(),n=lt({locationHref:window.location.href,storage:window.localStorage,envBaseUrl:null,isDev:!1,isExtension:t});if(un(window.location.href)){let{mountWcUiPreview:t}=await D(async()=>{let{mountWcUiPreview:e}=await import(`./wc-shell-DHFdDKPB.js`).then(e=>e.s);return{mountWcUiPreview:e}},__vite__mapDeps([50,5,6,13,51,7,3,29,52,8,14,15,53,35,54,55,56]));t(e);return}ut(),mt(),n!==`connect`&&ke().catch(()=>{});let r=Ue(window.location.search),i=n===`cherry`?null:jt(window.location.search),a=!!i&&A();if(await Ft(r?{apiBaseUrl:r.apiBaseUrl,token:r.token}:null,a&&i?{extensionId:i.extensionId}:null)===`reload-pending`)return;if(!t&&(n===`follower`||n===`cherry`)){let{mountWcUiFollower:t}=await D(async()=>{let{mountWcUiFollower:e}=await import(`./wc-follower-orVLyho6.js`);return{mountWcUiFollower:e}},__vite__mapDeps([57,6,13,50,5,51,7,3,29,52,8,14,15,53,35,54,55,56,58,59,43,38,60,61,62,9,63,64,65,66,67,68,69,17,18,19,20,21,22,23,24,4,10,25,26,27,28,30,31,32,33,1,2,11,49,70,71,72,73,74,75,41,76,77,78,79,80,81]));return t(e,$,n)}await Ae(),w();let{bootstrapOAuthReplicas:o}=await D(async()=>{let{bootstrapOAuthReplicas:e}=await import(`./oauth-bootstrap-BPR0IgmZ.js`);return{bootstrapOAuthReplicas:e}},__vite__mapDeps([82,17,5,6,18,19,20,21,22,23,24,13,3,4,7,8,9,10,25,15,26,27,28,29,30,31,32,33,40]));if(await Promise.race([o().catch(e=>{$.error(`OAuth bootstrap failed`,e)}),new Promise(e=>setTimeout(e,1e4))]),n===`connect`){globalThis.__slicc_connect_mode=!0;let{loadLegacyStyles:t}=await D(async()=>{let{loadLegacyStyles:e}=await import(`./legacy-styles-DcRu2WCJ.js`);return{loadLegacyStyles:e}},__vite__mapDeps([83,6]));await t();let{mountConnectSurface:n}=await D(async()=>{let{mountConnectSurface:e}=await import(`./connect-surface-COZ8qeD4.js`);return{mountConnectSurface:e}},__vite__mapDeps([84,17,5,6,18,19,20,21,22,23,24,13,3,4,7,8,9,10,25,15,26,27,28,29,30,31,32,33]));await n(e);return}if(t){let{mountWcUiExtension:t}=await D(async()=>{let{mountWcUiExtension:e}=await import(`./wc-extension-DinzzE-u.js`);return{mountWcUiExtension:e}},__vite__mapDeps([85,6,69,5,17,18,19,20,21,22,23,24,13,3,4,7,8,9,10,25,15,26,27,28,29,30,31,32,33,50,51,52,14,53,35,54,55,56,1,2,11,60,68,49,70,71,72,73,74,75,41,61,62,63,64,65,76,66,86,79,80]));return t(e,$,n===`extension-detached`)}a&&i&&Xe(i.extensionId);let{mountWcUiLive:s}=await D(async()=>{let{mountWcUiLive:e}=await import(`./wc-live-Y30MNXP6.js`).then(e=>e.r);return{mountWcUiLive:e}},__vite__mapDeps([69,5,17,6,18,19,20,21,22,23,24,13,3,4,7,8,9,10,25,15,26,27,28,29,30,31,32,33,50,51,52,14,53,35,54,55,56,1,2,11,60,68,49,70,71,72,73,74,75,41,61,62,63,64,65,76,66]));return s(e,$,n)}function fn(e,t){let n=document.createElement(`div`);n.style.cssText=`padding:2rem;text-align:center;font-family:system-ui;`;let r=document.createElement(`h1`);r.textContent=`Failed to start`;let i=document.createElement(`p`);i.textContent=t instanceof Error?t.message:String(t);let a=document.createElement(`button`);a.type=`button`,a.textContent=`Reload`,a.addEventListener(`click`,()=>location.reload()),n.append(r,i,a),e.replaceChildren(n)}async function pn(e,t){let n;try{({renderBootRecoveryScreen:n}=await D(()=>import(`./recovery-screen-Xm3PO1gX.js`),[]))}catch{fn(e,t);return}if(n(e,t),t instanceof Error&&t.message.includes(`did not signal ready`))try{let{triageModuleWorkerHealth:r}=await D(async()=>{let{triageModuleWorkerHealth:e}=await import(`./worker-triage-BvsMZrdR.js`);return{triageModuleWorkerHealth:e}},[]),i=await r();i===`browser-wedged`&&n(e,t,{verdict:i})}catch{}}dn().catch(e=>{$.error(`Fatal error`,e);let t=document.getElementById(`app`);t&&pn(t,e)});export{bt as a,ft as c,Dt as i,tt as l,ln as n,P as o,Pt as r,wt as s,Lt as t,et as u};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-DG6fHM_V.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-C0HLsjny.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-BxrUfzom.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-CFWkfPNA.js","assets/base64-DJRlyqZu.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-GRCyib6X.js","assets/float-topology-BYb7rxY5.js","assets/runtime-env-E-i2SW1s.js","assets/secret-topology-BE7Eyd3P.js","assets/secrets-bridge-client-CHZomqvU.js","assets/port-bridge-client-Cti-DmEY.js","assets/image-markers-CxJ9ZBgw.js","assets/tool-ui-DfXu6quJ.js","assets/providers-EvW22h9s.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-Czpn1I53.js";import{n as t}from"./mime-types-k2E6ulyv.js";import{r as n,t as r}from"./base64-DJRlyqZu.js";import"./src-CAWTvdAa.js";import{n as i}from"./runtime-env-Dlaokqg1.js";import{i as a,n as o,t as s}from"./api-endpoint-GRCyib6X.js";import"./runtime-env-E-i2SW1s.js";import{t as c}from"./types-idfTVsM8.js";import"./mount-table-store-dY2IfQ5S.js";import"./fs-CZt4jt7E.js";import{t as l}from"./mount-bridge-client-BJeJ5p60.js";var u=`https://api.aem.live`,d=`application/folder`,f=5242880;function p(e){let t=e.match(/^aem:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid AEM source '${e}' — expected aem://org/site[/path]`);return{org:t[1],site:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}function m(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function h(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function g(e){return e.map(e=>e[`content-type`]===d||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:m(e[`last-modified`]),lastModified:h(e[`last-modified`])})}var _=class{kind=`aem`;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=p(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??f,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`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(`/`),r=`/${this.parsed.org}/sites/${this.parsed.site}/source`;return n?`${r}/${n}`:r}toListPath(e){return`${this.toSourcePath(e)}/`}request(e,t,n){return this.transport({method:e,path:t,origin:u,headers:n?.headers,body:n?.body})}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=await this.request(`GET`,this.toSourcePath(t));if(r.status===404)throw await this.cache.invalidateBody(t),new c(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new c(`EIO`,`aem readFile failed: ${r.status}`,e);let i=new Uint8Array(await r.arrayBuffer());if(i.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,i,m(r.headers.get(`last-modified`))),i}async assertUnchanged(e,t,n){if(!n)return;let r=await this.request(`HEAD`,this.toSourcePath(t));if(r.status===404)return;if(r.status>=400)throw new c(`EIO`,`aem precondition HEAD failed: ${r.status}`,e);let i=m(r.headers.get(`last-modified`));if(i&&i!==n)throw await this.cache.invalidateBody(t),new c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);await this.assertUnchanged(e,n,r?.etag??``);let i=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(i.status===401||i.status===403)throw new c(`EACCES`,`aem write denied`,e);if(i.status>=400)throw new c(`EIO`,`aem writeFile failed: ${i.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}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.request(`GET`,this.toListPath(t));if(r.status===404)throw new c(`ENOENT`,`no such directory`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new c(`EIO`,`aem list failed: ${r.status}`,e);let i=g(await r.json());return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e);if(t===``)return{kind:`directory`,size:0,mtime:0};let 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),s=(o&&!this.cache.isStale(o.cachedAt)?o.entries:await this.readDirQuietly(a))?.find(e=>e.name===i);if(!s)throw new c(`ENOENT`,`no such file or directory`,e);return s.kind===`directory`?{kind:`directory`,size:0,mtime:s.lastModified??0}:{kind:`file`,size:s.size??0,mtime:s.lastModified??0,etag:s.etag??``}}async readDirQuietly(e){try{return await this.readDir(e)}catch{return null}}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.request(`DELETE`,this.toSourcePath(t));if(n.status===404)throw new c(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new c(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new c(`EIO`,`aem 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.request(`GET`,this.toListPath(e));if(r.status===404){await this.cache.putListing(e,[]);return}if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=g(await r.json());for(let r of i){let i=e?`${e}/${r.name}`:r.name;r.kind===`directory`?n.push(i):await this.classifyFile(i,r.etag??``,t)}await this.cache.putListing(e,i)}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.site}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function v(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 y(e){return e.split(`/`).pop()||`data`}function b(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 x=5242880,S=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=b(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??x,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`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 c(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new c(`EACCES`,`da access denied`,e);if(i.status>=400)throw new c(`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 c(`EFBIG`,`body exceeds maxBodyBytes`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new c(`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,s,u),s}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),i=await this.cache.getBody(r),a=v(y(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 s=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:o,body:a.body}),l,u=1;try{l=await s()}catch{u=2,l=await s()}if(l.status===412){if(u===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new c(`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 c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new c(`EACCES`,`da write denied`,e);if(l.status>=400)throw new c(`EIO`,`da writeFile failed: ${l.status}`,e);let d=l.headers.get(`etag`)??``;await this.cache.putBody(r,n,d);let f=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(f)}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 c(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new c(`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 c(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.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(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new c(`ENOENT`,`no such file or directory`,e)}throw new c(`EIO`,`da stat failed: ${s.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 c(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new c(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new c(`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 C(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 w=26214400,T=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=C(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??w,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`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 c(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new c(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new c(`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 c(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``;return await this.cache.putBody(t,s,l),s}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new c(`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,s=1;try{o=await a()}catch{s=2,o=await a()}if(o.status===412){if(s===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new c(`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 c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new c(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new c(`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 c(`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 c(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new c(`ENOENT`,`no such file or directory`,e)}throw new c(`EIO`,`s3 stat failed: ${s.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 c(`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 c(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new c(`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}},E=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function D(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-DG6fHM_V.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,20,21,22,23,24,25,26])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new E(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var O=`slicc-mount-cache`,k=`listings`,A=`bodies`,j=class{mountId;ttlMs;dbName;dbPromise=null;constructor(e){this.mountId=e.mountId,this.ttlMs=e.ttlMs,this.dbName=e.dbName??O}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(k)||e.createObjectStore(k),e.objectStoreNames.contains(A)||e.createObjectStore(A)},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(k,`readonly`).objectStore(k).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(k,`readwrite`),o={entries:t,cachedAt:Date.now()};a.objectStore(k).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(k,`readwrite`);i.objectStore(k).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(A,`readonly`).objectStore(A).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,A,this.key(e),i)}catch(t){if(t instanceof DOMException&&t.name===`QuotaExceededError`){await this.evictLru(.25);try{await this.txPut(r,A,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(A,`readwrite`);i.objectStore(A).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(k),n(A)])}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(A,`readonly`).objectStore(A),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(A,`readwrite`),i=r.objectStore(A);for(let{key:e}of a)i.delete(e);r.oncomplete=()=>e(),r.onerror=()=>n(r.error)})}},M=r,N=n,P=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),F=new Set([101,103,204,205,304]);function I(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new c(`EACCES`,e.error):e.errorCode===`invalid_request`?new c(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||P.has(String(e.errorCode))?new c(`EIO`,e.error):new c(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=M(e.bodyBase64)}catch(e){throw new c(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=F.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function L(e,t){let n;try{n=await fetch(a(e),{method:`POST`,headers:s({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new c(`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 c(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function R(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new c(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function z(e,t,n){return i()?R(e,n):o()?l(e,n):L(t,n)}function B(e){return async t=>I(await z(`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?N(t.body):void 0}))}function V(e){let t=e?.getImsToken??(async()=>(await D()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new c(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return I(await z(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?N(e.body):void 0}))}}export{_ as AemMountBackend,S as DaMountBackend,j as RemoteMountCache,T as S3MountBackend,V as makeSignedFetchDa,B as makeSignedFetchS3};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-BaTmqQCH.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-C0HLsjny.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-BxrUfzom.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-CFWkfPNA.js","assets/base64-DJRlyqZu.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-GRCyib6X.js","assets/float-topology-BYb7rxY5.js","assets/runtime-env-E-i2SW1s.js","assets/secret-topology-BE7Eyd3P.js","assets/secrets-bridge-client-CHZomqvU.js","assets/port-bridge-client-Cti-DmEY.js","assets/image-markers-CxJ9ZBgw.js","assets/tool-ui-DfXu6quJ.js","assets/providers-N-GzEZuq.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-Czpn1I53.js";import{n as t}from"./mime-types-k2E6ulyv.js";import{r as n,t as r}from"./base64-DJRlyqZu.js";import"./src-CAWTvdAa.js";import{n as i}from"./runtime-env-Dlaokqg1.js";import{i as a,n as o,t as s}from"./api-endpoint-GRCyib6X.js";import"./runtime-env-E-i2SW1s.js";import{t as c}from"./types-idfTVsM8.js";import"./mount-table-store-dY2IfQ5S.js";import"./fs-CiufgGRG.js";import{t as l}from"./mount-bridge-client-BJeJ5p60.js";var u=`https://api.aem.live`,d=`application/folder`,f=5242880;function p(e){let t=e.match(/^aem:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid AEM source '${e}' — expected aem://org/site[/path]`);return{org:t[1],site:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}function m(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function h(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function g(e){return e.map(e=>e[`content-type`]===d||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:m(e[`last-modified`]),lastModified:h(e[`last-modified`])})}var _=class{kind=`aem`;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=p(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??f,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`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(`/`),r=`/${this.parsed.org}/sites/${this.parsed.site}/source`;return n?`${r}/${n}`:r}toListPath(e){return`${this.toSourcePath(e)}/`}request(e,t,n){return this.transport({method:e,path:t,origin:u,headers:n?.headers,body:n?.body})}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=await this.request(`GET`,this.toSourcePath(t));if(r.status===404)throw await this.cache.invalidateBody(t),new c(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new c(`EIO`,`aem readFile failed: ${r.status}`,e);let i=new Uint8Array(await r.arrayBuffer());if(i.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,i,m(r.headers.get(`last-modified`))),i}async assertUnchanged(e,t,n){if(!n)return;let r=await this.request(`HEAD`,this.toSourcePath(t));if(r.status===404)return;if(r.status>=400)throw new c(`EIO`,`aem precondition HEAD failed: ${r.status}`,e);let i=m(r.headers.get(`last-modified`));if(i&&i!==n)throw await this.cache.invalidateBody(t),new c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);await this.assertUnchanged(e,n,r?.etag??``);let i=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(i.status===401||i.status===403)throw new c(`EACCES`,`aem write denied`,e);if(i.status>=400)throw new c(`EIO`,`aem writeFile failed: ${i.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}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.request(`GET`,this.toListPath(t));if(r.status===404)throw new c(`ENOENT`,`no such directory`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new c(`EIO`,`aem list failed: ${r.status}`,e);let i=g(await r.json());return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e);if(t===``)return{kind:`directory`,size:0,mtime:0};let 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),s=(o&&!this.cache.isStale(o.cachedAt)?o.entries:await this.readDirQuietly(a))?.find(e=>e.name===i);if(!s)throw new c(`ENOENT`,`no such file or directory`,e);return s.kind===`directory`?{kind:`directory`,size:0,mtime:s.lastModified??0}:{kind:`file`,size:s.size??0,mtime:s.lastModified??0,etag:s.etag??``}}async readDirQuietly(e){try{return await this.readDir(e)}catch{return null}}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.request(`DELETE`,this.toSourcePath(t));if(n.status===404)throw new c(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new c(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new c(`EIO`,`aem 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.request(`GET`,this.toListPath(e));if(r.status===404){await this.cache.putListing(e,[]);return}if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=g(await r.json());for(let r of i){let i=e?`${e}/${r.name}`:r.name;r.kind===`directory`?n.push(i):await this.classifyFile(i,r.etag??``,t)}await this.cache.putListing(e,i)}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.site}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function v(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 y(e){return e.split(`/`).pop()||`data`}function b(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 x=5242880,S=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=b(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??x,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`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 c(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new c(`EACCES`,`da access denied`,e);if(i.status>=400)throw new c(`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 c(`EFBIG`,`body exceeds maxBodyBytes`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new c(`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,s,u),s}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),i=await this.cache.getBody(r),a=v(y(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 s=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:o,body:a.body}),l,u=1;try{l=await s()}catch{u=2,l=await s()}if(l.status===412){if(u===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new c(`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 c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new c(`EACCES`,`da write denied`,e);if(l.status>=400)throw new c(`EIO`,`da writeFile failed: ${l.status}`,e);let d=l.headers.get(`etag`)??``;await this.cache.putBody(r,n,d);let f=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(f)}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 c(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new c(`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 c(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.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(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new c(`ENOENT`,`no such file or directory`,e)}throw new c(`EIO`,`da stat failed: ${s.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 c(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new c(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new c(`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 C(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 w=26214400,T=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=C(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??w,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`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 c(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new c(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new c(`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 c(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``;return await this.cache.putBody(t,s,l),s}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new c(`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,s=1;try{o=await a()}catch{s=2,o=await a()}if(o.status===412){if(s===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new c(`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 c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new c(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new c(`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 c(`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 c(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new c(`ENOENT`,`no such file or directory`,e)}throw new c(`EIO`,`s3 stat failed: ${s.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 c(`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 c(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new c(`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}},E=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function D(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-BaTmqQCH.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,20,21,22,23,24,25,26])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new E(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var O=`slicc-mount-cache`,k=`listings`,A=`bodies`,j=class{mountId;ttlMs;dbName;dbPromise=null;constructor(e){this.mountId=e.mountId,this.ttlMs=e.ttlMs,this.dbName=e.dbName??O}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(k)||e.createObjectStore(k),e.objectStoreNames.contains(A)||e.createObjectStore(A)},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(k,`readonly`).objectStore(k).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(k,`readwrite`),o={entries:t,cachedAt:Date.now()};a.objectStore(k).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(k,`readwrite`);i.objectStore(k).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(A,`readonly`).objectStore(A).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,A,this.key(e),i)}catch(t){if(t instanceof DOMException&&t.name===`QuotaExceededError`){await this.evictLru(.25);try{await this.txPut(r,A,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(A,`readwrite`);i.objectStore(A).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(k),n(A)])}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(A,`readonly`).objectStore(A),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(A,`readwrite`),i=r.objectStore(A);for(let{key:e}of a)i.delete(e);r.oncomplete=()=>e(),r.onerror=()=>n(r.error)})}},M=r,N=n,P=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),F=new Set([101,103,204,205,304]);function I(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new c(`EACCES`,e.error):e.errorCode===`invalid_request`?new c(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||P.has(String(e.errorCode))?new c(`EIO`,e.error):new c(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=M(e.bodyBase64)}catch(e){throw new c(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=F.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function L(e,t){let n;try{n=await fetch(a(e),{method:`POST`,headers:s({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new c(`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 c(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function R(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new c(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function z(e,t,n){return i()?R(e,n):o()?l(e,n):L(t,n)}function B(e){return async t=>I(await z(`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?N(t.body):void 0}))}function V(e){let t=e?.getImsToken??(async()=>(await D()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new c(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return I(await z(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?N(e.body):void 0}))}}export{_ as AemMountBackend,S as DaMountBackend,j as RemoteMountCache,T as S3MountBackend,V as makeSignedFetchDa,B as makeSignedFetchS3};