diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
new file mode 100644
index 0000000..41a0ca1
--- /dev/null
+++ b/.github/workflows/check.yml
@@ -0,0 +1,36 @@
+name: Check plugin
+
+on:
+ pull_request:
+ branches: [main]
+ push:
+ branches: [main]
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+concurrency:
+ group: check-${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ check:
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ env:
+ CHROME_BIN: google-chrome
+ steps:
+ - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
+ with:
+ persist-credentials: false
+ - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
+ with:
+ node-version: "24"
+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
+ with:
+ bun-version: "1.4.4"
+ - run: bun install --frozen-lockfile --ignore-scripts
+ - run: bun run check
+ - run: git diff --exit-code -- dist/gui-experimental.cjs
+ - run: node --test .github/scripts/owner-approval.test.cjs
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..940fd62
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,17 @@
+# Changelog
+
+## 0.3.0
+
+- Add muted, looping MP4 and WebM wallpapers, animated GIF and APNG uploads, and self-contained HTML wallpapers.
+- Add Static and Live gallery filters, live indicators, and hover or keyboard-focus previews.
+- Keep gallery thumbnails still until previewed. Support companion poster images for HTML and video wallpapers.
+- Serve video and HTML from a token-protected loopback endpoint with video byte-range support. Images and HTML retain the 8 MiB limit; videos allow up to 256 MiB.
+- Sandbox HTML scripts and block external asset loading and fetch requests. Only use trusted HTML; the sandbox is not a network firewall.
+- Include live wallpapers in slideshow order. Video and HTML switch instantly; fades remain available between images.
+- Add compatibility with OpenCode 2.4.x from 2.4.3.
+- Preserve existing uploaded wallpapers, selections, and appearance preferences.
+- Recover folder watching when a deleted folder reappears during a scan.
+
+## 0.2.0
+
+- Add wallpaper slideshows with configurable display time and image fades.
diff --git a/README.md b/README.md
index 4c96ea6..aaf6684 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,12 @@
# OpenCode Backdrop
-
Use your own wallpapers in OpenCode Desktop. Supports OpenCode 2.2.x from 2.2.6 and 2.3.x from 2.3.2 through the GUI plugin API.
+
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.
## Install
```sh
-opencode plugin add 'github:viralcodex/opencode-backdrop#v0.2.0'
+opencode plugin add 'github:viralcodex/opencode-backdrop#v0.3.0'
```
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,7 +14,7 @@ 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.2.0"],
+ "plugins": ["github:viralcodex/opencode-backdrop#v0.3.0"],
}
```
@@ -22,19 +22,31 @@ This installs the plugin globally. Alternatively, add it to your global `opencod
1. Open **Settings > Wallpapers**.
2. Choose **Change folder** to use a local folder, or **+** to upload an image.
-3. Select an image and adjust tint, brightness and fit.
+3. Select a wallpaper and adjust tint, brightness and fit.
-Wallpaper starts off with an empty gallery. Images and preferences stay local, and images are not sent to models. Files must be non-empty and no larger than 8 MiB.
+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.
-- Folder images support PNG, JPEG, WebP and SVG, including subfolders. Changes appear automatically.
-- Uploads support PNG, JPEG and WebP.
-- The gallery shows at most two rows, including the **+** tile. Use **Show more** to see all images, or **Show less** to collapse it.
+- 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 gallery images in order. Choose **None** or **Fade** in the transition dropdown and set **Display time** in seconds, from 5 to 86400. The default is 60 seconds. Slideshow needs at least two images, and fades respect reduced-motion settings.
+- 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 images by moving or deleting their source files.
+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.
## Optional folder configuration
@@ -45,7 +57,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.2.0",
+ "package": "github:viralcodex/opencode-backdrop#v0.3.0",
"options": { "folder": "/absolute/path/to/wallpapers" },
},
],
@@ -56,10 +68,15 @@ 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.
+
```sh
bun run check
-bun run test:styles
bun run test:storage /path/to/opencode
```
-`check` includes native Node filesystem-watcher tests and rebuilds the GUI bundle. `test:styles` runs that bundle's setup, wallpaper switching, stylesheet cleanup, and gallery-toggle checks in headless Chrome; set `CHROME_BIN` if Chrome is installed elsewhere. `test:storage` checks migration against an OpenCode checkout's actual persistence decoder. Pass the checkout path or set `OPENCODE_CHECKOUT`.
+`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/bun.lock b/bun.lock
index 674ff44..87ac944 100644
--- a/bun.lock
+++ b/bun.lock
@@ -16,7 +16,7 @@
"vite-plugin-solid": "2.11.10",
},
"peerDependencies": {
- "@opencode/plugin": "~2.2.6 || ~2.3.2 || ^0.0.0-dev",
+ "@opencode/plugin": "~2.2.6 || ~2.3.2 || ~2.4.3 || ^0.0.0-dev",
"effect": "^4.1.0",
"solid-js": "^1.9.17",
},
diff --git a/dist/gui-experimental.cjs b/dist/gui-experimental.cjs
index f974c7d..c511d1e 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 n=require("solid-js/web"),O=require("@opencode/plugin/gui"),h=require("solid-js"),p=require("effect"),de=require("solid-js/store"),ie=require("node:fs"),N=require("node:fs/promises"),_=require("node:path"),Se=require("node:os"),G=8*1024*1024,ke=p.Schema.Struct({id:p.Schema.String,title:p.Schema.String,version:p.Schema.String}),xe=p.Schema.Struct({id:p.Schema.String,version:p.Schema.String}),le=O.Ipc.define({id:"wallpaper.catalog.v5",state:p.Schema.Struct({folder:p.Schema.String,folderLabel:p.Schema.optional(p.Schema.String),ready:p.Schema.Boolean,images:p.Schema.Array(ke),error:p.Schema.String}),methods:{refresh:{output:p.Schema.Boolean},setFolder:{input:p.Schema.NonEmptyString,output:p.Schema.Boolean},read:{input:xe,output:p.Schema.String}}}),$e=/^[A-Za-z0-9+/]+={0,2}$/,Ee=new Set(["image/png","image/jpeg","image/webp"]),pe=p.Schema.String.check(p.Schema.isPattern(/^(?:data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2})?$/),p.Schema.isMaxLength(23+4*Math.ceil(G/3)),p.Schema.makeFilter(e=>{const t=X(e);return!e||t.length%4===0&&ge(t)<=G}));function Ce(e){if(!Ee.has(e.type))throw new Error("image.typeError");if(e.size===0||e.size>G)throw new Error("image.sizeError")}function ue(e){const t=/^data:(image\/(?:png|jpeg|webp|svg\+xml))(;base64)?,([\s\S]+)$/.exec(e);if(!t)throw new Error("image.decodeError");const[,a,i,r]=t;if(i&&(r.length%4!==0||ge(r)>G||!$e.test(r)))throw new Error("image.decodeError");if(!i&&a!=="image/svg+xml")throw new Error("image.decodeError");try{const l=new Blob([i?Uint8Array.from(atob(r),d=>d.charCodeAt(0)):decodeURIComponent(r)],{type:a});if(l.size===0||l.size>G)throw new Error("image.decodeError");return l}catch(l){throw new Error("image.decodeError",{cause:l})}}async function ee(e,t){t.throwIfAborted();const a=new Image,i=()=>{a.src=""};t.addEventListener("abort",i,{once:!0});try{return a.src=e,await a.decode(),t.throwIfAborted(),a}catch(r){throw t.throwIfAborted(),new Error("image.decodeError",{cause:r})}finally{t.removeEventListener("abort",i)}}async function Ae(e,t){t.throwIfAborted();const a=URL.createObjectURL(ue(e));try{const i=await ee(a,t),r=document.createElement("canvas"),l=Math.min(1,320/i.naturalWidth,200/i.naturalHeight);r.width=Math.max(1,Math.round(i.naturalWidth*l)),r.height=Math.max(1,Math.round(i.naturalHeight*l));const d=r.getContext("2d");if(!d)throw new Error("image.decodeError");d.drawImage(i,0,0,r.width,r.height);const g=await new Promise((c,b)=>{r.toBlob(f=>f?c(f):b(new Error("image.decodeError")),"image/png")});return t.throwIfAborted(),{blob:g,width:r.width,height:r.height}}finally{URL.revokeObjectURL(a)}}async function Le(e,t){t.throwIfAborted(),Ce(e);const a=URL.createObjectURL(e);try{await ee(a,t)}finally{URL.revokeObjectURL(a)}return t.throwIfAborted(),new Promise((i,r)=>{const l=new FileReader,d=()=>l.abort(),g=()=>t.removeEventListener("abort",d);l.onload=()=>{g(),typeof l.result!="string"?r(new Error("image.readError")):i(l.result)},l.onerror=()=>{g(),r(new Error("image.readError"))},l.onabort=()=>{g(),r(t.reason)},t.addEventListener("abort",d,{once:!0});try{l.readAsDataURL(e)}catch(c){g(),r(new Error("image.readError",{cause:c}))}})}function Q(e,t){return e.startsWith("image.")?t(e):`${t("image.readError")} ${e}`}function X(e){return e.slice(e.indexOf(",")+1)}function ge(e){return e.length/4*3-(e.endsWith("==")?2:e.endsWith("=")?1:0)}const P={tint:{min:0,max:100,initial:80},brightness:{min:25,max:150,initial:100}},me=["tint","brightness"],j={min:5,max:86400,duration:60,transition:"fade"},he=800,Re=p.Schema.Struct({id:p.Schema.String.check(p.Schema.isPattern(/^(?:custom|upload:.+)$/)),name:p.Schema.String.check(p.Schema.isMinLength(1)),image:pe.check(p.Schema.isMinLength(1))}),U={enabled:p.Schema.Boolean,preset:p.Schema.String,images:p.Schema.Array(Re).check(p.Schema.makeFilter(e=>new Set(e.map(t=>t.id)).size===e.length)),tint:p.Schema.Int.check(p.Schema.isBetween({minimum:P.tint.min,maximum:P.tint.max})),brightness:p.Schema.Int.check(p.Schema.isBetween({minimum:P.brightness.min,maximum:P.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"])},z=p.Schema.Struct({...U,images:p.Schema.optional(U.images),tint:p.Schema.optional(U.tint),brightness:p.Schema.optional(U.brightness),slideshow:p.Schema.optional(U.slideshow),duration:p.Schema.optional(U.duration),transition:p.Schema.optional(U.transition),image:p.Schema.optional(pe),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))}),Me=z.pipe(p.Schema.decodeTo(p.Schema.Struct(U),{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?P.tint.initial:100-e.strength),brightness:e.brightness??P.brightness.initial,slideshow:e.slideshow??!1,duration:e.duration??j.duration,transition:e.transition??j.transition})),encode:p.SchemaGetter.transform(e=>e)})),D={enabled:!1,preset:"",images:[],tint:P.tint.initial,brightness:P.brightness.initial,fit:"cover",slideshow:!1,duration:j.duration,transition:j.transition};function T(e,t){return p.Schema.withDecodingDefaultType(p.Effect.succeed(t))(e).pipe(p.Schema.catchDecoding(()=>p.Effect.succeed(p.Option.some(t))))}const Ie=p.Schema.Struct({enabled:T(U.enabled,D.enabled),preset:T(U.preset,D.preset),fit:T(U.fit,D.fit),images:T(z.fields.images,void 0),tint:T(z.fields.tint,void 0),brightness:T(z.fields.brightness,void 0),slideshow:T(z.fields.slideshow,void 0),duration:T(z.fields.duration,void 0),transition:T(z.fields.transition,void 0),image:T(z.fields.image,void 0),imageName:T(z.fields.imageName,void 0),strength:T(z.fields.strength,void 0)}).pipe(p.Schema.decodeTo(Me));function fe(e){return{tint:e.tint,brightness:e.brightness}}function V(e,t){return e?.id===t?.id&&e?.version===t?.version&&e?.image===t?.image}function Y(e,t){return t.find(a=>a.id===e.preset)}function be(e){return e.images}function We(e=[],t=D,a=[]){const i=new Map(a.map(r=>[r.id,r]));return[...e,...be(t).map(r=>{const l=we(r.name),d=i.get(r.id);return d?.image===r.image&&d.title===l?d:{id:r.id,title:l,version:"custom",image:r.image}})]}function te(e){return e.id==="custom"||e.id.startsWith("upload:")}function _e(e,t,a){if(!te(t)||(e.images=e.images.filter(r=>r.id!==t.id),e.preset!==t.id))return;const i=a[a.findIndex(r=>r.id===t.id)+1]??a.find(r=>r.id!==t.id);e.preset=i?.id??D.preset,i||(e.enabled=!1)}function re(e,t){e.enabled=t!=="off",t!=="off"&&(e.preset=t)}function Te(e,t,a){re(e,t?Y(e,a)?.id??a[0]?.id??"off":"off")}function H(e,t){return te(e)?e.title||t("image.custom"):e.title}function se(e,t,a){const i=K(e.name),r=X(e.image??"");for(const l of be(t)){if(l.name&&K(l.name)===i)throw new Error("image.duplicateName");if(r&&r===X(l.image))throw new Error("image.duplicateImage")}for(const l of a){const d=Ue(l.id);if(d&&K(d)===i)throw new Error("image.duplicateName")}}function Ue(e){if(!e.startsWith("file:"))return"";const t=e.slice(5);return decodeURIComponent(t)}function K(e){return we(e).normalize("NFC").toLowerCase()}function we(e){const t=(e.split(/[\\/]/).at(-1)??e).trim();return t.replace(/\.(?:png|jpe?g|webp|svg)$/i,"")||t}function ze(e,t,a,i,r,l){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 a(),!e.signal.aborted&&l({title:e.t("picker.title"),placeholder:e.t("picker.search"),current:i(),options:t().map(d=>({title:H(d,e.t),value:d.id}))},d=>{if(!e.signal.aborted){if(d==="settings"){e.layout.settings("wallpaper");return}r(d)}}))}}}function ve(e){return h.createMemo(()=>{const t=e();return t?{...t}:void 0},void 0,{equals:V})}function Pe(e,t,a){const[i,r]=h.createSignal(e()),[l,d]=h.createSignal();let g;const c=()=>{clearTimeout(g),g=void 0},b=f=>{c();const C=t()&&!a()?he:0;h.batch(()=>{d(C?{show:f,duration:C}:void 0),!C&&!f&&r(!1)}),C&&(g=setTimeout(()=>{g=void 0,h.batch(()=>{d(void 0),f||r(!1)})},C))};return h.createEffect(h.on(()=>[e(),a()],([f,C])=>{if(c(),!f)return b(!1);r(!0),C&&d(void 0)})),h.createEffect(h.on(()=>e()&&t(),(f,C)=>{f&&!C&&b(!0)})),h.onCleanup(c),{enabled:i,fade:l}}function je(e,t,a=()=>0){const[i,r]=de.createStore({url:"",width:0,height:0,loading:!1,error:"",choice:void 0,previous:void 0,transition:0});let l;const d=()=>{clearTimeout(l),l=void 0,i.previous&&URL.revokeObjectURL(i.previous.url),r({previous:void 0,transition:0})};h.onCleanup(()=>{d(),i.url&&URL.revokeObjectURL(i.url)});const g=ve(e);return h.createEffect(h.on(g,c=>{const b=new AbortController;let f="";if(h.onCleanup(()=>{b.abort(),f&&URL.revokeObjectURL(f),f=""}),r({loading:!!c,error:""}),!c){d(),i.url&&URL.revokeObjectURL(i.url),r({url:"",width:0,height:0,choice:void 0});return}if(i.url&&V(c,i.choice)){r({loading:!1});return}(async()=>{try{const C=c.image??await t(c,b.signal);b.signal.throwIfAborted(),f=URL.createObjectURL(ue(C));const y=await ee(f,b.signal);b.signal.throwIfAborted(),d();const $=h.untrack(a),L=i.url&&$>0?{url:i.url,width:i.width,height:i.height}:void 0;i.url&&!L&&URL.revokeObjectURL(i.url);const I={url:f,width:y.naturalWidth,height:y.naturalHeight};f="",r({...I,choice:c,previous:L,transition:L?$:0,loading:!1,error:""}),L&&(l=setTimeout(d,$))}catch(C){f&&URL.revokeObjectURL(f),f="",b.signal.aborted||r({loading:!1,error:C instanceof Error?C.message:String(C)})}})()})),i}function Fe(e,t){const[a,i]=de.createStore({url:"",width:0,height:0,loading:!1,error:""}),r=ve(e);return h.createRenderEffect(()=>{const l=r(),d=new AbortController;let g;if(h.onCleanup(()=>{d.abort(),g?.release()}),i({url:"",width:0,height:0,loading:!!l,error:""}),!!l)try{if(g=t.acquire(l),g.value){i({...g.value,loading:!1});return}g.ready.then(c=>{d.signal.aborted||i({...c,loading:!1})},c=>{d.signal.aborted||i({loading:!1,error:c instanceof Error?c.message:String(c)})})}catch(c){i({loading:!1,error:c instanceof Error?c.message:String(c)})}}),a}function Be(e){const t=new Map;return Object.assign((i,r,l)=>{const d=t.get(i)??new Set,g=new Set(l.filter(Boolean)),c=[...g].filter(b=>!d.has(b));g.size?t.set(i,g):t.delete(i),c.length&&e.show({variant:"error",icon:"outline-photo",title:r,description:c.join(`
+"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(`
-`)})},{retain(i){const r=new Set(i);for(const l of t.keys())r.has(l)||t.delete(l)}})}function Oe(e,{maxEntries:t=48,maxBytes:a=8*1024*1024,concurrency:i=2,signal:r}={}){const l=new Map,d=new Set,g=new Map,c=p.Semaphore.makeUnsafe(i);let b=0,f=!1;function C(s){const w=g.get(s);w!==void 0&&(g.delete(s),b-=w)}function y(s){C(s),s.value&&URL.revokeObjectURL(s.value.url),s.value=void 0,d.delete(s)}function $(s){s.retired||(C(s),l.get(s.choice.id)===s&&l.delete(s.choice.id),s.retired=!0,s.controller.abort(),s.reject(s.controller.signal.reason),s.users?d.add(s):y(s))}function L(s){if(!(s.users||s.retired))for(C(s),g.set(s,s.bytes),b+=s.bytes;g.size>t||b>a;){const w=g.keys().next().value;if(!w)break;$(w)}}function I(s){p.Effect.runPromise(c.withPermit(p.Effect.tryPromise({try:w=>e(s.choice,w),catch:w=>w})),{signal:s.controller.signal}).then(w=>{s.controller.signal.throwIfAborted(),s.value={url:URL.createObjectURL(w.blob),width:w.width,height:w.height},s.bytes=w.blob.size,s.resolve(s.value),L(s)}).catch(w=>{s.reject(w),$(s)})}function x(s){if(f)throw new DOMException("Thumbnail cache is disposed.","AbortError");let w=l.get(s.id);if(w&&!V(w.choice,s)&&($(w),w=void 0),!w){const{promise:o,resolve:m,reject:u}=Promise.withResolvers();w={choice:{...s},controller:new AbortController,ready:o,resolve:m,reject:u,users:0,bytes:0,retired:!1},I(w)}const A=w;C(A),A.users++,l.set(s.id,A);let v=!1;return{value:A.value,ready:A.ready,release(){v||(v=!0,A.users--,A.retired&&!A.users?y(A):L(A))}}}function E(){if(!f){f=!0,r?.removeEventListener("abort",E);for(const s of new Set([...l.values(),...d]))$(s),y(s);l.clear(),d.clear(),g.clear(),b=0}}return r?.addEventListener("abort",E,{once:!0}),r?.aborted&&E(),{acquire:x,peek(s){const w=l.get(s.id);return w&&V(w.choice,s)?w.value:void 0},retain(s){const w=new Map(s.map(A=>[A.id,A]));for(const A of l.values())V(A.choice,w.get(A.choice.id))||$(A)},dispose:E}}function qe(e,t){const a=document.createElement("style"),i=document.createElement("style"),r=document.createElement("style");return a.dataset.wallpaperStyle="settings",i.dataset.wallpaperStyle="canvas",r.dataset.wallpaperStyle="image",a.textContent=e,i.textContent=t,i.disabled=!0,document.head.append(a,i,r),{update(l){r.textContent=l,i.disabled=!l},dispose(){a.remove(),i.remove(),r.remove()}}}const F='[data-slot="home-panel"], [data-slot="session-chat-panel"] > .bg-v2-background-bg-base, [data-component="new-session"]',ae=`
+`)})},{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=`
[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 Ne(e){const t=`:is(${e})`;return`
+`;function ut(e){const t=`:is(${e})`;return`
${t}::before,
${t}::after {
content: "";
@@ -34,15 +34,15 @@
z-index: -99;
background: var(--wallpaper-tint, transparent);
}
- `}const De=`
- :is(${F}) {
+ `}const gt=`
+ :is(${D}) {
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(${F}) [data-wallpaper-backed] {
+ :is(${D}) [data-wallpaper-backed] {
isolation: isolate;
background: var(--v2-background-bg-base);
}
@@ -115,10 +115,28 @@
[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);
}
-`,Ge=De+Ne(`${F}, :is(${F}) [data-wallpaper-backed]`);function Ve(e,t){const a=e.enabled&&!!t,{tint:i,brightness:r}=fe(e);return{"--wallpaper-image":a?`url(${JSON.stringify(t)})`:"none","--wallpaper-fit":e.fit,"--wallpaper-tint":a?`color-mix(in srgb, var(--v2-background-bg-base) ${i}%, transparent)`:"transparent","--wallpaper-filter":a?`brightness(${r}%) contrast(85%) saturate(90%)`:"none"}}function He(e,t){if(!e.enabled||!t)return"";const a=Object.entries(Ve(e,t)).map(([i,r])=>`${i}: ${r};`).join(`
- `);return`${F} {
+`,mt=gt+ut(`${D}, :is(${D}) [data-wallpaper-backed]`)+`
+ .opencode-wallpaper-media {
+ position: absolute;
+ inset: 0;
+ width: 100%;
+ height: 100%;
+ z-index: -100;
+ border: 0;
+ border-radius: inherit;
+ pointer-events: none;
+ object-fit: var(--wallpaper-fit, cover);
+ filter: var(--wallpaper-filter, none);
+ background: var(--v2-background-bg-base);
+ }
+
+ [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 ye(e,t,a,i){const r=Math[i==="cover"?"max":"min"](e.width/a.width,e.height/a.height),l=a.width*r,d=a.height*r,g=(e.width-l)/2-(t.left-e.left),c=(e.height-d)/2-(t.top-e.top),b=f=>`${Math.round(f*1e3)/1e3}px`;return{"--wallpaper-background-size":`${b(l)} ${b(d)}`,"--wallpaper-background-position":`${b(g)} ${b(c)}`}}function Ke(e){if(!(e.image.width>0&&e.image.height>0))return()=>{};const t=new Map,a=new Set;let i=0,r=!1,l=!0,d=[];const g=(y,$)=>{$.attribute===null?y.removeAttribute("data-wallpaper-backed"):y.setAttribute("data-wallpaper-backed",$.attribute);for(const[L,I]of $.properties)I.value?y.style.setProperty(L,I.value,I.priority):y.style.removeProperty(L)},c=()=>{!r&&!i&&(i=requestAnimationFrame(f))},b=new ResizeObserver(c);function f(){if(i=0,r)return;l&&(d=[...document.querySelectorAll(ae)],l=!1);const y=new Set,$=new Set,L=new Map,I=[];for(const x of d){const E=x.closest(F);if(!E)continue;const s=x.getBoundingClientRect(),w=L.get(E)??E.getBoundingClientRect();L.set(E,w),!(!s.width||!s.height||!w.width||!w.height)&&(y.add(x),$.add(E),$.add(x),I.push({element:x,geometry:ye(w,s,e.image,e.fit)}))}for(const[x,E]of t)y.has(x)||(g(x,E),t.delete(x));for(const{element:x,geometry:E}of I){t.has(x)||t.set(x,{attribute:x.getAttribute("data-wallpaper-backed"),properties:new Map(Object.keys(E).map(s=>[s,{value:x.style.getPropertyValue(s),priority:x.style.getPropertyPriority(s)}]))});for(const[s,w]of Object.entries(E))x.style.getPropertyValue(s)!==w&&x.style.setProperty(s,w);x.hasAttribute("data-wallpaper-backed")||x.setAttribute("data-wallpaper-backed","")}for(const x of a)$.has(x)||(b.unobserve(x),a.delete(x));for(const x of $)a.has(x)||(b.observe(x),a.add(x))}const C=new MutationObserver(()=>{l=!0,c()});return C.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(!r){r=!0,cancelAnimationFrame(i),C.disconnect(),b.disconnect(),document.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c);for(const[y,$]of t)g(y,$);t.clear(),a.clear(),d=[]}}}var Je=n.template(""),Ze=n.template(""),Qe=n.template("");function Xe(e){const[t,a]=h.createSignal(!!e.cache.peek(e.choice));let i;h.onMount(()=>{const l=new IntersectionObserver(d=>{a(d.some(g=>g.isIntersecting))},{rootMargin:"200px"});l.observe(i),h.onCleanup(()=>l.disconnect())});const r=Fe(()=>t()?e.choice:void 0,e.cache);return(()=>{var l=Je(),d=i;return typeof d=="function"?n.use(d,l):i=l,n.insert(l,n.createComponent(h.Show,{get when(){return r.url},get fallback(){return n.createComponent(h.Show,{get when(){return r.error},get children(){var g=Ze();return n.insert(g,()=>e.t("image.unavailable")),n.effect(c=>{var b=Q(r.error,e.t),f=Q(r.error,e.t);return b!==c.e&&n.setAttribute(g,"title",c.e=b),f!==c.t&&n.setAttribute(g,"aria-label",c.t=f),c},{e:void 0,t:void 0}),g}})},children:g=>(()=>{var c=Qe();return n.effect(()=>n.setAttribute(c,"src",g())),c})()})),n.effect(()=>n.setAttribute(l,"aria-busy",r.loading)),l})()}var Ye=n.template("