@doxbrix/doxloop 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1153 -0
- package/README.md +422 -226
- package/assets/doxbrix-preview.css +77 -15
- package/contracts/agent-events-v1.schema.json +1 -0
- package/contracts/coverage-v1.schema.json +59 -0
- package/contracts/drift-v1.schema.json +1 -0
- package/contracts/evaluation-v1.schema.json +62 -0
- package/contracts/quality-codes-v1.json +1 -0
- package/contracts/quality-report-v1.schema.json +1 -0
- package/contracts/validation-v1.schema.json +1 -0
- package/dist/agent-failure.d.ts +36 -0
- package/dist/agent-failure.js +98 -0
- package/dist/agent-isolation.d.ts +17 -0
- package/dist/agent-isolation.js +94 -0
- package/dist/agent-log.d.ts +197 -0
- package/dist/agent-log.js +1094 -0
- package/dist/agent-process.d.ts +63 -0
- package/dist/agent-process.js +128 -0
- package/dist/agent-reply.d.ts +47 -0
- package/dist/agent-reply.js +315 -0
- package/dist/agents.d.ts +40 -4
- package/dist/agents.js +115 -11
- package/dist/api-coverage.d.ts +11 -0
- package/dist/api-coverage.js +72 -0
- package/dist/application-probe.d.ts +28 -0
- package/dist/application-probe.js +93 -0
- package/dist/application-url.d.ts +14 -0
- package/dist/application-url.js +26 -0
- package/dist/args.js +15 -0
- package/dist/artifact-deploy.d.ts +9 -0
- package/dist/artifact-deploy.js +28 -8
- package/dist/assets.d.ts +72 -0
- package/dist/assets.js +382 -0
- package/dist/auth.d.ts +10 -0
- package/dist/auth.js +38 -9
- package/dist/author.d.ts +206 -4
- package/dist/author.js +1650 -52
- package/dist/authoring-batches.d.ts +190 -0
- package/dist/authoring-batches.js +489 -0
- package/dist/authoring-postpass.d.ts +79 -0
- package/dist/authoring-postpass.js +1289 -0
- package/dist/authoring-progress.d.ts +95 -0
- package/dist/authoring-progress.js +269 -0
- package/dist/autosync.d.ts +56 -0
- package/dist/autosync.js +442 -0
- package/dist/batch-artifacts.d.ts +81 -0
- package/dist/batch-artifacts.js +412 -0
- package/dist/batch-limits.d.ts +37 -0
- package/dist/batch-limits.js +80 -0
- package/dist/branding.d.ts +41 -0
- package/dist/branding.js +229 -0
- package/dist/bundle-upload.d.ts +26 -0
- package/dist/bundle-upload.js +99 -0
- package/dist/capture-auth.d.ts +95 -0
- package/dist/capture-auth.js +204 -0
- package/dist/capture.d.ts +48 -0
- package/dist/capture.js +20 -1
- package/dist/cli.js +839 -32
- package/dist/content-links.d.ts +10 -0
- package/dist/content-links.js +49 -0
- package/dist/contract-validation.d.ts +4 -0
- package/dist/contract-validation.js +25 -0
- package/dist/coverage-actions.d.ts +8 -0
- package/dist/coverage-actions.js +71 -0
- package/dist/coverage-resolutions.d.ts +16 -0
- package/dist/coverage-resolutions.js +58 -0
- package/dist/db.d.ts +37 -0
- package/dist/db.js +288 -0
- package/dist/demo.d.ts +12 -0
- package/dist/demo.js +122 -0
- package/dist/deploy-credentials.d.ts +7 -0
- package/dist/deploy-credentials.js +76 -0
- package/dist/deploy-targets/github-pages.d.ts +3 -0
- package/dist/deploy-targets/github-pages.js +100 -0
- package/dist/deploy-targets/index.d.ts +8 -0
- package/dist/deploy-targets/index.js +78 -0
- package/dist/deploy-targets/netlify.d.ts +3 -0
- package/dist/deploy-targets/netlify.js +49 -0
- package/dist/deploy-targets/types.d.ts +32 -0
- package/dist/deploy-targets/types.js +2 -0
- package/dist/deploy-targets/vercel.d.ts +3 -0
- package/dist/deploy-targets/vercel.js +95 -0
- package/dist/deploy.d.ts +9 -0
- package/dist/deploy.js +87 -13
- package/dist/deterministic-capture.d.ts +90 -0
- package/dist/deterministic-capture.js +435 -0
- package/dist/direct-edit.d.ts +40 -0
- package/dist/direct-edit.js +159 -0
- package/dist/docs-crawl.d.ts +86 -0
- package/dist/docs-crawl.js +536 -0
- package/dist/docs-site.d.ts +49 -0
- package/dist/docs-site.js +233 -0
- package/dist/doctor.js +8 -0
- package/dist/documentation-collections.d.ts +23 -0
- package/dist/documentation-collections.js +191 -0
- package/dist/documentation-plan.d.ts +253 -0
- package/dist/documentation-plan.js +2563 -0
- package/dist/doxbrix-build.d.ts +19 -0
- package/dist/doxbrix-build.js +167 -0
- package/dist/doxbrix-markdown.d.ts +9 -0
- package/dist/doxbrix-markdown.js +115 -14
- package/dist/drift.d.ts +10 -0
- package/dist/drift.js +164 -0
- package/dist/evaluation.d.ts +46 -0
- package/dist/evaluation.js +113 -0
- package/dist/evidence-pack.d.ts +47 -0
- package/dist/evidence-pack.js +358 -0
- package/dist/evidence.d.ts +25 -0
- package/dist/evidence.js +175 -0
- package/dist/fs.d.ts +8 -2
- package/dist/fs.js +41 -11
- package/dist/generator-api.d.ts +89 -0
- package/dist/generator-preflight.d.ts +27 -0
- package/dist/generator-preflight.js +105 -0
- package/dist/generator-runtime.d.ts +7 -0
- package/dist/generator-runtime.js +17 -1
- package/dist/generators.d.ts +24 -2
- package/dist/generators.js +54 -1
- package/dist/git-delivery.d.ts +17 -0
- package/dist/git-delivery.js +123 -0
- package/dist/globs.d.ts +16 -0
- package/dist/globs.js +65 -0
- package/dist/glossary.d.ts +26 -0
- package/dist/glossary.js +179 -0
- package/dist/history.d.ts +106 -0
- package/dist/history.js +600 -0
- package/dist/html-markdown.d.ts +46 -0
- package/dist/html-markdown.js +423 -0
- package/dist/interactive.js +16 -15
- package/dist/job-events.d.ts +74 -0
- package/dist/job-events.js +377 -0
- package/dist/keep-awake.d.ts +50 -0
- package/dist/keep-awake.js +123 -0
- package/dist/local-source-snapshot.d.ts +20 -0
- package/dist/local-source-snapshot.js +61 -0
- package/dist/mintlify-detect.d.ts +3 -0
- package/dist/mintlify-detect.js +18 -0
- package/dist/mintlify-import.d.ts +75 -0
- package/dist/mintlify-import.js +190 -0
- package/dist/navigation.d.ts +98 -0
- package/dist/navigation.js +310 -0
- package/dist/openapi.d.ts +60 -0
- package/dist/openapi.js +439 -0
- package/dist/page-editor-bridge.d.ts +3 -0
- package/dist/page-editor-bridge.js +109 -0
- package/dist/page-editor-preview.d.ts +10 -0
- package/dist/page-editor-preview.js +55 -0
- package/dist/page-extension.d.ts +9 -0
- package/dist/page-extension.js +15 -0
- package/dist/page-metadata.d.ts +28 -0
- package/dist/page-metadata.js +166 -0
- package/dist/page-operations.d.ts +34 -0
- package/dist/page-operations.js +215 -0
- package/dist/page-routes.d.ts +4 -0
- package/dist/page-routes.js +61 -0
- package/dist/pages.d.ts +20 -0
- package/dist/pages.js +184 -0
- package/dist/plan-generator.d.ts +3 -0
- package/dist/plan-generator.js +21 -0
- package/dist/plan-navigation.d.ts +11 -0
- package/dist/plan-navigation.js +30 -0
- package/dist/planning-captures.d.ts +20 -0
- package/dist/planning-captures.js +143 -0
- package/dist/planning-research.d.ts +135 -0
- package/dist/planning-research.js +472 -0
- package/dist/planning-triage.d.ts +23 -0
- package/dist/planning-triage.js +131 -0
- package/dist/preview.d.ts +24 -0
- package/dist/preview.js +280 -29
- package/dist/project-detect.d.ts +36 -0
- package/dist/project-detect.js +251 -0
- package/dist/project-import.d.ts +54 -0
- package/dist/project-import.js +157 -0
- package/dist/project-lock.d.ts +6 -0
- package/dist/project-lock.js +96 -0
- package/dist/project-registry.d.ts +25 -0
- package/dist/project-registry.js +79 -0
- package/dist/project.d.ts +35 -3
- package/dist/project.js +388 -38
- package/dist/prompts.d.ts +9 -0
- package/dist/prompts.js +33 -4
- package/dist/proposal-replay.d.ts +32 -0
- package/dist/proposal-replay.js +99 -0
- package/dist/quality-claims.d.ts +8 -0
- package/dist/quality-claims.js +168 -0
- package/dist/quality-config.d.ts +5 -0
- package/dist/quality-config.js +84 -0
- package/dist/quality-contract.d.ts +37 -0
- package/dist/quality-contract.js +46 -0
- package/dist/quality-examples.d.ts +4 -0
- package/dist/quality-examples.js +233 -0
- package/dist/quality-gates.d.ts +16 -0
- package/dist/quality-gates.js +192 -0
- package/dist/quality-links.d.ts +7 -0
- package/dist/quality-links.js +149 -0
- package/dist/quality-lint.d.ts +6 -0
- package/dist/quality-lint.js +124 -0
- package/dist/quality-rendered.d.ts +11 -0
- package/dist/quality-rendered.js +222 -0
- package/dist/quality-schema.d.ts +3 -0
- package/dist/quality-schema.js +71 -0
- package/dist/release-notes.d.ts +44 -0
- package/dist/release-notes.js +183 -0
- package/dist/remote-monitor.d.ts +16 -0
- package/dist/remote-monitor.js +74 -0
- package/dist/remote-source.d.ts +34 -0
- package/dist/remote-source.js +426 -0
- package/dist/review-diff.d.ts +82 -0
- package/dist/review-diff.js +400 -0
- package/dist/review-learning.d.ts +11 -0
- package/dist/review-learning.js +60 -0
- package/dist/review-render.d.ts +38 -0
- package/dist/review-render.js +224 -0
- package/dist/review-report.d.ts +9 -0
- package/dist/review-report.js +89 -0
- package/dist/review-ui.d.ts +14 -0
- package/dist/review-ui.js +1248 -0
- package/dist/schedule.d.ts +78 -0
- package/dist/schedule.js +480 -0
- package/dist/screen-capture-provider.d.ts +52 -0
- package/dist/screen-capture-provider.js +218 -0
- package/dist/screenshot-workflow.d.ts +167 -0
- package/dist/screenshot-workflow.js +1237 -0
- package/dist/settings.d.ts +1 -1
- package/dist/settings.js +95 -7
- package/dist/site-export.d.ts +18 -0
- package/dist/site-export.js +87 -0
- package/dist/source-connectors.d.ts +33 -0
- package/dist/source-connectors.js +268 -0
- package/dist/source-discovery.d.ts +132 -0
- package/dist/source-discovery.js +823 -0
- package/dist/source-intelligence.d.ts +9 -0
- package/dist/source-intelligence.js +306 -0
- package/dist/sync-review.d.ts +28 -0
- package/dist/sync-review.js +264 -0
- package/dist/sync-runs.d.ts +192 -0
- package/dist/sync-runs.js +2244 -0
- package/dist/sync.d.ts +35 -0
- package/dist/sync.js +298 -32
- package/dist/text-diff.d.ts +9 -0
- package/dist/text-diff.js +59 -0
- package/dist/types.d.ts +946 -1
- package/dist/ui/assets/doxloop-logo-light-De7Nx7j7.png +0 -0
- package/dist/ui/assets/index-BHBYU2aG.css +1 -0
- package/dist/ui/assets/index-Cq3RPQiC.js +33 -0
- package/dist/ui/index.html +18 -0
- package/dist/ui-server.d.ts +83 -0
- package/dist/ui-server.js +3532 -0
- package/dist/usage-budget.d.ts +28 -0
- package/dist/usage-budget.js +90 -0
- package/dist/validation.d.ts +25 -1
- package/dist/validation.js +312 -26
- package/dist/workspace-tools.d.ts +54 -0
- package/dist/workspace-tools.js +123 -0
- package/docs/agent-compatibility.md +50 -28
- package/docs/ci-and-automation.md +105 -66
- package/docs/doxbrix-http-api.md +8 -1
- package/docs/existing-documentation.md +80 -0
- package/docs/generation-performance.md +108 -0
- package/docs/generator-authoring.md +68 -5
- package/docs/generator-selection.md +50 -13
- package/docs/mintlify-import.md +71 -0
- package/docs/openapi-security.md +25 -0
- package/docs/project-format.md +331 -36
- package/docs/release-quality.md +158 -0
- package/docs/releasing.md +72 -0
- package/docs/review-workflows.md +51 -0
- package/docs/security-model.md +102 -39
- package/docs/troubleshooting.md +226 -93
- package/package.json +46 -15
- package/scripts/test-auto-screenshot.mjs +172 -0
- package/skills/doxloop-authoring/SKILL.md +242 -361
- package/skills/doxloop-authoring/references/existing-documentation.md +94 -0
- package/skills/doxloop-authoring/references/navigation-architecture.md +18 -7
- package/skills/doxloop-authoring/references/page-depth.md +169 -0
- package/skills/doxloop-authoring/references/project-format.md +106 -7
- package/skills/doxloop-authoring/references/quality.md +10 -0
- package/skills/doxloop-authoring/references/screenshot-manifest.md +113 -0
- package/skills/doxloop-authoring/references/screenshots.md +149 -235
- package/skills/doxloop-authoring/references/workflows.md +76 -0
- package/skills/doxloop-doxbrix/SKILL.md +38 -22
- package/skills/doxloop-doxbrix/references/api-endpoints.md +15 -14
- package/skills/doxloop-doxbrix/references/components.md +30 -3
- package/skills/doxloop-doxbrix/references/manifest.md +3 -2
- package/vendor/doxbrix-import/LICENSE +202 -0
- package/vendor/doxbrix-import/README.md +17 -0
- package/vendor/doxbrix-import/UPSTREAM.json +47 -0
- package/vendor/doxbrix-import/dist/docs/frontmatter.d.ts +13 -0
- package/vendor/doxbrix-import/dist/docs/frontmatter.js +83 -0
- package/vendor/doxbrix-import/dist/docs/import.d.ts +21 -0
- package/vendor/doxbrix-import/dist/docs/import.js +147 -0
- package/vendor/doxbrix-import/dist/docs/manifest.d.ts +163 -0
- package/vendor/doxbrix-import/dist/docs/manifest.js +64 -0
- package/vendor/doxbrix-import/dist/docs/project.d.ts +25 -0
- package/vendor/doxbrix-import/dist/docs/project.js +77 -0
- package/vendor/doxbrix-import/dist/docs/starter.d.ts +4 -0
- package/vendor/doxbrix-import/dist/docs/starter.js +11 -0
- package/vendor/doxbrix-import/dist/importer.d.ts +227 -0
- package/vendor/doxbrix-import/dist/importer.js +1567 -0
- package/vendor/doxbrix-import/dist/mintlify-openapi.d.ts +37 -0
- package/vendor/doxbrix-import/dist/mintlify-openapi.js +305 -0
- package/vendor/doxbrix-import/dist/safe-path.d.ts +9 -0
- package/vendor/doxbrix-import/dist/safe-path.js +47 -0
- package/dist/agents.d.ts.map +0 -1
- package/dist/agents.js.map +0 -1
- package/dist/args.d.ts.map +0 -1
- package/dist/args.js.map +0 -1
- package/dist/artifact-deploy.d.ts.map +0 -1
- package/dist/artifact-deploy.js.map +0 -1
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js.map +0 -1
- package/dist/author.d.ts.map +0 -1
- package/dist/author.js.map +0 -1
- package/dist/capture.d.ts.map +0 -1
- package/dist/capture.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/deploy.d.ts.map +0 -1
- package/dist/deploy.js.map +0 -1
- package/dist/deployment-visibility.d.ts.map +0 -1
- package/dist/deployment-visibility.js.map +0 -1
- package/dist/doctor.d.ts.map +0 -1
- package/dist/doctor.js.map +0 -1
- package/dist/doxbrix-markdown.d.ts.map +0 -1
- package/dist/doxbrix-markdown.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/fs.d.ts.map +0 -1
- package/dist/fs.js.map +0 -1
- package/dist/generator-api.d.ts.map +0 -1
- package/dist/generator-api.js.map +0 -1
- package/dist/generator-manager.d.ts.map +0 -1
- package/dist/generator-manager.js.map +0 -1
- package/dist/generator-runtime.d.ts.map +0 -1
- package/dist/generator-runtime.js.map +0 -1
- package/dist/generators.d.ts.map +0 -1
- package/dist/generators.js.map +0 -1
- package/dist/interactive.d.ts.map +0 -1
- package/dist/interactive.js.map +0 -1
- package/dist/preview.d.ts.map +0 -1
- package/dist/preview.js.map +0 -1
- package/dist/progress.d.ts.map +0 -1
- package/dist/progress.js.map +0 -1
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js.map +0 -1
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js.map +0 -1
- package/dist/settings.d.ts.map +0 -1
- package/dist/settings.js.map +0 -1
- package/dist/sync.d.ts.map +0 -1
- package/dist/sync.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/validation.d.ts.map +0 -1
- package/dist/validation.js.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js.map +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))a(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&a(l)}).observe(document,{childList:!0,subtree:!0});function i(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function a(s){if(s.ep)return;s.ep=!0;const o=i(s);fetch(s.href,o)}})();var Ni,Le,Mr,dt,Ta,Lr,zr,Gi,gi,Ht,Er,va,ta,ia,_i={},Si=[],Vs=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Xt=Array.isArray;function tt(n,t){for(var i in t)n[i]=t[i];return n}function ba(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function Jt(n,t,i){var a,s,o,l={};for(o in t)o=="key"?a=t[o]:o=="ref"?s=t[o]:l[o]=t[o];if(arguments.length>2&&(l.children=arguments.length>3?Ni.call(arguments,2):i),typeof n=="function"&&n.defaultProps!=null)for(o in n.defaultProps)l[o]===void 0&&(l[o]=n.defaultProps[o]);return fi(n,l,a,s,null)}function fi(n,t,i,a,s){var o={type:n,props:t,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++Mr,__i:-1,__u:0};return s==null&&Le.vnode!=null&&Le.vnode(o),o}function ie(n){return n.children}function Wn(n,t){this.props=n,this.context=t}function Ut(n,t){if(t==null)return n.__?Ut(n.__,n.__i+1):null;for(var i;t<n.__k.length;t++)if((i=n.__k[t])!=null&&i.__e!=null)return i.__e;return typeof n.type=="function"?Ut(n):null}function Ks(n){if(n.__P&&n.__d){var t=n.__v,i=t.__e,a=[],s=[],o=tt({},t);o.__v=t.__v+1,Le.vnode&&Le.vnode(o),ya(n.__P,o,t,n.__n,n.__P.namespaceURI,32&t.__u?[i]:null,a,i??Ut(t),!!(32&t.__u),s),o.__v=t.__v,o.__.__k[o.__i]=o,jr(a,o,s),t.__e=t.__=null,o.__e!=i&&Nr(o)}}function Nr(n){if((n=n.__)!=null&&n.__c!=null)return n.__e=n.__c.base=null,n.__k.some(function(t){if(t!=null&&t.__e!=null)return n.__e=n.__c.base=t.__e}),Nr(n)}function Da(n){(!n.__d&&(n.__d=!0)&&dt.push(n)&&!$i.__r++||Ta!=Le.debounceRendering)&&((Ta=Le.debounceRendering)||Lr)($i)}function $i(){try{for(var n,t=1;dt.length;)dt.length>t&&dt.sort(zr),n=dt.shift(),t=dt.length,Ks(n)}finally{dt.length=$i.__r=0}}function Or(n,t,i,a,s,o,l,c,d,m,r){var g,u,v,h,y,P,k,C=a&&a.__k||Si,w=t.length;for(d=Js(i,t,C,d,w),g=0;g<w;g++)(v=i.__k[g])!=null&&(u=v.__i!=-1&&C[v.__i]||_i,v.__i=g,P=ya(n,v,u,s,o,l,c,d,m,r),h=v.__e,v.ref&&u.ref!=v.ref&&(u.ref&&wa(u.ref,null,v),r.push(v.ref,v.__c||h,v)),y==null&&h!=null&&(y=h),(k=!!(4&v.__u))||u.__k===v.__k?(d=Ur(v,d,n,k),k&&u.__e&&(u.__e=null)):typeof v.type=="function"&&P!==void 0?d=P:h&&(d=h.nextSibling),v.__u&=-7);return i.__e=y,d}function Js(n,t,i,a,s){var o,l,c,d,m,r=i.length,g=r,u=0;for(n.__k=new Array(s),o=0;o<s;o++)(l=t[o])!=null&&typeof l!="boolean"&&typeof l!="function"?(typeof l=="string"||typeof l=="number"||typeof l=="bigint"||l.constructor==String?l=n.__k[o]=fi(null,l,null,null,null):Xt(l)?l=n.__k[o]=fi(ie,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=n.__k[o]=fi(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):n.__k[o]=l,d=o+u,l.__=n,l.__b=n.__b+1,c=null,(m=l.__i=Ys(l,i,d,g))!=-1&&(g--,(c=i[m])&&(c.__u|=2)),c==null||c.__v==null?(m==-1&&(s>r?u--:s<r&&u++),typeof l.type!="function"&&(l.__u|=4)):m!=d&&(m==d-1?u--:m==d+1?u++:(m>d?u--:u++,l.__u|=4))):n.__k[o]=null;if(g)for(o=0;o<r;o++)(c=i[o])!=null&&(2&c.__u)==0&&(c.__e==a&&(a=Ut(c)),qr(c,c));return a}function Ur(n,t,i,a){var s,o;if(typeof n.type=="function"){for(s=n.__k,o=0;s&&o<s.length;o++)s[o]&&(s[o].__=n,t=Ur(s[o],t,i,a));return t}n.__e!=t&&(a&&(t&&n.type&&!t.parentNode&&(t=Ut(n)),i.insertBefore(n.__e,t||null)),t=n.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Bt(n,t){return t=t||[],n==null||typeof n=="boolean"||(Xt(n)?n.some(function(i){Bt(i,t)}):t.push(n)),t}function Ys(n,t,i,a){var s,o,l,c=n.key,d=n.type,m=t[i],r=m!=null&&(2&m.__u)==0;if(m===null&&c==null||r&&c==m.key&&d==m.type)return i;if(a>(r?1:0)){for(s=i-1,o=i+1;s>=0||o<t.length;)if((m=t[l=s>=0?s--:o++])!=null&&(2&m.__u)==0&&c==m.key&&d==m.type)return l}return-1}function Ra(n,t,i){t[0]=="-"?n.setProperty(t,i??""):n[t]=i==null?"":typeof i!="number"||Vs.test(t)?i:i+"px"}function li(n,t,i,a,s){var o,l;e:if(t=="style")if(typeof i=="string")n.style.cssText=i;else{if(typeof a=="string"&&(n.style.cssText=a=""),a)for(t in a)i&&t in i||Ra(n.style,t,"");if(i)for(t in i)a&&i[t]==a[t]||Ra(n.style,t,i[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(Er,"$1")),l=t.toLowerCase(),t=l in n||t=="onFocusOut"||t=="onFocusIn"?l.slice(2):t.slice(2),n.l||(n.l={}),n.l[t+o]=i,i?a?i[Ht]=a[Ht]:(i[Ht]=va,n.addEventListener(t,o?ia:ta,o)):n.removeEventListener(t,o?ia:ta,o);else{if(s=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in n)try{n[t]=i??"";break e}catch{}typeof i=="function"||(i==null||i===!1&&t[4]!="-"?n.removeAttribute(t):n.setAttribute(t,t=="popover"&&i==1?"":i))}}function Ma(n){return function(t){if(this.l){var i=this.l[t.type+n];if(t[gi]==null)t[gi]=va++;else if(t[gi]<i[Ht])return;return i(Le.event?Le.event(t):t)}}}function ya(n,t,i,a,s,o,l,c,d,m){var r,g,u,v,h,y,P,k,C,w,I,L,D,E,A,j,W=t.type;if(t.constructor!==void 0)return null;128&i.__u&&(d=!!(32&i.__u),o=[c=t.__e=i.__e]),(r=Le.__b)&&r(t);e:if(typeof W=="function"){g=l.length;try{if(C=t.props,w=W.prototype&&W.prototype.render,I=(r=W.contextType)&&a[r.__c],L=r?I?I.props.value:r.__:a,i.__c?k=(u=t.__c=i.__c).__=u.__E:(w?t.__c=u=new W(C,L):(t.__c=u=new Wn(C,L),u.constructor=W,u.render=Qs),I&&I.sub(u),u.state||(u.state={}),u.__n=a,v=u.__d=!0,u.__h=[],u._sb=[]),w&&u.__s==null&&(u.__s=u.state),w&&W.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=tt({},u.__s)),tt(u.__s,W.getDerivedStateFromProps(C,u.__s))),h=u.props,y=u.state,u.__v=t,v)w&&W.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),w&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(w&&W.getDerivedStateFromProps==null&&C!==h&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(C,L),t.__v==i.__v||!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(C,u.__s,L)===!1){t.__v!=i.__v&&(u.props=C,u.state=u.__s,u.__d=!1),t.__e=i.__e,t.__k=i.__k,t.__k.some(function(O){O&&(O.__=t)}),Si.push.apply(u.__h,u._sb),u._sb=[],u.__h.length&&l.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(C,u.__s,L),w&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(h,y,P)})}if(u.context=L,u.props=C,u.__P=n,u.__e=!1,D=Le.__r,E=0,w)u.state=u.__s,u.__d=!1,D&&D(t),r=u.render(u.props,u.state,u.context),Si.push.apply(u.__h,u._sb),u._sb=[];else do u.__d=!1,D&&D(t),r=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++E<25);u.state=u.__s,u.getChildContext!=null&&(a=tt(tt({},a),u.getChildContext())),w&&!v&&u.getSnapshotBeforeUpdate!=null&&(P=u.getSnapshotBeforeUpdate(h,y)),A=r!=null&&r.type===ie&&r.key==null?Fr(r.props.children):r,c=Or(n,Xt(A)?A:[A],t,i,a,s,o,l,c,d,m),u.base=t.__e,t.__u&=-161,u.__h.length&&l.push(u),k&&(u.__E=u.__=null)}catch(O){if(l.length=g,t.__v=null,d||o!=null){if(O.then){for(t.__u|=d?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),t.__e=c}else if(o!=null)for(j=o.length;j--;)ba(o[j])}else t.__e=i.__e;t.__k==null&&(t.__k=i.__k||[]),O.then||Br(t),Le.__e(O,t,i)}}else o==null&&t.__v==i.__v?(t.__k=i.__k,t.__e=i.__e):c=t.__e=Zs(i.__e,t,i,a,s,o,l,d,m);return(r=Le.diffed)&&r(t),128&t.__u?void 0:c}function Br(n){n&&(n.__c&&(n.__c.__e=!0),n.__k&&n.__k.some(Br))}function jr(n,t,i){for(var a=0;a<i.length;a++)wa(i[a],i[++a],i[++a]);Le.__c&&Le.__c(t,n),n.some(function(s){try{n=s.__h,s.__h=[],n.some(function(o){o.call(s)})}catch(o){Le.__e(o,s.__v)}})}function Fr(n){return typeof n!="object"||n==null||n.__b>0?n:Xt(n)?n.map(Fr):n.constructor!==void 0?null:tt({},n)}function Zs(n,t,i,a,s,o,l,c,d){var m,r,g,u,v,h,y,P=i.props||_i,k=t.props,C=t.type;if(C=="svg"?s="http://www.w3.org/2000/svg":C=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),o!=null){for(m=0;m<o.length;m++)if((v=o[m])&&"setAttribute"in v==!!C&&(C?v.localName==C:v.nodeType==3)){n=v,o[m]=null;break}}if(n==null){if(C==null)return document.createTextNode(k);n=document.createElementNS(s,C,k.is&&k),c&&(Le.__m&&Le.__m(t,o),c=!1),o=null}if(C==null)P===k||c&&n.data==k||(n.data=k);else{if(o=C=="textarea"&&k.defaultValue!=null?null:o&&Ni.call(n.childNodes),!c&&o!=null)for(P={},m=0;m<n.attributes.length;m++)P[(v=n.attributes[m]).name]=v.value;for(m in P)v=P[m],m=="dangerouslySetInnerHTML"?g=v:m=="children"||m in k||m=="value"&&"defaultValue"in k||m=="checked"&&"defaultChecked"in k||li(n,m,null,v,s);for(m in k)v=k[m],m=="children"?u=v:m=="dangerouslySetInnerHTML"?r=v:m=="value"?h=v:m=="checked"?y=v:c&&typeof v!="function"||P[m]===v||li(n,m,v,P[m],s);if(r)c||g&&(r.__html==g.__html||r.__html==n.innerHTML)||(n.innerHTML=r.__html),t.__k=[];else if(g&&(n.innerHTML=""),Or(t.type=="template"?n.content:n,Xt(u)?u:[u],t,i,a,C=="foreignObject"?"http://www.w3.org/1999/xhtml":s,o,l,o?o[0]:i.__k&&Ut(i,0),c,d),o!=null)for(m=o.length;m--;)ba(o[m]);c&&C!="textarea"||(m="value",C=="progress"&&h==null?n.removeAttribute("value"):h!=null&&(h!==n[m]||C=="progress"&&!h||C=="option"&&h!=P[m])&&li(n,m,h,P[m],s),m="checked",y!=null&&y!=n[m]&&li(n,m,y,P[m],s))}return n}function wa(n,t,i){try{if(typeof n=="function"){var a=typeof n.__u=="function";a&&n.__u(),a&&t==null||(n.__u=n(t))}else n.current=t}catch(s){Le.__e(s,i)}}function qr(n,t,i){var a,s;if(Le.unmount&&Le.unmount(n),(a=n.ref)&&(a.current&&a.current!=n.__e||wa(a,null,t)),(a=n.__c)!=null){if(a.componentWillUnmount)try{a.componentWillUnmount()}catch(o){Le.__e(o,t)}a.base=a.__P=a.__n=null}if(a=n.__k)for(s=0;s<a.length;s++)a[s]&&qr(a[s],t,i||typeof n.type!="function");i||ba(n.__e),n.__c=n.__=n.__e=void 0}function Qs(n,t,i){return this.constructor(n,i)}function aa(n,t,i){var a,s,o,l;t==document&&(t=document.documentElement),Le.__&&Le.__(n,t),s=(a=!1)?null:t.__k,o=[],l=[],ya(t,n=t.__k=Jt(ie,null,[n]),s||_i,_i,t.namespaceURI,s?null:t.firstChild?Ni.call(t.childNodes):null,o,s?s.__e:t.firstChild,a,l),jr(o,n,l),n.props.children=null}Ni=Si.slice,Le={__e:function(n,t,i,a){for(var s,o,l;t=t.__;)if((s=t.__c)&&!s.__)try{if((o=s.constructor)&&o.getDerivedStateFromError!=null&&(s.setState(o.getDerivedStateFromError(n)),l=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(n,a||{}),l=s.__d),l)return s.__E=s}catch(c){n=c}throw n}},Mr=0,Wn.prototype.setState=function(n,t){var i;i=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=tt({},this.state),typeof n=="function"&&(n=n(tt({},i),this.props)),n&&tt(i,n),n!=null&&this.__v&&(t&&this._sb.push(t),Da(this))},Wn.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),Da(this))},Wn.prototype.render=ie,dt=[],Lr=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,zr=function(n,t){return n.__v.__b-t.__v.__b},$i.__r=0,Gi=Math.random().toString(8),gi="__d"+Gi,Ht="__a"+Gi,Er=/(PointerCapture)$|Capture$/i,va=0,ta=Ma(!1),ia=Ma(!0);var Xs=0;function e(n,t,i,a,s,o){t||(t={});var l,c,d=t;if("ref"in d)for(c in d={},t)c=="ref"?l=t[c]:d[c]=t[c];var m={type:n,props:d,key:i,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Xs,__i:-1,__u:0,__source:s,__self:o};if(typeof n=="function"&&(l=n.defaultProps))for(c in l)d[c]===void 0&&(d[c]=l[c]);return Le.vnode&&Le.vnode(m),m}var $t,Qe,Hi,La,Pi=0,Wr=[],an=Le,za=an.__b,Ea=an.__r,Na=an.diffed,Oa=an.__c,Ua=an.unmount,Ba=an.__;function ei(n,t){an.__h&&an.__h(Qe,n,Pi||t),Pi=0;var i=Qe.__H||(Qe.__H={__:[],__h:[]});return n>=i.__.length&&i.__.push({}),i.__[n]}function p(n){return Pi=1,eo(Hr,n)}function eo(n,t,i){var a=ei($t++,2);if(a.t=n,!a.__c&&(a.__=[i?i(t):Hr(void 0,t),function(c){var d=a.__N?a.__N[0]:a.__[0],m=a.t(d,c);d!==m&&(a.__N=[m,a.__[1]],a.__c.setState({}))}],a.__c=Qe,!Qe.__f)){var s=function(c,d,m){if(!a.__c.__H)return!0;var r=!1,g=a.__c.props!==c;if(a.__c.__H.__.some(function(v){if(v.__N){r=!0;var h=v.__[0];v.__=v.__N,v.__N=void 0,h!==v.__[0]&&(g=!0)}}),o){var u=o.call(this,c,d,m);return r?u||g:u}return!r||g};Qe.__f=!0;var o=Qe.shouldComponentUpdate,l=Qe.componentWillUpdate;Qe.componentWillUpdate=function(c,d,m){if(this.__e){var r=o;o=void 0,s(c,d,m),o=r}l&&l.call(this,c,d,m)},Qe.shouldComponentUpdate=s}return a.__N||a.__}function ae(n,t){var i=ei($t++,3);!an.__s&&ka(i.__H,t)&&(i.__=n,i.u=t,Qe.__H.__h.push(i))}function Ii(n,t){var i=ei($t++,4);!an.__s&&ka(i.__H,t)&&(i.__=n,i.u=t,Qe.__h.push(i))}function Re(n){return Pi=5,Ai(function(){return{current:n}},[])}function Ai(n,t){var i=ei($t++,7);return ka(i.__H,t)&&(i.__=n(),i.__H=t,i.__h=n),i.__}function Gr(){var n=ei($t++,11);if(!n.__){for(var t=Qe.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var i=t.__m||(t.__m=[0,0]);n.__="P"+i[0]+"-"+i[1]++}return n.__}function no(){for(var n;n=Wr.shift();){var t=n.__H;if(n.__P&&t)try{t.__h.some(mi),t.__h.some(ra),t.__h=[]}catch(i){t.__h=[],an.__e(i,n.__v)}}}an.__b=function(n){Qe=null,za&&za(n)},an.__=function(n,t){n&&t.__k&&t.__k.__m&&(n.__m=t.__k.__m),Ba&&Ba(n,t)},an.__r=function(n){Ea&&Ea(n),$t=0;var t=(Qe=n.__c).__H;t&&(Hi===Qe?(t.__h=[],Qe.__h=[],t.__.some(function(i){i.__N&&(i.__=i.__N),i.u=i.__N=void 0})):(t.__h.some(mi),t.__h.some(ra),t.__h=[],$t=0)),Hi=Qe},an.diffed=function(n){Na&&Na(n);var t=n.__c;t&&t.__H&&(t.__H.__h.length&&(Wr.push(t)!==1&&La===an.requestAnimationFrame||((La=an.requestAnimationFrame)||to)(no)),t.__H.__.some(function(i){i.u&&(i.__H=i.u,i.u=void 0)})),Hi=Qe=null},an.__c=function(n,t){t.some(function(i){try{i.__h.some(mi),i.__h=i.__h.filter(function(a){return!a.__||ra(a)})}catch(a){t.some(function(s){s.__h&&(s.__h=[])}),t=[],an.__e(a,i.__v)}}),Oa&&Oa(n,t)},an.unmount=function(n){Ua&&Ua(n);var t,i=n.__c;i&&i.__H&&(i.__H.__.some(function(a){try{mi(a)}catch(s){t=s}}),i.__H=void 0,t&&an.__e(t,i.__v))};var ja=typeof requestAnimationFrame=="function";function to(n){var t,i=function(){clearTimeout(a),ja&&cancelAnimationFrame(t),setTimeout(n)},a=setTimeout(i,35);ja&&(t=requestAnimationFrame(i))}function mi(n){var t=Qe,i=n.__c;typeof i=="function"&&(n.__c=void 0,i()),Qe=t}function ra(n){var t=Qe;n.__c=n.__(),Qe=t}function ka(n,t){return!n||n.length!==t.length||t.some(function(i,a){return i!==n[a]})}function Hr(n,t){return typeof t=="function"?t(n):t}const io=12e4,Gn={signal:new AbortController().signal},ao="The Doxloop control center did not respond within two minutes. Check that `doxloop ui` is still running in your terminal, then try again.";async function _e(n,t){let i;try{i=await fetch(n,{...t,signal:t?.signal??AbortSignal.timeout(io),headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}})}catch(s){throw ro(s)?new Error(ao):s}const a=await i.json().catch(()=>({}));if(so(i.status,a.error))throw window.location.reload(),new Error("The local UI session changed. Reloading Doxloop…");if(!i.ok)throw new Error(a.error??`Request failed (${i.status})`);return a}function ro(n){return n instanceof Error&&(n.name==="TimeoutError"||n.name==="AbortError")}function so(n,t){return n===409&&t==="Invalid local UI session. Reload the Doxloop UI."}function K(n,t={},i){return _e(n,{...i,method:"POST",body:JSON.stringify(t)})}function qn(n,t){return _e(n,{method:"PATCH",body:JSON.stringify(t)})}function gt(n,t){return _e(n,{method:"PUT",body:JSON.stringify(t)})}function sa(n){return _e(n,{method:"DELETE"})}function oo(n,t){for(var i in t)n[i]=t[i];return n}function Fa(n,t){for(var i in n)if(i!=="__source"&&!(i in t))return!0;for(var a in t)if(a!=="__source"&&n[a]!==t[a])return!0;return!1}function qa(n,t){this.props=n,this.context=t}(qa.prototype=new Wn).isPureReactComponent=!0,qa.prototype.shouldComponentUpdate=function(n,t){return Fa(this.props,n)||Fa(this.state,t)};var Wa=Le.__b;Le.__b=function(n){n.type&&n.type.__f&&n.ref&&(n.props.ref=n.ref,n.ref=null),Wa&&Wa(n)};var lo=Le.__e;Le.__e=function(n,t,i,a){if(n.then){for(var s,o=t;o=o.__;)if((s=o.__c)&&s.__c)return t.__e==null&&(t.__e=i.__e,t.__k=i.__k||[]),s.__c(n,t)}lo(n,t,i,a)};var Ga=Le.unmount;function Vr(n,t,i){return n&&(n.__c&&n.__c.__H&&(n.__c.__H.__.forEach(function(a){typeof a.__c=="function"&&a.__c()}),n.__c.__H=null),(n=oo({},n)).__c!=null&&(n.__c.__P===i&&(n.__c.__P=t),n.__c.__e=!0,n.__c=null),n.__k=n.__k&&n.__k.map(function(a){return Vr(a,t,i)})),n}function Kr(n,t,i){return n&&i&&(n.__v=null,n.__k=n.__k&&n.__k.map(function(a){return Kr(a,t,i)}),n.__c&&n.__c.__P===t&&(n.__e&&i.appendChild(n.__e),n.__c.__e=!0,n.__c.__P=i)),n}function Vi(){this.__u=0,this.o=null,this.__b=null}function Jr(n){var t=n.__&&n.__.__c;return t&&t.__a&&t.__a(n)}function ci(){this.i=null,this.l=null}Le.unmount=function(n){var t=n.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&n.__u&&(n.type=null),Ga&&Ga(n)},(Vi.prototype=new Wn).__c=function(n,t){var i=t.__c,a=this;a.o==null&&(a.o=[]),a.o.push(i);var s=Jr(a.__v),o=!1,l=function(){o||a.__z||(o=!0,i.__R=null,s?s(d):d())};i.__R=l;var c=i.__P;i.__P=null;var d=function(){if(!--a.__u){if(a.state.__a){var m=a.state.__a;a.__v.__k[0]=Kr(m,m.__c.__P,m.__c.__O)}var r;for(a.setState({__a:a.__b=null});r=a.o.pop();)r.__P=c,r.forceUpdate()}};a.__u++||32&t.__u||a.setState({__a:a.__b=a.__v.__k[0]}),n.then(l,l)},Vi.prototype.componentWillUnmount=function(){this.o=[]},Vi.prototype.render=function(n,t){if(this.__b){if(this.__v.__k){var i=document.createElement("div"),a=this.__v.__k[0].__c;this.__v.__k[0]=Vr(this.__b,i,a.__O=a.__P)}this.__b=null}var s=t.__a&&Jt(ie,null,n.fallback);return s&&(s.__u&=-33),[Jt(ie,null,t.__a?null:n.children),s]};var Ha=function(n,t,i){if(++i[1]===i[0]&&n.l.delete(t),n.props.revealOrder&&(n.props.revealOrder[0]!=="t"||!n.l.size))for(i=n.i;i;){for(;i.length>3;)i.pop()();if(i[1]<i[0])break;n.i=i=i[2]}};function co(n){return this.getChildContext=function(){return n.context},n.children}function uo(n){var t=this,i=n.h;if(t.componentWillUnmount=function(){aa(null,t.v),t.v=null,t.h=null},t.h&&t.h!==i&&t.componentWillUnmount(),!t.v){for(var a=t.__v;a!==null&&!a.__m&&a.__!==null;)a=a.__;t.h=i,t.v={nodeType:1,parentNode:i,childNodes:[],__k:{__m:a.__m},contains:function(){return!0},namespaceURI:i.namespaceURI,insertBefore:function(s,o){this.childNodes.push(s),t.h.insertBefore(s,o)},removeChild:function(s){this.childNodes.splice(this.childNodes.indexOf(s)>>>1,1),t.h.removeChild(s)}}}aa(Jt(co,{context:t.context},n.__v),t.v)}function Yr(n,t){var i=Jt(uo,{__v:n,h:t});return i.containerInfo=t,i}(ci.prototype=new Wn).__a=function(n){var t=this,i=Jr(t.__v),a=t.l.get(n);return a[0]++,function(s){var o=function(){t.props.revealOrder?(a.push(s),Ha(t,n,a)):s()};i?i(o):o()}},ci.prototype.render=function(n){this.i=null,this.l=new Map;var t=Bt(n.children);n.revealOrder&&n.revealOrder[0]==="b"&&t.reverse();for(var i=t.length;i--;)this.l.set(t[i],this.i=[1,0,this.i]);return n.children},ci.prototype.componentDidUpdate=ci.prototype.componentDidMount=function(){var n=this;this.l.forEach(function(t,i){Ha(n,i,t)})};var po=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,ho=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,go=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,fo=/[A-Z0-9]/g,mo=typeof document<"u",vo=function(n){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(n)};Wn.prototype.isReactComponent=!0,["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(n){Object.defineProperty(Wn.prototype,n,{configurable:!0,get:function(){return this["UNSAFE_"+n]},set:function(t){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:t})}})});var Va=Le.event;Le.event=function(n){return Va&&(n=Va(n)),n.persist=function(){},n.isPropagationStopped=function(){return this.cancelBubble},n.isDefaultPrevented=function(){return this.defaultPrevented},n.nativeEvent=n};var bo={configurable:!0,get:function(){return this.class}},Ka=Le.vnode;Le.vnode=function(n){typeof n.type=="string"&&(function(t){var i=t.props,a=t.type,s={},o=a.indexOf("-")==-1;for(var l in i){var c=i[l];if(!(l==="value"&&"defaultValue"in i&&c==null||mo&&l==="children"&&a==="noscript"||l==="class"||l==="className")){var d=l.toLowerCase();l==="defaultValue"&&"value"in i&&i.value==null?l="value":l==="download"&&c===!0?c="":d==="translate"&&c==="no"?c=!1:d[0]==="o"&&d[1]==="n"?d==="ondoubleclick"?l="ondblclick":d!=="onchange"||a!=="input"&&a!=="textarea"||vo(i.type)?d==="onfocus"?l="onfocusin":d==="onblur"?l="onfocusout":go.test(l)&&(l=d):d=l="oninput":o&&ho.test(l)?l=l.replace(fo,"-$&").toLowerCase():c===null&&(c=void 0),d==="oninput"&&s[l=d]&&(l="oninputCapture"),s[l]=c}}a=="select"&&(s.multiple&&Array.isArray(s.value)&&(s.value=Bt(i.children).forEach(function(m){m.props.selected=s.value.indexOf(m.props.value)!=-1})),s.defaultValue!=null&&(s.value=Bt(i.children).forEach(function(m){m.props.selected=s.multiple?s.defaultValue.indexOf(m.props.value)!=-1:s.defaultValue==m.props.value}))),i.class&&!i.className?(s.class=i.class,Object.defineProperty(s,"className",bo)):i.className&&(s.class=s.className=i.className),t.props=s})(n),n.$$typeof=po,Ka&&Ka(n)};var Ja=Le.__r;Le.__r=function(n){Ja&&Ja(n),n.__c};var Ya=Le.diffed;Le.diffed=function(n){Ya&&Ya(n);var t=n.props,i=n.__e;i!=null&&n.type==="textarea"&&"value"in t&&t.value!==i.value&&(i.value=t.value==null?"":t.value)};const Ki={terminal:"M3 4h18v16H3zM6 8l4 4-4 4M13 16h5",code:"M8 6 2 12l6 6M16 6l6 6-6 6M14 3l-4 18",server:"M3 3h18v7H3zM3 14h18v7H3zM7 6.5h.01M7 17.5h.01M16 6.5h2M16 17.5h2",package:"M12 2 22 7v10l-10 5L2 17V7zM2 7l10 5 10-5M12 12v10M7 4.5l10 5V15",plug:"M8 2v5M16 2v5M6 7h12v4a6 6 0 0 1-12 0zM12 17v5",wrench:"M14 7a5 5 0 0 0-6 6l-5 5a2.1 2.1 0 0 0 3 3l5-5a5 5 0 0 0 6-6l-3 3-3-3z",workflow:"M3 3h6v6H3zM15 15h6v6h-6zM9 6h6a3 3 0 0 1 3 3v6M6 9v9h9",history:"M3 11a9 9 0 1 1 2.6 7.4M3 4v7h7M12 7v5l3 2",eyeOff:"M3 3l18 18M10.6 5.1 12 5c6 0 10 7 10 7a20 20 0 0 1-3 3.8M6.3 6.3A24 24 0 0 0 2 12s4 7 10 7a13 13 0 0 0 5.7-1.7M10 10a3 3 0 0 0 4 4",download:"M12 3v12M7 10l5 5 5-5M3 16v5h18v-5",layers:"M12 2 2 7l10 5 10-5zM2 12l10 5 10-5M2 17l10 5 10-5",rocket:"M14 4c3-2 6-1 6-1s1 3-1 6l-7 7-4-4zM8 12H4l-2 4h7M12 16v4l4-2v-5M7 17l-3 3M16 7h.01",compass:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0ZM16 8l-2 6-6 2 2-6z",globe:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0ZM3 12h18M12 3c5 5 5 13 0 18-5-5-5-13 0-18",eye:"M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12ZM15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z",undo:"M9 5 4 10l5 5M4 10h10a6 6 0 0 1 0 12",overview:"M3.5 3.5h7v7h-7zM13.5 3.5h7v7h-7zM3.5 13.5h7v7h-7zM13.5 13.5h7v7h-7z",update:"M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z",review:"M9 11l3 3L22 4M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11",deploy:"M16 16l-4-4-4 4M12 12v9M20.4 16.6A5 5 0 0 0 18 7h-1.3A8 8 0 1 0 3 15.3",menu:"M4 7h16M4 12h16M4 17h16",home:"M3 10.4 12 3.2l9 7.2V20a1 1 0 0 1-1 1h-4.6v-6H9.6v6H5a1 1 0 0 1-1-1z",sources:"M12 3c4.1 0 7.5 1.3 7.5 3s-3.4 3-7.5 3-7.5-1.3-7.5-3 3.4-3 7.5-3ZM4.5 6v6c0 1.7 3.4 3 7.5 3s7.5-1.3 7.5-3V6M4.5 12v6c0 1.7 3.4 3 7.5 3s7.5-1.3 7.5-3v-6",authoring:"M12 3.2l1.85 5 4.95 1.85-4.95 1.85L12 16.9l-1.85-5L5.2 10.05l4.95-1.85zM18.5 15l.75 2.05L21.3 17.8l-2.05.75L18.5 20.6l-.75-2.05L15.7 17.8l2.05-.75z",sync:"M20.5 12a8.5 8.5 0 0 1-14.9 5.6M3.5 12a8.5 8.5 0 0 1 14.9-5.6M18.4 3.2v3.2h-3.2M5.6 20.8v-3.2h3.2",proposals:"M6.5 3h7.2L19 8.3V21H6.5zM13.4 3v5.4H19M9.8 13.6h5.4M12.5 10.9v5.4",preview:"M4.4 4.6h15.2a1.4 1.4 0 0 1 1.4 1.4v9.4a1.4 1.4 0 0 1-1.4 1.4H4.4A1.4 1.4 0 0 1 3 15.4V6a1.4 1.4 0 0 1 1.4-1.4ZM9 20.8h6M12 16.8v4",publish:"M12 16.2V3.6M7.6 8l4.4-4.4L16.4 8M4 14.6v3.8A1.6 1.6 0 0 0 5.6 20h12.8a1.6 1.6 0 0 0 1.6-1.6v-3.8",settings:"M12 9.2a2.8 2.8 0 1 1 0 5.6 2.8 2.8 0 0 1 0-5.6ZM19.1 14.4a1.5 1.5 0 0 0 .3 1.7l.1.1a1.9 1.9 0 1 1-2.7 2.7l-.1-.1a1.5 1.5 0 0 0-2.6 1.1v.2a1.9 1.9 0 1 1-3.8 0v-.1a1.5 1.5 0 0 0-2.6-1.1l-.1.1a1.9 1.9 0 1 1-2.7-2.7l.1-.1a1.5 1.5 0 0 0-1.1-2.6h-.2a1.9 1.9 0 1 1 0-3.8h.1a1.5 1.5 0 0 0 1.1-2.6l-.1-.1a1.9 1.9 0 1 1 2.7-2.7l.1.1a1.5 1.5 0 0 0 2.6-1.1v-.2a1.9 1.9 0 1 1 3.8 0v.1a1.5 1.5 0 0 0 2.6 1.1l.1-.1a1.9 1.9 0 1 1 2.7 2.7l-.1.1a1.5 1.5 0 0 0 1.1 2.6h.2a1.9 1.9 0 1 1 0 3.8h-.1a1.5 1.5 0 0 0-1.4.9Z",search:"M11 4.2a6.8 6.8 0 1 1 0 13.6 6.8 6.8 0 0 1 0-13.6ZM20 20l-4-4",plus:"M12 5.2v13.6M5.2 12h13.6",minus:"M5.5 12h13",copy:"M9 9.5h9.5V19H9zM5.5 14.5V5h9.5",check:"M5.2 12.6 9.6 17 18.8 7.4",alert:"M12 3.9 2.9 20.1h18.2zM12 9.6v4.6M12 17.1h.01",info:"M12 3.2a8.8 8.8 0 1 1 0 17.6 8.8 8.8 0 0 1 0-17.6ZM12 11v5.4M12 7.7h.01",close:"M6.4 6.4l11.2 11.2M17.6 6.4 6.4 17.6",chevronRight:"m9.5 5.5 6.5 6.5-6.5 6.5",chevronDown:"m5.5 9.5 6.5 6.5 6.5-6.5",chevronUp:"m5.5 14.5 6.5-6.5 6.5 6.5",chevronLeft:"m14.5 5.5-6.5 6.5 6.5 6.5",chevronUpDown:"m8 10 4-4 4 4M8 14l4 4 4-4",help:"M12 3.2a8.8 8.8 0 1 1 0 17.6 8.8 8.8 0 0 1 0-17.6ZM9.5 9.3a2.6 2.6 0 0 1 5 .9c0 1.7-2.5 2.6-2.5 2.6v1.1M12 17.4h.01",clock:"M12 3.2a8.8 8.8 0 1 1 0 17.6 8.8 8.8 0 0 1 0-17.6ZM12 7.2V12l3.2 2",external:"M14 3.8h6.2V10M20.2 3.8 11.6 12.4M18.6 14.2v4.6a1.4 1.4 0 0 1-1.4 1.4H5.6a1.4 1.4 0 0 1-1.4-1.4V7.2a1.4 1.4 0 0 1 1.4-1.4h4.6",link:"M9.4 14.6 14.6 9.4M7.3 16.7l-1.1 1.1a3.5 3.5 0 0 1-5-5l3.5-3.5a3.5 3.5 0 0 1 5 0M16.7 7.3l1.1-1.1a3.5 3.5 0 0 1 5 5l-3.5 3.5a3.5 3.5 0 0 1-5 0",trash:"M4.5 6.8h15M9.4 6.8V4.6h5.2v2.2M6.7 6.8 7.8 20h8.4l1.1-13.2M10.3 10.4v6M13.7 10.4v6",shield:"M12 3.3 19 6v5.7c0 4.3-2.8 7.5-7 8.9-4.2-1.4-7-4.6-7-8.9V6z",file:"M6.6 3h7.2L19 8.3V21H6.6zM13.5 3v5.4H19",api:"M8.4 8.4 4.8 12l3.6 3.6M15.6 8.4 19.2 12l-3.6 3.6M13.4 5.8l-2.8 12.4",braces:"M9 3.5H7.7A2.7 2.7 0 0 0 5 6.2v3.1A2.7 2.7 0 0 1 2.5 12 2.7 2.7 0 0 1 5 14.7v3.1a2.7 2.7 0 0 0 2.7 2.7H9M15 3.5h1.3A2.7 2.7 0 0 1 19 6.2v3.1a2.7 2.7 0 0 0 2.5 2.7 2.7 2.7 0 0 0-2.5 2.7v3.1a2.7 2.7 0 0 1-2.7 2.7H15",folder:"M3.6 6.4a1.4 1.4 0 0 1 1.4-1.4h3.7l2 2.4h7.7a1.4 1.4 0 0 1 1.4 1.4v9.4a1.4 1.4 0 0 1-1.4 1.4H5a1.4 1.4 0 0 1-1.4-1.4z",github:"M12 3.2a8.8 8.8 0 0 0-2.8 17.2c.4.1.6-.2.6-.5v-1.7c-2.4.5-3-1.1-3-1.1-.4-1-1-1.3-1-1.3-.8-.6.1-.5.1-.5.9.1 1.4.9 1.4.9.8 1.4 2.1 1 2.6.8.1-.6.3-1 .6-1.2-1.9-.2-3.9-1-3.9-4.2 0-.9.3-1.7.9-2.3-.1-.2-.4-1.1.1-2.3 0 0 .7-.2 2.3.9a8 8 0 0 1 4.2 0c1.6-1.1 2.3-.9 2.3-.9.5 1.2.2 2.1.1 2.3.6.6.9 1.4.9 2.3 0 3.2-2 4-3.9 4.2.3.3.6.8.6 1.7v2.5c0 .3.2.6.6.5A8.8 8.8 0 0 0 12 3.2Z",gitlab:"M12 21.2 3.6 15.1 5.9 4.2a.8.8 0 0 1 1.5-.1L9.8 11h4.4l2.4-6.9a.8.8 0 0 1 1.5.1l2.3 10.9zM3.6 15.1 9.8 11 12 21.2 14.2 11l6.2 4.1",bell:"M12 3.6a5.4 5.4 0 0 1 5.4 5.4c0 4.4 1.6 5.6 1.6 5.6H5s1.6-1.2 1.6-5.6A5.4 5.4 0 0 1 12 3.6ZM10.3 17.8a1.9 1.9 0 0 0 3.4 0",sparkle:"M12 3.2l1.85 5 4.95 1.85-4.95 1.85L12 16.9l-1.85-5L5.2 10.05l4.95-1.85z",arrowRight:"M4.5 12h15M13.5 6l6 6-6 6",refresh:"M20.5 12a8.5 8.5 0 0 1-14.9 5.6M3.5 12a8.5 8.5 0 0 1 14.9-5.6M18.4 3.2v3.2h-3.2M5.6 20.8v-3.2h3.2",play:"M7.5 4.8 19 12 7.5 19.2z",stop:"M6.5 6.5h11v11h-11z",columns:"M4.2 5.4h15.6v13.2H4.2zM12 5.4v13.2",filter:"M4 6h16l-6.2 7.3V19l-3.6-2v-3.7z",book:"M4.4 4.6h5.1A2.5 2.5 0 0 1 12 7.1v12a2 2 0 0 0-2-1.8H4.4zM19.6 4.6h-5.1A2.5 2.5 0 0 0 12 7.1v12a2 2 0 0 1 2-1.8h5.6z",user:"M12 4.2a3.7 3.7 0 1 1 0 7.4 3.7 3.7 0 0 1 0-7.4ZM4.8 20.2a7.2 7.2 0 0 1 14.4 0",key:"M15.2 4.6a4.6 4.6 0 1 1-3.6 7.5L4 19.7v-2.9h2.9v-2.6h2.6l2.1-2.1a4.6 4.6 0 0 1 3.6-7.5Z",logout:"M9.6 20H5.8A1.8 1.8 0 0 1 4 18.2V5.8A1.8 1.8 0 0 1 5.8 4h3.8M15.4 16.2 19.6 12l-4.2-4.2M19.6 12H9.4",wand:"M5.2 18.8 14.6 9.4M12.8 7.6l3.6 3.6M18 3l.8 2.2 2.2.8-2.2.8-.8 2.2-.8-2.2-2.2-.8 2.2-.8z",list:"M5 7h.01M5 12h.01M5 17h.01M9.2 7H19M9.2 12H19M9.2 17H19",record:"M12 4.6a7.4 7.4 0 1 1 0 14.8 7.4 7.4 0 0 1 0-14.8ZM12 9.6a2.4 2.4 0 1 1 0 4.8 2.4 2.4 0 0 1 0-4.8Z",broadcast:"M8.5 8.5a5 5 0 0 0 0 7M15.5 15.5a5 5 0 0 0 0-7M5.6 5.6a9 9 0 0 0 0 12.8M18.4 18.4a9 9 0 0 0 0-12.8M12 10.7a1.3 1.3 0 1 1 0 2.6 1.3 1.3 0 0 1 0-2.6Z",bot:"M12 3.2v2.2M8.4 5.4h7.2a2.4 2.4 0 0 1 2.4 2.4v8a2.4 2.4 0 0 1-2.4 2.4H8.4A2.4 2.4 0 0 1 6 15.8v-8a2.4 2.4 0 0 1 2.4-2.4ZM9.8 10.2v1.6M14.2 10.2v1.6M9.9 15h4.2",brain:"M9.5 4.2A3.2 3.2 0 0 0 6.3 7.4v.3A3.5 3.5 0 0 0 4 11a3.5 3.5 0 0 0 2.1 3.2v.4A3.2 3.2 0 0 0 9.3 18h.2M14.5 4.2a3.2 3.2 0 0 1 3.2 3.2v.3A3.5 3.5 0 0 1 20 11a3.5 3.5 0 0 1-2.1 3.2v.4a3.2 3.2 0 0 1-3.2 3.4h-.2M9.5 4.2V20M14.5 4.2V20M6.3 7.7h3.2M14.5 7.7h3.2M6.1 14.2h3.4M14.5 14.2h3.4",chat:"M5.2 5.2h13.6A2.2 2.2 0 0 1 21 7.4v7.2a2.2 2.2 0 0 1-2.2 2.2h-7.1l-4.8 3.5v-3.5H5.2A2.2 2.2 0 0 1 3 14.6V7.4a2.2 2.2 0 0 1 2.2-2.2Z",camera:"M8.2 6.2 9.5 4h5l1.3 2.2h3A2.2 2.2 0 0 1 21 8.4v9.4a2.2 2.2 0 0 1-2.2 2.2H5.2A2.2 2.2 0 0 1 3 17.8V8.4a2.2 2.2 0 0 1 2.2-2.2zM12 9a4 4 0 1 0 0 8 4 4 0 0 0 0-8Z",lock:"M7.4 10.4V8a4.6 4.6 0 0 1 9.2 0v2.4M6.4 10.4h11.2a1.4 1.4 0 0 1 1.4 1.4v6.8a1.4 1.4 0 0 1-1.4 1.4H6.4A1.4 1.4 0 0 1 5 18.6v-6.8a1.4 1.4 0 0 1 1.4-1.4Z",zap:"M13.4 3 5.8 13.4h5.2L10.6 21l7.6-10.4h-5.2z",cloud:"M7.6 18.6a4.5 4.5 0 0 1 .2-9 5.7 5.7 0 0 1 10.9 1.7 3.7 3.7 0 0 1-.5 7.3z",calendar:"M5.6 5.4h12.8a1.4 1.4 0 0 1 1.4 1.4v11.8a1.4 1.4 0 0 1-1.4 1.4H5.6a1.4 1.4 0 0 1-1.4-1.4V6.8a1.4 1.4 0 0 1 1.4-1.4ZM8.4 3.4v4M15.6 3.4v4M4.2 10.4h15.6",map:"M9.2 4.4 3.6 6.8v12.8l5.6-2.4 5.6 2.4 5.6-2.4V4.4l-5.6 2.4zM9.2 4.4v12.8M14.8 6.8v12.8",users:"M9.4 4.6a3.4 3.4 0 1 1 0 6.8 3.4 3.4 0 0 1 0-6.8ZM3.2 19.8a6.2 6.2 0 0 1 12.4 0M16.6 5.2a3.4 3.4 0 0 1 0 6.4M17.9 14.4a6.2 6.2 0 0 1 2.9 5.4",activity:"M3.4 12h3.8l2.4-6.8 4 13.6 2.4-6.8h4.6",sparkles:"M12 3.2l1.85 5 4.95 1.85-4.95 1.85L12 16.9l-1.85-5L5.2 10.05l4.95-1.85zM18.5 15l.75 2.05L21.3 17.8l-2.05.75L18.5 20.6l-.75-2.05L15.7 17.8l2.05-.75z"};function $({name:n,size:t=16,class:i}){if(n==="gitlab")return e("svg",{class:`icon gitlab-icon ${i??""}`,viewBox:"0 0 36 36",width:t,height:t,"aria-hidden":"true",children:[e("path",{fill:"#e24329",d:"M18 34.8 24.6 14.5H11.4z"}),e("path",{fill:"#fc6d26",d:"M18 34.8 11.4 14.5H2.2z"}),e("path",{fill:"#fca326",d:"M2.2 14.5.2 20.6c-.2.6 0 1.3.6 1.7L18 34.8z"}),e("path",{fill:"#e24329",d:"M2.2 14.5h9.2L7.5 2.6c-.2-.6-1.1-.6-1.3 0z"}),e("path",{fill:"#fca326",d:"m33.8 14.5 2 6.1c.2.6 0 1.3-.6 1.7L18 34.8z"}),e("path",{fill:"#e24329",d:"M33.8 14.5h-9.2l3.9-11.9c.2-.6 1.1-.6 1.3 0z"}),e("path",{fill:"#fc6d26",d:"m18 34.8 6.6-20.3h9.2z"})]});const a={bolt:"zap",database:"sources"},s=Ki[n]??Ki[a[n]??""]??Ki.info;return e("svg",{class:`icon ${i??""}`,viewBox:"0 0 24 24",width:t,height:t,fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:e("path",{d:s})})}const yo=/\u001b\[[0-?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)|\u001b[@-Z\\-_]/g,Zr=/^\d{2}:\d{2}:\d{2} /;function Oi(n){return n.replace(yo,"")}function wo(n){const t=n.replace(Zr,"").trim();if(t.startsWith("DOXLOOP_EVENT"))return!0;if(!t.startsWith("{")||!t.endsWith("}"))return!1;try{const i=JSON.parse(t);return typeof i=="object"&&i!==null&&typeof i.type=="string"}catch{return!1}}function Ca(n){return n.map(Oi).filter(t=>!wo(t))}const ko=[[/^product$/,"Product research"],[/^application$/,"App exploration"],[/^existing-docs/,"Existing docs review"],[/^batch/,"Writing"]];function Co(n){return ko.find(([t])=>t.test(n))?.[1]??n.replace(/[-_]+/g," ").replace(/^\w/,t=>t.toUpperCase())}function xo(n){let t=0,i=0;const a=[];let s;for(const o of Ca(n)){const l=o.replace(Zr,""),c=/^\[([^\]]+)\]\s*(.*)$/.exec(l),d=c?Co(c[1]):"",m=(c?c[2]:l).trim();d&&!a.includes(d)&&a.push(d),/^✓ Using \S*capture\S* browser_take_screenshot/.test(m)?t+=1:/^✓ Running /.test(m)?i+=1:d&&m.length>40&&!/^[→✓✗×!]/.test(m)&&!/^(?:Using|Running|Codex|Claude|Gemini) /.test(m)&&(s={session:d,text:m})}return{screenshots:t,sourceReads:i,sessions:a,...s?{latestNote:s}:{}}}function Ue(n){return e("section",{class:`panel ${n.class??""}`,children:[(n.title||n.actions)&&e("header",{class:"panel-head",children:[n.icon&&e("span",{class:"panel-icon",children:e($,{name:n.icon,size:17})}),e("div",{class:"panel-title",children:[n.title&&e("h2",{children:n.title}),n.description&&e("p",{children:n.description})]}),n.actions&&e("div",{class:"panel-actions",children:n.actions})]}),e("div",{class:`panel-body ${n.flush?"flush":""}`,children:n.children}),n.footer&&e("footer",{class:"panel-foot",children:n.footer})]})}function ht({title:n,description:t,icon:i,actions:a,meta:s,kicker:o}){return e("div",{class:"page-head",children:[i&&e("span",{class:"page-head-icon",children:e($,{name:i,size:30})}),e("div",{class:"page-head-copy","data-kicker":o,children:[e("h1",{children:n}),t&&e("p",{children:t}),s&&e("div",{class:"page-meta",children:s})]}),a&&e("div",{class:"page-head-actions",children:a})]})}function Qr({value:n,onChange:t,items:i}){return e("div",{class:"tabs",role:"tablist",children:i.map(([a,s])=>e("button",{role:"tab","aria-selected":n===a,class:n===a?"active":"",onClick:()=>t(a),children:s},a))})}function _(n){const{tone:t="secondary",size:i="md",icon:a,busy:s,children:o,class:l,...c}=n;return e("button",{...c,class:`btn ${t} ${i} ${l??""}`,disabled:!!(c.disabled||s),"aria-busy":s,children:[s?e("span",{class:"spinner"}):a&&e($,{name:a,size:i==="sm"?14:16}),s?"Working…":o]})}function Me({tone:n="neutral",icon:t,children:i}){return e("span",{class:`badge ${n}`,children:[t&&e($,{name:t,size:12}),i]})}function U(n){return e("label",{class:`field ${n.wide?"wide":""}`,children:[e("span",{class:"field-label",children:[n.label,n.hint&&e("span",{class:"field-hint",tabIndex:0,role:"img","aria-label":n.hint,"data-hint":n.hint,onClick:t=>t.preventDefault(),children:e($,{name:"info",size:12})})]}),n.children]})}function re(n){return e("input",{...n,class:`input ${n.class??""}`})}function Fe({icon:n,...t}){const{children:i,class:a,disabled:s,name:o,onChange:l,value:c}=t,d=Re(null),m=Re(null),r=Gr(),[g,u]=p(!1),[v,h]=p(0),[y,P]=p({left:0,top:0,width:0}),k=Bt(i).flatMap(A=>{if(!A||typeof A!="object"||A.type!=="option")return[];const j=A,W=Bt(j.props.children).join("");return[{value:String(j.props.value??W),label:W,disabled:!!j.props.disabled}]}),C=Math.max(0,k.findIndex(A=>A.value===String(c??""))),w=k[C],I=()=>{if(s||!d.current)return;const A=d.current.getBoundingClientRect(),j=Math.min(248,k.length*39+10),W=innerHeight-A.bottom-8,O=W<Math.min(180,j)&&A.top>W;P({left:A.left,top:O?Math.max(8,A.top-j-4):A.bottom+4,width:A.width}),h(C),u(!0)},L=(A,j=!1)=>{j||(l?.({currentTarget:{value:A},target:{value:A}}),u(!1),d.current?.querySelector("button")?.focus())},D=A=>{if(!k.length)return;let j=v;do j=(j+A+k.length)%k.length;while(k[j]?.disabled&&j!==v);h(j)},E=A=>{if(A.key==="ArrowDown"||A.key==="ArrowUp"){A.preventDefault(),g?D(A.key==="ArrowDown"?1:-1):I();return}if(A.key==="Home"&&g){A.preventDefault(),h(0);return}if(A.key==="End"&&g){A.preventDefault(),h(Math.max(0,k.length-1));return}if((A.key==="Enter"||A.key===" ")&&g){A.preventDefault();const j=k[v];j&&L(j.value,j.disabled);return}A.key==="Escape"&&g&&(A.preventDefault(),u(!1))};return ae(()=>{if(!g)return;const A=O=>{const ue=O.target;!d.current?.contains(ue)&&!m.current?.contains(ue)&&u(!1)},j=()=>u(!1),W=O=>{const ue=O.target;ue instanceof Node&&m.current?.contains(ue)||u(!1)};return addEventListener("mousedown",A),addEventListener("resize",j),addEventListener("scroll",W,!0),()=>{removeEventListener("mousedown",A),removeEventListener("resize",j),removeEventListener("scroll",W,!0)}},[g]),e("span",{ref:d,class:`select-wrap custom-select ${n?"with-icon":""}`,children:[n&&e($,{name:n,size:15,class:"lead-icon"}),e("button",{type:"button",class:`input custom-select-trigger ${a??""}`,disabled:s,"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],"aria-haspopup":"listbox","aria-expanded":g,"aria-controls":g?r:void 0,"aria-activedescendant":g?`${r}-${v}`:void 0,onClick:()=>g?u(!1):I(),onKeyDown:E,children:[e("span",{children:w?.label||"Select an option"}),e($,{name:"chevronDown",size:14})]}),o&&e("input",{type:"hidden",name:o,value:String(c??"")}),g&&typeof document<"u"&&Yr(e("div",{ref:m,id:r,class:"custom-select-menu",role:"listbox","aria-label":t["aria-label"],style:`left:${y.left}px;top:${y.top}px;width:${y.width}px`,children:k.map((A,j)=>e("button",{type:"button",id:`${r}-${j}`,role:"option","aria-selected":j===C,class:`${j===C?"selected":""} ${j===v?"highlighted":""}`,disabled:A.disabled,onMouseEnter:()=>h(j),onClick:()=>L(A.value,A.disabled),children:[e("span",{children:A.label}),j===C&&e($,{name:"check",size:14})]},`${A.value}-${j}`))}),document.body)]})}function it({value:n,options:t,placeholder:i,disabled:a,onValueChange:s}){const o=Re(null),l=Re(null),c=Re(null),d=Gr(),[m,r]=p(!1),[g,u]=p(""),[v,h]=p(0),[y,P]=p({left:0,top:0,width:0}),k=g.trim().toLowerCase(),C=k?t.filter(([D,E])=>`${E} ${D}`.toLowerCase().includes(k)):t,w=(D="")=>{if(a||!o.current)return;const E=o.current.getBoundingClientRect(),A=Math.min(248,Math.max(44,t.length*45+10)),j=innerHeight-E.bottom-8,W=j<Math.min(180,A)&&E.top>j;P({left:E.left,top:W?Math.max(8,E.top-A-4):E.bottom+4,width:E.width}),u(D),h(0),r(!0)},I=D=>{s(D),u(""),r(!1),l.current?.focus()},L=D=>{if(D.key==="ArrowDown"||D.key==="ArrowUp"){D.preventDefault(),m?C.length&&h(E=>(E+(D.key==="ArrowDown"?1:-1)+C.length)%C.length):w();return}if(D.key==="Enter"&&m&&C[v]){D.preventDefault(),I(C[v][0]);return}D.key==="Escape"&&m&&(D.preventDefault(),r(!1))};return ae(()=>{if(!m)return;const D=j=>{const W=j.target;!o.current?.contains(W)&&!c.current?.contains(W)&&r(!1)},E=()=>r(!1),A=j=>{const W=j.target;W instanceof Node&&c.current?.contains(W)||r(!1)};return addEventListener("mousedown",D),addEventListener("resize",E),addEventListener("scroll",A,!0),()=>{removeEventListener("mousedown",D),removeEventListener("resize",E),removeEventListener("scroll",A,!0)}},[m]),e("span",{ref:o,class:"select-wrap editable-select",children:[e("input",{ref:l,class:"input",role:"combobox",value:n,placeholder:i,disabled:a,"aria-autocomplete":"list","aria-expanded":m,"aria-controls":m?d:void 0,"aria-activedescendant":m&&C[v]?`${d}-${v}`:void 0,onFocus:()=>{m||w()},onInput:D=>{const E=D.currentTarget.value;s(E),w(E)},onKeyDown:L}),e("button",{type:"button",tabindex:-1,disabled:a,"aria-label":m?"Close suggestions":"Show suggestions",onMouseDown:D=>D.preventDefault(),onClick:()=>m?r(!1):w(),children:e($,{name:"chevronDown",size:14})}),m&&typeof document<"u"&&Yr(e("div",{ref:c,id:d,class:"editable-select-menu",role:"listbox",style:`left:${y.left}px;top:${y.top}px;width:${y.width}px`,children:C.length?C.map(([D,E],A)=>e("button",{type:"button",id:`${d}-${A}`,role:"option","aria-selected":n===D,class:`${n===D?"selected":""} ${v===A?"highlighted":""}`,onMouseEnter:()=>h(A),onClick:()=>I(D),children:[e("span",{children:[e("strong",{children:E}),E!==D&&e("small",{children:D})]}),n===D&&e($,{name:"check",size:14})]},D)):e("span",{class:"editable-select-empty",children:"No suggestion found. Your custom value will be used."})}),document.body)]})}function en(n){return e("textarea",{...n,class:`input textarea ${n.class??""}`})}function jt({checked:n,disabled:t,onChange:i,label:a}){return e("label",{class:"toggle",children:[e("input",{type:"checkbox",checked:n,disabled:t,onChange:s=>i(s.currentTarget.checked)}),e("span",{class:"toggle-track"}),e("span",{class:"toggle-text",children:a})]})}function pt({value:n,onChange:t,items:i}){return e("div",{class:"segmented",role:"group",children:i.map(([a,s])=>e("button",{type:"button",class:n===a?"active":"","aria-pressed":n===a,onClick:()=>t(a),children:s},a))})}function Mn({title:n,detail:t,icon:i="file",action:a}){return e("div",{class:"empty",children:[e("span",{class:"empty-icon",children:e($,{name:i,size:20})}),e("strong",{children:n}),t&&e("p",{children:t}),a]})}function Te({tone:n="info",children:t}){return e("p",{class:`note ${n}`,children:[e($,{name:n==="info"?"shield":"alert",size:14}),t]})}function Xr({head:n,children:t,class:i}){return e("div",{class:`table-wrap ${i??""}`,children:e("table",{class:"table",children:[e("thead",{children:e("tr",{children:n})}),e("tbody",{children:t})]})})}function Za({value:n,onInput:t,placeholder:i}){return e(en,{class:"mono-input",rows:5,value:n.join(`
|
|
2
|
+
`),placeholder:i,onInput:a=>t(a.currentTarget.value.split(`
|
|
3
|
+
`).map(s=>s.trim()).filter(Boolean))})}function Ye(n){const t=new Date(n);return Number.isNaN(t.getTime())?n:t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function In(n){return n.split(",").map(t=>t.trim()).filter(Boolean)}function _o(n){return Object.entries(n).map(([t,i])=>`${t} = ${i}`).join(`
|
|
4
|
+
`)}function So(n){const t={};for(const i of n.split(`
|
|
5
|
+
`)){const[a,...s]=i.split("=");a?.trim()&&s.join("=").trim()&&(t[a.trim()]=s.join("=").trim())}return t}class Qa extends Wn{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t){console.error("Doxloop control center rendering error",t)}render(){if(!this.state.error)return this.props.children;const t=this.state.error.message||String(this.state.error);return e("div",{class:"page",children:e("section",{class:"panel error-boundary",role:"alert",children:e("div",{class:"panel-body",children:[e("span",{class:"error-boundary-icon",children:e($,{name:"alert",size:22})}),e("h2",{children:"This screen could not be shown"}),e("p",{children:"Doxloop hit an unexpected error while drawing this page. Your documentation and any running job are unaffected."}),e("pre",{class:"error-boundary-detail",children:t}),e("div",{class:"form-actions",children:[e(_,{onClick:()=>{this.setState({error:null}),this.props.onReset?.()},children:"Try again"}),e(_,{tone:"primary",onClick:()=>{history.replaceState({},"","/overview"),location.reload()},children:"Reload the control center"})]})]})})})}}function es({url:n,onUrl:t,inspection:i,onInspection:a,error:s,onError:o}){const[l,c]=p(!1),d=Re(),m=i?.status==="running";ae(()=>{if(!i||i.status!=="running")return;let v=!0;const h=async()=>{try{const y=await _e(`/api/docs-site/inspect/${encodeURIComponent(i.id)}`);if(!v)return;a(y),y.status==="running"&&(d.current=setTimeout(()=>{h()},1500))}catch(y){if(!v)return;a({...i,status:"failed",error:y instanceof Error?y.message:String(y)})}};return d.current=setTimeout(()=>{h()},1200),()=>{v=!1,d.current&&clearTimeout(d.current)}},[i?.id,i?.status]);const r=async()=>{if(!(!n.trim()||l)){c(!0),o?.("");try{a(await K("/api/docs-site/inspect",{url:n.trim()}))}catch(v){o?.(v instanceof Error?v.message:String(v))}finally{c(!1)}}},g=i?.summary,u=!!(g&&g.pages>0&&g.words/g.pages<20);return e("div",{class:"docs-site-fields",children:[e(U,{label:"Documentation site address",hint:"The public address of the documentation you want rewritten, for example https://docs.example.com or a section such as https://example.com/docs/. Doxloop reads its pages into a read-only snapshot; the site itself is never changed.",children:e("div",{class:"docs-site-url-input",children:[e($,{name:"globe",size:18}),e(re,{value:n,placeholder:"https://docs.example.com","aria-invalid":!!s,disabled:m,onInput:v=>{t(v.currentTarget.value),i&&i.url!==v.currentTarget.value.trim()&&a(void 0)},onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),r())}}),e(_,{tone:g?"secondary":"primary",icon:g?"refresh":"search",busy:l||m,disabled:!n.trim(),onClick:()=>{r()},children:g?"Crawl again":"Crawl site"})]})}),s&&e("p",{class:"field-error",role:"alert",children:s}),m&&e("div",{class:"docs-site-progress",role:"status",children:[e("span",{class:"spinner"}),e("div",{children:[e("strong",{children:"Reading the documentation site…"}),e("small",{children:[i.progress.fetched," page",i.progress.fetched===1?"":"s"," read · ",i.progress.discovered," discovered"]})]})]}),i?.status==="failed"&&e("p",{class:"field-error",role:"alert",children:i.error??"The documentation site could not be read."}),g&&e("div",{class:`docs-site-summary ${u?"thin":""}`,role:"status",children:[e("header",{children:[e("span",{class:"docs-site-summary-icon",children:e($,{name:u?"alert":"check",size:16})}),e("div",{children:[e("strong",{children:u?`${g.pages} page${g.pages===1?"":"s"} found, but almost no text could be read`:`${g.pages} page${g.pages===1?"":"s"} ready to rewrite`}),e("small",{children:[g.words.toLocaleString()," words · ",g.images," images",g.generator?` · built with ${g.generator}`:""," · found through ",g.discovery.length?g.discovery.join(", "):"the entry page"]})]})]}),g.samplePages.length>0&&e("ul",{class:"docs-site-sample-pages",children:[g.samplePages.map(v=>e("li",{children:[e("span",{children:v.title}),e("small",{children:[v.path||"/"," · ",v.words," words"]})]},v.path)),g.pages>g.samplePages.length&&e("li",{class:"docs-site-more",children:["and ",g.pages-g.samplePages.length," more"]})]}),u&&e("p",{class:"docs-site-thin-note",children:"This site builds its pages in the browser, so the crawler saw empty shells. Adding it would give the writers nothing to work from. Try the address of a page that shows text without JavaScript, or leave this source out."}),(g.truncated||g.brokenLinks>0||g.skipped>0||g.warnings.length>0)&&e("ul",{class:"docs-site-notes",children:[g.truncated&&e("li",{children:["The crawl stopped at ",g.pageLimit," pages; ",g.discovered-g.pages," discovered pages were not read."]}),g.brokenLinks>0&&e("li",{children:[g.brokenLinks," internal link",g.brokenLinks===1?"":"s"," on the site point at pages that failed to load. The rewrite will not repeat them."]}),g.skipped>0&&e("li",{children:[g.skipped," URL",g.skipped===1?"":"s"," were skipped (non-HTML content or errors)."]}),g.warnings.filter(v=>!g.truncated||!v.startsWith("Crawl stopped")).map(v=>e("li",{children:v},v))]})]})]})}const $o={codex:[{id:"gpt-5.6-luna",label:"GPT-5.6 Luna",reasoning:["none","low","medium","high","xhigh","max"]},{id:"gpt-5.6-sol",label:"GPT-5.6 Sol",reasoning:["low","medium","high","xhigh"]},{id:"gpt-5.6-terra",label:"GPT-5.6 Terra",reasoning:["low","medium","high","xhigh"]}],claude:[{id:"claude-sonnet-5",label:"Claude Sonnet 5",reasoning:["low","medium","high","xhigh"]},{id:"claude-opus-5",label:"Claude Opus 5",reasoning:["medium","high","xhigh","max"]},{id:"claude-fable-5",label:"Claude Fable 5",reasoning:["low","medium","high"]},{id:"claude-haiku-4-5-20251001",label:"Claude Haiku 4.5",reasoning:["low","medium"]}],gemini:[{id:"gemini-3.1-pro-preview",label:"Gemini 3.1 Pro Preview",reasoning:[]},{id:"gemini-3.6-flash",label:"Gemini 3.6 Flash",reasoning:[]},{id:"gemini-3.5-flash",label:"Gemini 3.5 Flash",reasoning:[]},{id:"gemini-3.5-flash-lite",label:"Gemini 3.5 Flash Lite",reasoning:[]}]};function Pt(n){return n==="codex"||n==="claude"||n==="gemini"?$o[n]:[]}function It(n){return Pt(n)[0]?.id??""}function Ui(n,t){return Pt(n).find(i=>i.id===t)?.reasoning??[]}function Ft(n,t){const i=Ui(n,t);return i.includes("high")?"high":i[0]??""}function Po({initialPath:n="",onImported:t,onCancel:i}){const[a,s]=p("local"),[o,l]=p(n),[c,d]=p(""),[m,r]=p(""),[g,u]=p(""),[v,h]=p(""),[y,P]=p(null),[k,C]=p(""),[w,I]=p(!1),[L,D]=p(""),[E,A]=p(""),[j,W]=p(!1),O=Re(),ue=Re(!0);ae(()=>()=>{ue.current=!1,O.current&&K("/api/projects/mintlify/discard",{id:O.current}).catch(()=>{})},[]);const ge=async()=>{D("browse"),A("");try{const G=await K("/api/projects/browse",{},Gn);G.path&&l(G.path)}catch(G){A(di(G))}finally{D("")}},fe=async()=>{D("inspect"),A("");try{const G=await K("/api/projects/mintlify/inspect",{...a==="local"?{path:o}:{repository:c,branch:m,authMethod:v?"credentials":"automatic",gitSecret:v},subdirectory:g},Gn);if(!ue.current){await K("/api/projects/mintlify/discard",{id:G.id});return}O.current=G.id,P(G),C(G.suggestedDestination),I(!1),h("")}catch(G){A(di(G))}finally{D("")}},ye=async()=>{y&&await K("/api/projects/mintlify/discard",{id:y.id}).catch(()=>{}),O.current=void 0,P(null),A("")},ce=async()=>{if(y){D("convert"),A("");try{await K("/api/projects/mintlify/convert",{id:y.id,destination:k,allowWarnings:w},Gn),O.current=void 0,W(!0)}catch(G){A(di(G))}finally{D("")}}},se=!!(y&&(y.unmapped.length||y.warnings.length));return j?e("div",{class:"import-existing-panel",children:[e(Te,{children:["Converted ",y?.pageCount," ",y?.pageCount===1?"page":"pages"," to Doxbrix. Your documentation is ready in ",k,"."]}),e("p",{children:"Open Pages to review the converted site and preview it. Connect your product code or API specification in Sources, request changes in Update, then publish from Deploy → Doxbrix."}),e("p",{children:"The conversion report is saved with the project. Imported pages start as unverified until their claims are checked against your product sources."}),e(_,{tone:"primary",onClick:()=>{t().catch(G=>A(di(G)))},children:"Open documentation"}),E&&e(Te,{tone:"bad",children:E})]}):e("div",{class:"import-existing-panel mintlify-import-panel",children:[e("p",{children:"Convert your Mintlify site into a new Doxbrix project, ready to edit and deploy with Doxloop. The original project stays in place."}),y?e(ie,{children:[e("div",{class:"import-inspection ok",children:e("div",{children:[e("strong",{children:[y.title," → Doxbrix"]}),e("small",{children:[y.pageCount," ",y.pageCount===1?"page":"pages"," · ",y.assetCount," ",y.assetCount===1?"asset":"assets"," · ",y.spaces.length," navigation ",y.spaces.length===1?"space":"spaces"," · ",y.redirects.length," redirects"]}),e("small",{children:[y.source.repository||y.source.path,y.source.branch?" · "+y.source.branch:"",y.source.subdirectory?" · "+y.source.subdirectory:""]})]})}),e(U,{label:"New Doxbrix project folder",hint:"Choose a new folder outside the original project. Its parent folder must already exist.",children:e(re,{"aria-label":"New Doxbrix project folder",value:k,disabled:!!L,onInput:G=>C(G.currentTarget.value)})}),e("details",{class:"import-page-sample",children:[e("summary",{children:y.pageCount>y.pages.length?"First "+y.pages.length+" converted pages":"Converted pages"}),e("ul",{children:y.pages.map(G=>e("li",{children:e("code",{children:G})},G))})]}),se?e("div",{class:"mintlify-conversion-warnings",children:[e(Te,{tone:"warn",children:"Some content needs review after conversion."}),y.unmapped.length>0&&e("p",{children:["Unsupported constructs: ",y.unmapped.join(", ")]}),y.warnings.length>0&&e("ul",{children:y.warnings.map(G=>e("li",{children:G},G))}),e("label",{children:[e("input",{type:"checkbox",checked:w,disabled:!!L,onChange:G=>I(G.currentTarget.checked)})," I understand these limitations and will review the converted documentation."]})]}):e(Te,{children:"No unsupported constructs were reported by the converter. Review the rendered pages before publishing."})]}):e(ie,{children:[e(Qr,{value:a,onChange:G=>{s(G),A("")},items:[["local","Local folder"],["github","GitHub repository"]]}),e("fieldset",{disabled:!!L,class:"mintlify-import-fields",children:[a==="local"?e(U,{label:"Mintlify project folder",hint:"Choose the documentation folder or its parent repository. A single nested Mintlify site is detected automatically.",children:e("div",{class:"source-folder-input",children:[e(re,{"aria-label":"Mintlify project folder",value:o,placeholder:"/path/to/mintlify-docs",onInput:G=>l(G.currentTarget.value)}),e(_,{icon:"folder",onClick:()=>{ge()},children:"Browse"})]})}):e(ie,{children:[e(U,{label:"GitHub repository",children:e(re,{"aria-label":"GitHub repository",value:c,placeholder:"https://github.com/your-team/docs or your-team/docs",onInput:G=>d(G.currentTarget.value)})}),e(U,{label:"Branch (optional)",hint:"Leave empty to use the repository's default branch.",children:e(re,{"aria-label":"Branch (optional)",value:m,onInput:G=>r(G.currentTarget.value)})}),e("details",{children:[e("summary",{children:"Private repository access"}),e(U,{label:"GitHub access token",hint:"Uses your existing Git credentials by default. A token is held only for this local session.",children:e(re,{"aria-label":"GitHub access token",type:"password",autoComplete:"off",value:v,onInput:G=>h(G.currentTarget.value)})})]})]}),e(U,{label:"Documentation subfolder (optional)",hint:"For repositories with several documentation sites, enter the folder containing docs.json or mint.json.",children:e(re,{"aria-label":"Documentation subfolder (optional)",value:g,placeholder:"e.g. website/docs",onInput:G=>u(G.currentTarget.value)})})]})]}),L&&e("p",{role:"status",children:L==="inspect"?"Reading the project, converting pages, and checking API references…":L==="convert"?"Creating your Doxbrix workspace…":"Choose a folder in the system dialog…"}),E&&e(Te,{tone:"bad",children:E}),e("footer",{class:"import-existing-actions",children:[i&&e(_,{disabled:!!L,onClick:i,children:"Cancel"}),y?e(ie,{children:[e(_,{disabled:!!L,onClick:()=>{ye()},children:"Change source"}),e(_,{tone:"primary",busy:L==="convert",disabled:!!L||!k.trim()||se&&!w,onClick:()=>{ce()},children:"Convert and open Doxbrix project"})]}):e(_,{tone:"primary",busy:L==="inspect",disabled:!!L||!(a==="local"?o.trim():c.trim()),onClick:()=>{fe()},children:"Review conversion"})]})]})}function di(n){return n instanceof Error?n.message:String(n)}function Io(n,t){return(n??[]).filter(i=>i.path!==t).sort((i,a)=>a.lastOpenedAt.localeCompare(i.lastOpenedAt))}function Xa(n){return n.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||n}function ns(n,t){return n?t.find(i=>i.id===n)?.displayName??n:"Unknown generator"}function Ao(n,t){if(n.alreadyProject)return{headline:"Already a Doxloop project",detail:"Open it instead of importing it again.",tone:"bad",canImport:!1};if(!n.generator)return{headline:"No documentation generator recognized",detail:"Choose the generator and the folder that holds the pages if this is a documentation site.",tone:"warn",canImport:!1};const i=ns(n.generator,t),a=n.contentDir?`in ${n.contentDir}/`:"in the folder itself",s=`${n.pageCount} ${n.pageCount===1?"page":"pages"}`;if(n.pageCount===0)return{headline:`${i} site with no pages ${a}`,detail:"Check the content directory before importing.",tone:"warn",canImport:!0};if(!n.generatorInstalled)return{headline:`${i} site · ${s}`,detail:`The ${n.generatorPackage??i} package is not installed in this folder. Import can add it as a development dependency.`,tone:"warn",canImport:!0};const o=n.markers.length?` · detected from ${n.markers.join(", ")}`:"";return{headline:`${i} site · ${s}`,detail:`Pages ${a}${o}. No page will be changed.`,tone:"ok",canImport:!0}}function To({state:n,onSwitched:t,onNewProject:i,onError:a}){const s=n.project,[o,l]=p(!1),[c,d]=p(""),[m,r]=p(n.recentProjects??[]),[g,u]=p(null),[v,h]=p({top:0,left:0}),y=Re(null),P=Re(null);ae(()=>{r(n.recentProjects??[])},[n.recentProjects]),ae(()=>{if(!o)return;const L=E=>{y.current&&!y.current.contains(E.target)&&l(!1)},D=E=>{E.key==="Escape"&&(l(!1),P.current?.focus())};return y.current?.querySelector(".project-switcher-menu button:not(:disabled)")?.focus(),document.addEventListener("mousedown",L),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",L),document.removeEventListener("keydown",D)}},[o]);const k=Io(m,n.root),C=async L=>{d(L);try{await K("/api/projects/open",{path:L}),l(!1),await t()}catch(D){a(Ot(D))}finally{d("")}},w=async L=>{try{const D=await K("/api/projects/forget",{path:L});r(D.recent)}catch(D){a(Ot(D))}},I=async()=>{d("browse");try{const L=await K("/api/projects/browse",{},Gn);if(!L.path)return;const D=await K("/api/projects/inspect",{path:L.path});if(D.alreadyProject){await C(L.path);return}l(!1),u({path:L.path,inspection:D})}catch(L){a(Ot(L))}finally{d("")}};return e("div",{class:"project-switcher",ref:y,children:[e("button",{type:"button",class:"workspace-identity project-switcher-toggle","aria-haspopup":"dialog","aria-expanded":o,"aria-controls":o?"project-switcher-menu":void 0,"aria-label":`Current workspace: ${s.title}. Switch project`,ref:P,onClick:()=>{const L=P.current?.getBoundingClientRect();L&&h({top:L.bottom+6,left:L.left}),l(D=>!D)},children:[e("span",{class:"workspace-identity-mark",children:s.title.slice(0,1).toUpperCase()}),e("span",{class:"workspace-identity-copy",children:[e("strong",{children:s.title}),e("small",{children:n.root?Xa(n.root):"Local workspace"})]}),e($,{name:"chevronUpDown",size:14})]}),o&&e("div",{id:"project-switcher-menu",class:"project-switcher-menu",role:"dialog","aria-label":"Switch project",style:{top:`${v.top}px`,left:`${v.left}px`},children:[e("div",{class:"project-switcher-current",children:[e("small",{children:"Open now"}),e("strong",{children:s.title}),e("span",{title:n.root,children:n.root})]}),e("div",{class:"project-switcher-section",role:"group","aria-label":"Recent projects",children:[e("small",{"aria-hidden":"true",children:"Recent"}),k.length===0&&e("p",{class:"project-switcher-empty",children:"No other projects opened yet."}),k.map(L=>e("div",{class:`project-recent-row ${L.missing?"missing":""}`,children:[e("button",{type:"button",disabled:!!c||L.missing,title:L.path,onClick:()=>{C(L.path)},children:[e("span",{class:"project-recent-mark",children:L.title.slice(0,1).toUpperCase()}),e("span",{class:"project-recent-copy",children:[e("strong",{children:L.title}),e("small",{children:L.missing?"Folder no longer has a Doxloop project":`${L.generator} · ${Xa(L.path)}`})]}),c===L.path&&e("span",{class:"spinner"})]}),e("button",{type:"button",class:"project-recent-forget","aria-label":`Remove ${L.title} from recent projects`,title:"Remove from recent",onClick:()=>{w(L.path)},children:e($,{name:"close",size:13})})]},L.path))]}),e("div",{class:"project-switcher-actions",role:"group","aria-label":"Other projects",children:[e("button",{type:"button",disabled:!!c,onClick:()=>{I()},children:[e($,{name:"folder",size:16}),e("span",{children:[e("strong",{children:"Open folder…"}),e("small",{children:"A Doxloop project, or existing docs to import"})]}),c==="browse"&&e("span",{class:"spinner"})]}),e("button",{type:"button",disabled:!!c,onClick:()=>{l(!1),u({path:""})},children:[e($,{name:"publish",size:16}),e("span",{children:[e("strong",{children:"Import existing documentation…"}),e("small",{children:"Keep your generator, or convert Mintlify to Doxbrix"})]})]}),e("button",{type:"button",disabled:!!c,onClick:()=>{l(!1),i()},children:[e($,{name:"plus",size:16}),e("span",{children:[e("strong",{children:"New documentation project"}),e("small",{children:"Open the setup wizard"})]})]})]})]}),g&&e("div",{class:"proposal-ready-scrim project-dialog-scrim",role:"presentation",children:e("section",{class:"project-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"import-project-title",children:[e("button",{class:"proposal-ready-close",type:"button","aria-label":"Close",onClick:()=>u(null),children:e($,{name:"close",size:16})}),e("header",{children:[e("span",{class:"proposal-ready-icon",children:e($,{name:"publish",size:22})}),e("div",{children:[e("h2",{id:"import-project-title",children:"Import existing documentation"}),e("p",{children:"Keep a supported documentation site in its native format, or convert a Mintlify project from a local folder or GitHub to Doxbrix."})]})]}),e(ts,{initialPath:g.path,initialInspection:g.inspection,onCancel:()=>u(null),onImported:async()=>{u(null),await t()}})]})})]})}function ts(n){const[t,i]=p(n.initialInspection?.conversion==="mintlify"?"mintlify":"native"),[a,s]=p(n.initialPath??"");return e("div",{children:[e(Qr,{value:t,onChange:i,items:[["native","Keep existing generator"],["mintlify","Mintlify to Doxbrix"]]}),t==="mintlify"?e(Po,{initialPath:a,onImported:n.onImported,onCancel:n.onCancel}):e(Do,{...n,onMintlify:o=>{s(o),i("mintlify")}})]})}function Do({initialPath:n="",initialInspection:t,onImported:i,onCancel:a,onMintlify:s}){const[o,l]=p(n),[c,d]=p(t),[m,r]=p([]),[g,u]=p(t?.generator??""),[v,h]=p(t?.contentDir??""),[y,P]=p(t?.title??""),[k,C]=p(!0),[w,I]=p(!1),[L,D]=p(!1),[E,A]=p(!1),[j,W]=p(""),O=Re(t?`${n}|${t.generator??""}|${t.contentDir??""}`:"");ae(()=>{_e("/api/projects").then(H=>r(H.generators??[])).catch(()=>{})},[]),ae(()=>{c?.conversion==="mintlify"&&s(o)},[c]);const ue=async(H={})=>{const N=o.trim();if(!N)return;const oe=`${N}|${H.generator??""}|${H.contentDir??""}`;if(O.current!==oe){O.current=oe,I(!0),W("");try{const Ce=await K("/api/projects/inspect",{path:N,...H});d(Ce),u(Ce.generator??H.generator??""),h(Ce.contentDir??H.contentDir??""),P(ee=>ee.trim()?ee:Ce.title)}catch(Ce){d(void 0),W(Ot(Ce))}finally{I(!1)}}},ge=async()=>{D(!0),W("");try{const H=await K("/api/projects/browse",{},Gn);if(H.path){l(H.path),O.current="",P("");const N=await K("/api/projects/inspect",{path:H.path});O.current=`${H.path}|${N.generator??""}|${N.contentDir??""}`,d(N),u(N.generator??""),h(N.contentDir??""),P(N.title)}}catch(H){W(Ot(H))}finally{D(!1)}},fe=H=>{u(H),H&&ue({generator:H,...v?{contentDir:v}:{}})},ye=()=>{ue({...g?{generator:g}:{},contentDir:v})},ce=async()=>{A(!0),W("");try{await K("/api/projects/import",{path:o.trim(),...g?{generator:g}:{},contentDir:v,...y.trim()?{title:y.trim()}:{},installGenerator:k&&c?!c.generatorInstalled:!1},Gn),await i()}catch(H){W(Ot(H))}finally{A(!1)}},se=c?Ao(c,m):void 0,G=!!(c&&se?.canImport&&g&&o.trim())&&!w&&!E;return e("div",{class:"import-existing-panel",children:[e(U,{label:"Documentation folder",hint:"The folder that holds the site's configuration, for example where mkdocs.yml or docusaurus.config.js lives.",children:e("div",{class:"source-folder-input",children:[e(re,{value:o,placeholder:"/path/to/your/docs-site",onInput:H=>{l(H.currentTarget.value),d(void 0)},onBlur:()=>{ue()},onKeyDown:H=>{H.key==="Enter"&&(H.preventDefault(),ue())}}),e(_,{icon:"folder",busy:L,onClick:()=>{ge()},children:"Browse"}),e(_,{busy:w,disabled:!o.trim(),onClick:()=>{ue()},children:"Check"})]})}),se&&e("div",{class:`import-inspection ${se.tone}`,children:[e("span",{children:e($,{name:se.tone==="ok"?"check":"alert",size:16})}),e("div",{children:[e("strong",{children:se.headline}),e("small",{children:se.detail})]})]}),c&&!c.alreadyProject&&e(ie,{children:[e("div",{class:"import-existing-grid",children:[e(U,{label:"Generator",hint:c.generator?`Detected ${ns(c.generator,m)}.`:"Not detected. Choose the site generator.",children:e(Fe,{value:g,onChange:H=>fe(H.currentTarget.value),children:[e("option",{value:"",children:"Choose a generator"}),(m.length?m:c.detection.candidates.map(H=>({id:H.generator,displayName:H.generator,installed:!0}))).map(H=>e("option",{value:H.id,children:[H.displayName,c.detection.candidates.some(N=>N.generator===H.id)?" · detected":""]},H.id))]})}),e(U,{label:"Content directory",hint:g==="doxbrix"?"Leave empty when the pages are in the folder itself.":"The folder inside the site that holds the pages.",children:e("div",{class:"source-folder-input",children:[e(re,{value:v,placeholder:g==="doxbrix"?"(folder itself)":"docs",onInput:H=>h(H.currentTarget.value),onBlur:ye,onKeyDown:H=>{H.key==="Enter"&&(H.preventDefault(),ye())}}),e(_,{busy:w,onClick:ye,children:"Re-check"})]})})]}),e(U,{label:"Documentation title",children:e(re,{value:y,onInput:H=>P(H.currentTarget.value)})}),c.pages.length>0&&e("div",{class:"import-page-sample",children:[e("small",{children:c.pageCount>c.pages.length?`First ${c.pages.length} of ${c.pageCount} pages`:`${c.pageCount} ${c.pageCount===1?"page":"pages"}`}),e("ul",{children:c.pages.map(H=>e("li",{children:e("code",{children:H})},H))})]}),g&&!c.generatorInstalled&&c.generatorPackage&&e("label",{class:"import-install-choice",children:[e("input",{type:"checkbox",checked:k,onChange:H=>C(H.currentTarget.checked)}),e("span",{children:[e("strong",{children:["Install ",c.generatorPackage," into this folder"]}),e("small",{children:"Adds a development dependency to the folder's package.json so Doxloop can read and validate the site. Uncheck to install it yourself first."})]})]})]}),j&&e(Te,{tone:"bad",children:j}),e("footer",{class:"import-existing-actions",children:[a&&e(_,{onClick:a,disabled:E,children:"Cancel"}),e(_,{tone:"primary",icon:"check",busy:E,disabled:!G,onClick:()=>{ce()},children:"Import and open"})]})]})}function Ot(n){return n instanceof Error?n.message:String(n)}const er=[["codex","Codex"],["claude","Claude Code"],["gemini","Gemini"]],is=[{id:"screenshots",label:"Application screenshots",hint:"A run-scoped capture browser the agent uses to photograph the product.",support:{codex:{level:"full",note:"Capture browser passed on the command line."},claude:{level:"full",note:"Capture browser passed on the command line."},gemini:{level:"full",note:"Capture browser merged into the workspace .gemini/settings.json and trusted for the run."}}},{id:"sources",label:"External sources",hint:"Reading product folders outside the documentation project without being able to change them.",support:{codex:{level:"full",note:"Read through a sandbox that denies writes."},claude:{level:"full",note:"Read through a sandbox that denies writes."},gemini:{level:"limited",note:"Cannot be denied writes, so an unattended run reads a throwaway copy of each local folder instead of the real checkout."}}},{id:"cost-cap",label:"Spending cap",hint:'Stops an unattended run at the "Maximum Claude spend" amount.',support:{codex:{level:"none",note:"No spending flag; use the minutes and runs-per-day budgets."},claude:{level:"full",note:"Passed as --max-budget-usd; the stop reason names the cap."},gemini:{level:"none",note:"No spending flag; use the minutes and runs-per-day budgets."}}},{id:"live-log",label:"Live activity log",hint:"One-line summaries of what the agent reads, writes, and runs, with stage progress.",support:{codex:{level:"full",note:"Formatted from the codex exec event stream."},claude:{level:"full",note:"Formatted from the stream-json output."},gemini:{level:"full",note:"Formatted from the stream-json output."}}},{id:"sign-in",label:"Sign-in check",hint:"Whether Doxloop can tell before a run that the assistant is signed in.",support:{codex:{level:"full",note:"Asks codex login status."},claude:{level:"full",note:"Asks claude auth status."},gemini:{level:"limited",note:"Looks for an API key or Vertex AI project in the environment, or the Google sign-in token file."}}},{id:"validation",label:"Validation during a run",hint:"Letting the agent run the Doxloop checks on what it wrote.",support:{codex:{level:"full",note:"Commands run inside the workspace sandbox."},claude:{level:"full",note:"Commands run inside the sandbox."},gemini:{level:"limited",note:"Only the doxloop command is pre-approved; other commands need a confirmation an unattended run cannot give."}}}];function nr(n){return is.some(t=>t.support[n].level==="limited")?"Limited":"Full"}const Ro={full:"Yes",limited:"Limited",none:"No"},Mo={full:"check",limited:"alert",none:"close"};function as({selected:n,compact:t=!1}){return e("div",{class:`agent-capabilities${t?" compact":""}`,role:"table","aria-label":"What each coding assistant supports",children:[e("div",{class:"agent-capabilities-head",role:"row",children:[e("span",{role:"columnheader",children:"Capability"}),er.map(([i,a])=>e("span",{role:"columnheader",class:n===i?"selected":"",children:[e("strong",{children:a}),e("small",{class:nr(i).toLowerCase(),children:nr(i)})]},i))]}),is.map(i=>e("div",{class:"agent-capabilities-row",role:"row",children:[e("span",{role:"rowheader",children:[e("strong",{children:i.label}),!t&&e("small",{children:i.hint})]}),er.map(([a])=>{const s=i.support[a];return e("span",{role:"cell",class:`${s.level}${n===a?" selected":""}`,title:s.note,children:[e($,{name:Mo[s.level],size:12}),Ro[s.level],!t&&n===a&&e("small",{children:s.note})]},a)})]},i.id))]})}const tr=["full","supported","basic"],Lo={pass:"check",warning:"alert",fail:"close"};function rs(n){return n?.tierLabel??(n?.tier?n.tier[0].toUpperCase()+n.tier.slice(1):"")}function zo({entry:n}){if(!n?.tier)return null;const t=n.toolchainLabels?.length?n.toolchainLabels.join(", "):"No extra toolchain";return e("small",{class:`generator-tier-label tier-${n.tier}`,title:n.tierDescription,children:[e($,{name:n.tier==="full"?"check":"info",size:12}),rs(n)," tier · ",t]})}function Eo({generators:n,selected:t}){const i=[...n].filter(a=>a.tier).sort((a,s)=>tr.indexOf(a.tier)-tr.indexOf(s.tier));return i.length===0?null:e("div",{class:"generator-tiers",role:"table","aria-label":"Generator support tiers",children:[e("div",{class:"generator-tiers-head",role:"row",children:[e("span",{role:"columnheader",children:"Generator"}),e("span",{role:"columnheader",children:"Tier"}),e("span",{role:"columnheader",children:"Needs"})]}),i.map(a=>e("div",{class:`generator-tiers-row${t===a.id?" selected":""}`,role:"row",children:[e("span",{role:"rowheader",children:e("strong",{children:a.displayName})}),e("span",{role:"cell",class:`tier-${a.tier}`,title:a.tierDescription,children:rs(a)}),e("span",{role:"cell",children:a.toolchainLabels?.length?a.toolchainLabels.join(", "):"Nothing extra"})]},a.id)),e("p",{class:"generator-tiers-legend",children:[e("strong",{children:"Full"})," generators have validated navigation, documented components, and diagrams, and are built in CI.",e("strong",{children:"Supported"})," generators validate nested navigation where the configuration is readable and say so when it is not.",e("strong",{children:"Basic"})," generators scaffold, preview, and build, with navigation checks limited to what the scaffold owns."]})]})}function No({entry:n,result:t,busy:i,onRetry:a}){if(!n||n.id==="doxbrix")return null;const s=t?t.ready?t.checks.some(o=>o.status==="warning")?"warning":"ready":"missing":"pending";return e("section",{class:`setup-generator-preflight ${s}`,"aria-live":"polite",children:[e("header",{children:[e("span",{class:"setup-generator-preflight-icon",children:e($,{name:s==="ready"?"check":s==="pending"?"settings":"alert",size:17})}),e("div",{children:[e("strong",{children:i?`Checking tools for ${n.displayName}…`:t?t.ready?`${n.displayName} tools are ready`:`${n.displayName} needs tools that are not installed`:`Tools for ${n.displayName}`}),e("small",{children:[n.toolchainLabels?.length?`Preview and the strict build need ${n.toolchainLabels.join(" and ")}.`:"No extra toolchain is needed.",!t?.ready&&t?" You can still create the project; install the missing tools before previewing or publishing.":""]})]}),e(_,{size:"sm",busy:i,onClick:a,children:"Check again"})]}),t&&e("ul",{class:"setup-generator-preflight-checks",children:t.checks.map((o,l)=>e("li",{class:o.status,children:[e($,{name:Lo[o.status],size:13}),e("span",{children:[e("strong",{children:o.label}),o.detail&&e("small",{children:o.detail})]})]},l))})]})}const Oo=3,Uo=300,vi=500;function Bo(n){return n.maxPages<vi}function jo(n,t,i=0){const a=n==="starter"?{maxPages:5,maxMinutes:15}:n==="comprehensive"?{maxPages:vi,maxMinutes:120}:{maxPages:vi,maxMinutes:45},s=Math.min(vi,Math.max(a.maxPages,i));return{maxPages:s,maxScreenshots:t?Math.min(Uo,s*Oo):0,maxMinutes:a.maxMinutes}}const Ti="Understand the product, get started, and complete the primary supported workflows.";function oa(n,t){return jo(n,t!=="disabled")}function Fo(n){return`${Bo(n)?`${n.maxPages} pages`:"No page limit"} · ${n.maxScreenshots} screenshots · ${n.maxMinutes} minutes per attempt`}function ss(n){return n==="yes"?"enabled":"disabled"}function os(n,t){const i=t.trim()||"/";try{const s=new URL(n.trim());if(s.href.includes("#")&&(s.hash===""||s.hash.startsWith("#/"))&&!/^[a-z][a-z0-9+.-]*:/i.test(i)){const o=i.startsWith("#")?i.slice(1):i;return s.hash=o.startsWith("/")?o:`/${o}`,s.toString()}}catch{}const a=n.trim().replace(/\/+$/,"");try{return new URL(i,`${a}/`).toString()}catch{return`${a}${i.startsWith("/")?i:`/${i}`}`}}function ls(n){const t=n.applicationBaseUrl?.trim()??"",i=n.applicationStartPath?.trim()??"";if(!t)return"Enter the application URL, or turn off product screenshots for an API or library without screens.";if(!qo(t))return"Enter the full application URL including http:// or https://, for example http://localhost:3000.";if(!i.startsWith("/")||i.startsWith("//"))return"The starting page must be a route that begins with /, for example / or /settings/team."}function qo(n){try{const t=new URL(n);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function Wo(n){const t=n.screenshots!=="disabled",i=t,a=ls(n);return{required:t,started:i,complete:!a,...a?{issue:a}:{}}}function Go(n,t){if(n===1)return t.directory.trim()?t.title.trim()?void 0:"Enter a title for your documentation.":"Enter a workspace name.";if(n===2)return t.sourceDialogOpen?"Finish adding the source, or close the Add source dialog, before continuing.":t.sourceCount===0?"Add at least one source. Doxloop documents what it finds in your sources.":void 0;if(n===3){if(t.agent&&!t.agentInstalled)return`${t.agentLabel} is not installed. Install it, or choose a different coding assistant.`;if(t.agent&&t.agentAuthentication?.status==="unauthenticated")return`${t.agentLabel} is signed out on this computer. ${cs(t.agent)}, or choose a different coding assistant.`;const i=t.reasoning?.trim()??"";return i&&t.reasoningLevels?.length&&!t.reasoningLevels.includes(i)?`"${i}" is not a reasoning level for this model. Choose one of: ${t.reasoningLevels.join(", ")}.`:t.screenshots!=="disabled"?ls(t):void 0}}function cs(n){return n==="claude"?"Open Terminal, run `claude auth login`, then choose Check again":n==="codex"?"Open Terminal, run `codex login`, then choose Check again":"Sign in to Gemini (run `gemini` once in Terminal, or set GEMINI_API_KEY), then choose Check again"}const ir=["codex","claude","gemini"];function Ho(n){const t=[...n??[]].filter(i=>i.executable).sort((i,a)=>ir.indexOf(i.name)-ir.indexOf(a.name));return t.find(i=>i.authentication?.status==="authenticated")?.name??t.find(i=>i.authentication?.status!=="unauthenticated")?.name??t[0]?.name??"codex"}const Vo=["applicationPassword","gitSecret"];function Ko(n,t,i){const a={...n};for(const s of Vo)s in a&&(a[s]="");return{form:a,sources:t.map(s=>({...s,..."gitSecret"in s?{gitSecret:""}:{}})),step:i}}function Jo(n){return`doxloop.setup-draft:${n}`}function Yo(n){const t=n.readerOutcome.trim()||Ti,i=n.screenshots!=="disabled"&&n.applicationBaseUrl?.trim()?`
|
|
6
|
+
Application screenshot capture: use ${os(n.applicationBaseUrl,n.applicationStartPath??"/")} as the initial safe capture surface. Infer only evidence-supported, non-destructive visible workflows and propose the meaningful states before capture.${n.applicationSignInSkipped?" The application needs sign-in and the user chose to continue without it: keep signed-in workflows text-only and do not ask for credentials or a test account.":""}`:"";return{mode:"create",scope:n.scope,request:`Primary reader outcome: ${t}
|
|
7
|
+
Research the complete evidence-supported public product surface and propose a coherent ${n.scope} documentation set.${i}`,clarificationMode:n.clarificationMode,...n.agent?{agent:n.agent}:{},...n.model?{model:n.model}:{},...n.agent==="codex"&&n.reasoning?{reasoning:n.reasoning}:{},...n.agent==="claude"&&n.effort?{effort:n.effort}:{},screenshots:n.screenshots}}function Zo(n,t){try{const i=new URL(n),a=n.trim().slice(i.origin.length).replace(/\/+$/,"");if(a&&a!=="/"&&t.startsWith(a)){const s=t.slice(a.length);return s.startsWith("/")?s:`/${s}`}}catch{}return t}function la(n){const t=n.toLowerCase();return t.includes("gitlab.com")||t.includes("gitlab.")?"gitlab":t.includes("github.com")||t.includes("github.")?"github":"git"}function Qo(n){try{const t=new URL(n.trim()),i=t.pathname.replace(/\/+$/,"").split("/").filter(Boolean).pop();return i&&!/^(docs?|documentation|help|guide|guides|manual)$/i.test(i)?`${t.hostname} ${i}`:t.hostname}catch{return}}function Xo(n){const t=la(n);return t==="git"?"sources":t}const el=()=>({name:"",sourceKind:"directory",sourceLocation:"git",sourcePath:"",repository:"",branch:"main",subdirectory:"",authMethod:"automatic",gitUsername:"",gitSecret:"",specInput:"file",specContent:""});function nl({state:n,act:t,error:i,onContinue:a,onCancel:s}){const[o,l]=p("new"),c=Jo(n.cwd),[d]=p(()=>ll(c)),m=()=>{const b=Ho(n.agents),V=It(b),we=Ft(b,V);return{directory:"my-product-docs",parentDirectory:"",title:"Product documentation",sourceKind:"directory",sourceLocation:"git",sourceName:"",sourcePath:"",repository:"",branch:"main",subdirectory:"",authMethod:"automatic",gitUsername:"",gitSecret:"",specInput:"file",specContent:"",generator:"doxbrix",agent:b,model:V,reasoning:b==="codex"?we:"",effort:b==="claude"?we:"",screenshots:"enabled",applicationBaseUrl:"",applicationStartPath:"/",applicationSignIn:"no",applicationLoginPath:"",applicationUsername:"",applicationPassword:"",audiences:[],scope:"comprehensive",readerOutcome:"",experienceLevel:"beginner",preferredExamples:"",locale:"en-US",accessibilityTarget:"WCAG 2.2 AA",exclusions:"",terminology:"",designDirection:"",clarificationMode:"review",customInstructions:""}},[r,g]=p(()=>d?{...m(),...d.form}:m()),[u,v]=p(()=>d?.step??1);ae(()=>{scrollTo({top:0})},[u]);const[h,y]=p(()=>d?.sources??[]),[P,k]=p(!!d),[C,w]=p(!1);ae(()=>{if(!C)try{localStorage.setItem(c,JSON.stringify(Ko(r,h,u)))}catch{}},[r,h,u,C]);const I=()=>{try{localStorage.removeItem(c)}catch{}g(m()),y([]),v(1),k(!1)},[L,D]=p("closed"),[E,A]=p("");ae(()=>{if(!E)return;const b=setTimeout(()=>A(""),4e3);return()=>clearTimeout(b)},[E]),ae(()=>{A("")},[u]);const[j,W]=p(""),O=Re(null),[ue,ge]=p(),[fe,ye]=p(!1),[ce,se]=p({directory:"",sourcePath:""}),[G,H]=p(null),N=(b,V)=>H({step:b,message:V}),oe=()=>H(null),[Ce,ee]=p(!1),[Q,x]=p(!1),[B,F]=p(!1),[T,Z]=p([]),[Y,pe]=p([]),[te,M]=p(""),[ne,xe]=p(!1),[Ie,X]=p(!1),[J,Ae]=p(),[Be,ke]=p(!1),[Ke,Je]=p(!1),[q,ze]=p(),[Pe,Ze]=p(""),[nn,Ee]=p(""),z=n.generators,Se=z.find(b=>b.id===r.generator),[tn,R]=p(),[me,Oe]=p(!1),Ge=async b=>{if(!b||b==="doxbrix"){R(void 0);return}Oe(!0);try{const V=await K("/api/setup/generator/preflight",{generator:b});V.generator===b&&R(V)}catch(V){R({generator:b,tier:"basic",ready:!1,checks:[{status:"fail",label:"Tool check failed",detail:lt(V)}]})}finally{Oe(!1)}};ae(()=>{u===3&&Ge(r.generator)},[u,r.generator]);const kn=Pt(r.agent),An=Ui(r.agent,r.model),mn=n.agents?.find(b=>b.name===r.agent),Tn=r.agent?n.jobs.find(b=>b.type==="agent:install"&&b.agent===r.agent&&(b.status==="running"||b.agent===nn)):void 0;r.agent;const on=n.agents?.find(b=>b.name!==r.agent&&b.executable&&b.authentication?.status==="authenticated")?.name,Dn=b=>{const V=It(b),we=Ft(b,V);Ee(""),oe(),g(Xe=>({...Xe,agent:b,model:V,reasoning:b==="codex"?we:"",effort:b==="claude"?we:""}))},[Jn,He]=p(!1),mt=async()=>{He(!0),oe();try{await t(()=>Promise.resolve(null))}finally{He(!1)}},$e=(b,V)=>{g(we=>({...we,[b]:V})),oe(),b==="directory"&&se(we=>({...we,directory:""})),b==="generator"&&R(void 0),(b==="sourcePath"||b==="sourceKind")&&se(we=>({...we,sourcePath:""})),b.startsWith("application")&&(Ae(void 0),Je(!1)),["repository","authMethod","gitUsername","gitSecret","sourceLocation"].includes(b)&&(se(we=>({...we,sourcePath:""})),M(""),pe([]))},de=Wo(r),Ln=de.required,at=de.complete,ln=de.issue,Cn=b=>Go(b,{directory:r.directory,title:r.title,sourceCount:h.length,sourceDialogOpen:L!=="closed",agent:r.agent,agentInstalled:!!mn,agentLabel:ct(r.agent),...mn?.authentication?{agentAuthentication:mn.authentication}:{},reasoning:r.agent==="claude"?r.effort:r.reasoning,reasoningLevels:An,screenshots:r.screenshots,applicationBaseUrl:r.applicationBaseUrl,applicationStartPath:r.applicationStartPath}),cn=()=>({baseUrl:r.applicationBaseUrl,readyPath:r.applicationStartPath,screenshots:{policy:"auto",startPath:r.applicationStartPath},...r.applicationSignIn==="yes"&&r.applicationLoginPath.trim()?{authentication:{loginPath:r.applicationLoginPath.trim()}}:{}}),hn=n.projectFound&&n.root&&n.root.replace(/[\\/][^\\/]+[\\/]?$/,"")||n.cwd,vt=()=>{const b=r.repository.trim();!/^(?:https?:\/\/|git@)\S+\/\S+/.test(b)||te||B||r.authMethod==="credentials"&&(!r.gitUsername.trim()||!r.gitSecret.trim())||qt()},[rt,Yn]=p(!1),zn=r.applicationSignIn==="yes"&&!!(r.applicationUsername.trim()&&r.applicationPassword),[gn,At]=p([]),[Un,En]=p(""),dn=!zn&&!q?.session?gn.find(b=>b.path===Un):void 0,vn=zn||!!dn,bt=rt||r.applicationSignIn==="yes"||!!q?.session||!!q?.signIn.active||J?.status==="authentication-required"||gn.length>0;ae(()=>{const b=r.applicationBaseUrl.trim();if(r.screenshots==="disabled"||!/^https?:\/\/\S+/.test(b)){At([]);return}let V=!0;const we=setTimeout(()=>{K("/api/setup/application/saved-sign-ins",{baseUrl:b}).then(Xe=>{V&&At(Xe.matches)}).catch(()=>{V&&At([])})},400);return()=>{V=!1,clearTimeout(we)}},[r.applicationBaseUrl,r.screenshots]);const Bn=async(b,V)=>{Ze(b),oe();try{ze(await V()),Ae(void 0)}catch(we){N(u,lt(we))}finally{Ze("")}};ae(()=>{if(!q?.signIn.active)return;const b=setInterval(()=>{_e("/api/setup/application/auth").then(V=>ze(V)).catch(()=>{})},2e3);return()=>clearInterval(b)},[q?.signIn.active]);const Nn=async()=>{ke(!0),oe();let b;try{const V={...cn(),hasCredentials:vn};b=await K("/api/setup/application/readiness",V)}catch(V){b={configured:!0,reachable:!1,status:"unreachable",message:lt(V)}}finally{ke(!1)}return Ae(b),b.status==="authentication-required"&&g(V=>({...V,applicationSignIn:"yes",applicationLoginPath:V.applicationLoginPath||(b.signInPath?Zo(V.applicationBaseUrl,b.signInPath):"")})),b},Zn=async()=>{const b=J?.status==="ready"?J:await Nn();return b.status==="authentication-required"&&Ke?{...b,status:"ready"}:b},st=b=>b.status==="authentication-required"?`Your application shows a sign-in page first${b.signInPath?` (${b.signInPath})`:""}. Choose "Sign in with browser" and sign in once, or enter a test account below. You can also choose "Continue without signing in" — then screenshots only show the sign-in pages.`:/^Application URL/.test(b.message)?b.message:`${b.message} Start the application and continue again, or turn off product screenshots.`,Rn=r.sourceKind==="openapi"?"openapi":r.sourceLocation==="git"?"git":"local",be=b=>{if(b==="openapi"){$e("sourceKind",b);return}g(V=>({...V,sourceKind:"directory",sourceLocation:b})),oe(),se(V=>({...V,sourcePath:""})),M("")},Tt=()=>({name:r.sourceName,sourceKind:r.sourceKind,sourceLocation:r.sourceLocation,sourcePath:r.sourcePath,repository:r.repository,branch:r.branch,subdirectory:r.subdirectory,authMethod:r.authMethod,gitUsername:r.gitUsername,gitSecret:r.gitSecret,specInput:r.specInput,specContent:r.specContent,...r.sourceKind==="docs-site"&&ue?.status==="completed"?{inspectionId:ue.id,docsSite:ue.summary}:{}}),f=async(b,V=Tt())=>{try{const we=await K("/api/setup/validate",{directory:r.directory,parentDirectory:r.parentDirectory||hn,...b?{...V}:{}});return se({directory:we.directoryError??"",sourcePath:we.sourcePathError??""}),we}catch(we){N(u,lt(we));return}},ve=async()=>{ee(!0);try{const b=Cn(u);if(b){N(u,b);return}if(u===1){const V=await f(!1);if(!V||V.directoryError)return}if(u===2)for(const V of h){if(V.sourceKind==="openapi"&&V.specInput==="file"&&V.specContent.trim())continue;const we=await f(!0,V);if(!we)return;if(we.directoryError){v(1);return}if(we.sourcePathError){N(2,`${V.name}: ${we.sourcePathError}`);return}}if(u===3&&Ln){const V=await Zn();if(V.status!=="ready"){N(3,st(V));return}}oe(),v(V=>V+1)}finally{ee(!1)}},Ne=async()=>{if(!r.agent)return;Ee(r.agent);const b=await t(()=>K("/api/agent/install",{agent:r.agent}));(!b||!("status"in b))&&Ee("")},je=()=>{const b=el();g(V=>({...V,sourceKind:b.sourceKind,sourceLocation:b.sourceLocation,sourceName:b.name,sourcePath:b.sourcePath,repository:b.repository,branch:b.branch,subdirectory:b.subdirectory,authMethod:b.authMethod,gitUsername:b.gitUsername,gitSecret:b.gitSecret,specInput:b.specInput,specContent:b.specContent})),M(""),Z([]),pe([]),se(V=>({...V,sourcePath:""})),W(""),ge(void 0)},Ve=async b=>{b&&($e("specContent",await b.text()),$e("sourcePath",""),$e("specInput","file"),W(b.name))},De=async()=>{const b=Tt(),V=b.sourceKind==="openapi"?b.sourcePath||"OpenAPI Specification":b.sourceLocation==="git"?b.repository:b.sourcePath,we=b.sourceKind==="openapi"?"OpenAPI Specification":b.sourceKind==="docs-site"?"Existing Documentation":b.sourceLocation==="git"?"Git Repository":"Local Repository",Sn=(b.sourceKind==="docs-site"?Qo(b.sourcePath):V.replace(/[?#].*$/,"").replace(/[\\/]+$/,"").split(/[\\/]/).pop()?.replace(/\.git$/i,"").replace(/\.(json|ya?ml)$/i,""))||we,Ct=h.filter(yn=>yn.name===Sn||yn.name.startsWith(`${Sn} `)).length,pn={...b,name:Ct?`${Sn} ${Ct+1}`:Sn};ye(!0);try{const yn=await f(!0,pn);if(!yn||yn.directoryError||yn.sourcePathError)return;const si={...yn.sourcePath&&pn.sourceLocation==="local"?{...pn,sourcePath:yn.sourcePath}:pn,...yn.openapiSummary?{openapiSummary:yn.openapiSummary}:{}};y(Wi=>[...Wi,si]),je(),D("closed"),A(si.name)}finally{ye(!1)}},[yt,Dt]=p(!1),xn=async()=>{Dt(!0),oe();try{const b=await K("/api/projects/browse",{},Gn);b.path&&$e("parentDirectory",b.path)}catch(b){N(1,lt(b))}finally{Dt(!1)}},ii=async()=>{x(!0),oe();try{const b=await K("/api/setup/browse-directory",{},Gn);b.path&&$e("sourcePath",b.path)}catch(b){se(V=>({...V,sourcePath:lt(b)}))}finally{x(!1)}},qt=async()=>{F(!0),oe(),se(b=>({...b,sourcePath:""}));try{const b=await K("/api/setup/git/test",{repository:r.repository,branch:r.branch,authMethod:r.authMethod,gitUsername:r.gitUsername,gitSecret:r.gitSecret});g(V=>({...V,repository:b.repository,branch:b.branch})),Z(b.branches),await jn(b.repository,b.branch),M(b.head)}catch(b){M(""),pe([]),se(V=>({...V,sourcePath:lt(b)}))}finally{F(!1)}},jn=async(b,V)=>{xe(!0);try{const we=await K("/api/setup/git/folders",{...r,repository:b,branch:V,subdirectory:""});pe(we.directories)}finally{xe(!1)}},Fi=async b=>{g(V=>({...V,branch:b,subdirectory:""})),oe(),se(V=>({...V,sourcePath:""}));try{await jn(r.repository,b)}catch(V){se(we=>({...we,sourcePath:lt(V)}))}},ot=()=>{M(""),Z([]),pe([]),se(b=>({...b,sourcePath:""}))},Qn=async()=>{X(!0),oe();try{for(const V of[1,2,3]){const we=Cn(V);if(we){v(V),N(V,we);return}}if(Ln){const V=await Zn();if(V.status!=="ready"){v(3),N(3,st(V));return}}if(!C){const V=await f(!1);if(!V)return;if(V.directoryError){v(1);return}for(const we of h){if(we.sourceKind==="openapi"&&we.specInput==="file"&&we.specContent.trim())continue;const Xe=await f(!0,we);if(!Xe)return;if(Xe.sourcePathError){v(2),N(2,`${we.name}: ${Xe.sourcePathError}`);return}}}if(!C){if(!await t(()=>K("/api/project",{...r,parentDirectory:r.parentDirectory||hn,sources:h,...r.screenshots!=="disabled"&&r.applicationBaseUrl.trim()?{application:{baseUrl:r.applicationBaseUrl.trim(),readyPath:r.applicationStartPath.trim(),screenshots:{policy:"auto",highlight:!0,viewport:{width:1440,height:900},startPath:r.applicationStartPath.trim()},...r.applicationSignIn==="yes"&&r.applicationLoginPath.trim()?{authentication:{loginPath:r.applicationLoginPath.trim()}}:{}},...zn?{applicationCredentials:{username:r.applicationUsername.trim(),password:r.applicationPassword}}:{},...dn?{applicationSignInFrom:dn.path}:{}}:{},documentation:{audiences:r.audiences,primaryAudience:r.audiences.join(", "),priorityOutcomes:[r.readerOutcome.trim()||Ti],experienceLevel:r.experienceLevel,preferredExamples:rr(r.preferredExamples),locale:r.locale.trim()||"en-US",accessibilityTarget:r.accessibilityTarget.trim()||"WCAG 2.2 AA",exclusions:rr(r.exclusions),terminology:sl(r.terminology),designDirection:r.designDirection.trim(),customInstructions:r.customInstructions}}),void 0,!1)){N(5,"The documentation workspace could not be created. Review the configuration and try again.");return}w(!0);try{localStorage.removeItem(c)}catch{}}if(!await t(()=>K("/api/plans",Yo({...r,applicationSignInSkipped:Ke&&r.applicationSignIn==="yes"&&!q?.session&&!vn})),void 0,!1)){N(5,"The documentation plan could not be started. Review the configuration and try again.");return}await a("authoring")}finally{X(!1)}},_n=r.sourceLocation==="local"?"local":r.authMethod==="credentials"?"private":"public",Rt=b=>{if(b==="local"){be("local");return}be("git"),$e("authMethod",b==="private"?"credentials":"automatic"),ot()},fn=b=>{je(),g(V=>({...V,sourceKind:b,sourceLocation:"git"})),oe()},Wt=()=>{je(),g(b=>({...b,sourceKind:"directory",sourceLocation:"git"})),D("type")},Xn=(b,V)=>{g(we=>{const Xe={...we,[b]:V},Sn=!!(Xe.applicationLoginPath.trim()||Xe.applicationUsername.trim()||Xe.applicationPassword);return{...Xe,applicationSignIn:Sn||q?.session?"yes":"no"}}),oe(),Ae(void 0),Je(!1)},wt=()=>{g(b=>({...b,applicationSignIn:"yes"})),Bn("start",()=>K("/api/setup/application/sign-in",{...cn(),...r.applicationLoginPath.trim()?{authentication:{loginPath:r.applicationLoginPath.trim()}}:{}}))},qi=J?.status==="ready"?"Reachable":J?.status==="authentication-required"?"Sign-in required":"Unreachable",ai=J?.status==="ready"?"good":J?.status==="authentication-required"?"warn":"bad",ri=r.sourceKind==="openapi"?"Add OpenAPI spec":r.sourceKind==="docs-site"?"Add existing documentation":"Add source code",Mt={1:o==="new"?["Name your documentation","Where the workspace lives and what readers will call it."]:["Use an existing documentation folder","Point Doxloop at a documentation site you already have. Nothing in it is changed."],2:["Connect your content","Doxloop reads code, specs and live docs sites. Add at least one."],3:["Choose your coding agent","Doxloop drives the assistant you already pay for. No extra API key."],4:["Guide the writing","Tell the planner who reads this and how deep to go."],5:["Review and create your plan",""]},[bn,un]=Mt[u]??Mt[1],Lt=r.agent==="claude"?r.effort:r.reasoning,kt=r.screenshots!=="disabled",et=b=>b.sourceKind==="openapi"?["OpenAPI",b.openapiSummary?`${b.openapiSummary.title} ${b.openapiSummary.version} · ${b.openapiSummary.operationCount} operations`:b.sourcePath||"Uploaded specification"]:b.sourceKind==="docs-site"?["Docs site",b.docsSite?`${b.docsSite.pages} pages · ${b.docsSite.words.toLocaleString()} words${b.docsSite.generator?` · ${b.docsSite.generator}`:""}`:b.sourcePath]:b.sourceLocation==="git"?[la(b.repository)==="github"?"GitHub":la(b.repository)==="gitlab"?"GitLab":"Git",`${b.branch}${b.subdirectory?` / ${b.subdirectory}`:""}`]:["Local folder",b.sourcePath],zt=b=>b.sourceKind==="openapi"?"braces":b.sourceKind==="docs-site"?"globe":b.sourceLocation==="git"?Xo(b.repository):"folder";return e("div",{class:"setup setup-wizard",children:[e("header",{class:"wizard-bar",children:[e("div",{class:"wizard-brand",children:[e("span",{class:"wizard-mark","aria-hidden":"true",children:"D"}),e("span",{class:"wizard-wordmark",children:"Doxloop"}),e("i",{class:"wizard-bar-divider","aria-hidden":"true"}),e("span",{class:"wizard-context",children:"Set up documentation"})]}),e("nav",{class:"wizard-stepper","aria-label":"Setup navigation",children:tl.map((b,V)=>{const we=V+1,Xe=we<u?"done":we===u?"current":"upcoming";return e(ie,{children:[V>0&&e("i",{class:`wizard-connector ${we<=u?"done":""}`,"aria-hidden":"true"}),e("button",{type:"button",class:`wizard-step ${Xe}`,"aria-label":`Step ${we}: ${b}`,"aria-current":we===u?"step":void 0,disabled:Ie||we>u,onClick:()=>v(we),children:[e("span",{class:"wizard-step-mark",children:we<u?e($,{name:"check",size:12}):we}),e("span",{class:"wizard-step-label",children:b})]})]},b)})}),e("div",{class:"wizard-bar-actions",children:s&&e(_,{tone:"ghost",class:"setup-cancel-button",title:"Your answers are kept as a draft",onClick:s,children:"Save and exit"})})]}),e("div",{class:"wizard-body",children:e("div",{class:"wizard-column",children:[P&&e("div",{class:"setup-draft-note",role:"status",children:[e("span",{children:"Restored your unfinished setup. Re-enter any passwords."}),e("span",{children:[e(_,{size:"sm",tone:"ghost",onClick:()=>k(!1),children:"Dismiss"}),e(_,{size:"sm",onClick:I,children:"Start over"})]})]}),e("div",{class:"wizard-heading",children:[e("span",{class:"kicker",children:["Step ",u," of 5"]}),e("h1",{children:bn}),un&&e("p",{children:un})]}),u===1&&e(ie,{children:[e("div",{class:"wizard-group",children:[e("span",{class:"field-label",children:"How do you want to start?"}),e("div",{class:"radio-rows",role:"radiogroup","aria-label":"How to start",children:[e("button",{type:"button",role:"radio","aria-checked":o==="new",class:o==="new"?"selected":"",onClick:()=>{l("new"),oe()},children:e("span",{children:[e("strong",{children:"Start new"}),e("small",{children:"Create a fresh documentation site from your sources."})]})}),e("button",{type:"button",role:"radio","aria-checked":o==="existing",class:o==="existing"?"selected":"",onClick:()=>{l("existing"),oe()},children:e("span",{children:[e("strong",{children:"Use an existing documentation folder"}),e("small",{children:"Keep your generator, or convert Mintlify."})]})})]})]}),o==="existing"&&e("div",{class:"wizard-panel setup-import-existing",children:e(ts,{onImported:()=>a("pages")})}),o==="new"&&e(ie,{children:[e(U,{label:"Location",hint:"The folder the new workspace is created in. Keep it outside your product source, usually the parent folder of the checkout.",children:e("div",{class:"wizard-addon-row",children:[e(re,{class:"mono-input",value:r.parentDirectory||hn,onInput:b=>$e("parentDirectory",b.currentTarget.value)}),e(_,{icon:"folder",busy:yt,onClick:()=>{xn()},children:"Browse"})]})}),e(U,{label:"Workspace name",hint:"The folder your docs will live in.",children:[e(sr,{value:r.directory,valid:!!r.directory.trim()&&!ce.directory,invalid:!!ce.directory,onInput:b=>$e("directory",b)}),ce.directory&&e("small",{class:"field-error",children:ce.directory})]}),e(U,{label:"Documentation title",hint:"The title readers will see.",children:e(sr,{value:r.title,valid:!!r.title.trim(),onInput:b=>$e("title",b)})})]})]}),u===2&&e(ie,{children:[e("div",{class:"wizard-source-list","aria-label":"Connected sources",children:[h.map((b,V)=>{const[we,Xe]=et(b);return e("div",{class:"wizard-source-row",children:[e("span",{class:"wizard-source-icon",children:e($,{name:zt(b),size:16})}),e("div",{class:"wizard-source-copy",children:[e("strong",{children:b.name}),e("span",{class:"wizard-source-meta",children:[e("span",{children:we}),e("span",{children:Xe})]})]}),e(Me,{tone:"good",children:"Connected"}),e("button",{type:"button",class:"wizard-icon-button","aria-label":`Delete ${b.name}`,title:"Delete source",onClick:()=>y(Sn=>Sn.filter((Ct,pn)=>pn!==V)),children:e($,{name:"trash",size:16})})]},`${b.name}-${V}`)}),e("button",{type:"button",class:"wizard-source-add",onClick:Wt,children:[e($,{name:"plus",size:16}),e("span",{children:h.length?"Add another source":"Add source"})]})]}),e(Te,{children:"Private repositories need a personal access token. It is stored in your keychain, never in the project."}),E&&e("div",{class:"source-added-success",role:"status",children:[e("span",{children:e($,{name:"check",size:16})}),e("div",{children:[e("strong",{children:"Source added"}),e("small",{children:[E," is connected and ready."]})]}),e("button",{type:"button","aria-label":"Dismiss",onClick:()=>A(""),children:e($,{name:"close",size:13})})]}),L!=="closed"&&e("div",{class:"sources-modal-scrim",onClick:()=>D("closed"),children:e("section",{class:`sources-reference-dialog ${r.sourceKind==="openapi"?"openapi":r.sourceKind==="docs-site"?"docs-site":"source"}`,role:"dialog","aria-modal":"true","aria-labelledby":"setup-source-dialog-title",onClick:b=>b.stopPropagation(),children:[e("header",{children:[e("h2",{id:"setup-source-dialog-title",children:ri}),e("button",{type:"button","aria-label":"Close",onClick:()=>D("closed"),children:e($,{name:"close",size:16})})]}),e("div",{class:"sources-dialog-body",children:[e("div",{class:"wizard-group",children:[e("span",{class:"field-label",children:"What are you adding?"}),e("div",{class:"radio-rows",role:"group","aria-label":"Source type",children:[e("button",{type:"button","aria-pressed":r.sourceKind==="directory","aria-label":"Source code",onClick:()=>fn("directory"),children:e("span",{children:[e("strong",{children:"Source code"}),e("small",{children:"A Git repository or local folder"})]})}),e("button",{type:"button","aria-pressed":r.sourceKind==="openapi","aria-label":"OpenAPI spec",onClick:()=>fn("openapi"),children:e("span",{children:[e("strong",{children:"OpenAPI spec"}),e("small",{children:"From a URL or an uploaded file"})]})}),e("button",{type:"button","aria-pressed":r.sourceKind==="docs-site","aria-label":"Existing documentation: rewrite a live docs site",onClick:()=>fn("docs-site"),children:e("span",{children:[e("strong",{children:"Existing documentation"}),e("small",{children:"Crawl a live docs site to audit and rewrite it"})]})})]})]}),r.sourceKind==="docs-site"?e(es,{url:r.sourcePath,onUrl:b=>{$e("sourcePath",b),se(V=>({...V,sourcePath:""}))},inspection:ue,onInspection:ge,error:ce.sourcePath,onError:b=>se(V=>({...V,sourcePath:b}))}):r.sourceKind==="directory"?e(ie,{children:[e("div",{class:"wizard-group",children:[e("span",{class:"field-label",children:"Where is it?"}),e("div",{class:"radio-rows",role:"group","aria-label":"Source location",children:[e("button",{type:"button","aria-pressed":_n==="public","aria-label":"Public repository",onClick:()=>Rt("public"),children:e("span",{children:[e("strong",{children:"Public repository"}),e("small",{children:"GitHub, GitLab or another Git service"})]})}),e("button",{type:"button","aria-pressed":_n==="private","aria-label":"Private repository",onClick:()=>Rt("private"),children:e("span",{children:[e("strong",{children:"Private repository"}),e("small",{children:"Needs a personal access token"})]})}),e("button",{type:"button","aria-pressed":_n==="local","aria-label":"Local folder",onClick:()=>Rt("local"),children:e("span",{children:[e("strong",{children:"Local folder"}),e("small",{children:"A folder on this computer or network"})]})})]})]}),Rn==="git"?e(ie,{children:[e(U,{label:"Repository URL",hint:"Paste the clone or browser URL of the repository.",children:e("div",{class:"wizard-addon-row",children:[e(re,{class:"mono-input",value:r.repository,placeholder:"https://github.com/your-team/product",onInput:b=>{$e("repository",b.currentTarget.value),ot()},onBlur:vt,onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),vt())}}),e(ol,{connected:!!te,busy:B,disabled:!r.repository.trim()||r.authMethod==="credentials"&&(!r.gitUsername.trim()||!r.gitSecret.trim()),onClick:()=>{qt()}})]})}),r.authMethod==="credentials"&&e(ie,{children:[e(U,{label:"Username",children:e(re,{value:r.gitUsername,autocomplete:"username",onInput:b=>{$e("gitUsername",b.currentTarget.value),ot()}})}),e(U,{label:"Personal access token",hint:"Held in your keychain for this computer only.",children:e(re,{type:"password",value:r.gitSecret,autocomplete:"off",onInput:b=>{$e("gitSecret",b.currentTarget.value),ot()}})})]}),e(U,{label:"Branch",children:e(Fe,{value:r.branch,disabled:!te||B,onChange:b=>{Fi(b.currentTarget.value)},children:T.length?T.map(b=>e("option",{children:b},b)):e("option",{children:B?"Connecting...":"Connect repository first"})})}),e(U,{label:"Folder (optional)",hint:"Document one folder of the repository instead of all of it.",children:e(Fe,{value:r.subdirectory,disabled:!te||ne,onChange:b=>$e("subdirectory",b.currentTarget.value),children:[e("option",{value:"",children:"/"}),Y.map(b=>e("option",{children:b},b))]})})]}):e(U,{label:"Local folder",children:e("div",{class:"wizard-addon-row",children:[e(re,{class:"mono-input",value:r.sourcePath,"aria-invalid":!!ce.sourcePath,onInput:b=>{$e("sourcePath",b.currentTarget.value),se(V=>({...V,sourcePath:""}))}}),e(_,{icon:"folder",busy:Q,onClick:()=>{ii()},children:"Browse"})]})}),ce.sourcePath&&e("p",{class:"field-error",role:"alert",children:ce.sourcePath})]}):e(ie,{children:[e("div",{class:"wizard-group",children:[e("span",{class:"field-label",children:"Format"}),e("div",{class:"radio-rows",role:"group","aria-label":"Specification input",children:[e("button",{type:"button","aria-pressed":r.specInput==="file",onClick:()=>$e("specInput","file"),children:e("span",{children:[e("strong",{children:"Upload file"}),e("small",{children:".yaml, .yml or .json"})]})}),e("button",{type:"button","aria-pressed":r.specInput==="url",onClick:()=>$e("specInput","url"),children:e("span",{children:[e("strong",{children:"From URL"}),e("small",{children:"A public OpenAPI document"})]})})]})]}),r.specInput==="file"?e("div",{class:`openapi-dropzone ${j?"has-file":""}`,onDragOver:b=>b.preventDefault(),onDrop:b=>{b.preventDefault(),Ve(b.dataTransfer?.files[0])},children:[e("input",{ref:O,type:"file",accept:".yaml,.yml,.json,application/json,text/yaml",onChange:b=>{Ve(b.currentTarget.files?.[0])}}),e("span",{children:e($,{name:j?"check":"publish",size:20})}),e("strong",{children:j||"Drop your OpenAPI file here"}),e(_,{size:"sm",onClick:()=>O.current?.click(),children:j?"Choose another file":"Browse file"})]}):e(U,{label:"OpenAPI spec URL",hint:"Public URLs and standard OpenAPI formats are supported.",children:e(re,{class:"mono-input",value:r.sourcePath,placeholder:"https://api.example.com/openapi.json",onInput:b=>{$e("sourcePath",b.currentTarget.value),$e("specContent",""),W("")}})})]})]}),e("footer",{children:[e(_,{tone:"ghost",onClick:()=>D("closed"),children:"Cancel"}),e(_,{tone:"primary",icon:"plus",busy:fe,disabled:r.sourceKind==="docs-site"?ue?.status!=="completed"||ue.url!==r.sourcePath.trim().replace(/#.*$/,"")&&!r.sourcePath.trim():r.sourceKind==="directory"?Rn==="git"?!te||ne:!r.sourcePath.trim():r.specInput==="file"?!r.specContent.trim():!r.sourcePath.trim(),onClick:()=>{De()},children:"Add source"})]})]})})]}),u===3&&e(ie,{children:[e("div",{class:"wizard-group",children:[e("span",{class:"field-label",children:"Coding agent"}),e("div",{class:"radio-rows wizard-agent-rows",role:"radiogroup","aria-label":"Coding agent",children:["claude","codex","gemini"].map(b=>{const V=n.agents?.find(pn=>pn.name===b),we=Pt(b)[0]?.label??"default model",Xe=V?V.authentication?.status==="authenticated"?"signed in":V.authentication?.status==="unauthenticated"?"signed out":"installed":"not installed",Sn=n.jobs.find(pn=>pn.type==="agent:install"&&pn.agent===b&&(pn.status==="running"||pn.agent===nn)),Ct=Sn?.status==="running"||nn===b&&!Sn;return e("label",{class:r.agent===b?"selected":"",children:[e("input",{type:"radio",name:"setup-agent",class:"wizard-radio-input",value:b,checked:r.agent===b,disabled:Tn?.status==="running",onChange:()=>Dn(b)}),e("span",{children:[e("strong",{children:ct(b)}),e("small",{children:[we," · ",Xe]})]}),V?V.authentication?.status==="authenticated"?e(Me,{tone:"good",children:"Ready"}):V.authentication?.status==="unauthenticated"?e(Me,{tone:"warn",children:"Signed out"}):e(Me,{tone:"neutral",children:"Installed"}):e(_,{size:"sm",busy:Ct,onClick:pn=>{pn.preventDefault(),Dn(b),Ee(b),t(()=>K("/api/agent/install",{agent:b})).then(yn=>{(!yn||!("status"in yn))&&Ee("")})},children:"Install"})]},b)})})]}),r.agent&&!mn&&Tn&&e(cl,{job:Tn,onRetry:()=>{Ne()}}),mn?.authentication?.status==="unauthenticated"&&e("div",{class:"wizard-inline-alert",role:"alert",children:[e(Te,{tone:"warn",children:[ct(r.agent)," is signed out on this computer. ",cs(r.agent),".",on?` Or use ${ct(on)}, which is signed in.`:""]}),e("div",{class:"wizard-inline-actions",children:[on&&e(_,{size:"sm",tone:"primary",onClick:()=>Dn(on),children:["Use ",ct(on)]}),e(_,{size:"sm",busy:Jn,onClick:()=>{mt()},children:"Check again"})]})]}),e(U,{label:"Model",hint:r.agent?`Search suggested ${ct(r.agent)} models or enter another model ID.`:"Select a coding agent first.",children:e(it,{value:r.model,options:kn.map(b=>[b.id,b.label]),disabled:!r.agent,placeholder:"Search or enter a model ID",onValueChange:b=>$e("model",b)})}),e(U,{label:r.agent==="claude"?"Effort":"Reasoning",hint:An.length?"Higher levels plan more carefully and take longer. Search suggested levels or enter a custom value.":"Enter a supported value, or leave blank for the default.",children:e(it,{value:Lt,options:An.map(b=>[b,b]),disabled:!r.agent,placeholder:"Search or enter a value",onValueChange:b=>$e(r.agent==="claude"?"effort":"reasoning",b)})}),e("details",{class:"wizard-advanced",children:[e("summary",{children:[e("span",{children:[e("strong",{children:"Advanced"}),e("small",{children:"Documentation generator and what each tool supports"})]}),e($,{name:"chevronDown",size:16})]}),e("div",{class:"wizard-advanced-fields",children:[e(U,{label:"Documentation generator",hint:"Creates and organizes your documentation site.",children:[e(Fe,{value:r.generator,onChange:b=>$e("generator",b.currentTarget.value),children:z.map(b=>e("option",{value:b.id,children:b.displayName}))}),e("span",{class:"wizard-field-badges",children:[r.generator==="doxbrix"&&e("span",{class:"badge teal no-dot",children:"Recommended"}),e(zo,{entry:Se})]})]}),e(No,{entry:Se,result:tn,busy:me,onRetry:()=>{Ge(r.generator)}}),e("details",{class:"agent-capabilities-details setup-generator-tiers",open:!!Se?.tier&&Se?.tier!=="full",children:[e("summary",{children:["What each generator supports",Se?.tier&&Se.tier!=="full"?` · ${Se.displayName} is ${Se.tierLabel??Se.tier}`:""]}),e(Eo,{generators:z,selected:r.generator})]}),e("details",{class:"agent-capabilities-details setup-agent-capabilities",open:r.agent==="gemini",children:[e("summary",{children:["What each assistant supports",r.agent==="gemini"?" · Gemini is limited in some areas":""]}),e(as,{selected:r.agent||void 0})]})]})]}),e("section",{class:"wizard-box setup-capture-profile","aria-label":"Screenshots",children:[e("div",{class:"wizard-box-row",children:[e("span",{class:"wizard-box-title",children:"Add product screenshots"}),e(jt,{checked:kt,label:"Add product screenshots",onChange:b=>{$e("screenshots",ss(b?"yes":"no")),Ae(void 0)}})]}),kt&&e("div",{class:"wizard-box-body",children:[e(U,{label:"Application URL",hint:"The address of your running local, demo, or test application. Doxloop captures the screens your guides describe; anything it cannot reach stays text-only.",children:e("div",{class:"wizard-addon-row",children:[e(re,{class:"mono-input",value:r.applicationBaseUrl,placeholder:"http://localhost:3000",onInput:b=>$e("applicationBaseUrl",b.currentTarget.value)}),e(_,{"aria-label":"Check page",disabled:!at,busy:Be,onClick:()=>{Nn()},children:"Check"})]})}),J&&e("div",{class:`wizard-readiness ${ai}`,children:[e(Me,{tone:ai,children:qi}),e("span",{children:J.message})]}),e(U,{label:"Starting page",hint:"The first application page Doxloop may open. Use / for the home page.",children:e(re,{class:"mono-input",value:r.applicationStartPath,placeholder:"/ or /settings/team",onInput:b=>$e("applicationStartPath",b.currentTarget.value)})}),bt?e(ie,{children:[e(U,{label:"Sign-in route",hint:"Optional. Where the sign-in window opens; leave empty when the app redirects to its sign-in page. Sign in once so screenshots show the signed-in product; the session and test account stay on this computer.",children:e("div",{class:"wizard-addon-row",children:[e(re,{class:"mono-input",value:r.applicationLoginPath,placeholder:"/login",onInput:b=>Xn("applicationLoginPath",b.currentTarget.value)}),e(_,{icon:"globe",disabled:!at||q?.signIn.active,busy:Pe==="start",onClick:wt,children:q?.session?"Sign in again with browser":"Sign in with browser"})]})}),q?.session&&!q.signIn.active&&e("div",{class:"wizard-readiness good",children:[e(Me,{tone:"good",children:"Signed in"}),e("span",{children:"A browser session is saved for screenshots."})]}),!q?.session&&!zn&&gn.length>0&&e("div",{class:"radio-rows wizard-saved-sign-ins",role:"radiogroup","aria-label":"Saved sign-in",children:gn.map(b=>e("button",{type:"button",role:"radio","aria-checked":Un===b.path,class:Un===b.path?"selected":"",onClick:()=>{En(Un===b.path?"":b.path),g(V=>({...V,applicationSignIn:"yes",applicationUsername:V.applicationUsername||b.username||"",applicationLoginPath:V.applicationLoginPath||b.loginPath||""})),Ae(void 0),oe()},children:e("span",{children:[e("strong",{children:["Use the saved sign-in from ",b.title]}),e("small",{children:[b.username,b.session?"browser session":"",b.path.split(/[\\/]/).filter(Boolean).at(-1)].filter(Boolean).join(" · ")})]})},b.path))}),e(U,{label:"Test account username or email",hint:"Optional. For a plain username and password form.",children:e(re,{value:r.applicationUsername,autocomplete:"off",placeholder:"docs-demo@example.com",onInput:b=>Xn("applicationUsername",b.currentTarget.value)})}),e(U,{label:"Test account password",hint:"Typed by the capture browser, never shown to the agent or saved in the project.",children:e(re,{type:"password",value:r.applicationPassword,autocomplete:"new-password",placeholder:dn?"Using the saved sign-in":"Enter a password",onInput:b=>Xn("applicationPassword",b.currentTarget.value)})})]}):e(_,{tone:"link",class:"wizard-signin-open",onClick:()=>Yn(!0),children:"My app needs a sign-in"}),q?.signIn.active&&e("div",{class:"setup-capture-signin-actions",children:[e(Te,{tone:q.signIn.open?"info":"warn",children:e("span",{children:q.signIn.open?e(ie,{children:["Sign in in the Chrome window, then choose ",e("strong",{children:"Save session"}),"."]}):e(ie,{children:["The Chrome window was closed. Choose ",e("strong",{children:"Save session"})," to keep the last signed-in state, or start again."]})})}),e("div",{class:"wizard-inline-actions",children:[e(_,{busy:Pe==="cancel",onClick:()=>{Bn("cancel",()=>K("/api/setup/application/sign-in/cancel"))},children:"Cancel"}),e(_,{tone:"primary",busy:Pe==="finish",onClick:()=>{Bn("finish",()=>K("/api/setup/application/sign-in/finish"))},children:"Save session"})]})]}),J?.status==="authentication-required"&&!Ke&&e("div",{children:e(_,{size:"sm",tone:"ghost",onClick:()=>{Je(!0),oe()},children:"Continue without signing in"})}),Ke&&e("small",{class:"setup-signin-skipped",children:"Continuing without sign-in: screenshots show only pages visible before sign-in."}),ln?e(Te,{children:ln}):null]})]})]}),u===4&&e(al,{audiences:r.audiences,scope:r.scope,readerOutcome:r.readerOutcome,preferences:{experienceLevel:r.experienceLevel,preferredExamples:r.preferredExamples,locale:r.locale,accessibilityTarget:r.accessibilityTarget,exclusions:r.exclusions,terminology:r.terminology,designDirection:r.designDirection,clarificationMode:r.clarificationMode},customInstructions:r.customInstructions,onAudiencesChange:b=>g(V=>({...V,audiences:b})),onScopeChange:b=>g(V=>({...V,scope:b})),onReaderOutcomeChange:b=>g(V=>({...V,readerOutcome:b})),onPreferencesChange:b=>g(V=>({...V,...b})),onInstructionsChange:b=>g(V=>({...V,customInstructions:b}))}),u===5&&e(ie,{children:[e("section",{class:"wizard-panel wizard-summary","aria-label":"Documentation configuration",children:e("div",{class:"vrows",children:[e(xt,{label:"Title",value:`${r.title||"Untitled documentation"} · ${(r.parentDirectory||hn).replace(/[\\/]+$/,"")}/${r.directory}`,onEdit:()=>v(1)}),e(xt,{label:"Sources",value:h.length?h.map(b=>b.name).join(" · "):"No sources yet",onEdit:()=>v(2)}),e(xt,{label:"Agent",value:`${ct(r.agent)} · ${r.model||"default model"}${Lt?` · ${Lt}`:""}${mn?.authentication?.status==="unauthenticated"?" · signed out":""}`,onEdit:()=>v(3)}),e(xt,{label:"Depth",value:`${rl(r.scope)} · ${Fo(oa(r.scope,r.screenshots))}`,onEdit:()=>v(4)}),e(xt,{label:"Screenshots",value:r.screenshots==="disabled"?"Off":`On · ${os(r.applicationBaseUrl,r.applicationStartPath)}${r.applicationSignIn==="yes"?` · ${q?.session?"sign-in saved":dn?`sign-in from ${dn.title}`:vn?"test account":"without sign-in"}`:""}`,onEdit:()=>v(3)}),e(xt,{label:"Audience",value:`${r.audiences.length?r.audiences.join(", "):"Agent decides the audience"}${ar(r.customInstructions).length?` · ${ar(r.customInstructions).join(", ")}`:""}`,onEdit:()=>v(4)}),e(xt,{label:"Reader goal",value:r.readerOutcome.trim()||Ti,onEdit:()=>v(4)})]})}),e("div",{class:"wizard-callout setup-review-ready",children:[e("span",{class:"wizard-callout-icon",children:e($,{name:"lock",size:18})}),e("div",{children:[e("strong",{children:"Nothing is written until you approve the plan."}),e("small",{children:"Planning takes several minutes and produces a plan you can edit before any page is generated."})]})]}),Ie&&h.some(b=>b.sourceLocation==="git")&&e(Te,{children:"Downloading read-only repository snapshots and starting documentation planning…"})]}),G?.step===u&&e(Te,{tone:"bad",children:G.message}),i&&e(Te,{tone:"bad",children:i}),e("footer",{class:"wizard-footer setup-actions",children:[e("span",{children:u>1&&e(_,{tone:"ghost",class:"setup-back-button wizard-back",icon:"arrowRight",disabled:Ie,onClick:()=>v(b=>b-1),children:"Back"})}),u===1&&o==="existing"?e("span",{class:"setup-existing-hint",children:"Import above to open the folder's pages."}):u<5?e(_,{tone:"primary",busy:Ce,disabled:Ie,onClick:()=>{ve()},children:["Continue ",e($,{name:"arrowRight",size:16})]}):e(_,{tone:"primary",class:"wizard-create",icon:"sparkles",busy:Ie,onClick:()=>{Qn()},children:"Create documentation plan"})]})]})})]})}const tl=["Workspace","Sources","Agent","Guidance","Review"];function xt({label:n,value:t,onEdit:i}){return e("div",{class:"vrow",children:[e("span",{class:"vrow-label",children:[n,e("small",{children:t})]}),e("span",{class:"vrow-value",children:e(_,{tone:"link","aria-label":`Edit ${n.toLowerCase()}`,onClick:i,children:"Edit"})})]})}const il=["Developers","API consumers","Administrators","End users","Technical decision-makers"],ds=[["Beginner-friendly","Explain unfamiliar concepts for readers who are new to the product."],["Concise","Keep explanations concise and action-oriented."],["Code-heavy","Prioritize practical code examples where the sources support them."],["Include examples","Include realistic examples for important workflows."]];function ar(n){const t=n.split(`
|
|
8
|
+
`).map(i=>i.trim());return ds.filter(([,i])=>t.includes(i)).map(([i])=>i.toLowerCase())}function al({audiences:n,scope:t,readerOutcome:i,preferences:a,customInstructions:s,onAudiencesChange:o,onScopeChange:l,onReaderOutcomeChange:c,onPreferencesChange:d,onInstructionsChange:m}){const[r,g]=p(""),u=il.filter(k=>k.toLowerCase().includes(r.trim().toLowerCase())&&!n.some(C=>C.toLowerCase()===k.toLowerCase())),v=k=>{const C=k.trim().replace(/,$/,"").trim();if(!C||n.some(w=>w.toLowerCase()===C.toLowerCase())){g("");return}o([...n,C]),g("")},h=k=>{const C=n.some(w=>w.toLowerCase()===k.toLowerCase());o(C?n.filter(w=>w.toLowerCase()!==k.toLowerCase()):[...n,k])},y=s.split(`
|
|
9
|
+
`).map(k=>k.trim()),P=k=>{const C=y.filter(Boolean);m(C.includes(k)?C.filter(w=>w!==k).join(`
|
|
10
|
+
`):[...C,k].join(`
|
|
11
|
+
`))};return e(ie,{children:[e("div",{class:"wizard-group",children:[e("span",{class:"field-label",children:"Documentation depth"}),e("div",{class:"radio-rows",role:"radiogroup","aria-label":"Documentation depth",children:[["starter","Starter","A quickstart and the essentials"],["standard","Standard","Guides for every main workflow, concepts and troubleshooting"],["comprehensive","Comprehensive","Every surface, reference included","Recommended"]].map(([k,C,w,I])=>e("button",{type:"button",role:"radio","aria-checked":t===k,class:t===k?"selected":"",onClick:()=>l(k),children:[e("span",{children:[e("strong",{children:C}),e("small",{children:w})]}),I&&e("span",{class:"badge teal no-dot",children:I})]},k))})]}),e("div",{class:"wizard-group",children:[e("span",{class:"field-label",children:["Who is this documentation for?",e("span",{class:"field-hint",tabIndex:0,role:"img","aria-label":"Optional. Name the readers so the planner can choose the right depth and examples. Press Enter after each audience.","data-hint":"Optional. Name the readers so the planner can choose the right depth and examples. Press Enter after each audience.",children:e($,{name:"info",size:12})})]}),e("div",{class:"audience-picker input",onClick:k=>k.currentTarget.querySelector("input")?.focus(),children:[n.map(k=>e("span",{class:"audience-token",children:[k,e("button",{type:"button","aria-label":`Remove ${k}`,onClick:C=>{C.stopPropagation(),h(k)},children:e($,{name:"close",size:11})})]},k)),e("input",{value:r,"aria-label":"Add an audience",placeholder:n.length?"Add another audience…":"Backend developers evaluating the product for a new app",onInput:k=>g(k.currentTarget.value),onKeyDown:k=>{k.key==="Enter"||k.key===","?(k.preventDefault(),v(k.currentTarget.value)):k.key==="Backspace"&&!k.currentTarget.value&&n.length&&o(n.slice(0,-1))},onBlur:()=>v(r)})]}),u.length>0&&e("div",{class:"wizard-chips","aria-label":"Suggested audiences",children:u.map(k=>e("button",{type:"button",class:`chip ${n.includes(k)?"on":""}`,"aria-pressed":n.includes(k),onMouseDown:C=>C.preventDefault(),onClick:()=>h(k),children:[n.includes(k)&&e($,{name:"check",size:14}),k]},k))})]}),e("div",{class:"wizard-group",children:[e("span",{class:"field-label",children:"Style"}),e("div",{class:"wizard-chips","aria-label":"Suggested writing instructions",children:ds.map(([k,C])=>e("button",{type:"button",class:`chip ${y.includes(C)?"on":""}`,"aria-pressed":y.includes(C),onClick:()=>P(C),children:[y.includes(C)&&e($,{name:"check",size:14}),k]},k))})]}),e("details",{class:"wizard-advanced setup-guidance-advanced",children:[e("summary",{children:[e("span",{children:[e("strong",{children:"Advanced planning preferences"}),e("small",{children:"Reader experience, locale, terminology, exclusions, open-question policy"})]}),e($,{name:"chevronDown",size:16})]}),e("div",{class:"wizard-advanced-fields",children:[e(U,{label:"What should readers be able to do?",hint:"The outcomes the documentation must make possible. Leave it empty to use the default shown.",children:e(re,{value:i,placeholder:Ti,onInput:k=>c(k.currentTarget.value)})}),e(U,{label:"Reader experience",children:e(Fe,{value:a.experienceLevel,onChange:k=>d({experienceLevel:k.currentTarget.value}),children:[e("option",{value:"beginner",children:"Beginner"}),e("option",{value:"intermediate",children:"Intermediate"}),e("option",{value:"advanced",children:"Advanced"}),e("option",{value:"mixed",children:"Mixed experience"})]})}),e(U,{label:"Preferred examples",hint:"Comma-separated languages or tools",children:e(re,{value:a.preferredExamples,placeholder:"TypeScript, curl",onInput:k=>d({preferredExamples:k.currentTarget.value})})}),e(U,{label:"Locale",children:e(re,{value:a.locale,placeholder:"en-US",onInput:k=>d({locale:k.currentTarget.value})})}),e(U,{label:"Accessibility target",children:e(re,{value:a.accessibilityTarget,placeholder:"WCAG 2.2 AA",onInput:k=>d({accessibilityTarget:k.currentTarget.value})})}),e(U,{label:"Terminology",hint:"One term = guidance per line",children:e(en,{rows:3,value:a.terminology,placeholder:"access key = API access token",onInput:k=>d({terminology:k.currentTarget.value})})}),e(U,{label:"Exclusions",hint:"Comma-separated",children:e(en,{rows:3,value:a.exclusions,placeholder:"Internal APIs, unreleased features",onInput:k=>d({exclusions:k.currentTarget.value})})}),e(U,{label:"Design direction",children:e(en,{rows:3,value:a.designDirection,placeholder:"Use the product brand and prioritize a compact developer-focused layout.",onInput:k=>d({designDirection:k.currentTarget.value})})}),e(U,{label:"If the planner has questions",children:e(Fe,{value:a.clarificationMode,onChange:k=>d({clarificationMode:k.currentTarget.value}),children:[e("option",{value:"review",children:"Ask me in the review screen"}),e("option",{value:"defaults",children:"Use recommended defaults when possible"}),e("option",{value:"stop",children:"Stop and wait for explicit answers"})]})}),e(U,{label:"Custom instructions",hint:"Free-form guidance for the writer. Style choices above are kept here as lines.",children:e(en,{rows:5,value:s,placeholder:"For example: Use concise explanations, include TypeScript examples, and add troubleshooting sections.",onInput:k=>m(k.currentTarget.value)})})]})]})]})}function rl(n){return n[0].toUpperCase()+n.slice(1)}function rr(n){return[...new Set(n.split(/[,\n]/).map(t=>t.trim()).filter(Boolean))]}function sl(n){return Object.fromEntries(n.split(`
|
|
12
|
+
`).flatMap(t=>{const i=t.indexOf("=");if(i<=0)return[];const a=t.slice(0,i).trim(),s=t.slice(i+1).trim();return a&&s?[[a,s]]:[]}))}function sr({value:n,valid:t,invalid:i,onInput:a}){return e("div",{class:"validated-setup-input",children:[e(re,{value:n,"aria-invalid":!!i,onInput:s=>a(s.currentTarget.value)}),t&&e($,{name:"check",size:14})]})}function ol({connected:n,busy:t,disabled:i,onClick:a}){const s=n?"Repository connected":t?"Connecting repository":"Connect repository";return e("button",{type:"button",class:`repository-connect-button ${n?"connected":""}`,"aria-label":s,title:s,disabled:i||t||n,onClick:a,children:t?e("span",{class:"repository-connect-spinner"}):e($,{name:n?"check":"link",size:19})})}function ll(n){try{const t=JSON.parse(localStorage.getItem(n)??"null");if(!t||typeof t.form!="object"||!t.form||!Array.isArray(t.sources))return;const i=typeof t.step=="number"&&t.step>=1&&t.step<=5?Math.floor(t.step):1;return i>1||t.sources.length?{form:t.form,sources:t.sources,step:i}:void 0}catch{return}}function lt(n){return n instanceof Error?n.message:String(n)}function ct(n){return n==="claude"?"Claude Code":n==="codex"?"Codex":"Gemini"}function cl({job:n,onRetry:t}){const i=n.agent?ct(n.agent):"Agent";return n.status==="running"?e("div",{class:"agent-install-progress",children:[e("span",{class:"spinner"}),e("span",{children:["Installing ",i,"…"]})]}):n.status==="succeeded"?e("div",{class:"agent-install-progress good",children:[e($,{name:"check",size:14}),e("span",{children:[i," installed"]})]}):e("div",{class:"agent-install-progress bad",children:[e($,{name:"alert",size:14}),e("span",{children:"Installation failed"}),e(_,{size:"sm",onClick:t,children:"Try again"})]})}function us({path:n,proposal:t,onRequest:i}){const[a,s]=p([]),[o,l]=p(""),[c,d]=p(""),[m,r]=p(""),[g,u]=p(!1);ae(()=>{let h=!0;return _e("/api/comments").then(y=>{if(h){if(!Array.isArray(y))throw new Error("Comments could not be loaded. Reload to try again.");s(y)}}).catch(y=>{h&&r(y.message)}),()=>{h=!1}},[n,t?.id]);const v=async h=>{u(!0),r("");try{await h()}catch(y){r(String(y))}finally{u(!1)}};return e("details",{class:"text-editor",children:[e("summary",{children:"Comments and agent requests"}),e("div",{class:"text-editor-body",children:[m&&e("p",{role:"alert",children:m}),a.filter(h=>h.path===n&&h.proposalId===t?.id).map(h=>e("article",{children:[e("small",{children:[Ye(h.createdAt),h.hunkId?` · Hunk ${h.hunkId.slice(0,8)}`:"",h.resolvedAt?" · Resolved":""]}),e("p",{style:{whiteSpace:"pre-wrap"},children:h.text}),!h.resolvedAt&&e("div",{class:"text-editor-actions",children:[e("button",{disabled:g,onClick:()=>{v(()=>i(h.text,h.hunkId))},children:"Ask agent to address"}),e("button",{disabled:g,onClick:()=>{v(async()=>s(await K("/api/comments",{resolveId:h.id})))},children:"Resolve comment"})]})]},h.id)),t&&e("label",{children:["Comment scope",e("select",{value:c,onChange:h=>d(h.currentTarget.value),children:[e("option",{value:"",children:"Whole file"}),t.change.hunks.map((h,y)=>e("option",{value:h.id,children:["Hunk ",y+1]}))]})]}),e("label",{children:["Comment",e("textarea",{"aria-label":"Comment",maxLength:8e3,value:o,onInput:h=>l(h.currentTarget.value)})]}),e("button",{disabled:g||!o.trim(),onClick:()=>{v(async()=>{s(await K("/api/comments",{path:n,text:o,...t?{proposalId:t.id,changeId:t.change.id}:{},...c?{hunkId:c}:{}})),l("")})},children:"Save comment"})]})]})}function dl({paths:n,onChanged:t}){const[i,a]=p("description"),[s,o]=p(""),[l,c]=p(),[d,m]=p(""),[r,g]=p(!1);ae(()=>c(void 0),[n.join("|"),i,s]);const u=async v=>{g(!0);try{await v()}catch(h){m(String(h))}finally{g(!1)}};return e("details",{class:"text-editor",children:[e("summary",{children:["Bulk metadata · ",n.length," selected pages"]}),e("div",{class:"text-editor-body",children:[e("label",{children:["Field",e("select",{value:i,onChange:v=>a(v.currentTarget.value),children:["description","icon","socialImage","canonical"].map(v=>e("option",{children:v}))})]}),e("label",{children:["Value",e("input",{value:s,onInput:v=>o(v.currentTarget.value)})]}),e("p",{children:"Review the selected paths before saving. Empty optional fields are cleared. All pages save together; any conflict stops the entire batch."}),l&&e("ul",{children:l.map(v=>e("li",{children:[v.path,": ",i," → ",s||"(clear)"]}))}),e("p",{role:"status",children:d}),e("button",{disabled:r||!n.length,onClick:()=>{u(async()=>{const v=await Promise.all(n.map(async h=>{const y=await _e(`/api/pages/metadata?path=${encodeURIComponent(h)}`);if(!y.editable)throw new Error(y.reason);return{path:h,fingerprint:y.fingerprint,fields:{[i]:s||null}}}));c(v),m("Review this batch, then save.")})},children:"Preview batch"}),l&&e("button",{disabled:r,onClick:()=>{u(async()=>{await gt("/api/pages/bulk-metadata",{writes:l}),c(void 0),m("Batch saved. Use Recent direct edits to undo it."),await t()})},children:"Save metadata batch"})]})]})}function ul({onChanged:n}){const[t,i]=p(),[a,s]=p(!1),[o,l]=p(""),[c,d]=p(!1),m=async r=>{d(!0);try{await r()}catch(g){l(String(g))}finally{d(!1)}};return e("details",{class:"text-editor",children:[e("summary",{children:"Audit existing documentation and reader verification"}),e("div",{class:"text-editor-body",children:[e("button",{disabled:c,onClick:()=>{m(async()=>{i(await _e("/api/audit")),s((await _e("/api/reader-verification")).enabled)})},children:"Run read-only audit"}),t&&e(ie,{children:[e("p",{children:[t.generator," · ",t.contentDir||"project root"," · ",t.pages.length," pages · ",t.drift.pages.length," stale · ",t.unverified.length," unverified · ",t.unmapped.length," unmapped"]}),e("p",{children:t.message}),t.drift.notes.map(r=>e("p",{children:r})),e("details",{children:[e("summary",{children:"Recognized page routes"}),e("ul",{children:t.pages.map(r=>e("li",{children:[r.path," → ",r.route]}))})]}),e("button",{disabled:c||!t.unmapped.length,onClick:()=>{m(async()=>{await K("/api/audit/backfill"),i(await _e("/api/audit")),await n()})},children:"Backfill missing evidence entries only"}),e("label",{children:[e("input",{type:"checkbox",checked:a,disabled:c,onChange:r=>{const g=r.currentTarget.checked;m(async()=>{await gt("/api/reader-verification",{enabled:g}),s(g),await n()})}})," Show reader verification labels in the Doxbrix reader"]}),e("p",{children:"Labels report evidence state and recorded revisions. Native generators retain their own reader templates."})]}),e("p",{role:"status",children:o})]})]})}function pl({onChanged:n,onTranslate:t}){const[i,a]=p([]),[s,o]=p(""),[l,c]=p(""),[d,m]=p("default"),[r,g]=p([]),[u,v]=p(""),[h,y]=p(!1),[P,k]=p(""),C=async w=>{y(!0);try{await w()}catch(I){k(String(I))}finally{y(!1)}};return e("details",{class:"text-editor",onToggle:w=>{w.currentTarget.open&&C(async()=>{const I=await _e("/api/collections");a(I),o(I[0]?.directory??"")})},children:[e("summary",{children:"Versions and languages"}),e("div",{class:"text-editor-body",children:[e("p",{children:"Create a separate documentation snapshot or translation draft. Copied pages retain source associations and require fresh verification. Docusaurus uses native version and locale directories; Doxbrix and MkDocs expose named collections in navigation."}),e("ul",{children:i.map(w=>e("li",{children:[w.version," · ",w.locale," · ",w.directory||"project root"]}))}),e("label",{children:["Copy from",e("select",{value:s,onChange:w=>o(w.currentTarget.value),children:i.map(w=>e("option",{value:w.directory,children:[w.version," · ",w.locale]}))})]}),e("label",{children:["Version",e("input",{value:l,placeholder:"1.0 or current",onInput:w=>c(w.currentTarget.value)})]}),e("label",{children:["Locale",e("input",{value:d,placeholder:"default or fr",onInput:w=>m(w.currentTarget.value)})]}),e("button",{disabled:h||!l||!d,onClick:()=>{C(async()=>{const w=await K("/api/collections",{sourceDirectory:s,version:l,locale:d});g(w.pages),v(d),k(w.message),a(await _e("/api/collections")),await n()})},children:"Create collection"}),r.length>0&&u!=="default"&&e("button",{disabled:h,onClick:()=>{C(async()=>{await t(r,u),k("Translation proposal started. Review it before accepting.")})},children:"Ask agent to translate copied pages"}),e("p",{role:"status",children:P}),e("p",{children:"Use Pages to edit and review each collection. Recent direct edits can undo collection creation while its files remain unchanged."})]})]})}function ps({root:n,path:t,proposal:i,refreshToken:a,focusLine:s,onChanged:o}){const l=Re(null),c=Re(null),d=i?`/api/proposals/${i.id}/changes/${i.changeId}/content`:`/api/pages/content?path=${encodeURIComponent(t)}`,m=`doxloop:text-draft:${n}:${i?.id??"live"}:${t}`,[r,g]=p(),[u,v]=p(),[h,y]=p(""),[P,k]=p(""),[C,w]=p(""),[I,L]=p(!1),[D,E]=p(!1),[A,j]=p(!1),[W,O]=p(""),[ue,ge]=p();ae(()=>{let G=!0;return _e(d).then(H=>{if(!G)return;g(H);let N;try{N=JSON.parse(sessionStorage.getItem(m)??"null")}catch{}v(N?.content!==void 0&&N.fingerprint?N:H),N&&k("Your unsaved draft was restored."),N&&N.fingerprint!==H.fingerprint&&(E(!0),y("The saved page changed since this draft. Compare both versions before saving."))}).catch(H=>{G&&y(H.message)}),()=>{G=!1}},[d,m,a]),ae(()=>{if(!s||!u||!l.current||!c.current)return;c.current.open=!0;const G=u.content.split(`
|
|
13
|
+
`),H=G.slice(0,Math.max(0,s-1)).reduce((N,oe)=>N+oe.length+1,0);l.current.focus(),l.current.setSelectionRange(H,H+(G[s-1]?.length??0)),l.current.scrollTop=Math.max(0,s-4)*20},[s,r?.fingerprint]);const fe=!!(u&&r&&u.content!==r.content);ae(()=>{const G=H=>{fe&&(H.preventDefault(),H.returnValue="")};return addEventListener("beforeunload",G),()=>removeEventListener("beforeunload",G)},[fe]);const ye=G=>{v(G),w("");try{sessionStorage.setItem(m,JSON.stringify(G))}catch{k("Browser draft storage is unavailable; keep this tab open until you save.")}},ce=async G=>{L(!0),y("");try{await G()}catch(H){y(H instanceof Error?H.message:String(H))}finally{L(!1)}},se=()=>ce(async()=>{if(!u)return;const G={path:t,...u,evidenceDisposition:A?"preserved":"needs-review"};i&&ge(r);const H=i?await qn(d,G):await gt("/api/pages/content",G),N=await _e(d);g(N),v(N),E(!1),O(H.editId??"");try{sessionStorage.removeItem(m)}catch{}k(i?"Proposed text saved. Review the updated diff before accepting.":"Page saved. The preview and evidence status have been updated."),await o()});return e("details",{ref:c,class:"text-editor",children:[e("summary",{children:["Edit text directly ",e("small",{children:"Save without running an agent"})]}),e("div",{class:"text-editor-body",children:[h&&e("p",{role:"alert",class:"text-editor-error",children:h}),P&&e("p",{role:"status",children:P}),u&&e(ie,{children:[e("label",{class:"text-editor-label",children:["Page source",e("textarea",{ref:l,disabled:I,"aria-label":"Page source",spellcheck:!1,value:u.content,onInput:G=>ye({...u,content:G.currentTarget.value}),onKeyDown:G=>{(G.metaKey||G.ctrlKey)&&G.key==="s"&&(G.preventDefault(),I||se())}})]}),e("label",{children:[e("input",{type:"checkbox",checked:A,onChange:G=>j(G.currentTarget.checked)})," This only changes wording; the recorded evidence is still valid."]}),e("p",{class:"text-editor-hint",children:"Otherwise the page is marked for evidence review. Markdown preview approximates native components; use the site preview for final checks."}),e("div",{class:"text-editor-actions",children:[e("button",{type:"button",class:"button",disabled:I||!fe,onClick:()=>{se()},children:I?"Working…":i?"Save proposed text":"Save page"}),e("button",{type:"button",class:"button",disabled:I,onClick:()=>{ce(async()=>w((await K("/api/pages/preview",{content:u.content})).html))},children:"Preview draft"}),e("button",{type:"button",class:"button",disabled:I,onClick:()=>{ce(async()=>{g(await _e(d)),E(!0)})},children:"Compare saved version"}),i&&ue&&r&&e("button",{type:"button",class:"button",disabled:I||fe,onClick:()=>{ce(async()=>{await qn(d,{content:ue.content,fingerprint:r.fingerprint,evidenceDisposition:"needs-review"});const G=await _e(d);g(G),v(G),ge(void 0),k("Proposed text edit undone. Evidence still requires review."),await o()})},children:"Undo proposed text edit"}),W&&e("button",{type:"button",class:"button",disabled:I,onClick:()=>{ce(async()=>{await K(`/api/direct-edits/${W}/undo`);const G=await _e(d);g(G),v(G),O(""),k("Saved edit undone."),await o()})},children:"Undo saved edit"})]}),D&&r&&e("section",{class:"text-editor-compare",children:[e("h3",{children:"Latest saved version"}),e("pre",{children:r.content}),e("button",{type:"button",class:"button",onClick:()=>{ye(r),y(""),E(!1)},children:"Discard draft and use saved version"}),u.fingerprint!==r.fingerprint&&e("button",{type:"button",class:"button",onClick:()=>{ye({...u,fingerprint:r.fingerprint}),y(""),k("Your draft now replaces the compared version when you save. Check the full text first.")},children:"Use my draft to replace this version"})]}),C&&e("iframe",{title:"Unsaved text preview",sandbox:"",srcDoc:C})]})]})]})}function hl({root:n,path:t,contentDir:i,onChanged:a}){const[s,o]=p("create"),[l,c]=p(""),[d,m]=p(""),[r,g]=p(""),[u,v]=p(!1),[h,y]=p(""),[P,k]=p([]),[C,w]=p(""),[I,L]=p(""),[D,E]=p();ae(()=>{E(void 0),t&&_e(`/api/pages/content?path=${encodeURIComponent(t)}`).then(E).catch(j=>y(j.message))},[n,t]);const A=async j=>{v(!0),y("");try{await j()}catch(W){y(W instanceof Error?W.message:String(W))}finally{v(!1)}};return e("details",{class:"text-editor page-tools",onToggle:j=>{j.currentTarget.open&&t&&_e(`/api/pages/content?path=${encodeURIComponent(t)}`).then(E).catch(W=>y(W.message))},children:[e("summary",{children:["Manage pages ",e("small",{children:"Create, move, delete, or undo changes"})]}),e("div",{class:"text-editor-body",children:[h&&e("p",{role:"alert",class:"text-editor-error",children:h}),C&&e("p",{role:"status",children:C}),e("label",{children:["Page operation",e("select",{"aria-label":"Page operation",value:s,onChange:j=>o(j.currentTarget.value),children:[e("option",{value:"create",children:"Create page"}),e("option",{value:"rename",disabled:!t,children:"Rename / move selected page"}),e("option",{value:"delete",disabled:!t,children:"Delete selected page"})]})]}),s!=="create"&&e("p",{children:["Selected page: ",e("code",{children:t})]}),s!=="delete"&&e("label",{children:["New page path",e("input",{"aria-label":"New page path",placeholder:`${i?`${i}/`:""}guides/new-page.md`,value:l,onInput:j=>c(j.currentTarget.value)})]}),s==="create"&&e("label",{children:["New page title",e("input",{"aria-label":"New page title",value:d,onInput:j=>m(j.currentTarget.value)})]}),s==="delete"&&e("label",{children:["Replacement page (required when other pages link here)",e("input",{"aria-label":"Replacement page",value:r,onInput:j=>g(j.currentTarget.value)})]}),e("p",{class:"text-editor-hint",children:"Moves update links, navigation, and evidence together. Existing public URLs are preserved or redirected. Custom navigation that cannot be changed safely is left for an agent proposal."}),e("div",{class:"text-editor-actions",children:[e("button",{type:"button",class:"button",disabled:u||s!=="delete"&&!l.trim()||s!=="create"&&!D,onClick:()=>{A(async()=>{const j=await K("/api/pages/lifecycle",{action:s,path:s==="create"?l.trim():t,fingerprint:D?.fingerprint,to:l.trim(),title:d,replacement:r.trim()});L(j.editId),w("Page operation saved. Undo is available."),c(""),k([]),await a(j.path)})},children:u?"Working…":s==="create"?"Create page":s==="rename"?"Move page":"Delete page"}),I&&e("button",{type:"button",class:"button",disabled:u,onClick:()=>{A(async()=>{await K(`/api/direct-edits/${I}/undo`),L(""),w("Page operation undone."),await a()})},children:"Undo page operation"}),e("button",{type:"button",class:"button",onClick:()=>{A(async()=>k(await _e("/api/direct-edits")))},children:"Recent direct edits"})]}),P.length>0&&e("ul",{children:P.slice(0,20).map(j=>e("li",{children:[j.requestText," · ",j.status," ",j.status==="completed"&&e("button",{type:"button",disabled:u,onClick:()=>{A(async()=>{await K(`/api/direct-edits/${j.id}/undo`),k(await _e("/api/direct-edits")),await a()})},children:"Undo"})]},j.id))})]})]})}function gl(n,t,i){let a=n,s=n.length;for(const o of[...t].sort((l,c)=>c.start-l.start)){if(o.start<0||o.end>s||n.slice(o.start,o.end)!==o.text)throw new Error("The editable preview is out of date. Reopen Content to refresh it.");s=o.start;const l=i.get(o.start);l!==void 0&&(a=a.slice(0,o.start)+l+a.slice(o.end))}return a}function fl({root:n,path:t,editing:i,native:a,base:s,focusLine:o,refreshToken:l,mode:c,onModeChange:d,onEditingChange:m,onStatus:r,onChanged:g,children:u}){const v=`doxloop:text-draft:${n}:live:${t}`,[h,y]=p(),[P,k]=p(),[C,w]=p(a&&!o?"visual":"source"),I=c??C,L=te=>{w(te),d?.(te)},[D,E]=p(),[A,j]=p(!1),[W,O]=p(!1),[ue,ge]=p(""),[fe,ye]=p(""),[ce,se]=p(),[G,H]=p(!1),[N,oe]=p(""),Ce=Re(null),ee=Re(null),Q=Re(""),x=Re(new Map),B=!!(P&&h&&P.content!==h.content),F=B||W;ae(()=>{let te=!0;return _e(`/api/pages/content?path=${encodeURIComponent(t)}`).then(M=>{if(!te)return;y(M);let ne=null;try{ne=JSON.parse(sessionStorage.getItem(v)??"null")}catch{}ne&&typeof ne.content=="string"&&typeof ne.fingerprint=="string"?(k(ne),m(!0),ye("Your unsaved draft was restored."),ne.fingerprint!==M.fingerprint&&(se(M),ge("The page changed since this draft. Compare before saving."))):k(M)}).catch(M=>{te&&ge(M.message)}),()=>{te=!1}},[v,l]),Ii(()=>{r(B,W)},[B,W]),ae(()=>{const te=M=>{F&&(M.preventDefault(),M.returnValue="")};return addEventListener("beforeunload",te),()=>removeEventListener("beforeunload",te)},[F]),ae(()=>{o&&(L("source"),m(!0))},[o]),Ii(()=>{if(!o||!P||I!=="source"||!ee.current)return;const te=P.content.split(`
|
|
14
|
+
`),M=te.slice(0,Math.max(0,o-1)).reduce((ne,xe)=>ne+xe.length+1,0);ee.current.focus(),ee.current.setSelectionRange(M,M+(te[o-1]?.length??0))},[o,I,h?.fingerprint,!!P]),ae(()=>{if(!i||I!=="visual"||!P||!s)return;let te=!0;return j(!0),E(void 0),K("/api/pages/editor-preview",{path:t,content:P.content,base:s}).then(M=>{te&&(Q.current=P.content,x.current.clear(),E(M))}).catch(M=>{te&&(ge(M.message),L("source"))}).finally(()=>{te&&j(!1)}),()=>{te=!1}},[i,I,!!P,h?.fingerprint,s]),ae(()=>{Ce.current?.contentWindow?.postMessage({type:"doxloop:editor-lock",locked:W},"*")},[W]);const T=te=>{if(!P)return;const M={...P,content:te};k(M);try{sessionStorage.setItem(v,JSON.stringify(M))}catch{ye("Draft storage is unavailable. Keep this page open until you save.")}},Z=()=>{try{sessionStorage.removeItem(v)}catch{}},Y=async te=>{if(!W){O(!0),ge("");try{await te()}catch(M){ge(M instanceof Error?M.message:String(M))}finally{O(!1)}}},pe=()=>Y(async()=>{if(!P||!B||ce)return;const te=await gt("/api/pages/content",{path:t,...P,evidenceDisposition:G?"preserved":"needs-review"});y(te),k(te),oe(te.editId),Z(),m(!1),ye("Page saved locally. Not published."),await g()});return ae(()=>{const te=M=>{if(M.source!==Ce.current?.contentWindow||!i||W||!D)return;if(M.data?.type==="doxloop:save-draft"){pe();return}const ne=M.data;if(!(ne?.type!=="doxloop:edit-block"||typeof ne.text!="string"||ne.text.length>5e5)&&D.blocks.some(xe=>xe.start===ne.start&&xe.end===ne.end)){x.current.set(ne.start,ne.text);try{T(gl(Q.current,D.blocks,x.current))}catch(xe){ge(xe instanceof Error?xe.message:String(xe))}}};return addEventListener("message",te),()=>removeEventListener("message",te)},[i,W,D,P,ce]),e("div",{class:"page-content-editor",children:[ue&&e("div",{class:"page-editor-notice error",role:"alert",children:[e("span",{children:ue}),P&&e(_,{size:"sm",disabled:W,onClick:()=>{Y(async()=>se(await _e(`/api/pages/content?path=${encodeURIComponent(t)}`)))},children:"Compare saved version"})]}),fe&&e("div",{class:"page-editor-notice",role:"status",children:[e("span",{children:fe}),N&&e(_,{size:"sm",disabled:W||B,onClick:()=>{Y(async()=>{await K(`/api/direct-edits/${N}/undo`);const te=await _e(`/api/pages/content?path=${encodeURIComponent(t)}`);y(te),k(te),oe(""),E(void 0),m(!1),ye("Saved edit undone."),await g()})},children:"Undo saved edit"}),e(_,{size:"sm",tone:"ghost",onClick:()=>ye(""),children:"Dismiss"})]}),i&&e(ie,{children:[e("div",{class:"page-editor-toolbar",children:[e(pt,{value:I,onChange:L,items:a?[["visual","Content"],["source","Edit source"]]:[["source","Edit source"]]}),e("span",{role:"status",children:W?"Saving…":B?"Unsaved changes":"Editing content"}),e(_,{size:"sm",disabled:W||!h,onClick:()=>{k(h),Z(),se(void 0),ge(""),m(!1)},children:"Discard"}),e(_,{size:"sm",tone:"primary",disabled:W||!B||!!ce,onClick:()=>{pe()},children:"Save changes"})]}),e("div",{class:"page-editor-hint",children:[I==="visual"?"Click outlined text to edit, including lists, links, and tables. Use Edit source for link destinations or component settings.":"Edit the page in its native source format. Save to refresh the site preview.",e("details",{children:[e("summary",{children:"Evidence settings"}),e("label",{children:[e("input",{type:"checkbox",checked:G,onChange:te=>H(te.currentTarget.checked)})," Wording only — the recorded evidence is still valid."]}),e("small",{children:"Other changes are marked for evidence review."})]})]}),ce&&e("section",{class:"page-editor-conflict",children:[e("h3",{children:"Latest saved version"}),e("pre",{children:ce.content}),e(_,{disabled:W,onClick:()=>{y(ce),k(ce),Z(),se(void 0),ge(""),L("source")},children:"Discard draft and use saved version"}),e(_,{disabled:W,onClick:()=>{if(P){const te={content:P.content,fingerprint:ce.fingerprint};y(ce),k(te);try{sessionStorage.setItem(v,JSON.stringify(te))}catch{}se(void 0),ge(""),ye("Compared version selected. Check your draft before saving.")}},children:"Keep my draft against this version"})]}),P?I==="source"?e("textarea",{ref:ee,class:"page-source-editor","aria-label":"Page source",spellcheck:!1,disabled:W,value:P.content,onInput:te=>T(te.currentTarget.value),onKeyDown:te=>{(te.metaKey||te.ctrlKey)&&te.key==="s"&&(te.preventDefault(),pe())}}):A||!D?e("div",{class:"preview-placeholder",children:s?"Preparing editable preview…":"Waiting for the site preview. You can use Edit source now."}):e(ie,{children:[D.blocks.length===0&&e("div",{class:"page-editor-notice",children:"This page has no editable text regions. Use Edit source to change its content."}),e("iframe",{ref:Ce,title:"Editable page preview",sandbox:"allow-scripts",src:D.url})]}):e("div",{class:"preview-placeholder",children:"Loading page source…"})]}),!i&&u]})}function ml(n,t,i){const a=n.jobs.find(s=>s.status==="running"&&/^(plan:|author:|proposal:|page-edit:|sync$)/.test(s.type));return a?{mood:"attention",eyebrow:"Work in progress",headline:a.type==="plan:generate"?"Writing the approved documentation":a.type.startsWith("plan:")?"Researching your documentation plan":"Preparing documentation changes",detail:"Follow the current run. Your accepted documentation stays available while the proposal is prepared.",label:"View current run"}:i?{mood:"attention",eyebrow:"Needs your review",headline:"Documentation changes are ready",detail:"Review the proposed changes before accepting them.",label:"Review changes"}:n.documentationPlan?.status==="failed"||n.documentationPlan?.status==="cancelled"?{mood:"attention",eyebrow:"Run needs attention",headline:"Continue from the last saved stage",detail:n.documentationPlan.error??"Open the update to inspect the failure and the available recovery actions.",label:"Review recovery options"}:n.documentationPlan&&["ready-for-review","needs-input","approved","stale"].includes(n.documentationPlan.status)?{mood:"attention",eyebrow:"Plan ready",headline:"Review your documentation plan",detail:"Review the scope, answer open questions, and approve generation when the plan is ready.",label:"Review plan"}:t?n.drift&&"status"in n.drift&&n.drift.status==="stale"?{mood:"attention",eyebrow:"Sources changed",headline:"Your documentation needs an update",detail:`${n.drift.pages.length} pages need verification against the current sources.`,label:"Plan an update"}:!n.drift||!("status"in n.drift)||n.drift.status==="unknown"?{mood:"attention",eyebrow:"Freshness unknown",headline:"Check the evidence behind your documentation",detail:"Existing pages do not by themselves establish that documentation is current.",label:"Check sources"}:{mood:"current",eyebrow:"Source check is current",headline:"No source changes are waiting",detail:"The tracked evidence has no detected drift. Preview the documentation or plan an update.",label:"Plan an update"}:{mood:"start",eyebrow:"Start the loop",headline:"Create your first documentation plan",detail:n.project?.sources.length?"Your sources are connected. Plan a small first batch to reach a useful result.":"Connect a source to begin planning your documentation.",label:n.project?.sources.length?"Create documentation":"Connect a source"}}function vl(n){return JSON.stringify([n.root,n.project?.sources,n.documentationPlan?.updatedAt,n.jobs.map(t=>[t.id,t.status]),Array.isArray(n.runs)?n.runs.map(t=>[t.id,t.status,t.changes.map(i=>i.hunks.map(a=>[a.acceptedAt,a.rejectedAt]))]):[],n.validation])}function bl(n,t,i){return n.filter(a=>a.type.startsWith("plan:")&&a.status!=="running"&&t.has(a.id)&&!i.has(a.id))}function yl(n,t,i){return n.filter(a=>a.type.startsWith("page-edit:")&&a.status!=="running"&&t.has(a.id)&&!i.has(a.id))}const wl=/^\d{2}:\d{2}:\d{2} /;function kl(n){return n.replace(wl,"")}function Cl(n){return{showSave:n.changed,showApprove:!0,approveDisabled:n.changed||n.busy||!n.hasPages||n.hasQuestions||n.captureRequired&&!n.hasVisualPages||!n.captureReady}}function xl(n){const t={create:0,update:0,preserve:0,remove:0,pagesToWrite:0,activeChanges:0};for(const i of n)i.priority!=="later"&&(t[i.action]+=1,(i.action==="create"||i.action==="update")&&(t.pagesToWrite+=1),i.action!=="preserve"&&(t.activeChanges+=1));return t}function or(n){return n==="preserve"?"Unchanged":n==="remove"?"Delete":n.charAt(0).toUpperCase()+n.slice(1)}function _l(n){return n.status==="approved"?"generate":n.status==="failed"?n.failure?.stage==="propose"?"retry-planning":"retry-generating":"approve"}function hs(n){const t=n.type.trim().toLowerCase().replace(/[\s_]+/g,"-");return/(^|-)(how-?to|tutorials?|guides?|quickstart|walkthrough)s?($|-)/.test(t)}const Sl=/(sign-?in|sign-?up|log-?in|register|auth|password)/i;function $l(n,t,i){if(t==="disabled")return;const a=n.filter(d=>d.priority!=="later"&&hs(d));if(a.length<3)return;const s=a.filter(d=>d.visuals&&d.visuals.mode!=="none");if(s.length*2>=a.length)return;const o=s.length>0&&s.every(d=>Sl.test(d.visuals?.startPath??"")),l=i?.status==="authentication-required"||i?.signInPath||o?"sign-in":i&&i.reachable===!1?"unreachable":"unknown",c=a.filter(d=>d.visuals?.mode==="none"&&!!d.visuals.rationale?.trim()).length;return{guides:a.length,withScreenshots:s.length,reason:l,explained:c}}function Pl(n,t,i){const a=o=>!!o&&n.some(l=>l.name===o&&l.status==="authenticated");return a(t)?t:a(i)?i:(n.find(o=>o.status==="authenticated")??n.find(o=>o.status==="unknown"))?.name??t??i??n[0]?.name??""}const Di={overview:"overview",sources:"sources",authoring:"update",pages:"pages",proposals:"review",publish:"deploy",settings:"settings"},Il={authoring:"authoring",proposals:"proposals",publish:"publish"};function ca(n){const t=n.split("/").filter(Boolean)[0];return t?Object.keys(Di).find(a=>Di[a]===t)??Il[t]??"not-found":"overview"}function Ri(n,t={}){const i=new URLSearchParams;for(const[s,o]of Object.entries(t))o&&i.set(s,o);const a=i.toString();return`/${Di[n]}${a?`?${a}`:""}`}function Al(n,t=""){const i=ca(n);if(i==="not-found")return;const a=`/${Di[i]}${t.startsWith("?")&&t.length>1?t:""}`;return a===`${n}${t}`?void 0:a}function xa(){const[,n]=p(0);return ae(()=>{const t=()=>n(i=>i+1);return addEventListener("popstate",t),()=>removeEventListener("popstate",t)},[]),new URLSearchParams(location.search)}function sn(n,t={},i="replace"){const a=Ri(n,t);`${location.pathname}${location.search}`!==a&&(history[i==="push"?"pushState":"replaceState"]({},"",a),dispatchEvent(new PopStateEvent("popstate")))}const Tl=3;class Dl{constructor(t=Tl){this.threshold=t}threshold;consecutive=0;failed(){return this.consecutive+=1,this.consecutive===this.threshold}succeeded(){this.consecutive=0}}const Rl=2e3,Ml=6e4,Ll=15e3;function zl({running:n,streamConnected:t,hidden:i}){return i?null:n?t?Ll:Rl:Ml}const El=1.25,gs=.55;function ui(n){const t=Math.max(1,Math.round(n));if(t<60)return`${t} min`;const i=Math.floor(t/60),a=t%60;return a?`${i}h ${a}m`:`${i}h`}function Nl(n){return n<1?`~${Math.max(100,Math.round(n*10)*100)}k`:n<10?`~${Number(n.toFixed(1))}M`:`~${Math.ceil(n/5)*5}M`}function Ol(n){const t=Math.max(1,n),i=t*El;return{minutes:Math.max(5,Math.round(i/5)*5),millionTokens:t*gs}}function Ul(n,t){const i=Math.max(1,n),a=`${i} page${i===1?"":"s"}`,s=Nl(i*gs);if(t?.range){const{minimumMinutes:l,maximumMinutes:c}=t.range;return`Estimate: ${l===c?`about ${ui(l)}`:`${ui(l)}–${ui(c)}`} and ${s} tokens for ${a}, based on ${t.samples} of your past runs. Your agent provider bills the tokens.`}const o=Ol(i);return`Rough estimate: about ${ui(o.minutes)} and ${s} tokens for ${a} (based on typical runs). Your agent provider bills the tokens.`}const da="doxloop:preview-notice";function Bl(n){dispatchEvent(new CustomEvent(da,{detail:n}))}async function _a(n,t=Bl){let i=null;try{i=window.open("about:blank","_blank")}catch{i=null}if(i){try{i.opener=null}catch{}try{i.document.title="Starting preview…",i.document.body.style.font="15px system-ui, sans-serif",i.document.body.style.padding="32px",i.document.body.textContent="Starting the Doxloop preview… This tab opens the documentation as soon as it is ready."}catch{}}t({state:"starting"});try{const{url:a}=await n(!i),s=!!(i&&!i.closed);return s&&i.location.replace(a),t({state:"ready",url:a,blocked:!s}),a}catch(a){try{i?.close()}catch{}t({state:"failed",error:a instanceof Error?a.message:String(a)});return}}function jl(n,t,i){return lr(n,t)||lr(n,i)?{form:i,seeded:i,stale:!1}:{form:n,seeded:i,stale:!0}}function lr(n,t){return JSON.stringify(n)===JSON.stringify(t)}function bi(n,t){const[i,a]=p(n),s=Re(i),[o,l]=p(!1),c=Re(t);return ae(()=>{if(c.current===t)return;c.current=t;const m=jl(i,s.current,n());s.current=m.seeded,l(m.stale),m.stale||a(m.form)},[t]),[i,a,{stale:o,resync:()=>{a(s.current),l(!1)}}]}function Fl({open:n,commands:t,onClose:i}){const[a,s]=p(""),[o,l]=p(0),c=Re(null),d=Re(null),m=Ai(()=>{const v=a.trim().toLowerCase(),h=v?t.filter(y=>`${y.label} ${y.hint??""} ${y.group}`.toLowerCase().includes(v)):t;return v?h.slice(0,40):h.filter((y,P)=>y.group!=="Pages"||P<200).slice(0,14)},[t,a]);if(ae(()=>{if(!n)return;s(""),l(0);const v=setTimeout(()=>c.current?.focus(),0);return()=>clearTimeout(v)},[n]),ae(()=>{l(0)},[a]),ae(()=>{d.current?.querySelector(".command-palette-item.active")?.scrollIntoView({block:"nearest"})},[o,m]),!n)return null;const r=v=>{v&&(i(),v.run())},g=v=>{v.key==="ArrowDown"?(v.preventDefault(),l(h=>m.length?(h+1)%m.length:0)):v.key==="ArrowUp"?(v.preventDefault(),l(h=>m.length?(h-1+m.length)%m.length:0)):v.key==="Enter"?(v.preventDefault(),r(m[o])):v.key==="Escape"&&(v.preventDefault(),i())},u=[];return m.forEach((v,h)=>{const y=u.find(([P])=>P===v.group);y?y[1].push([v,h]):u.push([v.group,[[v,h]]])}),e("div",{class:"command-palette-scrim",role:"presentation",onMouseDown:v=>{v.target===v.currentTarget&&i()},children:e("div",{class:"command-palette",role:"dialog","aria-modal":"true","aria-label":"Search or jump to",children:[e("div",{class:"command-palette-input",children:[e($,{name:"search",size:18}),e("input",{ref:c,type:"text",autofocus:!0,value:a,placeholder:"Search pages, screens, and actions…","aria-label":"Search pages, screens, and actions",onInput:v=>s(v.currentTarget.value),onKeyDown:g}),e("kbd",{children:"esc"})]}),e("div",{ref:d,class:"command-palette-list",role:"listbox",children:[m.length===0&&e("div",{class:"command-palette-empty",children:["Nothing matches “",a,"”."]}),u.map(([v,h])=>e("div",{children:[e("span",{class:"kicker command-palette-group",children:v}),h.map(([y,P])=>e("button",{type:"button",role:"option","aria-selected":P===o,class:`command-palette-item ${P===o?"active":""}`,onMouseEnter:()=>l(P),onClick:()=>r(y),children:[e($,{name:y.icon,size:16}),e("span",{children:y.label}),y.hint&&e("small",{children:y.hint})]},y.id))]},v))]}),e("div",{class:"command-palette-foot",children:[e("span",{children:"↑↓ move"}),e("span",{children:"↵ open"}),e("span",{children:"esc close"})]})]})})}function ql(n){ae(()=>{const t=i=>{(i.metaKey||i.ctrlKey)&&i.key.toLowerCase()==="k"&&(i.preventDefault(),n())};return addEventListener("keydown",t),()=>removeEventListener("keydown",t)},[n])}const fs={page:0,navigation:1,asset:2};function Wl(n){return!(n.category in fs)}function Gl(n){const t=i=>fs[i.category]??3;return[...n].sort((i,a)=>t(i)-t(a))[0]}function ms(n){const t={concurrent:[],documentation:[],supporting:[]};for(const i of n)i.changedDuringRun?t.concurrent.push(i):Wl(i)?t.supporting.push(i):t.documentation.push(i);return t}function Hl(n){return n.hunks.map(t=>`${t.id}:${t.acceptedAt?"a":t.rejectedAt?"r":"p"}`).join(",")}function Vl(n,t=!1){const i={accepted:0,rejected:0,remaining:0};for(const a of n){if(a.hunks.length===0){i[t?"accepted":"remaining"]+=1;continue}a.hunks.some(s=>!s.acceptedAt&&!s.rejectedAt)?i.remaining+=1:a.hunks.some(s=>s.acceptedAt)?i.accepted+=1:i.rejected+=1}return i}function Kl(n,t){const i=`${n.captured} screenshot${n.captured===1?"":"s"}`;return t&&t>=n.guides?`Screenshots in ${n.guides} of ${t} guide${t===1?"":"s"} · ${i} verified`:`Screenshots in ${n.guides} guide${n.guides===1?"":"s"} · ${i} verified`}function vs({runId:n,change:t,layout:i="split",onlyChanges:a=!0}){return e("div",{class:"review-device",children:e("iframe",{class:"review-frame",title:`Review ${t.title}`,src:`/review-preview/${n}/${t.id}?layout=${i}${a?"&only=1":""}`})})}function bs({runId:n,change:t,act:i,onReviseHunk:a=()=>{},partialActions:s=!0,beforeAccept:o=()=>!0}){const[l,c]=p(null),[d,m]=p(""),r=Hl(t);if(ae(()=>{m(""),_e(`/api/proposals/${n}/changes/${t.id}/diff`).then(c).catch(u=>m(u instanceof Error?u.message:String(u)))},[n,t.id,r]),ae(()=>c(null),[n,t.id]),d)return e("div",{class:"diff-message error",children:d});if(!l)return e("div",{class:"diff-message",children:"Loading source diff…"});if(l.binary)return e(Mn,{title:"Binary asset",detail:"This file has no line-by-line source diff. Accept the page to apply it."});const g=Yl(l.rows);return e("div",{class:"source-diff",children:[e("div",{class:"diff-summary",children:[e("span",{class:"added",children:["+",l.added]}),e("span",{class:"removed",children:["−",l.removed]}),e("small",{children:s?"Accept one change at a time, or accept the complete page.":"Review the source changes before accepting the complete edit."})]}),g.map((u,v)=>e("section",{class:`hunk ${u.state??""}`,children:[e("header",{children:[e("strong",{children:u.hunkId?`Change ${v+1}`:"Context"}),s&&u.hunkId&&u.state==="pending"&&e("span",{class:"hunk-actions",children:[e(_,{size:"sm",onClick:()=>a(u.hunkId),children:"Revise"}),e(_,{size:"sm",tone:"danger",onClick:()=>{const h=prompt("Why reject this change? (optional)","");h!==null&&i(()=>K(`/api/proposals/${n}/reject-changes`,{changeId:t.id,hunkIds:[u.hunkId],reason:h}),"Change rejected")},children:"Reject change"}),e(_,{size:"sm",tone:"primary",onClick:()=>o()&&void i(()=>K(`/api/proposals/${n}/accept`,{scope:"hunk",changeId:t.id,hunkId:u.hunkId,...t.changedDuringRun?{confirmChangedDuringRun:!0}:{}}),"Change accepted"),children:"Accept change"})]}),u.hunkId&&t.hunks.find(h=>h.id===u.hunkId)?.rejectionReason&&e("small",{children:t.hunks.find(h=>h.id===u.hunkId)?.rejectionReason}),u.hunkId&&u.state!=="pending"&&e(Me,{tone:ws(u.state??""),children:u.state??"resolved"})]}),e("div",{class:"diff-lines",children:u.rows.map((h,y)=>e(Jl,{row:h},y))})]},u.hunkId??v))]})}function ys({change:n,onClose:t}){const i=n.rationale,a=[...i.claims.added,...i.claims.changed,...i.claims.removed];return e("div",{class:"proposal-drawer-scrim",role:"presentation",onClick:s=>s.target===s.currentTarget&&t(),children:e("aside",{class:"proposal-rationale-drawer",role:"dialog","aria-modal":"true","aria-labelledby":"proposal-rationale-title",children:[e("header",{children:[e("span",{children:[e("small",{children:"Why this change"}),e("h2",{id:"proposal-rationale-title",children:n.title}),e("code",{children:n.path})]}),e("button",{type:"button","aria-label":"Close rationale",onClick:t,children:e($,{name:"close",size:17})})]}),e("div",{class:"proposal-drawer-body",children:[e("section",{class:"rationale-lead",children:[e(Me,{tone:ws(i.confidence),children:i.confidence.replace("-"," ")}),e("p",{children:i.reason})]}),e("section",{children:[e("h3",{children:"Supporting evidence"}),i.evidence.length>0?e("div",{class:"rationale-evidence-list",children:i.evidence.map((s,o)=>e("article",{class:s.available?"":"unavailable",children:[e($,{name:"link",size:14}),e("span",{children:[e("strong",{children:s.source}),e("code",{children:s.path??s.operation??"Configured source"}),s.revision&&e("small",{children:["Revision ",s.revision.slice(0,12)]}),!s.available&&e("small",{children:"Unavailable in this environment"})]})]},o))}):e("p",{class:"muted-copy",children:"No precise source reference was recorded. Review this change manually before acceptance."})]}),a.length>0&&e("section",{children:[e("h3",{children:"Reader-facing claims"}),e("ul",{children:a.map(s=>e("li",{children:s},s))})]}),i.affectedInterfaces.length>0&&e("section",{children:[e("h3",{children:"Public interfaces affected"}),e("div",{class:"rationale-tags",children:i.affectedInterfaces.map(s=>e("span",{children:s},s))})]}),e("section",{class:"rationale-validation",children:[e("h3",{children:"Checks"}),e("p",{children:[e($,{name:"check",size:14})," ",i.validation.errors," errors · ",i.validation.warnings," warnings"]}),e("small",{children:i.authorship==="human"?"Edited by a reviewer":i.planId?`From approved plan ${i.planId}`:"Generated from the review request"})]}),i.assumptions.length>0&&e("details",{children:[e("summary",{children:"Assumptions to verify"}),e("ul",{children:i.assumptions.map(s=>e("li",{children:s},s))})]})]})]})})}function Jl({row:n}){if(n.type==="gap")return e("div",{class:"diff-line gap",children:[e("span",{}),e("span",{}),e("b",{}),e("code",{children:[n.hidden," unchanged lines"]})]});const t=n.type==="insert"?"+":n.type==="delete"?"−":" ";return e("div",{class:`diff-line ${n.type}`,children:[e("span",{children:n.oldNumber??""}),e("span",{children:n.newNumber??""}),e("b",{children:t}),e("code",{dangerouslySetInnerHTML:{__html:n.html||" "}})]})}function Yl(n){const t=[];for(const i of n){const a=t.at(-1);a&&a.hunkId===i.hunkId?a.rows.push(i):t.push({...i.hunkId?{hunkId:i.hunkId}:{},...i.hunkState?{state:i.hunkState}:{},rows:[i]})}return t}function ws(n){return["verified","accepted","added"].includes(n)?"good":["pending","modified","inferred"].includes(n)?"info":n==="needs-human"?"warn":["rejected","deleted"].includes(n)?"bad":"neutral"}const cr=".png,.jpg,.jpeg,.gif,.webp,.svg,.avif,.ico,.pdf,.mp4,.webm,.mov,.zip",ks=".png,.jpg,.jpeg,.gif,.webp,.svg,.avif,.ico";function Cs(n){return new Promise((t,i)=>{const a=new FileReader;a.onerror=()=>i(new Error(`Could not read ${n.name}.`)),a.onload=()=>t(String(a.result??"").replace(/^data:[^;]*;base64,/,"")),a.readAsDataURL(n)})}async function xs(n,t,i={}){const a=[];for(const s of n){const o=await Cs(s),l={name:i.name??s.name,data:o,replace:i.replace===!0,...i.directory?{directory:i.directory}:{}};let c=await t(()=>K("/api/assets",l).catch(d=>{if(/already exists/.test(d.message)&&!i.replace&&confirm(`${l.name} already exists. Replace it?`))return K("/api/assets",{...l,replace:!0});throw d}),`${i.replace?"Replaced":"Uploaded"} ${l.name}`,!1);c&&a.push(c),c=void 0}return a}function Vt(n){return`/api/assets/file?path=${encodeURIComponent(n.path)}&v=${encodeURIComponent(n.modifiedAt)}`}function dr(n){return n<1024?`${n} B`:n<1024*1024?`${Math.round(n/102.4)/10} KB`:`${Math.round(n/104857.6)/10} MB`}function Zl({act:n,onError:t,onChanged:i}){const[a,s]=p(),[o,l]=p(!0),[c,d]=p(""),[m,r]=p(),[g,u]=p(""),[v,h]=p(!1),y=Re(null),P=Re(null),k=async()=>{try{s(await _e("/api/assets"))}catch(O){t(O instanceof Error?O.message:String(O))}finally{l(!1)}};ae(()=>{k()},[]);const C=a?.assets??[],w=C.find(O=>O.path===m);Ii(()=>{u(w?.references[0]?.alt??"")},[w?.path,w?.references.map(O=>O.alt).join("|")]);const I=c.trim().toLowerCase(),L=I?C.filter(O=>`${O.name} ${O.path}`.toLowerCase().includes(I)):C,D=C.filter(O=>O.references.length===0).length,E=async(O,ue=!1)=>{if(O.length!==0){h(!0);try{const ge=w?.path.split("/").slice(0,-1).join("/"),fe=await xs(O,n,ue&&w?{replace:!0,name:w.name,...ge?{directory:ge}:{}}:{});await k(),fe[0]&&r(fe[0].path),i?.()}finally{h(!1)}}},A=async()=>{if(w){h(!0);try{await n(()=>K("/api/assets/alt",{path:w.path,alt:g}),"Alt text updated",!1)&&(await k(),i?.())}finally{h(!1)}}},j=async()=>{if(w&&confirm(`Delete ${w.name}? This cannot be undone.`)){h(!0);try{await n(()=>K("/api/assets/delete",{path:w.path}),`Deleted ${w.name}`,!1)&&(r(void 0),await k(),i?.())}finally{h(!1)}}},W=async O=>{try{await navigator.clipboard.writeText(O)}catch{}};return e("div",{class:"asset-library",children:[e("input",{ref:y,type:"file",accept:cr,multiple:!0,hidden:!0,onChange:O=>{const ue=[...O.currentTarget.files??[]];O.currentTarget.value="",E(ue)}}),e("input",{ref:P,type:"file",accept:w?.kind==="image"?ks:cr,hidden:!0,onChange:O=>{const ue=[...O.currentTarget.files??[]];O.currentTarget.value="",E(ue,!0)}}),e("header",{class:"asset-library-head",children:[e("div",{children:[e("h2",{children:"Images and files"}),e("p",{children:a?e(ie,{children:["Uploads go to ",e("code",{children:a.directory})," and pages reference them as ",e("code",{children:[a.publicPrefix.replace(/\/$/,""),"/name"]}),". ",C.length," asset",C.length===1?"":"s",D?`, ${D} unused`:"","."]}):"Loading the asset library…"})]}),e("div",{class:"asset-library-actions",children:[e("label",{class:"page-search asset-search",children:[e("span",{class:"sr-only",children:"Search assets"}),e($,{name:"search",size:16}),e(re,{type:"search",value:c,placeholder:"Search by name",onInput:O=>d(O.currentTarget.value)})]}),e(_,{tone:"primary",icon:"plus",busy:v,onClick:()=>y.current?.click(),children:"Upload"})]})]}),e("div",{class:`asset-library-body ${w?"with-detail":""}`,onDragOver:O=>{O.preventDefault()},onDrop:O=>{O.preventDefault(),E([...O.dataTransfer?.files??[]])},children:[e("div",{class:"asset-grid",role:"list",children:o?e("div",{class:"page-list-empty",children:[e("span",{class:"spinner"}),"Loading assets…"]}):L.length===0?e(Mn,{icon:"file",title:I?`No assets match “${c.trim()}”`:"No images or files yet",...I?{}:{detail:"Upload images here, or drop files onto this area. Uploaded images can be inserted into any page by the agent."}}):L.map(O=>e("button",{type:"button",role:"listitem",class:`asset-tile ${m===O.path?"active":""}`,onClick:()=>r(O.path===m?void 0:O.path),children:[e("span",{class:"asset-thumb",children:O.kind==="image"?e("img",{src:Vt(O),alt:"",loading:"lazy"}):e($,{name:"file",size:26})}),e("span",{class:"asset-tile-copy",children:[e("strong",{children:O.name}),e("small",{children:[dr(O.bytes)," · ",O.references.length?`${O.references.length} use${O.references.length===1?"":"s"}`:"Unused"]})]})]},O.path))}),w&&e("aside",{class:"asset-detail","aria-label":`${w.name} details`,children:[e("header",{children:[e("strong",{children:w.name}),e("button",{type:"button","aria-label":"Close details",onClick:()=>r(void 0),children:e($,{name:"close",size:14})})]}),w.kind==="image"&&e("a",{class:"asset-detail-preview",href:Vt(w),target:"_blank",rel:"noreferrer",children:e("img",{src:Vt(w),alt:g||w.name})}),e("dl",{class:"asset-detail-facts",children:[e("dt",{children:"Public path"}),e("dd",{children:[e("code",{children:w.publicPath}),e("button",{type:"button","aria-label":"Copy public path",title:"Copy",onClick:()=>{W(w.publicPath)},children:e($,{name:"copy",size:13})})]}),e("dt",{children:"File"}),e("dd",{children:e("code",{children:w.path})}),e("dt",{children:"Size"}),e("dd",{children:dr(w.bytes)})]}),w.kind==="image"&&e("div",{class:"asset-alt",children:[e("label",{class:"field",children:[e("span",{class:"field-label",children:"Alt text"}),e(re,{value:g,disabled:w.references.length===0||v,placeholder:w.references.length?"Describe what the image shows":"Embed the image in a page first",onInput:O=>u(O.currentTarget.value)}),e("small",{children:w.references.length?`Applied to every page that embeds this image (${w.references.length}).`:"Alt text lives on the page that embeds the image."})]}),w.references.length>0&&e(_,{size:"sm",tone:"primary",busy:v,disabled:g.trim()===(w.references[0]?.alt??""),onClick:()=>{A()},children:"Save alt text"})]}),w.references.length>0&&e("div",{class:"asset-references",children:[e("strong",{children:"Used on"}),e("ul",{children:w.references.map((O,ue)=>e("li",{children:[e("code",{children:O.page}),O.alt?e("small",{children:["“",O.alt,"”"]}):e("small",{class:"warn",children:"No alt text"})]},`${O.page}-${ue}`))})]}),w.references.length===0&&e(Te,{children:"This file is not embedded in any page."}),e("footer",{children:[e(_,{size:"sm",icon:"refresh",busy:v,onClick:()=>P.current?.click(),children:"Replace file"}),e(_,{size:"sm",tone:"danger",icon:"trash",busy:v,disabled:w.references.length>0,title:w.references.length>0?"Pages still embed this file. Ask the agent to remove it from them first.":void 0,onClick:()=>{j()},children:"Delete"})]})]})]})]})}function Sa({act:n,onPick:t,onClose:i,title:a="Choose an image"}){const[s,o]=p(),[l,c]=p(!1),[d,m]=p(""),r=Re(null),g=async()=>{try{o((await _e("/api/assets")).assets.filter(v=>v.kind==="image"))}catch(v){m(v instanceof Error?v.message:String(v))}};ae(()=>{g()},[]);const u=async v=>{c(!0);try{const h=await xs(v,n);h[0]&&t(h[0])}finally{c(!1)}};return e("div",{class:"sources-modal-scrim",onClick:i,children:e("section",{class:"sources-reference-dialog asset-picker",role:"dialog","aria-modal":"true","aria-label":a,onClick:v=>v.stopPropagation(),children:[e("header",{children:[e("span",{class:"sources-dialog-icon",children:e($,{name:"file",size:22})}),e("div",{children:[e("h2",{children:a}),e("p",{children:"Pick an image from the project or upload a new one."})]}),e("button",{type:"button","aria-label":"Close",onClick:i,children:e($,{name:"close",size:17})})]}),e("div",{class:"sources-dialog-body",children:[e("input",{ref:r,type:"file",accept:ks,hidden:!0,onChange:v=>{const h=[...v.currentTarget.files??[]];v.currentTarget.value="",u(h)}}),d&&e(Te,{tone:"bad",children:d}),s?s.length===0?e(Mn,{icon:"file",title:"No images in this project yet",detail:"Upload one to continue."}):e("div",{class:"asset-grid picker",role:"list",children:s.map(v=>e("button",{type:"button",role:"listitem",class:"asset-tile",onClick:()=>t(v),children:[e("span",{class:"asset-thumb",children:e("img",{src:Vt(v),alt:"",loading:"lazy"})}),e("span",{class:"asset-tile-copy",children:[e("strong",{children:v.name}),e("small",{children:v.publicPath})]})]},v.path))}):e("div",{class:"page-list-empty",children:[e("span",{class:"spinner"}),"Loading images…"]})]}),e("footer",{children:[e(_,{onClick:i,children:"Cancel"}),e(_,{tone:"primary",icon:"plus",busy:l,onClick:()=>r.current?.click(),children:"Upload image"})]})]})})}const Ql=["Inter","IBM Plex Sans","Source Sans 3","Roboto","Open Sans","Lato","Nunito","Manrope","Work Sans","Public Sans"],Xl=["ui-monospace","JetBrains Mono","Fira Code","IBM Plex Mono","Source Code Pro","Roboto Mono"],Ji={primaryColor:"#6366f1",backgroundColorLight:"#ffffff",backgroundColorDark:"#12131a",font:"Inter",codeFont:"ui-monospace",mode:"system",codeTheme:"auto"};function Yi(n){const t={name:n.site?.name??"",description:n.site?.description??""};for(const i of ec)t[i]=n.theme?.[i]??"";return t}const ec=["primaryColor","lightColor","darkColor","backgroundColorLight","backgroundColorDark","font","headingFont","codeFont","logoLight","logoDark","favicon","faviconLight","faviconDark","backgroundImage","mode","codeTheme","logoHref"];function nc({act:n,onError:t,previewUrl:i,onPreviewStart:a}){const[s,o]=p(),[l,c]=p(),[d,m]=p(),[r,g]=p(!1),[u,v]=p(0),[h,y]=p(i),P=async()=>{try{const A=await _e("/api/branding");o(A),c(Yi(A))}catch(A){t(A instanceof Error?A.message:String(A))}};if(ae(()=>{P()},[]),ae(()=>{h||!s?.editable||a().then(A=>{A&&y(A)})},[s?.editable,h]),!s||!l)return e(Ue,{title:"Branding",description:"Logo, colours, and fonts for the published site.",children:e("div",{class:"page-list-empty",children:[e("span",{class:"spinner"}),"Loading branding…"]})});if(!s.editable)return e(Ue,{title:"Branding",description:"Logo, colours, and fonts for the published site.",children:[e(Te,{children:s.reason}),s.configFile&&e("p",{class:"branding-config-hint",children:["Theme configuration: ",e("code",{children:s.configFile})]})]});const k=Yi(s),C=Object.keys(l).filter(A=>l[A]!==k[A]),w=(A,j)=>c({...l,[A]:j}),I=async()=>{if(C.length!==0){g(!0);try{const A={};for(const O of C)O!=="name"&&O!=="description"&&(A[O]=l[O]||null);const j={fingerprint:s.fingerprint,...C.includes("name")||C.includes("description")?{site:{name:l.name,description:l.description}}:{},...Object.keys(A).length?{theme:A}:{}},W=await n(()=>gt("/api/branding",j),"Branding saved",!1);W&&(o(W),c(Yi(W)),v(O=>O+1))}finally{g(!1)}}},L=()=>c(k),D=(A,j,W)=>e(U,{label:j,hint:W,children:e("span",{class:"color-field",children:[e("input",{type:"color","aria-label":`${j} swatch`,value:/^#[0-9a-f]{6}$/i.test(l[A])?l[A]:Ji[A]??Ji.primaryColor,onInput:O=>w(A,O.currentTarget.value)}),e(re,{"aria-label":j,value:l[A],placeholder:Ji[A]??"Inherit",maxlength:7,onInput:O=>w(A,O.currentTarget.value)}),l[A]&&e("button",{type:"button",class:"color-clear","aria-label":`Clear ${j}`,onClick:()=>w(A,""),children:e($,{name:"close",size:12})})]})}),E=(A,j,W)=>e(U,{label:j,hint:W,children:e("span",{class:"asset-field",children:[l[A]&&/^\//.test(l[A])&&e("img",{class:"asset-field-thumb",src:tc(s,l[A]),alt:""}),e(re,{"aria-label":j,value:l[A],placeholder:"/assets/logo.svg or https://…",onInput:O=>w(A,O.currentTarget.value)}),e(_,{size:"sm",onClick:()=>m(A),children:"Choose…"}),l[A]&&e("button",{type:"button",class:"color-clear","aria-label":`Clear ${j}`,onClick:()=>w(A,""),children:e($,{name:"close",size:12})})]})});return e(ie,{children:[d&&e(Sa,{act:n,title:`Choose the ${ur(d).toLowerCase()}`,onClose:()=>m(void 0),onPick:A=>{w(d,A.publicPath),m(void 0)}}),e(Ue,{title:"Branding",description:"Logo, colours, and fonts for the published site. Changes show in the preview below without an agent run.",actions:e(ie,{children:[e(_,{size:"sm",tone:"ghost",disabled:C.length===0||r,onClick:L,children:"Discard"}),e(_,{size:"sm",tone:"primary",busy:r,disabled:C.length===0,onClick:()=>{I()},children:"Save branding"})]}),children:[e("div",{class:"branding-grid",children:[e("section",{class:"branding-section",children:[e("h3",{children:"Identity"}),e("div",{class:"form-grid",children:[e(U,{label:"Site name",children:e(re,{value:l.name,onInput:A=>w("name",A.currentTarget.value)})}),e(U,{label:"Site description",hint:"Used for social previews and search results",children:e(re,{value:l.description,onInput:A=>w("description",A.currentTarget.value)})}),E("logoLight","Logo (light mode)","SVG or PNG. Shown in the top bar."),E("logoDark","Logo (dark mode)","Optional. Falls back to the light logo."),E("favicon","Favicon","PNG, ICO, or SVG."),e(U,{label:"Logo link",hint:"Where the logo points. Defaults to the first page.",children:e(re,{value:l.logoHref,placeholder:"/ or https://example.com",onInput:A=>w("logoHref",A.currentTarget.value)})})]})]}),e("section",{class:"branding-section",children:[e("h3",{children:"Colours"}),e("div",{class:"form-grid",children:[D("primaryColor","Primary colour","Links, buttons, and the active navigation item."),D("lightColor","Accent in light mode","Optional override of the primary colour on light backgrounds."),D("darkColor","Accent in dark mode","Optional override of the primary colour on dark backgrounds."),D("backgroundColorLight","Light background","Page background in light mode."),D("backgroundColorDark","Dark background","Page background in dark mode."),e(U,{label:"Default colour mode",children:e(Fe,{value:l.mode||"system",onChange:A=>w("mode",A.currentTarget.value),children:[e("option",{value:"system",children:"Follow the reader's system"}),e("option",{value:"light",children:"Light"}),e("option",{value:"dark",children:"Dark"})]})}),e(U,{label:"Code block theme",children:e(Fe,{value:l.codeTheme||"auto",onChange:A=>w("codeTheme",A.currentTarget.value),children:[e("option",{value:"auto",children:"Match colour mode"}),e("option",{value:"light",children:"Always light"}),e("option",{value:"dark",children:"Always dark"})]})})]})]}),e("section",{class:"branding-section",children:[e("h3",{children:"Fonts"}),e("div",{class:"form-grid",children:[e(U,{label:"Body font",hint:"Google Fonts families load automatically; others need a font source in docs.json.",children:e(re,{list:"branding-fonts",value:l.font,placeholder:"Inter",onInput:A=>w("font",A.currentTarget.value)})}),e(U,{label:"Heading font",hint:"Optional. Defaults to the body font.",children:e(re,{list:"branding-fonts",value:l.headingFont,placeholder:"Same as body",onInput:A=>w("headingFont",A.currentTarget.value)})}),e(U,{label:"Code font",children:e(re,{list:"branding-code-fonts",value:l.codeFont,placeholder:"ui-monospace",onInput:A=>w("codeFont",A.currentTarget.value)})})]}),e("datalist",{id:"branding-fonts",children:Ql.map(A=>e("option",{value:A},A))}),e("datalist",{id:"branding-code-fonts",children:Xl.map(A=>e("option",{value:A},A))})]})]}),C.length>0&&e(Te,{children:["Unsaved changes: ",C.map(ur).join(", "),". Save to see them in the preview."]}),e("p",{class:"branding-config-hint",children:["Stored in ",e("code",{children:s.configFile}),"."]})]}),e(Ue,{title:"Live preview",description:"The site as readers see it, with the saved branding.",flush:!0,children:e("div",{class:"branding-preview",children:h?e("iframe",{title:"Branding preview",src:`${h}/?embed=page`},`${h}:${u}`):e("div",{class:"preview-placeholder",children:[e("span",{class:"spinner"}),e("strong",{children:"Preview is starting…"})]})})})]})}function tc(n,t){const i=n.assets.find(a=>a.publicPath===t);return i?Vt({path:i.path,modifiedAt:""}):""}function ur(n){return{name:"site name",description:"site description",primaryColor:"primary colour",lightColor:"light accent",darkColor:"dark accent",backgroundColorLight:"light background",backgroundColorDark:"dark background",font:"body font",headingFont:"heading font",codeFont:"code font",logoLight:"light logo",logoDark:"dark logo",favicon:"favicon",faviconLight:"light favicon",faviconDark:"dark favicon",backgroundImage:"background image",mode:"colour mode",codeTheme:"code theme",logoHref:"logo link"}[n]??n}function ic({path:n,act:t,onError:i,onSaved:a}){const[s,o]=p(),[l,c]=p({title:"",description:"",canonical:"",socialImage:"",icon:""}),[d,m]=p(!1),[r,g]=p(!1),[u,v]=p(!1),h=async()=>{try{const C=await _e(`/api/pages/metadata?path=${encodeURIComponent(n)}`),w={...C,fields:C.fields??{},otherKeys:C.otherKeys??[]};o(w),c({title:w.fields.title??"",description:w.fields.description??"",canonical:w.fields.canonical??"",socialImage:w.fields.socialImage??"",icon:w.fields.icon??""})}catch(C){i(C instanceof Error?C.message:String(C))}};ae(()=>{o(void 0),d&&h()},[n,d]);const y=s?{title:s.fields.title??"",description:s.fields.description??"",canonical:s.fields.canonical??"",socialImage:s.fields.socialImage??"",icon:s.fields.icon??""}:l,P=Object.keys(l).filter(C=>l[C]!==y[C]),k=async()=>{if(!(!s||P.length===0)){g(!0);try{const C={};for(const I of P)C[I]=l[I]||null;const w=await t(()=>gt("/api/pages/metadata",{path:n,fingerprint:s.fingerprint,fields:C}),"Page metadata saved",!1);w&&(o(w),a())}finally{g(!1)}}};return e("section",{class:"page-metadata",children:[u&&e(Sa,{act:t,title:"Choose the social image",onClose:()=>v(!1),onPick:C=>{c({...l,socialImage:C.publicPath}),v(!1)}}),e("button",{type:"button",class:"page-metadata-toggle","aria-expanded":d,onClick:()=>m(!d),children:[e($,{name:"braces",size:15}),e("span",{children:"Page metadata"}),e("small",{children:"Title, description, icon, canonical URL, social image"}),e($,{name:d?"chevronUp":"chevronDown",size:15})]}),d&&(s?s.editable?e("div",{class:"page-metadata-body",children:[e("div",{class:"form-grid",children:[e(U,{label:"Title",children:e(re,{value:l.title,maxlength:160,onInput:C=>c({...l,title:C.currentTarget.value})})}),e(U,{label:"Sidebar icon",hint:"An icon name or a single emoji",children:e(re,{value:l.icon,placeholder:"compass",onInput:C=>c({...l,icon:C.currentTarget.value})})}),e(U,{label:"Description",hint:"One outcome-focused sentence; shown in search results and page cards",wide:!0,children:e(en,{rows:2,maxlength:320,value:l.description,onInput:C=>c({...l,description:C.currentTarget.value})})}),e(U,{label:"Canonical URL",hint:"Only when this page is also published elsewhere",children:e(re,{value:l.canonical,placeholder:"https://docs.example.com/guides/install",onInput:C=>c({...l,canonical:C.currentTarget.value})})}),e(U,{label:"Social image",hint:"Shown when the page is shared. PNG or JPEG, 1200×630 works best.",children:e("span",{class:"asset-field",children:[e(re,{"aria-label":"Social image",value:l.socialImage,placeholder:"/assets/social.png",onInput:C=>c({...l,socialImage:C.currentTarget.value})}),e(_,{size:"sm",onClick:()=>v(!0),children:"Choose…"})]})})]}),s.otherKeys.length>0&&e("small",{class:"page-metadata-other",children:["Other frontmatter kept as is: ",s.otherKeys.join(", "),"."]}),e("div",{class:"form-actions",children:[e(_,{size:"sm",tone:"ghost",disabled:P.length===0,onClick:()=>c(y),children:"Discard"}),e(_,{size:"sm",tone:"primary",busy:r,disabled:P.length===0,onClick:()=>{k()},children:"Save metadata"})]})]}):e(Te,{children:s.reason}):e("div",{class:"page-list-empty",children:[e("span",{class:"spinner"}),"Loading metadata…"]}))]})}function ac({value:n,onChange:t,disabled:i}){const a=(s,o)=>t(n.map((l,c)=>c===s?{...l,...o}:l));return e("div",{class:"terms-editor",children:[n.length===0&&e("p",{class:"terms-empty",children:"No terms yet. Add the product vocabulary readers must recognise, with the meaning or preferred wording."}),n.map((s,o)=>e("div",{class:"terms-row",children:[e(re,{"aria-label":`Term ${o+1}`,value:s.term,placeholder:"Workspace",disabled:i,onInput:l=>a(o,{term:l.currentTarget.value})}),e(re,{"aria-label":`Definition for term ${o+1}`,value:s.definition,placeholder:"A shared container for projects, members, and billing.",disabled:i,onInput:l=>a(o,{definition:l.currentTarget.value})}),e("button",{type:"button","aria-label":`Remove term ${o+1}`,disabled:i,onClick:()=>t(n.filter((l,c)=>c!==o)),children:e($,{name:"close",size:14})})]},o)),e(_,{size:"sm",icon:"plus",disabled:i,onClick:()=>t([...n,{term:"",definition:""}]),children:"Add term"})]})}function rc(n){return Object.entries(n).map(([t,i])=>({term:t,definition:i}))}function pr(n){const t={};for(const i of n){const a=i.term.trim();a&&i.definition.trim()&&(t[a]=i.definition.trim())}return t}function sc({act:n,onError:t,onOpenPage:i,unsavedTerms:a}){const[s,o]=p(),[l,c]=p(!1),d=async()=>{try{o(await _e("/api/glossary"))}catch(g){t(g instanceof Error?g.message:String(g))}};ae(()=>{d()},[]);const m=async(g=!1)=>{c(!0);try{const u=await n(()=>K("/api/glossary/generate",{replace:g}),"Glossary page generated",!1);u&&o(u)}finally{c(!1)}},r=s?.terms?.length??0;return e(Ue,{title:"Glossary page",description:"A reader-facing glossary generated from the terminology above, added to the navigation and kept out of the agent's way.",children:s?e("div",{class:"glossary-panel",children:[e("div",{class:"glossary-status",children:[e("span",{class:`glossary-mark ${s.page?"ready":""}`,children:e($,{name:"book",size:18})}),e("div",{children:[e("strong",{children:s.page?s.generated?"Glossary page is generated":"A hand-written glossary exists":"No glossary page yet"}),e("small",{children:[r," term",r===1?"":"s"," available",s.fromPlan?` (${s.fromPlan} from the current plan)`:"",s.page?` · ${s.page}`:""]})]})]}),a&&e(Te,{tone:"warn",children:"Save the terminology above first so the page reflects your latest edits."}),s.page&&!s.generated&&e(Te,{tone:"warn",children:[s.page," was not generated by Doxloop. Regenerating replaces it with the terminology map."]}),e("div",{class:"form-actions",children:[s.page&&e(_,{size:"sm",icon:"file",onClick:()=>i(s.page),children:"Open page"}),e(_,{size:"sm",tone:"primary",icon:"sparkles",busy:l,disabled:r===0||a,onClick:()=>{m(!!(s.page&&!s.generated))},children:s.page?"Regenerate glossary":"Generate glossary page"})]})]}):e("div",{class:"page-list-empty",children:[e("span",{class:"spinner"}),"Checking the glossary…"]})})}function oc({sources:n,value:t,onChange:i,disabled:a}){const[s,o]=p(),[l,c]=p(""),d=t.source||n[0]||"";ae(()=>{if(!d)return;let r=!0;return c(""),_e(`/api/sources/refs?source=${encodeURIComponent(d)}`).then(g=>{r&&(o(g),!t.from&&!t.to&&g.suggested?i({source:d,version:t.version||g.suggested.version.replace(/ \(unreleased changes\)$/,""),from:g.suggested.from,to:g.suggested.to}):t.source!==d&&i({...t,source:d}))}).catch(g=>{r&&c(g.message)}),()=>{r=!1}},[d]);const m=[...s?.tags??[],...s?.branches??[],"HEAD"].map(r=>[r,r]);return e("section",{class:"release-template","aria-label":"Release notes inputs",children:[e("header",{children:[e("span",{children:e($,{name:"calendar",size:17})}),e("div",{children:[e("h2",{children:"Which release?"}),e("p",{children:"Doxloop reads the commits and changed files between two refs of the product repository, plus its changelog, and hands them to the planner as the only evidence for the release page."})]})]}),e("div",{class:"form-grid",children:[n.length>1&&e(U,{label:"Repository",children:e(Fe,{value:d,disabled:a,onChange:r=>i({source:r.currentTarget.value,version:t.version,from:"",to:""}),children:n.map(r=>e("option",{value:r,children:r},r))})}),e(U,{label:"Version",hint:"The label readers see, such as v0.2.0",children:e(re,{value:t.version,disabled:a,placeholder:s?.suggested?.version??"v1.2.0",onInput:r=>i({...t,source:d,version:r.currentTarget.value})})}),e(U,{label:"From",hint:"The previous release tag or commit",children:e(it,{value:t.from,options:m,disabled:a??!1,placeholder:s?.tags[1]??"Previous tag",onValueChange:r=>i({...t,source:d,from:r})})}),e(U,{label:"To",hint:"The release tag, branch, or HEAD",children:e(it,{value:t.to,options:m,disabled:a??!1,placeholder:s?.tags[0]??"HEAD",onValueChange:r=>i({...t,source:d,to:r})})})]}),l&&e(Te,{tone:"bad",children:l}),s&&s.tags.length===0&&e(Te,{children:"The repository has no tags, so use commit hashes or branch names for the range."}),s&&e("small",{class:"release-refs-hint",children:[s.tags.length," tag",s.tags.length===1?"":"s"," · HEAD ",s.head]})]})}let hr=0;function Hn(n="nav"){return hr+=1,`${n}-${hr}`}function yi(n){return n.map(t=>{if(t.type==="group"){const{items:i,...a}=t;return{id:Hn(),node:a,children:yi(i??[])}}return{id:Hn(),node:t}})}function wi(n){return n.map(t=>{if(t.node.type==="group")return{...t.node,items:wi(t.children??[])};if(t.node.type==="page"){const{path:i,pageTitle:a,...s}=t.node;return s}return t.node})}function rn(n,t,i=null,a=0){for(const[s,o]of n.entries()){if(o.id===t)return{item:o,siblings:n,index:s,parentId:i,depth:a};if(o.children){const l=rn(o.children,t,o.id,a+1);if(l)return l}}}function ni(n,t=0,i=null){const a=[];for(const s of n)a.push({item:s,depth:t,parentId:i}),s.children&&a.push(...ni(s.children,t+1,s.id));return a}function _s(n,t){return n.id===t||(n.children?.some(i=>_s(i,t))??!1)}function ti(n,t){return n.filter(i=>i.id!==t).map(i=>i.children?{...i,children:ti(i.children,t)}:i)}function $a(n,t,i,a){if(i===null){const s=[...n];return s.splice(gr(a,0,s.length),0,t),s}return n.map(s=>{if(s.id===i){const o=[...s.children??[]];return o.splice(gr(a,0,o.length),0,t),{...s,children:o}}return s.children?{...s,children:$a(s.children,t,i,a)}:s})}function Yt(n,t,i){return n.map(a=>a.id===t?i(a):a.children?{...a,children:Yt(a.children,t,i)}:a)}function _t(n,t,i,a){const s=rn(n,t);if(!s||i!==null&&_s(s.item,i)||i!==null&&rn(n,i)?.item.node.type!=="group")return n;let o=a;return s.parentId===i&&s.index<a&&(o-=1),$a(ti(n,t),s.item,i,o)}function ut(n,t,i){const a=rn(n,t);if(!a)return n;const s=a.index+i;return s<0||s>=a.siblings.length?n:_t(n,t,a.parentId,i>0?s+1:s)}function Mi(n,t){const i=rn(n,t);if(!i)return n;const a=i.siblings[i.index-1];return!a||a.node.type!=="group"?n:_t(n,t,a.id,a.children?.length??0)}function Li(n,t){const i=rn(n,t);if(!i||i.parentId===null)return n;const a=rn(n,i.parentId);return a?_t(n,t,a.parentId,a.index+1):n}function Ss(n,t){const i=rn(n,t);if(!i||i.item.node.type!=="group")return n;const a=i.item.children??[];let s=ti(n,t);return a.forEach((o,l)=>{s=$a(s,o,i.parentId,i.index+l)}),s}function lc(n){const t=[];for(const{item:i}of ni(n))i.node.type==="page"&&t.push(i.node.file);return t}function cc(n){return ni(n).reduce((t,i)=>Math.max(t,i.depth+1),0)}function Fn(n){const t=n.node;switch(t.type){case"page":return t.title||t.pageTitle||dc(t.file);case"group":return t.label;case"label":return t.text;case"divider":return"Divider";case"link":return t.title;case"api":return t.title}}function dc(n){return n.split("/").at(-1).replace(/\.[^.]+$/,"").replace(/[-_]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function Zi(n,t){const i=new Map(t.map(o=>[o.id,o])),a=new Set;return{items:n.sections.map(o=>({id:Hn("section"),node:{type:"group",label:o.title},sectionId:o.id,children:o.pageIds.flatMap(l=>{const c=i.get(l);return!c||a.has(l)?[]:(a.add(l),[{id:Hn("plan"),node:{type:"page",file:c.id,title:c.title,path:c.path}}])})})),unsectioned:t.filter(o=>!a.has(o.id))}}function uc(n,t){const i=[],a=[],s=new Set;for(const o of n)if(o.node.type==="group"){const l=o.sectionId??hc(o.node.label);let c=l;for(let d=2;s.has(c);d+=1)c=`${l}-${d}`;s.add(c),i.push({id:c,title:o.node.label,pageIds:lc(o.children??[])})}else o.node.type==="page"&&a.push(o.node.file);return a.length>0&&i.push({id:s.has("documentation")?"documentation-pages":"documentation",title:"Documentation",pageIds:a}),{top:t,sections:i.filter(o=>o.pageIds.length>0)}}function pc(n){return{id:Hn("plan"),node:{type:"page",file:n.id,title:n.title,path:n.path}}}function hc(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"section"}function gr(n,t,i){return Math.min(i,Math.max(t,n))}function $s({items:n,onChange:t,supports:i,icons:a,editable:s,requiresEveryPage:o,orphans:l,maxDepth:c,emptyLabel:d,onSelectPage:m,activePath:r,rowClass:g,rowMeta:u,onOpenItem:v,childNoun:h="item"}){const[y,P]=p(),[k,C]=p(),[w,I]=p(),[L,D]=p(!1),E=Re(null),A=ni(n),j=y?rn(n,y):void 0,W=c??Number.POSITIVE_INFINITY;ae(()=>{y&&!rn(n,y)&&P(void 0)},[n,y]);const O=x=>{x!==n&&t(x)},ue=x=>E.current?.querySelector(`[data-nav-item="${x}"]`)?.focus(),ge=(x,B)=>B+cc([x])<=W,fe=x=>{const B=rn(n,x),F=B?.siblings[B.index-1];return!!(B&&F&&F.node.type==="group"&&ge(B.item,B.depth))},ye=x=>(rn(n,x)?.parentId??null)!==null,ce=x=>x.node.type!=="page"||!o,se=()=>{const x={id:Hn("group"),node:{type:"group",label:"New section"},children:[]};O([...n,x]),P(x.id)},G=x=>{const B={id:Hn(),node:x};O([...n,B]),P(B.id)},H=x=>{const B={id:Hn("page"),node:{type:"page",file:x.file,path:x.path,pageTitle:x.title}},F=j&&j.item.node.type==="group"?j.item.id:null,T=F?Yt(n,F,Z=>({...Z,children:[...Z.children??[],B]})):[...n,B];O(T),D(!1)},N=x=>{const B=rn(n,x);B&&(B.item.node.type==="group"&&(B.item.children?.length??0)>0?O(Ss(n,x)):O(ti(n,x)),y===x&&P(void 0))},oe=(x,B)=>{if(x.target instanceof HTMLInputElement||x.target instanceof HTMLSelectElement)return;const F=A.findIndex(T=>T.item.id===B);if(x.key==="ArrowDown"&&!x.altKey){x.preventDefault();const T=A[F+1];T&&ue(T.item.id)}else if(x.key==="ArrowUp"&&!x.altKey){x.preventDefault();const T=A[F-1];T&&ue(T.item.id)}else if(s){if(x.altKey&&x.key==="ArrowDown")x.preventDefault(),O(ut(n,B,1)),requestAnimationFrame(()=>ue(B));else if(x.altKey&&x.key==="ArrowUp")x.preventDefault(),O(ut(n,B,-1)),requestAnimationFrame(()=>ue(B));else if(x.altKey&&x.key==="ArrowRight")x.preventDefault(),fe(B)&&O(Mi(n,B)),requestAnimationFrame(()=>ue(B));else if(x.altKey&&x.key==="ArrowLeft")x.preventDefault(),O(Li(n,B)),requestAnimationFrame(()=>ue(B));else if(x.key==="Enter"||x.key===" "){x.preventDefault();const T=v&&rn(n,B)?.item;T&&T.node.type==="page"?v(T):P(y===B?void 0:B)}else if(x.key==="Delete"||x.key==="Backspace"){const T=rn(n,B)?.item;T&&ce(T)&&(x.preventDefault(),N(B))}}else return},Ce=(x,B,F)=>{const T=x.currentTarget.getBoundingClientRect(),Z=(x.clientY-T.top)/Math.max(T.height,1);return F&&Z>.3&&Z<.7?"into":Z<.5?"before":"after"},ee=(x,B)=>{if(!k||k===x)return;const F=rn(n,x);if(!F)return;const T=rn(n,k);if(T){if(B==="into"&&ge(T.item,F.depth)){O(_t(n,k,x,F.item.children?.length??0));return}ge(T.item,F.depth-1)&&O(_t(n,k,F.parentId,F.index+(B==="after"||B==="into"?1:0)))}},Q=(x,B)=>x.map(F=>{const T=F.node,Z=T.type==="group",Y=y===F.id,pe=w?.id===F.id?w.position:void 0;return e("div",{class:`nav-tree-branch depth-${Math.min(B,3)}`,children:[e("div",{class:`nav-tree-row ${Y?"active":""} ${k===F.id?"dragging":""} ${pe?`drop-${pe}`:""} type-${T.type} ${g?.(F)??""}`,"data-nav-item":F.id,role:"treeitem","aria-level":B+1,"aria-selected":Y,"aria-current":T.type==="page"&&T.path===r?"page":void 0,"aria-expanded":Z?!0:void 0,tabIndex:0,draggable:s,onClick:()=>{v&&T.type==="page"?v(F):P(Y?void 0:F.id)},onKeyDown:te=>oe(te,F.id),onDragStart:te=>{s&&(C(F.id),te.dataTransfer?.setData("text/plain",F.id),te.dataTransfer&&(te.dataTransfer.effectAllowed="move"))},onDragEnd:()=>{C(void 0),I(void 0)},onDragOver:te=>{if(!k||k===F.id)return;te.preventDefault();const M=Ce(te,F.id,Z);(w?.id!==F.id||w.position!==M)&&I({id:F.id,position:M})},onDragLeave:()=>{w?.id===F.id&&I(void 0)},onDrop:te=>{te.preventDefault();const M=w?.id===F.id?w.position:Ce(te,F.id,Z);ee(F.id,M),C(void 0),I(void 0)},children:[e("span",{class:"nav-tree-handle","aria-hidden":"true",children:e($,{name:"menu",size:14})}),e("span",{class:"nav-tree-icon",children:e($,{name:fc(F),size:15})}),e("span",{class:"nav-tree-label",children:[e("strong",{children:Fn(F)}),T.type==="page"&&e("code",{children:T.path??T.file}),T.type==="link"&&e("code",{children:T.href}),T.type==="api"&&e("code",{children:T.spec}),T.type==="group"&&e("small",{children:[F.children?.length??0," ",h,(F.children?.length??0)===1?"":"s"]})]}),u?.(F),"hidden"in T&&T.hidden&&e("span",{class:"nav-tree-flag",children:"Hidden"}),s&&e("span",{class:"nav-tree-actions",onClick:te=>te.stopPropagation(),children:[e("button",{type:"button","aria-label":`Move ${Fn(F)} up`,title:"Move up (Alt+↑)",onClick:()=>O(ut(n,F.id,-1)),children:e($,{name:"chevronUp",size:14})}),e("button",{type:"button","aria-label":`Move ${Fn(F)} down`,title:"Move down (Alt+↓)",onClick:()=>O(ut(n,F.id,1)),children:e($,{name:"chevronDown",size:14})}),e("button",{type:"button","aria-label":`Move ${Fn(F)} into the section above`,title:"Move into the section above (Alt+→)",disabled:!fe(F.id),onClick:()=>O(Mi(n,F.id)),children:e($,{name:"chevronRight",size:14})}),e("button",{type:"button","aria-label":`Move ${Fn(F)} out of its section`,title:"Move out of the section (Alt+←)",disabled:!ye(F.id),onClick:()=>O(Li(n,F.id)),children:e($,{name:"chevronLeft",size:14})}),e("button",{type:"button",class:"danger","aria-label":Z?`Ungroup ${Fn(F)}`:`Remove ${Fn(F)} from navigation`,title:Z?"Ungroup":"Remove from navigation",disabled:!ce(F),onClick:()=>N(F.id),children:e($,{name:Z?"columns":"close",size:14})})]})]}),Y&&T.type==="page"&&T.path&&m&&e(_,{size:"sm",class:"nav-open-page",icon:"file",onClick:()=>m(T.path),children:"Open page"}),Y&&s&&e(gc,{item:F,supports:i,icons:a,requiresEveryPage:o,onChange:te=>O(Yt(n,F.id,M=>({...M,node:{...M.node,...te}})))}),Z&&e("div",{class:"nav-tree-children",role:"group",children:Q(F.children??[],B+1)})]},F.id)});return e("div",{class:"nav-tree-editor",children:[s&&e("div",{class:"nav-tree-toolbar",role:"toolbar","aria-label":"Add navigation items",children:[e(_,{size:"sm",icon:"folder",onClick:se,children:"Add section"}),l.length>0&&e(_,{size:"sm",icon:"plus",class:L?"active-filter":"","aria-expanded":L,onClick:()=>D(!L),children:["Add page",j?.item.node.type==="group"?` to ${Fn(j.item)}`:""]}),i.labels&&e(_,{size:"sm",onClick:()=>G({type:"label",text:"Section label"}),children:"Add label"}),i.dividers&&e(_,{size:"sm",onClick:()=>G({type:"divider"}),children:"Add divider"}),i.links&&e(_,{size:"sm",icon:"link",onClick:()=>G({type:"link",title:"External link",href:"https://"}),children:"Add link"}),e("small",{children:"Drag rows to reorder, or focus a row and use Alt with the arrow keys."})]}),L&&l.length>0&&e("div",{class:"nav-tree-orphans","aria-label":"Pages not in navigation",children:l.map(x=>e("button",{type:"button",onClick:()=>H(x),children:[e($,{name:"file",size:14}),e("span",{children:[e("strong",{children:x.title}),e("code",{children:x.path})]}),e("b",{children:"Add"})]},x.path))}),e("div",{ref:E,class:"nav-tree",role:"tree","aria-label":"Navigation",onDragOver:x=>{k&&x.target===E.current&&x.preventDefault()},onDrop:x=>{k&&x.target===E.current&&(x.preventDefault(),O(_t(n,k,null,n.length)),C(void 0),I(void 0))},children:n.length===0?e("div",{class:"nav-tree-empty",children:d??"No navigation items yet. Add a section, then add pages to it."}):Q(n,0)})]})}function gc({item:n,supports:t,icons:i,requiresEveryPage:a,onChange:s}){const o=n.node,l=t.icons&&(o.type==="page"||o.type==="group"||o.type==="link"||o.type==="api"),c=t.hidden&&(o.type==="page"||o.type==="group");return e("div",{class:"nav-tree-details",onClick:d=>d.stopPropagation(),children:[o.type==="page"&&e("label",{class:"field",children:[e("span",{class:"field-label",children:"Label in navigation"}),e(re,{value:o.title??"",placeholder:o.pageTitle??"Page title",onInput:d=>s({title:d.currentTarget.value||void 0})}),e("small",{children:["Leave empty to use the page title",o.pageTitle?` “${o.pageTitle}”`:"","."]})]}),o.type==="group"&&e("label",{class:"field",children:[e("span",{class:"field-label",children:"Section name"}),e(re,{value:o.label,onInput:d=>s({label:d.currentTarget.value})})]}),o.type==="label"&&e("label",{class:"field",children:[e("span",{class:"field-label",children:"Label text"}),e(re,{value:o.text,onInput:d=>s({text:d.currentTarget.value})})]}),(o.type==="link"||o.type==="api")&&e("label",{class:"field",children:[e("span",{class:"field-label",children:"Title"}),e(re,{value:o.title,onInput:d=>s({title:d.currentTarget.value})})]}),o.type==="link"&&e("label",{class:"field",children:[e("span",{class:"field-label",children:"Address"}),e(re,{value:o.href,placeholder:"https://",onInput:d=>s({href:d.currentTarget.value})})]}),l&&e("label",{class:"field",children:[e("span",{class:"field-label",children:"Icon"}),e(Fe,{value:"icon"in o&&o.icon||"",onChange:d=>s({icon:d.currentTarget.value||void 0}),children:[e("option",{value:"",children:"None"}),i.map(d=>e("option",{value:d,children:d},d))]})]}),c&&e("div",{class:"nav-tree-hidden",children:[e(jt,{checked:!!("hidden"in o&&o.hidden),onChange:d=>s({hidden:d||void 0}),label:"Hidden from the sidebar"}),e("small",{children:a&&o.type==="page"?"The page stays reachable by link and in search.":"Hidden items are kept but not shown."})]})]})}function fc(n){switch(n.node.type){case"group":return"folder";case"page":return"file";case"link":return"link";case"api":return"api";case"label":return"list";case"divider":return"minus"}}function fr({items:n,onChange:t,supports:i,icons:a,editable:s,requiresEveryPage:o,orphans:l,onSelectPage:c,activePath:d,selectedPaths:m=[],onTogglePage:r}){const[g,u]=p(new Set),[v,h]=p(),[y,P]=p(),[k,C]=p(),[w,I]=p(""),[L,D]=p(!1),[E,A]=p(),[j,W]=p(),O=Re(null),ue=Re(!1),ge=T=>T.flatMap(Z=>[Z,...!g.has(Z.id)&&Z.children?ge(Z.children):[]]),fe=ge(n),ye=T=>{h(T),O.current?.querySelector(`[data-nav-item="${T}"]`)?.focus()},ce=T=>{s&&T!==n&&t(T)},se=(T,Z)=>ce(Yt(n,T,Y=>({...Y,node:{...Y.node,...Z}}))),G=T=>u(Z=>{const Y=new Set(Z);return Y.has(T)?Y.delete(T):Y.add(T),Y}),H=(T,Z=!1)=>{h(T.id),T.node.type==="page"&&T.node.path?Z&&r?r(T.node.path):T.node.path!==d&&c?.(T.node.path):T.node.type==="group"&&G(T.id)},N=(T,Z=!1)=>{!s||T.node.type==="divider"||(ue.current=!1,C(void 0),P({id:T.id,text:Z&&T.node.type==="link"?T.node.href:Fn(T),...Z?{address:Z}:{}}))},oe=()=>{if(!y||ue.current)return;ue.current=!0;const T=rn(n,y.id)?.item,Z=y.text.trim();T&&(Z||T.node.type==="page")&&se(T.id,y.address?{href:Z}:T.node.type==="group"?{label:Z}:T.node.type==="label"?{text:Z}:{title:Z||void 0}),P(void 0)},Ce=T=>{I(""),C({id:T,kind:"icon"})};ae(()=>{if(!k&&!L)return;O.current?.querySelector(".explorer-popover input, .explorer-popover button")?.focus();const T=Z=>{(!(Z.target instanceof Element)||!Z.target.closest(".explorer-popover, .explorer-icon, .explorer-more, .explorer-add"))&&(C(void 0),D(!1))};return document.addEventListener("pointerdown",T),()=>document.removeEventListener("pointerdown",T)},[k,L]),ae(()=>{s||(C(void 0),D(!1))},[s]);const ee=(T,Z)=>{if(T.target!==T.currentTarget)return;const Y=fe.findIndex(pe=>pe.id===Z.id);if(T.key==="F2")T.preventDefault(),N(Z);else if(T.key==="ContextMenu"||T.shiftKey&&T.key==="F10")T.preventDefault(),C({id:Z.id,kind:"menu"});else if(T.altKey&&T.key.startsWith("Arrow"))T.preventDefault(),T.key==="ArrowDown"&&ce(ut(n,Z.id,1)),T.key==="ArrowUp"&&ce(ut(n,Z.id,-1)),T.key==="ArrowRight"&&ce(Mi(n,Z.id)),T.key==="ArrowLeft"&&ce(Li(n,Z.id)),ye(Z.id);else if(T.key==="ArrowDown"||T.key==="ArrowUp"){T.preventDefault();const pe=fe[Y+(T.key==="ArrowDown"?1:-1)];pe&&ye(pe.id)}else if(T.key==="ArrowRight"&&Z.node.type==="group")T.preventDefault(),g.has(Z.id)?G(Z.id):Z.children?.[0]&&ye(Z.children[0].id);else if(T.key==="ArrowLeft")if(T.preventDefault(),Z.node.type==="group"&&!g.has(Z.id))G(Z.id);else{const pe=rn(n,Z.id)?.parentId;pe&&ye(pe)}else T.key==="Enter"?(T.preventDefault(),H(Z)):T.key===" "&&Z.node.type==="page"&&(T.preventDefault(),Z.node.path&&r?.(Z.node.path))},Q=T=>{const Z={id:Hn(),node:T==="group"?{type:T,label:"New section"}:T==="label"?{type:T,text:"New label"}:T==="link"?{type:T,title:"New link",href:"https://"}:{type:T},...T==="group"?{children:[]}:{}};ce([...n,Z]),D(!1),T!=="divider"&&N(Z)},x=T=>{ce(T.node.type==="group"?Ss(n,T.id):ti(n,T.id)),C(void 0)},B=(T,Z)=>{const Y=T.currentTarget.getBoundingClientRect(),pe=(T.clientY-Y.top)/Y.height;return Z.node.type==="group"&&pe>.25&&pe<.75?"into":pe<.5?"before":"after"},F=(T,Z=0)=>T.map(Y=>{const pe=Y.node,te=Fn(Y),M=pe.type==="page"&&pe.path===d,ne=y?.id===Y.id,xe="icon"in pe&&pe.icon?pe.icon:pe.type==="group"?"folder":pe.type==="link"?"link":pe.type==="divider"?"minus":"file",Ie=s&&i.icons&&["page","group","link","api"].includes(pe.type),X="hidden"in pe&&pe.hidden;return e("div",{class:"explorer-branch",children:[e("div",{role:"treeitem","aria-level":Z+1,"aria-expanded":pe.type==="group"?!g.has(Y.id):void 0,"aria-selected":pe.type==="page"?m.includes(pe.path??""):v===Y.id,"aria-current":M?"page":void 0,tabIndex:v===Y.id||!v&&(M||Y===fe[0])?0:-1,"data-nav-item":Y.id,class:`explorer-row ${M?"current":""} ${X?"is-hidden":""} ${j?.id===Y.id?`drop-${j.position}`:""}`,style:{paddingLeft:`${8+Z*14}px`},title:pe.type==="page"?pe.path??pe.file:te,draggable:s&&!ne,onClick:J=>{ne||H(Y,J.metaKey||J.ctrlKey)},onDblClick:J=>{J.preventDefault(),N(Y)},onKeyDown:J=>ee(J,Y),onFocus:()=>h(Y.id),onContextMenu:J=>{s&&(J.preventDefault(),C({id:Y.id,kind:"menu"}),h(Y.id))},onDragStart:J=>{A(Y.id),C(void 0),J.dataTransfer?.setData("text/plain",Y.id),J.dataTransfer&&(J.dataTransfer.effectAllowed="move")},onDragEnd:()=>{A(void 0),W(void 0)},onDragOver:J=>{!s||!E||E===Y.id||(J.preventDefault(),W({id:Y.id,position:B(J,Y)}))},onDragLeave:()=>W(void 0),onDrop:J=>{if(J.preventDefault(),s&&E&&E!==Y.id){const Ae=rn(n,Y.id),Be=B(J,Y);ce(_t(n,E,Be==="into"?Y.id:Ae.parentId,Be==="into"?Y.children?.length??0:Ae.index+(Be==="after"?1:0))),Be==="into"&&u(ke=>{const Ke=new Set(ke);return Ke.delete(Y.id),Ke})}A(void 0),W(void 0)},children:[pe.type==="group"?e("button",{class:"explorer-chevron","aria-label":`${g.has(Y.id)?"Expand":"Collapse"} ${te}`,onClick:J=>{J.stopPropagation(),G(Y.id)},onDblClick:J=>J.stopPropagation(),children:e($,{name:g.has(Y.id)?"chevronRight":"chevronDown",size:12})}):e("span",{class:"explorer-chevron"}),Ie?e("button",{class:"explorer-icon","aria-label":`Change icon for ${te}`,title:"Change icon","aria-expanded":k?.id===Y.id&&k.kind==="icon",onClick:J=>{J.stopPropagation(),Ce(Y.id)},onDblClick:J=>J.stopPropagation(),children:e(Qi,{name:xe})}):e("span",{class:"explorer-icon",children:e(Qi,{name:xe})}),ne?e("input",{class:"explorer-rename","aria-label":y.address?"Link address":`Rename ${te}`,ref:J=>{J&&document.activeElement!==J&&(J.focus(),J.select())},value:y.text,maxLength:y.address?2e3:120,onClick:J=>J.stopPropagation(),onDblClick:J=>J.stopPropagation(),onInput:J=>P({...y,text:J.currentTarget.value}),onBlur:oe,onKeyDown:J=>{J.stopPropagation(),J.key==="Enter"&&(J.preventDefault(),oe(),ye(Y.id)),J.key==="Escape"&&(J.preventDefault(),ue.current=!0,P(void 0),ye(Y.id))}}):e("span",{class:"explorer-label",children:te}),X&&e("span",{title:"Hidden from navigation",children:e($,{name:"eyeOff",size:13})}),pe.type==="page"&&r&&e("input",{class:"explorer-select",type:"checkbox",checked:m.includes(pe.path??""),"aria-label":`Select ${pe.pageTitle??te}`,onClick:J=>J.stopPropagation(),onChange:()=>pe.path&&r(pe.path)}),s&&e("button",{class:"explorer-more","aria-label":`Actions for ${te}`,title:"More actions","aria-expanded":k?.id===Y.id&&k.kind==="menu",onClick:J=>{J.stopPropagation(),C({id:Y.id,kind:"menu"})},onDblClick:J=>J.stopPropagation(),children:"⋯"})]}),k?.id===Y.id&&e("div",{class:"explorer-popover",role:k.kind==="icon"?"dialog":"menu","aria-label":k.kind==="icon"?`Choose icon for ${te}`:`Actions for ${te}`,onKeyDown:J=>{J.key==="Escape"&&(J.stopPropagation(),C(void 0),ye(Y.id))},children:k.kind==="icon"?e(ie,{children:[e("input",{autoFocus:!0,"aria-label":"Search icons",placeholder:"Search icons…",value:w,onInput:J=>I(J.currentTarget.value)}),e("div",{class:"explorer-icon-grid",children:a.filter(J=>J.includes(w.toLowerCase())).map(J=>e("button",{title:J,"aria-label":`Use ${J} icon`,"aria-pressed":xe===J,onClick:()=>{se(Y.id,{icon:J}),C(void 0),ye(Y.id)},children:e(Qi,{name:J})}))}),e("button",{onClick:()=>{se(Y.id,{icon:void 0}),C(void 0),ye(Y.id)},children:"Use default icon"})]}):e(ie,{children:[pe.type!=="divider"&&e("button",{role:"menuitem",onClick:()=>N(Y),children:["Rename",e("span",{children:"F2"})]}),pe.type==="link"&&e("button",{role:"menuitem",onClick:()=>N(Y,!0),children:"Edit link address"}),e("button",{role:"menuitem",onClick:()=>{ce(ut(n,Y.id,-1)),C(void 0)},children:["Move up",e("span",{children:"Alt ↑"})]}),e("button",{role:"menuitem",onClick:()=>{ce(ut(n,Y.id,1)),C(void 0)},children:["Move down",e("span",{children:"Alt ↓"})]}),e("button",{role:"menuitem",onClick:()=>{ce(Mi(n,Y.id)),C(void 0)},children:["Indent",e("span",{children:"Alt →"})]}),e("button",{role:"menuitem",onClick:()=>{ce(Li(n,Y.id)),C(void 0)},children:["Outdent",e("span",{children:"Alt ←"})]}),i.hidden&&["page","group"].includes(pe.type)&&e("button",{role:"menuitem",onClick:()=>{se(Y.id,{hidden:!X||void 0}),C(void 0)},children:X?"Show in navigation":"Hide from navigation"}),(pe.type!=="page"||!o)&&e("button",{role:"menuitem",onClick:()=>x(Y),children:pe.type==="group"?"Ungroup section":"Remove from navigation"})]})}),pe.type==="group"&&!g.has(Y.id)&&e("div",{role:"group",children:F(Y.children??[],Z+1)})]},Y.id)});return e("div",{class:"navigation-explorer",ref:O,children:[e("div",{class:"explorer-tools",children:[e("span",{children:"Click to open · F2 to rename"}),s&&e("button",{class:"explorer-add",title:"Add navigation item","aria-label":"Add navigation item","aria-expanded":L,onClick:()=>D(!L),children:e($,{name:"plus",size:15})})]}),L&&e("div",{class:"explorer-popover explorer-add-menu",role:"menu","aria-label":"Add navigation item",children:[e("button",{role:"menuitem",onClick:()=>Q("group"),children:"New section"}),i.links&&e("button",{role:"menuitem",onClick:()=>Q("link"),children:"New link"}),i.labels&&e("button",{role:"menuitem",onClick:()=>Q("label"),children:"New label"}),i.dividers&&e("button",{role:"menuitem",onClick:()=>Q("divider"),children:"New divider"}),l.map(T=>e("button",{role:"menuitem",onClick:()=>{ce([...n,{id:Hn(),node:{type:"page",file:T.file,path:T.path,pageTitle:T.title}}]),D(!1)},children:["Add ",T.title]}))]}),e("div",{role:"tree","aria-label":"Navigation","aria-multiselectable":"true",children:[F(n),!n.length&&e("p",{class:"explorer-empty",children:"Add a section or page with +."})]}),l.length>0&&e("div",{class:"explorer-unlisted",children:[e("span",{children:"Not in navigation"}),l.map(T=>e("button",{onClick:()=>c?.(T.path),children:[e($,{name:"file",size:15}),T.title]}))]})]})}function Qi({name:n}){return/[^\w-]/.test(n)?e("span",{class:"navigation-emoji","aria-hidden":"true",children:n}):e($,{name:n,size:16})}function mc({act:n,onError:t,previewUrl:i,embedded:a=!1,onStatus:s,onSaved:o,onSelectPage:l,activePath:c,selectedPaths:d,onTogglePage:m,pages:r=[],refreshToken:g}){const[u,v]=p(),[h,y]=p([]),[P,k]=p(0),[C,w]=p(!1),[I,L]=p(""),[D,E]=p(""),[A,j]=p(i),[W,O]=p(0),[ue,ge]=p(!1),fe=async(Q=0)=>{E("");const x=setTimeout(()=>ge(!0),6e3);try{const B=await _e("/api/navigation",{signal:AbortSignal.timeout(2e4)}),F={...B,spaces:B.spaces??[],orphans:B.orphans??[],icons:B.icons??[],supports:B.supports??{icons:!1,hidden:!1,labels:!1,links:!1,dividers:!1,spaces:!1}};v(F),y(F.spaces.map(T=>({name:T.name,...T.version?{version:T.version}:{},items:yi(T.nav)}))),L("")}catch(B){if(Q===0)return clearTimeout(x),await new Promise(F=>setTimeout(F,1500)),await fe(1);E(B instanceof Error?B.message:String(B))}finally{clearTimeout(x),ge(!1)}};ae(()=>{a||A||!u?.editable||K("/api/preview/start",{open:!1}).then(Q=>j(Q.url)).catch(()=>{})},[u?.editable,A]);const ye=Ai(()=>JSON.stringify(u?.spaces.map(Q=>({name:Q.name,...Q.version?{version:Q.version}:{},nav:Q.nav.map(Ps)}))??[]),[u]),ce=JSON.stringify(h.map(Q=>({name:Q.name,...Q.version?{version:Q.version}:{},nav:wi(Q.items)}))),se=!!u&&ce!==ye;ae(()=>{!se&&!C&&fe()},[g]),ae(()=>{const Q=B=>ni(B.items).some(({item:F})=>F.node.type==="page"&&F.node.path===c);if(h[P]&&Q(h[P]))return;const x=h.findIndex(Q);x>=0&&k(x)},[c,h.length]),Ii(()=>{s?.(se,C)},[se,C]),ae(()=>{const Q=x=>{(se||C)&&(x.preventDefault(),x.returnValue="")};return addEventListener("beforeunload",Q),()=>removeEventListener("beforeunload",Q)},[se,C]);const G=h[P]??h[0],H=Ai(()=>{if(!u)return[];const Q=new Set(h.flatMap(x=>wi(x.items)).flatMap(Is));return u.orphans.filter(x=>!Q.has(x.file))},[u,ce]),N=async()=>{if(!(!u||!se||C)){w(!0);try{const Q=await n(()=>gt("/api/navigation",{fingerprint:u.fingerprint,spaces:h.map(x=>({name:x.name,...x.version?{version:x.version}:{},nav:wi(x.items)}))}).catch(x=>{throw/changed on disk/.test(x.message)&&L(x.message),x}),"Navigation saved",!1);Q&&(v(Q),y(Q.spaces.map((x,B)=>({name:x.name,...x.version?{version:x.version}:{},items:As(yi(x.nav),h[B]?.items??[])}))),O(x=>x+1),await o?.())}catch(Q){t(Q instanceof Error?Q.message:String(Q))}finally{w(!1)}}},oe=()=>{u&&y(u.spaces.map(Q=>({name:Q.name,...Q.version?{version:Q.version}:{},items:yi(Q.nav)})))};if(!u&&D)return e(Te,{tone:"bad",children:[e("span",{children:D}),e(_,{size:"sm",onClick:()=>{fe()},children:"Retry navigation"})]});if(!u)return e("div",{class:"page-list-empty",children:[e("span",{class:"spinner"}),ue?e(ie,{children:["Still loading navigation…",e(_,{size:"sm",tone:"link",onClick:()=>{fe(1)},children:"Retry"})]}):"Loading navigation…"]});if(!u.editable&&a)return e(fr,{items:r.map(Q=>({id:Q.path,node:{type:"page",file:Q.path,path:Q.path,pageTitle:Q.title}})),onChange:()=>{},supports:u.supports,icons:[],editable:!1,requiresEveryPage:!1,orphans:[],...l?{onSelectPage:l}:{},...m?{onTogglePage:m}:{},...d?{selectedPaths:d}:{},...c?{activePath:c}:{}});if(!u.editable)return e("div",{class:`navigation-view ${a?"navigation-view-embedded":""}`,children:e("section",{class:"navigation-editor-pane",children:[e(Te,{children:u.reason}),u.configFile&&e("p",{class:"branding-config-hint",children:["Navigation file: ",e("code",{children:u.configFile})]})]})});const Ce=[...new Set(h.map(Q=>Q.version).filter(Q=>!!Q))],ee=a?fr:$s;return e("div",{class:`navigation-view ${a?"navigation-view-embedded":""}`,children:[e("section",{class:"navigation-editor-pane",children:[a?e("header",{class:"explorer-header",children:[e("h2",{children:"Explorer"}),e("span",{class:"explorer-save-state",role:"status",children:C?"Saving…":se?"Unsaved":"Saved"}),e(_,{size:"sm",tone:"ghost","aria-label":"Discard navigation",title:"Discard navigation changes",disabled:!se||C,onClick:oe,children:e($,{name:"undo",size:14})}),e(_,{size:"sm",tone:"ghost","aria-label":"Save navigation",title:"Save navigation",disabled:!se,busy:C,onClick:()=>{N()},children:e($,{name:"check",size:15})})]}):e("header",{class:"navigation-editor-head",children:[e("h2",{children:"Sidebar navigation"}),e("div",{class:"navigation-editor-actions",children:[e(_,{size:"sm",disabled:!se||C,onClick:oe,children:"Discard"}),e(_,{size:"sm",busy:C,disabled:!se,onClick:()=>{N()},children:"Save navigation"})]})]}),I&&e(Te,{tone:"bad",children:e("span",{class:"note-body",children:[I,e("span",{class:"note-actions",children:e(_,{size:"sm",onClick:()=>{fe()},children:"Reload navigation"})})]})}),Ce.length>1&&e("label",{class:"navigation-editor-head",children:["Version",e("select",{"aria-label":"Documentation version",value:h[P]?.version,onChange:Q=>k(h.findIndex(x=>x.version===Q.currentTarget.value)),children:Ce.map(Q=>e("option",{value:Q,children:Q},Q))})]}),h.length>1&&e("div",{class:"navigation-spaces",role:"tablist","aria-label":"Spaces",children:h.map((Q,x)=>(Ce.length<2||Q.version===h[P]?.version)&&e("button",{type:"button",role:"tab","aria-selected":x===P,class:x===P?"active":"",onClick:()=>k(x),children:Q.name},x))}),!a&&H.length>0&&e(Te,{tone:u.requiresEveryPage?"warn":"info",children:[H.length," page",H.length===1?" is":"s are"," not in the navigation",u.requiresEveryPage?", which validation reports as an error":"",". Use “Add page” to place ",H.length===1?"it":"them","."]}),G&&e(ee,{items:G.items,onChange:Q=>y(h.map((x,B)=>B===P?{...x,items:Q}:x)),supports:u.supports,icons:u.icons,editable:!C,...d?{selectedPaths:d}:{},...m?{onTogglePage:m}:{},...l?{onSelectPage:l}:{},...c?{activePath:c}:{},requiresEveryPage:u.requiresEveryPage,orphans:H})]}),!a&&e("aside",{class:"navigation-preview-pane","aria-label":"Navigation preview",children:[e("div",{class:"preview-chrome","aria-hidden":"true",children:[e("span",{class:"preview-dots",children:[e("i",{}),e("i",{}),e("i",{})]}),e("code",{children:"/"})]}),A?e("iframe",{title:"Navigation preview",src:`${A}/`},`${A}:${W}`):e("div",{class:"preview-placeholder",children:[e("span",{class:"spinner"}),e("strong",{children:"Preview is starting…"})]}),se&&e("div",{class:"navigation-preview-note",children:[e($,{name:"info",size:13}),"The preview shows the saved navigation. Save to see your changes."]})]})]})}function vc({plan:n,editable:t,onChange:i,renderPage:a,pageClass:s,onOpenPage:o,onCreatePage:l}){const c=n.pages.filter(P=>P.priority!=="later"&&P.action!=="remove"),d=JSON.stringify([n.navigation,c.map(P=>[P.id,P.title,P.path])]),[m,r]=p(()=>({key:d,...Zi(n.navigation,c)}));ae(()=>{m.key!==d&&r({key:d,...Zi(n.navigation,c)})},[d]);const g=m.key===d?m.items:Zi(n.navigation,c).items,u=m.key===d?m.unsectioned:[],v=new Map(c.map(P=>[P.id,P])),h=P=>P.node.type==="page"?v.get(P.node.file):void 0,y=(P,k=[])=>{const C=uc(P,n.navigation.top),w=[...c,...k];r({key:JSON.stringify([C,w.map(I=>[I.id,I.title,I.path])]),items:P,unsectioned:w.filter(I=>!C.sections.some(L=>L.pageIds.includes(I.id)))}),i(C)};return e($s,{items:g,onChange:P=>y(P),childNoun:"page",...s?{rowClass:P=>{const k=h(P);return k?s(k):""}}:{},...a||t&&l?{rowMeta:P=>{const k=h(P);return k?a?.(k):P.node.type==="group"&&t&&l?e("button",{type:"button",class:"btn link sm nav-tree-add-page",onClick:C=>{C.stopPropagation();const w=l();y(Yt(g,P.id,I=>({...I,children:[...I.children??[],pc(w)]})),[w])},children:"Add page"}):null}}:{},...o?{onOpenItem:P=>{const k=h(P);k&&o(k)}}:{},supports:{icons:!1,hidden:!1,labels:!1,links:!1,dividers:!1,spaces:!1},icons:[],editable:t,requiresEveryPage:!1,orphans:u.map(P=>({file:P.id,path:P.path,title:P.title})),maxDepth:1,emptyLabel:"No sections yet. Add a section, then add the planned pages to it."})}function Ps(n){if(n.type==="group")return{...n,items:n.items.map(Ps)};if(n.type==="page"){const{path:t,pageTitle:i,...a}=n;return a}return n}function Is(n){return n.type==="page"?[n.file]:n.type==="group"?n.items.flatMap(Is):[]}function As(n,t){return n.map((i,a)=>({...i,id:t[a]?.id??i.id,...i.children?{children:As(i.children,t[a]?.children??[])}:{}}))}const mr=[["overview","Home","home"],null,["authoring","Plan","sparkle"],["pages","Docs","file"],["proposals","Review","review"],["publish","Publish","publish"],null,["sources","Sources","sources"],["settings","Settings","settings"]],bc={overview:"Home",sources:"Sources",authoring:"Plan",pages:"Docs",proposals:"Review",publish:"Publish",settings:"Settings","not-found":"Not found"},yc=new URL("/assets/doxloop-logo-light-De7Nx7j7.png",import.meta.url).href;function wc({state:n,loading:t,error:i,reload:a,act:s,onJobsUpdate:o,onError:l,onErrorDismiss:c,onNewProject:d}){const m=n.project,[r,g]=p(()=>{const x=Al(location.pathname,location.search);return x&&history.replaceState({},"",x),ca(location.pathname)}),[u,v]=p(!1),[h,y]=p(!1),[P,k]=p(null),[C,w]=p(null),I=Re(new Set(n.jobs.filter(x=>x.status==="running").map(x=>x.id))),L=Re(new Set),D=ft(n.runs).filter(x=>St.includes(x.status)).length,E=Qt(n)||n.documentationPlan?.status==="generated"?"Update":"Create",A=x=>{const B=I.current,F=x.filter(ne=>ne.type==="author:update"&&ne.status==="succeeded"&&B.has(ne.id)&&!L.current.has(ne.id)),T=bl(x,B,L.current),Z=yl(x,B,L.current),Y=x.filter(ne=>(ne.type.startsWith("proposal:revise:")||ne.type.startsWith("proposal:resume:"))&&ne.status!=="running"&&B.has(ne.id)&&!L.current.has(ne.id)),pe=x.filter(ne=>ne.type==="sync"&&ne.status!=="running"&&B.has(ne.id)&&!L.current.has(ne.id)),te=x.some(ne=>ne.type.startsWith("plan:")&&ne.status!=="running"&&B.has(ne.id)),M=x.some(ne=>ne.status!=="running"&&B.has(ne.id))&&!te&&pe.length+F.length+Z.length+Y.length===0;I.current=new Set(x.filter(ne=>ne.status==="running").map(ne=>ne.id)),o(x),(te&&T.length===0||M)&&a();for(const ne of pe)L.current.add(ne.id),w(Oc(ne)),a();for(const ne of T){if(L.current.add(ne.id),ne.type!=="plan:generate"&&ne.type!=="plan:continue"||ne.status!=="succeeded"){a();continue}(async()=>{await a();try{const Ie=(await _e("/api/proposals")).find(X=>St.includes(X.status));if(!Ie)return;k(Ie),sn("proposals",{proposal:Ie.id},"push"),g("proposals")}catch(xe){l(wn(xe))}})()}for(const ne of F)L.current.add(ne.id),(async()=>{await a();try{const Ie=(await _e("/api/proposals")).find(X=>St.includes(X.status));if(!Ie)return;k(Ie),sn("proposals",{proposal:Ie.id},"push"),g("proposals")}catch(xe){l(wn(xe))}})();for(const ne of Z)L.current.add(ne.id),(async()=>{await a();const xe=ne.type.slice(10);try{if(!(await _e("/api/proposals")).some(X=>X.id===xe&&X.editRequest))return;sn("pages",{run:xe})}catch(Ie){l(wn(Ie))}})();for(const ne of Y)L.current.add(ne.id),(async()=>{if(await a(),ne.status==="succeeded")try{const xe=ne.type.startsWith("proposal:resume:"),Ie=ne.type.slice((xe?"proposal:resume:":"proposal:revise:").length),J=(await _e("/api/proposals")).find(Ae=>(xe?Ae.id===Ie:Ae.revisionOf===Ie)&&Ae.status==="awaiting-review");if(!J)return;J.editRequest?sn("pages",{run:J.id}):(k(J),sn("proposals",{proposal:J.id},"push"),g("proposals"))}catch(xe){l(wn(xe))}})()};ae(()=>{const x=new EventSource("/api/jobs/stream");return x.onopen=()=>y(!0),x.onmessage=B=>{try{const F=JSON.parse(B.data);Array.isArray(F)&&A(F)}catch{}},x.onerror=()=>y(!1),()=>{x.close(),y(!1)}},[]),ae(()=>{const x=()=>g(ca(location.pathname));return addEventListener("popstate",x),()=>removeEventListener("popstate",x)},[]);const j=n.jobs.some(x=>x.status==="running"),W=Re(new Dl),[O,ue]=p(()=>typeof document<"u"&&document.hidden),ge=async()=>{try{const x=await _e("/api/jobs");W.current.succeeded(),A(x)}catch(x){W.current.failed()&&l(`The control center stopped answering: ${wn(x)}`)}};ae(()=>{const x=()=>{ue(document.hidden),document.hidden||(ge(),a())};return document.addEventListener("visibilitychange",x),()=>document.removeEventListener("visibilitychange",x)},[]),ae(()=>{const x=zl({running:j,streamConnected:h,hidden:O});if(x===null)return;const B=window.setInterval(()=>{ge()},x);return()=>clearInterval(B)},[j,h,O]);const fe=(x,B={})=>{window.dispatchEvent(new Event("doxloop:before-navigation",{cancelable:!0}))&&(history.pushState({},"",Ri(x,B)),g(x),v(!1))},[ye,ce]=p(null);ae(()=>{const x=B=>{const F=B.detail;ce(F.state==="ready"&&!F.blocked?null:F),F.state==="failed"&&l(`The preview could not start: ${F.error}`)};return addEventListener(da,x),()=>removeEventListener(da,x)},[]);const se=async()=>{if(ye?.state==="starting")return;await _a(B=>K("/api/preview/start",{open:B}))&&a()},G=n.jobs.filter(x=>x.status==="running"&&x.type!=="preview").length,H=xa(),N=r==="proposals"&&!!H.get("proposal"),oe=N?{label:"Back to Review",route:"proposals"}:null,[Ce,ee]=p(!1);ql(()=>ee(!0));const Q=[{id:"act:plan",group:"Actions",label:Qt(n)?"Plan an update":"Create documentation",icon:"sparkle",run:()=>fe("authoring")},{id:"act:preview",group:"Actions",label:"Preview docs",icon:"external",run:()=>{se()}},{id:"act:new",group:"Actions",label:"New project",icon:"plus",run:d},...mr.flatMap(x=>x?[{id:`go:${x[0]}`,group:"Go to",label:x[1],icon:x[2],run:()=>fe(x[0])}]:[]),...(Ia(n.validation).ok?n.validation.pages:[]).map(x=>({id:`page:${x}`,group:"Pages",label:xd(x),icon:"file",hint:x,run:()=>fe("pages",{path:x})}))];return e("div",{class:`shell ${r==="proposals"?"proposal-shell":""} ${r==="pages"?"pages-shell":""} ${r==="sources"?"sources-shell":""} ${N?"focus-mode":""}`,children:[u&&e("button",{class:"nav-scrim","aria-label":"Close navigation",onClick:()=>v(!1)}),e(Fl,{open:Ce,commands:Q,onClose:()=>ee(!1)}),P&&e("div",{class:"proposal-ready-scrim",role:"presentation",children:e("section",{class:"proposal-ready-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"proposal-ready-title",children:[e("button",{class:"proposal-ready-close",type:"button","aria-label":"Close",onClick:()=>k(null),children:e($,{name:"close",size:16})}),e("span",{class:"proposal-ready-icon",children:e($,{name:"proposals",size:24})}),e("div",{children:[e("h2",{id:"proposal-ready-title",children:"Documentation changes are ready"}),e("p",{children:"Your update finished successfully. Review the proposed changes before they replace the current documentation."})]}),e("div",{class:"proposal-ready-summary",children:[e("strong",{children:ma(P.changes)}),e("span",{children:"The current documentation remains unchanged until you accept the proposal."})]}),e("footer",{children:[e(_,{icon:"external",onClick:()=>{ua(P.id)},children:"Preview changes"}),e(_,{tone:"primary",icon:"proposals",onClick:()=>{const x=P;k(null),fe("proposals",{proposal:x.id})},children:"Review changes"})]})]})}),e("aside",{class:`sidebar ${u?"open":""}`,children:[e("div",{class:"sidebar-brand-row",children:[e("button",{class:"workspace-brand",type:"button","aria-label":"Doxloop",onClick:()=>fe("overview"),children:[e("span",{class:"brand-mark","aria-hidden":"true",children:"D"}),e("span",{class:"brand-word",children:"Doxloop"}),e("img",{src:yc,alt:""})]}),e("button",{class:"sidebar-close",type:"button","aria-label":"Close navigation",onClick:()=>v(!1),children:e($,{name:"close",size:16})})]}),e(To,{state:n,onNewProject:d,onError:l,onSwitched:async()=>{window.location.replace(Ri("overview"))}}),e("nav",{class:"reference-sidebar-nav","aria-label":"Main navigation",children:mr.map((x,B)=>x===null?e("span",{class:"nav-divider",role:"separator"},`divider-${B}`):e("button",{type:"button",class:`nav-item ${r===x[0]?"active":""}`,"aria-label":`${x[1]}${x[0]==="proposals"&&D>0?`, ${D} pending`:""}`,"aria-current":r===x[0]?"page":void 0,onClick:()=>fe(x[0]),children:[e("span",{class:"nav-glyph",children:e($,{name:x[2],size:17})}),e("span",{class:"nav-copy",children:e("span",{children:x[1]})}),x[0]==="proposals"&&D>0&&e("b",{class:"nav-count","aria-label":`${D} pending proposal${D===1?"":"s"}`,children:D})]},x[0]))}),e("div",{class:"sidebar-foot",children:[e("button",{type:"button",class:"new-project-button","aria-label":"New documentation project",title:"Start new or import existing docs",onClick:d,children:[e("span",{class:"nav-glyph",children:e($,{name:"plus",size:16})}),e("span",{children:[e("strong",{children:"New project"}),e("small",{children:"Start new or import existing docs"})]})]}),e("a",{class:"sidebar-foot-link",href:"https://github.com/doxbrix/doxloop",target:"_blank",rel:"noreferrer","aria-label":"Support (opens GitHub in a new tab)",children:[e("span",{class:"nav-glyph",children:e($,{name:"help",size:16})}),e("span",{children:"Support"})]})]})]}),e("main",{class:"workspace-main",children:[e("header",{class:"workspace-navbar",children:[e("button",{class:"workspace-mobile-menu",type:"button","aria-label":"Open navigation",onClick:()=>v(!0),children:e($,{name:"menu",size:18})}),N&&oe?e("button",{type:"button",class:"workspace-back-link",onClick:()=>r==="proposals"?sn("proposals",{},"push"):fe(oe.route),children:[e($,{name:"chevronLeft",size:16}),e("span",{children:oe.label})]}):e("div",{class:"workspace-crumbs",children:[e("button",{type:"button",class:"workspace-crumb",title:m.title,"aria-label":`${m.title} overview`,onClick:()=>fe("overview"),children:m.title}),e($,{name:"chevronRight",size:14}),e("strong",{class:"workspace-screen-title",children:r==="authoring"?`${E} documentation`:bc[r]})]}),e("span",{class:"workspace-navbar-spacer"}),G>0&&e("button",{type:"button",class:"workspace-activity-chip",title:"Open running task progress","aria-label":`${G} task${G===1?"":"s"} running. Open progress`,onClick:()=>{const x=n.jobs.find(F=>F.status==="running"&&!F.type.includes("preview")),B=x?.type.match(/^proposal:(?:revise|resume):(.+)$/)?.[1];B?location.assign(`/review?proposal=${encodeURIComponent(B)}`):fe(x?.type.startsWith("page-edit:")?"pages":"authoring")},children:[e("i",{}),G===1?"1 task running":`${G} tasks running`]}),e("button",{type:"button",class:"workspace-search-button","aria-label":"Search or jump to (⌘K)",onClick:()=>ee(!0),children:[e($,{name:"search",size:15}),e("span",{children:"Search or jump to…"}),e("kbd",{children:"⌘K"})]}),e("button",{type:"button",class:"workspace-preview-primary","aria-label":"Preview docs in a new tab","aria-busy":ye?.state==="starting",disabled:ye?.state==="starting",onClick:()=>{se()},children:[ye?.state==="starting"?e("span",{class:"spinner"}):e($,{name:"preview",size:15}),e("strong",{children:ye?.state==="starting"?"Starting preview…":"Preview docs"}),e($,{name:"external",size:12})]})]}),e("div",{class:"main",children:e("div",{class:"page",children:[t&&e("div",{class:"loading-bar"}),i&&e(Cc,{title:"Action failed",detail:i,onClose:c}),C&&e("div",{class:`page-updated-toast sync-outcome-toast ${C.tone}`,role:"status",children:[e("span",{class:"toast-icon",children:e($,{name:C.tone==="good"?"check":C.tone==="bad"?"alert":"info",size:15})}),e("span",{class:"toast-copy",children:[e("strong",{children:C.title}),e("small",{children:C.detail})]}),C.proposalId&&e(_,{size:"sm",onClick:()=>{w(null),fe("proposals",{proposal:C.proposalId})},children:"Review"}),e("button",{type:"button",class:"toast-close","aria-label":"Dismiss",onClick:()=>w(null),children:e($,{name:"close",size:14})})]}),ye&&ye.state!=="failed"&&e("div",{class:`page-updated-toast preview-notice-toast ${ye.state==="ready"?"warn":"info"}`,role:"status",children:[e("span",{class:"toast-icon",children:e($,{name:ye.state==="ready"?"external":"refresh",size:15})}),e("span",{class:"toast-copy",children:ye.state==="starting"?e(ie,{children:[e("strong",{children:"Starting the documentation preview…"}),e("small",{children:"It opens in a new tab when it is ready."})]}):e(ie,{children:[e("strong",{children:"The preview is ready"}),e("small",{children:["Your browser did not open a new tab. ",e("a",{href:ye.url,target:"_blank",rel:"noreferrer",children:["Open the preview at ",ye.url]})]})]})}),e("button",{type:"button",class:"toast-close","aria-label":"Dismiss",onClick:()=>ce(null),children:e($,{name:"close",size:14})})]}),r==="overview"&&e(kc,{state:n,act:s,navigate:fe,openPreview:se}),r==="sources"&&e(Pc,{state:n,act:s,navigate:fe}),r==="authoring"&&e(Lc,{state:n,act:s,streamConnected:h,onError:l}),r==="pages"&&e(Gc,{state:n,act:s,streamConnected:h,onError:l}),r==="proposals"&&e(td,{state:n,act:s,onError:l}),r==="publish"&&e(pd,{state:n,act:s,streamConnected:h,onError:l}),r==="settings"&&e(hd,{state:n,act:s,onError:l}),r==="not-found"&&e(xc,{navigate:fe})]})})]})]})}function kc({state:n,act:t,navigate:i,openPreview:a}){const s=n.project,[o,l]=p();ae(()=>{let ee=!0;return _e("/api/source-intelligence").then(Q=>{ee&&l(Q)}).catch(()=>{}),()=>{ee=!1}},[vl(n)]);const d=ft(n.runs).find(ee=>St.includes(ee.status)),m=o?.coverage.metrics.filter(ee=>ee.status!=="unknown")??[],r=m.reduce((ee,Q)=>ee+Q.documented,0),g=m.reduce((ee,Q)=>ee+Q.total,0),u=g>0?Math.round(r/g*100):0,v=o?Qt(n)?u>=90?"Strong coverage":u>=70?"Good foundation":u>=40?"Gaps remain":"Needs attention":"Not documented yet":"Checking evidence",h=Qt(n),y=n.documentationPlan,P=n.effectiveDeployment?.slug??s.deployment?.slug,k=n.latestDeployment,C=k?.url??(k?"Deployment recorded":"Nothing published yet"),w=n.jobs[0]?.finishedAt??n.jobs[0]?.startedAt??y?.updatedAt,I=d?.changes??[];I.filter(ee=>ee.kind==="added").length,I.filter(ee=>ee.kind!=="added"&&ee.kind!=="deleted").length;const L=n.jobs.slice(0,5),D=n.jobs.filter(ee=>ee.status==="running"&&ee.type!=="preview").length,E=Ia(n.validation),A=E.ok?E.result.issues:[],j=E.ok?E.result.errors:0,W=E.ok?E.result.warnings:0,O=E.ok?E.result.pages.length:y?.pages.filter(ee=>ee.priority!=="later").length??0,ue=yd(n.agents,s.defaultAgent),ge=ue?ue.authentication.status==="authenticated"?"good":ue.authentication.status==="unknown"?"neutral":"warn":"warn",{mood:fe,eyebrow:ye,headline:ce,detail:se,label:G}=ml(n,h,!!d),H=D?"authoring":d?"proposals":G==="Check sources"||!s.sources.length?"sources":"authoring",N=y?.pages.filter(ee=>ee.priority!=="later").length??0,oe=[{label:"Sources",sub:`${s.sources.length} connected`,icon:"sources",route:"sources",state:s.sources.length?"done":"idle"},{label:"Plan",sub:y?`Version ${y.version}`:"Not started",icon:"list",route:"authoring",state:y?.status==="planning"||y?.status==="revising"?"active":y?"done":"idle"},{label:"Write",sub:y?.status==="generating"?"In progress":d&&!h?`${N} pages written`:h?`${E.ok?E.result.pages.length:N} pages ready`:"Waiting",icon:"update",route:"authoring",state:y?.status==="generating"?"active":h||d?"done":"idle"},{label:"Review",sub:d?"Awaiting you":"No pending changes",icon:"review",route:"proposals",state:d?"active":h?"done":"idle"},{label:"Publish",sub:k?"Published":P?"Not published yet":"Not configured",icon:"publish",route:"publish",state:k?"done":"idle"}],Ce=oe.filter(ee=>ee.state==="done").length;return e("section",{class:"overview-page",children:[e(ht,{kicker:"Home",title:"Your documentation loop",description:"Everything between your source code and the published docs, in one pass."}),e("section",{class:"pipeline-card","aria-label":"Documentation workflow",children:[e("div",{class:"pipeline-track",children:e("i",{style:{width:`${Math.max(0,(Ce-1)/(oe.length-1))*100}%`}})}),oe.map(ee=>e("button",{type:"button",class:ee.state,onClick:()=>i(ee.route),children:[e("span",{children:e($,{name:ee.state==="done"?"check":ee.icon,size:ee.state==="done"?13:17})}),e("span",{class:"pipeline-copy",children:[e("strong",{children:ee.label}),e("small",{children:ee.sub})]})]},ee.label))]}),e("section",{class:`ov-hero ${fe}`,"aria-label":"Workspace status",children:[e("div",{class:"ov-hero-copy",children:[e("span",{class:"ov-eyebrow",children:[e("i",{}),ye]}),e("h2",{children:ce}),e("p",{children:se}),e("div",{class:"ov-hero-actions",children:[e(_,{tone:"primary",icon:d?"review":h?"update":s.sources.length?"sparkle":"sources",onClick:()=>i(H),children:G}),h&&!d&&e(_,{icon:"file",onClick:()=>i("pages"),children:"Edit a page"}),h&&e(_,{icon:"preview",onClick:()=>{a()},children:"Preview docs"})]})]}),e("dl",{class:"ov-hero-facts",children:[e("div",{children:[e("dt",{children:"Coding agent"}),e("dd",{children:[e("i",{class:`ov-dot ${ge}`}),ue?`${On(ue.name)} ${Cd(ue.authentication.status)}`:"None detected"]}),e("button",{type:"button",class:"ov-fact-link",onClick:()=>i("settings",{section:"general"}),children:"Agent settings"})]}),e("div",{children:[e("dt",{children:"Activity"}),e("dd",{children:[e("i",{class:`ov-dot ${D?"info":"neutral"}`}),D?`${D} task${D===1?"":"s"} running`:"Idle"]})]}),e("div",{children:[e("dt",{children:"Last checked"}),e("dd",{children:w?Ye(w):"Not yet"})]}),n.root&&e("div",{children:[e("dt",{children:"Project folder"}),e("dd",{title:n.root,children:e("code",{children:n.root})})]})]})]}),e("div",{class:"ov-metrics",children:[e("button",{type:"button",class:"ov-metric",onClick:()=>i("sources"),children:[e("span",{class:"ov-donut",style:{"--ov-coverage":`${u}%`},children:e("b",{children:o?`${u}%`:"—"})}),e("span",{class:"ov-metric-copy",children:[e("small",{children:"Coverage"}),e("strong",{children:v}),e("span",{children:o?`${r} of ${g} discovered items documented`:"Appears after source discovery completes"})]}),e($,{name:"chevronRight",size:16,class:"ov-metric-arrow"})]}),e("button",{type:"button",class:`ov-metric ${h?j?"bad":W?"warn":"good":""}`,onClick:()=>i("pages"),children:[e("span",{class:"ov-figure",children:O}),h?e("span",{class:"ov-metric-copy",children:[e("small",{children:"Pages"}),e("strong",{children:E.ok?Pr(E.result):"Validation unavailable"}),e("span",{children:E.ok?A.some(ee=>ee.severity==="error")?"Fix the errors before publishing.":A.length?"Worth a look. Warnings do not block publishing.":"Navigation, metadata, and links look consistent.":E.reason})]}):e("span",{class:"ov-metric-copy",children:[e("small",{children:"Pages"}),e("strong",{children:"Starter pages"}),e("span",{children:"Replaced when you approve your first proposal."})]}),e($,{name:"chevronRight",size:16,class:"ov-metric-arrow"})]}),e("button",{type:"button",class:`ov-metric ${k?"good":""}`,onClick:()=>i("publish"),children:[e("span",{class:"ov-metric-icon",children:e($,{name:P?"cloud":"publish",size:20})}),e("span",{class:"ov-metric-copy",children:[e("small",{children:"Published site"}),e("strong",{children:k?"Published successfully":"Not published yet"}),e("code",{children:C})]}),e($,{name:"chevronRight",size:16,class:"ov-metric-arrow"})]})]}),h&&A.length>0&&e("section",{class:"panel ov-issues","aria-label":"Validation issues",children:[e("header",{class:"panel-head",children:[e("div",{class:"panel-title",children:[e("h2",{children:"Validation issues"}),e("p",{children:[E.ok?Pr(E.result):""," across ",O," page",O===1?"":"s","."]})]}),e("div",{class:"panel-actions",children:e(_,{size:"sm",onClick:()=>i("pages"),children:"Open pages"})})]}),e("ul",{children:[A.slice(0,6).map((ee,Q)=>e("li",{children:[e(Me,{tone:ee.severity==="error"?"bad":"warn",children:ee.severity}),ee.file&&e("code",{children:ee.file}),e("span",{children:ee.message})]},`${ee.code}-${Q}`)),A.length>6&&e("li",{class:"more",children:["and ",A.length-6," more"]})]})]}),e("section",{class:"panel overview-activity-card","aria-label":"Recent activity",children:[e("header",{class:"panel-head",children:[e("div",{class:"panel-title",children:[e("h2",{children:"Recent activity"}),e("p",{children:"Agents run in the background. Every run keeps a full log."})]}),D>0&&e(Me,{tone:"info",icon:"refresh",children:[D," running"]})]}),e("ol",{class:"ov-activity",children:L.length?L.map(ee=>e("li",{class:ee.status,children:[e("span",{class:"ov-activity-icon",children:e($,{name:Uc(ee.type),size:15})}),e("p",{children:[e("strong",{children:Zt(ee.type)}),Bc(ee)]}),e("time",{children:Ye(ee.finishedAt??ee.startedAt)}),e("span",{class:"ov-activity-actions",children:[ee.status==="running"&&e(_,{size:"sm",tone:"danger",icon:"stop",onClick:()=>{t(()=>K(`/api/jobs/${ee.id}/cancel`),`${Zt(ee.type)} stopped`)},children:"Stop"}),e("a",{class:"btn secondary sm",href:`/api/jobs/${ee.id}/log`,target:"_blank",rel:"noreferrer",title:"Open the full log",children:"Log"})]})]},ee.id)):e("li",{class:"empty",children:[e("span",{class:"ov-activity-icon",children:e($,{name:"check",size:15})}),e("p",{children:"Your workspace is ready. Activity appears here after the first run."})]})})]})]})}function Cc({title:n,detail:t,onClose:i}){return e("div",{class:"banner bad",children:[e($,{name:"alert",size:16}),e("div",{children:[e("strong",{children:n}),e("span",{children:t})]}),e("button",{"aria-label":"Dismiss",onClick:i,children:e($,{name:"close",size:14})})]})}function xc({navigate:n}){return e("div",{class:"workspace-not-found",children:[e("span",{children:e($,{name:"alert",size:24})}),e("h1",{children:"Workspace page not found"}),e("p",{children:"This URL does not match an available Doxloop workspace."}),e(_,{tone:"primary",onClick:()=>n("authoring"),children:"Open documentation update"})]})}function _c(n){const t=n.toLowerCase();return t.includes("gitlab.com")||t.includes("gitlab.")?"gitlab":t.includes("github.com")||t.includes("github.")?"github":"git"}function Sc(n){const t=_c(n);return t==="git"?"sources":t}async function ua(n,t){await _a(i=>K(`/api/proposals/${n}/preview/start`,{open:i}))}function $c({connected:n,busy:t,disabled:i,onClick:a}){return n?e("button",{type:"button",class:"repository-connected-button",onClick:a,children:[e($,{name:"check",size:14}),"Connected"]}):e(_,{tone:"primary",busy:t,disabled:i,onClick:a,children:"Connect"})}function Pc({state:n,act:t,navigate:i}){const a=n.project,[s,o]=p(null),[l,c]=p(),[d,m]=p(""),[r,g]=p(""),[u,v]=p(!1),[h,y]=p(null),[P,k]=p("git"),[C,w]=p("file"),[I,L]=p({repository:"",branch:"main",subdirectory:"",path:"",authMethod:"automatic",gitUsername:"",gitSecret:"",specContent:"",fileName:"",space:"",routePrefix:"",navigationGroup:"",sharedPages:""}),[D,E]=p(),[A,j]=p([]),[W,O]=p([]),[ue,ge]=p(""),[fe,ye]=p(!1),[ce,se]=p(!1),[G,H]=p(!1),[N,oe]=p(""),[Ce,ee]=p(),[Q,x]=p(null),B=Re(null),F=a.sources,T=()=>{L({repository:"",branch:"main",subdirectory:"",path:"",authMethod:"automatic",gitUsername:"",gitSecret:"",specContent:"",fileName:"",space:"",routePrefix:"",navigationGroup:"",sharedPages:""}),j([]),O([]),ge(""),k("git"),w("file"),c(void 0),m("")},Z=R=>{T(),o(R)},Y=async()=>E(await _e("/api/source-intelligence"));ae(()=>{let R=!0;return _e("/api/source-intelligence").then(me=>{R&&E(me)}).catch(()=>{}),()=>{R=!1}},[a.sources.map(R=>`${R.name}:${R.path}`).join("|")]),ae(()=>{if(!Q)return;const R=Oe=>{Oe.target?.closest?.(".source-row-actions")||x(null)},me=Oe=>{Oe.key==="Escape"&&x(null)};return addEventListener("mousedown",R),addEventListener("keydown",me),()=>{removeEventListener("mousedown",R),removeEventListener("keydown",me)}},[Q]);const pe=()=>o(null),te=async()=>{if(!(!I.repository.trim()||fe)){ye(!0);try{const R=await t(()=>K("/api/setup/git/test",I),void 0,!1);if(!R)return;L(Oe=>({...Oe,repository:R.repository,branch:R.branch,subdirectory:""})),j(R.branches),se(!0);const me=await t(()=>K("/api/setup/git/folders",{...I,repository:R.repository,branch:R.branch,subdirectory:""}),void 0,!1);if(!me)return;O(me.directories),ge(R.head)}finally{se(!1),ye(!1)}}},M=async R=>{L(me=>({...me,branch:R,subdirectory:""})),se(!0);try{const me=await t(()=>K("/api/setup/git/folders",{...I,branch:R,subdirectory:""}),void 0,!1);O(me?.directories??[])}finally{se(!1)}},ne=async R=>{if(!R)return;const me=await R.text();w("file"),L(Oe=>({...Oe,fileName:R.name,specContent:me,path:""}))},xe=async()=>{const R=s==="openapi"?I.path||I.fileName||"openapi":P==="git"?I.repository:I.path,Oe=(s==="docs-site"?(()=>{try{return new URL(I.path.trim()).hostname.replace(/^www\./,"").replace(/^docs\./,"docs-")}catch{return"docs"}})():R.replace(/[?#].*$/,"").replace(/[\\/]+$/,"").split(/[\\/]/).pop()?.replace(/\.git$/i,"").replace(/\.(json|ya?ml)$/i,"")||"source").toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"docs";H(!0);try{const Ge=I.space.trim()||I.routePrefix.trim()||I.navigationGroup.trim()||I.sharedPages.trim()?{space:I.space.trim()||void 0,routePrefix:I.routePrefix.trim()||void 0,navigationGroup:I.navigationGroup.trim()||void 0,sharedPages:In(I.sharedPages)}:void 0,kn=s==="docs-site"?{kind:"docs-site",name:Oe,url:I.path.trim(),inspectionId:l?.id,scope:Ge}:s==="openapi"?{kind:"openapi",name:Oe,path:C==="url"?I.path:void 0,specContent:C==="file"?I.specContent:void 0,scope:Ge}:P==="git"?{kind:"git",name:Oe,...I,scope:Ge}:{kind:"directory",name:Oe,path:I.path,scope:Ge};await t(()=>K("/api/sources",kn,s==="docs-site"?Gn:void 0),"Source added")!==void 0&&pe()}finally{H(!1)}},Ie=async R=>{if(confirm(`Re-crawl ${R.site?.url??R.name}? The new snapshot replaces the current one; the next update compares them and names the pages that changed.`)){g(R.name);try{await t(()=>K(`/api/sources/${encodeURIComponent(R.name)}/refresh`,{},Gn),"Documentation site re-crawled"),await Y()}finally{g("")}}},X=R=>{x(null),oe(R.name),t(()=>K(`/api/sources/${encodeURIComponent(R.name)}/test`),"Source connection checked").then(()=>Y()).finally(()=>oe(""))},J=n.jobs.some(R=>R.type==="sync"&&R.status==="running"),Ae=Ds(n.jobs),Be=P==="local"?"local":I.authMethod==="credentials"?"private":"public",ke=R=>{if(R==="local"){k("local");return}k("git"),L({...I,authMethod:R==="private"?"credentials":"automatic"}),ge(""),j([]),O([])},Ke=()=>{ge(""),j([]),O([])},Je=D?.coverage.metrics.filter(R=>R.status!=="unknown")??[],q=Je.reduce((R,me)=>R+me.documented,0),ze=Je.reduce((R,me)=>R+me.total,0),Pe=ze>0?Math.round(q/ze*100):null,Ze=D?.coverage.metrics.filter(R=>R.status==="unknown").length??0,nn=Pe===null?"Awaiting discovery":Pe>=90?"Strong coverage":Pe>=70?"Good foundation":Pe>=40?"Coverage gaps remain":"Needs attention",Ee=D?.coverage.metrics.reduce((R,me)=>R+Gt(me),0)??0,z=D?.coverage.metrics.filter(R=>Gt(R)>0).sort((R,me)=>Gt(me)-Gt(R))[0],Se=D?.coverage.metrics.find(R=>R.id===Ce),tn=s==="docs-site"?l?.status!=="completed":s==="source"?P==="git"?!ue||ce:!I.path.trim():C==="file"?!I.specContent.trim():!I.path.trim();return e("div",{class:"sources-reference-page",children:[e(ht,{kicker:"Sources",title:"Sources",description:"What Doxloop reads, how well it is covered, and when it was last checked.",actions:e(ie,{children:[e(_,{icon:"bell",onClick:()=>v(!0),children:"Monitoring"}),e(_,{tone:"primary",icon:"plus",onClick:()=>Z("source"),children:"Add source"})]})}),e(Ue,{class:"sources-library",title:"Connected sources",flush:!0,actions:F.length>0?e(_,{size:"sm",icon:"refresh",busy:J,disabled:J||Ae,title:Ae?"Available when the running writing task finishes":void 0,onClick:()=>{t(()=>K("/api/sync/now"),"Source check started",!1)},children:"Check now"}):void 0,children:F.length?e("div",{class:"source-rows",role:"table","aria-label":"Connected sources",children:[e("div",{class:"sr-only",role:"row",children:[e("span",{role:"columnheader",children:"Source"}),e("span",{role:"columnheader",children:"Type"}),e("span",{role:"columnheader",children:"Details"}),e("span",{role:"columnheader",children:"Status"}),e("span",{role:"columnheader",children:"Actions"})]}),e("div",{role:"rowgroup",children:F.map(R=>{const me=D?.health.find(on=>on.name===R.name),Oe=R.kind==="openapi"?"OpenAPI":R.kind==="docs-site"?"Docs site":R.remote?vd(R.remote.repository):"Local folder",Ge=me?.docsSite??R.site,kn=me?.openapi?`v${me.openapi.version} · ${me.openapi.operationCount} operations · ${me.openapi.schemas.length} schemas`:R.kind==="docs-site"?Ge?`${Ge.pages} pages · ${Ge.words.toLocaleString()} words${Ge.generator?` · ${Ge.generator}`:""} · crawled ${Ye(Ge.crawledAt)}`:"Existing documentation":me?.branch?`${me.branch}${me.subdirectory?` / ${me.subdirectory}`:""}${me.revision?` · ${me.revision.slice(0,10)}`:""}`:R.scope?.routePrefix?`Owns /${R.scope.routePrefix.replace(/^\//,"")}`:"Project-wide evidence",An=me?me.status==="healthy"?"Current":me.status==="warning"?"Needs attention":"Unavailable":"Checking…",mn=me?me.status==="healthy"?"good":me.status==="warning"?"warn":"bad":"neutral",Tn=R.site?.url??(R.remote?R.remote.repository:R.path);return e("div",{class:"source-row",role:"row",children:[e("span",{class:"source-row-icon","aria-hidden":"true",children:e($,{name:R.kind==="openapi"?"braces":R.kind==="docs-site"?"globe":R.remote?Sc(R.remote.repository):"folder",size:16})}),e("div",{class:"source-row-copy",role:"presentation",children:[e("div",{class:"source-row-name",role:"cell",title:Tn,children:R.name}),e("p",{class:"source-row-meta",role:"presentation",children:[e("span",{role:"cell",children:Oe}),e("span",{role:"cell",class:"source-row-detail",title:me?`Checked ${Ye(me.checkedAt)}${me.lastMonitoringAt?` · Last monitoring check ${Ye(me.lastMonitoringAt)}`:""}`:Tn,children:[kn,R.scope?.routePrefix&&me?.openapi&&e(ie,{children:[" · owns /",R.scope.routePrefix.replace(/^\//,"")]}),me&&e(ie,{children:[" · checked ",Ye(me.checkedAt)]}),R.kind==="docs-site"&&me?.docsSite&&me.docsSite.brokenLinks>0&&e("small",{children:[me.docsSite.brokenLinks," broken internal links on the site"]}),R.kind==="docs-site"&&me?.status==="warning"&&e("small",{class:"source-health-error",children:me.summary}),me?.status==="error"&&e("small",{class:"source-health-error",children:me.summary})]})]})]}),e("div",{class:"source-row-status",role:"cell",children:e(Me,{tone:mn,children:N===R.name?"Checking…":An})}),e("div",{class:"source-row-actions",role:"cell",children:[e("button",{type:"button",class:"ops-icon-button","aria-label":`Source options for ${R.name}`,"aria-haspopup":"menu","aria-expanded":Q===R.name,onClick:()=>x(Q===R.name?null:R.name),children:e(Ic,{})}),Q===R.name&&e("div",{class:"ops-menu",role:"menu","aria-label":`${R.name} options`,children:[R.kind==="docs-site"&&e("button",{type:"button",role:"menuitem","aria-label":`Re-crawl ${R.name}`,disabled:r===R.name,onClick:()=>{x(null),Ie(R)},children:[e($,{name:r===R.name?"clock":"globe",size:15}),"Re-crawl the site"]}),e("button",{type:"button",role:"menuitem","aria-label":`Test ${R.name}`,disabled:N===R.name,onClick:()=>X(R),children:[e($,{name:"refresh",size:15}),"Test connection"]}),e("button",{type:"button",role:"menuitem","aria-label":`Configure documentation ownership for ${R.name}`,onClick:()=>{x(null),y(R)},children:[e($,{name:"map",size:15}),"Documentation ownership"]}),e("button",{type:"button",role:"menuitem",class:"danger","aria-label":`Delete ${R.name}`,onClick:()=>{x(null),confirm(`Remove ${R.name}?`)&&t(()=>sa(`/api/sources/${encodeURIComponent(R.name)}`),"Source removed")},children:[e($,{name:"trash",size:15}),"Remove source"]})]})]})]},R.name)})})]}):e("div",{class:"ops-empty-wrap",children:e(Mn,{icon:"sources",title:"No sources yet",detail:"Connect a repository, an OpenAPI spec, or a live docs site.",action:e(_,{size:"sm",tone:"primary",icon:"plus",onClick:()=>Z("source"),children:"Add source"})})})}),D&&e(Ue,{class:"coverage-panel",title:"Documentation coverage",flush:!0,actions:e(ie,{children:[D.evidenceDiagnostics.length>0&&e(Me,{tone:"warn",children:[D.evidenceDiagnostics.length," evidence note",D.evidenceDiagnostics.length===1?"":"s"]}),z&&e(_,{size:"sm",onClick:()=>ee(z.id),children:["Review ",Ee," ",Ee===1?"gap":"gaps"]})]}),children:[e("div",{class:"coverage-summary",title:D.coverage.disclaimer,children:[e("strong",{class:`coverage-figure ${Pe===null?"":Pe>=70?"good":Pe>=40?"warn":"bad"}`,"aria-label":Pe===null?"Coverage unavailable":`${Pe}% overall documentation coverage`,children:Pe===null?"—":`${Pe}%`}),e("div",{class:"coverage-summary-copy",children:[e("span",{class:`coverage-assessment ${Pe!==null&&Pe<70?"attention":""}`,children:nn}),e("span",{class:"coverage-summary-detail",children:[q," of ",ze," discovered items are documented",Ee>0&&e(ie,{children:[" · ",Ee," ",Ee===1?"gap":"gaps"]}),Ze>0&&e(ie,{children:[" · ",Ze," ",Ze===1?"surface":"surfaces"," without items"]})]})]})]}),e("div",{class:"coverage-rows",children:D.coverage.metrics.map(R=>{const me=R.status!=="unknown",Oe=Gt(R);return e("div",{class:`coverage-row ${me?"":"unknown"}`,title:me?R.denominator:`Discovery completed, but no items in this category were found in the connected sources. ${R.denominator}`,children:[e("span",{class:"coverage-row-label",children:R.label}),e("div",{class:`progress ${me?R.percent>=90?"good":R.percent>=70?"":"warn":""}`,role:"progressbar","aria-label":`${R.label} coverage`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":me?R.percent:void 0,children:e("i",{style:{width:me?`${R.percent}%`:"0%"}})}),me?e("span",{class:"coverage-row-percent",title:`${R.documented} of ${R.total}`,children:[R.percent,"%"]}):e("em",{class:"coverage-row-percent",children:"No items discovered"}),(Oe>0||R.excluded>0)&&e("button",{type:"button",class:"coverage-review-action",onClick:()=>ee(R.id),children:Oe>0?`${Oe} ${Oe===1?"gap":"gaps"}`:`${R.excluded} excluded`})]},R.id)})}),D.evidenceDiagnostics.length>0&&e("details",{class:"source-evidence-notes",children:[e("summary",{children:"Review evidence precision"}),D.evidenceDiagnostics.slice(0,8).map(R=>e("div",{children:[e("strong",{children:R.page}),e("p",{children:R.message}),e("small",{children:R.suggestion})]},`${R.code}:${R.page}:${R.identifier}`))]})]}),F.length>0&&e(Tc,{value:n.drift,navigate:i,sync:a.sync,onConfigure:()=>v(!0)}),u&&e(Os,{state:n,act:t,onClose:()=>v(!1)}),Se&&e(Rc,{metric:Se,pages:D?.coverage.pages??[],act:t,onClose:()=>ee(void 0),onReport:E,onCreateUpdate:async R=>{const me=R.map(Ge=>`- ${Ge.label}${Ge.source?` — source: ${Ge.source}`:""}${Ge.path?`, path: ${Ge.path}`:""}`).join(`
|
|
15
|
+
`),Oe=await t(()=>K("/api/plans",{mode:"update",scope:"custom",clarificationMode:"review",request:`Create one focused documentation update plan that resolves these ${R.length} selected coverage ${R.length===1?"gap":"gaps"}:
|
|
16
|
+
${me}
|
|
17
|
+
Map each public surface or reader outcome to the most appropriate reader-facing page and preserve unrelated documentation.`}),"Coverage update planning started");return Oe!==void 0&&i("authoring"),Oe!==void 0}}),h&&e(Mc,{source:h,act:t,onClose:()=>y(null)}),s&&e(Us,{class:`add-source-sheet ${s}`,title:"Add source",onClose:pe,footer:e(ie,{children:[e(_,{tone:"ghost",onClick:pe,children:"Cancel"}),e(_,{tone:"primary",icon:"plus",busy:G,disabled:tn,onClick:()=>{xe()},children:"Add source"})]}),children:[e("div",{class:"field ops-choice",children:[e("span",{class:"field-label",children:"What are you adding?"}),e(ki,{label:"What are you adding?",value:s,onChange:Z,items:[{id:"source",label:"Source code",detail:"A Git repository or local folder"},{id:"openapi",label:"OpenAPI spec",detail:"From a URL or an uploaded file"},{id:"docs-site",label:"Rewrite a live docs site",detail:"Crawl an existing site to audit and rewrite"}]})]}),s==="source"&&e(ie,{children:[e("div",{class:"field ops-choice",children:[e("span",{class:"field-label",children:"Where is it?"}),e(ki,{label:"Where is it?",value:Be,onChange:ke,items:[{id:"public",label:"Public repository"},{id:"private",label:"Private repository",detail:"Needs a personal access token"},{id:"local",label:"Local folder"}]})]}),P==="git"?e(ie,{children:[I.authMethod==="credentials"&&e(ie,{children:[e(U,{label:"Username",children:e(re,{value:I.gitUsername,autocomplete:"username",onInput:R=>{L({...I,gitUsername:R.currentTarget.value}),Ke()}})}),e(U,{label:"Personal access token",hint:"A token with read access to the repository. It is used to connect and is stored outside the project.",children:e(re,{type:"password",value:I.gitSecret,autocomplete:"off",onInput:R=>{L({...I,gitSecret:R.currentTarget.value}),Ke()}})})]}),e(U,{label:"Repository URL",hint:"A GitHub, GitLab, Azure DevOps or other Git URL. Connect to load its branches and folders.",children:e("div",{class:"repository-connect-input",children:[e(re,{class:"mono-input",value:I.repository,placeholder:"https://github.com/org/repository",onInput:R=>{L({...I,repository:R.currentTarget.value}),Ke()}}),e($c,{connected:!!ue,busy:fe,disabled:!I.repository.trim()||I.authMethod==="credentials"&&(!I.gitUsername.trim()||!I.gitSecret.trim()),onClick:()=>{te()}})]})}),e(U,{label:"Branch",children:e(Fe,{value:I.branch,disabled:!ue||fe,onChange:R=>{M(R.currentTarget.value)},children:A.length?A.map(R=>e("option",{children:R},R)):e("option",{children:fe?"Connecting...":"Connect repository first"})})}),e(U,{label:"Folder (optional)",hint:"Limit the source to one folder of the repository.",children:e(Fe,{value:I.subdirectory,disabled:!ue||ce,onChange:R=>L({...I,subdirectory:R.currentTarget.value}),children:[e("option",{value:"",children:"/"}),W.map(R=>e("option",{children:R},R))]})})]}):e(U,{label:"Local folder",children:e("div",{class:"source-folder-input",children:[e(re,{class:"mono-input",value:I.path,onInput:R=>L({...I,path:R.currentTarget.value})}),e(_,{icon:"folder",onClick:()=>{K("/api/setup/browse-directory").then(R=>R.path&&L({...I,path:R.path}))},children:"Browse"})]})})]}),s==="openapi"&&e(ie,{children:[e("div",{class:"field ops-choice",children:[e("span",{class:"field-label",children:"Where is it?"}),e(ki,{label:"Where is it?",value:C,onChange:w,items:[{id:"file",label:"Upload a file",detail:".yaml, .yml or .json"},{id:"url",label:"From a URL",detail:"A public address"}]})]}),C==="file"?e("div",{class:`openapi-dropzone ${I.fileName?"has-file":""}`,onDragOver:R=>R.preventDefault(),onDrop:R=>{R.preventDefault(),ne(R.dataTransfer?.files[0])},children:[e("input",{ref:B,type:"file",accept:".yaml,.yml,.json,application/json,text/yaml",onChange:R=>{ne(R.currentTarget.files?.[0])}}),e("span",{children:e($,{name:I.fileName?"check":"publish",size:22})}),e("strong",{children:I.fileName||"Drag and drop your OpenAPI file here"}),e(_,{size:"sm",onClick:()=>B.current?.click(),children:I.fileName?"Choose another file":"Browse file"})]}):e(U,{label:"OpenAPI spec URL",hint:"Public URLs in standard OpenAPI formats are supported.",children:e(re,{class:"mono-input",value:I.path,placeholder:"https://example.com/openapi.yaml",onInput:R=>L({...I,path:R.currentTarget.value,specContent:"",fileName:""})})})]}),s==="docs-site"&&e(es,{url:I.path,onUrl:R=>{L({...I,path:R}),m("")},inspection:l,onInspection:c,error:d,onError:m}),e("details",{class:"source-scope-fields",children:[e("summary",{children:"Documentation ownership (optional)"}),e("div",{children:[e(U,{label:"Route prefix",children:e(re,{value:I.routePrefix,placeholder:"api or integrations/payments",onInput:R=>L({...I,routePrefix:R.currentTarget.value})})}),e(U,{label:"Navigation group",children:e(re,{value:I.navigationGroup,placeholder:"API reference",onInput:R=>L({...I,navigationGroup:R.currentTarget.value})})}),e(U,{label:"Space",children:e(re,{value:I.space,placeholder:"Developers",onInput:R=>L({...I,space:R.currentTarget.value})})}),e(U,{label:"Shared pages",hint:"Comma-separated page paths or globs",children:e(re,{value:I.sharedPages,placeholder:"docs/overview.mdx",onInput:R=>L({...I,sharedPages:R.currentTarget.value})})})]})]})]})]})}function Gt(n){return n.items.filter(t=>t.state==="uncovered"||t.state==="needs-human"||t.state==="planned"||t.state==="stale").length}function Ic(){return e("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[e("circle",{cx:"12",cy:"12",r:"1"}),e("circle",{cx:"19",cy:"12",r:"1"}),e("circle",{cx:"5",cy:"12",r:"1"})]})}function ki({label:n,value:t,onChange:i,items:a}){return e("div",{class:"radio-rows",role:"radiogroup","aria-label":n,children:a.map(s=>e("button",{type:"button",role:"radio","aria-checked":t===s.id,class:t===s.id?"selected":"",disabled:s.disabled,onClick:()=>i(s.id),children:[e("span",{children:[e("strong",{children:s.label}),s.detail&&e("small",{children:s.detail})]}),s.trailing]},s.id))})}function Ac({assessments:n,pages:t}){const i=new Map(t.map(a=>[a.id,a.title]));return e("div",{class:"plan-existing-docs",children:n.map(a=>{const s={rewrite:0,merge:0,preserve:0,drop:0};for(const l of a.pages)s[l.disposition]+=1;const o=a.findings.filter(l=>l.severity==="blocker").length;return e("section",{class:"plan-existing-docs-source",children:[e("header",{children:[e("h3",{children:a.source}),e("small",{children:[a.pages.length," existing page",a.pages.length===1?"":"s"," assessed · ",a.findings.length," finding",a.findings.length===1?"":"s",o?` (${o} blocking)`:""]})]}),a.summary&&e("p",{children:a.summary}),e("div",{class:"plan-existing-docs-stats",children:[e("div",{children:[e("strong",{children:s.rewrite}),e("span",{children:"pages rewritten"})]}),e("div",{children:[e("strong",{children:s.merge}),e("span",{children:"pages merged"})]}),e("div",{children:[e("strong",{children:s.preserve}),e("span",{children:"pages preserved"})]}),e("div",{children:[e("strong",{children:s.drop}),e("span",{children:"pages dropped"})]}),e("div",{children:[e("strong",{children:a.coverage.gaps.length}),e("span",{children:"coverage gaps filled"})]}),e("div",{children:[e("strong",{children:a.coverage.contradicted.length}),e("span",{children:"claims corrected"})]})]}),e("div",{class:"plan-existing-docs-columns",children:[e("section",{class:"gaps",children:[e("h4",{children:"Not covered today"}),a.coverage.gaps.length?e("ul",{children:a.coverage.gaps.map(l=>e("li",{children:l},l))}):e("span",{class:"empty",children:"No gaps against the product sources."})]}),e("section",{class:"contradicted",children:[e("h4",{children:"Contradicted by the product"}),a.coverage.contradicted.length?e("ul",{children:a.coverage.contradicted.map(l=>e("li",{children:l},l))}):e("span",{class:"empty",children:"No claims contradicted."})]}),e("section",{class:"obsolete",children:[e("h4",{children:"Obsolete"}),a.coverage.obsolete.length?e("ul",{children:a.coverage.obsolete.map(l=>e("li",{children:l},l))}):e("span",{class:"empty",children:"Nothing obsolete found."})]}),e("section",{class:"preserved",children:[e("h4",{children:"Kept from the existing docs"}),a.coverage.preserved.length?e("ul",{children:a.coverage.preserved.map(l=>e("li",{children:l},l))}):e("span",{class:"empty",children:"Nothing marked for preservation."})]})]}),a.strengths.length>0&&e(Te,{tone:"info",children:["Strengths kept: ",a.strengths.join(" · ")]}),a.findings.length>0&&e("div",{class:"plan-existing-docs-findings",children:a.findings.map(l=>e("article",{children:[e("span",{class:`severity-pill ${l.severity}`,children:l.severity}),e("div",{children:[e("strong",{children:l.title}),l.description&&e("p",{children:l.description}),l.pages.length>0&&e("small",{children:l.pages.join(", ")})]})]},l.title))}),a.pages.length>0&&e("details",{class:"plan-existing-docs-dispositions",children:[e("summary",{children:["Where each existing page lands (",a.pages.length,")"]}),e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"Existing page"}),e("th",{children:"Decision"}),e("th",{children:"New page"}),e("th",{children:"Why"})]})}),e("tbody",{children:a.pages.map(l=>e("tr",{children:[e("td",{children:[l.title??l.path,e("small",{children:l.url??l.path})]}),e("td",{children:e("span",{class:`disposition-pill ${l.disposition}`,children:l.disposition})}),e("td",{children:l.into.length?l.into.map(c=>i.get(c)??c).join(", "):"—"}),e("td",{children:l.reason})]},l.path))})]})]})]},a.source)})})}function Tc({value:n,navigate:t,sync:i,onConfigure:a}){const s=bd(n),o=e("div",{class:"vrow",children:[e("span",{class:"vrow-label",children:"Monitoring"}),e("span",{class:"vrow-value",children:[i.on.length?Dc(i):"Not configured",e(_,{tone:"link",onClick:a,children:"Configure"})]})]});if(!s.ok)return e(Ue,{class:"freshness-panel unknown",title:"Freshness",flush:!0,children:e("div",{class:"vrows",children:[e("div",{class:"vrow",children:e("span",{class:"vrow-label",children:["Documentation freshness",e("small",{children:s.reason})]})}),o]})});const{status:l,pages:c,sources:d=[],trackedPages:m,notes:r=[]}=s.drift,g=d.filter(h=>h.changedPaths.length>0||h.filteredPaths>0),u=l==="stale"?`${c.length} page${c.length===1?"":"s"} behind the sources`:l==="current"?"Documentation matches the sources":"Freshness not tracked yet",v=l==="stale"?"Plan an update to bring these pages in line with what changed.":l==="current"?`${m??c.length} tracked page${(m??c.length)===1?"":"s"} have evidence that still matches the connected sources.`:r[0]??"Pages gain freshness tracking once an accepted update records their evidence.";return e(Ue,{class:`freshness-panel ${l}`,title:"Freshness",flush:!0,children:e("div",{class:"vrows",children:[e("div",{class:"vrow",children:[e("span",{class:"vrow-label",children:[u,e("small",{children:v})]}),e("span",{class:"vrow-value",children:[e(Me,{tone:l==="stale"?"warn":l==="current"?"good":"neutral",children:l==="stale"?`${c.length} stale`:l==="current"?"Up to date":"Not tracked"}),l==="stale"&&e(_,{tone:"link",onClick:()=>t("authoring"),children:"Plan an update"})]})]}),l==="stale"&&c.slice(0,8).map(h=>e("div",{class:"vrow freshness-page",children:[e("span",{class:"vrow-label",children:e("code",{children:h.page})}),e("span",{class:"vrow-value",children:(h.reasons??[]).map(y=>y.kind==="max-age"?`evidence older than ${y.ageDays??"?"} days`:`${y.source}: ${y.paths?.length??0} changed path${(y.paths?.length??0)===1?"":"s"}`).join(" · ")||"Sources changed"})]},h.page)),l==="stale"&&c.length>8&&e("div",{class:"vrow",children:e("span",{class:"vrow-label faint",children:["and ",c.length-8," more"]})}),g.map(h=>e("div",{class:"vrow",children:[e("span",{class:"vrow-label",children:[h.name,e("small",{children:"Source changed since the last update"})]}),e("span",{class:"vrow-value",children:[h.changedPaths.length," changed",h.filteredPaths>0&&e(ie,{children:[" · ",h.filteredPaths," filtered by watch rules"]})]})]},h.name)),o]})})}function Dc(n){const t=[Ei(Kt(n.on))];return n.budget?.maxUsd&&t.push(`$${n.budget.maxUsd.toFixed(2)} cap per run`),n.budget?.maxRunsPerDay&&t.push(`${n.budget.maxRunsPerDay} run${n.budget.maxRunsPerDay===1?"":"s"} per day`),n.budget?.maxMinutes&&t.push(`${n.budget.maxMinutes} min limit`),t.join(" · ")}function Rc({metric:n,pages:t,act:i,onClose:a,onReport:s,onCreateUpdate:o}){const l=n.items.filter(D=>D.state==="uncovered"||D.state==="needs-human"||D.state==="planned"||D.state==="stale"),c=n.items.filter(D=>D.state==="documented"||D.state==="excluded"),[d,m]=p([]),[r,g]=p(!1),u=l.filter(D=>d.includes(D.id)),v=l.length>0&&u.length===l.length;ae(()=>{const D=new Set(l.map(E=>E.id));m(E=>E.filter(A=>D.has(A)))},[n]);const h=async(D,E,A,j)=>{const W=await i(()=>K("/api/coverage/resolve",{id:D.id,action:E,page:A,reason:j}),"Coverage updated");W&&s(W)},y=(D,E)=>{m(A=>E?[...new Set([...A,D.id])]:A.filter(j=>j!==D.id))},[P,k]=p(""),[C,w]=p(!1),I=async()=>{const D=P.trim();if(!D||!u.length)return;let E;for(const A of u)E=await K("/api/coverage/resolve",{id:A.id,action:"exclude",reason:D}).catch(()=>E);E&&s(E),m([]),w(!1),k("")},L=async()=>{if(u.length){g(!0);try{await o(u)}finally{g(!1)}}};return e("div",{class:"sources-modal-scrim coverage-resolution-scrim",onClick:a,children:e("section",{class:"coverage-resolution-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"coverage-resolution-title",onClick:D=>D.stopPropagation(),children:[e("header",{children:[e("div",{children:[e("span",{class:"coverage-dialog-eyebrow",children:"Review documentation gaps"}),e("h2",{id:"coverage-resolution-title",children:n.label}),e("p",{children:"Choose everything you want to document, then create one update plan."})]}),e("button",{type:"button","aria-label":"Close",onClick:a,children:e($,{name:"close",size:17})})]}),l.length>0&&e("div",{class:"coverage-selection-toolbar",children:[e("label",{children:[e("input",{type:"checkbox",checked:v,onChange:D=>m(D.currentTarget.checked?l.map(E=>E.id):[])}),e("span",{children:["Select all ",l.length," ",l.length===1?"gap":"gaps"]})]}),e("strong",{children:[u.length," selected"]})]}),e("div",{class:"coverage-resolution-list",children:[l.length>0?e("section",{class:"coverage-gap-section","aria-label":"Gaps needing attention",children:[e("div",{class:"coverage-list-heading",children:[e("strong",{children:"Needs attention"}),e("small",{children:"Select gaps to add to this update"})]}),l.map(D=>e(vr,{item:D,pages:t,selected:d.includes(D.id),onSelectedChange:E=>y(D,E),onResolve:h},D.id))]}):e("div",{class:"coverage-gaps-empty",children:[e($,{name:"check",size:22}),e("strong",{children:"Everything is resolved"}),e("small",{children:"There are no documentation gaps in this category."})]}),c.length>0&&e("details",{class:"coverage-resolved-items",children:[e("summary",{children:[c.length," already resolved"]}),e("div",{children:c.map(D=>e(vr,{item:D,pages:t,selected:!1,onSelectedChange:()=>{},onResolve:h},D.id))})]})]}),e("footer",{children:[e("div",{class:"coverage-plan-summary",children:[e("strong",{children:u.length?`${u.length} ${u.length===1?"gap":"gaps"} ready to plan`:"No gaps selected"}),e("small",{children:u.length?"One plan will cover your full selection.":"Select one or more gaps to continue."})]}),e("div",{children:C?e("span",{class:"coverage-bulk-internal",children:[e(re,{value:P,"aria-label":"Why these are not part of the public documentation",placeholder:"Why are these internal?",onInput:D=>k(D.currentTarget.value)}),e(_,{size:"sm",tone:"ghost",onClick:()=>w(!1),children:"Cancel"}),e(_,{size:"sm",disabled:!P.trim(),onClick:()=>{I()},children:"Mark internal"})]}):e(ie,{children:[e(_,{onClick:a,children:"Close"}),e(_,{disabled:!u.length,onClick:()=>w(!0),children:["Mark internal",u.length?` (${u.length})`:""]}),e(_,{tone:"primary",busy:r,disabled:!u.length,onClick:()=>{L()},children:["Create update plan",u.length?` (${u.length})`:""]})]})})]})]})})}function vr({item:n,pages:t,selected:i,onSelectedChange:a,onResolve:s}){const[o,l]=p(n.page??n.suggestedPage??t[0]??""),[c,d]=p(n.reason??""),[m,r]=p(!1),[g,u]=p(null),v=async y=>{r(!0);try{await s(n,y,o,c),u(null)}finally{r(!1)}},h=n.state==="uncovered"||n.state==="needs-human"||n.state==="planned"||n.state==="stale";return e("article",{class:`coverage-resolution-item ${n.state} ${i?"selected":""}`,children:[e("div",{class:"coverage-resolution-item-heading",children:[e("span",{children:[e("strong",{children:n.label}),e("small",{children:[n.source,n.path].filter(Boolean).join(" · ")||n.page||"Priority reader outcome"})]}),h?e("label",{class:"coverage-update-choice",children:[e("input",{type:"checkbox",checked:i,onChange:y=>a(y.currentTarget.checked)}),e("span",{children:i?"Added":"Add to update"})]}):e(Me,{tone:n.state==="documented"?"good":"neutral",children:n.state})]}),h&&e("div",{class:"coverage-resolution-controls",children:[e("div",{class:"coverage-alternative-actions",children:[e("small",{children:"Or resolve without an update"}),e("span",{children:[t.length>0&&n.surface!=="verified-pages"&&e("button",{type:"button","aria-expanded":g==="link",onClick:()=>u(g==="link"?null:"link"),children:"Link existing page"}),n.surface==="reader-journeys"?e("button",{type:"button",disabled:m,onClick:()=>{v("remove-priority")},children:"No longer a priority"}):n.surface!=="verified-pages"&&e("button",{type:"button","aria-expanded":g==="exclude",onClick:()=>u(g==="exclude"?null:"exclude"),children:"Mark as internal"}),e("button",{type:"button",disabled:m,onClick:()=>{v("needs-human")},children:"Decide later"})]})]}),g==="link"&&e("div",{class:"coverage-inline-resolution",children:[e(Fe,{"aria-label":`Page for ${n.label}`,value:o,onChange:y=>l(y.currentTarget.value),children:t.map(y=>e("option",{value:y,children:[y,y===n.suggestedPage?" — suggested":""]},y))}),e(_,{size:"sm",disabled:!o||m,onClick:()=>{v("link")},children:"Link page"}),e("button",{type:"button","aria-label":"Cancel linking page",onClick:()=>u(null),children:e($,{name:"close",size:14})})]}),g==="exclude"&&e("div",{class:"coverage-inline-resolution",children:[e(re,{value:c,"aria-label":`Reason ${n.label} is internal`,placeholder:"Why is this not part of the public documentation?",onInput:y=>d(y.currentTarget.value)}),e(_,{size:"sm",disabled:!c.trim()||m,onClick:()=>{v("exclude")},children:"Mark internal"}),e("button",{type:"button","aria-label":"Cancel marking internal",onClick:()=>u(null),children:e($,{name:"close",size:14})})]})]}),n.state==="excluded"&&e("div",{class:"coverage-resolution-actions",children:[e("small",{children:n.reason}),e(_,{size:"sm",disabled:m,onClick:()=>{v("reset")},children:"Restore"})]})]})}function Mc({source:n,act:t,onClose:i}){const[a,s]=p({space:n.scope?.space??"",routePrefix:n.scope?.routePrefix??"",navigationGroup:n.scope?.navigationGroup??"",sharedPages:(n.scope?.sharedPages??[]).join(", ")}),[o,l]=p(!1),c=async()=>{l(!0);try{await t(()=>qn(`/api/sources/${encodeURIComponent(n.name)}`,{scope:a.space.trim()||a.routePrefix.trim()||a.navigationGroup.trim()||a.sharedPages.trim()?{space:a.space.trim()||void 0,routePrefix:a.routePrefix.trim()||void 0,navigationGroup:a.navigationGroup.trim()||void 0,sharedPages:In(a.sharedPages)}:null}),"Documentation ownership saved")!==void 0&&i()}finally{l(!1)}};return e("div",{class:"sources-modal-scrim ops-dialog-scrim",onClick:i,children:e("section",{class:"sources-reference-dialog source-scope-dialog ops-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"source-scope-title",onClick:d=>d.stopPropagation(),children:[e("header",{class:"ops-dialog-head",children:[e("div",{children:[e("h2",{id:"source-scope-title",children:"Documentation ownership"}),e("p",{children:["Keep changes from ",e("strong",{children:n.name})," inside a clear documentation boundary."]})]}),e("button",{type:"button",class:"ops-icon-button","aria-label":"Close",onClick:i,children:e($,{name:"close",size:16})})]}),e("div",{class:"sources-dialog-body ops-dialog-body",children:[e(U,{label:"Route prefix",hint:"Pages grounded in this source stay below this route.",children:e(re,{value:a.routePrefix,placeholder:"api or integrations/payments",onInput:d=>s({...a,routePrefix:d.currentTarget.value})})}),e(U,{label:"Navigation group",children:e(re,{value:a.navigationGroup,placeholder:"API reference",onInput:d=>s({...a,navigationGroup:d.currentTarget.value})})}),e(U,{label:"Space",children:e(re,{value:a.space,placeholder:"Developers",onInput:d=>s({...a,space:d.currentTarget.value})})}),e(U,{label:"Shared pages",hint:"Comma-separated paths or globs allowed outside the route. Overlapping route prefixes are rejected, and shared pages must be listed explicitly so one source cannot silently rewrite another source's section.",children:e(re,{value:a.sharedPages,placeholder:"docs/overview.mdx",onInput:d=>s({...a,sharedPages:d.currentTarget.value})})})]}),e("footer",{class:"ops-dialog-foot",children:[e(_,{tone:"ghost",onClick:i,children:"Cancel"}),e(_,{tone:"primary",busy:o,onClick:()=>{c()},children:"Save ownership"})]})]})})}function Lc({state:n,act:t,streamConnected:i,onError:a}){const s=Qt(n),o=s?"update":"create",l=n.receipt?.pendingSources??[],c=n.project?.defaultAgent??"",d=n.project?.defaultModel||It(c),m=Ft(c,d),[r,g]=p({request:"",scope:"starter",limits:{maxPages:5,maxScreenshots:0,maxMinutes:15},targetPages:"",clarificationMode:"review",agent:c,model:d,reasoning:c==="codex"?m:"",effort:c==="claude"?m:"",screenshots:"disabled"}),[u,v]=p(()=>Ir(n)),[h,y]=p(!1),[P,k]=p(!1),[C,w]=p(!1),I=Pt(r.agent),L=Ui(r.agent,r.model),[D,E]=p(!1),[A,j]=p(!1),[W,O]=p(),[ue,ge]=p(),[fe,ye]=p(!1),[ce,se]=p([]),[G,H]=p("documentation"),[N,oe]=p({source:"",version:"",from:"",to:""}),Ce=n.jobs.filter(X=>X.type.startsWith("plan:")||X.type.startsWith("author:")||X.type.startsWith("page-edit:")||X.type==="capture"||X.type==="sync"),ee=Ce.find(X=>X.status==="running"),Q=ee??Ce[0],x=!!(ee||A),B=u?void 0:n.documentationPlan;ae(()=>{ee&&E(!0)},[ee?.id,ee?.status]),ae(()=>{if(o!=="create"){O(void 0);return}let X=!0;return _e("/api/plans/discovery").then(J=>{X&&J?.suggestedPages&&typeof J.publicSignals=="number"&&O(J)}).catch(()=>{}),()=>{X=!1}},[o,n.project?.sources.length]),ae(()=>{let X=!0;return _e("/api/sources/git").then(J=>{X&&se(Array.isArray(J?.sources)?J.sources:[])}).catch(()=>{X&&se([])}),()=>{X=!1}},[n.project?.sources.map(X=>`${X.name}:${X.path}`).join("|")]),ae(()=>{if(r.screenshots==="disabled"){ge(void 0);return}let X=!0;return _e("/api/application/readiness").then(J=>{X&&ge(J)}).catch(()=>{X&&ge(void 0)}),()=>{X=!1}},[r.screenshots,n.project?.application?.baseUrl]);const F=async()=>{ye(!0);let X;try{X=await _e("/api/application/readiness")}catch{X=void 0}finally{ye(!1)}return ge(X),X};ae(()=>{v(Ir(n))},[n.documentationPlan?.id,n.documentationPlan?.status,n.documentationPlan?.proposalId,ft(n.runs).map(X=>`${X.id}:${X.status}`).join("|")]);const T=async()=>{if(x||fe)return;if(r.screenshots==="enabled"){const Je=ue?.status==="ready"?ue:await F();if(Je?.status!=="ready"){a(Je?`Screenshots are required for this run, but the application check did not pass: ${Je.message}`:"Screenshots are required for this run, but Doxloop could not check the application. Start it, then try again.");return}}if(G==="release-notes"&&(!N.version.trim()||!N.from.trim()||!N.to.trim())){a("Release notes need a version label and the two Git refs that bound the release.");return}const{reasoning:X,effort:J,targetPages:Ae,...Be}=r,ke=Ae.trim()?Number(Ae):void 0;if(ke!==void 0&&(!Number.isInteger(ke)||ke<1)){a("Target page count must be a whole number of at least 1.");return}if(ke!==void 0&&ke>r.limits.maxPages){a("The minimum pages exceeds this batch maximum. Raise Maximum pages or lower the minimum.");return}const Ke={...Be,scope:o==="create"?r.scope:"custom",...ke!==void 0?{targetPages:ke}:{},...G==="release-notes"?{template:{kind:"release-notes",version:N.version.trim(),from:N.from.trim(),to:N.to.trim(),sources:[N.source||ce[0]].filter(Boolean)},request:r.request.trim()||`Release notes for ${N.version.trim()}`}:{},mode:o,...r.agent==="codex"&&X?{reasoning:X}:{},...r.agent==="claude"&&J?{effort:J}:{}};j(!0),E(!0);try{await t(()=>K("/api/plans",Ke),"Planning started")?v(!1):E(!1)}finally{j(!1)}},Z=[["starter","Starter","First success path and essential reference"],["standard","Standard","Primary journeys, concepts, troubleshooting, and reference"],["comprehensive","Comprehensive","Complete evidence-supported public surface"]],Y=Z.find(([X])=>X===r.scope)?.[1]??"Custom",pe=[r.agent?On(r.agent):"Automatically detect",r.model,r.agent==="codex"?r.reasoning:r.agent==="claude"?r.effort:""].filter(Boolean).join(" · "),te=X=>g({...r,screenshots:ss(X),limits:{...r.limits,maxScreenshots:X==="yes"?r.limits.maxScreenshots||oa(r.scope,"auto").maxScreenshots:0}}),M=!!(B&&B.status!=="generated"),ne=G==="release-notes"?"Anything the release notes must call out?":"What should readers be able to do?",xe=G==="release-notes"?"Optional. For example: Lead with the new billing API and mark the removed legacy mode as breaking.":o==="create"?"For example: Help developers install the SDK, authenticate, and complete their first successful API request.":"For example: Document API key rotation and update the authentication journey with a TypeScript example.",Ie=ue?.status==="ready";return e("div",{class:"authoring-page pl-page",children:[!M&&e(ht,{kicker:"Plan",title:B?.status==="generated"?"Documentation plan":o==="create"?"Create documentation":"Update documentation",description:B?.status==="generated"?"The approved plan was generated. Review the proposal before anything reaches readers.":"Ask for what readers should be able to do. Doxloop researches, plans, and waits for your approval.",actions:!B&&n.documentationPlan&&n.documentationPlan.status!=="cancelled"?e(_,{icon:"file",onClick:()=>v(!1),children:["Open plan v",n.documentationPlan.version]}):void 0}),s&&l.length>0&&e(Te,{tone:"info",children:[l.length===1?`New source “${l[0]}” was added.`:`${l.length} new sources were added.`," The planning agent will inspect ",l.length===1?"it":"them"," and show where the documentation should change."]}),B?e(zc,{plan:B,act:t,busy:x,agents:n.agents??[],defaultAgent:c,onStartAnother:()=>v(!0)}):e("div",{class:"authoring-workbench",children:e("section",{class:"panel authoring-request pl-composer",children:[e("fieldset",{class:"authoring-fields pl-composer-prompt",disabled:x,children:[ce.length>0&&e("div",{class:"pl-composer-type",children:e(pt,{value:G,onChange:H,items:[["documentation","Documentation"],["release-notes","Release notes"]]})}),e("label",{class:"pl-composer-field",children:[e("span",{class:"sr-only",children:ne}),e(en,{rows:3,maxlength:2e3,value:r.request,placeholder:xe,onInput:X=>g({...r,request:X.currentTarget.value})})]}),G==="release-notes"&&e(oc,{sources:ce,value:N,onChange:oe,disabled:x})]}),e("div",{class:"pl-composer-row",children:[e("div",{class:"pl-composer-chips",children:[o==="create"&&e("button",{type:"button",class:"chip","aria-expanded":P,disabled:x,onClick:()=>k(!P),children:[e($,{name:"layers",size:14}),Y," scope",e($,{name:"chevronDown",size:13,class:`pl-chevron ${P?"open":""}`})]}),e("button",{type:"button",class:"chip","aria-expanded":h,disabled:x,onClick:()=>y(!h),children:[e($,{name:"bot",size:14}),e("span",{class:"sr-only",children:"Agent: "}),pe,e($,{name:"chevronDown",size:13,class:`pl-chevron ${h?"open":""}`})]}),e("button",{type:"button",class:"chip","aria-pressed":r.screenshots!=="disabled",disabled:x,onClick:()=>te(r.screenshots==="disabled"?"yes":"no"),children:[e($,{name:"camera",size:14}),"Screenshots ",r.screenshots==="disabled"?"off":"on"]}),e("button",{type:"button",class:"chip","aria-expanded":C,disabled:x,onClick:()=>w(!C),children:[e($,{name:"file",size:14}),"Up to ",r.limits.maxPages," pages",e($,{name:"chevronDown",size:13,class:`pl-chevron ${C?"open":""}`})]})]}),e(_,{disabled:x,busy:A||fe,tone:"primary",icon:"sparkle",onClick:()=>{T()},children:o==="create"?"Create documentation plan":"Plan documentation update"})]}),P&&o==="create"&&e("section",{class:"pl-composer-expand","aria-label":"Documentation scope",children:[e("div",{class:"radio-rows",children:Z.map(([X,J,Ae])=>{const Be=W?.suggestedPages[X];return e("button",{type:"button",class:r.scope===X?"selected":"","aria-pressed":r.scope===X,disabled:x,onClick:()=>g({...r,scope:X,limits:oa(X,r.screenshots)}),children:[e("span",{children:[e("strong",{children:J}),e("small",{children:Ae})]}),e("b",{children:Be?`About ${Be} pages`:"Estimating…"})]},X)})}),W&&e("small",{class:"pl-composer-hint",children:["Based on ",W.publicSignals," public source signal",W.publicSignals===1?"":"s",". Small products stay small; unsupported topics are never added as filler."]})]}),h&&e("fieldset",{class:"authoring-options pl-composer-expand",disabled:x,children:[e(U,{label:"Agent",children:e(Fe,{value:r.agent,onChange:X=>{const J=X.currentTarget.value,Ae=It(J),Be=Ft(J,Ae);g({...r,agent:J,model:Ae,reasoning:J==="codex"?Be:"",effort:J==="claude"?Be:""})},children:[e("option",{value:"",children:"Automatically detect"}),e("option",{value:"codex",children:"Codex"}),e("option",{value:"claude",children:"Claude Code"}),e("option",{value:"gemini",children:"Gemini"})]})}),e(U,{label:"Model",children:e(it,{value:r.model,options:I.map(X=>[X.id,X.label]),disabled:!r.agent,placeholder:"Default model",onValueChange:X=>g({...r,model:X})})}),e(U,{label:r.agent==="claude"?"Effort":"Reasoning",children:e(it,{value:r.agent==="claude"?r.effort:r.reasoning,options:L.map(X=>[X,X]),disabled:!r.agent,placeholder:"Default",onValueChange:X=>g({...r,[r.agent==="claude"?"effort":"reasoning"]:X})})}),e(U,{label:"Planner questions",hint:"What the planner does when it needs a decision from you.",children:e(Fe,{value:r.clarificationMode,onChange:X=>g({...r,clarificationMode:X.currentTarget.value}),children:[e("option",{value:"review",children:"Ask in review"}),e("option",{value:"defaults",children:"Use recommendations"}),e("option",{value:"stop",children:"Always wait for answers"})]})})]}),r.screenshots!=="disabled"&&e("section",{class:"pl-composer-expand pl-composer-capture","aria-label":"Application screenshot behavior",children:[ue?e("small",{class:`capture-readiness ${Ie?"ready":"missing"}`,children:[e($,{name:Ie?"check":"info",size:13}),ue.message,!ue.configured&&e(ie,{children:[" Configure it in ",e("button",{type:"button",onClick:()=>sn("settings",{section:"capture"},"push"),children:"Settings"}),"."]}),ue.configured&&!Ie&&e(ie,{children:[" ",e("button",{type:"button",disabled:fe,onClick:()=>{F()},children:fe?"Checking…":"Check again"})]})]}):e("small",{class:"capture-readiness",children:"Checking the application…"}),r.screenshots==="enabled"&&!Ie&&e("small",{class:"pl-composer-hint",children:"Screenshots are required for this run. Planning checks the application again when you start; start or configure it first."})]}),C&&e("section",{class:"pl-composer-expand pl-composer-limits","aria-label":"Run limits",children:[e(U,{label:"Minimum pages to write",hint:o==="create"?"Optional. Leave empty to let the evidence decide; the batch maximum limits what can be approved for this run.":"Optional. Ask for a larger update when the existing documentation is thin; the planner adds distinct evidence-backed pages rather than filler.",children:e(re,{type:"number",min:"1",max:"500",value:r.targetPages,placeholder:o==="create"?W?String(W.suggestedPages[r.scope]):"For example: 40":"For example: 25",onInput:X=>g({...r,targetPages:X.currentTarget.value})})}),e("label",{class:"field",children:[e("span",{class:"field-label",children:"Batch page limit"}),e("input",{"aria-label":"Batch page limit",type:"range",min:"1",max:"50",value:Math.min(50,r.limits.maxPages),onInput:X=>g({...r,limits:{...r.limits,maxPages:Number(X.currentTarget.value)}})})]}),["maxPages","maxScreenshots","maxMinutes"].map(X=>e(U,{label:X==="maxPages"?"Maximum pages":X==="maxScreenshots"?"Maximum screenshots":"Maximum minutes",children:e(re,{type:"number",min:X==="maxScreenshots"?0:1,value:r.limits[X],onInput:J=>g({...r,limits:{...r.limits,[X]:Number(J.currentTarget.value)}})})},X)),e("div",{class:"pl-composer-limit-foot",children:[e(Rs,{pages:r.limits.maxPages,agent:r.agent,model:r.model}),e(_,{size:"sm",onClick:()=>g({...r,scope:"starter",targetPages:"",screenshots:"disabled",limits:{maxPages:5,maxScreenshots:0,maxMinutes:15}}),children:"Small first batch"})]})]})]})}),(Q||A)&&e("section",{class:`panel pl-live ${D?"open":""}`,children:[e("header",{class:"panel-head pl-live-head",children:[e("button",{type:"button",class:"pl-live-toggle","aria-expanded":D,onClick:()=>E(!D),children:[e($,{name:"zap",size:16}),e("span",{class:"pl-live-title",children:[e("strong",{children:"Live activity"}),e("small",{children:ee?`${Zt(ee.type)} · started ${Ye(ee.startedAt)}`:A?"Starting planning agent…":Q?`${Zt(Q.type)} · ${Kn(Q.status)} ${Ye(Q.finishedAt??Q.startedAt)}`:"Show the latest workflow log"})]}),e($,{name:"chevronDown",size:16,class:`pl-chevron ${D?"open":""}`})]}),e("div",{class:"panel-actions",children:[ee&&e(Me,{tone:i?"good":"warn",children:i?"Live":"Reconnecting…"}),ee&&e(_,{size:"sm",tone:"danger",icon:"stop","aria-label":"Stop update",onClick:()=>{t(()=>K(`/api/jobs/${ee.id}/cancel`),"Update stopped")},children:"Stop"})]})]}),D&&Q&&e("div",{class:"panel-body flush",children:e(Pa,{job:Q,act:t,hideStop:!0,captures:!!n.project?.application})}),D&&!Q&&e("div",{class:"authoring-live-empty",children:"Starting the planning agent…"})]}),e(Ue,{class:"history-panel pl-history",title:"Update history",flush:!0,children:e(Qc,{jobs:n.jobs,onError:a})})]})}function zc({plan:n,act:t,busy:i,agents:a,defaultAgent:s,onStartAnother:o}){const[l,c]=p(n),[d,m]=p(""),[r,g]=p({}),[u,v]=p("all"),[h,y]=p(),[P,k]=p(!1),[C,w]=p([]),I=Re(null),[L,D]=p(!1),[E,A]=p(!1),[j,W]=p(!1),[O,ue]=p(!1),[ge,fe]=p(!1),[ye,ce]=p(!1),[se,G]=p(),[H,N]=p(),[oe,Ce]=p("idle"),[ee,Q]=p(0),[x,B]=p(""),[F,T]=p(""),[Z,Y]=p(!1),[pe,te]=p(!1),[M,ne]=p({}),xe=Re(n),[Ie,X]=p(null),J=f=>{xe.current=f,c(f),g(f.clarification.answers),X(null)};ae(()=>{n.id!==xe.current.id||hi(l)===hi(xe.current)?J(n):X(n)},[n.id,n.version,n.status,n.updatedAt]),ae(()=>{let f=!0;return n.version<=1?(w([]),()=>{f=!1}):(_e(`/api/plans/${n.id}/versions`).then(ve=>{f&&w(ve)}).catch(()=>{f&&w([])}),()=>{f=!1})},[n.id,n.version,n.updatedAt]);const Ae=i||["planning","revising","generating"].includes(n.status),Be=n.status==="generating"||i&&n.status==="approved",ke=!Ae&&!["generated","cancelled"].includes(n.status),Ke=n.status==="stale",Je=ke&&hi(l)!==hi(n),q=l.pages.filter(f=>f.priority!=="later"),ze=xl(q),Pe=Ec(l.execution.screenshots),Ze=q.filter(f=>f.visuals&&f.visuals.mode!=="none"),nn=Ze.reduce((f,ve)=>f+Math.max(1,ve.visuals?.estimatedCaptures??0),0),Ee=Pe==="enabled",z=Pe!=="disabled"&&Ze.length>0,Se=Ze.filter(f=>!f.visuals?.startPath?.trim()||!f.visuals?.workflow?.trim()||f.visuals?.captureSequence?.length!==f.visuals?.estimatedCaptures||(f.visuals?.captureSequence??[]).some(ve=>ve.trim().length<20)),tn=!Ee||H?.reachable===!0&&Se.length===0,R=_l(n),me=R==="retry-planning"?"Planning stopped before it proposed any pages. Retry planning to run it again with the same brief.":l.questions.length>0?"Resolve the required questions before approval.":Je?"Save your direct edits, then approve the updated plan.":Ee&&Ze.length===0?"Screenshots are required, but no page plans one. Add a guide, or change this run to Automatic.":Ee&&Se.length>0?`Complete the capture details for ${Se.map(f=>f.title).join(", ")} before approval.`:Ee&&oe==="checking"?"Checking that the application is reachable…":Ee&&!H?"Screenshots are required, but Doxloop could not check the application. Start it, then choose Check again.":Ee&&H?.reachable!==!0?`Screenshots are required, but the application is not reachable. ${H?.message??""}`.trim():void 0,Oe=R==="retry-planning",Ge=Oe&&l.pages.length===0,kn=a.filter(f=>f.executable),An=kn.map(f=>({name:f.name,status:Bs(f.authentication.status)})),mn=n.execution.agent||s,Tn=An.some(f=>f.name===mn&&f.status==="unauthenticated"),on=x||Pl(An,mn||void 0,s||void 0),Dn=An.some(f=>f.name===on&&f.status==="unauthenticated"),Jn=`${n.id}:${n.version}`,He=Oe?void 0:$l(q,Pe,H),mt=Cl({changed:Je,busy:i,hasPages:l.pages.length>0,hasQuestions:l.questions.length>0,captureRequired:Ee,hasVisualPages:Ze.length>0,captureReady:tn}),$e=h?q.findIndex(f=>f.id===h):-1,de=$e>=0?q[$e]:void 0,Ln=ze.pagesToWrite>0?`${ze.pagesToWrite} page${ze.pagesToWrite===1?"":"s"}`:"documentation changes",at=C.find(f=>f.version<n.version),ln=at?Nc(at,n):void 0,Cn=l.capabilities.filter(f=>f.disposition==="needs-human").length;ae(()=>{if(Pe==="disabled"){N(void 0),Ce("idle");return}let f=!0;return Ce("checking"),_e("/api/application/readiness").then(ve=>{f&&(N(ve),Ce("done"))}).catch(()=>{f&&(N(void 0),Ce("failed"))}),()=>{f=!1}},[Pe,ee]),ae(()=>{if(Pe==="disabled")return;const f=()=>{document.visibilityState==="visible"&&Q(ve=>ve+1)};return addEventListener("focus",f),document.addEventListener("visibilitychange",f),()=>{removeEventListener("focus",f),document.removeEventListener("visibilitychange",f)}},[Pe]);const cn=(f,ve)=>c({...l,scope:"custom",pages:q.map((Ne,je)=>je===f?ve:Ne)}),hn=(f,ve)=>{const Ne=f+ve;if(Ne<0||Ne>=q.length)return;const je=[...q],[Ve]=je.splice(f,1);je.splice(Ne,0,Ve),c({...l,scope:"custom",pages:je})},vt=()=>{const f=br(q.length);c({...l,scope:"custom",pages:[...q,f]}),y(f.id)},rt=()=>{const f=br(l.pages.length);return c(ve=>({...ve,scope:"custom",pages:[...ve.pages,f]})),y(f.id),f},Yn=f=>{const ve=q[f],Ne=ve?l.capabilities.map(je=>{const Ve=je.pageIds.filter(De=>De!==ve.id);return{...je,pageIds:Ve,disposition:Ve.length===0&&(je.disposition==="planned"||je.disposition==="existing")?"excluded":je.disposition}}):l.capabilities;c({...l,scope:"custom",pages:q.filter((je,Ve)=>Ve!==f),capabilities:Ne}),y(void 0)},zn=async(f=!1)=>{A(!0);try{await t(()=>K(`/api/plans/${n.id}/clarify`,{answers:r,useRecommendations:f}),"Continuing documentation plan")}finally{A(!1)}},gn=async()=>{ce(!0);try{await t(()=>K(`/api/plans/${n.id}/resume`),"Continuing with the current plan")}finally{ce(!1)}},At=async()=>{D(!0);try{const f=await t(()=>qn(`/api/plans/${n.id}`,Ts({...l,navigation:{...l.navigation,sections:l.navigation.sections.filter(ve=>ve.pageIds.length>0)}})),"Plan changes saved");f&&c(f)}finally{D(!1)}},Un=async()=>{if(d.trim()){A(!0);try{await t(()=>K(`/api/plans/${n.id}/revise`,{feedback:d}),"Plan revision started")&&m("")}finally{A(!1)}}},En=async f=>{G(f);try{await t(()=>K(`/api/plans/${n.id}/continue`,{strategy:f}),f==="resume"?"Continuing the documentation run":"Continuing with the work already done")}finally{G(void 0)}},dn=async()=>{fe(!0);try{await t(()=>K(`/api/plans/${n.id}/retry`,on?{agent:on}:{}),"Planning restarted")}finally{fe(!1)}},vn=async()=>{W(n.status!=="approved");try{if(n.status!=="approved"&&!await t(()=>K(`/api/plans/${n.id}/approve`),"Plan approved"))return;ue(!0),await t(()=>K(`/api/plans/${n.id}/generate`),"Documentation generation started")}finally{W(!1),ue(!1)}};if(ae(()=>{h&&!q.some(f=>f.id===h)&&y(void 0)},[h,q]),ae(()=>{if(!h)return;const f=ve=>{ve.key==="Escape"&&y(void 0)};return addEventListener("keydown",f),()=>removeEventListener("keydown",f)},[h]),n.status==="generated")return e(Ue,{class:"plan-complete-panel pl-complete",children:[e("div",{class:"plan-complete",children:[e("span",{children:e($,{name:"check",size:22})}),e("div",{children:[e("h2",{children:"Documentation proposal is ready"}),e("p",{children:"The approved plan was generated in an isolated workspace. Reader-facing files stay unchanged until you review and accept them."})]})]}),e("div",{class:"plan-complete-actions",children:[e(_,{onClick:o,children:"Plan another update"}),e(_,{tone:"primary",icon:"proposals",onClick:()=>sn("proposals",n.proposalId?{proposal:n.proposalId}:{},"push"),children:"Review generated files"})]})]});const bt=n.scope==="custom"?"Custom scope":n.scope.charAt(0).toUpperCase()+n.scope.slice(1),Bn=l.execution.agent?`${On(l.execution.agent)}${l.execution.model?` · ${l.execution.model}`:""}`:"",Nn=l.execution.limits??{maxPages:50,maxScreenshots:20,maxMinutes:30},Zn=Pe==="disabled"?void 0:oe==="checking"?["neutral","Checking…"]:H?.reachable?[H.status==="authentication-required"?"warn":"good",H.status==="authentication-required"?"Sign-in needed":"Reachable"]:["warn","Not reachable"],st=f=>f==="create"?"good":f==="update"?"info":f==="remove"?"bad":"neutral",Rn=f=>u==="all"||(u==="changes"?f.action!=="preserve":f.action===u),be=f=>e("span",{class:`badge no-dot ${f.priority==="must-have"?"teal":"neutral"}`,children:f.priority==="must-have"?"Essential":"Recommended"}),Tt=f=>e(ie,{children:[e("span",{class:"pl-page-purpose",children:f.purpose}),e("span",{class:`pl-page-camera ${f.visuals&&f.visuals.mode!=="none"&&Pe!=="disabled"?"on":""}`,title:f.visuals&&f.visuals.mode!=="none"?`${f.visuals.estimatedCaptures} planned screenshot${f.visuals.estimatedCaptures===1?"":"s"}`:"No screenshots planned",children:e($,{name:"camera",size:15})}),(n.mode==="update"||f.action!=="create")&&e("span",{class:`badge no-dot ${st(f.action)}`,children:or(f.action)}),be(f),e("button",{type:"button",class:"pl-icon-btn","aria-label":`Page options: ${f.title}`,onClick:ve=>{ve.stopPropagation(),y(f.id)},children:e($,{name:"chevronRight",size:16})})]});return e("div",{class:"documentation-plan-review pl-review",children:[e("section",{class:"pl-review-head",children:[e("div",{class:"pl-review-heading",children:[e("span",{class:"kicker",children:["Plan version ",n.version," · ",Be?"approved":n.status==="planning"||n.status==="revising"?"started":"proposed"," ",Ye(Be?n.updatedAt:n.createdAt)]}),e("h1",{children:Be?"Writing your documentation":n.status==="planning"?"Researching your documentation plan":n.status==="revising"?"Revising your documentation plan":Ge?"No pages proposed yet":"Review your documentation plan"})]}),e("div",{class:"pl-review-actions",children:[e("div",{class:"pl-review-buttons",children:[n.status!=="ready-for-review"&&(Be?e(Me,{tone:"info",children:"Writing"}):e(Me,{tone:Vn(n.status),children:Kn(n.status)})),mt.showSave&&e(_,{busy:L,onClick:()=>{At()},children:"Save changes"}),!Ae&&!Oe&&e(_,{icon:"sparkle",disabled:i,onClick:()=>{I.current?.focus(),I.current?.scrollIntoView({block:"center",behavior:"smooth"})},children:"Ask the agent to revise"}),!Ae&&(R==="retry-planning"?e(_,{tone:"primary",icon:"refresh",busy:ge,disabled:i,onClick:()=>{dn()},children:"Retry planning"}):e(_,{tone:"primary",icon:Je?"lock":"play",busy:j||O,disabled:mt.approveDisabled,onClick:()=>{vn()},children:Je?"Save changes before approval":R==="generate"?`Generate ${Ln}`:R==="retry-generating"?`Retry generating ${Ln}`:`Approve & generate ${Ln}`}))]}),!Ae&&e("small",{class:"pl-review-hint",children:[e($,{name:me?"help":"lock",size:13}),me??(Cn>0?`${Cn} coverage ${Cn===1?"item needs":"items need"} a decision; you can save and continue if intentionally deferred.`:"Nothing is written until you approve this exact plan.")]})]})]}),Ie&&e("div",{class:"plan-pending-refresh pl-pending",role:"status",children:[e($,{name:"info",size:15}),e("span",{children:[e("strong",{children:"A newer version of this plan arrived while you were editing."})," Keep your unsaved edits, or load the new version and lose them."]}),e("span",{class:"plan-pending-actions",children:[e(_,{size:"sm",onClick:()=>X(null),children:"Keep my edits"}),e(_,{size:"sm",tone:"primary",onClick:()=>J(Ie),children:"Load new version"})]})]}),Ke&&e(Ue,{class:"plan-stale-panel",title:"Sources changed since this plan was proposed",description:"The plan itself is unchanged and can be approved as it is; generation reads the current sources when it writes each page. Ask the agent to revise only if the change should alter which pages are written.",actions:e(ie,{children:[e(_,{size:"sm",icon:"refresh",busy:ye,disabled:i,onClick:()=>{gn()},children:"Clear this notice"}),e(_,{size:"sm",icon:"wand",disabled:i,onClick:()=>I.current?.focus(),children:"Ask the agent to revise"})]}),children:e("p",{class:"pl-stale-copy",children:"Approve to generate from the current sources, or ask the agent to revise the plan first."})}),Oe&&e(Ue,{class:"plan-failed-panel pl-failed",icon:"alert",title:"Planning did not finish",description:Tn?`${On(mn)} is signed out on this computer, so it could not research your sources. Retry with a signed-in assistant, or sign ${On(mn)} in again first.`:"The planning agent stopped before it proposed any pages. Nothing in your project changed.",children:[n.error&&e("pre",{class:"plan-failed-error pl-error",children:Oi(n.error)}),kn.length>0&&e(U,{label:"Retry with",children:e(Fe,{"aria-label":"Assistant to retry planning with",value:on,disabled:i,onChange:f=>B(f.currentTarget.value),children:kn.map(f=>e("option",{value:f.name,children:`${On(f.name)} · ${wd(f.authentication.status)}`},f.name))})}),e("div",{class:"pl-inline-actions",children:e(_,{tone:"primary",icon:"refresh",busy:ge,disabled:i,onClick:()=>{dn()},children:"Retry planning"})}),Dn&&e(Te,{tone:"warn",children:[On(on)," is signed out. ",kd(on)]})]}),n.error&&!Ke&&!Oe&&e(Te,{tone:"bad",children:n.error}),n.status==="failed"&&n.failure&&(n.failure.resumable||n.failure.ignorable)&&e(Ue,{class:"plan-recovery-panel pl-recovery",title:"Continue without starting over",description:n.failure.stage==="generate"?"The pages and screenshots the agent already produced are preserved in this run’s workspace. Continue from there instead of paying for another full run.":"The planner proposed a plan but could not meet every planning gate. You can review and edit that plan yourself instead of running the planner again.",children:[e("ul",{class:"plan-recovery-options",children:[n.failure.stage==="generate"&&n.failure.resumable&&e("li",{children:[e("strong",{children:"Resume the run"}),e("span",{children:"Starts the agent again in the same workspace with a brief of what is finished. Verified screenshots and completed pages are kept; only the unfinished or rejected parts are redone."})]}),n.failure.stage==="generate"&&n.failure.ignorable&&e("li",{children:[e("strong",{children:"Ignore the problems"}),e("span",{children:"Accepts the generated files for review now. Each screenshot problem is recorded on its step as text-only and listed on the proposal so you can judge it before publishing."})]}),n.failure.stage!=="generate"&&e("li",{children:[e("strong",{children:"Review this plan anyway"}),e("span",{children:"Opens the plan the planner left behind. The unmet gate becomes a note on the review, and approval still checks required screenshots and open questions."})]})]}),n.failure.stage==="generate"&&n.failure.proposalId&&e("section",{class:"plan-recovery-captures","aria-label":"Screenshots already captured",children:[e("h3",{children:"Screenshots already captured"}),e("p",{children:"These images are kept by both choices below. Resume recaptures only the states that are still missing."}),e(Ms,{live:!1,run:n.failure.proposalId})]}),e("footer",{class:"plan-recovery-actions pl-inline-actions",children:[n.failure.stage==="generate"&&n.failure.resumable&&e(_,{tone:"primary",icon:"play",busy:se==="resume",disabled:i||!!se,onClick:()=>{En("resume")},children:"Resume generation"}),n.failure.stage==="generate"&&n.failure.ignorable&&e(_,{icon:"check",busy:se==="ignore-errors",disabled:i||!!se,onClick:()=>{En("ignore-errors")},children:"Ignore problems & continue"}),n.failure.stage!=="generate"&&n.failure.ignorable&&e(_,{tone:"primary",icon:"check",busy:se==="ignore-errors",disabled:i||!!se,onClick:()=>{En("ignore-errors")},children:"Review this plan anyway"}),e("small",{children:n.failure.stage==="generate"?`“Retry generating” above starts a new run from the approved plan${n.failure.resumable?" only if this workspace can no longer be reused":""}.`:"Or ask the agent to revise the plan below, which runs the planner again."})]})]}),Ae&&e(Ue,{class:"plan-progress-panel pl-progress",children:e("div",{class:"plan-progress",children:[e("span",{class:"spinner"}),e("div",{children:[e("strong",{children:Be?"Writing the approved documentation":n.status==="revising"?"Revising the documentation plan":"Researching sources and existing documentation"}),e("p",{children:Be?"Pages are written in batches. The proposal opens in Review when writing finishes; your current documentation stays unchanged until you apply it.":"Follow the activity log below. The documentation project stays unchanged during planning."})]})]})}),!Ae&&e(ie,{children:[e(Ue,{class:"pl-brief",title:"Documentation brief",actions:ke||P?e(_,{tone:"link",onClick:()=>k(!P),children:P?"Close brief":ke?"Edit brief":"Show details"}):void 0,children:[n.productProfile&&e("p",{class:"pl-brief-text",children:n.productProfile}),e("p",{class:"pl-brief-text",children:n.summary||"No additional summary was provided."}),e("div",{class:"pl-brief-badges",children:[(()=>{const f=q.filter(Ne=>Ne.action==="preserve").length,ve=q.length-f;return e("span",{class:"badge no-dot",children:[ve," page",ve===1?"":"s"," to write",f>0?` · ${f} kept as is`:""]})})(),e("span",{class:"badge no-dot",children:[l.navigation.sections.length," section",l.navigation.sections.length===1?"":"s"]}),nn>0&&Pe!=="disabled"&&e("span",{class:"badge no-dot",children:[nn," screenshot",nn===1?"":"s"]}),e("span",{class:"badge no-dot teal",children:bt}),Bn&&e("span",{class:"badge no-dot",children:Bn}),n.mode==="update"&&ze.create>0&&e("span",{class:"badge no-dot good",children:[ze.create," new"]}),n.mode==="update"&&ze.update>0&&e("span",{class:"badge no-dot info",children:[ze.update," updated"]}),n.mode==="update"&&ze.remove>0&&e("span",{class:"badge no-dot bad",children:[ze.remove," deleted"]}),n.mode==="update"&&ze.preserve>0&&e("span",{class:"badge no-dot",children:[ze.preserve," unchanged"]})]}),P&&e("div",{class:"pl-brief-editor",children:[e("section",{class:"plan-coverage-summary pl-coverage-summary",children:[e("header",{children:[e("div",{children:[e("strong",{children:"Evidence coverage"}),e("small",{children:[l.discovery.publicSignals," deterministic public signals inspected"]})]}),e("span",{children:[l.capabilities.filter(f=>f.disposition==="planned"||f.disposition==="existing").length," mapped"]})]}),l.capabilities.length>0?e("ul",{children:l.capabilities.map((f,ve)=>e("li",{children:[e("span",{children:[e("b",{children:f.title}),e("small",{children:f.kind})]}),ke?e(Fe,{"aria-label":`Coverage decision for ${f.title}`,value:f.disposition,onChange:Ne=>c({...l,scope:"custom",capabilities:l.capabilities.map((je,Ve)=>Ve===ve?{...je,disposition:Ne.currentTarget.value}:je)}),children:[e("option",{value:"planned",children:"Document"}),e("option",{value:"existing",children:"Existing documentation"}),e("option",{value:"excluded",children:"Exclude as internal"}),e("option",{value:"needs-human",children:"Decide later"})]}):e("em",{class:f.disposition,children:f.disposition==="needs-human"?"Needs decision":f.disposition})]},f.id))}):e("p",{children:"No capability map was returned for this plan."})]}),e(U,{label:"Audiences",hint:"Comma-separated",children:e(re,{disabled:!ke,value:l.audiences.join(", "),onInput:f=>c({...l,scope:"custom",audiences:In(f.currentTarget.value)})})}),e(U,{label:"Reader outcomes",hint:"Comma-separated",children:e(re,{disabled:!ke,value:l.outcomes.join(", "),onInput:f=>c({...l,scope:"custom",outcomes:In(f.currentTarget.value)})})}),e(U,{label:"Reader experience",children:e(Fe,{disabled:!ke,value:l.experienceLevel,onChange:f=>c({...l,scope:"custom",experienceLevel:f.currentTarget.value}),children:[e("option",{value:"beginner",children:"New to the product"}),e("option",{value:"intermediate",children:"Some experience"}),e("option",{value:"advanced",children:"Experienced"}),e("option",{value:"mixed",children:"Mixed audience"})]})}),e(U,{label:"Preferred examples",hint:"Comma-separated languages or tools",children:e(re,{disabled:!ke,value:l.preferredExamples.join(", "),onInput:f=>c({...l,scope:"custom",preferredExamples:In(f.currentTarget.value)})})}),e(U,{label:"Locale",children:e(re,{disabled:!ke,value:l.locale,onInput:f=>c({...l,scope:"custom",locale:f.currentTarget.value})})}),e(U,{label:"Accessibility target",children:e(re,{disabled:!ke,value:l.accessibilityTarget,onInput:f=>c({...l,scope:"custom",accessibilityTarget:f.currentTarget.value})})}),e(U,{label:"Style guide",children:e(re,{disabled:!ke,value:l.styleGuide,onInput:f=>c({...l,scope:"custom",styleGuide:f.currentTarget.value})})}),e(U,{label:"Terminology",hint:"One preferred term = guidance per line",children:e(en,{disabled:!ke,rows:3,value:_o(l.terminology),onInput:f=>c({...l,scope:"custom",terminology:So(f.currentTarget.value)})})}),e(U,{label:"Exclusions",hint:"Comma-separated",children:e(en,{disabled:!ke,rows:3,value:l.exclusions.join(", "),onInput:f=>c({...l,scope:"custom",exclusions:In(f.currentTarget.value)})})}),e(U,{label:"Plan-wide instructions",children:e(en,{disabled:!ke,rows:3,value:l.instructions,onInput:f=>c({...l,scope:"custom",instructions:f.currentTarget.value})})})]})]}),l.questions.length>0&&e(Ue,{class:"pl-questions",icon:"alert",title:"Needs your decision",actions:e(Me,{tone:"warn",children:[l.questions.length," open question",l.questions.length===1?"":"s"]}),children:[l.questions.map(f=>{const ve=r[f.id]??"",Ne=!!f.recommendation&&ve.trim()===f.recommendation.trim(),je=!f.recommendation||M[f.id]||ve.trim()!==""&&!Ne;return e("article",{class:"pl-question",children:[e("strong",{children:f.question}),f.whyItMatters&&e("p",{children:f.whyItMatters}),f.recommendation&&e("div",{class:"pl-recommendation",children:[e($,{name:"sparkle",size:16}),e("div",{children:[e("strong",{children:"Recommendation"}),e("span",{children:f.recommendation})]})]}),e("div",{class:"pl-question-actions",children:[f.recommendation&&(Ne?e(_,{size:"sm",tone:"ghost",icon:"check",disabled:!0,children:"Recommendation applied"}):e(_,{size:"sm",tone:"primary",onClick:()=>{g({...r,[f.id]:f.recommendation}),ne({...M,[f.id]:!1})},children:"Use recommendation"})),f.recommendation&&!je&&e(_,{size:"sm",tone:"ghost",onClick:()=>ne({...M,[f.id]:!0}),children:"Write my own answer"})]}),je&&e(re,{"aria-label":`Your answer: ${f.question}`,value:ve,placeholder:f.recommendation??"Enter your decision",onInput:Ve=>g({...r,[f.id]:Ve.currentTarget.value})})]},f.id)}),e("footer",{class:"pl-question-foot",children:[e(_,{size:"sm",disabled:i||!l.questions.every(f=>f.recommendation),onClick:()=>{zn(!0)},children:"Use all recommendations"}),e(_,{size:"sm",tone:"primary",busy:E,disabled:i||!l.questions.every(f=>r[f.id]?.trim()),onClick:()=>{zn()},children:"Continue planning"})]})]}),!Ge&&e("section",{class:"pl-structure","aria-label":"Documentation structure",children:[e("h2",{children:"Review documentation structure"}),e("div",{class:"pl-structure-tools",children:[e(pt,{value:u,onChange:v,items:[["all","All pages"],["changes","Changes"],["create","New"],["update","Updated"],["preserve","Unchanged"],...ze.remove>0?[["remove","Deleted"]]:[]]}),ke&&e(_,{size:"sm",icon:"plus",onClick:vt,children:"Add page"})]}),e(vc,{plan:l,editable:ke,onChange:f=>c(ve=>({...ve,scope:"custom",navigation:f})),pageClass:f=>`plan-tree-page ${f.action} ${f.priority} ${Rn(f)?"":"pl-filtered-out"}`,renderPage:Tt,onOpenPage:f=>y(f.id),...ke?{onCreatePage:rt}:{}}),q.some(f=>f.action==="remove"&&Rn(f))&&e("div",{class:"pl-removed",role:"list","aria-label":"Pages to delete",children:[e("header",{children:[e($,{name:"trash",size:15}),e("strong",{children:"Pages to delete"}),e("span",{children:[q.filter(f=>f.action==="remove").length," page",q.filter(f=>f.action==="remove").length===1?"":"s"]})]}),q.flatMap((f,ve)=>f.action==="remove"&&Rn(f)?[e("div",{class:`pl-removed-row plan-tree-page ${f.action} ${f.priority}`,role:"listitem",children:[e("button",{type:"button",class:"pl-removed-title",title:f.path,onClick:()=>y(f.id),children:e("strong",{children:f.title})}),Tt(q[ve])]},f.id)]:[])]}),e("small",{class:"pl-structure-hint",children:"Drag pages between sections, or focus a row and use Alt with the arrow keys. Open a page to edit its purpose, priority, and screenshots."})]}),!Ge&&e(Ue,{class:"pl-facts",flush:!0,children:e("div",{class:"vrows",children:[!(H?.configured===!1&&nn===0)&&e(ie,{children:[e("div",{class:"vrow",children:[e("span",{class:"vrow-label",children:["Application screenshots",e("small",{children:[nn>0?`${nn} planned across ${Ze.length} page${Ze.length===1?"":"s"}`:"No application screenshots planned",H?.status==="authentication-required"&&Pe!=="disabled"?" · needs sign-in":""]})]}),e("span",{class:"vrow-value",children:[Zn&&e(Me,{tone:Zn[0],children:Zn[1]}),e(Fe,{"aria-label":"Screenshot policy",disabled:!ke,value:Pe,onChange:f=>{const ve=f.currentTarget.value;c({...l,execution:{...l.execution,screenshots:ve},pages:l.pages.map(Ne=>!Ne.visuals||Ne.visuals.mode==="none"?Ne:{...Ne,visuals:{...Ne.visuals,mode:ve==="enabled"?"required":ve==="auto"?"recommended":Ne.visuals.mode}})})},children:[e("option",{value:"auto",children:"Automatic"}),e("option",{value:"enabled",children:"Require screenshots"}),e("option",{value:"disabled",children:"No screenshots"})]})]})]}),Pe!=="disabled"&&e("div",{class:"pl-fact-detail",children:[e("div",{class:`plan-capture-readiness pl-readiness ${H?.reachable?"ready":"missing"}`,children:[e($,{name:H?.reachable?"check":"info",size:15}),e("span",{children:[e("strong",{children:oe==="checking"?"Checking the application…":H?H.status==="authentication-required"?"Sign-in may be required during capture":H.reachable?"Application reachable":"Application setup needed":"Application check did not complete"}),e("small",{children:H?.message??(oe==="checking"?"Confirming the configured application answers before capture.":"Doxloop could not reach the readiness check. Start the application, then check again.")})]}),H?.configured===!1?e(_,{size:"sm",onClick:()=>sn("settings",{section:"capture"},"push"),children:"Configure application"}):e(_,{size:"sm",icon:"refresh",busy:oe==="checking",onClick:()=>Q(f=>f+1),children:"Check again"})]}),Ze.length>0&&e("button",{type:"button",class:"btn link","aria-expanded":pe,onClick:()=>te(!pe),children:pe?"Hide planned screenshots":`Show planned screenshots for ${Ze.length} page${Ze.length===1?"":"s"}`}),pe&&Ze.length>0&&e("ul",{class:"plan-screenshot-pages",children:Ze.map(f=>e("li",{children:[e("span",{class:"plan-screenshot-page-icon",children:e($,{name:"camera",size:14})}),e("span",{children:[e("strong",{children:f.title}),e("small",{children:[f.visuals?.startPath?e("code",{children:f.visuals.startPath}):e("em",{children:"Starting route needed"}),f.visuals?.rationale&&e(ie,{children:[" · ",f.visuals.rationale]})]})]}),e("b",{children:[f.visuals?.estimatedCaptures," ",Pe==="enabled"?"required":(f.visuals?.estimatedCaptures??0)===1?"candidate":"candidates"]})]},f.id))}),Pe==="enabled"&&Ze.length===0&&e(Te,{tone:"bad",children:"Required screenshot mode needs at least one visible UI guide. Open a page and choose “Require screenshots,” or change this run to Automatic."}),z&&Se.length>0&&e(Te,{tone:Ee?"bad":"info",children:[Ee?"Add":"For better automatic capture, add"," a starting route, capture workflow, and one meaningful capture-sequence line per planned screenshot for ",Se.map(f=>f.title).join(", "),Ee?" before approval.":". Documentation generation can continue if those optional captures are skipped."]})]})]}),(n.advisories??[]).some(f=>!(He&&/procedural pages? ha(s|ve) application screenshots/.test(f)))&&e("div",{class:"pl-fact-detail",children:n.advisories?.filter(f=>!(He&&/procedural pages? ha(s|ve) application screenshots/.test(f))).map(f=>e(Te,{tone:"info",children:f},f))}),e("div",{class:"vrow",children:[e("span",{class:"vrow-label",children:["Batch limits",e("small",{children:"Approval and proposal validation enforce these maxima."})]}),e("span",{class:"vrow-value",children:[Nn.maxPages," pages · ",Nn.maxScreenshots," screenshots · ",Nn.maxMinutes," minutes per batch",ke&&e("button",{type:"button",class:"pl-icon-btn","aria-label":"Edit batch limits","aria-expanded":Z,onClick:()=>Y(!Z),children:e($,{name:Z?"chevronUp":"chevronRight",size:16})})]})]}),Z&&ke&&e("div",{class:"pl-fact-detail",children:["maxPages","maxScreenshots","maxMinutes"].map(f=>e(U,{label:f==="maxPages"?"Maximum pages":f==="maxScreenshots"?"Maximum screenshots":"Maximum minutes",children:e(re,{disabled:!ke,type:"number",min:f==="maxScreenshots"?0:1,value:Nn[f],onInput:ve=>c({...l,execution:{...l.execution,limits:{...Nn,[f]:Number(ve.currentTarget.value)}}})})},f))}),e("div",{class:"vrow",children:[e("span",{class:"vrow-label",children:"Sources changed since this plan"}),e("span",{class:"vrow-value",children:[Ke?"Sources changed":"None",e(Me,{tone:Ke?"warn":"good",children:Ke?"Review advised":"Current"})]})]}),e("div",{class:"vrow",children:[e("span",{class:"vrow-label",children:"Estimated run"}),e("span",{class:"vrow-value",children:e(Rs,{pages:ze.pagesToWrite||q.length,agent:l.execution.agent,model:l.execution.model})})]})]})}),n.existingDocumentation&&n.existingDocumentation.length>0&&e(Ue,{class:"plan-existing-docs-panel",title:"Existing documentation audit",description:"What the agent found in the documentation being rewritten, and where every existing page lands in this plan.",children:e(Ac,{assessments:n.existingDocumentation,pages:l.pages})}),ln&&e(Ue,{class:"pl-version",title:`Changed since version ${at.version}`,actions:e("span",{class:"badge no-dot",children:["Version ",n.version]}),children:[e("div",{class:"pl-brief-badges",children:[ln.added.length>0&&e("span",{class:"badge no-dot good",children:["+ ",ln.added.length," page",ln.added.length===1?"":"s"]}),ln.changed.length>0&&e("span",{class:"badge no-dot info",children:[ln.changed.length," edited"]}),ln.removed.length>0&&e("span",{class:"badge no-dot bad",children:["− ",ln.removed.length," removed"]}),ln.briefChanged&&e("span",{class:"badge no-dot",children:"Brief updated"})]}),e("details",{class:"pl-version-details",children:[e("summary",{children:"See version changes"}),e("ul",{children:[ln.added.map(f=>e("li",{children:["Added “",f,"”"]},`add-${f}`)),ln.changed.map(f=>e("li",{children:["Changed “",f,"”"]},`change-${f}`)),ln.removed.map(f=>e("li",{children:["Removed “",f,"”"]},`remove-${f}`))]})]})]}),He&&F!==Jn&&e("section",{class:"plan-coverage-warning pl-coverage-warning",role:"status","aria-label":"Screenshot coverage",children:[e("span",{class:"plan-coverage-warning-icon",children:e($,{name:"camera",size:18})}),e("div",{children:[e("strong",{children:[He.withScreenshots===0?`None of the ${He.guides} how-to guides has a planned screenshot.`:`Only ${He.withScreenshots} of ${He.guides} how-to guides have a planned screenshot.`,He.explained>0?He.explained===He.guides-He.withScreenshots?" The planner gave a reason for every text-only guide; open a page to read it.":` The planner gave a reason for ${He.explained} text-only guide${He.explained===1?"":"s"}; open a page to read it.`:""]}),e("p",{children:He.reason==="sign-in"?"Doxloop could not get past the sign-in page of your app. Sign in under Settings → Screenshots, then ask the agent to update the plan.":He.reason==="unreachable"?"Doxloop could not reach your app while planning. Start it and check Settings → Screenshots, then ask the agent to update the plan.":"Your app is reachable, so the plan can include more. Ask the agent to add screenshots to the guides that walk through the app."})]}),e("div",{class:"plan-coverage-warning-actions",children:[He.reason==="unknown"?e(_,{icon:"sparkle",onClick:()=>{m("Add screenshots to every guide that walks through the app, with one screenshot for each step that changes the screen."),I.current?.focus()},children:"Ask for more screenshots"}):e(_,{icon:He.reason==="sign-in"?"key":"settings",onClick:()=>sn("settings",{section:"capture"},"push"),children:He.reason==="sign-in"?"Sign in to your app":"Open screenshot settings"}),e(_,{tone:"ghost",onClick:()=>T(Jn),children:"Continue without"})]})]}),e("div",{class:"plan-revision-panel pl-revise",children:[e("span",{class:"pl-revise-icon",children:e($,{name:"sparkle",size:16})}),e(en,{ref:I,"aria-label":"Want to change the plan?",disabled:i,rows:1,maxlength:1500,value:d,placeholder:"Want to change the plan? Tell the agent what to revise…",onInput:f=>m(f.currentTarget.value),onKeyDown:f=>{f.key==="Enter"&&(f.metaKey||f.ctrlKey)&&(f.preventDefault(),Un())}}),e(_,{disabled:!d.trim()||i||Je,busy:E,onClick:()=>{Un()},children:"Send"})]}),Je&&e("small",{class:"pl-revise-hint",children:"Save your direct edits before asking the agent to revise the plan."}),de&&e("div",{class:"plan-page-drawer-backdrop",onMouseDown:f=>{f.currentTarget===f.target&&y(void 0)},children:e("aside",{class:"plan-page-drawer pl-drawer",role:"dialog","aria-modal":"true","aria-labelledby":"plan-page-drawer-title",children:[e("header",{children:[e("div",{children:[e("span",{class:"kicker",children:["Page ",$e+1," of ",q.length]}),e("h2",{id:"plan-page-drawer-title",children:"Page details"})]}),e("button",{type:"button","aria-label":"Close page details",onClick:()=>y(void 0),children:e($,{name:"close",size:18})})]}),e("div",{class:"plan-page-drawer-body",children:[e("div",{class:"plan-page-drawer-name",children:[e(re,{disabled:!ke,value:de.title,"aria-label":"Page title",onInput:f=>cn($e,{...de,title:f.currentTarget.value})}),e("span",{class:`badge no-dot ${st(de.action)}`,children:or(de.action)})]}),e(U,{label:"Purpose",children:e(en,{disabled:!ke,rows:4,value:de.purpose,onInput:f=>cn($e,{...de,purpose:f.currentTarget.value})})}),e(U,{label:"What should happen",children:e(Fe,{disabled:!ke,value:de.action,onChange:f=>cn($e,{...de,action:f.currentTarget.value}),children:[e("option",{value:"create",children:"Create this page"}),e("option",{value:"update",children:"Update this page"}),e("option",{value:"preserve",children:"Leave unchanged"}),e("option",{value:"remove",children:"Delete existing page"})]})}),e(U,{label:"Priority in this generation",children:e(Fe,{disabled:!ke,value:de.priority,onChange:f=>cn($e,{...de,priority:f.currentTarget.value}),children:[e("option",{value:"must-have",children:"Essential"}),e("option",{value:"next",children:"Recommended"})]})}),e(U,{label:"Documentation section",hint:"The page type the generator files this page under, such as how-to or reference.",children:e(re,{disabled:!ke,value:de.type,onInput:f=>cn($e,{...de,type:f.currentTarget.value})})}),e(U,{label:"Diagram",hint:"Concept pages default to a required Mermaid diagram; the writer must include one and the editor previews it.",children:e(Fe,{disabled:!ke,value:de.diagram??(de.type==="concept"?"required":"none"),onChange:f=>cn($e,{...de,diagram:f.currentTarget.value==="required"?"required":"none"}),children:[e("option",{value:"required",children:"Required"}),e("option",{value:"none",children:"Not needed"})]})}),e("section",{class:"plan-page-visuals pl-drawer-section",children:[e("h3",{children:"Application screenshots"}),e(U,{label:"Visual treatment",children:e(Fe,{disabled:!ke||Pe==="disabled",value:de.visuals?.mode??"none",onChange:f=>{const ve=f.currentTarget.value,Ne=ve!=="none"&&(de.visuals?.mode??"none")==="none",je=ve==="none"?0:Math.max(pi(de.type,ve),de.visuals?.estimatedCaptures??0);cn($e,{...de,visuals:{mode:ve,rationale:Ne?"":de.visuals?.rationale??"",estimatedCaptures:je,...ve!=="none"&&de.visuals?.startPath?{startPath:de.visuals.startPath}:{},...ve!=="none"&&de.visuals?.workflow?{workflow:de.visuals.workflow}:{},...ve!=="none"&&de.visuals?.captureSequence?{captureSequence:de.visuals.captureSequence,captureIds:de.visuals.captureIds}:{}}})},children:[e("option",{value:"none",children:"Text only"}),e("option",{value:"recommended",children:"Capture when ready"}),e("option",{value:"required",children:"Require screenshots"})]})}),e(U,{label:de.visuals?.mode==="required"||Pe==="enabled"?"Required captures":"Planned captures",children:e(re,{disabled:!ke||Pe==="disabled"||(de.visuals?.mode??"none")==="none",type:"number",min:pi(de.type,de.visuals?.mode??"recommended"),max:"20",value:de.visuals?.estimatedCaptures??0,onInput:f=>{const ve=de.visuals?.mode??"recommended";cn($e,{...de,visuals:{...de.visuals,mode:ve,rationale:de.visuals?.rationale??"",estimatedCaptures:Math.max(pi(de.type,ve),Math.min(20,Number(f.currentTarget.value)||1))}})}})}),e(U,{label:"Starting route",hint:"Relative to the configured application URL",children:e(re,{disabled:!ke||Pe==="disabled"||(de.visuals?.mode??"none")==="none",value:de.visuals?.startPath??"",placeholder:"/settings/team",onInput:f=>cn($e,{...de,visuals:{...de.visuals,mode:de.visuals?.mode??"recommended",rationale:de.visuals?.rationale??"",estimatedCaptures:Math.max(1,de.visuals?.estimatedCaptures??1),startPath:f.currentTarget.value,captureIds:[]}})})}),e(U,{label:"Capture workflow",hint:"Include the safe test state and ordered actions",children:e(en,{disabled:!ke||Pe==="disabled"||(de.visuals?.mode??"none")==="none",rows:4,value:de.visuals?.workflow??"",placeholder:"Use the demo workspace. Open Team settings, invite a synthetic member, and verify the invitation state.",onInput:f=>cn($e,{...de,visuals:{...de.visuals,mode:de.visuals?.mode??"recommended",rationale:de.visuals?.rationale??"",estimatedCaptures:Math.max(1,de.visuals?.estimatedCaptures??1),workflow:f.currentTarget.value,captureIds:[]}})})}),e(U,{label:"Capture sequence",hint:"One screenshot per line: action — visible state — why it helps",children:e(en,{disabled:!ke||Pe==="disabled"||(de.visuals?.mode??"none")==="none",rows:Math.max(4,Math.min(8,de.visuals?.estimatedCaptures??4)),value:(de.visuals?.captureSequence??[]).join(`
|
|
18
|
+
`),placeholder:`Open Team settings — Team settings heading and navigation are visible — orients the reader
|
|
19
|
+
Select Invite member — the empty invitation form is open — confirms where data is entered
|
|
20
|
+
Submit the demo invitation — success confirmation is visible — proves completion`,onInput:f=>{const ve=f.currentTarget.value.split(/\r?\n/).map(je=>je.trim()).filter(Boolean),Ne=de.visuals?.mode??"recommended";cn($e,{...de,visuals:{...de.visuals,mode:Ne,rationale:de.visuals?.rationale??"",estimatedCaptures:Math.max(pi(de.type,Ne),ve.length),captureSequence:ve,captureIds:ve.map(je=>{const Ve=de.visuals?.captureSequence?.indexOf(je)??-1;return Ve>=0?de.visuals?.captureIds?.[Ve]??"":""})}})}})}),e(U,{label:"Why images help",children:e(en,{disabled:!ke||Pe==="disabled"||(de.visuals?.mode??"none")==="none",rows:3,value:de.visuals?.rationale??"",placeholder:"Show the complete invitation journey so readers can verify each meaningful state.",onInput:f=>cn($e,{...de,visuals:{...de.visuals,mode:de.visuals?.mode??"recommended",estimatedCaptures:Math.max(1,de.visuals?.estimatedCaptures??1),rationale:f.currentTarget.value}})})})]}),e("section",{class:"plan-page-reason pl-drawer-reason",children:[e("h3",{children:"Why the agent recommends this page"}),e("p",{children:de.rationale||"No rationale was provided for this page."}),de.evidenceDetails.length>0?e("details",{children:[e("summary",{children:["View ",de.evidenceDetails.length," supporting source",de.evidenceDetails.length===1?"":"s"]}),e("div",{class:"plan-evidence-list",children:de.evidenceDetails.map((f,ve)=>e("article",{children:[e("span",{children:f.source}),e("div",{children:[e("code",{children:[f.path,f.line?`:${f.line}`:""]}),(f.label||f.kind)&&e("small",{children:f.label??f.kind})]})]},`${f.source}-${f.path}-${ve}`))})]}):de.evidence.length>0&&e("details",{children:[e("summary",{children:["View ",de.evidence.length," supporting source",de.evidence.length===1?"":"s"]}),e("ul",{children:de.evidence.map(f=>e("li",{children:e("code",{children:f})},f))})]})]}),e("details",{class:"plan-page-advanced pl-drawer-advanced",children:[e("summary",{children:"Advanced settings"}),e("div",{children:e(U,{label:"File path",hint:"Used by the generator to place the file.",children:e(re,{disabled:!ke,class:"mono",value:de.path,onInput:f=>cn($e,{...de,path:f.currentTarget.value})})})})]})]}),e("footer",{children:[e("div",{class:"plan-page-move",children:[e(_,{size:"sm",disabled:!ke||$e===0,onClick:()=>hn($e,-1),children:"Move up"}),e(_,{size:"sm",disabled:!ke||$e===q.length-1,onClick:()=>hn($e,1),children:"Move down"})]}),ke&&e(_,{size:"sm",tone:"danger",icon:"trash",onClick:()=>Yn($e),children:"Remove page"}),e(_,{size:"sm",tone:"primary",onClick:()=>y(void 0),children:"Done"})]})]})})]})]})}function br(n){return{id:`new-page-${Date.now()}-${n}`,title:"New page",path:`new-page-${n+1}`,type:"how-to",priority:"next",action:"create",purpose:"Describe the reader outcome for this page.",rationale:"Added by the reviewer.",evidence:[],evidenceDetails:[],visuals:{mode:"none",rationale:"No application capture planned.",estimatedCaptures:0}}}function Ts(n){return{scope:n.scope,summary:n.summary,audiences:n.audiences,outcomes:n.outcomes,terminology:n.terminology,exclusions:n.exclusions,instructions:n.instructions,experienceLevel:n.experienceLevel,preferredExamples:n.preferredExamples,locale:n.locale,accessibilityTarget:n.accessibilityTarget,styleGuide:n.styleGuide,capabilities:n.capabilities,navigation:n.navigation,estimatedPages:n.estimatedPages,pages:n.pages,questions:n.questions,execution:n.execution}}function Ec(n){return n===!0||n==="enabled"?"enabled":n===!1||n==="disabled"?"disabled":"auto"}function pi(n,t){return t==="none"?0:1}function hi(n){return JSON.stringify(Ts(n))}function Nc(n,t){const i=new Map(n.pages.map(d=>[d.id,d])),a=new Map(t.pages.map(d=>[d.id,d])),s=t.pages.filter(d=>!i.has(d.id)).map(d=>d.title),o=n.pages.filter(d=>!a.has(d.id)).map(d=>d.title),l=t.pages.filter(d=>{const m=i.get(d.id);return m&&JSON.stringify(m)!==JSON.stringify(d)}).map(d=>d.title),c=JSON.stringify({audiences:n.audiences,outcomes:n.outcomes,terminology:n.terminology,exclusions:n.exclusions,instructions:n.instructions})!==JSON.stringify({audiences:t.audiences,outcomes:t.outcomes,terminology:t.terminology,exclusions:t.exclusions,instructions:t.instructions});return{added:s,removed:o,changed:l,briefChanged:c}}function Ds(n){return n.some(t=>t.status==="running"&&(t.type.startsWith("page-edit:")||t.type==="plan:generate"||t.type==="plan:continue"||t.type.startsWith("proposal:revise:")||t.type.startsWith("proposal:resume:")))}function Oc(n){const t=n.outcome;if(n.status==="cancelled")return{tone:"info",title:"Source check stopped",detail:"The check was stopped before it finished."};if(!t)return n.status==="succeeded"?{tone:"good",title:"Source check finished",detail:"Open the log under Recent activity for details."}:{tone:"bad",title:"Source check failed",detail:Bi(n)??"Open the log under Recent activity for details."};const i=t.pages??0,a=`${i} page${i===1?"":"s"} stale`;switch(t.status){case"current":return{tone:"good",title:"Sources checked · docs are current",detail:t.message};case"stale":return{tone:"warn",title:a,detail:t.message};case"proposal":return{tone:"good",title:t.proposalId?"Proposal ready for review":a,detail:t.message,...t.proposalId?{proposalId:t.proposalId}:{}};case"skipped":return t.pages===void 0?{tone:"info",title:"Source check postponed",detail:"Another task is running for this project. Choose Check now again when it finishes."}:i===0?{tone:"good",title:"Sources checked · docs are current",detail:"No page depends on a changed source file."}:{tone:"warn",title:`${a} · update skipped`,detail:t.message};case"failed":return{tone:"bad",title:"Proposal failed",detail:t.message,...t.proposalId?{proposalId:t.proposalId}:{}};default:return{tone:"info",title:"Freshness unknown",detail:t.message}}}function Zt(n){return n.startsWith("page-edit:")?"Editing a page with the agent":n==="plan:propose"?"Researching and building the documentation plan":n==="plan:revise"?"Revising the documentation plan":n==="plan:generate"?"Generating the approved documentation proposal":n==="plan:continue"||n.startsWith("proposal:resume:")?"Continuing the interrupted documentation run":n.startsWith("proposal:revise:")?"Revising the proposal with the agent":n==="author:update"?"Updating documentation":n==="author:create"?"Creating documentation":n==="author:review"?"Reviewing documentation":n==="sync"?"Checking sources for changes":n==="login"?"Signing in to Doxbrix":n==="agent:install"?"Installing the agent":n==="capture"?"Capturing screenshots":n==="generator"?"Changing the documentation generator":n==="deploy:dry-run"?"Validating the deployment":n==="deploy"?"Deploying documentation":n==="preview"?"Running the local preview":"Documentation workflow in progress"}function Uc(n){return n.startsWith("deploy")?"deploy":n.startsWith("plan")?"list":n.includes("proposal")?"review":n==="login"?"key":n==="agent:install"?"bot":n==="capture"?"camera":"update"}function Bi(n){if(n.status!=="failed")return;const t=n.lines.map(s=>Oi(kl(s))).reverse();return t.some(ji)?"Doxbrix did not accept the saved sign-in. Sign in again from Publish.":(t.find(s=>s.startsWith("doxloop: "))??t.find(s=>s.trim()&&!s.startsWith("DOXLOOP_EVENT ")))?.replace(/^doxloop: /,"").trim()||void 0}function Bc(n){if(n.status==="running")return" is running";if(n.status==="succeeded")return" completed successfully";if(n.type==="sync"&&n.outcome?.status==="skipped"&&n.outcome.pages===void 0)return" was postponed because another task was running";if(n.status==="failed"){const t=Bi(n);return` needs attention${t?`: ${t}`:""}`}return` was ${n.status}`}function Rs({pages:n,agent:t,model:i}){const[a,s]=p();return ae(()=>{let o=!0;return s(void 0),_e(`/api/authoring-estimate?pages=${n}&agent=${encodeURIComponent(t??"")}&model=${encodeURIComponent(i??"")}`).then(l=>{o&&typeof l?.samples=="number"&&s(l)}).catch(()=>{}),()=>{o=!1}},[n,t,i]),e("p",{class:"run-estimate",children:[e($,{name:"clock",size:14}),e("span",{children:Ul(n,a)})]})}function Ms({live:n,run:t,plan:i}){const[a,s]=p([]),[o,l]=p(!1),[c,d]=p(""),[m,r]=p(null),g=Re(null),u=async(h,y)=>{const P=t??new URL(h.url,location.origin).searchParams.get("run");if(!P){d("This screenshot no longer belongs to a run.");return}try{d(""),await K("/api/captures/replace",{run:P,path:h.file,data:await Cs(y)}),s(k=>k.map(C=>C.file===h.file?{...C,url:`${C.url.split("&v=")[0]}&v=${Date.now()}`}:C))}catch(k){d(wn(k))}};ae(()=>{let h=!1;const y=async()=>{try{const k=await _e(i?`/api/captures?plan=${encodeURIComponent(i)}`:t?`/api/captures?run=${encodeURIComponent(t)}`:"/api/captures");h||s(k.captures)}catch{}finally{h||l(!0)}};if(y(),!n)return()=>{h=!0};const P=setInterval(()=>{y()},4e3);return()=>{h=!0,clearInterval(P)}},[n,t,i]);const v=a.filter(h=>h.duplicateOf).length;return o&&a.length===0?e(Mn,{icon:"camera",title:"No screenshots captured yet",detail:n?"Images appear here as the agent verifies each state.":"This run did not capture application screenshots."}):e("div",{class:"capture-gallery",children:[e("input",{ref:g,type:"file",accept:".png",hidden:!0,onChange:h=>{const y=h.currentTarget.files?.[0];h.currentTarget.value="",y&&m&&u(m,y)}}),c&&e(Te,{tone:"bad",children:c}),v>0&&e(Te,{tone:"bad",children:[v," of ",a.length," captures repeat an earlier image. Steps showing the same screen under different names mislead readers — the agent should reach those states or record them as text-only."]}),e("div",{class:"capture-grid",children:a.map(h=>e("figure",{class:`capture-tile${h.duplicateOf?" duplicate":""}`,children:[e("a",{href:h.url,target:"_blank",rel:"noreferrer",children:e("img",{src:h.url,alt:h.alt??h.file,loading:"lazy"})}),e("figcaption",{children:[e("strong",{children:h.guide?`${h.guide} · ${h.step??""}`:h.file.split("/").slice(-1)[0]}),e("small",{children:h.duplicateOf?`Identical to ${h.duplicateOf.split("/").slice(-1)[0]}`:h.alt??h.file}),!n&&!i&&e("button",{type:"button",class:"capture-replace",onClick:()=>{r(h),g.current?.click()},children:[e($,{name:"refresh",size:12}),"Replace screenshot"]})]})]},h.file))})]})}function jc(n){if(n.status==="succeeded")return 100;if(n.status!=="running")return null;const t=[...n.stages].reverse().find(i=>i.status==="running"&&i.progress?.total);if(t?.progress?.total)return Math.min(100,Math.round(t.progress.done/t.progress.total*100))}function yr(n){const t=Math.max(0,Math.round(n/1e3));if(t<60)return`${t} s`;const i=Math.floor(t/60);return t%60?`${i} min ${t%60} s`:`${i} min`}function Fc(n){if(n.progress&&(n.progress.total!==void 0||n.progress.done>0))return n.progress.total!==void 0?`${n.progress.done} of ${n.progress.total}`:String(n.progress.done);const t=n.startedAt?Date.parse(n.startedAt):Number.NaN;if(Number.isNaN(t))return"";if(n.status==="running")return`running for ${yr(Date.now()-t)}`;const i=n.finishedAt?Date.parse(n.finishedAt):Number.NaN;return Number.isNaN(i)?"":yr(i-t)}function Pa({job:n,act:t,stopLabel:i="Stop update",hideStop:a=!1,captures:s=!0}){const o=Re(null),l=n.agent?On(n.agent):"Agent",[c,d]=p("log"),m=jc(n);return ae(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[n.lines.length,c]),e("div",{class:"authoring-live-log pl-livelog",children:[m!==null&&e("div",{class:`pl-live-progress ${n.status}`,children:[e("div",{class:`progress ${n.status==="succeeded"?"good":"info"} ${m===void 0?"indeterminate":""}`,role:"progressbar","aria-label":"Run progress",...m===void 0?{}:{"aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100},children:e("i",{style:m===void 0?void 0:`width:${m}%`})}),m!==void 0&&e("span",{children:[m,"%"]})]}),n.stages.length>0&&e("ol",{class:"workflow-stages pl-stages","aria-label":"Documentation workflow stages",children:n.stages.map(r=>e("li",{class:r.status,children:[e("span",{class:"pl-stage-mark",children:r.status==="completed"?e($,{name:"check",size:12}):r.status==="failed"?e($,{name:"alert",size:12}):r.status==="running"?e("i",{}):null}),e("strong",{children:r.label}),e("small",{children:Fc(r)})]},r.id))}),(()=>{const r=xo(n.lines);return!r.sessions.length&&!r.screenshots&&!r.sourceReads?null:e("div",{class:"pl-activity-summary","aria-live":"polite",children:[r.latestNote&&e("p",{children:[e("strong",{children:r.latestNote.session}),e("span",{children:r.latestNote.text.length>240?`${r.latestNote.text.slice(0,237)}…`:r.latestNote.text})]}),e("ul",{children:[r.sessions.length>0&&e("li",{children:[e($,{name:"bot",size:14}),r.sessions.join(" · ")]}),(s||r.screenshots>0)&&e("li",{children:[e($,{name:"camera",size:14}),r.screenshots," screenshot",r.screenshots===1?"":"s"," captured"]}),e("li",{children:[e($,{name:"file",size:14}),r.sourceReads," source read",r.sourceReads===1?"":"s"]})]})]})})(),e("div",{class:"pl-log",children:[e("div",{class:"live-job-meta pl-log-meta","aria-live":"polite",children:[e("span",{children:[e($,{name:"bot",size:14}),l]}),e("span",{children:[e($,{name:"clock",size:14}),"Last output ",Ye(n.lastOutputAt??n.startedAt)]}),e("span",{class:"authoring-live-actions",children:[s&&e(pt,{value:c,onChange:d,items:[["log","Log"],["captures","Screenshots"]]}),n.status==="running"&&!a&&e(_,{size:"sm",tone:"danger",icon:"stop",onClick:()=>{t(()=>K(`/api/jobs/${n.id}/cancel`),"Update stopped")},children:i}),n.status!=="running"&&n.retryable&&e(_,{size:"sm",icon:"refresh",onClick:()=>{t(()=>K(`/api/jobs/${n.id}/retry`),"Workflow restarted")},children:"Retry stage"})]})]}),c==="log"||!s?e("pre",{ref:o,class:"terminal live-terminal pl-log-lines","aria-live":"polite",children:n.lines.length>0?Ca(n.lines).join(`
|
|
21
|
+
`):`Starting ${l}…`}):e("div",{class:"pl-log-captures",children:e(Ms,{live:n.status==="running",plan:n.type==="plan:propose"||n.type==="plan:revise"?n.planId:void 0})}),e("div",{class:"pl-log-foot",children:e("a",{class:"btn link",href:`/api/jobs/${n.id}/log`,target:"_blank",rel:"noreferrer",children:["Open full log ",e($,{name:"arrowRight",size:14})]})})]})]})}const qc=[["Fix wording","Fix the wording so it is clearer and more precise."],["Add an example","Add a practical example that helps readers complete the task."],["Update for a recent change","Update this page for the recent product change: "],["Add a section","Add a section that explains "],["Shorten","Shorten this page while preserving the essential instructions."],["Rewrite for a different audience","Rewrite this page for a different audience: "]],Xi={verified:["Verified","good"],"needs-review":["Needs review","warn"],none:["No evidence","neutral"]},Et=8;function Wc(n,t){let i=n.find(s=>s.id===t);const a=new Set;for(;i?.supersededBy&&!a.has(i.id);){a.add(i.id);const s=n.find(o=>o.id===i.supersededBy);if(!s)break;i=s}return i}function Gc({state:n,act:t,streamConnected:i,onError:a}){const s=new URLSearchParams(location.search),[o,l]=p([]),[c,d]=p(!0),[m,r]=p(""),[g,u]=p(""),[v,h]=p(""),[y,P]=p([]),[k,C]=p(Number(s.get("line"))||0);ae(()=>{let S=!0;if(!v){P([]);return}return _e(`/api/pages/search?q=${encodeURIComponent(v)}`).then(le=>{S&&P(le)}).catch(le=>{S&&a(le.message)}),()=>{S=!1}},[v,n.runs]);const[w,I]=p(()=>s.get("path")?[s.get("path")]:[]),[L,D]=p(s.get("run")??"");ae(()=>{if(o.length===0)return;const S=new Set(o.map(he=>he.path)),le=w.map(he=>S.has(he)?he:[`${he}.mdx`,`${he}.md`,`${he}/index.mdx`,`${he}/index.md`].find(qe=>S.has(qe))??he);le.some((he,qe)=>he!==w[qe])&&I(le)},[o,w]);const[E,A]=p(""),[j,W]=p(!1),[O,ue]=p(!1),ge=n.project?.defaultAgent??"",fe=n.project?.defaultModel||It(ge),ye=Ft(ge,fe),[ce,se]=p(ge),[G,H]=p(fe),[N,oe]=p(ge==="codex"?ye:""),[Ce,ee]=p(ge==="claude"?ye:""),[Q,x]=p(!1),[B,F]=p(!!s.get("run"));ae(()=>{B&&requestAnimationFrame(()=>{const S=document.querySelector(".page-agent-panel");S?.scrollIntoView({block:"nearest",behavior:"smooth"}),S?.querySelector("input:not([type=checkbox]), textarea")?.focus({preventScroll:!0})})},[B]);const[T,Z]=p(!!(s.get("edit")||s.get("line"))),Y=n.project?.generator==="doxbrix",[pe,te]=p(Y&&!k?"visual":"source"),[M,ne]=p(!1),[xe,Ie]=p(!1),[X,J]=p(!1),[Ae,Be]=p(!1),[ke,Ke]=p(!1),Je=!0,[q,ze]=p(!1),[Pe,Ze]=p(!1),nn=()=>!q&&!Pe?!0:(a("Save or discard your navigation changes before leaving the navigation editor."),!1),Ee=M||xe,z=()=>Ee?(a("Save or discard your content edits before changing pages or starting an agent edit."),!1):!0,[Se,tn]=p(!1),[R,me]=p("rendered"),[Oe,Ge]=p("unified"),[kn,An]=p(!0),[mn,Tn]=p(""),[on,Dn]=p(!1),[Jn,He]=p(""),[mt,$e]=p(null),[de,Ln]=p(null),[at,ln]=p(!1),[Cn,cn]=p(()=>wr(s.get("view"))),[hn,vt]=p(n.preview?.running?n.preview.url??"":""),[rt,Yn]=p(n.preview?.running&&n.preview.url?"ready":"idle"),[zn,gn]=p(0),[At,Un]=p(!1),[En,dn]=p(null),[vn,bt]=p(null),Bn=Re(null),Nn=Re(null),Zn=Re(null),st=Re(null),Rn=ft(n.runs).filter(S=>S.editRequest),be=Wc(Rn,L),f=n.jobs.find(S=>S.status==="running"&&(S.type.startsWith("page-edit:")||S.type.startsWith("proposal:revise:")&&Rn.some(le=>S.type.endsWith(le.id))))??(vn?.status==="running"?vn:void 0),ve=f?.type.startsWith("page-edit:")?Rn.find(S=>f.type===`page-edit:${S.id}`):Rn.find(S=>f?.type===`proposal:revise:${S.id}`),Ne=ve?.editRequest?.paths??(vn?w:be?.editRequest?.paths??[]),je=S=>o.find(le=>le.path===S)?.title??S.split("/").at(-1)??S,Ve=w.map(S=>o.find(le=>le.path===S)).filter(S=>!!S),De=Ve[0],yt=be?.changes.filter(S=>S.category==="page")??[],Dt=be?.changes.filter(S=>S.category!=="page")??[],xn=yt.find(S=>S.id===mn)??yt[0],ii=v.toLocaleLowerCase(),qt=g?o.filter(S=>`${S.version??"current"} / ${S.locale??"default"}`===g):o,jn=ii?qt.filter(S=>`${S.title} ${S.path}`.toLocaleLowerCase().includes(ii)||y.some(le=>le.path===S.path)):qt,Fi=Hc(jn),ot=o.filter(S=>S.evidence==="needs-review").length,Qn=be?.editRequest?.paths??[],_n=!!(De&&Qn.includes(De.path)),Rt=!!(f&&De&&!Ne.includes(De.path)),fn=!!(be&&!f&&["awaiting-review","conflicted"].includes(be.status)),Wt=!!(be&&!f&&be.status==="failed"),Xn=Rn.filter(S=>S.status==="awaiting-review"&&S.id!==be?.id),wt=be?.validation?.errors??0,qi=E.trim().length>=Et,ai=Ve.length>1?`What should change on these ${Ve.length} pages?`:"What should change on this page?";ae(()=>{(f||fn||Wt)&&F(!0)},[f?.id,fn,Wt]),ae(()=>{ne(!1),Ie(!1),Be(!1),te(Y&&!k?"visual":"source")},[De?.path]),ae(()=>{const S=le=>{if(Ee||q||Pe){if(le.preventDefault(),!z())return;nn()}};return addEventListener("doxloop:before-navigation",S),()=>removeEventListener("doxloop:before-navigation",S)},[Ee,q,Pe]);const[ri,Mt]=p(""),bn=async(S=0)=>{try{l(await _e("/api/pages",{signal:AbortSignal.timeout(2e4)})),Mt("")}catch(le){if(S===0)return await new Promise(he=>setTimeout(he,1500)),await bn(1);Mt(wn(le))}d(!1)};ae(()=>{bn()},[]),ae(()=>{const S=()=>{const le=new URLSearchParams(location.search);if(Ee||q||Pe){un(w,L),z()&&nn();return}D(le.get("run")??""),cn(wr(le.get("view")));const he=le.get("path");he&&I([he])};return addEventListener("popstate",S),()=>removeEventListener("popstate",S)},[Ee,q,Pe,Je,Cn,w,L]),ae(()=>{const S=window.setTimeout(()=>h(m.trim()),150);return()=>clearTimeout(S)},[m]),ae(()=>{w.length||!o.length||I([o[0].path])},[o.length]),ae(()=>{be?.editRequest&&(I(be.editRequest.paths),A(be.editRequest.instruction),W(be.editRequest.allowRelated),Tn(yt[0]?.id??""),Dn(!1),He(""),be.id!==L&&(D(be.id),un(be.editRequest.paths,be.id)))},[be?.id]),ae(()=>{if(!vn)return;const S=n.jobs.find(he=>he.id===vn.id);((vn.type.startsWith("page-edit:")?be?.id===vn.type.slice(10)&&be.status!=="generating":be?.revisionOf===vn.type.slice(16))||S&&S.status!=="running")&&bt(null)},[be?.id,be?.status,n.jobs,vn?.id]),ae(()=>{!De||rt!=="idle"||(Yn("starting"),K("/api/preview/start",{open:!1}).then(S=>{vt(S.url),Yn("ready")}).catch(S=>{Yn("failed"),a(wn(S))}))},[De?.path,rt]);const un=(S,le="",he=Cn)=>{const qe=new URLSearchParams;he!=="pages"&&qe.set("view",he),le?qe.set("run",le):S[0]&&qe.set("path",S[0]),history.replaceState({},"",`/pages${qe.size?`?${qe}`:""}`)},Lt=S=>{!z()||!nn()||(cn(S),un(w,be&&w[0]&&Qn.includes(w[0])?be.id:"",S))},kt=()=>{D(""),Dn(!1),He("")},et=S=>{z()&&(C(0),Z(!1),I([S]),dn(null),un([S],be&&Qn.includes(S)?be.id:""))};ae(()=>{const S=le=>{if(!(!hn||le.source!==st.current?.contentWindow||le.origin!==new URL(hn).origin||le.data?.type!=="doxloop:preview-navigate"||typeof le.data.href!="string"))try{const he=new URL(le.data.href);if(he.origin!==new URL(hn).origin)return;const qe=nt=>decodeURIComponent(nt).replace(/\.(md|mdx)$/,"").replace(/\/$/,"")||"/",$n=o.find(nt=>qe(nt.route)===qe(he.pathname));$n?et($n.path):a("This link is outside the documentation page list. Open it in the full site preview.")}catch{}};return addEventListener("message",S),()=>removeEventListener("message",S)},[hn,o,Ee,be?.id]);const zt=S=>{if(!z())return;C(0),Z(!1);const le=w.includes(S)?w.filter(he=>he!==S):[S,...w];I(le),dn(null),un(le,be&&le[0]&&Qn.includes(le[0])?be.id:"")},b=(S,le)=>{const he=jn.findIndex($n=>$n.path===S),qe=jn[he+le];qe&&(et(qe.path),Zn.current?.querySelector(`[data-page-index="${he+le}"]`)?.focus())},V=S=>{const le=Bn.current,he=le?.selectionStart??E.length,qe=le?.selectionEnd??E.length,$n=he>0&&!/\s$/.test(E.slice(0,he))?" ":"",nt=`${E.slice(0,he)}${$n}${S}${E.slice(qe)}`,oi=he+$n.length+S.length;A(nt),requestAnimationFrame(()=>{le?.focus(),le?.setSelectionRange(oi,oi)})},we=async S=>{const le=(S?.instruction??E).trim(),he=S?.paths??w;if(!(le.length<Et||he.length===0||f||!z())){Z(!1),F(!0),tn(!0),Ln(null);try{const qe=await t(()=>K("/api/pages/edit",{paths:he,instruction:le,allowRelated:S?.allowRelated??j,screenshots:O?"enabled":"disabled",agent:ce||void 0,model:G||void 0,...ce==="codex"&&N?{reasoning:N}:{},...ce==="claude"&&Ce?{effort:Ce}:{}}),"Page edit started",!1);if(qe?.job.type.startsWith("page-edit:")){bt(qe.job);const $n=qe.job.type.slice(10);A(le),I(he),D($n),Dn(!1),un(he,$n)}}finally{tn(!1)}}},Xe=async()=>{if(!be)return;const S=await t(()=>K(`/api/proposals/${be.id}/accept`,{scope:"all"}));if(S?.status!=="applied")return;const le=S.editRequest?.paths??w;Ln(S),kt(),A(""),W(!1),gn(he=>he+1),un(le),await bn()},Sn=async()=>{if(!be)return;await t(()=>K(`/api/proposals/${be.id}/reject`),"Edit rejected")&&(kt(),un(w))},Ct=async()=>{if(!be||Jn.trim().length<Et)return;const S=await t(()=>K(`/api/proposals/${be.id}/refine`,{instruction:Jn.trim()}),"Refinement started",!1);S&&(bt(S.job),Dn(!1),He(""))},pn=async S=>{Un(!0);try{await t(()=>K(`/api/proposals/${S.id}/undo`),"Page edit undone")&&(Ln(null),gn(he=>he+1),await bn())}finally{Un(!1)}},yn=async()=>{if(De){if(En){dn(null);return}try{const S=await _e(`/api/history?page=${encodeURIComponent(De.path)}`);dn(S.entries)}catch(S){a(wn(S))}}},si=async S=>{const le=window.open("about:blank","_blank");le&&(le.opener=null);try{const he=await K("/api/preview/start",{open:!1});vt(he.url),Yn("ready"),le?.location.replace(`${he.url}${S}`)}catch(he){le?.close(),a(wn(he))}},Wi=async S=>{if(!be)return;const le=window.open("about:blank","_blank");le&&(le.opener=null);try{const he=await K(`/api/proposals/${be.id}/preview/start`,{open:!1});le?.location.replace(`${he.url}${S}`)}catch(he){le?.close(),a(wn(he))}},qs=S=>{if(!z())return;Z(!1),F(!0);const le=S.editRequest?.paths??[];D(S.id),le[0]&&I(le),dn(null),un(le,S.id)},Ws=()=>{F(!0),requestAnimationFrame(()=>Bn.current?.focus())},Aa=S=>e("div",{class:"current-page-preview",children:rt==="ready"&&hn?e("iframe",{ref:st,title:"Current page preview",src:`${hn}${S.route}?embed=page&workspace=1`},`${S.path}:${zn}`):e("div",{class:"preview-placeholder",children:rt==="failed"?e(ie,{children:[e($,{name:"alert",size:18}),e("strong",{children:"The preview could not start"}),e(_,{size:"sm",onClick:()=>Yn("idle"),children:"Try again"})]}):e(ie,{children:[e("span",{class:"spinner"}),e("strong",{children:"Preview is starting…"})]})})});return e("div",{class:`pages-page preview-first-pages ${B?"agent-panel-open":""} ${ke||!De?"page-list-open":""} navigation-open ${!!(!f&&fn&&be&&_n)?"reviewing":""} ${f?"running":""}`,children:[mt&&e(ys,{change:mt,onClose:()=>$e(null)}),at&&e(Sa,{act:t,title:"Insert an image",onClose:()=>ln(!1),onPick:S=>{ln(!1),V(`Insert the image ${S.publicPath} with descriptive alt text where it best supports the text.`)}}),de&&e("div",{class:"page-updated-toast",role:"status",children:[e("span",{class:"toast-icon",children:e($,{name:"check",size:15})}),e("span",{class:"toast-copy",children:[e("strong",{children:"Page updated"}),e("small",{children:(de.editRequest?.paths??[]).map(je).join(", ")||"The change was written to the project."})]}),e(_,{size:"sm",onClick:()=>{pn(de)},children:"Undo"}),e("button",{type:"button",class:"toast-close","aria-label":"Dismiss",onClick:()=>Ln(null),children:e($,{name:"close",size:14})})]}),e(ht,{kicker:"Docs",title:"Docs",actions:e("div",{class:"pages-view-actions",children:[e(pt,{value:Cn,onChange:Lt,items:[["pages","Pages"],["assets","Images & files"]]}),e(_,{icon:"settings",disabled:xe,"aria-pressed":X,onClick:()=>{z()&&nn()&&J(!X)},children:"Workspace tools"})]})}),X&&e("section",{class:"pages-workspace-tools","aria-label":"Workspace tools",children:[Cn==="pages"&&e(hl,{root:n.root??n.cwd,contentDir:n.project?.contentDir??"",...De?{path:De.path}:{},onChanged:async S=>{const le=await _e("/api/pages");l(le);const he=S??le.find(qe=>qe.path===De?.path)?.path??le[0]?.path;I(he?[he]:[]),un(he?[he]:[]),gn(qe=>qe+1),await t(async()=>!0)}}),e(pl,{onChanged:async()=>{await bn(),await t(async()=>!0)},onTranslate:async(S,le)=>{await we({paths:S,instruction:`Translate these documentation pages to ${le}. Preserve code, API names, navigation routes, source associations, and links. Re-verify factual claims. Change only the selected translation pages.`,allowRelated:!1})}}),e(ul,{onChanged:async()=>{await bn(),await t(async()=>!0)}})]}),Cn==="pages"&&w.length>1&&e(dl,{paths:w,onChanged:async()=>{await bn(),gn(S=>S+1),await t(async()=>!0)}}),Cn==="assets"&&e(Zl,{act:t,onError:a,onChanged:()=>{gn(S=>S+1),bn()}}),Cn==="pages"&&e("div",{class:"pages-workbench",children:[e("aside",{class:"page-list-panel","aria-label":"Edit site navigation",children:[e("label",{class:"page-search",children:[e("span",{class:"sr-only",children:"Search pages"}),e($,{name:"search",size:16}),e(re,{type:"search",value:m,placeholder:"Search titles, paths, or page text",onInput:S=>r(S.currentTarget.value)})]}),e("div",{hidden:!!(m.trim()||g),children:e(mc,{act:t,onError:a,embedded:!0,pages:o,refreshToken:zn,selectedPaths:w,onTogglePage:zt,onStatus:(S,le)=>{ze(S),Ze(le)},onSaved:async()=>{await bn(),Ee||gn(S=>S+1)},onSelectPage:et,...De?{activePath:De.path}:{}})}),[...new Set(o.map(S=>`${S.version??"current"} / ${S.locale??"default"}`))].length>1&&e("label",{children:["Version / locale",e("select",{"aria-label":"Version / locale",value:g,onChange:S=>u(S.currentTarget.value),children:[e("option",{value:"",children:"All versions and languages"}),[...new Set(o.map(S=>`${S.version??"current"} / ${S.locale??"default"}`))].map(S=>e("option",{children:S}))]})]}),y.length>0&&e("details",{open:!0,children:[e("summary",{children:[y.length," text matches",y.length===200?" (first 200)":""]}),e("ul",{class:"page-text-matches",children:y.map(S=>e("li",{children:e("button",{onClick:()=>{z()&&(et(S.path),C(S.line),Z(!0))},children:[e("strong",{children:[S.section," · line ",S.line]}),e("small",{children:S.excerpt})]})}))})]}),!!(m.trim()||g)&&e(ie,{children:[e("div",{class:"page-list-summary",children:[e("span",{children:[v?`${jn.length} of ${o.length}`:o.length," page",o.length===1?"":"s"]}),w.length>1?e("button",{type:"button",class:"page-list-clear",onClick:()=>De&&et(De.path),children:[w.length," selected · Clear"]}):e("span",{class:"page-list-hint",children:"Tick boxes to edit several at once"})]}),e("div",{ref:Zn,class:"page-list",role:"listbox","aria-label":"Documentation pages","aria-multiselectable":"true",children:c?e("div",{class:"page-list-empty",children:[e("span",{class:"spinner"}),"Loading pages…"]}):o.length===0?e("div",{class:"page-list-empty",children:"No pages yet. Create a documentation plan to write the first ones."}):jn.length===0?e("div",{class:"page-list-empty",children:["No pages match “",v,"”."]}):Fi.map(([S,le])=>e("section",{class:"page-list-group",children:[e("h2",{children:S}),le.map(he=>{const qe=jn.indexOf(he),$n=w.includes(he.path),nt=w[0]===he.path,[oi,Gs]=Xi[he.evidence];return e("div",{role:"option","aria-disabled":xe,"aria-selected":$n,"aria-current":nt?"page":void 0,tabIndex:nt||qe===0&&!w.some(Pn=>jn.some(Hs=>Hs.path===Pn))?0:-1,"data-page-index":qe,class:`page-list-row ${$n?"selected":""} ${nt?"active":""}`,onClick:()=>et(he.path),onKeyDown:Pn=>{Pn.target instanceof HTMLInputElement||(Pn.key==="ArrowDown"||Pn.key==="ArrowUp"?(Pn.preventDefault(),b(he.path,Pn.key==="ArrowDown"?1:-1)):Pn.key===" "?(Pn.preventDefault(),zt(he.path)):Pn.key==="Enter"&&(Pn.preventDefault(),et(he.path)))},children:[e("span",{class:"page-list-check",onClick:Pn=>Pn.stopPropagation(),children:e("input",{type:"checkbox","aria-label":`Select ${he.title}`,disabled:xe,checked:$n,onChange:()=>zt(he.path)})}),e("span",{class:"page-list-copy",children:[e("strong",{children:he.title}),e("code",{children:he.path}),e("small",{children:[e("span",{class:`evidence-dot ${Gs}`}),oi,e("i",{children:"·"}),he.wordCount.toLocaleString()," words",he.updatedAt?e(ie,{children:[e("i",{children:"·"}),Ye(he.updatedAt)]}):null]})]})]},he.path)})]},S))})]}),ri&&e(Te,{tone:"bad",children:[e("span",{children:["The page list did not load: ",ri]}),e(_,{size:"sm",onClick:()=>{d(!0),Mt(""),bn(1)},children:"Retry"})]}),e("div",{class:"page-list-foot",children:[e("span",{children:c?"Loading pages…":`${o.length} page${o.length===1?"":"s"}${ot>0?` · ${ot} need${ot===1?"s":""} review`:""}`}),e(_,{tone:"link","aria-label":"Open images & files",onClick:()=>Lt("assets"),children:"Images & files"})]})]}),e("section",{class:"page-detail-pane",children:De?e(ie,{children:[e("header",{class:"page-detail-header",children:[e("div",{class:"page-detail-copy",children:[e(_,{size:"sm",icon:"menu",class:"page-outline-toggle",onClick:()=>Ke(!ke),children:"Pages"}),e("div",{class:"page-detail-title",children:[e("h2",{children:De.title}),e(Me,{tone:Xi[De.evidence][1],children:Xi[De.evidence][0]})]}),e("code",{class:"page-detail-path",children:De.path})]}),e("div",{class:"page-detail-actions",children:[e(_,{size:"sm",tone:"ghost",icon:"clock","aria-pressed":!!En,onClick:()=>{yn()},children:"History"}),e(_,{size:"sm",icon:"external",onClick:()=>{si(De.route)},children:"Open in preview"}),e("button",{type:"button",class:`page-agent-toggle ${B?"active":""}`,"aria-label":"Instruct agent",title:"Instruct agent","aria-expanded":B,onClick:()=>F(!B),children:[e($,{name:"sparkles",size:14}),"Instruct agent",(f||fn)&&e("i",{})]}),e("button",{type:"button",class:"page-options-toggle",disabled:xe,"aria-label":"Page options",title:"Page options","aria-expanded":Ae,onClick:()=>{z()&&Be(!Ae)},children:e(Ls,{})})]})]}),e("div",{class:"page-detail-tabs",role:"tablist","aria-label":"Page views",children:[e("button",{type:"button",role:"tab","aria-selected":!Ae&&(!T||pe==="visual"),class:!Ae&&(!T||pe==="visual")?"active":"",onClick:()=>{Be(!1),T&&te("visual")},children:"Content"}),e("button",{type:"button",role:"tab","aria-selected":!Ae&&T&&pe==="source",class:!Ae&&T&&pe==="source"?"active":"",disabled:!!(xe||f||fn&&_n),onClick:()=>{if(Be(!1),!T){if(!z())return;Z(!0)}te("source")},children:"Source"}),e("button",{type:"button",role:"tab","aria-selected":Ae,class:Ae?"active":"",disabled:xe,onClick:()=>{z()&&Be(!Ae)},children:"Evidence"}),e("span",{class:"page-detail-tabs-side",children:[De.updatedAt&&!T&&e("small",{children:["Updated ",Ye(De.updatedAt)]}),e("button",{type:"button",class:`page-content-toggle ${T?"active":""}`,"aria-pressed":T,disabled:!!(xe||f||fn&&_n),onClick:()=>{z()&&Z(!T)},children:[e($,{name:"update",size:14}),"Edit content"]})]})]}),Ae&&e("section",{class:"page-options-panel","aria-label":"Page options",children:[e(us,{path:De.path,onRequest:async S=>{await we({paths:[De.path],instruction:`Address this reviewer comment on ${De.path}: ${S}`})}},`comments:${De.path}`),!f&&!(fn&&_n)&&e(ic,{path:De.path,act:t,onError:a,onSaved:()=>{gn(S=>S+1),bn()}})]}),Ve.length>1&&e("div",{class:"selected-pages-strip","aria-label":"Pages selected for this update",children:[e("strong",{children:[e($,{name:"list",size:14}),Ve.length," pages in this edit"]}),Ve.map(S=>e("span",{class:`selected-page-chip ${S.path===De.path?"active":""}`,children:[e("button",{type:"button",onClick:()=>{if(!z())return;const le=[S.path,...w.filter(he=>he!==S.path)];I(le),un(le,be&&Qn.includes(S.path)?be.id:"")},children:S.title}),e("button",{type:"button","aria-label":`Remove ${S.title}`,onClick:()=>zt(S.path),children:e($,{name:"close",size:12})})]},S.path))]}),Xn.length>0&&!f&&e("div",{class:"page-pending-strip",children:[e($,{name:"info",size:15}),e("span",{children:Xn.length===1?e(ie,{children:["An edit of ",e("strong",{children:(Xn[0].editRequest?.paths??[]).map(je).join(", ")})," is waiting for your review."]}):e(ie,{children:[e("strong",{children:[Xn.length," edits"]})," are waiting for your review."]})}),e(_,{size:"sm",onClick:()=>qs(Xn[0]),children:"Open review"})]}),En&&e("div",{class:"proposal-drawer-scrim page-history-scrim",role:"presentation",onClick:S=>S.target===S.currentTarget&&dn(null),children:e("aside",{class:"page-history-panel",role:"dialog","aria-modal":"true","aria-labelledby":"page-history-title",onKeyDown:S=>{S.key==="Escape"&&dn(null)},children:[e("header",{children:[e("span",{children:[e("span",{class:"kicker",children:"History"}),e("strong",{id:"page-history-title",children:De.title})]}),e("button",{type:"button","aria-label":"Close page history",onClick:()=>dn(null),children:e($,{name:"close",size:16})})]}),e("div",{class:"page-history-body",children:En.length?En.map(S=>e("div",{class:"page-history-row",children:[e(Me,{tone:Vn(S.requestStatus),children:Kn(S.requestStatus)}),e("span",{children:[e("strong",{children:S.requestText??"Documentation update"}),e("small",{children:Ye(S.requestedAt)})]})]},S.requestId)):e("p",{class:"page-history-empty",children:"No recorded changes for this page yet."})})]})}),e("div",{class:"page-editor-layout",children:[e("section",{class:"page-editor-canvas","aria-label":"Page content",children:[!f&&!(fn&&_n)&&e(fl,{root:n.root??n.cwd,path:De.path,native:Y,base:hn?`${hn}${De.route}`:"",focusLine:k,refreshToken:zn,editing:T,mode:pe,onModeChange:te,onEditingChange:Z,onStatus:(S,le)=>{ne(S),Ie(le)},onChanged:async()=>{await bn(),C(0),gn(S=>S+1),await t(async()=>!0)},children:Aa(De)},`${n.root??n.cwd}:${De.path}`),f&&Aa(De),!f&&fn&&be&&_n&&e("section",{class:"page-edit-review","aria-label":"Proposed changes",children:[xn?e(ie,{children:[e("div",{class:"page-review-toolbar",children:[yt.length>1?e(Fe,{"aria-label":"Changed page",value:xn.id,onChange:S=>Tn(S.currentTarget.value),children:yt.map(S=>e("option",{value:S.id,children:[S.title," — ",S.path]},S.id))}):e("code",{class:"page-review-path",children:xn.path}),e("div",{class:"page-review-controls",children:[e(pt,{value:R,onChange:me,items:[["rendered","Rendered"],["source","Source"]]}),R==="rendered"&&e(ie,{children:[e(pt,{value:Oe,onChange:Ge,items:[["split","Side-by-side"],["unified","Inline"]]}),e(_,{size:"sm",class:kn?"active-filter":"",onClick:()=>An(!kn),children:kn?"Changes only":"Show all"})]}),e(_,{size:"sm",icon:"info",onClick:()=>$e(xn),children:"Why this change"}),e(_,{size:"sm",icon:"external",onClick:()=>{Wi(o.find(S=>S.path===xn.path)?.route??De.route)},children:"Open proposed page"})]})]}),e("div",{class:"page-review-body",children:R==="source"?e(bs,{runId:be.id,change:xn,act:t,partialActions:!1}):e(vs,{runId:be.id,change:xn,layout:Oe,onlyChanges:kn})})]}):e(Mn,{title:"The agent did not change the page",detail:"Refine the instruction or reject this edit."}),xn&&be.status==="awaiting-review"&&xn.hunks.every(S=>!S.acceptedAt&&!S.rejectedAt)&&e(ps,{root:n.root??n.cwd,path:xn.path,proposal:{id:be.id,changeId:xn.id},onChanged:async()=>{await t(async()=>!0)}},`${be.id}:${xn.id}`)]})]}),B&&e("aside",{class:"page-agent-panel","aria-label":"Agent instructions",onKeyDown:S=>{S.key==="Escape"&&(F(!1),document.querySelector(".page-agent-toggle")?.focus())},children:[e("header",{class:"page-agent-panel-header",children:[e("h2",{class:"kicker",children:"Instruct the agent"}),e("span",{class:"page-agent-scope",children:Ve.length>1?`${Ve.length} pages selected`:De.title}),e("button",{type:"button","aria-label":"Close agent panel",onClick:()=>{F(!1),requestAnimationFrame(()=>document.querySelector(".page-agent-toggle")?.focus())},children:e($,{name:"close",size:16})})]}),f&&!Rt&&e(ie,{children:e("section",{class:"page-edit-running",children:[e("header",{children:[e("span",{class:"running-pulse","aria-hidden":"true",children:e("i",{})}),e("div",{children:[e("h2",{children:["Editing ",Ne.length===1?je(Ne[0]):`${Ne.length} pages`]}),e("blockquote",{children:ve?.editRequest?.followUps.at(-1)?.instruction??ve?.editRequest?.instruction??E})]}),e(Me,{tone:i?"good":"warn",children:i?"Live":"Reconnecting…"})]}),e(Pa,{job:f,act:t,stopLabel:"Stop",captures:!!n.project?.application})]})}),f&&Rt&&e("div",{class:"page-agent-other-run",children:[e("p",{children:"An edit is running on another page."}),e(_,{onClick:()=>{I([...Ne]),un(Ne,ve?.id??L)},children:"Show the edit"})]}),!f&&fn&&be&&_n&&e("div",{class:"page-agent-review",children:[e("header",{class:"page-review-head",children:[e("div",{children:[e("small",{children:"Agent proposal"}),e("h2",{children:"Review this edit"}),e("p",{children:Kc(be)})]}),e(Me,{tone:Vn(be.status),children:Kn(be.status)})]}),e("blockquote",{class:"page-review-instruction",children:[e($,{name:"chat",size:14}),e("span",{children:Ci(be)})]}),be.status==="conflicted"&&e(Te,{tone:"bad",children:e("span",{class:"note-body",children:[be.error,e("span",{class:"note-actions",children:[e(_,{size:"sm",onClick:()=>{kt(),un(w),gn(S=>S+1),bn()},children:"Reload and compare"}),e(_,{size:"sm",tone:"danger",onClick:()=>{Sn()},children:"Reject"})]})]})}),wt>0&&e(Te,{tone:"bad",children:e("span",{class:"note-body",children:["The proposed edit has ",wt," validation error",wt===1?"":"s",". Fix the validation errors by refining the instruction, or reject this edit.",e("ul",{class:"note-issues",children:be.validation?.issues?.filter(S=>S.severity==="error").map(S=>e("li",{children:[S.file?e("code",{children:S.file}):null,S.message]},`${S.code}:${S.file??""}:${S.message}`))})]})}),Dt.length>0&&e("details",{class:"page-related-changes",children:[e("summary",{children:["Also changed ",e("span",{children:Dt.length})]}),Dt.map(S=>e("div",{children:[e($,{name:"file",size:14}),e("span",{children:[e("strong",{children:S.title}),e("code",{children:S.path})]}),e(Me,{tone:"neutral",children:S.category})]},S.id))]}),on&&e("div",{class:"page-refine",children:[e(U,{label:"What should be different?",hint:"The agent continues in the same isolated copy, so earlier instructions still apply.",children:e(en,{ref:Nn,rows:4,value:Jn,placeholder:"For example: keep the new example, but shorten the introduction to two sentences.",onInput:S=>He(S.currentTarget.value)})}),e("div",{class:"page-refine-actions",children:[e(_,{tone:"primary",icon:"sparkles",disabled:Jn.trim().length<Et,onClick:()=>{Ct()},children:"Send to the agent"}),e(_,{tone:"ghost",onClick:()=>{Dn(!1),He("")},children:"Cancel"})]})]}),e("footer",{class:"page-review-actions",children:[e(_,{tone:"primary",icon:"check",disabled:be.status==="conflicted"||wt>0,title:wt>0?"Fix the validation errors by refining the instruction, or reject this edit.":void 0,onClick:()=>{Xe()},children:"Accept"}),e(_,{tone:"danger",onClick:()=>{Sn()},children:"Reject"}),e(_,{icon:"chat",class:on?"active-filter":"",onClick:()=>{Dn(!on),on||requestAnimationFrame(()=>Nn.current?.focus())},children:"Refine"}),e("small",{children:"Accepting writes the page to the project. You can undo it afterwards."})]})]}),!f&&!(fn&&_n)&&e(ie,{children:[Wt&&be&&_n&&e(Jc,{proposal:be,onRetry:S=>{we({instruction:Ci(be),allowRelated:S,paths:Qn})},onRefine:()=>{A(Ci(be)),kt(),un(Qn),Ws()}}),e("section",{class:"page-edit-composer",children:e("div",{class:"composer-body",children:[e("div",{class:"page-intent-chips","aria-label":"Starting points",children:[e("span",{class:"sr-only",children:"Start with"}),qc.map(([S,le])=>e("button",{type:"button",class:"chip","aria-pressed":"false",disabled:Se,onClick:()=>V(le),children:S},S)),e("button",{type:"button",class:"chip","aria-pressed":"false",disabled:Se,onClick:()=>ln(!0),children:[e($,{name:"plus",size:12}),"Insert an image…"]})]}),e("div",{class:"composer-line",children:[e("div",{class:"composer-field",children:[e("label",{for:"page-edit-instruction",class:"sr-only",children:ai}),e("div",{class:"composer-textarea",children:[e($,{name:"update",size:16}),e(en,{id:"page-edit-instruction",ref:Bn,rows:1,maxlength:2e3,value:E,disabled:Se,placeholder:Ve.length>1?`What should be different on these ${Ve.length} pages?`:"What should be different on this page?",onInput:S=>A(S.currentTarget.value),onKeyDown:S=>{(S.metaKey||S.ctrlKey)&&S.key==="Enter"&&(S.preventDefault(),we())}}),e("small",{class:E.length>1900?"warn":"",children:E.trim().length<Et&&E.length>0?`At least ${Et} characters`:E.length>0?`${E.length}/2000`:""})]})]}),e(_,{tone:"primary",icon:"sparkles",busy:Se,disabled:!qi||w.length===0||Ee,onClick:()=>{we()},children:"Generate proposal"})]}),e("div",{class:"composer-options",children:[e(jt,{checked:j,disabled:Se,onChange:W,label:"Also allow related changes"}),n.project?.application&&e(jt,{checked:O,disabled:Se,onChange:ue,label:"Capture product screenshots"}),e("details",{class:"page-agent-advanced",children:[e("summary",{children:"Options & agent settings"}),e("button",{type:"button",class:"agent-config-summary","aria-expanded":Q,onClick:()=>x(!Q),children:[e($,{name:"bot",size:16}),e("span",{children:["Agent: ",e("b",{children:[ce?On(ce):"Automatically detect",G?` · ${G}`:""]})]}),e("strong",{children:Q?"Done":"Change"})]}),Q&&e("div",{class:"page-agent-options",children:[e(U,{label:"Agent",children:e(Fe,{value:ce,onChange:S=>{const le=S.currentTarget.value,he=It(le),qe=Ft(le,he);se(le),H(he),oe(le==="codex"?qe:""),ee(le==="claude"?qe:"")},children:[e("option",{value:"",children:"Automatically detect"}),e("option",{value:"codex",children:"Codex"}),e("option",{value:"claude",children:"Claude Code"}),e("option",{value:"gemini",children:"Gemini"})]})}),e(U,{label:"Model",children:e(it,{value:G,options:Pt(ce).map(S=>[S.id,S.label]),disabled:!ce,onValueChange:H})}),(ce==="codex"||ce==="claude")&&e(U,{label:ce==="claude"?"Effort":"Reasoning",children:e(it,{value:ce==="claude"?Ce:N,options:Ui(ce,G).map(S=>[S,S]),onValueChange:ce==="claude"?ee:oe})})]})]})]}),Ee&&e("small",{class:"composer-note",children:"Save or discard your content edits before generating a proposal."})]})})]})]})]}),e("footer",{class:"page-canvas-status",children:[e($,{name:"preview",size:14}),e("span",{children:fn&&_n?"Proposed changes · Not applied":M?"Unsaved draft":"Local preview"}),e("code",{children:De.path})]})]}):e("div",{class:"page-detail-empty",children:e(Mn,{icon:"file",title:"Choose a page",detail:"Select a page to preview it, edit its content, or ask the agent."})})})]})]})}function Ls(){return e("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[e("circle",{cx:"5",cy:"12",r:"1.7"}),e("circle",{cx:"12",cy:"12",r:"1.7"}),e("circle",{cx:"19",cy:"12",r:"1.7"})]})}function wr(n){return n==="assets"?n:"pages"}function Hc(n){const t=new Map;for(const a of n){const s=a.inNavigation?a.section??"Documentation":"Not in navigation",o=t.get(s)??[];o.push(a),t.set(s,o)}const i=t.get("Not in navigation");return i&&(t.delete("Not in navigation"),t.set("Not in navigation",i)),[...t]}function Vc(n){const t=n.changes.filter(i=>i.category==="page"&&i.kind!=="deleted").length;return n.revisionOf&&n.status==="failed"?"Agent revision that did not finish · the proposal it revised is unchanged":n.planId?`${n.authoringMode==="create"?"New documentation":"Documentation update"} from the approved plan · ${t} page${t===1?"":"s"}`:n.summary||"Documentation update"}function Kc(n){const t=n.changes.filter(o=>o.category==="page").length,i=n.changes.filter(o=>o.category!=="page"),a=[`${t} page${t===1?"":"s"} changed`];i.some(o=>o.category==="evidence")&&a.push("evidence updated");const s=i.filter(o=>o.category!=="evidence").length;return s>0&&a.push(`${s} other file${s===1?"":"s"}`),a.join(" · ")}function Ci(n){return n.editRequest?.followUps.at(-1)?.instruction??n.editRequest?.instruction??""}function Jc({proposal:n,onRetry:t,onRefine:i}){const a=n.error??"The documentation agent could not complete this edit.",s=a.includes("outside this page")||a.includes("outside these pages"),o=a.includes("did not change this page")||a.includes("did not change these pages");return e("div",{class:"page-edit-failure",role:"alert",children:[e("span",{class:"failure-icon",children:e($,{name:"alert",size:16})}),e("div",{children:[e("strong",{children:s?"The agent changed files outside the selected page":o?"The agent did not change the page":"The edit did not finish"}),e("p",{children:a}),e("div",{class:"note-actions",children:s?e(ie,{children:[e(_,{size:"sm",tone:"primary",onClick:()=>t(!0),children:"Retry allowing related changes"}),e(_,{size:"sm",onClick:i,children:"Refine the instruction"})]}):o?e(_,{size:"sm",tone:"primary",onClick:i,children:"Refine the instruction"}):e(ie,{children:[e(_,{size:"sm",tone:"primary",icon:"refresh",onClick:()=>t(!!n.editRequest?.allowRelated),children:"Try again"}),e(_,{size:"sm",onClick:i,children:"Refine the instruction"})]})})]})]})}function pa(n,t,i,a){const[s,o]=p([]),[l,c]=p(!0),[d,m]=p(!0),r=i.filter(g=>g.status!=="running").map(g=>g.id).join(",");return ae(()=>{let g=!0;return(async()=>{try{const u=await _e(n);if(!g)return;c(u.available!==!1),o(t(u))}catch(u){g&&a(wn(u))}finally{g&&m(!1)}})(),()=>{g=!1}},[n,r]),{entries:s,available:l,loading:d}}function zs(){return e(Te,{tone:"info",children:"Documentation history needs a Node.js runtime with built-in SQLite (Node 22.13 or newer). Every other part of this workspace works normally."})}function ha(n,t){const i=n.length||t;return i===1?"1 page":`${i} pages`}const kr=140;function Yc(n){const t=n.replace(/\s+/g," ").trim();return t.length<=kr?{text:t,truncated:!1}:{text:`${t.slice(0,kr).replace(/\s+\S*$/,"").trimEnd()}…`,truncated:!0}}function Zc(n,t=3){const i=n.map(a=>a.title?.trim()||a.path.split("/").at(-1)||a.path);return i.length<=t?i.join(", "):`${i.slice(0,t).join(", ")} and ${i.length-t} more`}function Es(n){return n==="create"?"Create":n==="review"?"Review":n==="edit"?"Edit":n==="navigation"?"Navigation":n==="branding"?"Branding":n==="asset"?"Asset":n==="metadata"?"Metadata":n==="glossary"?"Glossary":"Update"}function ga(n){const t=n.requestText?.replace(/\s+/g," ").trim(),i=t?.startsWith("Implement the approved Doxloop documentation plan at .doxloop/documentation-plan.json");return t&&!i?t:n.kind==="create"?"Create documentation from the approved plan.":n.kind==="review"?"Review the documentation.":n.trigger==="schedule"||n.trigger==="watch"?"Update documentation for detected source changes.":i?"Update documentation from the approved plan.":"Update documentation from configured sources."}function Qc({jobs:n,onError:t}){const{entries:i,available:a,loading:s}=pa("/api/history?limit=25",o=>o.requests??[],n,t);return a?s&&i.length===0?e("div",{class:"history-loading",children:"Loading history…"}):i.length===0?e(Mn,{icon:"clock",title:"No documentation history yet",detail:"Once you start an update, the request and everything it changed are recorded here."}):e(Xr,{class:"history-table pl-history-table",head:e(ie,{children:[e("th",{children:"Request"}),e("th",{children:"Result"}),e("th",{children:"Cost"}),e("th",{children:"When"})]}),children:i.map(o=>{const l=o.pages??[],c=Yc(ga(o)),d=o.kind==="edit"?l[0]?.path:void 0,m=()=>{d&&sn("pages",{path:d},"push")},r=o.pagesChanged>0?`${ha(l,o.pagesChanged)} changed`:o.kind==="edit"&&l.length>0?`${ha(l,l.length)} selected`:"";return e("tr",{class:`history-row ${d?"clickable":""}`,tabIndex:d?0:void 0,onClick:m,onKeyDown:g=>{!d||g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),m())},children:[e("td",{children:e("div",{class:"history-request",children:[e("strong",{title:c.truncated?ga(o):void 0,children:c.text}),e("small",{children:[Es(o.kind),l.length>0&&e("span",{class:"history-pages",title:l.map(g=>g.path).join(`
|
|
22
|
+
`),children:[" · ",Zc(l)]})]}),o.error&&e("small",{class:"history-error",title:o.error,children:Fs(o.error)})]})}),e("td",{class:"history-result",children:[e(Me,{tone:Vn(o.status),children:Kn(o.status)}),r&&e("small",{children:r})]}),e("td",{class:"history-cost",children:o.usage?e("span",{title:`${o.usage.totalTokens.toLocaleString()} tokens · ${o.usage.turns} turns · largest context ${o.usage.maxContextTokens.toLocaleString()} tokens`,children:Ns(o.usage)}):e("span",{children:"—"})}),e("td",{class:"muted-cell",children:Ye(o.createdAt)})]},o.id)})}):e(zs,{})}function Xc({entries:n,available:t,loading:i}){return t?i&&n.length===0?e("div",{class:"history-loading ops-empty-wrap",children:"Loading history…"}):n.length===0?e("div",{class:"ops-empty-wrap",children:e(Mn,{icon:"clock",title:"Nothing published yet",detail:"Each deployment is recorded here with the pages it published and whether it succeeded."})}):e(Xr,{class:"history-table deploy-history",head:e(ie,{children:[e("th",{children:"Publish"}),e("th",{children:"Access"}),e("th",{children:"Result"}),e("th",{children:"When"})]}),children:n.map(a=>e("tr",{class:"history-row",children:[e("td",{children:[e("span",{class:"deploy-history-name",children:[a.slug??a.name??a.target,a.pagesCount!==void 0&&e(ie,{children:[" · ",ha([],a.pagesCount)]})]}),(a.pagesCreated||a.pagesUpdated)&&e("small",{class:"history-lines",children:[a.pagesCreated?e("i",{class:"added",children:["+",a.pagesCreated," new"]}):null,a.pagesUpdated?e("i",{children:[a.pagesCreated?" · ":"",a.pagesUpdated," updated"]}):null]})]}),e("td",{class:"deploy-history-target",children:a.target==="doxbrix"?a.visibility==="public"?"Public":a.visibility==="private"?"Private":"Doxbrix":ed(a.target)}),e("td",{children:[e(Me,{tone:Vn(a.status),children:a.status==="succeeded"?"Published":a.status==="failed"?"Failed":Kn(a.status)}),a.error&&e("small",{class:"history-error",title:a.error,children:Fs(a.error)})]}),e("td",{class:"muted-cell",children:[Ye(a.startedAt),a.durationMs!==void 0&&e("small",{class:"history-duration",children:nd(a.durationMs)})]})]},`${a.startedAt}-${a.slug??a.target}`))}):e("div",{class:"ops-empty-wrap",children:e(zs,{})})}function ed(n){return n==="github-pages"?"GitHub Pages":n==="netlify"?"Netlify":n==="vercel"?"Vercel":n==="doxbrix"?"Doxbrix":n==="export"?"Export":n}function Ns(n){const i=[`${(s=>{const o=(l,c)=>{const d=l.toFixed(1);return`${d.endsWith(".0")?d.slice(0,-2):d}${c}`};return s>=1e6?o(s/1e6,"M"):s>=1e3?o(s/1e3,"k"):String(Math.round(s))})(n.totalTokens)} tokens`],a=n.inputTokens+n.cacheReadTokens+n.cacheCreationTokens;return a>0&&(n.cacheReadTokens>0||n.cacheCreationTokens>0)&&i.push(`${Math.round(n.cacheReadTokens/a*100)}% cached`),n.costUsd!==void 0&&i.push(n.costUsd>0&&n.costUsd<.01?"<$0.01":`$${n.costUsd.toFixed(2)}`),n.sessions!==1&&i.push(`${n.sessions} sessions`),i.join(" · ")}function nd(n){if(n<1e3)return"under a second";const t=Math.round(n/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Os({state:n,act:t,onClose:i}){const a=n.project,[s,o]=p(()=>{const w={...structuredClone(a.sync),mode:"auto"};return w.on.length?w:{...w,on:[Ar(Kt([]))]}}),[l,c]=p(()=>Kt(a.sync.on)),[d,m]=p(!1),[r,g]=p(!1),u=(w,I)=>o(L=>({...L,[w]:I})),v=w=>{c(I=>{const L={...I,...w};return o(D=>({...D,on:[Ar(L)]})),L})},h=Intl.DateTimeFormat().resolvedOptions().timeZone,y=a.sources.filter(w=>(w.kind??"directory")==="directory"&&!w.remote),P=n.jobs.some(w=>w.type==="sync"&&w.status==="running"),k=Ds(n.jobs),C=async()=>{g(!0);try{await t(()=>K("/api/sync/configure",{...s,mode:"auto"}),"Monitoring configuration installed")!==void 0&&i()}finally{g(!1)}};return e("div",{class:"sources-modal-scrim ops-dialog-scrim",onClick:i,children:e("section",{class:"monitoring-dialog ops-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"monitoring-dialog-title",onClick:w=>w.stopPropagation(),children:[e("header",{class:"ops-dialog-head",children:[e("div",{children:[e("h2",{id:"monitoring-dialog-title",children:"Configure project monitoring"}),e("p",{children:["One project-wide policy checks all ",a.sources.length," connected sources. Changes generate a documentation proposal for review."]})]}),e("button",{type:"button",class:"ops-icon-button","aria-label":"Close",onClick:i,children:e($,{name:"close",size:16})})]}),e("div",{class:"monitoring-dialog-body ops-dialog-body",children:[e("div",{class:"monitoring-dialog-status",children:[e("span",{class:a.sync.on.length?"active":"",children:[e("i",{}),a.sync.on.length?Ei(Kt(a.sync.on)):"Monitoring is not configured"]}),e(_,{size:"sm",icon:"refresh",busy:P,disabled:P||k,title:k?"Available when the running writing task finishes":void 0,onClick:()=>{t(()=>K("/api/sync/now"),"Source check started",!1)},children:P?"Checking…":"Check now"})]}),P&&e(Te,{children:"A source check is running. Its result appears as a notice when it finishes; the live log is under Plan."}),y.length>0&&e(Te,{children:[y.map(w=>w.name).join(", ")," ",y.length===1?"is a local folder and is":"are local folders and are"," checked in place: a Git checkout by its HEAD commit and working tree, any other folder by the files recorded at the last sync. Nothing is fetched, pulled, or written there."]}),e("section",{class:"monitoring-policy-fields",children:[e(U,{label:"Product branch",hint:"The branch monitoring compares against. Leave empty for the source's default branch.",children:e(re,{value:s.branch??"",placeholder:a.sources.find(w=>w.remote?.branch)?.remote?.branch??"main",onInput:w=>u("branch",w.currentTarget.value)})}),e("div",{class:"field ops-choice",children:[e("span",{class:"field-label",children:"Schedule"}),e(ki,{label:"Schedule",value:l.kind,onChange:w=>v({kind:w}),items:[{id:"daily",label:"Daily"},{id:"weekdays",label:"Weekdays"},{id:"weekly",label:"Weekly"},{id:"monthly",label:"Monthly"},{id:"custom",label:"Custom interval",detail:"Every few minutes or hours"}]})]}),l.kind==="weekly"&&e(U,{label:"Day of week",children:e(Fe,{value:l.weekday,onChange:w=>v({weekday:w.currentTarget.value}),children:js.map(([w,I])=>e("option",{value:w,children:I},w))})}),l.kind==="monthly"&&e(U,{label:"Day of month",hint:"The 1st through 28th runs reliably every month.",children:e(re,{type:"number",min:"1",max:"28",value:l.day,onInput:w=>v({day:ea(w.currentTarget.value,1,28)})})}),l.kind!=="custom"&&e(U,{label:"Time",hint:`Uses your device timezone (${h}).`,children:e(re,{type:"time",value:l.time,onInput:w=>v({time:w.currentTarget.value||"09:00"})})}),l.kind==="custom"&&e(ie,{children:[e(U,{label:"Repeat every",children:e(re,{type:"number",min:"1",max:l.unit==="m"?"59":"24",value:l.interval,onInput:w=>v({interval:ea(w.currentTarget.value,1,l.unit==="m"?59:24)})})}),e(U,{label:"Interval",children:e(Fe,{value:l.unit,onChange:w=>{const I=w.currentTarget.value;v({unit:I,interval:Math.min(l.interval,I==="m"?59:24)})},children:[e("option",{value:"m",children:"Minutes"}),e("option",{value:"h",children:"Hours"})]})})]}),e("p",{class:"schedule-summary",children:[e($,{name:"calendar",size:15}),Ei(l)]}),e("button",{type:"button",class:"disclosure","aria-expanded":d,onClick:()=>m(!d),children:[e($,{name:d?"chevronDown":"chevronRight",size:14}),"Advanced watch scope and budgets"]}),d&&e("div",{class:"form-grid gap-top",children:[e(U,{label:"Watched paths",hint:"One glob per line. Only changes under these paths trigger an update.",children:e(Za,{value:s.watch,onInput:w=>u("watch",w),placeholder:`src/**
|
|
23
|
+
openapi.yaml`})}),e(U,{label:"Ignored paths",hint:"One glob per line. Changes here never trigger an update.",children:e(Za,{value:s.ignore,onInput:w=>u("ignore",w),placeholder:`**/*.test.ts
|
|
24
|
+
pnpm-lock.yaml`})}),e(U,{label:"Maximum agent minutes",children:e(re,{type:"number",min:"1",value:s.budget?.maxMinutes??"",onInput:w=>o({...s,budget:na(s.budget,"maxMinutes",w.currentTarget.value)})})}),e(U,{label:"Maximum runs per day",children:e(re,{type:"number",min:"1",value:s.budget?.maxRunsPerDay??"",onInput:w=>o({...s,budget:na(s.budget,"maxRunsPerDay",w.currentTarget.value)})})}),(!n.project?.defaultAgent||n.project.defaultAgent==="claude")&&e(U,{label:"Maximum Claude spend (USD)",hint:"Stops a Claude Code run at this cost and names the cap in the run log. Codex and Gemini have no spending flag, so this is ignored for them. Leave it empty for no cap.",children:e(re,{type:"number",min:"0.5",step:"0.5",placeholder:"No cap",value:s.budget?.maxUsd??"",onInput:w=>o({...s,budget:na(s.budget,"maxUsd",w.currentTarget.value)})})}),e(U,{label:"Re-verify after (days)",hint:"Checks evidence age even when source content is unchanged.",children:e(re,{type:"number",min:"1",max:"3650",value:s.maxVerificationAgeDays??"",onInput:w=>u("maxVerificationAgeDays",w.currentTarget.value?ea(w.currentTarget.value,1,3650):void 0)})}),e(U,{label:"Expired verification",children:e(Fe,{value:s.maxVerificationAgeSeverity??"warn",onChange:w=>u("maxVerificationAgeSeverity",w.currentTarget.value),children:[e("option",{value:"warn",children:"Warn"}),e("option",{value:"fail",children:"Fail validation"})]})})]}),e(Te,{children:"Save and install adds a background schedule on this computer, so checks run even when the control center is closed. Updates arrive as proposals under Review. Monitoring never changes the product source or publishes on its own."})]})]}),e("footer",{class:"ops-dialog-foot",children:[a.sync.on.length>0&&e(_,{tone:"danger",onClick:()=>confirm("Disable the installed monitoring schedule?")&&void t(()=>K("/api/sync/off"),"Monitoring disabled"),children:"Disable"}),e("span",{}),e(_,{tone:"ghost",onClick:i,children:"Cancel"}),e(_,{tone:"primary",busy:r,onClick:()=>{C()},children:"Save and install"})]})]})})}function td({state:n,act:t,onError:i}){const a=ft(n.runs),[s,o]=p(!1),l=a.filter(z=>!!z.archivedAt).length,c=a.filter(z=>s?!!z.archivedAt:!z.archivedAt),d=xa(),m=d.get("proposal")??"",r=a.find(z=>z.id===m),g=d.get("file")??"",u=z=>sn("proposals",z?{proposal:z}:{},"push"),v=z=>sn("proposals",{proposal:m,file:z}),[h,y]=p(null),[P,k]=p(!1),[C,w]=p(null),[I,L]=p(null),[D,E]=p("rendered"),[A,j]=p("split"),[W,O]=p(""),[ue,ge]=p(""),[fe,ye]=p(!0),[ce,se]=p(null),[G,H]=p(null),N=r?.changes.find(z=>z.id===g)??(r?Gl(r.changes):void 0),oe=r?!r.archivedAt&&St.includes(r.status):!1,Ce=r?ms(r.changes).concurrent:[];ae(()=>k(!1),[h?.id]);const ee=z=>!z.changedDuringRun||confirm(`${z.path} was edited in the project while the agent ran. Applying this change replaces that edit. Continue?`),[Q,x]=p([]),B=r?n.jobs.filter(z=>z.type===`proposal:revise:${r.id}`||z.type===`proposal:resume:${r.id}`):[],F=B.find(z=>z.status==="running"),T=F?void 0:B.find(z=>z.status==="failed"&&!Q.includes(z.id));r&&fa(r.changes);const Z=r?Vl(r.changes,r.status==="applied"):{accepted:0,rejected:0,remaining:0},Y=r&&n.documentationPlan&&(n.documentationPlan.proposalId===r.id||n.documentationPlan.id===r.planId)?n.documentationPlan:void 0,pe=Y?Y.pages.filter(z=>z.priority!=="later"&&z.action!=="remove"&&z.action!=="preserve"&&hs(z)).length:void 0,[te,M]=p(!1),ne=Re(null);ae(()=>{if(!te)return;const z=tn=>{tn.target instanceof Node&&!ne.current?.contains(tn.target)&&M(!1)},Se=tn=>{tn.key==="Escape"&&M(!1)};return document.addEventListener("pointerdown",z),document.addEventListener("keydown",Se),()=>{document.removeEventListener("pointerdown",z),document.removeEventListener("keydown",Se)}},[te]),ae(()=>{M(!1),Ie("")},[m]);const[xe,Ie]=p(""),[X,J]=p("current"),Ae=D==="source"?"source":A==="split"?"split":"rendered",Be=z=>{z==="source"?E("source"):(E("rendered"),j(z==="split"?"split":"unified"))},ke=r?r.changes.filter(z=>z.category==="page"&&z.kind!=="deleted").length:0,Ke=r?r.changes.filter(z=>z.category==="page"&&z.kind==="deleted").length:0,Je=r?n.jobs.find(z=>z.type.endsWith(`:${r.id}`)):void 0,q=r&&r.changes.length>0?Math.round(Z.accepted/r.changes.length*100):0,[ze,Pe]=p(!1),Ze=async z=>{if(!ze){Pe(!0);try{const Se=await t(()=>K(`/api/proposals/${z.id}/accept`,{scope:"all",...P?{confirmChangedDuringRun:!0}:{}}),"Documentation changes applied",!1);y(null),Se&&(w(Se),t(async()=>!0))}finally{Pe(!1)}}},nn=async(z,Se=G)=>{if(!Se?.instruction.trim())return!1;const tn=Se.mode==="all"?z.changes.map(me=>me.id):Se.mode==="current"?N?[N.id]:[]:Se.selectedIds,R=await t(()=>K(`/api/proposals/${z.id}/revise`,{instruction:Se.instruction,changeIds:tn,hunkIds:Se.hunkIds}),"Revision started",!1);return R&&H(null),!!R},Ee=async()=>{if(!(!r||!N||!xe.trim()||!oe)){if(X==="selected"){H({mode:"selected",instruction:xe.trim(),selectedIds:[N.id],hunkIds:[]});return}await nn(r,{mode:X,instruction:xe.trim(),selectedIds:[N.id],hunkIds:[]})&&Ie("")}};return e(ie,{children:[I&&e("div",{class:"proposal-ready-scrim",role:"presentation",children:e("section",{class:"proposal-ready-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"proposal-delivery-title",children:[e("button",{class:"proposal-ready-close",type:"button","aria-label":"Close",onClick:()=>L(null),children:e($,{name:"close",size:16})}),e("span",{class:"proposal-ready-icon",children:e($,{name:"external",size:24})}),e("div",{children:[e("h2",{id:"proposal-delivery-title",children:I.pullRequestUrl?"Pull request is ready":I.pushedAt?"Branch published":"Pull-request branch is ready"}),e("p",{children:I.pushedAt?"The reviewed commit is available on the remote without changing your current working tree.":"Doxloop created the branch in an isolated Git worktree without changing your current working tree."})]}),e("div",{class:"proposal-ready-summary",children:[e("strong",{children:I.branch}),e("span",{children:["Commit ",I.commit.slice(0,12)]})]}),!I.pushedAt&&I.pullRequestCommand&&e("code",{children:I.pullRequestCommand}),e("footer",{children:[I.pullRequestUrl?e("a",{class:"btn primary md",href:I.pullRequestUrl,target:"_blank",rel:"noreferrer",children:"Open pull request"}):I.pushedAt?I.compareUrl&&e("a",{class:"btn primary md",href:I.compareUrl,target:"_blank",rel:"noreferrer",children:"Open comparison"}):e(ie,{children:[e(_,{onClick:()=>{(async()=>{const z=await t(()=>K(`/api/proposals/${m}/delivery/publish`,{createPullRequest:!1}),"Branch published");z&&L(z)})()},children:"Push branch"}),e(_,{tone:"primary",onClick:()=>{(async()=>{const z=await t(()=>K(`/api/proposals/${m}/delivery/publish`,{createPullRequest:!0}),"Pull request created");z&&L(z)})()},children:"Push & create PR"})]}),e(_,{onClick:()=>L(null),children:"Done"})]})]})}),ce&&e(ys,{change:ce,onClose:()=>se(null)}),G&&r&&e(id,{proposal:r,current:N,draft:G,onChange:H,onClose:()=>H(null),onSubmit:()=>{nn(r)}}),h&&e("div",{class:"proposal-ready-scrim",role:"presentation",children:e("section",{class:"proposal-ready-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"proposal-accept-title",children:[e("button",{class:"proposal-ready-close",type:"button","aria-label":"Close",disabled:ze,onClick:()=>y(null),children:e($,{name:"close",size:16})}),e("span",{class:"proposal-ready-icon",children:e($,{name:"proposals",size:24})}),e("div",{children:[e("h2",{id:"proposal-accept-title",children:"Apply these documentation changes?"}),e("p",{children:"This replaces the current versions of the reviewed files with the proposed versions."})]}),e("div",{class:"proposal-ready-summary",children:[e("strong",{children:ma(h.changes)}),e("span",{children:"Only the files listed in this proposal will be applied."})]}),Ce.length>0&&e("div",{class:"proposal-concurrent-warning",role:"group","aria-label":"Files edited while the agent ran",children:[e("strong",{children:[e($,{name:"alert",size:14}),Ce.length===1?"One file was edited while the agent ran":`${Ce.length} files were edited while the agent ran`]}),e("p",{children:"The agent never saw these edits. Applying the proposal replaces them with the proposed versions."}),e("ul",{children:Ce.map(z=>e("li",{children:e("code",{children:z.path})},z.id))}),e(jt,{checked:P,onChange:k,label:"Replace my edits to these files"})]}),e("footer",{children:[e(_,{disabled:ze,onClick:()=>y(null),children:"Cancel"}),e(_,{tone:"primary",icon:"check",busy:ze,disabled:Ce.length>0&&!P,onClick:()=>{Ze(h)},children:"Apply changes"})]})]})}),C&&e("div",{class:"proposal-ready-scrim",role:"presentation",children:e("section",{class:"proposal-ready-dialog proposal-applied-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"proposal-applied-title",children:[e("button",{class:"proposal-ready-close",type:"button","aria-label":"Close",onClick:()=>w(null),children:e($,{name:"close",size:16})}),e("span",{class:"proposal-ready-icon applied",children:e($,{name:"check",size:24})}),e("div",{children:[e("h2",{id:"proposal-applied-title",children:C.status==="applied"?"Documentation changes applied":"Some changes were applied"}),e("p",{children:[rd(C)," Preview the result, then publish it when it looks right."]})]}),e("div",{class:"proposal-ready-summary",children:[e("strong",{children:ma(C.changes)}),e("span",{children:C.status==="applied"?"Undo stays available from this proposal until newer edits replace these files.":"The remaining changes are still waiting for a decision in this proposal."})]}),e("footer",{children:[e(_,{onClick:()=>w(null),children:"Done"}),e(_,{icon:"preview",onClick:()=>{_a(z=>K("/api/preview/start",{open:z}))},children:"Preview docs"}),e(_,{tone:"primary",icon:"deploy",onClick:()=>{w(null),sn("publish",{},"push")},children:"Publish"})]})]})}),r?e(ht,{kicker:Y?`Proposal · plan v${Y.version}`:r.editRequest?"Proposal · page edit":"Proposal",title:"Review proposal",actions:e(ie,{children:[e("div",{class:"review-more",ref:ne,children:[e("button",{type:"button",class:"btn secondary md review-more-trigger","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":te,onClick:()=>M(!te),children:e(Ls,{})}),te&&e("div",{class:"review-more-menu",role:"menu","aria-label":"More actions",children:[(oe||r.status==="stale"&&!r.archivedAt)&&e("button",{type:"button",role:"menuitem",onClick:()=>{M(!1),H({mode:"all",instruction:"Regenerate this proposal using the current approved plan and evidence.",selectedIds:r.changes.map(z=>z.id),hunkIds:[]})},children:"Regenerate"}),r.status==="awaiting-review"&&!r.archivedAt&&(r.validation?.errors??0)>0&&e("button",{type:"button",role:"menuitem",onClick:()=>{M(!1),t(()=>K(`/api/proposals/${r.id}/repair`),"Proposal repaired and validated again")},children:"Repair proposal"}),r.status==="failed"&&!r.archivedAt&&r.recovery?.resumable!==!1&&e("button",{type:"button",role:"menuitem",onClick:()=>{M(!1),t(()=>K(`/api/proposals/${r.id}/resume`),"Continuing the documentation run")},children:"Resume"}),r.status==="failed"&&!r.archivedAt&&r.recovery?.ignorable!==!1&&e("button",{type:"button",role:"menuitem",onClick:()=>{M(!1),t(()=>K(`/api/proposals/${r.id}/recover`,{ignoreScreenshotProblems:!0}),"Proposal ready for review with problems ignored")},children:"Ignore problems & review"}),r.status==="applied"&&r.undo?.status==="available"&&e("button",{type:"button",role:"menuitem",onClick:()=>{M(!1),confirm("Undo every file applied by this proposal? Newer edits will be protected.")&&t(()=>K(`/api/proposals/${r.id}/undo`),"Documentation changes undone")},children:"Undo"}),!r.archivedAt&&r.status!=="generating"&&e("button",{type:"button",role:"menuitem",onClick:()=>{M(!1),confirm("Archive this proposal? It can remain in history until cleanup.")&&t(()=>K(`/api/proposals/${r.id}/archive`),"Proposal archived")},children:"Archive"}),I&&!I.pushedAt&&e("button",{type:"button",role:"menuitem",onClick:()=>{M(!1),(async()=>{const z=await t(()=>K(`/api/proposals/${r.id}/delivery/publish`,{createPullRequest:!1}),"Branch published");z&&L(z)})()},children:"Push branch"}),I&&!I.pushedAt&&e("button",{type:"button",role:"menuitem",onClick:()=>{M(!1),(async()=>{const z=await t(()=>K(`/api/proposals/${r.id}/delivery/publish`,{createPullRequest:!0}),"Pull request created");z&&L(z)})()},children:"Push & create PR"}),I?.pullRequestUrl&&e("a",{role:"menuitem",href:I.pullRequestUrl,target:"_blank",rel:"noreferrer",onClick:()=>M(!1),children:"Open pull request"}),I?.pushedAt&&!I.pullRequestUrl&&I.compareUrl&&e("a",{role:"menuitem",href:I.compareUrl,target:"_blank",rel:"noreferrer",onClick:()=>M(!1),children:"Open comparison"})]})]}),oe&&e(_,{icon:"publish",onClick:()=>{(async()=>{const z=await t(()=>K(`/api/proposals/${r.id}/delivery/branch`,{}),"Pull-request branch prepared");z&&L(z)})()},children:"Prepare PR branch"}),r.status==="applied"?r.undo?.status==="available"?e(_,{icon:"undo",onClick:()=>{confirm("Undo every file applied by this proposal? Newer edits will be protected.")&&t(()=>K(`/api/proposals/${r.id}/undo`),"Documentation changes undone")},children:"Undo apply"}):e(Me,{tone:"good",children:"Applied"}):e(_,{tone:"primary",icon:"check",disabled:!oe,onClick:()=>y(r),children:"Apply changes"})]})}):e(ht,{kicker:"Review",title:"Review",actions:a.length>0?e(ie,{children:[e(_,{onClick:()=>o(!s),children:s?"Back to proposals":`Archived (${l})`}),s&&l>0&&e(_,{tone:"danger",onClick:()=>confirm("Permanently remove every archived proposal workspace?")&&void t(()=>K("/api/proposals/cleanup",{}),"Archived proposals cleaned up"),children:"Clean up archived"})]}):void 0}),a.length===0?e(Ue,{flush:!0,children:e(Mn,{icon:"review",title:"No changes waiting for review",detail:"When the agent finishes writing, the proposal appears here."})}):r?e("div",{class:"review",children:[e("section",{class:"review-summary-bar","aria-label":"Proposal summary",children:[e("div",{class:"review-summary-copy",children:[e("strong",{children:[Y?`Generated from plan v${Y.version}`:r.editRequest?"Page edit":"Documentation update"," · ",r.changes.length," file",r.changes.length===1?"":"s",ke>0?` · ${ke} page${ke===1?"":"s"}`:"",Ke>0?` · ${Ke} removed`:"",r.screenshots&&r.screenshots.status!=="not-requested"?` · ${r.screenshots.captured} screenshot${r.screenshots.captured===1?"":"s"}`:""]}),e("small",{children:[r.sourceSummary,Ye(r.createdAt),r.usage?Ns(r.usage):""].filter(Boolean).join(" · ")})]}),e("div",{class:"review-summary-side",children:[r.validation&&e(Me,{tone:r.validation.errors>0?"bad":r.validation.warnings>0?"warn":"good",children:r.validation.errors>0?`${r.validation.errors} validation error${r.validation.errors===1?"":"s"}`:r.validation.warnings>0?`${r.validation.warnings} validation warning${r.validation.warnings===1?"":"s"}`:"Navigation valid"}),r.screenshots&&r.screenshots.status!=="not-requested"&&e(Me,{tone:r.screenshots.status==="verified"?"good":r.screenshots.status==="failed"?"bad":"neutral",children:r.screenshots.status==="verified"?`Screenshots verified ${r.screenshots.captured} / ${r.screenshots.planned}`:r.screenshots.status==="failed"?"Screenshots need attention":r.screenshots.status==="skipped"?"Screenshots skipped":"Screenshots planned"}),e(Me,{tone:Vn(r.archivedAt?"archived":r.status),children:r.archivedAt?"Archived":Kn(r.status)}),e(_,{size:"sm",icon:"external",onClick:()=>{ua(r.id)},children:"Preview docs"}),Je&&e("a",{class:"btn ghost sm",href:`/api/jobs/${Je.id}/log`,target:"_blank",rel:"noreferrer",children:"Open log"})]})]}),e("div",{class:"review-notices",children:[r.status==="failed"&&!r.archivedAt&&e("div",{class:"proposal-lifecycle-notice failed",children:[e($,{name:"alert",size:15}),e("span",{class:"proposal-failed-copy",children:[e("strong",{children:"This run stopped before it could be reviewed."}),r.error&&e("small",{children:r.error}),(r.recovery?.resumable!==!1||r.recovery?.ignorable!==!1)&&e("small",{children:"Its workspace is preserved: continue it instead of generating again."})]}),(r.recovery?.resumable!==!1||r.recovery?.ignorable!==!1)&&e("span",{class:"proposal-failed-actions",children:[r.recovery?.resumable!==!1&&e(_,{size:"sm",tone:"primary",icon:"play",onClick:()=>{t(()=>K(`/api/proposals/${r.id}/resume`),"Continuing the documentation run")},children:"Resume"}),r.recovery?.ignorable!==!1&&e(_,{size:"sm",icon:"check",onClick:()=>{t(()=>K(`/api/proposals/${r.id}/recover`,{ignoreScreenshotProblems:!0}),"Proposal ready for review with problems ignored")},children:"Ignore problems & review"})]})]}),T&&e("div",{class:"proposal-lifecycle-notice failed",role:"alert",children:[e($,{name:"alert",size:15}),e("span",{class:"proposal-failed-copy",children:[e("strong",{children:T.type.startsWith("proposal:resume:")?"The run could not be continued.":"The agent could not complete this revision."}),e("small",{children:Bi(T)??"The agent stopped without reporting a reason. Open the log for details."})]}),e("span",{class:"proposal-failed-actions",children:[e("a",{class:"btn secondary sm",href:`/api/jobs/${T.id}/log`,target:"_blank",rel:"noreferrer",children:"Open log"}),e(_,{size:"sm",onClick:()=>x([...Q,T.id]),children:"Dismiss"})]})]}),F&&e("section",{class:"proposal-revision-live","aria-label":"Agent revision in progress",children:[e("header",{children:[e($,{name:"bot",size:15}),e("strong",{children:Zt(F.type)}),e("small",{children:"The proposal updates when the agent finishes."})]}),e(Pa,{job:F,act:t,stopLabel:"Stop",captures:!!n.project?.application})]}),r.status==="awaiting-review"&&!r.archivedAt&&(r.validation?.errors??0)>0&&e("div",{class:"proposal-lifecycle-notice failed",children:[e($,{name:"alert",size:15}),e("span",{class:"proposal-failed-copy",children:[e("strong",{children:[r.validation.errors," validation error",r.validation.errors===1?"":"s"," keep this proposal from being applied."]}),e("small",{children:"Repair lets Doxloop fix navigation placement and unresolvable links deterministically, without starting an agent."})]}),e("span",{class:"proposal-failed-actions",children:e(_,{size:"sm",tone:"primary",icon:"check",onClick:()=>{t(()=>K(`/api/proposals/${r.id}/repair`),"Proposal repaired and validated again")},children:"Repair proposal"})})]}),r.advisories?.map(z=>e("div",{class:"proposal-lifecycle-notice advisory",children:[e($,{name:"info",size:15}),e("span",{children:z})]},z)),(r.status==="stale"||r.status==="superseded"||r.archivedAt)&&e("div",{class:`proposal-lifecycle-notice ${r.status}`,children:[e($,{name:"info",size:15}),e("span",{children:r.status==="stale"?r.error:r.status==="superseded"?`A newer revision${r.supersededBy?` (${r.supersededBy})`:""} replaced this proposal.`:"This proposal is archived."})]}),r.screenshots&&r.screenshots.status!=="not-requested"&&e("div",{class:`proposal-screenshot-result ${r.screenshots.ignoredProblems?"ignored":r.screenshots.status==="verified"&&pe!==void 0&&r.screenshots.guides*2<pe?"thin":r.screenshots.status}`,children:[e("span",{class:"screenshot-camera",children:e($,{name:"camera",size:17})}),e("span",{children:[e("strong",{children:r.screenshots.status==="skipped"?"Application screenshots skipped":r.screenshots.status==="failed"?"Application screenshot capture needs attention":Kl(r.screenshots,pe)}),e("small",{children:[r.screenshots.ignoredProblems?`${r.screenshots.ignoredProblems} screenshot problem${r.screenshots.ignoredProblems===1?"":"s"} to review. `:"",r.screenshots.message?e(md,{message:r.screenshots.message}):r.screenshots.textOnly>0?`${r.screenshots.textOnly} step${r.screenshots.textOnly===1?"":"s"} could not be captured and are described in text.`:pe!==void 0&&r.screenshots.guides<pe?`The other ${pe-r.screenshots.guides} guide${pe-r.screenshots.guides===1?" is":"s are"} text-only.`:""]})]}),r.screenshots.status==="verified"&&e(_,{size:"sm",onClick:()=>{ua(r.id)},children:"Review in preview"})]})]}),e("div",{class:"review-workspace",children:[e("aside",{class:"review-files","aria-label":"Files in this proposal",children:[e("div",{class:"review-files-card",children:[e("div",{class:"review-files-head",children:[e("strong",{children:[r.changes.length," file",r.changes.length===1?"":"s"]}),e("small",{children:[Z.accepted," accepted · ",Z.remaining," pending",Z.rejected>0?` · ${Z.rejected} rejected`:""]})]}),e("div",{class:"progress good",role:"progressbar","aria-label":"Accepted files","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":q,children:e("i",{style:{width:`${q}%`}})}),e("div",{class:"review-files-actions",children:[e(_,{size:"sm",disabled:!oe,onClick:()=>r&&y(r),children:"Accept all"}),e(_,{size:"sm",tone:"ghost",disabled:!oe,onClick:()=>confirm("Reject the remaining undecided changes? Already accepted changes stay applied.")&&void t(()=>K(`/api/proposals/${r.id}/reject`),"Remaining changes rejected"),children:"Reject remaining"})]})]}),N&&e(ad,{changes:r.changes,selected:N,onSelect:v},r.id),oe&&e("details",{class:"text-editor review-folder-tools",children:[e("summary",{children:"Review a folder"}),e("div",{class:"text-editor-body",children:[e("label",{children:["Folder",e("select",{value:W,onChange:z=>O(z.currentTarget.value),children:[e("option",{value:"",children:"Choose a folder"}),[...new Set(r.changes.flatMap(z=>{const Se=z.path.split("/");return Se.slice(0,-1).map((tn,R)=>Se.slice(0,R+1).join("/"))}))].sort().map(z=>e("option",{children:z}))]})]}),W&&e("ul",{children:r.changes.filter(z=>z.path.startsWith(`${W}/`)&&z.hunks.some(Se=>!Se.acceptedAt&&!Se.rejectedAt)).map(z=>e("li",{children:z.path}))}),e("label",{children:["Rejection reason",e("input",{value:ue,onInput:z=>ge(z.currentTarget.value)})]}),e("div",{class:"text-editor-actions",children:[e(_,{disabled:!W,onClick:()=>{if(r.changes.filter(Se=>Se.path.startsWith(`${W}/`)).some(Se=>Se.changedDuringRun)){i("A file in this folder changed during generation. Review and accept it individually before accepting the folder.");return}t(()=>K(`/api/proposals/${r.id}/accept`,{scope:"folder",folder:W}),"Folder changes accepted")},children:"Accept pending changes in folder"}),e(_,{disabled:!W||!ue.trim(),onClick:()=>{t(()=>K(`/api/proposals/${r.id}/reject-changes`,{scope:"folder",folder:W,reason:ue}),"Folder changes rejected")},children:"Reject pending changes in folder"})]})]})]})]}),e("section",{class:"review-diff-panel",children:N?e(ie,{children:[e("header",{class:"review-file-head",children:[e("div",{class:"review-file-head-main",children:[e("div",{class:"review-file-title",children:[e("code",{children:N.path}),e("span",{class:`badge no-dot ${N.kind==="added"?"good":N.kind==="deleted"?"bad":"warn"}`,children:N.kind==="added"?"Added":N.kind==="deleted"?"Deleted":"Modified"}),N.changedDuringRun&&e("span",{class:"badge warn",children:"Edited while the agent ran"})]}),e("small",{children:[N.hunks.length," change",N.hunks.length===1?"":"s"," · ",N.category,N.title&&N.title!==N.path?` · ${N.title}`:""," · ",Math.max(0,r.changes.findIndex(z=>z.id===N.id))+1," of ",r.changes.length]})]}),e("div",{class:"review-file-head-actions",children:[e(pt,{value:Ae,onChange:Be,items:[["rendered","Rendered"],["split","Side-by-side"],["source","Source"]]}),e(_,{size:"sm",tone:"danger",disabled:!oe||!N.hunks.some(z=>!z.acceptedAt&&!z.rejectedAt),onClick:()=>{const z=prompt("Why reject the remaining changes in this file? (optional)","");z!==null&&t(()=>K(`/api/proposals/${r.id}/reject-changes`,{changeId:N.id,reason:z}),"File changes rejected")},children:"Reject file"}),e(_,{size:"sm",tone:"primary",icon:"check",disabled:!oe,onClick:()=>ee(N)&&void t(()=>K(`/api/proposals/${r.id}/accept`,{scope:"page",changeId:N.id,...N.changedDuringRun?{confirmChangedDuringRun:!0}:{}}),"Page accepted"),children:"Accept file"})]})]}),e("div",{class:"review-file-tools",children:[D==="rendered"&&e("button",{type:"button",class:"chip","aria-pressed":fe,onClick:()=>ye(!fe),children:"Changes only"}),e(_,{size:"sm",tone:"ghost",icon:"info",onClick:()=>se(N),children:"Why this change"}),r.status==="applied"&&N.category==="page"&&N.kind!=="deleted"&&e(_,{size:"sm",tone:"ghost",icon:"update",onClick:()=>sn("pages",{path:N.path},"push"),children:"Edit this page"})]}),N.changedDuringRun&&e("div",{class:"proposal-lifecycle-notice concurrent",role:"note",children:[e($,{name:"alert",size:15}),e("span",{children:[e("strong",{children:"This file was edited in the project while the agent ran."})," The comparison shows the proposal against your edited version; accepting replaces that edit and asks first."]})]}),e("div",{class:"review-diff-body",children:D==="source"?e(bs,{runId:r.id,change:N,act:t,partialActions:oe,beforeAccept:()=>ee(N),onReviseHunk:z=>H({mode:"current",instruction:"",selectedIds:[N.id],hunkIds:[z]})}):e(vs,{runId:r.id,change:N,layout:A,onlyChanges:fe},`${r.id}:${N.afterHash}`)}),e("div",{class:"review-file-extras",children:[e(us,{path:N.path,proposal:{id:r.id,change:N},onRequest:async(z,Se)=>{if(!oe)throw new Error("This proposal is closed. Comment on the live page to request a new update.");await t(()=>K(`/api/proposals/${r.id}/revise`,{instruction:`Address this reviewer comment: ${z}`,changeIds:[N.id],hunkIds:Se?[Se]:[]}),"Comment revision started")}},`comments:${r.id}:${N.id}`),oe&&N.category==="page"&&!N.binary&&N.kind!=="deleted"&&N.hunks.every(z=>!z.acceptedAt&&!z.rejectedAt)&&e(ps,{root:n.root??n.cwd,path:N.path,proposal:{id:r.id,changeId:N.id},onChanged:async()=>{await t(async()=>!0)}},`${r.id}:${N.id}`)]}),e("footer",{class:"review-revise-bar",children:[e("div",{class:"review-revise-input",children:[e($,{name:"sparkles",size:16}),e("input",{class:"input",type:"text","aria-label":"Ask the agent to revise",placeholder:oe?"Ask the agent to revise this file…":"This proposal is closed",value:xe,disabled:!oe,onInput:z=>Ie(z.currentTarget.value),onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),Ee())}})]}),e("label",{class:"review-revise-scope",children:[e("span",{class:"sr-only",children:"Revision scope"}),e("select",{class:"chip",value:X,disabled:!oe,onChange:z=>J(z.currentTarget.value),children:[e("option",{value:"current",children:"This file"}),e("option",{value:"all",children:"Whole proposal"}),e("option",{value:"selected",children:"Choose files"})]}),e($,{name:"chevronDown",size:13})]}),e(_,{disabled:!oe||!xe.trim(),onClick:()=>{Ee()},children:"Send"})]})]}):e(Mn,{title:"This proposal contains no file changes"})})]})]}):e(Ue,{class:"proposal-index-panel",flush:!0,children:c.length===0?e(Mn,{icon:"review",title:s?"No archived proposals":"No changes waiting for review",detail:s?"Archived proposal workspaces appear here until cleanup.":"When the agent finishes writing, the proposal appears here."}):e("div",{class:"proposal-index-list",children:c.map(z=>{const Se=fa(z.changes),tn=z.editRequest;if(tn){const R=tn.paths.length===1?tn.paths[0]:`${tn.paths.length} pages`;return e("button",{type:"button",class:"proposal-index-row",onClick:()=>sn("pages",{run:z.id},"push"),children:[e("span",{class:"proposal-index-copy",children:[e("strong",{children:["Page edit · ",R]}),e("small",{children:[Ye(z.createdAt)," · ",Ci(z)]})]}),e(Me,{tone:Vn(z.archivedAt?"archived":z.status),children:z.archivedAt?"Archived":Kn(z.status)}),e($,{name:"chevronRight",size:15})]},z.id)}return e("button",{type:"button",class:"proposal-index-row",onClick:()=>u(z.id),children:[e("span",{class:"proposal-index-copy",children:[e("strong",{children:Vc(z)}),e("small",{children:[Ye(z.createdAt),`${z.changes.length} file${z.changes.length===1?"":"s"}: ${Se.added} added, ${Se.modified} changed${Se.deleted?`, ${Se.deleted} removed`:""}`,z.validation?z.validation.errors?`${z.validation.errors} validation error${z.validation.errors===1?"":"s"}`:"validates":""].filter(Boolean).join(" · ")})]}),e(Me,{tone:Vn(z.archivedAt?"archived":z.status),children:z.archivedAt?"Archived":Kn(z.status)}),e($,{name:"chevronRight",size:15})]},z.id)})})})]})}function id({proposal:n,current:t,draft:i,onChange:a,onClose:s,onSubmit:o}){const l=i.mode==="all"?n.changes.length:i.mode==="current"?+!!t:i.selectedIds.length;return e("div",{class:"proposal-ready-scrim",role:"presentation",children:e("section",{class:"proposal-revision-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"proposal-revision-title",children:[e("header",{children:[e("span",{children:[e("small",{children:"Agent revision"}),e("h2",{id:"proposal-revision-title",children:"What should change?"}),e("p",{children:"Only the selected scope will be regenerated. Everything else stays exactly as reviewed."})]}),e("button",{type:"button","aria-label":"Close revision",onClick:s,children:e($,{name:"close",size:16})})]}),e("div",{class:"revision-scope-tabs",children:[["current","This file"],["selected","Choose files"],["all","Whole proposal"]].map(([c,d])=>e("button",{type:"button",class:i.mode===c?"active":"",onClick:()=>a({...i,mode:c,selectedIds:c==="current"&&t?[t.id]:i.selectedIds,hunkIds:c==="current"?i.hunkIds:[]}),children:d}))}),i.hunkIds.length>0&&e(Te,{tone:"info",children:["The request is scoped to one selected source change in ",t?.path,"."]}),i.mode==="selected"&&e("div",{class:"revision-file-list",children:n.changes.map(c=>e("label",{children:[e("input",{type:"checkbox",checked:i.selectedIds.includes(c.id),onChange:d=>a({...i,selectedIds:d.currentTarget.checked?[...i.selectedIds,c.id]:i.selectedIds.filter(m=>m!==c.id)})}),e("span",{children:[e("strong",{children:c.title}),e("code",{children:c.path})]}),e(Me,{tone:Vn(c.kind),children:c.kind})]},c.id))}),e(U,{label:"Revision instructions",children:e(en,{rows:5,maxlength:2e3,value:i.instruction,placeholder:"For example: Make this task more concise, keep the API example, and explain the expected response.",onInput:c=>a({...i,instruction:c.currentTarget.value})})}),e("footer",{children:[e("small",{children:[l," file",l===1?"":"s"," selected"]}),e("span",{children:[e(_,{onClick:s,children:"Cancel"}),e(_,{tone:"primary",icon:"wand",disabled:!i.instruction.trim()||l===0,onClick:o,children:"Send to agent"})]})]})]})})}function ad({changes:n,selected:t,onSelect:i}){const[a,s]=p(""),o=ms(n),[l,c]=p(!1),d=l||o.supporting.some(y=>y.id===t.id)||o.documentation.length===0&&o.concurrent.length===0,m=[{id:"concurrent",label:"Changed while the agent ran",changes:o.concurrent,tone:"warn"},{id:"documentation",label:"Pages, navigation, and assets",changes:o.documentation,tone:""},...d?[{id:"supporting",label:"Evidence, configuration, and skills",changes:o.supporting,tone:""}]:[]].filter(y=>y.changes.length>0),r=a.trim().toLocaleLowerCase(),g=(y,P)=>y.path.localeCompare(P.path),u=m.map(y=>({...y,changes:[...y.changes].filter(P=>!r||P.path.toLocaleLowerCase().includes(r)).sort(g)})).filter(y=>y.changes.length>0),v=u.reduce((y,P)=>y+P.changes.length,0),h=y=>y.hunks.length===0?"pending":y.hunks.every(P=>P.acceptedAt)?"accepted":y.hunks.every(P=>P.rejectedAt)?"rejected":y.hunks.some(P=>P.acceptedAt||P.rejectedAt)?"partial":"pending";return e("nav",{class:"review-file-list","aria-label":"Changed files",children:[n.length>8&&e("label",{class:"review-file-search",children:[e("span",{class:"sr-only",children:"Search changed files"}),e($,{name:"search",size:15}),e("input",{class:"input",type:"search",value:a,placeholder:"Filter files…",onInput:y=>s(y.currentTarget.value)})]}),v>0?u.map(y=>e("section",{class:`review-file-group ${y.tone}`,"aria-label":y.label,children:[e("header",{children:[e("span",{class:"kicker",children:y.label}),e("small",{children:y.changes.length})]}),y.changes.map(P=>{const k=h(P);return e("button",{type:"button",class:`review-file-row ${t.id===P.id?"active":""} ${k}`,"aria-current":t.id===P.id?"true":void 0,title:P.path,onClick:()=>i(P.id),children:[e("b",{class:`review-file-kind ${P.kind}`,"aria-hidden":"true",children:P.kind==="added"?"A":P.kind==="deleted"?"D":"M"}),e("span",{class:"review-file-path",children:P.path}),k==="accepted"&&e($,{name:"check",size:13}),k==="rejected"&&e($,{name:"close",size:13}),k==="partial"&&e("i",{class:"review-file-partial",title:"Partly decided"})]},P.id)})]},y.id)):e("div",{class:"review-file-search-empty",children:[e("strong",{children:"No matching files"}),e("small",{children:"Try a filename or folder path."})]}),o.supporting.length>0&&!r&&e("button",{type:"button",class:"review-file-group-toggle","aria-expanded":d,onClick:()=>c(!d),children:[e($,{name:"chevronRight",size:12}),d?"Hide":"Show"," ",o.supporting.length," supporting file",o.supporting.length===1?"":"s"]})]})}function fa(n){return n.reduce((t,i)=>(i.kind==="added"?t.added+=1:i.kind==="deleted"?t.deleted+=1:t.modified+=1,t),{added:0,modified:0,deleted:0})}function rd(n){const t=n.changes.filter(i=>i.category==="page"&&i.kind!=="deleted"&&(n.status==="applied"||i.hunks.some(a=>a.acceptedAt))).length;return t>0?`${t} page${t===1?"":"s"} applied.`:"The accepted files were applied."}function ma(n){const t=fa(n);return`${n.length} file change${n.length===1?"":"s"} · ${t.added} added · ${t.modified} modified · ${t.deleted} deleted`}const sd=/^\s*(?:\d{2}:\d{2}:\d{2}\s+)?([✓✗])\s+(.+)$/;function od(n,t,i=!1){return i?["Validating documentation","Building static site","Writing folder and zip"]:n==="doxbrix"?t?["Validating documentation","Building bundle"]:["Validating documentation","Building bundle","Locating project","Publishing to Doxbrix"]:t?["Validating documentation","Building site locally"]:["Validating documentation","Locating project","Building site locally","Reserving secure upload","Uploading static artifact","Indexing and deploying"]}function ld(n,t){const i=[];for(const c of n.lines){const d=sd.exec(Oi(c));d&&i.push({text:(d[2]??"").trim(),ok:d[1]==="✓"})}const a=n.status==="running",s=t.map((c,d)=>{const m=i[d];if(m){const[r,g]=m.text.split(" · ");return{label:r||c,...g?{detail:g}:{},status:m.ok?"done":"failed"}}return d===i.length&&a?{label:c,status:"running"}:{label:c,status:"pending"}}),o=s.filter(c=>c.status==="done").length,l=n.status==="succeeded"?100:Math.min(95,Math.round(o/Math.max(t.length,1)*100)+(a?6:0));return{steps:s,percent:l}}function cd({job:n,generator:t,act:i,streamConnected:a,onDismiss:s,siteUrl:o}){const l=Re(null),[c,d]=p(n.status!=="succeeded"),m=n.type==="deploy:dry-run",r=n.type==="export",{steps:g,percent:u}=ld(n,od(t,m,r)),v=n.status==="running",h=g.find(C=>C.status==="running");ae(()=>{l.current&&(l.current.scrollTop=l.current.scrollHeight)},[n.lines.length,c]);const y=n.status==="failed"&&n.lines.some(C=>ji(C)),P=v?h?.label??(r?"Exporting static site":m?"Validating deployment":"Publishing to Doxbrix"):n.status==="succeeded"?r?"Static site exported":m?"Deployment is valid":"Documentation published":n.status==="cancelled"?r?"Export cancelled":"Publish cancelled":r?"Export failed":"Publish failed",k=Re(null);return ae(()=>{n.status==="running"&&k.current?.scrollIntoView({behavior:"smooth",block:"start"})},[n.id]),e("section",{ref:k,class:`panel deploy-progress ${n.status}`,"aria-live":"polite",children:[y&&e(Te,{tone:"warn",children:e("span",{children:["Doxbrix did not accept the saved sign-in, so nothing was uploaded. It may have expired, been revoked, or belong to a different Doxbrix server. Choose ",e("strong",{children:"Sign in with browser"})," above, then deploy again."]})}),e("header",{class:"panel-head deploy-progress-head",children:[e("span",{class:`deploy-progress-icon ${n.status}`,children:e($,{name:v?"publish":n.status==="succeeded"?"check":"alert",size:17})}),e("div",{class:"panel-title deploy-progress-title",children:[e("h2",{children:r?"Latest export":m?"Latest dry run":"Latest publish"}),e("p",{children:[e("strong",{children:P})," · ",v?`started ${Ye(n.startedAt)}`:r?"Self-hostable folder and zip on this computer":m?"Validation only, nothing uploaded":n.status!=="succeeded"?"Nothing was changed on the live site":o?`Live at ${Nt(o)}`:"Published to Doxbrix"]})]}),e("div",{class:"panel-actions",children:[v?e(Me,{tone:a?"info":"warn",children:a?"In progress":"Reconnecting…"}):e(Me,{tone:Vn(n.status),children:n.status==="succeeded"?r?"Exported":m?"Valid":"Live":n.status==="failed"?"Failed":Kn(n.status)}),!v&&n.status==="succeeded"&&o&&!r&&!m&&e("a",{class:"btn secondary sm",href:o,target:"_blank",rel:"noreferrer",children:[e($,{name:"external",size:14}),"View site"]}),v&&e(_,{size:"sm",tone:"danger",icon:"stop",onClick:()=>{i(()=>K(`/api/jobs/${n.id}/cancel`),"Deployment stopped")},children:"Stop"}),!v&&s&&e(_,{size:"sm",tone:"ghost",icon:"close",onClick:s,children:"Dismiss"})]})]}),v&&e("div",{class:"deploy-progress-bar",children:[e("div",{class:"deploy-progress-track running",children:e("i",{style:{width:`${u}%`}})}),e("span",{children:[u,"%"]})]}),e("ol",{class:"deploy-progress-steps",children:g.map((C,w)=>e("li",{class:C.status,children:[e("span",{class:"deploy-step-mark",children:C.status==="done"?e($,{name:"check",size:12}):C.status==="failed"?e($,{name:"close",size:12}):null}),e("span",{class:"deploy-step-copy",children:[e("strong",{children:C.label}),C.detail&&e("small",{children:C.detail})]})]},w))}),e("div",{class:"deploy-progress-log",children:[e("div",{class:"live-job-meta",children:[e("button",{type:"button",class:"deploy-log-toggle","aria-expanded":c,onClick:()=>d(!c),children:[e($,{name:"chevronDown",size:14}),c?"Hide log":"Show log"]}),e("span",{children:[e($,{name:"clock",size:14}),"Last output ",Ye(n.lastOutputAt??n.startedAt)]}),e("span",{class:"authoring-live-actions",children:e("a",{href:`/api/jobs/${n.id}/log`,target:"_blank",rel:"noreferrer",children:["Open full log ",e($,{name:"external",size:12})]})})]}),c&&e("pre",{ref:l,class:"terminal live-terminal",children:n.lines.length>0?Ca(n.lines).join(`
|
|
25
|
+
`):"Starting deployment…"})]})]})}function dd({checks:n}){return e("ul",{class:"publish-checklist","aria-label":"Before publishing",children:n.map(t=>e("li",{class:t.state,children:[e("span",{class:"publish-check-mark","aria-hidden":"true",children:e($,{name:t.state==="ok"?"check":"alert",size:13})}),e("span",{class:"publish-check-copy",children:[e("strong",{children:t.title}),e("small",{children:t.detail})]}),t.action&&e("button",{type:"button",class:"btn link",onClick:t.action.run,children:t.action.label})]},t.title))})}function Cr({value:n,onChange:t}){return e("div",{class:"radio-rows publish-visibility",role:"radiogroup","aria-label":"Who can read it",children:[e("button",{type:"button",role:"radio","aria-checked":n==="public",class:n==="public"?"selected":"",onClick:()=>t("public"),children:[e($,{name:"globe",size:17}),e("span",{children:[e("strong",{children:"Public"}),e("small",{children:"Anyone with the link can read it. Search engines can index it."})]})]}),e("button",{type:"button",role:"radio","aria-checked":n==="private",class:n==="private"?"selected":"",onClick:()=>t("private"),children:[e($,{name:"lock",size:17}),e("span",{children:[e("strong",{children:"Private"}),e("small",{children:"Only people you invite in Doxbrix can open it."})]})]})]})}function ud({job:n,onCancel:t}){const i=n.lines.join(`
|
|
26
|
+
`),a=/Open (https?:\/\/\S+)/.exec(i)?.[1],s=/Enter code:\s*([A-Z0-9-]{4,})/.exec(i)?.[1],o=Number(/The code expires in (\d+) minute/.exec(i)?.[1]),l=o&&n.startedAt?new Date(Date.parse(n.startedAt)+o*6e4).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):"";return e("section",{class:"publish-hero",role:"status","aria-live":"polite",children:[e("div",{class:"publish-hero-head",children:[e("span",{class:"publish-mark","aria-hidden":"true",children:e($,{name:"rocket",size:22})}),e("div",{children:[e("h2",{children:"Approve the sign-in in your browser"}),e("p",{children:["Doxbrix opened in a new tab. Check that it shows this code, then choose ",e("strong",{children:"Approve"}),". This page continues by itself."]})]})]}),e("div",{class:"publish-code",children:[e("span",{class:"kicker",children:"Your code"}),e("code",{children:s??"…"}),e("span",{class:"publish-code-wait",children:[e("span",{class:"spinner"}),"Waiting for approval",l&&e(ie,{children:[" · the code works until ",l]})]})]}),e("div",{class:"publish-hero-foot",children:[e("span",{children:a?e(ie,{children:["Tab did not open? Go to ",e("a",{href:a,target:"_blank",rel:"noreferrer",children:a.replace(/^https?:\/\//,"")})]}):"Starting the sign-in…"}),e(_,{onClick:t,children:"Cancel sign-in"})]})]})}function pd({state:n,act:t,streamConnected:i,onError:a}){const s=n.effectiveDeployment,[o,l,c]=bi(()=>({...s,target:"doxbrix"}),JSON.stringify(s)),d=n.project?.deployment?.visibility,[m,r]=p(null),[g,u]=p(!1),[v,h]=p(!1),[y,P]=p(!1),k=n.account,C=!!k?.signedIn,w=n.jobs.find(q=>q.type.startsWith("deploy")&&q.status==="running"),I=!!(w||g),[L,D]=p(),E=w??$r(n.jobs,q=>q.type.startsWith("deploy"),L),A=n.jobs.find(q=>q.type==="login"),[j,W]=p(),O=A?.status==="running"?A:void 0,ue=!O&&!C?$r(n.jobs,q=>q.type==="login"&&q.status==="failed",j):void 0,ge=o.visibility==="public",fe=pa("/api/history/deployments?limit=25",q=>q.deployments??[],n.jobs,a),ye=pa("/api/history?limit=50",q=>q.requests??[],n.jobs,a),[ce,se]=p(null),G=n.jobs.filter(q=>q.type.startsWith("deploy")&&q.status!=="running").length;ae(()=>{if(!C)return;let q=!0;return _e("/api/deployment/site").then(ze=>{q&&se(ze.url)}).catch(()=>{}),()=>{q=!1}},[C,G]);const H=fe.entries.find(q=>q.status==="succeeded"&&q.target==="doxbrix"),N=H?.url,oe=ce??(N&&!N.includes("/editor?project=")?N:void 0),Ce=!!(oe&&H),ee=(()=>{try{if(!oe||!o.slug)return".sites.doxbrix.com";const q=new URL(oe).hostname;return q.startsWith(`${o.slug}.`)?q.slice(o.slug.length):".sites.doxbrix.com"}catch{return".sites.doxbrix.com"}})(),Q=oe?Nt(oe):`${o.slug} · address confirmed on first publish`,x=Ia(n.validation),B=ft(n.runs).filter(q=>St.includes(q.status)&&!q.archivedAt),F=x.ok?x.result.pages.length:0,T=x.ok?x.result.issues.filter(q=>q.severity==="error"):[],Z=[...x.ok?T.length===0?[{state:"ok",title:`${F} page${F===1?" passes":"s pass"} validation`,detail:"Links, navigation, and page names are publish-safe"}]:T.slice(0,3).map(q=>({state:"bad",title:q.code==="duplicate-page-name"?"Two pages share a name":`${q.file??"Documentation"} needs a fix`,detail:q.message,action:{label:"Open Docs",run:()=>sn("pages",q.file&&/\.mdx?$/.test(q.file)?{path:q.file}:{},"push")}})):[{state:"warn",title:"Validation has not finished",detail:x.reason}],B.length===0?{state:"ok",title:"Nothing waiting in Review",detail:"Every accepted change is included"}:{state:"warn",title:`${B.length} proposal${B.length===1?"":"s"} waiting in Review`,detail:"Publishing now leaves those changes out",action:{label:"Review changes",run:()=>sn("proposals",{proposal:B[0].id},"push")}},...ce&&!H&&!fe.loading?[{state:"warn",title:"This address already has a Doxbrix site",detail:`${Nt(ce)} was published from another workspace. Publishing replaces it; change the address to keep both.`,action:{label:"Change address",run:()=>h(!0)}}]:[]],Y=T.length>0||!x.ok,pe=H?Date.parse(H.startedAt):void 0,te=pe===void 0?[]:ye.entries.filter(q=>["applied","completed","partially-applied"].includes(q.status)&&Date.parse(q.finishedAt??q.createdAt)>pe&&q.pagesChanged>0),M=[...new Map(te.flatMap(q=>q.pages?.length?q.pages.filter(ze=>ze.decision!=="rejected").map(ze=>[ze.path,{path:ze.path,title:ze.title,changeKind:ze.changeKind}]):[[`request:${q.id}`,{path:Es(q.kind),title:ga(q),changeKind:"modified"}]])).values()],ne=E?.status==="failed"&&E.lines.some(q=>ji(q)),xe=()=>{t(()=>K("/api/auth/login",{apiUrl:o.apiUrl}),"Browser sign-in started")},Ie=async q=>{const ze={...o,visibility:q};return l(ze),t(()=>qn("/api/project",{deployment:ze}),void 0)},X=async()=>{if(!(I||Y||!C)){u(!0);try{const q=ge?"public":"private";if(!d&&await Ie(q)===void 0)return;await t(()=>K("/api/deploy",{...o,target:"doxbrix",visibility:q,public:q==="public",dryRun:!1}),"Publishing to Doxbrix")}finally{u(!1)}}},J=async()=>{await t(()=>qn("/api/project",{deployment:{...o,target:"doxbrix"}}),"Site settings saved")!==void 0&&h(!1)},Ae=q=>{if(q!==(ge?"public":"private")){if(Ce){r(q);return}d?Ie(q):l({...o,visibility:q})}},Be=()=>{oe&&navigator.clipboard?.writeText(oe).then(()=>{P(!0),setTimeout(()=>P(!1),1600)}).catch(()=>{})},ke=n.project?.title??"your documentation",Ke=`${F} page${F===1?"":"s"} · ${ge?"public":"private"}`,Je=e(Ue,{class:"publish-site",title:"Site",...v?{description:"Changes apply from the next publish."}:{},actions:v?e(ie,{children:[e(_,{size:"sm",tone:"ghost",onClick:()=>{c.resync(),h(!1)},children:"Cancel"}),e(_,{size:"sm",tone:"primary",icon:"check",onClick:()=>{J()},children:"Save"})]}):e(_,{size:"sm",onClick:()=>h(!0),children:"Change"}),children:v?e(ie,{children:[e(U,{label:"Site name",children:e(re,{value:o.name,onInput:q=>l({...o,name:q.currentTarget.value})})}),e(U,{label:"Address",hint:oe?"The part before the Doxbrix domain.":"Doxbrix may add your team as a prefix; the full address is shown after the first publish.",children:e("div",{class:"input-addon-row",children:[e(re,{class:"mono-input",value:o.slug,onInput:q=>l({...o,slug:q.currentTarget.value})}),e("span",{class:"input-addon",children:ee})]})})]}):e("div",{class:"vrows",children:[e("div",{class:"vrow",children:[e("span",{class:"vrow-label",children:"Address"}),e("span",{class:"vrow-value mono",children:Q})]}),e("div",{class:"vrow",children:[e("span",{class:"vrow-label",children:"Site name"}),e("span",{class:"vrow-value",children:o.name})]})]})});return e("div",{class:"publish-page publish-doxbrix",children:[m&&e("div",{class:"proposal-ready-scrim",role:"presentation",children:e("section",{class:"proposal-ready-dialog visibility-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"visibility-dialog-title",children:[e("button",{class:"proposal-ready-close",type:"button","aria-label":"Close",onClick:()=>r(null),children:e($,{name:"close",size:16})}),e("span",{class:"proposal-ready-icon",children:e($,{name:m==="public"?"globe":"lock",size:24})}),e("div",{children:[e("h2",{id:"visibility-dialog-title",children:["Make the site ",m,"?"]}),e("p",{children:[m==="public"?"Anyone with the link will be able to read it.":"Only people you invite in Doxbrix will be able to open it."," This applies from the next publish."]})]}),e("footer",{children:[e(_,{tone:"ghost",onClick:()=>r(null),children:"Cancel"}),e(_,{tone:"primary",icon:"check",onClick:()=>{const q=m;r(null),Ie(q)},children:["Make it ",m]})]})]})}),e(ht,{kicker:"Publish",title:"Publish",description:Ce?"Your documentation is live on Doxbrix.":"Your documentation, live on Doxbrix."}),c.stale&&e(xi,{onResync:c.resync}),!C&&(O?e(ud,{job:O,onCancel:()=>{t(()=>K(`/api/jobs/${O.id}/cancel`),"Sign-in cancelled")}}):e("section",{class:"publish-hero",children:[e("div",{class:"publish-hero-head",children:[e("span",{class:"publish-mark","aria-hidden":"true",children:e($,{name:"rocket",size:22})}),e("div",{children:[e("h2",{children:Ce?"Sign in to Doxbrix to publish changes":`Put ${ke} online`}),e("p",{children:"Doxbrix hosts your documentation with search, a reader assistant, and access control, free to start. Sign in once, choose who can read it, and publish."})]})]}),e("div",{class:"publish-connect",children:[e($,{name:"key",size:20}),e("span",{children:[e("strong",{children:"Connect your Doxbrix account"}),e("small",{children:k?.signedInElsewhere?.length?`You are signed in to ${k.signedInElsewhere.map(Nt).join(", ")}; this project publishes to ${Nt(k.apiUrl)}. That sign-in is kept.`:"Opens your browser. You approve once; the session stays on this computer."})]}),e(_,{tone:"primary",icon:"external",onClick:xe,children:"Sign in to Doxbrix"})]}),ue&&e(Te,{tone:"warn",children:e("span",{class:"note-body",children:[e("strong",{children:"Sign-in did not complete."})," ",$d(ue),e("span",{class:"note-actions",children:e(_,{size:"sm",onClick:()=>W(ue.id),children:"Dismiss"})})]})})]})),Ce&&e("section",{class:"publish-live","aria-label":"Live site",children:[e("div",{class:"publish-live-meta",children:[e(Me,{tone:"good",children:"Live"}),e("span",{children:[ge?"Public":"Private"," · published ",Ye(H.startedAt)]})]}),e("div",{class:"publish-live-address",children:[e("a",{class:"mono",href:oe,target:"_blank",rel:"noreferrer",children:Nt(oe)}),e(_,{icon:"copy","aria-label":"Copy site address",onClick:Be,children:y?"Copied":"Copy"}),e("a",{class:"btn primary md",href:oe,target:"_blank",rel:"noreferrer",children:[e($,{name:"external",size:16}),"Visit site"]})]}),e("div",{class:"publish-live-stats",children:[e("span",{children:[e($,{name:"file",size:15}),H.pagesCount??F," pages"]}),e("span",{children:[e($,{name:ge?"globe":"lock",size:15}),ge?"Anyone with the link":"Invited readers only"]}),e("span",{children:[e($,{name:"sparkle",size:15}),"Reader assistant included"]})]})]}),ne&&e("section",{class:"publish-attention",role:"alert",children:[e("span",{class:"publish-attention-icon",children:e($,{name:"key",size:18})}),e("div",{children:[e("h2",{children:"Doxbrix did not accept the saved sign-in"}),e("p",{children:"It expired, was revoked, or belongs to another Doxbrix server, so nothing was uploaded. Sign in again; your changes are still ready."})]}),e(_,{tone:"primary",icon:"key",onClick:xe,children:"Sign in again"})]}),E&&e(cd,{job:E,generator:n.project?.generator,act:t,streamConnected:i,siteUrl:oe,onDismiss:E.status==="running"?void 0:()=>D(E.id)}),C&&!Ce&&e("div",{class:"publish-account-row",children:[e("span",{class:"avatar",children:(k?.user?.name||k?.user?.email||"?").slice(0,2).toUpperCase()}),e("span",{class:"publish-account-identity",children:[e("strong",{children:"Signed in to Doxbrix"}),e("small",{children:k?.user?.email})]}),e(_,{size:"sm",tone:"ghost",icon:"logout",onClick:()=>{t(()=>K("/api/auth/logout"),"Signed out")},children:"Switch account"})]}),Ce&&M.length>0&&e(Ue,{class:"publish-changes",title:"Changes since the last publish",description:"Saved or accepted since then, not yet on the live site.",actions:e(Me,{tone:"warn",children:[M.length," page",M.length===1?"":"s"]}),flush:!0,children:e("ul",{class:"publish-change-list",children:M.slice(0,8).map(q=>e("li",{children:[e("code",{children:q.changeKind==="added"?"A":q.changeKind==="deleted"?"D":"M"}),e("span",{children:q.title||q.path}),e("small",{children:q.path})]},q.path))})}),e(Ue,{class:"publish-ready",title:Ce?"Before the next publish":"Ready to publish",description:"Doxloop checks everything before it uploads.",flush:!0,children:e(dd,{checks:Z})}),!Ce&&e(Ue,{class:"publish-visibility-panel",title:"Who can read it",description:"You can change this later; it applies from the next publish.",children:e(Cr,{value:ge?"public":"private",onChange:Ae})}),!Ce&&Je,e("div",{class:"publish-bar",children:[e("span",{children:[e("strong",{children:Ce?M.length?`${M.length} changed page${M.length===1?"":"s"} to publish`:"The live site is up to date":Ke}),e("small",{children:C?Y?"Fix the checks above to publish.":"Usually live in under a minute.":"Sign in to Doxbrix to publish."})]}),e(_,{class:"publish-deploy-button",tone:"primary",icon:"publish",busy:I,disabled:!C||Y||I,onClick:()=>{X()},children:Ce?M.length?`Publish ${M.length} change${M.length===1?"":"s"}`:"Publish again":"Publish to Doxbrix"})]}),Ce&&e("details",{class:"publish-settings",children:[e("summary",{children:[e($,{name:"settings",size:15}),"Site settings",e("small",{children:[Q," · ",ge?"public":"private"]})]}),e("div",{class:"publish-settings-body",children:[e(Ue,{class:"publish-visibility-panel",title:"Who can read it",children:e(Cr,{value:ge?"public":"private",onChange:Ae})}),Je,C&&e("div",{class:"publish-account-row",children:[e("span",{class:"avatar",children:(k?.user?.name||k?.user?.email||"?").slice(0,2).toUpperCase()}),e("span",{class:"publish-account-identity",children:[e("strong",{children:"Signed in to Doxbrix"}),e("small",{children:k?.user?.email})]}),e(_,{size:"sm",tone:"ghost",icon:"logout",onClick:()=>{t(()=>K("/api/auth/logout"),"Signed out")},children:"Sign out"})]})]})]}),e(Ue,{class:"history-panel",title:"History",flush:!0,children:e(Xc,{...fe})})]})}const xr=[["general","General","Project identity and defaults","settings"],["experience","Audience and voice","Writing style and accessibility","book"],["capture","Screenshots","Application screenshots","preview"],["branding","Branding","Logo, colours, and fonts","sparkle"],["tools","Generator","Active documentation generator","publish"],["monitoring","Monitoring","Schedule and budgets","bell"]],_r={requested:"Only when requested",auto:"Automatically for UI workflows",off:"Never"},Sr={beginner:"Beginner",intermediate:"Intermediate",advanced:"Advanced",mixed:"Mixed"};function hd({state:n,act:t,onError:i}){const a=n.project,o=xa().get("section"),l=xr.some(([M])=>M===o)?o:"general",c=M=>sn("settings",{section:M}),[d,m,r]=bi(()=>({title:a.title,defaultAgent:a.defaultAgent??"",defaultModel:a.defaultModel??""}),JSON.stringify([a.title,a.defaultAgent,a.defaultModel])),[g,u,v]=bi(()=>({...a.documentation,audiencesText:a.documentation.audiences?.join(", ")??"",customInstructions:a.documentation.customInstructions??"",outcomesText:a.documentation.priorityOutcomes?.join(`
|
|
27
|
+
`)??"",preferredExamplesText:a.documentation.preferredExamples?.join(", ")??"",toneText:a.documentation.tone.join(", "),exclusionsText:a.documentation.exclusions.join(`
|
|
28
|
+
`),terms:rc(a.documentation.terminology)}),JSON.stringify(a.documentation)),[h,y,P]=bi(()=>({baseUrl:a.application?.baseUrl??"",source:a.application?.source??"",readyPath:a.application?.readyPath??"",policy:a.application?.screenshots?.policy??"requested",highlight:a.application?.screenshots?.highlight??!0,startPath:a.application?.screenshots?.startPath??"/",workflow:a.application?.screenshots?.workflow??"",viewportWidth:String(a.application?.screenshots?.viewport?.width??1440),viewportHeight:String(a.application?.screenshots?.viewport?.height??900),loginPath:a.application?.authentication?.loginPath??""}),JSON.stringify(a.application??null)),[k,C]=p(),[w,I]=p(!1),[L,D]=p(null),[E,A]=p(null),[j,W]=p(!1),[O,ue]=p(),ge=!!a.application;ae(()=>{if(!ge){ue(void 0);return}let M=!0;return _e("/api/application/auth").then(ne=>{M&&ue(ne)}).catch(()=>{}),()=>{M=!1}},[ge,L]);const fe={baseUrl:h.baseUrl,source:h.source,readyPath:h.readyPath,screenshots:{policy:h.policy,highlight:h.highlight,viewport:{width:h.viewportWidth,height:h.viewportHeight},startPath:h.startPath,workflow:h.workflow},authentication:{loginPath:h.loginPath}},ye=async()=>{I(!0);try{C(await K("/api/application/readiness",fe))}catch{C(void 0)}finally{I(!1)}},ce=()=>t(()=>qn("/api/project",d),"Identity settings saved"),se=()=>t(()=>qn("/api/project",{documentation:{...g,audiences:In(g.audiencesText),priorityOutcomes:Tr(g.outcomesText),preferredExamples:In(g.preferredExamplesText),tone:In(g.toneText),exclusions:g.exclusionsText.split(`
|
|
29
|
+
`).map(M=>M.trim()).filter(Boolean),terminology:pr(g.terms)}}),"Documentation preferences saved"),G=()=>t(()=>qn("/api/project",{application:fe}),"Application settings saved"),H=JSON.stringify(pr(g.terms))!==JSON.stringify(a.documentation.terminology),N=M=>{A({identity:d,docs:g,application:h}),D(M)},oe=()=>{E&&(m(E.identity),u(E.docs),y(E.application)),D(null)},[Ce,ee]=p(!1),Q=async M=>{ee(!0);try{await M()!==void 0&&D(null)}finally{ee(!1)}},x=d.defaultAgent?`${On(d.defaultAgent)}${d.defaultModel?` · ${d.defaultModel}`:""}`:"Choose per run",B=(M,ne=3)=>M.length===0?"":M.length<=ne?M.join(", "):`${M.slice(0,ne).join(", ")} · ${M.length-ne} more`,F=n.generators.find(M=>M.id===a.generator),T=a.sync,Z=[T.budget?.maxMinutes?`${T.budget.maxMinutes} min`:"",T.budget?.maxRunsPerDay?`${T.budget.maxRunsPerDay} runs per day`:"",T.budget?.maxUsd?`$${T.budget.maxUsd.toFixed(2)} cap`:""].filter(Boolean).join(" · "),Y=(M,ne,xe,Ie)=>e(U,{label:M,...Ie?{hint:Ie}:{},children:e(re,{value:g[ne]??"",...xe?{placeholder:xe}:{},onInput:X=>u({...g,[ne]:X.currentTarget.value})})}),te=(()=>{switch(L){case"title":return{title:"Site title",save:ce,body:e(U,{label:"Site title",children:e(re,{value:d.title,onInput:M=>m({...d,title:M.currentTarget.value})})})};case"agent":return{title:"Default coding agent",save:ce,body:e(ie,{children:[e(U,{label:"Default documentation agent",children:e(Fe,{value:d.defaultAgent,onChange:M=>{const ne=M.currentTarget.value;m({...d,defaultAgent:ne,defaultModel:ne===d.defaultAgent?d.defaultModel:It(ne)})},children:[e("option",{value:"",children:"Choose per run"}),e("option",{value:"codex",children:"Codex"}),e("option",{value:"claude",children:"Claude Code"}),e("option",{value:"gemini",children:"Gemini"})]})}),e(U,{label:"Default model",hint:d.defaultAgent?`Used by ${On(d.defaultAgent)} runs unless a run picks another model. Search suggested models or enter another model ID.`:"Choose a default agent to set its model.",children:e(it,{value:d.defaultModel,options:Pt(d.defaultAgent).map(M=>[M.id,M.label]),disabled:!d.defaultAgent,placeholder:"Agent default",onValueChange:M=>m({...d,defaultModel:M})})}),e("details",{class:"agent-capabilities-details",open:d.defaultAgent==="gemini",children:[e("summary",{children:"What each assistant supports"}),e(as,{selected:d.defaultAgent||void 0})]})]})};case"primaryAudience":return{title:"Primary audience",save:se,body:Y("Primary audience","primaryAudience","Developers integrating our API")};case"audiences":return{title:"Audiences",save:se,body:Y("Audiences","audiencesText","Developers, API consumers, administrators","Separate multiple audiences with commas")};case"experienceLevel":return{title:"Experience level",save:se,body:e(U,{label:"Experience level",children:e(Fe,{value:g.experienceLevel??"intermediate",onChange:M=>u({...g,experienceLevel:M.currentTarget.value}),children:Object.entries(Sr).map(([M,ne])=>e("option",{value:M,children:ne},M))})})};case"locale":return{title:"Locale",save:se,body:Y("Locale","locale","en-US")};case"accessibilityTarget":return{title:"Accessibility target",save:se,body:Y("Accessibility target","accessibilityTarget","WCAG 2.2 AA")};case"tone":return{title:"Tone",save:se,body:Y("Tone","toneText","clear, direct, helpful","Separate several qualities with commas")};case"outcomes":return{title:"Priority outcomes",save:se,body:e(U,{label:"Priority outcomes",hint:"What readers must be able to do, one outcome per line.",children:e(en,{rows:5,value:g.outcomesText??"",placeholder:`Install the product and send the first request
|
|
30
|
+
Diagnose and fix common errors`,onInput:M=>u({...g,outcomesText:M.currentTarget.value})})})};case"preferredExamples":return{title:"Preferred examples",save:se,body:Y("Preferred examples","preferredExamplesText","TypeScript, curl","Languages and tools examples are written in")};case"designDirection":return{title:"Design direction",save:se,body:Y("Design direction","designDirection","Compact, task-led developer documentation")};case"standardsProfile":return{title:"Standards profile",save:se,body:Y("Standards profile","standardsProfile")};case"styleGuide":return{title:"Style guide",save:se,body:Y("Style guide","styleGuide")};case"terms":return{title:"Preferred terminology",save:se,body:e(U,{label:"Preferred terminology",hint:"Product vocabulary with its meaning or preferred wording. Feeds every run and the glossary page.",wide:!0,children:e(ac,{value:g.terms,onChange:M=>u({...g,terms:M})})})};case"exclusions":return{title:"Content exclusions",save:se,body:e(U,{label:"Content exclusions",hint:"One item per line",children:e(en,{rows:6,value:g.exclusionsText,onInput:M=>u({...g,exclusionsText:M.currentTarget.value})})})};case"instructions":return{title:"Instructions",save:se,body:e(U,{label:"Instructions",hint:"Additional guidance reused for future documentation runs",wide:!0,children:e(en,{rows:8,value:g.customInstructions,placeholder:"Use concise explanations and include TypeScript examples.",onInput:M=>u({...g,customInstructions:M.currentTarget.value})})})};case"applicationUrl":return{title:"Application URL",save:G,disabled:!h.baseUrl,body:e(ie,{children:[e(U,{label:"Application base URL",hint:"A safe local or test instance of the product; screenshots are taken there.",children:e(re,{value:h.baseUrl,placeholder:"http://localhost:3000",onInput:M=>y({...h,baseUrl:M.currentTarget.value})})}),e(U,{label:"Product source",hint:"The connected source this application is built from.",children:e(Fe,{value:h.source,onChange:M=>y({...h,source:M.currentTarget.value}),children:[e("option",{value:"",children:"None"}),a.sources.map(M=>e("option",{value:M.name,children:M.name},M.name))]})}),e(U,{label:"Ready path",hint:"A path that answers once the application is up, for example /health.",children:e(re,{value:h.readyPath,placeholder:"/health",onInput:M=>y({...h,readyPath:M.currentTarget.value})})}),e(U,{label:"Default starting route",hint:"Where capture sessions begin.",children:e(re,{value:h.startPath,placeholder:"/settings/team",onInput:M=>y({...h,startPath:M.currentTarget.value})})})]})};case"signIn":return{title:"Sign-in",save:G,disabled:!h.baseUrl,body:e(ie,{children:[e(U,{label:"Sign-in route",hint:"Where the browser sign-in opens; leave empty when the app redirects to its login page",children:e(re,{value:h.loginPath,placeholder:"/login",onInput:M=>y({...h,loginPath:M.currentTarget.value})})}),e(gd,{embedded:!0,application:fe,configured:ge,onError:i,onChanged:()=>C(void 0)})]})};case"screenshotPolicy":return{title:"Screenshot policy",save:G,disabled:!h.baseUrl,body:e(ie,{children:[e(U,{label:"Screenshot policy",children:e(Fe,{value:h.policy,onChange:M=>y({...h,policy:M.currentTarget.value}),children:Object.entries(_r).map(([M,ne])=>e("option",{value:M,children:ne},M))})}),e(U,{label:"Capture workflow guidance",hint:"Safe test state, authentication, actions, and expected outcomes",wide:!0,children:e(en,{rows:5,value:h.workflow,placeholder:"Reuse the signed-in demo workspace and synthetic data only.",onInput:M=>y({...h,workflow:M.currentTarget.value})})})]})};case"viewport":return{title:"Viewport",save:G,disabled:!h.baseUrl,body:e(ie,{children:[e(U,{label:"Viewport width",children:e(re,{type:"number",min:"320",max:"3840",value:h.viewportWidth,onInput:M=>y({...h,viewportWidth:M.currentTarget.value})})}),e(U,{label:"Viewport height",children:e(re,{type:"number",min:"320",max:"2160",value:h.viewportHeight,onInput:M=>y({...h,viewportHeight:M.currentTarget.value})})}),e(jt,{checked:h.highlight,onChange:M=>y({...h,highlight:M}),label:"Highlight captured controls"})]})};default:return null}})();return e(ie,{children:[e(ht,{kicker:"Settings",title:"Settings",description:"Choose a row to change it. Nothing is saved until you choose Save."}),e("div",{class:"settings",children:[e("nav",{class:"settings-nav","aria-label":"Settings sections",children:xr.map(([M,ne,xe,Ie])=>e("button",{class:l===M?"active":"","aria-pressed":l===M,onClick:()=>c(M),children:[e($,{name:Ie,size:16}),e("span",{children:[e("strong",{children:ne}),e("small",{children:xe})]})]},M))}),e("div",{class:"stack",children:[l==="general"&&e(ie,{children:[r.stale&&e(xi,{onResync:r.resync}),e(Ue,{title:"Project identity",flush:!0,children:e("div",{class:"vrows",children:[e(We,{label:"Site title",value:d.title,onOpen:()=>N("title")}),e(We,{label:"Default coding agent",value:x,onOpen:()=>N("agent")}),e(We,{label:"Content directory",value:e("code",{children:a.contentDir||"Project root"})}),e(We,{label:"Documentation generator",value:Sd(n.generators,a.generator),onOpen:()=>c("tools")}),e(We,{label:"Project folder",value:e("code",{children:n.root??n.cwd})})]})})]}),l==="experience"&&e(ie,{children:[v.stale&&e(xi,{onResync:v.resync}),e(Ue,{title:"Audience and voice",flush:!0,children:e("div",{class:"vrows",children:[(g.primaryAudience??"").trim()&&(g.primaryAudience??"").trim()!==In(g.audiencesText).join(", ")&&e(We,{label:"Primary audience",value:g.primaryAudience??"",onOpen:()=>N("primaryAudience")}),e(We,{label:"Audiences",value:B(In(g.audiencesText)),onOpen:()=>N("audiences")}),e(We,{label:"Experience level",value:Sr[g.experienceLevel??"intermediate"]??g.experienceLevel??"",onOpen:()=>N("experienceLevel")}),e(We,{label:"Locale",value:g.locale,onOpen:()=>N("locale")}),e(We,{label:"Accessibility target",value:g.accessibilityTarget,onOpen:()=>N("accessibilityTarget")}),e(We,{label:"Tone",value:B(In(g.toneText)),onOpen:()=>N("tone")}),e(We,{label:"Priority outcomes",value:B(Tr(g.outcomesText)),onOpen:()=>N("outcomes")}),e(We,{label:"Preferred examples",value:B(In(g.preferredExamplesText)),onOpen:()=>N("preferredExamples")}),e(We,{label:"Design direction",value:g.designDirection??"",onOpen:()=>N("designDirection")}),e(We,{label:"Standards profile",value:g.standardsProfile,onOpen:()=>N("standardsProfile")}),e(We,{label:"Style guide",value:g.styleGuide,onOpen:()=>N("styleGuide")}),e(We,{label:"Preferred terminology",value:B(g.terms.map(M=>M.term)),onOpen:()=>N("terms")}),e(We,{label:"Content exclusions",value:B(g.exclusionsText.split(`
|
|
31
|
+
`).map(M=>M.trim()).filter(Boolean),2),onOpen:()=>N("exclusions")}),e(We,{label:"Instructions",value:g.customInstructions,onOpen:()=>N("instructions")})]})}),e(sc,{act:t,onError:i,unsavedTerms:H,onOpenPage:M=>sn("pages",{path:M},"push")})]}),l==="branding"&&e(nc,{act:t,onError:i,...n.preview?.running&&n.preview.url?{previewUrl:n.preview.url}:{},onPreviewStart:()=>K("/api/preview/start",{open:!1}).then(M=>M.url).catch(M=>{i(wn(M))})}),l==="capture"&&e(ie,{children:[P.stale&&e(xi,{onResync:P.resync}),e(Ue,{title:"Application screenshots",flush:!0,actions:e(_,{size:"sm",disabled:!h.baseUrl,busy:w,onClick:()=>{ye()},children:"Test application"}),...ge?{footer:e(_,{size:"sm",tone:"danger",onClick:()=>{t(()=>qn("/api/project",{application:null}),"Application configuration removed")},children:"Remove application"})}:{},children:e("div",{class:"vrows",children:[k&&e("div",{class:"vrow",children:[e("span",{class:"vrow-label",children:[k.status==="ready"?"Application reachable":k.status==="authentication-required"?"Sign-in needed":"Application not reachable",e("small",{children:k.message})]}),e("span",{class:"vrow-value",children:e(Me,{tone:k.status==="ready"?"good":"warn",children:k.status==="ready"?"Reachable":"Check"})})]}),e(We,{label:"Application URL",value:h.baseUrl?e("code",{children:h.baseUrl}):"",sub:h.source?`Built from ${h.source}`:void 0,onOpen:()=>N("applicationUrl")}),e(We,{label:"Sign-in",value:O?.session?e(Me,{tone:"good",children:["Session saved ",Ye(O.session.savedAt)]}):O?.credentials?e(Me,{tone:"good",children:["Credentials for ",O.credentials.username]}):h.loginPath?e("code",{children:h.loginPath}):"Not set up",onOpen:()=>N("signIn")}),e(We,{label:"Screenshot policy",value:_r[h.policy]??h.policy,onOpen:()=>N("screenshotPolicy")}),e(We,{label:"Viewport",value:`${h.viewportWidth} × ${h.viewportHeight}${h.highlight?" · highlight captured controls":""}`,onOpen:()=>N("viewport")})]})})]}),l==="tools"&&e(Ue,{title:"Documentation generator",flush:!0,children:e("div",{class:"vrows",children:[e(We,{label:"Generator",value:e(ie,{children:[F?.displayName??a.generator,e(Me,{tone:"good",children:"Active"})]})}),e(We,{label:"Package",value:F?.id==="doxbrix"?"Built in":e("code",{children:F?.packageName??a.generator})}),F?.tierLabel&&e(We,{label:"Tier",sub:F.tierDescription,value:`${F.tierLabel}${F.toolchainLabels?.length?` · ${F.toolchainLabels.join(", ")}`:""}`})]})}),l==="monitoring"&&e(Ue,{title:"Monitoring",flush:!0,actions:e(_,{size:"sm",icon:"bell",onClick:()=>W(!0),children:"Configure"}),children:e("div",{class:"vrows",children:[e(We,{label:"Schedule",value:T.on.length?Ei(Kt(T.on)):"Not configured",onOpen:()=>W(!0)}),e(We,{label:"Product branch",value:T.branch??"",onOpen:()=>W(!0)}),e(We,{label:"Budgets",value:Z||"No limits",onOpen:()=>W(!0)}),e(We,{label:"Re-verify after",value:T.maxVerificationAgeDays?`${T.maxVerificationAgeDays} days · ${T.maxVerificationAgeSeverity==="fail"?"fail validation":"warn"}`:"Only on source changes",onOpen:()=>W(!0)}),e(We,{label:"Watched paths",value:T.watch.length?B(T.watch,2):"Everything",sub:T.ignore.length?`${T.ignore.length} ignored`:void 0,onOpen:()=>W(!0)})]})})]})]}),j&&e(Os,{state:n,act:t,onClose:()=>W(!1)}),L&&te&&e(Us,{class:"settings-sheet",title:te.title,onClose:oe,footer:e(ie,{children:[e(_,{tone:"ghost",onClick:oe,children:"Cancel"}),e(_,{tone:"primary",busy:Ce,disabled:te.disabled,onClick:()=>{Q(te.save)},children:"Save"})]}),children:te.body})]})}function We({label:n,value:t,sub:i,onOpen:a}){const o=e(ie,{children:[e("span",{class:"vrow-label",children:[n,i&&e("small",{children:i})]}),e("span",{class:"vrow-value",children:[t===""||t===void 0||t===null?e("em",{children:"Not set"}):typeof t=="string"?e("span",{class:"value-text",children:t}):t,a&&e($,{name:"chevronRight",size:16})]})]});return a?e("button",{type:"button",class:"vrow settings-row",onClick:a,children:o}):e("div",{class:"vrow settings-row static",children:o})}function gd({application:n,configured:t,onError:i,onChanged:a,embedded:s}){const[o,l]=p(),[c,d]=p(""),[m,r]=p({username:"",password:""}),g=async()=>{try{l(await _e("/api/application/auth"))}catch(y){i(wn(y))}};ae(()=>{t&&g()},[t]),ae(()=>{if(!o?.signIn.active)return;const y=setInterval(()=>{g()},2e3);return()=>clearInterval(y)},[o?.signIn.active]);const u=async(y,P)=>{d(y);try{l(await P()),a()}catch(k){i(wn(k))}finally{d("")}},v=o?.signIn,h=e(ie,{children:[!t&&e(Te,{children:"Save the application settings first. Sign-in details are stored on this computer against the project, never in the repository."}),e("div",{class:"capture-signin",children:[e("section",{class:"capture-signin-block",children:[e("header",{children:[e("strong",{children:"Recorded browser session"}),e("small",{children:"Sign in by hand in a Chrome window Doxloop opens, including MFA, SSO, or passkeys. The signed-in cookies and local storage are loaded into every capture run."})]}),o?.session?e("div",{class:"plan-capture-readiness ready",children:[e($,{name:"check",size:15}),e("span",{children:[e("strong",{children:["Session saved ",Ye(o.session.savedAt)]}),e("small",{children:[o.session.origin," · ",o.session.cookies," cookie",o.session.cookies===1?"":"s"," · ",o.session.origins," storage origin",o.session.origins===1?"":"s",". Sign in again when the application reports the session expired."]})]})]}):o&&e("div",{class:"plan-capture-readiness missing",children:[e($,{name:"info",size:15}),e("span",{children:[e("strong",{children:"No session recorded"}),e("small",{children:"Screenshots of signed-in screens need a session or credentials."})]})]}),v?.active&&e(Te,{tone:v.open?"info":"warn",children:e("span",{children:v.open?e(ie,{children:["A Chrome window is open at ",v.url,". Complete the sign-in there, wait for the signed-in screen, then choose ",e("strong",{children:"Save session"}),"."]}):e(ie,{children:["The Chrome window was closed. Choose ",e("strong",{children:"Save session"})," to keep the last signed-in state, or start again."]})})}),e("div",{class:"form-actions start",children:v?.active?e(ie,{children:[e(_,{busy:c==="cancel",onClick:()=>{u("cancel",()=>K("/api/application/sign-in/cancel"))},children:"Cancel"}),e(_,{tone:"primary",icon:"check",busy:c==="finish",onClick:()=>{u("finish",()=>K("/api/application/sign-in/finish"))},children:"Save session"})]}):e(ie,{children:[o?.session&&e(_,{tone:"danger",busy:c==="forget",onClick:()=>{u("forget",()=>sa("/api/application/session"))},children:"Forget session"}),e(_,{icon:"preview",disabled:!n.baseUrl,busy:c==="start",onClick:()=>{u("start",()=>K("/api/application/sign-in",n))},children:o?.session?"Sign in again with browser":"Sign in with browser"})]})})]}),e("section",{class:"capture-signin-block",children:[e("header",{children:[e("strong",{children:"Sign-in credentials"}),e("small",{children:"For a plain username and password form. The agent fills the form by secret name; the capture server substitutes the values and redacts them from every result. Use a test account, never a production one."})]}),o?.credentials&&e("div",{class:"plan-capture-readiness ready",children:[e($,{name:"check",size:15}),e("span",{children:[e("strong",{children:["Credentials saved for ",o.credentials.username]}),e("small",{children:["Saved ",Ye(o.credentials.savedAt),". Enter new values below to replace them."]})]})]}),e(U,{label:"Username or email",children:e(re,{value:m.username,autocomplete:"off",placeholder:"docs-demo@example.com",onInput:y=>r({...m,username:y.currentTarget.value})})}),e(U,{label:"Password",children:e(re,{type:"password",value:m.password,autocomplete:"new-password",placeholder:"••••••••",onInput:y=>r({...m,password:y.currentTarget.value})})}),e("div",{class:"form-actions start",children:[o?.credentials&&e(_,{tone:"danger",busy:c==="remove",onClick:()=>{u("remove",()=>sa("/api/application/credentials"))},children:"Remove credentials"}),e(_,{disabled:!t||!m.username.trim()||!m.password,busy:c==="save",onClick:()=>{u("save",async()=>{const y=await gt("/api/application/credentials",m);return r({username:"",password:""}),y})},children:"Save credentials"})]})]})]})]});return s?e("div",{class:"capture-signin-embedded",children:h}):e(Ue,{title:"Application sign-in",description:"Let the capture browser past a login page without sharing secrets with the agent or the project.",children:h})}function xi({onResync:n}){return e("div",{class:"stale-form-notice",role:"status",children:[e($,{name:"info",size:14}),e("span",{children:"These settings changed elsewhere while you were editing. Your unsaved edits are still here."}),e(_,{size:"sm",onClick:n,children:"Load the saved values"})]})}function Us({title:n,description:t,onClose:i,footer:a,children:s,class:o}){return ae(()=>{const l=c=>{c.key==="Escape"&&i()};return addEventListener("keydown",l),()=>removeEventListener("keydown",l)},[i]),e("div",{class:"sources-modal-scrim ops-sheet-scrim",onClick:i,children:e("section",{class:`ops-sheet ${o??""}`,role:"dialog","aria-modal":"true","aria-label":n,onClick:l=>l.stopPropagation(),children:[e("header",{class:"ops-sheet-head",children:[e("div",{children:[e("h2",{children:n}),t&&e("p",{children:t})]}),e("button",{type:"button",class:"ops-icon-button","aria-label":"Close",onClick:i,children:e($,{name:"close",size:16})})]}),e("div",{class:"ops-sheet-body",children:s}),a&&e("footer",{class:"ops-sheet-foot",children:a})]})})}const St=["awaiting-review","partially-applied","conflicted"],fd=30*6e4;function $r(n,t,i,a=Date.now()){const s=n.find(t);if(!s||s.status==="running"||s.id===i)return;const o=Date.parse(s.finishedAt??s.startedAt);if(!(Number.isFinite(o)&&a-o>fd))return s}function Vn(n){return["applied","accepted","approved","generated","succeeded","pass","added"].includes(n)?"good":["awaiting-review","ready-for-review","planning","revising","generating","pending","running","modified"].includes(n)?"info":["needs-input","stale","partially-applied","conflicted"].includes(n)?"warn":["rejected","failed","error","deleted"].includes(n)?"bad":"neutral"}function Kn(n){if(n==="awaiting-review")return"Awaiting review";const t=n.replaceAll("-"," ").replaceAll("_"," ");return t.charAt(0).toUpperCase()+t.slice(1)}function md({message:n}){const t=[...new Set(n.match(/assets\/[^\s;=,]+?\.(?:png|jpe?g|webp)/g)??[])];if(t.length<3)return e(ie,{children:n});const i=n.replace(/:\s*assets\/[\s\S]*\.(?:png|jpe?g|webp)\.?/,".").replace(/\s+/g," ").trim();return e(ie,{children:[i,e("details",{class:"screenshot-message-paths",children:[e("summary",{children:["Show ",t.length," image",t.length===1?"":"s"]}),e("ul",{children:t.map(a=>e("li",{children:e("code",{children:a})},a))})]})]})}function wn(n){return n instanceof Error?n.message:String(n)}function vd(n,t){const i=n.toLowerCase();return i.includes("github.com")?"GitHub":i.includes("gitlab.com")?"GitLab":i.includes("dev.azure.com")||i.includes("visualstudio.com")?"Azure DevOps":i.includes("bitbucket.org")?"Bitbucket":"Git"}function ft(n){return Array.isArray(n)?n:[]}function zi(n){return!!(n&&typeof n=="object"&&typeof n.error=="string")}function Ia(n){return n?zi(n)||!Array.isArray(n.pages)?{ok:!1,reason:`Validation could not run: ${zi(n)?n.error:"unexpected response"}`}:{ok:!0,result:{...n,issues:Array.isArray(n.issues)?n.issues:[]}}:{ok:!1,reason:"Validation has not run yet."}}function Pr(n){return n.errors>0?`${n.errors} validation error${n.errors===1?"":"s"}${n.warnings>0?` and ${n.warnings} warning${n.warnings===1?"":"s"}`:""}`:n.warnings>0?`${n.warnings} validation warning${n.warnings===1?"":"s"}`:"Documentation validates cleanly"}function bd(n){return n?zi(n)||!Array.isArray(n.pages)?{ok:!1,reason:`Freshness could not be checked: ${zi(n)?n.error:"unexpected response"}`}:{ok:!0,drift:n}:{ok:!1,reason:"Freshness has not been checked yet."}}function yd(n,t){if(n?.length)return n.find(i=>i.name===t&&i.executable)??n.find(i=>i.preferred&&i.executable)??n.find(i=>i.executable)}function Bs(n){return n==="authenticated"?"authenticated":n==="unauthenticated"||n==="missing"?"unauthenticated":"unknown"}function wd(n){const t=Bs(n);return t==="authenticated"?"signed in":t==="unauthenticated"?"signed out":"sign-in not checked"}function kd(n){return n==="claude"?"Run `claude auth login` in a terminal, or choose another assistant.":n==="codex"?"Run `codex login` in a terminal, or choose another assistant.":n==="gemini"?"Run `gemini` in a terminal and sign in, or choose another assistant.":"Sign it in from a terminal, or choose another assistant."}function Cd(n){return n==="authenticated"?"is signed in":n==="unauthenticated"||n==="missing"?"needs sign-in":n==="unknown"?"sign-in unknown":n.replaceAll("-"," ")}function xd(n){return(n.split("/").pop()?.replace(/\.(mdx?|md)$/i,"")??n).replace(/[-_]+/g," ").replace(/^\w/,i=>i.toUpperCase())}function Qt(n){return(n.mintlifyImport?.pageCount??0)>0||n.receipt?.completedAt?!0:ft(n.runs).some(t=>t.status==="applied"||t.status==="partially-applied")}function Ir(n){const t=n.documentationPlan;if(!t||t.status==="cancelled")return!0;if(t.status!=="generated")return!1;const i=t.proposalId?ft(n.runs).find(a=>a.id===t.proposalId):void 0;return i?!St.includes(i.status):!1}const js=[["mon","Monday"],["tue","Tuesday"],["wed","Wednesday"],["thu","Thursday"],["fri","Friday"],["sat","Saturday"],["sun","Sunday"]];function Kt(n){const t=n[0]??"",i={kind:"daily",time:"09:00",weekday:"mon",day:1,interval:1,unit:"h"};let a=/^daily@(\d{2}:\d{2})$/.exec(t);return a?{...i,time:a[1]}:(a=/^weekdays@(\d{2}:\d{2})$/.exec(t),a?{...i,kind:"weekdays",time:a[1]}:(a=/^weekly@(sun|mon|tue|wed|thu|fri|sat)@(\d{2}:\d{2})$/.exec(t),a?{...i,kind:"weekly",weekday:a[1],time:a[2]}:(a=/^monthly@(\d{1,2})@(\d{2}:\d{2})$/.exec(t),a?{...i,kind:"monthly",day:Number(a[1]),time:a[2]}:(a=/^every@(\d+)([mh])$/.exec(t),a?{...i,kind:"custom",interval:Number(a[1]),unit:a[2]}:i))))}function Ar(n){return n.kind==="weekdays"?`weekdays@${n.time}`:n.kind==="weekly"?`weekly@${n.weekday}@${n.time}`:n.kind==="monthly"?`monthly@${n.day}@${n.time}`:n.kind==="custom"?`every@${n.interval}${n.unit}`:`daily@${n.time}`}function Ei(n){const t=_d(n.time);return n.kind==="weekdays"?`Every weekday at ${t}`:n.kind==="weekly"?`Every ${js.find(([i])=>i===n.weekday)?.[1]??"Monday"} at ${t}`:n.kind==="monthly"?`Day ${n.day} of every month at ${t}`:n.kind==="custom"?`Every ${n.interval} ${n.unit==="m"?"minute":"hour"}${n.interval===1?"":"s"}`:`Every day at ${t}`}function _d(n){const[t=0,i=0]=n.split(":").map(Number),a=t>=12?"PM":"AM";return`${t%12||12}:${String(i).padStart(2,"0")} ${a}`}function ea(n,t,i){return Math.min(i,Math.max(t,Number(n)||t))}function na(n,t,i){const a={...n},s=Number(i);return s>0?a[t]=s:delete a[t],a}function Sd(n,t){return n.find(i=>i.id===t)?.displayName??t}function On(n){return n==="claude"?"Claude Code":n==="codex"?"Codex":"Gemini"}function Tr(n){return(n??"").split(`
|
|
32
|
+
`).map(t=>t.trim()).filter(Boolean)}function $d(n){const t=Bi(n);return t&&/authori[sz]ation expired|expired_token|code expired/i.test(t)?"The sign-in code expired before it was approved. Choose Sign in with browser to get a new code.":t&&/access_denied|denied/i.test(t)?"The sign-in was declined in the browser. Choose Sign in with browser to try again.":t?.replace(/\s*Run `doxloop login` again\.?/," Choose Sign in with browser to try again.")??"The sign-in stopped before an account was connected. Try again."}function Fs(n){return ji(n)?"Doxbrix did not accept the saved sign-in. Sign in again, then redeploy.":n}function Nt(n){try{return new URL(n).host}catch{return n}}function ji(n){return/\b401\b.*unauthori[sz]ed|authentication required|provide a dxb_token/i.test(n)}function Pd(){const[n,t]=p(null),[i,a]=p(""),[s,o]=p(!0),[l,c]=p(!1),d=async()=>{o(!0);try{t(await _e("/api/state")),a("")}catch(r){a(Rr(r))}finally{o(!1)}};ae(()=>{d()},[]);const m=async(r,g,u=!0)=>{a("");try{const v=await r();return u&&await d(),v}catch(v){a(Rr(v));return}};return!n&&s?e(Dr,{}):n?!n.projectFound||l?e(Qa,{onReset:()=>{d()},children:e(nl,{state:n,act:m,error:i,onContinue:async r=>{c(!1),history.pushState({},"",Ri(r)),await d()},...n.projectFound?{onCancel:()=>{c(!1),a("")}}:{}})}):e(Qa,{onReset:()=>{d()},children:e(wc,{state:n,onNewProject:()=>c(!0),loading:s,error:i,reload:d,act:m,onJobsUpdate:r=>t(g=>g&&{...g,jobs:r}),onError:a,onErrorDismiss:()=>a("")},n.root)}):e(Dr,{error:i})}function Dr({error:n}){return e("div",{class:"splash",children:[e("span",{class:"splash-mark",children:"D"}),e("strong",{children:"Doxloop"}),e("p",{children:n??"Opening the local control center…"})]})}function Rr(n){return n instanceof Error?n.message:String(n)}aa(e(Pd,{}),document.getElementById("app"));
|
|
33
|
+
//# sourceMappingURL=index-Cq3RPQiC.js.map
|