@reqvire-org/ads 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ads-errors.mjs +110 -25
- package/dist/analysis/composition-axes.mjs +48 -0
- package/dist/analysis/construction-memo.mjs +38 -0
- package/dist/analysis/context.mjs +19 -0
- package/dist/analysis/design-reads.mjs +177 -0
- package/dist/analysis/factored-classes.mjs +90 -0
- package/dist/analysis/helpers.mjs +5 -7
- package/dist/analysis/native-project.mjs +12 -0
- package/dist/analysis/owner-analysis-cache.mjs +86 -23
- package/dist/analysis/owner-analysis-key.mjs +42 -10
- package/dist/analysis/owner-choices.mjs +23 -4
- package/dist/analysis/owner-composition.mjs +118 -33
- package/dist/analysis/owner-reuse.mjs +8 -6
- package/dist/analysis/owner-source.mjs +253 -76
- package/dist/analysis/scenario-keys.mjs +10 -7
- package/dist/analysis/service.mjs +50 -3
- package/dist/analysis/standalone.mjs +7 -4
- package/dist/analysis/syntax.mjs +59 -1
- package/dist/analysis/worker-protocol.mjs +14 -2
- package/dist/analysis/worker.mjs +32 -10
- package/dist/architecture-report.mjs +26 -0
- package/dist/asset-view-facts.mjs +16 -2
- package/dist/boundaries.mjs +26 -10
- package/dist/bun-compiler.mjs +2 -2
- package/dist/check-service.mjs +29 -17
- package/dist/check.mjs +13 -6
- package/dist/cli.mjs +1 -1
- package/dist/composed-keyline.mjs +2 -2
- package/dist/config.mjs +2 -1
- package/dist/construction-output.mjs +3 -2
- package/dist/construction-spec.d.mts +111 -6
- package/dist/construction-spec.mjs +172 -30
- package/dist/corner-overpaint.mjs +16 -4
- package/dist/derived-states.mjs +182 -0
- package/dist/design-inputs.mjs +18 -3
- package/dist/design-system-closure.mjs +12 -7
- package/dist/emit/contract.mjs +24 -5
- package/dist/emit/emission.mjs +6 -4
- package/dist/emit/integrity.mjs +8 -2
- package/dist/emit/output-watch.mjs +120 -0
- package/dist/emit/owner-emission-cache.mjs +4 -4
- package/dist/emit/preview-emitter.mjs +4 -2
- package/dist/emit/preview-tree.mjs +1 -1
- package/dist/emit/service.mjs +8 -2
- package/dist/finding-rules.mjs +3 -0
- package/dist/form-states.mjs +8 -0
- package/dist/frame-regions.mjs +29 -9
- package/dist/hover-geometry.mjs +15 -0
- package/dist/input-digests.mjs +17 -10
- package/dist/linaria/delivery.mjs +2 -0
- package/dist/lowering-properties.mjs +5 -0
- package/dist/lowering-region-layout.mjs +7 -2
- package/dist/mcp/build-status.mjs +9 -1
- package/dist/mcp/compiler-channel.mjs +11 -4
- package/dist/mcp/mutations.mjs +1 -0
- package/dist/mcp/preview-http.bundle.js +1 -1
- package/dist/mcp/preview-watch.mjs +2 -1
- package/dist/mcp/preview-widget.bundle.js +1 -1
- package/dist/motion-model.mjs +1 -1
- package/dist/owner-analysis-check.mjs +19 -5
- package/dist/owner-errors.mjs +4 -2
- package/dist/owner-lowering.mjs +71 -12
- package/dist/owner-scenarios.mjs +4 -1
- package/dist/ownership-model.mjs +18 -4
- package/dist/placeholder-contrast.mjs +17 -1
- package/dist/platform-features.mjs +10 -1
- package/dist/profile-view-facts.mjs +1 -1
- package/dist/recipe-macro.d.mts +72 -13
- package/dist/recipe-model.mjs +9 -5
- package/dist/region-lowering.mjs +238 -40
- package/dist/render-audit/layout-shift.page.mjs +24 -0
- package/dist/render-audit/render-states.mjs +122 -1
- package/dist/render-audit/render-states.page.mjs +140 -0
- package/dist/render-audit/worker.mjs +18 -3
- package/dist/render-audit.mjs +114 -1
- package/dist/role-vocabulary.d.mts +5 -0
- package/dist/role-vocabulary.mjs +12 -1
- package/dist/scenarios-compiler.mjs +20 -6
- package/dist/showcase/assets-view.mjs +29 -13
- package/dist/showcase/client.bundle.js +32 -32
- package/dist/showcase/http-client.bundle.js +15 -15
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +4 -4
- package/dist/skills/ads-designer/references/accessibility.md +7 -0
- package/dist/skills/ads-designer/references/branding.md +13 -3
- package/dist/skills/ads-designer/references/contracts.md +5 -2
- package/dist/skills/ads-designer/references/design-data.md +1 -1
- package/dist/skills/ads-designer/references/layout.md +5 -1
- package/dist/skills/ads-designer/references/motion.md +9 -1
- package/dist/skills/ads-designer/references/recipes.md +27 -3
- package/dist/skills/ads-import/references/contracts.md +5 -2
- package/dist/skills/ads-import/references/design-data.md +1 -1
- package/dist/skills/ads-import/references/layout.md +5 -1
- package/dist/skills/ads-import/references/recipes.md +27 -3
- package/dist/skills/ads-migrate/SKILL.md +1 -0
- package/dist/skills/ads-migrate/references/0.5.1-to-0.5.2.md +185 -0
- package/dist/skills/ads-port/references/contracts.md +5 -2
- package/dist/skills/ads-port/references/design-data.md +1 -1
- package/dist/skills/ads-port/references/layout.md +5 -1
- package/dist/skills/ads-port/references/recipes.md +27 -3
- package/dist/surface-contrast.mjs +1 -0
- package/dist/surface-effects.mjs +5 -3
- package/dist/task-cache.mjs +8 -18
- package/dist/validation-checks.mjs +1 -1
- package/docs/ARCHITECTURE.md +63 -7
- package/docs/CACHING.md +152 -24
- package/docs/CHANGELOG.md +200 -23
- package/docs/GUIDE.md +45 -1
- package/docs/LANGUAGE.md +146 -8
- package/docs/MOTION.md +10 -2
- package/docs/PROFILE-KINDS.md +9 -1
- package/docs/RULES.md +22 -14
- package/docs/TOKEN-ROLES.md +7 -1
- package/package.json +1 -1
|
@@ -106,6 +106,6 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
106
106
|
- omitted: host decides border`)}),cx=d({method:p("ui/request-display-mode"),params:d({mode:di.describe("The display mode being requested.")})}),Sb=d({mode:di.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),_b=C([p("model"),p("app")]).describe("Tool visibility scope - who can access the tool."),lx=d({resourceUri:a().optional(),visibility:g(_b).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
107
107
|
- "model": Tool visible to and callable by the agent
|
|
108
108
|
- "app": Tool callable by the app from this server only`),csp:Yc().optional(),permissions:Yc().optional()}),ux=d({mimeTypes:g(a()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),dx=d({method:p("ui/download-file"),params:d({contents:g(C([ko,To])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),px=d({method:p("ui/message"),params:d({role:p("user").describe('Message role, currently only "user" is supported.'),content:g(Tt).describe("Message content blocks (text, image, etc.).")})}),hx=d({method:p("ui/notifications/sandbox-resource-ready"),params:d({html:a().describe("HTML content to load into the inner iframe."),sandbox:a().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Pl.optional().describe("CSP configuration from resource metadata."),permissions:El.optional().describe("Sandbox permissions from resource metadata.")})}),yb=d({method:p("ui/notifications/tool-result"),params:oo.describe("Standard MCP tool execution result.")}),pf=d({toolInfo:d({id:vt.optional().describe("JSON-RPC id of the tools/call request."),tool:to.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:ob.optional().describe("Current color theme preference."),styles:pb.optional().describe("Style configuration for theming the app."),displayMode:di.optional().describe("How the UI is currently displayed."),availableDisplayModes:g(di).optional().describe("Display modes the host supports."),containerDimensions:C([d({height:w().describe("Fixed container height in pixels.")}),d({maxHeight:C([w(),Kc()]).optional().describe("Maximum container height in pixels.")})]).and(C([d({width:w().describe("Fixed container width in pixels.")}),d({maxWidth:C([w(),Kc()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
109
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:a().optional().describe("User's language and region preference in BCP 47 format."),timeZone:a().optional().describe("User's timezone in IANA format."),userAgent:a().optional().describe("Host application identifier."),platform:C([p("web"),p("desktop"),p("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:d({touch:T().optional().describe("Whether the device supports touch input."),hover:T().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:d({top:w().describe("Top safe area inset in pixels."),right:w().describe("Right safe area inset in pixels."),bottom:w().describe("Bottom safe area inset in pixels."),left:w().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),bb=d({method:p("ui/notifications/host-context-changed"),params:pf.describe("Partial context update containing only changed fields.")}),mx=d({method:p("ui/update-model-context"),params:d({content:g(Tt).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:E(a(),L().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),fx=d({method:p("ui/initialize"),params:d({appInfo:Et.describe("App identification (name and version)."),appCapabilities:gb.describe("Features and capabilities this app provides."),protocolVersion:a().describe("Protocol version this app supports.")})}),vb=d({protocolVersion:a().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Et.describe("Host application identification and version."),hostCapabilities:fb.describe("Features and capabilities provided by the host."),hostContext:pf.describe("Rich context about the host environment.")}).passthrough(),wb={target:"draft-2020-12"};async function af(e,t){let o=e["~standard"];if(o.jsonSchema)return o.jsonSchema[t](wb);throw Error(`Schema (vendor: ${o.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function cf(e,t,o=""){let r=await e["~standard"].validate(t);if(r.issues){let n=r.issues.map((i)=>{let s=i.path?.map((c)=>typeof c==="object"?c.key:c).join(".");return s?`${s}: ${i.message}`:i.message}).join("; ");throw Error(o+n)}return r.value}function zb(e,t){let o={...e,...t};if(t.experimental!==void 0)o.experimental={...e.experimental,...t.experimental};if(t.tools!==void 0)o.tools={...e.tools,...t.tools};return o}class La extends li{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new lf;_methods=new uf;setRequestHandler=(...e)=>{let[t,...o]=nf("request",e)??e;this._methods.claim(t,"setRequestHandler"),super.setRequestHandler.call(this,t,...o)};setNotificationHandler=(...e)=>{let[t,...o]=nf("notification",e)??e;this._methods.claim(t,"setNotificationHandler"),super.setNotificationHandler.call(this,t,...o)};removeRequestHandler=(e)=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=(e)=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:cb,toolinputpartial:lb,toolresult:yb,toolcancelled:ub,hostcontextchanged:bb};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!La.ONE_SHOT_EVENTS.has(e)||this._everHadListener.has(e))return;if(this._everHadListener.add(e),!this._initializedSent)return;let t=`[ext-apps] "${String(e)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(t);console.warn(t)}setEventHandler(e,t){if(t)this._assertHandlerTiming(e);this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},(o)=>{let r=o;if(e==="hostcontextchanged")this._hostContext={...this._hostContext,...r};this._events.dispatch(e,r)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,o){if(t&&o)console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},o={autoResize:!0}){super(o);if(this._appInfo=e,this._appCapabilities=t,this.options=o,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!o.allowUnsafeEval)ct({jitless:!0});this.replaceRequestHandler("ping",(r)=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=zb(this._appCapabilities,e)}registerTool(e,t,o){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,n=()=>{if(r._initializedSent&&r._appCapabilities.tools?.listChanged)r.sendToolListChanged()},i=t.inputSchema!==void 0,s={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,n()},disable(){this.enabled=!1,n()},update(c){Object.assign(this,c),n()},remove(){if(r._registeredTools[e]!==s)return;delete r._registeredTools[e],n()},handler:async(c,l)=>{if(!s.enabled)throw Error(`Tool ${e} is disabled`);let u;if(i){let h=s.inputSchema,m=h?await cf(h,c??{},`Invalid input for tool ${e}: `):c??{};u=await o(m,l)}else u=await o(l);if(s.outputSchema&&!u.isError)u.structuredContent=await cf(s.outputSchema,u.structuredContent,`Invalid output for tool ${e}: `);return u}};if(this._registeredTools[e]=s,!this._appCapabilities.tools&&!this.transport)this.registerAppCapabilities({tools:{listChanged:!0}});return this.ensureToolHandlersInitialized(),n(),s}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){if(this._toolHandlersInitialized)return;this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let o=this._registeredTools[e.name];if(!o)throw Error(`Tool ${e.name} not found`);return o.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,r])=>r.enabled).map(async([o,r])=>{let n={name:o,title:r.title,description:r.description,inputSchema:r.inputSchema?await af(r.inputSchema,"input"):{type:"object",properties:{}}};if(r.outputSchema)n.outputSchema=await af(r.outputSchema,"output");if(r.annotations)n.annotations=r.annotations;if(r._meta)n._meta=r._meta;return n}))})}async sendToolListChanged(e={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(e){this.setEventHandler("toolinput",e)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(e){this.setEventHandler("toolinputpartial",e)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(e){this.setEventHandler("toolresult",e)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(e){this.setEventHandler("toolcancelled",e)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(e){this.setEventHandler("hostcontextchanged",e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,e),this._onteardown=e,this.replaceRequestHandler("ui/resource-teardown",{params:hb.shape.params,result:mb},(t,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(t,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler("tools/call",(t,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(t.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler("tools/list",(t,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(t.params,o)})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized("callServerTool"),typeof e==="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},t)}async listServerResources(e,t){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:e},t)}sendMessage(e,t){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:e},ab,t)}sendLog(e){return this.notification({method:"notifications/message",params:e})}updateModelContext(e,t){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:e},Xt,t)}openLink(e,t){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},sb,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},ib,t)}requestTeardown(e={}){return this.notification({method:"ui/notifications/request-teardown",params:e})}requestDisplayMode(e,t){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:e},Sb,t)}sendSizeChanged(e){return this.notification({method:"ui/notifications/size-changed",params:e})}setupSizeChangedNotifications(){let e=!1,t=0,o=0,r=()=>{if(e)return;e=!0,requestAnimationFrame(()=>{e=!1;let i=document.documentElement,s=i.style.height;i.style.height="max-content";let c=Math.ceil(i.getBoundingClientRect().height);i.style.height=s;let l=Math.ceil(window.innerWidth);if(l!==t||c!==o)t=l,o=c,this.sendSizeChanged({width:l,height:c})})};r();let n=new ResizeObserver(r);return n.observe(document.documentElement),n.observe(document.body),()=>n.disconnect()}async connect(e=new df(window.parent,window.parent),t){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(e);let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:eb}},vb,t);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);if(this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize)this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}}var Rb=(e)=>typeof e==="object"&&e!==null,hf=(e)=>new Map([...e].flatMap(([t,o])=>o.hot?[[o.hot.id,{uri:t,source:o.hot.source,record:o}]]:[]));function mf(){let e=new Map,t=new Set,o=!1,r;function n(s){let l={data:e.get(s)?.data??{},callbacks:[],listeners:new Map};return e.set(s,l),{data:l.data,accept(u,h){if(!u||typeof u==="function"){let m=typeof u==="function"?u:void 0;l.callbacks.push({deps:[s],callback:(f)=>m?.(f[0])})}else l.callbacks.push({deps:typeof u==="string"?[u]:u,callback:(m)=>h?.(typeof u==="string"?m[0]:m)})},acceptExports(u,h){l.callbacks.push({deps:[s],callback:(m)=>h?.(m[0])})},dispose(u){l.dispose=u},prune(u){l.prune=u},invalidate(){o=!0},decline(){o=!0},on(u,h){let m=l.listeners.get(u)??new Set;m.add(h),l.listeners.set(u,m)},off(u,h){l.listeners.get(u)?.delete(h)},send(){throw Error("Preview hot-update custom messages are not a public transport.")}}}async function i(s){for(let c of e.values())for(let l of c.listeners.get(s)??[])await l()}return{context:n,observe(s,c,l){let u=e.get(s);if(!u)return;let m=import(c).then((f)=>{u.exports=Rb(f)?f:void 0,u.isComponent=l});t.add(m),m.then(()=>t.delete(m),(f)=>{t.delete(m),r=f})},async update(s,c,l,u){if(await Promise.all(t),r)throw r;let h=hf(s),m=hf(c),f=new Map,S=new Map;for(let[v,{record:k}]of h)for(let U of[...k.imports,...k.dynamicImports]){let z=s.get(U)?.hot?.id;if(!z)continue;let R=f.get(z)??new Set;R.add(v),f.set(z,R)}function y(v,k=new Set){if(k.has(v))return!1;let U=e.get(v);if(U?.callbacks.some((M)=>M.deps.includes(v))&&m.has(v))return S.set(v,U),!0;let z=f.get(v);if(!z?.size)return!1;let R=new Set([...k,v]);for(let M of z)if(!y(M,R))return!1;return!0}for(let[v,k]of h){let U=m.get(v);if(!U||k.source!==U.source){if(!y(v))return!1}}if(!S.size)return!0;o=!1,await i("vite:beforeUpdate");let b=[];for(let[v,k]of S){if(!u())return!1;await k.dispose?.(k.data);let U=m.get(v)?.uri??"";b.push([v,k,await l(U)])}if(!u())return!1;for(let[,v,k]of b){let{isComponent:U,exports:z}=v;if(!U)continue;let R=Object.keys(k).filter((M)=>M!=="__esModule");if(!z||R.length!==Object.keys(z).filter((M)=>M!=="__esModule").length||R.some((M)=>!Object.hasOwn(z,M)||!U(k[M])&&z[M]!==k[M]))return!1}for(let[v,k,U]of b)for(let z of k.callbacks)if(z.deps.includes(v))await z.callback(z.deps.map((R)=>R===v?U:void 0));return await i("vite:afterUpdate"),await new Promise((v)=>setTimeout(v,20)),u()&&!o},async dispose(){for(let s of e.values())await s.dispose?.(s.data),await s.prune?.(s.data);e.clear(),t.clear(),r=void 0}}}var xb=["imports","dynamicImports","styles","references"],Rr=(e)=>typeof e==="object"&&e!==null,ff=(e)=>Rr(e)?e.message:void 0,pi=(e,t,o)=>Object.assign(Error(e,o),t);function Pb(e,t){if(Rr(e))Reflect.set(e,"resourceUri",t);return e}var gf=(e)=>Rr(e)?e.epoch:void 0;function kl(e){if(typeof e.module!=="string")throw Error(`Missing preview dependency metadata: ${String(e.module)}`);return e.module}var Eb=(e)=>Rr(e)?e:{};async function kb(e,t){let o=await crypto.subtle.digest("SHA-256",t),r="sha256:"+[...new Uint8Array(o)].map((n)=>n.toString(16).padStart(2,"0")).join("");if(t.length!==e?.size||r!==e.digest)throw pi("Preview resource integrity check failed. Rebuild and reopen the preview.",{code:"ADS_RESOURCE_INTEGRITY",category:"build"});return t}function Sf(e,t){let o=[],r=new Set;function n(i){if(r.has(i))return;r.add(i);let s=e.get(i);if(!s)throw Error(`Missing preview dependency metadata: ${i}`);for(let c of[...s.imports,...s.styles,...s.references])n(c);o.push(i)}return n(t),o}function _f(e,t){if(!e||e.revision===t.revision)return[];let o=(r,n)=>{let i=new Map(Object.entries(r.assets));return JSON.stringify(Sf(i,kl(n)).map((s)=>[s,i.get(s)]))};return t.scenarios.filter((r)=>{let n=e.scenarios.find((i)=>i.id===r.id);return!n||o(e,n)!==o(t,r)}).map((r)=>r.id)}function Tb(e,t,o,r){let{digest:n,hot:i}=t;if(!/^ads:\/\/assets\/[a-f0-9]{64}\.[a-z0-9]+$/.test(e)||typeof n!=="string"||!/^sha256:[a-f0-9]{64}$/.test(n))return null;if(i&&(!o.refresh||t.kind!=="module"||!Rr(i)||typeof i.id!=="string"||!i.id||i.id.length>4096||r.has(i.id)||typeof i.source!=="string"||!/^[a-f0-9]{64}$/.test(i.source)))return null;if(!xb.every((s)=>Array.isArray(t[s])&&t[s].every((c)=>Object.hasOwn(o.assets,c))))return null;return t}class Tl{read;records=new Map;bytes=new Map;urls=new Map;styles=new Map;styleReady=new Map;revisions=new Set;loadedModules=new Set;executed=new Map;moduleHistory=new Set;importing=Promise.resolve();mounting=Promise.resolve();refreshDirty=!1;generation=0;prefetchGeneration=0;closed=!1;hot;mounted;unmount;constructor(e){this.read=e,this.hot=mf(),Reflect.set(globalThis,"__adsPreviewHot",this.hot),Reflect.set(globalThis,"__dsPreviewImport",(t)=>this.importModule(t))}register(e){if(e.schemaVersion!==1||!Array.isArray(e.scenarios)||!e.assets||typeof e.revision!=="string")throw Error("Unsupported preview manifest. Rebuild previews with the installed ADS version.");let t=e.refresh;if(t&&(!Rr(t)||t.version!==1||typeof t.epoch!=="string"||!t.epoch||t.epoch.length>100))throw Error("Unsupported preview refresh protocol. Reopen with the current ADS version.");let o=new Set,r=[];for(let[n,i]of Object.entries(e.assets)){let s=Tb(n,i,e,o);if(!s)throw Error("Invalid preview dependency graph.");if(s.hot)o.add(s.hot.id);if(this.records.has(n)&&this.records.get(n)?.digest!==s.digest)throw pi("An immutable preview resource changed its content. Rebuild previews with the current ADS version.",{code:"ADS_RESOURCE_IDENTITY",category:"build",resourceUri:n});r.push([n,s])}for(let[n,i]of r)this.records.set(n,i)}async resource(e){let t=this.bytes.get(e);if(!t)t=(async()=>{let o=this.records.get(e);if(!o)throw Error(`Unknown preview dependency: ${e}`);let r;try{r=await this.read(e)}catch(s){throw pi(`Preview resource read failed for ${e}: ${String(ff(s))}`,{code:"ADS_RESOURCE_READ",category:"transport",resourceUri:e},{cause:s})}if(this.closed)throw Error("The preview App was closed.");let n=r.contents.find((s)=>s.uri===e);if(!n)throw pi(`Missing preview dependency: ${e}`,{code:"ADS_RESOURCE_CONTENT",category:"build",resourceUri:e});let i=typeof n.text==="string"?new TextEncoder().encode(n.text):Uint8Array.from(atob(String(n.blob)),(s)=>s.charCodeAt(0));try{return await kb(o,i)}catch(s){throw Pb(s,e)}})(),this.bytes.set(e,t),t.catch(()=>this.bytes.delete(e));return t}closure(e){return Sf(this.records,e)}asset(e){let t=this.records.get(e);if(!t)throw Error(`Missing preview dependency metadata: ${e}`);return t}async prefetch(e,t){if(this.closed)return;this.register(e);let o=++this.prefetchGeneration,r=new Set,n=[],i=0;for(let u of t){let h=e.scenarios.find((S)=>S.id===u);if(!h)continue;let m=this.closure(kl(h)).filter((S)=>!this.bytes.has(S)&&!r.has(S)),f=m.reduce((S,y)=>S+this.asset(y).size,0);if(i+f>16777216||r.size+m.length>256)continue;i+=f,n.push(u);for(let S of m)r.add(S)}let s=[...r],c=0,l=async()=>{while(!this.closed&&o===this.prefetchGeneration&&c<s.length)await this.resource(s[c++]??"")};return await Promise.all(Array.from({length:Math.min(3,s.length)},l)),{scenarios:n,resources:s.length}}mapImports(e){if(!Object.keys(e).length)return;let t=document.createElement("script");t.type="importmap",t.textContent=JSON.stringify({imports:e}),document.head.append(t)}async materialize(e){let t=this.closure(e);await Promise.all(t.map((r)=>this.resource(r)));let o={};for(let r of t){if(this.closed)throw Error("The preview App was closed.");if(this.urls.has(r))continue;let n=this.asset(r),i=await this.resource(r);if(n.kind==="module"||n.mimeType==="text/css"||n.mimeType==="text/javascript"){let c=new TextDecoder().decode(i);for(let l of n.references){let u=this.urls.get(l);if(!u)throw Error("Unsupported cyclic asset reference.");c=c.replaceAll(l,u)}i=c}let s=URL.createObjectURL(new Blob([i],{type:n.mimeType}));if(this.urls.set(r,s),n.kind==="module")o[r]=s}return this.mapImports(o),t}async importModule(e){let t=this.importing.then(()=>this.materialize(e));this.importing=t.catch(()=>{});let o=await t;await this.attachStyles(o);try{let r=await import(e);this.loadedModules.add(e);for(let n of o){let i=this.records.get(n);if(i?.hot)this.executed.set(i.hot.id,{uri:n,record:i}),this.moduleHistory.add(n)}return Eb(r)}catch(r){throw Error(`Preview module import failed for ${e}: ${String(ff(r))}. Inspect the App resource bridge, browser network/CSP diagnostics and current build.`,{cause:r})}}async attachStyles(e){for(let t of e){if(this.records.get(t)?.mimeType!=="text/css")continue;if(this.styles.has(t)){await this.styleReady.get(t);continue}let r=document.createElement("link");r.rel="stylesheet",r.href=this.urls.get(t)??"",this.styles.set(t,r);let n=new Promise((i,s)=>{r.onload=i,r.onerror=()=>s(Error("The host CSP blocked a preview stylesheet."))});this.styleReady.set(t,n),document.head.append(r);try{await n}catch(i){throw r.remove(),this.styles.delete(t),this.styleReady.delete(t),i}}}async refreshStyles(e,t){let o=[e],r=new Set,n=new Set;for(let i of o){if(r.has(i))continue;r.add(i);for(let s of await this.materialize(i)){n.add(s);for(let c of this.asset(s).dynamicImports){let l=this.records.get(c)?.hot?.id;if(this.loadedModules.has(c)||l!==void 0&&this.executed.has(l))o.push(c)}}}if(await this.attachStyles([...n]),t!==this.generation||this.closed)return!1;for(let[i,s]of this.styles)if(!n.has(i))s.remove(),this.styles.delete(i),this.styleReady.delete(i);for(let i of n){let s=this.styles.get(i);if(s)document.head.append(s)}return!0}async mount(e,t,o){let r=++this.generation,n=this.mounting.then(()=>r!==this.generation||this.closed?!1:this.mountRevision(e,t,o,r));return this.mounting=n.catch(()=>{}),n}async mountRevision(e,t,o,r){this.register(e);let n=e.scenarios.find((b)=>b.id===t);if(!n)throw Error("The selected scenario is no longer registered.");let i=kl(n),s=JSON.stringify(this.closure(i).map((b)=>[b,this.records.get(b)])),c=new Map(this.closure(i).map((b)=>[b,this.records.get(b)])),l=(b)=>{throw pi(b,{code:"ADS_PREVIEW_REOPEN"})};if(this.refreshDirty)l("An interrupted module update requires a clean preview frame.");let u=[...this.urls.keys()].reduce((b,v)=>b+this.asset(v).size,0);if(this.records.size>4096||u>67108864)l("Reopen the preview to release retained module revisions.");let h=e.refresh;if(this.mounted&&gf(this.mounted.refresh)!==gf(h))l("The preview compiler changed. Reopening an isolated frame for its new runtime.");if(h&&this.mounted){let b=new Map(Object.keys(e.assets).map((z)=>[z,this.asset(z)])),v=new Map([...b].flatMap(([z,R])=>R.hot?[[R.hot.id,{uri:z,record:R}]]:[]));for(let[z,{record:R}]of this.executed){let M=v.get(z);if(M&&M.record.hot?.source!==R.hot?.source&&this.moduleHistory.has(M.uri))l("Restoring a previous module revision requires a clean preview frame.")}let k=new Map([...this.executed.values()].map(({uri:z,record:R})=>[z,R]));this.refreshDirty=!0;let U=await this.hot.update(k,b,(z)=>this.importModule(z),()=>r===this.generation&&!this.closed);if(r!==this.generation||this.closed)return!1;if(!U)l("This edit changes a refresh boundary. Reopening the preview with fresh component state.");this.refreshDirty=!1;for(let z of this.executed.keys()){let R=v.get(z);if(R)this.executed.set(z,R)}if(this.mounted.id===t){if(!await this.refreshStyles(i,r))return!1;return this.revisions.add(i),this.mounted={...this.mounted,signature:s,records:c,module:i},!0}}if(this.mounted?.id===t&&this.mounted.container===o&&this.mounted.signature===s)return this.refreshStyles(i,r);if(this.revisions.add(i),!h&&this.revisions.size>20)l("Reopen the preview to release retained module revisions.");let m=await this.importModule(i);if(r!==this.generation)return!1;let f=this.unmount;if(this.unmount=void 0,this.mounted=void 0,await f?.(),r!==this.generation||this.closed)return!1;if(o.replaceChildren(),!await this.refreshStyles(i,r))return!1;let S=m.mount;if(typeof S!=="function")throw Error("The compiled scenario has no mount adapter.");let y=S(o);if(typeof y!=="function")throw Error("The scenario mount adapter must return an unmount callback.");return this.unmount=()=>y(),this.mounted={id:t,container:o,signature:s,records:c,module:i,refresh:h},!0}async dispose(){if(this.closed)return;this.closed=!0,++this.generation,++this.prefetchGeneration,await this.mounting,await this.unmount?.(),await this.hot.dispose(),this.mounted=void 0;for(let e of this.styles.values())e.remove();for(let e of this.urls.values())URL.revokeObjectURL(e);if(this.styles.clear(),this.styleReady.clear(),this.urls.clear(),this.bytes.clear(),this.records.clear(),this.revisions.clear(),this.loadedModules.clear(),this.executed.clear(),this.moduleHistory.clear(),Reflect.deleteProperty(globalThis,"__dsPreviewImport"),Reflect.get(globalThis,"__adsPreviewHot")===this.hot)Reflect.deleteProperty(globalThis,"__adsPreviewHot")}}var $l="ads-preview-guide-options",yf="ads-preview-guide-state",$b=["off","hover","always"];var vx=Object.freeze({mode:"off",bounds:!0,tracks:!1,gaps:!1,padding:!0,margins:!0,mini:!1}),Cb=(e)=>$b.some((t)=>t===e),so=(e,t)=>typeof e==="object"&&e!==null?e[t]:void 0;function hi(e){let t=so(e,"mode");return{mode:Cb(t)?t:so(e,"all")===!0?"always":"off",bounds:so(e,"bounds")===!0,tracks:so(e,"tracks")===!0,gaps:so(e,"gaps")===!0,padding:so(e,"padding")===!0,margins:so(e,"margins")===!0,mini:so(e,"mini")===!0}}function bf(e){let{mode:t,...o}=hi(e);return{all:t==="always",...o}}function vf(e){let{mode:t,...o}=hi(e);return t!=="off"&&Object.values(o).some(Boolean)}var Ib={bounds:"bounds",content:"bounds",column:"tracks",row:"tracks",gap:"gaps",gutter:"gaps",margin:"margins",padding:"padding","mini-unit":"mini"},Cl=["Top","Right","Bottom","Left"],Ob=["paddingTop","paddingRight","paddingBottom","paddingLeft","marginTop","marginRight","marginBottom","marginLeft"],io=(e)=>typeof e==="object"&&e!==null,Mb=(e)=>io(e)&&typeof e.property==="string"&&typeof e.value==="string";function Ab(e){if(!io(e))return null;let t={},o={};for(let[r,n]of Object.entries(io(e.profiles)?e.profiles:{}))if(io(n)&&typeof n.miniUnit==="string"&&typeof n.miniUnitPx==="number")t[r]={miniUnit:n.miniUnit,miniUnitPx:n.miniUnitPx};for(let[r,n]of Object.entries(io(e.owners)?e.owners:{}))if(Array.isArray(n))o[r]=n.filter((i)=>typeof i==="string");return{profiles:t,owners:o}}function Nb(e){if(!io(e)||e.schemaVersion!==1||typeof e.source!=="string"||!Array.isArray(e.rules))return null;let t=e.rules.flatMap((o)=>{if(!io(o)||typeof o.selector!=="string"||!Array.isArray(o.declarations))return[];return[{selector:o.selector,declarations:o.declarations.filter(Mb)}]});return{source:e.source,rules:t}}function qb(e){let t=e.defaultView;if(!t)throw Error("The preview document has no window.");return t}function wf(e,{onDetails:t=()=>{}}={}){let o=e.ownerDocument,r=qb(o),n=(D)=>parseFloat(D)||0,i,s,c="",l,u=!1,h=[],m="components",f=null,S={},y=null,b=new Set,v=new r.ResizeObserver(M),k=new r.MutationObserver(M),U=(D)=>D instanceof r.Element?D:null,z=(D,ne)=>D instanceof r.HTMLElement?D[ne]:0,R=(D)=>D?.getAttribute("data-ads-source")??void 0;function M(){if(u&&!s)s=r.requestAnimationFrame(Qe)}function oe(D){let ne=U(D.target),be=ne?.closest("[data-ads-source]"),re=ne?.closest('button, summary, a[href], [role="button"]'),le=be&&e.contains(be)?re&&e.contains(re)?re:ne:null;if(f!==le)f=le,M()}function pe(){if(f)f=null,M()}function we(D){let ne=D.relatedTarget;if(!(ne instanceof r.Node&&e.contains(ne)))pe()}function de(D,ne){let be=y?.profiles??{},re=D.closest("[data-ads-profile]")?.getAttribute("data-ads-profile")??void 0,le=R(D.closest("[data-ads-source]")),je=re!==void 0?[re]:(le===void 0?void 0:y?.owners[le])??[],Ie=(je.length?je:Object.keys(be)).flatMap((se)=>{let J=be[se];return J?[J]:[]}),[Oe]=Ie;if(!Oe||new Set(Ie.map((se)=>`${se.miniUnit}:${se.miniUnitPx}`)).size!==1)return 0;let Z=ne.getPropertyValue(Oe.miniUnit).trim();return/^\d*\.?\d+px$/.test(Z)?n(Z):/^\d*\.?\d+rem$/.test(Z)?n(Z)*n(r.getComputedStyle(o.documentElement).fontSize):Oe.miniUnitPx}function Ne(D){let ne=R(D.closest("[data-ads-source]"));return h.filter((be)=>be.source===ne).flatMap((be)=>be.rules.filter((re)=>{try{return D.matches(re.selector)}catch{return!1}}).flatMap((re)=>re.declarations))}function Ve(){let D=[...e.querySelectorAll("[data-ads-source]")].filter((ne)=>{let be=ne.getBoundingClientRect();return be.width&&be.height});if(D.length)return D;return[...(e.querySelector(".ads-preview-root")??e).children].filter((ne)=>!["STYLE","SCRIPT","LINK","H1"].includes(ne.tagName))}let Be=()=>({width:o.documentElement.clientWidth,height:o.documentElement.clientHeight});function ot(D){let{width:ne,height:be}=Be(),re={left:0,top:0,right:ne,bottom:be};for(let le=D.parentElement;le;le=le.parentElement){let je=r.getComputedStyle(le),Ie=le.getBoundingClientRect(),Oe=le.offsetWidth?Ie.width/le.offsetWidth:1,Z=le.offsetHeight?Ie.height/le.offsetHeight:1;if(/(auto|scroll|hidden|clip)/.test(je.overflowX))re.left=Math.max(re.left,Ie.left+le.clientLeft*Oe),re.right=Math.min(re.right,Ie.left+(le.clientLeft+le.clientWidth)*Oe);if(/(auto|scroll|hidden|clip)/.test(je.overflowY))re.top=Math.max(re.top,Ie.top+le.clientTop*Z),re.bottom=Math.min(re.bottom,Ie.top+(le.clientTop+le.clientHeight)*Z)}return re}function Qe(){if(s=void 0,!u)return;let D=Ve();if(f&&!e.contains(f))f=null;let ne=S.all===!0?[...D]:f?[f]:[];if(S.all===!0)for(let Z of D)for(let se of Z.querySelectorAll("*")){if(se.closest("svg")||["STYLE","SCRIPT","LINK"].includes(se.tagName)||ne.includes(se))continue;let J=r.getComputedStyle(se);if(/grid|flex/.test(J.display)||Ob.some((ke)=>n(J[ke])!==0))ne.push(se)}if(f&&!ne.includes(f))ne.push(f);let be=ne.filter((Z)=>S.mini===!0||/\/components\//.test(R(Z.closest("[data-ads-source]"))??"")||m==="components"||m==="tokens"||m==="foundation"),re=new Set(be.filter((Z)=>!be.some((se)=>se!==Z&&se.contains(Z)))),le=[],je=new Set([e]),Ie=[];for(let Z of ne){let se=r.getComputedStyle(Z),J=Z.getBoundingClientRect(),ke=ot(Z);if(!J.width||!J.height||J.right<=ke.left||J.left>=ke.right||J.bottom<=ke.top||J.top>=ke.bottom)continue;je.add(Z);let ht=z(Z,"offsetWidth"),I=z(Z,"offsetHeight"),A=ht?J.width/ht:1,B=I?J.height/I:1,X=Cl.map((Re)=>n(se[`border${Re}Width`])),ve=Cl.map((Re)=>n(se[`padding${Re}`])),_e=Cl.map((Re)=>n(se[`margin${Re}`])),[Pe=0,Le=0,ye=0,ze=0]=X,[P=0,We=0,j=0,N=0]=ve,G=J.left+(ze+N)*A,O=J.top+(Pe+P)*B,x=J.width-(Le+ze+We+N)*A,Y=J.height-(Pe+ye+P+j)*B,W=o.createElement("div");W.dataset.adsSpatialSource=R(Z)??"measured-box",Object.assign(W.style,{position:"fixed",inset:"0",clipPath:`inset(${ke.top}px ${Math.max(0,Be().width-ke.right)}px ${Math.max(0,Be().height-ke.bottom)}px ${ke.left}px)`});let ge=(Re,ue,ce,he,ie,ee,Me=!1)=>{if(ce<=0||he<=0||S[Ib[ie]]===!1)return;let Ee=o.createElement("div");return Ee.dataset.adsGuide=ie,Object.assign(Ee.style,{position:"absolute",left:`${Re}px`,top:`${ue}px`,width:`${ce}px`,height:`${he}px`,boxSizing:"border-box",...Me?{border:`1px solid ${ee}`}:{background:ee}}),W.append(Ee),Ee};if(ge(J.left,J.top,J.width,J.height,"bounds","rgb(70 120 250 / .75)",!0),re.has(Z)){let Re=de(Z,se);if(Re>0){let ue=r.devicePixelRatio||1,ce=Math.floor(J.left*ue),he=Math.floor(J.top*ue),ie=Math.ceil(J.right*ue)-ce,ee=Math.ceil(J.bottom*ue)-he,Me=ge(ce/ue,he/ue,ie/ue,ee/ue,"mini-unit","transparent");if(Me&&ie>0&&ee>0){Me.dataset.adsUnit=`${Re}`,Me.dataset.adsMajor=`${Re*2}`;let Ee=o.createElement("canvas");Ee.width=ie,Ee.height=ee,Object.assign(Ee.style,{display:"block",width:`${ie/ue}px`,height:`${ee/ue}px`,imageRendering:"pixelated"});let Je=Ee.getContext("2d");if(Je){let it=[Re*A*ue,Re*B*ue];for(let Ue=0;;Ue++){let Xe=Math.round(J.left*ue+Ue*it[0])-ce;if(Xe>=ie)break;Je.fillStyle=Ue%2?"#617dba14":"#617dba38",Je.fillRect(Xe,0,1,ee)}for(let Ue=0;;Ue++){let Xe=Math.round(J.top*ue+Ue*it[1])-he;if(Xe>=ee)break;Je.fillStyle=Ue%2?"#617dba14":"#617dba38",Je.fillRect(0,Xe,ie,1)}}Me.append(Ee)}}}let zt=(Re,ue,ce,he)=>{let[ie=0,ee=0,Me=0,Ee=0]=Re.map((Zt,Ht)=>Math.max(0,Zt)*(Ht%2?A:B)),Je=ue?J.left-Ee:J.left+ze*A,it=ue?J.top-ie:J.top+Pe*B,Ue=ue?J.width+Ee+ee:J.width-(Le+ze)*A,Xe=ue?J.height+ie+Me:J.height-(Pe+ye)*B;ge(Je,it,Ue,ie,ce,he),ge(Je,it+Xe-Me,Ue,Me,ce,he),ge(Je,it+ie,Ee,Xe-ie-Me,ce,he),ge(Je+Ue-ee,it+ie,ee,Xe-ie-Me,ce,he)};if(zt(_e,!0,"margin","rgb(234 149 43 / .2)"),m!=="mocks"||f===Z||S.padding===!0)zt(ve,!1,"padding","rgb(55 186 130 / .22)");let mt=Ne(Z);if(se.display.includes("grid")){let Re=(ue,ce)=>{let he=ue.replace(/\[[^\]]*\]/g,"").trim().split(/\s+/);if(!he.length||!he.every((Je)=>/^\d*\.?\d+px$/.test(Je)))return;let ie=he.map(n),ee=n(ce==="columns"?se.columnGap:se.rowGap)*(ce==="columns"?A:B),Me=ce==="columns"&&se.direction==="rtl",Ee=ce==="columns"?Me?G+x:G:O;W.dataset[ce==="columns"?"adsGridColumns":"adsGridRows"]=String(ie.length),ie.forEach((Je,it)=>{let Ue=Je*(ce==="columns"?A:B);if(Me)Ee-=Ue;if(ge(ce==="columns"?Ee:G,ce==="columns"?O:Ee,ce==="columns"?Ue:x,ce==="columns"?Y:Ue,ce==="columns"?"column":"row","rgb(200 66 135 / .35)",!0),Ee+=Me?0:Ue,it<ie.length-1)ge(ce==="columns"?Me?Ee-ee:Ee:G,ce==="columns"?O:Ee,ce==="columns"?ee:x,ce==="columns"?Y:ee,"gap","rgb(200 66 135 / .12)");Ee+=Me?-ee:ee})};if(Re(se.gridTemplateColumns,"columns"),mt.some((ue)=>ue.property==="grid-template-rows"&&ue.value!=="none"))Re(se.gridTemplateRows,"rows");for(let ue of Z.children){let ce=r.getComputedStyle(ue),he=ue.getBoundingClientRect();if(ce.display==="none"||!he.width||!he.height)continue;let ie=n(ce.marginLeft)*A,ee=n(ce.marginRight)*A;ge(he.left-ie,he.top,ie,he.height,"gutter","rgb(200 66 135 / .16)"),ge(he.right,he.top,ee,he.height,"gutter","rgb(200 66 135 / .16)")}}if(se.display.includes("flex")||m==="mocks"){let Re=[...Z.children].filter((ue)=>{let ce=ue.getBoundingClientRect();return ce.width&&ce.height});for(let ue of Re){je.add(ue);let ce=ue.getBoundingClientRect();ge(ce.left,ce.top,ce.width,ce.height,"content","rgb(70 120 250 / .5)",!0)}Re.forEach((ue,ce)=>{let he=Re[ce-1];if(!he)return;let ie=he.getBoundingClientRect(),ee=ue.getBoundingClientRect();if(ee.top>=ie.bottom)ge(Math.max(ie.left,ee.left),ie.bottom,Math.min(ie.right,ee.right)-Math.max(ie.left,ee.left),ee.top-ie.bottom,"gap","rgb(200 66 135 / .16)");else if(ee.left>=ie.right)ge(ie.right,Math.max(ie.top,ee.top),ee.left-ie.right,Math.min(ie.bottom,ee.bottom)-Math.max(ie.top,ee.top),"gap","rgb(200 66 135 / .16)");else if(ie.left>=ee.right)ge(ee.right,Math.max(ie.top,ee.top),ie.left-ee.right,Math.min(ie.bottom,ee.bottom)-Math.max(ie.top,ee.top),"gap","rgb(200 66 135 / .16)")})}if(le.push(W),f===Z){let Re=[...new Set(mt.flatMap((ue)=>ue.value.match(/--[\w-]+/g)??[]))];Ie.push({label:Z.getAttribute("aria-label")??Z.getAttribute("role")??Z.tagName.toLowerCase(),width:Math.round(J.width*10)/10,height:Math.round(J.height*10)/10,display:se.display,padding:ve,margin:_e,rowGap:se.rowGap,columnGap:se.columnGap,tokens:Re})}}for(let Z of b)if(!je.has(Z))v.unobserve(Z),b.delete(Z);for(let Z of je)if(!b.has(Z))v.observe(Z),b.add(Z);let[Oe]=Ie;if(Oe){l=f??void 0;let Z=JSON.stringify(Oe);if(Z!==c)c=Z,t(Oe)}else if(l&&!e.contains(l))te();i?.replaceChildren(...le)}function te(){l=void 0,c="",t(null)}function fe(D){if(u===D){M();return}if(u=D,D)i=o.createElement("div"),i.id="ads-grid-overlay",i.setAttribute("aria-hidden","true"),i.style.cssText="position:fixed;inset:0;z-index:2147483646;pointer-events:none;overflow:hidden",o.body.append(i),k.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),k.observe(o.documentElement,{attributes:!0}),e.addEventListener("pointermove",oe,{passive:!0}),e.addEventListener("pointerleave",pe),e.addEventListener("focusin",oe),e.addEventListener("focusout",we),r.addEventListener("resize",M),o.addEventListener("scroll",M,!0),M();else{if(s!==void 0)r.cancelAnimationFrame(s);s=void 0,v.disconnect(),b.clear(),k.disconnect(),e.removeEventListener("pointermove",oe),e.removeEventListener("pointerleave",pe),e.removeEventListener("focusin",oe),e.removeEventListener("focusout",we),r.removeEventListener("resize",M),o.removeEventListener("scroll",M,!0),i?.remove(),i=void 0,f=null,te()}}return{setVisible:fe,setGuides(D){S=io(D)?D:{},M()},setMetadata(D,ne,be=null){h=D.flatMap((re)=>{let le=Nb(re);return le?[le]:[]}),m=ne,y=Ab(be),f=null,te(),M()},dispose(){fe(!1)}}}function jb(e){let t=e instanceof HTMLElement?Number(e.dataset.adsStageInset??""):Number.NaN;return Number.isFinite(t)&&t>=0&&e instanceof HTMLElement&&e.dataset.adsStageInset!==void 0?t:null}function Lb(e){let t=e.defaultView;if(!t)throw Error("The preview document has no window.");return t}function Ub(e){let t=e.map((o)=>({...o}));for(let o=!0;o;){o=!1;e:for(let r=0;r<t.length;r++)for(let n=r+1;n<t.length;n++){let i=t[r],s=t[n];if(i&&s&&i.left<=s.right&&s.left<=i.right&&i.top<=s.bottom&&s.top<=i.bottom){t[r]={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)},t.splice(n,1),o=!0;break e}}}return t}function zf(e,{decorate:t=!0}={}){let o=e.ownerDocument,r=Lb(o),n=null,i=null,s=null,c=0,l=null,u=new r.ResizeObserver(()=>k()),h=new r.MutationObserver(()=>U()),m=new r.MutationObserver(()=>k()),f=()=>k();function S(){if(l?.remove(),l=null,s)delete s.dataset.adsStaged,delete s.dataset.adsSubjectOnly}function y(z){if(z===s)return;if(s?.removeEventListener("scroll",f),u.disconnect(),S(),s=z,!s)return;s.addEventListener("scroll",f,{passive:!0}),u.observe(s)}function b(){let z=e.querySelector(":scope > .ads-preview-root");y(z instanceof r.HTMLElement?z:null);let R=s&&n?[...s.querySelectorAll(n)]:[],M=R.filter((de)=>!R.some((Ne)=>Ne!==de&&Ne.contains(de))),[oe]=M,pe=M.length===1&&oe?oe.parentElement:null,we=s!==null&&pe!==null&&(pe===s||pe.parentElement===s&&pe.children.length===1)&&[...s.children].every((de)=>de===l||de===pe||de===oe);return s?.toggleAttribute("data-ads-subject-only",we),M}function v(){c=0;let z=b();if(!t||!s||s.hasAttribute("data-ads-subject-only")){if(l?.remove(),l=null,s)delete s.dataset.adsStaged;return}let R=s,M=new Set(["SPAN","STRONG","EM","B","I","SMALL","CODE","LABEL","ABBR"]),oe=(te)=>M.has(te.tagName)&&!z.includes(te)&&te.querySelector("*")===null&&Boolean(te.textContent?.trim()),pe=(te)=>{let fe=te.parentElement;if(!fe||fe===R)return te;if(fe.children.length===1)return[...fe.childNodes].some((re)=>re.nodeType===3&&re.textContent?.trim())?fe:te;let D=[...fe.children].filter((re)=>re!==te),ne=r.getComputedStyle(fe);return(ne.display.includes("flex")&&!ne.flexDirection.startsWith("column")||ne.display.startsWith("inline"))&&D.some(oe)&&D.every((re)=>oe(re)||z.includes(re))?fe:te},we=Ub(z.map(pe).flatMap((te)=>{u.observe(te,{box:"border-box"});let fe=te.getBoundingClientRect(),D=i&&te.matches(i)?0:jb(te)??16;return fe.width&&fe.height?[{left:fe.left-D,top:fe.top-D,right:fe.right+D,bottom:fe.bottom+D}]:[]}));if(!we.length){S();return}let de=R.getBoundingClientRect(),Ne=de.left+R.clientLeft,Ve=de.top+R.clientTop,Be={left:Ne,top:Ve,right:Ne+R.clientWidth,bottom:Ve+R.clientHeight};if(!l||l.parentElement!==R)l?.remove(),l=o.createElement("div"),l.dataset.adsSubjectStage="",l.setAttribute("aria-hidden","true"),Object.assign(l.style,{position:"fixed",inset:"0",pointerEvents:"none",background:"var(--bg-canvas, Canvas)",zIndex:"-1"}),R.prepend(l);R.dataset.adsStaged="";let ot=we.map((te)=>({left:Math.max(te.left,Be.left),top:Math.max(te.top,Be.top),right:Math.min(te.right,Be.right),bottom:Math.min(te.bottom,Be.bottom)})).filter((te)=>te.right>te.left&&te.bottom>te.top),Qe=(te)=>`M${te.left} ${te.top}H${te.right}V${te.bottom}H${te.left}Z`;l.style.clipPath=ot.length?`path("${ot.map(Qe).join("")}")`:"inset(50%)",l.dataset.adsStages=String(we.length)}function k(){if(!c)c=r.requestAnimationFrame(v)}function U(){b(),k()}return h.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","hidden","open","data-ads-source"]}),m.observe(o.documentElement,{attributes:!0,attributeFilter:["data-theme","data-brand"]}),r.addEventListener("resize",k),{setSubjectSelector(z,R=null){n=z||null,i=R,U()},refresh:U,dispose(){if(h.disconnect(),m.disconnect(),c)r.cancelAnimationFrame(c);r.removeEventListener("resize",k),y(null),S(),n=null,i=null}}}var ut=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof Map);var Rf=/^[a-f0-9]{64}$/,Db=/^ads:\/\/assets\/[a-f0-9]{64}\.[a-z0-9]+$/;var Zb=["react","preact"],Hb=["imports","dynamicImports","styles","references"];function Fb(e){if(!ut(e)||e.schemaVersion!==1||!Zb.includes(e.framework)||!Rf.test(String(e.revision))||!ut(e.assets)||!Array.isArray(e.scenarios))throw Error("Invalid preview manifest update.");let t=e.assets,o=new Set;for(let r of e.scenarios){let n=ut(r)?r.id:void 0,i=ut(r)?r.module:void 0,s=typeof i==="string"?t[i]:void 0;if(typeof n!=="string"||o.has(n)||!ut(s)||s.kind!=="module")throw Error("Invalid updated preview scenarios.");o.add(n)}for(let[r,n]of Object.entries(t))if(!Db.test(r)||!ut(n)||!Hb.every((i)=>{let s=n[i];return Array.isArray(s)&&s.every((c)=>typeof c==="string"&&Object.hasOwn(t,c))}))throw Error("Invalid updated preview dependencies.")}function Il(e){return Fb(e),e}function xf(e,t){if(!ut(e)||e.version!==1)throw Error("Unsupported preview manifest update.");if(e.type==="full")return Il(e.manifest);if(!t||e.baseRevision!==t.revision)throw Error("Preview manifest update base does not match.");let o=e.header;if(!ut(o)||Object.hasOwn(o,"assets")||Object.hasOwn(o,"scenarios")||!Rf.test(String(o.revision)))throw Error("Invalid preview manifest update header.");if(e.type==="unchanged"){if(o.revision!==t.revision)throw Error("Unchanged preview revision does not match.");return Il({...o,assets:t.assets,scenarios:t.scenarios})}let{assets:r,scenarios:n}=e,i=ut(r)?r.upsert:void 0,s=ut(r)?r.remove:void 0,c=ut(n)?n.upsert:void 0,l=ut(n)?n.remove:void 0;if(e.type!=="delta"||!i||!Array.isArray(s)||!Array.isArray(c)||!Array.isArray(l))throw Error("Invalid preview manifest delta.");let u=new Map(Object.entries(t.assets)),h=new Map(t.scenarios.map((y)=>[y.id,y]));for(let y of s)if(typeof y!=="string"||!u.delete(y))throw Error("Unknown removed preview asset.");let m=Object.entries(i);for(let[y,b]of m)u.set(y,b);for(let y of l)if(!h.delete(y))throw Error("Unknown removed preview scenario.");let f=new Set;for(let y of c){let b=ut(y)?y.id:void 0;if(!y||f.has(b))throw Error("Duplicate updated preview scenario.");f.add(b),h.set(b,y)}let S=(ut(n)?n.order:void 0)??t.scenarios.map((y)=>y.id);if(!Array.isArray(S)||S.length!==h.size||new Set(S).size!==S.length||S.some((y)=>!h.has(y)))throw Error("Invalid updated preview scenario order.");return Il({...o,assets:Object.fromEntries(u),scenarios:S.map((y)=>h.get(y))})}var Pf=(e,t)=>typeof e==="object"&&e!==null?Reflect.get(e,t):void 0;function Vb(e){let t=e.contents.find((o)=>typeof o.text==="string")?.text;if(t===void 0)throw Error("The preview manifest resource has no text.");return JSON.parse(t)}function Ef(e){let t=new Map,o=new Map,r=0,n,i=0,s=0,c=!0;function l(u){t.delete(u.revision),t.set(u.revision,{graph:u,size:new TextEncoder().encode(JSON.stringify(u)).byteLength});let h=[...t.values()].reduce((m,f)=>m+f.size,0);while(t.size>6||h>8388608){let[m]=t;if(!m)break;h-=m[1].size,t.delete(m[0])}}return{clear(){r++,t.clear(),o.clear(),n=void 0,c=!0},async get(u,{revision:h,session:m}={}){let f=h?t.get(h)?.graph:void 0;if(f&&(!m||f.session===m))return{...f,transportManifestUri:u};let S=n,y=r,b=JSON.stringify([u,h,m,S?.revision]),v=o.get(b);if(!v){let k=++i,U=(async()=>{let z;if(S&&c)try{z=await e(u+"?from="+S.revision)}catch(pe){if(Pf(pe,"code")!==-32002&&!/unknown (?:ADS )?resource|resource not found/i.test(String(Pf(pe,"message"))))throw pe;if(y===r)c=!1;z=await e(u)}else z=await e(u);let R=Vb(z),M=typeof R==="object"&&R!==null&&Boolean(Reflect.get(R,"type")),oe=xf(M?R:{version:1,type:"full",manifest:R},S);if(y===r){if(l(oe),k>=s)n=oe,s=k}return oe})();o.set(b,U),U.then(()=>{if(o.get(b)===U)o.delete(b)},()=>{if(o.get(b)===U)o.delete(b)}),v=U}return{...await v,transportManifestUri:u}}}}var Ml=(e)=>typeof e==="object"&&e!==null,Ol=(e)=>Ml(e)?e:{},me=(e,t)=>Ml(e)?e[t]:void 0,xr=(e)=>typeof e==="string"?e:void 0,kf=(e)=>({message:xr(me(e,"message"))??"",code:me(e,"code"),category:me(e,"category"),resourceUri:me(e,"resourceUri")});function Tf(e){let t=document.getElementById(e);if(!t)throw Error(`The preview document has no #${e}.`);return t}async function $f(e,t=(o)=>new Tl(o)){let o=Tf("root"),r=Tf("ads-preview-status"),n=document.documentElement,i,s=async(I)=>{if(!e.getHostCapabilities()?.serverResources)throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");try{return await e.readServerResource({uri:i?i+encodeURIComponent(I):I},{timeout:15000})}catch(A){if(me(A,"code")===-32601||me(A,"message")==="Method not found")throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");throw A}},c=t(s),l=Ef(s);n.dataset.adsPreviewDelivery=e.delivery??"mcp-blob";let u,h,m,f,S,y=!1,b,v=0,k={},U=[],z=!1,R,M,oe=new Set;function pe(I){if(e.getHostVersion()?.name!=="ADS showcase")return;let A=M;if(M=I,!A)return;let B=_f(A,I).filter((X)=>X!==u&&oe.has(X));if(!B.length)return;c.prefetch(I,B).then((X)=>de("prefetched",{revision:I.revision,...X})).catch((X)=>console.warn("ADS preview prefetch",me(X,"message")))}function we(I,A=!1){r.textContent=I,r.hidden=!I||e.getHostVersion()?.name==="ADS showcase",r.setAttribute("role",A?"alert":"status")}async function de(I,A={}){try{if(e.getHostCapabilities()?.logging)await e.sendLog({level:I==="error"?"error":"info",logger:"ads-preview",data:{state:I,id:u,...A}})}catch{}}let Ne=!1,Ve=wf(o),Be=zf(o,{decorate:Reflect.get(globalThis,"__ADS_RENDER_AUDIT__")!==!0}),ot={foundation:'.ads-grid-example, .ads-grid-unit, [data-slot="sample"][data-ads-specimen]',tokens:'[data-slot="sample"][data-ads-specimen]:not([data-ads-specimen="value"])',profiles:'[data-slot="sample"][data-ads-specimen]:not([data-ads-specimen="value"]):not([data-ads-specimen="motion"]):not([data-ads-specimen="applied"]), .ds-motion-track, .ds-applied-sample',assets:'[data-slot="sample"]:not(:empty), .icons-set, .icons-mag, .icons-sizes'},Qe='[data-slot="specimen"]:not([data-frame="screen"])',te=".ads-preview-root[data-ads-bare] > :not([data-ads-subject-stage])";function fe(I){let A=Ol(I);k={...k,...A,styles:{...Ol(k.styles),...Ol(A.styles)}};let B=k.theme,X=k.adsTheme??(B==="light"||B==="dark"?me(U.find((_e)=>me(_e,"scheme")===B)??{name:B},"name"):void 0);if(X)n.dataset.theme=String(X);if(k.adsChoices==="host")n.dataset.adsChoices="host";let ve=k.adsBrand;if(typeof ve==="string"&&/^[a-z][a-z0-9-]*$/.test(ve))n.dataset.brand=ve;Ve.setGuides(k.gridGuides),Ve.setVisible(Ne&&k.gridOverlay===!0),le(),Z(),be()}let D;function ne(I){if(I===D)return;if(D=I,I===void 0){Reflect.deleteProperty(globalThis,"__ADS_SCENARIO_STATE__");return}Reflect.set(globalThis,"__ADS_SCENARIO_STATE__",I),document.dispatchEvent(new CustomEvent("ads-scenario-state",{detail:{state:I}}))}function be(){if(!("adsState"in k))return;let I=k.adsState;ne(typeof I==="string"?I:void 0)}let re=(I)=>{let A=me(I instanceof CustomEvent?I.detail:void 0,"state");if(typeof A!=="string")return;D=A,Reflect.set(globalThis,"__ADS_SCENARIO_STATE__",A),de("scenario-state",{name:A})};document.addEventListener("ads-scenario-state-chosen",re);function le(){document.dispatchEvent(new CustomEvent(yf,{detail:hi(k.gridGuideChoices??k.gridGuides)}))}function je(I){let A=I instanceof CustomEvent?I.detail:void 0;if(!A){le();return}let B=hi(A);fe({gridGuideChoices:B,gridGuides:bf(B),gridOverlay:vf(B)}),de("guide-options",{options:B})}document.addEventListener($l,je);let Ie=(I)=>{let A=I instanceof CustomEvent?I.detail:void 0,B=me(A,"target");if(typeof B==="string")de("navigate",{target:B,token:me(A,"token")})};document.addEventListener("ads-preview-navigate",Ie);let Oe;function Z(){let I=k.adsFocus;if(!Ml(I)||I.nonce===Oe||I.target!==u||n.dataset.adsPreviewState!=="ready")return;Oe=I.nonce,document.dispatchEvent(new CustomEvent("ads-preview-focus",{detail:{token:I.token}}))}async function se(I="ads://preview/manifest",A,B){try{return await(c.manifest?c.manifest(I,{revision:A,session:B,scenario:u}):l.get(I,{revision:A,session:B}))}catch(X){throw Object.assign(Error(xr(me(X,"message")),{cause:X}),{code:"ADS_MANIFEST_READ",category:"transport"})}}async function J(I,A,B=!1,X="",ve=!1,_e){let Pe=B||ve;if(!X&&I===u&&A&&A===m&&(!_e||_e===f)&&Pe===z){we(Pe?"Checking changes…":""),await de(Pe?"checking":"ready",{revision:m});return}let Le=++v;++c.generation,u=I,Ne=!1,Ve.setVisible(!1),oe.add(I),n.dataset.adsScenario=I,n.dataset.adsPreviewState="loading";for(let ye of["adsPreviewErrorCategory","adsPreviewErrorCode","adsPreviewResourceUri"])delete n.dataset[ye];we(""),await de(X?"reverting":"loading");try{let ye=performance.now(),ze=await se(B?"ads://preview/live":"ads://preview/manifest",A,_e);if(Le!==v)return;let P=ze.themes;if(Array.isArray(P))U=P,fe({});if(A&&ze.revision!==A||_e&&ze.session!==_e){if(Le===v)we("Updating preview…"),await de("loading",{code:"ADS_PREVIEW_CHANGED"});return}if(Le!==v)return;let We=performance.now();performance.measure("ads-preview:manifest",{start:ye,end:We});let j=await c.mount(ze,I,o);if(performance.measure("ads-preview:load-mount",{start:We,end:performance.now()}),!j||Le!==v)return;let G=ze.scenarios.find((x)=>x.id===I)?.kind;o.dataset.adsScenarioKind=String(G??"");let O=typeof G==="string"&&Object.hasOwn(ot,G)?ot[G]:void 0;if(O!==void 0)Be.setSubjectSelector(O,".ads-grid-example");else Be.setSubjectSelector(`${Qe}, ${te}`,Qe);if(m=ze.revision,f=ze.session,z=Pe,await new Promise((x)=>requestAnimationFrame(()=>requestAnimationFrame(x))),await document.fonts.ready,Le!==v)return;if(Ne=G==="components"||G==="patterns"||G==="mocks"||G==="foundation",Ve.setMetadata(Object.values(ze.assets).flatMap((x)=>x.spatial?[x.spatial]:[]),G,ze.spatial),fe({}),o.dataset.adsPaintBindings="[]",o.dataset.adsPaintAudit="false",o.dataset.adsPaintAuditComplete="not-requested",Le===v){if(n.dataset.adsPreviewRevision=m,n.dataset.adsPreviewState=X?"error":Pe?"checking":"ready",we(X||(Pe?"Checking changes…":""),Boolean(X)),await de(X?"error":Pe?"checking":"ready",{revision:m,selectionRevision:h,...X?{message:X}:{}}),!Pe&&!X)pe(ze)}if(Le===v)Oe=void 0,Z()}catch(ye){if(Le===v){let{message:ze,code:P,category:We,resourceUri:j}=kf(ye);if(n.dataset.adsPreviewState="error",n.dataset.adsPreviewErrorCategory=String(We??"runner"),n.dataset.adsPreviewErrorCode=String(P??"ADS_PREVIEW_STARTUP"),j)n.dataset.adsPreviewResourceUri=String(j);we(ze,!0),await de("error",{message:ze,...P?{code:P}:{},...We?{category:We}:{},...j?{resourceUri:j}:{}})}}}async function ke(I){if(!u)return;if(document.visibilityState==="hidden"){if(I)b=I;return}if(y){if(I)b=I;return}y=!0;let A=v;try{let B=I??JSON.parse((await s("ads://project/build")).contents.find((ye)=>typeof ye.text==="string")?.text??"");if(A!==v)return;R=void 0;let X=me(B,"previews");if(!Array.isArray(X))throw Error("The build report lists no previews.");let ve=X.find((ye)=>me(ye,"id")===u),_e=me(B,"session"),Pe=xr(me(B,"manifestRevision")),Le=me(ve,"live");if(Le&&!me(ve,"current")){let ye=xr(me(Le,"revision"));if(ye!==m||_e!==f||!z)await J(u,ye,!0,"",!1,_e);else we("Checking changes…")}else if(!ve||!me(ve,"current")){let ye=me(ve,"diagnostics"),ze=Array.isArray(ye)?me(ye[0],"message"):void 0;if(ze&&z){let P=await se("ads://preview/manifest",Pe,_e);await J(u,P.revision,!1,`Build failed. Showing the previous preview.
|
|
109
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:a().optional().describe("User's language and region preference in BCP 47 format."),timeZone:a().optional().describe("User's timezone in IANA format."),userAgent:a().optional().describe("Host application identifier."),platform:C([p("web"),p("desktop"),p("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:d({touch:T().optional().describe("Whether the device supports touch input."),hover:T().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:d({top:w().describe("Top safe area inset in pixels."),right:w().describe("Right safe area inset in pixels."),bottom:w().describe("Bottom safe area inset in pixels."),left:w().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),bb=d({method:p("ui/notifications/host-context-changed"),params:pf.describe("Partial context update containing only changed fields.")}),mx=d({method:p("ui/update-model-context"),params:d({content:g(Tt).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:E(a(),L().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),fx=d({method:p("ui/initialize"),params:d({appInfo:Et.describe("App identification (name and version)."),appCapabilities:gb.describe("Features and capabilities this app provides."),protocolVersion:a().describe("Protocol version this app supports.")})}),vb=d({protocolVersion:a().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Et.describe("Host application identification and version."),hostCapabilities:fb.describe("Features and capabilities provided by the host."),hostContext:pf.describe("Rich context about the host environment.")}).passthrough(),wb={target:"draft-2020-12"};async function af(e,t){let o=e["~standard"];if(o.jsonSchema)return o.jsonSchema[t](wb);throw Error(`Schema (vendor: ${o.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function cf(e,t,o=""){let r=await e["~standard"].validate(t);if(r.issues){let n=r.issues.map((i)=>{let s=i.path?.map((c)=>typeof c==="object"?c.key:c).join(".");return s?`${s}: ${i.message}`:i.message}).join("; ");throw Error(o+n)}return r.value}function zb(e,t){let o={...e,...t};if(t.experimental!==void 0)o.experimental={...e.experimental,...t.experimental};if(t.tools!==void 0)o.tools={...e.tools,...t.tools};return o}class La extends li{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new lf;_methods=new uf;setRequestHandler=(...e)=>{let[t,...o]=nf("request",e)??e;this._methods.claim(t,"setRequestHandler"),super.setRequestHandler.call(this,t,...o)};setNotificationHandler=(...e)=>{let[t,...o]=nf("notification",e)??e;this._methods.claim(t,"setNotificationHandler"),super.setNotificationHandler.call(this,t,...o)};removeRequestHandler=(e)=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=(e)=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:cb,toolinputpartial:lb,toolresult:yb,toolcancelled:ub,hostcontextchanged:bb};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!La.ONE_SHOT_EVENTS.has(e)||this._everHadListener.has(e))return;if(this._everHadListener.add(e),!this._initializedSent)return;let t=`[ext-apps] "${String(e)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(t);console.warn(t)}setEventHandler(e,t){if(t)this._assertHandlerTiming(e);this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},(o)=>{let r=o;if(e==="hostcontextchanged")this._hostContext={...this._hostContext,...r};this._events.dispatch(e,r)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,o){if(t&&o)console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},o={autoResize:!0}){super(o);if(this._appInfo=e,this._appCapabilities=t,this.options=o,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!o.allowUnsafeEval)ct({jitless:!0});this.replaceRequestHandler("ping",(r)=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=zb(this._appCapabilities,e)}registerTool(e,t,o){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,n=()=>{if(r._initializedSent&&r._appCapabilities.tools?.listChanged)r.sendToolListChanged()},i=t.inputSchema!==void 0,s={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,n()},disable(){this.enabled=!1,n()},update(c){Object.assign(this,c),n()},remove(){if(r._registeredTools[e]!==s)return;delete r._registeredTools[e],n()},handler:async(c,l)=>{if(!s.enabled)throw Error(`Tool ${e} is disabled`);let u;if(i){let h=s.inputSchema,m=h?await cf(h,c??{},`Invalid input for tool ${e}: `):c??{};u=await o(m,l)}else u=await o(l);if(s.outputSchema&&!u.isError)u.structuredContent=await cf(s.outputSchema,u.structuredContent,`Invalid output for tool ${e}: `);return u}};if(this._registeredTools[e]=s,!this._appCapabilities.tools&&!this.transport)this.registerAppCapabilities({tools:{listChanged:!0}});return this.ensureToolHandlersInitialized(),n(),s}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){if(this._toolHandlersInitialized)return;this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let o=this._registeredTools[e.name];if(!o)throw Error(`Tool ${e.name} not found`);return o.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,r])=>r.enabled).map(async([o,r])=>{let n={name:o,title:r.title,description:r.description,inputSchema:r.inputSchema?await af(r.inputSchema,"input"):{type:"object",properties:{}}};if(r.outputSchema)n.outputSchema=await af(r.outputSchema,"output");if(r.annotations)n.annotations=r.annotations;if(r._meta)n._meta=r._meta;return n}))})}async sendToolListChanged(e={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(e){this.setEventHandler("toolinput",e)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(e){this.setEventHandler("toolinputpartial",e)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(e){this.setEventHandler("toolresult",e)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(e){this.setEventHandler("toolcancelled",e)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(e){this.setEventHandler("hostcontextchanged",e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,e),this._onteardown=e,this.replaceRequestHandler("ui/resource-teardown",{params:hb.shape.params,result:mb},(t,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(t,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler("tools/call",(t,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(t.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler("tools/list",(t,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(t.params,o)})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized("callServerTool"),typeof e==="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},t)}async listServerResources(e,t){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:e},t)}sendMessage(e,t){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:e},ab,t)}sendLog(e){return this.notification({method:"notifications/message",params:e})}updateModelContext(e,t){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:e},Xt,t)}openLink(e,t){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},sb,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},ib,t)}requestTeardown(e={}){return this.notification({method:"ui/notifications/request-teardown",params:e})}requestDisplayMode(e,t){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:e},Sb,t)}sendSizeChanged(e){return this.notification({method:"ui/notifications/size-changed",params:e})}setupSizeChangedNotifications(){let e=!1,t=0,o=0,r=()=>{if(e)return;e=!0,requestAnimationFrame(()=>{e=!1;let i=document.documentElement,s=i.style.height;i.style.height="max-content";let c=Math.ceil(i.getBoundingClientRect().height);i.style.height=s;let l=Math.ceil(window.innerWidth);if(l!==t||c!==o)t=l,o=c,this.sendSizeChanged({width:l,height:c})})};r();let n=new ResizeObserver(r);return n.observe(document.documentElement),n.observe(document.body),()=>n.disconnect()}async connect(e=new df(window.parent,window.parent),t){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(e);let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:eb}},vb,t);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);if(this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize)this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}}var Rb=(e)=>typeof e==="object"&&e!==null,hf=(e)=>new Map([...e].flatMap(([t,o])=>o.hot?[[o.hot.id,{uri:t,source:o.hot.source,record:o}]]:[]));function mf(){let e=new Map,t=new Set,o=!1,r;function n(s){let l={data:e.get(s)?.data??{},callbacks:[],listeners:new Map};return e.set(s,l),{data:l.data,accept(u,h){if(!u||typeof u==="function"){let m=typeof u==="function"?u:void 0;l.callbacks.push({deps:[s],callback:(f)=>m?.(f[0])})}else l.callbacks.push({deps:typeof u==="string"?[u]:u,callback:(m)=>h?.(typeof u==="string"?m[0]:m)})},acceptExports(u,h){l.callbacks.push({deps:[s],callback:(m)=>h?.(m[0])})},dispose(u){l.dispose=u},prune(u){l.prune=u},invalidate(){o=!0},decline(){o=!0},on(u,h){let m=l.listeners.get(u)??new Set;m.add(h),l.listeners.set(u,m)},off(u,h){l.listeners.get(u)?.delete(h)},send(){throw Error("Preview hot-update custom messages are not a public transport.")}}}async function i(s){for(let c of e.values())for(let l of c.listeners.get(s)??[])await l()}return{context:n,observe(s,c,l){let u=e.get(s);if(!u)return;let m=import(c).then((f)=>{u.exports=Rb(f)?f:void 0,u.isComponent=l});t.add(m),m.then(()=>t.delete(m),(f)=>{t.delete(m),r=f})},async update(s,c,l,u){if(await Promise.all(t),r)throw r;let h=hf(s),m=hf(c),f=new Map,S=new Map;for(let[v,{record:k}]of h)for(let U of[...k.imports,...k.dynamicImports]){let z=s.get(U)?.hot?.id;if(!z)continue;let R=f.get(z)??new Set;R.add(v),f.set(z,R)}function y(v,k=new Set){if(k.has(v))return!1;let U=e.get(v);if(U?.callbacks.some((M)=>M.deps.includes(v))&&m.has(v))return S.set(v,U),!0;let z=f.get(v);if(!z?.size)return!1;let R=new Set([...k,v]);for(let M of z)if(!y(M,R))return!1;return!0}for(let[v,k]of h){let U=m.get(v);if(!U||k.source!==U.source){if(!y(v))return!1}}if(!S.size)return!0;o=!1,await i("vite:beforeUpdate");let b=[];for(let[v,k]of S){if(!u())return!1;await k.dispose?.(k.data);let U=m.get(v)?.uri??"";b.push([v,k,await l(U)])}if(!u())return!1;for(let[,v,k]of b){let{isComponent:U,exports:z}=v;if(!U)continue;let R=Object.keys(k).filter((M)=>M!=="__esModule");if(!z||R.length!==Object.keys(z).filter((M)=>M!=="__esModule").length||R.some((M)=>!Object.hasOwn(z,M)||!U(k[M])&&z[M]!==k[M]))return!1}for(let[v,k,U]of b)for(let z of k.callbacks)if(z.deps.includes(v))await z.callback(z.deps.map((R)=>R===v?U:void 0));return await i("vite:afterUpdate"),await new Promise((v)=>setTimeout(v,20)),u()&&!o},async dispose(){for(let s of e.values())await s.dispose?.(s.data),await s.prune?.(s.data);e.clear(),t.clear(),r=void 0}}}var xb=["imports","dynamicImports","styles","references"],Rr=(e)=>typeof e==="object"&&e!==null,ff=(e)=>Rr(e)?e.message:void 0,pi=(e,t,o)=>Object.assign(Error(e,o),t);function Pb(e,t){if(Rr(e))Reflect.set(e,"resourceUri",t);return e}var gf=(e)=>Rr(e)?e.epoch:void 0;function kl(e){if(typeof e.module!=="string")throw Error(`Missing preview dependency metadata: ${String(e.module)}`);return e.module}var Eb=(e)=>Rr(e)?e:{};async function kb(e,t){let o=await crypto.subtle.digest("SHA-256",t),r="sha256:"+[...new Uint8Array(o)].map((n)=>n.toString(16).padStart(2,"0")).join("");if(t.length!==e?.size||r!==e.digest)throw pi("Preview resource integrity check failed. Rebuild and reopen the preview.",{code:"ADS_RESOURCE_INTEGRITY",category:"build"});return t}function Sf(e,t){let o=[],r=new Set;function n(i){if(r.has(i))return;r.add(i);let s=e.get(i);if(!s)throw Error(`Missing preview dependency metadata: ${i}`);for(let c of[...s.imports,...s.styles,...s.references])n(c);o.push(i)}return n(t),o}function _f(e,t){if(!e||e.revision===t.revision)return[];let o=(r,n)=>{let i=new Map(Object.entries(r.assets));return JSON.stringify(Sf(i,kl(n)).map((s)=>[s,i.get(s)]))};return t.scenarios.filter((r)=>{let n=e.scenarios.find((i)=>i.id===r.id);return!n||o(e,n)!==o(t,r)}).map((r)=>r.id)}function Tb(e,t,o,r){let{digest:n,hot:i}=t;if(!/^ads:\/\/assets\/[a-f0-9]{64}\.[a-z0-9]+$/.test(e)||typeof n!=="string"||!/^sha256:[a-f0-9]{64}$/.test(n))return null;if(i&&(!o.refresh||t.kind!=="module"||!Rr(i)||typeof i.id!=="string"||!i.id||i.id.length>4096||r.has(i.id)||typeof i.source!=="string"||!/^[a-f0-9]{64}$/.test(i.source)))return null;if(!xb.every((s)=>Array.isArray(t[s])&&t[s].every((c)=>Object.hasOwn(o.assets,c))))return null;return t}class Tl{read;records=new Map;bytes=new Map;urls=new Map;styles=new Map;styleReady=new Map;revisions=new Set;loadedModules=new Set;executed=new Map;moduleHistory=new Set;importing=Promise.resolve();mounting=Promise.resolve();refreshDirty=!1;generation=0;prefetchGeneration=0;closed=!1;hot;mounted;unmount;constructor(e){this.read=e,this.hot=mf(),Reflect.set(globalThis,"__adsPreviewHot",this.hot),Reflect.set(globalThis,"__dsPreviewImport",(t)=>this.importModule(t))}register(e){if(e.schemaVersion!==1||!Array.isArray(e.scenarios)||!e.assets||typeof e.revision!=="string")throw Error("Unsupported preview manifest. Rebuild previews with the installed ADS version.");let t=e.refresh;if(t&&(!Rr(t)||t.version!==1||typeof t.epoch!=="string"||!t.epoch||t.epoch.length>100))throw Error("Unsupported preview refresh protocol. Reopen with the current ADS version.");let o=new Set,r=[];for(let[n,i]of Object.entries(e.assets)){let s=Tb(n,i,e,o);if(!s)throw Error("Invalid preview dependency graph.");if(s.hot)o.add(s.hot.id);if(this.records.has(n)&&this.records.get(n)?.digest!==s.digest)throw pi("An immutable preview resource changed its content. Rebuild previews with the current ADS version.",{code:"ADS_RESOURCE_IDENTITY",category:"build",resourceUri:n});r.push([n,s])}for(let[n,i]of r)this.records.set(n,i)}async resource(e){let t=this.bytes.get(e);if(!t)t=(async()=>{let o=this.records.get(e);if(!o)throw Error(`Unknown preview dependency: ${e}`);let r;try{r=await this.read(e)}catch(s){throw pi(`Preview resource read failed for ${e}: ${String(ff(s))}`,{code:"ADS_RESOURCE_READ",category:"transport",resourceUri:e},{cause:s})}if(this.closed)throw Error("The preview App was closed.");let n=r.contents.find((s)=>s.uri===e);if(!n)throw pi(`Missing preview dependency: ${e}`,{code:"ADS_RESOURCE_CONTENT",category:"build",resourceUri:e});let i=typeof n.text==="string"?new TextEncoder().encode(n.text):Uint8Array.from(atob(String(n.blob)),(s)=>s.charCodeAt(0));try{return await kb(o,i)}catch(s){throw Pb(s,e)}})(),this.bytes.set(e,t),t.catch(()=>this.bytes.delete(e));return t}closure(e){return Sf(this.records,e)}asset(e){let t=this.records.get(e);if(!t)throw Error(`Missing preview dependency metadata: ${e}`);return t}async prefetch(e,t){if(this.closed)return;this.register(e);let o=++this.prefetchGeneration,r=new Set,n=[],i=0;for(let u of t){let h=e.scenarios.find((S)=>S.id===u);if(!h)continue;let m=this.closure(kl(h)).filter((S)=>!this.bytes.has(S)&&!r.has(S)),f=m.reduce((S,y)=>S+this.asset(y).size,0);if(i+f>16777216||r.size+m.length>256)continue;i+=f,n.push(u);for(let S of m)r.add(S)}let s=[...r],c=0,l=async()=>{while(!this.closed&&o===this.prefetchGeneration&&c<s.length)await this.resource(s[c++]??"")};return await Promise.all(Array.from({length:Math.min(3,s.length)},l)),{scenarios:n,resources:s.length}}mapImports(e){if(!Object.keys(e).length)return;let t=document.createElement("script");t.type="importmap",t.textContent=JSON.stringify({imports:e}),document.head.append(t)}async materialize(e){let t=this.closure(e);await Promise.all(t.map((r)=>this.resource(r)));let o={};for(let r of t){if(this.closed)throw Error("The preview App was closed.");if(this.urls.has(r))continue;let n=this.asset(r),i=await this.resource(r);if(n.kind==="module"||n.mimeType==="text/css"||n.mimeType==="text/javascript"){let c=new TextDecoder().decode(i);for(let l of n.references){let u=this.urls.get(l);if(!u)throw Error("Unsupported cyclic asset reference.");c=c.replaceAll(l,u)}i=c}let s=URL.createObjectURL(new Blob([i],{type:n.mimeType}));if(this.urls.set(r,s),n.kind==="module")o[r]=s}return this.mapImports(o),t}async importModule(e){let t=this.importing.then(()=>this.materialize(e));this.importing=t.catch(()=>{});let o=await t;await this.attachStyles(o);try{let r=await import(e);this.loadedModules.add(e);for(let n of o){let i=this.records.get(n);if(i?.hot)this.executed.set(i.hot.id,{uri:n,record:i}),this.moduleHistory.add(n)}return Eb(r)}catch(r){throw Error(`Preview module import failed for ${e}: ${String(ff(r))}. Inspect the App resource bridge, browser network/CSP diagnostics and current build.`,{cause:r})}}async attachStyles(e){for(let t of e){if(this.records.get(t)?.mimeType!=="text/css")continue;if(this.styles.has(t)){await this.styleReady.get(t);continue}let r=document.createElement("link");r.rel="stylesheet",r.href=this.urls.get(t)??"",this.styles.set(t,r);let n=new Promise((i,s)=>{r.onload=i,r.onerror=()=>s(Error("The host CSP blocked a preview stylesheet."))});this.styleReady.set(t,n),document.head.append(r);try{await n}catch(i){throw r.remove(),this.styles.delete(t),this.styleReady.delete(t),i}}}async refreshStyles(e,t){let o=[e],r=new Set,n=new Set;for(let i of o){if(r.has(i))continue;r.add(i);for(let s of await this.materialize(i)){n.add(s);for(let c of this.asset(s).dynamicImports){let l=this.records.get(c)?.hot?.id;if(this.loadedModules.has(c)||l!==void 0&&this.executed.has(l))o.push(c)}}}if(await this.attachStyles([...n]),t!==this.generation||this.closed)return!1;for(let[i,s]of this.styles)if(!n.has(i))s.remove(),this.styles.delete(i),this.styleReady.delete(i);for(let i of n){let s=this.styles.get(i);if(s)document.head.append(s)}return!0}async mount(e,t,o){let r=++this.generation,n=this.mounting.then(()=>r!==this.generation||this.closed?!1:this.mountRevision(e,t,o,r));return this.mounting=n.catch(()=>{}),n}async mountRevision(e,t,o,r){this.register(e);let n=e.scenarios.find((b)=>b.id===t);if(!n)throw Error("The selected scenario is no longer registered.");let i=kl(n),s=JSON.stringify(this.closure(i).map((b)=>[b,this.records.get(b)])),c=new Map(this.closure(i).map((b)=>[b,this.records.get(b)])),l=(b)=>{throw pi(b,{code:"ADS_PREVIEW_REOPEN"})};if(this.refreshDirty)l("An interrupted module update requires a clean preview frame.");let u=[...this.urls.keys()].reduce((b,v)=>b+this.asset(v).size,0);if(this.records.size>4096||u>67108864)l("Reopen the preview to release retained module revisions.");let h=e.refresh;if(this.mounted&&gf(this.mounted.refresh)!==gf(h))l("The preview compiler changed. Reopening an isolated frame for its new runtime.");if(h&&this.mounted){let b=new Map(Object.keys(e.assets).map((z)=>[z,this.asset(z)])),v=new Map([...b].flatMap(([z,R])=>R.hot?[[R.hot.id,{uri:z,record:R}]]:[]));for(let[z,{record:R}]of this.executed){let M=v.get(z);if(M&&M.record.hot?.source!==R.hot?.source&&this.moduleHistory.has(M.uri))l("Restoring a previous module revision requires a clean preview frame.")}let k=new Map([...this.executed.values()].map(({uri:z,record:R})=>[z,R]));this.refreshDirty=!0;let U=await this.hot.update(k,b,(z)=>this.importModule(z),()=>r===this.generation&&!this.closed);if(r!==this.generation||this.closed)return!1;if(!U)l("This edit changes a refresh boundary. Reopening the preview with fresh component state.");this.refreshDirty=!1;for(let z of this.executed.keys()){let R=v.get(z);if(R)this.executed.set(z,R)}if(this.mounted.id===t){if(!await this.refreshStyles(i,r))return!1;return this.revisions.add(i),this.mounted={...this.mounted,signature:s,records:c,module:i},!0}}if(this.mounted?.id===t&&this.mounted.container===o&&this.mounted.signature===s)return this.refreshStyles(i,r);if(this.revisions.add(i),!h&&this.revisions.size>20)l("Reopen the preview to release retained module revisions.");let m=await this.importModule(i);if(r!==this.generation)return!1;let f=this.unmount;if(this.unmount=void 0,this.mounted=void 0,await f?.(),r!==this.generation||this.closed)return!1;if(o.replaceChildren(),!await this.refreshStyles(i,r))return!1;let S=m.mount;if(typeof S!=="function")throw Error("The compiled scenario has no mount adapter.");let y=S(o);if(typeof y!=="function")throw Error("The scenario mount adapter must return an unmount callback.");return this.unmount=()=>y(),this.mounted={id:t,container:o,signature:s,records:c,module:i,refresh:h},!0}async dispose(){if(this.closed)return;this.closed=!0,++this.generation,++this.prefetchGeneration,await this.mounting,await this.unmount?.(),await this.hot.dispose(),this.mounted=void 0;for(let e of this.styles.values())e.remove();for(let e of this.urls.values())URL.revokeObjectURL(e);if(this.styles.clear(),this.styleReady.clear(),this.urls.clear(),this.bytes.clear(),this.records.clear(),this.revisions.clear(),this.loadedModules.clear(),this.executed.clear(),this.moduleHistory.clear(),Reflect.deleteProperty(globalThis,"__dsPreviewImport"),Reflect.get(globalThis,"__adsPreviewHot")===this.hot)Reflect.deleteProperty(globalThis,"__adsPreviewHot")}}var $l="ads-preview-guide-options",yf="ads-preview-guide-state",$b=["off","hover","always"];var vx=Object.freeze({mode:"off",bounds:!0,tracks:!1,gaps:!1,padding:!0,margins:!0,mini:!1}),Cb=(e)=>$b.some((t)=>t===e),so=(e,t)=>typeof e==="object"&&e!==null?e[t]:void 0;function hi(e){let t=so(e,"mode");return{mode:Cb(t)?t:so(e,"all")===!0?"always":"off",bounds:so(e,"bounds")===!0,tracks:so(e,"tracks")===!0,gaps:so(e,"gaps")===!0,padding:so(e,"padding")===!0,margins:so(e,"margins")===!0,mini:so(e,"mini")===!0}}function bf(e){let{mode:t,...o}=hi(e);return{all:t==="always",...o}}function vf(e){let{mode:t,...o}=hi(e);return t!=="off"&&Object.values(o).some(Boolean)}var Ib={bounds:"bounds",content:"bounds",column:"tracks",row:"tracks",gap:"gaps",gutter:"gaps",margin:"margins",padding:"padding","mini-unit":"mini"},Cl=["Top","Right","Bottom","Left"],Ob=["paddingTop","paddingRight","paddingBottom","paddingLeft","marginTop","marginRight","marginBottom","marginLeft"],io=(e)=>typeof e==="object"&&e!==null,Mb=(e)=>io(e)&&typeof e.property==="string"&&typeof e.value==="string";function Ab(e){if(!io(e))return null;let t={},o={};for(let[r,n]of Object.entries(io(e.profiles)?e.profiles:{}))if(io(n)&&typeof n.miniUnit==="string"&&typeof n.miniUnitPx==="number")t[r]={miniUnit:n.miniUnit,miniUnitPx:n.miniUnitPx};for(let[r,n]of Object.entries(io(e.owners)?e.owners:{}))if(Array.isArray(n))o[r]=n.filter((i)=>typeof i==="string");return{profiles:t,owners:o}}function Nb(e){if(!io(e)||e.schemaVersion!==1||typeof e.source!=="string"||!Array.isArray(e.rules))return null;let t=e.rules.flatMap((o)=>{if(!io(o)||typeof o.selector!=="string"||!Array.isArray(o.declarations))return[];return[{selector:o.selector,declarations:o.declarations.filter(Mb)}]});return{source:e.source,rules:t}}function qb(e){let t=e.defaultView;if(!t)throw Error("The preview document has no window.");return t}function wf(e,{onDetails:t=()=>{}}={}){let o=e.ownerDocument,r=qb(o),n=(D)=>parseFloat(D)||0,i,s,c="",l,u=!1,h=[],m="components",f=null,S={},y=null,b=new Set,v=new r.ResizeObserver(M),k=new r.MutationObserver(M),U=(D)=>D instanceof r.Element?D:null,z=(D,ne)=>D instanceof r.HTMLElement?D[ne]:0,R=(D)=>D?.getAttribute("data-ads-source")??void 0;function M(){if(u&&!s)s=r.requestAnimationFrame(Qe)}function oe(D){let ne=U(D.target),be=ne?.closest("[data-ads-source]"),re=ne?.closest('button, summary, a[href], [role="button"]'),le=be&&e.contains(be)?re&&e.contains(re)?re:ne:null;if(f!==le)f=le,M()}function pe(){if(f)f=null,M()}function we(D){let ne=D.relatedTarget;if(!(ne instanceof r.Node&&e.contains(ne)))pe()}function de(D,ne){let be=y?.profiles??{},re=D.closest("[data-ads-profile]")?.getAttribute("data-ads-profile")??void 0,le=R(D.closest("[data-ads-source]")),je=re!==void 0?[re]:(le===void 0?void 0:y?.owners[le])??[],Ie=(je.length?je:Object.keys(be)).flatMap((se)=>{let J=be[se];return J?[J]:[]}),[Oe]=Ie;if(!Oe||new Set(Ie.map((se)=>`${se.miniUnit}:${se.miniUnitPx}`)).size!==1)return 0;let Z=ne.getPropertyValue(Oe.miniUnit).trim();return/^\d*\.?\d+px$/.test(Z)?n(Z):/^\d*\.?\d+rem$/.test(Z)?n(Z)*n(r.getComputedStyle(o.documentElement).fontSize):Oe.miniUnitPx}function Ne(D){let ne=R(D.closest("[data-ads-source]"));return h.filter((be)=>be.source===ne).flatMap((be)=>be.rules.filter((re)=>{try{return D.matches(re.selector)}catch{return!1}}).flatMap((re)=>re.declarations))}function Ve(){let D=[...e.querySelectorAll("[data-ads-source]")].filter((ne)=>{let be=ne.getBoundingClientRect();return be.width&&be.height});if(D.length)return D;return[...(e.querySelector(".ads-preview-root")??e).children].filter((ne)=>!["STYLE","SCRIPT","LINK","H1"].includes(ne.tagName))}let Be=()=>({width:o.documentElement.clientWidth,height:o.documentElement.clientHeight});function ot(D){let{width:ne,height:be}=Be(),re={left:0,top:0,right:ne,bottom:be};for(let le=D.parentElement;le;le=le.parentElement){let je=r.getComputedStyle(le),Ie=le.getBoundingClientRect(),Oe=le.offsetWidth?Ie.width/le.offsetWidth:1,Z=le.offsetHeight?Ie.height/le.offsetHeight:1;if(/(auto|scroll|hidden|clip)/.test(je.overflowX))re.left=Math.max(re.left,Ie.left+le.clientLeft*Oe),re.right=Math.min(re.right,Ie.left+(le.clientLeft+le.clientWidth)*Oe);if(/(auto|scroll|hidden|clip)/.test(je.overflowY))re.top=Math.max(re.top,Ie.top+le.clientTop*Z),re.bottom=Math.min(re.bottom,Ie.top+(le.clientTop+le.clientHeight)*Z)}return re}function Qe(){if(s=void 0,!u)return;let D=Ve();if(f&&!e.contains(f))f=null;let ne=S.all===!0?[...D]:f?[f]:[];if(S.all===!0)for(let Z of D)for(let se of Z.querySelectorAll("*")){if(se.closest("svg")||["STYLE","SCRIPT","LINK"].includes(se.tagName)||ne.includes(se))continue;let J=r.getComputedStyle(se);if(/grid|flex/.test(J.display)||Ob.some((ke)=>n(J[ke])!==0))ne.push(se)}if(f&&!ne.includes(f))ne.push(f);let be=ne.filter((Z)=>S.mini===!0||/\/components\//.test(R(Z.closest("[data-ads-source]"))??"")||m==="components"||m==="tokens"||m==="foundation"),re=new Set(be.filter((Z)=>!be.some((se)=>se!==Z&&se.contains(Z)))),le=[],je=new Set([e]),Ie=[];for(let Z of ne){let se=r.getComputedStyle(Z),J=Z.getBoundingClientRect(),ke=ot(Z);if(!J.width||!J.height||J.right<=ke.left||J.left>=ke.right||J.bottom<=ke.top||J.top>=ke.bottom)continue;je.add(Z);let ht=z(Z,"offsetWidth"),I=z(Z,"offsetHeight"),A=ht?J.width/ht:1,B=I?J.height/I:1,X=Cl.map((Re)=>n(se[`border${Re}Width`])),ve=Cl.map((Re)=>n(se[`padding${Re}`])),_e=Cl.map((Re)=>n(se[`margin${Re}`])),[Pe=0,Le=0,ye=0,ze=0]=X,[P=0,We=0,j=0,N=0]=ve,G=J.left+(ze+N)*A,O=J.top+(Pe+P)*B,x=J.width-(Le+ze+We+N)*A,Y=J.height-(Pe+ye+P+j)*B,W=o.createElement("div");W.dataset.adsSpatialSource=R(Z)??"measured-box",Object.assign(W.style,{position:"fixed",inset:"0",clipPath:`inset(${ke.top}px ${Math.max(0,Be().width-ke.right)}px ${Math.max(0,Be().height-ke.bottom)}px ${ke.left}px)`});let ge=(Re,ue,ce,he,ie,ee,Me=!1)=>{if(ce<=0||he<=0||S[Ib[ie]]===!1)return;let Ee=o.createElement("div");return Ee.dataset.adsGuide=ie,Object.assign(Ee.style,{position:"absolute",left:`${Re}px`,top:`${ue}px`,width:`${ce}px`,height:`${he}px`,boxSizing:"border-box",...Me?{border:`1px solid ${ee}`}:{background:ee}}),W.append(Ee),Ee};if(ge(J.left,J.top,J.width,J.height,"bounds","rgb(70 120 250 / .75)",!0),re.has(Z)){let Re=de(Z,se);if(Re>0){let ue=r.devicePixelRatio||1,ce=Math.floor(J.left*ue),he=Math.floor(J.top*ue),ie=Math.ceil(J.right*ue)-ce,ee=Math.ceil(J.bottom*ue)-he,Me=ge(ce/ue,he/ue,ie/ue,ee/ue,"mini-unit","transparent");if(Me&&ie>0&&ee>0){Me.dataset.adsUnit=`${Re}`,Me.dataset.adsMajor=`${Re*2}`;let Ee=o.createElement("canvas");Ee.width=ie,Ee.height=ee,Object.assign(Ee.style,{display:"block",width:`${ie/ue}px`,height:`${ee/ue}px`,imageRendering:"pixelated"});let Je=Ee.getContext("2d");if(Je){let it=[Re*A*ue,Re*B*ue];for(let Ue=0;;Ue++){let Xe=Math.round(J.left*ue+Ue*it[0])-ce;if(Xe>=ie)break;Je.fillStyle=Ue%2?"#617dba14":"#617dba38",Je.fillRect(Xe,0,1,ee)}for(let Ue=0;;Ue++){let Xe=Math.round(J.top*ue+Ue*it[1])-he;if(Xe>=ee)break;Je.fillStyle=Ue%2?"#617dba14":"#617dba38",Je.fillRect(0,Xe,ie,1)}}Me.append(Ee)}}}let zt=(Re,ue,ce,he)=>{let[ie=0,ee=0,Me=0,Ee=0]=Re.map((Zt,Ht)=>Math.max(0,Zt)*(Ht%2?A:B)),Je=ue?J.left-Ee:J.left+ze*A,it=ue?J.top-ie:J.top+Pe*B,Ue=ue?J.width+Ee+ee:J.width-(Le+ze)*A,Xe=ue?J.height+ie+Me:J.height-(Pe+ye)*B;ge(Je,it,Ue,ie,ce,he),ge(Je,it+Xe-Me,Ue,Me,ce,he),ge(Je,it+ie,Ee,Xe-ie-Me,ce,he),ge(Je+Ue-ee,it+ie,ee,Xe-ie-Me,ce,he)};if(zt(_e,!0,"margin","rgb(234 149 43 / .2)"),m!=="mocks"||f===Z||S.padding===!0)zt(ve,!1,"padding","rgb(55 186 130 / .22)");let mt=Ne(Z);if(se.display.includes("grid")){let Re=(ue,ce)=>{let he=ue.replace(/\[[^\]]*\]/g,"").trim().split(/\s+/);if(!he.length||!he.every((Je)=>/^\d*\.?\d+px$/.test(Je)))return;let ie=he.map(n),ee=n(ce==="columns"?se.columnGap:se.rowGap)*(ce==="columns"?A:B),Me=ce==="columns"&&se.direction==="rtl",Ee=ce==="columns"?Me?G+x:G:O;W.dataset[ce==="columns"?"adsGridColumns":"adsGridRows"]=String(ie.length),ie.forEach((Je,it)=>{let Ue=Je*(ce==="columns"?A:B);if(Me)Ee-=Ue;if(ge(ce==="columns"?Ee:G,ce==="columns"?O:Ee,ce==="columns"?Ue:x,ce==="columns"?Y:Ue,ce==="columns"?"column":"row","rgb(200 66 135 / .35)",!0),Ee+=Me?0:Ue,it<ie.length-1)ge(ce==="columns"?Me?Ee-ee:Ee:G,ce==="columns"?O:Ee,ce==="columns"?ee:x,ce==="columns"?Y:ee,"gap","rgb(200 66 135 / .12)");Ee+=Me?-ee:ee})};if(Re(se.gridTemplateColumns,"columns"),mt.some((ue)=>ue.property==="grid-template-rows"&&ue.value!=="none"))Re(se.gridTemplateRows,"rows");for(let ue of Z.children){let ce=r.getComputedStyle(ue),he=ue.getBoundingClientRect();if(ce.display==="none"||!he.width||!he.height)continue;let ie=n(ce.marginLeft)*A,ee=n(ce.marginRight)*A;ge(he.left-ie,he.top,ie,he.height,"gutter","rgb(200 66 135 / .16)"),ge(he.right,he.top,ee,he.height,"gutter","rgb(200 66 135 / .16)")}}if(se.display.includes("flex")||m==="mocks"){let Re=[...Z.children].filter((ue)=>{let ce=ue.getBoundingClientRect();return ce.width&&ce.height});for(let ue of Re){je.add(ue);let ce=ue.getBoundingClientRect();ge(ce.left,ce.top,ce.width,ce.height,"content","rgb(70 120 250 / .5)",!0)}Re.forEach((ue,ce)=>{let he=Re[ce-1];if(!he)return;let ie=he.getBoundingClientRect(),ee=ue.getBoundingClientRect();if(ee.top>=ie.bottom)ge(Math.max(ie.left,ee.left),ie.bottom,Math.min(ie.right,ee.right)-Math.max(ie.left,ee.left),ee.top-ie.bottom,"gap","rgb(200 66 135 / .16)");else if(ee.left>=ie.right)ge(ie.right,Math.max(ie.top,ee.top),ee.left-ie.right,Math.min(ie.bottom,ee.bottom)-Math.max(ie.top,ee.top),"gap","rgb(200 66 135 / .16)");else if(ie.left>=ee.right)ge(ee.right,Math.max(ie.top,ee.top),ie.left-ee.right,Math.min(ie.bottom,ee.bottom)-Math.max(ie.top,ee.top),"gap","rgb(200 66 135 / .16)")})}if(le.push(W),f===Z){let Re=[...new Set(mt.flatMap((ue)=>ue.value.match(/--[\w-]+/g)??[]))];Ie.push({label:Z.getAttribute("aria-label")??Z.getAttribute("role")??Z.tagName.toLowerCase(),width:Math.round(J.width*10)/10,height:Math.round(J.height*10)/10,display:se.display,padding:ve,margin:_e,rowGap:se.rowGap,columnGap:se.columnGap,tokens:Re})}}for(let Z of b)if(!je.has(Z))v.unobserve(Z),b.delete(Z);for(let Z of je)if(!b.has(Z))v.observe(Z),b.add(Z);let[Oe]=Ie;if(Oe){l=f??void 0;let Z=JSON.stringify(Oe);if(Z!==c)c=Z,t(Oe)}else if(l&&!e.contains(l))te();i?.replaceChildren(...le)}function te(){l=void 0,c="",t(null)}function fe(D){if(u===D){M();return}if(u=D,D)i=o.createElement("div"),i.id="ads-grid-overlay",i.setAttribute("aria-hidden","true"),i.style.cssText="position:fixed;inset:0;z-index:2147483646;pointer-events:none;overflow:hidden",o.body.append(i),k.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),k.observe(o.documentElement,{attributes:!0}),e.addEventListener("pointermove",oe,{passive:!0}),e.addEventListener("pointerleave",pe),e.addEventListener("focusin",oe),e.addEventListener("focusout",we),r.addEventListener("resize",M),o.addEventListener("scroll",M,!0),M();else{if(s!==void 0)r.cancelAnimationFrame(s);s=void 0,v.disconnect(),b.clear(),k.disconnect(),e.removeEventListener("pointermove",oe),e.removeEventListener("pointerleave",pe),e.removeEventListener("focusin",oe),e.removeEventListener("focusout",we),r.removeEventListener("resize",M),o.removeEventListener("scroll",M,!0),i?.remove(),i=void 0,f=null,te()}}return{setVisible:fe,setGuides(D){S=io(D)?D:{},M()},setMetadata(D,ne,be=null){h=D.flatMap((re)=>{let le=Nb(re);return le?[le]:[]}),m=ne,y=Ab(be),f=null,te(),M()},dispose(){fe(!1)}}}function jb(e){let t=e instanceof HTMLElement?Number(e.dataset.adsStageInset??""):Number.NaN;return Number.isFinite(t)&&t>=0&&e instanceof HTMLElement&&e.dataset.adsStageInset!==void 0?t:null}function Lb(e){let t=e.defaultView;if(!t)throw Error("The preview document has no window.");return t}function Ub(e){let t=e.map((o)=>({...o}));for(let o=!0;o;){o=!1;e:for(let r=0;r<t.length;r++)for(let n=r+1;n<t.length;n++){let i=t[r],s=t[n];if(i&&s&&i.left<=s.right&&s.left<=i.right&&i.top<=s.bottom&&s.top<=i.bottom){t[r]={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)},t.splice(n,1),o=!0;break e}}}return t}function zf(e,{decorate:t=!0}={}){let o=e.ownerDocument,r=Lb(o),n=null,i=null,s=null,c=0,l=null,u=new r.ResizeObserver(()=>k()),h=new r.MutationObserver(()=>U()),m=new r.MutationObserver(()=>k()),f=()=>k();function S(){if(l?.remove(),l=null,s)delete s.dataset.adsStaged,delete s.dataset.adsSubjectOnly}function y(z){if(z===s)return;if(s?.removeEventListener("scroll",f),u.disconnect(),S(),s=z,!s)return;s.addEventListener("scroll",f,{passive:!0}),u.observe(s)}function b(){let z=e.querySelector(":scope > .ads-preview-root");y(z instanceof r.HTMLElement?z:null);let R=s&&n?[...s.querySelectorAll(n)]:[],M=R.filter((de)=>!R.some((Ne)=>Ne!==de&&Ne.contains(de))),[oe]=M,pe=M.length===1&&oe?oe.parentElement:null,we=s!==null&&pe!==null&&(pe===s||pe.parentElement===s&&pe.children.length===1)&&[...s.children].every((de)=>de===l||de===pe||de===oe);return s?.toggleAttribute("data-ads-subject-only",we),M}function v(){c=0;let z=b();if(!t||!s||s.hasAttribute("data-ads-subject-only")){if(l?.remove(),l=null,s)delete s.dataset.adsStaged;return}let R=s,M=new Set(["SPAN","STRONG","EM","B","I","SMALL","CODE","LABEL","ABBR"]),oe=(te)=>M.has(te.tagName)&&!z.includes(te)&&te.querySelector("*")===null&&Boolean(te.textContent?.trim()),pe=(te)=>{let fe=te.parentElement;if(!fe||fe===R)return te;if(fe.children.length===1)return[...fe.childNodes].some((re)=>re.nodeType===3&&re.textContent?.trim())?fe:te;let D=[...fe.children].filter((re)=>re!==te),ne=r.getComputedStyle(fe);return(ne.display.includes("flex")&&!ne.flexDirection.startsWith("column")||ne.display.startsWith("inline"))&&D.some(oe)&&D.every((re)=>oe(re)||z.includes(re))?fe:te},we=Ub(z.map(pe).flatMap((te)=>{u.observe(te,{box:"border-box"});let fe=te.getBoundingClientRect(),D=i&&te.matches(i)?0:jb(te)??16;return fe.width&&fe.height?[{left:fe.left-D,top:fe.top-D,right:fe.right+D,bottom:fe.bottom+D}]:[]}));if(!we.length){S();return}let de=R.getBoundingClientRect(),Ne=de.left+R.clientLeft,Ve=de.top+R.clientTop,Be={left:Ne,top:Ve,right:Ne+R.clientWidth,bottom:Ve+R.clientHeight};if(!l||l.parentElement!==R)l?.remove(),l=o.createElement("div"),l.dataset.adsSubjectStage="",l.setAttribute("aria-hidden","true"),Object.assign(l.style,{position:"fixed",inset:"0",pointerEvents:"none",background:"var(--bg-canvas, Canvas)",zIndex:"-1"}),R.prepend(l);R.dataset.adsStaged="";let ot=we.map((te)=>({left:Math.max(te.left,Be.left),top:Math.max(te.top,Be.top),right:Math.min(te.right,Be.right),bottom:Math.min(te.bottom,Be.bottom)})).filter((te)=>te.right>te.left&&te.bottom>te.top),Qe=(te)=>`M${te.left} ${te.top}H${te.right}V${te.bottom}H${te.left}Z`;l.style.clipPath=ot.length?`path("${ot.map(Qe).join("")}")`:"inset(50%)",l.dataset.adsStages=String(we.length)}function k(){if(!c)c=r.requestAnimationFrame(v)}function U(){b(),k()}return h.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","hidden","open","data-ads-source"]}),m.observe(o.documentElement,{attributes:!0,attributeFilter:["data-theme","data-brand"]}),r.addEventListener("resize",k),{setSubjectSelector(z,R=null){n=z||null,i=R,U()},refresh:U,dispose(){if(h.disconnect(),m.disconnect(),c)r.cancelAnimationFrame(c);r.removeEventListener("resize",k),y(null),S(),n=null,i=null}}}var ut=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof Map);var Rf=/^[a-f0-9]{64}$/,Db=/^ads:\/\/assets\/[a-f0-9]{64}\.[a-z0-9]+$/;var Zb=["react","preact"],Hb=["imports","dynamicImports","styles","references"];function Fb(e){if(!ut(e)||e.schemaVersion!==1||!Zb.includes(e.framework)||!Rf.test(String(e.revision))||!ut(e.assets)||!Array.isArray(e.scenarios))throw Error("Invalid preview manifest update.");let t=e.assets,o=new Set;for(let r of e.scenarios){let n=ut(r)?r.id:void 0,i=ut(r)?r.module:void 0,s=typeof i==="string"?t[i]:void 0;if(typeof n!=="string"||o.has(n)||!ut(s)||s.kind!=="module")throw Error("Invalid updated preview scenarios.");o.add(n)}for(let[r,n]of Object.entries(t))if(!Db.test(r)||!ut(n)||!Hb.every((i)=>{let s=n[i];return Array.isArray(s)&&s.every((c)=>typeof c==="string"&&Object.hasOwn(t,c))}))throw Error("Invalid updated preview dependencies.")}function Il(e){return Fb(e),e}function xf(e,t){if(!ut(e)||e.version!==1)throw Error("Unsupported preview manifest update.");if(e.type==="full")return Il(e.manifest);if(!t||e.baseRevision!==t.revision)throw Error("Preview manifest update base does not match.");let o=e.header;if(!ut(o)||Object.hasOwn(o,"assets")||Object.hasOwn(o,"scenarios")||!Rf.test(String(o.revision)))throw Error("Invalid preview manifest update header.");if(e.type==="unchanged"){if(o.revision!==t.revision)throw Error("Unchanged preview revision does not match.");return Il({...o,assets:t.assets,scenarios:t.scenarios})}let{assets:r,scenarios:n}=e,i=ut(r)?r.upsert:void 0,s=ut(r)?r.remove:void 0,c=ut(n)?n.upsert:void 0,l=ut(n)?n.remove:void 0;if(e.type!=="delta"||!i||!Array.isArray(s)||!Array.isArray(c)||!Array.isArray(l))throw Error("Invalid preview manifest delta.");let u=new Map(Object.entries(t.assets)),h=new Map(t.scenarios.map((y)=>[y.id,y]));for(let y of s)if(typeof y!=="string"||!u.delete(y))throw Error("Unknown removed preview asset.");let m=Object.entries(i);for(let[y,b]of m)u.set(y,b);for(let y of l)if(!h.delete(y))throw Error("Unknown removed preview scenario.");let f=new Set;for(let y of c){let b=ut(y)?y.id:void 0;if(!y||f.has(b))throw Error("Duplicate updated preview scenario.");f.add(b),h.set(b,y)}let S=(ut(n)?n.order:void 0)??t.scenarios.map((y)=>y.id);if(!Array.isArray(S)||S.length!==h.size||new Set(S).size!==S.length||S.some((y)=>!h.has(y)))throw Error("Invalid updated preview scenario order.");return Il({...o,assets:Object.fromEntries(u),scenarios:S.map((y)=>h.get(y))})}var Pf=(e,t)=>typeof e==="object"&&e!==null?Reflect.get(e,t):void 0;function Vb(e){let t=e.contents.find((o)=>typeof o.text==="string")?.text;if(t===void 0)throw Error("The preview manifest resource has no text.");return JSON.parse(t)}function Ef(e){let t=new Map,o=new Map,r=0,n,i=0,s=0,c=!0;function l(u){t.delete(u.revision),t.set(u.revision,{graph:u,size:new TextEncoder().encode(JSON.stringify(u)).byteLength});let h=[...t.values()].reduce((m,f)=>m+f.size,0);while(t.size>6||h>8388608){let[m]=t;if(!m)break;h-=m[1].size,t.delete(m[0])}}return{clear(){r++,t.clear(),o.clear(),n=void 0,c=!0},async get(u,{revision:h,session:m}={}){let f=h?t.get(h)?.graph:void 0;if(f&&(!m||f.session===m))return{...f,transportManifestUri:u};let S=n,y=r,b=JSON.stringify([u,h,m,S?.revision]),v=o.get(b);if(!v){let k=++i,U=(async()=>{let z;if(S&&c)try{z=await e(u+"?from="+S.revision)}catch(pe){if(Pf(pe,"code")!==-32002&&!/unknown (?:ADS )?resource|resource not found/i.test(String(Pf(pe,"message"))))throw pe;if(y===r)c=!1;z=await e(u)}else z=await e(u);let R=Vb(z),M=typeof R==="object"&&R!==null&&Boolean(Reflect.get(R,"type")),oe=xf(M?R:{version:1,type:"full",manifest:R},S);if(y===r){if(l(oe),k>=s)n=oe,s=k}return oe})();o.set(b,U),U.then(()=>{if(o.get(b)===U)o.delete(b)},()=>{if(o.get(b)===U)o.delete(b)}),v=U}return{...await v,transportManifestUri:u}}}}var Ml=(e)=>typeof e==="object"&&e!==null,Ol=(e)=>Ml(e)?e:{},me=(e,t)=>Ml(e)?e[t]:void 0,xr=(e)=>typeof e==="string"?e:void 0,kf=(e)=>({message:xr(me(e,"message"))??"",code:me(e,"code"),category:me(e,"category"),resourceUri:me(e,"resourceUri")});function Tf(e){let t=document.getElementById(e);if(!t)throw Error(`The preview document has no #${e}.`);return t}async function $f(e,t=(o)=>new Tl(o)){let o=Tf("root"),r=Tf("ads-preview-status"),n=document.documentElement,i,s=async(I)=>{if(!e.getHostCapabilities()?.serverResources)throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");try{return await e.readServerResource({uri:i?i+encodeURIComponent(I):I},{timeout:15000})}catch(A){if(me(A,"code")===-32601||me(A,"message")==="Method not found")throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");throw A}},c=t(s),l=Ef(s);n.dataset.adsPreviewDelivery=e.delivery??"mcp-blob";let u,h,m,f,S,y=!1,b,v=0,k={},U=[],z=!1,R,M,oe=new Set;function pe(I){if(e.getHostVersion()?.name!=="ADS showcase")return;let A=M;if(M=I,!A)return;let B=_f(A,I).filter((X)=>X!==u&&oe.has(X));if(!B.length)return;c.prefetch(I,B).then((X)=>de("prefetched",{revision:I.revision,...X})).catch((X)=>console.warn("ADS preview prefetch",me(X,"message")))}function we(I,A=!1){r.textContent=I,r.hidden=!I||e.getHostVersion()?.name==="ADS showcase",r.setAttribute("role",A?"alert":"status")}async function de(I,A={}){try{if(e.getHostCapabilities()?.logging)await e.sendLog({level:I==="error"?"error":"info",logger:"ads-preview",data:{state:I,id:u,...A}})}catch{}}let Ne=!1,Ve=wf(o),Be=zf(o,{decorate:Reflect.get(globalThis,"__ADS_RENDER_AUDIT__")!==!0}),ot={foundation:'.ads-grid-example, .ads-grid-unit, [data-slot="sample"][data-ads-specimen]',tokens:'[data-slot="sample"][data-ads-specimen]:not([data-ads-specimen="value"])',profiles:'[data-slot="sample"][data-ads-specimen]:not([data-ads-specimen="value"]):not([data-ads-specimen="motion"]):not([data-ads-specimen="applied"]), .ds-motion-track, .ds-applied-sample',assets:'[data-slot="sample"]:not(:empty), .catalogue-set, .catalogue-mag, .catalogue-sizes'},Qe='[data-slot="specimen"]:not([data-frame="screen"])',te=".ads-preview-root[data-ads-bare] > :not([data-ads-subject-stage])";function fe(I){let A=Ol(I);k={...k,...A,styles:{...Ol(k.styles),...Ol(A.styles)}};let B=k.theme,X=k.adsTheme??(B==="light"||B==="dark"?me(U.find((_e)=>me(_e,"scheme")===B)??{name:B},"name"):void 0);if(X)n.dataset.theme=String(X);if(k.adsChoices==="host")n.dataset.adsChoices="host";let ve=k.adsBrand;if(typeof ve==="string"&&/^[a-z][a-z0-9-]*$/.test(ve))n.dataset.brand=ve;Ve.setGuides(k.gridGuides),Ve.setVisible(Ne&&k.gridOverlay===!0),le(),Z(),be()}let D;function ne(I){if(I===D)return;if(D=I,I===void 0){Reflect.deleteProperty(globalThis,"__ADS_SCENARIO_STATE__");return}Reflect.set(globalThis,"__ADS_SCENARIO_STATE__",I),document.dispatchEvent(new CustomEvent("ads-scenario-state",{detail:{state:I}}))}function be(){if(!("adsState"in k))return;let I=k.adsState;ne(typeof I==="string"?I:void 0)}let re=(I)=>{let A=me(I instanceof CustomEvent?I.detail:void 0,"state");if(typeof A!=="string")return;D=A,Reflect.set(globalThis,"__ADS_SCENARIO_STATE__",A),de("scenario-state",{name:A})};document.addEventListener("ads-scenario-state-chosen",re);function le(){document.dispatchEvent(new CustomEvent(yf,{detail:hi(k.gridGuideChoices??k.gridGuides)}))}function je(I){let A=I instanceof CustomEvent?I.detail:void 0;if(!A){le();return}let B=hi(A);fe({gridGuideChoices:B,gridGuides:bf(B),gridOverlay:vf(B)}),de("guide-options",{options:B})}document.addEventListener($l,je);let Ie=(I)=>{let A=I instanceof CustomEvent?I.detail:void 0,B=me(A,"target");if(typeof B==="string")de("navigate",{target:B,token:me(A,"token")})};document.addEventListener("ads-preview-navigate",Ie);let Oe;function Z(){let I=k.adsFocus;if(!Ml(I)||I.nonce===Oe||I.target!==u||n.dataset.adsPreviewState!=="ready")return;Oe=I.nonce,document.dispatchEvent(new CustomEvent("ads-preview-focus",{detail:{token:I.token}}))}async function se(I="ads://preview/manifest",A,B){try{return await(c.manifest?c.manifest(I,{revision:A,session:B,scenario:u}):l.get(I,{revision:A,session:B}))}catch(X){throw Object.assign(Error(xr(me(X,"message")),{cause:X}),{code:"ADS_MANIFEST_READ",category:"transport"})}}async function J(I,A,B=!1,X="",ve=!1,_e){let Pe=B||ve;if(!X&&I===u&&A&&A===m&&(!_e||_e===f)&&Pe===z){we(Pe?"Checking changes…":""),await de(Pe?"checking":"ready",{revision:m});return}let Le=++v;++c.generation,u=I,Ne=!1,Ve.setVisible(!1),oe.add(I),n.dataset.adsScenario=I,n.dataset.adsPreviewState="loading";for(let ye of["adsPreviewErrorCategory","adsPreviewErrorCode","adsPreviewResourceUri"])delete n.dataset[ye];we(""),await de(X?"reverting":"loading");try{let ye=performance.now(),ze=await se(B?"ads://preview/live":"ads://preview/manifest",A,_e);if(Le!==v)return;let P=ze.themes;if(Array.isArray(P))U=P,fe({});if(A&&ze.revision!==A||_e&&ze.session!==_e){if(Le===v)we("Updating preview…"),await de("loading",{code:"ADS_PREVIEW_CHANGED"});return}if(Le!==v)return;let We=performance.now();performance.measure("ads-preview:manifest",{start:ye,end:We});let j=await c.mount(ze,I,o);if(performance.measure("ads-preview:load-mount",{start:We,end:performance.now()}),!j||Le!==v)return;let G=ze.scenarios.find((x)=>x.id===I)?.kind;o.dataset.adsScenarioKind=String(G??"");let O=typeof G==="string"&&Object.hasOwn(ot,G)?ot[G]:void 0;if(O!==void 0)Be.setSubjectSelector(O,".ads-grid-example");else Be.setSubjectSelector(`${Qe}, ${te}`,Qe);if(m=ze.revision,f=ze.session,z=Pe,await new Promise((x)=>requestAnimationFrame(()=>requestAnimationFrame(x))),await document.fonts.ready,Le!==v)return;if(Ne=G==="components"||G==="patterns"||G==="mocks"||G==="foundation",Ve.setMetadata(Object.values(ze.assets).flatMap((x)=>x.spatial?[x.spatial]:[]),G,ze.spatial),fe({}),o.dataset.adsPaintBindings="[]",o.dataset.adsPaintAudit="false",o.dataset.adsPaintAuditComplete="not-requested",Le===v){if(n.dataset.adsPreviewRevision=m,n.dataset.adsPreviewState=X?"error":Pe?"checking":"ready",we(X||(Pe?"Checking changes…":""),Boolean(X)),await de(X?"error":Pe?"checking":"ready",{revision:m,selectionRevision:h,...X?{message:X}:{}}),!Pe&&!X)pe(ze)}if(Le===v)Oe=void 0,Z()}catch(ye){if(Le===v){let{message:ze,code:P,category:We,resourceUri:j}=kf(ye);if(n.dataset.adsPreviewState="error",n.dataset.adsPreviewErrorCategory=String(We??"runner"),n.dataset.adsPreviewErrorCode=String(P??"ADS_PREVIEW_STARTUP"),j)n.dataset.adsPreviewResourceUri=String(j);we(ze,!0),await de("error",{message:ze,...P?{code:P}:{},...We?{category:We}:{},...j?{resourceUri:j}:{}})}}}async function ke(I){if(!u)return;if(document.visibilityState==="hidden"){if(I)b=I;return}if(y){if(I)b=I;return}y=!0;let A=v;try{let B=I??JSON.parse((await s("ads://project/build")).contents.find((ye)=>typeof ye.text==="string")?.text??"");if(A!==v)return;R=void 0;let X=me(B,"previews");if(!Array.isArray(X))throw Error("The build report lists no previews.");let ve=X.find((ye)=>me(ye,"id")===u),_e=me(B,"session"),Pe=xr(me(B,"manifestRevision")),Le=me(ve,"live");if(Le&&!me(ve,"current")){let ye=xr(me(Le,"revision"));if(ye!==m||_e!==f||!z)await J(u,ye,!0,"",!1,_e);else we("Checking changes…")}else if(!ve||!me(ve,"current")){let ye=me(ve,"diagnostics"),ze=Array.isArray(ye)?me(ye[0],"message"):void 0;if(ze&&z){let P=await se("ads://preview/manifest",Pe,_e);await J(u,P.revision,!1,`Build failed. Showing the previous preview.
|
|
110
110
|
${String(ze)}`,!1,_e)}we(ze?`Build failed. Showing the previous preview.
|
|
111
111
|
${String(ze)}`:"Rebuilding. This is the previous preview.",Boolean(ze))}else{let ye=await se("ads://preview/manifest",Pe,_e);if(A!==v)return;if(ye.revision!==m||ye.session!==f||z)await J(u,ye.revision,!1,"",!1,_e);else we(""),pe(ye)}}catch(B){if(A!==v)return;let X=`Preview freshness unavailable: ${String(me(B,"message"))}`;if(we(X,!0),R!==X)R=X,await de("error",{message:X})}finally{y=!1;let B=b;if(b=void 0,B)ke(B)}}e.onbuildreport=(I)=>{ke(I)};let ht=()=>{if(document.visibilityState!=="hidden")b=void 0,ke()};document.addEventListener("visibilitychange",ht),e.ontoolresult=(I)=>{let A=I.structuredContent,B=xr(me(A,"draftScope"));if(B!==i)++v,++c.generation,l.clear(),m=f=M=void 0,oe.clear();i=B;let X=me(me(A,"previewResult"),"structuredContent")??A,ve=me(me(X,"scenario"),"id");if(ve&&!("adsState"in k)){let _e=me(X,"state");if(typeof _e==="string")ne(_e);else if(String(ve)!==u)ne(void 0)}if(ve){let _e=me(X,"manifestRevision");h=_e;let Pe=me(X,"build");J(String(ve),xr(_e),me(X,"manifestUri")==="ads://preview/live","",me(Pe,"current")===!1,me(Pe,"session")).then(()=>{if(e.buildPollInterval===0)ke()})}},e.onhostcontextchanged=fe,e.onteardown=async()=>(++v,u=b=void 0,e.onbuildreport=void 0,l.clear(),document.removeEventListener("visibilitychange",ht),document.removeEventListener($l,je),document.removeEventListener("ads-preview-navigate",Ie),document.removeEventListener("ads-scenario-state-chosen",re),Ve.dispose(),Be.dispose(),clearInterval(S),await c.dispose(),{});try{let I=performance.now();if(await e.connect(),performance.measure("ads-preview:connect",{start:I,end:performance.now()}),fe(e.getHostContext()??{}),!e.getHostCapabilities()?.serverResources)throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");let A=e.buildPollInterval??150;if(A>0)S=setInterval(()=>{ke()},A);let B=document.getElementById("ads-preview-selection");if(B)J(String(me(JSON.parse(B.textContent??""),"id")))}catch(I){we(kf(I).message,!0)}window.addEventListener("pagehide",()=>{u=b=void 0,e.onbuildreport=void 0,clearInterval(S),l.clear(),c.dispose()},{once:!0})}var Dt=new La({name:"ADS resource preview",version:"1.0.0"},{},{autoResize:!0}),Jb={getHostCapabilities:()=>Dt.getHostCapabilities(),getHostVersion:()=>Dt.getHostVersion(),getHostContext:()=>Dt.getHostContext(),connect:()=>Dt.connect(),readServerResource:(e,t)=>Dt.readServerResource(e,t),sendLog:(e)=>Dt.sendLog(e),set ontoolresult(e){Dt.ontoolresult=e},set onhostcontextchanged(e){Dt.onhostcontextchanged=e},set onteardown(e){Dt.onteardown=e}};await $f(Jb);
|
package/dist/motion-model.mjs
CHANGED
|
@@ -5,7 +5,7 @@ const OPERATIONS = {
|
|
|
5
5
|
"scale-inline": { channel: "scale", field: "scale", neutral: 1 },
|
|
6
6
|
"scale-block": { channel: "scale", field: "scale", neutral: 1 },
|
|
7
7
|
rotate: { channel: "rotate", field: "angle", neutral: 0 }
|
|
8
|
-
}, isProperty = (value) => Object.hasOwn(OPERATIONS, value), CHANNELS = ["translate", "scale", "rotate"], CONDITIONS = new Set(["&:hover:not(:disabled)", "&:active:not(:disabled)", '&[aria-busy="true"]']), declarationsOf = (node) => (node.nodes ?? []).filter((child) => child.type === "decl");
|
|
8
|
+
}, isProperty = (value) => Object.hasOwn(OPERATIONS, value), CHANNELS = ["translate", "scale", "rotate"], CONDITIONS = new Set(["&:hover:not(:disabled)", "&:active:not(:disabled)", '&[aria-busy="true"]', '&[aria-expanded="true"]', '&[aria-pressed="true"]', '&[aria-checked="true"]', '&[aria-selected="true"]']), declarationsOf = (node) => (node.nodes ?? []).filter((child) => child.type === "decl");
|
|
9
9
|
export const inspectMotion = (part, motionProfiles, { complete = !0 } = {}) => rejecting(() => {
|
|
10
10
|
const children = part.nodes ?? [], transitions = children.filter((node) => node.type === "decl" && node.prop === "transition"), whens = children.filter((node) => node.type === "atrule" && node.name === "ads-when" && declarationsOf(node).some((field) => isProperty(field.prop) || field.prop === "repeat"));
|
|
11
11
|
if (transitions.length === 0 && whens.length === 0)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { currentAnalysis, memoFact, memoProgram } from "./analysis/context.mjs";
|
|
3
3
|
import { capturedTreeFiles, optionalSourceText } from "./analysis/helpers.mjs";
|
|
4
|
-
import { projectOwnerCache, projectScenarioCache } from "./analysis/owner-analysis-cache.mjs";
|
|
4
|
+
import { projectConstructionCache, projectOwnerCache, projectScenarioCache } from "./analysis/owner-analysis-cache.mjs";
|
|
5
|
+
import { wholeDesignDigests } from "./analysis/design-reads.mjs";
|
|
6
|
+
import { scenarioWork } from "./analysis/scenario-keys.mjs";
|
|
5
7
|
import { designDigests } from "./analysis/owner-analysis-key.mjs";
|
|
6
8
|
import { barrelDeclarations, checkDesignSystem } from "./analysis/owner-discovery.mjs";
|
|
7
9
|
import { ownerReuse } from "./analysis/owner-reuse.mjs";
|
|
@@ -115,7 +117,14 @@ async function analyzeRevision(inputs, captured, settings) {
|
|
|
115
117
|
const reads = designInputs.stats.reads, design = timing.timeStage("design-inputs", () => designInputs.read(captured, settings), void 0, () => ({ reused: designInputs.stats.reads === reads }));
|
|
116
118
|
if (design.kind === "err")
|
|
117
119
|
return { report: { diagnostics: findingsOf(inputs, { kind: "design-inputs", failure: design.error }), advisories: [], contexts: [], palette: [], tokens: [], fonts: [], appIcon: [], assets: [], composed: [], packages: [] }, checked: null };
|
|
118
|
-
const { foundation, assets, contexts } = design.value, texts = designTexts(captured), contextFindings = design.value.undefinedContexts.map((item) => undefinedContextFinding(inputs, texts, item)), palette = paletteFindings(inputs, foundation, contexts, design.value.palette), tokens = timing.timeStage("token-checks", () => tokenFindings(inputs, texts, foundation, design.value.document)), missing = missingTokenFindings(inputs, texts, foundation), fonts = timing.timeStage("font-checks", () => fontFindings(inputs, texts, foundation, design.value.document, design.value.fonts)), icon = await timing.timeStage("app-icon-checks", () => appIconReading(design.value.appIcon, { assets, foundation, contexts })), appIcon = icon.findings.map((finding) => appIconFinding(inputs, texts, finding)),
|
|
120
|
+
const { foundation, assets, contexts } = design.value, texts = designTexts(captured), contextFindings = design.value.undefinedContexts.map((item) => undefinedContextFinding(inputs, texts, item)), palette = paletteFindings(inputs, foundation, contexts, design.value.palette), tokens = timing.timeStage("token-checks", () => tokenFindings(inputs, texts, foundation, design.value.document)), missing = missingTokenFindings(inputs, texts, foundation), fonts = timing.timeStage("font-checks", () => fontFindings(inputs, texts, foundation, design.value.document, design.value.fonts)), icon = await timing.timeStage("app-icon-checks", () => appIconReading(design.value.appIcon, { assets, foundation, contexts })), appIcon = icon.findings.map((finding) => appIconFinding(inputs, texts, finding)), digests = designDigests(texts, assets, inputs.dsRoot), constructions = {
|
|
121
|
+
cache: projectConstructionCache(inputs.cacheOwner),
|
|
122
|
+
root: inputs.dsRoot,
|
|
123
|
+
catalog: assets,
|
|
124
|
+
whole: wholeDesignDigests(foundation, digests.assets),
|
|
125
|
+
tokens: digests.tokens,
|
|
126
|
+
tally: { reused: 0, built: 0 }
|
|
127
|
+
}, reuse = ownerReuse({
|
|
119
128
|
cache: projectOwnerCache(inputs.cacheOwner),
|
|
120
129
|
scenarios: projectScenarioCache(inputs.cacheOwner),
|
|
121
130
|
root: inputs.dsRoot,
|
|
@@ -123,7 +132,8 @@ async function analyzeRevision(inputs, captured, settings) {
|
|
|
123
132
|
framework: inputs.framework ?? null,
|
|
124
133
|
contexts,
|
|
125
134
|
foundation,
|
|
126
|
-
|
|
135
|
+
assets,
|
|
136
|
+
design: digests,
|
|
127
137
|
environment: revisionEnvironment()
|
|
128
138
|
}), options = {
|
|
129
139
|
foundation,
|
|
@@ -135,8 +145,12 @@ async function analyzeRevision(inputs, captured, settings) {
|
|
|
135
145
|
publicAlias: inputs.publicAlias,
|
|
136
146
|
framework: inputs.framework ?? null,
|
|
137
147
|
stats: analysis,
|
|
138
|
-
cache: extractionCache(inputs.cacheOwner, inputs.cacheLimits)
|
|
139
|
-
|
|
148
|
+
cache: extractionCache(inputs.cacheOwner, inputs.cacheLimits),
|
|
149
|
+
constructions
|
|
150
|
+
}, styling = { ...scenarioWork.styling }, analyzed = await checkDesignSystem(inputs.dsRoot, options, reuse.owners);
|
|
151
|
+
timing.recordStage("construction-reuse", 0, { ...constructions.tally });
|
|
152
|
+
timing.recordStage("scenario-styling", 0, { computed: scenarioWork.styling.computed - styling.computed, reused: scenarioWork.styling.reused - styling.reused });
|
|
153
|
+
const tally = reuse.tally();
|
|
140
154
|
owners.last = tally;
|
|
141
155
|
if (tally !== null) {
|
|
142
156
|
owners.analyzed += tally.analyzed.length;
|
package/dist/owner-errors.mjs
CHANGED
|
@@ -95,9 +95,8 @@ export function constructionError(failure) {
|
|
|
95
95
|
case "surface-shadow-layer":
|
|
96
96
|
case "content-missing":
|
|
97
97
|
case "profile-provider-conflict":
|
|
98
|
-
case "parts-visual-repeated":
|
|
99
98
|
case "artwork-binding-missing":
|
|
100
|
-
case "paint-
|
|
99
|
+
case "artwork-paint-contrast-insufficient":
|
|
101
100
|
case "spatial-token-expected":
|
|
102
101
|
case "spatial-bound-unit":
|
|
103
102
|
case "spatial-clause-unsupported":
|
|
@@ -121,8 +120,11 @@ export function constructionError(failure) {
|
|
|
121
120
|
case "enter-surface-unsupported":
|
|
122
121
|
case "enter-property-conflict":
|
|
123
122
|
case "pseudo-surface-unsupported":
|
|
123
|
+
case "state-geometry-unsupported":
|
|
124
124
|
case "placeholder-contrast-insufficient":
|
|
125
125
|
case "placeholder-contrast-unresolved":
|
|
126
|
+
case "progress-contrast-insufficient":
|
|
127
|
+
case "progress-contrast-unresolved":
|
|
126
128
|
case "state-contrast-insufficient":
|
|
127
129
|
case "inactive-surface-active":
|
|
128
130
|
case "target-size-below-minimum":
|
package/dist/owner-lowering.mjs
CHANGED
|
@@ -3,7 +3,9 @@ import { reducedMotionPolicy } from "./lowering-motion.mjs";
|
|
|
3
3
|
import { attempt } from "./result.mjs";
|
|
4
4
|
import { tokenValueContexts } from "./design-foundation.mjs";
|
|
5
5
|
import { lengthPx } from "./css-length.mjs";
|
|
6
|
+
import { inactiveCondition, NON_TEXT_MINIMUM, paintContrast } from "./paint-contrast.mjs";
|
|
6
7
|
import { normalizedDeclarations, scaleValue } from "./construction-spec.mjs";
|
|
8
|
+
import { frameValues } from "./region-lowering.mjs";
|
|
7
9
|
import { FRAME_INSET_FIELDS } from "./lowering-region-layout.mjs";
|
|
8
10
|
import {
|
|
9
11
|
HIT_AREA_FIELDS,
|
|
@@ -51,7 +53,7 @@ export function controlEnvelope(spec, line, visual, gap) {
|
|
|
51
53
|
}
|
|
52
54
|
export function lowerControl(spec, foundation, input) {
|
|
53
55
|
return attempt((reject) => {
|
|
54
|
-
const profile = profiles(foundation, reject), selected = profile.select(spec.profile, spec.select), slots = Object.fromEntries(selected.fields), text = profile.of(spec.text ?? slots["text-profile"], "text", spec.profile), frame = profile.of(slots["frame-profile"], "frame", spec.profile), spacing = profile.of(slots["spacing-profile"], "spacing", spec.profile), visual = profile.of(slots["visual-profile"], "visual", spec.profile), focus = profile.of(slots["focus-profile"], "focus", spec.profile), animated = spec.glyph !== null && (spec.glyph.transition.length > 0 || spec.glyph.when.length > 0), pressed = spec.press.when.length > 0, motion = animated || pressed || slots["motion-profile"] !== void 0 ? profile.of(slots["motion-profile"], "motion", spec.profile) : {};
|
|
56
|
+
const profile = profiles(foundation, reject), selected = profile.select(spec.profile, spec.select), slots = Object.fromEntries(selected.fields), text = profile.of(spec.text ?? slots["text-profile"], "text", spec.profile), frame = profile.of(slots["frame-profile"], "frame", spec.profile), spacing = profile.of(slots["spacing-profile"], "spacing", spec.profile), visual = profile.of(slots["visual-profile"], "visual", spec.profile), focus = profile.of(slots["focus-profile"], "focus", spec.profile), animated = spec.glyph !== null && (spec.glyph.transition.length > 0 || spec.glyph.when.length > 0) || spec.decor.some((box) => box.when.some(([, , effects]) => effects.length > 0)), pressed = spec.press.when.length > 0, motion = animated || pressed || slots["motion-profile"] !== void 0 ? profile.of(slots["motion-profile"], "motion", spec.profile) : {};
|
|
55
57
|
if (animated || pressed || slots["motion-profile"] !== void 0) {
|
|
56
58
|
const reduced = reducedMotionPolicy(motion.reduced);
|
|
57
59
|
if (reduced.kind === "unsupported")
|
|
@@ -70,11 +72,11 @@ export function lowerControl(spec, foundation, input) {
|
|
|
70
72
|
if (line !== void 0 && spec.normalize.some(([property]) => property === "border-style"))
|
|
71
73
|
return reject({ kind: "extent-conflict", element: "&", property: "border-style", providers: ["frame profile", "normalize"] });
|
|
72
74
|
const minInline = frame["min-inline-size"], { asset, hasText } = input;
|
|
73
|
-
if (!hasText && asset === null)
|
|
75
|
+
if (!hasText && asset === null && spec.decor.length === 0)
|
|
74
76
|
return reject({ kind: "content-missing" });
|
|
75
|
-
if (asset !== null && asset.paint
|
|
76
|
-
|
|
77
|
-
const geometry = asset === null ? null : visualPart(asset, visual, input.state, LIGHT, reject), at = (fields, name, owner) => profile.field(fields, owner, name), lineHeight = at(text, "line-height", "text"), gap = at(spacing, "content-gap", "spacing"), box = controlBox(frame, controlEnvelope(spec, hasText ? LINE_BOX : null, geometry?.extent ?? null, gap), profile.field, reject), keepsWidth = hasText && spec.label
|
|
77
|
+
if (asset !== null && asset.paint === "slots")
|
|
78
|
+
slotArtworkContrast(foundation, asset, spec, (name) => profile.of(name, "surface"), reject);
|
|
79
|
+
const geometry = asset === null ? null : visualPart(asset, visual, input.state, input.theme ?? LIGHT, reject), at = (fields, name, owner) => profile.field(fields, owner, name), lineHeight = at(text, "line-height", "text"), gap = at(spacing, "content-gap", "spacing"), box = controlBox(frame, controlEnvelope(spec, hasText ? LINE_BOX : null, geometry?.extent ?? null, gap), profile.field, reject), keepsWidth = hasText && spec.label?.wrap === "never";
|
|
78
80
|
out.rule("&", {
|
|
79
81
|
...controlArrangement(spec),
|
|
80
82
|
...spec.extent === "container" && spec.layout !== "native" ? { display: "flex", "inline-size": "100%" } : {},
|
|
@@ -114,17 +116,20 @@ export function lowerControl(spec, foundation, input) {
|
|
|
114
116
|
"outline-style": "solid"
|
|
115
117
|
});
|
|
116
118
|
const { label, glyph } = spec;
|
|
117
|
-
|
|
119
|
+
for (const box of spec.decor)
|
|
120
|
+
lowerDecor(out, box, profile, motion, reject);
|
|
121
|
+
if (hasText && label !== null) {
|
|
118
122
|
const trim = label.textEdge.length === 0 ? {} : { "text-box-trim": "trim-both", "text-box-edge": label.textEdge.join(" ") }, wrap = label.wrap === "never" ? { "white-space": "nowrap" } : { "min-inline-size": "0", "overflow-wrap": label.wrap === "anywhere" ? "anywhere" : "break-word" };
|
|
119
|
-
out.rule(`& > ${label.selector}`, { ...wrap, ...trim });
|
|
123
|
+
out.rule(`& > ${label.selector}`, { ...wrap, ...trim, ...label.align === null ? {} : { "text-align": label.align } });
|
|
120
124
|
}
|
|
121
125
|
if (geometry !== null && glyph !== null) {
|
|
122
|
-
const part = `& > ${glyph.selector}
|
|
126
|
+
const part = `& > ${glyph.selector}`, turns = glyph.when.some(([, effects]) => effects.some((effect) => effect.effect === "rotate"));
|
|
123
127
|
out.rule(part, {
|
|
124
128
|
...geometry.part,
|
|
125
129
|
...animated ? {
|
|
126
130
|
translate: "0px",
|
|
127
131
|
scale: "1",
|
|
132
|
+
...turns ? { rotate: "0deg" } : {},
|
|
128
133
|
...glyph.transition.length > 0 ? {
|
|
129
134
|
"transition-property": glyph.transition.join(", "),
|
|
130
135
|
"transition-duration": at(motion, "duration", "motion"),
|
|
@@ -133,12 +138,16 @@ export function lowerControl(spec, foundation, input) {
|
|
|
133
138
|
} : {}
|
|
134
139
|
} : {}
|
|
135
140
|
});
|
|
136
|
-
out.rule(`${part} >
|
|
141
|
+
out.rule(`${part} > ${geometry.element}`, geometry.media);
|
|
142
|
+
if (asset !== null && asset.paint === "slots")
|
|
143
|
+
out.paint(glyph.selector, [...asset.slots].map(([slot, value]) => ({ slot, paint: value === "currentColor" ? { kind: "current-color" } : { kind: "token", name: value } })));
|
|
137
144
|
for (const [condition, effects] of glyph.when) {
|
|
138
145
|
const values = {};
|
|
139
146
|
for (const effect of effects)
|
|
140
147
|
if (effect.effect === "translate-inline")
|
|
141
148
|
values.translate = at(motion, effect.field, "motion");
|
|
149
|
+
else if (effect.effect === "rotate")
|
|
150
|
+
values.rotate = at(motion, effect.field, "motion");
|
|
142
151
|
else
|
|
143
152
|
values.scale = scaleValue(effect.effect, at(motion, effect.field, "motion"));
|
|
144
153
|
out.rule(`${condition} > ${glyph.selector}`, values);
|
|
@@ -149,12 +158,61 @@ export function lowerControl(spec, foundation, input) {
|
|
|
149
158
|
if (inline !== void 0)
|
|
150
159
|
out.rule(`${condition}:dir(rtl) > ${glyph.selector}`, { translate: "0px" }, reduced);
|
|
151
160
|
}
|
|
152
|
-
const moved = [...new Set(glyph.when.flatMap(([, effects]) => effects.map((effect) => effect.effect === "translate-inline" ? "translate" : "scale")))];
|
|
161
|
+
const moved = [...new Set(glyph.when.flatMap(([, effects]) => effects.map((effect) => effect.effect === "translate-inline" ? "translate" : effect.effect === "rotate" ? "rotate" : "scale")))];
|
|
153
162
|
writePlays(out, profile, foundation, glyph.name, glyph.plays, part, moved, reject);
|
|
154
163
|
}
|
|
155
164
|
return out.finish({ kind: "control", artwork: geometry === null ? null : placed(geometry), targets: { elements: [target], neighbours: [] } }, input.hidden);
|
|
156
165
|
});
|
|
157
166
|
}
|
|
167
|
+
function lowerDecor(out, box, profile, motion, reject) {
|
|
168
|
+
const path = `& > ${box.selector}`, base = box.surface === null ? {} : profile.of(box.surface, "surface"), moved = new Set(box.when.flatMap(([, , effects]) => effects.map((effect) => effect.effect === "translate-inline" ? "translate" : "scale"))), timing = box.transition.length === 0 ? {} : {
|
|
169
|
+
"transition-property": box.transition.join(", "),
|
|
170
|
+
"transition-duration": profile.field(motion, "motion", "duration"),
|
|
171
|
+
...motion.delay === void 0 ? {} : { "transition-delay": motion.delay },
|
|
172
|
+
"transition-timing-function": profile.field(motion, "motion", "easing")
|
|
173
|
+
};
|
|
174
|
+
out.rule(path, {
|
|
175
|
+
"box-sizing": "border-box",
|
|
176
|
+
"flex-grow": "0",
|
|
177
|
+
"flex-shrink": "0",
|
|
178
|
+
"flex-basis": "auto",
|
|
179
|
+
...frameValues(profile.of(box.box, "frame"), profile, reject),
|
|
180
|
+
...settled(base, !1),
|
|
181
|
+
...moved.has("translate") ? { translate: "0px" } : {},
|
|
182
|
+
...moved.has("scale") ? { scale: "1" } : {},
|
|
183
|
+
...timing
|
|
184
|
+
});
|
|
185
|
+
for (const [condition, surface, effects] of box.when) {
|
|
186
|
+
const values = surface === null ? {} : { ...settled(profile.of(surface, "surface"), !1) };
|
|
187
|
+
for (const effect of effects) {
|
|
188
|
+
const value = profile.field(motion, "motion", effect.field);
|
|
189
|
+
if (effect.effect === "translate-inline")
|
|
190
|
+
values.translate = value;
|
|
191
|
+
else if (effect.effect !== "rotate")
|
|
192
|
+
values.scale = scaleValue(effect.effect, value);
|
|
193
|
+
}
|
|
194
|
+
out.rule(`${condition} > ${box.selector}`, values);
|
|
195
|
+
const inline = effects.find((effect) => effect.effect === "translate-inline");
|
|
196
|
+
if (inline !== void 0)
|
|
197
|
+
out.rule(`${condition}:dir(rtl) > ${box.selector}`, { translate: `calc(${profile.field(motion, "motion", inline.field)} * -1)` });
|
|
198
|
+
}
|
|
199
|
+
if (box.transition.length > 0)
|
|
200
|
+
out.rule(path, { "transition-duration": "0s", "transition-delay": "0s" }, ["media", "(prefers-reduced-motion: reduce)"]);
|
|
201
|
+
}
|
|
202
|
+
function slotArtworkContrast(foundation, asset, spec, surface, reject) {
|
|
203
|
+
const base = surface(spec.surface), states = [[null, base], ...spec.when.filter(([condition]) => !inactiveCondition(condition)).map(([condition, name]) => [condition, surface(name)])];
|
|
204
|
+
for (const context of tokenValueContexts(foundation))
|
|
205
|
+
for (const [condition, fields] of states) {
|
|
206
|
+
const background = fields.background ?? base.background;
|
|
207
|
+
if (background === void 0)
|
|
208
|
+
continue;
|
|
209
|
+
const paints = [...asset.slots.values()].map((value) => value === "currentColor" ? fields.color ?? base.color ?? null : `var(${value})`).filter((value) => value !== null), outcomes = paints.map((foreground) => paintContrast(context, { foreground, background }, NON_TEXT_MINIMUM));
|
|
210
|
+
if (outcomes.some((outcome) => outcome.kind !== "insufficient"))
|
|
211
|
+
continue;
|
|
212
|
+
const ratio = Math.max(...outcomes.map((outcome) => outcome.kind === "insufficient" ? outcome.ratio : 0));
|
|
213
|
+
return reject({ kind: "artwork-paint-contrast-insufficient", asset: asset.name, context: context.label, state: condition, background, paints, ratio, minimum: NON_TEXT_MINIMUM });
|
|
214
|
+
}
|
|
215
|
+
}
|
|
158
216
|
function drawnHeight(foundation, asset, visual, reject) {
|
|
159
217
|
const minimum = asset.spec.minDrawnHeight;
|
|
160
218
|
if (minimum === void 0)
|
|
@@ -178,8 +236,9 @@ export function lowerArtwork(spec, foundation, input) {
|
|
|
178
236
|
const profile = profiles(foundation, reject), { asset, visualProfile, theme } = input;
|
|
179
237
|
if (asset === null || visualProfile === null)
|
|
180
238
|
return reject({ kind: "artwork-binding-missing" });
|
|
181
|
-
const visual = profile.of(visualProfile, "visual"), geometry = visualPart(asset, visual, input.state, theme, reject), out = output(input.root, "lowerArtwork", reject, profile), height = drawnHeight(foundation, asset, visual, reject), { part } = spec;
|
|
182
|
-
|
|
239
|
+
const visual = profile.of(visualProfile, "visual"), geometry = visualPart(asset, visual, input.state, theme, reject), out = output(input.root, "lowerArtwork", reject, profile), height = drawnHeight(foundation, asset, visual, reject), { part } = spec, tone = spec.surface === null ? {} : profile.of(spec.surface, "surface");
|
|
240
|
+
profile.only(tone, "surface", ["color"]);
|
|
241
|
+
out.rule("&", { display: "inline-flex", "align-items": spec.align, "justify-content": "center", "min-inline-size": "0", ...tone.color === void 0 ? {} : { color: tone.color } });
|
|
183
242
|
out.rule(`& > ${part.selector}`, geometry.part);
|
|
184
243
|
out.rule(`& > ${part.selector} > ${geometry.element}`, geometry.media);
|
|
185
244
|
if (asset.paint === "slots")
|
package/dist/owner-scenarios.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { throwIfCancelled } from "./analysis/context.mjs";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
import { isAuthoring, publicExports } from "./analysis/owner-discovery.mjs";
|
|
3
4
|
import { location, memoProgram, symbolAt, unalias, valueSymbolAt, walk } from "./analysis/helpers.mjs";
|
|
@@ -818,8 +819,10 @@ export async function scenarioFindings(options, reuse = null) {
|
|
|
818
819
|
const files = sourceFiles(options.dsRoot, options).filter(isScenarioFile).sort();
|
|
819
820
|
let program;
|
|
820
821
|
const compute = async (file) => factsOf(options, await (program ??= reuse === null ? scenarioProgram(options, files) : Promise.resolve(reuse.program)), file), keys = reuse === null ? null : await revisionScenarioKeys({ dsRoot: options.dsRoot, publicAlias: options.config.publicAlias, framework: options.config.framework ?? null, graph: reuse.graph, globals: reuse.globals }), cache = reuse === null || keys === null ? null : projectScenarioCache(reuse.cacheOwner), facts = [];
|
|
821
|
-
for (const file of files)
|
|
822
|
+
for (const file of files) {
|
|
823
|
+
throwIfCancelled();
|
|
822
824
|
facts.push(await obtainScenarioResult(cache, options.dsRoot, keys?.get(path.relative(options.dsRoot, file).split(path.sep).join("/")), "facts", () => compute(file)));
|
|
825
|
+
}
|
|
823
826
|
const { diagnostics, registered } = assemble(options, files, facts.map((fact) => fact.registration)), unreadable = diagnostics.some((diagnostic) => diagnostic.rule === "scenario-metadata"), scenarios = registered.filter(({ entry }) => entry.kind !== "mocks").map(({ file, entry }) => ({ file: projectPath(options, file), covers: [...entry.covers] })), coverage = scenarioCoverage(options, { scenarios }, exports.value).filter((finding) => !(unreadable && finding.rule === "scenario-coverage")), unrendered = new Map(files.map((file, index) => [file, facts[index]?.unrendered ?? null])), renders = registered.flatMap(({ file }) => (unrendered.get(file) ?? []).filter(({ name }) => exports.value.names.has(name)).map(({ name, line, column }) => ({
|
|
824
827
|
rule: "scenario-render",
|
|
825
828
|
file: projectPath(options, file),
|