@dvina/artifact-renderer-viewer 0.0.46 → 0.0.47
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.
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DzCiO5xC.js","assets/react-vendor-Dhb16r3m.js","assets/mermaid.core-UUGPJ6yi.js","assets/pdf-renderer-DUYqGnQu.js","assets/pdf-vendor-Cxe0BN_5.js","assets/jszip-vendor-D1v1h9Q9.js","assets/pptx-renderer-DPSAG5_x.js","assets/docx-renderer-Bws5M_Ee.js","assets/docx-vendor-DalbKGQU.js","assets/spreadsheet-renderer-WVtOHmRi.js","assets/xlsx-vendor-BUW7exb-.js","assets/zip-renderer-oijmTXXF.js","assets/epub-renderer-C-aCqy3m.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as h,d as yt,j as v,_ as se,e as Ut,v as _n,o as he,u as me,i as Ye,n as Ae,k as Re,l as Dn,t as qt,E as On,m as Ze,p as ye,q as J,x as Fn,y as zn,z as oe,A as _e,B as $n,C as xe,D as ue,F as Vn,M as Un,G as qn}from"./react-vendor-Dhb16r3m.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(o){if(o.ep)return;o.ep=!0;const a=n(o);fetch(o.href,a)}})();const Hn=["ui/message","ui/open-link","dvina/open-target"];function Te(e){return e==="html"||e==="widget"}const Ht="dvina-artifact-renderer",Me="1.0",Bn=new Set(["viewer.init","viewer.load-document","viewer.set-theme","viewer.set-safe-area","viewer.go-to-page","viewer.send-artifact-data","viewer.append-html","viewer.complete-html-stream","viewer.abort-html-stream","viewer.widget-response"]),Wn=new Set(["viewer.ready","viewer.document-loaded","viewer.page-changed","viewer.artifact-event","viewer.widget-request","viewer.resize","viewer.scroll","viewer.telemetry","viewer.error","viewer.unsupported"]),Gn=new Set(["viewer.ack"]);function _(e){return typeof e=="object"&&e!==null}function j(e){return typeof e=="string"&&e.length>0}function Xn(e){return Array.isArray(e)&&e.every(j)}function Kn(e){return e==="load-document"||e==="pagination"||e==="resize-notifications"||e==="artifact-runtime"}function Yn(e){return e==="allow-downloads"||e==="allow-forms"||e==="allow-modals"||e==="allow-pointer-lock"||e==="allow-popups"||e==="allow-popups-to-escape-sandbox"||e==="allow-same-origin"||e==="allow-scripts"||e==="allow-top-navigation-by-user-activation"}function Bt(e){return e==="pdf"||e==="pptx"||e==="docx"||e==="xls"||e==="xlsx"||e==="csv"||e==="audio"||e==="image"||e==="video"||e==="zip"||e==="epub"||e==="text"||e==="code"||e==="html"||e==="markdown"||e==="mermaid"||e==="json"||e==="jsonl"||e==="ndjson"||e==="tsv"||e==="xml"||e==="toml"||e==="ini"||e==="dotenv"||e==="yaml"||e==="widget"||e==="unknown"}function ae(e){return e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.every(ae):_(e)?Object.values(e).every(ae):!1}function Je(e){return _(e)&&!Array.isArray(e)&&["top","right","bottom","left"].every(t=>{const n=e[t];return n===void 0||typeof n=="number"&&Number.isFinite(n)&&n>=0})}function Qe(e){if(!_(e)||e.mode!=="light"&&e.mode!=="dark")return!1;const t=n=>n===void 0||_(n)&&Object.values(n).every(r=>r===void 0||typeof r=="string");return t(e.tokens)&&t(e.variables)}function Wt(e){if(!_(e))return!1;const t=e.source;if(!_(t))return!1;const n=t.kind==="url"&&j(t.url)||t.kind==="session"&&j(t.url)&&j(t.sessionId)||t.kind==="stream",r=e.renderOptions,o=r===void 0||_(r)&&(r.spreadsheetMode===void 0||r.spreadsheetMode==="fast"||r.spreadsheetMode==="styled")&&(r.codeLanguage===void 0||j(r.codeLanguage))&&(r.html===void 0||_(r.html)&&(r.html.revisionId===void 0||j(r.html.revisionId))&&(r.html.artifactData===void 0||ae(r.html.artifactData))&&(r.html.bootstrap===void 0||r.html.bootstrap==="auto"||r.html.bootstrap==="off")&&(r.html.execution===void 0||r.html.execution==="document"||r.html.execution==="stream")&&(r.html.sandbox===void 0||Array.isArray(r.html.sandbox)&&r.html.sandbox.every(Yn)))&&(r.widget===void 0||Zn(r.widget));return j(e.id)&&j(e.name)&&Bt(e.format)&&n&&o&&(e.mimeType===void 0||typeof e.mimeType=="string")&&(e.size===void 0||typeof e.size=="number")}function Zn(e){if(!_(e))return!1;const t=e.kit,n=t===void 0||t===!1||_(t)&&["css","script","reactScript"].every(r=>t[r]===void 0||typeof t[r]=="string");return(e.kind===void 0||e.kind==="html"||e.kind==="react")&&(e.layout===void 0||e.layout==="inline"||e.layout==="panel")&&n&&(e.bridge===void 0||typeof e.bridge=="boolean")&&(e.data===void 0||typeof e.data=="boolean")&&(e.pictures===void 0||typeof e.pictures=="boolean")&&(e.viewportHeight===void 0||typeof e.viewportHeight=="number"&&Number.isFinite(e.viewportHeight)&&e.viewportHeight>0)&&(e.labels===void 0||_(e.labels)&&Object.values(e.labels).every(r=>r===void 0||typeof r=="string"))&&(e.revisionId===void 0||j(e.revisionId))&&(e.artifactData===void 0||ae(e.artifactData))}function Gt(e){return _(e)&&j(e.token)&&j(e.expiresAt)&&Xn(e.scopes)}function Jn(e){return _(e)&&j(e.name)&&j(e.origin)&&j(e.sdkVersion)}function Qn(e){return e==="format-not-supported"||e==="encrypted-document"||e==="missing-renderer"||e==="feature-not-available"}function er(e){return e==="invalid-message"||e==="origin-mismatch"||e==="session-expired"||e==="document-fetch-failed"||e==="renderer-failed"||e==="timeout"}function tr(e){return e==="info"||e==="warn"||e==="error"}function nr(e){return _(e)&&j(e.viewerVersion)&&Array.isArray(e.supportedProtocolVersions)&&e.supportedProtocolVersions.every(t=>t===Me)&&Array.isArray(e.capabilities)&&e.capabilities.every(Kn)}function rr(e){return _(e)&&Wt(e.document)&&(e.theme===void 0||Qe(e.theme))&&(e.safeArea===void 0||Je(e.safeArea))&&(e.scrollProgressDistance===void 0||vr(e.scrollProgressDistance))&&(e.session===void 0||Gt(e.session))&&Jn(e.host)}function ir(e){return _(e)&&Wt(e.document)&&(e.theme===void 0||Qe(e.theme))&&(e.safeArea===void 0||Je(e.safeArea))&&(e.session===void 0||Gt(e.session))}function or(e){return _(e)&&typeof e.page=="number"&&Number.isInteger(e.page)&&e.page>0}function ar(e){return _(e)&&Qe(e.theme)}function sr(e){return _(e)&&(e.documentId===void 0||j(e.documentId))&&ae(e.data)}function lr(e){return _(e)&&(e.documentId===void 0||j(e.documentId))&&j(e.html)&&(e.sequence===void 0||typeof e.sequence=="number"&&Number.isInteger(e.sequence)&&e.sequence>=0)}function cr(e){return _(e)&&(e.documentId===void 0||j(e.documentId))}function ur(e){return _(e)&&(e.documentId===void 0||j(e.documentId))&&(e.reason===void 0||j(e.reason))}function dr(e){return _(e)&&j(e.documentId)&&Bt(e.format)&&j(e.title)&&(e.pageCount===void 0||typeof e.pageCount=="number")}function fr(e){return _(e)&&typeof e.page=="number"&&(e.pageCount===void 0||typeof e.pageCount=="number")}function pr(e){return _(e)&&j(e.documentId)&&j(e.name)&&(e.detail===void 0||ae(e.detail))}const mr=new Set(["ui/message","ui/open-link","dvina/open-target","ui/update-model-context","dvina/call"]);function Xt(e){return typeof e=="string"&&mr.has(e)}function Kt(e,t){if(!_(t)||Array.isArray(t)||!ae(t))return!1;switch(e){case"ui/message":return t.role==="user"&&Array.isArray(t.content)&&t.content.length>0&&t.content.every(n=>_(n)&&n.type==="text"&&j(n.text));case"ui/open-link":return j(t.url)&&/^https?:\/\//i.test(t.url);case"dvina/open-target":return j(t.kind)&&j(t.id);case"ui/update-model-context":return"structuredContent"in t;case"dvina/call":return j(t.name)}}function hr(e){return _(e)&&j(e.documentId)&&j(e.requestId)&&Xt(e.method)&&Kt(e.method,e.params)}function gr(e){return _(e)&&j(e.requestId)&&(e.result===void 0||ae(e.result))&&(e.error===void 0||_(e.error)&&j(e.error.code)&&typeof e.error.message=="string")}function vr(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function br(e){return _(e)&&typeof e.progress=="number"&&e.progress>=0&&e.progress<=1}function wr(e){return _(e)&&typeof e.height=="number"&&(e.reason==="content"||e.reason==="viewport"||e.reason==="renderer")}function xr(e){return _(e)&&j(e.name)&&tr(e.level)&&j(e.message)&&(e.context===void 0||_(e.context)&&Object.values(e.context).every(t=>t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"))}function yr(e){return _(e)&&j(e.documentId)&&Qn(e.reason)&&j(e.message)}function kr(e){return _(e)&&(e.documentId===void 0||j(e.documentId))&&er(e.code)&&j(e.message)&&typeof e.recoverable=="boolean"}function Er(e){return _(e)&&(e.status==="accepted"||e.status==="rejected")&&(e.reason===void 0||j(e.reason))}const Ar={"viewer.ready":nr,"viewer.init":rr,"viewer.load-document":ir,"viewer.set-theme":ar,"viewer.set-safe-area":e=>_(e)&&Je(e.safeArea),"viewer.go-to-page":or,"viewer.send-artifact-data":sr,"viewer.append-html":lr,"viewer.complete-html-stream":cr,"viewer.abort-html-stream":ur,"viewer.widget-response":gr,"viewer.widget-request":hr,"viewer.document-loaded":dr,"viewer.page-changed":fr,"viewer.artifact-event":pr,"viewer.resize":wr,"viewer.scroll":br,"viewer.telemetry":xr,"viewer.error":kr,"viewer.unsupported":yr,"viewer.ack":Er};function Yt(e){return typeof e=="string"&&Bn.has(e)}function Sr(e){return typeof e=="string"&&Wn.has(e)}function Zt(e){return typeof e=="string"&&Gn.has(e)}function Lr(e){return Yt(e)||Sr(e)||Zt(e)}function Cr(e){return _(e)&&e.channel===Ht&&e.version===Me&&j(e.instanceId)&&j(e.messageId)&&Lr(e.type)&&typeof e.timestamp=="number"&&"payload"in e}function Ir(e){if(!Cr(e))return!1;if(Zt(e.type)){if(!j(e.requestId))return!1}else if("requestId"in e&&e.requestId!==void 0)return!1;return Ar[e.type](e.payload)}function Rr(e){return Ir(e)&&Yt(e.type)}function Tr(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`viewer-${Math.random().toString(36).slice(2,10)}`}function Q(e){return{channel:Ht,version:Me,messageId:e.messageId??Tr(),timestamp:e.timestamp??Date.now(),...e}}function Jt(e,t){if(e.source.kind==="stream")return null;const n=e.source.url;if(!n)return null;const r=new Headers;let o=!1;return t!=null&&t.token&&(r.set("Authorization",`Bearer ${t.token}`),o=!0),{url:n,init:o?{headers:r}:void 0}}const jr={inline:!1,tokensCss:`@layer dvina-tokens,theme,base,dvina,components,utilities;@layer dvina-tokens{:root{color-scheme:light;--dv-font-offset: 0px;--dv-font-text: "Inter", sans-serif;--dv-font-heading: "Inter Tight", "Inter", sans-serif;--dv-font-display: "Manrope", system-ui, sans-serif;--dv-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--dv-text-xs: calc(var(--dv-font-offset) + .75rem);--dv-text-xs-leading: calc(16 / 12);--dv-text-s: calc(var(--dv-font-offset) + .8125rem);--dv-text-s-leading: calc(20 / 13);--dv-text-m: calc(var(--dv-font-offset) + .9375rem);--dv-text-m-leading: calc(22 / 15);--dv-text-l: calc(var(--dv-font-offset) + 1.0625rem);--dv-text-l-leading: calc(28 / 17);--dv-ui-xs: calc(var(--dv-font-offset) + .75rem);--dv-ui-s: calc(var(--dv-font-offset) + .8125rem);--dv-ui-m: calc(var(--dv-font-offset) + 1rem);--dv-ui-l: calc(var(--dv-font-offset) + 1.0625rem);--dv-caption: calc(var(--dv-font-offset) + .65rem);--dv-display: calc(var(--dv-font-offset) + 1.875rem);--dv-display-leading: 1.08;--dv-page: #fff;--dv-panel: color-mix(in srgb, #fff, #f3f3f3 35%);--dv-surface: #fff;--dv-surface-muted: #f3f3f3;--dv-surface-sunk: color-mix(in srgb, #fff, #f3f3f3 50%);--dv-fill: rgba(0, 0, 0, .04);--dv-fill-hover: rgba(0, 0, 0, .05);--dv-fill-strong: rgba(0, 0, 0, .08);--dv-glass: color-mix(in srgb, color-mix(in srgb, #fff, #f3f3f3 50%), transparent 30%);--dv-glass-tint: color-mix(in srgb, color-mix(in srgb, #fff, #f3f3f3 50%), transparent 30%);--dv-popover: color-mix(in srgb, color-mix(in srgb, color-mix(in srgb, #fff, #f3f3f3 50%), transparent 30%) 75%, #fff);--dv-segment-puck: #e7e7e9;--dv-switch-on: rgba(0, 0, 0, .82);--dv-text: rgb(46 46 46);--dv-text-muted: rgb(107 109 128);--dv-text-faint: rgb(127 127 127);--dv-link: #0a6e8c;--dv-link-hover: #085a73;--dv-border: rgba(0, 0, 0, .075);--dv-border-strong: rgba(0, 0, 0, .1);--dv-border-hover: rgba(0, 0, 0, .16);--dv-ring: rgba(51, 51, 51, .64);--dv-accent: rgba(0, 0, 0, .82);--dv-accent-hover: rgba(0, 0, 0, .9);--dv-on-accent: #fff;--dv-brand: #4c99f6;--dv-on-brand: rgb(255 255 255);--dv-positive: rgb(74 201 155);--dv-positive-pale: rgba(74, 201, 155, .12);--dv-positive-text: color-mix(in srgb, rgb(74 201 155) 35%, rgb(46 46 46));--dv-negative: #ff3b30;--dv-negative-pale: rgb(255 59 48 / .08);--dv-negative-text: color-mix(in srgb, #ff3b30 35%, rgb(46 46 46));--dv-warning: rgb(255 199 0);--dv-warning-pale: rgba(255, 199, 0, .12);--dv-warning-text: #946200;--dv-info: rgb(112 182 246);--dv-info-pale: rgba(126, 190, 247, .3);--dv-info-text: color-mix(in srgb, rgb(112 182 246) 35%, rgb(46 46 46));--dv-highlight: rgba(255, 199, 0, .12);--dv-chart-1: #4c99f6;--dv-red: #ff3b30;--dv-orange: #ff9500;--dv-yellow: #ffcc00;--dv-green: #34c759;--dv-teal: #30b0c7;--dv-blue: #0084f7;--dv-indigo: #5856d6;--dv-purple: #af52de;--dv-pink: #ff2d55;--dv-gray: #8e8e93;--dv-radius-xs: calc(.75rem - 8px) ;--dv-radius-s: calc(.75rem - 4px) ;--dv-radius-m: .75rem;--dv-radius-l: 1.5rem ;--dv-radius-pill: 999px;--dv-stroke: 1.6px;--dv-space-1: .25rem;--dv-space-2: .5rem;--dv-space-3: .75rem;--dv-space-4: 1rem;--dv-space-5: 1.25rem;--dv-space-6: 1.5rem;--dv-space-8: 2rem;--dv-space-10: 2.5rem;--dv-control-s: 2rem;--dv-control-m: 2.75rem;--dv-control-l: 3.5rem;--dv-disabled-opacity: .5;--dv-shadow-surface: 0px 0px 0px 1px rgb(0 0 0 / .055);--dv-shadow-control: 0px 0px 0px 1px rgb(0 0 0 / .055), 0px 1px 1px -.5px rgb(0 0 0 / .055);--dv-shadow-raised: 0 .25rem 1.25rem rgba(0, 0, 0, .1);--dv-duration: .1s;--dv-duration-slow: calc(.1s / .6);--dv-ease: cubic-bezier(.2, 0, .4, .9);--dv-ease-emphasized: cubic-bezier(.22, 1, .36, 1);--dv-ease-soft: cubic-bezier(.2, .8, .2, 1);--dv-chart-2: #50cca2;--dv-chart-3: #ccac53;--dv-chart-4: #cc7485;--dv-chart-5: #93a4cc;--dv-chart-6: #cccc2e;--dv-chart-7: #3cc2a8;--dv-chart-8: #cca569}:root[data-theme-mode=dark]{color-scheme:dark;--dv-page: #0a0a0a;--dv-panel: color-mix(in srgb, #0a0a0a, #222324 35%);--dv-surface: #292929;--dv-surface-muted: #222324;--dv-surface-sunk: #222324;--dv-fill: rgba(255, 255, 255, .08);--dv-fill-hover: rgba(255, 255, 255, .05);--dv-fill-strong: rgba(255, 255, 255, .24);--dv-glass: color-mix(in srgb, color-mix(in srgb, #0a0a0a, #222324 50%), transparent 15%);--dv-glass-tint: color-mix(in srgb, #2f3133, transparent 40%);--dv-popover: color-mix(in srgb, color-mix(in srgb, #2f3133, transparent 40%) 70%, #0a0a0a);--dv-segment-puck: #3a3a3c;--dv-switch-on: #4591f7;--dv-text: rgb(230 230 230);--dv-text-muted: rgb(186 186 186);--dv-text-faint: rgb(133 133 133);--dv-link: #7098be;--dv-link-hover: #6093c4;--dv-border: rgba(206, 206, 206, .075);--dv-border-strong: rgba(255, 255, 255, .1);--dv-border-hover: rgba(255, 255, 255, .15);--dv-ring: rgba(255, 255, 255, .64);--dv-accent: #ededed;--dv-accent-hover: #fff;--dv-on-accent: #0a0a0a;--dv-brand: #4591f7;--dv-positive-pale: rgba(74, 201, 155, .32);--dv-positive-text: color-mix(in srgb, rgb(74 201 155) 100%, rgb(230 230 230));--dv-negative: #ff453a;--dv-negative-pale: rgb(255 69 58 / .2);--dv-negative-text: color-mix(in srgb, #ff453a 100%, rgb(230 230 230));--dv-warning-pale: rgba(255, 199, 0, .32);--dv-warning-text: rgb(255 199 0);--dv-info-pale: rgba(102, 141, 176, .3);--dv-info-text: color-mix(in srgb, rgb(112 182 246) 100%, rgb(230 230 230));--dv-highlight: rgba(255, 199, 0, .32);--dv-chart-1: #4591f7;--dv-red: #ff453a;--dv-orange: #ff9f0a;--dv-yellow: #ffd60a;--dv-green: #30d158;--dv-teal: #40c8e0;--dv-blue: #0292ff;--dv-indigo: #5e5ce6;--dv-purple: #bf5af2;--dv-pink: #ff375f;--dv-gray: #98989d;--dv-shadow-surface: inset 0 1px 0 0 rgba(255, 255, 255, .05), inset 0 0 0 1px rgba(255, 255, 255, .02), 0 0 0 1px rgba(0, 0, 0, .12), 0 1px 1px -.5px rgba(0, 0, 0, .18), 0 3px 3px -1.5px rgba(0, 0, 0, .18);--dv-shadow-control: inset 0 1px 0 0 rgba(255, 255, 255, .05), inset 0 0 0 1px rgba(255, 255, 255, .04), 0 0 0 1px rgba(0, 0, 0, .14), 0 1px 1px -.5px rgba(0, 0, 0, .18), 0 3px 3px -1.5px rgba(0, 0, 0, .18), 0 6px 6px -3px rgba(0, 0, 0, .18);--dv-shadow-raised: inset 0 1px 0 0 rgba(255, 255, 255, .05), inset 0 0 0 1px rgba(255, 255, 255, .04), 0 0 0 1px rgba(0, 0, 0, .14), 0 1px 1px -.5px rgba(0, 0, 0, .18), 0 3px 3px -1.5px rgba(0, 0, 0, .18), 0 6px 6px -3px rgba(0, 0, 0, .18);--dv-chart-2: #b5ead7;--dv-chart-3: #ffdfba;--dv-chart-4: #ffb3ba;--dv-chart-5: #c7ceea;--dv-chart-6: #ffffba;--dv-chart-7: #a1d9ce;--dv-chart-8: #ffdac1}@media(prefers-color-scheme:dark){:root:not([data-theme-mode]){color-scheme:dark;--dv-page: #0a0a0a;--dv-panel: color-mix(in srgb, #0a0a0a, #222324 35%);--dv-surface: #292929;--dv-surface-muted: #222324;--dv-surface-sunk: #222324;--dv-fill: rgba(255, 255, 255, .08);--dv-fill-hover: rgba(255, 255, 255, .05);--dv-fill-strong: rgba(255, 255, 255, .24);--dv-glass: color-mix(in srgb, color-mix(in srgb, #0a0a0a, #222324 50%), transparent 15%);--dv-glass-tint: color-mix(in srgb, #2f3133, transparent 40%);--dv-popover: color-mix(in srgb, color-mix(in srgb, #2f3133, transparent 40%) 70%, #0a0a0a);--dv-segment-puck: #3a3a3c;--dv-switch-on: #4591f7;--dv-text: rgb(230 230 230);--dv-text-muted: rgb(186 186 186);--dv-text-faint: rgb(133 133 133);--dv-link: #7098be;--dv-link-hover: #6093c4;--dv-border: rgba(206, 206, 206, .075);--dv-border-strong: rgba(255, 255, 255, .1);--dv-border-hover: rgba(255, 255, 255, .15);--dv-ring: rgba(255, 255, 255, .64);--dv-accent: #ededed;--dv-accent-hover: #fff;--dv-on-accent: #0a0a0a;--dv-brand: #4591f7;--dv-positive-pale: rgba(74, 201, 155, .32);--dv-positive-text: color-mix(in srgb, rgb(74 201 155) 100%, rgb(230 230 230));--dv-negative: #ff453a;--dv-negative-pale: rgb(255 69 58 / .2);--dv-negative-text: color-mix(in srgb, #ff453a 100%, rgb(230 230 230));--dv-warning-pale: rgba(255, 199, 0, .32);--dv-warning-text: rgb(255 199 0);--dv-info-pale: rgba(102, 141, 176, .3);--dv-info-text: color-mix(in srgb, rgb(112 182 246) 100%, rgb(230 230 230));--dv-highlight: rgba(255, 199, 0, .32);--dv-chart-1: #4591f7;--dv-red: #ff453a;--dv-orange: #ff9f0a;--dv-yellow: #ffd60a;--dv-green: #30d158;--dv-teal: #40c8e0;--dv-blue: #0292ff;--dv-indigo: #5e5ce6;--dv-purple: #bf5af2;--dv-pink: #ff375f;--dv-gray: #98989d;--dv-shadow-surface: inset 0 1px 0 0 rgba(255, 255, 255, .05), inset 0 0 0 1px rgba(255, 255, 255, .02), 0 0 0 1px rgba(0, 0, 0, .12), 0 1px 1px -.5px rgba(0, 0, 0, .18), 0 3px 3px -1.5px rgba(0, 0, 0, .18);--dv-shadow-control: inset 0 1px 0 0 rgba(255, 255, 255, .05), inset 0 0 0 1px rgba(255, 255, 255, .04), 0 0 0 1px rgba(0, 0, 0, .14), 0 1px 1px -.5px rgba(0, 0, 0, .18), 0 3px 3px -1.5px rgba(0, 0, 0, .18), 0 6px 6px -3px rgba(0, 0, 0, .18);--dv-shadow-raised: inset 0 1px 0 0 rgba(255, 255, 255, .05), inset 0 0 0 1px rgba(255, 255, 255, .04), 0 0 0 1px rgba(0, 0, 0, .14), 0 1px 1px -.5px rgba(0, 0, 0, .18), 0 3px 3px -1.5px rgba(0, 0, 0, .18), 0 6px 6px -3px rgba(0, 0, 0, .18);--dv-chart-2: #b5ead7;--dv-chart-3: #ffdfba;--dv-chart-4: #ffb3ba;--dv-chart-5: #c7ceea;--dv-chart-6: #ffffba;--dv-chart-7: #a1d9ce;--dv-chart-8: #ffdac1}}@media not (min-width:48rem){:root{--dv-text-m: calc(var(--dv-font-offset) + .875rem);--dv-text-m-leading: calc(20 / 14)}}}
|
|
3
|
+
`,kitCss:new URL("widget-kit-HGTdzr-B.css",import.meta.url).href,kitScript:new URL("widget-kit-BBNeO9Gd.js",import.meta.url).href,kitReactScript:new URL("widget-kit-react-BMDV86-w.js",import.meta.url).href,tailwindScript:new URL("widget-tailwind-aFST5_Zt.js",import.meta.url).href,tailwindCss:`/*
|
|
4
|
+
* Tailwind for React artifacts (never inline widgets): Tailwind's theme and utilities over the kit's --dv-* tokens,
|
|
5
|
+
* without its preflight (the kit styles bare elements) and without its palette, so every colour is one of ours and a
|
|
6
|
+
* class follows light and dark with the tokens. Read as \`<style type="text/tailwindcss">\` by the browser build.
|
|
7
|
+
*
|
|
8
|
+
* Layers (declared first in kit.css): theme, base, dvina (the kit), components, utilities, so a utility wins over
|
|
9
|
+
* the kit's styling of the element it is on.
|
|
10
|
+
*/
|
|
11
|
+
@import "tailwindcss/theme.css" layer(theme);
|
|
12
|
+
@import "tailwindcss/utilities.css" layer(utilities);
|
|
13
|
+
|
|
14
|
+
/* Dark is the engine's mode attribute, not the system's preference. */
|
|
15
|
+
@custom-variant dark (&:where([data-theme-mode="dark"], [data-theme-mode="dark"] *));
|
|
16
|
+
|
|
17
|
+
@theme inline {
|
|
18
|
+
/* Ours only: Tailwind's palette, fonts, sizes, radii, shadows and easings are cleared first. */
|
|
19
|
+
--color-*: initial;
|
|
20
|
+
--font-*: initial;
|
|
21
|
+
--text-*: initial;
|
|
22
|
+
--radius-*: initial;
|
|
23
|
+
--shadow-*: initial;
|
|
24
|
+
--inset-shadow-*: initial;
|
|
25
|
+
--drop-shadow-*: initial;
|
|
26
|
+
--ease-*: initial;
|
|
27
|
+
|
|
28
|
+
--color-transparent: transparent;
|
|
29
|
+
--color-current: currentColor;
|
|
30
|
+
--color-white: #fff;
|
|
31
|
+
--color-black: #000;
|
|
32
|
+
|
|
33
|
+
/* Grounds: bg-page, bg-panel, bg-surface (a card), bg-surface-muted, bg-sunk, bg-fill (a quiet control),
|
|
34
|
+
bg-fill-hover, bg-fill-strong, bg-glass, bg-popover. */
|
|
35
|
+
--color-page: var(--dv-page);
|
|
36
|
+
--color-panel: var(--dv-panel);
|
|
37
|
+
--color-surface: var(--dv-surface);
|
|
38
|
+
--color-surface-muted: var(--dv-surface-muted);
|
|
39
|
+
--color-sunk: var(--dv-surface-sunk);
|
|
40
|
+
--color-fill: var(--dv-fill);
|
|
41
|
+
--color-fill-hover: var(--dv-fill-hover);
|
|
42
|
+
--color-fill-strong: var(--dv-fill-strong);
|
|
43
|
+
--color-glass: var(--dv-glass);
|
|
44
|
+
--color-popover: var(--dv-popover);
|
|
45
|
+
|
|
46
|
+
/* Text: text-foreground, text-muted, text-faint, text-link. */
|
|
47
|
+
--color-foreground: var(--dv-text);
|
|
48
|
+
--color-muted: var(--dv-text-muted);
|
|
49
|
+
--color-faint: var(--dv-text-faint);
|
|
50
|
+
--color-link: var(--dv-link);
|
|
51
|
+
|
|
52
|
+
/* Lines: border-border, border-border-strong, ring-ring. */
|
|
53
|
+
--color-border: var(--dv-border);
|
|
54
|
+
--color-border-strong: var(--dv-border-strong);
|
|
55
|
+
--color-ring: var(--dv-ring);
|
|
56
|
+
|
|
57
|
+
/* The primary action (near-black in light, near-white in dark), its text, and the brand blue. */
|
|
58
|
+
--color-accent: var(--dv-accent);
|
|
59
|
+
--color-accent-hover: var(--dv-accent-hover);
|
|
60
|
+
--color-on-accent: var(--dv-on-accent);
|
|
61
|
+
--color-brand: var(--dv-brand);
|
|
62
|
+
--color-on-brand: var(--dv-on-brand);
|
|
63
|
+
|
|
64
|
+
/* Status: the colour, its pale fill and small text on that fill (bg-positive-pale text-positive-text). */
|
|
65
|
+
--color-positive: var(--dv-positive);
|
|
66
|
+
--color-positive-pale: var(--dv-positive-pale);
|
|
67
|
+
--color-positive-text: var(--dv-positive-text);
|
|
68
|
+
--color-negative: var(--dv-negative);
|
|
69
|
+
--color-negative-pale: var(--dv-negative-pale);
|
|
70
|
+
--color-negative-text: var(--dv-negative-text);
|
|
71
|
+
--color-warning: var(--dv-warning);
|
|
72
|
+
--color-warning-pale: var(--dv-warning-pale);
|
|
73
|
+
--color-warning-text: var(--dv-warning-text);
|
|
74
|
+
--color-info: var(--dv-info);
|
|
75
|
+
--color-info-pale: var(--dv-info-pale);
|
|
76
|
+
--color-info-text: var(--dv-info-text);
|
|
77
|
+
--color-highlight: var(--dv-highlight);
|
|
78
|
+
|
|
79
|
+
/* Chart series, in order. */
|
|
80
|
+
--color-chart-1: var(--dv-chart-1);
|
|
81
|
+
--color-chart-2: var(--dv-chart-2);
|
|
82
|
+
--color-chart-3: var(--dv-chart-3);
|
|
83
|
+
--color-chart-4: var(--dv-chart-4);
|
|
84
|
+
--color-chart-5: var(--dv-chart-5);
|
|
85
|
+
--color-chart-6: var(--dv-chart-6);
|
|
86
|
+
--color-chart-7: var(--dv-chart-7);
|
|
87
|
+
--color-chart-8: var(--dv-chart-8);
|
|
88
|
+
|
|
89
|
+
/* Hues, one shade each, light and dark (bg-blue/15 for a tint). */
|
|
90
|
+
--color-red: var(--dv-red);
|
|
91
|
+
--color-orange: var(--dv-orange);
|
|
92
|
+
--color-yellow: var(--dv-yellow);
|
|
93
|
+
--color-green: var(--dv-green);
|
|
94
|
+
--color-teal: var(--dv-teal);
|
|
95
|
+
--color-blue: var(--dv-blue);
|
|
96
|
+
--color-indigo: var(--dv-indigo);
|
|
97
|
+
--color-purple: var(--dv-purple);
|
|
98
|
+
--color-pink: var(--dv-pink);
|
|
99
|
+
--color-gray: var(--dv-gray);
|
|
100
|
+
|
|
101
|
+
/* Families: font-sans (text), font-heading, font-display (figures), font-mono. */
|
|
102
|
+
--font-sans: var(--dv-font-text);
|
|
103
|
+
--font-heading: var(--dv-font-heading);
|
|
104
|
+
--font-display: var(--dv-font-display);
|
|
105
|
+
--font-mono: var(--dv-font-mono);
|
|
106
|
+
|
|
107
|
+
/* Sizes on the app's scale: text-xs 12, text-sm 13, text-base the chat's 15 (14 on a phone), text-lg 17,
|
|
108
|
+
text-xl 20, text-2xl 24, text-display 30. */
|
|
109
|
+
--text-xs: var(--dv-text-xs);
|
|
110
|
+
--text-xs--line-height: var(--dv-text-xs-leading);
|
|
111
|
+
--text-sm: var(--dv-text-s);
|
|
112
|
+
--text-sm--line-height: var(--dv-text-s-leading);
|
|
113
|
+
--text-base: var(--dv-text-m);
|
|
114
|
+
--text-base--line-height: var(--dv-text-m-leading);
|
|
115
|
+
--text-lg: var(--dv-text-l);
|
|
116
|
+
--text-lg--line-height: var(--dv-text-l-leading);
|
|
117
|
+
--text-xl: calc(var(--dv-font-offset) + 1.25rem);
|
|
118
|
+
--text-xl--line-height: 1.2;
|
|
119
|
+
--text-2xl: calc(var(--dv-font-offset) + 1.5rem);
|
|
120
|
+
--text-2xl--line-height: 1.15;
|
|
121
|
+
--text-display: var(--dv-display);
|
|
122
|
+
--text-display--line-height: var(--dv-display-leading);
|
|
123
|
+
|
|
124
|
+
/* Corners: rounded-xs 4, rounded-sm 8, rounded-md 12, rounded-lg 24 (cards), rounded-full a pill. */
|
|
125
|
+
--radius-xs: var(--dv-radius-xs);
|
|
126
|
+
--radius-sm: var(--dv-radius-s);
|
|
127
|
+
--radius-md: var(--dv-radius-m);
|
|
128
|
+
--radius-lg: var(--dv-radius-l);
|
|
129
|
+
|
|
130
|
+
/* Elevation by role: shadow-surface (a card), shadow-control, shadow-raised (something floating). */
|
|
131
|
+
--shadow-surface: var(--dv-shadow-surface);
|
|
132
|
+
--shadow-control: var(--dv-shadow-control);
|
|
133
|
+
--shadow-raised: var(--dv-shadow-raised);
|
|
134
|
+
|
|
135
|
+
/* Motion: ease-standard, ease-emphasized, ease-soft; durations stay Tailwind's numbers (duration-100…). */
|
|
136
|
+
--ease-standard: var(--dv-ease);
|
|
137
|
+
--ease-emphasized: var(--dv-ease-emphasized);
|
|
138
|
+
--ease-soft: var(--dv-ease-soft);
|
|
139
|
+
--default-transition-duration: var(--dv-duration);
|
|
140
|
+
--default-transition-timing-function: var(--dv-ease);
|
|
141
|
+
--default-font-family: var(--dv-font-text);
|
|
142
|
+
--default-mono-font-family: var(--dv-font-mono);
|
|
143
|
+
}
|
|
144
|
+
`,reactLoader:new URL("widget-react-DdwoFg4K.js",import.meta.url).href,svgMenu:new URL("widget-svg-menu-BdZCKjBm.js",import.meta.url).href},Mr=["https://cdnjs.cloudflare.com","https://cdn.jsdelivr.net","https://unpkg.com","https://esm.sh"];function Be(e){return new URL(e,window.location.href).href}function Qt(e=window.location.origin){const t=Mr.join(" ");return["default-src 'none'",`script-src 'unsafe-inline' 'unsafe-eval' blob: ${e} ${t}`,`style-src 'unsafe-inline' ${e} ${t} https://fonts.googleapis.com`,`font-src data: ${e} ${t} https://fonts.gstatic.com`,`img-src data: blob: ${t}`,"media-src data: blob:",`connect-src ${t}`,"worker-src blob:","frame-src 'none'","form-action 'none'","base-uri 'none'"].join("; ")}const Pr=["allow-scripts","allow-forms","allow-popups","allow-popups-to-escape-sandbox","allow-downloads"],en={inline:"html,body{margin:0;background:transparent}html{overflow:hidden}body{display:flow-root}",panel:"html,body{margin:0;min-height:100%}body{display:flow-root}"},fe={...jr};function Nr(e){const t=e.replace(/^\[|\]$/g,"").toLowerCase();return t==="localhost"||t.endsWith(".localhost")||t.endsWith(".local")||t==="::1"||/^127\./.test(t)||/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[01])\./.test(t)}const _r=["kitCss","kitScript","kitReactScript","tailwindScript","reactLoader","svgMenu"];let kt=null;function Et(){return kt??(kt=fe.inline||!Nr(window.location.hostname)?Promise.resolve():Promise.all(_r.map(async e=>{const t=await fetch(fe[e]);if(!t.ok)throw new Error(`${e}: ${t.status}`);return[e,await t.text()]})).then(e=>{for(const[t,n]of e)fe[t]=n;fe.inline=!0},()=>{})),kt}const Dr=480,Or=1600;function Fr(e){if(!(e===void 0||!Number.isFinite(e)||e<=0))return Math.round(Math.min(Or,Math.max(Dr,e)))}function At(e){return{height:e,viewportSized:!1,atViewport:null,atGrown:null}}function zr(e,t,n){const r=o=>({height:o,viewportSized:!1,atViewport:o===n?t:null,atGrown:o>n?t:null});return t<=n?{frame:r(n),shown:t}:e.height>n?t<=e.height?{frame:r(t),shown:t}:{frame:{height:n,viewportSized:!0,atViewport:null,atGrown:t},shown:e.height}:e.viewportSized&&(e.atViewport===null?e.atGrown!==null&&t<e.atGrown:t===e.atViewport)?{frame:{...e,atViewport:t},shown:n}:{frame:r(t),shown:t}}const $r='"use strict";(()=>{var ze=300,Ge=/^[A-Za-z0-9_.:-]{1,128}$/;function ce(e,t){if(typeof t!="string"||!Ge.test(t))throw new Error(`A ${e} is 1\\u2013128 letters, digits or . _ : - ("${String(t)}" is not).`)}function We(e,t){return e===t?0:e==null?1:t==null||e<t?-1:1}function Ye(e,t){let r=null,n=null,o=[],a=0,m=!1,g=new Set,y=()=>g.forEach(i=>i());function c(i=!1){return r&&!i?Promise.resolve(r):(n&&!i||(n=e.read().then(l=>{n=null,r={version:l.version,collections:structuredClone(l.collections)};for(let{op:d}of o)v(d);return y(),r},l=>{throw n=null,l})),n)}function v(i){var d,p;if(!r)return;let l=(d=r.collections)[p=i.collection]??(d[p]={});i.op==="delete"?delete l[i.id]:i.op==="set"?l[i.id]=structuredClone(i.doc??{}):l[i.id]={...l[i.id]??{},...structuredClone(i.doc??{})}}async function h(){var l;if(a=0,m||o.length===0)return;m=!0;let i=o;o=[];try{let d=await e.apply(i.map(({op:p})=>p));if(r){r.version=d.version;for(let{collection:p,id:A,doc:s}of d.changed){let w=(l=r.collections)[p]??(l[p]={});s===null?delete w[A]:w[A]=s}for(let{op:p}of o)v(p)}i.forEach(({settle:p})=>p()),y()}catch(d){let p=d instanceof Error?d:new Error(String(d));i.forEach(({settle:A})=>A(p)),t(p),await c(!0).catch(()=>{})}finally{m=!1,o.length&&u()}}function u(){a||(a=window.setTimeout(()=>void h(),ze))}async function S(i){return ce("collection",i.collection),ce("document id",i.id),await c(),new Promise((l,d)=>{v(i),o.push({op:i,settle:p=>p?d(p):l()}),y(),u()})}return{load:c,refresh(){r&&!m&&o.length===0&&c(!0).catch(()=>{})},collection(i){ce("collection",i);let l=()=>r?.collections[i]??{};return Object.freeze({async get(d){await c();let p=l()[d];return p?{...structuredClone(p),id:d}:null},async list(d={}){await c();let p=Object.entries(l()).map(([L,N])=>({...structuredClone(N),id:L})),{where:A,orderBy:s,limit:w}=d;if(typeof A=="function"?p=p.filter(A):A&&(p=p.filter(L=>Object.entries(A).every(([N,P])=>L[N]===P))),s){let[L,N]=Array.isArray(s)?s:[s,"asc"];p.sort((P,_)=>We(P[L],_[L])*(N==="desc"?-1:1))}return typeof w=="number"?p.slice(0,Math.max(0,w)):p},set:(d,p)=>S({op:"set",collection:i,id:d,doc:p}),update:(d,p)=>S({op:"update",collection:i,id:d,doc:p}),delete:d=>S({op:"delete",collection:i,id:d}),subscribe(d){return g.add(d),()=>g.delete(d)}})}}}var Xe="_kv";function be(e,t=()=>{}){let r=Ye(e,t),n=()=>r.refresh();window.addEventListener("focus",n),document.addEventListener("visibilitychange",()=>document.visibilityState==="visible"&&n());let o=Object.freeze({collection:g=>r.collection(g)}),a=()=>r.collection(Xe),m=Object.freeze({async get(g){return(await a().get(g))?.value},set:(g,y)=>a().set(g,{value:y}),delete:g=>a().delete(g),async list(g={}){return(await a().list()).map(c=>c.id).filter(c=>!g.prefix||c.startsWith(g.prefix))}});return{db:o,storage:m}}var we=15e3;function he(e){let t=new Map,r=0;function n(s,w,L=we){return e.enabled?o(s,w,L):Promise.reject(new Error("The widget bridge is off."))}function o(s,w,L=we){let N=`w${++r}`;return new Promise((P,_)=>{let k=window.setTimeout(()=>{t.delete(N),_(new Error(`${s} timed out after ${L} ms`))},L);t.set(N,{resolve:P,reject:_,timer:k}),e.post({channel:e.channel,jsonrpc:"2.0",id:N,method:s,params:w})})}let a=(s,w)=>n(s,w).then(()=>!0,()=>!1),m={send:(s,w)=>typeof s=="string"&&s.trim()?a("ui/message",{role:"user",content:[{type:"text",text:s.trim()}],...w===void 0?{}:{context:w}}):Promise.resolve(!1)},g={open:s=>a("ui/open-link",{url:String(s)})},y={open:(s,w)=>a("dvina/open-target",{kind:s,id:w})},c={set:s=>a("ui/update-model-context",{structuredContent:s}),clear:()=>a("ui/update-model-context",{structuredContent:null})},v={call:(s,w)=>n("dvina/call",w===void 0?{name:s}:{name:s,args:w})},h={prompt:m,link:g,target:y,context:c,host:v},u=null,S={read:()=>v.call("db.read",{}),apply:s=>v.call("db.apply",{ops:s})},i=s=>!e.data||s!=="db"&&s!=="storage"?null:(u??(u=be(S,w=>console.error("[dvina] a write was refused:",w.message))),s==="db"?u.db:u.storage),l={use:s=>Promise.resolve(e.enabled?s in h?Object.freeze({...h[s]}):i(s):null)};function d(s){if(s.jsonrpc!=="2.0"||typeof s.id!="string")return!1;let w=t.get(s.id);if(!w)return!0;t.delete(s.id),window.clearTimeout(w.timer);let L=s.error;return L?w.reject(new Error(L.message||"The host refused the request.")):w.resolve(s.result??null),!0}function p(){document.addEventListener("click",s=>{if(s.defaultPrevented||s.button!==0)return;let w=s.target?.closest?.("a[href]");!w||!/^https?:/i.test(w.href)||(s.preventDefault(),g.open(w.href))})}let A=e.enabled||e.pictures?(s,w)=>o("dvina/call",w===void 0?{name:s}:{name:s,args:w}):null;return{dvina:l,prompt:m,link:g,host:v,pictures:A,receive:d,interceptLinks:p}}var j="data-dvina-image",Y="data-dvina-image-state",Ke="image.read";var Ze=/^image\\/(webp|jpeg|png|gif|avif)$/,ye=/^(data|blob):/i;function ue(e){let t=e.getAttribute("src");return!t||!ye.test(t)}function Qe(e){let t=e.getAttribute("src");t&&!ye.test(t)&&e.removeAttribute("src"),e.removeAttribute("srcset"),e.removeAttribute("sizes");let r=e.parentElement;r?.tagName==="PICTURE"&&r.querySelectorAll("source[srcset]").forEach(n=>n.removeAttribute("srcset"))}function de(e){let{mimeType:t,data:r}=e??{};if(typeof t!="string"||!Ze.test(t)||typeof r!="string")throw new Error("The host gave no picture.");if(r.length>Math.ceil(8388608/3)*4)throw new Error("The picture is too large.");let n=atob(r),o=new Uint8Array(n.length);for(let a=0;a<n.length;a+=1)o[a]=n.charCodeAt(a);return new Blob([o],{type:t})}function Ee(e){let t=new Map,r=new Map,n=[],o=0,a=0,m=typeof IntersectionObserver=="function"?new IntersectionObserver(i=>{for(let l of i)l.isIntersecting&&(m?.unobserve(l.target),v(l.target))}):null;function g(){for(;o<3&&n.length>0;){let i=n.shift();o+=1,i().finally(()=>{o-=1,g()})}}function y(i){let l=t.get(i);if(l)return l;let{call:d}=e;if(!d){r.set(i,null);let A=Promise.resolve(null);return t.set(i,A),A}let p=new Promise(A=>{let s=w=>{r.set(i,w),A(w)};n.push(async()=>{if(a>=12)return s(null);a+=1;let w=await d(Ke,{url:i}).then(L=>URL.createObjectURL(de(L))).catch(()=>(a-=1,null));s(w)}),g()});return t.set(i,p),p}function c(i){let l=i.getAttribute(j)?.trim();if(!(!l||!ue(i))){if(Qe(i),r.has(l)){h(i,l,r.get(l)??null);return}i.setAttribute(Y,"loading"),m?m.observe(i):v(i)}}function v(i){let l=i.getAttribute(j)?.trim();!l||!ue(i)||y(l).then(d=>h(i,l,d))}function h(i,l,d){if(!(i.getAttribute(j)?.trim()!==l||!ue(i))){if(!d){i.setAttribute(Y,"failed");return}i.removeAttribute(Y),i.src=d}}function u(i){i instanceof HTMLImageElement&&c(i),i.querySelectorAll?.(`img[${j}]`).forEach(c)}function S(i){let l=new MutationObserver(d=>{for(let p of d)p.type==="attributes"?u(p.target):p.addedNodes.forEach(A=>A.nodeType===Node.ELEMENT_NODE&&u(A))});return l.observe(i,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[j,"src","srcset"]}),(i instanceof Element||i instanceof Document)&&u(i),l}return{apply:u,observe:S}}function Te(e,t){if(e.tagName!=="IMG"||t.tagName!=="IMG")return;let r=e.getAttribute(j);if(!r||r!==t.getAttribute(j))return;let n=e.getAttribute("src");n&&/^blob:/i.test(n)&&!/^data:/i.test(t.getAttribute("src")??"")&&(t.setAttribute("src",n),t.removeAttribute("srcset"),t.removeAttribute("sizes"));let o=e.getAttribute(Y);o&&t.setAttribute(Y,o)}var J=".cite",q="data-dvina-cite",Ae="data-dvina-cite-joined",et=/^[\\s,;·]*$/,tt="source.icon",nt=3,fe="http://www.w3.org/2000/svg",rt=["M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20","M2 12h20"];function xe(e){let t=e?.trim();if(!t)return null;try{let r=new URL(t);return r.protocol==="https:"||r.protocol==="http:"?r.href:null}catch{return null}}function W(e){return new URL(e).host.replace(/^www\\./,"")}function te(e){let t=e.getAttribute(q);if(t!==null)return t.split(" ").filter(Boolean);let r=e.matches("a")?[e]:[...e.querySelectorAll("a[href]")];return[...new Set(r.map(n=>xe(n.getAttribute("href"))).filter(n=>!!n))]}function it(e,t){let r=e.matches("a")?[e]:[...e.querySelectorAll("a[href]")];return t.map(n=>{let o=r.find(a=>xe(a.getAttribute("href"))===n)?.textContent?.trim();return o&&o!==W(n)?`${o} \\xB7 ${W(n)}`:W(n)}).join(`\n`)}function ot(){let e=document.createElementNS(fe,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("aria-hidden","true");let t=document.createElementNS(fe,"circle");t.setAttribute("cx","12"),t.setAttribute("cy","12"),t.setAttribute("r","10"),e.append(t);for(let r of rt){let n=document.createElementNS(fe,"path");n.setAttribute("d",r),e.append(n)}return e}function Se(e){let t=new Map,r=new WeakMap;function n(c){let v=W(c),h=t.get(v);if(h)return h;let{call:u}=e,S=u?u(tt,{url:c}).then(i=>URL.createObjectURL(de(i))).catch(()=>null):Promise.resolve(null);return t.set(v,S),S}function o(c){let v=document.createElement("span");return v.className="cite-icon",v.append(ot()),n(c).then(h=>{if(!h)return;let u=document.createElement("img");u.alt="",u.src=h,v.replaceChildren(u)}),v}function a(c,v,h){let u=[...new Map(v.map(l=>[W(l),l])).values()],S=document.createElement("span");S.className="cite-icons",S.append(...u.slice(0,nt).map(o));let i=document.createElement("span");i.className="cite-label",i.textContent=v.length>1?`+${v.length-1}`:W(v[0]),c.setAttribute("title",h),c.replaceChildren(S,i)}function m(c){if(c.hasAttribute(q))return;let v=te(c);if(!v.length)return;let h=it(c,v);c.setAttribute(q,v.join(" ")),c.matches("a")||(c.setAttribute("role","link"),c.setAttribute("tabindex","0"));let u=Me(c);if(!u){r.set(c,{urls:v,title:h}),a(c,v,h);return}c.setAttribute(Ae,""),c.replaceChildren();let S=r.get(u)??{urls:te(u),title:u.getAttribute("title")??""},i={urls:[...new Set([...S.urls,...v])],title:[...new Set([...S.title.split(`\n`),...h.split(`\n`)])].filter(Boolean).join(`\n`)};r.set(u,i),a(u,i.urls,i.title)}function g(c){c instanceof Element&&c.matches(J)&&m(c),c.querySelectorAll?.(J).forEach(m)}function y(c){let v=new MutationObserver(u=>{for(let S of u)S.addedNodes.forEach(i=>{if(i.nodeType!==Node.ELEMENT_NODE)return;g(i);let l=i.parentElement?.closest(J);l&&!l.hasAttribute(q)&&m(l)})});v.observe(c,{childList:!0,subtree:!0}),(c instanceof Element||c instanceof Document)&&g(c);let h=u=>{let S=u.target?.closest?.(`${J}[${q}]`);if(!S||S.matches("a")||u instanceof KeyboardEvent&&u.key!=="Enter"&&u.key!==" ")return;u.preventDefault();let[i]=te(S);i&&e.open(i)};return document.addEventListener("click",h),document.addEventListener("keydown",h),v}return{apply:g,observe:y}}function Me(e){let t=e.previousSibling;for(;t&&t.nodeType!==Node.ELEMENT_NODE;){if(t.nodeType===Node.TEXT_NODE&&!et.test(t.textContent??""))return null;t=t.previousSibling}let r=t;return!r?.matches(J)||!r.hasAttribute(q)?null:r.hasAttribute(Ae)?Me(r):r}function Le(e,t){if(!e.matches(J)||!t.matches(J))return!1;let r=e.getAttribute(q);return r!==null&&r===te(t).join(" ")}var X=new Map;function me(e){let t=!1,r=()=>{t||(t=!0,cancelAnimationFrame(n),window.clearTimeout(X.get(n)),X.delete(n),e())},n=requestAnimationFrame(r);return X.set(n,window.setTimeout(r,100)),n}function pe(e){cancelAnimationFrame(e),window.clearTimeout(X.get(e)),X.delete(e)}var at={requestFrame:me,cancelFrame:pe,setTimer:(e,t)=>window.setTimeout(e,t),clearTimer:e=>window.clearTimeout(e),now:()=>performance.now()};function Re(e,t=at,r=150){let n=0,o=0,a=Number.NEGATIVE_INFINITY;function m(){n=0,a=t.now(),e()}function g(){n&&t.cancelFrame(n),o&&t.clearTimer(o),n=0,o=0}return{request(){if(n||o)return;let y=a+r-t.now();if(y<=0){n=t.requestFrame(m);return}o=t.setTimer(()=>{o=0,n=t.requestFrame(m)},y)},flushNow(){g(),m()},cancel:g}}var Ve=11;function st(e,t){var r=t.attributes,n,o,a,m,g;if(!(t.nodeType===Ve||e.nodeType===Ve)){for(var y=r.length-1;y>=0;y--)n=r[y],o=n.name,a=n.namespaceURI,m=n.value,a?(o=n.localName||o,g=e.getAttributeNS(a,o),g!==m&&(n.prefix==="xmlns"&&(o=n.name),e.setAttributeNS(a,o,m))):(g=e.getAttribute(o),g!==m&&e.setAttribute(o,m));for(var c=e.attributes,v=c.length-1;v>=0;v--)n=c[v],o=n.name,a=n.namespaceURI,a?(o=n.localName||o,t.hasAttributeNS(a,o)||e.removeAttributeNS(a,o)):t.hasAttribute(o)||e.removeAttribute(o)}}var ne,lt="http://www.w3.org/1999/xhtml",O=typeof document>"u"?void 0:document,ct=!!O&&"content"in O.createElement("template"),ut=!!O&&O.createRange&&"createContextualFragment"in O.createRange();function dt(e){var t=O.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}function ft(e){ne||(ne=O.createRange(),ne.selectNode(O.body));var t=ne.createContextualFragment(e);return t.childNodes[0]}function mt(e){var t=O.createElement("body");return t.innerHTML=e,t.childNodes[0]}function pt(e){return e=e.trim(),ct?dt(e):ut?ft(e):mt(e)}function re(e,t){var r=e.nodeName,n=t.nodeName,o,a;return r===n?!0:(o=r.charCodeAt(0),a=n.charCodeAt(0),o<=90&&a>=97?r===n.toUpperCase():a<=90&&o>=97?n===r.toUpperCase():!1)}function gt(e,t){return!t||t===lt?O.createElement(e):O.createElementNS(t,e)}function vt(e,t){for(var r=e.firstChild;r;){var n=r.nextSibling;t.appendChild(r),r=n}return t}function ge(e,t,r){e[r]!==t[r]&&(e[r]=t[r],e[r]?e.setAttribute(r,""):e.removeAttribute(r))}var Ce={OPTION:function(e,t){var r=e.parentNode;if(r){var n=r.nodeName.toUpperCase();n==="OPTGROUP"&&(r=r.parentNode,n=r&&r.nodeName.toUpperCase()),n==="SELECT"&&!r.hasAttribute("multiple")&&(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),r.selectedIndex=-1)}ge(e,t,"selected")},INPUT:function(e,t){ge(e,t,"checked"),ge(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var r=t.value;e.value!==r&&(e.value=r);var n=e.firstChild;if(n){var o=n.nodeValue;if(o==r||!r&&o==e.placeholder)return;n.nodeValue=r}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var r=-1,n=0,o=e.firstChild,a,m;o;)if(m=o.nodeName&&o.nodeName.toUpperCase(),m==="OPTGROUP")a=o,o=a.firstChild,o||(o=a.nextSibling,a=null);else{if(m==="OPTION"){if(o.hasAttribute("selected")){r=n;break}n++}o=o.nextSibling,!o&&a&&(o=a.nextSibling,a=null)}e.selectedIndex=r}}},K=1,Ne=11,Oe=3,Pe=8;function B(){}function bt(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}function wt(e){return function(r,n,o){if(o||(o={}),typeof n=="string")if(r.nodeName==="#document"||r.nodeName==="HTML"){var a=n;n=O.createElement("html"),n.innerHTML=a}else if(r.nodeName==="BODY"){var m=n;n=O.createElement("html"),n.innerHTML=m;var g=n.querySelector("body");g&&(n=g)}else n=pt(n);else n.nodeType===Ne&&(n=n.firstElementChild);var y=o.getNodeKey||bt,c=o.onBeforeNodeAdded||B,v=o.onNodeAdded||B,h=o.onBeforeElUpdated||B,u=o.onElUpdated||B,S=o.onBeforeNodeDiscarded||B,i=o.onNodeDiscarded||B,l=o.onBeforeElChildrenUpdated||B,d=o.skipFromChildren||B,p=o.addChild||function(E,T){return E.appendChild(T)},A=o.childrenOnly===!0,s=Object.create(null),w=[];function L(E){w.push(E)}function N(E,T){if(E.nodeType===K)for(var R=E.firstChild;R;){var x=void 0;T&&(x=y(R))?L(x):(i(R),R.firstChild&&N(R,T)),R=R.nextSibling}}function P(E,T,R){S(E)!==!1&&(T&&T.removeChild(E),i(E),N(E,R))}function _(E){if(E.nodeType===K||E.nodeType===Ne)for(var T=E.firstChild;T;){var R=y(T);R&&(s[R]=T),_(T),T=T.nextSibling}}_(r);function k(E){v(E);for(var T=E.firstChild;T;){var R=T.nextSibling,x=y(T);if(x){var M=s[x];M&&re(T,M)?(T.parentNode.replaceChild(M,T),b(M,T)):k(T)}else k(T);T=R}}function f(E,T,R){for(;T;){var x=T.nextSibling;(R=y(T))?L(R):P(T,E,!0),T=x}}function b(E,T,R){var x=y(T);if(x&&delete s[x],!R){var M=h(E,T);if(M===!1||(M instanceof HTMLElement&&(E=M,_(E)),e(E,T),u(E),l(E,T)===!1))return}E.nodeName!=="TEXTAREA"?D(E,T):Ce.TEXTAREA(E,T)}function D(E,T){var R=d(E,T),x=T.firstChild,M=E.firstChild,z,I,G,Q,F;e:for(;x;){for(Q=x.nextSibling,z=y(x);!R&&M;){if(G=M.nextSibling,x.isSameNode&&x.isSameNode(M)){x=Q,M=G;continue e}I=y(M);var ee=M.nodeType,H=void 0;if(ee===x.nodeType&&(ee===K?(z?z!==I&&((F=s[z])?G===F?H=!1:(E.insertBefore(F,M),I?L(I):P(M,E,!0),M=F,I=y(M)):H=!1):I&&(H=!1),H=H!==!1&&re(M,x),H&&b(M,x)):(ee===Oe||ee==Pe)&&(H=!0,M.nodeValue!==x.nodeValue&&(M.nodeValue=x.nodeValue))),H){x=Q,M=G;continue e}I?L(I):P(M,E,!0),M=G}if(z&&(F=s[z])&&re(F,x))R||p(E,F),b(F,x);else{var le=c(x);le!==!1&&(le&&(x=le),x.actualize&&(x=x.actualize(E.ownerDocument||O)),p(E,x),k(x))}x=Q,M=G}f(E,M,I);var ve=Ce[E.nodeName];ve&&ve(E,T)}var V=r,U=V.nodeType,$=n.nodeType;if(!A){if(U===K)$===K?re(r,n)||(i(r),V=vt(r,gt(n.nodeName,n.namespaceURI))):V=n;else if(U===Oe||U===Pe){if($===U)return V.nodeValue!==n.nodeValue&&(V.nodeValue=n.nodeValue),V;V=n}}if(V===n)i(r);else{if(n.isSameNode&&n.isSameNode(V))return;if(b(V,n,A),w)for(var ae=0,qe=w.length;ae<qe;ae++){var se=s[w[ae]];se&&P(se,se.parentNode,!1)}}return!A&&V!==r&&r.parentNode&&(V.actualize&&(V=V.actualize(r.ownerDocument||O)),r.parentNode.replaceChild(V,r)),V}}var ht=wt(st),_e=ht;var yt=220;function Et(e){e.tagName==="STYLE"||e.tagName==="SCRIPT"||e.tagName==="LINK"||typeof e.animate=="function"&&(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches||e.animate([{opacity:0},{opacity:1}],{duration:yt,easing:"ease-out"}))}function Ie(e){let t=e.lastIndexOf("<");return t===-1?e:e.indexOf(">",t)===-1?e.slice(0,t):e}function ke(e,t,r={}){let n=r.fade??!0,o=e.cloneNode(!1);o.innerHTML=t,_e(e,o,{childrenOnly:!0,onBeforeElUpdated(a,m){return Le(a,m)?!1:(Te(a,m),!a.isEqualNode(m))},onNodeAdded(a){return n&&a.nodeType===Node.ELEMENT_NODE&&Et(a),a}})}function Tt(e){let t=document.createElement("script");for(let r of Array.from(e.attributes))t.setAttribute(r.name,r.value);return t.textContent=e.textContent??"",t}function At(e){return new Promise(t=>{e.addEventListener("load",()=>t(null),{once:!0}),e.addEventListener("error",()=>t(`Failed to load ${e.src}`),{once:!0})})}async function De(e,t){for(let r of Array.from(e.querySelectorAll("script"))){let n=Tt(r),a=n.hasAttribute("src")?At(n):null;r.replaceWith(n);let m=a?await a:null;m&&t?.({src:n.src,message:m})}}function xt(e){return Array.from(e.children).filter(t=>["STYLE","LINK","SCRIPT"].includes(t.tagName)).map(t=>t.outerHTML).join("")}function Fe(e){let{root:t}=e,r="",n=!1,o="",a=0,m=new Set;function g(h){for(let u of m)h?.hasAttribute(u)||document.body.removeAttribute(u);m=new Set;for(let u of Array.from(h?.attributes??[]))document.body.setAttribute(u.name,u.value),m.add(u.name)}function y(){let h=n?r:Ie(r);if(e.markup==="fragment")return h;if(!h)return g(null),"";let u=new DOMParser().parseFromString(h,"text/html");return g(u.body),xt(u.head)+u.body.innerHTML}function c(){let h=y();h!==o&&(ke(t,h,{fade:!(n&&a===0)}),o=h,a+=1),e.onRender?.()}let v=Re(c,e.clock,e.intervalMs);return{append(h){n||typeof h!="string"||h.length===0||(r+=h,v.request())},async complete(){n||(n=!0,v.flushNow(),await De(t,e.onScriptFailure),e.onComplete?.())},abort(){v.cancel(),r="",o="",a=0,n=!1,t.replaceChildren(),g(null),e.onRender?.()},get completed(){return n}}}function He(e,t){if(typeof e!="string"||e.length===0)return"";let r=e.trim();if(r.startsWith("rgb("))return r.replace(/^rgb\\((.*)\\)$/i,`rgba($1, ${t})`);if(r.startsWith("rgba("))return r.replace(/^rgba\\(([^,]+),([^,]+),([^,]+),[^)]+\\)$/i,`rgba($1,$2,$3, ${t})`);if(!r.startsWith("#"))return"";let n=r.slice(1),o=n.length===3?n.split("").map(y=>y+y).join(""):n.length===6?n:"";if(!o)return"";let[a,m,g]=[0,2,4].map(y=>Number.parseInt(o.slice(y,y+2),16));return`rgba(${a}, ${m}, ${g}, ${t})`}function St(e){let t=e.mode==="dark",r=e.tokens?.surface||(t?"#09090b":"#ffffff"),n=e.tokens?.surfaceMuted||(t?"rgba(255, 255, 255, 0.04)":"rgba(15, 23, 42, 0.03)"),o=e.tokens?.text||(t?"#fafafa":"#09090b"),a=e.tokens?.accent||o;return{"--widget-bg":"transparent","--widget-surface":r,"--widget-surface-muted":n,"--widget-border":He(o,t?.14:.1)||(t?"rgba(255, 255, 255, 0.14)":"rgba(15, 23, 42, 0.1)"),"--widget-text":o,"--widget-text-muted":He(o,t?.7:.62)||(t?"rgba(250, 250, 250, 0.7)":"rgba(15, 23, 42, 0.62)"),"--widget-accent":a,"--widget-accent-contrast":t?"#09090b":"#ffffff","--widget-radius":"16px","--widget-font-family":\'"Inter", "Segoe UI", sans-serif\',"--widget-font-heading":\'600 1rem/1.2 "Inter", "Segoe UI", sans-serif\',"--widget-font-text-s":"0.875rem","--widget-font-text-m":"1rem","--widget-control-height":"2.75rem","--widget-shadow-1":"none"}}var Be=new Set;function Ue(e){if(!e||e.mode!=="light"&&e.mode!=="dark")return!1;let t=document.documentElement,r={...St(e),...e.variables};for(let n of Be)n in r||t.style.removeProperty(n);for(let[n,o]of Object.entries(r))t.style.setProperty(n.startsWith("--")?n:`--${n}`,o);return Be=new Set(Object.keys(r)),t.dataset.themeMode=e.mode,t.style.colorScheme=e.mode,!0}var ie,oe=["top","right","bottom","left"];function $e(e){let t={top:0,right:0,bottom:0,left:0};for(let n of oe){let o=e?.[n]??0;if(typeof o!="number"||!Number.isFinite(o)||o<0)return null;t[n]=o}for(let n of oe)document.documentElement.style.setProperty(`--viewer-safe-area-${n}`,`${t[n]}px`);ie||(ie=document.createElement("style"),document.head.appendChild(ie));let r=oe.map(n=>`${t[n]}px`).join(" ");return ie.textContent=oe.some(n=>t[n]>0)?`html { box-sizing: border-box !important; padding: ${r} !important; scroll-padding: ${r} !important; }`:"",t}var C={scale:1,x:0,y:0};function je(){return C}function Z(e,t){if(!e||typeof e!="object")return;let r=e,n=Number(r.scale),o=Number(r.x),a=Number(r.y);if(!(!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(a))&&(C={scale:n,x:o,y:a},!!t)){if(t.setAttribute("data-viewer-zoom-target",""),n===1&&o===0&&a===0){t.style.removeProperty("transform"),t.style.removeProperty("transform-origin"),t.style.removeProperty("will-change");return}t.style.transformOrigin="0 0",t.style.willChange="transform",t.style.transform=`translate3d(${o}px, ${a}px, 0) scale(${n})`}}function Je(e){let t=new Map,r=0,n=1,o=null,a=null,m=!1,g=1,y=4,c=i=>Math.min(y,Math.max(g,i)),v=()=>{document.documentElement.style.touchAction=C.scale>g?"none":"pan-x pan-y"},h=i=>{Z(i,e()),v()};function u(){let i=Array.from(t.values());i.length<2||(r=Math.max(Math.hypot(i[1].x-i[0].x,i[1].y-i[0].y),1),n=C.scale,o=null,a=null,m=!0)}document.addEventListener("pointerdown",i=>{i.pointerType==="touch"&&(t.set(i.pointerId,{x:i.clientX,y:i.clientY}),t.size===2?(i.preventDefault(),u()):C.scale>g&&(o={x:i.clientX,y:i.clientY},a={...C},m=!1))}),document.addEventListener("pointermove",i=>{if(i.pointerType!=="touch"||!t.has(i.pointerId))return;t.set(i.pointerId,{x:i.clientX,y:i.clientY});let l=Array.from(t.values());if(l.length>=2&&r>0){i.preventDefault();let d={x:(l[0].x+l[1].x)/2,y:(l[0].y+l[1].y)/2},p=Math.hypot(l[1].x-l[0].x,l[1].y-l[0].y),A=c(n*(p/r)),s=A/C.scale;h({scale:A,x:d.x-(d.x-C.x)*s,y:d.y-(d.y-C.y)*s});return}if(l.length===1&&C.scale>g&&o&&a){let d=l[0],p=d.x-o.x,A=d.y-o.y;(Math.abs(p)>3||Math.abs(A)>3)&&(m=!0),m&&(i.preventDefault(),h({scale:C.scale,x:a.x+p,y:a.y+A}))}});let S=i=>{if(!(i.pointerType!=="touch"||!t.has(i.pointerId))){if(t.delete(i.pointerId),t.size>=2){u();return}if(t.size===1&&C.scale>g){o=Array.from(t.values())[0],a={...C};return}r=0,o=null,a=null,C.scale-g<.015&&Z({scale:g,x:0,y:0},e()),v()}};document.addEventListener("pointerup",S),document.addEventListener("pointercancel",S),document.addEventListener("wheel",i=>{if(!i.ctrlKey&&!i.metaKey)return;i.preventDefault();let l=c(C.scale*Math.exp(-i.deltaY*.002)),d=l/C.scale;h({scale:l,x:i.clientX-(i.clientX-C.x)*d,y:i.clientY-(i.clientY-C.y)*d})},{passive:!1}),v()}function Mt(e){let{channel:t,rootId:r}=e,n=new Set,o=!1,a=0,m=0,g=e.widget?.layout==="inline",y=(f,b)=>window.parent.postMessage({channel:t,type:f,...b},"*"),c=()=>document.getElementById(r),v=()=>c()??document.body;function h(){if(g&&document.body){let b=Math.ceil(document.body.getBoundingClientRect().height);return m=A?.completed?b:Math.max(m,b),m}let f=c();return Math.max(f?Math.ceil(f.getBoundingClientRect().height):0,document.body?.scrollHeight??0,document.body?.offsetHeight??0,document.documentElement?.scrollHeight??0,document.documentElement?.offsetHeight??0)}function u(f){a&&pe(a),a=me(()=>{a=0,y("artifact.resize",{height:h(),reason:f})})}function S(f){!f||!Ue(f)||(window.artifactRenderer.themeMode=f.mode,window.artifactRenderer.theme=f,window.dispatchEvent(new CustomEvent("dvina-artifact-renderer:theme",{detail:f})),document.dispatchEvent(new CustomEvent("dvina-artifact-renderer:theme",{detail:f})))}function i(f){let b=$e(f);b&&(window.artifactRenderer.safeArea=b,window.dispatchEvent(new CustomEvent("dvina-artifact-renderer:safe-area",{detail:b})))}function l(f){window.__artifactRendererData=f,window.dispatchEvent(new CustomEvent("dvina-artifact-renderer:data",{detail:f}));for(let b of n)try{b(f)}catch{}}window.artifactRenderer={version:"0.2.0",themeMode:e.theme.mode,theme:e.theme,getData:()=>window.__artifactRendererData,onData(f){return typeof f!="function"?()=>{}:(n.add(f),()=>n.delete(f))},emit(f,b){typeof f!="string"||f.length===0||y("artifact.event",{name:f,detail:b})},requestResize:()=>u("renderer")};let d=he({channel:t,enabled:e.widget?.bridge!==!1,data:e.widget?.data===!0,pictures:e.widget?.pictures===!0,post:f=>window.parent.postMessage(f,"*")});if(window.sendPrompt=d.prompt.send,window.openLink=d.link.open,window.dvina=d.dvina,d.interceptLinks(),e.widget){let f=Ee({call:d.pictures}),b=Se({call:d.pictures,open:d.link.open}),D=()=>{f.observe(document.body),b.observe(document.body)};document.body?D():document.addEventListener("DOMContentLoaded",D,{once:!0})}let p=f=>y("artifact.event",{name:"runtime.error",detail:{message:f}}),A=null;function s(){if(A)return A;let f=c();return!e.stream||!f?null:(A=Fe({root:f,markup:e.stream,onRender(){Z(je(),v()),u("content")},onComplete(){e.widget&&window.__dvinaSvgMenu?.(e.widget.labels),document.dispatchEvent(new Event("DOMContentLoaded",{bubbles:!0})),window.dispatchEvent(new Event("load")),u("content")},onScriptFailure:b=>p(b.message)}),A)}window.addEventListener("message",f=>{let b=f.data;if(!(!b||b.channel!==t||f.source!==window.parent)&&!d.receive(b))switch(b.type){case"artifact.set-safe-area":i(b.safeArea),u("renderer");return;case"artifact.set-theme":S(b.theme),u("renderer");return;case"artifact.update-data":l(b.data);return;case"artifact.set-zoom-transform":Z(b.transform,v());return;case"artifact.stream-append-html":s()?.append(b.html);return;case"artifact.stream-complete":s()?.complete();return;case"artifact.react-module":L(b);return;case"artifact.stream-abort":s()?.abort();return}});let w=!1;async function L(f){let b=c();if(w||!b)return;w=!0;let D={text:document.getElementById("dvina-kit-react")?.textContent??void 0,url:e.kitReactUrl};try{if(f.error||!f.code)throw new Error(f.error||"The widget has no code.");if(!window.__dvinaMountReact)throw new Error("React mode is not loaded in this frame.");await window.__dvinaMountReact(b,f.code,D)}catch(V){let U=V instanceof Error?V.message:String(V),$=document.createElement("p");$.setAttribute("role","alert"),$.className="dvina-widget-error",$.textContent=`This widget could not be shown: ${U}`,b.replaceChildren($),p(U)}u("content")}function N(){o||(o=!0,y("artifact.ready",{}),u("renderer"),e.initialData!==void 0&&l(e.initialData),e.initialReact&&L(e.initialReact),e.initialHtml!==void 0&&(s()?.append(e.initialHtml),s()?.complete()))}if(window.addEventListener("load",N,{once:!0}),document.readyState==="complete"?N():document.addEventListener("DOMContentLoaded",N,{once:!0}),S(e.theme),i(e.safeArea),Je(v),typeof ResizeObserver=="function"){let f=new ResizeObserver(()=>u("content"));f.observe(document.documentElement),document.body?f.observe(document.body):document.addEventListener("DOMContentLoaded",()=>f.observe(document.body),{once:!0})}window.addEventListener("resize",()=>u("viewport"));let P=0,_=null,k=new WeakMap;document.addEventListener("scroll",f=>{let b=f.target===document?document.scrollingElement||document.documentElement:f.target;if(!b||typeof b.scrollTop!="number")return;let D=k.get(b)??0;k.set(b,b.scrollTop),b.scrollTop!==D&&(_=b.scrollTop,!P&&(P=requestAnimationFrame(()=>{P=0,y("artifact.scroll",{scrollTop:_})})))},{capture:!0,passive:!0}),window.addEventListener("error",f=>p(f.message||"Executable HTML runtime error")),window.addEventListener("unhandledrejection",f=>{let b=f.reason;p(b instanceof Error?b.message:String(b??"Unhandled rejection"))})}window.__dvinaFrame&&Mt(window.__dvinaFrame);})();\n';function Vr(){let e=0;const t=new Map;function n(){const r=[];for(;t.has(e);){const o=t.get(e);t.delete(e),o!==void 0&&r.push({html:o,sequence:e}),e+=1}return r}return{push(r){if(r.sequence===void 0){const o=e;return e+=1,[{html:r.html,sequence:o}]}return r.sequence<e?[]:(t.set(r.sequence,r.html),n())},reset(){t.clear(),e=0}}}var Ur="dvina-widget";function qr(e){const t=new RegExp(`<meta name="${Ur}" content="(html|react)"`).exec(e.slice(0,4096));return t?t[1]:null}const Hr=1e3,Br=30,Wr=24,Gr=1e4,Xr="image.read";function Kr(e){const t=e.gapMs??Hr,n=new Map,r={data:[],pictures:[]};return function(a,i){if(!Xt(a))return{ok:!1,error:{code:"invalid-params",message:`Unknown method ${String(a)}.`}};if(!Kt(a,i))return{ok:!1,error:{code:"invalid-params",message:`Invalid params for ${a}.`}};if(Hn.includes(a)){if(!e.isUserActive())return{ok:!1,error:{code:"user-activation-required",message:`${a} needs a click or key press first.`}};const c=e.now();if(c-(n.get(a)??Number.NEGATIVE_INFINITY)<t)return{ok:!1,error:{code:"rate-limited",message:`${a} was asked too soon again.`}};n.set(a,c)}if(a==="dvina/call"){const c=i.name===Xr?"pictures":"data",s=c==="pictures"?Wr:Br,l=e.now();if(r[c]=r[c].filter(p=>l-p<Gr),r[c].length>=s)return{ok:!1,error:{code:"rate-limited",message:"Too many host calls; wait a moment."}};r[c].push(l)}return{ok:!0,method:a,params:i}}}function Yr(){var e;return((e=navigator.userActivation)==null?void 0:e.isActive)??!1}const H="dvina-artifact-renderer-html",We="dvina-viewer:artifact-scroll",et="dvina-artifact-renderer-stream-root",Zr=["allow-downloads","allow-forms","allow-same-origin","allow-scripts"];function Jr(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.channel===H&&t.jsonrpc==="2.0"&&typeof t.id=="string"&&"method"in t}function Qr(e){const t=e.params;return e.method==="dvina/call"&&(t==null?void 0:t.name)==="image.read"}function ke(e){return e.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<").replaceAll(">",">")}function ei(e){var t,n,r,o;return[e.mode,((t=e.tokens)==null?void 0:t.surface)??"",((n=e.tokens)==null?void 0:n.surfaceMuted)??"",((r=e.tokens)==null?void 0:r.text)??"",((o=e.tokens)==null?void 0:o.accent)??"",JSON.stringify(e.variables??{})].join(":")}function Ge(e){return e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.every(Ge):typeof e!="object"||e===null?!1:Object.values(e).every(Ge)}function ti(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.channel!==H?!1:t.type==="artifact.ready"||t.type==="artifact.scroll"&&typeof t.scrollTop=="number"&&Number.isFinite(t.scrollTop)||t.type==="artifact.resize"&&typeof t.height=="number"&&(t.reason==="content"||t.reason==="viewport"||t.reason==="renderer")?!0:t.type==="artifact.event"&&(t.name===void 0||typeof t.name=="string")&&(t.detail===void 0||Ge(t.detail))}function pe(e){return e.replace(/<\/script/gi,"<\\/script").replace(/<!--/g,"<\\!--")}function De(e){return e.replace(/<\/style/gi,"<\\/style")}function Pe(e){const t={channel:H,rootId:et,...e};return`<script>window.__dvinaFrame=${pe(JSON.stringify(t))};<\/script><script>${pe($r)}<\/script>`}function ni(e,t,n,r,o={}){const a=`<base href="${ke(t)}"><style>html, body { margin: 0; padding: 0; background: transparent; }</style>${Pe({initialData:n,theme:r,safeArea:o})}`;return/<head[^>]*>/i.test(e)?e.replace(/<head([^>]*)>/i,`<head$1>${a}`):/<html[^>]*>/i.test(e)?e.replace(/<html([^>]*)>/i,`<html$1><head>${a}</head>`):`<!doctype html><html><head>${a}</head><body>${e}</body></html>`}function ri(e,t,n={}){return`<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><style>html, body { margin: 0; padding: 0; background: transparent; }</style>${Pe({initialData:e,theme:t,safeArea:n,stream:"document"})}</head><body><div id="${et}"></div></body></html>`}function ii(e,t,n,r,o={}){const a=t.layout??"panel",i=fe,c=f=>ke(Be(f)),s=f=>i.inline?`<script>${pe(f)}<\/script>`:`<script src="${c(f)}"><\/script>`,l=Pe({initialData:n,theme:r,safeArea:o,widget:{layout:a,bridge:t.bridge!==!1,labels:t.labels,data:t.data===!0,pictures:t.pictures??t.bridge!==!1}}),p=`<meta http-equiv="Content-Security-Policy" content="${ke(Qt())}" /><style>${en[a]}</style>${l}${s(i.svgMenu)}`;return e.replace(/<html([^>]*)>/i,(f,g)=>`<html${g.replace(/\s(data-widget-layout|data-theme-mode)="[^"]*"/g,"")} data-widget-layout="${a}" data-theme-mode="${r.mode}">`).replace(/<head([^>]*)>/i,`<head$1>${p}`)}function St(e,t,n,r={},o,a){const i=e.layout??"inline",c=e.kind==="react",s=e.kit===void 0?void 0:e.kit||{},l=fe,p=Pe({initialData:t,theme:n,safeArea:r,stream:"fragment",widget:{layout:i,bridge:e.bridge!==!1,labels:e.labels,data:e.data===!0,pictures:e.pictures??e.bridge!==!1},initialHtml:o,initialReact:a,kitReactUrl:s||l.inline?void 0:Be(l.kitReactScript)}),u=s??(l.inline?{css:l.kitCss,script:l.kitScript,reactScript:l.kitReactScript}:null),f=w=>ke(Be(w)),g=u?u.css?`<style id="dvina-kit">${De(u.css)}</style>`:"":`<link rel="stylesheet" id="dvina-kit" href="${f(l.kitCss)}" />`,m=u?u.script?`<script id="dvina-kit-script">${pe(u.script)}<\/script>`:"":`<script id="dvina-kit-script" src="${f(l.kitScript)}"><\/script>`,x=w=>l.inline?`<script>${pe(w)}<\/script>`:`<script src="${f(w)}"><\/script>`,E=`<style type="text/tailwindcss" id="dvina-tailwind">${De(l.tailwindCss)}</style>${x(l.tailwindScript)}`,b=c?`${E}${x(l.reactLoader)}${u!=null&&u.reactScript?`<script type="text/plain" id="dvina-kit-react">${pe(u.reactScript)}<\/script>`:""}`:"",S=`<style id="dvina-tokens">${De(l.tokensCss)}</style>`;return`<!doctype html><html data-widget-layout="${i}" data-theme-mode="${n.mode}"><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><meta http-equiv="Content-Security-Policy" content="${ke(Qt())}" /><style>${en[i]}</style>${S}${g}${p}${x(l.svgMenu)}${m}${b}</head><body><div id="${et}"></div></body></html>`}function oi(e,t,n){return!Number.isFinite(e)||e<=0?t:n?Math.max(t,Math.ceil(e)):Math.ceil(e)}function ai({label:e}){return v.jsxs("div",{className:"document-loading",children:[v.jsx("div",{className:"document-spinner"}),v.jsx("p",{children:e})]})}function si({title:e,message:t}){return v.jsxs("div",{className:"document-empty-state",children:[v.jsx("h3",{children:e}),v.jsx("p",{children:t})]})}function li({document:e,session:t,theme:n,safeArea:r,artifactDataMessage:o,streamCommandMessage:a,onLoaded:i,onError:c,onTelemetry:s,onResize:l,onArtifactEvent:p,onWidgetRequest:u,widgetResponseMessage:f}){var lt,ct,ut,dt,ft,pt,mt,ht,gt,vt,bt;const g=h.useMemo(()=>Jt(e,t),[e,t]),m=h.useRef(null),x=h.useRef(!1),E=h.useRef(!1),b=h.useRef(n),S=h.useRef(r),w=h.useRef({chunks:[],completed:!1}),z=h.useRef((ct=(lt=e.renderOptions)==null?void 0:lt.html)==null?void 0:ct.artifactData),L=h.useRef([]),O=h.useRef(Vr()),[V,y]=h.useState({status:"loading"}),A=h.useRef(0),d=h.useRef(0);b.current=n,S.current=r;const D=h.useMemo(()=>ei(n),[n]),M=e.format==="widget",T=(ut=e.renderOptions)==null?void 0:ut.widget,X=M?T==null?void 0:T.artifactData:(ft=(dt=e.renderOptions)==null?void 0:dt.html)==null?void 0:ft.artifactData,K=Te(e.format)&&e.source.kind==="stream",ee=M&&(T==null?void 0:T.kind)==="react",Y=M&&((T==null?void 0:T.layout)??"inline")==="inline"?Fr(T==null?void 0:T.viewportHeight):void 0,R=h.useRef(At(Y??0)),[P,N]=h.useState(Y??0),k=h.useMemo(()=>{var $,U;const C=(M?T==null?void 0:T.revisionId:(U=($=e.renderOptions)==null?void 0:$.html)==null?void 0:U.revisionId)??"live",I=(g==null?void 0:g.url)??e.id;return`${e.id}:${C}:${I}`},[e.id,(mt=(pt=e.renderOptions)==null?void 0:pt.html)==null?void 0:mt.revisionId,M,T==null?void 0:T.revisionId,g==null?void 0:g.url]),B=k,F=h.useMemo(()=>{var $,U;const C=(U=($=e.renderOptions)==null?void 0:$.html)==null?void 0:U.sandbox,I=M?Pr:C&&C.length>0?C:Zr;return Array.from(new Set(I)).join(" ")},[M,(gt=(ht=e.renderOptions)==null?void 0:ht.html)==null?void 0:gt.sandbox]),Z=()=>{var C;if(!(!E.current||!((C=m.current)!=null&&C.contentWindow))){for(const I of L.current)m.current.contentWindow.postMessage(I,"*");L.current=[]}},W=C=>{var I;if(!E.current||!((I=m.current)!=null&&I.contentWindow)){L.current.push(C);return}m.current.contentWindow.postMessage(C,"*")},ge=()=>{L.current=L.current.filter(C=>{const I=C;return I.type!=="artifact.stream-append-html"&&I.type!=="artifact.stream-complete"&&I.type!=="artifact.stream-abort"})};h.useEffect(()=>{const C=m.current;if(!C)return;const I=$=>{const U=$.detail;W({channel:H,type:"artifact.set-zoom-transform",transform:U})};return C.addEventListener("viewer-zoom-transform",I),()=>C.removeEventListener("viewer-zoom-transform",I)},[B,V.status]),h.useEffect(()=>{z.current=X,ve.current=null,d.current=0,O.current.reset(),w.current={chunks:[],completed:!1}},[k,X]),h.useEffect(()=>{x.current=!1,E.current=!1,L.current=[],A.current=0,R.current=At(Y??0),N(Y??0)},[B,Y]);const ve=h.useRef(null),at=async()=>{ve.current??(ve.current=yt(w.current.chunks.map(I=>I.html).join("")));const C=await ve.current;W({channel:H,type:"artifact.react-module",...C})},Tn=()=>{if(K){if(ee){w.current.completed&&at();return}for(const C of w.current.chunks)W({channel:H,type:"artifact.stream-append-html",html:C.html,sequence:C.sequence});w.current.completed&&W({channel:H,type:"artifact.stream-complete"})}};h.useEffect(()=>{var $,U;if(K&&M){let q=!0;return Et().then(()=>{q&&y({status:"srcdoc",markup:St(T??{},X,b.current,S.current)})}),s==null||s("info","html.render.mode","Widget stream shell mounted.",{documentId:e.id,mode:"widget-stream-shell"}),()=>{q=!1}}if(K){y({status:"srcdoc",markup:ri(X,b.current,S.current)}),s==null||s("info","html.render.mode","Executable HTML stream shell mounted.",{documentId:e.id,mode:"stream-shell"});return}if(!g){y({status:"error",message:"The HTML artifact does not expose a preview-safe URL."});return}const C=new AbortController,I=M||((U=($=e.renderOptions)==null?void 0:$.html)==null?void 0:U.bootstrap)!=="off";return y({status:"loading"}),!I&&e.source.kind==="url"?(y({status:"url",url:g.url}),s==null||s("info","html.render.mode","HTML artifact is loading from a direct URL.",{documentId:e.id,mode:"url"}),()=>C.abort()):(fetch(g.url,{...g.init,signal:C.signal}).then(async q=>{var wt,xt;if(!q.ok)throw new Error(`Request failed with status ${q.status}`);const ce=await q.text();M&&await Et(),y({status:"srcdoc",markup:M&&qr(ce)?ii(ce,T??{},X,b.current,S.current):M?St(T??{},X,b.current,S.current,ee?void 0:ce,ee?await yt(ce):void 0):I?ni(ce,g.url,(xt=(wt=e.renderOptions)==null?void 0:wt.html)==null?void 0:xt.artifactData,b.current,S.current):ce}),s==null||s("info","html.render.mode",I?"HTML artifact is loading through sandboxed srcdoc bootstrap.":"HTML artifact is loading through sandboxed srcdoc without bootstrap.",{documentId:e.id,mode:I?"srcdoc-bootstrap":"srcdoc"})}).catch(q=>{if(!C.signal.aborted){if(e.source.kind==="url"&&!M){y({status:"url",url:g.url}),s==null||s("warn","html.render.fallback","HTML bootstrap fetch failed, falling back to direct URL mode.",{documentId:e.id,error:q instanceof Error?q.message:"Unknown fetch failure"});return}y({status:"error",message:q instanceof Error?q.message:"Unknown HTML fetch failure"})}}),()=>C.abort())},[e,K,s,g]),h.useEffect(()=>{W({channel:H,type:"artifact.set-theme",theme:n})},[D]),h.useEffect(()=>{E.current&&W({channel:H,type:"artifact.set-safe-area",safeArea:r??{}})},[r]),h.useEffect(()=>{o&&(z.current=o.data,W({channel:H,type:"artifact.update-data",data:o.data}))},[o==null?void 0:o.nonce]),h.useEffect(()=>{const C=(a==null?void 0:a.commands)??[];if(C.length<d.current&&(d.current=0),!!K){for(const I of C.slice(d.current))jn(I);d.current=C.length}},[K,a==null?void 0:a.nonce]);function jn(C){if(C.type==="append"){const I=O.current.push({html:C.html,sequence:C.sequence});for(const $ of I)w.current.chunks.push($),!ee&&W({channel:H,type:"artifact.stream-append-html",html:$.html,sequence:$.sequence});return}if(C.type==="abort"){O.current.reset(),w.current={chunks:[],completed:!1},W({channel:H,type:"artifact.stream-abort",reason:C.reason});return}if(w.current.completed=!0,ee){at();return}W({channel:H,type:"artifact.stream-complete"})}const Mn=h.useRef(Kr({isUserActive:Yr,now:()=>performance.now()})),Ne=h.useRef(new Map),Pn=h.useRef(0),Le=(C,I)=>{var $,U;(U=($=m.current)==null?void 0:$.contentWindow)==null||U.postMessage({channel:H,jsonrpc:"2.0",id:C,...I},"*")},Nn=C=>{if(M&&(T==null?void 0:T.bridge)===!1&&!(T.pictures&&Qr(C))){Le(C.id,{error:{code:"bridge-off",message:"The widget bridge is off."}});return}const I=Mn.current(C.method,C.params);if(!I.ok){Le(C.id,{error:I.error});return}if(!u){Le(C.id,{error:{code:"no-handler",message:"The host takes no widget requests."}});return}const $=`${e.id}:${++Pn.current}`;Ne.current.set($,C.id),u({requestId:$,method:I.method,params:I.params})},Ce=h.useRef(0);if(h.useEffect(()=>{const C=(f==null?void 0:f.payloads)??[];C.length<Ce.current&&(Ce.current=0);for(const{requestId:I,result:$,error:U}of C.slice(Ce.current)){const q=Ne.current.get(I);q!==void 0&&(Ne.current.delete(I),Le(q,U?{error:U}:{result:$??null}))}Ce.current=C.length},[f==null?void 0:f.nonce]),h.useEffect(()=>{const C=I=>{var $;if(I.source===(($=m.current)==null?void 0:$.contentWindow)){if(Jr(I.data)){Nn(I.data);return}if(ti(I.data)){if(I.data.type==="artifact.ready"){E.current=!0,z.current!==void 0&&W({channel:H,type:"artifact.update-data",data:z.current}),ge(),Z(),W({channel:H,type:"artifact.set-safe-area",safeArea:S.current??{}}),Tn(),s==null||s("info","html.artifact.ready","Executable HTML artifact announced readiness.",{documentId:e.id});return}if(I.data.type==="artifact.resize"){const U=oi(I.data.height,A.current,K&&!M);if(U<=0)return;if(A.current=U,Y===void 0){l==null||l(U,I.data.reason);return}const q=zr(R.current,U,Y);R.current=q.frame,N(q.frame.height),l==null||l(q.shown,I.data.reason);return}if(I.data.type==="artifact.scroll"){window.dispatchEvent(new CustomEvent(We,{detail:{scrollTop:I.data.scrollTop}}));return}I.data.type==="artifact.event"&&I.data.name&&(p==null||p(I.data.name,I.data.detail))}}};return window.addEventListener("message",C),()=>window.removeEventListener("message",C)},[e.id,K,p,l,s,u,B,Y,T==null?void 0:T.bridge]),h.useEffect(()=>{V.status==="error"&&c("document-fetch-failed",V.message,!0)},[c,V]),V.status==="loading")return M&&((T==null?void 0:T.layout)??"inline")==="inline"?null:v.jsx(ai,{label:"Preparing executable HTML artifact"});if(V.status==="error")return v.jsx(si,{title:"HTML preview unavailable",message:V.message});const st={ref:m,key:B,className:"document-html-frame",style:Y===void 0?{colorScheme:n.mode}:{colorScheme:n.mode,height:`${P}px`},allow:"clipboard-write","data-viewer-zoom-target":"","data-viewer-zoom-bridge":"html",title:e.name,sandbox:F,onLoad:()=>{x.current||(x.current=!0,i())},onError:()=>{c("renderer-failed","The executable HTML iframe could not be mounted.",!0)}};return v.jsx("div",{className:"document-html-shell","data-safe-area-fallback":!F.split(" ").includes("allow-scripts")||V.status==="url"||!K&&((bt=(vt=e.renderOptions)==null?void 0:vt.html)==null?void 0:bt.bootstrap)==="off",children:V.status==="srcdoc"?v.jsx("iframe",{...st,srcDoc:V.markup}):v.jsx("iframe",{...st,src:V.url})})}const Lt=48;function ci({distance:e=Lt,onProgress:t,requestFrame:n=o=>window.requestAnimationFrame(o),cancelFrame:r=o=>window.cancelAnimationFrame(o)}){let o=e,a=null,i=0,c=0;const s=new WeakMap;function l(g){const m=Math.min(1,Math.max(0,g/o));return Math.round(m*100)/100}function p(){if(i=0,a===null)return;const g=l(a);a=null,g!==c&&(c=g,t(g))}function u(g){Number.isFinite(g)&&(a=g,i||(i=n(p)))}function f(g){if(g instanceof Document){const m=g.scrollingElement??g.documentElement;return{key:g,top:m.scrollTop}}return g instanceof Element?{key:g,top:g.scrollTop}:null}return{handleScroll(g){const m=f(g.target);if(!m)return;const x=s.get(m.key)??0;s.set(m.key,m.top),m.top!==x&&u(m.top)},report:u,reset(){a=null,i&&r(i),i=0,c!==0&&(c=0,t(0))},setDistance(g){o=g!==void 0&&Number.isFinite(g)&&g>0?g:Lt},dispose(){i&&r(i),i=0,a=null}}}const te=1,ui=4,di=.015,Ct=3;function It(e){return Math.min(ui,Math.max(te,e))}function fi(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function Rt(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function pi(e){const t=e.querySelector("[data-viewer-zoom-target]");return t?t.dataset.viewerZoomBridge==="html"?{kind:"bridge",element:t}:{kind:"element",element:t}:null}function mi(e,t){if(e.kind==="bridge"){e.element.dispatchEvent(new CustomEvent("viewer-zoom-transform",{detail:t}));return}e.element.style.transformOrigin="0 0",e.element.style.willChange="transform",e.element.style.transform=`translate3d(${t.x}px, ${t.y}px, 0) scale(${t.scale})`}function Tt(e){if(e.kind==="bridge"){e.element.dispatchEvent(new CustomEvent("viewer-zoom-transform",{detail:{scale:te,x:0,y:0}}));return}e.element.style.removeProperty("transform"),e.element.style.removeProperty("transform-origin"),e.element.style.removeProperty("will-change")}function hi(e,t){h.useEffect(()=>{const n=e.current;if(!n||!t)return;const r=new Map;let o=null,a=null,i={scale:te,x:0,y:0},c=0,s=te,l=null,p=null,u=!1,f=0;const g=()=>{n.style.touchAction=i.scale>te?"none":"pan-x pan-y"},m=()=>{if(o??(o=pi(n)),o&&!a){const y=n.getBoundingClientRect(),A=o.element.getBoundingClientRect();a={x:A.left-y.left,y:A.top-y.top}}return o},x=y=>{const A=n.getBoundingClientRect();return{x:y.clientX-A.left,y:y.clientY-A.top}},E=()=>(m(),a??{x:0,y:0}),b=()=>{f=0;const y=m();y&&mi(y,i)},S=y=>{i=y,g(),f||(f=requestAnimationFrame(b))},w=()=>{const y=Array.from(r.values());y.length<2||!m()||(c=Math.max(Rt(y[0],y[1]),1),s=i.scale,l=null,p=null,u=!0)},z=y=>{var A;if(y.pointerType==="touch"){if(r.set(y.pointerId,x(y)),r.size===2){m(),y.preventDefault(),(A=n.setPointerCapture)==null||A.call(n,y.pointerId),w();return}r.size===1&&i.scale>te&&m()&&(l=x(y),p={...i},u=!1)}},L=y=>{if(y.pointerType!=="touch"||!r.has(y.pointerId))return;r.set(y.pointerId,x(y));const A=Array.from(r.values());if(A.length>=2&&c>0){y.preventDefault();const d=fi(A[0],A[1]),D=It(s*(Rt(A[0],A[1])/c)),M=D/i.scale,T=E();S({scale:D,x:d.x-T.x-(d.x-T.x-i.x)*M,y:d.y-T.y-(d.y-T.y-i.y)*M});return}if(A.length===1&&i.scale>te&&l&&p){const d=A[0],D=d.x-l.x,M=d.y-l.y;(Math.abs(D)>Ct||Math.abs(M)>Ct)&&(u=!0),u&&(y.preventDefault(),S({scale:i.scale,x:p.x+D,y:p.y+M}))}},O=y=>{var A;if(!(y.pointerType!=="touch"||!r.has(y.pointerId))){if(r.delete(y.pointerId),(A=n.releasePointerCapture)==null||A.call(n,y.pointerId),r.size>=2){w();return}if(r.size===1&&i.scale>te){l=Array.from(r.values())[0],p={...i};return}c=0,l=null,p=null,i.scale-te<di&&(f&&(cancelAnimationFrame(f),f=0),i={scale:te,x:0,y:0},o&&Tt(o)),g()}},V=y=>{if(!y.ctrlKey&&!y.metaKey||!m())return;y.preventDefault();const A=x(y),d=It(i.scale*Math.exp(-y.deltaY*.002)),D=d/i.scale,M=E();S({scale:d,x:A.x-M.x-(A.x-M.x-i.x)*D,y:A.y-M.y-(A.y-M.y-i.y)*D})};return g(),n.addEventListener("pointerdown",z),n.addEventListener("pointermove",L),n.addEventListener("pointerup",O),n.addEventListener("pointercancel",O),n.addEventListener("wheel",V,{passive:!1}),()=>{f&&cancelAnimationFrame(f),n.removeEventListener("pointerdown",z),n.removeEventListener("pointermove",L),n.removeEventListener("pointerup",O),n.removeEventListener("pointercancel",O),n.removeEventListener("wheel",V),n.style.removeProperty("touch-action"),o&&Tt(o)}},[e,t])}const gi={json:"json",jsonl:"json",ndjson:"json",yaml:"yaml",tsv:"tsv",xml:"xml",toml:"toml",ini:"ini",dotenv:"dotenv"},vi=new Set(["code","json","jsonl","ndjson","yaml","tsv","xml","toml","ini","dotenv"]),bi={".astro":"astro",".bash":"bash",".bat":"bat",".c":"c",".cc":"cpp",".cjs":"javascript",".cls":"apex",".cmake":"cmake",".cpp":"cpp",".cs":"csharp",".css":"css",".cts":"typescript",".cue":"cue",".dart":"dart",".dockerfile":"docker",".env":"dotenv",".go":"go",".graphql":"graphql",".groovy":"groovy",".h":"c",".hpp":"cpp",".html":"html",".ini":"ini",".java":"java",".js":"javascript",".json":"json",".jsonl":"json",".json5":"json5",".jsonc":"jsonc",".jsx":"jsx",".kt":"kotlin",".kts":"kotlin",".less":"less",".lua":"lua",".mdx":"mdx",".mjs":"javascript",".mts":"typescript",".php":"php",".pl":"perl",".ps1":"powershell",".py":"python",".r":"r",".rb":"ruby",".rs":"rust",".sass":"sass",".scala":"scala",".scss":"scss",".sh":"bash",".sol":"solidity",".sql":"sql",".svelte":"svelte",".swift":"swift",".tab":"tsv",".tsv":"tsv",".toml":"toml",".ts":"typescript",".tsx":"tsx",".vue":"vue",".xml":"xml",".xsl":"xml",".yaml":"yaml",".yml":"yaml",".zsh":"zsh"},jt={"application/ecmascript":"javascript","application/javascript":"javascript","application/jsonl":"json","application/ndjson":"json","application/sql":"sql","application/toml":"toml","application/typescript":"typescript","application/x-env":"dotenv","application/x-httpd-php":"php","application/x-jsonlines":"json","application/x-ndjson":"json","application/x-sh":"bash","application/x-toml":"toml","application/xml":"xml","text/css":"css","text/env":"dotenv","text/html":"html","text/ini":"ini","text/javascript":"javascript","text/jsx":"jsx","text/plain+dotenv":"dotenv","text/plain+php":"php","text/python":"python","text/rust":"rust","text/scala":"scala","text/sh":"bash","text/sql":"sql","text/tab-separated-values":"tsv","text/toml":"toml","text/typescript":"typescript","text/x-c":"c","text/x-c++src":"cpp","text/x-csharp":"csharp","text/x-env":"dotenv","text/x-go":"go","text/x-ini":"ini","text/x-java-source":"java","text/x-jsonl":"json","text/x-ndjson":"json","text/x-kotlin":"kotlin","text/x-python":"python","text/x-ruby":"ruby","text/x-shellscript":"bash","text/x-swift":"swift","text/x-toml":"toml","text/xml":"xml"},Mt={dockerfile:"docker",makefile:"make"};let Oe,Fe;function wi(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function xi(e){return`<pre class="code-preview-fallback"><code>${wi(e)}</code></pre>`}function yi(e){const n=e.toLowerCase().match(/(\.[a-z0-9]+)$/);return(n==null?void 0:n[1])??null}function tn(e){var i,c,s,l;const t=(c=(i=e.renderOptions)==null?void 0:i.codeLanguage)==null?void 0:c.trim();if(t)return t;const n=gi[e.format];if(n)return n;const r=(l=(s=e.mimeType)==null?void 0:s.toLowerCase().split(";")[0])==null?void 0:l.trim();if(r&&jt[r])return jt[r];const o=e.name.toLowerCase();if(Mt[o])return Mt[o];const a=yi(e.name);return a?bi[a]:void 0}function Pt(e){return vi.has(e.format)||e.format==="text"&&!!tn(e)}async function nn(){return Oe||(Oe=se(()=>import("./index-DzCiO5xC.js"),__vite__mapDeps([0,1]))),Oe}async function ki(){return Fe||(Fe=nn().then(e=>{const t=new Map;for(const n of e.bundledLanguagesInfo){t.set(n.id.toLowerCase(),{id:n.id,name:n.name});for(const r of n.aliases??[])t.set(r.toLowerCase(),{id:n.id,name:n.name})}return t})),Fe}async function Ei(e,t,n="light"){const[r,o]=await Promise.all([nn(),ki()]),a=t==null?void 0:t.trim().toLowerCase(),i=a?o.get(a):void 0;return i?{html:await r.codeToHtml(e,{lang:i.id,theme:n==="dark"?"houston":"light-plus"}),languageLabel:i.name,highlighted:!0,canonicalLanguage:i.id}:{html:xi(e),languageLabel:(t==null?void 0:t.trim())||"Plain text",highlighted:!1,canonicalLanguage:void 0}}function rn({source:e,title:t,languageHint:n,themeMode:r,onRendered:o,onError:a,onTelemetry:i}){const[c,s]=h.useState({status:"loading"}),l=h.useMemo(()=>e.replace(/\r\n/g,`
|
|
145
|
+
`),[e]),p=h.useMemo(()=>l.split(`
|
|
146
|
+
`).length,[l]);return h.useEffect(()=>{if(!l.trim()){const f="The code document is empty.";s({status:"error",error:f}),i==null||i("warn","code-preview.skipped",f,{languageHint:n??null}),a==null||a(f);return}let u=!1;return s({status:"loading"}),i==null||i("info","code-preview.started","Started code preview render.",{languageHint:n??null,lineCount:p}),Ei(l,n,r).then(f=>{u||(s({status:"ready",html:f.html,languageLabel:f.languageLabel,highlighted:f.highlighted}),i==null||i(f.highlighted?"info":"warn",f.highlighted?"code-preview.rendered":"code-preview.fallback",f.highlighted?"Rendered highlighted code preview.":"Rendered code preview without syntax highlighting.",{languageHint:n??null,resolvedLanguage:f.canonicalLanguage??null}),o==null||o())}).catch(f=>{if(u)return;const g=f instanceof Error?f.message:"The code preview could not be rendered.";s({status:"error",error:g}),i==null||i("error","code-preview.failed",g,{languageHint:n??null}),a==null||a(g)}),()=>{u=!0}},[n,p,l,a,o,i,r]),c.status==="loading"?v.jsxs("div",{className:"code-preview-shell code-preview-shell-loading","aria-live":"polite",children:[v.jsx("div",{className:"document-spinner"}),v.jsx("p",{children:"Rendering code preview..."})]}):c.status==="error"?v.jsxs("div",{className:"code-preview-shell code-preview-error",role:"status",children:[v.jsx("p",{children:c.error}),v.jsx("pre",{children:v.jsx("code",{children:e})})]}):v.jsx("div",{className:"code-preview-shell",children:v.jsx("div",{className:"code-preview-body",dangerouslySetInnerHTML:{__html:c.html}})})}function Nt(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,o=n.indexOf(t);for(;o!==-1;)r++,o=n.indexOf(t,o+t.length);return r}function Ai(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Si(e,t,n){const o=Ut((n||{}).ignore||[]),a=Li(t);let i=-1;for(;++i<a.length;)_n(e,"text",c);function c(l,p){let u=-1,f;for(;++u<p.length;){const g=p[u],m=f?f.children:void 0;if(o(g,m?m.indexOf(g):void 0,f))return;f=g}if(f)return s(l,p)}function s(l,p){const u=p[p.length-1],f=a[i][0],g=a[i][1];let m=0;const E=u.children.indexOf(l);let b=!1,S=[];f.lastIndex=0;let w=f.exec(l.value);for(;w;){const z=w.index,L={index:w.index,input:w.input,stack:[...p,l]};let O=g(...w,L);if(typeof O=="string"&&(O=O.length>0?{type:"text",value:O}:void 0),O===!1?f.lastIndex=z+1:(m!==z&&S.push({type:"text",value:l.value.slice(m,z)}),Array.isArray(O)?S.push(...O):O&&S.push(O),m=z+w[0].length,b=!0),!f.global)break;w=f.exec(l.value)}return b?(m<l.value.length&&S.push({type:"text",value:l.value.slice(m)}),u.children.splice(E,1,...S)):S=[l],E+S.length}}function Li(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const o=n[r];t.push([Ci(o[0]),Ii(o[1])])}return t}function Ci(e){return typeof e=="string"?new RegExp(Ai(e),"g"):e}function Ii(e){return typeof e=="function"?e:function(){return e}}const ze="phrasing",$e=["autolink","link","image","label"];function Ri(){return{transforms:[Di],enter:{literalAutolink:ji,literalAutolinkEmail:Ve,literalAutolinkHttp:Ve,literalAutolinkWww:Ve},exit:{literalAutolink:_i,literalAutolinkEmail:Ni,literalAutolinkHttp:Mi,literalAutolinkWww:Pi}}}function Ti(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ze,notInConstruct:$e},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ze,notInConstruct:$e},{character:":",before:"[ps]",after:"\\/",inConstruct:ze,notInConstruct:$e}]}}function ji(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Ve(e){this.config.enter.autolinkProtocol.call(this,e)}function Mi(e){this.config.exit.autolinkProtocol.call(this,e)}function Pi(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];he(t.type==="link"),t.url="http://"+this.sliceSerialize(e)}function Ni(e){this.config.exit.autolinkEmail.call(this,e)}function _i(e){this.exit(e)}function Di(e){Si(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Oi],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Fi]],{ignore:["link","linkReference"]})}function Oi(e,t,n,r,o){let a="";if(!on(o)||(/^w/i.test(t)&&(n=t+n,t="",a="http://"),!zi(n)))return!1;const i=$i(n+r);if(!i[0])return!1;const c={type:"link",title:null,url:a+t+i[0],children:[{type:"text",value:t+i[0]}]};return i[1]?[c,{type:"text",value:i[1]}]:c}function Fi(e,t,n,r){return!on(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function zi(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function $i(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const o=Nt(e,"(");let a=Nt(e,")");for(;r!==-1&&o>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),a++;return[e,n]}function on(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||me(n)||Ye(n))&&(!t||n!==47)}an.peek=Ki;function Vi(){this.buffer()}function Ui(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function qi(){this.buffer()}function Hi(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Bi(e){const t=this.resume(),n=this.stack[this.stack.length-1];he(n.type==="footnoteReference"),n.identifier=Ae(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Wi(e){this.exit(e)}function Gi(e){const t=this.resume(),n=this.stack[this.stack.length-1];he(n.type==="footnoteDefinition"),n.identifier=Ae(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Xi(e){this.exit(e)}function Ki(){return"["}function an(e,t,n,r){const o=n.createTracker(r);let a=o.move("[^");const i=n.enter("footnoteReference"),c=n.enter("reference");return a+=o.move(n.safe(n.associationId(e),{after:"]",before:a})),c(),i(),a+=o.move("]"),a}function Yi(){return{enter:{gfmFootnoteCallString:Vi,gfmFootnoteCall:Ui,gfmFootnoteDefinitionLabelString:qi,gfmFootnoteDefinition:Hi},exit:{gfmFootnoteCallString:Bi,gfmFootnoteCall:Wi,gfmFootnoteDefinitionLabelString:Gi,gfmFootnoteDefinition:Xi}}}function Zi(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:an},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,o,a,i){const c=a.createTracker(i);let s=c.move("[^");const l=a.enter("footnoteDefinition"),p=a.enter("label");return s+=c.move(a.safe(a.associationId(r),{before:s,after:"]"})),p(),s+=c.move("]:"),r.children&&r.children.length>0&&(c.shift(4),s+=c.move((t?`
|
|
147
|
+
`:" ")+a.indentLines(a.containerFlow(r,c.current()),t?sn:Ji))),l(),s}}function Ji(e,t,n){return t===0?e:sn(e,t,n)}function sn(e,t,n){return(n?"":" ")+e}const Qi=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];ln.peek=io;function eo(){return{canContainEols:["delete"],enter:{strikethrough:no},exit:{strikethrough:ro}}}function to(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Qi}],handlers:{delete:ln}}}function no(e){this.enter({type:"delete",children:[]},e)}function ro(e){this.exit(e)}function ln(e,t,n,r){const o=n.createTracker(r),a=n.enter("strikethrough");let i=o.move("~~");return i+=n.containerPhrasing(e,{...o.current(),before:i,after:"~"}),i+=o.move("~~"),a(),i}function io(){return"~"}function oo(e){return e.length}function ao(e,t){const n=t||{},r=(n.align||[]).concat(),o=n.stringLength||oo,a=[],i=[],c=[],s=[];let l=0,p=-1;for(;++p<e.length;){const x=[],E=[];let b=-1;for(e[p].length>l&&(l=e[p].length);++b<e[p].length;){const S=so(e[p][b]);if(n.alignDelimiters!==!1){const w=o(S);E[b]=w,(s[b]===void 0||w>s[b])&&(s[b]=w)}x.push(S)}i[p]=x,c[p]=E}let u=-1;if(typeof r=="object"&&"length"in r)for(;++u<l;)a[u]=_t(r[u]);else{const x=_t(r);for(;++u<l;)a[u]=x}u=-1;const f=[],g=[];for(;++u<l;){const x=a[u];let E="",b="";x===99?(E=":",b=":"):x===108?E=":":x===114&&(b=":");let S=n.alignDelimiters===!1?1:Math.max(1,s[u]-E.length-b.length);const w=E+"-".repeat(S)+b;n.alignDelimiters!==!1&&(S=E.length+S+b.length,S>s[u]&&(s[u]=S),g[u]=S),f[u]=w}i.splice(1,0,f),c.splice(1,0,g),p=-1;const m=[];for(;++p<i.length;){const x=i[p],E=c[p];u=-1;const b=[];for(;++u<l;){const S=x[u]||"";let w="",z="";if(n.alignDelimiters!==!1){const L=s[u]-(E[u]||0),O=a[u];O===114?w=" ".repeat(L):O===99?L%2?(w=" ".repeat(L/2+.5),z=" ".repeat(L/2-.5)):(w=" ".repeat(L/2),z=w):z=" ".repeat(L)}n.delimiterStart!==!1&&!u&&b.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&S==="")&&(n.delimiterStart!==!1||u)&&b.push(" "),n.alignDelimiters!==!1&&b.push(w),b.push(S),n.alignDelimiters!==!1&&b.push(z),n.padding!==!1&&b.push(" "),(n.delimiterEnd!==!1||u!==l-1)&&b.push("|")}m.push(n.delimiterEnd===!1?b.join("").replace(/ +$/,""):b.join(""))}return m.join(`
|
|
148
|
+
`)}function so(e){return e==null?"":String(e)}function _t(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function lo(e,t,n,r){const o=n.enter("blockquote"),a=n.createTracker(r);a.move("> "),a.shift(2);const i=n.indentLines(n.containerFlow(e,a.current()),co);return o(),i}function co(e,t,n){return">"+(n?"":" ")+e}function uo(e,t){return Dt(e,t.inConstruct,!0)&&!Dt(e,t.notInConstruct,!1)}function Dt(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Ot(e,t,n,r){let o=-1;for(;++o<n.unsafe.length;)if(n.unsafe[o].character===`
|
|
149
|
+
`&&uo(n.stack,n.unsafe[o]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
150
|
+
`}function fo(e,t){const n=String(e);let r=n.indexOf(t),o=r,a=0,i=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===o?++a>i&&(i=a):a=1,o=r+t.length,r=n.indexOf(t,o);return i}function po(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function mo(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function ho(e,t,n,r){const o=mo(n),a=e.value||"",i=o==="`"?"GraveAccent":"Tilde";if(po(e,n)){const u=n.enter("codeIndented"),f=n.indentLines(a,go);return u(),f}const c=n.createTracker(r),s=o.repeat(Math.max(fo(a,o)+1,3)),l=n.enter("codeFenced");let p=c.move(s);if(e.lang){const u=n.enter(`codeFencedLang${i}`);p+=c.move(n.safe(e.lang,{before:p,after:" ",encode:["`"],...c.current()})),u()}if(e.lang&&e.meta){const u=n.enter(`codeFencedMeta${i}`);p+=c.move(" "),p+=c.move(n.safe(e.meta,{before:p,after:`
|
|
151
|
+
`,encode:["`"],...c.current()})),u()}return p+=c.move(`
|
|
152
|
+
`),a&&(p+=c.move(a+`
|
|
153
|
+
`)),p+=c.move(s),l(),p}function go(e,t,n){return(n?"":" ")+e}function tt(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function vo(e,t,n,r){const o=tt(n),a=o==='"'?"Quote":"Apostrophe",i=n.enter("definition");let c=n.enter("label");const s=n.createTracker(r);let l=s.move("[");return l+=s.move(n.safe(n.associationId(e),{before:l,after:"]",...s.current()})),l+=s.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),l+=s.move("<"),l+=s.move(n.safe(e.url,{before:l,after:">",...s.current()})),l+=s.move(">")):(c=n.enter("destinationRaw"),l+=s.move(n.safe(e.url,{before:l,after:e.title?" ":`
|
|
154
|
+
`,...s.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=s.move(" "+o),l+=s.move(n.safe(e.title,{before:l,after:o,...s.current()})),l+=s.move(o),c()),i(),l}function bo(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Ee(e){return"&#x"+e.toString(16).toUpperCase()+";"}function je(e,t,n){const r=Re(e),o=Re(t);return r===void 0?o===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}cn.peek=wo;function cn(e,t,n,r){const o=bo(n),a=n.enter("emphasis"),i=n.createTracker(r),c=i.move(o);let s=i.move(n.containerPhrasing(e,{after:o,before:c,...i.current()}));const l=s.charCodeAt(0),p=je(r.before.charCodeAt(r.before.length-1),l,o);p.inside&&(s=Ee(l)+s.slice(1));const u=s.charCodeAt(s.length-1),f=je(r.after.charCodeAt(0),u,o);f.inside&&(s=s.slice(0,-1)+Ee(u));const g=i.move(o);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:p.outside},c+s+g}function wo(e,t,n){return n.options.emphasis||"*"}function xo(e,t){let n=!1;return Dn(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,On}),!!((!e.depth||e.depth<3)&&qt(e)&&(t.options.setext||n))}function yo(e,t,n,r){const o=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(xo(e,n)){const p=n.enter("headingSetext"),u=n.enter("phrasing"),f=n.containerPhrasing(e,{...a.current(),before:`
|
|
155
|
+
`,after:`
|
|
156
|
+
`});return u(),p(),f+`
|
|
157
|
+
`+(o===1?"=":"-").repeat(f.length-(Math.max(f.lastIndexOf("\r"),f.lastIndexOf(`
|
|
158
|
+
`))+1))}const i="#".repeat(o),c=n.enter("headingAtx"),s=n.enter("phrasing");a.move(i+" ");let l=n.containerPhrasing(e,{before:"# ",after:`
|
|
159
|
+
`,...a.current()});return/^[\t ]/.test(l)&&(l=Ee(l.charCodeAt(0))+l.slice(1)),l=l?i+" "+l:i,n.options.closeAtx&&(l+=" "+i),s(),c(),l}un.peek=ko;function un(e){return e.value||""}function ko(){return"<"}dn.peek=Eo;function dn(e,t,n,r){const o=tt(n),a=o==='"'?"Quote":"Apostrophe",i=n.enter("image");let c=n.enter("label");const s=n.createTracker(r);let l=s.move("![");return l+=s.move(n.safe(e.alt,{before:l,after:"]",...s.current()})),l+=s.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),l+=s.move("<"),l+=s.move(n.safe(e.url,{before:l,after:">",...s.current()})),l+=s.move(">")):(c=n.enter("destinationRaw"),l+=s.move(n.safe(e.url,{before:l,after:e.title?" ":")",...s.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=s.move(" "+o),l+=s.move(n.safe(e.title,{before:l,after:o,...s.current()})),l+=s.move(o),c()),l+=s.move(")"),i(),l}function Eo(){return"!"}fn.peek=Ao;function fn(e,t,n,r){const o=e.referenceType,a=n.enter("imageReference");let i=n.enter("label");const c=n.createTracker(r);let s=c.move("![");const l=n.safe(e.alt,{before:s,after:"]",...c.current()});s+=c.move(l+"]["),i();const p=n.stack;n.stack=[],i=n.enter("reference");const u=n.safe(n.associationId(e),{before:s,after:"]",...c.current()});return i(),n.stack=p,a(),o==="full"||!l||l!==u?s+=c.move(u+"]"):o==="shortcut"?s=s.slice(0,-1):s+=c.move("]"),s}function Ao(){return"!"}pn.peek=So;function pn(e,t,n){let r=e.value||"",o="`",a=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(r);)o+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++a<n.unsafe.length;){const i=n.unsafe[a],c=n.compilePattern(i);let s;if(i.atBreak)for(;s=c.exec(r);){let l=s.index;r.charCodeAt(l)===10&&r.charCodeAt(l-1)===13&&l--,r=r.slice(0,l)+" "+r.slice(s.index+1)}}return o+r+o}function So(){return"`"}function mn(e,t){const n=qt(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}hn.peek=Lo;function hn(e,t,n,r){const o=tt(n),a=o==='"'?"Quote":"Apostrophe",i=n.createTracker(r);let c,s;if(mn(e,n)){const p=n.stack;n.stack=[],c=n.enter("autolink");let u=i.move("<");return u+=i.move(n.containerPhrasing(e,{before:u,after:">",...i.current()})),u+=i.move(">"),c(),n.stack=p,u}c=n.enter("link"),s=n.enter("label");let l=i.move("[");return l+=i.move(n.containerPhrasing(e,{before:l,after:"](",...i.current()})),l+=i.move("]("),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter("destinationLiteral"),l+=i.move("<"),l+=i.move(n.safe(e.url,{before:l,after:">",...i.current()})),l+=i.move(">")):(s=n.enter("destinationRaw"),l+=i.move(n.safe(e.url,{before:l,after:e.title?" ":")",...i.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=i.move(" "+o),l+=i.move(n.safe(e.title,{before:l,after:o,...i.current()})),l+=i.move(o),s()),l+=i.move(")"),c(),l}function Lo(e,t,n){return mn(e,n)?"<":"["}gn.peek=Co;function gn(e,t,n,r){const o=e.referenceType,a=n.enter("linkReference");let i=n.enter("label");const c=n.createTracker(r);let s=c.move("[");const l=n.containerPhrasing(e,{before:s,after:"]",...c.current()});s+=c.move(l+"]["),i();const p=n.stack;n.stack=[],i=n.enter("reference");const u=n.safe(n.associationId(e),{before:s,after:"]",...c.current()});return i(),n.stack=p,a(),o==="full"||!l||l!==u?s+=c.move(u+"]"):o==="shortcut"?s=s.slice(0,-1):s+=c.move("]"),s}function Co(){return"["}function nt(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Io(e){const t=nt(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Ro(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function vn(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function To(e,t,n,r){const o=n.enter("list"),a=n.bulletCurrent;let i=e.ordered?Ro(n):nt(n);const c=e.ordered?i==="."?")":".":Io(n);let s=t&&n.bulletLastUsed?i===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((i==="*"||i==="-")&&p&&(!p.children||!p.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(s=!0),vn(n)===i&&p){let u=-1;for(;++u<e.children.length;){const f=e.children[u];if(f&&f.type==="listItem"&&f.children&&f.children[0]&&f.children[0].type==="thematicBreak"){s=!0;break}}}}s&&(i=c),n.bulletCurrent=i;const l=n.containerFlow(e,r);return n.bulletLastUsed=i,n.bulletCurrent=a,o(),l}function jo(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Mo(e,t,n,r){const o=jo(n);let a=n.bulletCurrent||nt(n);t&&t.type==="list"&&t.ordered&&(a=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let i=a.length+1;(o==="tab"||o==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(i=Math.ceil(i/4)*4);const c=n.createTracker(r);c.move(a+" ".repeat(i-a.length)),c.shift(i);const s=n.enter("listItem"),l=n.indentLines(n.containerFlow(e,c.current()),p);return s(),l;function p(u,f,g){return f?(g?"":" ".repeat(i))+u:(g?a:a+" ".repeat(i-a.length))+u}}function Po(e,t,n,r){const o=n.enter("paragraph"),a=n.enter("phrasing"),i=n.containerPhrasing(e,r);return a(),o(),i}const No=Ut(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function _o(e,t,n,r){return(e.children.some(function(i){return No(i)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Do(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}bn.peek=Oo;function bn(e,t,n,r){const o=Do(n),a=n.enter("strong"),i=n.createTracker(r),c=i.move(o+o);let s=i.move(n.containerPhrasing(e,{after:o,before:c,...i.current()}));const l=s.charCodeAt(0),p=je(r.before.charCodeAt(r.before.length-1),l,o);p.inside&&(s=Ee(l)+s.slice(1));const u=s.charCodeAt(s.length-1),f=je(r.after.charCodeAt(0),u,o);f.inside&&(s=s.slice(0,-1)+Ee(u));const g=i.move(o+o);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:p.outside},c+s+g}function Oo(e,t,n){return n.options.strong||"*"}function Fo(e,t,n,r){return n.safe(e.value,r)}function zo(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function $o(e,t,n){const r=(vn(n)+(n.options.ruleSpaces?" ":"")).repeat(zo(n));return n.options.ruleSpaces?r.slice(0,-1):r}const wn={blockquote:lo,break:Ot,code:ho,definition:vo,emphasis:cn,hardBreak:Ot,heading:yo,html:un,image:dn,imageReference:fn,inlineCode:pn,link:hn,linkReference:gn,list:To,listItem:Mo,paragraph:Po,root:_o,strong:bn,text:Fo,thematicBreak:$o};function Vo(){return{enter:{table:Uo,tableData:Ft,tableHeader:Ft,tableRow:Ho},exit:{codeText:Bo,table:qo,tableData:Ue,tableHeader:Ue,tableRow:Ue}}}function Uo(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function qo(e){this.exit(e),this.data.inTable=void 0}function Ho(e){this.enter({type:"tableRow",children:[]},e)}function Ue(e){this.exit(e)}function Ft(e){this.enter({type:"tableCell",children:[]},e)}function Bo(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Wo));const n=this.stack[this.stack.length-1];he(n.type==="inlineCode"),n.value=t,this.exit(e)}function Wo(e,t){return t==="|"?t:e}function Go(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,o=t.stringLength,a=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
160
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:i,tableCell:s,tableRow:c}};function i(g,m,x,E){return l(p(g,x,E),g.align)}function c(g,m,x,E){const b=u(g,x,E),S=l([b]);return S.slice(0,S.indexOf(`
|
|
161
|
+
`))}function s(g,m,x,E){const b=x.enter("tableCell"),S=x.enter("phrasing"),w=x.containerPhrasing(g,{...E,before:a,after:a});return S(),b(),w}function l(g,m){return ao(g,{align:m,alignDelimiters:r,padding:n,stringLength:o})}function p(g,m,x){const E=g.children;let b=-1;const S=[],w=m.enter("table");for(;++b<E.length;)S[b]=u(E[b],m,x);return w(),S}function u(g,m,x){const E=g.children;let b=-1;const S=[],w=m.enter("tableRow");for(;++b<E.length;)S[b]=s(E[b],g,m,x);return w(),S}function f(g,m,x){let E=wn.inlineCode(g,m,x);return x.stack.includes("tableCell")&&(E=E.replace(/\|/g,"\\$&")),E}}function Xo(){return{exit:{taskListCheckValueChecked:zt,taskListCheckValueUnchecked:zt,paragraph:Yo}}}function Ko(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Zo}}}function zt(e){const t=this.stack[this.stack.length-2];he(t.type==="listItem"),t.checked=e.type==="taskListCheckValueChecked"}function Yo(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];he(n.type==="paragraph");const r=n.children[0];if(r&&r.type==="text"){const o=t.children;let a=-1,i;for(;++a<o.length;){const c=o[a];if(c.type==="paragraph"){i=c;break}}i===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function Zo(e,t,n,r){const o=e.children[0],a=typeof e.checked=="boolean"&&o&&o.type==="paragraph",i="["+(e.checked?"x":" ")+"] ",c=n.createTracker(r);a&&c.move(i);let s=wn.listItem(e,t,n,{...r,...c.current()});return a&&(s=s.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),s;function l(p){return p+i}}function Jo(){return[Ri(),Yi(),eo(),Vo(),Xo()]}function Qo(e){return{extensions:[Ti(),Zi(e),to(),Go(e),Ko()]}}const ea={tokenize:aa,partial:!0},xn={tokenize:sa,partial:!0},yn={tokenize:la,partial:!0},kn={tokenize:ca,partial:!0},ta={tokenize:ua,partial:!0},En={name:"wwwAutolink",tokenize:ia,previous:Sn},An={name:"protocolAutolink",tokenize:oa,previous:Ln},ie={name:"emailAutolink",tokenize:ra,previous:Cn},re={};function na(){return{text:re}}let le=48;for(;le<123;)re[le]=ie,le++,le===58?le=65:le===91&&(le=97);re[43]=ie;re[45]=ie;re[46]=ie;re[95]=ie;re[72]=[ie,An];re[104]=[ie,An];re[87]=[ie,En];re[119]=[ie,En];function ra(e,t,n){const r=this;let o,a;return i;function i(u){return!Xe(u)||!Cn.call(r,r.previous)||rt(r.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(u))}function c(u){return Xe(u)?(e.consume(u),c):u===64?(e.consume(u),s):n(u)}function s(u){return u===46?e.check(ta,p,l)(u):u===45||u===95||Ze(u)?(a=!0,e.consume(u),s):p(u)}function l(u){return e.consume(u),o=!0,s}function p(u){return a&&o&&ye(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(u)):n(u)}}function ia(e,t,n){const r=this;return o;function o(i){return i!==87&&i!==119||!Sn.call(r,r.previous)||rt(r.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(ea,e.attempt(xn,e.attempt(yn,a),n),n)(i))}function a(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function oa(e,t,n){const r=this;let o="",a=!1;return i;function i(u){return(u===72||u===104)&&Ln.call(r,r.previous)&&!rt(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(u),e.consume(u),c):n(u)}function c(u){if(ye(u)&&o.length<5)return o+=String.fromCodePoint(u),e.consume(u),c;if(u===58){const f=o.toLowerCase();if(f==="http"||f==="https")return e.consume(u),s}return n(u)}function s(u){return u===47?(e.consume(u),a?l:(a=!0,s)):n(u)}function l(u){return u===null||Fn(u)||J(u)||me(u)||Ye(u)?n(u):e.attempt(xn,e.attempt(yn,p),n)(u)}function p(u){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(u)}}function aa(e,t,n){let r=0;return o;function o(i){return(i===87||i===119)&&r<3?(r++,e.consume(i),o):i===46&&r===3?(e.consume(i),a):n(i)}function a(i){return i===null?n(i):t(i)}}function sa(e,t,n){let r,o,a;return i;function i(l){return l===46||l===95?e.check(kn,s,c)(l):l===null||J(l)||me(l)||l!==45&&Ye(l)?s(l):(a=!0,e.consume(l),i)}function c(l){return l===95?r=!0:(o=r,r=void 0),e.consume(l),i}function s(l){return o||r||!a?n(l):t(l)}}function la(e,t){let n=0,r=0;return o;function o(i){return i===40?(n++,e.consume(i),o):i===41&&r<n?a(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?e.check(kn,t,a)(i):i===null||J(i)||me(i)?t(i):(e.consume(i),o)}function a(i){return i===41&&r++,e.consume(i),o}}function ca(e,t,n){return r;function r(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(e.consume(c),r):c===38?(e.consume(c),a):c===93?(e.consume(c),o):c===60||c===null||J(c)||me(c)?t(c):n(c)}function o(c){return c===null||c===40||c===91||J(c)||me(c)?t(c):r(c)}function a(c){return ye(c)?i(c):n(c)}function i(c){return c===59?(e.consume(c),r):ye(c)?(e.consume(c),i):n(c)}}function ua(e,t,n){return r;function r(a){return e.consume(a),o}function o(a){return Ze(a)?n(a):t(a)}}function Sn(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||J(e)}function Ln(e){return!ye(e)}function Cn(e){return!(e===47||Xe(e))}function Xe(e){return e===43||e===45||e===46||e===95||Ze(e)}function rt(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const da={tokenize:wa,partial:!0};function fa(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:ga,continuation:{tokenize:va},exit:ba}},text:{91:{name:"gfmFootnoteCall",tokenize:ha},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:pa,resolveTo:ma}}}}function pa(e,t,n){const r=this;let o=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i;for(;o--;){const s=r.events[o][1];if(s.type==="labelImage"){i=s;break}if(s.type==="gfmFootnoteCall"||s.type==="labelLink"||s.type==="label"||s.type==="image"||s.type==="link")break}return c;function c(s){if(!i||!i._balanced)return n(s);const l=Ae(r.sliceSerialize({start:i.end,end:r.now()}));return l.codePointAt(0)!==94||!a.includes(l.slice(1))?n(s):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(s),e.exit("gfmFootnoteCallLabelMarker"),t(s))}}function ma(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},c=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",o,t],["exit",o,t],["enter",a,t],["enter",i,t],["exit",i,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...c),e}function ha(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,i;return c;function c(u){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),s}function s(u){return u!==94?n(u):(e.enter("gfmFootnoteCallMarker"),e.consume(u),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(u){if(a>999||u===93&&!i||u===null||u===91||J(u))return n(u);if(u===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return o.includes(Ae(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(u)}return J(u)||(i=!0),a++,e.consume(u),u===92?p:l}function p(u){return u===91||u===92||u===93?(e.consume(u),a++,l):l(u)}}function ga(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,i=0,c;return s;function s(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),l}function l(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):n(m)}function p(m){if(i>999||m===93&&!c||m===null||m===91||J(m))return n(m);if(m===93){e.exit("chunkString");const x=e.exit("gfmFootnoteDefinitionLabelString");return a=Ae(r.sliceSerialize(x)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return J(m)||(c=!0),i++,e.consume(m),m===92?u:p}function u(m){return m===91||m===92||m===93?(e.consume(m),i++,p):p(m)}function f(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),o.includes(a)||o.push(a),oe(e,g,"gfmFootnoteDefinitionWhitespace")):n(m)}function g(m){return t(m)}}function va(e,t,n){return e.check(zn,t,e.attempt(da,t,n))}function ba(e){e.exit("gfmFootnoteDefinition")}function wa(e,t,n){const r=this;return oe(e,o,"gfmFootnoteDefinitionIndent",5);function o(a){const i=r.events[r.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?t(a):n(a)}}function xa(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:o};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function o(i,c){let s=-1;for(;++s<i.length;)if(i[s][0]==="enter"&&i[s][1].type==="strikethroughSequenceTemporary"&&i[s][1]._close){let l=s;for(;l--;)if(i[l][0]==="exit"&&i[l][1].type==="strikethroughSequenceTemporary"&&i[l][1]._open&&i[s][1].end.offset-i[s][1].start.offset===i[l][1].end.offset-i[l][1].start.offset){i[s][1].type="strikethroughSequence",i[l][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},i[l][1].start),end:Object.assign({},i[s][1].end)},u={type:"strikethroughText",start:Object.assign({},i[l][1].end),end:Object.assign({},i[s][1].start)},f=[["enter",p,c],["enter",i[l][1],c],["exit",i[l][1],c],["enter",u,c]],g=c.parser.constructs.insideSpan.null;g&&_e(f,f.length,0,$n(g,i.slice(l+1,s),c)),_e(f,f.length,0,[["exit",u,c],["enter",i[s][1],c],["exit",i[s][1],c],["exit",p,c]]),_e(i,l-1,s-l+3,f),s=l+f.length-2;break}}for(s=-1;++s<i.length;)i[s][1].type==="strikethroughSequenceTemporary"&&(i[s][1].type="data");return i}function a(i,c,s){const l=this.previous,p=this.events;let u=0;return f;function f(m){return l===126&&p[p.length-1][1].type!=="characterEscape"?s(m):(i.enter("strikethroughSequenceTemporary"),g(m))}function g(m){const x=Re(l);if(m===126)return u>1?s(m):(i.consume(m),u++,g);if(u<2&&!n)return s(m);const E=i.exit("strikethroughSequenceTemporary"),b=Re(m);return E._open=!b||b===2&&!!x,E._close=!x||x===2&&!!b,c(m)}}}class ya{constructor(){this.map=[]}add(t,n,r){ka(this,t,n,r)}consume(t){if(this.map.sort(function(a,i){return a[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let o=r.pop();for(;o;){for(const a of o)t.push(a);o=r.pop()}this.map.length=0}}function ka(e,t,n,r){let o=0;if(!(n===0&&r.length===0)){for(;o<e.map.length;){if(e.map[o][0]===t){e.map[o][1]+=n,e.map[o][2].push(...r);return}o+=1}e.map.push([t,n,r])}}function Ea(e,t){let n=!1;const r=[];for(;t<e.length;){const o=e[t];if(n){if(o[0]==="enter")o[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Aa(){return{flow:{null:{name:"table",tokenize:Sa,resolveAll:La}}}}function Sa(e,t,n){const r=this;let o=0,a=0,i;return c;function c(d){let D=r.events.length-1;for(;D>-1;){const X=r.events[D][1].type;if(X==="lineEnding"||X==="linePrefix")D--;else break}const M=D>-1?r.events[D][1].type:null,T=M==="tableHead"||M==="tableRow"?O:s;return T===O&&r.parser.lazy[r.now().line]?n(d):T(d)}function s(d){return e.enter("tableHead"),e.enter("tableRow"),l(d)}function l(d){return d===124||(i=!0,a+=1),p(d)}function p(d){return d===null?n(d):xe(d)?a>1?(a=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),g):n(d):ue(d)?oe(e,p,"whitespace")(d):(a+=1,i&&(i=!1,o+=1),d===124?(e.enter("tableCellDivider"),e.consume(d),e.exit("tableCellDivider"),i=!0,p):(e.enter("data"),u(d)))}function u(d){return d===null||d===124||J(d)?(e.exit("data"),p(d)):(e.consume(d),d===92?f:u)}function f(d){return d===92||d===124?(e.consume(d),u):u(d)}function g(d){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(d):(e.enter("tableDelimiterRow"),i=!1,ue(d)?oe(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):m(d))}function m(d){return d===45||d===58?E(d):d===124?(i=!0,e.enter("tableCellDivider"),e.consume(d),e.exit("tableCellDivider"),x):L(d)}function x(d){return ue(d)?oe(e,E,"whitespace")(d):E(d)}function E(d){return d===58?(a+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(d),e.exit("tableDelimiterMarker"),b):d===45?(a+=1,b(d)):d===null||xe(d)?z(d):L(d)}function b(d){return d===45?(e.enter("tableDelimiterFiller"),S(d)):L(d)}function S(d){return d===45?(e.consume(d),S):d===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(d),e.exit("tableDelimiterMarker"),w):(e.exit("tableDelimiterFiller"),w(d))}function w(d){return ue(d)?oe(e,z,"whitespace")(d):z(d)}function z(d){return d===124?m(d):d===null||xe(d)?!i||o!==a?L(d):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(d)):L(d)}function L(d){return n(d)}function O(d){return e.enter("tableRow"),V(d)}function V(d){return d===124?(e.enter("tableCellDivider"),e.consume(d),e.exit("tableCellDivider"),V):d===null||xe(d)?(e.exit("tableRow"),t(d)):ue(d)?oe(e,V,"whitespace")(d):(e.enter("data"),y(d))}function y(d){return d===null||d===124||J(d)?(e.exit("data"),V(d)):(e.consume(d),d===92?A:y)}function A(d){return d===92||d===124?(e.consume(d),y):y(d)}}function La(e,t){let n=-1,r=!0,o=0,a=[0,0,0,0],i=[0,0,0,0],c=!1,s=0,l,p,u;const f=new ya;for(;++n<e.length;){const g=e[n],m=g[1];g[0]==="enter"?m.type==="tableHead"?(c=!1,s!==0&&($t(f,t,s,l,p),p=void 0,s=0),l={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",l,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,u=void 0,a=[0,0,0,0],i=[0,n+1,0,0],c&&(c=!1,p={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",p,t]])),o=m.type==="tableDelimiterRow"?2:p?3:1):o&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,i[2]===0&&(a[1]!==0&&(i[0]=i[1],u=Ie(f,t,a,o,void 0,u),a=[0,0,0,0]),i[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(i[0]=i[1],u=Ie(f,t,a,o,void 0,u)),a=i,i=[a[1],n,0,0])):m.type==="tableHead"?(c=!0,s=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(s=n,a[1]!==0?(i[0]=i[1],u=Ie(f,t,a,o,n,u)):i[1]!==0&&(u=Ie(f,t,i,o,n,u)),o=0):o&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(i[3]=n)}for(s!==0&&$t(f,t,s,l,p),f.consume(t.events),n=-1;++n<t.events.length;){const g=t.events[n];g[0]==="enter"&&g[1].type==="table"&&(g[1]._align=Ea(t.events,n))}return e}function Ie(e,t,n,r,o,a){const i=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(a.end=Object.assign({},de(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const s=de(t.events,n[1]);if(a={type:i,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const l=de(t.events,n[2]),p=de(t.events,n[3]),u={type:c,start:Object.assign({},l),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",u,t]]),r!==2){const f=t.events[n[2]],g=t.events[n[3]];if(f[1].end=Object.assign({},g[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,x=n[3]-n[2]-1;e.add(m,x,[])}}e.add(n[3]+1,0,[["exit",u,t]])}return o!==void 0&&(a.end=Object.assign({},de(t.events,o)),e.add(o,0,[["exit",a,t]]),a=void 0),a}function $t(e,t,n,r,o){const a=[],i=de(t.events,n);o&&(o.end=Object.assign({},i),a.push(["exit",o,t])),r.end=Object.assign({},i),a.push(["exit",r,t]),e.add(n+1,0,a)}function de(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Ca={name:"tasklistCheck",tokenize:Ra};function Ia(){return{text:{91:Ca}}}function Ra(e,t,n){const r=this;return o;function o(s){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(s):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(s),e.exit("taskListCheckMarker"),a)}function a(s){return J(s)?(e.enter("taskListCheckValueUnchecked"),e.consume(s),e.exit("taskListCheckValueUnchecked"),i):s===88||s===120?(e.enter("taskListCheckValueChecked"),e.consume(s),e.exit("taskListCheckValueChecked"),i):n(s)}function i(s){return s===93?(e.enter("taskListCheckMarker"),e.consume(s),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):n(s)}function c(s){return xe(s)?t(s):ue(s)?e.check({tokenize:Ta},t,n)(s):n(s)}}function Ta(e,t,n){return oe(e,r,"whitespace");function r(o){return o===null?n(o):t(o)}}function ja(e){return Vn([na(),fa(),xa(e),Aa(),Ia()])}const Ma={};function Pa(e){const t=this,n=e||Ma,r=t.data(),o=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),i=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);o.push(ja(n)),a.push(Jo()),i.push(Qo(n))}let qe;async function Na(){return qe||(qe=se(()=>import("./mermaid.core-UUGPJ6yi.js").then(e=>e.bF),__vite__mapDeps([2,1])).then(e=>e.default)),qe}function In({source:e,title:t,themeMode:n="light",onRendered:r,onError:o,onTelemetry:a}){const i=h.useId(),c=h.useMemo(()=>`mermaid-${i.replace(/[^a-zA-Z0-9_-]/g,"")}`,[i]),[s,l]=h.useState({status:"loading"});return h.useEffect(()=>{const p=e.trim();if(!p){const f="The Mermaid diagram is empty.";l({status:"error",error:f}),a==null||a("warn","mermaid.render.skipped",f,{definitionLength:0}),o==null||o(f);return}let u=!1;return l({status:"loading"}),a==null||a("info","mermaid.render.started","Started Mermaid render.",{definitionLength:p.length}),Na().then(f=>(f.initialize({startOnLoad:!1,securityLevel:"strict",theme:n==="dark"?"dark":"neutral",suppressErrorRendering:!0,fontFamily:'"Inter", "Segoe UI", sans-serif'}),f.render(c,p))).then(({svg:f})=>{u||(l({status:"ready",svg:f}),a==null||a("info","mermaid.rendered","Rendered Mermaid diagram.",{definitionLength:p.length}),r==null||r())}).catch(f=>{if(u)return;const g=f instanceof Error?f.message:"The Mermaid diagram could not be rendered.";l({status:"error",error:g}),a==null||a("error","mermaid.render.failed",g,{definitionLength:p.length}),o==null||o(g)}),()=>{u=!0}},[c,o,r,a,e,n]),s.status==="loading"?v.jsxs("div",{className:"document-mermaid-shell document-mermaid-shell-loading","aria-live":"polite",children:[v.jsx("div",{className:"document-spinner"}),v.jsx("p",{children:"Rendering Mermaid diagram..."})]}):s.status==="error"?v.jsxs("div",{className:"document-mermaid-shell document-mermaid-error",role:"status",children:[v.jsx("h3",{children:"Mermaid preview unavailable"}),v.jsx("p",{children:s.error}),v.jsxs("pre",{children:[t?v.jsx("span",{children:t}):null,v.jsx("code",{children:e})]})]}):v.jsx("div",{className:"document-mermaid-shell",children:v.jsx("div",{className:"document-mermaid-frame","data-viewer-zoom-target":!0,"aria-label":t??"Mermaid diagram",dangerouslySetInnerHTML:{__html:s.svg}})})}function Ke(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(t=>Ke(t)).join(""):h.isValidElement(e)?Ke(e.props.children):""}function _a(e){var n;const t=e==null?void 0:e.match(/language-([^\s]+)/);return(n=t==null?void 0:t[1])==null?void 0:n.toLowerCase()}function Da(e){return h.Children.toArray(e).find(n=>h.isValidElement(n)&&n.type==="code")??null}function Oa(e){return{a({href:t,children:n}){return v.jsx("a",{href:t,target:"_blank",rel:"noreferrer",children:n})},img({src:t,alt:n}){return t?v.jsx("img",{src:t,alt:n??"",loading:"lazy"}):null},pre({children:t}){const n=Da(t);if(!n)return v.jsx("pre",{children:t});const r=_a(n.props.className),o=Ke(n.props.children).replace(/\n$/,"");return["mermaid","mmd"].includes(r??"")?v.jsx(In,{source:o,title:"Embedded Mermaid diagram",themeMode:e==null?void 0:e.themeMode,onTelemetry:e==null?void 0:e.onTelemetry}):v.jsx(rn,{source:o,title:r?`${r} code block`:"Code block",languageHint:r,themeMode:e==null?void 0:e.themeMode,onTelemetry:e==null?void 0:e.onTelemetry})},table({children:t}){return v.jsx("div",{className:"document-markdown-table-wrap",children:v.jsx("table",{children:t})})}}}function Fa(e,t){return v.jsx("article",{className:"document-markdown-prose",children:v.jsx(Un,{remarkPlugins:[Pa],components:Oa(t),children:e})})}const za=h.lazy(()=>se(()=>import("./pdf-renderer-DUYqGnQu.js"),__vite__mapDeps([3,1,4,5]))),$a=h.lazy(()=>se(()=>import("./pptx-renderer-DPSAG5_x.js"),__vite__mapDeps([6,1,4,5]))),Va=h.lazy(()=>se(()=>import("./docx-renderer-Bws5M_Ee.js"),__vite__mapDeps([7,1,8,5]))),Ua=h.lazy(()=>se(()=>import("./spreadsheet-renderer-WVtOHmRi.js"),__vite__mapDeps([9,1,10]))),qa=h.lazy(()=>se(()=>import("./zip-renderer-oijmTXXF.js"),__vite__mapDeps([11,1,5]))),Ha=h.lazy(()=>se(()=>import("./epub-renderer-C-aCqy3m.js"),__vite__mapDeps([12,1,5]))),Ba=new Set([".md",".markdown"]),Wa=new Set(["application/markdown","application/x-markdown","text/markdown","text/x-markdown"]);function Ga(e){var t;return(t=e.toLowerCase().match(/(\.[a-z0-9]+)$/))==null?void 0:t[1]}function Xa(e){var t;return(t=e==null?void 0:e.toLowerCase().split(";")[0])==null?void 0:t.trim()}function Ka(e){if(e.format!=="text")return!1;const t=Ga(e.name);if(t&&Ba.has(t))return!0;const n=Xa(e.mimeType);return!!(n&&Wa.has(n))}function Se(e,t){return h.useMemo(()=>Jt(e,t),[e,t])}function it(e,t){const[n,r]=h.useState({status:t?"loading":"idle"});return h.useEffect(()=>{if(!t){r({status:"idle"});return}if(!e){r({status:"error",error:"The document does not expose a preview-safe URL for binary rendering."});return}const o=new AbortController;let a;return r({status:"loading"}),fetch(e.url,{...e.init,signal:o.signal}).then(async i=>{if(!i.ok)throw new Error(`Request failed with status ${i.status}`);const c=await i.blob();a=URL.createObjectURL(c),r({status:"ready",url:a})}).catch(i=>{o.signal.aborted||r({status:"error",error:i instanceof Error?i.message:"Unknown binary fetch failure"})}),()=>{o.abort(),a&&URL.revokeObjectURL(a)}},[t,e]),n}function Ya(e,t){const[n,r]=h.useState({status:"loading"});return h.useEffect(()=>{if(!e){r({status:"error",error:"The document does not expose a preview-safe URL for text rendering."});return}const o=new AbortController;return r({status:"loading"}),fetch(e.url,{...e.init,signal:o.signal}).then(async a=>{if(!a.ok)throw new Error(`Request failed with status ${a.status}`);const i=await a.text();r({status:"ready",text:i})}).catch(a=>{o.signal.aborted||r({status:"error",error:a instanceof Error?a.message:"Unknown text fetch failure"})}),()=>{o.abort()}},[t,e]),n}function ne(e,t){h.useLayoutEffect(()=>{if(!e.current||!t)return;const n=a=>{if(!e.current)return;const i=Math.ceil(e.current.getBoundingClientRect().height);t(i,a)},r=new ResizeObserver(()=>n("content"));r.observe(e.current);const o=()=>n("viewport");return window.addEventListener("resize",o),n("renderer"),()=>{r.disconnect(),window.removeEventListener("resize",o)}},[t,e])}function G({label:e}){return v.jsxs("div",{className:"document-loading",children:[v.jsx("div",{className:"document-spinner"}),v.jsx("p",{children:e})]})}function ot({title:e,message:t}){return v.jsxs("div",{className:"document-empty-state",children:[v.jsx("h3",{children:e}),v.jsx("p",{children:t})]})}function Za({document:e,session:t,onLoaded:n,onError:r,onResize:o}){const a=Se(e,t),i=e.source.kind==="session",c=it(a,i),s=h.useRef(null);ne(s,o);const l=i?c.url:a==null?void 0:a.url;return h.useEffect(()=>{i&&c.status==="error"&&r("document-fetch-failed",c.error??"Image failed to load",!0)},[e,c.error,c.status,r,i]),i&&c.status==="loading"?v.jsx(G,{label:"Fetching secure image preview"}):l?v.jsx("div",{ref:s,className:"document-media-shell",children:v.jsx("img",{src:l,alt:e.name,className:"document-image","data-viewer-zoom-target":!0,onLoad:()=>n(),onError:()=>r("document-fetch-failed","The image preview could not be loaded.",!0)})}):v.jsx(ot,{title:"Image preview unavailable",message:"This image does not expose a preview-safe URL."})}function Ja({document:e,session:t,onLoaded:n,onError:r,onResize:o}){const a=Se(e,t),i=e.source.kind==="session",c=it(a,i),s=h.useRef(null);ne(s,o);const l=i?c.url:a==null?void 0:a.url;return h.useEffect(()=>{i&&c.status==="error"&&r("document-fetch-failed",c.error??"Video failed to load",!0)},[e,c.error,c.status,r,i]),i&&c.status==="loading"?v.jsx(G,{label:"Preparing secure video preview"}):l?v.jsx("div",{ref:s,className:"document-media-shell",children:v.jsx("video",{className:"document-video",controls:!0,playsInline:!0,src:l,onLoadedMetadata:()=>n(),onError:()=>r("document-fetch-failed","The video preview could not be loaded.",!0)})}):v.jsx(ot,{title:"Video preview unavailable",message:"This video does not expose a preview-safe URL."})}function Qa({document:e,session:t,onLoaded:n,onError:r,onResize:o}){const a=Se(e,t),i=e.source.kind==="session",c=it(a,i),s=h.useRef(null);ne(s,o);const l=i?c.url:a==null?void 0:a.url;return h.useEffect(()=>{i&&c.status==="error"&&r("document-fetch-failed",c.error??"Audio failed to load",!0)},[e,c.error,c.status,r,i]),i&&c.status==="loading"?v.jsx(G,{label:"Preparing secure audio preview"}):l?v.jsx("div",{ref:s,className:"document-media-shell document-audio-shell",children:v.jsx("audio",{className:"document-audio",controls:!0,preload:"metadata",src:l,onLoadedMetadata:()=>n(),onError:()=>r("document-fetch-failed","The audio preview could not be loaded.",!0)})}):v.jsx(ot,{title:"Audio preview unavailable",message:"This audio file does not expose a preview-safe URL."})}function be({document:e,session:t,onLoaded:n,onError:r,onResize:o,onTelemetry:a,themeMode:i,presentation:c}){const s=Se(e,t),l=Ya(s,!0),p=h.useRef(null),u=h.useRef(!1),f=h.useRef(!1),g=h.useRef(!1),m=h.useRef(!1),x=Pt(e);return ne(p,o),h.useEffect(()=>{u.current=!1,f.current=!1,g.current=!1,m.current=!1},[e.id]),h.useEffect(()=>{l.status==="ready"&&c!=="mermaid"&&!x&&n(),l.status==="error"&&r("document-fetch-failed",l.error??"Text preview failed to load.",!0)},[e,r,n,c,l.error,l.status,x]),l.status==="loading"?v.jsx(G,{label:c==="markdown"?"Rendering markdown preview":c==="mermaid"?"Rendering Mermaid preview":x?"Rendering code preview":"Loading text preview"}):l.status!=="ready"?null:c==="mermaid"?v.jsx("div",{ref:p,className:"document-mermaid-document",children:v.jsx(In,{source:l.text??"",title:e.name,themeMode:i,onTelemetry:a,onRendered:()=>{u.current||(u.current=!0,n())},onError:E=>{f.current||(f.current=!0,r("renderer-failed",E,!1))}})}):Pt(e)?v.jsx("div",{ref:p,className:"document-code-document","data-viewer-zoom-target":!0,children:v.jsx(rn,{source:l.text??"",title:e.name,languageHint:tn(e),themeMode:i,onTelemetry:a,onRendered:()=>{g.current||(g.current=!0,n())},onError:E=>{m.current||(m.current=!0,r("renderer-failed",E,!1))}})}):v.jsx("div",{ref:p,"data-viewer-zoom-target":!0,className:c==="markdown"?"document-markdown":"document-text-shell",children:c==="markdown"?Fa(l.text??"",{onTelemetry:a,themeMode:i}):v.jsx("pre",{children:l.text})})}function es({document:e,onUnsupported:t}){return h.useEffect(()=>{t("format-not-supported",`Format "${e.format}" is not supported in the current viewer phase.`)},[e,t]),null}function ts(e){const{document:t,pageNavigationRequest:n}=e,r=Se(t,e.session);switch(t.format){case"audio":return v.jsx(Qa,{...e});case"image":return v.jsx(Za,{...e});case"video":return v.jsx(Ja,{...e});case"text":return v.jsx(be,{...e,presentation:Ka(t)?"markdown":"text"});case"code":return v.jsx(be,{...e,presentation:"text"});case"json":case"jsonl":case"ndjson":case"tsv":case"xml":case"toml":case"ini":case"dotenv":case"yaml":return v.jsx(be,{...e,presentation:"text"});case"html":case"widget":return v.jsx(li,{...e});case"markdown":return v.jsx(be,{...e,presentation:"markdown"});case"mermaid":return v.jsx(be,{...e,presentation:"mermaid"});case"pdf":return v.jsx(h.Suspense,{fallback:v.jsx(G,{label:"Loading PDF renderer"}),children:v.jsx(za,{...e,request:r,useContainerResize:ne,pageNavigationRequest:n})});case"pptx":return v.jsx(h.Suspense,{fallback:v.jsx(G,{label:"Loading PPTX renderer"}),children:v.jsx($a,{...e,request:r,useContainerResize:ne,pageNavigationRequest:n,LoadingState:G})});case"docx":return v.jsx(h.Suspense,{fallback:v.jsx(G,{label:"Loading DOCX renderer"}),children:v.jsx(Va,{...e,request:r,useContainerResize:ne,LoadingState:G})});case"xls":case"xlsx":case"csv":return v.jsx(h.Suspense,{fallback:v.jsx(G,{label:"Loading spreadsheet renderer"}),children:v.jsx(Ua,{...e,request:r,useContainerResize:ne,LoadingState:G})});case"zip":return v.jsx(h.Suspense,{fallback:v.jsx(G,{label:"Loading archive renderer"}),children:v.jsx(qa,{...e,request:r,useContainerResize:ne,LoadingState:G})});case"epub":return v.jsx(h.Suspense,{fallback:v.jsx(G,{label:"Loading EPUB renderer"}),children:v.jsx(Ha,{...e,request:r,useContainerResize:ne,LoadingState:G})});default:return v.jsx(es,{document:t,onUnsupported:e.onUnsupported})}}function ns({state:e,theme:t,safeArea:n,currentDocument:r,session:o,pageNavigationRequest:a,artifactDataMessage:i,streamCommandMessage:c,onLoaded:s,onUnsupported:l,onError:p,onTelemetry:u,onResize:f,onPageChanged:g,onArtifactEvent:m,onWidgetRequest:x,widgetResponseMessage:E}){var O,V,y,A;const b=h.useRef(null),S=h.useRef(null),w=h.useRef(0);hi(S,r==null?void 0:r.id);const z=h.useMemo(()=>{var d,D,M,T,X,K,ee,Y;return{...(d=t.tokens)!=null&&d.surface?{"--bg":t.tokens.surface}:{},...(D=t.tokens)!=null&&D.surfaceMuted?{"--panel":t.tokens.surfaceMuted}:{},...(M=t.tokens)!=null&&M.surface?{"--panel-strong":t.tokens.surface}:{},...(T=t.tokens)!=null&&T.surface?{"--message-panel-bg":t.tokens.surface}:{},...(X=t.tokens)!=null&&X.surface?{"--document-surface":t.tokens.surface}:{},...(K=t.tokens)!=null&&K.text?{"--text":t.tokens.text}:{},...(ee=t.tokens)!=null&&ee.text?{"--document-code-text":t.tokens.text}:{},...(Y=t.tokens)!=null&&Y.accent?{"--accent":t.tokens.accent}:{}}},[(O=t.tokens)==null?void 0:O.accent,(V=t.tokens)==null?void 0:V.surface,(y=t.tokens)==null?void 0:y.surfaceMuted,(A=t.tokens)==null?void 0:A.text]),L=h.useCallback((d,D)=>{if(Number.isFinite(D)&&(D??0)>0&&(w.current=Math.ceil(D??0)),!b.current)return;const M=Math.ceil(b.current.getBoundingClientRect().height),T=r&&Te(r.format)&&w.current>0?w.current:Math.max(M,w.current);T<=0||f(T,d)},[r==null?void 0:r.format,f]);return h.useLayoutEffect(()=>{w.current=0},[r==null?void 0:r.id]),h.useLayoutEffect(()=>{const d=document.documentElement;for(const D of["top","right","bottom","left"])d.style.setProperty(`--viewer-safe-area-${D}`,`${n[D]??0}px`);return()=>{for(const D of["top","right","bottom","left"])d.style.removeProperty(`--viewer-safe-area-${D}`)}},[n]),h.useLayoutEffect(()=>{const d=document.documentElement,D=Object.entries(z);d.dataset.themeMode=t.mode,d.dataset.documentFormat=(r==null?void 0:r.format)??"unknown";for(const[M,T]of D)d.style.setProperty(M,T);return()=>{delete d.dataset.themeMode,delete d.dataset.documentFormat;for(const[M]of D)d.style.removeProperty(M)}},[r==null?void 0:r.format,t.mode,z]),h.useLayoutEffect(()=>{if(!b.current)return;const d=new ResizeObserver(()=>L("content"));d.observe(b.current);const D=()=>L("viewport");return window.addEventListener("resize",D),L("renderer"),()=>{d.disconnect(),window.removeEventListener("resize",D)}},[L,e.phase,r==null?void 0:r.id]),(e.phase==="initializing"||e.phase==="loading-document"||e.phase==="ready")&&r?v.jsx("main",{ref:b,className:"viewer-shell viewer-shell-document",children:v.jsx("section",{className:"viewer-panel",children:v.jsx("div",{ref:S,className:"viewer-stage",children:v.jsx(ts,{document:r,session:o,theme:t,safeArea:n,themeMode:t.mode,onLoaded:s,onUnsupported:l,onError:p,onTelemetry:u,onResize:(d,D)=>L(D,d),onPageChanged:g,onArtifactEvent:m,onWidgetRequest:x,widgetResponseMessage:E,pageNavigationRequest:a,artifactDataMessage:i,streamCommandMessage:c})})})}):v.jsx("main",{ref:b,className:"viewer-shell"})}function He(e){if(e.phase==="initializing"||e.phase==="loading-document"||e.phase==="ready"||e.phase==="unsupported"||e.phase==="error")return e.document}const rs="0.1.0",is=["load-document","pagination","resize-notifications","artifact-runtime"];function os(){var r;const e=new URLSearchParams(window.location.search),t=e.get("themeMode"),n=t==="dark"||t==="light"?t:(r=window.matchMedia)!=null&&r.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light";return{instanceId:e.get("instanceId")??"",parentOrigin:e.get("parentOrigin")??"",initialThemeMode:n}}function as(e){return e?Number.isNaN(Date.parse(e.expiresAt))||Date.parse(e.expiresAt)<=Date.now():!1}function ss(e){return Q({instanceId:e,type:"viewer.ready",payload:{viewerVersion:rs,supportedProtocolVersions:[Me],capabilities:[...is]}})}function Vt(e,t,n,r){return Q({instanceId:e,requestId:t,type:"viewer.ack",payload:{status:n,reason:r}})}function ls(e,t,n){return Q({instanceId:e,type:"viewer.document-loaded",payload:{documentId:t.id,format:t.format,title:t.name,pageCount:n.pageCount}})}function cs(e,t,n,r){return Q({instanceId:e,type:"viewer.unsupported",payload:{documentId:t.id,reason:n,message:r}})}function us(e,t,n,r,o){return Q({instanceId:e,type:"viewer.error",payload:{documentId:o,code:t,message:n,recoverable:r}})}function ds(e,t,n){return Q({instanceId:e,type:"viewer.resize",payload:{height:t,reason:n}})}function fs(e,t){return Q({instanceId:e,type:"viewer.scroll",payload:{progress:t}})}function ps(e,t,n,r,o){return Q({instanceId:e,type:"viewer.telemetry",payload:{level:t,name:n,message:r,context:o}})}function ms(e,t,n){return Q({instanceId:e,type:"viewer.page-changed",payload:{page:t,pageCount:n}})}function hs(e,t,n,r){return Q({instanceId:e,type:"viewer.artifact-event",payload:{documentId:t.id,name:n,detail:r}})}function gs(e,t){return Q({instanceId:e,type:"viewer.widget-request",payload:t})}function vs(e){return e.instanceId&&e.parentOrigin&&e.parentOrigin!=="*"?{phase:"booting"}:{phase:"error",code:"invalid-message",message:"Viewer bootstrap is missing a secure instanceId or parent origin.",recoverable:!1}}function we(e){return e.phase==="initializing"||e.phase==="loading-document"||e.phase==="ready"?e.document:void 0}function bs(e){return e.type==="viewer.append-html"?{type:"append",html:e.payload.html,sequence:e.payload.sequence}:e.type==="viewer.abort-html-stream"?{type:"abort",reason:e.payload.reason}:{type:"complete"}}function ws(){const e=h.useMemo(()=>os(),[]),[t,n]=h.useState(()=>vs(e)),[r,o]=h.useState({}),[a,i]=h.useState({}),[c,s]=h.useState({mode:e.initialThemeMode}),[l,p]=h.useState(),[u,f]=h.useState(),[g,m]=h.useState(),[x,E]=h.useState(),b=h.useRef(t),S=h.useRef(r);h.useEffect(()=>{b.current=t},[t]),h.useEffect(()=>{S.current=r},[r]);const w=h.useCallback(R=>{window.parent!==window&&e.parentOrigin&&window.parent.postMessage(R,e.parentOrigin)},[e.parentOrigin]),z=h.useRef(null);h.useEffect(()=>{if(!e.instanceId)return;const R=ci({onProgress:k=>w(fs(e.instanceId,k))});z.current=R;const P=k=>R.handleScroll(k),N=k=>{var F;const B=(F=k.detail)==null?void 0:F.scrollTop;typeof B=="number"&&R.report(B)};return document.addEventListener("scroll",P,{capture:!0,passive:!0}),window.addEventListener(We,N),()=>{document.removeEventListener("scroll",P,{capture:!0}),window.removeEventListener(We,N),R.dispose(),z.current=null}},[e.instanceId,w]);const L=h.useCallback((R,P,N,k)=>{e.instanceId&&e.parentOrigin&&window.parent!==window&&window.parent.postMessage(ps(e.instanceId,R,P,N,k),e.parentOrigin)},[e.instanceId,e.parentOrigin]),O=h.useCallback((R,P,N,k)=>{n({phase:"error",code:R,message:P,recoverable:N,document:k}),w(us(e.instanceId,R,P,N,k==null?void 0:k.id)),L("error",R,P,{recoverable:N,documentId:(k==null?void 0:k.id)??null})},[e.instanceId,w,L]);h.useEffect(()=>{if(!e.instanceId||!e.parentOrigin||e.parentOrigin==="*")return;const R=(N,k)=>{var W;const B=N.payload.document,F=N.payload.session;if(s(ge=>N.payload.theme??ge),as(F)){w(Vt(e.instanceId,N.messageId,"rejected","Session has expired.")),O("session-expired","The secure viewer session is missing or expired.",!0,B);return}i(ge=>N.payload.safeArea??(N.type==="viewer.init"?{}:ge)),N.type==="viewer.init"&&((W=z.current)==null||W.setDistance(N.payload.scrollProgressDistance));const Z=k??(b.current.phase==="ready"||b.current.phase==="initializing"||b.current.phase==="loading-document"?b.current.host:{name:"unknown-host",origin:e.parentOrigin,sdkVersion:"unknown"});o({}),p(void 0),f(void 0),m(void 0),L("info",N.type,"Viewer accepted a parent command.",{documentId:B.id,format:B.format}),n({phase:N.type==="viewer.init"?"initializing":"loading-document",document:B,session:F,host:Z}),w(Vt(e.instanceId,N.messageId,"accepted"))},P=N=>{var B;if(N.source!==window.parent)return;if(N.origin!==e.parentOrigin){O("origin-mismatch",`Rejected parent message from unexpected origin ${N.origin}.`,!1,we(b.current));return}if(!Rr(N.data)){L("warn","viewer.parent-message.ignored","Ignored a parent window message that did not match the viewer protocol.",{phase:b.current.phase});return}const k=N.data;if(k.instanceId===e.instanceId){if(k.type==="viewer.init"){R(k,k.payload.host);return}if(k.type==="viewer.go-to-page"){p(F=>({page:k.payload.page,nonce:((F==null?void 0:F.nonce)??0)+1}));return}if(k.type==="viewer.set-safe-area"){i(k.payload.safeArea);return}if(k.type==="viewer.set-theme"){const F=k.payload.theme;s(F),L("info","viewer.set-theme","Viewer updated theme without reloading the document.",{documentId:((B=we(b.current))==null?void 0:B.id)??null,mode:F.mode});return}if(k.type==="viewer.widget-response"){E(F=>({nonce:((F==null?void 0:F.nonce)??0)+1,payloads:[...(F==null?void 0:F.payloads)??[],k.payload]}));return}if(k.type==="viewer.send-artifact-data"){const F=we(b.current)??He(b.current);if(!F||!Te(F.format)){L("warn","artifact.data.ignored","Artifact runtime data was ignored because no HTML artifact is active.",{requestedDocumentId:k.payload.documentId??null});return}if(k.payload.documentId&&k.payload.documentId!==F.id){L("warn","artifact.data.mismatch","Artifact runtime data targeted a different document and was ignored.",{activeDocumentId:F.id,requestedDocumentId:k.payload.documentId});return}f(Z=>({nonce:((Z==null?void 0:Z.nonce)??0)+1,data:k.payload.data}));return}if(k.type==="viewer.append-html"||k.type==="viewer.complete-html-stream"||k.type==="viewer.abort-html-stream"){const F=we(b.current)??He(b.current);if(!F||!Te(F.format)||F.source.kind!=="stream"){L("warn","html.stream.ignored","HTML stream command was ignored because no stream HTML document is active.",{commandType:k.type,requestedDocumentId:k.payload.documentId??null});return}if(k.payload.documentId&&k.payload.documentId!==F.id){L("warn","html.stream.mismatch","HTML stream command targeted a different document and was ignored.",{activeDocumentId:F.id,requestedDocumentId:k.payload.documentId,commandType:k.type});return}m(Z=>({nonce:((Z==null?void 0:Z.nonce)??0)+1,commands:[...(Z==null?void 0:Z.commands)??[],bs(k)]}));return}R(k)}};return window.addEventListener("message",P),n({phase:"waiting-for-init"}),w(ss(e.instanceId)),L("info","viewer.ready","Viewer shell announced readiness."),()=>{window.removeEventListener("message",P)}},[e.instanceId,e.parentOrigin,O,w,L]);const V=h.useCallback(R=>{o(P=>({...P,pageCount:R==null?void 0:R.pageCount})),n(P=>P.phase!=="initializing"&&P.phase!=="loading-document"?P:(w(ls(e.instanceId,P.document,{...S.current,...R})),L("info","document.loaded","Renderer finished loading the document.",{documentId:P.document.id,format:P.document.format,pageCount:(R==null?void 0:R.pageCount)??null}),{phase:"ready",document:P.document,session:P.session,host:P.host}))},[e.instanceId,w,L]),y=h.useCallback((R,P)=>{n(N=>{const k=we(N)??(N.phase==="ready"?N.document:void 0);return k&&(w(cs(e.instanceId,k,R,P)),L("warn",R,P,{documentId:k.id})),{phase:"unsupported",document:k,reason:R,message:P}})},[e.instanceId,w,L]),A=He(t),d=A==null?void 0:A.id;h.useEffect(()=>{var R;(R=z.current)==null||R.reset()},[d]);const D=t.phase==="initializing"||t.phase==="loading-document"||t.phase==="ready"?t.session:void 0,M=h.useCallback((R,P,N)=>{O(R,P,N,A)},[A,O]),T=h.useCallback((R,P,N,k)=>{L(R,P,N,{documentId:(A==null?void 0:A.id)??null,format:(A==null?void 0:A.format)??null,...k})},[A,L]),X=h.useCallback((R,P)=>{w(ds(e.instanceId,R,P))},[e.instanceId,w]),K=h.useCallback((R,P)=>{A&&(w(hs(e.instanceId,A,R,P)),L("info","artifact.event","HTML artifact emitted a runtime event.",{eventName:R,documentId:A.id}))},[e.instanceId,A,w,L]),ee=h.useCallback(R=>{A&&(w(gs(e.instanceId,{documentId:A.id,...R})),L("info","widget.request","A widget asked its host.",{method:R.method,documentId:A.id}))},[e.instanceId,A,w,L]),Y=h.useCallback((R,P)=>{o(N=>({...N,currentPage:R,pageCount:P??N.pageCount})),w(ms(e.instanceId,R,P)),L("info","page.changed","PDF page changed.",{page:R,pageCount:P??null})},[e.instanceId,w,L]);return v.jsx(ns,{state:t,theme:c,safeArea:a,currentDocument:A,session:D,pageNavigationRequest:l,artifactDataMessage:u,streamCommandMessage:g,onLoaded:V,onUnsupported:y,onError:M,onTelemetry:T,onResize:X,onPageChanged:Y,onArtifactEvent:K,onWidgetRequest:ee,widgetResponseMessage:x})}const Rn=document.getElementById("root");if(!Rn)throw new Error("Root element not found");qn.createRoot(Rn).render(v.jsx(h.StrictMode,{children:v.jsx(ws,{})}));export{Nt as c};
|