From 5d4d236689cd784e195c731647bb824856e2db69 Mon Sep 17 00:00:00 2001 From: Lukas Oppermann Date: Tue, 20 Oct 2026 20:01:41 +0200 Subject: [PATCH 1/4] docs: clarify prototype repository setup (#47) ## Why Agents asked to set up a prototyping repository have to assemble instructions from several guides. This makes local setup easy to confuse with full guidance authoring, team preparation, or Hub deployment, and decisions can get lost when moving to a fresh session. ## What changes Add a canonical prototype repository setup guide and link it from the README, agent instructions, and onboarding guides. It covers new and existing targets, a paste-ready fresh-session handoff, verifying the local starter, and continuing only to the requested outcome. The team setup path now explicitly prepares and shares the reviewed baseline before Hub setup. Installer and `/setup-skills` behavior stay unchanged. The cross-session workflow has been reviewed against the existing instructions but has not been exercised end to end in a fresh setup. --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a303def4-749a-4a0e-9701-b7004ce1ef0e --- AGENTS.md | 2 +- README.md | 4 +- docs/README.md | 2 + docs/getting-started.md | 2 +- docs/prototype-environment.md | 22 ++------ docs/prototype-repository-setup.md | 84 ++++++++++++++++++++++++++++++ starter/README.md | 2 +- 7 files changed, 97 insertions(+), 21 deletions(-) create mode 100644 docs/prototype-repository-setup.md diff --git a/AGENTS.md b/AGENTS.md index 54114727..f452c368 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -35,7 +35,7 @@ Follow the [commit and PR conventions](CONTRIBUTING.md#commits-and-pull-requests Hub releases use `hub-v*` tags. The starter follows `main` and has no separate release process. Start a new agent session after copying the starter so its local skills are discovered. -To create a local prototype repository, download and review `scripts/install-starter.sh` with `curl`, then run it without `gh`, credentials, or a clone. From a local Replica checkout, use `scripts/create-prototype-repo.sh ` instead. Choose a new destination outside this checkout; either path creates an independent, uncommitted repository. Start a fresh agent session there before invoking its `/setup-skills` skill; the running session in this checkout will not discover the copied skills. Use an existing Node.js installation matching `engines.node` in [starter/package.json](starter/package.json). On macOS or Linux, obtain approval before installing nodenv, node-build, or Node.js or changing shell configuration; do not install them automatically. +For requests to create a prototype repository or set up an existing repository for prototyping, read [prototype repository setup](docs/prototype-repository-setup.md) before acting. It owns target selection, starter installation, the fresh-session handoff, and the path from local preview to optional guidance, a team baseline, or Hub. ## Browser validation and Playwright fallback diff --git a/README.md b/README.md index 07220ffa..47fdfe3e 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,9 @@ Replica has four parts: **Ready to make prototypes?** Follow [Get started with Replica](docs/getting-started.md) to install the GitHub Copilot app, add your team's prototyping repository, install the canvas, and create your first prototype. It also covers connecting to Hub, publishing, sharing and commenting, and adding controls. -**Setting up Replica for your organization?** Follow [environment setup](docs/prototype-environment.md) to create your team's prototyping repository, add your design system and guidance, and deploy Hub. Your organization deploys and runs Hub on its own infrastructure. GitHub doesn't host it. +**Creating a prototyping repository?** Point your agent at [prototype repository setup](docs/prototype-repository-setup.md). It covers new and existing repositories, getting the starter running locally, and continuing with product guidance or a shared team baseline. Local prototyping needs no Hub. + +**Setting up Replica for your organization?** Follow [environment setup](docs/prototype-environment.md) to add shared guidance and starting pages, deploy Hub, and connect publishing and team feedback. Your organization deploys and runs Hub on its own infrastructure. GitHub doesn't host it. **How did setup go?** [Share your feedback](https://survey.alchemer.com/s3/9055055/Replica-feedback). It helps us make Replica easier to start. diff --git a/docs/README.md b/docs/README.md index 3e52667f..449de56f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -6,6 +6,8 @@ These guides apply across the Replica monorepo. Start with [Contributing](../CON [Get started with Replica](getting-started.md) walks new users through installing Copilot, adding their team's repository and canvas, creating and publishing a prototype, sharing feedback, and adding controls. +[Set up a prototype repository](prototype-repository-setup.md) guides agents through new or existing repository targets, starter installation, the fresh-session handoff, and a verified local preview before optional product guidance or team setup. + [Set up and configure your prototype environment](prototype-environment.md) walks environment maintainers through creating the shared repository, adding design-system guidance and templates, deploying Hub with Docker, connecting builds, and inviting the team. ## Shared conventions diff --git a/docs/getting-started.md b/docs/getting-started.md index e67f5388..650cb9fd 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -2,7 +2,7 @@ Create an interactive prototype with GitHub Copilot, publish it to Replica Hub, and collect feedback from your team. This guide helps you join your organization's prototyping environment and create your first shared prototype. -You can create and try prototypes locally without Hub. Publishing and team comments need a Hub hosted by your organization, a connected GitHub repository, and the repository's Replica build workflow. Ask your team for its Hub URL and repository, or follow [environment setup](prototype-environment.md) if you are setting these up for the first time. +You can create and try prototypes locally without Hub. To create a repository rather than join an existing one, follow [prototype repository setup](prototype-repository-setup.md). Publishing and team comments need a Hub hosted by your organization, a connected GitHub repository, and the repository's Replica build workflow. Ask your team for its Hub URL and repository, or follow [environment setup](prototype-environment.md) if you are setting up shared hosting for the first time. ## 1. Download the GitHub Copilot app diff --git a/docs/prototype-environment.md b/docs/prototype-environment.md index 50926255..4cdde0d3 100644 --- a/docs/prototype-environment.md +++ b/docs/prototype-environment.md @@ -4,6 +4,8 @@ Give your organization a shared place to create prototypes with its own componen This guide is for the people setting up and maintaining that environment, not everyone creating a prototype. It covers the starter repository, design-system guidance, Docker deployment, GitHub connection, and handoff to your team. If your organization already has an environment, follow [Get started with Replica](getting-started.md) to join it instead. +For a local prototype repository without hosted publishing or comments, use [prototype repository setup](prototype-repository-setup.md). It does not require the server, domain, Docker, or GitHub App described below. + The linked technical guides own deployment configuration, access rules, and recovery procedures. Keep them open as you work through the steps below. ## Who should be involved @@ -22,23 +24,9 @@ Install [GitHub CLI](https://cli.github.com/) on the author's computer for canva ## 1. Create the team's prototype repository -Start with Replica Starter in a new directory, separate from your live product and the Replica source checkout. In a terminal on your computer, go to the folder where you keep projects and download the installer: - -```sh -curl -fLSs https://raw.githubusercontent.com/github/replica/main/scripts/install-starter.sh -o install-starter.sh -``` - -Read the downloaded script before running it. Choose a new destination that does not already exist: - -```sh -bash install-starter.sh my-prototype -``` - -The installer creates an independent, uncommitted Git repository with no remote. It needs no GitHub credentials and publishes nothing. From a local Replica checkout, use [`scripts/create-prototype-repo.sh`](../scripts/create-prototype-repo.sh) instead, with a new destination outside that checkout. - -In the Copilot app, click **+** beside **Projects**, choose **Local folder or repository**, and select `my-prototype`. Start a fresh session so Copilot discovers the starter's local skills. Ask Copilot to install the dependencies, reviewing commands before approval. +Follow steps 1 through 3 of [prototype repository setup](prototype-repository-setup.md) to create an independent starter, open a fresh Copilot session, and verify its local preview. Then return here to prepare the team's guidance and starting pages. -Create an empty GitHub repository in your organization for this environment. Connect the local repository to it as `origin`, review the starter files, make the initial commit, and push the default branch. Ask an engineer to help with these Git steps if needed. Give prototype authors write access and reviewers read access. Keep production credentials and real customer data out of it. +Use a GitHub repository in your organization for this shared environment. Give prototype authors write access and reviewers read access. Keep production credentials and real customer data out of it. Continue below to prepare guidance and starting pages before inviting the team. ## 2. Add your product and design-system guidance @@ -56,7 +44,7 @@ Add a small set of representative pages with sample data, such as a list, a deta The hub always offers **Default**, which opens the repository's root page. To offer additional templates, declare their names, descriptions, and routes in `.github/replica.json`. See [template configuration](../hub/docs/github-actions-builds.md#uploaded-artifact) for the format and limits, and [templates in the hub](../hub/docs/gallery.md#templates) for how people use them. -Review the pages and guidance together, then commit them to the team's default branch. New prototypes start from that shared version without changing it. +Review the pages and guidance together, then follow [share the baseline on GitHub](prototype-repository-setup.md#share-the-baseline-on-github) to create or use the intended organization repository, connect `origin`, and commit and push the reviewed baseline when authorized. For an existing shared repository, merge through its contribution process. Verify the actual default branch contains the baseline before continuing to Hub setup. New prototypes start from that shared version without changing it. ## 4. Deploy the hub diff --git a/docs/prototype-repository-setup.md b/docs/prototype-repository-setup.md new file mode 100644 index 00000000..6c4045d2 --- /dev/null +++ b/docs/prototype-repository-setup.md @@ -0,0 +1,84 @@ +# Set up a prototype repository + +Use this guide when someone points an agent at `github/replica` and asks it to set up a prototyping repository. The first milestone is an independent starter app with a verified local preview. Product guidance, reference components, a shared team baseline, and Hub publishing are separate milestones. + +This guide uses the existing installer and starter workflows. It does not change `/setup-skills`, which drafts the full shared context library on plain setup. + +## 1. Resolve the target and requested outcome + +Reuse the repository name, destination, references, and decisions already supplied. Ask only for missing information needed for the next action. + +| Target | Next action | +| --- | --- | +| New local repository | Choose a new directory outside the Replica checkout, then follow step 2. | +| Existing local or GitHub repository | Inspect its instructions, files, Git state, and remote before proposing changes. If it already uses Replica, continue from its current setup state. | +| Existing empty directory or repository | Explain that the installer requires a new destination. Propose creating the starter in a separate directory and reviewing how to integrate it into the intended repository. Get approval before transferring files or changing repository configuration. | +| Existing repository with another app | Agree whether to adapt that app or create a separate prototype repository before installing anything. Preserve existing files and history. | + +A local repository needs no GitHub credentials or Hub. If the user also requests a GitHub repository, resolve its owner and visibility before creating it. Follow the host's authorization rules for repository creation, commits, and pushes; local setup alone does not authorize them. + +When a reference app is supplied, retain it for the guidance and component work in step 4. A request to create the repository does not require a design-system questionnaire before copying the starter. + +## 2. Create the independent starter + +Without a local Replica checkout, download the installer: + +```sh +curl -fLSs https://raw.githubusercontent.com/github/replica/main/scripts/install-starter.sh -o install-starter.sh +``` + +Read the downloaded script before running it. Use a destination that does not exist and whose parent directory exists: + +```sh +bash install-starter.sh my-prototype +``` + +From a local Replica checkout, use the checked-out script instead: + +```sh +bash scripts/create-prototype-repo.sh ../my-prototype +``` + +Both paths create an independent, uncommitted Git repository with no remote. They copy the starter without Replica's source history, require no GitHub credentials, and publish nothing. The installer does not install Node.js or app dependencies. + +Before asking the user to accept the copied repository's Copilot app configuration, review `.github/github-app.yml` and the startup details in the copied `README.md`. Explain that session startup can install Copilot CLI globally when missing, install or enable the Replica plugin, and will run `npm ci`. + +Add the new directory to the Copilot app using **Projects → + → Local folder or repository**, then start a fresh session there. The session in the Replica checkout cannot discover the copied local skills. + +Before ending the originating session, provide a paste-ready kickoff message headed **Prompt 1: Continue prototype repository setup**. Tell the user to paste it into the fresh session; a new session does not inherit the previous conversation. Include the user's goal, repository path, supplied references, requested milestone, settled decisions and approvals, completed actions, blockers, and next step. + +The kickoff must tell the new session to follow the copied repository's `AGENTS.md` and resume this guide at step 3. Include the [absolute guide URL](https://github.com/github/replica/blob/main/docs/prototype-repository-setup.md#3-verify-the-existing-app-locally), since this guide is not copied into the starter. If that version is not yet available at the URL, include steps 3 through 5 inline instead. The new session reuses settled answers and checks which actions and approvals remain applicable. + +## 3. Verify the existing app locally + +Check `node --version` against `engines.node` in the copied `package.json`. Reuse a compatible installed runtime. On macOS or Linux, obtain approval before installing Node.js, nodenv, or node-build, or changing shell configuration. + +The fresh session does not receive the setup output, so ask the user to inspect it and report any failures before repeating setup. Dependency installation success does not prove that the current session loaded the canvas. + +Follow the copied README's **Connect the Replica canvas** and **Canvas preflight** sections for plugin activation and recovery. Complete that preflight before starting a preview. Use its **Run it** commands, reuse an existing responsive server when appropriate, and open the actual printed URL. Verify that the included app renders; a successful dependency install or HTTP response alone is not a rendered check. + +This milestone checks the existing starter page without building product UI. Report a missing runtime, unavailable canvas, or failed preview with its specific recovery step. Hub connection is not required for local preview. + +## 4. Continue only to the requested milestone + +| Requested outcome | Continue with | +| --- | --- | +| Local starter and preview | Report the verified state and stop. No guidance authoring or Hub setup is needed just to inspect the included app. | +| Product or design-system setup | Run the new repository's `/setup-skills` with the supplied sources. Reuse prior answers. Follow its source intake, installation approval, draft review, and separate activation steps. | +| Reference-based starting UI | Complete the applicable guidance setup, then use the local `create-prototype` skill to build the requested shell or page. Establish whether components come from an installable package, permitted source reuse, or newly authored components. Verify the rendered result against the authorized reference. | +| Shared team baseline | Complete the applicable guidance setup, [prepare useful starting pages](prototype-environment.md#3-prepare-useful-starting-pages), and review them together. Then [share the baseline on GitHub](#share-the-baseline-on-github). | +| Hosted publishing and comments | First [share the reviewed baseline on GitHub and verify it on the actual default branch](#share-the-baseline-on-github), then follow [deploy the hub](prototype-environment.md#4-deploy-the-hub) and the remaining environment setup steps, or connect to an existing team Hub. | + +Guidance drafts are not active guidance. Installed tokens or packages are not proof that reference components are usable or that a shell resembles the reference. Keep those outcomes distinct. + +### Share the baseline on GitHub + +After reviewing the starter files, guidance, and starting pages, use the intended empty GitHub repository or create one with the agreed owner and visibility. Connect it as a remote named `origin`, make the initial commit, and push the intended default branch only when authorized. For an existing shared repository, follow its contribution process to merge the reviewed changes instead of replacing its remote or history. Ask an engineer for help with these Git steps if needed. + +Verify the repository's actual default branch contains the intended baseline before calling it ready for teammates or continuing to Hub repository connection. A local preview is not evidence of a published Hub Build. + +## 5. Report what is ready + +Finish with a short status summary based on observed results. Distinguish **verified**, **blocked**, **not checked**, and **not requested** rather than saying only "setup complete." + +Cover the runtime and dependencies, current-session canvas availability, rendered preview and URL, guidance activation, reference components or shell, default-branch baseline, and Hub publishing only as applicable. Name the next blocker and its recovery action. Preserve this summary across a required session handoff. diff --git a/starter/README.md b/starter/README.md index 30960e99..4119b08c 100644 --- a/starter/README.md +++ b/starter/README.md @@ -1,6 +1,6 @@ # Replica Starter -A minimal starting point for a new prototype. Download and review `scripts/install-starter.sh` from `github/replica` to create an independent, uncommitted repository without cloning Replica. From a local Replica checkout, run `./scripts/create-prototype-repo.sh ../my-prototype` instead. Both paths copy this starter without source history or a remote. Open the new repository in a fresh agent session so it discovers the skills, then use `/setup-skills` to draft context from your product and design-system sources. Review and approve the drafts before building a prototype. See the [Replica setup guide](https://github.com/github/replica/blob/main/docs/prototype-environment.md#1-create-the-teams-prototype-repository) for commands. +A minimal starting point for a new prototype. Download and review `scripts/install-starter.sh` from `github/replica` to create an independent, uncommitted repository without cloning Replica. From a local Replica checkout, run `./scripts/create-prototype-repo.sh ../my-prototype` instead. Both paths copy this starter without source history or a remote. Open the new repository in a fresh agent session so it discovers the skills, then use `/setup-skills` to draft context from your product and design-system sources. Review and approve the drafts before building a prototype. See [prototype repository setup](https://github.com/github/replica/blob/main/docs/prototype-repository-setup.md) for commands and the path from local preview to optional guidance and a shared baseline. The app has hash-based routing, a start page, a linked sub-page, and a scaffolded activity example. Replace the example pages with your prototype. From ec561c4f1f3cc14025ddd4679bccad605e8715c9 Mon Sep 17 00:00:00 2001 From: Copilot <223556219+Copilot@users.noreply.github.com> Date: Wed, 21 Oct 2026 00:15:56 +0000 Subject: [PATCH 2/4] fix(canvas): keep unpublished improvements local Capture source when selecting a target and require a matching published Build before initial synchronization. Retain its identity across retries, follow-ups, and deletion. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../extensions/replica-prototype/README.md | 2 + .../renderer-improvement-notes-prototype.js | 2 +- .../capture-review-revision/index.mjs | 97 ++++++ .../improvement-notes/index.mjs | 82 +++++ .../improvement-notes/index.test.mjs | 300 +++++++++++++++++- .../start-canvas-server/index.mjs | 4 + .../start-canvas-server/index.test.mjs | 5 + .../tests/improvement-notes.test.tsx | 48 ++- .../prototype-canvas-improvement-notes/en.ts | 2 + .../index.tsx | 53 +++- .../types.ts | 2 +- .../use-saved-notes/index.ts | 15 +- hub/docs/prototype-canvas.md | 6 +- 13 files changed, 585 insertions(+), 33 deletions(-) create mode 100644 .github/extensions/replica-prototype/capture-review-revision/index.mjs diff --git a/.github/extensions/replica-prototype/README.md b/.github/extensions/replica-prototype/README.md index 72b09b8c..1a4eb800 100644 --- a/.github/extensions/replica-prototype/README.md +++ b/.github/extensions/replica-prototype/README.md @@ -70,6 +70,8 @@ Contributors can load uncommitted changes from a local Replica checkout with `co ## Pick & polish +New improvements remain local until their captured source matches a successful published Build, including on branches with an older Build. Target selection captures the source without changing the real Git index. Capture failures and older notes without provenance still allow local use but cannot synchronize. Once uploaded, later changes retain the original Build identity and remain private owner notes. + **Fix all** invokes the bundled, model-discoverable [`/replica-pick-and-polish` skill](skills/replica-pick-and-polish/SKILL.md) with the verified checkout, branch, batch ID, and thread count. Notes, conversation history, and images are retrieved separately from the immutable batch. When the skill is missing or disabled, or the runtime has no skill catalog, the request includes the same bundled procedure inline. Catalog or fallback-file errors stop preparation without sending work or leaving a batch awaiting results. See the [Pick & polish guide](../../../hub/docs/prototype-canvas.md#pick--polish) for saved-note and recovery behavior. ## Learnings diff --git a/.github/extensions/replica-prototype/assets/renderer-improvement-notes-prototype.js b/.github/extensions/replica-prototype/assets/renderer-improvement-notes-prototype.js index 3a03c9c7..1e825f7d 100644 --- a/.github/extensions/replica-prototype/assets/renderer-improvement-notes-prototype.js +++ b/.github/extensions/replica-prototype/assets/renderer-improvement-notes-prototype.js @@ -1 +1 @@ -import{n as e,r as t}from"./renderer-rolldown-runtime.js";import{E as n,K as r,L as i,M as a,X as o,Y as s,f as c,g as l,q as u,x as d,z as f}from"./renderer-vendor.js";import{a as p,c as m,f as h,m as g,o as ee,p as te,s as _}from"./renderer.js";import{t as v}from"./renderer-improvement-notes-vendor.js";import{t as ne}from"./renderer-prototype-canvas-improvement-threads.js";var y=t(o(),1),re=s(),b=r(),ie=v(),x={title:`Pick & polish`,localAuthor:`Local author`,branch:`prototype/welcome`,demo:`UI prototype`,demoNotice:`Sample preview. Notes reset on reload. No Hub API calls or agent work.`,canvasDemoNotice:`UI-only notes over the live preview. Notes reset on canvas reload. Captures, Hub sync and agent results are simulated.`,canvasBatchSource:`Live preview · UI-only batch`,sampleBatchSource:`Local, uncommitted sample`,bridgeUnavailable:`Annotation needs the updated Replica preview bridge. Reconnect or reload the preview after updating the canvas.`,capturePlaceholder:`UI-only capture placeholder`,annotate:`Pick & polish`,fix:`Fix all`,openNotes:e=>`Open improvement notes (${e})`,fixAll:e=>`Fix all (${e})`,notes:`Pick & polish`,closeNotes:`Close pick & polish`,owner:`Only your notes appear here. Authorized API callers can request other authors' notes.`,selectHint:`Click an element or drag a rectangle. For a keyboard region, focus the preview, press Shift+Enter, then use arrows and Enter to choose two corners. Escape exits annotation mode.`,keyboardHint:`Click an element or drag a rectangle. Focus the preview and press Shift+Enter for keyboard region selection; arrows move the corner and Enter selects it.`,regionHint:`Choose two corners in the preview. Use arrow keys to move the corner, then Enter.`,firstCorner:`First corner selected. Choose the second corner.`,regionSmall:`Choose a larger region, at least 8 preview pixels wide and high.`,add:`Add improvement note`,edit:`Edit improvement note`,label:`What should change?`,placeholder:`Describe the improvement you want Copilot to make...`,save:`Save note`,saveEdit:`Save changes`,cancel:`Cancel`,discard:`Discard draft`,keep:`Keep writing`,discardTitle:`Discard your unsaved note?`,discardBody:`Your saved notes will stay unchanged.`,capture:`Captured target`,empty:`A little feedback goes a long way`,emptyBody:`Select an element or draw around an area. Collect notes across screens, then fix them together.`,emptyFilter:`No notes in this view.`,allActive:`Active notes`,readyFilter:`Ready to review`,resolvedFilter:`Resolved`,filter:`Filter improvement notes`,viewTarget:`View target`,noteActions:e=>`Note actions: ${e}`,editAction:`Edit`,deleteAction:`Delete`,deleteTitle:`Delete this improvement note?`,deleteBody:`This removes the note. It does not change the prototype.`,resolve:`Confirm resolved`,solution:`Solution`,solutionUnavailable:`The solution summary is not available in this canvas.`,readyReadOnly:`Ready notes are read-only. Add a new note to request further changes.`,reopen:`Reopen`,retryFix:`Retry fix`,noteSent:`Sent in the simulated batch. No real agent has started.`,noteReady:`Simulated change is ready. Review the target before resolving.`,noteBlocked:`Simulated agent could not safely identify the change. Edit the note or retry.`,handoff:`Demo handoff to Copilot`,handoffNotice:`This is the captured batch, not a live agent request. New notes stay out of this batch.`,complete:`Simulate ready to review`,block:`Simulate blocked`,closeHandoff:`Continue annotating`,sent:`Demo batch captured. No code was changed.`,finished:`Simulated result received. Review each note before resolving.`,fixBusy:`Finish or close the current simulated batch before sending another.`,syncControls:`Demo connection`,offline:`Offline`,connected:`Connected`,syncFailure:`Sync failure`,syncRetry:`Retry demo sync`,syncFailed:`Demo sync failed. Your note remains in this demo; retry when connected.`,syncSuccess:`Demo sync completed.`,targetMissing:`This sample target is no longer available. The saved capture is still shown.`,previewUnavailable:`The demo preview is unavailable. Try selecting the target again.`,saved:`Note added.`,savedLocally:`Notes are saved locally.`,storageLoading:`Loading your notes...`,productionSent:`Notes sent to Copilot. Review the changes before confirming resolution.`,productionBusy:`Copilot is working on the captured batch.`,branchChanged:`The prototype branch changed. Close this draft and select the target again.`,workChanged:`The open improvements changed while syncing. Review them and select Fix all again.`,returnToActive:`Return to active`,regionTarget:`Selected region`,closeComposer:`Close note composer`,closeDiscard:`Close discard confirmation`,closeDelete:`Close delete confirmation`,closeBatch:`Close demo handoff`,exit:`Exit annotation mode`,sampleScreens:`Sample prototype screens`,sampleWorkspace:`Octocat's workspace`,projects:`Projects`,settings:`Settings`,navigationHint:`Navigate between screens. Your notes stay together.`,authorContext:`Across this prototype · Demo author: octocat`,batchHint:`Fix only this batch. Do not commit, push, or publish. Report per-note results for the author to review.`,perNoteResult:`Simulate a result for this note`,batchLabel:e=>`View demo batch (${e})`,statuses:{open:`Open`,sent:`Sent to Copilot`,ready:`Ready to review`,resolved:`Resolved`,blocked:`Needs attention`},sync:{local:`Demo: local only`,synced:`Demo: synced`,failed:`Demo: sync failed`}};function ae(e,t){let n=[e.thread?.originalStatus??e.status,...e.thread?.messages.filter(e=>e.role===`author`).map(e=>e.status)??[]];return{id:e.id,revision:e.revision,body:e.body,capture:e.capture,author:e.thread?.originalAuthor?`@${e.thread.originalAuthor.login}`:e.author===`local`?x.localAuthor:`@${e.author}`,avatarUrl:(e.thread?.originalAuthor??e.authorProfile)?.avatarUrl,target:e.target,path:e.route,status:e.status,originalPending:(e.thread?.originalStatus??e.status)===`open`,...n.includes(`sent`)?{retryStatus:`sent`}:n.includes(`blocked`)?{retryStatus:`blocked`}:{},messages:e.thread?.messages.map(e=>({...e,...e.role===`author`&&e.author?{author:`@${e.author.login}`,avatarUrl:e.author.avatarUrl}:{author:void 0},pending:e.role===`author`&&e.status===`open`}))??(e.result?[{id:`legacy-result`,role:`copilot`,body:e.result,status:e.status===`blocked`?`blocked`:`ready`}]:[]),...t&&(t.status===`resolved`||t.status===`moved`)?{point:t.point}:{}}}function oe(e,t){let n=e.cloneNode(!0);if(!(n instanceof SVGSVGElement))throw Error(`The demo preview could not be captured.`);return n.setAttribute(`viewBox`,`${t.x} ${t.y} ${t.width} ${t.height}`),n.setAttribute(`width`,String(t.width)),n.setAttribute(`height`,String(t.height)),n.removeAttribute(`class`),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}var se=[{id:`projects-heading`,label:`Projects heading`,route:`/projects`,rect:{x:40,y:35,width:640,height:78}},{id:`new-project`,label:`New project button`,route:`/projects`,rect:{x:764,y:42,width:156,height:42}},{id:`activity`,label:`Activity summary`,route:`/projects`,rect:{x:40,y:144,width:880,height:100}},{id:`welcome-card`,label:`Welcome project card`,route:`/projects`,rect:{x:40,y:285,width:420,height:230}},{id:`onboarding-card`,label:`Onboarding project card`,route:`/projects`,rect:{x:500,y:285,width:420,height:230}},{id:`settings-heading`,label:`Settings heading`,route:`/settings`,rect:{x:40,y:35,width:700,height:78}},{id:`workspace-name`,label:`Workspace name field`,route:`/settings`,rect:{x:40,y:152,width:880,height:138}},{id:`notifications`,label:`Notifications settings`,route:`/settings`,rect:{x:40,y:318,width:880,height:130}},{id:`save-settings`,label:`Save settings button`,route:`/settings`,rect:{x:40,y:478,width:166,height:42}}],ce=[{id:1,kind:`improvement_note`,author:`octocat`,body:`Make the primary action more prominent and shorten the label to 'New project'.`,route:`/projects`,target:`New project button`,selector:`[data-improvement-target="new-project"]`,rect:{x:764,y:42,width:156,height:42},capture:``,status:`open`,sync:`local`,revision:1},{id:2,kind:`improvement_note`,author:`octocat`,body:`Give the two cards a little more breathing room and align their metadata.`,route:`/projects`,target:`Selected region`,selector:null,rect:{x:28,y:273,width:904,height:250},capture:``,status:`open`,sync:`local`,revision:1},{id:3,kind:`improvement_note`,author:`octocat`,body:`Explain what notifications this switch controls before asking me to enable it.`,route:`/settings`,target:`Notifications settings`,selector:`[data-improvement-target="notifications"]`,rect:{x:40,y:318,width:880,height:130},capture:``,status:`ready`,sync:`synced`,revision:1}],S=u();function le({route:e}){return(0,S.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 960 560`,className:`improvement-demo__scene`,role:`group`,"aria-label":`Sample prototype ${e}`,fontFamily:`system-ui, sans-serif`,children:[(0,S.jsx)(`rect`,{width:`960`,height:`560`,fill:`#f8fafc`}),se.filter(t=>t.route===e).map(t=>(0,S.jsxs)(`g`,{"data-improvement-target":t.id,children:[(0,S.jsx)(`rect`,{...t.rect,rx:`10`,fill:t.id.includes(`heading`)?`#f8fafc`:t.id===`new-project`||t.id===`save-settings`?`#155d3d`:`#ffffff`,stroke:t.id.includes(`heading`)?`none`:`#dce3e9`}),t.id.includes(`heading`)?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`text`,{x:`40`,y:`67`,fill:`#172b24`,fontSize:`28`,fontWeight:`650`,children:e===`/projects`?`Your projects`:`Workspace settings`}),(0,S.jsx)(`text`,{x:`40`,y:`99`,fill:`#596b65`,fontSize:`15`,children:e===`/projects`?`A home for your team's next great idea.`:`Make this space work for your team.`})]}):t.id===`new-project`||t.id===`save-settings`?(0,S.jsx)(`text`,{x:t.rect.x+t.rect.width/2,y:t.rect.y+26,textAnchor:`middle`,fill:`#ffffff`,fontSize:`14`,fontWeight:`600`,children:t.id===`new-project`?`+ Create project`:`Save settings`}):t.id===`activity`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`text`,{x:`64`,y:`179`,fill:`#596b65`,fontSize:`13`,children:`THIS WEEK`}),(0,S.jsx)(`text`,{x:`64`,y:`214`,fill:`#172b24`,fontSize:`23`,fontWeight:`600`,children:`12 prototypes`}),(0,S.jsx)(`text`,{x:`348`,y:`179`,fill:`#596b65`,fontSize:`13`,children:`IN REVIEW`}),(0,S.jsx)(`text`,{x:`348`,y:`214`,fill:`#172b24`,fontSize:`23`,fontWeight:`600`,children:`4 conversations`}),(0,S.jsx)(`text`,{x:`642`,y:`179`,fill:`#596b65`,fontSize:`13`,children:`YOUR TEAM`}),(0,S.jsx)(`text`,{x:`642`,y:`214`,fill:`#172b24`,fontSize:`23`,fontWeight:`600`,children:`Making things happen`})]}):t.id.includes(`card`)?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`rect`,{x:t.rect.x+16,y:`301`,width:`388`,height:`100`,rx:`6`,fill:t.id===`welcome-card`?`#e3efe9`:`#eee9f7`}),(0,S.jsx)(`rect`,{x:t.rect.x+40,y:`323`,width:`100`,height:`10`,rx:`4`,fill:`#ffffff`}),(0,S.jsx)(`rect`,{x:t.rect.x+40,y:`345`,width:`196`,height:`6`,rx:`3`,fill:`#ffffff`}),(0,S.jsx)(`rect`,{x:t.rect.x+40,y:`363`,width:`156`,height:`6`,rx:`3`,fill:`#ffffff`}),(0,S.jsx)(`text`,{x:t.rect.x+24,y:`437`,fill:`#172b24`,fontSize:`18`,fontWeight:`600`,children:t.id===`welcome-card`?`Welcome experience`:`A better onboarding`}),(0,S.jsx)(`text`,{x:t.rect.x+24,y:`463`,fill:`#596b65`,fontSize:`13`,children:t.id===`welcome-card`?`prototype/welcome`:`prototype/onboarding`}),(0,S.jsx)(`circle`,{cx:t.rect.x+30,cy:`490`,r:`5`,fill:`#2a7954`}),(0,S.jsx)(`text`,{x:t.rect.x+44,y:`495`,fill:`#596b65`,fontSize:`12`,children:`Updated today · The Octocat`})]}):t.id===`workspace-name`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`text`,{x:`64`,y:`184`,fill:`#172b24`,fontSize:`17`,fontWeight:`600`,children:`Workspace name`}),(0,S.jsx)(`text`,{x:`64`,y:`209`,fill:`#596b65`,fontSize:`13`,children:`This is how your workspace appears to your team.`}),(0,S.jsx)(`rect`,{x:`64`,y:`230`,width:`600`,height:`38`,rx:`6`,fill:`#f8fafc`,stroke:`#dce3e9`}),(0,S.jsx)(`text`,{x:`78`,y:`255`,fill:`#172b24`,fontSize:`14`,children:`Octocat's workspace`})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`text`,{x:`64`,y:`351`,fill:`#172b24`,fontSize:`17`,fontWeight:`600`,children:`Notifications`}),(0,S.jsx)(`text`,{x:`64`,y:`385`,fill:`#596b65`,fontSize:`14`,children:`Keep me in the loop`}),(0,S.jsx)(`rect`,{x:`824`,y:`366`,width:`48`,height:`26`,rx:`13`,fill:`#155d3d`}),(0,S.jsx)(`circle`,{cx:`857`,cy:`379`,r:`9`,fill:`#ffffff`})]})]},t.id))]})}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ue({frameRef:e,prototypeUrl:t,previewUrl:n,notes:r,annotating:i,composing:a,onSelect:o,onRoute:s,onCancel:c,onProblem:l}){let u=n??t,[d,f]=(0,y.useState)(null),[p,h]=(0,y.useState)(new Map),g=JSON.stringify(r.filter(e=>e.anchor).slice(0,200).map(e=>({id:e.id,anchor:e.anchor}))),te=(0,y.useEffectEvent)(e=>{if(!i||a)return;let t=_.safeParse(e);t.success?o(t.data):(c(),l(x.previewUnavailable))}),v=(0,y.useCallback)((t,n={})=>{u&&d&&e?.current?.contentWindow&&e.current.contentWindow.postMessage({type:t,nonce:d.nonce,...n},new URL(u).origin)},[d,e,u]);return(0,y.useEffect)(()=>{let t=e?.current;if(!t||!u)return;let n=new URL(u).origin,r=crypto.randomUUID(),i=Date.now(),a=JSON.parse(g);function o(){t?.contentWindow?.postMessage({type:`replica:canvas:request-ready`,nonce:r},n),t?.contentWindow?.postMessage({type:`replica:canvas:resolve`,nonce:r,anchors:a},n)}function d(){r=crypto.randomUUID(),i=Date.now(),f({nonce:r,ready:!1}),h(new Map),c(),o()}function p(e){let a=e.data;if(e.source===t?.contentWindow&&e.origin===n&&C(a)&&a.nonce===r){if(a.type===`replica:canvas:ready`){let e=m.safeParse(a.route);if(a.protocolVersion!==1||a.improvementSelection!==!0||!e.success){f({nonce:r,ready:!1}),l(x.bridgeUnavailable);return}i=Date.now(),f(e=>e?.nonce===r&&e.ready?e:{nonce:r,ready:!0}),s(e.data.pathname+e.data.search+e.data.hash)}else if(a.type===`replica:canvas:selected`)te(a.anchor);else if(a.type===`replica:canvas:resolved`&&Array.isArray(a.results)){let e=new Map;for(let t of a.results){if(!C(t))continue;let n=ee.safeParse({commentId:t.id,status:`resolved`,point:{x:t.x,y:t.y},rect:t.rect??{x:t.x,y:t.y,width:1,height:1}});n.success&&e.set(n.data.commentId,n.data)}h(e)}else a.type===`replica:canvas:selection-failed`||a.type===`replica:canvas:bridge-error`?(c(),l(a.reason===`area-too-small`?x.regionSmall:x.bridgeUnavailable)):a.type===`replica:canvas:selection-cancelled`?a.reason!==`command`&&c():a.type===`replica:canvas:conversation-dismiss-requested`&&window.dispatchEvent(new Event(`replica:review-dismiss`))}}t.addEventListener(`load`,d),window.addEventListener(`message`,p),f({nonce:r,ready:!1}),o();let _=window.setInterval(()=>{Date.now()-i>2e4&&(f({nonce:r,ready:!1}),h(new Map),c(),l(x.bridgeUnavailable)),o()},2e3);return()=>{t.removeEventListener(`load`,d),window.removeEventListener(`message`,p),window.clearInterval(_),t.contentWindow?.postMessage({type:`replica:canvas:cancel-selection`,nonce:r},n),t.contentWindow?.postMessage({type:`replica:canvas:clear-selection`,nonce:r},n)}},[g,e,u,c,l,s]),(0,y.useEffect)(()=>{d?.ready&&(i&&!a?v(`replica:canvas:select`,{mode:`improvement`}):v(`replica:canvas:cancel-selection`),a||v(`replica:canvas:clear-selection`))},[i,a,d?.ready,v]),{ready:d?.ready===!0,resolutions:p}}function de(e){let[t,n]=(0,y.useState)(null),[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(!1),l=(0,y.useRef)(null),u=(0,y.useRef)(!1),d=(0,y.useRef)(null),f=(0,y.useRef)(!1),m=(0,y.useRef)(0);function h(e){f.current&&(l.current=e,n(e))}(0,y.useEffect)(()=>{if(!e)return;f.current=!0;let t=!1,r=!1,a=0;async function s(){if(u.current||r)return;r=!0;let s=m.current;try{let n=await p(`/api/improvement-notes`,e);if(u.current||s!==m.current||t)return;if(h(n),Date.now()-a>15e3){a=Date.now();let r=p(`/api/improvement-notes/sync`,e,{method:`POST`,body:JSON.stringify({identity:n.identity,revision:n.revision})}).then(e=>{t||h(e)});d.current=r;try{await r}finally{d.current===r&&(d.current=null)}}t||o(``)}catch(e){t||(e instanceof Error&&`statusCode`in e&&e.statusCode===403&&(l.current=null,n(null),i(``)),o(e instanceof Error?e.message:String(e)))}finally{r=!1}}s();let c=window.setInterval(()=>void s(),3e3);return()=>{f.current=!1,t=!0,window.clearInterval(c)}},[e]);async function g(t,n={}){if(!e||!l.current||u.current)return!1;let r=l.current.identity,a=l.current.notes.filter(e=>e.status===`open`).map(e=>`${e.id}:${e.revision}`).sort().join(`,`);u.current=!0,m.current++,c(!0),i(``);try{if(await d.current,!f.current)return!1;if(!l.current||l.current.identity!==r)throw Error(x.branchChanged);if(t===`fix`&&l.current.notes.filter(e=>e.status===`open`).map(e=>`${e.id}:${e.revision}`).sort().join(`,`)!==a)throw Error(x.workChanged);return h(await p(t===`fix`?`/api/improvement-notes/fix`:`/api/improvement-notes`,e,{method:`POST`,body:JSON.stringify({identity:l.current.identity,revision:l.current.revision,operation:t,...n})})),!0}catch(e){return f.current&&i(e instanceof Error?e.message:String(e)),!1}finally{u.current=!1,f.current&&c(!1)}}return{state:t,error:r||a,busy:s,change:g}}var w=e({ImprovementNotesPrototype:()=>T});function T({initial:e=`empty`,canvas:t}){let[r,o]=(0,y.useState)(()=>ce.slice(0,e===`empty`?0:e===`single`?1:3).map(e=>{let t=new DOMParser().parseFromString((0,ie.renderToStaticMarkup)((0,S.jsx)(le,{route:e.route})),`image/svg+xml`).documentElement;if(!(t instanceof SVGSVGElement))throw Error(`The sample preview could not be captured.`);return{...e,capture:oe(t,e.rect)}})),s=de(t?.token),u=s.state?.syncError===`Notes are saved locally until Hub discovers this branch.`?null:s.state?.syncError,p=t?.token?s.state?.notes??[]:r,[m,ee]=(0,y.useState)(`/projects`),[_,v]=(0,y.useState)(!1),[C,w]=(0,y.useState)(!0),[T,E]=(0,y.useState)(null),[D,O]=(0,y.useState)(null),[k,A]=(0,y.useState)(``),[fe,pe]=(0,y.useState)(!1),[j,me]=(0,y.useState)(null),[M,he]=(0,y.useState)(`active`),[N,ge]=(0,y.useState)(`offline`),[P,_e]=(0,y.useState)([]),[ve,F]=(0,y.useState)(!1),[ye,I]=(0,y.useState)(``),[be,L]=(0,y.useState)(null),[R,z]=(0,y.useState)(!1),[B,xe]=(0,y.useState)({x:160,y:160}),[V,H]=(0,y.useState)(null),[Se,Ce]=(0,y.useState)(null),[U,W]=(0,y.useState)(null),G=(0,y.useRef)(null),we=(0,y.useRef)(null),K=(0,y.useRef)(null),Te=(0,y.useRef)(null),q=(0,y.useRef)(null),Ee=(0,y.useRef)(e===`empty`?1:e===`single`?2:4),J=p.filter(e=>e.status===`open`),Y=!t?.token||s.state!==null,De=T!==null&&!fe&&Y;(0,y.useLayoutEffect)(()=>{De&&Te.current?.focus()},[De]);let Oe=!!t?.token&&T!==null&&T.identity!==s.state?.identity,ke=D!==null&&p.some(e=>e.id===D&&e.status===`ready`),Ae=p.filter(e=>e.status!==`resolved`).length,je=M===`ready`?x.readyFilter:M===`resolved`?x.resolvedFilter:x.allActive,Me=p.filter(e=>M===`resolved`?e.status===`resolved`:M===`ready`?e.status===`ready`:e.status!==`resolved`),Ne=!!s.state?.activeBatch||P.some(e=>p.some(t=>t.id===e.id&&t.revision===e.revision&&t.status===`sent`)),Pe=p.filter(e=>e.route===m&&e.status!==`resolved`),X=p.find(e=>e.id===be&&e.route===m),Fe=(0,y.useCallback)(e=>{let t=e.kind===`element`?e.accessibleName||e.tagName:x.regionTarget;E({identity:s.state?.identity,anchor:e,route:e.route.pathname+e.route.search+e.route.hash,target:t,selector:e.kind===`element`?e.selector:null,rect:e.rect,capture:``,capturePlaceholder:!0}),O(null),A(``)},[s.state?.identity]),Ie=(0,y.useCallback)(()=>{K.current?.getAttribute(`aria-pressed`)===`true`&&K.current.focus(),v(!1)},[]),Le=t?.frameRef,Z=ue({frameRef:Le,prototypeUrl:t?.prototypeUrl,previewUrl:t?.previewUrl,notes:p,annotating:_,composing:T!==null,onSelect:Fe,onRoute:ee,onCancel:Ie,onProblem:I}),Q=!!t;(0,y.useLayoutEffect)(()=>{Le&&Ce(Le.current?.closest(`.canvas-shell`)?.querySelector(`#canvas-improvement-controls`)??null)},[Le]);function Re(){w(!0),t?.onOpenNotes()}function ze(e,t){let n=we.current?.querySelector(`svg`);n?(E({route:m,target:t?.label??x.regionTarget,selector:t?`[data-improvement-target="${t.id}"]`:null,rect:e,capture:oe(n,e)}),A(``),O(null),W(null),H(null),z(!1)):I(x.previewUnavailable)}function Be(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function Ve(e){let t=we.current?.getBoundingClientRect();return!t?.width||!t.height?(I(x.previewUnavailable),null):{x:Math.max(0,Math.min(960,(e.clientX-t.left)/t.width*960)),y:Math.max(0,Math.min(560,(e.clientY-t.top)/t.height*560))}}function He(e,t){let n=Be(e,t);W(null),H(null),n.width<8||n.height<8?I(x.regionSmall):ze(n)}function Ue(){let e=T?.originalBody??``;k===e?(E(null),O(null)):pe(!0)}async function We(){if(ke){I(x.readyReadOnly);return}if(!T||!k.trim()||s.busy||Oe)return;if(t?.token){if(!await s.change(D===null?`create`:`edit`,{id:D,identity:T.identity,expectedNoteRevision:T.noteRevision,body:k.trim(),anchor:T.anchor,capture:T.capturePlaceholder?``:T.capture}))return;he(`active`),Re(),E(null),O(null),I(x.saved);return}let e=N===`connected`?`synced`:N===`failed`?`failed`:`local`;if(D!==null)o(t=>t.map(t=>t.id===D?{...t,body:k.trim(),revision:t.revision+1,status:`open`,sync:e}:t));else{let t={...T,id:Ee.current++,body:k.trim(),kind:`improvement_note`,author:`octocat`,status:`open`,sync:e,revision:1};o(e=>[...e,t]),L(t.id)}he(`active`),Re(),E(null),O(null),I(N===`failed`?x.syncFailed:x.saved)}async function Ge(){J.length&&!Ne&&(t?.token?await s.change(`fix`)&&I(x.productionSent):(_e(J.map(e=>({...e}))),o(e=>e.map(e=>e.status===`open`?{...e,status:`sent`}:e)),F(!0),I(x.sent)))}function Ke(e){o(t=>t.map(t=>P.some(e=>e.id===t.id&&e.revision===t.revision)&&t.status===`sent`?{...t,status:e}:t)),F(!1),w(!0),I(x.finished)}async function $(e,n){t?.token?await s.change(`status`,{id:e.id,status:n,identity:s.state?.identity,expectedNoteRevision:e.revision})&&q.current?.focus():(o(t=>t.map(t=>t.id===e.id?{...t,status:n,sync:N===`connected`?`synced`:N===`failed`?`failed`:`local`}:t)),q.current?.focus())}let qe=(0,S.jsx)(`div`,{className:`improvement-demo__actions`,children:(0,S.jsxs)(`div`,{role:`group`,"aria-label":x.title,className:`improvement-demo__split`,children:[(0,S.jsx)(b.Button,{ref:K,size:`small`,variant:`secondary`,className:`canvas-toolbar-compact-button`,"aria-label":x.annotate,title:x.annotate,leadingVisual:(0,S.jsx)(a,{}),"aria-pressed":_,disabled:Q&&(!Z.ready||!!t?.token&&!s.state),onClick:()=>{v(!_),_||(w(!1),I(x.selectHint)),z(!1),H(null),W(null)},children:(0,S.jsx)(`span`,{className:`canvas-toolbar-button-label`,children:x.annotate})}),(0,S.jsx)(b.Button,{ref:q,size:`small`,variant:`secondary`,"aria-label":x.openNotes(Ae),"aria-expanded":C&&!t?.hubOpen,onClick:Re,children:(0,S.jsx)(te,{children:Ae})})]})});return(0,S.jsxs)(`section`,{"aria-label":x.title,className:`improvement-demo${Q?` improvement-demo--embedded`:``}`,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||T||j!==null||ve||(v(!1),z(!1),H(null),W(null),G.current=null,_&&K.current?.focus())},children:[Q?null:(0,S.jsxs)(`header`,{className:`improvement-demo__browser`,children:[(0,S.jsx)(`span`,{className:`improvement-demo__browser-dot`}),(0,S.jsxs)(`code`,{children:[`localhost:5173`,m]}),(0,S.jsx)(`span`,{className:`improvement-demo__badge`,children:x.demo})]}),Q?Se&&(0,re.createPortal)(qe,Se):(0,S.jsxs)(`header`,{className:`improvement-demo__toolbar`,children:[(0,S.jsxs)(`div`,{className:`improvement-demo__identity`,children:[(0,S.jsx)(`strong`,{children:x.branch}),(0,S.jsx)(`span`,{children:x.title})]}),qe]}),Q?null:(0,S.jsx)(`div`,{className:`improvement-demo__disclaimer`,children:x.demoNotice}),(0,S.jsxs)(`div`,{className:`improvement-demo__workspace`,children:[Q?null:(0,S.jsxs)(`section`,{className:`improvement-demo__preview`,"aria-label":`Prototype preview`,children:[(0,S.jsxs)(`nav`,{className:`improvement-demo__pages`,"aria-label":x.sampleScreens,children:[(0,S.jsx)(`span`,{className:`improvement-demo__app-name`,children:x.sampleWorkspace}),[`/projects`,`/settings`].map(e=>(0,S.jsx)(`button`,{type:`button`,"aria-current":m===e?`page`:void 0,onClick:()=>{ee(e),L(null),H(null),W(null)},children:e===`/projects`?x.projects:x.settings},e))]}),(0,S.jsxs)(`div`,{ref:we,className:`improvement-demo__stage${_?` improvement-demo__stage--selecting`:``}`,role:R?`button`:`group`,tabIndex:_?0:-1,"aria-describedby":`improvement-selection-hint`,"aria-label":R?`Choose region corners`:`Selectable preview`,onKeyDown:e=>{if(e.key===`Escape`)e.preventDefault(),v(!1),z(!1),H(null),W(null),G.current=null,K.current?.focus();else if(_&&e.shiftKey&&e.key===`Enter`)e.preventDefault(),z(!R),H(null),W(null),I(R?x.selectHint:x.regionHint);else if(R&&[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Enter`,` `].includes(e.key)){if(e.preventDefault(),e.key===`Enter`||e.key===` `)V?He(V,B):(H(B),I(x.firstCorner));else{let t={x:Math.max(0,Math.min(960,B.x+(e.key===`ArrowRight`?10:e.key===`ArrowLeft`?-10:0))),y:Math.max(0,Math.min(560,B.y+(e.key===`ArrowDown`?10:e.key===`ArrowUp`?-10:0)))};xe(t),V&&W(Be(V,t))}}},onPointerDown:e=>{if(!_||e.button!==0||e.target instanceof Element&&e.target.closest(`[data-note-pin]`))return;e.preventDefault();let t=Ve(e);if(!t)return;if(R){xe(t),G.current={start:t,target:void 0,pointerId:e.pointerId},e.currentTarget.setPointerCapture(e.pointerId);return}let n=e.target instanceof Element?e.target.closest(`[data-improvement-target]`):null;G.current={start:t,target:se.find(e=>e.id===n?.getAttribute(`data-improvement-target`)),pointerId:e.pointerId},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{if(!G.current||G.current.pointerId!==e.pointerId)return;let t=Ve(e);if(!t)return;if(R){xe(t),V&&W(Be(V,t));return}let n=Be(G.current.start,t);Math.hypot(n.width,n.height)>=8&&W(n)},onPointerUp:e=>{let t=G.current;if(!t||t.pointerId!==e.pointerId)return;G.current=null,e.currentTarget.releasePointerCapture(e.pointerId);let n=Ve(e);if(!n)return;if(R){xe(n),V?He(V,n):(H(n),I(x.firstCorner));return}let r=Be(t.start,n);Math.hypot(r.width,r.height)>=8?He(t.start,n):t.target&&ze(t.target.rect,t.target),W(null)},onPointerCancel:()=>{G.current=null,W(null)},onLostPointerCapture:()=>{G.current=null,W(null)},children:[(0,S.jsx)(le,{route:m}),_&&!R?se.filter(e=>e.route===m).map(e=>(0,S.jsx)(`button`,{type:`button`,"data-improvement-target":e.id,className:`improvement-demo__element-target`,"aria-label":e.label,style:{left:`${e.rect.x/960*100}%`,top:`${e.rect.y/560*100}%`,width:`${e.rect.width/960*100}%`,height:`${e.rect.height/560*100}%`},onClick:()=>{T||ze(e.rect,e)}},e.id)):null,U?(0,S.jsx)(`div`,{className:`improvement-demo__outline`,style:{left:`${U.x/960*100}%`,top:`${U.y/560*100}%`,width:`${U.width/960*100}%`,height:`${U.height/560*100}%`}}):null,R?(0,S.jsx)(`span`,{className:`improvement-demo__corner`,style:{left:`${B.x/960*100}%`,top:`${B.y/560*100}%`}}):null,Pe.map(e=>(0,S.jsx)(`button`,{"data-note-pin":!0,type:`button`,className:`improvement-demo__pin${be===e.id?` improvement-demo__pin--selected`:``}`,style:{left:`${Math.min(e.rect.x+e.rect.width,930)/960*100}%`,top:`${e.rect.y/560*100}%`},"aria-label":`Open improvement note ${e.id}: ${e.target}`,onClick:()=>{L(e.id),w(!0),he(`active`)},children:e.id},e.id)),X?(0,S.jsx)(`div`,{className:`improvement-demo__outline improvement-demo__outline--saved`,style:{left:`${X.rect.x/960*100}%`,top:`${X.rect.y/560*100}%`,width:`${X.rect.width/960*100}%`,height:`${X.rect.height/560*100}%`}}):null]}),(0,S.jsxs)(`footer`,{className:`improvement-demo__preview-footer`,children:[(0,S.jsx)(`span`,{id:`improvement-selection-hint`,children:_?x.keyboardHint:x.navigationHint}),(0,S.jsx)(`span`,{children:`960 × 560`})]})]}),Q&&!t?.token?(0,S.jsx)(`div`,{className:`canvas-improvement-markers`,children:Pe.map(e=>{let t=Z.resolutions.get(e.id);return!t||t.status!==`resolved`&&t.status!==`moved`?null:(0,S.jsx)(`button`,{type:`button`,className:`improvement-demo__pin`,style:{left:t.point.x,top:t.point.y},"aria-label":`Open improvement note ${e.id}: ${e.target}`,onClick:()=>{L(e.id),he(e.status===`ready`?`ready`:`active`),Re()},children:e.id},e.id)})}):null,t?.token?(0,S.jsx)(ne,{identity:s.state?.identity??``,controls:!1,returnFocusRef:q,open:C&&!t.hubOpen&&!T,active:(C||_)&&!t.hubOpen&&!T,onOpen:Re,onClose:()=>{w(!1),q.current?.focus()},threads:p.map(e=>ae(e,Z.resolutions.get(e.id))),busy:s.busy||!s.state,activeBatch:!!s.state?.activeBatch,error:s.error||u||s.state?.profileError||(s.state?Z.ready?``:x.bridgeUnavailable:x.storageLoading),onSelect:e=>{let n=p.find(t=>t.id===e);n&&n.route!==m&&t.onNavigate(new URL(n.route,t.prototypeUrl).href)},onFollowUp:(e,t)=>s.change(`follow-up`,{id:e.id,expectedNoteRevision:e.revision,body:t}),onResolve:e=>s.change(`status`,{id:e.id,expectedNoteRevision:e.revision,status:`resolved`}),onDelete:e=>s.change(`delete`,{id:e.id,expectedNoteRevision:e.revision}),onFix:()=>s.change(`fix`),onRetry:e=>s.change(`status`,{id:e.id,expectedNoteRevision:e.revision,status:`open`})}):(0,S.jsxs)(h,{className:`improvement-notes-sidebar`,contentClassName:`improvement-demo__panel`,title:x.notes,open:C&&!t?.hubOpen,closeLabel:x.closeNotes,onClose:()=>{w(!1),q.current?.focus()},children:[s.error&&(!T||!Y)?(0,S.jsx)(`p`,{role:`alert`,className:`improvement-demo__notice`,children:s.error}):null,u?(0,S.jsx)(`p`,{role:`status`,className:`improvement-demo__notice`,children:u}):null,t?.token&&!s.state?(0,S.jsx)(`p`,{role:`status`,className:`improvement-demo__notice`,children:x.storageLoading}):null,Q&&!Z.ready?(0,S.jsx)(`p`,{role:`status`,className:`improvement-demo__notice`,children:x.bridgeUnavailable}):null,(0,S.jsxs)(`div`,{className:`improvement-demo__filters`,children:[(0,S.jsxs)(b.ActionMenu,{size:`small`,selectionVariant:`single`,menuAlignment:`start`,onSelect:he,children:[(0,S.jsx)(b.ActionMenu.Button,{size:`small`,variant:`secondary`,"aria-label":`${x.filter}: ${je}`,children:je}),(0,S.jsx)(b.ActionMenu.Overlay,{"aria-label":x.filter,children:[{value:`active`,label:x.allActive},{value:`ready`,label:x.readyFilter},{value:`resolved`,label:x.resolvedFilter}].map(e=>(0,S.jsx)(b.ActionMenu.Item,{value:e.value,selected:M===e.value,role:`menuitemradio`,onKeyDownCapture:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.click())},children:e.label},e.value))})]}),M===`active`?(0,S.jsx)(b.Button,{size:`small`,variant:`primary`,className:`improvement-demo__fix-all`,leadingVisual:(0,S.jsx)(l,{}),"aria-label":x.fixAll(J.length),disabled:!J.length||Ne||s.busy,title:Ne?Q?x.productionBusy:x.fixBusy:void 0,onClick:()=>void Ge(),children:(0,S.jsxs)(`span`,{className:`improvement-demo__fix-label`,children:[x.fix,(0,S.jsx)(te,{children:J.length})]})}):null]}),(0,S.jsxs)(`div`,{className:`improvement-demo__note-list`,children:[Me.length?null:(0,S.jsxs)(`div`,{className:`improvement-demo__empty`,children:[(0,S.jsx)(d,{size:28}),(0,S.jsx)(`h2`,{children:p.length?x.emptyFilter:x.empty}),p.length?null:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`p`,{children:x.emptyBody}),(0,S.jsx)(b.Button,{size:`small`,variant:`secondary`,leadingVisual:(0,S.jsx)(a,{}),disabled:Q&&(!Z.ready||!Y),onClick:()=>{v(!0),w(!1),K.current?.focus()},children:x.annotate})]})]}),Me.map(e=>(0,S.jsxs)(`article`,{"aria-label":`Improvement note ${e.id}`,className:`improvement-demo__note${be===e.id?` improvement-demo__note--focused`:``}`,children:[(0,S.jsxs)(`div`,{className:`improvement-demo__note-header`,children:[e.status===`ready`?(0,S.jsx)(`span`,{className:`improvement-demo__status improvement-demo__status--ready`,children:x.statuses.ready}):null,(0,S.jsx)(`p`,{className:`improvement-demo__body`,children:e.body}),(0,S.jsx)(`div`,{className:`improvement-demo__note-menu`,children:(0,S.jsxs)(b.ActionMenu,{selectionVariant:`none`,size:`small`,menuAlignment:`end`,children:[(0,S.jsx)(b.ActionMenu.Button,{className:`improvement-demo__menu-trigger`,variant:`subtle`,"aria-label":x.noteActions(e.target),leadingVisual:(0,S.jsx)(n,{size:16}),children:``}),(0,S.jsxs)(b.ActionMenu.Overlay,{"aria-label":x.noteActions(e.target),children:[(0,S.jsx)(b.ActionMenu.Item,{value:`edit`,className:`improvement-demo__menu-item`,leadingVisual:(0,S.jsx)(d,{size:16}),disabled:e.status===`ready`,title:e.status===`ready`?x.readyReadOnly:void 0,onClick:()=>{e.status===`ready`?I(x.readyReadOnly):(E({...e,identity:s.state?.identity,noteRevision:e.revision,originalBody:e.body}),O(e.id),A(e.body))},onKeyDownCapture:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.click())},children:x.editAction}),(0,S.jsx)(b.ActionMenu.Item,{value:`delete`,className:`improvement-demo__menu-item improvement-demo__delete-item`,leadingVisual:(0,S.jsx)(c,{size:16}),onClick:()=>me({id:e.id,revision:e.revision,body:e.body,identity:s.state?.identity}),onKeyDownCapture:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.click())},children:x.deleteAction})]})]})})]}),(0,S.jsxs)(`div`,{className:`improvement-demo__note-meta`,children:[(0,S.jsx)(`span`,{children:e.target}),(0,S.jsx)(`span`,{className:`improvement-demo__note-separator`,"aria-hidden":`true`}),(0,S.jsx)(`button`,{className:`improvement-demo__note-route`,type:`button`,"aria-label":`${x.viewTarget}: ${e.target} (${e.route})`,onClick:()=>{if(t&&e.anchor){let n=new URL(t.prototypeUrl);n.pathname=e.anchor.route.pathname,n.search=e.anchor.route.search,n.hash=e.anchor.route.hash,t.onNavigate(n.href)}else ee(e.route);L(e.id)},children:(0,S.jsx)(`code`,{children:e.route})})]}),e.status!==`open`&&e.status!==`ready`?(0,S.jsx)(`span`,{className:`improvement-demo__status improvement-demo__status--${e.status}`,children:x.statuses[e.status]}):null,e.status===`ready`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`details`,{className:`improvement-demo__solution`,children:[(0,S.jsxs)(`summary`,{children:[(0,S.jsx)(i,{size:14,"aria-hidden":`true`}),x.solution]}),(0,S.jsx)(`p`,{children:e.result||(Q?x.solutionUnavailable:x.noteReady)})]}),(0,S.jsx)(`p`,{className:`improvement-demo__read-only`,children:x.readyReadOnly})]}):e.result?(0,S.jsx)(`p`,{className:`improvement-demo__result`,children:e.result}):null,e.capture&&!e.capturePlaceholder?(0,S.jsx)(`img`,{className:`improvement-demo__thumbnail`,src:e.capture,alt:`${e.capturePlaceholder?x.capturePlaceholder:x.capture}: ${e.target}`}):null,!Q&&(e.status===`sent`||e.status===`blocked`)?(0,S.jsx)(`p`,{className:`improvement-demo__result`,children:e.status===`sent`?x.noteSent:x.noteBlocked}):null,(0,S.jsxs)(`div`,{className:`improvement-demo__note-actions`,children:[Q&&e.status===`sent`?(0,S.jsx)(b.Button,{size:`small`,variant:`secondary`,onClick:()=>void $(e,`open`),children:x.returnToActive}):null,e.status===`ready`?(0,S.jsx)(b.Button,{size:`small`,variant:`secondary`,leadingVisual:(0,S.jsx)(f,{}),onClick:()=>$(e,`resolved`),children:x.resolve}):null,e.status===`resolved`?(0,S.jsx)(b.Button,{size:`small`,variant:`secondary`,onClick:()=>$(e,`open`),children:x.reopen}):null,e.status===`blocked`?(0,S.jsx)(b.Button,{size:`small`,variant:`secondary`,onClick:()=>$(e,`open`),children:x.retryFix}):null]}),!Q&&e.status===`sent`?(0,S.jsxs)(`details`,{className:`improvement-demo__simulation`,children:[(0,S.jsx)(`summary`,{children:x.perNoteResult}),(0,S.jsx)(b.Button,{size:`small`,variant:`secondary`,onClick:()=>$(e,`ready`),children:x.complete}),(0,S.jsx)(b.Button,{size:`small`,variant:`secondary`,onClick:()=>$(e,`blocked`),children:x.block})]}):null,Q?null:(0,S.jsx)(`small`,{className:e.sync===`failed`?`improvement-demo__sync-error`:``,children:x.sync[e.sync]})]},e.id))]}),!Q&&Ne?(0,S.jsx)(b.Button,{size:`small`,variant:`secondary`,onClick:()=>F(!0),children:x.batchLabel(P.length)}):null,Q?null:(0,S.jsxs)(`footer`,{className:`improvement-demo__connection`,children:[(0,S.jsxs)(`label`,{children:[x.syncControls,(0,S.jsxs)(`select`,{value:N,onChange:e=>{let t=e.target.value;(t===`offline`||t===`connected`||t===`failed`)&&(ge(t),t!==`offline`&&o(e=>e.map(e=>({...e,sync:t===`connected`?`synced`:`failed`}))))},children:[(0,S.jsx)(`option`,{value:`offline`,children:x.offline}),(0,S.jsx)(`option`,{value:`connected`,children:x.connected}),(0,S.jsx)(`option`,{value:`failed`,children:x.syncFailure})]})]}),p.some(e=>e.sync===`failed`)?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`p`,{children:x.syncFailed}),(0,S.jsx)(b.Button,{size:`small`,variant:`secondary`,onClick:()=>{ge(`connected`),o(e=>e.map(e=>({...e,sync:`synced`}))),I(x.syncSuccess)},children:x.syncRetry})]}):null]})]})]}),(0,S.jsx)(`p`,{className:`improvement-demo__announcement${Q?` visually-hidden`:``}`,role:`status`,children:ye}),De?(0,S.jsxs)(g,{title:D===null?x.add:x.edit,closeLabel:x.closeComposer,returnFocusRef:K,onClose:Ue,className:`improvement-demo__composer`,children:[s.error?(0,S.jsx)(`p`,{role:`alert`,className:`improvement-demo__notice`,children:s.error}):null,Oe?(0,S.jsx)(`p`,{role:`alert`,className:`improvement-demo__notice`,children:x.branchChanged}):null,ke?(0,S.jsx)(`p`,{role:`alert`,className:`improvement-demo__notice`,children:x.readyReadOnly}):null,(0,S.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),We()},children:[(0,S.jsxs)(b.FormControl,{fullWidth:!0,children:[(0,S.jsx)(b.FormControl.Label,{children:x.label}),(0,S.jsx)(b.Textarea,{ref:Te,value:k,maxLength:1e4,rows:4,placeholder:x.placeholder,readOnly:ke,onChange:e=>A(e.target.value),required:!0})]}),(0,S.jsx)(`div`,{className:`improvement-demo__dialog-actions`,children:(0,S.jsx)(b.Button,{type:`submit`,size:`small`,variant:`primary`,disabled:!k.trim()||s.busy||Oe||ke,children:D===null?x.save:x.saveEdit})})]})]}):null,fe&&Y?(0,S.jsxs)(g,{title:x.discardTitle,closeLabel:x.closeDiscard,returnFocusRef:K,onClose:()=>pe(!1),children:[(0,S.jsx)(`p`,{children:x.discardBody}),(0,S.jsxs)(`div`,{className:`improvement-demo__dialog-actions`,children:[(0,S.jsx)(b.Button,{size:`small`,variant:`secondary`,onClick:()=>pe(!1),children:x.keep}),(0,S.jsx)(b.Button,{size:`small`,variant:`primary`,onClick:()=>{pe(!1),E(null),O(null),A(``)},children:x.discard})]})]}):null,j!==null&&Y?(0,S.jsxs)(g,{title:x.deleteTitle,closeLabel:x.closeDelete,returnFocusRef:q,onClose:()=>me(null),children:[(0,S.jsx)(`p`,{children:x.deleteBody}),(0,S.jsx)(`blockquote`,{className:`improvement-demo__delete-preview`,children:j.body}),(0,S.jsxs)(`div`,{className:`improvement-demo__dialog-actions`,children:[(0,S.jsx)(b.Button,{size:`small`,variant:`secondary`,onClick:()=>me(null),children:x.cancel}),(0,S.jsx)(b.Button,{size:`small`,variant:`primary`,className:`improvement-demo__delete-confirm`,onClick:async()=>{(!t?.token||await s.change(`delete`,{id:j.id,identity:j.identity,expectedNoteRevision:j.revision}))&&(o(e=>e.filter(e=>e.id!==j.id)),me(null),L(null))},children:x.deleteAction})]})]}):null,ve?(0,S.jsxs)(g,{title:x.handoff,closeLabel:x.closeBatch,returnFocusRef:q,onClose:()=>F(!1),className:`improvement-demo__handoff`,children:[(0,S.jsx)(`p`,{children:x.handoffNotice}),(0,S.jsxs)(`div`,{className:`improvement-demo__batch-context`,children:[(0,S.jsx)(`code`,{children:t?.branch??x.branch}),(0,S.jsxs)(`span`,{children:[Q?x.canvasBatchSource:x.sampleBatchSource,` · `,P.length,` notes`]})]}),(0,S.jsx)(`ol`,{children:P.map(e=>(0,S.jsxs)(`li`,{children:[(0,S.jsxs)(`strong`,{children:[`#`,e.id,` · `,e.target]}),(0,S.jsxs)(`code`,{children:[e.route,` · revision `,e.revision]}),(0,S.jsx)(`p`,{children:e.body}),(0,S.jsx)(`img`,{className:`improvement-demo__thumbnail`,src:e.capture,alt:`${e.capturePlaceholder?x.capturePlaceholder:x.capture}: ${e.target}`}),(0,S.jsx)(`code`,{children:e.selector??`Region: ${e.rect.x}, ${e.rect.y}, ${e.rect.width} × ${e.rect.height}`})]},`${e.id}-${e.revision}`))}),(0,S.jsx)(`p`,{className:`improvement-demo__form-hint`,children:x.batchHint}),(0,S.jsxs)(`div`,{className:`improvement-demo__dialog-actions`,children:[(0,S.jsx)(b.Button,{size:`small`,variant:`secondary`,onClick:()=>F(!1),children:x.closeHandoff}),(0,S.jsx)(b.Button,{size:`small`,variant:`secondary`,onClick:()=>Ke(`blocked`),children:x.block}),(0,S.jsx)(b.Button,{size:`small`,variant:`primary`,onClick:()=>Ke(`ready`),children:x.complete})]})]}):null]})}export{w as t}; \ No newline at end of file +import{n as e,r as t}from"./renderer-rolldown-runtime.js";import{E as n,K as r,L as i,M as a,X as o,Y as s,f as c,g as l,q as u,x as d,z as f}from"./renderer-vendor.js";import{a as p,c as m,f as h,m as g,o as _,p as ee,s as v}from"./renderer.js";import{t as y}from"./renderer-improvement-notes-vendor.js";import{t as te}from"./renderer-prototype-canvas-improvement-threads.js";var b=t(o(),1),ne=s(),x=r(),re=y(),S={title:`Pick & polish`,localAuthor:`Local author`,branch:`prototype/welcome`,demo:`UI prototype`,demoNotice:`Sample preview. Notes reset on reload. No Hub API calls or agent work.`,canvasDemoNotice:`UI-only notes over the live preview. Notes reset on canvas reload. Captures, Hub sync and agent results are simulated.`,canvasBatchSource:`Live preview · UI-only batch`,sampleBatchSource:`Local, uncommitted sample`,bridgeUnavailable:`Annotation needs the updated Replica preview bridge. Reconnect or reload the preview after updating the canvas.`,capturePlaceholder:`UI-only capture placeholder`,sourceUnavailable:`You can still save this improvement locally, but it cannot sync without a captured source.`,annotate:`Pick & polish`,fix:`Fix all`,openNotes:e=>`Open improvement notes (${e})`,fixAll:e=>`Fix all (${e})`,notes:`Pick & polish`,closeNotes:`Close pick & polish`,owner:`Only your notes appear here. Authorized API callers can request other authors' notes.`,selectHint:`Click an element or drag a rectangle. For a keyboard region, focus the preview, press Shift+Enter, then use arrows and Enter to choose two corners. Escape exits annotation mode.`,keyboardHint:`Click an element or drag a rectangle. Focus the preview and press Shift+Enter for keyboard region selection; arrows move the corner and Enter selects it.`,regionHint:`Choose two corners in the preview. Use arrow keys to move the corner, then Enter.`,firstCorner:`First corner selected. Choose the second corner.`,regionSmall:`Choose a larger region, at least 8 preview pixels wide and high.`,add:`Add improvement note`,edit:`Edit improvement note`,label:`What should change?`,placeholder:`Describe the improvement you want Copilot to make...`,save:`Save note`,saveEdit:`Save changes`,cancel:`Cancel`,discard:`Discard draft`,keep:`Keep writing`,discardTitle:`Discard your unsaved note?`,discardBody:`Your saved notes will stay unchanged.`,capture:`Captured target`,empty:`A little feedback goes a long way`,emptyBody:`Select an element or draw around an area. Collect notes across screens, then fix them together.`,emptyFilter:`No notes in this view.`,allActive:`Active notes`,readyFilter:`Ready to review`,resolvedFilter:`Resolved`,filter:`Filter improvement notes`,viewTarget:`View target`,noteActions:e=>`Note actions: ${e}`,editAction:`Edit`,deleteAction:`Delete`,deleteTitle:`Delete this improvement note?`,deleteBody:`This removes the note. It does not change the prototype.`,resolve:`Confirm resolved`,solution:`Solution`,solutionUnavailable:`The solution summary is not available in this canvas.`,readyReadOnly:`Ready notes are read-only. Add a new note to request further changes.`,reopen:`Reopen`,retryFix:`Retry fix`,noteSent:`Sent in the simulated batch. No real agent has started.`,noteReady:`Simulated change is ready. Review the target before resolving.`,noteBlocked:`Simulated agent could not safely identify the change. Edit the note or retry.`,handoff:`Demo handoff to Copilot`,handoffNotice:`This is the captured batch, not a live agent request. New notes stay out of this batch.`,complete:`Simulate ready to review`,block:`Simulate blocked`,closeHandoff:`Continue annotating`,sent:`Demo batch captured. No code was changed.`,finished:`Simulated result received. Review each note before resolving.`,fixBusy:`Finish or close the current simulated batch before sending another.`,syncControls:`Demo connection`,offline:`Offline`,connected:`Connected`,syncFailure:`Sync failure`,syncRetry:`Retry demo sync`,syncFailed:`Demo sync failed. Your note remains in this demo; retry when connected.`,syncSuccess:`Demo sync completed.`,targetMissing:`This sample target is no longer available. The saved capture is still shown.`,previewUnavailable:`The demo preview is unavailable. Try selecting the target again.`,saved:`Note added.`,savedLocally:`Notes are saved locally.`,storageLoading:`Loading your notes...`,productionSent:`Notes sent to Copilot. Review the changes before confirming resolution.`,productionBusy:`Copilot is working on the captured batch.`,branchChanged:`The prototype branch changed. Close this draft and select the target again.`,workChanged:`The open improvements changed while syncing. Review them and select Fix all again.`,returnToActive:`Return to active`,regionTarget:`Selected region`,closeComposer:`Close note composer`,closeDiscard:`Close discard confirmation`,closeDelete:`Close delete confirmation`,closeBatch:`Close demo handoff`,exit:`Exit annotation mode`,sampleScreens:`Sample prototype screens`,sampleWorkspace:`Octocat's workspace`,projects:`Projects`,settings:`Settings`,navigationHint:`Navigate between screens. Your notes stay together.`,authorContext:`Across this prototype · Demo author: octocat`,batchHint:`Fix only this batch. Do not commit, push, or publish. Report per-note results for the author to review.`,perNoteResult:`Simulate a result for this note`,batchLabel:e=>`View demo batch (${e})`,statuses:{open:`Open`,sent:`Sent to Copilot`,ready:`Ready to review`,resolved:`Resolved`,blocked:`Needs attention`},sync:{local:`Demo: local only`,synced:`Demo: synced`,failed:`Demo: sync failed`}};function ie(e,t){let n=[e.thread?.originalStatus??e.status,...e.thread?.messages.filter(e=>e.role===`author`).map(e=>e.status)??[]];return{id:e.id,revision:e.revision,body:e.body,capture:e.capture,author:e.thread?.originalAuthor?`@${e.thread.originalAuthor.login}`:e.author===`local`?S.localAuthor:`@${e.author}`,avatarUrl:(e.thread?.originalAuthor??e.authorProfile)?.avatarUrl,target:e.target,path:e.route,status:e.status,originalPending:(e.thread?.originalStatus??e.status)===`open`,...n.includes(`sent`)?{retryStatus:`sent`}:n.includes(`blocked`)?{retryStatus:`blocked`}:{},messages:e.thread?.messages.map(e=>({...e,...e.role===`author`&&e.author?{author:`@${e.author.login}`,avatarUrl:e.author.avatarUrl}:{author:void 0},pending:e.role===`author`&&e.status===`open`}))??(e.result?[{id:`legacy-result`,role:`copilot`,body:e.result,status:e.status===`blocked`?`blocked`:`ready`}]:[]),...t&&(t.status===`resolved`||t.status===`moved`)?{point:t.point}:{}}}function ae(e,t){let n=e.cloneNode(!0);if(!(n instanceof SVGSVGElement))throw Error(`The demo preview could not be captured.`);return n.setAttribute(`viewBox`,`${t.x} ${t.y} ${t.width} ${t.height}`),n.setAttribute(`width`,String(t.width)),n.setAttribute(`height`,String(t.height)),n.removeAttribute(`class`),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}var oe=[{id:`projects-heading`,label:`Projects heading`,route:`/projects`,rect:{x:40,y:35,width:640,height:78}},{id:`new-project`,label:`New project button`,route:`/projects`,rect:{x:764,y:42,width:156,height:42}},{id:`activity`,label:`Activity summary`,route:`/projects`,rect:{x:40,y:144,width:880,height:100}},{id:`welcome-card`,label:`Welcome project card`,route:`/projects`,rect:{x:40,y:285,width:420,height:230}},{id:`onboarding-card`,label:`Onboarding project card`,route:`/projects`,rect:{x:500,y:285,width:420,height:230}},{id:`settings-heading`,label:`Settings heading`,route:`/settings`,rect:{x:40,y:35,width:700,height:78}},{id:`workspace-name`,label:`Workspace name field`,route:`/settings`,rect:{x:40,y:152,width:880,height:138}},{id:`notifications`,label:`Notifications settings`,route:`/settings`,rect:{x:40,y:318,width:880,height:130}},{id:`save-settings`,label:`Save settings button`,route:`/settings`,rect:{x:40,y:478,width:166,height:42}}],se=[{id:1,kind:`improvement_note`,author:`octocat`,body:`Make the primary action more prominent and shorten the label to 'New project'.`,route:`/projects`,target:`New project button`,selector:`[data-improvement-target="new-project"]`,rect:{x:764,y:42,width:156,height:42},capture:``,status:`open`,sync:`local`,revision:1},{id:2,kind:`improvement_note`,author:`octocat`,body:`Give the two cards a little more breathing room and align their metadata.`,route:`/projects`,target:`Selected region`,selector:null,rect:{x:28,y:273,width:904,height:250},capture:``,status:`open`,sync:`local`,revision:1},{id:3,kind:`improvement_note`,author:`octocat`,body:`Explain what notifications this switch controls before asking me to enable it.`,route:`/settings`,target:`Notifications settings`,selector:`[data-improvement-target="notifications"]`,rect:{x:40,y:318,width:880,height:130},capture:``,status:`ready`,sync:`synced`,revision:1}],C=u();function ce({route:e}){return(0,C.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 960 560`,className:`improvement-demo__scene`,role:`group`,"aria-label":`Sample prototype ${e}`,fontFamily:`system-ui, sans-serif`,children:[(0,C.jsx)(`rect`,{width:`960`,height:`560`,fill:`#f8fafc`}),oe.filter(t=>t.route===e).map(t=>(0,C.jsxs)(`g`,{"data-improvement-target":t.id,children:[(0,C.jsx)(`rect`,{...t.rect,rx:`10`,fill:t.id.includes(`heading`)?`#f8fafc`:t.id===`new-project`||t.id===`save-settings`?`#155d3d`:`#ffffff`,stroke:t.id.includes(`heading`)?`none`:`#dce3e9`}),t.id.includes(`heading`)?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`text`,{x:`40`,y:`67`,fill:`#172b24`,fontSize:`28`,fontWeight:`650`,children:e===`/projects`?`Your projects`:`Workspace settings`}),(0,C.jsx)(`text`,{x:`40`,y:`99`,fill:`#596b65`,fontSize:`15`,children:e===`/projects`?`A home for your team's next great idea.`:`Make this space work for your team.`})]}):t.id===`new-project`||t.id===`save-settings`?(0,C.jsx)(`text`,{x:t.rect.x+t.rect.width/2,y:t.rect.y+26,textAnchor:`middle`,fill:`#ffffff`,fontSize:`14`,fontWeight:`600`,children:t.id===`new-project`?`+ Create project`:`Save settings`}):t.id===`activity`?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`text`,{x:`64`,y:`179`,fill:`#596b65`,fontSize:`13`,children:`THIS WEEK`}),(0,C.jsx)(`text`,{x:`64`,y:`214`,fill:`#172b24`,fontSize:`23`,fontWeight:`600`,children:`12 prototypes`}),(0,C.jsx)(`text`,{x:`348`,y:`179`,fill:`#596b65`,fontSize:`13`,children:`IN REVIEW`}),(0,C.jsx)(`text`,{x:`348`,y:`214`,fill:`#172b24`,fontSize:`23`,fontWeight:`600`,children:`4 conversations`}),(0,C.jsx)(`text`,{x:`642`,y:`179`,fill:`#596b65`,fontSize:`13`,children:`YOUR TEAM`}),(0,C.jsx)(`text`,{x:`642`,y:`214`,fill:`#172b24`,fontSize:`23`,fontWeight:`600`,children:`Making things happen`})]}):t.id.includes(`card`)?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`rect`,{x:t.rect.x+16,y:`301`,width:`388`,height:`100`,rx:`6`,fill:t.id===`welcome-card`?`#e3efe9`:`#eee9f7`}),(0,C.jsx)(`rect`,{x:t.rect.x+40,y:`323`,width:`100`,height:`10`,rx:`4`,fill:`#ffffff`}),(0,C.jsx)(`rect`,{x:t.rect.x+40,y:`345`,width:`196`,height:`6`,rx:`3`,fill:`#ffffff`}),(0,C.jsx)(`rect`,{x:t.rect.x+40,y:`363`,width:`156`,height:`6`,rx:`3`,fill:`#ffffff`}),(0,C.jsx)(`text`,{x:t.rect.x+24,y:`437`,fill:`#172b24`,fontSize:`18`,fontWeight:`600`,children:t.id===`welcome-card`?`Welcome experience`:`A better onboarding`}),(0,C.jsx)(`text`,{x:t.rect.x+24,y:`463`,fill:`#596b65`,fontSize:`13`,children:t.id===`welcome-card`?`prototype/welcome`:`prototype/onboarding`}),(0,C.jsx)(`circle`,{cx:t.rect.x+30,cy:`490`,r:`5`,fill:`#2a7954`}),(0,C.jsx)(`text`,{x:t.rect.x+44,y:`495`,fill:`#596b65`,fontSize:`12`,children:`Updated today · The Octocat`})]}):t.id===`workspace-name`?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`text`,{x:`64`,y:`184`,fill:`#172b24`,fontSize:`17`,fontWeight:`600`,children:`Workspace name`}),(0,C.jsx)(`text`,{x:`64`,y:`209`,fill:`#596b65`,fontSize:`13`,children:`This is how your workspace appears to your team.`}),(0,C.jsx)(`rect`,{x:`64`,y:`230`,width:`600`,height:`38`,rx:`6`,fill:`#f8fafc`,stroke:`#dce3e9`}),(0,C.jsx)(`text`,{x:`78`,y:`255`,fill:`#172b24`,fontSize:`14`,children:`Octocat's workspace`})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`text`,{x:`64`,y:`351`,fill:`#172b24`,fontSize:`17`,fontWeight:`600`,children:`Notifications`}),(0,C.jsx)(`text`,{x:`64`,y:`385`,fill:`#596b65`,fontSize:`14`,children:`Keep me in the loop`}),(0,C.jsx)(`rect`,{x:`824`,y:`366`,width:`48`,height:`26`,rx:`13`,fill:`#155d3d`}),(0,C.jsx)(`circle`,{cx:`857`,cy:`379`,r:`9`,fill:`#ffffff`})]})]},t.id))]})}function le(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ue({frameRef:e,prototypeUrl:t,previewUrl:n,notes:r,annotating:i,composing:a,onSelect:o,onRoute:s,onCancel:c,onProblem:l}){let u=n??t,[d,f]=(0,b.useState)(null),[p,h]=(0,b.useState)(new Map),g=JSON.stringify(r.filter(e=>e.anchor).slice(0,200).map(e=>({id:e.id,anchor:e.anchor}))),ee=(0,b.useEffectEvent)(e=>{if(!i||a)return;let t=v.safeParse(e);t.success?o(t.data):(c(),l(S.previewUnavailable))}),y=(0,b.useCallback)((t,n={})=>{u&&d&&e?.current?.contentWindow&&e.current.contentWindow.postMessage({type:t,nonce:d.nonce,...n},new URL(u).origin)},[d,e,u]);return(0,b.useEffect)(()=>{let t=e?.current;if(!t||!u)return;let n=new URL(u).origin,r=crypto.randomUUID(),i=Date.now(),a=JSON.parse(g);function o(){t?.contentWindow?.postMessage({type:`replica:canvas:request-ready`,nonce:r},n),t?.contentWindow?.postMessage({type:`replica:canvas:resolve`,nonce:r,anchors:a},n)}function d(){r=crypto.randomUUID(),i=Date.now(),f({nonce:r,ready:!1}),h(new Map),c(),o()}function p(e){let a=e.data;if(e.source===t?.contentWindow&&e.origin===n&&le(a)&&a.nonce===r){if(a.type===`replica:canvas:ready`){let e=m.safeParse(a.route);if(a.protocolVersion!==1||a.improvementSelection!==!0||!e.success){f({nonce:r,ready:!1}),l(S.bridgeUnavailable);return}i=Date.now(),f(e=>e?.nonce===r&&e.ready?e:{nonce:r,ready:!0}),s(e.data.pathname+e.data.search+e.data.hash)}else if(a.type===`replica:canvas:selected`)ee(a.anchor);else if(a.type===`replica:canvas:resolved`&&Array.isArray(a.results)){let e=new Map;for(let t of a.results){if(!le(t))continue;let n=_.safeParse({commentId:t.id,status:`resolved`,point:{x:t.x,y:t.y},rect:t.rect??{x:t.x,y:t.y,width:1,height:1}});n.success&&e.set(n.data.commentId,n.data)}h(e)}else a.type===`replica:canvas:selection-failed`||a.type===`replica:canvas:bridge-error`?(c(),l(a.reason===`area-too-small`?S.regionSmall:S.bridgeUnavailable)):a.type===`replica:canvas:selection-cancelled`?a.reason!==`command`&&c():a.type===`replica:canvas:conversation-dismiss-requested`&&window.dispatchEvent(new Event(`replica:review-dismiss`))}}t.addEventListener(`load`,d),window.addEventListener(`message`,p),f({nonce:r,ready:!1}),o();let v=window.setInterval(()=>{Date.now()-i>2e4&&(f({nonce:r,ready:!1}),h(new Map),c(),l(S.bridgeUnavailable)),o()},2e3);return()=>{t.removeEventListener(`load`,d),window.removeEventListener(`message`,p),window.clearInterval(v),t.contentWindow?.postMessage({type:`replica:canvas:cancel-selection`,nonce:r},n),t.contentWindow?.postMessage({type:`replica:canvas:clear-selection`,nonce:r},n)}},[g,e,u,c,l,s]),(0,b.useEffect)(()=>{d?.ready&&(i&&!a?y(`replica:canvas:select`,{mode:`improvement`}):y(`replica:canvas:cancel-selection`),a||y(`replica:canvas:clear-selection`))},[i,a,d?.ready,y]),{ready:d?.ready===!0,resolutions:p}}function de(e){let[t,n]=(0,b.useState)(null),[r,i]=(0,b.useState)(``),[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(!1),l=(0,b.useRef)(null),u=(0,b.useRef)(!1),d=(0,b.useRef)(null),f=(0,b.useRef)(!1),m=(0,b.useRef)(0);function h(e){f.current&&(l.current=e,n(e))}(0,b.useEffect)(()=>{if(!e)return;f.current=!0;let t=!1,r=!1,a=0;async function s(){if(u.current||r)return;r=!0;let s=m.current;try{let n=await p(`/api/improvement-notes`,e);if(u.current||s!==m.current||t)return;if(h(n),Date.now()-a>15e3){a=Date.now();let r=p(`/api/improvement-notes/sync`,e,{method:`POST`,body:JSON.stringify({identity:n.identity,revision:n.revision})}).then(e=>{t||h(e)});d.current=r;try{await r}finally{d.current===r&&(d.current=null)}}t||o(``)}catch(e){t||(e instanceof Error&&`statusCode`in e&&e.statusCode===403&&(l.current=null,n(null),i(``)),o(e instanceof Error?e.message:String(e)))}finally{r=!1}}s();let c=window.setInterval(()=>void s(),3e3);return()=>{f.current=!1,t=!0,window.clearInterval(c)}},[e]);async function g(t,n={}){if(!e||!l.current||u.current)return!1;let r=l.current.identity,a=l.current.notes.filter(e=>e.status===`open`).map(e=>`${e.id}:${e.revision}`).sort().join(`,`);u.current=!0,m.current++,c(!0),i(``);try{if(await d.current,!f.current)return!1;if(!l.current||l.current.identity!==r)throw Error(S.branchChanged);if(t===`fix`&&l.current.notes.filter(e=>e.status===`open`).map(e=>`${e.id}:${e.revision}`).sort().join(`,`)!==a)throw Error(S.workChanged);return h(await p(t===`fix`?`/api/improvement-notes/fix`:`/api/improvement-notes`,e,{method:`POST`,body:JSON.stringify({identity:l.current.identity,revision:l.current.revision,operation:t,...n})})),!0}catch(e){return f.current&&i(e instanceof Error?e.message:String(e)),!1}finally{u.current=!1,f.current&&c(!1)}}async function _(){if(!e)return null;i(``);try{return await p(`/api/improvement-notes/capture`,e,{method:`POST`})}catch(e){return i(`${e instanceof Error?e.message:String(e)} ${S.sourceUnavailable}`),null}}return{state:t,error:r||a,busy:s,change:g,capture:_}}var fe=e({ImprovementNotesPrototype:()=>pe});function pe({initial:e=`empty`,canvas:t}){let[r,o]=(0,b.useState)(()=>se.slice(0,e===`empty`?0:e===`single`?1:3).map(e=>{let t=new DOMParser().parseFromString((0,re.renderToStaticMarkup)((0,C.jsx)(ce,{route:e.route})),`image/svg+xml`).documentElement;if(!(t instanceof SVGSVGElement))throw Error(`The sample preview could not be captured.`);return{...e,capture:ae(t,e.rect)}})),s=de(t?.token),u=s.state?.syncError===`Notes are saved locally until Hub discovers this branch.`?null:s.state?.syncError,p=t?.token?s.state?.notes??[]:r,[m,_]=(0,b.useState)(`/projects`),[v,y]=(0,b.useState)(!1),[le,fe]=(0,b.useState)(!1),[pe,me]=(0,b.useState)(null),he=(0,b.useRef)(0),[ge,w]=(0,b.useState)(!0),[T,E]=(0,b.useState)(null),[D,O]=(0,b.useState)(null),[k,A]=(0,b.useState)(``),[_e,ve]=(0,b.useState)(!1),[j,ye]=(0,b.useState)(null),[M,N]=(0,b.useState)(`active`),[P,be]=(0,b.useState)(`offline`),[F,xe]=(0,b.useState)([]),[Se,I]=(0,b.useState)(!1),[Ce,L]=(0,b.useState)(``),[we,R]=(0,b.useState)(null),[z,B]=(0,b.useState)(!1),[V,Te]=(0,b.useState)({x:160,y:160}),[H,U]=(0,b.useState)(null),[Ee,De]=(0,b.useState)(null),[W,G]=(0,b.useState)(null),K=(0,b.useRef)(null),Oe=(0,b.useRef)(null),q=(0,b.useRef)(null),ke=(0,b.useRef)(null),J=(0,b.useRef)(null),Ae=(0,b.useRef)(e===`empty`?1:e===`single`?2:4),Y=p.filter(e=>e.status===`open`),X=!t?.token||s.state!==null,je=T!==null&&!_e&&X;(0,b.useLayoutEffect)(()=>{je&&ke.current?.focus()},[je]);let Me=!!t?.token&&T!==null&&T.identity!==s.state?.identity,Ne=D!==null&&p.some(e=>e.id===D&&e.status===`ready`),Pe=p.filter(e=>e.status!==`resolved`).length,Fe=M===`ready`?S.readyFilter:M===`resolved`?S.resolvedFilter:S.allActive,Ie=p.filter(e=>M===`resolved`?e.status===`resolved`:M===`ready`?e.status===`ready`:e.status!==`resolved`),Le=!!s.state?.activeBatch||F.some(e=>p.some(t=>t.id===e.id&&t.revision===e.revision&&t.status===`sent`)),Re=p.filter(e=>e.route===m&&e.status!==`resolved`),ze=p.find(e=>e.id===we&&e.route===m),Be=(0,b.useCallback)(e=>{let t=e.kind===`element`?e.accessibleName||e.tagName:S.regionTarget;E({identity:pe?.identity??s.state?.identity,sourceId:pe?.sourceId,anchor:e,route:e.route.pathname+e.route.search+e.route.hash,target:t,selector:e.kind===`element`?e.selector:null,rect:e.rect,capture:``,capturePlaceholder:!0}),O(null),A(``)},[s.state?.identity,pe]),Ve=(0,b.useCallback)(()=>{he.current++,fe(!1),q.current?.getAttribute(`aria-pressed`)===`true`&&q.current.focus(),y(!1)},[]);async function He(){let e=++he.current;fe(!0);let n=t?.token?await s.capture():null;e===he.current&&(fe(!1),me(n),y(!0),w(!1),L(S.selectHint),B(!1),U(null),G(null))}let Ue=t?.frameRef,Z=ue({frameRef:Ue,prototypeUrl:t?.prototypeUrl,previewUrl:t?.previewUrl,notes:p,annotating:v,composing:T!==null,onSelect:Be,onRoute:_,onCancel:Ve,onProblem:L}),Q=!!t;(0,b.useLayoutEffect)(()=>{Ue&&De(Ue.current?.closest(`.canvas-shell`)?.querySelector(`#canvas-improvement-controls`)??null)},[Ue]);function We(){w(!0),t?.onOpenNotes()}function Ge(e,t){let n=Oe.current?.querySelector(`svg`);n?(E({route:m,target:t?.label??S.regionTarget,selector:t?`[data-improvement-target="${t.id}"]`:null,rect:e,capture:ae(n,e)}),A(``),O(null),G(null),U(null),B(!1)):L(S.previewUnavailable)}function Ke(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function qe(e){let t=Oe.current?.getBoundingClientRect();return!t?.width||!t.height?(L(S.previewUnavailable),null):{x:Math.max(0,Math.min(960,(e.clientX-t.left)/t.width*960)),y:Math.max(0,Math.min(560,(e.clientY-t.top)/t.height*560))}}function Je(e,t){let n=Ke(e,t);G(null),U(null),n.width<8||n.height<8?L(S.regionSmall):Ge(n)}function Ye(){let e=T?.originalBody??``;k===e?(E(null),O(null),t?.token&&Ve()):ve(!0)}async function Xe(){if(Ne){L(S.readyReadOnly);return}if(!T||!k.trim()||s.busy||Me)return;if(t?.token){if(!await s.change(D===null?`create`:`edit`,{id:D,identity:T.identity,sourceId:T.sourceId,expectedNoteRevision:T.noteRevision,body:k.trim(),anchor:T.anchor,capture:T.capturePlaceholder?``:T.capture}))return;N(`active`),We(),Ve(),E(null),O(null),L(S.saved);return}let e=P===`connected`?`synced`:P===`failed`?`failed`:`local`;if(D!==null)o(t=>t.map(t=>t.id===D?{...t,body:k.trim(),revision:t.revision+1,status:`open`,sync:e}:t));else{let t={...T,id:Ae.current++,body:k.trim(),kind:`improvement_note`,author:`octocat`,status:`open`,sync:e,revision:1};o(e=>[...e,t]),R(t.id)}N(`active`),We(),E(null),O(null),L(P===`failed`?S.syncFailed:S.saved)}async function Ze(){Y.length&&!Le&&(t?.token?await s.change(`fix`)&&L(S.productionSent):(xe(Y.map(e=>({...e}))),o(e=>e.map(e=>e.status===`open`?{...e,status:`sent`}:e)),I(!0),L(S.sent)))}function Qe(e){o(t=>t.map(t=>F.some(e=>e.id===t.id&&e.revision===t.revision)&&t.status===`sent`?{...t,status:e}:t)),I(!1),w(!0),L(S.finished)}async function $(e,n){t?.token?await s.change(`status`,{id:e.id,status:n,identity:s.state?.identity,expectedNoteRevision:e.revision})&&J.current?.focus():(o(t=>t.map(t=>t.id===e.id?{...t,status:n,sync:P===`connected`?`synced`:P===`failed`?`failed`:`local`}:t)),J.current?.focus())}let $e=(0,C.jsx)(`div`,{className:`improvement-demo__actions`,children:(0,C.jsxs)(`div`,{role:`group`,"aria-label":S.title,className:`improvement-demo__split`,children:[(0,C.jsx)(x.Button,{ref:q,size:`small`,variant:`secondary`,className:`canvas-toolbar-compact-button`,"aria-label":S.annotate,title:S.annotate,leadingVisual:(0,C.jsx)(a,{}),"aria-pressed":v,disabled:le||Q&&(!Z.ready||!!t?.token&&!s.state),onClick:()=>{v?Ve():He()},children:(0,C.jsx)(`span`,{className:`canvas-toolbar-button-label`,children:S.annotate})}),(0,C.jsx)(x.Button,{ref:J,size:`small`,variant:`secondary`,"aria-label":S.openNotes(Pe),"aria-expanded":ge&&!t?.hubOpen,onClick:We,children:(0,C.jsx)(ee,{children:Pe})})]})});return(0,C.jsxs)(`section`,{"aria-label":S.title,className:`improvement-demo${Q?` improvement-demo--embedded`:``}`,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||T||j!==null||Se||(y(!1),B(!1),U(null),G(null),K.current=null,v&&q.current?.focus())},children:[Q?null:(0,C.jsxs)(`header`,{className:`improvement-demo__browser`,children:[(0,C.jsx)(`span`,{className:`improvement-demo__browser-dot`}),(0,C.jsxs)(`code`,{children:[`localhost:5173`,m]}),(0,C.jsx)(`span`,{className:`improvement-demo__badge`,children:S.demo})]}),Q?Ee&&(0,ne.createPortal)($e,Ee):(0,C.jsxs)(`header`,{className:`improvement-demo__toolbar`,children:[(0,C.jsxs)(`div`,{className:`improvement-demo__identity`,children:[(0,C.jsx)(`strong`,{children:S.branch}),(0,C.jsx)(`span`,{children:S.title})]}),$e]}),Q?null:(0,C.jsx)(`div`,{className:`improvement-demo__disclaimer`,children:S.demoNotice}),(0,C.jsxs)(`div`,{className:`improvement-demo__workspace`,children:[Q?null:(0,C.jsxs)(`section`,{className:`improvement-demo__preview`,"aria-label":`Prototype preview`,children:[(0,C.jsxs)(`nav`,{className:`improvement-demo__pages`,"aria-label":S.sampleScreens,children:[(0,C.jsx)(`span`,{className:`improvement-demo__app-name`,children:S.sampleWorkspace}),[`/projects`,`/settings`].map(e=>(0,C.jsx)(`button`,{type:`button`,"aria-current":m===e?`page`:void 0,onClick:()=>{_(e),R(null),U(null),G(null)},children:e===`/projects`?S.projects:S.settings},e))]}),(0,C.jsxs)(`div`,{ref:Oe,className:`improvement-demo__stage${v?` improvement-demo__stage--selecting`:``}`,role:z?`button`:`group`,tabIndex:v?0:-1,"aria-describedby":`improvement-selection-hint`,"aria-label":z?`Choose region corners`:`Selectable preview`,onKeyDown:e=>{if(e.key===`Escape`)e.preventDefault(),y(!1),B(!1),U(null),G(null),K.current=null,q.current?.focus();else if(v&&e.shiftKey&&e.key===`Enter`)e.preventDefault(),B(!z),U(null),G(null),L(z?S.selectHint:S.regionHint);else if(z&&[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Enter`,` `].includes(e.key)){if(e.preventDefault(),e.key===`Enter`||e.key===` `)H?Je(H,V):(U(V),L(S.firstCorner));else{let t={x:Math.max(0,Math.min(960,V.x+(e.key===`ArrowRight`?10:e.key===`ArrowLeft`?-10:0))),y:Math.max(0,Math.min(560,V.y+(e.key===`ArrowDown`?10:e.key===`ArrowUp`?-10:0)))};Te(t),H&&G(Ke(H,t))}}},onPointerDown:e=>{if(!v||e.button!==0||e.target instanceof Element&&e.target.closest(`[data-note-pin]`))return;e.preventDefault();let t=qe(e);if(!t)return;if(z){Te(t),K.current={start:t,target:void 0,pointerId:e.pointerId},e.currentTarget.setPointerCapture(e.pointerId);return}let n=e.target instanceof Element?e.target.closest(`[data-improvement-target]`):null;K.current={start:t,target:oe.find(e=>e.id===n?.getAttribute(`data-improvement-target`)),pointerId:e.pointerId},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{if(!K.current||K.current.pointerId!==e.pointerId)return;let t=qe(e);if(!t)return;if(z){Te(t),H&&G(Ke(H,t));return}let n=Ke(K.current.start,t);Math.hypot(n.width,n.height)>=8&&G(n)},onPointerUp:e=>{let t=K.current;if(!t||t.pointerId!==e.pointerId)return;K.current=null,e.currentTarget.releasePointerCapture(e.pointerId);let n=qe(e);if(!n)return;if(z){Te(n),H?Je(H,n):(U(n),L(S.firstCorner));return}let r=Ke(t.start,n);Math.hypot(r.width,r.height)>=8?Je(t.start,n):t.target&&Ge(t.target.rect,t.target),G(null)},onPointerCancel:()=>{K.current=null,G(null)},onLostPointerCapture:()=>{K.current=null,G(null)},children:[(0,C.jsx)(ce,{route:m}),v&&!z?oe.filter(e=>e.route===m).map(e=>(0,C.jsx)(`button`,{type:`button`,"data-improvement-target":e.id,className:`improvement-demo__element-target`,"aria-label":e.label,style:{left:`${e.rect.x/960*100}%`,top:`${e.rect.y/560*100}%`,width:`${e.rect.width/960*100}%`,height:`${e.rect.height/560*100}%`},onClick:()=>{T||Ge(e.rect,e)}},e.id)):null,W?(0,C.jsx)(`div`,{className:`improvement-demo__outline`,style:{left:`${W.x/960*100}%`,top:`${W.y/560*100}%`,width:`${W.width/960*100}%`,height:`${W.height/560*100}%`}}):null,z?(0,C.jsx)(`span`,{className:`improvement-demo__corner`,style:{left:`${V.x/960*100}%`,top:`${V.y/560*100}%`}}):null,Re.map(e=>(0,C.jsx)(`button`,{"data-note-pin":!0,type:`button`,className:`improvement-demo__pin${we===e.id?` improvement-demo__pin--selected`:``}`,style:{left:`${Math.min(e.rect.x+e.rect.width,930)/960*100}%`,top:`${e.rect.y/560*100}%`},"aria-label":`Open improvement note ${e.id}: ${e.target}`,onClick:()=>{R(e.id),w(!0),N(`active`)},children:e.id},e.id)),ze?(0,C.jsx)(`div`,{className:`improvement-demo__outline improvement-demo__outline--saved`,style:{left:`${ze.rect.x/960*100}%`,top:`${ze.rect.y/560*100}%`,width:`${ze.rect.width/960*100}%`,height:`${ze.rect.height/560*100}%`}}):null]}),(0,C.jsxs)(`footer`,{className:`improvement-demo__preview-footer`,children:[(0,C.jsx)(`span`,{id:`improvement-selection-hint`,children:v?S.keyboardHint:S.navigationHint}),(0,C.jsx)(`span`,{children:`960 × 560`})]})]}),Q&&!t?.token?(0,C.jsx)(`div`,{className:`canvas-improvement-markers`,children:Re.map(e=>{let t=Z.resolutions.get(e.id);return!t||t.status!==`resolved`&&t.status!==`moved`?null:(0,C.jsx)(`button`,{type:`button`,className:`improvement-demo__pin`,style:{left:t.point.x,top:t.point.y},"aria-label":`Open improvement note ${e.id}: ${e.target}`,onClick:()=>{R(e.id),N(e.status===`ready`?`ready`:`active`),We()},children:e.id},e.id)})}):null,t?.token?(0,C.jsx)(te,{identity:s.state?.identity??``,controls:!1,returnFocusRef:J,open:ge&&!t.hubOpen&&!T,active:(ge||v)&&!t.hubOpen&&!T,onOpen:We,onClose:()=>{w(!1),J.current?.focus()},threads:p.map(e=>ie(e,Z.resolutions.get(e.id))),busy:s.busy||!s.state,activeBatch:!!s.state?.activeBatch,error:s.error||u||s.state?.profileError||(s.state?Z.ready?``:S.bridgeUnavailable:S.storageLoading),onSelect:e=>{let n=p.find(t=>t.id===e);n&&n.route!==m&&t.onNavigate(new URL(n.route,t.prototypeUrl).href)},onFollowUp:(e,t)=>s.change(`follow-up`,{id:e.id,expectedNoteRevision:e.revision,body:t}),onResolve:e=>s.change(`status`,{id:e.id,expectedNoteRevision:e.revision,status:`resolved`}),onDelete:e=>s.change(`delete`,{id:e.id,expectedNoteRevision:e.revision}),onFix:()=>s.change(`fix`),onRetry:e=>s.change(`status`,{id:e.id,expectedNoteRevision:e.revision,status:`open`})}):(0,C.jsxs)(h,{className:`improvement-notes-sidebar`,contentClassName:`improvement-demo__panel`,title:S.notes,open:ge&&!t?.hubOpen,closeLabel:S.closeNotes,onClose:()=>{w(!1),J.current?.focus()},children:[s.error&&(!T||!X)?(0,C.jsx)(`p`,{role:`alert`,className:`improvement-demo__notice`,children:s.error}):null,u?(0,C.jsx)(`p`,{role:`status`,className:`improvement-demo__notice`,children:u}):null,t?.token&&!s.state?(0,C.jsx)(`p`,{role:`status`,className:`improvement-demo__notice`,children:S.storageLoading}):null,Q&&!Z.ready?(0,C.jsx)(`p`,{role:`status`,className:`improvement-demo__notice`,children:S.bridgeUnavailable}):null,(0,C.jsxs)(`div`,{className:`improvement-demo__filters`,children:[(0,C.jsxs)(x.ActionMenu,{size:`small`,selectionVariant:`single`,menuAlignment:`start`,onSelect:N,children:[(0,C.jsx)(x.ActionMenu.Button,{size:`small`,variant:`secondary`,"aria-label":`${S.filter}: ${Fe}`,children:Fe}),(0,C.jsx)(x.ActionMenu.Overlay,{"aria-label":S.filter,children:[{value:`active`,label:S.allActive},{value:`ready`,label:S.readyFilter},{value:`resolved`,label:S.resolvedFilter}].map(e=>(0,C.jsx)(x.ActionMenu.Item,{value:e.value,selected:M===e.value,role:`menuitemradio`,onKeyDownCapture:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.click())},children:e.label},e.value))})]}),M===`active`?(0,C.jsx)(x.Button,{size:`small`,variant:`primary`,className:`improvement-demo__fix-all`,leadingVisual:(0,C.jsx)(l,{}),"aria-label":S.fixAll(Y.length),disabled:!Y.length||Le||s.busy,title:Le?Q?S.productionBusy:S.fixBusy:void 0,onClick:()=>void Ze(),children:(0,C.jsxs)(`span`,{className:`improvement-demo__fix-label`,children:[S.fix,(0,C.jsx)(ee,{children:Y.length})]})}):null]}),(0,C.jsxs)(`div`,{className:`improvement-demo__note-list`,children:[Ie.length?null:(0,C.jsxs)(`div`,{className:`improvement-demo__empty`,children:[(0,C.jsx)(d,{size:28}),(0,C.jsx)(`h2`,{children:p.length?S.emptyFilter:S.empty}),p.length?null:(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`p`,{children:S.emptyBody}),(0,C.jsx)(x.Button,{size:`small`,variant:`secondary`,leadingVisual:(0,C.jsx)(a,{}),disabled:le||Q&&(!Z.ready||!X),onClick:()=>{He(),q.current?.focus()},children:S.annotate})]})]}),Ie.map(e=>(0,C.jsxs)(`article`,{"aria-label":`Improvement note ${e.id}`,className:`improvement-demo__note${we===e.id?` improvement-demo__note--focused`:``}`,children:[(0,C.jsxs)(`div`,{className:`improvement-demo__note-header`,children:[e.status===`ready`?(0,C.jsx)(`span`,{className:`improvement-demo__status improvement-demo__status--ready`,children:S.statuses.ready}):null,(0,C.jsx)(`p`,{className:`improvement-demo__body`,children:e.body}),(0,C.jsx)(`div`,{className:`improvement-demo__note-menu`,children:(0,C.jsxs)(x.ActionMenu,{selectionVariant:`none`,size:`small`,menuAlignment:`end`,children:[(0,C.jsx)(x.ActionMenu.Button,{className:`improvement-demo__menu-trigger`,variant:`subtle`,"aria-label":S.noteActions(e.target),leadingVisual:(0,C.jsx)(n,{size:16}),children:``}),(0,C.jsxs)(x.ActionMenu.Overlay,{"aria-label":S.noteActions(e.target),children:[(0,C.jsx)(x.ActionMenu.Item,{value:`edit`,className:`improvement-demo__menu-item`,leadingVisual:(0,C.jsx)(d,{size:16}),disabled:e.status===`ready`,title:e.status===`ready`?S.readyReadOnly:void 0,onClick:()=>{e.status===`ready`?L(S.readyReadOnly):(E({...e,identity:s.state?.identity,noteRevision:e.revision,originalBody:e.body}),O(e.id),A(e.body))},onKeyDownCapture:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.click())},children:S.editAction}),(0,C.jsx)(x.ActionMenu.Item,{value:`delete`,className:`improvement-demo__menu-item improvement-demo__delete-item`,leadingVisual:(0,C.jsx)(c,{size:16}),onClick:()=>ye({id:e.id,revision:e.revision,body:e.body,identity:s.state?.identity}),onKeyDownCapture:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.click())},children:S.deleteAction})]})]})})]}),(0,C.jsxs)(`div`,{className:`improvement-demo__note-meta`,children:[(0,C.jsx)(`span`,{children:e.target}),(0,C.jsx)(`span`,{className:`improvement-demo__note-separator`,"aria-hidden":`true`}),(0,C.jsx)(`button`,{className:`improvement-demo__note-route`,type:`button`,"aria-label":`${S.viewTarget}: ${e.target} (${e.route})`,onClick:()=>{if(t&&e.anchor){let n=new URL(t.prototypeUrl);n.pathname=e.anchor.route.pathname,n.search=e.anchor.route.search,n.hash=e.anchor.route.hash,t.onNavigate(n.href)}else _(e.route);R(e.id)},children:(0,C.jsx)(`code`,{children:e.route})})]}),e.status!==`open`&&e.status!==`ready`?(0,C.jsx)(`span`,{className:`improvement-demo__status improvement-demo__status--${e.status}`,children:S.statuses[e.status]}):null,e.status===`ready`?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`details`,{className:`improvement-demo__solution`,children:[(0,C.jsxs)(`summary`,{children:[(0,C.jsx)(i,{size:14,"aria-hidden":`true`}),S.solution]}),(0,C.jsx)(`p`,{children:e.result||(Q?S.solutionUnavailable:S.noteReady)})]}),(0,C.jsx)(`p`,{className:`improvement-demo__read-only`,children:S.readyReadOnly})]}):e.result?(0,C.jsx)(`p`,{className:`improvement-demo__result`,children:e.result}):null,e.capture&&!e.capturePlaceholder?(0,C.jsx)(`img`,{className:`improvement-demo__thumbnail`,src:e.capture,alt:`${e.capturePlaceholder?S.capturePlaceholder:S.capture}: ${e.target}`}):null,!Q&&(e.status===`sent`||e.status===`blocked`)?(0,C.jsx)(`p`,{className:`improvement-demo__result`,children:e.status===`sent`?S.noteSent:S.noteBlocked}):null,(0,C.jsxs)(`div`,{className:`improvement-demo__note-actions`,children:[Q&&e.status===`sent`?(0,C.jsx)(x.Button,{size:`small`,variant:`secondary`,onClick:()=>void $(e,`open`),children:S.returnToActive}):null,e.status===`ready`?(0,C.jsx)(x.Button,{size:`small`,variant:`secondary`,leadingVisual:(0,C.jsx)(f,{}),onClick:()=>$(e,`resolved`),children:S.resolve}):null,e.status===`resolved`?(0,C.jsx)(x.Button,{size:`small`,variant:`secondary`,onClick:()=>$(e,`open`),children:S.reopen}):null,e.status===`blocked`?(0,C.jsx)(x.Button,{size:`small`,variant:`secondary`,onClick:()=>$(e,`open`),children:S.retryFix}):null]}),!Q&&e.status===`sent`?(0,C.jsxs)(`details`,{className:`improvement-demo__simulation`,children:[(0,C.jsx)(`summary`,{children:S.perNoteResult}),(0,C.jsx)(x.Button,{size:`small`,variant:`secondary`,onClick:()=>$(e,`ready`),children:S.complete}),(0,C.jsx)(x.Button,{size:`small`,variant:`secondary`,onClick:()=>$(e,`blocked`),children:S.block})]}):null,Q?null:(0,C.jsx)(`small`,{className:e.sync===`failed`?`improvement-demo__sync-error`:``,children:S.sync[e.sync]})]},e.id))]}),!Q&&Le?(0,C.jsx)(x.Button,{size:`small`,variant:`secondary`,onClick:()=>I(!0),children:S.batchLabel(F.length)}):null,Q?null:(0,C.jsxs)(`footer`,{className:`improvement-demo__connection`,children:[(0,C.jsxs)(`label`,{children:[S.syncControls,(0,C.jsxs)(`select`,{value:P,onChange:e=>{let t=e.target.value;(t===`offline`||t===`connected`||t===`failed`)&&(be(t),t!==`offline`&&o(e=>e.map(e=>({...e,sync:t===`connected`?`synced`:`failed`}))))},children:[(0,C.jsx)(`option`,{value:`offline`,children:S.offline}),(0,C.jsx)(`option`,{value:`connected`,children:S.connected}),(0,C.jsx)(`option`,{value:`failed`,children:S.syncFailure})]})]}),p.some(e=>e.sync===`failed`)?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`p`,{children:S.syncFailed}),(0,C.jsx)(x.Button,{size:`small`,variant:`secondary`,onClick:()=>{be(`connected`),o(e=>e.map(e=>({...e,sync:`synced`}))),L(S.syncSuccess)},children:S.syncRetry})]}):null]})]})]}),(0,C.jsx)(`p`,{className:`improvement-demo__announcement${Q?` visually-hidden`:``}`,role:`status`,children:Ce}),je?(0,C.jsxs)(g,{title:D===null?S.add:S.edit,closeLabel:S.closeComposer,returnFocusRef:q,onClose:Ye,className:`improvement-demo__composer`,children:[s.error?(0,C.jsx)(`p`,{role:`alert`,className:`improvement-demo__notice`,children:s.error}):null,Me?(0,C.jsx)(`p`,{role:`alert`,className:`improvement-demo__notice`,children:S.branchChanged}):null,Ne?(0,C.jsx)(`p`,{role:`alert`,className:`improvement-demo__notice`,children:S.readyReadOnly}):null,(0,C.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),Xe()},children:[(0,C.jsxs)(x.FormControl,{fullWidth:!0,children:[(0,C.jsx)(x.FormControl.Label,{children:S.label}),(0,C.jsx)(x.Textarea,{ref:ke,value:k,maxLength:1e4,rows:4,placeholder:S.placeholder,readOnly:Ne,onChange:e=>A(e.target.value),required:!0})]}),(0,C.jsx)(`div`,{className:`improvement-demo__dialog-actions`,children:(0,C.jsx)(x.Button,{type:`submit`,size:`small`,variant:`primary`,disabled:!k.trim()||s.busy||Me||Ne,children:D===null?S.save:S.saveEdit})})]})]}):null,_e&&X?(0,C.jsxs)(g,{title:S.discardTitle,closeLabel:S.closeDiscard,returnFocusRef:q,onClose:()=>ve(!1),children:[(0,C.jsx)(`p`,{children:S.discardBody}),(0,C.jsxs)(`div`,{className:`improvement-demo__dialog-actions`,children:[(0,C.jsx)(x.Button,{size:`small`,variant:`secondary`,onClick:()=>ve(!1),children:S.keep}),(0,C.jsx)(x.Button,{size:`small`,variant:`primary`,onClick:()=>{ve(!1),E(null),O(null),A(``),t?.token&&Ve()},children:S.discard})]})]}):null,j!==null&&X?(0,C.jsxs)(g,{title:S.deleteTitle,closeLabel:S.closeDelete,returnFocusRef:J,onClose:()=>ye(null),children:[(0,C.jsx)(`p`,{children:S.deleteBody}),(0,C.jsx)(`blockquote`,{className:`improvement-demo__delete-preview`,children:j.body}),(0,C.jsxs)(`div`,{className:`improvement-demo__dialog-actions`,children:[(0,C.jsx)(x.Button,{size:`small`,variant:`secondary`,onClick:()=>ye(null),children:S.cancel}),(0,C.jsx)(x.Button,{size:`small`,variant:`primary`,className:`improvement-demo__delete-confirm`,onClick:async()=>{(!t?.token||await s.change(`delete`,{id:j.id,identity:j.identity,expectedNoteRevision:j.revision}))&&(o(e=>e.filter(e=>e.id!==j.id)),ye(null),R(null))},children:S.deleteAction})]})]}):null,Se?(0,C.jsxs)(g,{title:S.handoff,closeLabel:S.closeBatch,returnFocusRef:J,onClose:()=>I(!1),className:`improvement-demo__handoff`,children:[(0,C.jsx)(`p`,{children:S.handoffNotice}),(0,C.jsxs)(`div`,{className:`improvement-demo__batch-context`,children:[(0,C.jsx)(`code`,{children:t?.branch??S.branch}),(0,C.jsxs)(`span`,{children:[Q?S.canvasBatchSource:S.sampleBatchSource,` · `,F.length,` notes`]})]}),(0,C.jsx)(`ol`,{children:F.map(e=>(0,C.jsxs)(`li`,{children:[(0,C.jsxs)(`strong`,{children:[`#`,e.id,` · `,e.target]}),(0,C.jsxs)(`code`,{children:[e.route,` · revision `,e.revision]}),(0,C.jsx)(`p`,{children:e.body}),(0,C.jsx)(`img`,{className:`improvement-demo__thumbnail`,src:e.capture,alt:`${e.capturePlaceholder?S.capturePlaceholder:S.capture}: ${e.target}`}),(0,C.jsx)(`code`,{children:e.selector??`Region: ${e.rect.x}, ${e.rect.y}, ${e.rect.width} × ${e.rect.height}`})]},`${e.id}-${e.revision}`))}),(0,C.jsx)(`p`,{className:`improvement-demo__form-hint`,children:S.batchHint}),(0,C.jsxs)(`div`,{className:`improvement-demo__dialog-actions`,children:[(0,C.jsx)(x.Button,{size:`small`,variant:`secondary`,onClick:()=>I(!1),children:S.closeHandoff}),(0,C.jsx)(x.Button,{size:`small`,variant:`secondary`,onClick:()=>Qe(`blocked`),children:S.block}),(0,C.jsx)(x.Button,{size:`small`,variant:`primary`,onClick:()=>Qe(`ready`),children:S.complete})]})]}):null]})}export{fe as t}; \ No newline at end of file diff --git a/.github/extensions/replica-prototype/capture-review-revision/index.mjs b/.github/extensions/replica-prototype/capture-review-revision/index.mjs new file mode 100644 index 00000000..56422f37 --- /dev/null +++ b/.github/extensions/replica-prototype/capture-review-revision/index.mjs @@ -0,0 +1,97 @@ +import { mkdtemp, rm } from "node:fs/promises" +import path from "node:path" + +import { runCommand } from "../run-command/index.mjs" + +export async function captureReviewRevision(context) { + const gitDirectory = await runCommand( + "git", + ["rev-parse", "--absolute-git-dir"], + context.repositoryPath, + ) + if (!gitDirectory.ok) throw new Error("Could not locate the local review Git directory.") + const directory = await mkdtemp(path.join(gitDirectory.stdout.trim(), "replica-review-")) + const env = { ...process.env, GIT_INDEX_FILE: path.join(directory, "index") } + const config = ["-c", "core.fsmonitor=false", "-c", "core.hooksPath=/dev/null"] + async function git(args, optional = false) { + const result = await runCommand("git", [...config, ...args], context.repositoryPath, { env }) + if (!result.ok && !(optional && result.exitCode === 1)) + throw new Error(`Could not capture the local review revision: ${result.error}`) + return result + } + try { + // Snapshotting must not execute repository-defined clean filters or filter processes. + const filters = await git( + ["config", "--name-only", "--get-regexp", "^filter\\..*\\.(clean|process|required)$"], + true, + ) + for (const key of filters.stdout.trim().split("\n").filter(Boolean)) { + config.push("-c", `${key}=${key.endsWith(".required") ? "false" : ""}`) + } + const head = (await git(["rev-parse", "HEAD"])).stdout.trim() + const branch = (await git(["branch", "--show-current"])).stdout.trim() + const headTree = (await git(["rev-parse", "HEAD^{tree}"])).stdout.trim() + if (!/^[0-9a-f]{40}$/.test(head) || !branch) + throw new Error("Open a committed, named branch before commenting.") + await git(["read-tree", head]) + const files = ( + await git(["ls-files", "-z", "--cached", "--others", "--exclude-standard"]) + ).stdout + .split("\0") + .filter(Boolean) + for (let offset = 0; offset < files.length; offset += 100) { + const attributes = ( + await git([ + "--literal-pathspecs", + "check-attr", + "-z", + "filter", + "--", + ...files.slice(offset, offset + 100), + ]) + ).stdout.split("\0") + for (let index = 2; index < attributes.length; index += 3) { + if (!["unspecified", "unset"].includes(attributes[index])) + throw new Error("Local review revisions do not support Git clean filters.") + } + } + const submodules = await git([ + "diff", + "--no-ext-diff", + "--no-textconv", + "--ignore-submodules=none", + "--name-only", + "-z", + "--diff-filter=M", + head, + "--", + ]) + const changedPaths = new Set(submodules.stdout.split("\0")) + const entries = (await git(["ls-files", "--stage", "-z"])).stdout + if ( + entries + .split("\0") + .some( + (entry) => + entry.startsWith("160000 ") && changedPaths.has(entry.slice(entry.indexOf("\t") + 1)), + ) + ) + throw new Error("Commit or discard submodule changes before commenting on this preview.") + await git(["add", "--all", "--", "."]) + const treeSha = (await git(["write-tree"])).stdout.trim() + const currentHead = (await git(["rev-parse", "HEAD"])).stdout.trim() + const currentBranch = (await git(["branch", "--show-current"])).stdout.trim() + const remaining = await git( + ["diff", "--no-ext-diff", "--no-textconv", "--quiet", "--ignore-submodules=none"], + true, + ) + const untracked = (await git(["ls-files", "--others", "--exclude-standard"])).stdout + if (currentHead !== head || currentBranch !== branch || !remaining.ok || untracked) + throw new Error("The checkout changed while capturing this review revision. Try again.") + if (!/^[0-9a-f]{40}$/.test(treeSha)) + throw new Error("Could not verify the local review source tree.") + return { treeSha, commitSha: head, clean: treeSha === headTree } + } finally { + await rm(directory, { recursive: true, force: true }) + } +} diff --git a/.github/extensions/replica-prototype/improvement-notes/index.mjs b/.github/extensions/replica-prototype/improvement-notes/index.mjs index 61e5a12b..8c2872d9 100644 --- a/.github/extensions/replica-prototype/improvement-notes/index.mjs +++ b/.github/extensions/replica-prototype/improvement-notes/index.mjs @@ -6,6 +6,7 @@ import { isDeepStrictEqual } from "node:util" import { createPrivateStore } from "../private-store/index.mjs" import { currentCanvasContext } from "../create-canvas-context/index.mjs" +import { captureReviewRevision } from "../capture-review-revision/index.mjs" import { runCommand } from "../run-command/index.mjs" import { validateAnchor } from "../assets/review-anchor-validation.mjs" import { improvementBatchResult } from "../improvement-batch-result/index.mjs" @@ -21,6 +22,8 @@ const statuses = new Set(["open", "sent", "ready", "resolved", "blocked"]) const maximumCapture = 1_500_000 const maximumNotes = 200 const maximumStoreBytes = maximumNotes * (maximumCapture + 64_000) * 2 +const missingSourceMessage = + "This local improvement has no captured source. It cannot sync. Keep it locally or select its target again as a new improvement." const pickAndPolishSkillUrl = new URL("../skills/replica-pick-and-polish/SKILL.md", import.meta.url) export async function readPickAndPolishInstructions(skillUrl = pickAndPolishSkillUrl) { @@ -54,6 +57,13 @@ function checkNote(note, owner) { Buffer.byteLength(note.body) > 10_000 || !Number.isSafeInteger(note.revision) || note.revision < 1 || + (note.buildNumber !== undefined && + (!Number.isSafeInteger(note.buildNumber) || note.buildNumber < 1)) || + (note.source !== undefined && + (!/^[0-9a-f]{40}$/.test(note.source?.treeSha) || + !/^[0-9a-f]{40}$/.test(note.source?.commitSha) || + typeof note.source?.clean !== "boolean" || + !Number.isFinite(Date.parse(note.createdAt)))) || (note.syncedRevision !== undefined && (!Number.isSafeInteger(note.syncedRevision) || note.syncedRevision < 1 || @@ -106,6 +116,7 @@ export function createImprovementNotes(getContext, session, getHub, options = {} options.directory || path.join(os.homedir(), ".config", "replica", "improvement-notes") const store = createPrivateStore(directory) const profiles = new Map() + const captures = new Map() async function identity() { const context = await currentCanvasContext(getContext()) @@ -302,6 +313,16 @@ export function createImprovementNotes(getContext, session, getHub, options = {} } return { + async capture() { + const { key, context } = await identity() + const source = await captureReviewRevision(context) + if ((await identity()).key !== key) + fail("The prototype branch changed while selecting a target. Try again.", 409) + const sourceId = randomUUID() + if (captures.size >= maximumNotes) captures.delete(captures.keys().next().value) + captures.set(sourceId, { identity: key, source }) + return { identity: key, sourceId } + }, async load() { const { key, context } = await identity() const record = await read(key) @@ -382,6 +403,9 @@ export function createImprovementNotes(getContext, session, getHub, options = {} if (record.notes.length >= maximumNotes) fail("This prototype has reached its 200-note storage limit.") const { anchor, body, capture = "" } = input + const selected = input.sourceId === undefined ? null : captures.get(input.sourceId) + if (input.sourceId !== undefined && selected?.identity !== input.identity) + fail("The selected source expired. Select the target again before saving.", 409) const note = checkNote({ id: record.nextId++, localId: randomUUID(), @@ -393,6 +417,8 @@ export function createImprovementNotes(getContext, session, getHub, options = {} revision: 1, status: "open", sync: "local", + createdAt: new Date().toISOString(), + ...(selected ? { source: selected.source } : {}), }) if (author) { if (profile?.owner) record.owner = profile.owner @@ -410,6 +436,7 @@ export function createImprovementNotes(getContext, session, getHub, options = {} rect: anchor.rect, }) record.notes.push(note) + if (!selected) record.syncError = missingSourceMessage return } const note = record.notes.find((item) => item.id === input.id && !item.deleted) @@ -550,6 +577,13 @@ export function createImprovementNotes(getContext, session, getHub, options = {} if (item.kind !== "improvement_note" || item.author?.login !== owner.login) fail("Hub returned another author's improvement note.", 502) const existing = record.notes.find((note) => note.localId === item.localId) + if (existing?.buildNumber !== undefined && item.buildNumber !== existing.buildNumber) + fail("Hub returned a changed improvement Build.", 409) + if (existing?.syncedRevision && item.buildNumber !== undefined) { + if (!Number.isSafeInteger(item.buildNumber) || item.buildNumber < 1) + fail("Hub returned an invalid improvement Build.", 502) + existing.buildNumber = item.buildNumber + } if (existing && existing.sync !== "synced") continue if (existing && item.revision < existing.revision) fail("Hub returned an older improvement-note revision.", 409) @@ -564,6 +598,7 @@ export function createImprovementNotes(getContext, session, getHub, options = {} author: item.thread?.originalAuthor ? owner.login : "local", revision: item.revision, syncedRevision: item.revision, + ...(item.buildNumber !== undefined ? { buildNumber: item.buildNumber } : {}), body: item.body ?? existing?.body ?? "Deleted improvement note", status: item.status, anchor, @@ -591,8 +626,50 @@ export function createImprovementNotes(getContext, session, getHub, options = {} return } invalidateBatchRequests(record) + let publishedTree for (const note of record.notes.filter((item) => item.sync !== "synced")) { try { + if (note.buildNumber === undefined && !note.syncedRevision) { + if (note.deleted) continue + if (!note.source) { + record.syncError = missingSourceMessage + continue + } + const build = status.prototype.build + if (!build) { + record.syncError = + "Improvements are saved locally until their captured source has a published Build." + continue + } + if ( + !Number.isSafeInteger(build.number) || + build.number < 1 || + !/^[0-9a-f]{40}$/.test(build.commitSha) || + !Number.isFinite(Date.parse(build.publishedAt)) + ) + fail("Hub did not return a valid published Build.", 502) + if (publishedTree === undefined) { + const tree = await runCommand( + "git", + ["rev-parse", `${build.commitSha}^{tree}`], + context.repositoryPath, + ) + if (!tree.ok) + fail("Fetch the published Build commit to sync local improvements.", 409) + publishedTree = tree.stdout.trim() + } + if ( + note.source.treeSha !== publishedTree || + Date.parse(build.publishedAt) < Date.parse(note.createdAt) + ) { + record.syncError = + "Improvements are saved locally until their captured source has a published Build." + continue + } + // Keep the selected Build on retries, even if the upload response is lost. + note.buildNumber = build.number + await store.write(`${input.identity}.json`, record) + } const result = await hub.request(base, { ...requestOptions, method: "POST", @@ -600,6 +677,7 @@ export function createImprovementNotes(getContext, session, getHub, options = {} local_id: note.localId, revision: note.revision, previous_revision: note.syncedRevision ?? 0, + ...(note.buildNumber !== undefined ? { build_number: note.buildNumber } : {}), body: note.body, anchor: note.anchor, status: note.status, @@ -611,10 +689,14 @@ export function createImprovementNotes(getContext, session, getHub, options = {} if ( result.localId !== note.localId || result.revision !== note.revision || + (note.buildNumber !== undefined && result.buildNumber !== note.buildNumber) || + (result.buildNumber !== undefined && + (!Number.isSafeInteger(result.buildNumber) || result.buildNumber < 1)) || !isDeepStrictEqual(result.thread, note.deleted ? null : note.thread) ) fail("Hub did not confirm the saved note revision.", 502) note.sync = "synced" + if (result.buildNumber !== undefined) note.buildNumber = result.buildNumber note.syncedRevision = note.revision if (note.author !== "local" || note.thread.originalAuthor) note.author = owner.login } catch (error) { diff --git a/.github/extensions/replica-prototype/improvement-notes/index.test.mjs b/.github/extensions/replica-prototype/improvement-notes/index.test.mjs index fb9c04de..a370d077 100644 --- a/.github/extensions/replica-prototype/improvement-notes/index.test.mjs +++ b/.github/extensions/replica-prototype/improvement-notes/index.test.mjs @@ -31,6 +31,19 @@ async function fixture(run) { await mkdir(root, { recursive: true }) const exec = promisify(execFile) await exec("git", ["init", "-q", "-b", "prototype/demo", root]) + await exec("git", [ + "-C", + root, + "-c", + "user.name=Test", + "-c", + "user.email=test@example.com", + "commit", + "-qm", + "Initial prototype", + "--allow-empty", + ]) + const commitSha = (await exec("git", ["-C", root, "rev-parse", "HEAD"])).stdout.trim() await exec("git", [ "-C", root, @@ -66,9 +79,48 @@ async function fixture(run) { ...storeOptions, }) } + function createPublished(getHub, storeOptions) { + const store = create(async () => { + const hub = await getHub() + if (!hub) return null + return { + ...hub, + status: async (...args) => { + const status = await hub.status(...args) + if (status.prototype && status.prototype.build === undefined) + status.prototype.build = { + number: 1, + commitSha, + publishedAt: new Date(Date.now() + 1000).toISOString(), + } + return status + }, + request: async (...args) => { + const response = await hub.request(...args) + if (args[1]?.method === "POST") + return { buildNumber: args[1].body.build_number, ...response } + return { + ...response, + ...(response.notes + ? { notes: response.notes.map((note) => ({ buildNumber: 1, ...note })) } + : {}), + } + }, + } + }, storeOptions) + return { + ...store, + save: async (input) => + store.save({ + ...(input.operation === "create" ? await store.capture() : {}), + ...input, + }), + } + } try { await run({ create, + createPublished, context, messages, session, @@ -99,9 +151,231 @@ it("keeps notes across provider restarts and sessions without committing them", }) }) +it("publishes only the selected source after its Build imports and retains that Build for later changes", async () => { + await fixture(async ({ create, anchor, root, exec }) => { + const originalCommit = (await exec("git", ["-C", root, "rev-parse", "HEAD"])).stdout.trim() + let build = null + const writes = [] + const hub = { + origin: "https://hub.example.com", + status: async () => ({ + state: "connected", + repository: "example/prototype", + branch: "prototype/demo", + prototype: { + id: 7, + repositoryId: 9, + viewerLogin: "octocat", + viewerId: 1, + build, + }, + }), + request: async (_url, options) => { + if (options.method !== "POST") return { threadVersion: 2, notes: [] } + writes.push(structuredClone(options.body)) + return { + localId: options.body.local_id, + revision: options.body.revision, + thread: options.body.deleted ? null : options.body.thread, + buildNumber: options.body.build_number, + } + }, + } + const store = create(async () => hub) + await writeFile(path.join(root, "screen.txt"), "Selected preview") + await exec("git", ["-C", root, "add", "screen.txt"]) + await writeFile(path.join(root, "screen.txt"), "Selected preview with unstaged changes") + const indexBefore = await readFile(path.join(root, ".git/index")) + const selection = await store.capture() + assert.deepEqual(await readFile(path.join(root, ".git/index")), indexBefore) + await writeFile(path.join(root, "screen.txt"), "Edited after selecting the target") + let state = await store.save({ + ...(await store.load()), + ...selection, + operation: "create", + body: "Clarify the selected preview", + anchor, + }) + const source = state.notes[0].source + assert.equal(source.commitSha, originalCommit) + assert.equal(source.clean, false) + state = await store.sync(state) + assert.equal(writes.length, 0) + build = { + number: 1, + commitSha: originalCommit, + publishedAt: new Date(Date.now() + 1000).toISOString(), + } + state = await store.sync(state) + assert.equal(writes.length, 0) + + async function commitPreview() { + await exec("git", ["-C", root, "add", "screen.txt"]) + await exec("git", [ + "-C", + root, + "-c", + "user.name=Test", + "-c", + "user.email=test@example.com", + "commit", + "-qm", + "Publish preview", + ]) + return (await exec("git", ["-C", root, "rev-parse", "HEAD"])).stdout.trim() + } + build = { ...build, number: 2, commitSha: await commitPreview() } + const restarted = create(async () => hub) + state = await restarted.sync(state) + assert.equal(writes.length, 0) + assert.deepEqual(state.notes[0].source, source) + await writeFile(path.join(root, "screen.txt"), "Selected preview with unstaged changes") + build = { + number: 3, + commitSha: await commitPreview(), + publishedAt: "2000-01-01T00:00:00Z", + } + state = await restarted.sync(state) + assert.equal(writes.length, 0) + build.publishedAt = new Date(Date.now() + 1000).toISOString() + await writeFile(path.join(root, "screen.txt"), "Another local edit") + state = await restarted.sync(state) + assert.equal(state.notes[0].sync, "synced") + assert.equal(state.notes[0].buildNumber, 3) + assert.equal(writes.length, 1) + assert.equal(writes[0].build_number, 3) + assert.deepEqual(writes[0].anchor, anchor) + + build = null + state = await restarted.save({ + ...state, + operation: "follow-up", + id: 1, + expectedNoteRevision: state.notes[0].revision, + body: "A later request", + }) + state = await restarted.sync(state) + assert.equal(writes[1].build_number, 3) + assert.equal(writes[1].previous_revision, 1) + assert.deepEqual(state.notes[0].source, source) + assert.equal(state.notes[0].body, "Clarify the selected preview") + state = await restarted.save({ + ...state, + operation: "delete", + id: 1, + expectedNoteRevision: state.notes[0].revision, + }) + await restarted.sync(state) + assert.equal(writes[2].build_number, 3) + assert.equal(writes[2].deleted, true) + }) +}) + +it("keeps legacy notes without captured provenance local instead of assigning the current source", async () => { + await fixture(async ({ create, anchor, root, exec }) => { + const commitSha = (await exec("git", ["-C", root, "rev-parse", "HEAD"])).stdout.trim() + let uploads = 0 + const hub = { + origin: "https://hub.example.com", + status: async () => ({ + state: "connected", + repository: "example/prototype", + branch: "prototype/demo", + prototype: { + id: 7, + repositoryId: 9, + viewerLogin: "octocat", + viewerId: 1, + build: { number: 1, commitSha, publishedAt: new Date().toISOString() }, + }, + }), + request: async (_url, options) => { + if (options.method !== "POST") return { threadVersion: 2, notes: [] } + uploads++ + return {} + }, + } + const store = create(async () => hub) + let state = await store.save({ + ...(await store.load()), + operation: "create", + body: "Saved by an older client", + anchor, + }) + state = await create(async () => hub).sync(state) + assert.equal(uploads, 0) + assert.equal(state.notes[0].sync, "local") + assert.equal(state.notes[0].source, undefined) + assert.equal(state.notes[0].buildNumber, undefined) + assert.match(state.syncError, /no captured source/) + await assert.rejects( + store.save({ + ...state, + operation: "create", + sourceId: randomUUID(), + body: "Expired selection", + anchor, + }), + /selected source expired/, + ) + }) +}) + +it("persists the selected Build before an uncertain upload and reuses it after a restart", async () => { + await fixture(async ({ createPublished, create, anchor }) => { + const builds = [] + let currentBuild + const hub = { + origin: "https://hub.example.com", + status: async () => ({ + state: "connected", + repository: "example/prototype", + branch: "prototype/demo", + prototype: { + id: 7, + repositoryId: 9, + viewerLogin: "octocat", + viewerId: 1, + build: currentBuild, + }, + }), + request: async (_url, options) => { + if (options.method !== "POST") return { threadVersion: 2, notes: [] } + builds.push(options.body.build_number) + const persisted = await create(async () => hub).load() + assert.equal(persisted.notes[0].buildNumber, 1) + if (builds.length === 1) throw new Error("Upload result lost") + return { + localId: options.body.local_id, + revision: options.body.revision, + thread: options.body.thread, + } + }, + } + const store = createPublished(async () => hub) + let state = await store.save({ + ...(await store.load()), + operation: "create", + body: "Retain the original Build", + anchor, + }) + state = await store.sync(state) + assert.equal(state.notes[0].sync, "failed") + assert.match(state.syncError, /Upload result lost/) + currentBuild = { + number: 2, + commitSha: "f".repeat(40), + publishedAt: new Date().toISOString(), + } + state = await createPublished(async () => hub).sync(state) + assert.equal(state.notes[0].sync, "synced") + assert.deepEqual(builds, [1, 1]) + }) +}) + it("snapshots verified authors without attributing unowned originals and gates older Hub synchronization", async () => { - await fixture(async ({ create, anchor, directory }) => { - const offline = create() + await fixture(async ({ createPublished: create, anchor, directory }) => { + const offline = create(async () => null) let state = await offline.save({ ...(await offline.load()), operation: "create", @@ -906,8 +1180,8 @@ it("reports dispatch failure durably without automatically replaying the request }) }) -it("syncs a discovered branch before a Build and refuses another author's account", async () => { - await fixture(async ({ create, anchor }) => { +it("syncs a published branch and refuses another author's account", async () => { + await fixture(async ({ createPublished: create, anchor }) => { let login = "octocat" const writes = [] const hub = { @@ -924,7 +1198,6 @@ it("syncs a discovered branch before a Build and refuses another author's accoun repositoryId: 9, viewerLogin: login, viewerId: login === "octocat" ? 1 : 2, - build: null, registered: false, }, } @@ -1069,7 +1342,7 @@ it("retains local notes when Hub cannot sync and rejects malformed note input", }) it("cancels a pending batch after Hub reopens its captured requests", async () => { - await fixture(async ({ create, anchor, messages }) => { + await fixture(async ({ createPublished: create, anchor, messages }) => { let remote const hub = { origin: "https://hub.example.com", @@ -1126,7 +1399,7 @@ it("cancels a pending batch after Hub reopens its captured requests", async () = }) it("pulls creator notes while preserving unsynchronized edits and rejecting foreign authors", async () => { - await fixture(async ({ create, anchor }) => { + await fixture(async ({ createPublished: create, anchor }) => { let remote = [] let rejectUpload = false const hub = { @@ -1295,7 +1568,7 @@ it("rejects an older draft even after polling advances the collection revision", }) it("does not upload owner-bound notes after the Hub connection changes during a pull", async () => { - await fixture(async ({ create, anchor }) => { + await fixture(async ({ createPublished: create, anchor }) => { let account = "octocat" let writes = 0 const hub = { @@ -1565,7 +1838,7 @@ it("reserves escaped answer bytes and preserves saved history when full", async }) it("roundtrips immutable requests and answers through Hub to another isolated local store", async () => { - await fixture(async ({ create, anchor, directory }) => { + await fixture(async ({ createPublished: create, anchor, directory }) => { const remote = [] let supported = false const hub = { @@ -1646,6 +1919,7 @@ it("roundtrips immutable requests and answers through Hub to another isolated lo directory: path.join(directory, "another-local-store"), }) const pulled = await second.sync(await second.load()) + assert.equal(pulled.notes[0].buildNumber, 1) assert.deepEqual(pulled.notes[0].thread, state.notes[0].thread) assert.equal(pulled.notes[0].body, "Original") assert.equal(pulled.notes[0].thread.messages[0].body, "Saved answer") @@ -1804,7 +2078,7 @@ for (const status of ["open", "sent"]) { } it("saves and pulls the canonical validator's zero-size elements and narrow areas", async () => { - await fixture(async ({ create, anchor, directory }) => { + await fixture(async ({ createPublished: create, anchor, directory }) => { const remote = [] const hub = { origin: "https://hub.example.com", @@ -1920,7 +2194,7 @@ it("keeps a freshly pulled original unattributed until explicitly claimed despit for (const statusCode of [409, 422, undefined, 401, 403, 429, 500]) { it(`${[409, 422].includes(statusCode) ? "continues independent uploads after" : "stops uploads after"} ${statusCode ?? "a connection failure"} without clearing its error`, async () => { - await fixture(async ({ create, anchor }) => { + await fixture(async ({ createPublished: create, anchor }) => { const uploaded = [] const hub = { origin: "https://hub.example.com", @@ -1961,7 +2235,7 @@ for (const statusCode of [409, 422, undefined, 401, 403, 429, 500]) { } it("ignores an old batch's reopened request after a remote resend while another note keeps the batch alive", async () => { - await fixture(async ({ create, anchor }) => { + await fixture(async ({ createPublished: create, anchor }) => { const remote = [] const hub = { origin: "https://hub.example.com", @@ -2029,7 +2303,7 @@ for (const scenario of [ "partial legacy page", ]) { it(`${scenario === "complete" ? "collects every page before applying remote notes or uploading" : `preserves every local note and skips uploads after ${scenario}`}`, async () => { - await fixture(async ({ create, anchor }) => { + await fixture(async ({ createPublished: create, anchor }) => { let paging = false let pageReads = 0 const uploaded = [] diff --git a/.github/extensions/replica-prototype/start-canvas-server/index.mjs b/.github/extensions/replica-prototype/start-canvas-server/index.mjs index bc64f318..e79c9675 100644 --- a/.github/extensions/replica-prototype/start-canvas-server/index.mjs +++ b/.github/extensions/replica-prototype/start-canvas-server/index.mjs @@ -350,6 +350,10 @@ async function routeRequest( } requireToken(request, token) + if (requestUrl.pathname === "/api/improvement-notes/capture" && request.method === "POST") { + sendJson(response, 200, await improvementNotes.capture()) + return + } if (requestUrl.pathname === "/api/improvement-notes" && request.method === "GET") { sendJson(response, 200, await improvementNotes.load()) return diff --git a/.github/extensions/replica-prototype/start-canvas-server/index.test.mjs b/.github/extensions/replica-prototype/start-canvas-server/index.test.mjs index 47fed930..96a8351d 100644 --- a/.github/extensions/replica-prototype/start-canvas-server/index.test.mjs +++ b/.github/extensions/replica-prototype/start-canvas-server/index.test.mjs @@ -36,6 +36,9 @@ describe("startCanvasServer()", () => { const headers = { "X-Replica-Canvas-Token": token } const endpoint = new URL("/api/improvement-notes", canvas.url) assert.equal((await fetch(endpoint)).status, 403) + const captureEndpoint = new URL("/api/improvement-notes/capture", canvas.url) + assert.equal((await fetch(captureEndpoint, { method: "POST" })).status, 403) + const captured = await (await fetch(captureEndpoint, { method: "POST", headers })).json() const state = await (await fetch(endpoint, { headers })).json() const response = await fetch(endpoint, { method: "POST", @@ -44,6 +47,7 @@ describe("startCanvasServer()", () => { identity: state.identity, revision: state.revision, operation: "create", + sourceId: captured.sourceId, body: "Improve the selected button.", anchor: { schemaVersion: 1, @@ -61,6 +65,7 @@ describe("startCanvasServer()", () => { }) const saved = await response.json() assert.equal(response.status, 200, JSON.stringify(saved)) + assert.match(saved.notes[0].source.treeSha, /^[0-9a-f]{40}$/) await canvas.close() canvas = await startCanvasServer(context, { send: assert.fail }, options) const reopenedHtml = await (await fetch(canvas.url)).text() diff --git a/hub/app/javascript/application/prototype-canvas/tests/improvement-notes.test.tsx b/hub/app/javascript/application/prototype-canvas/tests/improvement-notes.test.tsx index 9b377aac..f3bf41df 100644 --- a/hub/app/javascript/application/prototype-canvas/tests/improvement-notes.test.tsx +++ b/hub/app/javascript/application/prototype-canvas/tests/improvement-notes.test.tsx @@ -40,7 +40,7 @@ function receive( }) } -function savedNotesFixture() { +function savedNotesFixture(captureFails = false) { const { fetch } = sharingFixture() const original = fetch.getMockImplementation()! const saved = { @@ -52,6 +52,10 @@ function savedNotesFixture() { } fetch.mockImplementation(async (path, options) => { if (!path.startsWith("/api/improvement-notes")) return original(path, options) + if (path.endsWith("/capture")) + return captureFails + ? Response.json({ error: "Source capture unavailable." }, { status: 409 }) + : Response.json({ identity: saved.identity, sourceId: "selected-source" }) if (options?.method === "POST") { if (typeof options.body !== "string") throw new Error("Expected a JSON notes request.") const input: unknown = JSON.parse(options.body) @@ -260,6 +264,7 @@ describe("App()", () => { }) await waitFor(() => expect(annotate).toBeEnabled()) fireEvent.click(annotate) + await waitFor(() => expect(annotate).toHaveAttribute("aria-pressed", "true")) receive(frame, { type: "replica:canvas:selected", anchor }) const composer = within(screen.getByRole("dialog", { name: copy.add })) fireEvent.change(composer.getByRole("textbox", { name: copy.label }), { @@ -325,7 +330,7 @@ describe("App()", () => { fireEvent.click(screen.getByRole("button", { name: threadCopy.close })) expect(screen.queryByRole("button", { name: threadCopy.point(1) })).not.toBeInTheDocument() fireEvent.click(picker) - expect(picker).toHaveAttribute("aria-pressed", "true") + await waitFor(() => expect(picker).toHaveAttribute("aria-pressed", "true")) expect(screen.queryByRole("complementary", { name: copy.notes })).not.toBeInTheDocument() const marker = screen.getByRole("button", { name: threadCopy.point(1) }) expect(marker).toBeVisible() @@ -350,6 +355,7 @@ describe("App()", () => { fireEvent.click(picker) expect(screen.queryByRole("button", { name: threadCopy.point(1) })).not.toBeInTheDocument() fireEvent.click(picker) + await waitFor(() => expect(picker).toHaveAttribute("aria-pressed", "true")) expect(screen.getByRole("button", { name: threadCopy.point(1) })).toBeVisible() receive(frame, { type: "replica:canvas:resolved", results: [] }) expect(screen.queryByRole("button", { name: threadCopy.point(1) })).not.toBeInTheDocument() @@ -476,6 +482,7 @@ describe("App()", () => { await waitFor(() => expect(annotate).toBeEnabled()) const post = vi.spyOn(frame.contentWindow!, "postMessage") fireEvent.click(annotate) + await waitFor(() => expect(annotate).toHaveAttribute("aria-pressed", "true")) expect(post).toHaveBeenCalledWith( { type: "replica:canvas:select", nonce, mode: "improvement" }, previewOrigin, @@ -560,14 +567,51 @@ describe("App()", () => { .filter(([, options]) => options?.method === "POST") .slice(initialWrites.length) expect(writes.map(([path]) => path)).toEqual([ + "/api/improvement-notes/capture", "/api/improvement-notes", "/api/improvement-notes/fix", ]) + const savedBody = writes.find(([path]) => path === "/api/improvement-notes")?.[1]?.body + if (typeof savedBody !== "string") throw new Error("Expected a serialized improvement.") + expect(JSON.parse(savedBody)).toMatchObject({ sourceId: "selected-source", anchor }) expect(saved.notes[0]).toMatchObject({ capture: "", anchor, body: "Clarify this action." }) view.unmount() }, ) + it("explains capture failure while still allowing an improvement to be saved privately", async () => { + vi.spyOn(crypto, "randomUUID").mockReturnValue(nonce) + const { fetch, saved } = savedNotesFixture(true) + render( + , + ) + const frame = screen.getByTitle("Demo prototype") + if (!(frame instanceof HTMLIFrameElement)) throw new Error("Expected the prototype iframe.") + const picker = await screen.findByRole("button", { name: copy.annotate }) + receive(frame, { + type: "replica:canvas:ready", + protocolVersion: 1, + improvementSelection: true, + route: anchor.route, + }) + await waitFor(() => expect(picker).toBeEnabled()) + fireEvent.click(picker) + await waitFor(() => expect(picker).toHaveAttribute("aria-pressed", "true")) + receive(frame, { type: "replica:canvas:selected", anchor }) + const composer = within(screen.getByRole("dialog", { name: copy.add })) + expect(composer.getByRole("alert")).toHaveTextContent(copy.sourceUnavailable) + fireEvent.change(composer.getByRole("textbox", { name: copy.label }), { + target: { value: "Keep this private local request" }, + }) + fireEvent.click(composer.getByRole("button", { name: copy.save })) + await waitFor(() => expect(saved.notes).toHaveLength(1)) + const write = fetch.mock.calls.find( + ([path, options]) => path === "/api/improvement-notes" && options?.method === "POST", + ) + if (typeof write?.[1]?.body !== "string") throw new Error("Expected a local save.") + expect(JSON.parse(write[1].body)).not.toHaveProperty("sourceId") + }) + it("preserves images already stored with saved notes", async () => { vi.spyOn(crypto, "randomUUID").mockReturnValue(nonce) const { saved } = savedNotesFixture() diff --git a/hub/app/javascript/features/prototype-canvas-improvement-notes/en.ts b/hub/app/javascript/features/prototype-canvas-improvement-notes/en.ts index 408448e1..e2791a45 100644 --- a/hub/app/javascript/features/prototype-canvas-improvement-notes/en.ts +++ b/hub/app/javascript/features/prototype-canvas-improvement-notes/en.ts @@ -11,6 +11,8 @@ export const copy = { bridgeUnavailable: "Annotation needs the updated Replica preview bridge. Reconnect or reload the preview after updating the canvas.", capturePlaceholder: "UI-only capture placeholder", + sourceUnavailable: + "You can still save this improvement locally, but it cannot sync without a captured source.", annotate: "Pick & polish", fix: "Fix all", openNotes: (count: number) => `Open improvement notes (${count})`, diff --git a/hub/app/javascript/features/prototype-canvas-improvement-notes/index.tsx b/hub/app/javascript/features/prototype-canvas-improvement-notes/index.tsx index d16a048c..a4b44797 100644 --- a/hub/app/javascript/features/prototype-canvas-improvement-notes/index.tsx +++ b/hub/app/javascript/features/prototype-canvas-improvement-notes/index.tsx @@ -74,6 +74,12 @@ export function ImprovementNotesPrototype({ initial = "empty", canvas }: Props) const notes = canvas?.token ? (saved.state?.notes ?? []) : demoNotes const [route, setRoute] = useState("/projects") const [annotating, setAnnotating] = useState(false) + const [capturingSource, setCapturingSource] = useState(false) + const [selectedSource, setSelectedSource] = useState<{ + identity: string + sourceId: string + } | null>(null) + const captureGeneration = useRef(0) const [panelOpen, setPanelOpen] = useState(true) const [selection, setSelection] = useState(null) const [editing, setEditing] = useState(null) @@ -140,7 +146,8 @@ export function ImprovementNotesPrototype({ initial = "empty", canvas }: Props) const target = anchor.kind === "element" ? anchor.accessibleName || anchor.tagName : copy.regionTarget setSelection({ - identity: saved.state?.identity, + identity: selectedSource?.identity ?? saved.state?.identity, + sourceId: selectedSource?.sourceId, anchor, route: anchor.route.pathname + anchor.route.search + anchor.route.hash, target, @@ -152,12 +159,28 @@ export function ImprovementNotesPrototype({ initial = "empty", canvas }: Props) setEditing(null) setDraft("") }, - [saved.state?.identity], + [saved.state?.identity, selectedSource], ) const cancelPreviewSelection = useCallback(() => { + captureGeneration.current++ + setCapturingSource(false) if (annotateRef.current?.getAttribute("aria-pressed") === "true") annotateRef.current.focus() setAnnotating(false) }, []) + async function beginSelection() { + const generation = ++captureGeneration.current + setCapturingSource(true) + const source = canvas?.token ? await saved.capture() : null + if (generation !== captureGeneration.current) return + setCapturingSource(false) + setSelectedSource(source) + setAnnotating(true) + setPanelOpen(false) + setMessage(copy.selectHint) + setRegionMode(false) + setFirstCorner(null) + setDragRect(null) + } const canvasFrameRef = canvas?.frameRef const preview = usePreviewSelection({ frameRef: canvasFrameRef, @@ -246,6 +269,7 @@ export function ImprovementNotesPrototype({ initial = "empty", canvas }: Props) } setSelection(null) setEditing(null) + if (canvas?.token) cancelPreviewSelection() } async function save() { @@ -259,6 +283,7 @@ export function ImprovementNotesPrototype({ initial = "empty", canvas }: Props) !(await saved.change(editing === null ? "create" : "edit", { id: editing, identity: selection.identity, + sourceId: selection.sourceId, expectedNoteRevision: selection.noteRevision, body: draft.trim(), anchor: selection.anchor, @@ -268,6 +293,7 @@ export function ImprovementNotesPrototype({ initial = "empty", canvas }: Props) return setFilter("active") openNotes() + cancelPreviewSelection() setSelection(null) setEditing(null) setMessage(copy.saved) @@ -376,16 +402,13 @@ export function ImprovementNotesPrototype({ initial = "empty", canvas }: Props) title={copy.annotate} leadingVisual={} aria-pressed={annotating} - disabled={embedded && (!preview.ready || (Boolean(canvas?.token) && !saved.state))} + disabled={ + capturingSource || + (embedded && (!preview.ready || (Boolean(canvas?.token) && !saved.state))) + } onClick={() => { - setAnnotating(!annotating) - if (!annotating) { - setPanelOpen(false) - setMessage(copy.selectHint) - } - setRegionMode(false) - setFirstCorner(null) - setDragRect(null) + if (annotating) cancelPreviewSelection() + else void beginSelection() }} > {copy.annotate} @@ -859,10 +882,11 @@ export function ImprovementNotesPrototype({ initial = "empty", canvas }: Props) size="small" variant="secondary" leadingVisual={} - disabled={embedded && (!preview.ready || !notesAvailable)} + disabled={ + capturingSource || (embedded && (!preview.ready || !notesAvailable)) + } onClick={() => { - setAnnotating(true) - setPanelOpen(false) + void beginSelection() annotateRef.current?.focus() }} > @@ -1203,6 +1227,7 @@ export function ImprovementNotesPrototype({ initial = "empty", canvas }: Props) setSelection(null) setEditing(null) setDraft("") + if (canvas?.token) cancelPreviewSelection() }} > {copy.discard} diff --git a/hub/app/javascript/features/prototype-canvas-improvement-notes/types.ts b/hub/app/javascript/features/prototype-canvas-improvement-notes/types.ts index 0439af99..5c3867ed 100644 --- a/hub/app/javascript/features/prototype-canvas-improvement-notes/types.ts +++ b/hub/app/javascript/features/prototype-canvas-improvement-notes/types.ts @@ -51,4 +51,4 @@ export type Note = { export type Selection = Pick< Note, "route" | "target" | "selector" | "rect" | "capture" | "anchor" | "capturePlaceholder" -> & { identity?: string; noteRevision?: number; originalBody?: string } +> & { identity?: string; sourceId?: string; noteRevision?: number; originalBody?: string } diff --git a/hub/app/javascript/features/prototype-canvas-improvement-notes/use-saved-notes/index.ts b/hub/app/javascript/features/prototype-canvas-improvement-notes/use-saved-notes/index.ts index ef56e0b2..63211ee4 100644 --- a/hub/app/javascript/features/prototype-canvas-improvement-notes/use-saved-notes/index.ts +++ b/hub/app/javascript/features/prototype-canvas-improvement-notes/use-saved-notes/index.ts @@ -132,5 +132,18 @@ export function useSavedNotes(token: string | undefined) { } } - return { state, error: error || refreshError, busy, change } + async function capture(): Promise<{ identity: string; sourceId: string } | null> { + if (!token) return null + setError("") + try { + return await request("/api/improvement-notes/capture", token, { method: "POST" }) + } catch (problem) { + setError( + `${problem instanceof Error ? problem.message : String(problem)} ${copy.sourceUnavailable}`, + ) + return null + } + } + + return { state, error: error || refreshError, busy, change, capture } } diff --git a/hub/docs/prototype-canvas.md b/hub/docs/prototype-canvas.md index e1275086..8455da34 100644 --- a/hub/docs/prototype-canvas.md +++ b/hub/docs/prototype-canvas.md @@ -24,7 +24,11 @@ An author can explicitly claim selected older unowned local improvements after b Owner-only files under `~/.config/replica/improvement-notes/` keep notes across canvas, provider, and conversation reloads. Identity uses the Git common directory, repository, and actual current branch, not the panel, port, route, commit, or session workspace. Notes in different worktrees of the same local repository and branch share that identity; different clones remain independent until Hub synchronization. Atomic writes, locks, and collection revisions reject stale panels rather than replacing another panel's work. A prototype supports up to 200 retained notes, including deletion tombstones. Conversations are bounded; saving a follow-up reserves the worst-case serialized answer for each open and sent request group, including escaped text, request references and status changes. Claims recheck that capacity after adding author snapshots. A full conversation reports an error and requires a new improvement instead of truncating history. Corrupt or non-private storage is reported without replacement. -Notes are saved locally before attempting Hub synchronization. The canvas retries synchronization periodically when a Hub connection is available, pulls the current author's notes, and uploads pending revisions idempotently. Background synchronization does not disable unchanged eligible actions. An explicit mutation waits for an ongoing sync, then uses the refreshed collection revision while preserving its captured note revision and identity; foreground mutations still disable controls and prevent duplicate submissions. Fix all requires another explicit selection if synchronization changed its pending work. Each upload must match the last synchronized Hub revision, so offline work cannot overwrite another clone's history. Follow-ups append against the current note revision without changing the original; polling preserves unsaved composer text. Deletion confirmations retain their opened note revision. A branch must have been discovered by Hub; note storage does not require registration, a successful Build, or publication. Note loading, saving, and synchronization use read-only identity verification and cannot register the prototype, push a branch, or initiate a Build. Undiscovered branches, unavailable connections, access failures, or conflicting revisions leave local notes intact. The informational branch-discovery notice is hidden; actionable synchronization errors remain visible. First synchronization binds the local collection to the Hub origin and immutable Hub user ID; a different connected account cannot read or mutate that collection. Identity verification and each synchronization request share a pinned connection and checkout; changing either stops the operation. +Notes are saved locally before attempting Hub synchronization. Starting target selection captures an immutable Git source tree and commit with an isolated index; later edits and submission never replace that source. A new improvement stays local until Hub reports a successful imported Build whose exact Git tree matches the captured source and whose publication time is no earlier than the saved request. An older Build, a clean checkout, or a matching commit alone cannot authorize an upload. The published commit must be available locally to verify its tree. A capture failure still allows private local saving with an explicit synchronization limitation. Older local notes without provenance are never assigned the current checkout's source and remain local; selecting the target again creates a new improvement without rewriting the original. + +The canvas retries synchronization periodically when a Hub connection is available, pulls the current author's notes, and uploads pending revisions idempotently. Initial upload includes `build_number`; the client persists that Build identity before sending, including when an upload result is uncertain. Later follow-ups, status changes, and deletions retain the saved `buildNumber` returned by Hub instead of using the current checkout or latest Build. Published improvements remain private owner notes, separate from ordinary review comments. Background synchronization does not disable unchanged eligible actions. An explicit mutation waits for an ongoing sync, then uses the refreshed collection revision while preserving its captured note revision and identity; foreground mutations still disable controls and prevent duplicate submissions. Fix all requires another explicit selection if synchronization changed its pending work. Each upload must match the last synchronized Hub revision, so offline work cannot overwrite another clone's history. Follow-ups append against the current note revision without changing the original target, source, or history; polling preserves unsaved composer text. Deletion confirmations retain their opened note revision. + +A branch must have been discovered by Hub to synchronize; local note storage does not require registration, a successful Build, or publication. Note loading, saving, and synchronization use read-only identity verification and cannot register the prototype, push a branch, or initiate a Build. Undiscovered branches, unavailable connections, access failures, or conflicting revisions leave local notes intact. The informational branch-discovery notice is hidden; actionable synchronization errors remain visible. First synchronization binds the local collection to the Hub origin and immutable Hub user ID; a different connected account cannot read or mutate that collection. Identity verification and each synchronization request share a pinned connection and checkout; changing either stops the operation. The client follows the collection's opaque `nextCursor` while `hasMore` is true, using the same pinned connection and checkout for every page. It retrieves and checks the complete collection before applying remote notes or uploading local work. Failed traversal, repeated cursors, inconsistent versions or invalid pagination leave local notes unchanged and expose a synchronization error. Older complete responses without pagination fields remain supported. Keyset pages are not a whole-collection snapshot; ordinary revision checks still protect writes. From 1f75e639b359c1791cafce4479129779f44a057b Mon Sep 17 00:00:00 2001 From: Lukas Oppermann Date: Wed, 21 Oct 2026 03:09:38 +0200 Subject: [PATCH 3/4] feat(hub): sync unpublished preview comments (#37) ## Why Authors need to comment before publishing, including with uncommitted edits. Keeping that feedback on their device avoids storing unpublished comments in Hub or attaching them to the wrong Build. ## What changes The canvas saves unpublished comments privately on the author's device across restarts. Authors can edit or delete them. Source edits, commits and preview reloads preserve the target captured when selection starts. While open, the canvas uploads comments only when a newer imported Build matches their saved source. Confirmed uploads remove the local copy; failures retain it and show an error. Uncertain uploads are checked against Hub rather than blindly sent again. Published conversations keep their existing API and access rules, with no Hub draft records or migration. Local commenting requires a named branch with an initial commit. Source capture preserves staged files; active Git clean filters and changed submodules report an explicit limitation. ![Local comments before first publication, shown with Storybook fixture data](https://github.com/user-attachments/assets/b7cd4858-5622-4965-a90a-8bcccc83f9f4) End-to-end publication against an authenticated Hub and full keyboard and screen-reader review remain unverified. Complete-suite runs also encountered intermittent canvas publication and checkout UI timeouts. --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1a0f3eb5-727a-4361-b09e-256fd982857d Copilot-Session: 81640dc7-0f59-4d95-9037-01b4eb681d03 --- .../extensions/replica-prototype/README.md | 6 +- .../replica-prototype/assets/canvas-bridge.js | 2 +- .../replica-prototype/assets/renderer.js | 10 +- .../capture-review-revision/index.mjs | 92 ++ .../capture-review-revision/index.test.mjs | 142 +++ .../authorization.test.mjs | 0 .../automatic-registration.test.mjs | 0 .../fresh-authorization.test.mjs | 0 .../index.mjs | 45 +- .../index.test.mjs | 11 +- .../rate-limits.test.mjs | 0 .../renewal.test.mjs | 0 .../index.mjs | 10 +- .../index.mjs | 2 +- .../index.test.mjs | 2 +- .../index.mjs | 4 +- .../index.test.mjs | 0 .../create-local-review-comments/index.mjs | 219 ++++ .../index.test.mjs | 307 +++++ .../replica-prototype/discover-hub/index.mjs | 2 +- .../discover-hub/index.test.mjs | 2 +- .../invalid-hub-origin/index.mjs | 1 + .../normalize-hub-origin/index.mjs | 10 + .../normalize-selected-hub-origin/index.mjs | 5 + .../replica-prototype/parse-hub-url/index.mjs | 22 + .../register-prototype-canvas/index.mjs | 6 +- .../register-prototype-canvas/index.test.mjs | 2 +- .../start-canvas-server/index.mjs | 199 ++- .../start-canvas-server/index.test.mjs | 231 +++- .../build-controls/controls.js | 2 +- .../application/prototype-canvas/index.tsx | 4 +- .../install-replica-controls-bridge/bridge.js | 2 +- .../bridge-health.test.tsx | 136 +- .../comment-visibility.test.tsx | 163 +-- .../prototype-canvas-hub-panel/index.test.tsx | 1118 +++++++++-------- .../prototype-canvas-hub-panel/index.tsx | 254 +++- .../reaction-updates.test.tsx | 37 +- .../prototype-canvas-hub-panel/stories.tsx | 88 +- .../index.tsx | 34 + .../review-comment-composer/index.tsx | 4 +- .../review-comment-composer/stories.tsx | 14 + .../features/review-comment-composer/types.ts | 1 + .../features/review-comment-row/index.tsx | 7 +- .../review-comments-sidebar/index.tsx | 4 +- .../review-thread-conversation/index.tsx | 88 +- .../features/review-thread-message/index.tsx | 2 +- .../javascript/utils/prototype-canvas/en.ts | 7 + .../utils/prototype-canvas/types.ts | 15 + .../resolve-prototype-publication/fixtures.ts | 12 + .../utils/review-comment/schemas.ts | 5 +- .../index.test.ts | 172 ++- .../review-thread-matches-filters/index.ts | 10 +- .../review-thread-matches-filters/types.ts | 3 +- hub/docs/prototype-canvas.md | 14 +- 54 files changed, 2468 insertions(+), 1060 deletions(-) create mode 100644 .github/extensions/replica-prototype/capture-review-revision/index.mjs create mode 100644 .github/extensions/replica-prototype/capture-review-revision/index.test.mjs rename .github/extensions/replica-prototype/{hub-client => create-hub-client}/authorization.test.mjs (100%) rename .github/extensions/replica-prototype/{hub-client => create-hub-client}/automatic-registration.test.mjs (100%) rename .github/extensions/replica-prototype/{hub-client => create-hub-client}/fresh-authorization.test.mjs (100%) rename .github/extensions/replica-prototype/{hub-client => create-hub-client}/index.mjs (96%) rename .github/extensions/replica-prototype/{hub-client => create-hub-client}/index.test.mjs (98%) rename .github/extensions/replica-prototype/{hub-client => create-hub-client}/rate-limits.test.mjs (100%) rename .github/extensions/replica-prototype/{hub-client => create-hub-client}/renewal.test.mjs (100%) rename .github/extensions/replica-prototype/{hub-connection => create-hub-connection}/index.mjs (91%) rename .github/extensions/replica-prototype/{hub-origin-store => create-hub-origin-store}/index.mjs (95%) rename .github/extensions/replica-prototype/{hub-origin-store => create-hub-origin-store}/index.test.mjs (95%) rename .github/extensions/replica-prototype/{recall-learnings => create-learnings-hook}/index.mjs (98%) rename .github/extensions/replica-prototype/{recall-learnings => create-learnings-hook}/index.test.mjs (100%) create mode 100644 .github/extensions/replica-prototype/create-local-review-comments/index.mjs create mode 100644 .github/extensions/replica-prototype/create-local-review-comments/index.test.mjs create mode 100644 .github/extensions/replica-prototype/invalid-hub-origin/index.mjs create mode 100644 .github/extensions/replica-prototype/normalize-hub-origin/index.mjs create mode 100644 .github/extensions/replica-prototype/normalize-selected-hub-origin/index.mjs create mode 100644 .github/extensions/replica-prototype/parse-hub-url/index.mjs create mode 100644 hub/app/javascript/features/prototype-canvas-hub-panel/test-support/render-prototype-canvas-hub-panel/index.tsx diff --git a/.github/extensions/replica-prototype/README.md b/.github/extensions/replica-prototype/README.md index 2626fc61..539bc5ae 100644 --- a/.github/extensions/replica-prototype/README.md +++ b/.github/extensions/replica-prototype/README.md @@ -264,7 +264,7 @@ Without a usable connection, the canvas offers a dismissible dialog once per ope Seven-day access tokens renew automatically while repository access remains valid and the connection has not been revoked or inactive for 30 days. Focus and user-initiated Hub actions count as activity; background polling and renewal do not. Expiry or revocation requires approval again. Temporary outages keep the preview usable and preserve saved credentials. Older connections keep their original expiry and need one new approval to become renewable. **Disconnect Hub** revokes the selected connection; you can also revoke it at `/canvas/connections` in Hub. Switching Hubs does not revoke an earlier connection. -The canvas follows branch changes. If Hub has not discovered the branch, the repository remains connected; push the branch and wait for discovery to use its Builds and reviews. Once Hub imports a successful Build of the current checkout, the canvas automatically registers eligible prototypes using the branch name as the initial title. Existing metadata is preserved. Use **Edit metadata** in **Hub** to change the title or description afterward. Registration requires write access and Hub's branch eligibility checks; errors appear in the shared critical banner and status polling retries automatically. Updated Hub APIs supply a `registrationReason` code explaining missing write access, excluded branches, missing remote heads, or branch authorship requirements. Unknown codes and older Hubs retain a generic error; independently verified permission and remote-ref facts can supply a specific explanation. Installing the extension does not deploy the updated Hub API. +The canvas follows branch changes. If Hub has not discovered the branch, the repository remains connected and comments can be saved locally; push the branch and wait for discovery to use its published Builds and reviews. Once Hub imports a successful Build of the current checkout, the canvas automatically registers eligible prototypes using the branch name as the initial title. Existing metadata is preserved. Use **Edit metadata** in **Hub** to change the title or description afterward. Registration requires write access and Hub's branch eligibility checks; errors appear in the shared critical banner and status polling retries automatically. Updated Hub APIs supply a `registrationReason` code explaining missing write access, excluded branches, missing remote heads, or branch authorship requirements. Unknown codes and older Hubs retain a generic error; independently verified permission and remote-ref facts can supply a specific explanation. Installing the extension does not deploy the updated Hub API. For a Hub started in [local development mode](https://github.com/github/replica/blob/main/hub/docs/local-development.md), open Copilot in Hub's `.local/prototypes/example` checkout and pass `"repository": "local/example"` when opening the canvas. Local repository hints only apply to matching checkouts under `.local/prototypes/` with a loopback Hub origin; they cannot redirect a remote checkout to another Hub repository. Start that example's dev server on a port reachable from the canvas before opening it. @@ -282,7 +282,9 @@ Pending commit-and-publish requests remain deduplicated across verified descenda Copilot uses the existing push workflow, not manual Actions dispatch or another publishing path. It follows `refresh_status`, registers discovered branches with `update_metadata`, and preserves saved metadata. If it stops before pushing, it calls `report_publish_result` with the request target and a `blocked`, `canceled`, or `failed` outcome so the canvas stops waiting and offers a retry. A later push of the current HEAD clears that failure so the canvas follows the new workflow and Build. The action rejects other canvases, targets, or modes, and any request whose push was already observed. It waits for Hub's imported Build matching the pushed commit and returns its exact URL. An older Build or Actions success alone is not enough. The local preview stays open. Entry-page checks still apply; incomplete landing-page verification is reported, not silently repaired and republished. -The canvas header uses Hub's review controls: **Add a comment** sits beside a comment count with unread state, and selecting the count opens the dedicated comments sidebar. The sidebar includes Hub's search, build/page/participant/read/resolved filters, pin visibility control, conversation rows, and thread view; the **Hub** panel remains focused on connection, prototype metadata, and publication state. Select a preview marker or conversation row to open the thread beside its target and reply without leaving the canvas. Markers use the same participant avatars, overflow, unread, resolved, focus, and accessible-label behavior as Hub. When the local checkout matches the imported Build's exact commit, **Add a comment** supports the same element and highlighted-area targets as Hub and saves the new thread directly to Hub. You can also reply, edit or delete your own messages, react, and resolve or reopen threads. Live changes arrive over Hub's review channel, with periodic refresh if that connection is unavailable. Hub credentials stay in the extension process and are never sent to the local preview. +**Add a comment** targets an element or highlighted area. Comments on unpublished changes stay on the author's device until a matching Build is published; comments on a clean checkout of the published Build save directly to Hub. See [local preview comments](../../../hub/docs/prototype-canvas.md#local-preview-comments) for requirements, storage and recovery. + +The header's comment count opens a sidebar with Hub's search, filters, unread state and pin visibility controls. Select a marker or row to open its conversation beside the target. Published conversations support replies, edits, deletion, reactions and resolution. Hub sends live updates, with periodic refresh when unavailable. The **Hub** panel remains focused on connection, metadata and publication. Hub credentials never reach the local preview. Open an already-running unauthenticated loopback prototype in this canvas. The extension's per-panel reverse proxy supplies its bundled bridge to ordinary Vite dev/preview and static HTML servers. Multiple prototypes, including servers in the same checkout, have independent proxy ports and lifecycles. Closing a panel stops only its proxy. diff --git a/.github/extensions/replica-prototype/assets/canvas-bridge.js b/.github/extensions/replica-prototype/assets/canvas-bridge.js index ff6253cb..2531d90d 100644 --- a/.github/extensions/replica-prototype/assets/canvas-bridge.js +++ b/.github/extensions/replica-prototype/assets/canvas-bridge.js @@ -1,4 +1,4 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=/* @__PURE__ */ ((n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)))((/* @__PURE__ */ o((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t}));e.validateShape=P;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern "^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern "^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return L.errors=a,o===0}e.number=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return R.errors=a,l===0}e.slider=ee;function ee(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return ee.errors=a,l===0}e.choice=te;function te(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return te.errors=a,o===0}e.checkboxGroup=ne;function ne(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ne.errors=a,o===0}e.text=re;function re(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return re.errors=a,l===0}e.color=z;function z(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return z.errors=a,o===0}e.button=ie;function ie(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ie.errors=a,o===0}})))(),1);function l(e){if(e&&typeof e==`object`){for(let t of Object.values(e))l(t);Object.freeze(e)}return e}function u(e){return Array.isArray(e)?`[${e.map(u).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${u(e[t])}`).join(`,`)}}`:JSON.stringify(e)}function d(e,t){if(!e)return!0;if(e.all)return e.all.every(e=>d(e,t));if(e.any)return e.any.some(e=>d(e,t));let n=t[e.control];return`equals`in e?n===e.equals:`in`in e?e.in.includes(n):Array.isArray(n)&&n.includes(e.includes)}var{validateDocumentShape:f,validateDeclaration:p}=c.default,m={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function h(e){let t=[...p.errors].filter(e=>!/^\/controls\/\d+(?:\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(m,e?.type)?m[e.type]:void 0,i=r&&c.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params}))}var g=class extends Error{constructor(e){super(`Invalid controls.replica.json:\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(` `)}`),this.name=`ControlsValidationError`,this.issues=e}};function _(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function v(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(v):[]}function y(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new g([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...v(s.when),...v(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function b(e){let t=/* @__PURE__ */ new Set;function n(e,r=0){if(r>24)throw new g([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new g([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new g([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new g([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new g([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function x(e){b(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return C(e),S(e),e;if(!f(e))throw new g(f.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params})));let n=/* @__PURE__ */ new Set;return t.forEach((e,t)=>{try{C(e),S(e)}catch(e){throw e instanceof g?new g(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new g([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function S(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new g(t)}function C(e){if(b(e),!p(e))throw new g(h(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=/* @__PURE__ */ new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=_(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=_(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new g(t);return y(e),e}var w=Symbol.for(`replica.controls.injected.runtime`),T=/* @__PURE__ */ new WeakMap;function E(){let e=globalThis[w];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=/* @__PURE__ */ new Map,t=/* @__PURE__ */ new Set,n=Object.freeze({version:2,create:e=>D(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});T.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[w]=n}return globalThis[w]}function D(e){C(e);let t=l(structuredClone(e)),n=u(t),r=E(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(u(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope "${t.scope}"; reload after schema changes`);return i}let a=T.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=y(t),f=/* @__PURE__ */ new Set,p=/* @__PURE__ */ new Map,m=/* @__PURE__ */ new Set,h={},g=0,v=!1,b=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function w(e){let n={};for(let t of c){let r=o.get(t);n[t]=d(r.when,e)&&d(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return l({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,d(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function D(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=l({...w(D()),revision:g});function O(e){let t=w(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(u(t)!==u(n)&&(x=l({...t,revision:++g}),b=!0,!v)){v=!0;try{for(;b;){b=!1;for(let e of[...f])e();a.notify()}}finally{v=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control "${e}"`);if(!x.visible[e])throw Error(`Control "${e}" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return f.add(e),()=>f.delete(e)},update(e,t){let n=_(k(e),t);if(n)throw Error(`Control "${e}": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control "${n}"`);let i=_(e,r);if(i)throw Error(`Control "${n}": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control "${e}"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(D());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control "${e}" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for "${e}"`);if(m.has(e))throw Error(`Action "${e}" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function O(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role="button"], [role="link"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function k(e,t){return JSON.stringify(e)===JSON.stringify(t)}function A(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function j(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function M(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API "${e}" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API "${e}" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function N(e){let t=e.binding;if(t.type===`api`){let e=M(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method "${n}" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=j(t.selector),r=O(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function P(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\(/.test(t)){let e=t.match(/\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function F(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function I(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):P(e,t.value);if(n.type===`style`)return P(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):P(e,i)}function L(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function R(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(/* @__PURE__ */ Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw L(e)}finally{window.clearTimeout(n)}}function ee(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function te(e,t,n){let r=e.binding;if(r.type===`api`){await R(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[F(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():ee(t,`value`,F(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,F(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,F(n)):i.hash=`#${F(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,"replicaControlsBinding",{value:!0}),window.dispatchEvent(a)}function ne(e){x(e);let t=(e.sets??[e]).map(e=>({controller:D(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=/* @__PURE__ */ new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=E().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!O(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=/* @__PURE__ */ Error(`API cleanup failed: ${L(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=/* @__PURE__ */ new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(F(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return N(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(A()).origin!==new URL(i).origin:A()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function v(e,t,n,r){let i=await R(()=>I(t.control,n));g(e,t,n,r);let a=_(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function b(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=A(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await te(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await v(e,t,o,s?A():a);if(!k(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=L(s),l=!1;if(o)try{let n=await v(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=/* @__PURE__ */ Error(`${c.message} ${L(e).message}`)}throw!l&&k(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function S(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await b(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!k(await R(()=>I(n,r)),n.default))await b(e,t,n.default);else{let n=await v(e,t,r,A());t.rejection&&!k(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,L(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=A();t.control.binding.type===`api`?await R(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>S(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function j(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of y(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!k(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await b(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&k(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(` `).slice(0,1e3))}let M=window.setInterval(()=>{C()},250);function P(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=I(t.control,t.object),r=_(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,P);return C(),{runtime:E(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>j(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?_(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return j(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await j(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(` -`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,P);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function re(){let e=await fetch(`/controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(e.status===404||e.status===410)return;if(!e.ok)throw Error(`controls.replica.json returned HTTP ${e.status}.`);let t=``,n=e.body?.getReader();if(n){let e=new TextDecoder,r=0;for(;;){let{done:i,value:a}=await n.read();if(i)break;if(r+=a.byteLength,r>256e3)throw await n.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);t+=e.decode(a,{stream:!0})}t+=e.decode()}else t=await e.text();if(new TextEncoder().encode(t).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(e.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(t)))return ne(JSON.parse(t))}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var ie=`replica:controls`;function ae(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&z(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||z({[r.id]:r.value}))}catch{return!1}}function oe(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var se=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function B(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!z(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!se.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function ce(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=/* @__PURE__ */ new Map,i=!1;for(let[e,a]of n){let n=se.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!z({[s]:c})){i=!0;continue}let l=r.get(o)??/* @__PURE__ */ new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{B(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function le(e,t){let n=new URL(e,window.location.href),r=ce(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(B(r.scopes)))n.searchParams.set(e,t);return n.toString()}function ue(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=B({...ce(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(le(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=ce(e);if(t.notice)throw Error(t.notice);s=B(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function de(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var fe={mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function pe(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?fe.controlsActionUnavailable:``)}}function me(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>pe(e,t)))}}function he(e){let t=``,n,r,i=``,a=!1,o=/* @__PURE__ */ new Set,s=!1,c=0,l,u,d=!1,f,p=/* @__PURE__ */ new Set,m=/* @__PURE__ */ new Set,h=``,g=ue(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,de(oe(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await re(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(oe);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:ie,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(ae(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:me(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!ae(r.data))return;let i=r.data;if(i.type===`hello`){t=i.epoch,o.clear(),s=!1,m.clear();let e=i.fromFrameUrl&&g?.managed();g?.set(e?g.current():i.controlQuery??``),d||await w,x(`reply`,i.requestId,void 0,e?g?.current():void 0);return}if(i.type!==`command`||i.epoch!==t||o.has(i.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,i.requestId,`Reconnect controls before sending more commands.`);return}o.add(i.requestId);let c=i.command;function l(){if(a||t!==i.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(c?.operation===`url`){g.set(c.query??``),c.scope&&n?.list().some(e=>e.declaration.scope===c.scope&&e.mountedCount>0)&&(m.add(c.scope),g.refresh()),x(`reply`,i.requestId);return}if(!c||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(c.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(c.contexts)||c.contexts.length!==e.length||e.some(e=>!c.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,l)}else{let e=n.list().find(e=>e.declaration.scope===c.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(c.fingerprint!==JSON.stringify(e.declaration)||c.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(c.operation===`restore`){if(!z(c.values))throw Error(`Invalid saved controls.`);await u?.restore(e,c.values,l),m.add(e.declaration.scope),g?.refresh()}else if(c.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,l);else{let t=e.declaration.controls.find(e=>e.id===c.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),c.operation===`update`){let n={[t.id]:c.value};if(!z(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,l)}else if(c.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===i.epoch&&(x(`reply`,i.requestId),u?.navigate())}catch(e){t===i.epoch&&x(`reply`,i.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}var V=`data-replica-canvas-bridge`,ge=new TextEncoder,_e=null,H=null,U=null,W=null,ve=`light-dark(#0969da, #58a6ff)`,G=null,ye=``,be=``,K=/* @__PURE__ */ new Map;function xe(){let e=J();return e.pathname+e.search+e.hash}for(let e of[`popstate`,`hashchange`])window.addEventListener(e,e=>{be=`replicaControlsBinding`in e&&e.replicaControlsBinding?xe():``});function q(e){return e.replace(/\s+/g,` `).trim()}function Se(e,t){let n=``,r=0;for(let i of e){let e=ge.encode(i).length;if(r+e>t)break;n+=i,r+=e}return n}function J(){let e=window.location.search.slice(1).split(`&`).filter(e=>{let t=new URLSearchParams(e).keys().next().value;return t!==`rc`&&!t?.startsWith(`rc.`)}).join(`&`);return{pathname:window.location.pathname,search:e?`?${e}`:``,hash:window.location.hash}}function Ce(){return{width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function we(e){return{x:e.left+window.scrollX,y:e.top+window.scrollY,width:e.width,height:e.height}}function Te(e){let t=e.getAttribute(`aria-labelledby`),n=t?t.split(/\s+/).map(e=>document.getElementById(e)?.textContent||``).join(` `):``,r=`labels`in e&&e.labels?Array.from(e.labels).map(e=>e.textContent||``).join(` `):``;return Se(q(e.getAttribute(`aria-label`)||n||r||e.getAttribute(`alt`)||e.getAttribute(`title`)||``),1e3)}function Ee(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,e=>`\\${e}`)}function De(e){if(e.id){let t=`#${Ee(e.id)}`;if(document.querySelectorAll(t).length===1)return t}for(let t of[`data-testid`,`data-test-id`]){let n=e.getAttribute(t);if(!n)continue;let r=`[${t}="${Ee(n)}"]`;if(document.querySelectorAll(r).length===1)return r}let t=[],n=e;for(;n&&n!==document.documentElement;){let e=n.tagName.toLowerCase(),r=n.parentElement?Array.from(n.parentElement.children).filter(e=>e.tagName===n?.tagName):[],i=r.length>1?`${e}:nth-of-type(${r.indexOf(n)+1})`:e;t.unshift(i);let a=t.join(` > `);if(document.querySelectorAll(a).length===1)return a;n=n.parentElement}return t.join(` > `)}function Oe(e,t){return e.tagName.toLowerCase()!==t.tagName||t.accessibleName&&Te(e)!==t.accessibleName?!1:!t.selectedText||q(e.textContent||``).includes(t.selectedText)}function ke(e){let t=null;try{t=document.querySelector(e.selector)}catch{}if(t&&Oe(t,e))return t;if(!e.accessibleName&&!e.selectedText)return null;let n=null;for(let r of document.getElementsByTagName(e.tagName))if(r!==t&&Oe(r,e)){if(n)return null;n=r}return n}function Ae(){let e=document.createElement(`div`);return e.setAttribute(V,``),Object.assign(e.style,{position:`fixed`,colorScheme:`light dark`,zIndex:`2147483647`,pointerEvents:`none`,border:`2px solid var(--replica-selection-accent)`,borderRadius:`4px`,background:`color-mix(in srgb, var(--replica-selection-accent) 12%, transparent)`,boxSizing:`border-box`}),e.style.setProperty(`--replica-selection-accent`,ve),document.documentElement.append(e),e}function Y(e,t){let n=e.style.position===`absolute`,r=`left`in t?t.left:t.x-window.scrollX,i=`top`in t?t.top:t.y-window.scrollY;Object.assign(e.style,{left:`${r+(n?window.scrollX:0)}px`,top:`${i+(n?window.scrollY:0)}px`,width:`${t.width}px`,height:`${t.height}px`})}function je(e,t=null){U?.remove(),U=e,W=t,U.style.pointerEvents=`none`}function X(e,t){window.parent.postMessage(t,e)}function Z(){H?.(),H=null}function Me(e,t,n){Z(),X(e,{type:`replica:canvas:selection-failed`,nonce:t,reason:n})}function Ne(e,t,n){let r=e.getBoundingClientRect(),i=De(e);if(!r.width||!r.height||!i)return null;let a=Se(q(window.getSelection()?.toString()||``),2e3);return{schemaVersion:1,kind:`element`,route:J(),selector:i,accessibleName:Te(e),tagName:e.tagName.toLowerCase(),selectedText:e.contains(window.getSelection()?.anchorNode||null)?a:``,rect:we(r),viewport:Ce(),elementOffset:{x:Math.min(1,Math.max(0,(t-r.left)/r.width)),y:Math.min(1,Math.max(0,(n-r.top)/r.height))}}}function Pe(e,t){Z();let n=null,r=Ae(),i=document.documentElement.style.cursor;document.documentElement.style.cursor=`crosshair`;function a(e){let t=e.target instanceof Element?e.target.closest(`:not([${V}])`):null;!t||t===document.documentElement||t===document.body?(n=null,r.style.display=`none`):(n=t,r.style.display=`block`,Y(r,t.getBoundingClientRect()))}function o(i){if(!n)return;i.preventDefault(),i.stopImmediatePropagation();let a=Ne(n,i.clientX,i.clientY);a?(r.style.position=Le(n)?`fixed`:`absolute`,Y(r,n.getBoundingClientRect()),je(r,n),Z(),X(e,{type:`replica:canvas:selected`,nonce:t,anchor:a})):(r.remove(),Me(e,t,`element-unavailable`))}function s(n){n.key===`Escape`&&(n.preventDefault(),Z(),X(e,{type:`replica:canvas:selection-cancelled`,nonce:t}))}document.addEventListener(`pointermove`,a,!0),document.addEventListener(`click`,o,!0),document.addEventListener(`keydown`,s,!0),H=()=>{document.removeEventListener(`pointermove`,a,!0),document.removeEventListener(`click`,o,!0),document.removeEventListener(`keydown`,s,!0),document.documentElement.style.cursor=i,U!==r&&r.remove()}}function Fe(e){let t=[[e.left+e.width/2,e.top+e.height/2],[e.left+1,e.top+1],[e.right-1,e.top+1],[e.right-1,e.bottom-1],[e.left+1,e.bottom-1]],n=/* @__PURE__ */ new Set;for(let[e,r]of t){for(let t of document.elementsFromPoint(e,r))if(t.hasAttribute(V)||n.add(t),n.size>=8)break;if(n.size>=8)break}return Array.from(n).flatMap(e=>{let t=De(e),n=e.getBoundingClientRect();return!t||!n.width||!n.height?[]:[{selector:t,accessibleName:Te(e),tagName:e.tagName.toLowerCase(),role:Se(e.getAttribute(`role`)||``,64),textExcerpt:Se(q(e.textContent||``),500),rect:we(n)}]})}function Ie(e,t){Z();let n=document.createElement(`div`);n.setAttribute(V,``),Object.assign(n.style,{position:`fixed`,inset:`0`,zIndex:`2147483646`,cursor:`crosshair`,touchAction:`none`});let r=Ae();r.style.display=`none`,document.body.append(n);let i=null;function a(e,t){if(!i)return;let n=Math.min(i.x,e),a=Math.min(i.y,t),o=Math.abs(e-i.x),s=Math.abs(t-i.y);r.style.display=`block`,Y(r,new DOMRect(n,a,o,s))}function o(e){e.preventDefault(),i={x:e.clientX,y:e.clientY},n.setPointerCapture(e.pointerId),a(e.clientX,e.clientY)}function s(e){i&&(e.preventDefault(),a(e.clientX,e.clientY))}function c(a){if(!i)return;a.preventDefault();let o=new DOMRect(Math.min(i.x,a.clientX),Math.min(i.y,a.clientY),Math.abs(a.clientX-i.x),Math.abs(a.clientY-i.y));if(Math.hypot(o.width,o.height)<8){n.remove(),r.remove(),Me(e,t,`area-too-small`);return}let s={schemaVersion:1,kind:`area`,route:J(),path:[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1},{x:0,y:0}],rect:we(o),viewport:Ce(),elements:Fe(o)};n.remove(),r.style.position=`absolute`,Y(r,o),je(r),Z(),X(e,{type:`replica:canvas:selected`,nonce:t,anchor:s})}function l(n){n.key===`Escape`&&(n.preventDefault(),Z(),X(e,{type:`replica:canvas:selection-cancelled`,nonce:t}))}n.addEventListener(`pointerdown`,o),n.addEventListener(`pointermove`,s),n.addEventListener(`pointerup`,c),document.addEventListener(`keydown`,l,!0),H=()=>{n.removeEventListener(`pointerdown`,o),n.removeEventListener(`pointermove`,s),n.removeEventListener(`pointerup`,c),document.removeEventListener(`keydown`,l,!0),n.remove(),U!==r&&r.remove()}}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Le(e){for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t).position;if(e===`fixed`||e===`sticky`)return!0}return!1}function Re(e){let t=J();if(!Q(e)||!Q(e.route)||e.route.pathname!==t.pathname||e.route.search!==t.search||e.route.hash!==t.hash)return null;if(e.kind===`area`){if(!Q(e.rect)||typeof e.rect.x!=`number`||typeof e.rect.y!=`number`||typeof e.rect.width!=`number`||typeof e.rect.height!=`number`||!Object.values(e.rect).every(Number.isFinite))return null;let t={x:e.rect.x-window.scrollX,y:e.rect.y-window.scrollY,width:e.rect.width,height:e.rect.height};return{x:t.x+t.width,y:t.y,rect:t,viewportAnchored:!1}}if(e.kind!==`element`||typeof e.selector!=`string`||typeof e.accessibleName!=`string`||typeof e.tagName!=`string`||e.selectedText!==void 0&&typeof e.selectedText!=`string`||!Q(e.elementOffset)||typeof e.elementOffset.x!=`number`||typeof e.elementOffset.y!=`number`||!Number.isFinite(e.elementOffset.x)||!Number.isFinite(e.elementOffset.y))return null;let n=ke({selector:e.selector,accessibleName:e.accessibleName,tagName:e.tagName,selectedText:e.selectedText});if(!n)return null;let r=n.getBoundingClientRect();return!r.width||!r.height?null:{x:r.left+r.width*e.elementOffset.x,y:r.top+r.height*e.elementOffset.y,viewportAnchored:Le(n)}}function $(e=!1){if(!G||!_e)return;let t=J(),n=JSON.stringify(t);e&&=n===ye,ye=n;let r=[];for(let t of G.anchors){let n=K.get(t.id),i;if(e&&n&&!n.viewportAnchored){let e=n.scrollX-window.scrollX,t=n.scrollY-window.scrollY;i={x:n.x+e,y:n.y+t,...n.rect?{rect:{...n.rect,x:n.rect.x+e,y:n.rect.y+t}}:{}}}else{let e=Re(t.anchor);if(!e){K.delete(t.id);continue}K.set(t.id,{...e,scrollX:window.scrollX,scrollY:window.scrollY}),i={x:e.x,y:e.y,...`rect`in e?{rect:e.rect}:{}}}r.push({id:t.id,...i})}X(_e,{type:`replica:canvas:resolved`,protocolVersion:1,nonce:G.nonce,route:t,...be===xe()?{replaceRoute:!0}:{},results:r})}function ze(e){let t=e.data;if(document.querySelector(`script[src="/__replica/bridge/v1.js"]`)||e.source!==window.parent||e.origin!==_e||!Q(t)||typeof t.nonce!=`string`||t.nonce.length>100)return;if(t.type===`replica:canvas:request-ready`){X(e.origin,{type:`replica:canvas:ready`,protocolVersion:1,nonce:t.nonce,route:J(),...be===xe()?{replaceRoute:!0}:{}});return}if(t.type===`replica:canvas:theme`){if(typeof t.accent!=`string`||t.accent.length>200||!CSS.supports(`color`,t.accent))return;ve=t.accent;for(let e of document.querySelectorAll(`[${V}]`))e.style.setProperty(`--replica-selection-accent`,ve);return}if(t.type===`replica:canvas:click`){let{selector:n,expectedLabel:r,route:i}=t,a=J(),o=`The click target is unavailable or ambiguous.`,s=null;if(typeof n==`string`&&n.length>0&&n.length<=512&&typeof r==`string`&&r.length>0&&r.length<=200&&Q(i)&&typeof i.pathname==`string`&&i.pathname===a.pathname&&i.search===a.search&&i.hash===a.hash)try{let e=document.querySelectorAll(n);e.length===1&&(s=e.item(0))}catch{o=`The click selector is invalid.`}else o=`The prototype route changed or the click input is invalid.`;if(s){let n=s;if(O(n,!0)||(Te(n)||q(n.textContent||``).slice(0,200))!==r)o=`The target is hidden, blocked, disabled, unsafe, or its accessible name changed.`;else{n.click(),X(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!0});return}}X(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!1,error:o});return}if(t.type===`replica:canvas:select`){t.mode===`element`?Pe(e.origin,t.nonce):t.mode===`area`&&Ie(e.origin,t.nonce);return}if(t.type===`replica:canvas:cancel-selection`){Z(),X(e.origin,{type:`replica:canvas:selection-cancelled`,nonce:t.nonce});return}if(t.type===`replica:canvas:clear-selection`){U?.remove(),U=null,W=null;return}if(t.type!==`replica:canvas:resolve`||!Array.isArray(t.anchors)||t.anchors.length>200)return;let n=[],r=t.anchors;for(let e of r)Q(e)&&typeof e.id==`number`&&Number.isSafeInteger(e.id)&&n.push({id:e.id,anchor:e.anchor});G={nonce:t.nonce,anchors:n},K.clear(),$()}var Be=Symbol.for(`replica.canvas.bridge.v1`),Ve=window;function He(e){if(!/^http:\/\/127\.0\.0\.1:\d+$/.test(e))throw Error(`Invalid Replica canvas parent.`);let t=Ve[Be];if(t===!0)throw Error(`Remove the old source bridge before using the extension-owned bridge.`);typeof t==`function`&&t(),ve=`light-dark(#0969da, #58a6ff)`,_e=e,G=null,ye=``,K.clear();let n=he(e),r=null;function i(){r!==null&&window.cancelAnimationFrame(r),r=null,U&&W&&(U.style.position=Le(W)?`fixed`:`absolute`,Y(U,W.getBoundingClientRect())),$()}function a(){r===null&&G&&(r=window.requestAnimationFrame(i))}function o(e){U&&W&&(e.target!==document&&e.target!==window||Le(W))&&Y(U,W.getBoundingClientRect()),r===null?$(e.target===document||e.target===window):i()}function s(){$()}function c(t){if(t.key!==`Escape`||t.defaultPrevented||t.isComposing||H||!G||t.target instanceof Element&&t.target.closest(`[role="dialog"], dialog, [role="menu"]`))return;let n=G;window.setTimeout(()=>{t.defaultPrevented||H||G!==n||X(e,{type:`replica:canvas:conversation-dismiss-requested`,nonce:n.nonce})},0)}window.addEventListener(`message`,ze),window.addEventListener(`scroll`,o,{capture:!0,passive:!0}),window.addEventListener(`resize`,s),window.addEventListener(`keydown`,c);let l=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.closest(`[${V}], [data-replica-controls-bridge]`)))&&a()});l.observe(document.documentElement,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let u=typeof ResizeObserver==`function`?new ResizeObserver(a):null;u?.observe(document.documentElement),Ve[Be]=()=>{window.removeEventListener(`message`,ze),window.removeEventListener(`scroll`,o,!0),window.removeEventListener(`resize`,s),window.removeEventListener(`keydown`,c),l.disconnect(),u?.disconnect(),r!==null&&window.cancelAnimationFrame(r),G=null,ye=``,K.clear(),n(),Z(),U?.remove(),U=null,W=null}}export{He as installBridge}; \ No newline at end of file +`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,P);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function re(){let e=await fetch(`/controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(e.status===404||e.status===410)return;if(!e.ok)throw Error(`controls.replica.json returned HTTP ${e.status}.`);let t=``,n=e.body?.getReader();if(n){let e=new TextDecoder,r=0;for(;;){let{done:i,value:a}=await n.read();if(i)break;if(r+=a.byteLength,r>256e3)throw await n.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);t+=e.decode(a,{stream:!0})}t+=e.decode()}else t=await e.text();if(new TextEncoder().encode(t).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(e.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(t)))return ne(JSON.parse(t))}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var ie=`replica:controls`;function ae(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&z(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||z({[r.id]:r.value}))}catch{return!1}}function oe(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var se=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function B(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!z(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!se.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function ce(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=/* @__PURE__ */ new Map,i=!1;for(let[e,a]of n){let n=se.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!z({[s]:c})){i=!0;continue}let l=r.get(o)??/* @__PURE__ */ new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{B(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function le(e,t){let n=new URL(e,window.location.href),r=ce(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(B(r.scopes)))n.searchParams.set(e,t);return n.toString()}function ue(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=B({...ce(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(le(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=ce(e);if(t.notice)throw Error(t.notice);s=B(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function de(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var fe={localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPagesExceeded:`Too many review comment pages.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function pe(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?fe.controlsActionUnavailable:``)}}function me(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>pe(e,t)))}}function he(e){let t=``,n,r,i=``,a=!1,o=/* @__PURE__ */ new Set,s=!1,c=0,l,u,d=!1,f,p=/* @__PURE__ */ new Set,m=/* @__PURE__ */ new Set,h=``,g=ue(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,de(oe(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await re(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(oe);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:ie,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(ae(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:me(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!ae(r.data))return;let i=r.data;if(i.type===`hello`){t=i.epoch,o.clear(),s=!1,m.clear();let e=i.fromFrameUrl&&g?.managed();g?.set(e?g.current():i.controlQuery??``),d||await w,x(`reply`,i.requestId,void 0,e?g?.current():void 0);return}if(i.type!==`command`||i.epoch!==t||o.has(i.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,i.requestId,`Reconnect controls before sending more commands.`);return}o.add(i.requestId);let c=i.command;function l(){if(a||t!==i.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(c?.operation===`url`){g.set(c.query??``),c.scope&&n?.list().some(e=>e.declaration.scope===c.scope&&e.mountedCount>0)&&(m.add(c.scope),g.refresh()),x(`reply`,i.requestId);return}if(!c||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(c.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(c.contexts)||c.contexts.length!==e.length||e.some(e=>!c.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,l)}else{let e=n.list().find(e=>e.declaration.scope===c.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(c.fingerprint!==JSON.stringify(e.declaration)||c.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(c.operation===`restore`){if(!z(c.values))throw Error(`Invalid saved controls.`);await u?.restore(e,c.values,l),m.add(e.declaration.scope),g?.refresh()}else if(c.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,l);else{let t=e.declaration.controls.find(e=>e.id===c.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),c.operation===`update`){let n={[t.id]:c.value};if(!z(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,l)}else if(c.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===i.epoch&&(x(`reply`,i.requestId),u?.navigate())}catch(e){t===i.epoch&&x(`reply`,i.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}var V=`data-replica-canvas-bridge`,ge=new TextEncoder,_e=null,H=null,U=null,W=null,ve=`light-dark(#0969da, #58a6ff)`,G=null,ye=``,be=``,K=/* @__PURE__ */ new Map;function xe(){let e=J();return e.pathname+e.search+e.hash}for(let e of[`popstate`,`hashchange`])window.addEventListener(e,e=>{be=`replicaControlsBinding`in e&&e.replicaControlsBinding?xe():``});function q(e){return e.replace(/\s+/g,` `).trim()}function Se(e,t){let n=``,r=0;for(let i of e){let e=ge.encode(i).length;if(r+e>t)break;n+=i,r+=e}return n}function J(){let e=window.location.search.slice(1).split(`&`).filter(e=>{let t=new URLSearchParams(e).keys().next().value;return t!==`rc`&&!t?.startsWith(`rc.`)}).join(`&`);return{pathname:window.location.pathname,search:e?`?${e}`:``,hash:window.location.hash}}function Ce(){return{width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function we(e){return{x:e.left+window.scrollX,y:e.top+window.scrollY,width:e.width,height:e.height}}function Te(e){let t=e.getAttribute(`aria-labelledby`),n=t?t.split(/\s+/).map(e=>document.getElementById(e)?.textContent||``).join(` `):``,r=`labels`in e&&e.labels?Array.from(e.labels).map(e=>e.textContent||``).join(` `):``;return Se(q(e.getAttribute(`aria-label`)||n||r||e.getAttribute(`alt`)||e.getAttribute(`title`)||``),1e3)}function Ee(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,e=>`\\${e}`)}function De(e){if(e.id){let t=`#${Ee(e.id)}`;if(document.querySelectorAll(t).length===1)return t}for(let t of[`data-testid`,`data-test-id`]){let n=e.getAttribute(t);if(!n)continue;let r=`[${t}="${Ee(n)}"]`;if(document.querySelectorAll(r).length===1)return r}let t=[],n=e;for(;n&&n!==document.documentElement;){let e=n.tagName.toLowerCase(),r=n.parentElement?Array.from(n.parentElement.children).filter(e=>e.tagName===n?.tagName):[],i=r.length>1?`${e}:nth-of-type(${r.indexOf(n)+1})`:e;t.unshift(i);let a=t.join(` > `);if(document.querySelectorAll(a).length===1)return a;n=n.parentElement}return t.join(` > `)}function Oe(e,t){return e.tagName.toLowerCase()!==t.tagName||t.accessibleName&&Te(e)!==t.accessibleName?!1:!t.selectedText||q(e.textContent||``).includes(t.selectedText)}function ke(e){let t=null;try{t=document.querySelector(e.selector)}catch{}if(t&&Oe(t,e))return t;if(!e.accessibleName&&!e.selectedText)return null;let n=null;for(let r of document.getElementsByTagName(e.tagName))if(r!==t&&Oe(r,e)){if(n)return null;n=r}return n}function Ae(){let e=document.createElement(`div`);return e.setAttribute(V,``),Object.assign(e.style,{position:`fixed`,colorScheme:`light dark`,zIndex:`2147483647`,pointerEvents:`none`,border:`2px solid var(--replica-selection-accent)`,borderRadius:`4px`,background:`color-mix(in srgb, var(--replica-selection-accent) 12%, transparent)`,boxSizing:`border-box`}),e.style.setProperty(`--replica-selection-accent`,ve),document.documentElement.append(e),e}function Y(e,t){let n=e.style.position===`absolute`,r=`left`in t?t.left:t.x-window.scrollX,i=`top`in t?t.top:t.y-window.scrollY;Object.assign(e.style,{left:`${r+(n?window.scrollX:0)}px`,top:`${i+(n?window.scrollY:0)}px`,width:`${t.width}px`,height:`${t.height}px`})}function je(e,t=null){U?.remove(),U=e,W=t,U.style.pointerEvents=`none`}function X(e,t){window.parent.postMessage(t,e)}function Z(){H?.(),H=null}function Me(e,t,n){Z(),X(e,{type:`replica:canvas:selection-failed`,nonce:t,reason:n})}function Ne(e,t,n){let r=e.getBoundingClientRect(),i=De(e);if(!r.width||!r.height||!i)return null;let a=Se(q(window.getSelection()?.toString()||``),2e3);return{schemaVersion:1,kind:`element`,route:J(),selector:i,accessibleName:Te(e),tagName:e.tagName.toLowerCase(),selectedText:e.contains(window.getSelection()?.anchorNode||null)?a:``,rect:we(r),viewport:Ce(),elementOffset:{x:Math.min(1,Math.max(0,(t-r.left)/r.width)),y:Math.min(1,Math.max(0,(n-r.top)/r.height))}}}function Pe(e,t){Z();let n=null,r=Ae(),i=document.documentElement.style.cursor;document.documentElement.style.cursor=`crosshair`;function a(e){let t=e.target instanceof Element?e.target.closest(`:not([${V}])`):null;!t||t===document.documentElement||t===document.body?(n=null,r.style.display=`none`):(n=t,r.style.display=`block`,Y(r,t.getBoundingClientRect()))}function o(i){if(!n)return;i.preventDefault(),i.stopImmediatePropagation();let a=Ne(n,i.clientX,i.clientY);a?(r.style.position=Le(n)?`fixed`:`absolute`,Y(r,n.getBoundingClientRect()),je(r,n),Z(),X(e,{type:`replica:canvas:selected`,nonce:t,anchor:a})):(r.remove(),Me(e,t,`element-unavailable`))}function s(n){n.key===`Escape`&&(n.preventDefault(),Z(),X(e,{type:`replica:canvas:selection-cancelled`,nonce:t}))}document.addEventListener(`pointermove`,a,!0),document.addEventListener(`click`,o,!0),document.addEventListener(`keydown`,s,!0),H=()=>{document.removeEventListener(`pointermove`,a,!0),document.removeEventListener(`click`,o,!0),document.removeEventListener(`keydown`,s,!0),document.documentElement.style.cursor=i,U!==r&&r.remove()}}function Fe(e){let t=[[e.left+e.width/2,e.top+e.height/2],[e.left+1,e.top+1],[e.right-1,e.top+1],[e.right-1,e.bottom-1],[e.left+1,e.bottom-1]],n=/* @__PURE__ */ new Set;for(let[e,r]of t){for(let t of document.elementsFromPoint(e,r))if(t.hasAttribute(V)||n.add(t),n.size>=8)break;if(n.size>=8)break}return Array.from(n).flatMap(e=>{let t=De(e),n=e.getBoundingClientRect();return!t||!n.width||!n.height?[]:[{selector:t,accessibleName:Te(e),tagName:e.tagName.toLowerCase(),role:Se(e.getAttribute(`role`)||``,64),textExcerpt:Se(q(e.textContent||``),500),rect:we(n)}]})}function Ie(e,t){Z();let n=document.createElement(`div`);n.setAttribute(V,``),Object.assign(n.style,{position:`fixed`,inset:`0`,zIndex:`2147483646`,cursor:`crosshair`,touchAction:`none`});let r=Ae();r.style.display=`none`,document.body.append(n);let i=null;function a(e,t){if(!i)return;let n=Math.min(i.x,e),a=Math.min(i.y,t),o=Math.abs(e-i.x),s=Math.abs(t-i.y);r.style.display=`block`,Y(r,new DOMRect(n,a,o,s))}function o(e){e.preventDefault(),i={x:e.clientX,y:e.clientY},n.setPointerCapture(e.pointerId),a(e.clientX,e.clientY)}function s(e){i&&(e.preventDefault(),a(e.clientX,e.clientY))}function c(a){if(!i)return;a.preventDefault();let o=new DOMRect(Math.min(i.x,a.clientX),Math.min(i.y,a.clientY),Math.abs(a.clientX-i.x),Math.abs(a.clientY-i.y));if(Math.hypot(o.width,o.height)<8){n.remove(),r.remove(),Me(e,t,`area-too-small`);return}let s={schemaVersion:1,kind:`area`,route:J(),path:[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1},{x:0,y:0}],rect:we(o),viewport:Ce(),elements:Fe(o)};n.remove(),r.style.position=`absolute`,Y(r,o),je(r),Z(),X(e,{type:`replica:canvas:selected`,nonce:t,anchor:s})}function l(n){n.key===`Escape`&&(n.preventDefault(),Z(),X(e,{type:`replica:canvas:selection-cancelled`,nonce:t}))}n.addEventListener(`pointerdown`,o),n.addEventListener(`pointermove`,s),n.addEventListener(`pointerup`,c),document.addEventListener(`keydown`,l,!0),H=()=>{n.removeEventListener(`pointerdown`,o),n.removeEventListener(`pointermove`,s),n.removeEventListener(`pointerup`,c),document.removeEventListener(`keydown`,l,!0),n.remove(),U!==r&&r.remove()}}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Le(e){for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t).position;if(e===`fixed`||e===`sticky`)return!0}return!1}function Re(e){let t=J();if(!Q(e)||!Q(e.route)||e.route.pathname!==t.pathname||e.route.search!==t.search||e.route.hash!==t.hash)return null;if(e.kind===`area`){if(!Q(e.rect)||typeof e.rect.x!=`number`||typeof e.rect.y!=`number`||typeof e.rect.width!=`number`||typeof e.rect.height!=`number`||!Object.values(e.rect).every(Number.isFinite))return null;let t={x:e.rect.x-window.scrollX,y:e.rect.y-window.scrollY,width:e.rect.width,height:e.rect.height};return{x:t.x+t.width,y:t.y,rect:t,viewportAnchored:!1}}if(e.kind!==`element`||typeof e.selector!=`string`||typeof e.accessibleName!=`string`||typeof e.tagName!=`string`||e.selectedText!==void 0&&typeof e.selectedText!=`string`||!Q(e.elementOffset)||typeof e.elementOffset.x!=`number`||typeof e.elementOffset.y!=`number`||!Number.isFinite(e.elementOffset.x)||!Number.isFinite(e.elementOffset.y))return null;let n=ke({selector:e.selector,accessibleName:e.accessibleName,tagName:e.tagName,selectedText:e.selectedText});if(!n)return null;let r=n.getBoundingClientRect();return!r.width||!r.height?null:{x:r.left+r.width*e.elementOffset.x,y:r.top+r.height*e.elementOffset.y,viewportAnchored:Le(n)}}function $(e=!1){if(!G||!_e)return;let t=J(),n=JSON.stringify(t);e&&=n===ye,ye=n;let r=[];for(let t of G.anchors){let n=K.get(t.id),i;if(e&&n&&!n.viewportAnchored){let e=n.scrollX-window.scrollX,t=n.scrollY-window.scrollY;i={x:n.x+e,y:n.y+t,...n.rect?{rect:{...n.rect,x:n.rect.x+e,y:n.rect.y+t}}:{}}}else{let e=Re(t.anchor);if(!e){K.delete(t.id);continue}K.set(t.id,{...e,scrollX:window.scrollX,scrollY:window.scrollY}),i={x:e.x,y:e.y,...`rect`in e?{rect:e.rect}:{}}}r.push({id:t.id,...i})}X(_e,{type:`replica:canvas:resolved`,protocolVersion:1,nonce:G.nonce,route:t,...be===xe()?{replaceRoute:!0}:{},results:r})}function ze(e){let t=e.data;if(document.querySelector(`script[src="/__replica/bridge/v1.js"]`)||e.source!==window.parent||e.origin!==_e||!Q(t)||typeof t.nonce!=`string`||t.nonce.length>100)return;if(t.type===`replica:canvas:request-ready`){X(e.origin,{type:`replica:canvas:ready`,protocolVersion:1,nonce:t.nonce,route:J(),...be===xe()?{replaceRoute:!0}:{}});return}if(t.type===`replica:canvas:theme`){if(typeof t.accent!=`string`||t.accent.length>200||!CSS.supports(`color`,t.accent))return;ve=t.accent;for(let e of document.querySelectorAll(`[${V}]`))e.style.setProperty(`--replica-selection-accent`,ve);return}if(t.type===`replica:canvas:click`){let{selector:n,expectedLabel:r,route:i}=t,a=J(),o=`The click target is unavailable or ambiguous.`,s=null;if(typeof n==`string`&&n.length>0&&n.length<=512&&typeof r==`string`&&r.length>0&&r.length<=200&&Q(i)&&typeof i.pathname==`string`&&i.pathname===a.pathname&&i.search===a.search&&i.hash===a.hash)try{let e=document.querySelectorAll(n);e.length===1&&(s=e.item(0))}catch{o=`The click selector is invalid.`}else o=`The prototype route changed or the click input is invalid.`;if(s){let n=s;if(O(n,!0)||(Te(n)||q(n.textContent||``).slice(0,200))!==r)o=`The target is hidden, blocked, disabled, unsafe, or its accessible name changed.`;else{n.click(),X(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!0});return}}X(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!1,error:o});return}if(t.type===`replica:canvas:select`){t.mode===`element`?Pe(e.origin,t.nonce):t.mode===`area`&&Ie(e.origin,t.nonce);return}if(t.type===`replica:canvas:cancel-selection`){Z(),X(e.origin,{type:`replica:canvas:selection-cancelled`,nonce:t.nonce});return}if(t.type===`replica:canvas:clear-selection`){U?.remove(),U=null,W=null;return}if(t.type!==`replica:canvas:resolve`||!Array.isArray(t.anchors)||t.anchors.length>200)return;let n=[],r=t.anchors;for(let e of r)Q(e)&&typeof e.id==`number`&&Number.isSafeInteger(e.id)&&n.push({id:e.id,anchor:e.anchor});G={nonce:t.nonce,anchors:n},K.clear(),$()}var Be=Symbol.for(`replica.canvas.bridge.v1`),Ve=window;function He(e){if(!/^http:\/\/127\.0\.0\.1:\d+$/.test(e))throw Error(`Invalid Replica canvas parent.`);let t=Ve[Be];if(t===!0)throw Error(`Remove the old source bridge before using the extension-owned bridge.`);typeof t==`function`&&t(),ve=`light-dark(#0969da, #58a6ff)`,_e=e,G=null,ye=``,K.clear();let n=he(e),r=null;function i(){r!==null&&window.cancelAnimationFrame(r),r=null,U&&W&&(U.style.position=Le(W)?`fixed`:`absolute`,Y(U,W.getBoundingClientRect())),$()}function a(){r===null&&G&&(r=window.requestAnimationFrame(i))}function o(e){U&&W&&(e.target!==document&&e.target!==window||Le(W))&&Y(U,W.getBoundingClientRect()),r===null?$(e.target===document||e.target===window):i()}function s(){$()}function c(t){if(t.key!==`Escape`||t.defaultPrevented||t.isComposing||H||!G||t.target instanceof Element&&t.target.closest(`[role="dialog"], dialog, [role="menu"]`))return;let n=G;window.setTimeout(()=>{t.defaultPrevented||H||G!==n||X(e,{type:`replica:canvas:conversation-dismiss-requested`,nonce:n.nonce})},0)}window.addEventListener(`message`,ze),window.addEventListener(`scroll`,o,{capture:!0,passive:!0}),window.addEventListener(`resize`,s),window.addEventListener(`keydown`,c);let l=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.closest(`[${V}], [data-replica-controls-bridge]`)))&&a()});l.observe(document.documentElement,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let u=typeof ResizeObserver==`function`?new ResizeObserver(a):null;u?.observe(document.documentElement),Ve[Be]=()=>{window.removeEventListener(`message`,ze),window.removeEventListener(`scroll`,o,!0),window.removeEventListener(`resize`,s),window.removeEventListener(`keydown`,c),l.disconnect(),u?.disconnect(),r!==null&&window.cancelAnimationFrame(r),G=null,ye=``,K.clear(),n(),Z(),U?.remove(),U=null,W=null}}export{He as installBridge}; \ No newline at end of file diff --git a/.github/extensions/replica-prototype/assets/renderer.js b/.github/extensions/replica-prototype/assets/renderer.js index cb4036f9..9a921878 100644 --- a/.github/extensions/replica-prototype/assets/renderer.js +++ b/.github/extensions/replica-prototype/assets/renderer.js @@ -1,7 +1,7 @@ -import{n as e,t}from"./renderer-rolldown-runtime.js";import{A as n,B as r,C as i,D as a,E as o,F as s,G as c,H as l,I as u,K as d,L as f,M as p,N as m,O as h,P as g,R as _,S as v,T as y,U as b,V as x,W as S,_ as C,a as w,b as T,c as E,d as D,f as O,g as k,h as A,i as j,j as M,k as ee,l as N,m as P,n as F,o as I,p as L,r as R,s as z,t as te,u as B,v as ne,w as re,x as ie,y as ae,z as oe}from"./renderer-vendor.js";var V=e(d(),1),se=S(),H=l(),U=b();function ce({size:e=`medium`,className:t,label:n}){return(0,U.jsx)(`span`,{role:n?`status`:void 0,"aria-label":n,"aria-hidden":!n||void 0,className:`hub-spinner hub-spinner--${e}${t?` ${t}`:``}`})}function le({className:e,...t}){return(0,U.jsx)(`span`,{...t,className:`hub-visually-hidden${e?` ${e}`:``}`})}function W(e){let t=(0,V.useId)(),{as:n,href:r,ref:i,icon:a,description:o,loading:s=!1,size:c=`medium`,variant:l=`default`,className:u,...d}=e,f=`hub-icon-button${c===`small`?` hub-icon-button--small`:``}${l===`invisible`?` hub-icon-button--invisible`:``}${l===`danger`?` hub-icon-button--danger`:``}${u?` ${u}`:``}`,p=l===`invisible`?`subtle`:`secondary`,m=!(!o||d.title||d[`aria-describedby`]||`disabled`in d&&d.disabled),h=[d[`aria-describedby`],o&&!m?t:void 0].filter(Boolean).join(` `)||void 0,g=d.title??(m?void 0:o??d[`aria-label`]),_=o&&!m?(0,U.jsx)(le,{id:t,children:o}):null,v=s?(0,U.jsx)(ce,{decorative:!0,size:`small`}):(0,U.jsx)(a,{size:16}),y=s?!0:d[`aria-busy`];if(n===`a`){let e=i,t=(0,U.jsx)(H.Button,{...d,ref:e,as:`a`,href:r,leadingVisual:v,variant:p,size:c,className:f,"aria-busy":y,"aria-describedby":h,title:g,children:_});return m&&o?(0,U.jsx)(H.Tooltip,{ref:i,text:o,type:`description`,children:t}):t}let b=(0,U.jsx)(H.Button,{...d,ref:i,type:d.type??`button`,leadingVisual:v,variant:p,size:c,className:f,"aria-busy":y,"aria-describedby":h,title:g,children:_});return m&&o?(0,U.jsx)(H.Tooltip,{ref:i,text:o,type:`description`,children:b}):b}function ue({title:e,closeLabel:t,onClose:n,returnFocusRef:r,descriptionId:i,className:a,children:o}){let s=(0,V.useRef)(null),c=(0,V.useId)();return(0,V.useLayoutEffect)(()=>{let e=s.current,t=r?.current??(document.activeElement instanceof HTMLElement?document.activeElement:null);return e?.showModal(),()=>{e?.close(),t?.focus()}},[r]),(0,U.jsxs)(`dialog`,{ref:s,"aria-labelledby":c,"aria-describedby":i,className:a?`canvas-dialog ${a}`:`canvas-dialog`,onCancel:e=>{e.preventDefault(),n()},onClick:e=>{if(e.target!==e.currentTarget)return;let{left:t,right:r,top:i,bottom:a}=e.currentTarget.getBoundingClientRect();(e.clientXr||e.clientYa)&&n()},children:[(0,U.jsxs)(`header`,{className:`canvas-dialog-header`,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`5`,id:c,children:e}),(0,U.jsx)(W,{variant:`invisible`,size:`small`,icon:B,"aria-label":t,onClick:n})]}),o]})}var G={mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function de({onClose:e,state:t,titleButtonRef:r}){let[i,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),l=t.stats.branchError?void 0:t.stats.branch,d=t.sessionId,f=t.stats.comparison;async function p(e,t){try{await navigator.clipboard.writeText(e),o(t),c(null)}catch{o(null),c(t===`branch`?G.branch:G.sessionId)}}function m(e,t){if(!e)return null;let r=t===`branch`?G.copyBranch:G.copySessionId,a=t===`branch`?G.branchCopied:G.sessionIdCopied;return(0,U.jsx)(H.Button,{type:`button`,className:`canvas-icon-button`,variant:`subtle`,size:`small`,leadingVisual:i===t?(0,U.jsx)(u,{size:16}):(0,U.jsx)(n,{size:16}),"aria-label":i===t?a:r,title:i===t?a:r,onClick:()=>void p(e,t),children:(0,U.jsx)(`span`,{className:`visually-hidden`,children:r})})}return(0,U.jsxs)(ue,{title:G.buildDetails,closeLabel:G.closeBuildDetails,className:`build-details-dialog`,returnFocusRef:r,onClose:e,children:[(0,U.jsxs)(`dl`,{className:`build-details-list`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:G.branch}),(0,U.jsxs)(`dd`,{children:[(0,U.jsx)(a,{size:16,"aria-hidden":`true`}),(0,U.jsx)(`code`,{children:l||t.stats.branchError||G.unavailable}),m(l,`branch`)]})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:G.sessionId}),(0,U.jsxs)(`dd`,{children:[(0,U.jsx)(`code`,{children:d||G.unavailable}),m(d,`sessionId`)]})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:f?.branch?`Behind ${f.branch}${f.source===`local`?` (local)`:``}`:G.comparison}),(0,U.jsx)(`dd`,{children:f?.error||(f?.behind===0?G.upToDate:f?.behind==null?G.unavailable:G.commitsBehind(f.behind))})]})]}),(0,U.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`visually-hidden`,children:i===`branch`?`${G.branchCopied}.`:i===`sessionId`?`${G.sessionIdCopied}.`:``}),s?(0,U.jsx)(`span`,{role:`alert`,className:`build-details-copy-error`,children:G.buildDetailsCopyFailed(s)}):null]})}function fe({pairing:e}){let[t,r]=(0,V.useState)(`idle`),i=(0,V.useRef)(null);(0,V.useEffect)(()=>{i.current?.querySelector(`a`)?.focus()},[]);async function a(){try{await navigator.clipboard.writeText(e.verificationUrl),r(`copied`)}catch{r(`failed`)}}return(0,U.jsxs)(`section`,{className:`hub-connection-approval`,"aria-label":G.connectionApproval,children:[(0,U.jsxs)(`p`,{role:`status`,children:[G.connectionWaiting,` `,(0,U.jsx)(`strong`,{children:e.userCode}),`.`]}),(0,U.jsxs)(`div`,{ref:i,className:`hub-connection-approval-actions`,role:`group`,"aria-label":G.connectionApproval,children:[(0,U.jsx)(H.Button,{as:`a`,variant:`primary`,size:`medium`,href:e.verificationUrl,target:`_blank`,rel:`noopener noreferrer`,children:G.connectToHub}),(0,U.jsx)(W,{icon:t===`copied`?u:n,size:`medium`,className:`hub-connection-approval-copy`,"aria-label":t===`copied`?G.approvalLinkCopied:G.copyApprovalLink,onClick:()=>void a()})]}),(0,U.jsx)(le,{role:`status`,children:t===`copied`?G.approvalLinkCopied:``}),t===`failed`?(0,U.jsx)(`p`,{role:`alert`,children:G.approvalCopyFailed}):null]})}function pe({status:e,pairing:t,connecting:n,error:r,onConnect:i,onSelectHub:a,onResetHub:o,onClose:s,hubButtonRef:c}){let l=(0,V.useId)(),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(!1),[g,_]=(0,V.useState)(!1),[v,y]=(0,V.useState)(!1),[b,x]=(0,V.useState)(``),S=(0,V.useRef)(null),C=(0,V.useRef)(null),w=f||!e?.hubOrigin||u!==null&&!m,T=(0,V.useRef)(w),E=u??e?.hubOrigin??``,D=n||g||v,O=!!t||n;(0,V.useEffect)(()=>{w&&!O?S.current?.focus():T.current&&!O&&C.current?.focus(),T.current=w},[w,O]),(0,V.useEffect)(()=>{if(f||u===null||!m||!e?.hubOrigin)return;let t=window.setTimeout(()=>d(null),0);return()=>window.clearTimeout(t)},[u,f,m,e?.hubOrigin]);async function k(){if(!D){_(!0),x(``);try{await a(E),d(null),p(!1)}catch(e){x(e instanceof Error?e.message:String(e))}finally{_(!1)}}}async function A(){if(!D&&o){y(!0),x(``);try{d(await o()),p(!!e?.hubOrigin)}catch(e){x(e instanceof Error?e.message:String(e))}finally{y(!1)}}}return(0,U.jsxs)(ue,{title:G.connectToHub,closeLabel:G.closeConnectionDialog,onClose:s,returnFocusRef:c,children:[(0,U.jsx)(`p`,{children:G.connectionDescription}),b||r?(0,U.jsx)(`p`,{role:`alert`,children:b||r}):null,(0,U.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),!D&&(!O&&w&&(f||e?.hubOrigin)?k():(x(``),e?.hubOrigin||h(!0),i(e?.hubOrigin?void 0:E)))},children:[!O&&(w?(0,U.jsxs)(`div`,{className:`hub-connection-origin-field`,children:[(0,U.jsx)(`label`,{htmlFor:l,children:G.hubUrl}),(0,U.jsxs)(`div`,{className:`hub-connection-origin-input`,children:[(0,U.jsx)(H.TextInput,{ref:S,id:l,type:`url`,value:E,onChange:e=>{h(!1),d(e.target.value)},required:!0,fullWidth:!0,disabled:D,placeholder:`https://hub.example.com`}),o?(0,U.jsx)(W,{icon:L,variant:`invisible`,size:`small`,"aria-label":G.resetHubUrl,disabled:D,"aria-busy":v,onClick:()=>void A()}):null]}),f||e?.hubOrigin?(0,U.jsx)(H.Button,{type:`submit`,variant:`subtle`,size:`small`,disabled:D,children:G.saveHub}):null]}):(0,U.jsxs)(`div`,{className:`hub-connection-origin`,children:[(0,U.jsx)(`a`,{href:e?.hubOrigin&&new URL(e.hubOrigin).origin,target:`_blank`,rel:`noopener noreferrer`,children:e?.hubOrigin}),(0,U.jsx)(W,{ref:C,icon:ae,variant:`invisible`,size:`small`,"aria-label":G.editHubUrl,disabled:D,onClick:()=>{x(``),p(!0),d(e?.hubOrigin??``)}})]})),t?(0,U.jsx)(fe,{pairing:t},t.verificationUrl):null,t?null:(0,U.jsx)(H.Button,{type:`submit`,variant:`primary`,disabled:D||!e?.repository||!O&&w&&(f||!!e?.hubOrigin),children:n?G.connectionOpeningBrowser:G.connectToHub})]})]})}function me({title:e,description:t,children:n,action:r,variant:i,layout:a,onDismiss:o,dismissLabel:c,className:l,...u}){let d=i===`critical`?A:i===`success`?s:i===`info`?y:x;return(0,U.jsxs)(`div`,{...u,role:i===`critical`||i===`warning`?`alert`:`status`,className:`hub-alert hub-alert--${i}${a===`compact`?` hub-alert--compact`:``}${l?` ${l}`:``}`,children:[(0,U.jsx)(d,{className:`hub-alert__icon`,size:20,"aria-hidden":`true`}),(0,U.jsxs)(`div`,{className:`hub-alert__content`,children:[(0,U.jsxs)(H.Text,{as:`p`,size:`100`,className:`hub-alert__message`,children:[(0,U.jsx)(`strong`,{className:`hub-alert__title`,children:e}),t?(0,U.jsx)(`span`,{className:`hub-alert__description`,children:t}):null]}),n]}),r||o?(0,U.jsxs)(`div`,{className:`hub-alert__action`,children:[r,o&&c?(0,U.jsx)(W,{icon:B,"aria-label":c,title:c,variant:`invisible`,size:`small`,onClick:o}):null]}):null]})}var K={title:`Publish uncommitted changes?`,description:`Do you want to commit changes before publishing? Publishing the committed version only excludes your local uncommitted edits.`,checkFailedTitle:`Could not check local changes`,checkFailed:`Git could not check local changes.`,retryCheck:`Retry check`,commit:`Commit changes & publish`,committed:`Publish committed version only`,close:`Close publishing dialog`,changedFiles:`Uncommitted changes`,moreChanges:e=>`${e} more`,localSkills:e=>`${e} local agent skill ${e===1?`file stays`:`files stay`} uncommitted.`,selection:`Copilot commits only changes related to this prototype task and asks if it cannot tell which changes belong.`,remember:`Always commit changes before publishing for this prototype`,settings:`Settings`,alwaysCommit:`Always commit changes before publishing`,retrySettings:`Retry settings`,preferenceTargetChanged:`The checkout changed. Refresh Settings and try again.`,invalidPreference:`Publishing settings returned an invalid response. Retry settings.`};function he({busy:e,error:t,changes:n,checkError:r,remembered:i,returnFocusRef:a,onClose:o,onChoose:s,onRetry:c}){let[l,u]=(0,V.useState)(i),d=(0,V.useId)(),f=(0,V.useId)();return(0,U.jsx)(ue,{title:r?K.checkFailedTitle:K.title,closeLabel:K.close,descriptionId:r?void 0:d,returnFocusRef:a,onClose:()=>{e||o()},className:`publish-changes-dialog`,children:(0,U.jsxs)(H.Stack,{gap:`normal`,padding:`none`,children:[r?null:(0,U.jsx)(`p`,{id:d,children:K.description}),r?(0,U.jsx)(me,{title:r,variant:`critical`,layout:`compact`}):null,n?.files.total?(0,U.jsx)(`section`,{"aria-label":K.changedFiles,children:(0,U.jsxs)(`ul`,{className:`publish-changes-dialog__files`,children:[n.files.paths.map(e=>(0,U.jsx)(`li`,{children:(0,U.jsx)(`code`,{children:e})},e)),n.files.total>n.files.paths.length?(0,U.jsx)(`li`,{children:K.moreChanges(n.files.total-n.files.paths.length)}):null]})}):null,r?null:(0,U.jsxs)(`p`,{children:[n?.localSkills.total?`${K.localSkills(n.localSkills.total)} `:null,K.selection]}),r?null:(0,U.jsxs)(H.FormControl,{id:f,fullWidth:!0,children:[(0,U.jsx)(H.Checkbox,{checked:l,disabled:e,onChange:e=>u(e.target.checked)}),(0,U.jsx)(H.FormControl.Label,{children:K.remember})]}),t?(0,U.jsx)(me,{title:t,variant:`critical`,layout:`compact`}):null,(0,U.jsxs)(`footer`,{className:`publish-changes-dialog__actions`,children:[r?(0,U.jsx)(H.Button,{variant:`primary`,size:`small`,disabled:e,"aria-busy":e,onClick:c,children:K.retryCheck}):null,r?null:(0,U.jsx)(H.Button,{variant:`primary`,size:`small`,disabled:e,"aria-busy":e,onClick:()=>s(`commit-changes`,l),children:K.commit}),(0,U.jsx)(H.Button,{size:`small`,disabled:e,onClick:()=>s(`committed-only`,!1),children:K.committed})]})]})})}function ge({value:e,label:t,copyLabel:r,copiedLabel:i,copyErrorLabel:a,compact:o=!1}){let[s,c]=(0,V.useState)(null),l=s?.value===e?s.status:null,u=l===`copied`?i:r;async function d(){try{await navigator.clipboard.writeText(e),c({value:e,status:`copied`})}catch{c({value:e,status:`failed`})}}return(0,U.jsxs)(`div`,{className:`copyable-text-input${o?` copyable-text-input--compact`:``}`,children:[(0,U.jsxs)(`div`,{className:`copyable-text-input__control`,children:[o?(0,U.jsx)(`input`,{type:`text`,value:e,"aria-label":t,readOnly:!0,className:`copyable-text-input__input`}):(0,U.jsx)(H.TextInput,{value:e,"aria-label":t,readOnly:!0,fullWidth:!0,className:`copyable-text-input__input`}),(0,U.jsx)(W,{icon:n,"aria-label":u,description:o?u:void 0,title:o?void 0:u,variant:`invisible`,size:`small`,className:`copyable-text-input__button`,onClick:()=>void d()})]}),(0,U.jsx)(le,{"aria-live":`polite`,"aria-atomic":`true`,children:l===`copied`?i:``}),l===`failed`?(0,U.jsx)(`span`,{role:`alert`,className:`copyable-text-input__error`,children:a}):null]})}function _e({children:e}){return(0,U.jsx)(`div`,{className:`prototype-workspace__body`,children:e})}function ve({title:e,description:t,trailing:n,headingAs:r=`h2`,headingRef:i}){return(0,U.jsxs)(`header`,{className:`hub-content-page-header`,children:[(0,U.jsxs)(`div`,{className:`hub-content-page-header__top`,children:[(0,U.jsx)(H.Heading,{as:r,size:`4`,ref:i,tabIndex:i?-1:void 0,children:e}),n]}),t?(0,U.jsx)(H.Text,{as:`p`,className:`hub-content-page-header__description`,children:t}):null]})}function ye({labels:e,headingRef:t,headingTrailing:n,feedback:r,form:i,formUnavailable:a,links:o,hasLinks:s,showEmpty:c=!0,listRef:l,listBusy:u,beforeLinks:d,afterLinks:f}){return(0,U.jsxs)(H.Stack,{gap:`normal`,children:[(0,U.jsx)(ve,{title:e.heading,description:e.description,headingRef:t,trailing:n}),r,i||(a===void 0?(0,U.jsxs)(`section`,{className:`share-links__empty`,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`5`,children:e.noBuildHeading}),(0,U.jsx)(H.Text,{as:`p`,className:`share-links__empty-description`,children:e.noBuildLabel})]}):a),d,s?(0,U.jsx)(`ul`,{className:`share-links__list`,ref:l,"aria-busy":u,children:o}):c?(0,U.jsxs)(`section`,{className:`share-links__empty`,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`5`,children:e.emptyHeading}),(0,U.jsx)(H.Text,{as:`p`,className:`share-links__empty-description`,children:e.emptyLabel})]}):null,f]})}function be({shareLink:e,className:t,copiedLabel:n,copyErrorLabel:r,copyLabel:i,urlLabel:a,unavailableLabel:o,highlighted:s,children:c}){return(0,U.jsx)(`li`,{"data-share-id":e.id,className:`share-link-item${s?` share-link-item--created`:``}${t?` ${t}`:``}`,children:(0,U.jsxs)(`div`,{className:`share-link-item__layout`,children:[(0,U.jsxs)(`div`,{className:`share-link-item__details`,children:[(0,U.jsx)(`h3`,{children:e.label}),(0,U.jsxs)(`span`,{className:`share-link-item__metadata`,children:[e.buildLabel,e.createdLabel?(0,U.jsxs)(U.Fragment,{children:[` · `,(0,U.jsx)(`time`,{dateTime:e.createdAt,children:e.createdLabel})]}):null,` · `,e.expiresAt?(0,U.jsx)(`time`,{dateTime:e.expiresAt,children:e.expiresLabel}):e.expiresLabel]})]}),(0,U.jsxs)(`div`,{className:`share-link-item__actions`,children:[o?(0,U.jsx)(`p`,{children:o}):(0,U.jsx)(ge,{value:e.url,label:a||e.label,copyLabel:i,copiedLabel:n,copyErrorLabel:r}),c]})]})})}function xe({data:e,action:t,hiddenFields:n,details:r,afterFields:a,onSubmit:o,label:s,onLabelChange:c,expiration:l,onExpirationChange:u,disabled:d,fieldsDisabled:f,busy:p,error:m}){let h=(0,V.useId)(),g=(0,V.useId)();return(0,U.jsxs)(`div`,{className:`share-links-form`,children:[e.buildLabel?(0,U.jsx)(H.Heading,{as:`h2`,size:`5`,children:e.buildLabel}):null,r,(0,U.jsxs)(`form`,{action:t,method:`post`,onSubmit:o,"aria-busy":p,className:`share-links__form`,children:[n,(0,U.jsxs)(`div`,{className:`share-links__form-row`,children:[(0,U.jsxs)(H.FormControl,{id:h,required:!0,fullWidth:!0,className:`share-links__field`,children:[(0,U.jsx)(H.FormControl.Label,{children:e.labelLabel}),(0,U.jsx)(H.TextInput,{"aria-label":e.labelLabel,"aria-invalid":!!m,name:`share_link[label]`,placeholder:e.labelPlaceholder,maxLength:e.labelMaximumBytes,value:s,onChange:c,disabled:f,fullWidth:!0}),m?(0,U.jsx)(H.FormControl.Validation,{validationStatus:`error`,className:`share-links__validation`,children:m}):null]}),m?(0,U.jsx)(le,{role:`alert`,children:m}):null,(0,U.jsxs)(H.FormControl,{id:g,fullWidth:!0,className:`share-links__field`,children:[(0,U.jsx)(H.FormControl.Label,{children:e.expirationLabel}),(0,U.jsx)(H.Select,{"aria-label":e.expirationLabel,name:`share_link[expiration]`,defaultValue:l===void 0?e.expirationOptions.find(e=>e.value===`seven_days`)?.value??e.expirationOptions[0]?.value:void 0,value:l,onChange:u,disabled:f,fullWidth:!0,children:e.expirationOptions.map(e=>(0,U.jsx)(H.Select.Option,{value:e.value,children:e.label},e.value))})]}),(0,U.jsx)(`div`,{className:`share-links__form-actions`,children:(0,U.jsx)(H.Button,{type:`submit`,variant:`primary`,leadingVisual:i,disabled:d,children:e.submitLabel})})]}),a?(0,U.jsx)(`div`,{className:`share-links__form-options`,children:a}):null]})]})}var q={title:`Share prototype`,internal:`Internal prototype link`,internalDescription:`Requires GitHub sign-in and repository access.`,internalUnavailable:`Internal prototype link unavailable.`,internalCopy:`Copy internal prototype link`,internalOpen:`Open internal prototype link`,public:`Public share links`,permissionUnknown:`Hub has not confirmed permission to manage public share links.`,group:`Publish and share`,back:`Back to preview`,warning:`Anyone with a link can view its Build without signing in. The prototype may expose sensitive or customer information. Check its content before sharing. Local and uncommitted changes are not included.`,target:`New links share this published Build:`,oldBuild:`This is the last published Build, not the current local preview.`,includeControlSettings:`Include current control settings`,controlSettingsDescription:`Adds settings for all configured pages to the links you copy or open. Saved share links stay unchanged.`,controlSettingsWarning:`Settings for controls that have not been published will not take effect for shared links.`,controlSettingsWarningTitle:`Local changes are not in the shared Build`,label:`Label`,labelPlaceholder:`Usability review`,labelInvalid:`Enter a label containing no more than 100 UTF-8 bytes.`,expiry:`Expires after`,expirations:[{value:`one_day`,label:`1 day`},{value:`seven_days`,label:`7 days`},{value:`thirty_days`,label:`30 days`},{value:`never`,label:`Never`}],create:`Create share link`,creating:`Working...`,active:`Active share links`,empty:`Create a link when someone needs signed-out access.`,emptyHeading:`No active share links`,loading:`Loading share links...`,refresh:`Refresh links`,authorize:`Verify with GitHub`,authorizationRetry:`Complete authorization in your browser, then refresh links and submit the action again. No action is replayed automatically.`,paginationFailed:`Hub returned a repeated share-link page. Refresh links to try again.`,noBuild:`A successful published Build is required before creating a share link.`,noBuildHeading:`No successful Build`,build:e=>`Build ${e}`,buildDetails:(e,t,n)=>`Commit: ${e}\nAuthor: @${t}\nPublished: ${n}`,denied:`Managing public share links requires repository admin access or authorship of any successful Build for this Prototype, with current read access. Write access alone is not sufficient.`,disabled:`Public sharing is disabled for this Hub. A Hub administrator must explicitly enable it. Previously revoked links never return.`,disconnected:`Connect to Hub before managing share links.`,connect:`Connect to Hub`,unavailable:`Hub is unavailable. Restore the connection and reopen Share prototype.`,branch:`Open a named prototype branch discovered by Hub before sharing.`,stale:`Hub or checkout changed. Return to preview and reopen Share prototype.`,deleted:`Share link deleted. Its public URL no longer works.`,never:`Never expires`,expires:e=>`Expires ${e}`,createdBy:(e,t)=>`Created by @${e} ${t}`,copy:(e,t)=>`Copy ${e}, Build #${t}`,copied:`Link copied`,copyError:`Could not copy the link. Select the URL and copy it manually.`,open:(e,t)=>`Open ${e}, Build #${t}`,delete:(e,t)=>`Delete ${e}, Build #${t}`,deletePrompt:e=>`Delete "${e}"? Anyone with this link will lose access to its Build.`,deletedError:`Could not delete the link.`,failed:`The sharing request failed.`,unknown:`The sharing request may have completed. Refresh active links before trying again. A matching label does not prove which request created a link.`,expired:`This link has expired. Refresh links.`};function Se({included:e,onChange:t,publishedVersionDiffers:n,disabled:r=!1,error:i,copy:a}){let o=(0,V.useId)(),s=e&&n;return(0,U.jsxs)(`div`,{className:`share-control-settings`,children:[(0,U.jsxs)(H.FormControl,{id:o,fullWidth:!0,children:[(0,U.jsx)(H.Checkbox,{checked:e,onChange:e=>t(e.target.checked),disabled:r}),(0,U.jsx)(H.FormControl.Label,{children:a?.label??q.includeControlSettings}),(0,U.jsx)(H.FormControl.Hint,{className:`share-control-settings__hint`,children:(0,U.jsx)(`span`,{className:`share-control-settings__description`,children:a?.description??q.controlSettingsDescription})})]}),i?(0,U.jsx)(me,{title:i,variant:`critical`,layout:`compact`}):null,s?(0,U.jsx)(me,{title:q.controlSettingsWarningTitle,description:q.controlSettingsWarning,variant:`warning`,layout:`compact`,className:`share-control-settings__warning`}):null]})}function Ce(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var we=`replica:controls:url`,Te=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function Ee(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!Ce(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!Te.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function De(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=Te.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!Ce({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{Ee(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function Oe(e,t){let n=new URL(e,window.location.href),r=De(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(Ee(r.scopes)))n.searchParams.set(e,t);return n.toString()}function ke({state:e,buildDetails:t,currentCommit:n,hasLocalChanges:r=!1,shareButtonRef:i,onClose:a,onConnect:o,onRefresh:s,onCreate:c,onDelete:l,onOpen:u,controlSettings:d,onAuthorize:f}){let[p,m]=(0,V.useState)(``),[h,g]=(0,V.useState)(`seven_days`),[_,y]=(0,V.useState)(``),[b,x]=(0,V.useState)(Date.now),S=(0,V.useRef)(null),C=(0,V.useRef)(null),w=(0,V.useRef)(null),T=e.context?.prototype,E=q.expirations.filter(e=>!T?.shareLinkExpirationOptions||T.shareLinkExpirationOptions.includes(e.value)),D=E.some(e=>e.value===h)?h:E.find(e=>e.value===`seven_days`)?.value??E[0]?.value??``,k=T?.published?T.build:null,A=k?.url,j=A&&URL.canParse(A)?new URL(A):null,M=j&&j.origin===e.context?.hubOrigin&&[`http:`,`https:`].includes(j.protocol)&&!j.username&&!j.password?A:null,ee=!!(k&&n&&n!==k.commitSha)||r,N=T?.canManageShareLinks===!0,P=!e.sharingDisabled&&T?.publicSharingEnabled!==!1,F=e.busy||e.loading||e.stale||!N||!P,I=d?.included?d.query??``:``,L=!!d?.blocked;function R(e){return Oe(e,I)}let z=P&&e.stale&&!e.loading&&e.created&&!e.links.some(t=>t.id===e.created?.id)?e.created:null;(0,V.useEffect)(()=>{let e=i.current;C.current?.focus();let t=window.setInterval(()=>x(Date.now()),1e4);return()=>{window.clearInterval(t),e?.focus()}},[i]),(0,V.useEffect)(()=>{if(e.busy||!w.current)return;let t=w.current;w.current=null,(t.map(e=>S.current?.querySelector(`[data-share-id="${e}"] button`)).find(e=>e&&!e.disabled)||C.current)?.focus()},[e.busy,e.links]);async function te(t,n){if(!window.confirm(q.deletePrompt(n)))return;let r=e.links.findIndex(e=>e.id===t),i=[...e.links.slice(r+1),...e.links.slice(0,r).reverse()].map(e=>e.id);await l(t)&&(w.current=i,(i.map(e=>S.current?.querySelector(`[data-share-id="${e}"] button`)).find(e=>e&&!e.disabled)||C.current)?.focus())}function ne(e){return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}return(0,U.jsx)(`main`,{className:`canvas-share-page`,"aria-label":q.title,children:(0,U.jsx)(_e,{children:(0,U.jsx)(ye,{labels:{heading:q.title,noBuildHeading:q.noBuildHeading,noBuildLabel:q.noBuild,emptyHeading:q.emptyHeading,emptyLabel:q.empty},headingRef:C,headingTrailing:(0,U.jsx)(`div`,{className:`canvas-share-close`,children:(0,U.jsx)(W,{icon:B,variant:`invisible`,"aria-label":q.back,description:q.back,onClick:a})}),feedback:(0,U.jsxs)(U.Fragment,{children:[d?(0,U.jsx)(Se,{included:d.included,onChange:d.onChange,publishedVersionDiffers:ee,disabled:e.busy||d.pending,error:d.error}):null,(0,U.jsxs)(`section`,{className:`canvas-share-internal`,"aria-label":q.internal,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`6`,children:q.internal}),(0,U.jsx)(`p`,{children:q.internalDescription}),M&&!L?(0,U.jsxs)(`div`,{className:`share-link-item__actions canvas-share-internal-actions`,children:[(0,U.jsx)(ge,{value:R(M),label:q.internal,copyLabel:q.internalCopy,copiedLabel:q.copied,copyErrorLabel:q.copyError}),(0,U.jsx)(W,{as:`a`,href:R(M),target:`_blank`,rel:`noopener`,icon:v,"aria-label":q.internalOpen,description:q.internalOpen})]}):M?null:(0,U.jsx)(`p`,{role:`status`,children:q.internalUnavailable})]}),(0,U.jsxs)(`div`,{className:`canvas-share-public-header`,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`6`,children:q.public}),(0,U.jsx)(`p`,{children:q.warning})]}),T&&!N?(0,U.jsx)(`p`,{role:`status`,children:T.canManageShareLinks===!1?q.denied:q.permissionUnknown}):null,P?null:(0,U.jsx)(`p`,{role:`status`,children:q.disabled}),e.error?(0,U.jsx)(me,{title:e.error,variant:`critical`,layout:`compact`}):null,e.authorization&&f?(0,U.jsx)(H.Button,{variant:`secondary`,size:`small`,onClick:f,disabled:e.busy,children:q.authorize}):null,o&&!e.context?(0,U.jsx)(H.Button,{variant:`secondary`,size:`small`,onClick:o,children:q.connect}):null]}),form:k&&N&&P?(0,U.jsx)(xe,{data:{buildLabel:null,labelLabel:q.label,labelPlaceholder:q.labelPlaceholder,labelMaximumBytes:100,expirationLabel:q.expiry,expirationOptions:E,submitLabel:e.busy?q.creating:q.create},label:p,onLabelChange:e=>{m(e.target.value),y(``)},expiration:D,onExpirationChange:e=>g(e.target.value),onSubmit:e=>{e.preventDefault(),!p.trim()||new TextEncoder().encode(p.trim()).length>100?y(q.labelInvalid):(y(``),c(p,D))},disabled:F,fieldsDisabled:e.busy,busy:e.busy,error:_,details:(0,U.jsxs)(`div`,{className:`canvas-share-build-details`,children:[(0,U.jsxs)(`p`,{children:[q.target,` `,(0,U.jsx)(`strong`,{children:q.build(k.number)}),` - `,(0,U.jsx)(`code`,{children:k.commitSha.slice(0,7)}),` - `,(0,U.jsx)(`time`,{dateTime:k.publishedAt,children:ne(k.publishedAt)})]}),ee?(0,U.jsx)(`p`,{children:q.oldBuild}):null]})}):null,formUnavailable:N&&P&&!k?void 0:null,beforeLinks:(0,U.jsxs)(U.Fragment,{children:[e.notice?(0,U.jsx)(`p`,{role:`status`,children:e.notice}):null,z&&!L?(0,U.jsx)(ge,{value:R(z.url),label:z.label,copyLabel:q.copy(z.label,z.buildNumber),copiedLabel:q.copied,copyErrorLabel:q.copyError}):null,e.loading?(0,U.jsx)(`p`,{role:`status`,children:q.loading}):null]}),hasLinks:N&&P&&!L&&e.links.length>0,showEmpty:N&&P&&!L&&!e.loading&&!e.stale,listRef:S,listBusy:e.loading,links:(!N||!P||L?[]:e.links).map(e=>{let n=e.expiresAt!==null&&Date.parse(e.expiresAt)<=b,r=t?.[e.buildNumber];return(0,U.jsxs)(be,{className:k&&e.buildNumberI?u(e.id,I):u(e.id)}),(0,U.jsx)(W,{icon:O,variant:`danger`,"aria-label":q.delete(e.label,e.buildNumber),description:q.delete(e.label,e.buildNumber),disabled:F||n,onClick:()=>void te(e.id,e.label)})]},e.id)}),afterLinks:(0,U.jsx)(`div`,{className:`canvas-share-list-actions`,children:N||!e.context&&!o?(0,U.jsx)(H.Button,{size:`small`,variant:`subtle`,onClick:s,disabled:e.busy||e.loading,children:q.refresh}):null})})})})}var J={checking:`Checking sharing readiness`,checkingDetail:`Checking Hub for a successful published Build and repository access.`,connect:`Connect before sharing`,connectDetail:`Connect to Hub before sharing this prototype.`,connectAction:`Connect to Hub`,publish:`Publish before sharing`,publishDetail:`To create a share link, publish this prototype to Hub first. Your local preview stays private.`,publishPermissionUnverified:`This Hub has not confirmed publishing permission. Copilot will check access when publishing and report any permission errors.`,preparing:`Preparing your prototype`,ready:`Ready to share`,readyDetail:`Your prototype is ready to share.`,manage:`Share prototype`,unavailable:`Sharing status unavailable`,unavailableDetail:`Hub could not verify sharing readiness. Retry before continuing.`,permissionUnknown:`This Hub cannot verify sharing or publishing permission. Update Hub and retry.`,restricted:`Sharing unavailable`,publishDenied:`Publishing requires repository write access. Ask a prototype author to publish a Build.`,local:`Local development prototypes cannot create public share links.`,changed:`Sharing target changed`,changedDetail:`The repository, branch, or Hub changed. Close this dialog and reopen Share for the intended prototype.`,boundary:`Internal review requires repository access. Public share links let anyone view a published Build, not your local preview.`,close:`Close sharing readiness`},Ae=`Branch not eligible for Hub registration`,Y={heading:`Branch publication`,checking:`Checking...`,retry:`Retry status`,retryPublish:`Retry publish`,requested:`Requested`,awaitingCopilot:`Waiting for Copilot`,publishBranch:`Publish`,publishChanges:`Publish changes`,registration:`Publishing`,registrationFailed:`Publication delayed`,published:`Published`,alreadyPublished:`Latest changes already published`,queued:`Build queued`,building:`Building`,awaitingHub:`Awaiting Hub`,awaitingBuild:`Awaiting build`,connect:`Connect to the hub`,workflowLink:`View workflow run`,initial:`Checking branch publication.`,checkingRemote:`Checking the exact branch on the origin repository.`,detached:`Open a named branch before publishing.`,changed:`The checkout changed. Refresh publication status.`,unknown:e=>`Remote branch status is unknown. ${e||`Check GitHub access and retry.`}`,pending:`Copilot received the publish request in chat and has not pushed this branch yet. Follow its progress in chat.`,checkingHub:`Checking the Hub connection.`,disconnected:`Connect to the hub before publishing this prototype.`,hubUnavailable:`Hub verification is unavailable. Restore access and retry.`,hubUnavailableTitle:`Hub verification unavailable`,staleHub:`The Hub status belongs to a different checkout. Refresh to continue.`,workflowMissing:`This checkout has no .github/workflows/replica.yml. Set up the repository's Replica build workflow before publishing.`,dispatchFailed:`Copilot could not receive the publish request.`,absent:`This branch won't appear in the hub until you publish.`,needsPush:`The remote branch points to a different commit. Publish pushes this branch without force.`,localChanges:`Local changes are not in the published prototype. Choose how to publish them.`,needsRegistration:`Hub imported this commit. The canvas is publishing it automatically.`,registrationDenied:`Hub could not register this branch. Check repository access and branch eligibility.`,registrationErrorTitle:`Hub registration failed`,registrationReasons:new Map([[`write_access_required`,{title:Ae,description:`You lack write access to this repository.`}],[`branch_not_reviewable`,{title:Ae,description:`Default, reserved, and internal branches cannot be registered in Hub.`}],[`remote_branch_missing`,{title:Ae,description:`The branch no longer exists on the remote repository.`}],[`branch_authorship_required`,{title:Ae,description:`You have not authored a commit unique to this branch.`}],[`repository_mismatch`,{title:Ae,description:`The branch belongs to a different repository.`}],[`already_registered`,{title:`Branch already registered in Hub`,description:`This branch is already registered in Hub. Refresh its status.`}],[`successful_build_required`,{title:`Hub registration delayed`,description:`Hub has not imported this checkout's successful Build yet.`}]]),ready:`Hub imported this commit and the prototype is registered.`,importFailed:`Hub could not import or build this commit. Pushing this unchanged commit does not rerun the failed work. Inspect the Build failure in Hub and repair the cause before publishing again.`,workflowUnavailable:`Workflow status is unavailable. Check GitHub access and retry.`,staleWorkflow:`Workflow status belongs to a different branch or commit.`,workflowQueued:`The Replica workflow for this commit is queued or waiting.`,workflowBuilding:`The Replica workflow is building this commit.`,workflowFailed:e=>`The Replica workflow finished with ${e||`an unsuccessful result`}. Pushing this unchanged commit does not rerun the failed work. Inspect the run and repair the cause before publishing again.`,importing:`The workflow succeeded. Waiting for Hub discovery and artifact import; this is not published yet.`,noBuild:`The exact branch and commit are on GitHub, but no matching Replica workflow run has appeared yet.`};function je({publication:e,busy:t,onPublish:n,onRetry:r}){if(e.kind===`ready`)return null;let i=e.kind===`requested`,a=t||i;return(0,U.jsxs)(`section`,{className:`canvas-branch-publication`,"aria-label":Y.heading,children:[e.error?(0,U.jsx)(me,{variant:`critical`,layout:`compact`,title:e.error.title,description:e.error.description}):(0,U.jsx)(`p`,{role:`status`,children:e.detail}),e.runUrl?(0,U.jsx)(`p`,{children:(0,U.jsx)(H.InlineLink,{className:`canvas-branch-publication__workflow-link`,href:e.runUrl,target:`_blank`,rel:`noopener noreferrer`,children:Y.workflowLink})}):null,(e.action!==`none`||i)&&e.kind!==`disconnected`?(0,U.jsx)(`div`,{className:`canvas-branch-publication__actions`,children:(0,U.jsx)(H.Button,{variant:`primary`,size:`small`,disabled:a,"aria-busy":a,leadingVisual:a?(0,U.jsx)(L,{size:16}):void 0,onClick:e.action===`retry`?r:n,children:e.label})}):null]})}function X({readiness:e,busy:t,shareButtonRef:n,onClose:r,onConnect:i,onPublish:a,onRetry:o,onManage:s}){let c=(0,V.useId)();return(0,U.jsxs)(ue,{title:e.title,closeLabel:J.close,onClose:r,returnFocusRef:n,descriptionId:c,children:[(0,U.jsx)(`p`,{id:c,role:`status`,children:e.detail}),[`connect`,`publish`,`ready`].includes(e.kind)?(0,U.jsx)(`p`,{children:J.boundary}):null,e.publication?(0,U.jsx)(je,{publication:e.publication,dirty:!1,busy:t,onPublish:a,onRetry:o}):null,[`connect`,`ready`,`retry`].includes(e.kind)?(0,U.jsx)(H.Button,{variant:`primary`,size:`small`,disabled:t,"aria-busy":t,onClick:e.kind===`connect`?i:e.kind===`ready`?s:o,children:e.kind===`connect`?J.connectAction:e.kind===`ready`?J.manage:Y.retry}):null]})}function Me({hub:e,connection:t,publication:n,sharing:r,shareIntent:i,controlSettings:a,readiness:o,state:s,hubOpen:c,buildDetailsOpen:l,onCloseBuildDetails:u,shareButtonRef:d,hubButtonRef:f,connectionButtonRef:p,publishButtonRef:m,titleButtonRef:h}){let{intent:g,targetChanged:_}=i,v=n.presentedState;return(0,U.jsxs)(U.Fragment,{children:[t.open&&(!g||g.connecting&&!_)?(0,U.jsx)(pe,{status:e.status,pairing:t.pairing,connecting:t.connecting,error:t.error,onConnect:t.connect,onSelectHub:e.select,onResetHub:e.reset,onClose:()=>{t.close(),i.setConnecting(!1)},hubButtonRef:g?d:c?p:f}):null,g&&!n.publishDialog&&(_||!g.connecting||!t.open)?(0,U.jsx)(X,{readiness:_?{kind:`restricted`,title:J.changed,detail:J.changedDetail}:o,busy:n.busy,shareButtonRef:d,onClose:()=>{i.close(),t.close()},onConnect:()=>{_||o.kind!==`connect`||(i.setConnecting(!0),t.showAndConnect())},onPublish:()=>{!_&&o.kind===`publish`&&n.publish()},onRetry:()=>void n.retry(),onManage:()=>{_||o.kind!==`ready`||(i.close(),r.open())}}):null,n.publishDialog?(0,U.jsx)(he,{busy:n.busy,error:n.publishDialogError,changes:n.publishDialog.preparation.changes,checkError:n.publishDialog.preparation.workingTree===`unavailable`?n.publishDialog.preparation.workingTreeError||K.checkFailed:void 0,remembered:n.publishDialog.preparation.remember,returnFocusRef:g?d:m,onClose:n.closePublishDialog,onChoose:(e,t)=>void n.choosePublish(e,t),onRetry:()=>void n.retryPublishCheck()},n.publishDialog.preparation.workingTree===`unavailable`?`unchecked`:`checked`):null,r.state.open?(0,U.jsx)(ke,{state:r.state,currentCommit:s?.stats.commitSha,hasLocalChanges:s?.stats.workingTree===`changed`,shareButtonRef:d,onClose:r.close,onConnect:!e.status||[`disconnected`,`pairing`,`unconfigured`].includes(e.status.state)?()=>{r.close(),t.show()}:void 0,onRefresh:()=>void r.refresh(),onCreate:r.create,onDelete:r.remove,onOpen:(e,t)=>void r.openLink(e,t),controlSettings:a,onAuthorize:()=>void r.authorize()}):null,l&&v?(0,U.jsx)(de,{state:v,titleButtonRef:h,onClose:u}):null]})}function Ne({address:e,addressRef:t,canGoBack:n,canGoForward:i,appearance:a,onAppearanceChange:o,onBack:s,onForward:c,onNavigate:l,onOpenTab:u,onReload:d}){let[f,p]=(0,V.useState)(null),m=f?.address===e?f.value:e,h=f?.address===e?f.error:``;function g(t){t.preventDefault();try{let t=new URL(m.trim(),e);if(![`http:`,`https:`].includes(t.protocol)||t.origin!==new URL(e).origin||t.username||t.password){p({address:e,value:m,error:G.browserAddressOrigin});return}p(null),l(t.href)}catch{p({address:e,value:m,error:G.browserAddressInvalid})}}return(0,U.jsx)(H.ThemeProvider,{colorMode:`auto`,className:`canvas-browser-theme`,children:(0,U.jsxs)(`nav`,{className:`canvas-browser-bar`,"aria-label":G.browserNavigation,children:[(0,U.jsxs)(`div`,{className:`canvas-browser-bar__navigation`,children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":G.browserBack,disabled:!n,onClick:s,children:(0,U.jsx)(r,{size:16})}),(0,U.jsx)(`button`,{type:`button`,"aria-label":G.browserForward,disabled:!i,onClick:c,children:(0,U.jsx)(oe,{size:16})}),(0,U.jsx)(`button`,{type:`button`,"aria-label":G.browserReload,onClick:d,children:(0,U.jsx)(L,{size:16})})]}),(0,U.jsxs)(`form`,{className:`canvas-browser-bar__address`,onSubmit:g,children:[(0,U.jsx)(`input`,{ref:t,"aria-label":G.browserAddress,"aria-invalid":!!h,"aria-describedby":h?`canvas-browser-address-error`:void 0,spellCheck:!1,value:m,onChange:t=>{p({address:e,value:t.target.value,error:``})},onFocus:e=>e.currentTarget.select(),onKeyDown:e=>{e.key===`Escape`&&(p(null),e.currentTarget.blur())}}),h?(0,U.jsx)(`span`,{id:`canvas-browser-address-error`,className:`canvas-browser-bar__error`,role:`alert`,children:h}):null]}),(0,U.jsxs)(`div`,{className:`canvas-browser-bar__tools`,children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":G.browserOpenTab,title:G.browserOpenTab,onClick:()=>{u().catch(t=>{p({address:e,value:m,error:t instanceof Error?t.message:String(t)})})},children:(0,U.jsx)(v,{size:16})}),(0,U.jsxs)(`div`,{className:`canvas-browser-bar__appearance`,role:`group`,"aria-label":G.browserAppearance,children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":G.browserLight,"aria-pressed":a===`light`,onClick:()=>o(`light`),children:(0,U.jsx)(P,{size:16})}),(0,U.jsx)(`button`,{type:`button`,"aria-label":G.browserDark,"aria-pressed":a===`dark`,onClick:()=>o(`dark`),children:(0,U.jsx)(ie,{size:16})})]})]})]})})}var Pe=e(t((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t}));e.validateShape=N;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern "^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern "^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return I.errors=a,o===0}e.number=L;function L(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return L.errors=a,l===0}e.slider=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return R.errors=a,l===0}e.choice=z;function z(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return z.errors=a,o===0}e.checkboxGroup=te;function te(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return te.errors=a,o===0}e.text=B;function B(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return B.errors=a,l===0}e.color=ne;function ne(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ne.errors=a,o===0}e.button=re;function re(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return re.errors=a,o===0}}))(),1),{validateDocumentShape:Fe,validateDeclaration:Ie}=Pe.default,Le={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function Re(e){let t=[...Ie.errors].filter(e=>!/^\/controls\/\d+(?:\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(Le,e?.type)?Le[e.type]:void 0,i=r&&Pe.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params}))}var ze=class extends Error{constructor(e){super(`Invalid controls.replica.json:\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(` -`)}`),this.name=`ControlsValidationError`,this.issues=e}};function Be(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function Ve(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(Ve):[]}function He(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=new Set,i=new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new ze([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...Ve(s.when),...Ve(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function Ue(e){let t=new Set;function n(e,r=0){if(r>24)throw new ze([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new ze([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new ze([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new ze([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new ze([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function We(e){if(Ue(e),!Ie(e))throw new ze(Re(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=Be(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=Be(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new ze(t);return He(e),e}function Ge(e,t){let[n,r]=(0,V.useState)(e),[i,a]=(0,V.useState)(null),o=(0,V.useRef)(e),s=(0,V.useRef)(e),c=(0,V.useRef)(0),l=(0,V.useRef)(!1);(0,V.useLayoutEffect)(()=>{s.current=e,l.current||(o.current=e,r(e))},[e]),(0,V.useLayoutEffect)(()=>()=>{c.current++},[]);function u(e){c.current++,l.current=!0,o.current=e,r(e),a(null)}function d(){c.current++,l.current=!1,o.current=s.current,r(s.current),a(null)}function f(e,n=e){u(e);let i=c.current;Promise.resolve().then(()=>t(n)).then(e=>{c.current===i&&(l.current=!1,o.current=e&&`value`in e?e.value:s.current,r(o.current))}).catch(()=>{c.current===i&&(d(),a(G.controlsValueNotApplied))})}return{draft:n,error:i,current:()=>o.current,stage:u,commit:f,reset:d}}function Ke(e){let t=e.step??1,n=Math.max(...[e.min,e.max,t].map(e=>{let[t=``,n=`0`]=String(e).split(`e`);return Math.max(0,(t.split(`.`)[1]?.length??0)-Number(n))})),r=Math.max(...[e.min,e.max].map(e=>n<=100?e.toFixed(n).length:String(e).length),String(e.default).length,String(t).length);return e.type===`slider`?`calc(${r}ch + var(--hub-space-8) * 2)`:`calc(${r}ch + var(--hub-space-8) * 2 + 1.25rem)`}function qe({id:e,control:t,value:n,disabled:r,message:i,onCommit:a}){let o=Ge(n,a),[s,c]=(0,V.useState)(null);function l(e){let n=e.target.value,r=t.type===`number`||t.type===`slider`?n===``?NaN:Number(n):n,i=Be(t,r);c(i),i?o.stage(n):o.commit(n,r)}let u=s||o.error,d=t.type===`number`||t.type===`slider`,f=t.type===`slider`?{"--controls-slider-progress":`${t.min===t.max?100:(Number(n)-t.min)/(t.max-t.min)*100}%`}:void 0,p=[i?`${e}-hint`:void 0,u?`${e}-validation`:void 0].filter(Boolean).join(` `)||void 0,m={id:e,disabled:r,value:String(o.draft),onChange:l,"aria-invalid":u?!0:void 0,"aria-describedby":p,onBlur:()=>{s&&(o.reset(),c(null))}},h;return h=t.type===`textarea`?(0,U.jsx)(H.Textarea,{...m,rows:2,resize:`vertical`}):d?(0,U.jsx)(H.TextInput,{...m,className:t.type===`slider`?`controls-number-input controls-number-input--slider`:`controls-number-input`,type:`number`,min:t.min,max:t.max,step:t.step??1,validationStatus:u?`error`:void 0,"aria-labelledby":`${e}-label`,style:{width:Ke(t)}}):t.type===`color`?(0,U.jsx)(`input`,{...m,className:`controls-native-color`,type:`color`}):(0,U.jsx)(H.TextInput,{...m,type:`text`}),(0,U.jsxs)(H.FormControl,{id:e,className:d?`controls-field controls-field--${t.type}`:`controls-field`,fullWidth:!d||t.type===`slider`,validationStatus:u?`error`:void 0,children:[d?(0,U.jsxs)(`div`,{className:`controls-field-heading`,children:[(0,U.jsx)(H.FormControl.Label,{id:`${e}-label`,htmlFor:e,className:`controls-field-label`,children:t.label}),t.type===`slider`?(0,U.jsxs)(`div`,{className:`controls-slider-row`,children:[(0,U.jsx)(`input`,{...m,id:`${e}-slider`,value:String(n),className:`controls-native-slider`,type:`range`,style:f,min:t.min,max:t.max,step:t.step??1,"aria-labelledby":`${e}-label`}),h]}):h]}):(0,U.jsx)(H.FormControl.Label,{className:`controls-field-label`,children:t.label}),d?null:h,i?(0,U.jsx)(H.FormControl.Hint,{children:(0,U.jsx)(`span`,{role:`status`,children:i})}):null,u?(0,U.jsx)(H.FormControl.Validation,{className:`controls-field-validation`,"aria-live":`polite`,children:u}):null]})}function Je({id:e,control:t,value:n,disabled:r,message:i,onCommit:a}){let o=Ge(n,a),s=[i?`${e}-unavailable`:void 0,o.error?`${e}-validation`:void 0].filter(Boolean).join(` `)||void 0;if(t.type===`boolean`||t.type===`select`)return(0,U.jsxs)(H.FormControl,{id:e,className:t.type===`boolean`?`controls-field controls-choice-row`:`controls-field controls-field--select`,fullWidth:t.type===`boolean`,validationStatus:o.error?`error`:void 0,children:[t.type===`select`?(0,U.jsx)(H.FormControl.Label,{className:`controls-field-label`,children:t.label}):null,t.type===`boolean`?(0,U.jsx)(H.Checkbox,{className:`controls-choice-mark`,disabled:r,"aria-describedby":s,checked:o.draft===!0,onChange:e=>o.commit(e.target.checked)}):(0,U.jsx)(H.Select,{className:`controls-select-input`,disabled:r,"aria-describedby":s,value:o.draft,onChange:e=>o.commit(e.target.value),children:t.options.map(e=>(0,U.jsx)(H.Select.Option,{value:e,children:e},e))}),t.type===`boolean`?(0,U.jsx)(H.FormControl.Label,{className:`controls-choice-label`,children:t.label}):null,i?(0,U.jsx)(H.FormControl.Hint,{children:(0,U.jsx)(`span`,{role:`status`,children:i})}):null,o.error?(0,U.jsx)(H.FormControl.Validation,{className:`controls-field-validation`,"aria-live":`polite`,children:o.error}):null]});let c=t.type===`checkboxGroup`,l=t.type===`segmented`,u=c?H.CheckboxGroup:H.RadioGroup,d=c?H.Checkbox:H.Radio;return(0,U.jsxs)(u,{id:e,className:`controls-field`,"aria-disabled":r||void 0,"aria-describedby":s,children:[(0,U.jsx)(u.Label,{className:`controls-choice-group-label`,children:t.label}),(0,U.jsx)(`div`,{className:l?`controls-segments`:`controls-options`,children:t.options.map((t,n)=>{let i=`${e}-${n}`,a=c?o.draft.includes(t):o.draft===t,u=(0,U.jsx)(d,{className:c?`controls-choice-mark`:`controls-choice-mark controls-choice-mark--radio`,id:i,name:e,value:t,checked:a,disabled:r,"aria-describedby":s,onChange:e=>{let n=o.current();o.commit(c?e.target.checked?[...n,t]:n.filter(e=>e!==t):t)}});return l?(0,U.jsxs)(`label`,{htmlFor:i,className:`controls-segment`,title:t,children:[(0,U.jsx)(le,{children:u}),(0,U.jsx)(H.Text,{as:`span`,size:`100`,weight:`medium`,children:t})]},t):(0,U.jsxs)(H.FormControl,{id:i,className:`controls-field controls-choice-row`,children:[u,(0,U.jsx)(H.FormControl.Label,{className:`controls-choice-label`,children:t})]},t)})}),i?(0,U.jsx)(H.Text,{as:`span`,id:`${e}-unavailable`,size:`100`,variant:`muted`,role:`status`,children:i}):null,o.error?(0,U.jsx)(u.Validation,{variant:`error`,role:`status`,children:o.error}):null]})}function Ye(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?G.controlsActionUnavailable:``)}}function Xe({scopes:e,disabled:t=!1,onCommand:n,collapsedGroups:r,onGroupCollapse:i}){let a=(0,V.useId)(),o=(0,V.useRef)(null),s=(0,V.useRef)(null),[c,l]=(0,V.useState)({});(0,V.useLayoutEffect)(()=>{s.current&&!s.current.isConnected&&(document.activeElement===document.body&&o.current?.focus(),s.current=null)},[e]);function u(e,r){if(!e.snapshot.visible[r.id])return null;let i=`${a}-${e.declaration.scope}-${r.id}`,o=e.snapshot.values[r.id];function s(t){return n(`update`,e.declaration.scope,r.id,t)}let c=e.snapshot.bindings?.[r.id],l=Ye(e,r),u={id:i,message:l.error?l.available?G.controlsNotApplied(r.label):G.controlsUnavailable(r.label):void 0,disabled:t||!!c?.error&&c?.available!==!0||c?.busy===!0};switch(r.type){case`button`:{let t=e.snapshot.actions[r.id];return(0,U.jsx)(`div`,{className:`controls-field controls-action-field`,children:(0,U.jsxs)(H.Button,{type:`button`,size:`small`,variant:`secondary`,className:`controls-action-button`,disabled:u.disabled||!t?.available||t.busy,"aria-describedby":u.message?`${i}-unavailable`:void 0,"aria-busy":t?.busy,onClick:()=>{n(`action`,e.declaration.scope,r.id)},children:[r.label,t?.busy?G.controlsActionBusy:``]})},r.id)}case`boolean`:case`select`:case`radio`:case`segmented`:case`checkboxGroup`:return(0,U.jsx)(Je,{...u,control:r,value:o,onCommit:s},r.id);case`number`:case`slider`:case`text`:case`textarea`:case`color`:return(0,U.jsx)(qe,{...u,control:r,value:o,onCommit:s},r.id)}}function d(e,t){if(!e.snapshot.visible[t.id])return null;let n=Ye(e,t);return(0,U.jsxs)(V.Fragment,{children:[u(e,t),t.type===`button`&&n.error?(0,U.jsx)(H.Text,{as:`p`,id:`${a}-${e.declaration.scope}-${t.id}-unavailable`,size:`100`,variant:`muted`,role:`status`,children:n.available?G.controlsNotApplied(t.label):G.controlsUnavailable(t.label)}):null]},t.id)}let f=[...e.filter(e=>e.declaration.role===`shared`),...e.filter(e=>e.declaration.role!==`shared`)].filter(e=>e.declaration.controls.some(t=>t.group?e.snapshot.groups[t.group]:e.snapshot.visible[t.id]));return(0,U.jsx)(`div`,{ref:o,tabIndex:-1,role:`region`,"aria-label":G.controlsRegion,className:`controls-fields`,onFocusCapture:e=>{s.current=e.target},children:f.map((e,t)=>{let n=new Set;return(0,U.jsxs)(`section`,{className:`controls-scope`,"aria-label":e.declaration.label??e.declaration.scope,children:[t>0?(0,U.jsx)(`hr`,{className:`controls-scope-divider`}):null,e.declaration.controls.map(t=>{if(!t.group)return d(e,t);if(n.has(t.group))return null;n.add(t.group);let o=e.declaration.groups?.find(e=>e.id===t.group);if(!o||!e.snapshot.groups[o.id])return null;let s=`${e.declaration.scope}/${o.id}`,u=(r??c)[s]===!0,f=`${a}-${e.declaration.scope}-${o.id}-group`;return(0,U.jsxs)(`fieldset`,{className:`controls-group`,"aria-label":o.label,children:[(0,U.jsx)(`legend`,{children:(0,U.jsx)(H.Button,{size:`small`,variant:`subtle`,type:`button`,block:!0,className:`controls-group-toggle controls-ghost-button`,"aria-label":u?G.controlsExpandGroup(o.label):G.controlsCollapseGroup(o.label),"aria-controls":f,"aria-expanded":!u,trailingVisual:u?(0,U.jsx)(m,{size:16}):(0,U.jsx)(g,{size:16}),onClick:t=>{t.currentTarget.focus(),i?i(e.declaration.scope,o.id,!u):l(e=>({...e,[s]:!u}))},children:(0,U.jsx)(H.Text,{as:`span`,size:`100`,weight:`bold`,variant:`muted`,className:`controls-group-label`,children:o.label})})}),(0,U.jsx)(`div`,{id:f,className:`controls-group-body`,hidden:u,children:e.declaration.controls.filter(e=>e.group===o.id).map(t=>d(e,t))})]},o.id)})]},e.declaration.scope)})})}function Ze(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}function Qe(e,t){let n=(0,V.useRef)(null),r=(0,V.useRef)(null),i=(0,V.useRef)(null),a=(0,V.useRef)({position:e,onChange:t}),o=(0,V.useRef)(null),[s,c]=(0,V.useState)(!1);(0,V.useLayoutEffect)(()=>{a.current={position:e,onChange:t}});let l=(0,V.useCallback)(e=>{let t=n.current?.getBoundingClientRect(),i=r.current?.getBoundingClientRect();if(!t||!i||!t.width||!t.height)return;let o={x:Math.max(0,Math.min(e.x,Math.max(0,t.width-i.width))),y:Math.max(0,Math.min(e.y,Math.max(0,t.height-i.height)))};(a.current.position?.x!==o.x||a.current.position?.y!==o.y)&&a.current.onChange(o)},[]);(0,V.useLayoutEffect)(()=>{let e=n.current,t=r.current;if(!e||!t)return;function i(){let n=e?.getBoundingClientRect(),r=t?.getBoundingClientRect();if(!n||!r||!n.width||!n.height)return;let i=r.left-n.left,a=r.top-n.top;(i<0||a<0||i>Math.max(0,n.width-r.width)||a>Math.max(0,n.height-r.height))&&l({x:i,y:a})}let a=new ResizeObserver(i);return a.observe(e),a.observe(t),window.addEventListener(`resize`,i),i(),()=>{a.disconnect(),window.removeEventListener(`resize`,i)}},[l]);function u(e=!1){let t=o.current;o.current=null,c(!1),t&&(e&&l(t.origin),i.current?.hasPointerCapture(t.pointerId)&&i.current.releasePointerCapture(t.pointerId))}return{boundsRef:n,panelRef:r,handleRef:i,dragging:s,onPointerDown:e=>{if(e.button!==0||o.current)return;let t=n.current?.getBoundingClientRect(),i=r.current?.getBoundingClientRect();t&&i&&(o.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,origin:{x:i.left-t.left,y:i.top-t.top}},e.currentTarget.setPointerCapture(e.pointerId),e.currentTarget.focus(),e.preventDefault(),c(!0))},onPointerMove:e=>{let t=o.current;t&&t.pointerId===e.pointerId&&l({x:t.origin.x+e.clientX-t.x,y:t.origin.y+e.clientY-t.y})},onPointerUp:e=>{o.current?.pointerId===e.pointerId&&u()},onPointerCancel:e=>{o.current?.pointerId===e.pointerId&&u(!0)},onLostPointerCapture:()=>{o.current&&u()},onKeyDown:e=>{if(e.key===`Escape`&&o.current){e.preventDefault(),u(!0);return}if(![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(e.key))return;let t=n.current?.getBoundingClientRect(),i=r.current?.getBoundingClientRect();if(!t||!i)return;e.preventDefault();let a=e.shiftKey?1:10;l({x:i.left-t.left+(e.key===`ArrowLeft`?-a:e.key===`ArrowRight`?a:0),y:i.top-t.top+(e.key===`ArrowUp`?-a:e.key===`ArrowDown`?a:0)})}}}function $e(e){let t=e.filter(e=>e.declaration.role!==`shared`),n=t.length?t:e;return n.length?Math.max(...n.map(e=>e.declaration.panel?.width??288)):288}function et({state:e,connection:t,layout:n,onLayoutChange:r,onDiagnose:i,diagnosisTarget:a=``}){let s=e.loading?[]:e.scopes.flatMap(e=>e.declaration.controls.flatMap(t=>{let n=Ye(e,t);return n.visible&&n.error?[{...n,label:t.label}]:[]})),c=!!(i&&!e.loading&&(!e.runtimeAvailable&&e.error||e.storageError||s.length||e.reconnectRequired||e.status===`missing-runtime`||e.status===`unsupported-runtime`||e.status===`invalid-config`)),l=c?JSON.stringify([a,e.status,e.runtimeAvailable,e.reconnectRequired,e.error,e.storageError,s.map(({scope:e,id:t,error:n})=>[e,t,n])]):``,[u,d]=(0,V.useState)(()=>({episode:l,identity:{},busy:!1,requested:!1,error:``}));u.episode!==l&&d({episode:l,identity:{},busy:!1,requested:!1,error:``});async function f(){if(!i||!c||u.busy||u.requested)return;let e=u.identity;d(t=>t.identity===e?{...t,busy:!0,error:``}:t);try{await i(),d(t=>t.identity===e?{...t,requested:!0}:t)}catch(t){d(n=>n.identity===e?{...n,error:t instanceof Error?t.message:G.controlsDiagnosisFailed}:n)}finally{d(t=>t.identity===e?{...t,busy:!1}:t)}}let m=(0,V.useId)(),h=(0,V.useId)(),_=(0,V.useRef)(null),{boundsRef:v,panelRef:y,handleRef:b,dragging:x,onPointerDown:S,onPointerMove:C,onPointerUp:w,onPointerCancel:T,onLostPointerCapture:E,onKeyDown:D}=Qe(n.position,e=>r(t=>({...t,position:e})));(0,V.useEffect)(()=>{b.current?.focus()},[b]),(0,V.useLayoutEffect)(()=>{_.current&&!_.current.isConnected&&(document.activeElement===document.body&&b.current?.focus(),_.current=null)},[e,b]);let O=e.loading?G.controlsConnecting:e.status===`no-controls`?G.controlsEmpty:e.status===`missing-runtime`?i?G.controlsLocalMissingRuntime:G.controlsMissingRuntime:e.status===`unsupported-runtime`?G.controlsUnsupportedRuntime:e.status===`invalid-config`?G.controlsInvalid:``,k=!e.loading&&(e.storageError||e.reconnectRequired||!e.runtimeAvailable&&e.error);return(0,U.jsx)(`div`,{ref:v,className:`canvas-controls-layer`,children:(0,U.jsxs)(`aside`,{ref:y,className:`canvas-controls-panel`,"aria-label":G.controls,onFocusCapture:e=>{e.target instanceof HTMLElement&&(_.current=e.target)},"data-collapsed":n.collapsed,"data-dragging":x||void 0,style:{left:n.position?.x,top:n.position?.y,width:`min(${$e(e.scopes)}px, calc(100% - var(--hub-space-16) * 2))`},children:[(0,U.jsxs)(`header`,{className:`canvas-controls-header`,children:[(0,U.jsx)(W,{icon:o,ref:b,size:`small`,variant:`invisible`,className:`canvas-controls-grab controls-ghost-button`,"aria-label":G.controlsMove,"aria-describedby":h,title:``,onPointerDown:S,onPointerMove:C,onPointerUp:w,onPointerCancel:T,onLostPointerCapture:E,onKeyDown:D}),(0,U.jsx)(le,{id:h,children:G.controlsMoveHint}),(0,U.jsx)(H.Button,{type:`button`,size:`small`,variant:`subtle`,block:!0,className:`canvas-controls-title controls-ghost-button`,"aria-label":n.collapsed?G.controlsExpand:G.controlsCollapse,"aria-expanded":!n.collapsed,"aria-controls":m,trailingVisual:n.collapsed?(0,U.jsx)(g,{size:16}):(0,U.jsx)(p,{size:16}),onClick:()=>r(e=>({...e,collapsed:!e.collapsed})),children:G.controls}),(0,U.jsx)(W,{icon:L,size:`small`,variant:`invisible`,className:`controls-ghost-button`,"aria-label":G.controlsResetAll,disabled:!e.runtimeAvailable||e.reconnectRequired||e.loading||e.resetting||!e.storageError&&!e.hasResettableValues&&!e.scopes.some(e=>Object.keys(Ze(e)).length>0)||e.scopes.some(e=>Object.values(e.snapshot.actions).some(e=>e.busy))||e.status!==`ready`&&e.status!==`no-controls`&&!e.storageError,onClick:()=>{t.resetAll()}})]}),(0,U.jsxs)(`div`,{id:m,className:`canvas-controls-body`,hidden:n.collapsed,children:[(0,U.jsxs)(`div`,{className:`canvas-controls-content`,children:[O||e.notice?(0,U.jsx)(`div`,{role:`status`,"aria-live":`polite`,children:(0,U.jsx)(H.Text,{as:`p`,size:`100`,variant:`muted`,children:[O,e.notice].filter(Boolean).join(` `)})}):null,!e.loading&&e.error?(0,U.jsx)(H.Text,{as:`p`,size:`100`,role:`alert`,children:e.error}):null,!e.loading&&e.scopeErrors?.map(e=>(0,U.jsx)(H.Text,{as:`p`,size:`100`,role:`alert`,children:G.controlsScopeError(e.scope,e.error)},e.scope)),!e.loading&&e.storageError?(0,U.jsx)(H.Text,{as:`p`,size:`100`,role:`alert`,children:e.storageError}):null,u.error?(0,U.jsx)(H.Text,{as:`p`,size:`100`,role:`alert`,children:u.error}):null,(0,U.jsx)(Xe,{scopes:e.loading?[]:e.scopes,disabled:e.resetting||e.reconnectRequired,collapsedGroups:n.collapsedGroups,onGroupCollapse:(e,t,n)=>r(r=>({...r,collapsedGroups:{...r.collapsedGroups,[`${e}/${t}`]:n}})),onCommand:(e,n,r,i)=>t.command(e,n,r,i)}),s.length?(0,U.jsxs)(H.Accordion,{className:`canvas-controls-diagnostics`,disableAnimation:!0,children:[(0,U.jsx)(H.Accordion.Heading,{children:G.controlsDiagnostics}),(0,U.jsx)(H.Accordion.Content,{children:s.map(({scope:e,id:t,label:n,error:r})=>(0,U.jsxs)(H.Text,{as:`p`,size:`100`,children:[n,`: `,r]},`${e}/${t}`))})]}):null]}),c||k?(0,U.jsxs)(`footer`,{className:`canvas-controls-footer`,children:[c?(0,U.jsx)(H.Button,{size:`small`,variant:`secondary`,type:`button`,disabled:u.busy||u.requested||e.resetting,onClick:()=>void f(),children:u.requested?G.controlsDiagnosisRequested:s.length?G.controlsFix:G.controlsDiagnose}):null,k?(0,U.jsx)(H.Button,{size:`small`,variant:`secondary`,type:`button`,disabled:e.resetting,onClick:()=>t.retry(),children:e.storageError?G.controlsRetryStorage:G.controlsRetry}):null]}):null]})]})})}var tt=c();function nt({children:e,className:t,...n}){return(0,U.jsx)(`span`,{...n,className:`hub-counter${t?` ${t}`:``}`,children:e})}var rt=(0,V.createContext)(null);function it({source:e,children:t}){return(0,U.jsx)(rt,{value:e,children:t})}function at({title:e,label:t=e,open:n,closeLabel:r,closeDisabled:i=!1,closeShortcut:a,closeRef:o,onClose:s,headerAccessory:c,className:l,contentClassName:u,children:d}){return(0,U.jsxs)(`aside`,{className:`hub-sidebar${l?` ${l}`:``}`,"aria-label":t,"aria-hidden":!n,"data-open":n,inert:!n,children:[(0,U.jsxs)(`header`,{className:`hub-sidebar__header`,children:[(0,U.jsxs)(`div`,{className:`hub-sidebar__heading`,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`subhead-medium`,weight:`normal`,children:e}),c]}),(0,U.jsx)(W,{ref:o,icon:B,"aria-label":r,"aria-keyshortcuts":a,title:r,description:r,variant:`invisible`,size:`small`,className:`hub-sidebar__close`,disabled:i,onClick:s})]}),(0,U.jsx)(`div`,{className:`hub-sidebar__content${u?` ${u}`:``}`,children:d})]})}function ot({src:e,size:t=32,className:n}){return(0,U.jsx)(H.Avatar,{src:e||`/avatar-placeholder.svg`,alt:``,size:32,className:`hub-user-avatar hub-user-avatar--${t}${n?` ${n}`:``}`})}function st({participants:e,size:t}){let n=e.slice(0,4),r=e.length-3;return(0,U.jsxs)(`span`,{className:`review-participant-stack review-participant-stack--${t}`,"data-avatar-count":n.length,"data-participant-count":e.length,"aria-hidden":`true`,children:[(r>1?n.slice(0,3):n).map(e=>(0,U.jsx)(`span`,{className:`review-participant-stack__avatar`,children:(0,U.jsx)(ot,{src:e.avatarUrl,size:24})},e.login)),r>1?(0,U.jsxs)(`span`,{className:`review-participant-stack__avatar review-participant-stack__avatar--overflow`,children:[`+`,r]}):null]})}function ct(e,t){let n=e.path.map(e=>({x:t.x+e.x*t.width,y:t.y+e.y*t.height})),r={x:t.x+t.width,y:t.y};return{path:n,point:n.reduce((e,t)=>{let n=(t.x-r.x)**2+(t.y-r.y)**2;return n{let e=c.current;if(!e)return;function t(){let t=e?.clientWidth??0;if(t)for(let e of l.current.values()){let n=Number.parseFloat(e.style.left),r=e.offsetWidth;if(!Number.isFinite(n)||!r)continue;let i=n-16,a=Math.max(0,Math.min(i,t-r))-i;e.style.setProperty(`--review-marker-offset-x`,`${a}px`)}}t();let n=typeof ResizeObserver>`u`?null:new ResizeObserver(t);n?.observe(e);for(let e of l.current.values())n?.observe(e);return window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[t,e]),(0,V.useEffect)(()=>{!i||n===null||u!==`resolved`&&u!==`moved`||l.current.get(n)?.focus({preventScroll:!0})},[i,u,n]),(0,U.jsx)(`div`,{ref:c,className:`review-comment-markers`,role:`group`,"aria-label":o.heading,children:e.map(e=>{let{root:i}=e,c=t.get(i.id);if(!c||c.status!==`resolved`&&c.status!==`moved`)return null;let u=e.replies.length>0,d=(e.unread?u?o.unreadMarkerWithRepliesLabel:o.unreadMarkerLabel:u?o.markerWithRepliesLabel:o.markerLabel).replace(`%{author}`,`@${i.author.login}`).replace(`%{count}`,(e.replies.length+1).toString()),f=i.anchor.kind===`area`?ct(i.anchor,c.rect):null,p=e.participants.slice(3),m=p.length>1?p.map(({login:e})=>`@${e}`).join(`, `):d;return(0,U.jsxs)(V.Fragment,{children:[f&&(!a||n===i.id)?(0,U.jsx)(`svg`,{className:`review-comment-area`,"aria-hidden":`true`,width:`100%`,height:`100%`,children:(0,U.jsx)(`polyline`,{className:n===i.id?`review-comment-area__path review-comment-area__path--selected`:`review-comment-area__path`,points:f.path.map(e=>`${e.x},${e.y}`).join(` `),vectorEffect:`non-scaling-stroke`})}):null,(0,U.jsx)(H.Tooltip,{text:m,type:`description`,ref:e=>{e instanceof HTMLButtonElement?l.current.set(i.id,e):l.current.delete(i.id)},children:(0,U.jsx)(`button`,{type:`button`,"data-review-thread-id":i.id,className:`review-comment-marker${n===i.id?` review-comment-marker--selected`:``}${i.resolvedAt?` review-comment-marker--resolved`:``}${e.unread?` review-comment-marker--unread`:``}${r&&n!==i.id?` review-comment-marker--blocked`:``}`,style:{left:f?.point.x??c.point.x,top:f?.point.y??c.point.y},"aria-label":d,disabled:r&&n!==i.id,onClick:()=>s(e),children:(0,U.jsx)(st,{participants:e.participants,size:`small`})})})]},i.id)})})}function Z({checked:e,onChange:t,size:n=`medium`,className:r,...i}){let{value:a,...o}=i;return(0,U.jsxs)(`label`,{className:`hub-switch hub-switch--${n}${r?` ${r}`:``}`,"data-disabled":i.disabled||void 0,children:[(0,U.jsx)(`span`,{className:`hub-switch__native-control`,children:(0,U.jsx)(H.Checkbox,{...o,value:a===void 0?void 0:String(a),role:`switch`,checked:e,onChange:e=>{i.disabled||t(e.currentTarget.checked)}})}),(0,U.jsx)(`span`,{className:`hub-switch__track`,"data-checked":e,"aria-hidden":`true`,children:(0,U.jsx)(`span`,{className:`hub-switch__thumb`})})]})}function Q(e){(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.click())}function ut({filters:e,participants:t,showPins:n,copy:r,onFiltersChange:i,onShowPinsChange:a}){let[o,s]=(0,V.useState)(!1),c=e.currentBuildOnly||e.currentPageOnly||e.showResolved||!e.showRead||e.onlyMine||e.participant!==null||!n,l=t.find(t=>t.login===e.participant),u=e.participant===null?r.allParticipantsLabel:l?.name?`${l.name} (@${l.login})`:`@${e.participant}`;return(0,U.jsxs)(`div`,{className:`review-comment-filter-controls`,children:[(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__search`,children:[(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__search-field`,children:[(0,U.jsx)(ne,{className:`review-comment-filter-controls__search-icon`,size:16,"aria-hidden":`true`}),(0,U.jsx)(`input`,{type:`search`,className:`review-comment-filter-controls__input`,"aria-label":r.searchLabel,placeholder:r.searchPlaceholder,value:e.search,onChange:t=>i({...e,search:t.target.value})})]}),(0,U.jsx)(W,{icon:h,"aria-label":r.filterLabel,description:r.filterLabel,"aria-expanded":o,variant:`invisible`,className:`review-comment-filter-controls__button${o||c?` review-comment-filter-controls__button--active`:``}`,onClick:()=>s(e=>!e)})]}),o?(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__filters`,children:[(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__participant`,children:[(0,U.jsx)(`span`,{children:r.participantFilterLabel}),(0,U.jsxs)(H.ActionMenu,{size:`small`,selectionVariant:`single`,menuAlignment:`end`,onSelect:t=>i({...e,participant:t===``?null:t}),children:[(0,U.jsx)(H.ActionMenu.Button,{className:`review-comment-filter-controls__participant-trigger`,variant:`secondary`,size:`small`,"aria-label":`${r.participantFilterLabel}: ${u}`,children:(0,U.jsx)(`span`,{className:`review-comment-filter-controls__participant-name`,children:u})}),(0,U.jsxs)(H.ActionMenu.Overlay,{"aria-label":r.participantFilterLabel,children:[(0,U.jsx)(H.ActionMenu.Item,{value:``,selected:e.participant===null,role:`menuitemradio`,onKeyDownCapture:Q,children:r.allParticipantsLabel}),t.map(t=>(0,U.jsx)(H.ActionMenu.Item,{value:t.login,selected:e.participant===t.login,role:`menuitemradio`,onKeyDownCapture:Q,children:t.name?`${t.name} (@${t.login})`:`@${t.login}`},t.login))]})]})]}),(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__toggle`,children:[(0,U.jsx)(`span`,{id:`review-comments-current-build`,children:r.currentBuildFilterLabel}),(0,U.jsx)(Z,{"aria-labelledby":`review-comments-current-build`,checked:e.currentBuildOnly,size:`small`,onChange:t=>i({...e,currentBuildOnly:t})})]}),(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__toggle`,children:[(0,U.jsx)(`span`,{id:`review-comments-current-page`,children:r.currentPageFilterLabel}),(0,U.jsx)(Z,{"aria-labelledby":`review-comments-current-page`,checked:e.currentPageOnly,size:`small`,onChange:t=>i({...e,currentPageOnly:t})})]}),(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__toggle`,children:[(0,U.jsx)(`span`,{id:`review-comments-show-resolved`,children:r.showResolvedLabel}),(0,U.jsx)(Z,{"aria-labelledby":`review-comments-show-resolved`,checked:e.showResolved,size:`small`,onChange:t=>i({...e,showResolved:t})})]}),(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__toggle`,children:[(0,U.jsx)(`span`,{id:`review-comments-unread-only`,children:r.unreadOnlyLabel}),(0,U.jsx)(Z,{"aria-labelledby":`review-comments-unread-only`,checked:!e.showRead,size:`small`,onChange:t=>i({...e,showRead:!t})})]}),(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__toggle`,children:[(0,U.jsx)(`span`,{id:`review-comments-only-mine`,children:r.onlyMineLabel}),(0,U.jsx)(Z,{"aria-labelledby":`review-comments-only-mine`,checked:e.onlyMine,size:`small`,onChange:t=>i({...e,onlyMine:t})})]}),(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__toggle`,children:[(0,U.jsx)(`span`,{id:`review-comments-show-pins`,children:r.showPinsLabel}),(0,U.jsx)(Z,{"aria-labelledby":`review-comments-show-pins`,checked:n,size:`small`,onChange:a})]})]}):null]})}var dt=[[31536e3,`y`],[2592e3,`mo`],[604800,`w`],[86400,`d`],[3600,`h`],[60,`m`]];function ft(e){let t=window.setInterval(e,6e4);return()=>window.clearInterval(t)}function pt(){return Math.floor(Date.now()/6e4)*6e4}function mt(){return null}function ht({value:e,showTitle:t=!0}){let n=Date.parse(e),r=Number.isNaN(n)?e:new Date(n).toUTCString(),i=(0,V.useSyncExternalStore)(ft,pt,mt),a=r;if(i!==null&&!Number.isNaN(n)){let e=Math.round((i-n)/1e3),t=dt.find(([t])=>Math.abs(e)>=t);a=t?`${e<0?`in `:``}${Math.round(Math.abs(e)/t[0])}${t[1]}${e<0?``:` ago`}`:`just now`}return(0,U.jsx)(`time`,{dateTime:e,title:t?r:void 0,"aria-label":r,children:a})}function gt({thread:e,currentBuildNumber:t,resolution:n,anchorStatusLabel:r,selected:i,selectionBlocked:a,copy:o,onSelect:s,buildHref:c}){let l=(0,V.useId)(),{root:u}=e,d=u.author.name||`@${u.author.login}`,f=a&&!i,p=o.buildLabel.replace(`%{number}`,u.buildNumber.toString()),m=u.buildNumber!==t,h=e.replies.length===1?o.replyCountOneLabel:o.replyCountOtherLabel.replace(`%{count}`,e.replies.length.toString()),g=o.missingAnchorLabel;return u.resolvedAt?g=o.resolvedLabel:r===void 0?n?n.status===`resolved`?g=null:n.status===`moved`?g=o.movedAnchorLabel:n.status===`changed`?g=o.changedAnchorLabel:n.status===`route-mismatch`&&(g=o.routeMismatchLabel):g=null:g=r,(0,U.jsx)(`article`,{className:`review-comment-row${i?` review-comment-row--selected`:``}${e.unread?` review-comment-row--unread`:``}`,onClick:t=>{f||t.target instanceof Element&&t.target.closest(`a`)||s(e)},children:(0,U.jsx)(`div`,{className:`review-comment-row__layout`,children:(0,U.jsxs)(`div`,{className:`review-comment-row__content`,children:[(0,U.jsxs)(`div`,{className:`review-comment-row__copy`,children:[(0,U.jsxs)(`div`,{className:`review-comment-row__metadata`,children:[(0,U.jsxs)(`span`,{className:`review-comment-row__author-and-build`,children:[(0,U.jsx)(ot,{src:u.author.avatarUrl,size:20,className:`review-comment-row__avatar`}),(0,U.jsx)(`span`,{id:`${l}-author`,className:`review-comment-row__author`,children:d}),m?(0,U.jsxs)(`span`,{className:`review-comment-row__build`,children:[`(`,(0,U.jsx)(`a`,{href:c||u.buildPath,target:c?`_blank`:void 0,rel:c?`noopener noreferrer`:void 0,children:p}),`)`]}):null]}),(0,U.jsx)(ht,{value:e.lastActivityAt})]}),(0,U.jsx)(`button`,{type:`button`,className:`review-comment-row__button`,"aria-labelledby":`${l}-author ${l}-body${e.unread?` ${l}-unread`:``}`,"aria-pressed":i,disabled:f,title:f?o.selectionBlockedLabel:void 0,children:(0,U.jsxs)(`span`,{className:`review-comment-row__body-container`,children:[e.unread?(0,U.jsx)(`span`,{role:`img`,id:`${l}-unread`,"aria-label":o.unreadLabel,title:o.unreadLabel,className:`review-comment-row__unread`}):null,(0,U.jsx)(`span`,{id:`${l}-body`,className:`review-comment-row__body`,children:u.body??o.deletedCommentLabel})]})})]}),g||e.replies.length>0?(0,U.jsxs)(`div`,{className:`review-comment-row__context`,children:[e.replies.length>0?(0,U.jsx)(`span`,{className:`review-comment-row__replies`,children:h}):null,g?(0,U.jsx)(H.Label,{size:`small`,className:`review-comment-row__status`,children:g}):null]}):null]})})})}function _t({frame:e,threads:t,currentBuildNumber:n,buildLinkOrigin:r,totalCount:i,hasThreads:a,filters:o,participants:s,resolutions:c,selectedThreadId:l,selectionBlocked:u,closeBlocked:d,showPins:f,loading:p,loadFailed:m,notice:h,copy:g,onClose:_,onFiltersChange:v,onShowPinsChange:y,onRetry:b,onSelect:x}){let S=a?g.noMatchesLabel:g.emptyLabel,C=(0,U.jsxs)(U.Fragment,{children:[h,(0,U.jsx)(ut,{filters:o,participants:s,showPins:f,copy:g,onFiltersChange:v,onShowPinsChange:y}),(0,U.jsxs)(`div`,{className:`review-comments-sidebar__body`,"aria-live":`polite`,children:[m?(0,U.jsxs)(`div`,{className:`review-comments-sidebar__state`,role:`alert`,children:[(0,U.jsx)(`span`,{children:g.loadErrorLabel}),(0,U.jsx)(H.Button,{size:`small`,onClick:b,children:g.retryLabel})]}):t.length===0&&!p?(0,U.jsx)(`div`,{className:`review-comments-sidebar__state`,children:S}):(0,U.jsx)(`div`,{className:`review-comments-sidebar__threads`,children:t.map(e=>(0,U.jsx)(gt,{thread:e,currentBuildNumber:n,buildHref:r?new URL(e.root.buildPath,r).href:void 0,resolution:c.get(e.root.id),selected:l===e.root.id,selectionBlocked:u,copy:g,onSelect:x},e.root.id))}),p?(0,U.jsxs)(`div`,{className:`review-comments-sidebar__loading`,children:[(0,U.jsx)(ce,{decorative:!0,size:`small`}),(0,U.jsx)(`span`,{children:g.loadingLabel})]}):null]})]});return e?(0,U.jsx)(at,{...e,title:g.heading,closeLabel:g.closeLabel,closeDisabled:d,closeShortcut:`Shift+C`,onClose:_,headerAccessory:(0,U.jsx)(nt,{children:i}),children:C}):(0,U.jsxs)(`aside`,{className:`review-comments-sidebar`,"aria-label":g.heading,children:[(0,U.jsxs)(`header`,{className:`review-comments-sidebar__header`,children:[(0,U.jsxs)(`span`,{className:`review-comments-sidebar__heading`,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`6`,children:g.heading}),(0,U.jsx)(nt,{children:i})]}),(0,U.jsx)(W,{icon:B,"aria-label":g.closeLabel,"aria-keyshortcuts":`Shift+C`,description:g.closeLabel,size:`small`,variant:`invisible`,className:`review-comments-sidebar__close`,disabled:d,onClick:_})]}),C]})}function vt({bridgeReady:e,copy:t,selectionBlocked:n,selecting:r,onCancelSelection:i,onStartAreaSelection:a,onStartElementSelection:o}){let s=(0,V.useId)(),c=!e||n,l=e?n?t.selectionBlockedLabel:t.commentMenuLabel:t.bridgeUnavailableLabel;if(r)return(0,U.jsx)(W,{icon:B,"aria-label":t.cancelSelectionLabel,description:t.cancelSelectionLabel,"aria-pressed":!0,size:`small`,variant:`default`,className:`review-comment-control__trigger`,onClick:i});let u=(0,U.jsxs)(H.ActionMenu,{selectionVariant:`none`,size:`small`,menuAlignment:`start`,disabled:c,children:[(0,U.jsx)(H.ActionMenu.Button,{className:`review-comment-control__trigger`,variant:`secondary`,"aria-label":t.commentMenuLabel,"aria-describedby":s,leadingVisual:(0,U.jsx)(f,{size:16}),onClick:e=>{let t=e.currentTarget,n=t.closest(`.repository-workspace__content`)?.getBoundingClientRect(),r=Math.min(window.innerHeight,n?.bottom??window.innerHeight),i=Math.max(0,r-t.getBoundingClientRect().bottom-8);t.closest(`[data-testid="ActionMenu"]`)?.style.setProperty(`--review-comment-control-menu-height`,`${i}px`)},children:``}),(0,U.jsxs)(H.ActionMenu.Overlay,{"aria-label":t.commentMenuLabel,children:[(0,U.jsx)(H.ActionMenu.Item,{className:`review-comment-control__menu-item`,value:`element`,leadingVisual:(0,U.jsx)(M,{size:16}),"aria-keyshortcuts":`C`,onClick:o,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())},children:t.commentOnElementLabel}),(0,U.jsx)(H.ActionMenu.Item,{className:`review-comment-control__menu-item`,value:`area`,leadingVisual:(0,U.jsx)(T,{size:16}),"aria-keyshortcuts":`H`,onClick:a,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())},children:t.highlightRegionLabel})]})]});return c?(0,U.jsxs)(`div`,{title:l,children:[u,(0,U.jsx)(le,{id:s,children:l})]}):(0,U.jsx)(H.Tooltip,{id:s,text:l,type:`description`,children:(0,U.jsx)(`div`,{children:u})})}var yt={search:``,currentBuildOnly:!1,currentPageOnly:!1,showResolved:!1,showRead:!0,onlyMine:!1,participant:null},bt={heading:`Comments`,closeLabel:`Close comments`,commentMenuLabel:`Add a comment`,commentOnElementLabel:`Comment on element`,highlightRegionLabel:`Highlight a region`,cancelSelectionLabel:`Cancel selection`,bridgeUnavailableLabel:`Adding comments needs the review bridge.`,selectionBlockedLabel:`Close or submit the open draft.`,selectionFailedLabel:`Hub could not anchor a comment to that element.`,areaTooSmallLabel:`Draw a larger region to add a comment.`,areaUnavailableLabel:`Hub could not save that region.`,searchLabel:`Search comments`,searchPlaceholder:`Search comments`,filterLabel:`Filters`,currentBuildFilterLabel:`Current build only`,currentPageFilterLabel:`Current page only`,participantFilterLabel:`Participant`,allParticipantsLabel:`All participants`,showResolvedLabel:`Show resolved`,unreadOnlyLabel:`Unread only`,onlyMineLabel:`Only your threads`,showPinsLabel:`Show pins`,sidebarShortcutLabel:`Shift+C`,loadingLabel:`Loading comments`,loadErrorLabel:`Comments could not be loaded.`,retryLabel:`Retry`,emptyLabel:`No comments have been added.`,noMatchesLabel:`No comments match these filters.`,buildLabel:`build %{number}`,movedAnchorLabel:`Moved`,changedAnchorLabel:`Context changed`,missingAnchorLabel:`Not found`,routeMismatchLabel:`Saved on another page`,resolvedLabel:`Resolved`,markerLabel:`Thread started by %{author}`,markerWithRepliesLabel:`Thread started by %{author}, %{count} comments`,unreadLabel:`Unread`,unreadMarkerLabel:`Unread thread started by %{author}`,unreadMarkerWithRepliesLabel:`Unread thread started by %{author}, %{count} comments`,replyCountOneLabel:`1 reply`,replyCountOtherLabel:`%{count} replies`,threadHeading:`Conversation`,backToCommentsLabel:`Back to comments`,resolvedByLabel:`Resolved by %{author}. Reopen this thread to reply.`,editedLabel:`Edited`,deletedCommentLabel:`Comment deleted`,addReactionLabel:`Add reaction`,reactionCountOneLabel:`%{reaction}, 1 reaction`,reactionCountOtherLabel:`%{reaction}, %{count} reactions`,reactionErrorLabel:`The reaction could not be changed.`,readErrorLabel:`Hub could not mark this conversation as read.`,markUnreadLabel:`Mark as unread`,markUnreadErrorLabel:`Hub could not mark this conversation as unread. Try again.`,reactionLabels:{"+1":`Thumbs up`,"-1":`Thumbs down`,laugh:`Laugh`,hooray:`Hooray`,confused:`Confused`,heart:`Heart`,rocket:`Rocket`,eyes:`Eyes`},commentActionsLabel:`Actions for comment by %{author}`,editLabel:`Edit`,deleteLabel:`Delete`,editCommentLabel:`Edit comment`,saveEditLabel:`Save`,savingEditLabel:`Saving comment`,cancelEditLabel:`Cancel`,editErrorLabel:`The comment could not be updated.`,deleteHeading:`Delete this comment?`,deletePromptLabel:`Deleted comment text cannot be recovered.`,confirmDeleteLabel:`Delete`,deletingLabel:`Deleting comment`,deleteErrorLabel:`The comment could not be deleted.`,replyLabel:`Reply`,replyPlaceholder:`Reply to this conversation`,replySubmitLabel:`Reply`,replySubmitTooltipMacLabel:`Reply (Cmd+Return)`,replySubmitTooltipOtherLabel:`Reply (Ctrl+Enter)`,replyingLabel:`Saving reply`,replyErrorLabel:`The reply could not be saved.`,resolveLabel:`Resolve`,resolvingLabel:`Resolving thread`,reopenLabel:`Reopen`,reopeningLabel:`Reopening thread`,resolutionErrorLabel:`The thread state could not be changed.`,resolvedReplyBlockedLabel:`Reopen this thread to reply.`,deletedReplyBlockedLabel:`Replies are closed.`,threadDiscardPromptLabel:`Your reply or edit has not been saved.`,composerHeading:`New comment`,composerLabel:`Comment`,composerPlaceholder:`Leave a review comment`,submitLabel:`Comment`,submitTooltipMacLabel:`Comment (Cmd+Return)`,submitTooltipOtherLabel:`Comment (Ctrl+Enter)`,submittingLabel:`Saving comment`,closeComposerLabel:`Cancel`,discardHeading:`Keep this draft?`,discardPromptLabel:`This comment has not been submitted.`,keepLabel:`Keep`,discardButtonLabel:`Discard`,bodyTooLongLabel:`Comments must be 10000 UTF-8 bytes or fewer.`,createErrorLabel:`The comment could not be saved.`};function xt(e,t){let n=new Map;n.set(e.login.toLowerCase(),e);for(let e of t.toReversed()){let t=e.login.toLowerCase();n.has(t)||n.set(t,e)}return Array.from(n.values())}function St(e){let t=new Map,n=new Map;for(let r of e){if(r.kind===`root`){t.set(r.id,r);continue}let e=n.get(r.rootId)??[];e.push(r),n.set(r.rootId,e)}return Array.from(t.values()).flatMap(e=>{let t=(n.get(e.id)??[]).filter(e=>e.deletedAt===null).sort((e,t)=>Date.parse(e.createdAt)-Date.parse(t.createdAt)||e.id-t.id);return e.deletedAt!==null&&t.length===0?[]:[{root:e,replies:t,participants:xt(e.author,t.map(e=>e.author)),lastActivityAt:t.at(-1)?.createdAt??e.createdAt,unread:e.viewerLastSeenActivityVersion===null||e.viewerLastSeenActivityVersionDate.parse(t.lastActivityAt)-Date.parse(e.lastActivityAt)||t.root.id-e.root.id)}var Ct=new TextEncoder;function wt(e,{prefix:t,required:n=!1}={}){return N().refine(r=>(!n||r!==``)&&(!t||r===``||r.startsWith(t))&&Ct.encode(r).length<=e)}var Tt=16384,Et=2048,Dt=2048,Ot=1024,kt=4096,At=1e3,jt=2e3,Mt=1e6,Nt=1e5,Pt=new TextEncoder,Ft=z().min(0).max(Mt),It=z().min(-Mt).max(Mt),Lt=z().min(0).max(Mt),Rt=E({x:z().min(0).max(1),y:z().min(0).max(1)}).strict(),zt=E({pathname:wt(Et,{prefix:`/`,required:!0}),search:wt(Dt,{prefix:`?`}),hash:wt(Ot,{prefix:`#`})}).strict(),Bt=E({x:Ft,y:Ft,width:Lt,height:Lt}).strict();E({x:It,y:It}).strict();var Vt=E({width:z().min(1).max(Nt),height:z().min(1).max(Nt),scrollX:Ft,scrollY:Ft}).strict(),Ht=E({schemaVersion:I(1),kind:I(`element`),route:zt,selector:wt(kt,{required:!0}),accessibleName:wt(At),tagName:wt(64,{required:!0}).regex(/^[a-z][a-z0-9-]*$/),selectedText:wt(jt),rect:Bt,viewport:Vt,elementOffset:Rt}).strict().refine(e=>Pt.encode(JSON.stringify(e)).length<=Tt),Ut=E({selector:wt(kt,{required:!0}),accessibleName:wt(At),tagName:wt(64,{required:!0}).regex(/^[a-z][a-z0-9-]*$/),role:wt(64),textExcerpt:wt(500),rect:Bt}).strict(),Wt=E({schemaVersion:I(1),kind:I(`area`),route:zt,path:R(Rt).min(2).max(160),rect:Bt,viewport:Vt,elements:R(Ut).max(8)}).strict().refine(e=>Math.hypot(e.rect.width,e.rect.height)>=8).refine(e=>Pt.encode(JSON.stringify(e)).length<=Tt),Gt=w(`kind`,[Ht,Wt]);w(`status`,[E({commentId:z().int().positive().max(2**53-1),status:te([`resolved`,`moved`]),rect:E({x:It,y:It,width:Lt,height:Lt}).strict(),point:E({x:It,y:It}).strict()}).strict(),E({commentId:z().int().positive().max(2**53-1),status:te([`changed`,`missing`,`route-mismatch`])}).strict()]);var Kt=z().int().positive().max(2**53-1),qt=N().refine(e=>!Number.isNaN(Date.parse(e))),Jt=qt.nullable(),Yt=E({login:N().min(1),name:N().nullable(),avatarUrl:N().nullable()}),Xt=te([`+1`,`-1`,`laugh`,`hooray`,`confused`,`heart`,`rocket`,`eyes`]),Zt=E({content:Xt,count:Kt,viewerHasReacted:j()}),Qt={id:Kt,body:N().nullable(),mentions:R(E({login:N().min(1),githubId:Kt})).optional(),createdAt:qt,updatedAt:qt,editedAt:Jt,deletedAt:Jt,author:Yt,viewerCanEdit:j(),viewerCanDelete:j(),reactions:R(Zt)},$t=E({...Qt,kind:I(`root`),buildNumber:Kt,buildPath:N().startsWith(`/`),anchor:Gt,resolvedAt:Jt,resolvedBy:Yt.nullable(),activityVersion:Kt,viewerLastSeenActivityVersion:Kt.nullable()}),en=E({...Qt,kind:I(`reply`),rootId:Kt}),tn=w(`kind`,[$t,en]),nn=w(`hasMore`,[E({comments:R(tn),nextCursor:N().min(1),hasMore:I(!0)}),E({comments:R(tn),nextCursor:F(),hasMore:I(!1)})]),rn=E({comments:R(tn).min(1).max(2)});function an(e,t){let{root:n}=e,{filters:r}=t;if(!r.showResolved&&n.resolvedAt!==null||!r.showRead&&!e.unread||r.onlyMine&&![n,...e.replies].some(e=>e.author.login.toLowerCase()===t.viewerLogin.toLowerCase())||r.currentBuildOnly&&n.buildNumber!==t.selectedBuildNumber||r.participant!==null&&!e.participants.some(e=>e.login.toLowerCase()===r.participant?.toLowerCase())||r.currentPageOnly&&t.route!==null&&(n.anchor.route.pathname!==t.route.pathname||n.anchor.route.search!==t.route.search||n.anchor.route.hash!==t.route.hash))return!1;let i=r.search.trim().toLowerCase();if(!i)return!0;let a=n.anchor.kind===`element`?[n.anchor.accessibleName,n.anchor.selectedText,n.anchor.tagName]:n.anchor.elements.flatMap(e=>[e.accessibleName,e.textExcerpt,e.tagName,e.role]);return[n.body??``,n.author.login,n.author.name??``,n.buildNumber.toString(),...e.replies.flatMap(e=>[e.body??``,e.author.login,e.author.name??``]),...a].join(` -`).toLowerCase().includes(i)}var on=E({candidates:R(E({githubId:z().int().positive().max(2**53-1),login:N().min(1).max(39),avatarUrl:N().nullable()}))});async function $(e,t,n={}){let r=await fetch(e,{...n,headers:{"Content-Type":`application/json`,"X-Replica-Canvas-Token":t,...n.headers}}),i=await r.json().catch(()=>({error:G.invalidResponse}));if(!r.ok)throw Object.assign(Error(i.error||G.requestFailed),{code:i.code,statusCode:r.status,authorization:i.authorization});return i}function sn({error:e,busy:t,requested:n,onFix:r,onDismiss:i}){let a=(0,V.useId)();return(0,U.jsxs)(ue,{title:G.commentingUnavailable,descriptionId:a,closeLabel:G.closeCommentingDialog,onClose:i,children:[(0,U.jsx)(`p`,{id:a,children:G.commentingDescription}),e?(0,U.jsx)(`p`,{role:`alert`,children:e}):null,(0,U.jsxs)(`div`,{className:`canvas-commenting-recovery__actions`,children:[(0,U.jsx)(H.Button,{variant:`primary`,disabled:t||n,onClick:r,children:n?G.commentingFixRequested:G.commentingFix}),(0,U.jsx)(H.Button,{variant:`subtle`,onClick:i,children:G.commentingDismiss})]})]})}function cn({cancelLabel:e,confirmLabel:t,description:n,errorLabel:r,heading:i,loading:a=!1,loadingAnnouncement:o,compact:s=!1,condensed:c=!1,onCancel:l,onConfirm:u}){let d=(0,U.jsx)(H.Button,{type:`button`,size:`small`,variant:c?`primary`:void 0,className:`review-confirmation-panel__cancel`,onClick:l,children:e}),f=(0,U.jsx)(H.Button,{type:`button`,size:`small`,variant:c?`secondary`:`primary`,className:c?void 0:`review-confirmation-panel__danger`,disabled:a,"aria-busy":a,onClick:u,children:t});return(0,U.jsxs)(`div`,{className:`review-confirmation-panel${s||c?` review-confirmation-panel--compact`:``}${c?` review-confirmation-panel--condensed`:``}`,role:`alert`,children:[(0,U.jsxs)(`div`,{className:`review-confirmation-panel__copy`,children:[(0,U.jsx)(`strong`,{children:i}),c?(0,U.jsx)(le,{children:n}):(0,U.jsx)(`span`,{children:n})]}),r?(0,U.jsx)(`span`,{className:`review-confirmation-panel__error`,children:r}):null,(0,U.jsxs)(`div`,{className:`review-confirmation-panel__actions`,children:[c?f:d,c?d:f,a&&o?(0,U.jsx)(le,{role:`status`,children:o}):null]})]})}function ln(){return(0,V.useContext)(rt)}function un(e){let t=e.matchAll(/(?e[1]?[e[1].toLowerCase()]:[])))}function dn({value:e,onValueChange:t,onKeyDown:n,ref:r,...i}){let a=ln(),o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=(0,V.useRef)(null),l=(0,V.useId)(),[u,d]=(0,V.useState)(e.length),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(!1),[v,y]=(0,V.useState)(0),[b,x]=(0,V.useState)(0),[S,C]=(0,V.useState)({left:0,top:0,width:0}),w=e.slice(0,u).match(/(?:^|[\s(])@([a-zA-Z0-9-]*)$/)?.[1]?.toLowerCase(),T=a!==null&&w!==void 0&&!f&&!i.disabled,E=un(e).length>10,D=m?.source===a&&m?.failed,O=g||m?.source!==a,k=(m?.source===a?m.candidates:[]).filter(e=>e.login.toLowerCase().includes(w??``)).slice(0,8),A=Math.min(b,Math.max(0,k.length-1));(0,V.useEffect)(()=>{o.current?.setCustomValidity(E?a?.copy.limit??``:``)},[a?.copy.limit,E]),(0,V.useEffect)(()=>{if(!T||!a)return;let e=!0,t=window.setTimeout(()=>{_(!0),a.load().then(t=>{e&&h({source:a,candidates:t,failed:!1})},()=>{e&&h({source:a,candidates:[],failed:!0})}).finally(()=>{e&&_(!1)})},150);return()=>{e=!1,window.clearTimeout(t)}},[T,v,a]),(0,V.useLayoutEffect)(()=>{if(!T)return;function e(){let e=o.current?.getBoundingClientRect();e&&C({left:e.left,width:e.width,top:Math.max(4,window.innerHeight-e.bottom<224?e.top-224:e.bottom)})}return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[T]);function j(n){if(w===void 0)return;let r=u-w.length-1,i=`@${n.login} `;t(e.slice(0,r)+i+e.slice(u)),p(!0);let a=r+i.length;window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.setSelectionRange(a,a),d(a)})}function M(e,t){o.current=e,typeof t==`function`?t(e):t&&(t.current=e)}return(0,U.jsxs)(`div`,{className:`mention-input`,children:[(0,U.jsx)(`textarea`,{...i,ref:e=>M(e,r),value:e,"aria-autocomplete":a?`list`:void 0,"aria-controls":T?l:void 0,"aria-activedescendant":T&&k.length?`${l}-${A}`:void 0,onChange:e=>{d(e.currentTarget.selectionStart),p(!1),x(0),t(e.currentTarget.value)},onSelect:e=>d(e.currentTarget.selectionStart),onBlur:e=>{s.current?.contains(e.relatedTarget)||p(!0)},onKeyDown:e=>{if(T&&e.key===`Escape`)e.preventDefault(),e.stopPropagation(),p(!0);else if(T&&D&&!O&&e.key===`Tab`&&!e.shiftKey)e.preventDefault(),c.current?.focus();else{if(T&&!O&&!D&&k.length){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),x((A+(e.key===`ArrowDown`?1:-1)+k.length)%k.length);return}if((e.key===`Enter`||e.key===`Tab`)&&!e.nativeEvent.isComposing&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey){e.preventDefault();let t=k[A];t&&j(t);return}}n?.(e)}}}),E&&a?.copy.limit?(0,U.jsx)(`span`,{role:`alert`,children:a.copy.limit}):null,T&&a?(0,tt.createPortal)((0,U.jsx)(`div`,{ref:s,id:l,className:`mention-input__suggestions`,style:S,onBlur:e=>{e.relatedTarget!==o.current&&!e.currentTarget.contains(e.relatedTarget)&&p(!0)},onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),p(!0),o.current?.focus()):e.key===`Tab`&&e.shiftKey&&(e.preventDefault(),o.current?.focus())},children:O?(0,U.jsx)(`span`,{role:`status`,children:a.copy.loading}):D?(0,U.jsxs)(`div`,{role:`alert`,children:[a.copy.error,` `,(0,U.jsx)(`button`,{ref:c,type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{y(v+1),o.current?.focus()},children:a.copy.retry})]}):(0,U.jsxs)(`ul`,{role:`listbox`,"aria-label":a.copy.suggestions,children:[k.map((e,t)=>(0,U.jsx)(`li`,{id:`${l}-${t}`,role:`option`,"aria-selected":t===A,children:(0,U.jsxs)(`button`,{type:`button`,tabIndex:-1,onMouseDown:e=>e.preventDefault(),onClick:()=>j(e),children:[`@`,e.login]})},e.githubId)),k.length?null:(0,U.jsx)(`li`,{role:`presentation`,children:a.copy.empty})]})}),document.body):null]})}function fn({anchorPoint:e,anchorRectangle:t,anchorSelector:n,layoutKey:r,preserveVerticalSide:i=!1}){let a=(0,V.useRef)(null),o=(0,V.useRef)(null),[s,c]=(0,V.useState)({left:e.x+12,top:e.y+12}),l=(0,V.useCallback)(()=>{let r=a.current,s=r?.parentElement;if(!r||!s)return;let l=r.offsetWidth,u=r.offsetHeight,d=s.clientWidth-l-8,f=s.clientHeight-u-8,p,m,h=(n?s.querySelector(n)??s.parentElement?.querySelector(n):null)?.getBoundingClientRect(),g=s.getBoundingClientRect(),_=h?{x:h.left-g.left,y:h.top-g.top,width:h.height,height:h.height}:t;if(_){let e=_.x+_.width+12,t=_.x-12-l,n=e+l<=s.clientWidth-8,r=t>=8,i=s.clientWidth-8-_.x-_.width,a=_.x-8;p=n?e:r?t:i>=a?e:t,m=_.y}else{let t=e.x+12,n=e.y+12;p=t+l<=s.clientWidth-8?t:e.x-12-l;let r=o.current,a=i&&r?.x===e.x&&r.y===e.y?r.side:n+u<=s.clientHeight-8?`below`:`above`;i&&(o.current={x:e.x,y:e.y,side:a}),m=a===`below`?n:e.y-12-u}let v={left:Math.max(8,Math.min(p,d)),top:Math.max(8,Math.min(m,f))};c(e=>e.left===v.left&&e.top===v.top?e:v)},[e,t,n,i]);return(0,V.useLayoutEffect)(()=>{l();let e=a.current,t=e?.parentElement;if(!e||!t||typeof ResizeObserver!=`function`)return;let r=new ResizeObserver(l);r.observe(e),r.observe(t);let i=n?t.querySelector(n)??t.parentElement?.querySelector(n):null;return i&&r.observe(i),window.addEventListener(`resize`,l),()=>{r.disconnect(),window.removeEventListener(`resize`,l)}},[n,r,l]),{cardRef:a,position:s}}function pn(){return typeof navigator<`u`&&/Mac/i.test(navigator.platform)}function mn(e,{allowPlainEnter:t=!1}={}){let n=e.isComposing||e.keyCode===229,r=pn()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey,i=t&&!e.metaKey&&!e.ctrlKey;return e.key===`Enter`&&!e.shiftKey&&!e.altKey&&!n&&!e.repeat&&(r||i)}var hn=new TextEncoder;function gn({anchorPoint:e,bodyMaximumBytes:t,copy:n,creating:r,onSubmit:i,onDiscard:a}){let o=(0,V.useId)(),[s,c]=(0,V.useState)(``),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(!1),p=(0,V.useRef)(!1),{cardRef:m,position:h}=fn({anchorPoint:e,layoutKey:`${l}:${d}`,preserveVerticalSide:!0}),g=hn.encode(s).length>t,_=s.trim()!==``&&!g&&!r&&!l,v=pn()?n.submitTooltipMacLabel:n.submitTooltipOtherLabel;(0,V.useEffect)(()=>{l?m.current?.querySelector(`.review-confirmation-panel__cancel`)?.focus({preventScroll:!0}):p.current&&m.current?.querySelector(`textarea`)?.focus({preventScroll:!0}),p.current=l},[m,l]);function y(){r||(s.trim()===``?a():u(!0))}async function b(e){e.preventDefault(),_&&(await i(s)||f(!0))}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-hidden":`true`,className:`review-comment-composer-backdrop`,onClick:y}),(0,U.jsx)(`section`,{ref:m,role:`dialog`,"aria-labelledby":o,className:`review-comment-composer`,style:{left:h.left,top:h.top},children:(0,U.jsxs)(`form`,{className:`review-comment-composer__form`,onSubmit:e=>{b(e)},onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),l?u(!1):y())},children:[(0,U.jsxs)(`header`,{className:`review-comment-composer__header`,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`6`,id:o,children:n.composerHeading}),(0,U.jsx)(W,{icon:B,"aria-label":n.closeComposerLabel,description:n.closeComposerLabel,variant:`invisible`,type:`button`,disabled:r,onClick:y})]}),(0,U.jsx)(dn,{autoFocus:!0,"aria-label":n.composerLabel,placeholder:n.composerPlaceholder,value:s,rows:4,onValueChange:e=>{c(e),u(!1),f(!1)},onKeyDown:e=>{_&&mn(e.nativeEvent)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),g?(0,U.jsx)(`span`,{role:`alert`,className:`review-comment-composer__error`,children:n.bodyTooLongLabel}):null,d?(0,U.jsx)(me,{variant:`critical`,title:n.createErrorLabel,className:`review-comment-composer__banner`}):null,l?(0,U.jsx)(cn,{heading:n.discardHeading,description:n.discardPromptLabel,cancelLabel:n.keepLabel,confirmLabel:n.discardButtonLabel,condensed:!0,onCancel:()=>u(!1),onConfirm:a}):(0,U.jsxs)(`footer`,{className:`review-comment-composer__actions`,children:[(0,U.jsx)(H.Button,{type:`button`,size:`small`,disabled:r,onClick:y,children:n.closeComposerLabel}),(0,U.jsx)(H.Tooltip,{text:v,type:`description`,children:(0,U.jsx)(H.Button,{type:`submit`,size:`small`,variant:`primary`,disabled:!_,"aria-busy":r,children:n.submitLabel})}),r?(0,U.jsx)(le,{role:`status`,children:n.submittingLabel}):null]})]})})]})}function _n({blockedLabel:e,confirmingDiscard:t,replyDraft:n,replyBodyTooLong:r,replyFailed:i,replyDisabled:a,replying:o,copy:s,onKeepDraft:c,onDiscardDraft:l,onSubmit:u,onDraftChange:d}){let f=(0,V.useRef)(null),p=n.trim()!==``&&!r&&!a&&!o&&!t&&!e,m=pn()?s.replySubmitTooltipMacLabel:s.replySubmitTooltipOtherLabel;return(0,V.useLayoutEffect)(()=>{f.current&&(f.current.style.height=`auto`,f.current.style.height=n?`${Math.min(f.current.scrollHeight,120)}px`:`2.5rem`)},[n]),t?(0,U.jsx)(cn,{heading:s.discardHeading,description:s.threadDiscardPromptLabel,cancelLabel:s.keepLabel,confirmLabel:s.discardButtonLabel,compact:!0,onCancel:c,onConfirm:l}):e?(0,U.jsx)(`span`,{className:`review-thread-reply-form__blocked`,children:e}):(0,U.jsxs)(`form`,{className:`review-thread-reply-form`,onSubmit:e=>{e.preventDefault(),p&&u()},children:[(0,U.jsxs)(`div`,{className:`review-thread-reply-form__composer`,children:[(0,U.jsx)(dn,{ref:f,"aria-label":s.replyLabel,placeholder:s.replyPlaceholder,value:n,rows:1,disabled:a,onValueChange:d,onKeyDown:e=>{p&&mn(e.nativeEvent,{allowPlainEnter:!0})&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,U.jsx)(H.Tooltip,{text:m,type:`description`,children:(0,U.jsx)(`button`,{type:`submit`,className:`review-thread-reply-form__submit`,disabled:!p,"aria-label":s.replySubmitLabel,"aria-busy":o,children:(0,U.jsx)(_,{size:16})})})]}),r?(0,U.jsx)(`span`,{role:`alert`,className:`review-thread-reply-form__error`,children:s.bodyTooLongLabel}):null,i?(0,U.jsx)(`span`,{role:`alert`,className:`review-thread-reply-form__error`,children:s.replyErrorLabel}):null,o?(0,U.jsx)(le,{role:`status`,children:s.replyingLabel}):null]})}function vn({comment:e}){let t=e.body??``,n=new Set(e.mentions?.map(e=>e.login.toLowerCase())??[]),r=t.matchAll(/(?({content:e,emoji:bn(e)}));function Sn(e,t=0,n=0){if(t!==0||n!==0)return{x:t,y:n};let r=e.getBoundingClientRect();return{x:r.left+r.width/2,y:r.top+r.height/2}}function Cn({comment:e,mutation:t,actionsDisabled:n,controlsHidden:r=!1,copy:i,onAdd:a,onRemove:o,onBurst:s}){let c=(0,V.useId)(),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(!1),p=(0,V.useRef)(!1),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(`outside-bottom`),v=t!==null&&(t.kind===`add-reaction`||t.kind===`remove-reaction`)&&t.commentId===e.id,y=e.reactions.flatMap(e=>{if(!m||e.content!==m.content)return[e];let t=e.count+Number(m.viewerHasReacted)-Number(e.viewerHasReacted);return t>0?[{...e,count:t,viewerHasReacted:m.viewerHasReacted}]:[]});m?.viewerHasReacted&&!e.reactions.some(({content:e})=>e===m.content)&&y.push({content:m.content,count:1,viewerHasReacted:!0});async function b(r,i){if(n||t!==null||p.current)return;let c=e.reactions.find(e=>e.content===r)?.viewerHasReacted??!1;p.current=!0,u(!1),h({content:r,viewerHasReacted:!c});try{if(!c){let e=xn.find(e=>e.content===r);e&&s(e.emoji,i.x,i.y)}let e=c?await o(r):await a(r);u(!e)}catch{u(!0)}finally{p.current=!1,h(null)}}function x(e,t){b(e,Sn(t.currentTarget,t.clientX,t.clientY))}let S=(0,U.jsxs)(H.ActionMenu,{selectionVariant:`none`,size:`small`,menuAlignment:`end`,menuSide:g,disabled:n,children:[(0,U.jsx)(H.ActionMenu.Button,{className:`review-comment-reactions__menu-trigger`,variant:`subtle`,"aria-label":i.addReactionLabel,"aria-describedby":c,"aria-busy":v||m!==null,leadingVisual:(0,U.jsx)(k,{size:16}),onClick:e=>{f(!0);let t=e.currentTarget.getBoundingClientRect(),n=e.currentTarget.closest(`.review-shell`)?.getBoundingClientRect(),r=Math.min(window.innerHeight,n?.bottom??1/0)-t.bottom,i=t.top-Math.max(0,n?.top??0),a=xn.length*36+16;_(rr?`outside-top`:`outside-bottom`)},children:``}),(0,U.jsx)(H.ActionMenu.Overlay,{"aria-label":i.addReactionLabel,children:xn.map(e=>(0,U.jsx)(H.ActionMenu.Item,{value:e.content,leadingVisual:(0,U.jsx)(`span`,{className:`review-comment-reactions__picker-emoji`,children:e.emoji}),onClick:t=>x(e.content,t),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),b(e.content,Sn(t.currentTarget)))},children:i.reactionLabels[e.content]},e.content))})]});return r&&!l?null:(0,U.jsxs)(`div`,{className:`review-comment-reactions__layout`,children:[r?null:(0,U.jsxs)(`div`,{className:`review-comment-reactions`,children:[y.map(e=>{let r=xn.find(({content:t})=>t===e.content);if(!r)return null;let a=(e.count===1?i.reactionCountOneLabel:i.reactionCountOtherLabel).replace(`%{reaction}`,i.reactionLabels[e.content]).replace(`%{count}`,e.count.toString());return(0,U.jsxs)(H.Button,{size:`small`,"aria-label":a,title:a,"aria-pressed":e.viewerHasReacted,disabled:n,"aria-busy":m?.content===e.content||v&&`content`in t&&t.content===e.content,className:e.viewerHasReacted?`review-comment-reaction--selected`:void 0,onClick:t=>x(e.content,t),children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,children:r.emoji}),(0,U.jsx)(nt,{"aria-hidden":`true`,children:e.count})]},e.content)}),n?(0,U.jsxs)(`div`,{title:i.addReactionLabel,children:[S,(0,U.jsx)(le,{id:c,children:i.addReactionLabel})]}):(0,U.jsx)(H.Tooltip,{id:c,text:i.addReactionLabel,type:`description`,className:`review-comment-reactions__tooltip${d?` review-comment-reactions__tooltip--suppressed`:``}`,children:(0,U.jsx)(`div`,{onMouseEnter:e=>{e.currentTarget.querySelector(`[aria-expanded="true"]`)||f(!1)},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||f(!1)},children:S})})]}),l?(0,U.jsx)(`span`,{role:`alert`,className:`review-comment-reactions__error`,children:i.reactionErrorLabel}):null]})}function wn({comment:e,mutation:t,copy:n,editing:r,editDraft:i,editBodyTooLong:a,editFailed:o,confirmingEditDiscard:s,saving:c,confirmingDelete:l,deleting:u,deleteFailed:d,actionsDisabled:f,onStartEdit:p,onEditDraftChange:m,onSaveEdit:h,onCancelEdit:g,onKeepEdit:_,onDiscardEdit:v,onRequestDelete:y,onCancelDelete:b,onDelete:x,onAddReaction:S,onRemoveReaction:C,onBurstReaction:w,onMarkUnread:T,markUnreadDisabled:E=!1}){let D=(0,V.useId)(),k=(0,V.useRef)(null),A=(0,V.useRef)(!1),[j,M]=(0,V.useState)(`outside-bottom`),N=e.author.name||`@${e.author.login}`,P=n.commentActionsLabel.replace(`%{author}`,`@${e.author.login}`),F=f&&(!T||E),I=!!(e.body&&e.viewerCanEdit),L=!!(e.body&&e.viewerCanDelete);return(0,V.useEffect)(()=>{s?k.current?.querySelector(`.review-confirmation-panel button`)?.focus({preventScroll:!0}):A.current&&k.current?.querySelector(`textarea`)?.focus({preventScroll:!0}),A.current=s},[s]),(0,U.jsxs)(`article`,{className:`review-thread-message`,"data-review-message-id":e.id,children:[(0,U.jsxs)(`div`,{className:`review-thread-message__header`,children:[(0,U.jsx)(ot,{src:e.author.avatarUrl,size:28}),(0,U.jsxs)(`span`,{className:`review-thread-message__byline`,children:[(0,U.jsx)(`strong`,{className:`review-thread-message__identity`,children:N}),(0,U.jsx)(ht,{value:e.createdAt}),e.editedAt?(0,U.jsx)(`span`,{children:n.editedLabel}):null]}),T||I||L?F?(0,U.jsxs)(`div`,{title:P,children:[(0,U.jsx)(H.ActionMenu,{selectionVariant:`none`,size:`small`,menuAlignment:`end`,disabled:!0,children:(0,U.jsx)(H.ActionMenu.Button,{className:`review-thread-message__menu-trigger`,variant:`subtle`,"aria-label":P,"aria-describedby":D,leadingVisual:(0,U.jsx)(re,{size:16}),children:``})}),(0,U.jsx)(le,{id:D,children:P})]}):(0,U.jsx)(H.Tooltip,{id:D,text:P,type:`description`,children:(0,U.jsx)(`div`,{children:(0,U.jsxs)(H.ActionMenu,{selectionVariant:`none`,size:`small`,menuAlignment:`end`,menuSide:j,children:[(0,U.jsx)(H.ActionMenu.Button,{className:`review-thread-message__menu-trigger`,variant:`subtle`,"aria-label":P,"aria-describedby":D,leadingVisual:(0,U.jsx)(re,{size:16}),onClick:e=>{let t=e.currentTarget.getBoundingClientRect(),n=e.currentTarget.closest(`.review-shell`)?.getBoundingClientRect(),r=Math.min(window.innerHeight,n?.bottom??1/0)-t.bottom,i=t.top-Math.max(0,n?.top??0);M(r<(T?128:88)&&i>r?`outside-top`:`outside-bottom`)},children:``}),(0,U.jsxs)(H.ActionMenu.Overlay,{"aria-label":P,children:[T?(0,U.jsx)(H.ActionMenu.Item,{value:`mark-unread`,disabled:E,leadingVisual:(0,U.jsx)(ee,{size:16}),onClick:()=>{E||T()},onKeyDown:e=>{!E&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),T())},children:n.markUnreadLabel}):null,I?(0,U.jsx)(H.ActionMenu.Item,{value:`edit`,disabled:f,leadingVisual:(0,U.jsx)(ae,{size:16}),onClick:p,onKeyDown:e=>{!f&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),p())},children:n.editLabel}):null,L&&(T||I)?(0,U.jsx)(`li`,{role:`separator`,className:`review-thread-message__menu-divider`}):null,L?(0,U.jsx)(H.ActionMenu.Item,{value:`delete`,disabled:f||t!==null,className:`review-thread-message__delete-item`,leadingVisual:(0,U.jsx)(O,{size:16}),onClick:y,onKeyDown:e=>{!f&&t===null&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),y())},children:n.deleteLabel}):null]})]})})}):null]}),r?(0,U.jsxs)(`form`,{ref:k,className:`review-thread-message__edit`,onSubmit:e=>{e.preventDefault(),s||h()},children:[(0,U.jsx)(dn,{autoFocus:!0,"aria-label":n.editCommentLabel,value:i,rows:3,onValueChange:m}),a?(0,U.jsx)(`span`,{role:`alert`,className:`review-thread-message__error`,children:n.bodyTooLongLabel}):null,o?(0,U.jsx)(`span`,{role:`alert`,className:`review-thread-message__error`,children:n.editErrorLabel}):null,s?(0,U.jsx)(cn,{heading:n.discardHeading,description:n.threadDiscardPromptLabel,cancelLabel:n.keepLabel,confirmLabel:n.discardButtonLabel,compact:!0,onCancel:_,onConfirm:v}):(0,U.jsxs)(`div`,{className:`review-thread-message__actions`,children:[(0,U.jsx)(H.Button,{type:`button`,size:`small`,disabled:c,onClick:g,children:n.cancelEditLabel}),(0,U.jsx)(H.Button,{type:`submit`,size:`small`,variant:`primary`,disabled:i.trim()===``||a||t!==null||c,"aria-busy":c,children:n.saveEditLabel}),c?(0,U.jsx)(le,{role:`status`,children:n.savingEditLabel}):null]})]}):l?(0,U.jsx)(cn,{heading:n.deleteHeading,description:n.deletePromptLabel,errorLabel:d?n.deleteErrorLabel:void 0,cancelLabel:n.cancelEditLabel,confirmLabel:n.confirmDeleteLabel,loading:u,loadingAnnouncement:n.deletingLabel,compact:!0,onCancel:b,onConfirm:x}):(0,U.jsx)(`p`,{className:e.body?`review-thread-message__body`:`review-thread-message__body review-thread-message__body--deleted`,children:e.body?(0,U.jsx)(vn,{comment:e}):n.deletedCommentLabel}),e.body?(0,U.jsx)(Cn,{comment:e,mutation:t,actionsDisabled:f,controlsHidden:r||l,copy:n,onAdd:S,onRemove:C,onBurst:w}):null]})}function Tn(){let e=(0,V.useRef)(null),t=(0,V.useRef)([]),n=(0,V.useRef)(new Map),[r,i]=(0,V.useState)(!1),a=(0,V.useCallback)((e,n,r)=>{if(window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches)return;let a=4+Math.floor(Math.random()*5),o=performance.now();for(let i=0;i{if(!r)return;let a=e.current,o=a?.getContext(`2d`);if(!a||!o){console.error(`Emoji reaction burst could not create a canvas context.`),t.current=[];let e=requestAnimationFrame(()=>i(!1));return()=>cancelAnimationFrame(e)}let s=a,c=o,l;function u(){let e=window.devicePixelRatio||1;s.width=Math.round(window.innerWidth*e),s.height=Math.round(window.innerHeight*e),c.setTransform(e,0,0,e,0,0)}function d(e,t){let r=Math.round(t),i=`${e}_${r}`;if(n.current.has(i))return n.current.get(i)??null;let a=document.createElement(`canvas`);a.width=r*2,a.height=r*2;let o=a.getContext(`2d`);return o?(o.font=`${r}px serif`,o.textAlign=`center`,o.textBaseline=`middle`,o.fillText(e,r,r),n.current.set(i,a),a):(console.error(`Emoji reaction burst could not draw an emoji.`),n.current.set(i,null),null)}function f(e){c.clearRect(0,0,window.innerWidth,window.innerHeight);let n=[];for(let r of t.current){if(e10&&(r.opacity-=.04),r.opacity<=0)continue;let t=d(r.emoji,r.size);t&&(c.globalAlpha=r.opacity,c.drawImage(t,r.x-t.width/2,r.y-t.height/2)),n.push(r)}c.globalAlpha=1,t.current=n,n.length>0?l=requestAnimationFrame(f):i(!1)}return u(),window.addEventListener(`resize`,u),l=requestAnimationFrame(f),()=>{cancelAnimationFrame(l),window.removeEventListener(`resize`,u)}},[r]),{burst:a,canvas:r?(0,tt.createPortal)((0,U.jsx)(`canvas`,{ref:e,className:`review-emoji-burst`,"aria-hidden":`true`}),document.body):null}}var En=new TextEncoder;function Dn({thread:e,bodyMaximumBytes:t,mutation:n,onClose:r,onDraftStateChange:i,onReply:a,onEdit:o,onDelete:s,onResolve:c,onReopen:l}){let[u,d]=(0,V.useState)(``),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(``),[v,y]=(0,V.useState)(``),[b,x]=(0,V.useState)(!1),[S,C]=(0,V.useState)(!1),[w,T]=(0,V.useState)(null),[E,D]=(0,V.useState)(!1),[O,k]=(0,V.useState)(!1),[A,j]=(0,V.useState)(!1),M=u.trim()!==``||m!==null,ee=En.encode(u).length>t,N=En.encode(g).length>t,P=e.root.resolvedAt!==null,F=e.root.deletedAt!==null||P;(0,V.useEffect)(()=>(i(M),()=>i(!1)),[M,i]);function I(){n||(u.trim()===``&&g===v?r():(C(!1),j(!0)))}function L(){d(``),h(null),_(``),y(``),C(!1),j(!1),i(!1),r()}async function R(){u.trim()===``||ee||n||(await a(u)?(d(``),p(!1)):p(!0))}function z(e){d(e),p(!1),j(!1)}function te(e){e.body&&(h(e.id),_(e.body),y(e.body),x(!1),T(null),D(!1))}function B(e){_(e),x(!1),C(!1),j(!1)}async function ne(e){g.trim()===``||N||n||(await o(e,g)?(h(null),_(``),y(``),C(!1),x(!1)):x(!0))}function re(){g===v?ie():C(!0)}function ie(){h(null),_(``),y(``),x(!1),C(!1),j(!1)}function ae(e){T(e),D(!1)}function oe(){T(null),D(!1)}async function se(e){n||(await s(e)?oe():D(!0))}async function H(){if(n||M)return;let e=P?await l():await c();k(!e)}return{state:{replyDraft:u,replyFailed:f,editingCommentId:m,editDraft:g,editFailed:b,confirmingEditDiscard:S,confirmingDeleteId:w,deleteFailed:E,resolutionFailed:O,confirmingDiscard:A,draftActive:M,replyBodyTooLong:ee,editBodyTooLong:N,resolved:P,replyBlocked:F},actions:{requestDismissal:I,discardAndClose:L,keepDraft:()=>j(!1),submitReply:R,changeReplyDraft:z,startEdit:te,changeEditDraft:B,saveEdit:ne,cancelEdit:re,keepEdit:()=>C(!1),discardEdit:ie,requestDelete:ae,cancelDelete:oe,deleteComment:se,changeResolution:H}}}function On(e){let t=e.closest(`[data-testid="ActionMenu"]`);if(!t)return;let n=e.getBoundingClientRect(),r=e.closest(`.review-shell`)?.getBoundingClientRect(),i=Math.max(0,r?.top??0),a=Math.min(window.innerHeight,r?.bottom??window.innerHeight);t.style.setProperty(`--review-thread-menu-room-top`,`${Math.max(0,n.top-i-8)}px`),t.style.setProperty(`--review-thread-menu-room-bottom`,`${Math.max(0,a-n.bottom-8)}px`)}function kn({thread:e,anchorPoint:t,bodyMaximumBytes:n,mutation:r,copy:i,onClose:a,onDraftStateChange:o,onReply:s,onEdit:c,onDelete:l,onResolve:u,onReopen:d,onAddReaction:f,onRemoveReaction:p,onMarkRead:m,onMarkUnread:h}){let g=(0,V.useId)(),_=(0,V.useRef)(null),v=(0,V.useRef)(0),y=(0,V.useRef)(e.root.activityVersion),b=(0,V.useRef)(null),x=(0,V.useRef)(!1),S=(0,V.useRef)(!1),C=(0,V.useRef)(!1),[w,T]=(0,V.useState)(!1),[E,D]=(0,V.useState)(!1),[O,k]=(0,V.useState)(!1),[A,j]=(0,V.useState)(!1),{burst:M,canvas:ee}=Tn(),{state:N,actions:P}=Dn({thread:e,bodyMaximumBytes:n,mutation:r,onClose:a,onDraftStateChange:o,onReply:s,onEdit:c,onDelete:l,onResolve:u,onReopen:d}),F={x:12,y:12},I=[e.root,...e.replies],{cardRef:L,position:R}=fn({anchorPoint:t??F,...t?{anchorSelector:`[data-review-thread-id="${e.root.id}"]`,anchorRectangle:{x:t.x-16,y:t.y-16,width:32,height:32}}:{},layoutKey:[N.confirmingDiscard,N.confirmingEditDiscard,N.replyFailed,N.editFailed,N.deleteFailed,N.resolutionFailed,N.editingCommentId,N.confirmingDeleteId,N.resolved,w,O,e.replies.length,e.participants.length,I.map(e=>e.reactions.length).join(`,`)].join(`:`)}),z={"--review-thread-left":`${R.left}px`,"--review-thread-top":`${R.top}px`},te=N.replyBlocked?e.root.deletedAt?i.deletedReplyBlockedLabel:e.root.resolvedBy?i.resolvedByLabel.replace(`%{author}`,e.root.resolvedBy.name||`@${e.root.resolvedBy.login}`):i.resolvedReplyBlockedLabel:null,ne=(0,V.useCallback)(()=>{L.current?.querySelector(`.review-thread-conversation__close`)?.focus({preventScroll:!0})},[L]);(0,V.useEffect)(()=>{if(N.confirmingDiscard)L.current?.querySelector(`.review-thread-conversation__footer button`)?.focus({preventScroll:!0});else if(C.current){let e=N.editingCommentId===null?`.review-thread-reply-form textarea`:`.review-thread-message__edit textarea`;L.current?.querySelector(e)?.focus({preventScroll:!0})}C.current=N.confirmingDiscard},[L,N.confirmingDiscard,N.editingCommentId]),(0,V.useEffect)(()=>{let e=document.activeElement;return _.current=e instanceof HTMLElement?e:null,ne(),()=>{_.current?.isConnected&&_.current.focus()}},[ne]),(0,V.useEffect)(()=>{let t=y.current;e.unread&&b.current!==t&&(b.current=t,x.current=!0,D(!0),m(t).then(e=>T(!e)).catch(()=>T(!0)).finally(()=>{x.current=!1,D(!1)}))},[m,e.unread]);async function re(){if(!(x.current||S.current||r!==null)){b.current=y.current,S.current=!0,j(!0),k(!1);try{let e=await h();k(!e),e&&T(!1)}catch{k(!0)}finally{S.current=!1,j(!1)}}}return(0,V.useEffect)(()=>{function e(){N.confirmingDiscard?P.keepDraft():N.confirmingEditDiscard?P.keepEdit():P.requestDismissal()}function t(t){t.key!==`Escape`||t.defaultPrevented||t.isComposing||L.current?.querySelector(`[role="menu"]`)||t.target instanceof Element&&t.target.closest(`[role="menu"], [role="dialog"], dialog`)||(t.preventDefault(),e())}function n(){let t=document.activeElement;L.current?.querySelector(`[role="menu"]`)||t instanceof Element&&(t.closest(`[role="menu"]`)||t.closest(`[role="dialog"], dialog`)&&!L.current?.contains(t))||e()}return document.addEventListener(`keydown`,t),window.addEventListener(`replica:review-dismiss`,n),()=>{document.removeEventListener(`keydown`,t),window.removeEventListener(`replica:review-dismiss`,n)}},[P,L,N.confirmingDiscard,N.confirmingEditDiscard]),(0,U.jsxs)(`section`,{ref:L,role:`dialog`,"aria-labelledby":g,className:`review-thread-conversation${t?` review-thread-conversation--anchored`:` review-thread-conversation--docked`}`,style:z,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||e.nativeEvent.isComposing||e.target instanceof Element&&e.target.closest(`[role="menu"]`)||(e.preventDefault(),N.confirmingDiscard?P.keepDraft():N.confirmingEditDiscard?P.keepEdit():P.requestDismissal())},children:[(0,U.jsxs)(`div`,{className:`review-thread-conversation__layout`,children:[(0,U.jsxs)(`header`,{className:`review-thread-conversation__header`,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`6`,id:g,children:i.threadHeading}),(0,U.jsx)(H.Button,{size:`small`,disabled:N.draftActive||r!==null,"aria-busy":r!==null&&`commentId`in r&&r.commentId===e.root.id&&(r.kind===`resolve`||r.kind===`reopen`),onClick:()=>{P.changeResolution()},children:N.resolved?i.reopenLabel:i.resolveLabel}),r&&`commentId`in r&&r.commentId===e.root.id&&(r.kind===`resolve`||r.kind===`reopen`)?(0,U.jsx)(le,{role:`status`,children:N.resolved?i.reopeningLabel:i.resolvingLabel}):null,(0,U.jsx)(W,{icon:B,"aria-label":i.backToCommentsLabel,title:i.backToCommentsLabel,variant:`invisible`,className:`review-thread-conversation__close`,onClick:P.requestDismissal})]}),N.resolutionFailed?(0,U.jsx)(me,{variant:`critical`,title:i.resolutionErrorLabel,className:`review-thread-conversation__banner`}):null,w?(0,U.jsx)(me,{variant:`critical`,title:i.readErrorLabel,className:`review-thread-conversation__banner`}):null,O?(0,U.jsx)(me,{variant:`critical`,title:i.markUnreadErrorLabel,className:`review-thread-conversation__banner`}):null,(0,U.jsx)(`div`,{className:`review-thread-conversation__messages`,onClickCapture:e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`button[data-testid="ActionMenu-button"]`);t&&e.currentTarget.contains(t)&&(v.current=e.currentTarget.scrollTop,On(t))},onScroll:e=>{let t=e.currentTarget.scrollTop,n=t-v.current;if(v.current=t,n===0)return;let r=e.currentTarget.getBoundingClientRect();e.currentTarget.querySelectorAll(`[role="menu"]`).forEach(e=>{let t=e.closest(`[data-testid="ActionMenu"]`)?.querySelector(`button[data-testid="ActionMenu-button"]`);if(!t)return;let i=t.getBoundingClientRect();if(r.height>0&&(i.bottom<=r.top||i.top>=r.bottom)){let n=e.contains(document.activeElement);t.click(),n&&ne();return}let a=Number.parseFloat(e.style.top);Number.isFinite(a)&&(e.style.top=`${a-n}px`),On(t)})},children:I.map(e=>(0,U.jsx)(wn,{comment:e,mutation:r,copy:i,editing:N.editingCommentId===e.id,editDraft:N.editingCommentId===e.id?N.editDraft:``,editBodyTooLong:N.editingCommentId===e.id&&N.editBodyTooLong,editFailed:N.editingCommentId===e.id&&N.editFailed,confirmingEditDiscard:N.editingCommentId===e.id&&N.confirmingEditDiscard,saving:r?.kind===`edit`&&r.commentId===e.id,confirmingDelete:N.confirmingDeleteId===e.id,deleting:r?.kind===`delete`&&r.commentId===e.id,deleteFailed:N.confirmingDeleteId===e.id&&N.deleteFailed,actionsDisabled:r!==null&&r.kind!==`add-reaction`&&r.kind!==`remove-reaction`||N.confirmingDiscard||N.confirmingDeleteId!==null||N.replyDraft.trim()!==``||N.editingCommentId!==null&&N.editingCommentId!==e.id,onStartEdit:()=>P.startEdit(e),onEditDraftChange:P.changeEditDraft,onSaveEdit:()=>{P.saveEdit(e.id)},onCancelEdit:P.cancelEdit,onKeepEdit:P.keepEdit,onDiscardEdit:P.discardEdit,onRequestDelete:()=>P.requestDelete(e.id),onCancelDelete:P.cancelDelete,onDelete:()=>{P.deleteComment(e.id)},onAddReaction:t=>f(e.id,t),onRemoveReaction:t=>p(e.id,t),onBurstReaction:M,onMarkUnread:e.kind===`root`?()=>void re():void 0,markUnreadDisabled:E||A||r!==null},e.id))}),(0,U.jsx)(`div`,{className:`review-thread-conversation__footer${te&&!N.confirmingDiscard?` review-thread-conversation__footer--blocked`:``}`,children:(0,U.jsx)(_n,{blockedLabel:te,confirmingDiscard:N.confirmingDiscard,replyDraft:N.replyDraft,replyBodyTooLong:N.replyBodyTooLong,replyFailed:N.replyFailed,replyDisabled:r!==null||N.editingCommentId!==null,replying:r?.kind===`reply`&&r.commentId===e.root.id,copy:i,onKeepDraft:P.keepDraft,onDiscardDraft:P.discardAndClose,onSubmit:()=>{P.submitReply()},onDraftChange:P.changeReplyDraft})})]}),ee]})}function An({selectionNotice:e,rateLimitNotice:t,composer:n,conversation:r}){return(0,U.jsxs)(U.Fragment,{children:[e||t?(0,U.jsxs)(`div`,{className:`canvas-selection-notice`,role:`alert`,children:[e?(0,U.jsx)(`div`,{children:e}):null,t?(0,U.jsx)(`div`,{children:t}):null]}):null,n?(0,U.jsx)(`div`,{className:`canvas-composer-shell`,children:(0,U.jsx)(gn,{...n})}):null,r?(0,U.jsx)(`div`,{className:`canvas-conversation-shell`,children:(0,U.jsx)(kn,{...r},r.thread.root.id)}):null]})}function jn({identity:e,enabled:t,ready:n,bridgeProblem:r,token:i}){let[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(!1),p=(0,V.useRef)(e);(0,V.useLayoutEffect)(()=>(p.current=e,()=>{p.current=``}),[e]),(0,V.useEffect)(()=>{let e=window.setTimeout(()=>{o(``),c(!1),u(!1),f(!1)},0);return()=>{window.clearTimeout(e)}},[e,t]);async function m(){let t=e;o(``),c(!0);try{await $(`/api/commenting/fix`,i,{method:`POST`}),p.current===t&&f(!0)}catch(e){p.current===t&&o(e instanceof Error?e.message:String(e))}finally{p.current===t&&c(!1)}}return{visible:t&&!n&&!l&&!!r,error:a,busy:s,requested:d,onFix:()=>void m(),onDismiss:()=>u(!0)}}function Mn({preference:e,disabled:t=!1}){let n=(0,V.useId)(),r=(0,V.useId)(),i=(0,V.useId)(),a=(0,V.useId)();return(0,U.jsxs)(`section`,{className:`canvas-hub-section`,"aria-labelledby":n,children:[(0,U.jsx)(H.Heading,{as:`h3`,size:`subhead-medium`,id:n,children:K.settings}),(0,U.jsxs)(`div`,{className:`canvas-publish-settings__option`,children:[(0,U.jsx)(`label`,{id:r,htmlFor:i,children:K.alwaysCommit}),(0,U.jsx)(Z,{className:`canvas-publish-settings__toggle`,id:i,"aria-labelledby":r,"aria-describedby":e.error?a:void 0,checked:e.remember===!0,disabled:e.loading||e.remember===null,"aria-disabled":e.saving||t||void 0,onChange:n=>{!e.saving&&!t&&e.save(n)},size:`small`})]}),e.error?(0,U.jsxs)(`div`,{id:a,className:`canvas-publish-settings__error`,children:[(0,U.jsx)(me,{title:e.error,variant:`critical`,layout:`compact`}),(0,U.jsx)(H.Button,{size:`small`,disabled:e.loading||e.saving,onClick:()=>void e.retry(),children:K.retrySettings})]}):null]})}function Nn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pn(e){return!Nn(e)||typeof e.pathname!=`string`||typeof e.search!=`string`||typeof e.hash!=`string`?null:{pathname:e.pathname,search:e.search,hash:e.hash}}function Fn({config:e,frameRef:t,onRouteChange:n,status:r,onStatusChange:i,onSelectHub:o,onConnect:s,onDisconnected:c,connectionButtonRef:l,connecting:u=!1,publication:d,publicationBusy:f=!1,dirty:p=!1,onPublish:m,onRetryPublication:h,publishPreference:g,open:_,onClose:v}){let[y,b]=(0,V.useState)({identity:``,items:[]}),x=r?.prototype?.repositoryId,S=r?.prototype?.id,C=r?.state===`connected`,w=r?.hubOrigin,T=(0,V.useMemo)(()=>({load:async()=>{if(!C||!w)throw Error(G.mentionSuggestionsError);return on.parse(await $(`/api/hub/mention-candidates?repositoryId=${x}&prototypeId=${S}`,e.token)).candidates},copy:{suggestions:G.mentionSuggestions,error:G.mentionSuggestionsError,loading:G.mentionSuggestionsLoading,empty:G.mentionSuggestionsEmpty,retry:bt.retryLabel,limit:G.mentionLimit}}),[e.token,C,w,x,S]),[E,D]=(0,V.useState)(!1),[O,k]=(0,V.useState)(yt),[A,j]=(0,V.useState)(!0),[M,ee]=(0,V.useState)(null),[N,P]=(0,V.useState)(null),[F,I]=(0,V.useState)(``),[R,z]=(0,V.useState)(``),[te,B]=(0,V.useState)(``),[ne,re]=(0,V.useState)(!1),[ie,ae]=(0,V.useState)(!1),[oe,se]=(0,V.useState)(!1),[ce,le]=(0,V.useState)(r?.discovery?.mismatch&&r.discovery.origin||r?.hubOrigin||``),[W,ue]=(0,V.useState)(!1),[de,fe]=(0,V.useState)(!1),[pe,K]=(0,V.useState)(``),[he,ge]=(0,V.useState)(``),[_e,ve]=(0,V.useState)(``),[ye,be]=(0,V.useState)(!1),[xe,q]=(0,V.useState)(null),[Se,Ce]=(0,V.useState)(!1),[we,Te]=(0,V.useState)(new Map),[Ee,De]=(0,V.useState)(!1),[Oe,ke]=(0,V.useState)(``),[J,Ae]=(0,V.useState)(null),[X,Me]=(0,V.useState)(null),[Ne,Pe]=(0,V.useState)(null),[Fe,Ie]=(0,V.useState)(!1),[Le,Re]=(0,V.useState)(null),ze=(0,V.useRef)(!1),Be=(0,V.useRef)(0),Ve=(0,V.useRef)(!1),He=(0,V.useRef)(``),Ue=(0,V.useRef)(null),We=(0,V.useRef)(``),Ge=(0,V.useRef)(_),Ke=(0,V.useRef)(void 0),qe=`${r?.hubOrigin??``}/${r?.repository??``}/${r?.branch??``}/${r?.state===`connected`?r.prototype?.id??``:``}`,Je=r?r.discovery?.mismatch&&r.discovery.origin||r.hubOrigin||``:null,Ye=(0,V.useRef)(Je),Xe=r?.state,Ze=Xe===`unavailable`||Xe===`denied`,Qe=(0,V.useRef)(Xe);(0,V.useEffect)(()=>{if(Je===null||Ye.current===Je)return;let e=window.setTimeout(()=>{le(Je),Ye.current=Je},0);return()=>window.clearTimeout(e)},[Je]),(0,V.useEffect)(()=>{if(!Xe||Qe.current===Xe)return;if(Xe!==`connected`&&Xe!==`undiscovered`){Qe.current=Xe;return}let e=window.setTimeout(()=>{se(!1),Qe.current=Xe},0);return()=>window.clearTimeout(e)},[Xe]);let $e=jn({identity:qe,enabled:r?.repositoryAuthorized===!0,ready:Ee,bridgeProblem:Oe,token:e.token}),et=(0,V.useMemo)(()=>y.identity===qe?y.items:[],[y,qe]),rt=(0,V.useMemo)(()=>St(et),[et]),ot=(0,V.useMemo)(()=>{let e=new Map(rt.flatMap(e=>e.participants.map(e=>[e.login.toLowerCase(),e])));return Array.from(e.values()).sort((e,t)=>(e.name||e.login).localeCompare(t.name||t.login))},[rt]),st=(0,V.useMemo)(()=>{let e=new Map;for(let t of rt){let n=t.root.id,r=we.get(n);if(r)e.set(n,{commentId:n,status:`resolved`,point:r,rect:r.rect});else if(Ee){let r=t.root.anchor.route;e.set(n,{commentId:n,status:M&&(r.pathname!==M.pathname||r.search!==M.search||r.hash!==M.hash)?`route-mismatch`:`missing`})}}return e},[Ee,we,M,rt]),Z=r?.state===`connected`?rt.find(e=>e.root.id===N):null,Q=r?.state===`connected`?r.prototype:null,ut=r?.state===`disconnected`||r?.state===`pairing`||r?.state===`unconfigured`,dt=Q?.build?.author.login,ft=dt&&/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}(?:\[bot\])?$/i.test(dt)?`https://github.com/${encodeURIComponent(dt)}`:null,pt=Q?.build?.author.name?.trim()||(ft?dt:null)||G.unknownCommitAuthor,mt=Q?.canEdit&&Q.registered,ht=Q?.id,gt=Q?.build??null,xt=(0,V.useMemo)(()=>Q?rt.filter(e=>an(e,{filters:O,viewerLogin:Q.viewerLogin,selectedBuildNumber:gt?.number,route:M})):rt,[gt?.number,O,M,Q,rt]),Ct=xt.length,wt=xt.some(e=>e.unread),Tt=!!(gt&&r?.commitSha&&r.commitSha===gt.commitSha),Et=X!==null||Se||Le!==null,Dt=_&&!E,Ot=typeof document>`u`?null:document.getElementById(`canvas-review-controls`),kt=X?X.kind===`element`?{x:X.rect.x-X.viewport.scrollX+X.rect.width*X.elementOffset.x,y:X.rect.y-X.viewport.scrollY+X.rect.height*X.elementOffset.y}:ct(X,{x:X.rect.x-X.viewport.scrollX,y:X.rect.y-X.viewport.scrollY,width:X.rect.width,height:X.rect.height}).point:null;(0,V.useLayoutEffect)(()=>(We.current=qe,()=>window.clearTimeout(Ke.current)),[qe]),(0,V.useLayoutEffect)(()=>{_&&Ue.current?.focus({preventScroll:!0})},[_]),(0,V.useEffect)(()=>{let e=Ge.current;if(Ge.current=_,!_||e||!E)return;if(Se){v();return}let t=window.setTimeout(()=>{D(!1),P(null)},0);return()=>window.clearTimeout(t)},[E,Se,v,_]),(0,V.useEffect)(()=>{if(!_)return;function e(e){e.key!==`Escape`||e.defaultPrevented||e.target instanceof Element&&e.target.closest(`[role="dialog"], dialog, [role="menu"]`)||(e.preventDefault(),v())}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[_,v]);let At=ye&&xe===qe,jt=JSON.stringify(rt.slice(0,200).map(({root:e})=>({id:e.id,anchor:e.anchor}))),Mt=(0,V.useCallback)(async()=>{if(!ht||Ve.current)return;let t=qe,n=Be.current;re(!0);try{let r=[],i=null;for(let t=0;t<100;t+=1){let n=nn.parse(await $(`/api/hub/comments${i?`?cursor=${encodeURIComponent(i)}`:``}`,e.token));if(r.push(...n.comments),i=n.nextCursor,!i)break;if(t===99)throw Error(`Too many review comment pages.`)}if(We.current!==t||Be.current!==n)return;b({identity:t,items:r}),ae(!1),I(``)}catch(e){We.current===t&&Be.current===n&&(ae(!0),I(e instanceof Error?e.message:String(e)))}finally{We.current===t&&Be.current===n&&re(!1)}},[e.token,ht,qe]);(0,V.useEffect)(()=>{let e=window.setTimeout(()=>{b({identity:qe,items:[]}),D(!1),k(yt),j(!0),ee(null),P(null),Ce(!1),be(!1),q(null),K(``),ge(``),Re(null),ze.current=!1,Ve.current=!1,Be.current+=1,Te(new Map),De(!1),Ae(null),Me(null),Pe(null),z(``),ae(!1),ht&&Mt()},0);return()=>window.clearTimeout(e)},[qe,ht,Mt]),(0,V.useEffect)(()=>{if(!ht)return;let e=window.setInterval(()=>void Mt(),3e4);return()=>window.clearInterval(e)},[ht,Mt]),(0,V.useEffect)(()=>{if(!ht)return;let t=new AbortController,n,r=5e3;async function i(){let a=Date.now();try{let n=await fetch(`/api/hub/events`,{headers:{"X-Replica-Canvas-Token":e.token},signal:t.signal});if(!n.ok||!n.body)throw Error(`Live review connection unavailable.`);Ie(!1);let r=n.body.getReader(),i=new TextDecoder,a=``;for(;!t.signal.aborted;){let{value:e,done:t}=await r.read();if(t)throw Error(`Live review connection closed.`);a+=i.decode(e,{stream:!0});let n=a.split(` +import{n as e,t}from"./renderer-rolldown-runtime.js";import{A as n,B as r,C as i,D as a,E as o,F as s,G as c,H as l,I as u,K as d,L as f,M as p,N as m,O as h,P as g,R as _,S as v,T as y,U as b,V as x,W as S,_ as C,a as w,b as T,c as E,d as D,f as O,g as k,h as A,i as j,j as M,k as ee,l as N,m as P,n as F,o as I,p as L,r as R,s as z,t as te,u as B,v as ne,w as re,x as ie,y as ae,z as oe}from"./renderer-vendor.js";var V=e(d(),1),se=S(),H=l(),U=b();function ce({size:e=`medium`,className:t,label:n}){return(0,U.jsx)(`span`,{role:n?`status`:void 0,"aria-label":n,"aria-hidden":!n||void 0,className:`hub-spinner hub-spinner--${e}${t?` ${t}`:``}`})}function W({className:e,...t}){return(0,U.jsx)(`span`,{...t,className:`hub-visually-hidden${e?` ${e}`:``}`})}function G(e){let t=(0,V.useId)(),{as:n,href:r,ref:i,icon:a,description:o,loading:s=!1,size:c=`medium`,variant:l=`default`,className:u,...d}=e,f=`hub-icon-button${c===`small`?` hub-icon-button--small`:``}${l===`invisible`?` hub-icon-button--invisible`:``}${l===`danger`?` hub-icon-button--danger`:``}${u?` ${u}`:``}`,p=l===`invisible`?`subtle`:`secondary`,m=!(!o||d.title||d[`aria-describedby`]||`disabled`in d&&d.disabled),h=[d[`aria-describedby`],o&&!m?t:void 0].filter(Boolean).join(` `)||void 0,g=d.title??(m?void 0:o??d[`aria-label`]),_=o&&!m?(0,U.jsx)(W,{id:t,children:o}):null,v=s?(0,U.jsx)(ce,{decorative:!0,size:`small`}):(0,U.jsx)(a,{size:16}),y=s?!0:d[`aria-busy`];if(n===`a`){let e=i,t=(0,U.jsx)(H.Button,{...d,ref:e,as:`a`,href:r,leadingVisual:v,variant:p,size:c,className:f,"aria-busy":y,"aria-describedby":h,title:g,children:_});return m&&o?(0,U.jsx)(H.Tooltip,{ref:i,text:o,type:`description`,children:t}):t}let b=(0,U.jsx)(H.Button,{...d,ref:i,type:d.type??`button`,leadingVisual:v,variant:p,size:c,className:f,"aria-busy":y,"aria-describedby":h,title:g,children:_});return m&&o?(0,U.jsx)(H.Tooltip,{ref:i,text:o,type:`description`,children:b}):b}function le({title:e,closeLabel:t,onClose:n,returnFocusRef:r,descriptionId:i,className:a,children:o}){let s=(0,V.useRef)(null),c=(0,V.useId)();return(0,V.useLayoutEffect)(()=>{let e=s.current,t=r?.current??(document.activeElement instanceof HTMLElement?document.activeElement:null);return e?.showModal(),()=>{e?.close(),t?.focus()}},[r]),(0,U.jsxs)(`dialog`,{ref:s,"aria-labelledby":c,"aria-describedby":i,className:a?`canvas-dialog ${a}`:`canvas-dialog`,onCancel:e=>{e.preventDefault(),n()},onClick:e=>{if(e.target!==e.currentTarget)return;let{left:t,right:r,top:i,bottom:a}=e.currentTarget.getBoundingClientRect();(e.clientXr||e.clientYa)&&n()},children:[(0,U.jsxs)(`header`,{className:`canvas-dialog-header`,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`5`,id:c,children:e}),(0,U.jsx)(G,{variant:`invisible`,size:`small`,icon:B,"aria-label":t,onClick:n})]}),o]})}var K={localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPagesExceeded:`Too many review comment pages.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function ue({onClose:e,state:t,titleButtonRef:r}){let[i,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),l=t.stats.branchError?void 0:t.stats.branch,d=t.sessionId,f=t.stats.comparison;async function p(e,t){try{await navigator.clipboard.writeText(e),o(t),c(null)}catch{o(null),c(t===`branch`?K.branch:K.sessionId)}}function m(e,t){if(!e)return null;let r=t===`branch`?K.copyBranch:K.copySessionId,a=t===`branch`?K.branchCopied:K.sessionIdCopied;return(0,U.jsx)(H.Button,{type:`button`,className:`canvas-icon-button`,variant:`subtle`,size:`small`,leadingVisual:i===t?(0,U.jsx)(u,{size:16}):(0,U.jsx)(n,{size:16}),"aria-label":i===t?a:r,title:i===t?a:r,onClick:()=>void p(e,t),children:(0,U.jsx)(`span`,{className:`visually-hidden`,children:r})})}return(0,U.jsxs)(le,{title:K.buildDetails,closeLabel:K.closeBuildDetails,className:`build-details-dialog`,returnFocusRef:r,onClose:e,children:[(0,U.jsxs)(`dl`,{className:`build-details-list`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:K.branch}),(0,U.jsxs)(`dd`,{children:[(0,U.jsx)(a,{size:16,"aria-hidden":`true`}),(0,U.jsx)(`code`,{children:l||t.stats.branchError||K.unavailable}),m(l,`branch`)]})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:K.sessionId}),(0,U.jsxs)(`dd`,{children:[(0,U.jsx)(`code`,{children:d||K.unavailable}),m(d,`sessionId`)]})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:f?.branch?`Behind ${f.branch}${f.source===`local`?` (local)`:``}`:K.comparison}),(0,U.jsx)(`dd`,{children:f?.error||(f?.behind===0?K.upToDate:f?.behind==null?K.unavailable:K.commitsBehind(f.behind))})]})]}),(0,U.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`visually-hidden`,children:i===`branch`?`${K.branchCopied}.`:i===`sessionId`?`${K.sessionIdCopied}.`:``}),s?(0,U.jsx)(`span`,{role:`alert`,className:`build-details-copy-error`,children:K.buildDetailsCopyFailed(s)}):null]})}function de({pairing:e}){let[t,r]=(0,V.useState)(`idle`),i=(0,V.useRef)(null);(0,V.useEffect)(()=>{i.current?.querySelector(`a`)?.focus()},[]);async function a(){try{await navigator.clipboard.writeText(e.verificationUrl),r(`copied`)}catch{r(`failed`)}}return(0,U.jsxs)(`section`,{className:`hub-connection-approval`,"aria-label":K.connectionApproval,children:[(0,U.jsxs)(`p`,{role:`status`,children:[K.connectionWaiting,` `,(0,U.jsx)(`strong`,{children:e.userCode}),`.`]}),(0,U.jsxs)(`div`,{ref:i,className:`hub-connection-approval-actions`,role:`group`,"aria-label":K.connectionApproval,children:[(0,U.jsx)(H.Button,{as:`a`,variant:`primary`,size:`medium`,href:e.verificationUrl,target:`_blank`,rel:`noopener noreferrer`,children:K.connectToHub}),(0,U.jsx)(G,{icon:t===`copied`?u:n,size:`medium`,className:`hub-connection-approval-copy`,"aria-label":t===`copied`?K.approvalLinkCopied:K.copyApprovalLink,onClick:()=>void a()})]}),(0,U.jsx)(W,{role:`status`,children:t===`copied`?K.approvalLinkCopied:``}),t===`failed`?(0,U.jsx)(`p`,{role:`alert`,children:K.approvalCopyFailed}):null]})}function fe({status:e,pairing:t,connecting:n,error:r,onConnect:i,onSelectHub:a,onResetHub:o,onClose:s,hubButtonRef:c}){let l=(0,V.useId)(),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(!1),[g,_]=(0,V.useState)(!1),[v,y]=(0,V.useState)(!1),[b,x]=(0,V.useState)(``),S=(0,V.useRef)(null),C=(0,V.useRef)(null),w=f||!e?.hubOrigin||u!==null&&!m,T=(0,V.useRef)(w),E=u??e?.hubOrigin??``,D=n||g||v,O=!!t||n;(0,V.useEffect)(()=>{w&&!O?S.current?.focus():T.current&&!O&&C.current?.focus(),T.current=w},[w,O]),(0,V.useEffect)(()=>{if(f||u===null||!m||!e?.hubOrigin)return;let t=window.setTimeout(()=>d(null),0);return()=>window.clearTimeout(t)},[u,f,m,e?.hubOrigin]);async function k(){if(!D){_(!0),x(``);try{await a(E),d(null),p(!1)}catch(e){x(e instanceof Error?e.message:String(e))}finally{_(!1)}}}async function A(){if(!D&&o){y(!0),x(``);try{d(await o()),p(!!e?.hubOrigin)}catch(e){x(e instanceof Error?e.message:String(e))}finally{y(!1)}}}return(0,U.jsxs)(le,{title:K.connectToHub,closeLabel:K.closeConnectionDialog,onClose:s,returnFocusRef:c,children:[(0,U.jsx)(`p`,{children:K.connectionDescription}),b||r?(0,U.jsx)(`p`,{role:`alert`,children:b||r}):null,(0,U.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),!D&&(!O&&w&&(f||e?.hubOrigin)?k():(x(``),e?.hubOrigin||h(!0),i(e?.hubOrigin?void 0:E)))},children:[!O&&(w?(0,U.jsxs)(`div`,{className:`hub-connection-origin-field`,children:[(0,U.jsx)(`label`,{htmlFor:l,children:K.hubUrl}),(0,U.jsxs)(`div`,{className:`hub-connection-origin-input`,children:[(0,U.jsx)(H.TextInput,{ref:S,id:l,type:`url`,value:E,onChange:e=>{h(!1),d(e.target.value)},required:!0,fullWidth:!0,disabled:D,placeholder:`https://hub.example.com`}),o?(0,U.jsx)(G,{icon:L,variant:`invisible`,size:`small`,"aria-label":K.resetHubUrl,disabled:D,"aria-busy":v,onClick:()=>void A()}):null]}),f||e?.hubOrigin?(0,U.jsx)(H.Button,{type:`submit`,variant:`subtle`,size:`small`,disabled:D,children:K.saveHub}):null]}):(0,U.jsxs)(`div`,{className:`hub-connection-origin`,children:[(0,U.jsx)(`a`,{href:e?.hubOrigin&&new URL(e.hubOrigin).origin,target:`_blank`,rel:`noopener noreferrer`,children:e?.hubOrigin}),(0,U.jsx)(G,{ref:C,icon:ae,variant:`invisible`,size:`small`,"aria-label":K.editHubUrl,disabled:D,onClick:()=>{x(``),p(!0),d(e?.hubOrigin??``)}})]})),t?(0,U.jsx)(de,{pairing:t},t.verificationUrl):null,t?null:(0,U.jsx)(H.Button,{type:`submit`,variant:`primary`,disabled:D||!e?.repository||!O&&w&&(f||!!e?.hubOrigin),children:n?K.connectionOpeningBrowser:K.connectToHub})]})]})}function pe({title:e,description:t,children:n,action:r,variant:i,layout:a,onDismiss:o,dismissLabel:c,className:l,...u}){let d=i===`critical`?A:i===`success`?s:i===`info`?y:x;return(0,U.jsxs)(`div`,{...u,role:i===`critical`||i===`warning`?`alert`:`status`,className:`hub-alert hub-alert--${i}${a===`compact`?` hub-alert--compact`:``}${l?` ${l}`:``}`,children:[(0,U.jsx)(d,{className:`hub-alert__icon`,size:20,"aria-hidden":`true`}),(0,U.jsxs)(`div`,{className:`hub-alert__content`,children:[(0,U.jsxs)(H.Text,{as:`p`,size:`100`,className:`hub-alert__message`,children:[(0,U.jsx)(`strong`,{className:`hub-alert__title`,children:e}),t?(0,U.jsx)(`span`,{className:`hub-alert__description`,children:t}):null]}),n]}),r||o?(0,U.jsxs)(`div`,{className:`hub-alert__action`,children:[r,o&&c?(0,U.jsx)(G,{icon:B,"aria-label":c,title:c,variant:`invisible`,size:`small`,onClick:o}):null]}):null]})}var q={title:`Publish uncommitted changes?`,description:`Do you want to commit changes before publishing? Publishing the committed version only excludes your local uncommitted edits.`,checkFailedTitle:`Could not check local changes`,checkFailed:`Git could not check local changes.`,retryCheck:`Retry check`,commit:`Commit changes & publish`,committed:`Publish committed version only`,close:`Close publishing dialog`,changedFiles:`Uncommitted changes`,moreChanges:e=>`${e} more`,localSkills:e=>`${e} local agent skill ${e===1?`file stays`:`files stay`} uncommitted.`,selection:`Copilot commits only changes related to this prototype task and asks if it cannot tell which changes belong.`,remember:`Always commit changes before publishing for this prototype`,settings:`Settings`,alwaysCommit:`Always commit changes before publishing`,retrySettings:`Retry settings`,preferenceTargetChanged:`The checkout changed. Refresh Settings and try again.`,invalidPreference:`Publishing settings returned an invalid response. Retry settings.`};function me({busy:e,error:t,changes:n,checkError:r,remembered:i,returnFocusRef:a,onClose:o,onChoose:s,onRetry:c}){let[l,u]=(0,V.useState)(i),d=(0,V.useId)(),f=(0,V.useId)();return(0,U.jsx)(le,{title:r?q.checkFailedTitle:q.title,closeLabel:q.close,descriptionId:r?void 0:d,returnFocusRef:a,onClose:()=>{e||o()},className:`publish-changes-dialog`,children:(0,U.jsxs)(H.Stack,{gap:`normal`,padding:`none`,children:[r?null:(0,U.jsx)(`p`,{id:d,children:q.description}),r?(0,U.jsx)(pe,{title:r,variant:`critical`,layout:`compact`}):null,n?.files.total?(0,U.jsx)(`section`,{"aria-label":q.changedFiles,children:(0,U.jsxs)(`ul`,{className:`publish-changes-dialog__files`,children:[n.files.paths.map(e=>(0,U.jsx)(`li`,{children:(0,U.jsx)(`code`,{children:e})},e)),n.files.total>n.files.paths.length?(0,U.jsx)(`li`,{children:q.moreChanges(n.files.total-n.files.paths.length)}):null]})}):null,r?null:(0,U.jsxs)(`p`,{children:[n?.localSkills.total?`${q.localSkills(n.localSkills.total)} `:null,q.selection]}),r?null:(0,U.jsxs)(H.FormControl,{id:f,fullWidth:!0,children:[(0,U.jsx)(H.Checkbox,{checked:l,disabled:e,onChange:e=>u(e.target.checked)}),(0,U.jsx)(H.FormControl.Label,{children:q.remember})]}),t?(0,U.jsx)(pe,{title:t,variant:`critical`,layout:`compact`}):null,(0,U.jsxs)(`footer`,{className:`publish-changes-dialog__actions`,children:[r?(0,U.jsx)(H.Button,{variant:`primary`,size:`small`,disabled:e,"aria-busy":e,onClick:c,children:q.retryCheck}):null,r?null:(0,U.jsx)(H.Button,{variant:`primary`,size:`small`,disabled:e,"aria-busy":e,onClick:()=>s(`commit-changes`,l),children:q.commit}),(0,U.jsx)(H.Button,{size:`small`,disabled:e,onClick:()=>s(`committed-only`,!1),children:q.committed})]})]})})}function he({value:e,label:t,copyLabel:r,copiedLabel:i,copyErrorLabel:a,compact:o=!1}){let[s,c]=(0,V.useState)(null),l=s?.value===e?s.status:null,u=l===`copied`?i:r;async function d(){try{await navigator.clipboard.writeText(e),c({value:e,status:`copied`})}catch{c({value:e,status:`failed`})}}return(0,U.jsxs)(`div`,{className:`copyable-text-input${o?` copyable-text-input--compact`:``}`,children:[(0,U.jsxs)(`div`,{className:`copyable-text-input__control`,children:[o?(0,U.jsx)(`input`,{type:`text`,value:e,"aria-label":t,readOnly:!0,className:`copyable-text-input__input`}):(0,U.jsx)(H.TextInput,{value:e,"aria-label":t,readOnly:!0,fullWidth:!0,className:`copyable-text-input__input`}),(0,U.jsx)(G,{icon:n,"aria-label":u,description:o?u:void 0,title:o?void 0:u,variant:`invisible`,size:`small`,className:`copyable-text-input__button`,onClick:()=>void d()})]}),(0,U.jsx)(W,{"aria-live":`polite`,"aria-atomic":`true`,children:l===`copied`?i:``}),l===`failed`?(0,U.jsx)(`span`,{role:`alert`,className:`copyable-text-input__error`,children:a}):null]})}function ge({children:e}){return(0,U.jsx)(`div`,{className:`prototype-workspace__body`,children:e})}function _e({title:e,description:t,trailing:n,headingAs:r=`h2`,headingRef:i}){return(0,U.jsxs)(`header`,{className:`hub-content-page-header`,children:[(0,U.jsxs)(`div`,{className:`hub-content-page-header__top`,children:[(0,U.jsx)(H.Heading,{as:r,size:`4`,ref:i,tabIndex:i?-1:void 0,children:e}),n]}),t?(0,U.jsx)(H.Text,{as:`p`,className:`hub-content-page-header__description`,children:t}):null]})}function ve({labels:e,headingRef:t,headingTrailing:n,feedback:r,form:i,formUnavailable:a,links:o,hasLinks:s,showEmpty:c=!0,listRef:l,listBusy:u,beforeLinks:d,afterLinks:f}){return(0,U.jsxs)(H.Stack,{gap:`normal`,children:[(0,U.jsx)(_e,{title:e.heading,description:e.description,headingRef:t,trailing:n}),r,i||(a===void 0?(0,U.jsxs)(`section`,{className:`share-links__empty`,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`5`,children:e.noBuildHeading}),(0,U.jsx)(H.Text,{as:`p`,className:`share-links__empty-description`,children:e.noBuildLabel})]}):a),d,s?(0,U.jsx)(`ul`,{className:`share-links__list`,ref:l,"aria-busy":u,children:o}):c?(0,U.jsxs)(`section`,{className:`share-links__empty`,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`5`,children:e.emptyHeading}),(0,U.jsx)(H.Text,{as:`p`,className:`share-links__empty-description`,children:e.emptyLabel})]}):null,f]})}function ye({shareLink:e,className:t,copiedLabel:n,copyErrorLabel:r,copyLabel:i,urlLabel:a,unavailableLabel:o,highlighted:s,children:c}){return(0,U.jsx)(`li`,{"data-share-id":e.id,className:`share-link-item${s?` share-link-item--created`:``}${t?` ${t}`:``}`,children:(0,U.jsxs)(`div`,{className:`share-link-item__layout`,children:[(0,U.jsxs)(`div`,{className:`share-link-item__details`,children:[(0,U.jsx)(`h3`,{children:e.label}),(0,U.jsxs)(`span`,{className:`share-link-item__metadata`,children:[e.buildLabel,e.createdLabel?(0,U.jsxs)(U.Fragment,{children:[` · `,(0,U.jsx)(`time`,{dateTime:e.createdAt,children:e.createdLabel})]}):null,` · `,e.expiresAt?(0,U.jsx)(`time`,{dateTime:e.expiresAt,children:e.expiresLabel}):e.expiresLabel]})]}),(0,U.jsxs)(`div`,{className:`share-link-item__actions`,children:[o?(0,U.jsx)(`p`,{children:o}):(0,U.jsx)(he,{value:e.url,label:a||e.label,copyLabel:i,copiedLabel:n,copyErrorLabel:r}),c]})]})})}function be({data:e,action:t,hiddenFields:n,details:r,afterFields:a,onSubmit:o,label:s,onLabelChange:c,expiration:l,onExpirationChange:u,disabled:d,fieldsDisabled:f,busy:p,error:m}){let h=(0,V.useId)(),g=(0,V.useId)();return(0,U.jsxs)(`div`,{className:`share-links-form`,children:[e.buildLabel?(0,U.jsx)(H.Heading,{as:`h2`,size:`5`,children:e.buildLabel}):null,r,(0,U.jsxs)(`form`,{action:t,method:`post`,onSubmit:o,"aria-busy":p,className:`share-links__form`,children:[n,(0,U.jsxs)(`div`,{className:`share-links__form-row`,children:[(0,U.jsxs)(H.FormControl,{id:h,required:!0,fullWidth:!0,className:`share-links__field`,children:[(0,U.jsx)(H.FormControl.Label,{children:e.labelLabel}),(0,U.jsx)(H.TextInput,{"aria-label":e.labelLabel,"aria-invalid":!!m,name:`share_link[label]`,placeholder:e.labelPlaceholder,maxLength:e.labelMaximumBytes,value:s,onChange:c,disabled:f,fullWidth:!0}),m?(0,U.jsx)(H.FormControl.Validation,{validationStatus:`error`,className:`share-links__validation`,children:m}):null]}),m?(0,U.jsx)(W,{role:`alert`,children:m}):null,(0,U.jsxs)(H.FormControl,{id:g,fullWidth:!0,className:`share-links__field`,children:[(0,U.jsx)(H.FormControl.Label,{children:e.expirationLabel}),(0,U.jsx)(H.Select,{"aria-label":e.expirationLabel,name:`share_link[expiration]`,defaultValue:l===void 0?e.expirationOptions.find(e=>e.value===`seven_days`)?.value??e.expirationOptions[0]?.value:void 0,value:l,onChange:u,disabled:f,fullWidth:!0,children:e.expirationOptions.map(e=>(0,U.jsx)(H.Select.Option,{value:e.value,children:e.label},e.value))})]}),(0,U.jsx)(`div`,{className:`share-links__form-actions`,children:(0,U.jsx)(H.Button,{type:`submit`,variant:`primary`,leadingVisual:i,disabled:d,children:e.submitLabel})})]}),a?(0,U.jsx)(`div`,{className:`share-links__form-options`,children:a}):null]})]})}var J={title:`Share prototype`,internal:`Internal prototype link`,internalDescription:`Requires GitHub sign-in and repository access.`,internalUnavailable:`Internal prototype link unavailable.`,internalCopy:`Copy internal prototype link`,internalOpen:`Open internal prototype link`,public:`Public share links`,permissionUnknown:`Hub has not confirmed permission to manage public share links.`,group:`Publish and share`,back:`Back to preview`,warning:`Anyone with a link can view its Build without signing in. The prototype may expose sensitive or customer information. Check its content before sharing. Local and uncommitted changes are not included.`,target:`New links share this published Build:`,oldBuild:`This is the last published Build, not the current local preview.`,includeControlSettings:`Include current control settings`,controlSettingsDescription:`Adds settings for all configured pages to the links you copy or open. Saved share links stay unchanged.`,controlSettingsWarning:`Settings for controls that have not been published will not take effect for shared links.`,controlSettingsWarningTitle:`Local changes are not in the shared Build`,label:`Label`,labelPlaceholder:`Usability review`,labelInvalid:`Enter a label containing no more than 100 UTF-8 bytes.`,expiry:`Expires after`,expirations:[{value:`one_day`,label:`1 day`},{value:`seven_days`,label:`7 days`},{value:`thirty_days`,label:`30 days`},{value:`never`,label:`Never`}],create:`Create share link`,creating:`Working...`,active:`Active share links`,empty:`Create a link when someone needs signed-out access.`,emptyHeading:`No active share links`,loading:`Loading share links...`,refresh:`Refresh links`,authorize:`Verify with GitHub`,authorizationRetry:`Complete authorization in your browser, then refresh links and submit the action again. No action is replayed automatically.`,paginationFailed:`Hub returned a repeated share-link page. Refresh links to try again.`,noBuild:`A successful published Build is required before creating a share link.`,noBuildHeading:`No successful Build`,build:e=>`Build ${e}`,buildDetails:(e,t,n)=>`Commit: ${e}\nAuthor: @${t}\nPublished: ${n}`,denied:`Managing public share links requires repository admin access or authorship of any successful Build for this Prototype, with current read access. Write access alone is not sufficient.`,disabled:`Public sharing is disabled for this Hub. A Hub administrator must explicitly enable it. Previously revoked links never return.`,disconnected:`Connect to Hub before managing share links.`,connect:`Connect to Hub`,unavailable:`Hub is unavailable. Restore the connection and reopen Share prototype.`,branch:`Open a named prototype branch discovered by Hub before sharing.`,stale:`Hub or checkout changed. Return to preview and reopen Share prototype.`,deleted:`Share link deleted. Its public URL no longer works.`,never:`Never expires`,expires:e=>`Expires ${e}`,createdBy:(e,t)=>`Created by @${e} ${t}`,copy:(e,t)=>`Copy ${e}, Build #${t}`,copied:`Link copied`,copyError:`Could not copy the link. Select the URL and copy it manually.`,open:(e,t)=>`Open ${e}, Build #${t}`,delete:(e,t)=>`Delete ${e}, Build #${t}`,deletePrompt:e=>`Delete "${e}"? Anyone with this link will lose access to its Build.`,deletedError:`Could not delete the link.`,failed:`The sharing request failed.`,unknown:`The sharing request may have completed. Refresh active links before trying again. A matching label does not prove which request created a link.`,expired:`This link has expired. Refresh links.`};function xe({included:e,onChange:t,publishedVersionDiffers:n,disabled:r=!1,error:i,copy:a}){let o=(0,V.useId)(),s=e&&n;return(0,U.jsxs)(`div`,{className:`share-control-settings`,children:[(0,U.jsxs)(H.FormControl,{id:o,fullWidth:!0,children:[(0,U.jsx)(H.Checkbox,{checked:e,onChange:e=>t(e.target.checked),disabled:r}),(0,U.jsx)(H.FormControl.Label,{children:a?.label??J.includeControlSettings}),(0,U.jsx)(H.FormControl.Hint,{className:`share-control-settings__hint`,children:(0,U.jsx)(`span`,{className:`share-control-settings__description`,children:a?.description??J.controlSettingsDescription})})]}),i?(0,U.jsx)(pe,{title:i,variant:`critical`,layout:`compact`}):null,s?(0,U.jsx)(pe,{title:J.controlSettingsWarningTitle,description:J.controlSettingsWarning,variant:`warning`,layout:`compact`,className:`share-control-settings__warning`}):null]})}function Se(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var Ce=`replica:controls:url`,we=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function Te(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!Se(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!we.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function Ee(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=we.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!Se({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{Te(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function De(e,t){let n=new URL(e,window.location.href),r=Ee(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(Te(r.scopes)))n.searchParams.set(e,t);return n.toString()}function Oe({state:e,buildDetails:t,currentCommit:n,hasLocalChanges:r=!1,shareButtonRef:i,onClose:a,onConnect:o,onRefresh:s,onCreate:c,onDelete:l,onOpen:u,controlSettings:d,onAuthorize:f}){let[p,m]=(0,V.useState)(``),[h,g]=(0,V.useState)(`seven_days`),[_,y]=(0,V.useState)(``),[b,x]=(0,V.useState)(Date.now),S=(0,V.useRef)(null),C=(0,V.useRef)(null),w=(0,V.useRef)(null),T=e.context?.prototype,E=J.expirations.filter(e=>!T?.shareLinkExpirationOptions||T.shareLinkExpirationOptions.includes(e.value)),D=E.some(e=>e.value===h)?h:E.find(e=>e.value===`seven_days`)?.value??E[0]?.value??``,k=T?.published?T.build:null,A=k?.url,j=A&&URL.canParse(A)?new URL(A):null,M=j&&j.origin===e.context?.hubOrigin&&[`http:`,`https:`].includes(j.protocol)&&!j.username&&!j.password?A:null,ee=!!(k&&n&&n!==k.commitSha)||r,N=T?.canManageShareLinks===!0,P=!e.sharingDisabled&&T?.publicSharingEnabled!==!1,F=e.busy||e.loading||e.stale||!N||!P,I=d?.included?d.query??``:``,L=!!d?.blocked;function R(e){return De(e,I)}let z=P&&e.stale&&!e.loading&&e.created&&!e.links.some(t=>t.id===e.created?.id)?e.created:null;(0,V.useEffect)(()=>{let e=i.current;C.current?.focus();let t=window.setInterval(()=>x(Date.now()),1e4);return()=>{window.clearInterval(t),e?.focus()}},[i]),(0,V.useEffect)(()=>{if(e.busy||!w.current)return;let t=w.current;w.current=null,(t.map(e=>S.current?.querySelector(`[data-share-id="${e}"] button`)).find(e=>e&&!e.disabled)||C.current)?.focus()},[e.busy,e.links]);async function te(t,n){if(!window.confirm(J.deletePrompt(n)))return;let r=e.links.findIndex(e=>e.id===t),i=[...e.links.slice(r+1),...e.links.slice(0,r).reverse()].map(e=>e.id);await l(t)&&(w.current=i,(i.map(e=>S.current?.querySelector(`[data-share-id="${e}"] button`)).find(e=>e&&!e.disabled)||C.current)?.focus())}function ne(e){return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}return(0,U.jsx)(`main`,{className:`canvas-share-page`,"aria-label":J.title,children:(0,U.jsx)(ge,{children:(0,U.jsx)(ve,{labels:{heading:J.title,noBuildHeading:J.noBuildHeading,noBuildLabel:J.noBuild,emptyHeading:J.emptyHeading,emptyLabel:J.empty},headingRef:C,headingTrailing:(0,U.jsx)(`div`,{className:`canvas-share-close`,children:(0,U.jsx)(G,{icon:B,variant:`invisible`,"aria-label":J.back,description:J.back,onClick:a})}),feedback:(0,U.jsxs)(U.Fragment,{children:[d?(0,U.jsx)(xe,{included:d.included,onChange:d.onChange,publishedVersionDiffers:ee,disabled:e.busy||d.pending,error:d.error}):null,(0,U.jsxs)(`section`,{className:`canvas-share-internal`,"aria-label":J.internal,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`6`,children:J.internal}),(0,U.jsx)(`p`,{children:J.internalDescription}),M&&!L?(0,U.jsxs)(`div`,{className:`share-link-item__actions canvas-share-internal-actions`,children:[(0,U.jsx)(he,{value:R(M),label:J.internal,copyLabel:J.internalCopy,copiedLabel:J.copied,copyErrorLabel:J.copyError}),(0,U.jsx)(G,{as:`a`,href:R(M),target:`_blank`,rel:`noopener`,icon:v,"aria-label":J.internalOpen,description:J.internalOpen})]}):M?null:(0,U.jsx)(`p`,{role:`status`,children:J.internalUnavailable})]}),(0,U.jsxs)(`div`,{className:`canvas-share-public-header`,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`6`,children:J.public}),(0,U.jsx)(`p`,{children:J.warning})]}),T&&!N?(0,U.jsx)(`p`,{role:`status`,children:T.canManageShareLinks===!1?J.denied:J.permissionUnknown}):null,P?null:(0,U.jsx)(`p`,{role:`status`,children:J.disabled}),e.error?(0,U.jsx)(pe,{title:e.error,variant:`critical`,layout:`compact`}):null,e.authorization&&f?(0,U.jsx)(H.Button,{variant:`secondary`,size:`small`,onClick:f,disabled:e.busy,children:J.authorize}):null,o&&!e.context?(0,U.jsx)(H.Button,{variant:`secondary`,size:`small`,onClick:o,children:J.connect}):null]}),form:k&&N&&P?(0,U.jsx)(be,{data:{buildLabel:null,labelLabel:J.label,labelPlaceholder:J.labelPlaceholder,labelMaximumBytes:100,expirationLabel:J.expiry,expirationOptions:E,submitLabel:e.busy?J.creating:J.create},label:p,onLabelChange:e=>{m(e.target.value),y(``)},expiration:D,onExpirationChange:e=>g(e.target.value),onSubmit:e=>{e.preventDefault(),!p.trim()||new TextEncoder().encode(p.trim()).length>100?y(J.labelInvalid):(y(``),c(p,D))},disabled:F,fieldsDisabled:e.busy,busy:e.busy,error:_,details:(0,U.jsxs)(`div`,{className:`canvas-share-build-details`,children:[(0,U.jsxs)(`p`,{children:[J.target,` `,(0,U.jsx)(`strong`,{children:J.build(k.number)}),` - `,(0,U.jsx)(`code`,{children:k.commitSha.slice(0,7)}),` - `,(0,U.jsx)(`time`,{dateTime:k.publishedAt,children:ne(k.publishedAt)})]}),ee?(0,U.jsx)(`p`,{children:J.oldBuild}):null]})}):null,formUnavailable:N&&P&&!k?void 0:null,beforeLinks:(0,U.jsxs)(U.Fragment,{children:[e.notice?(0,U.jsx)(`p`,{role:`status`,children:e.notice}):null,z&&!L?(0,U.jsx)(he,{value:R(z.url),label:z.label,copyLabel:J.copy(z.label,z.buildNumber),copiedLabel:J.copied,copyErrorLabel:J.copyError}):null,e.loading?(0,U.jsx)(`p`,{role:`status`,children:J.loading}):null]}),hasLinks:N&&P&&!L&&e.links.length>0,showEmpty:N&&P&&!L&&!e.loading&&!e.stale,listRef:S,listBusy:e.loading,links:(!N||!P||L?[]:e.links).map(e=>{let n=e.expiresAt!==null&&Date.parse(e.expiresAt)<=b,r=t?.[e.buildNumber];return(0,U.jsxs)(ye,{className:k&&e.buildNumberI?u(e.id,I):u(e.id)}),(0,U.jsx)(G,{icon:O,variant:`danger`,"aria-label":J.delete(e.label,e.buildNumber),description:J.delete(e.label,e.buildNumber),disabled:F||n,onClick:()=>void te(e.id,e.label)})]},e.id)}),afterLinks:(0,U.jsx)(`div`,{className:`canvas-share-list-actions`,children:N||!e.context&&!o?(0,U.jsx)(H.Button,{size:`small`,variant:`subtle`,onClick:s,disabled:e.busy||e.loading,children:J.refresh}):null})})})})}var Y={checking:`Checking sharing readiness`,checkingDetail:`Checking Hub for a successful published Build and repository access.`,connect:`Connect before sharing`,connectDetail:`Connect to Hub before sharing this prototype.`,connectAction:`Connect to Hub`,publish:`Publish before sharing`,publishDetail:`To create a share link, publish this prototype to Hub first. Your local preview stays private.`,publishPermissionUnverified:`This Hub has not confirmed publishing permission. Copilot will check access when publishing and report any permission errors.`,preparing:`Preparing your prototype`,ready:`Ready to share`,readyDetail:`Your prototype is ready to share.`,manage:`Share prototype`,unavailable:`Sharing status unavailable`,unavailableDetail:`Hub could not verify sharing readiness. Retry before continuing.`,permissionUnknown:`This Hub cannot verify sharing or publishing permission. Update Hub and retry.`,restricted:`Sharing unavailable`,publishDenied:`Publishing requires repository write access. Ask a prototype author to publish a Build.`,local:`Local development prototypes cannot create public share links.`,changed:`Sharing target changed`,changedDetail:`The repository, branch, or Hub changed. Close this dialog and reopen Share for the intended prototype.`,boundary:`Internal review requires repository access. Public share links let anyone view a published Build, not your local preview.`,close:`Close sharing readiness`},ke=`Branch not eligible for Hub registration`,X={heading:`Branch publication`,checking:`Checking...`,retry:`Retry status`,retryPublish:`Retry publish`,requested:`Requested`,awaitingCopilot:`Waiting for Copilot`,publishBranch:`Publish`,publishChanges:`Publish changes`,registration:`Publishing`,registrationFailed:`Publication delayed`,published:`Published`,alreadyPublished:`Latest changes already published`,queued:`Build queued`,building:`Building`,awaitingHub:`Awaiting Hub`,awaitingBuild:`Awaiting build`,connect:`Connect to the hub`,workflowLink:`View workflow run`,initial:`Checking branch publication.`,checkingRemote:`Checking the exact branch on the origin repository.`,detached:`Open a named branch before publishing.`,changed:`The checkout changed. Refresh publication status.`,unknown:e=>`Remote branch status is unknown. ${e||`Check GitHub access and retry.`}`,pending:`Copilot received the publish request in chat and has not pushed this branch yet. Follow its progress in chat.`,checkingHub:`Checking the Hub connection.`,disconnected:`Connect to the hub before publishing this prototype.`,hubUnavailable:`Hub verification is unavailable. Restore access and retry.`,hubUnavailableTitle:`Hub verification unavailable`,staleHub:`The Hub status belongs to a different checkout. Refresh to continue.`,workflowMissing:`This checkout has no .github/workflows/replica.yml. Set up the repository's Replica build workflow before publishing.`,dispatchFailed:`Copilot could not receive the publish request.`,absent:`This branch won't appear in the hub until you publish.`,needsPush:`The remote branch points to a different commit. Publish pushes this branch without force.`,localChanges:`Local changes are not in the published prototype. Choose how to publish them.`,needsRegistration:`Hub imported this commit. The canvas is publishing it automatically.`,registrationDenied:`Hub could not register this branch. Check repository access and branch eligibility.`,registrationErrorTitle:`Hub registration failed`,registrationReasons:new Map([[`write_access_required`,{title:ke,description:`You lack write access to this repository.`}],[`branch_not_reviewable`,{title:ke,description:`Default, reserved, and internal branches cannot be registered in Hub.`}],[`remote_branch_missing`,{title:ke,description:`The branch no longer exists on the remote repository.`}],[`branch_authorship_required`,{title:ke,description:`You have not authored a commit unique to this branch.`}],[`repository_mismatch`,{title:ke,description:`The branch belongs to a different repository.`}],[`already_registered`,{title:`Branch already registered in Hub`,description:`This branch is already registered in Hub. Refresh its status.`}],[`successful_build_required`,{title:`Hub registration delayed`,description:`Hub has not imported this checkout's successful Build yet.`}]]),ready:`Hub imported this commit and the prototype is registered.`,importFailed:`Hub could not import or build this commit. Pushing this unchanged commit does not rerun the failed work. Inspect the Build failure in Hub and repair the cause before publishing again.`,workflowUnavailable:`Workflow status is unavailable. Check GitHub access and retry.`,staleWorkflow:`Workflow status belongs to a different branch or commit.`,workflowQueued:`The Replica workflow for this commit is queued or waiting.`,workflowBuilding:`The Replica workflow is building this commit.`,workflowFailed:e=>`The Replica workflow finished with ${e||`an unsuccessful result`}. Pushing this unchanged commit does not rerun the failed work. Inspect the run and repair the cause before publishing again.`,importing:`The workflow succeeded. Waiting for Hub discovery and artifact import; this is not published yet.`,noBuild:`The exact branch and commit are on GitHub, but no matching Replica workflow run has appeared yet.`};function Ae({publication:e,busy:t,onPublish:n,onRetry:r}){if(e.kind===`ready`)return null;let i=e.kind===`requested`,a=t||i;return(0,U.jsxs)(`section`,{className:`canvas-branch-publication`,"aria-label":X.heading,children:[e.error?(0,U.jsx)(pe,{variant:`critical`,layout:`compact`,title:e.error.title,description:e.error.description}):(0,U.jsx)(`p`,{role:`status`,children:e.detail}),e.runUrl?(0,U.jsx)(`p`,{children:(0,U.jsx)(H.InlineLink,{className:`canvas-branch-publication__workflow-link`,href:e.runUrl,target:`_blank`,rel:`noopener noreferrer`,children:X.workflowLink})}):null,(e.action!==`none`||i)&&e.kind!==`disconnected`?(0,U.jsx)(`div`,{className:`canvas-branch-publication__actions`,children:(0,U.jsx)(H.Button,{variant:`primary`,size:`small`,disabled:a,"aria-busy":a,leadingVisual:a?(0,U.jsx)(L,{size:16}):void 0,onClick:e.action===`retry`?r:n,children:e.label})}):null]})}function je({readiness:e,busy:t,shareButtonRef:n,onClose:r,onConnect:i,onPublish:a,onRetry:o,onManage:s}){let c=(0,V.useId)();return(0,U.jsxs)(le,{title:e.title,closeLabel:Y.close,onClose:r,returnFocusRef:n,descriptionId:c,children:[(0,U.jsx)(`p`,{id:c,role:`status`,children:e.detail}),[`connect`,`publish`,`ready`].includes(e.kind)?(0,U.jsx)(`p`,{children:Y.boundary}):null,e.publication?(0,U.jsx)(Ae,{publication:e.publication,dirty:!1,busy:t,onPublish:a,onRetry:o}):null,[`connect`,`ready`,`retry`].includes(e.kind)?(0,U.jsx)(H.Button,{variant:`primary`,size:`small`,disabled:t,"aria-busy":t,onClick:e.kind===`connect`?i:e.kind===`ready`?s:o,children:e.kind===`connect`?Y.connectAction:e.kind===`ready`?Y.manage:X.retry}):null]})}function Me({hub:e,connection:t,publication:n,sharing:r,shareIntent:i,controlSettings:a,readiness:o,state:s,hubOpen:c,buildDetailsOpen:l,onCloseBuildDetails:u,shareButtonRef:d,hubButtonRef:f,connectionButtonRef:p,publishButtonRef:m,titleButtonRef:h}){let{intent:g,targetChanged:_}=i,v=n.presentedState;return(0,U.jsxs)(U.Fragment,{children:[t.open&&(!g||g.connecting&&!_)?(0,U.jsx)(fe,{status:e.status,pairing:t.pairing,connecting:t.connecting,error:t.error,onConnect:t.connect,onSelectHub:e.select,onResetHub:e.reset,onClose:()=>{t.close(),i.setConnecting(!1)},hubButtonRef:g?d:c?p:f}):null,g&&!n.publishDialog&&(_||!g.connecting||!t.open)?(0,U.jsx)(je,{readiness:_?{kind:`restricted`,title:Y.changed,detail:Y.changedDetail}:o,busy:n.busy,shareButtonRef:d,onClose:()=>{i.close(),t.close()},onConnect:()=>{_||o.kind!==`connect`||(i.setConnecting(!0),t.showAndConnect())},onPublish:()=>{!_&&o.kind===`publish`&&n.publish()},onRetry:()=>void n.retry(),onManage:()=>{_||o.kind!==`ready`||(i.close(),r.open())}}):null,n.publishDialog?(0,U.jsx)(me,{busy:n.busy,error:n.publishDialogError,changes:n.publishDialog.preparation.changes,checkError:n.publishDialog.preparation.workingTree===`unavailable`?n.publishDialog.preparation.workingTreeError||q.checkFailed:void 0,remembered:n.publishDialog.preparation.remember,returnFocusRef:g?d:m,onClose:n.closePublishDialog,onChoose:(e,t)=>void n.choosePublish(e,t),onRetry:()=>void n.retryPublishCheck()},n.publishDialog.preparation.workingTree===`unavailable`?`unchecked`:`checked`):null,r.state.open?(0,U.jsx)(Oe,{state:r.state,currentCommit:s?.stats.commitSha,hasLocalChanges:s?.stats.workingTree===`changed`,shareButtonRef:d,onClose:r.close,onConnect:!e.status||[`disconnected`,`pairing`,`unconfigured`].includes(e.status.state)?()=>{r.close(),t.show()}:void 0,onRefresh:()=>void r.refresh(),onCreate:r.create,onDelete:r.remove,onOpen:(e,t)=>void r.openLink(e,t),controlSettings:a,onAuthorize:()=>void r.authorize()}):null,l&&v?(0,U.jsx)(ue,{state:v,titleButtonRef:h,onClose:u}):null]})}function Ne({address:e,addressRef:t,canGoBack:n,canGoForward:i,appearance:a,onAppearanceChange:o,onBack:s,onForward:c,onNavigate:l,onOpenTab:u,onReload:d}){let[f,p]=(0,V.useState)(null),m=f?.address===e?f.value:e,h=f?.address===e?f.error:``;function g(t){t.preventDefault();try{let t=new URL(m.trim(),e);if(![`http:`,`https:`].includes(t.protocol)||t.origin!==new URL(e).origin||t.username||t.password){p({address:e,value:m,error:K.browserAddressOrigin});return}p(null),l(t.href)}catch{p({address:e,value:m,error:K.browserAddressInvalid})}}return(0,U.jsx)(H.ThemeProvider,{colorMode:`auto`,className:`canvas-browser-theme`,children:(0,U.jsxs)(`nav`,{className:`canvas-browser-bar`,"aria-label":K.browserNavigation,children:[(0,U.jsxs)(`div`,{className:`canvas-browser-bar__navigation`,children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":K.browserBack,disabled:!n,onClick:s,children:(0,U.jsx)(r,{size:16})}),(0,U.jsx)(`button`,{type:`button`,"aria-label":K.browserForward,disabled:!i,onClick:c,children:(0,U.jsx)(oe,{size:16})}),(0,U.jsx)(`button`,{type:`button`,"aria-label":K.browserReload,onClick:d,children:(0,U.jsx)(L,{size:16})})]}),(0,U.jsxs)(`form`,{className:`canvas-browser-bar__address`,onSubmit:g,children:[(0,U.jsx)(`input`,{ref:t,"aria-label":K.browserAddress,"aria-invalid":!!h,"aria-describedby":h?`canvas-browser-address-error`:void 0,spellCheck:!1,value:m,onChange:t=>{p({address:e,value:t.target.value,error:``})},onFocus:e=>e.currentTarget.select(),onKeyDown:e=>{e.key===`Escape`&&(p(null),e.currentTarget.blur())}}),h?(0,U.jsx)(`span`,{id:`canvas-browser-address-error`,className:`canvas-browser-bar__error`,role:`alert`,children:h}):null]}),(0,U.jsxs)(`div`,{className:`canvas-browser-bar__tools`,children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":K.browserOpenTab,title:K.browserOpenTab,onClick:()=>{u().catch(t=>{p({address:e,value:m,error:t instanceof Error?t.message:String(t)})})},children:(0,U.jsx)(v,{size:16})}),(0,U.jsxs)(`div`,{className:`canvas-browser-bar__appearance`,role:`group`,"aria-label":K.browserAppearance,children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":K.browserLight,"aria-pressed":a===`light`,onClick:()=>o(`light`),children:(0,U.jsx)(P,{size:16})}),(0,U.jsx)(`button`,{type:`button`,"aria-label":K.browserDark,"aria-pressed":a===`dark`,onClick:()=>o(`dark`),children:(0,U.jsx)(ie,{size:16})})]})]})]})})}var Pe=e(t((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t}));e.validateShape=N;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern "^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern "^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return I.errors=a,o===0}e.number=L;function L(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return L.errors=a,l===0}e.slider=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return R.errors=a,l===0}e.choice=z;function z(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return z.errors=a,o===0}e.checkboxGroup=te;function te(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return te.errors=a,o===0}e.text=B;function B(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return B.errors=a,l===0}e.color=ne;function ne(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ne.errors=a,o===0}e.button=re;function re(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return re.errors=a,o===0}}))(),1),{validateDocumentShape:Z,validateDeclaration:Fe}=Pe.default,Ie={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function Le(e){let t=[...Fe.errors].filter(e=>!/^\/controls\/\d+(?:\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(Ie,e?.type)?Ie[e.type]:void 0,i=r&&Pe.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params}))}var Re=class extends Error{constructor(e){super(`Invalid controls.replica.json:\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(` +`)}`),this.name=`ControlsValidationError`,this.issues=e}};function ze(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function Be(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(Be):[]}function Ve(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=new Set,i=new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new Re([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...Be(s.when),...Be(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function He(e){let t=new Set;function n(e,r=0){if(r>24)throw new Re([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new Re([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new Re([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new Re([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new Re([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function Ue(e){if(He(e),!Fe(e))throw new Re(Le(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=ze(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=ze(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new Re(t);return Ve(e),e}function We(e,t){let[n,r]=(0,V.useState)(e),[i,a]=(0,V.useState)(null),o=(0,V.useRef)(e),s=(0,V.useRef)(e),c=(0,V.useRef)(0),l=(0,V.useRef)(!1);(0,V.useLayoutEffect)(()=>{s.current=e,l.current||(o.current=e,r(e))},[e]),(0,V.useLayoutEffect)(()=>()=>{c.current++},[]);function u(e){c.current++,l.current=!0,o.current=e,r(e),a(null)}function d(){c.current++,l.current=!1,o.current=s.current,r(s.current),a(null)}function f(e,n=e){u(e);let i=c.current;Promise.resolve().then(()=>t(n)).then(e=>{c.current===i&&(l.current=!1,o.current=e&&`value`in e?e.value:s.current,r(o.current))}).catch(()=>{c.current===i&&(d(),a(K.controlsValueNotApplied))})}return{draft:n,error:i,current:()=>o.current,stage:u,commit:f,reset:d}}function Ge(e){let t=e.step??1,n=Math.max(...[e.min,e.max,t].map(e=>{let[t=``,n=`0`]=String(e).split(`e`);return Math.max(0,(t.split(`.`)[1]?.length??0)-Number(n))})),r=Math.max(...[e.min,e.max].map(e=>n<=100?e.toFixed(n).length:String(e).length),String(e.default).length,String(t).length);return e.type===`slider`?`calc(${r}ch + var(--hub-space-8) * 2)`:`calc(${r}ch + var(--hub-space-8) * 2 + 1.25rem)`}function Ke({id:e,control:t,value:n,disabled:r,message:i,onCommit:a}){let o=We(n,a),[s,c]=(0,V.useState)(null);function l(e){let n=e.target.value,r=t.type===`number`||t.type===`slider`?n===``?NaN:Number(n):n,i=ze(t,r);c(i),i?o.stage(n):o.commit(n,r)}let u=s||o.error,d=t.type===`number`||t.type===`slider`,f=t.type===`slider`?{"--controls-slider-progress":`${t.min===t.max?100:(Number(n)-t.min)/(t.max-t.min)*100}%`}:void 0,p=[i?`${e}-hint`:void 0,u?`${e}-validation`:void 0].filter(Boolean).join(` `)||void 0,m={id:e,disabled:r,value:String(o.draft),onChange:l,"aria-invalid":u?!0:void 0,"aria-describedby":p,onBlur:()=>{s&&(o.reset(),c(null))}},h;return h=t.type===`textarea`?(0,U.jsx)(H.Textarea,{...m,rows:2,resize:`vertical`}):d?(0,U.jsx)(H.TextInput,{...m,className:t.type===`slider`?`controls-number-input controls-number-input--slider`:`controls-number-input`,type:`number`,min:t.min,max:t.max,step:t.step??1,validationStatus:u?`error`:void 0,"aria-labelledby":`${e}-label`,style:{width:Ge(t)}}):t.type===`color`?(0,U.jsx)(`input`,{...m,className:`controls-native-color`,type:`color`}):(0,U.jsx)(H.TextInput,{...m,type:`text`}),(0,U.jsxs)(H.FormControl,{id:e,className:d?`controls-field controls-field--${t.type}`:`controls-field`,fullWidth:!d||t.type===`slider`,validationStatus:u?`error`:void 0,children:[d?(0,U.jsxs)(`div`,{className:`controls-field-heading`,children:[(0,U.jsx)(H.FormControl.Label,{id:`${e}-label`,htmlFor:e,className:`controls-field-label`,children:t.label}),t.type===`slider`?(0,U.jsxs)(`div`,{className:`controls-slider-row`,children:[(0,U.jsx)(`input`,{...m,id:`${e}-slider`,value:String(n),className:`controls-native-slider`,type:`range`,style:f,min:t.min,max:t.max,step:t.step??1,"aria-labelledby":`${e}-label`}),h]}):h]}):(0,U.jsx)(H.FormControl.Label,{className:`controls-field-label`,children:t.label}),d?null:h,i?(0,U.jsx)(H.FormControl.Hint,{children:(0,U.jsx)(`span`,{role:`status`,children:i})}):null,u?(0,U.jsx)(H.FormControl.Validation,{className:`controls-field-validation`,"aria-live":`polite`,children:u}):null]})}function qe({id:e,control:t,value:n,disabled:r,message:i,onCommit:a}){let o=We(n,a),s=[i?`${e}-unavailable`:void 0,o.error?`${e}-validation`:void 0].filter(Boolean).join(` `)||void 0;if(t.type===`boolean`||t.type===`select`)return(0,U.jsxs)(H.FormControl,{id:e,className:t.type===`boolean`?`controls-field controls-choice-row`:`controls-field controls-field--select`,fullWidth:t.type===`boolean`,validationStatus:o.error?`error`:void 0,children:[t.type===`select`?(0,U.jsx)(H.FormControl.Label,{className:`controls-field-label`,children:t.label}):null,t.type===`boolean`?(0,U.jsx)(H.Checkbox,{className:`controls-choice-mark`,disabled:r,"aria-describedby":s,checked:o.draft===!0,onChange:e=>o.commit(e.target.checked)}):(0,U.jsx)(H.Select,{className:`controls-select-input`,disabled:r,"aria-describedby":s,value:o.draft,onChange:e=>o.commit(e.target.value),children:t.options.map(e=>(0,U.jsx)(H.Select.Option,{value:e,children:e},e))}),t.type===`boolean`?(0,U.jsx)(H.FormControl.Label,{className:`controls-choice-label`,children:t.label}):null,i?(0,U.jsx)(H.FormControl.Hint,{children:(0,U.jsx)(`span`,{role:`status`,children:i})}):null,o.error?(0,U.jsx)(H.FormControl.Validation,{className:`controls-field-validation`,"aria-live":`polite`,children:o.error}):null]});let c=t.type===`checkboxGroup`,l=t.type===`segmented`,u=c?H.CheckboxGroup:H.RadioGroup,d=c?H.Checkbox:H.Radio;return(0,U.jsxs)(u,{id:e,className:`controls-field`,"aria-disabled":r||void 0,"aria-describedby":s,children:[(0,U.jsx)(u.Label,{className:`controls-choice-group-label`,children:t.label}),(0,U.jsx)(`div`,{className:l?`controls-segments`:`controls-options`,children:t.options.map((t,n)=>{let i=`${e}-${n}`,a=c?o.draft.includes(t):o.draft===t,u=(0,U.jsx)(d,{className:c?`controls-choice-mark`:`controls-choice-mark controls-choice-mark--radio`,id:i,name:e,value:t,checked:a,disabled:r,"aria-describedby":s,onChange:e=>{let n=o.current();o.commit(c?e.target.checked?[...n,t]:n.filter(e=>e!==t):t)}});return l?(0,U.jsxs)(`label`,{htmlFor:i,className:`controls-segment`,title:t,children:[(0,U.jsx)(W,{children:u}),(0,U.jsx)(H.Text,{as:`span`,size:`100`,weight:`medium`,children:t})]},t):(0,U.jsxs)(H.FormControl,{id:i,className:`controls-field controls-choice-row`,children:[u,(0,U.jsx)(H.FormControl.Label,{className:`controls-choice-label`,children:t})]},t)})}),i?(0,U.jsx)(H.Text,{as:`span`,id:`${e}-unavailable`,size:`100`,variant:`muted`,role:`status`,children:i}):null,o.error?(0,U.jsx)(u.Validation,{variant:`error`,role:`status`,children:o.error}):null]})}function Je(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?K.controlsActionUnavailable:``)}}function Ye({scopes:e,disabled:t=!1,onCommand:n,collapsedGroups:r,onGroupCollapse:i}){let a=(0,V.useId)(),o=(0,V.useRef)(null),s=(0,V.useRef)(null),[c,l]=(0,V.useState)({});(0,V.useLayoutEffect)(()=>{s.current&&!s.current.isConnected&&(document.activeElement===document.body&&o.current?.focus(),s.current=null)},[e]);function u(e,r){if(!e.snapshot.visible[r.id])return null;let i=`${a}-${e.declaration.scope}-${r.id}`,o=e.snapshot.values[r.id];function s(t){return n(`update`,e.declaration.scope,r.id,t)}let c=e.snapshot.bindings?.[r.id],l=Je(e,r),u={id:i,message:l.error?l.available?K.controlsNotApplied(r.label):K.controlsUnavailable(r.label):void 0,disabled:t||!!c?.error&&c?.available!==!0||c?.busy===!0};switch(r.type){case`button`:{let t=e.snapshot.actions[r.id];return(0,U.jsx)(`div`,{className:`controls-field controls-action-field`,children:(0,U.jsxs)(H.Button,{type:`button`,size:`small`,variant:`secondary`,className:`controls-action-button`,disabled:u.disabled||!t?.available||t.busy,"aria-describedby":u.message?`${i}-unavailable`:void 0,"aria-busy":t?.busy,onClick:()=>{n(`action`,e.declaration.scope,r.id)},children:[r.label,t?.busy?K.controlsActionBusy:``]})},r.id)}case`boolean`:case`select`:case`radio`:case`segmented`:case`checkboxGroup`:return(0,U.jsx)(qe,{...u,control:r,value:o,onCommit:s},r.id);case`number`:case`slider`:case`text`:case`textarea`:case`color`:return(0,U.jsx)(Ke,{...u,control:r,value:o,onCommit:s},r.id)}}function d(e,t){if(!e.snapshot.visible[t.id])return null;let n=Je(e,t);return(0,U.jsxs)(V.Fragment,{children:[u(e,t),t.type===`button`&&n.error?(0,U.jsx)(H.Text,{as:`p`,id:`${a}-${e.declaration.scope}-${t.id}-unavailable`,size:`100`,variant:`muted`,role:`status`,children:n.available?K.controlsNotApplied(t.label):K.controlsUnavailable(t.label)}):null]},t.id)}let f=[...e.filter(e=>e.declaration.role===`shared`),...e.filter(e=>e.declaration.role!==`shared`)].filter(e=>e.declaration.controls.some(t=>t.group?e.snapshot.groups[t.group]:e.snapshot.visible[t.id]));return(0,U.jsx)(`div`,{ref:o,tabIndex:-1,role:`region`,"aria-label":K.controlsRegion,className:`controls-fields`,onFocusCapture:e=>{s.current=e.target},children:f.map((e,t)=>{let n=new Set;return(0,U.jsxs)(`section`,{className:`controls-scope`,"aria-label":e.declaration.label??e.declaration.scope,children:[t>0?(0,U.jsx)(`hr`,{className:`controls-scope-divider`}):null,e.declaration.controls.map(t=>{if(!t.group)return d(e,t);if(n.has(t.group))return null;n.add(t.group);let o=e.declaration.groups?.find(e=>e.id===t.group);if(!o||!e.snapshot.groups[o.id])return null;let s=`${e.declaration.scope}/${o.id}`,u=(r??c)[s]===!0,f=`${a}-${e.declaration.scope}-${o.id}-group`;return(0,U.jsxs)(`fieldset`,{className:`controls-group`,"aria-label":o.label,children:[(0,U.jsx)(`legend`,{children:(0,U.jsx)(H.Button,{size:`small`,variant:`subtle`,type:`button`,block:!0,className:`controls-group-toggle controls-ghost-button`,"aria-label":u?K.controlsExpandGroup(o.label):K.controlsCollapseGroup(o.label),"aria-controls":f,"aria-expanded":!u,trailingVisual:u?(0,U.jsx)(m,{size:16}):(0,U.jsx)(g,{size:16}),onClick:t=>{t.currentTarget.focus(),i?i(e.declaration.scope,o.id,!u):l(e=>({...e,[s]:!u}))},children:(0,U.jsx)(H.Text,{as:`span`,size:`100`,weight:`bold`,variant:`muted`,className:`controls-group-label`,children:o.label})})}),(0,U.jsx)(`div`,{id:f,className:`controls-group-body`,hidden:u,children:e.declaration.controls.filter(e=>e.group===o.id).map(t=>d(e,t))})]},o.id)})]},e.declaration.scope)})})}function Xe(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}function Ze(e,t){let n=(0,V.useRef)(null),r=(0,V.useRef)(null),i=(0,V.useRef)(null),a=(0,V.useRef)({position:e,onChange:t}),o=(0,V.useRef)(null),[s,c]=(0,V.useState)(!1);(0,V.useLayoutEffect)(()=>{a.current={position:e,onChange:t}});let l=(0,V.useCallback)(e=>{let t=n.current?.getBoundingClientRect(),i=r.current?.getBoundingClientRect();if(!t||!i||!t.width||!t.height)return;let o={x:Math.max(0,Math.min(e.x,Math.max(0,t.width-i.width))),y:Math.max(0,Math.min(e.y,Math.max(0,t.height-i.height)))};(a.current.position?.x!==o.x||a.current.position?.y!==o.y)&&a.current.onChange(o)},[]);(0,V.useLayoutEffect)(()=>{let e=n.current,t=r.current;if(!e||!t)return;function i(){let n=e?.getBoundingClientRect(),r=t?.getBoundingClientRect();if(!n||!r||!n.width||!n.height)return;let i=r.left-n.left,a=r.top-n.top;(i<0||a<0||i>Math.max(0,n.width-r.width)||a>Math.max(0,n.height-r.height))&&l({x:i,y:a})}let a=new ResizeObserver(i);return a.observe(e),a.observe(t),window.addEventListener(`resize`,i),i(),()=>{a.disconnect(),window.removeEventListener(`resize`,i)}},[l]);function u(e=!1){let t=o.current;o.current=null,c(!1),t&&(e&&l(t.origin),i.current?.hasPointerCapture(t.pointerId)&&i.current.releasePointerCapture(t.pointerId))}return{boundsRef:n,panelRef:r,handleRef:i,dragging:s,onPointerDown:e=>{if(e.button!==0||o.current)return;let t=n.current?.getBoundingClientRect(),i=r.current?.getBoundingClientRect();t&&i&&(o.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,origin:{x:i.left-t.left,y:i.top-t.top}},e.currentTarget.setPointerCapture(e.pointerId),e.currentTarget.focus(),e.preventDefault(),c(!0))},onPointerMove:e=>{let t=o.current;t&&t.pointerId===e.pointerId&&l({x:t.origin.x+e.clientX-t.x,y:t.origin.y+e.clientY-t.y})},onPointerUp:e=>{o.current?.pointerId===e.pointerId&&u()},onPointerCancel:e=>{o.current?.pointerId===e.pointerId&&u(!0)},onLostPointerCapture:()=>{o.current&&u()},onKeyDown:e=>{if(e.key===`Escape`&&o.current){e.preventDefault(),u(!0);return}if(![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(e.key))return;let t=n.current?.getBoundingClientRect(),i=r.current?.getBoundingClientRect();if(!t||!i)return;e.preventDefault();let a=e.shiftKey?1:10;l({x:i.left-t.left+(e.key===`ArrowLeft`?-a:e.key===`ArrowRight`?a:0),y:i.top-t.top+(e.key===`ArrowUp`?-a:e.key===`ArrowDown`?a:0)})}}}function Qe(e){let t=e.filter(e=>e.declaration.role!==`shared`),n=t.length?t:e;return n.length?Math.max(...n.map(e=>e.declaration.panel?.width??288)):288}function $e({state:e,connection:t,layout:n,onLayoutChange:r,onDiagnose:i,diagnosisTarget:a=``}){let s=e.loading?[]:e.scopes.flatMap(e=>e.declaration.controls.flatMap(t=>{let n=Je(e,t);return n.visible&&n.error?[{...n,label:t.label}]:[]})),c=!!(i&&!e.loading&&(!e.runtimeAvailable&&e.error||e.storageError||s.length||e.reconnectRequired||e.status===`missing-runtime`||e.status===`unsupported-runtime`||e.status===`invalid-config`)),l=c?JSON.stringify([a,e.status,e.runtimeAvailable,e.reconnectRequired,e.error,e.storageError,s.map(({scope:e,id:t,error:n})=>[e,t,n])]):``,[u,d]=(0,V.useState)(()=>({episode:l,identity:{},busy:!1,requested:!1,error:``}));u.episode!==l&&d({episode:l,identity:{},busy:!1,requested:!1,error:``});async function f(){if(!i||!c||u.busy||u.requested)return;let e=u.identity;d(t=>t.identity===e?{...t,busy:!0,error:``}:t);try{await i(),d(t=>t.identity===e?{...t,requested:!0}:t)}catch(t){d(n=>n.identity===e?{...n,error:t instanceof Error?t.message:K.controlsDiagnosisFailed}:n)}finally{d(t=>t.identity===e?{...t,busy:!1}:t)}}let m=(0,V.useId)(),h=(0,V.useId)(),_=(0,V.useRef)(null),{boundsRef:v,panelRef:y,handleRef:b,dragging:x,onPointerDown:S,onPointerMove:C,onPointerUp:w,onPointerCancel:T,onLostPointerCapture:E,onKeyDown:D}=Ze(n.position,e=>r(t=>({...t,position:e})));(0,V.useEffect)(()=>{b.current?.focus()},[b]),(0,V.useLayoutEffect)(()=>{_.current&&!_.current.isConnected&&(document.activeElement===document.body&&b.current?.focus(),_.current=null)},[e,b]);let O=e.loading?K.controlsConnecting:e.status===`no-controls`?K.controlsEmpty:e.status===`missing-runtime`?i?K.controlsLocalMissingRuntime:K.controlsMissingRuntime:e.status===`unsupported-runtime`?K.controlsUnsupportedRuntime:e.status===`invalid-config`?K.controlsInvalid:``,k=!e.loading&&(e.storageError||e.reconnectRequired||!e.runtimeAvailable&&e.error);return(0,U.jsx)(`div`,{ref:v,className:`canvas-controls-layer`,children:(0,U.jsxs)(`aside`,{ref:y,className:`canvas-controls-panel`,"aria-label":K.controls,onFocusCapture:e=>{e.target instanceof HTMLElement&&(_.current=e.target)},"data-collapsed":n.collapsed,"data-dragging":x||void 0,style:{left:n.position?.x,top:n.position?.y,width:`min(${Qe(e.scopes)}px, calc(100% - var(--hub-space-16) * 2))`},children:[(0,U.jsxs)(`header`,{className:`canvas-controls-header`,children:[(0,U.jsx)(G,{icon:o,ref:b,size:`small`,variant:`invisible`,className:`canvas-controls-grab controls-ghost-button`,"aria-label":K.controlsMove,"aria-describedby":h,title:``,onPointerDown:S,onPointerMove:C,onPointerUp:w,onPointerCancel:T,onLostPointerCapture:E,onKeyDown:D}),(0,U.jsx)(W,{id:h,children:K.controlsMoveHint}),(0,U.jsx)(H.Button,{type:`button`,size:`small`,variant:`subtle`,block:!0,className:`canvas-controls-title controls-ghost-button`,"aria-label":n.collapsed?K.controlsExpand:K.controlsCollapse,"aria-expanded":!n.collapsed,"aria-controls":m,trailingVisual:n.collapsed?(0,U.jsx)(g,{size:16}):(0,U.jsx)(p,{size:16}),onClick:()=>r(e=>({...e,collapsed:!e.collapsed})),children:K.controls}),(0,U.jsx)(G,{icon:L,size:`small`,variant:`invisible`,className:`controls-ghost-button`,"aria-label":K.controlsResetAll,disabled:!e.runtimeAvailable||e.reconnectRequired||e.loading||e.resetting||!e.storageError&&!e.hasResettableValues&&!e.scopes.some(e=>Object.keys(Xe(e)).length>0)||e.scopes.some(e=>Object.values(e.snapshot.actions).some(e=>e.busy))||e.status!==`ready`&&e.status!==`no-controls`&&!e.storageError,onClick:()=>{t.resetAll()}})]}),(0,U.jsxs)(`div`,{id:m,className:`canvas-controls-body`,hidden:n.collapsed,children:[(0,U.jsxs)(`div`,{className:`canvas-controls-content`,children:[O||e.notice?(0,U.jsx)(`div`,{role:`status`,"aria-live":`polite`,children:(0,U.jsx)(H.Text,{as:`p`,size:`100`,variant:`muted`,children:[O,e.notice].filter(Boolean).join(` `)})}):null,!e.loading&&e.error?(0,U.jsx)(H.Text,{as:`p`,size:`100`,role:`alert`,children:e.error}):null,!e.loading&&e.scopeErrors?.map(e=>(0,U.jsx)(H.Text,{as:`p`,size:`100`,role:`alert`,children:K.controlsScopeError(e.scope,e.error)},e.scope)),!e.loading&&e.storageError?(0,U.jsx)(H.Text,{as:`p`,size:`100`,role:`alert`,children:e.storageError}):null,u.error?(0,U.jsx)(H.Text,{as:`p`,size:`100`,role:`alert`,children:u.error}):null,(0,U.jsx)(Ye,{scopes:e.loading?[]:e.scopes,disabled:e.resetting||e.reconnectRequired,collapsedGroups:n.collapsedGroups,onGroupCollapse:(e,t,n)=>r(r=>({...r,collapsedGroups:{...r.collapsedGroups,[`${e}/${t}`]:n}})),onCommand:(e,n,r,i)=>t.command(e,n,r,i)}),s.length?(0,U.jsxs)(H.Accordion,{className:`canvas-controls-diagnostics`,disableAnimation:!0,children:[(0,U.jsx)(H.Accordion.Heading,{children:K.controlsDiagnostics}),(0,U.jsx)(H.Accordion.Content,{children:s.map(({scope:e,id:t,label:n,error:r})=>(0,U.jsxs)(H.Text,{as:`p`,size:`100`,children:[n,`: `,r]},`${e}/${t}`))})]}):null]}),c||k?(0,U.jsxs)(`footer`,{className:`canvas-controls-footer`,children:[c?(0,U.jsx)(H.Button,{size:`small`,variant:`secondary`,type:`button`,disabled:u.busy||u.requested||e.resetting,onClick:()=>void f(),children:u.requested?K.controlsDiagnosisRequested:s.length?K.controlsFix:K.controlsDiagnose}):null,k?(0,U.jsx)(H.Button,{size:`small`,variant:`secondary`,type:`button`,disabled:e.resetting,onClick:()=>t.retry(),children:e.storageError?K.controlsRetryStorage:K.controlsRetry}):null]}):null]})]})})}var et=c();function tt({children:e,className:t,...n}){return(0,U.jsx)(`span`,{...n,className:`hub-counter${t?` ${t}`:``}`,children:e})}var nt=(0,V.createContext)(null);function rt({source:e,children:t}){return(0,U.jsx)(nt,{value:e,children:t})}function it({title:e,label:t=e,open:n,closeLabel:r,closeDisabled:i=!1,closeShortcut:a,closeRef:o,onClose:s,headerAccessory:c,className:l,contentClassName:u,children:d}){return(0,U.jsxs)(`aside`,{className:`hub-sidebar${l?` ${l}`:``}`,"aria-label":t,"aria-hidden":!n,"data-open":n,inert:!n,children:[(0,U.jsxs)(`header`,{className:`hub-sidebar__header`,children:[(0,U.jsxs)(`div`,{className:`hub-sidebar__heading`,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`subhead-medium`,weight:`normal`,children:e}),c]}),(0,U.jsx)(G,{ref:o,icon:B,"aria-label":r,"aria-keyshortcuts":a,title:r,description:r,variant:`invisible`,size:`small`,className:`hub-sidebar__close`,disabled:i,onClick:s})]}),(0,U.jsx)(`div`,{className:`hub-sidebar__content${u?` ${u}`:``}`,children:d})]})}function at({src:e,size:t=32,className:n}){return(0,U.jsx)(H.Avatar,{src:e||`/avatar-placeholder.svg`,alt:``,size:32,className:`hub-user-avatar hub-user-avatar--${t}${n?` ${n}`:``}`})}function ot({participants:e,size:t}){let n=e.slice(0,4),r=e.length-3;return(0,U.jsxs)(`span`,{className:`review-participant-stack review-participant-stack--${t}`,"data-avatar-count":n.length,"data-participant-count":e.length,"aria-hidden":`true`,children:[(r>1?n.slice(0,3):n).map(e=>(0,U.jsx)(`span`,{className:`review-participant-stack__avatar`,children:(0,U.jsx)(at,{src:e.avatarUrl,size:24})},e.login)),r>1?(0,U.jsxs)(`span`,{className:`review-participant-stack__avatar review-participant-stack__avatar--overflow`,children:[`+`,r]}):null]})}function st(e,t){let n=e.path.map(e=>({x:t.x+e.x*t.width,y:t.y+e.y*t.height})),r={x:t.x+t.width,y:t.y};return{path:n,point:n.reduce((e,t)=>{let n=(t.x-r.x)**2+(t.y-r.y)**2;return n{let e=c.current;if(!e)return;function t(){let t=e?.clientWidth??0;if(t)for(let e of l.current.values()){let n=Number.parseFloat(e.style.left),r=e.offsetWidth;if(!Number.isFinite(n)||!r)continue;let i=n-16,a=Math.max(0,Math.min(i,t-r))-i;e.style.setProperty(`--review-marker-offset-x`,`${a}px`)}}t();let n=typeof ResizeObserver>`u`?null:new ResizeObserver(t);n?.observe(e);for(let e of l.current.values())n?.observe(e);return window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[t,e]),(0,V.useEffect)(()=>{!i||n===null||u!==`resolved`&&u!==`moved`||l.current.get(n)?.focus({preventScroll:!0})},[i,u,n]),(0,U.jsx)(`div`,{ref:c,className:`review-comment-markers`,role:`group`,"aria-label":o.heading,children:e.map(e=>{let{root:i}=e,c=t.get(i.id);if(!c||c.status!==`resolved`&&c.status!==`moved`)return null;let u=e.replies.length>0,d=(e.unread?u?o.unreadMarkerWithRepliesLabel:o.unreadMarkerLabel:u?o.markerWithRepliesLabel:o.markerLabel).replace(`%{author}`,`@${i.author.login}`).replace(`%{count}`,(e.replies.length+1).toString()),f=i.anchor.kind===`area`?st(i.anchor,c.rect):null,p=e.participants.slice(3),m=p.length>1?p.map(({login:e})=>`@${e}`).join(`, `):d;return(0,U.jsxs)(V.Fragment,{children:[f&&(!a||n===i.id)?(0,U.jsx)(`svg`,{className:`review-comment-area`,"aria-hidden":`true`,width:`100%`,height:`100%`,children:(0,U.jsx)(`polyline`,{className:n===i.id?`review-comment-area__path review-comment-area__path--selected`:`review-comment-area__path`,points:f.path.map(e=>`${e.x},${e.y}`).join(` `),vectorEffect:`non-scaling-stroke`})}):null,(0,U.jsx)(H.Tooltip,{text:m,type:`description`,ref:e=>{e instanceof HTMLButtonElement?l.current.set(i.id,e):l.current.delete(i.id)},children:(0,U.jsx)(`button`,{type:`button`,"data-review-thread-id":i.id,className:`review-comment-marker${n===i.id?` review-comment-marker--selected`:``}${i.resolvedAt?` review-comment-marker--resolved`:``}${e.unread?` review-comment-marker--unread`:``}${r&&n!==i.id?` review-comment-marker--blocked`:``}`,style:{left:f?.point.x??c.point.x,top:f?.point.y??c.point.y},"aria-label":d,disabled:r&&n!==i.id,onClick:()=>s(e),children:(0,U.jsx)(ot,{participants:e.participants,size:`small`})})})]},i.id)})})}function lt({checked:e,onChange:t,size:n=`medium`,className:r,...i}){let{value:a,...o}=i;return(0,U.jsxs)(`label`,{className:`hub-switch hub-switch--${n}${r?` ${r}`:``}`,"data-disabled":i.disabled||void 0,children:[(0,U.jsx)(`span`,{className:`hub-switch__native-control`,children:(0,U.jsx)(H.Checkbox,{...o,value:a===void 0?void 0:String(a),role:`switch`,checked:e,onChange:e=>{i.disabled||t(e.currentTarget.checked)}})}),(0,U.jsx)(`span`,{className:`hub-switch__track`,"data-checked":e,"aria-hidden":`true`,children:(0,U.jsx)(`span`,{className:`hub-switch__thumb`})})]})}function ut(e){(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.click())}function dt({filters:e,participants:t,showPins:n,copy:r,onFiltersChange:i,onShowPinsChange:a}){let[o,s]=(0,V.useState)(!1),c=e.currentBuildOnly||e.currentPageOnly||e.showResolved||!e.showRead||e.onlyMine||e.participant!==null||!n,l=t.find(t=>t.login===e.participant),u=e.participant===null?r.allParticipantsLabel:l?.name?`${l.name} (@${l.login})`:`@${e.participant}`;return(0,U.jsxs)(`div`,{className:`review-comment-filter-controls`,children:[(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__search`,children:[(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__search-field`,children:[(0,U.jsx)(ne,{className:`review-comment-filter-controls__search-icon`,size:16,"aria-hidden":`true`}),(0,U.jsx)(`input`,{type:`search`,className:`review-comment-filter-controls__input`,"aria-label":r.searchLabel,placeholder:r.searchPlaceholder,value:e.search,onChange:t=>i({...e,search:t.target.value})})]}),(0,U.jsx)(G,{icon:h,"aria-label":r.filterLabel,description:r.filterLabel,"aria-expanded":o,variant:`invisible`,className:`review-comment-filter-controls__button${o||c?` review-comment-filter-controls__button--active`:``}`,onClick:()=>s(e=>!e)})]}),o?(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__filters`,children:[(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__participant`,children:[(0,U.jsx)(`span`,{children:r.participantFilterLabel}),(0,U.jsxs)(H.ActionMenu,{size:`small`,selectionVariant:`single`,menuAlignment:`end`,onSelect:t=>i({...e,participant:t===``?null:t}),children:[(0,U.jsx)(H.ActionMenu.Button,{className:`review-comment-filter-controls__participant-trigger`,variant:`secondary`,size:`small`,"aria-label":`${r.participantFilterLabel}: ${u}`,children:(0,U.jsx)(`span`,{className:`review-comment-filter-controls__participant-name`,children:u})}),(0,U.jsxs)(H.ActionMenu.Overlay,{"aria-label":r.participantFilterLabel,children:[(0,U.jsx)(H.ActionMenu.Item,{value:``,selected:e.participant===null,role:`menuitemradio`,onKeyDownCapture:ut,children:r.allParticipantsLabel}),t.map(t=>(0,U.jsx)(H.ActionMenu.Item,{value:t.login,selected:e.participant===t.login,role:`menuitemradio`,onKeyDownCapture:ut,children:t.name?`${t.name} (@${t.login})`:`@${t.login}`},t.login))]})]})]}),(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__toggle`,children:[(0,U.jsx)(`span`,{id:`review-comments-current-build`,children:r.currentBuildFilterLabel}),(0,U.jsx)(lt,{"aria-labelledby":`review-comments-current-build`,checked:e.currentBuildOnly,size:`small`,onChange:t=>i({...e,currentBuildOnly:t})})]}),(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__toggle`,children:[(0,U.jsx)(`span`,{id:`review-comments-current-page`,children:r.currentPageFilterLabel}),(0,U.jsx)(lt,{"aria-labelledby":`review-comments-current-page`,checked:e.currentPageOnly,size:`small`,onChange:t=>i({...e,currentPageOnly:t})})]}),(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__toggle`,children:[(0,U.jsx)(`span`,{id:`review-comments-show-resolved`,children:r.showResolvedLabel}),(0,U.jsx)(lt,{"aria-labelledby":`review-comments-show-resolved`,checked:e.showResolved,size:`small`,onChange:t=>i({...e,showResolved:t})})]}),(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__toggle`,children:[(0,U.jsx)(`span`,{id:`review-comments-unread-only`,children:r.unreadOnlyLabel}),(0,U.jsx)(lt,{"aria-labelledby":`review-comments-unread-only`,checked:!e.showRead,size:`small`,onChange:t=>i({...e,showRead:!t})})]}),(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__toggle`,children:[(0,U.jsx)(`span`,{id:`review-comments-only-mine`,children:r.onlyMineLabel}),(0,U.jsx)(lt,{"aria-labelledby":`review-comments-only-mine`,checked:e.onlyMine,size:`small`,onChange:t=>i({...e,onlyMine:t})})]}),(0,U.jsxs)(`div`,{className:`review-comment-filter-controls__toggle`,children:[(0,U.jsx)(`span`,{id:`review-comments-show-pins`,children:r.showPinsLabel}),(0,U.jsx)(lt,{"aria-labelledby":`review-comments-show-pins`,checked:n,size:`small`,onChange:a})]})]}):null]})}var ft=[[31536e3,`y`],[2592e3,`mo`],[604800,`w`],[86400,`d`],[3600,`h`],[60,`m`]];function pt(e){let t=window.setInterval(e,6e4);return()=>window.clearInterval(t)}function mt(){return Math.floor(Date.now()/6e4)*6e4}function ht(){return null}function gt({value:e,showTitle:t=!0}){let n=Date.parse(e),r=Number.isNaN(n)?e:new Date(n).toUTCString(),i=(0,V.useSyncExternalStore)(pt,mt,ht),a=r;if(i!==null&&!Number.isNaN(n)){let e=Math.round((i-n)/1e3),t=ft.find(([t])=>Math.abs(e)>=t);a=t?`${e<0?`in `:``}${Math.round(Math.abs(e)/t[0])}${t[1]}${e<0?``:` ago`}`:`just now`}return(0,U.jsx)(`time`,{dateTime:e,title:t?r:void 0,"aria-label":r,children:a})}function _t({thread:e,currentBuildNumber:t,resolution:n,anchorStatusLabel:r,selected:i,selectionBlocked:a,copy:o,onSelect:s,buildHref:c}){let l=(0,V.useId)(),{root:u}=e,d=u.author.name||`@${u.author.login}`,f=a&&!i,p=o.buildLabel.replace(`%{number}`,u.buildNumber?.toString()??``),m=u.buildNumber!==null&&u.buildPath!==null&&u.buildNumber!==t,h=e.replies.length===1?o.replyCountOneLabel:o.replyCountOtherLabel.replace(`%{count}`,e.replies.length.toString()),g=o.missingAnchorLabel;return u.resolvedAt?g=o.resolvedLabel:r===void 0?n?n.status===`resolved`?g=null:n.status===`moved`?g=o.movedAnchorLabel:n.status===`changed`?g=o.changedAnchorLabel:n.status===`route-mismatch`&&(g=o.routeMismatchLabel):g=null:g=r,(0,U.jsx)(`article`,{className:`review-comment-row${i?` review-comment-row--selected`:``}${e.unread?` review-comment-row--unread`:``}`,onClick:t=>{f||t.target instanceof Element&&t.target.closest(`a`)||s(e)},children:(0,U.jsx)(`div`,{className:`review-comment-row__layout`,children:(0,U.jsxs)(`div`,{className:`review-comment-row__content`,children:[(0,U.jsxs)(`div`,{className:`review-comment-row__copy`,children:[(0,U.jsxs)(`div`,{className:`review-comment-row__metadata`,children:[(0,U.jsxs)(`span`,{className:`review-comment-row__author-and-build`,children:[(0,U.jsx)(at,{src:u.author.avatarUrl,size:20,className:`review-comment-row__avatar`}),(0,U.jsx)(`span`,{id:`${l}-author`,className:`review-comment-row__author`,children:d}),m?(0,U.jsxs)(`span`,{className:`review-comment-row__build`,children:[`(`,(0,U.jsx)(`a`,{href:c||u.buildPath||void 0,target:c?`_blank`:void 0,rel:c?`noopener noreferrer`:void 0,children:p}),`)`]}):null]}),(0,U.jsx)(gt,{value:e.lastActivityAt})]}),(0,U.jsx)(`button`,{type:`button`,className:`review-comment-row__button`,"aria-labelledby":`${l}-author ${l}-body${e.unread?` ${l}-unread`:``}`,"aria-pressed":i,disabled:f,title:f?o.selectionBlockedLabel:void 0,children:(0,U.jsxs)(`span`,{className:`review-comment-row__body-container`,children:[e.unread?(0,U.jsx)(`span`,{role:`img`,id:`${l}-unread`,"aria-label":o.unreadLabel,title:o.unreadLabel,className:`review-comment-row__unread`}):null,(0,U.jsx)(`span`,{id:`${l}-body`,className:`review-comment-row__body`,children:u.body??o.deletedCommentLabel})]})})]}),g||e.replies.length>0?(0,U.jsxs)(`div`,{className:`review-comment-row__context`,children:[e.replies.length>0?(0,U.jsx)(`span`,{className:`review-comment-row__replies`,children:h}):null,g?(0,U.jsx)(H.Label,{size:`small`,className:`review-comment-row__status`,children:g}):null]}):null]})})})}function vt({frame:e,threads:t,currentBuildNumber:n,buildLinkOrigin:r,totalCount:i,hasThreads:a,filters:o,participants:s,resolutions:c,selectedThreadId:l,selectionBlocked:u,closeBlocked:d,showPins:f,loading:p,loadFailed:m,notice:h,copy:g,onClose:_,onFiltersChange:v,onShowPinsChange:y,onRetry:b,onSelect:x}){let S=a?g.noMatchesLabel:g.emptyLabel,C=(0,U.jsxs)(U.Fragment,{children:[h,(0,U.jsx)(dt,{filters:o,participants:s,showPins:f,copy:g,onFiltersChange:v,onShowPinsChange:y}),(0,U.jsxs)(`div`,{className:`review-comments-sidebar__body`,"aria-live":`polite`,children:[m?(0,U.jsxs)(`div`,{className:`review-comments-sidebar__state`,role:`alert`,children:[(0,U.jsx)(`span`,{children:g.loadErrorLabel}),(0,U.jsx)(H.Button,{size:`small`,onClick:b,children:g.retryLabel})]}):t.length===0&&!p?(0,U.jsx)(`div`,{className:`review-comments-sidebar__state`,children:S}):(0,U.jsx)(`div`,{className:`review-comments-sidebar__threads`,children:t.map(e=>(0,U.jsx)(_t,{thread:e,currentBuildNumber:n,buildHref:r&&e.root.buildPath?new URL(e.root.buildPath,r).href:void 0,resolution:c.get(e.root.id),selected:l===e.root.id,selectionBlocked:u,copy:g,onSelect:x},e.root.id))}),p?(0,U.jsxs)(`div`,{className:`review-comments-sidebar__loading`,children:[(0,U.jsx)(ce,{decorative:!0,size:`small`}),(0,U.jsx)(`span`,{children:g.loadingLabel})]}):null]})]});return e?(0,U.jsx)(it,{...e,title:g.heading,closeLabel:g.closeLabel,closeDisabled:d,closeShortcut:`Shift+C`,onClose:_,headerAccessory:(0,U.jsx)(tt,{children:i}),children:C}):(0,U.jsxs)(`aside`,{className:`review-comments-sidebar`,"aria-label":g.heading,children:[(0,U.jsxs)(`header`,{className:`review-comments-sidebar__header`,children:[(0,U.jsxs)(`span`,{className:`review-comments-sidebar__heading`,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`6`,children:g.heading}),(0,U.jsx)(tt,{children:i})]}),(0,U.jsx)(G,{icon:B,"aria-label":g.closeLabel,"aria-keyshortcuts":`Shift+C`,description:g.closeLabel,size:`small`,variant:`invisible`,className:`review-comments-sidebar__close`,disabled:d,onClick:_})]}),C]})}function yt({bridgeReady:e,copy:t,selectionBlocked:n,selecting:r,onCancelSelection:i,onStartAreaSelection:a,onStartElementSelection:o}){let s=(0,V.useId)(),c=!e||n,l=e?n?t.selectionBlockedLabel:t.commentMenuLabel:t.bridgeUnavailableLabel;if(r)return(0,U.jsx)(G,{icon:B,"aria-label":t.cancelSelectionLabel,description:t.cancelSelectionLabel,"aria-pressed":!0,size:`small`,variant:`default`,className:`review-comment-control__trigger`,onClick:i});let u=(0,U.jsxs)(H.ActionMenu,{selectionVariant:`none`,size:`small`,menuAlignment:`start`,disabled:c,children:[(0,U.jsx)(H.ActionMenu.Button,{className:`review-comment-control__trigger`,variant:`secondary`,"aria-label":t.commentMenuLabel,"aria-describedby":s,leadingVisual:(0,U.jsx)(f,{size:16}),onClick:e=>{let t=e.currentTarget,n=t.closest(`.repository-workspace__content`)?.getBoundingClientRect(),r=Math.min(window.innerHeight,n?.bottom??window.innerHeight),i=Math.max(0,r-t.getBoundingClientRect().bottom-8);t.closest(`[data-testid="ActionMenu"]`)?.style.setProperty(`--review-comment-control-menu-height`,`${i}px`)},children:``}),(0,U.jsxs)(H.ActionMenu.Overlay,{"aria-label":t.commentMenuLabel,children:[(0,U.jsx)(H.ActionMenu.Item,{className:`review-comment-control__menu-item`,value:`element`,leadingVisual:(0,U.jsx)(M,{size:16}),"aria-keyshortcuts":`C`,onClick:o,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())},children:t.commentOnElementLabel}),(0,U.jsx)(H.ActionMenu.Item,{className:`review-comment-control__menu-item`,value:`area`,leadingVisual:(0,U.jsx)(T,{size:16}),"aria-keyshortcuts":`H`,onClick:a,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())},children:t.highlightRegionLabel})]})]});return c?(0,U.jsxs)(`div`,{title:l,children:[u,(0,U.jsx)(W,{id:s,children:l})]}):(0,U.jsx)(H.Tooltip,{id:s,text:l,type:`description`,children:(0,U.jsx)(`div`,{children:u})})}var bt={search:``,currentBuildOnly:!1,currentPageOnly:!1,showResolved:!1,showRead:!0,onlyMine:!1,participant:null},xt={heading:`Comments`,closeLabel:`Close comments`,commentMenuLabel:`Add a comment`,commentOnElementLabel:`Comment on element`,highlightRegionLabel:`Highlight a region`,cancelSelectionLabel:`Cancel selection`,bridgeUnavailableLabel:`Adding comments needs the review bridge.`,selectionBlockedLabel:`Close or submit the open draft.`,selectionFailedLabel:`Hub could not anchor a comment to that element.`,areaTooSmallLabel:`Draw a larger region to add a comment.`,areaUnavailableLabel:`Hub could not save that region.`,searchLabel:`Search comments`,searchPlaceholder:`Search comments`,filterLabel:`Filters`,currentBuildFilterLabel:`Current build only`,currentPageFilterLabel:`Current page only`,participantFilterLabel:`Participant`,allParticipantsLabel:`All participants`,showResolvedLabel:`Show resolved`,unreadOnlyLabel:`Unread only`,onlyMineLabel:`Only your threads`,showPinsLabel:`Show pins`,sidebarShortcutLabel:`Shift+C`,loadingLabel:`Loading comments`,loadErrorLabel:`Comments could not be loaded.`,retryLabel:`Retry`,emptyLabel:`No comments have been added.`,noMatchesLabel:`No comments match these filters.`,buildLabel:`build %{number}`,movedAnchorLabel:`Moved`,changedAnchorLabel:`Context changed`,missingAnchorLabel:`Not found`,routeMismatchLabel:`Saved on another page`,resolvedLabel:`Resolved`,markerLabel:`Thread started by %{author}`,markerWithRepliesLabel:`Thread started by %{author}, %{count} comments`,unreadLabel:`Unread`,unreadMarkerLabel:`Unread thread started by %{author}`,unreadMarkerWithRepliesLabel:`Unread thread started by %{author}, %{count} comments`,replyCountOneLabel:`1 reply`,replyCountOtherLabel:`%{count} replies`,threadHeading:`Conversation`,backToCommentsLabel:`Back to comments`,resolvedByLabel:`Resolved by %{author}. Reopen this thread to reply.`,editedLabel:`Edited`,deletedCommentLabel:`Comment deleted`,addReactionLabel:`Add reaction`,reactionCountOneLabel:`%{reaction}, 1 reaction`,reactionCountOtherLabel:`%{reaction}, %{count} reactions`,reactionErrorLabel:`The reaction could not be changed.`,readErrorLabel:`Hub could not mark this conversation as read.`,markUnreadLabel:`Mark as unread`,markUnreadErrorLabel:`Hub could not mark this conversation as unread. Try again.`,reactionLabels:{"+1":`Thumbs up`,"-1":`Thumbs down`,laugh:`Laugh`,hooray:`Hooray`,confused:`Confused`,heart:`Heart`,rocket:`Rocket`,eyes:`Eyes`},commentActionsLabel:`Actions for comment by %{author}`,editLabel:`Edit`,deleteLabel:`Delete`,editCommentLabel:`Edit comment`,saveEditLabel:`Save`,savingEditLabel:`Saving comment`,cancelEditLabel:`Cancel`,editErrorLabel:`The comment could not be updated.`,deleteHeading:`Delete this comment?`,deletePromptLabel:`Deleted comment text cannot be recovered.`,confirmDeleteLabel:`Delete`,deletingLabel:`Deleting comment`,deleteErrorLabel:`The comment could not be deleted.`,replyLabel:`Reply`,replyPlaceholder:`Reply to this conversation`,replySubmitLabel:`Reply`,replySubmitTooltipMacLabel:`Reply (Cmd+Return)`,replySubmitTooltipOtherLabel:`Reply (Ctrl+Enter)`,replyingLabel:`Saving reply`,replyErrorLabel:`The reply could not be saved.`,resolveLabel:`Resolve`,resolvingLabel:`Resolving thread`,reopenLabel:`Reopen`,reopeningLabel:`Reopening thread`,resolutionErrorLabel:`The thread state could not be changed.`,resolvedReplyBlockedLabel:`Reopen this thread to reply.`,deletedReplyBlockedLabel:`Replies are closed.`,threadDiscardPromptLabel:`Your reply or edit has not been saved.`,composerHeading:`New comment`,composerLabel:`Comment`,composerPlaceholder:`Leave a review comment`,submitLabel:`Comment`,submitTooltipMacLabel:`Comment (Cmd+Return)`,submitTooltipOtherLabel:`Comment (Ctrl+Enter)`,submittingLabel:`Saving comment`,closeComposerLabel:`Cancel`,discardHeading:`Keep this draft?`,discardPromptLabel:`This comment has not been submitted.`,keepLabel:`Keep`,discardButtonLabel:`Discard`,bodyTooLongLabel:`Comments must be 10000 UTF-8 bytes or fewer.`,createErrorLabel:`The comment could not be saved.`};function St(e,t){let n=new Map;n.set(e.login.toLowerCase(),e);for(let e of t.toReversed()){let t=e.login.toLowerCase();n.has(t)||n.set(t,e)}return Array.from(n.values())}function Ct(e){let t=new Map,n=new Map;for(let r of e){if(r.kind===`root`){t.set(r.id,r);continue}let e=n.get(r.rootId)??[];e.push(r),n.set(r.rootId,e)}return Array.from(t.values()).flatMap(e=>{let t=(n.get(e.id)??[]).filter(e=>e.deletedAt===null).sort((e,t)=>Date.parse(e.createdAt)-Date.parse(t.createdAt)||e.id-t.id);return e.deletedAt!==null&&t.length===0?[]:[{root:e,replies:t,participants:St(e.author,t.map(e=>e.author)),lastActivityAt:t.at(-1)?.createdAt??e.createdAt,unread:e.viewerLastSeenActivityVersion===null||e.viewerLastSeenActivityVersionDate.parse(t.lastActivityAt)-Date.parse(e.lastActivityAt)||t.root.id-e.root.id)}var wt=new TextEncoder;function Tt(e,{prefix:t,required:n=!1}={}){return N().refine(r=>(!n||r!==``)&&(!t||r===``||r.startsWith(t))&&wt.encode(r).length<=e)}var Et=16384,Dt=2048,Q=2048,Ot=1024,kt=4096,At=1e3,jt=2e3,Mt=1e6,Nt=1e5,Pt=new TextEncoder,Ft=z().min(0).max(Mt),It=z().min(-Mt).max(Mt),Lt=z().min(0).max(Mt),Rt=E({x:z().min(0).max(1),y:z().min(0).max(1)}).strict(),zt=E({pathname:Tt(Dt,{prefix:`/`,required:!0}),search:Tt(Q,{prefix:`?`}),hash:Tt(Ot,{prefix:`#`})}).strict(),Bt=E({x:Ft,y:Ft,width:Lt,height:Lt}).strict();E({x:It,y:It}).strict();var Vt=E({width:z().min(1).max(Nt),height:z().min(1).max(Nt),scrollX:Ft,scrollY:Ft}).strict(),Ht=E({schemaVersion:I(1),kind:I(`element`),route:zt,selector:Tt(kt,{required:!0}),accessibleName:Tt(At),tagName:Tt(64,{required:!0}).regex(/^[a-z][a-z0-9-]*$/),selectedText:Tt(jt),rect:Bt,viewport:Vt,elementOffset:Rt}).strict().refine(e=>Pt.encode(JSON.stringify(e)).length<=Et),Ut=E({selector:Tt(kt,{required:!0}),accessibleName:Tt(At),tagName:Tt(64,{required:!0}).regex(/^[a-z][a-z0-9-]*$/),role:Tt(64),textExcerpt:Tt(500),rect:Bt}).strict(),Wt=E({schemaVersion:I(1),kind:I(`area`),route:zt,path:R(Rt).min(2).max(160),rect:Bt,viewport:Vt,elements:R(Ut).max(8)}).strict().refine(e=>Math.hypot(e.rect.width,e.rect.height)>=8).refine(e=>Pt.encode(JSON.stringify(e)).length<=Et),Gt=w(`kind`,[Ht,Wt]);w(`status`,[E({commentId:z().int().positive().max(2**53-1),status:te([`resolved`,`moved`]),rect:E({x:It,y:It,width:Lt,height:Lt}).strict(),point:E({x:It,y:It}).strict()}).strict(),E({commentId:z().int().positive().max(2**53-1),status:te([`changed`,`missing`,`route-mismatch`])}).strict()]);var Kt=z().int().positive().max(2**53-1),qt=N().refine(e=>!Number.isNaN(Date.parse(e))),Jt=qt.nullable(),Yt=E({login:N().min(1),name:N().nullable(),avatarUrl:N().nullable()}),Xt=te([`+1`,`-1`,`laugh`,`hooray`,`confused`,`heart`,`rocket`,`eyes`]),Zt=E({content:Xt,count:Kt,viewerHasReacted:j()}),Qt={id:Kt,body:N().nullable(),mentions:R(E({login:N().min(1),githubId:Kt})).optional(),createdAt:qt,updatedAt:qt,editedAt:Jt,deletedAt:Jt,author:Yt,viewerCanEdit:j(),viewerCanDelete:j(),reactions:R(Zt)},$t=E({...Qt,kind:I(`root`),buildNumber:Kt.nullable(),buildPath:N().startsWith(`/`).nullable(),draftRevisionId:Kt.nullable().optional(),anchor:Gt,resolvedAt:Jt,resolvedBy:Yt.nullable(),activityVersion:Kt,viewerLastSeenActivityVersion:Kt.nullable()}),en=E({...Qt,kind:I(`reply`),rootId:Kt}),tn=w(`kind`,[$t,en]),nn=w(`hasMore`,[E({comments:R(tn),nextCursor:N().min(1),hasMore:I(!0)}),E({comments:R(tn),nextCursor:F(),hasMore:I(!1)})]),rn=E({comments:R(tn).min(1).max(2)});function an(e,t){let{root:n}=e,{filters:r}=t;if(!r.showResolved&&n.resolvedAt!==null||!r.showRead&&!e.unread||r.onlyMine&&![n,...e.replies].some(e=>e.author.login.toLowerCase()===t.viewerLogin.toLowerCase())||r.currentBuildOnly&&(t.selectedDraftRevisionId==null?n.buildNumber!==t.selectedBuildNumber:n.draftRevisionId!==t.selectedDraftRevisionId)||r.participant!==null&&!e.participants.some(e=>e.login.toLowerCase()===r.participant?.toLowerCase())||r.currentPageOnly&&t.route!==null&&(n.anchor.route.pathname!==t.route.pathname||n.anchor.route.search!==t.route.search||n.anchor.route.hash!==t.route.hash))return!1;let i=r.search.trim().toLowerCase();if(!i)return!0;let a=n.anchor.kind===`element`?[n.anchor.accessibleName,n.anchor.selectedText,n.anchor.tagName]:n.anchor.elements.flatMap(e=>[e.accessibleName,e.textExcerpt,e.tagName,e.role]);return[n.body??``,n.author.login,n.author.name??``,n.buildNumber?.toString()??``,...e.replies.flatMap(e=>[e.body??``,e.author.login,e.author.name??``]),...a].join(` +`).toLowerCase().includes(i)}var on=E({candidates:R(E({githubId:z().int().positive().max(2**53-1),login:N().min(1).max(39),avatarUrl:N().nullable()}))});async function $(e,t,n={}){let r=await fetch(e,{...n,headers:{"Content-Type":`application/json`,"X-Replica-Canvas-Token":t,...n.headers}}),i=await r.json().catch(()=>({error:K.invalidResponse}));if(!r.ok)throw Object.assign(Error(i.error||K.requestFailed),{code:i.code,statusCode:r.status,authorization:i.authorization});return i}function sn({error:e,busy:t,requested:n,onFix:r,onDismiss:i}){let a=(0,V.useId)();return(0,U.jsxs)(le,{title:K.commentingUnavailable,descriptionId:a,closeLabel:K.closeCommentingDialog,onClose:i,children:[(0,U.jsx)(`p`,{id:a,children:K.commentingDescription}),e?(0,U.jsx)(`p`,{role:`alert`,children:e}):null,(0,U.jsxs)(`div`,{className:`canvas-commenting-recovery__actions`,children:[(0,U.jsx)(H.Button,{variant:`primary`,disabled:t||n,onClick:r,children:n?K.commentingFixRequested:K.commentingFix}),(0,U.jsx)(H.Button,{variant:`subtle`,onClick:i,children:K.commentingDismiss})]})]})}function cn({identity:e,enabled:t,ready:n,bridgeProblem:r,token:i}){let[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(!1),p=(0,V.useRef)(e);(0,V.useLayoutEffect)(()=>(p.current=e,()=>{p.current=``}),[e]),(0,V.useEffect)(()=>{let e=window.setTimeout(()=>{o(``),c(!1),u(!1),f(!1)},0);return()=>{window.clearTimeout(e)}},[e,t]);async function m(){let t=e;o(``),c(!0);try{await $(`/api/commenting/fix`,i,{method:`POST`}),p.current===t&&f(!0)}catch(e){p.current===t&&o(e instanceof Error?e.message:String(e))}finally{p.current===t&&c(!1)}}return{visible:t&&!n&&!l&&!!r,error:a,busy:s,requested:d,onFix:()=>void m(),onDismiss:()=>u(!0)}}function ln({cancelLabel:e,confirmLabel:t,description:n,errorLabel:r,heading:i,loading:a=!1,loadingAnnouncement:o,compact:s=!1,condensed:c=!1,onCancel:l,onConfirm:u}){let d=(0,U.jsx)(H.Button,{type:`button`,size:`small`,variant:c?`primary`:void 0,className:`review-confirmation-panel__cancel`,onClick:l,children:e}),f=(0,U.jsx)(H.Button,{type:`button`,size:`small`,variant:c?`secondary`:`primary`,className:c?void 0:`review-confirmation-panel__danger`,disabled:a,"aria-busy":a,onClick:u,children:t});return(0,U.jsxs)(`div`,{className:`review-confirmation-panel${s||c?` review-confirmation-panel--compact`:``}${c?` review-confirmation-panel--condensed`:``}`,role:`alert`,children:[(0,U.jsxs)(`div`,{className:`review-confirmation-panel__copy`,children:[(0,U.jsx)(`strong`,{children:i}),c?(0,U.jsx)(W,{children:n}):(0,U.jsx)(`span`,{children:n})]}),r?(0,U.jsx)(`span`,{className:`review-confirmation-panel__error`,children:r}):null,(0,U.jsxs)(`div`,{className:`review-confirmation-panel__actions`,children:[c?f:d,c?d:f,a&&o?(0,U.jsx)(W,{role:`status`,children:o}):null]})]})}function un(){return(0,V.useContext)(nt)}function dn(e){let t=e.matchAll(/(?e[1]?[e[1].toLowerCase()]:[])))}function fn({value:e,onValueChange:t,onKeyDown:n,ref:r,...i}){let a=un(),o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=(0,V.useRef)(null),l=(0,V.useId)(),[u,d]=(0,V.useState)(e.length),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(!1),[v,y]=(0,V.useState)(0),[b,x]=(0,V.useState)(0),[S,C]=(0,V.useState)({left:0,top:0,width:0}),w=e.slice(0,u).match(/(?:^|[\s(])@([a-zA-Z0-9-]*)$/)?.[1]?.toLowerCase(),T=a!==null&&w!==void 0&&!f&&!i.disabled,E=dn(e).length>10,D=m?.source===a&&m?.failed,O=g||m?.source!==a,k=(m?.source===a?m.candidates:[]).filter(e=>e.login.toLowerCase().includes(w??``)).slice(0,8),A=Math.min(b,Math.max(0,k.length-1));(0,V.useEffect)(()=>{o.current?.setCustomValidity(E?a?.copy.limit??``:``)},[a?.copy.limit,E]),(0,V.useEffect)(()=>{if(!T||!a)return;let e=!0,t=window.setTimeout(()=>{_(!0),a.load().then(t=>{e&&h({source:a,candidates:t,failed:!1})},()=>{e&&h({source:a,candidates:[],failed:!0})}).finally(()=>{e&&_(!1)})},150);return()=>{e=!1,window.clearTimeout(t)}},[T,v,a]),(0,V.useLayoutEffect)(()=>{if(!T)return;function e(){let e=o.current?.getBoundingClientRect();e&&C({left:e.left,width:e.width,top:Math.max(4,window.innerHeight-e.bottom<224?e.top-224:e.bottom)})}return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[T]);function j(n){if(w===void 0)return;let r=u-w.length-1,i=`@${n.login} `;t(e.slice(0,r)+i+e.slice(u)),p(!0);let a=r+i.length;window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.setSelectionRange(a,a),d(a)})}function M(e,t){o.current=e,typeof t==`function`?t(e):t&&(t.current=e)}return(0,U.jsxs)(`div`,{className:`mention-input`,children:[(0,U.jsx)(`textarea`,{...i,ref:e=>M(e,r),value:e,"aria-autocomplete":a?`list`:void 0,"aria-controls":T?l:void 0,"aria-activedescendant":T&&k.length?`${l}-${A}`:void 0,onChange:e=>{d(e.currentTarget.selectionStart),p(!1),x(0),t(e.currentTarget.value)},onSelect:e=>d(e.currentTarget.selectionStart),onBlur:e=>{s.current?.contains(e.relatedTarget)||p(!0)},onKeyDown:e=>{if(T&&e.key===`Escape`)e.preventDefault(),e.stopPropagation(),p(!0);else if(T&&D&&!O&&e.key===`Tab`&&!e.shiftKey)e.preventDefault(),c.current?.focus();else{if(T&&!O&&!D&&k.length){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),x((A+(e.key===`ArrowDown`?1:-1)+k.length)%k.length);return}if((e.key===`Enter`||e.key===`Tab`)&&!e.nativeEvent.isComposing&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey){e.preventDefault();let t=k[A];t&&j(t);return}}n?.(e)}}}),E&&a?.copy.limit?(0,U.jsx)(`span`,{role:`alert`,children:a.copy.limit}):null,T&&a?(0,et.createPortal)((0,U.jsx)(`div`,{ref:s,id:l,className:`mention-input__suggestions`,style:S,onBlur:e=>{e.relatedTarget!==o.current&&!e.currentTarget.contains(e.relatedTarget)&&p(!0)},onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),p(!0),o.current?.focus()):e.key===`Tab`&&e.shiftKey&&(e.preventDefault(),o.current?.focus())},children:O?(0,U.jsx)(`span`,{role:`status`,children:a.copy.loading}):D?(0,U.jsxs)(`div`,{role:`alert`,children:[a.copy.error,` `,(0,U.jsx)(`button`,{ref:c,type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{y(v+1),o.current?.focus()},children:a.copy.retry})]}):(0,U.jsxs)(`ul`,{role:`listbox`,"aria-label":a.copy.suggestions,children:[k.map((e,t)=>(0,U.jsx)(`li`,{id:`${l}-${t}`,role:`option`,"aria-selected":t===A,children:(0,U.jsxs)(`button`,{type:`button`,tabIndex:-1,onMouseDown:e=>e.preventDefault(),onClick:()=>j(e),children:[`@`,e.login]})},e.githubId)),k.length?null:(0,U.jsx)(`li`,{role:`presentation`,children:a.copy.empty})]})}),document.body):null]})}function pn({anchorPoint:e,anchorRectangle:t,anchorSelector:n,layoutKey:r,preserveVerticalSide:i=!1}){let a=(0,V.useRef)(null),o=(0,V.useRef)(null),[s,c]=(0,V.useState)({left:e.x+12,top:e.y+12}),l=(0,V.useCallback)(()=>{let r=a.current,s=r?.parentElement;if(!r||!s)return;let l=r.offsetWidth,u=r.offsetHeight,d=s.clientWidth-l-8,f=s.clientHeight-u-8,p,m,h=(n?s.querySelector(n)??s.parentElement?.querySelector(n):null)?.getBoundingClientRect(),g=s.getBoundingClientRect(),_=h?{x:h.left-g.left,y:h.top-g.top,width:h.height,height:h.height}:t;if(_){let e=_.x+_.width+12,t=_.x-12-l,n=e+l<=s.clientWidth-8,r=t>=8,i=s.clientWidth-8-_.x-_.width,a=_.x-8;p=n?e:r?t:i>=a?e:t,m=_.y}else{let t=e.x+12,n=e.y+12;p=t+l<=s.clientWidth-8?t:e.x-12-l;let r=o.current,a=i&&r?.x===e.x&&r.y===e.y?r.side:n+u<=s.clientHeight-8?`below`:`above`;i&&(o.current={x:e.x,y:e.y,side:a}),m=a===`below`?n:e.y-12-u}let v={left:Math.max(8,Math.min(p,d)),top:Math.max(8,Math.min(m,f))};c(e=>e.left===v.left&&e.top===v.top?e:v)},[e,t,n,i]);return(0,V.useLayoutEffect)(()=>{l();let e=a.current,t=e?.parentElement;if(!e||!t||typeof ResizeObserver!=`function`)return;let r=new ResizeObserver(l);r.observe(e),r.observe(t);let i=n?t.querySelector(n)??t.parentElement?.querySelector(n):null;return i&&r.observe(i),window.addEventListener(`resize`,l),()=>{r.disconnect(),window.removeEventListener(`resize`,l)}},[n,r,l]),{cardRef:a,position:s}}function mn(){return typeof navigator<`u`&&/Mac/i.test(navigator.platform)}function hn(e,{allowPlainEnter:t=!1}={}){let n=e.isComposing||e.keyCode===229,r=mn()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey,i=t&&!e.metaKey&&!e.ctrlKey;return e.key===`Enter`&&!e.shiftKey&&!e.altKey&&!n&&!e.repeat&&(r||i)}var gn=new TextEncoder;function _n({anchorPoint:e,bodyMaximumBytes:t,copy:n,creating:r,submitError:i,onSubmit:a,onDiscard:o}){let s=(0,V.useId)(),[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(!1),m=(0,V.useRef)(!1),{cardRef:h,position:g}=pn({anchorPoint:e,layoutKey:`${u}:${f}:${i??``}`,preserveVerticalSide:!0}),_=gn.encode(c).length>t,v=c.trim()!==``&&!_&&!r&&!u,y=mn()?n.submitTooltipMacLabel:n.submitTooltipOtherLabel;(0,V.useEffect)(()=>{u?h.current?.querySelector(`.review-confirmation-panel__cancel`)?.focus({preventScroll:!0}):m.current&&h.current?.querySelector(`textarea`)?.focus({preventScroll:!0}),m.current=u},[h,u]);function b(){r||(c.trim()===``?o():d(!0))}async function x(e){e.preventDefault(),v&&(await a(c)||p(!0))}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-hidden":`true`,className:`review-comment-composer-backdrop`,onClick:b}),(0,U.jsx)(`section`,{ref:h,role:`dialog`,"aria-labelledby":s,className:`review-comment-composer`,style:{left:g.left,top:g.top},children:(0,U.jsxs)(`form`,{className:`review-comment-composer__form`,onSubmit:e=>{x(e)},onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),u?d(!1):b())},children:[(0,U.jsxs)(`header`,{className:`review-comment-composer__header`,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`6`,id:s,children:n.composerHeading}),(0,U.jsx)(G,{icon:B,"aria-label":n.closeComposerLabel,description:n.closeComposerLabel,variant:`invisible`,type:`button`,disabled:r,onClick:b})]}),(0,U.jsx)(fn,{autoFocus:!0,"aria-label":n.composerLabel,placeholder:n.composerPlaceholder,value:c,rows:4,onValueChange:e=>{l(e),d(!1),p(!1)},onKeyDown:e=>{v&&hn(e.nativeEvent)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),_?(0,U.jsx)(`span`,{role:`alert`,className:`review-comment-composer__error`,children:n.bodyTooLongLabel}):null,f?(0,U.jsx)(pe,{variant:`critical`,title:n.createErrorLabel,description:i,className:`review-comment-composer__banner`}):null,u?(0,U.jsx)(ln,{heading:n.discardHeading,description:n.discardPromptLabel,cancelLabel:n.keepLabel,confirmLabel:n.discardButtonLabel,condensed:!0,onCancel:()=>d(!1),onConfirm:o}):(0,U.jsxs)(`footer`,{className:`review-comment-composer__actions`,children:[(0,U.jsx)(H.Button,{type:`button`,size:`small`,disabled:r,onClick:b,children:n.closeComposerLabel}),(0,U.jsx)(H.Tooltip,{text:y,type:`description`,children:(0,U.jsx)(H.Button,{type:`submit`,size:`small`,variant:`primary`,disabled:!v,"aria-busy":r,children:n.submitLabel})}),r?(0,U.jsx)(W,{role:`status`,children:n.submittingLabel}):null]})]})})]})}function vn({blockedLabel:e,confirmingDiscard:t,replyDraft:n,replyBodyTooLong:r,replyFailed:i,replyDisabled:a,replying:o,copy:s,onKeepDraft:c,onDiscardDraft:l,onSubmit:u,onDraftChange:d}){let f=(0,V.useRef)(null),p=n.trim()!==``&&!r&&!a&&!o&&!t&&!e,m=mn()?s.replySubmitTooltipMacLabel:s.replySubmitTooltipOtherLabel;return(0,V.useLayoutEffect)(()=>{f.current&&(f.current.style.height=`auto`,f.current.style.height=n?`${Math.min(f.current.scrollHeight,120)}px`:`2.5rem`)},[n]),t?(0,U.jsx)(ln,{heading:s.discardHeading,description:s.threadDiscardPromptLabel,cancelLabel:s.keepLabel,confirmLabel:s.discardButtonLabel,compact:!0,onCancel:c,onConfirm:l}):e?(0,U.jsx)(`span`,{className:`review-thread-reply-form__blocked`,children:e}):(0,U.jsxs)(`form`,{className:`review-thread-reply-form`,onSubmit:e=>{e.preventDefault(),p&&u()},children:[(0,U.jsxs)(`div`,{className:`review-thread-reply-form__composer`,children:[(0,U.jsx)(fn,{ref:f,"aria-label":s.replyLabel,placeholder:s.replyPlaceholder,value:n,rows:1,disabled:a,onValueChange:d,onKeyDown:e=>{p&&hn(e.nativeEvent,{allowPlainEnter:!0})&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,U.jsx)(H.Tooltip,{text:m,type:`description`,children:(0,U.jsx)(`button`,{type:`submit`,className:`review-thread-reply-form__submit`,disabled:!p,"aria-label":s.replySubmitLabel,"aria-busy":o,children:(0,U.jsx)(_,{size:16})})})]}),r?(0,U.jsx)(`span`,{role:`alert`,className:`review-thread-reply-form__error`,children:s.bodyTooLongLabel}):null,i?(0,U.jsx)(`span`,{role:`alert`,className:`review-thread-reply-form__error`,children:s.replyErrorLabel}):null,o?(0,U.jsx)(W,{role:`status`,children:s.replyingLabel}):null]})}function yn({comment:e}){let t=e.body??``,n=new Set(e.mentions?.map(e=>e.login.toLowerCase())??[]),r=t.matchAll(/(?({content:e,emoji:xn(e)}));function Cn(e,t=0,n=0){if(t!==0||n!==0)return{x:t,y:n};let r=e.getBoundingClientRect();return{x:r.left+r.width/2,y:r.top+r.height/2}}function wn({comment:e,mutation:t,actionsDisabled:n,controlsHidden:r=!1,copy:i,onAdd:a,onRemove:o,onBurst:s}){let c=(0,V.useId)(),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(!1),p=(0,V.useRef)(!1),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(`outside-bottom`),v=t!==null&&(t.kind===`add-reaction`||t.kind===`remove-reaction`)&&t.commentId===e.id,y=e.reactions.flatMap(e=>{if(!m||e.content!==m.content)return[e];let t=e.count+Number(m.viewerHasReacted)-Number(e.viewerHasReacted);return t>0?[{...e,count:t,viewerHasReacted:m.viewerHasReacted}]:[]});m?.viewerHasReacted&&!e.reactions.some(({content:e})=>e===m.content)&&y.push({content:m.content,count:1,viewerHasReacted:!0});async function b(r,i){if(n||t!==null||p.current)return;let c=e.reactions.find(e=>e.content===r)?.viewerHasReacted??!1;p.current=!0,u(!1),h({content:r,viewerHasReacted:!c});try{if(!c){let e=Sn.find(e=>e.content===r);e&&s(e.emoji,i.x,i.y)}let e=c?await o(r):await a(r);u(!e)}catch{u(!0)}finally{p.current=!1,h(null)}}function x(e,t){b(e,Cn(t.currentTarget,t.clientX,t.clientY))}let S=(0,U.jsxs)(H.ActionMenu,{selectionVariant:`none`,size:`small`,menuAlignment:`end`,menuSide:g,disabled:n,children:[(0,U.jsx)(H.ActionMenu.Button,{className:`review-comment-reactions__menu-trigger`,variant:`subtle`,"aria-label":i.addReactionLabel,"aria-describedby":c,"aria-busy":v||m!==null,leadingVisual:(0,U.jsx)(k,{size:16}),onClick:e=>{f(!0);let t=e.currentTarget.getBoundingClientRect(),n=e.currentTarget.closest(`.review-shell`)?.getBoundingClientRect(),r=Math.min(window.innerHeight,n?.bottom??1/0)-t.bottom,i=t.top-Math.max(0,n?.top??0),a=Sn.length*36+16;_(rr?`outside-top`:`outside-bottom`)},children:``}),(0,U.jsx)(H.ActionMenu.Overlay,{"aria-label":i.addReactionLabel,children:Sn.map(e=>(0,U.jsx)(H.ActionMenu.Item,{value:e.content,leadingVisual:(0,U.jsx)(`span`,{className:`review-comment-reactions__picker-emoji`,children:e.emoji}),onClick:t=>x(e.content,t),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),b(e.content,Cn(t.currentTarget)))},children:i.reactionLabels[e.content]},e.content))})]});return r&&!l?null:(0,U.jsxs)(`div`,{className:`review-comment-reactions__layout`,children:[r?null:(0,U.jsxs)(`div`,{className:`review-comment-reactions`,children:[y.map(e=>{let r=Sn.find(({content:t})=>t===e.content);if(!r)return null;let a=(e.count===1?i.reactionCountOneLabel:i.reactionCountOtherLabel).replace(`%{reaction}`,i.reactionLabels[e.content]).replace(`%{count}`,e.count.toString());return(0,U.jsxs)(H.Button,{size:`small`,"aria-label":a,title:a,"aria-pressed":e.viewerHasReacted,disabled:n,"aria-busy":m?.content===e.content||v&&`content`in t&&t.content===e.content,className:e.viewerHasReacted?`review-comment-reaction--selected`:void 0,onClick:t=>x(e.content,t),children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,children:r.emoji}),(0,U.jsx)(tt,{"aria-hidden":`true`,children:e.count})]},e.content)}),n?(0,U.jsxs)(`div`,{title:i.addReactionLabel,children:[S,(0,U.jsx)(W,{id:c,children:i.addReactionLabel})]}):(0,U.jsx)(H.Tooltip,{id:c,text:i.addReactionLabel,type:`description`,className:`review-comment-reactions__tooltip${d?` review-comment-reactions__tooltip--suppressed`:``}`,children:(0,U.jsx)(`div`,{onMouseEnter:e=>{e.currentTarget.querySelector(`[aria-expanded="true"]`)||f(!1)},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||f(!1)},children:S})})]}),l?(0,U.jsx)(`span`,{role:`alert`,className:`review-comment-reactions__error`,children:i.reactionErrorLabel}):null]})}function Tn({comment:e,mutation:t,copy:n,editing:r,editDraft:i,editBodyTooLong:a,editFailed:o,confirmingEditDiscard:s,saving:c,confirmingDelete:l,deleting:u,deleteFailed:d,actionsDisabled:f,onStartEdit:p,onEditDraftChange:m,onSaveEdit:h,onCancelEdit:g,onKeepEdit:_,onDiscardEdit:v,onRequestDelete:y,onCancelDelete:b,onDelete:x,onAddReaction:S,onRemoveReaction:C,onBurstReaction:w,onMarkUnread:T,markUnreadDisabled:E=!1}){let D=(0,V.useId)(),k=(0,V.useRef)(null),A=(0,V.useRef)(!1),[j,M]=(0,V.useState)(`outside-bottom`),N=e.author.name||`@${e.author.login}`,P=n.commentActionsLabel.replace(`%{author}`,`@${e.author.login}`),F=f&&(!T||E),I=!!(e.body&&e.viewerCanEdit),L=!!(e.body&&e.viewerCanDelete);return(0,V.useEffect)(()=>{s?k.current?.querySelector(`.review-confirmation-panel button`)?.focus({preventScroll:!0}):A.current&&k.current?.querySelector(`textarea`)?.focus({preventScroll:!0}),A.current=s},[s]),(0,U.jsxs)(`article`,{className:`review-thread-message`,"data-review-message-id":e.id,children:[(0,U.jsxs)(`div`,{className:`review-thread-message__header`,children:[(0,U.jsx)(at,{src:e.author.avatarUrl,size:28}),(0,U.jsxs)(`span`,{className:`review-thread-message__byline`,children:[(0,U.jsx)(`strong`,{className:`review-thread-message__identity`,children:N}),(0,U.jsx)(gt,{value:e.createdAt}),e.editedAt?(0,U.jsx)(`span`,{children:n.editedLabel}):null]}),T||I||L?F?(0,U.jsxs)(`div`,{title:P,children:[(0,U.jsx)(H.ActionMenu,{selectionVariant:`none`,size:`small`,menuAlignment:`end`,disabled:!0,children:(0,U.jsx)(H.ActionMenu.Button,{className:`review-thread-message__menu-trigger`,variant:`subtle`,"aria-label":P,"aria-describedby":D,leadingVisual:(0,U.jsx)(re,{size:16}),children:``})}),(0,U.jsx)(W,{id:D,children:P})]}):(0,U.jsx)(H.Tooltip,{id:D,text:P,type:`description`,children:(0,U.jsx)(`div`,{children:(0,U.jsxs)(H.ActionMenu,{selectionVariant:`none`,size:`small`,menuAlignment:`end`,menuSide:j,children:[(0,U.jsx)(H.ActionMenu.Button,{className:`review-thread-message__menu-trigger`,variant:`subtle`,"aria-label":P,"aria-describedby":D,leadingVisual:(0,U.jsx)(re,{size:16}),onClick:e=>{let t=e.currentTarget.getBoundingClientRect(),n=e.currentTarget.closest(`.review-shell`)?.getBoundingClientRect(),r=Math.min(window.innerHeight,n?.bottom??1/0)-t.bottom,i=t.top-Math.max(0,n?.top??0);M(r<(T?128:88)&&i>r?`outside-top`:`outside-bottom`)},children:``}),(0,U.jsxs)(H.ActionMenu.Overlay,{"aria-label":P,children:[T?(0,U.jsx)(H.ActionMenu.Item,{value:`mark-unread`,disabled:E,leadingVisual:(0,U.jsx)(ee,{size:16}),onClick:()=>{E||T()},onKeyDown:e=>{!E&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),T())},children:n.markUnreadLabel}):null,I?(0,U.jsx)(H.ActionMenu.Item,{value:`edit`,disabled:f,leadingVisual:(0,U.jsx)(ae,{size:16}),onClick:p,onKeyDown:e=>{!f&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),p())},children:n.editLabel}):null,L&&(T||I)?(0,U.jsx)(`li`,{role:`separator`,className:`review-thread-message__menu-divider`}):null,L?(0,U.jsx)(H.ActionMenu.Item,{value:`delete`,disabled:f||t!==null,className:`review-thread-message__delete-item`,leadingVisual:(0,U.jsx)(O,{size:16}),onClick:y,onKeyDown:e=>{!f&&t===null&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),y())},children:n.deleteLabel}):null]})]})})}):null]}),r?(0,U.jsxs)(`form`,{ref:k,className:`review-thread-message__edit`,onSubmit:e=>{e.preventDefault(),s||h()},children:[(0,U.jsx)(fn,{autoFocus:!0,"aria-label":n.editCommentLabel,value:i,rows:3,onValueChange:m}),a?(0,U.jsx)(`span`,{role:`alert`,className:`review-thread-message__error`,children:n.bodyTooLongLabel}):null,o?(0,U.jsx)(`span`,{role:`alert`,className:`review-thread-message__error`,children:n.editErrorLabel}):null,s?(0,U.jsx)(ln,{heading:n.discardHeading,description:n.threadDiscardPromptLabel,cancelLabel:n.keepLabel,confirmLabel:n.discardButtonLabel,compact:!0,onCancel:_,onConfirm:v}):(0,U.jsxs)(`div`,{className:`review-thread-message__actions`,children:[(0,U.jsx)(H.Button,{type:`button`,size:`small`,disabled:c,onClick:g,children:n.cancelEditLabel}),(0,U.jsx)(H.Button,{type:`submit`,size:`small`,variant:`primary`,disabled:i.trim()===``||a||t!==null||c,"aria-busy":c,children:n.saveEditLabel}),c?(0,U.jsx)(W,{role:`status`,children:n.savingEditLabel}):null]})]}):l?(0,U.jsx)(ln,{heading:n.deleteHeading,description:n.deletePromptLabel,errorLabel:d?n.deleteErrorLabel:void 0,cancelLabel:n.cancelEditLabel,confirmLabel:n.confirmDeleteLabel,loading:u,loadingAnnouncement:n.deletingLabel,compact:!0,onCancel:b,onConfirm:x}):(0,U.jsx)(`p`,{className:e.body?`review-thread-message__body`:`review-thread-message__body review-thread-message__body--deleted`,children:e.body?(0,U.jsx)(yn,{comment:e}):n.deletedCommentLabel}),e.body&&(e.kind!==`root`||e.buildNumber!==null)?(0,U.jsx)(wn,{comment:e,mutation:t,actionsDisabled:f,controlsHidden:r||l,copy:n,onAdd:S,onRemove:C,onBurst:w}):null]})}function En(){let e=(0,V.useRef)(null),t=(0,V.useRef)([]),n=(0,V.useRef)(new Map),[r,i]=(0,V.useState)(!1),a=(0,V.useCallback)((e,n,r)=>{if(window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches)return;let a=4+Math.floor(Math.random()*5),o=performance.now();for(let i=0;i{if(!r)return;let a=e.current,o=a?.getContext(`2d`);if(!a||!o){console.error(`Emoji reaction burst could not create a canvas context.`),t.current=[];let e=requestAnimationFrame(()=>i(!1));return()=>cancelAnimationFrame(e)}let s=a,c=o,l;function u(){let e=window.devicePixelRatio||1;s.width=Math.round(window.innerWidth*e),s.height=Math.round(window.innerHeight*e),c.setTransform(e,0,0,e,0,0)}function d(e,t){let r=Math.round(t),i=`${e}_${r}`;if(n.current.has(i))return n.current.get(i)??null;let a=document.createElement(`canvas`);a.width=r*2,a.height=r*2;let o=a.getContext(`2d`);return o?(o.font=`${r}px serif`,o.textAlign=`center`,o.textBaseline=`middle`,o.fillText(e,r,r),n.current.set(i,a),a):(console.error(`Emoji reaction burst could not draw an emoji.`),n.current.set(i,null),null)}function f(e){c.clearRect(0,0,window.innerWidth,window.innerHeight);let n=[];for(let r of t.current){if(e10&&(r.opacity-=.04),r.opacity<=0)continue;let t=d(r.emoji,r.size);t&&(c.globalAlpha=r.opacity,c.drawImage(t,r.x-t.width/2,r.y-t.height/2)),n.push(r)}c.globalAlpha=1,t.current=n,n.length>0?l=requestAnimationFrame(f):i(!1)}return u(),window.addEventListener(`resize`,u),l=requestAnimationFrame(f),()=>{cancelAnimationFrame(l),window.removeEventListener(`resize`,u)}},[r]),{burst:a,canvas:r?(0,et.createPortal)((0,U.jsx)(`canvas`,{ref:e,className:`review-emoji-burst`,"aria-hidden":`true`}),document.body):null}}var Dn=new TextEncoder;function On({thread:e,bodyMaximumBytes:t,mutation:n,onClose:r,onDraftStateChange:i,onReply:a,onEdit:o,onDelete:s,onResolve:c,onReopen:l}){let[u,d]=(0,V.useState)(``),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(``),[v,y]=(0,V.useState)(``),[b,x]=(0,V.useState)(!1),[S,C]=(0,V.useState)(!1),[w,T]=(0,V.useState)(null),[E,D]=(0,V.useState)(!1),[O,k]=(0,V.useState)(!1),[A,j]=(0,V.useState)(!1),M=u.trim()!==``||m!==null,ee=Dn.encode(u).length>t,N=Dn.encode(g).length>t,P=e.root.resolvedAt!==null,F=e.root.deletedAt!==null||P;(0,V.useEffect)(()=>(i(M),()=>i(!1)),[M,i]);function I(){n||(u.trim()===``&&g===v?r():(C(!1),j(!0)))}function L(){d(``),h(null),_(``),y(``),C(!1),j(!1),i(!1),r()}async function R(){u.trim()===``||ee||n||(await a(u)?(d(``),p(!1)):p(!0))}function z(e){d(e),p(!1),j(!1)}function te(e){e.body&&(h(e.id),_(e.body),y(e.body),x(!1),T(null),D(!1))}function B(e){_(e),x(!1),C(!1),j(!1)}async function ne(e){g.trim()===``||N||n||(await o(e,g)?(h(null),_(``),y(``),C(!1),x(!1)):x(!0))}function re(){g===v?ie():C(!0)}function ie(){h(null),_(``),y(``),x(!1),C(!1),j(!1)}function ae(e){T(e),D(!1)}function oe(){T(null),D(!1)}async function se(e){n||(await s(e)?oe():D(!0))}async function H(){if(n||M)return;let e=P?await l():await c();k(!e)}return{state:{replyDraft:u,replyFailed:f,editingCommentId:m,editDraft:g,editFailed:b,confirmingEditDiscard:S,confirmingDeleteId:w,deleteFailed:E,resolutionFailed:O,confirmingDiscard:A,draftActive:M,replyBodyTooLong:ee,editBodyTooLong:N,resolved:P,replyBlocked:F},actions:{requestDismissal:I,discardAndClose:L,keepDraft:()=>j(!1),submitReply:R,changeReplyDraft:z,startEdit:te,changeEditDraft:B,saveEdit:ne,cancelEdit:re,keepEdit:()=>C(!1),discardEdit:ie,requestDelete:ae,cancelDelete:oe,deleteComment:se,changeResolution:H}}}function kn(e){let t=e.closest(`[data-testid="ActionMenu"]`);if(!t)return;let n=e.getBoundingClientRect(),r=e.closest(`.review-shell`)?.getBoundingClientRect(),i=Math.max(0,r?.top??0),a=Math.min(window.innerHeight,r?.bottom??window.innerHeight);t.style.setProperty(`--review-thread-menu-room-top`,`${Math.max(0,n.top-i-8)}px`),t.style.setProperty(`--review-thread-menu-room-bottom`,`${Math.max(0,a-n.bottom-8)}px`)}function An({thread:e,anchorPoint:t,bodyMaximumBytes:n,mutation:r,copy:i,onClose:a,onDraftStateChange:o,onReply:s,onEdit:c,onDelete:l,onResolve:u,onReopen:d,onAddReaction:f,onRemoveReaction:p,onMarkRead:m,onMarkUnread:h}){let g=(0,V.useId)(),_=(0,V.useRef)(null),v=(0,V.useRef)(0),y=(0,V.useRef)(e.root.activityVersion),b=(0,V.useRef)(null),x=(0,V.useRef)(!1),S=(0,V.useRef)(!1),C=(0,V.useRef)(!1),[w,T]=(0,V.useState)(!1),[E,D]=(0,V.useState)(!1),[O,k]=(0,V.useState)(!1),[A,j]=(0,V.useState)(!1),{burst:M,canvas:ee}=En(),{state:N,actions:P}=On({thread:e,bodyMaximumBytes:n,mutation:r,onClose:a,onDraftStateChange:o,onReply:s,onEdit:c,onDelete:l,onResolve:u,onReopen:d}),F={x:12,y:12},I=[e.root,...e.replies],{cardRef:L,position:R}=pn({anchorPoint:t??F,...t?{anchorSelector:`[data-review-thread-id="${e.root.id}"]`,anchorRectangle:{x:t.x-16,y:t.y-16,width:32,height:32}}:{},layoutKey:[N.confirmingDiscard,N.confirmingEditDiscard,N.replyFailed,N.editFailed,N.deleteFailed,N.resolutionFailed,N.editingCommentId,N.confirmingDeleteId,N.resolved,w,O,e.replies.length,e.participants.length,I.map(e=>e.reactions.length).join(`,`)].join(`:`)}),z={"--review-thread-left":`${R.left}px`,"--review-thread-top":`${R.top}px`},te=N.replyBlocked?e.root.deletedAt?i.deletedReplyBlockedLabel:e.root.resolvedBy?i.resolvedByLabel.replace(`%{author}`,e.root.resolvedBy.name||`@${e.root.resolvedBy.login}`):i.resolvedReplyBlockedLabel:null,ne=(0,V.useCallback)(()=>{L.current?.querySelector(`.review-thread-conversation__close`)?.focus({preventScroll:!0})},[L]);(0,V.useEffect)(()=>{if(N.confirmingDiscard)L.current?.querySelector(`.review-thread-conversation__footer button`)?.focus({preventScroll:!0});else if(C.current){let e=N.editingCommentId===null?`.review-thread-reply-form textarea`:`.review-thread-message__edit textarea`;L.current?.querySelector(e)?.focus({preventScroll:!0})}C.current=N.confirmingDiscard},[L,N.confirmingDiscard,N.editingCommentId]),(0,V.useEffect)(()=>{let e=document.activeElement;return _.current=e instanceof HTMLElement?e:null,ne(),()=>{_.current?.isConnected&&_.current.focus()}},[ne]),(0,V.useEffect)(()=>{let t=y.current;e.unread&&b.current!==t&&(b.current=t,x.current=!0,D(!0),m(t).then(e=>T(!e)).catch(()=>T(!0)).finally(()=>{x.current=!1,D(!1)}))},[m,e.unread]);async function re(){if(!(x.current||S.current||r!==null)){b.current=y.current,S.current=!0,j(!0),k(!1);try{let e=await h();k(!e),e&&T(!1)}catch{k(!0)}finally{S.current=!1,j(!1)}}}return(0,V.useEffect)(()=>{function e(){N.confirmingDiscard?P.keepDraft():N.confirmingEditDiscard?P.keepEdit():P.requestDismissal()}function t(t){t.key!==`Escape`||t.defaultPrevented||t.isComposing||L.current?.querySelector(`[role="menu"]`)||t.target instanceof Element&&t.target.closest(`[role="menu"], [role="dialog"], dialog`)||(t.preventDefault(),e())}function n(){let t=document.activeElement;L.current?.querySelector(`[role="menu"]`)||t instanceof Element&&(t.closest(`[role="menu"]`)||t.closest(`[role="dialog"], dialog`)&&!L.current?.contains(t))||e()}return document.addEventListener(`keydown`,t),window.addEventListener(`replica:review-dismiss`,n),()=>{document.removeEventListener(`keydown`,t),window.removeEventListener(`replica:review-dismiss`,n)}},[P,L,N.confirmingDiscard,N.confirmingEditDiscard]),(0,U.jsxs)(`section`,{ref:L,role:`dialog`,"aria-labelledby":g,className:`review-thread-conversation${t?` review-thread-conversation--anchored`:` review-thread-conversation--docked`}`,style:z,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||e.nativeEvent.isComposing||e.target instanceof Element&&e.target.closest(`[role="menu"]`)||(e.preventDefault(),N.confirmingDiscard?P.keepDraft():N.confirmingEditDiscard?P.keepEdit():P.requestDismissal())},children:[(0,U.jsxs)(`div`,{className:`review-thread-conversation__layout`,children:[(0,U.jsxs)(`header`,{className:`review-thread-conversation__header`,children:[(0,U.jsx)(H.Heading,{as:`h2`,size:`6`,id:g,children:i.threadHeading}),e.root.buildNumber===null?null:(0,U.jsx)(H.Button,{size:`small`,disabled:N.draftActive||r!==null,"aria-busy":r!==null&&`commentId`in r&&r.commentId===e.root.id&&(r.kind===`resolve`||r.kind===`reopen`),onClick:()=>{P.changeResolution()},children:N.resolved?i.reopenLabel:i.resolveLabel}),r&&`commentId`in r&&r.commentId===e.root.id&&(r.kind===`resolve`||r.kind===`reopen`)?(0,U.jsx)(W,{role:`status`,children:N.resolved?i.reopeningLabel:i.resolvingLabel}):null,(0,U.jsx)(G,{icon:B,"aria-label":i.backToCommentsLabel,title:i.backToCommentsLabel,variant:`invisible`,className:`review-thread-conversation__close`,onClick:P.requestDismissal})]}),N.resolutionFailed?(0,U.jsx)(pe,{variant:`critical`,title:i.resolutionErrorLabel,className:`review-thread-conversation__banner`}):null,w?(0,U.jsx)(pe,{variant:`critical`,title:i.readErrorLabel,className:`review-thread-conversation__banner`}):null,O?(0,U.jsx)(pe,{variant:`critical`,title:i.markUnreadErrorLabel,className:`review-thread-conversation__banner`}):null,(0,U.jsx)(`div`,{className:`review-thread-conversation__messages`,onClickCapture:e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`button[data-testid="ActionMenu-button"]`);t&&e.currentTarget.contains(t)&&(v.current=e.currentTarget.scrollTop,kn(t))},onScroll:e=>{let t=e.currentTarget.scrollTop,n=t-v.current;if(v.current=t,n===0)return;let r=e.currentTarget.getBoundingClientRect();e.currentTarget.querySelectorAll(`[role="menu"]`).forEach(e=>{let t=e.closest(`[data-testid="ActionMenu"]`)?.querySelector(`button[data-testid="ActionMenu-button"]`);if(!t)return;let i=t.getBoundingClientRect();if(r.height>0&&(i.bottom<=r.top||i.top>=r.bottom)){let n=e.contains(document.activeElement);t.click(),n&&ne();return}let a=Number.parseFloat(e.style.top);Number.isFinite(a)&&(e.style.top=`${a-n}px`),kn(t)})},children:I.map(t=>(0,U.jsx)(Tn,{comment:t,mutation:r,copy:i,editing:N.editingCommentId===t.id,editDraft:N.editingCommentId===t.id?N.editDraft:``,editBodyTooLong:N.editingCommentId===t.id&&N.editBodyTooLong,editFailed:N.editingCommentId===t.id&&N.editFailed,confirmingEditDiscard:N.editingCommentId===t.id&&N.confirmingEditDiscard,saving:r?.kind===`edit`&&r.commentId===t.id,confirmingDelete:N.confirmingDeleteId===t.id,deleting:r?.kind===`delete`&&r.commentId===t.id,deleteFailed:N.confirmingDeleteId===t.id&&N.deleteFailed,actionsDisabled:r!==null&&r.kind!==`add-reaction`&&r.kind!==`remove-reaction`||N.confirmingDiscard||N.confirmingDeleteId!==null||N.replyDraft.trim()!==``||N.editingCommentId!==null&&N.editingCommentId!==t.id,onStartEdit:()=>P.startEdit(t),onEditDraftChange:P.changeEditDraft,onSaveEdit:()=>{P.saveEdit(t.id)},onCancelEdit:P.cancelEdit,onKeepEdit:P.keepEdit,onDiscardEdit:P.discardEdit,onRequestDelete:()=>P.requestDelete(t.id),onCancelDelete:P.cancelDelete,onDelete:()=>{P.deleteComment(t.id)},onAddReaction:e=>f(t.id,e),onRemoveReaction:e=>p(t.id,e),onBurstReaction:M,onMarkUnread:t.kind===`root`&&e.root.buildNumber!==null?()=>void re():void 0,markUnreadDisabled:E||A||r!==null},t.id))}),e.root.buildNumber!==null||N.confirmingDiscard?(0,U.jsx)(`div`,{className:`review-thread-conversation__footer${te&&!N.confirmingDiscard?` review-thread-conversation__footer--blocked`:``}`,children:(0,U.jsx)(vn,{blockedLabel:te,confirmingDiscard:N.confirmingDiscard,replyDraft:N.replyDraft,replyBodyTooLong:N.replyBodyTooLong,replyFailed:N.replyFailed,replyDisabled:r!==null||N.editingCommentId!==null,replying:r?.kind===`reply`&&r.commentId===e.root.id,copy:i,onKeepDraft:P.keepDraft,onDiscardDraft:P.discardAndClose,onSubmit:()=>{P.submitReply()},onDraftChange:P.changeReplyDraft})}):null]}),ee]})}function jn({selectionNotice:e,rateLimitNotice:t,composer:n,conversation:r}){return(0,U.jsxs)(U.Fragment,{children:[e||t?(0,U.jsxs)(`div`,{className:`canvas-selection-notice`,role:`alert`,children:[e?(0,U.jsx)(`div`,{children:e}):null,t?(0,U.jsx)(`div`,{children:t}):null]}):null,n?(0,U.jsx)(`div`,{className:`canvas-composer-shell`,children:(0,U.jsx)(_n,{...n})}):null,r?(0,U.jsx)(`div`,{className:`canvas-conversation-shell`,children:(0,U.jsx)(An,{...r},r.thread.root.id)}):null]})}function Mn({preference:e,disabled:t=!1}){let n=(0,V.useId)(),r=(0,V.useId)(),i=(0,V.useId)(),a=(0,V.useId)();return(0,U.jsxs)(`section`,{className:`canvas-hub-section`,"aria-labelledby":n,children:[(0,U.jsx)(H.Heading,{as:`h3`,size:`subhead-medium`,id:n,children:q.settings}),(0,U.jsxs)(`div`,{className:`canvas-publish-settings__option`,children:[(0,U.jsx)(`label`,{id:r,htmlFor:i,children:q.alwaysCommit}),(0,U.jsx)(lt,{className:`canvas-publish-settings__toggle`,id:i,"aria-labelledby":r,"aria-describedby":e.error?a:void 0,checked:e.remember===!0,disabled:e.loading||e.remember===null,"aria-disabled":e.saving||t||void 0,onChange:n=>{!e.saving&&!t&&e.save(n)},size:`small`})]}),e.error?(0,U.jsxs)(`div`,{id:a,className:`canvas-publish-settings__error`,children:[(0,U.jsx)(pe,{title:e.error,variant:`critical`,layout:`compact`}),(0,U.jsx)(H.Button,{size:`small`,disabled:e.loading||e.saving,onClick:()=>void e.retry(),children:q.retrySettings})]}):null]})}function Nn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pn(e){return!Nn(e)||typeof e.pathname!=`string`||typeof e.search!=`string`||typeof e.hash!=`string`?null:{pathname:e.pathname,search:e.search,hash:e.hash}}function Fn({config:e,frameRef:t,onRouteChange:n,status:r,onStatusChange:i,onSelectHub:o,onConnect:s,onDisconnected:c,connectionButtonRef:l,connecting:u=!1,publication:d,publicationBusy:f=!1,dirty:p=!1,onPublish:m,onRetryPublication:h,publishPreference:g,open:_,onClose:v}){let[y,b]=(0,V.useState)({identity:``,items:[]}),x=r?.prototype?.repositoryId,S=r?.prototype?.id,C=r?.state===`connected`,w=r?.hubOrigin,T=(0,V.useMemo)(()=>({load:async()=>{if(!C||!w)throw Error(K.mentionSuggestionsError);return on.parse(await $(`/api/hub/mention-candidates?repositoryId=${x}&prototypeId=${S}`,e.token)).candidates},copy:{suggestions:K.mentionSuggestions,error:K.mentionSuggestionsError,loading:K.mentionSuggestionsLoading,empty:K.mentionSuggestionsEmpty,retry:xt.retryLabel,limit:K.mentionLimit}}),[e.token,C,w,x,S]),[E,D]=(0,V.useState)(!1),[O,k]=(0,V.useState)(bt),[A,j]=(0,V.useState)(!0),[M,ee]=(0,V.useState)(null),[N,P]=(0,V.useState)(null),[F,I]=(0,V.useState)(``),[R,z]=(0,V.useState)(``),[te,B]=(0,V.useState)(``),[ne,re]=(0,V.useState)(``),[ie,ae]=(0,V.useState)(!1),[oe,se]=(0,V.useState)(!1),[ce,W]=(0,V.useState)(!1),[G,le]=(0,V.useState)(r?.discovery?.mismatch&&r.discovery.origin||r?.hubOrigin||``),[ue,de]=(0,V.useState)(!1),[fe,q]=(0,V.useState)(!1),[me,he]=(0,V.useState)(``),[ge,_e]=(0,V.useState)(``),[ve,ye]=(0,V.useState)(``),[be,J]=(0,V.useState)(!1),[xe,Se]=(0,V.useState)(null),[Ce,we]=(0,V.useState)(!1),[Te,Ee]=(0,V.useState)(new Map),[De,Oe]=(0,V.useState)(!1),[Y,ke]=(0,V.useState)(``),[je,Me]=(0,V.useState)(null),[Ne,Pe]=(0,V.useState)(!1),[Z,Fe]=(0,V.useState)(null),[Ie,Le]=(0,V.useState)(null),[Re,ze]=(0,V.useState)(!1),[Be,Ve]=(0,V.useState)(null),He=(0,V.useRef)(!1),Ue=(0,V.useRef)(0),We=(0,V.useRef)(!1),Ge=(0,V.useRef)(0),Ke=(0,V.useRef)(``),qe=(0,V.useRef)(``),Je=(0,V.useRef)(void 0),Ye=(0,V.useRef)(0),Xe=(0,V.useRef)(null),Ze=(0,V.useRef)(null),Qe=(0,V.useRef)(!1),$e=(0,V.useRef)(``),nt=(0,V.useRef)(_),at=(0,V.useRef)(void 0),ot=`${r?.hubOrigin??``}/${r?.repository??``}/${r?.branch??``}/${r?.state===`connected`?r.prototype?.id??``:``}`,lt=r?.reviewRevision,ut=lt?.id,dt=`${ot}/revision/${ut??``}`,ft=r?r.discovery?.mismatch&&r.discovery.origin||r.hubOrigin||``:null,pt=(0,V.useRef)(ft),mt=r?.state,ht=mt===`unavailable`||mt===`denied`,gt=(0,V.useRef)(mt);(0,V.useEffect)(()=>{if(ft===null||pt.current===ft)return;let e=window.setTimeout(()=>{le(ft),pt.current=ft},0);return()=>window.clearTimeout(e)},[ft]),(0,V.useEffect)(()=>{if(!mt||gt.current===mt)return;if(mt!==`connected`&&mt!==`undiscovered`){gt.current=mt;return}let e=window.setTimeout(()=>{W(!1),gt.current=mt},0);return()=>window.clearTimeout(e)},[mt]);let _t=cn({identity:ot,enabled:r?.repositoryAuthorized===!0,ready:De,bridgeProblem:Y,token:e.token}),St=(0,V.useMemo)(()=>y.identity===dt?y.items:[],[y,dt]),wt=(0,V.useMemo)(()=>Ct(St),[St]),Tt=(0,V.useMemo)(()=>{let e=new Map(wt.flatMap(e=>e.participants.map(e=>[e.login.toLowerCase(),e])));return Array.from(e.values()).sort((e,t)=>(e.name||e.login).localeCompare(t.name||t.login))},[wt]),Et=(0,V.useMemo)(()=>{let e=new Map;for(let t of wt){let n=t.root.id,r=Te.get(n);if(r)e.set(n,{commentId:n,status:`resolved`,point:r,rect:r.rect});else if(De){let r=t.root.anchor.route;e.set(n,{commentId:n,status:M&&(r.pathname!==M.pathname||r.search!==M.search||r.hash!==M.hash)?`route-mismatch`:`missing`})}}return e},[De,Te,M,wt]),Dt=wt.find(e=>e.root.id===N),Q=r?.state===`connected`?r.prototype:null,Ot=r?.state===`disconnected`||r?.state===`pairing`||r?.state===`unconfigured`,kt=Q?.build?.author.login,At=kt&&/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}(?:\[bot\])?$/i.test(kt)?`https://github.com/${encodeURIComponent(kt)}`:null,jt=Q?.build?.author.name?.trim()||(At?kt:null)||K.unknownCommitAuthor,Mt=Q?.canEdit&&Q.registered,Nt=Q?.id,Pt=Q?.build??null,Ft=Q?.viewerLogin||r?.viewerLogin,It=(0,V.useMemo)(()=>Ft?wt.filter(e=>an(e,{filters:O,viewerLogin:Ft,selectedBuildNumber:ut?null:Pt?.number,selectedDraftRevisionId:ut,route:M})):wt,[Pt?.number,ut,O,M,Ft,wt]),Lt=It.length,Rt=It.some(e=>e.unread),zt=!(!lt||r?.reviewError),Bt=!!(r?.repositoryAuthorized&&r.branch&&r.viewerLogin)||!!Q,Vt=Z!==null||Ce||Be!==null||Ne,Ht=_&&!E,Ut=typeof document>`u`?null:document.getElementById(`canvas-review-controls`),Wt=Z?Z.kind===`element`?{x:Z.rect.x-Z.viewport.scrollX+Z.rect.width*Z.elementOffset.x,y:Z.rect.y-Z.viewport.scrollY+Z.rect.height*Z.elementOffset.y}:st(Z,{x:Z.rect.x-Z.viewport.scrollX,y:Z.rect.y-Z.viewport.scrollY,width:Z.rect.width,height:Z.rect.height}).point:null;(0,V.useLayoutEffect)(()=>($e.current=ot,Ye.current+=1,Qe.current=!1,()=>window.clearTimeout(at.current)),[ot]),(0,V.useLayoutEffect)(()=>{Ke.current=dt,Ge.current+=1},[dt]),(0,V.useLayoutEffect)(()=>{_&&Xe.current?.focus({preventScroll:!0})},[_]),(0,V.useLayoutEffect)(()=>{!Z&&!Be&&!Ce&&Qe.current&&(Qe.current=!1,Ze.current?.focus({preventScroll:!0}))},[Z,Be,Ce]),(0,V.useEffect)(()=>{let e=nt.current;if(nt.current=_,!_||e||!E)return;if(Ce){v();return}let t=window.setTimeout(()=>{D(!1),P(null)},0);return()=>window.clearTimeout(t)},[E,Ce,v,_]),(0,V.useEffect)(()=>{if(!_)return;function e(e){e.key!==`Escape`||e.defaultPrevented||e.target instanceof Element&&e.target.closest(`[role="dialog"], dialog, [role="menu"]`)||(e.preventDefault(),v())}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[_,v]);let Kt=be&&xe===ot,qt=JSON.stringify(wt.slice(0,200).map(({root:e})=>({id:e.id,anchor:e.anchor}))),Jt=(0,V.useCallback)(async()=>{if(!Bt||We.current||Ke.current!==dt)return;let t=dt,n=++Ge.current,r=Ue.current;ae(!0),se(!1);try{let i=[],a=null;for(let t=0;t<100;t+=1){let n=nn.parse(await $(`/api/hub/comments${a||ut?`?${new URLSearchParams({...a?{cursor:a}:{},...ut?{local_revision_id:String(ut)}:{}})}`:``}`,e.token));if(i.push(...n.comments),a=n.nextCursor,!a)break;if(t===99)throw Error(K.commentPagesExceeded)}if(Ke.current!==t||Ge.current!==n||Ue.current!==r)return;b({identity:t,items:i}),se(!1),I(``)}catch(e){Ke.current===t&&Ge.current===n&&Ue.current===r&&(se(!0),I(e instanceof Error?e.message:String(e)))}finally{Ke.current===t&&Ge.current===n&&Ue.current===r&&ae(!1)}},[e.token,ut,Bt,dt]),Yt=(0,V.useRef)(Jt);(0,V.useLayoutEffect)(()=>{Yt.current=Jt},[Jt]),(0,V.useEffect)(()=>{let e=window.setTimeout(()=>{b({identity:Ke.current,items:[]}),D(!1),k(bt),j(!0),ee(null),P(null),we(!1),J(!1),Se(null),he(``),_e(``),Ve(null),He.current=!1,We.current=!1,Ue.current+=1,Ee(new Map),Oe(!1),Me(null),Pe(!1),Fe(null),Le(null),z(``),B(``),se(!1)},0);return()=>window.clearTimeout(e)},[ot]),(0,V.useEffect)(()=>{if(!Bt)return;let e=window.setTimeout(()=>void Jt(),0);return()=>window.clearTimeout(e)},[Bt,Jt]),(0,V.useEffect)(()=>{if(!Bt)return;let e=window.setInterval(()=>void Jt(),3e4);return()=>window.clearInterval(e)},[Bt,Jt]),(0,V.useEffect)(()=>{if(!Nt)return;let t=new AbortController,n,r=5e3;async function i(){let a=Date.now();try{let n=await fetch(`/api/hub/events`,{headers:{"X-Replica-Canvas-Token":e.token},signal:t.signal});if(!n.ok||!n.body)throw Error(`Live review connection unavailable.`);ze(!1);let r=n.body.getReader(),i=new TextDecoder,a=``;for(;!t.signal.aborted;){let{value:e,done:t}=await r.read();if(t)throw Error(`Live review connection closed.`);a+=i.decode(e,{stream:!0});let n=a.split(` `);a=n.pop()||``;for(let e of n)if(e.startsWith(`event: comments -`)&&Mt(),e.startsWith(`event: error -`))throw Error(`Live review connection failed.`)}}catch{t.signal.aborted||Ie(!0)}t.signal.aborted||(Date.now()-a>=3e4&&(r=5e3),n=window.setTimeout(()=>void i(),r),r=Math.min(r*2,6e4))}return i(),()=>{t.abort(),window.clearTimeout(n)}},[qe,ht,e.token,Mt]);let Nt=(0,V.useCallback)((n,r={})=>{let i=t.current;return!i?.contentWindow||!He.current?!1:(i.contentWindow.postMessage({type:n,nonce:He.current,...r},new URL(e.previewUrl??e.prototypeUrl).origin),!0)},[e.prototypeUrl,e.previewUrl,t]),Pt=(0,V.useCallback)(e=>{Ee&&Tt&&!Et&&(P(null),Pe(null),Ae(e),v(),Nt(`replica:canvas:select`,{mode:e}))},[Ee,Tt,v,Et,Nt]),Ft=(0,V.useCallback)(()=>{J&&(Nt(`replica:canvas:cancel-selection`),Ae(null))},[J,Nt]),It=(0,V.useCallback)(()=>{Nt(`replica:canvas:clear-selection`),Me(null),Pe(null)},[Nt]);(0,V.useEffect)(()=>{let r=t.current;if(!r){Te(new Map),De(!1);return}let i=new URL(e.previewUrl??e.prototypeUrl).origin,a=JSON.parse(jt),o=new Set(a.map(({id:e})=>e)),s=Date.now(),c=!1;function l(){He.current=crypto.randomUUID(),s=Date.now(),c=!1,De(!1),ke(``),Te(new Map),r?.contentWindow?.postMessage({type:`replica:canvas:request-ready`,nonce:He.current},i),u()}function u(){a.length&&r?.contentWindow?.postMessage({type:`replica:canvas:resolve`,nonce:He.current,anchors:a},i)}function d(e){let t=e.data;if(e.source===r?.contentWindow&&e.origin===i&&Nn(t)&&t.nonce===He.current){if(t.type===`replica:canvas:bridge-error`)De(!1),ke(G.commentingMissing);else if(t.type===`replica:canvas:ready`){if(t.protocolVersion!==1){c=!0,De(!1),ke(G.commentingIncompatible);return}if(!Pn(t.route))return;s=Date.now(),c=!1,De(!0),ke(``),ee(Pn(t.route)),n?.(Pn(t.route),t.replaceRoute===!0)}else if(!c){if(t.type===`replica:canvas:conversation-dismiss-requested`)window.dispatchEvent(new Event(`replica:review-dismiss`));else if(t.type===`replica:canvas:resolved`){if(t.protocolVersion!==1||!Pn(t.route)||!Array.isArray(t.results)||t.results.length>200)return;s=Date.now(),De(!0),ke(``),ee(Pn(t.route)),n?.(Pn(t.route),t.replaceRoute===!0);let e=new Map;for(let n of t.results){if(!Nn(n)||typeof n.id!=`number`||typeof n.x!=`number`||typeof n.y!=`number`||!o.has(n.id)||!Number.isFinite(n.x)||!Number.isFinite(n.y)||n.x<0||n.y<0||n.x>r.clientWidth||n.y>r.clientHeight)continue;let t=Nn(n.rect)&&typeof n.rect.x==`number`&&typeof n.rect.y==`number`&&typeof n.rect.width==`number`&&typeof n.rect.height==`number`&&Number.isFinite(n.rect.x)&&Number.isFinite(n.rect.y)&&Number.isFinite(n.rect.width)&&Number.isFinite(n.rect.height)&&n.rect.width>=0&&n.rect.height>=0?{x:n.rect.x,y:n.rect.y,width:n.rect.width,height:n.rect.height}:{x:n.x,y:n.y,width:0,height:0};e.set(n.id,{x:n.x,y:n.y,rect:t})}Te(e)}else if(t.type===`replica:canvas:selected`){let e=Gt.safeParse(t.anchor);if(!e.success){Nt(`replica:canvas:cancel-selection`),Nt(`replica:canvas:clear-selection`),Ae(null),Pe(Nn(t.anchor)&&t.anchor.kind===`area`?`area-unavailable`:`element-unavailable`);return}Me(e.data),Ae(null),Pe(null)}else t.type===`replica:canvas:selection-failed`&&(t.reason===`element-unavailable`||t.reason===`area-too-small`||t.reason===`area-unavailable`)?(Ae(null),Pe(t.reason)):t.type===`replica:canvas:selection-cancelled`&&Ae(null)}}}function f(){Ae(null),Me(null),Pe(null),l()}r.addEventListener(`load`,f),window.addEventListener(`message`,d),l();let p=window.setInterval(()=>{Date.now()-s>=2e4&&(De(!1),Te(new Map),ke(c?G.commentingIncompatible:G.commentingMissing)),r.contentWindow?.postMessage({type:`replica:canvas:request-ready`,nonce:He.current},i),u()},2e3);return()=>{r.removeEventListener(`load`,f),window.removeEventListener(`message`,d),window.clearInterval(p)}},[qe,jt,e.prototypeUrl,e.previewUrl,t,n,Nt]);async function Lt(t,n,r,i){let a=qe,o=i?.kind===`add-reaction`||i?.kind===`remove-reaction`||i?.kind===`mark-unread`;if(i){if(ze.current)return!1;ze.current=!0,Re(i)}o&&(Ve.current=!0,Be.current+=1),z(``);try{let i=await $(`/api/hub/comments/${t}`,e.token,{method:n,...r?{body:JSON.stringify(r)}:{}});if(We.current!==a)return!1;if(o){let e=rn.parse(i);b(t=>{if(t.identity!==a)return t;let n=new Map(t.items.map(e=>[e.id,e]));for(let t of e.comments)n.set(t.id,t);return{identity:a,items:[...n.values()]}})}return o||(Ke.current=window.setTimeout(()=>void Mt(),0)),!0}catch(e){return We.current===a&&(I(e instanceof Error?e.message:String(e)),e instanceof Error&&`statusCode`in e&&e.statusCode===429&&z(e.message)),!1}finally{i&&We.current===a&&(o&&(Ve.current=!1,Be.current+=1,Ke.current=window.setTimeout(()=>void Mt(),0)),ze.current=!1,Re(null))}}async function Rt(t){if(!gt||!X||ze.current)return!1;let n=qe;ze.current=!0,Re({kind:`create`}),z(``);try{let r=rn.parse(await $(`/api/hub/comments`,e.token,{method:`POST`,body:JSON.stringify({review_comment:{build_number:gt.number,body:t,anchor:X}})}));if(We.current!==n)return!1;let i=r.comments.find(e=>e.kind===`root`);return i?(b(e=>{if(e.identity!==n)return e;let t=new Map(e.items.map(e=>[e.id,e]));for(let e of r.comments)t.set(e.id,e);return{identity:n,items:[...t.values()]}}),It(),P(i.id),!0):!1}catch(e){return We.current===n&&(I(e instanceof Error?e.message:String(e)),e instanceof Error&&`statusCode`in e&&e.statusCode===429&&z(e.message)),!1}finally{We.current===n&&(ze.current=!1,Re(null))}}function zt(){Et||(E?(P(null),D(!1)):(D(!0),_&&v()))}let Bt=r?.repository&&r.branch?`https://github.com/${r.repository.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}/tree/${encodeURIComponent(r.branch)}`:null,Vt=r?.branch&&Bt?(0,U.jsxs)(`a`,{className:`canvas-hub-publication__branch`,href:Bt,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`Open ${r.branch} on GitHub`,children:[(0,U.jsx)(a,{size:16,"aria-hidden":`true`}),(0,U.jsx)(`span`,{children:r.branch})]}):r?.branch?(0,U.jsxs)(`span`,{className:`canvas-hub-publication__branch`,children:[(0,U.jsx)(a,{size:16,"aria-hidden":`true`}),(0,U.jsx)(`span`,{children:r.branch})]}):null,Ht=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(H.Heading,{as:`h3`,size:`subhead-medium`,id:`canvas-hub-origin-title`,children:`Hub`}),r&&r.state!==`unconfigured`?(0,U.jsx)(`div`,{className:`canvas-hub-origin`,children:r.hubOrigin?(0,U.jsx)(`a`,{href:Q?new URL(`/repositories/${Q.repositoryId}/prototypes/${Q.id}`,r.hubOrigin).href:r.hubOrigin,target:`_blank`,rel:`noopener noreferrer`,children:r.hubOrigin}):(0,U.jsx)(`span`,{children:`URL unavailable`})}):null,oe||r?.state===`disconnected`||r?.state===`unconfigured`?(0,U.jsxs)(`form`,{className:`canvas-hub-origin-form`,onSubmit:e=>{e.preventDefault(),!(W||de)&&(ue(!0),se(!0),I(``),o(ce).then(()=>{se(!1)}).catch(e=>I(e.message)).finally(()=>ue(!1)))},children:[(0,U.jsxs)(`div`,{className:`canvas-hub-origin-field`,children:[(0,U.jsxs)(`label`,{children:[G.hubUrl,(0,U.jsx)(`input`,{type:`url`,required:!0,value:ce,placeholder:`https://hub.example.com`,disabled:W||de,onChange:e=>le(e.target.value)})]}),(0,U.jsx)(H.Button,{type:`button`,size:`small`,variant:`subtle`,className:`canvas-icon-button`,leadingVisual:(0,U.jsx)(L,{size:16}),"aria-label":G.resetHubUrl,title:G.resetHubUrl,disabled:W||de,"aria-busy":de,onClick:()=>{fe(!0),I(``),$(`/api/hub/discovery`,e.token,{method:`POST`,body:`{}`}).then(async e=>{if(e.discovery?.state!==`valid`||!e.discovery.origin)throw Error(e.discovery?.message||G.resetHubUnavailable);le(e.discovery.origin),await i()}).catch(e=>I(e.message)).finally(()=>fe(!1))},children:(0,U.jsx)(`span`,{className:`visually-hidden`,children:G.resetHubUrl})})]}),(0,U.jsx)(`p`,{children:G.hubHttpsHint}),(0,U.jsxs)(`div`,{className:`canvas-hub-form-actions`,children:[(0,U.jsx)(H.Button,{type:`submit`,size:`small`,disabled:W||de,children:`Save Hub`}),oe&&r?.state!==`unconfigured`&&r?.state!==`disconnected`?(0,U.jsx)(H.Button,{type:`button`,size:`small`,variant:`subtle`,disabled:W||de,onClick:()=>se(!1),children:`Cancel`}):null]})]}):null]});return(0,U.jsxs)(it,{source:T,children:[$e.visible?(0,U.jsx)(sn,{...$e}):null,Q&&Ot?(0,tt.createPortal)((0,U.jsxs)(`div`,{className:`canvas-review-controls review-shell__comment-actions`,role:`group`,"aria-label":bt.heading,children:[(0,U.jsx)(vt,{bridgeReady:Ee&&Tt,copy:bt,selectionBlocked:Et,selecting:J!==null,onCancelSelection:Ft,onStartAreaSelection:()=>Pt(`area`),onStartElementSelection:()=>Pt(`element`)}),(0,U.jsx)(H.Tooltip,{text:Et?bt.selectionBlockedLabel:`${bt.heading} (${bt.sidebarShortcutLabel})`,type:`description`,children:(0,U.jsxs)(H.Button,{className:`canvas-comments-toggle review-shell__comments-toggle`,variant:`secondary`,size:`small`,"aria-label":`${bt.heading}, ${Ct}${wt?`, ${bt.unreadLabel}`:``}`,"aria-expanded":E,"aria-keyshortcuts":`Shift+C`,disabled:!gt||Et,onClick:zt,children:[(0,U.jsx)(nt,{children:Ct}),wt?(0,U.jsx)(`span`,{className:`canvas-comments-unread-badge review-shell__unread-badge`,"aria-hidden":`true`}):null]})})]}),Ot):null,A&&xt.length&&Ee?(0,U.jsx)(`div`,{className:`canvas-marker-layer`,children:(0,U.jsx)(lt,{threads:xt,resolutions:st,selectedThreadId:N,selectionBlocked:Se,focusSelectedMarker:!1,showAreaHighlightsOnlyWhenSelected:!0,copy:bt,onSelect:e=>P(e.root.id)})}):null,(0,U.jsxs)(at,{className:`canvas-hub-panel`,contentClassName:`canvas-hub-content`,title:`Replica Hub`,label:`Hub`,open:Dt,closeLabel:`Close Hub`,closeRef:Ue,onClose:v,children:[F?(0,U.jsx)(`p`,{role:`alert`,children:F}):null,te?(0,U.jsx)(`p`,{role:`alert`,children:te}):null,r?null:(0,U.jsx)(`p`,{children:`Checking Hub connection…`}),!ut&&!Ze&&r?.message?(0,U.jsx)(`p`,{role:`status`,children:r.message}):null,Ze?(0,U.jsxs)(`div`,{className:`canvas-hub-status`,children:[(0,U.jsx)(me,{variant:`warning`,layout:`compact`,title:r?.message||Y.hubUnavailable}),(0,U.jsx)(H.Button,{variant:`primary`,size:`small`,disabled:f,"aria-busy":f,leadingVisual:f?(0,U.jsx)(L,{size:16}):void 0,onClick:h||(()=>void i()),children:Y.retry})]}):null,!ut&&!Ze&&d&&m&&h?(0,U.jsx)(je,{publication:d,busy:f,dirty:p,onPublish:m,onRetry:h}):null,ut?(0,U.jsxs)(`section`,{className:`canvas-hub-connection`,children:[(0,U.jsx)(`p`,{children:G.connectionBeforePublishing}),(0,U.jsx)(H.Button,{ref:l,variant:`primary`,onClick:s,disabled:u,children:u?G.connectionOpeningBrowser:G.connectToHub})]}):null,!ut&&(!oe&&(r?.discovery?.mismatch||[`invalid`,`unreachable`].includes(r?.discovery?.state||``))||r?.state===`unconfigured`)?(0,U.jsxs)(`div`,{className:`canvas-hub-settings`,children:[!oe&&r?.discovery?.mismatch?(0,U.jsx)(`p`,{role:`alert`,children:`The repository configuration differs from your selected Hub. Your connection has not changed. Disconnect Hub before selecting another URL.`}):null,!oe&&[`invalid`,`unreachable`].includes(r?.discovery?.state||``)?(0,U.jsx)(`p`,{role:`alert`,children:r?.discovery?.message}):null,r?.state===`unconfigured`?(0,U.jsx)(`p`,{children:`Enter your Hub URL to connect.`}):null]}):null,r?.state===`undiscovered`&&!d?(0,U.jsxs)(`p`,{children:[`Connected to `,r.repository,`. Hub has not discovered`,` `,r.branch||`a prototype branch`,`. Your repository connection is ready. Push a named branch to make its Builds and reviews available.`]}):null,Q?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`section`,{className:d&&d.kind!==`ready`&&m&&h?`canvas-hub-publication canvas-hub-publication--after-status`:`canvas-hub-publication`,"aria-label":`Prototype`,children:mt&&At?(0,U.jsxs)(`form`,{className:`canvas-hub-publication__form`,onSubmit:t=>{t.preventDefault(),$(`/api/hub/metadata`,e.token,{method:`PATCH`,body:JSON.stringify({name:pe,description:he,startPage:_e})}).then(async()=>{be(!1),await i()}).catch(e=>I(e.message))},children:[(0,U.jsxs)(`div`,{className:`canvas-hub-publication__title`,children:[(0,U.jsxs)(`label`,{className:`canvas-hub-publication__name-field`,children:[(0,U.jsx)(`span`,{className:`visually-hidden`,children:`Name`}),(0,U.jsx)(`input`,{required:!0,maxLength:255,value:pe,onChange:e=>K(e.target.value)})]}),(0,U.jsx)(`span`,{className:`canvas-hub-publication__status`,children:Q.published?`Published`:Q.registered?`Registered`:`Not registered`})]}),Vt,(0,U.jsxs)(`label`,{className:`canvas-hub-publication__description-field`,children:[(0,U.jsx)(`span`,{className:`visually-hidden`,children:`Description`}),(0,U.jsx)(`textarea`,{value:he,placeholder:`Add a description`,onChange:e=>ge(e.target.value)})]}),(0,U.jsxs)(`label`,{className:`canvas-hub-publication__start-page-field`,children:[G.startPage,(0,U.jsx)(`input`,{value:_e,placeholder:`/`,"aria-describedby":`canvas-start-page-hint`,onChange:e=>ve(e.target.value)})]}),(0,U.jsx)(`p`,{id:`canvas-start-page-hint`,className:`canvas-hub-publication__hint`,children:G.startPageHint}),(0,U.jsxs)(`div`,{className:`canvas-hub-form-actions`,children:[(0,U.jsx)(H.Button,{type:`submit`,size:`small`,children:`Save metadata`}),(0,U.jsx)(H.Button,{type:`button`,size:`small`,variant:`subtle`,onClick:()=>be(!1),children:`Cancel`})]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`canvas-hub-publication__title`,children:[(0,U.jsx)(H.Heading,{as:`h3`,size:`subhead-large`,children:Q.name||r?.branch}),(0,U.jsx)(`span`,{className:`canvas-hub-publication__status`,children:Q.published?`Published`:Q.registered?`Registered`:`Not registered`})]}),Vt,Q.description?(0,U.jsx)(`p`,{className:`canvas-hub-publication__description`,children:Q.description}):null,(0,U.jsxs)(`p`,{className:`canvas-hub-publication__description canvas-hub-publication__start-page`,children:[G.startPage,`: `,(0,U.jsx)(`code`,{children:Q.startPage||`/`})]}),mt?(0,U.jsx)(H.Button,{size:`small`,variant:`subtle`,onClick:()=>{K(Q.name||``),ge(Q.description||``),ve(Q.startPage||``),q(qe),be(!0)},children:G.editDetails}):null]})}),(0,U.jsxs)(`section`,{className:`canvas-hub-section`,"aria-labelledby":`canvas-hub-build-title`,children:[(0,U.jsx)(H.Heading,{as:`h3`,size:`subhead-medium`,id:`canvas-hub-build-title`,children:G.latestBuild}),Q.build?(0,U.jsxs)(`div`,{className:`canvas-hub-build`,children:[(0,U.jsxs)(`div`,{className:`canvas-hub-build__identity`,children:[(0,U.jsx)(`a`,{href:Q.build.url,target:`_blank`,rel:`noopener noreferrer`,children:G.buildTitle(Q.build.number)}),(0,U.jsx)(`code`,{title:Q.build.commitSha,"aria-label":`${G.buildCommit} ${Q.build.commitSha}`,children:Q.build.commitSha.slice(0,7)})]}),(0,U.jsx)(`p`,{children:ft?(0,U.jsx)(`a`,{className:`canvas-hub-build__author`,href:ft,target:`_blank`,rel:`noopener noreferrer`,children:pt}):(0,U.jsx)(`span`,{children:pt})}),r?.commitSha&&r.commitSha!==Q.build.commitSha?(0,U.jsx)(`p`,{className:`canvas-hub-build__notice`,children:`Local checkout differs from this Build`}):null]}):(0,U.jsxs)(`p`,{children:[`No successful imported Build yet. Current Build: `,Q.buildState||`none`,`.`]}),Q.build&&r?.hubOrigin?(0,U.jsx)(`a`,{className:`canvas-hub-build__history`,href:new URL(`/repositories/${Q.repositoryId}/prototypes/${Q.id}/builds`,r.hubOrigin).href,target:`_blank`,rel:`noopener noreferrer`,children:G.showBuildHistory}):null]})]}):null,ut?null:(0,U.jsxs)(`section`,{className:`canvas-hub-section`,"aria-labelledby":`canvas-hub-origin-title`,children:[Ht,r?.hubOrigin&&[`connected`,`undiscovered`,`pairing`,`denied`,`unavailable`].includes(r.state)?(0,U.jsx)(`div`,{className:`canvas-hub-disconnect`,children:(0,U.jsx)(H.Button,{size:`small`,variant:`subtle`,onClick:()=>{B(``),$(`/api/hub/disconnect`,e.token,{method:`POST`,body:`{}`}).then(async()=>{le(r.discovery?.mismatch&&r.discovery.origin||r.hubOrigin||``),se(!0),await i(),c?.()}).catch(e=>{B(G.disconnectFailed(r.hubOrigin||``,e.message)),le(r.discovery?.mismatch&&r.discovery.origin||r.hubOrigin||``),se(!0)})},children:`Disconnect Hub`})}):null]}),Q?.registered&&Q.build&&g?(0,U.jsx)(Mn,{preference:g,disabled:f}):null]}),Q?(0,U.jsx)(_t,{frame:{open:E,className:`canvas-comments-sidebar-shell`,contentClassName:`canvas-comments-sidebar-content`},threads:xt,currentBuildNumber:gt?.number||0,buildLinkOrigin:r?.hubOrigin,totalCount:xt.length,hasThreads:rt.length>0,filters:O,participants:ot,resolutions:st,selectedThreadId:N,selectionBlocked:Et,closeBlocked:Se,showPins:A,loading:ne,loadFailed:ie,notice:Fe||gt&&!Tt?(0,U.jsxs)(`div`,{className:`canvas-comments-live-notices`,children:[Fe?(0,U.jsx)(`p`,{className:`canvas-comments-live-status`,role:`status`,children:`Live updates paused; checking every 30 seconds.`}):null,gt&&!Tt?(0,U.jsxs)(`p`,{className:`canvas-comments-live-status`,children:[`New comments are available when the local checkout matches Build #`,gt.number,`.`]}):null]}):null,copy:bt,onClose:zt,onFiltersChange:k,onShowPinsChange:j,onRetry:()=>void Mt(),onSelect:e=>P(e.root.id)}):null,(0,U.jsx)(An,{selectionNotice:Ne?Ne===`area-too-small`?bt.areaTooSmallLabel:Ne===`area-unavailable`?bt.areaUnavailableLabel:bt.selectionFailedLabel:null,rateLimitNotice:R&&!Dt?R:null,composer:X&&kt?{anchorPoint:kt,bodyMaximumBytes:1e4,copy:bt,creating:Le?.kind===`create`,onSubmit:Rt,onDiscard:It}:null,conversation:Z?{thread:Z,anchorPoint:we.get(Z.root.id)??null,bodyMaximumBytes:1e4,mutation:Le,copy:bt,onClose:()=>P(null),onDraftStateChange:Ce,onReply:e=>Lt(`${Z.root.id}/replies`,`POST`,{review_comment:{body:e}},{kind:`reply`,commentId:Z.root.id}),onEdit:(e,t)=>Lt(`${e}`,`PATCH`,{review_comment:{body:t}},{kind:`edit`,commentId:e}),onDelete:e=>Lt(`${e}`,`DELETE`,void 0,{kind:`delete`,commentId:e}),onResolve:()=>Lt(`${Z.root.id}/resolution`,`POST`,void 0,{kind:`resolve`,commentId:Z.root.id}),onReopen:()=>Lt(`${Z.root.id}/resolution`,`DELETE`,void 0,{kind:`reopen`,commentId:Z.root.id}),onAddReaction:(e,t)=>Lt(`${e}/reactions`,`POST`,{review_comment_reaction:{content:t,activity_version:Z.root.activityVersion}},{kind:`add-reaction`,commentId:e,content:t}),onRemoveReaction:(e,t)=>Lt(`${e}/reactions/${encodeURIComponent(t)}`,`DELETE`,{review_comment_reaction:{activity_version:Z.root.activityVersion}},{kind:`remove-reaction`,commentId:e,content:t}),onMarkRead:e=>Lt(`${Z.root.id}/read`,`POST`,{review_thread_read:{activity_version:e}}),onMarkUnread:()=>Lt(`${Z.root.id}/read`,`DELETE`,void 0,{kind:`mark-unread`,commentId:Z.root.id})}:null})]})}function In(e,t,n){function r(e,t,n){return{kind:e,title:t,detail:n}}if(!e||!t)return n.kind===`unknown`?r(`retry`,J.unavailable,n.detail):r(`checking`,J.checking,J.checkingDetail);if(!e.stats.branch)return r(`restricted`,J.restricted,n.detail);if(t.repository&&t.repository!==e.stats.repository||t.branch&&t.branch!==e.stats.branch)return r(`retry`,J.unavailable,J.changedDetail);if(t.discovery?.state===`local`||e.stats.repository?.startsWith(`local/`))return r(`restricted`,J.restricted,J.local);if(t.registrationReason===`branch_not_reviewable`||e.stats.branch===t.discovery?.defaultBranch)return r(`restricted`,J.restricted,Y.registrationReasons.get(`branch_not_reviewable`).description);if([`disconnected`,`pairing`,`unconfigured`].includes(t.state))return r(`connect`,J.connect,J.connectDetail);if([`denied`,`unavailable`].includes(t.state))return r(`retry`,J.unavailable,t.message||J.unavailableDetail);if(t.repository!==e.stats.repository||t.branch!==e.stats.branch)return r(`retry`,J.unavailable,J.unavailableDetail);let i=t.prototype;if(t.state===`connected`&&i?.branch===e.stats.branch&&i.registered&&i.published&&i.build&&Number.isSafeInteger(i.build.number)&&i.build.number>0)return r(`ready`,J.ready,J.readyDetail);if(t.state===`connected`&&(!i||i.branch!==e.stats.branch||typeof i.published!=`boolean`||i.published))return r(`retry`,J.unavailable,J.unavailableDetail);let a=t.state===`connected`?i?.canEdit:t.canPublish;if(a===!1)return r(`restricted`,J.restricted,J.publishDenied);let o=e.stats.remoteBranch,s=t.state===`undiscovered`&&t.repositoryAuthorized===!0&&!i&&(!t.commitSha||t.commitSha===e.stats.commitSha)&&o?.repository===e.stats.repository&&o?.branch===e.stats.branch&&o?.commitSha===e.stats.commitSha&&(o?.state===`absent`||o?.state===`present`&&e.publishRequest?.commitSha===e.stats.commitSha&&([`requested`,`in_progress`].includes(e.publishRequest?.state??``)||e.publishRequest?.state===`idle`&&e.publishRequest.remoteState===`absent`))&&![`loading`,`unknown`,`detached`,`workflow_missing`].includes(n.kind),c=a===void 0&&s;if(a!==!0&&!c)return r(`retry`,J.unavailable,J.permissionUnknown);let l=t.registrationReason||i?.registrationReason;if(n.error&&(l!==`remote_branch_missing`||!s)){let e=[`successful_build_required`,`already_registered`].includes(l||``),t=[`write_access_required`,`repository_mismatch`,`branch_not_reviewable`,`remote_branch_missing`,`branch_authorship_required`].includes(l||``);return{...r(e?`progress`:t?`restricted`:`retry`,n.error.title,n.error.description),...e?{publication:{...n,action:`retry`,label:Y.retry}}:{}}}if(n.kind===`detached`)return r(`restricted`,J.restricted,n.detail);if(n.action===`retry`)return r(`retry`,J.unavailable,n.detail);if(n.kind===`loading`)return r(`checking`,J.checking,n.detail);let u=c?`${J.publishDetail} ${J.publishPermissionUnverified}`:J.publishDetail,d=s&&l===`remote_branch_missing`?{...n,error:void 0}:n;return n.action===`publish`?{...r(`publish`,J.publish,u),publication:d}:{...r(`progress`,J.preparing,u),publication:d}}function Ln({open:e,onToggle:t,buttonRef:n}){return(0,U.jsx)(W,{icon:C,"aria-label":G.controls,description:G.controls,ref:n,size:`small`,variant:`default`,className:`canvas-controls-toggle`,"aria-expanded":e,onClick:t})}function Rn({toolbarRef:e,config:t,onPublish:n,publishButtonRef:r,hubButtonRef:a,titleButtonRef:o,onBuildDetails:s,publishing:c,state:l,prototypeName:u,hubOpen:d,onHub:f,publication:p,onControls:m,controlsOpen:h,controlsButtonRef:g,onShare:_,shareButtonRef:v}){let y=l?.publishStatus??{state:`unavailable`,detail:G.statusUnavailable},b=u?.trim()||l?.stats.branch||l?.name||t.name,x=l?[b,l.stats.repository,l.stats.commitSha?.slice(0,7),l.stats.workingTree===`changed`?G.workingTreeChanged:G.workingTreeClean,l.stats.urlHost].filter(Boolean).join(` · `):b,S=c||(p?p.action===`none`:y.state===`requested`||y.state===`in_progress`||y.state===`published`),C=c||(p?p.kind===`requested`||p.kind===`queued`||p.kind===`building`||p.kind===`importing`||p.kind===`awaiting_build`||p.kind===`registration`:y.state===`requested`||y.state===`in_progress`),w=!C&&(p?p.kind===`ready`:y.state===`published`),T=(0,U.jsx)(H.Button,{type:`button`,ref:r,className:`canvas-publish-button`,variant:`secondary`,size:`small`,leadingVisual:C?(0,U.jsx)(L,{size:16}):zn(y.state),disabled:S&&!w,"aria-busy":C,title:w?void 0:p?.detail||y.detail,onClick:S||w?void 0:n,children:p?.label||G.publishLabels[y.state]});return(0,U.jsxs)(`header`,{ref:e,className:`canvas-toolbar`,children:[(0,U.jsx)(H.Button,{type:`button`,className:`canvas-title`,ref:o,variant:`subtle`,size:`small`,title:x,disabled:!l,onClick:s,children:b}),(0,U.jsx)(`div`,{id:`canvas-review-controls`,className:`canvas-review-controls-slot`}),m?(0,U.jsx)(Ln,{buttonRef:g,open:h,onToggle:m}):null,f?(0,U.jsx)(H.Button,{type:`button`,ref:a,size:`small`,variant:`secondary`,"aria-expanded":d,onClick:f,children:G.editDetails}):null,(0,U.jsxs)(`div`,{className:`canvas-publish-share`,role:`group`,"aria-label":q.group,children:[w?(0,U.jsx)(H.Tooltip,{ref:r,text:Y.alreadyPublished,type:`description`,children:T}):T,_?(0,U.jsx)(W,{ref:v,icon:i,size:`small`,"aria-label":q.title,description:q.title,onClick:_}):null]})]})}function zn(e){return e===`published`?(0,U.jsx)(s,{size:16}):e===`failed`||e===`in_progress`||e===`requested`?(0,U.jsx)(L,{size:16}):(0,U.jsx)(D,{size:16})}function Bn(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>Ye(e,t)))}}var Vn={bridgeUnavailable:`The prototype bridge is not ready on this page.`,routeChanged:`The prototype route changed. Inspect the live canvas again.`,reloaded:`The prototype reloaded before confirming the click. Inspect the live canvas and retry.`,unconfirmed:`The prototype did not confirm the click. Check its bridge and retry.`,clickFailed:`The target could not be clicked.`,addressUnavailable:`The canvas address field is unavailable.`,unknownAction:`Unknown canvas action.`,replyRejected:`The live canvas rejected the action reply. Check its transport diagnostics.`,actionInterrupted:`The canvas changed before the action could run. Inspect the live canvas and retry.`,statusInterrupted:`The canvas changed while collecting Controls status. Inspect the live canvas and retry.`};function Hn(e){let{token:t,prototypeUrl:n,previewUrl:r,cancelClick:i}=e,a=(0,V.useRef)(e),o=(0,V.useRef)(null);(0,V.useLayoutEffect)(()=>{a.current=e}),(0,V.useEffect)(()=>{o.current??=crypto.randomUUID();let e={"X-Replica-Renderer-Id":o.current},s=!1,c=!1,l=new AbortController,u=new URL(r??n).origin;async function d(e){let t=a.current.frameRef.current,n=a.current.liveRoute;if(!t?.contentWindow||!n)throw Error(Vn.bridgeUnavailable);if(e.route.pathname!==n.pathname||e.route.search!==n.search||e.route.hash!==n.hash)throw Error(Vn.routeChanged);let r=crypto.randomUUID();return await new Promise((n,a)=>{function o(){window.clearTimeout(c),window.removeEventListener(`message`,l),i.current===s&&(i.current=null)}function s(){o(),a(Error(Vn.reloaded))}let c=window.setTimeout(()=>{o(),a(Error(Vn.unconfirmed))},2e3);function l(i){let s=i.data;i.source===t?.contentWindow&&i.origin===u&&s&&typeof s==`object`&&`type`in s&&s.type===`replica:canvas:click-result`&&`nonce`in s&&s.nonce===r&&(o(),`clicked`in s&&s.clicked===!0?n({clicked:!0,route:e.route}):a(Error(Vn.clickFailed)))}i.current=s,window.addEventListener(`message`,l),t.contentWindow.postMessage({type:`replica:canvas:click`,nonce:r,...e},u)})}async function f(e){let t=a.current.frameRef.current,r=crypto.randomUUID(),i=Date.now()+e,o=await new Promise((n,o)=>{function s(){window.clearTimeout(d),window.removeEventListener(`message`,p),t?.removeEventListener(`load`,m),l.signal.removeEventListener(`abort`,c)}function c(){s(),o(Error(Vn.statusInterrupted))}let d=window.setTimeout(()=>{if(s(),a.current.liveRoute)o(Error(Vn.bridgeUnavailable));else{let e=new URL(a.current.navigation.entries[a.current.navigation.index]);e.protocol=new URL(u).protocol,e.host=new URL(u).host,n({status:`pending`,url:e.href,error:``,controls:[]})}},e+1500),f=!1;function p(e){let i=e.data;e.source===t?.contentWindow&&t===a.current.frameRef.current&&e.origin===u&&i&&typeof i==`object`&&`type`in i&&(i.type===`replica:canvas:ready`&&!f&&(f=!0,m()),i.type===`replica:controls:status-result`&&`nonce`in i&&i.nonce===r&&`value`in i&&(s(),n(i.value)))}function m(){t===a.current.frameRef.current&&t?.contentWindow?.postMessage({type:`replica:controls:status`,nonce:r,timeoutMs:Math.max(0,i-Date.now())},u)}window.addEventListener(`message`,p),t?.addEventListener(`load`,m),l.signal.addEventListener(`abort`,c),m()});if(!o||typeof o!=`object`||!(`url`in o)||typeof o.url!=`string`||!(`status`in o)||typeof o.status!=`string`||!(`error`in o)||typeof o.error!=`string`||!(`controls`in o)||!Array.isArray(o.controls))throw Error(Vn.bridgeUnavailable);let s=new URL(o.url);if(s.origin!==u)throw Error(Vn.routeChanged);let c=new URL(n);s.protocol=c.protocol,s.host=c.host;let d=await p(i);return!d&&a.current.controlsConnection===void 0?{...o,url:s.href}:{...d?Bn(d,d.loading,s.href):{status:`pending`,url:s.href,error:``,controls:[]},runtime:{status:o.status,error:o.error,controls:o.controls}}}function p(e){let t=a.current.controlsConnection;if(!t)return Promise.resolve(null);let n=t.getSnapshot,r=t.subscribe,i=n();return!i.loading||e<=Date.now()?Promise.resolve(i):new Promise(t=>{let i={};function a(e){window.clearTimeout(c),i.unsubscribe?.(),l.signal.removeEventListener(`abort`,s),t(e)}function o(){let e=n();e.loading||a(e)}function s(){a(null)}let c=window.setTimeout(()=>a(n()),e-Date.now());i.unsubscribe=r(o),l.signal.addEventListener(`abort`,s,{once:!0}),o()})}async function m(){if(!(s||c)){s=!0;try{let{command:r,prototypeUrl:i}=await $(`/api/agent/next`,t,{headers:{...e,"X-Replica-Prototype-Url":n}});if(!c&&i&&i!==n){window.location.reload();return}if(!r)return;let o;try{if(await $(`/api/agent/progress`,t,{method:`POST`,headers:e,body:JSON.stringify({id:r.id,stage:`handler started`})}),c)throw Error(Vn.actionInterrupted);let n;if(r.type===`inspect`){let{appearance:e,navigation:t,liveRoute:r,addressRef:i}=a.current,o=i.current?.value;if(o===void 0)throw Error(Vn.addressUnavailable);n={address:t.entries[t.index],addressDraft:o,appearance:e,canGoBack:t.index>0,canGoForward:t.indexvoid m(),300);return()=>{c=!0,l.abort(),window.clearInterval(h),i.current?.()}},[n,r,t,i])}function Un(e,t,n){let r=t?.repository===e?.stats.repository&&t?.branch===e?.stats.branch,i=!e?.stats.branch&&!!e?.stats.branchError,a=i?void 0:t?.branch,o=!!(e&&!i&&(t?.repository&&t.repository!==e.stats.repository||t?.branch&&t.branch!==e.stats.branch||t?.commitSha&&t.commitSha!==e.stats.commitSha)),s=!!(n.kind===`ready`&&r&&t?.state===`connected`&&t.prototype?.published&&t.prototype.build?.commitSha===e?.stats.commitSha);return{state:e&&{...e,publishStatus:!s&&[`requested`,`in_progress`].includes(e.publishStatus?.state??``)||t?.state===`connected`&&!r?e.publishStatus:s&&t?.prototype?.build?{state:`published`,detail:G.hubBuildImported,versionCount:t.prototype.versionCount,lastUpdatedAt:t.prototype.build.publishedAt,run:{url:t.prototype.build.url,actor:t.prototype.build.author.login||t.prototype.build.author.name?{login:t.prototype.build.author.login||void 0,name:t.prototype.build.author.name||void 0,avatarUrl:t.prototype.build.author.avatarUrl||void 0}:null}}:{state:t?.state===`connected`?`not_published`:`unavailable`,detail:t?.state===`connected`?G.hubBuildMissing:G.hubPublicationUnavailable},stats:{...e.stats,branch:a||e.stats.branch,branchError:a&&a!==e.stats.branch?null:e.stats.branchError,repository:t?.repository||e.stats.repository,commitSha:e.stats.commitSha,comparison:o?{branch:null,source:null,behind:null,error:G.comparisonNeedsRefresh}:e.stats.comparison,publishedUrl:s?t?.prototype?.build?.url:void 0}},hubPublished:s,comparisonOutdated:o}}function Wn(e,t){let n;function r(e,t,r,i=`none`){return{kind:e,detail:t,label:r,action:i,...n?{error:n}:{}}}if(!e)return r(`loading`,Y.initial,Y.checking);let{stats:i}=e,a=i.remoteBranch;if(!a||a.state===`loading`)return r(`loading`,Y.checkingRemote,Y.checking);if(!i.branch||a.state===`detached`)return r(`detached`,Y.detached,Y.retry,`retry`);if(a.repository!==i.repository||a.branch!==i.branch||a.commitSha!==i.commitSha)return r(`unknown`,Y.changed,Y.retry,`retry`);if(a.state===`unknown`)return r(`unknown`,Y.unknown(a.error),Y.retry,`retry`);let o=t?.state===`connected`?t.prototype:void 0,s=o?.build?.commitSha===i.commitSha&&o?.branch===i.branch,c=e.publishRequest,l=t?.state===`connected`&&t.repository===i.repository&&t.branch===i.branch&&(!t.commitSha||t.commitSha===i.commitSha)&&t.prototype?.branch===i.branch&&t.prototype.build?.commitSha===i.commitSha?t.prototype.build:null,u=!!(l&&(c?.commitSha!==i.commitSha||c.buildNumber===void 0||typeof c.buildNumber==`number`&&l.number>c.buildNumber)),d=u&&o?.registered&&o.published,f=t!==null&&t.repository===i.repository&&(!t.branch||t.branch===i.branch)&&(!t.commitSha||t.commitSha===i.commitSha);if(t&&f&&(t.state===`connected`||t.state===`undiscovered`)&&!o?.registered&&(!o||o.branch===i.branch)){let e=t.registrationReason||o?.registrationReason,r=i.branch===t.discovery?.defaultBranch;if(e||t.registrationError||o?.canRegister===!1||r){let i=e||(r?`branch_not_reviewable`:o?.canEdit===!1?`write_access_required`:o?.canRegister===!1&&a.state===`absent`?`remote_branch_missing`:void 0);n=i&&Y.registrationReasons.get(i)||{title:Y.registrationErrorTitle,description:t.registrationError||Y.registrationDenied}}}if(c?.state===`requested`&&(!c.commitSha||c.commitSha===i.commitSha)&&(a.state===`absent`||a.remoteSha!==i.commitSha)&&!u){let e=Date.now()-Date.parse(c.requestedAt||``);if(Number.isFinite(e)&&e<6e5)return r(`requested`,Y.pending,Y.awaitingCopilot)}if(!t)return r(`loading`,Y.checkingHub,Y.checking);if(t.state===`disconnected`||t.state===`pairing`||t.state===`unconfigured`)return r(`disconnected`,t.message||Y.disconnected,Y.connect);if(t.state===`denied`||t.state===`unavailable`)return{...r(`unknown`,t.message||Y.hubUnavailable,Y.retry,`retry`),error:{title:Y.hubUnavailableTitle,description:t.message||Y.hubUnavailable}};if(!f)return r(`unknown`,Y.staleHub,Y.retry,`retry`);if(!i.replicaWorkflowExists)return r(`workflow_missing`,Y.workflowMissing,Y.retry,`retry`);if(c?.state===`failed`&&!d&&(!c.commitSha||c.commitSha===i.commitSha))return r(`failed`,c.error||Y.dispatchFailed,Y.retryPublish,`publish`);if(a.state===`absent`)return r(`unpublished`,Y.absent,Y.publishBranch,`publish`);if(a.remoteSha!==i.commitSha)return r(`needs_push`,Y.needsPush,Y.publishChanges,`publish`);if(s){if(!o.registered)return r(`registration`,t.registrationError||(o.canEdit&&o.canRegister?Y.needsRegistration:Y.registrationDenied),t.registrationError?Y.registrationFailed:Y.registration);if(o.published&&u)return r(`ready`,Y.ready,Y.published)}if(o?.currentBuild?.commitSha===i.commitSha&&o.branch===i.branch&&o.currentBuild.state===`failed`)return r(`failed`,Y.importFailed,Y.retryPublish,`publish`);let p=i.workflow;if(!p||p.state===`unavailable`)return r(`unknown`,p?.detail||Y.workflowUnavailable,Y.retry,`retry`);let m=p.run;if(m&&(m.headSha!==i.commitSha||m.headBranch!==i.branch))return r(`unknown`,Y.staleWorkflow,Y.retry,`retry`);if(c?.commitSha===i.commitSha&&c.workflowRunId!=null&&m?.databaseId===c.workflowRunId&&!u)return r(`awaiting_build`,Y.noBuild,Y.awaitingBuild);let h;if(p.state===`in_progress`&&m){let e=[`queued`,`waiting`,`pending`,`requested`].includes(m.status||``);h=r(e?`queued`:`building`,e?Y.workflowQueued:Y.workflowBuilding,e?Y.queued:Y.building)}else h=p.state===`failed`&&m?r(`failed`,Y.workflowFailed(m.conclusion),Y.retryPublish,`publish`):p.state===`succeeded`&&m?r(`importing`,Y.importing,Y.awaitingHub):r(`awaiting_build`,Y.noBuild,Y.awaitingBuild);return m?.url?.startsWith(`https://github.com/`)&&(h.runUrl=m.url),h}function Gn({token:e,state:t,hubStatus:n,error:r,setError:i,refresh:a,refreshHub:o,preferenceSaving:s=!1}){let[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(null),m=(0,V.useRef)(!1),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(``),[y,b]=(0,V.useState)(!1),x=!t&&r?{kind:`unknown`,action:`retry`,label:Y.retry,detail:r}:Wn(t,n),S=`${t?.stats.repository}/${t?.stats.branch}/${t?.stats.commitSha}`,C=f?.identity===S&&x.action===`publish`?{...x,kind:`failed`,detail:f.message,label:Y.retryPublish}:x.kind===`ready`&&t?.stats.workingTree===`changed`?{...x,kind:`needs_push`,action:`publish`,label:Y.publishChanges,detail:Y.localChanges}:x,w=Un(t,n,x);(0,V.useEffect)(()=>{w.comparisonOutdated&&a(!0)},[w.comparisonOutdated,n?.branch,n?.commitSha,n?.repository,a]);async function T(){if(!y){b(!0);try{await Promise.all([a(!0),o()])}finally{b(!1)}}}async function E(){s||(C.action===`retry`?await T():C.action===`none`||m.current||h||await D())}async function D(){if(!(s||m.current)){m.current=!0,d(!0),i(``),v(``);try{let t=await $(`/api/publish/prepare`,e,{method:`POST`,body:`{}`});t.workingTree===`unavailable`||t.workingTree===`changed`&&!t.remember?g({preparation:t}):(g(null),await O(t,t.workingTree===`changed`?`commit-changes`:`committed-only`))}catch(e){let t=e instanceof Error?e.message:String(e);i(t),v(t)}finally{m.current=!1,d(!1)}}}async function O(r,s,c){if(s===`committed-only`&&n?.state===`connected`&&n.repository===r.target.repository&&n.branch===r.target.branch&&n.prototype?.registered&&n.prototype.published&&n.prototype.build?.commitSha===r.target.commitSha&&t?.stats.remoteBranch?.state===`present`&&t.stats.remoteBranch.remoteSha===r.target.commitSha)g(null);else{p(null),v(``),i(``);try{let t=await $(`/api/publish`,e,{method:`POST`,body:JSON.stringify({target:r.target,workingTree:r.workingTree,mode:s,remember:c})});g(null),l(t.message),await o(),await a(!1)}catch(e){let t=e instanceof Error?e.message:String(e);p({message:t,identity:S}),i(t),v(t)}}}async function k(e,t){if(!(s||!h||m.current)){if(h.preparation.workingTree===`unavailable`&&e!==`committed-only`)v(K.checkFailed);else{m.current=!0,d(!0);try{await O(h.preparation,e,t)}finally{m.current=!1,d(!1)}}}}return{publication:C,presentedState:w.state,busy:u||y||s,notice:c,publishDialog:h,publishDialogError:_,closePublishDialog:()=>g(null),choosePublish:k,retryPublishCheck:D,publish:E,retry:T}}var Kn=`replica:controls`;function qn(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&Ce(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||Ce({[r.id]:r.value}))}catch{return!1}}function Jn(e){return Array.isArray(e)&&e.length<=100&&e.every(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`scope`in e&&typeof e.scope==`string`&&e.scope.length>0&&e.scope.length<=64&&`error`in e&&typeof e.error==`string`&&e.error.length>0&&e.error.length<=500)}function Yn(e){if(!e||typeof e!=`object`)return!1;let t=e;if(typeof t.runtimeAvailable!=`boolean`||t.reconnectRequired!==void 0&&typeof t.reconnectRequired!=`boolean`||t.status===`ready`&&(!t.runtimeAvailable||!t.scopes?.length)||t.error!==void 0&&(typeof t.error!=`string`||t.error.length>1e3)||t.scopeErrors!==void 0&&!Jn(t.scopeErrors)||![`ready`,`no-controls`,`missing-runtime`,`unsupported-runtime`,`invalid-config`].includes(t.status)||!Array.isArray(t.scopes)||t.scopes.length>100||t.status!==`ready`&&t.scopes.length>0)return!1;try{let e=new Set;for(let n of t.scopes){if(We(n.declaration),e.has(n.declaration.scope)||(e.add(n.declaration.scope),n.fingerprint!==JSON.stringify(n.declaration)||!Number.isSafeInteger(n.snapshot.revision)||n.snapshot.revision<0))return!1;let t=n.snapshot;if(!t.values||!t.visible||!t.groups||!t.actions)return!1;function r(e,t){return typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))}if(!r(t.values,n.declaration.controls.filter(e=>e.type!==`button`).map(e=>e.id))||!r(t.visible,n.declaration.controls.map(e=>e.id))||!r(t.groups,(n.declaration.groups??[]).map(e=>e.id))||!r(t.actions,n.declaration.controls.filter(e=>e.type===`button`).map(e=>e.id))||Object.values(t.groups).some(e=>typeof e!=`boolean`))return!1;if(t.bindings!==void 0){if(!t.bindings||typeof t.bindings!=`object`||Array.isArray(t.bindings))return!1;for(let[e,r]of Object.entries(t.bindings))if(!n.declaration.controls.some(t=>t.id===e)||!r||typeof r.error!=`string`||r.error.length>500||typeof r.busy!=`boolean`||r.available!==void 0&&typeof r.available!=`boolean`)return!1}for(let e of n.declaration.controls){if(typeof t.visible[e.id]!=`boolean`)return!1;if(e.type===`button`){let n=t.actions[e.id];if(!n||typeof n.available!=`boolean`||typeof n.busy!=`boolean`)return!1}else if(Be(e,t.values[e.id]))return!1}}return!0}catch{return!1}}function Xn(){return{runtimeAvailable:!1,status:`missing-runtime`,scopes:[],scopeErrors:[],loading:!0,notice:``,error:``,storageError:``,resetting:!1}}var Zn=class{frame;origin;api;surface;epoch=``;sequence=-1;state=Xn();listeners=new Set;pending=new Map;saved;storageReady=!1;restored=new Set;preparing=new Set;persisted=new Map;cachedScopes=new Map;retryState;resetForIdentity=!1;fromFrameUrl=!1;requests=new AbortController;poll;deadline;saveQueue=Promise.resolve();editQueue=Promise.resolve();stopped=!0;constructor(e,t,n,r=`canvas`){this.frame=e,this.origin=t,this.api=n,this.surface=r}getSnapshot=()=>this.state;getControlValues=()=>{let e=structuredClone(this.saved?.scopes??{}),t=new Map(this.cachedScopes);for(let e of this.state.scopes)t.set(e.declaration.scope,e);for(let[n,r]of t)e[n]=Ze(r);return e};subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});publish(e){this.state={...this.state,...e},this.state.hasResettableValues=Object.values(this.getControlValues()).some(e=>Object.keys(e).length>0);for(let e of[...this.listeners])e()}hasBindingError(e,t){return this.state.scopes.some(n=>(!e||n.declaration.scope===e)&&Object.entries(n.snapshot.bindings??{}).some(([e,n])=>(!t||e===t)&&!!n.error))}checkSaved(e){let t=e,n=/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/;if(!t||typeof t!=`object`||typeof t.identity!=`string`||!t.identity||t.identity.length>128||!t.scopes||typeof t.scopes!=`object`||Array.isArray(t.scopes)||t.storageError!==void 0&&(typeof t.storageError!=`string`||t.storageError.length>1e3)||t.notice!==void 0&&(typeof t.notice!=`string`||t.notice.length>1e3)||new Blob([JSON.stringify(t)]).size>27e4)throw Error(`Invalid controls storage response.`);for(let[e,r]of Object.entries(t.scopes)){if(!n.test(e)||!r||typeof r!=`object`||Array.isArray(r))throw Error(`Invalid controls storage scope.`);for(let[e,t]of Object.entries(r))if(!n.test(e)||!(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))throw Error(`Invalid saved control value.`)}}start=e=>{this.fromFrameUrl=e?.type===`load`&&this.sequence>=0;let t=[...this.pending.values()].some(e=>e.action);this.stop(),this.requests=new AbortController,this.stopped=!1,this.epoch=crypto.randomUUID(),this.sequence=-1,this.saved=void 0,this.storageReady=!1,this.restored.clear(),this.preparing.clear(),this.persisted.clear(),this.editQueue=Promise.resolve(),this.cachedScopes.clear(),this.retryState=void 0,this.resetForIdentity=!1,this.state=Xn(),t&&(this.state.notice=`The preview reconnected during an action. Its outcome is unknown; it was not replayed.`),this.publish({});let n=this.epoch;window.addEventListener(`message`,this.receive),this.frame.addEventListener(`load`,this.start);let r=()=>{this.storageReady&&(this.surface===`canvas`&&this.frame.contentWindow?.postMessage({type:`replica:canvas:request-ready`,nonce:n},this.origin),this.send(`hello`).catch(()=>{}))};r(),this.poll=setInterval(()=>{this.state.status===`missing-runtime`&&r()},1e3),this.deadline=setTimeout(()=>{this.state.loading&&this.publish({loading:!1,error:this.surface===`build`?`Build Controls did not connect. Reload the preview or check its definitions.`:G.controlsLocalConnectionFailed})},6e3),this.api().then(e=>{if(!(this.epoch!==n||this.stopped)){if(this.checkSaved(e),this.saved=e,this.retryState?.identity===e.identity)for(let[e,t]of this.retryState.scopes)this.restored.add(`${e}:${t.fingerprint}`),this.cachedScopes.set(e,t);else this.retryState?.identity&&(this.resetForIdentity=!0,this.publish({notice:`The checkout identity changed. Controls will use this branch's saved values or defaults.`}));this.retryState=void 0,this.storageReady=!0,this.publish({storageError:e.storageError||``,notice:e.notice||this.state.notice}),this.prepare(this.state),r()}}).catch(e=>{this.epoch!==n||this.stopped||(this.storageReady=!0,this.publish({storageError:this.surface===`build`?e instanceof Error?e.message:`Control settings could not be read from the URL.`:G.controlsLocalStorageFailed}),this.prepare(this.state),r())})};retry=()=>{let e={identity:this.saved?.identity,scopes:new Map(this.cachedScopes)};this.start(),this.retryState=e};stop=()=>{this.stopped=!0,this.requests.abort(),clearInterval(this.poll),clearTimeout(this.deadline),window.removeEventListener(`message`,this.receive),this.frame.removeEventListener(`load`,this.start);for(let e of this.pending.values())clearTimeout(e.timer),e.reject(Error(`The preview navigated. The command outcome is unknown; it will not be replayed.`));this.pending.clear()};receive=e=>{if(this.stopped||e.source!==this.frame.contentWindow||e.origin!==this.origin||!qn(e.data))return;let t=e.data;if(t.epoch!==this.epoch||!Yn(t.state)||!Number.isSafeInteger(t.sequence)||(t.sequence??-1)<0||t.type!==`snapshot`&&t.type!==`reply`)return;let n=this.pending.get(t.requestId);if(t.type!==`reply`||n){if((t.sequence??-1)>this.sequence){if(t.type===`snapshot`&&t.controlQuery!==void 0&&this.saved){let e=De(t.controlQuery),n=this.saved.identity,r=this.epoch;this.stop();let i=new AbortController;this.requests=i,this.publish({loading:!0}),this.api({method:`POST`,signal:i.signal,body:JSON.stringify({identity:n,replace:!0,scopes:e.scopes})}).then(()=>{this.epoch!==r||i.signal.aborted||(this.start(),e.notice&&this.publish({notice:e.notice}))}).catch(e=>{this.epoch!==r||i.signal.aborted||this.publish({loading:!1,storageError:e instanceof Error?e.message:`Controls history could not be restored.`})});return}if(t.controlQuery!==void 0&&this.saved){let e=this.epoch,n=this.requests,r=De(t.controlQuery);this.saved.scopes=r.scopes,this.restored.clear(),this.persisted.clear(),this.cachedScopes.clear(),this.publish({notice:r.notice,loading:!0}),this.api({method:`POST`,signal:n.signal,body:JSON.stringify({identity:this.saved.identity,replace:!0,scopes:r.scopes})}).catch(t=>{this.epoch!==e||this.stopped||n.signal.aborted||this.publish({storageError:t instanceof Error?t.message:`Controls history could not be restored.`})})}this.sequence=t.sequence;let e=t.state.status;this.publish({...t.state,scopeErrors:t.state.scopeErrors??[],reconnectRequired:t.state.reconnectRequired===!0,status:e,error:t.state.error||(this.state.status===`missing-runtime`&&t.state.status!==`missing-runtime`?``:this.state.error),loading:!this.storageReady||this.state.resetting||this.preparing.size>0||this.state.loading&&e===`missing-runtime`}),this.prepare(this.state)}n&&(this.pending.delete(t.requestId),clearTimeout(n.timer),t.error?n.reject(Error(t.error)):n.resolve(this.state))}};send(e,t){let n=crypto.randomUUID(),r={protocol:Kn,version:1,epoch:this.epoch,requestId:n,type:e,...t?{command:t}:{},...e===`hello`?{controlQuery:Ee(this.saved?.scopes??{}),fromFrameUrl:this.fromFrameUrl}:{}};return qn(r)?new Promise((i,a)=>{let o=setTimeout(()=>{this.pending.delete(n),a(Error(`The command timed out. Its outcome is unknown; it will not be retried automatically.`))},e===`hello`?1200:3e4);this.pending.set(n,{resolve:i,reject:a,timer:o,action:t?.operation===`action`}),this.frame.contentWindow?.postMessage(r,this.origin)}):Promise.reject(Error(`The controls command is invalid or exceeds the size limit.`))}async prepare(e){if(!this.saved&&!this.state.storageError||this.state.resetting||e.reconnectRequired)return;let t=this.epoch;if(this.resetForIdentity&&(e.status===`ready`||e.status===`no-controls`)){this.resetForIdentity=!1,this.publish({loading:!0,resetting:!0});try{await this.send(`command`,{operation:`reset-all`,contexts:e.scopes.map(e=>({scope:e.declaration.scope,fingerprint:e.fingerprint,revision:e.snapshot.revision}))})}catch{this.epoch===t&&this.publish({error:`The checkout changed, but runtime defaults could not be restored. Reload the preview before saving.`,storageError:`Saving is paused until the new checkout's runtime reconnects.`,loading:!1});return}finally{this.epoch===t&&this.publish({resetting:!1})}return this.epoch!==t||this.stopped?void 0:this.prepare(this.state)}for(let n of e.scopes){let e=n.declaration.scope,r=`${e}:${n.fingerprint}`;if(!this.preparing.has(r)){if(!this.restored.has(r)){this.preparing.add(r),this.publish({loading:!0});try{let i=this.saved?.scopes&&Object.hasOwn(this.saved.scopes,e)?this.saved.scopes[e]:{},a=Object.fromEntries(n.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)])),o=!1;for(let[e,t]of Object.entries(i)){let r=n.declaration.controls.find(t=>t.id===e);!r||Be(r,t)?o=!0:a[e]=t}if(Object.keys(a).length&&await this.send(`command`,{operation:`restore`,scope:e,fingerprint:n.fingerprint,revision:this.state.scopes.find(e=>e.fingerprint===n.fingerprint)?.snapshot.revision,values:a}),this.stopped||this.epoch!==t)return;this.restored.add(r),o&&this.publish({notice:this.surface===`build`?`Some URL control settings no longer match this page. Defaults were used.`:`Some saved controls no longer match this declaration and were discarded.`})}catch(n){if(this.epoch!==t||this.stopped)return;this.hasBindingError(e)||this.publish({error:n instanceof Error?n.message:`Saved controls could not be restored.`}),this.restored.add(r)}finally{this.epoch===t&&this.preparing.delete(r)}}if(this.epoch===t&&!this.stopped){let t=this.state.scopes.find(t=>t.declaration.scope===e);t&&(this.cachedScopes.set(e,t),this.persist(t))}}}this.epoch===t&&!this.stopped&&this.state.status!==`missing-runtime`&&this.publish({loading:this.preparing.size>0})}persist(e){if(!this.saved||this.state.storageError)return;let t=Ze(e),n=JSON.stringify(t);if(this.persisted.get(e.declaration.scope)===n)return;this.persisted.set(e.declaration.scope,n);let r=this.saved.identity,i=this.epoch,a=this.requests.signal;this.saveQueue=this.saveQueue.catch(()=>{}).then(async()=>{if(!(this.epoch!==i||this.stopped))try{if(await this.api({method:`POST`,signal:a,body:JSON.stringify({identity:r,scope:e.declaration.scope,values:t})}),this.epoch===i&&!this.stopped){let t=await this.api();if(this.checkSaved(t),this.epoch!==i||this.stopped)return;this.saved=t,await this.send(`command`,{operation:`url`,scope:e.declaration.scope,query:Ee(t.scopes)})}}catch(e){this.epoch===i&&!this.stopped&&this.publish({storageError:this.surface===`build`&&e instanceof Error?`${e.message} Changes remain in memory and are not in the URL.`:`Controls could not be saved. Changes remain in memory; use Retry to reconnect storage.`})}})}async command(e,t,n,r){if(this.state.loading||this.state.resetting||this.stopped)return;let i=this.epoch,a=this.state.scopes.find(e=>e.declaration.scope===t);if(!a){this.publish({error:`This controls scope is no longer active.`});return}let o=()=>this.applyCommand(e,t,a.fingerprint,i,n,r);if(e!==`update`)return o();let s=this.editQueue.catch(()=>{}).then(o);return this.editQueue=s.then(()=>{}),s}async applyCommand(e,t,n,r,i,a){if(this.epoch!==r||this.stopped||this.state.resetting)return;let o=this.state.scopes.find(e=>e.declaration.scope===t);if(!o||o.fingerprint!==n)this.publish({error:`The controls scope or declaration changed. The command was not applied.`});else{this.publish({error:``});try{if(this.state.reconnectRequired)throw Error(`Reconnect controls before sending more commands.`);if(e===`update`||e===`action`){let t=o.declaration.controls.find(e=>e.id===i);if(!t||!o.snapshot.visible[t.id])throw Error(`This control is unknown or hidden.`);if(e===`update`){let e=Be(t,a);if(e)throw Error(`Control "${t.id}": ${e}`)}else if(t.type!==`button`||!o.snapshot.actions[t.id]?.available||o.snapshot.actions[t.id]?.busy)throw Error(`This action is unavailable or busy.`)}let n=await this.send(`command`,{operation:e,scope:t,fingerprint:o.fingerprint,revision:o.snapshot.revision,...i?{id:i}:{},...e===`update`?{value:a}:{}});if(e===`update`&&i)return{value:n.scopes.find(e=>e.declaration.scope===t)?.snapshot.values[i]}}catch(e){!this.stopped&&this.epoch===r&&!this.hasBindingError(t,i)&&this.publish({error:e instanceof Error?e.message:`Controls command failed.`})}}}async resetAll(){if(this.state.resetting||this.stopped)return;let e=this.epoch;this.publish({resetting:!0});try{let t=``;await this.editQueue.catch(()=>{});let n=this.state.runtimeAvailable&&(this.state.status===`ready`||this.state.status===`no-controls`);if(n)try{await this.send(`command`,{operation:`reset-all`,contexts:this.state.scopes.map(e=>({scope:e.declaration.scope,fingerprint:e.fingerprint,revision:e.snapshot.revision}))})}catch(e){t=e instanceof Error?e.message:`Some app defaults could not be restored.`}if(this.epoch!==e||this.stopped)return;if(!this.saved){let e=await this.api();this.checkSaved(e),this.saved=e}await this.saveQueue.catch(()=>{}),await this.api({method:`POST`,signal:this.requests.signal,body:JSON.stringify({identity:this.saved.identity,reset:!0})}),this.saved.scopes={},await this.send(`command`,{operation:`url`,query:``}),this.cachedScopes.clear(),this.persisted.clear(),this.publish({storageError:``,error:this.hasBindingError()?``:t,notice:n?``:`Saved controls were cleared. Runtime defaults could not be restored until the preview reconnects.`})}catch(t){this.epoch===e&&this.publish({storageError:t instanceof Error?t.message:`Reset could not be saved.`})}finally{this.epoch===e&&this.publish({resetting:!1,loading:!1})}}};function Qn(e,t=()=>window.location.href,n=e=>{window.history.replaceState(window.history.state,``,e),window.dispatchEvent(new Event(we))}){return r=>Promise.resolve().then(()=>{r?.signal?.throwIfAborted();let i=De(new URL(t()).search);if(!r)return{identity:e,...i};if(r.method!==`POST`||typeof r.body!=`string`)throw Error(`Invalid URL controls request.`);let a=JSON.parse(r.body);if(!a||typeof a!=`object`||!(`identity`in a)||a.identity!==e)throw Error(`The controls URL identity changed.`);let o=i.scopes;if(`reset`in a&&a.reset===!0)o={};else if(`replace`in a&&a.replace===!0&&`scopes`in a){if(!a.scopes||typeof a.scopes!=`object`||Array.isArray(a.scopes))throw Error(`Invalid controls history settings.`);let e={};for(let[t,n]of Object.entries(a.scopes)){if(!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(t)||!Ce(n))throw Error(`Invalid controls history settings.`);e[t]=n}o=De(Ee(e)).scopes}else{if(!(`scope`in a)||typeof a.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(a.scope)||!(`values`in a)||!Ce(a.values))throw Error(`Invalid URL control settings.`);o={...o,[a.scope]:a.values}}let s=Oe(t(),Ee(o));s!==t()&&n(s)})}function $n({frameRef:e,prototypeUrl:t,previewUrl:n,address:r,replaceAddress:i}){let[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),l=(0,V.useRef)({address:r,replaceAddress:i});return(0,V.useLayoutEffect)(()=>{l.current={address:r,replaceAddress:i}},[r,i]),(0,V.useEffect)(()=>{if(!e.current)return;let r=new Zn(e.current,new URL(n??t).origin,Qn(`prototype:${new URL(t).origin}`,()=>l.current.address,e=>{l.current.address=e,l.current.replaceAddress(e)}));o(r);let i=r.subscribe(()=>c(r.getSnapshot()));return r.start(),()=>{i(),r.stop()}},[t,n,e]),{connection:a,state:s}}function er({token:e,status:t,onStatusChange:n,onSelectHub:r}){let[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(null),m=(0,V.useRef)(!1),h=(0,V.useRef)(!1),g=t?.state===`connected`||t?.state===`undiscovered`,_=t?.state===`disconnected`||t?.state===`pairing`||t?.state===`unconfigured`,v=g?null:t?.pairing||(f?.repository===t?.repository&&f?.hubOrigin===t?.hubOrigin?f?.pairing:null),y=v?.verificationUrl;(0,V.useEffect)(()=>{let e=window.setTimeout(()=>{g?(a(!1),p(null),l(``)):_&&t?.repository&&!m.current&&(m.current=!0,a(!0))},0);return()=>window.clearTimeout(e)},[g,_,t?.repository]),(0,V.useEffect)(()=>{if(!y||u)return;let t=!1,r=!1;async function i(){if(!r){r=!0;try{let r=await $(`/api/hub/poll`,e,{method:`POST`,body:`{}`});if(t)return;r.status!==`pending`&&(p(null),r.status!==`approved`&&l(G.connectionApprovalExpired),await n())}catch(e){t||(l(e instanceof Error?e.message:String(e)),d(!0))}finally{r=!1}}}let a=window.setInterval(()=>void i(),3e3);return()=>{t=!0,window.clearInterval(a)}},[y,u,e,n,t?.repository,t?.hubOrigin]);async function b(i){if(m.current=!0,!h.current){if(!t?.repository)l(G.connectionRepositoryRequired);else if(!t.hubOrigin&&!i)l(G.connectionHubRequired);else{h.current=!0,s(!0),l(``),d(!1);try{!t.hubOrigin&&i&&await r(i);let a=await $(`/api/hub/connect`,e,{method:`POST`,body:`{}`});p({repository:t.repository,hubOrigin:new URL(a.verificationUrl).origin,pairing:a}),a.browserError&&l(G.connectionBrowserFailed(a.browserError)),await n()}catch(e){l(e instanceof Error?e.message:String(e))}finally{h.current=!1,s(!1)}}}}function x(){a(!0),t?.hubOrigin&&b()}return{open:i,close:()=>a(!1),show:()=>a(!0),showAndConnect:x,connect:b,connecting:o,error:c,pairing:v}}function tr({token:e,onStatus:t,onError:n}){let[r,i]=(0,V.useState)(null),a=(0,V.useRef)(0),o=(0,V.useRef)(0),s=(0,V.useRef)(!1),c=(0,V.useCallback)(async(r,c=!1)=>{if(s.current||c&&o.current>0)return;o.current+=1;let l=++a.current;try{let o=r===`open`||r===`interaction`,c=await $(o?r===`open`?`/api/hub/open`:`/api/hub/activity`:`/api/hub/status`,e,o?{method:`POST`,body:`{}`}:{});if(l!==a.current||s.current)return;i(c);let u=c.prototype?.startPageImportError||c.localStartPageError;u&&n(u),t(c)}catch(e){if(l!==a.current||s.current)return;let t=e instanceof Error?e.message:String(e);i(e=>({state:`unavailable`,repository:e?.repository,branch:e?.branch,hubOrigin:e?.hubOrigin,message:G.hubStatusUnavailable(t)})),n(t)}finally{--o.current}},[e,t,n]),l=(0,V.useCallback)(async t=>{s.current=!0,a.current+=1,i(null);try{await $(`/api/hub/origin`,e,{method:`POST`,body:JSON.stringify({origin:t})})}finally{s.current=!1,await c()}},[e,c]);(0,V.useEffect)(()=>{let e=window.setTimeout(()=>void c(`open`),0),t=window.setInterval(()=>void c(void 0,!0),15e3);function n(){c(`interaction`)}return window.addEventListener(`focus`,n),()=>{a.current+=1,window.clearTimeout(e),window.clearInterval(t),window.removeEventListener(`focus`,n)}},[c]);async function u(){let t=await $(`/api/hub/discovery`,e,{method:`POST`,body:`{}`});if(t.discovery?.state!==`valid`||!t.discovery.origin)throw Error(t.discovery?.message||G.resetHubUnavailable);return await c(),t.discovery.origin}return{status:r,refresh:c,select:l,reset:u}}function nr({prototypeUrl:e,previewUrl:t,shellRef:n,cancelClick:r}){let[{key:i,ref:a},o]=(0,V.useState)(()=>({key:0,ref:(0,V.createRef)()})),[s,c]=(0,V.useState)({input:e,url:e}),[l,u]=(0,V.useState)({input:e,entries:[e],index:0}),[d,f]=(0,V.useState)(()=>window.matchMedia?.(`(prefers-color-scheme: dark)`)?.matches?`dark`:`light`),[p,m]=(0,V.useState)(null),h=(0,V.useRef)(null),g=l.input===e?l:{input:e,entries:[e],index:0},_=g.entries[g.index],v=(0,V.useCallback)(()=>r.current?.(),[r]),y=(0,V.useCallback)(t=>{if(new URL(t).origin!==new URL(e).origin)throw Error(G.startPageOrigin);u(e=>{let n=[...e.entries];return n[e.index]=t,{...e,entries:n}})},[e]),b=(0,V.useCallback)(t=>{if(h.current===e)return;h.current=e;let n=new URL(e),r=t.state===`connected`&&(t.prototype?.startPageSet??t.prototype?.startPage!==void 0)?t.prototype?.startPage:t.localStartPage;if(n.pathname!==`/`||n.search||n.hash||!r)return;let i=new URL(r,n);if(i.origin!==n.origin)throw Error(G.startPageOrigin);c({input:e,url:i.href}),u({input:e,entries:[i.href],index:0})},[e]);function x(){v(),m(null),c({input:e,url:_}),o(e=>({key:e.key+1,ref:(0,V.createRef)()}))}function S(t){t===_?x():(u(n=>{let r=n.input===e?n:g;return{...r,entries:[...r.entries.slice(0,r.index+1),t],index:r.index+1}}),c({input:e,url:t}))}function C(t){let n=g.entries[t];n&&(u({...g,index:t}),c({input:e,url:n}))}let w=(0,V.useCallback)((t,n=!1)=>{m(t);let r=new URL(e);r.pathname=t.pathname,r.search=t.search,r.hash=t.hash,u(t=>{let i=t.input===e?t:{input:e,entries:[e],index:0},a=new URL(i.entries[i.index]),o=[...a.searchParams].filter(([e])=>e.startsWith(`rc.`));for(let e of[r,a])for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);if(a.pathname===r.pathname&&a.searchParams.toString()===r.searchParams.toString()&&a.hash===r.hash)return i;for(let[e,t]of o)r.searchParams.append(e,t);let s=r.href;if(n){let e=[...i.entries];return e[i.index]=s,{...i,entries:e}}return{...i,entries:[...i.entries.slice(0,i.index+1),s],index:i.index+1}})},[e]);(0,V.useEffect)(()=>{let e=a.current;if(!e)return;function t(){v(),m(null)}return e.addEventListener(`load`,t),()=>{v(),e.removeEventListener(`load`,t)}},[v,a]),(0,V.useEffect)(()=>{let r=a.current;if(!r)return;let i=new URL(t??e).origin,o=crypto.randomUUID();function s(){let e=n.current?.closest(`.canvas-base`);e&&r?.contentWindow?.postMessage({type:`replica:canvas:theme`,nonce:o,accent:window.getComputedStyle(e).getPropertyValue(`--hub-accent`).trim()},i)}function c(e){e.source===r?.contentWindow&&e.origin===i&&e.data?.type===`replica:canvas:ready`&&s()}return r.addEventListener(`load`,s),window.addEventListener(`message`,c),s(),()=>{r.removeEventListener(`load`,s),window.removeEventListener(`message`,c)}},[d,e,t,a,n]);let T=new URL(s.input===e?s.url:e);if(t){let e=new URL(t);T.protocol=e.protocol,T.host=e.host}return{frameRef:a,frameKey:i,source:T.href,navigation:g,address:_,replaceAddress:y,appearance:d,setAppearance:f,liveRoute:p,initialize:b,reportRoute:w,reload:x,navigate:S,travel:C}}function rr(e){let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(``),a=(0,V.useRef)(null),o=(0,V.useRef)(0),s=(0,V.useRef)(0),c=(0,V.useCallback)(async(t,r=!1)=>{if(r&&s.current>0)return;s.current+=1;let c=++o.current;try{let r=await $(t?`/api/refresh`:`/api/state`,e,t?{method:`POST`,body:`{}`}:{});if(c!==o.current)return;a.current=r,n(r),i(``)}catch(e){if(c!==o.current)return;n(t=>t&&{...t,stats:{...t.stats,remoteBranch:{state:`unknown`,repository:t.stats.repository||null,branch:t.stats.branch||null,commitSha:t.stats.commitSha||null,error:ir(e)}}}),i(ir(e))}finally{--s.current}},[e]);return(0,V.useEffect)(()=>{let e=window.setTimeout(()=>void c(!0),0),t=window.setInterval(()=>{let e=a.current?.publishStatus?.state,t=a.current?.publishRequest,n=e===`requested`||e===`in_progress`||t?.state===`requested`||!!t?.requestedAt&&(e===`not_published`||e===`unavailable`);c(n,!0)},15e3);function n(){c(!0)}return window.addEventListener(`focus`,n),()=>{o.current+=1,window.clearTimeout(e),window.clearInterval(t),window.removeEventListener(`focus`,n)}},[c]),{state:t,error:r,setError:i,refresh:c}}function ir(e){return e instanceof Error?e.message:String(e)}function ar({token:e,enabled:t,repository:n,branch:r,commitSha:i,publicationRevision:a}){let o=`${n}/${r}/${i}/${a}`,[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(!1),p=(0,V.useRef)(null),m=(0,V.useRef)(0),h=t&&s?.identity===o?s:null,g=(0,V.useCallback)(async()=>{if(!t)return;let i=++m.current;u(!0);try{if(await p.current,i!==m.current)return;let t=await $(`/api/publish/prepare`,e,{method:`POST`,body:`{}`});if(i!==m.current)return;if(t.target.repository!==n||t.target.branch!==r)throw Error(K.preferenceTargetChanged);if(typeof t.remember!=`boolean`)throw Error(K.invalidPreference);c({identity:o,preparation:t,error:``})}catch(e){i===m.current&&c({identity:o,preparation:null,error:e instanceof Error?e.message:String(e)})}finally{i===m.current&&u(!1)}},[t,e,n,r,o]);(0,V.useEffect)(()=>{let e=window.setTimeout(()=>void g(),0);return()=>{m.current+=1,window.clearTimeout(e)}},[g]);async function _(n){if(!t||!h?.preparation||l||p.current)return;f(!0);let r=m.current,i=h.preparation,a=(async()=>{try{if((await $(`/api/publish/preference`,e,{method:`POST`,body:JSON.stringify({target:i.target,remember:n})})).remember!==n)throw Error(K.invalidPreference);r===m.current&&c({identity:o,preparation:{...i,remember:n},error:``})}catch(e){r===m.current&&c({identity:o,preparation:i,error:e instanceof Error?e.message:String(e)})}})();p.current=a;try{await a}finally{p.current=null,f(!1)}}return{remember:h?.preparation?.remember??null,loading:l||!h,saving:d,error:h?.error||``,save:_,retry:g}}function or(e,t,n){let r=n?.included,i=n?.error,a=n?.revision,o=(0,V.useMemo)(()=>{if(r!==void 0)return{identity:e,revision:a,included:r,error:i??``,pending:!1};let t=!1,n=``;if(e)try{let n=localStorage.getItem(`replica:share-controls:v1:${e}`);if(n!==null&&n!==`true`&&n!==`false`)throw Error(`Invalid saved share preference.`);t=n===`true`}catch{n=`The share preference could not be read. Control settings are off by default.`}return{identity:e,revision:a,included:t,error:n,pending:!1}},[e,a,r,i]),[s,c]=(0,V.useState)(o),l=s.identity===e&&s.revision===a?s:o,u=``,d=``;if(l.included)try{u=Ee(t)}catch(e){d=e instanceof Error?e.message:`Control settings could not be shared.`}return{included:l.included,query:u,error:d||l.error,blocked:!!d,...n?{pending:l.pending}:{},onChange:t=>{if(n){c({identity:e,revision:a,included:t,error:``,pending:!0});function r(n){c(r=>r.identity===e&&r.revision===a&&r.included===t?{...r,error:n,pending:!1}:r)}n.onChange(t).then(()=>r(``),e=>r(e instanceof Error?e.message:`This preference could not be saved. It will only apply while this page is open.`));return}let r=``;if(e)try{localStorage.setItem(`replica:share-controls:v1:${e}`,String(t))}catch{r=`This preference could not be saved. It will only apply while this page is open.`}c({identity:e,revision:a,included:t,error:r,pending:!1})}}}function sr({token:e,state:t,hubStatus:n}){let[r,i]=(0,V.useState)(null),a=!!(r&&(r.stale||r.repository!==void 0&&r.repository!==t?.stats.repository||r.branch!==void 0&&r.branch!==t?.stats.branch||n?.hubOrigin!==void 0&&r.hubOrigin!==void 0&&r.hubOrigin!==n.hubOrigin||r.token!==e));(0,V.useEffect)(()=>{if(!r||r.stale)return;let e=r.repository??t?.stats.repository,o=r.branch??t?.stats.branch,s=r.hubOrigin??n?.hubOrigin;if(!a&&e===r.repository&&o===r.branch&&s===r.hubOrigin)return;let c=window.setTimeout(()=>{i(t=>t&&{...t,repository:e,branch:o,hubOrigin:s,stale:a,connecting:!a&&t.connecting})},0);return()=>window.clearTimeout(c)},[r,a,t?.stats.repository,t?.stats.branch,n?.hubOrigin]);function o(){i({repository:t?.stats.repository,branch:t?.stats.branch,hubOrigin:n?.hubOrigin,token:e,connecting:!1,stale:!1})}function s(e){i(t=>t&&{...t,connecting:e})}return{intent:r,targetChanged:a,begin:o,close:()=>i(null),setConnecting:s}}var cr={open:!1,context:null,links:[],loading:!1,busy:!1,stale:!0,error:``,notice:``,created:null};function lr({token:e,hubStatus:t,prototypeState:n}){let[r,i]=(0,V.useState)(cr),a=(0,V.useRef)(r);a.current=r;let o=(0,V.useRef)(0),s=(0,V.useRef)(!1),c=(0,V.useRef)(!1),l=(0,V.useRef)(!1),u=(0,V.useRef)(!1),d=(0,V.useRef)(null),f=`${t?.hubOrigin}/${t?.repository}/${t?.branch}/${t?.state}`,p=(0,V.useRef)(f);p.current=f;let m=(0,V.useCallback)(()=>{!u.current||s.current||c.current||l.current||!d.current||(u.current=!1,d.current())},[]);(0,V.useLayoutEffect)(()=>{o.current+=1,i(e=>e.open?{...cr,open:!0,error:q.stale}:cr)},[f,e]),(0,V.useEffect)(()=>()=>{o.current+=1,u.current=!1},[]),(0,V.useEffect)(()=>{let e=t?.prototype;e&&e.canManageShareLinks!==!0&&a.current.context?.prototype.canManageShareLinks===!0&&(o.current+=1,i(t=>t.open&&t.context?.prototype.id===e.id?{...cr,open:!0,stale:!1,context:{...t.context,prototype:{...t.context.prototype,canManageShareLinks:e.canManageShareLinks}}}:t))},[t?.prototype]),(0,V.useEffect)(()=>{t?.prototype?.publicSharingEnabled===!1&&(o.current+=1,i(e=>e.open?{...cr,open:!0,sharingDisabled:!0,error:q.disabled,context:e.context?{...e.context,prototype:{...e.context.prototype,publicSharingEnabled:!1}}:null}:cr))},[t?.prototype?.publicSharingEnabled]);let h=(0,V.useCallback)((t,n)=>$(`/api/hub/share-links/${t}`,e,{method:`POST`,body:JSON.stringify(n)}),[e]),g=(0,V.useCallback)(e=>{e instanceof Error&&`code`in e&&(e.code===`public_sharing_disabled`||e.code===`public_sharing_changed`||e.code===`creator_access_changed`)&&(o.current+=1,i(t=>({...t,busy:!1,loading:!1,stale:!0,sharingDisabled:e.code===`public_sharing_disabled`,links:[],created:null,authorization:void 0})))},[]),_=(0,V.useCallback)(async(e=a.current.context)=>{if(!e||!e.prototype.canManageShareLinks||e.prototype.publicSharingEnabled===!1||c.current)return;c.current=!0;let t=o.current,n=p.current;i(e=>({...e,loading:!0,stale:!0,error:``}));try{let r=new Map,a=new Set,s=null;do{let i=await h(`list`,{target:e.target,...s?{cursor:s}:{}});if(t!==o.current||n!==p.current)return;for(let e of i.shareLinks)r.set(e.id,e);if(s=i.nextCursor,s){if(a.has(s))throw Error(q.paginationFailed);a.add(s)}}while(s);i(e=>({...e,links:[...r.values()],created:e.created?r.get(e.created.id)??null:null,loading:u.current,stale:u.current,sharingDisabled:!1}))}catch(e){t===o.current&&n===p.current&&(i(t=>({...t,loading:!1,stale:!0,error:e instanceof Error?e.message:q.failed})),g(e))}finally{c.current=!1,m()}},[h,m,g]),v=(0,V.useCallback)(async()=>{if(s.current||l.current||c.current){u.current=!0,i(e=>({...e,open:!0,stale:!0,loading:!0}));return}l.current=!0;let e=++o.current,r=p.current;i({...cr,open:!0,loading:!0});let a=t?.repository===n?.stats.repository&&t?.branch===n?.stats.branch,d=``;if(!t||[`disconnected`,`pairing`,`unconfigured`].includes(t.state)?d=q.disconnected:[`unavailable`,`denied`].includes(t.state)?d=q.unavailable:(t.state!==`connected`||!a)&&(d=q.branch),d)i({...cr,open:!0,error:d}),l.current=!1;else try{let t=await h(`context`,{});if(e!==o.current||r!==p.current)return;i(e=>({...e,context:t,loading:!1,stale:t.prototype.canManageShareLinks===!0})),await _(t)}catch(t){e===o.current&&r===p.current&&i(e=>({...e,loading:!1,error:t instanceof Error?t.message:q.failed}))}finally{l.current=!1,m()}},[t,n,_,h,m]);d.current=v;let y=(0,V.useCallback)(async(e,t)=>{let n=a.current;if(s.current||l.current||c.current||u.current||n.stale||!n.context||n.context.prototype.canManageShareLinks!==!0||n.sharingDisabled||n.context.prototype.publicSharingEnabled===!1)return!1;s.current=!0;let r=o.current;i(e=>({...e,busy:!0,error:``,notice:``}));try{let a=await h(e,{target:n.context.target,...t});return r===o.current&&(i(n=>({...n,notice:e===`delete`?q.deleted:``,authorization:void 0,created:`id`in a?a:e===`delete`&&`id`in t&&n.created?.id===t.id?null:n.created,links:e===`delete`&&`id`in t?n.links.filter(e=>e.id!==t.id):n.links})),await _(n.context),!0)}catch(e){if(r!==o.current)return!1;let t=e instanceof Error&&`code`in e&&e.code===`fresh_authorization_required`&&`authorization`in e&&e.authorization&&typeof e.authorization==`object`&&`url`in e.authorization&&typeof e.authorization.url==`string`&&`expiresAt`in e.authorization&&typeof e.authorization.expiresAt==`string`?{url:e.authorization.url,expiresAt:e.authorization.expiresAt}:void 0,n=e instanceof Error&&(!(`statusCode`in e)||`code`in e&&e.code===`share_delivery_unknown`);return i(r=>({...r,stale:!0,authorization:t,error:n?q.unknown:e instanceof Error?e.message:q.failed})),g(e),!1}finally{s.current=!1,r===o.current&&i(e=>({...e,busy:!1})),m()}},[_,h,m,g]),b=(0,V.useCallback)(async e=>{let t=a.current;if(!t.context||l.current||c.current||u.current)throw Error(q.stale);let n=o.current,r=await h(`controls-preference`,{target:t.context.target,included:e});if(n!==o.current)throw Error(q.stale);if(r.included!==e)throw Error(`The share preference could not be saved.`)},[h]),x=(0,V.useCallback)(async(e,t)=>{let n=a.current;if(!n.context||n.stale||l.current||c.current||u.current)return;let r=o.current;try{await h(`open`,{target:n.context.target,id:e,...t?{controlsQuery:t}:{}})}catch(e){r===o.current&&(i(t=>({...t,error:e instanceof Error?e.message:q.failed})),g(e))}},[h,g]),S=(0,V.useCallback)(async()=>{let e=a.current;if(!e.context||!e.authorization||e.busy)return;let t=o.current;try{await h(`authorize`,{target:e.context.target}),t===o.current&&i(e=>({...e,notice:q.authorizationRetry}))}catch(e){t===o.current&&(i(t=>({...t,error:e instanceof Error?e.message:q.failed})),g(e))}},[h,g]);return(0,V.useEffect)(()=>{if(!r.open||!r.context)return;function e(){s.current||_()}let t=window.setInterval(e,3e4);return window.addEventListener(`focus`,e),()=>{window.clearInterval(t),window.removeEventListener(`focus`,e)}},[r.open,r.context,_]),{state:r,open:v,close:()=>{u.current=!1,i(e=>({...e,open:!1}))},refresh:()=>r.context&&!r.sharingDisabled&&r.context.prototype.publicSharingEnabled!==!1?_():v(),create:(e,t)=>y(`create`,{label:e,expiration:t,buildNumber:r.context?.prototype.build?.number}),remove:e=>y(`delete`,{id:e}),openLink:x,setControlPreference:b,authorize:S}}function ur({config:e}){let t=(0,V.useRef)(null),n=(0,V.useRef)(null),r=(0,V.useRef)(null),i=(0,V.useRef)(null),a=(0,V.useRef)(null),o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useRef)(null),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)({position:null,collapsed:!1,collapsedGroups:{}}),[h,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(!1),y=(0,V.useCallback)(()=>{g(!1),o.current?.focus()},[]),{frameRef:b,frameKey:x,source:S,navigation:C,address:w,replaceAddress:T,appearance:E,setAppearance:D,liveRoute:O,initialize:k,reportRoute:A,reload:j,navigate:M,travel:ee}=nr({prototypeUrl:e.prototypeUrl,previewUrl:e.previewUrl,shellRef:t,cancelClick:u}),N=$n({...e,frameRef:b,address:w,replaceAddress:T}),P=N.state;Hn({...e,frameRef:b,addressRef:r,appearance:E,navigation:C,liveRoute:O,cancelClick:u,reload:j,controlsConnection:N.connection});let{state:F,error:I,setError:L,refresh:R}=rr(e.token),z=tr({token:e.token,onStatus:k,onError:L}),te=er({token:e.token,status:z.status,onStatusChange:z.refresh,onSelectHub:z.select}),B=lr({token:e.token,hubStatus:z.status,prototypeState:F}),ne=sr({token:e.token,state:F,hubStatus:z.status}),re=ar({token:e.token,enabled:h&&z.status?.state===`connected`&&z.status.prototype?.registered===!0&&!!z.status.prototype.build&&z.status.repository===F?.stats.repository&&z.status.branch===F?.stats.branch,repository:F?.stats.repository,branch:F?.stats.branch,commitSha:F?.stats.commitSha,publicationRevision:F?.publishRequest?.requestedAt}),ie=Gn({token:e.token,state:F,hubStatus:z.status,error:I,setError:L,refresh:R,refreshHub:z.refresh,preferenceSaving:re.saving}),ae=In(F,z.status,ie.publication),oe=B.state.context,se=or(oe?`${oe.hubOrigin}:${oe.prototype.repositoryId}:${oe.prototype.id}`:void 0,N.connection?.getControlValues()??{},{included:oe?.controlSettingsIncluded??!1,error:oe?.controlSettingsError,revision:oe?.target,onChange:B.setControlPreference});(0,V.useLayoutEffect)(()=>{document.body.classList.remove(`renderer-loading`);let e=t.current,r=n.current;if(!e||!r)return;function i(){let t=r?.getBoundingClientRect().height;t&&e?.style.setProperty(`--canvas-toolbar-height`,`${t}px`)}let a=new ResizeObserver(i);return a.observe(r),i(),()=>a.disconnect()},[]);function ce(){te.close(),ae.kind===`ready`?B.open():ne.begin()}return(0,U.jsxs)(H.ThemeProvider,{colorMode:E,className:`canvas-base`,children:[(0,U.jsxs)(`main`,{ref:t,className:`canvas-shell${B.state.open?` canvas-shell--inactive`:``}`,inert:B.state.open,"aria-hidden":B.state.open?!0:void 0,children:[(0,U.jsx)(Ne,{address:w,addressRef:r,canGoBack:C.index>0,canGoForward:C.indexee(C.index-1),onForward:()=>ee(C.index+1),onNavigate:M,onOpenTab:async()=>{await $(`/api/prototype/open`,e.token,{method:`POST`,body:JSON.stringify({url:w})})},onReload:j}),(0,U.jsx)(Rn,{toolbarRef:n,config:e,state:ie.presentedState,prototypeName:z.status?.state===`connected`&&z.status.prototype?.name||void 0,publishing:ie.busy,publication:ie.publication,publishButtonRef:i,hubButtonRef:o,titleButtonRef:c,onBuildDetails:()=>v(!0),controlsButtonRef:l,controlsOpen:d,onControls:()=>f(!d),onPublish:()=>void ie.publish(),onShare:ce,shareButtonRef:a,hubOpen:h,onHub:()=>{g(!h),z.refresh(`interaction`)}}),(0,U.jsx)(`iframe`,{ref:b,className:`prototype-frame`,title:G.prototypeFrameTitle(e.name),src:S,style:{colorScheme:E,backgroundColor:`var(--hub-canvas-default)`}},x),(0,U.jsx)(Fn,{config:e,frameRef:b,onRouteChange:A,status:z.status,onStatusChange:z.refresh,onSelectHub:z.select,onConnect:te.showAndConnect,onDisconnected:te.show,connectionButtonRef:s,connecting:te.connecting,publication:ie.publication,publicationBusy:ie.busy,dirty:F?.stats.workingTree===`changed`,onPublish:()=>void ie.publish(),onRetryPublication:()=>void ie.retry(),publishPreference:re,open:h,onClose:y}),d&&N.connection&&P?(0,U.jsx)(et,{state:P,connection:N.connection,layout:p,onLayoutChange:m,diagnosisTarget:w,onDiagnose:()=>$(`/api/controls/diagnose`,e.token,{method:`POST`,body:JSON.stringify({status:P.status,runtimeAvailable:P.runtimeAvailable,reconnectRequired:P.reconnectRequired===!0,hasError:!!P.error||Bn(P,P.loading,w).controls.some(e=>e.visible&&!!e.error),hasStorageError:!!P.storageError,previewUrl:w})})}):null]}),(0,U.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`visually-hidden`,children:I||ie.notice}),(0,U.jsx)(Me,{hub:z,connection:te,publication:ie,sharing:B,shareIntent:ne,controlSettings:se,readiness:ae,state:F,hubOpen:h,buildDetailsOpen:_,onCloseBuildDetails:()=>v(!1),shareButtonRef:a,hubButtonRef:o,connectionButtonRef:s,publishButtonRef:i,titleButtonRef:c})]})}var dr=document.querySelector(`#root`);if(!dr)throw Error(`Replica prototype renderer root is missing.`);(0,se.createRoot)(dr).render((0,U.jsx)(ur,{config:window.__REPLICA_CANVAS__})); \ No newline at end of file +`)&&Jt(),e.startsWith(`event: error +`))throw Error(`Live review connection failed.`)}}catch{t.signal.aborted||ze(!0)}t.signal.aborted||(Date.now()-a>=3e4&&(r=5e3),n=window.setTimeout(()=>void i(),r),r=Math.min(r*2,6e4))}return i(),()=>{t.abort(),window.clearTimeout(n)}},[ot,Nt,e.token,Jt]);let Xt=(0,V.useCallback)((n,r={})=>{let i=t.current;return!i?.contentWindow||!qe.current?!1:(i.contentWindow.postMessage({type:n,nonce:qe.current,...r},new URL(e.previewUrl??e.prototypeUrl).origin),!0)},[e.prototypeUrl,e.previewUrl,t]),Zt=(0,V.useCallback)(async t=>{if(!De||!zt||Vt)return;let n=ot,i=++Ye.current;Je.current=void 0,Pe(!0),z(``),P(null),Le(null),Me(t),v();try{let a=await $(`/api/hub/status`,e.token);if($e.current!==n||Ye.current!==i)return;if(!a.repositoryAuthorized&&a.state!==`connected`||a.prototype?.id!==Nt||a.hubOrigin!==r?.hubOrigin||a.repository!==r?.repository||a.branch!==r?.branch||!a.reviewRevision)throw Error(a.reviewError||K.commentPreparationFailed);Je.current=a.reviewRevision,Xt(`replica:canvas:select`,{mode:t})}catch(e){$e.current===n&&Ye.current===i&&(Me(null),z(e instanceof Error?e.message:String(e)))}finally{Ye.current===i&&Pe(!1)}},[De,zt,e.token,ot,v,Nt,Vt,Xt,r]),Qt=(0,V.useCallback)(()=>{je&&(Ye.current+=1,Je.current=void 0,Pe(!1),Xt(`replica:canvas:cancel-selection`),Me(null))},[je,Xt]),$t=(0,V.useCallback)(()=>{Ye.current+=1,Je.current=void 0,Xt(`replica:canvas:clear-selection`),Fe(null),Le(null),z(``)},[Xt]);(0,V.useEffect)(()=>{let r=t.current;if(!r){Ee(new Map),Oe(!1);return}let i=new URL(e.previewUrl??e.prototypeUrl).origin,a=JSON.parse(qt),o=new Set(a.map(({id:e})=>e)),s=Date.now(),c=!1;function l(){qe.current=crypto.randomUUID(),s=Date.now(),c=!1,Oe(!1),ke(``),Ee(new Map),r?.contentWindow?.postMessage({type:`replica:canvas:request-ready`,nonce:qe.current},i),u()}function u(){a.length&&r?.contentWindow?.postMessage({type:`replica:canvas:resolve`,nonce:qe.current,anchors:a},i)}function d(e){let t=e.data;if(e.source===r?.contentWindow&&e.origin===i&&Nn(t)&&t.nonce===qe.current){if(t.type===`replica:canvas:bridge-error`)Oe(!1),ke(K.commentingMissing);else if(t.type===`replica:canvas:ready`){if(t.protocolVersion!==1){c=!0,Oe(!1),ke(K.commentingIncompatible);return}if(!Pn(t.route))return;s=Date.now(),c=!1,Oe(!0),ke(``),ee(Pn(t.route)),n?.(Pn(t.route),t.replaceRoute===!0)}else if(!c){if(t.type===`replica:canvas:conversation-dismiss-requested`)window.dispatchEvent(new Event(`replica:review-dismiss`));else if(t.type===`replica:canvas:resolved`){if(t.protocolVersion!==1||!Pn(t.route)||!Array.isArray(t.results)||t.results.length>200)return;s=Date.now(),Oe(!0),ke(``),ee(Pn(t.route)),n?.(Pn(t.route),t.replaceRoute===!0);let e=new Map;for(let n of t.results){if(!Nn(n)||typeof n.id!=`number`||typeof n.x!=`number`||typeof n.y!=`number`||!o.has(n.id)||!Number.isFinite(n.x)||!Number.isFinite(n.y)||n.x<0||n.y<0||n.x>r.clientWidth||n.y>r.clientHeight)continue;let t=Nn(n.rect)&&typeof n.rect.x==`number`&&typeof n.rect.y==`number`&&typeof n.rect.width==`number`&&typeof n.rect.height==`number`&&Number.isFinite(n.rect.x)&&Number.isFinite(n.rect.y)&&Number.isFinite(n.rect.width)&&Number.isFinite(n.rect.height)&&n.rect.width>=0&&n.rect.height>=0?{x:n.rect.x,y:n.rect.y,width:n.rect.width,height:n.rect.height}:{x:n.x,y:n.y,width:0,height:0};e.set(n.id,{x:n.x,y:n.y,rect:t})}Ee(e)}else if(t.type===`replica:canvas:selected`){let e=Gt.safeParse(t.anchor);if(!e.success){Xt(`replica:canvas:cancel-selection`),Xt(`replica:canvas:clear-selection`),Me(null),Le(Nn(t.anchor)&&t.anchor.kind===`area`?`area-unavailable`:`element-unavailable`);return}Fe(e.data),Me(null),Le(null)}else t.type===`replica:canvas:selection-failed`&&(t.reason===`element-unavailable`||t.reason===`area-too-small`||t.reason===`area-unavailable`)?(Me(null),Le(t.reason)):t.type===`replica:canvas:selection-cancelled`&&Me(null)}}}function f(){Ye.current+=1,Pe(!1),Me(null),Le(null),l()}r.addEventListener(`load`,f),window.addEventListener(`message`,d),l();let p=window.setInterval(()=>{Date.now()-s>=2e4&&(Oe(!1),Ee(new Map),ke(c?K.commentingIncompatible:K.commentingMissing)),r.contentWindow?.postMessage({type:`replica:canvas:request-ready`,nonce:qe.current},i),u()},2e3);return()=>{r.removeEventListener(`load`,f),window.removeEventListener(`message`,d),window.clearInterval(p)}},[ot,qt,e.prototypeUrl,e.previewUrl,t,n,Xt]);async function en(t,n,r,i){let a=ot,o=dt,s=i?.kind===`add-reaction`||i?.kind===`remove-reaction`||i?.kind===`mark-unread`;if(i){if(He.current)return!1;He.current=!0,Ve(i)}s&&(We.current=!0,Ue.current+=1),B(``);try{let i=await $(`/api/hub/comments/${t}`,e.token,{method:n,...r?{body:JSON.stringify(r)}:{}});if($e.current!==a)return!1;if(s){let e=rn.parse(i);b(t=>{if(t.identity!==o)return t;let n=new Map(t.items.map(e=>[e.id,e]));for(let t of e.comments)n.set(t.id,t);return{identity:o,items:[...n.values()]}})}return s||(at.current=window.setTimeout(()=>void Yt.current(),0)),!0}catch(e){return $e.current===a&&(I(e instanceof Error?e.message:String(e)),e instanceof Error&&`statusCode`in e&&e.statusCode===429&&B(e.message)),!1}finally{i&&$e.current===a&&(s&&(We.current=!1,Ue.current+=1,at.current=window.setTimeout(()=>void Yt.current(),0)),He.current=!1,Ve(null))}}async function tn(t){let n=Je.current;if(!n||!Z||He.current)return!1;let r=ot,a=dt;He.current=!0,Ve({kind:`create`}),B(``),z(``);try{let o=rn.parse(await $(`/api/hub/comments`,e.token,{method:`POST`,body:JSON.stringify({review_revision:n,review_comment:{body:t,anchor:Z}})}));if($e.current!==r)return!1;let s=o.comments.find(e=>e.kind===`root`);if(!s)return!1;let c=s.buildNumber!==null||s.draftRevisionId===ut;c&&b(e=>{if(e.identity!==a)return e;let t=new Map(e.items.map(e=>[e.id,e]));for(let e of o.comments)t.set(e.id,e);return{identity:a,items:[...t.values()]}});let l=c&&Ke.current===a;return Qe.current=!l,$t(),l&&P(s.id),i().then(()=>{if($e.current===r)return Yt.current()}).catch(e=>{if($e.current===r){let t=e instanceof Error?e.message:String(e);I(K.commentRefreshFailed(t))}}),!0}catch(e){if($e.current===r){let t=e instanceof Error?e.message:String(e);I(t),z(t),e instanceof Error&&`statusCode`in e&&e.statusCode===429&&B(e.message)}return!1}finally{$e.current===r&&(He.current=!1,Ve(null))}}function ln(){Vt||(E?(P(null),D(!1)):(D(!0),_&&v()))}let un=r?.repository&&r.branch?`https://github.com/${r.repository.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}/tree/${encodeURIComponent(r.branch)}`:null,dn=r?.branch&&un?(0,U.jsxs)(`a`,{className:`canvas-hub-publication__branch`,href:un,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`Open ${r.branch} on GitHub`,children:[(0,U.jsx)(a,{size:16,"aria-hidden":`true`}),(0,U.jsx)(`span`,{children:r.branch})]}):r?.branch?(0,U.jsxs)(`span`,{className:`canvas-hub-publication__branch`,children:[(0,U.jsx)(a,{size:16,"aria-hidden":`true`}),(0,U.jsx)(`span`,{children:r.branch})]}):null,fn=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(H.Heading,{as:`h3`,size:`subhead-medium`,id:`canvas-hub-origin-title`,children:`Hub`}),r&&r.state!==`unconfigured`?(0,U.jsx)(`div`,{className:`canvas-hub-origin`,children:r.hubOrigin?(0,U.jsx)(`a`,{href:Q?new URL(`/repositories/${Q.repositoryId}/prototypes/${Q.id}`,r.hubOrigin).href:r.hubOrigin,target:`_blank`,rel:`noopener noreferrer`,children:r.hubOrigin}):(0,U.jsx)(`span`,{children:`URL unavailable`})}):null,ce||r?.state===`disconnected`||r?.state===`unconfigured`?(0,U.jsxs)(`form`,{className:`canvas-hub-origin-form`,onSubmit:e=>{e.preventDefault(),!(ue||fe)&&(de(!0),W(!0),I(``),o(G).then(()=>{W(!1)}).catch(e=>I(e.message)).finally(()=>de(!1)))},children:[(0,U.jsxs)(`div`,{className:`canvas-hub-origin-field`,children:[(0,U.jsxs)(`label`,{children:[K.hubUrl,(0,U.jsx)(`input`,{type:`url`,required:!0,value:G,placeholder:`https://hub.example.com`,disabled:ue||fe,onChange:e=>le(e.target.value)})]}),(0,U.jsx)(H.Button,{type:`button`,size:`small`,variant:`subtle`,className:`canvas-icon-button`,leadingVisual:(0,U.jsx)(L,{size:16}),"aria-label":K.resetHubUrl,title:K.resetHubUrl,disabled:ue||fe,"aria-busy":fe,onClick:()=>{q(!0),I(``),$(`/api/hub/discovery`,e.token,{method:`POST`,body:`{}`}).then(async e=>{if(e.discovery?.state!==`valid`||!e.discovery.origin)throw Error(e.discovery?.message||K.resetHubUnavailable);le(e.discovery.origin),await i()}).catch(e=>I(e.message)).finally(()=>q(!1))},children:(0,U.jsx)(`span`,{className:`visually-hidden`,children:K.resetHubUrl})})]}),(0,U.jsx)(`p`,{children:K.hubHttpsHint}),(0,U.jsxs)(`div`,{className:`canvas-hub-form-actions`,children:[(0,U.jsx)(H.Button,{type:`submit`,size:`small`,disabled:ue||fe,children:`Save Hub`}),ce&&r?.state!==`unconfigured`&&r?.state!==`disconnected`?(0,U.jsx)(H.Button,{type:`button`,size:`small`,variant:`subtle`,disabled:ue||fe,onClick:()=>W(!1),children:`Cancel`}):null]})]}):null]});return(0,U.jsxs)(rt,{source:T,children:[_t.visible?(0,U.jsx)(sn,{..._t}):null,Bt&&Ut?(0,et.createPortal)((0,U.jsxs)(`div`,{className:`canvas-review-controls review-shell__comment-actions`,role:`group`,"aria-label":xt.heading,children:[(0,U.jsx)(yt,{bridgeReady:De&&zt,copy:xt,selectionBlocked:Vt,selecting:je!==null,onCancelSelection:Qt,onStartAreaSelection:()=>void Zt(`area`),onStartElementSelection:()=>void Zt(`element`)}),(0,U.jsx)(H.Tooltip,{ref:Ze,text:Vt?xt.selectionBlockedLabel:`${xt.heading} (${xt.sidebarShortcutLabel})`,type:`description`,children:(0,U.jsxs)(H.Button,{className:`canvas-comments-toggle review-shell__comments-toggle`,variant:`secondary`,size:`small`,"aria-label":`${xt.heading}, ${Lt}${Rt?`, ${xt.unreadLabel}`:``}`,"aria-expanded":E,"aria-keyshortcuts":`Shift+C`,disabled:Vt,onClick:ln,children:[(0,U.jsx)(tt,{children:Lt}),Rt?(0,U.jsx)(`span`,{className:`canvas-comments-unread-badge review-shell__unread-badge`,"aria-hidden":`true`}):null]})})]}),Ut):null,A&&It.length&&De&&!je?(0,U.jsx)(`div`,{className:`canvas-marker-layer`,children:(0,U.jsx)(ct,{threads:It,resolutions:Et,selectedThreadId:N,selectionBlocked:Ce,focusSelectedMarker:!1,showAreaHighlightsOnlyWhenSelected:!0,copy:xt,onSelect:e=>P(e.root.id)})}):null,(0,U.jsxs)(it,{className:`canvas-hub-panel`,contentClassName:`canvas-hub-content`,title:`Replica Hub`,label:`Hub`,open:Ht,closeLabel:`Close Hub`,closeRef:Xe,onClose:v,children:[F?(0,U.jsx)(`p`,{role:`alert`,children:F}):null,ne?(0,U.jsx)(`p`,{role:`alert`,children:ne}):null,r?null:(0,U.jsx)(`p`,{children:`Checking Hub connection…`}),!Ot&&!ht&&r?.message?(0,U.jsx)(`p`,{role:`status`,children:r.message}):null,ht?(0,U.jsxs)(`div`,{className:`canvas-hub-status`,children:[(0,U.jsx)(pe,{variant:`warning`,layout:`compact`,title:r?.message||X.hubUnavailable}),(0,U.jsx)(H.Button,{variant:`primary`,size:`small`,disabled:f,"aria-busy":f,leadingVisual:f?(0,U.jsx)(L,{size:16}):void 0,onClick:h||(()=>void i()),children:X.retry})]}):null,!Ot&&!ht&&d&&m&&h?(0,U.jsx)(Ae,{publication:d,busy:f,dirty:p,onPublish:m,onRetry:h}):null,Ot?(0,U.jsxs)(`section`,{className:`canvas-hub-connection`,children:[(0,U.jsx)(`p`,{children:K.connectionBeforePublishing}),(0,U.jsx)(H.Button,{ref:l,variant:`primary`,onClick:s,disabled:u,children:u?K.connectionOpeningBrowser:K.connectToHub})]}):null,!Ot&&(!ce&&(r?.discovery?.mismatch||[`invalid`,`unreachable`].includes(r?.discovery?.state||``))||r?.state===`unconfigured`)?(0,U.jsxs)(`div`,{className:`canvas-hub-settings`,children:[!ce&&r?.discovery?.mismatch?(0,U.jsx)(`p`,{role:`alert`,children:`The repository configuration differs from your selected Hub. Your connection has not changed. Disconnect Hub before selecting another URL.`}):null,!ce&&[`invalid`,`unreachable`].includes(r?.discovery?.state||``)?(0,U.jsx)(`p`,{role:`alert`,children:r?.discovery?.message}):null,r?.state===`unconfigured`?(0,U.jsx)(`p`,{children:`Enter your Hub URL to connect.`}):null]}):null,r?.state===`undiscovered`&&!d?(0,U.jsxs)(`p`,{children:[`Connected to `,r.repository,`. Hub has not discovered`,` `,r.branch||`a prototype branch`,`. Your repository connection is ready. Push a named branch to make its Builds and reviews available.`]}):null,Q?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`section`,{className:d&&d.kind!==`ready`&&m&&h?`canvas-hub-publication canvas-hub-publication--after-status`:`canvas-hub-publication`,"aria-label":`Prototype`,children:Mt&&Kt?(0,U.jsxs)(`form`,{className:`canvas-hub-publication__form`,onSubmit:t=>{t.preventDefault(),$(`/api/hub/metadata`,e.token,{method:`PATCH`,body:JSON.stringify({name:me,description:ge,startPage:ve})}).then(async()=>{J(!1),await i()}).catch(e=>I(e.message))},children:[(0,U.jsxs)(`div`,{className:`canvas-hub-publication__title`,children:[(0,U.jsxs)(`label`,{className:`canvas-hub-publication__name-field`,children:[(0,U.jsx)(`span`,{className:`visually-hidden`,children:`Name`}),(0,U.jsx)(`input`,{required:!0,maxLength:255,value:me,onChange:e=>he(e.target.value)})]}),(0,U.jsx)(`span`,{className:`canvas-hub-publication__status`,children:Q.published?`Published`:Q.registered?`Registered`:`Not registered`})]}),dn,(0,U.jsxs)(`label`,{className:`canvas-hub-publication__description-field`,children:[(0,U.jsx)(`span`,{className:`visually-hidden`,children:`Description`}),(0,U.jsx)(`textarea`,{value:ge,placeholder:`Add a description`,onChange:e=>_e(e.target.value)})]}),(0,U.jsxs)(`label`,{className:`canvas-hub-publication__start-page-field`,children:[K.startPage,(0,U.jsx)(`input`,{value:ve,placeholder:`/`,"aria-describedby":`canvas-start-page-hint`,onChange:e=>ye(e.target.value)})]}),(0,U.jsx)(`p`,{id:`canvas-start-page-hint`,className:`canvas-hub-publication__hint`,children:K.startPageHint}),(0,U.jsxs)(`div`,{className:`canvas-hub-form-actions`,children:[(0,U.jsx)(H.Button,{type:`submit`,size:`small`,children:`Save metadata`}),(0,U.jsx)(H.Button,{type:`button`,size:`small`,variant:`subtle`,onClick:()=>J(!1),children:`Cancel`})]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`canvas-hub-publication__title`,children:[(0,U.jsx)(H.Heading,{as:`h3`,size:`subhead-large`,children:Q.name||r?.branch}),(0,U.jsx)(`span`,{className:`canvas-hub-publication__status`,children:Q.published?`Published`:Q.registered?`Registered`:`Not registered`})]}),dn,Q.description?(0,U.jsx)(`p`,{className:`canvas-hub-publication__description`,children:Q.description}):null,(0,U.jsxs)(`p`,{className:`canvas-hub-publication__description canvas-hub-publication__start-page`,children:[K.startPage,`: `,(0,U.jsx)(`code`,{children:Q.startPage||`/`})]}),Mt?(0,U.jsx)(H.Button,{size:`small`,variant:`subtle`,onClick:()=>{he(Q.name||``),_e(Q.description||``),ye(Q.startPage||``),Se(ot),J(!0)},children:K.editDetails}):null]})}),(0,U.jsxs)(`section`,{className:`canvas-hub-section`,"aria-labelledby":`canvas-hub-build-title`,children:[(0,U.jsx)(H.Heading,{as:`h3`,size:`subhead-medium`,id:`canvas-hub-build-title`,children:K.latestBuild}),Q.build?(0,U.jsxs)(`div`,{className:`canvas-hub-build`,children:[(0,U.jsxs)(`div`,{className:`canvas-hub-build__identity`,children:[(0,U.jsx)(`a`,{href:Q.build.url,target:`_blank`,rel:`noopener noreferrer`,children:K.buildTitle(Q.build.number)}),(0,U.jsx)(`code`,{title:Q.build.commitSha,"aria-label":`${K.buildCommit} ${Q.build.commitSha}`,children:Q.build.commitSha.slice(0,7)})]}),(0,U.jsx)(`p`,{children:At?(0,U.jsx)(`a`,{className:`canvas-hub-build__author`,href:At,target:`_blank`,rel:`noopener noreferrer`,children:jt}):(0,U.jsx)(`span`,{children:jt})}),r?.commitSha&&r.commitSha!==Q.build.commitSha?(0,U.jsx)(`p`,{className:`canvas-hub-build__notice`,children:`Local checkout differs from this Build`}):null]}):(0,U.jsxs)(`p`,{children:[`No successful imported Build yet. Current Build: `,Q.buildState||`none`,`.`]}),Q.build&&r?.hubOrigin?(0,U.jsx)(`a`,{className:`canvas-hub-build__history`,href:new URL(`/repositories/${Q.repositoryId}/prototypes/${Q.id}/builds`,r.hubOrigin).href,target:`_blank`,rel:`noopener noreferrer`,children:K.showBuildHistory}):null]})]}):null,Ot?null:(0,U.jsxs)(`section`,{className:`canvas-hub-section`,"aria-labelledby":`canvas-hub-origin-title`,children:[fn,r?.hubOrigin&&[`connected`,`undiscovered`,`pairing`,`denied`,`unavailable`].includes(r.state)?(0,U.jsx)(`div`,{className:`canvas-hub-disconnect`,children:(0,U.jsx)(H.Button,{size:`small`,variant:`subtle`,onClick:()=>{re(``),$(`/api/hub/disconnect`,e.token,{method:`POST`,body:`{}`}).then(async()=>{le(r.discovery?.mismatch&&r.discovery.origin||r.hubOrigin||``),W(!0),await i(),c?.()}).catch(e=>{re(K.disconnectFailed(r.hubOrigin||``,e.message)),le(r.discovery?.mismatch&&r.discovery.origin||r.hubOrigin||``),W(!0)})},children:`Disconnect Hub`})}):null]}),Q?.registered&&Q.build&&g?(0,U.jsx)(Mn,{preference:g,disabled:f}):null]}),Bt?(0,U.jsx)(vt,{frame:{open:E,className:`canvas-comments-sidebar-shell`,contentClassName:`canvas-comments-sidebar-content`},threads:It,currentBuildNumber:Pt?.number||0,buildLinkOrigin:r?.hubOrigin,totalCount:It.length,hasThreads:wt.length>0,filters:O,participants:Tt,resolutions:Et,selectedThreadId:N,selectionBlocked:Vt,closeBlocked:Ce,showPins:A,loading:ie,loadFailed:oe,notice:Re||r?.reviewError||r?.localCommentsError||ut?(0,U.jsxs)(`div`,{className:`canvas-comments-live-notices`,children:[Re?(0,U.jsx)(`p`,{className:`canvas-comments-live-status`,role:`status`,children:K.commentLiveUpdatesPaused}):null,r?.reviewError?(0,U.jsx)(`p`,{className:`canvas-comments-live-status`,children:r.reviewError}):null,r?.localCommentsError?(0,U.jsx)(`p`,{className:`canvas-comments-live-status`,role:`alert`,children:r.localCommentsError}):null,ut?(0,U.jsx)(`p`,{className:`canvas-comments-live-status`,children:K.localCommentsSaved}):null]}):null,copy:xt,onClose:ln,onFiltersChange:k,onShowPinsChange:j,onRetry:()=>void Jt(),onSelect:e=>P(e.root.id)}):null,(0,U.jsx)(jn,{selectionNotice:Ie?Ie===`area-too-small`?xt.areaTooSmallLabel:Ie===`area-unavailable`?xt.areaUnavailableLabel:xt.selectionFailedLabel:null,rateLimitNotice:Ht?null:te||!Z&&R||null,composer:Z&&Wt?{anchorPoint:Wt,bodyMaximumBytes:1e4,copy:xt,creating:Be?.kind===`create`,submitError:R,onSubmit:tn,onDiscard:$t}:null,conversation:Dt?{thread:Dt,anchorPoint:Te.get(Dt.root.id)??null,bodyMaximumBytes:1e4,mutation:Be,copy:xt,onClose:()=>P(null),onDraftStateChange:we,onReply:e=>en(`${Dt.root.id}/replies`,`POST`,{review_comment:{body:e}},{kind:`reply`,commentId:Dt.root.id}),onEdit:(e,t)=>en(`${e}`,`PATCH`,{review_comment:{body:t}},{kind:`edit`,commentId:e}),onDelete:e=>en(`${e}`,`DELETE`,void 0,{kind:`delete`,commentId:e}),onResolve:()=>en(`${Dt.root.id}/resolution`,`POST`,void 0,{kind:`resolve`,commentId:Dt.root.id}),onReopen:()=>en(`${Dt.root.id}/resolution`,`DELETE`,void 0,{kind:`reopen`,commentId:Dt.root.id}),onAddReaction:(e,t)=>en(`${e}/reactions`,`POST`,{review_comment_reaction:{content:t,activity_version:Dt.root.activityVersion}},{kind:`add-reaction`,commentId:e,content:t}),onRemoveReaction:(e,t)=>en(`${e}/reactions/${encodeURIComponent(t)}`,`DELETE`,{review_comment_reaction:{activity_version:Dt.root.activityVersion}},{kind:`remove-reaction`,commentId:e,content:t}),onMarkRead:e=>en(`${Dt.root.id}/read`,`POST`,{review_thread_read:{activity_version:e}}),onMarkUnread:()=>en(`${Dt.root.id}/read`,`DELETE`,void 0,{kind:`mark-unread`,commentId:Dt.root.id})}:null})]})}function In(e,t,n){function r(e,t,n){return{kind:e,title:t,detail:n}}if(!e||!t)return n.kind===`unknown`?r(`retry`,Y.unavailable,n.detail):r(`checking`,Y.checking,Y.checkingDetail);if(!e.stats.branch)return r(`restricted`,Y.restricted,n.detail);if(t.repository&&t.repository!==e.stats.repository||t.branch&&t.branch!==e.stats.branch)return r(`retry`,Y.unavailable,Y.changedDetail);if(t.discovery?.state===`local`||e.stats.repository?.startsWith(`local/`))return r(`restricted`,Y.restricted,Y.local);if(t.registrationReason===`branch_not_reviewable`||e.stats.branch===t.discovery?.defaultBranch)return r(`restricted`,Y.restricted,X.registrationReasons.get(`branch_not_reviewable`).description);if([`disconnected`,`pairing`,`unconfigured`].includes(t.state))return r(`connect`,Y.connect,Y.connectDetail);if([`denied`,`unavailable`].includes(t.state))return r(`retry`,Y.unavailable,t.message||Y.unavailableDetail);if(t.repository!==e.stats.repository||t.branch!==e.stats.branch)return r(`retry`,Y.unavailable,Y.unavailableDetail);let i=t.prototype;if(t.state===`connected`&&i?.branch===e.stats.branch&&i.registered&&i.published&&i.build&&Number.isSafeInteger(i.build.number)&&i.build.number>0)return r(`ready`,Y.ready,Y.readyDetail);if(t.state===`connected`&&(!i||i.branch!==e.stats.branch||typeof i.published!=`boolean`||i.published))return r(`retry`,Y.unavailable,Y.unavailableDetail);let a=t.state===`connected`?i?.canEdit:t.canPublish;if(a===!1)return r(`restricted`,Y.restricted,Y.publishDenied);let o=e.stats.remoteBranch,s=t.state===`undiscovered`&&t.repositoryAuthorized===!0&&!i&&(!t.commitSha||t.commitSha===e.stats.commitSha)&&o?.repository===e.stats.repository&&o?.branch===e.stats.branch&&o?.commitSha===e.stats.commitSha&&(o?.state===`absent`||o?.state===`present`&&e.publishRequest?.commitSha===e.stats.commitSha&&([`requested`,`in_progress`].includes(e.publishRequest?.state??``)||e.publishRequest?.state===`idle`&&e.publishRequest.remoteState===`absent`))&&![`loading`,`unknown`,`detached`,`workflow_missing`].includes(n.kind),c=a===void 0&&s;if(a!==!0&&!c)return r(`retry`,Y.unavailable,Y.permissionUnknown);let l=t.registrationReason||i?.registrationReason;if(n.error&&(l!==`remote_branch_missing`||!s)){let e=[`successful_build_required`,`already_registered`].includes(l||``),t=[`write_access_required`,`repository_mismatch`,`branch_not_reviewable`,`remote_branch_missing`,`branch_authorship_required`].includes(l||``);return{...r(e?`progress`:t?`restricted`:`retry`,n.error.title,n.error.description),...e?{publication:{...n,action:`retry`,label:X.retry}}:{}}}if(n.kind===`detached`)return r(`restricted`,Y.restricted,n.detail);if(n.action===`retry`)return r(`retry`,Y.unavailable,n.detail);if(n.kind===`loading`)return r(`checking`,Y.checking,n.detail);let u=c?`${Y.publishDetail} ${Y.publishPermissionUnverified}`:Y.publishDetail,d=s&&l===`remote_branch_missing`?{...n,error:void 0}:n;return n.action===`publish`?{...r(`publish`,Y.publish,u),publication:d}:{...r(`progress`,Y.preparing,u),publication:d}}function Ln({open:e,onToggle:t,buttonRef:n}){return(0,U.jsx)(G,{icon:C,"aria-label":K.controls,description:K.controls,ref:n,size:`small`,variant:`default`,className:`canvas-controls-toggle`,"aria-expanded":e,onClick:t})}function Rn({toolbarRef:e,config:t,onPublish:n,publishButtonRef:r,hubButtonRef:a,titleButtonRef:o,onBuildDetails:s,publishing:c,state:l,prototypeName:u,hubOpen:d,onHub:f,publication:p,onControls:m,controlsOpen:h,controlsButtonRef:g,onShare:_,shareButtonRef:v}){let y=l?.publishStatus??{state:`unavailable`,detail:K.statusUnavailable},b=u?.trim()||l?.stats.branch||l?.name||t.name,x=l?[b,l.stats.repository,l.stats.commitSha?.slice(0,7),l.stats.workingTree===`changed`?K.workingTreeChanged:K.workingTreeClean,l.stats.urlHost].filter(Boolean).join(` · `):b,S=c||(p?p.action===`none`:y.state===`requested`||y.state===`in_progress`||y.state===`published`),C=c||(p?p.kind===`requested`||p.kind===`queued`||p.kind===`building`||p.kind===`importing`||p.kind===`awaiting_build`||p.kind===`registration`:y.state===`requested`||y.state===`in_progress`),w=!C&&(p?p.kind===`ready`:y.state===`published`),T=(0,U.jsx)(H.Button,{type:`button`,ref:r,className:`canvas-publish-button`,variant:`secondary`,size:`small`,leadingVisual:C?(0,U.jsx)(L,{size:16}):zn(y.state),disabled:S&&!w,"aria-busy":C,title:w?void 0:p?.detail||y.detail,onClick:S||w?void 0:n,children:p?.label||K.publishLabels[y.state]});return(0,U.jsxs)(`header`,{ref:e,className:`canvas-toolbar`,children:[(0,U.jsx)(H.Button,{type:`button`,className:`canvas-title`,ref:o,variant:`subtle`,size:`small`,title:x,disabled:!l,onClick:s,children:b}),(0,U.jsx)(`div`,{id:`canvas-review-controls`,className:`canvas-review-controls-slot`}),m?(0,U.jsx)(Ln,{buttonRef:g,open:h,onToggle:m}):null,f?(0,U.jsx)(H.Button,{type:`button`,ref:a,size:`small`,variant:`secondary`,"aria-expanded":d,onClick:f,children:K.editDetails}):null,(0,U.jsxs)(`div`,{className:`canvas-publish-share`,role:`group`,"aria-label":J.group,children:[w?(0,U.jsx)(H.Tooltip,{ref:r,text:X.alreadyPublished,type:`description`,children:T}):T,_?(0,U.jsx)(G,{ref:v,icon:i,size:`small`,"aria-label":J.title,description:J.title,onClick:_}):null]})]})}function zn(e){return e===`published`?(0,U.jsx)(s,{size:16}):e===`failed`||e===`in_progress`||e===`requested`?(0,U.jsx)(L,{size:16}):(0,U.jsx)(D,{size:16})}function Bn(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>Je(e,t)))}}var Vn={bridgeUnavailable:`The prototype bridge is not ready on this page.`,routeChanged:`The prototype route changed. Inspect the live canvas again.`,reloaded:`The prototype reloaded before confirming the click. Inspect the live canvas and retry.`,unconfirmed:`The prototype did not confirm the click. Check its bridge and retry.`,clickFailed:`The target could not be clicked.`,addressUnavailable:`The canvas address field is unavailable.`,unknownAction:`Unknown canvas action.`,replyRejected:`The live canvas rejected the action reply. Check its transport diagnostics.`,actionInterrupted:`The canvas changed before the action could run. Inspect the live canvas and retry.`,statusInterrupted:`The canvas changed while collecting Controls status. Inspect the live canvas and retry.`};function Hn(e){let{token:t,prototypeUrl:n,previewUrl:r,cancelClick:i}=e,a=(0,V.useRef)(e),o=(0,V.useRef)(null);(0,V.useLayoutEffect)(()=>{a.current=e}),(0,V.useEffect)(()=>{o.current??=crypto.randomUUID();let e={"X-Replica-Renderer-Id":o.current},s=!1,c=!1,l=new AbortController,u=new URL(r??n).origin;async function d(e){let t=a.current.frameRef.current,n=a.current.liveRoute;if(!t?.contentWindow||!n)throw Error(Vn.bridgeUnavailable);if(e.route.pathname!==n.pathname||e.route.search!==n.search||e.route.hash!==n.hash)throw Error(Vn.routeChanged);let r=crypto.randomUUID();return await new Promise((n,a)=>{function o(){window.clearTimeout(c),window.removeEventListener(`message`,l),i.current===s&&(i.current=null)}function s(){o(),a(Error(Vn.reloaded))}let c=window.setTimeout(()=>{o(),a(Error(Vn.unconfirmed))},2e3);function l(i){let s=i.data;i.source===t?.contentWindow&&i.origin===u&&s&&typeof s==`object`&&`type`in s&&s.type===`replica:canvas:click-result`&&`nonce`in s&&s.nonce===r&&(o(),`clicked`in s&&s.clicked===!0?n({clicked:!0,route:e.route}):a(Error(Vn.clickFailed)))}i.current=s,window.addEventListener(`message`,l),t.contentWindow.postMessage({type:`replica:canvas:click`,nonce:r,...e},u)})}async function f(e){let t=a.current.frameRef.current,r=crypto.randomUUID(),i=Date.now()+e,o=await new Promise((n,o)=>{function s(){window.clearTimeout(d),window.removeEventListener(`message`,p),t?.removeEventListener(`load`,m),l.signal.removeEventListener(`abort`,c)}function c(){s(),o(Error(Vn.statusInterrupted))}let d=window.setTimeout(()=>{if(s(),a.current.liveRoute)o(Error(Vn.bridgeUnavailable));else{let e=new URL(a.current.navigation.entries[a.current.navigation.index]);e.protocol=new URL(u).protocol,e.host=new URL(u).host,n({status:`pending`,url:e.href,error:``,controls:[]})}},e+1500),f=!1;function p(e){let i=e.data;e.source===t?.contentWindow&&t===a.current.frameRef.current&&e.origin===u&&i&&typeof i==`object`&&`type`in i&&(i.type===`replica:canvas:ready`&&!f&&(f=!0,m()),i.type===`replica:controls:status-result`&&`nonce`in i&&i.nonce===r&&`value`in i&&(s(),n(i.value)))}function m(){t===a.current.frameRef.current&&t?.contentWindow?.postMessage({type:`replica:controls:status`,nonce:r,timeoutMs:Math.max(0,i-Date.now())},u)}window.addEventListener(`message`,p),t?.addEventListener(`load`,m),l.signal.addEventListener(`abort`,c),m()});if(!o||typeof o!=`object`||!(`url`in o)||typeof o.url!=`string`||!(`status`in o)||typeof o.status!=`string`||!(`error`in o)||typeof o.error!=`string`||!(`controls`in o)||!Array.isArray(o.controls))throw Error(Vn.bridgeUnavailable);let s=new URL(o.url);if(s.origin!==u)throw Error(Vn.routeChanged);let c=new URL(n);s.protocol=c.protocol,s.host=c.host;let d=await p(i);return!d&&a.current.controlsConnection===void 0?{...o,url:s.href}:{...d?Bn(d,d.loading,s.href):{status:`pending`,url:s.href,error:``,controls:[]},runtime:{status:o.status,error:o.error,controls:o.controls}}}function p(e){let t=a.current.controlsConnection;if(!t)return Promise.resolve(null);let n=t.getSnapshot,r=t.subscribe,i=n();return!i.loading||e<=Date.now()?Promise.resolve(i):new Promise(t=>{let i={};function a(e){window.clearTimeout(c),i.unsubscribe?.(),l.signal.removeEventListener(`abort`,s),t(e)}function o(){let e=n();e.loading||a(e)}function s(){a(null)}let c=window.setTimeout(()=>a(n()),e-Date.now());i.unsubscribe=r(o),l.signal.addEventListener(`abort`,s,{once:!0}),o()})}async function m(){if(!(s||c)){s=!0;try{let{command:r,prototypeUrl:i}=await $(`/api/agent/next`,t,{headers:{...e,"X-Replica-Prototype-Url":n}});if(!c&&i&&i!==n){window.location.reload();return}if(!r)return;let o;try{if(await $(`/api/agent/progress`,t,{method:`POST`,headers:e,body:JSON.stringify({id:r.id,stage:`handler started`})}),c)throw Error(Vn.actionInterrupted);let n;if(r.type===`inspect`){let{appearance:e,navigation:t,liveRoute:r,addressRef:i}=a.current,o=i.current?.value;if(o===void 0)throw Error(Vn.addressUnavailable);n={address:t.entries[t.index],addressDraft:o,appearance:e,canGoBack:t.index>0,canGoForward:t.indexvoid m(),300);return()=>{c=!0,l.abort(),window.clearInterval(h),i.current?.()}},[n,r,t,i])}function Un(e,t,n){let r=t?.repository===e?.stats.repository&&t?.branch===e?.stats.branch,i=!e?.stats.branch&&!!e?.stats.branchError,a=i?void 0:t?.branch,o=!!(e&&!i&&(t?.repository&&t.repository!==e.stats.repository||t?.branch&&t.branch!==e.stats.branch||t?.commitSha&&t.commitSha!==e.stats.commitSha)),s=!!(n.kind===`ready`&&r&&t?.state===`connected`&&t.prototype?.published&&t.prototype.build?.commitSha===e?.stats.commitSha);return{state:e&&{...e,publishStatus:!s&&[`requested`,`in_progress`].includes(e.publishStatus?.state??``)||t?.state===`connected`&&!r?e.publishStatus:s&&t?.prototype?.build?{state:`published`,detail:K.hubBuildImported,versionCount:t.prototype.versionCount,lastUpdatedAt:t.prototype.build.publishedAt,run:{url:t.prototype.build.url,actor:t.prototype.build.author.login||t.prototype.build.author.name?{login:t.prototype.build.author.login||void 0,name:t.prototype.build.author.name||void 0,avatarUrl:t.prototype.build.author.avatarUrl||void 0}:null}}:{state:t?.state===`connected`?`not_published`:`unavailable`,detail:t?.state===`connected`?K.hubBuildMissing:K.hubPublicationUnavailable},stats:{...e.stats,branch:a||e.stats.branch,branchError:a&&a!==e.stats.branch?null:e.stats.branchError,repository:t?.repository||e.stats.repository,commitSha:e.stats.commitSha,comparison:o?{branch:null,source:null,behind:null,error:K.comparisonNeedsRefresh}:e.stats.comparison,publishedUrl:s?t?.prototype?.build?.url:void 0}},hubPublished:s,comparisonOutdated:o}}function Wn(e,t){let n;function r(e,t,r,i=`none`){return{kind:e,detail:t,label:r,action:i,...n?{error:n}:{}}}if(!e)return r(`loading`,X.initial,X.checking);let{stats:i}=e,a=i.remoteBranch;if(!a||a.state===`loading`)return r(`loading`,X.checkingRemote,X.checking);if(!i.branch||a.state===`detached`)return r(`detached`,X.detached,X.retry,`retry`);if(a.repository!==i.repository||a.branch!==i.branch||a.commitSha!==i.commitSha)return r(`unknown`,X.changed,X.retry,`retry`);if(a.state===`unknown`)return r(`unknown`,X.unknown(a.error),X.retry,`retry`);let o=t?.state===`connected`?t.prototype:void 0,s=o?.build?.commitSha===i.commitSha&&o?.branch===i.branch,c=e.publishRequest,l=t?.state===`connected`&&t.repository===i.repository&&t.branch===i.branch&&(!t.commitSha||t.commitSha===i.commitSha)&&t.prototype?.branch===i.branch&&t.prototype.build?.commitSha===i.commitSha?t.prototype.build:null,u=!!(l&&(c?.commitSha!==i.commitSha||c.buildNumber===void 0||typeof c.buildNumber==`number`&&l.number>c.buildNumber)),d=u&&o?.registered&&o.published,f=t!==null&&t.repository===i.repository&&(!t.branch||t.branch===i.branch)&&(!t.commitSha||t.commitSha===i.commitSha);if(t&&f&&(t.state===`connected`||t.state===`undiscovered`)&&!o?.registered&&(!o||o.branch===i.branch)){let e=t.registrationReason||o?.registrationReason,r=i.branch===t.discovery?.defaultBranch;if(e||t.registrationError||o?.canRegister===!1||r){let i=e||(r?`branch_not_reviewable`:o?.canEdit===!1?`write_access_required`:o?.canRegister===!1&&a.state===`absent`?`remote_branch_missing`:void 0);n=i&&X.registrationReasons.get(i)||{title:X.registrationErrorTitle,description:t.registrationError||X.registrationDenied}}}if(c?.state===`requested`&&(!c.commitSha||c.commitSha===i.commitSha)&&(a.state===`absent`||a.remoteSha!==i.commitSha)&&!u){let e=Date.now()-Date.parse(c.requestedAt||``);if(Number.isFinite(e)&&e<6e5)return r(`requested`,X.pending,X.awaitingCopilot)}if(!t)return r(`loading`,X.checkingHub,X.checking);if(t.state===`disconnected`||t.state===`pairing`||t.state===`unconfigured`)return r(`disconnected`,t.message||X.disconnected,X.connect);if(t.state===`denied`||t.state===`unavailable`)return{...r(`unknown`,t.message||X.hubUnavailable,X.retry,`retry`),error:{title:X.hubUnavailableTitle,description:t.message||X.hubUnavailable}};if(!f)return r(`unknown`,X.staleHub,X.retry,`retry`);if(!i.replicaWorkflowExists)return r(`workflow_missing`,X.workflowMissing,X.retry,`retry`);if(c?.state===`failed`&&!d&&(!c.commitSha||c.commitSha===i.commitSha))return r(`failed`,c.error||X.dispatchFailed,X.retryPublish,`publish`);if(a.state===`absent`)return r(`unpublished`,X.absent,X.publishBranch,`publish`);if(a.remoteSha!==i.commitSha)return r(`needs_push`,X.needsPush,X.publishChanges,`publish`);if(s){if(!o.registered)return r(`registration`,t.registrationError||(o.canEdit&&o.canRegister?X.needsRegistration:X.registrationDenied),t.registrationError?X.registrationFailed:X.registration);if(o.published&&u)return r(`ready`,X.ready,X.published)}if(o?.currentBuild?.commitSha===i.commitSha&&o.branch===i.branch&&o.currentBuild.state===`failed`)return r(`failed`,X.importFailed,X.retryPublish,`publish`);let p=i.workflow;if(!p||p.state===`unavailable`)return r(`unknown`,p?.detail||X.workflowUnavailable,X.retry,`retry`);let m=p.run;if(m&&(m.headSha!==i.commitSha||m.headBranch!==i.branch))return r(`unknown`,X.staleWorkflow,X.retry,`retry`);if(c?.commitSha===i.commitSha&&c.workflowRunId!=null&&m?.databaseId===c.workflowRunId&&!u)return r(`awaiting_build`,X.noBuild,X.awaitingBuild);let h;if(p.state===`in_progress`&&m){let e=[`queued`,`waiting`,`pending`,`requested`].includes(m.status||``);h=r(e?`queued`:`building`,e?X.workflowQueued:X.workflowBuilding,e?X.queued:X.building)}else h=p.state===`failed`&&m?r(`failed`,X.workflowFailed(m.conclusion),X.retryPublish,`publish`):p.state===`succeeded`&&m?r(`importing`,X.importing,X.awaitingHub):r(`awaiting_build`,X.noBuild,X.awaitingBuild);return m?.url?.startsWith(`https://github.com/`)&&(h.runUrl=m.url),h}function Gn({token:e,state:t,hubStatus:n,error:r,setError:i,refresh:a,refreshHub:o,preferenceSaving:s=!1}){let[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(null),m=(0,V.useRef)(!1),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(``),[y,b]=(0,V.useState)(!1),x=!t&&r?{kind:`unknown`,action:`retry`,label:X.retry,detail:r}:Wn(t,n),S=`${t?.stats.repository}/${t?.stats.branch}/${t?.stats.commitSha}`,C=f?.identity===S&&x.action===`publish`?{...x,kind:`failed`,detail:f.message,label:X.retryPublish}:x.kind===`ready`&&t?.stats.workingTree===`changed`?{...x,kind:`needs_push`,action:`publish`,label:X.publishChanges,detail:X.localChanges}:x,w=Un(t,n,x);(0,V.useEffect)(()=>{w.comparisonOutdated&&a(!0)},[w.comparisonOutdated,n?.branch,n?.commitSha,n?.repository,a]);async function T(){if(!y){b(!0);try{await Promise.all([a(!0),o()])}finally{b(!1)}}}async function E(){s||(C.action===`retry`?await T():C.action===`none`||m.current||h||await D())}async function D(){if(!(s||m.current)){m.current=!0,d(!0),i(``),v(``);try{let t=await $(`/api/publish/prepare`,e,{method:`POST`,body:`{}`});t.workingTree===`unavailable`||t.workingTree===`changed`&&!t.remember?g({preparation:t}):(g(null),await O(t,t.workingTree===`changed`?`commit-changes`:`committed-only`))}catch(e){let t=e instanceof Error?e.message:String(e);i(t),v(t)}finally{m.current=!1,d(!1)}}}async function O(r,s,c){if(s===`committed-only`&&n?.state===`connected`&&n.repository===r.target.repository&&n.branch===r.target.branch&&n.prototype?.registered&&n.prototype.published&&n.prototype.build?.commitSha===r.target.commitSha&&t?.stats.remoteBranch?.state===`present`&&t.stats.remoteBranch.remoteSha===r.target.commitSha)g(null);else{p(null),v(``),i(``);try{let t=await $(`/api/publish`,e,{method:`POST`,body:JSON.stringify({target:r.target,workingTree:r.workingTree,mode:s,remember:c})});g(null),l(t.message),await o(),await a(!1)}catch(e){let t=e instanceof Error?e.message:String(e);p({message:t,identity:S}),i(t),v(t)}}}async function k(e,t){if(!(s||!h||m.current)){if(h.preparation.workingTree===`unavailable`&&e!==`committed-only`)v(q.checkFailed);else{m.current=!0,d(!0);try{await O(h.preparation,e,t)}finally{m.current=!1,d(!1)}}}}return{publication:C,presentedState:w.state,busy:u||y||s,notice:c,publishDialog:h,publishDialogError:_,closePublishDialog:()=>g(null),choosePublish:k,retryPublishCheck:D,publish:E,retry:T}}var Kn=`replica:controls`;function qn(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&Se(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||Se({[r.id]:r.value}))}catch{return!1}}function Jn(e){return Array.isArray(e)&&e.length<=100&&e.every(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`scope`in e&&typeof e.scope==`string`&&e.scope.length>0&&e.scope.length<=64&&`error`in e&&typeof e.error==`string`&&e.error.length>0&&e.error.length<=500)}function Yn(e){if(!e||typeof e!=`object`)return!1;let t=e;if(typeof t.runtimeAvailable!=`boolean`||t.reconnectRequired!==void 0&&typeof t.reconnectRequired!=`boolean`||t.status===`ready`&&(!t.runtimeAvailable||!t.scopes?.length)||t.error!==void 0&&(typeof t.error!=`string`||t.error.length>1e3)||t.scopeErrors!==void 0&&!Jn(t.scopeErrors)||![`ready`,`no-controls`,`missing-runtime`,`unsupported-runtime`,`invalid-config`].includes(t.status)||!Array.isArray(t.scopes)||t.scopes.length>100||t.status!==`ready`&&t.scopes.length>0)return!1;try{let e=new Set;for(let n of t.scopes){if(Ue(n.declaration),e.has(n.declaration.scope)||(e.add(n.declaration.scope),n.fingerprint!==JSON.stringify(n.declaration)||!Number.isSafeInteger(n.snapshot.revision)||n.snapshot.revision<0))return!1;let t=n.snapshot;if(!t.values||!t.visible||!t.groups||!t.actions)return!1;function r(e,t){return typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))}if(!r(t.values,n.declaration.controls.filter(e=>e.type!==`button`).map(e=>e.id))||!r(t.visible,n.declaration.controls.map(e=>e.id))||!r(t.groups,(n.declaration.groups??[]).map(e=>e.id))||!r(t.actions,n.declaration.controls.filter(e=>e.type===`button`).map(e=>e.id))||Object.values(t.groups).some(e=>typeof e!=`boolean`))return!1;if(t.bindings!==void 0){if(!t.bindings||typeof t.bindings!=`object`||Array.isArray(t.bindings))return!1;for(let[e,r]of Object.entries(t.bindings))if(!n.declaration.controls.some(t=>t.id===e)||!r||typeof r.error!=`string`||r.error.length>500||typeof r.busy!=`boolean`||r.available!==void 0&&typeof r.available!=`boolean`)return!1}for(let e of n.declaration.controls){if(typeof t.visible[e.id]!=`boolean`)return!1;if(e.type===`button`){let n=t.actions[e.id];if(!n||typeof n.available!=`boolean`||typeof n.busy!=`boolean`)return!1}else if(ze(e,t.values[e.id]))return!1}}return!0}catch{return!1}}function Xn(){return{runtimeAvailable:!1,status:`missing-runtime`,scopes:[],scopeErrors:[],loading:!0,notice:``,error:``,storageError:``,resetting:!1}}var Zn=class{frame;origin;api;surface;epoch=``;sequence=-1;state=Xn();listeners=new Set;pending=new Map;saved;storageReady=!1;restored=new Set;preparing=new Set;persisted=new Map;cachedScopes=new Map;retryState;resetForIdentity=!1;fromFrameUrl=!1;requests=new AbortController;poll;deadline;saveQueue=Promise.resolve();editQueue=Promise.resolve();stopped=!0;constructor(e,t,n,r=`canvas`){this.frame=e,this.origin=t,this.api=n,this.surface=r}getSnapshot=()=>this.state;getControlValues=()=>{let e=structuredClone(this.saved?.scopes??{}),t=new Map(this.cachedScopes);for(let e of this.state.scopes)t.set(e.declaration.scope,e);for(let[n,r]of t)e[n]=Xe(r);return e};subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});publish(e){this.state={...this.state,...e},this.state.hasResettableValues=Object.values(this.getControlValues()).some(e=>Object.keys(e).length>0);for(let e of[...this.listeners])e()}hasBindingError(e,t){return this.state.scopes.some(n=>(!e||n.declaration.scope===e)&&Object.entries(n.snapshot.bindings??{}).some(([e,n])=>(!t||e===t)&&!!n.error))}checkSaved(e){let t=e,n=/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/;if(!t||typeof t!=`object`||typeof t.identity!=`string`||!t.identity||t.identity.length>128||!t.scopes||typeof t.scopes!=`object`||Array.isArray(t.scopes)||t.storageError!==void 0&&(typeof t.storageError!=`string`||t.storageError.length>1e3)||t.notice!==void 0&&(typeof t.notice!=`string`||t.notice.length>1e3)||new Blob([JSON.stringify(t)]).size>27e4)throw Error(`Invalid controls storage response.`);for(let[e,r]of Object.entries(t.scopes)){if(!n.test(e)||!r||typeof r!=`object`||Array.isArray(r))throw Error(`Invalid controls storage scope.`);for(let[e,t]of Object.entries(r))if(!n.test(e)||!(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))throw Error(`Invalid saved control value.`)}}start=e=>{this.fromFrameUrl=e?.type===`load`&&this.sequence>=0;let t=[...this.pending.values()].some(e=>e.action);this.stop(),this.requests=new AbortController,this.stopped=!1,this.epoch=crypto.randomUUID(),this.sequence=-1,this.saved=void 0,this.storageReady=!1,this.restored.clear(),this.preparing.clear(),this.persisted.clear(),this.editQueue=Promise.resolve(),this.cachedScopes.clear(),this.retryState=void 0,this.resetForIdentity=!1,this.state=Xn(),t&&(this.state.notice=`The preview reconnected during an action. Its outcome is unknown; it was not replayed.`),this.publish({});let n=this.epoch;window.addEventListener(`message`,this.receive),this.frame.addEventListener(`load`,this.start);let r=()=>{this.storageReady&&(this.surface===`canvas`&&this.frame.contentWindow?.postMessage({type:`replica:canvas:request-ready`,nonce:n},this.origin),this.send(`hello`).catch(()=>{}))};r(),this.poll=setInterval(()=>{this.state.status===`missing-runtime`&&r()},1e3),this.deadline=setTimeout(()=>{this.state.loading&&this.publish({loading:!1,error:this.surface===`build`?`Build Controls did not connect. Reload the preview or check its definitions.`:K.controlsLocalConnectionFailed})},6e3),this.api().then(e=>{if(!(this.epoch!==n||this.stopped)){if(this.checkSaved(e),this.saved=e,this.retryState?.identity===e.identity)for(let[e,t]of this.retryState.scopes)this.restored.add(`${e}:${t.fingerprint}`),this.cachedScopes.set(e,t);else this.retryState?.identity&&(this.resetForIdentity=!0,this.publish({notice:`The checkout identity changed. Controls will use this branch's saved values or defaults.`}));this.retryState=void 0,this.storageReady=!0,this.publish({storageError:e.storageError||``,notice:e.notice||this.state.notice}),this.prepare(this.state),r()}}).catch(e=>{this.epoch!==n||this.stopped||(this.storageReady=!0,this.publish({storageError:this.surface===`build`?e instanceof Error?e.message:`Control settings could not be read from the URL.`:K.controlsLocalStorageFailed}),this.prepare(this.state),r())})};retry=()=>{let e={identity:this.saved?.identity,scopes:new Map(this.cachedScopes)};this.start(),this.retryState=e};stop=()=>{this.stopped=!0,this.requests.abort(),clearInterval(this.poll),clearTimeout(this.deadline),window.removeEventListener(`message`,this.receive),this.frame.removeEventListener(`load`,this.start);for(let e of this.pending.values())clearTimeout(e.timer),e.reject(Error(`The preview navigated. The command outcome is unknown; it will not be replayed.`));this.pending.clear()};receive=e=>{if(this.stopped||e.source!==this.frame.contentWindow||e.origin!==this.origin||!qn(e.data))return;let t=e.data;if(t.epoch!==this.epoch||!Yn(t.state)||!Number.isSafeInteger(t.sequence)||(t.sequence??-1)<0||t.type!==`snapshot`&&t.type!==`reply`)return;let n=this.pending.get(t.requestId);if(t.type!==`reply`||n){if((t.sequence??-1)>this.sequence){if(t.type===`snapshot`&&t.controlQuery!==void 0&&this.saved){let e=Ee(t.controlQuery),n=this.saved.identity,r=this.epoch;this.stop();let i=new AbortController;this.requests=i,this.publish({loading:!0}),this.api({method:`POST`,signal:i.signal,body:JSON.stringify({identity:n,replace:!0,scopes:e.scopes})}).then(()=>{this.epoch!==r||i.signal.aborted||(this.start(),e.notice&&this.publish({notice:e.notice}))}).catch(e=>{this.epoch!==r||i.signal.aborted||this.publish({loading:!1,storageError:e instanceof Error?e.message:`Controls history could not be restored.`})});return}if(t.controlQuery!==void 0&&this.saved){let e=this.epoch,n=this.requests,r=Ee(t.controlQuery);this.saved.scopes=r.scopes,this.restored.clear(),this.persisted.clear(),this.cachedScopes.clear(),this.publish({notice:r.notice,loading:!0}),this.api({method:`POST`,signal:n.signal,body:JSON.stringify({identity:this.saved.identity,replace:!0,scopes:r.scopes})}).catch(t=>{this.epoch!==e||this.stopped||n.signal.aborted||this.publish({storageError:t instanceof Error?t.message:`Controls history could not be restored.`})})}this.sequence=t.sequence;let e=t.state.status;this.publish({...t.state,scopeErrors:t.state.scopeErrors??[],reconnectRequired:t.state.reconnectRequired===!0,status:e,error:t.state.error||(this.state.status===`missing-runtime`&&t.state.status!==`missing-runtime`?``:this.state.error),loading:!this.storageReady||this.state.resetting||this.preparing.size>0||this.state.loading&&e===`missing-runtime`}),this.prepare(this.state)}n&&(this.pending.delete(t.requestId),clearTimeout(n.timer),t.error?n.reject(Error(t.error)):n.resolve(this.state))}};send(e,t){let n=crypto.randomUUID(),r={protocol:Kn,version:1,epoch:this.epoch,requestId:n,type:e,...t?{command:t}:{},...e===`hello`?{controlQuery:Te(this.saved?.scopes??{}),fromFrameUrl:this.fromFrameUrl}:{}};return qn(r)?new Promise((i,a)=>{let o=setTimeout(()=>{this.pending.delete(n),a(Error(`The command timed out. Its outcome is unknown; it will not be retried automatically.`))},e===`hello`?1200:3e4);this.pending.set(n,{resolve:i,reject:a,timer:o,action:t?.operation===`action`}),this.frame.contentWindow?.postMessage(r,this.origin)}):Promise.reject(Error(`The controls command is invalid or exceeds the size limit.`))}async prepare(e){if(!this.saved&&!this.state.storageError||this.state.resetting||e.reconnectRequired)return;let t=this.epoch;if(this.resetForIdentity&&(e.status===`ready`||e.status===`no-controls`)){this.resetForIdentity=!1,this.publish({loading:!0,resetting:!0});try{await this.send(`command`,{operation:`reset-all`,contexts:e.scopes.map(e=>({scope:e.declaration.scope,fingerprint:e.fingerprint,revision:e.snapshot.revision}))})}catch{this.epoch===t&&this.publish({error:`The checkout changed, but runtime defaults could not be restored. Reload the preview before saving.`,storageError:`Saving is paused until the new checkout's runtime reconnects.`,loading:!1});return}finally{this.epoch===t&&this.publish({resetting:!1})}return this.epoch!==t||this.stopped?void 0:this.prepare(this.state)}for(let n of e.scopes){let e=n.declaration.scope,r=`${e}:${n.fingerprint}`;if(!this.preparing.has(r)){if(!this.restored.has(r)){this.preparing.add(r),this.publish({loading:!0});try{let i=this.saved?.scopes&&Object.hasOwn(this.saved.scopes,e)?this.saved.scopes[e]:{},a=Object.fromEntries(n.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)])),o=!1;for(let[e,t]of Object.entries(i)){let r=n.declaration.controls.find(t=>t.id===e);!r||ze(r,t)?o=!0:a[e]=t}if(Object.keys(a).length&&await this.send(`command`,{operation:`restore`,scope:e,fingerprint:n.fingerprint,revision:this.state.scopes.find(e=>e.fingerprint===n.fingerprint)?.snapshot.revision,values:a}),this.stopped||this.epoch!==t)return;this.restored.add(r),o&&this.publish({notice:this.surface===`build`?`Some URL control settings no longer match this page. Defaults were used.`:`Some saved controls no longer match this declaration and were discarded.`})}catch(n){if(this.epoch!==t||this.stopped)return;this.hasBindingError(e)||this.publish({error:n instanceof Error?n.message:`Saved controls could not be restored.`}),this.restored.add(r)}finally{this.epoch===t&&this.preparing.delete(r)}}if(this.epoch===t&&!this.stopped){let t=this.state.scopes.find(t=>t.declaration.scope===e);t&&(this.cachedScopes.set(e,t),this.persist(t))}}}this.epoch===t&&!this.stopped&&this.state.status!==`missing-runtime`&&this.publish({loading:this.preparing.size>0})}persist(e){if(!this.saved||this.state.storageError)return;let t=Xe(e),n=JSON.stringify(t);if(this.persisted.get(e.declaration.scope)===n)return;this.persisted.set(e.declaration.scope,n);let r=this.saved.identity,i=this.epoch,a=this.requests.signal;this.saveQueue=this.saveQueue.catch(()=>{}).then(async()=>{if(!(this.epoch!==i||this.stopped))try{if(await this.api({method:`POST`,signal:a,body:JSON.stringify({identity:r,scope:e.declaration.scope,values:t})}),this.epoch===i&&!this.stopped){let t=await this.api();if(this.checkSaved(t),this.epoch!==i||this.stopped)return;this.saved=t,await this.send(`command`,{operation:`url`,scope:e.declaration.scope,query:Te(t.scopes)})}}catch(e){this.epoch===i&&!this.stopped&&this.publish({storageError:this.surface===`build`&&e instanceof Error?`${e.message} Changes remain in memory and are not in the URL.`:`Controls could not be saved. Changes remain in memory; use Retry to reconnect storage.`})}})}async command(e,t,n,r){if(this.state.loading||this.state.resetting||this.stopped)return;let i=this.epoch,a=this.state.scopes.find(e=>e.declaration.scope===t);if(!a){this.publish({error:`This controls scope is no longer active.`});return}let o=()=>this.applyCommand(e,t,a.fingerprint,i,n,r);if(e!==`update`)return o();let s=this.editQueue.catch(()=>{}).then(o);return this.editQueue=s.then(()=>{}),s}async applyCommand(e,t,n,r,i,a){if(this.epoch!==r||this.stopped||this.state.resetting)return;let o=this.state.scopes.find(e=>e.declaration.scope===t);if(!o||o.fingerprint!==n)this.publish({error:`The controls scope or declaration changed. The command was not applied.`});else{this.publish({error:``});try{if(this.state.reconnectRequired)throw Error(`Reconnect controls before sending more commands.`);if(e===`update`||e===`action`){let t=o.declaration.controls.find(e=>e.id===i);if(!t||!o.snapshot.visible[t.id])throw Error(`This control is unknown or hidden.`);if(e===`update`){let e=ze(t,a);if(e)throw Error(`Control "${t.id}": ${e}`)}else if(t.type!==`button`||!o.snapshot.actions[t.id]?.available||o.snapshot.actions[t.id]?.busy)throw Error(`This action is unavailable or busy.`)}let n=await this.send(`command`,{operation:e,scope:t,fingerprint:o.fingerprint,revision:o.snapshot.revision,...i?{id:i}:{},...e===`update`?{value:a}:{}});if(e===`update`&&i)return{value:n.scopes.find(e=>e.declaration.scope===t)?.snapshot.values[i]}}catch(e){!this.stopped&&this.epoch===r&&!this.hasBindingError(t,i)&&this.publish({error:e instanceof Error?e.message:`Controls command failed.`})}}}async resetAll(){if(this.state.resetting||this.stopped)return;let e=this.epoch;this.publish({resetting:!0});try{let t=``;await this.editQueue.catch(()=>{});let n=this.state.runtimeAvailable&&(this.state.status===`ready`||this.state.status===`no-controls`);if(n)try{await this.send(`command`,{operation:`reset-all`,contexts:this.state.scopes.map(e=>({scope:e.declaration.scope,fingerprint:e.fingerprint,revision:e.snapshot.revision}))})}catch(e){t=e instanceof Error?e.message:`Some app defaults could not be restored.`}if(this.epoch!==e||this.stopped)return;if(!this.saved){let e=await this.api();this.checkSaved(e),this.saved=e}await this.saveQueue.catch(()=>{}),await this.api({method:`POST`,signal:this.requests.signal,body:JSON.stringify({identity:this.saved.identity,reset:!0})}),this.saved.scopes={},await this.send(`command`,{operation:`url`,query:``}),this.cachedScopes.clear(),this.persisted.clear(),this.publish({storageError:``,error:this.hasBindingError()?``:t,notice:n?``:`Saved controls were cleared. Runtime defaults could not be restored until the preview reconnects.`})}catch(t){this.epoch===e&&this.publish({storageError:t instanceof Error?t.message:`Reset could not be saved.`})}finally{this.epoch===e&&this.publish({resetting:!1,loading:!1})}}};function Qn(e,t=()=>window.location.href,n=e=>{window.history.replaceState(window.history.state,``,e),window.dispatchEvent(new Event(Ce))}){return r=>Promise.resolve().then(()=>{r?.signal?.throwIfAborted();let i=Ee(new URL(t()).search);if(!r)return{identity:e,...i};if(r.method!==`POST`||typeof r.body!=`string`)throw Error(`Invalid URL controls request.`);let a=JSON.parse(r.body);if(!a||typeof a!=`object`||!(`identity`in a)||a.identity!==e)throw Error(`The controls URL identity changed.`);let o=i.scopes;if(`reset`in a&&a.reset===!0)o={};else if(`replace`in a&&a.replace===!0&&`scopes`in a){if(!a.scopes||typeof a.scopes!=`object`||Array.isArray(a.scopes))throw Error(`Invalid controls history settings.`);let e={};for(let[t,n]of Object.entries(a.scopes)){if(!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(t)||!Se(n))throw Error(`Invalid controls history settings.`);e[t]=n}o=Ee(Te(e)).scopes}else{if(!(`scope`in a)||typeof a.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(a.scope)||!(`values`in a)||!Se(a.values))throw Error(`Invalid URL control settings.`);o={...o,[a.scope]:a.values}}let s=De(t(),Te(o));s!==t()&&n(s)})}function $n({frameRef:e,prototypeUrl:t,previewUrl:n,address:r,replaceAddress:i}){let[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),l=(0,V.useRef)({address:r,replaceAddress:i});return(0,V.useLayoutEffect)(()=>{l.current={address:r,replaceAddress:i}},[r,i]),(0,V.useEffect)(()=>{if(!e.current)return;let r=new Zn(e.current,new URL(n??t).origin,Qn(`prototype:${new URL(t).origin}`,()=>l.current.address,e=>{l.current.address=e,l.current.replaceAddress(e)}));o(r);let i=r.subscribe(()=>c(r.getSnapshot()));return r.start(),()=>{i(),r.stop()}},[t,n,e]),{connection:a,state:s}}function er({token:e,status:t,onStatusChange:n,onSelectHub:r}){let[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(null),m=(0,V.useRef)(!1),h=(0,V.useRef)(!1),g=t?.state===`connected`||t?.state===`undiscovered`,_=t?.state===`disconnected`||t?.state===`pairing`||t?.state===`unconfigured`,v=g?null:t?.pairing||(f?.repository===t?.repository&&f?.hubOrigin===t?.hubOrigin?f?.pairing:null),y=v?.verificationUrl;(0,V.useEffect)(()=>{let e=window.setTimeout(()=>{g?(a(!1),p(null),l(``)):_&&t?.repository&&!m.current&&(m.current=!0,a(!0))},0);return()=>window.clearTimeout(e)},[g,_,t?.repository]),(0,V.useEffect)(()=>{if(!y||u)return;let t=!1,r=!1;async function i(){if(!r){r=!0;try{let r=await $(`/api/hub/poll`,e,{method:`POST`,body:`{}`});if(t)return;r.status!==`pending`&&(p(null),r.status!==`approved`&&l(K.connectionApprovalExpired),await n())}catch(e){t||(l(e instanceof Error?e.message:String(e)),d(!0))}finally{r=!1}}}let a=window.setInterval(()=>void i(),3e3);return()=>{t=!0,window.clearInterval(a)}},[y,u,e,n,t?.repository,t?.hubOrigin]);async function b(i){if(m.current=!0,!h.current){if(!t?.repository)l(K.connectionRepositoryRequired);else if(!t.hubOrigin&&!i)l(K.connectionHubRequired);else{h.current=!0,s(!0),l(``),d(!1);try{!t.hubOrigin&&i&&await r(i);let a=await $(`/api/hub/connect`,e,{method:`POST`,body:`{}`});p({repository:t.repository,hubOrigin:new URL(a.verificationUrl).origin,pairing:a}),a.browserError&&l(K.connectionBrowserFailed(a.browserError)),await n()}catch(e){l(e instanceof Error?e.message:String(e))}finally{h.current=!1,s(!1)}}}}function x(){a(!0),t?.hubOrigin&&b()}return{open:i,close:()=>a(!1),show:()=>a(!0),showAndConnect:x,connect:b,connecting:o,error:c,pairing:v}}function tr({token:e,onStatus:t,onError:n}){let[r,i]=(0,V.useState)(null),a=(0,V.useRef)(0),o=(0,V.useRef)(0),s=(0,V.useRef)(!1),c=(0,V.useCallback)(async(r,c=!1)=>{if(s.current||c&&o.current>0)return;o.current+=1;let l=++a.current;try{let o=r===`open`||r===`interaction`,c=await $(o?r===`open`?`/api/hub/open`:`/api/hub/activity`:`/api/hub/status`,e,o?{method:`POST`,body:`{}`}:{});if(l!==a.current||s.current)return;i(c);let u=c.prototype?.startPageImportError||c.localStartPageError;u&&n(u),t(c)}catch(e){if(l!==a.current||s.current)return;let t=e instanceof Error?e.message:String(e);i(e=>({state:`unavailable`,repository:e?.repository,branch:e?.branch,hubOrigin:e?.hubOrigin,message:K.hubStatusUnavailable(t)})),n(t)}finally{--o.current}},[e,t,n]),l=(0,V.useCallback)(async t=>{s.current=!0,a.current+=1,i(null);try{await $(`/api/hub/origin`,e,{method:`POST`,body:JSON.stringify({origin:t})})}finally{s.current=!1,await c()}},[e,c]);(0,V.useEffect)(()=>{let e=window.setTimeout(()=>void c(`open`),0),t=window.setInterval(()=>void c(void 0,!0),15e3);function n(){c(`interaction`)}return window.addEventListener(`focus`,n),()=>{a.current+=1,window.clearTimeout(e),window.clearInterval(t),window.removeEventListener(`focus`,n)}},[c]);async function u(){let t=await $(`/api/hub/discovery`,e,{method:`POST`,body:`{}`});if(t.discovery?.state!==`valid`||!t.discovery.origin)throw Error(t.discovery?.message||K.resetHubUnavailable);return await c(),t.discovery.origin}return{status:r,refresh:c,select:l,reset:u}}function nr({prototypeUrl:e,previewUrl:t,shellRef:n,cancelClick:r}){let[{key:i,ref:a},o]=(0,V.useState)(()=>({key:0,ref:(0,V.createRef)()})),[s,c]=(0,V.useState)({input:e,url:e}),[l,u]=(0,V.useState)({input:e,entries:[e],index:0}),[d,f]=(0,V.useState)(()=>window.matchMedia?.(`(prefers-color-scheme: dark)`)?.matches?`dark`:`light`),[p,m]=(0,V.useState)(null),h=(0,V.useRef)(null),g=l.input===e?l:{input:e,entries:[e],index:0},_=g.entries[g.index],v=(0,V.useCallback)(()=>r.current?.(),[r]),y=(0,V.useCallback)(t=>{if(new URL(t).origin!==new URL(e).origin)throw Error(K.startPageOrigin);u(e=>{let n=[...e.entries];return n[e.index]=t,{...e,entries:n}})},[e]),b=(0,V.useCallback)(t=>{if(h.current===e)return;h.current=e;let n=new URL(e),r=t.state===`connected`&&(t.prototype?.startPageSet??t.prototype?.startPage!==void 0)?t.prototype?.startPage:t.localStartPage;if(n.pathname!==`/`||n.search||n.hash||!r)return;let i=new URL(r,n);if(i.origin!==n.origin)throw Error(K.startPageOrigin);c({input:e,url:i.href}),u({input:e,entries:[i.href],index:0})},[e]);function x(){v(),m(null),c({input:e,url:_}),o(e=>({key:e.key+1,ref:(0,V.createRef)()}))}function S(t){t===_?x():(u(n=>{let r=n.input===e?n:g;return{...r,entries:[...r.entries.slice(0,r.index+1),t],index:r.index+1}}),c({input:e,url:t}))}function C(t){let n=g.entries[t];n&&(u({...g,index:t}),c({input:e,url:n}))}let w=(0,V.useCallback)((t,n=!1)=>{m(t);let r=new URL(e);r.pathname=t.pathname,r.search=t.search,r.hash=t.hash,u(t=>{let i=t.input===e?t:{input:e,entries:[e],index:0},a=new URL(i.entries[i.index]),o=[...a.searchParams].filter(([e])=>e.startsWith(`rc.`));for(let e of[r,a])for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);if(a.pathname===r.pathname&&a.searchParams.toString()===r.searchParams.toString()&&a.hash===r.hash)return i;for(let[e,t]of o)r.searchParams.append(e,t);let s=r.href;if(n){let e=[...i.entries];return e[i.index]=s,{...i,entries:e}}return{...i,entries:[...i.entries.slice(0,i.index+1),s],index:i.index+1}})},[e]);(0,V.useEffect)(()=>{let e=a.current;if(!e)return;function t(){v(),m(null)}return e.addEventListener(`load`,t),()=>{v(),e.removeEventListener(`load`,t)}},[v,a]),(0,V.useEffect)(()=>{let r=a.current;if(!r)return;let i=new URL(t??e).origin,o=crypto.randomUUID();function s(){let e=n.current?.closest(`.canvas-base`);e&&r?.contentWindow?.postMessage({type:`replica:canvas:theme`,nonce:o,accent:window.getComputedStyle(e).getPropertyValue(`--hub-accent`).trim()},i)}function c(e){e.source===r?.contentWindow&&e.origin===i&&e.data?.type===`replica:canvas:ready`&&s()}return r.addEventListener(`load`,s),window.addEventListener(`message`,c),s(),()=>{r.removeEventListener(`load`,s),window.removeEventListener(`message`,c)}},[d,e,t,a,n]);let T=new URL(s.input===e?s.url:e);if(t){let e=new URL(t);T.protocol=e.protocol,T.host=e.host}return{frameRef:a,frameKey:i,source:T.href,navigation:g,address:_,replaceAddress:y,appearance:d,setAppearance:f,liveRoute:p,initialize:b,reportRoute:w,reload:x,navigate:S,travel:C}}function rr(e){let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(``),a=(0,V.useRef)(null),o=(0,V.useRef)(0),s=(0,V.useRef)(0),c=(0,V.useCallback)(async(t,r=!1)=>{if(r&&s.current>0)return;s.current+=1;let c=++o.current;try{let r=await $(t?`/api/refresh`:`/api/state`,e,t?{method:`POST`,body:`{}`}:{});if(c!==o.current)return;a.current=r,n(r),i(``)}catch(e){if(c!==o.current)return;n(t=>t&&{...t,stats:{...t.stats,remoteBranch:{state:`unknown`,repository:t.stats.repository||null,branch:t.stats.branch||null,commitSha:t.stats.commitSha||null,error:ir(e)}}}),i(ir(e))}finally{--s.current}},[e]);return(0,V.useEffect)(()=>{let e=window.setTimeout(()=>void c(!0),0),t=window.setInterval(()=>{let e=a.current?.publishStatus?.state,t=a.current?.publishRequest,n=e===`requested`||e===`in_progress`||t?.state===`requested`||!!t?.requestedAt&&(e===`not_published`||e===`unavailable`);c(n,!0)},15e3);function n(){c(!0)}return window.addEventListener(`focus`,n),()=>{o.current+=1,window.clearTimeout(e),window.clearInterval(t),window.removeEventListener(`focus`,n)}},[c]),{state:t,error:r,setError:i,refresh:c}}function ir(e){return e instanceof Error?e.message:String(e)}function ar({token:e,enabled:t,repository:n,branch:r,commitSha:i,publicationRevision:a}){let o=`${n}/${r}/${i}/${a}`,[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(!1),p=(0,V.useRef)(null),m=(0,V.useRef)(0),h=t&&s?.identity===o?s:null,g=(0,V.useCallback)(async()=>{if(!t)return;let i=++m.current;u(!0);try{if(await p.current,i!==m.current)return;let t=await $(`/api/publish/prepare`,e,{method:`POST`,body:`{}`});if(i!==m.current)return;if(t.target.repository!==n||t.target.branch!==r)throw Error(q.preferenceTargetChanged);if(typeof t.remember!=`boolean`)throw Error(q.invalidPreference);c({identity:o,preparation:t,error:``})}catch(e){i===m.current&&c({identity:o,preparation:null,error:e instanceof Error?e.message:String(e)})}finally{i===m.current&&u(!1)}},[t,e,n,r,o]);(0,V.useEffect)(()=>{let e=window.setTimeout(()=>void g(),0);return()=>{m.current+=1,window.clearTimeout(e)}},[g]);async function _(n){if(!t||!h?.preparation||l||p.current)return;f(!0);let r=m.current,i=h.preparation,a=(async()=>{try{if((await $(`/api/publish/preference`,e,{method:`POST`,body:JSON.stringify({target:i.target,remember:n})})).remember!==n)throw Error(q.invalidPreference);r===m.current&&c({identity:o,preparation:{...i,remember:n},error:``})}catch(e){r===m.current&&c({identity:o,preparation:i,error:e instanceof Error?e.message:String(e)})}})();p.current=a;try{await a}finally{p.current=null,f(!1)}}return{remember:h?.preparation?.remember??null,loading:l||!h,saving:d,error:h?.error||``,save:_,retry:g}}function or(e,t,n){let r=n?.included,i=n?.error,a=n?.revision,o=(0,V.useMemo)(()=>{if(r!==void 0)return{identity:e,revision:a,included:r,error:i??``,pending:!1};let t=!1,n=``;if(e)try{let n=localStorage.getItem(`replica:share-controls:v1:${e}`);if(n!==null&&n!==`true`&&n!==`false`)throw Error(`Invalid saved share preference.`);t=n===`true`}catch{n=`The share preference could not be read. Control settings are off by default.`}return{identity:e,revision:a,included:t,error:n,pending:!1}},[e,a,r,i]),[s,c]=(0,V.useState)(o),l=s.identity===e&&s.revision===a?s:o,u=``,d=``;if(l.included)try{u=Te(t)}catch(e){d=e instanceof Error?e.message:`Control settings could not be shared.`}return{included:l.included,query:u,error:d||l.error,blocked:!!d,...n?{pending:l.pending}:{},onChange:t=>{if(n){c({identity:e,revision:a,included:t,error:``,pending:!0});function r(n){c(r=>r.identity===e&&r.revision===a&&r.included===t?{...r,error:n,pending:!1}:r)}n.onChange(t).then(()=>r(``),e=>r(e instanceof Error?e.message:`This preference could not be saved. It will only apply while this page is open.`));return}let r=``;if(e)try{localStorage.setItem(`replica:share-controls:v1:${e}`,String(t))}catch{r=`This preference could not be saved. It will only apply while this page is open.`}c({identity:e,revision:a,included:t,error:r,pending:!1})}}}function sr({token:e,state:t,hubStatus:n}){let[r,i]=(0,V.useState)(null),a=!!(r&&(r.stale||r.repository!==void 0&&r.repository!==t?.stats.repository||r.branch!==void 0&&r.branch!==t?.stats.branch||n?.hubOrigin!==void 0&&r.hubOrigin!==void 0&&r.hubOrigin!==n.hubOrigin||r.token!==e));(0,V.useEffect)(()=>{if(!r||r.stale)return;let e=r.repository??t?.stats.repository,o=r.branch??t?.stats.branch,s=r.hubOrigin??n?.hubOrigin;if(!a&&e===r.repository&&o===r.branch&&s===r.hubOrigin)return;let c=window.setTimeout(()=>{i(t=>t&&{...t,repository:e,branch:o,hubOrigin:s,stale:a,connecting:!a&&t.connecting})},0);return()=>window.clearTimeout(c)},[r,a,t?.stats.repository,t?.stats.branch,n?.hubOrigin]);function o(){i({repository:t?.stats.repository,branch:t?.stats.branch,hubOrigin:n?.hubOrigin,token:e,connecting:!1,stale:!1})}function s(e){i(t=>t&&{...t,connecting:e})}return{intent:r,targetChanged:a,begin:o,close:()=>i(null),setConnecting:s}}var cr={open:!1,context:null,links:[],loading:!1,busy:!1,stale:!0,error:``,notice:``,created:null};function lr({token:e,hubStatus:t,prototypeState:n}){let[r,i]=(0,V.useState)(cr),a=(0,V.useRef)(r);a.current=r;let o=(0,V.useRef)(0),s=(0,V.useRef)(!1),c=(0,V.useRef)(!1),l=(0,V.useRef)(!1),u=(0,V.useRef)(!1),d=(0,V.useRef)(null),f=`${t?.hubOrigin}/${t?.repository}/${t?.branch}/${t?.state}`,p=(0,V.useRef)(f);p.current=f;let m=(0,V.useCallback)(()=>{!u.current||s.current||c.current||l.current||!d.current||(u.current=!1,d.current())},[]);(0,V.useLayoutEffect)(()=>{o.current+=1,i(e=>e.open?{...cr,open:!0,error:J.stale}:cr)},[f,e]),(0,V.useEffect)(()=>()=>{o.current+=1,u.current=!1},[]),(0,V.useEffect)(()=>{let e=t?.prototype;e&&e.canManageShareLinks!==!0&&a.current.context?.prototype.canManageShareLinks===!0&&(o.current+=1,i(t=>t.open&&t.context?.prototype.id===e.id?{...cr,open:!0,stale:!1,context:{...t.context,prototype:{...t.context.prototype,canManageShareLinks:e.canManageShareLinks}}}:t))},[t?.prototype]),(0,V.useEffect)(()=>{t?.prototype?.publicSharingEnabled===!1&&(o.current+=1,i(e=>e.open?{...cr,open:!0,sharingDisabled:!0,error:J.disabled,context:e.context?{...e.context,prototype:{...e.context.prototype,publicSharingEnabled:!1}}:null}:cr))},[t?.prototype?.publicSharingEnabled]);let h=(0,V.useCallback)((t,n)=>$(`/api/hub/share-links/${t}`,e,{method:`POST`,body:JSON.stringify(n)}),[e]),g=(0,V.useCallback)(e=>{e instanceof Error&&`code`in e&&(e.code===`public_sharing_disabled`||e.code===`public_sharing_changed`||e.code===`creator_access_changed`)&&(o.current+=1,i(t=>({...t,busy:!1,loading:!1,stale:!0,sharingDisabled:e.code===`public_sharing_disabled`,links:[],created:null,authorization:void 0})))},[]),_=(0,V.useCallback)(async(e=a.current.context)=>{if(!e||!e.prototype.canManageShareLinks||e.prototype.publicSharingEnabled===!1||c.current)return;c.current=!0;let t=o.current,n=p.current;i(e=>({...e,loading:!0,stale:!0,error:``}));try{let r=new Map,a=new Set,s=null;do{let i=await h(`list`,{target:e.target,...s?{cursor:s}:{}});if(t!==o.current||n!==p.current)return;for(let e of i.shareLinks)r.set(e.id,e);if(s=i.nextCursor,s){if(a.has(s))throw Error(J.paginationFailed);a.add(s)}}while(s);i(e=>({...e,links:[...r.values()],created:e.created?r.get(e.created.id)??null:null,loading:u.current,stale:u.current,sharingDisabled:!1}))}catch(e){t===o.current&&n===p.current&&(i(t=>({...t,loading:!1,stale:!0,error:e instanceof Error?e.message:J.failed})),g(e))}finally{c.current=!1,m()}},[h,m,g]),v=(0,V.useCallback)(async()=>{if(s.current||l.current||c.current){u.current=!0,i(e=>({...e,open:!0,stale:!0,loading:!0}));return}l.current=!0;let e=++o.current,r=p.current;i({...cr,open:!0,loading:!0});let a=t?.repository===n?.stats.repository&&t?.branch===n?.stats.branch,d=``;if(!t||[`disconnected`,`pairing`,`unconfigured`].includes(t.state)?d=J.disconnected:[`unavailable`,`denied`].includes(t.state)?d=J.unavailable:(t.state!==`connected`||!a)&&(d=J.branch),d)i({...cr,open:!0,error:d}),l.current=!1;else try{let t=await h(`context`,{});if(e!==o.current||r!==p.current)return;i(e=>({...e,context:t,loading:!1,stale:t.prototype.canManageShareLinks===!0})),await _(t)}catch(t){e===o.current&&r===p.current&&i(e=>({...e,loading:!1,error:t instanceof Error?t.message:J.failed}))}finally{l.current=!1,m()}},[t,n,_,h,m]);d.current=v;let y=(0,V.useCallback)(async(e,t)=>{let n=a.current;if(s.current||l.current||c.current||u.current||n.stale||!n.context||n.context.prototype.canManageShareLinks!==!0||n.sharingDisabled||n.context.prototype.publicSharingEnabled===!1)return!1;s.current=!0;let r=o.current;i(e=>({...e,busy:!0,error:``,notice:``}));try{let a=await h(e,{target:n.context.target,...t});return r===o.current&&(i(n=>({...n,notice:e===`delete`?J.deleted:``,authorization:void 0,created:`id`in a?a:e===`delete`&&`id`in t&&n.created?.id===t.id?null:n.created,links:e===`delete`&&`id`in t?n.links.filter(e=>e.id!==t.id):n.links})),await _(n.context),!0)}catch(e){if(r!==o.current)return!1;let t=e instanceof Error&&`code`in e&&e.code===`fresh_authorization_required`&&`authorization`in e&&e.authorization&&typeof e.authorization==`object`&&`url`in e.authorization&&typeof e.authorization.url==`string`&&`expiresAt`in e.authorization&&typeof e.authorization.expiresAt==`string`?{url:e.authorization.url,expiresAt:e.authorization.expiresAt}:void 0,n=e instanceof Error&&(!(`statusCode`in e)||`code`in e&&e.code===`share_delivery_unknown`);return i(r=>({...r,stale:!0,authorization:t,error:n?J.unknown:e instanceof Error?e.message:J.failed})),g(e),!1}finally{s.current=!1,r===o.current&&i(e=>({...e,busy:!1})),m()}},[_,h,m,g]),b=(0,V.useCallback)(async e=>{let t=a.current;if(!t.context||l.current||c.current||u.current)throw Error(J.stale);let n=o.current,r=await h(`controls-preference`,{target:t.context.target,included:e});if(n!==o.current)throw Error(J.stale);if(r.included!==e)throw Error(`The share preference could not be saved.`)},[h]),x=(0,V.useCallback)(async(e,t)=>{let n=a.current;if(!n.context||n.stale||l.current||c.current||u.current)return;let r=o.current;try{await h(`open`,{target:n.context.target,id:e,...t?{controlsQuery:t}:{}})}catch(e){r===o.current&&(i(t=>({...t,error:e instanceof Error?e.message:J.failed})),g(e))}},[h,g]),S=(0,V.useCallback)(async()=>{let e=a.current;if(!e.context||!e.authorization||e.busy)return;let t=o.current;try{await h(`authorize`,{target:e.context.target}),t===o.current&&i(e=>({...e,notice:J.authorizationRetry}))}catch(e){t===o.current&&(i(t=>({...t,error:e instanceof Error?e.message:J.failed})),g(e))}},[h,g]);return(0,V.useEffect)(()=>{if(!r.open||!r.context)return;function e(){s.current||_()}let t=window.setInterval(e,3e4);return window.addEventListener(`focus`,e),()=>{window.clearInterval(t),window.removeEventListener(`focus`,e)}},[r.open,r.context,_]),{state:r,open:v,close:()=>{u.current=!1,i(e=>({...e,open:!1}))},refresh:()=>r.context&&!r.sharingDisabled&&r.context.prototype.publicSharingEnabled!==!1?_():v(),create:(e,t)=>y(`create`,{label:e,expiration:t,buildNumber:r.context?.prototype.build?.number}),remove:e=>y(`delete`,{id:e}),openLink:x,setControlPreference:b,authorize:S}}function ur({config:e}){let t=(0,V.useRef)(null),n=(0,V.useRef)(null),r=(0,V.useRef)(null),i=(0,V.useRef)(null),a=(0,V.useRef)(null),o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useRef)(null),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)({position:null,collapsed:!1,collapsedGroups:{}}),[h,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(!1),y=(0,V.useCallback)(()=>{g(!1),o.current?.focus()},[]),{frameRef:b,frameKey:x,source:S,navigation:C,address:w,replaceAddress:T,appearance:E,setAppearance:D,liveRoute:O,initialize:k,reportRoute:A,reload:j,navigate:M,travel:ee}=nr({prototypeUrl:e.prototypeUrl,previewUrl:e.previewUrl,shellRef:t,cancelClick:u}),N=$n({...e,frameRef:b,address:w,replaceAddress:T}),P=N.state;Hn({...e,frameRef:b,addressRef:r,appearance:E,navigation:C,liveRoute:O,cancelClick:u,reload:j,controlsConnection:N.connection});let{state:F,error:I,setError:L,refresh:R}=rr(e.token),z=tr({token:e.token,onStatus:k,onError:L}),te=er({token:e.token,status:z.status,onStatusChange:z.refresh,onSelectHub:z.select}),B=lr({token:e.token,hubStatus:z.status,prototypeState:F}),ne=sr({token:e.token,state:F,hubStatus:z.status}),re=ar({token:e.token,enabled:h&&z.status?.state===`connected`&&z.status.prototype?.registered===!0&&!!z.status.prototype.build&&z.status.repository===F?.stats.repository&&z.status.branch===F?.stats.branch,repository:F?.stats.repository,branch:F?.stats.branch,commitSha:F?.stats.commitSha,publicationRevision:F?.publishRequest?.requestedAt}),ie=Gn({token:e.token,state:F,hubStatus:z.status,error:I,setError:L,refresh:R,refreshHub:z.refresh,preferenceSaving:re.saving}),ae=In(F,z.status,ie.publication),oe=B.state.context,se=or(oe?`${oe.hubOrigin}:${oe.prototype.repositoryId}:${oe.prototype.id}`:void 0,N.connection?.getControlValues()??{},{included:oe?.controlSettingsIncluded??!1,error:oe?.controlSettingsError,revision:oe?.target,onChange:B.setControlPreference});(0,V.useLayoutEffect)(()=>{document.body.classList.remove(`renderer-loading`);let e=t.current,r=n.current;if(!e||!r)return;function i(){let t=r?.getBoundingClientRect().height;t&&e?.style.setProperty(`--canvas-toolbar-height`,`${t}px`)}let a=new ResizeObserver(i);return a.observe(r),i(),()=>a.disconnect()},[]);function ce(){te.close(),ae.kind===`ready`?B.open():ne.begin()}return(0,U.jsxs)(H.ThemeProvider,{colorMode:E,className:`canvas-base`,children:[(0,U.jsxs)(`main`,{ref:t,className:`canvas-shell${B.state.open?` canvas-shell--inactive`:``}`,inert:B.state.open,"aria-hidden":B.state.open?!0:void 0,children:[(0,U.jsx)(Ne,{address:w,addressRef:r,canGoBack:C.index>0,canGoForward:C.indexee(C.index-1),onForward:()=>ee(C.index+1),onNavigate:M,onOpenTab:async()=>{await $(`/api/prototype/open`,e.token,{method:`POST`,body:JSON.stringify({url:w})})},onReload:j}),(0,U.jsx)(Rn,{toolbarRef:n,config:e,state:ie.presentedState,prototypeName:z.status?.state===`connected`&&z.status.prototype?.name||void 0,publishing:ie.busy,publication:ie.publication,publishButtonRef:i,hubButtonRef:o,titleButtonRef:c,onBuildDetails:()=>v(!0),controlsButtonRef:l,controlsOpen:d,onControls:()=>f(!d),onPublish:()=>void ie.publish(),onShare:ce,shareButtonRef:a,hubOpen:h,onHub:()=>{g(!h),z.refresh(`interaction`)}}),(0,U.jsx)(`iframe`,{ref:b,className:`prototype-frame`,title:K.prototypeFrameTitle(e.name),src:S,style:{colorScheme:E,backgroundColor:`var(--hub-canvas-default)`}},x),(0,U.jsx)(Fn,{config:e,frameRef:b,onRouteChange:A,status:z.status,onStatusChange:z.refresh,onSelectHub:z.select,onConnect:te.showAndConnect,onDisconnected:te.show,connectionButtonRef:s,connecting:te.connecting,publication:ie.publication,publicationBusy:ie.busy,dirty:F?.stats.workingTree===`changed`,onPublish:()=>void ie.publish(),onRetryPublication:()=>void ie.retry(),publishPreference:re,open:h,onClose:y}),d&&N.connection&&P?(0,U.jsx)($e,{state:P,connection:N.connection,layout:p,onLayoutChange:m,diagnosisTarget:w,onDiagnose:()=>$(`/api/controls/diagnose`,e.token,{method:`POST`,body:JSON.stringify({status:P.status,runtimeAvailable:P.runtimeAvailable,reconnectRequired:P.reconnectRequired===!0,hasError:!!P.error||Bn(P,P.loading,w).controls.some(e=>e.visible&&!!e.error),hasStorageError:!!P.storageError,previewUrl:w})})}):null]}),(0,U.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`visually-hidden`,children:I||ie.notice}),(0,U.jsx)(Me,{hub:z,connection:te,publication:ie,sharing:B,shareIntent:ne,controlSettings:se,readiness:ae,state:F,hubOpen:h,buildDetailsOpen:_,onCloseBuildDetails:()=>v(!1),shareButtonRef:a,hubButtonRef:o,connectionButtonRef:s,publishButtonRef:i,titleButtonRef:c})]})}var dr=document.querySelector(`#root`);if(!dr)throw Error(`Replica prototype renderer root is missing.`);(0,se.createRoot)(dr).render((0,U.jsx)(ur,{config:window.__REPLICA_CANVAS__})); \ No newline at end of file diff --git a/.github/extensions/replica-prototype/capture-review-revision/index.mjs b/.github/extensions/replica-prototype/capture-review-revision/index.mjs new file mode 100644 index 00000000..b1c03826 --- /dev/null +++ b/.github/extensions/replica-prototype/capture-review-revision/index.mjs @@ -0,0 +1,92 @@ +import { mkdtemp, rm } from "node:fs/promises" +import os from "node:os" +import path from "node:path" + +import { runCommand } from "../run-command/index.mjs" + +export async function captureReviewRevision(context) { + const directory = await mkdtemp(path.join(os.tmpdir(), "replica-review-")) + const env = { ...process.env, GIT_INDEX_FILE: path.join(directory, "index") } + const config = ["-c", "core.fsmonitor=false", "-c", "core.hooksPath=/dev/null"] + async function git(args, optional = false) { + const result = await runCommand("git", [...config, ...args], context.repositoryPath, { env }) + if (!result.ok && !(optional && result.exitCode === 1)) + throw new Error(`Could not capture the local review revision: ${result.error}`) + return result + } + try { + // Snapshotting must not execute repository-defined clean filters or filter processes. + const filters = await git( + ["config", "--name-only", "--get-regexp", "^filter\\..*\\.(clean|process|required)$"], + true, + ) + for (const key of filters.stdout.trim().split("\n").filter(Boolean)) { + config.push("-c", `${key}=${key.endsWith(".required") ? "false" : ""}`) + } + const head = (await git(["rev-parse", "HEAD"])).stdout.trim() + const branch = (await git(["branch", "--show-current"])).stdout.trim() + const headTree = (await git(["rev-parse", "HEAD^{tree}"])).stdout.trim() + if (!/^[0-9a-f]{40}$/.test(head) || !branch) + throw new Error("Open a committed, named branch before commenting.") + await git(["read-tree", head]) + const files = ( + await git(["ls-files", "-z", "--cached", "--others", "--exclude-standard"]) + ).stdout + .split("\0") + .filter(Boolean) + for (let offset = 0; offset < files.length; offset += 100) { + const attributes = ( + await git([ + "--literal-pathspecs", + "check-attr", + "-z", + "filter", + "--", + ...files.slice(offset, offset + 100), + ]) + ).stdout.split("\0") + for (let index = 2; index < attributes.length; index += 3) { + if (!["unspecified", "unset"].includes(attributes[index])) + throw new Error("Local review revisions do not support Git clean filters.") + } + } + const submodules = await git([ + "diff", + "--no-ext-diff", + "--no-textconv", + "--ignore-submodules=none", + "--name-only", + "-z", + "--diff-filter=M", + head, + "--", + ]) + const changedPaths = new Set(submodules.stdout.split("\0")) + const entries = (await git(["ls-files", "--stage", "-z"])).stdout + if ( + entries + .split("\0") + .some( + (entry) => + entry.startsWith("160000 ") && changedPaths.has(entry.slice(entry.indexOf("\t") + 1)), + ) + ) + throw new Error("Commit or discard submodule changes before commenting on this preview.") + await git(["add", "--all", "--", "."]) + const treeSha = (await git(["write-tree"])).stdout.trim() + const currentHead = (await git(["rev-parse", "HEAD"])).stdout.trim() + const currentBranch = (await git(["branch", "--show-current"])).stdout.trim() + const remaining = await git( + ["diff", "--no-ext-diff", "--no-textconv", "--quiet", "--ignore-submodules=none"], + true, + ) + const untracked = (await git(["ls-files", "--others", "--exclude-standard"])).stdout + if (currentHead !== head || currentBranch !== branch || !remaining.ok || untracked) + throw new Error("The checkout changed while capturing this review revision. Try again.") + if (!/^[0-9a-f]{40}$/.test(treeSha)) + throw new Error("Could not verify the local review source tree.") + return { treeSha, commitSha: head, clean: treeSha === headTree } + } finally { + await rm(directory, { recursive: true, force: true }) + } +} diff --git a/.github/extensions/replica-prototype/capture-review-revision/index.test.mjs b/.github/extensions/replica-prototype/capture-review-revision/index.test.mjs new file mode 100644 index 00000000..80d7b71d --- /dev/null +++ b/.github/extensions/replica-prototype/capture-review-revision/index.test.mjs @@ -0,0 +1,142 @@ +import assert from "node:assert/strict" +import { execFileSync } from "node:child_process" +import { randomUUID } from "node:crypto" +import { mkdir, readFile, rm, writeFile } from "node:fs/promises" +import path from "node:path" +import { describe, it } from "node:test" + +import { captureReviewRevision } from "./index.mjs" + +async function withRepository(run) { + const workspace = path.join(process.cwd(), "storage/replica-extension-tests", randomUUID()) + const repositoryPath = path.join(workspace, "repository") + await mkdir(repositoryPath, { recursive: true }) + function git(...args) { + return execFileSync("git", args, { + cwd: repositoryPath, + encoding: "utf8", + stdio: "pipe", + }).trim() + } + try { + git("init", "-q", "-b", "prototype") + git("config", "user.name", "Replica") + git("config", "user.email", "replica@example.com") + git("config", "commit.gpgsign", "false") + await writeFile(path.join(repositoryPath, "tracked.txt"), "original\n") + await writeFile(path.join(repositoryPath, ".gitignore"), "ignored.txt\n") + git("add", ".") + git("commit", "-qm", "Fixture") + await run({ repositoryPath }, git, workspace) + } finally { + await rm(workspace, { recursive: true, force: true }) + } +} + +describe("captureReviewRevision()", () => { + it("returns the actual HEAD tree and commit for a clean checkout and excludes ignored files", async () => { + await withRepository(async (context, git) => { + await writeFile(path.join(context.repositoryPath, "ignored.txt"), "local secret\n") + + const revision = await captureReviewRevision(context) + + assert.deepEqual(revision, { + treeSha: git("rev-parse", "HEAD^{tree}"), + commitSha: git("rev-parse", "HEAD"), + clean: true, + }) + await writeFile(path.join(context.repositoryPath, "ignored.txt"), "changed secret\n") + assert.deepEqual(await captureReviewRevision(context), revision) + }) + }) + + it("captures working-tree contents rather than staged contents without changing the real index", async () => { + await withRepository(async (context, git) => { + const tracked = path.join(context.repositoryPath, "tracked.txt") + await writeFile(tracked, "staged\n") + git("add", "tracked.txt") + const indexPath = path.join(context.repositoryPath, ".git/index") + const stagedTree = git("write-tree") + const index = await readFile(indexPath) + const stagedRevision = await captureReviewRevision(context) + assert.equal(stagedRevision.treeSha, stagedTree) + assert.equal(stagedRevision.clean, false) + assert.deepEqual(await readFile(indexPath), index) + await writeFile(tracked, "unstaged after staging\n") + + const revision = await captureReviewRevision(context) + + assert.equal(revision.clean, false) + assert.equal(revision.commitSha, git("rev-parse", "HEAD")) + assert.notEqual(revision.treeSha, stagedTree) + assert.notEqual(revision.treeSha, git("rev-parse", "HEAD^{tree}")) + assert.equal(git("show", `${revision.treeSha}:tracked.txt`), "unstaged after staging") + assert.deepEqual(await readFile(indexPath), index) + assert.equal(git("write-tree"), stagedTree) + assert.deepEqual(await captureReviewRevision(context), revision) + }) + }) + + it("includes nonignored untracked files even when Git status hides them", async () => { + await withRepository(async (context, git) => { + git("config", "status.showUntrackedFiles", "no") + const originalTree = git("rev-parse", "HEAD^{tree}") + await writeFile(path.join(context.repositoryPath, "new file.txt"), "new contents\n") + + const revision = await captureReviewRevision(context) + + assert.equal(revision.clean, false) + assert.notEqual(revision.treeSha, originalTree) + assert.equal(git("show", `${revision.treeSha}:new file.txt`), "new contents") + assert.equal(git("diff", "--cached"), "") + await rm(path.join(context.repositoryPath, "new file.txt")) + assert.equal((await captureReviewRevision(context)).treeSha, originalTree) + }) + }) + + it("records tracked deletions without staging them", async () => { + await withRepository(async (context, git) => { + await rm(path.join(context.repositoryPath, "tracked.txt")) + + const revision = await captureReviewRevision(context) + + assert.equal(revision.clean, false) + assert.notEqual(revision.treeSha, git("rev-parse", "HEAD^{tree}")) + assert.equal(git("ls-tree", "--name-only", revision.treeSha, "tracked.txt"), "") + assert.equal(git("diff", "--cached"), "") + }) + }) + + it("rejects dirty submodules instead of claiming their unchanged gitlink identifies the preview", async () => { + await withRepository(async (context, git, workspace) => { + const source = path.join(workspace, "submodule-source") + await mkdir(source) + execFileSync("git", ["init", "-q", source], { stdio: "pipe" }) + await writeFile(path.join(source, "component.txt"), "original\n") + execFileSync("git", ["-C", source, "add", "."], { stdio: "pipe" }) + execFileSync( + "git", + [ + "-C", + source, + "-c", + "user.name=Replica", + "-c", + "user.email=replica@example.com", + "-c", + "commit.gpgsign=false", + "commit", + "-qm", + "Submodule fixture", + ], + { stdio: "pipe" }, + ) + git("-c", "protocol.file.allow=always", "submodule", "add", source, "component") + git("commit", "-qm", "Add submodule") + assert.equal((await captureReviewRevision(context)).clean, true) + await writeFile(path.join(context.repositoryPath, "component/component.txt"), "dirty\n") + + await assert.rejects(() => captureReviewRevision(context), /submodule/i) + }) + }) +}) diff --git a/.github/extensions/replica-prototype/hub-client/authorization.test.mjs b/.github/extensions/replica-prototype/create-hub-client/authorization.test.mjs similarity index 100% rename from .github/extensions/replica-prototype/hub-client/authorization.test.mjs rename to .github/extensions/replica-prototype/create-hub-client/authorization.test.mjs diff --git a/.github/extensions/replica-prototype/hub-client/automatic-registration.test.mjs b/.github/extensions/replica-prototype/create-hub-client/automatic-registration.test.mjs similarity index 100% rename from .github/extensions/replica-prototype/hub-client/automatic-registration.test.mjs rename to .github/extensions/replica-prototype/create-hub-client/automatic-registration.test.mjs diff --git a/.github/extensions/replica-prototype/hub-client/fresh-authorization.test.mjs b/.github/extensions/replica-prototype/create-hub-client/fresh-authorization.test.mjs similarity index 100% rename from .github/extensions/replica-prototype/hub-client/fresh-authorization.test.mjs rename to .github/extensions/replica-prototype/create-hub-client/fresh-authorization.test.mjs diff --git a/.github/extensions/replica-prototype/hub-client/index.mjs b/.github/extensions/replica-prototype/create-hub-client/index.mjs similarity index 96% rename from .github/extensions/replica-prototype/hub-client/index.mjs rename to .github/extensions/replica-prototype/create-hub-client/index.mjs index 91401397..4e894e7e 100644 --- a/.github/extensions/replica-prototype/hub-client/index.mjs +++ b/.github/extensions/replica-prototype/create-hub-client/index.mjs @@ -5,41 +5,7 @@ import path from "node:path" import { readCanvasRepository } from "../read-canvas-repository/index.mjs" import { runCommand } from "../run-command/index.mjs" import { createPrivateStore } from "../private-store/index.mjs" - -export class InvalidHubOrigin extends Error {} - -function parseHubUrl(value, name) { - let origin - try { - origin = new URL(value) - } catch { - throw new InvalidHubOrigin(`${name} must be an HTTP or HTTPS origin without credentials.`) - } - if (!["http:", "https:"].includes(origin.protocol) || origin.username || origin.password) { - throw new InvalidHubOrigin(`${name} must be an HTTP or HTTPS origin without credentials.`) - } - if ( - origin.protocol === "http:" && - origin.hostname !== "localhost" && - origin.hostname !== "127.0.0.1" && - !origin.hostname.endsWith(".localhost") - ) { - throw new InvalidHubOrigin("Remote Replica Hub connections require HTTPS.") - } - return origin -} - -export function normalizeHubOrigin(value, name = "REPLICA_HUB_ORIGIN") { - const origin = parseHubUrl(value, name) - if (origin.pathname !== "/" || origin.search || origin.hash) { - throw new InvalidHubOrigin(`${name} must be an HTTP or HTTPS origin without credentials.`) - } - return origin.origin -} - -export function normalizeSelectedHubOrigin(value) { - return parseHubUrl(value, "Hub URL").origin -} +import { normalizeHubOrigin } from "../normalize-hub-origin/index.mjs" function registrationReason(value) { if (value == null) return undefined @@ -299,6 +265,10 @@ export function createHubClient(context, options = {}) { return { origin: origin.origin, checkout, + async connectionKey(repository) { + const credential = await credentialFor(repository) + return credential ? connectionIdentity(credential) : null + }, async status() { const target = await checkout() if (!target.repository) { @@ -340,7 +310,9 @@ export function createHubClient(context, options = {}) { return { state: "undiscovered", repositoryAuthorized: true, + reviewConnectionId: connectionIdentity(credential), canPublish: connection.canPublish, + viewerLogin: connection.viewerLogin, repository: target.repository, commitSha: target.commitSha, message: "Connected to this repository. Open a named branch for Builds and reviews.", @@ -367,7 +339,9 @@ export function createHubClient(context, options = {}) { return { state: "undiscovered", repositoryAuthorized: true, + reviewConnectionId: connectionIdentity(credential), canPublish: connection.canPublish, + viewerLogin: connection.viewerLogin, repository: target.repository, branch: target.branch, commitSha: target.commitSha, @@ -418,6 +392,7 @@ export function createHubClient(context, options = {}) { return { state: "connected", repositoryAuthorized: true, + reviewConnectionId: connectionIdentity(credential), repository: target.repository, branch: target.branch, commitSha: target.commitSha, diff --git a/.github/extensions/replica-prototype/hub-client/index.test.mjs b/.github/extensions/replica-prototype/create-hub-client/index.test.mjs similarity index 98% rename from .github/extensions/replica-prototype/hub-client/index.test.mjs rename to .github/extensions/replica-prototype/create-hub-client/index.test.mjs index 643b7157..cb134b69 100644 --- a/.github/extensions/replica-prototype/hub-client/index.test.mjs +++ b/.github/extensions/replica-prototype/create-hub-client/index.test.mjs @@ -7,12 +7,11 @@ import path from "node:path" import { describe, it } from "node:test" import { createCanvasContext, currentCanvasContext } from "../create-canvas-context/index.mjs" -import { - createHubClient, - InvalidHubOrigin, - normalizeHubOrigin, - normalizeSelectedHubOrigin, -} from "./index.mjs" +import { InvalidHubOrigin } from "../invalid-hub-origin/index.mjs" +import { normalizeHubOrigin } from "../normalize-hub-origin/index.mjs" +import { normalizeSelectedHubOrigin } from "../normalize-selected-hub-origin/index.mjs" + +import { createHubClient } from "./index.mjs" describe("normalizeSelectedHubOrigin()", () => { it("converts manually selected Hub URLs to origins and preserves ports", () => { diff --git a/.github/extensions/replica-prototype/hub-client/rate-limits.test.mjs b/.github/extensions/replica-prototype/create-hub-client/rate-limits.test.mjs similarity index 100% rename from .github/extensions/replica-prototype/hub-client/rate-limits.test.mjs rename to .github/extensions/replica-prototype/create-hub-client/rate-limits.test.mjs diff --git a/.github/extensions/replica-prototype/hub-client/renewal.test.mjs b/.github/extensions/replica-prototype/create-hub-client/renewal.test.mjs similarity index 100% rename from .github/extensions/replica-prototype/hub-client/renewal.test.mjs rename to .github/extensions/replica-prototype/create-hub-client/renewal.test.mjs diff --git a/.github/extensions/replica-prototype/hub-connection/index.mjs b/.github/extensions/replica-prototype/create-hub-connection/index.mjs similarity index 91% rename from .github/extensions/replica-prototype/hub-connection/index.mjs rename to .github/extensions/replica-prototype/create-hub-connection/index.mjs index ce4133b7..2308a5b8 100644 --- a/.github/extensions/replica-prototype/hub-connection/index.mjs +++ b/.github/extensions/replica-prototype/create-hub-connection/index.mjs @@ -1,9 +1,7 @@ -import { - createHubClient, - InvalidHubOrigin, - normalizeSelectedHubOrigin, -} from "../hub-client/index.mjs" -import { createHubOriginStore } from "../hub-origin-store/index.mjs" +import { createHubClient } from "../create-hub-client/index.mjs" +import { InvalidHubOrigin } from "../invalid-hub-origin/index.mjs" +import { normalizeSelectedHubOrigin } from "../normalize-selected-hub-origin/index.mjs" +import { createHubOriginStore } from "../create-hub-origin-store/index.mjs" import { discoverHub } from "../discover-hub/index.mjs" import { readCanvasRepository } from "../read-canvas-repository/index.mjs" diff --git a/.github/extensions/replica-prototype/hub-origin-store/index.mjs b/.github/extensions/replica-prototype/create-hub-origin-store/index.mjs similarity index 95% rename from .github/extensions/replica-prototype/hub-origin-store/index.mjs rename to .github/extensions/replica-prototype/create-hub-origin-store/index.mjs index 88b3c3a6..a4fced73 100644 --- a/.github/extensions/replica-prototype/hub-origin-store/index.mjs +++ b/.github/extensions/replica-prototype/create-hub-origin-store/index.mjs @@ -2,7 +2,7 @@ import { createHash } from "node:crypto" import os from "node:os" import path from "node:path" -import { normalizeHubOrigin } from "../hub-client/index.mjs" +import { normalizeHubOrigin } from "../normalize-hub-origin/index.mjs" import { createPrivateStore } from "../private-store/index.mjs" export function createHubOriginStore(options = {}) { diff --git a/.github/extensions/replica-prototype/hub-origin-store/index.test.mjs b/.github/extensions/replica-prototype/create-hub-origin-store/index.test.mjs similarity index 95% rename from .github/extensions/replica-prototype/hub-origin-store/index.test.mjs rename to .github/extensions/replica-prototype/create-hub-origin-store/index.test.mjs index 3ec18b36..f84e070f 100644 --- a/.github/extensions/replica-prototype/hub-origin-store/index.test.mjs +++ b/.github/extensions/replica-prototype/create-hub-origin-store/index.test.mjs @@ -4,7 +4,7 @@ import { readdir, readFile, rm, writeFile } from "node:fs/promises" import path from "node:path" import { describe, it } from "node:test" -import { InvalidHubOrigin } from "../hub-client/index.mjs" +import { InvalidHubOrigin } from "../invalid-hub-origin/index.mjs" import { createHubOriginStore } from "./index.mjs" describe("createHubOriginStore()", () => { diff --git a/.github/extensions/replica-prototype/recall-learnings/index.mjs b/.github/extensions/replica-prototype/create-learnings-hook/index.mjs similarity index 98% rename from .github/extensions/replica-prototype/recall-learnings/index.mjs rename to .github/extensions/replica-prototype/create-learnings-hook/index.mjs index 1d9fd6ef..c3e6b81f 100644 --- a/.github/extensions/replica-prototype/recall-learnings/index.mjs +++ b/.github/extensions/replica-prototype/create-learnings-hook/index.mjs @@ -1,7 +1,7 @@ import path from "node:path" -import { createHubClient } from "../hub-client/index.mjs" -import { createHubOriginStore } from "../hub-origin-store/index.mjs" +import { createHubClient } from "../create-hub-client/index.mjs" +import { createHubOriginStore } from "../create-hub-origin-store/index.mjs" import { readCanvasRepository } from "../read-canvas-repository/index.mjs" const TIMEOUT_MS = 3_000 diff --git a/.github/extensions/replica-prototype/recall-learnings/index.test.mjs b/.github/extensions/replica-prototype/create-learnings-hook/index.test.mjs similarity index 100% rename from .github/extensions/replica-prototype/recall-learnings/index.test.mjs rename to .github/extensions/replica-prototype/create-learnings-hook/index.test.mjs diff --git a/.github/extensions/replica-prototype/create-local-review-comments/index.mjs b/.github/extensions/replica-prototype/create-local-review-comments/index.mjs new file mode 100644 index 00000000..d237c0f5 --- /dev/null +++ b/.github/extensions/replica-prototype/create-local-review-comments/index.mjs @@ -0,0 +1,219 @@ +import { createHash, randomBytes } from "node:crypto" +import os from "node:os" +import path from "node:path" +import { isDeepStrictEqual } from "node:util" + +import { createPrivateStore } from "../private-store/index.mjs" +import { runCommand } from "../run-command/index.mjs" + +export function createLocalReviewComments(context, options = {}) { + const store = createPrivateStore( + options.directory || path.join(os.homedir(), ".config", "replica", "canvas", "local-comments"), + ) + function filename(scope) { + if (!scope.hubOrigin || !scope.repository || !scope.branch || !scope.viewerLogin) + throw new Error("Connect to a named branch before saving local comments.") + return `${createHash("sha256") + .update( + JSON.stringify([ + context.repositoryPath, + scope.hubOrigin, + scope.repository, + scope.branch, + scope.viewerLogin, + ]), + ) + .digest("hex")}.json` + } + function validateBody(body) { + if (typeof body !== "string" || !body.trim() || Buffer.byteLength(body) > 10_000) + throw Object.assign(new Error("Comments must contain between 1 and 10000 bytes."), { + statusCode: 422, + }) + return body.trim() + } + async function entries(scope) { + return (await store.read(filename(scope))) || [] + } + async function mutate(scope, action) { + const file = filename(scope) + return store.lock(file, async () => { + const drafts = await entries(scope) + const result = await action(drafts) + await store.write(file, drafts) + return result + }) + } + function editable(drafts, id, discarding = false) { + const draft = drafts.find((entry) => entry.comment.id === Number(id)) + if (!draft) + throw Object.assign(new Error("Local comment not found."), { + statusCode: 404, + }) + if (draft.sendingAt && !discarding) + throw new Error("Check Hub before changing this comment: its upload could not be confirmed.") + return draft + } + return { + async list(scope) { + return (await entries(scope)).map((entry) => ({ + ...entry.comment, + viewerCanEdit: !entry.sendingAt, + })) + }, + async create(scope, revision, attributes) { + const body = validateBody(attributes.body) + if ( + !Number.isSafeInteger(revision.id) || + revision.id < 1 || + !/^[0-9a-f]{40}$/.test(revision.treeSha) || + !attributes.anchor || + !["element", "area"].includes(attributes.anchor.kind) + ) + throw Object.assign(new Error("Select a valid local preview target."), { + statusCode: 422, + }) + return mutate(scope, (drafts) => { + const now = new Date().toISOString() + const comment = { + id: 2 ** 48 + randomBytes(6).readUIntBE(0, 6), + kind: "root", + body, + anchor: attributes.anchor, + buildNumber: null, + buildPath: null, + draftRevisionId: revision.id, + createdAt: now, + updatedAt: now, + editedAt: null, + deletedAt: null, + author: { login: scope.viewerLogin, name: null, avatarUrl: null }, + viewerCanEdit: true, + viewerCanDelete: true, + reactions: [], + resolvedAt: null, + resolvedBy: null, + activityVersion: 1, + viewerLastSeenActivityVersion: 1, + } + drafts.push({ + treeSha: revision.treeSha, + prototypeId: revision.prototypeId ?? null, + comment, + }) + return comment + }) + }, + async update(scope, id, body) { + const text = validateBody(body) + return mutate(scope, (drafts) => { + const draft = editable(drafts, id) + const now = new Date().toISOString() + draft.comment = { + ...draft.comment, + body: text, + editedAt: now, + updatedAt: now, + } + return draft.comment + }) + }, + async remove(scope, id) { + return mutate(scope, (drafts) => { + const draft = editable(drafts, id, true) + drafts.splice(drafts.indexOf(draft), 1) + return { + ...draft.comment, + body: null, + deletedAt: new Date().toISOString(), + } + }) + }, + async sync(scope, build, hub) { + if (!(await entries(scope)).length) return + if (!/^[0-9a-f]{40}$/.test(build.commitSha)) + throw new Error("Hub returned an invalid Build commit.") + if (!Number.isFinite(Date.parse(build.publishedAt))) + throw new Error("Hub did not return the Build publication time.") + const tree = await runCommand( + "git", + ["rev-parse", `${build.commitSha}^{tree}`], + context.repositoryPath, + ) + if (!tree.ok) throw new Error("Fetch the published Build commit to sync local comments.") + const file = filename(scope) + await store.lock(file, async () => { + const drafts = await entries(scope) + const base = `/api/canvas/repositories/${build.repositoryId}/prototypes/${build.prototypeId}/review_comments` + for (const draft of [...drafts]) { + if (draft.prototypeId !== null && draft.prototypeId !== build.prototypeId) continue + if (draft.treeSha !== tree.stdout.trim()) continue + if (Date.parse(build.publishedAt) < Date.parse(draft.comment.createdAt)) continue + if (draft.sendingAt) { + const remote = [] + let cursor + do { + const page = await hub.request( + `${base}${cursor ? `?cursor=${encodeURIComponent(cursor)}` : ""}`, + { + expectedTarget: scope, + connectionScope: { identity: scope.connectionId }, + }, + ) + remote.push(...page.comments) + cursor = page.hasMore ? page.nextCursor : null + } while (cursor) + const saved = remote.some( + (comment) => + comment.kind === "root" && + comment.buildNumber === draft.sendingBuildNumber && + comment.author.login === scope.viewerLogin && + comment.body === draft.comment.body && + isDeepStrictEqual(comment.anchor, draft.comment.anchor) && + Date.parse(comment.createdAt) >= Date.parse(draft.sendingAt) - 1000, + ) + if (!saved) + throw new Error( + "A local comment upload could not be confirmed. Check the published review, then discard the local copy before saving it again if needed.", + ) + } else { + draft.sendingAt = new Date().toISOString() + draft.sendingBuildNumber = build.number + await store.write(file, drafts) + try { + const result = await hub.request(base, { + method: "POST", + interactive: true, + expectedTarget: scope, + connectionScope: { identity: scope.connectionId }, + body: { + review_comment: { + build_number: build.number, + body: draft.comment.body, + anchor: draft.comment.anchor, + }, + }, + }) + if ( + !result.comments?.some( + (comment) => comment.kind === "root" && comment.buildNumber === build.number, + ) + ) + throw new Error("Hub did not confirm the saved comment.") + } catch (error) { + // An HTTP rejection confirms no save; transport failures require reconciliation. + if (error.statusCode >= 400 && error.statusCode < 500) { + delete draft.sendingAt + delete draft.sendingBuildNumber + await store.write(file, drafts) + } + throw error + } + } + drafts.splice(drafts.indexOf(draft), 1) + await store.write(file, drafts) + } + }) + }, + } +} diff --git a/.github/extensions/replica-prototype/create-local-review-comments/index.test.mjs b/.github/extensions/replica-prototype/create-local-review-comments/index.test.mjs new file mode 100644 index 00000000..592e28d9 --- /dev/null +++ b/.github/extensions/replica-prototype/create-local-review-comments/index.test.mjs @@ -0,0 +1,307 @@ +import assert from "node:assert/strict" +import { execFileSync } from "node:child_process" +import { writeFile } from "node:fs/promises" +import path from "node:path" +import { describe, it } from "node:test" + +import { createLocalReviewComments } from "./index.mjs" +import { withContext } from "../test-support/with-context/index.mjs" + +function git(context, ...args) { + return execFileSync("git", args, { + cwd: context.repositoryPath, + encoding: "utf8", + }).trim() +} + +function revision(context) { + const treeSha = git(context, "rev-parse", "HEAD^{tree}") + return { id: Number.parseInt(treeSha.slice(0, 12), 16), treeSha } +} + +function localComments(context) { + return createLocalReviewComments(context, { + directory: path.join(context.repositoryPath, ".git", "local-review-comments"), + }) +} + +function build(context) { + return { + repositoryId: 5, + prototypeId: 4, + number: 7, + commitSha: git(context, "rev-parse", "HEAD"), + publishedAt: "2099-01-01T00:00:00Z", + } +} + +function fixture(context) { + return { + scope: { + hubOrigin: "https://hub.example.com", + repository: "github/replica", + branch: "prototype", + viewerLogin: "octocat", + }, + comments: localComments(context), + captured: revision(context), + } +} + +describe("createLocalReviewComments()", () => { + it("persists local edits and deletion across instances", async () => { + await withContext(async (context) => { + const { scope, captured } = fixture(context) + const anchor = { schemaVersion: 1, kind: "element", selector: "#save" } + const created = await localComments(context).create(scope, captured, { + body: "Keep this selection", + anchor, + }) + assert.deepEqual(await localComments(context).list(scope), [created]) + const updated = await localComments(context).update(scope, created.id, "Revised feedback") + assert.equal(updated.body, "Revised feedback") + assert.deepEqual(await localComments(context).list(scope), [updated]) + await localComments(context).remove(scope, created.id) + assert.deepEqual(await localComments(context).list(scope), []) + }) + }) + + it("isolates comments by Hub, repository, branch and reviewer", async () => { + await withContext(async (context) => { + const { comments, captured, scope } = fixture(context) + const original = await comments.create(scope, captured, { + body: "Original reviewer", + anchor: { schemaVersion: 1, kind: "element", selector: "#save" }, + }) + for (const changed of [ + { hubOrigin: "https://another-hub.example.com" }, + { repository: "github/another" }, + { branch: "another-branch" }, + { viewerLogin: "mona" }, + ]) { + const isolated = { ...scope, ...changed } + assert.deepEqual(await comments.list(isolated), []) + } + assert.deepEqual(await localComments(context).list(scope), [original]) + }) + }) + + it("uploads only matching source to an imported Build even when its commit differs", async () => { + await withContext(async (context) => { + const { comments, captured, scope } = fixture(context) + const originalCommit = git(context, "rev-parse", "HEAD") + const anchor = { + schemaVersion: 1, + kind: "element", + selector: "#original", + } + await comments.create(scope, captured, { + body: "Matching source", + anchor, + }) + await writeFile(path.join(context.repositoryPath, "new.txt"), "Different source") + git(context, "add", "new.txt") + const otherTree = git(context, "write-tree") + const other = { + id: Number.parseInt(otherTree.slice(0, 12), 16), + treeSha: otherTree, + } + const retained = await comments.create(scope, other, { + body: "Not in this Build", + anchor: { schemaVersion: 1, kind: "element", selector: "#save" }, + }) + git(context, "reset", "--quiet") + git( + context, + "-c", + "user.name=Test", + "-c", + "user.email=test@example.com", + "-c", + "commit.gpgsign=false", + "commit", + "--allow-empty", + "-qm", + "Same source, different commit", + ) + const imported = build(context) + assert.notEqual(imported.commitSha, originalCommit) + const requests = [] + await comments.sync(scope, imported, { + async request(route, options) { + requests.push({ route, options }) + return { + comments: [{ id: 900, kind: "root", buildNumber: imported.number }], + } + }, + }) + assert.equal(requests.length, 1) + assert.deepEqual(requests[0].options.body.review_comment, { + body: "Matching source", + anchor, + build_number: imported.number, + }) + assert.deepEqual(await localComments(context).list(scope), [retained]) + await comments.sync(scope, imported, { + async request() { + assert.fail("A synchronized comment must not be uploaded twice.") + }, + }) + await assert.rejects( + comments.sync( + scope, + { ...imported, commitSha: "f".repeat(40) }, + { + async request() { + assert.fail("An unknown Build must not receive local feedback.") + }, + }, + ), + /Fetch the published Build commit/, + ) + assert.deepEqual(await localComments(context).list(scope), [retained]) + }) + }) + + it("does not attach new feedback to an older Build with the same source tree", async () => { + await withContext(async (context) => { + const { comments, captured, scope } = fixture(context) + const imported = build(context) + const draft = await comments.create(scope, captured, { + body: "Feedback captured after the old Build", + anchor: { schemaVersion: 1, kind: "element", selector: "#save" }, + }) + await comments.sync( + scope, + { + ...imported, + publishedAt: new Date(Date.parse(draft.createdAt) - 1).toISOString(), + }, + { + async request() { + assert.fail("A Build published before the feedback must not claim it.") + }, + }, + ) + assert.deepEqual(await localComments(context).list(scope), [draft]) + }) + }) + + it("retains rejected uploads for a later retry and propagates the Hub error", async () => { + await withContext(async (context) => { + const { comments, captured, scope } = fixture(context) + const draft = await comments.create(scope, captured, { + body: "Retry this feedback", + anchor: { schemaVersion: 1, kind: "element", selector: "#save" }, + }) + const failure = Object.assign(new Error("Hub denied the request"), { + statusCode: 403, + }) + await assert.rejects( + comments.sync(scope, build(context), { + async request() { + throw failure + }, + }), + (error) => error === failure, + ) + assert.deepEqual(await localComments(context).list(scope), [draft]) + let retries = 0 + await localComments(context).sync(scope, build(context), { + async request() { + retries += 1 + return { comments: [{ id: 901, kind: "root", buildNumber: 7 }] } + }, + }) + assert.equal(retries, 1) + assert.deepEqual(await localComments(context).list(scope), []) + }) + }) + + it("keeps previous Prototype feedback separate even when a new history has the same source", async () => { + await withContext(async (context) => { + const { comments, captured, scope } = fixture(context) + const previous = await comments.create( + scope, + { ...captured, prototypeId: 4 }, + { + body: "Feedback for the previous history", + anchor: { schemaVersion: 1, kind: "element", selector: "#save" }, + }, + ) + await comments.create( + scope, + { ...captured, prototypeId: 9 }, + { + body: "Feedback for the current history", + anchor: { schemaVersion: 1, kind: "element", selector: "#save" }, + }, + ) + const imported = { ...build(context), prototypeId: 9 } + let uploads = 0 + await localComments(context).sync(scope, imported, { + async request(route, options) { + uploads += 1 + assert.equal(route, "/api/canvas/repositories/5/prototypes/9/review_comments") + assert.equal(options.body.review_comment.body, "Feedback for the current history") + return { + comments: [{ id: 904, kind: "root", buildNumber: imported.number }], + } + }, + }) + assert.equal(uploads, 1) + assert.deepEqual(await localComments(context).list(scope), [previous]) + }) + }) + + it("reconciles an ambiguous upload to its original Build after a newer Build arrives", async () => { + await withContext(async (context) => { + const { comments, captured, scope } = fixture(context) + const draft = await comments.create(scope, captured, { + body: "Response was lost", + anchor: { schemaVersion: 1, kind: "element", selector: "#save" }, + }) + const imported = build(context) + const failure = new Error("Connection lost after sending") + await assert.rejects( + comments.sync(scope, imported, { + async request() { + throw failure + }, + }), + (error) => error === failure, + ) + const pending = [{ ...draft, viewerCanEdit: false }] + assert.deepEqual(await localComments(context).list(scope), pending) + const newerBuild = { ...imported, number: imported.number + 1 } + await assert.rejects( + localComments(context).sync(scope, newerBuild, { + async request(route, options) { + assert.notEqual(options.method, "POST", "An uncertain save must never be replayed.") + return { comments: [], hasMore: false, nextCursor: null } + }, + }), + /could not be confirmed/, + ) + assert.deepEqual(await localComments(context).list(scope), pending) + await localComments(context).sync(scope, newerBuild, { + async request(route, options) { + assert.notEqual(options.method, "POST", "Reconciliation must not create another root.") + return { + comments: [ + { + ...draft, + id: 902, + buildNumber: imported.number, + createdAt: new Date().toISOString(), + }, + ], + hasMore: false, + nextCursor: null, + } + }, + }) + assert.deepEqual(await localComments(context).list(scope), []) + }) + }) +}) diff --git a/.github/extensions/replica-prototype/discover-hub/index.mjs b/.github/extensions/replica-prototype/discover-hub/index.mjs index 0abecbc8..a19bf2a8 100644 --- a/.github/extensions/replica-prototype/discover-hub/index.mjs +++ b/.github/extensions/replica-prototype/discover-hub/index.mjs @@ -4,7 +4,7 @@ import os from "node:os" import path from "node:path" import { promisify } from "node:util" -import { normalizeHubOrigin } from "../hub-client/index.mjs" +import { normalizeHubOrigin } from "../normalize-hub-origin/index.mjs" import { createPrivateStore } from "../private-store/index.mjs" import { readCanvasRepository } from "../read-canvas-repository/index.mjs" diff --git a/.github/extensions/replica-prototype/discover-hub/index.test.mjs b/.github/extensions/replica-prototype/discover-hub/index.test.mjs index 2bdf04de..335f2ae8 100644 --- a/.github/extensions/replica-prototype/discover-hub/index.test.mjs +++ b/.github/extensions/replica-prototype/discover-hub/index.test.mjs @@ -8,7 +8,7 @@ import { describe, it } from "node:test" import { discoverHub } from "./index.mjs" import { startCanvasServer } from "../start-canvas-server/index.mjs" import { createCanvasContext } from "../create-canvas-context/index.mjs" -import { createHubOriginStore } from "../hub-origin-store/index.mjs" +import { createHubOriginStore } from "../create-hub-origin-store/index.mjs" import { createPrivateStore } from "../private-store/index.mjs" import { runCommand } from "../run-command/index.mjs" diff --git a/.github/extensions/replica-prototype/invalid-hub-origin/index.mjs b/.github/extensions/replica-prototype/invalid-hub-origin/index.mjs new file mode 100644 index 00000000..03d9115a --- /dev/null +++ b/.github/extensions/replica-prototype/invalid-hub-origin/index.mjs @@ -0,0 +1 @@ +export class InvalidHubOrigin extends Error {} diff --git a/.github/extensions/replica-prototype/normalize-hub-origin/index.mjs b/.github/extensions/replica-prototype/normalize-hub-origin/index.mjs new file mode 100644 index 00000000..301eb105 --- /dev/null +++ b/.github/extensions/replica-prototype/normalize-hub-origin/index.mjs @@ -0,0 +1,10 @@ +import { InvalidHubOrigin } from "../invalid-hub-origin/index.mjs" +import { parseHubUrl } from "../parse-hub-url/index.mjs" + +export function normalizeHubOrigin(value, name = "REPLICA_HUB_ORIGIN") { + const origin = parseHubUrl(value, name) + if (origin.pathname !== "/" || origin.search || origin.hash) { + throw new InvalidHubOrigin(`${name} must be an HTTP or HTTPS origin without credentials.`) + } + return origin.origin +} diff --git a/.github/extensions/replica-prototype/normalize-selected-hub-origin/index.mjs b/.github/extensions/replica-prototype/normalize-selected-hub-origin/index.mjs new file mode 100644 index 00000000..019f0170 --- /dev/null +++ b/.github/extensions/replica-prototype/normalize-selected-hub-origin/index.mjs @@ -0,0 +1,5 @@ +import { parseHubUrl } from "../parse-hub-url/index.mjs" + +export function normalizeSelectedHubOrigin(value) { + return parseHubUrl(value, "Hub URL").origin +} diff --git a/.github/extensions/replica-prototype/parse-hub-url/index.mjs b/.github/extensions/replica-prototype/parse-hub-url/index.mjs new file mode 100644 index 00000000..73c18841 --- /dev/null +++ b/.github/extensions/replica-prototype/parse-hub-url/index.mjs @@ -0,0 +1,22 @@ +import { InvalidHubOrigin } from "../invalid-hub-origin/index.mjs" + +export function parseHubUrl(value, name) { + let origin + try { + origin = new URL(value) + } catch { + throw new InvalidHubOrigin(`${name} must be an HTTP or HTTPS origin without credentials.`) + } + if (!["http:", "https:"].includes(origin.protocol) || origin.username || origin.password) { + throw new InvalidHubOrigin(`${name} must be an HTTP or HTTPS origin without credentials.`) + } + if ( + origin.protocol === "http:" && + origin.hostname !== "localhost" && + origin.hostname !== "127.0.0.1" && + !origin.hostname.endsWith(".localhost") + ) { + throw new InvalidHubOrigin("Remote Replica Hub connections require HTTPS.") + } + return origin +} diff --git a/.github/extensions/replica-prototype/register-prototype-canvas/index.mjs b/.github/extensions/replica-prototype/register-prototype-canvas/index.mjs index d05860e8..552fb911 100644 --- a/.github/extensions/replica-prototype/register-prototype-canvas/index.mjs +++ b/.github/extensions/replica-prototype/register-prototype-canvas/index.mjs @@ -13,17 +13,17 @@ import { PUBLISH_RESULT_OUTCOMES, reportPublishResult, } from "../report-publish-result/index.mjs" -import { normalizeHubOrigin } from "../hub-client/index.mjs" +import { normalizeHubOrigin } from "../normalize-hub-origin/index.mjs" import { startCanvasServer } from "../start-canvas-server/index.mjs" import { agentCommands, MAX_RELOAD_ADDRESS_LENGTH } from "../agent-commands/index.mjs" import { startMissingPrototypeServer } from "../start-missing-prototype-server/index.mjs" import { commentActions } from "../comment-actions/index.mjs" -import { createHubConnection } from "../hub-connection/index.mjs" +import { createHubConnection } from "../create-hub-connection/index.mjs" import { createCommentStore } from "../comment-store/index.mjs" import { reviewAction } from "../review-action/index.mjs" import { projectValidation, validateControls } from "../validate-controls/index.mjs" import { projectControlsStatus } from "../controls-status/index.mjs" -import { createLearningsHook } from "../recall-learnings/index.mjs" +import { createLearningsHook } from "../create-learnings-hook/index.mjs" const HUB_STATES = new Set([ "connected", diff --git a/.github/extensions/replica-prototype/register-prototype-canvas/index.test.mjs b/.github/extensions/replica-prototype/register-prototype-canvas/index.test.mjs index b32c9406..69c58b41 100644 --- a/.github/extensions/replica-prototype/register-prototype-canvas/index.test.mjs +++ b/.github/extensions/replica-prototype/register-prototype-canvas/index.test.mjs @@ -12,7 +12,7 @@ import { readState } from "../read-state/index.mjs" import { requestPublish } from "../request-publish/index.mjs" import { writeState } from "../write-state/index.mjs" import { createPrivateStore } from "../private-store/index.mjs" -import { createHubOriginStore } from "../hub-origin-store/index.mjs" +import { createHubOriginStore } from "../create-hub-origin-store/index.mjs" import { rankForRecall, renderRecall } from "../../../../packages/learning/src/recall.mjs" import { metadataUpdateAcknowledgement, diff --git a/.github/extensions/replica-prototype/start-canvas-server/index.mjs b/.github/extensions/replica-prototype/start-canvas-server/index.mjs index eb826d71..5115c432 100644 --- a/.github/extensions/replica-prototype/start-canvas-server/index.mjs +++ b/.github/extensions/replica-prototype/start-canvas-server/index.mjs @@ -1,4 +1,4 @@ -import { randomBytes } from "node:crypto" +import { createHash, randomBytes } from "node:crypto" import { readFile } from "node:fs/promises" import { createServer } from "node:http" @@ -6,8 +6,8 @@ import { MAX_RELOAD_ADDRESS_LENGTH } from "../agent-commands/index.mjs" import { projectControlsStatus } from "../controls-status/index.mjs" import { currentCanvasContext } from "../create-canvas-context/index.mjs" import { getPrototypeState } from "../get-prototype-state/index.mjs" -import { createHubConnection } from "../hub-connection/index.mjs" -import { InvalidHubOrigin } from "../hub-client/index.mjs" +import { createHubConnection } from "../create-hub-connection/index.mjs" +import { InvalidHubOrigin } from "../invalid-hub-origin/index.mjs" import { openBrowser } from "../open-browser/index.mjs" import { readCanvasRepository } from "../read-canvas-repository/index.mjs" import { readPrototypeStartPage } from "../read-prototype-start-page/index.mjs" @@ -23,6 +23,8 @@ import { reviewAction } from "../review-action/index.mjs" import { createCommentStore } from "../comment-store/index.mjs" import { createShareLinks } from "../share-links/index.mjs" import { startPreviewProxy } from "../start-preview-proxy/index.mjs" +import { captureReviewRevision } from "../capture-review-revision/index.mjs" +import { createLocalReviewComments } from "../create-local-review-comments/index.mjs" const ASSET_PATHS = new Map([ [ @@ -58,6 +60,21 @@ export async function startCanvasServer(initialContext, session, options = {}) { const source = await readFile(new URL("../assets/canvas-bridge.js", import.meta.url), "utf8") const hubConnection = createHubConnection(() => context, options.hubOptions) const { hubClient, refreshDiscovery, selectHubOrigin, discoveries } = hubConnection + const localComments = createLocalReviewComments(initialContext, { + directory: options.localCommentsDirectory, + }) + async function localScope(hub, status) { + const connectionId = await hub.connectionKey(status.repository) + if (!connectionId || connectionId !== status.reviewConnectionId) + throw httpError(409, "The Hub connection changed. Refresh before using local comments.") + return { + hubOrigin: hub.origin, + repository: status.repository, + branch: status.branch, + viewerLogin: status.prototype?.viewerLogin || status.viewerLogin, + connectionId, + } + } async function updateMetadata({ name, description, startPage }, expectedTarget) { const hub = await hubClient() if (!hub) throw httpError(409, "Enter a Hub URL before connecting.") @@ -159,13 +176,77 @@ export async function startCanvasServer(initialContext, session, options = {}) { const hub = await hubClient() const { repository } = await readCanvasRepository(context) const discovery = discoveries.get(repository) - const status = hub + let status = hub ? await hub.status() : { state: "unconfigured", repository, message: "Enter a Hub URL to connect.", } + if ( + hub && + status.repositoryAuthorized && + status.branch && + status.registrationReason !== "branch_not_reviewable" + ) { + try { + const connectionId = await hub.connectionKey(status.repository) + if (!connectionId) throw httpError(401, "Connect to Hub before commenting.") + const snapshot = await captureReviewRevision(context) + if (snapshot.commitSha !== status.commitSha) + throw httpError( + 409, + "The checkout changed while preparing local comments. Refresh again.", + ) + const scope = await localScope(hub, status) + if (scope.connectionId !== connectionId) + throw httpError(409, "The Hub connection changed while preparing local comments.") + if (!scope.viewerLogin) throw new Error("Hub did not identify the connected reviewer.") + if (status.prototype?.build) { + try { + await localComments.sync( + scope, + { + ...status.prototype.build, + repositoryId: status.prototype.repositoryId, + prototypeId: status.prototype.id, + }, + hub, + ) + } catch (error) { + status = { + ...status, + localCommentsError: `Local comments not synced: ${error.message}`, + } + } + } + const published = + snapshot.clean && status.prototype?.build?.commitSha === snapshot.commitSha + status = { + ...status, + reviewRevision: { + ...snapshot, + id: published + ? null + : Number.parseInt( + createHash("sha256").update(snapshot.treeSha).digest("hex").slice(0, 12), + 16, + ) + 1, + prototypeId: status.prototype?.id ?? null, + repository: status.repository, + branch: status.branch, + buildNumber: published ? status.prototype.build.number : null, + hubOrigin: hub.origin, + connectionId, + }, + } + } catch (error) { + status = { + ...status, + reviewError: `Local comments unavailable: ${error.message}`, + } + } + } const ownsStartPage = status.state === "connected" && (status.prototype?.startPageSet ?? status.prototype?.startPage !== undefined) @@ -207,18 +288,24 @@ export async function startCanvasServer(initialContext, session, options = {}) { options.agentCommands, shareLinks, publishPreferences, + localComments, + localScope, ) } catch (error) { - sendJson(response, error?.statusCode || 500, { - error: error instanceof Error ? error.message : String(error), - ...(request.url?.startsWith("/api/hub/share-links") - ? { - code: error.code, - deliveryPhase: error.deliveryPhase, - authorization: error.authorization, - } - : {}), - }) + sendJson( + response, + error?.statusCode || (error?.code === "stale_comment_target" ? 409 : 500), + { + error: error instanceof Error ? error.message : String(error), + ...(request.url?.startsWith("/api/hub/share-links") + ? { + code: error.code, + deliveryPhase: error.deliveryPhase, + authorization: error.authorization, + } + : {}), + }, + ) } }) @@ -312,6 +399,8 @@ async function routeRequest( agentCommands, shareLinks, publishPreferences, + localComments, + localScope, ) { const requestUrl = new URL(request.url || "/", "http://127.0.0.1") @@ -496,13 +585,25 @@ async function routeRequest( return } if (requestUrl.pathname === "/api/hub/comments" && request.method === "GET") { - const base = await reviewPath(hub) + const status = await hub.status() + if (!status.repositoryAuthorized) throw httpError(403, "Connect to Hub before commenting.") + const scope = await localScope(hub, status) const cursor = requestUrl.searchParams.get("cursor") - sendJson( - response, - 200, - await hub.request(`${base}${cursor ? `?cursor=${encodeURIComponent(cursor)}` : ""}`), - ) + const page = status.prototype + ? await hub.request( + `${await reviewPath(hub)}${cursor ? `?cursor=${encodeURIComponent(cursor)}` : ""}`, + ) + : { comments: [], hasMore: false, nextCursor: null } + const revision = requestUrl.searchParams.get("local_revision_id") + const drafts = cursor + ? [] + : (await localComments.list(scope)).filter( + (comment) => !revision || comment.draftRevisionId === Number(revision), + ) + sendJson(response, 200, { + ...page, + comments: [...page.comments, ...drafts], + }) return } if (requestUrl.pathname === "/api/hub/mention-candidates" && request.method === "GET") { @@ -518,14 +619,52 @@ async function routeRequest( return } if (requestUrl.pathname === "/api/hub/comments" && request.method === "POST") { - const base = await reviewPath(hub) + const body = await readJson(request, 32_768) + const expected = body.review_revision + const status = await hub.status() + if ( + !expected || + expected.hubOrigin !== hub.origin || + typeof expected.connectionId !== "string" || + !expected.connectionId || + !status.repositoryAuthorized || + (status.prototype?.id ?? null) !== expected.prototypeId || + status.repository !== expected.repository || + status.branch !== expected.branch || + expected.connectionId !== (await hub.connectionKey(status.repository)) + ) + throw httpError( + 409, + "The Hub review target changed. Select a target again before commenting.", + ) + const attributes = { + body: body.review_comment?.body, + anchor: body.review_comment?.anchor, + } + if (expected.id === null) { + if (!Number.isSafeInteger(expected.buildNumber) || expected.buildNumber < 1) + throw httpError(400, "Select a valid published Build before commenting.") + attributes.build_number = expected.buildNumber + } else { + if (!Number.isSafeInteger(expected.id) || expected.id < 1) + throw httpError(400, "Select a valid local revision before commenting.") + const scope = await localScope(hub, status) + if (scope.connectionId !== expected.connectionId) + throw httpError(409, "The Hub connection changed. Select a target again.") + const comment = await localComments.create(scope, expected, attributes) + sendJson(response, 201, { comments: [comment] }) + return + } + const base = `/api/canvas/repositories/${status.prototype.repositoryId}/prototypes/${status.prototype.id}/review_comments` sendJson( response, 201, await hub.request(base, { method: "POST", interactive: true, - body: await readJson(request), + expectedTarget: status, + connectionScope: { identity: expected.connectionId }, + body: { review_comment: attributes }, }), ) return @@ -580,6 +719,22 @@ async function routeRequest( operation === "reactions" ? await readJson(request) : undefined + const status = await hub.status() + if (!status.repositoryAuthorized) throw httpError(403, "Connect to Hub before commenting.") + const scope = await localScope(hub, status) + if ((await localComments.list(scope)).some((comment) => comment.id === Number(id))) { + if (operation === "read" && method === "POST") { + sendJson(response, 200, {}) + return + } + if (operation) throw httpError(409, "Publish this comment before starting a conversation.") + const comment = + method === "PATCH" + ? await localComments.update(scope, id, body?.review_comment?.body) + : await localComments.remove(scope, id) + sendJson(response, 200, { comments: [comment] }) + return + } const suffix = operation ? `/${operation}${content ? `/${content}` : ""}` : "" sendJson( response, diff --git a/.github/extensions/replica-prototype/start-canvas-server/index.test.mjs b/.github/extensions/replica-prototype/start-canvas-server/index.test.mjs index c638382e..0fb1507b 100644 --- a/.github/extensions/replica-prototype/start-canvas-server/index.test.mjs +++ b/.github/extensions/replica-prototype/start-canvas-server/index.test.mjs @@ -777,6 +777,10 @@ esac const calls = [] const publishPrompts = [] const prototypes = new Map() + let currentPrototypeId = 4 + let currentBuildNumber = 2 + let currentBuildCommit = "1".padStart(40, "0") + let accessToken = "rp_secret" let canRegister = true let registrationError = false let registrationPending @@ -802,20 +806,32 @@ esac const branch = new URL(request.url, "http://localhost").searchParams.get("branch") if (branch === "prototype/second") { response.writeHead(404, { "Content-Type": "application/json" }) - response.end(JSON.stringify({ error: "Hub has not discovered this branch." })) + response.end( + JSON.stringify({ + error: "Hub has not discovered this branch.", + registrationReason: "remote_branch_missing", + }), + ) return } result = { - id: 4, + id: currentPrototypeId, repositoryId: 5, repository: "github/replica", viewerLogin: "octocat", branch, registered: prototypes.has(branch), + canEdit: true, canRegister, canManageShareLinks: true, published: sharingPublished, - build: sharingPublished ? { number: 2 } : null, + build: sharingPublished + ? { + number: currentBuildNumber, + commitSha: currentBuildCommit, + publishedAt: "2099-01-01T00:00:00Z", + } + : null, name: prototypes.get(branch)?.name ?? null, description: null, startPage: null, @@ -838,13 +854,13 @@ esac result = { deviceCode: "device", userCode: "ABCD", - verificationUrl: `${process.env.REPLICA_HUB_ORIGIN}/canvas/pair/ABCD`, + verificationUrl: `http://${request.headers.host}/canvas/pair/ABCD`, } } else if (request.url === "/api/canvas/pairings/token" && request.method === "POST") { result = { status: "approved", repository: "github/replica", - accessToken: "rp_secret", + accessToken, expiresAt: new Date(Date.now() + 60_000).toISOString(), } } else if (request.url === "/api/canvas/connection") { @@ -914,7 +930,24 @@ esac nextCursor: null, } } else if (request.url?.includes("/review_comments")) { - result = { comments: [], hasMore: false, nextCursor: null } + const attributes = body ? JSON.parse(body).review_comment : null + result = { + comments: + request.method === "POST" && request.url.endsWith("/review_comments") + ? [ + { + id: 9, + kind: "root", + body: attributes.body, + anchor: attributes.anchor, + author: { login: "octocat" }, + buildNumber: attributes.build_number, + }, + ] + : [], + hasMore: false, + nextCursor: null, + } } else { result = { name: "Updated" } } @@ -927,10 +960,15 @@ esac await writeFile( path.join(workspace, "git"), `#!/bin/sh +while [ "$1" = "-c" ]; do shift 2; done case "$1:$2" in remote:get-url) echo https://github.com/\${TEST_REPOSITORY:-github/replica}.git ;; branch:--show-current) echo "\${TEST_BRANCH:-prototype/first}" ;; rev-parse:HEAD) printf '%040d\\n' "\${TEST_HEAD:-1}" ;; + rev-parse:HEAD^{tree}) printf '%040d\\n' "\${TEST_HEAD_TREE:-2}" ;; + rev-parse:*^{tree}) printf '%040d\\n' "\${TEST_HEAD_TREE:-2}" ;; + write-tree:) printf '%040d\\n' "\${TEST_TREE:-2}" ;; + config:*) exit 1 ;; esac `, { mode: 0o755 }, @@ -945,27 +983,33 @@ esac sessionWorkspacePath: workspace, repositoryPath: workspace, }) - canvas = await startCanvasServer( - context, - { - send(message) { - publishPrompts.push({ - prompt: message.prompt, - registrations: calls.filter( - ({ path, method }) => path === "/api/canvas/prototype" && method === "PATCH", - ).length, - }) - return "message" + function startCanvas() { + return startCanvasServer( + context, + { + send(message) { + publishPrompts.push({ + prompt: message.prompt, + registrations: calls.filter( + ({ path, method }) => path === "/api/canvas/prototype" && method === "PATCH", + ).length, + }) + return "message" + }, }, - }, - { - hubOptions: { directory: path.join(workspace, "credentials") }, - openBrowser: async (url) => { - browserUrls.push(url) - return browserUnavailable ? { ok: false, error: "No browser available." } : { ok: true } + { + localCommentsDirectory: path.join(workspace, "local-comments"), + hubOptions: { directory: path.join(workspace, "credentials") }, + openBrowser: async (url) => { + browserUrls.push(url) + return browserUnavailable + ? { ok: false, error: "No browser available." } + : { ok: true } + }, }, - }, - ) + ) + } + canvas = await startCanvas() const page = await (await fetch(canvas.url)).text() let token = JSON.parse(page.match(/window\.__REPLICA_CANVAS__ = ([^;]+);/)[1]).token assert.equal((await fetch(new URL("/api/hub/status", canvas.url))).status, 403) @@ -1179,17 +1223,88 @@ esac (await send("/api/hub/mention-candidates?repositoryId=5&prototypeId=99")).status, 409, ) + const previousRevision = (await send("/api/hub/status")).body.reviewRevision + const beforeChangedRevision = calls.filter( + ({ path, method }) => path.endsWith("/review_comments") && method === "POST", + ).length + process.env.TEST_TREE = "3" + const posted = await send("/api/hub/comments", "POST", { + review_revision: previousRevision, + review_comment: { + body: "New thread", + anchor: { schemaVersion: 1, kind: "element", selector: "#save" }, + }, + }) + assert.equal(posted.status, 201) + const localRoots = (await send("/api/hub/comments")).body.comments + assert.equal(localRoots.length, 1) + assert.equal(localRoots[0].body, "New thread") + assert.equal(localRoots[0].draftRevisionId, previousRevision.id) + assert.equal(localRoots[0].buildNumber, null) + await canvas.close() + canvas = await startCanvas() + const reloadedPage = await (await fetch(canvas.url)).text() + token = JSON.parse(reloadedPage.match(/window\.__REPLICA_CANVAS__ = ([^;]+);/)[1]).token + assert.deepEqual((await send("/api/hub/comments")).body.comments, localRoots) + assert.equal( + calls.filter(({ path, method }) => path.endsWith("/review_comments") && method === "POST") + .length, + beforeChangedRevision, + ) + delete process.env.TEST_TREE + sharingPublished = true + const selectedBuild = (await send("/api/hub/status")).body.reviewRevision + assert.equal(selectedBuild.id, null) + assert.equal(selectedBuild.buildNumber, 2) + assert.equal((await send("/api/hub/comments")).body.comments.length, 0) + process.env.TEST_TREE = "3" + process.env.TEST_HEAD = "2" + process.env.TEST_HEAD_TREE = "3" + currentBuildNumber = 3 + currentBuildCommit = "2".padStart(40, "0") assert.equal( ( await send("/api/hub/comments", "POST", { + review_revision: selectedBuild, + review_comment: { body: "Keep the selected Build", anchor: { schemaVersion: 1 } }, + }) + ).status, + 201, + ) + assert.equal(JSON.parse(calls.at(-1).body).review_comment.build_number, 2) + sharingPublished = false + currentBuildNumber = 2 + currentBuildCommit = "1".padStart(40, "0") + delete process.env.TEST_HEAD + delete process.env.TEST_HEAD_TREE + delete process.env.TEST_TREE + assert.equal( + ( + await send("/api/hub/comments", "POST", { + review_revision: { ...previousRevision, hubOrigin: "https://another-hub.example.com" }, + review_comment: { body: "Wrong Hub", anchor: { schemaVersion: 1 } }, + }) + ).status, + 409, + ) + currentPrototypeId = 9 + assert.equal( + ( + await send("/api/hub/comments", "POST", { + review_revision: previousRevision, review_comment: { - build_number: 2, - body: "New thread", + body: "Stale Hub target", anchor: { schemaVersion: 1 }, }, }) ).status, - 201, + 409, + ) + currentPrototypeId = 4 + assert.equal( + calls.filter(({ path, method }) => path.endsWith("/review_comments") && method === "POST") + .length, + beforeChangedRevision + 2, ) assert.equal( ( @@ -1324,6 +1439,27 @@ esac const unpublishedRepositoryPage = await canvas.reviewAction("list_repository_comments", {}) assert.equal(unpublishedRepositoryPage.scanComplete, true) assert.equal(unpublishedRepositoryPage.target.branch, "prototype/second") + const draftOnly = (await send("/api/hub/status")).body + assert.equal(draftOnly.state, "undiscovered") + assert.equal(draftOnly.prototype, undefined) + const beforeUnpublishedSave = calls.length + assert.equal( + ( + await send("/api/hub/comments", "POST", { + review_revision: draftOnly.reviewRevision, + review_comment: { + body: "Review before Hub discovers the branch", + anchor: { schemaVersion: 1, kind: "element", selector: "#save" }, + }, + }) + ).status, + 201, + ) + assert.equal((await send("/api/hub/comments")).body.comments[0].buildNumber, null) + assert.ok( + calls.slice(beforeUnpublishedSave).every(({ method }) => method === "GET"), + "Saving unpublished feedback must not create any Hub records.", + ) assert.equal((await send("/api/publish", "POST", {})).status, 202) assert.equal(publishData(publishPrompts.at(-1).prompt).branch, "prototype/second") assert.equal(publishPrompts.at(-1).registrations, previousRegistrations) @@ -1370,6 +1506,38 @@ esac ) const originalHub = process.env.REPLICA_HUB_ORIGIN + const otherHub = `http://localhost:${hub.address().port}` + assert.equal((await send("/api/hub/origin", "POST", { origin: otherHub })).status, 200) + await send("/api/hub/pair", "POST", {}) + await send("/api/hub/poll", "POST", {}) + const otherHubStatus = (await send("/api/hub/status")).body + assert.equal(otherHubStatus.state, "connected") + const selectedConnection = otherHubStatus.reviewRevision + await send("/api/hub/disconnect", "POST", {}) + accessToken = "rp_reconnected" + await send("/api/hub/pair", "POST", {}) + await send("/api/hub/poll", "POST", {}) + const reconnectedStatus = (await send("/api/hub/status")).body + assert.equal(reconnectedStatus.state, "connected") + assert.notEqual( + reconnectedStatus.reviewRevision.connectionId, + selectedConnection.connectionId, + ) + const beforeReconnectedSave = calls.filter( + ({ path, method }) => path.endsWith("/review_comments") && method === "POST", + ).length + const reconnectedSave = await send("/api/hub/comments", "POST", { + review_revision: selectedConnection, + review_comment: { body: "Old connection", anchor: { schemaVersion: 1 } }, + }) + assert.equal(reconnectedSave.status, 409, JSON.stringify(reconnectedSave.body)) + assert.equal( + calls.filter(({ path, method }) => path.endsWith("/review_comments") && method === "POST") + .length, + beforeReconnectedSave, + ) + assert.equal((await send("/api/hub/origin", "POST", { origin: originalHub })).status, 200) + await send("/api/hub/status") const invalid = await send("/api/hub/origin", "POST", { origin: "http://hub.example.com", }) @@ -1413,7 +1581,10 @@ esac canvas = await startCanvasServer( context, { send() {} }, - { hubOptions: { directory: path.join(workspace, "credentials") } }, + { + hubOptions: { directory: path.join(workspace, "credentials") }, + localCommentsDirectory: path.join(workspace, "local-comments"), + }, ) const reopenedPage = await (await fetch(canvas.url)).text() token = JSON.parse(reopenedPage.match(/window\.__REPLICA_CANVAS__ = ([^;]+);/)[1]).token @@ -1430,6 +1601,8 @@ esac delete process.env.TEST_BRANCH delete process.env.TEST_REPOSITORY delete process.env.TEST_HEAD + delete process.env.TEST_HEAD_TREE + delete process.env.TEST_TREE if (originalOrigin === undefined) delete process.env.REPLICA_HUB_ORIGIN else process.env.REPLICA_HUB_ORIGIN = originalOrigin await new Promise((resolve, reject) => diff --git a/hub/.storybook/preview-fixtures/build-controls/controls.js b/hub/.storybook/preview-fixtures/build-controls/controls.js index 8bcdccd3..75f132d4 100644 --- a/hub/.storybook/preview-fixtures/build-controls/controls.js +++ b/hub/.storybook/preview-fixtures/build-controls/controls.js @@ -1,4 +1,4 @@ (function(){var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=((n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)))(o((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t}));e.validateShape=P;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern "^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern "^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return L.errors=a,o===0}e.number=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return R.errors=a,l===0}e.slider=z;function z(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return z.errors=a,l===0}e.choice=B;function B(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return B.errors=a,o===0}e.checkboxGroup=V;function V(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return V.errors=a,o===0}e.text=H;function H(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return H.errors=a,l===0}e.color=U;function U(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return U.errors=a,o===0}e.button=W;function W(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return W.errors=a,o===0}}))(),1);function l(e){if(e&&typeof e==`object`){for(let t of Object.values(e))l(t);Object.freeze(e)}return e}function u(e){return Array.isArray(e)?`[${e.map(u).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${u(e[t])}`).join(`,`)}}`:JSON.stringify(e)}function d(e,t){if(!e)return!0;if(e.all)return e.all.every(e=>d(e,t));if(e.any)return e.any.some(e=>d(e,t));let n=t[e.control];return`equals`in e?n===e.equals:`in`in e?e.in.includes(n):Array.isArray(n)&&n.includes(e.includes)}var{validateDocumentShape:f,validateDeclaration:p}=c.default,m={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function h(e){let t=[...p.errors].filter(e=>!/^\/controls\/\d+(?:\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(m,e?.type)?m[e.type]:void 0,i=r&&c.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params}))}var g=class extends Error{constructor(e){super(`Invalid controls.replica.json:\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(` `)}`),this.name=`ControlsValidationError`,this.issues=e}};function _(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function v(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(v):[]}function y(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=new Set,i=new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new g([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...v(s.when),...v(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function b(e){let t=new Set;function n(e,r=0){if(r>24)throw new g([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new g([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new g([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new g([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new g([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function x(e){b(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return C(e),S(e),e;if(!f(e))throw new g(f.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params})));let n=new Set;return t.forEach((e,t)=>{try{C(e),S(e)}catch(e){throw e instanceof g?new g(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new g([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function S(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new g(t)}function C(e){if(b(e),!p(e))throw new g(h(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=_(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=_(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new g(t);return y(e),e}var w=Symbol.for(`replica.controls.injected.runtime`),T=new WeakMap;function E(){let e=globalThis[w];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=new Map,t=new Set,n=Object.freeze({version:2,create:e=>D(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});T.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[w]=n}return globalThis[w]}function D(e){C(e);let t=l(structuredClone(e)),n=u(t),r=E(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(u(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope "${t.scope}"; reload after schema changes`);return i}let a=T.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=y(t),f=new Set,p=new Map,m=new Set,h={},g=0,v=!1,b=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function w(e){let n={};for(let t of c){let r=o.get(t);n[t]=d(r.when,e)&&d(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return l({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,d(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function D(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=l({...w(D()),revision:g});function O(e){let t=w(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(u(t)!==u(n)&&(x=l({...t,revision:++g}),b=!0,!v)){v=!0;try{for(;b;){b=!1;for(let e of[...f])e();a.notify()}}finally{v=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control "${e}"`);if(!x.visible[e])throw Error(`Control "${e}" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return f.add(e),()=>f.delete(e)},update(e,t){let n=_(k(e),t);if(n)throw Error(`Control "${e}": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control "${n}"`);let i=_(e,r);if(i)throw Error(`Control "${n}": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control "${e}"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(D());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control "${e}" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for "${e}"`);if(m.has(e))throw Error(`Action "${e}" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function O(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role="button"], [role="link"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function k(e,t){return JSON.stringify(e)===JSON.stringify(t)}function A(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function j(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function M(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API "${e}" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API "${e}" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function N(e){let t=e.binding;if(t.type===`api`){let e=M(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method "${n}" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=j(t.selector),r=O(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function P(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\(/.test(t)){let e=t.match(/\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function F(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function I(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):P(e,t.value);if(n.type===`style`)return P(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):P(e,i)}function L(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function R(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw L(e)}finally{window.clearTimeout(n)}}function z(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function B(e,t,n){let r=e.binding;if(r.type===`api`){await R(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[F(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():z(t,`value`,F(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,F(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,F(n)):i.hash=`#${F(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,"replicaControlsBinding",{value:!0}),window.dispatchEvent(a)}function V(e){x(e);let t=(e.sets??[e]).map(e=>({controller:D(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=E().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!O(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=Error(`API cleanup failed: ${L(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(F(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return N(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(A()).origin!==new URL(i).origin:A()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function v(e,t,n,r){let i=await R(()=>I(t.control,n));g(e,t,n,r);let a=_(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function b(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=A(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await B(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await v(e,t,o,s?A():a);if(!k(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=L(s),l=!1;if(o)try{let n=await v(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=Error(`${c.message} ${L(e).message}`)}throw!l&&k(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function S(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await b(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!k(await R(()=>I(n,r)),n.default))await b(e,t,n.default);else{let n=await v(e,t,r,A());t.rejection&&!k(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,L(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=A();t.control.binding.type===`api`?await R(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>S(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function j(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of y(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!k(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await b(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&k(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(` `).slice(0,1e3))}let M=window.setInterval(()=>{C()},250);function P(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=I(t.control,t.object),r=_(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,P);return C(),{runtime:E(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>j(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?_(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return j(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await j(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(` -`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,P);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function H(){let e=await fetch(`/controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(e.status===404||e.status===410)return;if(!e.ok)throw Error(`controls.replica.json returned HTTP ${e.status}.`);let t=``,n=e.body?.getReader();if(n){let e=new TextDecoder,r=0;for(;;){let{done:i,value:a}=await n.read();if(i)break;if(r+=a.byteLength,r>256e3)throw await n.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);t+=e.decode(a,{stream:!0})}t+=e.decode()}else t=await e.text();if(new TextEncoder().encode(t).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(e.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(t)))return V(JSON.parse(t))}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var W=`replica:controls`;function G(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&U(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||U({[r.id]:r.value}))}catch{return!1}}function K(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var q=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function J(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!U(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!q.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function Y(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=q.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!U({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{J(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function X(e,t){let n=new URL(e,window.location.href),r=Y(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(J(r.scopes)))n.searchParams.set(e,t);return n.toString()}function Z(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=J({...Y(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(X(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=Y(e);if(t.notice)throw Error(t.notice);s=J(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function ee(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var te={mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function ne(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?te.controlsActionUnavailable:``)}}function re(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>ne(e,t)))}}function ie(e){let t=``,n,r,i=``,a=!1,o=new Set,s=!1,c=0,l,u,d=!1,f,p=new Set,m=new Set,h=``,g=Z(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,ee(K(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await H(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(K);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:W,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(G(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:re(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!G(r.data))return;let c=r.data;if(c.type===`hello`){t=c.epoch,o.clear(),s=!1,m.clear();let e=c.fromFrameUrl&&g?.managed();g?.set(e?g.current():c.controlQuery??``),d||await w,x(`reply`,c.requestId,void 0,e?g?.current():void 0);return}if(c.type!==`command`||c.epoch!==t||o.has(c.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,c.requestId,`Reconnect controls before sending more commands.`);return}o.add(c.requestId);let l=c.command;function f(){if(a||t!==c.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(l?.operation===`url`){g.set(l.query??``),l.scope&&n?.list().some(e=>e.declaration.scope===l.scope&&e.mountedCount>0)&&(m.add(l.scope),g.refresh()),x(`reply`,c.requestId);return}if(!l||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(l.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(l.contexts)||l.contexts.length!==e.length||e.some(e=>!l.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,f)}else{let e=n.list().find(e=>e.declaration.scope===l.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(l.fingerprint!==JSON.stringify(e.declaration)||l.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(l.operation===`restore`){if(!U(l.values))throw Error(`Invalid saved controls.`);await u?.restore(e,l.values,f),m.add(e.declaration.scope),g?.refresh()}else if(l.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,f);else{let t=e.declaration.controls.find(e=>e.id===l.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),l.operation===`update`){let n={[t.id]:l.value};if(!U(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,f)}else if(l.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===c.epoch&&(x(`reply`,c.requestId),u?.navigate())}catch(e){t===c.epoch&&x(`reply`,c.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}var Q={enabled:!0,title:`Build preview`,items:3};function $(){let e=document.querySelector(`h1`),t=document.querySelector(`p`),n=document.querySelector(`ul`);if(!e||!t||!n)throw Error(`Build controls story markup is missing.`);e.textContent=Q.title,t.hidden=!Q.enabled,n.replaceChildren(...Array.from({length:Q.items},(e,t)=>{let n=document.createElement(`li`);return n.textContent=`Item ${t+1}`,n}))}Object.assign(window,{buildPreview:{readEnabled:()=>Q.enabled,writeEnabled:e=>{Q.enabled=e,$()},readTitle:()=>Q.title,writeTitle:e=>{Q.title=e,$()},readItems:()=>Q.items,writeItems:e=>{Q.items=e,$()},add:()=>{Q.items=Math.min(8,Q.items+1),$()}}}),$(),ie(window.location.origin)})(); \ No newline at end of file +`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,P);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function H(){let e=await fetch(`/controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(e.status===404||e.status===410)return;if(!e.ok)throw Error(`controls.replica.json returned HTTP ${e.status}.`);let t=``,n=e.body?.getReader();if(n){let e=new TextDecoder,r=0;for(;;){let{done:i,value:a}=await n.read();if(i)break;if(r+=a.byteLength,r>256e3)throw await n.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);t+=e.decode(a,{stream:!0})}t+=e.decode()}else t=await e.text();if(new TextEncoder().encode(t).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(e.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(t)))return V(JSON.parse(t))}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var W=`replica:controls`;function G(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&U(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||U({[r.id]:r.value}))}catch{return!1}}function K(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var q=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function J(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!U(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!q.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function Y(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=q.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!U({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{J(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function X(e,t){let n=new URL(e,window.location.href),r=Y(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(J(r.scopes)))n.searchParams.set(e,t);return n.toString()}function Z(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=J({...Y(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(X(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=Y(e);if(t.notice)throw Error(t.notice);s=J(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function ee(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var te={localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPagesExceeded:`Too many review comment pages.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function ne(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?te.controlsActionUnavailable:``)}}function re(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>ne(e,t)))}}function ie(e){let t=``,n,r,i=``,a=!1,o=new Set,s=!1,c=0,l,u,d=!1,f,p=new Set,m=new Set,h=``,g=Z(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,ee(K(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await H(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(K);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:W,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(G(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:re(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!G(r.data))return;let c=r.data;if(c.type===`hello`){t=c.epoch,o.clear(),s=!1,m.clear();let e=c.fromFrameUrl&&g?.managed();g?.set(e?g.current():c.controlQuery??``),d||await w,x(`reply`,c.requestId,void 0,e?g?.current():void 0);return}if(c.type!==`command`||c.epoch!==t||o.has(c.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,c.requestId,`Reconnect controls before sending more commands.`);return}o.add(c.requestId);let l=c.command;function f(){if(a||t!==c.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(l?.operation===`url`){g.set(l.query??``),l.scope&&n?.list().some(e=>e.declaration.scope===l.scope&&e.mountedCount>0)&&(m.add(l.scope),g.refresh()),x(`reply`,c.requestId);return}if(!l||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(l.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(l.contexts)||l.contexts.length!==e.length||e.some(e=>!l.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,f)}else{let e=n.list().find(e=>e.declaration.scope===l.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(l.fingerprint!==JSON.stringify(e.declaration)||l.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(l.operation===`restore`){if(!U(l.values))throw Error(`Invalid saved controls.`);await u?.restore(e,l.values,f),m.add(e.declaration.scope),g?.refresh()}else if(l.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,f);else{let t=e.declaration.controls.find(e=>e.id===l.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),l.operation===`update`){let n={[t.id]:l.value};if(!U(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,f)}else if(l.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===c.epoch&&(x(`reply`,c.requestId),u?.navigate())}catch(e){t===c.epoch&&x(`reply`,c.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}var Q={enabled:!0,title:`Build preview`,items:3};function $(){let e=document.querySelector(`h1`),t=document.querySelector(`p`),n=document.querySelector(`ul`);if(!e||!t||!n)throw Error(`Build controls story markup is missing.`);e.textContent=Q.title,t.hidden=!Q.enabled,n.replaceChildren(...Array.from({length:Q.items},(e,t)=>{let n=document.createElement(`li`);return n.textContent=`Item ${t+1}`,n}))}Object.assign(window,{buildPreview:{readEnabled:()=>Q.enabled,writeEnabled:e=>{Q.enabled=e,$()},readTitle:()=>Q.title,writeTitle:e=>{Q.title=e,$()},readItems:()=>Q.items,writeItems:e=>{Q.items=e,$()},add:()=>{Q.items=Math.min(8,Q.items+1),$()}}}),$(),ie(window.location.origin)})(); \ No newline at end of file diff --git a/hub/app/javascript/application/prototype-canvas/index.tsx b/hub/app/javascript/application/prototype-canvas/index.tsx index 94166f58..82224768 100644 --- a/hub/app/javascript/application/prototype-canvas/index.tsx +++ b/hub/app/javascript/application/prototype-canvas/index.tsx @@ -5,7 +5,7 @@ import { AppDialogs } from "@features/prototype-canvas-dialogs" import { BrowserBar } from "@components/prototype-browser-bar" import { ControlsPanel } from "@components/prototype-controls-panel" import type { ControlsPanelLayout } from "@components/prototype-controls-panel/types" -import { HubPanel } from "@features/prototype-canvas-hub-panel" +import { PrototypeCanvasHubPanel } from "@features/prototype-canvas-hub-panel" import { copy } from "@utils/prototype-canvas/en" import { request } from "@utils/prototype-canvas-request" import { resolveShareReadiness } from "@utils/resolve-prototype-share-readiness" @@ -234,7 +234,7 @@ export function App({ config }: Props) { }} /> - ()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=((n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)))(o((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t}));e.validateShape=P;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern "^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern "^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return L.errors=a,o===0}e.number=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return R.errors=a,l===0}e.slider=z;function z(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return z.errors=a,l===0}e.choice=B;function B(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return B.errors=a,o===0}e.checkboxGroup=V;function V(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return V.errors=a,o===0}e.text=H;function H(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return H.errors=a,l===0}e.color=U;function U(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return U.errors=a,o===0}e.button=W;function W(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return W.errors=a,o===0}}))(),1);function l(e){if(e&&typeof e==`object`){for(let t of Object.values(e))l(t);Object.freeze(e)}return e}function u(e){return Array.isArray(e)?`[${e.map(u).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${u(e[t])}`).join(`,`)}}`:JSON.stringify(e)}function d(e,t){if(!e)return!0;if(e.all)return e.all.every(e=>d(e,t));if(e.any)return e.any.some(e=>d(e,t));let n=t[e.control];return`equals`in e?n===e.equals:`in`in e?e.in.includes(n):Array.isArray(n)&&n.includes(e.includes)}var{validateDocumentShape:f,validateDeclaration:p}=c.default,m={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function h(e){let t=[...p.errors].filter(e=>!/^\/controls\/\d+(?:\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(m,e?.type)?m[e.type]:void 0,i=r&&c.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params}))}var g=class extends Error{constructor(e){super(`Invalid controls.replica.json:\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(` `)}`),this.name=`ControlsValidationError`,this.issues=e}};function _(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function v(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(v):[]}function y(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=new Set,i=new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new g([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...v(s.when),...v(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function b(e){let t=new Set;function n(e,r=0){if(r>24)throw new g([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new g([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new g([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new g([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new g([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function x(e){b(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return C(e),S(e),e;if(!f(e))throw new g(f.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params})));let n=new Set;return t.forEach((e,t)=>{try{C(e),S(e)}catch(e){throw e instanceof g?new g(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new g([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function S(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new g(t)}function C(e){if(b(e),!p(e))throw new g(h(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=_(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=_(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new g(t);return y(e),e}var w=Symbol.for(`replica.controls.injected.runtime`),T=new WeakMap;function E(){let e=globalThis[w];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=new Map,t=new Set,n=Object.freeze({version:2,create:e=>D(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});T.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[w]=n}return globalThis[w]}function D(e){C(e);let t=l(structuredClone(e)),n=u(t),r=E(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(u(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope "${t.scope}"; reload after schema changes`);return i}let a=T.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=y(t),f=new Set,p=new Map,m=new Set,h={},g=0,v=!1,b=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function w(e){let n={};for(let t of c){let r=o.get(t);n[t]=d(r.when,e)&&d(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return l({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,d(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function D(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=l({...w(D()),revision:g});function O(e){let t=w(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(u(t)!==u(n)&&(x=l({...t,revision:++g}),b=!0,!v)){v=!0;try{for(;b;){b=!1;for(let e of[...f])e();a.notify()}}finally{v=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control "${e}"`);if(!x.visible[e])throw Error(`Control "${e}" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return f.add(e),()=>f.delete(e)},update(e,t){let n=_(k(e),t);if(n)throw Error(`Control "${e}": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control "${n}"`);let i=_(e,r);if(i)throw Error(`Control "${n}": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control "${e}"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(D());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control "${e}" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for "${e}"`);if(m.has(e))throw Error(`Action "${e}" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function O(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role="button"], [role="link"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function k(e,t){return JSON.stringify(e)===JSON.stringify(t)}function A(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function j(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function M(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API "${e}" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API "${e}" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function N(e){let t=e.binding;if(t.type===`api`){let e=M(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method "${n}" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=j(t.selector),r=O(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function P(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\(/.test(t)){let e=t.match(/\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function F(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function I(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):P(e,t.value);if(n.type===`style`)return P(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):P(e,i)}function L(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function R(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw L(e)}finally{window.clearTimeout(n)}}function z(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function B(e,t,n){let r=e.binding;if(r.type===`api`){await R(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[F(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():z(t,`value`,F(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,F(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,F(n)):i.hash=`#${F(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,"replicaControlsBinding",{value:!0}),window.dispatchEvent(a)}function V(e){x(e);let t=(e.sets??[e]).map(e=>({controller:D(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=E().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!O(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=Error(`API cleanup failed: ${L(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(F(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return N(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(A()).origin!==new URL(i).origin:A()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function v(e,t,n,r){let i=await R(()=>I(t.control,n));g(e,t,n,r);let a=_(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function b(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=A(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await B(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await v(e,t,o,s?A():a);if(!k(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=L(s),l=!1;if(o)try{let n=await v(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=Error(`${c.message} ${L(e).message}`)}throw!l&&k(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function S(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await b(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!k(await R(()=>I(n,r)),n.default))await b(e,t,n.default);else{let n=await v(e,t,r,A());t.rejection&&!k(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,L(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=A();t.control.binding.type===`api`?await R(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>S(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function j(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of y(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!k(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await b(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&k(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(` `).slice(0,1e3))}let M=window.setInterval(()=>{C()},250);function P(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=I(t.control,t.object),r=_(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,P);return C(),{runtime:E(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>j(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?_(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return j(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await j(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(` -`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,P);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function H(){let e=await fetch(`/controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(e.status===404||e.status===410)return;if(!e.ok)throw Error(`controls.replica.json returned HTTP ${e.status}.`);let t=``,n=e.body?.getReader();if(n){let e=new TextDecoder,r=0;for(;;){let{done:i,value:a}=await n.read();if(i)break;if(r+=a.byteLength,r>256e3)throw await n.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);t+=e.decode(a,{stream:!0})}t+=e.decode()}else t=await e.text();if(new TextEncoder().encode(t).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(e.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(t)))return V(JSON.parse(t))}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var W=`replica:controls`;function G(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&U(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||U({[r.id]:r.value}))}catch{return!1}}function K(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var q=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function J(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!U(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!q.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function Y(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=q.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!U({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{J(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function X(e,t){let n=new URL(e,window.location.href),r=Y(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(J(r.scopes)))n.searchParams.set(e,t);return n.toString()}function Z(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=J({...Y(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(X(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=Y(e);if(t.notice)throw Error(t.notice);s=J(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function Q(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var $={mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function ee(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?$.controlsActionUnavailable:``)}}function te(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>ee(e,t)))}}function ne(e){let t=``,n,r,i=``,a=!1,o=new Set,s=!1,c=0,l,u,d=!1,f,p=new Set,m=new Set,h=``,g=Z(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,Q(K(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await H(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(K);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:W,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(G(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:te(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!G(r.data))return;let c=r.data;if(c.type===`hello`){t=c.epoch,o.clear(),s=!1,m.clear();let e=c.fromFrameUrl&&g?.managed();g?.set(e?g.current():c.controlQuery??``),d||await w,x(`reply`,c.requestId,void 0,e?g?.current():void 0);return}if(c.type!==`command`||c.epoch!==t||o.has(c.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,c.requestId,`Reconnect controls before sending more commands.`);return}o.add(c.requestId);let l=c.command;function f(){if(a||t!==c.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(l?.operation===`url`){g.set(l.query??``),l.scope&&n?.list().some(e=>e.declaration.scope===l.scope&&e.mountedCount>0)&&(m.add(l.scope),g.refresh()),x(`reply`,c.requestId);return}if(!l||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(l.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(l.contexts)||l.contexts.length!==e.length||e.some(e=>!l.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,f)}else{let e=n.list().find(e=>e.declaration.scope===l.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(l.fingerprint!==JSON.stringify(e.declaration)||l.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(l.operation===`restore`){if(!U(l.values))throw Error(`Invalid saved controls.`);await u?.restore(e,l.values,f),m.add(e.declaration.scope),g?.refresh()}else if(l.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,f);else{let t=e.declaration.controls.find(e=>e.id===l.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),l.operation===`update`){let n={[t.id]:l.value};if(!U(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,f)}else if(l.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===c.epoch&&(x(`reply`,c.requestId),u?.navigate())}catch(e){t===c.epoch&&x(`reply`,c.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}ne(`__REPLICA_CONTROLS_PARENT_ORIGIN__`)})(); \ No newline at end of file +`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,P);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function H(){let e=await fetch(`/controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(e.status===404||e.status===410)return;if(!e.ok)throw Error(`controls.replica.json returned HTTP ${e.status}.`);let t=``,n=e.body?.getReader();if(n){let e=new TextDecoder,r=0;for(;;){let{done:i,value:a}=await n.read();if(i)break;if(r+=a.byteLength,r>256e3)throw await n.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);t+=e.decode(a,{stream:!0})}t+=e.decode()}else t=await e.text();if(new TextEncoder().encode(t).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(e.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(t)))return V(JSON.parse(t))}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var W=`replica:controls`;function G(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&U(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||U({[r.id]:r.value}))}catch{return!1}}function K(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var q=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function J(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!U(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!q.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function Y(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=q.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!U({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{J(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function X(e,t){let n=new URL(e,window.location.href),r=Y(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(J(r.scopes)))n.searchParams.set(e,t);return n.toString()}function Z(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=J({...Y(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(X(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=Y(e);if(t.notice)throw Error(t.notice);s=J(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function Q(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var $={localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPagesExceeded:`Too many review comment pages.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function ee(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?$.controlsActionUnavailable:``)}}function te(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>ee(e,t)))}}function ne(e){let t=``,n,r,i=``,a=!1,o=new Set,s=!1,c=0,l,u,d=!1,f,p=new Set,m=new Set,h=``,g=Z(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,Q(K(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await H(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(K);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:W,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(G(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:te(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!G(r.data))return;let c=r.data;if(c.type===`hello`){t=c.epoch,o.clear(),s=!1,m.clear();let e=c.fromFrameUrl&&g?.managed();g?.set(e?g.current():c.controlQuery??``),d||await w,x(`reply`,c.requestId,void 0,e?g?.current():void 0);return}if(c.type!==`command`||c.epoch!==t||o.has(c.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,c.requestId,`Reconnect controls before sending more commands.`);return}o.add(c.requestId);let l=c.command;function f(){if(a||t!==c.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(l?.operation===`url`){g.set(l.query??``),l.scope&&n?.list().some(e=>e.declaration.scope===l.scope&&e.mountedCount>0)&&(m.add(l.scope),g.refresh()),x(`reply`,c.requestId);return}if(!l||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(l.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(l.contexts)||l.contexts.length!==e.length||e.some(e=>!l.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,f)}else{let e=n.list().find(e=>e.declaration.scope===l.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(l.fingerprint!==JSON.stringify(e.declaration)||l.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(l.operation===`restore`){if(!U(l.values))throw Error(`Invalid saved controls.`);await u?.restore(e,l.values,f),m.add(e.declaration.scope),g?.refresh()}else if(l.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,f);else{let t=e.declaration.controls.find(e=>e.id===l.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),l.operation===`update`){let n={[t.id]:l.value};if(!U(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,f)}else if(l.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===c.epoch&&(x(`reply`,c.requestId),u?.navigate())}catch(e){t===c.epoch&&x(`reply`,c.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}ne(`__REPLICA_CONTROLS_PARENT_ORIGIN__`)})(); \ No newline at end of file diff --git a/hub/app/javascript/features/prototype-canvas-hub-panel/bridge-health.test.tsx b/hub/app/javascript/features/prototype-canvas-hub-panel/bridge-health.test.tsx index 3f2c2969..cf0c7374 100644 --- a/hub/app/javascript/features/prototype-canvas-hub-panel/bridge-health.test.tsx +++ b/hub/app/javascript/features/prototype-canvas-hub-panel/bridge-health.test.tsx @@ -1,30 +1,13 @@ -import { ThemeProvider } from "@primer/react-brand" -import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react" +import { act, fireEvent, screen, waitFor, within } from "@testing-library/react" import { createRef } from "react" -import { afterEach, beforeAll, expect, it, vi } from "vitest" +import { expect, it, vi } from "vitest" import { octocatRootComment } from "@/storybook/fixtures/review/comments" import { reviewCommentsCopy } from "@utils/review-comment/en" import type { ReviewAnchor } from "@utils/review-anchor/types" - -import { HubPanel } from "." import { importedPrototype, publicationHub } from "@utils/resolve-prototype-publication/fixtures" -beforeAll(() => { - Object.defineProperty(HTMLDialogElement.prototype, "showModal", { - configurable: true, - value(this: HTMLDialogElement) { - this.open = true - }, - }) -}) - -afterEach(() => { - document.getElementById("canvas-review-controls")?.remove() - vi.useRealTimers() - vi.restoreAllMocks() - vi.unstubAllGlobals() -}) +import { renderPrototypeCanvasHubPanel } from "./test-support/render-prototype-canvas-hub-panel" it("waits for loading, validates compatibility, recovers from late responses, and clears readiness on reload", async () => { vi.useFakeTimers() @@ -33,30 +16,24 @@ it("waits for loading, validates compatibility, recovers from late responses, an const fetch = vi.fn() vi.stubGlobal("fetch", fetch) const frameRef = createRef() - const view = render( - -