feedkeeper 0.42.1 → 0.42.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.
- package/package.json +1 -1
- package/server/dist/feeds/content/noise/redditPosts.js +96 -0
- package/server/dist/feeds/contentNoise.js +3 -1
- package/server/dist/feeds/fetcher.js +24 -1
- package/server/package.json +1 -1
- package/web/dist/assets/{index-30jFGCKW.js → index-DX6YOuhF.js} +1 -1
- package/web/dist/index.html +1 -1
- package/web/dist/sw.js +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { count, flat, parseAddress } from "../shared.js";
|
|
2
|
+
const REDDIT_HOST = /(?:^|\.)reddit\.com$/i;
|
|
3
|
+
const REDDIT_USER_PATH = /^\/(?:u|user)\/[^/]+/i;
|
|
4
|
+
const REDDIT_COMMENTS_PATH = /^\/r\/[^/]+\/comments\//i;
|
|
5
|
+
const SUBMITTED_BY = /\bsubmitted\s+by\b/i;
|
|
6
|
+
function isRedditUrl(href, pathPattern) {
|
|
7
|
+
if (!href)
|
|
8
|
+
return false;
|
|
9
|
+
const parsed = parseAddress(href);
|
|
10
|
+
return Boolean(parsed && REDDIT_HOST.test(parsed.hostname) && pathPattern.test(parsed.pathname));
|
|
11
|
+
}
|
|
12
|
+
function isRedditPostTable(table) {
|
|
13
|
+
const rows = [...table.querySelectorAll(":scope > tbody > tr, :scope > tr")];
|
|
14
|
+
if (rows.length !== 1)
|
|
15
|
+
return false;
|
|
16
|
+
const cells = [...rows[0].children].filter(child => child.tagName === "TD");
|
|
17
|
+
if (cells.length === 0 || cells.length > 2)
|
|
18
|
+
return false;
|
|
19
|
+
const bodyCell = cells[cells.length - 1];
|
|
20
|
+
if (!SUBMITTED_BY.test(flat(bodyCell.textContent)))
|
|
21
|
+
return false;
|
|
22
|
+
const links = [...bodyCell.querySelectorAll("a[href]")];
|
|
23
|
+
const hasAuthor = links.some(link => isRedditUrl(link.getAttribute("href"), REDDIT_USER_PATH));
|
|
24
|
+
const hasComments = links.some(link => flat(link.textContent).toLowerCase() === "[comments]" && isRedditUrl(link.getAttribute("href"), REDDIT_COMMENTS_PATH));
|
|
25
|
+
return hasAuthor && hasComments;
|
|
26
|
+
}
|
|
27
|
+
function externalLinkHost(href) {
|
|
28
|
+
const parsed = parseAddress(href);
|
|
29
|
+
if (!parsed || !/^https?:$/.test(parsed.protocol))
|
|
30
|
+
return null;
|
|
31
|
+
if (REDDIT_HOST.test(parsed.hostname) || parsed.hostname === "i.redd.it" || parsed.hostname === "v.redd.it")
|
|
32
|
+
return null;
|
|
33
|
+
return parsed.hostname.replace(/^www\./i, "");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Reddit subreddit Atom feeds wrap every post in a 1-row layout `<table>` with a thumbnail cell and a body cell
|
|
37
|
+
* ending in `submitted by /u/… [link] [comments]`. Unwrap the thumbnail and `.md` body and drop the forum chrome.
|
|
38
|
+
*/
|
|
39
|
+
export function cleanRedditPost(root, stats) {
|
|
40
|
+
let changed = false;
|
|
41
|
+
for (const table of [...root.querySelectorAll("table")]) {
|
|
42
|
+
if (!isRedditPostTable(table))
|
|
43
|
+
continue;
|
|
44
|
+
const rows = [...table.querySelectorAll(":scope > tbody > tr, :scope > tr")];
|
|
45
|
+
const cells = [...rows[0].children].filter(child => child.tagName === "TD");
|
|
46
|
+
const doc = table.ownerDocument;
|
|
47
|
+
const replacement = [];
|
|
48
|
+
if (cells.length === 2) {
|
|
49
|
+
const thumbImg = cells[0].querySelector("img[src]");
|
|
50
|
+
const src = (thumbImg?.getAttribute("src") ?? "").trim();
|
|
51
|
+
if (thumbImg && src && !/^data:/i.test(src)) {
|
|
52
|
+
const figure = doc.createElement("p");
|
|
53
|
+
const cleanImg = doc.createElement("img");
|
|
54
|
+
cleanImg.setAttribute("src", src);
|
|
55
|
+
const alt = flat(thumbImg.getAttribute("alt"));
|
|
56
|
+
if (alt)
|
|
57
|
+
cleanImg.setAttribute("alt", alt);
|
|
58
|
+
figure.append(cleanImg);
|
|
59
|
+
replacement.push(figure);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const bodyCell = cells[cells.length - 1];
|
|
63
|
+
const md = bodyCell.querySelector("div.md");
|
|
64
|
+
if (md) {
|
|
65
|
+
for (const child of [...md.childNodes]) {
|
|
66
|
+
if (child.nodeType === 8)
|
|
67
|
+
continue; // Strip HTML comments (e.g. SC_OFF / SC_ON)
|
|
68
|
+
replacement.push(child);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// For link posts without body prose, preserve the external target link instead of `[link]`.
|
|
72
|
+
if (!md || flat(md.textContent) === "") {
|
|
73
|
+
const external = [...bodyCell.querySelectorAll("a[href]")].find(link => flat(link.textContent).toLowerCase() === "[link]" && externalLinkHost(link.getAttribute("href") ?? ""));
|
|
74
|
+
const href = external?.getAttribute("href") ?? "";
|
|
75
|
+
const host = external ? externalLinkHost(href) : null;
|
|
76
|
+
if (href && host) {
|
|
77
|
+
const p = doc.createElement("p");
|
|
78
|
+
const a = doc.createElement("a");
|
|
79
|
+
a.setAttribute("href", href);
|
|
80
|
+
a.textContent = host;
|
|
81
|
+
p.append("↗ ", a);
|
|
82
|
+
replacement.push(p);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (replacement.length > 0) {
|
|
86
|
+
table.replaceWith(...replacement);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
table.remove();
|
|
90
|
+
}
|
|
91
|
+
count(stats, "reddit-post");
|
|
92
|
+
changed = true;
|
|
93
|
+
}
|
|
94
|
+
return changed;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=redditPosts.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { cleanVideoPage } from "./content/noise/videoPages.js";
|
|
2
|
+
import { cleanRedditPost } from "./content/noise/redditPosts.js";
|
|
2
3
|
import { lazyImages } from "./content/noise/lazyImages.js";
|
|
3
4
|
import { JSDOM } from "jsdom";
|
|
4
5
|
import { SNIPPET_BYLINES, SNIPPET_IMAGE_CREDIT, SNIPPET_IMAGE_FILENAME, SNIPPET_IMAGE_METADATA, SNIPPET_MARKERS } from "./content/patterns/snippet-metadata/index.js";
|
|
@@ -700,6 +701,7 @@ export function cleanReaderHtml(html, title, stats = {}, author, url) {
|
|
|
700
701
|
return html;
|
|
701
702
|
const root = JSDOM.fragment(html);
|
|
702
703
|
const videoPage = cleanVideoPage(root, url, title, stats);
|
|
704
|
+
const redditPost = cleanRedditPost(root, stats);
|
|
703
705
|
const lazy = lazyImages.apply(root, stats);
|
|
704
706
|
const images = resolveCustomImages(root, stats);
|
|
705
707
|
const duplicates = collapseAdjacentImages(root, stats);
|
|
@@ -707,7 +709,7 @@ export function cleanReaderHtml(html, title, stats = {}, author, url) {
|
|
|
707
709
|
const embeds = resolveEmbeds(root, stats);
|
|
708
710
|
const noise = removeReaderNoise(root, title, stats, author);
|
|
709
711
|
const typography = removeTypography(root, stats);
|
|
710
|
-
return videoPage || lazy || images || duplicates || variants || embeds || noise || typography ? serialize(root) : html;
|
|
712
|
+
return videoPage || redditPost || lazy || images || duplicates || variants || embeds || noise || typography ? serialize(root) : html;
|
|
711
713
|
}
|
|
712
714
|
/**
|
|
713
715
|
* Some publishers wrap a picture in their own element and let a script fill the image: `<a-img src="/imgs/…">`
|
|
@@ -67,6 +67,26 @@ export function parseRetryAfter(value, now = Date.now()) {
|
|
|
67
67
|
return undefined;
|
|
68
68
|
return Math.max(now, date);
|
|
69
69
|
}
|
|
70
|
+
const MAX_RATELIMIT_RESET_MS = 24 * 60 * 60 * 1000;
|
|
71
|
+
/** Reads `X-RateLimit-Remaining` / `X-RateLimit-Reset` (relative seconds or epoch seconds) for proactive host pacing. */
|
|
72
|
+
export function parseRateLimitReset(headers, now = Date.now(), force = false) {
|
|
73
|
+
const remainingRaw = headers.get("x-ratelimit-remaining") ?? headers.get("ratelimit-remaining");
|
|
74
|
+
if (!force) {
|
|
75
|
+
if (remainingRaw === null)
|
|
76
|
+
return undefined;
|
|
77
|
+
const remaining = Number(remainingRaw.trim());
|
|
78
|
+
if (!Number.isFinite(remaining) || remaining >= 1)
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
const resetRaw = headers.get("x-ratelimit-reset") ?? headers.get("ratelimit-reset");
|
|
82
|
+
if (resetRaw === null)
|
|
83
|
+
return undefined;
|
|
84
|
+
const reset = Number(resetRaw.trim());
|
|
85
|
+
if (!Number.isFinite(reset) || reset < 0)
|
|
86
|
+
return undefined;
|
|
87
|
+
const target = reset > 1_000_000_000 ? reset * 1000 : now + Math.ceil(reset) * 1000 + 1000;
|
|
88
|
+
return Math.min(now + MAX_RATELIMIT_RESET_MS, Math.max(now, target));
|
|
89
|
+
}
|
|
70
90
|
/** DNS preflight cannot be cancelled, but must not hold the caller past its deadline. */
|
|
71
91
|
async function validateUrl(url, signal) {
|
|
72
92
|
signal.throwIfAborted();
|
|
@@ -108,6 +128,9 @@ async function downloadPublic(url, opts) {
|
|
|
108
128
|
if (redirects === 0 && opts.lastModified)
|
|
109
129
|
headers["If-Modified-Since"] = opts.lastModified;
|
|
110
130
|
const response = await undiciFetch(validated, { headers, redirect: "manual", signal, dispatcher });
|
|
131
|
+
const rateLimitUntil = parseRateLimitReset(response.headers, Date.now(), response.status === 429);
|
|
132
|
+
if (rateLimitUntil)
|
|
133
|
+
feedRequests.defer(host, rateLimitUntil);
|
|
111
134
|
if (response.status === 304) {
|
|
112
135
|
await response.body?.cancel();
|
|
113
136
|
return { notModified: true, buffer: Buffer.alloc(0), finalUrl: currentUrl, contentType: response.headers.get("content-type") ?? undefined };
|
|
@@ -123,7 +146,7 @@ async function downloadPublic(url, opts) {
|
|
|
123
146
|
if (!response.ok) {
|
|
124
147
|
let retryAt = parseRetryAfter(response.headers.get("retry-after"));
|
|
125
148
|
if (response.status === 429 || response.status === 503) {
|
|
126
|
-
retryAt = Math.max(retryAt ?? 0, Date.now() + readPollSettings().retryBaseMs * (0.5 + Math.random() * 0.5));
|
|
149
|
+
retryAt = Math.max(retryAt ?? 0, rateLimitUntil ?? 0, Date.now() + readPollSettings().retryBaseMs * (0.5 + Math.random() * 0.5));
|
|
127
150
|
feedRequests.defer(host, retryAt);
|
|
128
151
|
}
|
|
129
152
|
await response.body?.cancel();
|
package/server/package.json
CHANGED
|
@@ -93,7 +93,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
93
93
|
function ns(e,t){return $o(e)||es(e,t)||rs(e,t)||ts()}function rs(e,t){if(e){if(typeof e==`string`)return Qo(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Qo(e,t):void 0}}function is(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof Zo;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}is.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},is.prototype.next=function(e){return this._invoke(`next`,e)},is.prototype.throw=function(e){return this._invoke(`throw`,e)},is.prototype.return=function(e){return this._invoke(`return`,e)};var as=Object.entries,os=Object.setPrototypeOf,ss=Object.isFrozen,cs=Object.getPrototypeOf,ls=Object.getOwnPropertyDescriptor,us=Object.freeze,ds=Object.seal,fs=Object.create,ps=typeof Reflect<`u`&&Reflect,ms=ps.apply,hs=ps.construct;us||=function(e){return e},ds||=function(e){return e},ms||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},hs||=function(e){return new e(...[...arguments].slice(1))};var gs=Bs(Array.prototype.forEach);Array.prototype.indexOf;var _s=Bs(Array.prototype.lastIndexOf),vs=Bs(Array.prototype.pop),ys=Bs(Array.prototype.push),bs=Bs(Array.prototype.slice),xs=Bs(Array.prototype.splice),Ss=Array.isArray,Cs=Vs(Set),ws=Bs(Set.prototype.add),Ts=Bs(Set.prototype.has),Es=Bs(String.prototype.toLowerCase),Ds=Bs(String.prototype.toString),Os=Bs(String.prototype.match),ks=Bs(String.prototype.replace),As=Bs(String.prototype.indexOf),js=Bs(String.prototype.trim),Ms=Bs(Number.prototype.toString),Ns=Bs(Boolean.prototype.toString),Ps=typeof BigInt>`u`?null:Bs(BigInt.prototype.toString),Fs=typeof Symbol>`u`?null:Bs(Symbol.prototype.toString),Is=Bs(Object.prototype.hasOwnProperty),Ls=Bs(Object.prototype.toString),Rs=Bs(RegExp.prototype.test),zs=Vs(TypeError);function Bs(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return ms(e,t,n)}}function Vs(e){return function(){return hs(e,[...arguments])}}function G(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Es;if(os&&os(e,null),!Ss(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(ss(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Hs(e){for(let t=0;t<e.length;t++)Is(e,t)||(e[t]=null);return e}function Us(e){let t=fs(null);for(let r of as(e)){var n=ns(r,2);let i=n[0],a=n[1];Is(e,i)&&(t[i]=Ss(a)?Hs(a):a&&typeof a==`object`&&a.constructor===Object?Us(a):a)}return t}function Ws(e){switch(typeof e){case`string`:return e;case`number`:return Ms(e);case`boolean`:return Ns(e);case`bigint`:return Ps?Ps(e):`0`;case`symbol`:return Fs?Fs(e):`Symbol()`;case`undefined`:return Ls(e);case`function`:case`object`:{if(e===null)return Ls(e);let t=e,n=Gs(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Ls(e)}return Ls(e)}default:return Ls(e)}}function Gs(e,t){for(;e!==null;){let n=ls(e,t);if(n){if(n.get)return Bs(n.get);if(typeof n.value==`function`)return Bs(n.value)}e=cs(e)}function n(){return null}return n}function Ks(e,t){for(;e!==null;){let n=ls(e,t);if(n)return n.get?Bs(n.get):null;e=cs(e)}return null}function qs(e){try{return Rs(e,``),!0}catch{return!1}}var Js=us(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Ys=us(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),Xs=us([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Zs=us([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Qs=us(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),$s=us([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),ec=us([`#text`]),tc=us(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),nc=us(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),rc=us(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),ic=us([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),ac=ds(/{{[\w\W]*|^[\w\W]*}}/g),oc=ds(/<%[\w\W]*|^[\w\W]*%>/g),sc=ds(/\${[\w\W]*/g),cc=ds(/^data-[\-\w.\u00B7-\uFFFF]+$/),lc=ds(/^aria-[\-\w]+$/),uc=ds(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),dc=ds(/^(?:\w+script|data):/i),fc=ds(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),pc=ds(/^html$/i),mc=ds(/^[a-z][.\w]*(-[.\w]+)+$/i),hc=ds(/<[/\w!]/g),gc=ds(/<[/\w]/g),_c=ds(/<\/no(script|embed|frames)/i),vc=ds(/\/>/i),yc={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},bc=us(G({},[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`])),xc=function(){return typeof window>`u`?null:window},Sc=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Cc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},wc=function(e,t,n,r){return Is(e,t)&&Ss(e[t])?G(r.base?Us(r.base):{},e[t],r.transform):n},Tc=function(e,t,n){let r=Is(e,t)?e[t]:void 0;return r&&typeof r==`object`?Us(r):n()};function Ec(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:xc(),t=e=>Ec(e);if(t.version=`3.4.17`,t.removed=[],!e||!e.document||e.document.nodeType!==yc.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=Gs(d,`cloneNode`),p=Gs(d,`remove`),m=Gs(d,`removeAttributeNode`),h=Gs(d,`nextSibling`),g=Gs(d,`childNodes`),_=Gs(d,`parentNode`),v=Gs(d,`shadowRoot`),y=Gs(d,`attributes`),b=o&&o.prototype?Gs(o.prototype,`nodeType`):null,x=o&&o.prototype?Gs(o.prototype,`nodeName`):null,S=o&&o.prototype?Gs(o.prototype,`ownerDocument`):null,C=function(e){return b?b(e):e.nodeType},w=function(e){return x?x(e):e.nodeName},T=Ks(d,`namespaceURI`),E=function(e){return T?T(e):e.namespaceURI};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let D,O=``,k,A=!1,j=0,ee=function(){if(j>0)throw zs(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},te=function(e){ee(),j++;try{return D.createHTML(e)}finally{j--}},ne=function(e){ee(),j++;try{return D.createScriptURL(e)}finally{j--}},re=function(){return A||=(k=Sc(u,i),!0),k},M=n,ie=M.implementation,ae=M.createNodeIterator,oe=M.createDocumentFragment,se=M.getElementsByTagName,ce=r.importNode,N=Cc();t.isSupported=typeof as==`function`&&typeof _==`function`&&ie&&ie.createHTMLDocument!==void 0;let le=ac,ue=oc,de=sc,fe=cc,pe=lc,me=dc,he=fc,ge=mc,P=uc,F=null,_e=G({},[...Js,...Ys,...Xs,...Qs,...ec]),I=null,ve=G({},[...tc,...nc,...rc,...ic]),ye=Object.seal(fs(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),be=null,L=null,xe=Object.seal(fs(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Se=!0,Ce=!0,we=!1,Te=!0,Ee=!1,De=!0,Oe=!1,ke=!1,Ae=null,je=null,Me=!1,Ne=!1,Pe=!1,Fe=!1,Ie=!0,Le=!1,Re=`user-content-`,ze=!0,Be=!1,Ve=null,He={},Ue=null,We=G({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Ge=null,Ke=G({},[`audio`,`video`,`img`,`source`,`image`,`track`]),qe=null,Je=G({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ye=`http://www.w3.org/1998/Math/MathML`,Xe=`http://www.w3.org/2000/svg`,Ze=`http://www.w3.org/1999/xhtml`,Qe=Ze,$e=!1,et=null,tt=G({},[Ye,Xe,Ze],Ds),nt=us([`mi`,`mo`,`mn`,`ms`,`mtext`]),rt=G({},nt),it=us([`annotation-xml`]),at=G({},it),ot=G({},[`title`,`style`,`font`,`a`,`script`]),st=null,ct=[`application/xhtml+xml`,`text/html`],lt=null,R=null,ut=n.createElement(`form`),dt=function(e){return e instanceof RegExp||e instanceof Function},ft=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(R&&R===e)return;e&&typeof e==`object`||(e={}),e=Us(e),st=ct.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,lt=st===`application/xhtml+xml`?Ds:Es,F=wc(e,`ALLOWED_TAGS`,_e,{transform:lt}),I=wc(e,`ALLOWED_ATTR`,ve,{transform:lt}),et=wc(e,`ALLOWED_NAMESPACES`,tt,{transform:Ds}),qe=wc(e,`ADD_URI_SAFE_ATTR`,Je,{transform:lt,base:Je}),Ge=wc(e,`ADD_DATA_URI_TAGS`,Ke,{transform:lt,base:Ke}),Ue=wc(e,`FORBID_CONTENTS`,We,{transform:lt}),be=wc(e,`FORBID_TAGS`,Us({}),{transform:lt}),L=wc(e,`FORBID_ATTR`,Us({}),{transform:lt}),He=Is(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Us(e.USE_PROFILES):e.USE_PROFILES:!1,Se=e.ALLOW_ARIA_ATTR!==!1,Ce=e.ALLOW_DATA_ATTR!==!1,we=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Te=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ee=e.SAFE_FOR_TEMPLATES||!1,De=e.SAFE_FOR_XML!==!1,Oe=e.WHOLE_DOCUMENT||!1,Ne=e.RETURN_DOM||!1,Pe=e.RETURN_DOM_FRAGMENT||!1,Fe=e.RETURN_TRUSTED_TYPE||!1,Me=e.FORCE_BODY||!1,Ie=e.SANITIZE_DOM!==!1,Le=e.SANITIZE_NAMED_PROPS||!1,ze=e.KEEP_CONTENT!==!1,Be=e.IN_PLACE||!1,P=qs(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:uc,Qe=typeof e.NAMESPACE==`string`?e.NAMESPACE:Ze,rt=Tc(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>G({},nt)),at=Tc(e,`HTML_INTEGRATION_POINTS`,()=>G({},it));let t=Tc(e,`CUSTOM_ELEMENT_HANDLING`,()=>fs(null));if(ye=fs(null),Is(t,`tagNameCheck`)&&dt(t.tagNameCheck)&&(ye.tagNameCheck=t.tagNameCheck),Is(t,`attributeNameCheck`)&&dt(t.attributeNameCheck)&&(ye.attributeNameCheck=t.attributeNameCheck),Is(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(ye.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),ds(ye),Ee&&(Ce=!1),Pe&&(Ne=!0),He&&(F=G({},ec),I=fs(null),He.html===!0&&(G(F,Js),G(I,tc)),He.svg===!0&&(G(F,Ys),G(I,nc),G(I,ic)),He.svgFilters===!0&&(G(F,Xs),G(I,nc),G(I,ic)),He.mathMl===!0&&(G(F,Qs),G(I,rc),G(I,ic))),xe.tagCheck=null,xe.attributeCheck=null,Is(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?xe.tagCheck=e.ADD_TAGS:Ss(e.ADD_TAGS)&&(F===_e&&(F=Us(F)),G(F,e.ADD_TAGS,lt))),Is(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?xe.attributeCheck=e.ADD_ATTR:Ss(e.ADD_ATTR)&&(I===ve&&(I=Us(I)),G(I,e.ADD_ATTR,lt))),Is(e,`ADD_FORBID_CONTENTS`)&&Ss(e.ADD_FORBID_CONTENTS)&&(Ue===We&&(Ue=Us(Ue)),G(Ue,e.ADD_FORBID_CONTENTS,lt)),ze&&(F[`#text`]=!0),Oe&&G(F,[`html`,`head`,`body`]),F.table&&(G(F,[`tbody`]),delete be.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw zs(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw zs(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=D;D=e.TRUSTED_TYPES_POLICY;try{O=te(``)}catch(e){throw D=t,e}}else e.TRUSTED_TYPES_POLICY===null?(D=void 0,O=``):(D===void 0&&(D=re()),D&&typeof O==`string`&&(O=te(``)));us&&us(e),R=e},pt=G({},[...Ys,...Xs,...Zs]),mt=G({},[...Qs,...$s]),ht=function(e,t,n){return t.namespaceURI===Ze?e===`svg`:t.namespaceURI===Ye?e===`svg`&&(n===`annotation-xml`||rt[n]):!!pt[e]},gt=function(e,t,n){return t.namespaceURI===Ze?e===`math`:t.namespaceURI===Xe?e===`math`&&at[n]:!!mt[e]},_t=function(e,t,n){return t.namespaceURI===Xe&&!at[n]||t.namespaceURI===Ye&&!rt[n]?!1:!mt[e]&&(ot[e]||!pt[e])},vt=function(e){let t=E(e),n=Es(w(e)),r=_(e),i,a;return r&&C(r)===yc.element?(i={namespaceURI:E(r)},a=Es(w(r))):(i={namespaceURI:Qe},a=`template`),et[t]?t===Xe?ht(n,i,a):t===Ye?gt(n,i,a):t===Ze?_t(n,i,a):!!(st===`application/xhtml+xml`&&et[t]):!1},yt=function(e){ys(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw zs(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},bt=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},xt=function(e){Tt(e);let t=g(e);t&&gs(bs(t),e=>{try{p(e)}catch{}});let n=C(e)===yc.element?y(e):null;if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&bt(e,r,i)}},St=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}ys(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Ne||Pe)try{yt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},Ct=function(e){let t=y(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||I[lt(i)]||bt(e,r,i)}},wt=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=[e];for(;r.length>0;){let e=r.pop();if(t(e)===!1)continue;if(n&&C(e)===yc.element){let t=v(e);Bt(t)&&r.push(t)}let i=g(e);if(i)for(let e=i.length-1;e>=0;--e)r.push(i[e])}},Tt=function(e){wt(e,e=>{C(e)===yc.element&&Ct(e)})},Et=function(e){let t=[];return wt(e,e=>{t.push(e)},!0),t},Dt=function(e,t){let n=Cs();gs(Et(e),e=>{C(e)===yc.element&&ws(n,e)}),gs(t,e=>{C(e)===yc.element&&!Ts(n,e)&&Ct(e)})},Ot=function(e,n){let r=!1;return gs(t.removed,t=>{t.element&&(r||=t.element===e,Tt(t.element))}),Dt(e,n),r},kt=function(e,t){let n=Ve,r=null,i=()=>(r||(r=Cs(),gs(t,e=>{ws(r,e)})),r);for(let t=0;;t++){let r=Et(e),a=[e],o=!1;if(gs(r,e=>{C(e)===yc.documentFragment?ys(a,e):!o&&!Ts(n,e)&&(o=Ts(i(),e))}),!o)return;if(t>=8)throw zs(`the tree kept changing during in-place sanitization; refusing to return it`);gs(a,(t,n)=>{At(t,n>0,e,i())})}},At=function(e,t,n,r){let i=Ft(e),a;for(;a=i.nextNode();)Ts(r,a)&&!Ts(Ve,a)&&(t&&Ht(N.uponSanitizeShadowNode,a,null),qt(a,n),en(a,n),Bt(a.content)&&tn(a.content))},jt=function(e){Ve&&ws(Ve,e)},Mt=function(e,t){return De?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Nt=function(e){De&&wt(e,e=>{let t=C(e);if(t===yc.processingInstruction||t===yc.comment&&Rs(gc,e.data)){try{p(e)}catch{}return!1}if(t===yc.element){let t=e,n=lt(w(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Mt(`for`,n)&&t.removeAttribute(`for`)}catch{}}return!0})},Pt=function(e){let t=null,r=null;if(Me)e=`<remove></remove>`+e;else{let t=Os(e,/^[\r\n\t ]+/);r=t&&t[0]}st===`application/xhtml+xml`&&Qe===Ze&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=D?te(e):e;if(Qe===Ze)try{t=new l().parseFromString(i,st)}catch{}if(!t||!t.documentElement){t=ie.createDocument(Qe,`template`,null);try{t.documentElement.innerHTML=$e?O:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Qe===Ze?se.call(t,Oe?`html`:`body`)[0]:Oe?t.documentElement:a},Ft=function(e){let t=S?S(e):e.ownerDocument;return ae.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},It=function(e){return e=ks(e,le,` `),e=ks(e,ue,` `),e=ks(e,de,` `),e},Lt=function(e){Rt(e);let t=e.querySelectorAll?.call(e,`template`);t&&gs(t,e=>{Bt(e.content)&&Lt(e.content)})},Rt=function(e){e.normalize();let t=S?S(e):e.ownerDocument,n=ae.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=It(r.data),r=n.nextNode()},zt=function(e){let t=x?x(e):null;return typeof t!=`string`||lt(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==y(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==b(e)||e.childNodes!==g(e)},Bt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return b(e)===yc.documentFragment}catch{return!1}},Vt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return typeof b(e)==`number`}catch{return!1}};function Ht(e,n,r){e.length!==0&&gs(e,e=>{e.call(t,n,r,R)})}let Ut=function(e,t){return!!(De&&e.hasChildNodes()&&!Vt(e.firstElementChild)&&Rs(hc,e.textContent)&&Rs(hc,e.innerHTML)||De&&bc[t]&&C(e)===yc.element&&E(e)===Ze&&(Vt(e.firstElementChild)||typeof e.textContent==`string`&&Rs(hc,e.textContent))||e.nodeType===yc.processingInstruction||De&&e.nodeType===yc.comment&&Rs(gc,e.data))},Wt=function(e,t){return e instanceof RegExp?Rs(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Gt=function(e,t,n){if(!be[t]&&Xt(t)&&Wt(ye.tagNameCheck,t))return!1;if(ze&&!Ue[t]&&!Ue[Es(t)]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,h(e))}}}return yt(e),!0},z=function(e,t,n,r){return e.length===0?t:t===n||t===r?Us(t):t},Kt=function(e,t){return e===t||_(e)!==null?!1:(Be&&Tt(e),!0)},qt=function(e,n){if(jt(e),Ht(N.beforeSanitizeElements,e,null),Kt(e,n))return!0;if(zt(e))return yt(e),!0;let r=lt(w(e));if(F=z(N.uponSanitizeElement,F,_e,Ae),Ht(N.uponSanitizeElement,e,{tagName:r,allowedTags:F}),Kt(e,n))return!0;if(Ut(e,r))return yt(e),!0;if(be[r]||!(xe.tagCheck instanceof Function&&xe.tagCheck(r))&&!F[r]){let t=Gt(e,r,n);return t===!1&&(Ht(N.afterSanitizeElements,e,null),Kt(e,n))?!0:t}if(C(e)===yc.element&&!vt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Rs(_c,e.innerHTML))return yt(e),!0;if(Ee&&e.nodeType===yc.text){let n=It(e.textContent);e.textContent!==n&&(ys(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Ht(N.afterSanitizeElements,e,null),Kt(e,n)},Jt=function(e,t,r){if(L[t]||Mt(t,e)||Ie&&(t===`id`||t===`name`)&&(r in n||r in ut))return!1;let i=I[t]||xe.attributeCheck instanceof Function&&xe.attributeCheck(t,e);return Ce&&Rs(fe,t)||Se&&Rs(pe,t)?!0:i?qe[t]||Rs(P,ks(r,he,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&As(r,`data:`)===0&&Ge[e]||we&&!Rs(me,ks(r,he,``))?!0:!r:Xt(e)&&Wt(ye.tagNameCheck,e)&&Wt(ye.attributeNameCheck,t,e)||t===`is`&&ye.allowCustomizedBuiltInElements&&Wt(ye.tagNameCheck,r)},Yt=G({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Xt=function(e){return!Yt[Es(e)]&&Rs(ge,e)},Zt=function(e,t,n,r){if(D&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return te(r);case`TrustedScriptURL`:return ne(r)}return r},Qt=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!zt(e)||(yt(e),!1)}catch{return St(t,e),!1}},$t=function(e,t){return De&&Rs(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,t)?!0:Es(e)===`attributename`&&Os(t,`href`)!==null},en=function(e,n){if(Ht(N.beforeSanitizeAttributes,e,null),Kt(e,n))return;let r=e.attributes;if(!r||zt(e))return;I=z(N.uponSanitizeAttribute,I,ve,je);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:I,forceKeepAttr:void 0},a=r.length,o=lt(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=lt(s),d=l,f=s===`value`?d:js(d),p=!1;i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Ht(N.uponSanitizeAttribute,e,i),f=i.attrValue,Le&&(u===`id`||u===`name`)&&As(f,Re)!==0&&(St(s,e,n),f=Re+f,p=!0),$t(s,f)?St(s,e,n):i.forceKeepAttr||(i.keepAttr?!Te&&Rs(vc,f)?St(s,e,n):(Ee&&(f=It(f)),Jt(o,u,f)?(f=Zt(o,u,c,f),f!==d&&Qt(e,s,c,f)&&p&&vs(t.removed)):St(s,e,n)):St(s,e,n))}Ht(N.afterSanitizeAttributes,e,null),Kt(e,n)},tn=function(e){let t=null,n=Ft(e);for(Ht(N.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Ht(N.uponSanitizeShadowNode,t,null),qt(t,e),en(t,e),Bt(t.content)&&tn(t.content),C(t)===yc.element){let e=v(t);Bt(e)&&(nn(e),tn(e))}Ee&&Rt(e),Ht(N.afterSanitizeShadowDOM,e,null)},nn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){tn(e.shadow);continue}let n=e.node,r=C(n)===yc.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=x?x(n):null;if(typeof e==`string`&<(e)===`template`){let e=n.content;Bt(e)&&t.push({node:e,shadow:null})}}if(r){let e=v(n);Bt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if($e=!e,$e&&(e=`<!-->`),typeof e!=`string`&&!Vt(e)&&(e=Ws(e),typeof e!=`string`))throw zs(`dirty is not a string, aborting`);if(!t.isSupported)return e;ke?(F=Ae,I=je):ft(n),(N.uponSanitizeElement.length>0||N.uponSanitizeAttribute.length>0)&&(F=Us(F)),N.uponSanitizeAttribute.length>0&&(I=Us(I)),t.removed=[];let c=Be&&typeof e!=`string`&&Vt(e),l=[],u=Ve;if(c){Nt(e);let t=w(e);if(typeof t==`string`){let n=lt(t);if(!F[n]||be[n])throw xt(e),zs(`root node is forbidden and cannot be sanitized in-place`)}if(zt(e))throw xt(e),zs(`root node is clobbered and cannot be sanitized in-place`);l=Et(e),Ve=Cs()}else if(Vt(e))i=Pt(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===yc.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),nn(i);else{if(!Ne&&!Ee&&!Oe&&e.indexOf(`<`)===-1)return D&&Fe?te(e):e;if(i=Pt(e),!i)return Ne?null:Fe?O:``}i&&Me&&yt(i.firstChild);let d=c?e:i;try{c&&nn(e);let t=Ft(d);for(;o=t.nextNode();)qt(o,d),en(o,d),Bt(o.content)&&tn(o.content);c&&kt(e,l)}catch(t){throw c&&(xt(e),Ot(e,l)),t}finally{Ve=u}if(c){if(Ot(e,l))throw zs(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return Ee&&Lt(e),e}if(Ne){if(Ee&&Lt(i),Pe)for(s=oe.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(I.shadowroot||I.shadowrootmode)&&(s=ce.call(r,s,!0)),s}let f=Oe?i.outerHTML:i.innerHTML;return Oe&&F[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Rs(pc,i.ownerDocument.doctype.name)&&(f=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
94
94
|
`+f),Ee&&(f=It(f)),D&&Fe?te(f):f},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ft(e),ke=!0,Ae=F,je=I},t.clearConfig=function(){R=null,ke=!1,Ae=null,je=null,D=k,O=``},t.isValidAttribute=function(e,t,n){R||ft({});let r=lt(e),i=lt(t);return typeof n==`string`&&($t(t,n)||!Te&&Rs(vc,n))?!1:Jt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&Is(N,e)&&ys(N[e],t)},t.removeHook=function(e,t){if(Is(N,e)){if(t!==void 0){let n=_s(N[e],t);return n===-1?void 0:xs(N[e],n,1)[0]}return vs(N[e])}},t.removeHooks=function(e){Is(N,e)&&(N[e]=[])},t.removeAllHooks=function(){N=Cc()},t}var Dc=Ec();function Oc(e,t){try{let n=new URL(e,t||void 0);return n.protocol===`http:`||n.protocol===`https:`?n.toString():null}catch{return null}}function kc(e){if(!e)return``;try{return new URL(e).pathname.split(`/`).filter(Boolean).at(-1)?.toLowerCase()?.replace(/[-_]\d{2,4}x\d{2,4}(?=\.\w+$)/,``).replace(/\.(?:webp|jpeg)$/,`.jpg`)??``}catch{return``}}var Ac={USE_PROFILES:{html:!0},ALLOWED_ATTR:[`href`,`src`,`alt`,`title`,`width`,`height`,`data-media`,`data-source`],ALLOW_DATA_ATTR:!1,FORBID_TAGS:[`form`,`input`,`button`,`textarea`,`select`,`style`,`video`,`audio`,`source`]};function jc(e,t){return e.getAttribute(`width`)===`1`&&e.getAttribute(`height`)===`1`||!!(t&&/feedsportal\.com|feedburner\.com|pixel\.wp\.com|statcounter\.com/i.test(t))}function Mc(e){let t=Number(e.getAttribute(`width`)),n=Number(e.getAttribute(`height`));return t>0&&t<160||n>0&&n<100}function Nc(e,t){if(!e)return null;let n=Dc.sanitize(e,Ac),r=new DOMParser().parseFromString(n,`text/html`);for(let e of r.querySelectorAll(`img`)){let n=r.createRange();if(n.selectNodeContents(r.body),n.setEndBefore(e),n.toString().trim().length>160)return null;let i=Oc(e.getAttribute(`src`)??``,t);if(i&&!jc(e,i)&&!Mc(e))return i}return null}function Pc(e,t={}){if(!e)return``;let n=Dc.sanitize(e,Ac),r=new DOMParser().parseFromString(n,`text/html`),i=t.heroImageUrl?Oc(t.heroImageUrl,t.baseUrl):null,a=kc(i),o=r.body.textContent?.trim().length??0,s=null,c=null;Array.from(r.querySelectorAll(`img`)).forEach((e,n)=>{let l=Oc(e.getAttribute(`src`)??``,t.baseUrl),u=kc(l),d=!1;if(n===0&&i?.includes(`/archive/images/`)&&l?.includes(`/archive/images/`)){let t=r.createRange();t.selectNodeContents(r.body),t.setEndBefore(e),d=!t.toString().trim()}let f=!!(i&&l&&(l===i||a&&u===a||d||n===0&&o<400)),p=!1;if(l&&l===c&&s){let t=r.createRange();t.setStartAfter(s),t.setEndBefore(e),p=!t.toString().trim()}if(!l||jc(e,l)||f||p){let t=f?e.getAttribute(`alt`)?.trim():null,n=e.closest(`p`);e.remove(),t&&t.length>=15&&n&&n.textContent?.trim()===t&&!n.querySelector(`img`)&&n.remove()}else e.setAttribute(`src`,l),e.removeAttribute(`loading`),s=e,c=l}),r.querySelectorAll(`a`).forEach(e=>{let n=Oc(e.getAttribute(`href`)??``,t.baseUrl);n?(e.setAttribute(`href`,n),e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)):e.removeAttribute(`href`)}),t.paywallLabel&&r.querySelectorAll(`a[data-media="paywall"]`).forEach(e=>{e.textContent=t.paywallLabel??``}),r.querySelectorAll(`p, div, figure, a`).forEach(e=>{!e.textContent?.trim()&&!e.querySelector(`img`)&&e.remove()});let l=Array.from(r.body.childNodes);if(l.some(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())&&!r.body.querySelector(`p`)){let e=r.createElement(`p`);l.forEach(t=>e.appendChild(t)),r.body.appendChild(e)}return Dc.sanitize(r.body.innerHTML,Ac)}function Fc(e){return e?Math.max(1,Math.ceil(e.trim().split(/\s+/).length/200)):1}var Ic=new Map;function Lc(e){let t=Ic.get(e);return t||(t=new Promise(t=>{let n=new Image;n.onload=()=>t(n.naturalWidth>0&&n.naturalHeight>0),n.onerror=()=>t(!1),n.src=e}),Ic.set(e,t)),t}function Rc(e){let t=5381n;for(let n of e)t=BigInt.asUintN(64,t*33n+BigInt(n.codePointAt(0)??0));return`hsl(${Number(t%360n)} 33% 43.5%)`}function zc({feedId:e,iconUrl:t,siteUrl:n,feedUrl:r,articleUrl:i,fallbackName:a,className:o}){let s=JSON.stringify([e,t,n,r,i]),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let a=!1;l(null);async function o(){if(e){let t=`/api/feeds/${e}/icon`;await Lc(t)?a||l({key:s,url:t}):a||d(s);return}let o=new Set;t&&/^https?:\/\//i.test(t)&&o.add(t);for(let e of[n,r,i])if(e)try{let t=new URL(e);(t.protocol===`https:`||t.protocol===`http:`)&&o.add(`${t.origin}/favicon.ico`)}catch{}for(let e of o)if(await Lc(e)){a||l({key:s,url:e});return}a||d(s)}return o(),()=>{a=!0}},[s]),!c||c.key!==s?a&&u===s?(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`${o} inline-grid place-items-center font-semibold text-white`,style:{backgroundColor:Rc(a),fontSize:`0.58em`},children:Array.from(a.trim())[0]?.toUpperCase()??`?`}):null:(0,U.jsx)(`img`,{src:c.url,alt:``,className:o,loading:`lazy`,onError:()=>{Ic.set(c.url,Promise.resolve(!1)),l(null)}})}function Bc({text:e}){let t=(0,_.useMemo)(()=>!e||!To(e)?e:Wo(e).map((e,t)=>e.kind===`wbr`?(0,U.jsx)(`wbr`,{},t):e.kind===`nb`?(0,U.jsx)(`span`,{className:`nb`,children:e.value},t):(0,U.jsx)(_.Fragment,{children:e.value},t)),[e]);return(0,U.jsx)(U.Fragment,{children:t})}function Vc({item:e,isOpen:t,onClose:n,onToggleBookmark:r,onToggleRead:i,onNext:a,onPrevious:o,onItemUpdated:s,hasNext:c=!1,hasPrev:l=!1}){let{t:u,i18n:d}=R(),[f,p]=(0,_.useState)(61),m=(0,_.useRef)(null),h=(0,_.useCallback)(e=>{if(m.current?.disconnect(),!e)return;let t=()=>p(e.offsetHeight);t(),m.current=new ResizeObserver(t),m.current.observe(e)},[]),[g,v]=(0,_.useState)(!1),y=(0,_.useRef)(new Set),[b,x]=(0,_.useState)(new Set),S=e!==null&&b.has(e.id),C=(0,_.useRef)(e?.id??null);C.current=t?e?.id??null:null;let[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(null),O=e?.author||E,[k,A]=(0,_.useState)(null),[j,ee]=(0,_.useState)(!1),te=e?.feed_full_text_mode===`never`,[ne,re]=(0,_.useState)(null),M=e?.link?Oc(e.link):null;(0,_.useEffect)(()=>{T(!!e?.full_content_html),A(null),ee(!1)},[e?.id,e?.full_content_html]),(0,_.useEffect)(()=>{D(null)},[e?.id]),(0,_.useEffect)(()=>{t&&e&&M&&localStorage.getItem(`feedkeeper_auto_reader_mode`)!==`false`&&!e.full_content_html&&!te&&navigator.onLine&&ie()},[t,e?.id]),(0,_.useEffect)(()=>{if(t){let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}}},[t]);let ie=(0,_.useCallback)(async()=>{if(!e||y.current.has(e.id))return;if(e.full_content_html){T(e=>!e);return}if(!M)return;let t=e;y.current.add(t.id),x(new Set(y.current)),A(null),ee(!1);try{let e=await H.extractContent(t.id),n={id:t.id,full_content_html:e.full_content_html};s?.(n),C.current===t.id&&(e.byline&&D(e.byline),T(!0))}catch(e){C.current===t.id&&(e instanceof va&&e.code===`consent_wall`?ee(!0):e instanceof va&&e.status===0?A(u(`common.offlineAction`)):e instanceof va&&e.code===`full_text_disabled`||(console.error(`Failed to extract full text:`,e),A(u(`reader.extractionFailed`))))}finally{y.current.delete(t.id),x(new Set(y.current))}},[e,M,u,s]);(0,_.useEffect)(()=>{if(!t||!e)return;let s=e;function u(e){document.activeElement instanceof HTMLInputElement||document.activeElement instanceof HTMLTextAreaElement||(e.key===`Escape`?(e.preventDefault(),n()):(e.key===`j`||e.key===`ArrowRight`)&&c&&a?(e.preventDefault(),a()):(e.key===`k`||e.key===`ArrowLeft`)&&l&&o?(e.preventDefault(),o()):e.key===`s`||e.key===`S`?(e.preventDefault(),r(s)):e.key===`m`||e.key===`M`?(e.preventDefault(),i(s)):e.key===`r`||e.key===`R`?(e.preventDefault(),ie()):(e.key===`o`||e.key===`O`)&&M&&(e.preventDefault(),window.open(M,`_blank`,`noopener,noreferrer`)))}return window.addEventListener(`keydown`,u),()=>window.removeEventListener(`keydown`,u)},[t,e,M,c,l,a,o,n,r,i,ie]);let ae=(0,_.useMemo)(()=>e?.published_at?new Date(e.published_at):null,[e?.published_at]),oe=(0,_.useMemo)(()=>ae?new Intl.DateTimeFormat(d.resolvedLanguage,{dateStyle:`medium`}).format(ae):``,[ae,d.resolvedLanguage]),se=(0,_.useMemo)(()=>ae?new Intl.DateTimeFormat(d.resolvedLanguage,{timeStyle:`short`}).format(ae):``,[ae,d.resolvedLanguage]),ce=w?e?.full_content_html:e?.content_html,N=(0,_.useMemo)(()=>e?.image_url??Nc(ce??``,e?.link),[e?.image_url,ce,e?.link]);(0,_.useEffect)(()=>{if(re(null),!t||!N)return;let e=!1,n=new Image;return n.onload=()=>{!e&&n.naturalWidth>0&&n.naturalHeight>0&&re({src:N,width:n.naturalWidth,height:n.naturalHeight})},n.src=N,()=>{e=!0}},[t,N]);let le=ne?.src===N?ne:null,ue=le!==null&&le.width<=320&&le.height<=240,de=(0,_.useMemo)(()=>e&&ce?Yo(Pc(ce,{heroImageUrl:N,baseUrl:e.link,paywallLabel:u(`reader.paywallRead`)})):``,[e,ce,N,u]),fe=(0,_.useMemo)(()=>Fc((ce??e?.content_snippet??``).replace(/<[^>]+>/g,` `)),[ce,e?.content_snippet]);return!t||!e?null:(0,Xo.createPortal)((0,U.jsxs)(`div`,{className:`fixed inset-0 z-50 flex justify-end`,children:[(0,U.jsx)(`div`,{className:`fixed inset-0 bg-black/60 backdrop-blur-xs transition-opacity animate-fade-in`,onClick:n,"aria-hidden":`true`}),(0,U.jsxs)(`div`,{className:`relative z-10 w-full sm:max-w-2xl md:max-w-3xl h-full h-[100dvh] bg-[var(--c-surface)] shadow-2xl flex flex-col border-0 sm:border-l border-[var(--c-border)] animate-drawer-in`,role:`dialog`,"aria-modal":`true`,"aria-label":e.title??u(`items.title`),children:[(0,U.jsxs)(`header`,{ref:h,className:`absolute inset-x-0 top-0 z-20 px-4 py-3 border-b border-[var(--c-border)] backdrop-blur-md transform-gpu flex items-center justify-between gap-3`,style:{paddingTop:`max(0.75rem, env(safe-area-inset-top, 0px))`,backgroundColor:`color-mix(in srgb, var(--c-surface) 85%, transparent)`},children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 pr-2 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:[(0,U.jsx)(zc,{feedId:e.feed_id,iconUrl:e.feed_icon_url,siteUrl:e.feed_site_url,feedUrl:e.feed_url,articleUrl:e.link,className:`h-3.5 w-3.5 shrink-0 rounded-xs object-contain`}),(0,U.jsx)(`span`,{className:`truncate`,children:e.feed_title})]}),(0,U.jsx)(`button`,{type:`button`,onClick:n,title:u(`reader.close`),"aria-label":u(`reader.close`),className:`w-9 h-9 -mr-1 rounded-xl text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/60 active:scale-95 transition-all cursor-pointer flex items-center justify-center shrink-0`,children:(0,U.jsxs)(`svg`,{className:`w-6 h-6`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,U.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]}),(0,U.jsxs)(`main`,{className:`flex-1 overflow-y-auto overscroll-contain transform-gpu`,style:{paddingTop:f},children:[le&&!ue&&(0,U.jsx)(`img`,{src:le.src,alt:``,className:`block w-full max-h-[380px] object-cover`,onError:()=>re(null)}),(0,U.jsx)(`div`,{className:`px-5 sm:px-10 py-6 sm:py-8`,style:{paddingBottom:`max(2rem, env(safe-area-inset-bottom, 0px))`},children:(0,U.jsxs)(`article`,{className:`max-w-prose mx-auto`,children:[(0,U.jsxs)(`div`,{className:`flow-root`,children:[le&&ue&&(0,U.jsx)(`div`,{className:`float-right ml-4 mb-3 sm:ml-6 rounded-xl overflow-hidden border border-[var(--c-border)] bg-[var(--c-bg)] shadow-xs`,style:{width:le.width,maxWidth:`42%`},children:(0,U.jsx)(`img`,{src:le.src,alt:``,className:`block w-full h-auto`,onError:()=>re(null)})}),(0,U.jsx)(`h1`,{lang:Eo(e.title),className:`text-2xl sm:text-3xl font-bold font-['Manrope'] text-[var(--c-text)] leading-snug tracking-tight mb-3${Eo(e.title)===`ja`?` ja-phrases`:``}`,children:e.title?(0,U.jsx)(Bc,{text:e.title}):null})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 text-xs text-[var(--c-text-muted)] pb-5 border-b border-[var(--c-border)] mb-6 font-medium`,children:[O&&(0,U.jsx)(`span`,{children:O}),oe&&(0,U.jsxs)(U.Fragment,{children:[O&&(0,U.jsx)(`span`,{children:`•`}),(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsxs)(`svg`,{className:`w-3.5 h-3.5 shrink-0 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`18`,rx:`2`,ry:`2`}),(0,U.jsx)(`line`,{x1:`16`,y1:`2`,x2:`16`,y2:`6`}),(0,U.jsx)(`line`,{x1:`8`,y1:`2`,x2:`8`,y2:`6`}),(0,U.jsx)(`line`,{x1:`3`,y1:`10`,x2:`21`,y2:`10`})]}),(0,U.jsx)(`span`,{children:oe})]}),(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsxs)(`svg`,{className:`w-3.5 h-3.5 shrink-0 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,U.jsx)(`polyline`,{points:`12 6 12 12 16 14`})]}),(0,U.jsx)(`span`,{children:se})]})]}),(O||oe)&&(0,U.jsx)(`span`,{children:`•`}),(0,U.jsx)(`span`,{children:u(`reader.readingTime`,{count:fe})})]}),j&&(0,U.jsxs)(`div`,{className:`mb-6 p-4 rounded-xl border border-[var(--c-border)] bg-[var(--c-bg)] text-sm text-[var(--c-text-muted)] flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,U.jsx)(`span`,{children:u(`reader.consentWall`)}),M&&(0,U.jsx)(`a`,{href:M,target:`_blank`,rel:`noreferrer noopener`,className:`btn-primary text-sm whitespace-nowrap self-start sm:self-center`,children:u(`reader.readOriginal`)})]}),k&&(0,U.jsxs)(`div`,{className:`mb-6 p-4 rounded-xl bg-red-500/10 border border-red-500/30 text-red-600 dark:text-red-400 text-xs flex items-center justify-between gap-3`,children:[(0,U.jsx)(`span`,{children:k}),M&&(0,U.jsx)(`a`,{href:M,target:`_blank`,rel:`noreferrer noopener`,className:`underline font-semibold whitespace-nowrap hover:opacity-80`,children:u(`reader.openOriginal`)})]}),de?(0,U.jsx)(`div`,{className:`reader-content`,lang:Eo(e.content_snippet??e.title),dangerouslySetInnerHTML:{__html:de}}):e.content_snippet?(0,U.jsx)(`div`,{className:`reader-content`,lang:Eo(e.content_snippet),children:e.content_snippet.split(`
|
|
95
95
|
|
|
96
|
-
`).map((e,t)=>(0,U.jsx)(`p`,{children:(0,U.jsx)(Bc,{text:e})},t))}):(0,U.jsx)(`p`,{className:`text-[var(--c-text-muted)] italic`,children:u(`items.noItems`)}),(0,U.jsxs)(`div`,{className:`mt-12 pt-6 border-t border-[var(--c-border)]/60 flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:o,disabled:!l,title:u(`reader.previous`),"aria-label":u(`reader.previous`),className:`w-10 h-10 rounded-xl border border-[var(--c-border)] flex items-center justify-center text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40 active:scale-95 disabled:opacity-30 disabled:cursor-not-allowed transition-all cursor-pointer`,children:(0,U.jsx)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`polyline`,{points:`15 18 9 12 15 6`})})}),(0,U.jsx)(`button`,{type:`button`,onClick:a,disabled:!c,title:u(`reader.next`),"aria-label":u(`reader.next`),className:`w-10 h-10 rounded-xl border border-[var(--c-border)] flex items-center justify-center text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40 active:scale-95 disabled:opacity-30 disabled:cursor-not-allowed transition-all cursor-pointer`,children:(0,U.jsx)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`polyline`,{points:`9 18 15 12 9 6`})})})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[M&&(!te||e.full_content_html)&&(0,U.jsx)(`button`,{type:`button`,onClick:ie,disabled:S,title:u(w?`reader.togglePreview`:`reader.toggleFullText`),"aria-label":u(w?`reader.togglePreview`:`reader.toggleFullText`),className:`w-10 h-10 rounded-xl border flex items-center justify-center transition-all active:scale-95 cursor-pointer ${w?`bg-[var(--c-blue1)]/15 border-[var(--c-blue1)]/40 text-[var(--c-blue1)]`:`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40`}`,children:S?(0,U.jsx)(`svg`,{className:`w-4 h-4 animate-spin text-[var(--c-blue1)]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,strokeDasharray:`32`,strokeDashoffset:`12`})}):(0,U.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`path`,{d:`M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z`}),(0,U.jsx)(`path`,{d:`M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z`})]})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>r(e),title:e.bookmarked?u(`reader.unbookmark`):u(`reader.bookmark`),"aria-label":e.bookmarked?u(`reader.unbookmark`):u(`reader.bookmark`),className:`w-10 h-10 rounded-xl border flex items-center justify-center transition-all active:scale-95 cursor-pointer ${e.bookmarked?`bg-amber-500/15 border-amber-500/40 text-amber-500`:`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500 hover:border-amber-500/30`}`,children:(0,U.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:e.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>i(e),title:e.read?u(`reader.markUnread`):u(`reader.markRead`),"aria-label":e.read?u(`reader.markUnread`):u(`reader.markRead`),className:`w-10 h-10 rounded-xl border flex items-center justify-center transition-all active:scale-95 cursor-pointer ${e.read?`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)]`:`border-[var(--c-border)] text-[var(--c-blue1)] hover:border-[var(--c-blue3)]`}`,children:(0,U.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:e.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2.2`,children:(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})}),(0,U.jsx)(`button`,{type:`button`,onClick:async()=>{if(M)try{await navigator.clipboard.writeText(M),v(!0),setTimeout(()=>v(!1),2e3)}catch{}},title:u(g?`reader.linkCopied`:`reader.copyLink`),"aria-label":u(`reader.copyLink`),className:`w-10 h-10 rounded-xl border border-[var(--c-border)] flex items-center justify-center text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40 transition-all active:scale-95 cursor-pointer relative`,children:g?(0,U.jsx)(`svg`,{className:`w-4 h-4 text-emerald-500`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}):(0,U.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`}),(0,U.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})}),M&&(0,U.jsx)(`a`,{href:M,target:`_blank`,rel:`noreferrer noopener`,title:u(`reader.openOriginal`),"aria-label":u(`reader.openOriginal`),className:`w-10 h-10 rounded-xl border border-[var(--c-border)] flex items-center justify-center text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40 transition-all active:scale-95`,children:(0,U.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`}),(0,U.jsx)(`polyline`,{points:`15 3 21 3 21 9`}),(0,U.jsx)(`line`,{x1:`10`,y1:`14`,x2:`21`,y2:`3`})]})})]})]})]})})]})]})]}),document.body)}var Hc=`feedkeeper:extensions-changed`,Uc=[`login`,`menu`,`page`],Wc=/^[a-z0-9][a-z0-9-]{0,63}$/,Gc=(e,t)=>typeof e==`string`&&e.trim().length>0&&e.length<=t,Kc=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function qc(e){return Kc(e)?typeof e.id==`string`&&Wc.test(e.id)&&Gc(e.label,80)&&Gc(e.description,300)&&Gc(e.group,60)&&(e.shortLabel===void 0||Gc(e.shortLabel,40))&&(e.icon===void 0||Array.isArray(e.icon)&&e.icon.length<=8&&e.icon.every(e=>typeof e==`string`&&e.length<=400))&&(e.admin===void 0||typeof e.admin==`boolean`)&&typeof e.mount==`function`:!1}function Jc(e,t,n){let r=Kc(e)&&Kc(e.settings)?e.settings:{},i=new Set(Array.isArray(r.hidden)?r.hidden.filter(e=>typeof e==`string`&&t.includes(e)):[]),a=new Set(t),o=[];for(let e of Array.isArray(r.sections)?r.sections:[])qc(e)&&!a.has(e.id)&&(a.add(e.id),(!e.admin||n)&&o.push(e));return{hidden:i,sections:o}}function Yc(e){let t=[];for(let n of e){let e=n.group??``,r=t.find(t=>t.group===e);r?r.sections.push(n):t.push({group:e,sections:[n]})}return t}function Xc(e,t){if(typeof e==`string`)return e;if(!Kc(e))return null;let n=t.toLowerCase();for(let t of[n,n.split(`-`)[0],`en`]){let n=Object.entries(e).find(([e])=>e.toLowerCase()===t)?.[1];if(typeof n==`string`)return n}return Object.values(e).find(e=>typeof e==`string`)??null}function Zc(e){return/[\u0000-\u001f\\]/.test(e)||e.length>500?!1:/^\/(?![/\\])/.test(e)||/^https?:\/\/[^\s/]+/i.test(e)}function Qc(e,t,n){let r=Kc(e)&&Array.isArray(e.footerLinks)?e.footerLinks:[],i=[];for(let e of r.slice(0,8)){if(!Kc(e))continue;let r=Xc(e.label,t),a=Xc(e.href,t);if(!r||!Gc(r,60)||!a||!Zc(a)||n&&Array.isArray(e.placements)&&!e.placements.some(e=>e===n&&Uc.includes(e)))continue;let o=typeof e.icon==`string`&&Zc(e.icon)?e.icon:null;i.push({label:r,href:a,newTab:e.newTab===!0||/^https?:/i.test(a),icon:o})}return i}function $c(e){let t=Kc(e)?e.loginForm:void 0;return Kc(t)&&typeof t.mount==`function`?t:null}function el(e){let t=Kc(e)?e.passwordCard:void 0;return!Kc(t)||typeof t.mount!=`function`?null:{mount:t.mount,...typeof t.applies==`function`?{applies:t.applies}:{}}}function tl(e){let t=Kc(e)?e.onboarding:void 0;return Kc(t)&&typeof t.mount==`function`?t:null}function nl(e){if(typeof e!=`string`||e.length>500)return null;try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&!t.username&&!t.password?t.toString():null}catch{return null}}function rl(e,t,n){let r=Kc(e)&&Kc(e.starterPacks)?e.starterPacks:{},i=Array.isArray(r.packs)?r.packs:[],a=new Map;if(r.replace!==!0)for(let e of t)a.set(e.id,e);for(let e of i.slice(0,12))Kc(e)&&typeof e.id==`string`&&Wc.test(e.id)&&Array.isArray(e.feeds)&&a.set(e.id,e);let o=[];for(let e of a.values()){let t=Xc(e.title,n);if(!t||!Gc(t,60))continue;let r=[];for(let t of e.feeds.slice(0,20)){if(!Kc(t)||!Gc(t.title,80))continue;let e=nl(t.url);if(!e)continue;let i=Xc(t.description,n);r.push({title:t.title,url:e,lang:typeof t.lang==`string`?t.lang.toLowerCase().split(`-`)[0]:``,description:i&&Gc(i,200)?i:``})}r.length>0&&o.push({id:e.id,title:t,description:Xc(e.description,n)??``,feeds:r})}return o}function il(e){let t=Kc(e)?e.articlesNotice:void 0;return!Kc(t)||typeof t.mount!=`function`?null:{mount:t.mount,...typeof t.applies==`function`?{applies:t.applies}:{}}}function al(e,t){let n=Kc(e)&&Kc(e.meta)?e.meta:{},r=Xc(n.title,t)?.trim()??null,i=Xc(n.description,t)?.trim()??null;return{title:r&&Gc(r,80)?r:null,description:i&&Gc(i,300)?i:null}}function ol(e,t){if(!Kc(e)||!Array.isArray(e.pages))return[];let n=[],r=new Set;for(let i of e.pages){if(!Kc(i)||typeof i.id!=`string`||!Wc.test(i.id)||r.has(i.id))continue;let e=Xc(i.label,t);if(Gc(e,40)&&typeof i.mount==`function`&&!(!Array.isArray(i.icon)||!i.icon.length||i.icon.length>8||!i.icon.every(e=>Gc(e,400)))&&(n.push({id:i.id,label:e,icon:i.icon,mount:i.mount}),r.add(i.id),n.length===3))break}return n}var sl=0;function cl(e){let t=()=>{sl++,e()};return window.addEventListener(Hc,t),()=>window.removeEventListener(Hc,t)}function ll(){return(0,_.useSyncExternalStore)(cl,()=>sl),window.feedkeeperExtensions}function ul(){let{pageId:e}=vr(),{user:t}=lo(),{i18n:n}=R(),r=n.resolvedLanguage||`en`,i=ol(ll(),r).find(({id:t})=>t===e);return t&&i?(0,U.jsx)(dl,{page:i,userId:t.id,language:r},t.id):null}function dl({page:{mount:e},userId:t,language:n}){let r=(0,_.useRef)(null),[i,a]=(0,_.useState)(null);(0,_.useEffect)(()=>{if(!r.current)return;let i=r.current,o=!0,s;try{s=e(i,{userId:t,language:n,appendText:fl,openArticle:(e,t)=>{o&&a({item:e,onChange:t})}})}catch(e){console.error(`Could not mount extension page`,e),i.replaceChildren()}return()=>{o=!1,typeof s==`function`&&s(),i.replaceChildren(),a(null)}},[e,t,n]);function o(e){i&&i.item.id===e.id&&(i.onChange(e),a(t=>t?.item.id===e.id?{...t,item:{...t.item,...e}}:t))}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{ref:r}),i&&(0,U.jsx)(Vc,{item:i.item,isOpen:!0,onClose:()=>a(null),onItemUpdated:e=>o({...i.item,...e}),onToggleRead:e=>{ya(`read`,e.id,!e.read).then(()=>{no(),o({...e,read:!e.read})}).catch(console.error)},onToggleBookmark:e=>{ya(`bookmark`,e.id,!e.bookmarked).then(()=>o({...e,bookmarked:!e.bookmarked})).catch(console.error)}})]})}function fl(e,t){Eo(t)&&(e.lang=`ja`);for(let n of Wo(t))if(n.kind===`wbr`)e.append(document.createElement(`wbr`));else if(n.kind===`nb`){let t=document.createElement(`span`);t.className=`nb`,t.textContent=n.value,e.append(t)}else e.append(n.value)}var pl=`M435.6,124.8l0,-73.2l-435.6,0l-0,816l92.4,-0l0,-381.6l325.2,0l-0,-74.4l-325.2,0l0,-286.8l343.2,0zM1065.6,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM1722,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM2396.4,830.4l0,-830.4l-90,0l0,278.4c-18,-8.4,-97.2,-39.6,-188.4,-39.6c-164.4,0,-262.8,106.8,-262.8,306c0,242.4,86.4,337.2,279.6,337.2c121.2,-0,216,-32.4,261.6,-51.6zm-90,-48c-21.6,12,-84,33.6,-171.6,33.6c-129.6,0,-188.4,-78,-188.4,-271.2c0,-159.6,63.6,-238.8,189.6,-238.8c72,0,146.4,28.8,170.4,38.4l0,438zM3187.2,867.6l-386.4,-427.2l355.2,-388.8l-120,0l-340.8,388.8l367.2,427.2l124.8,-0zm-494.4,-0l-0,-816l-92.4,0l0,816l92.4,-0zM3776.4,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM4432.8,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM5133.6,544.8c0,-210,-92.4,-306,-282,-306c-118.8,0,-231.6,36,-260.4,50.4l-0,832.8l90,0l0,-280.8c16.8,13.2,99.6,40.8,187.2,40.8c165.6,0,265.2,-92.4,265.2,-337.2zm-93.6,0c0,194.4,-57.6,271.2,-188.4,271.2c-69.6,0,-141.6,-25.2,-170.4,-37.2l0,-439.2c18,-8.4,81.6,-33.6,171.6,-33.6c120,0,187.2,68.4,187.2,238.8zM5792.4,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM6256.8,313.2l0,-68.4c-9.6,-1.2,-50.4,-6,-66,-6c-106.8,0,-223.2,39.6,-240,48l-0,580.8l90,-0l0,-531.6c16.8,-6,90,-28.8,158.4,-28.8c14.4,0,45.6,3.6,57.6,6z`;function ml(){return(0,U.jsx)(`svg`,{className:`wordmark`,viewBox:`0 0 6257 1122`,role:`img`,"aria-label":`FeedKeeper`,children:(0,U.jsx)(`path`,{d:pl})})}function hl({size:e=28}){return(0,U.jsxs)(`span`,{className:`brand-lockup`,style:{"--m":`${e}px`},children:[(0,U.jsx)(`img`,{src:`/logo.svg`,alt:``}),(0,U.jsx)(ml,{})]})}var gl=({isActive:e})=>`relative z-10 flex h-full items-center gap-2 rounded-lg px-3 text-sm font-medium transition-colors focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${e?`text-[var(--c-text)]`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`;function _l({onItemsClick:e,pages:t}){let{t:n,i18n:r}=R(),i=dr(),a=(0,_.useRef)(null),[o,s]=(0,_.useState)(null),c=t.map(({id:e,label:t})=>e+t).join(`|`);return(0,_.useLayoutEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{let t=e.querySelector(`a[aria-current="page"]`);s(t?{left:t.offsetLeft,width:t.offsetWidth}:null)};t();let n=new ResizeObserver(t);return e.querySelectorAll(`a`).forEach(e=>n.observe(e)),()=>n.disconnect()},[i.pathname,r.resolvedLanguage,c]),(0,U.jsxs)(`nav`,{ref:a,className:`relative hidden h-9 items-center rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] p-0.5 md:flex`,children:[o&&(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0.5 left-0 rounded-lg border border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] shadow-sm transition-[transform,width] duration-300 ease-[cubic-bezier(0.25,1,0.5,1)] motion-reduce:transition-none`,style:{width:o.width,transform:`translateX(${o.left}px)`}}),t.map(({id:e,label:t,icon:n})=>(0,U.jsxs)(Mi,{to:`/extensions/${e}`,className:gl,children:[(0,U.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:n.map(e=>(0,U.jsx)(`path`,{d:e},e))}),t]},e)),(0,U.jsxs)(Mi,{to:`/items`,onClick:e,className:gl,children:[(0,U.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h12`})}),n(`nav.items`)]}),(0,U.jsxs)(Mi,{to:`/feeds`,className:gl,children:[(0,U.jsxs)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`path`,{d:`M4 11a9 9 0 0 1 9 9`}),(0,U.jsx)(`path`,{d:`M4 4a16 16 0 0 1 16 16`}),(0,U.jsx)(`circle`,{cx:`5`,cy:`19`,r:`1`})]}),n(`nav.feeds`)]})]})}var vl=`fk_theme`,yl=new Set,bl=(()=>{try{let e=localStorage.getItem(vl);return e===`light`||e===`dark`?e:`system`}catch{return`system`}})();function xl(e){return yl.add(e),()=>yl.delete(e)}function Sl(){return bl}function Cl(e){bl=e,e===`system`?document.documentElement.removeAttribute(`data-theme`):document.documentElement.setAttribute(`data-theme`,e);try{e===`system`?localStorage.removeItem(vl):localStorage.setItem(vl,e)}catch{}yl.forEach(e=>e())}function wl({standalone:e,hasPrompt:t,userAgent:n,maxTouchPoints:r}){if(e)return`installed`;if(t)return`prompt`;if(/iPhone|iPad|iPod/.test(n)||/Macintosh/.test(n)&&r>1)return`ios`;let i=/Safari\//.test(n)&&!/Chrome|Chromium|CriOS|FxiOS|Edg|OPR|Firefox/.test(n);return/Macintosh/.test(n)&&i?`mac-safari`:`unsupported`}var Tl=null,El=!1,Dl=new Set,Ol=()=>Dl.forEach(e=>e());function kl(){window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),Tl=e,Ol()}),window.addEventListener(`appinstalled`,()=>{Tl=null,El=!0,Ol()})}function Al(e){Dl.add(e);let t=window.matchMedia(`(display-mode: standalone)`);return t.addEventListener(`change`,e),()=>{Dl.delete(e),t.removeEventListener(`change`,e)}}function jl(){return wl({standalone:El||window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0,hasPrompt:Tl!==null,userAgent:navigator.userAgent,maxTouchPoints:navigator.maxTouchPoints??0})}async function Ml(){let e=Tl;if(!e)return;Tl=null,await e.prompt();let{outcome:t}=await e.userChoice;t===`accepted`&&(El=!0),Ol()}function Nl(e,t){let n=e.trim().split(/\s+/).filter(Boolean);return n.length===0?t.charAt(0).toUpperCase()||`?`:(n[0].charAt(0)+(n.length>1?n[n.length-1].charAt(0):``)).toUpperCase()}function Pl({user:e,className:t=``}){let n=Ca(e),[r,i]=(0,_.useState)(null);return(0,U.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full border border-[var(--c-border)] bg-[var(--c-mobile-nav-active)] font-semibold tracking-wide text-[var(--c-text)] ${t}`,children:n&&r!==n?(0,U.jsx)(`img`,{src:n,alt:``,className:`h-full w-full object-cover`,onError:()=>i(n)}):(0,U.jsx)(`span`,{"aria-hidden":`true`,children:Nl(e.display_name,e.email)})})}var Fl={login:`mt-4 justify-center text-xs`,menu:`border-t border-[var(--c-border)] px-3 py-2.5 text-xs`,page:`mt-10 border-t border-[var(--c-border)] pt-4 text-xs`};function Il({placement:e}){let{t,i18n:n}=R(),r=Qc(ll(),n.resolvedLanguage||`en`,e);return r.length===0?null:(0,U.jsx)(`nav`,{"aria-label":t(`nav.footerLinks`),className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[var(--c-text-muted)] ${Fl[e]}`,children:r.map((e,t)=>(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-3`,children:[t>0&&(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`opacity-50`,children:`•`}),(0,U.jsxs)(`a`,{href:e.href,...e.newTab?{target:`_blank`,rel:`noopener noreferrer`}:{},className:`transition-colors hover:text-[var(--c-text)] hover:underline`,children:[e.icon&&(0,U.jsx)(`img`,{src:e.icon,alt:``,width:14,height:14,className:`mr-1.5 inline-block align-[-2px]`}),e.label]})]},`${e.href}-${t}`))})}var Ll={light:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,U.jsx)(`path`,{d:`M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41`})]}),dark:(0,U.jsx)(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`}),system:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,U.jsx)(`path`,{d:`M12 3a9 9 0 0 1 0 18Z`,fill:`currentColor`,stroke:`none`})]})},Rl=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm font-medium text-[var(--c-text)] transition-colors hover:bg-[var(--c-surface-hover)] focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] cursor-pointer`;function zl(){let{t:e}=R(),{user:t,logout:n}=lo(),r=dr(),i=(0,_.useSyncExternalStore)(xl,Sl),a=(0,_.useSyncExternalStore)(Al,jl),[o,s]=(0,_.useState)(!1),c=(0,_.useRef)(null),l=(0,_.useRef)(null),u=(0,_.useId)();if((0,_.useEffect)(()=>s(!1),[r.pathname]),(0,_.useEffect)(()=>{if(!o)return;let e=e=>{c.current?.contains(e.target)||s(!1)},t=e=>{e.key===`Escape`&&(s(!1),l.current?.focus())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[o]),!t)return null;let d={light:e(`settings.themeLight`),dark:e(`settings.themeDark`),system:e(`settings.themeSystem`)};return(0,U.jsxs)(`div`,{ref:c,className:`relative`,children:[(0,U.jsx)(`button`,{ref:l,type:`button`,onClick:()=>s(e=>!e),"aria-expanded":o,"aria-controls":u,"aria-label":e(`nav.account`),title:t.display_name||t.email,className:`flex rounded-full transition-shadow cursor-pointer focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--c-blue3)] ${o||r.pathname.startsWith(`/settings`)?`ring-2 ring-[var(--c-blue3)] ring-offset-2 ring-offset-[var(--c-surface)]`:`hover:ring-2 hover:ring-[var(--c-border)] hover:ring-offset-2 hover:ring-offset-[var(--c-surface)]`}`,children:(0,U.jsx)(Pl,{user:t,className:`h-9 w-9 text-xs`})}),o&&(0,U.jsxs)(`div`,{id:u,className:`card animate-fade-in absolute right-0 top-full z-50 mt-2 w-72 max-w-[calc(100vw-2rem)] p-1.5 shadow-xl`,style:{boxShadow:`0 16px 40px -12px rgba(0, 0, 0, 0.35)`},children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3 px-3 pt-2 pb-3`,children:[(0,U.jsx)(Pl,{user:t,className:`h-10 w-10 text-sm`}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`truncate text-sm font-semibold text-[var(--c-text)]`,children:t.display_name||t.email}),t.display_name&&(0,U.jsx)(`p`,{className:`truncate text-xs text-[var(--c-text-muted)]`,children:t.email})]})]}),(0,U.jsxs)(`div`,{className:`border-t border-[var(--c-border)] px-3 py-3`,children:[(0,U.jsx)(`p`,{className:`mb-2 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:e(`settings.theme`)}),(0,U.jsx)(`div`,{className:`grid grid-cols-3 gap-1 rounded-xl border border-[var(--c-border)] p-0.5`,role:`group`,"aria-label":e(`settings.theme`),children:Object.keys(Ll).map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>Cl(e),"aria-pressed":i===e,className:`flex h-8 items-center justify-center gap-1.5 rounded-lg text-xs font-medium transition-colors cursor-pointer focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${i===e?`border border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] text-[var(--c-text)] shadow-sm`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:[(0,U.jsx)(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:Ll[e]}),d[e]]},e))})]}),(0,U.jsxs)(`div`,{className:`flex flex-col border-t border-[var(--c-border)] pt-1.5`,children:[(0,U.jsxs)(Mi,{to:`/settings`,className:`${Rl} max-md:hidden`,children:[(0,U.jsxs)(`svg`,{className:`h-4 w-4 text-[var(--c-text-muted)]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,U.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z`})]}),e(`nav.settings`)]}),a===`prompt`&&(0,U.jsxs)(`button`,{type:`button`,className:Rl,onClick:()=>{s(!1),Ml()},children:[(0,U.jsxs)(`svg`,{className:`h-4 w-4 text-[var(--c-text-muted)]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`path`,{d:`M12 3v12M7 10l5 5 5-5`}),(0,U.jsx)(`path`,{d:`M5 21h14`})]}),e(`settings.installApp`)]}),(0,U.jsxs)(`button`,{type:`button`,className:`${Rl} text-[var(--c-danger)]! hover:bg-[var(--c-danger-bg)]!`,onClick:()=>{s(!1),n()},children:[(0,U.jsxs)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,U.jsx)(`polyline`,{points:`16 17 21 12 16 7`}),(0,U.jsx)(`line`,{x1:`21`,y1:`12`,x2:`9`,y2:`12`})]}),e(`nav.logout`)]})]}),(0,U.jsx)(Il,{placement:`menu`})]})]})}function Bl(e){return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}}function Vl(){return(0,_.useSyncExternalStore)(Bl,()=>navigator.onLine,()=>!0)}function Hl(){let{t:e}=R(),t=(0,_.useSyncExternalStore)(na,ta,()=>0);return Vl()?null:(0,U.jsxs)(`div`,{role:`status`,className:`border-b px-4 py-2 text-center text-sm text-[var(--c-text-muted)]`,style:{borderColor:`var(--c-border)`,backgroundColor:`var(--c-surface)`},children:[e(`common.offlineBanner`),t>0&&` ${e(`common.offlinePending`,{count:t})}`]})}function Ul(){let{t:e}=R(),{refresh:t}=lo();return(0,U.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col items-center justify-center gap-4 bg-[var(--c-bg)] px-6 text-center`,children:[(0,U.jsx)(`img`,{src:`/logo.svg`,alt:``,className:`h-12 w-12`}),(0,U.jsx)(`h1`,{className:`text-xl font-semibold`,style:{fontFamily:`Manrope, sans-serif`},children:e(`common.offlineTitle`)}),(0,U.jsx)(`p`,{className:`max-w-sm text-sm text-[var(--c-text-muted)]`,children:e(`common.offlineText`)}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>void t(),className:`btn-primary`,children:e(`common.retry`)})]})}var Wl=[],Gl=1,Kl=new Set,ql=()=>Kl.forEach(e=>e());function Jl(e){return Kl.add(e),()=>Kl.delete(e)}function Yl(){return Wl}function Xl(e){Wl=Wl.filter(t=>t.id!==e),ql()}function Zl(e,t){let n=Gl++;Wl=[...Wl.slice(-2),{id:n,type:e,message:t}],ql(),window.setTimeout(()=>Xl(n),e===`error`?7e3:4e3)}var K={success:e=>Zl(`success`,e),error:e=>Zl(`error`,e),info:e=>Zl(`info`,e)};function Ql(){let{t:e}=R(),t=(0,_.useSyncExternalStore)(Jl,Yl);return(0,U.jsx)(`div`,{"aria-live":`polite`,className:`pointer-events-none fixed inset-x-0 bottom-[calc(6.5rem+env(safe-area-inset-bottom,0px))] z-[60] flex flex-col items-center gap-2 px-4 md:bottom-6`,children:t.map(t=>(0,U.jsxs)(`div`,{role:t.type===`error`?`alert`:`status`,className:`card animate-fade-in pointer-events-auto flex w-full max-w-md items-start gap-3 px-4 py-3 text-sm`,style:{boxShadow:`0 16px 40px -12px rgba(0, 0, 0, 0.35)`},children:[(0,U.jsx)(`span`,{className:`mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-white ${t.type===`error`?`bg-[var(--c-danger)]`:t.type===`info`?`bg-[var(--c-text-muted)]`:`bg-[var(--c-green3)]`}`,"aria-hidden":`true`,children:(0,U.jsx)(`svg`,{className:`h-3 w-3`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`,children:t.type===`error`?(0,U.jsx)(`path`,{d:`M12 7v6M12 17h.01`}):t.type===`info`?(0,U.jsx)(`path`,{d:`M12 7h.01M12 11v6`}):(0,U.jsx)(`path`,{d:`m5 12 5 5 9-10`})})}),(0,U.jsx)(`p`,{className:`min-w-0 flex-1 text-[var(--c-text)]`,children:t.message}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>Xl(t.id),"aria-label":e(`common.close`),className:`-mr-1 shrink-0 rounded p-0.5 text-[var(--c-text-muted)] hover:text-[var(--c-text)] cursor-pointer`,children:(0,U.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]},t.id))})}function $l(){let{t:e,i18n:t}=R(),n=ol(ll(),t.resolvedLanguage||`en`),r=dr();(0,_.useEffect)(()=>{let e=()=>void za(),t=()=>document.visibilityState===`visible`&&e();return e(),window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,t)}},[]),(0,_.useEffect)(()=>{let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>void eo(),800)},n=()=>document.visibilityState===`visible`&&t();t();let r=window.setInterval(t,12e4);window.addEventListener(`online`,t),document.addEventListener(`visibilitychange`,n);let i=ro(t);return()=>{window.clearTimeout(e),window.clearInterval(r),window.removeEventListener(`online`,t),document.removeEventListener(`visibilitychange`,n),i()}},[]),(0,_.useEffect)(()=>{r.pathname!==`/items`&&(window.scrollTo({top:0,left:0,behavior:`instant`}),requestAnimationFrame(()=>{window.scrollTo({top:0,left:0,behavior:`instant`})}))},[r.pathname]);let i=()=>{r.pathname===`/items`&&(Ka(),window.scrollTo({top:0,left:0,behavior:`smooth`}))},a=n.findIndex(({id:e})=>r.pathname===`/extensions/${e}`),o=a>=0?a:n.length+(r.pathname.startsWith(`/feeds`)?1:r.pathname.startsWith(`/settings`)?2:0);return(0,U.jsxs)(`div`,{className:`min-h-screen flex flex-col`,children:[(0,U.jsx)(`header`,{"data-app-header":!0,className:`sticky top-0 z-30 backdrop-blur-md border-b`,style:{borderColor:`var(--c-border)`,backgroundColor:`color-mix(in srgb, var(--c-surface) 85%, transparent)`,paddingTop:`env(safe-area-inset-top, 0px)`},children:(0,U.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-3 flex items-center justify-between gap-4`,children:[(0,U.jsx)(Mi,{to:`/items`,onClick:i,className:`flex items-center gap-2.5 shrink-0 hover:opacity-85 transition-opacity`,children:(0,U.jsx)(hl,{size:28})}),(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(_l,{onItemsClick:i,pages:n}),(0,U.jsx)(zl,{})]})]})}),(0,U.jsx)(Hl,{}),(0,U.jsx)(`main`,{className:`flex-1 max-w-5xl w-full mx-auto px-4 pt-4 pb-24 md:py-6`,children:(0,U.jsx)(`div`,{className:`animate-page-fade`,children:(0,U.jsx)(Vr,{})},r.pathname)}),(0,U.jsx)(Ql,{}),(0,U.jsx)(`nav`,{className:`mobile-bottom-nav md:hidden fixed left-3 right-3 max-w-sm mx-auto z-40 pointer-events-auto no-drag select-none`,"aria-label":e(`nav.menu`),children:(0,U.jsxs)(`div`,{className:`relative flex items-center justify-between p-1.5 rounded-full border backdrop-blur-2xl backdrop-saturate-180 transition-all duration-300 no-drag select-none`,style:{backgroundColor:`color-mix(in srgb, var(--c-surface) 80%, transparent)`,borderColor:`var(--c-border)`,borderWidth:`1px`,boxShadow:`0 2px 12px -4px rgba(0, 0, 0, 0.3)`},onContextMenu:e=>e.preventDefault(),children:[(0,U.jsx)(`div`,{"aria-hidden":`true`,className:`absolute top-1.5 bottom-1.5 left-1.5 rounded-full bg-[var(--c-mobile-nav-active)] border border-[var(--c-mobile-nav-active-border)] shadow-sm transition-transform duration-300 ease-[cubic-bezier(0.25,1,0.5,1)] pointer-events-none no-drag`,style:{width:`calc((100% - 0.75rem) / ${3+n.length})`,transform:`translateX(calc(${o} * 100%))`}}),n.map(({id:e,label:t,icon:n})=>(0,U.jsx)(Mi,{to:`/extensions/${e}`,draggable:!1,className:`relative z-10 flex-1 min-w-0 no-drag select-none`,children:({isActive:e})=>(0,U.jsxs)(`span`,{className:`h-[54px] w-full rounded-full flex flex-col items-center justify-center gap-0.5 ${e?`text-[var(--c-text)] font-semibold`:`text-[var(--c-text-muted)] font-medium`}`,children:[(0,U.jsx)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:n.map(e=>(0,U.jsx)(`path`,{d:e},e))}),(0,U.jsx)(`span`,{className:`text-[11px] leading-tight tracking-tight text-center`,children:t})]})},e)),(0,U.jsx)(Mi,{to:`/items`,onClick:i,draggable:!1,onDragStart:e=>e.preventDefault(),onContextMenu:e=>e.preventDefault(),className:`relative z-10 flex-1 min-w-0 no-drag select-none`,children:({isActive:t})=>(0,U.jsxs)(`div`,{className:`h-[54px] w-full rounded-full flex flex-col items-center justify-center gap-0.5 transition-colors duration-200 cursor-pointer no-drag select-none ${t?`text-[var(--c-text)] font-semibold`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)] font-medium`}`,children:[(0,U.jsx)(`svg`,{className:`w-5 h-5 transition-transform duration-200 pointer-events-none ${t?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h12`})}),(0,U.jsx)(`span`,{className:`text-[11px] leading-tight tracking-tight pointer-events-none select-none`,children:e(`nav.items`)})]})}),(0,U.jsx)(Mi,{to:`/feeds`,draggable:!1,onDragStart:e=>e.preventDefault(),onContextMenu:e=>e.preventDefault(),className:`relative z-10 flex-1 min-w-0 no-drag select-none`,children:({isActive:t})=>(0,U.jsxs)(`div`,{className:`h-[54px] w-full rounded-full flex flex-col items-center justify-center gap-0.5 transition-colors duration-200 cursor-pointer no-drag select-none ${t?`text-[var(--c-text)] font-semibold`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)] font-medium`}`,children:[(0,U.jsxs)(`svg`,{className:`w-5 h-5 transition-transform duration-200 pointer-events-none ${t?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`path`,{d:`M4 11a9 9 0 0 1 9 9`}),(0,U.jsx)(`path`,{d:`M4 4a16 16 0 0 1 16 16`}),(0,U.jsx)(`circle`,{cx:`5`,cy:`19`,r:`1`})]}),(0,U.jsx)(`span`,{className:`text-[11px] leading-tight tracking-tight pointer-events-none select-none`,children:e(`nav.feeds`)})]})}),(0,U.jsx)(Mi,{to:`/settings`,draggable:!1,onDragStart:e=>e.preventDefault(),onContextMenu:e=>e.preventDefault(),className:`relative z-10 flex-1 min-w-0 no-drag select-none`,children:({isActive:t})=>(0,U.jsxs)(`div`,{className:`h-[54px] w-full rounded-full flex flex-col items-center justify-center gap-0.5 transition-colors duration-200 cursor-pointer no-drag select-none ${t?`text-[var(--c-text)] font-semibold`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)] font-medium`}`,children:[(0,U.jsxs)(`svg`,{className:`w-5 h-5 transition-transform duration-200 pointer-events-none ${t?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,U.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z`})]}),(0,U.jsx)(`span`,{className:`text-[11px] leading-tight tracking-tight pointer-events-none select-none`,children:e(`nav.settings`)})]})})]})})]})}function eu(){let{t:e}=R(),{refresh:t}=lo(),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(!1);async function f(r){r.preventDefault(),d(!0),l(null);try{await H.onboard({email:n,password:o,displayName:i}),await t()}catch{l(e(`common.error`))}finally{d(!1)}}return(0,U.jsx)(`div`,{className:`min-h-screen flex items-center justify-center px-4`,children:(0,U.jsxs)(`div`,{className:`card p-8 w-full max-w-md`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col items-center mb-6 text-center`,children:[(0,U.jsx)(`h1`,{className:`mb-3`,children:(0,U.jsx)(hl,{size:44})}),(0,U.jsx)(`p`,{className:`text-sm mt-1`,style:{color:`var(--c-text-muted)`},children:e(`onboarding.subtitle`)})]}),(0,U.jsxs)(`form`,{onSubmit:f,className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{className:`text-sm font-medium block mb-1`,children:e(`onboarding.emailLabel`)}),(0,U.jsx)(`input`,{type:`email`,required:!0,className:`input`,value:n,onChange:e=>r(e.target.value)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{className:`text-sm font-medium block mb-1`,children:e(`onboarding.displayNameLabel`)}),(0,U.jsx)(`input`,{type:`text`,required:!0,className:`input`,value:i,onChange:e=>a(e.target.value)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{className:`text-sm font-medium block mb-1`,children:e(`onboarding.passwordLabel`)}),(0,U.jsx)(`input`,{type:`password`,required:!0,minLength:10,className:`input`,value:o,onChange:e=>s(e.target.value)}),(0,U.jsx)(`p`,{className:`text-xs mt-1`,style:{color:`var(--c-text-muted)`},children:e(`onboarding.passwordHint`)})]}),c&&(0,U.jsx)(`p`,{className:`text-sm text-danger`,children:c}),(0,U.jsx)(`button`,{type:`submit`,disabled:u,className:`btn-primary`,children:e(`onboarding.submit`)})]}),(0,U.jsxs)(`div`,{className:`mt-6 pt-4 border-t text-sm`,style:{borderColor:`var(--c-border)`},children:[(0,U.jsx)(`p`,{className:`font-medium`,children:e(`onboarding.orUseCli`)}),(0,U.jsx)(`p`,{style:{color:`var(--c-text-muted)`},children:e(`onboarding.cliHint`)})]})]})})}function tu(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function nu(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function q(){return ru.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var ru={stubThis:e=>e};function iu(e){let{id:t}=e;return{...e,id:nu(t),transports:e.transports,type:e.type}}function au(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var J=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function ou({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new J({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new J({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new J({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new J({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new J({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new J({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new J({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new J({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!au(t))return new J({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new J({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new J({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new J({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var su=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},cu=[`cross-platform`,`platform`];function lu(e){if(e&&!(cu.indexOf(e)<0))return e}async function uu(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!q())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:nu(t.challenge),user:{...t.user,id:nu(t.user.id)},excludeCredentials:t.excludeCredentials?.map(iu)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=su.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw ou({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){du(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=tu(e))}catch(e){du(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=tu(c.getAuthenticatorData())}catch(e){du(`getAuthenticatorData()`,e)}return{id:o,rawId:tu(s),response:{attestationObject:tu(c.attestationObject),clientDataJSON:tu(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:lu(a.authenticatorAttachment)}}function du(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function fu(){if(!q())return pu.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?pu.stubThis(new Promise(e=>e(!1))):pu.stubThis(e.isConditionalMediationAvailable())}var pu={stubThis:e=>e};function mu({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new J({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new J({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!au(t))return new J({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new J({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new J({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function hu(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!q())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(iu));let a={...t,challenge:nu(t.challenge),allowCredentials:i},o={};if(n){if(!await fu())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=su.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw mu({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=tu(u.userHandle)),{id:c,rawId:tu(l),response:{authenticatorData:tu(u.authenticatorData),clientDataJSON:tu(u.clientDataJSON),signature:tu(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:lu(s.authenticatorAttachment)}}async function gu(e,t,n=`POST`,r){let i=await fetch(`/api/auth/security${e}`,{method:n,signal:r,credentials:`same-origin`,headers:{"Content-Type":`application/json`},...t===void 0?{}:{body:JSON.stringify(t)}}),a=i.status===204?void 0:await i.json();if(!i.ok)throw new va(i.status,a.error,a);return a}async function _u(){let e=await gu(`/reauth/passkey/options`,{}),t=await hu({optionsJSON:e.publicKey});return(await gu(`/reauth/passkey/verify`,{challengeId:e.challengeId,credential:t})).reauthToken}async function vu(e,t){let n=await gu(`/passkeys/register/options`,{reauthToken:e}),r=await uu({optionsJSON:n.publicKey});await gu(`/passkeys/register/verify`,{challengeId:n.challengeId,credential:r,name:t})}function yu(e){let t,n;function r(){t?.abort(),t=void 0,clearTimeout(n)}async function i(a=!0){if(t&&a)return;r();let o=new AbortController,{signal:s}=o;t=o;let c=!1;try{if(a){let t=await window.PublicKeyCredential?.isConditionalMediationAvailable?.().catch(()=>!1)??!1;if(s.aborted||(e.onAutofill(t),!t))return}let t=await gu(`/passkeys/options`,{},`POST`,s);if(s.aborted)return;a&&(n=setTimeout(()=>{r(),i()},24e4));let o=await navigator.credentials.get({signal:s,...a?{mediation:`conditional`}:{},publicKey:{...t.publicKey,extensions:t.publicKey.extensions,challenge:nu(t.publicKey.challenge),allowCredentials:a?[]:t.publicKey.allowCredentials?.map(e=>({type:`public-key`,id:nu(e.id),transports:e.transports}))}});if(s.aborted||!o)return;clearTimeout(n),c=!0,e.onSelect();let l=o.response,u={id:o.id,rawId:tu(o.rawId),type:o.type,clientExtensionResults:o.getClientExtensionResults(),response:{clientDataJSON:tu(l.clientDataJSON),authenticatorData:tu(l.authenticatorData),signature:tu(l.signature),userHandle:l.userHandle?tu(l.userHandle):null}};await gu(`/passkeys/verify`,{challengeId:t.challengeId,credential:u},`POST`,s),s.aborted||await e.onSuccess()}catch(t){s.aborted||(c||!a?e.onError(t):t instanceof Error&&t.name===`NotAllowedError`||e.onAutofill(!1))}finally{t===o&&(clearTimeout(n),t=void 0)}}return{start:i,stop:r}}function bu({name:e,mount:t}){let n=(0,_.useRef)(null),r=R().i18n.resolvedLanguage;return(0,_.useEffect)(()=>{let r=n.current;if(!r)return;let i;try{i=t(r)}catch(t){console.error(`[extensions] "${e}" failed to open`,t)}return()=>{try{typeof i==`function`&&i()}catch(t){console.error(`[extensions] "${e}" failed to close`,t)}r.replaceChildren()}},[e,r]),(0,U.jsx)(`div`,{ref:n,className:`min-w-0`})}function xu(){let{t:e}=R(),{refresh:t}=lo(),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(),f=(0,_.useRef)(void 0),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!0),[S,C]=(0,_.useState)(`https://github.com/visualfusion/feedkeeper`),[w,T]=(0,_.useState)(null),E=$c(ll()),D=E?.mount,O=(0,_.useEffectEvent)(async()=>{await j(),y(!1)}),k=(0,_.useEffectEvent)(()=>{g(e(`login.error`)),y(!1)});(0,_.useEffect)(()=>{if(!c||i||D)return;let e=yu({onAutofill:d,onSelect:()=>{y(!0),g(null)},onSuccess:O,onError:k});f.current=e,e.start();let t=()=>{e.start()},n=()=>{e.stop(),y(!1)};return window.addEventListener(`pagehide`,n),window.addEventListener(`pageshow`,t),()=>{e.stop(),f.current=void 0,window.removeEventListener(`pagehide`,n),window.removeEventListener(`pageshow`,t)}},[c,i,D]),(0,_.useEffect)(()=>{gu(`/config`,void 0,`GET`).then(e=>l(e.passkeys)).catch(()=>{}),H.getConfig().then(e=>{e&&(x(e.showGithubLink),e.githubUrl&&C(e.githubUrl),e.loginSubtitle&&T(e.loginSubtitle))}).catch(()=>{})},[]);async function A(t){if(t.preventDefault(),!v){f.current?.stop(),y(!0),g(null);try{i?await gu(`/mfa`,{challengeId:i,code:o}):await H.login(n,p),await j()}catch(t){t instanceof va&&t.code===`mfa_required`?(a(t.data.challengeId),m(``)):(g(e(`login.error`)),f.current?.start())}finally{y(!1)}}}async function j(){let e=new URLSearchParams(window.location.search).get(`next`);e?.startsWith(`/oauth/authorize?`)?window.location.assign(e):await t()}return(0,U.jsxs)(`div`,{className:`min-h-screen flex flex-col items-center justify-center px-4`,children:[(0,U.jsxs)(`div`,{className:`card p-8 w-full max-w-sm`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col items-center mb-6 text-center`,children:[(0,U.jsx)(`h1`,{className:`mb-3`,children:(0,U.jsx)(hl,{size:44})}),(0,U.jsx)(`p`,{className:`text-xs mt-1`,style:{color:`var(--c-text-muted)`},children:w??e(`login.subtitle`)})]}),E?(0,U.jsx)(bu,{name:`login-form`,mount:E.mount}):(0,U.jsxs)(`form`,{onSubmit:A,className:`flex flex-col gap-4`,children:[!i&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{htmlFor:`login-email`,className:`text-sm font-medium block mb-1`,children:e(`login.emailLabel`)}),(0,U.jsx)(`input`,{id:`login-email`,name:`username`,type:`email`,autoComplete:`username webauthn`,required:!0,autoFocus:!0,className:`input`,value:n,onChange:e=>r(e.target.value),onFocus:()=>{v||f.current?.start()}})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{htmlFor:`login-password`,className:`text-sm font-medium block mb-1`,children:e(`login.passwordLabel`)}),(0,U.jsx)(`input`,{type:`password`,id:`login-password`,name:`password`,autoComplete:`current-password`,required:!0,className:`input`,value:p,onChange:e=>m(e.target.value)})]})]}),i&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`label`,{htmlFor:`mfa-code`,children:e(`security.code`)}),(0,U.jsx)(`input`,{id:`mfa-code`,className:`input`,autoFocus:!0,autoComplete:`one-time-code`,value:o,onChange:e=>s(e.target.value),required:!0}),(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{a(void 0),s(``)},children:e(`security.cancel`)})]}),c&&!i&&u===!1&&(0,U.jsx)(`button`,{type:`button`,className:`text-sm underline`,disabled:v,onClick:()=>void f.current?.start(!1),children:e(`security.signInPasskey`)}),h&&(0,U.jsx)(`p`,{className:`text-sm text-danger`,children:h}),(0,U.jsx)(`button`,{type:`submit`,disabled:v,className:`btn-primary`,children:e(`login.submit`)})]})]}),(0,U.jsx)(Il,{placement:`login`}),b&&(0,U.jsx)(`div`,{className:`mt-4 text-center`,children:(0,U.jsxs)(`a`,{href:S,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 text-xs text-[var(--c-text-muted)] hover:text-[var(--c-text)] transition-colors opacity-80 hover:opacity-100`,children:[(0,U.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,U.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.53 1.032 1.53 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z`})}),(0,U.jsx)(`span`,{children:e(`login.viewOnGithub`)})]})})]})}function Su({className:e=``,size:t=`md`,center:n=!0}){let{t:r}=R(),i=(0,U.jsx)(`div`,{className:`rounded-full animate-spin border-[var(--c-border)] border-t-[var(--c-blue1)] dark:border-t-white/80 ${{sm:`w-5 h-5 border-2`,md:`w-8 h-8 border-[2.5px]`,lg:`w-10 h-10 border-3`}[t]} ${e}`,role:`status`,"aria-label":r(`common.loading`)});return n?(0,U.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center min-h-[45vh] w-full py-12 animate-fade-in`,children:i}):i}function Cu({label:e,items:t,className:n=``}){let[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(!1),s=(0,_.useRef)(null),c=(0,_.useRef)(null),l=(0,_.useId)();return(0,_.useLayoutEffect)(()=>{if(!r||!c.current)return;let e=c.current.getBoundingClientRect();o(window.innerHeight-e.bottom<48*t.length+24)},[r,t.length]),(0,_.useEffect)(()=>{if(!r)return;let e=e=>{s.current?.contains(e.target)||i(!1)},t=e=>{e.key===`Escape`&&(i(!1),c.current?.focus())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[r]),(0,U.jsxs)(`div`,{ref:s,className:`relative ${n}`,children:[(0,U.jsx)(`button`,{ref:c,type:`button`,onClick:e=>{e.stopPropagation(),i(e=>!e)},"aria-label":e,title:e,"aria-expanded":r,"aria-controls":l,className:`flex h-9 w-9 items-center justify-center rounded-lg text-[var(--c-text-muted)] transition-colors hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] cursor-pointer ${r?`bg-[var(--c-surface-hover)] text-[var(--c-text)]`:``}`,children:(0,U.jsxs)(`svg`,{className:`h-5 w-5`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:[(0,U.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.8`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.8`}),(0,U.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.8`})]})}),r&&(0,U.jsx)(`div`,{id:l,className:`card animate-fade-in absolute right-0 z-40 w-64 p-1.5 ${a?`bottom-full mb-2`:`top-full mt-2`}`,style:{boxShadow:`0 16px 40px -12px rgba(0, 0, 0, 0.35)`},children:t.map(e=>(0,U.jsxs)(`button`,{type:`button`,disabled:e.disabled,onClick:t=>{t.stopPropagation(),i(!1),e.onSelect()},className:`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors disabled:opacity-50 cursor-pointer disabled:cursor-default ${e.danger?`text-[var(--c-danger)] hover:bg-[var(--c-danger-bg)]`:`text-[var(--c-text)] hover:bg-[var(--c-surface-hover)]`}`,children:[e.icon&&(0,U.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center ${e.danger?``:`text-[var(--c-text-muted)]`}`,children:e.icon}),e.label]},e.label))})]})}function wu(){let{user:e}=lo(),t=e?.capabilities;return{syncAllowed:!t||t.features.sync===!0,manageUrl:t?.manageUrl??null}}function Tu({value:e,onChange:t,options:n,placeholder:r,className:i=``,size:a=`md`,disabled:o=!1,ariaLabel:s}){let{t:c}=R(),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(-1),p=(0,_.useRef)(null),m=(0,_.useRef)(null),h=(0,_.useId)(),g=n.find(t=>t.value===e);(0,_.useEffect)(()=>{function e(e){p.current&&!p.current.contains(e.target)&&u(!1)}if(l)return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[l]),(0,_.useEffect)(()=>{if(l){let t=n.findIndex(t=>t.value===e);f(t>=0?t:0)}},[l,e,n]),(0,_.useEffect)(()=>{if(l&&d>=0&&m.current){let e=m.current.querySelector(`[data-index="${d}"]`);e&&e.scrollIntoView({block:`nearest`})}},[d,l]);function v(e){o||(l?e.key===`Escape`?(e.preventDefault(),u(!1)):e.key===`ArrowDown`?(e.preventDefault(),f(e=>e<n.length-1?e+1:0)):e.key===`ArrowUp`?(e.preventDefault(),f(e=>e>0?e-1:n.length-1)):e.key===`Home`?(e.preventDefault(),f(0)):e.key===`End`?(e.preventDefault(),f(n.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d>=0&&d<n.length&&(t(n[d].value),u(!1))):(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(!0)))}let y=[];n.forEach((e,t)=>{let n=e.group??null,r=y.find(e=>e.groupName===n);r||(r={groupName:n,items:[]},y.push(r)),r.items.push({opt:e,index:t})});let b=a===`sm`;return(0,U.jsxs)(`div`,{ref:p,className:`relative inline-block ${i}`,onKeyDown:v,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||u(!1)},children:[(0,U.jsxs)(`button`,{type:`button`,id:h,role:`combobox`,"aria-label":s,"aria-haspopup":`listbox`,"aria-expanded":l,"aria-controls":l?`${h}-listbox`:void 0,"aria-activedescendant":l&&d>=0?`${h}-option-${d}`:void 0,disabled:o,onClick:()=>!o&&u(e=>!e),className:`w-full flex items-center justify-between gap-2 text-left font-normal transition-colors cursor-pointer select-none rounded-lg border bg-[var(--c-surface)] text-[var(--c-text)] shadow-xs hover:border-[var(--c-blue3)] focus:outline-none focus:border-[var(--c-blue3)] ${l?`border-[var(--c-blue3)]`:`border-[var(--c-border)]`} ${b?`px-2.5 py-1 text-xs min-h-[30px]`:`px-3 py-1.5 text-sm min-h-[38px]`} ${o?`opacity-50 cursor-not-allowed`:``}`,children:[(0,U.jsx)(`span`,{className:`truncate flex items-center gap-1.5`,children:g?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`truncate`,children:g.label}),g.badge!==void 0&&(0,U.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.2 rounded-full font-medium shrink-0`,style:{backgroundColor:`var(--c-border)`,color:`var(--c-text-muted)`},children:g.badge})]}):(0,U.jsx)(`span`,{style:{color:`var(--c-text-muted)`},children:r??`—`})}),(0,U.jsx)(`svg`,{className:`shrink-0 transition-transform duration-200 opacity-60 ${l?`rotate-180`:``} ${b?`w-3 h-3`:`w-3.5 h-3.5`}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,U.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})]}),l&&(0,U.jsx)(`div`,{className:`absolute left-0 mt-1 w-full min-w-[180px] max-w-xs sm:max-w-none rounded-lg border border-[var(--c-border)] bg-[var(--c-surface)] shadow-lg z-50 overflow-hidden`,style:{backdropFilter:`blur(8px)`},children:(0,U.jsx)(`ul`,{ref:m,id:`${h}-listbox`,role:`listbox`,"aria-labelledby":h,className:`max-h-60 overflow-y-auto py-1 text-[var(--c-text)] focus:outline-none`,children:n.length===0?(0,U.jsx)(`li`,{className:`px-3 py-2 text-xs italic`,style:{color:`var(--c-text-muted)`},children:r??c(`common.noOptions`)}):y.map((n,r)=>(0,U.jsxs)(`li`,{role:`group`,"aria-label":n.groupName??void 0,children:[n.groupName&&(0,U.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-wider select-none border-t first:border-t-0`,style:{borderColor:`var(--c-border)`,color:`var(--c-text-muted)`},children:n.groupName}),(0,U.jsx)(`ul`,{role:`presentation`,children:n.items.map(({opt:n,index:r})=>{let i=n.value===e,a=r===d;return(0,U.jsxs)(`li`,{id:`${h}-option-${r}`,"data-index":r,role:`option`,"aria-selected":i,onClick:()=>{t(n.value),u(!1)},onMouseEnter:()=>f(r),className:`flex items-center justify-between gap-2 cursor-pointer select-none transition-colors ${b?`px-2.5 py-1.5 text-xs`:`px-3 py-2 text-sm`} ${a?`bg-[var(--c-border)]/40 text-[var(--c-text)]`:`text-[var(--c-text)]`} ${i?`font-medium bg-[var(--c-blue1)]/10`:``}`,children:[(0,U.jsxs)(`span`,{className:`truncate flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`truncate`,children:n.label}),n.badge!==void 0&&(0,U.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.2 rounded-full font-medium shrink-0`,style:{backgroundColor:`var(--c-border)`,color:`var(--c-text-muted)`},children:n.badge})]}),i&&(0,U.jsx)(`svg`,{className:`w-3.5 h-3.5 shrink-0`,style:{color:`var(--c-blue3)`},viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`polyline`,{points:`20 6 9 17 4 12`})})]},n.value)})})]},n.groupName??`ungrouped-${r}`))})})]})}function Eu(e,t){let n=/^feed_http_(\d{3})$/.exec(t);if(n){let t=Number(n[1]);return t===404||t===410?e(`feeds.errors.notFound`,{status:t}):t===401||t===403?e(`feeds.errors.refused`,{status:t}):t===429?e(`feeds.errors.limited`):e(t>=400&&t<500&&t!==408&&t!==425?`feeds.errors.rejected`:`feeds.errors.unavailable`,{status:t})}return t===`feed_timeout`?e(`feeds.errors.timeout`):t===`feed_network_error`?e(`feeds.errors.network`):t===`feed_invalid_or_unavailable`?e(`feeds.errors.invalidFeed`):t}var Du=[[`day`,864e5],[`hour`,36e5],[`minute`,6e4]];function Ou(e,t,n=Date.now()){let r=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),i=e.getTime()-n;for(let[e,t]of Du)if(Math.abs(i)>=t)return r.format(Math.round(i/t),e);return r.format(0,`minute`)}function ku({children:e,className:t=`h-4 w-4`}){return(0,U.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:e})}var Au=({className:e})=>(0,U.jsxs)(ku,{className:e,children:[(0,U.jsx)(`path`,{d:`M21 12a9 9 0 1 1-2.64-6.36`}),(0,U.jsx)(`path`,{d:`M21 3v6h-6`})]}),ju=()=>(0,U.jsx)(ku,{children:(0,U.jsx)(`path`,{d:`M2 12l4 4 6-7M10 16l2 0 8-9`})}),Mu=()=>(0,U.jsxs)(ku,{children:[(0,U.jsx)(`path`,{d:`M12 20h9`}),(0,U.jsx)(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),Nu=()=>(0,U.jsx)(ku,{children:(0,U.jsx)(`path`,{d:`M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6`})}),Pu=({className:e})=>(0,U.jsx)(ku,{className:e,children:(0,U.jsx)(`path`,{d:`M12 5v14M5 12h14`})}),Fu=()=>(0,U.jsxs)(ku,{children:[(0,U.jsx)(`path`,{d:`M12 15V3M7 8l5-5 5 5`}),(0,U.jsx)(`path`,{d:`M5 21h14`})]}),Iu=()=>(0,U.jsxs)(ku,{children:[(0,U.jsx)(`path`,{d:`M12 3v12M7 10l5 5 5-5`}),(0,U.jsx)(`path`,{d:`M5 21h14`})]}),Lu=()=>(0,U.jsx)(ku,{children:(0,U.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z`})}),Ru=()=>(0,U.jsxs)(ku,{className:`h-4 w-4`,children:[(0,U.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,U.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),zu=()=>(0,U.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:[6,12,18].flatMap(e=>[9,15].map(t=>(0,U.jsx)(`circle`,{cx:t,cy:e,r:`1.5`},`${t}-${e}`)))}),Bu=()=>(0,U.jsx)(ku,{className:`h-5 w-5`,children:(0,U.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})}),Vu=()=>(0,U.jsxs)(ku,{className:`h-3.5 w-3.5 shrink-0`,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,U.jsx)(`path`,{d:`M12 8v4M12 16h.01`})]}),Hu=({className:e=`h-3.5 w-3.5`})=>(0,U.jsxs)(ku,{className:e,children:[(0,U.jsx)(`path`,{d:`M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9`}),(0,U.jsx)(`path`,{d:`M13.73 21a2 2 0 0 1-3.46 0`})]});function Uu(e,t){return t<60?e(`feeds.minutesShort`,{count:t}):e(`feeds.hoursShort`,{count:Math.round(t/60)})}function Wu(e){try{return e?new URL(e).hostname.replace(/^www\./,``):null}catch{return null}}function Gu({feed:e,folderOptions:t,intervalOptions:n,onClose:r,onSaved:i}){let{t:a}=R(),[o,s]=(0,_.useState)(e.label?.trim()||e.title?.trim()||e.url),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(e.folder_id??null),[f,p]=(0,_.useState)(e.poll_interval_minutes),[m,h]=(0,_.useState)(e.full_text_mode!==`never`),[g,v]=(0,_.useState)(),[y,b]=(0,_.useState)(),[x,S]=(0,_.useState)(!1);async function C(){S(!0);try{await H.updateFeed(e.id,{...c?{label:o.trim()||null}:{},folderId:u,pollIntervalMinutes:f,fullTextMode:m?`auto`:`never`,...g===void 0?{}:{notify:g},...y===void 0?{}:{badge:y}}),no(),K.success(a(`feeds.changesSaved`)),r(),await i()}catch{K.error(a(`common.error`))}finally{S(!1)}}return(0,U.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-[var(--c-border)] bg-[var(--c-bg)]/60 px-4 py-4 sm:px-5`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-[var(--c-text-muted)]`,children:[a(`feeds.labelPlaceholder`),(0,U.jsx)(`input`,{type:`text`,className:`input text-sm`,placeholder:e.title??e.url,value:o,onChange:e=>{s(e.target.value),l(!0)}})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-xs font-medium text-[var(--c-text-muted)]`,children:[a(`feeds.folder`),(0,U.jsx)(Tu,{value:u?String(u):``,onChange:e=>d(e?Number(e):null),options:t,className:`w-full`,placeholder:a(`feeds.noFolder`)})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-xs font-medium text-[var(--c-text-muted)]`,children:[a(`feeds.interval`),(0,U.jsx)(Tu,{value:String(f),onChange:e=>p(Number(e)),options:n,className:`w-full`})]})]}),(0,U.jsxs)(`label`,{className:`flex cursor-pointer select-none items-start gap-2.5 text-sm`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 rounded`,checked:m,onChange:e=>h(e.target.checked)}),(0,U.jsxs)(`span`,{children:[a(`feeds.fullText`),(0,U.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--c-text-muted)]`,children:e.full_text_blocked_at?a(`feeds.fullTextBlocked`):a(`feeds.fullTextHint`)})]})]}),(0,U.jsxs)(`label`,{className:`flex cursor-pointer select-none items-start gap-2.5 text-sm`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 rounded`,checked:g??e.notify!==0,onChange:e=>v(e.target.checked)}),(0,U.jsxs)(`span`,{children:[a(`feeds.notify`),(0,U.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--c-text-muted)]`,children:a(`feeds.notifyHint`)})]})]}),(0,U.jsxs)(`label`,{className:`flex cursor-pointer select-none items-start gap-2.5 text-sm`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 rounded`,checked:y??e.badge!==0,onChange:e=>b(e.target.checked)}),(0,U.jsxs)(`span`,{children:[a(`feeds.badge`),(0,U.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--c-text-muted)]`,children:a(`feeds.badgeHint`)})]})]}),(0,U.jsx)(`p`,{className:`truncate font-mono text-xs text-[var(--c-text-muted)]`,title:e.url,children:e.url}),(0,U.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:r,className:`btn-secondary px-3 py-1.5 text-sm`,children:a(`common.cancel`)}),(0,U.jsx)(`button`,{type:`button`,onClick:C,disabled:x,className:`btn-primary px-4 py-1.5 text-sm`,children:a(`common.save`)})]})]})}function Ku({feed:e,editing:t,refreshing:n,highlighted:r=!1,folderOptions:i,intervalOptions:a,onEdit:o,onRefresh:s,onMarkRead:c,onUnsubscribe:l,onSaved:u,drag:d}){let{t:f,i18n:p}=R(),{syncAllowed:m}=wu(),h=e.label??e.title??e.url,g=Wu(e.site_url)??Wu(e.url),_=!!e.last_error,v=!e.last_polled_at,y=[{label:f(n?`feeds.refreshing`:`feeds.refreshFeed`),icon:(0,U.jsx)(Au,{className:`h-4 w-4 ${n?`animate-spin`:``}`}),onSelect:s,disabled:n||!m},...e.unread_count>0?[{label:f(`feeds.markAllRead`),icon:(0,U.jsx)(ju,{}),onSelect:c}]:[],{label:f(`feeds.edit`),icon:(0,U.jsx)(Mu,{}),onSelect:()=>o(!t)},{label:f(`feeds.unsubscribe`),icon:(0,U.jsx)(Nu,{}),onSelect:l,danger:!0}];return(0,U.jsxs)(`li`,{id:`feed-${e.id}`,draggable:!!d&&!t,onDragStart:d?.onDragStart,onDragOver:d?.onDragOver,onDragEnd:d?.onDragEnd,onDrop:d?.onDrop,className:`group/feed relative scroll-mt-28 first:rounded-t-xl last:rounded-b-xl transition-[opacity,background-color] duration-700 ${r?`bg-[var(--c-mobile-nav-active)]`:``} ${d?.isDragging?`opacity-40`:``} ${d?.isDragOver?`shadow-[inset_0_2px_0_var(--c-blue3)]`:``}`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3.5 sm:px-5`,children:[d&&(0,U.jsx)(`span`,{className:`-mr-1 flex shrink-0 cursor-grab touch-none text-[var(--c-text-muted)] opacity-50 transition-opacity hover:opacity-100 group-hover/feed:opacity-80 active:cursor-grabbing`,title:f(`feeds.dragHandle`),"aria-hidden":`true`,children:(0,U.jsx)(zu,{})}),(0,U.jsx)(zc,{feedId:e.id,iconUrl:e.icon_url,siteUrl:e.site_url,feedUrl:e.url,fallbackName:h,className:`h-5 w-5 shrink-0 rounded object-contain text-xs leading-none`}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(_||v)&&(0,U.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${_?`bg-[var(--c-danger)]`:`bg-[var(--c-text-muted)]`}`,title:_?f(`feeds.statusFailing`,{count:e.consecutive_errors||1}):f(`feeds.statusPending`)}),(0,U.jsx)(ji,{to:`/items?feed=${e.id}`,draggable:!1,className:`truncate font-semibold text-[var(--c-text)] hover:underline`,children:h}),e.notify!==0&&(0,U.jsx)(`span`,{className:`inline-flex shrink-0 items-center text-[var(--c-text-muted)]`,title:f(`feeds.notifyActive`),"aria-label":f(`feeds.notifyActive`),children:(0,U.jsx)(Hu,{className:`h-3.5 w-3.5`})})]}),(0,U.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-[var(--c-text-muted)]`,children:[g,f(`feeds.everyInterval`,{interval:Uu(f,e.poll_interval_minutes)}),e.last_polled_at?f(`feeds.checkedAgo`,{time:Ou(new Date(e.last_polled_at),p.resolvedLanguage)}):f(`feeds.statusPending`)].filter(Boolean).join(` · `)}),_&&(0,U.jsxs)(`p`,{className:`mt-1.5 flex items-start gap-1.5 text-xs text-[var(--c-danger)]`,title:e.last_error??void 0,children:[(0,U.jsx)(Vu,{}),(0,U.jsx)(`span`,{className:`line-clamp-2`,children:Eu(f,e.last_error??``)})]})]}),e.unread_count>0&&(0,U.jsx)(ji,{to:`/items?feed=${e.id}`,draggable:!1,className:`shrink-0 rounded-full bg-[var(--c-mobile-nav-active)] px-2.5 py-0.5 text-xs font-semibold tabular-nums text-[var(--c-text)] hover:bg-[var(--c-border)]`,title:f(`feeds.unread`,{count:e.unread_count}),children:e.unread_count}),(0,U.jsx)(Cu,{label:f(`feeds.moreActions`),items:y,className:`-mr-2 shrink-0`})]}),t&&(0,U.jsx)(Gu,{feed:e,folderOptions:i,intervalOptions:a,onClose:()=>o(!1),onSaved:u})]})}function qu(e,t){let n=t.toLowerCase().split(`-`)[0],r=e.feeds.filter(e=>e.lang===n||e.lang===``),i=n===`en`||n===`ja`&&r.length>0?[]:e.feeds.filter(e=>e.lang===`en`);return[...r,...i]}function Ju(e,t){let n=t.toLowerCase().split(`-`)[0],r=e=>e.lang===n||e.lang===``?0:e.lang===`en`?1:2;return[...e.feeds].sort((e,t)=>r(e)-r(t))}function Yu({folderOptions:e,defaultFolderId:t,initialUrl:n=``,subscribedUrls:r=[],compact:i=!1,onClose:a,onAdded:o}){let{t:s}=R(),[c,l]=(0,_.useState)(n),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(t),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)([]),y=new Set(r.map(Xu));async function b(e,t){h(!0),v([]);try{let n=await H.subscribeFeed(e,t,f);l(``),d(``),await o(n)}catch(e){e instanceof va&&e.code===`multiple_feeds_found`&&e.data&&typeof e.data==`object`&&`feeds`in e.data?v(e.data.feeds):e instanceof va&&e.code===`already_subscribed`?K.error(s(`feeds.alreadySubscribed`)):e instanceof va&&(e.code===`no_feeds_found`||e.code===`invalid_feed`)?K.error(s(`feeds.noFeedsFoundOnPage`)):K.error(s(`feeds.subscribeFailed`))}finally{h(!1)}}function x(e){e.preventDefault();let t=c.trim();t&&!/^https?:\/\//i.test(t)&&(t=t.startsWith(`//`)?`https:${t}`:`https://${t}`),b(t,u.trim()||null)}return(0,U.jsxs)(`section`,{className:i?`flex flex-col gap-4`:`card animate-fade-in flex flex-col gap-4 p-4 sm:p-5`,children:[!i&&(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`h2`,{className:`text-base font-semibold`,children:s(`feeds.addFeed`)}),(0,U.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-1 text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,"aria-label":s(`common.close`),children:(0,U.jsx)(Bu,{})})]}),(0,U.jsxs)(`form`,{onSubmit:x,className:`flex flex-col gap-3 ${i?`sm:flex-row sm:items-start`:``}`,children:[(0,U.jsx)(`input`,{type:`text`,required:!0,autoFocus:!i,placeholder:s(`feeds.urlPlaceholder`),className:i?`input sm:flex-1`:`input`,value:c,onChange:e=>{l(e.target.value),g.length&&v([])}}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row`,children:[!i&&(0,U.jsx)(`input`,{type:`text`,placeholder:s(`feeds.labelPlaceholder`),className:`input sm:flex-1`,value:u,onChange:e=>d(e.target.value)}),!i&&(0,U.jsx)(Tu,{value:f?String(f):``,onChange:e=>p(e?Number(e):null),options:e,className:`w-full sm:w-52`,placeholder:s(`feeds.noFolder`)}),(0,U.jsx)(`button`,{type:`submit`,disabled:m,className:`btn-primary whitespace-nowrap`,children:s(m?`feeds.subscribing`:`feeds.subscribe`)})]})]}),g.length>0&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:s(`feeds.multipleFeedsFound`)}),(0,U.jsx)(`ul`,{className:`divide-y divide-[var(--c-border)] rounded-xl border border-[var(--c-border)]`,children:g.map(e=>{let t=y.has(Xu(e.url));return(0,U.jsxs)(`li`,{className:`flex flex-col gap-2.5 px-3 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-3 ${t?`opacity-70`:``}`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`break-words text-sm font-medium`,children:e.title??e.url}),(0,U.jsx)(`p`,{className:`truncate text-xs text-[var(--c-text-muted)]`,children:e.url})]}),(0,U.jsx)(`button`,{type:`button`,disabled:m||t,onClick:()=>b(e.url,e.title||u.trim()||null),className:`btn-primary w-full shrink-0 whitespace-nowrap px-3 py-1.5 text-xs sm:w-auto`,children:s(t?`feeds.subscribed`:`feeds.subscribe`)})]},e.url)})})]})]})}function Xu(e){return e.trim().replace(/\/+$/,``).toLowerCase()}function Y(){let{t:e}=R(),{manageUrl:t}=wu();return(0,U.jsxs)(`section`,{role:`status`,className:`card flex flex-col gap-2 p-4 sm:p-5`,"aria-labelledby":`plan-notice-title`,children:[(0,U.jsx)(`h2`,{id:`plan-notice-title`,className:`text-base font-semibold`,children:e(`plan.limitedTitle`)}),(0,U.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:e(`plan.limitedText`)}),t&&(0,U.jsx)(`a`,{href:t,className:`btn-primary self-start`,style:{textDecoration:`none`},children:e(`plan.view`)})]})}var Zu={news:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2`}),(0,U.jsx)(`path`,{d:`M18 14h-8`}),(0,U.jsx)(`path`,{d:`M15 18h-5`}),(0,U.jsx)(`path`,{d:`M10 6h8v4h-8V6Z`})]}),technology:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`}),(0,U.jsx)(`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`}),(0,U.jsx)(`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`})]}),development:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`m18 16 4-4-4-4`}),(0,U.jsx)(`path`,{d:`m6 8-4 4 4 4`}),(0,U.jsx)(`path`,{d:`m14.5 4-5 16`})]}),science:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2`}),(0,U.jsx)(`path`,{d:`M8.5 2h7`}),(0,U.jsx)(`path`,{d:`M7 16h10`})]}),design:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`}),(0,U.jsx)(`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.563-2.512 5.563-5.563C22 6.5 17.5 2 12 2Z`})]}),gaming:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`line`,{x1:`6`,x2:`10`,y1:`11`,y2:`11`}),(0,U.jsx)(`line`,{x1:`8`,x2:`8`,y1:`9`,y2:`13`}),(0,U.jsx)(`line`,{x1:`15`,x2:`15.01`,y1:`12`,y2:`12`}),(0,U.jsx)(`line`,{x1:`18`,x2:`18.01`,y1:`10`,y2:`10`}),(0,U.jsx)(`path`,{d:`M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z`})]}),business:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`polyline`,{points:`22 7 13.5 15.5 8.5 10.5 2 17`}),(0,U.jsx)(`polyline`,{points:`16 7 22 7 22 13`})]}),sport:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M6 9H4.5a2.5 2.5 0 0 1 0-5H6`}),(0,U.jsx)(`path`,{d:`M18 9h1.5a2.5 2.5 0 0 0 0-5H18`}),(0,U.jsx)(`path`,{d:`M4 22h16`}),(0,U.jsx)(`path`,{d:`M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22`}),(0,U.jsx)(`path`,{d:`M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22`}),(0,U.jsx)(`path`,{d:`M18 2H6v7a6 6 0 0 0 12 0V2Z`})]}),culture:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z`}),(0,U.jsx)(`path`,{d:`m6.2 5.3 3.1 3.9`}),(0,U.jsx)(`path`,{d:`m12.4 3.4 3.1 4`}),(0,U.jsx)(`path`,{d:`M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z`})]})},X=`M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M15.97 6.37c.62-.75 1.04-1.8 0.93-2.85-.9.04-1.99.6-2.63 1.35-.57.65-1.07 1.71-.93 2.73.99.08 2.02-.48 2.63-1.23Z`;function Z({id:e}){if(e===`apple`)return(0,U.jsx)(`svg`,{className:`w-3.5 h-3.5 shrink-0`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:X})});let t=Zu[e];return t?(0,U.jsx)(`svg`,{className:`w-3.5 h-3.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:t}):null}async function Qu(e){try{let t=(await H.listFolders()).folders.find(t=>t.name===e);return t?t.id:(await H.createFolder(e)).id}catch{return null}}function $u({onSubscribed:e}){let{t,i18n:n}=R(),{syncAllowed:r}=wu(),i=ll(),a=tl(i),o=n.resolvedLanguage||`en`,[s,c]=(0,_.useState)([]),[l,u]=(0,_.useState)(!1),d=(0,_.useMemo)(()=>rl(i,s,o).map(e=>({...e,feeds:l?Ju(e,o):qu(e,o)})).filter(e=>e.feeds.length>0),[i,s,o,l]),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(new Set),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(!1),x=(0,_.useRef)(null),S=d.find(e=>e.id===f)??d[0]??null,C=d.reduce((e,t)=>e+t.feeds.filter(e=>m.has(e.url)).length,0),w=S!==null&&S.feeds.every(e=>m.has(e.url));(0,_.useEffect)(()=>{let e=!0;return H.feedLists(o).then(t=>{e&&c(t.lists)},()=>{e&&c([])}),()=>{e=!1}},[o]);function T(e){h(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})}function E(){S&&h(e=>{let t=new Set(e);for(let e of S.feeds)w?t.delete(e.url):t.add(e.url);return t})}async function D(){let n=[];for(let e of d)for(let t of e.feeds)m.has(t.url)&&n.push({url:t.url,folderName:e.title});if(n.length===0)return;v({done:0,total:n.length});let r=new Map;for(let e of new Set(n.map(e=>e.folderName)))r.set(e,await Qu(e));let i=0,a=0,o=0,s=new Set,c=[...n];await Promise.all(Array.from({length:Math.min(3,n.length)},async()=>{for(let e=c.shift();e;e=c.shift()){try{await H.subscribeFeed(e.url,null,r.get(e.folderName)??null),i++,s.add(e.url)}catch(t){t instanceof va&&t.code===`already_subscribed`?(i++,s.add(e.url)):a++}v({done:++o,total:n.length})}})),v(null),h(e=>new Set([...e].filter(e=>!s.has(e)))),a>0?K.error(t(`welcome.packPartial`,{added:i,failed:a})):K.success(t(`welcome.packAdded`,{count:i})),i>0&&await e()}async function O(n){let r=n.target.files?.[0];if(r){b(!0);try{let n=await H.importOpml(await r.text());n.failed>0?K.error(t(`feeds.importPartial`,{imported:n.imported,skipped:n.skipped,failed:n.failed})):K.success(t(`feeds.importSuccess`,{imported:n.imported,skipped:n.skipped})),n.imported>0&&await e()}catch{K.error(t(`feeds.importFailed`))}finally{b(!1),x.current&&(x.current.value=``)}}}async function k(n){K.success(t(`feeds.subscribedToast`,{title:n.label||n.title||n.url})),await e()}let A=g!==null||y;return r?(0,U.jsxs)(`section`,{className:`card flex flex-col gap-6 p-5 sm:p-7 shadow-xs`,"aria-labelledby":`welcome-title`,children:[(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h2`,{id:`welcome-title`,className:`text-xl sm:text-2xl font-bold tracking-tight text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:t(`welcome.title`)}),(0,U.jsx)(`p`,{className:`max-w-xl text-xs sm:text-sm text-[var(--c-text-muted)] mt-0.5 leading-relaxed`,children:t(`welcome.intro`)})]})}),a&&(0,U.jsx)(bu,{name:`onboarding`,mount:a.mount}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-4`,children:[d.length>0&&(0,U.jsxs)(`div`,{className:`rounded-2xl border border-[var(--c-border)]/80 bg-[var(--c-surface-hover)]/25 p-4 sm:p-5 flex flex-col gap-3.5`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,U.jsx)(`div`,{className:`w-7 h-7 rounded-lg bg-[var(--c-blue1)]/10 text-[var(--c-blue1)] flex items-center justify-center shrink-0`,children:(0,U.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,U.jsx)(`polygon`,{points:`16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76`})]})}),(0,U.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:t(`welcome.packsTitle`)})]}),(0,U.jsx)(`p`,{className:`text-xs sm:text-sm text-[var(--c-text-muted)] mt-1 ml-9.5`,children:t(`welcome.packsHint`)})]}),(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t(`welcome.packsTitle`),children:d.map(e=>{let t=e.feeds.filter(e=>m.has(e.url)).length,n=S?.id===e.id;return(0,U.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:A,onClick:()=>p(e.id),className:`inline-flex items-center gap-2 rounded-full border px-3.5 py-1.5 text-xs sm:text-sm font-semibold cursor-pointer transition-all ${n?`border-[var(--c-blue1)] bg-[var(--c-blue1)] text-white shadow-xs`:`border-[var(--c-border)] bg-[var(--c-surface)] hover:border-[var(--c-blue3)] hover:bg-[var(--c-surface-hover)] text-[var(--c-text)]`}`,children:[(0,U.jsx)(Z,{id:e.id}),(0,U.jsx)(`span`,{children:e.title}),t>0&&(0,U.jsx)(`span`,{className:`rounded-full px-1.5 text-[0.625rem] font-bold leading-4 ${n?`bg-white/25 text-white`:`bg-[var(--c-blue1)] text-white`}`,children:t})]},e.id)})}),S&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-3 pt-2 animate-fade-in border-t border-[var(--c-border)]/60`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[S.description&&(0,U.jsx)(`p`,{className:`text-xs sm:text-sm text-[var(--c-text-muted)]`,children:S.description}),(0,U.jsx)(`button`,{type:`button`,disabled:A,onClick:E,className:`text-xs sm:text-sm font-semibold text-[var(--c-blue1)] cursor-pointer hover:underline`,children:t(w?`welcome.deselectAll`:`welcome.selectAll`)})]}),(0,U.jsx)(`ul`,{className:`divide-y divide-[var(--c-border)] rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)]`,children:S.feeds.map(e=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 px-3.5 py-2.5 hover:bg-[var(--c-surface-hover)]/50 transition-colors`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:m.has(e.url),disabled:A,onChange:()=>T(e.url),className:`mt-0.5 rounded accent-[var(--c-blue1)]`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate text-xs sm:text-sm font-medium`,children:e.title}),e.description&&(0,U.jsx)(`span`,{className:`block text-xs text-[var(--c-text-muted)] leading-snug`,children:e.description})]}),e.lang&&(0,U.jsx)(`span`,{className:`shrink-0 text-[0.625rem] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded bg-[var(--c-surface-hover)] text-[var(--c-text-muted)]`,children:e.lang})]})},e.url))})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,U.jsx)(`button`,{type:`button`,disabled:A||C===0,onClick:()=>void D(),className:`btn-primary self-start text-xs sm:text-sm font-semibold px-4 py-2`,children:g?t(`welcome.subscribingProgress`,{done:g.done,total:g.total}):t(`welcome.subscribePack`,{count:C})}),(0,U.jsxs)(`label`,{className:`inline-flex items-center gap-2 text-xs sm:text-sm text-[var(--c-text-muted)] cursor-pointer`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:l,disabled:A,onChange:e=>u(e.target.checked),className:`rounded accent-[var(--c-blue1)]`}),t(`welcome.allLanguages`)]})]})]}),(0,U.jsxs)(`div`,{className:`rounded-2xl border border-[var(--c-border)]/80 bg-[var(--c-surface-hover)]/25 p-4 sm:p-5 flex flex-col gap-3.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,U.jsx)(`div`,{className:`w-7 h-7 rounded-lg bg-[var(--c-blue1)]/10 text-[var(--c-blue1)] flex items-center justify-center shrink-0`,children:(0,U.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,U.jsx)(`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`}),(0,U.jsx)(`path`,{d:`M2 12h20`})]})}),(0,U.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:t(`welcome.addTitle`)})]}),(0,U.jsx)(Yu,{compact:!0,folderOptions:[],defaultFolderId:null,onClose:()=>{},onAdded:k})]}),(0,U.jsxs)(`div`,{className:`rounded-2xl border border-[var(--c-border)]/80 bg-[var(--c-surface-hover)]/25 p-4 sm:p-5 flex flex-col sm:flex-row sm:items-center justify-between gap-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,U.jsx)(`div`,{className:`w-7 h-7 rounded-lg bg-[var(--c-blue1)]/10 text-[var(--c-blue1)] flex items-center justify-center shrink-0`,children:(0,U.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`path`,{d:`M21 8v13H3V8`}),(0,U.jsx)(`path`,{d:`M1 3h22v5H1z`}),(0,U.jsx)(`path`,{d:`M10 12h4`})]})}),(0,U.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:t(`welcome.importTitle`)})]}),(0,U.jsx)(`p`,{className:`text-xs sm:text-sm text-[var(--c-text-muted)] mt-1 ml-9.5`,children:t(`welcome.importHint`)})]}),(0,U.jsxs)(`button`,{type:`button`,disabled:A,onClick:()=>x.current?.click(),className:`btn-secondary inline-flex items-center gap-2 shrink-0 text-xs sm:text-sm font-semibold px-4 py-2`,children:[(0,U.jsx)(Fu,{}),t(y?`feeds.importing`:`feeds.importOpml`)]}),(0,U.jsx)(`input`,{type:`file`,ref:x,onChange:O,accept:`.opml,.xml,text/xml,application/xml`,className:`hidden`})]})]})]}):(0,U.jsx)(Y,{})}function ed({folder:e,onRenamed:t}){let{t:n}=R(),[r,i]=(0,_.useState)(e.name);async function a(){let a=r.trim();if(!a||a===e.name)i(e.name);else try{await H.updateFolder(e.id,a),K.success(n(`feeds.folderRenamed`,{name:a})),await t()}catch{i(e.name),K.error(n(`common.error`))}}return(0,U.jsx)(`input`,{className:`input h-9 min-h-0 flex-1 border-transparent bg-transparent px-2 text-sm shadow-none hover:border-[var(--c-border)] focus:border-[var(--c-border)]`,value:r,onChange:e=>i(e.target.value),onBlur:()=>void a(),onKeyDown:t=>{t.key===`Enter`&&t.currentTarget.blur(),t.key===`Escape`&&i(e.name)}})}function td({folders:e,onClose:t,onChanged:n}){let{t:r}=R(),{syncAllowed:i}=wu(),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(!1);async function l(e){if(e.preventDefault(),a.trim()){c(!0);try{await H.createFolder(a.trim()),K.success(r(`feeds.folderCreated`,{name:a.trim()})),o(``),await n()}catch{K.error(r(`common.error`))}finally{c(!1)}}}async function u(e){if(confirm(r(`feeds.deleteFolderConfirm`,{name:e.name})))try{await H.deleteFolder(e.id),K.success(r(`feeds.folderDeleted`,{name:e.name})),await n()}catch{K.error(r(`common.error`))}}return(0,U.jsxs)(`section`,{className:`card animate-fade-in flex flex-col gap-4 p-4 sm:p-5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h2`,{className:`text-base font-semibold`,children:r(`feeds.manageFolders`)}),(0,U.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--c-text-muted)]`,children:r(`feeds.renameFolderHint`)})]}),(0,U.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg p-1 text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,"aria-label":r(`common.close`),children:(0,U.jsx)(Bu,{})})]}),e.length>0&&(0,U.jsx)(`ul`,{className:`divide-y divide-[var(--c-border)] rounded-xl border border-[var(--c-border)]`,children:e.map(e=>(0,U.jsxs)(`li`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,U.jsx)(ed,{folder:e,onRenamed:n},e.name),(0,U.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-[var(--c-text-muted)]`,children:r(`feeds.feedCount`,{count:e.feed_count??0})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:`rounded-lg p-2 text-[var(--c-text-muted)] hover:bg-[var(--c-danger-bg)] hover:text-[var(--c-danger)] cursor-pointer`,"aria-label":r(`common.delete`),title:r(`common.delete`),children:(0,U.jsx)(Nu,{})})]},e.id))}),(0,U.jsxs)(`form`,{onSubmit:l,className:`flex gap-2`,children:[(0,U.jsx)(`input`,{type:`text`,disabled:!i,placeholder:r(`feeds.newFolderPlaceholder`),className:`input flex-1`,value:a,onChange:e=>o(e.target.value)}),(0,U.jsx)(`button`,{type:`submit`,disabled:s||!i||!a.trim(),title:i?void 0:r(`plan.unavailable`),className:`btn-primary whitespace-nowrap`,children:r(`feeds.addFolder`)})]})]})}function nd(e,t,n){e.deferred?K.info(n(`feeds.refreshPendingToast`,{title:t})):e.error?K.error(n(`feeds.refreshFailedToast`,{title:t,error:Eu(n,e.error)})):K.success(n(`feeds.refreshedToast`,{title:t,count:e.newItems}))}function rd(e,t){e.deferred?K.info(t(`feeds.refreshAllPendingToast`,{count:e.deferred,newItems:e.newItems})):e.errors||K.success(t(`feeds.refreshedAllToast`,{count:e.refreshed,newItems:e.newItems})),e.errors>0&&K.error(t(`feeds.failingCount`,{count:e.errors}))}var id=[5,15,30,60,180,360,720,1440],ad=`none`;function od(e,t){return!t||[e.label,e.title,e.url,e.site_url].filter(Boolean).join(` `).toLowerCase().includes(t.toLowerCase())}function sd(){let{t:e}=R(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(new Set),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),[v,y]=Li(),[b]=(0,_.useState)(()=>[v.get(`url`),v.get(`text`),v.get(`add`)].filter(Boolean).join(` `).match(/https?:\/\/[^\s]+/i)?.[0]??``);(0,_.useEffect)(()=>{(v.has(`add`)||v.has(`url`)||v.has(`text`))&&(j&&c(`add`),y({},{replace:!0}))},[]);let[x,S]=(0,_.useState)(`all`),[C,w]=(0,_.useState)(null),[T,E]=(0,_.useState)(!1),[D,O]=(0,_.useState)(null),k=(0,_.useRef)(null);async function A(){try{let[e,t]=await Promise.all([H.listFeeds(),H.listFolders().catch(()=>({folders:[]}))]);n(e),i(t.folders)}catch(e){console.error(`Failed to load feeds:`,e)}finally{o(!1)}}(0,_.useEffect)(()=>{A()},[]),(0,_.useEffect)(()=>{if(D===null)return;document.getElementById(`feed-${D}`)?.scrollIntoView({behavior:`smooth`,block:`center`});let e=window.setTimeout(()=>O(null),2500);return()=>window.clearTimeout(e)},[D,t]);let{syncAllowed:j}=wu(),ee=e=>(e.label??e.title??e.url).replace(/\s+/g,` `).trim();async function te(t){K.success(e(`feeds.subscribedToast`,{title:ee(t)})),g(``),S(`all`),await A(),O(t.id)}let ne=(0,_.useMemo)(()=>[{value:``,label:e(`feeds.noFolder`)},...r.map(e=>({value:String(e.id),label:e.name}))],[r,e]),re=(0,_.useMemo)(()=>id.map(t=>({value:String(t),label:Uu(e,t)})),[e]),M=(0,_.useMemo)(()=>{let n=new Map;for(let e of t){let t=e.folder_id??null;n.set(t,[...n.get(t)??[],e])}let i=[...r].sort((e,t)=>e.name.localeCompare(t.name)).map(e=>({key:`folder:${e.id}`,name:e.name,feeds:n.get(e.id)??[]}));return i.push({key:ad,name:e(`feeds.uncategorized`),feeds:n.get(null)??[]}),i.filter(e=>e.feeds.length>0)},[t,r,e]),ie=(0,_.useMemo)(()=>M.filter(e=>x===`all`||x===`failing`||e.key===x).map(e=>({...e,feeds:e.feeds.filter(e=>od(e,h)&&(x!==`failing`||!!e.last_error))})).filter(e=>e.feeds.length>0),[M,x,h]),ae=t.reduce((e,t)=>e+t.unread_count,0),oe=t.filter(e=>e.last_error).length,se=!h&&x!==`failing`;(0,_.useEffect)(()=>{if(!C)return;let e=e=>e.preventDefault();return window.addEventListener(`dragover`,e),window.addEventListener(`drop`,e),()=>{window.removeEventListener(`dragover`,e),window.removeEventListener(`drop`,e)}},[C!==null]);async function ce(){if(!C||C.from===C.over){w(null);return}let e=M.map(e=>{if(e.key!==C.group)return e.feeds;let t=[...e.feeds],[n]=t.splice(C.from,1);return t.splice(C.over,0,n),t}).flat();n(e),w(null);try{await H.reorderFeeds(e.map(e=>e.id))}catch(e){console.error(`Failed to save feed order:`,e),await A()}}async function N(t){f(e=>new Set(e).add(t));try{let r=await H.refreshFeed(t);r.feed?n(e=>e.map(e=>e.id===t?r.feed:e)):await A(),nd(r,r.feed?ee(r.feed):``,e)}catch{K.error(e(`common.error`))}finally{f(e=>{let n=new Set(e);return n.delete(t),n})}}async function le(){m(!0);try{let t=await H.refreshAllFeeds();await A(),rd(t,e)}catch{K.error(e(`common.error`))}finally{m(!1)}}async function ue(t){if(confirm(e(`feeds.unsubscribeConfirm`,{title:ee(t)})))try{await H.unsubscribeFeed(t.id),K.success(e(`feeds.unsubscribedToast`,{title:ee(t)})),await A()}catch{K.error(e(`common.error`))}}async function de(t){try{await H.markAllRead(t.id),K.success(e(`feeds.markedReadToast`,{title:ee(t)})),await A()}catch{K.error(e(`common.error`))}}function fe(){let e=document.createElement(`a`);e.href=H.exportOpmlUrl(),e.download=`feedkeeper-subscriptions.opml`,e.click()}async function pe(t){let n=t.target.files?.[0];if(n){E(!0);try{let t=await H.importOpml(await n.text());t.failed>0?K.error(e(`feeds.importPartial`,{imported:t.imported,skipped:t.skipped,failed:t.failed})):K.success(e(`feeds.importSuccess`,{imported:t.imported,skipped:t.skipped})),await A()}catch{K.error(e(`feeds.importFailed`))}finally{E(!1),k.current&&(k.current.value=``)}}}let me=[{key:`all`,label:e(`feeds.filterAll`),count:t.length},...M.map(e=>({key:e.key,label:e.name,count:e.feeds.length})),...oe>0?[{key:`failing`,label:e(`feeds.filterFailing`),count:oe,danger:!0}]:[]];return(0,U.jsxs)(`div`,{className:`flex flex-col gap-6 pb-24`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h1`,{className:`text-2xl font-semibold`,children:e(`feeds.title`)}),!a&&t.length>0&&(0,U.jsxs)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:[e(`feeds.feedCount`,{count:t.length}),` · `,e(`feeds.unread`,{count:ae}),oe>0&&(0,U.jsxs)(U.Fragment,{children:[` · `,(0,U.jsx)(`button`,{type:`button`,onClick:()=>S(`failing`),className:`text-[var(--c-danger)] hover:underline cursor-pointer`,children:e(`feeds.failingCount`,{count:oe})})]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(a||t.length>0)&&(0,U.jsxs)(`button`,{type:`button`,disabled:!j,title:j?void 0:e(`plan.unavailable`),onClick:()=>c(s===`add`?null:`add`),className:`btn-primary inline-flex items-center gap-1.5 whitespace-nowrap`,children:[(0,U.jsx)(Pu,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:e(`feeds.addFeed`)}),(0,U.jsx)(`span`,{className:`sm:hidden`,children:e(`feeds.addFeedShort`)})]}),(0,U.jsx)(Cu,{label:e(`feeds.moreActions`),items:[{label:e(p?`feeds.refreshing`:`feeds.refreshAll`),icon:(0,U.jsx)(Au,{className:`h-4 w-4 ${p?`animate-spin`:``}`}),onSelect:le,disabled:p||!j},{label:e(`feeds.manageFolders`),icon:(0,U.jsx)(Lu,{}),onSelect:()=>c(`folders`)},{label:e(T?`feeds.importing`:`feeds.importOpml`),icon:(0,U.jsx)(Fu,{}),onSelect:()=>k.current?.click(),disabled:T||!j},{label:e(`feeds.exportOpml`),icon:(0,U.jsx)(Iu,{}),onSelect:fe}]}),(0,U.jsx)(`input`,{type:`file`,ref:k,onChange:pe,accept:`.opml,.xml,text/xml,application/xml`,className:`hidden`})]})]}),!j&&t.length>0&&(0,U.jsx)(Y,{}),s===`add`&&j&&(0,U.jsx)(Yu,{folderOptions:ne,defaultFolderId:x.startsWith(`folder:`)?Number(x.slice(7)):null,initialUrl:b,subscribedUrls:t.map(e=>e.url),onClose:()=>c(null),onAdded:te}),s===`folders`&&(0,U.jsx)(td,{folders:r,onClose:()=>c(null),onChanged:A}),a?(0,U.jsx)(Su,{size:`lg`}):t.length===0?s!==`add`&&(0,U.jsx)($u,{onSubscribed:A}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`span`,{className:`pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-[var(--c-text-muted)] opacity-60`,children:(0,U.jsx)(Ru,{})}),(0,U.jsx)(`input`,{type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:e(`feeds.searchPlaceholder`),"aria-label":e(`feeds.searchPlaceholder`),className:`input pl-9`})]}),(0,U.jsx)(`div`,{className:`-mx-4 flex gap-2 overflow-x-auto px-4 pb-1 sm:mx-0 sm:flex-wrap sm:overflow-visible sm:px-0`,role:`group`,"aria-label":e(`feeds.folder`),children:me.map(e=>{let t=x===e.key;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>S(e.key),"aria-pressed":t,className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border px-3 py-1.5 text-sm font-medium transition-colors cursor-pointer ${t?`border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] text-[var(--c-text)]`:`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)]`} ${e.danger&&!t?`text-[var(--c-danger)]`:``}`,children:[e.label,e.count!==void 0&&(0,U.jsx)(`span`,{className:`text-xs tabular-nums opacity-70`,children:e.count})]},e.key)})})]}),ie.length===0?(0,U.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:e(`feeds.noMatches`)}):(0,U.jsx)(`div`,{className:`flex flex-col gap-6 animate-page-fade`,children:ie.map(t=>{let n=t.feeds.reduce((e,t)=>e+t.unread_count,0);return(0,U.jsxs)(`section`,{children:[(0,U.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-3 px-1`,children:[(0,U.jsx)(`h2`,{className:`truncate text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:t.name}),(0,U.jsxs)(`span`,{className:`shrink-0 text-xs text-[var(--c-text-muted)]`,children:[e(`feeds.feedCount`,{count:t.feeds.length}),n>0&&` · ${e(`feeds.unread`,{count:n})}`]})]}),(0,U.jsx)(`ul`,{className:`card divide-y divide-[var(--c-border)]`,children:t.feeds.map((e,n)=>(0,U.jsx)(Ku,{feed:e,editing:l===e.id,refreshing:d.has(e.id),highlighted:D===e.id,folderOptions:ne,intervalOptions:re,onEdit:t=>u(t?e.id:null),onRefresh:()=>void N(e.id),onMarkRead:()=>void de(e),onUnsubscribe:()=>void ue(e),onSaved:A,drag:se&&t.feeds.length>1?{isDragging:C?.group===t.key&&C.from===n,isDragOver:C?.group===t.key&&C.over===n&&C.from!==n,onDragStart:r=>{r.dataTransfer.effectAllowed=`move`,r.dataTransfer.setData(`application/x-feedkeeper-feed`,String(e.id)),w({group:t.key,from:n,over:n})},onDragOver:e=>{C?.group===t.key&&(e.preventDefault(),C.over!==n&&w({...C,over:n}))},onDragEnd:()=>void ce(),onDrop:e=>e.preventDefault()}:void 0},e.id))})]},t.key)})})]})]})}function cd(){let[e,t]=(0,_.useState)(()=>new Date);return(0,_.useEffect)(()=>{let n=new Date(e);n.setHours(24,0,1,0);let r=window.setTimeout(()=>t(new Date),n.getTime()-Date.now());return()=>window.clearTimeout(r)},[e]),e}function ld({className:e=``}){let{i18n:t}=R(),n=cd(),r=e=>new Intl.DateTimeFormat(t.resolvedLanguage,{weekday:`long`,day:`numeric`,month:`long`,...e?{year:`numeric`}:{}}).format(n);return(0,U.jsxs)(`time`,{dateTime:n.toLocaleDateString(`sv-SE`),className:`truncate text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)] ${e}`,children:[(0,U.jsx)(`span`,{className:`sm:hidden`,children:r(!1)}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:r(!0)})]})}var ud=650;function dd(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content.querySelectorAll(`script, style, noscript, template, svg, [hidden], [aria-hidden='true']`).forEach(e=>e.remove()),t.content.querySelectorAll(`p, div, li, br, blockquote, section, article, h1, h2, h3, h4, h5, h6`).forEach(e=>e.after(` `)),t.content.textContent?.replace(/\s+/g,` `).trim()??``}function fd(e){let t=e.full_content_html?.trim()?dd(e.full_content_html):``,n=!t&&e.content_html?.trim()?dd(e.content_html):``,r=e.content_snippet?.replace(/\s+/g,` `).trim()??``,i=t||(n.length>=r.length?n:r);return i?i.length<=ud?i:Eo(i)===`ja`?Do(i,ud):`${i.slice(0,ud).trimEnd()}…`:null}function pd({item:e,className:t}){let n=(0,_.useMemo)(()=>fd(e),[e]);if(!n)return null;let r=Eo(n);return(0,U.jsx)(`p`,{className:r===`ja`?`${t} ja-phrases`:t,lang:r,children:(0,U.jsx)(Bc,{text:n})})}function md(e){let t=0,n=-5;return e.map((e,r)=>{let i=/^https?:\/\//i.test(e.image_url??``),a=(e.content_snippet?.trim().length??0)>=220,o=(i||a)&&r-n>=5&&t<=1;return t=(t+(o?2:1))%3,o&&(n=r),o})}function hd(e){let t=e.map(()=>!1),n=[],r=0;return e.forEach((i,a)=>{n.push(a),r+=i?2:1,r===3&&(n.some(t=>e[t])&&n.forEach(n=>{t[n]=!e[n]}),n=[],r=0)}),t}function gd({url:e,featured:t}){let[n,r]=(0,_.useState)(`loading`);return!e||!/^https?:\/\//i.test(e)?null:(0,U.jsx)(`div`,{className:n===`hidden`?`hidden`:`overflow-hidden border-b border-[var(--c-border)] bg-[var(--c-bg)]`,children:(0,U.jsx)(`img`,{src:e,alt:``,loading:`lazy`,className:`w-full object-cover transition-transform duration-300 group-hover:scale-[1.025] ${t?`aspect-[3/2] lg:aspect-[16/9]`:`aspect-[3/2]`} ${n===`visible`?`opacity-100`:`opacity-0`}`,onLoad:e=>{let{naturalWidth:n,naturalHeight:i}=e.currentTarget;r(n>=(t?400:160)&&i>=(t?220:100)?`visible`:`hidden`)},onError:()=>r(`hidden`)})})}function _d({item:e,featured:t,besideFeature:n,onOpen:r,onBookmark:i,onRead:a}){let{t:o,i18n:s}=R(),c=e.published_at?new Date(e.published_at):null,l=c&&!Number.isNaN(c.getTime())?c:null,u=l?new Intl.DateTimeFormat(s.resolvedLanguage,{dateStyle:`medium`}).format(l):null,d=l?new Intl.DateTimeFormat(s.resolvedLanguage,{timeStyle:`short`}).format(l):null;return(0,U.jsx)(`li`,{className:t?`lg:col-span-2`:``,children:(0,U.jsxs)(`article`,{className:`card group relative flex h-full flex-col overflow-hidden transition-colors duration-150 hover:border-[var(--c-blue3)] hover:bg-[var(--c-surface-hover)]`,style:{opacity:e.read?.65:1},children:[(0,U.jsx)(`button`,{type:`button`,className:`absolute inset-0 z-10 rounded-xl focus-visible:outline-2 focus-visible:outline-offset-[-3px] focus-visible:outline-[var(--c-blue3)]`,"aria-label":e.title||e.feed_title||o(`items.title`),onClick:()=>r(e)}),(0,U.jsx)(gd,{url:e.image_url,featured:t},e.image_url??``),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col ${t?`p-4 sm:p-5 lg:p-6`:`p-4 sm:p-5`}`,children:[(0,U.jsxs)(`div`,{className:`mb-3 flex min-w-0 items-center gap-2 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:[(0,U.jsx)(zc,{feedId:e.feed_id,iconUrl:e.feed_icon_url,siteUrl:e.feed_site_url,feedUrl:e.feed_url,articleUrl:e.link,className:`h-3.5 w-3.5 shrink-0 rounded-xs object-contain`}),(0,U.jsx)(`span`,{className:`truncate`,children:e.feed_title})]}),(0,U.jsx)(`h2`,{lang:Eo(e.title||e.feed_title),className:`text-[var(--c-text)] ${t?`text-lg leading-snug lg:text-2xl lg:leading-tight`:`text-lg leading-snug`} font-semibold${Eo(e.title||e.feed_title)===`ja`?` ja-phrases`:``}`,children:e.title||e.feed_title?(0,U.jsx)(Bc,{text:e.title||e.feed_title}):null}),(0,U.jsx)(pd,{item:e,className:`mt-3 text-sm leading-relaxed text-[var(--c-text-muted)] ${t?`line-clamp-3 lg:line-clamp-4`:n?`line-clamp-3 lg:line-clamp-12`:`line-clamp-3`}`}),(0,U.jsxs)(`div`,{className:`pointer-events-none relative z-20 mt-auto flex flex-wrap items-center gap-x-3 gap-y-2 pt-5 text-xs text-[var(--c-text-muted)]`,children:[u&&(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:d??void 0,children:[(0,U.jsxs)(`svg`,{className:`h-3.5 w-3.5 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`18`,rx:`2`}),(0,U.jsx)(`path`,{d:`M8 2v4M16 2v4M3 10h18`})]}),u]}),d&&(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsxs)(`svg`,{className:`h-3.5 w-3.5 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,U.jsx)(`path`,{d:`M12 6v6l4 2`})]}),d]}),(0,U.jsxs)(`div`,{className:`pointer-events-auto ml-auto flex items-center gap-1.5`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:()=>i(e),title:e.bookmarked?o(`items.unbookmark`):o(`items.bookmark`),"aria-label":e.bookmarked?o(`items.unbookmark`):o(`items.bookmark`),className:`grid h-8 w-8 place-items-center rounded-lg border transition-colors ${e.bookmarked?`border-amber-500/40 bg-amber-500/15 text-amber-500`:`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500`}`,children:(0,U.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:e.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,U.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>a(e),title:e.read?o(`items.markUnread`):o(`items.markRead`),"aria-label":e.read?o(`items.markUnread`):o(`items.markRead`),className:`grid h-8 w-8 place-items-center rounded-lg border border-[var(--c-border)] transition-colors ${e.read?`text-[var(--c-text-muted)]`:`text-[var(--c-blue3)]`}`,children:(0,U.jsx)(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:e.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2.2`,"aria-hidden":`true`,children:(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})})]})]})]})]})})}function vd({items:e,onOpen:t,onBookmark:n,onRead:r}){let i=(0,_.useMemo)(()=>md(e),[e]),a=(0,_.useMemo)(()=>hd(i),[i]);return(0,U.jsx)(`ul`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 sm:gap-5 animate-page-fade`,children:e.map((e,o)=>(0,U.jsx)(_d,{item:e,featured:i[o],besideFeature:a[o],onOpen:t,onBookmark:n,onRead:r},e.id))})}var yd=68,bd=92,xd=`input, select, textarea, [contenteditable='true'], [data-no-pull]`;function Sd(){let e=e=>{e.preventDefault(),e.stopPropagation()};window.addEventListener(`click`,e,{capture:!0,once:!0}),window.setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function Cd({children:e,disabled:t=!1,onRefresh:n}){let{t:r}=R(),i=(0,_.useRef)(null),a=(0,_.useRef)(0),[o,s]=(0,_.useState)(0),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!1),m=(0,_.useCallback)(()=>{u||(p(!1),d(!0),s(56),n().catch(()=>p(!0)).finally(()=>{d(!1),s(0)}))},[u,n]);(0,_.useEffect)(()=>{let e=i.current;if(!e)return;let n=null;function r(){n=null,a.current=0,l(!1),s(0)}function o(e){t||u||e.touches.length!==1||window.scrollY>1||!window.matchMedia(`(any-pointer: coarse)`).matches||document.body.style.overflow===`hidden`||e.target.closest(xd)||(n={x:e.touches[0].clientX,y:e.touches[0].clientY})}function c(e){if(!n||e.touches.length!==1)return;let t=e.touches[0].clientX-n.x,i=e.touches[0].clientY-n.y;if(window.scrollY>1||Math.abs(t)>Math.abs(i)){r();return}if(i<=0){a.current=0,s(0);return}e.preventDefault();let o=Math.min(bd,i*.72);a.current=o,l(!0),s(o)}function d(){if(!n)return;let e=a.current>=yd;a.current>8&&Sd(),r(),e&&m()}return e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,c,{passive:!1}),e.addEventListener(`touchend`,d),e.addEventListener(`touchcancel`,r),()=>{e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,c),e.removeEventListener(`touchend`,d),e.removeEventListener(`touchcancel`,r)}},[t,u,n,m]);let h=u?1:Math.min(1,o/yd);return(0,U.jsxs)(`div`,{ref:i,children:[(0,U.jsx)(`button`,{type:`button`,className:`sr-only focus:not-sr-only sm:hidden`,onClick:m,disabled:t||u,children:r(`items.refresh`)}),(0,U.jsx)(`div`,{"aria-hidden":`true`,className:`relative flex items-center justify-center overflow-hidden`,style:{height:o,transition:c?`none`:`height 220ms ease-out`},children:(0,U.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full border border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text)] shadow-sm`,style:{opacity:Math.min(1,o/30),transform:`scale(${.65+h*.35})`},children:(0,U.jsxs)(`svg`,{className:`h-5 w-5 ${u?`animate-spin motion-reduce:animate-none`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:u?void 0:{transform:`rotate(${h*270}deg)`},children:[(0,U.jsx)(`path`,{d:`M18 7a8 8 0 1 0 2 5`,pathLength:`100`,strokeDasharray:`${h*100} 100`}),(0,U.jsx)(`path`,{d:`M18 3v4h-4`,opacity:h})]})})}),u&&(0,U.jsx)(`span`,{className:`sr-only`,role:`status`,children:r(`items.refreshing`)}),f&&(0,U.jsx)(`p`,{className:`mb-3 text-center text-sm text-[var(--c-danger)]`,role:`alert`,children:r(`items.refreshFailed`)}),e]})}function wd(){let{user:e}=lo(),t=il(ll()),[n,r]=(0,_.useState)(!1),i=!!e?.intro_dismissed_at;return(0,_.useEffect)(()=>{let n=!0;if(r(!1),t&&e&&i)return Promise.resolve(!t.applies||t.applies({id:e.id,email:e.email,display_name:e.display_name??null})).then(e=>{n&&r(e===!0)}).catch(()=>{n&&r(!1)}),()=>{n=!1}},[t?.mount,t?.applies,e?.id,i]),!t||!n?null:(0,U.jsx)(bu,{name:`articles-notice`,mount:t.mount})}function Td(){let{t:e}=R(),{user:t,setCurrentUser:n}=lo(),[r,i]=(0,_.useState)(!1);if(!t||t.intro_dismissed_at)return null;async function a(){i(!0);try{n(await H.dismissIntro())}catch{i(!1)}}let o=[{key:`views`,className:`hidden sm:flex`,icon:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2`}),(0,U.jsx)(`path`,{d:`M18 14h-8`}),(0,U.jsx)(`path`,{d:`M15 18h-5`}),(0,U.jsx)(`path`,{d:`M10 6h8v4h-8V6Z`})]})},{key:`unread`,solid:!0,icon:(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})},{key:`star`,icon:(0,U.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})},{key:`folders`,icon:(0,U.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z`})}];return(0,U.jsxs)(`section`,{className:`card animate-fade-in flex flex-col gap-5 p-5 sm:p-7 shadow-xs`,"aria-labelledby":`intro-title`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h2`,{id:`intro-title`,className:`text-xl sm:text-2xl font-bold tracking-tight text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:e(`intro.title`)}),(0,U.jsx)(`p`,{className:`mt-0.5 text-xs sm:text-sm leading-relaxed text-[var(--c-text-muted)]`,children:e(`intro.subtitle`)})]}),(0,U.jsx)(`button`,{type:`button`,onClick:a,disabled:r,"aria-label":e(`common.close`),className:`shrink-0 rounded-lg p-1 text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,children:(0,U.jsx)(Bu,{})})]}),(0,U.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:o.map(t=>(0,U.jsxs)(`li`,{className:`flex items-start gap-3.5 rounded-2xl border border-[var(--c-border)]/80 bg-[var(--c-surface-hover)]/25 p-4 ${t.className??``}`,children:[(0,U.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text)]`,children:(0,U.jsx)(`svg`,{className:t.solid?`h-3.5 w-3.5`:`h-4 w-4`,viewBox:`0 0 24 24`,fill:t.solid?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:t.solid?2.2:2,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:t.icon})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:e(`intro.${t.key}Title`)}),(0,U.jsx)(`p`,{className:`mt-0.5 text-xs sm:text-sm leading-relaxed text-[var(--c-text-muted)]`,children:e(`intro.${t.key}Text`)})]})]},t.key))}),(0,U.jsx)(`button`,{type:`button`,onClick:a,disabled:r,className:`btn-primary self-start`,children:e(`intro.done`)})]})}var Ed=50;function Dd(){return(0,U.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,U.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]})}var Od=`(max-width: 639px)`;function kd(){return(0,_.useSyncExternalStore)(e=>{let t=window.matchMedia(Od);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},()=>window.matchMedia(Od).matches)}function Ad(){let{t:e,i18n:t}=R(),[n,r]=Li(),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),{syncAllowed:u}=wu(),[d,f]=(0,_.useState)([]),[p,m]=(0,_.useState)([]),[h,g]=(0,_.useState)(!0),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(!1),E=(0,_.useRef)(0),D=(0,_.useRef)(0),O=(0,_.useRef)(!1),[k,A]=(0,_.useState)(null),[j,ee]=(0,_.useState)(()=>{try{return localStorage.getItem(`feedkeeper_items_view`)===`newspaper`?`newspaper`:`list`}catch{return`list`}}),te=kd()?`newspaper`:j;function ne(e){if(e!==j){Ka(),ee(e),window.scrollTo({top:0,behavior:`instant`});try{localStorage.setItem(`feedkeeper_items_view`,e)}catch{}}}let re=`feedkeeper_filter_scope`,M=`feedkeeper_filter_unread`,ie=`feedkeeper_filter_bookmarked`,ae=n.get(`article`),oe=(()=>{let e=n.get(`feed`);if(e)return`feed:${e}`;let t=n.get(`folder`);if(t)return`folder:${t}`;try{let e=localStorage.getItem(re);if(e)return e}catch{}return``})(),se=(()=>{try{let e=localStorage.getItem(M);if(e!==null)return e===`true`}catch{}return!0})(),ce=(()=>{if(n.get(`saved`)===`1`)return!0;if(n.get(`article`))return!1;try{let e=localStorage.getItem(ie);if(e!==null)return e===`true`}catch{}return!1})(),[N,le]=(0,_.useState)(oe),[ue,de]=(0,_.useState)(se),[fe,pe]=(0,_.useState)(ce),me=ue&&!fe,[he,ge]=(0,_.useState)(``),[P,F]=(0,_.useState)(!1),_e=(0,_.useRef)(null),I=(0,_.useRef)(null),ve=(0,_.useRef)(null),[ye,be]=(0,_.useState)(61),[L,xe]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let e=document.querySelector(`[data-app-header]`);if(!e)return;let t=new ResizeObserver(()=>be(e.getBoundingClientRect().height));return t.observe(e),()=>t.disconnect()},[]),(0,_.useEffect)(()=>{function e(){let e=ve.current?.getBoundingClientRect().top;xe(window.scrollY>0&&e!==void 0&&e<=ye+1)}return e(),window.addEventListener(`scroll`,e,{passive:!0}),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e),window.removeEventListener(`resize`,e)}},[ye]),(0,_.useEffect)(()=>{P&&_e.current?.focus()},[P]),(0,_.useEffect)(()=>{let e=window.matchMedia(`(min-width: 640px)`),t=()=>{e.matches&&F(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);function Se(){F(!1),requestAnimationFrame(()=>I.current?.focus())}function Ce(e){Ka(),ge(e)}function we(){Ka(),de(e=>{let t=!e;try{localStorage.setItem(M,String(t))}catch{}return t})}function Te(){Ka(),pe(e=>{let t=!e;try{localStorage.setItem(ie,String(t))}catch{}return t})}(0,_.useEffect)(()=>{if(h||O.current)return;let e=Wa(),t=requestAnimationFrame(()=>{e>0&&window.scrollTo({top:e,behavior:`instant`}),O.current=!0});return()=>cancelAnimationFrame(t)},[h]),(0,_.useEffect)(()=>{function e(){O.current&&document.body.style.overflow!==`hidden`&&Ga(window.scrollY)}return window.addEventListener(`scroll`,e,{passive:!0}),()=>{O.current&&document.body.style.overflow!==`hidden`&&Ga(window.scrollY),window.removeEventListener(`scroll`,e)}},[]),(0,_.useEffect)(()=>{let e=n.get(`feed`),t=n.get(`folder`);if(e){let t=`feed:${e}`;t!==N&&Ka(),le(t);try{localStorage.setItem(re,t)}catch{}}else if(t){let e=`folder:${t}`;e!==N&&Ka(),le(e);try{localStorage.setItem(re,e)}catch{}}else if(oe&&!n.toString()){let e=new URLSearchParams(n);oe.startsWith(`feed:`)?e.set(`feed`,oe.slice(5)):oe.startsWith(`folder:`)&&e.set(`folder`,oe.slice(7)),r(e,{replace:!0})}},[n]);function Ee(e){Ka(),le(e);try{e?localStorage.setItem(re,e):localStorage.removeItem(re)}catch{}let t=new URLSearchParams(n);t.delete(`feed`),t.delete(`folder`),e.startsWith(`feed:`)?t.set(`feed`,e.slice(5)):e.startsWith(`folder:`)&&t.set(`folder`,e.slice(7)),r(t,{replace:!0})}(0,_.useEffect)(()=>{Promise.all([H.listFeeds(),H.listFolders().then(e=>({...e,ok:!0})).catch(()=>({folders:[],ok:!1}))]).then(([e,t])=>{a(e),f(t.folders),l(t.ok),s(!0)}).catch(e=>console.error(`Failed to load initial feeds/folders:`,e))},[]),(0,_.useEffect)(()=>{o&&N&&(N.startsWith(`feed:`)?!i.some(e=>`feed:${e.id}`===N):N.startsWith(`folder:`)&&c&&!d.some(e=>`folder:${e.id}`===N))&&Ee(``)},[o,c,i,d,N]);let De=N.startsWith(`feed:`)?Number(N.slice(5)):void 0,Oe=N.startsWith(`folder:`)?Number(N.slice(7)):void 0,ke=!he&&!fe&&De===void 0&&Oe===void 0,Ae=ke&&i.length>0&&i.every(e=>!e.last_polled_at);async function je(){try{let[e,t]=await Promise.all([H.listFeeds(),H.listFolders().then(e=>({...e,ok:!0})).catch(()=>({folders:[],ok:!1}))]);return e.length===0&&(n.has(`folder`)||n.has(`feed`))&&(r({},{replace:!0}),le(``)),a(e),f(t.folders),l(t.ok),s(!0),e}catch(e){return console.error(`Failed to reload feeds:`,e),null}}async function Me(){await je(),await Ne(),no()}async function Ne(){let e=++E.current;g(!0),y(!1),C(!1),x(!1);try{let t=await H.listItems({feedId:De,folderId:Oe,unreadOnly:me,bookmarkedOnly:fe,search:he||void 0,limit:Ed});e===E.current&&(m(t),D.current=t.length,T(t.length===Ed))}catch(t){e===E.current&&(console.error(`Failed to load items:`,t),y(!0))}finally{e===E.current&&g(!1)}}async function Pe(){if(b||!w)return;let e=E.current,t=me||fe?p.filter(e=>(!me||!e.read)&&(!fe||e.bookmarked)).length:D.current;x(!0),C(!1);try{let n=await H.listItems({feedId:De,folderId:Oe,unreadOnly:me,bookmarkedOnly:fe,search:he||void 0,limit:Ed,offset:t});e===E.current&&(D.current=t+n.length,m(e=>{let t=new Set(e.map(e=>e.id));return[...e,...n.filter(e=>!t.has(e.id))]}),T(n.length===Ed))}catch(t){e===E.current&&(console.error(`Failed to load more items:`,t),C(!0))}finally{e===E.current&&x(!1)}}let Fe=(0,_.useRef)(Pe);Fe.current=Pe;let Ie=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=Ie.current;if(!e||!w||S||b||v)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&Fe.current()},{rootMargin:`600px 0px`});return t.observe(e),()=>t.disconnect()},[w,S,b,v,p.length]),(0,_.useEffect)(()=>{m([]),g(!0),T(!1),x(!1);let e=setTimeout(()=>{Ne()},200);return()=>{clearTimeout(e),E.current++}},[N,ue,fe,he]),(0,_.useEffect)(()=>{if(!Ae)return;let e=0,t=setInterval(()=>{e++,je().then(e=>{e?.some(e=>e.last_polled_at)&&Ne()}),e>=45&&clearInterval(t)},4e3);return()=>clearInterval(t)},[Ae]);let Le=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(ae){let e=p.find(e=>e.id===Number(ae));A(e??null),e&&!e.read&&Le.current!==e.id&&(Le.current=e.id,H.markRead(e.id).then(no).catch(()=>{}),m(t=>t.map(t=>t.id===e.id?{...t,read:!0}:t)))}else A(null)},[ae,p]);function Re(e){A(e),e.read||(H.markRead(e.id).then(no).catch(()=>{}),m(t=>t.map(t=>t.id===e.id?{...t,read:!0}:t)),A({...e,read:!0}));let t=new URLSearchParams(n);t.set(`article`,String(e.id)),r(t)}function ze(){A(null);let e=new URLSearchParams(n);e.delete(`article`),r(e)}let Be=k?p.findIndex(e=>e.id===k.id):-1,Ve=Be>=0&&Be<p.length-1,He=Be>0;function Ue(){Ve&&Re(p[Be+1])}function We(){He&&Re(p[Be-1])}async function Ge(t){try{await t()}catch(t){if(!(t instanceof va&&t.status===0))throw t;K.error(e(`common.offlineAction`))}}async function Ke(e){let t=!e.read;e.read?await H.markUnread(e.id):await H.markRead(e.id),no(),m(n=>n.map(n=>n.id===e.id?{...n,read:t}:n)),k?.id===e.id&&A(e=>e?{...e,read:t}:null)}async function qe(e){let t=!e.bookmarked;e.bookmarked?await H.unbookmarkItem(e.id):await H.bookmarkItem(e.id),window.setTimeout(()=>void Ba({force:!0}),t?2e4:0),m(n=>fe&&!t&&k?.id!==e.id?n.filter(t=>t.id!==e.id):n.map(n=>n.id===e.id?{...n,bookmarked:t}:n)),k?.id===e.id&&A(e=>e?{...e,bookmarked:t}:null)}async function Je(){await Ge(async()=>{await H.markAllRead({feedId:De,folderId:Oe}),await Ne(),no()})}let[Ye,Xe]=(0,_.useState)(!1);async function Ze(){Xe(!0);try{let t=await H.refreshAllFeeds();await Ne(),rd(t,e)}catch{K.error(e(`items.refreshFailed`))}finally{Xe(!1)}}let Qe=new Intl.DateTimeFormat(t.resolvedLanguage,{dateStyle:`medium`}),$e=new Intl.DateTimeFormat(t.resolvedLanguage,{timeStyle:`short`}),et=(0,_.useMemo)(()=>{let t=[{value:``,label:e(`items.allFeeds`)}];if(d.length>0)for(let n of d)t.push({value:`folder:${n.id}`,label:n.name,group:e(`feeds.folderGroup`),badge:n.unread_count});for(let n of i)t.push({value:`feed:${n.id}`,label:n.label??n.title??n.url,group:e(`feeds.feedGroup`),badge:n.unread_count});return t},[d,i,e]),tt=N?et.find(e=>e.value===N)?.label??e(`items.title`):e(`items.allFeeds`);function nt(e){m(t=>t.map(t=>t.id===e.id?{...t,...e}:t)),A(t=>t?.id===e.id?{...t,...e}:t)}let rt=(0,U.jsxs)(`div`,{className:`flex flex-col gap-5 sm:gap-6`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 sm:gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h1`,{className:`sr-only`,children:tt}),(0,U.jsx)(ld,{className:`block`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`relative hidden h-11 w-[220px] shrink-0 grid-cols-2 rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] p-1 sm:grid`,role:`group`,"aria-label":e(`items.viewMode`),children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-1 left-1 w-[calc((100%-0.5rem)/2)] rounded-lg border border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] shadow-sm transition-transform duration-300 ease-[cubic-bezier(0.25,1,0.5,1)] motion-reduce:transition-none`,style:{transform:j===`newspaper`?`translateX(100%)`:`translateX(0)`}}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>ne(`list`),title:e(`items.listView`),"aria-label":e(`items.listView`),"aria-pressed":j===`list`,className:`relative z-10 flex h-full min-w-0 items-center justify-center gap-1.5 rounded-lg text-xs sm:text-sm font-medium transition-colors focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${j===`list`?`text-[var(--c-text)]`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:[(0,U.jsxs)(`svg`,{className:`h-4 w-4 transition-transform duration-200 motion-reduce:transition-none ${j===`list`?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`path`,{d:`M8 6h12M8 12h12M8 18h12`}),(0,U.jsx)(`circle`,{cx:`4`,cy:`6`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`circle`,{cx:`4`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`circle`,{cx:`4`,cy:`18`,r:`1`,fill:`currentColor`,stroke:`none`})]}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:e(`items.listView`)})]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>ne(`newspaper`),title:e(`items.newspaperView`),"aria-label":e(`items.newspaperView`),"aria-pressed":j===`newspaper`,className:`relative z-10 flex h-full min-w-0 items-center justify-center gap-1.5 rounded-lg text-xs sm:text-sm font-medium transition-colors focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${j===`newspaper`?`text-[var(--c-text)]`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:[(0,U.jsxs)(`svg`,{className:`h-4 w-4 transition-transform duration-200 motion-reduce:transition-none ${j===`newspaper`?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`path`,{d:`M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2`}),(0,U.jsx)(`path`,{d:`M18 14h-8`}),(0,U.jsx)(`path`,{d:`M15 18h-5`}),(0,U.jsx)(`path`,{d:`M10 6h8v4h-8V6Z`})]}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:e(`items.newspaperView`)})]})]}),(0,U.jsx)(`button`,{type:`button`,onClick:Ze,disabled:Ye||!u,title:e(u?Ye?`items.refreshing`:`items.refresh`:`plan.unavailable`),"aria-label":e(Ye?`items.refreshing`:`items.refresh`),className:`btn-secondary hidden h-11 w-11 shrink-0 items-center justify-center p-0! sm:flex`,children:(0,U.jsx)(Au,{className:`h-5 w-5 ${Ye?`animate-spin motion-reduce:animate-none`:``}`})}),(0,U.jsx)(`button`,{type:`button`,onClick:Je,title:e(`feeds.markAllRead`),"aria-label":e(`feeds.markAllRead`),className:`btn-secondary flex h-11 w-11 shrink-0 items-center justify-center p-0!`,children:(0,U.jsx)(`svg`,{className:`h-5 w-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:`M3 12l4 4 6-7M11 16l3 0 7-8`})})})]})]}),(0,U.jsxs)(`div`,{ref:ve,className:`sticky z-20 py-2`,style:{top:ye},children:[L&&(0,U.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute -top-px bottom-0 left-1/2 w-screen -translate-x-1/2 border-y border-[var(--c-border)] backdrop-blur-md`,style:{backgroundColor:`color-mix(in srgb, var(--c-surface) 85%, transparent)`}}),(0,U.jsxs)(`div`,{className:`items-toolbar relative z-10 flex items-center gap-2 sm:gap-3 ${P?`items-toolbar-open`:``}`,children:[(0,U.jsx)(`div`,{className:`items-toolbar-scope min-w-0 flex-1 sm:flex-none sm:w-64`,inert:P,children:(0,U.jsx)(Tu,{value:N,onChange:Ee,options:et,className:`w-full`,placeholder:e(`items.allFeeds`)})}),(0,U.jsxs)(`div`,{className:`relative hidden sm:block flex-1 min-w-0`,children:[(0,U.jsx)(`input`,{type:`search`,placeholder:e(`items.searchPlaceholder`),"aria-label":e(`items.searchPlaceholder`),className:`input w-full pl-9 pr-3`,value:he,onChange:e=>Ce(e.target.value)}),(0,U.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none opacity-45 text-[var(--c-text-muted)]`,children:(0,U.jsx)(Dd,{})})]}),(0,U.jsxs)(`div`,{className:`items-toolbar-search relative h-[38px] min-w-0 overflow-hidden sm:hidden`,children:[(0,U.jsx)(`button`,{ref:I,type:`button`,onClick:()=>F(!0),"aria-label":e(`items.searchPlaceholder`),"aria-controls":`mobile-article-search`,"aria-expanded":P,title:e(`items.searchPlaceholder`),"aria-hidden":P,tabIndex:P?-1:0,className:`absolute inset-y-0 left-0 z-10 flex w-[38px] items-center justify-center rounded-lg border transition-opacity duration-150 ${P?`pointer-events-none opacity-0`:he?`border-[var(--c-blue3)] bg-[var(--c-surface-hover)] text-[var(--c-text)] opacity-100`:`border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text-muted)] opacity-100`}`,children:(0,U.jsx)(Dd,{})}),(0,U.jsxs)(`div`,{className:`flex h-full min-w-0 items-center gap-2 transition-opacity duration-200 ${P?`opacity-100 delay-75`:`pointer-events-none opacity-0`}`,inert:!P,children:[(0,U.jsx)(`span`,{className:`pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-[var(--c-text-muted)] opacity-60`,children:(0,U.jsx)(Dd,{})}),(0,U.jsx)(`input`,{id:`mobile-article-search`,ref:_e,type:`search`,placeholder:e(`items.searchPlaceholder`),"aria-label":e(`items.searchPlaceholder`),className:`input min-w-0 flex-1 pl-9`,value:he,onChange:e=>Ce(e.target.value),onKeyDown:e=>{e.key===`Escape`&&Se()}}),(0,U.jsx)(`button`,{type:`button`,onClick:Se,"aria-label":e(`common.close`),title:e(`common.close`),className:`w-[38px] h-[38px] rounded-lg border border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text-muted)] flex items-center justify-center shrink-0 cursor-pointer`,children:(0,U.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,U.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})]}),(0,U.jsxs)(`div`,{className:`items-toolbar-filters flex items-center gap-1.5 sm:gap-2 shrink-0`,inert:P,children:[(0,U.jsx)(`button`,{type:`button`,onClick:Te,title:e(fe?`items.all`:`items.bookmarkedOnly`),"aria-label":e(`items.bookmarkedOnly`),"aria-pressed":fe,className:`w-[38px] h-[38px] rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${fe?`bg-amber-500/15 border-amber-500/40 text-amber-500`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500 hover:border-amber-500/30`}`,children:(0,U.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:fe?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,U.jsx)(`button`,{type:`button`,onClick:we,disabled:fe,title:e(fe?`items.unreadIgnoredInSaved`:ue?`items.all`:`items.unreadOnly`),"aria-label":e(`items.unreadOnly`),"aria-pressed":me,className:`w-[38px] h-[38px] rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer disabled:cursor-default disabled:opacity-40 ${me?`bg-[var(--c-surface-hover)] border-[var(--c-blue3)] text-[var(--c-text)] shadow-xs`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:border-[var(--c-blue3)]`}`,children:(0,U.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:me?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2.2`,children:(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})})]})]})]}),o&&i.length>0&&!u&&(0,U.jsx)(Y,{}),o&&i.length>0&&!v&&(0,U.jsx)(Td,{}),o&&i.length>0&&!v&&(0,U.jsx)(wd,{}),v?(0,U.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3`,children:[(0,U.jsx)(`p`,{style:{color:`var(--c-text-muted)`},children:e(`items.loadFailed`)}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>void Ne(),className:`btn-secondary`,children:e(`common.retry`)})]}):h&&p.length===0?(0,U.jsx)(Su,{size:`lg`}):p.length===0&&o&&i.length===0?(0,U.jsx)($u,{onSubscribed:Me}):p.length===0&&Ae?(0,U.jsxs)(`div`,{role:`status`,className:`card flex flex-col items-center gap-3 px-6 py-12 text-center`,children:[(0,U.jsx)(Su,{size:`lg`}),(0,U.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`welcome.fetchingTitle`)}),(0,U.jsx)(`p`,{className:`max-w-sm text-sm text-[var(--c-text-muted)]`,children:e(`welcome.fetchingHint`)})]}):p.length===0&&ke&&me&&i.length>0?(0,U.jsxs)(`div`,{className:`card flex flex-col items-center gap-3 px-6 py-12 text-center`,children:[(0,U.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`items.allReadTitle`)}),(0,U.jsx)(`p`,{className:`max-w-sm text-sm text-[var(--c-text-muted)]`,children:e(`items.allReadHint`)}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>de(!1),className:`btn-secondary mt-1`,children:e(`items.all`)})]}):p.length===0?(0,U.jsx)(`p`,{style:{color:`var(--c-text-muted)`},children:e(fe&&!he?`items.noSaved`:he?`items.noResults`:`items.noItems`)}):te===`newspaper`?(0,U.jsx)(vd,{items:p,onOpen:Re,onBookmark:qe,onRead:Ke}):(0,U.jsx)(`ul`,{className:`flex flex-col gap-4 sm:gap-5 animate-page-fade`,children:p.map(t=>{let n=t.published_at?new Date(t.published_at):null;return(0,U.jsx)(`li`,{onClick:()=>Re(t),className:`card overflow-hidden p-4 sm:p-0 transition-colors duration-150 hover:bg-[var(--c-surface-hover)] hover:border-[var(--c-blue3)]/60 cursor-pointer group/card`,style:{opacity:t.read?.6:1},children:(0,U.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-stretch justify-between gap-3 sm:gap-0`,children:[t.image_url&&(0,U.jsx)(`div`,{className:`order-first w-[calc(100%+2rem)] -mx-4 -mt-4 sm:m-0 sm:w-52 sm:min-w-52 h-48 sm:h-auto sm:self-stretch overflow-hidden shrink-0 border-b sm:border-b-0 sm:border-r bg-[var(--c-bg)] group transition-opacity hover:opacity-90 block`,style:{borderColor:`var(--c-border)`},children:(0,U.jsx)(`img`,{src:t.image_url,alt:``,className:`w-full h-full object-cover group-hover:scale-105 transition-transform duration-200`,loading:`lazy`,onError:e=>{let t=e.currentTarget.parentElement;t&&(t.style.display=`none`)}})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1 sm:p-5 sm:pr-3 flex flex-col justify-between`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`mb-3 flex min-w-0 items-center gap-2 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:[(0,U.jsx)(zc,{feedId:t.feed_id,iconUrl:t.feed_icon_url,siteUrl:t.feed_site_url,feedUrl:t.feed_url,articleUrl:t.link,className:`w-3.5 h-3.5 rounded-xs shrink-0 object-contain`}),(0,U.jsx)(`span`,{className:`truncate`,children:t.feed_title})]}),(0,U.jsx)(`h2`,{lang:Eo(t.title),className:`text-lg leading-snug font-semibold text-[var(--c-text)]${Eo(t.title)===`ja`?` ja-phrases`:``}`,children:t.title?(0,U.jsx)(Bc,{text:t.title}):null}),(0,U.jsx)(pd,{item:t,className:`mt-3 text-sm leading-relaxed line-clamp-3 text-[var(--c-text-muted)]`})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs pt-5`,style:{color:`var(--c-text-muted)`},children:[(0,U.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 min-w-0`,children:n&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsxs)(`svg`,{className:`w-3.5 h-3.5 shrink-0 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`18`,rx:`2`,ry:`2`}),(0,U.jsx)(`line`,{x1:`16`,y1:`2`,x2:`16`,y2:`6`}),(0,U.jsx)(`line`,{x1:`8`,y1:`2`,x2:`8`,y2:`6`}),(0,U.jsx)(`line`,{x1:`3`,y1:`10`,x2:`21`,y2:`10`})]}),(0,U.jsx)(`span`,{children:Qe.format(n)})]}),(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsxs)(`svg`,{className:`w-3.5 h-3.5 shrink-0 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,U.jsx)(`polyline`,{points:`12 6 12 12 16 14`})]}),(0,U.jsx)(`span`,{children:$e.format(n)})]})]})}),(0,U.jsxs)(`div`,{className:`flex sm:hidden items-center gap-2 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,U.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),qe(t)},title:t.bookmarked?e(`items.unbookmark`):e(`items.bookmark`),"aria-label":t.bookmarked?e(`items.unbookmark`):e(`items.bookmark`),className:`w-8 h-8 rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${t.bookmarked?`bg-amber-500/15 border-amber-500/40 text-amber-500`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500 hover:border-amber-500/30`}`,children:(0,U.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:t.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,U.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Ke(t)},title:t.read?e(`items.markUnread`):e(`items.markRead`),"aria-label":t.read?e(`items.markUnread`):e(`items.markRead`),className:`w-8 h-8 rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${t.read?`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:border-[var(--c-blue3)]`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-blue1)] hover:border-[var(--c-blue3)]`}`,children:(0,U.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:t.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2.2`,children:(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})})]})]})]}),(0,U.jsxs)(`div`,{className:`hidden sm:flex items-center gap-2 pt-5 pr-5 shrink-0 self-start`,onClick:e=>e.stopPropagation(),children:[(0,U.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),qe(t)},title:t.bookmarked?e(`items.unbookmark`):e(`items.bookmark`),"aria-label":t.bookmarked?e(`items.unbookmark`):e(`items.bookmark`),className:`w-9 h-9 rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${t.bookmarked?`bg-amber-500/15 border-amber-500/40 text-amber-500`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500 hover:border-amber-500/30`}`,children:(0,U.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:t.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,U.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Ke(t)},title:t.read?e(`items.markUnread`):e(`items.markRead`),"aria-label":t.read?e(`items.markUnread`):e(`items.markRead`),className:`w-9 h-9 rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${t.read?`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:border-[var(--c-blue3)]`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-blue1)] hover:border-[var(--c-blue3)]`}`,children:(0,U.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:t.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2.2`,children:(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})})]})]})},t.id)})}),!v&&p.length>0&&(w||S)&&(S?(0,U.jsx)(`button`,{type:`button`,onClick:()=>{Pe()},className:`btn-secondary self-center`,children:e(`common.retry`)}):(0,U.jsx)(`div`,{ref:Ie,className:`flex min-h-12 items-center justify-center`,children:b&&(0,U.jsx)(Su,{size:`sm`})})),(0,U.jsx)(Vc,{item:k,isOpen:!!k,onClose:ze,onToggleBookmark:qe,onToggleRead:Ke,onNext:Ue,onPrevious:We,onItemUpdated:nt,hasNext:Ve,hasPrev:He})]});return(0,U.jsx)(Cd,{disabled:h||!u||!!k||P,onRefresh:Ze,children:rt})}function jd(e,t){let n=Math.min(e,t);return{sx:Math.round((e-n)/2),sy:Math.round((t-n)/2),size:n}}async function Md(e){let t=await createImageBitmap(e);try{let{sx:e,sy:n,size:r}=jd(t.width,t.height),i=document.createElement(`canvas`);i.width=256,i.height=256;let a=i.getContext(`2d`);if(!a)throw Error(`canvas_unavailable`);return a.fillStyle=`#ffffff`,a.fillRect(0,0,256,256),a.imageSmoothingQuality=`high`,a.drawImage(t,e,n,r,r,0,0,256,256),await new Promise((e,t)=>{i.toBlob(n=>n?e(n):t(Error(`encode_failed`)),`image/jpeg`,.88)})}finally{t.close()}}function Nd({title:e,description:t,children:n,footer:r}){return(0,U.jsxs)(`section`,{className:`card`,children:[(e||t)&&(0,U.jsxs)(`header`,{className:`px-5 pt-5 pb-1 sm:px-6`,children:[e&&(0,U.jsx)(`h3`,{className:`text-base font-semibold`,children:e}),t&&(0,U.jsx)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:t})]}),(0,U.jsx)(`div`,{className:`divide-y divide-[var(--c-border)]`,children:n}),r&&(0,U.jsx)(`footer`,{className:`flex flex-wrap items-center justify-end gap-3 border-t border-[var(--c-border)] px-5 py-4 sm:px-6`,children:r})]})}function Pd({label:e,hint:t,htmlFor:n,children:r,stacked:i=!1,inline:a=!1}){return(0,U.jsxs)(`div`,{className:`flex gap-3 px-5 py-4 sm:px-6 ${i?`flex-col`:a?`flex-row items-center justify-between gap-4 sm:gap-6`:`flex-col sm:flex-row sm:items-center sm:justify-between sm:gap-6`}`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`label`,{htmlFor:n,className:`text-sm font-medium`,children:e}),t&&(0,U.jsx)(`p`,{className:`mt-0.5 text-sm text-[var(--c-text-muted)]`,children:t})]}),r&&(0,U.jsx)(`div`,{className:i?``:`shrink-0`,children:r})]})}function Fd({children:e}){return(0,U.jsx)(`div`,{className:`px-5 py-4 sm:px-6`,children:e})}function Id({id:e,checked:t,onChange:n,label:r}){return(0,U.jsxs)(`label`,{className:`relative inline-flex cursor-pointer items-center`,children:[(0,U.jsx)(`input`,{id:e,type:`checkbox`,className:`peer sr-only`,checked:t,onChange:e=>n(e.target.checked),"aria-label":r}),(0,U.jsx)(`span`,{className:`h-6 w-11 rounded-full bg-[var(--c-border)] transition-colors peer-checked:bg-[var(--c-blue1)] peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-[var(--c-blue3)] after:absolute after:left-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:bg-white after:shadow-sm after:transition-transform after:content-[''] peer-checked:after:translate-x-5`})]})}function Ld({message:e}){return e?(0,U.jsx)(`p`,{role:`status`,className:`text-sm ${e.type===`error`?`text-danger`:`text-[var(--c-green3)]`}`,children:e.text}):null}function Rd({title:e,description:t}){return(0,U.jsxs)(`div`,{className:`mb-5`,children:[(0,U.jsx)(`h2`,{className:`text-xl font-semibold`,children:e}),t&&(0,U.jsx)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:t})]})}var zd=o(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),Bd=o((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),Vd=o((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),Hd=o(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Ud=o(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Wd=o((e=>{var t=Bd().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),Gd=o((e=>{var t=Bd().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Kd=o((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),qd=o((e=>{var t=Vd(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),Jd=o((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Yd=o((e=>{var t=Jd();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),Xd=o(((e,t)=>{var n=Yd();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),Zd=o((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Qd=o((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
|
|
96
|
+
`).map((e,t)=>(0,U.jsx)(`p`,{children:(0,U.jsx)(Bc,{text:e})},t))}):(0,U.jsx)(`p`,{className:`text-[var(--c-text-muted)] italic`,children:u(`items.noItems`)}),(0,U.jsxs)(`div`,{className:`mt-12 pt-6 border-t border-[var(--c-border)]/60 flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:o,disabled:!l,title:u(`reader.previous`),"aria-label":u(`reader.previous`),className:`w-10 h-10 rounded-xl border border-[var(--c-border)] flex items-center justify-center text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40 active:scale-95 disabled:opacity-30 disabled:cursor-not-allowed transition-all cursor-pointer`,children:(0,U.jsx)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`polyline`,{points:`15 18 9 12 15 6`})})}),(0,U.jsx)(`button`,{type:`button`,onClick:a,disabled:!c,title:u(`reader.next`),"aria-label":u(`reader.next`),className:`w-10 h-10 rounded-xl border border-[var(--c-border)] flex items-center justify-center text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40 active:scale-95 disabled:opacity-30 disabled:cursor-not-allowed transition-all cursor-pointer`,children:(0,U.jsx)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`polyline`,{points:`9 18 15 12 9 6`})})})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[M&&(!te||e.full_content_html)&&(0,U.jsx)(`button`,{type:`button`,onClick:ie,disabled:S,title:u(w?`reader.togglePreview`:`reader.toggleFullText`),"aria-label":u(w?`reader.togglePreview`:`reader.toggleFullText`),className:`w-10 h-10 rounded-xl border flex items-center justify-center transition-all active:scale-95 cursor-pointer ${w?`bg-[var(--c-blue1)]/15 border-[var(--c-blue1)]/40 text-[var(--c-blue1)]`:`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40`}`,children:S?(0,U.jsx)(`svg`,{className:`w-4 h-4 animate-spin text-[var(--c-blue1)]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,strokeDasharray:`32`,strokeDashoffset:`12`})}):(0,U.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`path`,{d:`M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z`}),(0,U.jsx)(`path`,{d:`M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z`})]})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>r(e),title:e.bookmarked?u(`reader.unbookmark`):u(`reader.bookmark`),"aria-label":e.bookmarked?u(`reader.unbookmark`):u(`reader.bookmark`),className:`w-10 h-10 rounded-xl border flex items-center justify-center transition-all active:scale-95 cursor-pointer ${e.bookmarked?`bg-amber-500/15 border-amber-500/40 text-amber-500`:`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500 hover:border-amber-500/30`}`,children:(0,U.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:e.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>i(e),title:e.read?u(`reader.markUnread`):u(`reader.markRead`),"aria-label":e.read?u(`reader.markUnread`):u(`reader.markRead`),className:`w-10 h-10 rounded-xl border flex items-center justify-center transition-all active:scale-95 cursor-pointer ${e.read?`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)]`:`border-[var(--c-border)] text-[var(--c-blue1)] hover:border-[var(--c-blue3)]`}`,children:(0,U.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:e.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2.2`,children:(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})}),(0,U.jsx)(`button`,{type:`button`,onClick:async()=>{if(M)try{await navigator.clipboard.writeText(M),v(!0),setTimeout(()=>v(!1),2e3)}catch{}},title:u(g?`reader.linkCopied`:`reader.copyLink`),"aria-label":u(`reader.copyLink`),className:`w-10 h-10 rounded-xl border border-[var(--c-border)] flex items-center justify-center text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40 transition-all active:scale-95 cursor-pointer relative`,children:g?(0,U.jsx)(`svg`,{className:`w-4 h-4 text-emerald-500`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}):(0,U.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`}),(0,U.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})}),M&&(0,U.jsx)(`a`,{href:M,target:`_blank`,rel:`noreferrer noopener`,title:u(`reader.openOriginal`),"aria-label":u(`reader.openOriginal`),className:`w-10 h-10 rounded-xl border border-[var(--c-border)] flex items-center justify-center text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40 transition-all active:scale-95`,children:(0,U.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`}),(0,U.jsx)(`polyline`,{points:`15 3 21 3 21 9`}),(0,U.jsx)(`line`,{x1:`10`,y1:`14`,x2:`21`,y2:`3`})]})})]})]})]})})]})]})]}),document.body)}var Hc=`feedkeeper:extensions-changed`,Uc=[`login`,`menu`,`page`],Wc=/^[a-z0-9][a-z0-9-]{0,63}$/,Gc=(e,t)=>typeof e==`string`&&e.trim().length>0&&e.length<=t,Kc=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function qc(e){return Kc(e)?typeof e.id==`string`&&Wc.test(e.id)&&Gc(e.label,80)&&Gc(e.description,300)&&Gc(e.group,60)&&(e.shortLabel===void 0||Gc(e.shortLabel,40))&&(e.icon===void 0||Array.isArray(e.icon)&&e.icon.length<=8&&e.icon.every(e=>typeof e==`string`&&e.length<=400))&&(e.admin===void 0||typeof e.admin==`boolean`)&&typeof e.mount==`function`:!1}function Jc(e,t,n){let r=Kc(e)&&Kc(e.settings)?e.settings:{},i=new Set(Array.isArray(r.hidden)?r.hidden.filter(e=>typeof e==`string`&&t.includes(e)):[]),a=new Set(t),o=[];for(let e of Array.isArray(r.sections)?r.sections:[])qc(e)&&!a.has(e.id)&&(a.add(e.id),(!e.admin||n)&&o.push(e));return{hidden:i,sections:o}}function Yc(e){let t=[];for(let n of e){let e=n.group??``,r=t.find(t=>t.group===e);r?r.sections.push(n):t.push({group:e,sections:[n]})}return t}function Xc(e,t){if(typeof e==`string`)return e;if(!Kc(e))return null;let n=t.toLowerCase();for(let t of[n,n.split(`-`)[0],`en`]){let n=Object.entries(e).find(([e])=>e.toLowerCase()===t)?.[1];if(typeof n==`string`)return n}return Object.values(e).find(e=>typeof e==`string`)??null}function Zc(e){return/[\u0000-\u001f\\]/.test(e)||e.length>500?!1:/^\/(?![/\\])/.test(e)||/^https?:\/\/[^\s/]+/i.test(e)}function Qc(e,t,n){let r=Kc(e)&&Array.isArray(e.footerLinks)?e.footerLinks:[],i=[];for(let e of r.slice(0,8)){if(!Kc(e))continue;let r=Xc(e.label,t),a=Xc(e.href,t);if(!r||!Gc(r,60)||!a||!Zc(a)||n&&Array.isArray(e.placements)&&!e.placements.some(e=>e===n&&Uc.includes(e)))continue;let o=typeof e.icon==`string`&&Zc(e.icon)?e.icon:null;i.push({label:r,href:a,newTab:e.newTab===!0||/^https?:/i.test(a),icon:o})}return i}function $c(e){let t=Kc(e)?e.loginForm:void 0;return Kc(t)&&typeof t.mount==`function`?t:null}function el(e){let t=Kc(e)?e.passwordCard:void 0;return!Kc(t)||typeof t.mount!=`function`?null:{mount:t.mount,...typeof t.applies==`function`?{applies:t.applies}:{}}}function tl(e){let t=Kc(e)?e.onboarding:void 0;return Kc(t)&&typeof t.mount==`function`?t:null}function nl(e){if(typeof e!=`string`||e.length>500)return null;try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&!t.username&&!t.password?t.toString():null}catch{return null}}function rl(e,t,n){let r=Kc(e)&&Kc(e.starterPacks)?e.starterPacks:{},i=Array.isArray(r.packs)?r.packs:[],a=new Map;if(r.replace!==!0)for(let e of t)a.set(e.id,e);for(let e of i.slice(0,12))Kc(e)&&typeof e.id==`string`&&Wc.test(e.id)&&Array.isArray(e.feeds)&&a.set(e.id,e);let o=[];for(let e of a.values()){let t=Xc(e.title,n);if(!t||!Gc(t,60))continue;let r=[];for(let t of e.feeds.slice(0,20)){if(!Kc(t)||!Gc(t.title,80))continue;let e=nl(t.url);if(!e)continue;let i=Xc(t.description,n);r.push({title:t.title,url:e,lang:typeof t.lang==`string`?t.lang.toLowerCase().split(`-`)[0]:``,description:i&&Gc(i,200)?i:``})}r.length>0&&o.push({id:e.id,title:t,description:Xc(e.description,n)??``,feeds:r})}return o}function il(e){let t=Kc(e)?e.articlesNotice:void 0;return!Kc(t)||typeof t.mount!=`function`?null:{mount:t.mount,...typeof t.applies==`function`?{applies:t.applies}:{}}}function al(e,t){let n=Kc(e)&&Kc(e.meta)?e.meta:{},r=Xc(n.title,t)?.trim()??null,i=Xc(n.description,t)?.trim()??null;return{title:r&&Gc(r,80)?r:null,description:i&&Gc(i,300)?i:null}}function ol(e,t){if(!Kc(e)||!Array.isArray(e.pages))return[];let n=[],r=new Set;for(let i of e.pages){if(!Kc(i)||typeof i.id!=`string`||!Wc.test(i.id)||r.has(i.id))continue;let e=Xc(i.label,t);if(Gc(e,40)&&typeof i.mount==`function`&&!(!Array.isArray(i.icon)||!i.icon.length||i.icon.length>8||!i.icon.every(e=>Gc(e,400)))&&(n.push({id:i.id,label:e,icon:i.icon,mount:i.mount}),r.add(i.id),n.length===3))break}return n}var sl=0;function cl(e){let t=()=>{sl++,e()};return window.addEventListener(Hc,t),()=>window.removeEventListener(Hc,t)}function ll(){return(0,_.useSyncExternalStore)(cl,()=>sl),window.feedkeeperExtensions}function ul(){let{pageId:e}=vr(),{user:t}=lo(),{i18n:n}=R(),r=n.resolvedLanguage||`en`,i=ol(ll(),r).find(({id:t})=>t===e);return t&&i?(0,U.jsx)(dl,{page:i,userId:t.id,language:r},t.id):null}function dl({page:{mount:e},userId:t,language:n}){let r=(0,_.useRef)(null),[i,a]=(0,_.useState)(null);(0,_.useEffect)(()=>{if(!r.current)return;let i=r.current,o=!0,s;try{s=e(i,{userId:t,language:n,appendText:fl,openArticle:(e,t)=>{o&&a({item:e,onChange:t})}})}catch(e){console.error(`Could not mount extension page`,e),i.replaceChildren()}return()=>{o=!1,typeof s==`function`&&s(),i.replaceChildren(),a(null)}},[e,t,n]);function o(e){i&&i.item.id===e.id&&(i.onChange(e),a(t=>t?.item.id===e.id?{...t,item:{...t.item,...e}}:t))}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{ref:r}),i&&(0,U.jsx)(Vc,{item:i.item,isOpen:!0,onClose:()=>a(null),onItemUpdated:e=>o({...i.item,...e}),onToggleRead:e=>{ya(`read`,e.id,!e.read).then(()=>{no(),o({...e,read:!e.read})}).catch(console.error)},onToggleBookmark:e=>{ya(`bookmark`,e.id,!e.bookmarked).then(()=>o({...e,bookmarked:!e.bookmarked})).catch(console.error)}})]})}function fl(e,t){Eo(t)&&(e.lang=`ja`);for(let n of Wo(t))if(n.kind===`wbr`)e.append(document.createElement(`wbr`));else if(n.kind===`nb`){let t=document.createElement(`span`);t.className=`nb`,t.textContent=n.value,e.append(t)}else e.append(n.value)}var pl=`M435.6,124.8l0,-73.2l-435.6,0l-0,816l92.4,-0l0,-381.6l325.2,0l-0,-74.4l-325.2,0l0,-286.8l343.2,0zM1065.6,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM1722,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM2396.4,830.4l0,-830.4l-90,0l0,278.4c-18,-8.4,-97.2,-39.6,-188.4,-39.6c-164.4,0,-262.8,106.8,-262.8,306c0,242.4,86.4,337.2,279.6,337.2c121.2,-0,216,-32.4,261.6,-51.6zm-90,-48c-21.6,12,-84,33.6,-171.6,33.6c-129.6,0,-188.4,-78,-188.4,-271.2c0,-159.6,63.6,-238.8,189.6,-238.8c72,0,146.4,28.8,170.4,38.4l0,438zM3187.2,867.6l-386.4,-427.2l355.2,-388.8l-120,0l-340.8,388.8l367.2,427.2l124.8,-0zm-494.4,-0l-0,-816l-92.4,0l0,816l92.4,-0zM3776.4,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM4432.8,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM5133.6,544.8c0,-210,-92.4,-306,-282,-306c-118.8,0,-231.6,36,-260.4,50.4l-0,832.8l90,0l0,-280.8c16.8,13.2,99.6,40.8,187.2,40.8c165.6,0,265.2,-92.4,265.2,-337.2zm-93.6,0c0,194.4,-57.6,271.2,-188.4,271.2c-69.6,0,-141.6,-25.2,-170.4,-37.2l0,-439.2c18,-8.4,81.6,-33.6,171.6,-33.6c120,0,187.2,68.4,187.2,238.8zM5792.4,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM6256.8,313.2l0,-68.4c-9.6,-1.2,-50.4,-6,-66,-6c-106.8,0,-223.2,39.6,-240,48l-0,580.8l90,-0l0,-531.6c16.8,-6,90,-28.8,158.4,-28.8c14.4,0,45.6,3.6,57.6,6z`;function ml(){return(0,U.jsx)(`svg`,{className:`wordmark`,viewBox:`0 0 6257 1122`,role:`img`,"aria-label":`FeedKeeper`,children:(0,U.jsx)(`path`,{d:pl})})}function hl({size:e=28}){return(0,U.jsxs)(`span`,{className:`brand-lockup`,style:{"--m":`${e}px`},children:[(0,U.jsx)(`img`,{src:`/logo.svg`,alt:``}),(0,U.jsx)(ml,{})]})}var gl=({isActive:e})=>`relative z-10 flex h-full items-center gap-2 rounded-lg px-3 text-sm font-medium transition-colors focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${e?`text-[var(--c-text)]`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`;function _l({onItemsClick:e,pages:t}){let{t:n,i18n:r}=R(),i=dr(),a=(0,_.useRef)(null),[o,s]=(0,_.useState)(null),c=t.map(({id:e,label:t})=>e+t).join(`|`);return(0,_.useLayoutEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{let t=e.querySelector(`a[aria-current="page"]`);s(t?{left:t.offsetLeft,width:t.offsetWidth}:null)};t();let n=new ResizeObserver(t);return e.querySelectorAll(`a`).forEach(e=>n.observe(e)),()=>n.disconnect()},[i.pathname,r.resolvedLanguage,c]),(0,U.jsxs)(`nav`,{ref:a,className:`relative hidden h-9 items-center rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] p-0.5 md:flex`,children:[o&&(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0.5 left-0 rounded-lg border border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] shadow-sm transition-[transform,width] duration-300 ease-[cubic-bezier(0.25,1,0.5,1)] motion-reduce:transition-none`,style:{width:o.width,transform:`translateX(${o.left}px)`}}),t.map(({id:e,label:t,icon:n})=>(0,U.jsxs)(Mi,{to:`/extensions/${e}`,className:gl,children:[(0,U.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:n.map(e=>(0,U.jsx)(`path`,{d:e},e))}),t]},e)),(0,U.jsxs)(Mi,{to:`/items`,onClick:e,className:gl,children:[(0,U.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h12`})}),n(`nav.items`)]}),(0,U.jsxs)(Mi,{to:`/feeds`,className:gl,children:[(0,U.jsxs)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`path`,{d:`M4 11a9 9 0 0 1 9 9`}),(0,U.jsx)(`path`,{d:`M4 4a16 16 0 0 1 16 16`}),(0,U.jsx)(`circle`,{cx:`5`,cy:`19`,r:`1`})]}),n(`nav.feeds`)]})]})}var vl=`fk_theme`,yl=new Set,bl=(()=>{try{let e=localStorage.getItem(vl);return e===`light`||e===`dark`?e:`system`}catch{return`system`}})();function xl(e){return yl.add(e),()=>yl.delete(e)}function Sl(){return bl}function Cl(e){bl=e,e===`system`?document.documentElement.removeAttribute(`data-theme`):document.documentElement.setAttribute(`data-theme`,e);try{e===`system`?localStorage.removeItem(vl):localStorage.setItem(vl,e)}catch{}yl.forEach(e=>e())}function wl({standalone:e,hasPrompt:t,userAgent:n,maxTouchPoints:r}){if(e)return`installed`;if(t)return`prompt`;if(/iPhone|iPad|iPod/.test(n)||/Macintosh/.test(n)&&r>1)return`ios`;let i=/Safari\//.test(n)&&!/Chrome|Chromium|CriOS|FxiOS|Edg|OPR|Firefox/.test(n);return/Macintosh/.test(n)&&i?`mac-safari`:`unsupported`}var Tl=null,El=!1,Dl=new Set,Ol=()=>Dl.forEach(e=>e());function kl(){window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),Tl=e,Ol()}),window.addEventListener(`appinstalled`,()=>{Tl=null,El=!0,Ol()})}function Al(e){Dl.add(e);let t=window.matchMedia(`(display-mode: standalone)`);return t.addEventListener(`change`,e),()=>{Dl.delete(e),t.removeEventListener(`change`,e)}}function jl(){return wl({standalone:El||window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0,hasPrompt:Tl!==null,userAgent:navigator.userAgent,maxTouchPoints:navigator.maxTouchPoints??0})}async function Ml(){let e=Tl;if(!e)return;Tl=null,await e.prompt();let{outcome:t}=await e.userChoice;t===`accepted`&&(El=!0),Ol()}function Nl(e,t){let n=e.trim().split(/\s+/).filter(Boolean);return n.length===0?t.charAt(0).toUpperCase()||`?`:(n[0].charAt(0)+(n.length>1?n[n.length-1].charAt(0):``)).toUpperCase()}function Pl({user:e,className:t=``}){let n=Ca(e),[r,i]=(0,_.useState)(null);return(0,U.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full border border-[var(--c-border)] bg-[var(--c-mobile-nav-active)] font-semibold tracking-wide text-[var(--c-text)] ${t}`,children:n&&r!==n?(0,U.jsx)(`img`,{src:n,alt:``,className:`h-full w-full object-cover`,onError:()=>i(n)}):(0,U.jsx)(`span`,{"aria-hidden":`true`,children:Nl(e.display_name,e.email)})})}var Fl={login:`mt-4 justify-center text-xs`,menu:`border-t border-[var(--c-border)] px-3 py-2.5 text-xs`,page:`mt-10 border-t border-[var(--c-border)] pt-4 text-xs`};function Il({placement:e}){let{t,i18n:n}=R(),r=Qc(ll(),n.resolvedLanguage||`en`,e);return r.length===0?null:(0,U.jsx)(`nav`,{"aria-label":t(`nav.footerLinks`),className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[var(--c-text-muted)] ${Fl[e]}`,children:r.map((e,t)=>(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-3`,children:[t>0&&(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`opacity-50`,children:`•`}),(0,U.jsxs)(`a`,{href:e.href,...e.newTab?{target:`_blank`,rel:`noopener noreferrer`}:{},className:`transition-colors hover:text-[var(--c-text)] hover:underline`,children:[e.icon&&(0,U.jsx)(`img`,{src:e.icon,alt:``,width:14,height:14,className:`mr-1.5 inline-block align-[-2px]`}),e.label]})]},`${e.href}-${t}`))})}var Ll={light:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,U.jsx)(`path`,{d:`M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41`})]}),dark:(0,U.jsx)(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`}),system:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,U.jsx)(`path`,{d:`M12 3a9 9 0 0 1 0 18Z`,fill:`currentColor`,stroke:`none`})]})},Rl=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm font-medium text-[var(--c-text)] transition-colors hover:bg-[var(--c-surface-hover)] focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] cursor-pointer`;function zl(){let{t:e}=R(),{user:t,logout:n}=lo(),r=dr(),i=(0,_.useSyncExternalStore)(xl,Sl),a=(0,_.useSyncExternalStore)(Al,jl),[o,s]=(0,_.useState)(!1),c=(0,_.useRef)(null),l=(0,_.useRef)(null),u=(0,_.useId)();if((0,_.useEffect)(()=>s(!1),[r.pathname]),(0,_.useEffect)(()=>{if(!o)return;let e=e=>{c.current?.contains(e.target)||s(!1)},t=e=>{e.key===`Escape`&&(s(!1),l.current?.focus())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[o]),!t)return null;let d={light:e(`settings.themeLight`),dark:e(`settings.themeDark`),system:e(`settings.themeSystem`)};return(0,U.jsxs)(`div`,{ref:c,className:`relative`,children:[(0,U.jsx)(`button`,{ref:l,type:`button`,onClick:()=>s(e=>!e),"aria-expanded":o,"aria-controls":u,"aria-label":e(`nav.account`),title:t.display_name||t.email,className:`flex rounded-full transition-shadow cursor-pointer focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--c-blue3)] ${o||r.pathname.startsWith(`/settings`)?`ring-2 ring-[var(--c-blue3)] ring-offset-2 ring-offset-[var(--c-surface)]`:`hover:ring-2 hover:ring-[var(--c-border)] hover:ring-offset-2 hover:ring-offset-[var(--c-surface)]`}`,children:(0,U.jsx)(Pl,{user:t,className:`h-9 w-9 text-xs`})}),o&&(0,U.jsxs)(`div`,{id:u,className:`card animate-fade-in absolute right-0 top-full z-50 mt-2 w-72 max-w-[calc(100vw-2rem)] p-1.5 shadow-xl`,style:{boxShadow:`0 16px 40px -12px rgba(0, 0, 0, 0.35)`},children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3 px-3 pt-2 pb-3`,children:[(0,U.jsx)(Pl,{user:t,className:`h-10 w-10 text-sm`}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`truncate text-sm font-semibold text-[var(--c-text)]`,children:t.display_name||t.email}),t.display_name&&(0,U.jsx)(`p`,{className:`truncate text-xs text-[var(--c-text-muted)]`,children:t.email})]})]}),(0,U.jsxs)(`div`,{className:`border-t border-[var(--c-border)] px-3 py-3`,children:[(0,U.jsx)(`p`,{className:`mb-2 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:e(`settings.theme`)}),(0,U.jsx)(`div`,{className:`grid grid-cols-3 gap-1 rounded-xl border border-[var(--c-border)] p-0.5`,role:`group`,"aria-label":e(`settings.theme`),children:Object.keys(Ll).map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>Cl(e),"aria-pressed":i===e,className:`flex h-8 items-center justify-center gap-1.5 rounded-lg text-xs font-medium transition-colors cursor-pointer focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${i===e?`border border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] text-[var(--c-text)] shadow-sm`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:[(0,U.jsx)(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:Ll[e]}),d[e]]},e))})]}),(0,U.jsxs)(`div`,{className:`flex flex-col border-t border-[var(--c-border)] pt-1.5`,children:[(0,U.jsxs)(Mi,{to:`/settings`,className:`${Rl} max-md:hidden`,children:[(0,U.jsxs)(`svg`,{className:`h-4 w-4 text-[var(--c-text-muted)]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,U.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z`})]}),e(`nav.settings`)]}),a===`prompt`&&(0,U.jsxs)(`button`,{type:`button`,className:Rl,onClick:()=>{s(!1),Ml()},children:[(0,U.jsxs)(`svg`,{className:`h-4 w-4 text-[var(--c-text-muted)]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`path`,{d:`M12 3v12M7 10l5 5 5-5`}),(0,U.jsx)(`path`,{d:`M5 21h14`})]}),e(`settings.installApp`)]}),(0,U.jsxs)(`button`,{type:`button`,className:`${Rl} text-[var(--c-danger)]! hover:bg-[var(--c-danger-bg)]!`,onClick:()=>{s(!1),n()},children:[(0,U.jsxs)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,U.jsx)(`polyline`,{points:`16 17 21 12 16 7`}),(0,U.jsx)(`line`,{x1:`21`,y1:`12`,x2:`9`,y2:`12`})]}),e(`nav.logout`)]})]}),(0,U.jsx)(Il,{placement:`menu`})]})]})}function Bl(e){return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}}function Vl(){return(0,_.useSyncExternalStore)(Bl,()=>navigator.onLine,()=>!0)}function Hl(){let{t:e}=R(),t=(0,_.useSyncExternalStore)(na,ta,()=>0);return Vl()?null:(0,U.jsxs)(`div`,{role:`status`,className:`border-b px-4 py-2 text-center text-sm text-[var(--c-text-muted)]`,style:{borderColor:`var(--c-border)`,backgroundColor:`var(--c-surface)`},children:[e(`common.offlineBanner`),t>0&&` ${e(`common.offlinePending`,{count:t})}`]})}function Ul(){let{t:e}=R(),{refresh:t}=lo();return(0,U.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col items-center justify-center gap-4 bg-[var(--c-bg)] px-6 text-center`,children:[(0,U.jsx)(`img`,{src:`/logo.svg`,alt:``,className:`h-12 w-12`}),(0,U.jsx)(`h1`,{className:`text-xl font-semibold`,style:{fontFamily:`Manrope, sans-serif`},children:e(`common.offlineTitle`)}),(0,U.jsx)(`p`,{className:`max-w-sm text-sm text-[var(--c-text-muted)]`,children:e(`common.offlineText`)}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>void t(),className:`btn-primary`,children:e(`common.retry`)})]})}var Wl=[],Gl=1,Kl=new Set,ql=()=>Kl.forEach(e=>e());function Jl(e){return Kl.add(e),()=>Kl.delete(e)}function Yl(){return Wl}function Xl(e){Wl=Wl.filter(t=>t.id!==e),ql()}function Zl(e,t){let n=Gl++;Wl=[...Wl.slice(-2),{id:n,type:e,message:t}],ql(),window.setTimeout(()=>Xl(n),e===`error`?7e3:4e3)}var K={success:e=>Zl(`success`,e),error:e=>Zl(`error`,e),info:e=>Zl(`info`,e)};function Ql(){let{t:e}=R(),t=(0,_.useSyncExternalStore)(Jl,Yl);return(0,U.jsx)(`div`,{"aria-live":`polite`,className:`pointer-events-none fixed inset-x-0 bottom-[calc(6.5rem+env(safe-area-inset-bottom,0px))] z-[60] flex flex-col items-center gap-2 px-4 md:bottom-6`,children:t.map(t=>(0,U.jsxs)(`div`,{role:t.type===`error`?`alert`:`status`,className:`card animate-fade-in pointer-events-auto flex w-full max-w-md items-start gap-3 px-4 py-3 text-sm`,style:{boxShadow:`0 16px 40px -12px rgba(0, 0, 0, 0.35)`},children:[(0,U.jsx)(`span`,{className:`mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-white ${t.type===`error`?`bg-[var(--c-danger)]`:t.type===`info`?`bg-[var(--c-text-muted)]`:`bg-[var(--c-green3)]`}`,"aria-hidden":`true`,children:(0,U.jsx)(`svg`,{className:`h-3 w-3`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`,children:t.type===`error`?(0,U.jsx)(`path`,{d:`M12 7v6M12 17h.01`}):t.type===`info`?(0,U.jsx)(`path`,{d:`M12 7h.01M12 11v6`}):(0,U.jsx)(`path`,{d:`m5 12 5 5 9-10`})})}),(0,U.jsx)(`p`,{className:`min-w-0 flex-1 text-[var(--c-text)]`,children:t.message}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>Xl(t.id),"aria-label":e(`common.close`),className:`-mr-1 shrink-0 rounded p-0.5 text-[var(--c-text-muted)] hover:text-[var(--c-text)] cursor-pointer`,children:(0,U.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]},t.id))})}function $l(){let{t:e,i18n:t}=R(),n=ol(ll(),t.resolvedLanguage||`en`),r=dr();(0,_.useEffect)(()=>{let e=()=>void za(),t=()=>document.visibilityState===`visible`&&e();return e(),window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,t)}},[]),(0,_.useEffect)(()=>{let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>void eo(),800)},n=()=>document.visibilityState===`visible`&&t();t();let r=window.setInterval(t,12e4);window.addEventListener(`online`,t),document.addEventListener(`visibilitychange`,n);let i=ro(t);return()=>{window.clearTimeout(e),window.clearInterval(r),window.removeEventListener(`online`,t),document.removeEventListener(`visibilitychange`,n),i()}},[]),(0,_.useEffect)(()=>{r.pathname!==`/items`&&(window.scrollTo({top:0,left:0,behavior:`instant`}),requestAnimationFrame(()=>{window.scrollTo({top:0,left:0,behavior:`instant`})}))},[r.pathname]);let i=()=>{r.pathname===`/items`&&(Ka(),window.scrollTo({top:0,left:0,behavior:`smooth`}))},a=n.findIndex(({id:e})=>r.pathname===`/extensions/${e}`),o=a>=0?a:n.length+(r.pathname.startsWith(`/feeds`)?1:r.pathname.startsWith(`/settings`)?2:0);return(0,U.jsxs)(`div`,{className:`min-h-screen flex flex-col`,children:[(0,U.jsx)(`header`,{"data-app-header":!0,className:`sticky top-0 z-30 backdrop-blur-md border-b`,style:{borderColor:`var(--c-border)`,backgroundColor:`color-mix(in srgb, var(--c-surface) 85%, transparent)`,paddingTop:`env(safe-area-inset-top, 0px)`},children:(0,U.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-3 flex items-center justify-between gap-4`,children:[(0,U.jsx)(Mi,{to:`/items`,onClick:i,className:`flex items-center gap-2.5 shrink-0 hover:opacity-85 transition-opacity`,children:(0,U.jsx)(hl,{size:28})}),(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(_l,{onItemsClick:i,pages:n}),(0,U.jsx)(zl,{})]})]})}),(0,U.jsx)(Hl,{}),(0,U.jsx)(`main`,{className:`flex-1 max-w-5xl w-full mx-auto px-4 pt-4 pb-24 md:py-6`,children:(0,U.jsx)(`div`,{className:`animate-page-fade`,children:(0,U.jsx)(Vr,{})},r.pathname)}),(0,U.jsx)(Ql,{}),(0,U.jsx)(`nav`,{className:`mobile-bottom-nav md:hidden fixed left-3 right-3 max-w-sm mx-auto z-40 pointer-events-auto no-drag select-none`,"aria-label":e(`nav.menu`),children:(0,U.jsxs)(`div`,{className:`relative flex items-center justify-between p-1.5 rounded-full border backdrop-blur-2xl backdrop-saturate-180 transition-all duration-300 no-drag select-none`,style:{backgroundColor:`color-mix(in srgb, var(--c-surface) 80%, transparent)`,borderColor:`var(--c-border)`,borderWidth:`1px`,boxShadow:`0 2px 12px -4px rgba(0, 0, 0, 0.3)`},onContextMenu:e=>e.preventDefault(),children:[(0,U.jsx)(`div`,{"aria-hidden":`true`,className:`absolute top-1.5 bottom-1.5 left-1.5 rounded-full bg-[var(--c-mobile-nav-active)] border border-[var(--c-mobile-nav-active-border)] shadow-sm transition-transform duration-300 ease-[cubic-bezier(0.25,1,0.5,1)] pointer-events-none no-drag`,style:{width:`calc((100% - 0.75rem) / ${3+n.length})`,transform:`translateX(calc(${o} * 100%))`}}),n.map(({id:e,label:t,icon:n})=>(0,U.jsx)(Mi,{to:`/extensions/${e}`,draggable:!1,className:`relative z-10 flex-1 min-w-0 no-drag select-none`,children:({isActive:e})=>(0,U.jsxs)(`span`,{className:`h-[54px] w-full rounded-full flex flex-col items-center justify-center gap-0.5 ${e?`text-[var(--c-text)] font-semibold`:`text-[var(--c-text-muted)] font-medium`}`,children:[(0,U.jsx)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:n.map(e=>(0,U.jsx)(`path`,{d:e},e))}),(0,U.jsx)(`span`,{className:`text-[11px] leading-tight tracking-tight text-center`,children:t})]})},e)),(0,U.jsx)(Mi,{to:`/items`,onClick:i,draggable:!1,onDragStart:e=>e.preventDefault(),onContextMenu:e=>e.preventDefault(),className:`relative z-10 flex-1 min-w-0 no-drag select-none`,children:({isActive:t})=>(0,U.jsxs)(`div`,{className:`h-[54px] w-full rounded-full flex flex-col items-center justify-center gap-0.5 transition-colors duration-200 cursor-pointer no-drag select-none ${t?`text-[var(--c-text)] font-semibold`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)] font-medium`}`,children:[(0,U.jsx)(`svg`,{className:`w-5 h-5 transition-transform duration-200 pointer-events-none ${t?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h12`})}),(0,U.jsx)(`span`,{className:`text-[11px] leading-tight tracking-tight pointer-events-none select-none`,children:e(`nav.items`)})]})}),(0,U.jsx)(Mi,{to:`/feeds`,draggable:!1,onDragStart:e=>e.preventDefault(),onContextMenu:e=>e.preventDefault(),className:`relative z-10 flex-1 min-w-0 no-drag select-none`,children:({isActive:t})=>(0,U.jsxs)(`div`,{className:`h-[54px] w-full rounded-full flex flex-col items-center justify-center gap-0.5 transition-colors duration-200 cursor-pointer no-drag select-none ${t?`text-[var(--c-text)] font-semibold`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)] font-medium`}`,children:[(0,U.jsxs)(`svg`,{className:`w-5 h-5 transition-transform duration-200 pointer-events-none ${t?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`path`,{d:`M4 11a9 9 0 0 1 9 9`}),(0,U.jsx)(`path`,{d:`M4 4a16 16 0 0 1 16 16`}),(0,U.jsx)(`circle`,{cx:`5`,cy:`19`,r:`1`})]}),(0,U.jsx)(`span`,{className:`text-[11px] leading-tight tracking-tight pointer-events-none select-none`,children:e(`nav.feeds`)})]})}),(0,U.jsx)(Mi,{to:`/settings`,draggable:!1,onDragStart:e=>e.preventDefault(),onContextMenu:e=>e.preventDefault(),className:`relative z-10 flex-1 min-w-0 no-drag select-none`,children:({isActive:t})=>(0,U.jsxs)(`div`,{className:`h-[54px] w-full rounded-full flex flex-col items-center justify-center gap-0.5 transition-colors duration-200 cursor-pointer no-drag select-none ${t?`text-[var(--c-text)] font-semibold`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)] font-medium`}`,children:[(0,U.jsxs)(`svg`,{className:`w-5 h-5 transition-transform duration-200 pointer-events-none ${t?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,U.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z`})]}),(0,U.jsx)(`span`,{className:`text-[11px] leading-tight tracking-tight pointer-events-none select-none`,children:e(`nav.settings`)})]})})]})})]})}function eu(){let{t:e}=R(),{refresh:t}=lo(),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(!1);async function f(r){r.preventDefault(),d(!0),l(null);try{await H.onboard({email:n,password:o,displayName:i}),await t()}catch{l(e(`common.error`))}finally{d(!1)}}return(0,U.jsx)(`div`,{className:`min-h-screen flex items-center justify-center px-4`,children:(0,U.jsxs)(`div`,{className:`card p-8 w-full max-w-md`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col items-center mb-6 text-center`,children:[(0,U.jsx)(`h1`,{className:`mb-3`,children:(0,U.jsx)(hl,{size:44})}),(0,U.jsx)(`p`,{className:`text-sm mt-1`,style:{color:`var(--c-text-muted)`},children:e(`onboarding.subtitle`)})]}),(0,U.jsxs)(`form`,{onSubmit:f,className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{className:`text-sm font-medium block mb-1`,children:e(`onboarding.emailLabel`)}),(0,U.jsx)(`input`,{type:`email`,required:!0,className:`input`,value:n,onChange:e=>r(e.target.value)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{className:`text-sm font-medium block mb-1`,children:e(`onboarding.displayNameLabel`)}),(0,U.jsx)(`input`,{type:`text`,required:!0,className:`input`,value:i,onChange:e=>a(e.target.value)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{className:`text-sm font-medium block mb-1`,children:e(`onboarding.passwordLabel`)}),(0,U.jsx)(`input`,{type:`password`,required:!0,minLength:10,className:`input`,value:o,onChange:e=>s(e.target.value)}),(0,U.jsx)(`p`,{className:`text-xs mt-1`,style:{color:`var(--c-text-muted)`},children:e(`onboarding.passwordHint`)})]}),c&&(0,U.jsx)(`p`,{className:`text-sm text-danger`,children:c}),(0,U.jsx)(`button`,{type:`submit`,disabled:u,className:`btn-primary`,children:e(`onboarding.submit`)})]}),(0,U.jsxs)(`div`,{className:`mt-6 pt-4 border-t text-sm`,style:{borderColor:`var(--c-border)`},children:[(0,U.jsx)(`p`,{className:`font-medium`,children:e(`onboarding.orUseCli`)}),(0,U.jsx)(`p`,{style:{color:`var(--c-text-muted)`},children:e(`onboarding.cliHint`)})]})]})})}function tu(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function nu(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function q(){return ru.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var ru={stubThis:e=>e};function iu(e){let{id:t}=e;return{...e,id:nu(t),transports:e.transports,type:e.type}}function au(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var J=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function ou({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new J({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new J({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new J({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new J({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new J({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new J({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new J({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new J({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!au(t))return new J({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new J({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new J({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new J({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var su=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},cu=[`cross-platform`,`platform`];function lu(e){if(e&&!(cu.indexOf(e)<0))return e}async function uu(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!q())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:nu(t.challenge),user:{...t.user,id:nu(t.user.id)},excludeCredentials:t.excludeCredentials?.map(iu)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=su.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw ou({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){du(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=tu(e))}catch(e){du(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=tu(c.getAuthenticatorData())}catch(e){du(`getAuthenticatorData()`,e)}return{id:o,rawId:tu(s),response:{attestationObject:tu(c.attestationObject),clientDataJSON:tu(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:lu(a.authenticatorAttachment)}}function du(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function fu(){if(!q())return pu.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?pu.stubThis(new Promise(e=>e(!1))):pu.stubThis(e.isConditionalMediationAvailable())}var pu={stubThis:e=>e};function mu({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new J({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new J({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!au(t))return new J({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new J({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new J({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function hu(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!q())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(iu));let a={...t,challenge:nu(t.challenge),allowCredentials:i},o={};if(n){if(!await fu())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=su.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw mu({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=tu(u.userHandle)),{id:c,rawId:tu(l),response:{authenticatorData:tu(u.authenticatorData),clientDataJSON:tu(u.clientDataJSON),signature:tu(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:lu(s.authenticatorAttachment)}}async function gu(e,t,n=`POST`,r){let i=await fetch(`/api/auth/security${e}`,{method:n,signal:r,credentials:`same-origin`,headers:{"Content-Type":`application/json`},...t===void 0?{}:{body:JSON.stringify(t)}}),a=i.status===204?void 0:await i.json();if(!i.ok)throw new va(i.status,a.error,a);return a}async function _u(){let e=await gu(`/reauth/passkey/options`,{}),t=await hu({optionsJSON:e.publicKey});return(await gu(`/reauth/passkey/verify`,{challengeId:e.challengeId,credential:t})).reauthToken}async function vu(e,t){let n=await gu(`/passkeys/register/options`,{reauthToken:e}),r=await uu({optionsJSON:n.publicKey});await gu(`/passkeys/register/verify`,{challengeId:n.challengeId,credential:r,name:t})}function yu(e){let t,n;function r(){t?.abort(),t=void 0,clearTimeout(n)}async function i(a=!0){if(t&&a)return;r();let o=new AbortController,{signal:s}=o;t=o;let c=!1;try{if(a){let t=await window.PublicKeyCredential?.isConditionalMediationAvailable?.().catch(()=>!1)??!1;if(s.aborted||(e.onAutofill(t),!t))return}let t=await gu(`/passkeys/options`,{},`POST`,s);if(s.aborted)return;a&&(n=setTimeout(()=>{r(),i()},24e4));let o=await navigator.credentials.get({signal:s,...a?{mediation:`conditional`}:{},publicKey:{...t.publicKey,extensions:t.publicKey.extensions,challenge:nu(t.publicKey.challenge),allowCredentials:a?[]:t.publicKey.allowCredentials?.map(e=>({type:`public-key`,id:nu(e.id),transports:e.transports}))}});if(s.aborted||!o)return;clearTimeout(n),c=!0,e.onSelect();let l=o.response,u={id:o.id,rawId:tu(o.rawId),type:o.type,clientExtensionResults:o.getClientExtensionResults(),response:{clientDataJSON:tu(l.clientDataJSON),authenticatorData:tu(l.authenticatorData),signature:tu(l.signature),userHandle:l.userHandle?tu(l.userHandle):null}};await gu(`/passkeys/verify`,{challengeId:t.challengeId,credential:u},`POST`,s),s.aborted||await e.onSuccess()}catch(t){s.aborted||(c||!a?e.onError(t):t instanceof Error&&t.name===`NotAllowedError`||e.onAutofill(!1))}finally{t===o&&(clearTimeout(n),t=void 0)}}return{start:i,stop:r}}function bu({name:e,mount:t}){let n=(0,_.useRef)(null),r=R().i18n.resolvedLanguage;return(0,_.useEffect)(()=>{let r=n.current;if(!r)return;let i;try{i=t(r)}catch(t){console.error(`[extensions] "${e}" failed to open`,t)}return()=>{try{typeof i==`function`&&i()}catch(t){console.error(`[extensions] "${e}" failed to close`,t)}r.replaceChildren()}},[e,r]),(0,U.jsx)(`div`,{ref:n,className:`min-w-0`})}function xu(){let{t:e}=R(),{refresh:t}=lo(),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(),f=(0,_.useRef)(void 0),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!0),[S,C]=(0,_.useState)(`https://github.com/visualfusion/feedkeeper`),[w,T]=(0,_.useState)(null),E=$c(ll()),D=E?.mount,O=(0,_.useEffectEvent)(async()=>{await j(),y(!1)}),k=(0,_.useEffectEvent)(()=>{g(e(`login.error`)),y(!1)});(0,_.useEffect)(()=>{if(!c||i||D)return;let e=yu({onAutofill:d,onSelect:()=>{y(!0),g(null)},onSuccess:O,onError:k});f.current=e,e.start();let t=()=>{e.start()},n=()=>{e.stop(),y(!1)};return window.addEventListener(`pagehide`,n),window.addEventListener(`pageshow`,t),()=>{e.stop(),f.current=void 0,window.removeEventListener(`pagehide`,n),window.removeEventListener(`pageshow`,t)}},[c,i,D]),(0,_.useEffect)(()=>{gu(`/config`,void 0,`GET`).then(e=>l(e.passkeys)).catch(()=>{}),H.getConfig().then(e=>{e&&(x(e.showGithubLink),e.githubUrl&&C(e.githubUrl),e.loginSubtitle&&T(e.loginSubtitle))}).catch(()=>{})},[]);async function A(t){if(t.preventDefault(),!v){f.current?.stop(),y(!0),g(null);try{i?await gu(`/mfa`,{challengeId:i,code:o}):await H.login(n,p),await j()}catch(t){t instanceof va&&t.code===`mfa_required`?(a(t.data.challengeId),m(``)):(g(e(`login.error`)),f.current?.start())}finally{y(!1)}}}async function j(){let e=new URLSearchParams(window.location.search).get(`next`);e?.startsWith(`/oauth/authorize?`)?window.location.assign(e):await t()}return(0,U.jsxs)(`div`,{className:`min-h-screen flex flex-col items-center justify-center px-4`,children:[(0,U.jsxs)(`div`,{className:`card p-8 w-full max-w-sm`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col items-center mb-6 text-center`,children:[(0,U.jsx)(`h1`,{className:`mb-3`,children:(0,U.jsx)(hl,{size:44})}),(0,U.jsx)(`p`,{className:`text-xs mt-1`,style:{color:`var(--c-text-muted)`},children:w??e(`login.subtitle`)})]}),E?(0,U.jsx)(bu,{name:`login-form`,mount:E.mount}):(0,U.jsxs)(`form`,{onSubmit:A,className:`flex flex-col gap-4`,children:[!i&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{htmlFor:`login-email`,className:`text-sm font-medium block mb-1`,children:e(`login.emailLabel`)}),(0,U.jsx)(`input`,{id:`login-email`,name:`username`,type:`email`,autoComplete:`username webauthn`,required:!0,autoFocus:!0,className:`input`,value:n,onChange:e=>r(e.target.value),onFocus:()=>{v||f.current?.start()}})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{htmlFor:`login-password`,className:`text-sm font-medium block mb-1`,children:e(`login.passwordLabel`)}),(0,U.jsx)(`input`,{type:`password`,id:`login-password`,name:`password`,autoComplete:`current-password`,required:!0,className:`input`,value:p,onChange:e=>m(e.target.value)})]})]}),i&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`label`,{htmlFor:`mfa-code`,children:e(`security.code`)}),(0,U.jsx)(`input`,{id:`mfa-code`,className:`input`,autoFocus:!0,autoComplete:`one-time-code`,value:o,onChange:e=>s(e.target.value),required:!0}),(0,U.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{a(void 0),s(``)},children:e(`security.cancel`)})]}),c&&!i&&u===!1&&(0,U.jsx)(`button`,{type:`button`,className:`text-sm underline`,disabled:v,onClick:()=>void f.current?.start(!1),children:e(`security.signInPasskey`)}),h&&(0,U.jsx)(`p`,{className:`text-sm text-danger`,children:h}),(0,U.jsx)(`button`,{type:`submit`,disabled:v,className:`btn-primary`,children:e(`login.submit`)})]})]}),(0,U.jsx)(Il,{placement:`login`}),b&&(0,U.jsx)(`div`,{className:`mt-4 text-center`,children:(0,U.jsxs)(`a`,{href:S,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 text-xs text-[var(--c-text-muted)] hover:text-[var(--c-text)] transition-colors opacity-80 hover:opacity-100`,children:[(0,U.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,U.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.53 1.032 1.53 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z`})}),(0,U.jsx)(`span`,{children:e(`login.viewOnGithub`)})]})})]})}function Su({className:e=``,size:t=`md`,center:n=!0}){let{t:r}=R(),i=(0,U.jsx)(`div`,{className:`rounded-full animate-spin border-[var(--c-border)] border-t-[var(--c-blue1)] dark:border-t-white/80 ${{sm:`w-5 h-5 border-2`,md:`w-8 h-8 border-[2.5px]`,lg:`w-10 h-10 border-3`}[t]} ${e}`,role:`status`,"aria-label":r(`common.loading`)});return n?(0,U.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center min-h-[45vh] w-full py-12 animate-fade-in`,children:i}):i}function Cu({label:e,items:t,className:n=``}){let[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(!1),s=(0,_.useRef)(null),c=(0,_.useRef)(null),l=(0,_.useId)();return(0,_.useLayoutEffect)(()=>{if(!r||!c.current)return;let e=c.current.getBoundingClientRect();o(window.innerHeight-e.bottom<48*t.length+24)},[r,t.length]),(0,_.useEffect)(()=>{if(!r)return;let e=e=>{s.current?.contains(e.target)||i(!1)},t=e=>{e.key===`Escape`&&(i(!1),c.current?.focus())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[r]),(0,U.jsxs)(`div`,{ref:s,className:`relative ${n}`,children:[(0,U.jsx)(`button`,{ref:c,type:`button`,onClick:e=>{e.stopPropagation(),i(e=>!e)},"aria-label":e,title:e,"aria-expanded":r,"aria-controls":l,className:`flex h-9 w-9 items-center justify-center rounded-lg text-[var(--c-text-muted)] transition-colors hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] cursor-pointer ${r?`bg-[var(--c-surface-hover)] text-[var(--c-text)]`:``}`,children:(0,U.jsxs)(`svg`,{className:`h-5 w-5`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:[(0,U.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.8`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.8`}),(0,U.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.8`})]})}),r&&(0,U.jsx)(`div`,{id:l,className:`card animate-fade-in absolute right-0 z-40 w-64 p-1.5 ${a?`bottom-full mb-2`:`top-full mt-2`}`,style:{boxShadow:`0 16px 40px -12px rgba(0, 0, 0, 0.35)`},children:t.map(e=>(0,U.jsxs)(`button`,{type:`button`,disabled:e.disabled,onClick:t=>{t.stopPropagation(),i(!1),e.onSelect()},className:`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors disabled:opacity-50 cursor-pointer disabled:cursor-default ${e.danger?`text-[var(--c-danger)] hover:bg-[var(--c-danger-bg)]`:`text-[var(--c-text)] hover:bg-[var(--c-surface-hover)]`}`,children:[e.icon&&(0,U.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center ${e.danger?``:`text-[var(--c-text-muted)]`}`,children:e.icon}),e.label]},e.label))})]})}function wu(){let{user:e}=lo(),t=e?.capabilities;return{syncAllowed:!t||t.features.sync===!0,manageUrl:t?.manageUrl??null}}function Tu({value:e,onChange:t,options:n,placeholder:r,className:i=``,size:a=`md`,disabled:o=!1,ariaLabel:s}){let{t:c}=R(),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(-1),p=(0,_.useRef)(null),m=(0,_.useRef)(null),h=(0,_.useId)(),g=n.find(t=>t.value===e);(0,_.useEffect)(()=>{function e(e){p.current&&!p.current.contains(e.target)&&u(!1)}if(l)return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[l]),(0,_.useEffect)(()=>{if(l){let t=n.findIndex(t=>t.value===e);f(t>=0?t:0)}},[l,e,n]),(0,_.useEffect)(()=>{if(l&&d>=0&&m.current){let e=m.current.querySelector(`[data-index="${d}"]`);e&&e.scrollIntoView({block:`nearest`})}},[d,l]);function v(e){o||(l?e.key===`Escape`?(e.preventDefault(),u(!1)):e.key===`ArrowDown`?(e.preventDefault(),f(e=>e<n.length-1?e+1:0)):e.key===`ArrowUp`?(e.preventDefault(),f(e=>e>0?e-1:n.length-1)):e.key===`Home`?(e.preventDefault(),f(0)):e.key===`End`?(e.preventDefault(),f(n.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d>=0&&d<n.length&&(t(n[d].value),u(!1))):(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(!0)))}let y=[];n.forEach((e,t)=>{let n=e.group??null,r=y.find(e=>e.groupName===n);r||(r={groupName:n,items:[]},y.push(r)),r.items.push({opt:e,index:t})});let b=a===`sm`;return(0,U.jsxs)(`div`,{ref:p,className:`relative inline-block ${i}`,onKeyDown:v,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||u(!1)},children:[(0,U.jsxs)(`button`,{type:`button`,id:h,role:`combobox`,"aria-label":s,"aria-haspopup":`listbox`,"aria-expanded":l,"aria-controls":l?`${h}-listbox`:void 0,"aria-activedescendant":l&&d>=0?`${h}-option-${d}`:void 0,disabled:o,onClick:()=>!o&&u(e=>!e),className:`w-full flex items-center justify-between gap-2 text-left font-normal transition-colors cursor-pointer select-none rounded-lg border bg-[var(--c-surface)] text-[var(--c-text)] shadow-xs hover:border-[var(--c-blue3)] focus:outline-none focus:border-[var(--c-blue3)] ${l?`border-[var(--c-blue3)]`:`border-[var(--c-border)]`} ${b?`px-2.5 py-1 text-xs min-h-[30px]`:`px-3 py-1.5 text-sm min-h-[38px]`} ${o?`opacity-50 cursor-not-allowed`:``}`,children:[(0,U.jsx)(`span`,{className:`truncate flex items-center gap-1.5`,children:g?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`truncate`,children:g.label}),g.badge!==void 0&&(0,U.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.2 rounded-full font-medium shrink-0`,style:{backgroundColor:`var(--c-border)`,color:`var(--c-text-muted)`},children:g.badge})]}):(0,U.jsx)(`span`,{style:{color:`var(--c-text-muted)`},children:r??`—`})}),(0,U.jsx)(`svg`,{className:`shrink-0 transition-transform duration-200 opacity-60 ${l?`rotate-180`:``} ${b?`w-3 h-3`:`w-3.5 h-3.5`}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,U.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})]}),l&&(0,U.jsx)(`div`,{className:`absolute left-0 mt-1 w-full min-w-[180px] max-w-xs sm:max-w-none rounded-lg border border-[var(--c-border)] bg-[var(--c-surface)] shadow-lg z-50 overflow-hidden`,style:{backdropFilter:`blur(8px)`},children:(0,U.jsx)(`ul`,{ref:m,id:`${h}-listbox`,role:`listbox`,"aria-labelledby":h,className:`max-h-60 overflow-y-auto py-1 text-[var(--c-text)] focus:outline-none`,children:n.length===0?(0,U.jsx)(`li`,{className:`px-3 py-2 text-xs italic`,style:{color:`var(--c-text-muted)`},children:r??c(`common.noOptions`)}):y.map((n,r)=>(0,U.jsxs)(`li`,{role:`group`,"aria-label":n.groupName??void 0,children:[n.groupName&&(0,U.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-wider select-none border-t first:border-t-0`,style:{borderColor:`var(--c-border)`,color:`var(--c-text-muted)`},children:n.groupName}),(0,U.jsx)(`ul`,{role:`presentation`,children:n.items.map(({opt:n,index:r})=>{let i=n.value===e,a=r===d;return(0,U.jsxs)(`li`,{id:`${h}-option-${r}`,"data-index":r,role:`option`,"aria-selected":i,onClick:()=>{t(n.value),u(!1)},onMouseEnter:()=>f(r),className:`flex items-center justify-between gap-2 cursor-pointer select-none transition-colors ${b?`px-2.5 py-1.5 text-xs`:`px-3 py-2 text-sm`} ${a?`bg-[var(--c-border)]/40 text-[var(--c-text)]`:`text-[var(--c-text)]`} ${i?`font-medium bg-[var(--c-blue1)]/10`:``}`,children:[(0,U.jsxs)(`span`,{className:`truncate flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`truncate`,children:n.label}),n.badge!==void 0&&(0,U.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.2 rounded-full font-medium shrink-0`,style:{backgroundColor:`var(--c-border)`,color:`var(--c-text-muted)`},children:n.badge})]}),i&&(0,U.jsx)(`svg`,{className:`w-3.5 h-3.5 shrink-0`,style:{color:`var(--c-blue3)`},viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`polyline`,{points:`20 6 9 17 4 12`})})]},n.value)})})]},n.groupName??`ungrouped-${r}`))})})]})}function Eu(e,t){let n=/^feed_http_(\d{3})$/.exec(t);if(n){let t=Number(n[1]);return t===404||t===410?e(`feeds.errors.notFound`,{status:t}):t===401||t===403?e(`feeds.errors.refused`,{status:t}):t===429?e(`feeds.errors.limited`):e(t>=400&&t<500&&t!==408&&t!==425?`feeds.errors.rejected`:`feeds.errors.unavailable`,{status:t})}return t===`feed_timeout`?e(`feeds.errors.timeout`):t===`feed_network_error`?e(`feeds.errors.network`):t===`feed_invalid_or_unavailable`?e(`feeds.errors.invalidFeed`):t}var Du=[[`day`,864e5],[`hour`,36e5],[`minute`,6e4]];function Ou(e,t,n=Date.now()){let r=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),i=e.getTime()-n;for(let[e,t]of Du)if(Math.abs(i)>=t)return r.format(Math.round(i/t),e);return r.format(0,`minute`)}function ku({children:e,className:t=`h-4 w-4`}){return(0,U.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:e})}var Au=({className:e})=>(0,U.jsxs)(ku,{className:e,children:[(0,U.jsx)(`path`,{d:`M21 12a9 9 0 1 1-2.64-6.36`}),(0,U.jsx)(`path`,{d:`M21 3v6h-6`})]}),ju=()=>(0,U.jsx)(ku,{children:(0,U.jsx)(`path`,{d:`M2 12l4 4 6-7M10 16l2 0 8-9`})}),Mu=()=>(0,U.jsxs)(ku,{children:[(0,U.jsx)(`path`,{d:`M12 20h9`}),(0,U.jsx)(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),Nu=()=>(0,U.jsx)(ku,{children:(0,U.jsx)(`path`,{d:`M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6`})}),Pu=({className:e})=>(0,U.jsx)(ku,{className:e,children:(0,U.jsx)(`path`,{d:`M12 5v14M5 12h14`})}),Fu=()=>(0,U.jsxs)(ku,{children:[(0,U.jsx)(`path`,{d:`M12 15V3M7 8l5-5 5 5`}),(0,U.jsx)(`path`,{d:`M5 21h14`})]}),Iu=()=>(0,U.jsxs)(ku,{children:[(0,U.jsx)(`path`,{d:`M12 3v12M7 10l5 5 5-5`}),(0,U.jsx)(`path`,{d:`M5 21h14`})]}),Lu=()=>(0,U.jsx)(ku,{children:(0,U.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z`})}),Ru=()=>(0,U.jsxs)(ku,{className:`h-4 w-4`,children:[(0,U.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,U.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),zu=()=>(0,U.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:[6,12,18].flatMap(e=>[9,15].map(t=>(0,U.jsx)(`circle`,{cx:t,cy:e,r:`1.5`},`${t}-${e}`)))}),Bu=()=>(0,U.jsx)(ku,{className:`h-5 w-5`,children:(0,U.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})}),Vu=()=>(0,U.jsxs)(ku,{className:`h-3.5 w-3.5 shrink-0`,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,U.jsx)(`path`,{d:`M12 8v4M12 16h.01`})]}),Hu=({className:e=`h-3.5 w-3.5`})=>(0,U.jsxs)(ku,{className:e,children:[(0,U.jsx)(`path`,{d:`M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9`}),(0,U.jsx)(`path`,{d:`M13.73 21a2 2 0 0 1-3.46 0`})]});function Uu(e,t){return t<60?e(`feeds.minutesShort`,{count:t}):e(`feeds.hoursShort`,{count:Math.round(t/60)})}function Wu(e){try{return e?new URL(e).hostname.replace(/^www\./,``):null}catch{return null}}function Gu({feed:e,folderOptions:t,intervalOptions:n,onClose:r,onSaved:i}){let{t:a}=R(),[o,s]=(0,_.useState)(e.label?.trim()||e.title?.trim()||e.url),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(e.folder_id??null),[f,p]=(0,_.useState)(e.poll_interval_minutes),[m,h]=(0,_.useState)(e.full_text_mode!==`never`),[g,v]=(0,_.useState)(),[y,b]=(0,_.useState)(),[x,S]=(0,_.useState)(!1);async function C(){S(!0);try{await H.updateFeed(e.id,{...c?{label:o.trim()||null}:{},folderId:u,pollIntervalMinutes:f,fullTextMode:m?`auto`:`never`,...g===void 0?{}:{notify:g},...y===void 0?{}:{badge:y}}),no(),K.success(a(`feeds.changesSaved`)),r(),await i()}catch{K.error(a(`common.error`))}finally{S(!1)}}return(0,U.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-[var(--c-border)] bg-[var(--c-bg)]/60 px-4 py-4 sm:px-5`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-[var(--c-text-muted)]`,children:[a(`feeds.labelPlaceholder`),(0,U.jsx)(`input`,{type:`text`,className:`input text-sm`,placeholder:e.title??e.url,value:o,onChange:e=>{s(e.target.value),l(!0)}})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-xs font-medium text-[var(--c-text-muted)]`,children:[a(`feeds.folder`),(0,U.jsx)(Tu,{value:u?String(u):``,onChange:e=>d(e?Number(e):null),options:t,className:`w-full`,placeholder:a(`feeds.noFolder`)})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-xs font-medium text-[var(--c-text-muted)]`,children:[a(`feeds.interval`),(0,U.jsx)(Tu,{value:String(f),onChange:e=>p(Number(e)),options:n,className:`w-full`})]})]}),(0,U.jsxs)(`label`,{className:`flex cursor-pointer select-none items-start gap-2.5 text-sm`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 rounded`,checked:m,onChange:e=>h(e.target.checked)}),(0,U.jsxs)(`span`,{children:[a(`feeds.fullText`),(0,U.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--c-text-muted)]`,children:e.full_text_blocked_at?a(`feeds.fullTextBlocked`):a(`feeds.fullTextHint`)})]})]}),(0,U.jsxs)(`label`,{className:`flex cursor-pointer select-none items-start gap-2.5 text-sm`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 rounded`,checked:g??e.notify!==0,onChange:e=>v(e.target.checked)}),(0,U.jsxs)(`span`,{children:[a(`feeds.notify`),(0,U.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--c-text-muted)]`,children:a(`feeds.notifyHint`)})]})]}),(0,U.jsxs)(`label`,{className:`flex cursor-pointer select-none items-start gap-2.5 text-sm`,children:[(0,U.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 rounded`,checked:y??e.badge!==0,onChange:e=>b(e.target.checked)}),(0,U.jsxs)(`span`,{children:[a(`feeds.badge`),(0,U.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--c-text-muted)]`,children:a(`feeds.badgeHint`)})]})]}),(0,U.jsx)(`p`,{className:`truncate font-mono text-xs text-[var(--c-text-muted)]`,title:e.url,children:e.url}),(0,U.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:r,className:`btn-secondary px-3 py-1.5 text-sm`,children:a(`common.cancel`)}),(0,U.jsx)(`button`,{type:`button`,onClick:C,disabled:x,className:`btn-primary px-4 py-1.5 text-sm`,children:a(`common.save`)})]})]})}function Ku({feed:e,editing:t,refreshing:n,highlighted:r=!1,folderOptions:i,intervalOptions:a,onEdit:o,onRefresh:s,onMarkRead:c,onUnsubscribe:l,onSaved:u,drag:d}){let{t:f,i18n:p}=R(),{syncAllowed:m}=wu(),h=e.label??e.title??e.url,g=Wu(e.site_url)??Wu(e.url),_=!!e.last_error,v=!e.last_polled_at,y=[{label:f(n?`feeds.refreshing`:`feeds.refreshFeed`),icon:(0,U.jsx)(Au,{className:`h-4 w-4 ${n?`animate-spin`:``}`}),onSelect:s,disabled:n||!m},...e.unread_count>0?[{label:f(`feeds.markAllRead`),icon:(0,U.jsx)(ju,{}),onSelect:c}]:[],{label:f(`feeds.edit`),icon:(0,U.jsx)(Mu,{}),onSelect:()=>o(!t)},{label:f(`feeds.unsubscribe`),icon:(0,U.jsx)(Nu,{}),onSelect:l,danger:!0}];return(0,U.jsxs)(`li`,{id:`feed-${e.id}`,draggable:!!d&&!t,onDragStart:d?.onDragStart,onDragOver:d?.onDragOver,onDragEnd:d?.onDragEnd,onDrop:d?.onDrop,className:`group/feed relative scroll-mt-28 first:rounded-t-xl last:rounded-b-xl transition-[opacity,background-color] duration-700 ${r?`bg-[var(--c-mobile-nav-active)]`:``} ${d?.isDragging?`opacity-40`:``} ${d?.isDragOver?`shadow-[inset_0_2px_0_var(--c-blue3)]`:``}`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3.5 sm:px-5`,children:[d&&(0,U.jsx)(`span`,{className:`-mr-1 flex shrink-0 cursor-grab touch-none text-[var(--c-text-muted)] opacity-50 transition-opacity hover:opacity-100 group-hover/feed:opacity-80 active:cursor-grabbing`,title:f(`feeds.dragHandle`),"aria-hidden":`true`,children:(0,U.jsx)(zu,{})}),(0,U.jsx)(zc,{feedId:e.id,iconUrl:e.icon_url,siteUrl:e.site_url,feedUrl:e.url,fallbackName:h,className:`h-5 w-5 shrink-0 rounded object-contain text-xs leading-none`}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(_||v)&&(0,U.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${_?`bg-[var(--c-danger)]`:`bg-[var(--c-text-muted)]`}`,title:_?f(`feeds.statusFailing`,{count:e.consecutive_errors||1}):f(`feeds.statusPending`)}),(0,U.jsx)(ji,{to:`/items?feed=${e.id}`,draggable:!1,className:`truncate font-semibold text-[var(--c-text)] hover:underline`,children:h}),e.notify!==0&&(0,U.jsx)(`span`,{className:`inline-flex shrink-0 items-center text-[var(--c-text-muted)]`,title:f(`feeds.notifyActive`),"aria-label":f(`feeds.notifyActive`),children:(0,U.jsx)(Hu,{className:`h-3.5 w-3.5`})})]}),(0,U.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-[var(--c-text-muted)]`,children:[g,f(`feeds.everyInterval`,{interval:Uu(f,e.poll_interval_minutes)}),e.last_polled_at?f(`feeds.checkedAgo`,{time:Ou(new Date(e.last_polled_at),p.resolvedLanguage)}):f(`feeds.statusPending`)].filter(Boolean).join(` · `)}),_&&(0,U.jsxs)(`p`,{className:`mt-1.5 flex items-start gap-1.5 text-xs text-[var(--c-danger)]`,title:e.last_error??void 0,children:[(0,U.jsx)(Vu,{}),(0,U.jsx)(`span`,{className:`line-clamp-2`,children:Eu(f,e.last_error??``)})]})]}),e.unread_count>0&&(0,U.jsx)(ji,{to:`/items?feed=${e.id}`,draggable:!1,className:`shrink-0 rounded-full bg-[var(--c-mobile-nav-active)] px-2.5 py-0.5 text-xs font-semibold tabular-nums text-[var(--c-text)] hover:bg-[var(--c-border)]`,title:f(`feeds.unread`,{count:e.unread_count}),children:e.unread_count}),(0,U.jsx)(Cu,{label:f(`feeds.moreActions`),items:y,className:`-mr-2 shrink-0`})]}),t&&(0,U.jsx)(Gu,{feed:e,folderOptions:i,intervalOptions:a,onClose:()=>o(!1),onSaved:u})]})}function qu(e,t){let n=t.toLowerCase().split(`-`)[0],r=e.feeds.filter(e=>e.lang===n||e.lang===``),i=n===`en`||n===`ja`&&r.length>0?[]:e.feeds.filter(e=>e.lang===`en`);return[...r,...i]}function Ju(e,t){let n=t.toLowerCase().split(`-`)[0],r=e=>e.lang===n||e.lang===``?0:e.lang===`en`?1:2;return[...e.feeds].sort((e,t)=>r(e)-r(t))}function Yu({folderOptions:e,defaultFolderId:t,initialUrl:n=``,subscribedUrls:r=[],compact:i=!1,onClose:a,onAdded:o}){let{t:s}=R(),[c,l]=(0,_.useState)(n),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(t),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)([]),y=new Set(r.map(Xu));async function b(e,t){h(!0),v([]);try{let n=await H.subscribeFeed(e,t,f);l(``),d(``),await o(n)}catch(e){e instanceof va&&e.code===`multiple_feeds_found`&&e.data&&typeof e.data==`object`&&`feeds`in e.data?v(e.data.feeds):e instanceof va&&e.code===`already_subscribed`?K.error(s(`feeds.alreadySubscribed`)):e instanceof va&&(e.code===`no_feeds_found`||e.code===`invalid_feed`)?K.error(s(`feeds.noFeedsFoundOnPage`)):K.error(s(`feeds.subscribeFailed`))}finally{h(!1)}}function x(e){e.preventDefault();let t=c.trim();t&&!/^https?:\/\//i.test(t)&&(t=t.startsWith(`//`)?`https:${t}`:`https://${t}`),b(t,u.trim()||null)}return(0,U.jsxs)(`section`,{className:i?`flex flex-col gap-4`:`card animate-fade-in flex flex-col gap-4 p-4 sm:p-5`,children:[!i&&(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`h2`,{className:`text-base font-semibold`,children:s(`feeds.addFeed`)}),(0,U.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-1 text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,"aria-label":s(`common.close`),children:(0,U.jsx)(Bu,{})})]}),(0,U.jsxs)(`form`,{onSubmit:x,className:`flex flex-col gap-3 ${i?`sm:flex-row sm:items-start`:``}`,children:[(0,U.jsx)(`input`,{type:`text`,required:!0,autoFocus:!i,placeholder:s(`feeds.urlPlaceholder`),className:i?`input sm:flex-1`:`input`,value:c,onChange:e=>{l(e.target.value),g.length&&v([])}}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row`,children:[!i&&(0,U.jsx)(`input`,{type:`text`,placeholder:s(`feeds.labelPlaceholder`),className:`input sm:flex-1`,value:u,onChange:e=>d(e.target.value)}),!i&&(0,U.jsx)(Tu,{value:f?String(f):``,onChange:e=>p(e?Number(e):null),options:e,className:`w-full sm:w-52`,placeholder:s(`feeds.noFolder`)}),(0,U.jsx)(`button`,{type:`submit`,disabled:m,className:`btn-primary whitespace-nowrap`,children:s(m?`feeds.subscribing`:`feeds.subscribe`)})]})]}),g.length>0&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:s(`feeds.multipleFeedsFound`)}),(0,U.jsx)(`ul`,{className:`divide-y divide-[var(--c-border)] rounded-xl border border-[var(--c-border)]`,children:g.map(e=>{let t=y.has(Xu(e.url));return(0,U.jsxs)(`li`,{className:`flex flex-col gap-2.5 px-3 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-3 ${t?`opacity-70`:``}`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`break-words text-sm font-medium`,children:e.title??e.url}),(0,U.jsx)(`p`,{className:`truncate text-xs text-[var(--c-text-muted)]`,children:e.url})]}),(0,U.jsx)(`button`,{type:`button`,disabled:m||t,onClick:()=>b(e.url,e.title||u.trim()||null),className:`btn-primary w-full shrink-0 whitespace-nowrap px-3 py-1.5 text-xs sm:w-auto`,children:s(t?`feeds.subscribed`:`feeds.subscribe`)})]},e.url)})})]})]})}function Xu(e){return e.trim().replace(/\/+$/,``).toLowerCase()}function Y(){let{t:e}=R(),{manageUrl:t}=wu();return(0,U.jsxs)(`section`,{role:`status`,className:`card flex flex-col gap-2 p-4 sm:p-5`,"aria-labelledby":`plan-notice-title`,children:[(0,U.jsx)(`h2`,{id:`plan-notice-title`,className:`text-base font-semibold`,children:e(`plan.limitedTitle`)}),(0,U.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:e(`plan.limitedText`)}),t&&(0,U.jsx)(`a`,{href:t,className:`btn-primary self-start`,style:{textDecoration:`none`},children:e(`plan.view`)})]})}var Zu={news:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2`}),(0,U.jsx)(`path`,{d:`M18 14h-8`}),(0,U.jsx)(`path`,{d:`M15 18h-5`}),(0,U.jsx)(`path`,{d:`M10 6h8v4h-8V6Z`})]}),technology:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`}),(0,U.jsx)(`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`}),(0,U.jsx)(`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`})]}),development:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`m18 16 4-4-4-4`}),(0,U.jsx)(`path`,{d:`m6 8-4 4 4 4`}),(0,U.jsx)(`path`,{d:`m14.5 4-5 16`})]}),science:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2`}),(0,U.jsx)(`path`,{d:`M8.5 2h7`}),(0,U.jsx)(`path`,{d:`M7 16h10`})]}),design:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}),(0,U.jsx)(`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`}),(0,U.jsx)(`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.563-2.512 5.563-5.563C22 6.5 17.5 2 12 2Z`})]}),gaming:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`line`,{x1:`6`,x2:`10`,y1:`11`,y2:`11`}),(0,U.jsx)(`line`,{x1:`8`,x2:`8`,y1:`9`,y2:`13`}),(0,U.jsx)(`line`,{x1:`15`,x2:`15.01`,y1:`12`,y2:`12`}),(0,U.jsx)(`line`,{x1:`18`,x2:`18.01`,y1:`10`,y2:`10`}),(0,U.jsx)(`path`,{d:`M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z`})]}),business:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`polyline`,{points:`22 7 13.5 15.5 8.5 10.5 2 17`}),(0,U.jsx)(`polyline`,{points:`16 7 22 7 22 13`})]}),sport:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M6 9H4.5a2.5 2.5 0 0 1 0-5H6`}),(0,U.jsx)(`path`,{d:`M18 9h1.5a2.5 2.5 0 0 0 0-5H18`}),(0,U.jsx)(`path`,{d:`M4 22h16`}),(0,U.jsx)(`path`,{d:`M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22`}),(0,U.jsx)(`path`,{d:`M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22`}),(0,U.jsx)(`path`,{d:`M18 2H6v7a6 6 0 0 0 12 0V2Z`})]}),culture:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z`}),(0,U.jsx)(`path`,{d:`m6.2 5.3 3.1 3.9`}),(0,U.jsx)(`path`,{d:`m12.4 3.4 3.1 4`}),(0,U.jsx)(`path`,{d:`M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z`})]})},X=`M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M15.97 6.37c.62-.75 1.04-1.8 0.93-2.85-.9.04-1.99.6-2.63 1.35-.57.65-1.07 1.71-.93 2.73.99.08 2.02-.48 2.63-1.23Z`;function Z({id:e}){if(e===`apple`)return(0,U.jsx)(`svg`,{className:`w-3.5 h-3.5 shrink-0`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:X})});let t=Zu[e];return t?(0,U.jsx)(`svg`,{className:`w-3.5 h-3.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:t}):null}async function Qu(e){try{let t=(await H.listFolders()).folders.find(t=>t.name===e);return t?t.id:(await H.createFolder(e)).id}catch{return null}}function $u({onSubscribed:e}){let{t,i18n:n}=R(),{syncAllowed:r}=wu(),i=ll(),a=tl(i),o=n.resolvedLanguage||`en`,[s,c]=(0,_.useState)([]),[l,u]=(0,_.useState)(!1),d=(0,_.useMemo)(()=>rl(i,s,o).map(e=>({...e,feeds:l?Ju(e,o):qu(e,o)})).filter(e=>e.feeds.length>0),[i,s,o,l]),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(new Set),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(!1),x=(0,_.useRef)(null),S=d.find(e=>e.id===f)??d[0]??null,C=d.reduce((e,t)=>e+t.feeds.filter(e=>m.has(e.url)).length,0),w=S!==null&&S.feeds.every(e=>m.has(e.url));(0,_.useEffect)(()=>{let e=!0;return H.feedLists(o).then(t=>{e&&c(t.lists)},()=>{e&&c([])}),()=>{e=!1}},[o]);function T(e){h(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})}function E(){S&&h(e=>{let t=new Set(e);for(let e of S.feeds)w?t.delete(e.url):t.add(e.url);return t})}async function D(){let n=[];for(let e of d)for(let t of e.feeds)m.has(t.url)&&n.push({url:t.url,label:t.title,folderName:e.title});if(n.length===0)return;v({done:0,total:n.length});let r=new Map;for(let e of new Set(n.map(e=>e.folderName)))r.set(e,await Qu(e));let i=0,a=0,o=0,s=new Set,c=[...n];await Promise.all(Array.from({length:Math.min(3,n.length)},async()=>{for(let e=c.shift();e;e=c.shift()){try{await H.subscribeFeed(e.url,e.label||null,r.get(e.folderName)??null),i++,s.add(e.url)}catch(t){t instanceof va&&t.code===`already_subscribed`?(i++,s.add(e.url)):a++}v({done:++o,total:n.length})}})),v(null),h(e=>new Set([...e].filter(e=>!s.has(e)))),a>0?K.error(t(`welcome.packPartial`,{added:i,failed:a})):K.success(t(`welcome.packAdded`,{count:i})),i>0&&await e()}async function O(n){let r=n.target.files?.[0];if(r){b(!0);try{let n=await H.importOpml(await r.text());n.failed>0?K.error(t(`feeds.importPartial`,{imported:n.imported,skipped:n.skipped,failed:n.failed})):K.success(t(`feeds.importSuccess`,{imported:n.imported,skipped:n.skipped})),n.imported>0&&await e()}catch{K.error(t(`feeds.importFailed`))}finally{b(!1),x.current&&(x.current.value=``)}}}async function k(n){K.success(t(`feeds.subscribedToast`,{title:n.label||n.title||n.url})),await e()}let A=g!==null||y;return r?(0,U.jsxs)(`section`,{className:`card flex flex-col gap-6 p-5 sm:p-7 shadow-xs`,"aria-labelledby":`welcome-title`,children:[(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h2`,{id:`welcome-title`,className:`text-xl sm:text-2xl font-bold tracking-tight text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:t(`welcome.title`)}),(0,U.jsx)(`p`,{className:`max-w-xl text-xs sm:text-sm text-[var(--c-text-muted)] mt-0.5 leading-relaxed`,children:t(`welcome.intro`)})]})}),a&&(0,U.jsx)(bu,{name:`onboarding`,mount:a.mount}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-4`,children:[d.length>0&&(0,U.jsxs)(`div`,{className:`rounded-2xl border border-[var(--c-border)]/80 bg-[var(--c-surface-hover)]/25 p-4 sm:p-5 flex flex-col gap-3.5`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,U.jsx)(`div`,{className:`w-7 h-7 rounded-lg bg-[var(--c-blue1)]/10 text-[var(--c-blue1)] flex items-center justify-center shrink-0`,children:(0,U.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,U.jsx)(`polygon`,{points:`16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76`})]})}),(0,U.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:t(`welcome.packsTitle`)})]}),(0,U.jsx)(`p`,{className:`text-xs sm:text-sm text-[var(--c-text-muted)] mt-1 ml-9.5`,children:t(`welcome.packsHint`)})]}),(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t(`welcome.packsTitle`),children:d.map(e=>{let t=e.feeds.filter(e=>m.has(e.url)).length,n=S?.id===e.id;return(0,U.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:A,onClick:()=>p(e.id),className:`inline-flex items-center gap-2 rounded-full border px-3.5 py-1.5 text-xs sm:text-sm font-semibold cursor-pointer transition-all ${n?`border-[var(--c-blue1)] bg-[var(--c-blue1)] text-white shadow-xs`:`border-[var(--c-border)] bg-[var(--c-surface)] hover:border-[var(--c-blue3)] hover:bg-[var(--c-surface-hover)] text-[var(--c-text)]`}`,children:[(0,U.jsx)(Z,{id:e.id}),(0,U.jsx)(`span`,{children:e.title}),t>0&&(0,U.jsx)(`span`,{className:`rounded-full px-1.5 text-[0.625rem] font-bold leading-4 ${n?`bg-white/25 text-white`:`bg-[var(--c-blue1)] text-white`}`,children:t})]},e.id)})}),S&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-3 pt-2 animate-fade-in border-t border-[var(--c-border)]/60`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[S.description&&(0,U.jsx)(`p`,{className:`text-xs sm:text-sm text-[var(--c-text-muted)]`,children:S.description}),(0,U.jsx)(`button`,{type:`button`,disabled:A,onClick:E,className:`text-xs sm:text-sm font-semibold text-[var(--c-blue1)] cursor-pointer hover:underline`,children:t(w?`welcome.deselectAll`:`welcome.selectAll`)})]}),(0,U.jsx)(`ul`,{className:`divide-y divide-[var(--c-border)] rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)]`,children:S.feeds.map(e=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 px-3.5 py-2.5 hover:bg-[var(--c-surface-hover)]/50 transition-colors`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:m.has(e.url),disabled:A,onChange:()=>T(e.url),className:`mt-0.5 rounded accent-[var(--c-blue1)]`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate text-xs sm:text-sm font-medium`,children:e.title}),e.description&&(0,U.jsx)(`span`,{className:`block text-xs text-[var(--c-text-muted)] leading-snug`,children:e.description})]}),e.lang&&(0,U.jsx)(`span`,{className:`shrink-0 text-[0.625rem] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded bg-[var(--c-surface-hover)] text-[var(--c-text-muted)]`,children:e.lang})]})},e.url))})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,U.jsx)(`button`,{type:`button`,disabled:A||C===0,onClick:()=>void D(),className:`btn-primary self-start text-xs sm:text-sm font-semibold px-4 py-2`,children:g?t(`welcome.subscribingProgress`,{done:g.done,total:g.total}):t(`welcome.subscribePack`,{count:C})}),(0,U.jsxs)(`label`,{className:`inline-flex items-center gap-2 text-xs sm:text-sm text-[var(--c-text-muted)] cursor-pointer`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:l,disabled:A,onChange:e=>u(e.target.checked),className:`rounded accent-[var(--c-blue1)]`}),t(`welcome.allLanguages`)]})]})]}),(0,U.jsxs)(`div`,{className:`rounded-2xl border border-[var(--c-border)]/80 bg-[var(--c-surface-hover)]/25 p-4 sm:p-5 flex flex-col gap-3.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,U.jsx)(`div`,{className:`w-7 h-7 rounded-lg bg-[var(--c-blue1)]/10 text-[var(--c-blue1)] flex items-center justify-center shrink-0`,children:(0,U.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,U.jsx)(`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`}),(0,U.jsx)(`path`,{d:`M2 12h20`})]})}),(0,U.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:t(`welcome.addTitle`)})]}),(0,U.jsx)(Yu,{compact:!0,folderOptions:[],defaultFolderId:null,onClose:()=>{},onAdded:k})]}),(0,U.jsxs)(`div`,{className:`rounded-2xl border border-[var(--c-border)]/80 bg-[var(--c-surface-hover)]/25 p-4 sm:p-5 flex flex-col sm:flex-row sm:items-center justify-between gap-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,U.jsx)(`div`,{className:`w-7 h-7 rounded-lg bg-[var(--c-blue1)]/10 text-[var(--c-blue1)] flex items-center justify-center shrink-0`,children:(0,U.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`path`,{d:`M21 8v13H3V8`}),(0,U.jsx)(`path`,{d:`M1 3h22v5H1z`}),(0,U.jsx)(`path`,{d:`M10 12h4`})]})}),(0,U.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:t(`welcome.importTitle`)})]}),(0,U.jsx)(`p`,{className:`text-xs sm:text-sm text-[var(--c-text-muted)] mt-1 ml-9.5`,children:t(`welcome.importHint`)})]}),(0,U.jsxs)(`button`,{type:`button`,disabled:A,onClick:()=>x.current?.click(),className:`btn-secondary inline-flex items-center gap-2 shrink-0 text-xs sm:text-sm font-semibold px-4 py-2`,children:[(0,U.jsx)(Fu,{}),t(y?`feeds.importing`:`feeds.importOpml`)]}),(0,U.jsx)(`input`,{type:`file`,ref:x,onChange:O,accept:`.opml,.xml,text/xml,application/xml`,className:`hidden`})]})]})]}):(0,U.jsx)(Y,{})}function ed({folder:e,onRenamed:t}){let{t:n}=R(),[r,i]=(0,_.useState)(e.name);async function a(){let a=r.trim();if(!a||a===e.name)i(e.name);else try{await H.updateFolder(e.id,a),K.success(n(`feeds.folderRenamed`,{name:a})),await t()}catch{i(e.name),K.error(n(`common.error`))}}return(0,U.jsx)(`input`,{className:`input h-9 min-h-0 flex-1 border-transparent bg-transparent px-2 text-sm shadow-none hover:border-[var(--c-border)] focus:border-[var(--c-border)]`,value:r,onChange:e=>i(e.target.value),onBlur:()=>void a(),onKeyDown:t=>{t.key===`Enter`&&t.currentTarget.blur(),t.key===`Escape`&&i(e.name)}})}function td({folders:e,onClose:t,onChanged:n}){let{t:r}=R(),{syncAllowed:i}=wu(),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(!1);async function l(e){if(e.preventDefault(),a.trim()){c(!0);try{await H.createFolder(a.trim()),K.success(r(`feeds.folderCreated`,{name:a.trim()})),o(``),await n()}catch{K.error(r(`common.error`))}finally{c(!1)}}}async function u(e){if(confirm(r(`feeds.deleteFolderConfirm`,{name:e.name})))try{await H.deleteFolder(e.id),K.success(r(`feeds.folderDeleted`,{name:e.name})),await n()}catch{K.error(r(`common.error`))}}return(0,U.jsxs)(`section`,{className:`card animate-fade-in flex flex-col gap-4 p-4 sm:p-5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h2`,{className:`text-base font-semibold`,children:r(`feeds.manageFolders`)}),(0,U.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--c-text-muted)]`,children:r(`feeds.renameFolderHint`)})]}),(0,U.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg p-1 text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,"aria-label":r(`common.close`),children:(0,U.jsx)(Bu,{})})]}),e.length>0&&(0,U.jsx)(`ul`,{className:`divide-y divide-[var(--c-border)] rounded-xl border border-[var(--c-border)]`,children:e.map(e=>(0,U.jsxs)(`li`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,U.jsx)(ed,{folder:e,onRenamed:n},e.name),(0,U.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-[var(--c-text-muted)]`,children:r(`feeds.feedCount`,{count:e.feed_count??0})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:`rounded-lg p-2 text-[var(--c-text-muted)] hover:bg-[var(--c-danger-bg)] hover:text-[var(--c-danger)] cursor-pointer`,"aria-label":r(`common.delete`),title:r(`common.delete`),children:(0,U.jsx)(Nu,{})})]},e.id))}),(0,U.jsxs)(`form`,{onSubmit:l,className:`flex gap-2`,children:[(0,U.jsx)(`input`,{type:`text`,disabled:!i,placeholder:r(`feeds.newFolderPlaceholder`),className:`input flex-1`,value:a,onChange:e=>o(e.target.value)}),(0,U.jsx)(`button`,{type:`submit`,disabled:s||!i||!a.trim(),title:i?void 0:r(`plan.unavailable`),className:`btn-primary whitespace-nowrap`,children:r(`feeds.addFolder`)})]})]})}function nd(e,t,n){e.deferred?K.info(n(`feeds.refreshPendingToast`,{title:t})):e.error?K.error(n(`feeds.refreshFailedToast`,{title:t,error:Eu(n,e.error)})):K.success(n(`feeds.refreshedToast`,{title:t,count:e.newItems}))}function rd(e,t){e.deferred?K.info(t(`feeds.refreshAllPendingToast`,{count:e.deferred,newItems:e.newItems})):e.errors||K.success(t(`feeds.refreshedAllToast`,{count:e.refreshed,newItems:e.newItems})),e.errors>0&&K.error(t(`feeds.failingCount`,{count:e.errors}))}var id=[5,15,30,60,180,360,720,1440],ad=`none`;function od(e,t){return!t||[e.label,e.title,e.url,e.site_url].filter(Boolean).join(` `).toLowerCase().includes(t.toLowerCase())}function sd(){let{t:e}=R(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(new Set),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),[v,y]=Li(),[b]=(0,_.useState)(()=>[v.get(`url`),v.get(`text`),v.get(`add`)].filter(Boolean).join(` `).match(/https?:\/\/[^\s]+/i)?.[0]??``);(0,_.useEffect)(()=>{(v.has(`add`)||v.has(`url`)||v.has(`text`))&&(j&&c(`add`),y({},{replace:!0}))},[]);let[x,S]=(0,_.useState)(`all`),[C,w]=(0,_.useState)(null),[T,E]=(0,_.useState)(!1),[D,O]=(0,_.useState)(null),k=(0,_.useRef)(null);async function A(){try{let[e,t]=await Promise.all([H.listFeeds(),H.listFolders().catch(()=>({folders:[]}))]);n(e),i(t.folders)}catch(e){console.error(`Failed to load feeds:`,e)}finally{o(!1)}}(0,_.useEffect)(()=>{A()},[]),(0,_.useEffect)(()=>{if(D===null)return;document.getElementById(`feed-${D}`)?.scrollIntoView({behavior:`smooth`,block:`center`});let e=window.setTimeout(()=>O(null),2500);return()=>window.clearTimeout(e)},[D,t]);let{syncAllowed:j}=wu(),ee=e=>(e.label??e.title??e.url).replace(/\s+/g,` `).trim();async function te(t){K.success(e(`feeds.subscribedToast`,{title:ee(t)})),g(``),S(`all`),await A(),O(t.id)}let ne=(0,_.useMemo)(()=>[{value:``,label:e(`feeds.noFolder`)},...r.map(e=>({value:String(e.id),label:e.name}))],[r,e]),re=(0,_.useMemo)(()=>id.map(t=>({value:String(t),label:Uu(e,t)})),[e]),M=(0,_.useMemo)(()=>{let n=new Map;for(let e of t){let t=e.folder_id??null;n.set(t,[...n.get(t)??[],e])}let i=[...r].sort((e,t)=>e.name.localeCompare(t.name)).map(e=>({key:`folder:${e.id}`,name:e.name,feeds:n.get(e.id)??[]}));return i.push({key:ad,name:e(`feeds.uncategorized`),feeds:n.get(null)??[]}),i.filter(e=>e.feeds.length>0)},[t,r,e]),ie=(0,_.useMemo)(()=>M.filter(e=>x===`all`||x===`failing`||e.key===x).map(e=>({...e,feeds:e.feeds.filter(e=>od(e,h)&&(x!==`failing`||!!e.last_error))})).filter(e=>e.feeds.length>0),[M,x,h]),ae=t.reduce((e,t)=>e+t.unread_count,0),oe=t.filter(e=>e.last_error).length,se=!h&&x!==`failing`;(0,_.useEffect)(()=>{if(!C)return;let e=e=>e.preventDefault();return window.addEventListener(`dragover`,e),window.addEventListener(`drop`,e),()=>{window.removeEventListener(`dragover`,e),window.removeEventListener(`drop`,e)}},[C!==null]);async function ce(){if(!C||C.from===C.over){w(null);return}let e=M.map(e=>{if(e.key!==C.group)return e.feeds;let t=[...e.feeds],[n]=t.splice(C.from,1);return t.splice(C.over,0,n),t}).flat();n(e),w(null);try{await H.reorderFeeds(e.map(e=>e.id))}catch(e){console.error(`Failed to save feed order:`,e),await A()}}async function N(t){f(e=>new Set(e).add(t));try{let r=await H.refreshFeed(t);r.feed?n(e=>e.map(e=>e.id===t?r.feed:e)):await A(),nd(r,r.feed?ee(r.feed):``,e)}catch{K.error(e(`common.error`))}finally{f(e=>{let n=new Set(e);return n.delete(t),n})}}async function le(){m(!0);try{let t=await H.refreshAllFeeds();await A(),rd(t,e)}catch{K.error(e(`common.error`))}finally{m(!1)}}async function ue(t){if(confirm(e(`feeds.unsubscribeConfirm`,{title:ee(t)})))try{await H.unsubscribeFeed(t.id),K.success(e(`feeds.unsubscribedToast`,{title:ee(t)})),await A()}catch{K.error(e(`common.error`))}}async function de(t){try{await H.markAllRead(t.id),K.success(e(`feeds.markedReadToast`,{title:ee(t)})),await A()}catch{K.error(e(`common.error`))}}function fe(){let e=document.createElement(`a`);e.href=H.exportOpmlUrl(),e.download=`feedkeeper-subscriptions.opml`,e.click()}async function pe(t){let n=t.target.files?.[0];if(n){E(!0);try{let t=await H.importOpml(await n.text());t.failed>0?K.error(e(`feeds.importPartial`,{imported:t.imported,skipped:t.skipped,failed:t.failed})):K.success(e(`feeds.importSuccess`,{imported:t.imported,skipped:t.skipped})),await A()}catch{K.error(e(`feeds.importFailed`))}finally{E(!1),k.current&&(k.current.value=``)}}}let me=[{key:`all`,label:e(`feeds.filterAll`),count:t.length},...M.map(e=>({key:e.key,label:e.name,count:e.feeds.length})),...oe>0?[{key:`failing`,label:e(`feeds.filterFailing`),count:oe,danger:!0}]:[]];return(0,U.jsxs)(`div`,{className:`flex flex-col gap-6 pb-24`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h1`,{className:`text-2xl font-semibold`,children:e(`feeds.title`)}),!a&&t.length>0&&(0,U.jsxs)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:[e(`feeds.feedCount`,{count:t.length}),` · `,e(`feeds.unread`,{count:ae}),oe>0&&(0,U.jsxs)(U.Fragment,{children:[` · `,(0,U.jsx)(`button`,{type:`button`,onClick:()=>S(`failing`),className:`text-[var(--c-danger)] hover:underline cursor-pointer`,children:e(`feeds.failingCount`,{count:oe})})]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(a||t.length>0)&&(0,U.jsxs)(`button`,{type:`button`,disabled:!j,title:j?void 0:e(`plan.unavailable`),onClick:()=>c(s===`add`?null:`add`),className:`btn-primary inline-flex items-center gap-1.5 whitespace-nowrap`,children:[(0,U.jsx)(Pu,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:e(`feeds.addFeed`)}),(0,U.jsx)(`span`,{className:`sm:hidden`,children:e(`feeds.addFeedShort`)})]}),(0,U.jsx)(Cu,{label:e(`feeds.moreActions`),items:[{label:e(p?`feeds.refreshing`:`feeds.refreshAll`),icon:(0,U.jsx)(Au,{className:`h-4 w-4 ${p?`animate-spin`:``}`}),onSelect:le,disabled:p||!j},{label:e(`feeds.manageFolders`),icon:(0,U.jsx)(Lu,{}),onSelect:()=>c(`folders`)},{label:e(T?`feeds.importing`:`feeds.importOpml`),icon:(0,U.jsx)(Fu,{}),onSelect:()=>k.current?.click(),disabled:T||!j},{label:e(`feeds.exportOpml`),icon:(0,U.jsx)(Iu,{}),onSelect:fe}]}),(0,U.jsx)(`input`,{type:`file`,ref:k,onChange:pe,accept:`.opml,.xml,text/xml,application/xml`,className:`hidden`})]})]}),!j&&t.length>0&&(0,U.jsx)(Y,{}),s===`add`&&j&&(0,U.jsx)(Yu,{folderOptions:ne,defaultFolderId:x.startsWith(`folder:`)?Number(x.slice(7)):null,initialUrl:b,subscribedUrls:t.map(e=>e.url),onClose:()=>c(null),onAdded:te}),s===`folders`&&(0,U.jsx)(td,{folders:r,onClose:()=>c(null),onChanged:A}),a?(0,U.jsx)(Su,{size:`lg`}):t.length===0?s!==`add`&&(0,U.jsx)($u,{onSubscribed:A}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`span`,{className:`pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-[var(--c-text-muted)] opacity-60`,children:(0,U.jsx)(Ru,{})}),(0,U.jsx)(`input`,{type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:e(`feeds.searchPlaceholder`),"aria-label":e(`feeds.searchPlaceholder`),className:`input pl-9`})]}),(0,U.jsx)(`div`,{className:`-mx-4 flex gap-2 overflow-x-auto px-4 pb-1 sm:mx-0 sm:flex-wrap sm:overflow-visible sm:px-0`,role:`group`,"aria-label":e(`feeds.folder`),children:me.map(e=>{let t=x===e.key;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>S(e.key),"aria-pressed":t,className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border px-3 py-1.5 text-sm font-medium transition-colors cursor-pointer ${t?`border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] text-[var(--c-text)]`:`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)]`} ${e.danger&&!t?`text-[var(--c-danger)]`:``}`,children:[e.label,e.count!==void 0&&(0,U.jsx)(`span`,{className:`text-xs tabular-nums opacity-70`,children:e.count})]},e.key)})})]}),ie.length===0?(0,U.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:e(`feeds.noMatches`)}):(0,U.jsx)(`div`,{className:`flex flex-col gap-6 animate-page-fade`,children:ie.map(t=>{let n=t.feeds.reduce((e,t)=>e+t.unread_count,0);return(0,U.jsxs)(`section`,{children:[(0,U.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-3 px-1`,children:[(0,U.jsx)(`h2`,{className:`truncate text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:t.name}),(0,U.jsxs)(`span`,{className:`shrink-0 text-xs text-[var(--c-text-muted)]`,children:[e(`feeds.feedCount`,{count:t.feeds.length}),n>0&&` · ${e(`feeds.unread`,{count:n})}`]})]}),(0,U.jsx)(`ul`,{className:`card divide-y divide-[var(--c-border)]`,children:t.feeds.map((e,n)=>(0,U.jsx)(Ku,{feed:e,editing:l===e.id,refreshing:d.has(e.id),highlighted:D===e.id,folderOptions:ne,intervalOptions:re,onEdit:t=>u(t?e.id:null),onRefresh:()=>void N(e.id),onMarkRead:()=>void de(e),onUnsubscribe:()=>void ue(e),onSaved:A,drag:se&&t.feeds.length>1?{isDragging:C?.group===t.key&&C.from===n,isDragOver:C?.group===t.key&&C.over===n&&C.from!==n,onDragStart:r=>{r.dataTransfer.effectAllowed=`move`,r.dataTransfer.setData(`application/x-feedkeeper-feed`,String(e.id)),w({group:t.key,from:n,over:n})},onDragOver:e=>{C?.group===t.key&&(e.preventDefault(),C.over!==n&&w({...C,over:n}))},onDragEnd:()=>void ce(),onDrop:e=>e.preventDefault()}:void 0},e.id))})]},t.key)})})]})]})}function cd(){let[e,t]=(0,_.useState)(()=>new Date);return(0,_.useEffect)(()=>{let n=new Date(e);n.setHours(24,0,1,0);let r=window.setTimeout(()=>t(new Date),n.getTime()-Date.now());return()=>window.clearTimeout(r)},[e]),e}function ld({className:e=``}){let{i18n:t}=R(),n=cd(),r=e=>new Intl.DateTimeFormat(t.resolvedLanguage,{weekday:`long`,day:`numeric`,month:`long`,...e?{year:`numeric`}:{}}).format(n);return(0,U.jsxs)(`time`,{dateTime:n.toLocaleDateString(`sv-SE`),className:`truncate text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)] ${e}`,children:[(0,U.jsx)(`span`,{className:`sm:hidden`,children:r(!1)}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:r(!0)})]})}var ud=650;function dd(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content.querySelectorAll(`script, style, noscript, template, svg, [hidden], [aria-hidden='true']`).forEach(e=>e.remove()),t.content.querySelectorAll(`p, div, li, br, blockquote, section, article, h1, h2, h3, h4, h5, h6`).forEach(e=>e.after(` `)),t.content.textContent?.replace(/\s+/g,` `).trim()??``}function fd(e){let t=e.full_content_html?.trim()?dd(e.full_content_html):``,n=!t&&e.content_html?.trim()?dd(e.content_html):``,r=e.content_snippet?.replace(/\s+/g,` `).trim()??``,i=t||(n.length>=r.length?n:r);return i?i.length<=ud?i:Eo(i)===`ja`?Do(i,ud):`${i.slice(0,ud).trimEnd()}…`:null}function pd({item:e,className:t}){let n=(0,_.useMemo)(()=>fd(e),[e]);if(!n)return null;let r=Eo(n);return(0,U.jsx)(`p`,{className:r===`ja`?`${t} ja-phrases`:t,lang:r,children:(0,U.jsx)(Bc,{text:n})})}function md(e){let t=0,n=-5;return e.map((e,r)=>{let i=/^https?:\/\//i.test(e.image_url??``),a=(e.content_snippet?.trim().length??0)>=220,o=(i||a)&&r-n>=5&&t<=1;return t=(t+(o?2:1))%3,o&&(n=r),o})}function hd(e){let t=e.map(()=>!1),n=[],r=0;return e.forEach((i,a)=>{n.push(a),r+=i?2:1,r===3&&(n.some(t=>e[t])&&n.forEach(n=>{t[n]=!e[n]}),n=[],r=0)}),t}function gd({url:e,featured:t}){let[n,r]=(0,_.useState)(`loading`);return!e||!/^https?:\/\//i.test(e)?null:(0,U.jsx)(`div`,{className:n===`hidden`?`hidden`:`overflow-hidden border-b border-[var(--c-border)] bg-[var(--c-bg)]`,children:(0,U.jsx)(`img`,{src:e,alt:``,loading:`lazy`,className:`w-full object-cover transition-transform duration-300 group-hover:scale-[1.025] ${t?`aspect-[3/2] lg:aspect-[16/9]`:`aspect-[3/2]`} ${n===`visible`?`opacity-100`:`opacity-0`}`,onLoad:e=>{let{naturalWidth:n,naturalHeight:i}=e.currentTarget;r(n>=(t?400:160)&&i>=(t?220:100)?`visible`:`hidden`)},onError:()=>r(`hidden`)})})}function _d({item:e,featured:t,besideFeature:n,onOpen:r,onBookmark:i,onRead:a}){let{t:o,i18n:s}=R(),c=e.published_at?new Date(e.published_at):null,l=c&&!Number.isNaN(c.getTime())?c:null,u=l?new Intl.DateTimeFormat(s.resolvedLanguage,{dateStyle:`medium`}).format(l):null,d=l?new Intl.DateTimeFormat(s.resolvedLanguage,{timeStyle:`short`}).format(l):null;return(0,U.jsx)(`li`,{className:t?`lg:col-span-2`:``,children:(0,U.jsxs)(`article`,{className:`card group relative flex h-full flex-col overflow-hidden transition-colors duration-150 hover:border-[var(--c-blue3)] hover:bg-[var(--c-surface-hover)]`,style:{opacity:e.read?.65:1},children:[(0,U.jsx)(`button`,{type:`button`,className:`absolute inset-0 z-10 rounded-xl focus-visible:outline-2 focus-visible:outline-offset-[-3px] focus-visible:outline-[var(--c-blue3)]`,"aria-label":e.title||e.feed_title||o(`items.title`),onClick:()=>r(e)}),(0,U.jsx)(gd,{url:e.image_url,featured:t},e.image_url??``),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col ${t?`p-4 sm:p-5 lg:p-6`:`p-4 sm:p-5`}`,children:[(0,U.jsxs)(`div`,{className:`mb-3 flex min-w-0 items-center gap-2 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:[(0,U.jsx)(zc,{feedId:e.feed_id,iconUrl:e.feed_icon_url,siteUrl:e.feed_site_url,feedUrl:e.feed_url,articleUrl:e.link,className:`h-3.5 w-3.5 shrink-0 rounded-xs object-contain`}),(0,U.jsx)(`span`,{className:`truncate`,children:e.feed_title})]}),(0,U.jsx)(`h2`,{lang:Eo(e.title||e.feed_title),className:`text-[var(--c-text)] ${t?`text-lg leading-snug lg:text-2xl lg:leading-tight`:`text-lg leading-snug`} font-semibold${Eo(e.title||e.feed_title)===`ja`?` ja-phrases`:``}`,children:e.title||e.feed_title?(0,U.jsx)(Bc,{text:e.title||e.feed_title}):null}),(0,U.jsx)(pd,{item:e,className:`mt-3 text-sm leading-relaxed text-[var(--c-text-muted)] ${t?`line-clamp-3 lg:line-clamp-4`:n?`line-clamp-3 lg:line-clamp-12`:`line-clamp-3`}`}),(0,U.jsxs)(`div`,{className:`pointer-events-none relative z-20 mt-auto flex flex-wrap items-center gap-x-3 gap-y-2 pt-5 text-xs text-[var(--c-text-muted)]`,children:[u&&(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:d??void 0,children:[(0,U.jsxs)(`svg`,{className:`h-3.5 w-3.5 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`18`,rx:`2`}),(0,U.jsx)(`path`,{d:`M8 2v4M16 2v4M3 10h18`})]}),u]}),d&&(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsxs)(`svg`,{className:`h-3.5 w-3.5 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,U.jsx)(`path`,{d:`M12 6v6l4 2`})]}),d]}),(0,U.jsxs)(`div`,{className:`pointer-events-auto ml-auto flex items-center gap-1.5`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:()=>i(e),title:e.bookmarked?o(`items.unbookmark`):o(`items.bookmark`),"aria-label":e.bookmarked?o(`items.unbookmark`):o(`items.bookmark`),className:`grid h-8 w-8 place-items-center rounded-lg border transition-colors ${e.bookmarked?`border-amber-500/40 bg-amber-500/15 text-amber-500`:`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500`}`,children:(0,U.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:e.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,U.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>a(e),title:e.read?o(`items.markUnread`):o(`items.markRead`),"aria-label":e.read?o(`items.markUnread`):o(`items.markRead`),className:`grid h-8 w-8 place-items-center rounded-lg border border-[var(--c-border)] transition-colors ${e.read?`text-[var(--c-text-muted)]`:`text-[var(--c-blue3)]`}`,children:(0,U.jsx)(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:e.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2.2`,"aria-hidden":`true`,children:(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})})]})]})]})]})})}function vd({items:e,onOpen:t,onBookmark:n,onRead:r}){let i=(0,_.useMemo)(()=>md(e),[e]),a=(0,_.useMemo)(()=>hd(i),[i]);return(0,U.jsx)(`ul`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 sm:gap-5 animate-page-fade`,children:e.map((e,o)=>(0,U.jsx)(_d,{item:e,featured:i[o],besideFeature:a[o],onOpen:t,onBookmark:n,onRead:r},e.id))})}var yd=68,bd=92,xd=`input, select, textarea, [contenteditable='true'], [data-no-pull]`;function Sd(){let e=e=>{e.preventDefault(),e.stopPropagation()};window.addEventListener(`click`,e,{capture:!0,once:!0}),window.setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function Cd({children:e,disabled:t=!1,onRefresh:n}){let{t:r}=R(),i=(0,_.useRef)(null),a=(0,_.useRef)(0),[o,s]=(0,_.useState)(0),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!1),m=(0,_.useCallback)(()=>{u||(p(!1),d(!0),s(56),n().catch(()=>p(!0)).finally(()=>{d(!1),s(0)}))},[u,n]);(0,_.useEffect)(()=>{let e=i.current;if(!e)return;let n=null;function r(){n=null,a.current=0,l(!1),s(0)}function o(e){t||u||e.touches.length!==1||window.scrollY>1||!window.matchMedia(`(any-pointer: coarse)`).matches||document.body.style.overflow===`hidden`||e.target.closest(xd)||(n={x:e.touches[0].clientX,y:e.touches[0].clientY})}function c(e){if(!n||e.touches.length!==1)return;let t=e.touches[0].clientX-n.x,i=e.touches[0].clientY-n.y;if(window.scrollY>1||Math.abs(t)>Math.abs(i)){r();return}if(i<=0){a.current=0,s(0);return}e.preventDefault();let o=Math.min(bd,i*.72);a.current=o,l(!0),s(o)}function d(){if(!n)return;let e=a.current>=yd;a.current>8&&Sd(),r(),e&&m()}return e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,c,{passive:!1}),e.addEventListener(`touchend`,d),e.addEventListener(`touchcancel`,r),()=>{e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,c),e.removeEventListener(`touchend`,d),e.removeEventListener(`touchcancel`,r)}},[t,u,n,m]);let h=u?1:Math.min(1,o/yd);return(0,U.jsxs)(`div`,{ref:i,children:[(0,U.jsx)(`button`,{type:`button`,className:`sr-only focus:not-sr-only sm:hidden`,onClick:m,disabled:t||u,children:r(`items.refresh`)}),(0,U.jsx)(`div`,{"aria-hidden":`true`,className:`relative flex items-center justify-center overflow-hidden`,style:{height:o,transition:c?`none`:`height 220ms ease-out`},children:(0,U.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full border border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text)] shadow-sm`,style:{opacity:Math.min(1,o/30),transform:`scale(${.65+h*.35})`},children:(0,U.jsxs)(`svg`,{className:`h-5 w-5 ${u?`animate-spin motion-reduce:animate-none`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:u?void 0:{transform:`rotate(${h*270}deg)`},children:[(0,U.jsx)(`path`,{d:`M18 7a8 8 0 1 0 2 5`,pathLength:`100`,strokeDasharray:`${h*100} 100`}),(0,U.jsx)(`path`,{d:`M18 3v4h-4`,opacity:h})]})})}),u&&(0,U.jsx)(`span`,{className:`sr-only`,role:`status`,children:r(`items.refreshing`)}),f&&(0,U.jsx)(`p`,{className:`mb-3 text-center text-sm text-[var(--c-danger)]`,role:`alert`,children:r(`items.refreshFailed`)}),e]})}function wd(){let{user:e}=lo(),t=il(ll()),[n,r]=(0,_.useState)(!1),i=!!e?.intro_dismissed_at;return(0,_.useEffect)(()=>{let n=!0;if(r(!1),t&&e&&i)return Promise.resolve(!t.applies||t.applies({id:e.id,email:e.email,display_name:e.display_name??null})).then(e=>{n&&r(e===!0)}).catch(()=>{n&&r(!1)}),()=>{n=!1}},[t?.mount,t?.applies,e?.id,i]),!t||!n?null:(0,U.jsx)(bu,{name:`articles-notice`,mount:t.mount})}function Td(){let{t:e}=R(),{user:t,setCurrentUser:n}=lo(),[r,i]=(0,_.useState)(!1);if(!t||t.intro_dismissed_at)return null;async function a(){i(!0);try{n(await H.dismissIntro())}catch{i(!1)}}let o=[{key:`views`,className:`hidden sm:flex`,icon:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2`}),(0,U.jsx)(`path`,{d:`M18 14h-8`}),(0,U.jsx)(`path`,{d:`M15 18h-5`}),(0,U.jsx)(`path`,{d:`M10 6h8v4h-8V6Z`})]})},{key:`unread`,solid:!0,icon:(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})},{key:`star`,icon:(0,U.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})},{key:`folders`,icon:(0,U.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z`})}];return(0,U.jsxs)(`section`,{className:`card animate-fade-in flex flex-col gap-5 p-5 sm:p-7 shadow-xs`,"aria-labelledby":`intro-title`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h2`,{id:`intro-title`,className:`text-xl sm:text-2xl font-bold tracking-tight text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:e(`intro.title`)}),(0,U.jsx)(`p`,{className:`mt-0.5 text-xs sm:text-sm leading-relaxed text-[var(--c-text-muted)]`,children:e(`intro.subtitle`)})]}),(0,U.jsx)(`button`,{type:`button`,onClick:a,disabled:r,"aria-label":e(`common.close`),className:`shrink-0 rounded-lg p-1 text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,children:(0,U.jsx)(Bu,{})})]}),(0,U.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:o.map(t=>(0,U.jsxs)(`li`,{className:`flex items-start gap-3.5 rounded-2xl border border-[var(--c-border)]/80 bg-[var(--c-surface-hover)]/25 p-4 ${t.className??``}`,children:[(0,U.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text)]`,children:(0,U.jsx)(`svg`,{className:t.solid?`h-3.5 w-3.5`:`h-4 w-4`,viewBox:`0 0 24 24`,fill:t.solid?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:t.solid?2.2:2,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:t.icon})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:e(`intro.${t.key}Title`)}),(0,U.jsx)(`p`,{className:`mt-0.5 text-xs sm:text-sm leading-relaxed text-[var(--c-text-muted)]`,children:e(`intro.${t.key}Text`)})]})]},t.key))}),(0,U.jsx)(`button`,{type:`button`,onClick:a,disabled:r,className:`btn-primary self-start`,children:e(`intro.done`)})]})}var Ed=50;function Dd(){return(0,U.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,U.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]})}var Od=`(max-width: 639px)`;function kd(){return(0,_.useSyncExternalStore)(e=>{let t=window.matchMedia(Od);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},()=>window.matchMedia(Od).matches)}function Ad(){let{t:e,i18n:t}=R(),[n,r]=Li(),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),{syncAllowed:u}=wu(),[d,f]=(0,_.useState)([]),[p,m]=(0,_.useState)([]),[h,g]=(0,_.useState)(!0),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(!1),E=(0,_.useRef)(0),D=(0,_.useRef)(0),O=(0,_.useRef)(!1),[k,A]=(0,_.useState)(null),[j,ee]=(0,_.useState)(()=>{try{return localStorage.getItem(`feedkeeper_items_view`)===`newspaper`?`newspaper`:`list`}catch{return`list`}}),te=kd()?`newspaper`:j;function ne(e){if(e!==j){Ka(),ee(e),window.scrollTo({top:0,behavior:`instant`});try{localStorage.setItem(`feedkeeper_items_view`,e)}catch{}}}let re=`feedkeeper_filter_scope`,M=`feedkeeper_filter_unread`,ie=`feedkeeper_filter_bookmarked`,ae=n.get(`article`),oe=(()=>{let e=n.get(`feed`);if(e)return`feed:${e}`;let t=n.get(`folder`);if(t)return`folder:${t}`;try{let e=localStorage.getItem(re);if(e)return e}catch{}return``})(),se=(()=>{try{let e=localStorage.getItem(M);if(e!==null)return e===`true`}catch{}return!0})(),ce=(()=>{if(n.get(`saved`)===`1`)return!0;if(n.get(`article`))return!1;try{let e=localStorage.getItem(ie);if(e!==null)return e===`true`}catch{}return!1})(),[N,le]=(0,_.useState)(oe),[ue,de]=(0,_.useState)(se),[fe,pe]=(0,_.useState)(ce),me=ue&&!fe,[he,ge]=(0,_.useState)(``),[P,F]=(0,_.useState)(!1),_e=(0,_.useRef)(null),I=(0,_.useRef)(null),ve=(0,_.useRef)(null),[ye,be]=(0,_.useState)(61),[L,xe]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let e=document.querySelector(`[data-app-header]`);if(!e)return;let t=new ResizeObserver(()=>be(e.getBoundingClientRect().height));return t.observe(e),()=>t.disconnect()},[]),(0,_.useEffect)(()=>{function e(){let e=ve.current?.getBoundingClientRect().top;xe(window.scrollY>0&&e!==void 0&&e<=ye+1)}return e(),window.addEventListener(`scroll`,e,{passive:!0}),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e),window.removeEventListener(`resize`,e)}},[ye]),(0,_.useEffect)(()=>{P&&_e.current?.focus()},[P]),(0,_.useEffect)(()=>{let e=window.matchMedia(`(min-width: 640px)`),t=()=>{e.matches&&F(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);function Se(){F(!1),requestAnimationFrame(()=>I.current?.focus())}function Ce(e){Ka(),ge(e)}function we(){Ka(),de(e=>{let t=!e;try{localStorage.setItem(M,String(t))}catch{}return t})}function Te(){Ka(),pe(e=>{let t=!e;try{localStorage.setItem(ie,String(t))}catch{}return t})}(0,_.useEffect)(()=>{if(h||O.current)return;let e=Wa(),t=requestAnimationFrame(()=>{e>0&&window.scrollTo({top:e,behavior:`instant`}),O.current=!0});return()=>cancelAnimationFrame(t)},[h]),(0,_.useEffect)(()=>{function e(){O.current&&document.body.style.overflow!==`hidden`&&Ga(window.scrollY)}return window.addEventListener(`scroll`,e,{passive:!0}),()=>{O.current&&document.body.style.overflow!==`hidden`&&Ga(window.scrollY),window.removeEventListener(`scroll`,e)}},[]),(0,_.useEffect)(()=>{let e=n.get(`feed`),t=n.get(`folder`);if(e){let t=`feed:${e}`;t!==N&&Ka(),le(t);try{localStorage.setItem(re,t)}catch{}}else if(t){let e=`folder:${t}`;e!==N&&Ka(),le(e);try{localStorage.setItem(re,e)}catch{}}else if(oe&&!n.toString()){let e=new URLSearchParams(n);oe.startsWith(`feed:`)?e.set(`feed`,oe.slice(5)):oe.startsWith(`folder:`)&&e.set(`folder`,oe.slice(7)),r(e,{replace:!0})}},[n]);function Ee(e){Ka(),le(e);try{e?localStorage.setItem(re,e):localStorage.removeItem(re)}catch{}let t=new URLSearchParams(n);t.delete(`feed`),t.delete(`folder`),e.startsWith(`feed:`)?t.set(`feed`,e.slice(5)):e.startsWith(`folder:`)&&t.set(`folder`,e.slice(7)),r(t,{replace:!0})}(0,_.useEffect)(()=>{Promise.all([H.listFeeds(),H.listFolders().then(e=>({...e,ok:!0})).catch(()=>({folders:[],ok:!1}))]).then(([e,t])=>{a(e),f(t.folders),l(t.ok),s(!0)}).catch(e=>console.error(`Failed to load initial feeds/folders:`,e))},[]),(0,_.useEffect)(()=>{o&&N&&(N.startsWith(`feed:`)?!i.some(e=>`feed:${e.id}`===N):N.startsWith(`folder:`)&&c&&!d.some(e=>`folder:${e.id}`===N))&&Ee(``)},[o,c,i,d,N]);let De=N.startsWith(`feed:`)?Number(N.slice(5)):void 0,Oe=N.startsWith(`folder:`)?Number(N.slice(7)):void 0,ke=!he&&!fe&&De===void 0&&Oe===void 0,Ae=ke&&i.length>0&&i.every(e=>!e.last_polled_at);async function je(){try{let[e,t]=await Promise.all([H.listFeeds(),H.listFolders().then(e=>({...e,ok:!0})).catch(()=>({folders:[],ok:!1}))]);return e.length===0&&(n.has(`folder`)||n.has(`feed`))&&(r({},{replace:!0}),le(``)),a(e),f(t.folders),l(t.ok),s(!0),e}catch(e){return console.error(`Failed to reload feeds:`,e),null}}async function Me(){await je(),await Ne(),no()}async function Ne(){let e=++E.current;g(!0),y(!1),C(!1),x(!1);try{let t=await H.listItems({feedId:De,folderId:Oe,unreadOnly:me,bookmarkedOnly:fe,search:he||void 0,limit:Ed});e===E.current&&(m(t),D.current=t.length,T(t.length===Ed))}catch(t){e===E.current&&(console.error(`Failed to load items:`,t),y(!0))}finally{e===E.current&&g(!1)}}async function Pe(){if(b||!w)return;let e=E.current,t=me||fe?p.filter(e=>(!me||!e.read)&&(!fe||e.bookmarked)).length:D.current;x(!0),C(!1);try{let n=await H.listItems({feedId:De,folderId:Oe,unreadOnly:me,bookmarkedOnly:fe,search:he||void 0,limit:Ed,offset:t});e===E.current&&(D.current=t+n.length,m(e=>{let t=new Set(e.map(e=>e.id));return[...e,...n.filter(e=>!t.has(e.id))]}),T(n.length===Ed))}catch(t){e===E.current&&(console.error(`Failed to load more items:`,t),C(!0))}finally{e===E.current&&x(!1)}}let Fe=(0,_.useRef)(Pe);Fe.current=Pe;let Ie=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=Ie.current;if(!e||!w||S||b||v)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&Fe.current()},{rootMargin:`600px 0px`});return t.observe(e),()=>t.disconnect()},[w,S,b,v,p.length]),(0,_.useEffect)(()=>{m([]),g(!0),T(!1),x(!1);let e=setTimeout(()=>{Ne()},200);return()=>{clearTimeout(e),E.current++}},[N,ue,fe,he]),(0,_.useEffect)(()=>{if(!Ae)return;let e=0,t=setInterval(()=>{e++,je().then(e=>{e?.some(e=>e.last_polled_at)&&Ne()}),e>=45&&clearInterval(t)},4e3);return()=>clearInterval(t)},[Ae]);let Le=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(ae){let e=p.find(e=>e.id===Number(ae));A(e??null),e&&!e.read&&Le.current!==e.id&&(Le.current=e.id,H.markRead(e.id).then(no).catch(()=>{}),m(t=>t.map(t=>t.id===e.id?{...t,read:!0}:t)))}else A(null)},[ae,p]);function Re(e){A(e),e.read||(H.markRead(e.id).then(no).catch(()=>{}),m(t=>t.map(t=>t.id===e.id?{...t,read:!0}:t)),A({...e,read:!0}));let t=new URLSearchParams(n);t.set(`article`,String(e.id)),r(t)}function ze(){A(null);let e=new URLSearchParams(n);e.delete(`article`),r(e)}let Be=k?p.findIndex(e=>e.id===k.id):-1,Ve=Be>=0&&Be<p.length-1,He=Be>0;function Ue(){Ve&&Re(p[Be+1])}function We(){He&&Re(p[Be-1])}async function Ge(t){try{await t()}catch(t){if(!(t instanceof va&&t.status===0))throw t;K.error(e(`common.offlineAction`))}}async function Ke(e){let t=!e.read;e.read?await H.markUnread(e.id):await H.markRead(e.id),no(),m(n=>n.map(n=>n.id===e.id?{...n,read:t}:n)),k?.id===e.id&&A(e=>e?{...e,read:t}:null)}async function qe(e){let t=!e.bookmarked;e.bookmarked?await H.unbookmarkItem(e.id):await H.bookmarkItem(e.id),window.setTimeout(()=>void Ba({force:!0}),t?2e4:0),m(n=>fe&&!t&&k?.id!==e.id?n.filter(t=>t.id!==e.id):n.map(n=>n.id===e.id?{...n,bookmarked:t}:n)),k?.id===e.id&&A(e=>e?{...e,bookmarked:t}:null)}async function Je(){await Ge(async()=>{await H.markAllRead({feedId:De,folderId:Oe}),await Ne(),no()})}let[Ye,Xe]=(0,_.useState)(!1);async function Ze(){Xe(!0);try{let t=await H.refreshAllFeeds();await Ne(),rd(t,e)}catch{K.error(e(`items.refreshFailed`))}finally{Xe(!1)}}let Qe=new Intl.DateTimeFormat(t.resolvedLanguage,{dateStyle:`medium`}),$e=new Intl.DateTimeFormat(t.resolvedLanguage,{timeStyle:`short`}),et=(0,_.useMemo)(()=>{let t=[{value:``,label:e(`items.allFeeds`)}];if(d.length>0)for(let n of d)t.push({value:`folder:${n.id}`,label:n.name,group:e(`feeds.folderGroup`),badge:n.unread_count});for(let n of i)t.push({value:`feed:${n.id}`,label:n.label??n.title??n.url,group:e(`feeds.feedGroup`),badge:n.unread_count});return t},[d,i,e]),tt=N?et.find(e=>e.value===N)?.label??e(`items.title`):e(`items.allFeeds`);function nt(e){m(t=>t.map(t=>t.id===e.id?{...t,...e}:t)),A(t=>t?.id===e.id?{...t,...e}:t)}let rt=(0,U.jsxs)(`div`,{className:`flex flex-col gap-5 sm:gap-6`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 sm:gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h1`,{className:`sr-only`,children:tt}),(0,U.jsx)(ld,{className:`block`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`relative hidden h-11 w-[220px] shrink-0 grid-cols-2 rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] p-1 sm:grid`,role:`group`,"aria-label":e(`items.viewMode`),children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-1 left-1 w-[calc((100%-0.5rem)/2)] rounded-lg border border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] shadow-sm transition-transform duration-300 ease-[cubic-bezier(0.25,1,0.5,1)] motion-reduce:transition-none`,style:{transform:j===`newspaper`?`translateX(100%)`:`translateX(0)`}}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>ne(`list`),title:e(`items.listView`),"aria-label":e(`items.listView`),"aria-pressed":j===`list`,className:`relative z-10 flex h-full min-w-0 items-center justify-center gap-1.5 rounded-lg text-xs sm:text-sm font-medium transition-colors focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${j===`list`?`text-[var(--c-text)]`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:[(0,U.jsxs)(`svg`,{className:`h-4 w-4 transition-transform duration-200 motion-reduce:transition-none ${j===`list`?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`path`,{d:`M8 6h12M8 12h12M8 18h12`}),(0,U.jsx)(`circle`,{cx:`4`,cy:`6`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`circle`,{cx:`4`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`circle`,{cx:`4`,cy:`18`,r:`1`,fill:`currentColor`,stroke:`none`})]}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:e(`items.listView`)})]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>ne(`newspaper`),title:e(`items.newspaperView`),"aria-label":e(`items.newspaperView`),"aria-pressed":j===`newspaper`,className:`relative z-10 flex h-full min-w-0 items-center justify-center gap-1.5 rounded-lg text-xs sm:text-sm font-medium transition-colors focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${j===`newspaper`?`text-[var(--c-text)]`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:[(0,U.jsxs)(`svg`,{className:`h-4 w-4 transition-transform duration-200 motion-reduce:transition-none ${j===`newspaper`?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`path`,{d:`M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2`}),(0,U.jsx)(`path`,{d:`M18 14h-8`}),(0,U.jsx)(`path`,{d:`M15 18h-5`}),(0,U.jsx)(`path`,{d:`M10 6h8v4h-8V6Z`})]}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:e(`items.newspaperView`)})]})]}),(0,U.jsx)(`button`,{type:`button`,onClick:Ze,disabled:Ye||!u,title:e(u?Ye?`items.refreshing`:`items.refresh`:`plan.unavailable`),"aria-label":e(Ye?`items.refreshing`:`items.refresh`),className:`btn-secondary hidden h-11 w-11 shrink-0 items-center justify-center p-0! sm:flex`,children:(0,U.jsx)(Au,{className:`h-5 w-5 ${Ye?`animate-spin motion-reduce:animate-none`:``}`})}),(0,U.jsx)(`button`,{type:`button`,onClick:Je,title:e(`feeds.markAllRead`),"aria-label":e(`feeds.markAllRead`),className:`btn-secondary flex h-11 w-11 shrink-0 items-center justify-center p-0!`,children:(0,U.jsx)(`svg`,{className:`h-5 w-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:`M3 12l4 4 6-7M11 16l3 0 7-8`})})})]})]}),(0,U.jsxs)(`div`,{ref:ve,className:`sticky z-20 py-2`,style:{top:ye},children:[L&&(0,U.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute -top-px bottom-0 left-1/2 w-screen -translate-x-1/2 border-y border-[var(--c-border)] backdrop-blur-md`,style:{backgroundColor:`color-mix(in srgb, var(--c-surface) 85%, transparent)`}}),(0,U.jsxs)(`div`,{className:`items-toolbar relative z-10 flex items-center gap-2 sm:gap-3 ${P?`items-toolbar-open`:``}`,children:[(0,U.jsx)(`div`,{className:`items-toolbar-scope min-w-0 flex-1 sm:flex-none sm:w-64`,inert:P,children:(0,U.jsx)(Tu,{value:N,onChange:Ee,options:et,className:`w-full`,placeholder:e(`items.allFeeds`)})}),(0,U.jsxs)(`div`,{className:`relative hidden sm:block flex-1 min-w-0`,children:[(0,U.jsx)(`input`,{type:`search`,placeholder:e(`items.searchPlaceholder`),"aria-label":e(`items.searchPlaceholder`),className:`input w-full pl-9 pr-3`,value:he,onChange:e=>Ce(e.target.value)}),(0,U.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none opacity-45 text-[var(--c-text-muted)]`,children:(0,U.jsx)(Dd,{})})]}),(0,U.jsxs)(`div`,{className:`items-toolbar-search relative h-[38px] min-w-0 overflow-hidden sm:hidden`,children:[(0,U.jsx)(`button`,{ref:I,type:`button`,onClick:()=>F(!0),"aria-label":e(`items.searchPlaceholder`),"aria-controls":`mobile-article-search`,"aria-expanded":P,title:e(`items.searchPlaceholder`),"aria-hidden":P,tabIndex:P?-1:0,className:`absolute inset-y-0 left-0 z-10 flex w-[38px] items-center justify-center rounded-lg border transition-opacity duration-150 ${P?`pointer-events-none opacity-0`:he?`border-[var(--c-blue3)] bg-[var(--c-surface-hover)] text-[var(--c-text)] opacity-100`:`border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text-muted)] opacity-100`}`,children:(0,U.jsx)(Dd,{})}),(0,U.jsxs)(`div`,{className:`flex h-full min-w-0 items-center gap-2 transition-opacity duration-200 ${P?`opacity-100 delay-75`:`pointer-events-none opacity-0`}`,inert:!P,children:[(0,U.jsx)(`span`,{className:`pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-[var(--c-text-muted)] opacity-60`,children:(0,U.jsx)(Dd,{})}),(0,U.jsx)(`input`,{id:`mobile-article-search`,ref:_e,type:`search`,placeholder:e(`items.searchPlaceholder`),"aria-label":e(`items.searchPlaceholder`),className:`input min-w-0 flex-1 pl-9`,value:he,onChange:e=>Ce(e.target.value),onKeyDown:e=>{e.key===`Escape`&&Se()}}),(0,U.jsx)(`button`,{type:`button`,onClick:Se,"aria-label":e(`common.close`),title:e(`common.close`),className:`w-[38px] h-[38px] rounded-lg border border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text-muted)] flex items-center justify-center shrink-0 cursor-pointer`,children:(0,U.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,U.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})]}),(0,U.jsxs)(`div`,{className:`items-toolbar-filters flex items-center gap-1.5 sm:gap-2 shrink-0`,inert:P,children:[(0,U.jsx)(`button`,{type:`button`,onClick:Te,title:e(fe?`items.all`:`items.bookmarkedOnly`),"aria-label":e(`items.bookmarkedOnly`),"aria-pressed":fe,className:`w-[38px] h-[38px] rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${fe?`bg-amber-500/15 border-amber-500/40 text-amber-500`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500 hover:border-amber-500/30`}`,children:(0,U.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:fe?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,U.jsx)(`button`,{type:`button`,onClick:we,disabled:fe,title:e(fe?`items.unreadIgnoredInSaved`:ue?`items.all`:`items.unreadOnly`),"aria-label":e(`items.unreadOnly`),"aria-pressed":me,className:`w-[38px] h-[38px] rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer disabled:cursor-default disabled:opacity-40 ${me?`bg-[var(--c-surface-hover)] border-[var(--c-blue3)] text-[var(--c-text)] shadow-xs`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:border-[var(--c-blue3)]`}`,children:(0,U.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:me?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2.2`,children:(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})})]})]})]}),o&&i.length>0&&!u&&(0,U.jsx)(Y,{}),o&&i.length>0&&!v&&(0,U.jsx)(Td,{}),o&&i.length>0&&!v&&(0,U.jsx)(wd,{}),v?(0,U.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3`,children:[(0,U.jsx)(`p`,{style:{color:`var(--c-text-muted)`},children:e(`items.loadFailed`)}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>void Ne(),className:`btn-secondary`,children:e(`common.retry`)})]}):h&&p.length===0?(0,U.jsx)(Su,{size:`lg`}):p.length===0&&o&&i.length===0?(0,U.jsx)($u,{onSubscribed:Me}):p.length===0&&Ae?(0,U.jsxs)(`div`,{role:`status`,className:`card flex flex-col items-center gap-3 px-6 py-12 text-center`,children:[(0,U.jsx)(Su,{size:`lg`}),(0,U.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`welcome.fetchingTitle`)}),(0,U.jsx)(`p`,{className:`max-w-sm text-sm text-[var(--c-text-muted)]`,children:e(`welcome.fetchingHint`)})]}):p.length===0&&ke&&me&&i.length>0?(0,U.jsxs)(`div`,{className:`card flex flex-col items-center gap-3 px-6 py-12 text-center`,children:[(0,U.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`items.allReadTitle`)}),(0,U.jsx)(`p`,{className:`max-w-sm text-sm text-[var(--c-text-muted)]`,children:e(`items.allReadHint`)}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>de(!1),className:`btn-secondary mt-1`,children:e(`items.all`)})]}):p.length===0?(0,U.jsx)(`p`,{style:{color:`var(--c-text-muted)`},children:e(fe&&!he?`items.noSaved`:he?`items.noResults`:`items.noItems`)}):te===`newspaper`?(0,U.jsx)(vd,{items:p,onOpen:Re,onBookmark:qe,onRead:Ke}):(0,U.jsx)(`ul`,{className:`flex flex-col gap-4 sm:gap-5 animate-page-fade`,children:p.map(t=>{let n=t.published_at?new Date(t.published_at):null;return(0,U.jsx)(`li`,{onClick:()=>Re(t),className:`card overflow-hidden p-4 sm:p-0 transition-colors duration-150 hover:bg-[var(--c-surface-hover)] hover:border-[var(--c-blue3)]/60 cursor-pointer group/card`,style:{opacity:t.read?.6:1},children:(0,U.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-stretch justify-between gap-3 sm:gap-0`,children:[t.image_url&&(0,U.jsx)(`div`,{className:`order-first w-[calc(100%+2rem)] -mx-4 -mt-4 sm:m-0 sm:w-52 sm:min-w-52 h-48 sm:h-auto sm:self-stretch overflow-hidden shrink-0 border-b sm:border-b-0 sm:border-r bg-[var(--c-bg)] group transition-opacity hover:opacity-90 block`,style:{borderColor:`var(--c-border)`},children:(0,U.jsx)(`img`,{src:t.image_url,alt:``,className:`w-full h-full object-cover group-hover:scale-105 transition-transform duration-200`,loading:`lazy`,onError:e=>{let t=e.currentTarget.parentElement;t&&(t.style.display=`none`)}})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1 sm:p-5 sm:pr-3 flex flex-col justify-between`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`mb-3 flex min-w-0 items-center gap-2 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:[(0,U.jsx)(zc,{feedId:t.feed_id,iconUrl:t.feed_icon_url,siteUrl:t.feed_site_url,feedUrl:t.feed_url,articleUrl:t.link,className:`w-3.5 h-3.5 rounded-xs shrink-0 object-contain`}),(0,U.jsx)(`span`,{className:`truncate`,children:t.feed_title})]}),(0,U.jsx)(`h2`,{lang:Eo(t.title),className:`text-lg leading-snug font-semibold text-[var(--c-text)]${Eo(t.title)===`ja`?` ja-phrases`:``}`,children:t.title?(0,U.jsx)(Bc,{text:t.title}):null}),(0,U.jsx)(pd,{item:t,className:`mt-3 text-sm leading-relaxed line-clamp-3 text-[var(--c-text-muted)]`})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs pt-5`,style:{color:`var(--c-text-muted)`},children:[(0,U.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 min-w-0`,children:n&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsxs)(`svg`,{className:`w-3.5 h-3.5 shrink-0 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`18`,rx:`2`,ry:`2`}),(0,U.jsx)(`line`,{x1:`16`,y1:`2`,x2:`16`,y2:`6`}),(0,U.jsx)(`line`,{x1:`8`,y1:`2`,x2:`8`,y2:`6`}),(0,U.jsx)(`line`,{x1:`3`,y1:`10`,x2:`21`,y2:`10`})]}),(0,U.jsx)(`span`,{children:Qe.format(n)})]}),(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsxs)(`svg`,{className:`w-3.5 h-3.5 shrink-0 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,U.jsx)(`polyline`,{points:`12 6 12 12 16 14`})]}),(0,U.jsx)(`span`,{children:$e.format(n)})]})]})}),(0,U.jsxs)(`div`,{className:`flex sm:hidden items-center gap-2 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,U.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),qe(t)},title:t.bookmarked?e(`items.unbookmark`):e(`items.bookmark`),"aria-label":t.bookmarked?e(`items.unbookmark`):e(`items.bookmark`),className:`w-8 h-8 rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${t.bookmarked?`bg-amber-500/15 border-amber-500/40 text-amber-500`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500 hover:border-amber-500/30`}`,children:(0,U.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:t.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,U.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Ke(t)},title:t.read?e(`items.markUnread`):e(`items.markRead`),"aria-label":t.read?e(`items.markUnread`):e(`items.markRead`),className:`w-8 h-8 rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${t.read?`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:border-[var(--c-blue3)]`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-blue1)] hover:border-[var(--c-blue3)]`}`,children:(0,U.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:t.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2.2`,children:(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})})]})]})]}),(0,U.jsxs)(`div`,{className:`hidden sm:flex items-center gap-2 pt-5 pr-5 shrink-0 self-start`,onClick:e=>e.stopPropagation(),children:[(0,U.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),qe(t)},title:t.bookmarked?e(`items.unbookmark`):e(`items.bookmark`),"aria-label":t.bookmarked?e(`items.unbookmark`):e(`items.bookmark`),className:`w-9 h-9 rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${t.bookmarked?`bg-amber-500/15 border-amber-500/40 text-amber-500`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500 hover:border-amber-500/30`}`,children:(0,U.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:t.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,U.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Ke(t)},title:t.read?e(`items.markUnread`):e(`items.markRead`),"aria-label":t.read?e(`items.markUnread`):e(`items.markRead`),className:`w-9 h-9 rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${t.read?`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:border-[var(--c-blue3)]`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-blue1)] hover:border-[var(--c-blue3)]`}`,children:(0,U.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:t.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2.2`,children:(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})})]})]})},t.id)})}),!v&&p.length>0&&(w||S)&&(S?(0,U.jsx)(`button`,{type:`button`,onClick:()=>{Pe()},className:`btn-secondary self-center`,children:e(`common.retry`)}):(0,U.jsx)(`div`,{ref:Ie,className:`flex min-h-12 items-center justify-center`,children:b&&(0,U.jsx)(Su,{size:`sm`})})),(0,U.jsx)(Vc,{item:k,isOpen:!!k,onClose:ze,onToggleBookmark:qe,onToggleRead:Ke,onNext:Ue,onPrevious:We,onItemUpdated:nt,hasNext:Ve,hasPrev:He})]});return(0,U.jsx)(Cd,{disabled:h||!u||!!k||P,onRefresh:Ze,children:rt})}function jd(e,t){let n=Math.min(e,t);return{sx:Math.round((e-n)/2),sy:Math.round((t-n)/2),size:n}}async function Md(e){let t=await createImageBitmap(e);try{let{sx:e,sy:n,size:r}=jd(t.width,t.height),i=document.createElement(`canvas`);i.width=256,i.height=256;let a=i.getContext(`2d`);if(!a)throw Error(`canvas_unavailable`);return a.fillStyle=`#ffffff`,a.fillRect(0,0,256,256),a.imageSmoothingQuality=`high`,a.drawImage(t,e,n,r,r,0,0,256,256),await new Promise((e,t)=>{i.toBlob(n=>n?e(n):t(Error(`encode_failed`)),`image/jpeg`,.88)})}finally{t.close()}}function Nd({title:e,description:t,children:n,footer:r}){return(0,U.jsxs)(`section`,{className:`card`,children:[(e||t)&&(0,U.jsxs)(`header`,{className:`px-5 pt-5 pb-1 sm:px-6`,children:[e&&(0,U.jsx)(`h3`,{className:`text-base font-semibold`,children:e}),t&&(0,U.jsx)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:t})]}),(0,U.jsx)(`div`,{className:`divide-y divide-[var(--c-border)]`,children:n}),r&&(0,U.jsx)(`footer`,{className:`flex flex-wrap items-center justify-end gap-3 border-t border-[var(--c-border)] px-5 py-4 sm:px-6`,children:r})]})}function Pd({label:e,hint:t,htmlFor:n,children:r,stacked:i=!1,inline:a=!1}){return(0,U.jsxs)(`div`,{className:`flex gap-3 px-5 py-4 sm:px-6 ${i?`flex-col`:a?`flex-row items-center justify-between gap-4 sm:gap-6`:`flex-col sm:flex-row sm:items-center sm:justify-between sm:gap-6`}`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`label`,{htmlFor:n,className:`text-sm font-medium`,children:e}),t&&(0,U.jsx)(`p`,{className:`mt-0.5 text-sm text-[var(--c-text-muted)]`,children:t})]}),r&&(0,U.jsx)(`div`,{className:i?``:`shrink-0`,children:r})]})}function Fd({children:e}){return(0,U.jsx)(`div`,{className:`px-5 py-4 sm:px-6`,children:e})}function Id({id:e,checked:t,onChange:n,label:r}){return(0,U.jsxs)(`label`,{className:`relative inline-flex cursor-pointer items-center`,children:[(0,U.jsx)(`input`,{id:e,type:`checkbox`,className:`peer sr-only`,checked:t,onChange:e=>n(e.target.checked),"aria-label":r}),(0,U.jsx)(`span`,{className:`h-6 w-11 rounded-full bg-[var(--c-border)] transition-colors peer-checked:bg-[var(--c-blue1)] peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-[var(--c-blue3)] after:absolute after:left-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:bg-white after:shadow-sm after:transition-transform after:content-[''] peer-checked:after:translate-x-5`})]})}function Ld({message:e}){return e?(0,U.jsx)(`p`,{role:`status`,className:`text-sm ${e.type===`error`?`text-danger`:`text-[var(--c-green3)]`}`,children:e.text}):null}function Rd({title:e,description:t}){return(0,U.jsxs)(`div`,{className:`mb-5`,children:[(0,U.jsx)(`h2`,{className:`text-xl font-semibold`,children:e}),t&&(0,U.jsx)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:t})]})}var zd=o(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),Bd=o((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),Vd=o((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),Hd=o(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Ud=o(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Wd=o((e=>{var t=Bd().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),Gd=o((e=>{var t=Bd().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Kd=o((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),qd=o((e=>{var t=Vd(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),Jd=o((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Yd=o((e=>{var t=Jd();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),Xd=o(((e,t)=>{var n=Yd();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),Zd=o((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Qd=o((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
|
|
97
97
|
]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^[0-9]+$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),$d=o((e=>{var t=Zd(),n=Qd();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),ef=o((e=>{var t=Bd(),n=qd(),r=Vd(),i=$d(),a=Zd(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),tf=o((e=>{var t=Bd(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),nf=o(((e,t)=>{var n=$d();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),rf=o(((e,t)=>{var n=$d(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t=0;for(;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),af=o(((e,t)=>{var n=$d();function r(e){this.mode=n.BYTE,this.data=typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),of=o(((e,t)=>{var n=$d(),r=Bd();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t=0;for(;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
|
|
98
98
|
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),sf=o(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),cf=o((e=>{var t=$d(),n=nf(),r=rf(),i=af(),a=of(),o=Qd(),s=Bd(),c=sf();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
|
|
99
99
|
Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),lf=o((e=>{var t=Bd(),n=Vd(),r=Hd(),i=Ud(),a=Wd(),o=Gd(),s=Kd(),c=qd(),l=Xd(),u=ef(),d=tf(),f=$d(),p=cf();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
|
package/web/dist/index.html
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
<meta name="twitter:image" content="/logo.svg" />
|
|
31
31
|
<!-- Inline so the splash paints before any script or stylesheet loads -->
|
|
32
32
|
<style>html{background:#f8fafc}html[data-theme=dark]{background:#0b0f17}@media (prefers-color-scheme:dark){html:not([data-theme=light]){background:#0b0f17}}#splash{z-index:100;background:inherit;justify-content:center;align-items:center;transition:opacity .3s;display:flex;position:fixed;inset:0}#splash img{width:62px;height:62px;animation:.4s both splash-in}#splash.splash-hidden{opacity:0;pointer-events:none}@keyframes splash-in{0%{opacity:0;transform:scale(.92)}}@media (prefers-reduced-motion:reduce){#splash,#splash img{transition:none;animation:none}}</style>
|
|
33
|
-
<script type="module" crossorigin src="/assets/index-
|
|
33
|
+
<script type="module" crossorigin src="/assets/index-DX6YOuhF.js"></script>
|
|
34
34
|
<link rel="stylesheet" crossorigin href="/assets/index-C4E4b1Mp.css">
|
|
35
35
|
</head>
|
|
36
36
|
<body>
|
package/web/dist/sw.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// FeedKeeper service worker. Built into dist/sw.js, where the placeholder below is
|
|
2
2
|
// replaced with a hash of the build's file names so every release gets its own app cache.
|
|
3
|
-
const BUILD_ID = "
|
|
3
|
+
const BUILD_ID = "da7d638d3952";
|
|
4
4
|
const STATIC_CACHE = `fk-static-${BUILD_ID}`;
|
|
5
5
|
const API_CACHE = "fk-api";
|
|
6
6
|
let privateGeneration = 0;
|