diff --git a/CHANGELOG.md b/CHANGELOG.md
index 940fd62..aa1256f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog
+## 0.3.1
+
+- Resume videos and restart HTML wallpapers after focus or visibility interruptions without changing the selected wallpaper. HTML simulation state resets on recovery; sandbox restrictions stay unchanged.
+- Fix a catalog refresh-completion race and simplify thumbnail ownership, header alignment, gallery controls and styles.
+- Consolidate overlapping tests and verify folder deletion/recreation under Desktop's Node runtime, including direct folders, aliases and atomic replacements.
+
## 0.3.0
- Add muted, looping MP4 and WebM wallpapers, animated GIF and APNG uploads, and self-contained HTML wallpapers.
diff --git a/README.md b/README.md
index aaf6684..0d282b9 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,15 @@
# OpenCode Backdrop
-
Use your own wallpapers in OpenCode Desktop. Supports OpenCode 2.2.x from 2.2.6, 2.3.x from 2.3.2, and 2.4.x from 2.4.3 through the GUI plugin API.
-
+
Use your own wallpapers in OpenCode Desktop.
+
+
+
+https://github.com/user-attachments/assets/72617017-5f4d-4153-94dd-635d6eaea54d
## Install
```sh
-opencode plugin add 'github:viralcodex/opencode-backdrop#v0.3.0'
+opencode plugin add 'github:viralcodex/opencode-backdrop#v0.3.1'
```
This installs the plugin globally. Alternatively, add it to your global `opencode.json` or `opencode.jsonc`, keeping any existing plugins. Do not add it to `cli.json`.
@@ -14,39 +17,25 @@ This installs the plugin globally. Alternatively, add it to your global `opencod
```jsonc
{
"$schema": "https://opencode.ai/config.json",
- "plugins": ["github:viralcodex/opencode-backdrop#v0.3.0"],
+ "plugins": ["github:viralcodex/opencode-backdrop#v0.3.1"],
}
```
## Use
+Images and HTML (WebGL self-contained animated wallpapers) must be non-empty and no larger than 8 MiB and videos can be up to 256 MiB.
1. Open **Settings > Wallpapers**.
2. Choose **Change folder** to use a local folder, or **+** to upload an image.
3. Select a wallpaper and adjust tint, brightness and fit.
-Wallpaper starts off with an empty gallery. Wallpapers and preferences stay local and are not sent to models. Images and HTML must be non-empty and no larger than 8 MiB; videos can be up to 256 MiB.
-
-- Folders support PNG, JPEG, WebP, SVG, GIF, APNG, MP4, WebM, and self-contained HTML, including subfolders. Changes appear automatically.
-- Uploads support PNG, JPEG, WebP, GIF and APNG. Add video and HTML through the wallpaper folder.
-- Videos play muted and loop continuously. MP4 with H.264 is recommended; other codecs depend on Desktop support. Animated images keep their original animation.
-- HTML wallpapers run in a sandbox without access to the OpenCode interface or local storage. CSP blocks external scripts, styles, assets, and fetch requests. Embed everything in the HTML and use files from sources you trust. This is not a network firewall; a script can still navigate its own frame to another URL.
-- Filter the gallery by **All wallpapers**, **Static**, or **Live**. Live tiles have a small play icon beside their name. Hover or keyboard-focus a live tile to preview it without changing your selected wallpaper.
-- Videos and animated images show static thumbnail frames until previewed. For an HTML poster, put `Name.poster.png`, `.jpg`, `.jpeg`, or `.webp` beside `Name.html`. Poster files stay out of the gallery. Without a poster, HTML tiles show a live-wallpaper label until previewed.
-- The gallery shows at most two rows, including the **+** tile. Use **Show more** to see all wallpapers, or **Show less** to collapse it.
-- More tint improves text contrast. **Fill background** crops the image; **Show whole image** keeps it fully visible.
-- Use `/wallpaper` in chat to switch images or turn wallpaper off. Escape cancels the picker.
-- Turn **Show wallpaper** off to restore the app's backgrounds without losing your choices.
-- Turn **Wallpaper slideshow** on to cycle through all wallpapers in gallery order, regardless of the gallery filter. Choose **None** or **Fade** and set **Display time** in seconds, from 5 to 86400. The default is 60 seconds. Slideshow needs at least two wallpapers. Fades apply between images and respect reduced-motion settings; video and HTML switch instantly. Live playback itself does not pause under reduced motion.
-
-To remove an upload, hover or focus its tile and click **X**. Remove folder wallpapers by moving or deleting their source files.
-
-## Koi Pond example
-
-[Koi Pond](https://github.com/Himanshu-Sangshetti/koipond) is a live WebGL wallpaper, not a video. Download `koipond-linux.tar.gz` from its [wallpaper release](https://github.com/Himanshu-Sangshetti/koipond/releases/tag/wallpaper-v0.2.0), extract `web/index.html`, and save it in your wallpaper folder as `Koi Pond.html`. No installer is needed. Select it in **Settings > Wallpapers**.
-
-Save the repo's [poster image](https://raw.githubusercontent.com/Himanshu-Sangshetti/koipond/main/.github/assets/hero.webp) beside it as `Koi Pond.poster.webp` to show the pond before hovering.
-
-Other HTML animations work the same way when bundled into one file. The wallpaper cannot intercept clicks or read the OpenCode interface. HTML fills the panel; the fit setting applies to images and videos.
+## Features
+1. Use `/wallpaper` in chat to switch images or turn wallpaper off.
+2. Folders support PNG, JPEG, WebP, SVG, GIF, APNG, MP4, WebM, and self-contained HTML, including subfolders.
+3. Uploads support PNG, JPEG, WebP, GIF and APNG. Add video and HTML through the wallpaper folder.
+4. Videos play muted and loop continuously. MP4 with H.264 is recommended; other codecs depend on Desktop support.
+5. HTML wallpapers run in a sandbox without access to the OpenCode interface or local storage. (CSP blocks external scripts, styles, assets, and fetch requests. Add only from trusted sources.)
+6. Turn **Wallpaper slideshow** on to cycle through all wallpapers in gallery order, regardless of the gallery filter.
+7. Choose **Fade** and set **Display time** in seconds, from 5 to 86400. The default is 60 seconds.
## Optional folder configuration
@@ -57,7 +46,7 @@ You can set an initial folder with an absolute path instead of choosing one in S
"$schema": "https://opencode.ai/config.json",
"plugins": [
{
- "package": "github:viralcodex/opencode-backdrop#v0.3.0",
+ "package": "github:viralcodex/opencode-backdrop#v0.3.1",
"options": { "folder": "/absolute/path/to/wallpapers" },
},
],
@@ -68,15 +57,9 @@ The folder chosen in Settings takes precedence over this option.
## Development
-Use Bun 1.4.4, as pinned in `package.json`, so the generated bundle matches CI.
+Use Bun 1.4.4, as pinned in `package.json`.
```sh
bun run check
bun run test:storage /path/to/opencode
```
-
-`check` rebuilds the GUI bundle and runs unit, native Node filesystem-watcher, headless Chrome, and package checks. Set `CHROME_BIN` to a Chrome or Chromium executable if it is installed elsewhere. The PR workflow runs these checks and rejects a stale committed bundle. `test:storage` checks migration against an OpenCode checkout's actual persistence decoder. Pass the checkout path or set `OPENCODE_CHECKOUT`.
-
-## Release
-
-See [CHANGELOG.md](CHANGELOG.md) for the 0.3.0 release notes. Before tagging `v0.3.0`, run `bun install --frozen-lockfile --ignore-scripts` and `bun run check`, then commit the rebuilt `dist/gui-experimental.cjs` with the source changes. Run the host-storage check against a supported OpenCode checkout and smoke-test the installed package in Desktop. Keep the local `showcase/` captures and artwork out of this PR.
diff --git a/dist/gui-experimental.cjs b/dist/gui-experimental.cjs
index c511d1e..6754a4e 100644
--- a/dist/gui-experimental.cjs
+++ b/dist/gui-experimental.cjs
@@ -1,12 +1,12 @@
-"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("solid-js/web"),Z=require("@opencode/plugin/gui"),u=require("solid-js"),p=require("effect"),he=require("solid-js/store"),Se=require("node:fs"),X=require("node:fs/promises"),U=require("node:path"),Be=require("node:os"),Fe=require("node:crypto"),Ne=require("node:http"),qe=require("node:stream/promises"),te=8*1024*1024,He=256*1024*1024,De=p.Schema.Struct({id:p.Schema.String,title:p.Schema.String,version:p.Schema.String,kind:p.Schema.optional(p.Schema.Literals(["video","html"])),animated:p.Schema.optional(p.Schema.Boolean),poster:p.Schema.optional(p.Schema.Struct({id:p.Schema.String,version:p.Schema.String}))}),ue=p.Schema.Struct({id:p.Schema.String,version:p.Schema.String}),ke=Z.Ipc.define({id:"wallpaper.catalog.v7",state:p.Schema.Struct({folder:p.Schema.String,folderLabel:p.Schema.optional(p.Schema.String),ready:p.Schema.Boolean,images:p.Schema.Array(De),error:p.Schema.String}),methods:{refresh:{output:p.Schema.Boolean},setFolder:{input:p.Schema.NonEmptyString,output:p.Schema.Boolean},read:{input:ue,output:p.Schema.String},source:{input:ue,output:p.Schema.String}}}),Ve=/^[A-Za-z0-9+/]+={0,2}$/,Ge=new Set(["image/png","image/jpeg","image/webp","image/gif","image/apng"]),Ae=p.Schema.String.check(p.Schema.isPattern(/^(?:data:image\/(?:png|jpeg|webp|gif|apng);base64,[A-Za-z0-9+/]+={0,2})?$/),p.Schema.isMaxLength(23+4*Math.ceil(te/3)),p.Schema.makeFilter(e=>{const t=ce(e);return!e||t.length%4===0&&Re(t)<=te}));function Ke(e){if(!Ge.has(e.type))throw new Error("image.typeError");if(e.size===0||e.size>te)throw new Error("image.sizeError")}function Le(e,t){if(t==="image/gif"||t==="image/apng")return!0;if(t==="image/webp")return e.length>20&&new TextDecoder().decode(e.subarray(12,16))==="VP8X"&&!!(e[20]&2);if(t==="image/svg+xml")return/<(?:animate\w*|set)\b|\banimation(?:-[\w-]+)?\s*[:=]/i.test(new TextDecoder().decode(e).replace(//g,""));if(t!=="image/png")return!1;const r=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let a=8;a+12<=e.length;a+=r.getUint32(a)+12){const n=r.getUint32(a+4);if(n===1633899596)return a+16<=e.length&&r.getUint32(a+8)>1;if(n===1229209940)return!1}return!1}function be(e){const t=/^data:(image\/(?:png|jpeg|webp|gif|apng|svg\+xml))(;base64)?,([\s\S]+)$/.exec(e);if(!t)throw new Error("image.decodeError");const[,r,a,n]=t;if(a&&(n.length%4!==0||Re(n)>te||!Ve.test(n)))throw new Error("image.decodeError");if(!a&&r!=="image/svg+xml")throw new Error("image.decodeError");try{const i=new Blob([a?Uint8Array.from(atob(n),l=>l.charCodeAt(0)):decodeURIComponent(n)],{type:r});if(i.size===0||i.size>te)throw new Error("image.decodeError");return i}catch(i){throw new Error("image.decodeError",{cause:i})}}async function we(e,t){t.throwIfAborted();const r=new Image,a=()=>{r.src=""};t.addEventListener("abort",a,{once:!0});try{return r.src=e,await r.decode(),t.throwIfAborted(),r}catch(n){throw t.throwIfAborted(),new Error("image.decodeError",{cause:n})}finally{t.removeEventListener("abort",a)}}async function Je(e,t){t.throwIfAborted();const r=URL.createObjectURL(be(e));try{const a=await we(r,t);return await Me(a,a.naturalWidth,a.naturalHeight,t)}finally{URL.revokeObjectURL(r)}}async function Me(e,t,r,a){a.throwIfAborted();const n=document.createElement("canvas"),i=Math.min(1,320/t,200/r);n.width=Math.max(1,Math.round(t*i)),n.height=Math.max(1,Math.round(r*i));const l=n.getContext("2d");if(!l)throw new Error("image.decodeError");l.drawImage(e,0,0,n.width,n.height);const s=await new Promise((c,g)=>{n.toBlob(h=>h?c(h):g(new Error("image.decodeError")),"image/png")});return a.throwIfAborted(),{blob:s,width:n.width,height:n.height}}async function Xe(e,t){t.throwIfAborted(),Ke(e);const r=URL.createObjectURL(e);try{await we(r,t)}finally{URL.revokeObjectURL(r)}return t.throwIfAborted(),new Promise((a,n)=>{const i=new FileReader,l=()=>i.abort(),s=()=>t.removeEventListener("abort",l);i.onload=()=>{s(),typeof i.result!="string"?n(new Error("image.readError")):a(i.result)},i.onerror=()=>{s(),n(new Error("image.readError"))},i.onabort=()=>{s(),n(t.reason)},t.addEventListener("abort",l,{once:!0});try{i.readAsDataURL(e)}catch(c){s(),n(new Error("image.readError",{cause:c}))}})}function ge(e,t){return e.startsWith("image.")?t(e):`${t("image.readError")} ${e}`}function ce(e){return e.slice(e.indexOf(",")+1)}function Re(e){return e.length/4*3-(e.endsWith("==")?2:e.endsWith("=")?1:0)}const K={tint:{min:0,max:100,initial:80},brightness:{min:25,max:150,initial:100}},Ie=["tint","brightness"],J={min:5,max:86400,duration:60,transition:"fade"},Te=800,Ze=p.Schema.Struct({id:p.Schema.String.check(p.Schema.isPattern(/^(?:custom|upload:.+)$/)),name:p.Schema.String.check(p.Schema.isMinLength(1)),image:Ae.check(p.Schema.isMinLength(1))}),H={enabled:p.Schema.Boolean,preset:p.Schema.String,images:p.Schema.Array(Ze).check(p.Schema.makeFilter(e=>new Set(e.map(t=>t.id)).size===e.length)),tint:p.Schema.Int.check(p.Schema.isBetween({minimum:K.tint.min,maximum:K.tint.max})),brightness:p.Schema.Int.check(p.Schema.isBetween({minimum:K.brightness.min,maximum:K.brightness.max})),fit:p.Schema.Literals(["cover","contain"]),slideshow:p.Schema.Boolean,duration:p.Schema.Int.check(p.Schema.isBetween({minimum:J.min,maximum:J.max})),transition:p.Schema.Literals(["none","fade"])},G=p.Schema.Struct({...H,images:p.Schema.optional(H.images),tint:p.Schema.optional(H.tint),brightness:p.Schema.optional(H.brightness),slideshow:p.Schema.optional(H.slideshow),duration:p.Schema.optional(H.duration),transition:p.Schema.optional(H.transition),image:p.Schema.optional(Ae),imageName:p.Schema.optional(p.Schema.String),strength:p.Schema.optional(p.Schema.Int.check(p.Schema.isBetween({minimum:5,maximum:45}))),hidden:p.Schema.optional(p.Schema.Array(p.Schema.String))}),Qe=G.pipe(p.Schema.decodeTo(p.Schema.Struct(H),{decode:p.SchemaGetter.transform(e=>({enabled:e.enabled,preset:e.preset,fit:e.fit,images:e.image&&!e.images?.some(t=>t.id==="custom")?[{id:"custom",name:e.imageName||"Wallpaper",image:e.image},...e.images??[]]:e.images??[],tint:e.tint??(e.strength===void 0?K.tint.initial:100-e.strength),brightness:e.brightness??K.brightness.initial,slideshow:e.slideshow??!1,duration:e.duration??J.duration,transition:e.transition??J.transition})),encode:p.SchemaGetter.transform(e=>e)})),ee={enabled:!1,preset:"",images:[],tint:K.tint.initial,brightness:K.brightness.initial,fit:"cover",slideshow:!1,duration:J.duration,transition:J.transition};function q(e,t){return p.Schema.withDecodingDefaultType(p.Effect.succeed(t))(e).pipe(p.Schema.catchDecoding(()=>p.Effect.succeed(p.Option.some(t))))}const Ye=p.Schema.Struct({enabled:q(H.enabled,ee.enabled),preset:q(H.preset,ee.preset),fit:q(H.fit,ee.fit),images:q(G.fields.images,void 0),tint:q(G.fields.tint,void 0),brightness:q(G.fields.brightness,void 0),slideshow:q(G.fields.slideshow,void 0),duration:q(G.fields.duration,void 0),transition:q(G.fields.transition,void 0),image:q(G.fields.image,void 0),imageName:q(G.fields.imageName,void 0),strength:q(G.fields.strength,void 0)}).pipe(p.Schema.decodeTo(Qe));function We(e){return{tint:e.tint,brightness:e.brightness}}function oe(e,t){return e?.id===t?.id&&e?.version===t?.version&&e?.image===t?.image&&e?.kind===t?.kind&&e?.animated===t?.animated&&e?.poster?.id===t?.poster?.id&&e?.poster?.version===t?.poster?.version}function Q(e){return!!e.kind||!!e.animated}function et(e,t){return t==="all"?e:e.filter(r=>Q(r)===(t==="live"))}function me(e,t){return t.find(r=>r.id===e.preset)}function ze(e){return e.images}function tt(e=[],t=ee,r=[]){const a=new Map(r.map(n=>[n.id,n]));return[...e,...ze(t).map(n=>{const i=Pe(n.name),l=a.get(n.id);if(l?.image===n.image&&l.title===i)return l;const s=n.image.slice(5,n.image.indexOf(";")),c=Uint8Array.from(atob(ce(n.image).slice(0,87380)),g=>g.charCodeAt(0));return{id:n.id,title:i,version:"custom",image:n.image,...Le(c,s)?{animated:!0}:{}}})]}function ve(e){return e.id==="custom"||e.id.startsWith("upload:")}function rt(e,t,r){if(!ve(t)||(e.images=e.images.filter(n=>n.id!==t.id),e.preset!==t.id))return;const a=r[r.findIndex(n=>n.id===t.id)+1]??r.find(n=>n.id!==t.id);e.preset=a?.id??ee.preset,a||(e.enabled=!1)}function ye(e,t){e.enabled=t!=="off",t!=="off"&&(e.preset=t)}function at(e,t,r){ye(e,t?me(e,r)?.id??r[0]?.id??"off":"off")}function Y(e,t){return ve(e)?e.title||t("image.custom"):e.title}function xe(e,t,r){const a=pe(e.name),n=ce(e.image??"");for(const i of ze(t)){if(i.name&&pe(i.name)===a)throw new Error("image.duplicateName");if(n&&n===ce(i.image))throw new Error("image.duplicateImage")}for(const i of r){const l=nt(i.id);if(l&&pe(l)===a)throw new Error("image.duplicateName")}}function nt(e){if(!e.startsWith("file:"))return"";const t=e.slice(5);return decodeURIComponent(t)}function pe(e){return Pe(e).normalize("NFC").toLowerCase()}function Pe(e){const t=(e.split(/[\\/]/).at(-1)??e).trim();return t.replace(/\.(?:png|jpe?g|webp|svg|gif|apng|mp4|webm|html?)$/i,"")||t}function ot(e,t,r,a,n,i){return{id:"choose",title:e.t("picker.title"),description:e.t("picker.description"),keywords:"wallpaper background image",slash:{name:"wallpaper"},async run(){e.signal.aborted||(await r(),!e.signal.aborted&&i({title:e.t("picker.title"),placeholder:e.t("picker.search"),current:a(),options:t().map(l=>({title:Y(l,e.t),value:l.id}))},l=>{if(!e.signal.aborted){if(l==="settings"){e.layout.settings("wallpaper");return}n(l)}}))}}}function _e(e){return u.createMemo(()=>{const t=e();return t?{...t}:void 0},void 0,{equals:oe})}function it(e,t,r){const[a,n]=u.createSignal(e()),[i,l]=u.createSignal();let s;const c=()=>{clearTimeout(s),s=void 0},g=h=>{c();const A=t()&&!r()?Te:0;u.batch(()=>{l(A?{show:h,duration:A}:void 0),!A&&!h&&n(!1)}),A&&(s=setTimeout(()=>{s=void 0,u.batch(()=>{l(void 0),h||n(!1)})},A))};return u.createEffect(u.on(()=>[e(),r()],([h,A])=>{if(c(),!h)return g(!1);n(!0),A&&l(void 0)})),u.createEffect(u.on(()=>e()&&t(),(h,A)=>{h&&!A&&g(!0)})),u.onCleanup(c),{enabled:a,fade:i}}function lt(e,t,r=()=>0){const[a,n]=he.createStore({url:"",width:0,height:0,loading:!1,error:"",choice:void 0,previous:void 0,transition:0});let i;const l=()=>{clearTimeout(i),i=void 0,a.previous&&URL.revokeObjectURL(a.previous.url),n({previous:void 0,transition:0})};u.onCleanup(()=>{l(),a.url&&URL.revokeObjectURL(a.url)});const s=_e(e);return u.createEffect(u.on(s,c=>{const g=new AbortController;let h="";if(u.onCleanup(()=>{g.abort(),h&&URL.revokeObjectURL(h),h=""}),n({loading:!!c,error:""}),!c){l(),a.url&&URL.revokeObjectURL(a.url),n({url:"",width:0,height:0,choice:void 0});return}if(a.url&&oe(c,a.choice)){n({loading:!1});return}(async()=>{try{const A=c.image??await t(c,g.signal);g.signal.throwIfAborted(),h=URL.createObjectURL(be(A));const b=await we(h,g.signal);g.signal.throwIfAborted(),l();const w=u.untrack(r),k=a.url&&w>0?{url:a.url,width:a.width,height:a.height}:void 0;a.url&&!k&&URL.revokeObjectURL(a.url);const z={url:h,width:b.naturalWidth,height:b.naturalHeight};h="",n({...z,choice:c,previous:k,transition:k?w:0,loading:!1,error:""}),k&&(i=setTimeout(l,w))}catch(A){h&&URL.revokeObjectURL(h),h="",g.signal.aborted||n({loading:!1,error:A instanceof Error?A.message:String(A)})}})()})),a}function st(e,t){const[r,a]=he.createStore({url:"",width:0,height:0,loading:!1,error:""}),n=_e(e);return u.createRenderEffect(()=>{const i=n(),l=new AbortController;let s;if(u.onCleanup(()=>{l.abort(),s?.release()}),a({url:"",width:0,height:0,loading:!!i,error:""}),!!i)try{if(s=t.acquire(i),s.value){a({...s.value,loading:!1});return}s.ready.then(c=>{l.signal.aborted||a({...c,loading:!1})},c=>{l.signal.aborted||a({loading:!1,error:c instanceof Error?c.message:String(c)})})}catch(c){a({loading:!1,error:c instanceof Error?c.message:String(c)})}}),r}function ct(e){const t=new Map;return Object.assign((a,n,i)=>{const l=t.get(a)??new Set,s=new Set(i.filter(Boolean)),c=[...s].filter(g=>!l.has(g));s.size?t.set(a,s):t.delete(a),c.length&&e.show({variant:"error",icon:"outline-photo",title:n,description:c.join(`
+"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("solid-js/web"),X=require("@opencode/plugin/gui"),u=require("solid-js"),p=require("effect"),fe=require("solid-js/store"),ye=require("node:fs"),J=require("node:fs/promises"),j=require("node:path"),_e=require("node:os"),je=require("node:crypto"),Oe=require("node:http"),Be=require("node:stream/promises"),ee=8*1024*1024,Fe=256*1024*1024,se=p.Schema.Struct({id:p.Schema.String,version:p.Schema.String}),Ne=p.Schema.Struct({id:p.Schema.String,title:p.Schema.String,version:p.Schema.String,kind:p.Schema.optional(p.Schema.Literals(["video","html"])),animated:p.Schema.optional(p.Schema.Boolean),poster:p.Schema.optional(se)}),Se=X.Ipc.define({id:"wallpaper.catalog.v7",state:p.Schema.Struct({folder:p.Schema.String,folderLabel:p.Schema.optional(p.Schema.String),ready:p.Schema.Boolean,images:p.Schema.Array(Ne),error:p.Schema.String}),methods:{refresh:{output:p.Schema.Boolean},setFolder:{input:p.Schema.NonEmptyString,output:p.Schema.Boolean},read:{input:se,output:p.Schema.String},source:{input:se,output:p.Schema.String}}}),qe=/^[A-Za-z0-9+/]+={0,2}$/,He=new Set(["image/png","image/jpeg","image/webp","image/gif","image/apng"]),Ee=p.Schema.String.check(p.Schema.isPattern(/^(?:data:image\/(?:png|jpeg|webp|gif|apng);base64,[A-Za-z0-9+/]+={0,2})?$/),p.Schema.isMaxLength(23+4*Math.ceil(ee/3)),p.Schema.makeFilter(e=>{const t=ce(e);return!e||t.length%4===0&&Me(t)<=ee}));function Ve(e){if(!He.has(e.type))throw new Error("image.typeError");if(e.size===0||e.size>ee)throw new Error("image.sizeError")}function Ae(e,t){if(t==="image/gif"||t==="image/apng")return!0;if(t==="image/webp")return e.length>20&&new TextDecoder().decode(e.subarray(12,16))==="VP8X"&&!!(e[20]&2);if(t==="image/svg+xml")return/<(?:animate\w*|set)\b|\banimation(?:-[\w-]+)?\s*[:=]/i.test(new TextDecoder().decode(e).replace(//g,""));if(t!=="image/png")return!1;const r=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let n=8;n+12<=e.length;n+=r.getUint32(n)+12){const a=r.getUint32(n+4);if(a===1633899596)return n+16<=e.length&&r.getUint32(n+8)>1;if(a===1229209940)return!1}return!1}function he(e){const t=/^data:(image\/(?:png|jpeg|webp|gif|apng|svg\+xml))(;base64)?,([\s\S]+)$/.exec(e);if(!t)throw new Error("image.decodeError");const[,r,n,a]=t;if(n&&(a.length%4!==0||Me(a)>ee||!qe.test(a)))throw new Error("image.decodeError");if(!n&&r!=="image/svg+xml")throw new Error("image.decodeError");try{const i=new Blob([n?Uint8Array.from(atob(a),l=>l.charCodeAt(0)):decodeURIComponent(a)],{type:r});if(i.size===0||i.size>ee)throw new Error("image.decodeError");return i}catch(i){throw new Error("image.decodeError",{cause:i})}}async function we(e,t){t.throwIfAborted();const r=new Image,n=()=>{r.src=""};t.addEventListener("abort",n,{once:!0});try{return r.src=e,await r.decode(),t.throwIfAborted(),r}catch(a){throw t.throwIfAborted(),new Error("image.decodeError",{cause:a})}finally{t.removeEventListener("abort",n)}}async function De(e,t){t.throwIfAborted();const r=URL.createObjectURL(he(e));try{const n=await we(r,t);return await Le(n,n.naturalWidth,n.naturalHeight,t)}finally{URL.revokeObjectURL(r)}}async function Le(e,t,r,n){n.throwIfAborted();const a=Math.min(1,320/t,200/r);t=Math.max(1,Math.round(t*a)),r=Math.max(1,Math.round(r*a));const i=new OffscreenCanvas(t,r),l=i.getContext("2d");if(!l)throw new Error("image.decodeError");l.drawImage(e,0,0,i.width,i.height);const s=await i.convertToBlob({type:"image/png"}).catch(c=>{throw new Error("image.decodeError",{cause:c})});return n.throwIfAborted(),{blob:s,width:t,height:r}}async function Ge(e,t){t.throwIfAborted(),Ve(e);const r=URL.createObjectURL(e);try{await we(r,t)}finally{URL.revokeObjectURL(r)}t.throwIfAborted();const n=new FileReader,a=()=>n.abort();return t.addEventListener("abort",a,{once:!0}),new Promise((i,l)=>{n.onload=()=>{typeof n.result!="string"?l(new Error("image.readError")):i(n.result)},n.onerror=()=>l(new Error("image.readError")),n.onabort=()=>l(t.reason);try{n.readAsDataURL(e)}catch(s){l(new Error("image.readError",{cause:s}))}}).finally(()=>t.removeEventListener("abort",a))}function ue(e,t){return e.startsWith("image.")?t(e):`${t("image.readError")} ${e}`}function ce(e){return e.slice(e.indexOf(",")+1)}function Me(e){return e.length/4*3-(e.endsWith("==")?2:e.endsWith("=")?1:0)}const G={tint:{min:0,max:100,initial:80},brightness:{min:25,max:150,initial:100}},Re=["tint","brightness"],K={min:5,max:86400,duration:60,transition:"fade"},Ie=800,Ke=p.Schema.Struct({id:p.Schema.String.check(p.Schema.isPattern(/^(?:custom|upload:.+)$/)),name:p.Schema.String.check(p.Schema.isMinLength(1)),image:Ee.check(p.Schema.isMinLength(1))}),q={enabled:p.Schema.Boolean,preset:p.Schema.String,images:p.Schema.Array(Ke).check(p.Schema.makeFilter(e=>new Set(e.map(t=>t.id)).size===e.length)),tint:p.Schema.Int.check(p.Schema.isBetween({minimum:G.tint.min,maximum:G.tint.max})),brightness:p.Schema.Int.check(p.Schema.isBetween({minimum:G.brightness.min,maximum:G.brightness.max})),fit:p.Schema.Literals(["cover","contain"]),slideshow:p.Schema.Boolean,duration:p.Schema.Int.check(p.Schema.isBetween({minimum:K.min,maximum:K.max})),transition:p.Schema.Literals(["none","fade"])},D=p.Schema.Struct({...q,images:p.Schema.optional(q.images),tint:p.Schema.optional(q.tint),brightness:p.Schema.optional(q.brightness),slideshow:p.Schema.optional(q.slideshow),duration:p.Schema.optional(q.duration),transition:p.Schema.optional(q.transition),image:p.Schema.optional(Ee),imageName:p.Schema.optional(p.Schema.String),strength:p.Schema.optional(p.Schema.Int.check(p.Schema.isBetween({minimum:5,maximum:45}))),hidden:p.Schema.optional(p.Schema.Array(p.Schema.String))}),Je=D.pipe(p.Schema.decodeTo(p.Schema.Struct(q),{decode:p.SchemaGetter.transform(e=>({enabled:e.enabled,preset:e.preset,fit:e.fit,images:e.image&&!e.images?.some(t=>t.id==="custom")?[{id:"custom",name:e.imageName||"Wallpaper",image:e.image},...e.images??[]]:e.images??[],tint:e.tint??(e.strength===void 0?G.tint.initial:100-e.strength),brightness:e.brightness??G.brightness.initial,slideshow:e.slideshow??!1,duration:e.duration??K.duration,transition:e.transition??K.transition})),encode:p.SchemaGetter.transform(e=>e)})),Y={enabled:!1,preset:"",images:[],tint:G.tint.initial,brightness:G.brightness.initial,fit:"cover",slideshow:!1,duration:K.duration,transition:K.transition};function N(e,t){return p.Schema.withDecodingDefaultType(p.Effect.succeed(t))(e).pipe(p.Schema.catchDecoding(()=>p.Effect.succeed(p.Option.some(t))))}const Xe=p.Schema.Struct({enabled:N(q.enabled,Y.enabled),preset:N(q.preset,Y.preset),fit:N(q.fit,Y.fit),images:N(D.fields.images,void 0),tint:N(D.fields.tint,void 0),brightness:N(D.fields.brightness,void 0),slideshow:N(D.fields.slideshow,void 0),duration:N(D.fields.duration,void 0),transition:N(D.fields.transition,void 0),image:N(D.fields.image,void 0),imageName:N(D.fields.imageName,void 0),strength:N(D.fields.strength,void 0)}).pipe(p.Schema.decodeTo(Je));function ne(e,t){return e?.id===t?.id&&e?.version===t?.version&&e?.image===t?.image&&e?.kind===t?.kind&&e?.animated===t?.animated&&e?.poster?.id===t?.poster?.id&&e?.poster?.version===t?.poster?.version}function Z(e){return!!e.kind||!!e.animated}function Ze(e,t){return t==="all"?e:e.filter(r=>Z(r)===(t==="live"))}function ge(e,t){return t.find(r=>r.id===e.preset)}function Qe(e=[],t=Y,r=[]){const n=new Map(r.map(a=>[a.id,a]));return[...e,...t.images.map(a=>{const i=Te(a.name),l=n.get(a.id);if(l?.image===a.image&&l.title===i)return l;const s=a.image.slice(5,a.image.indexOf(";")),c=Uint8Array.from(atob(ce(a.image).slice(0,87380)),g=>g.charCodeAt(0));return{id:a.id,title:i,version:"custom",image:a.image,...Ae(c,s)?{animated:!0}:{}}})]}function be(e){return e.id==="custom"||e.id.startsWith("upload:")}function Ye(e,t,r){if(!be(t)||(e.images=e.images.filter(a=>a.id!==t.id),e.preset!==t.id))return;const n=r[r.findIndex(a=>a.id===t.id)+1]??r.find(a=>a.id!==t.id);e.preset=n?.id??Y.preset,n||(e.enabled=!1)}function ve(e,t){e.enabled=t!=="off",t!=="off"&&(e.preset=t)}function et(e,t,r){ve(e,t?ge(e,r)?.id??r[0]?.id??"off":"off")}function Q(e,t){return be(e)?e.title||t("image.custom"):e.title}function ke(e,t,r){const n=pe(e.name),a=ce(e.image??"");for(const i of t.images){if(i.name&&pe(i.name)===n)throw new Error("image.duplicateName");if(a&&a===ce(i.image))throw new Error("image.duplicateImage")}for(const i of r){const l=tt(i.id);if(l&&pe(l)===n)throw new Error("image.duplicateName")}}function tt(e){return e.startsWith("file:")?decodeURIComponent(e.slice(5)):""}function pe(e){return Te(e).normalize("NFC").toLowerCase()}function Te(e){const t=(e.split(/[\\/]/).at(-1)??e).trim();return t.replace(/\.(?:png|jpe?g|webp|svg|gif|apng|mp4|webm|html?)$/i,"")||t}function rt(e,t,r,n,a,i){return{id:"choose",title:e.t("picker.title"),description:e.t("picker.description"),keywords:"wallpaper background image",slash:{name:"wallpaper"},async run(){e.signal.aborted||(await r(),!e.signal.aborted&&i({title:e.t("picker.title"),placeholder:e.t("picker.search"),current:n(),options:t().map(l=>({title:Q(l,e.t),value:l.id}))},l=>{if(!e.signal.aborted){if(l==="settings"){e.layout.settings("wallpaper");return}a(l)}}))}}}function We(e){return u.createMemo(()=>{const t=e();return t?{...t}:void 0},void 0,{equals:ne})}function at(e,t,r){const[n,a]=u.createSignal(e()),[i,l]=u.createSignal();let s;const c=()=>{clearTimeout(s),s=void 0},g=b=>{c();const A=t()&&!r()?Ie:0;u.batch(()=>{l(A?{show:b,duration:A}:void 0),!A&&!b&&a(!1)}),A&&(s=setTimeout(()=>{s=void 0,u.batch(()=>{l(void 0),b||a(!1)})},A))};return u.createEffect(u.on(()=>[e(),r()],([b,A])=>{if(c(),!b)return g(!1);a(!0),A&&l(void 0)})),u.createEffect(u.on(()=>e()&&t(),(b,A)=>{b&&!A&&g(!0)})),u.onCleanup(c),{enabled:n,fade:i}}function nt(e,t,r=()=>0){const[n,a]=fe.createStore({url:"",width:0,height:0,loading:!1,error:"",choice:void 0,previous:void 0,transition:0});let i;const l=()=>{clearTimeout(i),i=void 0,n.previous&&URL.revokeObjectURL(n.previous.url),a({previous:void 0,transition:0})};u.onCleanup(()=>{l(),n.url&&URL.revokeObjectURL(n.url)});const s=We(e);return u.createEffect(u.on(s,c=>{const g=new AbortController;let b="";if(u.onCleanup(()=>{g.abort(),b&&URL.revokeObjectURL(b),b=""}),a({loading:!!c,error:""}),!c){l(),n.url&&URL.revokeObjectURL(n.url),a({url:"",width:0,height:0,choice:void 0});return}if(n.url&&ne(c,n.choice)){a({loading:!1});return}(async()=>{try{const A=c.image??await t(c,g.signal);g.signal.throwIfAborted(),b=URL.createObjectURL(he(A));const m=await we(b,g.signal);g.signal.throwIfAborted(),l();const w=u.untrack(r),k=n.url&&w>0?{url:n.url,width:n.width,height:n.height}:void 0;n.url&&!k&&URL.revokeObjectURL(n.url);const C={url:b,width:m.naturalWidth,height:m.naturalHeight};b="",a({...C,choice:c,previous:k,transition:k?w:0,loading:!1,error:""}),k&&(i=setTimeout(l,w))}catch(A){b&&URL.revokeObjectURL(b),b="",g.signal.aborted||a({loading:!1,error:A instanceof Error?A.message:String(A)})}})()})),n}function ot(e,t){const[r,n]=fe.createStore({url:"",width:0,height:0,loading:!1,error:""}),a=We(e);return u.createRenderEffect(()=>{const i=a();let l=!0,s;if(u.onCleanup(()=>{l=!1,s?.release()}),n({url:"",width:0,height:0,loading:!!i,error:""}),!i)return;const c=g=>{l&&n({loading:!1,error:g instanceof Error?g.message:String(g)})};try{if(s=t.acquire(i),s.value){n({...s.value,loading:!1});return}s.ready.then(g=>{l&&n({...g,loading:!1})},c)}catch(g){c(g)}}),r}function it(e){const t=new Map;return Object.assign((n,a,i)=>{const l=t.get(n)??new Set,s=new Set(i.filter(Boolean)),c=[...s].filter(g=>!l.has(g));s.size?t.set(n,s):t.delete(n),c.length&&e.show({variant:"error",icon:"outline-photo",title:a,description:c.join(`
-`)})},{retain(a){const n=new Set(a);for(const i of t.keys())n.has(i)||t.delete(i)}})}function dt(e,{maxEntries:t=48,maxBytes:r=8*1024*1024,concurrency:a=2,signal:n}={}){const i=new Map,l=new Set,s=new Map,c=p.Semaphore.makeUnsafe(a);let g=0,h=!1;function A(d){const m=s.get(d);m!==void 0&&(s.delete(d),g-=m)}function b(d){A(d),d.value&&URL.revokeObjectURL(d.value.url),d.value=void 0,l.delete(d)}function w(d){d.retired||(A(d),i.get(d.choice.id)===d&&i.delete(d.choice.id),d.retired=!0,d.controller.abort(),d.reject(d.controller.signal.reason),d.users?l.add(d):b(d))}function k(d){if(!(d.users||d.retired))for(A(d),s.set(d,d.bytes),g+=d.bytes;s.size>t||g>r;){const m=s.keys().next().value;if(!m)break;w(m)}}function z(d){p.Effect.runPromise(c.withPermit(p.Effect.tryPromise({try:m=>e(d.choice,m),catch:m=>m})),{signal:d.controller.signal}).then(m=>{d.controller.signal.throwIfAborted(),d.value={url:URL.createObjectURL(m.blob),width:m.width,height:m.height},d.bytes=m.blob.size,d.resolve(d.value),k(d)}).catch(m=>{d.reject(m),w(d)})}function I(d){if(h)throw new DOMException("Thumbnail cache is disposed.","AbortError");let m=i.get(d.id);if(m&&!oe(m.choice,d)&&(w(m),m=void 0),!m){const{promise:T,resolve:f,reject:$}=Promise.withResolvers();m={choice:{...d},controller:new AbortController,ready:T,resolve:f,reject:$,users:0,bytes:0,retired:!1},z(m)}const E=m;A(E),E.users++,i.set(d.id,E);let C=!1;return{value:E.value,ready:E.ready,release(){C||(C=!0,E.users--,E.retired&&!E.users?b(E):k(E))}}}function y(){if(!h){h=!0,n?.removeEventListener("abort",y);for(const d of new Set([...i.values(),...l]))w(d),b(d);i.clear(),l.clear(),s.clear(),g=0}}return n?.addEventListener("abort",y,{once:!0}),n?.aborted&&y(),{acquire:I,peek(d){const m=i.get(d.id);return m&&oe(m.choice,d)?m.value:void 0},retain(d){const m=new Map(d.map(E=>[E.id,E]));for(const E of i.values())oe(E.choice,m.get(E.choice.id))||w(E)},dispose:y}}function pt(e,t){const r=document.createElement("style"),a=document.createElement("style"),n=document.createElement("style");return r.dataset.wallpaperStyle="settings",a.dataset.wallpaperStyle="canvas",n.dataset.wallpaperStyle="image",r.textContent=e,a.textContent=t,a.disabled=!0,document.head.append(r,a,n),{update(i){n.textContent=i,a.disabled=!i},dispose(){r.remove(),a.remove(),n.remove()}}}const D='[data-slot="home-panel"], [data-slot="session-chat-panel"] > .bg-v2-background-bg-base, [data-component="new-session"]',de=`
+`)})},{retain(n){const a=new Set(n);for(const i of t.keys())a.has(i)||t.delete(i)}})}function lt(e,{maxEntries:t=48,maxBytes:r=8*1024*1024,concurrency:n=2,signal:a}={}){const i=new Map,l=new Set,s=new Set,c=p.Semaphore.makeUnsafe(n);let g=0,b=!1;function A(d){s.delete(d)&&(g-=d.bytes)}function m(d){A(d),d.value&&URL.revokeObjectURL(d.value.url),d.value=void 0,l.delete(d)}function w(d){d.controller.signal.aborted||(i.get(d.choice.id)===d&&i.delete(d.choice.id),d.controller.abort(),d.result.reject(d.controller.signal.reason),d.users?l.add(d):m(d))}function k(d){if(!(d.users||d.controller.signal.aborted))for(s.add(d),g+=d.bytes;s.size>t||g>r;){const v=s.keys().next().value;if(!v)break;w(v)}}function C(d){p.Effect.runPromise(c.withPermit(p.Effect.tryPromise({try:v=>e(d.choice,v),catch:v=>v})),{signal:d.controller.signal}).then(v=>{d.controller.signal.throwIfAborted(),d.value={url:URL.createObjectURL(v.blob),width:v.width,height:v.height},A(d),d.bytes=v.blob.size,d.result.resolve(d.value),k(d)}).catch(v=>{d.result.reject(v),w(d)})}function O(d){if(b)throw new DOMException("Thumbnail cache is disposed.","AbortError");let v=i.get(d.id);v&&!ne(v.choice,d)&&(w(v),v=void 0),v||(v={choice:{...d},controller:new AbortController,result:Promise.withResolvers(),users:0,bytes:0},C(v));const y=v;A(y),y.users++,i.set(d.id,y);let I=!1;return{value:y.value,ready:y.result.promise,release(){I||(I=!0,y.users--,y.controller.signal.aborted&&!y.users?m(y):k(y))}}}function f(){if(!b){b=!0,a?.removeEventListener("abort",f);for(const d of[...i.values(),...l])w(d),m(d)}}return a?.addEventListener("abort",f,{once:!0}),a?.aborted&&f(),{acquire:O,peek(d){const v=i.get(d.id);return v&&ne(v.choice,d)?v.value:void 0},retain(d){const v=new Map(d.map(y=>[y.id,y]));for(const y of i.values())ne(y.choice,v.get(y.choice.id))||w(y)},dispose:f}}function st(e,t){const[r,n,a]=["settings","canvas","image"].map(i=>{const l=document.createElement("style");return l.dataset.wallpaperStyle=i,l});return r.textContent=e,n.textContent=t,n.disabled=!0,document.head.append(r,n,a),{update(i){a.textContent=i,n.disabled=!i},dispose(){for(const i of[r,n,a])i.remove()}}}const H='[data-slot="home-panel"], [data-slot="session-chat-panel"] > .bg-v2-background-bg-base, [data-component="new-session"]',de=`
[data-slot="home-panel"] .sticky.bg-v2-background-bg-base,
[data-slot="session-chat-panel"] [data-session-title] > .bg-v2-background-bg-base,
[data-slot="session-chat-panel"] [data-slot="session-location-bar"],
[data-slot="session-chat-panel"] [data-component="collapsed-tool-group"] > [data-component="collapsible"] > [data-slot="collapsible-trigger"][aria-expanded="true"],
[data-slot="session-chat-panel"] :is([data-component="edit-tool"], [data-component="write-tool"], [data-component="apply-patch-tool"]) > [data-component="collapsible"] > [data-slot="collapsible-trigger"]:is([aria-expanded="true"], [data-locked])
-`;function ut(e){const t=`:is(${e})`;return`
+`;function ct(e){const t=`:is(${e})`;return`
${t}::before,
${t}::after {
content: "";
@@ -34,15 +34,15 @@
z-index: -99;
background: var(--wallpaper-tint, transparent);
}
- `}const gt=`
- :is(${D}) {
+ `}const dt=`
+ :is(${H}) {
position: relative;
isolation: isolate;
--wallpaper-secondary: color-mix(in srgb, var(--v2-text-text-base) 88%, var(--v2-background-bg-base));
--wallpaper-text-shadow: 0 1px 2px var(--v2-background-bg-base), 0 0 4px var(--v2-background-bg-base);
}
- :is(${D}) [data-wallpaper-backed] {
+ :is(${H}) [data-wallpaper-backed] {
isolation: isolate;
background: var(--v2-background-bg-base);
}
@@ -70,7 +70,10 @@
:is([data-slot="home-panel"], [data-component="new-session"]) :is(.text-v2-text-text-muted, .text-v2-text-text-faint),
[data-component="new-session"] [data-slot="new-session-location-path"],
- [data-slot="session-chat-panel"] [data-slot="session-timeline-scroll"] :is(.text-v2-text-text-muted, .text-v2-text-text-faint, [data-slot="basic-tool-tool-subtitle"]:not(.webfetch-link), [data-slot="basic-tool-tool-arg"], [data-slot="context-tool-group-usage"], [data-slot="context-tool-group-matches"], [data-slot="execute-tool-call-args"], [data-slot="text-part-meta"], [data-component="reasoning-part"] [data-component="markdown"]) {
+ [data-slot="session-chat-panel"] [data-slot="session-timeline-scroll"] :is(.text-v2-text-text-muted, .text-v2-text-text-faint, [data-slot="basic-tool-tool-subtitle"]:not(.webfetch-link), [data-slot="basic-tool-tool-arg"], [data-slot="context-tool-group-usage"], [data-slot="context-tool-group-matches"], [data-slot="execute-tool-call-args"], [data-slot="text-part-meta"], [data-component="reasoning-part"] [data-component="markdown"]),
+ :is([data-slot="home-panel"], [data-component="new-session"]) :is(.text-v2-icon-icon-muted, .text-v2-icon-icon-faint),
+ [data-slot="home-panel"] button.text-v2-text-text-faint > [data-slot="icon-svg"],
+ [data-slot="home-panel"] [data-component="home-session-search"] input::placeholder {
color: var(--wallpaper-secondary);
}
@@ -80,15 +83,6 @@
text-shadow: var(--wallpaper-text-shadow);
}
- :is([data-slot="home-panel"], [data-component="new-session"]) :is(.text-v2-icon-icon-muted, .text-v2-icon-icon-faint),
- [data-slot="home-panel"] button.text-v2-text-text-faint > [data-slot="icon-svg"] {
- color: var(--wallpaper-secondary);
- }
-
- [data-slot="home-panel"] [data-component="home-session-search"] input::placeholder {
- color: var(--wallpaper-secondary);
- }
-
[data-slot="home-panel"] button:is(:hover, :focus-visible, [data-selected]) {
color: var(--v2-text-text-base);
}
@@ -115,7 +109,7 @@
[data-component="new-session"] [data-slot="brick-breaker-hud"] :is(.bg-v2-border-border-base, .bg-v2-icon-icon-faint) {
background-color: var(--wallpaper-secondary);
}
-`,mt=gt+ut(`${D}, :is(${D}) [data-wallpaper-backed]`)+`
+`,pt=dt+ct(`${H}, :is(${H}) [data-wallpaper-backed]`)+`
.opencode-wallpaper-media {
position: absolute;
inset: 0;
@@ -133,10 +127,10 @@
[data-wallpaper-media] :is(${de}) {
background: var(--v2-background-bg-base);
}
-`;function ft(e,t,r=!1){const a=e.enabled&&!!t,{tint:n,brightness:i}=We(e);return{"--wallpaper-image":a&&!r?`url(${JSON.stringify(t)})`:"none","--wallpaper-fit":e.fit,"--wallpaper-tint":a?`color-mix(in srgb, var(--v2-background-bg-base) ${n}%, transparent)`:"transparent","--wallpaper-filter":a?`brightness(${i}%) contrast(85%) saturate(90%)`:"none"}}function ht(e,t,r=!1){if(!e.enabled||!t)return"";const a=Object.entries(ft(e,t,r)).map(([n,i])=>`${n}: ${i};`).join(`
- `);return`${D} {
- ${a}
-}`}function Ue(e,t,r,a){const n=Math[a==="cover"?"max":"min"](e.width/r.width,e.height/r.height),i=r.width*n,l=r.height*n,s=(e.width-i)/2-(t.left-e.left),c=(e.height-l)/2-(t.top-e.top),g=h=>`${Math.round(h*1e3)/1e3}px`;return{"--wallpaper-background-size":`${g(i)} ${g(l)}`,"--wallpaper-background-position":`${g(s)} ${g(c)}`}}function bt(e){if(!(e.image.width>0&&e.image.height>0))return()=>{};const t=new Map,r=new Set;let a=0,n=!1,i=!0,l=[];const s=(b,w)=>{w.attribute===null?b.removeAttribute("data-wallpaper-backed"):b.setAttribute("data-wallpaper-backed",w.attribute);for(const[k,z]of w.properties)z.value?b.style.setProperty(k,z.value,z.priority):b.style.removeProperty(k)},c=()=>{!n&&!a&&(a=requestAnimationFrame(h))},g=new ResizeObserver(c);function h(){if(a=0,n)return;i&&(l=[...document.querySelectorAll(de)],i=!1);const b=new Set,w=new Set,k=new Map,z=[];for(const I of l){const y=I.closest(D);if(!y)continue;const d=I.getBoundingClientRect(),m=k.get(y)??y.getBoundingClientRect();k.set(y,m),!(!d.width||!d.height||!m.width||!m.height)&&(b.add(I),w.add(y),w.add(I),z.push({element:I,geometry:Ue(m,d,e.image,e.fit)}))}for(const[I,y]of t)b.has(I)||(s(I,y),t.delete(I));for(const{element:I,geometry:y}of z){t.has(I)||t.set(I,{attribute:I.getAttribute("data-wallpaper-backed"),properties:new Map(Object.keys(y).map(d=>[d,{value:I.style.getPropertyValue(d),priority:I.style.getPropertyPriority(d)}]))});for(const[d,m]of Object.entries(y))I.style.getPropertyValue(d)!==m&&I.style.setProperty(d,m);I.hasAttribute("data-wallpaper-backed")||I.setAttribute("data-wallpaper-backed","")}for(const I of r)w.has(I)||(g.unobserve(I),r.delete(I));for(const I of w)r.has(I)||(g.observe(I),r.add(I))}const A=new MutationObserver(()=>{i=!0,c()});return A.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-expanded","data-locked","class"]}),document.addEventListener("scroll",c,{capture:!0,passive:!0}),window.addEventListener("resize",c,{passive:!0}),c(),()=>{if(!n){n=!0,cancelAnimationFrame(a),A.disconnect(),g.disconnect(),document.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c);for(const[b,w]of t)s(b,w);t.clear(),r.clear(),l=[]}}}function wt(e,t){const[r,a]=he.createStore({url:"",loading:!1,error:""}),n=u.createMemo(e,void 0,{equals:(i,l)=>i?.id===l?.id&&i?.version===l?.version&&i?.kind===l?.kind});return u.createEffect(u.on(n,i=>{const l=new AbortController;let s;u.onCleanup(()=>{l.abort(),s?.()}),a({url:"",loading:!!i,error:""}),i?.kind&&t(i,l.signal).then(c=>{l.signal.throwIfAborted(),s=vt(c,i.kind,g=>{l.signal.aborted||a({loading:!1,error:g,url:g?"":c})}),a({url:c})}).catch(c=>{l.signal.aborted||a({loading:!1,error:c instanceof Error?c.message:String(c)})})})),r}function vt(e,t,r){const a=je(e,t,r);a.className="opencode-wallpaper-media";let n=0;const i=()=>{n=0;const g=[...document.querySelectorAll(D)].findLast(h=>h.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})&&h.getBoundingClientRect().height>0);a.parentElement!==g&&(a.parentElement?.removeAttribute("data-wallpaper-media"),g?(g.setAttribute("data-wallpaper-media",""),g.append(a),a instanceof HTMLVideoElement&&a.play().catch(()=>{})):(a instanceof HTMLVideoElement&&a.pause(),a.remove()))},l=()=>{n||(n=requestAnimationFrame(i))},s=new MutationObserver(l);s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","data-active"]});const c=new ResizeObserver(l);return c.observe(document.body),window.addEventListener("resize",l),i(),()=>{s.disconnect(),c.disconnect(),window.removeEventListener("resize",l),cancelAnimationFrame(n),a.parentElement?.removeAttribute("data-wallpaper-media"),a.remove(),a.removeAttribute("src"),a instanceof HTMLVideoElement&&a.load()}}function je(e,t,r){const a=document.createElement(t==="video"?"video":"iframe");return a.setAttribute("aria-hidden","true"),a.tabIndex=-1,a.inert=!0,a.onerror=()=>r("image.decodeError"),a instanceof HTMLVideoElement?(a.autoplay=!0,a.muted=!0,a.loop=!0,a.playsInline=!0,a.onloadeddata=()=>r("")):(a.setAttribute("sandbox","allow-scripts"),a.referrerPolicy="no-referrer",a.onload=()=>r("")),a.src=e,a}async function yt(e,t){t.throwIfAborted();const r=document.createElement("video");r.muted=!0,r.preload="auto",r.crossOrigin="anonymous";const a=new AbortController,n=AbortSignal.timeout(15e3),i=AbortSignal.any([t,n]);try{return await new Promise((l,s)=>{r.onloadeddata=()=>l(),r.onerror=()=>s(new Error("image.decodeError")),i.addEventListener("abort",()=>s(t.aborted?t.reason:new Error("image.decodeError")),{once:!0,signal:a.signal}),i.throwIfAborted(),r.src=e}),await Me(r,r.videoWidth,r.videoHeight,t)}finally{a.abort(),r.onloadeddata=null,r.onerror=null,r.removeAttribute("src"),r.load()}}function St(e){const[t,r]=u.createSignal();return u.createEffect(u.on(()=>e.choice,a=>{const n=new AbortController;let i,l="";r(void 0),u.onCleanup(()=>{n.abort(),i?.removeAttribute("src"),i instanceof HTMLVideoElement&&i.load(),l&&URL.revokeObjectURL(l)}),Promise.resolve(a.image??e.read(a,n.signal)).then(s=>{n.signal.throwIfAborted();const c=(g="")=>{!g&&i&&(i.style.opacity="1")};a.kind?i=je(s,a.kind,c):(i=new Image,i.alt="",i.onload=()=>c(),l=URL.createObjectURL(be(s)),i.src=l),i.className="opencode-wallpaper-preview-media",i.style.opacity="0",r(i)}).catch(()=>{})})),o.createComponent(u.Show,{get when(){return t()},children:a=>a()})}var kt=o.template(""),$e=o.template(""),xt=o.template("");function $t(e){const[t,r]=u.createSignal(!!e.cache.peek(e.choice));let a;u.onMount(()=>{const i=new IntersectionObserver(l=>{r(l.some(s=>s.isIntersecting))},{rootMargin:"200px"});i.observe(a),u.onCleanup(()=>i.disconnect())});const n=st(()=>t()&&(e.choice.kind!=="html"||e.choice.poster)?e.choice:void 0,e.cache);return(()=>{var i=kt(),l=a;return typeof l=="function"?o.use(l,i):a=i,o.insert(i,o.createComponent(u.Show,{get when(){return n.url},get fallback(){return o.createComponent(u.Show,{get when(){return e.choice.kind==="html"},get fallback(){return o.createComponent(u.Show,{get when(){return n.error},get children(){var s=$e();return o.insert(s,()=>e.t("image.unavailable")),o.effect(c=>{var g=ge(n.error,e.t),h=ge(n.error,e.t);return g!==c.e&&o.setAttribute(s,"title",c.e=g),h!==c.t&&o.setAttribute(s,"aria-label",c.t=h),c},{e:void 0,t:void 0}),s}})},get children(){var s=$e();return o.insert(s,()=>e.t("image.live")),s}})},children:s=>(()=>{var c=xt();return o.effect(()=>o.setAttribute(c,"src",s())),c})()}),null),o.insert(i,o.createComponent(u.Show,{get when(){return o.memo(()=>!!e.preview)()&&e.read},children:s=>o.createComponent(St,{get choice(){return e.choice},get read(){return s()}})}),null),o.effect(()=>o.setAttribute(i,"aria-busy",n.loading)),i})()}var Et=o.template("